@transcend-io/cli 4.121.2 → 4.122.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 (106) hide show
  1. package/README.md +12 -0
  2. package/build/codecs.d.ts +12540 -1290
  3. package/build/codecs.d.ts.map +1 -1
  4. package/build/codecs.js +225 -12
  5. package/build/codecs.js.map +1 -1
  6. package/build/constants.d.ts.map +1 -1
  7. package/build/constants.js +12 -0
  8. package/build/constants.js.map +1 -1
  9. package/build/enums.d.ts +7 -1
  10. package/build/enums.d.ts.map +1 -1
  11. package/build/enums.js +6 -0
  12. package/build/enums.js.map +1 -1
  13. package/build/graphql/fetchAllAgentFiles.d.ts +24 -0
  14. package/build/graphql/fetchAllAgentFiles.d.ts.map +1 -0
  15. package/build/graphql/fetchAllAgentFiles.js +32 -0
  16. package/build/graphql/fetchAllAgentFiles.js.map +1 -0
  17. package/build/graphql/fetchAllAgentFunctions.d.ts +20 -0
  18. package/build/graphql/fetchAllAgentFunctions.d.ts.map +1 -0
  19. package/build/graphql/fetchAllAgentFunctions.js +35 -0
  20. package/build/graphql/fetchAllAgentFunctions.js.map +1 -0
  21. package/build/graphql/fetchAllAgents.d.ts +54 -0
  22. package/build/graphql/fetchAllAgents.d.ts.map +1 -0
  23. package/build/graphql/fetchAllAgents.js +32 -0
  24. package/build/graphql/fetchAllAgents.js.map +1 -0
  25. package/build/graphql/fetchAllDataCategories.d.ts +42 -0
  26. package/build/graphql/fetchAllDataCategories.d.ts.map +1 -0
  27. package/build/graphql/fetchAllDataCategories.js +32 -0
  28. package/build/graphql/fetchAllDataCategories.js.map +1 -0
  29. package/build/graphql/fetchAllProcessingPurposes.d.ts +40 -0
  30. package/build/graphql/fetchAllProcessingPurposes.d.ts.map +1 -0
  31. package/build/graphql/fetchAllProcessingPurposes.js +32 -0
  32. package/build/graphql/fetchAllProcessingPurposes.js.map +1 -0
  33. package/build/graphql/fetchAllVendors.d.ts +57 -0
  34. package/build/graphql/fetchAllVendors.d.ts.map +1 -0
  35. package/build/graphql/fetchAllVendors.js +32 -0
  36. package/build/graphql/fetchAllVendors.js.map +1 -0
  37. package/build/graphql/gqls/agent.d.ts +4 -0
  38. package/build/graphql/gqls/agent.d.ts.map +1 -0
  39. package/build/graphql/gqls/agent.js +64 -0
  40. package/build/graphql/gqls/agent.js.map +1 -0
  41. package/build/graphql/gqls/agentFile.d.ts +4 -0
  42. package/build/graphql/gqls/agentFile.d.ts.map +1 -0
  43. package/build/graphql/gqls/agentFile.js +47 -0
  44. package/build/graphql/gqls/agentFile.js.map +1 -0
  45. package/build/graphql/gqls/agentFunction.d.ts +4 -0
  46. package/build/graphql/gqls/agentFunction.d.ts.map +1 -0
  47. package/build/graphql/gqls/agentFunction.js +46 -0
  48. package/build/graphql/gqls/agentFunction.js.map +1 -0
  49. package/build/graphql/gqls/dataCategory.d.ts +4 -0
  50. package/build/graphql/gqls/dataCategory.d.ts.map +1 -0
  51. package/build/graphql/gqls/dataCategory.js +62 -0
  52. package/build/graphql/gqls/dataCategory.js.map +1 -0
  53. package/build/graphql/gqls/index.d.ts +6 -0
  54. package/build/graphql/gqls/index.d.ts.map +1 -1
  55. package/build/graphql/gqls/index.js +6 -0
  56. package/build/graphql/gqls/index.js.map +1 -1
  57. package/build/graphql/gqls/processingPurpose.d.ts +4 -0
  58. package/build/graphql/gqls/processingPurpose.d.ts.map +1 -0
  59. package/build/graphql/gqls/processingPurpose.js +64 -0
  60. package/build/graphql/gqls/processingPurpose.js.map +1 -0
  61. package/build/graphql/gqls/vendor.d.ts +4 -0
  62. package/build/graphql/gqls/vendor.d.ts.map +1 -0
  63. package/build/graphql/gqls/vendor.js +65 -0
  64. package/build/graphql/gqls/vendor.js.map +1 -0
  65. package/build/graphql/index.d.ts +12 -0
  66. package/build/graphql/index.d.ts.map +1 -1
  67. package/build/graphql/index.js +12 -0
  68. package/build/graphql/index.js.map +1 -1
  69. package/build/graphql/pullTranscendConfiguration.d.ts.map +1 -1
  70. package/build/graphql/pullTranscendConfiguration.js +126 -1
  71. package/build/graphql/pullTranscendConfiguration.js.map +1 -1
  72. package/build/graphql/reportPromptRun.d.ts +4 -0
  73. package/build/graphql/reportPromptRun.d.ts.map +1 -1
  74. package/build/graphql/reportPromptRun.js.map +1 -1
  75. package/build/graphql/syncAgentFiles.d.ts +26 -0
  76. package/build/graphql/syncAgentFiles.d.ts.map +1 -0
  77. package/build/graphql/syncAgentFiles.js +99 -0
  78. package/build/graphql/syncAgentFiles.js.map +1 -0
  79. package/build/graphql/syncAgentFunctions.d.ts +26 -0
  80. package/build/graphql/syncAgentFunctions.d.ts.map +1 -0
  81. package/build/graphql/syncAgentFunctions.js +94 -0
  82. package/build/graphql/syncAgentFunctions.js.map +1 -0
  83. package/build/graphql/syncAgents.d.ts +34 -0
  84. package/build/graphql/syncAgents.d.ts.map +1 -0
  85. package/build/graphql/syncAgents.js +109 -0
  86. package/build/graphql/syncAgents.js.map +1 -0
  87. package/build/graphql/syncBusinessEntities.d.ts.map +1 -1
  88. package/build/graphql/syncBusinessEntities.js +1 -0
  89. package/build/graphql/syncBusinessEntities.js.map +1 -1
  90. package/build/graphql/syncConfigurationToTranscend.d.ts.map +1 -1
  91. package/build/graphql/syncConfigurationToTranscend.js +37 -1
  92. package/build/graphql/syncConfigurationToTranscend.js.map +1 -1
  93. package/build/graphql/syncDataCategories.d.ts +26 -0
  94. package/build/graphql/syncDataCategories.d.ts.map +1 -0
  95. package/build/graphql/syncDataCategories.js +97 -0
  96. package/build/graphql/syncDataCategories.js.map +1 -0
  97. package/build/graphql/syncProcessingPurposes.d.ts +26 -0
  98. package/build/graphql/syncProcessingPurposes.d.ts.map +1 -0
  99. package/build/graphql/syncProcessingPurposes.js +97 -0
  100. package/build/graphql/syncProcessingPurposes.js.map +1 -0
  101. package/build/graphql/syncVendors.d.ts +26 -0
  102. package/build/graphql/syncVendors.d.ts.map +1 -0
  103. package/build/graphql/syncVendors.js +108 -0
  104. package/build/graphql/syncVendors.js.map +1 -0
  105. package/build/tsbuildinfo +1 -1
  106. package/package.json +2 -1
