@salesforce/lds-adapters-platform-learning 1.299.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/dist/es/es2018/platform-learning.js +456 -0
- package/dist/es/es2018/types/src/generated/adapters/adapter-utils.d.ts +62 -0
- package/dist/es/es2018/types/src/generated/adapters/evaluateLearningItem.d.ts +18 -0
- package/dist/es/es2018/types/src/generated/adapters/evaluateLearningItemForCommunity.d.ts +19 -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 +3 -0
- package/dist/es/es2018/types/src/generated/resources/postConnectCommunitiesLearningItemActionsEvaluateByCommunityIdAndLearningItemId.d.ts +18 -0
- package/dist/es/es2018/types/src/generated/resources/postConnectLearningItemActionsEvaluateByLearningItemId.d.ts +17 -0
- package/dist/es/es2018/types/src/generated/types/EvaluateLearningItemInputRepresentation.d.ts +32 -0
- package/dist/es/es2018/types/src/generated/types/LearningItemProgressRepresentation.d.ts +50 -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 +486 -0
- package/src/raml/api.raml +98 -0
- package/src/raml/luvio.raml +24 -0
package/sfdc/index.js
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
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 { withDefaultLuvio } from 'force/ldsEngine';
|
|
16
|
+
import { serializeStructuredKey, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$2, typeCheckConfig as typeCheckConfig$2 } from 'force/luvioEngine';
|
|
17
|
+
|
|
18
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
19
|
+
const { keys: ObjectKeys, create: ObjectCreate } = Object;
|
|
20
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
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
|
+
function validateConfig(config, adapter, oneOf) {
|
|
29
|
+
const { displayName } = adapter;
|
|
30
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
31
|
+
if (config === undefined ||
|
|
32
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
33
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
34
|
+
}
|
|
35
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
36
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
37
|
+
}
|
|
38
|
+
if (unsupported !== undefined &&
|
|
39
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
40
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
const supported = required.concat(optional);
|
|
43
|
+
if (ObjectKeys(config).some(key => !supported.includes(key))) {
|
|
44
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function untrustedIsObject(untrusted) {
|
|
48
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
49
|
+
}
|
|
50
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
51
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
52
|
+
}
|
|
53
|
+
function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
|
|
54
|
+
return {
|
|
55
|
+
name,
|
|
56
|
+
required,
|
|
57
|
+
resourceType,
|
|
58
|
+
typeCheckShape,
|
|
59
|
+
isArrayShape,
|
|
60
|
+
coerceFn,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
64
|
+
const required = paramsMeta.filter(p => p.required).map(p => p.name);
|
|
65
|
+
const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
|
|
66
|
+
return {
|
|
67
|
+
displayName,
|
|
68
|
+
parameters: {
|
|
69
|
+
required,
|
|
70
|
+
optional,
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const keyPrefix = 'learning';
|
|
75
|
+
|
|
76
|
+
const { isArray: ArrayIsArray } = Array;
|
|
77
|
+
function createLink(ref) {
|
|
78
|
+
return {
|
|
79
|
+
__ref: serializeStructuredKey(ref),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const TTL = 15000;
|
|
84
|
+
const VERSION = "987ec5d201417fd82d2e377adf8ef5cd";
|
|
85
|
+
function validate(obj, path = 'LearningItemProgressRepresentation') {
|
|
86
|
+
const v_error = (() => {
|
|
87
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
88
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
89
|
+
}
|
|
90
|
+
const obj_completedDate = obj.completedDate;
|
|
91
|
+
const path_completedDate = path + '.completedDate';
|
|
92
|
+
let obj_completedDate_union0 = null;
|
|
93
|
+
const obj_completedDate_union0_error = (() => {
|
|
94
|
+
if (typeof obj_completedDate !== 'string') {
|
|
95
|
+
return new TypeError('Expected "string" but received "' + typeof obj_completedDate + '" (at "' + path_completedDate + '")');
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
if (obj_completedDate_union0_error != null) {
|
|
99
|
+
obj_completedDate_union0 = obj_completedDate_union0_error.message;
|
|
100
|
+
}
|
|
101
|
+
let obj_completedDate_union1 = null;
|
|
102
|
+
const obj_completedDate_union1_error = (() => {
|
|
103
|
+
if (obj_completedDate !== null) {
|
|
104
|
+
return new TypeError('Expected "null" but received "' + typeof obj_completedDate + '" (at "' + path_completedDate + '")');
|
|
105
|
+
}
|
|
106
|
+
})();
|
|
107
|
+
if (obj_completedDate_union1_error != null) {
|
|
108
|
+
obj_completedDate_union1 = obj_completedDate_union1_error.message;
|
|
109
|
+
}
|
|
110
|
+
if (obj_completedDate_union0 && obj_completedDate_union1) {
|
|
111
|
+
let message = 'Object doesn\'t match union (at "' + path_completedDate + '")';
|
|
112
|
+
message += '\n' + obj_completedDate_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
113
|
+
message += '\n' + obj_completedDate_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
114
|
+
return new TypeError(message);
|
|
115
|
+
}
|
|
116
|
+
const obj_completedPercent = obj.completedPercent;
|
|
117
|
+
const path_completedPercent = path + '.completedPercent';
|
|
118
|
+
let obj_completedPercent_union0 = null;
|
|
119
|
+
const obj_completedPercent_union0_error = (() => {
|
|
120
|
+
if (typeof obj_completedPercent !== 'number') {
|
|
121
|
+
return new TypeError('Expected "number" but received "' + typeof obj_completedPercent + '" (at "' + path_completedPercent + '")');
|
|
122
|
+
}
|
|
123
|
+
})();
|
|
124
|
+
if (obj_completedPercent_union0_error != null) {
|
|
125
|
+
obj_completedPercent_union0 = obj_completedPercent_union0_error.message;
|
|
126
|
+
}
|
|
127
|
+
let obj_completedPercent_union1 = null;
|
|
128
|
+
const obj_completedPercent_union1_error = (() => {
|
|
129
|
+
if (obj_completedPercent !== null) {
|
|
130
|
+
return new TypeError('Expected "null" but received "' + typeof obj_completedPercent + '" (at "' + path_completedPercent + '")');
|
|
131
|
+
}
|
|
132
|
+
})();
|
|
133
|
+
if (obj_completedPercent_union1_error != null) {
|
|
134
|
+
obj_completedPercent_union1 = obj_completedPercent_union1_error.message;
|
|
135
|
+
}
|
|
136
|
+
if (obj_completedPercent_union0 && obj_completedPercent_union1) {
|
|
137
|
+
let message = 'Object doesn\'t match union (at "' + path_completedPercent + '")';
|
|
138
|
+
message += '\n' + obj_completedPercent_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
139
|
+
message += '\n' + obj_completedPercent_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
140
|
+
return new TypeError(message);
|
|
141
|
+
}
|
|
142
|
+
const obj_id = obj.id;
|
|
143
|
+
const path_id = path + '.id';
|
|
144
|
+
if (typeof obj_id !== 'string') {
|
|
145
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
146
|
+
}
|
|
147
|
+
const obj_isCompleted = obj.isCompleted;
|
|
148
|
+
const path_isCompleted = path + '.isCompleted';
|
|
149
|
+
if (typeof obj_isCompleted !== 'boolean') {
|
|
150
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_isCompleted + '" (at "' + path_isCompleted + '")');
|
|
151
|
+
}
|
|
152
|
+
const obj_learningItemId = obj.learningItemId;
|
|
153
|
+
const path_learningItemId = path + '.learningItemId';
|
|
154
|
+
if (typeof obj_learningItemId !== 'string') {
|
|
155
|
+
return new TypeError('Expected "string" but received "' + typeof obj_learningItemId + '" (at "' + path_learningItemId + '")');
|
|
156
|
+
}
|
|
157
|
+
})();
|
|
158
|
+
return v_error === undefined ? null : v_error;
|
|
159
|
+
}
|
|
160
|
+
const RepresentationType = 'LearningItemProgressRepresentation';
|
|
161
|
+
function keyBuilder(luvio, config) {
|
|
162
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.learning_item_progress_id;
|
|
163
|
+
}
|
|
164
|
+
function keyBuilderFromType(luvio, object) {
|
|
165
|
+
const keyParams = {
|
|
166
|
+
learning_item_progress_id: object.id
|
|
167
|
+
};
|
|
168
|
+
return keyBuilder(luvio, keyParams);
|
|
169
|
+
}
|
|
170
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
171
|
+
return input;
|
|
172
|
+
}
|
|
173
|
+
const select$2 = function LearningItemProgressRepresentationSelect() {
|
|
174
|
+
return {
|
|
175
|
+
kind: 'Fragment',
|
|
176
|
+
version: VERSION,
|
|
177
|
+
private: [],
|
|
178
|
+
selections: [
|
|
179
|
+
{
|
|
180
|
+
name: 'completedDate',
|
|
181
|
+
kind: 'Scalar'
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'completedPercent',
|
|
185
|
+
kind: 'Scalar'
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'id',
|
|
189
|
+
kind: 'Scalar'
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'isCompleted',
|
|
193
|
+
kind: 'Scalar'
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'learningItemId',
|
|
197
|
+
kind: 'Scalar'
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
function equals(existing, incoming) {
|
|
203
|
+
const existing_isCompleted = existing.isCompleted;
|
|
204
|
+
const incoming_isCompleted = incoming.isCompleted;
|
|
205
|
+
if (!(existing_isCompleted === incoming_isCompleted)) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const existing_id = existing.id;
|
|
209
|
+
const incoming_id = incoming.id;
|
|
210
|
+
if (!(existing_id === incoming_id)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
const existing_learningItemId = existing.learningItemId;
|
|
214
|
+
const incoming_learningItemId = incoming.learningItemId;
|
|
215
|
+
if (!(existing_learningItemId === incoming_learningItemId)) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const existing_completedDate = existing.completedDate;
|
|
219
|
+
const incoming_completedDate = incoming.completedDate;
|
|
220
|
+
if (!(existing_completedDate === incoming_completedDate)) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
const existing_completedPercent = existing.completedPercent;
|
|
224
|
+
const incoming_completedPercent = incoming.completedPercent;
|
|
225
|
+
if (!(existing_completedPercent === incoming_completedPercent)) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
const ingest = function LearningItemProgressRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
231
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
232
|
+
const validateError = validate(input);
|
|
233
|
+
if (validateError !== null) {
|
|
234
|
+
throw validateError;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const key = keyBuilderFromType(luvio, input);
|
|
238
|
+
const ttlToUse = TTL;
|
|
239
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "learning", VERSION, RepresentationType, equals);
|
|
240
|
+
return createLink(key);
|
|
241
|
+
};
|
|
242
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
243
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
244
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
245
|
+
rootKeySet.set(rootKey, {
|
|
246
|
+
namespace: keyPrefix,
|
|
247
|
+
representationName: RepresentationType,
|
|
248
|
+
mergeable: false
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function select$1(luvio, params) {
|
|
253
|
+
return select$2();
|
|
254
|
+
}
|
|
255
|
+
function getResponseCacheKeys$1(storeKeyMap, luvio, resourceParams, response) {
|
|
256
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
257
|
+
}
|
|
258
|
+
function ingestSuccess$1(luvio, resourceParams, response) {
|
|
259
|
+
const { body } = response;
|
|
260
|
+
const key = keyBuilderFromType(luvio, body);
|
|
261
|
+
luvio.storeIngest(key, ingest, body);
|
|
262
|
+
const snapshot = luvio.storeLookup({
|
|
263
|
+
recordId: key,
|
|
264
|
+
node: select$1(),
|
|
265
|
+
variables: {},
|
|
266
|
+
});
|
|
267
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
268
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
269
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
deepFreeze(snapshot.data);
|
|
273
|
+
return snapshot;
|
|
274
|
+
}
|
|
275
|
+
function createResourceRequest$1(config) {
|
|
276
|
+
const headers = {};
|
|
277
|
+
return {
|
|
278
|
+
baseUri: '/services/data/v62.0',
|
|
279
|
+
basePath: '/connect/learningItem/' + config.urlParams.learningItemId + '/actions/evaluate',
|
|
280
|
+
method: 'post',
|
|
281
|
+
body: config.body,
|
|
282
|
+
urlParams: config.urlParams,
|
|
283
|
+
queryParams: {},
|
|
284
|
+
headers,
|
|
285
|
+
priority: 'normal',
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const adapterName$1 = 'evaluateLearningItem';
|
|
290
|
+
const evaluateLearningItem_ConfigPropertyMetadata = [
|
|
291
|
+
generateParamConfigMetadata('learningItemId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
292
|
+
generateParamConfigMetadata('details', false, 2 /* Body */, 4 /* Unsupported */),
|
|
293
|
+
];
|
|
294
|
+
const evaluateLearningItem_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName$1, evaluateLearningItem_ConfigPropertyMetadata);
|
|
295
|
+
const createResourceParams$1 = /*#__PURE__*/ createResourceParams$2(evaluateLearningItem_ConfigPropertyMetadata);
|
|
296
|
+
function typeCheckConfig$1(untrustedConfig) {
|
|
297
|
+
const config = {};
|
|
298
|
+
typeCheckConfig$2(untrustedConfig, config, evaluateLearningItem_ConfigPropertyMetadata);
|
|
299
|
+
const untrustedConfig_details = untrustedConfig.details;
|
|
300
|
+
if (untrustedIsObject(untrustedConfig_details)) {
|
|
301
|
+
const untrustedConfig_details_object = {};
|
|
302
|
+
const untrustedConfig_details_keys = Object.keys(untrustedConfig_details);
|
|
303
|
+
for (let i = 0, arrayLength = untrustedConfig_details_keys.length; i < arrayLength; i++) {
|
|
304
|
+
const key = untrustedConfig_details_keys[i];
|
|
305
|
+
const untrustedConfig_details_prop = untrustedConfig_details[key];
|
|
306
|
+
if (untrustedConfig_details_object !== undefined) {
|
|
307
|
+
untrustedConfig_details_object[key] = untrustedConfig_details_prop;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (untrustedConfig_details_object !== undefined && Object.keys(untrustedConfig_details_object).length >= 0) {
|
|
311
|
+
config.details = untrustedConfig_details_object;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return config;
|
|
315
|
+
}
|
|
316
|
+
function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
|
|
317
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
321
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
322
|
+
}
|
|
323
|
+
const config = typeCheckConfig$1(untrustedConfig);
|
|
324
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
return config;
|
|
328
|
+
}
|
|
329
|
+
function buildNetworkSnapshot$1(luvio, config, options) {
|
|
330
|
+
const resourceParams = createResourceParams$1(config);
|
|
331
|
+
const request = createResourceRequest$1(resourceParams);
|
|
332
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
333
|
+
.then((response) => {
|
|
334
|
+
return luvio.handleSuccessResponse(() => {
|
|
335
|
+
const snapshot = ingestSuccess$1(luvio, resourceParams, response);
|
|
336
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
337
|
+
}, () => {
|
|
338
|
+
const cache = new StoreKeyMap();
|
|
339
|
+
getResponseCacheKeys$1(cache, luvio, resourceParams, response.body);
|
|
340
|
+
return cache;
|
|
341
|
+
});
|
|
342
|
+
}, (response) => {
|
|
343
|
+
deepFreeze(response);
|
|
344
|
+
throw response;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
const evaluateLearningItemAdapterFactory = (luvio) => {
|
|
348
|
+
return function evaluateLearningItem(untrustedConfig) {
|
|
349
|
+
const config = validateAdapterConfig$1(untrustedConfig, evaluateLearningItem_ConfigPropertyNames);
|
|
350
|
+
// Invalid or incomplete config
|
|
351
|
+
if (config === null) {
|
|
352
|
+
throw new Error('Invalid config for "evaluateLearningItem"');
|
|
353
|
+
}
|
|
354
|
+
return buildNetworkSnapshot$1(luvio, config);
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
function select(luvio, params) {
|
|
359
|
+
return select$2();
|
|
360
|
+
}
|
|
361
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
362
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
363
|
+
}
|
|
364
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
365
|
+
const { body } = response;
|
|
366
|
+
const key = keyBuilderFromType(luvio, body);
|
|
367
|
+
luvio.storeIngest(key, ingest, body);
|
|
368
|
+
const snapshot = luvio.storeLookup({
|
|
369
|
+
recordId: key,
|
|
370
|
+
node: select(),
|
|
371
|
+
variables: {},
|
|
372
|
+
});
|
|
373
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
374
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
375
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
deepFreeze(snapshot.data);
|
|
379
|
+
return snapshot;
|
|
380
|
+
}
|
|
381
|
+
function createResourceRequest(config) {
|
|
382
|
+
const headers = {};
|
|
383
|
+
return {
|
|
384
|
+
baseUri: '/services/data/v62.0',
|
|
385
|
+
basePath: '/connect/communities/' + config.urlParams.communityId + '/learningItem/' + config.urlParams.learningItemId + '/actions/evaluate',
|
|
386
|
+
method: 'post',
|
|
387
|
+
body: config.body,
|
|
388
|
+
urlParams: config.urlParams,
|
|
389
|
+
queryParams: {},
|
|
390
|
+
headers,
|
|
391
|
+
priority: 'normal',
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const adapterName = 'evaluateLearningItemForCommunity';
|
|
396
|
+
const evaluateLearningItemForCommunity_ConfigPropertyMetadata = [
|
|
397
|
+
generateParamConfigMetadata('communityId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
398
|
+
generateParamConfigMetadata('learningItemId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
399
|
+
generateParamConfigMetadata('details', false, 2 /* Body */, 4 /* Unsupported */),
|
|
400
|
+
];
|
|
401
|
+
const evaluateLearningItemForCommunity_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, evaluateLearningItemForCommunity_ConfigPropertyMetadata);
|
|
402
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$2(evaluateLearningItemForCommunity_ConfigPropertyMetadata);
|
|
403
|
+
function typeCheckConfig(untrustedConfig) {
|
|
404
|
+
const config = {};
|
|
405
|
+
typeCheckConfig$2(untrustedConfig, config, evaluateLearningItemForCommunity_ConfigPropertyMetadata);
|
|
406
|
+
const untrustedConfig_details = untrustedConfig.details;
|
|
407
|
+
if (untrustedIsObject(untrustedConfig_details)) {
|
|
408
|
+
const untrustedConfig_details_object = {};
|
|
409
|
+
const untrustedConfig_details_keys = Object.keys(untrustedConfig_details);
|
|
410
|
+
for (let i = 0, arrayLength = untrustedConfig_details_keys.length; i < arrayLength; i++) {
|
|
411
|
+
const key = untrustedConfig_details_keys[i];
|
|
412
|
+
const untrustedConfig_details_prop = untrustedConfig_details[key];
|
|
413
|
+
if (untrustedConfig_details_object !== undefined) {
|
|
414
|
+
untrustedConfig_details_object[key] = untrustedConfig_details_prop;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (untrustedConfig_details_object !== undefined && Object.keys(untrustedConfig_details_object).length >= 0) {
|
|
418
|
+
config.details = untrustedConfig_details_object;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return config;
|
|
422
|
+
}
|
|
423
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
424
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
428
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
429
|
+
}
|
|
430
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
431
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
return config;
|
|
435
|
+
}
|
|
436
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
437
|
+
const resourceParams = createResourceParams(config);
|
|
438
|
+
const request = createResourceRequest(resourceParams);
|
|
439
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
440
|
+
.then((response) => {
|
|
441
|
+
return luvio.handleSuccessResponse(() => {
|
|
442
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
443
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
444
|
+
}, () => {
|
|
445
|
+
const cache = new StoreKeyMap();
|
|
446
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
447
|
+
return cache;
|
|
448
|
+
});
|
|
449
|
+
}, (response) => {
|
|
450
|
+
deepFreeze(response);
|
|
451
|
+
throw response;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
const evaluateLearningItemForCommunityAdapterFactory = (luvio) => {
|
|
455
|
+
return function evaluateLearningItemForCommunity(untrustedConfig) {
|
|
456
|
+
const config = validateAdapterConfig(untrustedConfig, evaluateLearningItemForCommunity_ConfigPropertyNames);
|
|
457
|
+
// Invalid or incomplete config
|
|
458
|
+
if (config === null) {
|
|
459
|
+
throw new Error('Invalid config for "evaluateLearningItemForCommunity"');
|
|
460
|
+
}
|
|
461
|
+
return buildNetworkSnapshot(luvio, config);
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
let evaluateLearningItem;
|
|
466
|
+
let evaluateLearningItemForCommunity;
|
|
467
|
+
// Notify Update Available
|
|
468
|
+
function bindExportsTo(luvio) {
|
|
469
|
+
// LDS Adapters
|
|
470
|
+
function unwrapSnapshotData(factory) {
|
|
471
|
+
const adapter = factory(luvio);
|
|
472
|
+
return (config) => adapter(config).then((snapshot) => snapshot.data);
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
evaluateLearningItem: unwrapSnapshotData(evaluateLearningItemAdapterFactory),
|
|
476
|
+
evaluateLearningItemForCommunity: unwrapSnapshotData(evaluateLearningItemForCommunityAdapterFactory),
|
|
477
|
+
// Imperative GET Adapters
|
|
478
|
+
// Notify Update Availables
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
withDefaultLuvio((luvio) => {
|
|
482
|
+
({ evaluateLearningItem, evaluateLearningItemForCommunity } = bindExportsTo(luvio));
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
export { evaluateLearningItem, evaluateLearningItemForCommunity };
|
|
486
|
+
// version: 1.299.0-161c48605a
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#%RAML 1.0
|
|
2
|
+
securedBy:
|
|
3
|
+
- OAuth2
|
|
4
|
+
title: Salesforce Connect API
|
|
5
|
+
version: '62.0'
|
|
6
|
+
mediaType: application/json
|
|
7
|
+
protocols:
|
|
8
|
+
- https
|
|
9
|
+
baseUri: /services/data/v62.0
|
|
10
|
+
securitySchemes:
|
|
11
|
+
OAuth2:
|
|
12
|
+
type: OAuth 2.0
|
|
13
|
+
settings:
|
|
14
|
+
authorizationUri: https://example.com/oauth/authorize
|
|
15
|
+
accessTokenUri: ''
|
|
16
|
+
authorizationGrants:
|
|
17
|
+
- implicit
|
|
18
|
+
annotationTypes:
|
|
19
|
+
oas-readOnly:
|
|
20
|
+
type: boolean
|
|
21
|
+
allowedTargets: TypeDeclaration
|
|
22
|
+
oas-collectionFormat:
|
|
23
|
+
type: string
|
|
24
|
+
oas-body-name:
|
|
25
|
+
type: string
|
|
26
|
+
allowedTargets: TypeDeclaration
|
|
27
|
+
types:
|
|
28
|
+
EvaluateLearningItemInputRepresentation:
|
|
29
|
+
description: Represents the data that's sent for evaluating the learning item
|
|
30
|
+
type: object
|
|
31
|
+
properties:
|
|
32
|
+
details:
|
|
33
|
+
description: The learning item data, in JSON format, that you want to evaluate.
|
|
34
|
+
type: object
|
|
35
|
+
required: false # TODO Hand-rolled W-8253396
|
|
36
|
+
properties:
|
|
37
|
+
//:
|
|
38
|
+
type: any
|
|
39
|
+
LearningItemProgressRepresentation:
|
|
40
|
+
description: Represents the response that's returned after a learning item is evaluated successfully
|
|
41
|
+
type: object
|
|
42
|
+
properties:
|
|
43
|
+
completedDate:
|
|
44
|
+
description: The date when the user completed the learning item
|
|
45
|
+
type: string | nil
|
|
46
|
+
completedPercent:
|
|
47
|
+
description: Percentage of the learning item that's complete
|
|
48
|
+
#format: double # Hand-rolled format not allowed with union type
|
|
49
|
+
type: number | nil
|
|
50
|
+
id:
|
|
51
|
+
description: The ID of the learning item progress
|
|
52
|
+
type: string
|
|
53
|
+
isCompleted:
|
|
54
|
+
description: Whether the learning item is complete (true) or not (false). The default value is false
|
|
55
|
+
type: boolean
|
|
56
|
+
learningItemId:
|
|
57
|
+
description: The ID of the learning item that was evaluated
|
|
58
|
+
type: string
|
|
59
|
+
/connect:
|
|
60
|
+
/communities/{communityId}/learningItem/{learningItemId}/actions/evaluate:
|
|
61
|
+
post:
|
|
62
|
+
displayName: postEvaluateLearningItem
|
|
63
|
+
description: Checks the completion progress of a learning item
|
|
64
|
+
responses:
|
|
65
|
+
'200':
|
|
66
|
+
description: Success
|
|
67
|
+
body:
|
|
68
|
+
application/json:
|
|
69
|
+
type: LearningItemProgressRepresentation
|
|
70
|
+
body:
|
|
71
|
+
application/json:
|
|
72
|
+
type: EvaluateLearningItemInputRepresentation
|
|
73
|
+
(oas-body-name): evaluateLearningItemInputRepresentation
|
|
74
|
+
uriParameters:
|
|
75
|
+
communityId:
|
|
76
|
+
type: string
|
|
77
|
+
required: true
|
|
78
|
+
learningItemId:
|
|
79
|
+
type: string
|
|
80
|
+
required: true
|
|
81
|
+
/learningItem/{learningItemId}/actions/evaluate:
|
|
82
|
+
post:
|
|
83
|
+
displayName: postEvaluateLearningItem
|
|
84
|
+
description: Checks the completion progress of a learning item
|
|
85
|
+
responses:
|
|
86
|
+
'200':
|
|
87
|
+
description: Success
|
|
88
|
+
body:
|
|
89
|
+
application/json:
|
|
90
|
+
type: LearningItemProgressRepresentation
|
|
91
|
+
body:
|
|
92
|
+
application/json:
|
|
93
|
+
type: EvaluateLearningItemInputRepresentation
|
|
94
|
+
(oas-body-name): evaluateLearningItemInputRepresentation
|
|
95
|
+
uriParameters:
|
|
96
|
+
learningItemId:
|
|
97
|
+
type: string
|
|
98
|
+
required: true
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#%RAML 1.0 Overlay
|
|
2
|
+
extends: ./api.raml
|
|
3
|
+
|
|
4
|
+
uses:
|
|
5
|
+
luvio: luvio://annotations.raml
|
|
6
|
+
|
|
7
|
+
(luvio.keyPrefix): 'learning'
|
|
8
|
+
(luvio.ttl): 2592000000
|
|
9
|
+
|
|
10
|
+
types:
|
|
11
|
+
LearningItemProgressRepresentation:
|
|
12
|
+
(luvio.ttl): 15000 # 15 seconds
|
|
13
|
+
(luvio.key):
|
|
14
|
+
learning_item_progress_id: id
|
|
15
|
+
|
|
16
|
+
/connect:
|
|
17
|
+
/communities/{communityId}/learningItem/{learningItemId}/actions/evaluate:
|
|
18
|
+
post:
|
|
19
|
+
(luvio.adapter):
|
|
20
|
+
name: evaluateLearningItemForCommunity
|
|
21
|
+
/learningItem/{learningItemId}/actions/evaluate:
|
|
22
|
+
post:
|
|
23
|
+
(luvio.adapter):
|
|
24
|
+
name: evaluateLearningItem
|