@salesforce/lds-adapters-commerce-extensions 1.124.2 → 1.124.4

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 (35) hide show
  1. package/dist/es/es2018/commerce-extensions.js +1994 -1994
  2. package/dist/{types → es/es2018/types}/src/generated/adapters/adapter-utils.d.ts +66 -66
  3. package/dist/{types → es/es2018/types}/src/generated/adapters/createMapping.d.ts +17 -17
  4. package/dist/{types → es/es2018/types}/src/generated/adapters/deleteMapping.d.ts +13 -13
  5. package/dist/{types → es/es2018/types}/src/generated/adapters/getExtensions.d.ts +25 -25
  6. package/dist/{types → es/es2018/types}/src/generated/adapters/getMapping.d.ts +27 -27
  7. package/dist/{types → es/es2018/types}/src/generated/adapters/getMappings.d.ts +27 -27
  8. package/dist/{types → es/es2018/types}/src/generated/adapters/getProviders.d.ts +27 -27
  9. package/dist/{types → es/es2018/types}/src/generated/adapters/updateMapping.d.ts +18 -18
  10. package/dist/{types → es/es2018/types}/src/generated/artifacts/main.d.ts +7 -7
  11. package/dist/{types → es/es2018/types}/src/generated/artifacts/sfdc.d.ts +13 -13
  12. package/dist/{types → es/es2018/types}/src/generated/resources/deleteCommerceExtensionMappingsByMappingId.d.ts +12 -12
  13. package/dist/{types → es/es2018/types}/src/generated/resources/getCommerceExtensionExtensions.d.ts +12 -12
  14. package/dist/{types → es/es2018/types}/src/generated/resources/getCommerceExtensionMappings.d.ts +16 -16
  15. package/dist/{types → es/es2018/types}/src/generated/resources/getCommerceExtensionMappingsByMappingId.d.ts +16 -16
  16. package/dist/{types → es/es2018/types}/src/generated/resources/getCommerceExtensionProviders.d.ts +16 -16
  17. package/dist/{types → es/es2018/types}/src/generated/resources/postCommerceExtensionMappings.d.ts +15 -15
  18. package/dist/{types → es/es2018/types}/src/generated/resources/putCommerceExtensionMappingsByMappingId.d.ts +18 -18
  19. package/dist/{types → es/es2018/types}/src/generated/types/ApexClassOutputRepresentation.d.ts +38 -38
  20. package/dist/{types → es/es2018/types}/src/generated/types/EffectiveMappingRepresentation.d.ts +29 -29
  21. package/dist/{types → es/es2018/types}/src/generated/types/ExtensionOutputCollectionRepresentation.d.ts +43 -43
  22. package/dist/{types → es/es2018/types}/src/generated/types/ExtensionOutputRepresentation.d.ts +57 -57
  23. package/dist/{types → es/es2018/types}/src/generated/types/MappingInputRepresentation.d.ts +48 -48
  24. package/dist/{types → es/es2018/types}/src/generated/types/MappingOutputCollectionRepresentation.d.ts +43 -43
  25. package/dist/{types → es/es2018/types}/src/generated/types/MappingOutputRepresentation.d.ts +49 -49
  26. package/dist/{types → es/es2018/types}/src/generated/types/ProviderOutputCollectionRepresentation.d.ts +43 -43
  27. package/dist/{types → es/es2018/types}/src/generated/types/ProviderOutputRepresentation.d.ts +53 -53
  28. package/dist/{types → es/es2018/types}/src/generated/types/type-utils.d.ts +39 -39
  29. package/dist/{types → es/es2018/types}/src/main.d.ts +2 -2
  30. package/dist/{types → es/es2018/types}/src/sfdc.d.ts +3 -3
  31. package/package.json +1 -1
  32. package/sfdc/index.d.ts +1 -1
  33. package/sfdc/index.js +2093 -2093
  34. package/dist/umd/es2018/commerce-extensions.js +0 -2066
  35. package/dist/umd/es5/commerce-extensions.js +0 -2074
