@salesforce/lds-adapters-industries-field-service 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 (30) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/industries-field-service.js +1287 -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/bookAppointmentSlot.d.ts +16 -0
  5. package/dist/es/es2018/types/src/generated/adapters/createProductServiceCampaign.d.ts +15 -0
  6. package/dist/es/es2018/types/src/generated/adapters/createWorkOrders.d.ts +16 -0
  7. package/dist/es/es2018/types/src/generated/adapters/getAppointmentSlots.d.ts +29 -0
  8. package/dist/es/es2018/types/src/generated/adapters/priceItemWithCoverage.d.ts +21 -0
  9. package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +6 -0
  10. package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +10 -0
  11. package/dist/es/es2018/types/src/generated/resources/getConnectIndustriesFieldServiceAppointmentSchedulingSlotsByServiceAppointmentIdAndSchedulingPolicyId.d.ts +17 -0
  12. package/dist/es/es2018/types/src/generated/resources/postConnectIndustriesFieldServiceProductServiceCampaignItemsFromList.d.ts +12 -0
  13. package/dist/es/es2018/types/src/generated/resources/postConnectIndustriesFieldServiceProductServiceCampaignWorkOrder.d.ts +13 -0
  14. package/dist/es/es2018/types/src/generated/resources/putConnectIndustriesFieldServiceAppointmentSchedulingSlotsByServiceAppointmentIdAndSchedulingPolicyId.d.ts +13 -0
  15. package/dist/es/es2018/types/src/generated/resources/putConnectIndustriesFieldServiceWorkOrderEstimationPriceItem.d.ts +18 -0
  16. package/dist/es/es2018/types/src/generated/types/AppointmentSchedulingRepresentation.d.ts +55 -0
  17. package/dist/es/es2018/types/src/generated/types/AppointmentSlotRepresentation.d.ts +34 -0
  18. package/dist/es/es2018/types/src/generated/types/AssetCoverageInputRepresentation.d.ts +34 -0
  19. package/dist/es/es2018/types/src/generated/types/PriceItemWithCoverageInputRepresentation.d.ts +42 -0
  20. package/dist/es/es2018/types/src/generated/types/PriceItemWithCoverageRepresentation.d.ts +47 -0
  21. package/dist/es/es2018/types/src/generated/types/ProductServiceCampaignItemsFromListInputRepresentation.d.ts +38 -0
  22. package/dist/es/es2018/types/src/generated/types/ProductServiceCampaignItemsFromListRepresentation.d.ts +44 -0
  23. package/dist/es/es2018/types/src/generated/types/WorkOrderForProductServiceCampaignItemInputRepresentation.d.ts +32 -0
  24. package/dist/es/es2018/types/src/generated/types/WorkOrderForProductServiceCampaignItemRepresentation.d.ts +44 -0
  25. package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
  26. package/package.json +67 -0
  27. package/sfdc/index.d.ts +1 -0
  28. package/sfdc/index.js +1387 -0
  29. package/src/raml/api.raml +251 -0
  30. package/src/raml/luvio.raml +60 -0
