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