@memberjunction/actions-bizapps-lms 2.55.0 → 2.56.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.
Files changed (49) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +15 -0
  3. package/README.md +321 -0
  4. package/dist/providers/learnworlds/actions/create-user.action.d.ts +20 -0
  5. package/dist/providers/learnworlds/actions/create-user.action.d.ts.map +1 -0
  6. package/dist/providers/learnworlds/actions/create-user.action.js +243 -0
  7. package/dist/providers/learnworlds/actions/create-user.action.js.map +1 -0
  8. package/dist/providers/learnworlds/actions/enroll-user.action.d.ts +20 -0
  9. package/dist/providers/learnworlds/actions/enroll-user.action.d.ts.map +1 -0
  10. package/dist/providers/learnworlds/actions/enroll-user.action.js +208 -0
  11. package/dist/providers/learnworlds/actions/enroll-user.action.js.map +1 -0
  12. package/dist/providers/learnworlds/actions/get-certificates.action.d.ts +20 -0
  13. package/dist/providers/learnworlds/actions/get-certificates.action.d.ts.map +1 -0
  14. package/dist/providers/learnworlds/actions/get-certificates.action.js +301 -0
  15. package/dist/providers/learnworlds/actions/get-certificates.action.js.map +1 -0
  16. package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts +36 -0
  17. package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts.map +1 -0
  18. package/dist/providers/learnworlds/actions/get-course-analytics.action.js +333 -0
  19. package/dist/providers/learnworlds/actions/get-course-analytics.action.js.map +1 -0
  20. package/dist/providers/learnworlds/actions/get-course-details.action.d.ts +28 -0
  21. package/dist/providers/learnworlds/actions/get-course-details.action.d.ts.map +1 -0
  22. package/dist/providers/learnworlds/actions/get-course-details.action.js +237 -0
  23. package/dist/providers/learnworlds/actions/get-course-details.action.js.map +1 -0
  24. package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts +28 -0
  25. package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts.map +1 -0
  26. package/dist/providers/learnworlds/actions/get-quiz-results.action.js +368 -0
  27. package/dist/providers/learnworlds/actions/get-quiz-results.action.js.map +1 -0
  28. package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts +20 -0
  29. package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts.map +1 -0
  30. package/dist/providers/learnworlds/actions/get-user-enrollments.action.js +228 -0
  31. package/dist/providers/learnworlds/actions/get-user-enrollments.action.js.map +1 -0
  32. package/dist/providers/learnworlds/actions/index.d.ts +8 -0
  33. package/dist/providers/learnworlds/actions/index.d.ts.map +1 -1
  34. package/dist/providers/learnworlds/actions/index.js +8 -0
  35. package/dist/providers/learnworlds/actions/index.js.map +1 -1
  36. package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts +20 -0
  37. package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts.map +1 -0
  38. package/dist/providers/learnworlds/actions/update-user-progress.action.js +254 -0
  39. package/dist/providers/learnworlds/actions/update-user-progress.action.js.map +1 -0
  40. package/package.json +6 -6
  41. package/src/providers/learnworlds/actions/create-user.action.ts +249 -0
  42. package/src/providers/learnworlds/actions/enroll-user.action.ts +233 -0
  43. package/src/providers/learnworlds/actions/get-certificates.action.ts +332 -0
  44. package/src/providers/learnworlds/actions/get-course-analytics.action.ts +359 -0
  45. package/src/providers/learnworlds/actions/get-course-details.action.ts +267 -0
  46. package/src/providers/learnworlds/actions/get-quiz-results.action.ts +399 -0
  47. package/src/providers/learnworlds/actions/get-user-enrollments.action.ts +242 -0
  48. package/src/providers/learnworlds/actions/index.ts +9 -1
  49. package/src/providers/learnworlds/actions/update-user-progress.action.ts +277 -0
@@ -1,4 +1,4 @@
1
1
 
2
- > @memberjunction/actions-bizapps-lms@2.55.0 build
2
+ > @memberjunction/actions-bizapps-lms@2.56.0 build
3
3
  > tsc
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @memberjunction/actions-bizapps-lms
2
2
 
