@salesforce/lds-adapters-revenue-place-quote 1.124.2 → 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/revenue-place-quote.js +318 -318
- package/dist/{types → es/es2018/types}/src/generated/adapters/adapter-utils.d.ts +66 -66
- package/dist/{types → es/es2018/types}/src/generated/adapters/updateQuote.d.ts +15 -15
- 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 +2 -2
- package/dist/{types → es/es2018/types}/src/generated/resources/postCommerceQuotesActionsPlace.d.ts +13 -13
- package/dist/{types → es/es2018/types}/src/generated/types/PlaceQuoteErrorResponseRepresentation.d.ts +35 -35
- package/dist/{types → es/es2018/types}/src/generated/types/PlaceQuoteInputRepresentation.d.ts +32 -32
- package/dist/{types → es/es2018/types}/src/generated/types/PlaceQuoteInputWrapperRepresentation.d.ts +29 -29
- package/dist/{types → es/es2018/types}/src/generated/types/PlaceQuoteOutputRepresentation.d.ts +52 -52
- package/dist/{types → es/es2018/types}/src/generated/types/type-utils.d.ts +39 -39
- package/package.json +5 -5
- package/sfdc/index.d.ts +1 -1
- package/sfdc/index.js +334 -334
- package/dist/umd/es2018/revenue-place-quote.js +0 -349
- package/dist/umd/es5/revenue-place-quote.js +0 -352
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* For full license text, see the LICENSE.txt file
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
(function (global, factory) {
|
|
8
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.revenuePlaceQuote = {}, global.engine));
|
|
11
|
-
})(this, (function (exports, engine) { 'use strict';
|
|
12
|
-
|
|
13
|
-
var ObjectPrototypeHasOwnProperty = Object.prototype.hasOwnProperty;
|
|
14
|
-
var ObjectKeys$1 = Object.keys;
|
|
15
|
-
var ArrayIsArray$1 = Array.isArray;
|
|
16
|
-
/**
|
|
17
|
-
* Validates an adapter config is well-formed.
|
|
18
|
-
* @param config The config to validate.
|
|
19
|
-
* @param adapter The adapter validation configuration.
|
|
20
|
-
* @param oneOf The keys the config must contain at least one of.
|
|
21
|
-
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
22
|
-
*/
|
|
23
|
-
function validateConfig(config, adapter, oneOf) {
|
|
24
|
-
var displayName = adapter.displayName;
|
|
25
|
-
var _a = adapter.parameters, required = _a.required, optional = _a.optional, unsupported = _a.unsupported;
|
|
26
|
-
if (config === undefined ||
|
|
27
|
-
required.every(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); }) === false) {
|
|
28
|
-
throw new TypeError("adapter ".concat(displayName, " configuration must specify ").concat(required.sort().join(', ')));
|
|
29
|
-
}
|
|
30
|
-
if (oneOf && oneOf.some(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); }) === false) {
|
|
31
|
-
throw new TypeError("adapter ".concat(displayName, " configuration must specify one of ").concat(oneOf.sort().join(', ')));
|
|
32
|
-
}
|
|
33
|
-
if (unsupported !== undefined &&
|
|
34
|
-
unsupported.some(function (req) { return ObjectPrototypeHasOwnProperty.call(config, req); })) {
|
|
35
|
-
throw new TypeError("adapter ".concat(displayName, " does not yet support ").concat(unsupported.sort().join(', ')));
|
|
36
|
-
}
|
|
37
|
-
var supported = required.concat(optional);
|
|
38
|
-
if (ObjectKeys$1(config).some(function (key) { return !supported.includes(key); })) {
|
|
39
|
-
throw new TypeError("adapter ".concat(displayName, " configuration supports only ").concat(supported.sort().join(', ')));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function untrustedIsObject(untrusted) {
|
|
43
|
-
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
44
|
-
}
|
|
45
|
-
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
46
|
-
return configPropertyNames.parameters.required.every(function (req) { return req in config; });
|
|
47
|
-
}
|
|
48
|
-
var keyPrefix = 'place-quote';
|
|
49
|
-
|
|
50
|
-
var ObjectFreeze = Object.freeze, ObjectKeys = Object.keys;
|
|
51
|
-
var ArrayIsArray = Array.isArray;
|
|
52
|
-
var JSONStringify = JSON.stringify;
|
|
53
|
-
function deepFreeze$2(value) {
|
|
54
|
-
// No need to freeze primitives
|
|
55
|
-
if (typeof value !== 'object' || value === null) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (ArrayIsArray(value)) {
|
|
59
|
-
for (var i = 0, len = value.length; i < len; i += 1) {
|
|
60
|
-
deepFreeze$2(value[i]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
var keys = ObjectKeys(value);
|
|
65
|
-
for (var i = 0, len = keys.length; i < len; i += 1) {
|
|
66
|
-
deepFreeze$2(value[keys[i]]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
ObjectFreeze(value);
|
|
70
|
-
}
|
|
71
|
-
function createLink(ref) {
|
|
72
|
-
return {
|
|
73
|
-
__ref: engine.serializeStructuredKey(ref),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function validate$2(obj, path) {
|
|
78
|
-
if (path === void 0) { path = 'PlaceQuoteInputRepresentation'; }
|
|
79
|
-
var v_error = (function () {
|
|
80
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
81
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
82
|
-
}
|
|
83
|
-
var obj_graph = obj.graph;
|
|
84
|
-
var path_graph = path + '.graph';
|
|
85
|
-
if (typeof obj_graph !== 'object' || ArrayIsArray(obj_graph) || obj_graph === null) {
|
|
86
|
-
return new TypeError('Expected "object" but received "' + typeof obj_graph + '" (at "' + path_graph + '")');
|
|
87
|
-
}
|
|
88
|
-
var obj_pricingPref = obj.pricingPref;
|
|
89
|
-
var path_pricingPref = path + '.pricingPref';
|
|
90
|
-
if (typeof obj_pricingPref !== 'string') {
|
|
91
|
-
return new TypeError('Expected "string" but received "' + typeof obj_pricingPref + '" (at "' + path_pricingPref + '")');
|
|
92
|
-
}
|
|
93
|
-
})();
|
|
94
|
-
return v_error === undefined ? null : v_error;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function validate$1(obj, path) {
|
|
98
|
-
if (path === void 0) { path = 'PlaceQuoteErrorResponseRepresentation'; }
|
|
99
|
-
var v_error = (function () {
|
|
100
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
101
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
102
|
-
}
|
|
103
|
-
var obj_errorCode = obj.errorCode;
|
|
104
|
-
var path_errorCode = path + '.errorCode';
|
|
105
|
-
if (typeof obj_errorCode !== 'string') {
|
|
106
|
-
return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
|
|
107
|
-
}
|
|
108
|
-
var obj_message = obj.message;
|
|
109
|
-
var path_message = path + '.message';
|
|
110
|
-
if (typeof obj_message !== 'string') {
|
|
111
|
-
return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
|
|
112
|
-
}
|
|
113
|
-
var obj_referenceId = obj.referenceId;
|
|
114
|
-
var path_referenceId = path + '.referenceId';
|
|
115
|
-
if (typeof obj_referenceId !== 'string') {
|
|
116
|
-
return new TypeError('Expected "string" but received "' + typeof obj_referenceId + '" (at "' + path_referenceId + '")');
|
|
117
|
-
}
|
|
118
|
-
})();
|
|
119
|
-
return v_error === undefined ? null : v_error;
|
|
120
|
-
}
|
|
121
|
-
function deepFreeze$1(input) {
|
|
122
|
-
ObjectFreeze(input);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
var TTL = 1000;
|
|
126
|
-
var VERSION = "32a768cba447434ebb8e37e67aed1302";
|
|
127
|
-
function validate(obj, path) {
|
|
128
|
-
if (path === void 0) { path = 'PlaceQuoteOutputRepresentation'; }
|
|
129
|
-
var v_error = (function () {
|
|
130
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
131
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
132
|
-
}
|
|
133
|
-
var obj_quoteId = obj.quoteId;
|
|
134
|
-
var path_quoteId = path + '.quoteId';
|
|
135
|
-
if (typeof obj_quoteId !== 'string') {
|
|
136
|
-
return new TypeError('Expected "string" but received "' + typeof obj_quoteId + '" (at "' + path_quoteId + '")');
|
|
137
|
-
}
|
|
138
|
-
var obj_requestIdentifier = obj.requestIdentifier;
|
|
139
|
-
var path_requestIdentifier = path + '.requestIdentifier';
|
|
140
|
-
if (typeof obj_requestIdentifier !== 'string') {
|
|
141
|
-
return new TypeError('Expected "string" but received "' + typeof obj_requestIdentifier + '" (at "' + path_requestIdentifier + '")');
|
|
142
|
-
}
|
|
143
|
-
var obj_responseError = obj.responseError;
|
|
144
|
-
var path_responseError = path + '.responseError';
|
|
145
|
-
if (!ArrayIsArray(obj_responseError)) {
|
|
146
|
-
return new TypeError('Expected "array" but received "' + typeof obj_responseError + '" (at "' + path_responseError + '")');
|
|
147
|
-
}
|
|
148
|
-
for (var i = 0; i < obj_responseError.length; i++) {
|
|
149
|
-
var obj_responseError_item = obj_responseError[i];
|
|
150
|
-
var path_responseError_item = path_responseError + '[' + i + ']';
|
|
151
|
-
var referencepath_responseError_itemValidationError = validate$1(obj_responseError_item, path_responseError_item);
|
|
152
|
-
if (referencepath_responseError_itemValidationError !== null) {
|
|
153
|
-
var message = 'Object doesn\'t match PlaceQuoteErrorResponseRepresentation (at "' + path_responseError_item + '")\n';
|
|
154
|
-
message += referencepath_responseError_itemValidationError.message.split('\n').map(function (line) { return '\t' + line; }).join('\n');
|
|
155
|
-
return new TypeError(message);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
var obj_statusURL = obj.statusURL;
|
|
159
|
-
var path_statusURL = path + '.statusURL';
|
|
160
|
-
if (typeof obj_statusURL !== 'string') {
|
|
161
|
-
return new TypeError('Expected "string" but received "' + typeof obj_statusURL + '" (at "' + path_statusURL + '")');
|
|
162
|
-
}
|
|
163
|
-
var obj_success = obj.success;
|
|
164
|
-
var path_success = path + '.success';
|
|
165
|
-
if (typeof obj_success !== 'boolean') {
|
|
166
|
-
return new TypeError('Expected "boolean" but received "' + typeof obj_success + '" (at "' + path_success + '")');
|
|
167
|
-
}
|
|
168
|
-
})();
|
|
169
|
-
return v_error === undefined ? null : v_error;
|
|
170
|
-
}
|
|
171
|
-
var RepresentationType = 'PlaceQuoteOutputRepresentation';
|
|
172
|
-
function keyBuilder(luvio, config) {
|
|
173
|
-
return keyPrefix + '::' + RepresentationType + ':' + config.quoteId;
|
|
174
|
-
}
|
|
175
|
-
function keyBuilderFromType(luvio, object) {
|
|
176
|
-
var keyParams = {
|
|
177
|
-
quoteId: object.quoteId
|
|
178
|
-
};
|
|
179
|
-
return keyBuilder(luvio, keyParams);
|
|
180
|
-
}
|
|
181
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
182
|
-
return input;
|
|
183
|
-
}
|
|
184
|
-
var select$1 = function PlaceQuoteOutputRepresentationSelect() {
|
|
185
|
-
return {
|
|
186
|
-
kind: 'Fragment',
|
|
187
|
-
version: VERSION,
|
|
188
|
-
private: [],
|
|
189
|
-
opaque: true
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
function equals(existing, incoming) {
|
|
193
|
-
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
function deepFreeze(input) {
|
|
199
|
-
var input_responseError = input.responseError;
|
|
200
|
-
for (var i = 0; i < input_responseError.length; i++) {
|
|
201
|
-
var input_responseError_item = input_responseError[i];
|
|
202
|
-
deepFreeze$1(input_responseError_item);
|
|
203
|
-
}
|
|
204
|
-
ObjectFreeze(input_responseError);
|
|
205
|
-
ObjectFreeze(input);
|
|
206
|
-
}
|
|
207
|
-
var ingest = function PlaceQuoteOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
208
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
209
|
-
var validateError = validate(input);
|
|
210
|
-
if (validateError !== null) {
|
|
211
|
-
throw validateError;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
var key = keyBuilderFromType(luvio, input);
|
|
215
|
-
var existingRecord = store.readEntry(key);
|
|
216
|
-
var ttlToUse = TTL;
|
|
217
|
-
var incomingRecord = normalize(input, store.readEntry(key), {
|
|
218
|
-
fullPath: key,
|
|
219
|
-
parent: path.parent,
|
|
220
|
-
propertyName: path.propertyName,
|
|
221
|
-
ttl: ttlToUse
|
|
222
|
-
});
|
|
223
|
-
deepFreeze(input);
|
|
224
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
225
|
-
luvio.storePublish(key, incomingRecord);
|
|
226
|
-
}
|
|
227
|
-
{
|
|
228
|
-
var storeMetadataParams = {
|
|
229
|
-
ttl: ttlToUse,
|
|
230
|
-
namespace: "place-quote",
|
|
231
|
-
version: VERSION,
|
|
232
|
-
representationName: RepresentationType,
|
|
233
|
-
};
|
|
234
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
235
|
-
}
|
|
236
|
-
return createLink(key);
|
|
237
|
-
};
|
|
238
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
239
|
-
var rootKeySet = new engine.StoreKeyMap();
|
|
240
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
241
|
-
var rootKey = keyBuilderFromType(luvio, input);
|
|
242
|
-
rootKeySet.set(rootKey, {
|
|
243
|
-
namespace: keyPrefix,
|
|
244
|
-
representationName: RepresentationType,
|
|
245
|
-
mergeable: false
|
|
246
|
-
});
|
|
247
|
-
return rootKeySet;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function select(luvio, params) {
|
|
251
|
-
return select$1();
|
|
252
|
-
}
|
|
253
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
254
|
-
return getTypeCacheKeys(luvio, response);
|
|
255
|
-
}
|
|
256
|
-
function ingestSuccess(luvio, resourceParams, response) {
|
|
257
|
-
var body = response.body;
|
|
258
|
-
var key = keyBuilderFromType(luvio, body);
|
|
259
|
-
luvio.storeIngest(key, ingest, body);
|
|
260
|
-
var snapshot = luvio.storeLookup({
|
|
261
|
-
recordId: key,
|
|
262
|
-
node: select(),
|
|
263
|
-
variables: {},
|
|
264
|
-
});
|
|
265
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
266
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
267
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return snapshot;
|
|
271
|
-
}
|
|
272
|
-
function createResourceRequest(config) {
|
|
273
|
-
var headers = {};
|
|
274
|
-
return {
|
|
275
|
-
baseUri: '/services/data/v58.0',
|
|
276
|
-
basePath: '/commerce/quotes/actions/place',
|
|
277
|
-
method: 'post',
|
|
278
|
-
body: config.body,
|
|
279
|
-
urlParams: {},
|
|
280
|
-
queryParams: {},
|
|
281
|
-
headers: headers,
|
|
282
|
-
priority: 'normal',
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
var updateQuote_ConfigPropertyNames = {
|
|
287
|
-
displayName: 'updateQuote',
|
|
288
|
-
parameters: {
|
|
289
|
-
required: ['PlaceQuoteInput'],
|
|
290
|
-
optional: []
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
function createResourceParams(config) {
|
|
294
|
-
var resourceParams = {
|
|
295
|
-
body: {
|
|
296
|
-
PlaceQuoteInput: config.PlaceQuoteInput
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
return resourceParams;
|
|
300
|
-
}
|
|
301
|
-
function typeCheckConfig(untrustedConfig) {
|
|
302
|
-
var config = {};
|
|
303
|
-
var untrustedConfig_PlaceQuoteInput = untrustedConfig.PlaceQuoteInput;
|
|
304
|
-
var referencePlaceQuoteInputRepresentationValidationError = validate$2(untrustedConfig_PlaceQuoteInput);
|
|
305
|
-
if (referencePlaceQuoteInputRepresentationValidationError === null) {
|
|
306
|
-
config.PlaceQuoteInput = untrustedConfig_PlaceQuoteInput;
|
|
307
|
-
}
|
|
308
|
-
return config;
|
|
309
|
-
}
|
|
310
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
311
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
315
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
316
|
-
}
|
|
317
|
-
var config = typeCheckConfig(untrustedConfig);
|
|
318
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
319
|
-
return null;
|
|
320
|
-
}
|
|
321
|
-
return config;
|
|
322
|
-
}
|
|
323
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
324
|
-
var resourceParams = createResourceParams(config);
|
|
325
|
-
var request = createResourceRequest(resourceParams);
|
|
326
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
327
|
-
.then(function (response) {
|
|
328
|
-
return luvio.handleSuccessResponse(function () {
|
|
329
|
-
var snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
330
|
-
return luvio.storeBroadcast().then(function () { return snapshot; });
|
|
331
|
-
}, function () { return getResponseCacheKeys(luvio, resourceParams, response.body); });
|
|
332
|
-
}, function (response) {
|
|
333
|
-
deepFreeze$2(response);
|
|
334
|
-
throw response;
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
var updateQuoteAdapterFactory = function (luvio) {
|
|
338
|
-
return function updateQuote(untrustedConfig) {
|
|
339
|
-
var config = validateAdapterConfig(untrustedConfig, updateQuote_ConfigPropertyNames);
|
|
340
|
-
// Invalid or incomplete config
|
|
341
|
-
if (config === null) {
|
|
342
|
-
throw new Error('Invalid config for "updateQuote"');
|
|
343
|
-
}
|
|
344
|
-
return buildNetworkSnapshot(luvio, config);
|
|
345
|
-
};
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
exports.updateQuoteAdapterFactory = updateQuoteAdapterFactory;
|
|
349
|
-
|
|
350
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
351
|
-
|
|
352
|
-
}));
|