@salesforce/lds-adapters-revenue-billing-batch 1.272.0 → 1.273.1

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.
@@ -4,10 +4,11 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$3, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$3 } from '@luvio/engine';
8
8
 
9
9
  const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
10
  const { keys: ObjectKeys, create: ObjectCreate } = Object;
11
+ const { stringify: JSONStringify$1 } = JSON;
11
12
  const { isArray: ArrayIsArray$1 } = Array;
12
13
  /**
13
14
  * Validates an adapter config is well-formed.
@@ -41,6 +42,68 @@ function untrustedIsObject(untrusted) {
41
42
  function areRequiredParametersPresent(config, configPropertyNames) {
42
43
  return configPropertyNames.parameters.required.every(req => req in config);
43
44
  }
45
+ const snapshotRefreshOptions = {
46
+ overrides: {
47
+ headers: {
48
+ 'Cache-Control': 'no-cache',
49
+ },
50
+ }
51
+ };
52
+ /**
53
+ * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
54
+ * This is needed because insertion order for JSON.stringify(object) affects output:
55
+ * JSON.stringify({a: 1, b: 2})
56
+ * "{"a":1,"b":2}"
57
+ * JSON.stringify({b: 2, a: 1})
58
+ * "{"b":2,"a":1}"
59
+ * @param data Data to be JSON-stringified.
60
+ * @returns JSON.stringified value with consistent ordering of keys.
61
+ */
62
+ function stableJSONStringify(node) {
63
+ // This is for Date values.
64
+ if (node && node.toJSON && typeof node.toJSON === 'function') {
65
+ // eslint-disable-next-line no-param-reassign
66
+ node = node.toJSON();
67
+ }
68
+ if (node === undefined) {
69
+ return;
70
+ }
71
+ if (typeof node === 'number') {
72
+ return isFinite(node) ? '' + node : 'null';
73
+ }
74
+ if (typeof node !== 'object') {
75
+ return JSONStringify$1(node);
76
+ }
77
+ let i;
78
+ let out;
79
+ if (ArrayIsArray$1(node)) {
80
+ out = '[';
81
+ for (i = 0; i < node.length; i++) {
82
+ if (i) {
83
+ out += ',';
84
+ }
85
+ out += stableJSONStringify(node[i]) || 'null';
86
+ }
87
+ return out + ']';
88
+ }
89
+ if (node === null) {
90
+ return 'null';
91
+ }
92
+ const keys = ObjectKeys(node).sort();
93
+ out = '';
94
+ for (i = 0; i < keys.length; i++) {
95
+ const key = keys[i];
96
+ const value = stableJSONStringify(node[key]);
97
+ if (!value) {
98
+ continue;
99
+ }
100
+ if (out) {
101
+ out += ',';
102
+ }
103
+ out += JSONStringify$1(key) + ':' + value;
104
+ }
105
+ return '{' + out + '}';
106
+ }
44
107
  function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
45
108
  return {
46
109
  name,
@@ -72,7 +135,7 @@ function createLink(ref) {
72
135
  };
73
136
  }
74
137
 
