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