@salesforce/lds-adapters-commerce-catalog 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.
- package/dist/es/es2018/commerce-catalog.js +923 -923
- package/dist/{types → es/es2018/types}/src/generated/adapters/adapter-utils.d.ts +66 -66
- package/dist/{types → es/es2018/types}/src/generated/adapters/getProduct.d.ts +34 -34
- package/dist/{types → es/es2018/types}/src/generated/adapters/getProductCategoryPath.d.ts +27 -27
- package/dist/{types → es/es2018/types}/src/generated/artifacts/main.d.ts +2 -2
- package/dist/{types → es/es2018/types}/src/generated/artifacts/sfdc.d.ts +5 -5
- package/dist/{types → es/es2018/types}/src/generated/resources/getCommerceWebstoresProductCategoriesByProductCategoryIdAndWebstoreId.d.ts +23 -23
- package/dist/{types → es/es2018/types}/src/generated/resources/getCommerceWebstoresProductCategoryPathProductCategoriesByProductCategoryIdAndWebstoreId.d.ts +16 -16
- package/dist/{types → es/es2018/types}/src/generated/resources/getCommerceWebstoresProductsByProductIdAndWebstoreId.d.ts +25 -25
- package/dist/{types → es/es2018/types}/src/generated/types/ProductCategoryDetailRepresentation.d.ts +45 -45
- package/dist/{types → es/es2018/types}/src/generated/types/ProductCategoryMediaGroupRepresentation.d.ts +42 -42
- package/dist/{types → es/es2018/types}/src/generated/types/ProductCategoryMediaRepresentation.d.ts +47 -47
- package/dist/{types → es/es2018/types}/src/generated/types/ProductCategoryPathRepresentation.d.ts +30 -30
- package/dist/{types → es/es2018/types}/src/generated/types/ProductCategoryRepresentation.d.ts +35 -35
- package/dist/{types → es/es2018/types}/src/generated/types/ProductDetailRepresentation.d.ts +50 -50
- package/dist/{types → es/es2018/types}/src/generated/types/ProductEntitlementRepresentation.d.ts +29 -29
- package/dist/{types → es/es2018/types}/src/generated/types/ProductMediaContentDocumentRepresentation.d.ts +41 -41
- package/dist/{types → es/es2018/types}/src/generated/types/ProductMediaGroupRepresentation.d.ts +42 -42
- package/dist/{types → es/es2018/types}/src/generated/types/ProductMediaRepresentation.d.ts +47 -47
- package/dist/{types → es/es2018/types}/src/generated/types/type-utils.d.ts +39 -39
- package/package.json +3 -3
- package/sfdc/index.d.ts +1 -1
- package/sfdc/index.js +951 -951
- package/dist/umd/es2018/commerce-catalog.js +0 -965
- package/dist/umd/es5/commerce-catalog.js +0 -976
|
@@ -1,965 +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.cmsCatalog = {}, 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 = 'Commerce';
|
|
56
|
-
|
|
57
|
-
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
58
|
-
const { isArray: ArrayIsArray } = Array;
|
|
59
|
-
const { stringify: JSONStringify } = JSON;
|
|
60
|
-
function createLink(ref) {
|
|
61
|
-
return {
|
|
62
|
-
__ref: engine.serializeStructuredKey(ref),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function validate$5(obj, path = 'ProductCategoryRepresentation') {
|
|
67
|
-
const v_error = (() => {
|
|
68
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
69
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
70
|
-
}
|
|
71
|
-
const obj_description = obj.description;
|
|
72
|
-
const path_description = path + '.description';
|
|
73
|
-
let obj_description_union0 = null;
|
|
74
|
-
const obj_description_union0_error = (() => {
|
|
75
|
-
if (typeof obj_description !== 'string') {
|
|
76
|
-
return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
|
|
77
|
-
}
|
|
78
|
-
})();
|
|
79
|
-
if (obj_description_union0_error != null) {
|
|
80
|
-
obj_description_union0 = obj_description_union0_error.message;
|
|
81
|
-
}
|
|
82
|
-
let obj_description_union1 = null;
|
|
83
|
-
const obj_description_union1_error = (() => {
|
|
84
|
-
if (obj_description !== null) {
|
|
85
|
-
return new TypeError('Expected "null" but received "' + typeof obj_description + '" (at "' + path_description + '")');
|
|
86
|
-
}
|
|
87
|
-
})();
|
|
88
|
-
if (obj_description_union1_error != null) {
|
|
89
|
-
obj_description_union1 = obj_description_union1_error.message;
|
|
90
|
-
}
|
|
91
|
-
if (obj_description_union0 && obj_description_union1) {
|
|
92
|
-
let message = 'Object doesn\'t match union (at "' + path_description + '")';
|
|
93
|
-
message += '\n' + obj_description_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
94
|
-
message += '\n' + obj_description_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
95
|
-
return new TypeError(message);
|
|
96
|
-
}
|
|
97
|
-
const obj_id = obj.id;
|
|
98
|
-
const path_id = path + '.id';
|
|
99
|
-
let obj_id_union0 = null;
|
|
100
|
-
const obj_id_union0_error = (() => {
|
|
101
|
-
if (typeof obj_id !== 'string') {
|
|
102
|
-
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
103
|
-
}
|
|
104
|
-
})();
|
|
105
|
-
if (obj_id_union0_error != null) {
|
|
106
|
-
obj_id_union0 = obj_id_union0_error.message;
|
|
107
|
-
}
|
|
108
|
-
let obj_id_union1 = null;
|
|
109
|
-
const obj_id_union1_error = (() => {
|
|
110
|
-
if (obj_id !== null) {
|
|
111
|
-
return new TypeError('Expected "null" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
112
|
-
}
|
|
113
|
-
})();
|
|
114
|
-
if (obj_id_union1_error != null) {
|
|
115
|
-
obj_id_union1 = obj_id_union1_error.message;
|
|
116
|
-
}
|
|
117
|
-
if (obj_id_union0 && obj_id_union1) {
|
|
118
|
-
let message = 'Object doesn\'t match union (at "' + path_id + '")';
|
|
119
|
-
message += '\n' + obj_id_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
120
|
-
message += '\n' + obj_id_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
121
|
-
return new TypeError(message);
|
|
122
|
-
}
|
|
123
|
-
const obj_name = obj.name;
|
|
124
|
-
const path_name = path + '.name';
|
|
125
|
-
if (typeof obj_name !== 'string') {
|
|
126
|
-
return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
|
|
127
|
-
}
|
|
128
|
-
})();
|
|
129
|
-
return v_error === undefined ? null : v_error;
|
|
130
|
-
}
|
|
131
|
-
function deepFreeze$5(input) {
|
|
132
|
-
ObjectFreeze(input);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const VERSION$1 = "931ade08fb09ff2c63a3cbfcd5f9a73a";
|
|
136
|
-
function validate$4(obj, path = 'ProductCategoryPathRepresentation') {
|
|
137
|
-
const v_error = (() => {
|
|
138
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
139
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
140
|
-
}
|
|
141
|
-
const obj_path = obj.path;
|
|
142
|
-
const path_path = path + '.path';
|
|
143
|
-
if (!ArrayIsArray(obj_path)) {
|
|
144
|
-
return new TypeError('Expected "array" but received "' + typeof obj_path + '" (at "' + path_path + '")');
|
|
145
|
-
}
|
|
146
|
-
for (let i = 0; i < obj_path.length; i++) {
|
|
147
|
-
const obj_path_item = obj_path[i];
|
|
148
|
-
const path_path_item = path_path + '[' + i + ']';
|
|
149
|
-
const referencepath_path_itemValidationError = validate$5(obj_path_item, path_path_item);
|
|
150
|
-
if (referencepath_path_itemValidationError !== null) {
|
|
151
|
-
let message = 'Object doesn\'t match ProductCategoryRepresentation (at "' + path_path_item + '")\n';
|
|
152
|
-
message += referencepath_path_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
153
|
-
return new TypeError(message);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
})();
|
|
157
|
-
return v_error === undefined ? null : v_error;
|
|
158
|
-
}
|
|
159
|
-
const RepresentationType$1 = 'ProductCategoryPathRepresentation';
|
|
160
|
-
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
161
|
-
return input;
|
|
162
|
-
}
|
|
163
|
-
const select$3 = function ProductCategoryPathRepresentationSelect() {
|
|
164
|
-
return {
|
|
165
|
-
kind: 'Fragment',
|
|
166
|
-
version: VERSION$1,
|
|
167
|
-
private: [],
|
|
168
|
-
opaque: true
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
function equals$1(existing, incoming) {
|
|
172
|
-
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
function deepFreeze$4(input) {
|
|
178
|
-
const input_path = input.path;
|
|
179
|
-
for (let i = 0; i < input_path.length; i++) {
|
|
180
|
-
const input_path_item = input_path[i];
|
|
181
|
-
deepFreeze$5(input_path_item);
|
|
182
|
-
}
|
|
183
|
-
ObjectFreeze(input_path);
|
|
184
|
-
ObjectFreeze(input);
|
|
185
|
-
}
|
|
186
|
-
const ingest$1 = function ProductCategoryPathRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
187
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
188
|
-
const validateError = validate$4(input);
|
|
189
|
-
if (validateError !== null) {
|
|
190
|
-
throw validateError;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const key = path.fullPath;
|
|
194
|
-
const existingRecord = store.readEntry(key);
|
|
195
|
-
const ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
|
|
196
|
-
let incomingRecord = normalize$1(input, store.readEntry(key), {
|
|
197
|
-
fullPath: key,
|
|
198
|
-
parent: path.parent,
|
|
199
|
-
propertyName: path.propertyName,
|
|
200
|
-
ttl: ttlToUse
|
|
201
|
-
});
|
|
202
|
-
deepFreeze$4(input);
|
|
203
|
-
if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
|
|
204
|
-
luvio.storePublish(key, incomingRecord);
|
|
205
|
-
}
|
|
206
|
-
if (ttlToUse !== undefined) {
|
|
207
|
-
const storeMetadataParams = {
|
|
208
|
-
ttl: ttlToUse,
|
|
209
|
-
namespace: "Commerce",
|
|
210
|
-
version: VERSION$1,
|
|
211
|
-
representationName: RepresentationType$1,
|
|
212
|
-
};
|
|
213
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
214
|
-
}
|
|
215
|
-
return createLink(key);
|
|
216
|
-
};
|
|
217
|
-
function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
|
|
218
|
-
const rootKeySet = new engine.StoreKeyMap();
|
|
219
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
220
|
-
const rootKey = fullPathFactory();
|
|
221
|
-
rootKeySet.set(rootKey, {
|
|
222
|
-
namespace: keyPrefix,
|
|
223
|
-
representationName: RepresentationType$1,
|
|
224
|
-
mergeable: false
|
|
225
|
-
});
|
|
226
|
-
return rootKeySet;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function select$2(luvio, params) {
|
|
230
|
-
return select$3();
|
|
231
|
-
}
|
|
232
|
-
function keyBuilder$3(luvio, params) {
|
|
233
|
-
return keyPrefix + '::ProductCategoryPathRepresentation:(' + 'productCategoryId:' + params.urlParams.productCategoryId + ',' + 'webstoreId:' + params.urlParams.webstoreId + ')';
|
|
234
|
-
}
|
|
235
|
-
function getResponseCacheKeys$1(luvio, resourceParams, response) {
|
|
236
|
-
return getTypeCacheKeys$1(luvio, response, () => keyBuilder$3(luvio, resourceParams));
|
|
237
|
-
}
|
|
238
|
-
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
239
|
-
const { body } = response;
|
|
240
|
-
const key = keyBuilder$3(luvio, resourceParams);
|
|
241
|
-
luvio.storeIngest(key, ingest$1, body);
|
|
242
|
-
const snapshot = luvio.storeLookup({
|
|
243
|
-
recordId: key,
|
|
244
|
-
node: select$2(),
|
|
245
|
-
variables: {},
|
|
246
|
-
}, snapshotRefresh);
|
|
247
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
248
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
249
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return snapshot;
|
|
253
|
-
}
|
|
254
|
-
function ingestError$1(luvio, params, error, snapshotRefresh) {
|
|
255
|
-
const key = keyBuilder$3(luvio, params);
|
|
256
|
-
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
257
|
-
luvio.storeIngestError(key, errorSnapshot);
|
|
258
|
-
return errorSnapshot;
|
|
259
|
-
}
|
|
260
|
-
function createResourceRequest$1(config) {
|
|
261
|
-
const headers = {};
|
|
262
|
-
return {
|
|
263
|
-
baseUri: '/services/data/v58.0',
|
|
264
|
-
basePath: '/commerce/webstores/' + config.urlParams.webstoreId + '/product-category-path/product-categories/' + config.urlParams.productCategoryId + '',
|
|
265
|
-
method: 'get',
|
|
266
|
-
body: null,
|
|
267
|
-
urlParams: config.urlParams,
|
|
268
|
-
queryParams: {},
|
|
269
|
-
headers,
|
|
270
|
-
priority: 'normal',
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const getProductCategoryPath_ConfigPropertyNames = {
|
|
275
|
-
displayName: 'getProductCategoryPath',
|
|
276
|
-
parameters: {
|
|
277
|
-
required: ['productCategoryId', 'webstoreId'],
|
|
278
|
-
optional: []
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
function createResourceParams$1(config) {
|
|
282
|
-
const resourceParams = {
|
|
283
|
-
urlParams: {
|
|
284
|
-
productCategoryId: config.productCategoryId, webstoreId: config.webstoreId
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
return resourceParams;
|
|
288
|
-
}
|
|
289
|
-
function keyBuilder$2(luvio, config) {
|
|
290
|
-
const resourceParams = createResourceParams$1(config);
|
|
291
|
-
return keyBuilder$3(luvio, resourceParams);
|
|
292
|
-
}
|
|
293
|
-
function typeCheckConfig$1(untrustedConfig) {
|
|
294
|
-
const config = {};
|
|
295
|
-
const untrustedConfig_productCategoryId = untrustedConfig.productCategoryId;
|
|
296
|
-
if (typeof untrustedConfig_productCategoryId === 'string') {
|
|
297
|
-
config.productCategoryId = untrustedConfig_productCategoryId;
|
|
298
|
-
}
|
|
299
|
-
const untrustedConfig_webstoreId = untrustedConfig.webstoreId;
|
|
300
|
-
if (typeof untrustedConfig_webstoreId === 'string') {
|
|
301
|
-
config.webstoreId = untrustedConfig_webstoreId;
|
|
302
|
-
}
|
|
303
|
-
return config;
|
|
304
|
-
}
|
|
305
|
-
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
306
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
310
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
311
|
-
}
|
|
312
|
-
const config = typeCheckConfig$1(untrustedConfig);
|
|
313
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
314
|
-
return null;
|
|
315
|
-
}
|
|
316
|
-
return config;
|
|
317
|
-
}
|
|
318
|
-
function adapterFragment$1(luvio, config) {
|
|
319
|
-
createResourceParams$1(config);
|
|
320
|
-
return select$2();
|
|
321
|
-
}
|
|
322
|
-
function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
|
|
323
|
-
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
324
|
-
config,
|
|
325
|
-
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
326
|
-
});
|
|
327
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
328
|
-
}
|
|
329
|
-
function onFetchResponseError$1(luvio, config, resourceParams, response) {
|
|
330
|
-
const snapshot = ingestError$1(luvio, resourceParams, response, {
|
|
331
|
-
config,
|
|
332
|
-
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
333
|
-
});
|
|
334
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
335
|
-
}
|
|
336
|
-
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
337
|
-
const resourceParams = createResourceParams$1(config);
|
|
338
|
-
const request = createResourceRequest$1(resourceParams);
|
|
339
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
340
|
-
.then((response) => {
|
|
341
|
-
return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
|
|
342
|
-
}, (response) => {
|
|
343
|
-
return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
|
|
347
|
-
const { luvio, config } = context;
|
|
348
|
-
const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
|
|
349
|
-
const dispatchOptions = {
|
|
350
|
-
resourceRequestContext: {
|
|
351
|
-
requestCorrelator,
|
|
352
|
-
luvioRequestMethod: undefined,
|
|
353
|
-
},
|
|
354
|
-
eventObservers
|
|
355
|
-
};
|
|
356
|
-
if (networkPriority !== 'normal') {
|
|
357
|
-
dispatchOptions.overrides = {
|
|
358
|
-
priority: networkPriority
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
return buildNetworkSnapshot$1(luvio, config, dispatchOptions);
|
|
362
|
-
}
|
|
363
|
-
function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
|
|
364
|
-
const { luvio, config } = context;
|
|
365
|
-
const selector = {
|
|
366
|
-
recordId: keyBuilder$2(luvio, config),
|
|
367
|
-
node: adapterFragment$1(luvio, config),
|
|
368
|
-
variables: {},
|
|
369
|
-
};
|
|
370
|
-
const cacheSnapshot = storeLookup(selector, {
|
|
371
|
-
config,
|
|
372
|
-
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
373
|
-
});
|
|
374
|
-
return cacheSnapshot;
|
|
375
|
-
}
|
|
376
|
-
const getProductCategoryPathAdapterFactory = (luvio) => function Commerce__getProductCategoryPath(untrustedConfig, requestContext) {
|
|
377
|
-
const config = validateAdapterConfig$1(untrustedConfig, getProductCategoryPath_ConfigPropertyNames);
|
|
378
|
-
// Invalid or incomplete config
|
|
379
|
-
if (config === null) {
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
383
|
-
buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
function validate$3(obj, path = 'ProductMediaRepresentation') {
|
|
387
|
-
const v_error = (() => {
|
|
388
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
389
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
390
|
-
}
|
|
391
|
-
const obj_alternateText = obj.alternateText;
|
|
392
|
-
const path_alternateText = path + '.alternateText';
|
|
393
|
-
let obj_alternateText_union0 = null;
|
|
394
|
-
const obj_alternateText_union0_error = (() => {
|
|
395
|
-
if (typeof obj_alternateText !== 'string') {
|
|
396
|
-
return new TypeError('Expected "string" but received "' + typeof obj_alternateText + '" (at "' + path_alternateText + '")');
|
|
397
|
-
}
|
|
398
|
-
})();
|
|
399
|
-
if (obj_alternateText_union0_error != null) {
|
|
400
|
-
obj_alternateText_union0 = obj_alternateText_union0_error.message;
|
|
401
|
-
}
|
|
402
|
-
let obj_alternateText_union1 = null;
|
|
403
|
-
const obj_alternateText_union1_error = (() => {
|
|
404
|
-
if (obj_alternateText !== null) {
|
|
405
|
-
return new TypeError('Expected "null" but received "' + typeof obj_alternateText + '" (at "' + path_alternateText + '")');
|
|
406
|
-
}
|
|
407
|
-
})();
|
|
408
|
-
if (obj_alternateText_union1_error != null) {
|
|
409
|
-
obj_alternateText_union1 = obj_alternateText_union1_error.message;
|
|
410
|
-
}
|
|
411
|
-
if (obj_alternateText_union0 && obj_alternateText_union1) {
|
|
412
|
-
let message = 'Object doesn\'t match union (at "' + path_alternateText + '")';
|
|
413
|
-
message += '\n' + obj_alternateText_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
414
|
-
message += '\n' + obj_alternateText_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
415
|
-
return new TypeError(message);
|
|
416
|
-
}
|
|
417
|
-
const obj_contentVersionId = obj.contentVersionId;
|
|
418
|
-
const path_contentVersionId = path + '.contentVersionId';
|
|
419
|
-
let obj_contentVersionId_union0 = null;
|
|
420
|
-
const obj_contentVersionId_union0_error = (() => {
|
|
421
|
-
if (typeof obj_contentVersionId !== 'string') {
|
|
422
|
-
return new TypeError('Expected "string" but received "' + typeof obj_contentVersionId + '" (at "' + path_contentVersionId + '")');
|
|
423
|
-
}
|
|
424
|
-
})();
|
|
425
|
-
if (obj_contentVersionId_union0_error != null) {
|
|
426
|
-
obj_contentVersionId_union0 = obj_contentVersionId_union0_error.message;
|
|
427
|
-
}
|
|
428
|
-
let obj_contentVersionId_union1 = null;
|
|
429
|
-
const obj_contentVersionId_union1_error = (() => {
|
|
430
|
-
if (obj_contentVersionId !== null) {
|
|
431
|
-
return new TypeError('Expected "null" but received "' + typeof obj_contentVersionId + '" (at "' + path_contentVersionId + '")');
|
|
432
|
-
}
|
|
433
|
-
})();
|
|
434
|
-
if (obj_contentVersionId_union1_error != null) {
|
|
435
|
-
obj_contentVersionId_union1 = obj_contentVersionId_union1_error.message;
|
|
436
|
-
}
|
|
437
|
-
if (obj_contentVersionId_union0 && obj_contentVersionId_union1) {
|
|
438
|
-
let message = 'Object doesn\'t match union (at "' + path_contentVersionId + '")';
|
|
439
|
-
message += '\n' + obj_contentVersionId_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
440
|
-
message += '\n' + obj_contentVersionId_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
441
|
-
return new TypeError(message);
|
|
442
|
-
}
|
|
443
|
-
const obj_id = obj.id;
|
|
444
|
-
const path_id = path + '.id';
|
|
445
|
-
let obj_id_union0 = null;
|
|
446
|
-
const obj_id_union0_error = (() => {
|
|
447
|
-
if (typeof obj_id !== 'string') {
|
|
448
|
-
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
449
|
-
}
|
|
450
|
-
})();
|
|
451
|
-
if (obj_id_union0_error != null) {
|
|
452
|
-
obj_id_union0 = obj_id_union0_error.message;
|
|
453
|
-
}
|
|
454
|
-
let obj_id_union1 = null;
|
|
455
|
-
const obj_id_union1_error = (() => {
|
|
456
|
-
if (obj_id !== null) {
|
|
457
|
-
return new TypeError('Expected "null" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
458
|
-
}
|
|
459
|
-
})();
|
|
460
|
-
if (obj_id_union1_error != null) {
|
|
461
|
-
obj_id_union1 = obj_id_union1_error.message;
|
|
462
|
-
}
|
|
463
|
-
if (obj_id_union0 && obj_id_union1) {
|
|
464
|
-
let message = 'Object doesn\'t match union (at "' + path_id + '")';
|
|
465
|
-
message += '\n' + obj_id_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
466
|
-
message += '\n' + obj_id_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
467
|
-
return new TypeError(message);
|
|
468
|
-
}
|
|
469
|
-
const obj_mediaType = obj.mediaType;
|
|
470
|
-
const path_mediaType = path + '.mediaType';
|
|
471
|
-
if (typeof obj_mediaType !== 'string') {
|
|
472
|
-
return new TypeError('Expected "string" but received "' + typeof obj_mediaType + '" (at "' + path_mediaType + '")');
|
|
473
|
-
}
|
|
474
|
-
const obj_sortOrder = obj.sortOrder;
|
|
475
|
-
const path_sortOrder = path + '.sortOrder';
|
|
476
|
-
if (typeof obj_sortOrder !== 'number' || (typeof obj_sortOrder === 'number' && Math.floor(obj_sortOrder) !== obj_sortOrder)) {
|
|
477
|
-
return new TypeError('Expected "integer" but received "' + typeof obj_sortOrder + '" (at "' + path_sortOrder + '")');
|
|
478
|
-
}
|
|
479
|
-
const obj_title = obj.title;
|
|
480
|
-
const path_title = path + '.title';
|
|
481
|
-
if (typeof obj_title !== 'string') {
|
|
482
|
-
return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
|
|
483
|
-
}
|
|
484
|
-
const obj_url = obj.url;
|
|
485
|
-
const path_url = path + '.url';
|
|
486
|
-
if (typeof obj_url !== 'string') {
|
|
487
|
-
return new TypeError('Expected "string" but received "' + typeof obj_url + '" (at "' + path_url + '")');
|
|
488
|
-
}
|
|
489
|
-
})();
|
|
490
|
-
return v_error === undefined ? null : v_error;
|
|
491
|
-
}
|
|
492
|
-
function deepFreeze$3(input) {
|
|
493
|
-
ObjectFreeze(input);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
function validate$2(obj, path = 'ProductEntitlementRepresentation') {
|
|
497
|
-
const v_error = (() => {
|
|
498
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
499
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
500
|
-
}
|
|
501
|
-
const obj_canViewPrice = obj.canViewPrice;
|
|
502
|
-
const path_canViewPrice = path + '.canViewPrice';
|
|
503
|
-
let obj_canViewPrice_union0 = null;
|
|
504
|
-
const obj_canViewPrice_union0_error = (() => {
|
|
505
|
-
if (typeof obj_canViewPrice !== 'boolean') {
|
|
506
|
-
return new TypeError('Expected "boolean" but received "' + typeof obj_canViewPrice + '" (at "' + path_canViewPrice + '")');
|
|
507
|
-
}
|
|
508
|
-
})();
|
|
509
|
-
if (obj_canViewPrice_union0_error != null) {
|
|
510
|
-
obj_canViewPrice_union0 = obj_canViewPrice_union0_error.message;
|
|
511
|
-
}
|
|
512
|
-
let obj_canViewPrice_union1 = null;
|
|
513
|
-
const obj_canViewPrice_union1_error = (() => {
|
|
514
|
-
if (obj_canViewPrice !== null) {
|
|
515
|
-
return new TypeError('Expected "null" but received "' + typeof obj_canViewPrice + '" (at "' + path_canViewPrice + '")');
|
|
516
|
-
}
|
|
517
|
-
})();
|
|
518
|
-
if (obj_canViewPrice_union1_error != null) {
|
|
519
|
-
obj_canViewPrice_union1 = obj_canViewPrice_union1_error.message;
|
|
520
|
-
}
|
|
521
|
-
if (obj_canViewPrice_union0 && obj_canViewPrice_union1) {
|
|
522
|
-
let message = 'Object doesn\'t match union (at "' + path_canViewPrice + '")';
|
|
523
|
-
message += '\n' + obj_canViewPrice_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
524
|
-
message += '\n' + obj_canViewPrice_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
525
|
-
return new TypeError(message);
|
|
526
|
-
}
|
|
527
|
-
})();
|
|
528
|
-
return v_error === undefined ? null : v_error;
|
|
529
|
-
}
|
|
530
|
-
function deepFreeze$2(input) {
|
|
531
|
-
ObjectFreeze(input);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
function validate$1(obj, path = 'ProductMediaGroupRepresentation') {
|
|
535
|
-
const v_error = (() => {
|
|
536
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
537
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
538
|
-
}
|
|
539
|
-
const obj_developerName = obj.developerName;
|
|
540
|
-
const path_developerName = path + '.developerName';
|
|
541
|
-
if (typeof obj_developerName !== 'string') {
|
|
542
|
-
return new TypeError('Expected "string" but received "' + typeof obj_developerName + '" (at "' + path_developerName + '")');
|
|
543
|
-
}
|
|
544
|
-
const obj_id = obj.id;
|
|
545
|
-
const path_id = path + '.id';
|
|
546
|
-
if (typeof obj_id !== 'string') {
|
|
547
|
-
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
548
|
-
}
|
|
549
|
-
const obj_mediaItems = obj.mediaItems;
|
|
550
|
-
const path_mediaItems = path + '.mediaItems';
|
|
551
|
-
if (!ArrayIsArray(obj_mediaItems)) {
|
|
552
|
-
return new TypeError('Expected "array" but received "' + typeof obj_mediaItems + '" (at "' + path_mediaItems + '")');
|
|
553
|
-
}
|
|
554
|
-
for (let i = 0; i < obj_mediaItems.length; i++) {
|
|
555
|
-
const obj_mediaItems_item = obj_mediaItems[i];
|
|
556
|
-
const path_mediaItems_item = path_mediaItems + '[' + i + ']';
|
|
557
|
-
const referencepath_mediaItems_itemValidationError = validate$3(obj_mediaItems_item, path_mediaItems_item);
|
|
558
|
-
if (referencepath_mediaItems_itemValidationError !== null) {
|
|
559
|
-
let message = 'Object doesn\'t match ProductMediaRepresentation (at "' + path_mediaItems_item + '")\n';
|
|
560
|
-
message += referencepath_mediaItems_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
561
|
-
return new TypeError(message);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
const obj_name = obj.name;
|
|
565
|
-
const path_name = path + '.name';
|
|
566
|
-
if (typeof obj_name !== 'string') {
|
|
567
|
-
return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
|
|
568
|
-
}
|
|
569
|
-
const obj_usageType = obj.usageType;
|
|
570
|
-
const path_usageType = path + '.usageType';
|
|
571
|
-
if (typeof obj_usageType !== 'string') {
|
|
572
|
-
return new TypeError('Expected "string" but received "' + typeof obj_usageType + '" (at "' + path_usageType + '")');
|
|
573
|
-
}
|
|
574
|
-
})();
|
|
575
|
-
return v_error === undefined ? null : v_error;
|
|
576
|
-
}
|
|
577
|
-
function deepFreeze$1(input) {
|
|
578
|
-
const input_mediaItems = input.mediaItems;
|
|
579
|
-
for (let i = 0; i < input_mediaItems.length; i++) {
|
|
580
|
-
const input_mediaItems_item = input_mediaItems[i];
|
|
581
|
-
deepFreeze$3(input_mediaItems_item);
|
|
582
|
-
}
|
|
583
|
-
ObjectFreeze(input_mediaItems);
|
|
584
|
-
ObjectFreeze(input);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
const VERSION = "aeb68d0cbb5b505d40ca2f6997bb9194";
|
|
588
|
-
function validate(obj, path = 'ProductDetailRepresentation') {
|
|
589
|
-
const v_error = (() => {
|
|
590
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
591
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
592
|
-
}
|
|
593
|
-
const obj_defaultImage = obj.defaultImage;
|
|
594
|
-
const path_defaultImage = path + '.defaultImage';
|
|
595
|
-
const referencepath_defaultImageValidationError = validate$3(obj_defaultImage, path_defaultImage);
|
|
596
|
-
if (referencepath_defaultImageValidationError !== null) {
|
|
597
|
-
let message = 'Object doesn\'t match ProductMediaRepresentation (at "' + path_defaultImage + '")\n';
|
|
598
|
-
message += referencepath_defaultImageValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
599
|
-
return new TypeError(message);
|
|
600
|
-
}
|
|
601
|
-
const obj_entitlement = obj.entitlement;
|
|
602
|
-
const path_entitlement = path + '.entitlement';
|
|
603
|
-
const referencepath_entitlementValidationError = validate$2(obj_entitlement, path_entitlement);
|
|
604
|
-
if (referencepath_entitlementValidationError !== null) {
|
|
605
|
-
let message = 'Object doesn\'t match ProductEntitlementRepresentation (at "' + path_entitlement + '")\n';
|
|
606
|
-
message += referencepath_entitlementValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
607
|
-
return new TypeError(message);
|
|
608
|
-
}
|
|
609
|
-
const obj_fields = obj.fields;
|
|
610
|
-
const path_fields = path + '.fields';
|
|
611
|
-
if (typeof obj_fields !== 'object' || ArrayIsArray(obj_fields) || obj_fields === null) {
|
|
612
|
-
return new TypeError('Expected "object" but received "' + typeof obj_fields + '" (at "' + path_fields + '")');
|
|
613
|
-
}
|
|
614
|
-
const obj_fields_keys = ObjectKeys(obj_fields);
|
|
615
|
-
for (let i = 0; i < obj_fields_keys.length; i++) {
|
|
616
|
-
const key = obj_fields_keys[i];
|
|
617
|
-
const obj_fields_prop = obj_fields[key];
|
|
618
|
-
const path_fields_prop = path_fields + '["' + key + '"]';
|
|
619
|
-
let obj_fields_prop_union0 = null;
|
|
620
|
-
const obj_fields_prop_union0_error = (() => {
|
|
621
|
-
if (typeof obj_fields_prop !== 'string') {
|
|
622
|
-
return new TypeError('Expected "string" but received "' + typeof obj_fields_prop + '" (at "' + path_fields_prop + '")');
|
|
623
|
-
}
|
|
624
|
-
})();
|
|
625
|
-
if (obj_fields_prop_union0_error != null) {
|
|
626
|
-
obj_fields_prop_union0 = obj_fields_prop_union0_error.message;
|
|
627
|
-
}
|
|
628
|
-
let obj_fields_prop_union1 = null;
|
|
629
|
-
const obj_fields_prop_union1_error = (() => {
|
|
630
|
-
if (obj_fields_prop !== null) {
|
|
631
|
-
return new TypeError('Expected "null" but received "' + typeof obj_fields_prop + '" (at "' + path_fields_prop + '")');
|
|
632
|
-
}
|
|
633
|
-
})();
|
|
634
|
-
if (obj_fields_prop_union1_error != null) {
|
|
635
|
-
obj_fields_prop_union1 = obj_fields_prop_union1_error.message;
|
|
636
|
-
}
|
|
637
|
-
if (obj_fields_prop_union0 && obj_fields_prop_union1) {
|
|
638
|
-
let message = 'Object doesn\'t match union (at "' + path_fields_prop + '")';
|
|
639
|
-
message += '\n' + obj_fields_prop_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
640
|
-
message += '\n' + obj_fields_prop_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
641
|
-
return new TypeError(message);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
const obj_id = obj.id;
|
|
645
|
-
const path_id = path + '.id';
|
|
646
|
-
if (typeof obj_id !== 'string') {
|
|
647
|
-
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
648
|
-
}
|
|
649
|
-
const obj_mediaGroups = obj.mediaGroups;
|
|
650
|
-
const path_mediaGroups = path + '.mediaGroups';
|
|
651
|
-
if (!ArrayIsArray(obj_mediaGroups)) {
|
|
652
|
-
return new TypeError('Expected "array" but received "' + typeof obj_mediaGroups + '" (at "' + path_mediaGroups + '")');
|
|
653
|
-
}
|
|
654
|
-
for (let i = 0; i < obj_mediaGroups.length; i++) {
|
|
655
|
-
const obj_mediaGroups_item = obj_mediaGroups[i];
|
|
656
|
-
const path_mediaGroups_item = path_mediaGroups + '[' + i + ']';
|
|
657
|
-
const referencepath_mediaGroups_itemValidationError = validate$1(obj_mediaGroups_item, path_mediaGroups_item);
|
|
658
|
-
if (referencepath_mediaGroups_itemValidationError !== null) {
|
|
659
|
-
let message = 'Object doesn\'t match ProductMediaGroupRepresentation (at "' + path_mediaGroups_item + '")\n';
|
|
660
|
-
message += referencepath_mediaGroups_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
661
|
-
return new TypeError(message);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
const obj_primaryProductCategoryPath = obj.primaryProductCategoryPath;
|
|
665
|
-
const path_primaryProductCategoryPath = path + '.primaryProductCategoryPath';
|
|
666
|
-
const referencepath_primaryProductCategoryPathValidationError = validate$4(obj_primaryProductCategoryPath, path_primaryProductCategoryPath);
|
|
667
|
-
if (referencepath_primaryProductCategoryPathValidationError !== null) {
|
|
668
|
-
let message = 'Object doesn\'t match ProductCategoryPathRepresentation (at "' + path_primaryProductCategoryPath + '")\n';
|
|
669
|
-
message += referencepath_primaryProductCategoryPathValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
670
|
-
return new TypeError(message);
|
|
671
|
-
}
|
|
672
|
-
})();
|
|
673
|
-
return v_error === undefined ? null : v_error;
|
|
674
|
-
}
|
|
675
|
-
const RepresentationType = 'ProductDetailRepresentation';
|
|
676
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
677
|
-
return input;
|
|
678
|
-
}
|
|
679
|
-
const select$1 = function ProductDetailRepresentationSelect() {
|
|
680
|
-
return {
|
|
681
|
-
kind: 'Fragment',
|
|
682
|
-
version: VERSION,
|
|
683
|
-
private: [],
|
|
684
|
-
opaque: true
|
|
685
|
-
};
|
|
686
|
-
};
|
|
687
|
-
function equals(existing, incoming) {
|
|
688
|
-
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
689
|
-
return false;
|
|
690
|
-
}
|
|
691
|
-
return true;
|
|
692
|
-
}
|
|
693
|
-
function deepFreeze(input) {
|
|
694
|
-
const input_defaultImage = input.defaultImage;
|
|
695
|
-
deepFreeze$3(input_defaultImage);
|
|
696
|
-
const input_entitlement = input.entitlement;
|
|
697
|
-
deepFreeze$2(input_entitlement);
|
|
698
|
-
const input_fields = input.fields;
|
|
699
|
-
const input_fields_keys = Object.keys(input_fields);
|
|
700
|
-
const input_fields_length = input_fields_keys.length;
|
|
701
|
-
for (let i = 0; i < input_fields_length; i++) {
|
|
702
|
-
input_fields_keys[i];
|
|
703
|
-
}
|
|
704
|
-
ObjectFreeze(input_fields);
|
|
705
|
-
const input_mediaGroups = input.mediaGroups;
|
|
706
|
-
for (let i = 0; i < input_mediaGroups.length; i++) {
|
|
707
|
-
const input_mediaGroups_item = input_mediaGroups[i];
|
|
708
|
-
deepFreeze$1(input_mediaGroups_item);
|
|
709
|
-
}
|
|
710
|
-
ObjectFreeze(input_mediaGroups);
|
|
711
|
-
const input_primaryProductCategoryPath = input.primaryProductCategoryPath;
|
|
712
|
-
deepFreeze$4(input_primaryProductCategoryPath);
|
|
713
|
-
ObjectFreeze(input);
|
|
714
|
-
}
|
|
715
|
-
const ingest = function ProductDetailRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
716
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
717
|
-
const validateError = validate(input);
|
|
718
|
-
if (validateError !== null) {
|
|
719
|
-
throw validateError;
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
const key = path.fullPath;
|
|
723
|
-
const existingRecord = store.readEntry(key);
|
|
724
|
-
const ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
|
|
725
|
-
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
726
|
-
fullPath: key,
|
|
727
|
-
parent: path.parent,
|
|
728
|
-
propertyName: path.propertyName,
|
|
729
|
-
ttl: ttlToUse
|
|
730
|
-
});
|
|
731
|
-
deepFreeze(input);
|
|
732
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
733
|
-
luvio.storePublish(key, incomingRecord);
|
|
734
|
-
}
|
|
735
|
-
if (ttlToUse !== undefined) {
|
|
736
|
-
const storeMetadataParams = {
|
|
737
|
-
ttl: ttlToUse,
|
|
738
|
-
namespace: "Commerce",
|
|
739
|
-
version: VERSION,
|
|
740
|
-
representationName: RepresentationType,
|
|
741
|
-
};
|
|
742
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
743
|
-
}
|
|
744
|
-
return createLink(key);
|
|
745
|
-
};
|
|
746
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
747
|
-
const rootKeySet = new engine.StoreKeyMap();
|
|
748
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
749
|
-
const rootKey = fullPathFactory();
|
|
750
|
-
rootKeySet.set(rootKey, {
|
|
751
|
-
namespace: keyPrefix,
|
|
752
|
-
representationName: RepresentationType,
|
|
753
|
-
mergeable: false
|
|
754
|
-
});
|
|
755
|
-
return rootKeySet;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
function select(luvio, params) {
|
|
759
|
-
return select$1();
|
|
760
|
-
}
|
|
761
|
-
function keyBuilder$1(luvio, params) {
|
|
762
|
-
return keyPrefix + '::ProductDetailRepresentation:(' + 'effectiveAccountId:' + params.queryParams.effectiveAccountId + ',' + 'excludeEntitlement:' + params.queryParams.excludeEntitlement + ',' + 'excludeFields:' + params.queryParams.excludeFields + ',' + 'excludeMedia:' + params.queryParams.excludeMedia + ',' + 'excludePrimaryProductCategory:' + params.queryParams.excludePrimaryProductCategory + ',' + 'fields:' + params.queryParams.fields + ',' + 'mediaGroups:' + params.queryParams.mediaGroups + ',' + 'productId:' + params.urlParams.productId + ',' + 'webstoreId:' + params.urlParams.webstoreId + ')';
|
|
763
|
-
}
|
|
764
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
765
|
-
return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
|
|
766
|
-
}
|
|
767
|
-
function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
|
|
768
|
-
const { body } = response;
|
|
769
|
-
const key = keyBuilder$1(luvio, resourceParams);
|
|
770
|
-
luvio.storeIngest(key, ingest, body);
|
|
771
|
-
const snapshot = luvio.storeLookup({
|
|
772
|
-
recordId: key,
|
|
773
|
-
node: select(),
|
|
774
|
-
variables: {},
|
|
775
|
-
}, snapshotRefresh);
|
|
776
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
777
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
778
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return snapshot;
|
|
782
|
-
}
|
|
783
|
-
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
784
|
-
const key = keyBuilder$1(luvio, params);
|
|
785
|
-
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
786
|
-
luvio.storeIngestError(key, errorSnapshot);
|
|
787
|
-
return errorSnapshot;
|
|
788
|
-
}
|
|
789
|
-
function createResourceRequest(config) {
|
|
790
|
-
const headers = {};
|
|
791
|
-
return {
|
|
792
|
-
baseUri: '/services/data/v58.0',
|
|
793
|
-
basePath: '/commerce/webstores/' + config.urlParams.webstoreId + '/products/' + config.urlParams.productId + '',
|
|
794
|
-
method: 'get',
|
|
795
|
-
body: null,
|
|
796
|
-
urlParams: config.urlParams,
|
|
797
|
-
queryParams: config.queryParams,
|
|
798
|
-
headers,
|
|
799
|
-
priority: 'normal',
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
const getProduct_ConfigPropertyNames = {
|
|
804
|
-
displayName: 'getProduct',
|
|
805
|
-
parameters: {
|
|
806
|
-
required: ['productId', 'webstoreId'],
|
|
807
|
-
optional: ['effectiveAccountId', 'excludeEntitlement', 'excludeFields', 'excludeMedia', 'excludePrimaryProductCategory', 'fields', 'mediaGroups']
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
function createResourceParams(config) {
|
|
811
|
-
const resourceParams = {
|
|
812
|
-
urlParams: {
|
|
813
|
-
productId: config.productId, webstoreId: config.webstoreId
|
|
814
|
-
},
|
|
815
|
-
queryParams: {
|
|
816
|
-
effectiveAccountId: config.effectiveAccountId, excludeEntitlement: config.excludeEntitlement, excludeFields: config.excludeFields, excludeMedia: config.excludeMedia, excludePrimaryProductCategory: config.excludePrimaryProductCategory, fields: config.fields, mediaGroups: config.mediaGroups
|
|
817
|
-
}
|
|
818
|
-
};
|
|
819
|
-
return resourceParams;
|
|
820
|
-
}
|
|
821
|
-
function keyBuilder(luvio, config) {
|
|
822
|
-
const resourceParams = createResourceParams(config);
|
|
823
|
-
return keyBuilder$1(luvio, resourceParams);
|
|
824
|
-
}
|
|
825
|
-
function typeCheckConfig(untrustedConfig) {
|
|
826
|
-
const config = {};
|
|
827
|
-
const untrustedConfig_productId = untrustedConfig.productId;
|
|
828
|
-
if (typeof untrustedConfig_productId === 'string') {
|
|
829
|
-
config.productId = untrustedConfig_productId;
|
|
830
|
-
}
|
|
831
|
-
const untrustedConfig_webstoreId = untrustedConfig.webstoreId;
|
|
832
|
-
if (typeof untrustedConfig_webstoreId === 'string') {
|
|
833
|
-
config.webstoreId = untrustedConfig_webstoreId;
|
|
834
|
-
}
|
|
835
|
-
const untrustedConfig_effectiveAccountId = untrustedConfig.effectiveAccountId;
|
|
836
|
-
if (typeof untrustedConfig_effectiveAccountId === 'string') {
|
|
837
|
-
config.effectiveAccountId = untrustedConfig_effectiveAccountId;
|
|
838
|
-
}
|
|
839
|
-
const untrustedConfig_excludeEntitlement = untrustedConfig.excludeEntitlement;
|
|
840
|
-
if (typeof untrustedConfig_excludeEntitlement === 'boolean') {
|
|
841
|
-
config.excludeEntitlement = untrustedConfig_excludeEntitlement;
|
|
842
|
-
}
|
|
843
|
-
const untrustedConfig_excludeFields = untrustedConfig.excludeFields;
|
|
844
|
-
if (typeof untrustedConfig_excludeFields === 'boolean') {
|
|
845
|
-
config.excludeFields = untrustedConfig_excludeFields;
|
|
846
|
-
}
|
|
847
|
-
const untrustedConfig_excludeMedia = untrustedConfig.excludeMedia;
|
|
848
|
-
if (typeof untrustedConfig_excludeMedia === 'boolean') {
|
|
849
|
-
config.excludeMedia = untrustedConfig_excludeMedia;
|
|
850
|
-
}
|
|
851
|
-
const untrustedConfig_excludePrimaryProductCategory = untrustedConfig.excludePrimaryProductCategory;
|
|
852
|
-
if (typeof untrustedConfig_excludePrimaryProductCategory === 'boolean') {
|
|
853
|
-
config.excludePrimaryProductCategory = untrustedConfig_excludePrimaryProductCategory;
|
|
854
|
-
}
|
|
855
|
-
const untrustedConfig_fields = untrustedConfig.fields;
|
|
856
|
-
if (ArrayIsArray$1(untrustedConfig_fields)) {
|
|
857
|
-
const untrustedConfig_fields_array = [];
|
|
858
|
-
for (let i = 0, arrayLength = untrustedConfig_fields.length; i < arrayLength; i++) {
|
|
859
|
-
const untrustedConfig_fields_item = untrustedConfig_fields[i];
|
|
860
|
-
if (typeof untrustedConfig_fields_item === 'string') {
|
|
861
|
-
untrustedConfig_fields_array.push(untrustedConfig_fields_item);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
config.fields = untrustedConfig_fields_array;
|
|
865
|
-
}
|
|
866
|
-
const untrustedConfig_mediaGroups = untrustedConfig.mediaGroups;
|
|
867
|
-
if (ArrayIsArray$1(untrustedConfig_mediaGroups)) {
|
|
868
|
-
const untrustedConfig_mediaGroups_array = [];
|
|
869
|
-
for (let i = 0, arrayLength = untrustedConfig_mediaGroups.length; i < arrayLength; i++) {
|
|
870
|
-
const untrustedConfig_mediaGroups_item = untrustedConfig_mediaGroups[i];
|
|
871
|
-
if (typeof untrustedConfig_mediaGroups_item === 'string') {
|
|
872
|
-
untrustedConfig_mediaGroups_array.push(untrustedConfig_mediaGroups_item);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
config.mediaGroups = untrustedConfig_mediaGroups_array;
|
|
876
|
-
}
|
|
877
|
-
return config;
|
|
878
|
-
}
|
|
879
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
880
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
881
|
-
return null;
|
|
882
|
-
}
|
|
883
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
884
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
885
|
-
}
|
|
886
|
-
const config = typeCheckConfig(untrustedConfig);
|
|
887
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
888
|
-
return null;
|
|
889
|
-
}
|
|
890
|
-
return config;
|
|
891
|
-
}
|
|
892
|
-
function adapterFragment(luvio, config) {
|
|
893
|
-
createResourceParams(config);
|
|
894
|
-
return select();
|
|
895
|
-
}
|
|
896
|
-
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
897
|
-
const snapshot = ingestSuccess(luvio, resourceParams, response, {
|
|
898
|
-
config,
|
|
899
|
-
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
900
|
-
});
|
|
901
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
902
|
-
}
|
|
903
|
-
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
904
|
-
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
905
|
-
config,
|
|
906
|
-
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
907
|
-
});
|
|
908
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
909
|
-
}
|
|
910
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
911
|
-
const resourceParams = createResourceParams(config);
|
|
912
|
-
const request = createResourceRequest(resourceParams);
|
|
913
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
914
|
-
.then((response) => {
|
|
915
|
-
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
916
|
-
}, (response) => {
|
|
917
|
-
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
921
|
-
const { luvio, config } = context;
|
|
922
|
-
const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
|
|
923
|
-
const dispatchOptions = {
|
|
924
|
-
resourceRequestContext: {
|
|
925
|
-
requestCorrelator,
|
|
926
|
-
luvioRequestMethod: undefined,
|
|
927
|
-
},
|
|
928
|
-
eventObservers
|
|
929
|
-
};
|
|
930
|
-
if (networkPriority !== 'normal') {
|
|
931
|
-
dispatchOptions.overrides = {
|
|
932
|
-
priority: networkPriority
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
return buildNetworkSnapshot(luvio, config, dispatchOptions);
|
|
936
|
-
}
|
|
937
|
-
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
938
|
-
const { luvio, config } = context;
|
|
939
|
-
const selector = {
|
|
940
|
-
recordId: keyBuilder(luvio, config),
|
|
941
|
-
node: adapterFragment(luvio, config),
|
|
942
|
-
variables: {},
|
|
943
|
-
};
|
|
944
|
-
const cacheSnapshot = storeLookup(selector, {
|
|
945
|
-
config,
|
|
946
|
-
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
947
|
-
});
|
|
948
|
-
return cacheSnapshot;
|
|
949
|
-
}
|
|
950
|
-
const getProductAdapterFactory = (luvio) => function Commerce__getProduct(untrustedConfig, requestContext) {
|
|
951
|
-
const config = validateAdapterConfig(untrustedConfig, getProduct_ConfigPropertyNames);
|
|
952
|
-
// Invalid or incomplete config
|
|
953
|
-
if (config === null) {
|
|
954
|
-
return null;
|
|
955
|
-
}
|
|
956
|
-
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
957
|
-
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
exports.getProductAdapterFactory = getProductAdapterFactory;
|
|
961
|
-
exports.getProductCategoryPathAdapterFactory = getProductCategoryPathAdapterFactory;
|
|
962
|
-
|
|
963
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
964
|
-
|
|
965
|
-
}));
|