@salesforce/lds-adapters-service-itsm-risk-score-evaluation 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/service-itsm-risk-score-evaluation.js +578 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/getRiskQstResponses.d.ts +27 -0
- package/dist/es/es2018/types/src/generated/adapters/inferAttributes.d.ts +16 -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 +4 -0
- package/dist/es/es2018/types/src/generated/resources/getConnectServiceItsmRiskQstResponseById.d.ts +15 -0
- package/dist/es/es2018/types/src/generated/resources/postConnectServiceItsmInference.d.ts +13 -0
- package/dist/es/es2018/types/src/generated/types/InferenceInputRepresentation.d.ts +31 -0
- package/dist/es/es2018/types/src/generated/types/InferenceOutputRepresentation.d.ts +44 -0
- package/dist/es/es2018/types/src/generated/types/RiskQstResponse.d.ts +40 -0
- package/dist/es/es2018/types/src/generated/types/RiskQstResponseOutput.d.ts +39 -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 +620 -0
- package/src/raml/api.raml +100 -0
- package/src/raml/luvio.raml +35 -0
package/sfdc/index.js
ADDED
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* ATTENTION!
|
|
9
|
+
* THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
|
|
10
|
+
* If you would like to contribute to LDS, please follow the steps outlined in the git repo.
|
|
11
|
+
* Any changes made to this file in p4 will be automatically overwritten.
|
|
12
|
+
* *******************************************************************************************
|
|
13
|
+
*/
|
|
14
|
+
/* proxy-compat-disable */
|
|
15
|
+
import { createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, createImperativeAdapter } from 'force/ldsBindings';
|
|
16
|
+
import { withDefaultLuvio } from 'force/ldsEngine';
|
|
17
|
+
import { serializeStructuredKey, ingestShape, deepFreeze, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$1, typeCheckConfig as typeCheckConfig$2, StoreKeyMap, createResourceParams as createResourceParams$2 } from 'force/luvioEngine';
|
|
18
|
+
|
|
19
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
20
|
+
const { keys: ObjectKeys, create: ObjectCreate } = Object;
|
|
21
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
22
|
+
/**
|
|
23
|
+
* Validates an adapter config is well-formed.
|
|
24
|
+
* @param config The config to validate.
|
|
25
|
+
* @param adapter The adapter validation configuration.
|
|
26
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
27
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
28
|
+
*/
|
|
29
|
+
function validateConfig(config, adapter, oneOf) {
|
|
30
|
+
const { displayName } = adapter;
|
|
31
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
32
|
+
if (config === undefined ||
|
|
33
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
34
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
37
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
38
|
+
}
|
|
39
|
+
if (unsupported !== undefined &&
|
|
40
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
41
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
42
|
+
}
|
|
43
|
+
const supported = required.concat(optional);
|
|
44
|
+
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
45
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function untrustedIsObject(untrusted) {
|
|
49
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
50
|
+
}
|
|
51
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
52
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
53
|
+
}
|
|
54
|
+
const snapshotRefreshOptions = {
|
|
55
|
+
overrides: {
|
|
56
|
+
headers: {
|
|
57
|
+
'Cache-Control': 'no-cache',
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
|
|
62
|
+
return {
|
|
63
|
+
name,
|
|
64
|
+
required,
|
|
65
|
+
resourceType,
|
|
66
|
+
typeCheckShape,
|
|
67
|
+
isArrayShape,
|
|
68
|
+
coerceFn,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
72
|
+
const required = paramsMeta.filter(p => p.required).map(p => p.name);
|
|
73
|
+
const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
|
|
74
|
+
return {
|
|
75
|
+
displayName,
|
|
76
|
+
parameters: {
|
|
77
|
+
required,
|
|
78
|
+
optional,
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const keyPrefix = 'service-itsm-risk-score-evaluation';
|
|
83
|
+
|
|
84
|
+
const { isArray: ArrayIsArray } = Array;
|
|
85
|
+
const { stringify: JSONStringify } = JSON;
|
|
86
|
+
function equalsArray(a, b, equalsItem) {
|
|
87
|
+
const aLength = a.length;
|
|
88
|
+
const bLength = b.length;
|
|
89
|
+
if (aLength !== bLength) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
for (let i = 0; i < aLength; i++) {
|
|
93
|
+
if (equalsItem(a[i], b[i]) === false) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
function createLink(ref) {
|
|
100
|
+
return {
|
|
101
|
+
__ref: serializeStructuredKey(ref),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const VERSION$2 = "855b66cd2c797f296ef308bdea978796";
|
|
106
|
+
function validate$2(obj, path = 'RiskQstResponse') {
|
|
107
|
+
const v_error = (() => {
|
|
108
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
109
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
110
|
+
}
|
|
111
|
+
const obj_question = obj.question;
|
|
112
|
+
const path_question = path + '.question';
|
|
113
|
+
if (typeof obj_question !== 'string') {
|
|
114
|
+
return new TypeError('Expected "string" but received "' + typeof obj_question + '" (at "' + path_question + '")');
|
|
115
|
+
}
|
|
116
|
+
const obj_response = obj.response;
|
|
117
|
+
const path_response = path + '.response';
|
|
118
|
+
if (typeof obj_response !== 'string') {
|
|
119
|
+
return new TypeError('Expected "string" but received "' + typeof obj_response + '" (at "' + path_response + '")');
|
|
120
|
+
}
|
|
121
|
+
})();
|
|
122
|
+
return v_error === undefined ? null : v_error;
|
|
123
|
+
}
|
|
124
|
+
const RepresentationType$2 = 'RiskQstResponse';
|
|
125
|
+
function keyBuilder$3(luvio, config) {
|
|
126
|
+
return keyPrefix + '::' + RepresentationType$2 + ':' + config.id;
|
|
127
|
+
}
|
|
128
|
+
function keyBuilderFromType$1(luvio, object) {
|
|
129
|
+
const keyParams = {
|
|
130
|
+
id: object.question
|
|
131
|
+
};
|
|
132
|
+
return keyBuilder$3(luvio, keyParams);
|
|
133
|
+
}
|
|
134
|
+
function normalize$2(input, existing, path, luvio, store, timestamp) {
|
|
135
|
+
return input;
|
|
136
|
+
}
|
|
137
|
+
const select$4 = function RiskQstResponseSelect() {
|
|
138
|
+
return {
|
|
139
|
+
kind: 'Fragment',
|
|
140
|
+
version: VERSION$2,
|
|
141
|
+
private: [],
|
|
142
|
+
selections: [
|
|
143
|
+
{
|
|
144
|
+
name: 'question',
|
|
145
|
+
kind: 'Scalar'
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'response',
|
|
149
|
+
kind: 'Scalar'
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
function equals$2(existing, incoming) {
|
|
155
|
+
const existing_question = existing.question;
|
|
156
|
+
const incoming_question = incoming.question;
|
|
157
|
+
if (!(existing_question === incoming_question)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const existing_response = existing.response;
|
|
161
|
+
const incoming_response = incoming.response;
|
|
162
|
+
if (!(existing_response === incoming_response)) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
const ingest$2 = function RiskQstResponseIngest(input, path, luvio, store, timestamp) {
|
|
168
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
169
|
+
const validateError = validate$2(input);
|
|
170
|
+
if (validateError !== null) {
|
|
171
|
+
throw validateError;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const key = keyBuilderFromType$1(luvio, input);
|
|
175
|
+
const ttlToUse = path.ttl !== undefined ? path.ttl : 120000;
|
|
176
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$2, "service-itsm-risk-score-evaluation", VERSION$2, RepresentationType$2, equals$2);
|
|
177
|
+
return createLink(key);
|
|
178
|
+
};
|
|
179
|
+
function getTypeCacheKeys$2(rootKeySet, luvio, input, fullPathFactory) {
|
|
180
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
181
|
+
const rootKey = keyBuilderFromType$1(luvio, input);
|
|
182
|
+
rootKeySet.set(rootKey, {
|
|
183
|
+
namespace: keyPrefix,
|
|
184
|
+
representationName: RepresentationType$2,
|
|
185
|
+
mergeable: false
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const TTL$1 = 300;
|
|
190
|
+
const VERSION$1 = "88c9514f2c41a9aaac5a4cd0146935e8";
|
|
191
|
+
function validate$1(obj, path = 'RiskQstResponseOutput') {
|
|
192
|
+
const v_error = (() => {
|
|
193
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
194
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
195
|
+
}
|
|
196
|
+
const obj_riskQstResponseList = obj.riskQstResponseList;
|
|
197
|
+
const path_riskQstResponseList = path + '.riskQstResponseList';
|
|
198
|
+
if (!ArrayIsArray(obj_riskQstResponseList)) {
|
|
199
|
+
return new TypeError('Expected "array" but received "' + typeof obj_riskQstResponseList + '" (at "' + path_riskQstResponseList + '")');
|
|
200
|
+
}
|
|
201
|
+
for (let i = 0; i < obj_riskQstResponseList.length; i++) {
|
|
202
|
+
const obj_riskQstResponseList_item = obj_riskQstResponseList[i];
|
|
203
|
+
const path_riskQstResponseList_item = path_riskQstResponseList + '[' + i + ']';
|
|
204
|
+
if (typeof obj_riskQstResponseList_item !== 'object' || Array.isArray(obj_riskQstResponseList_item)) {
|
|
205
|
+
return new TypeError('Expected "object" but received "' + typeof obj_riskQstResponseList_item + '" (at "' + path_riskQstResponseList_item + '")');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
})();
|
|
209
|
+
return v_error === undefined ? null : v_error;
|
|
210
|
+
}
|
|
211
|
+
const RepresentationType$1 = 'RiskQstResponseOutput';
|
|
212
|
+
function normalize$1(input, existing, path, luvio, store, timestamp) {
|
|
213
|
+
const input_riskQstResponseList = input.riskQstResponseList;
|
|
214
|
+
const input_riskQstResponseList_id = path.fullPath + '__riskQstResponseList';
|
|
215
|
+
for (let i = 0; i < input_riskQstResponseList.length; i++) {
|
|
216
|
+
const input_riskQstResponseList_item = input_riskQstResponseList[i];
|
|
217
|
+
let input_riskQstResponseList_item_id = input_riskQstResponseList_id + '__' + i;
|
|
218
|
+
input_riskQstResponseList[i] = ingest$2(input_riskQstResponseList_item, {
|
|
219
|
+
fullPath: input_riskQstResponseList_item_id,
|
|
220
|
+
propertyName: i,
|
|
221
|
+
parent: {
|
|
222
|
+
data: input,
|
|
223
|
+
key: path.fullPath,
|
|
224
|
+
existing: existing,
|
|
225
|
+
},
|
|
226
|
+
ttl: path.ttl
|
|
227
|
+
}, luvio, store, timestamp);
|
|
228
|
+
}
|
|
229
|
+
return input;
|
|
230
|
+
}
|
|
231
|
+
const select$3 = function RiskQstResponseOutputSelect() {
|
|
232
|
+
return {
|
|
233
|
+
kind: 'Fragment',
|
|
234
|
+
version: VERSION$1,
|
|
235
|
+
private: [],
|
|
236
|
+
selections: [
|
|
237
|
+
{
|
|
238
|
+
name: 'riskQstResponseList',
|
|
239
|
+
kind: 'Link',
|
|
240
|
+
plural: true,
|
|
241
|
+
fragment: select$4()
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
function equals$1(existing, incoming) {
|
|
247
|
+
const existing_riskQstResponseList = existing.riskQstResponseList;
|
|
248
|
+
const incoming_riskQstResponseList = incoming.riskQstResponseList;
|
|
249
|
+
const equals_riskQstResponseList_items = equalsArray(existing_riskQstResponseList, incoming_riskQstResponseList, (existing_riskQstResponseList_item, incoming_riskQstResponseList_item) => {
|
|
250
|
+
if (!(existing_riskQstResponseList_item.__ref === incoming_riskQstResponseList_item.__ref)) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (equals_riskQstResponseList_items === false) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
const ingest$1 = function RiskQstResponseOutputIngest(input, path, luvio, store, timestamp) {
|
|
260
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
261
|
+
const validateError = validate$1(input);
|
|
262
|
+
if (validateError !== null) {
|
|
263
|
+
throw validateError;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const key = path.fullPath;
|
|
267
|
+
const ttlToUse = TTL$1;
|
|
268
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize$1, "service-itsm-risk-score-evaluation", VERSION$1, RepresentationType$1, equals$1);
|
|
269
|
+
return createLink(key);
|
|
270
|
+
};
|
|
271
|
+
function getTypeCacheKeys$1(rootKeySet, luvio, input, fullPathFactory) {
|
|
272
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
273
|
+
const rootKey = fullPathFactory();
|
|
274
|
+
rootKeySet.set(rootKey, {
|
|
275
|
+
namespace: keyPrefix,
|
|
276
|
+
representationName: RepresentationType$1,
|
|
277
|
+
mergeable: false
|
|
278
|
+
});
|
|
279
|
+
const input_riskQstResponseList_length = input.riskQstResponseList.length;
|
|
280
|
+
for (let i = 0; i < input_riskQstResponseList_length; i++) {
|
|
281
|
+
getTypeCacheKeys$2(rootKeySet, luvio, input.riskQstResponseList[i]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function select$2(luvio, params) {
|
|
286
|
+
return select$3();
|
|
287
|
+
}
|
|
288
|
+
function keyBuilder$2(luvio, params) {
|
|
289
|
+
return keyPrefix + '::RiskQstResponseOutput:(' + 'id:' + params.urlParams.id + ')';
|
|
290
|
+
}
|
|
291
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
292
|
+
getTypeCacheKeys$1(storeKeyMap, luvio, response, () => keyBuilder$2(luvio, resourceParams));
|
|
293
|
+
}
|
|
294
|
+
function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
|
|
295
|
+
const { body } = response;
|
|
296
|
+
const key = keyBuilder$2(luvio, resourceParams);
|
|
297
|
+
luvio.storeIngest(key, ingest$1, body);
|
|
298
|
+
const snapshot = luvio.storeLookup({
|
|
299
|
+
recordId: key,
|
|
300
|
+
node: select$2(),
|
|
301
|
+
variables: {},
|
|
302
|
+
}, snapshotRefresh);
|
|
303
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
304
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
305
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
deepFreeze(snapshot.data);
|
|
309
|
+
return snapshot;
|
|
310
|
+
}
|
|
311
|
+
function ingestError(luvio, params, error, snapshotRefresh) {
|
|
312
|
+
const key = keyBuilder$2(luvio, params);
|
|
313
|
+
const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
|
|
314
|
+
const storeMetadataParams = {
|
|
315
|
+
ttl: TTL$1,
|
|
316
|
+
namespace: keyPrefix,
|
|
317
|
+
version: VERSION$1,
|
|
318
|
+
representationName: RepresentationType$1
|
|
319
|
+
};
|
|
320
|
+
luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
|
|
321
|
+
return errorSnapshot;
|
|
322
|
+
}
|
|
323
|
+
function createResourceRequest$1(config) {
|
|
324
|
+
const headers = {};
|
|
325
|
+
return {
|
|
326
|
+
baseUri: '/services/data/v66.0',
|
|
327
|
+
basePath: '/connect/service-itsm/riskQstResponse/' + config.urlParams.id + '',
|
|
328
|
+
method: 'get',
|
|
329
|
+
body: null,
|
|
330
|
+
urlParams: config.urlParams,
|
|
331
|
+
queryParams: {},
|
|
332
|
+
headers,
|
|
333
|
+
priority: 'normal',
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const adapterName$1 = 'getRiskQstResponses';
|
|
338
|
+
const getRiskQstResponses_ConfigPropertyMetadata = [
|
|
339
|
+
generateParamConfigMetadata('id', true, 0 /* UrlParameter */, 0 /* String */),
|
|
340
|
+
];
|
|
341
|
+
const getRiskQstResponses_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, getRiskQstResponses_ConfigPropertyMetadata);
|
|
342
|
+
const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(getRiskQstResponses_ConfigPropertyMetadata);
|
|
343
|
+
function keyBuilder$1(luvio, config) {
|
|
344
|
+
const resourceParams = createResourceParams$1(config);
|
|
345
|
+
return keyBuilder$2(luvio, resourceParams);
|
|
346
|
+
}
|
|
347
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
348
|
+
const config = {};
|
|
349
|
+
typeCheckConfig$2(untrustedConfig, config, getRiskQstResponses_ConfigPropertyMetadata);
|
|
350
|
+
return config;
|
|
351
|
+
}
|
|
352
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
353
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
357
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
358
|
+
}
|
|
359
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
360
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
return config;
|
|
364
|
+
}
|
|
365
|
+
function adapterFragment(luvio, config) {
|
|
366
|
+
createResourceParams$1(config);
|
|
367
|
+
return select$2();
|
|
368
|
+
}
|
|
369
|
+
function onFetchResponseSuccess(luvio, config, resourceParams, response) {
|
|
370
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
|
|
371
|
+
config,
|
|
372
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
373
|
+
});
|
|
374
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
375
|
+
}
|
|
376
|
+
function onFetchResponseError(luvio, config, resourceParams, response) {
|
|
377
|
+
const snapshot = ingestError(luvio, resourceParams, response, {
|
|
378
|
+
config,
|
|
379
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
380
|
+
});
|
|
381
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
382
|
+
}
|
|
383
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
384
|
+
const resourceParams = createResourceParams$1(config);
|
|
385
|
+
const request = createResourceRequest$1(resourceParams);
|
|
386
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
387
|
+
.then((response) => {
|
|
388
|
+
return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => {
|
|
389
|
+
const cache = new StoreKeyMap();
|
|
390
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
391
|
+
return cache;
|
|
392
|
+
});
|
|
393
|
+
}, (response) => {
|
|
394
|
+
return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
|
|
398
|
+
return buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext, buildNetworkSnapshot$1, undefined, false);
|
|
399
|
+
}
|
|
400
|
+
function buildCachedSnapshotCachePolicy(context, storeLookup) {
|
|
401
|
+
const { luvio, config } = context;
|
|
402
|
+
const selector = {
|
|
403
|
+
recordId: keyBuilder$1(luvio, config),
|
|
404
|
+
node: adapterFragment(luvio, config),
|
|
405
|
+
variables: {},
|
|
406
|
+
};
|
|
407
|
+
const cacheSnapshot = storeLookup(selector, {
|
|
408
|
+
config,
|
|
409
|
+
resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
|
|
410
|
+
});
|
|
411
|
+
return cacheSnapshot;
|
|
412
|
+
}
|
|
413
|
+
const getRiskQstResponsesAdapterFactory = (luvio) => function serviceItsmRiskScoreEvaluation__getRiskQstResponses(untrustedConfig, requestContext) {
|
|
414
|
+
const config = validateAdapterConfig$1(untrustedConfig, getRiskQstResponses_ConfigPropertyNames);
|
|
415
|
+
// Invalid or incomplete config
|
|
416
|
+
if (config === null) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
|
|
420
|
+
buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const TTL = 100;
|
|
424
|
+
const VERSION = "f23637adb9ccb2e92ffd91c172feecf9";
|
|
425
|
+
function validate(obj, path = 'InferenceOutputRepresentation') {
|
|
426
|
+
const v_error = (() => {
|
|
427
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
428
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
429
|
+
}
|
|
430
|
+
const obj_error = obj.error;
|
|
431
|
+
const path_error = path + '.error';
|
|
432
|
+
if (typeof obj_error !== 'string') {
|
|
433
|
+
return new TypeError('Expected "string" but received "' + typeof obj_error + '" (at "' + path_error + '")');
|
|
434
|
+
}
|
|
435
|
+
const obj_result = obj.result;
|
|
436
|
+
const path_result = path + '.result';
|
|
437
|
+
if (typeof obj_result !== 'object' || ArrayIsArray(obj_result) || obj_result === null) {
|
|
438
|
+
return new TypeError('Expected "object" but received "' + typeof obj_result + '" (at "' + path_result + '")');
|
|
439
|
+
}
|
|
440
|
+
const obj_usecase = obj.usecase;
|
|
441
|
+
const path_usecase = path + '.usecase';
|
|
442
|
+
if (typeof obj_usecase !== 'string') {
|
|
443
|
+
return new TypeError('Expected "string" but received "' + typeof obj_usecase + '" (at "' + path_usecase + '")');
|
|
444
|
+
}
|
|
445
|
+
})();
|
|
446
|
+
return v_error === undefined ? null : v_error;
|
|
447
|
+
}
|
|
448
|
+
const RepresentationType = 'InferenceOutputRepresentation';
|
|
449
|
+
function keyBuilder(luvio, config) {
|
|
450
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.id;
|
|
451
|
+
}
|
|
452
|
+
function keyBuilderFromType(luvio, object) {
|
|
453
|
+
const keyParams = {
|
|
454
|
+
id: object.usecase
|
|
455
|
+
};
|
|
456
|
+
return keyBuilder(luvio, keyParams);
|
|
457
|
+
}
|
|
458
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
459
|
+
return input;
|
|
460
|
+
}
|
|
461
|
+
const select$1 = function InferenceOutputRepresentationSelect() {
|
|
462
|
+
return {
|
|
463
|
+
kind: 'Fragment',
|
|
464
|
+
version: VERSION,
|
|
465
|
+
private: [],
|
|
466
|
+
opaque: true
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
function equals(existing, incoming) {
|
|
470
|
+
if (JSONStringify(incoming) !== JSONStringify(existing)) {
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
const ingest = function InferenceOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
476
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
477
|
+
const validateError = validate(input);
|
|
478
|
+
if (validateError !== null) {
|
|
479
|
+
throw validateError;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const key = keyBuilderFromType(luvio, input);
|
|
483
|
+
const ttlToUse = TTL;
|
|
484
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "service-itsm-risk-score-evaluation", VERSION, RepresentationType, equals);
|
|
485
|
+
return createLink(key);
|
|
486
|
+
};
|
|
487
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
488
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
489
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
490
|
+
rootKeySet.set(rootKey, {
|
|
491
|
+
namespace: keyPrefix,
|
|
492
|
+
representationName: RepresentationType,
|
|
493
|
+
mergeable: false
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function select(luvio, params) {
|
|
498
|
+
return select$1();
|
|
499
|
+
}
|
|
500
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
501
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
502
|
+
}
|
|
503
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
504
|
+
const { body } = response;
|
|
505
|
+
const key = keyBuilderFromType(luvio, body);
|
|
506
|
+
luvio.storeIngest(key, ingest, body);
|
|
507
|
+
const snapshot = luvio.storeLookup({
|
|
508
|
+
recordId: key,
|
|
509
|
+
node: select(),
|
|
510
|
+
variables: {},
|
|
511
|
+
});
|
|
512
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
513
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
514
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
deepFreeze(snapshot.data);
|
|
518
|
+
return snapshot;
|
|
519
|
+
}
|
|
520
|
+
function createResourceRequest(config) {
|
|
521
|
+
const headers = {};
|
|
522
|
+
return {
|
|
523
|
+
baseUri: '/services/data/v66.0',
|
|
524
|
+
basePath: '/connect/service-itsm/inference',
|
|
525
|
+
method: 'post',
|
|
526
|
+
body: config.body,
|
|
527
|
+
urlParams: {},
|
|
528
|
+
queryParams: {},
|
|
529
|
+
headers,
|
|
530
|
+
priority: 'normal',
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const adapterName = 'inferAttributes';
|
|
535
|
+
const inferAttributes_ConfigPropertyMetadata = [
|
|
536
|
+
generateParamConfigMetadata('inputText', true, 2 /* Body */, 0 /* String */),
|
|
537
|
+
generateParamConfigMetadata('usecase', true, 2 /* Body */, 0 /* String */),
|
|
538
|
+
];
|
|
539
|
+
const inferAttributes_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, inferAttributes_ConfigPropertyMetadata);
|
|
540
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$2(inferAttributes_ConfigPropertyMetadata);
|
|
541
|
+
function typeCheckConfig(untrustedConfig) {
|
|
542
|
+
const config = {};
|
|
543
|
+
typeCheckConfig$2(untrustedConfig, config, inferAttributes_ConfigPropertyMetadata);
|
|
544
|
+
return config;
|
|
545
|
+
}
|
|
546
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
547
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
551
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
552
|
+
}
|
|
553
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
554
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
return config;
|
|
558
|
+
}
|
|
559
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
560
|
+
const resourceParams = createResourceParams(config);
|
|
561
|
+
const request = createResourceRequest(resourceParams);
|
|
562
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
563
|
+
.then((response) => {
|
|
564
|
+
return luvio.handleSuccessResponse(() => {
|
|
565
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
566
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
567
|
+
}, () => {
|
|
568
|
+
const cache = new StoreKeyMap();
|
|
569
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
570
|
+
return cache;
|
|
571
|
+
});
|
|
572
|
+
}, (response) => {
|
|
573
|
+
deepFreeze(response);
|
|
574
|
+
throw response;
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
const inferAttributesAdapterFactory = (luvio) => {
|
|
578
|
+
return function inferAttributes(untrustedConfig) {
|
|
579
|
+
const config = validateAdapterConfig(untrustedConfig, inferAttributes_ConfigPropertyNames);
|
|
580
|
+
// Invalid or incomplete config
|
|
581
|
+
if (config === null) {
|
|
582
|
+
throw new Error('Invalid config for "inferAttributes"');
|
|
583
|
+
}
|
|
584
|
+
return buildNetworkSnapshot(luvio, config);
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
let getRiskQstResponses;
|
|
589
|
+
let inferAttributes;
|
|
590
|
+
// Imperative GET Adapters
|
|
591
|
+
let getRiskQstResponses_imperative;
|
|
592
|
+
// Adapter Metadata
|
|
593
|
+
const getRiskQstResponsesMetadata = {
|
|
594
|
+
apiFamily: 'serviceitsm-risk-score-evaluation',
|
|
595
|
+
name: 'getRiskQstResponses',
|
|
596
|
+
ttl: 300,
|
|
597
|
+
};
|
|
598
|
+
// Notify Update Available
|
|
599
|
+
function bindExportsTo(luvio) {
|
|
600
|
+
// LDS Adapters
|
|
601
|
+
const getRiskQstResponses_ldsAdapter = createInstrumentedAdapter(createLDSAdapter(luvio, 'getRiskQstResponses', getRiskQstResponsesAdapterFactory), getRiskQstResponsesMetadata);
|
|
602
|
+
function unwrapSnapshotData(factory) {
|
|
603
|
+
const adapter = factory(luvio);
|
|
604
|
+
return (config) => adapter(config).then((snapshot) => snapshot.data);
|
|
605
|
+
}
|
|
606
|
+
return {
|
|
607
|
+
getRiskQstResponses: createWireAdapterConstructor(luvio, getRiskQstResponses_ldsAdapter, getRiskQstResponsesMetadata),
|
|
608
|
+
inferAttributes: unwrapSnapshotData(inferAttributesAdapterFactory),
|
|
609
|
+
// Imperative GET Adapters
|
|
610
|
+
getRiskQstResponses_imperative: createImperativeAdapter(luvio, getRiskQstResponses_ldsAdapter, getRiskQstResponsesMetadata),
|
|
611
|
+
// Notify Update Availables
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
withDefaultLuvio((luvio) => {
|
|
615
|
+
({ getRiskQstResponses, inferAttributes, getRiskQstResponses_imperative } =
|
|
616
|
+
bindExportsTo(luvio));
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
export { getRiskQstResponses, getRiskQstResponses_imperative, inferAttributes };
|
|
620
|
+
// version: 0.1.0-dev1-c978a7b010
|