comprodls-sdk 2.90.3-development → 2.92.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 +2834 -6201
  3. package/dist/comprodls-sdk.min.js +1 -1
  4. package/lib/comprodls.js +39 -57
  5. package/lib/config/index.js +173 -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 +141 -318
  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
@@ -30,9 +30,6 @@ var Agent = require('agentkeepalive');
30
30
  var helpers = require('../../helpers');
31
31
  var DLSError = helpers.errors.DLSError;
32
32
 
33
- /*********************************
34
- * Setting Up Module Entry Point
35
- **********************************/
36
33
  module.exports = spacesextn;
37
34
 
38
35
  var keepaliveAgent = new Agent({
@@ -44,27 +41,14 @@ var keepaliveAgent = new Agent({
44
41
  function spacesextn(accountId) {
45
42
  this.accountId = accountId;
46
43
  return {
47
- entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
44
+ entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this),
45
+ setupUser: setupUser.bind(this)
48
46
  };
49
47
  }
50
48
 
51
49
  /**
52
- * @param {
53
- * *users: [{
54
- * *ext_user_id: 'string',
55
- * ext_role: 'string',
56
- * *products: [{
57
- * *productcode: 'string',
58
- * ext_entitlement_meta: {
59
- * start_date: <epoch>,
60
- * *end_date: <epoch>
61
- * },
62
- * ext_data : {},
63
- * *action: 'string'
64
- * }]
65
- * }],
66
- * *ext_actor_id: 'string'
67
- * } options
50
+ * Wiki Link for SDK params
51
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/22_Integrations-Adapter#entitlebulkuserstoproductsparams
68
52
  */
69
53
  function entitleBulkUsersToProducts(options) {
70
54
  var self = this;
@@ -105,3 +89,43 @@ function entitleBulkUsersToProducts(options) {
105
89
  return dfd.promise;
106
90
  }
107
91
 
92
+ /**
93
+ * Wiki Link for SDK params
94
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/22_Integrations-Adapter#setupuserparams
95
+ */
96
+ function setupUser(options) {
97
+ var self = this;
98
+ //Initializing promise
99
+ var deferred = q.defer();
100
+
101
+ if (options && options.ext_user_id && options.workflow_type) {
102
+ //Passed all validations, Contruct API url
103
+ var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
104
+ url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
105
+
106
+ var requestAPI = request.post(url)
107
+ .set('Content-Type', 'application/json')
108
+ .set('Accept', 'application/json')
109
+ .send(options);
110
+
111
+ if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
112
+
113
+ requestAPI
114
+ .agent(keepaliveAgent)
115
+ .end(function(err, res) {
116
+ if (err) {
117
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
118
+ deferred.reject(err);
119
+ } else {
120
+ deferred.resolve(res.body);
121
+ }
122
+ });
123
+ } else {
124
+ var err = {};
125
+ err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
126
+ 'in the request options.';
127
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
128
+ deferred.reject(err);
129
+ }
130
+ return deferred.promise;
131
+ }
@@ -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,30 +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
- "street1": "string",
63
- "street2": "string",
64
- "street3": "string",
65
- "house_no": "string",
66
- "post_code": "string"
67
- },
68
- "display_name": "string",
69
- "school_key": "string"
70
- }
71
- }
52
+ * Wiki Link for SDK params
53
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#createworkflowparams
72
54
  */
73
55
  function createWorkflow(options) {
74
56
  var self = this;
@@ -88,7 +70,7 @@ function createWorkflow(options) {
88
70
  var requestAPI = request.post(url)
89
71
  .set('Content-Type', 'application/json')
90
72
  .set('Accept', 'application/json')
91
- .send(options)
73
+ .send(options);
92
74
 
93
75
  if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
94
76
 
@@ -108,14 +90,10 @@ function createWorkflow(options) {
108
90
  return dfd.promise;
109
91
  }
110
92
 
111
- /* options = {
112
- "workflow_type": "string", // required
113
- "status" : "string", // required
114
- "start": "string" //epoch
115
- "end": "string" //epoch
116
- "cursor" : "string"
117
- };
118
- */
93
+ /**
94
+ * Wiki Link for SDK params
95
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#getallworkflowparams
96
+ */
119
97
  function getAllWorkflow(options) {
120
98
  var self = this;
121
99
  // Initializing promise
@@ -153,15 +131,10 @@ function getAllWorkflow(options) {
153
131
  return dfd.promise;
154
132
  }
155
133
 
156
- /* options = {
157
- "workflow_type": "string", // required
158
- "status" : "string", // required
159
- "ext_user_id": "string" //required
160
- "start": "string" //epoch
161
- "end": "string" //epoch
162
- "cursor" : "string"
163
- };
164
- */
134
+ /**
135
+ * Wiki Link for SDK params
136
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#getallworkflowofauserparams
137
+ */
165
138
  function getAllWorkflowOfAUser(options) {
166
139
  var self = this;
167
140
  // Initializing promise
@@ -199,11 +172,10 @@ function getAllWorkflowOfAUser(options) {
199
172
  return dfd.promise;
200
173
  }
201
174
 
202
- /* options = {
203
- "workflowid": "string", // required
204
- "context_id" : "string", // required
205
- };
206
- */
175
+ /**
176
+ * Wiki Link for SDK params
177
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#getaworkflowparams
178
+ */
207
179
  function getAWorkflow(options) {
208
180
  var self = this;
209
181
  // Initializing promise
@@ -239,13 +211,10 @@ function getAWorkflow(options) {
239
211
  return dfd.promise;
240
212
  }
241
213
 
242
- /* options = {
243
- "workflowid": "string", // required
244
- "body" : { // required
245
- "context_id": "string" // required
246
- }
247
- };
248
- */
214
+ /**
215
+ * Wiki Link for SDK params
216
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#acceptaworkflowparams
217
+ */
249
218
  function acceptAWorkflow(options) {
250
219
  var self = this;
251
220
  // Initializing promise
@@ -278,14 +247,10 @@ function acceptAWorkflow(options) {
278
247
  return dfd.promise;
279
248
  }
280
249
 
281
- /* options = {
282
- "workflowid": "string", // required
283
- "body" : { // required
284
- "context_id": "string", // required
285
- "org_id": "string", // required
286
- }
287
- };
288
- */
250
+ /**
251
+ * Wiki Link for SDK params
252
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#processaworkflowparams
253
+ */
289
254
  function processAWorkflow(options) {
290
255
  var self = this;
291
256
  // Initializing promise
@@ -312,7 +277,7 @@ function processAWorkflow(options) {
312
277
  }
313
278
  else {
314
279
  err = {};
315
- 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' +
316
281
  ' in request options.';
317
282
  err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
318
283
  dfd.reject(err);
@@ -320,13 +285,10 @@ function processAWorkflow(options) {
320
285
  return dfd.promise;
321
286
  }
322
287
 
323
- /* options = {
324
- "workflowid": "string", // required
325
- "body" : { // required
326
- "context_id": "string" // required
327
- }
328
- };
329
- */
288
+ /**
289
+ * Wiki Link for SDK params
290
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#revokeaworkflowparams
291
+ */
330
292
  function revokeAWorkflow(options) {
331
293
  var self = this;
332
294
  // Initializing promise
@@ -362,13 +324,10 @@ function revokeAWorkflow(options) {
362
324
  return dfd.promise;
363
325
  }
364
326
 
365
- /* options = {
366
- "workflowid": "string", // required
367
- "body" : { // required
368
- "context_id": "string" // required
369
- }
370
- };
371
- */
327
+ /**
328
+ * Wiki Link for SDK params
329
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#completeaworkflowparams
330
+ */
372
331
  function completeAWorkflow(options) {
373
332
  var self = this;
374
333
  // Initializing promise
@@ -405,26 +364,8 @@ function completeAWorkflow(options) {
405
364
  }
406
365
 
407
366
  /**
408
- * options={
409
- * "context_id": "string", //mandatory
410
- * "body": {
411
- "ext_user_id": "string", //mandatory
412
- "workflow_type": "institution_request", //mandatory
413
- "institution_request": {
414
- "address": {
415
- "city": "string",
416
- "country": "string",
417
- "street1": "string",
418
- "street2": "string",
419
- "street3": "string",
420
- "house_no": "string",
421
- "post_code": "string"
422
- },
423
- "display_name": "string",
424
- "school_key": "string"
425
- }
426
- }
427
- }
367
+ * Wiki Link for SDK params
368
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/21_Workflows-Adapter#updateworkflowrequestparams
428
369
  */
429
370
  function updateWorkflowRequest(options) {
430
371
  var self = this;
@@ -445,7 +386,7 @@ function updateWorkflowRequest(options) {
445
386
  var requestAPI = request.put(url)
446
387
  .set('Content-Type', 'application/json')
447
388
  .set('Accept', 'application/json').query(queryParams)
448
- .send(options.body)
389
+ .send(options.body);
449
390
 
450
391
  if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
451
392
  requestAPI.end(function(error, response) {
@@ -462,4 +403,4 @@ function updateWorkflowRequest(options) {
462
403
  dfd.reject(err);
463
404
  }
464
405
  return dfd.promise;
465
- }
406
+ }