@salesforce/lds-adapters-commerce-store-pricing 1.100.2
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/LICENSE.txt +82 -0
- package/dist/es/es2018/commerce-store-pricing.js +432 -0
- package/dist/types/src/generated/adapters/adapter-utils.d.ts +66 -0
- package/dist/types/src/generated/adapters/getProductPrice.d.ts +28 -0
- package/dist/types/src/generated/artifacts/main.d.ts +1 -0
- package/dist/types/src/generated/artifacts/sfdc.d.ts +3 -0
- package/dist/types/src/generated/resources/getCommerceWebstoresPricingProductsByProductIdAndWebstoreId.d.ts +19 -0
- package/dist/types/src/generated/resources/postCommerceWebstoresPricingProductsByWebstoreId.d.ts +18 -0
- package/dist/types/src/generated/types/PriceAdjustmentScheduleRepresentation.d.ts +33 -0
- package/dist/types/src/generated/types/PriceAdjustmentTierRepresentation.d.ts +44 -0
- package/dist/types/src/generated/types/PricingInputRepresentation.d.ts +29 -0
- package/dist/types/src/generated/types/PricingLineItemInputRepresentation.d.ts +29 -0
- package/dist/types/src/generated/types/PricingLineItemInputRepresentationList.d.ts +29 -0
- package/dist/types/src/generated/types/PricingResultLineItemRepresentation.d.ts +41 -0
- package/dist/types/src/generated/types/PricingResultRepresentation.d.ts +36 -0
- package/dist/types/src/generated/types/ProductPriceRepresentation.d.ts +42 -0
- package/dist/types/src/generated/types/type-utils.d.ts +39 -0
- package/dist/umd/es2018/commerce-store-pricing.js +440 -0
- package/dist/umd/es5/commerce-store-pricing.js +443 -0
- package/package.json +52 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +464 -0
- package/src/raml/api.raml +196 -0
- package/src/raml/luvio.raml +16 -0
|
@@ -0,0 +1,443 @@
|
|
|
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.commerceStorePricing = {}, global.engine));
|
|
11
|
+
})(this, (function (exports, engine) { 'use strict';
|
|
12
|
+
|
|
13
|
+
var ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty;
|
|
14
|
+
var ObjectKeys = 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(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;
|
|
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$2(obj, path) {
|
|
67
|
+
if (path === void 0) { path = 'PriceAdjustmentTierRepresentation'; }
|
|
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_adjustmentType = obj.adjustmentType;
|
|
73
|
+
var path_adjustmentType = path + '.adjustmentType';
|
|
74
|
+
if (typeof obj_adjustmentType !== 'string') {
|
|
75
|
+
return new TypeError('Expected "string" but received "' + typeof obj_adjustmentType + '" (at "' + path_adjustmentType + '")');
|
|
76
|
+
}
|
|
77
|
+
var obj_adjustmentValue = obj.adjustmentValue;
|
|
78
|
+
var path_adjustmentValue = path + '.adjustmentValue';
|
|
79
|
+
if (typeof obj_adjustmentValue !== 'string') {
|
|
80
|
+
return new TypeError('Expected "string" but received "' + typeof obj_adjustmentValue + '" (at "' + path_adjustmentValue + '")');
|
|
81
|
+
}
|
|
82
|
+
var obj_id = obj.id;
|
|
83
|
+
var path_id = path + '.id';
|
|
84
|
+
if (typeof obj_id !== 'string') {
|
|
85
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
86
|
+
}
|
|
87
|
+
var obj_lowerBound = obj.lowerBound;
|
|
88
|
+
var path_lowerBound = path + '.lowerBound';
|
|
89
|
+
if (typeof obj_lowerBound !== 'string') {
|
|
90
|
+
return new TypeError('Expected "string" but received "' + typeof obj_lowerBound + '" (at "' + path_lowerBound + '")');
|
|
91
|
+
}
|
|
92
|
+
var obj_tierUnitPrice = obj.tierUnitPrice;
|
|
93
|
+
var path_tierUnitPrice = path + '.tierUnitPrice';
|
|
94
|
+
if (typeof obj_tierUnitPrice !== 'string') {
|
|
95
|
+
return new TypeError('Expected "string" but received "' + typeof obj_tierUnitPrice + '" (at "' + path_tierUnitPrice + '")');
|
|
96
|
+
}
|
|
97
|
+
var obj_upperBound = obj.upperBound;
|
|
98
|
+
var path_upperBound = path + '.upperBound';
|
|
99
|
+
if (typeof obj_upperBound !== 'string') {
|
|
100
|
+
return new TypeError('Expected "string" but received "' + typeof obj_upperBound + '" (at "' + path_upperBound + '")');
|
|
101
|
+
}
|
|
102
|
+
})();
|
|
103
|
+
return v_error === undefined ? null : v_error;
|
|
104
|
+
}
|
|
105
|
+
function deepFreeze$2(input) {
|
|
106
|
+
ObjectFreeze(input);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function validate$1(obj, path) {
|
|
110
|
+
if (path === void 0) { path = 'PriceAdjustmentScheduleRepresentation'; }
|
|
111
|
+
var v_error = (function () {
|
|
112
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
113
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
114
|
+
}
|
|
115
|
+
var obj_id = obj.id;
|
|
116
|
+
var path_id = path + '.id';
|
|
117
|
+
if (typeof obj_id !== 'string') {
|
|
118
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
119
|
+
}
|
|
120
|
+
var obj_priceAdjustmentTiers = obj.priceAdjustmentTiers;
|
|
121
|
+
var path_priceAdjustmentTiers = path + '.priceAdjustmentTiers';
|
|
122
|
+
if (!ArrayIsArray(obj_priceAdjustmentTiers)) {
|
|
123
|
+
return new TypeError('Expected "array" but received "' + typeof obj_priceAdjustmentTiers + '" (at "' + path_priceAdjustmentTiers + '")');
|
|
124
|
+
}
|
|
125
|
+
for (var i = 0; i < obj_priceAdjustmentTiers.length; i++) {
|
|
126
|
+
var obj_priceAdjustmentTiers_item = obj_priceAdjustmentTiers[i];
|
|
127
|
+
var path_priceAdjustmentTiers_item = path_priceAdjustmentTiers + '[' + i + ']';
|
|
128
|
+
var referencepath_priceAdjustmentTiers_itemValidationError = validate$2(obj_priceAdjustmentTiers_item, path_priceAdjustmentTiers_item);
|
|
129
|
+
if (referencepath_priceAdjustmentTiers_itemValidationError !== null) {
|
|
130
|
+
var message = 'Object doesn\'t match PriceAdjustmentTierRepresentation (at "' + path_priceAdjustmentTiers_item + '")\n';
|
|
131
|
+
message += referencepath_priceAdjustmentTiers_itemValidationError.message.split('\n').map(function (line) { return '\t' + line; }).join('\n');
|
|
132
|
+
return new TypeError(message);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
return v_error === undefined ? null : v_error;
|
|
137
|
+
}
|
|
138
|
+
function deepFreeze$1(input) {
|
|
139
|
+
var input_priceAdjustmentTiers = input.priceAdjustmentTiers;
|
|
140
|
+
for (var i = 0; i < input_priceAdjustmentTiers.length; i++) {
|
|
141
|
+
var input_priceAdjustmentTiers_item = input_priceAdjustmentTiers[i];
|
|
142
|
+
deepFreeze$2(input_priceAdjustmentTiers_item);
|
|
143
|
+
}
|
|
144
|
+
ObjectFreeze(input_priceAdjustmentTiers);
|
|
145
|
+
ObjectFreeze(input);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var VERSION = "3e2882f4e8e38efd02e1a14114269e4c";
|
|
149
|
+
function validate(obj, path) {
|
|
150
|
+
if (path === void 0) { path = 'ProductPriceRepresentation'; }
|
|
151
|
+
var v_error = (function () {
|
|
152
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
153
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
154
|
+
}
|
|
155
|
+
var obj_currencyIsoCode = obj.currencyIsoCode;
|
|
156
|
+
var path_currencyIsoCode = path + '.currencyIsoCode';
|
|
157
|
+
if (typeof obj_currencyIsoCode !== 'string') {
|
|
158
|
+
return new TypeError('Expected "string" but received "' + typeof obj_currencyIsoCode + '" (at "' + path_currencyIsoCode + '")');
|
|
159
|
+
}
|
|
160
|
+
var obj_listPrice = obj.listPrice;
|
|
161
|
+
var path_listPrice = path + '.listPrice';
|
|
162
|
+
if (typeof obj_listPrice !== 'string') {
|
|
163
|
+
return new TypeError('Expected "string" but received "' + typeof obj_listPrice + '" (at "' + path_listPrice + '")');
|
|
164
|
+
}
|
|
165
|
+
var obj_priceAdjustment = obj.priceAdjustment;
|
|
166
|
+
var path_priceAdjustment = path + '.priceAdjustment';
|
|
167
|
+
var obj_priceAdjustment_union0 = null;
|
|
168
|
+
var obj_priceAdjustment_union0_error = (function () {
|
|
169
|
+
var referencepath_priceAdjustmentValidationError = validate$1(obj_priceAdjustment, path_priceAdjustment);
|
|
170
|
+
if (referencepath_priceAdjustmentValidationError !== null) {
|
|
171
|
+
var message = 'Object doesn\'t match PriceAdjustmentScheduleRepresentation (at "' + path_priceAdjustment + '")\n';
|
|
172
|
+
message += referencepath_priceAdjustmentValidationError.message.split('\n').map(function (line) { return '\t' + line; }).join('\n');
|
|
173
|
+
return new TypeError(message);
|
|
174
|
+
}
|
|
175
|
+
})();
|
|
176
|
+
if (obj_priceAdjustment_union0_error != null) {
|
|
177
|
+
obj_priceAdjustment_union0 = obj_priceAdjustment_union0_error.message;
|
|
178
|
+
}
|
|
179
|
+
var obj_priceAdjustment_union1 = null;
|
|
180
|
+
var obj_priceAdjustment_union1_error = (function () {
|
|
181
|
+
if (obj_priceAdjustment !== null) {
|
|
182
|
+
return new TypeError('Expected "null" but received "' + typeof obj_priceAdjustment + '" (at "' + path_priceAdjustment + '")');
|
|
183
|
+
}
|
|
184
|
+
})();
|
|
185
|
+
if (obj_priceAdjustment_union1_error != null) {
|
|
186
|
+
obj_priceAdjustment_union1 = obj_priceAdjustment_union1_error.message;
|
|
187
|
+
}
|
|
188
|
+
if (obj_priceAdjustment_union0 && obj_priceAdjustment_union1) {
|
|
189
|
+
var message = 'Object doesn\'t match union (at "' + path_priceAdjustment + '")';
|
|
190
|
+
message += '\n' + obj_priceAdjustment_union0.split('\n').map(function (line) { return '\t' + line; }).join('\n');
|
|
191
|
+
message += '\n' + obj_priceAdjustment_union1.split('\n').map(function (line) { return '\t' + line; }).join('\n');
|
|
192
|
+
return new TypeError(message);
|
|
193
|
+
}
|
|
194
|
+
var obj_pricebookEntryId = obj.pricebookEntryId;
|
|
195
|
+
var path_pricebookEntryId = path + '.pricebookEntryId';
|
|
196
|
+
if (typeof obj_pricebookEntryId !== 'string') {
|
|
197
|
+
return new TypeError('Expected "string" but received "' + typeof obj_pricebookEntryId + '" (at "' + path_pricebookEntryId + '")');
|
|
198
|
+
}
|
|
199
|
+
var obj_unitPrice = obj.unitPrice;
|
|
200
|
+
var path_unitPrice = path + '.unitPrice';
|
|
201
|
+
if (typeof obj_unitPrice !== 'string') {
|
|
202
|
+
return new TypeError('Expected "string" but received "' + typeof obj_unitPrice + '" (at "' + path_unitPrice + '")');
|
|
203
|
+
}
|
|
204
|
+
})();
|
|
205
|
+
return v_error === undefined ? null : v_error;
|
|
206
|
+
}
|
|
207
|
+
var RepresentationType = 'ProductPriceRepresentation';
|
|
208
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
209
|
+
return input;
|
|
210
|
+
}
|
|
211
|
+
var select$1 = function ProductPriceRepresentationSelect() {
|
|
212
|
+
return {
|
|
213
|
+
kind: 'Fragment',
|
|
214
|
+
version: VERSION,
|
|
215
|
+
private: [],
|
|
216
|
+
opaque: true
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
function equals(existing, incoming) {
|
|
220
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
function deepFreeze(input) {
|
|
226
|
+
var input_priceAdjustment = input.priceAdjustment;
|
|
227
|
+
if (input_priceAdjustment !== null && typeof input_priceAdjustment === 'object') {
|
|
228
|
+
deepFreeze$1(input_priceAdjustment);
|
|
229
|
+
}
|
|
230
|
+
ObjectFreeze(input);
|
|
231
|
+
}
|
|
232
|
+
var ingest = function ProductPriceRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
233
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
234
|
+
var validateError = validate(input);
|
|
235
|
+
if (validateError !== null) {
|
|
236
|
+
throw validateError;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
var key = path.fullPath;
|
|
240
|
+
var existingRecord = store.readEntry(key);
|
|
241
|
+
var ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
|
|
242
|
+
var incomingRecord = normalize(input, store.readEntry(key), {
|
|
243
|
+
fullPath: key,
|
|
244
|
+
parent: path.parent,
|
|
245
|
+
propertyName: path.propertyName,
|
|
246
|
+
ttl: ttlToUse
|
|
247
|
+
});
|
|
248
|
+
deepFreeze(input);
|
|
249
|
+
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
250
|
+
luvio.storePublish(key, incomingRecord);
|
|
251
|
+
}
|
|
252
|
+
if (ttlToUse !== undefined) {
|
|
253
|
+
var storeMetadataParams = {
|
|
254
|
+
ttl: ttlToUse,
|
|
255
|
+
namespace: "Commerce",
|
|
256
|
+
version: VERSION,
|
|
257
|
+
representationName: RepresentationType,
|
|
258
|
+
};
|
|
259
|
+
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
260
|
+
}
|
|
261
|
+
return createLink(key);
|
|
262
|
+
};
|
|
263
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
264
|
+
var rootKeySet = new engine.StoreKeyMap();
|
|
265
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
266
|
+
var rootKey = fullPathFactory();
|
|
267
|
+
rootKeySet.set(rootKey, {
|
|
268
|
+
namespace: keyPrefix,
|
|
269
|
+
representationName: RepresentationType,
|
|
270
|
+
mergeable: false
|
|
271
|
+
});
|
|
272
|
+
return rootKeySet;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function select(luvio, params) {
|
|
276
|
+
return select$1();
|
|
277
|
+
}
|
|
278
|
+
function keyBuilder$1(luvio, params) {
|
|
279
|
+
return keyPrefix + '::ProductPriceRepresentation:(' + 'effectiveAccountId:' + params.queryParams.effectiveAccountId + ',' + 'productId:' + params.urlParams.productId + ',' + 'webstoreId:' + params.urlParams.webstoreId + ')';
|
|
280
|
+
}
|
|
281
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
282
|
+
return getTypeCacheKeys(luvio, response, function () { return keyBuilder$1(luvio, resourceParams); });
|
|
283
|
+
}
|
|
284
|
+
function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
|
|
285
|
+
var body = response.body;
|
|
286
|
+
var key = keyBuilder$1(luvio, resourceParams);
|
|
287
|
+
luvio.storeIngest(key, ingest, body);
|
|
288
|
+
var snapshot = luvio.storeLookup({
|
|
289
|
+
recordId: key,
|
|
290
|
+
node: select(),
|
|
291
|
+
variables: {},
|
|
292
|
+
}, snapshotRefresh);
|
|
293
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
294
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
295
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return snapshot;
|
|
299
|
+
}
|
|
300
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
301
|
+
var key = keyBuilder$1(luvio, params);
|
|
302
|
+
var errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
303
|
+
luvio.storeIngestError(key, errorSnapshot);
|
|
304
|
+
return errorSnapshot;
|
|
305
|
+
}
|
|
306
|
+
function createResourceRequest(config) {
|
|
307
|
+
var headers = {};
|
|
308
|
+
return {
|
|
309
|
+
baseUri: '/services/data/v58.0',
|
|
310
|
+
basePath: '/commerce/webstores/' + config.urlParams.webstoreId + '/pricing/products/' + config.urlParams.productId + '',
|
|
311
|
+
method: 'get',
|
|
312
|
+
body: null,
|
|
313
|
+
urlParams: config.urlParams,
|
|
314
|
+
queryParams: config.queryParams,
|
|
315
|
+
headers: headers,
|
|
316
|
+
priority: 'normal',
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
var getProductPrice_ConfigPropertyNames = {
|
|
321
|
+
displayName: 'getProductPrice',
|
|
322
|
+
parameters: {
|
|
323
|
+
required: ['productId', 'webstoreId'],
|
|
324
|
+
optional: ['effectiveAccountId']
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
function createResourceParams(config) {
|
|
328
|
+
var resourceParams = {
|
|
329
|
+
urlParams: {
|
|
330
|
+
productId: config.productId, webstoreId: config.webstoreId
|
|
331
|
+
},
|
|
332
|
+
queryParams: {
|
|
333
|
+
effectiveAccountId: config.effectiveAccountId
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
return resourceParams;
|
|
337
|
+
}
|
|
338
|
+
function keyBuilder(luvio, config) {
|
|
339
|
+
var resourceParams = createResourceParams(config);
|
|
340
|
+
return keyBuilder$1(luvio, resourceParams);
|
|
341
|
+
}
|
|
342
|
+
function typeCheckConfig(untrustedConfig) {
|
|
343
|
+
var config = {};
|
|
344
|
+
var untrustedConfig_productId = untrustedConfig.productId;
|
|
345
|
+
if (typeof untrustedConfig_productId === 'string') {
|
|
346
|
+
config.productId = untrustedConfig_productId;
|
|
347
|
+
}
|
|
348
|
+
var untrustedConfig_webstoreId = untrustedConfig.webstoreId;
|
|
349
|
+
if (typeof untrustedConfig_webstoreId === 'string') {
|
|
350
|
+
config.webstoreId = untrustedConfig_webstoreId;
|
|
351
|
+
}
|
|
352
|
+
var untrustedConfig_effectiveAccountId = untrustedConfig.effectiveAccountId;
|
|
353
|
+
if (typeof untrustedConfig_effectiveAccountId === 'string') {
|
|
354
|
+
config.effectiveAccountId = untrustedConfig_effectiveAccountId;
|
|
355
|
+
}
|
|
356
|
+
return config;
|
|
357
|
+
}
|
|
358
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
359
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
363
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
364
|
+
}
|
|
365
|
+
var config = typeCheckConfig(untrustedConfig);
|
|
366
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
return config;
|
|
370
|
+
}
|
|
371
|
+
function adapterFragment(luvio, config) {
|
|
372
|
+
createResourceParams(config);
|
|
373
|
+
return select();
|
|
374
|
+
}
|
|
375
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
376
|
+
var snapshot = ingestSuccess(luvio, resourceParams, response, {
|
|
377
|
+
config: config,
|
|
378
|
+
resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
|
|
379
|
+
});
|
|
380
|
+
return luvio.storeBroadcast().then(function () { return snapshot; });
|
|
381
|
+
}
|
|
382
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
383
|
+
var snapshot = ingestError(luvio, resourceParams, response, {
|
|
384
|
+
config: config,
|
|
385
|
+
resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
|
|
386
|
+
});
|
|
387
|
+
return luvio.storeBroadcast().then(function () { return snapshot; });
|
|
388
|
+
}
|
|
389
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
390
|
+
var resourceParams = createResourceParams(config);
|
|
391
|
+
var request = createResourceRequest(resourceParams);
|
|
392
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
393
|
+
.then(function (response) {
|
|
394
|
+
return luvio.handleSuccessResponse(function () { return onFetchResponseSuccess(luvio, config, resourceParams, response); }, function () { return getResponseCacheKeys(luvio, resourceParams, response.body); });
|
|
395
|
+
}, function (response) {
|
|
396
|
+
return luvio.handleErrorResponse(function () { return onFetchResponseError(luvio, config, resourceParams, response); });
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
400
|
+
var luvio = context.luvio, config = context.config;
|
|
401
|
+
var networkPriority = coercedAdapterRequestContext.networkPriority, requestCorrelator = coercedAdapterRequestContext.requestCorrelator, eventObservers = coercedAdapterRequestContext.eventObservers;
|
|
402
|
+
var dispatchOptions = {
|
|
403
|
+
resourceRequestContext: {
|
|
404
|
+
requestCorrelator: requestCorrelator,
|
|
405
|
+
luvioRequestMethod: undefined,
|
|
406
|
+
},
|
|
407
|
+
eventObservers: eventObservers
|
|
408
|
+
};
|
|
409
|
+
if (networkPriority !== 'normal') {
|
|
410
|
+
dispatchOptions.overrides = {
|
|
411
|
+
priority: networkPriority
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return buildNetworkSnapshot(luvio, config, dispatchOptions);
|
|
415
|
+
}
|
|
416
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
417
|
+
var luvio = context.luvio, config = context.config;
|
|
418
|
+
var selector = {
|
|
419
|
+
recordId: keyBuilder(luvio, config),
|
|
420
|
+
node: adapterFragment(luvio, config),
|
|
421
|
+
variables: {},
|
|
422
|
+
};
|
|
423
|
+
var cacheSnapshot = storeLookup(selector, {
|
|
424
|
+
config: config,
|
|
425
|
+
resolve: function () { return buildNetworkSnapshot(luvio, config, snapshotRefreshOptions); }
|
|
426
|
+
});
|
|
427
|
+
return cacheSnapshot;
|
|
428
|
+
}
|
|
429
|
+
var getProductPriceAdapterFactory = function (luvio) { return function Commerce__getProductPrice(untrustedConfig, requestContext) {
|
|
430
|
+
var config = validateAdapterConfig(untrustedConfig, getProductPrice_ConfigPropertyNames);
|
|
431
|
+
// Invalid or incomplete config
|
|
432
|
+
if (config === null) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
return luvio.applyCachePolicy((requestContext || {}), { config: config, luvio: luvio }, // BuildSnapshotContext
|
|
436
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
437
|
+
}; };
|
|
438
|
+
|
|
439
|
+
exports.getProductPriceAdapterFactory = getProductPriceAdapterFactory;
|
|
440
|
+
|
|
441
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
442
|
+
|
|
443
|
+
}));
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/lds-adapters-commerce-store-pricing",
|
|
3
|
+
"version": "1.100.2",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
+
"description": "Wire adapters Commerce Store Pricing",
|
|
6
|
+
"main": "dist/umd/es2018/commerce-store-pricing.js",
|
|
7
|
+
"module": "dist/es/es2018/commerce-store-pricing.js",
|
|
8
|
+
"types": "dist/types/src/generated/artifacts/main.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"sfdc",
|
|
12
|
+
"src/raml/*"
|
|
13
|
+
],
|
|
14
|
+
"sfdc": {
|
|
15
|
+
"path": "forcelds/ldsAdaptersCommerceStorePricing/",
|
|
16
|
+
"namespace": "lightning",
|
|
17
|
+
"module": "commerceApi"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"clean": "rm -rf dist sfdc src/generated karma/dist",
|
|
21
|
+
"build": "yarn build:raml && yarn build:services && yarn build:karma",
|
|
22
|
+
"build:karma": "rollup --config rollup.config.karma.js",
|
|
23
|
+
"build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
|
|
24
|
+
"build:services": "rollup --config rollup.config.js",
|
|
25
|
+
"start": "karma start",
|
|
26
|
+
"test": "karma start --single-run",
|
|
27
|
+
"test:compat": "karma start --single-run --compat",
|
|
28
|
+
"release:corejar": "yarn build && ../core-build/scripts/core.js --adapter=lds-adapters-commerce-store-pricing",
|
|
29
|
+
"release:core": "../../scripts/release/core.js --adapter=lds-adapters-commerce-store-pricing"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@salesforce/lds-bindings": "^1.100.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@salesforce/lds-karma": "^1.100.2"
|
|
36
|
+
},
|
|
37
|
+
"nx": {
|
|
38
|
+
"targets": {
|
|
39
|
+
"build": {
|
|
40
|
+
"outputs": [
|
|
41
|
+
"packages/lds-adapters-commerce-store-pricing/dist",
|
|
42
|
+
"packages/lds-adapters-commerce-store-pricing/karma/dist",
|
|
43
|
+
"packages/lds-adapters-commerce-store-pricing/sfdc",
|
|
44
|
+
"packages/lds-adapters-commerce-store-pricing/src/generated"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"volta": {
|
|
50
|
+
"extends": "../../package.json"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/sfdc/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/types/src/generated/artifacts/sfdc';
|