comprodls-sdk 2.90.3-development → 2.91.0-thor

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +1 -137
  2. package/dist/comprodls-sdk.js +2917 -6291
  3. package/dist/comprodls-sdk.min.js +1 -1
  4. package/lib/comprodls.js +39 -57
  5. package/lib/config/index.js +172 -198
  6. package/lib/helpers/index.js +3 -2
  7. package/lib/helpers/lib/api/converter.js +1 -2
  8. package/lib/helpers/lib/api/index.js +19 -94
  9. package/lib/helpers/lib/errors.js +75 -80
  10. package/lib/helpers/lib/requestLayer.js +154 -0
  11. package/lib/helpers/lib/validator.js +65 -52
  12. package/lib/open_access/index.js +48 -53
  13. package/lib/services/analytics/index.js +286 -1014
  14. package/lib/services/attempts/index.js +38 -88
  15. package/lib/services/auth/index.js +324 -806
  16. package/lib/services/authextn/index.js +85 -247
  17. package/lib/services/datasyncmanager/index.js +10 -45
  18. package/lib/services/drive/index.js +20 -83
  19. package/lib/services/integrations/index.js +51 -126
  20. package/lib/services/invitations/index.js +20 -61
  21. package/lib/services/product/index.js +82 -85
  22. package/lib/services/pub/index.js +167 -235
  23. package/lib/services/pushX/index.js +195 -142
  24. package/lib/services/pushX/pubnubClientWrapper.js +399 -172
  25. package/lib/services/rules/index.js +14 -67
  26. package/lib/services/spaces/index.js +106 -289
  27. package/lib/services/spacesextn/index.js +44 -20
  28. package/lib/services/superuser/index.js +21 -36
  29. package/lib/services/taxonomy/index.js +27 -57
  30. package/lib/services/workflows/index.js +38 -97
  31. package/lib/services/xapi/index.js +7 -168
  32. package/lib/token/index.js +73 -67
  33. package/lib/token/validations.js +45 -48
  34. package/package.json +2 -3
  35. package/lib/helpers/lib/api/validations.js +0 -73
  36. package/lib/helpers/lib/utils.js +0 -24
  37. package/lib/services/activity/activity.js +0 -209
  38. package/lib/services/activity/attempt.js +0 -431
  39. package/lib/services/activity/index.js +0 -28
  40. package/lib/services/auth/classProduct.js +0 -37
  41. package/lib/services/collab/index.js +0 -468
  42. package/test.js +0 -38
package/README.md CHANGED
@@ -38,9 +38,7 @@ The SDK supports following APIs:
38
38
  <tbody>
39
39
  <tr><td>Auth API</td><td>http://auth.comprodls.com</td><td>1.0.0</td></tr>
40
40
  <tr><td>Product API</td><td>http://product.comprodls.com</td><td>1.0.0</td></tr>
41
- <tr><td>Collab API</td><td>http://collab.comprodls.com</td><td>1.0.0</td></tr>
42
41
  <tr><td>Analytics API</td><td>http://analytics.comprodls.com</td><td>1.0.0</td></tr>
43
- <tr><td>Activity / Test API</td><td>http://activity.comprodls.com</td><td>1.0.0</td></tr>
44
42
  <tr><td>xAPI</td><td>http://xapi.comprodls.com</td><td>1.0.0</td></tr>
45
43
  <tr><td>Push Notifications</td><td>---</td><td>1.0.0</td></tr>
46
44
  <tr><td>Pub</td><td>http://pub.comprodls.com</td><td>1.0.0</td></tr>
@@ -87,44 +85,9 @@ var comproDLS = require('comprodls-sdk').init();
87
85
  ### Authentication & Tokens
88
86
  Authentication (acquiring a valid token) is the first thing you need to do before using any function of comproDLS SDK. Following are the ways to authenticate:
89
87
 
