@salesforce/lds-adapters-revenue-harmonizebilling 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.
Files changed (26) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/revenue-harmonizebilling.js +915 -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/postDraftInvoices.d.ts +28 -0
  5. package/dist/es/es2018/types/src/generated/adapters/resumeBilling.d.ts +28 -0
  6. package/dist/es/es2018/types/src/generated/adapters/suspendBilling.d.ts +28 -0
  7. package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +3 -0
  8. package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +7 -0
  9. package/dist/es/es2018/types/src/generated/resources/postCommerceInvoicingActionsResumeBilling.d.ts +16 -0
  10. package/dist/es/es2018/types/src/generated/resources/postCommerceInvoicingActionsSuspendBilling.d.ts +16 -0
  11. package/dist/es/es2018/types/src/generated/resources/postCommerceInvoicingInvoicesCollectionActionsPost.d.ts +16 -0
  12. package/dist/es/es2018/types/src/generated/types/ErrorResponseRepresentation.d.ts +31 -0
  13. package/dist/es/es2018/types/src/generated/types/InvoiceDraftToPostedInputRepresentation.d.ts +31 -0
  14. package/dist/es/es2018/types/src/generated/types/ResumeBillingEntityInputRepresentation.d.ts +31 -0
  15. package/dist/es/es2018/types/src/generated/types/ResumeBillingInputRepresentation.d.ts +29 -0
  16. package/dist/es/es2018/types/src/generated/types/RevenueAsyncRepresentation.d.ts +39 -0
  17. package/dist/es/es2018/types/src/generated/types/SuspendBillingEntityInputRepresentation.d.ts +34 -0
  18. package/dist/es/es2018/types/src/generated/types/SuspendBillingInputRepresentation.d.ts +29 -0
  19. package/dist/es/es2018/types/src/generated/types/SuspendResumeBillingEntityOutputRepresentation.d.ts +37 -0
  20. package/dist/es/es2018/types/src/generated/types/SuspendResumeBillingOutputRepresentation.d.ts +30 -0
  21. package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
  22. package/package.json +66 -0
  23. package/sfdc/index.d.ts +1 -0
  24. package/sfdc/index.js +969 -0
  25. package/src/raml/api.raml +195 -0
  26. package/src/raml/luvio.raml +34 -0
