@salesforce/lds-adapters-sales-pathassistant 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,691 @@
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$3, typeCheckConfig as typeCheckConfig$3, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$2 } 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 = 'pathassistant';
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
+ const TTL$2 = 30000;
83
+ const VERSION$2 = "a729b9451867a2ddc52e8106de4e17c5";
84
+ function validate$2(obj, path = 'CollapsibleDrawerUserPrefRepresentation') {
85
+ const v_error = (() => {
86
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
87
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
88
+ }
89
+ const obj_apiName = obj.apiName;
90
+ const path_apiName = path + '.apiName';
91
+ if (typeof obj_apiName !== 'string') {
92
+ return new TypeError('Expected "string" but received "' + typeof obj_apiName + '" (at "' + path_apiName + '")');
93
+ }
94
+ const obj_isSuccess = obj.isSuccess;
95
+ const path_isSuccess = path + '.isSuccess';
96
+ if (typeof obj_isSuccess !== 'boolean') {
97
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
98
+ }
99
+ })();
100
+ return v_error === undefined ? null : v_error;
101
+ }
102
+ const RepresentationType$2 = 'CollapsibleDrawerUserPrefRepresentation';
103
+ function keyBuilder$4(luvio, config) {
104
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.apiName;
105
+ }
106
+ function keyBuilderFromType(luvio, object) {
107
+ const keyParams = {
108
+ apiName: object.apiName
109
+ };
110
+ return keyBuilder$4(luvio, keyParams);
111
+ }
112
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
113
+ return input;
114
+ }
115
+ const select$5 = function CollapsibleDrawerUserPrefRepresentationSelect() {
116
+ return {
117
+ kind: 'Fragment',
118
+ version: VERSION$2,
119
+ private: [],
120
+ selections: [
121
+ {
122
+ name: 'apiName',
123
+ kind: 'Scalar'
124
+ },
125
+ {
126
+ name: 'isSuccess',
127
+ kind: 'Scalar'
128
+ }
129
+ ]
130
+ };
131
+ };
132
+ function equals$2(existing, incoming) {
133
+ const existing_isSuccess = existing.isSuccess;
134
+ const incoming_isSuccess = incoming.isSuccess;
135
+ if (!(existing_isSuccess === incoming_isSuccess)) {
136
+ return false;
137
+ }
138
+ const existing_apiName = existing.apiName;
139
+ const incoming_apiName = incoming.apiName;
140
+ if (!(existing_apiName === incoming_apiName)) {
141
+ return false;
142
+ }
143
+ return true;
144
+ }
145
+ const ingest$2 = function CollapsibleDrawerUserPrefRepresentationIngest(input, path, luvio, store, timestamp) {
146
+ if (process.env.NODE_ENV !== 'production') {
147
+ const validateError = validate$2(input);
148
+ if (validateError !== null) {
149
+ throw validateError;
150
+ }
151
+ }
152
+ const key = keyBuilderFromType(luvio, input);
153
+ const ttlToUse = TTL$2;
154
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "pathassistant", VERSION$2, RepresentationType$2, equals$2);
155
+ return createLink(key);
156
+ };
157
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
158
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
159
+ const rootKey = keyBuilderFromType(luvio, input);
160
+ rootKeySet.set(rootKey, {
161
+ namespace: keyPrefix,
162
+ representationName: RepresentationType$2,
163
+ mergeable: false
164
+ });
165
+ }
166
+
167
+ function select$4(luvio, params) {
168
+ return select$5();
169
+ }
170
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
171
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
172
+ }
173
+ function ingestSuccess$2(luvio, resourceParams, response) {
174
+ const { body } = response;
175
+ const key = keyBuilderFromType(luvio, body);
176
+ luvio.storeIngest(key, ingest$2, body);
177
+ const snapshot = luvio.storeLookup({
178
+ recordId: key,
179
+ node: select$4(),
180
+ variables: {},
181
+ });
182
+ if (process.env.NODE_ENV !== 'production') {
183
+ if (snapshot.state !== 'Fulfilled') {
184
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
185
+ }
186
+ }
187
+ deepFreeze(snapshot.data);
188
+ return snapshot;
189
+ }
190
+ function createResourceRequest$2(config) {
191
+ const headers = {};
192
+ return {
193
+ baseUri: '/services/data/v66.0',
194
+ basePath: '/connect/pathassistant/collapsibleDrawerUserPref',
195
+ method: 'patch',
196
+ body: null,
197
+ urlParams: {},
198
+ queryParams: config.queryParams,
199
+ headers,
200
+ priority: 'normal',
201
+ };
202
+ }
203
+
204
+ const adapterName$2 = 'updateCollapsibleDrawerUserPref';
205
+ const updateCollapsibleDrawerUserPref_ConfigPropertyMetadata = [
206
+ generateParamConfigMetadata('isCollapsed', false, 1 /* QueryParameter */, 1 /* Boolean */),
207
+ ];
208
+ const updateCollapsibleDrawerUserPref_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, updateCollapsibleDrawerUserPref_ConfigPropertyMetadata);
209
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(updateCollapsibleDrawerUserPref_ConfigPropertyMetadata);
210
+ function typeCheckConfig$2(untrustedConfig) {
211
+ const config = {};
212
+ typeCheckConfig$3(untrustedConfig, config, updateCollapsibleDrawerUserPref_ConfigPropertyMetadata);
213
+ return config;
214
+ }
215
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
216
+ if (!untrustedIsObject(untrustedConfig)) {
217
+ return null;
218
+ }
219
+ if (process.env.NODE_ENV !== 'production') {
220
+ validateConfig(untrustedConfig, configPropertyNames);
221
+ }
222
+ const config = typeCheckConfig$2(untrustedConfig);
223
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
224
+ return null;
225
+ }
226
+ return config;
227
+ }
228
+ function buildNetworkSnapshot$2(luvio, config, options) {
229
+ const resourceParams = createResourceParams$2(config);
230
+ const request = createResourceRequest$2(resourceParams);
231
+ return luvio.dispatchResourceRequest(request, options)
232
+ .then((response) => {
233
+ return luvio.handleSuccessResponse(() => {
234
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
235
+ return luvio.storeBroadcast().then(() => snapshot);
236
+ }, () => {
237
+ const cache = new StoreKeyMap();
238
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
239
+ return cache;
240
+ });
241
+ }, (response) => {
242
+ deepFreeze(response);
243
+ throw response;
244
+ });
245
+ }
246
+ const updateCollapsibleDrawerUserPrefAdapterFactory = (luvio) => {
247
+ return function updateCollapsibleDrawerUserPref(untrustedConfig) {
248
+ const config = validateAdapterConfig$2(untrustedConfig, updateCollapsibleDrawerUserPref_ConfigPropertyNames);
249
+ // Invalid or incomplete config
250
+ if (config === null) {
251
+ throw new Error('Invalid config for "updateCollapsibleDrawerUserPref"');
252
+ }
253
+ return buildNetworkSnapshot$2(luvio, config);
254
+ };
255
+ };
256
+
257
+ const TTL$1 = 30000;
258
+ const VERSION$1 = "4fa0084a0c26cd9bb89e092a910800f1";
259
+ function validate$1(obj, path = 'PathAssistantMetadataRepresentation') {
260
+ const v_error = (() => {
261
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
262
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
263
+ }
264
+ const obj_extraData = obj.extraData;
265
+ const path_extraData = path + '.extraData';
266
+ if (obj_extraData === undefined) {
267
+ return new TypeError('Expected "defined" but received "' + typeof obj_extraData + '" (at "' + path_extraData + '")');
268
+ }
269
+ const obj_pathAssistant = obj.pathAssistant;
270
+ const path_pathAssistant = path + '.pathAssistant';
271
+ if (obj_pathAssistant === undefined) {
272
+ return new TypeError('Expected "defined" but received "' + typeof obj_pathAssistant + '" (at "' + path_pathAssistant + '")');
273
+ }
274
+ const obj_recordData = obj.recordData;
275
+ const path_recordData = path + '.recordData';
276
+ if (obj_recordData === undefined) {
277
+ return new TypeError('Expected "defined" but received "' + typeof obj_recordData + '" (at "' + path_recordData + '")');
278
+ }
279
+ })();
280
+ return v_error === undefined ? null : v_error;
281
+ }
282
+ const RepresentationType$1 = 'PathAssistantMetadataRepresentation';
283
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
284
+ return input;
285
+ }
286
+ const select$3 = function PathAssistantMetadataRepresentationSelect() {
287
+ return {
288
+ kind: 'Fragment',
289
+ version: VERSION$1,
290
+ private: [],
291
+ selections: [
292
+ {
293
+ name: 'extraData',
294
+ kind: 'Object',
295
+ // any
296
+ },
297
+ {
298
+ name: 'pathAssistant',
299
+ kind: 'Object',
300
+ // any
301
+ },
302
+ {
303
+ name: 'recordData',
304
+ kind: 'Object',
305
+ // any
306
+ }
307
+ ]
308
+ };
309
+ };
310
+ function equals$1(existing, incoming) {
311
+ const existing_extraData = existing.extraData;
312
+ const incoming_extraData = incoming.extraData;
313
+ if (JSONStringify(incoming_extraData) !== JSONStringify(existing_extraData)) {
314
+ return false;
315
+ }
316
+ const existing_pathAssistant = existing.pathAssistant;
317
+ const incoming_pathAssistant = incoming.pathAssistant;
318
+ if (JSONStringify(incoming_pathAssistant) !== JSONStringify(existing_pathAssistant)) {
319
+ return false;
320
+ }
321
+ const existing_recordData = existing.recordData;
322
+ const incoming_recordData = incoming.recordData;
323
+ if (JSONStringify(incoming_recordData) !== JSONStringify(existing_recordData)) {
324
+ return false;
325
+ }
326
+ return true;
327
+ }
328
+ const ingest$1 = function PathAssistantMetadataRepresentationIngest(input, path, luvio, store, timestamp) {
329
+ if (process.env.NODE_ENV !== 'production') {
330
+ const validateError = validate$1(input);
331
+ if (validateError !== null) {
332
+ throw validateError;
333
+ }
334
+ }
335
+ const key = path.fullPath;
336
+ const ttlToUse = TTL$1;
337
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "pathassistant", VERSION$1, RepresentationType$1, equals$1);
338
+ return createLink(key);
339
+ };
340
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
341
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
342
+ const rootKey = fullPathFactory();
343
+ rootKeySet.set(rootKey, {
344
+ namespace: keyPrefix,
345
+ representationName: RepresentationType$1,
346
+ mergeable: false
347
+ });
348
+ }
349
+
350
+ function select$2(luvio, params) {
351
+ return select$3();
352
+ }
353
+ function keyBuilder$3(luvio, params) {
354
+ return keyPrefix + '::PathAssistantMetadataRepresentation:(' + 'picklistFieldApiName:' + params.queryParams.picklistFieldApiName + ',' + 'recordId:' + params.urlParams.recordId + ')';
355
+ }
356
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
357
+ getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$3(luvio, resourceParams));
358
+ }
359
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
360
+ const { body } = response;
361
+ const key = keyBuilder$3(luvio, resourceParams);
362
+ luvio.storeIngest(key, ingest$1, body);
363
+ const snapshot = luvio.storeLookup({
364
+ recordId: key,
365
+ node: select$2(),
366
+ variables: {},
367
+ }, snapshotRefresh);
368
+ if (process.env.NODE_ENV !== 'production') {
369
+ if (snapshot.state !== 'Fulfilled') {
370
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
371
+ }
372
+ }
373
+ deepFreeze(snapshot.data);
374
+ return snapshot;
375
+ }
376
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
377
+ const key = keyBuilder$3(luvio, params);
378
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
379
+ const storeMetadataParams = {
380
+ ttl: TTL$1,
381
+ namespace: keyPrefix,
382
+ version: VERSION$1,
383
+ representationName: RepresentationType$1
384
+ };
385
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
386
+ return errorSnapshot;
387
+ }
388
+ function createResourceRequest$1(config) {
389
+ const headers = {};
390
+ return {
391
+ baseUri: '/services/data/v66.0',
392
+ basePath: '/connect/pathassistant/' + config.urlParams.recordId + '',
393
+ method: 'get',
394
+ body: null,
395
+ urlParams: config.urlParams,
396
+ queryParams: config.queryParams,
397
+ headers,
398
+ priority: 'normal',
399
+ };
400
+ }
401
+
402
+ const adapterName$1 = 'getPathAssistant';
403
+ const getPathAssistant_ConfigPropertyMetadata = [
404
+ generateParamConfigMetadata('recordId', true, 0 /* UrlParameter */, 0 /* String */),
405
+ generateParamConfigMetadata('picklistFieldApiName', false, 1 /* QueryParameter */, 0 /* String */),
406
+ ];
407
+ const getPathAssistant_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getPathAssistant_ConfigPropertyMetadata);
408
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(getPathAssistant_ConfigPropertyMetadata);
409
+ function keyBuilder$2(luvio, config) {
410
+ const resourceParams = createResourceParams$1(config);
411
+ return keyBuilder$3(luvio, resourceParams);
412
+ }
413
+ function typeCheckConfig$1(untrustedConfig) {
414
+ const config = {};
415
+ typeCheckConfig$3(untrustedConfig, config, getPathAssistant_ConfigPropertyMetadata);
416
+ return config;
417
+ }
418
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
419
+ if (!untrustedIsObject(untrustedConfig)) {
420
+ return null;
421
+ }
422
+ if (process.env.NODE_ENV !== 'production') {
423
+ validateConfig(untrustedConfig, configPropertyNames);
424
+ }
425
+ const config = typeCheckConfig$1(untrustedConfig);
426
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
427
+ return null;
428
+ }
429
+ return config;
430
+ }
431
+ function adapterFragment$1(luvio, config) {
432
+ createResourceParams$1(config);
433
+ return select$2();
434
+ }
435
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
436
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
437
+ config,
438
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
439
+ });
440
+ return luvio.storeBroadcast().then(() => snapshot);
441
+ }
442
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
443
+ const snapshot = ingestError$1(luvio, resourceParams, response, {
444
+ config,
445
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
446
+ });
447
+ return luvio.storeBroadcast().then(() => snapshot);
448
+ }
449
+ function buildNetworkSnapshot$1(luvio, config, options) {
450
+ const resourceParams = createResourceParams$1(config);
451
+ const request = createResourceRequest$1(resourceParams);
452
+ return luvio.dispatchResourceRequest(request, options)
453
+ .then((response) => {
454
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => {
455
+ const cache = new StoreKeyMap();
456
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
457
+ return cache;
458
+ });
459
+ }, (response) => {
460
+ return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
461
+ });
462
+ }
463
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
464
+ return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
465
+ }
466
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
467
+ const { luvio, config } = context;
468
+ const selector = {
469
+ recordId: keyBuilder$2(luvio, config),
470
+ node: adapterFragment$1(luvio, config),
471
+ variables: {},
472
+ };
473
+ const cacheSnapshot = storeLookup(selector, {
474
+ config,
475
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
476
+ });
477
+ return cacheSnapshot;
478
+ }
479
+ const getPathAssistantAdapterFactory = (luvio) => function pathassistant__getPathAssistant(untrustedConfig, requestContext) {
480
+ const config = validateAdapterConfig$1(untrustedConfig, getPathAssistant_ConfigPropertyNames);
481
+ // Invalid or incomplete config
482
+ if (config === null) {
483
+ return null;
484
+ }
485
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
486
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
487
+ };
488
+
489
+ const TTL = 30000;
490
+ const VERSION = "ba6bce075182b2ef08471882a25ab029";
491
+ function validate(obj, path = 'PathAssistantDaysInStageRepresentation') {
492
+ const v_error = (() => {
493
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
494
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
495
+ }
496
+ const obj_picklistValuesToDays = obj.picklistValuesToDays;
497
+ const path_picklistValuesToDays = path + '.picklistValuesToDays';
498
+ if (obj_picklistValuesToDays === undefined) {
499
+ return new TypeError('Expected "defined" but received "' + typeof obj_picklistValuesToDays + '" (at "' + path_picklistValuesToDays + '")');
500
+ }
501
+ })();
502
+ return v_error === undefined ? null : v_error;
503
+ }
504
+ const RepresentationType = 'PathAssistantDaysInStageRepresentation';
505
+ function normalize(input, existing, path, luvio, store, timestamp) {
506
+ return input;
507
+ }
508
+ const select$1 = function PathAssistantDaysInStageRepresentationSelect() {
509
+ return {
510
+ kind: 'Fragment',
511
+ version: VERSION,
512
+ private: [],
513
+ selections: [
514
+ {
515
+ name: 'picklistValuesToDays',
516
+ kind: 'Object',
517
+ // any
518
+ }
519
+ ]
520
+ };
521
+ };
522
+ function equals(existing, incoming) {
523
+ const existing_picklistValuesToDays = existing.picklistValuesToDays;
524
+ const incoming_picklistValuesToDays = incoming.picklistValuesToDays;
525
+ if (JSONStringify(incoming_picklistValuesToDays) !== JSONStringify(existing_picklistValuesToDays)) {
526
+ return false;
527
+ }
528
+ return true;
529
+ }
530
+ const ingest = function PathAssistantDaysInStageRepresentationIngest(input, path, luvio, store, timestamp) {
531
+ if (process.env.NODE_ENV !== 'production') {
532
+ const validateError = validate(input);
533
+ if (validateError !== null) {
534
+ throw validateError;
535
+ }
536
+ }
537
+ const key = path.fullPath;
538
+ const ttlToUse = TTL;
539
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "pathassistant", VERSION, RepresentationType, equals);
540
+ return createLink(key);
541
+ };
542
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
543
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
544
+ const rootKey = fullPathFactory();
545
+ rootKeySet.set(rootKey, {
546
+ namespace: keyPrefix,
547
+ representationName: RepresentationType,
548
+ mergeable: false
549
+ });
550
+ }
551
+
552
+ function select(luvio, params) {
553
+ return select$1();
554
+ }
555
+ function keyBuilder$1(luvio, params) {
556
+ return keyPrefix + '::PathAssistantDaysInStageRepresentation:(' + 'picklistFieldApiName:' + params.queryParams.picklistFieldApiName + ',' + 'recordId:' + params.urlParams.recordId + ')';
557
+ }
558
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
559
+ getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
560
+ }
561
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
562
+ const { body } = response;
563
+ const key = keyBuilder$1(luvio, resourceParams);
564
+ luvio.storeIngest(key, ingest, body);
565
+ const snapshot = luvio.storeLookup({
566
+ recordId: key,
567
+ node: select(),
568
+ variables: {},
569
+ }, snapshotRefresh);
570
+ if (process.env.NODE_ENV !== 'production') {
571
+ if (snapshot.state !== 'Fulfilled') {
572
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
573
+ }
574
+ }
575
+ deepFreeze(snapshot.data);
576
+ return snapshot;
577
+ }
578
+ function ingestError(luvio, params, error, snapshotRefresh) {
579
+ const key = keyBuilder$1(luvio, params);
580
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
581
+ const storeMetadataParams = {
582
+ ttl: TTL,
583
+ namespace: keyPrefix,
584
+ version: VERSION,
585
+ representationName: RepresentationType
586
+ };
587
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
588
+ return errorSnapshot;
589
+ }
590
+ function createResourceRequest(config) {
591
+ const headers = {};
592
+ return {
593
+ baseUri: '/services/data/v66.0',
594
+ basePath: '/connect/pathassistant/' + config.urlParams.recordId + '/daysInStage',
595
+ method: 'get',
596
+ body: null,
597
+ urlParams: config.urlParams,
598
+ queryParams: config.queryParams,
599
+ headers,
600
+ priority: 'normal',
601
+ };
602
+ }
603
+
604
+ const adapterName = 'getPathAssistantDaysInStage';
605
+ const getPathAssistantDaysInStage_ConfigPropertyMetadata = [
606
+ generateParamConfigMetadata('recordId', true, 0 /* UrlParameter */, 0 /* String */),
607
+ generateParamConfigMetadata('picklistFieldApiName', false, 1 /* QueryParameter */, 0 /* String */),
608
+ ];
609
+ const getPathAssistantDaysInStage_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getPathAssistantDaysInStage_ConfigPropertyMetadata);
610
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(getPathAssistantDaysInStage_ConfigPropertyMetadata);
611
+ function keyBuilder(luvio, config) {
612
+ const resourceParams = createResourceParams(config);
613
+ return keyBuilder$1(luvio, resourceParams);
614
+ }
615
+ function typeCheckConfig(untrustedConfig) {
616
+ const config = {};
617
+ typeCheckConfig$3(untrustedConfig, config, getPathAssistantDaysInStage_ConfigPropertyMetadata);
618
+ return config;
619
+ }
620
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
621
+ if (!untrustedIsObject(untrustedConfig)) {
622
+ return null;
623
+ }
624
+ if (process.env.NODE_ENV !== 'production') {
625
+ validateConfig(untrustedConfig, configPropertyNames);
626
+ }
627
+ const config = typeCheckConfig(untrustedConfig);
628
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
629
+ return null;
630
+ }
631
+ return config;
632
+ }
633
+ function adapterFragment(luvio, config) {
634
+ createResourceParams(config);
635
+ return select();
636
+ }
637
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
638
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
639
+ config,
640
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
641
+ });
642
+ return luvio.storeBroadcast().then(() => snapshot);
643
+ }
644
+ function onFetchResponseError(luvio, config, resourceParams, response) {
645
+ const snapshot = ingestError(luvio, resourceParams, response, {
646
+ config,
647
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
648
+ });
649
+ return luvio.storeBroadcast().then(() => snapshot);
650
+ }
651
+ function buildNetworkSnapshot(luvio, config, options) {
652
+ const resourceParams = createResourceParams(config);
653
+ const request = createResourceRequest(resourceParams);
654
+ return luvio.dispatchResourceRequest(request, options)
655
+ .then((response) => {
656
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
657
+ const cache = new StoreKeyMap();
658
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
659
+ return cache;
660
+ });
661
+ }, (response) => {
662
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
663
+ });
664
+ }
665
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
666
+ return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
667
+ }
668
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
669
+ const { luvio, config } = context;
670
+ const selector = {
671
+ recordId: keyBuilder(luvio, config),
672
+ node: adapterFragment(luvio, config),
673
+ variables: {},
674
+ };
675
+ const cacheSnapshot = storeLookup(selector, {
676
+ config,
677
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
678
+ });
679
+ return cacheSnapshot;
680
+ }
681
+ const getPathAssistantDaysInStageAdapterFactory = (luvio) => function pathassistant__getPathAssistantDaysInStage(untrustedConfig, requestContext) {
682
+ const config = validateAdapterConfig(untrustedConfig, getPathAssistantDaysInStage_ConfigPropertyNames);
683
+ // Invalid or incomplete config
684
+ if (config === null) {
685
+ return null;
686
+ }
687
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
688
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
689
+ };
690
+
691
+ export { getPathAssistantAdapterFactory, getPathAssistantDaysInStageAdapterFactory, updateCollapsibleDrawerUserPrefAdapterFactory };