@transcend-io/cli 6.13.2 → 6.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +40 -13
  2. package/build/cli-sync-ot.d.ts +3 -0
  3. package/build/cli-sync-ot.d.ts.map +1 -0
  4. package/build/cli-sync-ot.js +56 -0
  5. package/build/cli-sync-ot.js.map +1 -0
  6. package/build/codecs.d.ts +46 -0
  7. package/build/codecs.d.ts.map +1 -1
  8. package/build/codecs.js +28 -1
  9. package/build/codecs.js.map +1 -1
  10. package/build/graphql/fetchAllRequestIdentifiers.d.ts +2 -0
  11. package/build/graphql/fetchAllRequestIdentifiers.d.ts.map +1 -1
  12. package/build/graphql/gqls/assessment.d.ts +1 -0
  13. package/build/graphql/gqls/assessment.d.ts.map +1 -1
  14. package/build/graphql/gqls/assessment.js +13 -1
  15. package/build/graphql/gqls/assessment.js.map +1 -1
  16. package/build/graphql/parseAssessmentRiskLogic.d.ts +3 -1
  17. package/build/graphql/parseAssessmentRiskLogic.d.ts.map +1 -1
  18. package/build/graphql/parseAssessmentRiskLogic.js +3 -1
  19. package/build/graphql/parseAssessmentRiskLogic.js.map +1 -1
  20. package/build/graphql/pullTranscendConfiguration.d.ts.map +1 -1
  21. package/build/graphql/pullTranscendConfiguration.js +3 -1
  22. package/build/graphql/pullTranscendConfiguration.js.map +1 -1
  23. package/build/oneTrust/{getListOfAssessments.d.ts → endpoints/getListOfOneTrustAssessments.d.ts} +4 -3
  24. package/build/oneTrust/endpoints/getListOfOneTrustAssessments.d.ts.map +1 -0
  25. package/build/oneTrust/{getListOfAssessments.js → endpoints/getListOfOneTrustAssessments.js} +9 -7
  26. package/build/oneTrust/endpoints/getListOfOneTrustAssessments.js.map +1 -0
  27. package/build/oneTrust/{getAssessment.d.ts → endpoints/getOneTrustAssessment.d.ts} +4 -3
  28. package/build/oneTrust/endpoints/getOneTrustAssessment.d.ts.map +1 -0
  29. package/build/oneTrust/endpoints/getOneTrustAssessment.js +18 -0
  30. package/build/oneTrust/endpoints/getOneTrustAssessment.js.map +1 -0
  31. package/build/oneTrust/endpoints/getOneTrustRisk.d.ts +16 -0
  32. package/build/oneTrust/endpoints/getOneTrustRisk.d.ts.map +1 -0
  33. package/build/oneTrust/endpoints/getOneTrustRisk.js +18 -0
  34. package/build/oneTrust/endpoints/getOneTrustRisk.js.map +1 -0
  35. package/build/oneTrust/endpoints/getOneTrustUser.d.ts +16 -0
  36. package/build/oneTrust/endpoints/getOneTrustUser.d.ts.map +1 -0
  37. package/build/oneTrust/endpoints/getOneTrustUser.js +18 -0
  38. package/build/oneTrust/endpoints/getOneTrustUser.js.map +1 -0
  39. package/build/oneTrust/endpoints/index.d.ts +5 -0
  40. package/build/oneTrust/endpoints/index.d.ts.map +1 -0
  41. package/build/oneTrust/endpoints/index.js +21 -0
  42. package/build/oneTrust/endpoints/index.js.map +1 -0
  43. package/build/oneTrust/helpers/constants.d.ts +3 -0
  44. package/build/oneTrust/helpers/constants.d.ts.map +1 -0
  45. package/build/oneTrust/helpers/constants.js +15 -0
  46. package/build/oneTrust/helpers/constants.js.map +1 -0
  47. package/build/oneTrust/helpers/convertToEmptyStrings.d.ts +34 -0
  48. package/build/oneTrust/helpers/convertToEmptyStrings.d.ts.map +1 -0
  49. package/build/oneTrust/helpers/convertToEmptyStrings.js +58 -0
  50. package/build/oneTrust/helpers/convertToEmptyStrings.js.map +1 -0
  51. package/build/oneTrust/helpers/enrichOneTrustAssessment.d.ts +22 -0
  52. package/build/oneTrust/helpers/enrichOneTrustAssessment.d.ts.map +1 -0
  53. package/build/oneTrust/helpers/enrichOneTrustAssessment.js +95 -0
  54. package/build/oneTrust/helpers/enrichOneTrustAssessment.js.map +1 -0
  55. package/build/oneTrust/helpers/flattenOneTrustAssessment.d.ts +5 -0
  56. package/build/oneTrust/helpers/flattenOneTrustAssessment.d.ts.map +1 -0
  57. package/build/oneTrust/helpers/flattenOneTrustAssessment.js +136 -0
  58. package/build/oneTrust/helpers/flattenOneTrustAssessment.js.map +1 -0
  59. package/build/oneTrust/helpers/index.d.ts +4 -0
  60. package/build/oneTrust/helpers/index.d.ts.map +1 -0
  61. package/build/oneTrust/helpers/index.js +20 -0
  62. package/build/oneTrust/helpers/index.js.map +1 -0
  63. package/build/oneTrust/helpers/oneTrustAssessmentToCsv.d.ts +14 -0
  64. package/build/oneTrust/helpers/oneTrustAssessmentToCsv.d.ts.map +1 -0
  65. package/build/oneTrust/helpers/oneTrustAssessmentToCsv.js +25 -0
  66. package/build/oneTrust/helpers/oneTrustAssessmentToCsv.js.map +1 -0
  67. package/build/oneTrust/helpers/oneTrustAssessmentToCsvRecord.d.ts +10 -0
  68. package/build/oneTrust/helpers/oneTrustAssessmentToCsvRecord.d.ts.map +1 -0
  69. package/build/oneTrust/helpers/oneTrustAssessmentToCsvRecord.js +38 -0
  70. package/build/oneTrust/helpers/oneTrustAssessmentToCsvRecord.js.map +1 -0
  71. package/build/oneTrust/helpers/oneTrustAssessmentToJson.d.ts +18 -0
  72. package/build/oneTrust/helpers/oneTrustAssessmentToJson.d.ts.map +1 -0
  73. package/build/oneTrust/helpers/oneTrustAssessmentToJson.js +28 -0
  74. package/build/oneTrust/helpers/oneTrustAssessmentToJson.js.map +1 -0
  75. package/build/oneTrust/{parseCliPullOtArguments.d.ts → helpers/parseCliSyncOtArguments.d.ts} +11 -5
  76. package/build/oneTrust/helpers/parseCliSyncOtArguments.d.ts.map +1 -0
  77. package/build/oneTrust/helpers/parseCliSyncOtArguments.js +109 -0
  78. package/build/oneTrust/helpers/parseCliSyncOtArguments.js.map +1 -0
  79. package/build/oneTrust/{writeOneTrustAssessment.d.ts → helpers/syncOneTrustAssessmentToDisk.d.ts} +5 -7
  80. package/build/oneTrust/helpers/syncOneTrustAssessmentToDisk.d.ts.map +1 -0
  81. package/build/oneTrust/helpers/syncOneTrustAssessmentToDisk.js +49 -0
  82. package/build/oneTrust/helpers/syncOneTrustAssessmentToDisk.js.map +1 -0
  83. package/build/oneTrust/helpers/syncOneTrustAssessmentToTranscend.d.ts +25 -0
  84. package/build/oneTrust/helpers/syncOneTrustAssessmentToTranscend.d.ts.map +1 -0
  85. package/build/oneTrust/helpers/syncOneTrustAssessmentToTranscend.js +35 -0
  86. package/build/oneTrust/helpers/syncOneTrustAssessmentToTranscend.js.map +1 -0
  87. package/build/oneTrust/helpers/syncOneTrustAssessments.d.ts +22 -0
  88. package/build/oneTrust/helpers/syncOneTrustAssessments.d.ts.map +1 -0
  89. package/build/oneTrust/helpers/syncOneTrustAssessments.js +125 -0
  90. package/build/oneTrust/helpers/syncOneTrustAssessments.js.map +1 -0
  91. package/build/oneTrust/helpers/tests/convertToEmptyStrings.test.d.ts +2 -0
  92. package/build/oneTrust/helpers/tests/convertToEmptyStrings.test.d.ts.map +1 -0
  93. package/build/oneTrust/helpers/tests/convertToEmptyStrings.test.js +74 -0
  94. package/build/oneTrust/helpers/tests/convertToEmptyStrings.test.js.map +1 -0
  95. package/build/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.d.ts +2 -0
  96. package/build/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.d.ts.map +1 -0
  97. package/build/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.js +592 -0
  98. package/build/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.js.map +1 -0
  99. package/build/oneTrust/index.d.ts +2 -4
  100. package/build/oneTrust/index.d.ts.map +1 -1
  101. package/build/oneTrust/index.js +2 -4
  102. package/build/oneTrust/index.js.map +1 -1
  103. package/build/tsbuildinfo +1 -1
  104. package/package.json +4 -4
  105. package/build/cli-pull-ot.d.ts +0 -3
  106. package/build/cli-pull-ot.d.ts.map +0 -1
  107. package/build/cli-pull-ot.js +0 -55
  108. package/build/cli-pull-ot.js.map +0 -1
  109. package/build/oneTrust/getAssessment.d.ts.map +0 -1
  110. package/build/oneTrust/getAssessment.js +0 -15
  111. package/build/oneTrust/getAssessment.js.map +0 -1
  112. package/build/oneTrust/getListOfAssessments.d.ts.map +0 -1
  113. package/build/oneTrust/getListOfAssessments.js.map +0 -1
  114. package/build/oneTrust/parseCliPullOtArguments.d.ts.map +0 -1
  115. package/build/oneTrust/parseCliPullOtArguments.js +0 -67
  116. package/build/oneTrust/parseCliPullOtArguments.js.map +0 -1
  117. package/build/oneTrust/types.d.ts +0 -391
  118. package/build/oneTrust/types.d.ts.map +0 -1
  119. package/build/oneTrust/types.js +0 -4
  120. package/build/oneTrust/types.js.map +0 -1
  121. package/build/oneTrust/writeOneTrustAssessment.d.ts.map +0 -1
  122. package/build/oneTrust/writeOneTrustAssessment.js +0 -41
  123. package/build/oneTrust/writeOneTrustAssessment.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.oneTrustAssessmentToCsvRecord = void 0;
