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,267 +1,267 @@
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
- * comproDLS SDK Product API Adaptor
22
- * Functions for calling Product API.
23
- ************************************************************/
24
- var request = require('superagent');
25
- var q = require('q');
26
-
27
- var helpers = require('../../helpers');
28
- var DLSError = helpers.errors.DLSError;
29
-
30
- /*********************************
31
- * Setting Up Module Entry Point
32
- **********************************/
33
- module.exports = product;
34
-
35
- function product(accountId) {
36
- this.accountId = accountId;
37
- return {
38
- getProduct: getProduct.bind(this),
39
- getGlobalEntitlementsForAUser: getGlobalEntitlementsForAUser.bind(this),
40
- getMicroEntitlementsForAUser: getMicroEntitlementsForAUser.bind(this),
41
-
42
- getAllBundles: getAllBundles.bind(this),
43
- getSingleBundle: getSingleBundle.bind(this)
44
- };
45
- }
46
-
47
- /*********************************
48
- * Public Function definitions
49
- **********************************/
50
-
51
- //options = {
52
- // productcode: '', //productcode of product
53
- // details: boolean, // (optional)
54
- // stage: string // (optional, ['1', '2', 'final']), default - final
55
- //}
56
- function getProduct(options) {
57
- var dfd = q.defer();
58
- var self = this;
59
- var err = {};
60
-
61
- if(options && options.productcode) {
62
- //Passed all validations, Construct API url
63
- var url = self.config.DEFAULT_HOSTS['PRODUCT'] +
64
- self.config.PRODUCT_API_URLS.getProductAPI;
65
- url = helpers.api.constructAPIUrl(url, {
66
- accountId: self.accountId,
67
- productCode: options.productcode
68
- });
69
-
70
- //Construct parameters
71
- var params = {};
72
- if(options.details) {
73
- params.details = options.details;
74
- }
75
- if(options.stage) {
76
- params.stage = options.stage;
77
- }
78
- //Setup request with URL and Params
79
- var requestAPI = request.get(url).query(params);
80
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
81
-
82
- //Call GET All Products Source Api
83
- requestAPI.end(function(err, response) {
84
- if (err) {
85
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
86
- dfd.reject(err);
87
- } else {
88
- dfd.resolve(response.body);
89
- }
90
- });
91
- }
92
- else {
93
- err.message = err.description = 'productcode not found in request options';
94
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
95
- dfd.reject(err);
96
- }
97
-
98
- return dfd.promise;
99
- }
100
-
101
- // options : { extUserId, productDetails, bundleDetails }
102
- function getGlobalEntitlementsForAUser(options) {
103
- var self = this;
104
-
105
- //Initializing promise
106
- var dfd = q.defer();
107
-
108
- if(options && options.extUserId) {
109
- //Passed all validations, Construct API url
110
- var url = self.config.DEFAULT_HOSTS.PRODUCT +
111
- self.config.PRODUCT_API_URLS.getEntitlementsOfAUser;
112
- url = helpers.api.constructAPIUrl(url,
113
- { accountId : self.accountId, extUserId : options.extUserId });
114
-
115
- //Contruct parameters
116
- var query = {};
117
- if(options.productDetails) { query.productDetails = options.productDetails; }
118
- if(options.bundleDetails) { query.bundleDetails = options.bundleDetails; }
119
-
120
- //Setup request with URL and Params
121
- var requestAPI = request.get(url).query(query);
122
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
123
-
124
- //Call GET ALL USER Api
125
- requestAPI.end(function(err, response) {
126
- if (err) {
127
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
128
- dfd.reject(err);
129
- }
130
- else { dfd.resolve(response.body); }
131
- });
132
- }
133
- else {
134
- var err = {};
135
- err.message = err.description = 'Mandatory parameter extUserId not found in request options';
136
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
137
- dfd.reject(err);
138
- }
139
- return dfd.promise;
140
-
141
- }
142
-
143
- /*options : {
144
- extuserid, //mandatory
145
- productcode, //mandatory
146
- context, //optional
147
- feature_key, //optional
148
- cursor //optional
149
- }
150
- */
151
- function getMicroEntitlementsForAUser(options) {
152
- var self = this;
153
-
154
- //Initializing promise
155
- var dfd = q.defer();
156
-
157
- if(options && options.extuserid && options.productcode ) {
158
- //Passed all validations, Construct API url
159
- var url = self.config.DEFAULT_HOSTS.PRODUCT +
160
- self.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser;
161
- url = helpers.api.constructAPIUrl(url,
162
- { accountId : self.accountId, extUserId : options.extuserid });
163
-
164
- //Contruct parameters
165
- var query = {};
166
- query.productcode = options.productcode;
167
- if (options.context) { query.context = options.context; }
168
- if (options.feature_key) { query.feature_key = options.feature_key; }
169
- if (options.cursor) { query.cursor = options.cursor; }
170
-
171
- //Setup request with URL and Params
172
- var requestAPI = request.get(url).query(query);
173
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
174
-
175
- //Call Get All User Micro Entitlements Api
176
- requestAPI.end(function(err, response) {
177
- if (err) {
178
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
179
- dfd.reject(err);
180
- }
181
- else { dfd.resolve(response.body); }
182
- });
183
- }
184
- else {
185
- var err = {};
186
- err.message = err.description = 'Mandatory parameter extuserid or productcode' +
187
- 'not found in request options';
188
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
189
- dfd.reject(err);
190
- }
191
- return dfd.promise;
192
-
193
- }
194
-
195
- // options= {
196
- // stage: "", //stage number or version
197
- // }
198
- function getAllBundles(options) {
199
- var self = this;
200
- var dfd = q.defer();
201
-
202
- //Passed all validations, Construct API url
203
- var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getAllBundles;
204
-
205
- url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
206
- //Contruct parameters
207
- var params = {};
208
- if(options && options.stage) { params.stage = options.stage; }
209
-
210
- //Setup request with URL and Post data
211
- var requestAPI = request.get(url).query(params);
212
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
213
-
214
- requestAPI.end(function (err, response) {
215
- if(err) {
216
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
217
- dfd.reject(err);
218
- } else {
219
- dfd.resolve(response.body);
220
- }
221
- });
222
-
223
- return dfd.promise;
224
- }
225
-
226
- // options = {
227
- // 'bundle-code': "", //bundle identifier
228
- // stage: "", //stage number/version
229
- // }
230
- function getSingleBundle(options) {
231
- var self = this;
232
- var dfd = q.defer();
233
- var err;
234
-
235
-
236
- if(options && options['bundle-code']) {
237
-
238
- var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getSingleBundle;
239
-
240
- url = helpers.api.constructAPIUrl(url, { accountId : self.accountId, bundleCode: options['bundle-code'] });
241
- //Contruct parameters
242
- var params = {};
243
- if(options.stage) { params.stage = options.stage; }
244
- //Setup request with URL and Post data
245
-
246
- var requestAPI = request.get(url).query(params);
247
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
248
-
249
- requestAPI.end(function (err, response) {
250
- if(err) {
251
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
252
- dfd.reject(err);
253
- } else {
254
- dfd.resolve(response.body);
255
- }
256
- });
257
- }
258
- else {
259
- err = {};
260
- err.message = err.description = 'Required parameter bundle-code not found in request options';
261
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
262
- dfd.reject(err);
263
- }
264
-
265
-
266
- return dfd.promise;
267
- }
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
+ * comproDLS SDK Product API Adaptor
22
+ * Functions for calling Product API.
23
+ ************************************************************/
24
+ var request = require('superagent');
25
+ var q = require('q');
26
+
27
+ var helpers = require('../../helpers');
28
+ var DLSError = helpers.errors.DLSError;
29
+
30
+ /*********************************
31
+ * Setting Up Module Entry Point
32
+ **********************************/
33
+ module.exports = product;
34
+
35
+ function product(accountId) {
36
+ this.accountId = accountId;
37
+ return {
38
+ getProduct: getProduct.bind(this),
39
+ getGlobalEntitlementsForAUser: getGlobalEntitlementsForAUser.bind(this),
40
+ getMicroEntitlementsForAUser: getMicroEntitlementsForAUser.bind(this),
41
+
42
+ getAllBundles: getAllBundles.bind(this),
43
+ getSingleBundle: getSingleBundle.bind(this)
44
+ };
45
+ }
46
+
47
+ /*********************************
48
+ * Public Function definitions
49
+ **********************************/
50
+
51
+ //options = {
52
+ // productcode: '', //productcode of product
53
+ // details: boolean, // (optional)
54
+ // stage: string // (optional, ['1', '2', 'final']), default - final
55
+ //}
56
+ function getProduct(options) {
57
+ var dfd = q.defer();
58
+ var self = this;
59
+ var err = {};
60
+
61
+ if(options && options.productcode) {
62
+ //Passed all validations, Construct API url
63
+ var url = self.config.DEFAULT_HOSTS['PRODUCT'] +
64
+ self.config.PRODUCT_API_URLS.getProductAPI;
65
+ url = helpers.api.constructAPIUrl(url, {
66
+ accountId: self.accountId,
67
+ productCode: options.productcode
68
+ });
69
+
70
+ //Construct parameters
71
+ var params = {};
72
+ if(options.details) {
73
+ params.details = options.details;
74
+ }
75
+ if(options.stage) {
76
+ params.stage = options.stage;
77
+ }
78
+ //Setup request with URL and Params
79
+ var requestAPI = request.get(url).query(params);
80
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
81
+
82
+ //Call GET All Products Source Api
83
+ requestAPI.end(function(err, response) {
84
+ if (err) {
85
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
86
+ dfd.reject(err);
87
+ } else {
88
+ dfd.resolve(response.body);
89
+ }
90
+ });
91
+ }
92
+ else {
93
+ err.message = err.description = 'productcode not found in request options';
94
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
95
+ dfd.reject(err);
96
+ }
97
+
98
+ return dfd.promise;
99
+ }
100
+
101
+ // options : { extUserId, productDetails, bundleDetails }
102
+ function getGlobalEntitlementsForAUser(options) {
103
+ var self = this;
104
+
105
+ //Initializing promise
106
+ var dfd = q.defer();
107
+
108
+ if(options && options.extUserId) {
109
+ //Passed all validations, Construct API url
110
+ var url = self.config.DEFAULT_HOSTS.PRODUCT +
111
+ self.config.PRODUCT_API_URLS.getEntitlementsOfAUser;
112
+ url = helpers.api.constructAPIUrl(url,
113
+ { accountId : self.accountId, extUserId : options.extUserId });
114
+
115
+ //Contruct parameters
116
+ var query = {};
117
+ if(options.productDetails) { query.productDetails = options.productDetails; }
118
+ if(options.bundleDetails) { query.bundleDetails = options.bundleDetails; }
119
+
120
+ //Setup request with URL and Params
121
+ var requestAPI = request.get(url).query(query);
122
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
123
+
124
+ //Call GET ALL USER Api
125
+ requestAPI.end(function(err, response) {
126
+ if (err) {
127
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
128
+ dfd.reject(err);
129
+ }
130
+ else { dfd.resolve(response.body); }
131
+ });
132
+ }
133
+ else {
134
+ var err = {};
135
+ err.message = err.description = 'Mandatory parameter extUserId not found in request options';
136
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
137
+ dfd.reject(err);
138
+ }
139
+ return dfd.promise;
140
+
141
+ }
142
+
143
+ /*options : {
144
+ extuserid, //mandatory
145
+ productcode, //mandatory
146
+ context, //optional
147
+ feature_key, //optional
148
+ cursor //optional
149
+ }
150
+ */
151
+ function getMicroEntitlementsForAUser(options) {
152
+ var self = this;
153
+
154
+ //Initializing promise
155
+ var dfd = q.defer();
156
+
157
+ if(options && options.extuserid && options.productcode ) {
158
+ //Passed all validations, Construct API url
159
+ var url = self.config.DEFAULT_HOSTS.PRODUCT +
160
+ self.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser;
161
+ url = helpers.api.constructAPIUrl(url,
162
+ { accountId : self.accountId, extUserId : options.extuserid });
163
+
164
+ //Contruct parameters
165
+ var query = {};
166
+ query.productcode = options.productcode;
167
+ if (options.context) { query.context = options.context; }
168
+ if (options.feature_key) { query.feature_key = options.feature_key; }
169
+ if (options.cursor) { query.cursor = options.cursor; }
170
+
171
+ //Setup request with URL and Params
172
+ var requestAPI = request.get(url).query(query);
173
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
174
+
175
+ //Call Get All User Micro Entitlements Api
176
+ requestAPI.end(function(err, response) {
177
+ if (err) {
178
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
179
+ dfd.reject(err);
180
+ }
181
+ else { dfd.resolve(response.body); }
182
+ });
183
+ }
184
+ else {
185
+ var err = {};
186
+ err.message = err.description = 'Mandatory parameter extuserid or productcode' +
187
+ 'not found in request options';
188
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
189
+ dfd.reject(err);
190
+ }
191
+ return dfd.promise;
192
+
193
+ }
194
+
195
+ // options= {
196
+ // stage: "", //stage number or version
197
+ // }
198
+ function getAllBundles(options) {
199
+ var self = this;
200
+ var dfd = q.defer();
201
+
202
+ //Passed all validations, Construct API url
203
+ var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getAllBundles;
204
+
205
+ url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
206
+ //Contruct parameters
207
+ var params = {};
208
+ if(options && options.stage) { params.stage = options.stage; }
209
+
210
+ //Setup request with URL and Post data
211
+ var requestAPI = request.get(url).query(params);
212
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
213
+
214
+ requestAPI.end(function (err, response) {
215
+ if(err) {
216
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
217
+ dfd.reject(err);
218
+ } else {
219
+ dfd.resolve(response.body);
220
+ }
221
+ });
222
+
223
+ return dfd.promise;
224
+ }
225
+
226
+ // options = {
227
+ // 'bundle-code': "", //bundle identifier
228
+ // stage: "", //stage number/version
229
+ // }
230
+ function getSingleBundle(options) {
231
+ var self = this;
232
+ var dfd = q.defer();
233
+ var err;
234
+
235
+
236
+ if(options && options['bundle-code']) {
237
+
238
+ var url = self.config.DEFAULT_HOSTS.PRODUCT + self.config.PRODUCT_API_URLS.getSingleBundle;
239
+
240
+ url = helpers.api.constructAPIUrl(url, { accountId : self.accountId, bundleCode: options['bundle-code'] });
241
+ //Contruct parameters
242
+ var params = {};
243
+ if(options.stage) { params.stage = options.stage; }
244
+ //Setup request with URL and Post data
245
+
246
+ var requestAPI = request.get(url).query(params);
247
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
248
+
249
+ requestAPI.end(function (err, response) {
250
+ if(err) {
251
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
252
+ dfd.reject(err);
253
+ } else {
254
+ dfd.resolve(response.body);
255
+ }
256
+ });
257
+ }
258
+ else {
259
+ err = {};
260
+ err.message = err.description = 'Required parameter bundle-code not found in request options';
261
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
262
+ dfd.reject(err);
263
+ }
264
+
265
+
266
+ return dfd.promise;
267
+ }