comprodls-sdk 2.89.0 → 2.90.0-qa

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 (41) hide show
  1. package/README.md +1 -137
  2. package/dist/comprodls-sdk.js +5937 -8432
  3. package/dist/comprodls-sdk.min.js +15 -1
  4. package/lib/comprodls.js +39 -57
  5. package/lib/config/index.js +171 -199
  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 +73 -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 +238 -896
  16. package/lib/services/authextn/index.js +50 -150
  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 +74 -85
  22. package/lib/services/pub/index.js +159 -234
  23. package/lib/services/pushX/index.js +29 -33
  24. package/lib/services/pushX/pubnubClientWrapper.js +398 -398
  25. package/lib/services/rules/index.js +14 -67
  26. package/lib/services/spaces/index.js +106 -294
  27. package/lib/services/spacesextn/index.js +4 -24
  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 +37 -98
  31. package/lib/services/xapi/index.js +6 -125
  32. package/lib/token/index.js +73 -67
  33. package/lib/token/validations.js +45 -48
  34. package/package.json +1 -2
  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
@@ -30,26 +30,22 @@ var helpers = require('../../helpers');
30
30
 
31
31
  var DLSError = helpers.errors.DLSError;
32
32
 
33
- /*********************************
34
- * Setting Up Module Entry Point
35
- **********************************/
36
33
  module.exports = superuser;
37
34
 
38
35
  //Superuser Adaptor Contsructor
