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
package/grunt/publish.js
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
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 Publish Task
|
|
23
|
-
* This task publishes/release new version of SDK to npm and bower.
|
|
24
|
-
* Releasing new version invloves following tasks:
|
|
25
|
-
* 1. Update package.json and bower.json with new tag/release number.
|
|
26
|
-
* 2. Commit above changes (master branch).
|
|
27
|
-
* 3. Create a new GIT release tag.
|
|
28
|
-
* 4. Push the new tag and master branch to origin.
|
|
29
|
-
* 5. Publish to NPM.
|
|
30
|
-
************************************************************/
|
|
31
|
-
|
|
32
|
-
var shell = require('shelljs');
|
|
33
|
-
var semver = require('semver');
|
|
34
|
-
|
|
35
|
-
module.exports = function(grunt) {
|
|
36
|
-
|
|
37
|
-
/* Grunt Task to publish/release new version of SDK to npm and bower.
|
|
38
|
-
* Params:
|
|
39
|
-
* tagnumber : new tag/release number
|
|
40
|
-
*/
|
|
41
|
-
grunt.registerTask('publish', 'Task to publish/release new version of SDK to npm and bower', function(tagnumber) {
|
|
42
|
-
|
|
43
|
-
//Get the options object
|
|
44
|
-
var options = this.options();
|
|
45
|
-
|
|
46
|
-
//Get the GIT access token from the environment variable.
|
|
47
|
-
var token = process.env[options.github_access_token];
|
|
48
|
-
|
|
49
|
-
//Construct URL of the repository.
|
|
50
|
-
var url = "https://" + token + "@github.com/comprodls/comprodls-sdk-js.git"
|
|
51
|
-
|
|
52
|
-
//Check whether the tagnumber is semantically valid
|
|
53
|
-
if (!tagnumber || !semver.valid(tagnumber)) {
|
|
54
|
-
//If tagnumber is not valid, throw error
|
|
55
|
-
grunt.fatal("Please enter a valid semver tagnumber");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
var checkTags = shell.exec('git ls-remote --tags', {silent: true}).stdout;
|
|
59
|
-
if(checkTags.indexOf('tags/v' + tagnumber) != -1) {
|
|
60
|
-
//If tagnumber is already present, throw error
|
|
61
|
-
grunt.fatal( tagnumber + " is already present");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//Function to update the version in package.json and bower.json
|
|
66
|
-
function updateVersion() {
|
|
67
|
-
//Read package.json and bower.json file
|
|
68
|
-
var pkg = grunt.file.readJSON('package.json');
|
|
69
|
-
var bower = grunt.file.readJSON('bower.json');
|
|
70
|
-
|
|
71
|
-
//Update version to specified tagnumber
|
|
72
|
-
pkg.version = tagnumber;
|
|
73
|
-
bower.version = tagnumber;
|
|
74
|
-
|
|
75
|
-
//Save package.json file
|
|
76
|
-
grunt.file.write('package.json', JSON.stringify(pkg, null, " "));
|
|
77
|
-
grunt.log.ok('Updated version of package.json to ' + tagnumber);
|
|
78
|
-
|
|
79
|
-
//Save bower.json file
|
|
80
|
-
grunt.file.write('bower.json', JSON.stringify(bower, null, " "));
|
|
81
|
-
grunt.log.ok('Updated version of bower.json to ' + tagnumber);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
//Function to stage the changes.
|
|
85
|
-
function add() {
|
|
86
|
-
var cmd = 'git add --all';
|
|
87
|
-
return run(cmd, 'Staged all files');
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
//Function to commit the changes.
|
|
91
|
-
function commit() {
|
|
92
|
-
add();
|
|
93
|
-
var commitMessage = "Release " + tagnumber + " , Creating JS Bundle files and updating SDK version.";
|
|
94
|
-
var options = '-m "' + commitMessage + '"';
|
|
95
|
-
var cmd = 'git commit ' + options;
|
|
96
|
-
return run(cmd, 'Committed all files');
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
//Function to create a new tag with the updates
|
|
100
|
-
function tag() {
|
|
101
|
-
var tagName = "v" + tagnumber;
|
|
102
|
-
var tagMessage = tagnumber;
|
|
103
|
-
var cmd = 'git tag ' + tagName + ' -m "' + tagMessage + '"';
|
|
104
|
-
return run(cmd, 'Created new tag v' + tagnumber);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
//Function to push the changes in master branch to remote
|
|
108
|
-
function pushMaster() {
|
|
109
|
-
var cmd = "git push " + url + " master";
|
|
110
|
-
return run(cmd, 'Pushed branch master to remote');
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
//Function to push the latest tag to remote
|
|
114
|
-
function pushTag() {
|
|
115
|
-
var tagName = "v" + tagnumber;
|
|
116
|
-
var cmd = "git push " + url + " " + tagName;
|
|
117
|
-
var msg = "Pushed new Tag " + tagName + " to remote";
|
|
118
|
-
return run(cmd, msg);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
//Publish the latest tag to NPM.
|
|
122
|
-
function publishToNPM() {
|
|
123
|
-
var cmd = "npm publish";
|
|
124
|
-
var msg = "Published version " + tagnumber + " to npm";
|
|
125
|
-
return run(cmd, msg);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//Function to run shell commands.
|
|
129
|
-
function run(cmd, msg) {
|
|
130
|
-
var command = shell.exec(cmd, {silent: true});
|
|
131
|
-
console.log(command.code)
|
|
132
|
-
if (!command.code) {
|
|
133
|
-
grunt.log.ok(msg);
|
|
134
|
-
} else {
|
|
135
|
-
grunt.fatal('Execution failed for command=' + cmd + ', Message=' + command.stderr);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
//Excecuting all functions
|
|
140
|
-
(function() {
|
|
141
|
-
updateVersion();
|
|
142
|
-
commit();
|
|
143
|
-
tag();
|
|
144
|
-
pushMaster();
|
|
145
|
-
pushTag();
|
|
146
|
-
publishToNPM();
|
|
147
|
-
})();
|
|
148
|
-
});
|
|
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 Publish Task
|
|
23
|
+
* This task publishes/release new version of SDK to npm and bower.
|
|
24
|
+
* Releasing new version invloves following tasks:
|
|
25
|
+
* 1. Update package.json and bower.json with new tag/release number.
|
|
26
|
+
* 2. Commit above changes (master branch).
|
|
27
|
+
* 3. Create a new GIT release tag.
|
|
28
|
+
* 4. Push the new tag and master branch to origin.
|
|
29
|
+
* 5. Publish to NPM.
|
|
30
|
+
************************************************************/
|
|
31
|
+
|
|
32
|
+
var shell = require('shelljs');
|
|
33
|
+
var semver = require('semver');
|
|
34
|
+
|
|
35
|
+
module.exports = function(grunt) {
|
|
36
|
+
|
|
37
|
+
/* Grunt Task to publish/release new version of SDK to npm and bower.
|
|
38
|
+
* Params:
|
|
39
|
+
* tagnumber : new tag/release number
|
|
40
|
+
*/
|
|
41
|
+
grunt.registerTask('publish', 'Task to publish/release new version of SDK to npm and bower', function(tagnumber) {
|
|
42
|
+
|
|
43
|
+
//Get the options object
|
|
44
|
+
var options = this.options();
|
|
45
|
+
|
|
46
|
+
//Get the GIT access token from the environment variable.
|
|
47
|
+
var token = process.env[options.github_access_token];
|
|
48
|
+
|
|
49
|
+
//Construct URL of the repository.
|
|
50
|
+
var url = "https://" + token + "@github.com/comprodls/comprodls-sdk-js.git"
|
|
51
|
+
|
|
52
|
+
//Check whether the tagnumber is semantically valid
|
|
53
|
+
if (!tagnumber || !semver.valid(tagnumber)) {
|
|
54
|
+
//If tagnumber is not valid, throw error
|
|
55
|
+
grunt.fatal("Please enter a valid semver tagnumber");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var checkTags = shell.exec('git ls-remote --tags', {silent: true}).stdout;
|
|
59
|
+
if(checkTags.indexOf('tags/v' + tagnumber) != -1) {
|
|
60
|
+
//If tagnumber is already present, throw error
|
|
61
|
+
grunt.fatal( tagnumber + " is already present");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
//Function to update the version in package.json and bower.json
|
|
66
|
+
function updateVersion() {
|
|
67
|
+
//Read package.json and bower.json file
|
|
68
|
+
var pkg = grunt.file.readJSON('package.json');
|
|
69
|
+
var bower = grunt.file.readJSON('bower.json');
|
|
70
|
+
|
|
71
|
+
//Update version to specified tagnumber
|
|
72
|
+
pkg.version = tagnumber;
|
|
73
|
+
bower.version = tagnumber;
|
|
74
|
+
|
|
75
|
+
//Save package.json file
|
|
76
|
+
grunt.file.write('package.json', JSON.stringify(pkg, null, " "));
|
|
77
|
+
grunt.log.ok('Updated version of package.json to ' + tagnumber);
|
|
78
|
+
|
|
79
|
+
//Save bower.json file
|
|
80
|
+
grunt.file.write('bower.json', JSON.stringify(bower, null, " "));
|
|
81
|
+
grunt.log.ok('Updated version of bower.json to ' + tagnumber);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//Function to stage the changes.
|
|
85
|
+
function add() {
|
|
86
|
+
var cmd = 'git add --all';
|
|
87
|
+
return run(cmd, 'Staged all files');
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//Function to commit the changes.
|
|
91
|
+
function commit() {
|
|
92
|
+
add();
|
|
93
|
+
var commitMessage = "Release " + tagnumber + " , Creating JS Bundle files and updating SDK version.";
|
|
94
|
+
var options = '-m "' + commitMessage + '"';
|
|
95
|
+
var cmd = 'git commit ' + options;
|
|
96
|
+
return run(cmd, 'Committed all files');
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
//Function to create a new tag with the updates
|
|
100
|
+
function tag() {
|
|
101
|
+
var tagName = "v" + tagnumber;
|
|
102
|
+
var tagMessage = tagnumber;
|
|
103
|
+
var cmd = 'git tag ' + tagName + ' -m "' + tagMessage + '"';
|
|
104
|
+
return run(cmd, 'Created new tag v' + tagnumber);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
//Function to push the changes in master branch to remote
|
|
108
|
+
function pushMaster() {
|
|
109
|
+
var cmd = "git push " + url + " master";
|
|
110
|
+
return run(cmd, 'Pushed branch master to remote');
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
//Function to push the latest tag to remote
|
|
114
|
+
function pushTag() {
|
|
115
|
+
var tagName = "v" + tagnumber;
|
|
116
|
+
var cmd = "git push " + url + " " + tagName;
|
|
117
|
+
var msg = "Pushed new Tag " + tagName + " to remote";
|
|
118
|
+
return run(cmd, msg);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
//Publish the latest tag to NPM.
|
|
122
|
+
function publishToNPM() {
|
|
123
|
+
var cmd = "npm publish";
|
|
124
|
+
var msg = "Published version " + tagnumber + " to npm";
|
|
125
|
+
return run(cmd, msg);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//Function to run shell commands.
|
|
129
|
+
function run(cmd, msg) {
|
|
130
|
+
var command = shell.exec(cmd, {silent: true});
|
|
131
|
+
console.log(command.code)
|
|
132
|
+
if (!command.code) {
|
|
133
|
+
grunt.log.ok(msg);
|
|
134
|
+
} else {
|
|
135
|
+
grunt.fatal('Execution failed for command=' + cmd + ', Message=' + command.stderr);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
//Excecuting all functions
|
|
140
|
+
(function() {
|
|
141
|
+
updateVersion();
|
|
142
|
+
commit();
|
|
143
|
+
tag();
|
|
144
|
+
pushMaster();
|
|
145
|
+
pushTag();
|
|
146
|
+
publishToNPM();
|
|
147
|
+
})();
|
|
148
|
+
});
|
|
149
149
|
};
|
package/lib/comprodls.js
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
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 Main Module
|
|
22
|
-
* This module provides definition of SDK for Javascript
|
|
23
|
-
************************************************************/
|
|
24
|
-
var token_manager = require('./token');
|
|
25
|
-
var helpers = require('./helpers');
|
|
26
|
-
var auth = require('./services/auth');
|
|
27
|
-
var activity = require('./services/activity');
|
|
28
|
-
var analytics = require('./services/analytics');
|
|
29
|
-
var collab = require('./services/collab');
|
|
30
|
-
var product = require('./services/product');
|
|
31
|
-
var xapi = require('./services/xapi');
|
|
32
|
-
var attempts = require('./services/attempts');
|
|
33
|
-
var push = require('./services/push');
|
|
34
|
-
var pushX = require('./services/pushX');
|
|
35
|
-
var pub = require('./services/pub');
|
|
36
|
-
var sisevents = require('./services/sisevents');
|
|
37
|
-
var lrs = require('./services/lrs');
|
|
38
|
-
var spaces = require('./services/spaces');
|
|
39
|
-
var config = require('./config');
|
|
40
|
-
var open_access = require('./open_access');
|
|
41
|
-
var superuser = require('./services/superuser');
|
|
42
|
-
var invitations = require('./services/invitations');
|
|
43
|
-
var workflows = require('./services/workflows');
|
|
44
|
-
var integrations = require('./services/integrations');
|
|
45
|
-
var validations = require('./token/validations');
|
|
46
|
-
var drive = require('./services/drive');
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/*********************************
|
|
50
|
-
* Setting Up Module Entry Point
|
|
51
|
-
**********************************/
|
|
52
|
-
exports.init = init;
|
|
53
|
-
|
|
54
|
-
//Factory function to create and return a new SDK object/instance
|
|
55
|
-
function init(environment, realm, options) {
|
|
56
|
-
return new comproDLS(environment, realm, options);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// Constructor for the SDK object
|
|
60
|
-
function comproDLS(environment, realm, options) {
|
|
61
|
-
options = options || {};
|
|
62
|
-
environment = environment || 'production';
|
|
63
|
-
realm = realm || 'global';
|
|
64
|
-
/*
|
|
65
|
-
* Instance level parameters, used across all API calls. These are set to null.
|
|
66
|
-
* Either authWithToken or authWithCredentials must be called to set these
|
|
67
|
-
* with valid values.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
/* API Token is a JSON Object with following structure
|
|
71
|
-
* {
|
|
72
|
-
* "access_token" : [String]
|
|
73
|
-
* }
|
|
74
|
-
*/
|
|
75
|
-
this.token = null;
|
|
76
|
-
|
|
77
|
-
//Organization Id
|
|
78
|
-
this.orgId = null;
|
|
79
|
-
this.traceid = options.traceid;
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
config.DEFAULT_HOSTS = config.REALM_HOSTS[realm.toUpperCase()][environment.toUpperCase()];
|
|
83
|
-
if(!config.DEFAULT_HOSTS){ throw 'Invalid Environment'; }
|
|
84
|
-
}
|
|
85
|
-
catch (e){
|
|
86
|
-
var realmObj = config.REALM_HOSTS[realm.toUpperCase()];
|
|
87
|
-
var err;
|
|
88
|
-
|
|
89
|
-
if(!realmObj) { err = new Error('Invalid Realm: ' + realm); }
|
|
90
|
-
else if(!realmObj[environment.toUpperCase()]) {
|
|
91
|
-
err = new Error('Invalid Environment: ' + environment);
|
|
92
|
-
}
|
|
93
|
-
throw err;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.config = config;
|
|
97
|
-
this.environment = environment;
|
|
98
|
-
|
|
99
|
-
if(options.orgid && options.token) {
|
|
100
|
-
var err = validations.authWithToken(options.orgid, options.token, {});
|
|
101
|
-
if (err) { throw err; }
|
|
102
|
-
else {
|
|
103
|
-
this.token = options.token;
|
|
104
|
-
this.orgId = options.orgid;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// This is the case when api requires orgid but not token
|
|
108
|
-
else if(options.orgid) {
|
|
109
|
-
this.orgId = options.orgid;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/****************************************
|
|
114
|
-
* Setting Up SDK Public Functions/Objects
|
|
115
|
-
*****************************************/
|
|
116
|
-
//Token Management
|
|
117
|
-
comproDLS.prototype.authWithCredentials = token_manager.authWithCredentials;
|
|
118
|
-
comproDLS.prototype.authWithToken = token_manager.authWithToken;
|
|
119
|
-
comproDLS.prototype.authWithExtUser = token_manager.authWithExtUser;
|
|
120
|
-
|
|
121
|
-
//Open Access SDK Functions
|
|
122
|
-
comproDLS.prototype.getClassEnrolmentsStat = open_access.getClassEnrolmentsStat;
|
|
123
|
-
comproDLS.prototype.getSingleInvitation = open_access.getSingleInvitation;
|
|
124
|
-
|
|
125
|
-
//Generic API Caller / Adaptor
|
|
126
|
-
comproDLS.prototype.request = helpers.api.genericAPICaller;
|
|
127
|
-
|
|
128
|
-
//Custom Service Adaptors
|
|
129
|
-
comproDLS.prototype.Auth = auth;
|
|
130
|
-
comproDLS.prototype.Activity = activity;
|
|
131
|
-
comproDLS.prototype.Analytics = analytics;
|
|
132
|
-
comproDLS.prototype.Collab = collab;
|
|
133
|
-
comproDLS.prototype.Product = product;
|
|
134
|
-
comproDLS.prototype.Xapi = xapi;
|
|
135
|
-
comproDLS.prototype.Attempts = attempts;
|
|
136
|
-
comproDLS.prototype.Push = push;
|
|
137
|
-
comproDLS.prototype.Pub = pub;
|
|
138
|
-
comproDLS.prototype.SISEvents = sisevents;
|
|
139
|
-
comproDLS.prototype.LRS = lrs;
|
|
140
|
-
comproDLS.prototype.PushX = pushX;
|
|
141
|
-
comproDLS.prototype.Spaces = spaces;
|
|
142
|
-
comproDLS.prototype.Superuser = superuser;
|
|
143
|
-
comproDLS.prototype.Invitations = invitations;
|
|
144
|
-
comproDLS.prototype.Workflows = workflows;
|
|
145
|
-
comproDLS.prototype.Integrations = integrations;
|
|
146
|
-
comproDLS.prototype.Drive = drive;
|
|
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 Main Module
|
|
22
|
+
* This module provides definition of SDK for Javascript
|
|
23
|
+
************************************************************/
|
|
24
|
+
var token_manager = require('./token');
|
|
25
|
+
var helpers = require('./helpers');
|
|
26
|
+
var auth = require('./services/auth');
|
|
27
|
+
var activity = require('./services/activity');
|
|
28
|
+
var analytics = require('./services/analytics');
|
|
29
|
+
var collab = require('./services/collab');
|
|
30
|
+
var product = require('./services/product');
|
|
31
|
+
var xapi = require('./services/xapi');
|
|
32
|
+
var attempts = require('./services/attempts');
|
|
33
|
+
var push = require('./services/push');
|
|
34
|
+
var pushX = require('./services/pushX');
|
|
35
|
+
var pub = require('./services/pub');
|
|
36
|
+
var sisevents = require('./services/sisevents');
|
|
37
|
+
var lrs = require('./services/lrs');
|
|
38
|
+
var spaces = require('./services/spaces');
|
|
39
|
+
var config = require('./config');
|
|
40
|
+
var open_access = require('./open_access');
|
|
41
|
+
var superuser = require('./services/superuser');
|
|
42
|
+
var invitations = require('./services/invitations');
|
|
43
|
+
var workflows = require('./services/workflows');
|
|
44
|
+
var integrations = require('./services/integrations');
|
|
45
|
+
var validations = require('./token/validations');
|
|
46
|
+
var drive = require('./services/drive');
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/*********************************
|
|
50
|
+
* Setting Up Module Entry Point
|
|
51
|
+
**********************************/
|
|
52
|
+
exports.init = init;
|
|
53
|
+
|
|
54
|
+
//Factory function to create and return a new SDK object/instance
|
|
55
|
+
function init(environment, realm, options) {
|
|
56
|
+
return new comproDLS(environment, realm, options);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Constructor for the SDK object
|
|
60
|
+
function comproDLS(environment, realm, options) {
|
|
61
|
+
options = options || {};
|
|
62
|
+
environment = environment || 'production';
|
|
63
|
+
realm = realm || 'global';
|
|
64
|
+
/*
|
|
65
|
+
* Instance level parameters, used across all API calls. These are set to null.
|
|
66
|
+
* Either authWithToken or authWithCredentials must be called to set these
|
|
67
|
+
* with valid values.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/* API Token is a JSON Object with following structure
|
|
71
|
+
* {
|
|
72
|
+
* "access_token" : [String]
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
this.token = null;
|
|
76
|
+
|
|
77
|
+
//Organization Id
|
|
78
|
+
this.orgId = null;
|
|
79
|
+
this.traceid = options.traceid;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
config.DEFAULT_HOSTS = config.REALM_HOSTS[realm.toUpperCase()][environment.toUpperCase()];
|
|
83
|
+
if(!config.DEFAULT_HOSTS){ throw 'Invalid Environment'; }
|
|
84
|
+
}
|
|
85
|
+
catch (e){
|
|
86
|
+
var realmObj = config.REALM_HOSTS[realm.toUpperCase()];
|
|
87
|
+
var err;
|
|
88
|
+
|
|
89
|
+
if(!realmObj) { err = new Error('Invalid Realm: ' + realm); }
|
|
90
|
+
else if(!realmObj[environment.toUpperCase()]) {
|
|
91
|
+
err = new Error('Invalid Environment: ' + environment);
|
|
92
|
+
}
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.config = config;
|
|
97
|
+
this.environment = environment;
|
|
98
|
+
|
|
99
|
+
if(options.orgid && options.token) {
|
|
100
|
+
var err = validations.authWithToken(options.orgid, options.token, {});
|
|
101
|
+
if (err) { throw err; }
|
|
102
|
+
else {
|
|
103
|
+
this.token = options.token;
|
|
104
|
+
this.orgId = options.orgid;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// This is the case when api requires orgid but not token
|
|
108
|
+
else if(options.orgid) {
|
|
109
|
+
this.orgId = options.orgid;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/****************************************
|
|
114
|
+
* Setting Up SDK Public Functions/Objects
|
|
115
|
+
*****************************************/
|
|
116
|
+
//Token Management
|
|
117
|
+
comproDLS.prototype.authWithCredentials = token_manager.authWithCredentials;
|
|
118
|
+
comproDLS.prototype.authWithToken = token_manager.authWithToken;
|
|
119
|
+
comproDLS.prototype.authWithExtUser = token_manager.authWithExtUser;
|
|
120
|
+
|
|
121
|
+
//Open Access SDK Functions
|
|
122
|
+
comproDLS.prototype.getClassEnrolmentsStat = open_access.getClassEnrolmentsStat;
|
|
123
|
+
comproDLS.prototype.getSingleInvitation = open_access.getSingleInvitation;
|
|
124
|
+
|
|
125
|
+
//Generic API Caller / Adaptor
|
|
126
|
+
comproDLS.prototype.request = helpers.api.genericAPICaller;
|
|
127
|
+
|
|
128
|
+
//Custom Service Adaptors
|
|
129
|
+
comproDLS.prototype.Auth = auth;
|
|
130
|
+
comproDLS.prototype.Activity = activity;
|
|
131
|
+
comproDLS.prototype.Analytics = analytics;
|
|
132
|
+
comproDLS.prototype.Collab = collab;
|
|
133
|
+
comproDLS.prototype.Product = product;
|
|
134
|
+
comproDLS.prototype.Xapi = xapi;
|
|
135
|
+
comproDLS.prototype.Attempts = attempts;
|
|
136
|
+
comproDLS.prototype.Push = push;
|
|
137
|
+
comproDLS.prototype.Pub = pub;
|
|
138
|
+
comproDLS.prototype.SISEvents = sisevents;
|
|
139
|
+
comproDLS.prototype.LRS = lrs;
|
|
140
|
+
comproDLS.prototype.PushX = pushX;
|
|
141
|
+
comproDLS.prototype.Spaces = spaces;
|
|
142
|
+
comproDLS.prototype.Superuser = superuser;
|
|
143
|
+
comproDLS.prototype.Invitations = invitations;
|
|
144
|
+
comproDLS.prototype.Workflows = workflows;
|
|
145
|
+
comproDLS.prototype.Integrations = integrations;
|
|
146
|
+
comproDLS.prototype.Drive = drive;
|