@salesforce/lds-adapters-platform-data-seed 1.339.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/platform-data-seed.js +685 -0
  3. package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
  4. package/dist/es/es2018/types/src/generated/adapters/getDataSeedStatus.d.ts +30 -0
  5. package/dist/es/es2018/types/src/generated/adapters/getUploadPreSignedUrl.d.ts +19 -0
  6. package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +2 -0
  7. package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +4 -0
  8. package/dist/es/es2018/types/src/generated/resources/getPlatformDataSeedV1DataSeedRequest.d.ts +18 -0
  9. package/dist/es/es2018/types/src/generated/resources/postPlatformDataSeedV1DataSeedGeneratePresignedUploadUrl.d.ts +18 -0
  10. package/dist/es/es2018/types/src/generated/types/DataSeedRequestObjectRepresentation.d.ts +58 -0
  11. package/dist/es/es2018/types/src/generated/types/DataSeedStatusErrorRepresentation.d.ts +28 -0
  12. package/dist/es/es2018/types/src/generated/types/DataSeedStatusOutputRepresentation.d.ts +32 -0
  13. package/dist/es/es2018/types/src/generated/types/PreSignedUrlBadErrorRepresentation.d.ts +28 -0
  14. package/dist/es/es2018/types/src/generated/types/PreSignedUrlInputRepresentation.d.ts +28 -0
  15. package/dist/es/es2018/types/src/generated/types/PreSignedUrlResultRepresentation.d.ts +41 -0
  16. package/dist/es/es2018/types/src/generated/types/PreSignedUrlServerErrorRepresentation.d.ts +31 -0
  17. package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
  18. package/package.json +66 -0
  19. package/sfdc/index.d.ts +1 -0
  20. package/sfdc/index.js +723 -0
  21. package/src/raml/api.raml +192 -0
  22. package/src/raml/luvio.raml +24 -0
