@salesforce/lds-adapters-cdp-data-transform 1.344.0

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.
@@ -0,0 +1,630 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$1, StoreKeyMap, createResourceParams as createResourceParams$1 } from '@luvio/engine';
8
+
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys, create: ObjectCreate } = Object;
11
+ const { stringify: JSONStringify$1 } = JSON;
12
+ const { isArray: ArrayIsArray$1 } = Array;
13
+ /**
14
+ * Validates an adapter config is well-formed.
15
+ * @param config The config to validate.
16
+ * @param adapter The adapter validation configuration.
17
+ * @param oneOf The keys the config must contain at least one of.
18
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
19
+ */
20
+ function validateConfig(config, adapter, oneOf) {
21
+ const { displayName } = adapter;
22
+ const { required, optional, unsupported } = adapter.parameters;
23
+ if (config === undefined ||
24
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
25
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
26
+ }
27
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
28
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
29
+ }
30
+ if (unsupported !== undefined &&
31
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
32
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
33
+ }
34
+ const supported = required.concat(optional);
35
+ if (ObjectKeys(config).some(key => !supported.includes(key))) {
36
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
37
+ }
38
+ }
39
+ function untrustedIsObject(untrusted) {
40
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
41
+ }
42
+ function areRequiredParametersPresent(config, configPropertyNames) {
43
+ return configPropertyNames.parameters.required.every(req => req in config);
44
+ }
45
+ const snapshotRefreshOptions = {
46
+ overrides: {
47
+ headers: {
48
+ 'Cache-Control': 'no-cache',
49
+ },
50
+ }
51
+ };
52
+ /**
53
+ * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
54
+ * This is needed because insertion order for JSON.stringify(object) affects output:
55
+ * JSON.stringify({a: 1, b: 2})
56
+ * "{"a":1,"b":2}"
57
+ * JSON.stringify({b: 2, a: 1})
58
+ * "{"b":2,"a":1}"
59
+ * @param data Data to be JSON-stringified.
60
+ * @returns JSON.stringified value with consistent ordering of keys.
61
+ */
62
+ function stableJSONStringify(node) {
63
+ // This is for Date values.
64
+ if (node && node.toJSON && typeof node.toJSON === 'function') {
65
+ // eslint-disable-next-line no-param-reassign
66
+ node = node.toJSON();
67
+ }
68
+ if (node === undefined) {
69
+ return;
70
+ }
71
+ if (typeof node === 'number') {
72
+ return isFinite(node) ? '' + node : 'null';
73
+ }
74
+ if (typeof node !== 'object') {
75
+ return JSONStringify$1(node);
76
+ }
77
+ let i;
78
+ let out;
79
+ if (ArrayIsArray$1(node)) {
80
+ out = '[';
81
+ for (i = 0; i < node.length; i++) {
82
+ if (i) {
83
+ out += ',';
84
+ }
85
+ out += stableJSONStringify(node[i]) || 'null';
86
+ }
87
+ return out + ']';
88
+ }
89
+ if (node === null) {
90
+ return 'null';
91
+ }
92
+ const keys = ObjectKeys(node).sort();
93
+ out = '';
94
+ for (i = 0; i < keys.length; i++) {
95
+ const key = keys[i];
96
+ const value = stableJSONStringify(node[key]);
97
+ if (!value) {
98
+ continue;
99
+ }
100
+ if (out) {
101
+ out += ',';
102
+ }
103
+ out += JSONStringify$1(key) + ':' + value;
104
+ }
105
+ return '{' + out + '}';
106
+ }
107
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
108
+ return {
109
+ name,
110
+ required,
111
+ resourceType,
112
+ typeCheckShape,
113
+ isArrayShape,
114
+ coerceFn,
115
+ };
116
+ }
117
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
118
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
119
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
120
+ return {
121
+ displayName,
122
+ parameters: {
123
+ required,
124
+ optional,
125
+ }
126
+ };
127
+ }
128
+ const keyPrefix = 'data-transform';
129
+
130
+ const { isArray: ArrayIsArray } = Array;
131
+ const { stringify: JSONStringify } = JSON;
132
+ function createLink(ref) {
133
+ return {
134
+ __ref: serializeStructuredKey(ref),
135
+ };
136
+ }
137
+
138
+ function validate$5(obj, path = 'TransformValidationIssueRepresentation') {
139
+ const v_error = (() => {
140
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
141
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
142
+ }
143
+ if (obj.errorCode !== undefined) {
144
+ const obj_errorCode = obj.errorCode;
145
+ const path_errorCode = path + '.errorCode';
146
+ if (typeof obj_errorCode !== 'string') {
147
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
148
+ }
149
+ }
150
+ if (obj.errorMessage !== undefined) {
151
+ const obj_errorMessage = obj.errorMessage;
152
+ const path_errorMessage = path + '.errorMessage';
153
+ if (typeof obj_errorMessage !== 'string') {
154
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
155
+ }
156
+ }
157
+ const obj_errorSeverity = obj.errorSeverity;
158
+ const path_errorSeverity = path + '.errorSeverity';
159
+ if (typeof obj_errorSeverity !== 'string') {
160
+ return new TypeError('Expected "string" but received "' + typeof obj_errorSeverity + '" (at "' + path_errorSeverity + '")');
161
+ }
162
+ })();
163
+ return v_error === undefined ? null : v_error;
164
+ }
165
+
166
+ function validate$4(obj, path = 'CdpUserRepresentation') {
167
+ const v_error = (() => {
168
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
169
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
170
+ }
171
+ const obj_id = obj.id;
172
+ const path_id = path + '.id';
173
+ if (typeof obj_id !== 'string') {
174
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
175
+ }
176
+ if (obj.name !== undefined) {
177
+ const obj_name = obj.name;
178
+ const path_name = path + '.name';
179
+ if (typeof obj_name !== 'string') {
180
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
181
+ }
182
+ }
183
+ if (obj.profilePhotoUrl !== undefined) {
184
+ const obj_profilePhotoUrl = obj.profilePhotoUrl;
185
+ const path_profilePhotoUrl = path + '.profilePhotoUrl';
186
+ if (typeof obj_profilePhotoUrl !== 'string') {
187
+ return new TypeError('Expected "string" but received "' + typeof obj_profilePhotoUrl + '" (at "' + path_profilePhotoUrl + '")');
188
+ }
189
+ }
190
+ })();
191
+ return v_error === undefined ? null : v_error;
192
+ }
193
+
194
+ function validate$3(obj, path = 'CdpAssetBaseRepresentation') {
195
+ const v_error = (() => {
196
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
197
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
198
+ }
199
+ if (obj.createdBy !== undefined) {
200
+ const obj_createdBy = obj.createdBy;
201
+ const path_createdBy = path + '.createdBy';
202
+ const referencepath_createdByValidationError = validate$4(obj_createdBy, path_createdBy);
203
+ if (referencepath_createdByValidationError !== null) {
204
+ let message = 'Object doesn\'t match CdpUserRepresentation (at "' + path_createdBy + '")\n';
205
+ message += referencepath_createdByValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
206
+ return new TypeError(message);
207
+ }
208
+ }
209
+ if (obj.createdDate !== undefined) {
210
+ const obj_createdDate = obj.createdDate;
211
+ const path_createdDate = path + '.createdDate';
212
+ if (typeof obj_createdDate !== 'string') {
213
+ return new TypeError('Expected "string" but received "' + typeof obj_createdDate + '" (at "' + path_createdDate + '")');
214
+ }
215
+ }
216
+ const obj_id = obj.id;
217
+ const path_id = path + '.id';
218
+ if (typeof obj_id !== 'string') {
219
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
220
+ }
221
+ if (obj.label !== undefined) {
222
+ const obj_label = obj.label;
223
+ const path_label = path + '.label';
224
+ if (typeof obj_label !== 'string') {
225
+ return new TypeError('Expected "string" but received "' + typeof obj_label + '" (at "' + path_label + '")');
226
+ }
227
+ }
228
+ if (obj.lastModifiedBy !== undefined) {
229
+ const obj_lastModifiedBy = obj.lastModifiedBy;
230
+ const path_lastModifiedBy = path + '.lastModifiedBy';
231
+ const referencepath_lastModifiedByValidationError = validate$4(obj_lastModifiedBy, path_lastModifiedBy);
232
+ if (referencepath_lastModifiedByValidationError !== null) {
233
+ let message = 'Object doesn\'t match CdpUserRepresentation (at "' + path_lastModifiedBy + '")\n';
234
+ message += referencepath_lastModifiedByValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
235
+ return new TypeError(message);
236
+ }
237
+ }
238
+ if (obj.lastModifiedDate !== undefined) {
239
+ const obj_lastModifiedDate = obj.lastModifiedDate;
240
+ const path_lastModifiedDate = path + '.lastModifiedDate';
241
+ if (typeof obj_lastModifiedDate !== 'string') {
242
+ return new TypeError('Expected "string" but received "' + typeof obj_lastModifiedDate + '" (at "' + path_lastModifiedDate + '")');
243
+ }
244
+ }
245
+ if (obj.name !== undefined) {
246
+ const obj_name = obj.name;
247
+ const path_name = path + '.name';
248
+ if (typeof obj_name !== 'string') {
249
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
250
+ }
251
+ }
252
+ if (obj.namespace !== undefined) {
253
+ const obj_namespace = obj.namespace;
254
+ const path_namespace = path + '.namespace';
255
+ if (typeof obj_namespace !== 'string') {
256
+ return new TypeError('Expected "string" but received "' + typeof obj_namespace + '" (at "' + path_namespace + '")');
257
+ }
258
+ }
259
+ if (obj.url !== undefined) {
260
+ const obj_url = obj.url;
261
+ const path_url = path + '.url';
262
+ if (typeof obj_url !== 'string') {
263
+ return new TypeError('Expected "string" but received "' + typeof obj_url + '" (at "' + path_url + '")');
264
+ }
265
+ }
266
+ })();
267
+ return v_error === undefined ? null : v_error;
268
+ }
269
+
270
+ function validate$2(obj, path = 'DataObjectFieldRepresentation') {
271
+ const v_error = (() => {
272
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
273
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
274
+ }
275
+ const obj_isPrimaryKey = obj.isPrimaryKey;
276
+ const path_isPrimaryKey = path + '.isPrimaryKey';
277
+ if (typeof obj_isPrimaryKey !== 'boolean') {
278
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isPrimaryKey + '" (at "' + path_isPrimaryKey + '")');
279
+ }
280
+ const obj_keyQualifierField = obj.keyQualifierField;
281
+ const path_keyQualifierField = path + '.keyQualifierField';
282
+ if (typeof obj_keyQualifierField !== 'string') {
283
+ return new TypeError('Expected "string" but received "' + typeof obj_keyQualifierField + '" (at "' + path_keyQualifierField + '")');
284
+ }
285
+ const obj_label = obj.label;
286
+ const path_label = path + '.label';
287
+ if (typeof obj_label !== 'string') {
288
+ return new TypeError('Expected "string" but received "' + typeof obj_label + '" (at "' + path_label + '")');
289
+ }
290
+ const obj_name = obj.name;
291
+ const path_name = path + '.name';
292
+ if (typeof obj_name !== 'string') {
293
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
294
+ }
295
+ const obj_type = obj.type;
296
+ const path_type = path + '.type';
297
+ if (typeof obj_type !== 'string') {
298
+ return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
299
+ }
300
+ })();
301
+ return v_error === undefined ? null : v_error;
302
+ }
303
+
304
+ function validate$1(obj, path = 'DataObjectRepresentation') {
305
+ const validateCdpAssetBaseRepresentation_validateError = validate$3(obj, path);
306
+ if (validateCdpAssetBaseRepresentation_validateError !== null) {
307
+ return validateCdpAssetBaseRepresentation_validateError;
308
+ }
309
+ const v_error = (() => {
310
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
311
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
312
+ }
313
+ const obj_category = obj.category;
314
+ const path_category = path + '.category';
315
+ if (typeof obj_category !== 'string') {
316
+ return new TypeError('Expected "string" but received "' + typeof obj_category + '" (at "' + path_category + '")');
317
+ }
318
+ if (obj.eventDateTimeFieldName !== undefined) {
319
+ const obj_eventDateTimeFieldName = obj.eventDateTimeFieldName;
320
+ const path_eventDateTimeFieldName = path + '.eventDateTimeFieldName';
321
+ if (typeof obj_eventDateTimeFieldName !== 'string') {
322
+ return new TypeError('Expected "string" but received "' + typeof obj_eventDateTimeFieldName + '" (at "' + path_eventDateTimeFieldName + '")');
323
+ }
324
+ }
325
+ const obj_fields = obj.fields;
326
+ const path_fields = path + '.fields';
327
+ if (!ArrayIsArray(obj_fields)) {
328
+ return new TypeError('Expected "array" but received "' + typeof obj_fields + '" (at "' + path_fields + '")');
329
+ }
330
+ for (let i = 0; i < obj_fields.length; i++) {
331
+ const obj_fields_item = obj_fields[i];
332
+ const path_fields_item = path_fields + '[' + i + ']';
333
+ const referencepath_fields_itemValidationError = validate$2(obj_fields_item, path_fields_item);
334
+ if (referencepath_fields_itemValidationError !== null) {
335
+ let message = 'Object doesn\'t match DataObjectFieldRepresentation (at "' + path_fields_item + '")\n';
336
+ message += referencepath_fields_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
337
+ return new TypeError(message);
338
+ }
339
+ }
340
+ if (obj.recordModifiedFieldName !== undefined) {
341
+ const obj_recordModifiedFieldName = obj.recordModifiedFieldName;
342
+ const path_recordModifiedFieldName = path + '.recordModifiedFieldName';
343
+ if (typeof obj_recordModifiedFieldName !== 'string') {
344
+ return new TypeError('Expected "string" but received "' + typeof obj_recordModifiedFieldName + '" (at "' + path_recordModifiedFieldName + '")');
345
+ }
346
+ }
347
+ const obj_type = obj.type;
348
+ const path_type = path + '.type';
349
+ if (typeof obj_type !== 'string') {
350
+ return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
351
+ }
352
+ })();
353
+ return v_error === undefined ? null : v_error;
354
+ }
355
+
356
+ const VERSION = "21a4cd3206473ce28645099a11735bc6";
357
+ function validate(obj, path = 'DataTransformValidationRepresentation') {
358
+ const v_error = (() => {
359
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
360
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
361
+ }
362
+ if (obj.issues !== undefined) {
363
+ const obj_issues = obj.issues;
364
+ const path_issues = path + '.issues';
365
+ if (!ArrayIsArray(obj_issues)) {
366
+ return new TypeError('Expected "array" but received "' + typeof obj_issues + '" (at "' + path_issues + '")');
367
+ }
368
+ for (let i = 0; i < obj_issues.length; i++) {
369
+ const obj_issues_item = obj_issues[i];
370
+ const path_issues_item = path_issues + '[' + i + ']';
371
+ const referencepath_issues_itemValidationError = validate$5(obj_issues_item, path_issues_item);
372
+ if (referencepath_issues_itemValidationError !== null) {
373
+ let message = 'Object doesn\'t match TransformValidationIssueRepresentation (at "' + path_issues_item + '")\n';
374
+ message += referencepath_issues_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
375
+ return new TypeError(message);
376
+ }
377
+ }
378
+ }
379
+ if (obj.outputDataObjects !== undefined) {
380
+ const obj_outputDataObjects = obj.outputDataObjects;
381
+ const path_outputDataObjects = path + '.outputDataObjects';
382
+ if (!ArrayIsArray(obj_outputDataObjects)) {
383
+ return new TypeError('Expected "array" but received "' + typeof obj_outputDataObjects + '" (at "' + path_outputDataObjects + '")');
384
+ }
385
+ for (let i = 0; i < obj_outputDataObjects.length; i++) {
386
+ const obj_outputDataObjects_item = obj_outputDataObjects[i];
387
+ const path_outputDataObjects_item = path_outputDataObjects + '[' + i + ']';
388
+ const referencepath_outputDataObjects_itemValidationError = validate$1(obj_outputDataObjects_item, path_outputDataObjects_item);
389
+ if (referencepath_outputDataObjects_itemValidationError !== null) {
390
+ let message = 'Object doesn\'t match DataObjectRepresentation (at "' + path_outputDataObjects_item + '")\n';
391
+ message += referencepath_outputDataObjects_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
392
+ return new TypeError(message);
393
+ }
394
+ }
395
+ }
396
+ })();
397
+ return v_error === undefined ? null : v_error;
398
+ }
399
+ const RepresentationType = 'DataTransformValidationRepresentation';
400
+ function normalize(input, existing, path, luvio, store, timestamp) {
401
+ return input;
402
+ }
403
+ const select$1 = function DataTransformValidationRepresentationSelect() {
404
+ return {
405
+ kind: 'Fragment',
406
+ version: VERSION,
407
+ private: [],
408
+ opaque: true
409
+ };
410
+ };
411
+ function equals(existing, incoming) {
412
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
413
+ return false;
414
+ }
415
+ return true;
416
+ }
417
+ const ingest = function DataTransformValidationRepresentationIngest(input, path, luvio, store, timestamp) {
418
+ if (process.env.NODE_ENV !== 'production') {
419
+ const validateError = validate(input);
420
+ if (validateError !== null) {
421
+ throw validateError;
422
+ }
423
+ }
424
+ const key = path.fullPath;
425
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 3000000;
426
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "data-transform", VERSION, RepresentationType, equals);
427
+ return createLink(key);
428
+ };
429
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
430
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
431
+ const rootKey = fullPathFactory();
432
+ rootKeySet.set(rootKey, {
433
+ namespace: keyPrefix,
434
+ representationName: RepresentationType,
435
+ mergeable: false
436
+ });
437
+ }
438
+
439
+ function select(luvio, params) {
440
+ return select$1();
441
+ }
442
+ function keyBuilder$1(luvio, params) {
443
+ return keyPrefix + '::DataTransformValidationRepresentation:(' + stableJSONStringify(params.body.capabilities) + '::' + 'creationType:' + params.body.creationType + '::' + (params.body.currencyIsoCode === undefined ? 'currencyIsoCode' : 'currencyIsoCode:' + params.body.currencyIsoCode) + '::' + (params.body.dataSpaceName === undefined ? 'dataSpaceName' : 'dataSpaceName:' + params.body.dataSpaceName) + '::' + stableJSONStringify(params.body.definition) + '::' + (params.body.description === undefined ? 'description' : 'description:' + params.body.description) + '::' + (params.body.label === undefined ? 'label' : 'label:' + params.body.label) + '::' + (params.body.name === undefined ? 'name' : 'name:' + params.body.name) + '::' + (params.body.primarySource === undefined ? 'primarySource' : 'primarySource:' + params.body.primarySource) + '::' + stableJSONStringify(params.body.tags) + '::' + 'type:' + params.body.type + ')';
444
+ }
445
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
446
+ getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
447
+ }
448
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
449
+ const { body } = response;
450
+ const key = keyBuilder$1(luvio, resourceParams);
451
+ luvio.storeIngest(key, ingest, body);
452
+ const snapshot = luvio.storeLookup({
453
+ recordId: key,
454
+ node: select(),
455
+ variables: {},
456
+ }, snapshotRefresh);
457
+ if (process.env.NODE_ENV !== 'production') {
458
+ if (snapshot.state !== 'Fulfilled') {
459
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
460
+ }
461
+ }
462
+ deepFreeze(snapshot.data);
463
+ return snapshot;
464
+ }
465
+ function ingestError(luvio, params, error, snapshotRefresh) {
466
+ const key = keyBuilder$1(luvio, params);
467
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
468
+ luvio.storeIngestError(key, errorSnapshot);
469
+ return errorSnapshot;
470
+ }
471
+ function createResourceRequest(config) {
472
+ const headers = {};
473
+ return {
474
+ baseUri: '/services/data/v62.0',
475
+ basePath: '/ssot/data-transforms-validation',
476
+ method: 'post',
477
+ body: config.body,
478
+ urlParams: {},
479
+ queryParams: {},
480
+ headers,
481
+ priority: 'normal',
482
+ };
483
+ }
484
+
485
+ const adapterName = 'validateDataTransforms';
486
+ const validateDataTransforms_ConfigPropertyMetadata = [
487
+ generateParamConfigMetadata('capabilities', false, 2 /* Body */, 4 /* Unsupported */),
488
+ generateParamConfigMetadata('creationType', true, 2 /* Body */, 0 /* String */),
489
+ generateParamConfigMetadata('currencyIsoCode', false, 2 /* Body */, 0 /* String */),
490
+ generateParamConfigMetadata('dataSpaceName', false, 2 /* Body */, 0 /* String */),
491
+ generateParamConfigMetadata('definition', true, 2 /* Body */, 4 /* Unsupported */),
492
+ generateParamConfigMetadata('description', false, 2 /* Body */, 0 /* String */),
493
+ generateParamConfigMetadata('label', false, 2 /* Body */, 0 /* String */),
494
+ generateParamConfigMetadata('name', false, 2 /* Body */, 0 /* String */),
495
+ generateParamConfigMetadata('primarySource', false, 2 /* Body */, 0 /* String */),
496
+ generateParamConfigMetadata('tags', false, 2 /* Body */, 4 /* Unsupported */),
497
+ generateParamConfigMetadata('type', true, 2 /* Body */, 0 /* String */),
498
+ ];
499
+ const validateDataTransforms_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, validateDataTransforms_ConfigPropertyMetadata);
500
+ const createResourceParams = /*#__PURE__*/ createResourceParams$1(validateDataTransforms_ConfigPropertyMetadata);
501
+ function keyBuilder(luvio, config) {
502
+ const resourceParams = createResourceParams(config);
503
+ return keyBuilder$1(luvio, resourceParams);
504
+ }
505
+ function typeCheckConfig(untrustedConfig) {
506
+ const config = {};
507
+ typeCheckConfig$1(untrustedConfig, config, validateDataTransforms_ConfigPropertyMetadata);
508
+ const untrustedConfig_capabilities = untrustedConfig.capabilities;
509
+ if (untrustedIsObject(untrustedConfig_capabilities)) {
510
+ const untrustedConfig_capabilities_object = {};
511
+ const untrustedConfig_capabilities_keys = Object.keys(untrustedConfig_capabilities);
512
+ for (let i = 0, arrayLength = untrustedConfig_capabilities_keys.length; i < arrayLength; i++) {
513
+ const key = untrustedConfig_capabilities_keys[i];
514
+ const untrustedConfig_capabilities_prop = untrustedConfig_capabilities[key];
515
+ if (typeof untrustedConfig_capabilities_prop === 'boolean') {
516
+ if (untrustedConfig_capabilities_object !== undefined) {
517
+ untrustedConfig_capabilities_object[key] = untrustedConfig_capabilities_prop;
518
+ }
519
+ }
520
+ }
521
+ if (untrustedConfig_capabilities_object !== undefined && Object.keys(untrustedConfig_capabilities_object).length >= 0) {
522
+ config.capabilities = untrustedConfig_capabilities_object;
523
+ }
524
+ }
525
+ const untrustedConfig_definition = untrustedConfig.definition;
526
+ if (untrustedIsObject(untrustedConfig_definition)) {
527
+ const untrustedConfig_definition_object = {};
528
+ const untrustedConfig_definition_keys = Object.keys(untrustedConfig_definition);
529
+ for (let i = 0, arrayLength = untrustedConfig_definition_keys.length; i < arrayLength; i++) {
530
+ const key = untrustedConfig_definition_keys[i];
531
+ const untrustedConfig_definition_prop = untrustedConfig_definition[key];
532
+ if (untrustedConfig_definition_object !== undefined) {
533
+ untrustedConfig_definition_object[key] = untrustedConfig_definition_prop;
534
+ }
535
+ }
536
+ if (untrustedConfig_definition_object !== undefined && Object.keys(untrustedConfig_definition_object).length >= 0) {
537
+ config.definition = untrustedConfig_definition_object;
538
+ }
539
+ }
540
+ const untrustedConfig_tags = untrustedConfig.tags;
541
+ if (untrustedIsObject(untrustedConfig_tags)) {
542
+ const untrustedConfig_tags_object = {};
543
+ const untrustedConfig_tags_keys = Object.keys(untrustedConfig_tags);
544
+ for (let i = 0, arrayLength = untrustedConfig_tags_keys.length; i < arrayLength; i++) {
545
+ const key = untrustedConfig_tags_keys[i];
546
+ const untrustedConfig_tags_prop = untrustedConfig_tags[key];
547
+ if (typeof untrustedConfig_tags_prop === 'string') {
548
+ if (untrustedConfig_tags_object !== undefined) {
549
+ untrustedConfig_tags_object[key] = untrustedConfig_tags_prop;
550
+ }
551
+ }
552
+ }
553
+ if (untrustedConfig_tags_object !== undefined && Object.keys(untrustedConfig_tags_object).length >= 0) {
554
+ config.tags = untrustedConfig_tags_object;
555
+ }
556
+ }
557
+ return config;
558
+ }
559
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
560
+ if (!untrustedIsObject(untrustedConfig)) {
561
+ return null;
562
+ }
563
+ if (process.env.NODE_ENV !== 'production') {
564
+ validateConfig(untrustedConfig, configPropertyNames);
565
+ }
566
+ const config = typeCheckConfig(untrustedConfig);
567
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
568
+ return null;
569
+ }
570
+ return config;
571
+ }
572
+ function adapterFragment(luvio, config) {
573
+ createResourceParams(config);
574
+ return select();
575
+ }
576
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
577
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
578
+ config,
579
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
580
+ });
581
+ return luvio.storeBroadcast().then(() => snapshot);
582
+ }
583
+ function onFetchResponseError(luvio, config, resourceParams, response) {
584
+ const snapshot = ingestError(luvio, resourceParams, response, {
585
+ config,
586
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
587
+ });
588
+ return luvio.storeBroadcast().then(() => snapshot);
589
+ }
590
+ function buildNetworkSnapshot(luvio, config, options) {
591
+ const resourceParams = createResourceParams(config);
592
+ const request = createResourceRequest(resourceParams);
593
+ return luvio.dispatchResourceRequest(request, options)
594
+ .then((response) => {
595
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
596
+ const cache = new StoreKeyMap();
597
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
598
+ return cache;
599
+ });
600
+ }, (response) => {
601
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
602
+ });
603
+ }
604
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
605
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, 'get', false);
606
+ }
607
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
608
+ const { luvio, config } = context;
609
+ const selector = {
610
+ recordId: keyBuilder(luvio, config),
611
+ node: adapterFragment(luvio, config),
612
+ variables: {},
613
+ };
614
+ const cacheSnapshot = storeLookup(selector, {
615
+ config,
616
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
617
+ });
618
+ return cacheSnapshot;
619
+ }
620
+ const validateDataTransformsAdapterFactory = (luvio) => function dataTransform__validateDataTransforms(untrustedConfig, requestContext) {
621
+ const config = validateAdapterConfig(untrustedConfig, validateDataTransforms_ConfigPropertyNames);
622
+ // Invalid or incomplete config
623
+ if (config === null) {
624
+ return null;
625
+ }
626
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
627
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
628
+ };
629
+
630
+ export { validateDataTransformsAdapterFactory };