@salesforce/lds-adapters-industries-cpq 1.100.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/dist/es/es2018/industries-cpq.js +448 -0
- package/dist/types/src/generated/adapters/adapter-utils.d.ts +66 -0
- package/dist/types/src/generated/adapters/preview.d.ts +15 -0
- package/dist/types/src/generated/artifacts/main.d.ts +1 -0
- package/dist/types/src/generated/artifacts/sfdc.d.ts +2 -0
- package/dist/types/src/generated/resources/postConnectCpqPreview.d.ts +13 -0
- package/dist/types/src/generated/types/CpqBaseListOutputRepresentation.d.ts +71 -0
- package/dist/types/src/generated/types/PreviewInputRepresentation.d.ts +46 -0
- package/dist/types/src/generated/types/PreviewInputRepresentationWrapper.d.ts +30 -0
- package/dist/types/src/generated/types/ProductConfigurationInputRepresentation.d.ts +32 -0
- package/dist/types/src/generated/types/type-utils.d.ts +39 -0
- package/dist/umd/es2018/industries-cpq.js +456 -0
- package/dist/umd/es5/industries-cpq.js +459 -0
- package/package.json +70 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +475 -0
- package/src/raml/api.raml +135 -0
- package/src/raml/luvio.raml +19 -0
|
@@ -0,0 +1,459 @@
|
|
|
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.industriesCpq = {}, 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 = 'cpq';
|
|
49
|
+
|
|
50
|
+
var ObjectFreeze = Object.freeze, ObjectKeys = Object.keys;
|
|
51
|
+
var ArrayIsArray = Array.isArray;
|
|
52
|
+
var JSONStringify = JSON.stringify;
|
|
53
|
+
function deepFreeze$1(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$1(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$1(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 = 'ProductConfigurationInputRepresentation'; }
|
|
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
|
+
if (obj.configuration !== undefined) {
|
|
84
|
+
var obj_configuration = obj.configuration;
|
|
85
|
+
var path_configuration = path + '.configuration';
|
|
86
|
+
if (typeof obj_configuration !== 'object' || ArrayIsArray(obj_configuration) || obj_configuration === null) {
|
|
87
|
+
return new TypeError('Expected "object" but received "' + typeof obj_configuration + '" (at "' + path_configuration + '")');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (obj.productId !== undefined) {
|
|
91
|
+
var obj_productId = obj.productId;
|
|
92
|
+
var path_productId = path + '.productId';
|
|
93
|
+
if (typeof obj_productId !== 'string') {
|
|
94
|
+
return new TypeError('Expected "string" but received "' + typeof obj_productId + '" (at "' + path_productId + '")');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
return v_error === undefined ? null : v_error;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function validate$1(obj, path) {
|
|
102
|
+
if (path === void 0) { path = 'PreviewInputRepresentation'; }
|
|
103
|
+
var v_error = (function () {
|
|
104
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
105
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
106
|
+
}
|
|
107
|
+
if (obj.cartId !== undefined) {
|
|
108
|
+
var obj_cartId = obj.cartId;
|
|
109
|
+
var path_cartId = path + '.cartId';
|
|
110
|
+
if (typeof obj_cartId !== 'string') {
|
|
111
|
+
return new TypeError('Expected "string" but received "' + typeof obj_cartId + '" (at "' + path_cartId + '")');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (obj.configuredItems !== undefined) {
|
|
115
|
+
var obj_configuredItems = obj.configuredItems;
|
|
116
|
+
var path_configuredItems = path + '.configuredItems';
|
|
117
|
+
if (!ArrayIsArray(obj_configuredItems)) {
|
|
118
|
+
return new TypeError('Expected "array" but received "' + typeof obj_configuredItems + '" (at "' + path_configuredItems + '")');
|
|
119
|
+
}
|
|
120
|
+
for (var i = 0; i < obj_configuredItems.length; i++) {
|
|
121
|
+
var obj_configuredItems_item = obj_configuredItems[i];
|
|
122
|
+
var path_configuredItems_item = path_configuredItems + '[' + i + ']';
|
|
123
|
+
var referencepath_configuredItems_itemValidationError = validate$2(obj_configuredItems_item, path_configuredItems_item);
|
|
124
|
+
if (referencepath_configuredItems_itemValidationError !== null) {
|
|
125
|
+
var message = 'Object doesn\'t match ProductConfigurationInputRepresentation (at "' + path_configuredItems_item + '")\n';
|
|
126
|
+
message += referencepath_configuredItems_itemValidationError.message.split('\n').map(function (line) { return '\t' + line; }).join('\n');
|
|
127
|
+
return new TypeError(message);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (obj.correlationId !== undefined) {
|
|
132
|
+
var obj_correlationId = obj.correlationId;
|
|
133
|
+
var path_correlationId = path + '.correlationId';
|
|
134
|
+
if (typeof obj_correlationId !== 'string') {
|
|
135
|
+
return new TypeError('Expected "string" but received "' + typeof obj_correlationId + '" (at "' + path_correlationId + '")');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (obj.customFields !== undefined) {
|
|
139
|
+
var obj_customFields = obj.customFields;
|
|
140
|
+
var path_customFields = path + '.customFields';
|
|
141
|
+
if (typeof obj_customFields !== 'object' || ArrayIsArray(obj_customFields) || obj_customFields === null) {
|
|
142
|
+
return new TypeError('Expected "object" but received "' + typeof obj_customFields + '" (at "' + path_customFields + '")');
|
|
143
|
+
}
|
|
144
|
+
var obj_customFields_keys = ObjectKeys(obj_customFields);
|
|
145
|
+
for (var i = 0; i < obj_customFields_keys.length; i++) {
|
|
146
|
+
var key = obj_customFields_keys[i];
|
|
147
|
+
var obj_customFields_prop = obj_customFields[key];
|
|
148
|
+
var path_customFields_prop = path_customFields + '["' + key + '"]';
|
|
149
|
+
if (typeof obj_customFields_prop !== 'string') {
|
|
150
|
+
return new TypeError('Expected "string" but received "' + typeof obj_customFields_prop + '" (at "' + path_customFields_prop + '")');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (obj.userContext !== undefined) {
|
|
155
|
+
var obj_userContext = obj.userContext;
|
|
156
|
+
var path_userContext = path + '.userContext';
|
|
157
|
+
if (typeof obj_userContext !== 'object' || ArrayIsArray(obj_userContext) || obj_userContext === null) {
|
|
158
|
+
return new TypeError('Expected "object" but received "' + typeof obj_userContext + '" (at "' + path_userContext + '")');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
return v_error === undefined ? null : v_error;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var TTL = 1000;
|
|
166
|
+
var VERSION = "5f42d9d8a2278fc45355868ea236f9c6";
|
|
167
|
+
function validate(obj, path) {
|
|
168
|
+
if (path === void 0) { path = 'CpqBaseListOutputRepresentation'; }
|
|
169
|
+
var v_error = (function () {
|
|
170
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
171
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
172
|
+
}
|
|
173
|
+
if (obj.errorCode !== undefined) {
|
|
174
|
+
var obj_errorCode = obj.errorCode;
|
|
175
|
+
var path_errorCode = path + '.errorCode';
|
|
176
|
+
if (typeof obj_errorCode !== 'string') {
|
|
177
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (obj.errorDetails !== undefined) {
|
|
181
|
+
var obj_errorDetails = obj.errorDetails;
|
|
182
|
+
var path_errorDetails = path + '.errorDetails';
|
|
183
|
+
if (typeof obj_errorDetails !== 'string') {
|
|
184
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorDetails + '" (at "' + path_errorDetails + '")');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (obj.errorMessage !== undefined) {
|
|
188
|
+
var obj_errorMessage = obj.errorMessage;
|
|
189
|
+
var path_errorMessage = path + '.errorMessage';
|
|
190
|
+
if (typeof obj_errorMessage !== 'string') {
|
|
191
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (obj.limit !== undefined) {
|
|
195
|
+
var obj_limit = obj.limit;
|
|
196
|
+
var path_limit = path + '.limit';
|
|
197
|
+
if (typeof obj_limit !== 'number' || (typeof obj_limit === 'number' && Math.floor(obj_limit) !== obj_limit)) {
|
|
198
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_limit + '" (at "' + path_limit + '")');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (obj.offSet !== undefined) {
|
|
202
|
+
var obj_offSet = obj.offSet;
|
|
203
|
+
var path_offSet = path + '.offSet';
|
|
204
|
+
if (typeof obj_offSet !== 'number' || (typeof obj_offSet === 'number' && Math.floor(obj_offSet) !== obj_offSet)) {
|
|
205
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_offSet + '" (at "' + path_offSet + '")');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (obj.query !== undefined) {
|
|
209
|
+
var obj_query = obj.query;
|
|
210
|
+
var path_query = path + '.query';
|
|
211
|
+
if (typeof obj_query !== 'object' || ArrayIsArray(obj_query) || obj_query === null) {
|
|
212
|
+
return new TypeError('Expected "object" but received "' + typeof obj_query + '" (at "' + path_query + '")');
|
|
213
|
+
}
|
|
214
|
+
var obj_query_keys = ObjectKeys(obj_query);
|
|
215
|
+
for (var i = 0; i < obj_query_keys.length; i++) {
|
|
216
|
+
var key = obj_query_keys[i];
|
|
217
|
+
var obj_query_prop = obj_query[key];
|
|
218
|
+
var path_query_prop = path_query + '["' + key + '"]';
|
|
219
|
+
if (typeof obj_query_prop !== 'object' || ArrayIsArray(obj_query_prop) || obj_query_prop === null) {
|
|
220
|
+
return new TypeError('Expected "object" but received "' + typeof obj_query_prop + '" (at "' + path_query_prop + '")');
|
|
221
|
+
}
|
|
222
|
+
var obj_query_prop_keys = ObjectKeys(obj_query_prop);
|
|
223
|
+
for (var i_1 = 0; i_1 < obj_query_prop_keys.length; i_1++) {
|
|
224
|
+
var key_1 = obj_query_prop_keys[i_1];
|
|
225
|
+
var obj_query_prop_prop = obj_query_prop[key_1];
|
|
226
|
+
var path_query_prop_prop = path_query_prop + '["' + key_1 + '"]';
|
|
227
|
+
if (typeof obj_query_prop_prop !== 'object' || ArrayIsArray(obj_query_prop_prop) || obj_query_prop_prop === null) {
|
|
228
|
+
return new TypeError('Expected "object" but received "' + typeof obj_query_prop_prop + '" (at "' + path_query_prop_prop + '")');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
var obj_result = obj.result;
|
|
234
|
+
var path_result = path + '.result';
|
|
235
|
+
if (!ArrayIsArray(obj_result)) {
|
|
236
|
+
return new TypeError('Expected "array" but received "' + typeof obj_result + '" (at "' + path_result + '")');
|
|
237
|
+
}
|
|
238
|
+
for (var i = 0; i < obj_result.length; i++) {
|
|
239
|
+
var obj_result_item = obj_result[i];
|
|
240
|
+
var path_result_item = path_result + '[' + i + ']';
|
|
241
|
+
if (obj_result_item === undefined) {
|
|
242
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_result_item + '" (at "' + path_result_item + '")');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
var obj_status = obj.status;
|
|
246
|
+
var path_status = path + '.status';
|
|
247
|
+
if (typeof obj_status !== 'string') {
|
|
248
|
+
return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
|
|
249
|
+
}
|
|
250
|
+
if (obj.total !== undefined) {
|
|
251
|
+
var obj_total = obj.total;
|
|
252
|
+
var path_total = path + '.total';
|
|
253
|
+
if (typeof obj_total !== 'number' || (typeof obj_total === 'number' && Math.floor(obj_total) !== obj_total)) {
|
|
254
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_total + '" (at "' + path_total + '")');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
})();
|
|
258
|
+
return v_error === undefined ? null : v_error;
|
|
259
|
+
}
|
|
260
|
+
var RepresentationType = 'CpqBaseListOutputRepresentation';
|
|
261
|
+
function keyBuilder(luvio, config) {
|
|
262
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.message;
|
|
263
|
+
}
|
|
264
|
+
function keyBuilderFromType(luvio, object) {
|
|
265
|
+
var keyParams = {
|
|
266
|
+
message: object.status
|
|
267
|
+
};
|
|
268
|
+
return keyBuilder(luvio, keyParams);
|
|
269
|
+
}
|
|
270
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
271
|
+
return input;
|
|
272
|
+
}
|
|
273
|
+
var select$1 = function CpqBaseListOutputRepresentationSelect() {
|
|
274
|
+
return {
|
|
275
|
+
kind: 'Fragment',
|
|
276
|
+
version: VERSION,
|
|
277
|
+
private: [],
|
|
278
|
+
opaque: true
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
function equals(existing, incoming) {
|
|
282
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
function deepFreeze(input) {
|
|
288
|
+
var input_query = input.query;
|
|
289
|
+
if (input_query !== undefined) {
|
|
290
|
+
var input_query_keys = Object.keys(input_query);
|
|
291
|
+
var input_query_length = input_query_keys.length;
|
|
292
|
+
for (var i = 0; i < input_query_length; i++) {
|
|
293
|
+
var key = input_query_keys[i];
|
|
294
|
+
var input_query_prop = input_query[key];
|
|
295
|
+
var input_query_prop_keys = Object.keys(input_query_prop);
|
|
296
|
+
var input_query_prop_length = input_query_prop_keys.length;
|
|
297
|
+
for (var i_2 = 0; i_2 < input_query_prop_length; i_2++) {
|
|
298
|
+
var key_2 = input_query_prop_keys[i_2];
|
|
299
|
+
var input_query_prop_prop = input_query_prop[key_2];
|
|
300
|
+
ObjectFreeze(input_query_prop_prop);
|
|
301
|
+
}
|
|
302
|
+
ObjectFreeze(input_query_prop);
|
|
303
|
+
}
|
|
304
|
+
ObjectFreeze(input_query);
|
|
305
|
+
}
|
|
306
|
+
var input_result = input.result;
|
|
307
|
+
for (var i = 0; i < input_result.length; i++) {
|
|
308
|
+
var input_result_item = input_result[i];
|
|
309
|
+
deepFreeze$1(input_result_item);
|
|
310
|
+
}
|
|
311
|
+
ObjectFreeze(input_result);
|
|
312
|
+
ObjectFreeze(input);
|
|
313
|
+
}
|
|
314
|
+
var ingest = function CpqBaseListOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
315
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
316
|
+
var validateError = validate(input);
|
|
317
|
+
if (validateError !== null) {
|
|
318
|
+
throw validateError;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
var key = keyBuilderFromType(luvio, input);
|
|
322
|
+
var existingRecord = store.readEntry(key);
|
|
323
|
+
var ttlToUse = TTL;
|
|
324
|
+
var incomingRecord = normalize(input, store.readEntry(key), {
|
|
325
|
+
fullPath: key,
|
|
326
|
+
parent: path.parent,
|
|
327
|
+
propertyName: path.propertyName,
|
|
328
|
+
ttl: ttlToUse
|
|
329
|
+
});
|
|
330
|
+
deepFreeze(input);
|
|
331
|
+
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
332
|
+
luvio.storePublish(key, incomingRecord);
|
|
333
|
+
}
|
|
334
|
+
{
|
|
335
|
+
var storeMetadataParams = {
|
|
336
|
+
ttl: ttlToUse,
|
|
337
|
+
namespace: "cpq",
|
|
338
|
+
version: VERSION,
|
|
339
|
+
representationName: RepresentationType,
|
|
340
|
+
};
|
|
341
|
+
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
342
|
+
}
|
|
343
|
+
return createLink(key);
|
|
344
|
+
};
|
|
345
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
346
|
+
var rootKeySet = new engine.StoreKeyMap();
|
|
347
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
348
|
+
var rootKey = keyBuilderFromType(luvio, input);
|
|
349
|
+
rootKeySet.set(rootKey, {
|
|
350
|
+
namespace: keyPrefix,
|
|
351
|
+
representationName: RepresentationType,
|
|
352
|
+
mergeable: false
|
|
353
|
+
});
|
|
354
|
+
return rootKeySet;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function select(luvio, params) {
|
|
358
|
+
return select$1();
|
|
359
|
+
}
|
|
360
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
361
|
+
return getTypeCacheKeys(luvio, response);
|
|
362
|
+
}
|
|
363
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
364
|
+
var body = response.body;
|
|
365
|
+
var key = keyBuilderFromType(luvio, body);
|
|
366
|
+
luvio.storeIngest(key, ingest, body);
|
|
367
|
+
var snapshot = luvio.storeLookup({
|
|
368
|
+
recordId: key,
|
|
369
|
+
node: select(),
|
|
370
|
+
variables: {},
|
|
371
|
+
});
|
|
372
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
373
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
374
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return snapshot;
|
|
378
|
+
}
|
|
379
|
+
function createResourceRequest(config) {
|
|
380
|
+
var headers = {};
|
|
381
|
+
return {
|
|
382
|
+
baseUri: '/services/data/v58.0',
|
|
383
|
+
basePath: '/connect/cpq/preview',
|
|
384
|
+
method: 'post',
|
|
385
|
+
body: config.body,
|
|
386
|
+
urlParams: {},
|
|
387
|
+
queryParams: {},
|
|
388
|
+
headers: headers,
|
|
389
|
+
priority: 'normal',
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var preview_ConfigPropertyNames = {
|
|
394
|
+
displayName: 'preview',
|
|
395
|
+
parameters: {
|
|
396
|
+
required: ['previewInput'],
|
|
397
|
+
optional: []
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
function createResourceParams(config) {
|
|
401
|
+
var resourceParams = {
|
|
402
|
+
body: {
|
|
403
|
+
previewInput: config.previewInput
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
return resourceParams;
|
|
407
|
+
}
|
|
408
|
+
function typeCheckConfig(untrustedConfig) {
|
|
409
|
+
var config = {};
|
|
410
|
+
var untrustedConfig_previewInput = untrustedConfig.previewInput;
|
|
411
|
+
var referencePreviewInputRepresentationValidationError = validate$1(untrustedConfig_previewInput);
|
|
412
|
+
if (referencePreviewInputRepresentationValidationError === null) {
|
|
413
|
+
config.previewInput = untrustedConfig_previewInput;
|
|
414
|
+
}
|
|
415
|
+
return config;
|
|
416
|
+
}
|
|
417
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
418
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
422
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
423
|
+
}
|
|
424
|
+
var config = typeCheckConfig(untrustedConfig);
|
|
425
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
return config;
|
|
429
|
+
}
|
|
430
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
431
|
+
var resourceParams = createResourceParams(config);
|
|
432
|
+
var request = createResourceRequest(resourceParams);
|
|
433
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
434
|
+
.then(function (response) {
|
|
435
|
+
return luvio.handleSuccessResponse(function () {
|
|
436
|
+
var snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
437
|
+
return luvio.storeBroadcast().then(function () { return snapshot; });
|
|
438
|
+
}, function () { return getResponseCacheKeys(luvio, resourceParams, response.body); });
|
|
439
|
+
}, function (response) {
|
|
440
|
+
deepFreeze$1(response);
|
|
441
|
+
throw response;
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
var previewAdapterFactory = function (luvio) {
|
|
445
|
+
return function preview(untrustedConfig) {
|
|
446
|
+
var config = validateAdapterConfig(untrustedConfig, preview_ConfigPropertyNames);
|
|
447
|
+
// Invalid or incomplete config
|
|
448
|
+
if (config === null) {
|
|
449
|
+
throw new Error('Invalid config for "preview"');
|
|
450
|
+
}
|
|
451
|
+
return buildNetworkSnapshot(luvio, config);
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
exports.previewAdapterFactory = previewAdapterFactory;
|
|
456
|
+
|
|
457
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
458
|
+
|
|
459
|
+
}));
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/lds-adapters-industries-cpq",
|
|
3
|
+
"version": "1.100.2",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
+
"description": "APIs for Industries CPQ Project",
|
|
6
|
+
"main": "dist/umd/es2018/industries-cpq.js",
|
|
7
|
+
"module": "dist/es/es2018/industries-cpq.js",
|
|
8
|
+
"types": "dist/types/src/generated/artifacts/main.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"sfdc",
|
|
12
|
+
"src/raml/*"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/es/es2018/industries-cpq.js",
|
|
17
|
+
"require": "./dist/umd/es2018/industries-cpq.js",
|
|
18
|
+
"types": "./dist/types/src/generated/artifacts/main.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./sfdc": {
|
|
21
|
+
"import": "./sfdc/index.js",
|
|
22
|
+
"types": "./sfdc/index.d.ts",
|
|
23
|
+
"default": "./sfdc/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sdfc": {
|
|
27
|
+
"namespace": "lightning",
|
|
28
|
+
"module": "industriesCpqApi"
|
|
29
|
+
},
|
|
30
|
+
"contributors": [
|
|
31
|
+
"panakapalli@salesforce.com"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "yarn build:raml && yarn build:services && yarn build:karma",
|
|
35
|
+
"build:karma": "rollup --config rollup.config.karma.js",
|
|
36
|
+
"build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
|
|
37
|
+
"build:services": "rollup --config rollup.config.js",
|
|
38
|
+
"clean": "rm -rf dist sfdc src/generated karma/dist",
|
|
39
|
+
"release:core": "../../scripts/release/core.js --adapter=lds-adapters-industries-cpq",
|
|
40
|
+
"release:corejar": "yarn build && ../core-build/scripts/core.js --adapter=lds-adapters-industries-cpq",
|
|
41
|
+
"start": "karma start",
|
|
42
|
+
"test": "karma start --single-run",
|
|
43
|
+
"test:compat": "karma start --single-run --compat"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@salesforce/lds-bindings": "^1.100.2"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@luvio/cli": "0.135.4",
|
|
50
|
+
"@luvio/compiler": "0.135.4",
|
|
51
|
+
"@luvio/engine": "0.135.4",
|
|
52
|
+
"@luvio/lwc-luvio": "0.135.4",
|
|
53
|
+
"@salesforce/lds-karma": "^1.100.2"
|
|
54
|
+
},
|
|
55
|
+
"nx": {
|
|
56
|
+
"targets": {
|
|
57
|
+
"build": {
|
|
58
|
+
"outputs": [
|
|
59
|
+
"packages/lds-adapters-industries-cpq/dist",
|
|
60
|
+
"packages/lds-adapters-industries-cpq/karma/dist",
|
|
61
|
+
"packages/lds-adapters-industries-cpq/sfdc",
|
|
62
|
+
"packages/lds-adapters-industries-cpq/src/generated"
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"volta": {
|
|
68
|
+
"extends": "../../package.json"
|
|
69
|
+
}
|
|
70
|
+
}
|
package/sfdc/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/types/src/generated/artifacts/sfdc';
|