@@ -0,0 +1,685 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
8
+
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys, create: ObjectCreate } = Object;
11
+ const { isArray: ArrayIsArray$1 } = Array;
12
+ /**
13
+ * Validates an adapter config is well-formed.
14
+ * @param config The config to validate.
15
+ * @param adapter The adapter validation configuration.
16
+ * @param oneOf The keys the config must contain at least one of.
17
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
18
+ */
19
+ function validateConfig(config, adapter, oneOf) {
20
+ const { displayName } = adapter;
21
+ const { required, optional, unsupported } = adapter.parameters;
22
+ if (config === undefined ||
23
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
24
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
25
+ }
26
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
27
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
28
+ }
29
+ if (unsupported !== undefined &&
30
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
31
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
32
+ }
33
+ const supported = required.concat(optional);
34
+ if (ObjectKeys(config).some(key => !supported.includes(key))) {
35
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
36
+ }
37
+ }
38
+ function untrustedIsObject(untrusted) {
39
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
40
+ }
41
+ function areRequiredParametersPresent(config, configPropertyNames) {
42
+ return configPropertyNames.parameters.required.every(req => req in config);
43
+ }
44
+ const snapshotRefreshOptions = {
45
+ overrides: {
46
+ headers: {
47
+ 'Cache-Control': 'no-cache',
48
+ },
49
+ }
50
+ };
51
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
52
+ return {
53
+ name,
54
+ required,
55
+ resourceType,
56
+ typeCheckShape,
57
+ isArrayShape,
58
+ coerceFn,
59
+ };
60
+ }
61
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
62
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
63
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
64
+ return {
65
+ displayName,
66
+ parameters: {
67
+ required,
68
+ optional,
69
+ }
70
+ };
71
+ }
72
+ const keyPrefix = 'data-seed';
73
+
74
+ const { isArray: ArrayIsArray } = Array;
75
+ function equalsArray(a, b, equalsItem) {
76
+ const aLength = a.length;
77
+ const bLength = b.length;
78
+ if (aLength !== bLength) {
79
+ return false;
80
+ }
81
+ for (let i = 0; i < aLength; i++) {
82
+ if (equalsItem(a[i], b[i]) === false) {
83
+ return false;
84
+ }
85
+ }
86
+ return true;
87
+ }
88
+ function createLink(ref) {
89
+ return {
90
+ __ref: serializeStructuredKey(ref),
91
+ };
92
+ }
93
+
94
+ const VERSION$2 = "ddec5d0c42ca88dcaf0598f884079ed2";
95
+ function validate$2(obj, path = 'DataSeedRequestObjectRepresentation') {
96
+ const v_error = (() => {
97
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
98
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
99
+ }
100
+ const obj_created_by = obj.created_by;
101
+ const path_created_by = path + '.created_by';
102
+ if (typeof obj_created_by !== 'string') {
103
+ return new TypeError('Expected "string" but received "' + typeof obj_created_by + '" (at "' + path_created_by + '")');
104
+ }
105
+ const obj_description = obj.description;
106
+ const path_description = path + '.description';
107
+ if (typeof obj_description !== 'string') {
108
+ return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
109
+ }
110
+ const obj_execution_end_time = obj.execution_end_time;
111
+ const path_execution_end_time = path + '.execution_end_time';
112
+ if (typeof obj_execution_end_time !== 'string') {
113
+ return new TypeError('Expected "string" but received "' + typeof obj_execution_end_time + '" (at "' + path_execution_end_time + '")');
114
+ }
115
+ const obj_execution_start_time = obj.execution_start_time;
116
+ const path_execution_start_time = path + '.execution_start_time';
117
+ if (typeof obj_execution_start_time !== 'string') {
118
+ return new TypeError('Expected "string" but received "' + typeof obj_execution_start_time + '" (at "' + path_execution_start_time + '")');
119
+ }
120
+ const obj_job_type = obj.job_type;
121
+ const path_job_type = path + '.job_type';
122
+ if (typeof obj_job_type !== 'string') {
123
+ return new TypeError('Expected "string" but received "' + typeof obj_job_type + '" (at "' + path_job_type + '")');
124
+ }
125
+ const obj_log_text = obj.log_text;
126
+ const path_log_text = path + '.log_text';
127
+ if (typeof obj_log_text !== 'string') {
128
+ return new TypeError('Expected "string" but received "' + typeof obj_log_text + '" (at "' + path_log_text + '")');
129
+ }
130
+ const obj_name = obj.name;
131
+ const path_name = path + '.name';
132
+ if (typeof obj_name !== 'string') {
133
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
134
+ }
135
+ const obj_organization_id = obj.organization_id;
136
+ const path_organization_id = path + '.organization_id';
137
+ if (typeof obj_organization_id !== 'string') {
138
+ return new TypeError('Expected "string" but received "' + typeof obj_organization_id + '" (at "' + path_organization_id + '")');
139
+ }
140
+ const obj_request_id = obj.request_id;
141
+ const path_request_id = path + '.request_id';
142
+ if (typeof obj_request_id !== 'string') {
143
+ return new TypeError('Expected "string" but received "' + typeof obj_request_id + '" (at "' + path_request_id + '")');
144
+ }
145
+ const obj_status = obj.status;
146
+ const path_status = path + '.status';
147
+ if (typeof obj_status !== 'string') {
148
+ return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
149
+ }
150
+ const obj_step = obj.step;
151
+ const path_step = path + '.step';
152
+ if (typeof obj_step !== 'string') {
153
+ return new TypeError('Expected "string" but received "' + typeof obj_step + '" (at "' + path_step + '")');
154
+ }
155
+ })();
156
+ return v_error === undefined ? null : v_error;
157
+ }
158
+ const select$4 = function DataSeedRequestObjectRepresentationSelect() {
159
+ return {
160
+ kind: 'Fragment',
161
+ version: VERSION$2,
162
+ private: [],
163
+ selections: [
164
+ {
165
+ name: 'created_by',
166
+ kind: 'Scalar'
167
+ },
168
+ {
169
+ name: 'description',
170
+ kind: 'Scalar'
171
+ },
172
+ {
173
+ name: 'execution_end_time',
174
+ kind: 'Scalar'
175
+ },
176
+ {
177
+ name: 'execution_start_time',
178
+ kind: 'Scalar'
179
+ },
180
+ {
181
+ name: 'job_type',
182
+ kind: 'Scalar'
183
+ },
184
+ {
185
+ name: 'log_text',
186
+ kind: 'Scalar'
187
+ },
188
+ {
189
+ name: 'name',
190
+ kind: 'Scalar'
191
+ },
192
+ {
193
+ name: 'organization_id',
194
+ kind: 'Scalar'
195
+ },
196
+ {
197
+ name: 'request_id',
198
+ kind: 'Scalar'
199
+ },
200
+ {
201
+ name: 'status',
202
+ kind: 'Scalar'
203
+ },
204
+ {
205
+ name: 'step',
206
+ kind: 'Scalar'
207
+ }
208
+ ]
209
+ };
210
+ };
211
+ function equals$2(existing, incoming) {
212
+ const existing_created_by = existing.created_by;
213
+ const incoming_created_by = incoming.created_by;
214
+ if (!(existing_created_by === incoming_created_by)) {
215
+ return false;
216
+ }
217
+ const existing_description = existing.description;
218
+ const incoming_description = incoming.description;
219
+ if (!(existing_description === incoming_description)) {
220
+ return false;
221
+ }
222
+ const existing_execution_end_time = existing.execution_end_time;
223
+ const incoming_execution_end_time = incoming.execution_end_time;
224
+ if (!(existing_execution_end_time === incoming_execution_end_time)) {
225
+ return false;
226
+ }
227
+ const existing_execution_start_time = existing.execution_start_time;
228
+ const incoming_execution_start_time = incoming.execution_start_time;
229
+ if (!(existing_execution_start_time === incoming_execution_start_time)) {
230
+ return false;
231
+ }
232
+ const existing_job_type = existing.job_type;
233
+ const incoming_job_type = incoming.job_type;
234
+ if (!(existing_job_type === incoming_job_type)) {
235
+ return false;
236
+ }
237
+ const existing_log_text = existing.log_text;
238
+ const incoming_log_text = incoming.log_text;
239
+ if (!(existing_log_text === incoming_log_text)) {
240
+ return false;
241
+ }
242
+ const existing_name = existing.name;
243
+ const incoming_name = incoming.name;
244
+ if (!(existing_name === incoming_name)) {
245
+ return false;
246
+ }
247
+ const existing_organization_id = existing.organization_id;
248
+ const incoming_organization_id = incoming.organization_id;
249
+ if (!(existing_organization_id === incoming_organization_id)) {
250
+ return false;
251
+ }
252
+ const existing_request_id = existing.request_id;
253
+ const incoming_request_id = incoming.request_id;
254
+ if (!(existing_request_id === incoming_request_id)) {
255
+ return false;
256
+ }
257
+ const existing_status = existing.status;
258
+ const incoming_status = incoming.status;
259
+ if (!(existing_status === incoming_status)) {
260
+ return false;
261
+ }
262
+ const existing_step = existing.step;
263
+ const incoming_step = incoming.step;
264
+ if (!(existing_step === incoming_step)) {
265
+ return false;
266
+ }
267
+ return true;
268
+ }
269
+
270
+ const VERSION$1 = "732685344ea5e037b5b3da3c38ad04eb";
271
+ function validate$1(obj, path = 'DataSeedStatusOutputRepresentation') {
272
+ const v_error = (() => {
273
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
274
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
275
+ }
276
+ const obj_correlation_id = obj.correlation_id;
277
+ const path_correlation_id = path + '.correlation_id';
278
+ if (typeof obj_correlation_id !== 'string') {
279
+ return new TypeError('Expected "string" but received "' + typeof obj_correlation_id + '" (at "' + path_correlation_id + '")');
280
+ }
281
+ const obj_data = obj.data;
282
+ const path_data = path + '.data';
283
+ if (!ArrayIsArray(obj_data)) {
284
+ return new TypeError('Expected "array" but received "' + typeof obj_data + '" (at "' + path_data + '")');
285
+ }
286
+ for (let i = 0; i < obj_data.length; i++) {
287
+ const obj_data_item = obj_data[i];
288
+ const path_data_item = path_data + '[' + i + ']';
289
+ const referencepath_data_itemValidationError = validate$2(obj_data_item, path_data_item);
290
+ if (referencepath_data_itemValidationError !== null) {
291
+ let message = 'Object doesn\'t match DataSeedRequestObjectRepresentation (at "' + path_data_item + '")\n';
292
+ message += referencepath_data_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
293
+ return new TypeError(message);
294
+ }
295
+ }
296
+ })();
297
+ return v_error === undefined ? null : v_error;
298
+ }
299
+ const RepresentationType$1 = 'DataSeedStatusOutputRepresentation';
300
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
301
+ return input;
302
+ }
303
+ const select$3 = function DataSeedStatusOutputRepresentationSelect() {
304
+ const { selections: DataSeedRequestObjectRepresentation__selections, opaque: DataSeedRequestObjectRepresentation__opaque, } = select$4();
305
+ return {
306
+ kind: 'Fragment',
307
+ version: VERSION$1,
308
+ private: [],
309
+ selections: [
310
+ {
311
+ name: 'correlation_id',
312
+ kind: 'Scalar'
313
+ },
314
+ {
315
+ name: 'data',
316
+ kind: 'Object',
317
+ plural: true,
318
+ selections: DataSeedRequestObjectRepresentation__selections
319
+ }
320
+ ]
321
+ };
322
+ };
323
+ function equals$1(existing, incoming) {
324
+ const existing_correlation_id = existing.correlation_id;
325
+ const incoming_correlation_id = incoming.correlation_id;
326
+ if (!(existing_correlation_id === incoming_correlation_id)) {
327
+ return false;
328
+ }
329
+ const existing_data = existing.data;
330
+ const incoming_data = incoming.data;
331
+ const equals_data_items = equalsArray(existing_data, incoming_data, (existing_data_item, incoming_data_item) => {
332
+ if (!(equals$2(existing_data_item, incoming_data_item))) {
333
+ return false;
334
+ }
335
+ });
336
+ if (equals_data_items === false) {
337
+ return false;
338
+ }
339
+ return true;
340
+ }
341
+ const ingest$1 = function DataSeedStatusOutputRepresentationIngest(input, path, luvio, store, timestamp) {
342
+ if (process.env.NODE_ENV !== 'production') {
343
+ const validateError = validate$1(input);
344
+ if (validateError !== null) {
345
+ throw validateError;
346
+ }
347
+ }
348
+ const key = path.fullPath;
349
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 30000;
350
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "data-seed", VERSION$1, RepresentationType$1, equals$1);
351
+ return createLink(key);
352
+ };
353
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
354
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
355
+ const rootKey = fullPathFactory();
356
+ rootKeySet.set(rootKey, {
357
+ namespace: keyPrefix,
358
+ representationName: RepresentationType$1,
359
+ mergeable: false
360
+ });
361
+ }
362
+
363
+ function select$2(luvio, params) {
364
+ return select$3();
365
+ }
366
+ function keyBuilder$2(luvio, params) {
367
+ return keyPrefix + '::DataSeedStatusOutputRepresentation:(' + 'xClientTraceId:' + params.headers.xClientTraceId + ',' + 'xSalesforceRegion:' + params.headers.xSalesforceRegion + ',' + 'orgUrl:' + params.headers.orgUrl + ',' + 'accessToken:' + params.headers.accessToken + ')';
368
+ }
369
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
370
+ getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
371
+ }
372
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
373
+ const { body } = response;
374
+ const key = keyBuilder$2(luvio, resourceParams);
375
+ luvio.storeIngest(key, ingest$1, body);
376
+ const snapshot = luvio.storeLookup({
377
+ recordId: key,
378
+ node: select$2(),
379
+ variables: {},
380
+ }, snapshotRefresh);
381
+ if (process.env.NODE_ENV !== 'production') {
382
+ if (snapshot.state !== 'Fulfilled') {
383
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
384
+ }
385
+ }
386
+ deepFreeze(snapshot.data);
387
+ return snapshot;
388
+ }
389
+ function ingestError(luvio, params, error, snapshotRefresh) {
390
+ const key = keyBuilder$2(luvio, params);
391
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
392
+ luvio.storeIngestError(key, errorSnapshot);
393
+ return errorSnapshot;
394
+ }
395
+ function createResourceRequest$1(config) {
396
+ const headers = {};
397
+ headers['x-client-trace-id'] = config.headers.xClientTraceId;
398
+ headers['x-salesforce-region'] = config.headers.xSalesforceRegion;
399
+ headers['Org-Url'] = config.headers.orgUrl;
400
+ headers['Access-Token'] = config.headers.accessToken;
401
+ return {
402
+ baseUri: 'api.salesforce.com',
403
+ basePath: '/platform/data-seed/v1/data-seed-request',
404
+ method: 'get',
405
+ body: null,
406
+ urlParams: {},
407
+ queryParams: {},
408
+ headers,
409
+ priority: 'normal',
410
+ };
411
+ }
412
+
413
+ const adapterName$1 = 'getDataSeedStatus';
414
+ const getDataSeedStatus_ConfigPropertyMetadata = [
415
+ generateParamConfigMetadata('xClientTraceId', true, 3 /* Header */, 0 /* String */),
416
+ generateParamConfigMetadata('xSalesforceRegion', true, 3 /* Header */, 0 /* String */),
417
+ generateParamConfigMetadata('orgUrl', true, 3 /* Header */, 0 /* String */),
418
+ generateParamConfigMetadata('accessToken', true, 3 /* Header */, 0 /* String */),
419
+ ];
420
+ const getDataSeedStatus_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getDataSeedStatus_ConfigPropertyMetadata);
421
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getDataSeedStatus_ConfigPropertyMetadata);
422
+ function keyBuilder$1(luvio, config) {
423
+ const resourceParams = createResourceParams$1(config);
424
+ return keyBuilder$2(luvio, resourceParams);
425
+ }
426
+ function typeCheckConfig$1(untrustedConfig) {
427
+ const config = {};
428
+ typeCheckConfig$2(untrustedConfig, config, getDataSeedStatus_ConfigPropertyMetadata);
429
+ return config;
430
+ }
431
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
432
+ if (!untrustedIsObject(untrustedConfig)) {
433
+ return null;
434
+ }
435
+ if (process.env.NODE_ENV !== 'production') {
436
+ validateConfig(untrustedConfig, configPropertyNames);
437
+ }
438
+ const config = typeCheckConfig$1(untrustedConfig);
439
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
440
+ return null;
441
+ }
442
+ return config;
443
+ }
444
+ function adapterFragment(luvio, config) {
445
+ createResourceParams$1(config);
446
+ return select$2();
447
+ }
448
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
449
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
450
+ config,
451
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
452
+ });
453
+ return luvio.storeBroadcast().then(() => snapshot);
454
+ }
455
+ function onFetchResponseError(luvio, config, resourceParams, response) {
456
+ const snapshot = ingestError(luvio, resourceParams, response, {
457
+ config,
458
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
459
+ });
460
+ return luvio.storeBroadcast().then(() => snapshot);
461
+ }
462
+ function buildNetworkSnapshot$1(luvio, config, options) {
463
+ const resourceParams = createResourceParams$1(config);
464
+ const request = createResourceRequest$1(resourceParams);
465
+ return luvio.dispatchResourceRequest(request, options)
466
+ .then((response) => {
467
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
468
+ const cache = new StoreKeyMap();
469
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
470
+ return cache;
471
+ });
472
+ }, (response) => {
473
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
474
+ });
475
+ }
476
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
477
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
478
+ }
479
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
480
+ const { luvio, config } = context;
481
+ const selector = {
482
+ recordId: keyBuilder$1(luvio, config),
483
+ node: adapterFragment(luvio, config),
484
+ variables: {},
485
+ };
486
+ const cacheSnapshot = storeLookup(selector, {
487
+ config,
488
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
489
+ });
490
+ return cacheSnapshot;
491
+ }
492
+ const getDataSeedStatusAdapterFactory = (luvio) => function dataSeed__getDataSeedStatus(untrustedConfig, requestContext) {
493
+ const config = validateAdapterConfig$1(untrustedConfig, getDataSeedStatus_ConfigPropertyNames);
494
+ // Invalid or incomplete config
495
+ if (config === null) {
496
+ return null;
497
+ }
498
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
499
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
500
+ };
501
+
502
+ const TTL = 300000;
503
+ const VERSION = "578e9dba5d8078135d4027313a51d7dc";
504
+ function validate(obj, path = 'PreSignedUrlResultRepresentation') {
505
+ const v_error = (() => {
506
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
507
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
508
+ }
509
+ const obj_s3_unique_id = obj.s3_unique_id;
510
+ const path_s3_unique_id = path + '.s3_unique_id';
511
+ if (typeof obj_s3_unique_id !== 'string') {
512
+ return new TypeError('Expected "string" but received "' + typeof obj_s3_unique_id + '" (at "' + path_s3_unique_id + '")');
513
+ }
514
+ const obj_url = obj.url;
515
+ const path_url = path + '.url';
516
+ if (typeof obj_url !== 'string') {
517
+ return new TypeError('Expected "string" but received "' + typeof obj_url + '" (at "' + path_url + '")');
518
+ }
519
+ })();
520
+ return v_error === undefined ? null : v_error;
521
+ }
522
+ const RepresentationType = 'PreSignedUrlResultRepresentation';
523
+ function keyBuilder(luvio, config) {
524
+ return keyPrefix + '::' + RepresentationType + ':' + config.s3_unique_id;
525
+ }
526
+ function keyBuilderFromType(luvio, object) {
527
+ const keyParams = {
528
+ s3_unique_id: object.s3_unique_id
529
+ };
530
+ return keyBuilder(luvio, keyParams);
531
+ }
532
+ function normalize(input, existing, path, luvio, store, timestamp) {
533
+ return input;
534
+ }
535
+ const select$1 = function PreSignedUrlResultRepresentationSelect() {
536
+ return {
537
+ kind: 'Fragment',
538
+ version: VERSION,
539
+ private: [],
540
+ selections: [
541
+ {
542
+ name: 's3_unique_id',
543
+ kind: 'Scalar'
544
+ },
545
+ {
546
+ name: 'url',
547
+ kind: 'Scalar'
548
+ }
549
+ ]
550
+ };
551
+ };
552
+ function equals(existing, incoming) {
553
+ const existing_s3_unique_id = existing.s3_unique_id;
554
+ const incoming_s3_unique_id = incoming.s3_unique_id;
555
+ if (!(existing_s3_unique_id === incoming_s3_unique_id)) {
556
+ return false;
557
+ }
558
+ const existing_url = existing.url;
559
+ const incoming_url = incoming.url;
560
+ if (!(existing_url === incoming_url)) {
561
+ return false;
562
+ }
563
+ return true;
564
+ }
565
+ const ingest = function PreSignedUrlResultRepresentationIngest(input, path, luvio, store, timestamp) {
566
+ if (process.env.NODE_ENV !== 'production') {
567
+ const validateError = validate(input);
568
+ if (validateError !== null) {
569
+ throw validateError;
570
+ }
571
+ }
572
+ const key = keyBuilderFromType(luvio, input);
573
+ const ttlToUse = TTL;
574
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "data-seed", VERSION, RepresentationType, equals);
575
+ return createLink(key);
576
+ };
577
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
578
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
579
+ const rootKey = keyBuilderFromType(luvio, input);
580
+ rootKeySet.set(rootKey, {
581
+ namespace: keyPrefix,
582
+ representationName: RepresentationType,
583
+ mergeable: false
584
+ });
585
+ }
586
+
587
+ function select(luvio, params) {
588
+ return select$1();
589
+ }
590
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
591
+ getTypeCacheKeys(storeKeyMap, luvio, response);
592
+ }
593
+ function ingestSuccess(luvio, resourceParams, response) {
594
+ const { body } = response;
595
+ const key = keyBuilderFromType(luvio, body);
596
+ luvio.storeIngest(key, ingest, body);
597
+ const snapshot = luvio.storeLookup({
598
+ recordId: key,
599
+ node: select(),
600
+ variables: {},
601
+ });
602
+ if (process.env.NODE_ENV !== 'production') {
603
+ if (snapshot.state !== 'Fulfilled') {
604
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
605
+ }
606
+ }
607
+ deepFreeze(snapshot.data);
608
+ return snapshot;
609
+ }
610
+ function createResourceRequest(config) {
611
+ const headers = {};
612
+ headers['x-client-trace-id'] = config.headers.xClientTraceId;
613
+ headers['x-salesforce-region'] = config.headers.xSalesforceRegion;
614
+ headers['Org-Url'] = config.headers.orgUrl;
615
+ headers['Access-Token'] = config.headers.accessToken;
616
+ return {
617
+ baseUri: 'api.salesforce.com',
618
+ basePath: '/platform/data-seed/v1/data-seed-generate-presigned-upload-url',
619
+ method: 'post',
620
+ body: config.body,
621
+ urlParams: {},
622
+ queryParams: {},
623
+ headers,
624
+ priority: 'normal',
625
+ };
626
+ }
627
+
628
+ const adapterName = 'getUploadPreSignedUrl';
629
+ const getUploadPreSignedUrl_ConfigPropertyMetadata = [
630
+ generateParamConfigMetadata('file_name', true, 2 /* Body */, 0 /* String */),
631
+ generateParamConfigMetadata('xClientTraceId', true, 3 /* Header */, 0 /* String */),
632
+ generateParamConfigMetadata('xSalesforceRegion', true, 3 /* Header */, 0 /* String */),
633
+ generateParamConfigMetadata('orgUrl', true, 3 /* Header */, 0 /* String */),
634
+ generateParamConfigMetadata('accessToken', true, 3 /* Header */, 0 /* String */),
635
+ ];
636
+ const getUploadPreSignedUrl_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, getUploadPreSignedUrl_ConfigPropertyMetadata);
637
+ const createResourceParams = /*#__PURE__*/ createResourceParams$2(getUploadPreSignedUrl_ConfigPropertyMetadata);
638
+ function typeCheckConfig(untrustedConfig) {
639
+ const config = {};
640
+ typeCheckConfig$2(untrustedConfig, config, getUploadPreSignedUrl_ConfigPropertyMetadata);
641
+ return config;
642
+ }
643
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
644
+ if (!untrustedIsObject(untrustedConfig)) {
645
+ return null;
646
+ }
647
+ if (process.env.NODE_ENV !== 'production') {
648
+ validateConfig(untrustedConfig, configPropertyNames);
649
+ }
650
+ const config = typeCheckConfig(untrustedConfig);
651
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
652
+ return null;
653
+ }
654
+ return config;
655
+ }
656
+ function buildNetworkSnapshot(luvio, config, options) {
657
+ const resourceParams = createResourceParams(config);
658
+ const request = createResourceRequest(resourceParams);
659
+ return luvio.dispatchResourceRequest(request, options)
660
+ .then((response) => {
661
+ return luvio.handleSuccessResponse(() => {
662
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
663
+ return luvio.storeBroadcast().then(() => snapshot);
664
+ }, () => {
665
+ const cache = new StoreKeyMap();
666
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
667
+ return cache;
668
+ });
669
+ }, (response) => {
670
+ deepFreeze(response);
671
+ throw response;
672
+ });
673
+ }
674
+ const getUploadPreSignedUrlAdapterFactory = (luvio) => {
675
+ return function getUploadPreSignedUrl(untrustedConfig) {
676
+ const config = validateAdapterConfig(untrustedConfig, getUploadPreSignedUrl_ConfigPropertyNames);
677
+ // Invalid or incomplete config
678
+ if (config === null) {
679
+ throw new Error('Invalid config for "getUploadPreSignedUrl"');
680
+ }
681
+ return buildNetworkSnapshot(luvio, config);
682
+ };
683
+ };
684
+
685
+ export { getDataSeedStatusAdapterFactory, getUploadPreSignedUrlAdapterFactory };