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