@salesforce/lds-adapters-commerce-store-pricing 0.131.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/dist/es/es2018/commerce-store-pricing.js +432 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +66 -0
- package/dist/es/es2018/types/src/generated/adapters/getProductPrice.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +1 -0
- package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +3 -0
- package/dist/es/es2018/types/src/generated/resources/getCommerceWebstoresPricingProductsByProductIdAndWebstoreId.d.ts +19 -0
- package/dist/es/es2018/types/src/generated/resources/postCommerceWebstoresPricingProductsByWebstoreId.d.ts +18 -0
- package/dist/es/es2018/types/src/generated/types/PriceAdjustmentScheduleRepresentation.d.ts +33 -0
- package/dist/es/es2018/types/src/generated/types/PriceAdjustmentTierRepresentation.d.ts +44 -0
- package/dist/es/es2018/types/src/generated/types/PricingInputRepresentation.d.ts +29 -0
- package/dist/es/es2018/types/src/generated/types/PricingLineItemInputRepresentation.d.ts +29 -0
- package/dist/es/es2018/types/src/generated/types/PricingLineItemInputRepresentationList.d.ts +29 -0
- package/dist/es/es2018/types/src/generated/types/PricingResultLineItemRepresentation.d.ts +41 -0
- package/dist/es/es2018/types/src/generated/types/PricingResultRepresentation.d.ts +36 -0
- package/dist/es/es2018/types/src/generated/types/ProductPriceRepresentation.d.ts +42 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +39 -0
- package/package.json +53 -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
package/sfdc/index.js
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* *******************************************************************************************
|
|
8
|
+
* ATTENTION!
|
|
9
|
+
* THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
|
|
10
|
+
* If you would like to contribute to LDS, please follow the steps outlined in the git repo.
|
|
11
|
+
* Any changes made to this file in p4 will be automatically overwritten.
|
|
12
|
+
* *******************************************************************************************
|
|
13
|
+
*/
|
|
14
|
+
/* proxy-compat-disable */
|
|
15
|
+
import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
|
|
16
|
+
import { withDefaultLuvio } from 'force/ldsEngine';
|
|
17
|
+
import { serializeStructuredKey, StoreKeyMap } from 'force/luvioEngine';
|
|
18
|
+
|
|
19
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
20
|
+
const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
|
|
21
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
22
|
+
/**
|
|
23
|
+
* Validates an adapter config is well-formed.
|
|
24
|
+
* @param config The config to validate.
|
|
25
|
+
* @param adapter The adapter validation configuration.
|
|
26
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
27
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
28
|
+
*/
|
|
29
|
+
function validateConfig(config, adapter, oneOf) {
|
|
30
|
+
const { displayName } = adapter;
|
|
31
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
32
|
+
if (config === undefined ||
|
|
33
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
34
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
37
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
38
|
+
}
|
|
39
|
+
if (unsupported !== undefined &&
|
|
40
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
41
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
42
|
+
}
|
|
43
|
+
const supported = required.concat(optional);
|
|
44
|
+
if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
|
|
45
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function untrustedIsObject(untrusted) {
|
|
49
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
50
|
+
}
|
|
51
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
52
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
53
|
+
}
|
|
54
|
+
const snapshotRefreshOptions = {
|
|
55
|
+
overrides: {
|
|
56
|
+
headers: {
|
|
57
|
+
'Cache-Control': 'no-cache',
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const keyPrefix = 'Commerce';
|
|
62
|
+
|
|
63
|
+
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
64
|
+
const { isArray: ArrayIsArray } = Array;
|
|
65
|
+
const { stringify: JSONStringify } = JSON;
|
|
66
|
+
function createLink(ref) {
|
|
67
|
+
return {
|
|
68
|
+
__ref: serializeStructuredKey(ref),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function validate$2(obj, path = 'PriceAdjustmentTierRepresentation') {
|
|
73
|
+
const v_error = (() => {
|
|
74
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
75
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
76
|
+
}
|
|
77
|
+
const obj_adjustmentType = obj.adjustmentType;
|
|
78
|
+
const path_adjustmentType = path + '.adjustmentType';
|
|
79
|
+
if (typeof obj_adjustmentType !== 'string') {
|
|
80
|
+
return new TypeError('Expected "string" but received "' + typeof obj_adjustmentType + '" (at "' + path_adjustmentType + '")');
|
|
81
|
+
}
|
|
82
|
+
const obj_adjustmentValue = obj.adjustmentValue;
|
|
83
|
+
const path_adjustmentValue = path + '.adjustmentValue';
|
|
84
|
+
if (typeof obj_adjustmentValue !== 'string') {
|
|
85
|
+
return new TypeError('Expected "string" but received "' + typeof obj_adjustmentValue + '" (at "' + path_adjustmentValue + '")');
|
|
86
|
+
}
|
|
87
|
+
const obj_id = obj.id;
|
|
88
|
+
const path_id = path + '.id';
|
|
89
|
+
if (typeof obj_id !== 'string') {
|
|
90
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
91
|
+
}
|
|
92
|
+
const obj_lowerBound = obj.lowerBound;
|
|
93
|
+
const path_lowerBound = path + '.lowerBound';
|
|
94
|
+
if (typeof obj_lowerBound !== 'string') {
|
|
95
|
+
return new TypeError('Expected "string" but received "' + typeof obj_lowerBound + '" (at "' + path_lowerBound + '")');
|
|
96
|
+
}
|
|
97
|
+
const obj_tierUnitPrice = obj.tierUnitPrice;
|
|
98
|
+
const path_tierUnitPrice = path + '.tierUnitPrice';
|
|
99
|
+
if (typeof obj_tierUnitPrice !== 'string') {
|
|
100
|
+
return new TypeError('Expected "string" but received "' + typeof obj_tierUnitPrice + '" (at "' + path_tierUnitPrice + '")');
|
|
101
|
+
}
|
|
102
|
+
const obj_upperBound = obj.upperBound;
|
|
103
|
+
const path_upperBound = path + '.upperBound';
|
|
104
|
+
if (typeof obj_upperBound !== 'string') {
|
|
105
|
+
return new TypeError('Expected "string" but received "' + typeof obj_upperBound + '" (at "' + path_upperBound + '")');
|
|
106
|
+
}
|
|
107
|
+
})();
|
|
108
|
+
return v_error === undefined ? null : v_error;
|
|
109
|
+
}
|
|
110
|
+
function deepFreeze$2(input) {
|
|
111
|
+
ObjectFreeze(input);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function validate$1(obj, path = 'PriceAdjustmentScheduleRepresentation') {
|
|
115
|
+
const v_error = (() => {
|
|
116
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
117
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
118
|
+
}
|
|
119
|
+
const obj_id = obj.id;
|
|
120
|
+
const path_id = path + '.id';
|
|
121
|
+
if (typeof obj_id !== 'string') {
|
|
122
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
123
|
+
}
|
|
124
|
+
const obj_priceAdjustmentTiers = obj.priceAdjustmentTiers;
|
|
125
|
+
const path_priceAdjustmentTiers = path + '.priceAdjustmentTiers';
|
|
126
|
+
if (!ArrayIsArray(obj_priceAdjustmentTiers)) {
|
|
127
|
+
return new TypeError('Expected "array" but received "' + typeof obj_priceAdjustmentTiers + '" (at "' + path_priceAdjustmentTiers + '")');
|
|
128
|
+
}
|
|
129
|
+
for (let i = 0; i < obj_priceAdjustmentTiers.length; i++) {
|
|
130
|
+
const obj_priceAdjustmentTiers_item = obj_priceAdjustmentTiers[i];
|
|
131
|
+
const path_priceAdjustmentTiers_item = path_priceAdjustmentTiers + '[' + i + ']';
|
|
132
|
+
const referencepath_priceAdjustmentTiers_itemValidationError = validate$2(obj_priceAdjustmentTiers_item, path_priceAdjustmentTiers_item);
|
|
133
|
+
if (referencepath_priceAdjustmentTiers_itemValidationError !== null) {
|
|
134
|
+
let message = 'Object doesn\'t match PriceAdjustmentTierRepresentation (at "' + path_priceAdjustmentTiers_item + '")\n';
|
|
135
|
+
message += referencepath_priceAdjustmentTiers_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
136
|
+
return new TypeError(message);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})();
|
|
140
|
+
return v_error === undefined ? null : v_error;
|
|
141
|
+
}
|
|
142
|
+
function deepFreeze$1(input) {
|
|
143
|
+
const input_priceAdjustmentTiers = input.priceAdjustmentTiers;
|
|
144
|
+
for (let i = 0; i < input_priceAdjustmentTiers.length; i++) {
|
|
145
|
+
const input_priceAdjustmentTiers_item = input_priceAdjustmentTiers[i];
|
|
146
|
+
deepFreeze$2(input_priceAdjustmentTiers_item);
|
|
147
|
+
}
|
|
148
|
+
ObjectFreeze(input_priceAdjustmentTiers);
|
|
149
|
+
ObjectFreeze(input);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const VERSION = "3e2882f4e8e38efd02e1a14114269e4c";
|
|
153
|
+
function validate(obj, path = 'ProductPriceRepresentation') {
|
|
154
|
+
const v_error = (() => {
|
|
155
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
156
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
157
|
+
}
|
|
158
|
+
const obj_currencyIsoCode = obj.currencyIsoCode;
|
|
159
|
+
const path_currencyIsoCode = path + '.currencyIsoCode';
|
|
160
|
+
if (typeof obj_currencyIsoCode !== 'string') {
|
|
161
|
+
return new TypeError('Expected "string" but received "' + typeof obj_currencyIsoCode + '" (at "' + path_currencyIsoCode + '")');
|
|
162
|
+
}
|
|
163
|
+
const obj_listPrice = obj.listPrice;
|
|
164
|
+
const path_listPrice = path + '.listPrice';
|
|
165
|
+
if (typeof obj_listPrice !== 'string') {
|
|
166
|
+
return new TypeError('Expected "string" but received "' + typeof obj_listPrice + '" (at "' + path_listPrice + '")');
|
|
167
|
+
}
|
|
168
|
+
const obj_priceAdjustment = obj.priceAdjustment;
|
|
169
|
+
const path_priceAdjustment = path + '.priceAdjustment';
|
|
170
|
+
let obj_priceAdjustment_union0 = null;
|
|
171
|
+
const obj_priceAdjustment_union0_error = (() => {
|
|
172
|
+
const referencepath_priceAdjustmentValidationError = validate$1(obj_priceAdjustment, path_priceAdjustment);
|
|
173
|
+
if (referencepath_priceAdjustmentValidationError !== null) {
|
|
174
|
+
let message = 'Object doesn\'t match PriceAdjustmentScheduleRepresentation (at "' + path_priceAdjustment + '")\n';
|
|
175
|
+
message += referencepath_priceAdjustmentValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
176
|
+
return new TypeError(message);
|
|
177
|
+
}
|
|
178
|
+
})();
|
|
179
|
+
if (obj_priceAdjustment_union0_error != null) {
|
|
180
|
+
obj_priceAdjustment_union0 = obj_priceAdjustment_union0_error.message;
|
|
181
|
+
}
|
|
182
|
+
let obj_priceAdjustment_union1 = null;
|
|
183
|
+
const obj_priceAdjustment_union1_error = (() => {
|
|
184
|
+
if (obj_priceAdjustment !== null) {
|
|
185
|
+
return new TypeError('Expected "null" but received "' + typeof obj_priceAdjustment + '" (at "' + path_priceAdjustment + '")');
|
|
186
|
+
}
|
|
187
|
+
})();
|
|
188
|
+
if (obj_priceAdjustment_union1_error != null) {
|
|
189
|
+
obj_priceAdjustment_union1 = obj_priceAdjustment_union1_error.message;
|
|
190
|
+
}
|
|
191
|
+
if (obj_priceAdjustment_union0 && obj_priceAdjustment_union1) {
|
|
192
|
+
let message = 'Object doesn\'t match union (at "' + path_priceAdjustment + '")';
|
|
193
|
+
message += '\n' + obj_priceAdjustment_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
194
|
+
message += '\n' + obj_priceAdjustment_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
195
|
+
return new TypeError(message);
|
|
196
|
+
}
|
|
197
|
+
const obj_pricebookEntryId = obj.pricebookEntryId;
|
|
198
|
+
const path_pricebookEntryId = path + '.pricebookEntryId';
|
|
199
|
+
if (typeof obj_pricebookEntryId !== 'string') {
|
|
200
|
+
return new TypeError('Expected "string" but received "' + typeof obj_pricebookEntryId + '" (at "' + path_pricebookEntryId + '")');
|
|
201
|
+
}
|
|
202
|
+
const obj_unitPrice = obj.unitPrice;
|
|
203
|
+
const path_unitPrice = path + '.unitPrice';
|
|
204
|
+
if (typeof obj_unitPrice !== 'string') {
|
|
205
|
+
return new TypeError('Expected "string" but received "' + typeof obj_unitPrice + '" (at "' + path_unitPrice + '")');
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
return v_error === undefined ? null : v_error;
|
|
209
|
+
}
|
|
210
|
+
const RepresentationType = 'ProductPriceRepresentation';
|
|
211
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
212
|
+
return input;
|
|
213
|
+
}
|
|
214
|
+
const select$1 = function ProductPriceRepresentationSelect() {
|
|
215
|
+
return {
|
|
216
|
+
kind: 'Fragment',
|
|
217
|
+
version: VERSION,
|
|
218
|
+
private: [],
|
|
219
|
+
opaque: true
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
function equals(existing, incoming) {
|
|
223
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
function deepFreeze(input) {
|
|
229
|
+
const input_priceAdjustment = input.priceAdjustment;
|
|
230
|
+
if (input_priceAdjustment !== null && typeof input_priceAdjustment === 'object') {
|
|
231
|
+
deepFreeze$1(input_priceAdjustment);
|
|
232
|
+
}
|
|
233
|
+
ObjectFreeze(input);
|
|
234
|
+
}
|
|
235
|
+
const ingest = function ProductPriceRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
236
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
237
|
+
const validateError = validate(input);
|
|
238
|
+
if (validateError !== null) {
|
|
239
|
+
throw validateError;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const key = path.fullPath;
|
|
243
|
+
const existingRecord = store.readEntry(key);
|
|
244
|
+
const ttlToUse = path.ttl !== undefined ? path.ttl : 2592000000;
|
|
245
|
+
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
246
|
+
fullPath: key,
|
|
247
|
+
parent: path.parent,
|
|
248
|
+
propertyName: path.propertyName,
|
|
249
|
+
ttl: ttlToUse
|
|
250
|
+
});
|
|
251
|
+
deepFreeze(input);
|
|
252
|
+
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
253
|
+
luvio.storePublish(key, incomingRecord);
|
|
254
|
+
}
|
|
255
|
+
if (ttlToUse !== undefined) {
|
|
256
|
+
const storeMetadataParams = {
|
|
257
|
+
ttl: ttlToUse,
|
|
258
|
+
namespace: "Commerce",
|
|
259
|
+
version: VERSION,
|
|
260
|
+
representationName: RepresentationType,
|
|
261
|
+
};
|
|
262
|
+
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
263
|
+
}
|
|
264
|
+
return createLink(key);
|
|
265
|
+
};
|
|
266
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
267
|
+
const rootKeySet = new StoreKeyMap();
|
|
268
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
269
|
+
const rootKey = fullPathFactory();
|
|
270
|
+
rootKeySet.set(rootKey, {
|
|
271
|
+
namespace: keyPrefix,
|
|
272
|
+
representationName: RepresentationType,
|
|
273
|
+
mergeable: false
|
|
274
|
+
});
|
|
275
|
+
return rootKeySet;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function select(luvio, params) {
|
|
279
|
+
return select$1();
|
|
280
|
+
}
|
|
281
|
+
function keyBuilder$1(luvio, params) {
|
|
282
|
+
return keyPrefix + '::ProductPriceRepresentation:(' + 'effectiveAccountId:' + params.queryParams.effectiveAccountId + ',' + 'productId:' + params.urlParams.productId + ',' + 'webstoreId:' + params.urlParams.webstoreId + ')';
|
|
283
|
+
}
|
|
284
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
285
|
+
return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
|
|
286
|
+
}
|
|
287
|
+
function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
|
|
288
|
+
const { body } = response;
|
|
289
|
+
const key = keyBuilder$1(luvio, resourceParams);
|
|
290
|
+
luvio.storeIngest(key, ingest, body);
|
|
291
|
+
const snapshot = luvio.storeLookup({
|
|
292
|
+
recordId: key,
|
|
293
|
+
node: select(),
|
|
294
|
+
variables: {},
|
|
295
|
+
}, snapshotRefresh);
|
|
296
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
297
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
298
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return snapshot;
|
|
302
|
+
}
|
|
303
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
304
|
+
const key = keyBuilder$1(luvio, params);
|
|
305
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
306
|
+
luvio.storeIngestError(key, errorSnapshot);
|
|
307
|
+
return errorSnapshot;
|
|
308
|
+
}
|
|
309
|
+
function createResourceRequest(config) {
|
|
310
|
+
const headers = {};
|
|
311
|
+
return {
|
|
312
|
+
baseUri: '/services/data/v58.0',
|
|
313
|
+
basePath: '/commerce/webstores/' + config.urlParams.webstoreId + '/pricing/products/' + config.urlParams.productId + '',
|
|
314
|
+
method: 'get',
|
|
315
|
+
body: null,
|
|
316
|
+
urlParams: config.urlParams,
|
|
317
|
+
queryParams: config.queryParams,
|
|
318
|
+
headers,
|
|
319
|
+
priority: 'normal',
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const getProductPrice_ConfigPropertyNames = {
|
|
324
|
+
displayName: 'getProductPrice',
|
|
325
|
+
parameters: {
|
|
326
|
+
required: ['productId', 'webstoreId'],
|
|
327
|
+
optional: ['effectiveAccountId']
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
function createResourceParams(config) {
|
|
331
|
+
const resourceParams = {
|
|
332
|
+
urlParams: {
|
|
333
|
+
productId: config.productId, webstoreId: config.webstoreId
|
|
334
|
+
},
|
|
335
|
+
queryParams: {
|
|
336
|
+
effectiveAccountId: config.effectiveAccountId
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
return resourceParams;
|
|
340
|
+
}
|
|
341
|
+
function keyBuilder(luvio, config) {
|
|
342
|
+
const resourceParams = createResourceParams(config);
|
|
343
|
+
return keyBuilder$1(luvio, resourceParams);
|
|
344
|
+
}
|
|
345
|
+
function typeCheckConfig(untrustedConfig) {
|
|
346
|
+
const config = {};
|
|
347
|
+
const untrustedConfig_productId = untrustedConfig.productId;
|
|
348
|
+
if (typeof untrustedConfig_productId === 'string') {
|
|
349
|
+
config.productId = untrustedConfig_productId;
|
|
350
|
+
}
|
|
351
|
+
const untrustedConfig_webstoreId = untrustedConfig.webstoreId;
|
|
352
|
+
if (typeof untrustedConfig_webstoreId === 'string') {
|
|
353
|
+
config.webstoreId = untrustedConfig_webstoreId;
|
|
354
|
+
}
|
|
355
|
+
const untrustedConfig_effectiveAccountId = untrustedConfig.effectiveAccountId;
|
|
356
|
+
if (typeof untrustedConfig_effectiveAccountId === 'string') {
|
|
357
|
+
config.effectiveAccountId = untrustedConfig_effectiveAccountId;
|
|
358
|
+
}
|
|
359
|
+
return config;
|
|
360
|
+
}
|
|
361
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
362
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
366
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
367
|
+
}
|
|
368
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
369
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
return config;
|
|
373
|
+
}
|
|
374
|
+
function adapterFragment(luvio, config) {
|
|
375
|
+
createResourceParams(config);
|
|
376
|
+
return select();
|
|
377
|
+
}
|
|
378
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
379
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response, {
|
|
380
|
+
config,
|
|
381
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
382
|
+
});
|
|
383
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
384
|
+
}
|
|
385
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
386
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
387
|
+
config,
|
|
388
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
389
|
+
});
|
|
390
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
391
|
+
}
|
|
392
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
393
|
+
const resourceParams = createResourceParams(config);
|
|
394
|
+
const request = createResourceRequest(resourceParams);
|
|
395
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
396
|
+
.then((response) => {
|
|
397
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
398
|
+
}, (response) => {
|
|
399
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
403
|
+
const { luvio, config } = context;
|
|
404
|
+
const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
|
|
405
|
+
const dispatchOptions = {
|
|
406
|
+
resourceRequestContext: {
|
|
407
|
+
requestCorrelator,
|
|
408
|
+
luvioRequestMethod: undefined,
|
|
409
|
+
},
|
|
410
|
+
eventObservers
|
|
411
|
+
};
|
|
412
|
+
if (networkPriority !== 'normal') {
|
|
413
|
+
dispatchOptions.overrides = {
|
|
414
|
+
priority: networkPriority
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
return buildNetworkSnapshot(luvio, config, dispatchOptions);
|
|
418
|
+
}
|
|
419
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
420
|
+
const { luvio, config } = context;
|
|
421
|
+
const selector = {
|
|
422
|
+
recordId: keyBuilder(luvio, config),
|
|
423
|
+
node: adapterFragment(luvio, config),
|
|
424
|
+
variables: {},
|
|
425
|
+
};
|
|
426
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
427
|
+
config,
|
|
428
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
429
|
+
});
|
|
430
|
+
return cacheSnapshot;
|
|
431
|
+
}
|
|
432
|
+
const getProductPriceAdapterFactory = (luvio) => function Commerce__getProductPrice(untrustedConfig, requestContext) {
|
|
433
|
+
const config = validateAdapterConfig(untrustedConfig, getProductPrice_ConfigPropertyNames);
|
|
434
|
+
// Invalid or incomplete config
|
|
435
|
+
if (config === null) {
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
439
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
let getProductPrice;
|
|
443
|
+
// Imperative GET Adapters
|
|
444
|
+
let getProductPrice_imperative;
|
|
445
|
+
// Adapter Metadata
|
|
446
|
+
const getProductPriceMetadata = { apiFamily: 'Commerce', name: 'getProductPrice' };
|
|
447
|
+
function bindExportsTo(luvio) {
|
|
448
|
+
// LDS Adapters
|
|
449
|
+
const getProductPrice_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getProductPrice', getProductPriceAdapterFactory), getProductPriceMetadata);
|
|
450
|
+
return {
|
|
451
|
+
getProductPrice: createWireAdapterConstructor(luvio, getProductPrice_ldsAdapter, getProductPriceMetadata),
|
|
452
|
+
// Imperative GET Adapters
|
|
453
|
+
getProductPrice_imperative: createImperativeAdapter(luvio, getProductPrice_ldsAdapter, getProductPriceMetadata)
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
withDefaultLuvio((luvio) => {
|
|
457
|
+
({
|
|
458
|
+
getProductPrice,
|
|
459
|
+
getProductPrice_imperative
|
|
460
|
+
} = bindExportsTo(luvio));
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
export { getProductPrice, getProductPrice_imperative };
|
|
464
|
+
// version: 0.131.0-c1ec5b7de
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
#%RAML 1.0
|
|
2
|
+
securedBy:
|
|
3
|
+
- OAuth2
|
|
4
|
+
title: Salesforce Connect API
|
|
5
|
+
version: '52.0'
|
|
6
|
+
mediaType: application/json
|
|
7
|
+
protocols:
|
|
8
|
+
- https
|
|
9
|
+
baseUri: /services/data/v58.0
|
|
10
|
+
securitySchemes:
|
|
11
|
+
OAuth2:
|
|
12
|
+
type: OAuth 2.0
|
|
13
|
+
settings:
|
|
14
|
+
authorizationUri: https://example.com/oauth/authorize
|
|
15
|
+
accessTokenUri: ''
|
|
16
|
+
authorizationGrants:
|
|
17
|
+
- implicit
|
|
18
|
+
annotationTypes:
|
|
19
|
+
oas-readOnly:
|
|
20
|
+
type: boolean
|
|
21
|
+
allowedTargets: TypeDeclaration
|
|
22
|
+
oas-collectionFormat:
|
|
23
|
+
type: string
|
|
24
|
+
oas-body-name:
|
|
25
|
+
type: string
|
|
26
|
+
allowedTargets: TypeDeclaration
|
|
27
|
+
types:
|
|
28
|
+
PriceAdjustmentScheduleRepresentation:
|
|
29
|
+
description: Representation for the details of a single price adjustment schedule
|
|
30
|
+
type: object
|
|
31
|
+
properties:
|
|
32
|
+
id:
|
|
33
|
+
description: Represents the ID of the price adjustment schedule
|
|
34
|
+
type: string
|
|
35
|
+
priceAdjustmentTiers:
|
|
36
|
+
description: Represents the list of price adjustment tiers
|
|
37
|
+
type: array
|
|
38
|
+
items:
|
|
39
|
+
type: PriceAdjustmentTierRepresentation
|
|
40
|
+
PriceAdjustmentTierRepresentation:
|
|
41
|
+
description: Representation for the details of a single price adjustment tier
|
|
42
|
+
type: object
|
|
43
|
+
properties:
|
|
44
|
+
adjustmentType:
|
|
45
|
+
description: Represents the price adjustment type
|
|
46
|
+
type: string
|
|
47
|
+
enum:
|
|
48
|
+
- AmountBasedAdjustment
|
|
49
|
+
- PercentageBasedAdjustment
|
|
50
|
+
adjustmentValue:
|
|
51
|
+
description: Represents the adjustment value
|
|
52
|
+
type: string
|
|
53
|
+
id:
|
|
54
|
+
description: Represents the ID of the price adjustment tier
|
|
55
|
+
type: string
|
|
56
|
+
lowerBound:
|
|
57
|
+
description: Represents the lower bound of the tier
|
|
58
|
+
type: string
|
|
59
|
+
tierUnitPrice:
|
|
60
|
+
description: Represents the unit price of the tier
|
|
61
|
+
type: string
|
|
62
|
+
upperBound:
|
|
63
|
+
description: Represents the upper bound of the tier
|
|
64
|
+
type: string
|
|
65
|
+
PricingInputRepresentation:
|
|
66
|
+
description: Representation of the request for multiple products pricing
|
|
67
|
+
type: object
|
|
68
|
+
properties:
|
|
69
|
+
pricingLineItems:
|
|
70
|
+
description: The Line Items the pricing request is for
|
|
71
|
+
type: array
|
|
72
|
+
items:
|
|
73
|
+
type: object
|
|
74
|
+
PricingLineItemInputRepresentation:
|
|
75
|
+
description: Representation of the Line Item portion the request for multiple
|
|
76
|
+
products pricing
|
|
77
|
+
type: object
|
|
78
|
+
properties:
|
|
79
|
+
productId:
|
|
80
|
+
description: The product ID to be priced in the request
|
|
81
|
+
type: string
|
|
82
|
+
PricingLineItemInputRepresentationList:
|
|
83
|
+
description: Wraps a list of Pricing Line Items for Apex
|
|
84
|
+
type: object
|
|
85
|
+
properties:
|
|
86
|
+
pricingLineItemInputList:
|
|
87
|
+
description: Pricing line Items
|
|
88
|
+
type: array
|
|
89
|
+
items:
|
|
90
|
+
type: object
|
|
91
|
+
PricingResultLineItemRepresentation:
|
|
92
|
+
description: Representation of the Line Item portion of the response for multiple
|
|
93
|
+
products pricing
|
|
94
|
+
type: object
|
|
95
|
+
properties:
|
|
96
|
+
# Error Response representation did not get created
|
|
97
|
+
# error:
|
|
98
|
+
# description: Error code and error message
|
|
99
|
+
# type: ErrorResponseRepresentation
|
|
100
|
+
listPrice:
|
|
101
|
+
description: Represents the list price for the product
|
|
102
|
+
type: string
|
|
103
|
+
pricebookEntryId:
|
|
104
|
+
description: Represents the ID of the pricebook entry
|
|
105
|
+
type: string
|
|
106
|
+
productId:
|
|
107
|
+
description: Represents the product ID to be priced in the response
|
|
108
|
+
type: string
|
|
109
|
+
success:
|
|
110
|
+
description: Represents whether execution was successful
|
|
111
|
+
type: boolean
|
|
112
|
+
unitPrice:
|
|
113
|
+
description: Represents the unit price for the product
|
|
114
|
+
type: string
|
|
115
|
+
PricingResultRepresentation:
|
|
116
|
+
description: Representation for the response for multiple products pricing
|
|
117
|
+
type: object
|
|
118
|
+
properties:
|
|
119
|
+
currencyIsoCode:
|
|
120
|
+
description: Represents the currency used in the Multi Products Pricing API
|
|
121
|
+
type: string
|
|
122
|
+
# Error response representation did not get created
|
|
123
|
+
# error:
|
|
124
|
+
# description: Error code and error message
|
|
125
|
+
# type: ErrorResponseRepresentation
|
|
126
|
+
pricingLineItemResults:
|
|
127
|
+
description: Represents the Line Items of the response
|
|
128
|
+
type: array
|
|
129
|
+
items:
|
|
130
|
+
type: PricingResultLineItemRepresentation
|
|
131
|
+
success:
|
|
132
|
+
description: Represents whether execution was successful
|
|
133
|
+
type: boolean
|
|
134
|
+
ProductPriceRepresentation:
|
|
135
|
+
description: Representation for the details of a single product price
|
|
136
|
+
type: object
|
|
137
|
+
properties:
|
|
138
|
+
currencyIsoCode:
|
|
139
|
+
description: Represents the currency used in this price calculations
|
|
140
|
+
type: string
|
|
141
|
+
listPrice:
|
|
142
|
+
description: Represents the list price for the product
|
|
143
|
+
type: string
|
|
144
|
+
priceAdjustment:
|
|
145
|
+
description: Represents the price adjustment schedule
|
|
146
|
+
type: PriceAdjustmentScheduleRepresentation | nil # TODO "nil" union type hand rolled
|
|
147
|
+
pricebookEntryId:
|
|
148
|
+
description: Represents the ID of the pricebook entry
|
|
149
|
+
type: string
|
|
150
|
+
unitPrice:
|
|
151
|
+
description: Represents the unit price for the product
|
|
152
|
+
type: string
|
|
153
|
+
/commerce/webstores/{webstoreId}/pricing/products:
|
|
154
|
+
post:
|
|
155
|
+
description: Resource to calculate the price
|
|
156
|
+
responses:
|
|
157
|
+
'200':
|
|
158
|
+
description: Success
|
|
159
|
+
body:
|
|
160
|
+
application/json:
|
|
161
|
+
type: PricingResultRepresentation
|
|
162
|
+
queryParameters:
|
|
163
|
+
effectiveAccountId:
|
|
164
|
+
type: string
|
|
165
|
+
required: false
|
|
166
|
+
body:
|
|
167
|
+
application/json:
|
|
168
|
+
type: PricingInputRepresentation
|
|
169
|
+
# TODO : HAND ROLLED, required not supported
|
|
170
|
+
# required: false
|
|
171
|
+
(oas-body-name): pricingInput
|
|
172
|
+
uriParameters:
|
|
173
|
+
webstoreId:
|
|
174
|
+
type: string
|
|
175
|
+
required: true
|
|
176
|
+
/commerce/webstores/{webstoreId}/pricing/products/{productId}:
|
|
177
|
+
get:
|
|
178
|
+
description: Get the list price and buyer price for a product in the context of
|
|
179
|
+
a Web Store for the given account and currency
|
|
180
|
+
responses:
|
|
181
|
+
'200':
|
|
182
|
+
description: Success
|
|
183
|
+
body:
|
|
184
|
+
application/json:
|
|
185
|
+
type: ProductPriceRepresentation
|
|
186
|
+
queryParameters:
|
|
187
|
+
effectiveAccountId:
|
|
188
|
+
type: string
|
|
189
|
+
required: false
|
|
190
|
+
uriParameters:
|
|
191
|
+
productId:
|
|
192
|
+
type: string
|
|
193
|
+
required: true
|
|
194
|
+
webstoreId:
|
|
195
|
+
type: string
|
|
196
|
+
required: true
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#%RAML 1.0 Overlay
|
|
2
|
+
extends: ./api.raml
|
|
3
|
+
uses:
|
|
4
|
+
luvio: luvio://annotations.raml
|
|
5
|
+
|
|
6
|
+
(luvio.keyPrefix): 'Commerce'
|
|
7
|
+
(luvio.ttl): 2592000000
|
|
8
|
+
|
|
9
|
+
types:
|
|
10
|
+
ProductPriceRepresentation:
|
|
11
|
+
(luvio.opaque): true
|
|
12
|
+
|
|
13
|
+
/commerce/webstores/{webstoreId}/pricing/products/{productId}:
|
|
14
|
+
get:
|
|
15
|
+
(luvio.adapter):
|
|
16
|
+
name: getProductPrice
|