4
+ const type_utils_1 = require("@transcend-io/type-utils");
5
+ const constants_1 = require("./constants");
6
+ const flattenOneTrustAssessment_1 = require("./flattenOneTrustAssessment");
7
+ const privacy_types_1 = require("@transcend-io/privacy-types");
8
+ /**
9
+ * Converts the assessment into a csv record (i.e. a map from the csv header
10
+ * to values). It always returns a record with every key in the same order.
11
+ *
12
+ * @param assessment - the assessment to convert to a csv record
13
+ * @returns a stringified csv entry ready to be appended to a file
14
+ */
15
+ const oneTrustAssessmentToCsvRecord = (
16
+ /** The assessment to convert */
17
+ assessment) => {
18
+ // flatten the assessment object so it does not have nested properties
19
+ const flatAssessment = (0, flattenOneTrustAssessment_1.flattenOneTrustAssessment)(assessment);
20
+ /**
21
+ * transform the flat assessment to:
22
+ * 1. have every possible header. This is how the backend can tell it's a CLI, not Dashboard, import.
23
+ * 2. have the headers in the same order. This is fundamental for constructing a CSV file.
24
+ */
25
+ const flatAssessmentFull = Object.fromEntries(constants_1.DEFAULT_ONE_TRUST_ASSESSMENT_CSV_HEADER.map((header) => {
26
+ var _a;
27
+ const value = (_a = flatAssessment[header]) !== null && _a !== void 0 ? _a : '';
28
+ const escapedValue = typeof value === 'string' &&
29
+ (value.includes(',') || value.includes('"'))
30
+ ? `"${value.replace(/"/g, '""')}"`
31
+ : value;
32
+ return [header, escapedValue];
33
+ }));
34
+ // ensure the record has the expected type!
35
+ return (0, type_utils_1.decodeCodec)(privacy_types_1.OneTrustAssessmentCsvRecord, flatAssessmentFull);
36
+ };
37
+ exports.oneTrustAssessmentToCsvRecord = oneTrustAssessmentToCsvRecord;
38
+ //# sourceMappingURL=oneTrustAssessmentToCsvRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneTrustAssessmentToCsvRecord.js","sourceRoot":"","sources":["../../../src/oneTrust/helpers/oneTrustAssessmentToCsvRecord.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AACvD,2CAAsE;AACtE,2EAAwE;AACxE,+DAGqC;AAErC;;;;;;GAMG;AACI,MAAM,6BAA6B,GAAG;AAC3C,gCAAgC;AAChC,UAAsC,EACT,EAAE;IAC/B,sEAAsE;IACtE,MAAM,cAAc,GAAG,IAAA,qDAAyB,EAAC,UAAU,CAAC,CAAC;IAE7D;;;;OAIG;IACH,MAAM,kBAAkB,GAAG,MAAM,CAAC,WAAW,CAC3C,mDAAuC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;;QACrD,MAAM,KAAK,GAAG,MAAA,cAAc,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAC;QAC3C,MAAM,YAAY,GAChB,OAAO,KAAK,KAAK,QAAQ;YACzB,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC1C,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;YAClC,CAAC,CAAC,KAAK,CAAC;QACZ,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAChC,CAAC,CAAC,CACH,CAAC;IAEF,2CAA2C;IAC3C,OAAO,IAAA,wBAAW,EAAC,2CAA2B,EAAE,kBAAkB,CAAC,CAAC;AACtE,CAAC,CAAC;AA1BW,QAAA,6BAA6B,iCA0BxC"}
@@ -0,0 +1,18 @@
1
+ import { OneTrustEnrichedAssessment } from '@transcend-io/privacy-types';
2
+ /**
3
+ * Converts the assessment into a json entry.
4
+ *
5
+ * @param param - information about the assessment and amount of entries
6
+ * @returns a stringified json entry ready to be appended to a file
7
+ */
8
+ export declare const oneTrustAssessmentToJson: ({ assessment, index, total, wrap, }: {
9
+ /** The assessment to convert */
10
+ assessment: OneTrustEnrichedAssessment;
11
+ /** The position of the assessment in the final Json object */
12
+ index: number;
13
+ /** The total amount of the assessments in the final Json object */
14
+ total: number;
15
+ /** Whether to wrap every entry in brackets */
16
+ wrap?: boolean | undefined;
17
+ }) => string;
18
+ //# sourceMappingURL=oneTrustAssessmentToJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneTrustAssessmentToJson.d.ts","sourceRoot":"","sources":["../../../src/oneTrust/helpers/oneTrustAssessmentToJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;IAMnC,gCAAgC;gBACpB,0BAA0B;IACtC,8DAA8D;WACvD,MAAM;IACb,mEAAmE;WAC5D,MAAM;IACb,8CAA8C;;MAE5C,MAqBH,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.oneTrustAssessmentToJson = void 0;
4
+ /**
5
+ * Converts the assessment into a json entry.
6
+ *
7
+ * @param param - information about the assessment and amount of entries
8
+ * @returns a stringified json entry ready to be appended to a file
9
+ */
10
+ const oneTrustAssessmentToJson = ({ assessment, index, total, wrap = true, }) => {
11
+ let jsonEntry = '';
12
+ // start with an opening bracket
13
+ if (index === 0 || wrap) {
14
+ jsonEntry = '[\n';
15
+ }
16
+ const stringifiedAssessment = JSON.stringify(assessment, null, 2);
17
+ // Add comma for all items except the last one
18
+ const comma = index < total - 1 ? ',' : '';
19
+ // write to file
20
+ jsonEntry = jsonEntry + stringifiedAssessment + comma;
21
+ // end with closing bracket
22
+ if (index === total - 1 || wrap) {
23
+ jsonEntry += ']';
24
+ }
25
+ return jsonEntry;
26
+ };
27
+ exports.oneTrustAssessmentToJson = oneTrustAssessmentToJson;
28
+ //# sourceMappingURL=oneTrustAssessmentToJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneTrustAssessmentToJson.js","sourceRoot":"","sources":["../../../src/oneTrust/helpers/oneTrustAssessmentToJson.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CAAC,EACvC,UAAU,EACV,KAAK,EACL,KAAK,EACL,IAAI,GAAG,IAAI,GAUZ,EAAU,EAAE;IACX,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,gCAAgC;IAChC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,EAAE;QACvB,SAAS,GAAG,KAAK,CAAC;KACnB;IAED,MAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAElE,8CAA8C;IAC9C,MAAM,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3C,gBAAgB;IAChB,SAAS,GAAG,SAAS,GAAG,qBAAqB,GAAG,KAAK,CAAC;IAEtD,2BAA2B;IAC3B,IAAI,KAAK,KAAK,KAAK,GAAG,CAAC,IAAI,IAAI,EAAE;QAC/B,SAAS,IAAI,GAAG,CAAC;KAClB;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAnCW,QAAA,wBAAwB,4BAmCnC"}
@@ -1,23 +1,29 @@
1
- import { OneTrustFileFormat, OneTrustPullResource } from '../enums';
1
+ import { OneTrustFileFormat, OneTrustPullResource } from '../../enums';
2
2
  interface OneTrustCliArguments {
3
3
  /** The name of the file to write the resources to */
4
4
  file: string;
5
5
  /** The OneTrust hostname to send the requests to */
6
6
  hostname: string;
7
- /** The OAuth Bearer token used to authenticate the requests */
8
- auth: string;
7
+ /** The OAuth Bearer token used to authenticate the requests to OneTrust */
8
+ oneTrustAuth: string;
9
+ /** The Transcend API key to authenticate the requests to Transcend */
10
+ transcendAuth: string;
11
+ /** The Transcend URL where to forward requests */
12
+ transcendUrl: string;
9
13
  /** The resource to pull from OneTrust */
10
14
  resource: OneTrustPullResource;
11
15
  /** Whether to enable debugging while reporting errors */
12
16
  debug: boolean;
13
17
  /** The export format of the file where to save the resources */
14
18
  fileFormat: OneTrustFileFormat;
19
+ /** Whether to export the resource into a file rather than push to transcend */
20
+ dryRun: boolean;
15
21
  }
