@salesforce/lds-adapters-industries-dataloading 1.100.2

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,637 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ (function (global, factory) {
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
9
+ typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.industriesDataloading = {}, global.engine));
11
+ })(this, (function (exports, engine) { 'use strict';
12
+
13
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
14
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
15
+ const { isArray: ArrayIsArray$1 } = Array;
16
+ /**
17
+ * Validates an adapter config is well-formed.
18
+ * @param config The config to validate.
19
+ * @param adapter The adapter validation configuration.
20
+ * @param oneOf The keys the config must contain at least one of.
21
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
22
+ */
23
+ function validateConfig(config, adapter, oneOf) {
24
+ const { displayName } = adapter;
25
+ const { required, optional, unsupported } = adapter.parameters;
26
+ if (config === undefined ||
27
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
28
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
29
+ }
30
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
31
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
32
+ }
33
+ if (unsupported !== undefined &&
34
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
35
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
36
+ }
37
+ const supported = required.concat(optional);
38
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
39
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
40
+ }
41
+ }
42
+ function untrustedIsObject(untrusted) {
43
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
44
+ }
45
+ function areRequiredParametersPresent(config, configPropertyNames) {
46
+ return configPropertyNames.parameters.required.every(req => req in config);
47
+ }
48
+ const snapshotRefreshOptions = {
49
+ overrides: {
50
+ headers: {
51
+ 'Cache-Control': 'no-cache',
52
+ },
53
+ }
54
+ };
55
+ const keyPrefix = 'dataloading';
56
+
57
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
58
+ const { isArray: ArrayIsArray } = Array;
59
+ const { stringify: JSONStringify } = JSON;
60
+ function createLink(ref) {
61
+ return {
62
+ __ref: engine.serializeStructuredKey(ref),
63
+ };
64
+ }
65
+
66
+ const TTL$1 = 300;
67
+ const VERSION$1 = "b425ebad11bb7cc3aa194625f9745e2a";
68
+ function validate$2(obj, path = 'ObjectCsvDataTemplateRepresentation') {
69
+ const v_error = (() => {
70
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
71
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
72
+ }
73
+ const obj_code = obj.code;
74
+ const path_code = path + '.code';
75
+ if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
76
+ return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
77
+ }
78
+ const obj_message = obj.message;
79
+ const path_message = path + '.message';
80
+ if (typeof obj_message !== 'string') {
81
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
82
+ }
83
+ const obj_template = obj.template;
84
+ const path_template = path + '.template';
85
+ if (typeof obj_template !== 'object' || ArrayIsArray(obj_template) || obj_template === null) {
86
+ return new TypeError('Expected "object" but received "' + typeof obj_template + '" (at "' + path_template + '")');
87
+ }
88
+ })();
89
+ return v_error === undefined ? null : v_error;
90
+ }
91
+ const RepresentationType$1 = 'ObjectCsvDataTemplateRepresentation';
92
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
93
+ return input;
94
+ }
95
+ const select$3 = function ObjectCsvDataTemplateRepresentationSelect() {
96
+ return {
97
+ kind: 'Fragment',
98
+ version: VERSION$1,
99
+ private: [],
100
+ opaque: true
101
+ };
102
+ };
103
+ function equals$1(existing, incoming) {
104
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
105
+ return false;
106
+ }
107
+ return true;
108
+ }
109
+ function deepFreeze$2(input) {
110
+ const input_template = input.template;
111
+ ObjectFreeze(input_template);
112
+ ObjectFreeze(input);
113
+ }
114
+ const ingest$1 = function ObjectCsvDataTemplateRepresentationIngest(input, path, luvio, store, timestamp) {
115
+ if (process.env.NODE_ENV !== 'production') {
116
+ const validateError = validate$2(input);
117
+ if (validateError !== null) {
118
+ throw validateError;
119
+ }
120
+ }
121
+ const key = path.fullPath;
122
+ const existingRecord = store.readEntry(key);
123
+ const ttlToUse = TTL$1;
124
+ let incomingRecord = normalize$1(input, store.readEntry(key), {
125
+ fullPath: key,
126
+ parent: path.parent,
127
+ propertyName: path.propertyName,
128
+ ttl: ttlToUse
129
+ });
130
+ deepFreeze$2(input);
131
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
132
+ luvio.storePublish(key, incomingRecord);
133
+ }
134
+ {
135
+ const storeMetadataParams = {
136
+ ttl: ttlToUse,
137
+ namespace: "dataloading",
138
+ version: VERSION$1,
139
+ representationName: RepresentationType$1,
140
+ };
141
+ luvio.publishStoreMetadata(key, storeMetadataParams);
142
+ }
143
+ return createLink(key);
144
+ };
145
+ function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
146
+ const rootKeySet = new engine.StoreKeyMap();
147
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
148
+ const rootKey = fullPathFactory();
149
+ rootKeySet.set(rootKey, {
150
+ namespace: keyPrefix,
151
+ representationName: RepresentationType$1,
152
+ mergeable: false
153
+ });
154
+ return rootKeySet;
155
+ }
156
+
157
+ function select$2(luvio, params) {
158
+ return select$3();
159
+ }
160
+ function keyBuilder$3(luvio, params) {
161
+ return keyPrefix + '::ObjectCsvDataTemplateRepresentation:(' + 'objectApiName:' + params.urlParams.objectApiName + ')';
162
+ }
163
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
164
+ return getTypeCacheKeys$1(luvio, response, () => keyBuilder$3(luvio, resourceParams));
165
+ }
166
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
167
+ const { body } = response;
168
+ const key = keyBuilder$3(luvio, resourceParams);
169
+ luvio.storeIngest(key, ingest$1, body);
170
+ const snapshot = luvio.storeLookup({
171
+ recordId: key,
172
+ node: select$2(),
173
+ variables: {},
174
+ }, snapshotRefresh);
175
+ if (process.env.NODE_ENV !== 'production') {
176
+ if (snapshot.state !== 'Fulfilled') {
177
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
178
+ }
179
+ }
180
+ return snapshot;
181
+ }
182
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
183
+ const key = keyBuilder$3(luvio, params);
184
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
185
+ const storeMetadataParams = {
186
+ ttl: TTL$1,
187
+ namespace: keyPrefix,
188
+ version: VERSION$1,
189
+ representationName: RepresentationType$1
190
+ };
191
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
192
+ return errorSnapshot;
193
+ }
194
+ function createResourceRequest$1(config) {
195
+ const headers = {};
196
+ return {
197
+ baseUri: '/services/data/v58.0',
198
+ basePath: '/connect/industries/dataloading/csv-data-template/' + config.urlParams.objectApiName + '',
199
+ method: 'get',
200
+ body: null,
201
+ urlParams: config.urlParams,
202
+ queryParams: {},
203
+ headers,
204
+ priority: 'normal',
205
+ };
206
+ }
207
+
208
+ const getCsvDataTemplate_ConfigPropertyNames = {
209
+ displayName: 'getCsvDataTemplate',
210
+ parameters: {
211
+ required: ['objectApiName'],
212
+ optional: []
213
+ }
214
+ };
215
+ function createResourceParams$1(config) {
216
+ const resourceParams = {
217
+ urlParams: {
218
+ objectApiName: config.objectApiName
219
+ }
220
+ };
221
+ return resourceParams;
222
+ }
223
+ function keyBuilder$2(luvio, config) {
224
+ const resourceParams = createResourceParams$1(config);
225
+ return keyBuilder$3(luvio, resourceParams);
226
+ }
227
+ function typeCheckConfig$1(untrustedConfig) {
228
+ const config = {};
229
+ const untrustedConfig_objectApiName = untrustedConfig.objectApiName;
230
+ if (typeof untrustedConfig_objectApiName === 'string') {
231
+ config.objectApiName = untrustedConfig_objectApiName;
232
+ }
233
+ return config;
234
+ }
235
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
236
+ if (!untrustedIsObject(untrustedConfig)) {
237
+ return null;
238
+ }
239
+ if (process.env.NODE_ENV !== 'production') {
240
+ validateConfig(untrustedConfig, configPropertyNames);
241
+ }
242
+ const config = typeCheckConfig$1(untrustedConfig);
243
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
244
+ return null;
245
+ }
246
+ return config;
247
+ }
248
+ function adapterFragment$1(luvio, config) {
249
+ createResourceParams$1(config);
250
+ return select$2();
251
+ }
252
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
253
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
254
+ config,
255
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
256
+ });
257
+ return luvio.storeBroadcast().then(() => snapshot);
258
+ }
259
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
260
+ const snapshot = ingestError$1(luvio, resourceParams, response, {
261
+ config,
262
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
263
+ });
264
+ return luvio.storeBroadcast().then(() => snapshot);
265
+ }
266
+ function buildNetworkSnapshot$1(luvio, config, options) {
267
+ const resourceParams = createResourceParams$1(config);
268
+ const request = createResourceRequest$1(resourceParams);
269
+ return luvio.dispatchResourceRequest(request, options)
270
+ .then((response) => {
271
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
272
+ }, (response) => {
273
+ return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
274
+ });
275
+ }
276
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
277
+ const { luvio, config } = context;
278
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
279
+ const dispatchOptions = {
280
+ resourceRequestContext: {
281
+ requestCorrelator,
282
+ luvioRequestMethod: undefined,
283
+ },
284
+ eventObservers
285
+ };
286
+ if (networkPriority !== 'normal') {
287
+ dispatchOptions.overrides = {
288
+ priority: networkPriority
289
+ };
290
+ }
291
+ return buildNetworkSnapshot$1(luvio, config, dispatchOptions);
292
+ }
293
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
294
+ const { luvio, config } = context;
295
+ const selector = {
296
+ recordId: keyBuilder$2(luvio, config),
297
+ node: adapterFragment$1(luvio, config),
298
+ variables: {},
299
+ };
300
+ const cacheSnapshot = storeLookup(selector, {
301
+ config,
302
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
303
+ });
304
+ return cacheSnapshot;
305
+ }
306
+ const getCsvDataTemplateAdapterFactory = (luvio) => function dataloading__getCsvDataTemplate(untrustedConfig, requestContext) {
307
+ const config = validateAdapterConfig$1(untrustedConfig, getCsvDataTemplate_ConfigPropertyNames);
308
+ // Invalid or incomplete config
309
+ if (config === null) {
310
+ return null;
311
+ }
312
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
313
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
314
+ };
315
+
316
+ function validate$1(obj, path = 'FeatureObjectRepresentation') {
317
+ const v_error = (() => {
318
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
319
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
320
+ }
321
+ const obj_apiName = obj.apiName;
322
+ const path_apiName = path + '.apiName';
323
+ if (typeof obj_apiName !== 'string') {
324
+ return new TypeError('Expected "string" but received "' + typeof obj_apiName + '" (at "' + path_apiName + '")');
325
+ }
326
+ const obj_label = obj.label;
327
+ const path_label = path + '.label';
328
+ if (typeof obj_label !== 'string') {
329
+ return new TypeError('Expected "string" but received "' + typeof obj_label + '" (at "' + path_label + '")');
330
+ }
331
+ })();
332
+ return v_error === undefined ? null : v_error;
333
+ }
334
+ function deepFreeze$1(input) {
335
+ ObjectFreeze(input);
336
+ }
337
+
338
+ const TTL = 300;
339
+ const VERSION = "440ab792d2d7f730b3d308c484a9222b";
340
+ function validate(obj, path = 'FeatureObjectsResultRepresentation') {
341
+ const v_error = (() => {
342
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
343
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
344
+ }
345
+ const obj_code = obj.code;
346
+ const path_code = path + '.code';
347
+ if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
348
+ return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
349
+ }
350
+ const obj_currentPageNumber = obj.currentPageNumber;
351
+ const path_currentPageNumber = path + '.currentPageNumber';
352
+ if (typeof obj_currentPageNumber !== 'number' || (typeof obj_currentPageNumber === 'number' && Math.floor(obj_currentPageNumber) !== obj_currentPageNumber)) {
353
+ return new TypeError('Expected "integer" but received "' + typeof obj_currentPageNumber + '" (at "' + path_currentPageNumber + '")');
354
+ }
355
+ const obj_currentPageSize = obj.currentPageSize;
356
+ const path_currentPageSize = path + '.currentPageSize';
357
+ if (typeof obj_currentPageSize !== 'number' || (typeof obj_currentPageSize === 'number' && Math.floor(obj_currentPageSize) !== obj_currentPageSize)) {
358
+ return new TypeError('Expected "integer" but received "' + typeof obj_currentPageSize + '" (at "' + path_currentPageSize + '")');
359
+ }
360
+ const obj_message = obj.message;
361
+ const path_message = path + '.message';
362
+ if (typeof obj_message !== 'string') {
363
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
364
+ }
365
+ const obj_objects = obj.objects;
366
+ const path_objects = path + '.objects';
367
+ if (!ArrayIsArray(obj_objects)) {
368
+ return new TypeError('Expected "array" but received "' + typeof obj_objects + '" (at "' + path_objects + '")');
369
+ }
370
+ for (let i = 0; i < obj_objects.length; i++) {
371
+ const obj_objects_item = obj_objects[i];
372
+ const path_objects_item = path_objects + '[' + i + ']';
373
+ const referencepath_objects_itemValidationError = validate$1(obj_objects_item, path_objects_item);
374
+ if (referencepath_objects_itemValidationError !== null) {
375
+ let message = 'Object doesn\'t match FeatureObjectRepresentation (at "' + path_objects_item + '")\n';
376
+ message += referencepath_objects_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
377
+ return new TypeError(message);
378
+ }
379
+ }
380
+ const obj_totalAvailableItems = obj.totalAvailableItems;
381
+ const path_totalAvailableItems = path + '.totalAvailableItems';
382
+ if (typeof obj_totalAvailableItems !== 'number' || (typeof obj_totalAvailableItems === 'number' && Math.floor(obj_totalAvailableItems) !== obj_totalAvailableItems)) {
383
+ return new TypeError('Expected "integer" but received "' + typeof obj_totalAvailableItems + '" (at "' + path_totalAvailableItems + '")');
384
+ }
385
+ })();
386
+ return v_error === undefined ? null : v_error;
387
+ }
388
+ const RepresentationType = 'FeatureObjectsResultRepresentation';
389
+ function normalize(input, existing, path, luvio, store, timestamp) {
390
+ return input;
391
+ }
392
+ const select$1 = function FeatureObjectsResultRepresentationSelect() {
393
+ return {
394
+ kind: 'Fragment',
395
+ version: VERSION,
396
+ private: [],
397
+ opaque: true
398
+ };
399
+ };
400
+ function equals(existing, incoming) {
401
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
402
+ return false;
403
+ }
404
+ return true;
405
+ }
406
+ function deepFreeze(input) {
407
+ const input_objects = input.objects;
408
+ for (let i = 0; i < input_objects.length; i++) {
409
+ const input_objects_item = input_objects[i];
410
+ deepFreeze$1(input_objects_item);
411
+ }
412
+ ObjectFreeze(input_objects);
413
+ ObjectFreeze(input);
414
+ }
415
+ const ingest = function FeatureObjectsResultRepresentationIngest(input, path, luvio, store, timestamp) {
416
+ if (process.env.NODE_ENV !== 'production') {
417
+ const validateError = validate(input);
418
+ if (validateError !== null) {
419
+ throw validateError;
420
+ }
421
+ }
422
+ const key = path.fullPath;
423
+ const existingRecord = store.readEntry(key);
424
+ const ttlToUse = TTL;
425
+ let incomingRecord = normalize(input, store.readEntry(key), {
426
+ fullPath: key,
427
+ parent: path.parent,
428
+ propertyName: path.propertyName,
429
+ ttl: ttlToUse
430
+ });
431
+ deepFreeze(input);
432
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
433
+ luvio.storePublish(key, incomingRecord);
434
+ }
435
+ {
436
+ const storeMetadataParams = {
437
+ ttl: ttlToUse,
438
+ namespace: "dataloading",
439
+ version: VERSION,
440
+ representationName: RepresentationType,
441
+ };
442
+ luvio.publishStoreMetadata(key, storeMetadataParams);
443
+ }
444
+ return createLink(key);
445
+ };
446
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
447
+ const rootKeySet = new engine.StoreKeyMap();
448
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
449
+ const rootKey = fullPathFactory();
450
+ rootKeySet.set(rootKey, {
451
+ namespace: keyPrefix,
452
+ representationName: RepresentationType,
453
+ mergeable: false
454
+ });
455
+ return rootKeySet;
456
+ }
457
+
458
+ function select(luvio, params) {
459
+ return select$1();
460
+ }
461
+ function keyBuilder$1(luvio, params) {
462
+ return keyPrefix + '::FeatureObjectsResultRepresentation:(' + 'limit:' + params.queryParams.limit + ',' + 'offset:' + params.queryParams.offset + ',' + 'type:' + params.queryParams.type + ',' + 'featureName:' + params.urlParams.featureName + ')';
463
+ }
464
+ function getResponseCacheKeys(luvio, resourceParams, response) {
465
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
466
+ }
467
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
468
+ const { body } = response;
469
+ const key = keyBuilder$1(luvio, resourceParams);
470
+ luvio.storeIngest(key, ingest, body);
471
+ const snapshot = luvio.storeLookup({
472
+ recordId: key,
473
+ node: select(),
474
+ variables: {},
475
+ }, snapshotRefresh);
476
+ if (process.env.NODE_ENV !== 'production') {
477
+ if (snapshot.state !== 'Fulfilled') {
478
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
479
+ }
480
+ }
481
+ return snapshot;
482
+ }
483
+ function ingestError(luvio, params, error, snapshotRefresh) {
484
+ const key = keyBuilder$1(luvio, params);
485
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
486
+ const storeMetadataParams = {
487
+ ttl: TTL,
488
+ namespace: keyPrefix,
489
+ version: VERSION,
490
+ representationName: RepresentationType
491
+ };
492
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
493
+ return errorSnapshot;
494
+ }
495
+ function createResourceRequest(config) {
496
+ const headers = {};
497
+ return {
498
+ baseUri: '/services/data/v58.0',
499
+ basePath: '/connect/industries/' + config.urlParams.featureName + '/objects',
500
+ method: 'get',
501
+ body: null,
502
+ urlParams: config.urlParams,
503
+ queryParams: config.queryParams,
504
+ headers,
505
+ priority: 'normal',
506
+ };
507
+ }
508
+
509
+ const getObjectsForFeature_ConfigPropertyNames = {
510
+ displayName: 'getObjectsForFeature',
511
+ parameters: {
512
+ required: ['featureName', 'type'],
513
+ optional: ['limit', 'offset']
514
+ }
515
+ };
516
+ function createResourceParams(config) {
517
+ const resourceParams = {
518
+ urlParams: {
519
+ featureName: config.featureName
520
+ },
521
+ queryParams: {
522
+ limit: config.limit, offset: config.offset, type: config.type
523
+ }
524
+ };
525
+ return resourceParams;
526
+ }
527
+ function keyBuilder(luvio, config) {
528
+ const resourceParams = createResourceParams(config);
529
+ return keyBuilder$1(luvio, resourceParams);
530
+ }
531
+ function typeCheckConfig(untrustedConfig) {
532
+ const config = {};
533
+ const untrustedConfig_featureName = untrustedConfig.featureName;
534
+ if (typeof untrustedConfig_featureName === 'string') {
535
+ config.featureName = untrustedConfig_featureName;
536
+ }
537
+ const untrustedConfig_limit = untrustedConfig.limit;
538
+ if (typeof untrustedConfig_limit === 'number' && Math.floor(untrustedConfig_limit) === untrustedConfig_limit) {
539
+ config.limit = untrustedConfig_limit;
540
+ }
541
+ const untrustedConfig_offset = untrustedConfig.offset;
542
+ if (typeof untrustedConfig_offset === 'number' && Math.floor(untrustedConfig_offset) === untrustedConfig_offset) {
543
+ config.offset = untrustedConfig_offset;
544
+ }
545
+ const untrustedConfig_type = untrustedConfig.type;
546
+ if (typeof untrustedConfig_type === 'string') {
547
+ config.type = untrustedConfig_type;
548
+ }
549
+ return config;
550
+ }
551
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
552
+ if (!untrustedIsObject(untrustedConfig)) {
553
+ return null;
554
+ }
555
+ if (process.env.NODE_ENV !== 'production') {
556
+ validateConfig(untrustedConfig, configPropertyNames);
557
+ }
558
+ const config = typeCheckConfig(untrustedConfig);
559
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
560
+ return null;
561
+ }
562
+ return config;
563
+ }
564
+ function adapterFragment(luvio, config) {
565
+ createResourceParams(config);
566
+ return select();
567
+ }
568
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
569
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
570
+ config,
571
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
572
+ });
573
+ return luvio.storeBroadcast().then(() => snapshot);
574
+ }
575
+ function onFetchResponseError(luvio, config, resourceParams, response) {
576
+ const snapshot = ingestError(luvio, resourceParams, response, {
577
+ config,
578
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
579
+ });
580
+ return luvio.storeBroadcast().then(() => snapshot);
581
+ }
582
+ function buildNetworkSnapshot(luvio, config, options) {
583
+ const resourceParams = createResourceParams(config);
584
+ const request = createResourceRequest(resourceParams);
585
+ return luvio.dispatchResourceRequest(request, options)
586
+ .then((response) => {
587
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
588
+ }, (response) => {
589
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
590
+ });
591
+ }
592
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
593
+ const { luvio, config } = context;
594
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
595
+ const dispatchOptions = {
596
+ resourceRequestContext: {
597
+ requestCorrelator,
598
+ luvioRequestMethod: undefined,
599
+ },
600
+ eventObservers
601
+ };
602
+ if (networkPriority !== 'normal') {
603
+ dispatchOptions.overrides = {
604
+ priority: networkPriority
605
+ };
606
+ }
607
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
608
+ }
609
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
610
+ const { luvio, config } = context;
611
+ const selector = {
612
+ recordId: keyBuilder(luvio, config),
613
+ node: adapterFragment(luvio, config),
614
+ variables: {},
615
+ };
616
+ const cacheSnapshot = storeLookup(selector, {
617
+ config,
618
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
619
+ });
620
+ return cacheSnapshot;
621
+ }
622
+ const getObjectsForFeatureAdapterFactory = (luvio) => function dataloading__getObjectsForFeature(untrustedConfig, requestContext) {
623
+ const config = validateAdapterConfig(untrustedConfig, getObjectsForFeature_ConfigPropertyNames);
624
+ // Invalid or incomplete config
625
+ if (config === null) {
626
+ return null;
627
+ }
628
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
629
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
630
+ };
631
+
632
+ exports.getCsvDataTemplateAdapterFactory = getCsvDataTemplateAdapterFactory;
633
+ exports.getObjectsForFeatureAdapterFactory = getObjectsForFeatureAdapterFactory;
634
+
635
+ Object.defineProperty(exports, '__esModule', { value: true });
636
+
637
+ }));