3
+ ## 2.56.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bf24cae: Various
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [bf24cae]
12
+ - @memberjunction/actions@2.56.0
13
+ - @memberjunction/core-entities@2.56.0
14
+ - @memberjunction/actions-base@2.56.0
15
+ - @memberjunction/core@2.56.0
16
+ - @memberjunction/global@2.56.0
17
+
3
18
  ## 2.55.0
4
19
 
5
20
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,321 @@
1
+ # @memberjunction/actions-bizapps-lms
2
+
3
+ Learning Management System (LMS) integration actions for MemberJunction. This package provides a standardized way to interact with various LMS platforms through MemberJunction's action framework.
4
+
5
+ ## Overview
6
+
7
+ This package implements actions for common LMS operations across multiple learning platforms:
8
+ - LearnWorlds ✅
9
+ - Moodle (coming soon)
10
+ - Canvas (coming soon)
11
+ - Blackboard (coming soon)
12
+ - LearnDash (coming soon)
13
+
14
+ ## Architecture
15
+
16
+ ### Base Classes
17
+
18
+ - **BaseLMSAction**: Abstract base class providing common functionality for all LMS actions
19
+ - Company-based credential management via CompanyIntegration entity
20
+ - Common parameter definitions
21
+ - Learning-specific utilities (progress calculation, duration formatting)
22
+ - Error handling patterns
23
+
24
+ - **Provider-Specific Base Classes** (e.g., LearnWorldsBaseAction):
25
+ - Handle provider-specific authentication
26
+ - API request/response handling
27
+ - Pagination support
28
+ - Data mapping between provider formats and standard formats
29
+
30
+ ### Authentication
31
+
32
+ The package uses MemberJunction's CompanyIntegration entity to store credentials:
33
+ - Each Company can have multiple LMS integrations
34
+ - API keys, OAuth tokens stored securely
35
+ - Environment variable support with database fallback
36
+
37
+ ## Available Actions
38
+
39
+ ### LearnWorlds
40
+
41
+ #### User Management
42
+
43
+ ##### GetLearnWorldsUsersAction
44
+ Retrieves users (students, instructors, admins) from LearnWorlds with comprehensive filtering.
45
+
46
+ **Parameters:**
47
+ - `CompanyID` (required): MemberJunction Company ID
48
+ - `SearchText`: Search by name, email, or username
49
+ - `Role`: Filter by user role (student, instructor, admin)
50
+ - `Status`: Filter by status (active, inactive, suspended)
51
+ - `Tags`: Filter by user tags (comma-separated)
52
+ - `CreatedAfter/CreatedBefore`: Date range filters
53
+ - `SortBy`: Sort field (created, name, email, last_login)
54
+ - `SortOrder`: asc or desc
55
+ - `IncludeCourseStats`: Include enrollment statistics
56
+ - `MaxResults`: Limit results (default: 100)
57
+
58
+ **Output:**
59
+ - `Users`: Array of user objects with profile and statistics
60
+ - `TotalCount`: Total number of users found
61
+ - `Summary`: Statistical summary including role distribution
62
+
63
+ ##### GetLearnWorldsUserDetailsAction
64
+ Retrieves comprehensive details about a specific user including enrollments and achievements.
65
+
66
+ **Parameters:**
67
+ - `CompanyID` (required): MemberJunction Company ID
68
+ - `UserID` (required): LearnWorlds user ID
69
+ - `IncludeEnrollments`: Include course enrollments (default: true)
70
+ - `IncludeStats`: Include additional statistics (default: true)
71
+
72
+ **Output:**
73
+ - `UserDetails`: Complete user profile with learning data
74
+ - `Summary`: User engagement and achievement summary
75
+
76
+ ##### GetLearnWorldsUserProgressAction
77
+ Retrieves detailed learning progress for a user across all courses or specific course.
78
+
79
+ **Parameters:**
80
+ - `CompanyID` (required): MemberJunction Company ID
81
+ - `UserID` (required): LearnWorlds user ID
82
+ - `CourseID`: Optional specific course ID
83
+ - `IncludeUnitDetails`: Include module/unit breakdown
84
+ - `IncludeLessonDetails`: Include individual lesson progress
85
+
86
+ **Output:**
87
+ - `UserProgress`: Comprehensive progress data
88
+ - `Summary`: Progress overview with key metrics
89
+
90
+ #### Course Management
91
+
92
+ ##### GetLearnWorldsCoursesAction
93
+ Retrieves the course catalog with advanced filtering and search capabilities.
94
+
95
+ **Parameters:**
96
+ - `CompanyID` (required): MemberJunction Company ID
97
+ - `SearchText`: Search in title and description
98
+ - `Status`: Filter by status (published, draft, coming_soon)
99
+ - `CategoryID`: Filter by category
100
+ - `Level`: Filter by difficulty (beginner, intermediate, advanced)
101
+ - `Language`: Filter by course language
102
+ - `OnlyFree`: Show only free courses
103
+ - `MinPrice/MaxPrice`: Price range filter
104
+ - `Tags`: Filter by course tags
105
+ - `InstructorID`: Filter by instructor
106
+ - `CreatedAfter/CreatedBefore`: Date range filters
107
+ - `SortBy`: Sort field (created, title, price, enrollments)
108
+ - `SortOrder`: asc or desc
109
+ - `IncludeEnrollmentStats`: Include enrollment data
110
+ - `MaxResults`: Limit results (default: 100)
111
+
112
+ **Output:**
113
+ - `Courses`: Array of course objects with details
114
+ - `TotalCount`: Total number of courses found
115
+ - `Summary`: Catalog statistics including pricing and enrollment data
116
+
117
+ ## Setup
118
+
119
+ ### 1. Create Integration Record
120
+
121
+ ```sql
122
+ INSERT INTO Integration (Name, Description, NavigationBaseURL, ClassName)
123
+ VALUES ('LearnWorlds', 'LearnWorlds LMS Integration',
124
+ 'https://api.learnworlds.com', 'LearnWorldsIntegration');
125
+ ```
126
+
127
+ ### 2. Configure CompanyIntegration
128
+
129
+ ```sql
130
+ INSERT INTO CompanyIntegration (CompanyID, IntegrationID, ExternalSystemID, IsActive)
131
+ VALUES (@CompanyID, @LearnWorldsIntegrationID, @SchoolDomain, 1);
132
+ -- ExternalSystemID: Your LearnWorlds school domain (e.g., 'myschool.learnworlds.com')
133
+ ```
134
+
135
+ ### 3. Set Environment Variables
136
+
137
+ ```bash
138
+ # LearnWorlds API credentials
139
+ BIZAPPS_LEARNWORLDS_[COMPANY_ID]_API_KEY=your_api_key
140
+ BIZAPPS_LEARNWORLDS_[COMPANY_ID]_SCHOOL_DOMAIN=myschool.learnworlds.com
141
+
142
+ # Example for company ID "12345"
143
+ BIZAPPS_LEARNWORLDS_12345_API_KEY=lw_api_xxxxxxxxxxxxx
144
+ BIZAPPS_LEARNWORLDS_12345_SCHOOL_DOMAIN=myschool.learnworlds.com
145
+ ```
146
+
147
+ ## Usage Examples
148
+
149
+ ### Get All Active Students
150
+ ```typescript
151
+ import { GetLearnWorldsUsersAction } from '@memberjunction/actions-bizapps-lms';
152
+
153
+ const action = new GetLearnWorldsUsersAction();
154
+ const result = await action.RunAction({
155
+ Params: [
156
+ { Name: 'CompanyID', Value: 'company-123' },
157
+ { Name: 'Role', Value: 'student' },
158
+ { Name: 'Status', Value: 'active' },
159
+ { Name: 'IncludeCourseStats', Value: true },
160
+ { Name: 'SortBy', Value: 'last_login' },
161
+ { Name: 'SortOrder', Value: 'desc' }
162
+ ],
163
+ ContextUser: currentUser
164
+ });
165
+
166
+ if (result.Success) {
167
+ const users = result.Params.find(p => p.Name === 'Users')?.Value;
168
+ const summary = result.Params.find(p => p.Name === 'Summary')?.Value;
169
+ console.log(`Found ${users.length} active students`);
170
+ console.log(`Average courses per student: ${summary.averageCoursesPerUser}`);
171
+ }
172
+ ```
173
+
174
+ ### Get User Learning Progress
175
+ ```typescript
176
+ import { GetLearnWorldsUserProgressAction } from '@memberjunction/actions-bizapps-lms';
177
+
178
+ const action = new GetLearnWorldsUserProgressAction();
179
+ const result = await action.RunAction({
180
+ Params: [
181
+ { Name: 'CompanyID', Value: 'company-123' },
182
+ { Name: 'UserID', Value: 'user-456' },
183
+ { Name: 'IncludeUnitDetails', Value: true }
184
+ ],
185
+ ContextUser: currentUser
186
+ });
187
+
188
+ if (result.Success) {
189
+ const progress = result.Params.find(p => p.Name === 'UserProgress')?.Value;
190
+ console.log(`User has completed ${progress.coursesCompleted} of ${progress.totalCourses} courses`);
191
+ console.log(`Overall progress: ${progress.overallProgressPercentage}%`);
192
+ }
193
+ ```
194
+
195
+ ### Search Course Catalog
196
+ ```typescript
197
+ import { GetLearnWorldsCoursesAction } from '@memberjunction/actions-bizapps-lms';
198
+
199
+ const action = new GetLearnWorldsCoursesAction();
200
+ const result = await action.RunAction({
201
+ Params: [
202
+ { Name: 'CompanyID', Value: 'company-123' },
203
+ { Name: 'SearchText', Value: 'JavaScript' },
204
+ { Name: 'Status', Value: 'published' },
205
+ { Name: 'Level', Value: 'beginner' },
206
+ { Name: 'MaxPrice', Value: 100 }
207
+ ],
208
+ ContextUser: currentUser
209
+ });
210
+
211
+ if (result.Success) {
212
+ const courses = result.Params.find(p => p.Name === 'Courses')?.Value;
213
+ courses.forEach(course => {
214
+ console.log(`${course.title} - $${course.price} (${course.totalEnrollments} students)`);
215
+ });
216
+ }
217
+ ```
218
+
219
+ ## Common Data Models
220
+
221
+ ### LMS User
222
+ ```typescript
223
+ interface LMSUser {
224
+ id: string;
225
+ email: string;
226
+ username: string;
227
+ firstName?: string;
228
+ lastName?: string;
229
+ status: 'active' | 'inactive' | 'suspended';
230
+ role: string;
231
+ createdAt: Date;
232
+ lastLoginAt?: Date;
233
+ totalCourses?: number;
234
+ completedCourses?: number;
235
+ totalTimeSpent?: number;
236
+ }
237
+ ```
238
+
239
+ ### Course Progress
240
+ ```typescript
241
+ interface CourseProgress {
242
+ courseId: string;
243
+ courseTitle: string;
244
+ enrolledAt: Date;
245
+ progressPercentage: number;
246
+ completedUnits: number;
247
+ totalUnits: number;
248
+ totalTimeSpent: number;
249
+ status: 'not_started' | 'in_progress' | 'completed' | 'expired';
250
+ certificateEarned: boolean;
251
+ }
252
+ ```
253
+
254
+ ### Course
255
+ ```typescript
256
+ interface LMSCourse {
257
+ id: string;
258
+ title: string;
259
+ description?: string;
260
+ status: 'published' | 'draft' | 'coming_soon';
261
+ price?: number;
262
+ currency?: string;
263
+ level?: 'beginner' | 'intermediate' | 'advanced' | 'all';
264
+ duration?: number;
265
+ totalEnrollments: number;
266
+ averageRating?: number;
267
+ instructorName?: string;
268
+ }
269
+ ```
270
+
271
+ ## Planned Actions
272
+
273
+ ### Coming Soon
274
+ - **GetCourseDetailsAction** - Detailed course information with curriculum
275
+ - **EnrollUserAction** - Enroll users in courses
276
+ - **GetUserEnrollmentsAction** - Get all enrollments for a user
277
+ - **GetCourseAnalyticsAction** - Course performance analytics
278
+ - **CreateUserAction** - Create new LMS users
279
+ - **UpdateUserProgressAction** - Update user progress manually
280
+ - **GetCertificatesAction** - Retrieve earned certificates
281
+ - **GetQuizResultsAction** - Get quiz/assessment results
282
+
283
+ ## Development
284
+
285
+ ### Adding New Providers
286
+
287
+ 1. Create provider directory: `src/providers/[provider-name]/`
288
+ 2. Extend `BaseLMSAction` with provider-specific base class
289
+ 3. Implement authentication mechanism
290
+ 4. Add pagination support for list endpoints
291
+ 5. Map provider data to common LMS models
292
+ 6. Implement core actions (users, courses, progress)
293
+ 7. Add comprehensive error handling
294
+ 8. Write unit tests
295
+ 9. Update documentation
296
+
297
+ ### Testing
298
+
299
+ ```bash
300
+ # Run tests
301
+ npm test
302
+
303
+ # Build package
304
+ npm run build
305
+
306
+ # Watch mode
307
+ npm run watch
308
+ ```
309
+
310
+ ## Best Practices
311
+
312
+ 1. **Pagination**: Always implement pagination for list endpoints
313
+ 2. **Rate Limiting**: Respect provider API limits
314
+ 3. **Data Mapping**: Consistently map to common models
315
+ 4. **Error Messages**: Provide clear, actionable error messages
316
+ 5. **Progress Tracking**: Calculate progress percentages consistently
317
+ 6. **Time Formatting**: Use consistent duration formatting
318
+
319
+ ## License
320
+
321
+ ISC
@@ -0,0 +1,20 @@
1
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action';
2
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
3
+ /**
4
+ * Action to create a new user in LearnWorlds
5
+ */
6
+ export declare class CreateUserAction extends LearnWorldsBaseAction {
7
+ /**
8
+ * Create a new user
9
+ */
10
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
11
+ /**
12
+ * Define the parameters this action expects
13
+ */
14
+ get Params(): ActionParam[];
15
+ /**
16
+ * Metadata about this action
17
+ */
18
+ get Description(): string;
19
+ }
20
+ //# sourceMappingURL=create-user.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-user.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/create-user.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEhG;;GAEG;AACH,qBACa,gBAAiB,SAAQ,qBAAqB;IACvD;;OAEG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsJvF;;OAEG;IACH,IAAW,MAAM,IAAI,WAAW,EAAE,CA2EjC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;CACJ"}
@@ -0,0 +1,243 @@
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.CreateUserAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const learnworlds_base_action_1 = require("../learnworlds-base.action");
12
+ /**
13
+ * Action to create a new user in LearnWorlds
14
+ */
15
+ let CreateUserAction = class CreateUserAction extends learnworlds_base_action_1.LearnWorldsBaseAction {
16
+ /**
17
+ * Create a new user
18
+ */
19
+ async InternalRunAction(params) {
20
+ const { Params, ContextUser } = params;
21
+ this.params = Params; // Set params for base class to use
22
+ try {
23
+ // Extract and validate parameters
24
+ const email = this.getParamValue(Params, 'Email');
25
+ const username = this.getParamValue(Params, 'Username');
26
+ const password = this.getParamValue(Params, 'Password');
27
+ const firstName = this.getParamValue(Params, 'FirstName');
28
+ const lastName = this.getParamValue(Params, 'LastName');
29
+ const role = this.getParamValue(Params, 'Role') || 'student';
30
+ const isActive = this.getParamValue(Params, 'IsActive') !== false;
31
+ const sendWelcomeEmail = this.getParamValue(Params, 'SendWelcomeEmail') !== false;
32
+ const tags = this.getParamValue(Params, 'Tags');
33
+ const customFields = this.getParamValue(Params, 'CustomFields');
34
+ const enrollInCourses = this.getParamValue(Params, 'EnrollInCourses');
35
+ if (!email) {
36
+ return {
37
+ Success: false,
38
+ ResultCode: 'VALIDATION_ERROR',
39
+ Message: 'Email is required',
40
+ Params
41
+ };
42
+ }
43
+ // Prepare user data
44
+ const userData = {
45
+ email: email,
46
+ role: role,
47
+ is_active: isActive
48
+ };
49
+ // Add optional fields
50
+ if (username)
51
+ userData.username = username;
52
+ if (password)
53
+ userData.password = password;
54
+ if (firstName)
55
+ userData.first_name = firstName;
56
+ if (lastName)
57
+ userData.last_name = lastName;
58
+ if (sendWelcomeEmail !== undefined)
59
+ userData.send_welcome_email = sendWelcomeEmail;
60
+ // Add tags if provided (expecting comma-separated string or array)
61
+ if (tags) {
62
+ userData.tags = Array.isArray(tags) ? tags : tags.split(',').map((t) => t.trim());
63
+ }
64
+ // Add custom fields if provided
65
+ if (customFields) {
66
+ userData.custom_fields = customFields;
67
+ }
68
+ // Create user
69
+ const newUser = await this.makeLearnWorldsRequest('users', 'POST', userData, ContextUser);
70
+ // Format user details
71
+ const userDetails = {
72
+ id: newUser.id,
73
+ email: newUser.email,
74
+ username: newUser.username,
75
+ firstName: newUser.first_name,
76
+ lastName: newUser.last_name,
77
+ fullName: `${newUser.first_name || ''} ${newUser.last_name || ''}`.trim(),
78
+ role: newUser.role,
79
+ status: newUser.is_active ? 'active' : 'inactive',
80
+ tags: newUser.tags || [],
81
+ customFields: newUser.custom_fields || {},
82
+ createdAt: newUser.created_at,
83
+ loginUrl: newUser.login_url,
84
+ resetPasswordUrl: newUser.reset_password_url
85
+ };
86
+ // Enroll in courses if requested
87
+ const enrollmentResults = [];
88
+ if (enrollInCourses && enrollInCourses.length > 0) {
89
+ const courseIds = Array.isArray(enrollInCourses) ? enrollInCourses : [enrollInCourses];
90
+ for (const courseId of courseIds) {
91
+ try {
92
+ const enrollData = await this.makeLearnWorldsRequest(`courses/${courseId}/enrollments`, 'POST', {
93
+ user_id: newUser.id,
94
+ justification: 'Enrolled during user creation',
95
+ notify_user: false
96
+ }, ContextUser);
97
+ enrollmentResults.push({
98
+ courseId: courseId,
99
+ success: true,
100
+ enrollmentId: enrollData.id
101
+ });
102
+ }
103
+ catch (enrollError) {
104
+ enrollmentResults.push({
105
+ courseId: courseId,
106
+ success: false,
107
+ error: enrollError instanceof Error ? enrollError.message : 'Enrollment failed'
108
+ });
109
+ }
110
+ }
111
+ }
112
+ // Create summary
113
+ const summary = {
114
+ userId: userDetails.id,
115
+ email: userDetails.email,
116
+ username: userDetails.username,
117
+ fullName: userDetails.fullName,
118
+ role: userDetails.role,
119
+ status: userDetails.status,
120
+ welcomeEmailSent: sendWelcomeEmail,
121
+ coursesEnrolled: enrollmentResults.filter(r => r.success).length,
122
+ totalCoursesRequested: enrollmentResults.length,
123
+ loginUrl: userDetails.loginUrl
124
+ };
125
+ // Update output parameters
126
+ const outputParams = [...Params];
127
+ const userDetailsParam = outputParams.find(p => p.Name === 'UserDetails');
128
+ if (userDetailsParam)
129
+ userDetailsParam.Value = userDetails;
130
+ const enrollmentResultsParam = outputParams.find(p => p.Name === 'EnrollmentResults');
131
+ if (enrollmentResultsParam)
132
+ enrollmentResultsParam.Value = enrollmentResults;
133
+ const summaryParam = outputParams.find(p => p.Name === 'Summary');
134
+ if (summaryParam)
135
+ summaryParam.Value = summary;
136
+ return {
137
+ Success: true,
138
+ ResultCode: 'SUCCESS',
139
+ Message: `Successfully created user ${userDetails.email}`,
140
+ Params: outputParams
141
+ };
142
+ }
143
+ catch (error) {
144
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
145
+ return {
146
+ Success: false,
147
+ ResultCode: 'ERROR',
148
+ Message: `Error creating user: ${errorMessage}`,
149
+ Params
150
+ };
151
+ }
152
+ }
153
+ /**
154
+ * Define the parameters this action expects
155
+ */
156
+ get Params() {
157
+ const baseParams = this.getCommonLMSParams();
158
+ const specificParams = [
159
+ {
160
+ Name: 'Email',
161
+ Type: 'Input',
162
+ Value: null
163
+ },
164
+ {
165
+ Name: 'Username',
166
+ Type: 'Input',
167
+ Value: null
168
+ },
169
+ {
170
+ Name: 'Password',
171
+ Type: 'Input',
172
+ Value: null
173
+ },
174
+ {
175
+ Name: 'FirstName',
176
+ Type: 'Input',
177
+ Value: null
178
+ },
179
+ {
180
+ Name: 'LastName',
181
+ Type: 'Input',
182
+ Value: null
183
+ },
184
+ {
185
+ Name: 'Role',
186
+ Type: 'Input',
187
+ Value: 'student'
188
+ },
189
+ {
190
+ Name: 'IsActive',
191
+ Type: 'Input',
192
+ Value: true
193
+ },
194
+ {
195
+ Name: 'SendWelcomeEmail',
196
+ Type: 'Input',
197
+ Value: true
198
+ },
199
+ {
200
+ Name: 'Tags',
201
+ Type: 'Input',
202
+ Value: null
203
+ },
204
+ {
205
+ Name: 'CustomFields',
206
+ Type: 'Input',
207
+ Value: null
208
+ },
209
+ {
210
+ Name: 'EnrollInCourses',
211
+ Type: 'Input',
212
+ Value: null
213
+ },
214
+ {
215
+ Name: 'UserDetails',
216
+ Type: 'Output',
217
+ Value: null
218
+ },
219
+ {
220
+ Name: 'EnrollmentResults',
221
+ Type: 'Output',
222
+ Value: null
223
+ },
224
+ {
225
+ Name: 'Summary',
226
+ Type: 'Output',
227
+ Value: null
228
+ }
229
+ ];
230
+ return [...baseParams, ...specificParams];
231
+ }
232
+ /**
233
+ * Metadata about this action
234
+ */
235
+ get Description() {
236
+ return 'Creates a new user in LearnWorlds with optional course enrollments and welcome email';
237
+ }
238
+ };
239
+ exports.CreateUserAction = CreateUserAction;
240
+ exports.CreateUserAction = CreateUserAction = __decorate([
241
+ (0, global_1.RegisterClass)(learnworlds_base_action_1.LearnWorldsBaseAction, 'CreateUserAction')
242
+ ], CreateUserAction);
243
+ //# sourceMappingURL=create-user.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-user.action.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/create-user.action.ts"],"names":[],"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,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,SAAS;aACnB;YACD;gBACI,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,iBAAiB;gBACvB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,IAAI;aACd;YACD;gBACI,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,IAAI;aACd;SACJ,CAAC;QACF,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,sFAAsF,CAAC;IAClG,CAAC;CACJ,CAAA;AAhPY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAa,EAAC,+CAAqB,EAAE,kBAAkB,CAAC;GAC5C,gBAAgB,CAgP5B"}
@@ -0,0 +1,20 @@
1
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action';
2
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
3
+ /**
4
+ * Action to enroll a user in a LearnWorlds course
5
+ */
6
+ export declare class EnrollUserAction extends LearnWorldsBaseAction {
7
+ /**
8
+ * Enroll a user in a course
9
+ */
10
+ InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
11
+ /**
12
+ * Define the parameters this action expects
13
+ */
14
+ get Params(): ActionParam[];
15
+ /**
16
+ * Metadata about this action
17
+ */
18
+ get Description(): string;
19
+ }
20
+ //# sourceMappingURL=enroll-user.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enroll-user.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/enroll-user.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEhG;;GAEG;AACH,qBACa,gBAAiB,SAAQ,qBAAqB;IACvD;;OAEG;IACU,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+JpF;;OAEG;IACH,IAAW,MAAM,IAAI,WAAW,EAAE,CAkDjC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;CACJ"}