@salesforce/lds-adapters-industries-epc 0.131.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.
Files changed (29) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/industries-epc.js +926 -0
  3. package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +66 -0
  4. package/dist/es/es2018/types/src/generated/adapters/createProductAttributeDefinition.d.ts +15 -0
  5. package/dist/es/es2018/types/src/generated/adapters/deactivate.d.ts +15 -0
  6. package/dist/es/es2018/types/src/generated/adapters/getProductFlowByProductId.d.ts +27 -0
  7. package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +3 -0
  8. package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +5 -0
  9. package/dist/es/es2018/types/src/generated/resources/getConnectEpcProductsFlowByProductId.d.ts +18 -0
  10. package/dist/es/es2018/types/src/generated/resources/patchConnectEpcActionsDeactivate.d.ts +13 -0
  11. package/dist/es/es2018/types/src/generated/resources/postConnectEpcProductAttributeDefinition.d.ts +13 -0
  12. package/dist/es/es2018/types/src/generated/types/DeactivateInputRepresentation.d.ts +35 -0
  13. package/dist/es/es2018/types/src/generated/types/DeactivateInputRepresentationWrapper.d.ts +30 -0
  14. package/dist/es/es2018/types/src/generated/types/ErrorOutputRepresentation.d.ts +35 -0
  15. package/dist/es/es2018/types/src/generated/types/ProductAttributeDefinitionInputRepresentation.d.ts +35 -0
  16. package/dist/es/es2018/types/src/generated/types/ProductAttributeDefinitionListInputRepresentation.d.ts +29 -0
  17. package/dist/es/es2018/types/src/generated/types/ProductAttributeDefinitionListInputRepresentationWrapper.d.ts +30 -0
  18. package/dist/es/es2018/types/src/generated/types/ProductAttributeDefinitionListRepresentation.d.ts +43 -0
  19. package/dist/es/es2018/types/src/generated/types/ProductAttributeDefinitionRepresentation.d.ts +32 -0
  20. package/dist/es/es2018/types/src/generated/types/ProductFlowConnectRepresentation.d.ts +29 -0
  21. package/dist/es/es2018/types/src/generated/types/ProductFlowOutputRepresentation.d.ts +38 -0
  22. package/dist/es/es2018/types/src/generated/types/RecordIdMapOutputRepresentation.d.ts +43 -0
  23. package/dist/es/es2018/types/src/generated/types/Status.d.ts +32 -0
  24. package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +39 -0
  25. package/package.json +67 -0
  26. package/sfdc/index.d.ts +1 -0
  27. package/sfdc/index.js +967 -0
  28. package/src/raml/api.raml +222 -0
  29. package/src/raml/luvio.raml +36 -0