90
- #### authWithCredentials
91
- You need valid comproDLS user credentials (organisationid, username and password) to use this method. Following is sample code to authenticate using credentials:
92
- ```javascript
93
- comproDLS.authWithCredentials("myorg", {username:"myusername", password:"mypassword"}, {}).then(
94
- function success(response) {
95
- //You may persist token object in session/localstorage etc. for later usage.
96
- var token = response["token"];
97
- console.log(token.expires_in);
98
-
99
- //user object contains user information
100
- var user = response["user"];
101
- console.log(user.name);
102
- console.log(user.roles);
103
-
104
- //org object contains organisation information
105
- var org = response["user"]["org"];
106
- console.log(org["type"]);
107
- },
108
- function error(err) {
109
- var type = err["type"];
110
- if (type == "API_ERROR") {
111
- if (err["httpcode"] == 401) {
112
- //Invalid Credentials
113
- console.log(err.message);
114
- }
115
- } else if (type == "SDK_ERROR") {
116
- console.log(err.message);
117
- }
118
- }
119
- );
120
- ```
121
- After successfully calling this function, the comproDLS SDK object will have a valid authentication token which will be used across all subsequent calls. All other SDK functions do not require the token or credentials (to be supplied as parameters). Furthermore, in case the token expires, SDK will automatically refresh it using the original credentials.
122
-
123
- See [authWithCredentials Documentation](https://github.com/comprodls/comprodls-sdk-js/wiki/02_Authentication-and-Tokens#authwithcredentials) for detailed information on method parameters, success and error response JSONs.
124
-
125
88
  #### authWithToken
126
89
 
127
- If you already have a persisted / saved comproDLS token (obtained via authWithCredentials method), you can use this method for a simple pass-through authentication (avoid generating a fresh token). Following is sample code:
90
+ If you already have a persisted / saved comproDLS token, you can use this method for a simple pass-through authentication (avoid generating a fresh token). Following is sample code:
128
91
  ```javascript
129
92
  /*
130
93
  * saved_token is token object obtained previously via authWithCredentials method
@@ -212,105 +175,6 @@ auth.getUserProfile().then(
212
175
  }
213
176
  }
214
177
  );
215
- ```
216
- #### ACTIVITY
217
- comproDLS Activity API provides functions to track assignment/test/activities and related data for scores, attempts, etc.
218
- **Note** You should have authenticated with comproDLS (authWithToken or authWithCredentials) before using these functions.
219
-
220
- Following is an example of using ACTIVITY API SDK adaptor to get information of the activity. In this function, the SDK adaptor abstracts the knowledge of underlying REST URLs & Parameters, and offers a simpler interface. For a list of all SDK ACTIVITY functions, see [ACTIVITY Adaptor Documentation](https://github.com/comprodls/comprodls-sdk-js/wiki/09_ACTIVITY-Adaptor).
221
-
222
- ```javascript
223
- var activity = comproDLS.Activity(productId, activityId, classId);
224
-
225
- /* Get all the attempts of an activity for a user */
226
- activity.getDetails().then(
227
- function success(response) {
228
-
229
- var activity = response.activity;
230
- /*--Activity {
231
- activityid (string),
232
- timestaken (integer),
233
- timespent (integer),
234
- timeallowed (integer),
235
- savedstate (string),
236
- attempts (Array[Attempt], optional)
237
- }-- */
238
- },
239
- function error(err) {
240
- /* --- Error --- */
241
- }
242
- );
243
-
244
- /* Start the attempt and store the attempt id */
245
- activity.newAttempt(startParameters).then(
246
- function success(response) {
247
- var attempt = response["attempt"];
248
-
249
- },
250
- function error(err) {
251
- /* --- Error --- */
252
- }
253
- );
254
-
255
- /* Load In-process Attempt */
256
- var attempt = activity.getAttempt(attemptId).then(
257
- function success(response) {
258
- var attempt = response["attempt"];
259
-
260
- },
261
- function error(err) {
262
- /* --- Error --- */
263
- }
264
- );
265
-
266
- // Save attempt state
267
- attempt.saveState(savedstate).then(
268
- function success(response) {
269
- var status = response.status;
270
- },
271
- function error(err) {
272
- /* --- Error --- */
273
- }
274
- );
275
-
276
- // Retrieve attempt state
277
- attempt.getState().then(
278
- function success(response) {
279
- var state = response.state;
280
- },
281
- function error(err) {
282
- /* --- Error --- */
283
- }
284
- );
285
-
286
- // Submit
287
-
288
- activity.submit(userresponse).then(
289
- function success(response) {
290
- var status = response.status;
291
- },
292
- function error(err) {
293
- /* --- Error --- */
294
- }
295
- );
296
-
297
-
298
- <!--// Get scores
299
- activity.getAttemptScore().then(
300
- function success(response) {
301
-
302
- //get /{orgid}/{productid}/activity/{activityid}
303
- //loop and return score for attempt.id
304
- console.log("Success " + attempt.id);
305
- },
306
- function error(err) {
307
- /* --- Error --- */
308
- }
309
- );-->
310
-
311
-
312
- )
313
-
314
178
  ```
315
179
 
316
180
  #### PUSH