@@ -0,0 +1,915 @@
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$3, StoreKeyMap, createResourceParams as createResourceParams$3, typeCheckConfig as typeCheckConfig$3 } 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 = 'HarmonizeBilling';
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
+ function validate$5(obj, path = 'ResumeBillingEntityInputRepresentation') {
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_referenceId = obj.referenceId;
100
+ const path_referenceId = path + '.referenceId';
101
+ if (typeof obj_referenceId !== 'string') {
102
+ return new TypeError('Expected "string" but received "' + typeof obj_referenceId + '" (at "' + path_referenceId + '")');
103
+ }
104
+ const obj_resumeDate = obj.resumeDate;
105
+ const path_resumeDate = path + '.resumeDate';
106
+ if (typeof obj_resumeDate !== 'string') {
107
+ return new TypeError('Expected "string" but received "' + typeof obj_resumeDate + '" (at "' + path_resumeDate + '")');
108
+ }
109
+ })();
110
+ return v_error === undefined ? null : v_error;
111
+ }
112
+
113
+ const VERSION$3 = "7ce2fe81672ecdc9756f0999302e57da";
114
+ function validate$4(obj, path = 'SuspendResumeBillingEntityOutputRepresentation') {
115
+ const v_error = (() => {
116
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
117
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
118
+ }
119
+ const obj_errorCode = obj.errorCode;
120
+ const path_errorCode = path + '.errorCode';
121
+ if (typeof obj_errorCode !== 'string') {
122
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
123
+ }
124
+ const obj_errorMessage = obj.errorMessage;
125
+ const path_errorMessage = path + '.errorMessage';
126
+ if (typeof obj_errorMessage !== 'string') {
127
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
128
+ }
129
+ const obj_isSuccess = obj.isSuccess;
130
+ const path_isSuccess = path + '.isSuccess';
131
+ if (typeof obj_isSuccess !== 'boolean') {
132
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
133
+ }
134
+ const obj_referenceId = obj.referenceId;
135
+ const path_referenceId = path + '.referenceId';
136
+ if (typeof obj_referenceId !== 'string') {
137
+ return new TypeError('Expected "string" but received "' + typeof obj_referenceId + '" (at "' + path_referenceId + '")');
138
+ }
139
+ })();
140
+ return v_error === undefined ? null : v_error;
141
+ }
142
+ const select$6 = function SuspendResumeBillingEntityOutputRepresentationSelect() {
143
+ return {
144
+ kind: 'Fragment',
145
+ version: VERSION$3,
146
+ private: [],
147
+ selections: [
148
+ {
149
+ name: 'errorCode',
150
+ kind: 'Scalar'
151
+ },
152
+ {
153
+ name: 'errorMessage',
154
+ kind: 'Scalar'
155
+ },
156
+ {
157
+ name: 'isSuccess',
158
+ kind: 'Scalar'
159
+ },
160
+ {
161
+ name: 'referenceId',
162
+ kind: 'Scalar'
163
+ }
164
+ ]
165
+ };
166
+ };
167
+ function equals$3(existing, incoming) {
168
+ const existing_isSuccess = existing.isSuccess;
169
+ const incoming_isSuccess = incoming.isSuccess;
170
+ if (!(existing_isSuccess === incoming_isSuccess)) {
171
+ return false;
172
+ }
173
+ const existing_errorCode = existing.errorCode;
174
+ const incoming_errorCode = incoming.errorCode;
175
+ if (!(existing_errorCode === incoming_errorCode)) {
176
+ return false;
177
+ }
178
+ const existing_errorMessage = existing.errorMessage;
179
+ const incoming_errorMessage = incoming.errorMessage;
180
+ if (!(existing_errorMessage === incoming_errorMessage)) {
181
+ return false;
182
+ }
183
+ const existing_referenceId = existing.referenceId;
184
+ const incoming_referenceId = incoming.referenceId;
185
+ if (!(existing_referenceId === incoming_referenceId)) {
186
+ return false;
187
+ }
188
+ return true;
189
+ }
190
+
191
+ const TTL$1 = 1000;
192
+ const VERSION$2 = "ebcd12edcc328665dfa61064953627b5";
193
+ function validate$3(obj, path = 'SuspendResumeBillingOutputRepresentation') {
194
+ const v_error = (() => {
195
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
196
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
197
+ }
198
+ const obj_result = obj.result;
199
+ const path_result = path + '.result';
200
+ if (!ArrayIsArray(obj_result)) {
201
+ return new TypeError('Expected "array" but received "' + typeof obj_result + '" (at "' + path_result + '")');
202
+ }
203
+ for (let i = 0; i < obj_result.length; i++) {
204
+ const obj_result_item = obj_result[i];
205
+ const path_result_item = path_result + '[' + i + ']';
206
+ const referencepath_result_itemValidationError = validate$4(obj_result_item, path_result_item);
207
+ if (referencepath_result_itemValidationError !== null) {
208
+ let message = 'Object doesn\'t match SuspendResumeBillingEntityOutputRepresentation (at "' + path_result_item + '")\n';
209
+ message += referencepath_result_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
210
+ return new TypeError(message);
211
+ }
212
+ }
213
+ })();
214
+ return v_error === undefined ? null : v_error;
215
+ }
216
+ const RepresentationType$1 = 'SuspendResumeBillingOutputRepresentation';
217
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
218
+ return input;
219
+ }
220
+ const select$5 = function SuspendResumeBillingOutputRepresentationSelect() {
221
+ const { selections: SuspendResumeBillingEntityOutputRepresentation__selections, opaque: SuspendResumeBillingEntityOutputRepresentation__opaque, } = select$6();
222
+ return {
223
+ kind: 'Fragment',
224
+ version: VERSION$2,
225
+ private: [],
226
+ selections: [
227
+ {
228
+ name: 'result',
229
+ kind: 'Object',
230
+ plural: true,
231
+ selections: SuspendResumeBillingEntityOutputRepresentation__selections
232
+ }
233
+ ]
234
+ };
235
+ };
236
+ function equals$2(existing, incoming) {
237
+ const existing_result = existing.result;
238
+ const incoming_result = incoming.result;
239
+ const equals_result_items = equalsArray(existing_result, incoming_result, (existing_result_item, incoming_result_item) => {
240
+ if (!(equals$3(existing_result_item, incoming_result_item))) {
241
+ return false;
242
+ }
243
+ });
244
+ if (equals_result_items === false) {
245
+ return false;
246
+ }
247
+ return true;
248
+ }
249
+ const ingest$1 = function SuspendResumeBillingOutputRepresentationIngest(input, path, luvio, store, timestamp) {
250
+ if (process.env.NODE_ENV !== 'production') {
251
+ const validateError = validate$3(input);
252
+ if (validateError !== null) {
253
+ throw validateError;
254
+ }
255
+ }
256
+ const key = path.fullPath;
257
+ const ttlToUse = TTL$1;
258
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "HarmonizeBilling", VERSION$2, RepresentationType$1, equals$2);
259
+ return createLink(key);
260
+ };
261
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
262
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
263
+ const rootKey = fullPathFactory();
264
+ rootKeySet.set(rootKey, {
265
+ namespace: keyPrefix,
266
+ representationName: RepresentationType$1,
267
+ mergeable: false
268
+ });
269
+ }
270
+
271
+ function select$4(luvio, params) {
272
+ return select$5();
273
+ }
274
+ function keyBuilder$5(luvio, params) {
275
+ return keyPrefix + '::SuspendResumeBillingOutputRepresentation:(' + '[' + params.body.referenceIds.map(element => 'referenceIds.referenceId:' + element.referenceId + '::' + 'referenceIds.resumeDate:' + element.resumeDate).join(',') + ']' + ')';
276
+ }
277
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
278
+ getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$5(luvio, resourceParams));
279
+ }
280
+ function ingestSuccess$2(luvio, resourceParams, response, snapshotRefresh) {
281
+ const { body } = response;
282
+ const key = keyBuilder$5(luvio, resourceParams);
283
+ luvio.storeIngest(key, ingest$1, body);
284
+ const snapshot = luvio.storeLookup({
285
+ recordId: key,
286
+ node: select$4(),
287
+ variables: {},
288
+ }, snapshotRefresh);
289
+ if (process.env.NODE_ENV !== 'production') {
290
+ if (snapshot.state !== 'Fulfilled') {
291
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
292
+ }
293
+ }
294
+ deepFreeze(snapshot.data);
295
+ return snapshot;
296
+ }
297
+ function ingestError$2(luvio, params, error, snapshotRefresh) {
298
+ const key = keyBuilder$5(luvio, params);
299
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
300
+ const storeMetadataParams = {
301
+ ttl: TTL$1,
302
+ namespace: keyPrefix,
303
+ version: VERSION$2,
304
+ representationName: RepresentationType$1
305
+ };
306
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
307
+ return errorSnapshot;
308
+ }
309
+ function createResourceRequest$2(config) {
310
+ const headers = {};
311
+ return {
312
+ baseUri: '/services/data/v66.0',
313
+ basePath: '/commerce/invoicing/actions/resume-billing',
314
+ method: 'post',
315
+ body: config.body,
316
+ urlParams: {},
317
+ queryParams: {},
318
+ headers,
319
+ priority: 'normal',
320
+ };
321
+ }
322
+
323
+ const adapterName$2 = 'resumeBilling';
324
+ const resumeBilling_ConfigPropertyMetadata = [
325
+ generateParamConfigMetadata('referenceIds', true, 2 /* Body */, 4 /* Unsupported */, true),
326
+ ];
327
+ const resumeBilling_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, resumeBilling_ConfigPropertyMetadata);
328
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(resumeBilling_ConfigPropertyMetadata);
329
+ function keyBuilder$4(luvio, config) {
330
+ const resourceParams = createResourceParams$2(config);
331
+ return keyBuilder$5(luvio, resourceParams);
332
+ }
333
+ function typeCheckConfig$2(untrustedConfig) {
334
+ const config = {};
335
+ const untrustedConfig_referenceIds = untrustedConfig.referenceIds;
336
+ if (ArrayIsArray$1(untrustedConfig_referenceIds)) {
337
+ const untrustedConfig_referenceIds_array = [];
338
+ for (let i = 0, arrayLength = untrustedConfig_referenceIds.length; i < arrayLength; i++) {
339
+ const untrustedConfig_referenceIds_item = untrustedConfig_referenceIds[i];
340
+ const referenceResumeBillingEntityInputRepresentationValidationError = validate$5(untrustedConfig_referenceIds_item);
341
+ if (referenceResumeBillingEntityInputRepresentationValidationError === null) {
342
+ untrustedConfig_referenceIds_array.push(untrustedConfig_referenceIds_item);
343
+ }
344
+ }
345
+ config.referenceIds = untrustedConfig_referenceIds_array;
346
+ }
347
+ return config;
348
+ }
349
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
350
+ if (!untrustedIsObject(untrustedConfig)) {
351
+ return null;
352
+ }
353
+ if (process.env.NODE_ENV !== 'production') {
354
+ validateConfig(untrustedConfig, configPropertyNames);
355
+ }
356
+ const config = typeCheckConfig$2(untrustedConfig);
357
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
358
+ return null;
359
+ }
360
+ return config;
361
+ }
362
+ function adapterFragment$2(luvio, config) {
363
+ createResourceParams$2(config);
364
+ return select$4();
365
+ }
366
+ function onFetchResponseSuccess$2(luvio, config, resourceParams, response) {
367
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response, {
368
+ config,
369
+ resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
370
+ });
371
+ return luvio.storeBroadcast().then(() => snapshot);
372
+ }
373
+ function onFetchResponseError$2(luvio, config, resourceParams, response) {
374
+ const snapshot = ingestError$2(luvio, resourceParams, response, {
375
+ config,
376
+ resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
377
+ });
378
+ return luvio.storeBroadcast().then(() => snapshot);
379
+ }
380
+ function buildNetworkSnapshot$2(luvio, config, options) {
381
+ const resourceParams = createResourceParams$2(config);
382
+ const request = createResourceRequest$2(resourceParams);
383
+ return luvio.dispatchResourceRequest(request, options)
384
+ .then((response) => {
385
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$2(luvio, config, resourceParams, response), () => {
386
+ const cache = new StoreKeyMap();
387
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
388
+ return cache;
389
+ });
390
+ }, (response) => {
391
+ return luvio.handleErrorResponse(() => onFetchResponseError$2(luvio, config, resourceParams, response));
392
+ });
393
+ }
394
+ function buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext) {
395
+ return buildNetworkSnapshotCachePolicy$3(context, coercedAdapterRequestContext, buildNetworkSnapshot$2, 'get', false);
396
+ }
397
+ function buildCachedSnapshotCachePolicy$2(context, storeLookup) {
398
+ const { luvio, config } = context;
399
+ const selector = {
400
+ recordId: keyBuilder$4(luvio, config),
401
+ node: adapterFragment$2(luvio, config),
402
+ variables: {},
403
+ };
404
+ const cacheSnapshot = storeLookup(selector, {
405
+ config,
406
+ resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
407
+ });
408
+ return cacheSnapshot;
409
+ }
410
+ const resumeBillingAdapterFactory = (luvio) => function HarmonizeBilling__resumeBilling(untrustedConfig, requestContext) {
411
+ const config = validateAdapterConfig$2(untrustedConfig, resumeBilling_ConfigPropertyNames);
412
+ // Invalid or incomplete config
413
+ if (config === null) {
414
+ return null;
415
+ }
416
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
417
+ buildCachedSnapshotCachePolicy$2, buildNetworkSnapshotCachePolicy$2);
418
+ };
419
+
420
+ function validate$2(obj, path = 'SuspendBillingEntityInputRepresentation') {
421
+ const v_error = (() => {
422
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
423
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
424
+ }
425
+ const obj_referenceId = obj.referenceId;
426
+ const path_referenceId = path + '.referenceId';
427
+ if (typeof obj_referenceId !== 'string') {
428
+ return new TypeError('Expected "string" but received "' + typeof obj_referenceId + '" (at "' + path_referenceId + '")');
429
+ }
430
+ const obj_resumeDate = obj.resumeDate;
431
+ const path_resumeDate = path + '.resumeDate';
432
+ if (typeof obj_resumeDate !== 'string') {
433
+ return new TypeError('Expected "string" but received "' + typeof obj_resumeDate + '" (at "' + path_resumeDate + '")');
434
+ }
435
+ const obj_suspendDate = obj.suspendDate;
436
+ const path_suspendDate = path + '.suspendDate';
437
+ if (typeof obj_suspendDate !== 'string') {
438
+ return new TypeError('Expected "string" but received "' + typeof obj_suspendDate + '" (at "' + path_suspendDate + '")');
439
+ }
440
+ })();
441
+ return v_error === undefined ? null : v_error;
442
+ }
443
+
444
+ function select$3(luvio, params) {
445
+ return select$5();
446
+ }
447
+ function keyBuilder$3(luvio, params) {
448
+ return keyPrefix + '::SuspendResumeBillingOutputRepresentation:(' + '[' + params.body.referenceIds.map(element => 'referenceIds.referenceId:' + element.referenceId + '::' + 'referenceIds.resumeDate:' + element.resumeDate + '::' + 'referenceIds.suspendDate:' + element.suspendDate).join(',') + ']' + ')';
449
+ }
450
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
451
+ getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$3(luvio, resourceParams));
452
+ }
453
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
454
+ const { body } = response;
455
+ const key = keyBuilder$3(luvio, resourceParams);
456
+ luvio.storeIngest(key, ingest$1, body);
457
+ const snapshot = luvio.storeLookup({
458
+ recordId: key,
459
+ node: select$3(),
460
+ variables: {},
461
+ }, snapshotRefresh);
462
+ if (process.env.NODE_ENV !== 'production') {
463
+ if (snapshot.state !== 'Fulfilled') {
464
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
465
+ }
466
+ }
467
+ deepFreeze(snapshot.data);
468
+ return snapshot;
469
+ }
470
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
471
+ const key = keyBuilder$3(luvio, params);
472
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
473
+ const storeMetadataParams = {
474
+ ttl: TTL$1,
475
+ namespace: keyPrefix,
476
+ version: VERSION$2,
477
+ representationName: RepresentationType$1
478
+ };
479
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
480
+ return errorSnapshot;
481
+ }
482
+ function createResourceRequest$1(config) {
483
+ const headers = {};
484
+ return {
485
+ baseUri: '/services/data/v66.0',
486
+ basePath: '/commerce/invoicing/actions/suspend-billing',
487
+ method: 'post',
488
+ body: config.body,
489
+ urlParams: {},
490
+ queryParams: {},
491
+ headers,
492
+ priority: 'normal',
493
+ };
494
+ }
495
+
496
+ const adapterName$1 = 'suspendBilling';
497
+ const suspendBilling_ConfigPropertyMetadata = [
498
+ generateParamConfigMetadata('referenceIds', true, 2 /* Body */, 4 /* Unsupported */, true),
499
+ ];
500
+ const suspendBilling_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, suspendBilling_ConfigPropertyMetadata);
501
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(suspendBilling_ConfigPropertyMetadata);
502
+ function keyBuilder$2(luvio, config) {
503
+ const resourceParams = createResourceParams$1(config);
504
+ return keyBuilder$3(luvio, resourceParams);
505
+ }
506
+ function typeCheckConfig$1(untrustedConfig) {
507
+ const config = {};
508
+ const untrustedConfig_referenceIds = untrustedConfig.referenceIds;
509
+ if (ArrayIsArray$1(untrustedConfig_referenceIds)) {
510
+ const untrustedConfig_referenceIds_array = [];
511
+ for (let i = 0, arrayLength = untrustedConfig_referenceIds.length; i < arrayLength; i++) {
512
+ const untrustedConfig_referenceIds_item = untrustedConfig_referenceIds[i];
513
+ const referenceSuspendBillingEntityInputRepresentationValidationError = validate$2(untrustedConfig_referenceIds_item);
514
+ if (referenceSuspendBillingEntityInputRepresentationValidationError === null) {
515
+ untrustedConfig_referenceIds_array.push(untrustedConfig_referenceIds_item);
516
+ }
517
+ }
518
+ config.referenceIds = untrustedConfig_referenceIds_array;
519
+ }
520
+ return config;
521
+ }
522
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
523
+ if (!untrustedIsObject(untrustedConfig)) {
524
+ return null;
525
+ }
526
+ if (process.env.NODE_ENV !== 'production') {
527
+ validateConfig(untrustedConfig, configPropertyNames);
528
+ }
529
+ const config = typeCheckConfig$1(untrustedConfig);
530
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
531
+ return null;
532
+ }
533
+ return config;
534
+ }
535
+ function adapterFragment$1(luvio, config) {
536
+ createResourceParams$1(config);
537
+ return select$3();
538
+ }
539
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
540
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
541
+ config,
542
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
543
+ });
544
+ return luvio.storeBroadcast().then(() => snapshot);
545
+ }
546
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
547
+ const snapshot = ingestError$1(luvio, resourceParams, response, {
548
+ config,
549
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
550
+ });
551
+ return luvio.storeBroadcast().then(() => snapshot);
552
+ }
553
+ function buildNetworkSnapshot$1(luvio, config, options) {
554
+ const resourceParams = createResourceParams$1(config);
555
+ const request = createResourceRequest$1(resourceParams);
556
+ return luvio.dispatchResourceRequest(request, options)
557
+ .then((response) => {
558
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => {
559
+ const cache = new StoreKeyMap();
560
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
561
+ return cache;
562
+ });
563
+ }, (response) => {
564
+ return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
565
+ });
566
+ }
567
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
568
+ return buildNetworkSnapshotCachePolicy$3(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, 'get', false);
569
+ }
570
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
571
+ const { luvio, config } = context;
572
+ const selector = {
573
+ recordId: keyBuilder$2(luvio, config),
574
+ node: adapterFragment$1(luvio, config),
575
+ variables: {},
576
+ };
577
+ const cacheSnapshot = storeLookup(selector, {
578
+ config,
579
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
580
+ });
581
+ return cacheSnapshot;
582
+ }
583
+ const suspendBillingAdapterFactory = (luvio) => function HarmonizeBilling__suspendBilling(untrustedConfig, requestContext) {
584
+ const config = validateAdapterConfig$1(untrustedConfig, suspendBilling_ConfigPropertyNames);
585
+ // Invalid or incomplete config
586
+ if (config === null) {
587
+ return null;
588
+ }
589
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
590
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
591
+ };
592
+
593
+ const VERSION$1 = "87ee05ce3f88ad0a2dc442b213bfc776";
594
+ function validate$1(obj, path = 'ErrorResponseRepresentation') {
595
+ const v_error = (() => {
596
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
597
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
598
+ }
599
+ const obj_errorCode = obj.errorCode;
600
+ const path_errorCode = path + '.errorCode';
601
+ if (typeof obj_errorCode !== 'string') {
602
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
603
+ }
604
+ const obj_message = obj.message;
605
+ const path_message = path + '.message';
606
+ if (typeof obj_message !== 'string') {
607
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
608
+ }
609
+ })();
610
+ return v_error === undefined ? null : v_error;
611
+ }
612
+ const select$2 = function ErrorResponseRepresentationSelect() {
613
+ return {
614
+ kind: 'Fragment',
615
+ version: VERSION$1,
616
+ private: [],
617
+ selections: [
618
+ {
619
+ name: 'errorCode',
620
+ kind: 'Scalar'
621
+ },
622
+ {
623
+ name: 'message',
624
+ kind: 'Scalar'
625
+ }
626
+ ]
627
+ };
628
+ };
629
+ function equals$1(existing, incoming) {
630
+ const existing_errorCode = existing.errorCode;
631
+ const incoming_errorCode = incoming.errorCode;
632
+ if (!(existing_errorCode === incoming_errorCode)) {
633
+ return false;
634
+ }
635
+ const existing_message = existing.message;
636
+ const incoming_message = incoming.message;
637
+ if (!(existing_message === incoming_message)) {
638
+ return false;
639
+ }
640
+ return true;
641
+ }
642
+
643
+ const TTL = 1000;
644
+ const VERSION = "c39f40d590b6aa4fa4327c8ca997c6cc";
645
+ function validate(obj, path = 'RevenueAsyncRepresentation') {
646
+ const v_error = (() => {
647
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
648
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
649
+ }
650
+ const obj_errors = obj.errors;
651
+ const path_errors = path + '.errors';
652
+ if (!ArrayIsArray(obj_errors)) {
653
+ return new TypeError('Expected "array" but received "' + typeof obj_errors + '" (at "' + path_errors + '")');
654
+ }
655
+ for (let i = 0; i < obj_errors.length; i++) {
656
+ const obj_errors_item = obj_errors[i];
657
+ const path_errors_item = path_errors + '[' + i + ']';
658
+ const referencepath_errors_itemValidationError = validate$1(obj_errors_item, path_errors_item);
659
+ if (referencepath_errors_itemValidationError !== null) {
660
+ let message = 'Object doesn\'t match ErrorResponseRepresentation (at "' + path_errors_item + '")\n';
661
+ message += referencepath_errors_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
662
+ return new TypeError(message);
663
+ }
664
+ }
665
+ const obj_requestIdentifier = obj.requestIdentifier;
666
+ const path_requestIdentifier = path + '.requestIdentifier';
667
+ if (typeof obj_requestIdentifier !== 'string') {
668
+ return new TypeError('Expected "string" but received "' + typeof obj_requestIdentifier + '" (at "' + path_requestIdentifier + '")');
669
+ }
670
+ if (obj.statusURL !== undefined) {
671
+ const obj_statusURL = obj.statusURL;
672
+ const path_statusURL = path + '.statusURL';
673
+ if (typeof obj_statusURL !== 'string') {
674
+ return new TypeError('Expected "string" but received "' + typeof obj_statusURL + '" (at "' + path_statusURL + '")');
675
+ }
676
+ }
677
+ const obj_success = obj.success;
678
+ const path_success = path + '.success';
679
+ if (typeof obj_success !== 'boolean') {
680
+ return new TypeError('Expected "boolean" but received "' + typeof obj_success + '" (at "' + path_success + '")');
681
+ }
682
+ })();
683
+ return v_error === undefined ? null : v_error;
684
+ }
685
+ const RepresentationType = 'RevenueAsyncRepresentation';
686
+ function normalize(input, existing, path, luvio, store, timestamp) {
687
+ return input;
688
+ }
689
+ const select$1 = function RevenueAsyncRepresentationSelect() {
690
+ const { selections: ErrorResponseRepresentation__selections, opaque: ErrorResponseRepresentation__opaque, } = select$2();
691
+ return {
692
+ kind: 'Fragment',
693
+ version: VERSION,
694
+ private: [],
695
+ selections: [
696
+ {
697
+ name: 'errors',
698
+ kind: 'Object',
699
+ plural: true,
700
+ selections: ErrorResponseRepresentation__selections
701
+ },
702
+ {
703
+ name: 'requestIdentifier',
704
+ kind: 'Scalar'
705
+ },
706
+ {
707
+ name: 'statusURL',
708
+ kind: 'Scalar',
709
+ required: false
710
+ },
711
+ {
712
+ name: 'success',
713
+ kind: 'Scalar'
714
+ }
715
+ ]
716
+ };
717
+ };
718
+ function equals(existing, incoming) {
719
+ const existing_success = existing.success;
720
+ const incoming_success = incoming.success;
721
+ if (!(existing_success === incoming_success)) {
722
+ return false;
723
+ }
724
+ const existing_requestIdentifier = existing.requestIdentifier;
725
+ const incoming_requestIdentifier = incoming.requestIdentifier;
726
+ if (!(existing_requestIdentifier === incoming_requestIdentifier)) {
727
+ return false;
728
+ }
729
+ const existing_statusURL = existing.statusURL;
730
+ const incoming_statusURL = incoming.statusURL;
731
+ // if at least one of these optionals is defined
732
+ if (existing_statusURL !== undefined || incoming_statusURL !== undefined) {
733
+ // if one of these is not defined we know the other is defined and therefore
734
+ // not equal
735
+ if (existing_statusURL === undefined || incoming_statusURL === undefined) {
736
+ return false;
737
+ }
738
+ if (!(existing_statusURL === incoming_statusURL)) {
739
+ return false;
740
+ }
741
+ }
742
+ const existing_errors = existing.errors;
743
+ const incoming_errors = incoming.errors;
744
+ const equals_errors_items = equalsArray(existing_errors, incoming_errors, (existing_errors_item, incoming_errors_item) => {
745
+ if (!(equals$1(existing_errors_item, incoming_errors_item))) {
746
+ return false;
747
+ }
748
+ });
749
+ if (equals_errors_items === false) {
750
+ return false;
751
+ }
752
+ return true;
753
+ }
754
+ const ingest = function RevenueAsyncRepresentationIngest(input, path, luvio, store, timestamp) {
755
+ if (process.env.NODE_ENV !== 'production') {
756
+ const validateError = validate(input);
757
+ if (validateError !== null) {
758
+ throw validateError;
759
+ }
760
+ }
761
+ const key = path.fullPath;
762
+ const ttlToUse = TTL;
763
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "HarmonizeBilling", VERSION, RepresentationType, equals);
764
+ return createLink(key);
765
+ };
766
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
767
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
768
+ const rootKey = fullPathFactory();
769
+ rootKeySet.set(rootKey, {
770
+ namespace: keyPrefix,
771
+ representationName: RepresentationType,
772
+ mergeable: false
773
+ });
774
+ }
775
+
776
+ function select(luvio, params) {
777
+ return select$1();
778
+ }
779
+ function keyBuilder$1(luvio, params) {
780
+ return keyPrefix + '::RevenueAsyncRepresentation:(' + (params.body.correlationId === undefined ? 'correlationId' : 'correlationId:' + params.body.correlationId) + '::' + 'invoiceIds:' + params.body.invoiceIds + ')';
781
+ }
782
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
783
+ getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
784
+ }
785
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
786
+ const { body } = response;
787
+ const key = keyBuilder$1(luvio, resourceParams);
788
+ luvio.storeIngest(key, ingest, body);
789
+ const snapshot = luvio.storeLookup({
790
+ recordId: key,
791
+ node: select(),
792
+ variables: {},
793
+ }, snapshotRefresh);
794
+ if (process.env.NODE_ENV !== 'production') {
795
+ if (snapshot.state !== 'Fulfilled') {
796
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
797
+ }
798
+ }
799
+ deepFreeze(snapshot.data);
800
+ return snapshot;
801
+ }
802
+ function ingestError(luvio, params, error, snapshotRefresh) {
803
+ const key = keyBuilder$1(luvio, params);
804
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
805
+ const storeMetadataParams = {
806
+ ttl: TTL,
807
+ namespace: keyPrefix,
808
+ version: VERSION,
809
+ representationName: RepresentationType
810
+ };
811
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
812
+ return errorSnapshot;
813
+ }
814
+ function createResourceRequest(config) {
815
+ const headers = {};
816
+ return {
817
+ baseUri: '/services/data/v66.0',
818
+ basePath: '/commerce/invoicing/invoices/collection/actions/post',
819
+ method: 'post',
820
+ body: config.body,
821
+ urlParams: {},
822
+ queryParams: {},
823
+ headers,
824
+ priority: 'normal',
825
+ };
826
+ }
827
+
828
+ const adapterName = 'postDraftInvoices';
829
+ const postDraftInvoices_ConfigPropertyMetadata = [
830
+ generateParamConfigMetadata('correlationId', false, 2 /* Body */, 0 /* String */),
831
+ generateParamConfigMetadata('invoiceIds', true, 2 /* Body */, 0 /* String */, true),
832
+ ];
833
+ const postDraftInvoices_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, postDraftInvoices_ConfigPropertyMetadata);
834
+ const createResourceParams = /*#__PURE__*/ createResourceParams$3(postDraftInvoices_ConfigPropertyMetadata);
835
+ function keyBuilder(luvio, config) {
836
+ const resourceParams = createResourceParams(config);
837
+ return keyBuilder$1(luvio, resourceParams);
838
+ }
839
+ function typeCheckConfig(untrustedConfig) {
840
+ const config = {};
841
+ typeCheckConfig$3(untrustedConfig, config, postDraftInvoices_ConfigPropertyMetadata);
842
+ return config;
843
+ }
844
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
845
+ if (!untrustedIsObject(untrustedConfig)) {
846
+ return null;
847
+ }
848
+ if (process.env.NODE_ENV !== 'production') {
849
+ validateConfig(untrustedConfig, configPropertyNames);
850
+ }
851
+ const config = typeCheckConfig(untrustedConfig);
852
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
853
+ return null;
854
+ }
855
+ return config;
856
+ }
857
+ function adapterFragment(luvio, config) {
858
+ createResourceParams(config);
859
+ return select();
860
+ }
861
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
862
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
863
+ config,
864
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
865
+ });
866
+ return luvio.storeBroadcast().then(() => snapshot);
867
+ }
868
+ function onFetchResponseError(luvio, config, resourceParams, response) {
869
+ const snapshot = ingestError(luvio, resourceParams, response, {
870
+ config,
871
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
872
+ });
873
+ return luvio.storeBroadcast().then(() => snapshot);
874
+ }
875
+ function buildNetworkSnapshot(luvio, config, options) {
876
+ const resourceParams = createResourceParams(config);
877
+ const request = createResourceRequest(resourceParams);
878
+ return luvio.dispatchResourceRequest(request, options)
879
+ .then((response) => {
880
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
881
+ const cache = new StoreKeyMap();
882
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
883
+ return cache;
884
+ });
885
+ }, (response) => {
886
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
887
+ });
888
+ }
889
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
890
+ return buildNetworkSnapshotCachePolicy$3(context, coercedAdapterRequestContext, buildNetworkSnapshot, 'get', false);
891
+ }
892
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
893
+ const { luvio, config } = context;
894
+ const selector = {
895
+ recordId: keyBuilder(luvio, config),
896
+ node: adapterFragment(luvio, config),
897
+ variables: {},
898
+ };
899
+ const cacheSnapshot = storeLookup(selector, {
900
+ config,
901
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
902
+ });
903
+ return cacheSnapshot;
904
+ }
905
+ const postDraftInvoicesAdapterFactory = (luvio) => function HarmonizeBilling__postDraftInvoices(untrustedConfig, requestContext) {
906
+ const config = validateAdapterConfig(untrustedConfig, postDraftInvoices_ConfigPropertyNames);
907
+ // Invalid or incomplete config
908
+ if (config === null) {
909
+ return null;
910
+ }
911
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
912
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
913
+ };
914
+
915
+ export { postDraftInvoicesAdapterFactory, resumeBillingAdapterFactory, suspendBillingAdapterFactory };