@salesforce/lds-adapters-industries-integration-orchestrator 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.
- package/LICENSE.txt +82 -0
- package/dist/es/es2018/industries-integration-orchestrator.js +615 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/fulfillmentContexts.d.ts +27 -0
- package/dist/es/es2018/types/src/generated/adapters/fulfillmentSteps.d.ts +29 -0
- package/dist/es/es2018/types/src/generated/artifacts/main.d.ts +2 -0
- package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +5 -0
- package/dist/es/es2018/types/src/generated/resources/getConnectFulfillmentContextsByRecordId.d.ts +15 -0
- package/dist/es/es2018/types/src/generated/resources/getConnectFulfillmentStepsByRecordId.d.ts +19 -0
- package/dist/es/es2018/types/src/generated/types/AdditionalPropertiesRepresentation.d.ts +34 -0
- package/dist/es/es2018/types/src/generated/types/FulfillmentContextsOutputRepresentation.d.ts +30 -0
- package/dist/es/es2018/types/src/generated/types/FulfillmentContextsRepresentation.d.ts +34 -0
- package/dist/es/es2018/types/src/generated/types/FulfillmentStepsOutputRepresentation.d.ts +54 -0
- package/dist/es/es2018/types/src/generated/types/FulfillmentStepsRepresentation.d.ts +41 -0
- package/dist/es/es2018/types/src/generated/types/type-utils.d.ts +32 -0
- package/package.json +66 -0
- package/sfdc/index.d.ts +1 -0
- package/sfdc/index.js +665 -0
- package/src/raml/api.raml +157 -0
- package/src/raml/luvio.raml +26 -0
|
@@ -0,0 +1,615 @@
|
|
|
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 { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$2, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from '@luvio/engine';
|
|
8
|
+
|
|
9
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
+
const { keys: ObjectKeys, create: ObjectCreate } = Object;
|
|
11
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
12
|
+
/**
|
|
13
|
+
* Validates an adapter config is well-formed.
|
|
14
|
+
* @param config The config to validate.
|
|
15
|
+
* @param adapter The adapter validation configuration.
|
|
16
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
17
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
18
|
+
*/
|
|
19
|
+
function validateConfig(config, adapter, oneOf) {
|
|
20
|
+
const { displayName } = adapter;
|
|
21
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
22
|
+
if (config === undefined ||
|
|
23
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
24
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
25
|
+
}
|
|
26
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
27
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
if (unsupported !== undefined &&
|
|
30
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
31
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
const supported = required.concat(optional);
|
|
34
|
+
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
35
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function untrustedIsObject(untrusted) {
|
|
39
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
40
|
+
}
|
|
41
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
42
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
43
|
+
}
|
|
44
|
+
const snapshotRefreshOptions = {
|
|
45
|
+
overrides: {
|
|
46
|
+
headers: {
|
|
47
|
+
'Cache-Control': 'no-cache',
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
|
|
52
|
+
return {
|
|
53
|
+
name,
|
|
54
|
+
required,
|
|
55
|
+
resourceType,
|
|
56
|
+
typeCheckShape,
|
|
57
|
+
isArrayShape,
|
|
58
|
+
coerceFn,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
62
|
+
const required = paramsMeta.filter(p => p.required).map(p => p.name);
|
|
63
|
+
const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
|
|
64
|
+
return {
|
|
65
|
+
displayName,
|
|
66
|
+
parameters: {
|
|
67
|
+
required,
|
|
68
|
+
optional,
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const keyPrefix = 'integration-orchestrator-connect-api';
|
|
73
|
+
|
|
74
|
+
const { isArray: ArrayIsArray } = Array;
|
|
75
|
+
const { stringify: JSONStringify } = JSON;
|
|
76
|
+
function createLink(ref) {
|
|
77
|
+
return {
|
|
78
|
+
__ref: serializeStructuredKey(ref),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function validate$4(obj, path = 'FulfillmentContextsRepresentation') {
|
|
83
|
+
const v_error = (() => {
|
|
84
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
85
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
86
|
+
}
|
|
87
|
+
const obj_id = obj.id;
|
|
88
|
+
const path_id = path + '.id';
|
|
89
|
+
if (typeof obj_id !== 'string') {
|
|
90
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
91
|
+
}
|
|
92
|
+
const obj_name = obj.name;
|
|
93
|
+
const path_name = path + '.name';
|
|
94
|
+
if (typeof obj_name !== 'string') {
|
|
95
|
+
return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
|
|
96
|
+
}
|
|
97
|
+
const obj_objectApiName = obj.objectApiName;
|
|
98
|
+
const path_objectApiName = path + '.objectApiName';
|
|
99
|
+
if (typeof obj_objectApiName !== 'string') {
|
|
100
|
+
return new TypeError('Expected "string" but received "' + typeof obj_objectApiName + '" (at "' + path_objectApiName + '")');
|
|
101
|
+
}
|
|
102
|
+
})();
|
|
103
|
+
return v_error === undefined ? null : v_error;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const TTL$1 = 10000;
|
|
107
|
+
const VERSION$1 = "63387271cf04544d4d2a863e284ed6d8";
|
|
108
|
+
function validate$3(obj, path = 'FulfillmentContextsOutputRepresentation') {
|
|
109
|
+
const v_error = (() => {
|
|
110
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
111
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
112
|
+
}
|
|
113
|
+
const obj_fulfillmentContexts = obj.fulfillmentContexts;
|
|
114
|
+
const path_fulfillmentContexts = path + '.fulfillmentContexts';
|
|
115
|
+
if (!ArrayIsArray(obj_fulfillmentContexts)) {
|
|
116
|
+
return new TypeError('Expected "array" but received "' + typeof obj_fulfillmentContexts + '" (at "' + path_fulfillmentContexts + '")');
|
|
117
|
+
}
|
|
118
|
+
for (let i = 0; i < obj_fulfillmentContexts.length; i++) {
|
|
119
|
+
const obj_fulfillmentContexts_item = obj_fulfillmentContexts[i];
|
|
120
|
+
const path_fulfillmentContexts_item = path_fulfillmentContexts + '[' + i + ']';
|
|
121
|
+
const referencepath_fulfillmentContexts_itemValidationError = validate$4(obj_fulfillmentContexts_item, path_fulfillmentContexts_item);
|
|
122
|
+
if (referencepath_fulfillmentContexts_itemValidationError !== null) {
|
|
123
|
+
let message = 'Object doesn\'t match FulfillmentContextsRepresentation (at "' + path_fulfillmentContexts_item + '")\n';
|
|
124
|
+
message += referencepath_fulfillmentContexts_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
125
|
+
return new TypeError(message);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})();
|
|
129
|
+
return v_error === undefined ? null : v_error;
|
|
130
|
+
}
|
|
131
|
+
const RepresentationType$1 = 'FulfillmentContextsOutputRepresentation';
|
|
132
|
+
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
133
|
+
return input;
|
|
134
|
+
}
|
|
135
|
+
const select$3 = function FulfillmentContextsOutputRepresentationSelect() {
|
|
136
|
+
return {
|
|
137
|
+
kind: 'Fragment',
|
|
138
|
+
version: VERSION$1,
|
|
139
|
+
private: [],
|
|
140
|
+
opaque: true
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
function equals$1(existing, incoming) {
|
|
144
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
const ingest$1 = function FulfillmentContextsOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
150
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
151
|
+
const validateError = validate$3(input);
|
|
152
|
+
if (validateError !== null) {
|
|
153
|
+
throw validateError;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const key = path.fullPath;
|
|
157
|
+
const ttlToUse = TTL$1;
|
|
158
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "integration-orchestrator-connect-api", VERSION$1, RepresentationType$1, equals$1);
|
|
159
|
+
return createLink(key);
|
|
160
|
+
};
|
|
161
|
+
function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
|
|
162
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
163
|
+
const rootKey = fullPathFactory();
|
|
164
|
+
rootKeySet.set(rootKey, {
|
|
165
|
+
namespace: keyPrefix,
|
|
166
|
+
representationName: RepresentationType$1,
|
|
167
|
+
mergeable: false
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function select$2(luvio, params) {
|
|
172
|
+
return select$3();
|
|
173
|
+
}
|
|
174
|
+
function keyBuilder$3(luvio, params) {
|
|
175
|
+
return keyPrefix + '::FulfillmentContextsOutputRepresentation:(' + 'recordId:' + params.urlParams.recordId + ')';
|
|
176
|
+
}
|
|
177
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
178
|
+
getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$3(luvio, resourceParams));
|
|
179
|
+
}
|
|
180
|
+
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
181
|
+
const { body } = response;
|
|
182
|
+
const key = keyBuilder$3(luvio, resourceParams);
|
|
183
|
+
luvio.storeIngest(key, ingest$1, body);
|
|
184
|
+
const snapshot = luvio.storeLookup({
|
|
185
|
+
recordId: key,
|
|
186
|
+
node: select$2(),
|
|
187
|
+
variables: {},
|
|
188
|
+
}, snapshotRefresh);
|
|
189
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
190
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
191
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
deepFreeze(snapshot.data);
|
|
195
|
+
return snapshot;
|
|
196
|
+
}
|
|
197
|
+
function ingestError$1(luvio, params, error, snapshotRefresh) {
|
|
198
|
+
const key = keyBuilder$3(luvio, params);
|
|
199
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
200
|
+
const storeMetadataParams = {
|
|
201
|
+
ttl: TTL$1,
|
|
202
|
+
namespace: keyPrefix,
|
|
203
|
+
version: VERSION$1,
|
|
204
|
+
representationName: RepresentationType$1
|
|
205
|
+
};
|
|
206
|
+
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
207
|
+
return errorSnapshot;
|
|
208
|
+
}
|
|
209
|
+
function createResourceRequest$1(config) {
|
|
210
|
+
const headers = {};
|
|
211
|
+
return {
|
|
212
|
+
baseUri: '/services/data/v66.0',
|
|
213
|
+
basePath: '/connect/fulfillmentContexts/' + config.urlParams.recordId + '',
|
|
214
|
+
method: 'get',
|
|
215
|
+
body: null,
|
|
216
|
+
urlParams: config.urlParams,
|
|
217
|
+
queryParams: {},
|
|
218
|
+
headers,
|
|
219
|
+
priority: 'normal',
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const adapterName$1 = 'fulfillmentContexts';
|
|
224
|
+
const fulfillmentContexts_ConfigPropertyMetadata = [
|
|
225
|
+
generateParamConfigMetadata('recordId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
226
|
+
];
|
|
227
|
+
const fulfillmentContexts_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, fulfillmentContexts_ConfigPropertyMetadata);
|
|
228
|
+
const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(fulfillmentContexts_ConfigPropertyMetadata);
|
|
229
|
+
function keyBuilder$2(luvio, config) {
|
|
230
|
+
const resourceParams = createResourceParams$1(config);
|
|
231
|
+
return keyBuilder$3(luvio, resourceParams);
|
|
232
|
+
}
|
|
233
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
234
|
+
const config = {};
|
|
235
|
+
typeCheckConfig$2(untrustedConfig, config, fulfillmentContexts_ConfigPropertyMetadata);
|
|
236
|
+
return config;
|
|
237
|
+
}
|
|
238
|
+
function validateAdapterConfig$1(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$1(untrustedConfig);
|
|
246
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
return config;
|
|
250
|
+
}
|
|
251
|
+
function adapterFragment$1(luvio, config) {
|
|
252
|
+
createResourceParams$1(config);
|
|
253
|
+
return select$2();
|
|
254
|
+
}
|
|
255
|
+
function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
|
|
256
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
257
|
+
config,
|
|
258
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
259
|
+
});
|
|
260
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
261
|
+
}
|
|
262
|
+
function onFetchResponseError$1(luvio, config, resourceParams, response) {
|
|
263
|
+
const snapshot = ingestError$1(luvio, resourceParams, response, {
|
|
264
|
+
config,
|
|
265
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
266
|
+
});
|
|
267
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
268
|
+
}
|
|
269
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
270
|
+
const resourceParams = createResourceParams$1(config);
|
|
271
|
+
const request = createResourceRequest$1(resourceParams);
|
|
272
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
273
|
+
.then((response) => {
|
|
274
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => {
|
|
275
|
+
const cache = new StoreKeyMap();
|
|
276
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
277
|
+
return cache;
|
|
278
|
+
});
|
|
279
|
+
}, (response) => {
|
|
280
|
+
return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
|
|
284
|
+
return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
|
|
285
|
+
}
|
|
286
|
+
function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
|
|
287
|
+
const { luvio, config } = context;
|
|
288
|
+
const selector = {
|
|
289
|
+
recordId: keyBuilder$2(luvio, config),
|
|
290
|
+
node: adapterFragment$1(luvio, config),
|
|
291
|
+
variables: {},
|
|
292
|
+
};
|
|
293
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
294
|
+
config,
|
|
295
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
296
|
+
});
|
|
297
|
+
return cacheSnapshot;
|
|
298
|
+
}
|
|
299
|
+
const fulfillmentContextsAdapterFactory = (luvio) => function integrationOrchestratorConnectApi__fulfillmentContexts(untrustedConfig, requestContext) {
|
|
300
|
+
const config = validateAdapterConfig$1(untrustedConfig, fulfillmentContexts_ConfigPropertyNames);
|
|
301
|
+
// Invalid or incomplete config
|
|
302
|
+
if (config === null) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
306
|
+
buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
function validate$2(obj, path = 'AdditionalPropertiesRepresentation') {
|
|
310
|
+
const v_error = (() => {
|
|
311
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
312
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
313
|
+
}
|
|
314
|
+
const obj_flexCardName = obj.flexCardName;
|
|
315
|
+
const path_flexCardName = path + '.flexCardName';
|
|
316
|
+
if (typeof obj_flexCardName !== 'string') {
|
|
317
|
+
return new TypeError('Expected "string" but received "' + typeof obj_flexCardName + '" (at "' + path_flexCardName + '")');
|
|
318
|
+
}
|
|
319
|
+
const obj_manual = obj.manual;
|
|
320
|
+
const path_manual = path + '.manual';
|
|
321
|
+
if (typeof obj_manual !== 'boolean') {
|
|
322
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_manual + '" (at "' + path_manual + '")');
|
|
323
|
+
}
|
|
324
|
+
const obj_sync = obj.sync;
|
|
325
|
+
const path_sync = path + '.sync';
|
|
326
|
+
if (typeof obj_sync !== 'boolean') {
|
|
327
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_sync + '" (at "' + path_sync + '")');
|
|
328
|
+
}
|
|
329
|
+
})();
|
|
330
|
+
return v_error === undefined ? null : v_error;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function validate$1(obj, path = 'FulfillmentStepsRepresentation') {
|
|
334
|
+
const v_error = (() => {
|
|
335
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
336
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
337
|
+
}
|
|
338
|
+
const obj_additionalProperties = obj.additionalProperties;
|
|
339
|
+
const path_additionalProperties = path + '.additionalProperties';
|
|
340
|
+
const referencepath_additionalPropertiesValidationError = validate$2(obj_additionalProperties, path_additionalProperties);
|
|
341
|
+
if (referencepath_additionalPropertiesValidationError !== null) {
|
|
342
|
+
let message = 'Object doesn\'t match AdditionalPropertiesRepresentation (at "' + path_additionalProperties + '")\n';
|
|
343
|
+
message += referencepath_additionalPropertiesValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
344
|
+
return new TypeError(message);
|
|
345
|
+
}
|
|
346
|
+
const obj_id = obj.id;
|
|
347
|
+
const path_id = path + '.id';
|
|
348
|
+
if (typeof obj_id !== 'string') {
|
|
349
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
350
|
+
}
|
|
351
|
+
const obj_lastModifiedDate = obj.lastModifiedDate;
|
|
352
|
+
const path_lastModifiedDate = path + '.lastModifiedDate';
|
|
353
|
+
if (typeof obj_lastModifiedDate !== 'string') {
|
|
354
|
+
return new TypeError('Expected "string" but received "' + typeof obj_lastModifiedDate + '" (at "' + path_lastModifiedDate + '")');
|
|
355
|
+
}
|
|
356
|
+
const obj_name = obj.name;
|
|
357
|
+
const path_name = path + '.name';
|
|
358
|
+
if (typeof obj_name !== 'string') {
|
|
359
|
+
return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
|
|
360
|
+
}
|
|
361
|
+
const obj_state = obj.state;
|
|
362
|
+
const path_state = path + '.state';
|
|
363
|
+
if (typeof obj_state !== 'string') {
|
|
364
|
+
return new TypeError('Expected "string" but received "' + typeof obj_state + '" (at "' + path_state + '")');
|
|
365
|
+
}
|
|
366
|
+
})();
|
|
367
|
+
return v_error === undefined ? null : v_error;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const TTL = 10000;
|
|
371
|
+
const VERSION = "b22606e2db4e742d7f1f00b32a6f1020";
|
|
372
|
+
function validate(obj, path = 'FulfillmentStepsOutputRepresentation') {
|
|
373
|
+
const v_error = (() => {
|
|
374
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
375
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
376
|
+
}
|
|
377
|
+
const obj_completedCount = obj.completedCount;
|
|
378
|
+
const path_completedCount = path + '.completedCount';
|
|
379
|
+
if (typeof obj_completedCount !== 'number' || (typeof obj_completedCount === 'number' && Math.floor(obj_completedCount) !== obj_completedCount)) {
|
|
380
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_completedCount + '" (at "' + path_completedCount + '")');
|
|
381
|
+
}
|
|
382
|
+
const obj_failedCount = obj.failedCount;
|
|
383
|
+
const path_failedCount = path + '.failedCount';
|
|
384
|
+
if (typeof obj_failedCount !== 'number' || (typeof obj_failedCount === 'number' && Math.floor(obj_failedCount) !== obj_failedCount)) {
|
|
385
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_failedCount + '" (at "' + path_failedCount + '")');
|
|
386
|
+
}
|
|
387
|
+
const obj_fatallyFailedCount = obj.fatallyFailedCount;
|
|
388
|
+
const path_fatallyFailedCount = path + '.fatallyFailedCount';
|
|
389
|
+
if (typeof obj_fatallyFailedCount !== 'number' || (typeof obj_fatallyFailedCount === 'number' && Math.floor(obj_fatallyFailedCount) !== obj_fatallyFailedCount)) {
|
|
390
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_fatallyFailedCount + '" (at "' + path_fatallyFailedCount + '")');
|
|
391
|
+
}
|
|
392
|
+
const obj_fulfillmentSteps = obj.fulfillmentSteps;
|
|
393
|
+
const path_fulfillmentSteps = path + '.fulfillmentSteps';
|
|
394
|
+
if (!ArrayIsArray(obj_fulfillmentSteps)) {
|
|
395
|
+
return new TypeError('Expected "array" but received "' + typeof obj_fulfillmentSteps + '" (at "' + path_fulfillmentSteps + '")');
|
|
396
|
+
}
|
|
397
|
+
for (let i = 0; i < obj_fulfillmentSteps.length; i++) {
|
|
398
|
+
const obj_fulfillmentSteps_item = obj_fulfillmentSteps[i];
|
|
399
|
+
const path_fulfillmentSteps_item = path_fulfillmentSteps + '[' + i + ']';
|
|
400
|
+
const referencepath_fulfillmentSteps_itemValidationError = validate$1(obj_fulfillmentSteps_item, path_fulfillmentSteps_item);
|
|
401
|
+
if (referencepath_fulfillmentSteps_itemValidationError !== null) {
|
|
402
|
+
let message = 'Object doesn\'t match FulfillmentStepsRepresentation (at "' + path_fulfillmentSteps_item + '")\n';
|
|
403
|
+
message += referencepath_fulfillmentSteps_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
|
|
404
|
+
return new TypeError(message);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const obj_inProgressCount = obj.inProgressCount;
|
|
408
|
+
const path_inProgressCount = path + '.inProgressCount';
|
|
409
|
+
if (typeof obj_inProgressCount !== 'number' || (typeof obj_inProgressCount === 'number' && Math.floor(obj_inProgressCount) !== obj_inProgressCount)) {
|
|
410
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_inProgressCount + '" (at "' + path_inProgressCount + '")');
|
|
411
|
+
}
|
|
412
|
+
const obj_pendingCount = obj.pendingCount;
|
|
413
|
+
const path_pendingCount = path + '.pendingCount';
|
|
414
|
+
if (typeof obj_pendingCount !== 'number' || (typeof obj_pendingCount === 'number' && Math.floor(obj_pendingCount) !== obj_pendingCount)) {
|
|
415
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_pendingCount + '" (at "' + path_pendingCount + '")');
|
|
416
|
+
}
|
|
417
|
+
const obj_readyCount = obj.readyCount;
|
|
418
|
+
const path_readyCount = path + '.readyCount';
|
|
419
|
+
if (typeof obj_readyCount !== 'number' || (typeof obj_readyCount === 'number' && Math.floor(obj_readyCount) !== obj_readyCount)) {
|
|
420
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_readyCount + '" (at "' + path_readyCount + '")');
|
|
421
|
+
}
|
|
422
|
+
const obj_skippedCount = obj.skippedCount;
|
|
423
|
+
const path_skippedCount = path + '.skippedCount';
|
|
424
|
+
if (typeof obj_skippedCount !== 'number' || (typeof obj_skippedCount === 'number' && Math.floor(obj_skippedCount) !== obj_skippedCount)) {
|
|
425
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_skippedCount + '" (at "' + path_skippedCount + '")');
|
|
426
|
+
}
|
|
427
|
+
const obj_totalCount = obj.totalCount;
|
|
428
|
+
const path_totalCount = path + '.totalCount';
|
|
429
|
+
if (typeof obj_totalCount !== 'number' || (typeof obj_totalCount === 'number' && Math.floor(obj_totalCount) !== obj_totalCount)) {
|
|
430
|
+
return new TypeError('Expected "integer" but received "' + typeof obj_totalCount + '" (at "' + path_totalCount + '")');
|
|
431
|
+
}
|
|
432
|
+
})();
|
|
433
|
+
return v_error === undefined ? null : v_error;
|
|
434
|
+
}
|
|
435
|
+
const RepresentationType = 'FulfillmentStepsOutputRepresentation';
|
|
436
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
437
|
+
return input;
|
|
438
|
+
}
|
|
439
|
+
const select$1 = function FulfillmentStepsOutputRepresentationSelect() {
|
|
440
|
+
return {
|
|
441
|
+
kind: 'Fragment',
|
|
442
|
+
version: VERSION,
|
|
443
|
+
private: [],
|
|
444
|
+
opaque: true
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
function equals(existing, incoming) {
|
|
448
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
const ingest = function FulfillmentStepsOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
454
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
455
|
+
const validateError = validate(input);
|
|
456
|
+
if (validateError !== null) {
|
|
457
|
+
throw validateError;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
const key = path.fullPath;
|
|
461
|
+
const ttlToUse = TTL;
|
|
462
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "integration-orchestrator-connect-api", VERSION, RepresentationType, equals);
|
|
463
|
+
return createLink(key);
|
|
464
|
+
};
|
|
465
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
466
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
467
|
+
const rootKey = fullPathFactory();
|
|
468
|
+
rootKeySet.set(rootKey, {
|
|
469
|
+
namespace: keyPrefix,
|
|
470
|
+
representationName: RepresentationType,
|
|
471
|
+
mergeable: false
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function select(luvio, params) {
|
|
476
|
+
return select$1();
|
|
477
|
+
}
|
|
478
|
+
function keyBuilder$1(luvio, params) {
|
|
479
|
+
return keyPrefix + '::FulfillmentStepsOutputRepresentation:(' + 'contextId:' + params.queryParams.contextId + ',' + 'stepType:' + params.queryParams.stepType + ',' + 'recordId:' + params.urlParams.recordId + ')';
|
|
480
|
+
}
|
|
481
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
482
|
+
getTypeCacheKeys(storeKeyMap, luvio, response, () => keyBuilder$1(luvio, resourceParams));
|
|
483
|
+
}
|
|
484
|
+
function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
|
|
485
|
+
const { body } = response;
|
|
486
|
+
const key = keyBuilder$1(luvio, resourceParams);
|
|
487
|
+
luvio.storeIngest(key, ingest, body);
|
|
488
|
+
const snapshot = luvio.storeLookup({
|
|
489
|
+
recordId: key,
|
|
490
|
+
node: select(),
|
|
491
|
+
variables: {},
|
|
492
|
+
}, snapshotRefresh);
|
|
493
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
494
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
495
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
deepFreeze(snapshot.data);
|
|
499
|
+
return snapshot;
|
|
500
|
+
}
|
|
501
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
502
|
+
const key = keyBuilder$1(luvio, params);
|
|
503
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
504
|
+
const storeMetadataParams = {
|
|
505
|
+
ttl: TTL,
|
|
506
|
+
namespace: keyPrefix,
|
|
507
|
+
version: VERSION,
|
|
508
|
+
representationName: RepresentationType
|
|
509
|
+
};
|
|
510
|
+
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
511
|
+
return errorSnapshot;
|
|
512
|
+
}
|
|
513
|
+
function createResourceRequest(config) {
|
|
514
|
+
const headers = {};
|
|
515
|
+
return {
|
|
516
|
+
baseUri: '/services/data/v66.0',
|
|
517
|
+
basePath: '/connect/fulfillmentSteps/' + config.urlParams.recordId + '',
|
|
518
|
+
method: 'get',
|
|
519
|
+
body: null,
|
|
520
|
+
urlParams: config.urlParams,
|
|
521
|
+
queryParams: config.queryParams,
|
|
522
|
+
headers,
|
|
523
|
+
priority: 'normal',
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const adapterName = 'fulfillmentSteps';
|
|
528
|
+
const fulfillmentSteps_ConfigPropertyMetadata = [
|
|
529
|
+
generateParamConfigMetadata('recordId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
530
|
+
generateParamConfigMetadata('contextId', false, 1 /* QueryParameter */, 0 /* String */),
|
|
531
|
+
generateParamConfigMetadata('stepType', false, 1 /* QueryParameter */, 0 /* String */),
|
|
532
|
+
];
|
|
533
|
+
const fulfillmentSteps_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, fulfillmentSteps_ConfigPropertyMetadata);
|
|
534
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$2(fulfillmentSteps_ConfigPropertyMetadata);
|
|
535
|
+
function keyBuilder(luvio, config) {
|
|
536
|
+
const resourceParams = createResourceParams(config);
|
|
537
|
+
return keyBuilder$1(luvio, resourceParams);
|
|
538
|
+
}
|
|
539
|
+
function typeCheckConfig(untrustedConfig) {
|
|
540
|
+
const config = {};
|
|
541
|
+
typeCheckConfig$2(untrustedConfig, config, fulfillmentSteps_ConfigPropertyMetadata);
|
|
542
|
+
return config;
|
|
543
|
+
}
|
|
544
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
545
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
549
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
550
|
+
}
|
|
551
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
552
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
return config;
|
|
556
|
+
}
|
|
557
|
+
function adapterFragment(luvio, config) {
|
|
558
|
+
createResourceParams(config);
|
|
559
|
+
return select();
|
|
560
|
+
}
|
|
561
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
562
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response, {
|
|
563
|
+
config,
|
|
564
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
565
|
+
});
|
|
566
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
567
|
+
}
|
|
568
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
569
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
570
|
+
config,
|
|
571
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
572
|
+
});
|
|
573
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
574
|
+
}
|
|
575
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
576
|
+
const resourceParams = createResourceParams(config);
|
|
577
|
+
const request = createResourceRequest(resourceParams);
|
|
578
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
579
|
+
.then((response) => {
|
|
580
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
|
|
581
|
+
const cache = new StoreKeyMap();
|
|
582
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
583
|
+
return cache;
|
|
584
|
+
});
|
|
585
|
+
}, (response) => {
|
|
586
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
590
|
+
return buildNetworkSnapshotCachePolicy$2(context, coercedAdapterRequestContext, buildNetworkSnapshot, undefined, false);
|
|
591
|
+
}
|
|
592
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
593
|
+
const { luvio, config } = context;
|
|
594
|
+
const selector = {
|
|
595
|
+
recordId: keyBuilder(luvio, config),
|
|
596
|
+
node: adapterFragment(luvio, config),
|
|
597
|
+
variables: {},
|
|
598
|
+
};
|
|
599
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
600
|
+
config,
|
|
601
|
+
resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
|
|
602
|
+
});
|
|
603
|
+
return cacheSnapshot;
|
|
604
|
+
}
|
|
605
|
+
const fulfillmentStepsAdapterFactory = (luvio) => function integrationOrchestratorConnectApi__fulfillmentSteps(untrustedConfig, requestContext) {
|
|
606
|
+
const config = validateAdapterConfig(untrustedConfig, fulfillmentSteps_ConfigPropertyNames);
|
|
607
|
+
// Invalid or incomplete config
|
|
608
|
+
if (config === null) {
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
612
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
export { fulfillmentContextsAdapterFactory, fulfillmentStepsAdapterFactory };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot, AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata } from '@luvio/engine';
|
|
2
|
+
export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
|
|
3
|
+
declare const ObjectKeys: {
|
|
4
|
+
(o: object): string[];
|
|
5
|
+
(o: {}): string[];
|
|
6
|
+
}, ObjectCreate: {
|
|
7
|
+
(o: object | null): any;
|
|
8
|
+
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
9
|
+
};
|
|
10
|
+
export { ObjectCreate, ObjectKeys };
|
|
11
|
+
export declare const ArrayIsArray: (arg: any) => arg is any[];
|
|
12
|
+
export declare const ArrayPrototypePush: (...items: any[]) => number;
|
|
13
|
+
export interface AdapterValidationConfig {
|
|
14
|
+
displayName: string;
|
|
15
|
+
parameters: {
|
|
16
|
+
required: string[];
|
|
17
|
+
optional: string[];
|
|
18
|
+
unsupported?: string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validates an adapter config is well-formed.
|
|
23
|
+
* @param config The config to validate.
|
|
24
|
+
* @param adapter The adapter validation configuration.
|
|
25
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
26
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateConfig<T>(config: Untrusted<T>, adapter: AdapterValidationConfig, oneOf?: string[]): void;
|
|
29
|
+
export declare function untrustedIsObject<Base>(untrusted: unknown): untrusted is Untrusted<Base>;
|
|
30
|
+
export type UncoercedConfiguration<Base, Options extends {
|
|
31
|
+
[key in keyof Base]?: any;
|
|
32
|
+
}> = {
|
|
33
|
+
[Key in keyof Base]?: Base[Key] | Options[Key];
|
|
34
|
+
};
|
|
35
|
+
export type Untrusted<Base> = Partial<Base>;
|
|
36
|
+
export declare function areRequiredParametersPresent<T>(config: any, configPropertyNames: AdapterValidationConfig): config is T;
|
|
37
|
+
export declare function refreshable<C, D, R>(adapter: $64$luvio_engine_Adapter<C, D>, resolve: (config: unknown) => Promise<$64$luvio_engine_Snapshot<R>>): $64$luvio_engine_Adapter<C, D>;
|
|
38
|
+
export declare const SNAPSHOT_STATE_FULFILLED = "Fulfilled";
|
|
39
|
+
export declare const SNAPSHOT_STATE_UNFULFILLED = "Unfulfilled";
|
|
40
|
+
export declare const snapshotRefreshOptions: {
|
|
41
|
+
overrides: {
|
|
42
|
+
headers: {
|
|
43
|
+
'Cache-Control': string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
|
|
49
|
+
* This is needed because insertion order for JSON.stringify(object) affects output:
|
|
50
|
+
* JSON.stringify({a: 1, b: 2})
|
|
51
|
+
* "{"a":1,"b":2}"
|
|
52
|
+
* JSON.stringify({b: 2, a: 1})
|
|
53
|
+
* "{"b":2,"a":1}"
|
|
54
|
+
* @param data Data to be JSON-stringified.
|
|
55
|
+
* @returns JSON.stringified value with consistent ordering of keys.
|
|
56
|
+
*/
|
|
57
|
+
export declare function stableJSONStringify(node: any): string | undefined;
|
|
58
|
+
export declare function getFetchResponseStatusText(status: number): string;
|
|
59
|
+
export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
|
|
60
|
+
export declare function generateParamConfigMetadata(name: string, required: boolean, resourceType: $64$luvio_engine_AdapterConfigMetadata['resourceType'], typeCheckShape: $64$luvio_engine_AdapterConfigMetadata['typeCheckShape'], isArrayShape?: boolean, coerceFn?: (v: unknown) => unknown): $64$luvio_engine_AdapterConfigMetadata;
|
|
61
|
+
export declare function buildAdapterValidationConfig(displayName: string, paramsMeta: $64$luvio_engine_AdapterConfigMetadata[]): AdapterValidationConfig;
|
|
62
|
+
export declare const keyPrefix = "integration-orchestrator-connect-api";
|