comprodls-sdk 2.12.0 → 2.12.1

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 (48) hide show
  1. package/.eslintrc +28 -28
  2. package/.npmignore +5 -0
  3. package/README.md +371 -371
  4. package/dist/comprodls-sdk.js +11493 -11471
  5. package/dist/comprodls-sdk.min.js +14 -14
  6. package/grunt/publish.js +148 -148
  7. package/lib/comprodls.js +146 -146
  8. package/lib/config/index.js +337 -337
  9. package/lib/helpers/index.js +29 -29
  10. package/lib/helpers/lib/api/converter.js +119 -119
  11. package/lib/helpers/lib/api/index.js +120 -120
  12. package/lib/helpers/lib/api/validations.js +72 -72
  13. package/lib/helpers/lib/errors.js +129 -129
  14. package/lib/helpers/lib/utils.js +23 -23
  15. package/lib/helpers/lib/validator.js +100 -100
  16. package/lib/open_access/index.js +121 -121
  17. package/lib/services/activity/activity.js +209 -209
  18. package/lib/services/activity/attempt.js +431 -431
  19. package/lib/services/activity/index.js +28 -28
  20. package/lib/services/analytics/index.js +1555 -1555
  21. package/lib/services/attempts/index.js +342 -342
  22. package/lib/services/auth/classProduct.js +37 -37
  23. package/lib/services/auth/index.js +2541 -2541
  24. package/lib/services/collab/index.js +468 -468
  25. package/lib/services/drive/index.js +144 -144
  26. package/lib/services/integrations/index.js +279 -279
  27. package/lib/services/invitations/index.js +313 -313
  28. package/lib/services/lrs/index.js +459 -459
  29. package/lib/services/product/index.js +267 -267
  30. package/lib/services/pub/index.js +407 -407
  31. package/lib/services/push/index.js +187 -187
  32. package/lib/services/push/pubnubClientWrapper.js +557 -557
  33. package/lib/services/push/sessionStorage.js +64 -64
  34. package/lib/services/pushX/index.js +190 -190
  35. package/lib/services/pushX/pubnubClientWrapper.js +211 -211
  36. package/lib/services/sisevents/index.js +113 -113
  37. package/lib/services/spaces/index.js +976 -929
  38. package/lib/services/superuser/index.js +175 -175
  39. package/lib/services/workflows/index.js +464 -464
  40. package/lib/services/xapi/index.js +232 -232
  41. package/lib/token/index.js +114 -114
  42. package/lib/token/validations.js +88 -88
  43. package/package-lock.json +5095 -0
  44. package/package.json +1 -1
  45. package/test.js +50 -50
  46. package/.vscode/launch.json +0 -23
  47. package/npm-debug.log.189866131 +0 -0
  48. package/npm-debug.log.712840116 +0 -26
