@memberjunction/actions-bizapps-lms 2.111.1 → 2.112.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -6
- package/dist/base/base-lms.action.d.ts +1 -1
- package/dist/base/base-lms.action.d.ts.map +1 -1
- package/dist/base/base-lms.action.js +15 -15
- package/dist/base/base-lms.action.js.map +1 -1
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts +1 -1
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/learnworlds-base.action.js +10 -10
- package/dist/providers/learnworlds/learnworlds-base.action.js.map +1 -1
- package/package.json +5 -6
- package/src/base/base-lms.action.ts +179 -172
- package/src/providers/learnworlds/learnworlds-base.action.ts +194 -194
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @memberjunction/actions-bizapps-lms
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.112.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- @memberjunction/
|
|
9
|
-
- @memberjunction/
|
|
10
|
-
- @memberjunction/
|
|
11
|
-
- @memberjunction/
|
|
7
|
+
- Updated dependencies [c126b59]
|
|
8
|
+
- @memberjunction/global@2.112.0
|
|
9
|
+
- @memberjunction/actions@2.112.0
|
|
10
|
+
- @memberjunction/actions-base@2.112.0
|
|
11
|
+
- @memberjunction/core-entities@2.112.0
|
|
12
12
|
|
|
13
13
|
## 2.110.1
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionParam } from '@memberjunction/actions-base';
|
|
2
2
|
import { BaseAction } from '@memberjunction/actions';
|
|
3
|
-
import { UserInfo } from '@memberjunction/
|
|
3
|
+
import { UserInfo } from '@memberjunction/global';
|
|
4
4
|
import { CompanyIntegrationEntity } from '@memberjunction/core-entities';
|
|
5
5
|
/**
|
|
6
6
|
* Base class for all LMS-related actions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-lms.action.d.ts","sourceRoot":"","sources":["../../src/base/base-lms.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"base-lms.action.d.ts","sourceRoot":"","sources":["../../src/base/base-lms.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE;;;GAGG;AACH,8BACsB,aAAc,SAAQ,UAAU;IACpD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAE3C;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAAyC;IAEpE;;OAEG;IACH,SAAS,CAAC,kBAAkB,IAAI,WAAW,EAAE;IAU7C;;OAEG;cACa,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA4BlH;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK7F;;OAEG;cACa,iBAAiB,CAC/B,WAAW,EAAE,wBAAwB,GACpC,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA6BzE;;OAEG;cACa,aAAa,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUrF;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG;IAKtE;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAI3C;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIhD;;OAEG;IACH,SAAS,CAAC,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAK/E;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAcjD;;OAEG;IACH,SAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,GAAG,GAAG,MAAM;IAQ7F;;OAEG;IACH,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS;CAa5G"}
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.BaseLMSAction = void 0;
|
|
10
10
|
const actions_1 = require("@memberjunction/actions");
|
|
11
11
|
const global_1 = require("@memberjunction/global");
|
|
12
|
-
const
|
|
12
|
+
const global_2 = require("@memberjunction/global");
|
|
13
13
|
/**
|
|
14
14
|
* Base class for all LMS-related actions.
|
|
15
15
|
* Provides common functionality and patterns for interacting with Learning Management Systems.
|
|
@@ -27,8 +27,8 @@ let BaseLMSAction = class BaseLMSAction extends actions_1.BaseAction {
|
|
|
27
27
|
{
|
|
28
28
|
Name: 'CompanyID',
|
|
29
29
|
Type: 'Input',
|
|
30
|
-
Value: null
|
|
31
|
-
}
|
|
30
|
+
Value: null,
|
|
31
|
+
},
|
|
32
32
|
];
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
@@ -39,11 +39,11 @@ let BaseLMSAction = class BaseLMSAction extends actions_1.BaseAction {
|
|
|
39
39
|
if (this._companyIntegration && this._companyIntegration.CompanyID === companyId) {
|
|
40
40
|
return this._companyIntegration;
|
|
41
41
|
}
|
|
42
|
-
const rv = new
|
|
42
|
+
const rv = new global_2.RunView();
|
|
43
43
|
const result = await rv.RunView({
|
|
44
44
|
EntityName: 'Company Integrations',
|
|
45
45
|
ExtraFilter: `CompanyID = '${companyId}' AND Integration.Name = '${this.integrationName}'`,
|
|
46
|
-
ResultType: 'entity_object'
|
|
46
|
+
ResultType: 'entity_object',
|
|
47
47
|
}, contextUser);
|
|
48
48
|
if (!result.Success) {
|
|
49
49
|
throw new Error(`Failed to retrieve company integration: ${result.ErrorMessage}`);
|
|
@@ -76,7 +76,7 @@ let BaseLMSAction = class BaseLMSAction extends actions_1.BaseAction {
|
|
|
76
76
|
return {
|
|
77
77
|
apiKey: envApiKey,
|
|
78
78
|
apiSecret: envApiSecret,
|
|
79
|
-
accessToken: envAccessToken
|
|
79
|
+
accessToken: envAccessToken,
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
// Fall back to database (for backwards compatibility)
|
|
@@ -85,7 +85,7 @@ let BaseLMSAction = class BaseLMSAction extends actions_1.BaseAction {
|
|
|
85
85
|
}
|
|
86
86
|
return {
|
|
87
87
|
apiKey: integration.APIKey || undefined,
|
|
88
|
-
accessToken: integration.AccessToken || undefined
|
|
88
|
+
accessToken: integration.AccessToken || undefined,
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -103,7 +103,7 @@ let BaseLMSAction = class BaseLMSAction extends actions_1.BaseAction {
|
|
|
103
103
|
* Helper to get parameter value with type safety
|
|
104
104
|
*/
|
|
105
105
|
getParamValue(params, paramName) {
|
|
106
|
-
const param = params.find(p => p.Name === paramName);
|
|
106
|
+
const param = params.find((p) => p.Name === paramName);
|
|
107
107
|
return param?.Value;
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
@@ -158,13 +158,13 @@ let BaseLMSAction = class BaseLMSAction extends actions_1.BaseAction {
|
|
|
158
158
|
*/
|
|
159
159
|
mapEnrollmentStatus(status) {
|
|
160
160
|
const statusMap = {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
active: 'active',
|
|
162
|
+
completed: 'completed',
|
|
163
|
+
finished: 'completed',
|
|
164
|
+
expired: 'expired',
|
|
165
|
+
suspended: 'suspended',
|
|
166
|
+
paused: 'suspended',
|
|
167
|
+
inactive: 'suspended',
|
|
168
168
|
};
|
|
169
169
|
return statusMap[status.toLowerCase()] || 'unknown';
|
|
170
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-lms.action.js","sourceRoot":"","sources":["../../src/base/base-lms.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,qDAAqD;AACrD,mDAAuD;AAGvD
|
|
1
|
+
{"version":3,"file":"base-lms.action.js","sourceRoot":"","sources":["../../src/base/base-lms.action.ts"],"names":[],"mappings":";;;;;;;;;AACA,qDAAqD;AACrD,mDAAuD;AAGvD,mDAA2D;AAE3D;;;GAGG;AAEI,IAAe,aAAa,GAA5B,MAAe,aAAc,SAAQ,oBAAU;IAWpD;;OAEG;IACK,mBAAmB,GAAoC,IAAI,CAAC;IAEpE;;OAEG;IACO,kBAAkB;QAC1B,OAAO;YACL;gBACE,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACZ;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,qBAAqB,CA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SAAS,GAAiF;YAC9F,MAAM,EAAE,QAAQ;YAChB,SAAS,EAAE,WAAW;YACtB,QAAQ,EAAE,WAAW;YACrB,OAAO,EAAE,SAAS;YAClB,SAAS,EAAE,WAAW;YACtB,MAAM,EAAE,WAAW;YACnB,QAAQ,EAAE,WAAW;SACtB,CAAC;QAEF,OAAO,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,SAAS,CAAC;IACtD,CAAC;CACF,CAAA;AA/LqB,sCAAa;wBAAb,aAAa;IADlC,IAAA,sBAAa,EAAC,oBAAU,EAAE,eAAe,CAAC;GACrB,aAAa,CA+LlC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseLMSAction } from '../../base/base-lms.action';
|
|
2
|
-
import { UserInfo } from '@memberjunction/
|
|
2
|
+
import { UserInfo } from '@memberjunction/global';
|
|
3
3
|
/**
|
|
4
4
|
* Base class for all LearnWorlds LMS actions.
|
|
5
5
|
* Handles LearnWorlds-specific authentication and API interaction patterns.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"learnworlds-base.action.d.ts","sourceRoot":"","sources":["../../../src/providers/learnworlds/learnworlds-base.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"learnworlds-base.action.d.ts","sourceRoot":"","sources":["../../../src/providers/learnworlds/learnworlds-base.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIlD;;;GAGG;AACH,8BACsB,qBAAsB,SAAQ,aAAa;IAC/D,SAAS,CAAC,WAAW,SAAiB;IACtC,SAAS,CAAC,eAAe,SAAiB;IAE1C;;OAEG;IACH,SAAS,CAAC,UAAU,SAAQ;IAE5B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;IAEtB;;OAEG;cACa,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAC5C,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAgB,EACjD,IAAI,CAAC,EAAE,GAAG,EACV,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,CAAC,CAAC;IA0Eb;;OAEG;cACa,+BAA+B,CAAC,CAAC,GAAG,GAAG,EACrD,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,WAAW,CAAC,EAAE,QAAQ,GACrB,OAAO,CAAC,CAAC,EAAE,CAAC;IA2Cf;;OAEG;IACH,SAAS,CAAC,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQjE;;OAEG;IACH,SAAS,CAAC,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAInD;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW;IAW5E;;OAEG;IACH,SAAS,CAAC,8BAA8B,CAAC,UAAU,EAAE,GAAG,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW;IAa3G;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,YAAY,EAAE,GAAG,GAAG;QAC9C,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB;CAQF"}
|
|
@@ -54,16 +54,16 @@ let LearnWorldsBaseAction = class LearnWorldsBaseAction extends base_lms_action_
|
|
|
54
54
|
const fullUrl = `${baseUrl}/${endpoint}`;
|
|
55
55
|
// Prepare headers
|
|
56
56
|
const headers = {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
Authorization: `Bearer ${credentials.apiKey}`,
|
|
58
|
+
Accept: 'application/json',
|
|
59
59
|
'Content-Type': 'application/json',
|
|
60
|
-
'Lw-Client': 'MemberJunction'
|
|
60
|
+
'Lw-Client': 'MemberJunction',
|
|
61
61
|
};
|
|
62
62
|
try {
|
|
63
63
|
const response = await fetch(fullUrl, {
|
|
64
64
|
method,
|
|
65
65
|
headers,
|
|
66
|
-
body: body ? JSON.stringify(body) : undefined
|
|
66
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
67
67
|
});
|
|
68
68
|
if (!response.ok) {
|
|
69
69
|
const errorText = await response.text();
|
|
@@ -104,7 +104,7 @@ let LearnWorldsBaseAction = class LearnWorldsBaseAction extends base_lms_action_
|
|
|
104
104
|
const queryParams = new URLSearchParams({
|
|
105
105
|
...params,
|
|
106
106
|
page: page.toString(),
|
|
107
|
-
limit: limit.toString()
|
|
107
|
+
limit: limit.toString(),
|
|
108
108
|
});
|
|
109
109
|
const response = await this.makeLearnWorldsRequest(`${endpoint}?${queryParams}`, 'GET', undefined, contextUser);
|
|
110
110
|
if (response.data && Array.isArray(response.data)) {
|
|
@@ -146,10 +146,10 @@ let LearnWorldsBaseAction = class LearnWorldsBaseAction extends base_lms_action_
|
|
|
146
146
|
*/
|
|
147
147
|
mapUserStatus(status) {
|
|
148
148
|
const statusMap = {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
active: 'active',
|
|
150
|
+
inactive: 'inactive',
|
|
151
|
+
suspended: 'suspended',
|
|
152
|
+
blocked: 'suspended',
|
|
153
153
|
};
|
|
154
154
|
return statusMap[status.toLowerCase()] || 'inactive';
|
|
155
155
|
}
|
|
@@ -176,7 +176,7 @@ let LearnWorldsBaseAction = class LearnWorldsBaseAction extends base_lms_action_
|
|
|
176
176
|
percentage: progressData.percentage || 0,
|
|
177
177
|
completedUnits: progressData.completed_units || 0,
|
|
178
178
|
totalUnits: progressData.total_units || 0,
|
|
179
|
-
timeSpent: progressData.time_spent || 0
|
|
179
|
+
timeSpent: progressData.time_spent || 0,
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"learnworlds-base.action.js","sourceRoot":"","sources":["../../../src/providers/learnworlds/learnworlds-base.action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AACvD,gEAA2D;AAG3D,qDAAqD;AAErD;;;GAGG;AAEI,IAAe,qBAAqB,GAApC,MAAe,qBAAsB,SAAQ,+BAAa;
|
|
1
|
+
{"version":3,"file":"learnworlds-base.action.js","sourceRoot":"","sources":["../../../src/providers/learnworlds/learnworlds-base.action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AACvD,gEAA2D;AAG3D,qDAAqD;AAErD;;;GAGG;AAEI,IAAe,qBAAqB,GAApC,MAAe,qBAAsB,SAAQ,+BAAa;IACrD,WAAW,GAAG,aAAa,CAAC;IAC5B,eAAe,GAAG,aAAa,CAAC;IAE1C;;OAEG;IACO,UAAU,GAAG,IAAI,CAAC;IAE5B;;OAEG;IACO,MAAM,CAAM;IAEtB;;OAEG;IACO,KAAK,CAAC,sBAAsB,CACpC,QAAgB,EAChB,SAA4C,KAAK,EACjD,IAAU,EACV,WAAsB;QAEtB,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QAED,oCAAoC;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,kCAAkC;QAClC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAE7E,kDAAkD;QAClD,MAAM,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OAAO,EAAE,WAAW;SACrB,CAAC;QAEF,OAAO,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,UAAU,CAAC;IACvD,CAAC;IAED;;OAEG;IACO,8BAA8B,CAAC,UAAe;QACtD,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;YACzB,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,UAAU,CAAC,SAAS,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC/C,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,YAAiB;QAM3C,OAAO;YACL,UAAU,EAAE,YAAY,CAAC,UAAU,IAAI,CAAC;YACxC,cAAc,EAAE,YAAY,CAAC,eAAe,IAAI,CAAC;YACjD,UAAU,EAAE,YAAY,CAAC,WAAW,IAAI,CAAC;YACzC,SAAS,EAAE,YAAY,CAAC,UAAU,IAAI,CAAC;SACxC,CAAC;IACJ,CAAC;CACF,CAAA;AAlNqB,sDAAqB;gCAArB,qBAAqB;IAD1C,IAAA,sBAAa,EAAC,oBAAU,EAAE,uBAAuB,CAAC;GAC7B,qBAAqB,CAkN1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/actions-bizapps-lms",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.112.0",
|
|
4
4
|
"description": "LMS system integration actions for MemberJunction",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
"author": "MemberJunction",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@memberjunction/
|
|
27
|
-
"@memberjunction/
|
|
28
|
-
"@memberjunction/actions
|
|
29
|
-
"@memberjunction/
|
|
30
|
-
"@memberjunction/core-entities": "2.111.1"
|
|
26
|
+
"@memberjunction/global": "2.112.0",
|
|
27
|
+
"@memberjunction/actions-base": "2.112.0",
|
|
28
|
+
"@memberjunction/actions": "2.112.0",
|
|
29
|
+
"@memberjunction/core-entities": "2.112.0"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
32
|
"@types/node": "20.8.7",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ActionParam } from '@memberjunction/actions-base';
|
|
2
2
|
import { BaseAction } from '@memberjunction/actions';
|
|
3
3
|
import { RegisterClass } from '@memberjunction/global';
|
|
4
|
-
import { UserInfo } from '@memberjunction/
|
|
4
|
+
import { UserInfo } from '@memberjunction/global';
|
|
5
5
|
import { CompanyIntegrationEntity } from '@memberjunction/core-entities';
|
|
6
|
-
import { Metadata, RunView } from '@memberjunction/
|
|
6
|
+
import { Metadata, RunView } from '@memberjunction/global';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Base class for all LMS-related actions.
|
|
@@ -11,187 +11,194 @@ import { Metadata, RunView } from '@memberjunction/core';
|
|
|
11
11
|
*/
|
|
12
12
|
@RegisterClass(BaseAction, 'BaseLMSAction')
|
|
13
13
|
export abstract class BaseLMSAction extends BaseAction {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The LMS provider this action is designed for (e.g., 'LearnWorlds', 'Moodle', etc.)
|
|
16
|
+
*/
|
|
17
|
+
protected abstract lmsProvider: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The integration name to look up in the Integration entity
|
|
21
|
+
*/
|
|
22
|
+
protected abstract integrationName: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Cached company integration for the current execution
|
|
26
|
+
*/
|
|
27
|
+
private _companyIntegration: CompanyIntegrationEntity | null = null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Common LMS parameters that many actions will need
|
|
31
|
+
*/
|
|
32
|
+
protected getCommonLMSParams(): ActionParam[] {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
Name: 'CompanyID',
|
|
36
|
+
Type: 'Input',
|
|
37
|
+
Value: null,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets the company integration record for the specified company and LMS
|
|
44
|
+
*/
|
|
45
|
+
protected async getCompanyIntegration(companyId: string, contextUser: UserInfo): Promise<CompanyIntegrationEntity> {
|
|
46
|
+
// Check cache first
|
|
47
|
+
if (this._companyIntegration && this._companyIntegration.CompanyID === companyId) {
|
|
48
|
+
return this._companyIntegration;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
ExtraFilter: `CompanyID = '${companyId}' AND Integration.Name = '${this.integrationName}'`,
|
|
55
|
-
ResultType: 'entity_object'
|
|
56
|
-
}, contextUser);
|
|
57
|
-
|
|
58
|
-
if (!result.Success) {
|
|
59
|
-
throw new Error(`Failed to retrieve company integration: ${result.ErrorMessage}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!result.Results || result.Results.length === 0) {
|
|
63
|
-
throw new Error(`No ${this.integrationName} integration found for company ${companyId}. Please configure the integration first.`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
this._companyIntegration = result.Results[0];
|
|
67
|
-
return this._companyIntegration;
|
|
51
|
+
const rv = new RunView();
|
|
52
|
+
const result = await rv.RunView<CompanyIntegrationEntity>(
|
|
53
|
+
{
|
|
54
|
+
EntityName: 'Company Integrations',
|
|
55
|
+
ExtraFilter: `CompanyID = '${companyId}' AND Integration.Name = '${this.integrationName}'`,
|
|
56
|
+
ResultType: 'entity_object',
|
|
57
|
+
},
|
|
58
|
+
contextUser
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (!result.Success) {
|
|
62
|
+
throw new Error(`Failed to retrieve company integration: ${result.ErrorMessage}`);
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* Format: BIZAPPS_{PROVIDER}_{COMPANY_ID}_{CREDENTIAL_TYPE}
|
|
73
|
-
* Example: BIZAPPS_LEARNWORLDS_12345_API_KEY
|
|
74
|
-
*/
|
|
75
|
-
protected getCredentialFromEnv(companyId: string, credentialType: string): string | undefined {
|
|
76
|
-
const envKey = `BIZAPPS_${this.lmsProvider.toUpperCase().replace(/\s+/g, '_')}_${companyId}_${credentialType.toUpperCase()}`;
|
|
77
|
-
return process.env[envKey];
|
|
65
|
+
if (!result.Results || result.Results.length === 0) {
|
|
66
|
+
throw new Error(`No ${this.integrationName} integration found for company ${companyId}. Please configure the integration first.`);
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
69
|
+
this._companyIntegration = result.Results[0];
|
|
70
|
+
return this._companyIntegration;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets credentials from environment variables
|
|
75
|
+
* Format: BIZAPPS_{PROVIDER}_{COMPANY_ID}_{CREDENTIAL_TYPE}
|
|
76
|
+
* Example: BIZAPPS_LEARNWORLDS_12345_API_KEY
|
|
77
|
+
*/
|
|
78
|
+
protected getCredentialFromEnv(companyId: string, credentialType: string): string | undefined {
|
|
79
|
+
const envKey = `BIZAPPS_${this.lmsProvider.toUpperCase().replace(/\s+/g, '_')}_${companyId}_${credentialType.toUpperCase()}`;
|
|
80
|
+
return process.env[envKey];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Gets API credentials - first tries environment variables, then falls back to database
|
|
85
|
+
*/
|
|
86
|
+
protected async getAPICredentials(
|
|
87
|
+
integration: CompanyIntegrationEntity
|
|
88
|
+
): Promise<{ apiKey?: string; apiSecret?: string; accessToken?: string }> {
|
|
89
|
+
const companyId = integration.CompanyID;
|
|
90
|
+
|
|
91
|
+
// Try environment variables first
|
|
92
|
+
const envApiKey = this.getCredentialFromEnv(companyId, 'API_KEY');
|
|
93
|
+
const envApiSecret = this.getCredentialFromEnv(companyId, 'API_SECRET');
|
|
94
|
+
const envAccessToken = this.getCredentialFromEnv(companyId, 'ACCESS_TOKEN');
|
|
95
|
+
|
|
96
|
+
if (envApiKey || envAccessToken) {
|
|
97
|
+
return {
|
|
98
|
+
apiKey: envApiKey,
|
|
99
|
+
apiSecret: envApiSecret,
|
|
100
|
+
accessToken: envAccessToken,
|
|
101
|
+
};
|
|
108
102
|
}
|
|
109
103
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (integration.CustomAttribute1) {
|
|
116
|
-
return integration.CustomAttribute1;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Return empty string - derived classes should override this
|
|
120
|
-
return '';
|
|
104
|
+
// Fall back to database (for backwards compatibility)
|
|
105
|
+
if (!integration.APIKey && !integration.AccessToken) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`No API credentials found for ${this.integrationName} integration. Please set environment variables or configure in database.`
|
|
108
|
+
);
|
|
121
109
|
}
|
|
122
110
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
111
|
+
return {
|
|
112
|
+
apiKey: integration.APIKey || undefined,
|
|
113
|
+
accessToken: integration.AccessToken || undefined,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Gets the base URL for API calls
|
|
119
|
+
*/
|
|
120
|
+
protected async getAPIBaseURL(integration: CompanyIntegrationEntity): Promise<string> {
|
|
121
|
+
// Check if custom URL is stored in the integration
|
|
122
|
+
if (integration.CustomAttribute1) {
|
|
123
|
+
return integration.CustomAttribute1;
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
// Return empty string - derived classes should override this
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Helper to get parameter value with type safety
|
|
132
|
+
*/
|
|
133
|
+
protected getParamValue(params: ActionParam[], paramName: string): any {
|
|
134
|
+
const param = params.find((p) => p.Name === paramName);
|
|
135
|
+
return param?.Value;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Standard date format for LMS systems (ISO 8601)
|
|
140
|
+
*/
|
|
141
|
+
protected formatLMSDate(date: Date): string {
|
|
142
|
+
return date.toISOString();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Parse date from LMS format
|
|
147
|
+
*/
|
|
148
|
+
protected parseLMSDate(dateString: string): Date {
|
|
149
|
+
return new Date(dateString);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Calculate progress percentage
|
|
154
|
+
*/
|
|
155
|
+
protected calculateProgressPercentage(completed: number, total: number): number {
|
|
156
|
+
if (total === 0) return 0;
|
|
157
|
+
return Math.round((completed / total) * 100);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Format duration in seconds to human readable format
|
|
162
|
+
*/
|
|
163
|
+
protected formatDuration(seconds: number): string {
|
|
164
|
+
const hours = Math.floor(seconds / 3600);
|
|
165
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
166
|
+
const secs = seconds % 60;
|
|
167
|
+
|
|
168
|
+
if (hours > 0) {
|
|
169
|
+
return `${hours}h ${minutes}m ${secs}s`;
|
|
170
|
+
} else if (minutes > 0) {
|
|
171
|
+
return `${minutes}m ${secs}s`;
|
|
172
|
+
} else {
|
|
173
|
+
return `${secs}s`;
|
|
136
174
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
* Calculate progress percentage
|
|
147
|
-
*/
|
|
148
|
-
protected calculateProgressPercentage(completed: number, total: number): number {
|
|
149
|
-
if (total === 0) return 0;
|
|
150
|
-
return Math.round((completed / total) * 100);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Format duration in seconds to human readable format
|
|
155
|
-
*/
|
|
156
|
-
protected formatDuration(seconds: number): string {
|
|
157
|
-
const hours = Math.floor(seconds / 3600);
|
|
158
|
-
const minutes = Math.floor((seconds % 3600) / 60);
|
|
159
|
-
const secs = seconds % 60;
|
|
160
|
-
|
|
161
|
-
if (hours > 0) {
|
|
162
|
-
return `${hours}h ${minutes}m ${secs}s`;
|
|
163
|
-
} else if (minutes > 0) {
|
|
164
|
-
return `${minutes}m ${secs}s`;
|
|
165
|
-
} else {
|
|
166
|
-
return `${secs}s`;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Helper to build consistent error messages for LMS operations
|
|
172
|
-
*/
|
|
173
|
-
protected buildLMSErrorMessage(operation: string, details: string, systemError?: any): string {
|
|
174
|
-
let message = `LMS operation failed: ${operation}. ${details}`;
|
|
175
|
-
if (systemError) {
|
|
176
|
-
message += ` System error: ${systemError.message || systemError}`;
|
|
177
|
-
}
|
|
178
|
-
return message;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Common enrollment status mapping
|
|
183
|
-
*/
|
|
184
|
-
protected mapEnrollmentStatus(status: string): 'active' | 'completed' | 'expired' | 'suspended' | 'unknown' {
|
|
185
|
-
const statusMap: Record<string, 'active' | 'completed' | 'expired' | 'suspended' | 'unknown'> = {
|
|
186
|
-
'active': 'active',
|
|
187
|
-
'completed': 'completed',
|
|
188
|
-
'finished': 'completed',
|
|
189
|
-
'expired': 'expired',
|
|
190
|
-
'suspended': 'suspended',
|
|
191
|
-
'paused': 'suspended',
|
|
192
|
-
'inactive': 'suspended'
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
return statusMap[status.toLowerCase()] || 'unknown';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Helper to build consistent error messages for LMS operations
|
|
179
|
+
*/
|
|
180
|
+
protected buildLMSErrorMessage(operation: string, details: string, systemError?: any): string {
|
|
181
|
+
let message = `LMS operation failed: ${operation}. ${details}`;
|
|
182
|
+
if (systemError) {
|
|
183
|
+
message += ` System error: ${systemError.message || systemError}`;
|
|
196
184
|
}
|
|
197
|
-
|
|
185
|
+
return message;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Common enrollment status mapping
|
|
190
|
+
*/
|
|
191
|
+
protected mapEnrollmentStatus(status: string): 'active' | 'completed' | 'expired' | 'suspended' | 'unknown' {
|
|
192
|
+
const statusMap: Record<string, 'active' | 'completed' | 'expired' | 'suspended' | 'unknown'> = {
|
|
193
|
+
active: 'active',
|
|
194
|
+
completed: 'completed',
|
|
195
|
+
finished: 'completed',
|
|
196
|
+
expired: 'expired',
|
|
197
|
+
suspended: 'suspended',
|
|
198
|
+
paused: 'suspended',
|
|
199
|
+
inactive: 'suspended',
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
return statusMap[status.toLowerCase()] || 'unknown';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { BaseLMSAction } from '../../base/base-lms.action';
|
|
3
|
-
import { UserInfo } from '@memberjunction/
|
|
3
|
+
import { UserInfo } from '@memberjunction/global';
|
|
4
4
|
import { CompanyIntegrationEntity } from '@memberjunction/core-entities';
|
|
5
5
|
import { BaseAction } from '@memberjunction/actions';
|
|
6
6
|
|
|
@@ -10,213 +10,213 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
10
10
|
*/
|
|
11
11
|
@RegisterClass(BaseAction, 'LearnWorldsBaseAction')
|
|
12
12
|
export abstract class LearnWorldsBaseAction extends BaseLMSAction {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
protected lmsProvider = 'LearnWorlds';
|
|
14
|
+
protected integrationName = 'LearnWorlds';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* LearnWorlds API version
|
|
18
|
+
*/
|
|
19
|
+
protected apiVersion = 'v2';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Current action parameters (set by the framework)
|
|
23
|
+
*/
|
|
24
|
+
protected params: any;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Makes an authenticated request to LearnWorlds API
|
|
28
|
+
*/
|
|
29
|
+
protected async makeLearnWorldsRequest<T = any>(
|
|
30
|
+
endpoint: string,
|
|
31
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' = 'GET',
|
|
32
|
+
body?: any,
|
|
33
|
+
contextUser?: UserInfo
|
|
34
|
+
): Promise<T> {
|
|
35
|
+
if (!contextUser) {
|
|
36
|
+
throw new Error('Context user is required for LearnWorlds API calls');
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
// Get company ID from action params
|
|
40
|
+
const companyId = this.getParamValue(this.params, 'CompanyID');
|
|
41
|
+
if (!companyId) {
|
|
42
|
+
throw new Error('CompanyID parameter is required');
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// Get API credentials (from env vars or database)
|
|
49
|
-
const credentials = await this.getAPICredentials(integration);
|
|
50
|
-
|
|
51
|
-
if (!credentials.apiKey) {
|
|
52
|
-
throw new Error('API Key is required for LearnWorlds integration');
|
|
53
|
-
}
|
|
45
|
+
// Get the integration credentials
|
|
46
|
+
const integration = await this.getCompanyIntegration(companyId, contextUser);
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!schoolDomain) {
|
|
58
|
-
throw new Error('School domain not found. Set in CompanyIntegration.ExternalSystemID or environment variable');
|
|
59
|
-
}
|
|
48
|
+
// Get API credentials (from env vars or database)
|
|
49
|
+
const credentials = await this.getAPICredentials(integration);
|
|
60
50
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
if (!credentials.apiKey) {
|
|
52
|
+
throw new Error('API Key is required for LearnWorlds integration');
|
|
53
|
+
}
|
|
64
54
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
55
|
+
// Get the school domain from ExternalSystemID or environment
|
|
56
|
+
const schoolDomain = integration.ExternalSystemID || this.getCredentialFromEnv(companyId, 'SCHOOL_DOMAIN');
|
|
57
|
+
if (!schoolDomain) {
|
|
58
|
+
throw new Error('School domain not found. Set in CompanyIntegration.ExternalSystemID or environment variable');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Build the full URL
|
|
62
|
+
const baseUrl = `https://${schoolDomain}/api/${this.apiVersion}`;
|
|
63
|
+
const fullUrl = `${baseUrl}/${endpoint}`;
|
|
64
|
+
|
|
65
|
+
// Prepare headers
|
|
66
|
+
const headers: Record<string, string> = {
|
|
67
|
+
Authorization: `Bearer ${credentials.apiKey}`,
|
|
68
|
+
Accept: 'application/json',
|
|
69
|
+
'Content-Type': 'application/json',
|
|
70
|
+
'Lw-Client': 'MemberJunction',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(fullUrl, {
|
|
75
|
+
method,
|
|
76
|
+
headers,
|
|
77
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
const errorText = await response.text();
|
|
82
|
+
let errorMessage = `LearnWorlds API error: ${response.status} ${response.statusText}`;
|
|
72
83
|
|
|
73
84
|
try {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
let errorMessage = `LearnWorlds API error: ${response.status} ${response.statusText}`;
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
const errorJson = JSON.parse(errorText);
|
|
86
|
-
if (errorJson.error) {
|
|
87
|
-
errorMessage = `LearnWorlds API error: ${errorJson.error.message || errorJson.error}`;
|
|
88
|
-
} else if (errorJson.message) {
|
|
89
|
-
errorMessage = `LearnWorlds API error: ${errorJson.message}`;
|
|
90
|
-
}
|
|
91
|
-
} catch {
|
|
92
|
-
errorMessage += ` - ${errorText}`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
throw new Error(errorMessage);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const result = await response.json();
|
|
99
|
-
return result as T;
|
|
100
|
-
} catch (error) {
|
|
101
|
-
if (error instanceof Error) {
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
throw new Error(`LearnWorlds API request failed: ${error}`);
|
|
85
|
+
const errorJson = JSON.parse(errorText);
|
|
86
|
+
if (errorJson.error) {
|
|
87
|
+
errorMessage = `LearnWorlds API error: ${errorJson.error.message || errorJson.error}`;
|
|
88
|
+
} else if (errorJson.message) {
|
|
89
|
+
errorMessage = `LearnWorlds API error: ${errorJson.message}`;
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
errorMessage += ` - ${errorText}`;
|
|
105
93
|
}
|
|
106
|
-
}
|
|
107
94
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*/
|
|
111
|
-
protected async makeLearnWorldsPaginatedRequest<T = any>(
|
|
112
|
-
endpoint: string,
|
|
113
|
-
params: Record<string, any> = {},
|
|
114
|
-
contextUser?: UserInfo
|
|
115
|
-
): Promise<T[]> {
|
|
116
|
-
const results: T[] = [];
|
|
117
|
-
let page = 1;
|
|
118
|
-
let hasMore = true;
|
|
119
|
-
const limit = params.limit || 50;
|
|
120
|
-
|
|
121
|
-
while (hasMore) {
|
|
122
|
-
const queryParams = new URLSearchParams({
|
|
123
|
-
...params,
|
|
124
|
-
page: page.toString(),
|
|
125
|
-
limit: limit.toString()
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const response = await this.makeLearnWorldsRequest<{
|
|
129
|
-
data: T[];
|
|
130
|
-
meta?: {
|
|
131
|
-
page: number;
|
|
132
|
-
totalPages: number;
|
|
133
|
-
totalItems: number;
|
|
134
|
-
};
|
|
135
|
-
}>(`${endpoint}?${queryParams}`, 'GET', undefined, contextUser);
|
|
136
|
-
|
|
137
|
-
if (response.data && Array.isArray(response.data)) {
|
|
138
|
-
results.push(...response.data);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Check if there are more pages
|
|
142
|
-
if (response.meta && response.meta.page < response.meta.totalPages) {
|
|
143
|
-
page++;
|
|
144
|
-
} else {
|
|
145
|
-
hasMore = false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Respect max results if specified
|
|
149
|
-
const maxResults = this.getParamValue(this.params, 'MaxResults');
|
|
150
|
-
if (maxResults && results.length >= maxResults) {
|
|
151
|
-
return results.slice(0, maxResults);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
95
|
+
throw new Error(errorMessage);
|
|
96
|
+
}
|
|
154
97
|
|
|
155
|
-
|
|
98
|
+
const result = await response.json();
|
|
99
|
+
return result as T;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error instanceof Error) {
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`LearnWorlds API request failed: ${error}`);
|
|
156
105
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Makes a paginated request to LearnWorlds API
|
|
110
|
+
*/
|
|
111
|
+
protected async makeLearnWorldsPaginatedRequest<T = any>(
|
|
112
|
+
endpoint: string,
|
|
113
|
+
params: Record<string, any> = {},
|
|
114
|
+
contextUser?: UserInfo
|
|
115
|
+
): Promise<T[]> {
|
|
116
|
+
const results: T[] = [];
|
|
117
|
+
let page = 1;
|
|
118
|
+
let hasMore = true;
|
|
119
|
+
const limit = params.limit || 50;
|
|
120
|
+
|
|
121
|
+
while (hasMore) {
|
|
122
|
+
const queryParams = new URLSearchParams({
|
|
123
|
+
...params,
|
|
124
|
+
page: page.toString(),
|
|
125
|
+
limit: limit.toString(),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const response = await this.makeLearnWorldsRequest<{
|
|
129
|
+
data: T[];
|
|
130
|
+
meta?: {
|
|
131
|
+
page: number;
|
|
132
|
+
totalPages: number;
|
|
133
|
+
totalItems: number;
|
|
134
|
+
};
|
|
135
|
+
}>(`${endpoint}?${queryParams}`, 'GET', undefined, contextUser);
|
|
136
|
+
|
|
137
|
+
if (response.data && Array.isArray(response.data)) {
|
|
138
|
+
results.push(...response.data);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Check if there are more pages
|
|
142
|
+
if (response.meta && response.meta.page < response.meta.totalPages) {
|
|
143
|
+
page++;
|
|
144
|
+
} else {
|
|
145
|
+
hasMore = false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Respect max results if specified
|
|
149
|
+
const maxResults = this.getParamValue(this.params, 'MaxResults');
|
|
150
|
+
if (maxResults && results.length >= maxResults) {
|
|
151
|
+
return results.slice(0, maxResults);
|
|
152
|
+
}
|
|
167
153
|
}
|
|
168
154
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
*/
|
|
172
|
-
protected formatLearnWorldsDate(date: Date): string {
|
|
173
|
-
return date.toISOString();
|
|
174
|
-
}
|
|
155
|
+
return results;
|
|
156
|
+
}
|
|
175
157
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
'suspended': 'suspended',
|
|
184
|
-
'blocked': 'suspended'
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
return statusMap[status.toLowerCase()] || 'inactive';
|
|
158
|
+
/**
|
|
159
|
+
* Convert LearnWorlds date format to Date object
|
|
160
|
+
*/
|
|
161
|
+
protected parseLearnWorldsDate(dateString: string | number): Date {
|
|
162
|
+
// LearnWorlds sometimes returns timestamps as seconds since epoch
|
|
163
|
+
if (typeof dateString === 'number') {
|
|
164
|
+
return new Date(dateString * 1000);
|
|
188
165
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
166
|
+
return new Date(dateString);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Format date for LearnWorlds API (ISO 8601)
|
|
171
|
+
*/
|
|
172
|
+
protected formatLearnWorldsDate(date: Date): string {
|
|
173
|
+
return date.toISOString();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Map LearnWorlds user status to standard status
|
|
178
|
+
*/
|
|
179
|
+
protected mapUserStatus(status: string): 'active' | 'inactive' | 'suspended' {
|
|
180
|
+
const statusMap: Record<string, 'active' | 'inactive' | 'suspended'> = {
|
|
181
|
+
active: 'active',
|
|
182
|
+
inactive: 'inactive',
|
|
183
|
+
suspended: 'suspended',
|
|
184
|
+
blocked: 'suspended',
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return statusMap[status.toLowerCase()] || 'inactive';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Map LearnWorlds enrollment status
|
|
192
|
+
*/
|
|
193
|
+
protected mapLearnWorldsEnrollmentStatus(enrollment: any): 'active' | 'completed' | 'expired' | 'suspended' {
|
|
194
|
+
if (enrollment.completed) {
|
|
195
|
+
return 'completed';
|
|
204
196
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
percentage: number;
|
|
211
|
-
completedUnits: number;
|
|
212
|
-
totalUnits: number;
|
|
213
|
-
timeSpent: number;
|
|
214
|
-
} {
|
|
215
|
-
return {
|
|
216
|
-
percentage: progressData.percentage || 0,
|
|
217
|
-
completedUnits: progressData.completed_units || 0,
|
|
218
|
-
totalUnits: progressData.total_units || 0,
|
|
219
|
-
timeSpent: progressData.time_spent || 0
|
|
220
|
-
};
|
|
197
|
+
if (enrollment.expired) {
|
|
198
|
+
return 'expired';
|
|
199
|
+
}
|
|
200
|
+
if (enrollment.suspended || !enrollment.active) {
|
|
201
|
+
return 'suspended';
|
|
221
202
|
}
|
|
222
|
-
|
|
203
|
+
return 'active';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Calculate progress from LearnWorlds data
|
|
208
|
+
*/
|
|
209
|
+
protected calculateProgress(progressData: any): {
|
|
210
|
+
percentage: number;
|
|
211
|
+
completedUnits: number;
|
|
212
|
+
totalUnits: number;
|
|
213
|
+
timeSpent: number;
|
|
214
|
+
} {
|
|
215
|
+
return {
|
|
216
|
+
percentage: progressData.percentage || 0,
|
|
217
|
+
completedUnits: progressData.completed_units || 0,
|
|
218
|
+
totalUnits: progressData.total_units || 0,
|
|
219
|
+
timeSpent: progressData.time_spent || 0,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|