@salesforce/lds-adapters-service-milestones 1.296.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt ADDED
@@ -0,0 +1,82 @@
1
+ Terms of Use
2
+
3
+ Copyright 2022 Salesforce, Inc. All rights reserved.
4
+
5
+ These Terms of Use govern the download, installation, and/or use of this
6
+ software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
7
+ last updated on April 15, 2022, and constitute a legally binding
8
+ agreement between you and Salesforce. If you do not agree to these Terms of
9
+ Use, do not install or use the Software.
10
+
11
+ Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
12
+ copyright license to reproduce, prepare derivative works of, publicly
13
+ display, publicly perform, sublicense, and distribute the Software and
14
+ derivative works subject to these Terms. These Terms shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ Subject to the limited rights expressly granted hereunder, Salesforce
18
+ reserves all rights, title, and interest in and to all intellectual
19
+ property subsisting in the Software. No rights are granted to you hereunder
20
+ other than as expressly set forth herein. Users residing in countries on
21
+ the United States Office of Foreign Assets Control sanction list, or which
22
+ are otherwise subject to a US export embargo, may not use the Software.
23
+
24
+ Implementation of the Software may require development work, for which you
25
+ are responsible. The Software may contain bugs, errors and
26
+ incompatibilities and is made available on an AS IS basis without support,
27
+ updates, or service level commitments.
28
+
29
+ Salesforce reserves the right at any time to modify, suspend, or
30
+ discontinue, the Software (or any part thereof) with or without notice. You
31
+ agree that Salesforce shall not be liable to you or to any third party for
32
+ any modification, suspension, or discontinuance.
33
+
34
+ You agree to defend Salesforce against any claim, demand, suit or
35
+ proceeding made or brought against Salesforce by a third party arising out
36
+ of or accruing from (a) your use of the Software, and (b) any application
37
+ you develop with the Software that infringes any copyright, trademark,
38
+ trade secret, trade dress, patent, or other intellectual property right of
39
+ any person or defames any person or violates their rights of publicity or
40
+ privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
41
+ from any damages, attorney fees, and costs finally awarded against
42
+ Salesforce as a result of, or for any amounts paid by Salesforce under a
43
+ settlement approved by you in writing of, a Claim Against Salesforce,
44
+ provided Salesforce (x) promptly gives you written notice of the Claim
45
+ Against Salesforce, (y) gives you sole control of the defense and
46
+ settlement of the Claim Against Salesforce (except that you may not settle
47
+ any Claim Against Salesforce unless it unconditionally releases Salesforce
48
+ of all liability), and (z) gives you all reasonable assistance, at your
49
+ expense.
50
+
51
+ WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
52
+ SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
54
+ INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
55
+ PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
56
+ OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
57
+ CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
58
+ HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
59
+
60
+ These Terms of Use shall be governed exclusively by the internal laws of
61
+ the State of California, without regard to its conflicts of laws
62
+ rules. Each party hereby consents to the exclusive jurisdiction of the
63
+ state and federal courts located in San Francisco County, California to
64
+ adjudicate any dispute arising out of or relating to these Terms of Use and
65
+ the download, installation, and/or use of the Software. Except as expressly
66
+ stated herein, these Terms of Use constitute the entire agreement between
67
+ the parties, and supersede all prior and contemporaneous agreements,
68
+ proposals, or representations, written or oral, concerning their subject
69
+ matter. No modification, amendment, or waiver of any provision of these
70
+ Terms of Use shall be effective unless it is by an update to these Terms of
71
+ Use that Salesforce makes available, or is in writing and signed by the
72
+ party against whom the modification, amendment, or waiver is to be
73
+ asserted.
74
+
75
+ Data Privacy: Salesforce may collect, process, and store device,
76
+ system, and other information related to your use of the Software. This
77
+ information includes, but is not limited to, IP address, user metrics, and
78
+ other data ("Usage Data"). Salesforce may use Usage Data for analytics,
79
+ product development, and marketing purposes. You acknowledge that files
80
+ generated in conjunction with the Software may contain sensitive or
81
+ confidential data, and you are solely responsible for anonymizing and
82
+ protecting such data.
@@ -0,0 +1,559 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
8
+
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys, create: ObjectCreate } = Object;
11
+ const { isArray: ArrayIsArray$1 } = Array;
12
+ /**
13
+ * Validates an adapter config is well-formed.
14
+ * @param config The config to validate.
15
+ * @param adapter The adapter validation configuration.
16
+ * @param oneOf The keys the config must contain at least one of.
17
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
18
+ */
19
+ function validateConfig(config, adapter, oneOf) {
20
+ const { displayName } = adapter;
21
+ const { required, optional, unsupported } = adapter.parameters;
22
+ if (config === undefined ||
23
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
24
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
25
+ }
26
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
27
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
28
+ }
29
+ if (unsupported !== undefined &&
30
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
31
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
32
+ }
33
+ const supported = required.concat(optional);
34
+ if (ObjectKeys(config).some(key => !supported.includes(key))) {
35
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
36
+ }
37
+ }
38
+ function untrustedIsObject(untrusted) {
39
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
40
+ }
41
+ function areRequiredParametersPresent(config, configPropertyNames) {
42
+ return configPropertyNames.parameters.required.every(req => req in config);
43
+ }
44
+ const snapshotRefreshOptions = {
45
+ overrides: {
46
+ headers: {
47
+ 'Cache-Control': 'no-cache',
48
+ },
49
+ }
50
+ };
51
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
52
+ return {
53
+ name,
54
+ required,
55
+ resourceType,
56
+ typeCheckShape,
57
+ isArrayShape,
58
+ coerceFn,
59
+ };
60
+ }
61
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
62
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
63
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
64
+ return {
65
+ displayName,
66
+ parameters: {
67
+ required,
68
+ optional,
69
+ }
70
+ };
71
+ }
72
+ const keyPrefix = 'Milestones';
73
+
74
+ const { isArray: ArrayIsArray } = Array;
75
+ const { stringify: JSONStringify } = JSON;
76
+ function createLink(ref) {
77
+ return {
78
+ __ref: serializeStructuredKey(ref),
79
+ };
80
+ }
81
+
82
+ const TTL$1 = 100;
83
+ const VERSION$1 = "77385f3d3c79cead805a91e3f9f1f94b";
84
+ function validate$1(obj, path = 'BusinessHoursRepresentation') {
85
+ const v_error = (() => {
86
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
87
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
88
+ }
89
+ const obj_endTime = obj.endTime;
90
+ const path_endTime = path + '.endTime';
91
+ let obj_endTime_union0 = null;
92
+ const obj_endTime_union0_error = (() => {
93
+ if (typeof obj_endTime !== 'string') {
94
+ return new TypeError('Expected "string" but received "' + typeof obj_endTime + '" (at "' + path_endTime + '")');
95
+ }
96
+ })();
97
+ if (obj_endTime_union0_error != null) {
98
+ obj_endTime_union0 = obj_endTime_union0_error.message;
99
+ }
100
+ let obj_endTime_union1 = null;
101
+ const obj_endTime_union1_error = (() => {
102
+ if (obj_endTime !== null) {
103
+ return new TypeError('Expected "null" but received "' + typeof obj_endTime + '" (at "' + path_endTime + '")');
104
+ }
105
+ })();
106
+ if (obj_endTime_union1_error != null) {
107
+ obj_endTime_union1 = obj_endTime_union1_error.message;
108
+ }
109
+ if (obj_endTime_union0 && obj_endTime_union1) {
110
+ let message = 'Object doesn\'t match union (at "' + path_endTime + '")';
111
+ message += '\n' + obj_endTime_union0.split('\n').map((line) => '\t' + line).join('\n');
112
+ message += '\n' + obj_endTime_union1.split('\n').map((line) => '\t' + line).join('\n');
113
+ return new TypeError(message);
114
+ }
115
+ const obj_startTime = obj.startTime;
116
+ const path_startTime = path + '.startTime';
117
+ let obj_startTime_union0 = null;
118
+ const obj_startTime_union0_error = (() => {
119
+ if (typeof obj_startTime !== 'string') {
120
+ return new TypeError('Expected "string" but received "' + typeof obj_startTime + '" (at "' + path_startTime + '")');
121
+ }
122
+ })();
123
+ if (obj_startTime_union0_error != null) {
124
+ obj_startTime_union0 = obj_startTime_union0_error.message;
125
+ }
126
+ let obj_startTime_union1 = null;
127
+ const obj_startTime_union1_error = (() => {
128
+ if (obj_startTime !== null) {
129
+ return new TypeError('Expected "null" but received "' + typeof obj_startTime + '" (at "' + path_startTime + '")');
130
+ }
131
+ })();
132
+ if (obj_startTime_union1_error != null) {
133
+ obj_startTime_union1 = obj_startTime_union1_error.message;
134
+ }
135
+ if (obj_startTime_union0 && obj_startTime_union1) {
136
+ let message = 'Object doesn\'t match union (at "' + path_startTime + '")';
137
+ message += '\n' + obj_startTime_union0.split('\n').map((line) => '\t' + line).join('\n');
138
+ message += '\n' + obj_startTime_union1.split('\n').map((line) => '\t' + line).join('\n');
139
+ return new TypeError(message);
140
+ }
141
+ })();
142
+ return v_error === undefined ? null : v_error;
143
+ }
144
+ const RepresentationType$1 = 'BusinessHoursRepresentation';
145
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
146
+ return input;
147
+ }
148
+ const select$3 = function BusinessHoursRepresentationSelect() {
149
+ return {
150
+ kind: 'Fragment',
151
+ version: VERSION$1,
152
+ private: [],
153
+ selections: [
154
+ {
155
+ name: 'endTime',
156
+ kind: 'Scalar'
157
+ },
158
+ {
159
+ name: 'startTime',
160
+ kind: 'Scalar'
161
+ }
162
+ ]
163
+ };
164
+ };
165
+ function equals$1(existing, incoming) {
166
+ const existing_endTime = existing.endTime;
167
+ const incoming_endTime = incoming.endTime;
168
+ if (!(existing_endTime === incoming_endTime)) {
169
+ return false;
170
+ }
171
+ const existing_startTime = existing.startTime;
172
+ const incoming_startTime = incoming.startTime;
173
+ if (!(existing_startTime === incoming_startTime)) {
174
+ return false;
175
+ }
176
+ return true;
177
+ }
178
+ const ingest$1 = function BusinessHoursRepresentationIngest(input, path, luvio, store, timestamp) {
179
+ if (process.env.NODE_ENV !== 'production') {
180
+ const validateError = validate$1(input);
181
+ if (validateError !== null) {
182
+ throw validateError;
183
+ }
184
+ }
185
+ const key = path.fullPath;
186
+ const ttlToUse = TTL$1;
187
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "Milestones", VERSION$1, RepresentationType$1, equals$1);
188
+ return createLink(key);
189
+ };
190
+ function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
191
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
192
+ const rootKey = fullPathFactory();
193
+ rootKeySet.set(rootKey, {
194
+ namespace: keyPrefix,
195
+ representationName: RepresentationType$1,
196
+ mergeable: false
197
+ });
198
+ }
199
+
200
+ function select$2(luvio, params) {
201
+ return select$3();
202
+ }
203
+ function keyBuilder$2(luvio, params) {
204
+ return keyPrefix + '::BusinessHoursRepresentation:(' + 'businessHoursId:' + params.queryParams.businessHoursId + ',' + 'getNextDayBusinessHours:' + params.queryParams.getNextDayBusinessHours + ')';
205
+ }
206
+ function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
207
+ getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
208
+ }
209
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
210
+ const { body } = response;
211
+ const key = keyBuilder$2(luvio, resourceParams);
212
+ luvio.storeIngest(key, ingest$1, body);
213
+ const snapshot = luvio.storeLookup({
214
+ recordId: key,
215
+ node: select$2(),
216
+ variables: {},
217
+ }, snapshotRefresh);
218
+ if (process.env.NODE_ENV !== 'production') {
219
+ if (snapshot.state !== 'Fulfilled') {
220
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
221
+ }
222
+ }
223
+ deepFreeze(snapshot.data);
224
+ return snapshot;
225
+ }
226
+ function ingestError(luvio, params, error, snapshotRefresh) {
227
+ const key = keyBuilder$2(luvio, params);
228
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
229
+ const storeMetadataParams = {
230
+ ttl: TTL$1,
231
+ namespace: keyPrefix,
232
+ version: VERSION$1,
233
+ representationName: RepresentationType$1
234
+ };
235
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
236
+ return errorSnapshot;
237
+ }
238
+ function createResourceRequest$1(config) {
239
+ const headers = {};
240
+ return {
241
+ baseUri: '/services/data/v62.0',
242
+ basePath: '/connect/milestones/business-hours',
243
+ method: 'get',
244
+ body: null,
245
+ urlParams: {},
246
+ queryParams: config.queryParams,
247
+ headers,
248
+ priority: 'normal',
249
+ };
250
+ }
251
+
252
+ const adapterName$1 = 'getBusinessHours';
253
+ const getBusinessHours_ConfigPropertyMetadata = [
254
+ generateParamConfigMetadata('businessHoursId', false, 1 /* QueryParameter */, 4 /* Unsupported */),
255
+ generateParamConfigMetadata('getNextDayBusinessHours', false, 1 /* QueryParameter */, 4 /* Unsupported */),
256
+ ];
257
+ const getBusinessHours_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getBusinessHours_ConfigPropertyMetadata);
258
+ const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getBusinessHours_ConfigPropertyMetadata);
259
+ function keyBuilder$1(luvio, config) {
260
+ const resourceParams = createResourceParams$1(config);
261
+ return keyBuilder$2(luvio, resourceParams);
262
+ }
263
+ function typeCheckConfig$1(untrustedConfig) {
264
+ const config = {};
265
+ const untrustedConfig_businessHoursId = untrustedConfig.businessHoursId;
266
+ if (typeof untrustedConfig_businessHoursId === 'string') {
267
+ config.businessHoursId = untrustedConfig_businessHoursId;
268
+ }
269
+ if (untrustedConfig_businessHoursId === null) {
270
+ config.businessHoursId = untrustedConfig_businessHoursId;
271
+ }
272
+ const untrustedConfig_getNextDayBusinessHours = untrustedConfig.getNextDayBusinessHours;
273
+ if (typeof untrustedConfig_getNextDayBusinessHours === 'boolean') {
274
+ config.getNextDayBusinessHours = untrustedConfig_getNextDayBusinessHours;
275
+ }
276
+ if (untrustedConfig_getNextDayBusinessHours === null) {
277
+ config.getNextDayBusinessHours = untrustedConfig_getNextDayBusinessHours;
278
+ }
279
+ return config;
280
+ }
281
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
282
+ if (!untrustedIsObject(untrustedConfig)) {
283
+ return null;
284
+ }
285
+ if (process.env.NODE_ENV !== 'production') {
286
+ validateConfig(untrustedConfig, configPropertyNames);
287
+ }
288
+ const config = typeCheckConfig$1(untrustedConfig);
289
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
290
+ return null;
291
+ }
292
+ return config;
293
+ }
294
+ function adapterFragment(luvio, config) {
295
+ createResourceParams$1(config);
296
+ return select$2();
297
+ }
298
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
299
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
300
+ config,
301
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
302
+ });
303
+ return luvio.storeBroadcast().then(() => snapshot);
304
+ }
305
+ function onFetchResponseError(luvio, config, resourceParams, response) {
306
+ const snapshot = ingestError(luvio, resourceParams, response, {
307
+ config,
308
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
309
+ });
310
+ return luvio.storeBroadcast().then(() => snapshot);
311
+ }
312
+ function buildNetworkSnapshot$1(luvio, config, options) {
313
+ const resourceParams = createResourceParams$1(config);
314
+ const request = createResourceRequest$1(resourceParams);
315
+ return luvio.dispatchResourceRequest(request, options)
316
+ .then((response) => {
317
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
318
+ const cache = new StoreKeyMap();
319
+ getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
320
+ return cache;
321
+ });
322
+ }, (response) => {
323
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
324
+ });
325
+ }
326
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
327
+ return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
328
+ }
329
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
330
+ const { luvio, config } = context;
331
+ const selector = {
332
+ recordId: keyBuilder$1(luvio, config),
333
+ node: adapterFragment(luvio, config),
334
+ variables: {},
335
+ };
336
+ const cacheSnapshot = storeLookup(selector, {
337
+ config,
338
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
339
+ });
340
+ return cacheSnapshot;
341
+ }
342
+ const getBusinessHoursAdapterFactory = (luvio) => function Milestones__getBusinessHours(untrustedConfig, requestContext) {
343
+ const config = validateAdapterConfig$1(untrustedConfig, getBusinessHours_ConfigPropertyNames);
344
+ // Invalid or incomplete config
345
+ if (config === null) {
346
+ return null;
347
+ }
348
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
349
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
350
+ };
351
+
352
+ const TTL = 100;
353
+ const VERSION = "2225350c2bb6b0628fe14b755cc2f9ee";
354
+ function validate(obj, path = 'MilestoneCompletedRepresentation') {
355
+ const v_error = (() => {
356
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
357
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
358
+ }
359
+ const obj_completed = obj.completed;
360
+ const path_completed = path + '.completed';
361
+ let obj_completed_union0 = null;
362
+ const obj_completed_union0_error = (() => {
363
+ if (typeof obj_completed !== 'boolean') {
364
+ return new TypeError('Expected "boolean" but received "' + typeof obj_completed + '" (at "' + path_completed + '")');
365
+ }
366
+ })();
367
+ if (obj_completed_union0_error != null) {
368
+ obj_completed_union0 = obj_completed_union0_error.message;
369
+ }
370
+ let obj_completed_union1 = null;
371
+ const obj_completed_union1_error = (() => {
372
+ if (obj_completed !== null) {
373
+ return new TypeError('Expected "null" but received "' + typeof obj_completed + '" (at "' + path_completed + '")');
374
+ }
375
+ })();
376
+ if (obj_completed_union1_error != null) {
377
+ obj_completed_union1 = obj_completed_union1_error.message;
378
+ }
379
+ if (obj_completed_union0 && obj_completed_union1) {
380
+ let message = 'Object doesn\'t match union (at "' + path_completed + '")';
381
+ message += '\n' + obj_completed_union0.split('\n').map((line) => '\t' + line).join('\n');
382
+ message += '\n' + obj_completed_union1.split('\n').map((line) => '\t' + line).join('\n');
383
+ return new TypeError(message);
384
+ }
385
+ const obj_milestoneId = obj.milestoneId;
386
+ const path_milestoneId = path + '.milestoneId';
387
+ let obj_milestoneId_union0 = null;
388
+ const obj_milestoneId_union0_error = (() => {
389
+ if (typeof obj_milestoneId !== 'string') {
390
+ return new TypeError('Expected "string" but received "' + typeof obj_milestoneId + '" (at "' + path_milestoneId + '")');
391
+ }
392
+ })();
393
+ if (obj_milestoneId_union0_error != null) {
394
+ obj_milestoneId_union0 = obj_milestoneId_union0_error.message;
395
+ }
396
+ let obj_milestoneId_union1 = null;
397
+ const obj_milestoneId_union1_error = (() => {
398
+ if (obj_milestoneId !== null) {
399
+ return new TypeError('Expected "null" but received "' + typeof obj_milestoneId + '" (at "' + path_milestoneId + '")');
400
+ }
401
+ })();
402
+ if (obj_milestoneId_union1_error != null) {
403
+ obj_milestoneId_union1 = obj_milestoneId_union1_error.message;
404
+ }
405
+ if (obj_milestoneId_union0 && obj_milestoneId_union1) {
406
+ let message = 'Object doesn\'t match union (at "' + path_milestoneId + '")';
407
+ message += '\n' + obj_milestoneId_union0.split('\n').map((line) => '\t' + line).join('\n');
408
+ message += '\n' + obj_milestoneId_union1.split('\n').map((line) => '\t' + line).join('\n');
409
+ return new TypeError(message);
410
+ }
411
+ })();
412
+ return v_error === undefined ? null : v_error;
413
+ }
414
+ const RepresentationType = 'MilestoneCompletedRepresentation';
415
+ function keyBuilder(luvio, config) {
416
+ return keyPrefix + '::' + RepresentationType + ':' + (config.requestId === null ? '' : config.requestId);
417
+ }
418
+ function keyBuilderFromType(luvio, object) {
419
+ const keyParams = {
420
+ requestId: object.milestoneId
421
+ };
422
+ return keyBuilder(luvio, keyParams);
423
+ }
424
+ function normalize(input, existing, path, luvio, store, timestamp) {
425
+ return input;
426
+ }
427
+ const select$1 = function MilestoneCompletedRepresentationSelect() {
428
+ return {
429
+ kind: 'Fragment',
430
+ version: VERSION,
431
+ private: [],
432
+ opaque: true
433
+ };
434
+ };
435
+ function equals(existing, incoming) {
436
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
437
+ return false;
438
+ }
439
+ return true;
440
+ }
441
+ const ingest = function MilestoneCompletedRepresentationIngest(input, path, luvio, store, timestamp) {
442
+ if (process.env.NODE_ENV !== 'production') {
443
+ const validateError = validate(input);
444
+ if (validateError !== null) {
445
+ throw validateError;
446
+ }
447
+ }
448
+ const key = keyBuilderFromType(luvio, input);
449
+ const ttlToUse = TTL;
450
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "Milestones", VERSION, RepresentationType, equals);
451
+ return createLink(key);
452
+ };
453
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
454
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
455
+ const rootKey = keyBuilderFromType(luvio, input);
456
+ rootKeySet.set(rootKey, {
457
+ namespace: keyPrefix,
458
+ representationName: RepresentationType,
459
+ mergeable: false
460
+ });
461
+ }
462
+
463
+ function select(luvio, params) {
464
+ return select$1();
465
+ }
466
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
467
+ getTypeCacheKeys(storeKeyMap, luvio, response);
468
+ }
469
+ function ingestSuccess(luvio, resourceParams, response) {
470
+ const { body } = response;
471
+ const key = keyBuilderFromType(luvio, body);
472
+ luvio.storeIngest(key, ingest, body);
473
+ const snapshot = luvio.storeLookup({
474
+ recordId: key,
475
+ node: select(),
476
+ variables: {},
477
+ });
478
+ if (process.env.NODE_ENV !== 'production') {
479
+ if (snapshot.state !== 'Fulfilled') {
480
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
481
+ }
482
+ }
483
+ deepFreeze(snapshot.data);
484
+ return snapshot;
485
+ }
486
+ function createResourceRequest(config) {
487
+ const headers = {};
488
+ return {
489
+ baseUri: '/services/data/v62.0',
490
+ basePath: '/connect/milestones/milestone-completed',
491
+ method: 'put',
492
+ body: null,
493
+ urlParams: {},
494
+ queryParams: config.queryParams,
495
+ headers,
496
+ priority: 'normal',
497
+ };
498
+ }
499
+
500
+ const adapterName = 'markMilestoneCompleted';
501
+ const markMilestoneCompleted_ConfigPropertyMetadata = [
502
+ generateParamConfigMetadata('milestoneId', false, 1 /* QueryParameter */, 4 /* Unsupported */),
503
+ ];
504
+ const markMilestoneCompleted_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, markMilestoneCompleted_ConfigPropertyMetadata);
505
+ const createResourceParams = /*#__PURE__*/ createResourceParams$2(markMilestoneCompleted_ConfigPropertyMetadata);
506
+ function typeCheckConfig(untrustedConfig) {
507
+ const config = {};
508
+ const untrustedConfig_milestoneId = untrustedConfig.milestoneId;
509
+ if (typeof untrustedConfig_milestoneId === 'string') {
510
+ config.milestoneId = untrustedConfig_milestoneId;
511
+ }
512
+ if (untrustedConfig_milestoneId === null) {
513
+ config.milestoneId = untrustedConfig_milestoneId;
514
+ }
515
+ return config;
516
+ }
517
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
518
+ if (!untrustedIsObject(untrustedConfig)) {
519
+ return null;
520
+ }
521
+ if (process.env.NODE_ENV !== 'production') {
522
+ validateConfig(untrustedConfig, configPropertyNames);
523
+ }
524
+ const config = typeCheckConfig(untrustedConfig);
525
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
526
+ return null;
527
+ }
528
+ return config;
529
+ }
530
+ function buildNetworkSnapshot(luvio, config, options) {
531
+ const resourceParams = createResourceParams(config);
532
+ const request = createResourceRequest(resourceParams);
533
+ return luvio.dispatchResourceRequest(request, options)
534
+ .then((response) => {
535
+ return luvio.handleSuccessResponse(() => {
536
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
537
+ return luvio.storeBroadcast().then(() => snapshot);
538
+ }, () => {
539
+ const cache = new StoreKeyMap();
540
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
541
+ return cache;
542
+ });
543
+ }, (response) => {
544
+ deepFreeze(response);
545
+ throw response;
546
+ });
547
+ }
548
+ const markMilestoneCompletedAdapterFactory = (luvio) => {
549
+ return function markMilestoneCompleted(untrustedConfig) {
550
+ const config = validateAdapterConfig(untrustedConfig, markMilestoneCompleted_ConfigPropertyNames);
551
+ // Invalid or incomplete config
552
+ if (config === null) {
553
+ throw new Error('Invalid config for "markMilestoneCompleted"');
554
+ }
555
+ return buildNetworkSnapshot(luvio, config);
556
+ };
557
+ };
558
+
559
+ export { getBusinessHoursAdapterFactory, markMilestoneCompletedAdapterFactory };