39
36
  function superuser(accountId) {
40
- this.accountId = accountId;
41
- return {
42
- getAllInstitutions: getAllInstitutions.bind(this),
43
- getInstitution: getInstitution.bind(this),
44
- provisionSpacesToSuperAdmin: provisionSpacesToSuperAdmin.bind(this)
45
- };
46
- }
47
-
48
- /*options = {
49
- "lookup": "string",
50
- "limit": "integer",
51
- "cursor": "object"
52
- }*/
37
+ this.accountId = accountId;
38
+ return {
39
+ getAllInstitutions: getAllInstitutions.bind(this),
40
+ getInstitution: getInstitution.bind(this),
41
+ provisionSpacesToSuperAdmin: provisionSpacesToSuperAdmin.bind(this)
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Wiki Link for SDK params
47
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/19_Superuser-Adapter#getallinstitutionsparams
48
+ */
53
49
  function getAllInstitutions(options) {
54
50
  var self = this;
55
51
  // Initializing promise
@@ -81,15 +77,16 @@ function getAllInstitutions(options) {
81
77
 
82
78
  return dfd.promise;
83
79
  }
84
-
85
- /** This function gets a particular Instituion using the unique identifier (space_code)
86
- * options = { "spacecode" : "string" }
87
- */
80
+
81
+ /**
82
+ * Wiki Link for SDK params
83
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/19_Superuser-Adapter#getinstitutionparams
84
+ */
88
85
  function getInstitution(options) {
89
86
  var self = this;
90
87
  // Initializing promise
91
88
  var dfd = q.defer();
92
-
89
+
93
90
  // Validations
94
91
  if(options && options.spacecode) {
95
92
  // Passed all validations, Contruct API url
@@ -109,7 +106,7 @@ function getInstitution(options) {
109
106
  }
110
107
  else { dfd.resolve(response.body); }
111
108
  });
112
- }
109
+ }
113
110
  else {
114
111
  var err = {};
115
112
  err.message = err.description = 'spacecode not found in request options.';
@@ -120,20 +117,8 @@ function getInstitution(options) {
120
117
  }
121
118
 
122
119
  /**
123
- * This will provision space to the super admin in shared/institutional org.
124
- * Note: The super admin can only be provisioned in one (shared/institutional) org at a time.
125
- *
126
- * @param {Object} options {
127
- "ext_user_id": "string",
128
- "ext_role": "string",
129
- "ext_email": "string",
130
- "ext_first_name": "string",
131
- "ext_last_name": "string",
132
- "address": { "country": "string" } // optional
133
- "space_code": "string", // optional, to provision the superadmin in institutional space.
134
- "private_space": boolean // optional, to provision the superadmin in shared space.
135
- }
136
- * @return {Promise} Promise.resolve({ entities:[ { spaces object }], count: entities.length })
120
+ * Wiki Link for SDK params
121
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/19_Superuser-Adapter#provisionspacestosuperadminparams
137
122
  */
138
123
  function provisionSpacesToSuperAdmin(options) {
139
124
  var self = this;
@@ -29,10 +29,8 @@ var helpers = require('../../helpers');
29
29
 
30
30
  var DLSError = helpers.errors.DLSError;
31
31
 
32
- /*********************************
33
- * Setting Up Module Entry Point
34
- **********************************/
35
32
  module.exports = taxonomy;
33
+
36
34
  //Taxonomy Adaptor Contsructor
37
35
  function taxonomy() {
38
36
  return {
@@ -51,10 +49,8 @@ function taxonomy() {
51
49
  **********************************/
52
50
 
53
51
  /**
54
- * options = {
55
- * entity_type: 'type of entity',
56
- * entity_id: 'id of the entity',
57
- * tags: 'array of tags for association with entity'
52
+ * Wiki Link for SDK params
53
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/25_TAXONOMY-Adaptor#associatetagswithentityparams
58
54
  */
59
55
  function associateTagsWithEntity(options) {
60
56
  var self = this;
@@ -102,20 +98,10 @@ function associateTagsWithEntity(options) {
102
98
  return dfd.promise;
103
99
  }
104
100
 
105
-
106
- /*
107
- options = {
108
- context: "string", //mandatory
109
- taxonomyid: "string", //mandatory
110
- body: {
111
- tags: [{
112
- "tagid": "",
113
- "tagname": "",
114
- "tag_data": {} // optional
115
- }]
116
- }
117
- }
118
- */
101
+ /**
102
+ * Wiki Link for SDK params
103
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/25_TAXONOMY-Adaptor#createtagsparams
104
+ */
119
105
  function createTags(options) {
120
106
  var self = this;
121
107
  // Initializing promise
@@ -158,16 +144,10 @@ function createTags(options) {
158
144
  return dfd.promise;
159
145
  }
160
146
 
161
- /* options = {
162
- "context": "string", //mandatory
163
- "taxonomyid": "string" //mandatory
164
- "body": {
165
- "tagid": "string", //mandatory
166
- "tagname": "string",
167
- "tag_data": {}
168
- }
169
- };
170
- */
147
+ /**
148
+ * Wiki Link for SDK params
149
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/25_TAXONOMY-Adaptor#updatetagsparams
150
+ */
171
151
  function updateTags(options) {
172
152
  var self = this;
173
153
  // Initializing promise
@@ -214,12 +194,10 @@ function updateTags(options) {
214
194
  return dfd.promise;
215
195
  }
216
196
 
217
- /* options = {
218
- "context": "string", // required
219
- "taxonomyid" : "string", // required
220
- "tagid" : "string"
221
- };
222
- */
197
+ /**
198
+ * Wiki Link for SDK params
199
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/25_TAXONOMY-Adaptor#deletetagsparams
200
+ */
223
201
  function deleteTags(options) {
224
202
  var self = this;
225
203
  // Initializing promise
@@ -268,13 +246,10 @@ function deleteTags(options) {
268
246
  return dfd.promise;
269
247
  }
270
248
 
271
- /*
272
- options = {
273
- context: "string", //mandatory
274
- taxonomyid: "string", //mandatory
275
- tagid: "string" //mandatory
276
- }
277
- */
249
+ /**
250
+ * Wiki Link for SDK params
251
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/25_TAXONOMY-Adaptor#gettagparams
252
+ */
278
253
  function getTag(options) {
279
254
  var self = this;
280
255
  // Initializing promise
@@ -324,13 +299,10 @@ function getTag(options) {
324
299
  return dfd.promise;
325
300
  }
326
301
 
327
- /*
328
- options = {
329
- context: "string", //mandatory
330
- taxonomyid: "string", //mandatory
331
- tagid: "string" //mandatory
332
- }
333
- */
302
+ /**
303
+ * Wiki Link for SDK params
304
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/25_TAXONOMY-Adaptor#gettaghierarchyparams
305
+ */
334
306
  function getTagHierarchy(options) {
335
307
  var self = this;
336
308
  // Initializing promise
@@ -380,12 +352,10 @@ function getTagHierarchy(options) {
380
352
  return dfd.promise;
381
353
  }
382
354
 
383
- /*
384
- options = {
385
- context: "string", //mandatory
386
- taxonomyid: "string" //mandatory
387
- }
388
- */
355
+ /**
356
+ * Wiki Link for SDK params
357
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/25_TAXONOMY-Adaptor#getalltagsparams
358
+ */
389
359
  function getAllTags(options) {
390
360
  var self = this;
391
361
  // Initializing promise
@@ -26,10 +26,6 @@ var request = require('superagent');
26
26
  var helpers = require('./../../helpers');
27
27
  var DLSError = helpers.errors.DLSError;
28
28
 
29
- /*************************************
30
- * Setting up Exports/Public functions
31
- *************************************/
32
-
33
29
  module.exports = workflows;
34
30
 
35
31
  //Workflows Adaptor Constructor
@@ -45,31 +41,16 @@ function workflows(accountId) {
45
41
  revokeAWorkflow: revokeAWorkflow.bind(this),
46
42
  completeAWorkflow: completeAWorkflow.bind(this),
47
43
  updateWorkflowRequest: updateWorkflowRequest.bind(this)
48
- }
44
+ };
49
45
  }
50
46
 
51
47
  /*********************************
52
48
  * Public Function definitions
53
49
  **********************************/
50
+
54
51
  /**
55
- * options={
56
- "ext_user_id": "string", //mandatory
57
- "workflow_type": "institution_request", //mandatory
58
- "institution_request": {
59
- "address": {
60
- "city": "string",
61
- "country": "string",
62
- "line1": "string",
63
- "street1": "string",
64
- "street2": "string",
65
- "street3": "string",
66
- "house_no": "string",
67
- "post_code": "string"
68
- },
69
- "display_name": "string",
70
- "school_key": "string"
71
- }
72
- }
52
+ * Wiki Link for SDK params
53
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#createworkflowparams
73
54
  */
74
55
  function createWorkflow(options) {
75
56
  var self = this;
@@ -89,7 +70,7 @@ function createWorkflow(options) {
89
70
  var requestAPI = request.post(url)
90
71
  .set('Content-Type', 'application/json')
91
72
  .set('Accept', 'application/json')
92
- .send(options)
73
+ .send(options);
93
74
 
94
75
  if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
95
76
 
@@ -109,14 +90,10 @@ function createWorkflow(options) {
109
90
  return dfd.promise;
110
91
  }
111
92
 
112
- /* options = {
113
- "workflow_type": "string", // required
114
- "status" : "string", // required
115
- "start": "string" //epoch
116
- "end": "string" //epoch
117
- "cursor" : "string"
118
- };
119
- */
93
+ /**
94
+ * Wiki Link for SDK params
95
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#getallworkflowparams
96
+ */
120
97
  function getAllWorkflow(options) {
121
98
  var self = this;
122
99
  // Initializing promise
@@ -154,15 +131,10 @@ function getAllWorkflow(options) {
154
131
  return dfd.promise;
155
132
  }
156
133
 
157
- /* options = {
158
- "workflow_type": "string", // required
159
- "status" : "string", // required
160
- "ext_user_id": "string" //required
161
- "start": "string" //epoch
162
- "end": "string" //epoch
163
- "cursor" : "string"
164
- };
165
- */
134
+ /**
135
+ * Wiki Link for SDK params
136
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#getallworkflowofauserparams
137
+ */
166
138
  function getAllWorkflowOfAUser(options) {
167
139
  var self = this;
168
140
  // Initializing promise
@@ -200,11 +172,10 @@ function getAllWorkflowOfAUser(options) {
200
172
  return dfd.promise;
201
173
  }
202
174
 
203
- /* options = {
204
- "workflowid": "string", // required
205
- "context_id" : "string", // required
206
- };
207
- */
175
+ /**
176
+ * Wiki Link for SDK params
177
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#getaworkflowparams
178
+ */
208
179
  function getAWorkflow(options) {
209
180
  var self = this;
210
181
  // Initializing promise
@@ -240,13 +211,10 @@ function getAWorkflow(options) {
240
211
  return dfd.promise;
241
212
  }
242
213
 
243
- /* options = {
244
- "workflowid": "string", // required
245
- "body" : { // required
246
- "context_id": "string" // required
247
- }
248
- };
249
- */
214
+ /**
215
+ * Wiki Link for SDK params
216
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#acceptaworkflowparams
217
+ */
250
218
  function acceptAWorkflow(options) {
251
219
  var self = this;
252
220
  // Initializing promise
@@ -279,14 +247,10 @@ function acceptAWorkflow(options) {
279
247
  return dfd.promise;
280
248
  }
281
249
 
282
- /* options = {
283
- "workflowid": "string", // required
284
- "body" : { // required
285
- "context_id": "string", // required
286
- "org_id": "string", // required
287
- }
288
- };
289
- */
250
+ /**
251
+ * Wiki Link for SDK params
252
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#processaworkflowparams
253
+ */
290
254
  function processAWorkflow(options) {
291
255
  var self = this;
292
256
  // Initializing promise
@@ -313,7 +277,7 @@ function processAWorkflow(options) {
313
277
  }
314
278
  else {
315
279
  err = {};
316
- err.message = err.description = 'Mandatory params - workflowid, body, body.context_id, body.org_id' +
280
+ err.message = err.description = 'Mandatory params - workflowid, body, body.context_id, body.org_id' +
317
281
  ' in request options.';
318
282
  err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
319
283
  dfd.reject(err);
@@ -321,13 +285,10 @@ function processAWorkflow(options) {
321
285
  return dfd.promise;
322
286
  }
323
287
 
324
- /* options = {
325
- "workflowid": "string", // required
326
- "body" : { // required
327
- "context_id": "string" // required
328
- }
329
- };
330
- */
288
+ /**
289
+ * Wiki Link for SDK params
290
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#revokeaworkflowparams
291
+ */
331
292
  function revokeAWorkflow(options) {
332
293
  var self = this;
333
294
  // Initializing promise
@@ -363,13 +324,10 @@ function revokeAWorkflow(options) {
363
324
  return dfd.promise;
364
325
  }
365
326
 
366
- /* options = {
367
- "workflowid": "string", // required
368
- "body" : { // required
369
- "context_id": "string" // required
370
- }
371
- };
372
- */
327
+ /**
328
+ * Wiki Link for SDK params
329
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#completeaworkflowparams
330
+ */
373
331
  function completeAWorkflow(options) {
374
332
  var self = this;
375
333
  // Initializing promise
@@ -406,27 +364,8 @@ function completeAWorkflow(options) {
406
364
  }
407
365
 
408
366
  /**
409
- * options={
410
- * "context_id": "string", //mandatory
411
- * "body": {
412
- "ext_user_id": "string", //mandatory
413
- "workflow_type": "institution_request", //mandatory
414
- "institution_request": {
415
- "address": {
416
- "city": "string",
417
- "country": "string",
418
- "line1": "string",
419
- "street1": "string",
420
- "street2": "string",
421
- "street3": "string",
422
- "house_no": "string",
423
- "post_code": "string"
424
- },
425
- "display_name": "string",
426
- "school_key": "string"
427
- }
428
- }
429
- }
367
+ * Wiki Link for SDK params
368
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#updateworkflowrequestparams
430
369
  */
431
370
  function updateWorkflowRequest(options) {
432
371
  var self = this;
@@ -447,7 +386,7 @@ function updateWorkflowRequest(options) {
447
386
  var requestAPI = request.put(url)
448
387
  .set('Content-Type', 'application/json')
449
388
  .set('Accept', 'application/json').query(queryParams)
450
- .send(options.body)
389
+ .send(options.body);
451
390
 
452
391
  if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
453
392
  requestAPI.end(function(error, response) {
@@ -23,10 +23,6 @@
23
23
  * Functions for calling xAPI.
24
24
  ************************************************************/
25
25
 
26
- /*********************************
27
- * Setting Up Module Entry Point
28
- **********************************/
29
-
30
26
  var q = require('q');
31
27
  var request = require('superagent');
32
28
 
@@ -46,69 +42,9 @@ function xapi(accountId) {
46
42
  };
47
43
  }
48
44
 
49
- /*
50
- options = {
51
- actor: {
52
- uuid: 'string', // userid of user posting statement / 'me'
53
- group: 'string' // (optional)
54
- },
55
- product: { // optional
56
- code: 'string',
57
- title: 'string' // (optional)
58
- ext-item: boolean // (optional, all items in entities will be treated as external items, hence no progress JSON update for them)
59
- },
60
- classid: 'string', // (optional) Specify if posting via class,
61
- space_key: 'string'// (optional)
62
-
63
- entities: [{
64
- assigned_path_id: 'string' //optional, assigned-path of a class
65
- timestamp: 0,
66
- verb: 'string', // [redo | evaluated | launched | interacted | completed | answered | attempted | scored | submitted']
67
- //('redo' verb can only be sent by teacher, admin and superadmin )
68
- model: 'string', // (optional) model hierarchy of resource if available
69
- item-code: 'string', // item-code of resource(optional)
70
- user_data: {
71
- documentid: 'string',
72
- folderid: 'string',
73
- action: 'create/update/delete',
74
- type: 'string',
75
- payload: 'string'
76
- },
77
- timespent: 0, // (optional)
78
- activity_status: 'string', // (optional) ['in_process', 'timed_out', 'completed']
79
- result: { // (optional)
80
- response: {
81
- audioPath: 'string',
82
- text: 'string',
83
- link: [
84
- {
85
- url: 'string',
86
- title: 'string',
87
- description: 'string'
88
- }
89
- ],
90
- attribs: {}
91
- },
92
- score: { // optional
93
- min: 0,
94
- scaled: 0,
95
- max: 0,
96
- raw: 0
97
- },
98
- comment: 'string', // optional
99
- questions: [{ // optional
100
- question-code: 'string',
101
- status-progress: 'string', // [not_attempted | in_progress]
102
- status-evaluation: 'string' // [not_applicable | partially_correct | correct | incorrect]
103
- }]
104
- },
105
- link-statementid: 'string' // required in case of verb = evaluated
106
- }],
107
- platform: {
108
- ua: 'string',
109
- sessionid: 'string'
110
- }
111
- };
45
+ /**
46
+ * Wiki Link for SDK params
47
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/08_XAPI-Adapter#poststatementsparams
112
48
  */
113
49
  function postStatements(options) {
114
50
  var self = this;
@@ -148,64 +84,9 @@ function postStatements(options) {
148
84
  return dfd.promise;
149
85
  }
150
86
 
151
- /*
152
- options = {
153
- actor: {
154
- ext_user_id: 'string', // (optional) who triggered the action - EXTERNAL_SYSTEM in case of verb = evaluated_external
155
- uuid: 'string' // who triggered the action - EXTERNAL_SYSTEM in case of verb = evaluated_external
156
- },
157
- product: {
158
- code: 'string',
159
- title: 'string' // (optional)
160
- ext-item: boolean // (optional, all items in entities will be treated as external items, hence no progress JSON update for them)
161
- },
162
- student_userid: "string", // (optional when verb = submitted_external) ON whom is the action taking place
163
- student_ext_user_id: "string", // (optional when verb = submitted_external) ON whom is the action taking place
164
- classid: 'string', // (optional) Specify if posting via class
165
- space_key: 'string', // (optional)
166
- platform: {
167
- ua: "string"
168
- },
169
- group: { // (optional)
170
- id: "string"
171
- }
172
- entities: [{
173
- assigned_path_id: 'string' //(optional) assigned-path of a class
174
- timestamp: 0,
175
- verb: 'string', // [evaluated_external, submitted_external]
176
- model: 'string', // (optional) model hierarchy of resource if available
177
- item-code: 'string', // item-code of resource
178
- timespent: 0, // (optional)
179
- part: integer, // (mandatory only for verb = evaluated_external)
180
- submission_order: integer, // [1, 2, 3]
181
- result: { // (optional)
182
- "response": {
183
- "text": "string",
184
- "audioPath": "string",
185
- "link": [
186
- {
187
- "url": "string",
188
- "title": "string",
189
- "description": "string"
190
- }
191
- ]
192
- },
193
- "score": {
194
- "min": 0,
195
- "scaled": 0,
196
- "max": 0,
197
- "raw": 0
198
- },
199
- "comment": "string", // (optional)
200
- "ext_data": "string", // (optional)
201
- questions: [{ // (optional)
202
- question-code: 'string',
203
- status-progress: 'string', // [not_attempted | in_progress]
204
- status-evaluation: 'string' // [not_applicable | partially_correct | correct | incorrect]
205
- }]
206
- }
207
- }]
208
- }
87
+ /**
88
+ * Wiki Link for SDK params
89
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/08_XAPI-Adapter#postexternalstatementsparams
209
90
  */
210
91
  function postExternalStatements(options) {
211
92
  var self = this;