16
22
  /**
17
23
  * Parse the command line arguments
18
24
  *
19
25
  * @returns the parsed arguments
20
26
  */
21
- export declare const parseCliPullOtArguments: () => OneTrustCliArguments;
27
+ export declare const parseCliSyncOtArguments: () => OneTrustCliArguments;
22
28
  export {};
23
- //# sourceMappingURL=parseCliPullOtArguments.d.ts.map
29
+ //# sourceMappingURL=parseCliSyncOtArguments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCliSyncOtArguments.d.ts","sourceRoot":"","sources":["../../../src/oneTrust/helpers/parseCliSyncOtArguments.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKvE,UAAU,oBAAoB;IAC5B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,yDAAyD;IACzD,KAAK,EAAE,OAAO,CAAC;IACf,gEAAgE;IAChE,UAAU,EAAE,kBAAkB,CAAC;IAC/B,+EAA+E;IAC/E,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,QAAO,oBA0J1C,CAAC"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseCliSyncOtArguments = void 0;
7
+ const logger_1 = require("../../logger");
8
+ const colors_1 = __importDefault(require("colors"));
9
+ const yargs_parser_1 = __importDefault(require("yargs-parser"));
10
+ const enums_1 = require("../../enums");
11
+ const VALID_RESOURCES = Object.values(enums_1.OneTrustPullResource);
12
+ const VALID_FILE_FORMATS = Object.values(enums_1.OneTrustFileFormat);
13
+ /**
14
+ * Parse the command line arguments
15
+ *
16
+ * @returns the parsed arguments
17
+ */
18
+ const parseCliSyncOtArguments = () => {
19
+ const { file, hostname, oneTrustAuth, resource, debug, fileFormat, dryRun, transcendAuth, transcendUrl, } = (0, yargs_parser_1.default)(process.argv.slice(2), {
20
+ string: [
21
+ 'file',
22
+ 'hostname',
23
+ 'oneTrustAuth',
24
+ 'resource',
25
+ 'fileFormat',
26
+ 'dryRun',
27
+ 'transcendAuth',
28
+ 'transcendUrl',
29
+ ],
30
+ boolean: ['debug', 'dryRun'],
31
+ default: {
32
+ resource: enums_1.OneTrustPullResource.Assessments,
33
+ fileFormat: enums_1.OneTrustFileFormat.Json,
34
+ debug: false,
35
+ dryRun: false,
36
+ transcendUrl: 'https://api.transcend.io',
37
+ },
38
+ });
39
+ // Must be able to authenticate to transcend to sync resources to it
40
+ if (!dryRun && !transcendAuth) {
41
+ logger_1.logger.error(colors_1.default.red(
42
+ // eslint-disable-next-line no-template-curly-in-string
43
+ 'Must specify a "transcendAuth" parameter to sync resources to Transcend. e.g. --transcendAuth=${TRANSCEND_API_KEY}'));
44
+ return process.exit(1);
45
+ }
46
+ if (!dryRun && !transcendUrl) {
47
+ logger_1.logger.error(colors_1.default.red(
48
+ // eslint-disable-next-line max-len
49
+ 'Must specify a "transcendUrl" parameter to sync resources to Transcend. e.g. --transcendUrl=https://api.transcend.io'));
50
+ return process.exit(1);
51
+ }
52
+ // Can only sync to Transcend via a CSV file format!
53
+ if (!dryRun && fileFormat !== enums_1.OneTrustFileFormat.Json) {
54
+ logger_1.logger.error(colors_1.default.red(`The "fileFormat" parameter must equal ${enums_1.OneTrustFileFormat.Json} to sync resources to Transcend.`));
55
+ return process.exit(1);
56
+ }
57
+ // If trying to sync to disk, must specify a file path
58
+ if (dryRun && !file) {
59
+ logger_1.logger.error(colors_1.default.red('Must set a "file" parameter when "dryRun" is "true". e.g. --file=./oneTrustAssessments.json'));
60
+ return process.exit(1);
61
+ }
62
+ // If trying to sync to disk, must specify a file format
63
+ if (dryRun && !fileFormat) {
64
+ logger_1.logger.error(colors_1.default.red(`Must set a "fileFormat" parameter when "dryRun" is "true". e.g. --fileFormat=${enums_1.OneTrustFileFormat.Json}. Supported formats: ${VALID_FILE_FORMATS.join(',')}`));
65
+ return process.exit(1);
66
+ }
67
+ if (file) {
68
+ const splitFile = file.split('.');
69
+ if (splitFile.length < 2) {
70
+ logger_1.logger.error(colors_1.default.red('The "file" parameter has an invalid format. Expected a path with extensions. e.g. --file=./pathToFile.json.'));
71
+ return process.exit(1);
72
+ }
73
+ if (splitFile.at(-1) !== fileFormat) {
74
+ logger_1.logger.error(colors_1.default.red(
75
+ // eslint-disable-next-line max-len
76
+ `The "file" and "fileFormat" parameters must specify the same format! Got file=${file} and fileFormat=${fileFormat}`));
77
+ return process.exit(1);
78
+ }
79
+ }
80
+ if (!hostname) {
81
+ logger_1.logger.error(colors_1.default.red('Missing required parameter "hostname". e.g. --hostname=customer.my.onetrust.com'));
82
+ return process.exit(1);
83
+ }
84
+ if (!oneTrustAuth) {
85
+ logger_1.logger.error(colors_1.default.red('Missing required parameter "oneTrustAuth". e.g. --oneTrustAuth=$ONE_TRUST_AUTH_TOKEN'));
86
+ return process.exit(1);
87
+ }
88
+ if (!VALID_RESOURCES.includes(resource)) {
89
+ logger_1.logger.error(colors_1.default.red(`Received invalid resource value: "${resource}". Allowed: ${VALID_RESOURCES.join(',')}`));
90
+ return process.exit(1);
91
+ }
92
+ if (!VALID_FILE_FORMATS.includes(fileFormat)) {
93
+ logger_1.logger.error(colors_1.default.red(`Received invalid fileFormat value: "${fileFormat}". Allowed: ${VALID_FILE_FORMATS.join(',')}`));
94
+ return process.exit(1);
95
+ }
96
+ return {
97
+ file,
98
+ hostname,
99
+ oneTrustAuth,
100
+ resource,
101
+ debug,
102
+ fileFormat,
103
+ dryRun,
104
+ transcendAuth,
105
+ transcendUrl,
106
+ };
107
+ };
108
+ exports.parseCliSyncOtArguments = parseCliSyncOtArguments;
109
+ //# sourceMappingURL=parseCliSyncOtArguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCliSyncOtArguments.js","sourceRoot":"","sources":["../../../src/oneTrust/helpers/parseCliSyncOtArguments.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAsC;AACtC,oDAA4B;AAC5B,gEAAiC;AACjC,uCAAuE;AAEvE,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,4BAAoB,CAAC,CAAC;AAC5D,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,0BAAkB,CAAC,CAAC;AAuB7D;;;;GAIG;AACI,MAAM,uBAAuB,GAAG,GAAyB,EAAE;IAChE,MAAM,EACJ,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,UAAU,EACV,MAAM,EACN,aAAa,EACb,YAAY,GACb,GAAG,IAAA,sBAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QAC/B,MAAM,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CAAC,IAAI,CAC9E,GAAG,CACJ,EAAE,CACJ,CACF,CAAC;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC5C,eAAM,CAAC,KAAK,CACV,gBAAM,CAAC,GAAG,CACR,uCAAuC,UAAU,eAAe,kBAAkB,CAAC,IAAI,CACrF,GAAG,CACJ,EAAE,CACJ,CACF,CAAC;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACxB;IAED,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,YAAY;QACZ,QAAQ;QACR,KAAK;QACL,UAAU;QACV,MAAM;QACN,aAAa;QACb,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AA1JW,QAAA,uBAAuB,2BA0JlC"}
@@ -1,23 +1,21 @@
1
- import { OneTrustFileFormat } from '../enums';
2
- import { OneTrustAssessment, OneTrustGetAssessmentResponse } from './types';
1
+ import { OneTrustFileFormat } from '../../enums';
2
+ import { OneTrustEnrichedAssessment } from '@transcend-io/privacy-types';
3
3
  /**
4
4
  * Write the assessment to disk at the specified file path.
5
5
  *
6
6
  *
7
7
  * @param param - information about the assessment to write
8
8
  */
