@transcend-io/cli 2.2.3

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 (95) hide show
  1. package/.yarn/sdks/eslint/package.json +6 -0
  2. package/.yarn/sdks/prettier/package.json +6 -0
  3. package/.yarn/sdks/typescript/package.json +6 -0
  4. package/LICENSE +21 -0
  5. package/README.md +301 -0
  6. package/build/cli-pull.d.ts +3 -0
  7. package/build/cli-pull.d.ts.map +1 -0
  8. package/build/cli-pull.js +53 -0
  9. package/build/cli-pull.js.map +1 -0
  10. package/build/cli-push.d.ts +3 -0
  11. package/build/cli-push.d.ts.map +1 -0
  12. package/build/cli-push.js +82 -0
  13. package/build/cli-push.js.map +1 -0
  14. package/build/codecs.d.ts +541 -0
  15. package/build/codecs.d.ts.map +1 -0
  16. package/build/codecs.js +216 -0
  17. package/build/codecs.js.map +1 -0
  18. package/build/constants.d.ts +2 -0
  19. package/build/constants.d.ts.map +1 -0
  20. package/build/constants.js +5 -0
  21. package/build/constants.js.map +1 -0
  22. package/build/fetchApiKeys.d.ts +21 -0
  23. package/build/fetchApiKeys.d.ts.map +1 -0
  24. package/build/fetchApiKeys.js +56 -0
  25. package/build/fetchApiKeys.js.map +1 -0
  26. package/build/fetchDataSubjects.d.ts +40 -0
  27. package/build/fetchDataSubjects.d.ts.map +1 -0
  28. package/build/fetchDataSubjects.js +85 -0
  29. package/build/fetchDataSubjects.js.map +1 -0
  30. package/build/fetchIdentifiers.d.ts +27 -0
  31. package/build/fetchIdentifiers.d.ts.map +1 -0
  32. package/build/fetchIdentifiers.js +83 -0
  33. package/build/fetchIdentifiers.js.map +1 -0
  34. package/build/gqls.d.ts +16 -0
  35. package/build/gqls.d.ts.map +1 -0
  36. package/build/gqls.js +310 -0
  37. package/build/gqls.js.map +1 -0
  38. package/build/index.d.ts +4 -0
  39. package/build/index.d.ts.map +1 -0
  40. package/build/index.js +16 -0
  41. package/build/index.js.map +1 -0
  42. package/build/logger.d.ts +2 -0
  43. package/build/logger.d.ts.map +1 -0
  44. package/build/logger.js +5 -0
  45. package/build/logger.js.map +1 -0
  46. package/build/pullTranscendConfiguration.d.ts +11 -0
  47. package/build/pullTranscendConfiguration.d.ts.map +1 -0
  48. package/build/pullTranscendConfiguration.js +95 -0
  49. package/build/pullTranscendConfiguration.js.map +1 -0
  50. package/build/readTranscendYaml.d.ts +19 -0
  51. package/build/readTranscendYaml.d.ts.map +1 -0
  52. package/build/readTranscendYaml.js +47 -0
  53. package/build/readTranscendYaml.js.map +1 -0
  54. package/build/syncConfigurationToTranscend.d.ts +11 -0
  55. package/build/syncConfigurationToTranscend.d.ts.map +1 -0
  56. package/build/syncConfigurationToTranscend.js +96 -0
  57. package/build/syncConfigurationToTranscend.js.map +1 -0
  58. package/build/syncDataSilos.d.ts +144 -0
  59. package/build/syncDataSilos.d.ts.map +1 -0
  60. package/build/syncDataSilos.js +178 -0
  61. package/build/syncDataSilos.js.map +1 -0
  62. package/build/syncEnrichers.d.ts +45 -0
  63. package/build/syncEnrichers.d.ts.map +1 -0
  64. package/build/syncEnrichers.js +69 -0
  65. package/build/syncEnrichers.js.map +1 -0
  66. package/build/tests/fetchApiKeys.test.d.ts +1 -0
  67. package/build/tests/fetchApiKeys.test.d.ts.map +1 -0
  68. package/build/tests/fetchApiKeys.test.js +3 -0
  69. package/build/tests/fetchApiKeys.test.js.map +1 -0
  70. package/build/tests/fetchDataSubjects.test.d.ts +1 -0
  71. package/build/tests/fetchDataSubjects.test.d.ts.map +1 -0
  72. package/build/tests/fetchDataSubjects.test.js +3 -0
  73. package/build/tests/fetchDataSubjects.test.js.map +1 -0
  74. package/build/tests/fetchIdentifiers.test.d.ts +1 -0
  75. package/build/tests/fetchIdentifiers.test.d.ts.map +1 -0
  76. package/build/tests/fetchIdentifiers.test.js +3 -0
  77. package/build/tests/fetchIdentifiers.test.js.map +1 -0
  78. package/build/tests/main.test.d.ts +1 -0
  79. package/build/tests/main.test.d.ts.map +1 -0
  80. package/build/tests/main.test.js +6 -0
  81. package/build/tests/main.test.js.map +1 -0
  82. package/build/tests/readTranscendYaml.test.d.ts +2 -0
  83. package/build/tests/readTranscendYaml.test.d.ts.map +1 -0
  84. package/build/tests/readTranscendYaml.test.js +38 -0
  85. package/build/tests/readTranscendYaml.test.js.map +1 -0
  86. package/build/tests/syncDataSilos.test.d.ts +1 -0
  87. package/build/tests/syncDataSilos.test.d.ts.map +1 -0
  88. package/build/tests/syncDataSilos.test.js +3 -0
  89. package/build/tests/syncDataSilos.test.js.map +1 -0
  90. package/build/tests/syncEnrichers.test.d.ts +1 -0
  91. package/build/tests/syncEnrichers.test.d.ts.map +1 -0
  92. package/build/tests/syncEnrichers.test.js +3 -0
  93. package/build/tests/syncEnrichers.test.js.map +1 -0
  94. package/build/tsbuildinfo +1 -0
  95. package/package.json +70 -0
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.TranscendInput = exports.DataSiloInput = exports.DatapointInput = exports.FieldInput = exports.EnricherInput = exports.ApiKeyInput = void 0;
23
+ const t = __importStar(require("io-ts"));
24
+ const type_utils_1 = require("@transcend-io/type-utils");
25
+ const privacy_types_1 = require("@transcend-io/privacy-types");
26
+ /**
27
+ * Input to define API keys that may be shared across data silos
28
+ * in the data map. When creating new data silos through the yaml
29
+ * cli, it is possible to specify which API key should be associated
30
+ * with the newly created data silo.
31
+ *
32
+ * @see https://docs.transcend.io/docs/authentication
33
+ */
34
+ exports.ApiKeyInput = t.type({
35
+ /** The display title of the enricher */
36
+ title: t.string,
37
+ });
38
+ /**
39
+ * Input to define an enricher
40
+ *
41
+ * Define enricher or pre-flight check webhooks that will be executed
42
+ * prior to privacy request workflows. Some examples may include:
43
+ * - identity enrichment: look up additional identifiers for that user.
44
+ * i.e. map an email address to a user ID
45
+ * - fraud check: auto-cancel requests if the user is flagged for fraudulent behavior
46
+ * - customer check: auto-cancel request for some custom business criteria
47
+ *
48
+ * @see https://docs.transcend.io/docs/identity-enrichment
49
+ */
50
+ exports.EnricherInput = t.intersection([
51
+ t.type({
52
+ /** The display title of the enricher */
53
+ title: t.string,
54
+ /** The URL of the enricher */
55
+ url: t.string,
56
+ /**
57
+ * The name of the identifier that will be the input to this enricher.
58
+ * Whenever a privacy request contains this identifier, the webhook will
59
+ * be called with the value of that identifier as input
60
+ */
61
+ 'input-identifier': t.string,
62
+ /**
63
+ * The names of the identifiers that can be resolved by this enricher.
64
+ * i.e. email -> [userId, phone, advertisingId]
65
+ */
66
+ 'output-identifiers': t.array(t.string),
67
+ }),
68
+ t.partial({
69
+ /** Internal description for why the enricher is needed */
70
+ description: t.string,
71
+ /** The privacy actions that the enricher should run against */
72
+ 'privacy-actions': t.array((0, type_utils_1.valuesOf)(privacy_types_1.RequestAction)),
73
+ }),
74
+ ]);
75
+ /**
76
+ * Annotate specific fields within a datapoint. These are often database table columns.
77
+ * Fields can also be a JSON object or separate file.
78
+ */
79
+ exports.FieldInput = t.intersection([
80
+ t.type({
81
+ /** The unique key of the field */
82
+ key: t.string,
83
+ }),
84
+ t.partial({
85
+ /** Display title of the field */
86
+ title: t.string,
87
+ /** The unique key of the datapoint. When a database, this is the table name. */
88
+ key: t.string,
89
+ /** Description of the field */
90
+ description: t.string,
91
+ }),
92
+ ]);
93
+ /**
94
+ * Datapoints are the different types of data models that existing within your data silo.
95
+ * If the data silo is a database, these would be your tables.
96
+ * Note: These are currently called "datapoints" in the Transcend UI and documentation.
97
+ *
98
+ * @see https://docs.transcend.io/docs/the-data-map#datapoints
99
+ */
100
+ exports.DatapointInput = t.intersection([
101
+ t.type({
102
+ /** The display title of the enricher */
103
+ title: t.string,
104
+ /** The unique key of the datapoint. When a database, this is the table name. */
105
+ key: t.string,
106
+ }),
107
+ t.partial({
108
+ /** Internal description for why the enricher is needed */
109
+ description: t.string,
110
+ /**
111
+ * What is the purpose of processing for this datapoint/table?
112
+ *
113
+ * @see https://github.com/transcend-io/privacy-types/blob/main/src/objects.ts
114
+ */
115
+ purpose: (0, type_utils_1.valuesOf)(privacy_types_1.ProcessingPurpose),
116
+ /**
117
+ * The category of personal data for this datapoint
118
+ *
119
+ * @see https://github.com/transcend-io/privacy-types/blob/main/src/objects.ts
120
+ */
121
+ category: (0, type_utils_1.valuesOf)(privacy_types_1.DataCategoryType),
122
+ /**
123
+ * The SQL queries that should be run for that datapoint in a privacy request.
124
+ *
125
+ * @see https://github.com/transcend-io/privacy-types/blob/main/src/actions.ts
126
+ */
127
+ 'privacy-action-queries': t.partial((0, type_utils_1.applyEnum)(privacy_types_1.RequestActionObjectResolver, () => t.string)),
128
+ /**
129
+ * The types of privacy actions that this datapoint can implement
130
+ *
131
+ * @see https://github.com/transcend-io/privacy-types/blob/main/src/actions.ts
132
+ */
133
+ 'privacy-actions': t.array((0, type_utils_1.valuesOf)(privacy_types_1.RequestActionObjectResolver)),
134
+ /**
135
+ * Provide field-level metadata for this datapoint.
136
+ * This is often the column metadata
137
+ */
138
+ fields: t.array(exports.FieldInput),
139
+ }),
140
+ ]);
141
+ /**
142
+ * Input to define a data silo
143
+ *
144
+ * Define the data silos in your data map. A data silo can be a database,
145
+ * or a web service that may use a collection of different data stores under the hood.
146
+ *
147
+ * @see https://docs.transcend.io/docs/the-data-map#data-silos
148
+ */
149
+ exports.DataSiloInput = t.intersection([
150
+ t.type({
151
+ /** The display title of the data silo */
152
+ title: t.string,
153
+ /**
154
+ * The type of integration. Common internal system types:
155
+ * server | database | cron | promptAPerson
156
+ */
157
+ integrationName: t.string,
158
+ }),
159
+ t.partial({
160
+ /** A description for that data silo */
161
+ description: t.string,
162
+ /** The webhook URL to notify for data privacy requests */
163
+ url: t.string,
164
+ /** The email address of the user to notify when a promptAPerson integration */
165
+ 'notify-email-address': t.string,
166
+ /** The title of the API key that will be used to respond to privacy requests */
167
+ 'api-key-title': t.string,
168
+ /**
169
+ * Specify which data subjects may have personally-identifiable-information (PII) within this system
170
+ * This field can be omitted, and the default assumption will be that the system may potentially
171
+ * contain PII for any potential data subject type.
172
+ */
173
+ 'data-subjects': t.array(t.string),
174
+ /**
175
+ * When this data silo implements a privacy request, these are the identifiers
176
+ * that should be looked up within this system.
177
+ */
178
+ 'identity-keys': t.array(t.string),
179
+ /**
180
+ * When a data erasure request is being performed, this data silo should not be deleted from
181
+ * until all of the following data silos were deleted first. This list can contain other internal
182
+ * systems defined in this file, as well as any of the SaaS tools connected in your Transcend instance.
183
+ */
184
+ 'deletion-dependencies': t.array(t.string),
185
+ /**
186
+ * The email addresses of the employees within your company that are the go-to individuals
187
+ * for managing this data silo
188
+ */
189
+ owners: t.array(t.string),
190
+ /**
191
+ * Specify this flag if the data silo is under development and should not be included
192
+ * in production privacy request workflows. Will still sync metadata to app.transcend.io.
193
+ */
194
+ disabled: t.boolean,
195
+ /**
196
+ * Datapoints defined within this data silo, see comment of `DatapointInput`
197
+ * for further details.
198
+ */
199
+ datapoints: t.array(exports.DatapointInput),
200
+ }),
201
+ ]);
202
+ exports.TranscendInput = t.partial({
203
+ /**
204
+ * API key definitions
205
+ */
206
+ 'api-keys': t.array(exports.ApiKeyInput),
207
+ /**
208
+ * Enricher definitions
209
+ */
210
+ enrichers: t.array(exports.EnricherInput),
211
+ /**
212
+ * Data silo definitions
213
+ */
214
+ 'data-silos': t.array(exports.DataSiloInput),
215
+ });
216
+ //# sourceMappingURL=codecs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs.js","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,yDAA+D;AAC/D,+DAKqC;AAErC;;;;;;;GAOG;AACU,QAAA,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC;IAChC,wCAAwC;IACxC,KAAK,EAAE,CAAC,CAAC,MAAM;CAChB,CAAC,CAAC;AAKH;;;;;;;;;;;GAWG;AACU,QAAA,aAAa,GAAG,CAAC,CAAC,YAAY,CAAC;IAC1C,CAAC,CAAC,IAAI,CAAC;QACL,wCAAwC;QACxC,KAAK,EAAE,CAAC,CAAC,MAAM;QACf,8BAA8B;QAC9B,GAAG,EAAE,CAAC,CAAC,MAAM;QACb;;;;WAIG;QACH,kBAAkB,EAAE,CAAC,CAAC,MAAM;QAC5B;;;WAGG;QACH,oBAAoB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;KACxC,CAAC;IACF,CAAC,CAAC,OAAO,CAAC;QACR,0DAA0D;QAC1D,WAAW,EAAE,CAAC,CAAC,MAAM;QACrB,+DAA+D;QAC/D,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,IAAA,qBAAQ,EAAC,6BAAa,CAAC,CAAC;KACpD,CAAC;CACH,CAAC,CAAC;AAKH;;;GAGG;AACU,QAAA,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC;IACvC,CAAC,CAAC,IAAI,CAAC;QACL,kCAAkC;QAClC,GAAG,EAAE,CAAC,CAAC,MAAM;KACd,CAAC;IACF,CAAC,CAAC,OAAO,CAAC;QACR,iCAAiC;QACjC,KAAK,EAAE,CAAC,CAAC,MAAM;QACf,gFAAgF;QAChF,GAAG,EA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,CAAC,CAAC,MAAM;QAChC,gFAAgF;QAChF,eAAe,EAAE,CAAC,CAAC,MAAM;QACzB;;;;WAIG;QACH,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAClC;;;WAGG;QACH,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAClC;;;;WAIG;QACH,uBAAuB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1C;;;WAGG;QACH,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACzB;;;WAGG;QACH,QAAQ,EAAE,CAAC,CAAC,OAAO;QACnB;;;WAGG;QACH,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,sBAAc,CAAC;KACpC,CAAC;CACH,CAAC,CAAC;AAKU,QAAA,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC;IACtC;;OAEG;IACH,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAW,CAAC;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAa,CAAC;IACjC;;OAEG;IACH,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAa,CAAC;CACrC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const ADMIN_DASH = "https://app.transcend.io/privacy-requests/connected-services";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,iEACyC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ADMIN_DASH = void 0;
4
+ exports.ADMIN_DASH = 'https://app.transcend.io/privacy-requests/connected-services';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GACrB,8DAA8D,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import { TranscendInput } from './codecs';
3
+ export interface ApiKey {
4
+ /** ID of APi key */
5
+ id: string;
6
+ /** Title of API key */
7
+ title: string;
8
+ }
9
+ /**
10
+ * Fetch all apiKeys and if any are found in the config that are
11
+ * missing, create those apiKeys.
12
+ *
13
+ * @param apiKeyInputs - API keys to fetch metadata on
14
+ * @param client - GraphQL client
15
+ * @param fetchAll - When true, fetch all API keys
16
+ * @returns A map from apiKey title to Identifier
17
+ */
18
+ export declare function fetchApiKeys({ 'api-keys': apiKeyInputs, 'data-silos': dataSilos, }: TranscendInput, client: GraphQLClient, fetchAll?: boolean): Promise<{
19
+ [k in string]: ApiKey;
20
+ }>;
21
+ //# sourceMappingURL=fetchApiKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchApiKeys.d.ts","sourceRoot":"","sources":["../src/fetchApiKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,MAAM;IACrB,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAMD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,EACE,UAAU,EAAE,YAAiB,EAC7B,YAAY,EAAE,SAAc,GAC7B,EAAE,cAAc,EACjB,MAAM,EAAE,aAAa,EACrB,QAAQ,UAAQ,GACf,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,GAAG,MAAM;CAAE,CAAC,CAkDpC"}
@@ -0,0 +1,56 @@
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.fetchApiKeys = void 0;
7
+ const gqls_1 = require("./gqls");
8
+ const keyBy_1 = __importDefault(require("lodash/keyBy"));
9
+ const uniq_1 = __importDefault(require("lodash/uniq"));
10
+ const difference_1 = __importDefault(require("lodash/difference"));
11
+ const logger_1 = require("./logger");
12
+ const colors_1 = __importDefault(require("colors"));
13
+ const PAGE_SIZE = 20;
14
+ const ADMIN_LINK = 'https://app.transcend.io/infrastructure/api-keys';
15
+ /**
16
+ * Fetch all apiKeys and if any are found in the config that are
17
+ * missing, create those apiKeys.
18
+ *
19
+ * @param apiKeyInputs - API keys to fetch metadata on
20
+ * @param client - GraphQL client
21
+ * @param fetchAll - When true, fetch all API keys
22
+ * @returns A map from apiKey title to Identifier
23
+ */
24
+ async function fetchApiKeys({ 'api-keys': apiKeyInputs = [], 'data-silos': dataSilos = [], }, client, fetchAll = false) {
25
+ logger_1.logger.info(colors_1.default.magenta(`Fetching ${fetchAll ? 'all' : apiKeyInputs.length} API keys...`));
26
+ const titles = apiKeyInputs.map(({ title }) => title);
27
+ const apiKeys = [];
28
+ let offset = 0;
29
+ // Paginate
30
+ let shouldContinue = false;
31
+ do {
32
+ const { apiKeys: { nodes },
33
+ // eslint-disable-next-line no-await-in-loop
34
+ } = await client.request(gqls_1.API_KEYS, {
35
+ first: PAGE_SIZE,
36
+ offset,
37
+ titles: fetchAll ? undefined : titles,
38
+ });
39
+ apiKeys.push(...nodes);
40
+ offset += PAGE_SIZE;
41
+ shouldContinue = nodes.length === PAGE_SIZE;
42
+ } while (shouldContinue);
43
+ // Create a map
44
+ const apiKeysByTitle = (0, keyBy_1.default)(apiKeys, 'title');
45
+ // Determine expected set of apiKeys expected
46
+ const expectedApiKeyTitles = (0, uniq_1.default)(dataSilos.map((silo) => silo['api-key-title']).filter((x) => !!x));
47
+ const missingApiKeys = (0, difference_1.default)(expectedApiKeyTitles, apiKeys.map(({ title }) => title));
48
+ // If there are missing apiKeys, throw an error
49
+ if (missingApiKeys.length > 0) {
50
+ logger_1.logger.info(colors_1.default.red(`Failed to find API keys "${missingApiKeys.join('", "')}"! Make sure these API keys are created at: ${ADMIN_LINK}`));
51
+ process.exit(1);
52
+ }
53
+ return apiKeysByTitle;
54
+ }
55
+ exports.fetchApiKeys = fetchApiKeys;
56
+ //# sourceMappingURL=fetchApiKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchApiKeys.js","sourceRoot":"","sources":["../src/fetchApiKeys.ts"],"names":[],"mappings":";;;;;;AACA,iCAAkC;AAClC,yDAAiC;AACjC,uDAA+B;AAC/B,mEAA2C;AAC3C,qCAAkC;AAClC,oDAA4B;AAU5B,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,UAAU,GAAG,kDAAkD,CAAC;AAEtE;;;;;;;;GAQG;AACI,KAAK,UAAU,YAAY,CAChC,EACE,UAAU,EAAE,YAAY,GAAG,EAAE,EAC7B,YAAY,EAAE,SAAS,GAAG,EAAE,GACb,EACjB,MAAqB,EACrB,QAAQ,GAAG,KAAK;IAEhB,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,OAAO,CACZ,YAAY,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,cAAc,CACjE,CACF,CAAC;IACF,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,WAAW;IACX,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,GAAG;QACD,MAAM,EACJ,OAAO,EAAE,EAAE,KAAK,EAAE;QAClB,4CAA4C;UAC7C,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,eAAQ,EAAE;YACjC,KAAK,EAAE,SAAS;YAChB,MAAM;YACN,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;SACtC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QACvB,MAAM,IAAI,SAAS,CAAC;QACpB,cAAc,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC;KAC7C,QAAQ,cAAc,EAAE;IAEzB,eAAe;IACf,MAAM,cAAc,GAAG,IAAA,eAAK,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE/C,6CAA6C;IAC7C,MAAM,oBAAoB,GAAG,IAAA,cAAI,EAC/B,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAClE,CAAC;IACF,MAAM,cAAc,GAAG,IAAA,oBAAU,EAC/B,oBAAoB,EACpB,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAClC,CAAC;IAEF,+CAA+C;IAC/C,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,GAAG,CACR,4BAA4B,cAAc,CAAC,IAAI,CAC7C,MAAM,CACP,+CAA+C,UAAU,EAAE,CAC7D,CACF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAzDD,oCAyDC"}
@@ -0,0 +1,40 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import { TranscendInput } from './codecs';
3
+ export interface DataSubject {
4
+ /** ID of data subject */
5
+ id: string;
6
+ /** Type of data subject */
7
+ type: string;
8
+ }
9
+ /**
10
+ * Fetch all of the data subjects in the organization
11
+ *
12
+ * @param input - Input to fetch
13
+ * @param client - GraphQL client
14
+ * @param fetchAll - When true, always fetch all subjects
15
+ * @returns The list of data subjects
16
+ */
17
+ export declare function fetchDataSubjects({ 'data-silos': dataSilos }: TranscendInput, client: GraphQLClient, fetchAll?: boolean): Promise<{
18
+ [type in string]: DataSubject;
19
+ }>;
20
+ /**
21
+ * Convert a list of data subject types into the block list of IDs to assign to the data silo
22
+ *
23
+ * @param dataSubjectTypes - The list of data subject types that the data silo should be for
24
+ * @param allDataSubjects - All data subjects in the organization
25
+ * @returns The block list of data subject ids to not process against this data silo
26
+ */
27
+ export declare function convertToDataSubjectBlockList(dataSubjectTypes: string[], allDataSubjects: {
28
+ [type in string]: DataSubject;
29
+ }): string[];
30
+ /**
31
+ * Convert a list of data subject types into the allow list of types
32
+ *
33
+ * @param dataSubjectTypes - The list of data subject types that the data silo should be for
34
+ * @param allDataSubjects - All data subjects in the organization
35
+ * @returns The allow list of data subjects for that silo
36
+ */
37
+ export declare function convertToDataSubjectAllowlist(dataSubjectTypes: string[], allDataSubjects: {
38
+ [type in string]: DataSubject;
39
+ }): string[];
40
+ //# sourceMappingURL=fetchDataSubjects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchDataSubjects.d.ts","sourceRoot":"","sources":["../src/fetchDataSubjects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK1C,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,YAAY,EAAE,SAAc,EAAE,EAAE,cAAc,EAChD,MAAM,EAAE,aAAa,EACrB,QAAQ,UAAQ,GACf,OAAO,CAAC;KAAG,IAAI,IAAI,MAAM,GAAG,WAAW;CAAE,CAAC,CAyC5C;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,MAAM,EAAE,EAC1B,eAAe,EAAE;KAAG,IAAI,IAAI,MAAM,GAAG,WAAW;CAAE,GACjD,MAAM,EAAE,CAUV;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,MAAM,EAAE,EAC1B,eAAe,EAAE;KAAG,IAAI,IAAI,MAAM,GAAG,WAAW;CAAE,GACjD,MAAM,EAAE,CAUV"}
@@ -0,0 +1,85 @@
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.convertToDataSubjectAllowlist = exports.convertToDataSubjectBlockList = exports.fetchDataSubjects = void 0;
7
+ const gqls_1 = require("./gqls");
8
+ const keyBy_1 = __importDefault(require("lodash/keyBy"));
9
+ const flatten_1 = __importDefault(require("lodash/flatten"));
10
+ const uniq_1 = __importDefault(require("lodash/uniq"));
11
+ const difference_1 = __importDefault(require("lodash/difference"));
12
+ const logger_1 = require("./logger");
13
+ const colors_1 = __importDefault(require("colors"));
14
+ const bluebird_1 = require("bluebird");
15
+ /**
16
+ * Fetch all of the data subjects in the organization
17
+ *
18
+ * @param input - Input to fetch
19
+ * @param client - GraphQL client
20
+ * @param fetchAll - When true, always fetch all subjects
21
+ * @returns The list of data subjects
22
+ */
23
+ async function fetchDataSubjects({ 'data-silos': dataSilos = [] }, client, fetchAll = false) {
24
+ // Only need to fetch data subjects if specified in config
25
+ const expectedDataSubjects = (0, uniq_1.default)((0, flatten_1.default)(dataSilos.map((silo) => silo['data-subjects'] || []) || []));
26
+ if (expectedDataSubjects.length === 0 && !fetchAll) {
27
+ return {};
28
+ }
29
+ // Fetch all data subjects in the organization
30
+ const { internalSubjects } = await client.request(gqls_1.DATA_SUBJECTS);
31
+ const dataSubjectByName = (0, keyBy_1.default)(internalSubjects, 'type');
32
+ // Determine expected set of data subjects to create
33
+ const missingDataSubjects = (0, difference_1.default)(expectedDataSubjects, internalSubjects.map(({ type }) => type));
34
+ // If there are missing data subjects, create new ones
35
+ if (missingDataSubjects.length > 0) {
36
+ logger_1.logger.info(colors_1.default.magenta(`Creating ${missingDataSubjects.length} new data subjects...`));
37
+ await (0, bluebird_1.mapSeries)(missingDataSubjects, async (dataSubject) => {
38
+ logger_1.logger.info(colors_1.default.magenta(`Creating data subject ${dataSubject}...`));
39
+ const { createSubject } = await client.request(gqls_1.CREATE_DATA_SUBJECT, {
40
+ type: dataSubject,
41
+ });
42
+ logger_1.logger.info(colors_1.default.green(`Created data subject ${dataSubject}!`));
43
+ dataSubjectByName[dataSubject] = createSubject.subject;
44
+ });
45
+ }
46
+ return dataSubjectByName;
47
+ }
48
+ exports.fetchDataSubjects = fetchDataSubjects;
49
+ /**
50
+ * Convert a list of data subject types into the block list of IDs to assign to the data silo
51
+ *
52
+ * @param dataSubjectTypes - The list of data subject types that the data silo should be for
53
+ * @param allDataSubjects - All data subjects in the organization
54
+ * @returns The block list of data subject ids to not process against this data silo
55
+ */
56
+ function convertToDataSubjectBlockList(dataSubjectTypes, allDataSubjects) {
57
+ dataSubjectTypes.forEach((type) => {
58
+ if (!allDataSubjects[type]) {
59
+ throw new Error(`Expected to find data subject definition: ${type}`);
60
+ }
61
+ });
62
+ return Object.values(allDataSubjects)
63
+ .filter((silo) => !dataSubjectTypes.includes(silo.type))
64
+ .map(({ id }) => id);
65
+ }
66
+ exports.convertToDataSubjectBlockList = convertToDataSubjectBlockList;
67
+ /**
68
+ * Convert a list of data subject types into the allow list of types
69
+ *
70
+ * @param dataSubjectTypes - The list of data subject types that the data silo should be for
71
+ * @param allDataSubjects - All data subjects in the organization
72
+ * @returns The allow list of data subjects for that silo
73
+ */
74
+ function convertToDataSubjectAllowlist(dataSubjectTypes, allDataSubjects) {
75
+ dataSubjectTypes.forEach((type) => {
76
+ if (!allDataSubjects[type]) {
77
+ throw new Error(`Expected to find data subject definition: ${type}`);
78
+ }
79
+ });
80
+ return Object.values(allDataSubjects)
81
+ .filter((silo) => !dataSubjectTypes.includes(silo.type))
82
+ .map(({ type }) => type);
83
+ }
84
+ exports.convertToDataSubjectAllowlist = convertToDataSubjectAllowlist;
85
+ //# sourceMappingURL=fetchDataSubjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchDataSubjects.js","sourceRoot":"","sources":["../src/fetchDataSubjects.ts"],"names":[],"mappings":";;;;;;AACA,iCAA4D;AAC5D,yDAAiC;AACjC,6DAAqC;AACrC,uDAA+B;AAC/B,mEAA2C;AAE3C,qCAAkC;AAClC,oDAA4B;AAC5B,uCAAqC;AASrC;;;;;;;GAOG;AACI,KAAK,UAAU,iBAAiB,CACrC,EAAE,YAAY,EAAE,SAAS,GAAG,EAAE,EAAkB,EAChD,MAAqB,EACrB,QAAQ,GAAG,KAAK;IAEhB,0DAA0D;IAC1D,MAAM,oBAAoB,GAAG,IAAA,cAAI,EAC/B,IAAA,iBAAO,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CACpE,CAAC;IACF,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE;QAClD,OAAO,EAAE,CAAC;KACX;IAED,8CAA8C;IAC9C,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAG9C,oBAAa,CAAC,CAAC;IAClB,MAAM,iBAAiB,GAAG,IAAA,eAAK,EAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAE1D,oDAAoD;IACpD,MAAM,mBAAmB,GAAG,IAAA,oBAAU,EACpC,oBAAoB,EACpB,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CACzC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sEAaC;AAED;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAC3C,gBAA0B,EAC1B,eAAkD;IAElD,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,6CAA6C,IAAI,EAAE,CAAC,CAAC;SACtE;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;SAClC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACvD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAbD,sEAaC"}
@@ -0,0 +1,27 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import { TranscendInput } from './codecs';
3
+ export interface Identifier {
4
+ /** ID of identifier */
5
+ id: string;
6
+ /** Name of identifier */
7
+ name: string;
8
+ }
9
+ /**
10
+ * Fetch all identifiers in the organization
11
+ *
12
+ * @param client - GraphQL client
13
+ * @returns All identifiers in the organization
14
+ */
15
+ export declare function fetchAllIdentifiers(client: GraphQLClient): Promise<Identifier[]>;
16
+ /**
17
+ * Fetch all identifiers and if any are found in the config that are
18
+ * missing, create those identifiers.
19
+ *
20
+ * @param input - Transcend input
21
+ * @param client - GraphQL client
22
+ * @returns A map from identifier name to Identifier
23
+ */
24
+ export declare function fetchIdentifiersAndCreateMissing({ enrichers, 'data-silos': dataSilos }: TranscendInput, client: GraphQLClient): Promise<{
25
+ [k in string]: Identifier;
26
+ }>;
27
+ //# sourceMappingURL=fetchIdentifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchIdentifiers.d.ts","sourceRoot":"","sources":["../src/fetchIdentifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM1C,MAAM,WAAW,UAAU;IACzB,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAID;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,UAAU,EAAE,CAAC,CAoBvB;AAED;;;;;;;GAOG;AACH,wBAAsB,gCAAgC,CACpD,EAAE,SAAc,EAAE,YAAY,EAAE,SAAc,EAAE,EAAE,cAAc,EAChE,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,GAAG,UAAU;CAAE,CAAC,CAmDxC"}
@@ -0,0 +1,83 @@
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.fetchIdentifiersAndCreateMissing = exports.fetchAllIdentifiers = void 0;
7
+ const gqls_1 = require("./gqls");
8
+ const keyBy_1 = __importDefault(require("lodash/keyBy"));
9
+ const uniq_1 = __importDefault(require("lodash/uniq"));
10
+ const flatten_1 = __importDefault(require("lodash/flatten"));
11
+ const difference_1 = __importDefault(require("lodash/difference"));
12
+ const logger_1 = require("./logger");
13
+ const colors_1 = __importDefault(require("colors"));
14
+ const bluebird_1 = require("bluebird");
15
+ const PAGE_SIZE = 20;
16
+ /**
17
+ * Fetch all identifiers in the organization
18
+ *
19
+ * @param client - GraphQL client
20
+ * @returns All identifiers in the organization
21
+ */
22
+ async function fetchAllIdentifiers(client) {
23
+ const identifiers = [];
24
+ let offset = 0;
25
+ // Try to fetch an enricher with the same title
26
+ let shouldContinue = false;
27
+ do {
28
+ const { identifiers: { nodes },
29
+ // eslint-disable-next-line no-await-in-loop
30
+ } = await client.request(gqls_1.IDENTIFIERS, {
31
+ first: PAGE_SIZE,
32
+ offset,
33
+ });
34
+ identifiers.push(...nodes);
35
+ offset += PAGE_SIZE;
36
+ shouldContinue = nodes.length === PAGE_SIZE;
37
+ } while (shouldContinue);
38
+ return identifiers;
39
+ }
40
+ exports.fetchAllIdentifiers = fetchAllIdentifiers;
41
+ /**
42
+ * Fetch all identifiers and if any are found in the config that are
43
+ * missing, create those identifiers.
44
+ *
45
+ * @param input - Transcend input
46
+ * @param client - GraphQL client
47
+ * @returns A map from identifier name to Identifier
48
+ */
49
+ async function fetchIdentifiersAndCreateMissing({ enrichers = [], 'data-silos': dataSilos = [] }, client) {
50
+ // Grab all existing identifiers
51
+ const identifiers = await fetchAllIdentifiers(client);
52
+ // Create a map
53
+ const identifiersByName = (0, keyBy_1.default)(identifiers, 'name');
54
+ // Determine expected set of identifiers
55
+ const expectedIdentifiers = (0, uniq_1.default)([
56
+ ...(0, flatten_1.default)(enrichers.map((enricher) => [
57
+ enricher['input-identifier'],
58
+ ...enricher['output-identifiers'],
59
+ ])),
60
+ ...(0, flatten_1.default)(dataSilos.map((dataSilo) => dataSilo['identity-keys'])),
61
+ ]).filter((x) => !!x);
62
+ const missingIdentifiers = (0, difference_1.default)(expectedIdentifiers, identifiers.map(({ name }) => name));
63
+ // If there are missing identifiers, create new ones
64
+ if (missingIdentifiers.length > 0) {
65
+ logger_1.logger.info(colors_1.default.magenta(`Creating ${missingIdentifiers.length} new identifiers...`));
66
+ const { newIdentifierTypes } = await client.request(gqls_1.NEW_IDENTIFIER_TYPES);
67
+ const nativeTypesRemaining = newIdentifierTypes.map(({ name }) => name);
68
+ await (0, bluebird_1.mapSeries)(missingIdentifiers, async (identifier) => {
69
+ logger_1.logger.info(colors_1.default.magenta(`Creating identifier ${identifier}...`));
70
+ const { createIdentifier } = await client.request(gqls_1.CREATE_IDENTIFIER, {
71
+ name: identifier,
72
+ type: nativeTypesRemaining.includes(identifier)
73
+ ? identifier
74
+ : 'custom',
75
+ });
76
+ logger_1.logger.info(colors_1.default.green(`Created identifier ${identifier}!`));
77
+ identifiersByName[identifier] = createIdentifier.identifier;
78
+ });
79
+ }
80
+ return identifiersByName;
81
+ }
82
+ exports.fetchIdentifiersAndCreateMissing = fetchIdentifiersAndCreateMissing;
83
+ //# sourceMappingURL=fetchIdentifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchIdentifiers.js","sourceRoot":"","sources":["../src/fetchIdentifiers.ts"],"names":[],"mappings":";;;;;;AACA,iCAA8E;AAC9E,yDAAiC;AACjC,uDAA+B;AAC/B,6DAAqC;AAErC,mEAA2C;AAC3C,qCAAkC;AAClC,oDAA4B;AAC5B,uCAAqC;AASrC,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;GAKG;AACI,KAAK,UAAU,mBAAmB,CACvC,MAAqB;IAErB,MAAM,WAAW,GAAiB,EAAE,CAAC;IACrC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,+CAA+C;IAC/C,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,GAAG;QACD,MAAM,EACJ,WAAW,EAAE,EAAE,KAAK,EAAE;QACtB,4CAA4C;UAC7C,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,kBAAW,EAAE;YACpC,KAAK,EAAE,SAAS;YAChB,MAAM;SACP,CAAC,CAAC;QACH,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC3B,MAAM,IAAI,SAAS,CAAC;QACpB,cAAc,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC;KAC7C,QAAQ,cAAc,EAAE;IAEzB,OAAO,WAAW,CAAC;AACrB,CAAC;AAtBD,kDAsBC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,gCAAgC,CACpD,EAAE,SAAS,GAAG,EAAE,EAAE,YAAY,EAAE,SAAS,GAAG,EAAE,EAAkB,EAChE,MAAqB;IAErB,gCAAgC;IAChC,MAAM,WAAW,GAAG,MAAM,mBAAmB,C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AAK,CAAC,CAAC,CAAC;YACpE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,wBAAiB,EAAE;gBACnE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,oBAAoB,CAAC,QAAQ,CAAC,UAAW,CAAC;oBAC9C,CAAC,CAAC,UAAU;oBACZ,CAAC,CAAC,QAAQ;aACb,CAAC,CAAC;YACH,eAAM,CAAC,IAAI,CAAC,gBAAM,CAAC,KAAK,CAAC,sBAAsB,UAAU,GAAG,CAAC,CAAC,CAAC;YAE/D,iBAAiB,CAAC,UAAW,CAAC,GAAG,gBAAgB,CAAC,UAAU,CAAC;QAC/D,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAtDD,4EAsDC"}
@@ -0,0 +1,16 @@
1
+ export declare const ENRICHERS: string;
2
+ export declare const IDENTIFIERS: string;
3
+ export declare const API_KEYS: string;
4
+ export declare const NEW_IDENTIFIER_TYPES: string;
5
+ export declare const CREATE_IDENTIFIER: string;
6
+ export declare const CREATE_ENRICHER: string;
7
+ export declare const UPDATE_ENRICHER: string;
8
+ export declare const DATA_SILOS: string;
9
+ export declare const DATA_SILO: string;
10
+ export declare const DATA_POINTS: string;
11
+ export declare const UPDATE_DATA_SILO: string;
12
+ export declare const DATA_SUBJECTS: string;
13
+ export declare const CREATE_DATA_SUBJECT: string;
14
+ export declare const UPDATE_OR_CREATE_DATA_POINT: string;
15
+ export declare const CREATE_DATA_SILO: string;
16
+ //# sourceMappingURL=gqls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gqls.d.ts","sourceRoot":"","sources":["../src/gqls.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,QAkBrB,CAAC;AAEF,eAAO,MAAM,WAAW,QASvB,CAAC;AAEF,eAAO,MAAM,QAAQ,QASpB,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAMhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAS7B,CAAC;AAEF,eAAO,MAAM,eAAe,QAuB3B,CAAC;AAEF,eAAO,MAAM,eAAe,QAwB3B,CAAC;AAEF,eAAO,MAAM,UAAU,QAoBtB,CAAC;AAEF,eAAO,MAAM,SAAS,QA4BrB,CAAC;AAEF,eAAO,MAAM,WAAW,QA+BvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAgC5B,CAAC;AAEF,eAAO,MAAM,aAAa,QAOzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAS/B,CAAC;AAEF,eAAO,MAAM,2BAA2B,QA6BvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAoC5B,CAAC"}