@salesforce/lds-adapters-platform-enablement 1.100.2

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.
@@ -0,0 +1,1455 @@
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, StoreKeyMap } from '@luvio/engine';
8
+
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys, freeze: ObjectFreeze, 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
+ const keyPrefix = 'enablement';
52
+
53
+ const { isArray: ArrayIsArray } = Array;
54
+ const { stringify: JSONStringify } = JSON;
55
+ function equalsArray(a, b, equalsItem) {
56
+ const aLength = a.length;
57
+ const bLength = b.length;
58
+ if (aLength !== bLength) {
59
+ return false;
60
+ }
61
+ for (let i = 0; i < aLength; i++) {
62
+ if (equalsItem(a[i], b[i]) === false) {
63
+ return false;
64
+ }
65
+ }
66
+ return true;
67
+ }
68
+ function createLink(ref) {
69
+ return {
70
+ __ref: serializeStructuredKey(ref),
71
+ };
72
+ }
73
+
74
+ var DiscriminatorValues;
75
+ (function (DiscriminatorValues) {
76
+ DiscriminatorValues["Task"] = "Task";
77
+ DiscriminatorValues["Section"] = "Section";
78
+ })(DiscriminatorValues || (DiscriminatorValues = {}));
79
+ const VERSION$3 = "a9470f37b0d95500b425222897fff882";
80
+ function validate$3(obj, path = 'EnablementProgramSummaryItemRepresentation') {
81
+ const v_error = (() => {
82
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
83
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
84
+ }
85
+ const obj_description = obj.description;
86
+ const path_description = path + '.description';
87
+ if (typeof obj_description !== 'string') {
88
+ return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
89
+ }
90
+ const obj_id = obj.id;
91
+ const path_id = path + '.id';
92
+ if (typeof obj_id !== 'string') {
93
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
94
+ }
95
+ const obj_sequenceNumber = obj.sequenceNumber;
96
+ const path_sequenceNumber = path + '.sequenceNumber';
97
+ if (typeof obj_sequenceNumber !== 'number' || (typeof obj_sequenceNumber === 'number' && Math.floor(obj_sequenceNumber) !== obj_sequenceNumber)) {
98
+ return new TypeError('Expected "integer" but received "' + typeof obj_sequenceNumber + '" (at "' + path_sequenceNumber + '")');
99
+ }
100
+ const obj_title = obj.title;
101
+ const path_title = path + '.title';
102
+ if (typeof obj_title !== 'string') {
103
+ return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
104
+ }
105
+ const obj_type = obj.type;
106
+ const path_type = path + '.type';
107
+ if (typeof obj_type !== 'string') {
108
+ return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
109
+ }
110
+ })();
111
+ return v_error === undefined ? null : v_error;
112
+ }
113
+ const select$5 = function EnablementProgramSummaryItemRepresentationSelect() {
114
+ return {
115
+ kind: 'Fragment',
116
+ version: VERSION$3,
117
+ private: [],
118
+ selections: [
119
+ {
120
+ name: 'description',
121
+ kind: 'Scalar'
122
+ },
123
+ {
124
+ name: 'id',
125
+ kind: 'Scalar'
126
+ },
127
+ {
128
+ name: 'sequenceNumber',
129
+ kind: 'Scalar'
130
+ },
131
+ {
132
+ name: 'title',
133
+ kind: 'Scalar'
134
+ },
135
+ {
136
+ name: 'type',
137
+ kind: 'Scalar'
138
+ }
139
+ ]
140
+ };
141
+ };
142
+ function equals$3(existing, incoming) {
143
+ const existing_sequenceNumber = existing.sequenceNumber;
144
+ const incoming_sequenceNumber = incoming.sequenceNumber;
145
+ if (!(existing_sequenceNumber === incoming_sequenceNumber)) {
146
+ return false;
147
+ }
148
+ const existing_description = existing.description;
149
+ const incoming_description = incoming.description;
150
+ if (!(existing_description === incoming_description)) {
151
+ return false;
152
+ }
153
+ const existing_id = existing.id;
154
+ const incoming_id = incoming.id;
155
+ if (!(existing_id === incoming_id)) {
156
+ return false;
157
+ }
158
+ const existing_title = existing.title;
159
+ const incoming_title = incoming.title;
160
+ if (!(existing_title === incoming_title)) {
161
+ return false;
162
+ }
163
+ const existing_type = existing.type;
164
+ const incoming_type = incoming.type;
165
+ if (!(existing_type === incoming_type)) {
166
+ return false;
167
+ }
168
+ return true;
169
+ }
170
+
171
+ const VERSION$2 = "4c8624037e7270f09e6a41f95632e74b";
172
+ function validate$2(obj, path = 'EnablementProgramSummaryTaskRepresentation') {
173
+ const validateEnablementProgramSummaryItemRepresentation_validateError = validate$3(obj, path);
174
+ if (validateEnablementProgramSummaryItemRepresentation_validateError !== null) {
175
+ return validateEnablementProgramSummaryItemRepresentation_validateError;
176
+ }
177
+ const v_error = (() => {
178
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
179
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
180
+ }
181
+ const obj_completedDate = obj.completedDate;
182
+ const path_completedDate = path + '.completedDate';
183
+ let obj_completedDate_union0 = null;
184
+ const obj_completedDate_union0_error = (() => {
185
+ if (typeof obj_completedDate !== 'string') {
186
+ return new TypeError('Expected "string" but received "' + typeof obj_completedDate + '" (at "' + path_completedDate + '")');
187
+ }
188
+ })();
189
+ if (obj_completedDate_union0_error != null) {
190
+ obj_completedDate_union0 = obj_completedDate_union0_error.message;
191
+ }
192
+ let obj_completedDate_union1 = null;
193
+ const obj_completedDate_union1_error = (() => {
194
+ if (obj_completedDate !== null) {
195
+ return new TypeError('Expected "null" but received "' + typeof obj_completedDate + '" (at "' + path_completedDate + '")');
196
+ }
197
+ })();
198
+ if (obj_completedDate_union1_error != null) {
199
+ obj_completedDate_union1 = obj_completedDate_union1_error.message;
200
+ }
201
+ if (obj_completedDate_union0 && obj_completedDate_union1) {
202
+ let message = 'Object doesn\'t match union (at "' + path_completedDate + '")';
203
+ message += '\n' + obj_completedDate_union0.split('\n').map((line) => '\t' + line).join('\n');
204
+ message += '\n' + obj_completedDate_union1.split('\n').map((line) => '\t' + line).join('\n');
205
+ return new TypeError(message);
206
+ }
207
+ const obj_completedPercent = obj.completedPercent;
208
+ const path_completedPercent = path + '.completedPercent';
209
+ let obj_completedPercent_union0 = null;
210
+ const obj_completedPercent_union0_error = (() => {
211
+ if (typeof obj_completedPercent !== 'number') {
212
+ return new TypeError('Expected "number" but received "' + typeof obj_completedPercent + '" (at "' + path_completedPercent + '")');
213
+ }
214
+ })();
215
+ if (obj_completedPercent_union0_error != null) {
216
+ obj_completedPercent_union0 = obj_completedPercent_union0_error.message;
217
+ }
218
+ let obj_completedPercent_union1 = null;
219
+ const obj_completedPercent_union1_error = (() => {
220
+ if (obj_completedPercent !== null) {
221
+ return new TypeError('Expected "null" but received "' + typeof obj_completedPercent + '" (at "' + path_completedPercent + '")');
222
+ }
223
+ })();
224
+ if (obj_completedPercent_union1_error != null) {
225
+ obj_completedPercent_union1 = obj_completedPercent_union1_error.message;
226
+ }
227
+ if (obj_completedPercent_union0 && obj_completedPercent_union1) {
228
+ let message = 'Object doesn\'t match union (at "' + path_completedPercent + '")';
229
+ message += '\n' + obj_completedPercent_union0.split('\n').map((line) => '\t' + line).join('\n');
230
+ message += '\n' + obj_completedPercent_union1.split('\n').map((line) => '\t' + line).join('\n');
231
+ return new TypeError(message);
232
+ }
233
+ const obj_contributingRecordCount = obj.contributingRecordCount;
234
+ const path_contributingRecordCount = path + '.contributingRecordCount';
235
+ let obj_contributingRecordCount_union0 = null;
236
+ const obj_contributingRecordCount_union0_error = (() => {
237
+ if (typeof obj_contributingRecordCount !== 'number' || (typeof obj_contributingRecordCount === 'number' && Math.floor(obj_contributingRecordCount) !== obj_contributingRecordCount)) {
238
+ return new TypeError('Expected "integer" but received "' + typeof obj_contributingRecordCount + '" (at "' + path_contributingRecordCount + '")');
239
+ }
240
+ })();
241
+ if (obj_contributingRecordCount_union0_error != null) {
242
+ obj_contributingRecordCount_union0 = obj_contributingRecordCount_union0_error.message;
243
+ }
244
+ let obj_contributingRecordCount_union1 = null;
245
+ const obj_contributingRecordCount_union1_error = (() => {
246
+ if (obj_contributingRecordCount !== null) {
247
+ return new TypeError('Expected "null" but received "' + typeof obj_contributingRecordCount + '" (at "' + path_contributingRecordCount + '")');
248
+ }
249
+ })();
250
+ if (obj_contributingRecordCount_union1_error != null) {
251
+ obj_contributingRecordCount_union1 = obj_contributingRecordCount_union1_error.message;
252
+ }
253
+ if (obj_contributingRecordCount_union0 && obj_contributingRecordCount_union1) {
254
+ let message = 'Object doesn\'t match union (at "' + path_contributingRecordCount + '")';
255
+ message += '\n' + obj_contributingRecordCount_union0.split('\n').map((line) => '\t' + line).join('\n');
256
+ message += '\n' + obj_contributingRecordCount_union1.split('\n').map((line) => '\t' + line).join('\n');
257
+ return new TypeError(message);
258
+ }
259
+ const obj_dueDate = obj.dueDate;
260
+ const path_dueDate = path + '.dueDate';
261
+ let obj_dueDate_union0 = null;
262
+ const obj_dueDate_union0_error = (() => {
263
+ if (typeof obj_dueDate !== 'string') {
264
+ return new TypeError('Expected "string" but received "' + typeof obj_dueDate + '" (at "' + path_dueDate + '")');
265
+ }
266
+ })();
267
+ if (obj_dueDate_union0_error != null) {
268
+ obj_dueDate_union0 = obj_dueDate_union0_error.message;
269
+ }
270
+ let obj_dueDate_union1 = null;
271
+ const obj_dueDate_union1_error = (() => {
272
+ if (obj_dueDate !== null) {
273
+ return new TypeError('Expected "null" but received "' + typeof obj_dueDate + '" (at "' + path_dueDate + '")');
274
+ }
275
+ })();
276
+ if (obj_dueDate_union1_error != null) {
277
+ obj_dueDate_union1 = obj_dueDate_union1_error.message;
278
+ }
279
+ if (obj_dueDate_union0 && obj_dueDate_union1) {
280
+ let message = 'Object doesn\'t match union (at "' + path_dueDate + '")';
281
+ message += '\n' + obj_dueDate_union0.split('\n').map((line) => '\t' + line).join('\n');
282
+ message += '\n' + obj_dueDate_union1.split('\n').map((line) => '\t' + line).join('\n');
283
+ return new TypeError(message);
284
+ }
285
+ const obj_enablementProgramSectionId = obj.enablementProgramSectionId;
286
+ const path_enablementProgramSectionId = path + '.enablementProgramSectionId';
287
+ let obj_enablementProgramSectionId_union0 = null;
288
+ const obj_enablementProgramSectionId_union0_error = (() => {
289
+ if (typeof obj_enablementProgramSectionId !== 'string') {
290
+ return new TypeError('Expected "string" but received "' + typeof obj_enablementProgramSectionId + '" (at "' + path_enablementProgramSectionId + '")');
291
+ }
292
+ })();
293
+ if (obj_enablementProgramSectionId_union0_error != null) {
294
+ obj_enablementProgramSectionId_union0 = obj_enablementProgramSectionId_union0_error.message;
295
+ }
296
+ let obj_enablementProgramSectionId_union1 = null;
297
+ const obj_enablementProgramSectionId_union1_error = (() => {
298
+ if (obj_enablementProgramSectionId !== null) {
299
+ return new TypeError('Expected "null" but received "' + typeof obj_enablementProgramSectionId + '" (at "' + path_enablementProgramSectionId + '")');
300
+ }
301
+ })();
302
+ if (obj_enablementProgramSectionId_union1_error != null) {
303
+ obj_enablementProgramSectionId_union1 = obj_enablementProgramSectionId_union1_error.message;
304
+ }
305
+ if (obj_enablementProgramSectionId_union0 && obj_enablementProgramSectionId_union1) {
306
+ let message = 'Object doesn\'t match union (at "' + path_enablementProgramSectionId + '")';
307
+ message += '\n' + obj_enablementProgramSectionId_union0.split('\n').map((line) => '\t' + line).join('\n');
308
+ message += '\n' + obj_enablementProgramSectionId_union1.split('\n').map((line) => '\t' + line).join('\n');
309
+ return new TypeError(message);
310
+ }
311
+ const obj_isCompleted = obj.isCompleted;
312
+ const path_isCompleted = path + '.isCompleted';
313
+ let obj_isCompleted_union0 = null;
314
+ const obj_isCompleted_union0_error = (() => {
315
+ if (typeof obj_isCompleted !== 'boolean') {
316
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isCompleted + '" (at "' + path_isCompleted + '")');
317
+ }
318
+ })();
319
+ if (obj_isCompleted_union0_error != null) {
320
+ obj_isCompleted_union0 = obj_isCompleted_union0_error.message;
321
+ }
322
+ let obj_isCompleted_union1 = null;
323
+ const obj_isCompleted_union1_error = (() => {
324
+ if (obj_isCompleted !== null) {
325
+ return new TypeError('Expected "null" but received "' + typeof obj_isCompleted + '" (at "' + path_isCompleted + '")');
326
+ }
327
+ })();
328
+ if (obj_isCompleted_union1_error != null) {
329
+ obj_isCompleted_union1 = obj_isCompleted_union1_error.message;
330
+ }
331
+ if (obj_isCompleted_union0 && obj_isCompleted_union1) {
332
+ let message = 'Object doesn\'t match union (at "' + path_isCompleted + '")';
333
+ message += '\n' + obj_isCompleted_union0.split('\n').map((line) => '\t' + line).join('\n');
334
+ message += '\n' + obj_isCompleted_union1.split('\n').map((line) => '\t' + line).join('\n');
335
+ return new TypeError(message);
336
+ }
337
+ const obj_isOverdue = obj.isOverdue;
338
+ const path_isOverdue = path + '.isOverdue';
339
+ let obj_isOverdue_union0 = null;
340
+ const obj_isOverdue_union0_error = (() => {
341
+ if (typeof obj_isOverdue !== 'boolean') {
342
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isOverdue + '" (at "' + path_isOverdue + '")');
343
+ }
344
+ })();
345
+ if (obj_isOverdue_union0_error != null) {
346
+ obj_isOverdue_union0 = obj_isOverdue_union0_error.message;
347
+ }
348
+ let obj_isOverdue_union1 = null;
349
+ const obj_isOverdue_union1_error = (() => {
350
+ if (obj_isOverdue !== null) {
351
+ return new TypeError('Expected "null" but received "' + typeof obj_isOverdue + '" (at "' + path_isOverdue + '")');
352
+ }
353
+ })();
354
+ if (obj_isOverdue_union1_error != null) {
355
+ obj_isOverdue_union1 = obj_isOverdue_union1_error.message;
356
+ }
357
+ if (obj_isOverdue_union0 && obj_isOverdue_union1) {
358
+ let message = 'Object doesn\'t match union (at "' + path_isOverdue + '")';
359
+ message += '\n' + obj_isOverdue_union0.split('\n').map((line) => '\t' + line).join('\n');
360
+ message += '\n' + obj_isOverdue_union1.split('\n').map((line) => '\t' + line).join('\n');
361
+ return new TypeError(message);
362
+ }
363
+ const obj_learningItemId = obj.learningItemId;
364
+ const path_learningItemId = path + '.learningItemId';
365
+ let obj_learningItemId_union0 = null;
366
+ const obj_learningItemId_union0_error = (() => {
367
+ if (typeof obj_learningItemId !== 'string') {
368
+ return new TypeError('Expected "string" but received "' + typeof obj_learningItemId + '" (at "' + path_learningItemId + '")');
369
+ }
370
+ })();
371
+ if (obj_learningItemId_union0_error != null) {
372
+ obj_learningItemId_union0 = obj_learningItemId_union0_error.message;
373
+ }
374
+ let obj_learningItemId_union1 = null;
375
+ const obj_learningItemId_union1_error = (() => {
376
+ if (obj_learningItemId !== null) {
377
+ return new TypeError('Expected "null" but received "' + typeof obj_learningItemId + '" (at "' + path_learningItemId + '")');
378
+ }
379
+ })();
380
+ if (obj_learningItemId_union1_error != null) {
381
+ obj_learningItemId_union1 = obj_learningItemId_union1_error.message;
382
+ }
383
+ if (obj_learningItemId_union0 && obj_learningItemId_union1) {
384
+ let message = 'Object doesn\'t match union (at "' + path_learningItemId + '")';
385
+ message += '\n' + obj_learningItemId_union0.split('\n').map((line) => '\t' + line).join('\n');
386
+ message += '\n' + obj_learningItemId_union1.split('\n').map((line) => '\t' + line).join('\n');
387
+ return new TypeError(message);
388
+ }
389
+ const obj_milestoneResult = obj.milestoneResult;
390
+ const path_milestoneResult = path + '.milestoneResult';
391
+ let obj_milestoneResult_union0 = null;
392
+ const obj_milestoneResult_union0_error = (() => {
393
+ if (typeof obj_milestoneResult !== 'number') {
394
+ return new TypeError('Expected "number" but received "' + typeof obj_milestoneResult + '" (at "' + path_milestoneResult + '")');
395
+ }
396
+ })();
397
+ if (obj_milestoneResult_union0_error != null) {
398
+ obj_milestoneResult_union0 = obj_milestoneResult_union0_error.message;
399
+ }
400
+ let obj_milestoneResult_union1 = null;
401
+ const obj_milestoneResult_union1_error = (() => {
402
+ if (obj_milestoneResult !== null) {
403
+ return new TypeError('Expected "null" but received "' + typeof obj_milestoneResult + '" (at "' + path_milestoneResult + '")');
404
+ }
405
+ })();
406
+ if (obj_milestoneResult_union1_error != null) {
407
+ obj_milestoneResult_union1 = obj_milestoneResult_union1_error.message;
408
+ }
409
+ if (obj_milestoneResult_union0 && obj_milestoneResult_union1) {
410
+ let message = 'Object doesn\'t match union (at "' + path_milestoneResult + '")';
411
+ message += '\n' + obj_milestoneResult_union0.split('\n').map((line) => '\t' + line).join('\n');
412
+ message += '\n' + obj_milestoneResult_union1.split('\n').map((line) => '\t' + line).join('\n');
413
+ return new TypeError(message);
414
+ }
415
+ const obj_milestoneTarget = obj.milestoneTarget;
416
+ const path_milestoneTarget = path + '.milestoneTarget';
417
+ let obj_milestoneTarget_union0 = null;
418
+ const obj_milestoneTarget_union0_error = (() => {
419
+ if (typeof obj_milestoneTarget !== 'number') {
420
+ return new TypeError('Expected "number" but received "' + typeof obj_milestoneTarget + '" (at "' + path_milestoneTarget + '")');
421
+ }
422
+ })();
423
+ if (obj_milestoneTarget_union0_error != null) {
424
+ obj_milestoneTarget_union0 = obj_milestoneTarget_union0_error.message;
425
+ }
426
+ let obj_milestoneTarget_union1 = null;
427
+ const obj_milestoneTarget_union1_error = (() => {
428
+ if (obj_milestoneTarget !== null) {
429
+ return new TypeError('Expected "null" but received "' + typeof obj_milestoneTarget + '" (at "' + path_milestoneTarget + '")');
430
+ }
431
+ })();
432
+ if (obj_milestoneTarget_union1_error != null) {
433
+ obj_milestoneTarget_union1 = obj_milestoneTarget_union1_error.message;
434
+ }
435
+ if (obj_milestoneTarget_union0 && obj_milestoneTarget_union1) {
436
+ let message = 'Object doesn\'t match union (at "' + path_milestoneTarget + '")';
437
+ message += '\n' + obj_milestoneTarget_union0.split('\n').map((line) => '\t' + line).join('\n');
438
+ message += '\n' + obj_milestoneTarget_union1.split('\n').map((line) => '\t' + line).join('\n');
439
+ return new TypeError(message);
440
+ }
441
+ const obj_minimumSampleSize = obj.minimumSampleSize;
442
+ const path_minimumSampleSize = path + '.minimumSampleSize';
443
+ let obj_minimumSampleSize_union0 = null;
444
+ const obj_minimumSampleSize_union0_error = (() => {
445
+ if (typeof obj_minimumSampleSize !== 'number' || (typeof obj_minimumSampleSize === 'number' && Math.floor(obj_minimumSampleSize) !== obj_minimumSampleSize)) {
446
+ return new TypeError('Expected "integer" but received "' + typeof obj_minimumSampleSize + '" (at "' + path_minimumSampleSize + '")');
447
+ }
448
+ })();
449
+ if (obj_minimumSampleSize_union0_error != null) {
450
+ obj_minimumSampleSize_union0 = obj_minimumSampleSize_union0_error.message;
451
+ }
452
+ let obj_minimumSampleSize_union1 = null;
453
+ const obj_minimumSampleSize_union1_error = (() => {
454
+ if (obj_minimumSampleSize !== null) {
455
+ return new TypeError('Expected "null" but received "' + typeof obj_minimumSampleSize + '" (at "' + path_minimumSampleSize + '")');
456
+ }
457
+ })();
458
+ if (obj_minimumSampleSize_union1_error != null) {
459
+ obj_minimumSampleSize_union1 = obj_minimumSampleSize_union1_error.message;
460
+ }
461
+ if (obj_minimumSampleSize_union0 && obj_minimumSampleSize_union1) {
462
+ let message = 'Object doesn\'t match union (at "' + path_minimumSampleSize + '")';
463
+ message += '\n' + obj_minimumSampleSize_union0.split('\n').map((line) => '\t' + line).join('\n');
464
+ message += '\n' + obj_minimumSampleSize_union1.split('\n').map((line) => '\t' + line).join('\n');
465
+ return new TypeError(message);
466
+ }
467
+ const obj_programDay = obj.programDay;
468
+ const path_programDay = path + '.programDay';
469
+ if (typeof obj_programDay !== 'number' || (typeof obj_programDay === 'number' && Math.floor(obj_programDay) !== obj_programDay)) {
470
+ return new TypeError('Expected "integer" but received "' + typeof obj_programDay + '" (at "' + path_programDay + '")');
471
+ }
472
+ const obj_taskCategory = obj.taskCategory;
473
+ const path_taskCategory = path + '.taskCategory';
474
+ if (typeof obj_taskCategory !== 'string') {
475
+ return new TypeError('Expected "string" but received "' + typeof obj_taskCategory + '" (at "' + path_taskCategory + '")');
476
+ }
477
+ const obj_taskSubCategory = obj.taskSubCategory;
478
+ const path_taskSubCategory = path + '.taskSubCategory';
479
+ if (typeof obj_taskSubCategory !== 'string') {
480
+ return new TypeError('Expected "string" but received "' + typeof obj_taskSubCategory + '" (at "' + path_taskSubCategory + '")');
481
+ }
482
+ })();
483
+ return v_error === undefined ? null : v_error;
484
+ }
485
+ const select$4 = function EnablementProgramSummaryTaskRepresentationSelect() {
486
+ const { selections: EnablementProgramSummaryItemRepresentationSelections } = select$5();
487
+ return {
488
+ kind: 'Fragment',
489
+ version: VERSION$2,
490
+ private: [],
491
+ selections: [
492
+ ...EnablementProgramSummaryItemRepresentationSelections,
493
+ {
494
+ name: 'completedDate',
495
+ kind: 'Scalar'
496
+ },
497
+ {
498
+ name: 'completedPercent',
499
+ kind: 'Scalar'
500
+ },
501
+ {
502
+ name: 'contributingRecordCount',
503
+ kind: 'Scalar'
504
+ },
505
+ {
506
+ name: 'dueDate',
507
+ kind: 'Scalar'
508
+ },
509
+ {
510
+ name: 'enablementProgramSectionId',
511
+ kind: 'Scalar'
512
+ },
513
+ {
514
+ name: 'isCompleted',
515
+ kind: 'Scalar'
516
+ },
517
+ {
518
+ name: 'isOverdue',
519
+ kind: 'Scalar'
520
+ },
521
+ {
522
+ name: 'learningItemId',
523
+ kind: 'Scalar'
524
+ },
525
+ {
526
+ name: 'milestoneResult',
527
+ kind: 'Scalar'
528
+ },
529
+ {
530
+ name: 'milestoneTarget',
531
+ kind: 'Scalar'
532
+ },
533
+ {
534
+ name: 'minimumSampleSize',
535
+ kind: 'Scalar'
536
+ },
537
+ {
538
+ name: 'programDay',
539
+ kind: 'Scalar'
540
+ },
541
+ {
542
+ name: 'taskCategory',
543
+ kind: 'Scalar'
544
+ },
545
+ {
546
+ name: 'taskSubCategory',
547
+ kind: 'Scalar'
548
+ }
549
+ ]
550
+ };
551
+ };
552
+ function equals$2(existing, incoming) {
553
+ if (equals$3(existing, incoming) === false) {
554
+ return false;
555
+ }
556
+ const existing_programDay = existing.programDay;
557
+ const incoming_programDay = incoming.programDay;
558
+ if (!(existing_programDay === incoming_programDay)) {
559
+ return false;
560
+ }
561
+ const existing_taskCategory = existing.taskCategory;
562
+ const incoming_taskCategory = incoming.taskCategory;
563
+ if (!(existing_taskCategory === incoming_taskCategory)) {
564
+ return false;
565
+ }
566
+ const existing_taskSubCategory = existing.taskSubCategory;
567
+ const incoming_taskSubCategory = incoming.taskSubCategory;
568
+ if (!(existing_taskSubCategory === incoming_taskSubCategory)) {
569
+ return false;
570
+ }
571
+ const existing_completedDate = existing.completedDate;
572
+ const incoming_completedDate = incoming.completedDate;
573
+ if (!(existing_completedDate === incoming_completedDate)) {
574
+ return false;
575
+ }
576
+ const existing_completedPercent = existing.completedPercent;
577
+ const incoming_completedPercent = incoming.completedPercent;
578
+ if (!(existing_completedPercent === incoming_completedPercent)) {
579
+ return false;
580
+ }
581
+ const existing_contributingRecordCount = existing.contributingRecordCount;
582
+ const incoming_contributingRecordCount = incoming.contributingRecordCount;
583
+ if (!(existing_contributingRecordCount === incoming_contributingRecordCount)) {
584
+ return false;
585
+ }
586
+ const existing_dueDate = existing.dueDate;
587
+ const incoming_dueDate = incoming.dueDate;
588
+ if (!(existing_dueDate === incoming_dueDate)) {
589
+ return false;
590
+ }
591
+ const existing_enablementProgramSectionId = existing.enablementProgramSectionId;
592
+ const incoming_enablementProgramSectionId = incoming.enablementProgramSectionId;
593
+ if (!(existing_enablementProgramSectionId === incoming_enablementProgramSectionId)) {
594
+ return false;
595
+ }
596
+ const existing_isCompleted = existing.isCompleted;
597
+ const incoming_isCompleted = incoming.isCompleted;
598
+ if (!(existing_isCompleted === incoming_isCompleted)) {
599
+ return false;
600
+ }
601
+ const existing_isOverdue = existing.isOverdue;
602
+ const incoming_isOverdue = incoming.isOverdue;
603
+ if (!(existing_isOverdue === incoming_isOverdue)) {
604
+ return false;
605
+ }
606
+ const existing_learningItemId = existing.learningItemId;
607
+ const incoming_learningItemId = incoming.learningItemId;
608
+ if (!(existing_learningItemId === incoming_learningItemId)) {
609
+ return false;
610
+ }
611
+ const existing_milestoneResult = existing.milestoneResult;
612
+ const incoming_milestoneResult = incoming.milestoneResult;
613
+ if (!(existing_milestoneResult === incoming_milestoneResult)) {
614
+ return false;
615
+ }
616
+ const existing_milestoneTarget = existing.milestoneTarget;
617
+ const incoming_milestoneTarget = incoming.milestoneTarget;
618
+ if (!(existing_milestoneTarget === incoming_milestoneTarget)) {
619
+ return false;
620
+ }
621
+ const existing_minimumSampleSize = existing.minimumSampleSize;
622
+ const incoming_minimumSampleSize = incoming.minimumSampleSize;
623
+ if (!(existing_minimumSampleSize === incoming_minimumSampleSize)) {
624
+ return false;
625
+ }
626
+ return true;
627
+ }
628
+
629
+ const TTL = 15000;
630
+ const VERSION$1 = "83df796ee9af3bf09f5729eac8b86d08";
631
+ function validate$1(obj, path = 'EnablementProgramSummaryRepresentation') {
632
+ const v_error = (() => {
633
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
634
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
635
+ }
636
+ const obj_description = obj.description;
637
+ const path_description = path + '.description';
638
+ let obj_description_union0 = null;
639
+ const obj_description_union0_error = (() => {
640
+ if (typeof obj_description !== 'string') {
641
+ return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
642
+ }
643
+ })();
644
+ if (obj_description_union0_error != null) {
645
+ obj_description_union0 = obj_description_union0_error.message;
646
+ }
647
+ let obj_description_union1 = null;
648
+ const obj_description_union1_error = (() => {
649
+ if (obj_description !== null) {
650
+ return new TypeError('Expected "null" but received "' + typeof obj_description + '" (at "' + path_description + '")');
651
+ }
652
+ })();
653
+ if (obj_description_union1_error != null) {
654
+ obj_description_union1 = obj_description_union1_error.message;
655
+ }
656
+ if (obj_description_union0 && obj_description_union1) {
657
+ let message = 'Object doesn\'t match union (at "' + path_description + '")';
658
+ message += '\n' + obj_description_union0.split('\n').map((line) => '\t' + line).join('\n');
659
+ message += '\n' + obj_description_union1.split('\n').map((line) => '\t' + line).join('\n');
660
+ return new TypeError(message);
661
+ }
662
+ const obj_dueDate = obj.dueDate;
663
+ const path_dueDate = path + '.dueDate';
664
+ let obj_dueDate_union0 = null;
665
+ const obj_dueDate_union0_error = (() => {
666
+ if (typeof obj_dueDate !== 'string') {
667
+ return new TypeError('Expected "string" but received "' + typeof obj_dueDate + '" (at "' + path_dueDate + '")');
668
+ }
669
+ })();
670
+ if (obj_dueDate_union0_error != null) {
671
+ obj_dueDate_union0 = obj_dueDate_union0_error.message;
672
+ }
673
+ let obj_dueDate_union1 = null;
674
+ const obj_dueDate_union1_error = (() => {
675
+ if (obj_dueDate !== null) {
676
+ return new TypeError('Expected "null" but received "' + typeof obj_dueDate + '" (at "' + path_dueDate + '")');
677
+ }
678
+ })();
679
+ if (obj_dueDate_union1_error != null) {
680
+ obj_dueDate_union1 = obj_dueDate_union1_error.message;
681
+ }
682
+ if (obj_dueDate_union0 && obj_dueDate_union1) {
683
+ let message = 'Object doesn\'t match union (at "' + path_dueDate + '")';
684
+ message += '\n' + obj_dueDate_union0.split('\n').map((line) => '\t' + line).join('\n');
685
+ message += '\n' + obj_dueDate_union1.split('\n').map((line) => '\t' + line).join('\n');
686
+ return new TypeError(message);
687
+ }
688
+ const obj_id = obj.id;
689
+ const path_id = path + '.id';
690
+ let obj_id_union0 = null;
691
+ const obj_id_union0_error = (() => {
692
+ if (typeof obj_id !== 'string') {
693
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
694
+ }
695
+ })();
696
+ if (obj_id_union0_error != null) {
697
+ obj_id_union0 = obj_id_union0_error.message;
698
+ }
699
+ let obj_id_union1 = null;
700
+ const obj_id_union1_error = (() => {
701
+ if (obj_id !== null) {
702
+ return new TypeError('Expected "null" but received "' + typeof obj_id + '" (at "' + path_id + '")');
703
+ }
704
+ })();
705
+ if (obj_id_union1_error != null) {
706
+ obj_id_union1 = obj_id_union1_error.message;
707
+ }
708
+ if (obj_id_union0 && obj_id_union1) {
709
+ let message = 'Object doesn\'t match union (at "' + path_id + '")';
710
+ message += '\n' + obj_id_union0.split('\n').map((line) => '\t' + line).join('\n');
711
+ message += '\n' + obj_id_union1.split('\n').map((line) => '\t' + line).join('\n');
712
+ return new TypeError(message);
713
+ }
714
+ const obj_items = obj.items;
715
+ const path_items = path + '.items';
716
+ if (!ArrayIsArray(obj_items)) {
717
+ return new TypeError('Expected "array" but received "' + typeof obj_items + '" (at "' + path_items + '")');
718
+ }
719
+ for (let i = 0; i < obj_items.length; i++) {
720
+ const obj_items_item = obj_items[i];
721
+ const path_items_item = path_items + '[' + i + ']';
722
+ if (obj_items_item === undefined) {
723
+ return new TypeError('Expected "defined" but received "' + typeof obj_items_item + '" (at "' + path_items_item + '")');
724
+ }
725
+ }
726
+ const obj_learningItemId = obj.learningItemId;
727
+ const path_learningItemId = path + '.learningItemId';
728
+ let obj_learningItemId_union0 = null;
729
+ const obj_learningItemId_union0_error = (() => {
730
+ if (typeof obj_learningItemId !== 'string') {
731
+ return new TypeError('Expected "string" but received "' + typeof obj_learningItemId + '" (at "' + path_learningItemId + '")');
732
+ }
733
+ })();
734
+ if (obj_learningItemId_union0_error != null) {
735
+ obj_learningItemId_union0 = obj_learningItemId_union0_error.message;
736
+ }
737
+ let obj_learningItemId_union1 = null;
738
+ const obj_learningItemId_union1_error = (() => {
739
+ if (obj_learningItemId !== null) {
740
+ return new TypeError('Expected "null" but received "' + typeof obj_learningItemId + '" (at "' + path_learningItemId + '")');
741
+ }
742
+ })();
743
+ if (obj_learningItemId_union1_error != null) {
744
+ obj_learningItemId_union1 = obj_learningItemId_union1_error.message;
745
+ }
746
+ if (obj_learningItemId_union0 && obj_learningItemId_union1) {
747
+ let message = 'Object doesn\'t match union (at "' + path_learningItemId + '")';
748
+ message += '\n' + obj_learningItemId_union0.split('\n').map((line) => '\t' + line).join('\n');
749
+ message += '\n' + obj_learningItemId_union1.split('\n').map((line) => '\t' + line).join('\n');
750
+ return new TypeError(message);
751
+ }
752
+ const obj_outcome = obj.outcome;
753
+ const path_outcome = path + '.outcome';
754
+ let obj_outcome_union0 = null;
755
+ const obj_outcome_union0_error = (() => {
756
+ const referencepath_outcomeValidationError = validate$2(obj_outcome, path_outcome);
757
+ if (referencepath_outcomeValidationError !== null) {
758
+ let message = 'Object doesn\'t match EnablementProgramSummaryTaskRepresentation (at "' + path_outcome + '")\n';
759
+ message += referencepath_outcomeValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
760
+ return new TypeError(message);
761
+ }
762
+ })();
763
+ if (obj_outcome_union0_error != null) {
764
+ obj_outcome_union0 = obj_outcome_union0_error.message;
765
+ }
766
+ let obj_outcome_union1 = null;
767
+ const obj_outcome_union1_error = (() => {
768
+ if (obj_outcome !== null) {
769
+ return new TypeError('Expected "null" but received "' + typeof obj_outcome + '" (at "' + path_outcome + '")');
770
+ }
771
+ })();
772
+ if (obj_outcome_union1_error != null) {
773
+ obj_outcome_union1 = obj_outcome_union1_error.message;
774
+ }
775
+ if (obj_outcome_union0 && obj_outcome_union1) {
776
+ let message = 'Object doesn\'t match union (at "' + path_outcome + '")';
777
+ message += '\n' + obj_outcome_union0.split('\n').map((line) => '\t' + line).join('\n');
778
+ message += '\n' + obj_outcome_union1.split('\n').map((line) => '\t' + line).join('\n');
779
+ return new TypeError(message);
780
+ }
781
+ const obj_status = obj.status;
782
+ const path_status = path + '.status';
783
+ if (typeof obj_status !== 'string') {
784
+ return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
785
+ }
786
+ if (obj.systemModStamp !== undefined) {
787
+ const obj_systemModStamp = obj.systemModStamp;
788
+ const path_systemModStamp = path + '.systemModStamp';
789
+ let obj_systemModStamp_union0 = null;
790
+ const obj_systemModStamp_union0_error = (() => {
791
+ if (typeof obj_systemModStamp !== 'string') {
792
+ return new TypeError('Expected "string" but received "' + typeof obj_systemModStamp + '" (at "' + path_systemModStamp + '")');
793
+ }
794
+ })();
795
+ if (obj_systemModStamp_union0_error != null) {
796
+ obj_systemModStamp_union0 = obj_systemModStamp_union0_error.message;
797
+ }
798
+ let obj_systemModStamp_union1 = null;
799
+ const obj_systemModStamp_union1_error = (() => {
800
+ if (obj_systemModStamp !== null) {
801
+ return new TypeError('Expected "null" but received "' + typeof obj_systemModStamp + '" (at "' + path_systemModStamp + '")');
802
+ }
803
+ })();
804
+ if (obj_systemModStamp_union1_error != null) {
805
+ obj_systemModStamp_union1 = obj_systemModStamp_union1_error.message;
806
+ }
807
+ if (obj_systemModStamp_union0 && obj_systemModStamp_union1) {
808
+ let message = 'Object doesn\'t match union (at "' + path_systemModStamp + '")';
809
+ message += '\n' + obj_systemModStamp_union0.split('\n').map((line) => '\t' + line).join('\n');
810
+ message += '\n' + obj_systemModStamp_union1.split('\n').map((line) => '\t' + line).join('\n');
811
+ return new TypeError(message);
812
+ }
813
+ }
814
+ const obj_title = obj.title;
815
+ const path_title = path + '.title';
816
+ let obj_title_union0 = null;
817
+ const obj_title_union0_error = (() => {
818
+ if (typeof obj_title !== 'string') {
819
+ return new TypeError('Expected "string" but received "' + typeof obj_title + '" (at "' + path_title + '")');
820
+ }
821
+ })();
822
+ if (obj_title_union0_error != null) {
823
+ obj_title_union0 = obj_title_union0_error.message;
824
+ }
825
+ let obj_title_union1 = null;
826
+ const obj_title_union1_error = (() => {
827
+ if (obj_title !== null) {
828
+ return new TypeError('Expected "null" but received "' + typeof obj_title + '" (at "' + path_title + '")');
829
+ }
830
+ })();
831
+ if (obj_title_union1_error != null) {
832
+ obj_title_union1 = obj_title_union1_error.message;
833
+ }
834
+ if (obj_title_union0 && obj_title_union1) {
835
+ let message = 'Object doesn\'t match union (at "' + path_title + '")';
836
+ message += '\n' + obj_title_union0.split('\n').map((line) => '\t' + line).join('\n');
837
+ message += '\n' + obj_title_union1.split('\n').map((line) => '\t' + line).join('\n');
838
+ return new TypeError(message);
839
+ }
840
+ })();
841
+ return v_error === undefined ? null : v_error;
842
+ }
843
+ const RepresentationType$1 = 'EnablementProgramSummaryRepresentation';
844
+ function keyBuilder$4(luvio, config) {
845
+ return keyPrefix + '::' + RepresentationType$1 + ':' + (config.enablement_program_id === null ? '' : config.enablement_program_id);
846
+ }
847
+ function keyBuilderFromType(luvio, object) {
848
+ const keyParams = {
849
+ enablement_program_id: object.id
850
+ };
851
+ return keyBuilder$4(luvio, keyParams);
852
+ }
853
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
854
+ return input;
855
+ }
856
+ const select$3 = function EnablementProgramSummaryRepresentationSelect() {
857
+ const { selections: EnablementProgramSummaryTaskRepresentation__selections, opaque: EnablementProgramSummaryTaskRepresentation__opaque, } = select$4();
858
+ return {
859
+ kind: 'Fragment',
860
+ version: VERSION$1,
861
+ private: [],
862
+ selections: [
863
+ {
864
+ name: 'description',
865
+ kind: 'Scalar'
866
+ },
867
+ {
868
+ name: 'dueDate',
869
+ kind: 'Scalar'
870
+ },
871
+ {
872
+ name: 'id',
873
+ kind: 'Scalar'
874
+ },
875
+ {
876
+ name: 'items',
877
+ kind: 'Object',
878
+ // any
879
+ },
880
+ {
881
+ name: 'learningItemId',
882
+ kind: 'Scalar'
883
+ },
884
+ {
885
+ name: 'outcome',
886
+ kind: 'Object',
887
+ nullable: true,
888
+ selections: EnablementProgramSummaryTaskRepresentation__selections
889
+ },
890
+ {
891
+ name: 'status',
892
+ kind: 'Scalar'
893
+ },
894
+ {
895
+ name: 'systemModStamp',
896
+ kind: 'Scalar',
897
+ required: false
898
+ },
899
+ {
900
+ name: 'title',
901
+ kind: 'Scalar'
902
+ }
903
+ ]
904
+ };
905
+ };
906
+ function equals$1(existing, incoming) {
907
+ const existing_status = existing.status;
908
+ const incoming_status = incoming.status;
909
+ if (!(existing_status === incoming_status)) {
910
+ return false;
911
+ }
912
+ const existing_description = existing.description;
913
+ const incoming_description = incoming.description;
914
+ if (!(existing_description === incoming_description)) {
915
+ return false;
916
+ }
917
+ const existing_dueDate = existing.dueDate;
918
+ const incoming_dueDate = incoming.dueDate;
919
+ if (!(existing_dueDate === incoming_dueDate)) {
920
+ return false;
921
+ }
922
+ const existing_id = existing.id;
923
+ const incoming_id = incoming.id;
924
+ if (!(existing_id === incoming_id)) {
925
+ return false;
926
+ }
927
+ const existing_items = existing.items;
928
+ const incoming_items = incoming.items;
929
+ const equals_items_items = equalsArray(existing_items, incoming_items, (existing_items_item, incoming_items_item) => {
930
+ if (JSONStringify(incoming_items_item) !== JSONStringify(existing_items_item)) {
931
+ return false;
932
+ }
933
+ });
934
+ if (equals_items_items === false) {
935
+ return false;
936
+ }
937
+ const existing_learningItemId = existing.learningItemId;
938
+ const incoming_learningItemId = incoming.learningItemId;
939
+ if (!(existing_learningItemId === incoming_learningItemId)) {
940
+ return false;
941
+ }
942
+ const existing_outcome = existing.outcome;
943
+ const incoming_outcome = incoming.outcome;
944
+ if (!(existing_outcome === incoming_outcome
945
+ || (existing_outcome != null &&
946
+ incoming_outcome != null &&
947
+ equals$2(existing_outcome, incoming_outcome)))) {
948
+ return false;
949
+ }
950
+ const existing_systemModStamp = existing.systemModStamp;
951
+ const incoming_systemModStamp = incoming.systemModStamp;
952
+ // if at least one of these optionals is defined
953
+ if (existing_systemModStamp !== undefined || incoming_systemModStamp !== undefined) {
954
+ // if one of these is not defined we know the other is defined and therefore
955
+ // not equal
956
+ if (existing_systemModStamp === undefined || incoming_systemModStamp === undefined) {
957
+ return false;
958
+ }
959
+ if (!(existing_systemModStamp === incoming_systemModStamp)) {
960
+ return false;
961
+ }
962
+ }
963
+ const existing_title = existing.title;
964
+ const incoming_title = incoming.title;
965
+ if (!(existing_title === incoming_title)) {
966
+ return false;
967
+ }
968
+ return true;
969
+ }
970
+ const ingest$1 = function EnablementProgramSummaryRepresentationIngest(input, path, luvio, store, timestamp) {
971
+ if (process.env.NODE_ENV !== 'production') {
972
+ const validateError = validate$1(input);
973
+ if (validateError !== null) {
974
+ throw validateError;
975
+ }
976
+ }
977
+ const key = keyBuilderFromType(luvio, input);
978
+ const existingRecord = store.readEntry(key);
979
+ const ttlToUse = TTL;
980
+ let incomingRecord = normalize$1(input, store.readEntry(key), {
981
+ fullPath: key,
982
+ parent: path.parent,
983
+ propertyName: path.propertyName,
984
+ ttl: ttlToUse
985
+ });
986
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
987
+ luvio.storePublish(key, incomingRecord);
988
+ }
989
+ {
990
+ const storeMetadataParams = {
991
+ ttl: ttlToUse,
992
+ namespace: "enablement",
993
+ version: VERSION$1,
994
+ representationName: RepresentationType$1,
995
+ };
996
+ luvio.publishStoreMetadata(key, storeMetadataParams);
997
+ }
998
+ return createLink(key);
999
+ };
1000
+ function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
1001
+ const rootKeySet = new StoreKeyMap();
1002
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1003
+ const rootKey = keyBuilderFromType(luvio, input);
1004
+ rootKeySet.set(rootKey, {
1005
+ namespace: keyPrefix,
1006
+ representationName: RepresentationType$1,
1007
+ mergeable: false
1008
+ });
1009
+ return rootKeySet;
1010
+ }
1011
+
1012
+ const VERSION = "7ef7adad59a82a6a2a4ab4ba77434b67";
1013
+ function validate(obj, path = 'EnablementProgramSummaryListRepresentation') {
1014
+ const v_error = (() => {
1015
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
1016
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
1017
+ }
1018
+ const obj_hasMore = obj.hasMore;
1019
+ const path_hasMore = path + '.hasMore';
1020
+ if (typeof obj_hasMore !== 'boolean') {
1021
+ return new TypeError('Expected "boolean" but received "' + typeof obj_hasMore + '" (at "' + path_hasMore + '")');
1022
+ }
1023
+ const obj_programSummaryList = obj.programSummaryList;
1024
+ const path_programSummaryList = path + '.programSummaryList';
1025
+ if (!ArrayIsArray(obj_programSummaryList)) {
1026
+ return new TypeError('Expected "array" but received "' + typeof obj_programSummaryList + '" (at "' + path_programSummaryList + '")');
1027
+ }
1028
+ for (let i = 0; i < obj_programSummaryList.length; i++) {
1029
+ const obj_programSummaryList_item = obj_programSummaryList[i];
1030
+ const path_programSummaryList_item = path_programSummaryList + '[' + i + ']';
1031
+ if (typeof obj_programSummaryList_item !== 'object') {
1032
+ return new TypeError('Expected "object" but received "' + typeof obj_programSummaryList_item + '" (at "' + path_programSummaryList_item + '")');
1033
+ }
1034
+ }
1035
+ })();
1036
+ return v_error === undefined ? null : v_error;
1037
+ }
1038
+ const RepresentationType = 'EnablementProgramSummaryListRepresentation';
1039
+ function normalize(input, existing, path, luvio, store, timestamp) {
1040
+ const input_programSummaryList = input.programSummaryList;
1041
+ const input_programSummaryList_id = path.fullPath + '__programSummaryList';
1042
+ for (let i = 0; i < input_programSummaryList.length; i++) {
1043
+ const input_programSummaryList_item = input_programSummaryList[i];
1044
+ let input_programSummaryList_item_id = input_programSummaryList_id + '__' + i;
1045
+ input_programSummaryList[i] = ingest$1(input_programSummaryList_item, {
1046
+ fullPath: input_programSummaryList_item_id,
1047
+ propertyName: i,
1048
+ parent: {
1049
+ data: input,
1050
+ key: path.fullPath,
1051
+ existing: existing,
1052
+ },
1053
+ ttl: path.ttl
1054
+ }, luvio, store);
1055
+ }
1056
+ return input;
1057
+ }
1058
+ const select$2 = function EnablementProgramSummaryListRepresentationSelect() {
1059
+ return {
1060
+ kind: 'Fragment',
1061
+ version: VERSION,
1062
+ private: [],
1063
+ selections: [
1064
+ {
1065
+ name: 'hasMore',
1066
+ kind: 'Scalar'
1067
+ },
1068
+ {
1069
+ name: 'programSummaryList',
1070
+ kind: 'Link',
1071
+ plural: true,
1072
+ fragment: select$3()
1073
+ }
1074
+ ]
1075
+ };
1076
+ };
1077
+ function equals(existing, incoming) {
1078
+ const existing_hasMore = existing.hasMore;
1079
+ const incoming_hasMore = incoming.hasMore;
1080
+ if (!(existing_hasMore === incoming_hasMore)) {
1081
+ return false;
1082
+ }
1083
+ const existing_programSummaryList = existing.programSummaryList;
1084
+ const incoming_programSummaryList = incoming.programSummaryList;
1085
+ const equals_programSummaryList_items = equalsArray(existing_programSummaryList, incoming_programSummaryList, (existing_programSummaryList_item, incoming_programSummaryList_item) => {
1086
+ if (!(existing_programSummaryList_item.__ref === incoming_programSummaryList_item.__ref)) {
1087
+ return false;
1088
+ }
1089
+ });
1090
+ if (equals_programSummaryList_items === false) {
1091
+ return false;
1092
+ }
1093
+ return true;
1094
+ }
1095
+ const ingest = function EnablementProgramSummaryListRepresentationIngest(input, path, luvio, store, timestamp) {
1096
+ if (process.env.NODE_ENV !== 'production') {
1097
+ const validateError = validate(input);
1098
+ if (validateError !== null) {
1099
+ throw validateError;
1100
+ }
1101
+ }
1102
+ const key = path.fullPath;
1103
+ const existingRecord = store.readEntry(key);
1104
+ const ttlToUse = path.ttl !== undefined ? path.ttl : 15000;
1105
+ let incomingRecord = normalize(input, store.readEntry(key), {
1106
+ fullPath: key,
1107
+ parent: path.parent,
1108
+ propertyName: path.propertyName,
1109
+ ttl: ttlToUse
1110
+ }, luvio, store);
1111
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
1112
+ luvio.storePublish(key, incomingRecord);
1113
+ }
1114
+ if (ttlToUse !== undefined) {
1115
+ const storeMetadataParams = {
1116
+ ttl: ttlToUse,
1117
+ namespace: "enablement",
1118
+ version: VERSION,
1119
+ representationName: RepresentationType,
1120
+ };
1121
+ luvio.publishStoreMetadata(key, storeMetadataParams);
1122
+ }
1123
+ return createLink(key);
1124
+ };
1125
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
1126
+ const rootKeySet = new StoreKeyMap();
1127
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
1128
+ const rootKey = fullPathFactory();
1129
+ rootKeySet.set(rootKey, {
1130
+ namespace: keyPrefix,
1131
+ representationName: RepresentationType,
1132
+ mergeable: false
1133
+ });
1134
+ const input_programSummaryList_length = input.programSummaryList.length;
1135
+ for (let i = 0; i < input_programSummaryList_length; i++) {
1136
+ rootKeySet.merge(getTypeCacheKeys$1(luvio, input.programSummaryList[i]));
1137
+ }
1138
+ return rootKeySet;
1139
+ }
1140
+
1141
+ function select$1(luvio, params) {
1142
+ return select$2();
1143
+ }
1144
+ function keyBuilder$3(luvio, params) {
1145
+ return keyPrefix + '::EnablementProgramSummaryListRepresentation:(' + 'limit:' + params.queryParams.limit + ')';
1146
+ }
1147
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
1148
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$3(luvio, resourceParams));
1149
+ }
1150
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
1151
+ const { body } = response;
1152
+ const key = keyBuilder$3(luvio, resourceParams);
1153
+ luvio.storeIngest(key, ingest, body);
1154
+ const snapshot = luvio.storeLookup({
1155
+ recordId: key,
1156
+ node: select$1(),
1157
+ variables: {},
1158
+ }, snapshotRefresh);
1159
+ if (process.env.NODE_ENV !== 'production') {
1160
+ if (snapshot.state !== 'Fulfilled') {
1161
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1162
+ }
1163
+ }
1164
+ return snapshot;
1165
+ }
1166
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
1167
+ const key = keyBuilder$3(luvio, params);
1168
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
1169
+ luvio.storeIngestError(key, errorSnapshot);
1170
+ return errorSnapshot;
1171
+ }
1172
+ function createResourceRequest$1(config) {
1173
+ const headers = {};
1174
+ return {
1175
+ baseUri: '/services/data/v58.0',
1176
+ basePath: '/connect/enablement/program/summary/assigned',
1177
+ method: 'get',
1178
+ body: null,
1179
+ urlParams: {},
1180
+ queryParams: config.queryParams,
1181
+ headers,
1182
+ priority: 'normal',
1183
+ };
1184
+ }
1185
+
1186
+ const getAssignedEnablementProgramSummary_ConfigPropertyNames = {
1187
+ displayName: 'getAssignedEnablementProgramSummary',
1188
+ parameters: {
1189
+ required: [],
1190
+ optional: ['limit']
1191
+ }
1192
+ };
1193
+ function createResourceParams$1(config) {
1194
+ const resourceParams = {
1195
+ queryParams: {
1196
+ limit: config.limit
1197
+ }
1198
+ };
1199
+ return resourceParams;
1200
+ }
1201
+ function keyBuilder$2(luvio, config) {
1202
+ const resourceParams = createResourceParams$1(config);
1203
+ return keyBuilder$3(luvio, resourceParams);
1204
+ }
1205
+ function typeCheckConfig$1(untrustedConfig) {
1206
+ const config = {};
1207
+ const untrustedConfig_limit = untrustedConfig.limit;
1208
+ if (typeof untrustedConfig_limit === 'number' && Math.floor(untrustedConfig_limit) === untrustedConfig_limit) {
1209
+ config.limit = untrustedConfig_limit;
1210
+ }
1211
+ return config;
1212
+ }
1213
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
1214
+ if (!untrustedIsObject(untrustedConfig)) {
1215
+ return null;
1216
+ }
1217
+ if (process.env.NODE_ENV !== 'production') {
1218
+ validateConfig(untrustedConfig, configPropertyNames);
1219
+ }
1220
+ const config = typeCheckConfig$1(untrustedConfig);
1221
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
1222
+ return null;
1223
+ }
1224
+ return config;
1225
+ }
1226
+ function adapterFragment$1(luvio, config) {
1227
+ createResourceParams$1(config);
1228
+ return select$1();
1229
+ }
1230
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
1231
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
1232
+ config,
1233
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
1234
+ });
1235
+ return luvio.storeBroadcast().then(() => snapshot);
1236
+ }
1237
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
1238
+ const snapshot = ingestError$1(luvio, resourceParams, response, {
1239
+ config,
1240
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
1241
+ });
1242
+ return luvio.storeBroadcast().then(() => snapshot);
1243
+ }
1244
+ function buildNetworkSnapshot$1(luvio, config, options) {
1245
+ const resourceParams = createResourceParams$1(config);
1246
+ const request = createResourceRequest$1(resourceParams);
1247
+ return luvio.dispatchResourceRequest(request, options)
1248
+ .then((response) => {
1249
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
1250
+ }, (response) => {
1251
+ return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
1252
+ });
1253
+ }
1254
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
1255
+ const { luvio, config } = context;
1256
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
1257
+ const dispatchOptions = {
1258
+ resourceRequestContext: {
1259
+ requestCorrelator,
1260
+ luvioRequestMethod: undefined,
1261
+ },
1262
+ eventObservers
1263
+ };
1264
+ if (networkPriority !== 'normal') {
1265
+ dispatchOptions.overrides = {
1266
+ priority: networkPriority
1267
+ };
1268
+ }
1269
+ return buildNetworkSnapshot$1(luvio, config, dispatchOptions);
1270
+ }
1271
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
1272
+ const { luvio, config } = context;
1273
+ const selector = {
1274
+ recordId: keyBuilder$2(luvio, config),
1275
+ node: adapterFragment$1(luvio, config),
1276
+ variables: {},
1277
+ };
1278
+ const cacheSnapshot = storeLookup(selector, {
1279
+ config,
1280
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
1281
+ });
1282
+ return cacheSnapshot;
1283
+ }
1284
+ const getAssignedEnablementProgramSummaryAdapterFactory = (luvio) => function enablement__getAssignedEnablementProgramSummary(untrustedConfig, requestContext) {
1285
+ const config = validateAdapterConfig$1(untrustedConfig, getAssignedEnablementProgramSummary_ConfigPropertyNames);
1286
+ // Invalid or incomplete config
1287
+ if (config === null) {
1288
+ return null;
1289
+ }
1290
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
1291
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
1292
+ };
1293
+
1294
+ function select(luvio, params) {
1295
+ return select$3();
1296
+ }
1297
+ function keyBuilder$1(luvio, params) {
1298
+ return keyBuilder$4(luvio, {
1299
+ enablement_program_id: params.urlParams.enablementProgramId
1300
+ });
1301
+ }
1302
+ function getResponseCacheKeys(luvio, resourceParams, response) {
1303
+ return getTypeCacheKeys$1(luvio, response);
1304
+ }
1305
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
1306
+ const { body } = response;
1307
+ const key = keyBuilder$1(luvio, resourceParams);
1308
+ luvio.storeIngest(key, ingest$1, body);
1309
+ const snapshot = luvio.storeLookup({
1310
+ recordId: key,
1311
+ node: select(),
1312
+ variables: {},
1313
+ }, snapshotRefresh);
1314
+ if (process.env.NODE_ENV !== 'production') {
1315
+ if (snapshot.state !== 'Fulfilled') {
1316
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
1317
+ }
1318
+ }
1319
+ return snapshot;
1320
+ }
1321
+ function ingestError(luvio, params, error, snapshotRefresh) {
1322
+ const key = keyBuilder$1(luvio, params);
1323
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
1324
+ const storeMetadataParams = {
1325
+ ttl: TTL,
1326
+ namespace: keyPrefix,
1327
+ version: VERSION$1,
1328
+ representationName: RepresentationType$1
1329
+ };
1330
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
1331
+ return errorSnapshot;
1332
+ }
1333
+ function createResourceRequest(config) {
1334
+ const headers = {};
1335
+ return {
1336
+ baseUri: '/services/data/v58.0',
1337
+ basePath: '/connect/enablement/program/summary/' + config.urlParams.enablementProgramId + '',
1338
+ method: 'get',
1339
+ body: null,
1340
+ urlParams: config.urlParams,
1341
+ queryParams: {},
1342
+ headers,
1343
+ priority: 'normal',
1344
+ };
1345
+ }
1346
+
1347
+ const getEnablementProgramSummary_ConfigPropertyNames = {
1348
+ displayName: 'getEnablementProgramSummary',
1349
+ parameters: {
1350
+ required: ['enablementProgramId'],
1351
+ optional: []
1352
+ }
1353
+ };
1354
+ function createResourceParams(config) {
1355
+ const resourceParams = {
1356
+ urlParams: {
1357
+ enablementProgramId: config.enablementProgramId
1358
+ }
1359
+ };
1360
+ return resourceParams;
1361
+ }
1362
+ function keyBuilder(luvio, config) {
1363
+ const resourceParams = createResourceParams(config);
1364
+ return keyBuilder$1(luvio, resourceParams);
1365
+ }
1366
+ function typeCheckConfig(untrustedConfig) {
1367
+ const config = {};
1368
+ const untrustedConfig_enablementProgramId = untrustedConfig.enablementProgramId;
1369
+ if (typeof untrustedConfig_enablementProgramId === 'string') {
1370
+ config.enablementProgramId = untrustedConfig_enablementProgramId;
1371
+ }
1372
+ return config;
1373
+ }
1374
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
1375
+ if (!untrustedIsObject(untrustedConfig)) {
1376
+ return null;
1377
+ }
1378
+ if (process.env.NODE_ENV !== 'production') {
1379
+ validateConfig(untrustedConfig, configPropertyNames);
1380
+ }
1381
+ const config = typeCheckConfig(untrustedConfig);
1382
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
1383
+ return null;
1384
+ }
1385
+ return config;
1386
+ }
1387
+ function adapterFragment(luvio, config) {
1388
+ createResourceParams(config);
1389
+ return select();
1390
+ }
1391
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
1392
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
1393
+ config,
1394
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
1395
+ });
1396
+ return luvio.storeBroadcast().then(() => snapshot);
1397
+ }
1398
+ function onFetchResponseError(luvio, config, resourceParams, response) {
1399
+ const snapshot = ingestError(luvio, resourceParams, response, {
1400
+ config,
1401
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
1402
+ });
1403
+ return luvio.storeBroadcast().then(() => snapshot);
1404
+ }
1405
+ function buildNetworkSnapshot(luvio, config, options) {
1406
+ const resourceParams = createResourceParams(config);
1407
+ const request = createResourceRequest(resourceParams);
1408
+ return luvio.dispatchResourceRequest(request, options)
1409
+ .then((response) => {
1410
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
1411
+ }, (response) => {
1412
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
1413
+ });
1414
+ }
1415
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
1416
+ const { luvio, config } = context;
1417
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
1418
+ const dispatchOptions = {
1419
+ resourceRequestContext: {
1420
+ requestCorrelator,
1421
+ luvioRequestMethod: undefined,
1422
+ },
1423
+ eventObservers
1424
+ };
1425
+ if (networkPriority !== 'normal') {
1426
+ dispatchOptions.overrides = {
1427
+ priority: networkPriority
1428
+ };
1429
+ }
1430
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
1431
+ }
1432
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
1433
+ const { luvio, config } = context;
1434
+ const selector = {
1435
+ recordId: keyBuilder(luvio, config),
1436
+ node: adapterFragment(luvio, config),
1437
+ variables: {},
1438
+ };
1439
+ const cacheSnapshot = storeLookup(selector, {
1440
+ config,
1441
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
1442
+ });
1443
+ return cacheSnapshot;
1444
+ }
1445
+ const getEnablementProgramSummaryAdapterFactory = (luvio) => function enablement__getEnablementProgramSummary(untrustedConfig, requestContext) {
1446
+ const config = validateAdapterConfig(untrustedConfig, getEnablementProgramSummary_ConfigPropertyNames);
1447
+ // Invalid or incomplete config
1448
+ if (config === null) {
1449
+ return null;
1450
+ }
1451
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
1452
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
1453
+ };
1454
+
1455
+ export { getAssignedEnablementProgramSummaryAdapterFactory, getEnablementProgramSummaryAdapterFactory };