@salesforce/lds-adapters-platform-learning 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/platform-learning.js +349 -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/artifacts/main.d.ts +1 -0
- package/dist/es/es2018/types/src/generated/artifacts/sfdc.d.ts +2 -0
- package/dist/es/es2018/types/src/generated/resources/postConnectLearningPlatformLearningItemActionsEvaluateByLearningItemId.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 +377 -0
- package/src/raml/api.raml +77 -0
- package/src/raml/luvio.raml +20 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2022, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
|
@@ -0,0 +1,349 @@
|
|
|
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, StoreKeyMap, createResourceParams as createResourceParams$1, typeCheckConfig as typeCheckConfig$1 } 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
|
+
function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
|
|
45
|
+
return {
|
|
46
|
+
name,
|
|
47
|
+
required,
|
|
48
|
+
resourceType,
|
|
49
|
+
typeCheckShape,
|
|
50
|
+
isArrayShape,
|
|
51
|
+
coerceFn,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function buildAdapterValidationConfig(displayName, paramsMeta) {
|
|
55
|
+
const required = paramsMeta.filter(p => p.required).map(p => p.name);
|
|
56
|
+
const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
|
|
57
|
+
return {
|
|
58
|
+
displayName,
|
|
59
|
+
parameters: {
|
|
60
|
+
required,
|
|
61
|
+
optional,
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const keyPrefix = 'learning';
|
|
66
|
+
|
|
67
|
+
const { isArray: ArrayIsArray } = Array;
|
|
68
|
+
function createLink(ref) {
|
|
69
|
+
return {
|
|
70
|
+
__ref: serializeStructuredKey(ref),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const TTL = 15000;
|
|
75
|
+
const VERSION = "a951328be5199223955d423d805f587b";
|
|
76
|
+
function validate(obj, path = 'LearningItemProgressRepresentation') {
|
|
77
|
+
const v_error = (() => {
|
|
78
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
79
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
80
|
+
}
|
|
81
|
+
const obj_completedDate = obj.completedDate;
|
|
82
|
+
const path_completedDate = path + '.completedDate';
|
|
83
|
+
let obj_completedDate_union0 = null;
|
|
84
|
+
const obj_completedDate_union0_error = (() => {
|
|
85
|
+
if (typeof obj_completedDate !== 'string') {
|
|
86
|
+
return new TypeError('Expected "string" but received "' + typeof obj_completedDate + '" (at "' + path_completedDate + '")');
|
|
87
|
+
}
|
|
88
|
+
})();
|
|
89
|
+
if (obj_completedDate_union0_error != null) {
|
|
90
|
+
obj_completedDate_union0 = obj_completedDate_union0_error.message;
|
|
91
|
+
}
|
|
92
|
+
let obj_completedDate_union1 = null;
|
|
93
|
+
const obj_completedDate_union1_error = (() => {
|
|
94
|
+
if (obj_completedDate !== null) {
|
|
95
|
+
return new TypeError('Expected "null" but received "' + typeof obj_completedDate + '" (at "' + path_completedDate + '")');
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
if (obj_completedDate_union1_error != null) {
|
|
99
|
+
obj_completedDate_union1 = obj_completedDate_union1_error.message;
|
|
100
|
+
}
|
|
101
|
+
if (obj_completedDate_union0 && obj_completedDate_union1) {
|
|
102
|
+
let message = 'Object doesn\'t match union (at "' + path_completedDate + '")';
|
|
103
|
+
message += '\n' + obj_completedDate_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
104
|
+
message += '\n' + obj_completedDate_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
105
|
+
return new TypeError(message);
|
|
106
|
+
}
|
|
107
|
+
const obj_completedPercent = obj.completedPercent;
|
|
108
|
+
const path_completedPercent = path + '.completedPercent';
|
|
109
|
+
let obj_completedPercent_union0 = null;
|
|
110
|
+
const obj_completedPercent_union0_error = (() => {
|
|
111
|
+
if (typeof obj_completedPercent !== 'number') {
|
|
112
|
+
return new TypeError('Expected "number" but received "' + typeof obj_completedPercent + '" (at "' + path_completedPercent + '")');
|
|
113
|
+
}
|
|
114
|
+
})();
|
|
115
|
+
if (obj_completedPercent_union0_error != null) {
|
|
116
|
+
obj_completedPercent_union0 = obj_completedPercent_union0_error.message;
|
|
117
|
+
}
|
|
118
|
+
let obj_completedPercent_union1 = null;
|
|
119
|
+
const obj_completedPercent_union1_error = (() => {
|
|
120
|
+
if (obj_completedPercent !== null) {
|
|
121
|
+
return new TypeError('Expected "null" but received "' + typeof obj_completedPercent + '" (at "' + path_completedPercent + '")');
|
|
122
|
+
}
|
|
123
|
+
})();
|
|
124
|
+
if (obj_completedPercent_union1_error != null) {
|
|
125
|
+
obj_completedPercent_union1 = obj_completedPercent_union1_error.message;
|
|
126
|
+
}
|
|
127
|
+
if (obj_completedPercent_union0 && obj_completedPercent_union1) {
|
|
128
|
+
let message = 'Object doesn\'t match union (at "' + path_completedPercent + '")';
|
|
129
|
+
message += '\n' + obj_completedPercent_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
130
|
+
message += '\n' + obj_completedPercent_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
131
|
+
return new TypeError(message);
|
|
132
|
+
}
|
|
133
|
+
const obj_id = obj.id;
|
|
134
|
+
const path_id = path + '.id';
|
|
135
|
+
if (typeof obj_id !== 'string') {
|
|
136
|
+
return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
|
|
137
|
+
}
|
|
138
|
+
const obj_isCompleted = obj.isCompleted;
|
|
139
|
+
const path_isCompleted = path + '.isCompleted';
|
|
140
|
+
if (typeof obj_isCompleted !== 'boolean') {
|
|
141
|
+
return new TypeError('Expected "boolean" but received "' + typeof obj_isCompleted + '" (at "' + path_isCompleted + '")');
|
|
142
|
+
}
|
|
143
|
+
const obj_learningItemId = obj.learningItemId;
|
|
144
|
+
const path_learningItemId = path + '.learningItemId';
|
|
145
|
+
if (typeof obj_learningItemId !== 'string') {
|
|
146
|
+
return new TypeError('Expected "string" but received "' + typeof obj_learningItemId + '" (at "' + path_learningItemId + '")');
|
|
147
|
+
}
|
|
148
|
+
})();
|
|
149
|
+
return v_error === undefined ? null : v_error;
|
|
150
|
+
}
|
|
151
|
+
const RepresentationType = 'LearningItemProgressRepresentation';
|
|
152
|
+
function keyBuilder(luvio, config) {
|
|
153
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.learning_item_id;
|
|
154
|
+
}
|
|
155
|
+
function keyBuilderFromType(luvio, object) {
|
|
156
|
+
const keyParams = {
|
|
157
|
+
learning_item_id: object.learningItemId
|
|
158
|
+
};
|
|
159
|
+
return keyBuilder(luvio, keyParams);
|
|
160
|
+
}
|
|
161
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
162
|
+
return input;
|
|
163
|
+
}
|
|
164
|
+
const select$1 = function LearningItemProgressRepresentationSelect() {
|
|
165
|
+
return {
|
|
166
|
+
kind: 'Fragment',
|
|
167
|
+
version: VERSION,
|
|
168
|
+
private: [],
|
|
169
|
+
selections: [
|
|
170
|
+
{
|
|
171
|
+
name: 'completedDate',
|
|
172
|
+
kind: 'Scalar'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'completedPercent',
|
|
176
|
+
kind: 'Scalar'
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'id',
|
|
180
|
+
kind: 'Scalar'
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'isCompleted',
|
|
184
|
+
kind: 'Scalar'
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'learningItemId',
|
|
188
|
+
kind: 'Scalar'
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
function equals(existing, incoming) {
|
|
194
|
+
const existing_isCompleted = existing.isCompleted;
|
|
195
|
+
const incoming_isCompleted = incoming.isCompleted;
|
|
196
|
+
if (!(existing_isCompleted === incoming_isCompleted)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
const existing_id = existing.id;
|
|
200
|
+
const incoming_id = incoming.id;
|
|
201
|
+
if (!(existing_id === incoming_id)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
const existing_learningItemId = existing.learningItemId;
|
|
205
|
+
const incoming_learningItemId = incoming.learningItemId;
|
|
206
|
+
if (!(existing_learningItemId === incoming_learningItemId)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
const existing_completedDate = existing.completedDate;
|
|
210
|
+
const incoming_completedDate = incoming.completedDate;
|
|
211
|
+
if (!(existing_completedDate === incoming_completedDate)) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const existing_completedPercent = existing.completedPercent;
|
|
215
|
+
const incoming_completedPercent = incoming.completedPercent;
|
|
216
|
+
if (!(existing_completedPercent === incoming_completedPercent)) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
const ingest = function LearningItemProgressRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
222
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
223
|
+
const validateError = validate(input);
|
|
224
|
+
if (validateError !== null) {
|
|
225
|
+
throw validateError;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const key = keyBuilderFromType(luvio, input);
|
|
229
|
+
const ttlToUse = TTL;
|
|
230
|
+
ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "learning", VERSION, RepresentationType, equals);
|
|
231
|
+
return createLink(key);
|
|
232
|
+
};
|
|
233
|
+
function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
|
|
234
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
235
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
236
|
+
rootKeySet.set(rootKey, {
|
|
237
|
+
namespace: keyPrefix,
|
|
238
|
+
representationName: RepresentationType,
|
|
239
|
+
mergeable: false
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function select(luvio, params) {
|
|
244
|
+
return select$1();
|
|
245
|
+
}
|
|
246
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
247
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
248
|
+
}
|
|
249
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
250
|
+
const { body } = response;
|
|
251
|
+
const key = keyBuilderFromType(luvio, body);
|
|
252
|
+
luvio.storeIngest(key, ingest, body);
|
|
253
|
+
const snapshot = luvio.storeLookup({
|
|
254
|
+
recordId: key,
|
|
255
|
+
node: select(),
|
|
256
|
+
variables: {},
|
|
257
|
+
});
|
|
258
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
259
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
260
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
deepFreeze(snapshot.data);
|
|
264
|
+
return snapshot;
|
|
265
|
+
}
|
|
266
|
+
function createResourceRequest(config) {
|
|
267
|
+
const headers = {};
|
|
268
|
+
return {
|
|
269
|
+
baseUri: '/services/data/v66.0',
|
|
270
|
+
basePath: '/connect/learning-platform/learning-item/' + config.urlParams.learningItemId + '/actions/evaluate',
|
|
271
|
+
method: 'post',
|
|
272
|
+
body: config.body,
|
|
273
|
+
urlParams: config.urlParams,
|
|
274
|
+
queryParams: {},
|
|
275
|
+
headers,
|
|
276
|
+
priority: 'normal',
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const adapterName = 'evaluateLearningItem';
|
|
281
|
+
const evaluateLearningItem_ConfigPropertyMetadata = [
|
|
282
|
+
generateParamConfigMetadata('learningItemId', true, 0 /* UrlParameter */, 0 /* String */),
|
|
283
|
+
generateParamConfigMetadata('details', false, 2 /* Body */, 4 /* Unsupported */),
|
|
284
|
+
];
|
|
285
|
+
const evaluateLearningItem_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, evaluateLearningItem_ConfigPropertyMetadata);
|
|
286
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$1(evaluateLearningItem_ConfigPropertyMetadata);
|
|
287
|
+
function typeCheckConfig(untrustedConfig) {
|
|
288
|
+
const config = {};
|
|
289
|
+
typeCheckConfig$1(untrustedConfig, config, evaluateLearningItem_ConfigPropertyMetadata);
|
|
290
|
+
const untrustedConfig_details = untrustedConfig.details;
|
|
291
|
+
if (untrustedIsObject(untrustedConfig_details)) {
|
|
292
|
+
const untrustedConfig_details_object = {};
|
|
293
|
+
const untrustedConfig_details_keys = Object.keys(untrustedConfig_details);
|
|
294
|
+
for (let i = 0, arrayLength = untrustedConfig_details_keys.length; i < arrayLength; i++) {
|
|
295
|
+
const key = untrustedConfig_details_keys[i];
|
|
296
|
+
const untrustedConfig_details_prop = untrustedConfig_details[key];
|
|
297
|
+
if (untrustedConfig_details_object !== undefined) {
|
|
298
|
+
untrustedConfig_details_object[key] = untrustedConfig_details_prop;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (untrustedConfig_details_object !== undefined && Object.keys(untrustedConfig_details_object).length >= 0) {
|
|
302
|
+
config.details = untrustedConfig_details_object;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return config;
|
|
306
|
+
}
|
|
307
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
308
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
312
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
313
|
+
}
|
|
314
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
315
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
return config;
|
|
319
|
+
}
|
|
320
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
321
|
+
const resourceParams = createResourceParams(config);
|
|
322
|
+
const request = createResourceRequest(resourceParams);
|
|
323
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
324
|
+
.then((response) => {
|
|
325
|
+
return luvio.handleSuccessResponse(() => {
|
|
326
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
327
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
328
|
+
}, () => {
|
|
329
|
+
const cache = new StoreKeyMap();
|
|
330
|
+
getResponseCacheKeys(cache, luvio, resourceParams, response.body);
|
|
331
|
+
return cache;
|
|
332
|
+
});
|
|
333
|
+
}, (response) => {
|
|
334
|
+
deepFreeze(response);
|
|
335
|
+
throw response;
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
const evaluateLearningItemAdapterFactory = (luvio) => {
|
|
339
|
+
return function evaluateLearningItem(untrustedConfig) {
|
|
340
|
+
const config = validateAdapterConfig(untrustedConfig, evaluateLearningItem_ConfigPropertyNames);
|
|
341
|
+
// Invalid or incomplete config
|
|
342
|
+
if (config === null) {
|
|
343
|
+
throw new Error('Invalid config for "evaluateLearningItem"');
|
|
344
|
+
}
|
|
345
|
+
return buildNetworkSnapshot(luvio, config);
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export { evaluateLearningItemAdapterFactory };
|
|
@@ -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 = "learning";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata, Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
|
|
2
|
+
import { Untrusted as adapter$45$utils_Untrusted, AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig } from './adapter-utils';
|
|
3
|
+
import { ResourceRequestConfig as resources_postConnectLearningPlatformLearningItemActionsEvaluateByLearningItemId_ResourceRequestConfig } from '../resources/postConnectLearningPlatformLearningItemActionsEvaluateByLearningItemId';
|
|
4
|
+
import { LearningItemProgressRepresentation as types_LearningItemProgressRepresentation_LearningItemProgressRepresentation } from '../types/LearningItemProgressRepresentation';
|
|
5
|
+
export declare const adapterName = "evaluateLearningItem";
|
|
6
|
+
export declare const evaluateLearningItem_ConfigPropertyMetadata: $64$luvio_engine_AdapterConfigMetadata[];
|
|
7
|
+
export declare const evaluateLearningItem_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
|
|
8
|
+
export interface EvaluateLearningItemConfig {
|
|
9
|
+
learningItemId: string;
|
|
10
|
+
details?: {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const createResourceParams: (config: EvaluateLearningItemConfig) => resources_postConnectLearningPlatformLearningItemActionsEvaluateByLearningItemId_ResourceRequestConfig;
|
|
15
|
+
export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<EvaluateLearningItemConfig>): adapter$45$utils_Untrusted<EvaluateLearningItemConfig>;
|
|
16
|
+
export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): EvaluateLearningItemConfig | null;
|
|
17
|
+
export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: EvaluateLearningItemConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_LearningItemProgressRepresentation_LearningItemProgressRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_LearningItemProgressRepresentation_LearningItemProgressRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_LearningItemProgressRepresentation_LearningItemProgressRepresentation, any>>;
|
|
18
|
+
export declare const evaluateLearningItemAdapterFactory: $64$luvio_engine_AdapterFactory<EvaluateLearningItemConfig, types_LearningItemProgressRepresentation_LearningItemProgressRepresentation>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { evaluateLearningItemAdapterFactory } from '../adapters/evaluateLearningItem';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, FetchResponse as $64$luvio_engine_FetchResponse, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
|
|
2
|
+
import { LearningItemProgressRepresentation as types_LearningItemProgressRepresentation_LearningItemProgressRepresentation } from '../types/LearningItemProgressRepresentation';
|
|
3
|
+
export interface ResourceRequestConfig {
|
|
4
|
+
urlParams: {
|
|
5
|
+
learningItemId: string;
|
|
6
|
+
};
|
|
7
|
+
body: {
|
|
8
|
+
details?: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
|
|
14
|
+
export declare function getResponseCacheKeys(storeKeyMap: any, luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_LearningItemProgressRepresentation_LearningItemProgressRepresentation): void;
|
|
15
|
+
export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_LearningItemProgressRepresentation_LearningItemProgressRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_LearningItemProgressRepresentation_LearningItemProgressRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_LearningItemProgressRepresentation_LearningItemProgressRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_LearningItemProgressRepresentation_LearningItemProgressRepresentation, any>;
|
|
16
|
+
export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
|
|
17
|
+
export default createResourceRequest;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
|
|
2
|
+
export declare const VERSION = "df8c2c7eb8ac96926f1c7eccd2ad5690";
|
|
3
|
+
export declare function validate(obj: any, path?: string): TypeError | null;
|
|
4
|
+
export declare const RepresentationType: string;
|
|
5
|
+
export declare function normalize(input: EvaluateLearningItemInputRepresentation, existing: EvaluateLearningItemInputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): EvaluateLearningItemInputRepresentationNormalized;
|
|
6
|
+
export declare const select: () => $64$luvio_engine_FragmentSelection;
|
|
7
|
+
export declare function equals(existing: EvaluateLearningItemInputRepresentationNormalized, incoming: EvaluateLearningItemInputRepresentationNormalized): boolean;
|
|
8
|
+
export declare const ingest: $64$luvio_engine_ResourceIngest;
|
|
9
|
+
export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: EvaluateLearningItemInputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
|
|
10
|
+
/**
|
|
11
|
+
* Represents the data that's sent for evaluating the learning item
|
|
12
|
+
*
|
|
13
|
+
* Keys:
|
|
14
|
+
* (none)
|
|
15
|
+
*/
|
|
16
|
+
export interface EvaluateLearningItemInputRepresentationNormalized {
|
|
17
|
+
/** The learning item data, in JSON format, that you want to evaluate. */
|
|
18
|
+
details?: {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents the data that's sent for evaluating the learning item
|
|
24
|
+
*
|
|
25
|
+
* Keys:
|
|
26
|
+
* (none)
|
|
27
|
+
*/
|
|
28
|
+
export interface EvaluateLearningItemInputRepresentation {
|
|
29
|
+
details?: {
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { KeyMetadata as $64$luvio_engine_KeyMetadata, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, Luvio as $64$luvio_engine_Luvio, IngestPath as $64$luvio_engine_IngestPath, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
|
|
2
|
+
export declare const TTL = 15000;
|
|
3
|
+
export declare const VERSION = "a951328be5199223955d423d805f587b";
|
|
4
|
+
export declare function validate(obj: any, path?: string): TypeError | null;
|
|
5
|
+
export declare const RepresentationType: string;
|
|
6
|
+
export interface KeyParams extends $64$luvio_engine_KeyMetadata {
|
|
7
|
+
learning_item_id: string;
|
|
8
|
+
}
|
|
9
|
+
export type LearningItemProgressRepresentationNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
|
|
10
|
+
export type PartialLearningItemProgressRepresentationNormalizedKeyMetadata = Partial<KeyParams> & $64$luvio_engine_NormalizedKeyMetadata;
|
|
11
|
+
export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: KeyParams): string;
|
|
12
|
+
export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: KeyParams): LearningItemProgressRepresentationNormalizedKeyMetadata;
|
|
13
|
+
export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: LearningItemProgressRepresentation): string;
|
|
14
|
+
export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: LearningItemProgressRepresentation): $64$luvio_engine_NormalizedKeyMetadata;
|
|
15
|
+
export declare function normalize(input: LearningItemProgressRepresentation, existing: LearningItemProgressRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): LearningItemProgressRepresentationNormalized;
|
|
16
|
+
export declare const select: () => $64$luvio_engine_FragmentSelection;
|
|
17
|
+
export declare function equals(existing: LearningItemProgressRepresentationNormalized, incoming: LearningItemProgressRepresentationNormalized): boolean;
|
|
18
|
+
export declare const ingest: $64$luvio_engine_ResourceIngest;
|
|
19
|
+
export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: LearningItemProgressRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
|
|
20
|
+
/**
|
|
21
|
+
* Represents the response that's returned after a learning item is evaluated successfully
|
|
22
|
+
*
|
|
23
|
+
* Keys:
|
|
24
|
+
* learning_item_id (string): learningItemId
|
|
25
|
+
*/
|
|
26
|
+
export interface LearningItemProgressRepresentationNormalized {
|
|
27
|
+
/** The date when the user completed the learning item */
|
|
28
|
+
completedDate: string | null;
|
|
29
|
+
/** Percentage of the learning item that's complete */
|
|
30
|
+
completedPercent: number | null;
|
|
31
|
+
/** The ID of the learning item progress */
|
|
32
|
+
id: string;
|
|
33
|
+
/** Whether the learning item is complete (true) or not (false). The default value is false */
|
|
34
|
+
isCompleted: boolean;
|
|
35
|
+
/** The ID of the learning item that was evaluated */
|
|
36
|
+
learningItemId: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Represents the response that's returned after a learning item is evaluated successfully
|
|
40
|
+
*
|
|
41
|
+
* Keys:
|
|
42
|
+
* learning_item_id (string): learningItemId
|
|
43
|
+
*/
|
|
44
|
+
export interface LearningItemProgressRepresentation {
|
|
45
|
+
completedDate: string | null;
|
|
46
|
+
completedPercent: number | null;
|
|
47
|
+
id: string;
|
|
48
|
+
isCompleted: boolean;
|
|
49
|
+
learningItemId: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
|
|
2
|
+
export declare const ObjectKeys: {
|
|
3
|
+
(o: object): string[];
|
|
4
|
+
(o: {}): string[];
|
|
5
|
+
}, ObjectCreate: {
|
|
6
|
+
(o: object | null): any;
|
|
7
|
+
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
8
|
+
}, ObjectAssign: {
|
|
9
|
+
<T extends {}, U>(target: T, source: U): T & U;
|
|
10
|
+
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
|
11
|
+
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
|
12
|
+
(target: object, ...sources: any[]): any;
|
|
13
|
+
};
|
|
14
|
+
export declare const ArrayIsArray: (arg: any) => arg is any[];
|
|
15
|
+
export declare const JSONStringify: {
|
|
16
|
+
(value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
|
|
17
|
+
(value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
|
|
18
|
+
};
|
|
19
|
+
type AllowedPrimitives = boolean | string | number | Date | null;
|
|
20
|
+
type Value<T> = T extends AllowedPrimitives ? T : RecursivePartial<T>;
|
|
21
|
+
export type RecursivePartial<T> = null | {
|
|
22
|
+
[P in keyof T]?: T[P] extends Array<infer U> ? Array<Value<U>> | null : Value<T[P]> | null;
|
|
23
|
+
};
|
|
24
|
+
export declare function equalsArray<U, V extends U[]>(a: V, b: V, equalsItem: (itemA: U, itemB: U) => boolean | void): boolean;
|
|
25
|
+
export declare function equalsObject<U, V extends {
|
|
26
|
+
[key: string]: U;
|
|
27
|
+
}>(a: V, b: V, equalsProp: (propA: U, propB: U) => boolean | void): boolean;
|
|
28
|
+
export declare function createLink(ref: string | $64$luvio_engine_NormalizedKeyMetadata): {
|
|
29
|
+
__ref: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function assignMetadataLink(entry: any, metadataKey: string | $64$luvio_engine_NormalizedKeyMetadata): void;
|
|
32
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/lds-adapters-platform-learning",
|
|
3
|
+
"version": "0.1.0-dev1",
|
|
4
|
+
"description": "Learning Platform Public API",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"main": "dist/es/es2018/platform-learning.js",
|
|
7
|
+
"module": "dist/es/es2018/platform-learning.js",
|
|
8
|
+
"types": "dist/es/es2018/types/src/generated/artifacts/main.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"sfdc",
|
|
12
|
+
"src/raml/*"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/es/es2018/types/src/generated/artifacts/main.d.ts",
|
|
17
|
+
"import": "./dist/es/es2018/platform-learning.js",
|
|
18
|
+
"require": "./dist/es/es2018/platform-learning.js"
|
|
19
|
+
},
|
|
20
|
+
"./sfdc": {
|
|
21
|
+
"types": "./sfdc/index.d.ts",
|
|
22
|
+
"import": "./sfdc/index.js",
|
|
23
|
+
"default": "./sfdc/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sfdc": {
|
|
27
|
+
"namespace": "lightning",
|
|
28
|
+
"module": "platformLearningApi"
|
|
29
|
+
},
|
|
30
|
+
"contributors": [
|
|
31
|
+
"n.chandarraj@salesforce.com"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "yarn build:services",
|
|
35
|
+
"build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
|
|
36
|
+
"build:services": "rollup --bundleConfigAsCjs --config rollup.config.js",
|
|
37
|
+
"clean": "rm -rf dist sfdc src/generated",
|
|
38
|
+
"release:core": "../../scripts/release/core.js --adapter=lds-adapters-platform-learning",
|
|
39
|
+
"release:corejar": "yarn build && ../core-build/scripts/core.js --adapter=lds-adapters-platform-learning",
|
|
40
|
+
"test:unit": "jest"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@salesforce/lds-bindings": "^0.1.0-dev1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@salesforce/lds-compiler-plugins": "^0.1.0-dev1"
|
|
47
|
+
},
|
|
48
|
+
"nx": {
|
|
49
|
+
"targets": {
|
|
50
|
+
"build": {
|
|
51
|
+
"outputs": [
|
|
52
|
+
"{projectRoot}/dist",
|
|
53
|
+
"{projectRoot}/sfdc"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"build:raml": {
|
|
57
|
+
"outputs": [
|
|
58
|
+
"{projectRoot}/src/generated"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"volta": {
|
|
64
|
+
"extends": "../../package.json"
|
|
65
|
+
}
|
|
66
|
+
}
|
package/sfdc/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/es/es2018/types/src/generated/artifacts/sfdc';
|
package/sfdc/index.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
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$1, typeCheckConfig as typeCheckConfig$1 } 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 = "a951328be5199223955d423d805f587b";
|
|
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_id;
|
|
163
|
+
}
|
|
164
|
+
function keyBuilderFromType(luvio, object) {
|
|
165
|
+
const keyParams = {
|
|
166
|
+
learning_item_id: object.learningItemId
|
|
167
|
+
};
|
|
168
|
+
return keyBuilder(luvio, keyParams);
|
|
169
|
+
}
|
|
170
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
171
|
+
return input;
|
|
172
|
+
}
|
|
173
|
+
const select$1 = 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(luvio, params) {
|
|
253
|
+
return select$1();
|
|
254
|
+
}
|
|
255
|
+
function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
|
|
256
|
+
getTypeCacheKeys(storeKeyMap, luvio, response);
|
|
257
|
+
}
|
|
258
|
+
function ingestSuccess(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(),
|
|
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(config) {
|
|
276
|
+
const headers = {};
|
|
277
|
+
return {
|
|
278
|
+
baseUri: '/services/data/v66.0',
|
|
279
|
+
basePath: '/connect/learning-platform/learning-item/' + 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 = '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, evaluateLearningItem_ConfigPropertyMetadata);
|
|
295
|
+
const createResourceParams = /*#__PURE__*/ createResourceParams$1(evaluateLearningItem_ConfigPropertyMetadata);
|
|
296
|
+
function typeCheckConfig(untrustedConfig) {
|
|
297
|
+
const config = {};
|
|
298
|
+
typeCheckConfig$1(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(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(untrustedConfig);
|
|
324
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
return config;
|
|
328
|
+
}
|
|
329
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
330
|
+
const resourceParams = createResourceParams(config);
|
|
331
|
+
const request = createResourceRequest(resourceParams);
|
|
332
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
333
|
+
.then((response) => {
|
|
334
|
+
return luvio.handleSuccessResponse(() => {
|
|
335
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
336
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
337
|
+
}, () => {
|
|
338
|
+
const cache = new StoreKeyMap();
|
|
339
|
+
getResponseCacheKeys(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(untrustedConfig, evaluateLearningItem_ConfigPropertyNames);
|
|
350
|
+
// Invalid or incomplete config
|
|
351
|
+
if (config === null) {
|
|
352
|
+
throw new Error('Invalid config for "evaluateLearningItem"');
|
|
353
|
+
}
|
|
354
|
+
return buildNetworkSnapshot(luvio, config);
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
let evaluateLearningItem;
|
|
359
|
+
// Notify Update Available
|
|
360
|
+
function bindExportsTo(luvio) {
|
|
361
|
+
// LDS Adapters
|
|
362
|
+
function unwrapSnapshotData(factory) {
|
|
363
|
+
const adapter = factory(luvio);
|
|
364
|
+
return (config) => adapter(config).then((snapshot) => snapshot.data);
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
evaluateLearningItem: unwrapSnapshotData(evaluateLearningItemAdapterFactory),
|
|
368
|
+
// Imperative GET Adapters
|
|
369
|
+
// Notify Update Availables
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
withDefaultLuvio((luvio) => {
|
|
373
|
+
({ evaluateLearningItem } = bindExportsTo(luvio));
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
export { evaluateLearningItem };
|
|
377
|
+
// version: 0.1.0-dev1-c978a7b010
|
|
@@ -0,0 +1,77 @@
|
|
|
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/v66.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 # TODO Hand-rolled W-8863405
|
|
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
|
+
/learning-platform/learning-item/{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
|
+
learningItemId:
|
|
76
|
+
type: string
|
|
77
|
+
required: true
|
|
@@ -0,0 +1,20 @@
|
|
|
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_id: learningItemId
|
|
15
|
+
|
|
16
|
+
/connect:
|
|
17
|
+
/learning-platform/learning-item/{learningItemId}/actions/evaluate:
|
|
18
|
+
post:
|
|
19
|
+
(luvio.adapter):
|
|
20
|
+
name: evaluateLearningItem
|