@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/LICENSE.txt ADDED
@@ -0,0 +1,82 @@
1
+ Terms of Use
2
+
3
+ Copyright 2022 Salesforce, Inc. All rights reserved.
4
+
5
+ These Terms of Use govern the download, installation, and/or use of this
6
+ software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
7
+ last updated on April 15, 2022, and constitute a legally binding
8
+ agreement between you and Salesforce. If you do not agree to these Terms of
9
+ Use, do not install or use the Software.
10
+
11
+ Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
12
+ copyright license to reproduce, prepare derivative works of, publicly
13
+ display, publicly perform, sublicense, and distribute the Software and
14
+ derivative works subject to these Terms. These Terms shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ Subject to the limited rights expressly granted hereunder, Salesforce
18
+ reserves all rights, title, and interest in and to all intellectual
19
+ property subsisting in the Software. No rights are granted to you hereunder
20
+ other than as expressly set forth herein. Users residing in countries on
21
+ the United States Office of Foreign Assets Control sanction list, or which
22
+ are otherwise subject to a US export embargo, may not use the Software.
23
+
24
+ Implementation of the Software may require development work, for which you
25
+ are responsible. The Software may contain bugs, errors and
26
+ incompatibilities and is made available on an AS IS basis without support,
27
+ updates, or service level commitments.
28
+
29
+ Salesforce reserves the right at any time to modify, suspend, or
30
+ discontinue, the Software (or any part thereof) with or without notice. You
31
+ agree that Salesforce shall not be liable to you or to any third party for
32
+ any modification, suspension, or discontinuance.
33
+
34
+ You agree to defend Salesforce against any claim, demand, suit or
35
+ proceeding made or brought against Salesforce by a third party arising out
36
+ of or accruing from (a) your use of the Software, and (b) any application
37
+ you develop with the Software that infringes any copyright, trademark,
38
+ trade secret, trade dress, patent, or other intellectual property right of
39
+ any person or defames any person or violates their rights of publicity or
40
+ privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
41
+ from any damages, attorney fees, and costs finally awarded against
42
+ Salesforce as a result of, or for any amounts paid by Salesforce under a
43
+ settlement approved by you in writing of, a Claim Against Salesforce,
44
+ provided Salesforce (x) promptly gives you written notice of the Claim
45
+ Against Salesforce, (y) gives you sole control of the defense and
46
+ settlement of the Claim Against Salesforce (except that you may not settle
47
+ any Claim Against Salesforce unless it unconditionally releases Salesforce
48
+ of all liability), and (z) gives you all reasonable assistance, at your
49
+ expense.
50
+
51
+ WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
52
+ SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
54
+ INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
55
+ PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
56
+ OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
57
+ CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
58
+ HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
59
+
60
+ These Terms of Use shall be governed exclusively by the internal laws of
61
+ the State of California, without regard to its conflicts of laws
62
+ rules. Each party hereby consents to the exclusive jurisdiction of the
63
+ state and federal courts located in San Francisco County, California to
64
+ adjudicate any dispute arising out of or relating to these Terms of Use and
65
+ the download, installation, and/or use of the Software. Except as expressly
66
+ stated herein, these Terms of Use constitute the entire agreement between
67
+ the parties, and supersede all prior and contemporaneous agreements,
68
+ proposals, or representations, written or oral, concerning their subject
69
+ matter. No modification, amendment, or waiver of any provision of these
70
+ Terms of Use shall be effective unless it is by an update to these Terms of
71
+ Use that Salesforce makes available, or is in writing and signed by the
72
+ party against whom the modification, amendment, or waiver is to be
73
+ asserted.
74
+
75
+ Data Privacy: Salesforce may collect, process, and store device,
76
+ system, and other information related to your use of the Software. This
77
+ information includes, but is not limited to, IP address, user metrics, and
78
+ other data ("Usage Data"). Salesforce may use Usage Data for analytics,
79
+ product development, and marketing purposes. You acknowledge that files
80
+ generated in conjunction with the Software may contain sensitive or
81
+ confidential data, and you are solely responsible for anonymizing and
82
+ protecting such data.
@@ -0,0 +1,581 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { StoreKeyMap } from '@luvio/engine';
8
+
9
+ const { freeze: ObjectFreeze$1, keys: ObjectKeys$1, create: ObjectCreate$1, assign: ObjectAssign } = Object;
10
+ const { isArray: ArrayIsArray$1 } = Array;
11
+ function deepFreeze$2(value) {
12
+ // No need to freeze primitives
13
+ if (typeof value !== 'object' || value === null) {
14
+ return;
15
+ }
16
+ if (ArrayIsArray$1(value)) {
17
+ for (let i = 0, len = value.length; i < len; i += 1) {
18
+ deepFreeze$2(value[i]);
19
+ }
20
+ }
21
+ else {
22
+ const keys = ObjectKeys$1(value);
23
+ for (let i = 0, len = keys.length; i < len; i += 1) {
24
+ deepFreeze$2(value[keys[i]]);
25
+ }
26
+ }
27
+ ObjectFreeze$1(value);
28
+ }
29
+
30
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
31
+ const { keys: ObjectKeys, freeze: ObjectFreeze, create: ObjectCreate } = Object;
32
+ const { stringify: JSONStringify } = JSON;
33
+ const { isArray: ArrayIsArray } = Array;
34
+ /**
35
+ * Validates an adapter config is well-formed.
36
+ * @param config The config to validate.
37
+ * @param adapter The adapter validation configuration.
38
+ * @param oneOf The keys the config must contain at least one of.
39
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
40
+ */
41
+ function validateConfig(config, adapter, oneOf) {
42
+ const { displayName } = adapter;
43
+ const { required, optional, unsupported } = adapter.parameters;
44
+ if (config === undefined ||
45
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
46
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
47
+ }
48
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
49
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
50
+ }
51
+ if (unsupported !== undefined &&
52
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
53
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
54
+ }
55
+ const supported = required.concat(optional);
56
+ if (ObjectKeys(config).some(key => !supported.includes(key))) {
57
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
58
+ }
59
+ }
60
+ function untrustedIsObject(untrusted) {
61
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray(untrusted) === false;
62
+ }
63
+ function areRequiredParametersPresent(config, configPropertyNames) {
64
+ return configPropertyNames.parameters.required.every(req => req in config);
65
+ }
66
+ /**
67
+ * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
68
+ * This is needed because insertion order for JSON.stringify(object) affects output:
69
+ * JSON.stringify({a: 1, b: 2})
70
+ * "{"a":1,"b":2}"
71
+ * JSON.stringify({b: 2, a: 1})
72
+ * "{"b":2,"a":1}"
73
+ * @param data Data to be JSON-stringified.
74
+ * @returns JSON.stringified value with consistent ordering of keys.
75
+ */
76
+ function stableJSONStringify(node) {
77
+ // This is for Date values.
78
+ if (node && node.toJSON && typeof node.toJSON === 'function') {
79
+ // eslint-disable-next-line no-param-reassign
80
+ node = node.toJSON();
81
+ }
82
+ if (node === undefined) {
83
+ return;
84
+ }
85
+ if (typeof node === 'number') {
86
+ return isFinite(node) ? '' + node : 'null';
87
+ }
88
+ if (typeof node !== 'object') {
89
+ return JSONStringify(node);
90
+ }
91
+ let i;
92
+ let out;
93
+ if (ArrayIsArray(node)) {
94
+ out = '[';
95
+ for (i = 0; i < node.length; i++) {
96
+ if (i) {
97
+ out += ',';
98
+ }
99
+ out += stableJSONStringify(node[i]) || 'null';
100
+ }
101
+ return out + ']';
102
+ }
103
+ if (node === null) {
104
+ return 'null';
105
+ }
106
+ const keys = ObjectKeys(node).sort();
107
+ out = '';
108
+ for (i = 0; i < keys.length; i++) {
109
+ const key = keys[i];
110
+ const value = stableJSONStringify(node[key]);
111
+ if (!value) {
112
+ continue;
113
+ }
114
+ if (out) {
115
+ out += ',';
116
+ }
117
+ out += JSONStringify(key) + ':' + value;
118
+ }
119
+ return '{' + out + '}';
120
+ }
121
+ const keyPrefix = 'FlowRuntime';
122
+
123
+ function deepFreeze$1(input) {
124
+ const input_keys = Object.keys(input);
125
+ const input_length = input_keys.length;
126
+ for (let i = 0; i < input_length; i++) {
127
+ const key = input_keys[i];
128
+ const input_prop = input[key];
129
+ deepFreeze$2(input_prop);
130
+ }
131
+ ObjectFreeze$1(input);
132
+ }
133
+
134
+ const RepresentationType = 'FlowRuntimeResponseRepresentation';
135
+ function deepFreeze(input) {
136
+ const input_error = input.error;
137
+ if (input_error !== undefined) {
138
+ deepFreeze$2(input_error);
139
+ }
140
+ const input_response = input.response;
141
+ if (input_response !== undefined) {
142
+ if (input_response !== null && typeof input_response === 'object') {
143
+ deepFreeze$1(input_response);
144
+ }
145
+ }
146
+ ObjectFreeze$1(input);
147
+ }
148
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
149
+ const rootKeySet = new StoreKeyMap();
150
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
151
+ const rootKey = fullPathFactory();
152
+ rootKeySet.set(rootKey, {
153
+ namespace: keyPrefix,
154
+ representationName: RepresentationType,
155
+ mergeable: false
156
+ });
157
+ return rootKeySet;
158
+ }
159
+
160
+ function keyBuilder$2(luvio, params) {
161
+ 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) + ')';
162
+ }
163
+ function getResponseCacheKeys$2(luvio, resourceParams, response) {
164
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$2(luvio, resourceParams));
165
+ }
166
+ function createResourceRequest$2(config) {
167
+ const headers = {};
168
+ return {
169
+ baseUri: '/services/data/v58.0',
170
+ basePath: '/connect/interaction/runtime/startFlow',
171
+ method: 'post',
172
+ body: config.body,
173
+ urlParams: {},
174
+ queryParams: {},
175
+ headers,
176
+ priority: 'normal',
177
+ };
178
+ }
179
+
180
+ const startFlow_ConfigPropertyNames = {
181
+ displayName: 'startFlow',
182
+ parameters: {
183
+ required: ['flowDevName'],
184
+ optional: ['flowVersionId', 'arguments', 'enableTrace', 'enableRollbackMode', 'debugAsUserId']
185
+ }
186
+ };
187
+ function createResourceParams$2(config) {
188
+ const resourceParams = {
189
+ body: {
190
+ flowDevName: config.flowDevName
191
+ }
192
+ };
193
+ if (config['flowVersionId'] !== undefined) {
194
+ resourceParams.body['flowVersionId'] = config['flowVersionId'];
195
+ }
196
+ if (config['arguments'] !== undefined) {
197
+ resourceParams.body['arguments'] = config['arguments'];
198
+ }
199
+ if (config['enableTrace'] !== undefined) {
200
+ resourceParams.body['enableTrace'] = config['enableTrace'];
201
+ }
202
+ if (config['enableRollbackMode'] !== undefined) {
203
+ resourceParams.body['enableRollbackMode'] = config['enableRollbackMode'];
204
+ }
205
+ if (config['debugAsUserId'] !== undefined) {
206
+ resourceParams.body['debugAsUserId'] = config['debugAsUserId'];
207
+ }
208
+ return resourceParams;
209
+ }
210
+ function typeCheckConfig$2(untrustedConfig) {
211
+ const config = {};
212
+ const untrustedConfig_flowDevName = untrustedConfig.flowDevName;
213
+ if (typeof untrustedConfig_flowDevName === 'string') {
214
+ config.flowDevName = untrustedConfig_flowDevName;
215
+ }
216
+ const untrustedConfig_flowVersionId = untrustedConfig.flowVersionId;
217
+ if (typeof untrustedConfig_flowVersionId === 'string') {
218
+ config.flowVersionId = untrustedConfig_flowVersionId;
219
+ }
220
+ const untrustedConfig_arguments = untrustedConfig.arguments;
221
+ if (typeof untrustedConfig_arguments === 'string') {
222
+ config.arguments = untrustedConfig_arguments;
223
+ }
224
+ const untrustedConfig_enableTrace = untrustedConfig.enableTrace;
225
+ if (typeof untrustedConfig_enableTrace === 'boolean') {
226
+ config.enableTrace = untrustedConfig_enableTrace;
227
+ }
228
+ const untrustedConfig_enableRollbackMode = untrustedConfig.enableRollbackMode;
229
+ if (typeof untrustedConfig_enableRollbackMode === 'boolean') {
230
+ config.enableRollbackMode = untrustedConfig_enableRollbackMode;
231
+ }
232
+ const untrustedConfig_debugAsUserId = untrustedConfig.debugAsUserId;
233
+ if (typeof untrustedConfig_debugAsUserId === 'string') {
234
+ config.debugAsUserId = untrustedConfig_debugAsUserId;
235
+ }
236
+ return config;
237
+ }
238
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
239
+ if (!untrustedIsObject(untrustedConfig)) {
240
+ return null;
241
+ }
242
+ if (process.env.NODE_ENV !== 'production') {
243
+ validateConfig(untrustedConfig, configPropertyNames);
244
+ }
245
+ const config = typeCheckConfig$2(untrustedConfig);
246
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
247
+ return null;
248
+ }
249
+ return config;
250
+ }
251
+
252
+ function buildNetworkSnapshot$2(luvio, config, options) {
253
+ const resourceParams = createResourceParams$2(config);
254
+ const request = createResourceRequest$2(resourceParams);
255
+ return luvio
256
+ .dispatchResourceRequest(request, options)
257
+ .then((response) => {
258
+ return luvio.handleSuccessResponse(() => {
259
+ deepFreeze(response.body);
260
+ return Promise.resolve(response.body);
261
+ }, () => {
262
+ return getResponseCacheKeys$2(luvio, resourceParams, response.body);
263
+ });
264
+ }, (response) => {
265
+ return luvio.handleErrorResponse(() => {
266
+ // We want to throw these exceptions to be caught in the runtime layer
267
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
268
+ throw new Error(response.body.message || response.body.error || response.body);
269
+ });
270
+ });
271
+ }
272
+ const startFlowAdapterFactory = (luvio) => function flowRuntime__startFlow(untrustedConfig) {
273
+ const config = validateAdapterConfig$2(untrustedConfig, startFlow_ConfigPropertyNames);
274
+ // Invalid or incomplete config
275
+ if (config === null) {
276
+ return null;
277
+ }
278
+ return buildNetworkSnapshot$2(luvio, config);
279
+ };
280
+
281
+ function keyBuilder$1(luvio, params) {
282
+ 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) + ')';
283
+ }
284
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
285
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
286
+ }
287
+ function createResourceRequest$1(config) {
288
+ const headers = {};
289
+ return {
290
+ baseUri: '/services/data/v58.0',
291
+ basePath: '/connect/interaction/runtime/navigateFlow',
292
+ method: 'post',
293
+ body: config.body,
294
+ urlParams: {},
295
+ queryParams: {},
296
+ headers,
297
+ priority: 'normal',
298
+ };
299
+ }
300
+
301
+ function validate$2(obj, path = 'FlowRuntimeNavigationFieldValue') {
302
+ const v_error = (() => {
303
+ if (typeof obj !== 'object' || ArrayIsArray$1(obj) || obj === null) {
304
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
305
+ }
306
+ const obj_field = obj.field;
307
+ const path_field = path + '.field';
308
+ if (typeof obj_field !== 'string') {
309
+ return new TypeError('Expected "string" but received "' + typeof obj_field + '" (at "' + path_field + '")');
310
+ }
311
+ if (obj.isVisible !== undefined) {
312
+ const obj_isVisible = obj.isVisible;
313
+ const path_isVisible = path + '.isVisible';
314
+ let obj_isVisible_union0 = null;
315
+ const obj_isVisible_union0_error = (() => {
316
+ if (typeof obj_isVisible !== 'boolean') {
317
+ return new TypeError('Expected "boolean" but received "' + typeof obj_isVisible + '" (at "' + path_isVisible + '")');
318
+ }
319
+ })();
320
+ if (obj_isVisible_union0_error != null) {
321
+ obj_isVisible_union0 = obj_isVisible_union0_error.message;
322
+ }
323
+ let obj_isVisible_union1 = null;
324
+ const obj_isVisible_union1_error = (() => {
325
+ if (obj_isVisible !== null) {
326
+ return new TypeError('Expected "null" but received "' + typeof obj_isVisible + '" (at "' + path_isVisible + '")');
327
+ }
328
+ })();
329
+ if (obj_isVisible_union1_error != null) {
330
+ obj_isVisible_union1 = obj_isVisible_union1_error.message;
331
+ }
332
+ if (obj_isVisible_union0 && obj_isVisible_union1) {
333
+ let message = 'Object doesn\'t match union (at "' + path_isVisible + '")';
334
+ message += '\n' + obj_isVisible_union0.split('\n').map((line) => '\t' + line).join('\n');
335
+ message += '\n' + obj_isVisible_union1.split('\n').map((line) => '\t' + line).join('\n');
336
+ return new TypeError(message);
337
+ }
338
+ }
339
+ if (obj.value !== undefined) {
340
+ const obj_value = obj.value;
341
+ const path_value = path + '.value';
342
+ if (obj_value === undefined) {
343
+ return new TypeError('Expected "defined" but received "' + typeof obj_value + '" (at "' + path_value + '")');
344
+ }
345
+ }
346
+ })();
347
+ return v_error === undefined ? null : v_error;
348
+ }
349
+
350
+ function validate$1(obj, path = 'FlowRuntimeHashbagRepresentation') {
351
+ const v_error = (() => {
352
+ if (typeof obj !== 'object' || ArrayIsArray$1(obj) || obj === null) {
353
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
354
+ }
355
+ const obj_keys = ObjectKeys$1(obj);
356
+ for (let i = 0; i < obj_keys.length; i++) {
357
+ const key = obj_keys[i];
358
+ const obj_prop = obj[key];
359
+ const path_prop = path + '["' + key + '"]';
360
+ if (obj_prop === undefined) {
361
+ return new TypeError('Expected "defined" but received "' + typeof obj_prop + '" (at "' + path_prop + '")');
362
+ }
363
+ }
364
+ })();
365
+ return v_error === undefined ? null : v_error;
366
+ }
367
+
368
+ function validate(obj, path = 'FlowRuntimeNavigateFlowRepresentation') {
369
+ const v_error = (() => {
370
+ if (typeof obj !== 'object' || ArrayIsArray$1(obj) || obj === null) {
371
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
372
+ }
373
+ const obj_action = obj.action;
374
+ const path_action = path + '.action';
375
+ if (typeof obj_action !== 'string') {
376
+ return new TypeError('Expected "string" but received "' + typeof obj_action + '" (at "' + path_action + '")');
377
+ }
378
+ if (obj.enableTrace !== undefined) {
379
+ const obj_enableTrace = obj.enableTrace;
380
+ const path_enableTrace = path + '.enableTrace';
381
+ if (typeof obj_enableTrace !== 'boolean') {
382
+ return new TypeError('Expected "boolean" but received "' + typeof obj_enableTrace + '" (at "' + path_enableTrace + '")');
383
+ }
384
+ }
385
+ if (obj.fields !== undefined) {
386
+ const obj_fields = obj.fields;
387
+ const path_fields = path + '.fields';
388
+ if (!ArrayIsArray$1(obj_fields)) {
389
+ return new TypeError('Expected "array" but received "' + typeof obj_fields + '" (at "' + path_fields + '")');
390
+ }
391
+ for (let i = 0; i < obj_fields.length; i++) {
392
+ const obj_fields_item = obj_fields[i];
393
+ const path_fields_item = path_fields + '[' + i + ']';
394
+ const referencepath_fields_itemValidationError = validate$2(obj_fields_item, path_fields_item);
395
+ if (referencepath_fields_itemValidationError !== null) {
396
+ let message = 'Object doesn\'t match FlowRuntimeNavigationFieldValue (at "' + path_fields_item + '")\n';
397
+ message += referencepath_fields_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
398
+ return new TypeError(message);
399
+ }
400
+ }
401
+ }
402
+ if (obj.lcErrors !== undefined) {
403
+ const obj_lcErrors = obj.lcErrors;
404
+ const path_lcErrors = path + '.lcErrors';
405
+ const referencepath_lcErrorsValidationError = validate$1(obj_lcErrors, path_lcErrors);
406
+ if (referencepath_lcErrorsValidationError !== null) {
407
+ let message = 'Object doesn\'t match FlowRuntimeHashbagRepresentation (at "' + path_lcErrors + '")\n';
408
+ message += referencepath_lcErrorsValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
409
+ return new TypeError(message);
410
+ }
411
+ }
412
+ const obj_serializedState = obj.serializedState;
413
+ const path_serializedState = path + '.serializedState';
414
+ if (typeof obj_serializedState !== 'string') {
415
+ return new TypeError('Expected "string" but received "' + typeof obj_serializedState + '" (at "' + path_serializedState + '")');
416
+ }
417
+ if (obj.uiElementVisited !== undefined) {
418
+ const obj_uiElementVisited = obj.uiElementVisited;
419
+ const path_uiElementVisited = path + '.uiElementVisited';
420
+ if (typeof obj_uiElementVisited !== 'boolean') {
421
+ return new TypeError('Expected "boolean" but received "' + typeof obj_uiElementVisited + '" (at "' + path_uiElementVisited + '")');
422
+ }
423
+ }
424
+ })();
425
+ return v_error === undefined ? null : v_error;
426
+ }
427
+
428
+ const navigateFlow_ConfigPropertyNames = {
429
+ displayName: 'navigateFlow',
430
+ parameters: {
431
+ required: ['request'],
432
+ optional: []
433
+ }
434
+ };
435
+ function createResourceParams$1(config) {
436
+ const resourceParams = {
437
+ body: {
438
+ request: config.request
439
+ }
440
+ };
441
+ return resourceParams;
442
+ }
443
+ function typeCheckConfig$1(untrustedConfig) {
444
+ const config = {};
445
+ const untrustedConfig_request = untrustedConfig.request;
446
+ const referenceFlowRuntimeNavigateFlowRepresentationValidationError = validate(untrustedConfig_request);
447
+ if (referenceFlowRuntimeNavigateFlowRepresentationValidationError === null) {
448
+ config.request = untrustedConfig_request;
449
+ }
450
+ return config;
451
+ }
452
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
453
+ if (!untrustedIsObject(untrustedConfig)) {
454
+ return null;
455
+ }
456
+ if (process.env.NODE_ENV !== 'production') {
457
+ validateConfig(untrustedConfig, configPropertyNames);
458
+ }
459
+ const config = typeCheckConfig$1(untrustedConfig);
460
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
461
+ return null;
462
+ }
463
+ return config;
464
+ }
465
+
466
+ function buildNetworkSnapshot$1(luvio, config, context) {
467
+ const resourceParams = createResourceParams$1(config);
468
+ const request = createResourceRequest$1(resourceParams);
469
+ return luvio
470
+ .dispatchResourceRequest(request, context)
471
+ .then((response) => {
472
+ return luvio.handleSuccessResponse(() => {
473
+ deepFreeze(response.body);
474
+ return Promise.resolve(response.body);
475
+ }, () => {
476
+ return getResponseCacheKeys$1(luvio, resourceParams, response.body);
477
+ });
478
+ }, (response) => {
479
+ return luvio.handleErrorResponse(() => {
480
+ // We want to throw these exceptions to be caught in the runtime layer
481
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
482
+ throw new Error(response.body.message || response.body.error || response.body);
483
+ });
484
+ });
485
+ }
486
+ const navigateFlowAdapterFactory = (luvio) => function flowRuntime__navigateFlow(untrustedConfig) {
487
+ const config = validateAdapterConfig$1(untrustedConfig, navigateFlow_ConfigPropertyNames);
488
+ // Invalid or incomplete config
489
+ if (config === null) {
490
+ return null;
491
+ }
492
+ return buildNetworkSnapshot$1(luvio, config);
493
+ };
494
+
495
+ function keyBuilder(luvio, params) {
496
+ return keyPrefix + '::FlowRuntimeResponseRepresentation:(' + 'pausedInterviewId:' + params.body.pausedInterviewId + ')';
497
+ }
498
+ function getResponseCacheKeys(luvio, resourceParams, response) {
499
+ return getTypeCacheKeys(luvio, response, () => keyBuilder(luvio, resourceParams));
500
+ }
501
+ function createResourceRequest(config) {
502
+ const headers = {};
503
+ return {
504
+ baseUri: '/services/data/v58.0',
505
+ basePath: '/connect/interaction/runtime/resumeFlow',
506
+ method: 'post',
507
+ body: config.body,
508
+ urlParams: {},
509
+ queryParams: {},
510
+ headers,
511
+ priority: 'normal',
512
+ };
513
+ }
514
+
515
+ const resumeFlow_ConfigPropertyNames = {
516
+ displayName: 'resumeFlow',
517
+ parameters: {
518
+ required: ['pausedInterviewId'],
519
+ optional: []
520
+ }
521
+ };
522
+ function createResourceParams(config) {
523
+ const resourceParams = {
524
+ body: {
525
+ pausedInterviewId: config.pausedInterviewId
526
+ }
527
+ };
528
+ return resourceParams;
529
+ }
530
+ function typeCheckConfig(untrustedConfig) {
531
+ const config = {};
532
+ const untrustedConfig_pausedInterviewId = untrustedConfig.pausedInterviewId;
533
+ if (typeof untrustedConfig_pausedInterviewId === 'string') {
534
+ config.pausedInterviewId = untrustedConfig_pausedInterviewId;
535
+ }
536
+ return config;
537
+ }
538
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
539
+ if (!untrustedIsObject(untrustedConfig)) {
540
+ return null;
541
+ }
542
+ if (process.env.NODE_ENV !== 'production') {
543
+ validateConfig(untrustedConfig, configPropertyNames);
544
+ }
545
+ const config = typeCheckConfig(untrustedConfig);
546
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
547
+ return null;
548
+ }
549
+ return config;
550
+ }
551
+
552
+ function buildNetworkSnapshot(luvio, config, options) {
553
+ const resourceParams = createResourceParams(config);
554
+ const request = createResourceRequest(resourceParams);
555
+ return luvio
556
+ .dispatchResourceRequest(request, options)
557
+ .then((response) => {
558
+ return luvio.handleSuccessResponse(() => {
559
+ deepFreeze(response.body);
560
+ return Promise.resolve(response.body);
561
+ }, () => {
562
+ return getResponseCacheKeys(luvio, resourceParams, response.body);
563
+ });
564
+ }, (response) => {
565
+ return luvio.handleErrorResponse(() => {
566
+ // We want to throw these exceptions to be caught in the runtime layer
567
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
568
+ throw new Error(response.body.message || response.body.error || response.body);
569
+ });
570
+ });
571
+ }
572
+ const resumeFlowAdapterFactory = (luvio) => function flowRuntime__resumeFlow(untrustedConfig) {
573
+ const config = validateAdapterConfig(untrustedConfig, resumeFlow_ConfigPropertyNames);
574
+ // Invalid or incomplete config
575
+ if (config === null) {
576
+ return null;
577
+ }
578
+ return buildNetworkSnapshot(luvio, config);
579
+ };
580
+
581
+ export { navigateFlowAdapterFactory, resumeFlowAdapterFactory, startFlowAdapterFactory };
@@ -0,0 +1,6 @@
1
+ import type { Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext } from '@luvio/engine';
2
+ import type { FlowRuntimeResponseRepresentation as types_FlowRuntimeResponseRepresentation_FlowRuntimeResponseRepresentation } from '../generated/types/FlowRuntimeResponseRepresentation';
3
+ import type { NavigateFlowConfig } from '../generated/adapters/navigateFlow';
4
+ export { adapterName } from '../generated/adapters/navigateFlow';
5
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: NavigateFlowConfig, context?: DispatchResourceRequestContext): Promise<types_FlowRuntimeResponseRepresentation_FlowRuntimeResponseRepresentation>;
6
+ export declare const navigateFlowAdapterFactory: any;
@@ -0,0 +1,6 @@
1
+ import type { Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext } from '@luvio/engine';
2
+ import type { FlowRuntimeResponseRepresentation as types_FlowRuntimeResponseRepresentation_FlowRuntimeResponseRepresentation } from '../generated/types/FlowRuntimeResponseRepresentation';
3
+ import type { ResumeFlowConfig } from '../generated/adapters/resumeFlow';
4
+ export { adapterName } from '../generated/adapters/resumeFlow';
5
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: ResumeFlowConfig, options?: DispatchResourceRequestContext): Promise<types_FlowRuntimeResponseRepresentation_FlowRuntimeResponseRepresentation>;
6
+ export declare const resumeFlowAdapterFactory: any;