@@ -1,279 +1,279 @@
1
- /*************************************************************************
2
- *
3
- * COMPRO CONFIDENTIAL
4
- * __________________
5
- *
6
- * [2015] - [2020] Compro Technologies Private Limited
7
- * All Rights Reserved.
8
- *
9
- * NOTICE: All information contained herein is, and remains
10
- * the property of Compro Technologies Private Limited. The
11
- * intellectual and technical concepts contained herein are
12
- * proprietary to Compro Technologies Private Limited and may
13
- * be covered by U.S. and Foreign Patents, patents in process,
14
- * and are protected by trade secret or copyright law.
15
- *
16
- * Dissemination of this information or reproduction of this material
17
- * is strictly forbidden unless prior written permission is obtained
18
- * from Compro Technologies Pvt. Ltd..
19
- ***************************************************************************/
20
-
21
- /***********************************************************
22
- * comproDLS SDK AUTH API Adaptor
23
- * Functions for calling AUTH API.
24
- ************************************************************/
25
-
26
- var q = require('q');
27
- var request = require('superagent');
28
-
29
- var helpers = require('../../helpers');
30
-
31
- var DLSError = helpers.errors.DLSError;
32
-
33
- /*********************************
34
- * Setting Up Module Entry Point
35
- **********************************/
36
- module.exports = integrations;
37
-
38
- //Integrations Adaptor Constructor
39
- function integrations(accountId) {
40
- this.accountId = accountId;
41
- return {
42
- getGetStreamCredentials: getGetStreamCredentials.bind(this),
43
- queryDataFromSearch: queryDataFromSearch.bind(this),
44
- getAuditTrailForAttempts: getAuditTrailForAttempts.bind(this),
45
- getAuditTrailForEntitlements: getAuditTrailForEntitlements.bind(this),
46
- getAuditTrailForMicroEntitlements: getAuditTrailForMicroEntitlements.bind(this)
47
- };
48
- }
49
-
50
- //params: NONE
51
- function getGetStreamCredentials() {
52
- var self = this;
53
- var dfd = q.defer(), err;
54
-
55
- var url = self.config.DEFAULT_HOSTS.INTEGRATION +
56
- self.config.INTEGRATIONS_API_URLS.getGetStreamCredentials;
57
- url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
58
-
59
- // Setup request with URL and Params
60
- var requestAPI = request.post(url)
61
- .set('Content-Type', 'application/json')
62
- .set('Accept', 'application/json')
63
- .send();
64
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
65
-
66
- requestAPI.end(function (error, response) {
67
- if(error) {
68
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
69
- dfd.reject(err);
70
- }
71
- else { dfd.resolve(response); }
72
- });
73
- return dfd.promise;
74
- }
75
-
76
- /*
77
- options = {
78
- index: 'string', //mandatory
79
- query: 'string' //mandatory
80
- }
81
- */
82
- function queryDataFromSearch(options) {
83
- var self = this;
84
- var dfd = q.defer();
85
- var err;
86
-
87
- if(options && options.index && options.query) {
88
- //Passed all validations, Construct API url
89
- var url = self.config.DEFAULT_HOSTS.INTEGRATION +
90
- self.config.INTEGRATIONS_API_URLS.queryDataFromSearch;
91
- url = helpers.api.constructAPIUrl(url, { index: options.index });
92
-
93
- // Contruct parameters
94
- var params = {
95
- query: options.query
96
- };
97
-
98
- //Setup request with URL and Params
99
- var requestAPI = request.get(url).query(params);
100
-
101
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
102
-
103
- requestAPI.end(function (err, response) {
104
- if (err) {
105
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
106
- dfd.reject(err);
107
- }
108
- else { dfd.resolve(response.body); }
109
- });
110
- }
111
- else {
112
- err = {};
113
- err.message = err.description = 'Mandatory params - index, type or query ' +
114
- 'not found in request options.';
115
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
116
- dfd.reject(err);
117
- }
118
- return dfd.promise;
119
- }
120
-
121
- /*
122
- options = {
123
- accountid: 'string',
124
- action: 'string',
125
- userid: 'string',
126
- productcode: 'string',
127
- item-code: 'string',
128
- cursor: 'string'
129
- }
130
- */
131
- function getAuditTrailForAttempts(options) {
132
- var self = this;
133
- var dfd = q.defer();
134
- var err;
135
-
136
- if (options && options.accountid && options.action &&
137
- options.userid && options.productcode && options['item-code']) {
138
- //Passed all validations, Construct API url
139
- var url = self.config.DEFAULT_HOSTS.INTEGRATION +
140
- self.config.INTEGRATIONS_API_URLS.auditTrail;
141
- url = helpers.api.constructAPIUrl(url, { accountId: options.accountid });
142
-
143
- // Contruct parameters
144
- var params = {
145
- audit_context: 'ATTEMPT-' + options.accountid + '#' + options.userid,
146
- target_context: 'PRODUCT-' + options.productcode + '#' + options['item-code'],
147
- action: options.action
148
- };
149
- if(options.cursor) { params.cursor = options.cursor; }
150
-
151
- //Setup request with URL and Params
152
- var requestAPI = request.get(url).query(params);
153
-
154
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
155
-
156
- requestAPI.end(function (err, response) {
157
- if(err) {
158
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
159
- dfd.reject(err);
160
- }
161
- else { dfd.resolve(response.body); }
162
- });
163
- }
164
- else {
165
- err = {};
166
- err.message = err.description = 'Mandatory params - accountid, action, userid, ' +
167
- 'productcode or item-code not found in request options.';
168
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
169
- dfd.reject(err);
170
- }
171
- return dfd.promise;
172
- }
173
-
174
- /*
175
- options = {
176
- accountid: 'string',
177
- action: 'string',
178
- userid: 'string',
179
- productcode: 'string',
180
- cursor: 'string'
181
- }
182
- */
183
- function getAuditTrailForEntitlements(options) {
184
- var self = this;
185
- var dfd = q.defer();
186
- var err;
187
-
188
- if(options && options.accountid && options.action &&
189
- options.userid && options.productcode) {
190
- //Passed all validations, Construct API url
191
- var url = self.config.DEFAULT_HOSTS.INTEGRATION +
192
- self.config.INTEGRATIONS_API_URLS.auditTrail;
193
- url = helpers.api.constructAPIUrl(url, { accountId: options.accountid });
194
-
195
- // Contruct parameters
196
- var params = {
197
- audit_context: 'ENTITLEMENT-' + options.accountid + '#' + options.userid,
198
- target_context: 'PRODUCT-' + options.productcode,
199
- type: 'entitlement',
200
- action: options.action
201
- };
202
- if(options.cursor) { params.cursor = options.cursor; }
203
-
204
- //Setup request with URL and Params
205
- var requestAPI = request.get(url).query(params);
206
-
207
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
208
-
209
- requestAPI.end(function (err, response) {
210
- if(err) {
211
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
212
- dfd.reject(err);
213
- }
214
- else { dfd.resolve(response.body); }
215
- });
216
- }
217
- else {
218
- err = {};
219
- err.message = err.description = 'Mandatory params - accountid, userid or productcode ' +
220
- 'not found in request options.';
221
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
222
- dfd.reject(err);
223
- }
224
- return dfd.promise;
225
- }
226
-
227
- /*
228
- options = {
229
- accountid: 'string',
230
- action: 'string',
231
- userid: 'string',
232
- productcode: 'string',
233
- context: 'string',
234
- cursor: 'string'
235
- }
236
- */
237
- function getAuditTrailForMicroEntitlements(options) {
238
- var self = this;
239
- var dfd = q.defer();
240
- var err;
241
-
242
- if(options && options.accountid && options.action &&
243
- options.userid && options.productcode && options.context) {
244
- //Passed all validations, Construct API url
245
- var url = self.config.DEFAULT_HOSTS.INTEGRATION +
246
- self.config.INTEGRATIONS_API_URLS.auditTrail;
247
- url = helpers.api.constructAPIUrl(url, { accountId: options.accountid });
248
-
249
- // Contruct parameters
250
- var params = {
251
- audit_context: 'ENTITLEMENT-' + options.accountid + '#' + options.userid,
252
- target_context: 'PRODUCT-' + options.productcode + '#' + options.context,
253
- type: 'micro-entitlement',
254
- action: options.action
255
- };
256
- if(options.cursor) { params.cursor = options.cursor; }
257
-
258
- //Setup request with URL and Params
259
- var requestAPI = request.get(url).query(params);
260
-
261
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
262
-
263
- requestAPI.end(function (err, response) {
264
- if(err){
265
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
266
- dfd.reject(err);
267
- }
268
- else { dfd.resolve(response.body); }
269
- });
270
- }
271
- else {
272
- err = {};
273
- err.message = err.description = 'Mandatory params - accountid, action, userid, productcode ' +
274
- 'or context not found in request options.';
275
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
276
- dfd.reject(err);
277
- }
278
- return dfd.promise;
279
- }
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+
21
+ /***********************************************************
22
+ * comproDLS SDK AUTH API Adaptor
23
+ * Functions for calling AUTH API.
24
+ ************************************************************/
25
+
26
+ var q = require('q');
27
+ var request = require('superagent');
28
+
29
+ var helpers = require('../../helpers');
30
+
31
+ var DLSError = helpers.errors.DLSError;
32
+
33
+ /*********************************
34
+ * Setting Up Module Entry Point
35
+ **********************************/
36
+ module.exports = integrations;
37
+
38
+ //Integrations Adaptor Constructor
39
+ function integrations(accountId) {
40
+ this.accountId = accountId;
41
+ return {
42
+ getGetStreamCredentials: getGetStreamCredentials.bind(this),
43
+ queryDataFromSearch: queryDataFromSearch.bind(this),
44
+ getAuditTrailForAttempts: getAuditTrailForAttempts.bind(this),
45
+ getAuditTrailForEntitlements: getAuditTrailForEntitlements.bind(this),
46
+ getAuditTrailForMicroEntitlements: getAuditTrailForMicroEntitlements.bind(this)
47
+ };
48
+ }
49
+
50
+ //params: NONE
51
+ function getGetStreamCredentials() {
52
+ var self = this;
53
+ var dfd = q.defer(), err;
54
+
55
+ var url = self.config.DEFAULT_HOSTS.INTEGRATION +
56
+ self.config.INTEGRATIONS_API_URLS.getGetStreamCredentials;
57
+ url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
58
+
59
+ // Setup request with URL and Params
60
+ var requestAPI = request.post(url)
61
+ .set('Content-Type', 'application/json')
62
+ .set('Accept', 'application/json')
63
+ .send();
64
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
65
+
66
+ requestAPI.end(function (error, response) {
67
+ if(error) {
68
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
69
+ dfd.reject(err);
70
+ }
71
+ else { dfd.resolve(response); }
72
+ });
73
+ return dfd.promise;
74
+ }
75
+
76
+ /*
77
+ options = {
78
+ index: 'string', //mandatory
79
+ query: 'string' //mandatory
80
+ }
81
+ */
82
+ function queryDataFromSearch(options) {
83
+ var self = this;
84
+ var dfd = q.defer();
85
+ var err;
86
+
87
+ if(options && options.index && options.query) {
88
+ //Passed all validations, Construct API url
89
+ var url = self.config.DEFAULT_HOSTS.INTEGRATION +
90
+ self.config.INTEGRATIONS_API_URLS.queryDataFromSearch;
91
+ url = helpers.api.constructAPIUrl(url, { index: options.index });
92
+
93
+ // Contruct parameters
94
+ var params = {
95
+ query: options.query
96
+ };
97
+
98
+ //Setup request with URL and Params
99
+ var requestAPI = request.get(url).query(params);
100
+
101
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
102
+
103
+ requestAPI.end(function (err, response) {
104
+ if (err) {
105
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
106
+ dfd.reject(err);
107
+ }
108
+ else { dfd.resolve(response.body); }
109
+ });
110
+ }
111
+ else {
112
+ err = {};
113
+ err.message = err.description = 'Mandatory params - index, type or query ' +
114
+ 'not found in request options.';
115
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
116
+ dfd.reject(err);
117
+ }
118
+ return dfd.promise;
119
+ }
120
+
121
+ /*
122
+ options = {
123
+ accountid: 'string',
124
+ action: 'string',
125
+ userid: 'string',
126
+ productcode: 'string',
127
+ item-code: 'string',
128
+ cursor: 'string'
129
+ }
130
+ */
131
+ function getAuditTrailForAttempts(options) {
132
+ var self = this;
133
+ var dfd = q.defer();
134
+ var err;
135
+
136
+ if (options && options.accountid && options.action &&
137
+ options.userid && options.productcode && options['item-code']) {
138
+ //Passed all validations, Construct API url
139
+ var url = self.config.DEFAULT_HOSTS.INTEGRATION +
140
+ self.config.INTEGRATIONS_API_URLS.auditTrail;
141
+ url = helpers.api.constructAPIUrl(url, { accountId: options.accountid });
142
+
143
+ // Contruct parameters
144
+ var params = {
145
+ audit_context: 'ATTEMPT-' + options.accountid + '#' + options.userid,
146
+ target_context: 'PRODUCT-' + options.productcode + '#' + options['item-code'],
147
+ action: options.action
148
+ };
149
+ if(options.cursor) { params.cursor = options.cursor; }
150
+
151
+ //Setup request with URL and Params
152
+ var requestAPI = request.get(url).query(params);
153
+
154
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
155
+
156
+ requestAPI.end(function (err, response) {
157
+ if(err) {
158
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
159
+ dfd.reject(err);
160
+ }
161
+ else { dfd.resolve(response.body); }
162
+ });
163
+ }
164
+ else {
165
+ err = {};
166
+ err.message = err.description = 'Mandatory params - accountid, action, userid, ' +
167
+ 'productcode or item-code not found in request options.';
168
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
169
+ dfd.reject(err);
170
+ }
171
+ return dfd.promise;
172
+ }
173
+
174
+ /*
175
+ options = {
176
+ accountid: 'string',
177
+ action: 'string',
178
+ userid: 'string',
179
+ productcode: 'string',
180
+ cursor: 'string'
181
+ }
182
+ */
183
+ function getAuditTrailForEntitlements(options) {
184
+ var self = this;
185
+ var dfd = q.defer();
186
+ var err;
187
+
188
+ if(options && options.accountid && options.action &&
189
+ options.userid && options.productcode) {
190
+ //Passed all validations, Construct API url
191
+ var url = self.config.DEFAULT_HOSTS.INTEGRATION +
192
+ self.config.INTEGRATIONS_API_URLS.auditTrail;
193
+ url = helpers.api.constructAPIUrl(url, { accountId: options.accountid });
194
+
195
+ // Contruct parameters
196
+ var params = {
197
+ audit_context: 'ENTITLEMENT-' + options.accountid + '#' + options.userid,
198
+ target_context: 'PRODUCT-' + options.productcode,
199
+ type: 'entitlement',
200
+ action: options.action
201
+ };
202
+ if(options.cursor) { params.cursor = options.cursor; }
203
+
204
+ //Setup request with URL and Params
205
+ var requestAPI = request.get(url).query(params);
206
+
207
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
208
+
209
+ requestAPI.end(function (err, response) {
210
+ if(err) {
211
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
212
+ dfd.reject(err);
213
+ }
214
+ else { dfd.resolve(response.body); }
215
+ });
216
+ }
217
+ else {
218
+ err = {};
219
+ err.message = err.description = 'Mandatory params - accountid, userid or productcode ' +
220
+ 'not found in request options.';
221
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
222
+ dfd.reject(err);
223
+ }
224
+ return dfd.promise;
225
+ }
226
+
227
+ /*
228
+ options = {
229
+ accountid: 'string',
230
+ action: 'string',
231
+ userid: 'string',
232
+ productcode: 'string',
233
+ context: 'string',
234
+ cursor: 'string'
235
+ }
236
+ */
237
+ function getAuditTrailForMicroEntitlements(options) {
238
+ var self = this;
239
+ var dfd = q.defer();
240
+ var err;
241
+
242
+ if(options && options.accountid && options.action &&
243
+ options.userid && options.productcode && options.context) {
244
+ //Passed all validations, Construct API url
245
+ var url = self.config.DEFAULT_HOSTS.INTEGRATION +
246
+ self.config.INTEGRATIONS_API_URLS.auditTrail;
247
+ url = helpers.api.constructAPIUrl(url, { accountId: options.accountid });
248
+
249
+ // Contruct parameters
250
+ var params = {
251
+ audit_context: 'ENTITLEMENT-' + options.accountid + '#' + options.userid,
252
+ target_context: 'PRODUCT-' + options.productcode + '#' + options.context,
253
+ type: 'micro-entitlement',
254
+ action: options.action
255
+ };
256
+ if(options.cursor) { params.cursor = options.cursor; }
257
+
258
+ //Setup request with URL and Params
259
+ var requestAPI = request.get(url).query(params);
260
+
261
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
262
+
263
+ requestAPI.end(function (err, response) {
264
+ if(err){
265
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
266
+ dfd.reject(err);
267
+ }
268
+ else { dfd.resolve(response.body); }
269
+ });
270
+ }
271
+ else {
272
+ err = {};
273
+ err.message = err.description = 'Mandatory params - accountid, action, userid, productcode ' +
274
+ 'or context not found in request options.';
275
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
276
+ dfd.reject(err);
277
+ }
278
+ return dfd.promise;
279
+ }