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