@salesforce/lds-adapters-platform-flow 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.
- package/LICENSE.txt +82 -0
- package/dist/es/es2018/platform-flow.js +581 -0
- package/dist/types/src/adapters/navigateFlow.d.ts +6 -0
- package/dist/types/src/adapters/resumeFlow.d.ts +6 -0
- package/dist/types/src/adapters/startFlow.d.ts +6 -0
- package/dist/types/src/artifacts/main.d.ts +3 -0
- package/dist/types/src/artifacts/sfdc.d.ts +4 -0
- package/dist/types/src/generated/adapters/adapter-utils.d.ts +66 -0
- package/dist/types/src/generated/adapters/navigateFlow.d.ts +27 -0
- package/dist/types/src/generated/adapters/resumeFlow.d.ts +26 -0
- package/dist/types/src/generated/adapters/startFlow.d.ts +31 -0
- package/dist/types/src/generated/artifacts/main.d.ts +3 -0
- package/dist/types/src/generated/artifacts/sfdc.d.ts +7 -0
- package/dist/types/src/generated/resources/postConnectInteractionRuntimeNavigateFlow.d.ts +16 -0
- package/dist/types/src/generated/resources/postConnectInteractionRuntimeResumeFlow.d.ts +15 -0
- package/dist/types/src/generated/resources/postConnectInteractionRuntimeStartFlow.d.ts +20 -0
- package/dist/types/src/generated/types/FlowRuntimeHashbagRepresentation.d.ts +28 -0
- package/dist/types/src/generated/types/FlowRuntimeNavigateFlowRepresentation.d.ts +40 -0
- package/dist/types/src/generated/types/FlowRuntimeNavigateFlowWrapperRepresentation.d.ts +29 -0
- package/dist/types/src/generated/types/FlowRuntimeNavigationFieldValue.d.ts +32 -0
- package/dist/types/src/generated/types/FlowRuntimeNavigationResult.d.ts +28 -0
- package/dist/types/src/generated/types/FlowRuntimeResponseRepresentation.d.ts +31 -0
- package/dist/types/src/generated/types/FlowRuntimeResumeFlowRepresentation.d.ts +28 -0
- package/dist/types/src/generated/types/FlowRuntimeRunFlowRepresentation.d.ts +38 -0
- package/dist/types/src/generated/types/type-utils.d.ts +39 -0
- package/dist/umd/es2018/platform-flow.js +591 -0
- package/dist/umd/es5/platform-flow.js +600 -0
- package/package.json +65 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +609 -0
- package/src/raml/api.raml +159 -0
- package/src/raml/luvio.raml +30 -0
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
(function (global, factory) {
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.platformFlow = {}, global.engine));
|
|
11
|
+
})(this, (function (exports, engine) { 'use strict';
|
|
12
|
+
|
|
13
|
+
const { freeze: ObjectFreeze$1, keys: ObjectKeys$1, create: ObjectCreate$1, assign: ObjectAssign } = Object;
|
|
14
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
15
|
+
function deepFreeze$2(value) {
|
|
16
|
+
// No need to freeze primitives
|
|
17
|
+
if (typeof value !== 'object' || value === null) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (ArrayIsArray$1(value)) {
|
|
21
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
22
|
+
deepFreeze$2(value[i]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const keys = ObjectKeys$1(value);
|
|
27
|
+
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
28
|
+
deepFreeze$2(value[keys[i]]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
ObjectFreeze$1(value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
35
|
+
const { keys: ObjectKeys, freeze: ObjectFreeze, create: ObjectCreate } = Object;
|
|
36
|
+
const { stringify: JSONStringify } = JSON;
|
|
37
|
+
const { isArray: ArrayIsArray } = Array;
|
|
38
|
+
/**
|
|
39
|
+
* Validates an adapter config is well-formed.
|
|
40
|
+
* @param config The config to validate.
|
|
41
|
+
* @param adapter The adapter validation configuration.
|
|
42
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
43
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
44
|
+
*/
|
|
45
|
+
function validateConfig(config, adapter, oneOf) {
|
|
46
|
+
const { displayName } = adapter;
|
|
47
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
48
|
+
if (config === undefined ||
|
|
49
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
50
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
51
|
+
}
|
|
52
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
53
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
54
|
+
}
|
|
55
|
+
if (unsupported !== undefined &&
|
|
56
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
57
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
58
|
+
}
|
|
59
|
+
const supported = required.concat(optional);
|
|
60
|
+
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
61
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function untrustedIsObject(untrusted) {
|
|
65
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray(untrusted) === false;
|
|
66
|
+
}
|
|
67
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
68
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
|
|
72
|
+
* This is needed because insertion order for JSON.stringify(object) affects output:
|
|
73
|
+
* JSON.stringify({a: 1, b: 2})
|
|
74
|
+
* "{"a":1,"b":2}"
|
|
75
|
+
* JSON.stringify({b: 2, a: 1})
|
|
76
|
+
* "{"b":2,"a":1}"
|
|
77
|
+
* @param data Data to be JSON-stringified.
|
|
78
|
+
* @returns JSON.stringified value with consistent ordering of keys.
|
|
79
|
+
*/
|
|
80
|
+
function stableJSONStringify(node) {
|
|
81
|
+
// This is for Date values.
|
|
82
|
+
if (node && node.toJSON && typeof node.toJSON === 'function') {
|
|
83
|
+
// eslint-disable-next-line no-param-reassign
|
|
84
|
+
node = node.toJSON();
|
|
85
|
+
}
|
|
86
|
+
if (node === undefined) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (typeof node === 'number') {
|
|
90
|
+
return isFinite(node) ? '' + node : 'null';
|
|
91
|
+
}
|
|
92
|
+
if (typeof node !== 'object') {
|
|
93
|
+
return JSONStringify(node);
|
|
94
|
+
}
|
|
95
|
+
let i;
|
|
96
|
+
let out;
|
|
97
|
+
if (ArrayIsArray(node)) {
|
|
98
|
+
out = '[';
|
|
99
|
+
for (i = 0; i < node.length; i++) {
|
|
100
|
+
if (i) {
|
|
101
|
+
out += ',';
|
|
102
|
+
}
|
|
103
|
+
out += stableJSONStringify(node[i]) || 'null';
|
|
104
|
+
}
|
|
105
|
+
return out + ']';
|
|
106
|
+
}
|
|
107
|
+
if (node === null) {
|
|
108
|
+
return 'null';
|
|
109
|
+
}
|
|
110
|
+
const keys = ObjectKeys(node).sort();
|
|
111
|
+
out = '';
|
|
112
|
+
for (i = 0; i < keys.length; i++) {
|
|
113
|
+
const key = keys[i];
|
|
114
|
+
const value = stableJSONStringify(node[key]);
|
|
115
|
+
if (!value) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (out) {
|
|
119
|
+
out += ',';
|
|
120
|
+
}
|
|
121
|
+
out += JSONStringify(key) + ':' + value;
|
|
122
|
+
}
|
|
123
|
+
return '{' + out + '}';
|
|
124
|
+
}
|
|
125
|
+
const keyPrefix = 'FlowRuntime';
|
|
126
|
+
|
|
127
|
+
function deepFreeze$1(input) {
|
|
128
|
+
const input_keys = Object.keys(input);
|
|
129
|
+
const input_length = input_keys.length;
|
|
130
|
+
for (let i = 0; i < input_length; i++) {
|
|
131
|
+
const key = input_keys[i];
|
|
132
|
+
const input_prop = input[key];
|
|
133
|
+
deepFreeze$2(input_prop);
|
|
134
|
+
}
|
|
135
|
+
ObjectFreeze$1(input);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const RepresentationType = 'FlowRuntimeResponseRepresentation';
|
|
139
|
+
function deepFreeze(input) {
|
|
140
|
+
const input_error = input.error;
|
|
141
|
+
if (input_error !== undefined) {
|
|
142
|
+
deepFreeze$2(input_error);
|
|
143
|
+
}
|
|
144
|
+
const input_response = input.response;
|
|
145
|
+
if (input_response !== undefined) {
|
|
146
|
+
if (input_response !== null && typeof input_response === 'object') {
|
|
147
|
+
deepFreeze$1(input_response);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
ObjectFreeze$1(input);
|
|
151
|
+
}
|
|
152
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
153
|
+
const rootKeySet = new engine.StoreKeyMap();
|
|
154
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
155
|
+
const rootKey = fullPathFactory();
|
|
156
|
+
rootKeySet.set(rootKey, {
|
|
157
|
+
namespace: keyPrefix,
|
|
158
|
+
representationName: RepresentationType,
|
|
159
|
+
mergeable: false
|
|
160
|
+
});
|
|
161
|
+
return rootKeySet;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function keyBuilder$2(luvio, params) {
|
|
165
|
+
return keyPrefix + '::FlowRuntimeResponseRepresentation:(' + 'flowDevName:' + params.body.flowDevName + '::' + (params.body.flowVersionId === undefined ? 'flowVersionId' : 'flowVersionId:' + params.body.flowVersionId) + '::' + (params.body.arguments === undefined ? 'arguments' : 'arguments:' + params.body.arguments) + '::' + (params.body.enableTrace === undefined ? 'enableTrace' : 'enableTrace:' + params.body.enableTrace) + '::' + (params.body.enableRollbackMode === undefined ? 'enableRollbackMode' : 'enableRollbackMode:' + params.body.enableRollbackMode) + '::' + (params.body.debugAsUserId === undefined ? 'debugAsUserId' : 'debugAsUserId:' + params.body.debugAsUserId) + ')';
|
|
166
|
+
}
|
|
167
|
+
function getResponseCacheKeys$2(luvio, resourceParams, response) {
|
|
168
|
+
return getTypeCacheKeys(luvio, response, () => keyBuilder$2(luvio, resourceParams));
|
|
169
|
+
}
|
|
170
|
+
function createResourceRequest$2(config) {
|
|
171
|
+
const headers = {};
|
|
172
|
+
return {
|
|
173
|
+
baseUri: '/services/data/v58.0',
|
|
174
|
+
basePath: '/connect/interaction/runtime/startFlow',
|
|
175
|
+
method: 'post',
|
|
176
|
+
body: config.body,
|
|
177
|
+
urlParams: {},
|
|
178
|
+
queryParams: {},
|
|
179
|
+
headers,
|
|
180
|
+
priority: 'normal',
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const startFlow_ConfigPropertyNames = {
|
|
185
|
+
displayName: 'startFlow',
|
|
186
|
+
parameters: {
|
|
187
|
+
required: ['flowDevName'],
|
|
188
|
+
optional: ['flowVersionId', 'arguments', 'enableTrace', 'enableRollbackMode', 'debugAsUserId']
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
function createResourceParams$2(config) {
|
|
192
|
+
const resourceParams = {
|
|
193
|
+
body: {
|
|
194
|
+
flowDevName: config.flowDevName
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
if (config['flowVersionId'] !== undefined) {
|
|
198
|
+
resourceParams.body['flowVersionId'] = config['flowVersionId'];
|
|
199
|
+
}
|
|
200
|
+
if (config['arguments'] !== undefined) {
|
|
201
|
+
resourceParams.body['arguments'] = config['arguments'];
|
|
202
|
+
}
|
|
203
|
+
if (config['enableTrace'] !== undefined) {
|
|
204
|
+
resourceParams.body['enableTrace'] = config['enableTrace'];
|
|
205
|
+
}
|
|
206
|
+
if (config['enableRollbackMode'] !== undefined) {
|
|
207
|
+
resourceParams.body['enableRollbackMode'] = config['enableRollbackMode'];
|
|
208
|
+
}
|
|
209
|
+
if (config['debugAsUserId'] !== undefined) {
|
|
210
|
+
resourceParams.body['debugAsUserId'] = config['debugAsUserId'];
|
|
211
|
+
}
|
|
212
|
+
return resourceParams;
|
|
213
|
+
}
|
|
214
|
+
function typeCheckConfig$2(untrustedConfig) {
|
|
215
|
+
const config = {};
|
|
216
|
+
const untrustedConfig_flowDevName = untrustedConfig.flowDevName;
|
|
217
|
+
if (typeof untrustedConfig_flowDevName === 'string') {
|
|
218
|
+
config.flowDevName = untrustedConfig_flowDevName;
|
|
219
|
+
}
|
|
220
|
+
const untrustedConfig_flowVersionId = untrustedConfig.flowVersionId;
|
|
221
|
+
if (typeof untrustedConfig_flowVersionId === 'string') {
|
|
222
|
+
config.flowVersionId = untrustedConfig_flowVersionId;
|
|
223
|
+
}
|
|
224
|
+
const untrustedConfig_arguments = untrustedConfig.arguments;
|
|
225
|
+
if (typeof untrustedConfig_arguments === 'string') {
|
|
226
|
+
config.arguments = untrustedConfig_arguments;
|
|
227
|
+
}
|
|
228
|
+
const untrustedConfig_enableTrace = untrustedConfig.enableTrace;
|
|
229
|
+
if (typeof untrustedConfig_enableTrace === 'boolean') {
|
|
230
|
+
config.enableTrace = untrustedConfig_enableTrace;
|
|
231
|
+
}
|
|
232
|
+
const untrustedConfig_enableRollbackMode = untrustedConfig.enableRollbackMode;
|
|
233
|
+
if (typeof untrustedConfig_enableRollbackMode === 'boolean') {
|
|
234
|
+
config.enableRollbackMode = untrustedConfig_enableRollbackMode;
|
|
235
|
+
}
|
|
236
|
+
const untrustedConfig_debugAsUserId = untrustedConfig.debugAsUserId;
|
|
237
|
+
if (typeof untrustedConfig_debugAsUserId === 'string') {
|
|
238
|
+
config.debugAsUserId = untrustedConfig_debugAsUserId;
|
|
239
|
+
}
|
|
240
|
+
return config;
|
|
241
|
+
}
|
|
242
|
+
function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
|
|
243
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
247
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
248
|
+
}
|
|
249
|
+
const config = typeCheckConfig$2(untrustedConfig);
|
|
250
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
return config;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function buildNetworkSnapshot$2(luvio, config, options) {
|
|
257
|
+
const resourceParams = createResourceParams$2(config);
|
|
258
|
+
const request = createResourceRequest$2(resourceParams);
|
|
259
|
+
return luvio
|
|
260
|
+
.dispatchResourceRequest(request, options)
|
|
261
|
+
.then((response) => {
|
|
262
|
+
return luvio.handleSuccessResponse(() => {
|
|
263
|
+
deepFreeze(response.body);
|
|
264
|
+
return Promise.resolve(response.body);
|
|
265
|
+
}, () => {
|
|
266
|
+
return getResponseCacheKeys$2(luvio, resourceParams, response.body);
|
|
267
|
+
});
|
|
268
|
+
}, (response) => {
|
|
269
|
+
return luvio.handleErrorResponse(() => {
|
|
270
|
+
// We want to throw these exceptions to be caught in the runtime layer
|
|
271
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
272
|
+
throw new Error(response.body.message || response.body.error || response.body);
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
const startFlowAdapterFactory = (luvio) => function flowRuntime__startFlow(untrustedConfig) {
|
|
277
|
+
const config = validateAdapterConfig$2(untrustedConfig, startFlow_ConfigPropertyNames);
|
|
278
|
+
// Invalid or incomplete config
|
|
279
|
+
if (config === null) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
return buildNetworkSnapshot$2(luvio, config);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
function keyBuilder$1(luvio, params) {
|
|
286
|
+
return keyPrefix + '::FlowRuntimeResponseRepresentation:(' + 'request.action:' + params.body.request.action + '::' + 'request.serializedState:' + params.body.request.serializedState + '::' + (params.body.request.fields === undefined ? 'request.fields' : 'request.fields:' + params.body.request.fields) + '::' + (params.body.request.uiElementVisited === undefined ? 'request.uiElementVisited' : 'request.uiElementVisited:' + params.body.request.uiElementVisited) + '::' + (params.body.request.enableTrace === undefined ? 'request.enableTrace' : 'request.enableTrace:' + params.body.request.enableTrace) + '::' + stableJSONStringify(params.body.request.lcErrors) + ')';
|
|
287
|
+
}
|
|
288
|
+
function getResponseCacheKeys$1(luvio, resourceParams, response) {
|
|
289
|
+
return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
|
|
290
|
+
}
|
|
291
|
+
function createResourceRequest$1(config) {
|
|
292
|
+
const headers = {};
|
|
293
|
+
return {
|
|
294
|
+
baseUri: '/services/data/v58.0',
|
|
295
|
+
basePath: '/connect/interaction/runtime/navigateFlow',
|
|
296
|
+
method: 'post',
|
|
297
|
+
body: config.body,
|
|
298
|
+
urlParams: {},
|
|
299
|
+
queryParams: {},
|
|
300
|
+
headers,
|
|
301
|
+
priority: 'normal',
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function validate$2(obj, path = 'FlowRuntimeNavigationFieldValue') {
|
|
306
|
+
const v_error = (() => {
|
|
307
|
+
if (typeof obj !== 'object' || ArrayIsArray$1(obj) || obj === null) {
|
|
308
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
309
|
+
}
|
|
310
|
+
const obj_field = obj.field;
|
|
311
|
+
const path_field = path + '.field';
|
|
312
|
+
if (typeof obj_field !== 'string') {
|
|
313
|
+
return new TypeError('Expected "string" but received "' + typeof obj_field + '" (at "' + path_field + '")');
|
|
314
|
+
}
|
|
315
|
+
if (obj.isVisible !== undefined) {
|
|
316
|
+
const obj_isVisible = obj.isVisible;
|
|
317
|
+
const path_isVisible = path + '.isVisible';
|
|
318
|
+
let obj_isVisible_union0 = null;
|
|
319
|
+
const obj_isVisible_union0_error = (() => {
|
|
320
|
+
if (typeof obj_isVisible !== 'boolean') {
|
|
321
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_isVisible + '" (at "' + path_isVisible + '")');
|
|
322
|
+
}
|
|
323
|
+
})();
|
|
324
|
+
if (obj_isVisible_union0_error != null) {
|
|
325
|
+
obj_isVisible_union0 = obj_isVisible_union0_error.message;
|
|
326
|
+
}
|
|
327
|
+
let obj_isVisible_union1 = null;
|
|
328
|
+
const obj_isVisible_union1_error = (() => {
|
|
329
|
+
if (obj_isVisible !== null) {
|
|
330
|
+
return new TypeError('Expected "null" but received "' + typeof obj_isVisible + '" (at "' + path_isVisible + '")');
|
|
331
|
+
}
|
|
332
|
+
})();
|
|
333
|
+
if (obj_isVisible_union1_error != null) {
|
|
334
|
+
obj_isVisible_union1 = obj_isVisible_union1_error.message;
|
|
335
|
+
}
|
|
336
|
+
if (obj_isVisible_union0 && obj_isVisible_union1) {
|
|
337
|
+
let message = 'Object doesn\'t match union (at "' + path_isVisible + '")';
|
|
338
|
+
message += '\n' + obj_isVisible_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
339
|
+
message += '\n' + obj_isVisible_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
340
|
+
return new TypeError(message);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (obj.value !== undefined) {
|
|
344
|
+
const obj_value = obj.value;
|
|
345
|
+
const path_value = path + '.value';
|
|
346
|
+
if (obj_value === undefined) {
|
|
347
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_value + '" (at "' + path_value + '")');
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
})();
|
|
351
|
+
return v_error === undefined ? null : v_error;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function validate$1(obj, path = 'FlowRuntimeHashbagRepresentation') {
|
|
355
|
+
const v_error = (() => {
|
|
356
|
+
if (typeof obj !== 'object' || ArrayIsArray$1(obj) || obj === null) {
|
|
357
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
358
|
+
}
|
|
359
|
+
const obj_keys = ObjectKeys$1(obj);
|
|
360
|
+
for (let i = 0; i < obj_keys.length; i++) {
|
|
361
|
+
const key = obj_keys[i];
|
|
362
|
+
const obj_prop = obj[key];
|
|
363
|
+
const path_prop = path + '["' + key + '"]';
|
|
364
|
+
if (obj_prop === undefined) {
|
|
365
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_prop + '" (at "' + path_prop + '")');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
})();
|
|
369
|
+
return v_error === undefined ? null : v_error;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function validate(obj, path = 'FlowRuntimeNavigateFlowRepresentation') {
|
|
373
|
+
const v_error = (() => {
|
|
374
|
+
if (typeof obj !== 'object' || ArrayIsArray$1(obj) || obj === null) {
|
|
375
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
376
|
+
}
|
|
377
|
+
const obj_action = obj.action;
|
|
378
|
+
const path_action = path + '.action';
|
|
379
|
+
if (typeof obj_action !== 'string') {
|
|
380
|
+
return new TypeError('Expected "string" but received "' + typeof obj_action + '" (at "' + path_action + '")');
|
|
381
|
+
}
|
|
382
|
+
if (obj.enableTrace !== undefined) {
|
|
383
|
+
const obj_enableTrace = obj.enableTrace;
|
|
384
|
+
const path_enableTrace = path + '.enableTrace';
|
|
385
|
+
if (typeof obj_enableTrace !== 'boolean') {
|
|
386
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_enableTrace + '" (at "' + path_enableTrace + '")');
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (obj.fields !== undefined) {
|
|
390
|
+
const obj_fields = obj.fields;
|
|
391
|
+
const path_fields = path + '.fields';
|
|
392
|
+
if (!ArrayIsArray$1(obj_fields)) {
|
|
393
|
+
return new TypeError('Expected "array" but received "' + typeof obj_fields + '" (at "' + path_fields + '")');
|
|
394
|
+
}
|
|
395
|
+
for (let i = 0; i < obj_fields.length; i++) {
|
|
396
|
+
const obj_fields_item = obj_fields[i];
|
|
397
|
+
const path_fields_item = path_fields + '[' + i + ']';
|
|
398
|
+
const referencepath_fields_itemValidationError = validate$2(obj_fields_item, path_fields_item);
|
|
399
|
+
if (referencepath_fields_itemValidationError !== null) {
|
|
400
|
+
let message = 'Object doesn\'t match FlowRuntimeNavigationFieldValue (at "' + path_fields_item + '")\n';
|
|
401
|
+
message += referencepath_fields_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
402
|
+
return new TypeError(message);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (obj.lcErrors !== undefined) {
|
|
407
|
+
const obj_lcErrors = obj.lcErrors;
|
|
408
|
+
const path_lcErrors = path + '.lcErrors';
|
|
409
|
+
const referencepath_lcErrorsValidationError = validate$1(obj_lcErrors, path_lcErrors);
|
|
410
|
+
if (referencepath_lcErrorsValidationError !== null) {
|
|
411
|
+
let message = 'Object doesn\'t match FlowRuntimeHashbagRepresentation (at "' + path_lcErrors + '")\n';
|
|
412
|
+
message += referencepath_lcErrorsValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
413
|
+
return new TypeError(message);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const obj_serializedState = obj.serializedState;
|
|
417
|
+
const path_serializedState = path + '.serializedState';
|
|
418
|
+
if (typeof obj_serializedState !== 'string') {
|
|
419
|
+
return new TypeError('Expected "string" but received "' + typeof obj_serializedState + '" (at "' + path_serializedState + '")');
|
|
420
|
+
}
|
|
421
|
+
if (obj.uiElementVisited !== undefined) {
|
|
422
|
+
const obj_uiElementVisited = obj.uiElementVisited;
|
|
423
|
+
const path_uiElementVisited = path + '.uiElementVisited';
|
|
424
|
+
if (typeof obj_uiElementVisited !== 'boolean') {
|
|
425
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_uiElementVisited + '" (at "' + path_uiElementVisited + '")');
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
})();
|
|
429
|
+
return v_error === undefined ? null : v_error;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const navigateFlow_ConfigPropertyNames = {
|
|
433
|
+
displayName: 'navigateFlow',
|
|
434
|
+
parameters: {
|
|
435
|
+
required: ['request'],
|
|
436
|
+
optional: []
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
function createResourceParams$1(config) {
|
|
440
|
+
const resourceParams = {
|
|
441
|
+
body: {
|
|
442
|
+
request: config.request
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
return resourceParams;
|
|
446
|
+
}
|
|
447
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
448
|
+
const config = {};
|
|
449
|
+
const untrustedConfig_request = untrustedConfig.request;
|
|
450
|
+
const referenceFlowRuntimeNavigateFlowRepresentationValidationError = validate(untrustedConfig_request);
|
|
451
|
+
if (referenceFlowRuntimeNavigateFlowRepresentationValidationError === null) {
|
|
452
|
+
config.request = untrustedConfig_request;
|
|
453
|
+
}
|
|
454
|
+
return config;
|
|
455
|
+
}
|
|
456
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
457
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
461
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
462
|
+
}
|
|
463
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
464
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
return config;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function buildNetworkSnapshot$1(luvio, config, context) {
|
|
471
|
+
const resourceParams = createResourceParams$1(config);
|
|
472
|
+
const request = createResourceRequest$1(resourceParams);
|
|
473
|
+
return luvio
|
|
474
|
+
.dispatchResourceRequest(request, context)
|
|
475
|
+
.then((response) => {
|
|
476
|
+
return luvio.handleSuccessResponse(() => {
|
|
477
|
+
deepFreeze(response.body);
|
|
478
|
+
return Promise.resolve(response.body);
|
|
479
|
+
}, () => {
|
|
480
|
+
return getResponseCacheKeys$1(luvio, resourceParams, response.body);
|
|
481
|
+
});
|
|
482
|
+
}, (response) => {
|
|
483
|
+
return luvio.handleErrorResponse(() => {
|
|
484
|
+
// We want to throw these exceptions to be caught in the runtime layer
|
|
485
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
486
|
+
throw new Error(response.body.message || response.body.error || response.body);
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
const navigateFlowAdapterFactory = (luvio) => function flowRuntime__navigateFlow(untrustedConfig) {
|
|
491
|
+
const config = validateAdapterConfig$1(untrustedConfig, navigateFlow_ConfigPropertyNames);
|
|
492
|
+
// Invalid or incomplete config
|
|
493
|
+
if (config === null) {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
return buildNetworkSnapshot$1(luvio, config);
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
function keyBuilder(luvio, params) {
|
|
500
|
+
return keyPrefix + '::FlowRuntimeResponseRepresentation:(' + 'pausedInterviewId:' + params.body.pausedInterviewId + ')';
|
|
501
|
+
}
|
|
502
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
503
|
+
return getTypeCacheKeys(luvio, response, () => keyBuilder(luvio, resourceParams));
|
|
504
|
+
}
|
|
505
|
+
function createResourceRequest(config) {
|
|
506
|
+
const headers = {};
|
|
507
|
+
return {
|
|
508
|
+
baseUri: '/services/data/v58.0',
|
|
509
|
+
basePath: '/connect/interaction/runtime/resumeFlow',
|
|
510
|
+
method: 'post',
|
|
511
|
+
body: config.body,
|
|
512
|
+
urlParams: {},
|
|
513
|
+
queryParams: {},
|
|
514
|
+
headers,
|
|
515
|
+
priority: 'normal',
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const resumeFlow_ConfigPropertyNames = {
|
|
520
|
+
displayName: 'resumeFlow',
|
|
521
|
+
parameters: {
|
|
522
|
+
required: ['pausedInterviewId'],
|
|
523
|
+
optional: []
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
function createResourceParams(config) {
|
|
527
|
+
const resourceParams = {
|
|
528
|
+
body: {
|
|
529
|
+
pausedInterviewId: config.pausedInterviewId
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
return resourceParams;
|
|
533
|
+
}
|
|
534
|
+
function typeCheckConfig(untrustedConfig) {
|
|
535
|
+
const config = {};
|
|
536
|
+
const untrustedConfig_pausedInterviewId = untrustedConfig.pausedInterviewId;
|
|
537
|
+
if (typeof untrustedConfig_pausedInterviewId === 'string') {
|
|
538
|
+
config.pausedInterviewId = untrustedConfig_pausedInterviewId;
|
|
539
|
+
}
|
|
540
|
+
return config;
|
|
541
|
+
}
|
|
542
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
543
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
544
|
+
return null;
|
|
545
|
+
}
|
|
546
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
547
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
548
|
+
}
|
|
549
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
550
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
return config;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
557
|
+
const resourceParams = createResourceParams(config);
|
|
558
|
+
const request = createResourceRequest(resourceParams);
|
|
559
|
+
return luvio
|
|
560
|
+
.dispatchResourceRequest(request, options)
|
|
561
|
+
.then((response) => {
|
|
562
|
+
return luvio.handleSuccessResponse(() => {
|
|
563
|
+
deepFreeze(response.body);
|
|
564
|
+
return Promise.resolve(response.body);
|
|
565
|
+
}, () => {
|
|
566
|
+
return getResponseCacheKeys(luvio, resourceParams, response.body);
|
|
567
|
+
});
|
|
568
|
+
}, (response) => {
|
|
569
|
+
return luvio.handleErrorResponse(() => {
|
|
570
|
+
// We want to throw these exceptions to be caught in the runtime layer
|
|
571
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
572
|
+
throw new Error(response.body.message || response.body.error || response.body);
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
const resumeFlowAdapterFactory = (luvio) => function flowRuntime__resumeFlow(untrustedConfig) {
|
|
577
|
+
const config = validateAdapterConfig(untrustedConfig, resumeFlow_ConfigPropertyNames);
|
|
578
|
+
// Invalid or incomplete config
|
|
579
|
+
if (config === null) {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
return buildNetworkSnapshot(luvio, config);
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
exports.navigateFlowAdapterFactory = navigateFlowAdapterFactory;
|
|
586
|
+
exports.resumeFlowAdapterFactory = resumeFlowAdapterFactory;
|
|
587
|
+
exports.startFlowAdapterFactory = startFlowAdapterFactory;
|
|
588
|
+
|
|
589
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
590
|
+
|
|
591
|
+
}));
|