comprodls-sdk 2.90.3-development → 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.
- package/README.md +1 -137
- package/dist/comprodls-sdk.js +2917 -6291
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/comprodls.js +39 -57
- package/lib/config/index.js +172 -198
- package/lib/helpers/index.js +3 -2
- package/lib/helpers/lib/api/converter.js +1 -2
- package/lib/helpers/lib/api/index.js +19 -94
- package/lib/helpers/lib/errors.js +75 -80
- package/lib/helpers/lib/requestLayer.js +154 -0
- package/lib/helpers/lib/validator.js +65 -52
- package/lib/open_access/index.js +48 -53
- package/lib/services/analytics/index.js +286 -1014
- package/lib/services/attempts/index.js +38 -88
- package/lib/services/auth/index.js +324 -806
- package/lib/services/authextn/index.js +85 -247
- package/lib/services/datasyncmanager/index.js +10 -45
- package/lib/services/drive/index.js +20 -83
- package/lib/services/integrations/index.js +51 -126
- package/lib/services/invitations/index.js +20 -61
- package/lib/services/product/index.js +82 -85
- package/lib/services/pub/index.js +167 -235
- package/lib/services/pushX/index.js +195 -142
- package/lib/services/pushX/pubnubClientWrapper.js +399 -172
- package/lib/services/rules/index.js +14 -67
- package/lib/services/spaces/index.js +106 -289
- package/lib/services/spacesextn/index.js +44 -20
- package/lib/services/superuser/index.js +21 -36
- package/lib/services/taxonomy/index.js +27 -57
- package/lib/services/workflows/index.js +38 -97
- package/lib/services/xapi/index.js +7 -168
- package/lib/token/index.js +73 -67
- package/lib/token/validations.js +45 -48
- package/package.json +2 -3
- package/lib/helpers/lib/api/validations.js +0 -73
- package/lib/helpers/lib/utils.js +0 -24
- package/lib/services/activity/activity.js +0 -209
- package/lib/services/activity/attempt.js +0 -431
- package/lib/services/activity/index.js +0 -28
- package/lib/services/auth/classProduct.js +0 -37
- package/lib/services/collab/index.js +0 -468
- package/test.js +0 -38
|
@@ -23,31 +23,32 @@
|
|
|
23
23
|
* Functions for calling PUSHX.
|
|
24
24
|
************************************************************/
|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
var q = require('q');
|
|
28
27
|
var request = require('superagent');
|
|
28
|
+
var Agent = require('agentkeepalive');
|
|
29
29
|
|
|
30
30
|
var helpers = require('../../helpers');
|
|
31
31
|
var pubnubClientWrapper = require('./pubnubClientWrapper');
|
|
32
32
|
var DLSError = helpers.errors.DLSError;
|
|
33
33
|
|
|
34
|
-
/*********************************
|
|
35
|
-
* Setting Up Module Entry Point
|
|
36
|
-
**********************************/
|
|
37
34
|
module.exports = pushX;
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
var keepaliveAgent = new Agent({
|
|
37
|
+
timeout: 60000,
|
|
38
|
+
freeSocketTimeout: 30000
|
|
39
|
+
});
|
|
40
|
+
|
|
42
41
|
function pushX() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
var _pubnubClientWrapper = pubnubClientWrapper();
|
|
43
|
+
return {
|
|
44
|
+
connect: _connect.bind(this, _pubnubClientWrapper),
|
|
45
|
+
cleanup: _cleanup.bind(this, _pubnubClientWrapper),
|
|
46
|
+
grantByUserOrgId: grantByUserOrgId.bind(this),
|
|
47
|
+
grantByAccountId: grantByAccountId.bind(this),
|
|
48
|
+
grantByAccountIdOnExtUserId: grantByAccountIdOnExtUserId.bind(this),
|
|
49
|
+
grantV2: grantV2.bind(this),
|
|
50
|
+
getPushedEvents: getPushedEvents.bind(this)
|
|
51
|
+
};
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/*********************************
|
|
@@ -55,144 +56,196 @@ function pushX() {
|
|
|
55
56
|
**********************************/
|
|
56
57
|
|
|
57
58
|
function _connect(pubnubCW, options) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
|
|
60
|
+
if (bpubnubV7 && !options.userid) {
|
|
61
|
+
var err = {};
|
|
62
|
+
err.message = err.description = 'Mandatory parameter userid not found in request options.';
|
|
63
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.PUSHX_ERROR, err);
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Adding SSL flag
|
|
68
|
+
return pubnubCW.setup({
|
|
69
|
+
'userid': options.userid,
|
|
70
|
+
'accountid': options.accountid,
|
|
71
|
+
'token': options.token,
|
|
72
|
+
'pubnub': {
|
|
73
|
+
'publishKey': options.publishKey,
|
|
74
|
+
'subscribeKey': options.subscribeKey,
|
|
75
|
+
'ssl': true,
|
|
76
|
+
'suppressLeaveEvents': true
|
|
77
|
+
},
|
|
78
|
+
'pollingEndpoint': options.pollingEndpoint,
|
|
79
|
+
'pollingIterations': options.pollingIterations || 10, // Default polling iterations is 10
|
|
80
|
+
'pollingInterval': options.pollingInterval, // Default polling interval is exponential backoff
|
|
81
|
+
});
|
|
76
82
|
}
|
|
77
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Wiki Link for SDK params
|
|
86
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/19_PUSHX-Adapter#cleanup
|
|
87
|
+
*/
|
|
78
88
|
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
79
89
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Wiki Link for SDK params
|
|
92
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/19_PUSHX-Adapter#get-user--org-level-grants
|
|
93
|
+
*/
|
|
83
94
|
function grantByUserOrgId(options) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
//Setup token in Authorization header
|
|
104
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
105
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
106
|
-
|
|
107
|
-
// Call Change Password Api
|
|
108
|
-
requestAPI.end(function(err, response) {
|
|
109
|
-
if(err) {
|
|
110
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
111
|
-
dfd.reject(err);
|
|
112
|
-
}
|
|
113
|
-
else { dfd.resolve(response.body); }
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
return dfd.promise;
|
|
95
|
+
var dfd = q.defer(); // Initializing promise
|
|
96
|
+
var allowedChannels = ['jobs', 'systemevents'];
|
|
97
|
+
var baseChannelName = "o-" + this.orgId + "\\$u-" + this.token.access_token + "\\$";
|
|
98
|
+
var patterns = [];
|
|
99
|
+
for(var i in allowedChannels) {
|
|
100
|
+
var channelName = baseChannelName + allowedChannels[i] + "\\..*";
|
|
101
|
+
patterns.push(channelName);
|
|
102
|
+
}
|
|
103
|
+
options.channels = {};
|
|
104
|
+
options.channels.patterns = patterns;
|
|
105
|
+
grantV2.call(this, options)
|
|
106
|
+
.then(function (res) {
|
|
107
|
+
dfd.resolve(res);
|
|
108
|
+
})
|
|
109
|
+
.catch(function(err) {
|
|
110
|
+
dfd.reject(err);
|
|
111
|
+
});
|
|
112
|
+
return dfd.promise;
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}*/
|
|
115
|
+
/**
|
|
116
|
+
* Wiki Link for SDK params
|
|
117
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/19_PUSHX-Adapter#get-account-level-grants
|
|
118
|
+
*/
|
|
124
119
|
function grantByAccountId(options) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
152
|
-
"not found in request options";
|
|
153
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
154
|
-
dfd.reject(err);
|
|
155
|
-
}
|
|
156
|
-
return dfd.promise;
|
|
120
|
+
var err ={};
|
|
121
|
+
var dfd = q.defer(); // Initializing promise
|
|
122
|
+
|
|
123
|
+
if(options.accountId && options.refId) {
|
|
124
|
+
var channel = "a-" + options.accountId + "$refid." + options.refId;
|
|
125
|
+
var exactMatch = [channel];
|
|
126
|
+
options.channels = {};
|
|
127
|
+
options.channels.exactMatch = exactMatch;
|
|
128
|
+
grantV2.call(this, options)
|
|
129
|
+
.then(function (res) {
|
|
130
|
+
dfd.resolve(res);
|
|
131
|
+
})
|
|
132
|
+
.catch(function(err) {
|
|
133
|
+
dfd.reject(err);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
138
|
+
"not found in request options";
|
|
139
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
140
|
+
dfd.reject(err);
|
|
141
|
+
}
|
|
142
|
+
return dfd.promise;
|
|
157
143
|
}
|
|
158
144
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}*/
|
|
145
|
+
/**
|
|
146
|
+
* Wiki Link for SDK params
|
|
147
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/19_PUSHX-Adapter#get-account-level-grants-on-extuserid
|
|
148
|
+
*/
|
|
164
149
|
function grantByAccountIdOnExtUserId(options) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
150
|
+
var err ={};
|
|
151
|
+
var dfd = q.defer(); // Initializing promise
|
|
152
|
+
|
|
153
|
+
if(options.accountId && options.extUserId) {
|
|
154
|
+
var channel = "a-" + options.accountId + "$u-" + options.extUserId;
|
|
155
|
+
var exactMatch = [channel];
|
|
156
|
+
options.channels = {};
|
|
157
|
+
options.channels.exactMatch = exactMatch;
|
|
158
|
+
grantV2.call(this, options)
|
|
159
|
+
.then(function (res) {
|
|
160
|
+
dfd.resolve(res);
|
|
161
|
+
})
|
|
162
|
+
.catch(function(err) {
|
|
163
|
+
dfd.reject(err);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
168
|
+
"not found in request options";
|
|
169
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
170
|
+
dfd.reject(err);
|
|
171
|
+
}
|
|
172
|
+
return dfd.promise;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* This function provides grant token on given channels
|
|
177
|
+
* Wiki Link for SDK params
|
|
178
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/19_PUSHX-Adapter#get-grant-token-for-the-access-manager-v3
|
|
179
|
+
*/
|
|
180
|
+
function grantV2(options) {
|
|
181
|
+
var self = this, err = {};
|
|
182
|
+
var dfd = q.defer();
|
|
183
|
+
var body = { channels: {} };
|
|
184
|
+
if(!options.channels) {
|
|
185
|
+
err.message = err.description = "channels not given in input body.";
|
|
186
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
187
|
+
dfd.reject(err);
|
|
196
188
|
return dfd.promise;
|
|
189
|
+
}
|
|
190
|
+
body.channels = options.channels;
|
|
191
|
+
// Passed all validations, Construct API url
|
|
192
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantV2;
|
|
193
|
+
// Setup request with URL and Params
|
|
194
|
+
var requestAPI = request.post(url)
|
|
195
|
+
.set('Content-Type', 'application/json')
|
|
196
|
+
.set('Accept', 'application/json');
|
|
197
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
198
|
+
|
|
199
|
+
requestAPI.send(body);
|
|
200
|
+
requestAPI.end(function(err, response) {
|
|
201
|
+
if(err) {
|
|
202
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
203
|
+
dfd.reject(err);
|
|
204
|
+
}
|
|
205
|
+
else { dfd.resolve(response.body); }
|
|
206
|
+
});
|
|
207
|
+
return dfd.promise;
|
|
197
208
|
}
|
|
198
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Wiki Link for SDK params
|
|
212
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/19_PUSHX-Adapter#getpushedeventsparams
|
|
213
|
+
*/
|
|
214
|
+
function getPushedEvents(options) {
|
|
215
|
+
var self = this;
|
|
216
|
+
var dfd = q.defer(); // Initializing promise
|
|
217
|
+
var accountid = options.accountid,
|
|
218
|
+
channelname = options.channelname,
|
|
219
|
+
starttime = options.starttime,
|
|
220
|
+
endtime = options.endtime;
|
|
221
|
+
|
|
222
|
+
if (accountid && channelname && starttime && endtime) {
|
|
223
|
+
// Passed all validations, Construct API url
|
|
224
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.getPushedEvents;
|
|
225
|
+
url = helpers.api.constructAPIUrl(url, { accountId: accountid });
|
|
226
|
+
|
|
227
|
+
// Setup request with URL and Params
|
|
228
|
+
var params = {channelname: channelname, starttime: starttime, endtime: endtime};
|
|
229
|
+
var requestAPI = request.get(url).query(params);
|
|
230
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
231
|
+
|
|
232
|
+
requestAPI
|
|
233
|
+
.agent(keepaliveAgent)
|
|
234
|
+
.end(function(error, response) {
|
|
235
|
+
if (error) {
|
|
236
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
237
|
+
dfd.reject(error);
|
|
238
|
+
} else {
|
|
239
|
+
dfd.resolve(response.body);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
var err = {};
|
|
245
|
+
err.message = err.description = 'Mandatory parameters [accountId, channelname,' +
|
|
246
|
+
' starttime, endtime] not found in request options';
|
|
247
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
248
|
+
dfd.reject(err);
|
|
249
|
+
}
|
|
250
|
+
return dfd.promise;
|
|
251
|
+
}
|