@salesforce/lds-adapters-platform-flow 1.100.2

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