@salesforce/lds-adapters-industries-featurevalidation 0.1.0-dev1

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.
@@ -0,0 +1,647 @@
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, 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
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
45
+ return {
46
+ name,
47
+ required,
48
+ resourceType,
49
+ typeCheckShape,
50
+ isArrayShape,
51
+ coerceFn,
52
+ };
53
+ }
54
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
55
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
56
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
57
+ return {
58
+ displayName,
59
+ parameters: {
60
+ required,
61
+ optional,
62
+ }
63
+ };
64
+ }
65
+ const keyPrefix = 'featurevalidation';
66
+
67
+ const { isArray: ArrayIsArray } = Array;
68
+ function equalsArray(a, b, equalsItem) {
69
+ const aLength = a.length;
70
+ const bLength = b.length;
71
+ if (aLength !== bLength) {
72
+ return false;
73
+ }
74
+ for (let i = 0; i < aLength; i++) {
75
+ if (equalsItem(a[i], b[i]) === false) {
76
+ return false;
77
+ }
78
+ }
79
+ return true;
80
+ }
81
+ function createLink(ref) {
82
+ return {
83
+ __ref: serializeStructuredKey(ref),
84
+ };
85
+ }
86
+
87
+ function validate$4(obj, path = 'FeatureValidationInputRepresentation') {
88
+ const v_error = (() => {
89
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
90
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
91
+ }
92
+ const obj_featureValidationInputDetails = obj.featureValidationInputDetails;
93
+ const path_featureValidationInputDetails = path + '.featureValidationInputDetails';
94
+ if (!ArrayIsArray(obj_featureValidationInputDetails)) {
95
+ return new TypeError('Expected "array" but received "' + typeof obj_featureValidationInputDetails + '" (at "' + path_featureValidationInputDetails + '")');
96
+ }
97
+ for (let i = 0; i < obj_featureValidationInputDetails.length; i++) {
98
+ const obj_featureValidationInputDetails_item = obj_featureValidationInputDetails[i];
99
+ const path_featureValidationInputDetails_item = path_featureValidationInputDetails + '[' + i + ']';
100
+ if (typeof obj_featureValidationInputDetails_item !== 'object' || ArrayIsArray(obj_featureValidationInputDetails_item) || obj_featureValidationInputDetails_item === null) {
101
+ return new TypeError('Expected "object" but received "' + typeof obj_featureValidationInputDetails_item + '" (at "' + path_featureValidationInputDetails_item + '")');
102
+ }
103
+ }
104
+ const obj_useCase = obj.useCase;
105
+ const path_useCase = path + '.useCase';
106
+ if (typeof obj_useCase !== 'string') {
107
+ return new TypeError('Expected "string" but received "' + typeof obj_useCase + '" (at "' + path_useCase + '")');
108
+ }
109
+ })();
110
+ return v_error === undefined ? null : v_error;
111
+ }
112
+
113
+ const VERSION$3 = "0d47ccdcf5db6f8d66e7eef5eecfea77";
114
+ function validate$3(obj, path = 'FeatureValidationAccessInfoRepresentation') {
115
+ const v_error = (() => {
116
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
117
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
118
+ }
119
+ const obj_accessLevel = obj.accessLevel;
120
+ const path_accessLevel = path + '.accessLevel';
121
+ if (typeof obj_accessLevel !== 'string') {
122
+ return new TypeError('Expected "string" but received "' + typeof obj_accessLevel + '" (at "' + path_accessLevel + '")');
123
+ }
124
+ const obj_apiName = obj.apiName;
125
+ const path_apiName = path + '.apiName';
126
+ if (typeof obj_apiName !== 'string') {
127
+ return new TypeError('Expected "string" but received "' + typeof obj_apiName + '" (at "' + path_apiName + '")');
128
+ }
129
+ const obj_hasAccess = obj.hasAccess;
130
+ const path_hasAccess = path + '.hasAccess';
131
+ if (typeof obj_hasAccess !== 'boolean') {
132
+ return new TypeError('Expected "boolean" but received "' + typeof obj_hasAccess + '" (at "' + path_hasAccess + '")');
133
+ }
134
+ const obj_type = obj.type;
135
+ const path_type = path + '.type';
136
+ if (typeof obj_type !== 'string') {
137
+ return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
138
+ }
139
+ })();
140
+ return v_error === undefined ? null : v_error;
141
+ }
142
+ const select$4 = function FeatureValidationAccessInfoRepresentationSelect() {
143
+ return {
144
+ kind: 'Fragment',
145
+ version: VERSION$3,
146
+ private: [],
147
+ selections: [
148
+ {
149
+ name: 'accessLevel',
150
+ kind: 'Scalar'
151
+ },
152
+ {
153
+ name: 'apiName',
154
+ kind: 'Scalar'
155
+ },
156
+ {
157
+ name: 'hasAccess',
158
+ kind: 'Scalar'
159
+ },
160
+ {
161
+ name: 'type',
162
+ kind: 'Scalar'
163
+ }
164
+ ]
165
+ };
166
+ };
167
+ function equals$3(existing, incoming) {
168
+ const existing_hasAccess = existing.hasAccess;
169
+ const incoming_hasAccess = incoming.hasAccess;
170
+ if (!(existing_hasAccess === incoming_hasAccess)) {
171
+ return false;
172
+ }
173
+ const existing_accessLevel = existing.accessLevel;
174
+ const incoming_accessLevel = incoming.accessLevel;
175
+ if (!(existing_accessLevel === incoming_accessLevel)) {
176
+ return false;
177
+ }
178
+ const existing_apiName = existing.apiName;
179
+ const incoming_apiName = incoming.apiName;
180
+ if (!(existing_apiName === incoming_apiName)) {
181
+ return false;
182
+ }
183
+ const existing_type = existing.type;
184
+ const incoming_type = incoming.type;
185
+ if (!(existing_type === incoming_type)) {
186
+ return false;
187
+ }
188
+ return true;
189
+ }
190
+
191
+ const VERSION$2 = "8b64929ba3ec78671e1ff0f37e0e40bf";
192
+ function validate$2(obj, path = 'FeatureValidationFieldValuesRepresentation') {
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
+ const obj_fieldName = obj.fieldName;
198
+ const path_fieldName = path + '.fieldName';
199
+ if (typeof obj_fieldName !== 'string') {
200
+ return new TypeError('Expected "string" but received "' + typeof obj_fieldName + '" (at "' + path_fieldName + '")');
201
+ }
202
+ const obj_fieldValue = obj.fieldValue;
203
+ const path_fieldValue = path + '.fieldValue';
204
+ if (typeof obj_fieldValue !== 'string') {
205
+ return new TypeError('Expected "string" but received "' + typeof obj_fieldValue + '" (at "' + path_fieldValue + '")');
206
+ }
207
+ const obj_message = obj.message;
208
+ const path_message = path + '.message';
209
+ if (typeof obj_message !== 'string') {
210
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
211
+ }
212
+ const obj_messageType = obj.messageType;
213
+ const path_messageType = path + '.messageType';
214
+ if (typeof obj_messageType !== 'string') {
215
+ return new TypeError('Expected "string" but received "' + typeof obj_messageType + '" (at "' + path_messageType + '")');
216
+ }
217
+ const obj_required = obj.required;
218
+ const path_required = path + '.required';
219
+ if (typeof obj_required !== 'boolean') {
220
+ return new TypeError('Expected "boolean" but received "' + typeof obj_required + '" (at "' + path_required + '")');
221
+ }
222
+ })();
223
+ return v_error === undefined ? null : v_error;
224
+ }
225
+ const select$3 = function FeatureValidationFieldValuesRepresentationSelect() {
226
+ return {
227
+ kind: 'Fragment',
228
+ version: VERSION$2,
229
+ private: [],
230
+ selections: [
231
+ {
232
+ name: 'fieldName',
233
+ kind: 'Scalar'
234
+ },
235
+ {
236
+ name: 'fieldValue',
237
+ kind: 'Scalar'
238
+ },
239
+ {
240
+ name: 'message',
241
+ kind: 'Scalar'
242
+ },
243
+ {
244
+ name: 'messageType',
245
+ kind: 'Scalar'
246
+ },
247
+ {
248
+ name: 'required',
249
+ kind: 'Scalar'
250
+ }
251
+ ]
252
+ };
253
+ };
254
+ function equals$2(existing, incoming) {
255
+ const existing_required = existing.required;
256
+ const incoming_required = incoming.required;
257
+ if (!(existing_required === incoming_required)) {
258
+ return false;
259
+ }
260
+ const existing_fieldName = existing.fieldName;
261
+ const incoming_fieldName = incoming.fieldName;
262
+ if (!(existing_fieldName === incoming_fieldName)) {
263
+ return false;
264
+ }
265
+ const existing_fieldValue = existing.fieldValue;
266
+ const incoming_fieldValue = incoming.fieldValue;
267
+ if (!(existing_fieldValue === incoming_fieldValue)) {
268
+ return false;
269
+ }
270
+ const existing_message = existing.message;
271
+ const incoming_message = incoming.message;
272
+ if (!(existing_message === incoming_message)) {
273
+ return false;
274
+ }
275
+ const existing_messageType = existing.messageType;
276
+ const incoming_messageType = incoming.messageType;
277
+ if (!(existing_messageType === incoming_messageType)) {
278
+ return false;
279
+ }
280
+ return true;
281
+ }
282
+
283
+ const VERSION$1 = "a1bf162cf98bc525d53bc137d27b2086";
284
+ function validate$1(obj, path = 'FeatureValidationOutputDetailsRepresentation') {
285
+ const v_error = (() => {
286
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
287
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
288
+ }
289
+ const obj_bpoName = obj.bpoName;
290
+ const path_bpoName = path + '.bpoName';
291
+ if (typeof obj_bpoName !== 'string') {
292
+ return new TypeError('Expected "string" but received "' + typeof obj_bpoName + '" (at "' + path_bpoName + '")');
293
+ }
294
+ const obj_bpoRecordId = obj.bpoRecordId;
295
+ const path_bpoRecordId = path + '.bpoRecordId';
296
+ if (typeof obj_bpoRecordId !== 'string') {
297
+ return new TypeError('Expected "string" but received "' + typeof obj_bpoRecordId + '" (at "' + path_bpoRecordId + '")');
298
+ }
299
+ const obj_featureValidationAccessInfo = obj.featureValidationAccessInfo;
300
+ const path_featureValidationAccessInfo = path + '.featureValidationAccessInfo';
301
+ if (!ArrayIsArray(obj_featureValidationAccessInfo)) {
302
+ return new TypeError('Expected "array" but received "' + typeof obj_featureValidationAccessInfo + '" (at "' + path_featureValidationAccessInfo + '")');
303
+ }
304
+ for (let i = 0; i < obj_featureValidationAccessInfo.length; i++) {
305
+ const obj_featureValidationAccessInfo_item = obj_featureValidationAccessInfo[i];
306
+ const path_featureValidationAccessInfo_item = path_featureValidationAccessInfo + '[' + i + ']';
307
+ const referencepath_featureValidationAccessInfo_itemValidationError = validate$3(obj_featureValidationAccessInfo_item, path_featureValidationAccessInfo_item);
308
+ if (referencepath_featureValidationAccessInfo_itemValidationError !== null) {
309
+ let message = 'Object doesn\'t match FeatureValidationAccessInfoRepresentation (at "' + path_featureValidationAccessInfo_item + '")\n';
310
+ message += referencepath_featureValidationAccessInfo_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
311
+ return new TypeError(message);
312
+ }
313
+ }
314
+ const obj_featureValidationFieldValues = obj.featureValidationFieldValues;
315
+ const path_featureValidationFieldValues = path + '.featureValidationFieldValues';
316
+ if (!ArrayIsArray(obj_featureValidationFieldValues)) {
317
+ return new TypeError('Expected "array" but received "' + typeof obj_featureValidationFieldValues + '" (at "' + path_featureValidationFieldValues + '")');
318
+ }
319
+ for (let i = 0; i < obj_featureValidationFieldValues.length; i++) {
320
+ const obj_featureValidationFieldValues_item = obj_featureValidationFieldValues[i];
321
+ const path_featureValidationFieldValues_item = path_featureValidationFieldValues + '[' + i + ']';
322
+ const referencepath_featureValidationFieldValues_itemValidationError = validate$2(obj_featureValidationFieldValues_item, path_featureValidationFieldValues_item);
323
+ if (referencepath_featureValidationFieldValues_itemValidationError !== null) {
324
+ let message = 'Object doesn\'t match FeatureValidationFieldValuesRepresentation (at "' + path_featureValidationFieldValues_item + '")\n';
325
+ message += referencepath_featureValidationFieldValues_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
326
+ return new TypeError(message);
327
+ }
328
+ }
329
+ const obj_message = obj.message;
330
+ const path_message = path + '.message';
331
+ if (typeof obj_message !== 'string') {
332
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
333
+ }
334
+ const obj_messageType = obj.messageType;
335
+ const path_messageType = path + '.messageType';
336
+ if (typeof obj_messageType !== 'string') {
337
+ return new TypeError('Expected "string" but received "' + typeof obj_messageType + '" (at "' + path_messageType + '")');
338
+ }
339
+ })();
340
+ return v_error === undefined ? null : v_error;
341
+ }
342
+ const select$2 = function FeatureValidationOutputDetailsRepresentationSelect() {
343
+ const { selections: FeatureValidationAccessInfoRepresentation__selections, opaque: FeatureValidationAccessInfoRepresentation__opaque, } = select$4();
344
+ const { selections: FeatureValidationFieldValuesRepresentation__selections, opaque: FeatureValidationFieldValuesRepresentation__opaque, } = select$3();
345
+ return {
346
+ kind: 'Fragment',
347
+ version: VERSION$1,
348
+ private: [],
349
+ selections: [
350
+ {
351
+ name: 'bpoName',
352
+ kind: 'Scalar'
353
+ },
354
+ {
355
+ name: 'bpoRecordId',
356
+ kind: 'Scalar'
357
+ },
358
+ {
359
+ name: 'featureValidationAccessInfo',
360
+ kind: 'Object',
361
+ plural: true,
362
+ selections: FeatureValidationAccessInfoRepresentation__selections
363
+ },
364
+ {
365
+ name: 'featureValidationFieldValues',
366
+ kind: 'Object',
367
+ plural: true,
368
+ selections: FeatureValidationFieldValuesRepresentation__selections
369
+ },
370
+ {
371
+ name: 'message',
372
+ kind: 'Scalar'
373
+ },
374
+ {
375
+ name: 'messageType',
376
+ kind: 'Scalar'
377
+ }
378
+ ]
379
+ };
380
+ };
381
+ function equals$1(existing, incoming) {
382
+ const existing_bpoName = existing.bpoName;
383
+ const incoming_bpoName = incoming.bpoName;
384
+ if (!(existing_bpoName === incoming_bpoName)) {
385
+ return false;
386
+ }
387
+ const existing_bpoRecordId = existing.bpoRecordId;
388
+ const incoming_bpoRecordId = incoming.bpoRecordId;
389
+ if (!(existing_bpoRecordId === incoming_bpoRecordId)) {
390
+ return false;
391
+ }
392
+ const existing_message = existing.message;
393
+ const incoming_message = incoming.message;
394
+ if (!(existing_message === incoming_message)) {
395
+ return false;
396
+ }
397
+ const existing_messageType = existing.messageType;
398
+ const incoming_messageType = incoming.messageType;
399
+ if (!(existing_messageType === incoming_messageType)) {
400
+ return false;
401
+ }
402
+ const existing_featureValidationAccessInfo = existing.featureValidationAccessInfo;
403
+ const incoming_featureValidationAccessInfo = incoming.featureValidationAccessInfo;
404
+ const equals_featureValidationAccessInfo_items = equalsArray(existing_featureValidationAccessInfo, incoming_featureValidationAccessInfo, (existing_featureValidationAccessInfo_item, incoming_featureValidationAccessInfo_item) => {
405
+ if (!(equals$3(existing_featureValidationAccessInfo_item, incoming_featureValidationAccessInfo_item))) {
406
+ return false;
407
+ }
408
+ });
409
+ if (equals_featureValidationAccessInfo_items === false) {
410
+ return false;
411
+ }
412
+ const existing_featureValidationFieldValues = existing.featureValidationFieldValues;
413
+ const incoming_featureValidationFieldValues = incoming.featureValidationFieldValues;
414
+ const equals_featureValidationFieldValues_items = equalsArray(existing_featureValidationFieldValues, incoming_featureValidationFieldValues, (existing_featureValidationFieldValues_item, incoming_featureValidationFieldValues_item) => {
415
+ if (!(equals$2(existing_featureValidationFieldValues_item, incoming_featureValidationFieldValues_item))) {
416
+ return false;
417
+ }
418
+ });
419
+ if (equals_featureValidationFieldValues_items === false) {
420
+ return false;
421
+ }
422
+ return true;
423
+ }
424
+
425
+ const TTL = 300;
426
+ const VERSION = "cca11a8e3ab8424bcce64057aad4f46d";
427
+ function validate(obj, path = 'FeatureValidationOutputRepresentation') {
428
+ const v_error = (() => {
429
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
430
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
431
+ }
432
+ if (obj.errorMessage !== undefined) {
433
+ const obj_errorMessage = obj.errorMessage;
434
+ const path_errorMessage = path + '.errorMessage';
435
+ if (typeof obj_errorMessage !== 'string') {
436
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
437
+ }
438
+ }
439
+ const obj_featureValidationOutputDetails = obj.featureValidationOutputDetails;
440
+ const path_featureValidationOutputDetails = path + '.featureValidationOutputDetails';
441
+ if (!ArrayIsArray(obj_featureValidationOutputDetails)) {
442
+ return new TypeError('Expected "array" but received "' + typeof obj_featureValidationOutputDetails + '" (at "' + path_featureValidationOutputDetails + '")');
443
+ }
444
+ for (let i = 0; i < obj_featureValidationOutputDetails.length; i++) {
445
+ const obj_featureValidationOutputDetails_item = obj_featureValidationOutputDetails[i];
446
+ const path_featureValidationOutputDetails_item = path_featureValidationOutputDetails + '[' + i + ']';
447
+ const referencepath_featureValidationOutputDetails_itemValidationError = validate$1(obj_featureValidationOutputDetails_item, path_featureValidationOutputDetails_item);
448
+ if (referencepath_featureValidationOutputDetails_itemValidationError !== null) {
449
+ let message = 'Object doesn\'t match FeatureValidationOutputDetailsRepresentation (at "' + path_featureValidationOutputDetails_item + '")\n';
450
+ message += referencepath_featureValidationOutputDetails_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
451
+ return new TypeError(message);
452
+ }
453
+ }
454
+ const obj_isSuccess = obj.isSuccess;
455
+ const path_isSuccess = path + '.isSuccess';
456
+ if (typeof obj_isSuccess !== 'boolean') {
457
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
458
+ }
459
+ })();
460
+ return v_error === undefined ? null : v_error;
461
+ }
462
+ const RepresentationType = 'FeatureValidationOutputRepresentation';
463
+ function keyBuilder(luvio, config) {
464
+ return keyPrefix + '::' + RepresentationType + ':' + config.isSuccess;
465
+ }
466
+ function keyBuilderFromType(luvio, object) {
467
+ const keyParams = {
468
+ isSuccess: object.isSuccess
469
+ };
470
+ return keyBuilder(luvio, keyParams);
471
+ }
472
+ function normalize(input, existing, path, luvio, store, timestamp) {
473
+ return input;
474
+ }
475
+ const select$1 = function FeatureValidationOutputRepresentationSelect() {
476
+ const { selections: FeatureValidationOutputDetailsRepresentation__selections, opaque: FeatureValidationOutputDetailsRepresentation__opaque, } = select$2();
477
+ return {
478
+ kind: 'Fragment',
479
+ version: VERSION,
480
+ private: [],
481
+ selections: [
482
+ {
483
+ name: 'errorMessage',
484
+ kind: 'Scalar',
485
+ required: false
486
+ },
487
+ {
488
+ name: 'featureValidationOutputDetails',
489
+ kind: 'Object',
490
+ plural: true,
491
+ selections: FeatureValidationOutputDetailsRepresentation__selections
492
+ },
493
+ {
494
+ name: 'isSuccess',
495
+ kind: 'Scalar'
496
+ }
497
+ ]
498
+ };
499
+ };
500
+ function equals(existing, incoming) {
501
+ const existing_isSuccess = existing.isSuccess;
502
+ const incoming_isSuccess = incoming.isSuccess;
503
+ if (!(existing_isSuccess === incoming_isSuccess)) {
504
+ return false;
505
+ }
506
+ const existing_errorMessage = existing.errorMessage;
507
+ const incoming_errorMessage = incoming.errorMessage;
508
+ // if at least one of these optionals is defined
509
+ if (existing_errorMessage !== undefined || incoming_errorMessage !== undefined) {
510
+ // if one of these is not defined we know the other is defined and therefore
511
+ // not equal
512
+ if (existing_errorMessage === undefined || incoming_errorMessage === undefined) {
513
+ return false;
514
+ }
515
+ if (!(existing_errorMessage === incoming_errorMessage)) {
516
+ return false;
517
+ }
518
+ }
519
+ const existing_featureValidationOutputDetails = existing.featureValidationOutputDetails;
520
+ const incoming_featureValidationOutputDetails = incoming.featureValidationOutputDetails;
521
+ const equals_featureValidationOutputDetails_items = equalsArray(existing_featureValidationOutputDetails, incoming_featureValidationOutputDetails, (existing_featureValidationOutputDetails_item, incoming_featureValidationOutputDetails_item) => {
522
+ if (!(equals$1(existing_featureValidationOutputDetails_item, incoming_featureValidationOutputDetails_item))) {
523
+ return false;
524
+ }
525
+ });
526
+ if (equals_featureValidationOutputDetails_items === false) {
527
+ return false;
528
+ }
529
+ return true;
530
+ }
531
+ const ingest = function FeatureValidationOutputRepresentationIngest(input, path, luvio, store, timestamp) {
532
+ if (process.env.NODE_ENV !== 'production') {
533
+ const validateError = validate(input);
534
+ if (validateError !== null) {
535
+ throw validateError;
536
+ }
537
+ }
538
+ const key = keyBuilderFromType(luvio, input);
539
+ const ttlToUse = TTL;
540
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "featurevalidation", VERSION, RepresentationType, equals);
541
+ return createLink(key);
542
+ };
543
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
544
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
545
+ const rootKey = keyBuilderFromType(luvio, input);
546
+ rootKeySet.set(rootKey, {
547
+ namespace: keyPrefix,
548
+ representationName: RepresentationType,
549
+ mergeable: false
550
+ });
551
+ }
552
+
553
+ function select(luvio, params) {
554
+ return select$1();
555
+ }
556
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
557
+ getTypeCacheKeys(storeKeyMap, luvio, response);
558
+ }
559
+ function ingestSuccess(luvio, resourceParams, response) {
560
+ const { body } = response;
561
+ const key = keyBuilderFromType(luvio, body);
562
+ luvio.storeIngest(key, ingest, body);
563
+ const snapshot = luvio.storeLookup({
564
+ recordId: key,
565
+ node: select(),
566
+ variables: {},
567
+ });
568
+ if (process.env.NODE_ENV !== 'production') {
569
+ if (snapshot.state !== 'Fulfilled') {
570
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
571
+ }
572
+ }
573
+ deepFreeze(snapshot.data);
574
+ return snapshot;
575
+ }
576
+ function createResourceRequest(config) {
577
+ const headers = {};
578
+ return {
579
+ baseUri: '/services/data/v66.0',
580
+ basePath: '/connect/industries/feature-validation',
581
+ method: 'post',
582
+ body: config.body,
583
+ urlParams: {},
584
+ queryParams: {},
585
+ headers,
586
+ priority: 'normal',
587
+ };
588
+ }
589
+
590
+ const adapterName = 'featureValidation';
591
+ const featureValidation_ConfigPropertyMetadata = [
592
+ generateParamConfigMetadata('FeatureValidationData', true, 2 /* Body */, 4 /* Unsupported */),
593
+ ];
594
+ const featureValidation_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, featureValidation_ConfigPropertyMetadata);
595
+ const createResourceParams = /*#__PURE__*/ createResourceParams$1(featureValidation_ConfigPropertyMetadata);
596
+ function typeCheckConfig(untrustedConfig) {
597
+ const config = {};
598
+ const untrustedConfig_FeatureValidationData = untrustedConfig.FeatureValidationData;
599
+ const referenceFeatureValidationInputRepresentationValidationError = validate$4(untrustedConfig_FeatureValidationData);
600
+ if (referenceFeatureValidationInputRepresentationValidationError === null) {
601
+ config.FeatureValidationData = untrustedConfig_FeatureValidationData;
602
+ }
603
+ return config;
604
+ }
605
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
606
+ if (!untrustedIsObject(untrustedConfig)) {
607
+ return null;
608
+ }
609
+ if (process.env.NODE_ENV !== 'production') {
610
+ validateConfig(untrustedConfig, configPropertyNames);
611
+ }
612
+ const config = typeCheckConfig(untrustedConfig);
613
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
614
+ return null;
615
+ }
616
+ return config;
617
+ }
618
+ function buildNetworkSnapshot(luvio, config, options) {
619
+ const resourceParams = createResourceParams(config);
620
+ const request = createResourceRequest(resourceParams);
621
+ return luvio.dispatchResourceRequest(request, options)
622
+ .then((response) => {
623
+ return luvio.handleSuccessResponse(() => {
624
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
625
+ return luvio.storeBroadcast().then(() => snapshot);
626
+ }, () => {
627
+ const cache = new StoreKeyMap();
628
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
629
+ return cache;
630
+ });
631
+ }, (response) => {
632
+ deepFreeze(response);
633
+ throw response;
634
+ });
635
+ }
636
+ const featureValidationAdapterFactory = (luvio) => {
637
+ return function featureValidation(untrustedConfig) {
638
+ const config = validateAdapterConfig(untrustedConfig, featureValidation_ConfigPropertyNames);
639
+ // Invalid or incomplete config
640
+ if (config === null) {
641
+ throw new Error('Invalid config for "featureValidation"');
642
+ }
643
+ return buildNetworkSnapshot(luvio, config);
644
+ };
645
+ };
646
+
647
+ export { featureValidationAdapterFactory };