package/sfdc/index.js ADDED
@@ -0,0 +1,1387 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /*
8
+ * ATTENTION!
9
+ * THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
10
+ * If you would like to contribute to LDS, please follow the steps outlined in the git repo.
11
+ * Any changes made to this file in p4 will be automatically overwritten.
12
+ * *******************************************************************************************
13
+ */
14
+ /* proxy-compat-disable */
15
+ import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
16
+ import { withDefaultLuvio } from 'force/ldsEngine';
17
+ import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$5, typeCheckConfig as typeCheckConfig$5, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1 } from 'force/luvioEngine';
18
+
19
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
20
+ const { keys: ObjectKeys$1, create: ObjectCreate$1 } = Object;
21
+ const { isArray: ArrayIsArray$1 } = Array;
22
+ /**
23
+ * Validates an adapter config is well-formed.
24
+ * @param config The config to validate.
25
+ * @param adapter The adapter validation configuration.
26
+ * @param oneOf The keys the config must contain at least one of.
27
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
28
+ */
29
+ function validateConfig(config, adapter, oneOf) {
30
+ const { displayName } = adapter;
31
+ const { required, optional, unsupported } = adapter.parameters;
32
+ if (config === undefined ||
33
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
34
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
35
+ }
36
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
37
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
38
+ }
39
+ if (unsupported !== undefined &&
40
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
41
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
42
+ }
43
+ const supported = required.concat(optional);
44
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
45
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
46
+ }
47
+ }
48
+ function untrustedIsObject(untrusted) {
49
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
50
+ }
51
+ function areRequiredParametersPresent(config, configPropertyNames) {
52
+ return configPropertyNames.parameters.required.every(req => req in config);
53
+ }
54
+ const snapshotRefreshOptions = {
55
+ overrides: {
56
+ headers: {
57
+ 'Cache-Control': 'no-cache',
58
+ },
59
+ }
60
+ };
61
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
62
+ return {
63
+ name,
64
+ required,
65
+ resourceType,
66
+ typeCheckShape,
67
+ isArrayShape,
68
+ coerceFn,
69
+ };
70
+ }
71
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
72
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
73
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
74
+ return {
75
+ displayName,
76
+ parameters: {
77
+ required,
78
+ optional,
79
+ }
80
+ };
81
+ }
82
+ const keyPrefix = 'field-service';
83
+
84
+ const { keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
85
+ const { isArray: ArrayIsArray } = Array;
86
+ const { stringify: JSONStringify } = JSON;
87
+ function equalsArray(a, b, equalsItem) {
88
+ const aLength = a.length;
89
+ const bLength = b.length;
90
+ if (aLength !== bLength) {
91
+ return false;
92
+ }
93
+ for (let i = 0; i < aLength; i++) {
94
+ if (equalsItem(a[i], b[i]) === false) {
95
+ return false;
96
+ }
97
+ }
98
+ return true;
99
+ }
100
+ function createLink(ref) {
101
+ return {
102
+ __ref: serializeStructuredKey(ref),
103
+ };
104
+ }
105
+
106
+ const VERSION$4 = "2f0233a95128b9599e2fdc4792332572";
107
+ function validate$5(obj, path = 'AppointmentSlotRepresentation') {
108
+ const v_error = (() => {
109
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
110
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
111
+ }
112
+ const obj_finishInterval = obj.finishInterval;
113
+ const path_finishInterval = path + '.finishInterval';
114
+ if (typeof obj_finishInterval !== 'string') {
115
+ return new TypeError('Expected "string" but received "' + typeof obj_finishInterval + '" (at "' + path_finishInterval + '")');
116
+ }
117
+ obj.grade;
118
+ const obj_startInterval = obj.startInterval;
119
+ const path_startInterval = path + '.startInterval';
120
+ if (typeof obj_startInterval !== 'string') {
121
+ return new TypeError('Expected "string" but received "' + typeof obj_startInterval + '" (at "' + path_startInterval + '")');
122
+ }
123
+ })();
124
+ return v_error === undefined ? null : v_error;
125
+ }
126
+ const select$9 = function AppointmentSlotRepresentationSelect() {
127
+ return {
128
+ kind: 'Fragment',
129
+ version: VERSION$4,
130
+ private: [],
131
+ selections: [
132
+ {
133
+ name: 'finishInterval',
134
+ kind: 'Scalar'
135
+ },
136
+ {
137
+ name: 'grade',
138
+ kind: 'Scalar'
139
+ },
140
+ {
141
+ name: 'startInterval',
142
+ kind: 'Scalar'
143
+ }
144
+ ]
145
+ };
146
+ };
147
+ function equals$4(existing, incoming) {
148
+ const existing_finishInterval = existing.finishInterval;
149
+ const incoming_finishInterval = incoming.finishInterval;
150
+ if (!(existing_finishInterval === incoming_finishInterval)) {
151
+ return false;
152
+ }
153
+ const existing_startInterval = existing.startInterval;
154
+ const incoming_startInterval = incoming.startInterval;
155
+ if (!(existing_startInterval === incoming_startInterval)) {
156
+ return false;
157
+ }
158
+ const existing_grade = existing.grade;
159
+ const incoming_grade = incoming.grade;
160
+ if (!(existing_grade === incoming_grade)) {
161
+ return false;
162
+ }
163
+ return true;
164
+ }
165
+
166
+ const TTL$3 = 1000;
167
+ const VERSION$3 = "adf3d4fd725138657e26bece6c0bc136";
168
+ function validate$4(obj, path = 'AppointmentSchedulingRepresentation') {
169
+ const v_error = (() => {
170
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
171
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
172
+ }
173
+ const obj_appointmentSlots = obj.appointmentSlots;
174
+ const path_appointmentSlots = path + '.appointmentSlots';
175
+ if (!ArrayIsArray(obj_appointmentSlots)) {
176
+ return new TypeError('Expected "array" but received "' + typeof obj_appointmentSlots + '" (at "' + path_appointmentSlots + '")');
177
+ }
178
+ for (let i = 0; i < obj_appointmentSlots.length; i++) {
179
+ const obj_appointmentSlots_item = obj_appointmentSlots[i];
180
+ const path_appointmentSlots_item = path_appointmentSlots + '[' + i + ']';
181
+ const referencepath_appointmentSlots_itemValidationError = validate$5(obj_appointmentSlots_item, path_appointmentSlots_item);
182
+ if (referencepath_appointmentSlots_itemValidationError !== null) {
183
+ let message = 'Object doesn\'t match AppointmentSlotRepresentation (at "' + path_appointmentSlots_item + '")\n';
184
+ message += referencepath_appointmentSlots_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
185
+ return new TypeError(message);
186
+ }
187
+ }
188
+ const obj_errorCode = obj.errorCode;
189
+ const path_errorCode = path + '.errorCode';
190
+ if (typeof obj_errorCode !== 'string') {
191
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
192
+ }
193
+ const obj_errorMessage = obj.errorMessage;
194
+ const path_errorMessage = path + '.errorMessage';
195
+ if (typeof obj_errorMessage !== 'string') {
196
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
197
+ }
198
+ const obj_isSuccess = obj.isSuccess;
199
+ const path_isSuccess = path + '.isSuccess';
200
+ if (typeof obj_isSuccess !== 'boolean') {
201
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
202
+ }
203
+ const obj_resourceId = obj.resourceId;
204
+ const path_resourceId = path + '.resourceId';
205
+ if (typeof obj_resourceId !== 'string') {
206
+ return new TypeError('Expected "string" but received "' + typeof obj_resourceId + '" (at "' + path_resourceId + '")');
207
+ }
208
+ const obj_serviceAppointmentId = obj.serviceAppointmentId;
209
+ const path_serviceAppointmentId = path + '.serviceAppointmentId';
210
+ if (typeof obj_serviceAppointmentId !== 'string') {
211
+ return new TypeError('Expected "string" but received "' + typeof obj_serviceAppointmentId + '" (at "' + path_serviceAppointmentId + '")');
212
+ }
213
+ })();
214
+ return v_error === undefined ? null : v_error;
215
+ }
216
+ const RepresentationType$3 = 'AppointmentSchedulingRepresentation';
217
+ function keyBuilder$5(luvio, config) {
218
+ return keyPrefix + '::' + RepresentationType$3 + ':' + config.id;
219
+ }
220
+ function keyBuilderFromType$3(luvio, object) {
221
+ const keyParams = {
222
+ id: object.serviceAppointmentId
223
+ };
224
+ return keyBuilder$5(luvio, keyParams);
225
+ }
226
+ function normalize$3(input, existing, path, luvio, store, timestamp) {
227
+ return input;
228
+ }
229
+ const select$8 = function AppointmentSchedulingRepresentationSelect() {
230
+ const { selections: AppointmentSlotRepresentation__selections, opaque: AppointmentSlotRepresentation__opaque, } = select$9();
231
+ return {
232
+ kind: 'Fragment',
233
+ version: VERSION$3,
234
+ private: [],
235
+ selections: [
236
+ {
237
+ name: 'appointmentSlots',
238
+ kind: 'Object',
239
+ plural: true,
240
+ selections: AppointmentSlotRepresentation__selections
241
+ },
242
+ {
243
+ name: 'errorCode',
244
+ kind: 'Scalar'
245
+ },
246
+ {
247
+ name: 'errorMessage',
248
+ kind: 'Scalar'
249
+ },
250
+ {
251
+ name: 'isSuccess',
252
+ kind: 'Scalar'
253
+ },
254
+ {
255
+ name: 'resourceId',
256
+ kind: 'Scalar'
257
+ },
258
+ {
259
+ name: 'serviceAppointmentId',
260
+ kind: 'Scalar'
261
+ }
262
+ ]
263
+ };
264
+ };
265
+ function equals$3(existing, incoming) {
266
+ const existing_isSuccess = existing.isSuccess;
267
+ const incoming_isSuccess = incoming.isSuccess;
268
+ if (!(existing_isSuccess === incoming_isSuccess)) {
269
+ return false;
270
+ }
271
+ const existing_errorCode = existing.errorCode;
272
+ const incoming_errorCode = incoming.errorCode;
273
+ if (!(existing_errorCode === incoming_errorCode)) {
274
+ return false;
275
+ }
276
+ const existing_errorMessage = existing.errorMessage;
277
+ const incoming_errorMessage = incoming.errorMessage;
278
+ if (!(existing_errorMessage === incoming_errorMessage)) {
279
+ return false;
280
+ }
281
+ const existing_resourceId = existing.resourceId;
282
+ const incoming_resourceId = incoming.resourceId;
283
+ if (!(existing_resourceId === incoming_resourceId)) {
284
+ return false;
285
+ }
286
+ const existing_serviceAppointmentId = existing.serviceAppointmentId;
287
+ const incoming_serviceAppointmentId = incoming.serviceAppointmentId;
288
+ if (!(existing_serviceAppointmentId === incoming_serviceAppointmentId)) {
289
+ return false;
290
+ }
291
+ const existing_appointmentSlots = existing.appointmentSlots;
292
+ const incoming_appointmentSlots = incoming.appointmentSlots;
293
+ const equals_appointmentSlots_items = equalsArray(existing_appointmentSlots, incoming_appointmentSlots, (existing_appointmentSlots_item, incoming_appointmentSlots_item) => {
294
+ if (!(equals$4(existing_appointmentSlots_item, incoming_appointmentSlots_item))) {
295
+ return false;
296
+ }
297
+ });
298
+ if (equals_appointmentSlots_items === false) {
299
+ return false;
300
+ }
301
+ return true;
302
+ }
303
+ const ingest$3 = function AppointmentSchedulingRepresentationIngest(input, path, luvio, store, timestamp) {
304
+ if (process.env.NODE_ENV !== 'production') {
305
+ const validateError = validate$4(input);
306
+ if (validateError !== null) {
307
+ throw validateError;
308
+ }
309
+ }
310
+ const key = keyBuilderFromType$3(luvio, input);
311
+ const ttlToUse = TTL$3;
312
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$3, "field-service", VERSION$3, RepresentationType$3, equals$3);
313
+ return createLink(key);
314
+ };
315
+ function getTypeCacheKeys$3(rootKeySet, luvio, input, fullPathFactory) {
316
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
317
+ const rootKey = keyBuilderFromType$3(luvio, input);
318
+ rootKeySet.set(rootKey, {
319
+ namespace: keyPrefix,
320
+ representationName: RepresentationType$3,
321
+ mergeable: false
322
+ });
323
+ }
324
+ const notifyUpdateAvailableFactory = (luvio) => {
325
+ return function notifyAppointmentSchedulingUpdateAvailable(configs) {
326
+ if (process.env.NODE_ENV !== 'production') {
327
+ const requiredKeyParams = ['id'];
328
+ configs.forEach(config => {
329
+ if (false === requiredKeyParams.every(req => req in config)) {
330
+ throw new Error(`one of the configs did not contain all required parameters: ${JSONStringify(ObjectKeys(config))}`);
331
+ }
332
+ });
333
+ }
334
+ const keys = configs.map(c => keyBuilder$5(luvio, c));
335
+ return luvio.notifyStoreUpdateAvailable(keys);
336
+ };
337
+ };
338
+
339
+ function select$7(luvio, params) {
340
+ return select$8();
341
+ }
342
+ function getResponseCacheKeys$4(storeKeyMap, luvio, resourceParams, response) {
343
+ getTypeCacheKeys$3(storeKeyMap, luvio, response);
344
+ }
345
+ function ingestSuccess$4(luvio, resourceParams, response) {
346
+ const { body } = response;
347
+ const key = keyBuilderFromType$3(luvio, body);
348
+ luvio.storeIngest(key, ingest$3, body);
349
+ const snapshot = luvio.storeLookup({
350
+ recordId: key,
351
+ node: select$7(),
352
+ variables: {},
353
+ });
354
+ if (process.env.NODE_ENV !== 'production') {
355
+ if (snapshot.state !== 'Fulfilled') {
356
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
357
+ }
358
+ }
359
+ deepFreeze(snapshot.data);
360
+ return snapshot;
361
+ }
362
+ function createResourceRequest$4(config) {
363
+ const headers = {};
364
+ return {
365
+ baseUri: '/services/data/v66.0',
366
+ basePath: '/connect/industries-field-service/appointment-scheduling/slots/' + config.urlParams.serviceAppointmentId + '/' + config.urlParams.schedulingPolicyId + '',
367
+ method: 'put',
368
+ body: null,
369
+ urlParams: config.urlParams,
370
+ queryParams: {},
371
+ headers,
372
+ priority: 'normal',
373
+ };
374
+ }
375
+
376
+ const adapterName$4 = 'bookAppointmentSlot';
377
+ const bookAppointmentSlot_ConfigPropertyMetadata = [
378
+ generateParamConfigMetadata('serviceAppointmentId', true, 0 /* UrlParameter */, 0 /* String */),
379
+ generateParamConfigMetadata('schedulingPolicyId', true, 0 /* UrlParameter */, 0 /* String */),
380
+ ];
381
+ const bookAppointmentSlot_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$4, bookAppointmentSlot_ConfigPropertyMetadata);
382
+ const createResourceParams$4 = /*#__PURE__*/ createResourceParams$5(bookAppointmentSlot_ConfigPropertyMetadata);
383
+ function typeCheckConfig$4(untrustedConfig) {
384
+ const config = {};
385
+ typeCheckConfig$5(untrustedConfig, config, bookAppointmentSlot_ConfigPropertyMetadata);
386
+ return config;
387
+ }
388
+ function validateAdapterConfig$4(untrustedConfig, configPropertyNames) {
389
+ if (!untrustedIsObject(untrustedConfig)) {
390
+ return null;
391
+ }
392
+ if (process.env.NODE_ENV !== 'production') {
393
+ validateConfig(untrustedConfig, configPropertyNames);
394
+ }
395
+ const config = typeCheckConfig$4(untrustedConfig);
396
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
397
+ return null;
398
+ }
399
+ return config;
400
+ }
401
+ function buildNetworkSnapshot$4(luvio, config, options) {
402
+ const resourceParams = createResourceParams$4(config);
403
+ const request = createResourceRequest$4(resourceParams);
404
+ return luvio.dispatchResourceRequest(request, options)
405
+ .then((response) => {
406
+ return luvio.handleSuccessResponse(() => {
407
+ const snapshot = ingestSuccess$4(luvio, resourceParams, response);
408
+ return luvio.storeBroadcast().then(() => snapshot);
409
+ }, () => {
410
+ const cache = new StoreKeyMap();
411
+ getResponseCacheKeys$4(cache, luvio, resourceParams, response.body);
412
+ return cache;
413
+ });
414
+ }, (response) => {
415
+ deepFreeze(response);
416
+ throw response;
417
+ });
418
+ }
419
+ const bookAppointmentSlotAdapterFactory = (luvio) => {
420
+ return function bookAppointmentSlot(untrustedConfig) {
421
+ const config = validateAdapterConfig$4(untrustedConfig, bookAppointmentSlot_ConfigPropertyNames);
422
+ // Invalid or incomplete config
423
+ if (config === null) {
424
+ throw new Error('Invalid config for "bookAppointmentSlot"');
425
+ }
426
+ return buildNetworkSnapshot$4(luvio, config);
427
+ };
428
+ };
429
+
430
+ const TTL$2 = 300;
431
+ const VERSION$2 = "5c4aa8faf25b64f7b7f98f8739c11b45";
432
+ function validate$3(obj, path = 'ProductServiceCampaignItemsFromListRepresentation') {
433
+ const v_error = (() => {
434
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
435
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
436
+ }
437
+ const obj_errorCode = obj.errorCode;
438
+ const path_errorCode = path + '.errorCode';
439
+ let obj_errorCode_union0 = null;
440
+ const obj_errorCode_union0_error = (() => {
441
+ if (typeof obj_errorCode !== 'string') {
442
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
443
+ }
444
+ })();
445
+ if (obj_errorCode_union0_error != null) {
446
+ obj_errorCode_union0 = obj_errorCode_union0_error.message;
447
+ }
448
+ let obj_errorCode_union1 = null;
449
+ const obj_errorCode_union1_error = (() => {
450
+ if (obj_errorCode !== null) {
451
+ return new TypeError('Expected "null" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
452
+ }
453
+ })();
454
+ if (obj_errorCode_union1_error != null) {
455
+ obj_errorCode_union1 = obj_errorCode_union1_error.message;
456
+ }
457
+ if (obj_errorCode_union0 && obj_errorCode_union1) {
458
+ let message = 'Object doesn\'t match union (at "' + path_errorCode + '")';
459
+ message += '\n' + obj_errorCode_union0.split('\n').map((line) => '\t' + line).join('\n');
460
+ message += '\n' + obj_errorCode_union1.split('\n').map((line) => '\t' + line).join('\n');
461
+ return new TypeError(message);
462
+ }
463
+ const obj_errorMessage = obj.errorMessage;
464
+ const path_errorMessage = path + '.errorMessage';
465
+ let obj_errorMessage_union0 = null;
466
+ const obj_errorMessage_union0_error = (() => {
467
+ if (typeof obj_errorMessage !== 'string') {
468
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
469
+ }
470
+ })();
471
+ if (obj_errorMessage_union0_error != null) {
472
+ obj_errorMessage_union0 = obj_errorMessage_union0_error.message;
473
+ }
474
+ let obj_errorMessage_union1 = null;
475
+ const obj_errorMessage_union1_error = (() => {
476
+ if (obj_errorMessage !== null) {
477
+ return new TypeError('Expected "null" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
478
+ }
479
+ })();
480
+ if (obj_errorMessage_union1_error != null) {
481
+ obj_errorMessage_union1 = obj_errorMessage_union1_error.message;
482
+ }
483
+ if (obj_errorMessage_union0 && obj_errorMessage_union1) {
484
+ let message = 'Object doesn\'t match union (at "' + path_errorMessage + '")';
485
+ message += '\n' + obj_errorMessage_union0.split('\n').map((line) => '\t' + line).join('\n');
486
+ message += '\n' + obj_errorMessage_union1.split('\n').map((line) => '\t' + line).join('\n');
487
+ return new TypeError(message);
488
+ }
489
+ const obj_isSuccess = obj.isSuccess;
490
+ const path_isSuccess = path + '.isSuccess';
491
+ if (typeof obj_isSuccess !== 'boolean') {
492
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
493
+ }
494
+ })();
495
+ return v_error === undefined ? null : v_error;
496
+ }
497
+ const RepresentationType$2 = 'ProductServiceCampaignItemsFromListRepresentation';
498
+ function keyBuilder$4(luvio, config) {
499
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.isSuccess;
500
+ }
501
+ function keyBuilderFromType$2(luvio, object) {
502
+ const keyParams = {
503
+ isSuccess: object.isSuccess
504
+ };
505
+ return keyBuilder$4(luvio, keyParams);
506
+ }
507
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
508
+ return input;
509
+ }
510
+ const select$6 = function ProductServiceCampaignItemsFromListRepresentationSelect() {
511
+ return {
512
+ kind: 'Fragment',
513
+ version: VERSION$2,
514
+ private: [],
515
+ selections: [
516
+ {
517
+ name: 'errorCode',
518
+ kind: 'Scalar'
519
+ },
520
+ {
521
+ name: 'errorMessage',
522
+ kind: 'Scalar'
523
+ },
524
+ {
525
+ name: 'isSuccess',
526
+ kind: 'Scalar'
527
+ }
528
+ ]
529
+ };
530
+ };
531
+ function equals$2(existing, incoming) {
532
+ const existing_isSuccess = existing.isSuccess;
533
+ const incoming_isSuccess = incoming.isSuccess;
534
+ if (!(existing_isSuccess === incoming_isSuccess)) {
535
+ return false;
536
+ }
537
+ const existing_errorCode = existing.errorCode;
538
+ const incoming_errorCode = incoming.errorCode;
539
+ if (!(existing_errorCode === incoming_errorCode)) {
540
+ return false;
541
+ }
542
+ const existing_errorMessage = existing.errorMessage;
543
+ const incoming_errorMessage = incoming.errorMessage;
544
+ if (!(existing_errorMessage === incoming_errorMessage)) {
545
+ return false;
546
+ }
547
+ return true;
548
+ }
549
+ const ingest$2 = function ProductServiceCampaignItemsFromListRepresentationIngest(input, path, luvio, store, timestamp) {
550
+ if (process.env.NODE_ENV !== 'production') {
551
+ const validateError = validate$3(input);
552
+ if (validateError !== null) {
553
+ throw validateError;
554
+ }
555
+ }
556
+ const key = keyBuilderFromType$2(luvio, input);
557
+ const ttlToUse = TTL$2;
558
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "field-service", VERSION$2, RepresentationType$2, equals$2);
559
+ return createLink(key);
560
+ };
561
+ function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
562
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
563
+ const rootKey = keyBuilderFromType$2(luvio, input);
564
+ rootKeySet.set(rootKey, {
565
+ namespace: keyPrefix,
566
+ representationName: RepresentationType$2,
567
+ mergeable: false
568
+ });
569
+ }
570
+
571
+ function select$5(luvio, params) {
572
+ return select$6();
573
+ }
574
+ function getResponseCacheKeys$3(storeKeyMap, luvio, resourceParams, response) {
575
+ getTypeCacheKeys$2(storeKeyMap, luvio, response);
576
+ }
577
+ function ingestSuccess$3(luvio, resourceParams, response) {
578
+ const { body } = response;
579
+ const key = keyBuilderFromType$2(luvio, body);
580
+ luvio.storeIngest(key, ingest$2, body);
581
+ const snapshot = luvio.storeLookup({
582
+ recordId: key,
583
+ node: select$5(),
584
+ variables: {},
585
+ });
586
+ if (process.env.NODE_ENV !== 'production') {
587
+ if (snapshot.state !== 'Fulfilled') {
588
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
589
+ }
590
+ }
591
+ deepFreeze(snapshot.data);
592
+ return snapshot;
593
+ }
594
+ function createResourceRequest$3(config) {
595
+ const headers = {};
596
+ return {
597
+ baseUri: '/services/data/v66.0',
598
+ basePath: '/connect/industries-field-service/product-service-campaign/items-from-list',
599
+ method: 'post',
600
+ body: config.body,
601
+ urlParams: {},
602
+ queryParams: {},
603
+ headers,
604
+ priority: 'normal',
605
+ };
606
+ }
607
+
608
+ const adapterName$3 = 'createProductServiceCampaign';
609
+ const createProductServiceCampaign_ConfigPropertyMetadata = [
610
+ generateParamConfigMetadata('actionableListId', true, 2 /* Body */, 0 /* String */),
611
+ ];
612
+ const createProductServiceCampaign_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$3, createProductServiceCampaign_ConfigPropertyMetadata);
613
+ const createResourceParams$3 = /*#__PURE__*/ createResourceParams$5(createProductServiceCampaign_ConfigPropertyMetadata);
614
+ function typeCheckConfig$3(untrustedConfig) {
615
+ const config = {};
616
+ typeCheckConfig$5(untrustedConfig, config, createProductServiceCampaign_ConfigPropertyMetadata);
617
+ return config;
618
+ }
619
+ function validateAdapterConfig$3(untrustedConfig, configPropertyNames) {
620
+ if (!untrustedIsObject(untrustedConfig)) {
621
+ return null;
622
+ }
623
+ if (process.env.NODE_ENV !== 'production') {
624
+ validateConfig(untrustedConfig, configPropertyNames);
625
+ }
626
+ const config = typeCheckConfig$3(untrustedConfig);
627
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
628
+ return null;
629
+ }
630
+ return config;
631
+ }
632
+ function buildNetworkSnapshot$3(luvio, config, options) {
633
+ const resourceParams = createResourceParams$3(config);
634
+ const request = createResourceRequest$3(resourceParams);
635
+ return luvio.dispatchResourceRequest(request, options)
636
+ .then((response) => {
637
+ return luvio.handleSuccessResponse(() => {
638
+ const snapshot = ingestSuccess$3(luvio, resourceParams, response);
639
+ return luvio.storeBroadcast().then(() => snapshot);
640
+ }, () => {
641
+ const cache = new StoreKeyMap();
642
+ getResponseCacheKeys$3(cache, luvio, resourceParams, response.body);
643
+ return cache;
644
+ });
645
+ }, (response) => {
646
+ deepFreeze(response);
647
+ throw response;
648
+ });
649
+ }
650
+ const createProductServiceCampaignAdapterFactory = (luvio) => {
651
+ return function createProductServiceCampaign(untrustedConfig) {
652
+ const config = validateAdapterConfig$3(untrustedConfig, createProductServiceCampaign_ConfigPropertyNames);
653
+ // Invalid or incomplete config
654
+ if (config === null) {
655
+ throw new Error('Invalid config for "createProductServiceCampaign"');
656
+ }
657
+ return buildNetworkSnapshot$3(luvio, config);
658
+ };
659
+ };
660
+
661
+ const TTL$1 = 300;
662
+ const VERSION$1 = "d796fd2d8002953326366aa94516c4b3";
663
+ function validate$2(obj, path = 'WorkOrderForProductServiceCampaignItemRepresentation') {
664
+ const v_error = (() => {
665
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
666
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
667
+ }
668
+ if (obj.errorCode !== undefined) {
669
+ const obj_errorCode = obj.errorCode;
670
+ const path_errorCode = path + '.errorCode';
671
+ if (typeof obj_errorCode !== 'string') {
672
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
673
+ }
674
+ }
675
+ if (obj.errorMessage !== undefined) {
676
+ const obj_errorMessage = obj.errorMessage;
677
+ const path_errorMessage = path + '.errorMessage';
678
+ if (typeof obj_errorMessage !== 'string') {
679
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
680
+ }
681
+ }
682
+ const obj_isSuccess = obj.isSuccess;
683
+ const path_isSuccess = path + '.isSuccess';
684
+ if (typeof obj_isSuccess !== 'boolean') {
685
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
686
+ }
687
+ })();
688
+ return v_error === undefined ? null : v_error;
689
+ }
690
+ const RepresentationType$1 = 'WorkOrderForProductServiceCampaignItemRepresentation';
691
+ function keyBuilder$3(luvio, config) {
692
+ return keyPrefix + '::' + RepresentationType$1 + ':' + config.id;
693
+ }
694
+ function keyBuilderFromType$1(luvio, object) {
695
+ const keyParams = {
696
+ id: object.isSuccess
697
+ };
698
+ return keyBuilder$3(luvio, keyParams);
699
+ }
700
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
701
+ return input;
702
+ }
703
+ const select$4 = function WorkOrderForProductServiceCampaignItemRepresentationSelect() {
704
+ return {
705
+ kind: 'Fragment',
706
+ version: VERSION$1,
707
+ private: [],
708
+ selections: [
709
+ {
710
+ name: 'errorCode',
711
+ kind: 'Scalar',
712
+ required: false
713
+ },
714
+ {
715
+ name: 'errorMessage',
716
+ kind: 'Scalar',
717
+ required: false
718
+ },
719
+ {
720
+ name: 'isSuccess',
721
+ kind: 'Scalar'
722
+ }
723
+ ]
724
+ };
725
+ };
726
+ function equals$1(existing, incoming) {
727
+ const existing_isSuccess = existing.isSuccess;
728
+ const incoming_isSuccess = incoming.isSuccess;
729
+ if (!(existing_isSuccess === incoming_isSuccess)) {
730
+ return false;
731
+ }
732
+ const existing_errorCode = existing.errorCode;
733
+ const incoming_errorCode = incoming.errorCode;
734
+ // if at least one of these optionals is defined
735
+ if (existing_errorCode !== undefined || incoming_errorCode !== undefined) {
736
+ // if one of these is not defined we know the other is defined and therefore
737
+ // not equal
738
+ if (existing_errorCode === undefined || incoming_errorCode === undefined) {
739
+ return false;
740
+ }
741
+ if (!(existing_errorCode === incoming_errorCode)) {
742
+ return false;
743
+ }
744
+ }
745
+ const existing_errorMessage = existing.errorMessage;
746
+ const incoming_errorMessage = incoming.errorMessage;
747
+ // if at least one of these optionals is defined
748
+ if (existing_errorMessage !== undefined || incoming_errorMessage !== undefined) {
749
+ // if one of these is not defined we know the other is defined and therefore
750
+ // not equal
751
+ if (existing_errorMessage === undefined || incoming_errorMessage === undefined) {
752
+ return false;
753
+ }
754
+ if (!(existing_errorMessage === incoming_errorMessage)) {
755
+ return false;
756
+ }
757
+ }
758
+ return true;
759
+ }
760
+ const ingest$1 = function WorkOrderForProductServiceCampaignItemRepresentationIngest(input, path, luvio, store, timestamp) {
761
+ if (process.env.NODE_ENV !== 'production') {
762
+ const validateError = validate$2(input);
763
+ if (validateError !== null) {
764
+ throw validateError;
765
+ }
766
+ }
767
+ const key = keyBuilderFromType$1(luvio, input);
768
+ const ttlToUse = TTL$1;
769
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "field-service", VERSION$1, RepresentationType$1, equals$1);
770
+ return createLink(key);
771
+ };
772
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
773
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
774
+ const rootKey = keyBuilderFromType$1(luvio, input);
775
+ rootKeySet.set(rootKey, {
776
+ namespace: keyPrefix,
777
+ representationName: RepresentationType$1,
778
+ mergeable: false
779
+ });
780
+ }
781
+
782
+ function select$3(luvio, params) {
783
+ return select$4();
784
+ }
785
+ function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
786
+ getTypeCacheKeys$1(storeKeyMap, luvio, response);
787
+ }
788
+ function ingestSuccess$2(luvio, resourceParams, response) {
789
+ const { body } = response;
790
+ const key = keyBuilderFromType$1(luvio, body);
791
+ luvio.storeIngest(key, ingest$1, body);
792
+ const snapshot = luvio.storeLookup({
793
+ recordId: key,
794
+ node: select$3(),
795
+ variables: {},
796
+ });
797
+ if (process.env.NODE_ENV !== 'production') {
798
+ if (snapshot.state !== 'Fulfilled') {
799
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
800
+ }
801
+ }
802
+ deepFreeze(snapshot.data);
803
+ return snapshot;
804
+ }
805
+ function createResourceRequest$2(config) {
806
+ const headers = {};
807
+ return {
808
+ baseUri: '/services/data/v66.0',
809
+ basePath: '/connect/industries-field-service/product-service-campaign/work-order',
810
+ method: 'post',
811
+ body: config.body,
812
+ urlParams: {},
813
+ queryParams: {},
814
+ headers,
815
+ priority: 'normal',
816
+ };
817
+ }
818
+
819
+ const adapterName$2 = 'createWorkOrders';
820
+ const createWorkOrders_ConfigPropertyMetadata = [
821
+ generateParamConfigMetadata('productServiceCampaignId', false, 2 /* Body */, 0 /* String */),
822
+ generateParamConfigMetadata('productServiceCampaignItemIds', false, 2 /* Body */, 4 /* Unsupported */, true),
823
+ ];
824
+ const createWorkOrders_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, createWorkOrders_ConfigPropertyMetadata);
825
+ const createResourceParams$2 = /*#__PURE__*/ createResourceParams$5(createWorkOrders_ConfigPropertyMetadata);
826
+ function typeCheckConfig$2(untrustedConfig) {
827
+ const config = {};
828
+ typeCheckConfig$5(untrustedConfig, config, createWorkOrders_ConfigPropertyMetadata);
829
+ const untrustedConfig_productServiceCampaignItemIds = untrustedConfig.productServiceCampaignItemIds;
830
+ if (ArrayIsArray$1(untrustedConfig_productServiceCampaignItemIds)) {
831
+ const untrustedConfig_productServiceCampaignItemIds_array = [];
832
+ for (let i = 0, arrayLength = untrustedConfig_productServiceCampaignItemIds.length; i < arrayLength; i++) {
833
+ const untrustedConfig_productServiceCampaignItemIds_item = untrustedConfig_productServiceCampaignItemIds[i];
834
+ if (typeof untrustedConfig_productServiceCampaignItemIds_item === 'string') {
835
+ untrustedConfig_productServiceCampaignItemIds_array.push(untrustedConfig_productServiceCampaignItemIds_item);
836
+ }
837
+ if (untrustedConfig_productServiceCampaignItemIds_item === null) {
838
+ untrustedConfig_productServiceCampaignItemIds_array.push(untrustedConfig_productServiceCampaignItemIds_item);
839
+ }
840
+ }
841
+ config.productServiceCampaignItemIds = untrustedConfig_productServiceCampaignItemIds_array;
842
+ }
843
+ return config;
844
+ }
845
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
846
+ if (!untrustedIsObject(untrustedConfig)) {
847
+ return null;
848
+ }
849
+ if (process.env.NODE_ENV !== 'production') {
850
+ validateConfig(untrustedConfig, configPropertyNames);
851
+ }
852
+ const config = typeCheckConfig$2(untrustedConfig);
853
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
854
+ return null;
855
+ }
856
+ return config;
857
+ }
858
+ function buildNetworkSnapshot$2(luvio, config, options) {
859
+ const resourceParams = createResourceParams$2(config);
860
+ const request = createResourceRequest$2(resourceParams);
861
+ return luvio.dispatchResourceRequest(request, options)
862
+ .then((response) => {
863
+ return luvio.handleSuccessResponse(() => {
864
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
865
+ return luvio.storeBroadcast().then(() => snapshot);
866
+ }, () => {
867
+ const cache = new StoreKeyMap();
868
+ getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
869
+ return cache;
870
+ });
871
+ }, (response) => {
872
+ deepFreeze(response);
873
+ throw response;
874
+ });
875
+ }
876
+ const createWorkOrdersAdapterFactory = (luvio) => {
877
+ return function createWorkOrders(untrustedConfig) {
878
+ const config = validateAdapterConfig$2(untrustedConfig, createWorkOrders_ConfigPropertyNames);
879
+ // Invalid or incomplete config
880
+ if (config === null) {
881
+ throw new Error('Invalid config for "createWorkOrders"');
882
+ }
883
+ return buildNetworkSnapshot$2(luvio, config);
884
+ };
885
+ };
886
+
887
+ function select$2(luvio, params) {
888
+ return select$8();
889
+ }
890
+ function keyBuilder$2(luvio, params) {
891
+ return keyBuilder$5(luvio, {
892
+ id: params.urlParams.serviceAppointmentId
893
+ });
894
+ }
895
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
896
+ getTypeCacheKeys$3(storeKeyMap, luvio, response);
897
+ }
898
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
899
+ const { body } = response;
900
+ const key = keyBuilder$2(luvio, resourceParams);
901
+ luvio.storeIngest(key, ingest$3, body);
902
+ const snapshot = luvio.storeLookup({
903
+ recordId: key,
904
+ node: select$2(),
905
+ variables: {},
906
+ }, snapshotRefresh);
907
+ if (process.env.NODE_ENV !== 'production') {
908
+ if (snapshot.state !== 'Fulfilled') {
909
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
910
+ }
911
+ }
912
+ deepFreeze(snapshot.data);
913
+ return snapshot;
914
+ }
915
+ function ingestError(luvio, params, error, snapshotRefresh) {
916
+ const key = keyBuilder$2(luvio, params);
917
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
918
+ const storeMetadataParams = {
919
+ ttl: TTL$3,
920
+ namespace: keyPrefix,
921
+ version: VERSION$3,
922
+ representationName: RepresentationType$3
923
+ };
924
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
925
+ return errorSnapshot;
926
+ }
927
+ function createResourceRequest$1(config) {
928
+ const headers = {};
929
+ return {
930
+ baseUri: '/services/data/v66.0',
931
+ basePath: '/connect/industries-field-service/appointment-scheduling/slots/' + config.urlParams.serviceAppointmentId + '/' + config.urlParams.schedulingPolicyId + '',
932
+ method: 'get',
933
+ body: null,
934
+ urlParams: config.urlParams,
935
+ queryParams: {},
936
+ headers,
937
+ priority: 'normal',
938
+ };
939
+ }
940
+ function createResourceRequestFromRepresentation(representation) {
941
+ const config = {
942
+ urlParams: {},
943
+ };
944
+ config.urlParams.serviceAppointmentId = representation.serviceAppointmentId;
945
+ return createResourceRequest$1(config);
946
+ }
947
+
948
+ const adapterName$1 = 'getAppointmentSlots';
949
+ const getAppointmentSlots_ConfigPropertyMetadata = [
950
+ generateParamConfigMetadata('serviceAppointmentId', true, 0 /* UrlParameter */, 0 /* String */),
951
+ generateParamConfigMetadata('schedulingPolicyId', true, 0 /* UrlParameter */, 0 /* String */),
952
+ ];
953
+ const getAppointmentSlots_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getAppointmentSlots_ConfigPropertyMetadata);
954
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$5(getAppointmentSlots_ConfigPropertyMetadata);
955
+ function keyBuilder$1(luvio, config) {
956
+ const resourceParams = createResourceParams$1(config);
957
+ return keyBuilder$2(luvio, resourceParams);
958
+ }
959
+ function typeCheckConfig$1(untrustedConfig) {
960
+ const config = {};
961
+ typeCheckConfig$5(untrustedConfig, config, getAppointmentSlots_ConfigPropertyMetadata);
962
+ return config;
963
+ }
964
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
965
+ if (!untrustedIsObject(untrustedConfig)) {
966
+ return null;
967
+ }
968
+ if (process.env.NODE_ENV !== 'production') {
969
+ validateConfig(untrustedConfig, configPropertyNames);
970
+ }
971
+ const config = typeCheckConfig$1(untrustedConfig);
972
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
973
+ return null;
974
+ }
975
+ return config;
976
+ }
977
+ function adapterFragment(luvio, config) {
978
+ createResourceParams$1(config);
979
+ return select$2();
980
+ }
981
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
982
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
983
+ config,
984
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
985
+ });
986
+ return luvio.storeBroadcast().then(() => snapshot);
987
+ }
988
+ function onFetchResponseError(luvio, config, resourceParams, response) {
989
+ const snapshot = ingestError(luvio, resourceParams, response, {
990
+ config,
991
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
992
+ });
993
+ return luvio.storeBroadcast().then(() => snapshot);
994
+ }
995
+ function buildNetworkSnapshot$1(luvio, config, options) {
996
+ const resourceParams = createResourceParams$1(config);
997
+ const request = createResourceRequest$1(resourceParams);
998
+ return luvio.dispatchResourceRequest(request, options)
999
+ .then((response) => {
1000
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
1001
+ const cache = new StoreKeyMap();
1002
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
1003
+ return cache;
1004
+ });
1005
+ }, (response) => {
1006
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
1007
+ });
1008
+ }
1009
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
1010
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
1011
+ }
1012
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
1013
+ const { luvio, config } = context;
1014
+ const selector = {
1015
+ recordId: keyBuilder$1(luvio, config),
1016
+ node: adapterFragment(luvio, config),
1017
+ variables: {},
1018
+ };
1019
+ const cacheSnapshot = storeLookup(selector, {
1020
+ config,
1021
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
1022
+ });
1023
+ return cacheSnapshot;
1024
+ }
1025
+ const getAppointmentSlotsAdapterFactory = (luvio) => function fieldService__getAppointmentSlots(untrustedConfig, requestContext) {
1026
+ const config = validateAdapterConfig$1(untrustedConfig, getAppointmentSlots_ConfigPropertyNames);
1027
+ // Invalid or incomplete config
1028
+ if (config === null) {
1029
+ return null;
1030
+ }
1031
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
1032
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
1033
+ };
1034
+ const notifyChangeFactory = (luvio, options) => {
1035
+ return function getConnectIndustriesFieldServiceAppointmentSchedulingSlotsByServiceAppointmentIdAndSchedulingPolicyIdNotifyChange(configs) {
1036
+ const keys = configs.map(c => keyBuilder$5(luvio, c));
1037
+ luvio.getNotifyChangeStoreEntries(keys).then(entries => {
1038
+ for (let i = 0, len = entries.length; i < len; i++) {
1039
+ const { key, record: val } = entries[i];
1040
+ const refreshRequest = createResourceRequestFromRepresentation(val);
1041
+ luvio.dispatchResourceRequest(refreshRequest, options)
1042
+ .then((response) => {
1043
+ return luvio.handleSuccessResponse(() => {
1044
+ const { body } = response;
1045
+ luvio.storeIngest(key, ingest$3, body);
1046
+ return luvio.storeBroadcast();
1047
+ }, () => {
1048
+ const cache = new StoreKeyMap();
1049
+ getTypeCacheKeys$3(cache, luvio, response.body);
1050
+ return cache;
1051
+ });
1052
+ }, (error) => {
1053
+ return luvio.handleErrorResponse(() => {
1054
+ const errorSnapshot = luvio.errorSnapshot(error);
1055
+ luvio.storeIngestError(key, errorSnapshot, {
1056
+ ttl: TTL$3,
1057
+ namespace: keyPrefix,
1058
+ version: VERSION$3,
1059
+ representationName: RepresentationType$3
1060
+ });
1061
+ return luvio.storeBroadcast().then(() => errorSnapshot);
1062
+ });
1063
+ });
1064
+ }
1065
+ });
1066
+ };
1067
+ };
1068
+
1069
+ function validate$1(obj, path = 'AssetCoverageInputRepresentation') {
1070
+ const v_error = (() => {
1071
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1072
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1073
+ }
1074
+ const obj_contractIds = obj.contractIds;
1075
+ const path_contractIds = path + '.contractIds';
1076
+ if (!ArrayIsArray(obj_contractIds)) {
1077
+ return new TypeError('Expected "array" but received "' + typeof obj_contractIds + '" (at "' + path_contractIds + '")');
1078
+ }
1079
+ for (let i = 0; i < obj_contractIds.length; i++) {
1080
+ const obj_contractIds_item = obj_contractIds[i];
1081
+ const path_contractIds_item = path_contractIds + '[' + i + ']';
1082
+ if (typeof obj_contractIds_item !== 'string') {
1083
+ return new TypeError('Expected "string" but received "' + typeof obj_contractIds_item + '" (at "' + path_contractIds_item + '")');
1084
+ }
1085
+ }
1086
+ const obj_entitlementIds = obj.entitlementIds;
1087
+ const path_entitlementIds = path + '.entitlementIds';
1088
+ if (!ArrayIsArray(obj_entitlementIds)) {
1089
+ return new TypeError('Expected "array" but received "' + typeof obj_entitlementIds + '" (at "' + path_entitlementIds + '")');
1090
+ }
1091
+ for (let i = 0; i < obj_entitlementIds.length; i++) {
1092
+ const obj_entitlementIds_item = obj_entitlementIds[i];
1093
+ const path_entitlementIds_item = path_entitlementIds + '[' + i + ']';
1094
+ if (typeof obj_entitlementIds_item !== 'string') {
1095
+ return new TypeError('Expected "string" but received "' + typeof obj_entitlementIds_item + '" (at "' + path_entitlementIds_item + '")');
1096
+ }
1097
+ }
1098
+ const obj_warrantyIds = obj.warrantyIds;
1099
+ const path_warrantyIds = path + '.warrantyIds';
1100
+ if (!ArrayIsArray(obj_warrantyIds)) {
1101
+ return new TypeError('Expected "array" but received "' + typeof obj_warrantyIds + '" (at "' + path_warrantyIds + '")');
1102
+ }
1103
+ for (let i = 0; i < obj_warrantyIds.length; i++) {
1104
+ const obj_warrantyIds_item = obj_warrantyIds[i];
1105
+ const path_warrantyIds_item = path_warrantyIds + '[' + i + ']';
1106
+ if (typeof obj_warrantyIds_item !== 'string') {
1107
+ return new TypeError('Expected "string" but received "' + typeof obj_warrantyIds_item + '" (at "' + path_warrantyIds_item + '")');
1108
+ }
1109
+ }
1110
+ })();
1111
+ return v_error === undefined ? null : v_error;
1112
+ }
1113
+
1114
+ const TTL = 300;
1115
+ const VERSION = "015dacd597244984e1677034427a3f46";
1116
+ function validate(obj, path = 'PriceItemWithCoverageRepresentation') {
1117
+ const v_error = (() => {
1118
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1119
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1120
+ }
1121
+ const obj_errorCode = obj.errorCode;
1122
+ const path_errorCode = path + '.errorCode';
1123
+ if (typeof obj_errorCode !== 'string') {
1124
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
1125
+ }
1126
+ const obj_errorMessage = obj.errorMessage;
1127
+ const path_errorMessage = path + '.errorMessage';
1128
+ if (typeof obj_errorMessage !== 'string') {
1129
+ return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
1130
+ }
1131
+ const obj_isSuccess = obj.isSuccess;
1132
+ const path_isSuccess = path + '.isSuccess';
1133
+ if (typeof obj_isSuccess !== 'boolean') {
1134
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isSuccess + '" (at "' + path_isSuccess + '")');
1135
+ }
1136
+ const obj_itemId = obj.itemId;
1137
+ const path_itemId = path + '.itemId';
1138
+ if (typeof obj_itemId !== 'string') {
1139
+ return new TypeError('Expected "string" but received "' + typeof obj_itemId + '" (at "' + path_itemId + '")');
1140
+ }
1141
+ })();
1142
+ return v_error === undefined ? null : v_error;
1143
+ }
1144
+ const RepresentationType = 'PriceItemWithCoverageRepresentation';
1145
+ function keyBuilder(luvio, config) {
1146
+ return keyPrefix + '::' + RepresentationType + ':' + config.itemId;
1147
+ }
1148
+ function keyBuilderFromType(luvio, object) {
1149
+ const keyParams = {
1150
+ itemId: object.itemId
1151
+ };
1152
+ return keyBuilder(luvio, keyParams);
1153
+ }
1154
+ function normalize(input, existing, path, luvio, store, timestamp) {
1155
+ return input;
1156
+ }
1157
+ const select$1 = function PriceItemWithCoverageRepresentationSelect() {
1158
+ return {
1159
+ kind: 'Fragment',
1160
+ version: VERSION,
1161
+ private: [],
1162
+ selections: [
1163
+ {
1164
+ name: 'errorCode',
1165
+ kind: 'Scalar'
1166
+ },
1167
+ {
1168
+ name: 'errorMessage',
1169
+ kind: 'Scalar'
1170
+ },
1171
+ {
1172
+ name: 'isSuccess',
1173
+ kind: 'Scalar'
1174
+ },
1175
+ {
1176
+ name: 'itemId',
1177
+ kind: 'Scalar'
1178
+ }
1179
+ ]
1180
+ };
1181
+ };
1182
+ function equals(existing, incoming) {
1183
+ const existing_isSuccess = existing.isSuccess;
1184
+ const incoming_isSuccess = incoming.isSuccess;
1185
+ if (!(existing_isSuccess === incoming_isSuccess)) {
1186
+ return false;
1187
+ }
1188
+ const existing_errorCode = existing.errorCode;
1189
+ const incoming_errorCode = incoming.errorCode;
1190
+ if (!(existing_errorCode === incoming_errorCode)) {
1191
+ return false;
1192
+ }
1193
+ const existing_errorMessage = existing.errorMessage;
1194
+ const incoming_errorMessage = incoming.errorMessage;
1195
+ if (!(existing_errorMessage === incoming_errorMessage)) {
1196
+ return false;
1197
+ }
1198
+ const existing_itemId = existing.itemId;
1199
+ const incoming_itemId = incoming.itemId;
1200
+ if (!(existing_itemId === incoming_itemId)) {
1201
+ return false;
1202
+ }
1203
+ return true;
1204
+ }
1205
+ const ingest = function PriceItemWithCoverageRepresentationIngest(input, path, luvio, store, timestamp) {
1206
+ if (process.env.NODE_ENV !== 'production') {
1207
+ const validateError = validate(input);
1208
+ if (validateError !== null) {
1209
+ throw validateError;
1210
+ }
1211
+ }
1212
+ const key = keyBuilderFromType(luvio, input);
1213
+ const ttlToUse = TTL;
1214
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "field-service", VERSION, RepresentationType, equals);
1215
+ return createLink(key);
1216
+ };
1217
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
1218
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1219
+ const rootKey = keyBuilderFromType(luvio, input);
1220
+ rootKeySet.set(rootKey, {
1221
+ namespace: keyPrefix,
1222
+ representationName: RepresentationType,
1223
+ mergeable: false
1224
+ });
1225
+ }
1226
+
1227
+ function select(luvio, params) {
1228
+ return select$1();
1229
+ }
1230
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
1231
+ getTypeCacheKeys(storeKeyMap, luvio, response);
1232
+ }
1233
+ function ingestSuccess(luvio, resourceParams, response) {
1234
+ const { body } = response;
1235
+ const key = keyBuilderFromType(luvio, body);
1236
+ luvio.storeIngest(key, ingest, body);
1237
+ const snapshot = luvio.storeLookup({
1238
+ recordId: key,
1239
+ node: select(),
1240
+ variables: {},
1241
+ });
1242
+ if (process.env.NODE_ENV !== 'production') {
1243
+ if (snapshot.state !== 'Fulfilled') {
1244
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1245
+ }
1246
+ }
1247
+ deepFreeze(snapshot.data);
1248
+ return snapshot;
1249
+ }
1250
+ function createResourceRequest(config) {
1251
+ const headers = {};
1252
+ return {
1253
+ baseUri: '/services/data/v66.0',
1254
+ basePath: '/connect/industries-field-service/work-order-estimation/price-item',
1255
+ method: 'put',
1256
+ body: config.body,
1257
+ urlParams: {},
1258
+ queryParams: {},
1259
+ headers,
1260
+ priority: 'normal',
1261
+ };
1262
+ }
1263
+
1264
+ const adapterName = 'priceItemWithCoverage';
1265
+ const priceItemWithCoverage_ConfigPropertyMetadata = [
1266
+ generateParamConfigMetadata('assetCoverageMap', true, 2 /* Body */, 4 /* Unsupported */),
1267
+ generateParamConfigMetadata('childItems', true, 2 /* Body */, 0 /* String */, true),
1268
+ generateParamConfigMetadata('itemId', true, 2 /* Body */, 0 /* String */),
1269
+ generateParamConfigMetadata('pricingProcedure', true, 2 /* Body */, 0 /* String */),
1270
+ ];
1271
+ const priceItemWithCoverage_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, priceItemWithCoverage_ConfigPropertyMetadata);
1272
+ const createResourceParams = /*#__PURE__*/ createResourceParams$5(priceItemWithCoverage_ConfigPropertyMetadata);
1273
+ function typeCheckConfig(untrustedConfig) {
1274
+ const config = {};
1275
+ typeCheckConfig$5(untrustedConfig, config, priceItemWithCoverage_ConfigPropertyMetadata);
1276
+ const untrustedConfig_assetCoverageMap = untrustedConfig.assetCoverageMap;
1277
+ if (untrustedIsObject(untrustedConfig_assetCoverageMap)) {
1278
+ const untrustedConfig_assetCoverageMap_object = {};
1279
+ const untrustedConfig_assetCoverageMap_keys = Object.keys(untrustedConfig_assetCoverageMap);
1280
+ for (let i = 0, arrayLength = untrustedConfig_assetCoverageMap_keys.length; i < arrayLength; i++) {
1281
+ const key = untrustedConfig_assetCoverageMap_keys[i];
1282
+ const untrustedConfig_assetCoverageMap_prop = untrustedConfig_assetCoverageMap[key];
1283
+ const referenceAssetCoverageInputRepresentationValidationError = validate$1(untrustedConfig_assetCoverageMap_prop);
1284
+ if (referenceAssetCoverageInputRepresentationValidationError === null) {
1285
+ if (untrustedConfig_assetCoverageMap_object !== undefined) {
1286
+ untrustedConfig_assetCoverageMap_object[key] = untrustedConfig_assetCoverageMap_prop;
1287
+ }
1288
+ }
1289
+ }
1290
+ if (untrustedConfig_assetCoverageMap_object !== undefined && Object.keys(untrustedConfig_assetCoverageMap_object).length >= 0) {
1291
+ config.assetCoverageMap = untrustedConfig_assetCoverageMap_object;
1292
+ }
1293
+ }
1294
+ return config;
1295
+ }
1296
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
1297
+ if (!untrustedIsObject(untrustedConfig)) {
1298
+ return null;
1299
+ }
1300
+ if (process.env.NODE_ENV !== 'production') {
1301
+ validateConfig(untrustedConfig, configPropertyNames);
1302
+ }
1303
+ const config = typeCheckConfig(untrustedConfig);
1304
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
1305
+ return null;
1306
+ }
1307
+ return config;
1308
+ }
1309
+ function buildNetworkSnapshot(luvio, config, options) {
1310
+ const resourceParams = createResourceParams(config);
1311
+ const request = createResourceRequest(resourceParams);
1312
+ return luvio.dispatchResourceRequest(request, options)
1313
+ .then((response) => {
1314
+ return luvio.handleSuccessResponse(() => {
1315
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
1316
+ return luvio.storeBroadcast().then(() => snapshot);
1317
+ }, () => {
1318
+ const cache = new StoreKeyMap();
1319
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
1320
+ return cache;
1321
+ });
1322
+ }, (response) => {
1323
+ deepFreeze(response);
1324
+ throw response;
1325
+ });
1326
+ }
1327
+ const priceItemWithCoverageAdapterFactory = (luvio) => {
1328
+ return function priceItemWithCoverage(untrustedConfig) {
1329
+ const config = validateAdapterConfig(untrustedConfig, priceItemWithCoverage_ConfigPropertyNames);
1330
+ // Invalid or incomplete config
1331
+ if (config === null) {
1332
+ throw new Error('Invalid config for "priceItemWithCoverage"');
1333
+ }
1334
+ return buildNetworkSnapshot(luvio, config);
1335
+ };
1336
+ };
1337
+
1338
+ let bookAppointmentSlot;
1339
+ let createProductServiceCampaign;
1340
+ let createWorkOrders;
1341
+ let getAppointmentSlots;
1342
+ let getAppointmentSlotsNotifyChange;
1343
+ let priceItemWithCoverage;
1344
+ // Imperative GET Adapters
1345
+ let getAppointmentSlots_imperative;
1346
+ const getAppointmentSlotsMetadata = {
1347
+ apiFamily: 'fieldservice',
1348
+ name: 'getAppointmentSlots',
1349
+ ttl: 1000,
1350
+ };
1351
+ // Notify Update Available
1352
+ let notifyAppointmentSchedulingUpdateAvailable;
1353
+ function bindExportsTo(luvio) {
1354
+ // LDS Adapters
1355
+ const getAppointmentSlots_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getAppointmentSlots', getAppointmentSlotsAdapterFactory), getAppointmentSlotsMetadata);
1356
+ function unwrapSnapshotData(factory) {
1357
+ const adapter = factory(luvio);
1358
+ return (config) => adapter(config).then((snapshot) => snapshot.data);
1359
+ }
1360
+ return {
1361
+ bookAppointmentSlot: unwrapSnapshotData(bookAppointmentSlotAdapterFactory),
1362
+ createProductServiceCampaign: unwrapSnapshotData(createProductServiceCampaignAdapterFactory),
1363
+ createWorkOrders: unwrapSnapshotData(createWorkOrdersAdapterFactory),
1364
+ getAppointmentSlots: createWireAdapterConstructor(luvio, getAppointmentSlots_ldsAdapter, getAppointmentSlotsMetadata),
1365
+ getAppointmentSlotsNotifyChange: createLDSAdapter(luvio, 'getAppointmentSlotsNotifyChange', notifyChangeFactory),
1366
+ priceItemWithCoverage: unwrapSnapshotData(priceItemWithCoverageAdapterFactory),
1367
+ // Imperative GET Adapters
1368
+ getAppointmentSlots_imperative: createImperativeAdapter(luvio, getAppointmentSlots_ldsAdapter, getAppointmentSlotsMetadata),
1369
+ // Notify Update Availables
1370
+ notifyAppointmentSchedulingUpdateAvailable: createLDSAdapter(luvio, 'notifyAppointmentSchedulingUpdateAvailable', notifyUpdateAvailableFactory),
1371
+ };
1372
+ }
1373
+ withDefaultLuvio((luvio) => {
1374
+ ({
1375
+ bookAppointmentSlot,
1376
+ createProductServiceCampaign,
1377
+ createWorkOrders,
1378
+ getAppointmentSlots,
1379
+ getAppointmentSlotsNotifyChange,
1380
+ priceItemWithCoverage,
1381
+ getAppointmentSlots_imperative,
1382
+ notifyAppointmentSchedulingUpdateAvailable,
1383
+ } = bindExportsTo(luvio));
1384
+ });
1385
+
1386
+ export { bookAppointmentSlot, createProductServiceCampaign, createWorkOrders, getAppointmentSlots, getAppointmentSlotsNotifyChange, getAppointmentSlots_imperative, notifyAppointmentSchedulingUpdateAvailable, priceItemWithCoverage };
1387
+ // version: 0.1.0-dev1-c978a7b010