@memberjunction/actions-bizapps-lms 2.112.0 → 2.113.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +13 -0
- 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 +6 -5
- package/src/base/base-lms.action.ts +172 -179
- package/src/providers/learnworlds/learnworlds-base.action.ts +194 -194
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @memberjunction/actions-bizapps-lms
|
|
2
2
|
|
|
3
|
+
## 2.113.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [7f8390e]
|
|
8
|
+
- Updated dependencies [4436cd2]
|
|
9
|
+
- @memberjunction/core-entities@2.113.1
|
|
10
|
+
- @memberjunction/global@2.113.1
|
|
11
|
+
- @memberjunction/core@2.113.1
|
|
12
|
+
- @memberjunction/actions@2.113.1
|
|
13
|
+
- @memberjunction/actions-base@2.113.1
|
|
14
|
+
|
|
3
15
|
## 2.112.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -8,6 +20,7 @@
|
|
|
8
20
|
- @memberjunction/global@2.112.0
|
|
9
21
|
- @memberjunction/actions@2.112.0
|
|
10
22
|
- @memberjunction/actions-base@2.112.0
|
|
23
|
+
- @memberjunction/core@2.112.0
|
|
11
24
|
- @memberjunction/core-entities@2.112.0
|
|
12
25
|
|
|
13
26
|
## 2.110.1
|
|
@@ -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/core';
|
|
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,sBAAsB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGzE;;;GAGG;AACH,8BACsB,aAAc,SAAQ,UAAU;IAClD;;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;IAyBlH;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK7F;;OAEG;cACa,iBAAiB,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA2BhJ;;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;CAa9G"}
|
|
@@ -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 core_1 = require("@memberjunction/core");
|
|
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 core_1.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(
|
|
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
|
-
active: 'active',
|
|
162
|
-
completed: 'completed',
|
|
163
|
-
finished: 'completed',
|
|
164
|
-
expired: 'expired',
|
|
165
|
-
suspended: 'suspended',
|
|
166
|
-
paused: 'suspended',
|
|
167
|
-
inactive: 'suspended'
|
|
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,+CAAyD;AAEzD;;;GAGG;AAEI,IAAe,aAAa,GAA5B,MAAe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AAI,OAAO,GAAG,yBAAyB,SAAS,KAAK,OAAO,EAAE,CAAC;QAC/D,IAAI,WAAW,EAAE,CAAC;YACd,OAAO,IAAI,kBAAkB,WAAW,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;QACtE,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;OAEG;IACO,mBAAmB,CAAC,MAAc;QACxC,MAAM,SAAS,GAAiF;YAC5F,QAAQ,EAAE,QAAQ;YAClB,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,WAAW;YACvB,SAAS,EAAE,SAAS;YACpB,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,WAAW;YACrB,UAAU,EAAE,WAAW;SAC1B,CAAC;QAEF,OAAO,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,SAAS,CAAC;IACxD,CAAC;CACJ,CAAA;AAxLqB,sCAAa;wBAAb,aAAa;IADlC,IAAA,sBAAa,EAAC,oBAAU,EAAE,eAAe,CAAC;GACrB,aAAa,CAwLlC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseLMSAction } from '../../base/base-lms.action';
|
|
2
|
-
import { UserInfo } from '@memberjunction/
|
|
2
|
+
import { UserInfo } from '@memberjunction/core';
|
|
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,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U,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACrB;CAQJ"}
|
|
@@ -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
|
-
Authorization: `Bearer ${credentials.apiKey}`,
|
|
58
|
-
Accept: 'application/json',
|
|
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
|
-
active: 'active',
|
|
150
|
-
inactive: 'inactive',
|
|
151
|
-
suspended: 'suspended',
|
|
152
|
-
blocked: 'suspended'
|
|
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;IACnD,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,CAClC,QAAgB,EAChB,SAA4C,KAAK,EACjD,IAAU,EACV,WAAsB;QAEtB,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,C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|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/actions-bizapps-lms",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.113.1",
|
|
4
4
|
"description": "LMS system integration actions for MemberJunction",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,10 +23,11 @@
|
|
|
23
23
|
"author": "MemberJunction",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@memberjunction/
|
|
27
|
-
"@memberjunction/
|
|
28
|
-
"@memberjunction/actions": "2.
|
|
29
|
-
"@memberjunction/
|
|
26
|
+
"@memberjunction/core": "2.113.1",
|
|
27
|
+
"@memberjunction/global": "2.113.1",
|
|
28
|
+
"@memberjunction/actions-base": "2.113.1",
|
|
29
|
+
"@memberjunction/actions": "2.113.1",
|
|
30
|
+
"@memberjunction/core-entities": "2.113.1"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@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/core';
|
|
5
5
|
import { CompanyIntegrationEntity } from '@memberjunction/core-entities';
|
|
6
|
-
import { Metadata, RunView } from '@memberjunction/
|
|
6
|
+
import { Metadata, RunView } from '@memberjunction/core';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Base class for all LMS-related actions.
|
|
@@ -11,194 +11,187 @@ import { Metadata, RunView } from '@memberjunction/global';
|
|
|
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
|
-
|
|
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;
|
|
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
|
+
];
|
|
49
40
|
}
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const rv = new RunView();
|
|
52
|
+
const result = await rv.RunView<CompanyIntegrationEntity>({
|
|
53
|
+
EntityName: 'Company Integrations',
|
|
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;
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Gets credentials from environment variables
|
|
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];
|
|
67
78
|
}
|
|
68
79
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
apiKey: envApiKey,
|
|
99
|
-
apiSecret: envApiSecret,
|
|
100
|
-
accessToken: envAccessToken,
|
|
101
|
-
};
|
|
80
|
+
/**
|
|
81
|
+
* Gets API credentials - first tries environment variables, then falls back to database
|
|
82
|
+
*/
|
|
83
|
+
protected async getAPICredentials(integration: CompanyIntegrationEntity): Promise<{ apiKey?: string; apiSecret?: string; accessToken?: string }> {
|
|
84
|
+
const companyId = integration.CompanyID;
|
|
85
|
+
|
|
86
|
+
// Try environment variables first
|
|
87
|
+
const envApiKey = this.getCredentialFromEnv(companyId, 'API_KEY');
|
|
88
|
+
const envApiSecret = this.getCredentialFromEnv(companyId, 'API_SECRET');
|
|
89
|
+
const envAccessToken = this.getCredentialFromEnv(companyId, 'ACCESS_TOKEN');
|
|
90
|
+
|
|
91
|
+
if (envApiKey || envAccessToken) {
|
|
92
|
+
return {
|
|
93
|
+
apiKey: envApiKey,
|
|
94
|
+
apiSecret: envApiSecret,
|
|
95
|
+
accessToken: envAccessToken
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Fall back to database (for backwards compatibility)
|
|
100
|
+
if (!integration.APIKey && !integration.AccessToken) {
|
|
101
|
+
throw new Error(`No API credentials found for ${this.integrationName} integration. Please set environment variables or configure in database.`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
apiKey: integration.APIKey || undefined,
|
|
106
|
+
accessToken: integration.AccessToken || undefined
|
|
107
|
+
};
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Gets the base URL for API calls
|
|
112
|
+
*/
|
|
113
|
+
protected async getAPIBaseURL(integration: CompanyIntegrationEntity): Promise<string> {
|
|
114
|
+
// Check if custom URL is stored in the integration
|
|
115
|
+
if (integration.CustomAttribute1) {
|
|
116
|
+
return integration.CustomAttribute1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Return empty string - derived classes should override this
|
|
120
|
+
return '';
|
|
109
121
|
}
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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;
|
|
123
|
+
/**
|
|
124
|
+
* Helper to get parameter value with type safety
|
|
125
|
+
*/
|
|
126
|
+
protected getParamValue(params: ActionParam[], paramName: string): any {
|
|
127
|
+
const param = params.find(p => p.Name === paramName);
|
|
128
|
+
return param?.Value;
|
|
124
129
|
}
|
|
125
130
|
|
|
126
|
-
|
|
127
|
-
|
|
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`;
|
|
131
|
+
/**
|
|
132
|
+
* Standard date format for LMS systems (ISO 8601)
|
|
133
|
+
*/
|
|
134
|
+
protected formatLMSDate(date: Date): string {
|
|
135
|
+
return date.toISOString();
|
|
174
136
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Parse date from LMS format
|
|
140
|
+
*/
|
|
141
|
+
protected parseLMSDate(dateString: string): Date {
|
|
142
|
+
return new Date(dateString);
|
|
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';
|
|
184
196
|
}
|
|
185
|
-
|
|
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
|
-
}
|
|
197
|
+
}
|
|
@@ -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/core';
|
|
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
|
-
|
|
38
|
-
|
|
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
|
-
}
|
|
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
|
+
}
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
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
|
+
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
// Get the integration credentials
|
|
46
|
+
const integration = await this.getCompanyIntegration(companyId, contextUser);
|
|
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
|
+
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
}
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw new Error('School domain not found. Set in CompanyIntegration.ExternalSystemID or environment variable');
|
|
59
|
-
}
|
|
61
|
+
// Build the full URL
|
|
62
|
+
const baseUrl = `https://${schoolDomain}/api/${this.apiVersion}`;
|
|
63
|
+
const fullUrl = `${baseUrl}/${endpoint}`;
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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}`;
|
|
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
|
+
};
|
|
83
72
|
|
|
84
73
|
try {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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}`;
|
|
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}`);
|
|
93
105
|
}
|
|
106
|
+
}
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
|
|
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
|
+
}
|
|
153
|
+
}
|
|
97
154
|
|
|
98
|
-
|
|
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}`);
|
|
105
|
-
}
|
|
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
|
-
}
|
|
155
|
+
return results;
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
|
|
156
|
-
|
|
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);
|
|
165
|
+
}
|
|
166
|
+
return new Date(dateString);
|
|
167
|
+
}
|
|
157
168
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (typeof dateString === 'number') {
|
|
164
|
-
return new Date(dateString * 1000);
|
|
169
|
+
/**
|
|
170
|
+
* Format date for LearnWorlds API (ISO 8601)
|
|
171
|
+
*/
|
|
172
|
+
protected formatLearnWorldsDate(date: Date): string {
|
|
173
|
+
return date.toISOString();
|
|
165
174
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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';
|
|
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';
|
|
196
188
|
}
|
|
197
|
-
|
|
198
|
-
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Map LearnWorlds enrollment status
|
|
192
|
+
*/
|
|
193
|
+
protected mapLearnWorldsEnrollmentStatus(enrollment: any): 'active' | 'completed' | 'expired' | 'suspended' {
|
|
194
|
+
if (enrollment.completed) {
|
|
195
|
+
return 'completed';
|
|
196
|
+
}
|
|
197
|
+
if (enrollment.expired) {
|
|
198
|
+
return 'expired';
|
|
199
|
+
}
|
|
200
|
+
if (enrollment.suspended || !enrollment.active) {
|
|
201
|
+
return 'suspended';
|
|
202
|
+
}
|
|
203
|
+
return 'active';
|
|
199
204
|
}
|
|
200
|
-
|
|
201
|
-
|
|
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
|
+
};
|
|
202
221
|
}
|
|
203
|
-
|
|
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
|
-
}
|
|
222
|
+
}
|