75
- function validate$6(obj, path = 'ScheduleOptionsInputRepresentation') {
138
+ function validate$7(obj, path = 'ScheduleOptionsInputRepresentation') {
76
139
  const v_error = (() => {
77
140
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
78
141
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -120,8 +183,8 @@ function validate$6(obj, path = 'ScheduleOptionsInputRepresentation') {
120
183
  return v_error === undefined ? null : v_error;
121
184
  }
122
185
 
123
- function validate$5(obj, path = 'PaymentsBatchSchedulerInputRepresentation') {
124
- const validateScheduleOptionsInputRepresentation_validateError = validate$6(obj, path);
186
+ function validate$6(obj, path = 'PaymentsBatchSchedulerInputRepresentation') {
187
+ const validateScheduleOptionsInputRepresentation_validateError = validate$7(obj, path);
125
188
  if (validateScheduleOptionsInputRepresentation_validateError !== null) {
126
189
  return validateScheduleOptionsInputRepresentation_validateError;
127
190
  }
@@ -154,7 +217,7 @@ function validate$5(obj, path = 'PaymentsBatchSchedulerInputRepresentation') {
154
217
  return v_error === undefined ? null : v_error;
155
218
  }
156
219
 
157
- function validate$4(obj, path = 'BillingBatchSchedulerRepresentation') {
220
+ function validate$5(obj, path = 'BillingBatchSchedulerRepresentation') {
158
221
  const v_error = (() => {
159
222
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
160
223
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -168,16 +231,16 @@ function validate$4(obj, path = 'BillingBatchSchedulerRepresentation') {
168
231
  return v_error === undefined ? null : v_error;
169
232
  }
170
233
 
171
- const TTL$1 = 1000;
172
- const VERSION$1 = "eff71edc32270b9a1e6e1779cb811c3c";
173
- function validate$3(obj, path = 'PaymentsBatchSchedulerOutputRepresentation') {
234
+ const TTL$2 = 1000;
235
+ const VERSION$2 = "eff71edc32270b9a1e6e1779cb811c3c";
236
+ function validate$4(obj, path = 'PaymentsBatchSchedulerOutputRepresentation') {
174
237
  const v_error = (() => {
175
238
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
176
239
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
177
240
  }
178
241
  const obj_billingBatchScheduler = obj.billingBatchScheduler;
179
242
  const path_billingBatchScheduler = path + '.billingBatchScheduler';
180
- const referencepath_billingBatchSchedulerValidationError = validate$4(obj_billingBatchScheduler, path_billingBatchScheduler);
243
+ const referencepath_billingBatchSchedulerValidationError = validate$5(obj_billingBatchScheduler, path_billingBatchScheduler);
181
244
  if (referencepath_billingBatchSchedulerValidationError !== null) {
182
245
  let message = 'Object doesn\'t match BillingBatchSchedulerRepresentation (at "' + path_billingBatchScheduler + '")\n';
183
246
  message += referencepath_billingBatchSchedulerValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -186,68 +249,68 @@ function validate$3(obj, path = 'PaymentsBatchSchedulerOutputRepresentation') {
186
249
  })();
187
250
  return v_error === undefined ? null : v_error;
188
251
  }
189
- const RepresentationType$1 = 'PaymentsBatchSchedulerOutputRepresentation';
190
- function keyBuilder$1(luvio, config) {
191
- return keyPrefix + '::' + RepresentationType$1 + ':' + config.billingBatchSchedulerId;
252
+ const RepresentationType$2 = 'PaymentsBatchSchedulerOutputRepresentation';
253
+ function keyBuilder$3(luvio, config) {
254
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.billingBatchSchedulerId;
192
255
  }
193
256
  function keyBuilderFromType$1(luvio, object) {
194
257
  const keyParams = {
195
258
  billingBatchSchedulerId: object.billingBatchScheduler.id
196
259
  };
197
- return keyBuilder$1(luvio, keyParams);
260
+ return keyBuilder$3(luvio, keyParams);
198
261
  }
199
- function normalize$1(input, existing, path, luvio, store, timestamp) {
262
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
200
263
  return input;
201
264
  }
202
- const select$3 = function PaymentsBatchSchedulerOutputRepresentationSelect() {
265
+ const select$5 = function PaymentsBatchSchedulerOutputRepresentationSelect() {
203
266
  return {
204
267
  kind: 'Fragment',
205
- version: VERSION$1,
268
+ version: VERSION$2,
206
269
  private: [],
207
270
  opaque: true
208
271
  };
209
272
  };
210
- function equals$1(existing, incoming) {
273
+ function equals$2(existing, incoming) {
211
274
  if (JSONStringify(incoming) !== JSONStringify(existing)) {
212
275
  return false;
213
276
  }
214
277
  return true;
215
278
  }
216
- const ingest$1 = function PaymentsBatchSchedulerOutputRepresentationIngest(input, path, luvio, store, timestamp) {
279
+ const ingest$2 = function PaymentsBatchSchedulerOutputRepresentationIngest(input, path, luvio, store, timestamp) {
217
280
  if (process.env.NODE_ENV !== 'production') {
218
- const validateError = validate$3(input);
281
+ const validateError = validate$4(input);
219
282
  if (validateError !== null) {
220
283
  throw validateError;
221
284
  }
222
285
  }
223
286
  const key = keyBuilderFromType$1(luvio, input);
224
- const ttlToUse = TTL$1;
225
- ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "BillingBatch", VERSION$1, RepresentationType$1, equals$1);
287
+ const ttlToUse = TTL$2;
288
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "BillingBatch", VERSION$2, RepresentationType$2, equals$2);
226
289
  return createLink(key);
227
290
  };
228
- function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
291
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
229
292
  // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
230
293
  const rootKey = keyBuilderFromType$1(luvio, input);
231
294
  rootKeySet.set(rootKey, {
232
295
  namespace: keyPrefix,
233
- representationName: RepresentationType$1,
296
+ representationName: RepresentationType$2,
234
297
  mergeable: false
235
298
  });
236
299
  }
237
300
 
238
- function select$2(luvio, params) {
239
- return select$3();
301
+ function select$4(luvio, params) {
302
+ return select$5();
240
303
  }
241
- function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
242
- getTypeCacheKeys$1(storeKeyMap, luvio, response);
304
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
305
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
243
306
  }
244
- function ingestSuccess$1(luvio, resourceParams, response) {
307
+ function ingestSuccess$2(luvio, resourceParams, response) {
245
308
  const { body } = response;
246
309
  const key = keyBuilderFromType$1(luvio, body);
247
- luvio.storeIngest(key, ingest$1, body);
310
+ luvio.storeIngest(key, ingest$2, body);
248
311
  const snapshot = luvio.storeLookup({
249
312
  recordId: key,
250
- node: select$2(),
313
+ node: select$4(),
251
314
  variables: {},
252
315
  });
253
316
  if (process.env.NODE_ENV !== 'production') {
@@ -258,7 +321,7 @@ function ingestSuccess$1(luvio, resourceParams, response) {
258
321
  deepFreeze(snapshot.data);
259
322
  return snapshot;
260
323
  }
261
- function createResourceRequest$1(config) {
324
+ function createResourceRequest$2(config) {
262
325
  const headers = {};
263
326
  return {
264
327
  baseUri: '/services/data/v61.0',
@@ -272,45 +335,45 @@ function createResourceRequest$1(config) {
272
335
  };
273
336
  }
274
337
 
275
- const adapterName$1 = 'createPaymentsBatchScheduler';
338
+ const adapterName$2 = 'createPaymentsBatchScheduler';
276
339
  const createPaymentsBatchScheduler_ConfigPropertyMetadata = [
277
340
  generateParamConfigMetadata('PaymentsBatchSchedulerInput', true, 2 /* Body */, 4 /* Unsupported */),
278
341
  ];
279
- const createPaymentsBatchScheduler_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createPaymentsBatchScheduler_ConfigPropertyMetadata);
280
- const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(createPaymentsBatchScheduler_ConfigPropertyMetadata);
281
- function typeCheckConfig$1(untrustedConfig) {
342
+ const createPaymentsBatchScheduler_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, createPaymentsBatchScheduler_ConfigPropertyMetadata);
343
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(createPaymentsBatchScheduler_ConfigPropertyMetadata);
344
+ function typeCheckConfig$2(untrustedConfig) {
282
345
  const config = {};
283
346
  const untrustedConfig_PaymentsBatchSchedulerInput = untrustedConfig.PaymentsBatchSchedulerInput;
284
- const referencePaymentsBatchSchedulerInputRepresentationValidationError = validate$5(untrustedConfig_PaymentsBatchSchedulerInput);
347
+ const referencePaymentsBatchSchedulerInputRepresentationValidationError = validate$6(untrustedConfig_PaymentsBatchSchedulerInput);
285
348
  if (referencePaymentsBatchSchedulerInputRepresentationValidationError === null) {
286
349
  config.PaymentsBatchSchedulerInput = untrustedConfig_PaymentsBatchSchedulerInput;
287
350
  }
288
351
  return config;
289
352
  }
290
- function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
353
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
291
354
  if (!untrustedIsObject(untrustedConfig)) {
292
355
  return null;
293
356
  }
294
357
  if (process.env.NODE_ENV !== 'production') {
295
358
  validateConfig(untrustedConfig, configPropertyNames);
296
359
  }
297
- const config = typeCheckConfig$1(untrustedConfig);
360
+ const config = typeCheckConfig$2(untrustedConfig);
298
361
  if (!areRequiredParametersPresent(config, configPropertyNames)) {
299
362
  return null;
300
363
  }
301
364
  return config;
302
365
  }
303
- function buildNetworkSnapshot$1(luvio, config, options) {
304
- const resourceParams = createResourceParams$1(config);
305
- const request = createResourceRequest$1(resourceParams);
366
+ function buildNetworkSnapshot$2(luvio, config, options) {
367
+ const resourceParams = createResourceParams$2(config);
368
+ const request = createResourceRequest$2(resourceParams);
306
369
  return luvio.dispatchResourceRequest(request, options)
307
370
  .then((response) => {
308
371
  return luvio.handleSuccessResponse(() => {
309
- const snapshot = ingestSuccess$1(luvio, resourceParams, response);
372
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
310
373
  return luvio.storeBroadcast().then(() => snapshot);
311
374
  }, () => {
312
375
  const cache = new StoreKeyMap();
313
- getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
376
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
314
377
  return cache;
315
378
  });
316
379
  }, (response) => {
@@ -320,16 +383,16 @@ function buildNetworkSnapshot$1(luvio, config, options) {
320
383
  }
321
384
  const createPaymentsBatchSchedulerAdapterFactory = (luvio) => {
322
385
  return function createPaymentsBatchScheduler(untrustedConfig) {
323
- const config = validateAdapterConfig$1(untrustedConfig, createPaymentsBatchScheduler_ConfigPropertyNames);
386
+ const config = validateAdapterConfig$2(untrustedConfig, createPaymentsBatchScheduler_ConfigPropertyNames);
324
387
  // Invalid or incomplete config
325
388
  if (config === null) {
326
389
  throw new Error('Invalid config for "createPaymentsBatchScheduler"');
327
390
  }
328
- return buildNetworkSnapshot$1(luvio, config);
391
+ return buildNetworkSnapshot$2(luvio, config);
329
392
  };
330
393
  };
331
394
 
332
- function validate$2(obj, path = 'ScheduleOptionsInputRepresentationForInvoice') {
395
+ function validate$3(obj, path = 'ScheduleOptionsInputRepresentationForInvoice') {
333
396
  const v_error = (() => {
334
397
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
335
398
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
@@ -380,8 +443,8 @@ function validate$2(obj, path = 'ScheduleOptionsInputRepresentationForInvoice')
380
443
  return v_error === undefined ? null : v_error;
381
444
  }
382
445
 
383
- function validate$1(obj, path = 'BatchInvoiceSchedulerInputRepresentation') {
384
- const validateScheduleOptionsInputRepresentationForInvoice_validateError = validate$2(obj, path);
446
+ function validate$2(obj, path = 'BatchInvoiceSchedulerInputRepresentation') {
447
+ const validateScheduleOptionsInputRepresentationForInvoice_validateError = validate$3(obj, path);
385
448
  if (validateScheduleOptionsInputRepresentationForInvoice_validateError !== null) {
386
449
  return validateScheduleOptionsInputRepresentationForInvoice_validateError;
387
450
  }
@@ -407,16 +470,16 @@ function validate$1(obj, path = 'BatchInvoiceSchedulerInputRepresentation') {
407
470
  return v_error === undefined ? null : v_error;
408
471
  }
409
472
 
410
- const TTL = 1000;
411
- const VERSION = "15c358b0b4903143c526f63f4010b958";
412
- function validate(obj, path = 'InvoicesBatchSchedulerOutputRepresentation') {
473
+ const TTL$1 = 1000;
474
+ const VERSION$1 = "15c358b0b4903143c526f63f4010b958";
475
+ function validate$1(obj, path = 'InvoicesBatchSchedulerOutputRepresentation') {
413
476
  const v_error = (() => {
414
477
  if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
415
478
  return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
416
479
  }
417
480
  const obj_billingBatchScheduler = obj.billingBatchScheduler;
418
481
  const path_billingBatchScheduler = path + '.billingBatchScheduler';
419
- const referencepath_billingBatchSchedulerValidationError = validate$4(obj_billingBatchScheduler, path_billingBatchScheduler);
482
+ const referencepath_billingBatchSchedulerValidationError = validate$5(obj_billingBatchScheduler, path_billingBatchScheduler);
420
483
  if (referencepath_billingBatchSchedulerValidationError !== null) {
421
484
  let message = 'Object doesn\'t match BillingBatchSchedulerRepresentation (at "' + path_billingBatchScheduler + '")\n';
422
485
  message += referencepath_billingBatchSchedulerValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
@@ -425,68 +488,68 @@ function validate(obj, path = 'InvoicesBatchSchedulerOutputRepresentation') {
425
488
  })();
426
489
  return v_error === undefined ? null : v_error;
427
490
  }
428
- const RepresentationType = 'InvoicesBatchSchedulerOutputRepresentation';
429
- function keyBuilder(luvio, config) {
430
- return keyPrefix + '::' + RepresentationType + ':' + config.billingBatchSchedulerId;
491
+ const RepresentationType$1 = 'InvoicesBatchSchedulerOutputRepresentation';
492
+ function keyBuilder$2(luvio, config) {
493
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.billingBatchSchedulerId;
431
494
  }
432
495
  function keyBuilderFromType(luvio, object) {
433
496
  const keyParams = {
434
497
  billingBatchSchedulerId: object.billingBatchScheduler.id
435
498
  };
436
- return keyBuilder(luvio, keyParams);
499
+ return keyBuilder$2(luvio, keyParams);
437
500
  }
438
- function normalize(input, existing, path, luvio, store, timestamp) {
501
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
439
502
  return input;
440
503
  }
441
- const select$1 = function InvoicesBatchSchedulerOutputRepresentationSelect() {
504
+ const select$3 = function InvoicesBatchSchedulerOutputRepresentationSelect() {
442
505
  return {
443
506
  kind: 'Fragment',
444
- version: VERSION,
507
+ version: VERSION$1,
445
508
  private: [],
446
509
  opaque: true
447
510
  };
448
511
  };
449
- function equals(existing, incoming) {
512
+ function equals$1(existing, incoming) {
450
513
  if (JSONStringify(incoming) !== JSONStringify(existing)) {
451
514
  return false;
452
515
  }
453
516
  return true;
454
517
  }
455
- const ingest = function InvoicesBatchSchedulerOutputRepresentationIngest(input, path, luvio, store, timestamp) {
518
+ const ingest$1 = function InvoicesBatchSchedulerOutputRepresentationIngest(input, path, luvio, store, timestamp) {
456
519
  if (process.env.NODE_ENV !== 'production') {
457
- const validateError = validate(input);
520
+ const validateError = validate$1(input);
458
521
  if (validateError !== null) {
459
522
  throw validateError;
460
523
  }
461
524
  }
462
525
  const key = keyBuilderFromType(luvio, input);
463
- const ttlToUse = TTL;
464
- ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "BillingBatch", VERSION, RepresentationType, equals);
526
+ const ttlToUse = TTL$1;
527
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "BillingBatch", VERSION$1, RepresentationType$1, equals$1);
465
528
  return createLink(key);
466
529
  };
467
- function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
530
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
468
531
  // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
469
532
  const rootKey = keyBuilderFromType(luvio, input);
470
533
  rootKeySet.set(rootKey, {
471
534
  namespace: keyPrefix,
472
- representationName: RepresentationType,
535
+ representationName: RepresentationType$1,
473
536
  mergeable: false
474
537
  });
475
538
  }
476
539
 
477
- function select(luvio, params) {
478
- return select$1();
540
+ function select$2(luvio, params) {
541
+ return select$3();
479
542
  }
480
- function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
481
- getTypeCacheKeys(storeKeyMap, luvio, response);
543
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
544
+ getTypeCacheKeys$1(storeKeyMap, luvio, response);
482
545
  }
483
- function ingestSuccess(luvio, resourceParams, response) {
546
+ function ingestSuccess$1(luvio, resourceParams, response) {
484
547
  const { body } = response;
485
548
  const key = keyBuilderFromType(luvio, body);
486
- luvio.storeIngest(key, ingest, body);
549
+ luvio.storeIngest(key, ingest$1, body);
487
550
  const snapshot = luvio.storeLookup({
488
551
  recordId: key,
489
- node: select(),
552
+ node: select$2(),
490
553
  variables: {},
491
554
  });
492
555
  if (process.env.NODE_ENV !== 'production') {
@@ -497,7 +560,7 @@ function ingestSuccess(luvio, resourceParams, response) {
497
560
  deepFreeze(snapshot.data);
498
561
  return snapshot;
499
562
  }
500
- function createResourceRequest(config) {
563
+ function createResourceRequest$1(config) {
501
564
  const headers = {};
502
565
  return {
503
566
  baseUri: '/services/data/v61.0',
@@ -511,45 +574,45 @@ function createResourceRequest(config) {
511
574
  };
512
575
  }
513
576
 
514
- const adapterName = 'createInvoicesBatchScheduler';
577
+ const adapterName$1 = 'createInvoicesBatchScheduler';
515
578
  const createInvoicesBatchScheduler_ConfigPropertyMetadata = [
516
579
  generateParamConfigMetadata('BatchInvoiceSchedulerInput', true, 2 /* Body */, 4 /* Unsupported */),
517
580
  ];
518
- const createInvoicesBatchScheduler_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, createInvoicesBatchScheduler_ConfigPropertyMetadata);
519
- const createResourceParams = /*#__PURE__*/ createResourceParams$2(createInvoicesBatchScheduler_ConfigPropertyMetadata);
520
- function typeCheckConfig(untrustedConfig) {
581
+ const createInvoicesBatchScheduler_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, createInvoicesBatchScheduler_ConfigPropertyMetadata);
582
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(createInvoicesBatchScheduler_ConfigPropertyMetadata);
583
+ function typeCheckConfig$1(untrustedConfig) {
521
584
  const config = {};
522
585
  const untrustedConfig_BatchInvoiceSchedulerInput = untrustedConfig.BatchInvoiceSchedulerInput;
523
- const referenceBatchInvoiceSchedulerInputRepresentationValidationError = validate$1(untrustedConfig_BatchInvoiceSchedulerInput);
586
+ const referenceBatchInvoiceSchedulerInputRepresentationValidationError = validate$2(untrustedConfig_BatchInvoiceSchedulerInput);
524
587
  if (referenceBatchInvoiceSchedulerInputRepresentationValidationError === null) {
525
588
  config.BatchInvoiceSchedulerInput = untrustedConfig_BatchInvoiceSchedulerInput;
526
589
  }
527
590
  return config;
528
591
  }
529
- function validateAdapterConfig(untrustedConfig, configPropertyNames) {
592
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
530
593
  if (!untrustedIsObject(untrustedConfig)) {
531
594
  return null;
532
595
  }
533
596
  if (process.env.NODE_ENV !== 'production') {
534
597
  validateConfig(untrustedConfig, configPropertyNames);
535
598
  }
536
- const config = typeCheckConfig(untrustedConfig);
599
+ const config = typeCheckConfig$1(untrustedConfig);
537
600
  if (!areRequiredParametersPresent(config, configPropertyNames)) {
538
601
  return null;
539
602
  }
540
603
  return config;
541
604
  }
542
- function buildNetworkSnapshot(luvio, config, options) {
543
- const resourceParams = createResourceParams(config);
544
- const request = createResourceRequest(resourceParams);
605
+ function buildNetworkSnapshot$1(luvio, config, options) {
606
+ const resourceParams = createResourceParams$1(config);
607
+ const request = createResourceRequest$1(resourceParams);
545
608
  return luvio.dispatchResourceRequest(request, options)
546
609
  .then((response) => {
547
610
  return luvio.handleSuccessResponse(() => {
548
- const snapshot = ingestSuccess(luvio, resourceParams, response);
611
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response);
549
612
  return luvio.storeBroadcast().then(() => snapshot);
550
613
  }, () => {
551
614
  const cache = new StoreKeyMap();
552
- getResponseCacheKeys(cache, luvio, resourceParams, response.body);
615
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
553
616
  return cache;
554
617
  });
555
618
  }, (response) => {
@@ -559,13 +622,241 @@ function buildNetworkSnapshot(luvio, config, options) {
559
622
  }
560
623
  const createInvoicesBatchSchedulerAdapterFactory = (luvio) => {
561
624
  return function createInvoicesBatchScheduler(untrustedConfig) {
562
- const config = validateAdapterConfig(untrustedConfig, createInvoicesBatchScheduler_ConfigPropertyNames);
625
+ const config = validateAdapterConfig$1(untrustedConfig, createInvoicesBatchScheduler_ConfigPropertyNames);
563
626
  // Invalid or incomplete config
564
627
  if (config === null) {
565
628
  throw new Error('Invalid config for "createInvoicesBatchScheduler"');
566
629
  }
567
- return buildNetworkSnapshot(luvio, config);
630
+ return buildNetworkSnapshot$1(luvio, config);
631
+ };
632
+ };
633
+
634
+ const TTL = 1000;
635
+ const VERSION = "4f294efd1302feb8c06cda89d151e387";
636
+ function validate(obj, path = 'InvoiceBatchDraftToPostedOutputRepresentation') {
637
+ const v_error = (() => {
638
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
639
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
640
+ }
641
+ const obj_invoiceBatchDraftToPostedId = obj.invoiceBatchDraftToPostedId;
642
+ const path_invoiceBatchDraftToPostedId = path + '.invoiceBatchDraftToPostedId';
643
+ if (typeof obj_invoiceBatchDraftToPostedId !== 'string') {
644
+ return new TypeError('Expected "string" but received "' + typeof obj_invoiceBatchDraftToPostedId + '" (at "' + path_invoiceBatchDraftToPostedId + '")');
645
+ }
646
+ const obj_requestIdentifier = obj.requestIdentifier;
647
+ const path_requestIdentifier = path + '.requestIdentifier';
648
+ if (typeof obj_requestIdentifier !== 'string') {
649
+ return new TypeError('Expected "string" but received "' + typeof obj_requestIdentifier + '" (at "' + path_requestIdentifier + '")');
650
+ }
651
+ const obj_success = obj.success;
652
+ const path_success = path + '.success';
653
+ if (typeof obj_success !== 'boolean') {
654
+ return new TypeError('Expected "boolean" but received "' + typeof obj_success + '" (at "' + path_success + '")');
655
+ }
656
+ })();
657
+ return v_error === undefined ? null : v_error;
658
+ }
659
+ const RepresentationType = 'InvoiceBatchDraftToPostedOutputRepresentation';
660
+ function normalize(input, existing, path, luvio, store, timestamp) {
661
+ return input;
662
+ }
663
+ const select$1 = function InvoiceBatchDraftToPostedOutputRepresentationSelect() {
664
+ return {
665
+ kind: 'Fragment',
666
+ version: VERSION,
667
+ private: [],
668
+ selections: [
669
+ {
670
+ name: 'invoiceBatchDraftToPostedId',
671
+ kind: 'Scalar'
672
+ },
673
+ {
674
+ name: 'requestIdentifier',
675
+ kind: 'Scalar'
676
+ },
677
+ {
678
+ name: 'success',
679
+ kind: 'Scalar'
680
+ }
681
+ ]
568
682
  };
569
683
  };
684
+ function equals(existing, incoming) {
685
+ const existing_success = existing.success;
686
+ const incoming_success = incoming.success;
687
+ if (!(existing_success === incoming_success)) {
688
+ return false;
689
+ }
690
+ const existing_invoiceBatchDraftToPostedId = existing.invoiceBatchDraftToPostedId;
691
+ const incoming_invoiceBatchDraftToPostedId = incoming.invoiceBatchDraftToPostedId;
692
+ if (!(existing_invoiceBatchDraftToPostedId === incoming_invoiceBatchDraftToPostedId)) {
693
+ return false;
694
+ }
695
+ const existing_requestIdentifier = existing.requestIdentifier;
696
+ const incoming_requestIdentifier = incoming.requestIdentifier;
697
+ if (!(existing_requestIdentifier === incoming_requestIdentifier)) {
698
+ return false;
699
+ }
700
+ return true;
701
+ }
702
+ const ingest = function InvoiceBatchDraftToPostedOutputRepresentationIngest(input, path, luvio, store, timestamp) {
703
+ if (process.env.NODE_ENV !== 'production') {
704
+ const validateError = validate(input);
705
+ if (validateError !== null) {
706
+ throw validateError;
707
+ }
708
+ }
709
+ const key = path.fullPath;
710
+ const ttlToUse = TTL;
711
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "BillingBatch", VERSION, RepresentationType, equals);
712
+ return createLink(key);
713
+ };
714
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
715
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
716
+ const rootKey = fullPathFactory();
717
+ rootKeySet.set(rootKey, {
718
+ namespace: keyPrefix,
719
+ representationName: RepresentationType,
720
+ mergeable: false
721
+ });
722
+ }
723
+
724
+ function select(luvio, params) {
725
+ return select$1();
726
+ }
727
+ function keyBuilder$1(luvio, params) {
728
+ return keyPrefix + '::InvoiceBatchDraftToPostedOutputRepresentation:(' + 'invoiceBatchRunId:' + params.urlParams.invoiceBatchRunId + ',' + stableJSONStringify(params.body) + ')';
729
+ }
730
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
731
+ getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
732
+ }
733
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
734
+ const { body } = response;
735
+ const key = keyBuilder$1(luvio, resourceParams);
736
+ luvio.storeIngest(key, ingest, body);
737
+ const snapshot = luvio.storeLookup({
738
+ recordId: key,
739
+ node: select(),
740
+ variables: {},
741
+ }, snapshotRefresh);
742
+ if (process.env.NODE_ENV !== 'production') {
743
+ if (snapshot.state !== 'Fulfilled') {
744
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
745
+ }
746
+ }
747
+ deepFreeze(snapshot.data);
748
+ return snapshot;
749
+ }
750
+ function ingestError(luvio, params, error, snapshotRefresh) {
751
+ const key = keyBuilder$1(luvio, params);
752
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
753
+ const storeMetadataParams = {
754
+ ttl: TTL,
755
+ namespace: keyPrefix,
756
+ version: VERSION,
757
+ representationName: RepresentationType
758
+ };
759
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
760
+ return errorSnapshot;
761
+ }
762
+ function createResourceRequest(config) {
763
+ const headers = {};
764
+ return {
765
+ baseUri: '/services/data/v61.0',
766
+ basePath: '/commerce/invoicing/invoice-batch-runs/' + config.urlParams.invoiceBatchRunId + '/actions/draft-to-posted',
767
+ method: 'post',
768
+ body: config.body,
769
+ urlParams: config.urlParams,
770
+ queryParams: {},
771
+ headers,
772
+ priority: 'normal',
773
+ };
774
+ }
775
+
776
+ const adapterName = 'postBatchDraftInvoices';
777
+ const postBatchDraftInvoices_ConfigPropertyMetadata = [
778
+ generateParamConfigMetadata('invoiceBatchRunId', true, 0 /* UrlParameter */, 0 /* String */),
779
+ ];
780
+ const postBatchDraftInvoices_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, postBatchDraftInvoices_ConfigPropertyMetadata);
781
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(postBatchDraftInvoices_ConfigPropertyMetadata);
782
+ function keyBuilder(luvio, config) {
783
+ const resourceParams = createResourceParams(config);
784
+ return keyBuilder$1(luvio, resourceParams);
785
+ }
786
+ function typeCheckConfig(untrustedConfig) {
787
+ const config = {};
788
+ typeCheckConfig$3(untrustedConfig, config, postBatchDraftInvoices_ConfigPropertyMetadata);
789
+ return config;
790
+ }
791
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
792
+ if (!untrustedIsObject(untrustedConfig)) {
793
+ return null;
794
+ }
795
+ if (process.env.NODE_ENV !== 'production') {
796
+ validateConfig(untrustedConfig, configPropertyNames);
797
+ }
798
+ const config = typeCheckConfig(untrustedConfig);
799
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
800
+ return null;
801
+ }
802
+ return config;
803
+ }
804
+ function adapterFragment(luvio, config) {
805
+ createResourceParams(config);
806
+ return select();
807
+ }
808
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
809
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
810
+ config,
811
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
812
+ });
813
+ return luvio.storeBroadcast().then(() => snapshot);
814
+ }
815
+ function onFetchResponseError(luvio, config, resourceParams, response) {
816
+ const snapshot = ingestError(luvio, resourceParams, response, {
817
+ config,
818
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
819
+ });
820
+ return luvio.storeBroadcast().then(() => snapshot);
821
+ }
822
+ function buildNetworkSnapshot(luvio, config, options) {
823
+ const resourceParams = createResourceParams(config);
824
+ const request = createResourceRequest(resourceParams);
825
+ return luvio.dispatchResourceRequest(request, options)
826
+ .then((response) => {
827
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
828
+ const cache = new StoreKeyMap();
829
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
830
+ return cache;
831
+ });
832
+ }, (response) => {
833
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
834
+ });
835
+ }
836
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
837
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot, 'get', false);
838
+ }
839
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
840
+ const { luvio, config } = context;
841
+ const selector = {
842
+ recordId: keyBuilder(luvio, config),
843
+ node: adapterFragment(luvio, config),
844
+ variables: {},
845
+ };
846
+ const cacheSnapshot = storeLookup(selector, {
847
+ config,
848
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
849
+ });
850
+ return cacheSnapshot;
851
+ }
852
+ const postBatchDraftInvoicesAdapterFactory = (luvio) => function BillingBatch__postBatchDraftInvoices(untrustedConfig, requestContext) {
853
+ const config = validateAdapterConfig(untrustedConfig, postBatchDraftInvoices_ConfigPropertyNames);
854
+ // Invalid or incomplete config
855
+ if (config === null) {
856
+ return null;
857
+ }
858
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
859
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
860
+ };
570
861
 
571
- export { createInvoicesBatchSchedulerAdapterFactory, createPaymentsBatchSchedulerAdapterFactory };
862
+ export { createInvoicesBatchSchedulerAdapterFactory, createPaymentsBatchSchedulerAdapterFactory, postBatchDraftInvoicesAdapterFactory };