comprodls-sdk 2.90.2 → 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
@@ -17,6 +17,7 @@
17
17
  * is strictly forbidden unless prior written permission is obtained
18
18
  * from Compro Technologies Pvt. Ltd..
19
19
  ***************************************************************************/
20
+
20
21
  /***********************************************************
21
22
  * comproDLS SDK Token Manager Module
22
23
  * Provides Token managements functions for the SDK
@@ -28,87 +29,92 @@ var helpers = require('../helpers');
28
29
  var DLSError = helpers.errors.DLSError;
29
30
  var validations = require('./validations');
30
31
 
31
- /*************************************
32
- * Setting up Exports/Public functions
33
- *************************************/
34
32
  exports.authWithExtUser = authWithExtUser;
35
33
  exports.authWithToken = authWithToken;
36
34
 
35
+
36
+ /**
37
+ * Wiki Link for SDK params
38
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/02_Authentication-and-Tokens#authwithextuser
39
+ */
37
40
  function authWithExtUser(organizationId, options) {
38
- var self = this;
39
- var dfd = q.defer();
41
+ var self = this;
42
+ var dfd = q.defer();
40
43
 
41
- //Validation
42
- var err = validations.validateAuthWithExtUser(organizationId, options);
43
- if (err) {
44
- dfd.reject(err);
45
- } else {
46
- //Passed all Validations, Setup the GET TOKEN API URL.
47
- var url = this.config.DEFAULT_HOSTS['AUTH'] + this.config.AUTH_API_URLS.getExtUserTokenAPI;
48
- url = helpers.api.constructAPIUrl(url, {"orgId" : organizationId});
44
+ //Validation
45
+ var err = validations.validateAuthWithExtUser(organizationId, options);
46
+ if (err) {
47
+ dfd.reject(err);
48
+ } else {
49
+ //Passed all Validations, Setup the GET TOKEN API URL.
50
+ var url = this.config.DEFAULT_HOSTS['AUTH'] + this.config.AUTH_API_URLS.getExtUserTokenAPI;
51
+ url = helpers.api.constructAPIUrl(url, {'orgId' : organizationId});
49
52
 
50
- //Setup Credentials
51
- var params = {
52
- "ext_user_id": options.ext_user_id
53
+ //Setup Credentials
54
+ var params = {
55
+ 'ext_user_id': options.ext_user_id
56
+ };
57
+ //Call the comproDLS GET TOKEN API
58
+ request.post(url).send(params).end(function(err, response) {
59
+ if (err) {
60
+ //API Error, Construct Standard SDK error response
61
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
62
+ dfd.reject(err);
63
+ } else {
64
+ //Success, Extract the Token & Other useful information
65
+ var token = {
66
+ 'access_token': response.body.access_token
67
+ };
68
+ var user = response.body.user;
69
+ var responseObj = {
70
+ 'token': token,
71
+ 'user': user,
72
+ 'metrics': response.body.metrics
53
73
  };
54
- //Call the comproDLS GET TOKEN API
55
- request.post(url).send(params).end(function(err, response) {
56
- if (err) {
57
- //API Error, Construct Standard SDK error response
58
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
59
- dfd.reject(err);
60
- } else {
61
-
62
- //Success, Extract the Token & Other useful information
63
- var token = {
64
- 'access_token': response.body.access_token
65
- };
66
- var user = response.body.user;
67
- var responseObj = {
68
- 'token': token,
69
- 'user': user,
70
- 'metrics': response.body.metrics
71
- }
72
74
 
73
- //Setting token and organisationid in comproDLS instance
74
- self.token = token;
75
- self.orgId = user.org.id;
75
+ //Setting token and organisationid in comproDLS instance
76
+ self.token = token;
77
+ self.orgId = user.org.id;
76
78
 
77
- dfd.resolve(responseObj);
78
- }
79
- });
80
- }
81
- return dfd.promise;
79
+ dfd.resolve(responseObj);
80
+ }
81
+ });
82
+ }
83
+ return dfd.promise;
82
84
  };
83
85
 
86
+ /**
87
+ * Wiki Link for SDK params
88
+ * https://github.com/comprodls/comprodls-sdk-js/wiki/02_Authentication-and-Tokens#authwithtoken
89
+ */
84
90
  function authWithToken(organizationId, token, options) {
85
- var self = this;
86
- var dfd = q.defer();
91
+ var self = this;
92
+ var dfd = q.defer();
87
93
 
88
- //Validation
89
- var err = validations.authWithToken(organizationId, token ,options);
90
- if (err) {
91
- dfd.reject(err);
92
- } else {
94
+ //Validation
95
+ var err = validations.authWithToken(organizationId, token ,options);
96
+ if (err) {
97
+ dfd.reject(err);
98
+ } else {
93
99
 
94
- //Setting token and organisationid in comproDLS instance
95
- self.token = token;
96
- self.orgId = organizationId;
100
+ //Setting token and organisationid in comproDLS instance
101
+ self.token = token;
102
+ self.orgId = organizationId;
97
103
 
98
- if (options && options.getuserdetails) {
99
- self.Auth().getUserProfile().then(function(response) {
100
- var responseObj = {
101
- 'token': self.token,
102
- 'user': response
103
- }
104
- dfd.resolve(responseObj);
105
- }, function(err) {
106
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
107
- dfd.reject(err);
108
- });
109
- } else {
110
- dfd.resolve(self.token);
111
- }
104
+ if (options && options.getuserdetails) {
105
+ self.Auth().getUserProfile().then(function(response) {
106
+ var responseObj = {
107
+ 'token': self.token,
108
+ 'user': response
109
+ };
110
+ dfd.resolve(responseObj);
111
+ }, function(err) {
112
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
113
+ dfd.reject(err);
114
+ });
115
+ } else {
116
+ dfd.resolve(self.token);
112
117
  }
113
- return dfd.promise;
118
+ }
119
+ return dfd.promise;
114
120
  };
@@ -17,15 +17,13 @@
17
17
  * is strictly forbidden unless prior written permission is obtained
18
18
  * from Compro Technologies Pvt. Ltd..
19
19
  ***************************************************************************/
20
+
20
21
  /***********************************************************
21
22
  * comproDLS Token Module Validations
22
23
  * This module contains validations for token manager module.
23
24
  ************************************************************/
24
25
  var validate = require('../helpers').validations.validate;
25
26
 
26
- /****************************************************
27
- * Setting up Exports/Public variables
28
- *****************************************************/
29
27
  exports.authWithToken = validateAuthWithToken;
30
28
  exports.validateAuthWithExtUser = validateAuthWithExtUser;
31
29
 
@@ -33,56 +31,55 @@ exports.validateAuthWithExtUser = validateAuthWithExtUser;
33
31
  * Public Function definitions
34
32
  **********************************/
35
33
  function validateAuthWithToken(organizationId, token ,options) {
36
- var validate_options = {
37
- 'organization': organizationId,
38
- 'token': token,
39
- 'options': options
40
- };
34
+ var validate_options = {
35
+ 'organization': organizationId,
36
+ 'token': token,
37
+ 'options': options
38
+ };
41
39
 
42
- var validate_constraints = {
43
- "organization": {
44
- "isString": true,
45
- "presence": true
46
- },
47
- "token": {
48
- "isObject": true,
49
- "presence": true,
50
- "contains": ["access_token"]
51
- },
52
- "token.access_token": {
53
- "isString": true,
54
- "presence": true
55
- },
56
- "options": {
57
- "isObject": true
58
- }
59
- };
40
+ var validate_constraints = {
41
+ 'organization': {
42
+ 'isString': true,
43
+ 'presence': true
44
+ },
45
+ 'token': {
46
+ 'isObject': true,
47
+ 'presence': true,
48
+ 'contains': ['access_token']
49
+ },
50
+ 'token.access_token': {
51
+ 'isString': true,
52
+ 'presence': true
53
+ },
54
+ 'options': {
55
+ 'isObject': true
56
+ }
57
+ };
60
58
 
61
- return validate(validate_options, validate_constraints);
59
+ return validate(validate_options, validate_constraints);
62
60
  };
63
61
 
64
62
  function validateAuthWithExtUser(organizationId, options) {
65
- var validate_options = {
66
- 'organization': organizationId,
67
- 'options': options
68
- };
63
+ var validate_options = {
64
+ 'organization': organizationId,
65
+ 'options': options
66
+ };
69
67
 
70
- var validate_constraints = {
71
- "organization": {
72
- "isString": true,
73
- "presence": true
74
- },
75
- "options": {
76
- "isObject": true,
77
- "presence": true,
78
- "contains": ["ext_user_id"]
79
- },
80
- "options.ext_user_id": {
81
- "isString": true,
82
- "presence": true
83
- }
84
- };
68
+ var validate_constraints = {
69
+ 'organization': {
70
+ 'isString': true,
71
+ 'presence': true
72
+ },
73
+ 'options': {
74
+ 'isObject': true,
75
+ 'presence': true,
76
+ 'contains': ['ext_user_id']
77
+ },
78
+ 'options.ext_user_id': {
79
+ 'isString': true,
80
+ 'presence': true
81
+ }
82
+ };
85
83
 
86
- return validate(validate_options, validate_constraints);
84
+ return validate(validate_options, validate_constraints);
87
85
  };
88
-
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "comprodls-sdk",
3
3
  "description": "comproDLS SDK for JavaScript",
4
- "version": "2.90.2",
4
+ "version": "2.91.0-thor",
5
5
  "author": {
6
6
  "name": "Compro Technologies Private Limited",
7
7
  "url": "http://www.comprotechnologies.com/"
@@ -13,7 +13,6 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "agentkeepalive": "4.2.0",
16
- "extend": "3.0.2",
17
16
  "pubnub": "7.5.0",
18
17
  "q": "~1.4.1",
19
18
  "string-template": "^1.0.0",
@@ -24,7 +23,7 @@
24
23
  "grunt": "^0.4.5",
25
24
  "grunt-browserify": "^4.0.1",
26
25
  "grunt-contrib-clean": "^1.0.0",
27
- "grunt-contrib-uglify": "^0.11.1",
26
+ "grunt-contrib-uglify": "4.0.1",
28
27
  "semver": "^5.1.0",
29
28
  "shelljs": "^0.6.0"
30
29
  }
@@ -1,73 +0,0 @@
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 APIS Module Validations
22
- * This module contains validations for APIS module.
23
- ************************************************************/
24
- var validate = require('../validator').validate;
25
-
26
- /****************************************************
27
- * Setting up Exports/Public variables
28
- *****************************************************/
29
- exports.genericAPICaller = validateGenericAPICaller;
30
-
31
- /*********************************
32
- * Public Function definitions
33
- **********************************/
34
- function validateGenericAPICaller(apiName, method, url, params) {
35
- var validate_options = {
36
- 'apiName': apiName,
37
- 'method': method,
38
- 'url': url,
39
- 'params':params
40
- };
41
-
42
- var validate_constraints = {
43
- "apiName" : {
44
- "isString" : true,
45
- "presence" : true,
46
- "inclusion": {
47
- "within" : ["AUTH" , "PRODUCT" , "COLLAB" , "ANALYTICS" , "ACTIVITY" , "XAPI"],
48
- "message": "^Enter a valid API Name"
49
- }
50
- },
51
- "method" : {
52
- "isString" : true,
53
- "presence" : true,
54
- "inclusion": {
55
- "within" : ["GET" , "POST" , "PUT" , "DELETE"],
56
- "message": "^Enter a valid HTTP method"
57
- }
58
- },
59
- "url" : {
60
- "isString" : true,
61
- "presence" : true,
62
- "format": {
63
- "pattern": "^/.*$",
64
- "message": "^Url should start with a /"
65
- }
66
- },
67
- "params" : {
68
- "isObject" : true
69
- }
70
- };
71
-
72
- return validate(validate_options, validate_constraints);
73
- };
@@ -1,24 +0,0 @@
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 Util Module
22
- * This module provides Utility functions for SDK
23
- ************************************************************/
24
- exports.isBrowser = typeof window !== "undefined";
@@ -1,209 +0,0 @@
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 Activity API Adaptor
23
- * Functions for calling Activity API.
24
- ************************************************************/
25
- var request = require('superagent');
26
- var q = require('q');
27
-
28
- var helpers = require('../../helpers');
29
- var DLSError = helpers.errors.DLSError;
30
- var extend = require('extend');
31
- /*********************************
32
- * Public Function definitions
33
- **********************************/
34
- module.exports = Activity;
35
-
36
- var attempt = require('./attempt');
37
-
38
- function Activity(productId, activityId, classId) {
39
- //When Activity constructor is called, check for instance type
40
- //comproDLS.Activity() will give instance type as ComproDLS
41
- //So the control goes to else
42
- if (this instanceof Activity) {
43
- this.productId = productId; //Here this is instance of Activity
44
- this.activityId = activityId; //Here this is instance of Activity
45
- this.classId = classId;
46
-
47
- } else { //New object of Activity is created and its instance type is Activity
48
- var act = new Activity(productId, activityId, classId);
49
- act.token = this.token; //Here this is instance of ComproDLS
50
- act.orgId = this.orgId; //Here this is instance of ComproDLS
51
- act.config = this.config;
52
- return act;
53
- }
54
- };
55
-
56
- Activity.prototype.getDetails = function () {
57
- var self = this;
58
-
59
- //Initializing promise
60
- var dfd = q.defer();
61
-
62
- //Validations
63
- var err = helpers.validations.isAuthenticated(this.orgId, this.token);
64
- if (err) {
65
- dfd.reject(err);
66
- } else {
67
-
68
- //Passed all validations, Contruct API url
69
- var url = self.config.DEFAULT_HOSTS['ACTIVITY'] + self.config.ACTIVITY_API_URLS.activityDetailsAPI;
70
-
71
- url = helpers.api.constructAPIUrl(url, {
72
- "orgId" : self.orgId,
73
- "productId" : self.productId,
74
- "activityId" : self.activityId
75
- });
76
- url = helpers.api.addClassIdQueryParam(url, self.classId);
77
-
78
- //Setup request with URL and Params
79
- var req = request.get(url);
80
-
81
- //Setup token in Authorization header
82
- req = helpers.api.setupAPIToken(req, self.token);
83
-
84
- // setting up traceid
85
- if(self.traceid) { req.set('X-Amzn-Trace-Id', self.traceid); }
86
-
87
- //Call GET activity details Api
88
- req.end(function (err, response) {
89
- if (err) {
90
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
91
- dfd.reject(err);
92
- } else {
93
- var responseBody = response.body;
94
- var resObject = new Object();
95
- resObject.activity = responseBody;
96
- dfd.resolve(resObject);
97
- }
98
- });
99
- }
100
- return dfd.promise;
101
- }
102
-
103
- Activity.prototype.loadAttempt = function (attemptId) {
104
- var oldAttempt = new attempt(this.productId, this.activityId, attemptId, null, this.classId, this.config);
105
- oldAttempt.setAuthCredentials(this.orgId, this.token);
106
- return oldAttempt.getAttemptInfo();
107
- }
108
-
109
- Activity.prototype.getAttempt = function (attemptId) {
110
- var oldAttempt = new attempt(this.productId, this.activityId, attemptId, null, this.classId, this.config);
111
- oldAttempt.setAuthCredentials(this.orgId, this.token);
112
- return oldAttempt;
113
- }
114
-
115
- Activity.prototype.newAttempt = function (params) {
116
- var newAttempt = new attempt(this.productId, this.activityId, null, null, this.classId, this.config);
117
- newAttempt.setAuthCredentials(this.orgId, this.token);
118
- return newAttempt.start(params);
119
- }
120
-
121
- Activity.prototype.getAllQuestions = function () {
122
- var self = this;
123
-
124
- //Initializing promise
125
- var dfd = q.defer();
126
-
127
- //Validations
128
- var err = helpers.validations.isAuthenticated(this.orgId, this.token);
129
- if (err) {
130
- dfd.reject(err);
131
- } else {
132
-
133
- //Passed all validations, Contruct API url
134
- var url = self.config.DEFAULT_HOSTS['PRODUCT'] + self.config.PRODUCT_API_URLS.activityAPI;
135
- url = helpers.api.constructAPIUrl(url, {
136
- "orgId" : self.orgId,
137
- "productId" : self.productId,
138
- "activityId" : self.activityId
139
- });
140
- url = helpers.api.addClassIdQueryParam(url, self.classId);
141
- //Setup request with URL and Params
142
- var req = request.get(url);
143
-
144
- //Setup token in Authorization header
145
- req = helpers.api.setupAPIToken(req, self.token);
146
-
147
- // Setting trace id
148
- if(self.traceid) { req.set('X-Amzn-Trace-Id', self.traceid); }
149
-
150
- //Call GET activity details Api
151
- req.end(function (err, response) {
152
- if (err) {
153
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
154
- dfd.reject(err);
155
- } else {
156
- var responseBody = response.body;
157
- var resObject = new Object();
158
- resObject.questions = responseBody.items;
159
- dfd.resolve(resObject);
160
- }
161
- });
162
- }
163
- return dfd.promise;
164
- }
165
-
166
- Activity.prototype.getQuestionsCount = function () {
167
- var self = this;
168
-
169
- //Initializing promise
170
- var dfd = q.defer();
171
-
172
- //Validations
173
- var err = helpers.validations.isAuthenticated(this.orgId, this.token);
174
- if (err) {
175
- dfd.reject(err);
176
- } else {
177
-
178
- //Passed all validations, Contruct API url
179
- var url = self.config.DEFAULT_HOSTS['PRODUCT'] + self.config.PRODUCT_API_URLS.activityAPI;
180
- url = helpers.api.constructAPIUrl(url, {
181
- "orgId" : self.orgId,
182
- "productId" : self.productId,
183
- "activityId" : self.activityId
184
- });
185
- url = helpers.api.addClassIdQueryParam(url, self.classId);
186
- //Setup request with URL and Params
187
- var req = request.get(url);
188
-
189
- //Setup token in Authorization header
190
- req = helpers.api.setupAPIToken(req, self.token);
191
-
192
- // Setting trace id
193
- if(self.traceid) { req.set('X-Amzn-Trace-Id', self.traceid); }
194
-
195
- //Call GET activity details Api
196
- req.end(function (err, response) {
197
- if (err) {
198
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
199
- dfd.reject(err);
200
- } else {
201
- var responseBody = {"count": response.body.items.length};
202
- var resObject = new Object();
203
- resObject.count = responseBody;
204
- dfd.resolve(resObject);
205
- }
206
- });
207
- }
208
- return dfd.promise;
209
- }