@@ -1,2066 +0,0 @@
1
- /**
2
- * Copyright (c) 2022, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
-
7
- (function (global, factory) {
8
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
9
- typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
10
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.commerceExtensions = {}, global.engine));
11
- })(this, (function (exports, engine) { 'use strict';
12
-
13
- const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
14
- const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
15
- const { isArray: ArrayIsArray$1 } = Array;
16
- /**
17
- * Validates an adapter config is well-formed.
18
- * @param config The config to validate.
19
- * @param adapter The adapter validation configuration.
20
- * @param oneOf The keys the config must contain at least one of.
21
- * @throws A TypeError if config doesn't satisfy the adapter's config validation.
22
- */
23
- function validateConfig(config, adapter, oneOf) {
24
- const { displayName } = adapter;
25
- const { required, optional, unsupported } = adapter.parameters;
26
- if (config === undefined ||
27
- required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
28
- throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
29
- }
30
- if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
31
- throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
32
- }
33
- if (unsupported !== undefined &&
34
- unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
35
- throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
36
- }
37
- const supported = required.concat(optional);
38
- if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
39
- throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
40
- }
41
- }
42
- function untrustedIsObject(untrusted) {
43
- return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
44
- }
45
- function areRequiredParametersPresent(config, configPropertyNames) {
46
- return configPropertyNames.parameters.required.every(req => req in config);
47
- }
48
- const snapshotRefreshOptions = {
49
- overrides: {
50
- headers: {
51
- 'Cache-Control': 'no-cache',
52
- },
53
- }
54
- };
55
- const keyPrefix = 'extensions';
56
-
57
- const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
58
- const { isArray: ArrayIsArray } = Array;
59
- const { stringify: JSONStringify } = JSON;
60
- function equalsArray(a, b, equalsItem) {
61
- const aLength = a.length;
62
- const bLength = b.length;
63
- if (aLength !== bLength) {
64
- return false;
65
- }
66
- for (let i = 0; i < aLength; i++) {
67
- if (equalsItem(a[i], b[i]) === false) {
68
- return false;
69
- }
70
- }
71
- return true;
72
- }
73
- function deepFreeze(value) {
74
- // No need to freeze primitives
75
- if (typeof value !== 'object' || value === null) {
76
- return;
77
- }
78
- if (ArrayIsArray(value)) {
79
- for (let i = 0, len = value.length; i < len; i += 1) {
80
- deepFreeze(value[i]);
81
- }
82
- }
83
- else {
84
- const keys = ObjectKeys(value);
85
- for (let i = 0, len = keys.length; i < len; i += 1) {
86
- deepFreeze(value[keys[i]]);
87
- }
88
- }
89
- ObjectFreeze(value);
90
- }
91
- function createLink(ref) {
92
- return {
93
- __ref: engine.serializeStructuredKey(ref),
94
- };
95
- }
96
-
97
- const TTL$5 = 60000;
98
- const VERSION$7 = "504c635d0167987915edb8f94a23ca6d";
99
- function validate$7(obj, path = 'ExtensionOutputRepresentation') {
100
- const v_error = (() => {
101
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
102
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
103
- }
104
- const obj_domain = obj.domain;
105
- const path_domain = path + '.domain';
106
- if (typeof obj_domain !== 'string') {
107
- return new TypeError('Expected "string" but received "' + typeof obj_domain + '" (at "' + path_domain + '")');
108
- }
109
- const obj_epn = obj.epn;
110
- const path_epn = path + '.epn';
111
- if (typeof obj_epn !== 'string') {
112
- return new TypeError('Expected "string" but received "' + typeof obj_epn + '" (at "' + path_epn + '")');
113
- }
114
- const obj_name = obj.name;
115
- const path_name = path + '.name';
116
- if (typeof obj_name !== 'string') {
117
- return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
118
- }
119
- const obj_product = obj.product;
120
- const path_product = path + '.product';
121
- if (typeof obj_product !== 'string') {
122
- return new TypeError('Expected "string" but received "' + typeof obj_product + '" (at "' + path_product + '")');
123
- }
124
- const obj_status = obj.status;
125
- const path_status = path + '.status';
126
- if (typeof obj_status !== 'string') {
127
- return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
128
- }
129
- const obj_type = obj.type;
130
- const path_type = path + '.type';
131
- if (typeof obj_type !== 'string') {
132
- return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
133
- }
134
- const obj_version = obj.version;
135
- const path_version = path + '.version';
136
- if (typeof obj_version !== 'number' || (typeof obj_version === 'number' && Math.floor(obj_version) !== obj_version)) {
137
- return new TypeError('Expected "integer" but received "' + typeof obj_version + '" (at "' + path_version + '")');
138
- }
139
- })();
140
- return v_error === undefined ? null : v_error;
141
- }
142
- const RepresentationType$5 = 'ExtensionOutputRepresentation';
143
- function keyBuilder$b(luvio, config) {
144
- return keyPrefix + '::' + RepresentationType$5 + ':' + config.epn;
145
- }
146
- function keyBuilderFromType$2(luvio, object) {
147
- const keyParams = {
148
- epn: object.epn
149
- };
150
- return keyBuilder$b(luvio, keyParams);
151
- }
152
- function normalize$5(input, existing, path, luvio, store, timestamp) {
153
- return input;
154
- }
155
- const select$d = function ExtensionOutputRepresentationSelect() {
156
- return {
157
- kind: 'Fragment',
158
- version: VERSION$7,
159
- private: [],
160
- selections: [
161
- {
162
- name: 'domain',
163
- kind: 'Scalar'
164
- },
165
- {
166
- name: 'epn',
167
- kind: 'Scalar'
168
- },
169
- {
170
- name: 'name',
171
- kind: 'Scalar'
172
- },
173
- {
174
- name: 'product',
175
- kind: 'Scalar'
176
- },
177
- {
178
- name: 'status',
179
- kind: 'Scalar'
180
- },
181
- {
182
- name: 'type',
183
- kind: 'Scalar'
184
- },
185
- {
186
- name: 'version',
187
- kind: 'Scalar'
188
- }
189
- ]
190
- };
191
- };
192
- function equals$7(existing, incoming) {
193
- const existing_version = existing.version;
194
- const incoming_version = incoming.version;
195
- if (!(existing_version === incoming_version)) {
196
- return false;
197
- }
198
- const existing_domain = existing.domain;
199
- const incoming_domain = incoming.domain;
200
- if (!(existing_domain === incoming_domain)) {
201
- return false;
202
- }
203
- const existing_epn = existing.epn;
204
- const incoming_epn = incoming.epn;
205
- if (!(existing_epn === incoming_epn)) {
206
- return false;
207
- }
208
- const existing_name = existing.name;
209
- const incoming_name = incoming.name;
210
- if (!(existing_name === incoming_name)) {
211
- return false;
212
- }
213
- const existing_product = existing.product;
214
- const incoming_product = incoming.product;
215
- if (!(existing_product === incoming_product)) {
216
- return false;
217
- }
218
- const existing_status = existing.status;
219
- const incoming_status = incoming.status;
220
- if (!(existing_status === incoming_status)) {
221
- return false;
222
- }
223
- const existing_type = existing.type;
224
- const incoming_type = incoming.type;
225
- if (!(existing_type === incoming_type)) {
226
- return false;
227
- }
228
- return true;
229
- }
230
- const ingest$5 = function ExtensionOutputRepresentationIngest(input, path, luvio, store, timestamp) {
231
- if (process.env.NODE_ENV !== 'production') {
232
- const validateError = validate$7(input);
233
- if (validateError !== null) {
234
- throw validateError;
235
- }
236
- }
237
- const key = keyBuilderFromType$2(luvio, input);
238
- const existingRecord = store.readEntry(key);
239
- const ttlToUse = TTL$5;
240
- let incomingRecord = normalize$5(input, store.readEntry(key), {
241
- fullPath: key,
242
- parent: path.parent,
243
- propertyName: path.propertyName,
244
- ttl: ttlToUse
245
- });
246
- if (existingRecord === undefined || equals$7(existingRecord, incomingRecord) === false) {
247
- luvio.storePublish(key, incomingRecord);
248
- }
249
- {
250
- const storeMetadataParams = {
251
- ttl: ttlToUse,
252
- namespace: "extensions",
253
- version: VERSION$7,
254
- representationName: RepresentationType$5,
255
- };
256
- luvio.publishStoreMetadata(key, storeMetadataParams);
257
- }
258
- return createLink(key);
259
- };
260
- function getTypeCacheKeys$5(luvio, input, fullPathFactory) {
261
- const rootKeySet = new engine.StoreKeyMap();
262
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
263
- const rootKey = keyBuilderFromType$2(luvio, input);
264
- rootKeySet.set(rootKey, {
265
- namespace: keyPrefix,
266
- representationName: RepresentationType$5,
267
- mergeable: false
268
- });
269
- return rootKeySet;
270
- }
271
-
272
- const TTL$4 = 60000;
273
- const VERSION$6 = "d4f70ccafbea6d39e182d71c60d4ba89";
274
- function validate$6(obj, path = 'ExtensionOutputCollectionRepresentation') {
275
- const v_error = (() => {
276
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
277
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
278
- }
279
- const obj_count = obj.count;
280
- const path_count = path + '.count';
281
- if (typeof obj_count !== 'number' || (typeof obj_count === 'number' && Math.floor(obj_count) !== obj_count)) {
282
- return new TypeError('Expected "integer" but received "' + typeof obj_count + '" (at "' + path_count + '")');
283
- }
284
- const obj_items = obj.items;
285
- const path_items = path + '.items';
286
- if (!ArrayIsArray(obj_items)) {
287
- return new TypeError('Expected "array" but received "' + typeof obj_items + '" (at "' + path_items + '")');
288
- }
289
- for (let i = 0; i < obj_items.length; i++) {
290
- const obj_items_item = obj_items[i];
291
- const path_items_item = path_items + '[' + i + ']';
292
- if (typeof obj_items_item !== 'object') {
293
- return new TypeError('Expected "object" but received "' + typeof obj_items_item + '" (at "' + path_items_item + '")');
294
- }
295
- }
296
- })();
297
- return v_error === undefined ? null : v_error;
298
- }
299
- const RepresentationType$4 = 'ExtensionOutputCollectionRepresentation';
300
- function normalize$4(input, existing, path, luvio, store, timestamp) {
301
- const input_items = input.items;
302
- const input_items_id = path.fullPath + '__items';
303
- for (let i = 0; i < input_items.length; i++) {
304
- const input_items_item = input_items[i];
305
- let input_items_item_id = input_items_id + '__' + i;
306
- input_items[i] = ingest$5(input_items_item, {
307
- fullPath: input_items_item_id,
308
- propertyName: i,
309
- parent: {
310
- data: input,
311
- key: path.fullPath,
312
- existing: existing,
313
- },
314
- ttl: path.ttl
315
- }, luvio, store);
316
- }
317
- return input;
318
- }
319
- const select$c = function ExtensionOutputCollectionRepresentationSelect() {
320
- return {
321
- kind: 'Fragment',
322
- version: VERSION$6,
323
- private: [],
324
- selections: [
325
- {
326
- name: 'count',
327
- kind: 'Scalar'
328
- },
329
- {
330
- name: 'items',
331
- kind: 'Link',
332
- plural: true,
333
- fragment: select$d()
334
- }
335
- ]
336
- };
337
- };
338
- function equals$6(existing, incoming) {
339
- const existing_count = existing.count;
340
- const incoming_count = incoming.count;
341
- if (!(existing_count === incoming_count)) {
342
- return false;
343
- }
344
- const existing_items = existing.items;
345
- const incoming_items = incoming.items;
346
- const equals_items_items = equalsArray(existing_items, incoming_items, (existing_items_item, incoming_items_item) => {
347
- if (!(existing_items_item.__ref === incoming_items_item.__ref)) {
348
- return false;
349
- }
350
- });
351
- if (equals_items_items === false) {
352
- return false;
353
- }
354
- return true;
355
- }
356
- const ingest$4 = function ExtensionOutputCollectionRepresentationIngest(input, path, luvio, store, timestamp) {
357
- if (process.env.NODE_ENV !== 'production') {
358
- const validateError = validate$6(input);
359
- if (validateError !== null) {
360
- throw validateError;
361
- }
362
- }
363
- const key = path.fullPath;
364
- const existingRecord = store.readEntry(key);
365
- const ttlToUse = TTL$4;
366
- let incomingRecord = normalize$4(input, store.readEntry(key), {
367
- fullPath: key,
368
- parent: path.parent,
369
- propertyName: path.propertyName,
370
- ttl: ttlToUse
371
- }, luvio, store);
372
- if (existingRecord === undefined || equals$6(existingRecord, incomingRecord) === false) {
373
- luvio.storePublish(key, incomingRecord);
374
- }
375
- {
376
- const storeMetadataParams = {
377
- ttl: ttlToUse,
378
- namespace: "extensions",
379
- version: VERSION$6,
380
- representationName: RepresentationType$4,
381
- };
382
- luvio.publishStoreMetadata(key, storeMetadataParams);
383
- }
384
- return createLink(key);
385
- };
386
- function getTypeCacheKeys$4(luvio, input, fullPathFactory) {
387
- const rootKeySet = new engine.StoreKeyMap();
388
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
389
- const rootKey = fullPathFactory();
390
- rootKeySet.set(rootKey, {
391
- namespace: keyPrefix,
392
- representationName: RepresentationType$4,
393
- mergeable: false
394
- });
395
- const input_items_length = input.items.length;
396
- for (let i = 0; i < input_items_length; i++) {
397
- rootKeySet.merge(getTypeCacheKeys$5(luvio, input.items[i]));
398
- }
399
- return rootKeySet;
400
- }
401
-
402
- function select$b(luvio, params) {
403
- return select$c();
404
- }
405
- function keyBuilder$a(luvio, params) {
406
- return keyPrefix + '::ExtensionOutputCollectionRepresentation:(' + ')';
407
- }
408
- function getResponseCacheKeys$6(luvio, resourceParams, response) {
409
- return getTypeCacheKeys$4(luvio, response, () => keyBuilder$a());
410
- }
411
- function ingestSuccess$5(luvio, resourceParams, response, snapshotRefresh) {
412
- const { body } = response;
413
- const key = keyBuilder$a();
414
- luvio.storeIngest(key, ingest$4, body);
415
- const snapshot = luvio.storeLookup({
416
- recordId: key,
417
- node: select$b(),
418
- variables: {},
419
- }, snapshotRefresh);
420
- if (process.env.NODE_ENV !== 'production') {
421
- if (snapshot.state !== 'Fulfilled') {
422
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
423
- }
424
- }
425
- return snapshot;
426
- }
427
- function ingestError$3(luvio, params, error, snapshotRefresh) {
428
- const key = keyBuilder$a();
429
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
430
- const storeMetadataParams = {
431
- ttl: TTL$4,
432
- namespace: keyPrefix,
433
- version: VERSION$6,
434
- representationName: RepresentationType$4
435
- };
436
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
437
- return errorSnapshot;
438
- }
439
- function createResourceRequest$6(config) {
440
- const headers = {};
441
- return {
442
- baseUri: '/services/data/v58.0',
443
- basePath: '/commerce/extension/extensions',
444
- method: 'get',
445
- body: null,
446
- urlParams: {},
447
- queryParams: {},
448
- headers,
449
- priority: 'normal',
450
- };
451
- }
452
-
453
- const getExtensions_ConfigPropertyNames = {
454
- displayName: 'getExtensions',
455
- parameters: {
456
- required: [],
457
- optional: []
458
- }
459
- };
460
- function createResourceParams$6(config) {
461
- const resourceParams = {};
462
- return resourceParams;
463
- }
464
- function keyBuilder$9(luvio, config) {
465
- return keyBuilder$a();
466
- }
467
- function typeCheckConfig$6(untrustedConfig) {
468
- const config = {};
469
- return config;
470
- }
471
- function validateAdapterConfig$6(untrustedConfig, configPropertyNames) {
472
- if (!untrustedIsObject(untrustedConfig)) {
473
- return null;
474
- }
475
- if (process.env.NODE_ENV !== 'production') {
476
- validateConfig(untrustedConfig, configPropertyNames);
477
- }
478
- const config = typeCheckConfig$6();
479
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
480
- return null;
481
- }
482
- return config;
483
- }
484
- function adapterFragment$3(luvio, config) {
485
- return select$b();
486
- }
487
- function onFetchResponseSuccess$3(luvio, config, resourceParams, response) {
488
- const snapshot = ingestSuccess$5(luvio, resourceParams, response, {
489
- config,
490
- resolve: () => buildNetworkSnapshot$6(luvio, config, snapshotRefreshOptions)
491
- });
492
- return luvio.storeBroadcast().then(() => snapshot);
493
- }
494
- function onFetchResponseError$3(luvio, config, resourceParams, response) {
495
- const snapshot = ingestError$3(luvio, resourceParams, response, {
496
- config,
497
- resolve: () => buildNetworkSnapshot$6(luvio, config, snapshotRefreshOptions)
498
- });
499
- return luvio.storeBroadcast().then(() => snapshot);
500
- }
501
- function buildNetworkSnapshot$6(luvio, config, options) {
502
- const resourceParams = createResourceParams$6();
503
- const request = createResourceRequest$6();
504
- return luvio.dispatchResourceRequest(request, options)
505
- .then((response) => {
506
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess$3(luvio, config, resourceParams, response), () => getResponseCacheKeys$6(luvio, resourceParams, response.body));
507
- }, (response) => {
508
- return luvio.handleErrorResponse(() => onFetchResponseError$3(luvio, config, resourceParams, response));
509
- });
510
- }
511
- function buildNetworkSnapshotCachePolicy$3(context, coercedAdapterRequestContext) {
512
- const { luvio, config } = context;
513
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
514
- const dispatchOptions = {
515
- resourceRequestContext: {
516
- requestCorrelator,
517
- luvioRequestMethod: undefined,
518
- },
519
- eventObservers
520
- };
521
- if (networkPriority !== 'normal') {
522
- dispatchOptions.overrides = {
523
- priority: networkPriority
524
- };
525
- }
526
- return buildNetworkSnapshot$6(luvio, config, dispatchOptions);
527
- }
528
- function buildCachedSnapshotCachePolicy$3(context, storeLookup) {
529
- const { luvio, config } = context;
530
- const selector = {
531
- recordId: keyBuilder$9(),
532
- node: adapterFragment$3(),
533
- variables: {},
534
- };
535
- const cacheSnapshot = storeLookup(selector, {
536
- config,
537
- resolve: () => buildNetworkSnapshot$6(luvio, config, snapshotRefreshOptions)
538
- });
539
- return cacheSnapshot;
540
- }
541
- const getExtensionsAdapterFactory = (luvio) => function extensions__getExtensions(untrustedConfig, requestContext) {
542
- const config = validateAdapterConfig$6(untrustedConfig, getExtensions_ConfigPropertyNames);
543
- // Invalid or incomplete config
544
- if (config === null) {
545
- return null;
546
- }
547
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
548
- buildCachedSnapshotCachePolicy$3, buildNetworkSnapshotCachePolicy$3);
549
- };
550
-
551
- const TTL$3 = 60000;
552
- const VERSION$5 = "cef52859122e69e7f8552d6d2fbf67f8";
553
- function validate$5(obj, path = 'MappingOutputRepresentation') {
554
- const v_error = (() => {
555
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
556
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
557
- }
558
- const obj_epn = obj.epn;
559
- const path_epn = path + '.epn';
560
- if (typeof obj_epn !== 'string') {
561
- return new TypeError('Expected "string" but received "' + typeof obj_epn + '" (at "' + path_epn + '")');
562
- }
563
- const obj_id = obj.id;
564
- const path_id = path + '.id';
565
- if (typeof obj_id !== 'string') {
566
- return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
567
- }
568
- const obj_providerName = obj.providerName;
569
- const path_providerName = path + '.providerName';
570
- if (typeof obj_providerName !== 'string') {
571
- return new TypeError('Expected "string" but received "' + typeof obj_providerName + '" (at "' + path_providerName + '")');
572
- }
573
- const obj_webstoreId = obj.webstoreId;
574
- const path_webstoreId = path + '.webstoreId';
575
- if (typeof obj_webstoreId !== 'string') {
576
- return new TypeError('Expected "string" but received "' + typeof obj_webstoreId + '" (at "' + path_webstoreId + '")');
577
- }
578
- })();
579
- return v_error === undefined ? null : v_error;
580
- }
581
- const RepresentationType$3 = 'MappingOutputRepresentation';
582
- function keyBuilder$8(luvio, config) {
583
- return keyPrefix + '::' + RepresentationType$3 + ':' + config.id;
584
- }
585
- function keyBuilderFromType$1(luvio, object) {
586
- const keyParams = {
587
- id: object.id
588
- };
589
- return keyBuilder$8(luvio, keyParams);
590
- }
591
- function normalize$3(input, existing, path, luvio, store, timestamp) {
592
- return input;
593
- }
594
- const select$a = function MappingOutputRepresentationSelect() {
595
- return {
596
- kind: 'Fragment',
597
- version: VERSION$5,
598
- private: [],
599
- selections: [
600
- {
601
- name: 'epn',
602
- kind: 'Scalar'
603
- },
604
- {
605
- name: 'id',
606
- kind: 'Scalar'
607
- },
608
- {
609
- name: 'providerName',
610
- kind: 'Scalar'
611
- },
612
- {
613
- name: 'webstoreId',
614
- kind: 'Scalar'
615
- }
616
- ]
617
- };
618
- };
619
- function equals$5(existing, incoming) {
620
- const existing_epn = existing.epn;
621
- const incoming_epn = incoming.epn;
622
- if (!(existing_epn === incoming_epn)) {
623
- return false;
624
- }
625
- const existing_id = existing.id;
626
- const incoming_id = incoming.id;
627
- if (!(existing_id === incoming_id)) {
628
- return false;
629
- }
630
- const existing_providerName = existing.providerName;
631
- const incoming_providerName = incoming.providerName;
632
- if (!(existing_providerName === incoming_providerName)) {
633
- return false;
634
- }
635
- const existing_webstoreId = existing.webstoreId;
636
- const incoming_webstoreId = incoming.webstoreId;
637
- if (!(existing_webstoreId === incoming_webstoreId)) {
638
- return false;
639
- }
640
- return true;
641
- }
642
- const ingest$3 = function MappingOutputRepresentationIngest(input, path, luvio, store, timestamp) {
643
- if (process.env.NODE_ENV !== 'production') {
644
- const validateError = validate$5(input);
645
- if (validateError !== null) {
646
- throw validateError;
647
- }
648
- }
649
- const key = keyBuilderFromType$1(luvio, input);
650
- const existingRecord = store.readEntry(key);
651
- const ttlToUse = TTL$3;
652
- let incomingRecord = normalize$3(input, store.readEntry(key), {
653
- fullPath: key,
654
- parent: path.parent,
655
- propertyName: path.propertyName,
656
- ttl: ttlToUse
657
- });
658
- if (existingRecord === undefined || equals$5(existingRecord, incomingRecord) === false) {
659
- luvio.storePublish(key, incomingRecord);
660
- }
661
- {
662
- const storeMetadataParams = {
663
- ttl: ttlToUse,
664
- namespace: "extensions",
665
- version: VERSION$5,
666
- representationName: RepresentationType$3,
667
- };
668
- luvio.publishStoreMetadata(key, storeMetadataParams);
669
- }
670
- return createLink(key);
671
- };
672
- function getTypeCacheKeys$3(luvio, input, fullPathFactory) {
673
- const rootKeySet = new engine.StoreKeyMap();
674
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
675
- const rootKey = keyBuilderFromType$1(luvio, input);
676
- rootKeySet.set(rootKey, {
677
- namespace: keyPrefix,
678
- representationName: RepresentationType$3,
679
- mergeable: false
680
- });
681
- return rootKeySet;
682
- }
683
- const notifyUpdateAvailableFactory = (luvio) => {
684
- return function notifyMappingUpdateAvailable(configs) {
685
- if (process.env.NODE_ENV !== 'production') {
686
- const requiredKeyParams = ['id'];
687
- configs.forEach(config => {
688
- if (false === requiredKeyParams.every(req => req in config)) {
689
- throw new Error(`one of the configs did not contain all required parameters: ${JSONStringify(ObjectKeys(config))}`);
690
- }
691
- });
692
- }
693
- const keys = configs.map(c => keyBuilder$8(luvio, c));
694
- return luvio.notifyStoreUpdateAvailable(keys);
695
- };
696
- };
697
-
698
- const TTL$2 = 60000;
699
- const VERSION$4 = "7aeadbbc38a3c6a4adff51c98906ed3e";
700
- function validate$4(obj, path = 'MappingOutputCollectionRepresentation') {
701
- const v_error = (() => {
702
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
703
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
704
- }
705
- const obj_count = obj.count;
706
- const path_count = path + '.count';
707
- if (typeof obj_count !== 'number' || (typeof obj_count === 'number' && Math.floor(obj_count) !== obj_count)) {
708
- return new TypeError('Expected "integer" but received "' + typeof obj_count + '" (at "' + path_count + '")');
709
- }
710
- const obj_items = obj.items;
711
- const path_items = path + '.items';
712
- if (!ArrayIsArray(obj_items)) {
713
- return new TypeError('Expected "array" but received "' + typeof obj_items + '" (at "' + path_items + '")');
714
- }
715
- for (let i = 0; i < obj_items.length; i++) {
716
- const obj_items_item = obj_items[i];
717
- const path_items_item = path_items + '[' + i + ']';
718
- if (typeof obj_items_item !== 'object') {
719
- return new TypeError('Expected "object" but received "' + typeof obj_items_item + '" (at "' + path_items_item + '")');
720
- }
721
- }
722
- })();
723
- return v_error === undefined ? null : v_error;
724
- }
725
- const RepresentationType$2 = 'MappingOutputCollectionRepresentation';
726
- function normalize$2(input, existing, path, luvio, store, timestamp) {
727
- const input_items = input.items;
728
- const input_items_id = path.fullPath + '__items';
729
- for (let i = 0; i < input_items.length; i++) {
730
- const input_items_item = input_items[i];
731
- let input_items_item_id = input_items_id + '__' + i;
732
- input_items[i] = ingest$3(input_items_item, {
733
- fullPath: input_items_item_id,
734
- propertyName: i,
735
- parent: {
736
- data: input,
737
- key: path.fullPath,
738
- existing: existing,
739
- },
740
- ttl: path.ttl
741
- }, luvio, store);
742
- }
743
- return input;
744
- }
745
- const select$9 = function MappingOutputCollectionRepresentationSelect() {
746
- return {
747
- kind: 'Fragment',
748
- version: VERSION$4,
749
- private: [],
750
- selections: [
751
- {
752
- name: 'count',
753
- kind: 'Scalar'
754
- },
755
- {
756
- name: 'items',
757
- kind: 'Link',
758
- plural: true,
759
- fragment: select$a()
760
- }
761
- ]
762
- };
763
- };
764
- function equals$4(existing, incoming) {
765
- const existing_count = existing.count;
766
- const incoming_count = incoming.count;
767
- if (!(existing_count === incoming_count)) {
768
- return false;
769
- }
770
- const existing_items = existing.items;
771
- const incoming_items = incoming.items;
772
- const equals_items_items = equalsArray(existing_items, incoming_items, (existing_items_item, incoming_items_item) => {
773
- if (!(existing_items_item.__ref === incoming_items_item.__ref)) {
774
- return false;
775
- }
776
- });
777
- if (equals_items_items === false) {
778
- return false;
779
- }
780
- return true;
781
- }
782
- const ingest$2 = function MappingOutputCollectionRepresentationIngest(input, path, luvio, store, timestamp) {
783
- if (process.env.NODE_ENV !== 'production') {
784
- const validateError = validate$4(input);
785
- if (validateError !== null) {
786
- throw validateError;
787
- }
788
- }
789
- const key = path.fullPath;
790
- const existingRecord = store.readEntry(key);
791
- const ttlToUse = TTL$2;
792
- let incomingRecord = normalize$2(input, store.readEntry(key), {
793
- fullPath: key,
794
- parent: path.parent,
795
- propertyName: path.propertyName,
796
- ttl: ttlToUse
797
- }, luvio, store);
798
- if (existingRecord === undefined || equals$4(existingRecord, incomingRecord) === false) {
799
- luvio.storePublish(key, incomingRecord);
800
- }
801
- {
802
- const storeMetadataParams = {
803
- ttl: ttlToUse,
804
- namespace: "extensions",
805
- version: VERSION$4,
806
- representationName: RepresentationType$2,
807
- };
808
- luvio.publishStoreMetadata(key, storeMetadataParams);
809
- }
810
- return createLink(key);
811
- };
812
- function getTypeCacheKeys$2(luvio, input, fullPathFactory) {
813
- const rootKeySet = new engine.StoreKeyMap();
814
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
815
- const rootKey = fullPathFactory();
816
- rootKeySet.set(rootKey, {
817
- namespace: keyPrefix,
818
- representationName: RepresentationType$2,
819
- mergeable: false
820
- });
821
- const input_items_length = input.items.length;
822
- for (let i = 0; i < input_items_length; i++) {
823
- rootKeySet.merge(getTypeCacheKeys$3(luvio, input.items[i]));
824
- }
825
- return rootKeySet;
826
- }
827
-
828
- function select$8(luvio, params) {
829
- return select$9();
830
- }
831
- function keyBuilder$7(luvio, params) {
832
- return keyPrefix + '::MappingOutputCollectionRepresentation:(' + 'epn:' + params.queryParams.epn + ',' + 'webstoreId:' + params.queryParams.webstoreId + ')';
833
- }
834
- function getResponseCacheKeys$5(luvio, resourceParams, response) {
835
- return getTypeCacheKeys$2(luvio, response, () => keyBuilder$7(luvio, resourceParams));
836
- }
837
- function ingestSuccess$4(luvio, resourceParams, response, snapshotRefresh) {
838
- const { body } = response;
839
- const key = keyBuilder$7(luvio, resourceParams);
840
- luvio.storeIngest(key, ingest$2, body);
841
- const snapshot = luvio.storeLookup({
842
- recordId: key,
843
- node: select$8(),
844
- variables: {},
845
- }, snapshotRefresh);
846
- if (process.env.NODE_ENV !== 'production') {
847
- if (snapshot.state !== 'Fulfilled') {
848
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
849
- }
850
- }
851
- return snapshot;
852
- }
853
- function ingestError$2(luvio, params, error, snapshotRefresh) {
854
- const key = keyBuilder$7(luvio, params);
855
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
856
- const storeMetadataParams = {
857
- ttl: TTL$2,
858
- namespace: keyPrefix,
859
- version: VERSION$4,
860
- representationName: RepresentationType$2
861
- };
862
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
863
- return errorSnapshot;
864
- }
865
- function createResourceRequest$5(config) {
866
- const headers = {};
867
- return {
868
- baseUri: '/services/data/v58.0',
869
- basePath: '/commerce/extension/mappings',
870
- method: 'get',
871
- body: null,
872
- urlParams: {},
873
- queryParams: config.queryParams,
874
- headers,
875
- priority: 'normal',
876
- };
877
- }
878
-
879
- const getMappings_ConfigPropertyNames = {
880
- displayName: 'getMappings',
881
- parameters: {
882
- required: [],
883
- optional: ['epn', 'webstoreId']
884
- }
885
- };
886
- function createResourceParams$5(config) {
887
- const resourceParams = {
888
- queryParams: {
889
- epn: config.epn, webstoreId: config.webstoreId
890
- }
891
- };
892
- return resourceParams;
893
- }
894
- function keyBuilder$6(luvio, config) {
895
- const resourceParams = createResourceParams$5(config);
896
- return keyBuilder$7(luvio, resourceParams);
897
- }
898
- function typeCheckConfig$5(untrustedConfig) {
899
- const config = {};
900
- const untrustedConfig_epn = untrustedConfig.epn;
901
- if (typeof untrustedConfig_epn === 'string') {
902
- config.epn = untrustedConfig_epn;
903
- }
904
- const untrustedConfig_webstoreId = untrustedConfig.webstoreId;
905
- if (typeof untrustedConfig_webstoreId === 'string') {
906
- config.webstoreId = untrustedConfig_webstoreId;
907
- }
908
- return config;
909
- }
910
- function validateAdapterConfig$5(untrustedConfig, configPropertyNames) {
911
- if (!untrustedIsObject(untrustedConfig)) {
912
- return null;
913
- }
914
- if (process.env.NODE_ENV !== 'production') {
915
- validateConfig(untrustedConfig, configPropertyNames);
916
- }
917
- const config = typeCheckConfig$5(untrustedConfig);
918
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
919
- return null;
920
- }
921
- return config;
922
- }
923
- function adapterFragment$2(luvio, config) {
924
- createResourceParams$5(config);
925
- return select$8();
926
- }
927
- function onFetchResponseSuccess$2(luvio, config, resourceParams, response) {
928
- const snapshot = ingestSuccess$4(luvio, resourceParams, response, {
929
- config,
930
- resolve: () => buildNetworkSnapshot$5(luvio, config, snapshotRefreshOptions)
931
- });
932
- return luvio.storeBroadcast().then(() => snapshot);
933
- }
934
- function onFetchResponseError$2(luvio, config, resourceParams, response) {
935
- const snapshot = ingestError$2(luvio, resourceParams, response, {
936
- config,
937
- resolve: () => buildNetworkSnapshot$5(luvio, config, snapshotRefreshOptions)
938
- });
939
- return luvio.storeBroadcast().then(() => snapshot);
940
- }
941
- function buildNetworkSnapshot$5(luvio, config, options) {
942
- const resourceParams = createResourceParams$5(config);
943
- const request = createResourceRequest$5(resourceParams);
944
- return luvio.dispatchResourceRequest(request, options)
945
- .then((response) => {
946
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess$2(luvio, config, resourceParams, response), () => getResponseCacheKeys$5(luvio, resourceParams, response.body));
947
- }, (response) => {
948
- return luvio.handleErrorResponse(() => onFetchResponseError$2(luvio, config, resourceParams, response));
949
- });
950
- }
951
- function buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext) {
952
- const { luvio, config } = context;
953
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
954
- const dispatchOptions = {
955
- resourceRequestContext: {
956
- requestCorrelator,
957
- luvioRequestMethod: undefined,
958
- },
959
- eventObservers
960
- };
961
- if (networkPriority !== 'normal') {
962
- dispatchOptions.overrides = {
963
- priority: networkPriority
964
- };
965
- }
966
- return buildNetworkSnapshot$5(luvio, config, dispatchOptions);
967
- }
968
- function buildCachedSnapshotCachePolicy$2(context, storeLookup) {
969
- const { luvio, config } = context;
970
- const selector = {
971
- recordId: keyBuilder$6(luvio, config),
972
- node: adapterFragment$2(luvio, config),
973
- variables: {},
974
- };
975
- const cacheSnapshot = storeLookup(selector, {
976
- config,
977
- resolve: () => buildNetworkSnapshot$5(luvio, config, snapshotRefreshOptions)
978
- });
979
- return cacheSnapshot;
980
- }
981
- const getMappingsAdapterFactory = (luvio) => function extensions__getMappings(untrustedConfig, requestContext) {
982
- const config = validateAdapterConfig$5(untrustedConfig, getMappings_ConfigPropertyNames);
983
- // Invalid or incomplete config
984
- if (config === null) {
985
- return null;
986
- }
987
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
988
- buildCachedSnapshotCachePolicy$2, buildNetworkSnapshotCachePolicy$2);
989
- };
990
-
991
- function select$7(luvio, params) {
992
- return select$a();
993
- }
994
- function getResponseCacheKeys$4(luvio, resourceParams, response) {
995
- return getTypeCacheKeys$3(luvio, response);
996
- }
997
- function ingestSuccess$3(luvio, resourceParams, response) {
998
- const { body } = response;
999
- const key = keyBuilderFromType$1(luvio, body);
1000
- luvio.storeIngest(key, ingest$3, body);
1001
- const snapshot = luvio.storeLookup({
1002
- recordId: key,
1003
- node: select$7(),
1004
- variables: {},
1005
- });
1006
- if (process.env.NODE_ENV !== 'production') {
1007
- if (snapshot.state !== 'Fulfilled') {
1008
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1009
- }
1010
- }
1011
- return snapshot;
1012
- }
1013
- function createResourceRequest$4(config) {
1014
- const headers = {};
1015
- return {
1016
- baseUri: '/services/data/v58.0',
1017
- basePath: '/commerce/extension/mappings',
1018
- method: 'post',
1019
- body: config.body,
1020
- urlParams: {},
1021
- queryParams: {},
1022
- headers,
1023
- priority: 'normal',
1024
- };
1025
- }
1026
-
1027
- const createMapping_ConfigPropertyNames = {
1028
- displayName: 'createMapping',
1029
- parameters: {
1030
- required: ['epn', 'providerName', 'webstoreId'],
1031
- optional: ['id']
1032
- }
1033
- };
1034
- function createResourceParams$4(config) {
1035
- const resourceParams = {
1036
- body: {
1037
- epn: config.epn, providerName: config.providerName, webstoreId: config.webstoreId
1038
- }
1039
- };
1040
- if (config['id'] !== undefined) {
1041
- resourceParams.body['id'] = config['id'];
1042
- }
1043
- return resourceParams;
1044
- }
1045
- function typeCheckConfig$4(untrustedConfig) {
1046
- const config = {};
1047
- const untrustedConfig_epn = untrustedConfig.epn;
1048
- if (typeof untrustedConfig_epn === 'string') {
1049
- config.epn = untrustedConfig_epn;
1050
- }
1051
- const untrustedConfig_id = untrustedConfig.id;
1052
- if (typeof untrustedConfig_id === 'string') {
1053
- config.id = untrustedConfig_id;
1054
- }
1055
- const untrustedConfig_providerName = untrustedConfig.providerName;
1056
- if (typeof untrustedConfig_providerName === 'string') {
1057
- config.providerName = untrustedConfig_providerName;
1058
- }
1059
- const untrustedConfig_webstoreId = untrustedConfig.webstoreId;
1060
- if (typeof untrustedConfig_webstoreId === 'string') {
1061
- config.webstoreId = untrustedConfig_webstoreId;
1062
- }
1063
- return config;
1064
- }
1065
- function validateAdapterConfig$4(untrustedConfig, configPropertyNames) {
1066
- if (!untrustedIsObject(untrustedConfig)) {
1067
- return null;
1068
- }
1069
- if (process.env.NODE_ENV !== 'production') {
1070
- validateConfig(untrustedConfig, configPropertyNames);
1071
- }
1072
- const config = typeCheckConfig$4(untrustedConfig);
1073
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
1074
- return null;
1075
- }
1076
- return config;
1077
- }
1078
- function buildNetworkSnapshot$4(luvio, config, options) {
1079
- const resourceParams = createResourceParams$4(config);
1080
- const request = createResourceRequest$4(resourceParams);
1081
- return luvio.dispatchResourceRequest(request, options)
1082
- .then((response) => {
1083
- return luvio.handleSuccessResponse(() => {
1084
- const snapshot = ingestSuccess$3(luvio, resourceParams, response);
1085
- return luvio.storeBroadcast().then(() => snapshot);
1086
- }, () => getResponseCacheKeys$4(luvio, resourceParams, response.body));
1087
- }, (response) => {
1088
- deepFreeze(response);
1089
- throw response;
1090
- });
1091
- }
1092
- const createMappingAdapterFactory = (luvio) => {
1093
- return function createMapping(untrustedConfig) {
1094
- const config = validateAdapterConfig$4(untrustedConfig, createMapping_ConfigPropertyNames);
1095
- // Invalid or incomplete config
1096
- if (config === null) {
1097
- throw new Error('Invalid config for "createMapping"');
1098
- }
1099
- return buildNetworkSnapshot$4(luvio, config);
1100
- };
1101
- };
1102
-
1103
- function keyBuilder$5(luvio, params) {
1104
- return keyBuilder$8(luvio, {
1105
- id: params.urlParams.mappingId
1106
- });
1107
- }
1108
- function getResponseCacheKeys$3(luvio, resourceParams) {
1109
- const key = keyBuilder$5(luvio, resourceParams);
1110
- const cacheKeyMap = new engine.StoreKeyMap();
1111
- cacheKeyMap.set(key, {
1112
- namespace: keyPrefix,
1113
- representationName: RepresentationType$3,
1114
- mergeable: false
1115
- });
1116
- return cacheKeyMap;
1117
- }
1118
- function evictSuccess(luvio, resourceParams) {
1119
- const key = keyBuilder$5(luvio, resourceParams);
1120
- luvio.storeEvict(key);
1121
- }
1122
- function createResourceRequest$3(config) {
1123
- const headers = {};
1124
- return {
1125
- baseUri: '/services/data/v58.0',
1126
- basePath: '/commerce/extension/mappings/' + config.urlParams.mappingId + '',
1127
- method: 'delete',
1128
- body: null,
1129
- urlParams: config.urlParams,
1130
- queryParams: {},
1131
- headers,
1132
- priority: 'normal',
1133
- };
1134
- }
1135
-
1136
- const adapterName = 'deleteMapping';
1137
- const deleteMapping_ConfigPropertyNames = {
1138
- displayName: 'deleteMapping',
1139
- parameters: {
1140
- required: ['mappingId'],
1141
- optional: []
1142
- }
1143
- };
1144
- function createResourceParams$3(config) {
1145
- const resourceParams = {
1146
- urlParams: {
1147
- mappingId: config.mappingId
1148
- }
1149
- };
1150
- return resourceParams;
1151
- }
1152
- function typeCheckConfig$3(untrustedConfig) {
1153
- const config = {};
1154
- const untrustedConfig_mappingId = untrustedConfig.mappingId;
1155
- if (typeof untrustedConfig_mappingId === 'string') {
1156
- config.mappingId = untrustedConfig_mappingId;
1157
- }
1158
- return config;
1159
- }
1160
- function validateAdapterConfig$3(untrustedConfig, configPropertyNames) {
1161
- if (!untrustedIsObject(untrustedConfig)) {
1162
- return null;
1163
- }
1164
- if (process.env.NODE_ENV !== 'production') {
1165
- validateConfig(untrustedConfig, configPropertyNames);
1166
- }
1167
- const config = typeCheckConfig$3(untrustedConfig);
1168
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
1169
- return null;
1170
- }
1171
- return config;
1172
- }
1173
- function buildNetworkSnapshot$3(luvio, config, options) {
1174
- const resourceParams = createResourceParams$3(config);
1175
- const request = createResourceRequest$3(resourceParams);
1176
- return luvio.dispatchResourceRequest(request, options)
1177
- .then(() => {
1178
- return luvio.handleSuccessResponse(() => {
1179
- evictSuccess(luvio, resourceParams);
1180
- return luvio.storeBroadcast();
1181
- }, () => getResponseCacheKeys$3(luvio, resourceParams));
1182
- }, (response) => {
1183
- deepFreeze(response);
1184
- throw response;
1185
- });
1186
- }
1187
- const deleteMappingAdapterFactory = (luvio) => {
1188
- return function extensionsdeleteMapping(untrustedConfig) {
1189
- const config = validateAdapterConfig$3(untrustedConfig, deleteMapping_ConfigPropertyNames);
1190
- // Invalid or incomplete config
1191
- if (config === null) {
1192
- throw new Error(`Invalid config for "${adapterName}"`);
1193
- }
1194
- return buildNetworkSnapshot$3(luvio, config);
1195
- };
1196
- };
1197
-
1198
- function select$6(luvio, params) {
1199
- return select$a();
1200
- }
1201
- function keyBuilder$4(luvio, params) {
1202
- return keyBuilder$8(luvio, {
1203
- id: params.urlParams.mappingId
1204
- });
1205
- }
1206
- function getResponseCacheKeys$2(luvio, resourceParams, response) {
1207
- return getTypeCacheKeys$3(luvio, response);
1208
- }
1209
- function ingestSuccess$2(luvio, resourceParams, response, snapshotRefresh) {
1210
- const { body } = response;
1211
- const key = keyBuilder$4(luvio, resourceParams);
1212
- luvio.storeIngest(key, ingest$3, body);
1213
- const snapshot = luvio.storeLookup({
1214
- recordId: key,
1215
- node: select$6(),
1216
- variables: {},
1217
- }, snapshotRefresh);
1218
- if (process.env.NODE_ENV !== 'production') {
1219
- if (snapshot.state !== 'Fulfilled') {
1220
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1221
- }
1222
- }
1223
- return snapshot;
1224
- }
1225
- function ingestError$1(luvio, params, error, snapshotRefresh) {
1226
- const key = keyBuilder$4(luvio, params);
1227
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
1228
- const storeMetadataParams = {
1229
- ttl: TTL$3,
1230
- namespace: keyPrefix,
1231
- version: VERSION$5,
1232
- representationName: RepresentationType$3
1233
- };
1234
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
1235
- return errorSnapshot;
1236
- }
1237
- function createResourceRequest$2(config) {
1238
- const headers = {};
1239
- return {
1240
- baseUri: '/services/data/v58.0',
1241
- basePath: '/commerce/extension/mappings/' + config.urlParams.mappingId + '',
1242
- method: 'get',
1243
- body: null,
1244
- urlParams: config.urlParams,
1245
- queryParams: {},
1246
- headers,
1247
- priority: 'normal',
1248
- };
1249
- }
1250
-
1251
- const getMapping_ConfigPropertyNames = {
1252
- displayName: 'getMapping',
1253
- parameters: {
1254
- required: ['mappingId'],
1255
- optional: []
1256
- }
1257
- };
1258
- function createResourceParams$2(config) {
1259
- const resourceParams = {
1260
- urlParams: {
1261
- mappingId: config.mappingId
1262
- }
1263
- };
1264
- return resourceParams;
1265
- }
1266
- function keyBuilder$3(luvio, config) {
1267
- const resourceParams = createResourceParams$2(config);
1268
- return keyBuilder$4(luvio, resourceParams);
1269
- }
1270
- function typeCheckConfig$2(untrustedConfig) {
1271
- const config = {};
1272
- const untrustedConfig_mappingId = untrustedConfig.mappingId;
1273
- if (typeof untrustedConfig_mappingId === 'string') {
1274
- config.mappingId = untrustedConfig_mappingId;
1275
- }
1276
- return config;
1277
- }
1278
- function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
1279
- if (!untrustedIsObject(untrustedConfig)) {
1280
- return null;
1281
- }
1282
- if (process.env.NODE_ENV !== 'production') {
1283
- validateConfig(untrustedConfig, configPropertyNames);
1284
- }
1285
- const config = typeCheckConfig$2(untrustedConfig);
1286
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
1287
- return null;
1288
- }
1289
- return config;
1290
- }
1291
- function adapterFragment$1(luvio, config) {
1292
- createResourceParams$2(config);
1293
- return select$6();
1294
- }
1295
- function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
1296
- const snapshot = ingestSuccess$2(luvio, resourceParams, response, {
1297
- config,
1298
- resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
1299
- });
1300
- return luvio.storeBroadcast().then(() => snapshot);
1301
- }
1302
- function onFetchResponseError$1(luvio, config, resourceParams, response) {
1303
- const snapshot = ingestError$1(luvio, resourceParams, response, {
1304
- config,
1305
- resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
1306
- });
1307
- return luvio.storeBroadcast().then(() => snapshot);
1308
- }
1309
- function buildNetworkSnapshot$2(luvio, config, options) {
1310
- const resourceParams = createResourceParams$2(config);
1311
- const request = createResourceRequest$2(resourceParams);
1312
- return luvio.dispatchResourceRequest(request, options)
1313
- .then((response) => {
1314
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => getResponseCacheKeys$2(luvio, resourceParams, response.body));
1315
- }, (response) => {
1316
- return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
1317
- });
1318
- }
1319
- function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
1320
- const { luvio, config } = context;
1321
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
1322
- const dispatchOptions = {
1323
- resourceRequestContext: {
1324
- requestCorrelator,
1325
- luvioRequestMethod: undefined,
1326
- },
1327
- eventObservers
1328
- };
1329
- if (networkPriority !== 'normal') {
1330
- dispatchOptions.overrides = {
1331
- priority: networkPriority
1332
- };
1333
- }
1334
- return buildNetworkSnapshot$2(luvio, config, dispatchOptions);
1335
- }
1336
- function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
1337
- const { luvio, config } = context;
1338
- const selector = {
1339
- recordId: keyBuilder$3(luvio, config),
1340
- node: adapterFragment$1(luvio, config),
1341
- variables: {},
1342
- };
1343
- const cacheSnapshot = storeLookup(selector, {
1344
- config,
1345
- resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
1346
- });
1347
- return cacheSnapshot;
1348
- }
1349
- const getMappingAdapterFactory = (luvio) => function extensions__getMapping(untrustedConfig, requestContext) {
1350
- const config = validateAdapterConfig$2(untrustedConfig, getMapping_ConfigPropertyNames);
1351
- // Invalid or incomplete config
1352
- if (config === null) {
1353
- return null;
1354
- }
1355
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
1356
- buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
1357
- };
1358
-
1359
- function select$5(luvio, params) {
1360
- return select$a();
1361
- }
1362
- function getResponseCacheKeys$1(luvio, resourceParams, response) {
1363
- return getTypeCacheKeys$3(luvio, response);
1364
- }
1365
- function ingestSuccess$1(luvio, resourceParams, response) {
1366
- const { body } = response;
1367
- const key = keyBuilderFromType$1(luvio, body);
1368
- luvio.storeIngest(key, ingest$3, body);
1369
- const snapshot = luvio.storeLookup({
1370
- recordId: key,
1371
- node: select$5(),
1372
- variables: {},
1373
- });
1374
- if (process.env.NODE_ENV !== 'production') {
1375
- if (snapshot.state !== 'Fulfilled') {
1376
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1377
- }
1378
- }
1379
- return snapshot;
1380
- }
1381
- function createResourceRequest$1(config) {
1382
- const headers = {};
1383
- return {
1384
- baseUri: '/services/data/v58.0',
1385
- basePath: '/commerce/extension/mappings/' + config.urlParams.mappingId + '',
1386
- method: 'put',
1387
- body: config.body,
1388
- urlParams: config.urlParams,
1389
- queryParams: {},
1390
- headers,
1391
- priority: 'normal',
1392
- };
1393
- }
1394
-
1395
- const updateMapping_ConfigPropertyNames = {
1396
- displayName: 'updateMapping',
1397
- parameters: {
1398
- required: ['mappingId', 'epn', 'providerName', 'webstoreId'],
1399
- optional: ['id']
1400
- }
1401
- };
1402
- function createResourceParams$1(config) {
1403
- const resourceParams = {
1404
- urlParams: {
1405
- mappingId: config.mappingId
1406
- },
1407
- body: {
1408
- epn: config.epn, providerName: config.providerName, webstoreId: config.webstoreId
1409
- }
1410
- };
1411
- if (config['id'] !== undefined) {
1412
- resourceParams.body['id'] = config['id'];
1413
- }
1414
- return resourceParams;
1415
- }
1416
- function typeCheckConfig$1(untrustedConfig) {
1417
- const config = {};
1418
- const untrustedConfig_mappingId = untrustedConfig.mappingId;
1419
- if (typeof untrustedConfig_mappingId === 'string') {
1420
- config.mappingId = untrustedConfig_mappingId;
1421
- }
1422
- const untrustedConfig_epn = untrustedConfig.epn;
1423
- if (typeof untrustedConfig_epn === 'string') {
1424
- config.epn = untrustedConfig_epn;
1425
- }
1426
- const untrustedConfig_id = untrustedConfig.id;
1427
- if (typeof untrustedConfig_id === 'string') {
1428
- config.id = untrustedConfig_id;
1429
- }
1430
- const untrustedConfig_providerName = untrustedConfig.providerName;
1431
- if (typeof untrustedConfig_providerName === 'string') {
1432
- config.providerName = untrustedConfig_providerName;
1433
- }
1434
- const untrustedConfig_webstoreId = untrustedConfig.webstoreId;
1435
- if (typeof untrustedConfig_webstoreId === 'string') {
1436
- config.webstoreId = untrustedConfig_webstoreId;
1437
- }
1438
- return config;
1439
- }
1440
- function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
1441
- if (!untrustedIsObject(untrustedConfig)) {
1442
- return null;
1443
- }
1444
- if (process.env.NODE_ENV !== 'production') {
1445
- validateConfig(untrustedConfig, configPropertyNames);
1446
- }
1447
- const config = typeCheckConfig$1(untrustedConfig);
1448
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
1449
- return null;
1450
- }
1451
- return config;
1452
- }
1453
- function buildNetworkSnapshot$1(luvio, config, options) {
1454
- const resourceParams = createResourceParams$1(config);
1455
- const request = createResourceRequest$1(resourceParams);
1456
- return luvio.dispatchResourceRequest(request, options)
1457
- .then((response) => {
1458
- return luvio.handleSuccessResponse(() => {
1459
- const snapshot = ingestSuccess$1(luvio, resourceParams, response);
1460
- return luvio.storeBroadcast().then(() => snapshot);
1461
- }, () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
1462
- }, (response) => {
1463
- deepFreeze(response);
1464
- throw response;
1465
- });
1466
- }
1467
- const updateMappingAdapterFactory = (luvio) => {
1468
- return function updateMapping(untrustedConfig) {
1469
- const config = validateAdapterConfig$1(untrustedConfig, updateMapping_ConfigPropertyNames);
1470
- // Invalid or incomplete config
1471
- if (config === null) {
1472
- throw new Error('Invalid config for "updateMapping"');
1473
- }
1474
- return buildNetworkSnapshot$1(luvio, config);
1475
- };
1476
- };
1477
-
1478
- const VERSION$3 = "bed780ad418f5f02446c1b0f9d165e5d";
1479
- function validate$3(obj, path = 'ApexClassOutputRepresentation') {
1480
- const v_error = (() => {
1481
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1482
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1483
- }
1484
- const obj_classId = obj.classId;
1485
- const path_classId = path + '.classId';
1486
- if (typeof obj_classId !== 'string') {
1487
- return new TypeError('Expected "string" but received "' + typeof obj_classId + '" (at "' + path_classId + '")');
1488
- }
1489
- const obj_className = obj.className;
1490
- const path_className = path + '.className';
1491
- if (typeof obj_className !== 'string') {
1492
- return new TypeError('Expected "string" but received "' + typeof obj_className + '" (at "' + path_className + '")');
1493
- }
1494
- const obj_namespace = obj.namespace;
1495
- const path_namespace = path + '.namespace';
1496
- if (typeof obj_namespace !== 'string') {
1497
- return new TypeError('Expected "string" but received "' + typeof obj_namespace + '" (at "' + path_namespace + '")');
1498
- }
1499
- const obj_version = obj.version;
1500
- const path_version = path + '.version';
1501
- if (typeof obj_version !== 'string') {
1502
- return new TypeError('Expected "string" but received "' + typeof obj_version + '" (at "' + path_version + '")');
1503
- }
1504
- })();
1505
- return v_error === undefined ? null : v_error;
1506
- }
1507
- const select$4 = function ApexClassOutputRepresentationSelect() {
1508
- return {
1509
- kind: 'Fragment',
1510
- version: VERSION$3,
1511
- private: [],
1512
- selections: [
1513
- {
1514
- name: 'classId',
1515
- kind: 'Scalar'
1516
- },
1517
- {
1518
- name: 'className',
1519
- kind: 'Scalar'
1520
- },
1521
- {
1522
- name: 'namespace',
1523
- kind: 'Scalar'
1524
- },
1525
- {
1526
- name: 'version',
1527
- kind: 'Scalar'
1528
- }
1529
- ]
1530
- };
1531
- };
1532
- function equals$3(existing, incoming) {
1533
- const existing_classId = existing.classId;
1534
- const incoming_classId = incoming.classId;
1535
- if (!(existing_classId === incoming_classId)) {
1536
- return false;
1537
- }
1538
- const existing_className = existing.className;
1539
- const incoming_className = incoming.className;
1540
- if (!(existing_className === incoming_className)) {
1541
- return false;
1542
- }
1543
- const existing_namespace = existing.namespace;
1544
- const incoming_namespace = incoming.namespace;
1545
- if (!(existing_namespace === incoming_namespace)) {
1546
- return false;
1547
- }
1548
- const existing_version = existing.version;
1549
- const incoming_version = incoming.version;
1550
- if (!(existing_version === incoming_version)) {
1551
- return false;
1552
- }
1553
- return true;
1554
- }
1555
-
1556
- const VERSION$2 = "5d74820ea8d6cfbe4e56d4a37b7cdb77";
1557
- function validate$2(obj, path = 'EffectiveMappingRepresentation') {
1558
- const v_error = (() => {
1559
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1560
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1561
- }
1562
- const obj_webstoreId = obj.webstoreId;
1563
- const path_webstoreId = path + '.webstoreId';
1564
- if (typeof obj_webstoreId !== 'string') {
1565
- return new TypeError('Expected "string" but received "' + typeof obj_webstoreId + '" (at "' + path_webstoreId + '")');
1566
- }
1567
- })();
1568
- return v_error === undefined ? null : v_error;
1569
- }
1570
- const select$3 = function EffectiveMappingRepresentationSelect() {
1571
- return {
1572
- kind: 'Fragment',
1573
- version: VERSION$2,
1574
- private: [],
1575
- selections: [
1576
- {
1577
- name: 'webstoreId',
1578
- kind: 'Scalar'
1579
- }
1580
- ]
1581
- };
1582
- };
1583
- function equals$2(existing, incoming) {
1584
- const existing_webstoreId = existing.webstoreId;
1585
- const incoming_webstoreId = incoming.webstoreId;
1586
- if (!(existing_webstoreId === incoming_webstoreId)) {
1587
- return false;
1588
- }
1589
- return true;
1590
- }
1591
-
1592
- const TTL$1 = 60000;
1593
- const VERSION$1 = "9e92dd6efb0ca494bcd06a4ad326b6a0";
1594
- function validate$1(obj, path = 'ProviderOutputRepresentation') {
1595
- const v_error = (() => {
1596
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1597
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1598
- }
1599
- const obj_apexClass = obj.apexClass;
1600
- const path_apexClass = path + '.apexClass';
1601
- const referencepath_apexClassValidationError = validate$3(obj_apexClass, path_apexClass);
1602
- if (referencepath_apexClassValidationError !== null) {
1603
- let message = 'Object doesn\'t match ApexClassOutputRepresentation (at "' + path_apexClass + '")\n';
1604
- message += referencepath_apexClassValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1605
- return new TypeError(message);
1606
- }
1607
- const obj_effectiveMappings = obj.effectiveMappings;
1608
- const path_effectiveMappings = path + '.effectiveMappings';
1609
- if (!ArrayIsArray(obj_effectiveMappings)) {
1610
- return new TypeError('Expected "array" but received "' + typeof obj_effectiveMappings + '" (at "' + path_effectiveMappings + '")');
1611
- }
1612
- for (let i = 0; i < obj_effectiveMappings.length; i++) {
1613
- const obj_effectiveMappings_item = obj_effectiveMappings[i];
1614
- const path_effectiveMappings_item = path_effectiveMappings + '[' + i + ']';
1615
- const referencepath_effectiveMappings_itemValidationError = validate$2(obj_effectiveMappings_item, path_effectiveMappings_item);
1616
- if (referencepath_effectiveMappings_itemValidationError !== null) {
1617
- let message = 'Object doesn\'t match EffectiveMappingRepresentation (at "' + path_effectiveMappings_item + '")\n';
1618
- message += referencepath_effectiveMappings_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
1619
- return new TypeError(message);
1620
- }
1621
- }
1622
- const obj_epn = obj.epn;
1623
- const path_epn = path + '.epn';
1624
- if (typeof obj_epn !== 'string') {
1625
- return new TypeError('Expected "string" but received "' + typeof obj_epn + '" (at "' + path_epn + '")');
1626
- }
1627
- const obj_name = obj.name;
1628
- const path_name = path + '.name';
1629
- if (typeof obj_name !== 'string') {
1630
- return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
1631
- }
1632
- const obj_type = obj.type;
1633
- const path_type = path + '.type';
1634
- if (typeof obj_type !== 'string') {
1635
- return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
1636
- }
1637
- })();
1638
- return v_error === undefined ? null : v_error;
1639
- }
1640
- const RepresentationType$1 = 'ProviderOutputRepresentation';
1641
- function keyBuilder$2(luvio, config) {
1642
- return keyPrefix + '::' + RepresentationType$1 + ':' + config.name;
1643
- }
1644
- function keyBuilderFromType(luvio, object) {
1645
- const keyParams = {
1646
- name: object.name
1647
- };
1648
- return keyBuilder$2(luvio, keyParams);
1649
- }
1650
- function normalize$1(input, existing, path, luvio, store, timestamp) {
1651
- return input;
1652
- }
1653
- const select$2 = function ProviderOutputRepresentationSelect() {
1654
- const { selections: ApexClassOutputRepresentation__selections, opaque: ApexClassOutputRepresentation__opaque, } = select$4();
1655
- const { selections: EffectiveMappingRepresentation__selections, opaque: EffectiveMappingRepresentation__opaque, } = select$3();
1656
- return {
1657
- kind: 'Fragment',
1658
- version: VERSION$1,
1659
- private: [],
1660
- selections: [
1661
- {
1662
- name: 'apexClass',
1663
- kind: 'Object',
1664
- selections: ApexClassOutputRepresentation__selections
1665
- },
1666
- {
1667
- name: 'effectiveMappings',
1668
- kind: 'Object',
1669
- plural: true,
1670
- selections: EffectiveMappingRepresentation__selections
1671
- },
1672
- {
1673
- name: 'epn',
1674
- kind: 'Scalar'
1675
- },
1676
- {
1677
- name: 'name',
1678
- kind: 'Scalar'
1679
- },
1680
- {
1681
- name: 'type',
1682
- kind: 'Scalar'
1683
- }
1684
- ]
1685
- };
1686
- };
1687
- function equals$1(existing, incoming) {
1688
- const existing_epn = existing.epn;
1689
- const incoming_epn = incoming.epn;
1690
- if (!(existing_epn === incoming_epn)) {
1691
- return false;
1692
- }
1693
- const existing_name = existing.name;
1694
- const incoming_name = incoming.name;
1695
- if (!(existing_name === incoming_name)) {
1696
- return false;
1697
- }
1698
- const existing_type = existing.type;
1699
- const incoming_type = incoming.type;
1700
- if (!(existing_type === incoming_type)) {
1701
- return false;
1702
- }
1703
- const existing_apexClass = existing.apexClass;
1704
- const incoming_apexClass = incoming.apexClass;
1705
- if (!(equals$3(existing_apexClass, incoming_apexClass))) {
1706
- return false;
1707
- }
1708
- const existing_effectiveMappings = existing.effectiveMappings;
1709
- const incoming_effectiveMappings = incoming.effectiveMappings;
1710
- const equals_effectiveMappings_items = equalsArray(existing_effectiveMappings, incoming_effectiveMappings, (existing_effectiveMappings_item, incoming_effectiveMappings_item) => {
1711
- if (!(equals$2(existing_effectiveMappings_item, incoming_effectiveMappings_item))) {
1712
- return false;
1713
- }
1714
- });
1715
- if (equals_effectiveMappings_items === false) {
1716
- return false;
1717
- }
1718
- return true;
1719
- }
1720
- const ingest$1 = function ProviderOutputRepresentationIngest(input, path, luvio, store, timestamp) {
1721
- if (process.env.NODE_ENV !== 'production') {
1722
- const validateError = validate$1(input);
1723
- if (validateError !== null) {
1724
- throw validateError;
1725
- }
1726
- }
1727
- const key = keyBuilderFromType(luvio, input);
1728
- const existingRecord = store.readEntry(key);
1729
- const ttlToUse = TTL$1;
1730
- let incomingRecord = normalize$1(input, store.readEntry(key), {
1731
- fullPath: key,
1732
- parent: path.parent,
1733
- propertyName: path.propertyName,
1734
- ttl: ttlToUse
1735
- });
1736
- if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
1737
- luvio.storePublish(key, incomingRecord);
1738
- }
1739
- {
1740
- const storeMetadataParams = {
1741
- ttl: ttlToUse,
1742
- namespace: "extensions",
1743
- version: VERSION$1,
1744
- representationName: RepresentationType$1,
1745
- };
1746
- luvio.publishStoreMetadata(key, storeMetadataParams);
1747
- }
1748
- return createLink(key);
1749
- };
1750
- function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
1751
- const rootKeySet = new engine.StoreKeyMap();
1752
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1753
- const rootKey = keyBuilderFromType(luvio, input);
1754
- rootKeySet.set(rootKey, {
1755
- namespace: keyPrefix,
1756
- representationName: RepresentationType$1,
1757
- mergeable: false
1758
- });
1759
- return rootKeySet;
1760
- }
1761
-
1762
- const TTL = 60000;
1763
- const VERSION = "d9978417e0efd08a87aa592d226979e1";
1764
- function validate(obj, path = 'ProviderOutputCollectionRepresentation') {
1765
- const v_error = (() => {
1766
- if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1767
- return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1768
- }
1769
- const obj_count = obj.count;
1770
- const path_count = path + '.count';
1771
- if (typeof obj_count !== 'number' || (typeof obj_count === 'number' && Math.floor(obj_count) !== obj_count)) {
1772
- return new TypeError('Expected "integer" but received "' + typeof obj_count + '" (at "' + path_count + '")');
1773
- }
1774
- const obj_items = obj.items;
1775
- const path_items = path + '.items';
1776
- if (!ArrayIsArray(obj_items)) {
1777
- return new TypeError('Expected "array" but received "' + typeof obj_items + '" (at "' + path_items + '")');
1778
- }
1779
- for (let i = 0; i < obj_items.length; i++) {
1780
- const obj_items_item = obj_items[i];
1781
- const path_items_item = path_items + '[' + i + ']';
1782
- if (typeof obj_items_item !== 'object') {
1783
- return new TypeError('Expected "object" but received "' + typeof obj_items_item + '" (at "' + path_items_item + '")');
1784
- }
1785
- }
1786
- })();
1787
- return v_error === undefined ? null : v_error;
1788
- }
1789
- const RepresentationType = 'ProviderOutputCollectionRepresentation';
1790
- function normalize(input, existing, path, luvio, store, timestamp) {
1791
- const input_items = input.items;
1792
- const input_items_id = path.fullPath + '__items';
1793
- for (let i = 0; i < input_items.length; i++) {
1794
- const input_items_item = input_items[i];
1795
- let input_items_item_id = input_items_id + '__' + i;
1796
- input_items[i] = ingest$1(input_items_item, {
1797
- fullPath: input_items_item_id,
1798
- propertyName: i,
1799
- parent: {
1800
- data: input,
1801
- key: path.fullPath,
1802
- existing: existing,
1803
- },
1804
- ttl: path.ttl
1805
- }, luvio, store);
1806
- }
1807
- return input;
1808
- }
1809
- const select$1 = function ProviderOutputCollectionRepresentationSelect() {
1810
- return {
1811
- kind: 'Fragment',
1812
- version: VERSION,
1813
- private: [],
1814
- selections: [
1815
- {
1816
- name: 'count',
1817
- kind: 'Scalar'
1818
- },
1819
- {
1820
- name: 'items',
1821
- kind: 'Link',
1822
- plural: true,
1823
- fragment: select$2()
1824
- }
1825
- ]
1826
- };
1827
- };
1828
- function equals(existing, incoming) {
1829
- const existing_count = existing.count;
1830
- const incoming_count = incoming.count;
1831
- if (!(existing_count === incoming_count)) {
1832
- return false;
1833
- }
1834
- const existing_items = existing.items;
1835
- const incoming_items = incoming.items;
1836
- const equals_items_items = equalsArray(existing_items, incoming_items, (existing_items_item, incoming_items_item) => {
1837
- if (!(existing_items_item.__ref === incoming_items_item.__ref)) {
1838
- return false;
1839
- }
1840
- });
1841
- if (equals_items_items === false) {
1842
- return false;
1843
- }
1844
- return true;
1845
- }
1846
- const ingest = function ProviderOutputCollectionRepresentationIngest(input, path, luvio, store, timestamp) {
1847
- if (process.env.NODE_ENV !== 'production') {
1848
- const validateError = validate(input);
1849
- if (validateError !== null) {
1850
- throw validateError;
1851
- }
1852
- }
1853
- const key = path.fullPath;
1854
- const existingRecord = store.readEntry(key);
1855
- const ttlToUse = TTL;
1856
- let incomingRecord = normalize(input, store.readEntry(key), {
1857
- fullPath: key,
1858
- parent: path.parent,
1859
- propertyName: path.propertyName,
1860
- ttl: ttlToUse
1861
- }, luvio, store);
1862
- if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
1863
- luvio.storePublish(key, incomingRecord);
1864
- }
1865
- {
1866
- const storeMetadataParams = {
1867
- ttl: ttlToUse,
1868
- namespace: "extensions",
1869
- version: VERSION,
1870
- representationName: RepresentationType,
1871
- };
1872
- luvio.publishStoreMetadata(key, storeMetadataParams);
1873
- }
1874
- return createLink(key);
1875
- };
1876
- function getTypeCacheKeys(luvio, input, fullPathFactory) {
1877
- const rootKeySet = new engine.StoreKeyMap();
1878
- // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1879
- const rootKey = fullPathFactory();
1880
- rootKeySet.set(rootKey, {
1881
- namespace: keyPrefix,
1882
- representationName: RepresentationType,
1883
- mergeable: false
1884
- });
1885
- const input_items_length = input.items.length;
1886
- for (let i = 0; i < input_items_length; i++) {
1887
- rootKeySet.merge(getTypeCacheKeys$1(luvio, input.items[i]));
1888
- }
1889
- return rootKeySet;
1890
- }
1891
-
1892
- function select(luvio, params) {
1893
- return select$1();
1894
- }
1895
- function keyBuilder$1(luvio, params) {
1896
- return keyPrefix + '::ProviderOutputCollectionRepresentation:(' + 'effectiveMappingsWebstoreId:' + params.queryParams.effectiveMappingsWebstoreId + ',' + 'epn:' + params.queryParams.epn + ')';
1897
- }
1898
- function getResponseCacheKeys(luvio, resourceParams, response) {
1899
- return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
1900
- }
1901
- function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
1902
- const { body } = response;
1903
- const key = keyBuilder$1(luvio, resourceParams);
1904
- luvio.storeIngest(key, ingest, body);
1905
- const snapshot = luvio.storeLookup({
1906
- recordId: key,
1907
- node: select(),
1908
- variables: {},
1909
- }, snapshotRefresh);
1910
- if (process.env.NODE_ENV !== 'production') {
1911
- if (snapshot.state !== 'Fulfilled') {
1912
- throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1913
- }
1914
- }
1915
- return snapshot;
1916
- }
1917
- function ingestError(luvio, params, error, snapshotRefresh) {
1918
- const key = keyBuilder$1(luvio, params);
1919
- const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
1920
- const storeMetadataParams = {
1921
- ttl: TTL,
1922
- namespace: keyPrefix,
1923
- version: VERSION,
1924
- representationName: RepresentationType
1925
- };
1926
- luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
1927
- return errorSnapshot;
1928
- }
1929
- function createResourceRequest(config) {
1930
- const headers = {};
1931
- return {
1932
- baseUri: '/services/data/v58.0',
1933
- basePath: '/commerce/extension/providers',
1934
- method: 'get',
1935
- body: null,
1936
- urlParams: {},
1937
- queryParams: config.queryParams,
1938
- headers,
1939
- priority: 'normal',
1940
- };
1941
- }
1942
-
1943
- const getProviders_ConfigPropertyNames = {
1944
- displayName: 'getProviders',
1945
- parameters: {
1946
- required: [],
1947
- optional: ['effectiveMappingsWebstoreId', 'epn']
1948
- }
1949
- };
1950
- function createResourceParams(config) {
1951
- const resourceParams = {
1952
- queryParams: {
1953
- effectiveMappingsWebstoreId: config.effectiveMappingsWebstoreId, epn: config.epn
1954
- }
1955
- };
1956
- return resourceParams;
1957
- }
1958
- function keyBuilder(luvio, config) {
1959
- const resourceParams = createResourceParams(config);
1960
- return keyBuilder$1(luvio, resourceParams);
1961
- }
1962
- function typeCheckConfig(untrustedConfig) {
1963
- const config = {};
1964
- const untrustedConfig_effectiveMappingsWebstoreId = untrustedConfig.effectiveMappingsWebstoreId;
1965
- if (typeof untrustedConfig_effectiveMappingsWebstoreId === 'string') {
1966
- config.effectiveMappingsWebstoreId = untrustedConfig_effectiveMappingsWebstoreId;
1967
- }
1968
- const untrustedConfig_epn = untrustedConfig.epn;
1969
- if (typeof untrustedConfig_epn === 'string') {
1970
- config.epn = untrustedConfig_epn;
1971
- }
1972
- return config;
1973
- }
1974
- function validateAdapterConfig(untrustedConfig, configPropertyNames) {
1975
- if (!untrustedIsObject(untrustedConfig)) {
1976
- return null;
1977
- }
1978
- if (process.env.NODE_ENV !== 'production') {
1979
- validateConfig(untrustedConfig, configPropertyNames);
1980
- }
1981
- const config = typeCheckConfig(untrustedConfig);
1982
- if (!areRequiredParametersPresent(config, configPropertyNames)) {
1983
- return null;
1984
- }
1985
- return config;
1986
- }
1987
- function adapterFragment(luvio, config) {
1988
- createResourceParams(config);
1989
- return select();
1990
- }
1991
- function onFetchResponseSuccess(luvio, config, resourceParams, response) {
1992
- const snapshot = ingestSuccess(luvio, resourceParams, response, {
1993
- config,
1994
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
1995
- });
1996
- return luvio.storeBroadcast().then(() => snapshot);
1997
- }
1998
- function onFetchResponseError(luvio, config, resourceParams, response) {
1999
- const snapshot = ingestError(luvio, resourceParams, response, {
2000
- config,
2001
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
2002
- });
2003
- return luvio.storeBroadcast().then(() => snapshot);
2004
- }
2005
- function buildNetworkSnapshot(luvio, config, options) {
2006
- const resourceParams = createResourceParams(config);
2007
- const request = createResourceRequest(resourceParams);
2008
- return luvio.dispatchResourceRequest(request, options)
2009
- .then((response) => {
2010
- return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
2011
- }, (response) => {
2012
- return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
2013
- });
2014
- }
2015
- function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
2016
- const { luvio, config } = context;
2017
- const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
2018
- const dispatchOptions = {
2019
- resourceRequestContext: {
2020
- requestCorrelator,
2021
- luvioRequestMethod: undefined,
2022
- },
2023
- eventObservers
2024
- };
2025
- if (networkPriority !== 'normal') {
2026
- dispatchOptions.overrides = {
2027
- priority: networkPriority
2028
- };
2029
- }
2030
- return buildNetworkSnapshot(luvio, config, dispatchOptions);
2031
- }
2032
- function buildCachedSnapshotCachePolicy(context, storeLookup) {
2033
- const { luvio, config } = context;
2034
- const selector = {
2035
- recordId: keyBuilder(luvio, config),
2036
- node: adapterFragment(luvio, config),
2037
- variables: {},
2038
- };
2039
- const cacheSnapshot = storeLookup(selector, {
2040
- config,
2041
- resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
2042
- });
2043
- return cacheSnapshot;
2044
- }
2045
- const getProvidersAdapterFactory = (luvio) => function extensions__getProviders(untrustedConfig, requestContext) {
2046
- const config = validateAdapterConfig(untrustedConfig, getProviders_ConfigPropertyNames);
2047
- // Invalid or incomplete config
2048
- if (config === null) {
2049
- return null;
2050
- }
2051
- return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
2052
- buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
2053
- };
2054
-
2055
- exports.createMappingAdapterFactory = createMappingAdapterFactory;
2056
- exports.deleteMappingAdapterFactory = deleteMappingAdapterFactory;
2057
- exports.getExtensionsAdapterFactory = getExtensionsAdapterFactory;
2058
- exports.getMappingAdapterFactory = getMappingAdapterFactory;
2059
- exports.getMappingsAdapterFactory = getMappingsAdapterFactory;
2060
- exports.getProvidersAdapterFactory = getProvidersAdapterFactory;
2061
- exports.notifyMappingUpdateAvailableFactory = notifyUpdateAvailableFactory;
2062
- exports.updateMappingAdapterFactory = updateMappingAdapterFactory;
2063
-
2064
- Object.defineProperty(exports, '__esModule', { value: true });
2065
-
2066
- }));