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.
- package/.eslintrc +28 -28
- package/.npmignore +5 -0
- package/README.md +371 -371
- package/dist/comprodls-sdk.js +11493 -11471
- package/dist/comprodls-sdk.min.js +14 -14
- package/grunt/publish.js +148 -148
- package/lib/comprodls.js +146 -146
- package/lib/config/index.js +337 -337
- package/lib/helpers/index.js +29 -29
- package/lib/helpers/lib/api/converter.js +119 -119
- package/lib/helpers/lib/api/index.js +120 -120
- package/lib/helpers/lib/api/validations.js +72 -72
- package/lib/helpers/lib/errors.js +129 -129
- package/lib/helpers/lib/utils.js +23 -23
- package/lib/helpers/lib/validator.js +100 -100
- package/lib/open_access/index.js +121 -121
- package/lib/services/activity/activity.js +209 -209
- package/lib/services/activity/attempt.js +431 -431
- package/lib/services/activity/index.js +28 -28
- package/lib/services/analytics/index.js +1555 -1555
- package/lib/services/attempts/index.js +342 -342
- package/lib/services/auth/classProduct.js +37 -37
- package/lib/services/auth/index.js +2541 -2541
- package/lib/services/collab/index.js +468 -468
- package/lib/services/drive/index.js +144 -144
- package/lib/services/integrations/index.js +279 -279
- package/lib/services/invitations/index.js +313 -313
- package/lib/services/lrs/index.js +459 -459
- package/lib/services/product/index.js +267 -267
- package/lib/services/pub/index.js +407 -407
- package/lib/services/push/index.js +187 -187
- package/lib/services/push/pubnubClientWrapper.js +557 -557
- package/lib/services/push/sessionStorage.js +64 -64
- package/lib/services/pushX/index.js +190 -190
- package/lib/services/pushX/pubnubClientWrapper.js +211 -211
- package/lib/services/sisevents/index.js +113 -113
- package/lib/services/spaces/index.js +976 -929
- package/lib/services/superuser/index.js +175 -175
- package/lib/services/workflows/index.js +464 -464
- package/lib/services/xapi/index.js +232 -232
- package/lib/token/index.js +114 -114
- package/lib/token/validations.js +88 -88
- package/package-lock.json +5095 -0
- package/package.json +1 -1
- package/test.js +50 -50
- package/.vscode/launch.json +0 -23
- package/npm-debug.log.189866131 +0 -0
- package/npm-debug.log.712840116 +0 -26
|
@@ -1,175 +1,175 @@
|
|
|
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 = superuser;
|
|
37
|
-
|
|
38
|
-
//Superuser Adaptor Contsructor
|
|
39
|
-
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
|
-
}*/
|
|
53
|
-
function getAllInstitutions(options) {
|
|
54
|
-
var self = this;
|
|
55
|
-
// Initializing promise
|
|
56
|
-
var dfd = q.defer();
|
|
57
|
-
|
|
58
|
-
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
59
|
-
self.config.AUTH_API_URLS.getAllInstitutions;
|
|
60
|
-
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
61
|
-
|
|
62
|
-
var params = {};
|
|
63
|
-
if(options) {
|
|
64
|
-
if(options.lookup) { params.lookup = options.lookup; }
|
|
65
|
-
if(options.cursor) { params.cursor = options.cursor; }
|
|
66
|
-
if(options.limit) { params.limit = options.limit; }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//Setup request with URL and Params
|
|
70
|
-
var requestAPI = request.get(url).query(params);
|
|
71
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
72
|
-
|
|
73
|
-
requestAPI.end(function(err, response) {
|
|
74
|
-
if(err) {
|
|
75
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
76
|
-
dfd.reject(err);
|
|
77
|
-
} else {
|
|
78
|
-
dfd.resolve(response.body);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return dfd.promise;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** This function gets a particular Instituion using the unique identifier (space_code)
|
|
86
|
-
* options = { "spacecode" : "string" }
|
|
87
|
-
*/
|
|
88
|
-
function getInstitution(options) {
|
|
89
|
-
var self = this;
|
|
90
|
-
// Initializing promise
|
|
91
|
-
var dfd = q.defer();
|
|
92
|
-
|
|
93
|
-
// Validations
|
|
94
|
-
if(options && options.spacecode) {
|
|
95
|
-
// Passed all validations, Contruct API url
|
|
96
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getInstitution;
|
|
97
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
98
|
-
accountid: self.accountId, spacecode: options.spacecode
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Setup request with URL and Params
|
|
102
|
-
var requestAPI = request.get(url);
|
|
103
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
104
|
-
|
|
105
|
-
requestAPI.end(function(error, response) {
|
|
106
|
-
if(error) {
|
|
107
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
108
|
-
dfd.reject(error);
|
|
109
|
-
}
|
|
110
|
-
else { dfd.resolve(response.body); }
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
var err = {};
|
|
115
|
-
err.message = err.description = 'spacecode not found in request options.';
|
|
116
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
117
|
-
dfd.reject(err);
|
|
118
|
-
}
|
|
119
|
-
return dfd.promise;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
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 })
|
|
137
|
-
*/
|
|
138
|
-
function provisionSpacesToSuperAdmin(options) {
|
|
139
|
-
var self = this;
|
|
140
|
-
// Initializing promise
|
|
141
|
-
var dfd = q.defer();
|
|
142
|
-
|
|
143
|
-
if(options && options.ext_user_id &&
|
|
144
|
-
options.ext_role && options.ext_email &&
|
|
145
|
-
options.ext_first_name && options.ext_last_name)
|
|
146
|
-
{
|
|
147
|
-
// Passed all validations, Contruct API url
|
|
148
|
-
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
149
|
-
self.config.AUTH_API_URLS.provisionSpacesToSuperAdmin;
|
|
150
|
-
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
151
|
-
|
|
152
|
-
// Setup request with URL and Params
|
|
153
|
-
var requestAPI = request.post(url)
|
|
154
|
-
.set('Content-Type', 'application/json')
|
|
155
|
-
.set('Accept', 'application/json')
|
|
156
|
-
.send(options);
|
|
157
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
158
|
-
|
|
159
|
-
requestAPI.end(function(error, response) {
|
|
160
|
-
if(error) {
|
|
161
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
162
|
-
dfd.reject(error);
|
|
163
|
-
}
|
|
164
|
-
else { dfd.resolve(response.body); }
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
var err = {};
|
|
169
|
-
err.message = err.description = 'Missing required input data';
|
|
170
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
171
|
-
dfd.reject(err);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return dfd.promise;
|
|
175
|
-
}
|
|
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 = superuser;
|
|
37
|
+
|
|
38
|
+
//Superuser Adaptor Contsructor
|
|
39
|
+
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
|
+
}*/
|
|
53
|
+
function getAllInstitutions(options) {
|
|
54
|
+
var self = this;
|
|
55
|
+
// Initializing promise
|
|
56
|
+
var dfd = q.defer();
|
|
57
|
+
|
|
58
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
59
|
+
self.config.AUTH_API_URLS.getAllInstitutions;
|
|
60
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
61
|
+
|
|
62
|
+
var params = {};
|
|
63
|
+
if(options) {
|
|
64
|
+
if(options.lookup) { params.lookup = options.lookup; }
|
|
65
|
+
if(options.cursor) { params.cursor = options.cursor; }
|
|
66
|
+
if(options.limit) { params.limit = options.limit; }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//Setup request with URL and Params
|
|
70
|
+
var requestAPI = request.get(url).query(params);
|
|
71
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
72
|
+
|
|
73
|
+
requestAPI.end(function(err, response) {
|
|
74
|
+
if(err) {
|
|
75
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
76
|
+
dfd.reject(err);
|
|
77
|
+
} else {
|
|
78
|
+
dfd.resolve(response.body);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return dfd.promise;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** This function gets a particular Instituion using the unique identifier (space_code)
|
|
86
|
+
* options = { "spacecode" : "string" }
|
|
87
|
+
*/
|
|
88
|
+
function getInstitution(options) {
|
|
89
|
+
var self = this;
|
|
90
|
+
// Initializing promise
|
|
91
|
+
var dfd = q.defer();
|
|
92
|
+
|
|
93
|
+
// Validations
|
|
94
|
+
if(options && options.spacecode) {
|
|
95
|
+
// Passed all validations, Contruct API url
|
|
96
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getInstitution;
|
|
97
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
98
|
+
accountid: self.accountId, spacecode: options.spacecode
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Setup request with URL and Params
|
|
102
|
+
var requestAPI = request.get(url);
|
|
103
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
104
|
+
|
|
105
|
+
requestAPI.end(function(error, response) {
|
|
106
|
+
if(error) {
|
|
107
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
108
|
+
dfd.reject(error);
|
|
109
|
+
}
|
|
110
|
+
else { dfd.resolve(response.body); }
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
var err = {};
|
|
115
|
+
err.message = err.description = 'spacecode not found in request options.';
|
|
116
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
117
|
+
dfd.reject(err);
|
|
118
|
+
}
|
|
119
|
+
return dfd.promise;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
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 })
|
|
137
|
+
*/
|
|
138
|
+
function provisionSpacesToSuperAdmin(options) {
|
|
139
|
+
var self = this;
|
|
140
|
+
// Initializing promise
|
|
141
|
+
var dfd = q.defer();
|
|
142
|
+
|
|
143
|
+
if(options && options.ext_user_id &&
|
|
144
|
+
options.ext_role && options.ext_email &&
|
|
145
|
+
options.ext_first_name && options.ext_last_name)
|
|
146
|
+
{
|
|
147
|
+
// Passed all validations, Contruct API url
|
|
148
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
149
|
+
self.config.AUTH_API_URLS.provisionSpacesToSuperAdmin;
|
|
150
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
151
|
+
|
|
152
|
+
// Setup request with URL and Params
|
|
153
|
+
var requestAPI = request.post(url)
|
|
154
|
+
.set('Content-Type', 'application/json')
|
|
155
|
+
.set('Accept', 'application/json')
|
|
156
|
+
.send(options);
|
|
157
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
158
|
+
|
|
159
|
+
requestAPI.end(function(error, response) {
|
|
160
|
+
if(error) {
|
|
161
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
162
|
+
dfd.reject(error);
|
|
163
|
+
}
|
|
164
|
+
else { dfd.resolve(response.body); }
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
var err = {};
|
|
169
|
+
err.message = err.description = 'Missing required input data';
|
|
170
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
171
|
+
dfd.reject(err);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return dfd.promise;
|
|
175
|
+
}
|