@salesforce/lds-adapters-industries-dataloading 0.1.0-dev1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sfdc/index.js ADDED
@@ -0,0 +1,585 @@
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, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$2, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from 'force/luvioEngine';
18
+
19
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
+ const { keys: ObjectKeys, create: ObjectCreate } = 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(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
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
62
+ return {
63
+ name,
64
+ required,
65
+ resourceType,
66
+ typeCheckShape,
67
+ isArrayShape,
68
+ coerceFn,
69
+ };
70
+ }
71
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
72
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
73
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
74
+ return {
75
+ displayName,
76
+ parameters: {
77
+ required,
78
+ optional,
79
+ }
80
+ };
81
+ }
82
+ const keyPrefix = 'dataloading';
83
+
84
+ const { isArray: ArrayIsArray } = Array;
85
+ const { stringify: JSONStringify } = JSON;
86
+ function createLink(ref) {
87
+ return {
88
+ __ref: serializeStructuredKey(ref),
89
+ };
90
+ }
91
+
92
+ const TTL$1 = 300;
93
+ const VERSION$1 = "b425ebad11bb7cc3aa194625f9745e2a";
94
+ function validate$2(obj, path = 'ObjectCsvDataTemplateRepresentation') {
95
+ const v_error = (() => {
96
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
97
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
98
+ }
99
+ const obj_code = obj.code;
100
+ const path_code = path + '.code';
101
+ if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
102
+ return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
103
+ }
104
+ const obj_message = obj.message;
105
+ const path_message = path + '.message';
106
+ if (typeof obj_message !== 'string') {
107
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
108
+ }
109
+ const obj_template = obj.template;
110
+ const path_template = path + '.template';
111
+ if (typeof obj_template !== 'object' || ArrayIsArray(obj_template) || obj_template === null) {
112
+ return new TypeError('Expected "object" but received "' + typeof obj_template + '" (at "' + path_template + '")');
113
+ }
114
+ })();
115
+ return v_error === undefined ? null : v_error;
116
+ }
117
+ const RepresentationType$1 = 'ObjectCsvDataTemplateRepresentation';
118
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
119
+ return input;
120
+ }
121
+ const select$3 = function ObjectCsvDataTemplateRepresentationSelect() {
122
+ return {
123
+ kind: 'Fragment',
124
+ version: VERSION$1,
125
+ private: [],
126
+ opaque: true
127
+ };
128
+ };
129
+ function equals$1(existing, incoming) {
130
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
131
+ return false;
132
+ }
133
+ return true;
134
+ }
135
+ const ingest$1 = function ObjectCsvDataTemplateRepresentationIngest(input, path, luvio, store, timestamp) {
136
+ if (process.env.NODE_ENV !== 'production') {
137
+ const validateError = validate$2(input);
138
+ if (validateError !== null) {
139
+ throw validateError;
140
+ }
141
+ }
142
+ const key = path.fullPath;
143
+ const ttlToUse = TTL$1;
144
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "dataloading", VERSION$1, RepresentationType$1, equals$1);
145
+ return createLink(key);
146
+ };
147
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
148
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
149
+ const rootKey = fullPathFactory();
150
+ rootKeySet.set(rootKey, {
151
+ namespace: keyPrefix,
152
+ representationName: RepresentationType$1,
153
+ mergeable: false
154
+ });
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(storeKeyMap, luvio, resourceParams, response) {
164
+ getTypeCacheKeys$1(storeKeyMap, 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
+ deepFreeze(snapshot.data);
181
+ return snapshot;
182
+ }
183
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
184
+ const key = keyBuilder$3(luvio, params);
185
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
186
+ const 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
+ const headers = {};
197
+ return {
198
+ baseUri: '/services/data/v66.0',
199
+ basePath: '/connect/industries/csv-data-template/' + config.urlParams.objectApiName + '',
200
+ method: 'get',
201
+ body: null,
202
+ urlParams: config.urlParams,
203
+ queryParams: {},
204
+ headers,
205
+ priority: 'normal',
206
+ };
207
+ }
208
+
209
+ const adapterName$1 = 'getCsvDataTemplate';
210
+ const getCsvDataTemplate_ConfigPropertyMetadata = [
211
+ generateParamConfigMetadata('objectApiName', true, 0 /* UrlParameter */, 0 /* String */),
212
+ ];
213
+ const getCsvDataTemplate_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getCsvDataTemplate_ConfigPropertyMetadata);
214
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getCsvDataTemplate_ConfigPropertyMetadata);
215
+ function keyBuilder$2(luvio, config) {
216
+ const resourceParams = createResourceParams$1(config);
217
+ return keyBuilder$3(luvio, resourceParams);
218
+ }
219
+ function typeCheckConfig$1(untrustedConfig) {
220
+ const config = {};
221
+ typeCheckConfig$2(untrustedConfig, config, getCsvDataTemplate_ConfigPropertyMetadata);
222
+ return config;
223
+ }
224
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
225
+ if (!untrustedIsObject(untrustedConfig)) {
226
+ return null;
227
+ }
228
+ if (process.env.NODE_ENV !== 'production') {
229
+ validateConfig(untrustedConfig, configPropertyNames);
230
+ }
231
+ const config = typeCheckConfig$1(untrustedConfig);
232
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
233
+ return null;
234
+ }
235
+ return config;
236
+ }
237
+ function adapterFragment$1(luvio, config) {
238
+ createResourceParams$1(config);
239
+ return select$2();
240
+ }
241
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
242
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
243
+ config,
244
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
245
+ });
246
+ return luvio.storeBroadcast().then(() => snapshot);
247
+ }
248
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
249
+ const snapshot = ingestError$1(luvio, resourceParams, response, {
250
+ config,
251
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
252
+ });
253
+ return luvio.storeBroadcast().then(() => snapshot);
254
+ }
255
+ function buildNetworkSnapshot$1(luvio, config, options) {
256
+ const resourceParams = createResourceParams$1(config);
257
+ const request = createResourceRequest$1(resourceParams);
258
+ return luvio.dispatchResourceRequest(request, options)
259
+ .then((response) => {
260
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => {
261
+ const cache = new StoreKeyMap();
262
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
263
+ return cache;
264
+ });
265
+ }, (response) => {
266
+ return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
267
+ });
268
+ }
269
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
270
+ return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
271
+ }
272
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
273
+ const { luvio, config } = context;
274
+ const selector = {
275
+ recordId: keyBuilder$2(luvio, config),
276
+ node: adapterFragment$1(luvio, config),
277
+ variables: {},
278
+ };
279
+ const cacheSnapshot = storeLookup(selector, {
280
+ config,
281
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
282
+ });
283
+ return cacheSnapshot;
284
+ }
285
+ const getCsvDataTemplateAdapterFactory = (luvio) => function dataloading__getCsvDataTemplate(untrustedConfig, requestContext) {
286
+ const config = validateAdapterConfig$1(untrustedConfig, getCsvDataTemplate_ConfigPropertyNames);
287
+ // Invalid or incomplete config
288
+ if (config === null) {
289
+ return null;
290
+ }
291
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
292
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
293
+ };
294
+
295
+ function validate$1(obj, path = 'FeatureObjectRepresentation') {
296
+ const v_error = (() => {
297
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
298
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
299
+ }
300
+ const obj_apiName = obj.apiName;
301
+ const path_apiName = path + '.apiName';
302
+ if (typeof obj_apiName !== 'string') {
303
+ return new TypeError('Expected "string" but received "' + typeof obj_apiName + '" (at "' + path_apiName + '")');
304
+ }
305
+ const obj_label = obj.label;
306
+ const path_label = path + '.label';
307
+ if (typeof obj_label !== 'string') {
308
+ return new TypeError('Expected "string" but received "' + typeof obj_label + '" (at "' + path_label + '")');
309
+ }
310
+ })();
311
+ return v_error === undefined ? null : v_error;
312
+ }
313
+
314
+ const TTL = 300;
315
+ const VERSION = "440ab792d2d7f730b3d308c484a9222b";
316
+ function validate(obj, path = 'FeatureObjectsResultRepresentation') {
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_code = obj.code;
322
+ const path_code = path + '.code';
323
+ if (typeof obj_code !== 'number' || (typeof obj_code === 'number' && Math.floor(obj_code) !== obj_code)) {
324
+ return new TypeError('Expected "integer" but received "' + typeof obj_code + '" (at "' + path_code + '")');
325
+ }
326
+ const obj_currentPageNumber = obj.currentPageNumber;
327
+ const path_currentPageNumber = path + '.currentPageNumber';
328
+ if (typeof obj_currentPageNumber !== 'number' || (typeof obj_currentPageNumber === 'number' && Math.floor(obj_currentPageNumber) !== obj_currentPageNumber)) {
329
+ return new TypeError('Expected "integer" but received "' + typeof obj_currentPageNumber + '" (at "' + path_currentPageNumber + '")');
330
+ }
331
+ const obj_currentPageSize = obj.currentPageSize;
332
+ const path_currentPageSize = path + '.currentPageSize';
333
+ if (typeof obj_currentPageSize !== 'number' || (typeof obj_currentPageSize === 'number' && Math.floor(obj_currentPageSize) !== obj_currentPageSize)) {
334
+ return new TypeError('Expected "integer" but received "' + typeof obj_currentPageSize + '" (at "' + path_currentPageSize + '")');
335
+ }
336
+ const obj_message = obj.message;
337
+ const path_message = path + '.message';
338
+ if (typeof obj_message !== 'string') {
339
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
340
+ }
341
+ const obj_objects = obj.objects;
342
+ const path_objects = path + '.objects';
343
+ if (!ArrayIsArray(obj_objects)) {
344
+ return new TypeError('Expected "array" but received "' + typeof obj_objects + '" (at "' + path_objects + '")');
345
+ }
346
+ for (let i = 0; i < obj_objects.length; i++) {
347
+ const obj_objects_item = obj_objects[i];
348
+ const path_objects_item = path_objects + '[' + i + ']';
349
+ const referencepath_objects_itemValidationError = validate$1(obj_objects_item, path_objects_item);
350
+ if (referencepath_objects_itemValidationError !== null) {
351
+ let message = 'Object doesn\'t match FeatureObjectRepresentation (at "' + path_objects_item + '")\n';
352
+ message += referencepath_objects_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
353
+ return new TypeError(message);
354
+ }
355
+ }
356
+ const obj_totalAvailableItems = obj.totalAvailableItems;
357
+ const path_totalAvailableItems = path + '.totalAvailableItems';
358
+ if (typeof obj_totalAvailableItems !== 'number' || (typeof obj_totalAvailableItems === 'number' && Math.floor(obj_totalAvailableItems) !== obj_totalAvailableItems)) {
359
+ return new TypeError('Expected "integer" but received "' + typeof obj_totalAvailableItems + '" (at "' + path_totalAvailableItems + '")');
360
+ }
361
+ })();
362
+ return v_error === undefined ? null : v_error;
363
+ }
364
+ const RepresentationType = 'FeatureObjectsResultRepresentation';
365
+ function normalize(input, existing, path, luvio, store, timestamp) {
366
+ return input;
367
+ }
368
+ const select$1 = function FeatureObjectsResultRepresentationSelect() {
369
+ return {
370
+ kind: 'Fragment',
371
+ version: VERSION,
372
+ private: [],
373
+ opaque: true
374
+ };
375
+ };
376
+ function equals(existing, incoming) {
377
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
378
+ return false;
379
+ }
380
+ return true;
381
+ }
382
+ const ingest = function FeatureObjectsResultRepresentationIngest(input, path, luvio, store, timestamp) {
383
+ if (process.env.NODE_ENV !== 'production') {
384
+ const validateError = validate(input);
385
+ if (validateError !== null) {
386
+ throw validateError;
387
+ }
388
+ }
389
+ const key = path.fullPath;
390
+ const ttlToUse = TTL;
391
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "dataloading", VERSION, RepresentationType, equals);
392
+ return createLink(key);
393
+ };
394
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
395
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
396
+ const rootKey = fullPathFactory();
397
+ rootKeySet.set(rootKey, {
398
+ namespace: keyPrefix,
399
+ representationName: RepresentationType,
400
+ mergeable: false
401
+ });
402
+ }
403
+
404
+ function select(luvio, params) {
405
+ return select$1();
406
+ }
407
+ function keyBuilder$1(luvio, params) {
408
+ return keyPrefix + '::FeatureObjectsResultRepresentation:(' + 'limit:' + params.queryParams.limit + ',' + 'offset:' + params.queryParams.offset + ',' + 'entityType:' + params.queryParams.entityType + ',' + 'featureName:' + params.urlParams.featureName + ')';
409
+ }
410
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
411
+ getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
412
+ }
413
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
414
+ const { body } = response;
415
+ const key = keyBuilder$1(luvio, resourceParams);
416
+ luvio.storeIngest(key, ingest, body);
417
+ const snapshot = luvio.storeLookup({
418
+ recordId: key,
419
+ node: select(),
420
+ variables: {},
421
+ }, snapshotRefresh);
422
+ if (process.env.NODE_ENV !== 'production') {
423
+ if (snapshot.state !== 'Fulfilled') {
424
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
425
+ }
426
+ }
427
+ deepFreeze(snapshot.data);
428
+ return snapshot;
429
+ }
430
+ function ingestError(luvio, params, error, snapshotRefresh) {
431
+ const key = keyBuilder$1(luvio, params);
432
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
433
+ const storeMetadataParams = {
434
+ ttl: TTL,
435
+ namespace: keyPrefix,
436
+ version: VERSION,
437
+ representationName: RepresentationType
438
+ };
439
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
440
+ return errorSnapshot;
441
+ }
442
+ function createResourceRequest(config) {
443
+ const headers = {};
444
+ return {
445
+ baseUri: '/services/data/v66.0',
446
+ basePath: '/connect/industries/' + config.urlParams.featureName + '/objects',
447
+ method: 'get',
448
+ body: null,
449
+ urlParams: config.urlParams,
450
+ queryParams: config.queryParams,
451
+ headers,
452
+ priority: 'normal',
453
+ };
454
+ }
455
+
456
+ const adapterName = 'getObjectsForFeature';
457
+ const getObjectsForFeature_ConfigPropertyMetadata = [
458
+ generateParamConfigMetadata('featureName', true, 0 /* UrlParameter */, 0 /* String */),
459
+ generateParamConfigMetadata('limit', false, 1 /* QueryParameter */, 3 /* Integer */),
460
+ generateParamConfigMetadata('offset', false, 1 /* QueryParameter */, 3 /* Integer */),
461
+ generateParamConfigMetadata('entityType', true, 1 /* QueryParameter */, 0 /* String */),
462
+ ];
463
+ const getObjectsForFeature_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getObjectsForFeature_ConfigPropertyMetadata);
464
+ const createResourceParams = /*#__PURE__*/ createResourceParams$2(getObjectsForFeature_ConfigPropertyMetadata);
465
+ function keyBuilder(luvio, config) {
466
+ const resourceParams = createResourceParams(config);
467
+ return keyBuilder$1(luvio, resourceParams);
468
+ }
469
+ function typeCheckConfig(untrustedConfig) {
470
+ const config = {};
471
+ typeCheckConfig$2(untrustedConfig, config, getObjectsForFeature_ConfigPropertyMetadata);
472
+ return config;
473
+ }
474
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
475
+ if (!untrustedIsObject(untrustedConfig)) {
476
+ return null;
477
+ }
478
+ if (process.env.NODE_ENV !== 'production') {
479
+ validateConfig(untrustedConfig, configPropertyNames);
480
+ }
481
+ const config = typeCheckConfig(untrustedConfig);
482
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
483
+ return null;
484
+ }
485
+ return config;
486
+ }
487
+ function adapterFragment(luvio, config) {
488
+ createResourceParams(config);
489
+ return select();
490
+ }
491
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
492
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
493
+ config,
494
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
495
+ });
496
+ return luvio.storeBroadcast().then(() => snapshot);
497
+ }
498
+ function onFetchResponseError(luvio, config, resourceParams, response) {
499
+ const snapshot = ingestError(luvio, resourceParams, response, {
500
+ config,
501
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
502
+ });
503
+ return luvio.storeBroadcast().then(() => snapshot);
504
+ }
505
+ function buildNetworkSnapshot(luvio, config, options) {
506
+ const resourceParams = createResourceParams(config);
507
+ const request = createResourceRequest(resourceParams);
508
+ return luvio.dispatchResourceRequest(request, options)
509
+ .then((response) => {
510
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
511
+ const cache = new StoreKeyMap();
512
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
513
+ return cache;
514
+ });
515
+ }, (response) => {
516
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
517
+ });
518
+ }
519
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
520
+ return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
521
+ }
522
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
523
+ const { luvio, config } = context;
524
+ const selector = {
525
+ recordId: keyBuilder(luvio, config),
526
+ node: adapterFragment(luvio, config),
527
+ variables: {},
528
+ };
529
+ const cacheSnapshot = storeLookup(selector, {
530
+ config,
531
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
532
+ });
533
+ return cacheSnapshot;
534
+ }
535
+ const getObjectsForFeatureAdapterFactory = (luvio) => function dataloading__getObjectsForFeature(untrustedConfig, requestContext) {
536
+ const config = validateAdapterConfig(untrustedConfig, getObjectsForFeature_ConfigPropertyNames);
537
+ // Invalid or incomplete config
538
+ if (config === null) {
539
+ return null;
540
+ }
541
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
542
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
543
+ };
544
+
545
+ let getCsvDataTemplate;
546
+ let getObjectsForFeature;
547
+ // Imperative GET Adapters
548
+ let getCsvDataTemplate_imperative;
549
+ let getObjectsForFeature_imperative;
550
+ // Adapter Metadata
551
+ const getCsvDataTemplateMetadata = {
552
+ apiFamily: 'dataloading',
553
+ name: 'getCsvDataTemplate',
554
+ ttl: 300,
555
+ };
556
+ const getObjectsForFeatureMetadata = {
557
+ apiFamily: 'dataloading',
558
+ name: 'getObjectsForFeature',
559
+ ttl: 300,
560
+ };
561
+ // Notify Update Available
562
+ function bindExportsTo(luvio) {
563
+ // LDS Adapters
564
+ const getCsvDataTemplate_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getCsvDataTemplate', getCsvDataTemplateAdapterFactory), getCsvDataTemplateMetadata);
565
+ const getObjectsForFeature_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getObjectsForFeature', getObjectsForFeatureAdapterFactory), getObjectsForFeatureMetadata);
566
+ return {
567
+ getCsvDataTemplate: createWireAdapterConstructor(luvio, getCsvDataTemplate_ldsAdapter, getCsvDataTemplateMetadata),
568
+ getObjectsForFeature: createWireAdapterConstructor(luvio, getObjectsForFeature_ldsAdapter, getObjectsForFeatureMetadata),
569
+ // Imperative GET Adapters
570
+ getCsvDataTemplate_imperative: createImperativeAdapter(luvio, getCsvDataTemplate_ldsAdapter, getCsvDataTemplateMetadata),
571
+ getObjectsForFeature_imperative: createImperativeAdapter(luvio, getObjectsForFeature_ldsAdapter, getObjectsForFeatureMetadata),
572
+ // Notify Update Availables
573
+ };
574
+ }
575
+ withDefaultLuvio((luvio) => {
576
+ ({
577
+ getCsvDataTemplate,
578
+ getObjectsForFeature,
579
+ getCsvDataTemplate_imperative,
580
+ getObjectsForFeature_imperative,
581
+ } = bindExportsTo(luvio));
582
+ });
583
+
584
+ export { getCsvDataTemplate, getCsvDataTemplate_imperative, getObjectsForFeature, getObjectsForFeature_imperative };
585
+ // version: 0.1.0-dev1-c978a7b010
@@ -0,0 +1,115 @@
1
+ #%RAML 1.0
2
+ securedBy:
3
+ - OAuth2
4
+ title: Salesforce Connect API
5
+ version: '58.0'
6
+ mediaType: application/json
7
+ protocols:
8
+ - https
9
+ baseUri: /services/data/v66.0
10
+ securitySchemes:
11
+ OAuth2:
12
+ type: OAuth 2.0
13
+ settings:
14
+ authorizationUri: https://example.com/oauth/authorize
15
+ accessTokenUri: ''
16
+ authorizationGrants:
17
+ - implicit
18
+ annotationTypes:
19
+ oas-readOnly:
20
+ type: boolean
21
+ allowedTargets: TypeDeclaration
22
+ oas-collectionFormat:
23
+ type: string
24
+ oas-body-name:
25
+ type: string
26
+ allowedTargets: TypeDeclaration
27
+
28
+ types:
29
+ ObjectCsvDataTemplateRepresentation:
30
+ description: Output representation for csv data template
31
+ type: object
32
+ properties:
33
+ code:
34
+ description: return code
35
+ type: integer
36
+ message:
37
+ description: return message
38
+ type: string
39
+ template:
40
+ description: return template
41
+ type: object
42
+
43
+ FeatureObjectsResultRepresentation:
44
+ description: Output representation for objects for a feature
45
+ type: object
46
+ properties:
47
+ code:
48
+ description: return code
49
+ type: integer
50
+ currentPageNumber:
51
+ description: return currentPageNumber
52
+ type: integer
53
+ currentPageSize:
54
+ description: return currentPageSize
55
+ type: integer
56
+ message:
57
+ description: return message
58
+ type: string
59
+ objects:
60
+ description: return objects
61
+ type: array
62
+ items:
63
+ type: FeatureObjectRepresentation
64
+ totalAvailableItems:
65
+ description: return totalAvailableItems
66
+ type: integer
67
+
68
+ FeatureObjectRepresentation:
69
+ description: Representation for an object in list of objects
70
+ type: object
71
+ properties:
72
+ apiName:
73
+ description: return apiName
74
+ type: string
75
+ label:
76
+ description: return label
77
+ type: string
78
+
79
+ /connect/industries/csv-data-template/{objectApiName}:
80
+ get:
81
+ description: method to get CSV Data Template for an object
82
+ responses:
83
+ '200':
84
+ description: Success
85
+ body:
86
+ application/json:
87
+ type: ObjectCsvDataTemplateRepresentation
88
+ uriParameters:
89
+ objectApiName:
90
+ type: string
91
+ required: true
92
+
93
+ /connect/industries/{featureName}/objects:
94
+ get:
95
+ description: method to get list of objects for feature
96
+ responses:
97
+ '200':
98
+ description: Success
99
+ body:
100
+ application/json:
101
+ type: FeatureObjectsResultRepresentation
102
+ queryParameters:
103
+ limit:
104
+ type: integer
105
+ required: false
106
+ offset:
107
+ type: integer
108
+ required: false
109
+ entityType:
110
+ type: string
111
+ required: true
112
+ uriParameters:
113
+ featureName:
114
+ type: string
115
+ required: true