@salesforce/lds-adapters-sales-eci 1.114.3 → 1.205.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.
@@ -0,0 +1,658 @@
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, deepFreeze, StoreKeyMap } 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
+ const keyPrefix = 'eci';
52
+
53
+ const { isArray: ArrayIsArray } = Array;
54
+ function equalsArray(a, b, equalsItem) {
55
+ const aLength = a.length;
56
+ const bLength = b.length;
57
+ if (aLength !== bLength) {
58
+ return false;
59
+ }
60
+ for (let i = 0; i < aLength; i++) {
61
+ if (equalsItem(a[i], b[i]) === false) {
62
+ return false;
63
+ }
64
+ }
65
+ return true;
66
+ }
67
+ function createLink(ref) {
68
+ return {
69
+ __ref: serializeStructuredKey(ref),
70
+ };
71
+ }
72
+
73
+ const TTL$1 = 60000;
74
+ const VERSION$1 = "05e77e36a867f8b3cf1bdfcc3aeb62c7";
75
+ function validate$1(obj, path = 'ConversationSummaryRepresentation') {
76
+ const v_error = (() => {
77
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
78
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
79
+ }
80
+ const obj_conversationRecordId = obj.conversationRecordId;
81
+ const path_conversationRecordId = path + '.conversationRecordId';
82
+ if (typeof obj_conversationRecordId !== 'string') {
83
+ return new TypeError('Expected "string" but received "' + typeof obj_conversationRecordId + '" (at "' + path_conversationRecordId + '")');
84
+ }
85
+ const obj_errorMessage = obj.errorMessage;
86
+ const path_errorMessage = path + '.errorMessage';
87
+ let obj_errorMessage_union0 = null;
88
+ const obj_errorMessage_union0_error = (() => {
89
+ if (typeof obj_errorMessage !== 'string') {
90
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
91
+ }
92
+ })();
93
+ if (obj_errorMessage_union0_error != null) {
94
+ obj_errorMessage_union0 = obj_errorMessage_union0_error.message;
95
+ }
96
+ let obj_errorMessage_union1 = null;
97
+ const obj_errorMessage_union1_error = (() => {
98
+ if (obj_errorMessage !== null) {
99
+ return new TypeError('Expected "null" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
100
+ }
101
+ })();
102
+ if (obj_errorMessage_union1_error != null) {
103
+ obj_errorMessage_union1 = obj_errorMessage_union1_error.message;
104
+ }
105
+ if (obj_errorMessage_union0 && obj_errorMessage_union1) {
106
+ let message = 'Object doesn\'t match union (at "' + path_errorMessage + '")';
107
+ message += '\n' + obj_errorMessage_union0.split('\n').map((line) => '\t' + line).join('\n');
108
+ message += '\n' + obj_errorMessage_union1.split('\n').map((line) => '\t' + line).join('\n');
109
+ return new TypeError(message);
110
+ }
111
+ const obj_id = obj.id;
112
+ const path_id = path + '.id';
113
+ if (typeof obj_id !== 'string') {
114
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
115
+ }
116
+ const obj_source = obj.source;
117
+ const path_source = path + '.source';
118
+ if (typeof obj_source !== 'string') {
119
+ return new TypeError('Expected "string" but received "' + typeof obj_source + '" (at "' + path_source + '")');
120
+ }
121
+ const obj_state = obj.state;
122
+ const path_state = path + '.state';
123
+ if (typeof obj_state !== 'string') {
124
+ return new TypeError('Expected "string" but received "' + typeof obj_state + '" (at "' + path_state + '")');
125
+ }
126
+ const obj_summary = obj.summary;
127
+ const path_summary = path + '.summary';
128
+ if (typeof obj_summary !== 'string') {
129
+ return new TypeError('Expected "string" but received "' + typeof obj_summary + '" (at "' + path_summary + '")');
130
+ }
131
+ })();
132
+ return v_error === undefined ? null : v_error;
133
+ }
134
+ const RepresentationType$1 = 'ConversationSummaryRepresentation';
135
+ function keyBuilder$3(luvio, config) {
136
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.conversation_sumamry_id;
137
+ }
138
+ function keyBuilderFromType$1(luvio, object) {
139
+ const keyParams = {
140
+ conversation_sumamry_id: object.id
141
+ };
142
+ return keyBuilder$3(luvio, keyParams);
143
+ }
144
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
145
+ return input;
146
+ }
147
+ const select$3 = function ConversationSummaryRepresentationSelect() {
148
+ return {
149
+ kind: 'Fragment',
150
+ version: VERSION$1,
151
+ private: [],
152
+ selections: [
153
+ {
154
+ name: 'conversationRecordId',
155
+ kind: 'Scalar'
156
+ },
157
+ {
158
+ name: 'errorMessage',
159
+ kind: 'Scalar'
160
+ },
161
+ {
162
+ name: 'id',
163
+ kind: 'Scalar'
164
+ },
165
+ {
166
+ name: 'source',
167
+ kind: 'Scalar'
168
+ },
169
+ {
170
+ name: 'state',
171
+ kind: 'Scalar'
172
+ },
173
+ {
174
+ name: 'summary',
175
+ kind: 'Scalar'
176
+ }
177
+ ]
178
+ };
179
+ };
180
+ function equals$1(existing, incoming) {
181
+ const existing_conversationRecordId = existing.conversationRecordId;
182
+ const incoming_conversationRecordId = incoming.conversationRecordId;
183
+ if (!(existing_conversationRecordId === incoming_conversationRecordId)) {
184
+ return false;
185
+ }
186
+ const existing_id = existing.id;
187
+ const incoming_id = incoming.id;
188
+ if (!(existing_id === incoming_id)) {
189
+ return false;
190
+ }
191
+ const existing_source = existing.source;
192
+ const incoming_source = incoming.source;
193
+ if (!(existing_source === incoming_source)) {
194
+ return false;
195
+ }
196
+ const existing_state = existing.state;
197
+ const incoming_state = incoming.state;
198
+ if (!(existing_state === incoming_state)) {
199
+ return false;
200
+ }
201
+ const existing_summary = existing.summary;
202
+ const incoming_summary = incoming.summary;
203
+ if (!(existing_summary === incoming_summary)) {
204
+ return false;
205
+ }
206
+ const existing_errorMessage = existing.errorMessage;
207
+ const incoming_errorMessage = incoming.errorMessage;
208
+ if (!(existing_errorMessage === incoming_errorMessage)) {
209
+ return false;
210
+ }
211
+ return true;
212
+ }
213
+ const ingest$1 = function ConversationSummaryRepresentationIngest(input, path, luvio, store, timestamp) {
214
+ if (process.env.NODE_ENV !== 'production') {
215
+ const validateError = validate$1(input);
216
+ if (validateError !== null) {
217
+ throw validateError;
218
+ }
219
+ }
220
+ const key = keyBuilderFromType$1(luvio, input);
221
+ const existingRecord = store.readEntry(key);
222
+ const ttlToUse = TTL$1;
223
+ let incomingRecord = normalize$1(input, store.readEntry(key), {
224
+ fullPath: key,
225
+ parent: path.parent,
226
+ propertyName: path.propertyName,
227
+ ttl: ttlToUse
228
+ });
229
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
230
+ luvio.storePublish(key, incomingRecord);
231
+ }
232
+ {
233
+ const storeMetadataParams = {
234
+ ttl: ttlToUse,
235
+ namespace: "eci",
236
+ version: VERSION$1,
237
+ representationName: RepresentationType$1,
238
+ };
239
+ luvio.publishStoreMetadata(key, storeMetadataParams);
240
+ }
241
+ return createLink(key);
242
+ };
243
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
244
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
245
+ const rootKey = keyBuilderFromType$1(luvio, input);
246
+ rootKeySet.set(rootKey, {
247
+ namespace: keyPrefix,
248
+ representationName: RepresentationType$1,
249
+ mergeable: false
250
+ });
251
+ }
252
+
253
+ function select$2(luvio, params) {
254
+ return select$3();
255
+ }
256
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
257
+ getTypeCacheKeys$1(storeKeyMap, luvio, response);
258
+ }
259
+ function ingestSuccess$1(luvio, resourceParams, response) {
260
+ const { body } = response;
261
+ const key = keyBuilderFromType$1(luvio, body);
262
+ luvio.storeIngest(key, ingest$1, body);
263
+ const snapshot = luvio.storeLookup({
264
+ recordId: key,
265
+ node: select$2(),
266
+ variables: {},
267
+ });
268
+ if (process.env.NODE_ENV !== 'production') {
269
+ if (snapshot.state !== 'Fulfilled') {
270
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
271
+ }
272
+ }
273
+ deepFreeze(snapshot.data);
274
+ return snapshot;
275
+ }
276
+ function createResourceRequest$1(config) {
277
+ const headers = {};
278
+ return {
279
+ baseUri: '/services/data/v59.0',
280
+ basePath: '/conversation/summary/ai/generate/' + config.urlParams.conversationId + '',
281
+ method: 'post',
282
+ body: null,
283
+ urlParams: config.urlParams,
284
+ queryParams: {},
285
+ headers,
286
+ priority: 'normal',
287
+ };
288
+ }
289
+
290
+ const generateConversationSummary_ConfigPropertyNames = {
291
+ displayName: 'generateConversationSummary',
292
+ parameters: {
293
+ required: ['conversationId'],
294
+ optional: []
295
+ }
296
+ };
297
+ function createResourceParams$1(config) {
298
+ const resourceParams = {
299
+ urlParams: {
300
+ conversationId: config.conversationId
301
+ }
302
+ };
303
+ return resourceParams;
304
+ }
305
+ function typeCheckConfig$1(untrustedConfig) {
306
+ const config = {};
307
+ const untrustedConfig_conversationId = untrustedConfig.conversationId;
308
+ if (typeof untrustedConfig_conversationId === 'string') {
309
+ config.conversationId = untrustedConfig_conversationId;
310
+ }
311
+ return config;
312
+ }
313
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
314
+ if (!untrustedIsObject(untrustedConfig)) {
315
+ return null;
316
+ }
317
+ if (process.env.NODE_ENV !== 'production') {
318
+ validateConfig(untrustedConfig, configPropertyNames);
319
+ }
320
+ const config = typeCheckConfig$1(untrustedConfig);
321
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
322
+ return null;
323
+ }
324
+ return config;
325
+ }
326
+ function buildNetworkSnapshot$1(luvio, config, options) {
327
+ const resourceParams = createResourceParams$1(config);
328
+ const request = createResourceRequest$1(resourceParams);
329
+ return luvio.dispatchResourceRequest(request, options)
330
+ .then((response) => {
331
+ return luvio.handleSuccessResponse(() => {
332
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
333
+ return luvio.storeBroadcast().then(() => snapshot);
334
+ }, () => {
335
+ const cache = new StoreKeyMap();
336
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
337
+ return cache;
338
+ });
339
+ }, (response) => {
340
+ deepFreeze(response);
341
+ throw response;
342
+ });
343
+ }
344
+ const generateConversationSummaryAdapterFactory = (luvio) => {
345
+ return function generateConversationSummary(untrustedConfig) {
346
+ const config = validateAdapterConfig$1(untrustedConfig, generateConversationSummary_ConfigPropertyNames);
347
+ // Invalid or incomplete config
348
+ if (config === null) {
349
+ throw new Error('Invalid config for "generateConversationSummary"');
350
+ }
351
+ return buildNetworkSnapshot$1(luvio, config);
352
+ };
353
+ };
354
+
355
+ const TTL = 60000;
356
+ const VERSION = "a9e3d8764d06757767b6c4311caa4e5c";
357
+ function validate(obj, path = 'ConversationSummaryListRepresentation') {
358
+ const v_error = (() => {
359
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
360
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
361
+ }
362
+ const obj_conversationSummaryList = obj.conversationSummaryList;
363
+ const path_conversationSummaryList = path + '.conversationSummaryList';
364
+ if (!ArrayIsArray(obj_conversationSummaryList)) {
365
+ return new TypeError('Expected "array" but received "' + typeof obj_conversationSummaryList + '" (at "' + path_conversationSummaryList + '")');
366
+ }
367
+ for (let i = 0; i < obj_conversationSummaryList.length; i++) {
368
+ const obj_conversationSummaryList_item = obj_conversationSummaryList[i];
369
+ const path_conversationSummaryList_item = path_conversationSummaryList + '[' + i + ']';
370
+ if (typeof obj_conversationSummaryList_item !== 'object') {
371
+ return new TypeError('Expected "object" but received "' + typeof obj_conversationSummaryList_item + '" (at "' + path_conversationSummaryList_item + '")');
372
+ }
373
+ }
374
+ const obj_id = obj.id;
375
+ const path_id = path + '.id';
376
+ if (typeof obj_id !== 'string') {
377
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
378
+ }
379
+ })();
380
+ return v_error === undefined ? null : v_error;
381
+ }
382
+ const RepresentationType = 'ConversationSummaryListRepresentation';
383
+ function keyBuilder$2(luvio, config) {
384
+ return keyPrefix + '::' + RepresentationType + ':' + config.id;
385
+ }
386
+ function keyBuilderFromType(luvio, object) {
387
+ const keyParams = {
388
+ id: object.id
389
+ };
390
+ return keyBuilder$2(luvio, keyParams);
391
+ }
392
+ function normalize(input, existing, path, luvio, store, timestamp) {
393
+ const input_conversationSummaryList = input.conversationSummaryList;
394
+ const input_conversationSummaryList_id = path.fullPath + '__conversationSummaryList';
395
+ for (let i = 0; i < input_conversationSummaryList.length; i++) {
396
+ const input_conversationSummaryList_item = input_conversationSummaryList[i];
397
+ let input_conversationSummaryList_item_id = input_conversationSummaryList_id + '__' + i;
398
+ input_conversationSummaryList[i] = ingest$1(input_conversationSummaryList_item, {
399
+ fullPath: input_conversationSummaryList_item_id,
400
+ propertyName: i,
401
+ parent: {
402
+ data: input,
403
+ key: path.fullPath,
404
+ existing: existing,
405
+ },
406
+ ttl: path.ttl
407
+ }, luvio, store);
408
+ }
409
+ return input;
410
+ }
411
+ const select$1 = function ConversationSummaryListRepresentationSelect() {
412
+ return {
413
+ kind: 'Fragment',
414
+ version: VERSION,
415
+ private: [],
416
+ selections: [
417
+ {
418
+ name: 'conversationSummaryList',
419
+ kind: 'Link',
420
+ plural: true,
421
+ fragment: select$3()
422
+ },
423
+ {
424
+ name: 'id',
425
+ kind: 'Scalar'
426
+ }
427
+ ]
428
+ };
429
+ };
430
+ function equals(existing, incoming) {
431
+ const existing_id = existing.id;
432
+ const incoming_id = incoming.id;
433
+ if (!(existing_id === incoming_id)) {
434
+ return false;
435
+ }
436
+ const existing_conversationSummaryList = existing.conversationSummaryList;
437
+ const incoming_conversationSummaryList = incoming.conversationSummaryList;
438
+ const equals_conversationSummaryList_items = equalsArray(existing_conversationSummaryList, incoming_conversationSummaryList, (existing_conversationSummaryList_item, incoming_conversationSummaryList_item) => {
439
+ if (!(existing_conversationSummaryList_item.__ref === incoming_conversationSummaryList_item.__ref)) {
440
+ return false;
441
+ }
442
+ });
443
+ if (equals_conversationSummaryList_items === false) {
444
+ return false;
445
+ }
446
+ return true;
447
+ }
448
+ const ingest = function ConversationSummaryListRepresentationIngest(input, path, luvio, store, timestamp) {
449
+ if (process.env.NODE_ENV !== 'production') {
450
+ const validateError = validate(input);
451
+ if (validateError !== null) {
452
+ throw validateError;
453
+ }
454
+ }
455
+ const key = keyBuilderFromType(luvio, input);
456
+ const existingRecord = store.readEntry(key);
457
+ const ttlToUse = TTL;
458
+ let incomingRecord = normalize(input, store.readEntry(key), {
459
+ fullPath: key,
460
+ parent: path.parent,
461
+ propertyName: path.propertyName,
462
+ ttl: ttlToUse
463
+ }, luvio, store);
464
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
465
+ luvio.storePublish(key, incomingRecord);
466
+ }
467
+ {
468
+ const storeMetadataParams = {
469
+ ttl: ttlToUse,
470
+ namespace: "eci",
471
+ version: VERSION,
472
+ representationName: RepresentationType,
473
+ };
474
+ luvio.publishStoreMetadata(key, storeMetadataParams);
475
+ }
476
+ return createLink(key);
477
+ };
478
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
479
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
480
+ const rootKey = keyBuilderFromType(luvio, input);
481
+ rootKeySet.set(rootKey, {
482
+ namespace: keyPrefix,
483
+ representationName: RepresentationType,
484
+ mergeable: false
485
+ });
486
+ const input_conversationSummaryList_length = input.conversationSummaryList.length;
487
+ for (let i = 0; i < input_conversationSummaryList_length; i++) {
488
+ getTypeCacheKeys$1(rootKeySet, luvio, input.conversationSummaryList[i]);
489
+ }
490
+ }
491
+
492
+ function select(luvio, params) {
493
+ return select$1();
494
+ }
495
+ function keyBuilder$1(luvio, params) {
496
+ return keyBuilder$2(luvio, {
497
+ id: params.urlParams.id
498
+ });
499
+ }
500
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
501
+ getTypeCacheKeys(storeKeyMap, luvio, response);
502
+ }
503
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
504
+ const { body } = response;
505
+ const key = keyBuilder$1(luvio, resourceParams);
506
+ luvio.storeIngest(key, ingest, body);
507
+ const snapshot = luvio.storeLookup({
508
+ recordId: key,
509
+ node: select(),
510
+ variables: {},
511
+ }, snapshotRefresh);
512
+ if (process.env.NODE_ENV !== 'production') {
513
+ if (snapshot.state !== 'Fulfilled') {
514
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
515
+ }
516
+ }
517
+ deepFreeze(snapshot.data);
518
+ return snapshot;
519
+ }
520
+ function ingestError(luvio, params, error, snapshotRefresh) {
521
+ const key = keyBuilder$1(luvio, params);
522
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
523
+ const storeMetadataParams = {
524
+ ttl: TTL,
525
+ namespace: keyPrefix,
526
+ version: VERSION,
527
+ representationName: RepresentationType
528
+ };
529
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
530
+ return errorSnapshot;
531
+ }
532
+ function createResourceRequest(config) {
533
+ const headers = {};
534
+ return {
535
+ baseUri: '/services/data/v59.0',
536
+ basePath: '/conversation/summary/related/' + config.urlParams.id + '',
537
+ method: 'get',
538
+ body: null,
539
+ urlParams: config.urlParams,
540
+ queryParams: {},
541
+ headers,
542
+ priority: 'normal',
543
+ };
544
+ }
545
+
546
+ const getConversationSummaryRelatedList_ConfigPropertyNames = {
547
+ displayName: 'getConversationSummaryRelatedList',
548
+ parameters: {
549
+ required: ['id'],
550
+ optional: []
551
+ }
552
+ };
553
+ function createResourceParams(config) {
554
+ const resourceParams = {
555
+ urlParams: {
556
+ id: config.id
557
+ }
558
+ };
559
+ return resourceParams;
560
+ }
561
+ function keyBuilder(luvio, config) {
562
+ const resourceParams = createResourceParams(config);
563
+ return keyBuilder$1(luvio, resourceParams);
564
+ }
565
+ function typeCheckConfig(untrustedConfig) {
566
+ const config = {};
567
+ const untrustedConfig_id = untrustedConfig.id;
568
+ if (typeof untrustedConfig_id === 'string') {
569
+ config.id = untrustedConfig_id;
570
+ }
571
+ return config;
572
+ }
573
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
574
+ if (!untrustedIsObject(untrustedConfig)) {
575
+ return null;
576
+ }
577
+ if (process.env.NODE_ENV !== 'production') {
578
+ validateConfig(untrustedConfig, configPropertyNames);
579
+ }
580
+ const config = typeCheckConfig(untrustedConfig);
581
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
582
+ return null;
583
+ }
584
+ return config;
585
+ }
586
+ function adapterFragment(luvio, config) {
587
+ createResourceParams(config);
588
+ return select();
589
+ }
590
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
591
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
592
+ config,
593
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
594
+ });
595
+ return luvio.storeBroadcast().then(() => snapshot);
596
+ }
597
+ function onFetchResponseError(luvio, config, resourceParams, response) {
598
+ const snapshot = ingestError(luvio, resourceParams, response, {
599
+ config,
600
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
601
+ });
602
+ return luvio.storeBroadcast().then(() => snapshot);
603
+ }
604
+ function buildNetworkSnapshot(luvio, config, options) {
605
+ const resourceParams = createResourceParams(config);
606
+ const request = createResourceRequest(resourceParams);
607
+ return luvio.dispatchResourceRequest(request, options)
608
+ .then((response) => {
609
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
610
+ const cache = new StoreKeyMap();
611
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
612
+ return cache;
613
+ });
614
+ }, (response) => {
615
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
616
+ });
617
+ }
618
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
619
+ const { luvio, config } = context;
620
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
621
+ const dispatchOptions = {
622
+ resourceRequestContext: {
623
+ requestCorrelator,
624
+ luvioRequestMethod: undefined,
625
+ },
626
+ eventObservers
627
+ };
628
+ if (networkPriority !== 'normal') {
629
+ dispatchOptions.overrides = {
630
+ priority: networkPriority
631
+ };
632
+ }
633
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
634
+ }
635
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
636
+ const { luvio, config } = context;
637
+ const selector = {
638
+ recordId: keyBuilder(luvio, config),
639
+ node: adapterFragment(luvio, config),
640
+ variables: {},
641
+ };
642
+ const cacheSnapshot = storeLookup(selector, {
643
+ config,
644
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
645
+ });
646
+ return cacheSnapshot;
647
+ }
648
+ const getConversationSummaryRelatedListAdapterFactory = (luvio) => function eci__getConversationSummaryRelatedList(untrustedConfig, requestContext) {
649
+ const config = validateAdapterConfig(untrustedConfig, getConversationSummaryRelatedList_ConfigPropertyNames);
650
+ // Invalid or incomplete config
651
+ if (config === null) {
652
+ return null;
653
+ }
654
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
655
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
656
+ };
657
+
658
+ export { generateConversationSummaryAdapterFactory, getConversationSummaryRelatedListAdapterFactory };