comprodls-sdk 2.64.1 → 2.67.0
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/dist/comprodls-sdk.js +262 -3
- package/dist/comprodls-sdk.min.js +15 -15
- package/lib/config/index.js +5 -1
- package/lib/services/authextn/index.js +257 -2
- package/package.json +3 -3
- package/test.js +38 -0
package/dist/comprodls-sdk.js
CHANGED
|
@@ -396,7 +396,11 @@ exports.AUTHEXTN_API_URLS = {
|
|
|
396
396
|
userAssignedPaths: '/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi',
|
|
397
397
|
|
|
398
398
|
// Class related APIs
|
|
399
|
-
particularClass: '/org/{orgId}/classes/{classId}'
|
|
399
|
+
particularClass: '/org/{orgId}/classes/{classId}',
|
|
400
|
+
|
|
401
|
+
// Org Entitlement related APIs
|
|
402
|
+
orgProductEntitlement: '/org/{orgid}/org-entitlements',
|
|
403
|
+
setupUser: '/accounts/{accountId}/user/setup'
|
|
400
404
|
|
|
401
405
|
};
|
|
402
406
|
|
|
@@ -8714,8 +8718,10 @@ var keepaliveAgent = new Agent({
|
|
|
8714
8718
|
});
|
|
8715
8719
|
|
|
8716
8720
|
//AuthExtn Adaptor Contsructor
|
|
8717
|
-
function authextn() {
|
|
8721
|
+
function authextn(accountId) {
|
|
8722
|
+
this.accountId = accountId;
|
|
8718
8723
|
return {
|
|
8724
|
+
// Gradeformat related APIs
|
|
8719
8725
|
createGradeformat: createGradeformat.bind(this),
|
|
8720
8726
|
updateGradeformat: updateGradeformat.bind(this),
|
|
8721
8727
|
deleteGradeformat: deleteGradeformat.bind(this),
|
|
@@ -8727,9 +8733,21 @@ function authextn() {
|
|
|
8727
8733
|
getParticularGradeformatOfAClass: getParticularGradeformatOfAClass.bind(this),
|
|
8728
8734
|
getAllGradeformatsOfAClass: getAllGradeformatsOfAClass.bind(this),
|
|
8729
8735
|
getClassesOfAGradeformat: getClassesOfAGradeformat.bind(this),
|
|
8736
|
+
|
|
8737
|
+
// Assigned-path related APIs
|
|
8730
8738
|
createUserAssignedPathEnrollments: createUserAssignedPathEnrollments.bind(this),
|
|
8731
8739
|
deleteUserAssignedPathEnrollments: deleteUserAssignedPathEnrollments.bind(this),
|
|
8732
|
-
|
|
8740
|
+
|
|
8741
|
+
// Class related APIs
|
|
8742
|
+
getParticularClassV2: getParticularClassV2.bind(this),
|
|
8743
|
+
|
|
8744
|
+
// Org Entitlement related APIs
|
|
8745
|
+
createOrgProductEntitlement: createOrgProductEntitlement.bind(this),
|
|
8746
|
+
updateOrgProductEntitlement: updateOrgProductEntitlement.bind(this),
|
|
8747
|
+
getParticularOrgProductEntitlement: getParticularOrgProductEntitlement.bind(this),
|
|
8748
|
+
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this),
|
|
8749
|
+
setupUser: setupUser.bind(this)
|
|
8750
|
+
|
|
8733
8751
|
};
|
|
8734
8752
|
}
|
|
8735
8753
|
|
|
@@ -9556,6 +9574,247 @@ function getParticularClassV2(options) {
|
|
|
9556
9574
|
|
|
9557
9575
|
return deferred.promise;
|
|
9558
9576
|
}
|
|
9577
|
+
|
|
9578
|
+
/**
|
|
9579
|
+
* @param {
|
|
9580
|
+
* *productcode: "string",
|
|
9581
|
+
* status: "string" // ['active', 'revoked'] - default: 'active'
|
|
9582
|
+
* expired: <boolean>, // default: false
|
|
9583
|
+
* startdate: <epoch>,
|
|
9584
|
+
* enddate: <epoch>,
|
|
9585
|
+
* audit: <boolean> // [true] - default: true
|
|
9586
|
+
* ext_data: {...},
|
|
9587
|
+
* } options
|
|
9588
|
+
*/
|
|
9589
|
+
function createOrgProductEntitlement(options) {
|
|
9590
|
+
var self = this;
|
|
9591
|
+
// Initializing promise
|
|
9592
|
+
var dfd = q.defer();
|
|
9593
|
+
|
|
9594
|
+
if (options && options.productcode) {
|
|
9595
|
+
// Passed all validations, Contruct API url
|
|
9596
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
9597
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
9598
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
9599
|
+
|
|
9600
|
+
var requestAPI = request.post(url)
|
|
9601
|
+
.set('Content-Type', 'application/json')
|
|
9602
|
+
.set('Accept', 'application/json')
|
|
9603
|
+
.send(options);
|
|
9604
|
+
|
|
9605
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9606
|
+
|
|
9607
|
+
requestAPI
|
|
9608
|
+
.agent(keepaliveAgent)
|
|
9609
|
+
.end(function(error, response) {
|
|
9610
|
+
if (error) {
|
|
9611
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
9612
|
+
dfd.reject(err);
|
|
9613
|
+
}
|
|
9614
|
+
else { dfd.resolve(response.body); }
|
|
9615
|
+
});
|
|
9616
|
+
} else {
|
|
9617
|
+
var err = {};
|
|
9618
|
+
err.message = err.description = 'Mandatory param: productcode not found in request options.';
|
|
9619
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
9620
|
+
dfd.reject(err);
|
|
9621
|
+
}
|
|
9622
|
+
|
|
9623
|
+
return dfd.promise;
|
|
9624
|
+
}
|
|
9625
|
+
|
|
9626
|
+
/**
|
|
9627
|
+
* @param {
|
|
9628
|
+
* *productcode: "string",
|
|
9629
|
+
* status: "string" // ['active', 'revoked']
|
|
9630
|
+
* expired: <boolean>,
|
|
9631
|
+
* startdate: <epoch>,
|
|
9632
|
+
* enddate: <epoch>,
|
|
9633
|
+
* audit: <boolean> // [true] - default: true
|
|
9634
|
+
* ext_data: {...},
|
|
9635
|
+
* } options
|
|
9636
|
+
*/
|
|
9637
|
+
function updateOrgProductEntitlement(options) {
|
|
9638
|
+
var self = this;
|
|
9639
|
+
// Initializing promise
|
|
9640
|
+
var dfd = q.defer();
|
|
9641
|
+
|
|
9642
|
+
if (options && options.productcode) {
|
|
9643
|
+
// Passed all validations, Contruct API url
|
|
9644
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
9645
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
9646
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
9647
|
+
|
|
9648
|
+
var requestAPI = request.put(url)
|
|
9649
|
+
.set('Content-Type', 'application/json')
|
|
9650
|
+
.set('Accept', 'application/json')
|
|
9651
|
+
.send(options);
|
|
9652
|
+
|
|
9653
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9654
|
+
|
|
9655
|
+
requestAPI
|
|
9656
|
+
.agent(keepaliveAgent)
|
|
9657
|
+
.end(function(error, response) {
|
|
9658
|
+
if (error) {
|
|
9659
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
9660
|
+
dfd.reject(err);
|
|
9661
|
+
}
|
|
9662
|
+
else { dfd.resolve(response.body); }
|
|
9663
|
+
});
|
|
9664
|
+
} else {
|
|
9665
|
+
var err = {};
|
|
9666
|
+
err.message = err.description = 'Mandatory param: productcode not found in request options.';
|
|
9667
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
9668
|
+
dfd.reject(err);
|
|
9669
|
+
}
|
|
9670
|
+
|
|
9671
|
+
return dfd.promise;
|
|
9672
|
+
}
|
|
9673
|
+
|
|
9674
|
+
/**
|
|
9675
|
+
* @param {
|
|
9676
|
+
* *productcode: "string"
|
|
9677
|
+
* } options
|
|
9678
|
+
*/
|
|
9679
|
+
function getParticularOrgProductEntitlement(options) {
|
|
9680
|
+
var self = this;
|
|
9681
|
+
//Initializing promise
|
|
9682
|
+
var deferred = q.defer();
|
|
9683
|
+
|
|
9684
|
+
//Validations
|
|
9685
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
9686
|
+
if (error) {
|
|
9687
|
+
deferred.reject(error);
|
|
9688
|
+
} else {
|
|
9689
|
+
if (options && options.productcode) {
|
|
9690
|
+
// Passed all validations, Contruct the API URL
|
|
9691
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
9692
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
9693
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
9694
|
+
|
|
9695
|
+
// Setup request with URL and Query Params
|
|
9696
|
+
var params = { productcode: options.productcode };
|
|
9697
|
+
var requestAPI = request.get(url).query(params);
|
|
9698
|
+
|
|
9699
|
+
// Setup 'traceid' in request header
|
|
9700
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9701
|
+
|
|
9702
|
+
// Setup 'token' in Authorization header
|
|
9703
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
9704
|
+
|
|
9705
|
+
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
9706
|
+
if (error) {
|
|
9707
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
9708
|
+
deferred.reject(error);
|
|
9709
|
+
} else {
|
|
9710
|
+
deferred.resolve(response.body);
|
|
9711
|
+
}
|
|
9712
|
+
});
|
|
9713
|
+
} else {
|
|
9714
|
+
error = {};
|
|
9715
|
+
error.message = error.description = 'Mandatory field \'productcode\' not found '+
|
|
9716
|
+
'in request options.';
|
|
9717
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
9718
|
+
deferred.reject(error);
|
|
9719
|
+
}
|
|
9720
|
+
}
|
|
9721
|
+
|
|
9722
|
+
return deferred.promise;
|
|
9723
|
+
}
|
|
9724
|
+
|
|
9725
|
+
/**
|
|
9726
|
+
* @param {
|
|
9727
|
+
* status: "string" // ['active', 'revoked']
|
|
9728
|
+
* expired: <boolean>,
|
|
9729
|
+
* cursor: <epoch>
|
|
9730
|
+
* } options
|
|
9731
|
+
*/
|
|
9732
|
+
function getAllOrgProductEntitlements(options) {
|
|
9733
|
+
var self = this;
|
|
9734
|
+
//Initializing promise
|
|
9735
|
+
var deferred = q.defer();
|
|
9736
|
+
|
|
9737
|
+
//Validations
|
|
9738
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
9739
|
+
if (error) {
|
|
9740
|
+
deferred.reject(error);
|
|
9741
|
+
} else {
|
|
9742
|
+
// Passed all validations, Contruct the API URL
|
|
9743
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
9744
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
9745
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
9746
|
+
|
|
9747
|
+
// Setup request with URL and Query Params
|
|
9748
|
+
var params = { productcode: options.productcode };
|
|
9749
|
+
|
|
9750
|
+
if (options.status) { params.status = options.status; }
|
|
9751
|
+
if (options.hasOwnProperty('expired')) { params.expired = options.expired; }
|
|
9752
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
9753
|
+
|
|
9754
|
+
var requestAPI = request.get(url).query(params);
|
|
9755
|
+
|
|
9756
|
+
// Setup 'traceid' in request header
|
|
9757
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9758
|
+
|
|
9759
|
+
// Setup 'token' in Authorization header
|
|
9760
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
9761
|
+
|
|
9762
|
+
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
9763
|
+
if (error) {
|
|
9764
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
9765
|
+
deferred.reject(error);
|
|
9766
|
+
} else {
|
|
9767
|
+
deferred.resolve(response.body);
|
|
9768
|
+
}
|
|
9769
|
+
});
|
|
9770
|
+
}
|
|
9771
|
+
|
|
9772
|
+
return deferred.promise;
|
|
9773
|
+
}
|
|
9774
|
+
|
|
9775
|
+
/**
|
|
9776
|
+
* @param {
|
|
9777
|
+
* ext_user_id: "string", // mandatory
|
|
9778
|
+
* workflow_type: "string", // mandatory
|
|
9779
|
+
* <workflow_type>: {} // mandatory
|
|
9780
|
+
* } options
|
|
9781
|
+
*/
|
|
9782
|
+
function setupUser(options) {
|
|
9783
|
+
var self = this;
|
|
9784
|
+
//Initializing promise
|
|
9785
|
+
var deferred = q.defer();
|
|
9786
|
+
|
|
9787
|
+
if(options && options.ext_user_id && options.workflow_type) {
|
|
9788
|
+
//Passed all validations, Contruct API url
|
|
9789
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
|
|
9790
|
+
url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
|
|
9791
|
+
|
|
9792
|
+
var requestAPI = request.post(url)
|
|
9793
|
+
.set('Content-Type', 'application/json')
|
|
9794
|
+
.set('Accept', 'application/json')
|
|
9795
|
+
.send(options);
|
|
9796
|
+
|
|
9797
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9798
|
+
|
|
9799
|
+
requestAPI
|
|
9800
|
+
.agent(keepaliveAgent)
|
|
9801
|
+
.end(function(err, res) {
|
|
9802
|
+
if(err) {
|
|
9803
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
9804
|
+
deferred.reject(err);
|
|
9805
|
+
} else {
|
|
9806
|
+
deferred.resolve(res.body);
|
|
9807
|
+
}
|
|
9808
|
+
});
|
|
9809
|
+
} else {
|
|
9810
|
+
err = {};
|
|
9811
|
+
err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
|
|
9812
|
+
'in the request options.';
|
|
9813
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
9814
|
+
deferred.reject(err);
|
|
9815
|
+
}
|
|
9816
|
+
return deferred.promise;
|
|
9817
|
+
}
|
|
9559
9818
|
|
|
9560
9819
|
},{"../../helpers":3,"agentkeepalive":36,"q":46,"superagent":49}],18:[function(require,module,exports){
|
|
9561
9820
|
/*************************************************************************
|