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