@memberjunction/actions-bizapps-lms 2.55.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 +4 -0
- package/CHANGELOG.md +12 -0
- package/dist/base/base-lms.action.d.ts +77 -0
- package/dist/base/base-lms.action.d.ts.map +1 -0
- package/dist/base/base-lms.action.js +176 -0
- package/dist/base/base-lms.action.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-courses.action.d.ts +125 -0
- package/dist/providers/learnworlds/actions/get-courses.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-courses.action.js +436 -0
- package/dist/providers/learnworlds/actions/get-courses.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-user-details.action.d.ts +95 -0
- package/dist/providers/learnworlds/actions/get-user-details.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-user-details.action.js +280 -0
- package/dist/providers/learnworlds/actions/get-user-details.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts +151 -0
- package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-user-progress.action.js +417 -0
- package/dist/providers/learnworlds/actions/get-user-progress.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-users.action.d.ts +53 -0
- package/dist/providers/learnworlds/actions/get-users.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-users.action.js +272 -0
- package/dist/providers/learnworlds/actions/get-users.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/index.d.ts +5 -0
- package/dist/providers/learnworlds/actions/index.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/index.js +22 -0
- package/dist/providers/learnworlds/actions/index.js.map +1 -0
- package/dist/providers/learnworlds/index.d.ts +3 -0
- package/dist/providers/learnworlds/index.d.ts.map +1 -0
- package/dist/providers/learnworlds/index.js +21 -0
- package/dist/providers/learnworlds/index.js.map +1 -0
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts +52 -0
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/learnworlds-base.action.js +186 -0
- package/dist/providers/learnworlds/learnworlds-base.action.js.map +1 -0
- package/package.json +40 -0
- package/src/base/base-lms.action.ts +197 -0
- package/src/index.ts +5 -0
- package/src/providers/learnworlds/actions/get-courses.action.ts +592 -0
- package/src/providers/learnworlds/actions/get-user-details.action.ts +381 -0
- package/src/providers/learnworlds/actions/get-user-progress.action.ts +625 -0
- package/src/providers/learnworlds/actions/get-users.action.ts +319 -0
- package/src/providers/learnworlds/actions/index.ts +5 -0
- package/src/providers/learnworlds/index.ts +5 -0
- package/src/providers/learnworlds/learnworlds-base.action.ts +221 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GetLearnWorldsUsersAction = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const learnworlds_base_action_1 = require("../learnworlds-base.action");
|
|
12
|
+
/**
|
|
13
|
+
* Action to retrieve users from LearnWorlds LMS
|
|
14
|
+
*/
|
|
15
|
+
let GetLearnWorldsUsersAction = class GetLearnWorldsUsersAction extends learnworlds_base_action_1.LearnWorldsBaseAction {
|
|
16
|
+
/**
|
|
17
|
+
* Description of the action
|
|
18
|
+
*/
|
|
19
|
+
get Description() {
|
|
20
|
+
return 'Retrieves users (students, instructors, admins) from LearnWorlds LMS with filtering and search options';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Main execution method
|
|
24
|
+
*/
|
|
25
|
+
async InternalRunAction(params) {
|
|
26
|
+
try {
|
|
27
|
+
const contextUser = params.ContextUser;
|
|
28
|
+
if (!contextUser) {
|
|
29
|
+
return {
|
|
30
|
+
Success: false,
|
|
31
|
+
ResultCode: 'ERROR',
|
|
32
|
+
Message: 'Context user is required for LearnWorlds API calls'
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Store params for base class methods
|
|
36
|
+
this.params = params.Params;
|
|
37
|
+
// Build query parameters
|
|
38
|
+
const queryParams = {};
|
|
39
|
+
// Search filter
|
|
40
|
+
const searchText = this.getParamValue(params.Params, 'SearchText');
|
|
41
|
+
if (searchText) {
|
|
42
|
+
queryParams.search = searchText;
|
|
43
|
+
}
|
|
44
|
+
// Role filter
|
|
45
|
+
const role = this.getParamValue(params.Params, 'Role');
|
|
46
|
+
if (role) {
|
|
47
|
+
queryParams.role = role;
|
|
48
|
+
}
|
|
49
|
+
// Status filter
|
|
50
|
+
const status = this.getParamValue(params.Params, 'Status');
|
|
51
|
+
if (status) {
|
|
52
|
+
queryParams.status = status;
|
|
53
|
+
}
|
|
54
|
+
// Tag filter
|
|
55
|
+
const tags = this.getParamValue(params.Params, 'Tags');
|
|
56
|
+
if (tags) {
|
|
57
|
+
queryParams.tags = tags;
|
|
58
|
+
}
|
|
59
|
+
// Date filters
|
|
60
|
+
const createdAfter = this.getParamValue(params.Params, 'CreatedAfter');
|
|
61
|
+
if (createdAfter) {
|
|
62
|
+
queryParams.created_after = this.formatLearnWorldsDate(new Date(createdAfter));
|
|
63
|
+
}
|
|
64
|
+
const createdBefore = this.getParamValue(params.Params, 'CreatedBefore');
|
|
65
|
+
if (createdBefore) {
|
|
66
|
+
queryParams.created_before = this.formatLearnWorldsDate(new Date(createdBefore));
|
|
67
|
+
}
|
|
68
|
+
// Sorting
|
|
69
|
+
const sortBy = this.getParamValue(params.Params, 'SortBy') || 'created';
|
|
70
|
+
const sortOrder = this.getParamValue(params.Params, 'SortOrder') || 'desc';
|
|
71
|
+
queryParams.sort = `${sortOrder === 'asc' ? '' : '-'}${sortBy}`;
|
|
72
|
+
// Include course stats
|
|
73
|
+
const includeCourseStats = this.getParamValue(params.Params, 'IncludeCourseStats');
|
|
74
|
+
if (includeCourseStats) {
|
|
75
|
+
queryParams.include = 'course_stats';
|
|
76
|
+
}
|
|
77
|
+
// Limit for pagination
|
|
78
|
+
const maxResults = this.getParamValue(params.Params, 'MaxResults') || 100;
|
|
79
|
+
queryParams.limit = Math.min(maxResults, 100); // LearnWorlds max is usually 100
|
|
80
|
+
// Make the API request
|
|
81
|
+
const users = await this.makeLearnWorldsPaginatedRequest('users', queryParams, contextUser);
|
|
82
|
+
// Map to our interface
|
|
83
|
+
const mappedUsers = users.map(user => this.mapLearnWorldsUser(user));
|
|
84
|
+
// Calculate summary
|
|
85
|
+
const summary = this.calculateUserSummary(mappedUsers);
|
|
86
|
+
// Create output parameters
|
|
87
|
+
if (!params.Params.find(p => p.Name === 'Users')) {
|
|
88
|
+
params.Params.push({
|
|
89
|
+
Name: 'Users',
|
|
90
|
+
Type: 'Output',
|
|
91
|
+
Value: mappedUsers
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
params.Params.find(p => p.Name === 'Users').Value = mappedUsers;
|
|
96
|
+
}
|
|
97
|
+
if (!params.Params.find(p => p.Name === 'TotalCount')) {
|
|
98
|
+
params.Params.push({
|
|
99
|
+
Name: 'TotalCount',
|
|
100
|
+
Type: 'Output',
|
|
101
|
+
Value: mappedUsers.length
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
params.Params.find(p => p.Name === 'TotalCount').Value = mappedUsers.length;
|
|
106
|
+
}
|
|
107
|
+
if (!params.Params.find(p => p.Name === 'Summary')) {
|
|
108
|
+
params.Params.push({
|
|
109
|
+
Name: 'Summary',
|
|
110
|
+
Type: 'Output',
|
|
111
|
+
Value: summary
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
params.Params.find(p => p.Name === 'Summary').Value = summary;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
Success: true,
|
|
119
|
+
ResultCode: 'SUCCESS',
|
|
120
|
+
Message: `Successfully retrieved ${mappedUsers.length} users from LearnWorlds`
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
125
|
+
return {
|
|
126
|
+
Success: false,
|
|
127
|
+
ResultCode: 'ERROR',
|
|
128
|
+
Message: errorMessage
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Map LearnWorlds user data to our interface
|
|
134
|
+
*/
|
|
135
|
+
mapLearnWorldsUser(lwUser) {
|
|
136
|
+
return {
|
|
137
|
+
id: lwUser.id || lwUser._id,
|
|
138
|
+
email: lwUser.email,
|
|
139
|
+
username: lwUser.username || lwUser.email,
|
|
140
|
+
firstName: lwUser.first_name,
|
|
141
|
+
lastName: lwUser.last_name,
|
|
142
|
+
fullName: lwUser.full_name || `${lwUser.first_name || ''} ${lwUser.last_name || ''}`.trim(),
|
|
143
|
+
status: this.mapUserStatus(lwUser.status || 'active'),
|
|
144
|
+
role: lwUser.role || 'student',
|
|
145
|
+
createdAt: this.parseLearnWorldsDate(lwUser.created || lwUser.created_at),
|
|
146
|
+
lastLoginAt: lwUser.last_login ? this.parseLearnWorldsDate(lwUser.last_login) : undefined,
|
|
147
|
+
tags: lwUser.tags || [],
|
|
148
|
+
customFields: lwUser.custom_fields || {},
|
|
149
|
+
totalCourses: lwUser.course_stats?.total || 0,
|
|
150
|
+
completedCourses: lwUser.course_stats?.completed || 0,
|
|
151
|
+
inProgressCourses: lwUser.course_stats?.in_progress || 0,
|
|
152
|
+
totalTimeSpent: lwUser.course_stats?.total_time_spent || 0,
|
|
153
|
+
avatarUrl: lwUser.avatar_url,
|
|
154
|
+
bio: lwUser.bio,
|
|
155
|
+
location: lwUser.location,
|
|
156
|
+
timezone: lwUser.timezone
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Calculate summary statistics
|
|
161
|
+
*/
|
|
162
|
+
calculateUserSummary(users) {
|
|
163
|
+
const summary = {
|
|
164
|
+
totalUsers: users.length,
|
|
165
|
+
activeUsers: users.filter(u => u.status === 'active').length,
|
|
166
|
+
inactiveUsers: users.filter(u => u.status === 'inactive').length,
|
|
167
|
+
suspendedUsers: users.filter(u => u.status === 'suspended').length,
|
|
168
|
+
usersByRole: {},
|
|
169
|
+
averageCoursesPerUser: 0,
|
|
170
|
+
totalTimeSpent: 0,
|
|
171
|
+
mostActiveUsers: [],
|
|
172
|
+
recentSignups: []
|
|
173
|
+
};
|
|
174
|
+
// Count by role
|
|
175
|
+
users.forEach(user => {
|
|
176
|
+
summary.usersByRole[user.role] = (summary.usersByRole[user.role] || 0) + 1;
|
|
177
|
+
summary.totalTimeSpent += user.totalTimeSpent || 0;
|
|
178
|
+
});
|
|
179
|
+
// Calculate averages
|
|
180
|
+
if (users.length > 0) {
|
|
181
|
+
const totalCourses = users.reduce((sum, u) => sum + (u.totalCourses || 0), 0);
|
|
182
|
+
summary.averageCoursesPerUser = totalCourses / users.length;
|
|
183
|
+
}
|
|
184
|
+
// Find most active users (by completed courses)
|
|
185
|
+
summary.mostActiveUsers = users
|
|
186
|
+
.filter(u => u.completedCourses && u.completedCourses > 0)
|
|
187
|
+
.sort((a, b) => (b.completedCourses || 0) - (a.completedCourses || 0))
|
|
188
|
+
.slice(0, 5)
|
|
189
|
+
.map(u => ({
|
|
190
|
+
id: u.id,
|
|
191
|
+
name: u.fullName || u.email,
|
|
192
|
+
completedCourses: u.completedCourses
|
|
193
|
+
}));
|
|
194
|
+
// Find recent signups (last 30 days)
|
|
195
|
+
const thirtyDaysAgo = new Date();
|
|
196
|
+
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
|
|
197
|
+
summary.recentSignups = users
|
|
198
|
+
.filter(u => u.createdAt > thirtyDaysAgo)
|
|
199
|
+
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
|
|
200
|
+
.slice(0, 10)
|
|
201
|
+
.map(u => ({
|
|
202
|
+
id: u.id,
|
|
203
|
+
name: u.fullName || u.email,
|
|
204
|
+
signupDate: u.createdAt
|
|
205
|
+
}));
|
|
206
|
+
return summary;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Define the parameters for this action
|
|
210
|
+
*/
|
|
211
|
+
get Params() {
|
|
212
|
+
const baseParams = this.getCommonLMSParams();
|
|
213
|
+
const specificParams = [
|
|
214
|
+
{
|
|
215
|
+
Name: 'SearchText',
|
|
216
|
+
Type: 'Input',
|
|
217
|
+
Value: null
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
Name: 'Role',
|
|
221
|
+
Type: 'Input',
|
|
222
|
+
Value: null
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
Name: 'Status',
|
|
226
|
+
Type: 'Input',
|
|
227
|
+
Value: null
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
Name: 'Tags',
|
|
231
|
+
Type: 'Input',
|
|
232
|
+
Value: null
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
Name: 'CreatedAfter',
|
|
236
|
+
Type: 'Input',
|
|
237
|
+
Value: null
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
Name: 'CreatedBefore',
|
|
241
|
+
Type: 'Input',
|
|
242
|
+
Value: null
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
Name: 'SortBy',
|
|
246
|
+
Type: 'Input',
|
|
247
|
+
Value: 'created'
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
Name: 'SortOrder',
|
|
251
|
+
Type: 'Input',
|
|
252
|
+
Value: 'desc'
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
Name: 'IncludeCourseStats',
|
|
256
|
+
Type: 'Input',
|
|
257
|
+
Value: true
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
Name: 'MaxResults',
|
|
261
|
+
Type: 'Input',
|
|
262
|
+
Value: 100
|
|
263
|
+
}
|
|
264
|
+
];
|
|
265
|
+
return [...baseParams, ...specificParams];
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
exports.GetLearnWorldsUsersAction = GetLearnWorldsUsersAction;
|
|
269
|
+
exports.GetLearnWorldsUsersAction = GetLearnWorldsUsersAction = __decorate([
|
|
270
|
+
(0, global_1.RegisterClass)(learnworlds_base_action_1.LearnWorldsBaseAction, 'GetLearnWorldsUsersAction')
|
|
271
|
+
], GetLearnWorldsUsersAction);
|
|
272
|
+
//# sourceMappingURL=get-users.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-users.action.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/get-users.action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AACvD,wEAAmE;AA6BnE;;GAEG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,+CAAqB;IAEhE;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,wGAAwG,CAAC;IACpH,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;YACvC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACf,OAAO;oBACH,OAAO,EAAE,KAAK;oB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QAAQ;gBACd,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,SAAS;aACnB;YACD;gBACI,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,MAAM;aAChB;YACD;gBACI,IAAI,EAAE,oBAAoB;gBAC1B,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,GAAG;aACb;SACJ,CAAC;QAEF,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC,CAAC;IAC9C,CAAC;CACJ,CAAA;AA5RY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,sBAAa,EAAC,+CAAqB,EAAE,2BAA2B,CAAC;GACrD,yBAAyB,CA4RrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Export all LearnWorlds actions
|
|
18
|
+
__exportStar(require("./get-users.action"), exports);
|
|
19
|
+
__exportStar(require("./get-user-details.action"), exports);
|
|
20
|
+
__exportStar(require("./get-user-progress.action"), exports);
|
|
21
|
+
__exportStar(require("./get-courses.action"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,qDAAmC;AACnC,4DAA0C;AAC1C,6DAA2C;AAC3C,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/learnworlds/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAC;AAG1C,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Export LearnWorlds base action
|
|
18
|
+
__exportStar(require("./learnworlds-base.action"), exports);
|
|
19
|
+
// Export all LearnWorlds actions
|
|
20
|
+
__exportStar(require("./actions"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/learnworlds/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,4DAA0C;AAE1C,iCAAiC;AACjC,4CAA0B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BaseLMSAction } from '../../base/base-lms.action';
|
|
2
|
+
import { UserInfo } from '@memberjunction/core';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all LearnWorlds LMS actions.
|
|
5
|
+
* Handles LearnWorlds-specific authentication and API interaction patterns.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class LearnWorldsBaseAction extends BaseLMSAction {
|
|
8
|
+
protected lmsProvider: string;
|
|
9
|
+
protected integrationName: string;
|
|
10
|
+
/**
|
|
11
|
+
* LearnWorlds API version
|
|
12
|
+
*/
|
|
13
|
+
protected apiVersion: string;
|
|
14
|
+
/**
|
|
15
|
+
* Current action parameters (set by the framework)
|
|
16
|
+
*/
|
|
17
|
+
protected params: any;
|
|
18
|
+
/**
|
|
19
|
+
* Makes an authenticated request to LearnWorlds API
|
|
20
|
+
*/
|
|
21
|
+
protected makeLearnWorldsRequest<T = any>(endpoint: string, method?: 'GET' | 'POST' | 'PUT' | 'DELETE', body?: any, contextUser?: UserInfo): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Makes a paginated request to LearnWorlds API
|
|
24
|
+
*/
|
|
25
|
+
protected makeLearnWorldsPaginatedRequest<T = any>(endpoint: string, params?: Record<string, any>, contextUser?: UserInfo): Promise<T[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Convert LearnWorlds date format to Date object
|
|
28
|
+
*/
|
|
29
|
+
protected parseLearnWorldsDate(dateString: string | number): Date;
|
|
30
|
+
/**
|
|
31
|
+
* Format date for LearnWorlds API (ISO 8601)
|
|
32
|
+
*/
|
|
33
|
+
protected formatLearnWorldsDate(date: Date): string;
|
|
34
|
+
/**
|
|
35
|
+
* Map LearnWorlds user status to standard status
|
|
36
|
+
*/
|
|
37
|
+
protected mapUserStatus(status: string): 'active' | 'inactive' | 'suspended';
|
|
38
|
+
/**
|
|
39
|
+
* Map LearnWorlds enrollment status
|
|
40
|
+
*/
|
|
41
|
+
protected mapLearnWorldsEnrollmentStatus(enrollment: any): 'active' | 'completed' | 'expired' | 'suspended';
|
|
42
|
+
/**
|
|
43
|
+
* Calculate progress from LearnWorlds data
|
|
44
|
+
*/
|
|
45
|
+
protected calculateProgress(progressData: any): {
|
|
46
|
+
percentage: number;
|
|
47
|
+
completedUnits: number;
|
|
48
|
+
totalUnits: number;
|
|
49
|
+
timeSpent: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=learnworlds-base.action.d.ts.map
|
|
@@ -0,0 +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,sBAAsB,CAAC;AAGhD;;;GAGG;AACH,8BACsB,qBAAsB,SAAQ,aAAa;IAC7D,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,EAC1C,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAgB,EACjD,IAAI,CAAC,EAAE,GAAG,EACV,WAAW,CAAC,EAAE,QAAQ,GACvB,OAAO,CAAC,CAAC,CAAC;IA0Eb;;OAEG;cACa,+BAA+B,CAAC,CAAC,GAAG,GAAG,EACnD,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,WAAW,CAAC,EAAE,QAAQ,GACvB,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;QAC5C,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACrB;CAQJ"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LearnWorldsBaseAction = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const base_lms_action_1 = require("../../base/base-lms.action");
|
|
12
|
+
/**
|
|
13
|
+
* Base class for all LearnWorlds LMS actions.
|
|
14
|
+
* Handles LearnWorlds-specific authentication and API interaction patterns.
|
|
15
|
+
*/
|
|
16
|
+
let LearnWorldsBaseAction = class LearnWorldsBaseAction extends base_lms_action_1.BaseLMSAction {
|
|
17
|
+
lmsProvider = 'LearnWorlds';
|
|
18
|
+
integrationName = 'LearnWorlds';
|
|
19
|
+
/**
|
|
20
|
+
* LearnWorlds API version
|
|
21
|
+
*/
|
|
22
|
+
apiVersion = 'v2';
|
|
23
|
+
/**
|
|
24
|
+
* Current action parameters (set by the framework)
|
|
25
|
+
*/
|
|
26
|
+
params;
|
|
27
|
+
/**
|
|
28
|
+
* Makes an authenticated request to LearnWorlds API
|
|
29
|
+
*/
|
|
30
|
+
async makeLearnWorldsRequest(endpoint, method = 'GET', body, contextUser) {
|
|
31
|
+
if (!contextUser) {
|
|
32
|
+
throw new Error('Context user is required for LearnWorlds API calls');
|
|
33
|
+
}
|
|
34
|
+
// Get company ID from action params
|
|
35
|
+
const companyId = this.getParamValue(this.params, 'CompanyID');
|
|
36
|
+
if (!companyId) {
|
|
37
|
+
throw new Error('CompanyID parameter is required');
|
|
38
|
+
}
|
|
39
|
+
// Get the integration credentials
|
|
40
|
+
const integration = await this.getCompanyIntegration(companyId, contextUser);
|
|
41
|
+
// Get API credentials (from env vars or database)
|
|
42
|
+
const credentials = await this.getAPICredentials(integration);
|
|
43
|
+
if (!credentials.apiKey) {
|
|
44
|
+
throw new Error('API Key is required for LearnWorlds integration');
|
|
45
|
+
}
|
|
46
|
+
// Get the school domain from ExternalSystemID or environment
|
|
47
|
+
const schoolDomain = integration.ExternalSystemID || this.getCredentialFromEnv(companyId, 'SCHOOL_DOMAIN');
|
|
48
|
+
if (!schoolDomain) {
|
|
49
|
+
throw new Error('School domain not found. Set in CompanyIntegration.ExternalSystemID or environment variable');
|
|
50
|
+
}
|
|
51
|
+
// Build the full URL
|
|
52
|
+
const baseUrl = `https://${schoolDomain}/api/${this.apiVersion}`;
|
|
53
|
+
const fullUrl = `${baseUrl}/${endpoint}`;
|
|
54
|
+
// Prepare headers
|
|
55
|
+
const headers = {
|
|
56
|
+
'Authorization': `Bearer ${credentials.apiKey}`,
|
|
57
|
+
'Accept': 'application/json',
|
|
58
|
+
'Content-Type': 'application/json',
|
|
59
|
+
'Lw-Client': 'MemberJunction'
|
|
60
|
+
};
|
|
61
|
+
try {
|
|
62
|
+
const response = await fetch(fullUrl, {
|
|
63
|
+
method,
|
|
64
|
+
headers,
|
|
65
|
+
body: body ? JSON.stringify(body) : undefined
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const errorText = await response.text();
|
|
69
|
+
let errorMessage = `LearnWorlds API error: ${response.status} ${response.statusText}`;
|
|
70
|
+
try {
|
|
71
|
+
const errorJson = JSON.parse(errorText);
|
|
72
|
+
if (errorJson.error) {
|
|
73
|
+
errorMessage = `LearnWorlds API error: ${errorJson.error.message || errorJson.error}`;
|
|
74
|
+
}
|
|
75
|
+
else if (errorJson.message) {
|
|
76
|
+
errorMessage = `LearnWorlds API error: ${errorJson.message}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
errorMessage += ` - ${errorText}`;
|
|
81
|
+
}
|
|
82
|
+
throw new Error(errorMessage);
|
|
83
|
+
}
|
|
84
|
+
const result = await response.json();
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`LearnWorlds API request failed: ${error}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Makes a paginated request to LearnWorlds API
|
|
96
|
+
*/
|
|
97
|
+
async makeLearnWorldsPaginatedRequest(endpoint, params = {}, contextUser) {
|
|
98
|
+
const results = [];
|
|
99
|
+
let page = 1;
|
|
100
|
+
let hasMore = true;
|
|
101
|
+
const limit = params.limit || 50;
|
|
102
|
+
while (hasMore) {
|
|
103
|
+
const queryParams = new URLSearchParams({
|
|
104
|
+
...params,
|
|
105
|
+
page: page.toString(),
|
|
106
|
+
limit: limit.toString()
|
|
107
|
+
});
|
|
108
|
+
const response = await this.makeLearnWorldsRequest(`${endpoint}?${queryParams}`, 'GET', undefined, contextUser);
|
|
109
|
+
if (response.data && Array.isArray(response.data)) {
|
|
110
|
+
results.push(...response.data);
|
|
111
|
+
}
|
|
112
|
+
// Check if there are more pages
|
|
113
|
+
if (response.meta && response.meta.page < response.meta.totalPages) {
|
|
114
|
+
page++;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
hasMore = false;
|
|
118
|
+
}
|
|
119
|
+
// Respect max results if specified
|
|
120
|
+
const maxResults = this.getParamValue(this.params, 'MaxResults');
|
|
121
|
+
if (maxResults && results.length >= maxResults) {
|
|
122
|
+
return results.slice(0, maxResults);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return results;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Convert LearnWorlds date format to Date object
|
|
129
|
+
*/
|
|
130
|
+
parseLearnWorldsDate(dateString) {
|
|
131
|
+
// LearnWorlds sometimes returns timestamps as seconds since epoch
|
|
132
|
+
if (typeof dateString === 'number') {
|
|
133
|
+
return new Date(dateString * 1000);
|
|
134
|
+
}
|
|
135
|
+
return new Date(dateString);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Format date for LearnWorlds API (ISO 8601)
|
|
139
|
+
*/
|
|
140
|
+
formatLearnWorldsDate(date) {
|
|
141
|
+
return date.toISOString();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Map LearnWorlds user status to standard status
|
|
145
|
+
*/
|
|
146
|
+
mapUserStatus(status) {
|
|
147
|
+
const statusMap = {
|
|
148
|
+
'active': 'active',
|
|
149
|
+
'inactive': 'inactive',
|
|
150
|
+
'suspended': 'suspended',
|
|
151
|
+
'blocked': 'suspended'
|
|
152
|
+
};
|
|
153
|
+
return statusMap[status.toLowerCase()] || 'inactive';
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Map LearnWorlds enrollment status
|
|
157
|
+
*/
|
|
158
|
+
mapLearnWorldsEnrollmentStatus(enrollment) {
|
|
159
|
+
if (enrollment.completed) {
|
|
160
|
+
return 'completed';
|
|
161
|
+
}
|
|
162
|
+
if (enrollment.expired) {
|
|
163
|
+
return 'expired';
|
|
164
|
+
}
|
|
165
|
+
if (enrollment.suspended || !enrollment.active) {
|
|
166
|
+
return 'suspended';
|
|
167
|
+
}
|
|
168
|
+
return 'active';
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Calculate progress from LearnWorlds data
|
|
172
|
+
*/
|
|
173
|
+
calculateProgress(progressData) {
|
|
174
|
+
return {
|
|
175
|
+
percentage: progressData.percentage || 0,
|
|
176
|
+
completedUnits: progressData.completed_units || 0,
|
|
177
|
+
totalUnits: progressData.total_units || 0,
|
|
178
|
+
timeSpent: progressData.time_spent || 0
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
exports.LearnWorldsBaseAction = LearnWorldsBaseAction;
|
|
183
|
+
exports.LearnWorldsBaseAction = LearnWorldsBaseAction = __decorate([
|
|
184
|
+
(0, global_1.RegisterClass)(base_lms_action_1.BaseLMSAction, 'LearnWorldsBaseAction')
|
|
185
|
+
], LearnWorldsBaseAction);
|
|
186
|
+
//# sourceMappingURL=learnworlds-base.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learnworlds-base.action.js","sourceRoot":"","sources":["../../../src/providers/learnworlds/learnworlds-base.action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AACvD,gEAA2D;AAI3D;;;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,CAAC;QAC1E,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;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC;QAED,kCAAkC;QAClC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAE7E,kDAAkD;QAClD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAE9D,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,CAAC;QAED,6DAA6D;QAC7D,MAAM,YAAY,GAAG,WAAW,CAAC,gBAAgB,IAAI,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;Q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,CAAC;QACD,IAAI,UAAU,CAAC,SAAS,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC7C,OAAO,WAAW,CAAC;QACvB,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,YAAiB;QAMzC,OAAO;YACH,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;SAC1C,CAAC;IACN,CAAC;CACJ,CAAA;AAlNqB,sDAAqB;gCAArB,qBAAqB;IAD1C,IAAA,sBAAa,EAAC,+BAAa,EAAE,uBAAuB,CAAC;GAChC,qBAAqB,CAkN1C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memberjunction/actions-bizapps-lms",
|
|
3
|
+
"version": "2.55.0",
|
|
4
|
+
"description": "LMS system integration actions for MemberJunction",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"watch": "tsc -w",
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"test": "echo \"No tests yet\""
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"memberjunction",
|
|
15
|
+
"actions",
|
|
16
|
+
"bizapps",
|
|
17
|
+
"lms",
|
|
18
|
+
"moodle",
|
|
19
|
+
"canvas",
|
|
20
|
+
"blackboard",
|
|
21
|
+
"learndash"
|
|
22
|
+
],
|
|
23
|
+
"author": "MemberJunction",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@memberjunction/core": "2.55.0",
|
|
27
|
+
"@memberjunction/global": "2.55.0",
|
|
28
|
+
"@memberjunction/actions-base": "2.55.0",
|
|
29
|
+
"@memberjunction/actions": "2.55.0",
|
|
30
|
+
"@memberjunction/core-entities": "2.55.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "20.8.7",
|
|
34
|
+
"rimraf": "^5.0.5",
|
|
35
|
+
"typescript": "~5.3.3"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=16"
|
|
39
|
+
}
|
|
40
|
+
}
|