@@ -0,0 +1,926 @@
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, StoreKeyMap } from '@luvio/engine';
8
+
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
11
+ const { isArray: ArrayIsArray$1 } = Array;
12
+ /**
13
+ * Validates an adapter config is well-formed.
14
+ * @param config The config to validate.
15
+ * @param adapter The adapter validation configuration.
16
+ * @param oneOf The keys the config must contain at least one of.
17
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
18
+ */
19
+ function validateConfig(config, adapter, oneOf) {
20
+ const { displayName } = adapter;
21
+ const { required, optional, unsupported } = adapter.parameters;
22
+ if (config === undefined ||
23
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
24
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
25
+ }
26
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
27
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
28
+ }
29
+ if (unsupported !== undefined &&
30
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
31
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
32
+ }
33
+ const supported = required.concat(optional);
34
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
35
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
36
+ }
37
+ }
38
+ function untrustedIsObject(untrusted) {
39
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
40
+ }
41
+ function areRequiredParametersPresent(config, configPropertyNames) {
42
+ return configPropertyNames.parameters.required.every(req => req in config);
43
+ }
44
+ const snapshotRefreshOptions = {
45
+ overrides: {
46
+ headers: {
47
+ 'Cache-Control': 'no-cache',
48
+ },
49
+ }
50
+ };
51
+ const keyPrefix = 'epc';
52
+
53
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
54
+ const { isArray: ArrayIsArray } = Array;
55
+ const { stringify: JSONStringify } = JSON;
56
+ function deepFreeze$7(value) {
57
+ // No need to freeze primitives
58
+ if (typeof value !== 'object' || value === null) {
59
+ return;
60
+ }
61
+ if (ArrayIsArray(value)) {
62
+ for (let i = 0, len = value.length; i < len; i += 1) {
63
+ deepFreeze$7(value[i]);
64
+ }
65
+ }
66
+ else {
67
+ const keys = ObjectKeys(value);
68
+ for (let i = 0, len = keys.length; i < len; i += 1) {
69
+ deepFreeze$7(value[keys[i]]);
70
+ }
71
+ }
72
+ ObjectFreeze(value);
73
+ }
74
+ function createLink(ref) {
75
+ return {
76
+ __ref: serializeStructuredKey(ref),
77
+ };
78
+ }
79
+
80
+ function validate$8(obj, path = 'DeactivateInputRepresentation') {
81
+ const v_error = (() => {
82
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
83
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
84
+ }
85
+ const obj_entityName = obj.entityName;
86
+ const path_entityName = path + '.entityName';
87
+ if (typeof obj_entityName !== 'string') {
88
+ return new TypeError('Expected "string" but received "' + typeof obj_entityName + '" (at "' + path_entityName + '")');
89
+ }
90
+ if (obj.parentRecordId !== undefined) {
91
+ const obj_parentRecordId = obj.parentRecordId;
92
+ const path_parentRecordId = path + '.parentRecordId';
93
+ if (typeof obj_parentRecordId !== 'string') {
94
+ return new TypeError('Expected "string" but received "' + typeof obj_parentRecordId + '" (at "' + path_parentRecordId + '")');
95
+ }
96
+ }
97
+ const obj_recordIds = obj.recordIds;
98
+ const path_recordIds = path + '.recordIds';
99
+ if (!ArrayIsArray(obj_recordIds)) {
100
+ return new TypeError('Expected "array" but received "' + typeof obj_recordIds + '" (at "' + path_recordIds + '")');
101
+ }
102
+ for (let i = 0; i < obj_recordIds.length; i++) {
103
+ const obj_recordIds_item = obj_recordIds[i];
104
+ const path_recordIds_item = path_recordIds + '[' + i + ']';
105
+ if (typeof obj_recordIds_item !== 'string') {
106
+ return new TypeError('Expected "string" but received "' + typeof obj_recordIds_item + '" (at "' + path_recordIds_item + '")');
107
+ }
108
+ }
109
+ })();
110
+ return v_error === undefined ? null : v_error;
111
+ }
112
+
113
+ function validate$7(obj, path = 'ErrorOutputRepresentation') {
114
+ const v_error = (() => {
115
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
116
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
117
+ }
118
+ const obj_details = obj.details;
119
+ const path_details = path + '.details';
120
+ if (!ArrayIsArray(obj_details)) {
121
+ return new TypeError('Expected "array" but received "' + typeof obj_details + '" (at "' + path_details + '")');
122
+ }
123
+ for (let i = 0; i < obj_details.length; i++) {
124
+ const obj_details_item = obj_details[i];
125
+ const path_details_item = path_details + '[' + i + ']';
126
+ if (typeof obj_details_item !== 'string') {
127
+ return new TypeError('Expected "string" but received "' + typeof obj_details_item + '" (at "' + path_details_item + '")');
128
+ }
129
+ }
130
+ const obj_message = obj.message;
131
+ const path_message = path + '.message';
132
+ if (typeof obj_message !== 'string') {
133
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
134
+ }
135
+ const obj_reason = obj.reason;
136
+ const path_reason = path + '.reason';
137
+ if (typeof obj_reason !== 'string') {
138
+ return new TypeError('Expected "string" but received "' + typeof obj_reason + '" (at "' + path_reason + '")');
139
+ }
140
+ })();
141
+ return v_error === undefined ? null : v_error;
142
+ }
143
+ function deepFreeze$6(input) {
144
+ const input_details = input.details;
145
+ ObjectFreeze(input_details);
146
+ ObjectFreeze(input);
147
+ }
148
+
149
+ const TTL$2 = 6000;
150
+ const VERSION$2 = "67abdeaa299bae24f468fd2e78cd1e1e";
151
+ function validate$6(obj, path = 'RecordIdMapOutputRepresentation') {
152
+ const v_error = (() => {
153
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
154
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
155
+ }
156
+ const obj_errors = obj.errors;
157
+ const path_errors = path + '.errors';
158
+ if (!ArrayIsArray(obj_errors)) {
159
+ return new TypeError('Expected "array" but received "' + typeof obj_errors + '" (at "' + path_errors + '")');
160
+ }
161
+ for (let i = 0; i < obj_errors.length; i++) {
162
+ const obj_errors_item = obj_errors[i];
163
+ const path_errors_item = path_errors + '[' + i + ']';
164
+ const referencepath_errors_itemValidationError = validate$7(obj_errors_item, path_errors_item);
165
+ if (referencepath_errors_itemValidationError !== null) {
166
+ let message = 'Object doesn\'t match ErrorOutputRepresentation (at "' + path_errors_item + '")\n';
167
+ message += referencepath_errors_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
168
+ return new TypeError(message);
169
+ }
170
+ }
171
+ const obj_status = obj.status;
172
+ const path_status = path + '.status';
173
+ if (typeof obj_status !== 'string') {
174
+ return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
175
+ }
176
+ })();
177
+ return v_error === undefined ? null : v_error;
178
+ }
179
+ const RepresentationType$2 = 'RecordIdMapOutputRepresentation';
180
+ function keyBuilder$3(luvio, config) {
181
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.message;
182
+ }
183
+ function keyBuilderFromType$1(luvio, object) {
184
+ const keyParams = {
185
+ message: object.status
186
+ };
187
+ return keyBuilder$3(luvio, keyParams);
188
+ }
189
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
190
+ return input;
191
+ }
192
+ const select$5 = function RecordIdMapOutputRepresentationSelect() {
193
+ return {
194
+ kind: 'Fragment',
195
+ version: VERSION$2,
196
+ private: [],
197
+ opaque: true
198
+ };
199
+ };
200
+ function equals$2(existing, incoming) {
201
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
202
+ return false;
203
+ }
204
+ return true;
205
+ }
206
+ function deepFreeze$5(input) {
207
+ const input_errors = input.errors;
208
+ for (let i = 0; i < input_errors.length; i++) {
209
+ const input_errors_item = input_errors[i];
210
+ deepFreeze$6(input_errors_item);
211
+ }
212
+ ObjectFreeze(input_errors);
213
+ ObjectFreeze(input);
214
+ }
215
+ const ingest$2 = function RecordIdMapOutputRepresentationIngest(input, path, luvio, store, timestamp) {
216
+ if (process.env.NODE_ENV !== 'production') {
217
+ const validateError = validate$6(input);
218
+ if (validateError !== null) {
219
+ throw validateError;
220
+ }
221
+ }
222
+ const key = keyBuilderFromType$1(luvio, input);
223
+ const existingRecord = store.readEntry(key);
224
+ const ttlToUse = TTL$2;
225
+ let incomingRecord = normalize$2(input, store.readEntry(key), {
226
+ fullPath: key,
227
+ parent: path.parent,
228
+ propertyName: path.propertyName,
229
+ ttl: ttlToUse
230
+ });
231
+ deepFreeze$5(input);
232
+ if (existingRecord === undefined || equals$2(existingRecord, incomingRecord) === false) {
233
+ luvio.storePublish(key, incomingRecord);
234
+ }
235
+ {
236
+ const storeMetadataParams = {
237
+ ttl: ttlToUse,
238
+ namespace: "epc",
239
+ version: VERSION$2,
240
+ representationName: RepresentationType$2,
241
+ };
242
+ luvio.publishStoreMetadata(key, storeMetadataParams);
243
+ }
244
+ return createLink(key);
245
+ };
246
+ function getTypeCacheKeys$2(luvio, input, fullPathFactory) {
247
+ const rootKeySet = new StoreKeyMap();
248
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
249
+ const rootKey = keyBuilderFromType$1(luvio, input);
250
+ rootKeySet.set(rootKey, {
251
+ namespace: keyPrefix,
252
+ representationName: RepresentationType$2,
253
+ mergeable: false
254
+ });
255
+ return rootKeySet;
256
+ }
257
+
258
+ function select$4(luvio, params) {
259
+ return select$5();
260
+ }
261
+ function getResponseCacheKeys$2(luvio, resourceParams, response) {
262
+ return getTypeCacheKeys$2(luvio, response);
263
+ }
264
+ function ingestSuccess$2(luvio, resourceParams, response) {
265
+ const { body } = response;
266
+ const key = keyBuilderFromType$1(luvio, body);
267
+ luvio.storeIngest(key, ingest$2, body);
268
+ const snapshot = luvio.storeLookup({
269
+ recordId: key,
270
+ node: select$4(),
271
+ variables: {},
272
+ });
273
+ if (process.env.NODE_ENV !== 'production') {
274
+ if (snapshot.state !== 'Fulfilled') {
275
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
276
+ }
277
+ }
278
+ return snapshot;
279
+ }
280
+ function createResourceRequest$2(config) {
281
+ const headers = {};
282
+ return {
283
+ baseUri: '/services/data/v58.0',
284
+ basePath: '/connect/epc/actions/deactivate',
285
+ method: 'patch',
286
+ body: config.body,
287
+ urlParams: {},
288
+ queryParams: {},
289
+ headers,
290
+ priority: 'normal',
291
+ };
292
+ }
293
+
294
+ const deactivate_ConfigPropertyNames = {
295
+ displayName: 'deactivate',
296
+ parameters: {
297
+ required: ['deactivateInputPayload'],
298
+ optional: []
299
+ }
300
+ };
301
+ function createResourceParams$2(config) {
302
+ const resourceParams = {
303
+ body: {
304
+ deactivateInputPayload: config.deactivateInputPayload
305
+ }
306
+ };
307
+ return resourceParams;
308
+ }
309
+ function typeCheckConfig$2(untrustedConfig) {
310
+ const config = {};
311
+ const untrustedConfig_deactivateInputPayload = untrustedConfig.deactivateInputPayload;
312
+ const referenceDeactivateInputRepresentationValidationError = validate$8(untrustedConfig_deactivateInputPayload);
313
+ if (referenceDeactivateInputRepresentationValidationError === null) {
314
+ config.deactivateInputPayload = untrustedConfig_deactivateInputPayload;
315
+ }
316
+ return config;
317
+ }
318
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
319
+ if (!untrustedIsObject(untrustedConfig)) {
320
+ return null;
321
+ }
322
+ if (process.env.NODE_ENV !== 'production') {
323
+ validateConfig(untrustedConfig, configPropertyNames);
324
+ }
325
+ const config = typeCheckConfig$2(untrustedConfig);
326
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
327
+ return null;
328
+ }
329
+ return config;
330
+ }
331
+ function buildNetworkSnapshot$2(luvio, config, options) {
332
+ const resourceParams = createResourceParams$2(config);
333
+ const request = createResourceRequest$2(resourceParams);
334
+ return luvio.dispatchResourceRequest(request, options)
335
+ .then((response) => {
336
+ return luvio.handleSuccessResponse(() => {
337
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
338
+ return luvio.storeBroadcast().then(() => snapshot);
339
+ }, () => getResponseCacheKeys$2(luvio, resourceParams, response.body));
340
+ }, (response) => {
341
+ deepFreeze$7(response);
342
+ throw response;
343
+ });
344
+ }
345
+ const deactivateAdapterFactory = (luvio) => {
346
+ return function deactivate(untrustedConfig) {
347
+ const config = validateAdapterConfig$2(untrustedConfig, deactivate_ConfigPropertyNames);
348
+ // Invalid or incomplete config
349
+ if (config === null) {
350
+ throw new Error('Invalid config for "deactivate"');
351
+ }
352
+ return buildNetworkSnapshot$2(luvio, config);
353
+ };
354
+ };
355
+
356
+ function validate$5(obj, path = 'ProductAttributeDefinitionListInputRepresentation') {
357
+ const v_error = (() => {
358
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
359
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
360
+ }
361
+ const obj_productAttributeDefinitions = obj.productAttributeDefinitions;
362
+ const path_productAttributeDefinitions = path + '.productAttributeDefinitions';
363
+ if (!ArrayIsArray(obj_productAttributeDefinitions)) {
364
+ return new TypeError('Expected "array" but received "' + typeof obj_productAttributeDefinitions + '" (at "' + path_productAttributeDefinitions + '")');
365
+ }
366
+ for (let i = 0; i < obj_productAttributeDefinitions.length; i++) {
367
+ const obj_productAttributeDefinitions_item = obj_productAttributeDefinitions[i];
368
+ const path_productAttributeDefinitions_item = path_productAttributeDefinitions + '[' + i + ']';
369
+ if (typeof obj_productAttributeDefinitions_item !== 'object' || ArrayIsArray(obj_productAttributeDefinitions_item) || obj_productAttributeDefinitions_item === null) {
370
+ return new TypeError('Expected "object" but received "' + typeof obj_productAttributeDefinitions_item + '" (at "' + path_productAttributeDefinitions_item + '")');
371
+ }
372
+ }
373
+ })();
374
+ return v_error === undefined ? null : v_error;
375
+ }
376
+
377
+ function validate$4(obj, path = 'ProductAttributeDefinitionRepresentation') {
378
+ const v_error = (() => {
379
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
380
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
381
+ }
382
+ if (obj.attributeDefinitionName !== undefined) {
383
+ const obj_attributeDefinitionName = obj.attributeDefinitionName;
384
+ const path_attributeDefinitionName = path + '.attributeDefinitionName';
385
+ if (typeof obj_attributeDefinitionName !== 'string') {
386
+ return new TypeError('Expected "string" but received "' + typeof obj_attributeDefinitionName + '" (at "' + path_attributeDefinitionName + '")');
387
+ }
388
+ }
389
+ if (obj.recordId !== undefined) {
390
+ const obj_recordId = obj.recordId;
391
+ const path_recordId = path + '.recordId';
392
+ if (typeof obj_recordId !== 'string') {
393
+ return new TypeError('Expected "string" but received "' + typeof obj_recordId + '" (at "' + path_recordId + '")');
394
+ }
395
+ }
396
+ })();
397
+ return v_error === undefined ? null : v_error;
398
+ }
399
+ function deepFreeze$4(input) {
400
+ ObjectFreeze(input);
401
+ }
402
+
403
+ const TTL$1 = 6000;
404
+ const VERSION$1 = "e67d3c8569b9667eac98cc1a9840041c";
405
+ function validate$3(obj, path = 'ProductAttributeDefinitionListRepresentation') {
406
+ const v_error = (() => {
407
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
408
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
409
+ }
410
+ const obj_data = obj.data;
411
+ const path_data = path + '.data';
412
+ if (!ArrayIsArray(obj_data)) {
413
+ return new TypeError('Expected "array" but received "' + typeof obj_data + '" (at "' + path_data + '")');
414
+ }
415
+ for (let i = 0; i < obj_data.length; i++) {
416
+ const obj_data_item = obj_data[i];
417
+ const path_data_item = path_data + '[' + i + ']';
418
+ const referencepath_data_itemValidationError = validate$4(obj_data_item, path_data_item);
419
+ if (referencepath_data_itemValidationError !== null) {
420
+ let message = 'Object doesn\'t match ProductAttributeDefinitionRepresentation (at "' + path_data_item + '")\n';
421
+ message += referencepath_data_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
422
+ return new TypeError(message);
423
+ }
424
+ }
425
+ const obj_message = obj.message;
426
+ const path_message = path + '.message';
427
+ if (typeof obj_message !== 'string') {
428
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
429
+ }
430
+ })();
431
+ return v_error === undefined ? null : v_error;
432
+ }
433
+ const RepresentationType$1 = 'ProductAttributeDefinitionListRepresentation';
434
+ function keyBuilder$2(luvio, config) {
435
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.message;
436
+ }
437
+ function keyBuilderFromType(luvio, object) {
438
+ const keyParams = {
439
+ message: object.message
440
+ };
441
+ return keyBuilder$2(luvio, keyParams);
442
+ }
443
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
444
+ return input;
445
+ }
446
+ const select$3 = function ProductAttributeDefinitionListRepresentationSelect() {
447
+ return {
448
+ kind: 'Fragment',
449
+ version: VERSION$1,
450
+ private: [],
451
+ opaque: true
452
+ };
453
+ };
454
+ function equals$1(existing, incoming) {
455
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
456
+ return false;
457
+ }
458
+ return true;
459
+ }
460
+ function deepFreeze$3(input) {
461
+ const input_data = input.data;
462
+ for (let i = 0; i < input_data.length; i++) {
463
+ const input_data_item = input_data[i];
464
+ deepFreeze$4(input_data_item);
465
+ }
466
+ ObjectFreeze(input_data);
467
+ ObjectFreeze(input);
468
+ }
469
+ const ingest$1 = function ProductAttributeDefinitionListRepresentationIngest(input, path, luvio, store, timestamp) {
470
+ if (process.env.NODE_ENV !== 'production') {
471
+ const validateError = validate$3(input);
472
+ if (validateError !== null) {
473
+ throw validateError;
474
+ }
475
+ }
476
+ const key = keyBuilderFromType(luvio, input);
477
+ const existingRecord = store.readEntry(key);
478
+ const ttlToUse = TTL$1;
479
+ let incomingRecord = normalize$1(input, store.readEntry(key), {
480
+ fullPath: key,
481
+ parent: path.parent,
482
+ propertyName: path.propertyName,
483
+ ttl: ttlToUse
484
+ });
485
+ deepFreeze$3(input);
486
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
487
+ luvio.storePublish(key, incomingRecord);
488
+ }
489
+ {
490
+ const storeMetadataParams = {
491
+ ttl: ttlToUse,
492
+ namespace: "epc",
493
+ version: VERSION$1,
494
+ representationName: RepresentationType$1,
495
+ };
496
+ luvio.publishStoreMetadata(key, storeMetadataParams);
497
+ }
498
+ return createLink(key);
499
+ };
500
+ function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
501
+ const rootKeySet = new StoreKeyMap();
502
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
503
+ const rootKey = keyBuilderFromType(luvio, input);
504
+ rootKeySet.set(rootKey, {
505
+ namespace: keyPrefix,
506
+ representationName: RepresentationType$1,
507
+ mergeable: false
508
+ });
509
+ return rootKeySet;
510
+ }
511
+
512
+ function select$2(luvio, params) {
513
+ return select$3();
514
+ }
515
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
516
+ return getTypeCacheKeys$1(luvio, response);
517
+ }
518
+ function ingestSuccess$1(luvio, resourceParams, response) {
519
+ const { body } = response;
520
+ const key = keyBuilderFromType(luvio, body);
521
+ luvio.storeIngest(key, ingest$1, body);
522
+ const snapshot = luvio.storeLookup({
523
+ recordId: key,
524
+ node: select$2(),
525
+ variables: {},
526
+ });
527
+ if (process.env.NODE_ENV !== 'production') {
528
+ if (snapshot.state !== 'Fulfilled') {
529
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
530
+ }
531
+ }
532
+ return snapshot;
533
+ }
534
+ function createResourceRequest$1(config) {
535
+ const headers = {};
536
+ return {
537
+ baseUri: '/services/data/v58.0',
538
+ basePath: '/connect/epc/product-attribute-definition',
539
+ method: 'post',
540
+ body: config.body,
541
+ urlParams: {},
542
+ queryParams: {},
543
+ headers,
544
+ priority: 'normal',
545
+ };
546
+ }
547
+
548
+ const createProductAttributeDefinition_ConfigPropertyNames = {
549
+ displayName: 'createProductAttributeDefinition',
550
+ parameters: {
551
+ required: ['productAttributeDefinitionListInputPayload'],
552
+ optional: []
553
+ }
554
+ };
555
+ function createResourceParams$1(config) {
556
+ const resourceParams = {
557
+ body: {
558
+ productAttributeDefinitionListInputPayload: config.productAttributeDefinitionListInputPayload
559
+ }
560
+ };
561
+ return resourceParams;
562
+ }
563
+ function typeCheckConfig$1(untrustedConfig) {
564
+ const config = {};
565
+ const untrustedConfig_productAttributeDefinitionListInputPayload = untrustedConfig.productAttributeDefinitionListInputPayload;
566
+ const referenceProductAttributeDefinitionListInputRepresentationValidationError = validate$5(untrustedConfig_productAttributeDefinitionListInputPayload);
567
+ if (referenceProductAttributeDefinitionListInputRepresentationValidationError === null) {
568
+ config.productAttributeDefinitionListInputPayload = untrustedConfig_productAttributeDefinitionListInputPayload;
569
+ }
570
+ return config;
571
+ }
572
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
573
+ if (!untrustedIsObject(untrustedConfig)) {
574
+ return null;
575
+ }
576
+ if (process.env.NODE_ENV !== 'production') {
577
+ validateConfig(untrustedConfig, configPropertyNames);
578
+ }
579
+ const config = typeCheckConfig$1(untrustedConfig);
580
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
581
+ return null;
582
+ }
583
+ return config;
584
+ }
585
+ function buildNetworkSnapshot$1(luvio, config, options) {
586
+ const resourceParams = createResourceParams$1(config);
587
+ const request = createResourceRequest$1(resourceParams);
588
+ return luvio.dispatchResourceRequest(request, options)
589
+ .then((response) => {
590
+ return luvio.handleSuccessResponse(() => {
591
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
592
+ return luvio.storeBroadcast().then(() => snapshot);
593
+ }, () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
594
+ }, (response) => {
595
+ deepFreeze$7(response);
596
+ throw response;
597
+ });
598
+ }
599
+ const createProductAttributeDefinitionAdapterFactory = (luvio) => {
600
+ return function createProductAttributeDefinition(untrustedConfig) {
601
+ const config = validateAdapterConfig$1(untrustedConfig, createProductAttributeDefinition_ConfigPropertyNames);
602
+ // Invalid or incomplete config
603
+ if (config === null) {
604
+ throw new Error('Invalid config for "createProductAttributeDefinition"');
605
+ }
606
+ return buildNetworkSnapshot$1(luvio, config);
607
+ };
608
+ };
609
+
610
+ function validate$2(obj, path = 'ProductFlowConnectRepresentation') {
611
+ const v_error = (() => {
612
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
613
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
614
+ }
615
+ if (obj.flowApiName !== undefined) {
616
+ const obj_flowApiName = obj.flowApiName;
617
+ const path_flowApiName = path + '.flowApiName';
618
+ if (typeof obj_flowApiName !== 'string') {
619
+ return new TypeError('Expected "string" but received "' + typeof obj_flowApiName + '" (at "' + path_flowApiName + '")');
620
+ }
621
+ }
622
+ })();
623
+ return v_error === undefined ? null : v_error;
624
+ }
625
+ function deepFreeze$2(input) {
626
+ ObjectFreeze(input);
627
+ }
628
+
629
+ function validate$1(obj, path = 'Status') {
630
+ const v_error = (() => {
631
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
632
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
633
+ }
634
+ const obj_code = obj.code;
635
+ const path_code = path + '.code';
636
+ if (typeof obj_code !== 'string') {
637
+ return new TypeError('Expected "string" but received "' + typeof obj_code + '" (at "' + path_code + '")');
638
+ }
639
+ const obj_message = obj.message;
640
+ const path_message = path + '.message';
641
+ if (typeof obj_message !== 'string') {
642
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
643
+ }
644
+ })();
645
+ return v_error === undefined ? null : v_error;
646
+ }
647
+ function deepFreeze$1(input) {
648
+ ObjectFreeze(input);
649
+ }
650
+
651
+ const TTL = 6000;
652
+ const VERSION = "a75aed3c640fb969c24561ef4f8cb169";
653
+ function validate(obj, path = 'ProductFlowOutputRepresentation') {
654
+ const v_error = (() => {
655
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
656
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
657
+ }
658
+ if (obj.correlationId !== undefined) {
659
+ const obj_correlationId = obj.correlationId;
660
+ const path_correlationId = path + '.correlationId';
661
+ if (typeof obj_correlationId !== 'string') {
662
+ return new TypeError('Expected "string" but received "' + typeof obj_correlationId + '" (at "' + path_correlationId + '")');
663
+ }
664
+ }
665
+ if (obj.productFlow !== undefined) {
666
+ const obj_productFlow = obj.productFlow;
667
+ const path_productFlow = path + '.productFlow';
668
+ const referencepath_productFlowValidationError = validate$2(obj_productFlow, path_productFlow);
669
+ if (referencepath_productFlowValidationError !== null) {
670
+ let message = 'Object doesn\'t match ProductFlowConnectRepresentation (at "' + path_productFlow + '")\n';
671
+ message += referencepath_productFlowValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
672
+ return new TypeError(message);
673
+ }
674
+ }
675
+ if (obj.status !== undefined) {
676
+ const obj_status = obj.status;
677
+ const path_status = path + '.status';
678
+ const referencepath_statusValidationError = validate$1(obj_status, path_status);
679
+ if (referencepath_statusValidationError !== null) {
680
+ let message = 'Object doesn\'t match Status (at "' + path_status + '")\n';
681
+ message += referencepath_statusValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
682
+ return new TypeError(message);
683
+ }
684
+ }
685
+ })();
686
+ return v_error === undefined ? null : v_error;
687
+ }
688
+ const RepresentationType = 'ProductFlowOutputRepresentation';
689
+ function normalize(input, existing, path, luvio, store, timestamp) {
690
+ return input;
691
+ }
692
+ const select$1 = function ProductFlowOutputRepresentationSelect() {
693
+ return {
694
+ kind: 'Fragment',
695
+ version: VERSION,
696
+ private: [],
697
+ opaque: true
698
+ };
699
+ };
700
+ function equals(existing, incoming) {
701
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
702
+ return false;
703
+ }
704
+ return true;
705
+ }
706
+ function deepFreeze(input) {
707
+ const input_productFlow = input.productFlow;
708
+ if (input_productFlow !== undefined) {
709
+ deepFreeze$2(input_productFlow);
710
+ }
711
+ const input_status = input.status;
712
+ if (input_status !== undefined) {
713
+ deepFreeze$1(input_status);
714
+ }
715
+ ObjectFreeze(input);
716
+ }
717
+ const ingest = function ProductFlowOutputRepresentationIngest(input, path, luvio, store, timestamp) {
718
+ if (process.env.NODE_ENV !== 'production') {
719
+ const validateError = validate(input);
720
+ if (validateError !== null) {
721
+ throw validateError;
722
+ }
723
+ }
724
+ const key = path.fullPath;
725
+ const existingRecord = store.readEntry(key);
726
+ const ttlToUse = TTL;
727
+ let incomingRecord = normalize(input, store.readEntry(key), {
728
+ fullPath: key,
729
+ parent: path.parent,
730
+ propertyName: path.propertyName,
731
+ ttl: ttlToUse
732
+ });
733
+ deepFreeze(input);
734
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
735
+ luvio.storePublish(key, incomingRecord);
736
+ }
737
+ {
738
+ const storeMetadataParams = {
739
+ ttl: ttlToUse,
740
+ namespace: "epc",
741
+ version: VERSION,
742
+ representationName: RepresentationType,
743
+ };
744
+ luvio.publishStoreMetadata(key, storeMetadataParams);
745
+ }
746
+ return createLink(key);
747
+ };
748
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
749
+ const rootKeySet = new StoreKeyMap();
750
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
751
+ const rootKey = fullPathFactory();
752
+ rootKeySet.set(rootKey, {
753
+ namespace: keyPrefix,
754
+ representationName: RepresentationType,
755
+ mergeable: false
756
+ });
757
+ return rootKeySet;
758
+ }
759
+
760
+ function select(luvio, params) {
761
+ return select$1();
762
+ }
763
+ function keyBuilder$1(luvio, params) {
764
+ return keyPrefix + '::ProductFlowOutputRepresentation:(' + 'correlationId:' + params.queryParams.correlationId + ',' + 'productId:' + params.urlParams.productId + ')';
765
+ }
766
+ function getResponseCacheKeys(luvio, resourceParams, response) {
767
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
768
+ }
769
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
770
+ const { body } = response;
771
+ const key = keyBuilder$1(luvio, resourceParams);
772
+ luvio.storeIngest(key, ingest, body);
773
+ const snapshot = luvio.storeLookup({
774
+ recordId: key,
775
+ node: select(),
776
+ variables: {},
777
+ }, snapshotRefresh);
778
+ if (process.env.NODE_ENV !== 'production') {
779
+ if (snapshot.state !== 'Fulfilled') {
780
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
781
+ }
782
+ }
783
+ return snapshot;
784
+ }
785
+ function ingestError(luvio, params, error, snapshotRefresh) {
786
+ const key = keyBuilder$1(luvio, params);
787
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
788
+ const storeMetadataParams = {
789
+ ttl: TTL,
790
+ namespace: keyPrefix,
791
+ version: VERSION,
792
+ representationName: RepresentationType
793
+ };
794
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
795
+ return errorSnapshot;
796
+ }
797
+ function createResourceRequest(config) {
798
+ const headers = {};
799
+ return {
800
+ baseUri: '/services/data/v58.0',
801
+ basePath: '/connect/epc/products/' + config.urlParams.productId + '/flow',
802
+ method: 'get',
803
+ body: null,
804
+ urlParams: config.urlParams,
805
+ queryParams: config.queryParams,
806
+ headers,
807
+ priority: 'normal',
808
+ };
809
+ }
810
+
811
+ const getProductFlowByProductId_ConfigPropertyNames = {
812
+ displayName: 'getProductFlowByProductId',
813
+ parameters: {
814
+ required: ['productId'],
815
+ optional: ['correlationId']
816
+ }
817
+ };
818
+ function createResourceParams(config) {
819
+ const resourceParams = {
820
+ urlParams: {
821
+ productId: config.productId
822
+ },
823
+ queryParams: {
824
+ correlationId: config.correlationId
825
+ }
826
+ };
827
+ return resourceParams;
828
+ }
829
+ function keyBuilder(luvio, config) {
830
+ const resourceParams = createResourceParams(config);
831
+ return keyBuilder$1(luvio, resourceParams);
832
+ }
833
+ function typeCheckConfig(untrustedConfig) {
834
+ const config = {};
835
+ const untrustedConfig_productId = untrustedConfig.productId;
836
+ if (typeof untrustedConfig_productId === 'string') {
837
+ config.productId = untrustedConfig_productId;
838
+ }
839
+ const untrustedConfig_correlationId = untrustedConfig.correlationId;
840
+ if (typeof untrustedConfig_correlationId === 'string') {
841
+ config.correlationId = untrustedConfig_correlationId;
842
+ }
843
+ return config;
844
+ }
845
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
846
+ if (!untrustedIsObject(untrustedConfig)) {
847
+ return null;
848
+ }
849
+ if (process.env.NODE_ENV !== 'production') {
850
+ validateConfig(untrustedConfig, configPropertyNames);
851
+ }
852
+ const config = typeCheckConfig(untrustedConfig);
853
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
854
+ return null;
855
+ }
856
+ return config;
857
+ }
858
+ function adapterFragment(luvio, config) {
859
+ createResourceParams(config);
860
+ return select();
861
+ }
862
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
863
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
864
+ config,
865
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
866
+ });
867
+ return luvio.storeBroadcast().then(() => snapshot);
868
+ }
869
+ function onFetchResponseError(luvio, config, resourceParams, response) {
870
+ const snapshot = ingestError(luvio, resourceParams, response, {
871
+ config,
872
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
873
+ });
874
+ return luvio.storeBroadcast().then(() => snapshot);
875
+ }
876
+ function buildNetworkSnapshot(luvio, config, options) {
877
+ const resourceParams = createResourceParams(config);
878
+ const request = createResourceRequest(resourceParams);
879
+ return luvio.dispatchResourceRequest(request, options)
880
+ .then((response) => {
881
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
882
+ }, (response) => {
883
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
884
+ });
885
+ }
886
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
887
+ const { luvio, config } = context;
888
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
889
+ const dispatchOptions = {
890
+ resourceRequestContext: {
891
+ requestCorrelator,
892
+ luvioRequestMethod: undefined,
893
+ },
894
+ eventObservers
895
+ };
896
+ if (networkPriority !== 'normal') {
897
+ dispatchOptions.overrides = {
898
+ priority: networkPriority
899
+ };
900
+ }
901
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
902
+ }
903
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
904
+ const { luvio, config } = context;
905
+ const selector = {
906
+ recordId: keyBuilder(luvio, config),
907
+ node: adapterFragment(luvio, config),
908
+ variables: {},
909
+ };
910
+ const cacheSnapshot = storeLookup(selector, {
911
+ config,
912
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
913
+ });
914
+ return cacheSnapshot;
915
+ }
916
+ const getProductFlowByProductIdAdapterFactory = (luvio) => function epc__getProductFlowByProductId(untrustedConfig, requestContext) {
917
+ const config = validateAdapterConfig(untrustedConfig, getProductFlowByProductId_ConfigPropertyNames);
918
+ // Invalid or incomplete config
919
+ if (config === null) {
920
+ return null;
921
+ }
922
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
923
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
924
+ };
925
+
926
+ export { createProductAttributeDefinitionAdapterFactory, deactivateAdapterFactory, getProductFlowByProductIdAdapterFactory };