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