@salesforce/lds-adapters-industries-decisiontable 1.248.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt 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,573 @@
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, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$1, StoreKeyMap, createResourceParams as createResourceParams$1 } from '@luvio/engine';
8
+
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys, create: ObjectCreate } = 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(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
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
52
+ return {
53
+ name,
54
+ required,
55
+ resourceType,
56
+ typeCheckShape,
57
+ isArrayShape,
58
+ coerceFn,
59
+ };
60
+ }
61
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
62
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
63
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
64
+ return {
65
+ displayName,
66
+ parameters: {
67
+ required,
68
+ optional,
69
+ }
70
+ };
71
+ }
72
+ const keyPrefix = 'DecisionTable';
73
+
74
+ const { isArray: ArrayIsArray } = Array;
75
+ const { stringify: JSONStringify } = JSON;
76
+ function createLink(ref) {
77
+ return {
78
+ __ref: serializeStructuredKey(ref),
79
+ };
80
+ }
81
+
82
+ function validate$3(obj, path = 'DecisionTableParameterOutputRepresentation') {
83
+ const v_error = (() => {
84
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
85
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
86
+ }
87
+ if (obj.columnMapping !== undefined) {
88
+ const obj_columnMapping = obj.columnMapping;
89
+ const path_columnMapping = path + '.columnMapping';
90
+ if (typeof obj_columnMapping !== 'string') {
91
+ return new TypeError('Expected "string" but received "' + typeof obj_columnMapping + '" (at "' + path_columnMapping + '")');
92
+ }
93
+ }
94
+ if (obj.dataType !== undefined) {
95
+ const obj_dataType = obj.dataType;
96
+ const path_dataType = path + '.dataType';
97
+ if (typeof obj_dataType !== 'string') {
98
+ return new TypeError('Expected "string" but received "' + typeof obj_dataType + '" (at "' + path_dataType + '")');
99
+ }
100
+ }
101
+ if (obj.decimalScale !== undefined) {
102
+ const obj_decimalScale = obj.decimalScale;
103
+ const path_decimalScale = path + '.decimalScale';
104
+ if (typeof obj_decimalScale !== 'number' || (typeof obj_decimalScale === 'number' && Math.floor(obj_decimalScale) !== obj_decimalScale)) {
105
+ return new TypeError('Expected "integer" but received "' + typeof obj_decimalScale + '" (at "' + path_decimalScale + '")');
106
+ }
107
+ }
108
+ if (obj.domainEntity !== undefined) {
109
+ const obj_domainEntity = obj.domainEntity;
110
+ const path_domainEntity = path + '.domainEntity';
111
+ if (typeof obj_domainEntity !== 'string') {
112
+ return new TypeError('Expected "string" but received "' + typeof obj_domainEntity + '" (at "' + path_domainEntity + '")');
113
+ }
114
+ }
115
+ if (obj.fieldName !== undefined) {
116
+ const obj_fieldName = obj.fieldName;
117
+ const path_fieldName = path + '.fieldName';
118
+ if (typeof obj_fieldName !== 'string') {
119
+ return new TypeError('Expected "string" but received "' + typeof obj_fieldName + '" (at "' + path_fieldName + '")');
120
+ }
121
+ }
122
+ if (obj.isGroupByField !== undefined) {
123
+ const obj_isGroupByField = obj.isGroupByField;
124
+ const path_isGroupByField = path + '.isGroupByField';
125
+ if (typeof obj_isGroupByField !== 'boolean') {
126
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isGroupByField + '" (at "' + path_isGroupByField + '")');
127
+ }
128
+ }
129
+ if (obj.isPriority !== undefined) {
130
+ const obj_isPriority = obj.isPriority;
131
+ const path_isPriority = path + '.isPriority';
132
+ if (typeof obj_isPriority !== 'boolean') {
133
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isPriority + '" (at "' + path_isPriority + '")');
134
+ }
135
+ }
136
+ if (obj.isRequired !== undefined) {
137
+ const obj_isRequired = obj.isRequired;
138
+ const path_isRequired = path + '.isRequired';
139
+ if (typeof obj_isRequired !== 'boolean') {
140
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isRequired + '" (at "' + path_isRequired + '")');
141
+ }
142
+ }
143
+ if (obj.maxlength !== undefined) {
144
+ const obj_maxlength = obj.maxlength;
145
+ const path_maxlength = path + '.maxlength';
146
+ if (typeof obj_maxlength !== 'number' || (typeof obj_maxlength === 'number' && Math.floor(obj_maxlength) !== obj_maxlength)) {
147
+ return new TypeError('Expected "integer" but received "' + typeof obj_maxlength + '" (at "' + path_maxlength + '")');
148
+ }
149
+ }
150
+ if (obj.operator !== undefined) {
151
+ const obj_operator = obj.operator;
152
+ const path_operator = path + '.operator';
153
+ if (typeof obj_operator !== 'string') {
154
+ return new TypeError('Expected "string" but received "' + typeof obj_operator + '" (at "' + path_operator + '")');
155
+ }
156
+ }
157
+ if (obj.sequence !== undefined) {
158
+ const obj_sequence = obj.sequence;
159
+ const path_sequence = path + '.sequence';
160
+ if (typeof obj_sequence !== 'number' || (typeof obj_sequence === 'number' && Math.floor(obj_sequence) !== obj_sequence)) {
161
+ return new TypeError('Expected "integer" but received "' + typeof obj_sequence + '" (at "' + path_sequence + '")');
162
+ }
163
+ }
164
+ if (obj.sortType !== undefined) {
165
+ const obj_sortType = obj.sortType;
166
+ const path_sortType = path + '.sortType';
167
+ if (typeof obj_sortType !== 'string') {
168
+ return new TypeError('Expected "string" but received "' + typeof obj_sortType + '" (at "' + path_sortType + '")');
169
+ }
170
+ }
171
+ if (obj.usage !== undefined) {
172
+ const obj_usage = obj.usage;
173
+ const path_usage = path + '.usage';
174
+ if (typeof obj_usage !== 'string') {
175
+ return new TypeError('Expected "string" but received "' + typeof obj_usage + '" (at "' + path_usage + '")');
176
+ }
177
+ }
178
+ })();
179
+ return v_error === undefined ? null : v_error;
180
+ }
181
+
182
+ function validate$2(obj, path = 'DecisionTableSourceCriteriaOutputRepresentation') {
183
+ const v_error = (() => {
184
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
185
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
186
+ }
187
+ if (obj.operator !== undefined) {
188
+ const obj_operator = obj.operator;
189
+ const path_operator = path + '.operator';
190
+ if (typeof obj_operator !== 'string') {
191
+ return new TypeError('Expected "string" but received "' + typeof obj_operator + '" (at "' + path_operator + '")');
192
+ }
193
+ }
194
+ if (obj.sequenceNumber !== undefined) {
195
+ const obj_sequenceNumber = obj.sequenceNumber;
196
+ const path_sequenceNumber = path + '.sequenceNumber';
197
+ if (typeof obj_sequenceNumber !== 'number' || (typeof obj_sequenceNumber === 'number' && Math.floor(obj_sequenceNumber) !== obj_sequenceNumber)) {
198
+ return new TypeError('Expected "integer" but received "' + typeof obj_sequenceNumber + '" (at "' + path_sequenceNumber + '")');
199
+ }
200
+ }
201
+ if (obj.sourceFieldName !== undefined) {
202
+ const obj_sourceFieldName = obj.sourceFieldName;
203
+ const path_sourceFieldName = path + '.sourceFieldName';
204
+ if (typeof obj_sourceFieldName !== 'string') {
205
+ return new TypeError('Expected "string" but received "' + typeof obj_sourceFieldName + '" (at "' + path_sourceFieldName + '")');
206
+ }
207
+ }
208
+ if (obj.value !== undefined) {
209
+ const obj_value = obj.value;
210
+ const path_value = path + '.value';
211
+ if (typeof obj_value !== 'string') {
212
+ return new TypeError('Expected "string" but received "' + typeof obj_value + '" (at "' + path_value + '")');
213
+ }
214
+ }
215
+ if (obj.valueType !== undefined) {
216
+ const obj_valueType = obj.valueType;
217
+ const path_valueType = path + '.valueType';
218
+ if (typeof obj_valueType !== 'string') {
219
+ return new TypeError('Expected "string" but received "' + typeof obj_valueType + '" (at "' + path_valueType + '")');
220
+ }
221
+ }
222
+ })();
223
+ return v_error === undefined ? null : v_error;
224
+ }
225
+
226
+ function validate$1(obj, path = 'DecisionTableDefinitionOutputRepresentation') {
227
+ const v_error = (() => {
228
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
229
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
230
+ }
231
+ if (obj.collectOperator !== undefined) {
232
+ const obj_collectOperator = obj.collectOperator;
233
+ const path_collectOperator = path + '.collectOperator';
234
+ if (typeof obj_collectOperator !== 'string') {
235
+ return new TypeError('Expected "string" but received "' + typeof obj_collectOperator + '" (at "' + path_collectOperator + '")');
236
+ }
237
+ }
238
+ if (obj.conditionCriteria !== undefined) {
239
+ const obj_conditionCriteria = obj.conditionCriteria;
240
+ const path_conditionCriteria = path + '.conditionCriteria';
241
+ if (typeof obj_conditionCriteria !== 'string') {
242
+ return new TypeError('Expected "string" but received "' + typeof obj_conditionCriteria + '" (at "' + path_conditionCriteria + '")');
243
+ }
244
+ }
245
+ if (obj.conditionType !== undefined) {
246
+ const obj_conditionType = obj.conditionType;
247
+ const path_conditionType = path + '.conditionType';
248
+ if (typeof obj_conditionType !== 'string') {
249
+ return new TypeError('Expected "string" but received "' + typeof obj_conditionType + '" (at "' + path_conditionType + '")');
250
+ }
251
+ }
252
+ if (obj.decisionResultPolicy !== undefined) {
253
+ const obj_decisionResultPolicy = obj.decisionResultPolicy;
254
+ const path_decisionResultPolicy = path + '.decisionResultPolicy';
255
+ if (typeof obj_decisionResultPolicy !== 'string') {
256
+ return new TypeError('Expected "string" but received "' + typeof obj_decisionResultPolicy + '" (at "' + path_decisionResultPolicy + '")');
257
+ }
258
+ }
259
+ if (obj.description !== undefined) {
260
+ const obj_description = obj.description;
261
+ const path_description = path + '.description';
262
+ if (typeof obj_description !== 'string') {
263
+ return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
264
+ }
265
+ }
266
+ if (obj.fullName !== undefined) {
267
+ const obj_fullName = obj.fullName;
268
+ const path_fullName = path + '.fullName';
269
+ if (typeof obj_fullName !== 'string') {
270
+ return new TypeError('Expected "string" but received "' + typeof obj_fullName + '" (at "' + path_fullName + '")');
271
+ }
272
+ }
273
+ if (obj.id !== undefined) {
274
+ const obj_id = obj.id;
275
+ const path_id = path + '.id';
276
+ if (typeof obj_id !== 'string') {
277
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
278
+ }
279
+ }
280
+ const obj_parameters = obj.parameters;
281
+ const path_parameters = path + '.parameters';
282
+ if (!ArrayIsArray(obj_parameters)) {
283
+ return new TypeError('Expected "array" but received "' + typeof obj_parameters + '" (at "' + path_parameters + '")');
284
+ }
285
+ for (let i = 0; i < obj_parameters.length; i++) {
286
+ const obj_parameters_item = obj_parameters[i];
287
+ const path_parameters_item = path_parameters + '[' + i + ']';
288
+ const referencepath_parameters_itemValidationError = validate$3(obj_parameters_item, path_parameters_item);
289
+ if (referencepath_parameters_itemValidationError !== null) {
290
+ let message = 'Object doesn\'t match DecisionTableParameterOutputRepresentation (at "' + path_parameters_item + '")\n';
291
+ message += referencepath_parameters_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
292
+ return new TypeError(message);
293
+ }
294
+ }
295
+ if (obj.setupName !== undefined) {
296
+ const obj_setupName = obj.setupName;
297
+ const path_setupName = path + '.setupName';
298
+ if (typeof obj_setupName !== 'string') {
299
+ return new TypeError('Expected "string" but received "' + typeof obj_setupName + '" (at "' + path_setupName + '")');
300
+ }
301
+ }
302
+ const obj_sourceCriteria = obj.sourceCriteria;
303
+ const path_sourceCriteria = path + '.sourceCriteria';
304
+ if (!ArrayIsArray(obj_sourceCriteria)) {
305
+ return new TypeError('Expected "array" but received "' + typeof obj_sourceCriteria + '" (at "' + path_sourceCriteria + '")');
306
+ }
307
+ for (let i = 0; i < obj_sourceCriteria.length; i++) {
308
+ const obj_sourceCriteria_item = obj_sourceCriteria[i];
309
+ const path_sourceCriteria_item = path_sourceCriteria + '[' + i + ']';
310
+ const referencepath_sourceCriteria_itemValidationError = validate$2(obj_sourceCriteria_item, path_sourceCriteria_item);
311
+ if (referencepath_sourceCriteria_itemValidationError !== null) {
312
+ let message = 'Object doesn\'t match DecisionTableSourceCriteriaOutputRepresentation (at "' + path_sourceCriteria_item + '")\n';
313
+ message += referencepath_sourceCriteria_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
314
+ return new TypeError(message);
315
+ }
316
+ }
317
+ if (obj.sourceObject !== undefined) {
318
+ const obj_sourceObject = obj.sourceObject;
319
+ const path_sourceObject = path + '.sourceObject';
320
+ if (typeof obj_sourceObject !== 'string') {
321
+ return new TypeError('Expected "string" but received "' + typeof obj_sourceObject + '" (at "' + path_sourceObject + '")');
322
+ }
323
+ }
324
+ if (obj.sourceType !== undefined) {
325
+ const obj_sourceType = obj.sourceType;
326
+ const path_sourceType = path + '.sourceType';
327
+ if (typeof obj_sourceType !== 'string') {
328
+ return new TypeError('Expected "string" but received "' + typeof obj_sourceType + '" (at "' + path_sourceType + '")');
329
+ }
330
+ }
331
+ if (obj.sourceconditionLogic !== undefined) {
332
+ const obj_sourceconditionLogic = obj.sourceconditionLogic;
333
+ const path_sourceconditionLogic = path + '.sourceconditionLogic';
334
+ if (typeof obj_sourceconditionLogic !== 'string') {
335
+ return new TypeError('Expected "string" but received "' + typeof obj_sourceconditionLogic + '" (at "' + path_sourceconditionLogic + '")');
336
+ }
337
+ }
338
+ if (obj.status !== undefined) {
339
+ const obj_status = obj.status;
340
+ const path_status = path + '.status';
341
+ if (typeof obj_status !== 'string') {
342
+ return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
343
+ }
344
+ }
345
+ if (obj.usageType !== undefined) {
346
+ const obj_usageType = obj.usageType;
347
+ const path_usageType = path + '.usageType';
348
+ if (typeof obj_usageType !== 'string') {
349
+ return new TypeError('Expected "string" but received "' + typeof obj_usageType + '" (at "' + path_usageType + '")');
350
+ }
351
+ }
352
+ })();
353
+ return v_error === undefined ? null : v_error;
354
+ }
355
+
356
+ const TTL = 1000;
357
+ const VERSION = "21435364536c593ed8b8972af7d154d5";
358
+ function validate(obj, path = 'DecisionTableOutputRepresentation') {
359
+ const v_error = (() => {
360
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
361
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
362
+ }
363
+ if (obj.code !== undefined) {
364
+ const obj_code = obj.code;
365
+ const path_code = path + '.code';
366
+ if (typeof obj_code !== 'string') {
367
+ return new TypeError('Expected "string" but received "' + typeof obj_code + '" (at "' + path_code + '")');
368
+ }
369
+ }
370
+ const obj_decisionTable = obj.decisionTable;
371
+ const path_decisionTable = path + '.decisionTable';
372
+ const referencepath_decisionTableValidationError = validate$1(obj_decisionTable, path_decisionTable);
373
+ if (referencepath_decisionTableValidationError !== null) {
374
+ let message = 'Object doesn\'t match DecisionTableDefinitionOutputRepresentation (at "' + path_decisionTable + '")\n';
375
+ message += referencepath_decisionTableValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
376
+ return new TypeError(message);
377
+ }
378
+ if (obj.isSuccess !== undefined) {
379
+ const obj_isSuccess = obj.isSuccess;
380
+ const path_isSuccess = path + '.isSuccess';
381
+ if (typeof obj_isSuccess !== 'boolean') {
382
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
383
+ }
384
+ }
385
+ if (obj.message !== undefined) {
386
+ const obj_message = obj.message;
387
+ const path_message = path + '.message';
388
+ if (typeof obj_message !== 'string') {
389
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
390
+ }
391
+ }
392
+ })();
393
+ return v_error === undefined ? null : v_error;
394
+ }
395
+ const RepresentationType = 'DecisionTableOutputRepresentation';
396
+ function normalize(input, existing, path, luvio, store, timestamp) {
397
+ return input;
398
+ }
399
+ const select$1 = function DecisionTableOutputRepresentationSelect() {
400
+ return {
401
+ kind: 'Fragment',
402
+ version: VERSION,
403
+ private: [],
404
+ opaque: true
405
+ };
406
+ };
407
+ function equals(existing, incoming) {
408
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
409
+ return false;
410
+ }
411
+ return true;
412
+ }
413
+ const ingest = function DecisionTableOutputRepresentationIngest(input, path, luvio, store, timestamp) {
414
+ if (process.env.NODE_ENV !== 'production') {
415
+ const validateError = validate(input);
416
+ if (validateError !== null) {
417
+ throw validateError;
418
+ }
419
+ }
420
+ const key = path.fullPath;
421
+ const ttlToUse = TTL;
422
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "DecisionTable", VERSION, RepresentationType, equals);
423
+ return createLink(key);
424
+ };
425
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
426
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
427
+ const rootKey = fullPathFactory();
428
+ rootKeySet.set(rootKey, {
429
+ namespace: keyPrefix,
430
+ representationName: RepresentationType,
431
+ mergeable: false
432
+ });
433
+ }
434
+
435
+ function select(luvio, params) {
436
+ return select$1();
437
+ }
438
+ function keyBuilder$1(luvio, params) {
439
+ return keyPrefix + '::DecisionTableOutputRepresentation:(' + 'decisionTableId:' + params.urlParams.decisionTableId + ')';
440
+ }
441
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
442
+ getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
443
+ }
444
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
445
+ const { body } = response;
446
+ const key = keyBuilder$1(luvio, resourceParams);
447
+ luvio.storeIngest(key, ingest, body);
448
+ const snapshot = luvio.storeLookup({
449
+ recordId: key,
450
+ node: select(),
451
+ variables: {},
452
+ }, snapshotRefresh);
453
+ if (process.env.NODE_ENV !== 'production') {
454
+ if (snapshot.state !== 'Fulfilled') {
455
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
456
+ }
457
+ }
458
+ deepFreeze(snapshot.data);
459
+ return snapshot;
460
+ }
461
+ function ingestError(luvio, params, error, snapshotRefresh) {
462
+ const key = keyBuilder$1(luvio, params);
463
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
464
+ const storeMetadataParams = {
465
+ ttl: TTL,
466
+ namespace: keyPrefix,
467
+ version: VERSION,
468
+ representationName: RepresentationType
469
+ };
470
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
471
+ return errorSnapshot;
472
+ }
473
+ function createResourceRequest(config) {
474
+ const headers = {};
475
+ return {
476
+ baseUri: '/services/data/v60.0',
477
+ basePath: '/connect/business-rules/decision-table/definitions/' + config.urlParams.decisionTableId + '',
478
+ method: 'get',
479
+ body: null,
480
+ urlParams: config.urlParams,
481
+ queryParams: {},
482
+ headers,
483
+ priority: 'normal',
484
+ };
485
+ }
486
+
487
+ const adapterName = 'getDecisionTable';
488
+ const getDecisionTable_ConfigPropertyMetadata = [
489
+ generateParamConfigMetadata('decisionTableId', true, 0 /* UrlParameter */, 0 /* String */),
490
+ ];
491
+ const getDecisionTable_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getDecisionTable_ConfigPropertyMetadata);
492
+ const createResourceParams = /*#__PURE__*/ createResourceParams$1(getDecisionTable_ConfigPropertyMetadata);
493
+ function keyBuilder(luvio, config) {
494
+ const resourceParams = createResourceParams(config);
495
+ return keyBuilder$1(luvio, resourceParams);
496
+ }
497
+ function typeCheckConfig(untrustedConfig) {
498
+ const config = {};
499
+ typeCheckConfig$1(untrustedConfig, config, getDecisionTable_ConfigPropertyMetadata);
500
+ return config;
501
+ }
502
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
503
+ if (!untrustedIsObject(untrustedConfig)) {
504
+ return null;
505
+ }
506
+ if (process.env.NODE_ENV !== 'production') {
507
+ validateConfig(untrustedConfig, configPropertyNames);
508
+ }
509
+ const config = typeCheckConfig(untrustedConfig);
510
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
511
+ return null;
512
+ }
513
+ return config;
514
+ }
515
+ function adapterFragment(luvio, config) {
516
+ createResourceParams(config);
517
+ return select();
518
+ }
519
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
520
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
521
+ config,
522
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
523
+ });
524
+ return luvio.storeBroadcast().then(() => snapshot);
525
+ }
526
+ function onFetchResponseError(luvio, config, resourceParams, response) {
527
+ const snapshot = ingestError(luvio, resourceParams, response, {
528
+ config,
529
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
530
+ });
531
+ return luvio.storeBroadcast().then(() => snapshot);
532
+ }
533
+ function buildNetworkSnapshot(luvio, config, options) {
534
+ const resourceParams = createResourceParams(config);
535
+ const request = createResourceRequest(resourceParams);
536
+ return luvio.dispatchResourceRequest(request, options)
537
+ .then((response) => {
538
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
539
+ const cache = new StoreKeyMap();
540
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
541
+ return cache;
542
+ });
543
+ }, (response) => {
544
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
545
+ });
546
+ }
547
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
548
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
549
+ }
550
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
551
+ const { luvio, config } = context;
552
+ const selector = {
553
+ recordId: keyBuilder(luvio, config),
554
+ node: adapterFragment(luvio, config),
555
+ variables: {},
556
+ };
557
+ const cacheSnapshot = storeLookup(selector, {
558
+ config,
559
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
560
+ });
561
+ return cacheSnapshot;
562
+ }
563
+ const getDecisionTableAdapterFactory = (luvio) => function DecisionTable__getDecisionTable(untrustedConfig, requestContext) {
564
+ const config = validateAdapterConfig(untrustedConfig, getDecisionTable_ConfigPropertyNames);
565
+ // Invalid or incomplete config
566
+ if (config === null) {
567
+ return null;
568
+ }
569
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
570
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
571
+ };
572
+
573
+ export { getDecisionTableAdapterFactory };