9
- export declare const writeOneTrustAssessment: ({ file, assessment, assessmentDetails, index, total, }: {
9
+ export declare const syncOneTrustAssessmentToDisk: ({ file, fileFormat, assessment, index, total, }: {
10
10
  /** The file path to write the assessment to */
11
11
  file: string;
12
12
  /** The format of the output file */
13
13
  fileFormat: OneTrustFileFormat;
14
14
  /** The basic assessment */
15
- assessment: OneTrustAssessment;
16
- /** The assessment with details */
17
- assessmentDetails: OneTrustGetAssessmentResponse;
15
+ assessment: OneTrustEnrichedAssessment;
18
16
  /** The index of the assessment being written to the file */
19
17
  index: number;
20
18
  /** The total amount of assessments that we will write */
21
19
  total: number;
22
20
  }) => void;
23
- //# sourceMappingURL=writeOneTrustAssessment.d.ts.map
21
+ //# sourceMappingURL=syncOneTrustAssessmentToDisk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncOneTrustAssessmentToDisk.d.ts","sourceRoot":"","sources":["../../../src/oneTrust/helpers/syncOneTrustAssessmentToDisk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B;IAOvC,+CAA+C;UACzC,MAAM;IACZ,oCAAoC;gBACxB,kBAAkB;IAC9B,2BAA2B;gBACf,0BAA0B;IACtC,4DAA4D;WACrD,MAAM;IACb,yDAAyD;WAClD,MAAM;MACX,IAqCH,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.syncOneTrustAssessmentToDisk = void 0;
7
+ const logger_1 = require("../../logger");
8
+ const colors_1 = __importDefault(require("colors"));
9
+ const enums_1 = require("../../enums");
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const oneTrustAssessmentToJson_1 = require("./oneTrustAssessmentToJson");
12
+ const oneTrustAssessmentToCsv_1 = require("./oneTrustAssessmentToCsv");
13
+ /**
14
+ * Write the assessment to disk at the specified file path.
15
+ *
16
+ *
17
+ * @param param - information about the assessment to write
18
+ */
19
+ const syncOneTrustAssessmentToDisk = ({ file, fileFormat, assessment, index, total, }) => {
20
+ logger_1.logger.info(colors_1.default.magenta(`Writing enriched assessment ${index + 1} of ${total} to file "${file}"...`));
21
+ if (fileFormat === enums_1.OneTrustFileFormat.Json) {
22
+ if (index === 0) {
23
+ fs_1.default.writeFileSync(file, (0, oneTrustAssessmentToJson_1.oneTrustAssessmentToJson)({
24
+ assessment,
25
+ index,
26
+ total,
27
+ wrap: false,
28
+ }));
29
+ }
30
+ else {
31
+ fs_1.default.appendFileSync(file, (0, oneTrustAssessmentToJson_1.oneTrustAssessmentToJson)({
32
+ assessment,
33
+ index,
34
+ total,
35
+ wrap: false,
36
+ }));
37
+ }
38
+ }
39
+ else if (fileFormat === enums_1.OneTrustFileFormat.Csv) {
40
+ if (index === 0) {
41
+ fs_1.default.writeFileSync(file, (0, oneTrustAssessmentToCsv_1.oneTrustAssessmentToCsv)({ assessment, index }));
42
+ }
43
+ else {
44
+ fs_1.default.appendFileSync(file, (0, oneTrustAssessmentToCsv_1.oneTrustAssessmentToCsv)({ assessment, index }));
45
+ }
46
+ }
47
+ };
48
+ exports.syncOneTrustAssessmentToDisk = syncOneTrustAssessmentToDisk;
49
+ //# sourceMappingURL=syncOneTrustAssessmentToDisk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncOneTrustAssessmentToDisk.js","sourceRoot":"","sources":["../../../src/oneTrust/helpers/syncOneTrustAssessmentToDisk.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAsC;AACtC,oDAA4B;AAC5B,uCAAiD;AACjD,4CAAoB;AACpB,yEAAsE;AACtE,uEAAoE;AAGpE;;;;;GAKG;AACI,MAAM,4BAA4B,GAAG,CAAC,EAC3C,IAAI,EACJ,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,GAYN,EAAQ,EAAE;IACT,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,OAAO,CACZ,+BACE,KAAK,GAAG,CACV,OAAO,KAAK,aAAa,IAAI,MAAM,CACpC,CACF,CAAC;IAEF,IAAI,UAAU,KAAK,0BAAkB,CAAC,IAAI,EAAE;QAC1C,IAAI,KAAK,KAAK,CAAC,EAAE;YACf,YAAE,CAAC,aAAa,CACd,IAAI,EACJ,IAAA,mDAAwB,EAAC;gBACvB,UAAU;gBACV,KAAK;gBACL,KAAK;gBACL,IAAI,EAAE,KAAK;aACZ,CAAC,CACH,CAAC;SACH;aAAM;YACL,YAAE,CAAC,cAAc,CACf,IAAI,EACJ,IAAA,mDAAwB,EAAC;gBACvB,UAAU;gBACV,KAAK;gBACL,KAAK;gBACL,IAAI,EAAE,KAAK;aAAU,CAAC,CACzB,CAAC;SACH;KACF;SAAM,IAAI,UAAU,KAAK,0BAAkB,CAAC,GAAG,EAAE;QAChD,IAAI,KAAK,KAAK,CAAC,EAAE;YACf,YAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAA,iDAAuB,EAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SACxE;aAAM;YACL,YAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAA,iDAAuB,EAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SACzE;KACF;AACH,CAAC,CAAC;AAtDW,QAAA,4BAA4B,gCAsDvC"}
@@ -0,0 +1,25 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import { OneTrustEnrichedAssessment } from '@transcend-io/privacy-types';
3
+ export interface AssessmentForm {
4
+ /** ID of Assessment Form */
5
+ id: string;
6
+ /** Title of Assessment Form */
7
+ name: string;
8
+ }
9
+ /**
10
+ * Write the assessment to a Transcend instance.
11
+ *
12
+ *
13
+ * @param param - information about the assessment and Transcend instance to write to
14
+ */
15
+ export declare const syncOneTrustAssessmentToTranscend: ({ transcend, assessment, total, index, }: {
16
+ /** the Transcend client instance */
17
+ transcend: GraphQLClient;
18
+ /** the assessment to sync to Transcend */
19
+ assessment: OneTrustEnrichedAssessment;
20
+ /** The index of the assessment being written to the file */
21
+ index: number;
22
+ /** The total amount of assessments that we will write */
23
+ total: number;
24
+ }) => Promise<AssessmentForm | undefined>;
25
+ //# sourceMappingURL=syncOneTrustAssessmentToTranscend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncOneTrustAssessmentToTranscend.d.ts","sourceRoot":"","sources":["../../../src/oneTrust/helpers/syncOneTrustAssessmentToTranscend.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAGzE,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC;IAM5C,oCAAoC;eACzB,aAAa;IACxB,0CAA0C;gBAC9B,0BAA0B;IACtC,4DAA4D;WACrD,MAAM;IACb,yDAAyD;WAClD,MAAM;MACX,QAAQ,cAAc,GAAG,SAAS,CAgCrC,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.syncOneTrustAssessmentToTranscend = void 0;
7
+ const logger_1 = require("../../logger");
8
+ const colors_1 = __importDefault(require("colors"));
9
+ const graphql_1 = require("../../graphql");
10
+ const oneTrustAssessmentToJson_1 = require("./oneTrustAssessmentToJson");
11
+ /**
12
+ * Write the assessment to a Transcend instance.
13
+ *
14
+ *
15
+ * @param param - information about the assessment and Transcend instance to write to
16
+ */
17
+ const syncOneTrustAssessmentToTranscend = async ({ transcend, assessment, total, index, }) => {
18
+ logger_1.logger.info(colors_1.default.magenta(`Writing enriched assessment ${index + 1} of ${total} to Transcend...`));
19
+ // convert the OneTrust assessment object into a CSV Record (a map from the csv header to values)
20
+ const json = (0, oneTrustAssessmentToJson_1.oneTrustAssessmentToJson)({
21
+ assessment,
22
+ index,
23
+ total,
24
+ });
25
+ // transform the csv record into a valid input to the mutation
26
+ const input = {
27
+ json,
28
+ };
29
+ const { importOneTrustAssessmentForms: { assessmentForms }, } = await (0, graphql_1.makeGraphQLRequest)(transcend, graphql_1.IMPORT_ONE_TRUST_ASSESSMENT_FORMS, {
30
+ input,
31
+ });
32
+ return assessmentForms[0];
33
+ };
34
+ exports.syncOneTrustAssessmentToTranscend = syncOneTrustAssessmentToTranscend;
35
+ //# sourceMappingURL=syncOneTrustAssessmentToTranscend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncOneTrustAssessmentToTranscend.js","sourceRoot":"","sources":["../../../src/oneTrust/helpers/syncOneTrustAssessmentToTranscend.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAsC;AACtC,oDAA4B;AAE5B,2CAGuB;AAGvB,yEAAsE;AAStE;;;;;GAKG;AACI,MAAM,iCAAiC,GAAG,KAAK,EAAE,EACtD,SAAS,EACT,UAAU,EACV,KAAK,EACL,KAAK,GAUN,EAAuC,EAAE;IACxC,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,OAAO,CACZ,+BAA+B,KAAK,GAAG,CAAC,OAAO,KAAK,kBAAkB,CACvE,CACF,CAAC;IAEF,iGAAiG;IACjG,MAAM,IAAI,GAAG,IAAA,mDAAwB,EAAC;QACpC,UAAU;QACV,KAAK;QACL,KAAK;KACN,CAAC,CAAC;IAEH,8DAA8D;IAC9D,MAAM,KAAK,GAAmC;QAC5C,IAAI;KACL,CAAC;IAEF,MAAM,EACJ,6BAA6B,EAAE,EAAE,eAAe,EAAE,GACnD,GAAG,MAAM,IAAA,4BAAkB,EAMzB,SAAS,EAAE,2CAAiC,EAAE;QAC/C,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC,CAAC;AA9CW,QAAA,iCAAiC,qCA8C5C"}
@@ -0,0 +1,22 @@
1
+ import { Got } from 'got/dist/source';
2
+ import { OneTrustFileFormat } from '../../enums';
3
+ import { GraphQLClient } from 'graphql-request';
4
+ export interface AssessmentForm {
5
+ /** ID of Assessment Form */
6
+ id: string;
7
+ /** Title of Assessment Form */
8
+ name: string;
9
+ }
10
+ export declare const syncOneTrustAssessments: ({ oneTrust, file, fileFormat, dryRun, transcend, }: {
11
+ /** the OneTrust client instance */
12
+ oneTrust: Got;
13
+ /** the Transcend client instance */
14
+ transcend?: GraphQLClient | undefined;
15
+ /** Whether to write to file instead of syncing to Transcend */
16
+ dryRun: boolean;
17
+ /** the path to the file in case dryRun is true */
18
+ file?: string | undefined;
19
+ /** the format of the file in case dryRun is true */
20
+ fileFormat?: OneTrustFileFormat | undefined;
21
+ }) => Promise<void>;
22
+ //# sourceMappingURL=syncOneTrustAssessments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncOneTrustAssessments.d.ts","sourceRoot":"","sources":["../../../src/oneTrust/helpers/syncOneTrustAssessments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAmBtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,uBAAuB;IAOlC,mCAAmC;cACzB,GAAG;IACb,oCAAoC;;IAEpC,+DAA+D;YACvD,OAAO;IACf,kDAAkD;;IAElD,oDAAoD;;MAElD,QAAQ,IAAI,CA8Jf,CAAC"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.syncOneTrustAssessments = void 0;
7
+ const endpoints_1 = require("../endpoints");
8
+ const bluebird_1 = require("bluebird");
9
+ const logger_1 = require("../../logger");
10
+ const uniq_1 = __importDefault(require("lodash/uniq"));
11
+ const enrichOneTrustAssessment_1 = require("./enrichOneTrustAssessment");
12
+ const syncOneTrustAssessmentToDisk_1 = require("./syncOneTrustAssessmentToDisk");
13
+ const enums_1 = require("../../enums");
14
+ const syncOneTrustAssessmentToTranscend_1 = require("./syncOneTrustAssessmentToTranscend");
15
+ const syncOneTrustAssessments = async ({ oneTrust, file, fileFormat, dryRun, transcend, }) => {
16
+ // fetch the list of all assessments in the OneTrust organization
17
+ logger_1.logger.info('Getting list of all assessments from OneTrust...');
18
+ const assessments = await (0, endpoints_1.getListOfOneTrustAssessments)({ oneTrust });
19
+ // a cache of OneTrust users so we avoid requesting already fetched users
20
+ const oneTrustCachedUsers = {};
21
+ // split all assessments in batches, so we can process some of steps in parallel
22
+ const BATCH_SIZE = 5;
23
+ const assessmentBatches = Array.from({
24
+ length: Math.ceil(assessments.length / BATCH_SIZE),
25
+ }, (_, i) => assessments.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE));
26
+ // process each batch and sync the batch right away so it's garbage collected and we don't run out of memory
27
+ await (0, bluebird_1.mapSeries)(assessmentBatches, async (assessmentBatch, batch) => {
28
+ const batchEnrichedAssessments = [];
29
+ // fetch assessment details from OneTrust in parallel
30
+ await (0, bluebird_1.map)(assessmentBatch, async (assessment, index) => {
31
+ const assessmentNumber = BATCH_SIZE * batch + index;
32
+ logger_1.logger.info(`[assessment ${assessmentNumber} of ${assessments.length}]: fetching details...`);
33
+ const assessmentDetails = await (0, endpoints_1.getOneTrustAssessment)({
34
+ oneTrust,
35
+ assessmentId: assessment.assessmentId,
36
+ });
37
+ // fetch assessment's creator information
38
+ const creatorId = assessmentDetails.createdBy.id;
39
+ let creator = oneTrustCachedUsers[creatorId];
40
+ if (!creator) {
41
+ logger_1.logger.info(`[assessment ${assessmentNumber} of ${assessments.length}]: fetching creator...`);
42
+ creator = await (0, endpoints_1.getOneTrustUser)({
43
+ oneTrust,
44
+ userId: creatorId,
45
+ });
46
+ oneTrustCachedUsers[creatorId] = creator;
47
+ }
48
+ // fetch assessment approvers information
49
+ const { approvers } = assessmentDetails;
50
+ let approversDetails = [];
51
+ if (approvers.length > 0) {
52
+ logger_1.logger.info(`[assessment ${assessmentNumber} of ${assessments.length}]: fetching approvers...`);
53
+ approversDetails = await (0, bluebird_1.map)(approvers.map(({ id }) => id), async (userId) => {
54
+ let approver = oneTrustCachedUsers[userId];
55
+ if (!approver) {
56
+ approver = await (0, endpoints_1.getOneTrustUser)({ oneTrust, userId });
57
+ oneTrustCachedUsers[userId] = approver;
58
+ }
59
+ return approver;
60
+ }, { concurrency: 5 });
61
+ }
62
+ // fetch assessment internal respondents information
63
+ const { respondents } = assessmentDetails;
64
+ // if a user is an internal respondents, their 'name' field can't be an email.
65
+ const internalRespondents = respondents.filter((r) => !r.name.includes('@'));
66
+ let respondentsDetails = [];
67
+ if (internalRespondents.length > 0) {
68
+ logger_1.logger.info(`[assessment ${assessmentNumber} of ${assessments.length}]: fetching respondents...`);
69
+ respondentsDetails = await (0, bluebird_1.map)(internalRespondents.map(({ id }) => id), async (userId) => {
70
+ let respondent = oneTrustCachedUsers[userId];
71
+ if (!respondent) {
72
+ respondent = await (0, endpoints_1.getOneTrustUser)({ oneTrust, userId });
73
+ oneTrustCachedUsers[userId] = respondent;
74
+ }
75
+ return respondent;
76
+ }, { concurrency: 5 });
77
+ }
78
+ // fetch assessment risk information
79
+ let riskDetails = [];
80
+ const riskIds = (0, uniq_1.default)(assessmentDetails.sections.flatMap((s) => s.questions.flatMap((q) => { var _a; return ((_a = q.risks) !== null && _a !== void 0 ? _a : []).flatMap((r) => r.riskId); })));
81
+ if (riskIds.length > 0) {
82
+ logger_1.logger.info(`[assessment ${assessmentNumber} of ${assessments.length}]: fetching risks...`);
83
+ riskDetails = await (0, bluebird_1.map)(riskIds, (riskId) => (0, endpoints_1.getOneTrustRisk)({ oneTrust, riskId: riskId }), {
84
+ concurrency: 5,
85
+ });
86
+ }
87
+ // enrich the assessments with user and risk details
88
+ const enrichedAssessment = (0, enrichOneTrustAssessment_1.enrichOneTrustAssessment)({
89
+ assessment,
90
+ assessmentDetails,
91
+ riskDetails,
92
+ creatorDetails: creator,
93
+ approversDetails,
94
+ respondentsDetails,
95
+ });
96
+ batchEnrichedAssessments.push(enrichedAssessment);
97
+ }, { concurrency: BATCH_SIZE });
98
+ // sync assessments in series to avoid concurrency bugs
99
+ await (0, bluebird_1.mapSeries)(batchEnrichedAssessments, async (enrichedAssessment, index) => {
100
+ // the assessment's global index takes its batch into consideration
101
+ const globalIndex = batch * BATCH_SIZE + index;
102
+ if (dryRun && file && fileFormat) {
103
+ // sync to file
104
+ (0, syncOneTrustAssessmentToDisk_1.syncOneTrustAssessmentToDisk)({
105
+ assessment: enrichedAssessment,
106
+ index: globalIndex,
107
+ total: assessments.length,
108
+ file,
109
+ fileFormat,
110
+ });
111
+ }
112
+ else if (fileFormat === enums_1.OneTrustFileFormat.Json && transcend) {
113
+ // sync to transcend
114
+ await (0, syncOneTrustAssessmentToTranscend_1.syncOneTrustAssessmentToTranscend)({
115
+ assessment: enrichedAssessment,
116
+ transcend,
117
+ total: assessments.length,
118
+ index: globalIndex,
119
+ });
120
+ }
121
+ });
122
+ });
123
+ };
124
+ exports.syncOneTrustAssessments = syncOneTrustAssessments;
125
+ //# sourceMappingURL=syncOneTrustAssessments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncOneTrustAssessments.js","sourceRoot":"","sources":["../../../src/oneTrust/helpers/syncOneTrustAssessments.ts"],"names":[],"mappings":";;;;;;AACA,4CAKsB;AACtB,uCAA0C;AAC1C,yCAAsC;AAQtC,uDAA+B;AAC/B,yEAAsE;AACtE,iFAA8E;AAC9E,uCAAiD;AAEjD,2FAAwF;AASjF,MAAM,uBAAuB,GAAG,KAAK,EAAE,EAC5C,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,MAAM,EACN,SAAS,GAYV,EAAiB,EAAE;IAClB,iEAAiE;IACjE,eAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,MAAM,IAAA,wCAA4B,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAErE,yEAAyE;IACzE,MAAM,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A,mDAAwB,EAAC;gBAClD,UAAU;gBACV,iBAAiB;gBACjB,WAAW;gBACX,cAAc,EAAE,OAAO;gBACvB,gBAAgB;gBAChB,kBAAkB;aACnB,CAAC,CAAC;YAEH,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACpD,CAAC,EACD,EAAE,WAAW,EAAE,UAAU,EAAE,CAC5B,CAAC;QAEF,uDAAuD;QACvD,MAAM,IAAA,oBAAS,EACb,wBAAwB,EACxB,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,EAAE;YAClC,mEAAmE;YACnE,MAAM,WAAW,GAAG,KAAK,GAAG,UAAU,GAAG,KAAK,CAAC;YAE/C,IAAI,MAAM,IAAI,IAAI,IAAI,UAAU,EAAE;gBAChC,eAAe;gBACf,IAAA,2DAA4B,EAAC;oBAC3B,UAAU,EAAE,kBAAkB;oBAC9B,KAAK,EAAE,WAAW;oBAClB,KAAK,EAAE,WAAW,CAAC,MAAM;oBACzB,IAAI;oBACJ,UAAU;iBACX,CAAC,CAAC;aACJ;iBAAM,IAAI,UAAU,KAAK,0BAAkB,CAAC,IAAI,IAAI,SAAS,EAAE;gBAC9D,oBAAoB;gBACpB,MAAM,IAAA,qEAAiC,EAAC;oBACtC,UAAU,EAAE,kBAAkB;oBAC9B,SAAS;oBACT,KAAK,EAAE,WAAW,CAAC,MAAM;oBACzB,KAAK,EAAE,WAAW;iBACnB,CAAC,CAAC;aACJ;QACH,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA/KW,QAAA,uBAAuB,2BA+KlC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=convertToEmptyStrings.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertToEmptyStrings.test.d.ts","sourceRoot":"","sources":["../../../../src/oneTrust/helpers/tests/convertToEmptyStrings.test.ts"],"names":[],"mappings":""}