@salesforce/lds-adapters-sales-yukon 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.
- package/LICENSE.txt +82 -0
- package/dist/es/es2018/sales-yukon.js +1150 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/getYukonSurfaceNudges.d.ts +28 -0
- package/dist/es/es2018/types/src/generated/adapters/getYukonSurfaceNudgesMock.d.ts +30 -0
- package/dist/es/es2018/types/src/generated/adapters/postYukonTelemetry.d.ts +16 -0
- package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +3 -0
- package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +8 -0
- package/dist/es/es2018/types/src/generated/resources/getYukonSurfacesNudgesBySurfaceId.d.ts +16 -0
- package/dist/es/es2018/types/src/generated/resources/getYukonSurfacesNudgesMockBySurfaceId.d.ts +20 -0
- package/dist/es/es2018/types/src/generated/resources/postYukonTelemetry.d.ts +13 -0
- package/dist/es/es2018/types/src/generated/types/YukonNudgeActionEngagementRepresentation.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/types/YukonNudgeActionStateRepresentation.d.ts +37 -0
- package/dist/es/es2018/types/src/generated/types/YukonNudgeInputRepresentation.d.ts +61 -0
- package/dist/es/es2018/types/src/generated/types/YukonNudgeOutputRepresentation.d.ts +54 -0
- package/dist/es/es2018/types/src/generated/types/YukonSurfaceNudgesOutputRepresentation.d.ts +47 -0
- package/dist/es/es2018/types/src/generated/types/YukonTelemetryInputGroupRepresentation.d.ts +29 -0
- package/dist/es/es2018/types/src/generated/types/YukonTelemetryInputRepresentation.d.ts +34 -0
- package/dist/es/es2018/types/src/generated/types/YukonTelemetryOutputRepresentation.d.ts +40 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
- package/package.json +66 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +1278 -0
- package/src/raml/api.raml +247 -0
- package/src/raml/luvio.raml +33 -0
|
@@ -0,0 +1,1150 @@
|
|
|
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$2, typeCheckConfig as typeCheckConfig$3, StoreKeyMap, createResourceParams as createResourceParams$3 } from '@luvio/engine';
|
|
8
|
+
|
|
9
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
+
const { keys: ObjectKeys$1, create: ObjectCreate$1 } = 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$1(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 = 'Yukon';
|
|
73
|
+
|
|
74
|
+
const { keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
75
|
+
const { isArray: ArrayIsArray } = Array;
|
|
76
|
+
const { stringify: JSONStringify } = JSON;
|
|
77
|
+
function equalsArray(a, b, equalsItem) {
|
|
78
|
+
const aLength = a.length;
|
|
79
|
+
const bLength = b.length;
|
|
80
|
+
if (aLength !== bLength) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
for (let i = 0; i < aLength; i++) {
|
|
84
|
+
if (equalsItem(a[i], b[i]) === false) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
function equalsObject(a, b, equalsProp) {
|
|
91
|
+
const aKeys = ObjectKeys(a).sort();
|
|
92
|
+
const bKeys = ObjectKeys(b).sort();
|
|
93
|
+
const aKeysLength = aKeys.length;
|
|
94
|
+
const bKeysLength = bKeys.length;
|
|
95
|
+
if (aKeysLength !== bKeysLength) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
99
|
+
const key = aKeys[i];
|
|
100
|
+
if (key !== bKeys[i]) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (equalsProp(a[key], b[key]) === false) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
function createLink(ref) {
|
|
110
|
+
return {
|
|
111
|
+
__ref: serializeStructuredKey(ref),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const VERSION$4 = "06d910116027ee7b77989f680bfcb262";
|
|
116
|
+
function validate$5(obj, path = 'YukonNudgeActionEngagementRepresentation') {
|
|
117
|
+
const v_error = (() => {
|
|
118
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
119
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
120
|
+
}
|
|
121
|
+
if (obj.primary !== undefined) {
|
|
122
|
+
const obj_primary = obj.primary;
|
|
123
|
+
const path_primary = path + '.primary';
|
|
124
|
+
if (typeof obj_primary !== 'number' || (typeof obj_primary === 'number' && Math.floor(obj_primary) !== obj_primary)) {
|
|
125
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_primary + '" (at "' + path_primary + '")');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (obj.secondary !== undefined) {
|
|
129
|
+
const obj_secondary = obj.secondary;
|
|
130
|
+
const path_secondary = path + '.secondary';
|
|
131
|
+
if (typeof obj_secondary !== 'number' || (typeof obj_secondary === 'number' && Math.floor(obj_secondary) !== obj_secondary)) {
|
|
132
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_secondary + '" (at "' + path_secondary + '")');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
return v_error === undefined ? null : v_error;
|
|
137
|
+
}
|
|
138
|
+
const select$7 = function YukonNudgeActionEngagementRepresentationSelect() {
|
|
139
|
+
return {
|
|
140
|
+
kind: 'Fragment',
|
|
141
|
+
version: VERSION$4,
|
|
142
|
+
private: [],
|
|
143
|
+
selections: [
|
|
144
|
+
{
|
|
145
|
+
name: 'primary',
|
|
146
|
+
kind: 'Scalar',
|
|
147
|
+
required: false
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'secondary',
|
|
151
|
+
kind: 'Scalar',
|
|
152
|
+
required: false
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
function equals$4(existing, incoming) {
|
|
158
|
+
const existing_primary = existing.primary;
|
|
159
|
+
const incoming_primary = incoming.primary;
|
|
160
|
+
// if at least one of these optionals is defined
|
|
161
|
+
if (existing_primary !== undefined || incoming_primary !== undefined) {
|
|
162
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
163
|
+
// not equal
|
|
164
|
+
if (existing_primary === undefined || incoming_primary === undefined) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
if (!(existing_primary === incoming_primary)) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const existing_secondary = existing.secondary;
|
|
172
|
+
const incoming_secondary = incoming.secondary;
|
|
173
|
+
// if at least one of these optionals is defined
|
|
174
|
+
if (existing_secondary !== undefined || incoming_secondary !== undefined) {
|
|
175
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
176
|
+
// not equal
|
|
177
|
+
if (existing_secondary === undefined || incoming_secondary === undefined) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
if (!(existing_secondary === incoming_secondary)) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const VERSION$3 = "361047d69f9d5767a73f945c54a9f97d";
|
|
188
|
+
function validate$4(obj, path = 'YukonNudgeActionStateRepresentation') {
|
|
189
|
+
const v_error = (() => {
|
|
190
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
191
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
192
|
+
}
|
|
193
|
+
if (obj.engagement !== undefined) {
|
|
194
|
+
const obj_engagement = obj.engagement;
|
|
195
|
+
const path_engagement = path + '.engagement';
|
|
196
|
+
const referencepath_engagementValidationError = validate$5(obj_engagement, path_engagement);
|
|
197
|
+
if (referencepath_engagementValidationError !== null) {
|
|
198
|
+
let message = 'Object doesn\'t match YukonNudgeActionEngagementRepresentation (at "' + path_engagement + '")\n';
|
|
199
|
+
message += referencepath_engagementValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
200
|
+
return new TypeError(message);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (obj.lastSeen !== undefined) {
|
|
204
|
+
const obj_lastSeen = obj.lastSeen;
|
|
205
|
+
const path_lastSeen = path + '.lastSeen';
|
|
206
|
+
if (typeof obj_lastSeen !== 'string') {
|
|
207
|
+
return new TypeError('Expected "string" but received "' + typeof obj_lastSeen + '" (at "' + path_lastSeen + '")');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (obj.seenCount !== undefined) {
|
|
211
|
+
const obj_seenCount = obj.seenCount;
|
|
212
|
+
const path_seenCount = path + '.seenCount';
|
|
213
|
+
if (typeof obj_seenCount !== 'number' || (typeof obj_seenCount === 'number' && Math.floor(obj_seenCount) !== obj_seenCount)) {
|
|
214
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_seenCount + '" (at "' + path_seenCount + '")');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (obj.stepCount !== undefined) {
|
|
218
|
+
const obj_stepCount = obj.stepCount;
|
|
219
|
+
const path_stepCount = path + '.stepCount';
|
|
220
|
+
if (typeof obj_stepCount !== 'number' || (typeof obj_stepCount === 'number' && Math.floor(obj_stepCount) !== obj_stepCount)) {
|
|
221
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_stepCount + '" (at "' + path_stepCount + '")');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
})();
|
|
225
|
+
return v_error === undefined ? null : v_error;
|
|
226
|
+
}
|
|
227
|
+
const select$6 = function YukonNudgeActionStateRepresentationSelect() {
|
|
228
|
+
const { selections: YukonNudgeActionEngagementRepresentation__selections, opaque: YukonNudgeActionEngagementRepresentation__opaque, } = select$7();
|
|
229
|
+
return {
|
|
230
|
+
kind: 'Fragment',
|
|
231
|
+
version: VERSION$3,
|
|
232
|
+
private: [],
|
|
233
|
+
selections: [
|
|
234
|
+
{
|
|
235
|
+
name: 'engagement',
|
|
236
|
+
kind: 'Object',
|
|
237
|
+
selections: YukonNudgeActionEngagementRepresentation__selections,
|
|
238
|
+
required: false
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'lastSeen',
|
|
242
|
+
kind: 'Scalar',
|
|
243
|
+
required: false
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'seenCount',
|
|
247
|
+
kind: 'Scalar',
|
|
248
|
+
required: false
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: 'stepCount',
|
|
252
|
+
kind: 'Scalar',
|
|
253
|
+
required: false
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
function equals$3(existing, incoming) {
|
|
259
|
+
const existing_seenCount = existing.seenCount;
|
|
260
|
+
const incoming_seenCount = incoming.seenCount;
|
|
261
|
+
// if at least one of these optionals is defined
|
|
262
|
+
if (existing_seenCount !== undefined || incoming_seenCount !== undefined) {
|
|
263
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
264
|
+
// not equal
|
|
265
|
+
if (existing_seenCount === undefined || incoming_seenCount === undefined) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
if (!(existing_seenCount === incoming_seenCount)) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const existing_stepCount = existing.stepCount;
|
|
273
|
+
const incoming_stepCount = incoming.stepCount;
|
|
274
|
+
// if at least one of these optionals is defined
|
|
275
|
+
if (existing_stepCount !== undefined || incoming_stepCount !== undefined) {
|
|
276
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
277
|
+
// not equal
|
|
278
|
+
if (existing_stepCount === undefined || incoming_stepCount === undefined) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (!(existing_stepCount === incoming_stepCount)) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const existing_lastSeen = existing.lastSeen;
|
|
286
|
+
const incoming_lastSeen = incoming.lastSeen;
|
|
287
|
+
// if at least one of these optionals is defined
|
|
288
|
+
if (existing_lastSeen !== undefined || incoming_lastSeen !== undefined) {
|
|
289
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
290
|
+
// not equal
|
|
291
|
+
if (existing_lastSeen === undefined || incoming_lastSeen === undefined) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
if (!(existing_lastSeen === incoming_lastSeen)) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const existing_engagement = existing.engagement;
|
|
299
|
+
const incoming_engagement = incoming.engagement;
|
|
300
|
+
// if at least one of these optionals is defined
|
|
301
|
+
if (existing_engagement !== undefined || incoming_engagement !== undefined) {
|
|
302
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
303
|
+
// not equal
|
|
304
|
+
if (existing_engagement === undefined || incoming_engagement === undefined) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
if (!(equals$4(existing_engagement, incoming_engagement))) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const VERSION$2 = "9c54ed50f042624537aa1b4fc1bc09f3";
|
|
315
|
+
function validate$3(obj, path = 'YukonNudgeOutputRepresentation') {
|
|
316
|
+
const v_error = (() => {
|
|
317
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
318
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
319
|
+
}
|
|
320
|
+
if (obj.actionState !== undefined) {
|
|
321
|
+
const obj_actionState = obj.actionState;
|
|
322
|
+
const path_actionState = path + '.actionState';
|
|
323
|
+
const referencepath_actionStateValidationError = validate$4(obj_actionState, path_actionState);
|
|
324
|
+
if (referencepath_actionStateValidationError !== null) {
|
|
325
|
+
let message = 'Object doesn\'t match YukonNudgeActionStateRepresentation (at "' + path_actionState + '")\n';
|
|
326
|
+
message += referencepath_actionStateValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
327
|
+
return new TypeError(message);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (obj.contentType !== undefined) {
|
|
331
|
+
const obj_contentType = obj.contentType;
|
|
332
|
+
const path_contentType = path + '.contentType';
|
|
333
|
+
if (typeof obj_contentType !== 'string') {
|
|
334
|
+
return new TypeError('Expected "string" but received "' + typeof obj_contentType + '" (at "' + path_contentType + '")');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (obj.endDate !== undefined) {
|
|
338
|
+
const obj_endDate = obj.endDate;
|
|
339
|
+
const path_endDate = path + '.endDate';
|
|
340
|
+
if (typeof obj_endDate !== 'string') {
|
|
341
|
+
return new TypeError('Expected "string" but received "' + typeof obj_endDate + '" (at "' + path_endDate + '")');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
const obj_id = obj.id;
|
|
345
|
+
const path_id = path + '.id';
|
|
346
|
+
if (typeof obj_id !== 'string') {
|
|
347
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
348
|
+
}
|
|
349
|
+
if (obj.metadata !== undefined) {
|
|
350
|
+
const obj_metadata = obj.metadata;
|
|
351
|
+
const path_metadata = path + '.metadata';
|
|
352
|
+
if (typeof obj_metadata !== 'object' || ArrayIsArray(obj_metadata) || obj_metadata === null) {
|
|
353
|
+
return new TypeError('Expected "object" but received "' + typeof obj_metadata + '" (at "' + path_metadata + '")');
|
|
354
|
+
}
|
|
355
|
+
const obj_metadata_keys = ObjectKeys(obj_metadata);
|
|
356
|
+
for (let i = 0; i < obj_metadata_keys.length; i++) {
|
|
357
|
+
const key = obj_metadata_keys[i];
|
|
358
|
+
const obj_metadata_prop = obj_metadata[key];
|
|
359
|
+
const path_metadata_prop = path_metadata + '["' + key + '"]';
|
|
360
|
+
if (obj_metadata_prop === undefined) {
|
|
361
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_metadata_prop + '" (at "' + path_metadata_prop + '")');
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const obj_payload = obj.payload;
|
|
366
|
+
const path_payload = path + '.payload';
|
|
367
|
+
if (typeof obj_payload !== 'object' || ArrayIsArray(obj_payload) || obj_payload === null) {
|
|
368
|
+
return new TypeError('Expected "object" but received "' + typeof obj_payload + '" (at "' + path_payload + '")');
|
|
369
|
+
}
|
|
370
|
+
const obj_payload_keys = ObjectKeys(obj_payload);
|
|
371
|
+
for (let i = 0; i < obj_payload_keys.length; i++) {
|
|
372
|
+
const key = obj_payload_keys[i];
|
|
373
|
+
const obj_payload_prop = obj_payload[key];
|
|
374
|
+
const path_payload_prop = path_payload + '["' + key + '"]';
|
|
375
|
+
if (obj_payload_prop === undefined) {
|
|
376
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_payload_prop + '" (at "' + path_payload_prop + '")');
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (obj.startDate !== undefined) {
|
|
380
|
+
const obj_startDate = obj.startDate;
|
|
381
|
+
const path_startDate = path + '.startDate';
|
|
382
|
+
if (typeof obj_startDate !== 'string') {
|
|
383
|
+
return new TypeError('Expected "string" but received "' + typeof obj_startDate + '" (at "' + path_startDate + '")');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
})();
|
|
387
|
+
return v_error === undefined ? null : v_error;
|
|
388
|
+
}
|
|
389
|
+
const select$5 = function YukonNudgeOutputRepresentationSelect() {
|
|
390
|
+
const { selections: YukonNudgeActionStateRepresentation__selections, opaque: YukonNudgeActionStateRepresentation__opaque, } = select$6();
|
|
391
|
+
return {
|
|
392
|
+
kind: 'Fragment',
|
|
393
|
+
version: VERSION$2,
|
|
394
|
+
private: [],
|
|
395
|
+
selections: [
|
|
396
|
+
{
|
|
397
|
+
name: 'actionState',
|
|
398
|
+
kind: 'Object',
|
|
399
|
+
selections: YukonNudgeActionStateRepresentation__selections,
|
|
400
|
+
required: false
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
name: 'contentType',
|
|
404
|
+
kind: 'Scalar',
|
|
405
|
+
required: false
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: 'endDate',
|
|
409
|
+
kind: 'Scalar',
|
|
410
|
+
required: false
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: 'id',
|
|
414
|
+
kind: 'Scalar'
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: 'metadata',
|
|
418
|
+
kind: 'Object',
|
|
419
|
+
// any
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: 'payload',
|
|
423
|
+
kind: 'Object',
|
|
424
|
+
// any
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
name: 'startDate',
|
|
428
|
+
kind: 'Scalar',
|
|
429
|
+
required: false
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
};
|
|
433
|
+
};
|
|
434
|
+
function equals$2(existing, incoming) {
|
|
435
|
+
const existing_contentType = existing.contentType;
|
|
436
|
+
const incoming_contentType = incoming.contentType;
|
|
437
|
+
// if at least one of these optionals is defined
|
|
438
|
+
if (existing_contentType !== undefined || incoming_contentType !== undefined) {
|
|
439
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
440
|
+
// not equal
|
|
441
|
+
if (existing_contentType === undefined || incoming_contentType === undefined) {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
if (!(existing_contentType === incoming_contentType)) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
const existing_endDate = existing.endDate;
|
|
449
|
+
const incoming_endDate = incoming.endDate;
|
|
450
|
+
// if at least one of these optionals is defined
|
|
451
|
+
if (existing_endDate !== undefined || incoming_endDate !== undefined) {
|
|
452
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
453
|
+
// not equal
|
|
454
|
+
if (existing_endDate === undefined || incoming_endDate === undefined) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
if (!(existing_endDate === incoming_endDate)) {
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
const existing_id = existing.id;
|
|
462
|
+
const incoming_id = incoming.id;
|
|
463
|
+
if (!(existing_id === incoming_id)) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
const existing_startDate = existing.startDate;
|
|
467
|
+
const incoming_startDate = incoming.startDate;
|
|
468
|
+
// if at least one of these optionals is defined
|
|
469
|
+
if (existing_startDate !== undefined || incoming_startDate !== undefined) {
|
|
470
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
471
|
+
// not equal
|
|
472
|
+
if (existing_startDate === undefined || incoming_startDate === undefined) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
if (!(existing_startDate === incoming_startDate)) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
const existing_actionState = existing.actionState;
|
|
480
|
+
const incoming_actionState = incoming.actionState;
|
|
481
|
+
// if at least one of these optionals is defined
|
|
482
|
+
if (existing_actionState !== undefined || incoming_actionState !== undefined) {
|
|
483
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
484
|
+
// not equal
|
|
485
|
+
if (existing_actionState === undefined || incoming_actionState === undefined) {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
if (!(equals$3(existing_actionState, incoming_actionState))) {
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
const existing_metadata = existing.metadata;
|
|
493
|
+
const incoming_metadata = incoming.metadata;
|
|
494
|
+
// if at least one of these optionals is defined
|
|
495
|
+
if (existing_metadata !== undefined || incoming_metadata !== undefined) {
|
|
496
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
497
|
+
// not equal
|
|
498
|
+
if (existing_metadata === undefined || incoming_metadata === undefined) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
const equals_metadata_props = equalsObject(existing_metadata, incoming_metadata, (existing_metadata_prop, incoming_metadata_prop) => {
|
|
502
|
+
if (JSONStringify(incoming_metadata_prop) !== JSONStringify(existing_metadata_prop)) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
if (equals_metadata_props === false) {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
const existing_payload = existing.payload;
|
|
511
|
+
const incoming_payload = incoming.payload;
|
|
512
|
+
const equals_payload_props = equalsObject(existing_payload, incoming_payload, (existing_payload_prop, incoming_payload_prop) => {
|
|
513
|
+
if (JSONStringify(incoming_payload_prop) !== JSONStringify(existing_payload_prop)) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
if (equals_payload_props === false) {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const VERSION$1 = "0a118b11a68bdb6eba86bc28ad247dd1";
|
|
524
|
+
function validate$2(obj, path = 'YukonSurfaceNudgesOutputRepresentation') {
|
|
525
|
+
const v_error = (() => {
|
|
526
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
527
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
528
|
+
}
|
|
529
|
+
if (obj.errorMessage !== undefined) {
|
|
530
|
+
const obj_errorMessage = obj.errorMessage;
|
|
531
|
+
const path_errorMessage = path + '.errorMessage';
|
|
532
|
+
if (typeof obj_errorMessage !== 'string') {
|
|
533
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
const obj_nudges = obj.nudges;
|
|
537
|
+
const path_nudges = path + '.nudges';
|
|
538
|
+
if (!ArrayIsArray(obj_nudges)) {
|
|
539
|
+
return new TypeError('Expected "array" but received "' + typeof obj_nudges + '" (at "' + path_nudges + '")');
|
|
540
|
+
}
|
|
541
|
+
for (let i = 0; i < obj_nudges.length; i++) {
|
|
542
|
+
const obj_nudges_item = obj_nudges[i];
|
|
543
|
+
const path_nudges_item = path_nudges + '[' + i + ']';
|
|
544
|
+
const referencepath_nudges_itemValidationError = validate$3(obj_nudges_item, path_nudges_item);
|
|
545
|
+
if (referencepath_nudges_itemValidationError !== null) {
|
|
546
|
+
let message = 'Object doesn\'t match YukonNudgeOutputRepresentation (at "' + path_nudges_item + '")\n';
|
|
547
|
+
message += referencepath_nudges_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
548
|
+
return new TypeError(message);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const obj_status = obj.status;
|
|
552
|
+
const path_status = path + '.status';
|
|
553
|
+
if (typeof obj_status !== 'string') {
|
|
554
|
+
return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
|
|
555
|
+
}
|
|
556
|
+
const obj_surface = obj.surface;
|
|
557
|
+
const path_surface = path + '.surface';
|
|
558
|
+
if (typeof obj_surface !== 'string') {
|
|
559
|
+
return new TypeError('Expected "string" but received "' + typeof obj_surface + '" (at "' + path_surface + '")');
|
|
560
|
+
}
|
|
561
|
+
})();
|
|
562
|
+
return v_error === undefined ? null : v_error;
|
|
563
|
+
}
|
|
564
|
+
const RepresentationType$1 = 'YukonSurfaceNudgesOutputRepresentation';
|
|
565
|
+
function keyBuilder$5(luvio, config) {
|
|
566
|
+
return keyPrefix + '::' + RepresentationType$1 + ':' + config.surface;
|
|
567
|
+
}
|
|
568
|
+
function keyBuilderFromType$1(luvio, object) {
|
|
569
|
+
const keyParams = {
|
|
570
|
+
surface: object.surface
|
|
571
|
+
};
|
|
572
|
+
return keyBuilder$5(luvio, keyParams);
|
|
573
|
+
}
|
|
574
|
+
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
575
|
+
return input;
|
|
576
|
+
}
|
|
577
|
+
const select$4 = function YukonSurfaceNudgesOutputRepresentationSelect() {
|
|
578
|
+
const { selections: YukonNudgeOutputRepresentation__selections, opaque: YukonNudgeOutputRepresentation__opaque, } = select$5();
|
|
579
|
+
return {
|
|
580
|
+
kind: 'Fragment',
|
|
581
|
+
version: VERSION$1,
|
|
582
|
+
private: [],
|
|
583
|
+
selections: [
|
|
584
|
+
{
|
|
585
|
+
name: 'errorMessage',
|
|
586
|
+
kind: 'Scalar',
|
|
587
|
+
required: false
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
name: 'nudges',
|
|
591
|
+
kind: 'Object',
|
|
592
|
+
plural: true,
|
|
593
|
+
selections: YukonNudgeOutputRepresentation__selections
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
name: 'status',
|
|
597
|
+
kind: 'Scalar'
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: 'surface',
|
|
601
|
+
kind: 'Scalar'
|
|
602
|
+
}
|
|
603
|
+
]
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
function equals$1(existing, incoming) {
|
|
607
|
+
const existing_errorMessage = existing.errorMessage;
|
|
608
|
+
const incoming_errorMessage = incoming.errorMessage;
|
|
609
|
+
// if at least one of these optionals is defined
|
|
610
|
+
if (existing_errorMessage !== undefined || incoming_errorMessage !== undefined) {
|
|
611
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
612
|
+
// not equal
|
|
613
|
+
if (existing_errorMessage === undefined || incoming_errorMessage === undefined) {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
if (!(existing_errorMessage === incoming_errorMessage)) {
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const existing_status = existing.status;
|
|
621
|
+
const incoming_status = incoming.status;
|
|
622
|
+
if (!(existing_status === incoming_status)) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
const existing_surface = existing.surface;
|
|
626
|
+
const incoming_surface = incoming.surface;
|
|
627
|
+
if (!(existing_surface === incoming_surface)) {
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
const existing_nudges = existing.nudges;
|
|
631
|
+
const incoming_nudges = incoming.nudges;
|
|
632
|
+
const equals_nudges_items = equalsArray(existing_nudges, incoming_nudges, (existing_nudges_item, incoming_nudges_item) => {
|
|
633
|
+
if (!(equals$2(existing_nudges_item, incoming_nudges_item))) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
if (equals_nudges_items === false) {
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
const ingest$1 = function YukonSurfaceNudgesOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
643
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
644
|
+
const validateError = validate$2(input);
|
|
645
|
+
if (validateError !== null) {
|
|
646
|
+
throw validateError;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const key = keyBuilderFromType$1(luvio, input);
|
|
650
|
+
const ttlToUse = path.ttl !== undefined ? path.ttl : 30000;
|
|
651
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "Yukon", VERSION$1, RepresentationType$1, equals$1);
|
|
652
|
+
return createLink(key);
|
|
653
|
+
};
|
|
654
|
+
function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
|
|
655
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
656
|
+
const rootKey = keyBuilderFromType$1(luvio, input);
|
|
657
|
+
rootKeySet.set(rootKey, {
|
|
658
|
+
namespace: keyPrefix,
|
|
659
|
+
representationName: RepresentationType$1,
|
|
660
|
+
mergeable: false
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function select$3(luvio, params) {
|
|
665
|
+
return select$4();
|
|
666
|
+
}
|
|
667
|
+
function keyBuilder$4(luvio, params) {
|
|
668
|
+
return keyBuilder$5(luvio, {
|
|
669
|
+
surface: params.urlParams.surfaceId
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
function getResponseCacheKeys$2(storeKeyMap, luvio, resourceParams, response) {
|
|
673
|
+
getTypeCacheKeys$1(storeKeyMap, luvio, response);
|
|
674
|
+
}
|
|
675
|
+
function ingestSuccess$2(luvio, resourceParams, response, snapshotRefresh) {
|
|
676
|
+
const { body } = response;
|
|
677
|
+
const key = keyBuilder$4(luvio, resourceParams);
|
|
678
|
+
luvio.storeIngest(key, ingest$1, body);
|
|
679
|
+
const snapshot = luvio.storeLookup({
|
|
680
|
+
recordId: key,
|
|
681
|
+
node: select$3(),
|
|
682
|
+
variables: {},
|
|
683
|
+
}, snapshotRefresh);
|
|
684
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
685
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
686
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
deepFreeze(snapshot.data);
|
|
690
|
+
return snapshot;
|
|
691
|
+
}
|
|
692
|
+
function ingestError$1(luvio, params, error, snapshotRefresh) {
|
|
693
|
+
const key = keyBuilder$4(luvio, params);
|
|
694
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
695
|
+
luvio.storeIngestError(key, errorSnapshot);
|
|
696
|
+
return errorSnapshot;
|
|
697
|
+
}
|
|
698
|
+
function createResourceRequest$2(config) {
|
|
699
|
+
const headers = {};
|
|
700
|
+
return {
|
|
701
|
+
baseUri: '/services/data/v66.0',
|
|
702
|
+
basePath: '/yukon/surfaces/' + config.urlParams.surfaceId + '/nudges',
|
|
703
|
+
method: 'get',
|
|
704
|
+
body: null,
|
|
705
|
+
urlParams: config.urlParams,
|
|
706
|
+
queryParams: {},
|
|
707
|
+
headers,
|
|
708
|
+
priority: 'normal',
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const adapterName$2 = 'getYukonSurfaceNudges';
|
|
713
|
+
const getYukonSurfaceNudges_ConfigPropertyMetadata = [
|
|
714
|
+
generateParamConfigMetadata('surfaceId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
715
|
+
];
|
|
716
|
+
const getYukonSurfaceNudges_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$2, getYukonSurfaceNudges_ConfigPropertyMetadata);
|
|
717
|
+
const createResourceParams$2 = /*#__PURE__*/ createResourceParams$3(getYukonSurfaceNudges_ConfigPropertyMetadata);
|
|
718
|
+
function keyBuilder$3(luvio, config) {
|
|
719
|
+
const resourceParams = createResourceParams$2(config);
|
|
720
|
+
return keyBuilder$4(luvio, resourceParams);
|
|
721
|
+
}
|
|
722
|
+
function typeCheckConfig$2(untrustedConfig) {
|
|
723
|
+
const config = {};
|
|
724
|
+
typeCheckConfig$3(untrustedConfig, config, getYukonSurfaceNudges_ConfigPropertyMetadata);
|
|
725
|
+
return config;
|
|
726
|
+
}
|
|
727
|
+
function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
|
|
728
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
732
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
733
|
+
}
|
|
734
|
+
const config = typeCheckConfig$2(untrustedConfig);
|
|
735
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
return config;
|
|
739
|
+
}
|
|
740
|
+
function adapterFragment$1(luvio, config) {
|
|
741
|
+
createResourceParams$2(config);
|
|
742
|
+
return select$3();
|
|
743
|
+
}
|
|
744
|
+
function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
|
|
745
|
+
const snapshot = ingestSuccess$2(luvio, resourceParams, response, {
|
|
746
|
+
config,
|
|
747
|
+
resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
|
|
748
|
+
});
|
|
749
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
750
|
+
}
|
|
751
|
+
function onFetchResponseError$1(luvio, config, resourceParams, response) {
|
|
752
|
+
const snapshot = ingestError$1(luvio, resourceParams, response, {
|
|
753
|
+
config,
|
|
754
|
+
resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
|
|
755
|
+
});
|
|
756
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
757
|
+
}
|
|
758
|
+
function buildNetworkSnapshot$2(luvio, config, options) {
|
|
759
|
+
const resourceParams = createResourceParams$2(config);
|
|
760
|
+
const request = createResourceRequest$2(resourceParams);
|
|
761
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
762
|
+
.then((response) => {
|
|
763
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => {
|
|
764
|
+
const cache = new StoreKeyMap();
|
|
765
|
+
getResponseCacheKeys$2(cache, luvio, resourceParams, response.body);
|
|
766
|
+
return cache;
|
|
767
|
+
});
|
|
768
|
+
}, (response) => {
|
|
769
|
+
return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
|
|
773
|
+
return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot$2, undefined, false);
|
|
774
|
+
}
|
|
775
|
+
function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
|
|
776
|
+
const { luvio, config } = context;
|
|
777
|
+
const selector = {
|
|
778
|
+
recordId: keyBuilder$3(luvio, config),
|
|
779
|
+
node: adapterFragment$1(luvio, config),
|
|
780
|
+
variables: {},
|
|
781
|
+
};
|
|
782
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
783
|
+
config,
|
|
784
|
+
resolve: () => buildNetworkSnapshot$2(luvio, config, snapshotRefreshOptions)
|
|
785
|
+
});
|
|
786
|
+
return cacheSnapshot;
|
|
787
|
+
}
|
|
788
|
+
const getYukonSurfaceNudgesAdapterFactory = (luvio) => function Yukon__getYukonSurfaceNudges(untrustedConfig, requestContext) {
|
|
789
|
+
const config = validateAdapterConfig$2(untrustedConfig, getYukonSurfaceNudges_ConfigPropertyNames);
|
|
790
|
+
// Invalid or incomplete config
|
|
791
|
+
if (config === null) {
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
795
|
+
buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
function select$2(luvio, params) {
|
|
799
|
+
return select$4();
|
|
800
|
+
}
|
|
801
|
+
function keyBuilder$2(luvio, params) {
|
|
802
|
+
return keyBuilder$5(luvio, {
|
|
803
|
+
surface: params.urlParams.surfaceId
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
807
|
+
getTypeCacheKeys$1(storeKeyMap, luvio, response);
|
|
808
|
+
}
|
|
809
|
+
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
810
|
+
const { body } = response;
|
|
811
|
+
const key = keyBuilder$2(luvio, resourceParams);
|
|
812
|
+
luvio.storeIngest(key, ingest$1, body);
|
|
813
|
+
const snapshot = luvio.storeLookup({
|
|
814
|
+
recordId: key,
|
|
815
|
+
node: select$2(),
|
|
816
|
+
variables: {},
|
|
817
|
+
}, snapshotRefresh);
|
|
818
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
819
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
820
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
deepFreeze(snapshot.data);
|
|
824
|
+
return snapshot;
|
|
825
|
+
}
|
|
826
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
827
|
+
const key = keyBuilder$2(luvio, params);
|
|
828
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
829
|
+
luvio.storeIngestError(key, errorSnapshot);
|
|
830
|
+
return errorSnapshot;
|
|
831
|
+
}
|
|
832
|
+
function createResourceRequest$1(config) {
|
|
833
|
+
const headers = {};
|
|
834
|
+
return {
|
|
835
|
+
baseUri: '/services/data/v66.0',
|
|
836
|
+
basePath: '/yukon/surfaces/' + config.urlParams.surfaceId + '/nudges/mock',
|
|
837
|
+
method: 'get',
|
|
838
|
+
body: null,
|
|
839
|
+
urlParams: config.urlParams,
|
|
840
|
+
queryParams: config.queryParams,
|
|
841
|
+
headers,
|
|
842
|
+
priority: 'normal',
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
const adapterName$1 = 'getYukonSurfaceNudgesMock';
|
|
847
|
+
const getYukonSurfaceNudgesMock_ConfigPropertyMetadata = [
|
|
848
|
+
generateParamConfigMetadata('surfaceId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
849
|
+
generateParamConfigMetadata('mockWith', false, 1 /* QueryParameter */, 0 /* String */),
|
|
850
|
+
generateParamConfigMetadata('size', false, 1 /* QueryParameter */, 3 /* Integer */),
|
|
851
|
+
];
|
|
852
|
+
const getYukonSurfaceNudgesMock_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getYukonSurfaceNudgesMock_ConfigPropertyMetadata);
|
|
853
|
+
const createResourceParams$1 = /*#__PURE__*/ createResourceParams$3(getYukonSurfaceNudgesMock_ConfigPropertyMetadata);
|
|
854
|
+
function keyBuilder$1(luvio, config) {
|
|
855
|
+
const resourceParams = createResourceParams$1(config);
|
|
856
|
+
return keyBuilder$2(luvio, resourceParams);
|
|
857
|
+
}
|
|
858
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
859
|
+
const config = {};
|
|
860
|
+
typeCheckConfig$3(untrustedConfig, config, getYukonSurfaceNudgesMock_ConfigPropertyMetadata);
|
|
861
|
+
return config;
|
|
862
|
+
}
|
|
863
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
864
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
868
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
869
|
+
}
|
|
870
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
871
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
872
|
+
return null;
|
|
873
|
+
}
|
|
874
|
+
return config;
|
|
875
|
+
}
|
|
876
|
+
function adapterFragment(luvio, config) {
|
|
877
|
+
createResourceParams$1(config);
|
|
878
|
+
return select$2();
|
|
879
|
+
}
|
|
880
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
881
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
882
|
+
config,
|
|
883
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
884
|
+
});
|
|
885
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
886
|
+
}
|
|
887
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
888
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
889
|
+
config,
|
|
890
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
891
|
+
});
|
|
892
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
893
|
+
}
|
|
894
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
895
|
+
const resourceParams = createResourceParams$1(config);
|
|
896
|
+
const request = createResourceRequest$1(resourceParams);
|
|
897
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
898
|
+
.then((response) => {
|
|
899
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
|
|
900
|
+
const cache = new StoreKeyMap();
|
|
901
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
902
|
+
return cache;
|
|
903
|
+
});
|
|
904
|
+
}, (response) => {
|
|
905
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
909
|
+
return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
|
|
910
|
+
}
|
|
911
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
912
|
+
const { luvio, config } = context;
|
|
913
|
+
const selector = {
|
|
914
|
+
recordId: keyBuilder$1(luvio, config),
|
|
915
|
+
node: adapterFragment(luvio, config),
|
|
916
|
+
variables: {},
|
|
917
|
+
};
|
|
918
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
919
|
+
config,
|
|
920
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
921
|
+
});
|
|
922
|
+
return cacheSnapshot;
|
|
923
|
+
}
|
|
924
|
+
const getYukonSurfaceNudgesMockAdapterFactory = (luvio) => function Yukon__getYukonSurfaceNudgesMock(untrustedConfig, requestContext) {
|
|
925
|
+
const config = validateAdapterConfig$1(untrustedConfig, getYukonSurfaceNudgesMock_ConfigPropertyNames);
|
|
926
|
+
// Invalid or incomplete config
|
|
927
|
+
if (config === null) {
|
|
928
|
+
return null;
|
|
929
|
+
}
|
|
930
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
931
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
function validate$1(obj, path = 'YukonTelemetryInputRepresentation') {
|
|
935
|
+
const v_error = (() => {
|
|
936
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
937
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
938
|
+
}
|
|
939
|
+
const obj_actionType = obj.actionType;
|
|
940
|
+
const path_actionType = path + '.actionType';
|
|
941
|
+
if (typeof obj_actionType !== 'string') {
|
|
942
|
+
return new TypeError('Expected "string" but received "' + typeof obj_actionType + '" (at "' + path_actionType + '")');
|
|
943
|
+
}
|
|
944
|
+
const obj_nudgeUniqueName = obj.nudgeUniqueName;
|
|
945
|
+
const path_nudgeUniqueName = path + '.nudgeUniqueName';
|
|
946
|
+
if (typeof obj_nudgeUniqueName !== 'string') {
|
|
947
|
+
return new TypeError('Expected "string" but received "' + typeof obj_nudgeUniqueName + '" (at "' + path_nudgeUniqueName + '")');
|
|
948
|
+
}
|
|
949
|
+
obj.timestamp;
|
|
950
|
+
})();
|
|
951
|
+
return v_error === undefined ? null : v_error;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const VERSION = "e7558ad301657c3ee704a2c236e9f427";
|
|
955
|
+
function validate(obj, path = 'YukonTelemetryOutputRepresentation') {
|
|
956
|
+
const v_error = (() => {
|
|
957
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
958
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
959
|
+
}
|
|
960
|
+
if (obj.errorMessage !== undefined) {
|
|
961
|
+
const obj_errorMessage = obj.errorMessage;
|
|
962
|
+
const path_errorMessage = path + '.errorMessage';
|
|
963
|
+
if (typeof obj_errorMessage !== 'string') {
|
|
964
|
+
return new TypeError('Expected "string" but received "' + typeof obj_errorMessage + '" (at "' + path_errorMessage + '")');
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const obj_status = obj.status;
|
|
968
|
+
const path_status = path + '.status';
|
|
969
|
+
if (typeof obj_status !== 'string') {
|
|
970
|
+
return new TypeError('Expected "string" but received "' + typeof obj_status + '" (at "' + path_status + '")');
|
|
971
|
+
}
|
|
972
|
+
})();
|
|
973
|
+
return v_error === undefined ? null : v_error;
|
|
974
|
+
}
|
|
975
|
+
const RepresentationType = 'YukonTelemetryOutputRepresentation';
|
|
976
|
+
function keyBuilder(luvio, config) {
|
|
977
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.id;
|
|
978
|
+
}
|
|
979
|
+
function keyBuilderFromType(luvio, object) {
|
|
980
|
+
const keyParams = {
|
|
981
|
+
id: object.status
|
|
982
|
+
};
|
|
983
|
+
return keyBuilder(luvio, keyParams);
|
|
984
|
+
}
|
|
985
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
986
|
+
return input;
|
|
987
|
+
}
|
|
988
|
+
const select$1 = function YukonTelemetryOutputRepresentationSelect() {
|
|
989
|
+
return {
|
|
990
|
+
kind: 'Fragment',
|
|
991
|
+
version: VERSION,
|
|
992
|
+
private: [],
|
|
993
|
+
selections: [
|
|
994
|
+
{
|
|
995
|
+
name: 'errorMessage',
|
|
996
|
+
kind: 'Scalar',
|
|
997
|
+
required: false
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
name: 'status',
|
|
1001
|
+
kind: 'Scalar'
|
|
1002
|
+
}
|
|
1003
|
+
]
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
1006
|
+
function equals(existing, incoming) {
|
|
1007
|
+
const existing_errorMessage = existing.errorMessage;
|
|
1008
|
+
const incoming_errorMessage = incoming.errorMessage;
|
|
1009
|
+
// if at least one of these optionals is defined
|
|
1010
|
+
if (existing_errorMessage !== undefined || incoming_errorMessage !== undefined) {
|
|
1011
|
+
// if one of these is not defined we know the other is defined and therefore
|
|
1012
|
+
// not equal
|
|
1013
|
+
if (existing_errorMessage === undefined || incoming_errorMessage === undefined) {
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
if (!(existing_errorMessage === incoming_errorMessage)) {
|
|
1017
|
+
return false;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
const existing_status = existing.status;
|
|
1021
|
+
const incoming_status = incoming.status;
|
|
1022
|
+
if (!(existing_status === incoming_status)) {
|
|
1023
|
+
return false;
|
|
1024
|
+
}
|
|
1025
|
+
return true;
|
|
1026
|
+
}
|
|
1027
|
+
const ingest = function YukonTelemetryOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
1028
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1029
|
+
const validateError = validate(input);
|
|
1030
|
+
if (validateError !== null) {
|
|
1031
|
+
throw validateError;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
const key = keyBuilderFromType(luvio, input);
|
|
1035
|
+
const ttlToUse = path.ttl !== undefined ? path.ttl : 30000;
|
|
1036
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "Yukon", VERSION, RepresentationType, equals);
|
|
1037
|
+
return createLink(key);
|
|
1038
|
+
};
|
|
1039
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
1040
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
1041
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
1042
|
+
rootKeySet.set(rootKey, {
|
|
1043
|
+
namespace: keyPrefix,
|
|
1044
|
+
representationName: RepresentationType,
|
|
1045
|
+
mergeable: false
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
function select(luvio, params) {
|
|
1050
|
+
return select$1();
|
|
1051
|
+
}
|
|
1052
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
1053
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
1054
|
+
}
|
|
1055
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
1056
|
+
const { body } = response;
|
|
1057
|
+
const key = keyBuilderFromType(luvio, body);
|
|
1058
|
+
luvio.storeIngest(key, ingest, body);
|
|
1059
|
+
const snapshot = luvio.storeLookup({
|
|
1060
|
+
recordId: key,
|
|
1061
|
+
node: select(),
|
|
1062
|
+
variables: {},
|
|
1063
|
+
});
|
|
1064
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1065
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
1066
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
deepFreeze(snapshot.data);
|
|
1070
|
+
return snapshot;
|
|
1071
|
+
}
|
|
1072
|
+
function createResourceRequest(config) {
|
|
1073
|
+
const headers = {};
|
|
1074
|
+
return {
|
|
1075
|
+
baseUri: '/services/data/v66.0',
|
|
1076
|
+
basePath: '/yukon/telemetry',
|
|
1077
|
+
method: 'post',
|
|
1078
|
+
body: config.body,
|
|
1079
|
+
urlParams: {},
|
|
1080
|
+
queryParams: {},
|
|
1081
|
+
headers,
|
|
1082
|
+
priority: 'normal',
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
const adapterName = 'postYukonTelemetry';
|
|
1087
|
+
const postYukonTelemetry_ConfigPropertyMetadata = [
|
|
1088
|
+
generateParamConfigMetadata('actions', true, 2 /* Body */, 4 /* Unsupported */, true),
|
|
1089
|
+
];
|
|
1090
|
+
const postYukonTelemetry_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, postYukonTelemetry_ConfigPropertyMetadata);
|
|
1091
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$3(postYukonTelemetry_ConfigPropertyMetadata);
|
|
1092
|
+
function typeCheckConfig(untrustedConfig) {
|
|
1093
|
+
const config = {};
|
|
1094
|
+
const untrustedConfig_actions = untrustedConfig.actions;
|
|
1095
|
+
if (ArrayIsArray$1(untrustedConfig_actions)) {
|
|
1096
|
+
const untrustedConfig_actions_array = [];
|
|
1097
|
+
for (let i = 0, arrayLength = untrustedConfig_actions.length; i < arrayLength; i++) {
|
|
1098
|
+
const untrustedConfig_actions_item = untrustedConfig_actions[i];
|
|
1099
|
+
const referenceYukonTelemetryInputRepresentationValidationError = validate$1(untrustedConfig_actions_item);
|
|
1100
|
+
if (referenceYukonTelemetryInputRepresentationValidationError === null) {
|
|
1101
|
+
untrustedConfig_actions_array.push(untrustedConfig_actions_item);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
config.actions = untrustedConfig_actions_array;
|
|
1105
|
+
}
|
|
1106
|
+
return config;
|
|
1107
|
+
}
|
|
1108
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
1109
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
1110
|
+
return null;
|
|
1111
|
+
}
|
|
1112
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1113
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
1114
|
+
}
|
|
1115
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
1116
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
1119
|
+
return config;
|
|
1120
|
+
}
|
|
1121
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
1122
|
+
const resourceParams = createResourceParams(config);
|
|
1123
|
+
const request = createResourceRequest(resourceParams);
|
|
1124
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
1125
|
+
.then((response) => {
|
|
1126
|
+
return luvio.handleSuccessResponse(() => {
|
|
1127
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
1128
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
1129
|
+
}, () => {
|
|
1130
|
+
const cache = new StoreKeyMap();
|
|
1131
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
1132
|
+
return cache;
|
|
1133
|
+
});
|
|
1134
|
+
}, (response) => {
|
|
1135
|
+
deepFreeze(response);
|
|
1136
|
+
throw response;
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
const postYukonTelemetryAdapterFactory = (luvio) => {
|
|
1140
|
+
return function postYukonTelemetry(untrustedConfig) {
|
|
1141
|
+
const config = validateAdapterConfig(untrustedConfig, postYukonTelemetry_ConfigPropertyNames);
|
|
1142
|
+
// Invalid or incomplete config
|
|
1143
|
+
if (config === null) {
|
|
1144
|
+
throw new Error('Invalid config for "postYukonTelemetry"');
|
|
1145
|
+
}
|
|
1146
|
+
return buildNetworkSnapshot(luvio, config);
|
|
1147
|
+
};
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
export { getYukonSurfaceNudgesAdapterFactory, getYukonSurfaceNudgesMockAdapterFactory, postYukonTelemetryAdapterFactory };
|