@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
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2022, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
|
|
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 keyPrefix = 'cpq';
|
|
45
|
+
|
|
46
|
+
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
47
|
+
const { isArray: ArrayIsArray } = Array;
|
|
48
|
+
const { stringify: JSONStringify } = JSON;
|
|
49
|
+
function deepFreeze$1(value) {
|
|
50
|
+
// No need to freeze primitives
|
|
51
|
+
if (typeof value !== 'object' || value === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (ArrayIsArray(value)) {
|
|
55
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
56
|
+
deepFreeze$1(value[i]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const keys = ObjectKeys(value);
|
|
61
|
+
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
62
|
+
deepFreeze$1(value[keys[i]]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ObjectFreeze(value);
|
|
66
|
+
}
|
|
67
|
+
function createLink(ref) {
|
|
68
|
+
return {
|
|
69
|
+
__ref: serializeStructuredKey(ref),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function validate$2(obj, path = 'ProductConfigurationInputRepresentation') {
|
|
74
|
+
const v_error = (() => {
|
|
75
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
76
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
77
|
+
}
|
|
78
|
+
if (obj.configuration !== undefined) {
|
|
79
|
+
const obj_configuration = obj.configuration;
|
|
80
|
+
const path_configuration = path + '.configuration';
|
|
81
|
+
if (typeof obj_configuration !== 'object' || ArrayIsArray(obj_configuration) || obj_configuration === null) {
|
|
82
|
+
return new TypeError('Expected "object" but received "' + typeof obj_configuration + '" (at "' + path_configuration + '")');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (obj.productId !== undefined) {
|
|
86
|
+
const obj_productId = obj.productId;
|
|
87
|
+
const path_productId = path + '.productId';
|
|
88
|
+
if (typeof obj_productId !== 'string') {
|
|
89
|
+
return new TypeError('Expected "string" but received "' + typeof obj_productId + '" (at "' + path_productId + '")');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
})();
|
|
93
|
+
return v_error === undefined ? null : v_error;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function validate$1(obj, path = 'PreviewInputRepresentation') {
|
|
97
|
+
const v_error = (() => {
|
|
98
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
99
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
100
|
+
}
|
|
101
|
+
if (obj.cartId !== undefined) {
|
|
102
|
+
const obj_cartId = obj.cartId;
|
|
103
|
+
const path_cartId = path + '.cartId';
|
|
104
|
+
if (typeof obj_cartId !== 'string') {
|
|
105
|
+
return new TypeError('Expected "string" but received "' + typeof obj_cartId + '" (at "' + path_cartId + '")');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (obj.configuredItems !== undefined) {
|
|
109
|
+
const obj_configuredItems = obj.configuredItems;
|
|
110
|
+
const path_configuredItems = path + '.configuredItems';
|
|
111
|
+
if (!ArrayIsArray(obj_configuredItems)) {
|
|
112
|
+
return new TypeError('Expected "array" but received "' + typeof obj_configuredItems + '" (at "' + path_configuredItems + '")');
|
|
113
|
+
}
|
|
114
|
+
for (let i = 0; i < obj_configuredItems.length; i++) {
|
|
115
|
+
const obj_configuredItems_item = obj_configuredItems[i];
|
|
116
|
+
const path_configuredItems_item = path_configuredItems + '[' + i + ']';
|
|
117
|
+
const referencepath_configuredItems_itemValidationError = validate$2(obj_configuredItems_item, path_configuredItems_item);
|
|
118
|
+
if (referencepath_configuredItems_itemValidationError !== null) {
|
|
119
|
+
let message = 'Object doesn\'t match ProductConfigurationInputRepresentation (at "' + path_configuredItems_item + '")\n';
|
|
120
|
+
message += referencepath_configuredItems_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
121
|
+
return new TypeError(message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (obj.correlationId !== undefined) {
|
|
126
|
+
const obj_correlationId = obj.correlationId;
|
|
127
|
+
const path_correlationId = path + '.correlationId';
|
|
128
|
+
if (typeof obj_correlationId !== 'string') {
|
|
129
|
+
return new TypeError('Expected "string" but received "' + typeof obj_correlationId + '" (at "' + path_correlationId + '")');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (obj.customFields !== undefined) {
|
|
133
|
+
const obj_customFields = obj.customFields;
|
|
134
|
+
const path_customFields = path + '.customFields';
|
|
135
|
+
if (typeof obj_customFields !== 'object' || ArrayIsArray(obj_customFields) || obj_customFields === null) {
|
|
136
|
+
return new TypeError('Expected "object" but received "' + typeof obj_customFields + '" (at "' + path_customFields + '")');
|
|
137
|
+
}
|
|
138
|
+
const obj_customFields_keys = ObjectKeys(obj_customFields);
|
|
139
|
+
for (let i = 0; i < obj_customFields_keys.length; i++) {
|
|
140
|
+
const key = obj_customFields_keys[i];
|
|
141
|
+
const obj_customFields_prop = obj_customFields[key];
|
|
142
|
+
const path_customFields_prop = path_customFields + '["' + key + '"]';
|
|
143
|
+
if (typeof obj_customFields_prop !== 'string') {
|
|
144
|
+
return new TypeError('Expected "string" but received "' + typeof obj_customFields_prop + '" (at "' + path_customFields_prop + '")');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (obj.userContext !== undefined) {
|
|
149
|
+
const obj_userContext = obj.userContext;
|
|
150
|
+
const path_userContext = path + '.userContext';
|
|
151
|
+
if (typeof obj_userContext !== 'object' || ArrayIsArray(obj_userContext) || obj_userContext === null) {
|
|
152
|
+
return new TypeError('Expected "object" but received "' + typeof obj_userContext + '" (at "' + path_userContext + '")');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
})();
|
|
156
|
+
return v_error === undefined ? null : v_error;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const TTL = 1000;
|
|
160
|
+
const VERSION = "5f42d9d8a2278fc45355868ea236f9c6";
|
|
161
|
+
function validate(obj, path = 'CpqBaseListOutputRepresentation') {
|
|
162
|
+
const v_error = (() => {
|
|
163
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
164
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
165
|
+
}
|
|
166
|
+
if (obj.errorCode !== undefined) {
|
|
167
|
+
const obj_errorCode = obj.errorCode;
|
|
168
|
+
const path_errorCode = path + '.errorCode';
|
|
169
|
+
if (typeof obj_errorCode !== 'string') {
|
|
170
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (obj.errorDetails !== undefined) {
|
|
174
|
+
const obj_errorDetails = obj.errorDetails;
|
|
175
|
+
const path_errorDetails = path + '.errorDetails';
|
|
176
|
+
if (typeof obj_errorDetails !== 'string') {
|
|
177
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorDetails + '" (at "' + path_errorDetails + '")');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (obj.errorMessage !== undefined) {
|
|
181
|
+
const obj_errorMessage = obj.errorMessage;
|
|
182
|
+
const path_errorMessage = path + '.errorMessage';
|
|
183
|
+
if (typeof obj_errorMessage !== 'string') {
|
|
184
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (obj.limit !== undefined) {
|
|
188
|
+
const obj_limit = obj.limit;
|
|
189
|
+
const path_limit = path + '.limit';
|
|
190
|
+
if (typeof obj_limit !== 'number' || (typeof obj_limit === 'number' && Math.floor(obj_limit) !== obj_limit)) {
|
|
191
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_limit + '" (at "' + path_limit + '")');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (obj.offSet !== undefined) {
|
|
195
|
+
const obj_offSet = obj.offSet;
|
|
196
|
+
const path_offSet = path + '.offSet';
|
|
197
|
+
if (typeof obj_offSet !== 'number' || (typeof obj_offSet === 'number' && Math.floor(obj_offSet) !== obj_offSet)) {
|
|
198
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_offSet + '" (at "' + path_offSet + '")');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (obj.query !== undefined) {
|
|
202
|
+
const obj_query = obj.query;
|
|
203
|
+
const path_query = path + '.query';
|
|
204
|
+
if (typeof obj_query !== 'object' || ArrayIsArray(obj_query) || obj_query === null) {
|
|
205
|
+
return new TypeError('Expected "object" but received "' + typeof obj_query + '" (at "' + path_query + '")');
|
|
206
|
+
}
|
|
207
|
+
const obj_query_keys = ObjectKeys(obj_query);
|
|
208
|
+
for (let i = 0; i < obj_query_keys.length; i++) {
|
|
209
|
+
const key = obj_query_keys[i];
|
|
210
|
+
const obj_query_prop = obj_query[key];
|
|
211
|
+
const path_query_prop = path_query + '["' + key + '"]';
|
|
212
|
+
if (typeof obj_query_prop !== 'object' || ArrayIsArray(obj_query_prop) || obj_query_prop === null) {
|
|
213
|
+
return new TypeError('Expected "object" but received "' + typeof obj_query_prop + '" (at "' + path_query_prop + '")');
|
|
214
|
+
}
|
|
215
|
+
const obj_query_prop_keys = ObjectKeys(obj_query_prop);
|
|
216
|
+
for (let i = 0; i < obj_query_prop_keys.length; i++) {
|
|
217
|
+
const key = obj_query_prop_keys[i];
|
|
218
|
+
const obj_query_prop_prop = obj_query_prop[key];
|
|
219
|
+
const path_query_prop_prop = path_query_prop + '["' + key + '"]';
|
|
220
|
+
if (typeof obj_query_prop_prop !== 'object' || ArrayIsArray(obj_query_prop_prop) || obj_query_prop_prop === null) {
|
|
221
|
+
return new TypeError('Expected "object" but received "' + typeof obj_query_prop_prop + '" (at "' + path_query_prop_prop + '")');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const obj_result = obj.result;
|
|
227
|
+
const path_result = path + '.result';
|
|
228
|
+
if (!ArrayIsArray(obj_result)) {
|
|
229
|
+
return new TypeError('Expected "array" but received "' + typeof obj_result + '" (at "' + path_result + '")');
|
|
230
|
+
}
|
|
231
|
+
for (let i = 0; i < obj_result.length; i++) {
|
|
232
|
+
const obj_result_item = obj_result[i];
|
|
233
|
+
const path_result_item = path_result + '[' + i + ']';
|
|
234
|
+
if (obj_result_item === undefined) {
|
|
235
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_result_item + '" (at "' + path_result_item + '")');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const obj_status = obj.status;
|
|
239
|
+
const path_status = path + '.status';
|
|
240
|
+
if (typeof obj_status !== 'string') {
|
|
241
|
+
return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
|
|
242
|
+
}
|
|
243
|
+
if (obj.total !== undefined) {
|
|
244
|
+
const obj_total = obj.total;
|
|
245
|
+
const path_total = path + '.total';
|
|
246
|
+
if (typeof obj_total !== 'number' || (typeof obj_total === 'number' && Math.floor(obj_total) !== obj_total)) {
|
|
247
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_total + '" (at "' + path_total + '")');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
})();
|
|
251
|
+
return v_error === undefined ? null : v_error;
|
|
252
|
+
}
|
|
253
|
+
const RepresentationType = 'CpqBaseListOutputRepresentation';
|
|
254
|
+
function keyBuilder(luvio, config) {
|
|
255
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.message;
|
|
256
|
+
}
|
|
257
|
+
function keyBuilderFromType(luvio, object) {
|
|
258
|
+
const keyParams = {
|
|
259
|
+
message: object.status
|
|
260
|
+
};
|
|
261
|
+
return keyBuilder(luvio, keyParams);
|
|
262
|
+
}
|
|
263
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
264
|
+
return input;
|
|
265
|
+
}
|
|
266
|
+
const select$1 = function CpqBaseListOutputRepresentationSelect() {
|
|
267
|
+
return {
|
|
268
|
+
kind: 'Fragment',
|
|
269
|
+
version: VERSION,
|
|
270
|
+
private: [],
|
|
271
|
+
opaque: true
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
function equals(existing, incoming) {
|
|
275
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
function deepFreeze(input) {
|
|
281
|
+
const input_query = input.query;
|
|
282
|
+
if (input_query !== undefined) {
|
|
283
|
+
const input_query_keys = Object.keys(input_query);
|
|
284
|
+
const input_query_length = input_query_keys.length;
|
|
285
|
+
for (let i = 0; i < input_query_length; i++) {
|
|
286
|
+
const key = input_query_keys[i];
|
|
287
|
+
const input_query_prop = input_query[key];
|
|
288
|
+
const input_query_prop_keys = Object.keys(input_query_prop);
|
|
289
|
+
const input_query_prop_length = input_query_prop_keys.length;
|
|
290
|
+
for (let i = 0; i < input_query_prop_length; i++) {
|
|
291
|
+
const key = input_query_prop_keys[i];
|
|
292
|
+
const input_query_prop_prop = input_query_prop[key];
|
|
293
|
+
ObjectFreeze(input_query_prop_prop);
|
|
294
|
+
}
|
|
295
|
+
ObjectFreeze(input_query_prop);
|
|
296
|
+
}
|
|
297
|
+
ObjectFreeze(input_query);
|
|
298
|
+
}
|
|
299
|
+
const input_result = input.result;
|
|
300
|
+
for (let i = 0; i < input_result.length; i++) {
|
|
301
|
+
const input_result_item = input_result[i];
|
|
302
|
+
deepFreeze$1(input_result_item);
|
|
303
|
+
}
|
|
304
|
+
ObjectFreeze(input_result);
|
|
305
|
+
ObjectFreeze(input);
|
|
306
|
+
}
|
|
307
|
+
const ingest = function CpqBaseListOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
308
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
309
|
+
const validateError = validate(input);
|
|
310
|
+
if (validateError !== null) {
|
|
311
|
+
throw validateError;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const key = keyBuilderFromType(luvio, input);
|
|
315
|
+
const existingRecord = store.readEntry(key);
|
|
316
|
+
const ttlToUse = TTL;
|
|
317
|
+
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
318
|
+
fullPath: key,
|
|
319
|
+
parent: path.parent,
|
|
320
|
+
propertyName: path.propertyName,
|
|
321
|
+
ttl: ttlToUse
|
|
322
|
+
});
|
|
323
|
+
deepFreeze(input);
|
|
324
|
+
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
325
|
+
luvio.storePublish(key, incomingRecord);
|
|
326
|
+
}
|
|
327
|
+
{
|
|
328
|
+
const storeMetadataParams = {
|
|
329
|
+
ttl: ttlToUse,
|
|
330
|
+
namespace: "cpq",
|
|
331
|
+
version: VERSION,
|
|
332
|
+
representationName: RepresentationType,
|
|
333
|
+
};
|
|
334
|
+
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
335
|
+
}
|
|
336
|
+
return createLink(key);
|
|
337
|
+
};
|
|
338
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
339
|
+
const rootKeySet = new StoreKeyMap();
|
|
340
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
341
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
342
|
+
rootKeySet.set(rootKey, {
|
|
343
|
+
namespace: keyPrefix,
|
|
344
|
+
representationName: RepresentationType,
|
|
345
|
+
mergeable: false
|
|
346
|
+
});
|
|
347
|
+
return rootKeySet;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function select(luvio, params) {
|
|
351
|
+
return select$1();
|
|
352
|
+
}
|
|
353
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
354
|
+
return getTypeCacheKeys(luvio, response);
|
|
355
|
+
}
|
|
356
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
357
|
+
const { body } = response;
|
|
358
|
+
const key = keyBuilderFromType(luvio, body);
|
|
359
|
+
luvio.storeIngest(key, ingest, body);
|
|
360
|
+
const snapshot = luvio.storeLookup({
|
|
361
|
+
recordId: key,
|
|
362
|
+
node: select(),
|
|
363
|
+
variables: {},
|
|
364
|
+
});
|
|
365
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
366
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
367
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return snapshot;
|
|
371
|
+
}
|
|
372
|
+
function createResourceRequest(config) {
|
|
373
|
+
const headers = {};
|
|
374
|
+
return {
|
|
375
|
+
baseUri: '/services/data/v58.0',
|
|
376
|
+
basePath: '/connect/cpq/preview',
|
|
377
|
+
method: 'post',
|
|
378
|
+
body: config.body,
|
|
379
|
+
urlParams: {},
|
|
380
|
+
queryParams: {},
|
|
381
|
+
headers,
|
|
382
|
+
priority: 'normal',
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const preview_ConfigPropertyNames = {
|
|
387
|
+
displayName: 'preview',
|
|
388
|
+
parameters: {
|
|
389
|
+
required: ['previewInput'],
|
|
390
|
+
optional: []
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
function createResourceParams(config) {
|
|
394
|
+
const resourceParams = {
|
|
395
|
+
body: {
|
|
396
|
+
previewInput: config.previewInput
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
return resourceParams;
|
|
400
|
+
}
|
|
401
|
+
function typeCheckConfig(untrustedConfig) {
|
|
402
|
+
const config = {};
|
|
403
|
+
const untrustedConfig_previewInput = untrustedConfig.previewInput;
|
|
404
|
+
const referencePreviewInputRepresentationValidationError = validate$1(untrustedConfig_previewInput);
|
|
405
|
+
if (referencePreviewInputRepresentationValidationError === null) {
|
|
406
|
+
config.previewInput = untrustedConfig_previewInput;
|
|
407
|
+
}
|
|
408
|
+
return config;
|
|
409
|
+
}
|
|
410
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
411
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
415
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
416
|
+
}
|
|
417
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
418
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
return config;
|
|
422
|
+
}
|
|
423
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
424
|
+
const resourceParams = createResourceParams(config);
|
|
425
|
+
const request = createResourceRequest(resourceParams);
|
|
426
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
427
|
+
.then((response) => {
|
|
428
|
+
return luvio.handleSuccessResponse(() => {
|
|
429
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
430
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
431
|
+
}, () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
432
|
+
}, (response) => {
|
|
433
|
+
deepFreeze$1(response);
|
|
434
|
+
throw response;
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
const previewAdapterFactory = (luvio) => {
|
|
438
|
+
return function preview(untrustedConfig) {
|
|
439
|
+
const config = validateAdapterConfig(untrustedConfig, preview_ConfigPropertyNames);
|
|
440
|
+
// Invalid or incomplete config
|
|
441
|
+
if (config === null) {
|
|
442
|
+
throw new Error('Invalid config for "preview"');
|
|
443
|
+
}
|
|
444
|
+
return buildNetworkSnapshot(luvio, config);
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
export { previewAdapterFactory };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot } from '@luvio/engine';
|
|
2
|
+
export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
|
|
3
|
+
declare const ObjectKeys: {
|
|
4
|
+
(o: object): string[];
|
|
5
|
+
(o: {}): string[];
|
|
6
|
+
}, ObjectFreeze: {
|
|
7
|
+
<T extends Function>(f: T): T;
|
|
8
|
+
<T_1 extends {
|
|
9
|
+
[idx: string]: object | U | null | undefined;
|
|
10
|
+
}, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>;
|
|
11
|
+
<T_2>(o: T_2): Readonly<T_2>;
|
|
12
|
+
}, ObjectCreate: {
|
|
13
|
+
(o: object | null): any;
|
|
14
|
+
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
15
|
+
};
|
|
16
|
+
export { ObjectFreeze, ObjectCreate, ObjectKeys };
|
|
17
|
+
export declare const ArrayIsArray: (arg: any) => arg is any[];
|
|
18
|
+
export declare const ArrayPrototypePush: (...items: any[]) => number;
|
|
19
|
+
export interface AdapterValidationConfig {
|
|
20
|
+
displayName: string;
|
|
21
|
+
parameters: {
|
|
22
|
+
required: string[];
|
|
23
|
+
optional: string[];
|
|
24
|
+
unsupported?: string[];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates an adapter config is well-formed.
|
|
29
|
+
* @param config The config to validate.
|
|
30
|
+
* @param adapter The adapter validation configuration.
|
|
31
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
32
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateConfig<T>(config: Untrusted<T>, adapter: AdapterValidationConfig, oneOf?: string[]): void;
|
|
35
|
+
export declare function untrustedIsObject<Base>(untrusted: unknown): untrusted is Untrusted<Base>;
|
|
36
|
+
export type UncoercedConfiguration<Base, Options extends {
|
|
37
|
+
[key in keyof Base]?: any;
|
|
38
|
+
}> = {
|
|
39
|
+
[Key in keyof Base]?: Base[Key] | Options[Key];
|
|
40
|
+
};
|
|
41
|
+
export type Untrusted<Base> = Partial<Base>;
|
|
42
|
+
export declare function areRequiredParametersPresent<T>(config: any, configPropertyNames: AdapterValidationConfig): config is T;
|
|
43
|
+
export declare function refreshable<C, D, R>(adapter: $64$luvio_engine_Adapter<C, D>, resolve: (config: unknown) => Promise<$64$luvio_engine_Snapshot<R>>): $64$luvio_engine_Adapter<C, D>;
|
|
44
|
+
export declare const SNAPSHOT_STATE_FULFILLED = "Fulfilled";
|
|
45
|
+
export declare const SNAPSHOT_STATE_UNFULFILLED = "Unfulfilled";
|
|
46
|
+
export declare const snapshotRefreshOptions: {
|
|
47
|
+
overrides: {
|
|
48
|
+
headers: {
|
|
49
|
+
'Cache-Control': string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
|
|
55
|
+
* This is needed because insertion order for JSON.stringify(object) affects output:
|
|
56
|
+
* JSON.stringify({a: 1, b: 2})
|
|
57
|
+
* "{"a":1,"b":2}"
|
|
58
|
+
* JSON.stringify({b: 2, a: 1})
|
|
59
|
+
* "{"b":2,"a":1}"
|
|
60
|
+
* @param data Data to be JSON-stringified.
|
|
61
|
+
* @returns JSON.stringified value with consistent ordering of keys.
|
|
62
|
+
*/
|
|
63
|
+
export declare function stableJSONStringify(node: any): string | undefined;
|
|
64
|
+
export declare function getFetchResponseStatusText(status: number): string;
|
|
65
|
+
export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
|
|
66
|
+
export declare const keyPrefix = "cpq";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig, Untrusted as adapter$45$utils_Untrusted } from './adapter-utils';
|
|
2
|
+
import { PreviewInputRepresentation as types_PreviewInputRepresentation_PreviewInputRepresentation } from '../types/PreviewInputRepresentation';
|
|
3
|
+
import { ResourceRequestConfig as resources_postConnectCpqPreview_ResourceRequestConfig } from '../resources/postConnectCpqPreview';
|
|
4
|
+
import { Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
|
|
5
|
+
import { CpqBaseListOutputRepresentation as types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation } from '../types/CpqBaseListOutputRepresentation';
|
|
6
|
+
export declare const adapterName = "preview";
|
|
7
|
+
export declare const preview_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
|
|
8
|
+
export interface PreviewConfig {
|
|
9
|
+
previewInput: types_PreviewInputRepresentation_PreviewInputRepresentation;
|
|
10
|
+
}
|
|
11
|
+
export declare function createResourceParams(config: PreviewConfig): resources_postConnectCpqPreview_ResourceRequestConfig;
|
|
12
|
+
export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<PreviewConfig>): adapter$45$utils_Untrusted<PreviewConfig>;
|
|
13
|
+
export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): PreviewConfig | null;
|
|
14
|
+
export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: PreviewConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation, any>>;
|
|
15
|
+
export declare const previewAdapterFactory: $64$luvio_engine_AdapterFactory<PreviewConfig, types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { previewAdapterFactory } from '../adapters/preview';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PreviewInputRepresentation as types_PreviewInputRepresentation_PreviewInputRepresentation } from '../types/PreviewInputRepresentation';
|
|
2
|
+
import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, FetchResponse as $64$luvio_engine_FetchResponse, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
|
|
3
|
+
import { CpqBaseListOutputRepresentation as types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation } from '../types/CpqBaseListOutputRepresentation';
|
|
4
|
+
export interface ResourceRequestConfig {
|
|
5
|
+
body: {
|
|
6
|
+
previewInput: types_PreviewInputRepresentation_PreviewInputRepresentation;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
|
|
10
|
+
export declare function getResponseCacheKeys(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation): $64$luvio_engine_DurableStoreKeyMetadataMap;
|
|
11
|
+
export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_CpqBaseListOutputRepresentation_CpqBaseListOutputRepresentation, any>;
|
|
12
|
+
export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
|
|
13
|
+
export default createResourceRequest;
|