@@ -0,0 +1,97 @@
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.syncDataCategories = exports.updateDataCategories = exports.createDataCategory = void 0;
7
+ const bluebird_1 = require("bluebird");
8
+ const gqls_1 = require("./gqls");
9
+ const logger_1 = require("../logger");
10
+ const keyBy_1 = __importDefault(require("lodash/keyBy"));
11
+ const makeGraphQLRequest_1 = require("./makeGraphQLRequest");
12
+ const colors_1 = __importDefault(require("colors"));
13
+ const fetchAllDataCategories_1 = require("./fetchAllDataCategories");
14
+ /**
15
+ * Input to create a new data category
16
+ *
17
+ * @param client - GraphQL client
18
+ * @param dataCategory - Input
19
+ */
20
+ async function createDataCategory(client, dataCategory) {
21
+ const input = {
22
+ name: dataCategory.name,
23
+ category: dataCategory.category,
24
+ description: dataCategory.description,
25
+ // TODO: https://transcend.height.app/T-31994 - add attributes, teams, owners
26
+ };
27
+ const { createDataCategory } = await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.CREATE_DATA_SUB_CATEGORY, {
28
+ input,
29
+ });
30
+ return createDataCategory.dataCategory;
31
+ }
32
+ exports.createDataCategory = createDataCategory;
33
+ /**
34
+ * Input to update data categories
35
+ *
36
+ * @param client - GraphQL client
37
+ * @param dataCategoryIdPairs - [DataCategoryInput, dataCategoryId] list
38
+ */
39
+ async function updateDataCategories(client, dataCategoryIdPairs) {
40
+ await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.UPDATE_DATA_SUB_CATEGORIES, {
41
+ input: {
42
+ dataSubCategories: dataCategoryIdPairs.map(([dataCategory, id]) => ({
43
+ id,
44
+ description: dataCategory.description,
45
+ // TODO: https://transcend.height.app/T-31994 - add teams, owners
46
+ attributes: dataCategory.attributes,
47
+ })),
48
+ },
49
+ });
50
+ }
51
+ exports.updateDataCategories = updateDataCategories;
52
+ /**
53
+ * Sync the data inventory data categories
54
+ *
55
+ * @param client - GraphQL client
56
+ * @param inputs - Inputs to create
57
+ * @returns True if run without error, returns false if an error occurred
58
+ */
59
+ async function syncDataCategories(client, inputs) {
60
+ // Fetch existing
61
+ logger_1.logger.info(colors_1.default.magenta(`Syncing "${inputs.length}" data categories...`));
62
+ let encounteredError = false;
63
+ // Fetch existing
64
+ const existingDataCategories = await (0, fetchAllDataCategories_1.fetchAllDataCategories)(client);
65
+ // Look up by name
66
+ const dataCategoryByName = (0, keyBy_1.default)(existingDataCategories, ({ name, category }) => `${name}:${category}`);
67
+ // Create new data categories
68
+ const newDataCategories = inputs.filter((input) => !dataCategoryByName[`${input.name}:${input.category}`]);
69
+ // Create new data categories
70
+ await (0, bluebird_1.mapSeries)(newDataCategories, async (dataCategory) => {
71
+ try {
72
+ const newDataCategory = await createDataCategory(client, dataCategory);
73
+ dataCategoryByName[`${newDataCategory.name}:${newDataCategory.category}`] = newDataCategory;
74
+ logger_1.logger.info(colors_1.default.green(`Successfully synced data category "${dataCategory.name}"!`));
75
+ }
76
+ catch (err) {
77
+ encounteredError = true;
78
+ logger_1.logger.info(colors_1.default.red(`Failed to sync data category "${dataCategory.name}"! - ${err.message}`));
79
+ }
80
+ });
81
+ // Update all data categories
82
+ try {
83
+ logger_1.logger.info(colors_1.default.magenta(`Updating "${inputs.length}" data categories!`));
84
+ await updateDataCategories(client, inputs.map((input) => [
85
+ input,
86
+ dataCategoryByName[`${input.name}:${input.category}`].id,
87
+ ]));
88
+ logger_1.logger.info(colors_1.default.green(`Successfully synced "${inputs.length}" data categories!`));
89
+ }
90
+ catch (err) {
91
+ encounteredError = true;
92
+ logger_1.logger.info(colors_1.default.red(`Failed to sync "${inputs.length}" data categories ! - ${err.message}`));
93
+ }
94
+ return !encounteredError;
95
+ }
96
+ exports.syncDataCategories = syncDataCategories;
97
+ //# sourceMappingURL=syncDataCategories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncDataCategories.js","sourceRoot":"","sources":["../../src/graphql/syncDataCategories.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAqC;AACrC,iCAA8E;AAC9E,sCAAmC;AACnC,yDAAiC;AACjC,6DAA0D;AAC1D,oDAA4B;AAC5B,qEAGkC;AAElC;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CACtC,MAAqB,EACrB,YAA+B;IAE/B,MAAM,KAAK,GAAG;QACZ,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,QAAQ,EAAE,YAAY,CAAC,QAAQ;QAC/B,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,6EAA6E;KAC9E,CAAC;IAEF,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,IAAA,uCAAkB,EAMpD,MAAM,EAAE,+BAAwB,EAAE;QACnC,KAAK;KACN,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC,YAAY,CAAC;AACzC,CAAC;AArBD,gDAqBC;AAED;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CACxC,MAAqB,EACrB,mBAAkD;IAElD,MAAM,IAAA,uCAAkB,EAAC,MAAM,EAAE,iCAA0B,EAAE;QAC3D,KAAK,EAAE;YACL,iBAAiB,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAClE,EAAE;gBACF,WAAW,EAAE,YAAY,CAAC,WAAW;gBACrC,kEAAkE;gBAClE,UAAU,EAAE,YAAY,CAAC,UAAU;aACpC,CAAC,CAAC;SACJ;KACF,CAAC,CAAC;AACL,CAAC;AAdD,oDAcC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CACtC,MAAqB,EACrB,MAA2B;IAE3B,iBAAiB;IACjB,eAAM,CAAC,IAAI,CAAC,gBAAM,CAAC,OAAO,CAAC,YAAY,MAAM,CAAC,MAAM,sBAAsB,CAAC,CAAC,CAAC;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,oBAAoB,CACxB,MAAM,EACN,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YACpB,KAAK;YACL,kBAAkB,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE;SACzD,CAAC,CACH,CAAC;QACF,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CAAC,wBAAwB,MAAM,CAAC,MAAM,oBAAoB,CAAC,CACxE,CAAC;KACH;IAAC,OAAO,GAAG,EAAE;QACZ,gBAAgB,GAAG,IAAI,CAAC;QACxB,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,GAAG,CACR,mBAAmB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,OAAO,EAAE,CACvE,CACF,CAAC;KACH;IAED,OAAO,CAAC,gBAAgB,CAAC;AAC3B,CAAC;AAtED,gDAsEC"}
@@ -0,0 +1,26 @@
1
+ import { ProcessingPurposeInput } from '../codecs';
2
+ import { GraphQLClient } from 'graphql-request';
3
+ import { ProcessingPurposeSubCategory } from './fetchAllProcessingPurposes';
4
+ /**
5
+ * Input to create a new processing purpose
6
+ *
7
+ * @param client - GraphQL client
8
+ * @param processingPurpose - Input
9
+ */
10
+ export declare function createProcessingPurpose(client: GraphQLClient, processingPurpose: ProcessingPurposeInput): Promise<Pick<ProcessingPurposeSubCategory, 'id' | 'name' | 'purpose'>>;
11
+ /**
12
+ * Input to update processing purposes
13
+ *
14
+ * @param client - GraphQL client
15
+ * @param processingPurposeIdPairs - [ProcessingPurposeInput, processingPurposeId] list
16
+ */
17
+ export declare function updateProcessingPurposes(client: GraphQLClient, processingPurposeIdPairs: [ProcessingPurposeInput, string][]): Promise<void>;
18
+ /**
19
+ * Sync the data inventory processing purposes
20
+ *
21
+ * @param client - GraphQL client
22
+ * @param inputs - Inputs to create
23
+ * @returns True if run without error, returns false if an error occurred
24
+ */
25
+ export declare function syncProcessingPurposes(client: GraphQLClient, inputs: ProcessingPurposeInput[]): Promise<boolean>;
26
+ //# sourceMappingURL=syncProcessingPurposes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncProcessingPurposes.d.ts","sourceRoot":"","sources":["../../src/graphql/syncProcessingPurposes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAUhD,OAAO,EAEL,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,aAAa,EACrB,iBAAiB,EAAE,sBAAsB,GACxC,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,CAkBxE;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,aAAa,EACrB,wBAAwB,EAAE,CAAC,sBAAsB,EAAE,MAAM,CAAC,EAAE,GAC3D,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,sBAAsB,EAAE,GAC/B,OAAO,CAAC,OAAO,CAAC,CA4ElB"}
@@ -0,0 +1,97 @@
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.syncProcessingPurposes = exports.updateProcessingPurposes = exports.createProcessingPurpose = void 0;
7
+ const bluebird_1 = require("bluebird");
8
+ const gqls_1 = require("./gqls");
9
+ const logger_1 = require("../logger");
10
+ const keyBy_1 = __importDefault(require("lodash/keyBy"));
11
+ const makeGraphQLRequest_1 = require("./makeGraphQLRequest");
12
+ const colors_1 = __importDefault(require("colors"));
13
+ const fetchAllProcessingPurposes_1 = require("./fetchAllProcessingPurposes");
14
+ /**
15
+ * Input to create a new processing purpose
16
+ *
17
+ * @param client - GraphQL client
18
+ * @param processingPurpose - Input
19
+ */
20
+ async function createProcessingPurpose(client, processingPurpose) {
21
+ const input = {
22
+ name: processingPurpose.name,
23
+ purpose: processingPurpose.purpose,
24
+ description: processingPurpose.description,
25
+ // TODO: https://transcend.height.app/T-31994 - add attributes, teams, owners
26
+ };
27
+ const { createProcessingPurposeSubCategory } = await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.CREATE_PROCESSING_PURPOSE_SUB_CATEGORY, {
28
+ input,
29
+ });
30
+ return createProcessingPurposeSubCategory.processingPurposeSubCategory;
31
+ }
32
+ exports.createProcessingPurpose = createProcessingPurpose;
33
+ /**
34
+ * Input to update processing purposes
35
+ *
36
+ * @param client - GraphQL client
37
+ * @param processingPurposeIdPairs - [ProcessingPurposeInput, processingPurposeId] list
38
+ */
39
+ async function updateProcessingPurposes(client, processingPurposeIdPairs) {
40
+ await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.UPDATE_PROCESSING_PURPOSE_SUB_CATEGORIES, {
41
+ input: {
42
+ processingPurposeSubCategories: processingPurposeIdPairs.map(([processingPurpose, id]) => ({
43
+ id,
44
+ description: processingPurpose.description,
45
+ // TODO: https://transcend.height.app/T-31994 - add teams, owners
46
+ attributes: processingPurpose.attributes,
47
+ })),
48
+ },
49
+ });
50
+ }
51
+ exports.updateProcessingPurposes = updateProcessingPurposes;
52
+ /**
53
+ * Sync the data inventory processing purposes
54
+ *
55
+ * @param client - GraphQL client
56
+ * @param inputs - Inputs to create
57
+ * @returns True if run without error, returns false if an error occurred
58
+ */
59
+ async function syncProcessingPurposes(client, inputs) {
60
+ // Fetch existing
61
+ logger_1.logger.info(colors_1.default.magenta(`Syncing "${inputs.length}" processing purposes...`));
62
+ let encounteredError = false;
63
+ // Fetch existing
64
+ const existingProcessingPurposes = await (0, fetchAllProcessingPurposes_1.fetchAllProcessingPurposes)(client);
65
+ // Look up by name
66
+ const processingPurposeByName = (0, keyBy_1.default)(existingProcessingPurposes, ({ name, purpose }) => `${name}:${purpose}`);
67
+ // Create new processing purposes
68
+ const newProcessingPurposes = inputs.filter((input) => !processingPurposeByName[`${input.name}:${input.purpose}`]);
69
+ // Create new processing purposes
70
+ await (0, bluebird_1.mapSeries)(newProcessingPurposes, async (processingPurpose) => {
71
+ try {
72
+ const newProcessingPurpose = await createProcessingPurpose(client, processingPurpose);
73
+ processingPurposeByName[`${newProcessingPurpose.name}:${newProcessingPurpose.purpose}`] = newProcessingPurpose;
74
+ logger_1.logger.info(colors_1.default.green(`Successfully synced processing purpose "${processingPurpose.name}"!`));
75
+ }
76
+ catch (err) {
77
+ encounteredError = true;
78
+ logger_1.logger.info(colors_1.default.red(`Failed to sync processing purpose "${processingPurpose.name}"! - ${err.message}`));
79
+ }
80
+ });
81
+ // Update all processing purposes
82
+ try {
83
+ logger_1.logger.info(colors_1.default.magenta(`Updating "${inputs.length}" processing purposes!`));
84
+ await updateProcessingPurposes(client, inputs.map((input) => [
85
+ input,
86
+ processingPurposeByName[`${input.name}:${input.purpose}`].id,
87
+ ]));
88
+ logger_1.logger.info(colors_1.default.green(`Successfully synced "${inputs.length}" processing purposes!`));
89
+ }
90
+ catch (err) {
91
+ encounteredError = true;
92
+ logger_1.logger.info(colors_1.default.red(`Failed to sync "${inputs.length}" processing purposes ! - ${err.message}`));
93
+ }
94
+ return !encounteredError;
95
+ }
96
+ exports.syncProcessingPurposes = syncProcessingPurposes;
97
+ //# sourceMappingURL=syncProcessingPurposes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncProcessingPurposes.js","sourceRoot":"","sources":["../../src/graphql/syncProcessingPurposes.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAqC;AACrC,iCAGgB;AAChB,sCAAmC;AACnC,yDAAiC;AACjC,6DAA0D;AAC1D,oDAA4B;AAC5B,6EAGsC;AAEtC;;;;;GAKG;AACI,KAAK,UA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AC;QACF,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CACV,wBAAwB,MAAM,CAAC,MAAM,wBAAwB,CAC9D,CACF,CAAC;KACH;IAAC,OAAO,GAAG,EAAE;QACZ,gBAAgB,GAAG,IAAI,CAAC;QACxB,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,GAAG,CACR,mBAAmB,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,OAAO,EAAE,CAC3E,CACF,CAAC;KACH;IAED,OAAO,CAAC,gBAAgB,CAAC;AAC3B,CAAC;AA/ED,wDA+EC"}
@@ -0,0 +1,26 @@
1
+ import { VendorInput } from '../codecs';
2
+ import { GraphQLClient } from 'graphql-request';
3
+ import { Vendor } from './fetchAllVendors';
4
+ /**
5
+ * Input to create a new vendor
6
+ *
7
+ * @param client - GraphQL client
8
+ * @param vendor - Input
9
+ */
10
+ export declare function createVendor(client: GraphQLClient, vendor: VendorInput): Promise<Pick<Vendor, 'id' | 'title'>>;
11
+ /**
12
+ * Input to update vendors
13
+ *
14
+ * @param client - GraphQL client
15
+ * @param vendorIdParis - [VendorInput, vendorId] list
16
+ */
17
+ export declare function updateVendors(client: GraphQLClient, vendorIdParis: [VendorInput, string][]): Promise<void>;
18
+ /**
19
+ * Sync the data inventory vendors
20
+ *
21
+ * @param client - GraphQL client
22
+ * @param inputs - Inputs to create
23
+ * @returns True if run without error, returns false if an error occurred
24
+ */
25
+ export declare function syncVendors(client: GraphQLClient, inputs: VendorInput[]): Promise<boolean>;
26
+ //# sourceMappingURL=syncVendors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncVendors.d.ts","sourceRoot":"","sources":["../../src/graphql/syncVendors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,OAAO,EAAmB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC,CAwBvC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,GACrC,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAsDlB"}
@@ -0,0 +1,108 @@
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.syncVendors = exports.updateVendors = exports.createVendor = void 0;
7
+ const bluebird_1 = require("bluebird");
8
+ const gqls_1 = require("./gqls");
9
+ const logger_1 = require("../logger");
10
+ const keyBy_1 = __importDefault(require("lodash/keyBy"));
11
+ const makeGraphQLRequest_1 = require("./makeGraphQLRequest");
12
+ const colors_1 = __importDefault(require("colors"));
13
+ const fetchAllVendors_1 = require("./fetchAllVendors");
14
+ /**
15
+ * Input to create a new vendor
16
+ *
17
+ * @param client - GraphQL client
18
+ * @param vendor - Input
19
+ */
20
+ async function createVendor(client, vendor) {
21
+ const input = {
22
+ title: vendor.title,
23
+ description: vendor.description,
24
+ address: vendor.address,
25
+ headquarterCountry: vendor.headquarterCountry,
26
+ headquarterSubDivision: vendor.headquarterSubDivision,
27
+ dataProcessingAgreementLink: vendor.dataProcessingAgreementLink,
28
+ contactName: vendor.contactName,
29
+ contactPhone: vendor.contactPhone,
30
+ websiteUrl: vendor.websiteUrl,
31
+ // TODO: https://transcend.height.app/T-31994 - add attributes, teams, owners
32
+ };
33
+ const { createVendor } = await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.CREATE_VENDOR, {
34
+ input,
35
+ });
36
+ return createVendor.vendor;
37
+ }
38
+ exports.createVendor = createVendor;
39
+ /**
40
+ * Input to update vendors
41
+ *
42
+ * @param client - GraphQL client
43
+ * @param vendorIdParis - [VendorInput, vendorId] list
44
+ */
45
+ async function updateVendors(client, vendorIdParis) {
46
+ await (0, makeGraphQLRequest_1.makeGraphQLRequest)(client, gqls_1.UPDATE_VENDORS, {
47
+ input: {
48
+ vendors: vendorIdParis.map(([vendor, id]) => ({
49
+ id,
50
+ title: vendor.title,
51
+ description: vendor.description,
52
+ address: vendor.address,
53
+ headquarterCountry: vendor.headquarterCountry,
54
+ headquarterSubDivision: vendor.headquarterSubDivision,
55
+ dataProcessingAgreementLink: vendor.dataProcessingAgreementLink,
56
+ contactName: vendor.contactName,
57
+ contactPhone: vendor.contactPhone,
58
+ websiteUrl: vendor.websiteUrl,
59
+ // TODO: https://transcend.height.app/T-31994 - add teams, owners
60
+ attributes: vendor.attributes,
61
+ })),
62
+ },
63
+ });
64
+ }
65
+ exports.updateVendors = updateVendors;
66
+ /**
67
+ * Sync the data inventory vendors
68
+ *
69
+ * @param client - GraphQL client
70
+ * @param inputs - Inputs to create
71
+ * @returns True if run without error, returns false if an error occurred
72
+ */
73
+ async function syncVendors(client, inputs) {
74
+ // Fetch existing
75
+ logger_1.logger.info(colors_1.default.magenta(`Syncing "${inputs.length}" vendors...`));
76
+ let encounteredError = false;
77
+ // Fetch existing
78
+ const existingVendors = await (0, fetchAllVendors_1.fetchAllVendors)(client);
79
+ // Look up by title
80
+ const vendorByTitle = (0, keyBy_1.default)(existingVendors, 'title');
81
+ // Create new vendors
82
+ const newVendors = inputs.filter((input) => !vendorByTitle[input.title]);
83
+ // Create new vendors
84
+ await (0, bluebird_1.mapSeries)(newVendors, async (vendor) => {
85
+ try {
86
+ const newVendor = await createVendor(client, vendor);
87
+ vendorByTitle[newVendor.title] = newVendor;
88
+ logger_1.logger.info(colors_1.default.green(`Successfully synced vendor "${vendor.title}"!`));
89
+ }
90
+ catch (err) {
91
+ encounteredError = true;
92
+ logger_1.logger.info(colors_1.default.red(`Failed to sync vendor "${vendor.title}"! - ${err.message}`));
93
+ }
94
+ });
95
+ // Update all vendors
96
+ try {
97
+ logger_1.logger.info(colors_1.default.magenta(`Updating "${inputs.length}" vendors!`));
98
+ await updateVendors(client, inputs.map((input) => [input, vendorByTitle[input.title].id]));
99
+ logger_1.logger.info(colors_1.default.green(`Successfully synced "${inputs.length}" vendors!`));
100
+ }
101
+ catch (err) {
102
+ encounteredError = true;
103
+ logger_1.logger.info(colors_1.default.red(`Failed to sync "${inputs.length}" vendors ! - ${err.message}`));
104
+ }
105
+ return !encounteredError;
106
+ }
107
+ exports.syncVendors = syncVendors;
108
+ //# sourceMappingURL=syncVendors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncVendors.js","sourceRoot":"","sources":["../../src/graphql/syncVendors.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAqC;AACrC,iCAAuD;AACvD,sCAAmC;AACnC,yDAAiC;AACjC,6DAA0D;AAC1D,oDAA4B;AAC5B,uDAA4D;AAE5D;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAChC,MAAqB,EACrB,MAAmB;IAEnB,MAAM,KAAK,GAAG;QACZ,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;QACrD,2BAA2B,EAAE,MAAM,CAAC,2BAA2B;QAC/D,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,6EAA6E;KAC9E,CAAC;IAEF,MAAM,EAAE,Y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