@salesforce/lds-adapters-platform-flow 0.131.0

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