diff --git a/README.md b/README.md index c96597ab..e233e3a0 100644 --- a/README.md +++ b/README.md @@ -606,6 +606,7 @@ To learn how to generate the token, see the [OAuth 2.0 Scopes](https://developer | fileFormat | The format of the output file. | string | csv | false | | resource | The resource to pull from OneTrust. For now, only assessments is supported. | string | assessments | false | | debug | Whether to print detailed logs in case of error. | boolean | false | false | +| dryRun | Whether to export the resource to a file rather than sync to Transcend. | boolean | false | false | #### Usage diff --git a/package.json b/package.json index a12d380a..c06e3f76 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "tr-pull-consent-metrics": "./build/cli-pull-consent-metrics.js", "tr-pull-consent-preferences": "./build/cli-pull-consent-preferences.js", "tr-pull-datapoints": "./build/cli-pull-datapoints.js", - "tr-sync-ot": "./build/cli-sync-ot.js", "tr-push": "./build/cli-push.js", "tr-request-approve": "./build/cli-request-approve.js", "tr-request-cancel": "./build/cli-request-cancel.js", @@ -42,6 +41,7 @@ "tr-retry-request-data-silos": "./build/cli-retry-request-data-silos.js", "tr-scan-packages": "./build/cli-scan-packages.js", "tr-skip-request-data-silos": "./build/cli-skip-request-data-silos.js", + "tr-sync-ot": "./build/cli-sync-ot.js", "tr-update-consent-manager": "./build/cli-update-consent-manager-to-latest.js", "tr-upload-consent-preferences": "./build/cli-upload-consent-preferences.js", "tr-upload-cookies-from-csv": "./build/cli-upload-cookies-from-csv.js", diff --git a/src/cli-sync-ot.ts b/src/cli-sync-ot.ts index b62abcc7..771418c3 100644 --- a/src/cli-sync-ot.ts +++ b/src/cli-sync-ot.ts @@ -5,7 +5,7 @@ import { getListOfOneTrustAssessments, getOneTrustAssessment, writeOneTrustAssessment, - parseCliPullOtArguments, + parseCliSyncOtArguments, createOneTrustGotInstance, getOneTrustRisk, } from './oneTrust'; @@ -29,7 +29,7 @@ import { */ async function main(): Promise { const { file, fileFormat, hostname, auth, resource } = - parseCliPullOtArguments(); + parseCliSyncOtArguments(); // try { // TODO: move to helper function diff --git a/src/oneTrust/index.ts b/src/oneTrust/index.ts index e98e34fe..5c921384 100644 --- a/src/oneTrust/index.ts +++ b/src/oneTrust/index.ts @@ -1,6 +1,6 @@ export * from './createOneTrustGotInstance'; export * from './getOneTrustAssessment'; export * from './writeOneTrustAssessment'; -export * from './parseCliPullOtArguments'; +export * from './parseCliSyncOtArguments'; export * from './getListOfOneTrustAssessments'; export * from './getOneTrustRisk'; diff --git a/src/oneTrust/parseCliPullOtArguments.ts b/src/oneTrust/parseCliPullOtArguments.ts deleted file mode 100644 index 4d31cbc3..00000000 --- a/src/oneTrust/parseCliPullOtArguments.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { logger } from '../logger'; -import colors from 'colors'; -import yargs from 'yargs-parser'; -import { OneTrustFileFormat, OneTrustPullResource } from '../enums'; - -const VALID_RESOURCES = Object.values(OneTrustPullResource); -const VALID_FILE_FORMATS = Object.values(OneTrustFileFormat); - -interface OneTrustCliArguments { - /** The name of the file to write the resources to */ - file: string; - /** The OneTrust hostname to send the requests to */ - hostname: string; - /** The OAuth Bearer token used to authenticate the requests */ - auth: string; - /** The resource to pull from OneTrust */ - resource: OneTrustPullResource; - /** Whether to enable debugging while reporting errors */ - debug: boolean; - /** The export format of the file where to save the resources */ - fileFormat: OneTrustFileFormat; -} - -/** - * Parse the command line arguments - * - * @returns the parsed arguments - */ -export const parseCliPullOtArguments = (): OneTrustCliArguments => { - const { file, hostname, auth, resource, debug, fileFormat } = yargs( - process.argv.slice(2), - { - string: ['file', 'hostname', 'auth', 'resource', 'fileFormat'], - boolean: ['debug'], - default: { - resource: OneTrustPullResource.Assessments, - fileFormat: OneTrustFileFormat.Csv, - debug: false, - }, - }, - ); - - if (!file) { - logger.error( - colors.red( - 'Missing required parameter "file". e.g. --file=./oneTrustAssessments.json', - ), - ); - return process.exit(1); - } - const splitFile = file.split('.'); - if (splitFile.length < 2) { - logger.error( - colors.red( - 'The "file" parameter has an invalid format. Expected a path with extensions. e.g. --file=./pathToFile.json.', - ), - ); - return process.exit(1); - } - if (splitFile.at(-1) !== fileFormat) { - logger.error( - colors.red( - `The "file" and "fileFormat" parameters must specify the same format! Got file=${file} and fileFormat=${fileFormat}`, - ), - ); - return process.exit(1); - } - - if (!hostname) { - logger.error( - colors.red( - 'Missing required parameter "hostname". e.g. --hostname=customer.my.onetrust.com', - ), - ); - return process.exit(1); - } - - if (!auth) { - logger.error( - colors.red( - 'Missing required parameter "auth". e.g. --auth=$ONE_TRUST_AUTH_TOKEN', - ), - ); - return process.exit(1); - } - if (!VALID_RESOURCES.includes(resource)) { - logger.error( - colors.red( - `Received invalid resource value: "${resource}". Allowed: ${VALID_RESOURCES.join( - ',', - )}`, - ), - ); - return process.exit(1); - } - if (!VALID_FILE_FORMATS.includes(fileFormat)) { - logger.error( - colors.red( - `Received invalid fileFormat value: "${fileFormat}". Allowed: ${VALID_FILE_FORMATS.join( - ',', - )}`, - ), - ); - return process.exit(1); - } - - return { - file, - hostname, - auth, - resource, - debug, - fileFormat, - }; -}; diff --git a/yarn.lock b/yarn.lock index 806d32ab..12dc0ff7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -593,7 +593,6 @@ __metadata: tr-pull-consent-metrics: ./build/cli-pull-consent-metrics.js tr-pull-consent-preferences: ./build/cli-pull-consent-preferences.js tr-pull-datapoints: ./build/cli-pull-datapoints.js - tr-pull-ot: ./build/cli-pull-ot.js tr-push: ./build/cli-push.js tr-request-approve: ./build/cli-request-approve.js tr-request-cancel: ./build/cli-request-cancel.js @@ -607,6 +606,7 @@ __metadata: tr-retry-request-data-silos: ./build/cli-retry-request-data-silos.js tr-scan-packages: ./build/cli-scan-packages.js tr-skip-request-data-silos: ./build/cli-skip-request-data-silos.js + tr-sync-ot: ./build/cli-sync-ot.js tr-update-consent-manager: ./build/cli-update-consent-manager-to-latest.js tr-upload-consent-preferences: ./build/cli-upload-consent-preferences.js tr-upload-cookies-from-csv: ./build/cli-upload-cookies-from-csv.js