@memberjunction/actions-bizapps-lms 5.3.1 → 5.4.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.
Files changed (194) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/LEARNWORLDS_SIDECAR_PLAN.md +845 -0
  4. package/dist/base/base-lms.action.d.ts +26 -4
  5. package/dist/base/base-lms.action.d.ts.map +1 -1
  6. package/dist/base/base-lms.action.js +73 -17
  7. package/dist/base/base-lms.action.js.map +1 -1
  8. package/dist/providers/learnworlds/actions/attach-tags.action.d.ts +26 -0
  9. package/dist/providers/learnworlds/actions/attach-tags.action.d.ts.map +1 -0
  10. package/dist/providers/learnworlds/actions/attach-tags.action.js +79 -0
  11. package/dist/providers/learnworlds/actions/attach-tags.action.js.map +1 -0
  12. package/dist/providers/learnworlds/actions/create-user.action.d.ts +24 -1
  13. package/dist/providers/learnworlds/actions/create-user.action.d.ts.map +1 -1
  14. package/dist/providers/learnworlds/actions/create-user.action.js +166 -142
  15. package/dist/providers/learnworlds/actions/create-user.action.js.map +1 -1
  16. package/dist/providers/learnworlds/actions/detach-tags.action.d.ts +26 -0
  17. package/dist/providers/learnworlds/actions/detach-tags.action.d.ts.map +1 -0
  18. package/dist/providers/learnworlds/actions/detach-tags.action.js +79 -0
  19. package/dist/providers/learnworlds/actions/detach-tags.action.js.map +1 -0
  20. package/dist/providers/learnworlds/actions/enroll-user.action.d.ts +31 -3
  21. package/dist/providers/learnworlds/actions/enroll-user.action.d.ts.map +1 -1
  22. package/dist/providers/learnworlds/actions/enroll-user.action.js +179 -125
  23. package/dist/providers/learnworlds/actions/enroll-user.action.js.map +1 -1
  24. package/dist/providers/learnworlds/actions/get-bulk-data.action.d.ts +79 -0
  25. package/dist/providers/learnworlds/actions/get-bulk-data.action.d.ts.map +1 -0
  26. package/dist/providers/learnworlds/actions/get-bulk-data.action.js +359 -0
  27. package/dist/providers/learnworlds/actions/get-bulk-data.action.js.map +1 -0
  28. package/dist/providers/learnworlds/actions/get-bundles.action.d.ts +34 -0
  29. package/dist/providers/learnworlds/actions/get-bundles.action.d.ts.map +1 -0
  30. package/dist/providers/learnworlds/actions/get-bundles.action.js +107 -0
  31. package/dist/providers/learnworlds/actions/get-bundles.action.js.map +1 -0
  32. package/dist/providers/learnworlds/actions/get-certificates.action.d.ts +33 -2
  33. package/dist/providers/learnworlds/actions/get-certificates.action.d.ts.map +1 -1
  34. package/dist/providers/learnworlds/actions/get-certificates.action.js +311 -244
  35. package/dist/providers/learnworlds/actions/get-certificates.action.js.map +1 -1
  36. package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts +14 -14
  37. package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts.map +1 -1
  38. package/dist/providers/learnworlds/actions/get-course-analytics.action.js +234 -226
  39. package/dist/providers/learnworlds/actions/get-course-analytics.action.js.map +1 -1
  40. package/dist/providers/learnworlds/actions/get-course-details.action.d.ts +42 -6
  41. package/dist/providers/learnworlds/actions/get-course-details.action.d.ts.map +1 -1
  42. package/dist/providers/learnworlds/actions/get-course-details.action.js +182 -148
  43. package/dist/providers/learnworlds/actions/get-course-details.action.js.map +1 -1
  44. package/dist/providers/learnworlds/actions/get-courses.action.d.ts +29 -82
  45. package/dist/providers/learnworlds/actions/get-courses.action.d.ts.map +1 -1
  46. package/dist/providers/learnworlds/actions/get-courses.action.js +188 -207
  47. package/dist/providers/learnworlds/actions/get-courses.action.js.map +1 -1
  48. package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts +22 -2
  49. package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts.map +1 -1
  50. package/dist/providers/learnworlds/actions/get-quiz-results.action.js +316 -294
  51. package/dist/providers/learnworlds/actions/get-quiz-results.action.js.map +1 -1
  52. package/dist/providers/learnworlds/actions/get-user-details.action.d.ts +23 -59
  53. package/dist/providers/learnworlds/actions/get-user-details.action.d.ts.map +1 -1
  54. package/dist/providers/learnworlds/actions/get-user-details.action.js +113 -114
  55. package/dist/providers/learnworlds/actions/get-user-details.action.js.map +1 -1
  56. package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts +43 -5
  57. package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts.map +1 -1
  58. package/dist/providers/learnworlds/actions/get-user-enrollments.action.js +191 -147
  59. package/dist/providers/learnworlds/actions/get-user-enrollments.action.js.map +1 -1
  60. package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts +21 -92
  61. package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts.map +1 -1
  62. package/dist/providers/learnworlds/actions/get-user-progress.action.js +145 -166
  63. package/dist/providers/learnworlds/actions/get-user-progress.action.js.map +1 -1
  64. package/dist/providers/learnworlds/actions/get-users.action.d.ts +14 -28
  65. package/dist/providers/learnworlds/actions/get-users.action.d.ts.map +1 -1
  66. package/dist/providers/learnworlds/actions/get-users.action.js +122 -143
  67. package/dist/providers/learnworlds/actions/get-users.action.js.map +1 -1
  68. package/dist/providers/learnworlds/actions/index.d.ts +7 -0
  69. package/dist/providers/learnworlds/actions/index.d.ts.map +1 -1
  70. package/dist/providers/learnworlds/actions/index.js +7 -0
  71. package/dist/providers/learnworlds/actions/index.js.map +1 -1
  72. package/dist/providers/learnworlds/actions/onboard-learner.action.d.ts +53 -0
  73. package/dist/providers/learnworlds/actions/onboard-learner.action.d.ts.map +1 -0
  74. package/dist/providers/learnworlds/actions/onboard-learner.action.js +236 -0
  75. package/dist/providers/learnworlds/actions/onboard-learner.action.js.map +1 -0
  76. package/dist/providers/learnworlds/actions/sso-login.action.d.ts +35 -0
  77. package/dist/providers/learnworlds/actions/sso-login.action.d.ts.map +1 -0
  78. package/dist/providers/learnworlds/actions/sso-login.action.js +101 -0
  79. package/dist/providers/learnworlds/actions/sso-login.action.js.map +1 -0
  80. package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts +12 -1
  81. package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts.map +1 -1
  82. package/dist/providers/learnworlds/actions/update-user-progress.action.js +167 -210
  83. package/dist/providers/learnworlds/actions/update-user-progress.action.js.map +1 -1
  84. package/dist/providers/learnworlds/actions/update-user.action.d.ts +39 -0
  85. package/dist/providers/learnworlds/actions/update-user.action.d.ts.map +1 -0
  86. package/dist/providers/learnworlds/actions/update-user.action.js +168 -0
  87. package/dist/providers/learnworlds/actions/update-user.action.js.map +1 -0
  88. package/dist/providers/learnworlds/index.d.ts +1 -0
  89. package/dist/providers/learnworlds/index.d.ts.map +1 -1
  90. package/dist/providers/learnworlds/index.js +2 -0
  91. package/dist/providers/learnworlds/index.js.map +1 -1
  92. package/dist/providers/learnworlds/interfaces/bundle.types.d.ts +16 -0
  93. package/dist/providers/learnworlds/interfaces/bundle.types.d.ts.map +1 -0
  94. package/dist/providers/learnworlds/interfaces/bundle.types.js +2 -0
  95. package/dist/providers/learnworlds/interfaces/bundle.types.js.map +1 -0
  96. package/dist/providers/learnworlds/interfaces/certificate.types.d.ts +66 -0
  97. package/dist/providers/learnworlds/interfaces/certificate.types.d.ts.map +1 -0
  98. package/dist/providers/learnworlds/interfaces/certificate.types.js +2 -0
  99. package/dist/providers/learnworlds/interfaces/certificate.types.js.map +1 -0
  100. package/dist/providers/learnworlds/interfaces/common.types.d.ts +221 -0
  101. package/dist/providers/learnworlds/interfaces/common.types.d.ts.map +1 -0
  102. package/dist/providers/learnworlds/interfaces/common.types.js +2 -0
  103. package/dist/providers/learnworlds/interfaces/common.types.js.map +1 -0
  104. package/dist/providers/learnworlds/interfaces/course.types.d.ts +393 -0
  105. package/dist/providers/learnworlds/interfaces/course.types.d.ts.map +1 -0
  106. package/dist/providers/learnworlds/interfaces/course.types.js +2 -0
  107. package/dist/providers/learnworlds/interfaces/course.types.js.map +1 -0
  108. package/dist/providers/learnworlds/interfaces/enrollment.types.d.ts +165 -0
  109. package/dist/providers/learnworlds/interfaces/enrollment.types.d.ts.map +1 -0
  110. package/dist/providers/learnworlds/interfaces/enrollment.types.js +2 -0
  111. package/dist/providers/learnworlds/interfaces/enrollment.types.js.map +1 -0
  112. package/dist/providers/learnworlds/interfaces/index.d.ts +12 -0
  113. package/dist/providers/learnworlds/interfaces/index.d.ts.map +1 -0
  114. package/dist/providers/learnworlds/interfaces/index.js +13 -0
  115. package/dist/providers/learnworlds/interfaces/index.js.map +1 -0
  116. package/dist/providers/learnworlds/interfaces/onboarding.types.d.ts +39 -0
  117. package/dist/providers/learnworlds/interfaces/onboarding.types.d.ts.map +1 -0
  118. package/dist/providers/learnworlds/interfaces/onboarding.types.js +2 -0
  119. package/dist/providers/learnworlds/interfaces/onboarding.types.js.map +1 -0
  120. package/dist/providers/learnworlds/interfaces/quiz.types.d.ts +108 -0
  121. package/dist/providers/learnworlds/interfaces/quiz.types.d.ts.map +1 -0
  122. package/dist/providers/learnworlds/interfaces/quiz.types.js +2 -0
  123. package/dist/providers/learnworlds/interfaces/quiz.types.js.map +1 -0
  124. package/dist/providers/learnworlds/interfaces/sso.types.d.ts +18 -0
  125. package/dist/providers/learnworlds/interfaces/sso.types.d.ts.map +1 -0
  126. package/dist/providers/learnworlds/interfaces/sso.types.js +2 -0
  127. package/dist/providers/learnworlds/interfaces/sso.types.js.map +1 -0
  128. package/dist/providers/learnworlds/interfaces/sync.types.d.ts +44 -0
  129. package/dist/providers/learnworlds/interfaces/sync.types.d.ts.map +1 -0
  130. package/dist/providers/learnworlds/interfaces/sync.types.js +2 -0
  131. package/dist/providers/learnworlds/interfaces/sync.types.js.map +1 -0
  132. package/dist/providers/learnworlds/interfaces/tag.types.d.ts +17 -0
  133. package/dist/providers/learnworlds/interfaces/tag.types.d.ts.map +1 -0
  134. package/dist/providers/learnworlds/interfaces/tag.types.js +2 -0
  135. package/dist/providers/learnworlds/interfaces/tag.types.js.map +1 -0
  136. package/dist/providers/learnworlds/interfaces/user.types.d.ts +198 -0
  137. package/dist/providers/learnworlds/interfaces/user.types.d.ts.map +1 -0
  138. package/dist/providers/learnworlds/interfaces/user.types.js +2 -0
  139. package/dist/providers/learnworlds/interfaces/user.types.js.map +1 -0
  140. package/dist/providers/learnworlds/learnworlds-base.action.d.ts +111 -7
  141. package/dist/providers/learnworlds/learnworlds-base.action.d.ts.map +1 -1
  142. package/dist/providers/learnworlds/learnworlds-base.action.js +293 -56
  143. package/dist/providers/learnworlds/learnworlds-base.action.js.map +1 -1
  144. package/package.json +8 -7
  145. package/src/__tests__/attach-tags.action.test.ts +137 -0
  146. package/src/__tests__/create-user.action.test.ts +311 -0
  147. package/src/__tests__/detach-tags.action.test.ts +136 -0
  148. package/src/__tests__/enroll-user.action.test.ts +283 -0
  149. package/src/__tests__/get-bulk-data.action.test.ts +649 -0
  150. package/src/__tests__/get-bundles.action.test.ts +215 -0
  151. package/src/__tests__/lms.test.ts +275 -184
  152. package/src/__tests__/onboard-learner.action.test.ts +455 -0
  153. package/src/__tests__/sso-login.action.test.ts +256 -0
  154. package/src/__tests__/update-user.action.test.ts +350 -0
  155. package/src/base/base-lms.action.ts +226 -163
  156. package/src/providers/learnworlds/actions/attach-tags.action.ts +90 -0
  157. package/src/providers/learnworlds/actions/create-user.action.ts +291 -235
  158. package/src/providers/learnworlds/actions/detach-tags.action.ts +90 -0
  159. package/src/providers/learnworlds/actions/enroll-user.action.ts +326 -220
  160. package/src/providers/learnworlds/actions/get-bulk-data.action.ts +438 -0
  161. package/src/providers/learnworlds/actions/get-bundles.action.ts +139 -0
  162. package/src/providers/learnworlds/actions/get-certificates.action.ts +499 -309
  163. package/src/providers/learnworlds/actions/get-course-analytics.action.ts +470 -337
  164. package/src/providers/learnworlds/actions/get-course-details.action.ts +395 -249
  165. package/src/providers/learnworlds/actions/get-courses.action.ts +508 -565
  166. package/src/providers/learnworlds/actions/get-quiz-results.action.ts +606 -381
  167. package/src/providers/learnworlds/actions/get-user-details.action.ts +335 -349
  168. package/src/providers/learnworlds/actions/get-user-enrollments.action.ts +328 -228
  169. package/src/providers/learnworlds/actions/get-user-progress.action.ts +522 -571
  170. package/src/providers/learnworlds/actions/get-users.action.ts +231 -282
  171. package/src/providers/learnworlds/actions/index.ts +8 -1
  172. package/src/providers/learnworlds/actions/onboard-learner.action.ts +286 -0
  173. package/src/providers/learnworlds/actions/sso-login.action.ts +116 -0
  174. package/src/providers/learnworlds/actions/update-user-progress.action.ts +301 -263
  175. package/src/providers/learnworlds/actions/update-user.action.ts +181 -0
  176. package/src/providers/learnworlds/index.ts +4 -1
  177. package/src/providers/learnworlds/interfaces/bundle.types.ts +17 -0
  178. package/src/providers/learnworlds/interfaces/certificate.types.ts +69 -0
  179. package/src/providers/learnworlds/interfaces/common.types.ts +233 -0
  180. package/src/providers/learnworlds/interfaces/course.types.ts +411 -0
  181. package/src/providers/learnworlds/interfaces/enrollment.types.ts +176 -0
  182. package/src/providers/learnworlds/interfaces/index.ts +12 -0
  183. package/src/providers/learnworlds/interfaces/onboarding.types.ts +41 -0
  184. package/src/providers/learnworlds/interfaces/quiz.types.ts +118 -0
  185. package/src/providers/learnworlds/interfaces/sso.types.ts +19 -0
  186. package/src/providers/learnworlds/interfaces/sync.types.ts +46 -0
  187. package/src/providers/learnworlds/interfaces/tag.types.ts +18 -0
  188. package/src/providers/learnworlds/interfaces/user.types.ts +204 -0
  189. package/src/providers/learnworlds/learnworlds-base.action.ts +468 -210
  190. package/tsconfig.json +1 -1
  191. package/dist/__tests__/lms.test.d.ts +0 -2
  192. package/dist/__tests__/lms.test.d.ts.map +0 -1
  193. package/dist/__tests__/lms.test.js +0 -232
  194. package/dist/__tests__/lms.test.js.map +0 -1
@@ -0,0 +1,181 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action';
3
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
4
+ import { BaseAction } from '@memberjunction/actions';
5
+ import { UserInfo } from '@memberjunction/core';
6
+ import { UpdateUserParams, UpdateUserResult, UpdateUserSummary } from '../interfaces';
7
+ import { LearnWorldsUser, LWApiUser } from '../interfaces';
8
+
9
+ /**
10
+ * Action to update an existing user in LearnWorlds
11
+ */
12
+ @RegisterClass(BaseAction, 'UpdateUserAction')
13
+ export class UpdateUserAction extends LearnWorldsBaseAction {
14
+ /**
15
+ * Updates a user's profile in LearnWorlds.
16
+ * Only sends non-undefined fields in the update body.
17
+ */
18
+ public async UpdateUser(params: UpdateUserParams, contextUser: UserInfo): Promise<UpdateUserResult> {
19
+ this.SetCompanyContext(params.CompanyID);
20
+
21
+ this.validatePathSegment(params.UserID, 'UserID');
22
+
23
+ const { body, fieldsUpdated } = this.buildUpdateBody(params);
24
+
25
+ if (fieldsUpdated.length === 0) {
26
+ throw new Error('No fields provided to update');
27
+ }
28
+
29
+ const response = await this.makeLearnWorldsRequest<LWApiUser>(`users/${params.UserID}`, 'PUT', body, contextUser);
30
+
31
+ const userDetails = this.mapResponseToUser(response);
32
+ const summary = this.buildUpdateSummary(params.UserID, userDetails.email, fieldsUpdated);
33
+
34
+ return { UserDetails: userDetails, Summary: summary };
35
+ }
36
+
37
+ /**
38
+ * Builds the API request body from non-undefined params and tracks which fields were updated
39
+ */
40
+ private buildUpdateBody(params: UpdateUserParams): { body: Record<string, unknown>; fieldsUpdated: string[] } {
41
+ const body: Record<string, unknown> = {};
42
+ const fieldsUpdated: string[] = [];
43
+
44
+ if (params.Email !== undefined) {
45
+ body.email = params.Email;
46
+ fieldsUpdated.push('Email');
47
+ }
48
+ if (params.Username !== undefined) {
49
+ body.username = params.Username;
50
+ fieldsUpdated.push('Username');
51
+ }
52
+ if (params.Password !== undefined) {
53
+ body.password = params.Password;
54
+ fieldsUpdated.push('Password');
55
+ }
56
+ if (params.FirstName !== undefined) {
57
+ body.first_name = params.FirstName;
58
+ fieldsUpdated.push('FirstName');
59
+ }
60
+ if (params.LastName !== undefined) {
61
+ body.last_name = params.LastName;
62
+ fieldsUpdated.push('LastName');
63
+ }
64
+ if (params.Role !== undefined) {
65
+ body.role = this.validateRole(params.Role);
66
+ fieldsUpdated.push('Role');
67
+ }
68
+ if (params.IsActive !== undefined) {
69
+ body.is_active = params.IsActive;
70
+ fieldsUpdated.push('IsActive');
71
+ }
72
+ if (params.Tags !== undefined) {
73
+ body.tags = params.Tags;
74
+ fieldsUpdated.push('Tags');
75
+ }
76
+ if (params.CustomFields !== undefined) {
77
+ body.custom_fields = params.CustomFields;
78
+ fieldsUpdated.push('CustomFields');
79
+ }
80
+
81
+ return { body, fieldsUpdated };
82
+ }
83
+
84
+ /**
85
+ * Maps the raw LearnWorlds API response to a LearnWorldsUser
86
+ */
87
+ private mapResponseToUser(response: LWApiUser): LearnWorldsUser {
88
+ return {
89
+ id: response.id || response._id || '',
90
+ email: response.email,
91
+ username: response.username || response.email,
92
+ firstName: response.first_name,
93
+ lastName: response.last_name,
94
+ fullName: response.full_name || `${response.first_name || ''} ${response.last_name || ''}`.trim(),
95
+ status: this.mapUserStatus(response.status || 'active'),
96
+ role: response.role || 'student',
97
+ createdAt: this.parseLearnWorldsDate(response.created || response.created_at || ''),
98
+ lastLoginAt: response.last_login ? this.parseLearnWorldsDate(response.last_login) : undefined,
99
+ tags: response.tags || [],
100
+ customFields: response.custom_fields || {},
101
+ };
102
+ }
103
+
104
+ /**
105
+ * Builds a summary of what was updated
106
+ */
107
+ private buildUpdateSummary(userId: string, email: string, fieldsUpdated: string[]): UpdateUserSummary {
108
+ return {
109
+ userId,
110
+ email,
111
+ fieldsUpdated,
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Framework entry point that delegates to the typed public method
117
+ */
118
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
119
+ const { Params, ContextUser } = params;
120
+ this.params = Params;
121
+
122
+ try {
123
+ const updateParams: UpdateUserParams = {
124
+ CompanyID: this.getRequiredStringParam(Params, 'CompanyID'),
125
+ UserID: this.getRequiredStringParam(Params, 'UserID'),
126
+ Email: this.getOptionalStringParam(Params, 'Email'),
127
+ Username: this.getOptionalStringParam(Params, 'Username'),
128
+ Password: this.getOptionalStringParam(Params, 'Password'),
129
+ FirstName: this.getOptionalStringParam(Params, 'FirstName'),
130
+ LastName: this.getOptionalStringParam(Params, 'LastName'),
131
+ Role: this.getOptionalStringParam(Params, 'Role'),
132
+ IsActive: this.getOptionalBooleanParam(Params, 'IsActive', undefined),
133
+ Tags: this.getOptionalStringArrayParam(Params, 'Tags'),
134
+ CustomFields: this.getParamValue(Params, 'CustomFields') as Record<string, unknown> | undefined,
135
+ };
136
+
137
+ if (!updateParams.UserID) {
138
+ return this.buildErrorResult('VALIDATION_ERROR', 'UserID is required', Params);
139
+ }
140
+
141
+ const result = await this.UpdateUser(updateParams, ContextUser);
142
+
143
+ this.setOutputParam(Params, 'UserDetails', result.UserDetails);
144
+ this.setOutputParam(Params, 'Summary', result.Summary);
145
+
146
+ return this.buildSuccessResult(`Successfully updated user ${result.UserDetails.email} (${result.Summary.fieldsUpdated.length} field(s) updated)`, Params);
147
+ } catch (error) {
148
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
149
+ return this.buildErrorResult('ERROR', `Error updating user: ${errorMessage}`, Params);
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Define the parameters this action expects
155
+ */
156
+ public get Params(): ActionParam[] {
157
+ const baseParams = this.getCommonLMSParams();
158
+ const specificParams: ActionParam[] = [
159
+ { Name: 'UserID', Type: 'Input', Value: null },
160
+ { Name: 'Email', Type: 'Input', Value: null },
161
+ { Name: 'Username', Type: 'Input', Value: null },
162
+ { Name: 'Password', Type: 'Input', Value: null },
163
+ { Name: 'FirstName', Type: 'Input', Value: null },
164
+ { Name: 'LastName', Type: 'Input', Value: null },
165
+ { Name: 'Role', Type: 'Input', Value: null },
166
+ { Name: 'IsActive', Type: 'Input', Value: null },
167
+ { Name: 'Tags', Type: 'Input', Value: null },
168
+ { Name: 'CustomFields', Type: 'Input', Value: null },
169
+ { Name: 'UserDetails', Type: 'Output', Value: null },
170
+ { Name: 'Summary', Type: 'Output', Value: null },
171
+ ];
172
+ return [...baseParams, ...specificParams];
173
+ }
174
+
175
+ /**
176
+ * Metadata about this action
177
+ */
178
+ public get Description(): string {
179
+ return 'Updates an existing user profile in LearnWorlds with optional field-level changes';
180
+ }
181
+ }
@@ -1,5 +1,8 @@
1
+ // Export LearnWorlds interfaces
2
+ export * from './interfaces';
3
+
1
4
  // Export LearnWorlds base action
2
5
  export * from './learnworlds-base.action';
3
6
 
4
7
  // Export all LearnWorlds actions
5
- export * from './actions';
8
+ export * from './actions';
@@ -0,0 +1,17 @@
1
+ import { LearnWorldsBaseParams, LearnWorldsBundle } from './common.types';
2
+
3
+ /**
4
+ * Parameters for the GetBundles action
5
+ */
6
+ export interface GetBundlesParams extends LearnWorldsBaseParams {
7
+ SearchText?: string;
8
+ MaxResults?: number;
9
+ }
10
+
11
+ /**
12
+ * Result of the GetBundles action
13
+ */
14
+ export interface GetBundlesResult {
15
+ Bundles: LearnWorldsBundle[];
16
+ TotalCount: number;
17
+ }
@@ -0,0 +1,69 @@
1
+ import { LearnWorldsBaseParams } from './common.types';
2
+
3
+ /**
4
+ * Parameters for the GetCertificates action
5
+ */
6
+ export interface GetCertificatesParams extends LearnWorldsBaseParams {
7
+ UserID?: string;
8
+ CourseID?: string;
9
+ DateFrom?: string;
10
+ DateTo?: string;
11
+ IncludeDownloadLinks?: boolean;
12
+ SortBy?: string;
13
+ SortOrder?: 'asc' | 'desc';
14
+ MaxResults?: number;
15
+ }
16
+
17
+ /**
18
+ * Result of the GetCertificates action
19
+ */
20
+ export interface GetCertificatesResult {
21
+ Certificates: FormattedCertificate[];
22
+ TotalCount: number;
23
+ Summary: CertificatesSummary;
24
+ }
25
+
26
+ export interface FormattedCertificate {
27
+ id: string;
28
+ userId: string;
29
+ courseId: string;
30
+ certificateNumber?: string;
31
+ issuedAt?: string;
32
+ expiresAt?: string;
33
+ status: string;
34
+ grade?: number;
35
+ score?: number;
36
+ completionPercentage: number;
37
+ user?: {
38
+ id: string;
39
+ email: string;
40
+ name: string;
41
+ };
42
+ course?: {
43
+ id: string;
44
+ title: string;
45
+ duration?: number;
46
+ };
47
+ downloadLinks?: {
48
+ pdf?: string;
49
+ image?: string;
50
+ publicUrl?: string;
51
+ };
52
+ verification: {
53
+ url?: string;
54
+ code?: string;
55
+ qrCode?: string;
56
+ };
57
+ }
58
+
59
+ export interface CertificatesSummary {
60
+ totalCertificates: number;
61
+ activeCertificates: number;
62
+ expiredCertificates: number;
63
+ dateRange: {
64
+ from: string;
65
+ to: string;
66
+ };
67
+ filterType: string;
68
+ groupedData: Record<string, FormattedCertificate[]> | null;
69
+ }
@@ -0,0 +1,233 @@
1
+ import { UserInfo } from '@memberjunction/core';
2
+
3
+ /**
4
+ * Base parameters shared by all LearnWorlds actions.
5
+ * Every typed public method requires at least a CompanyID.
6
+ */
7
+ export interface LearnWorldsBaseParams {
8
+ CompanyID: string;
9
+ }
10
+
11
+ /**
12
+ * Standard representation of a LearnWorlds user across actions
13
+ */
14
+ export interface LearnWorldsUser {
15
+ id: string;
16
+ email: string;
17
+ username: string;
18
+ firstName?: string;
19
+ lastName?: string;
20
+ fullName?: string;
21
+ status: 'active' | 'inactive' | 'suspended';
22
+ role: string;
23
+ createdAt: Date;
24
+ lastLoginAt?: Date;
25
+ tags?: string[];
26
+ customFields?: Record<string, unknown>;
27
+ totalCourses?: number;
28
+ completedCourses?: number;
29
+ inProgressCourses?: number;
30
+ totalTimeSpent?: number;
31
+ avatarUrl?: string;
32
+ bio?: string;
33
+ location?: string;
34
+ timezone?: string;
35
+ }
36
+
37
+ /**
38
+ * Standard representation of a LearnWorlds course
39
+ */
40
+ export interface LearnWorldsCourse {
41
+ id: string;
42
+ title: string;
43
+ subtitle?: string;
44
+ description?: string;
45
+ shortDescription?: string;
46
+ status: 'published' | 'draft' | 'coming_soon';
47
+ visibility: 'public' | 'private' | 'hidden';
48
+ isActive: boolean;
49
+ isFree: boolean;
50
+ price?: number;
51
+ currency?: string;
52
+ originalPrice?: number;
53
+ discountPercentage?: number;
54
+ categoryId?: string;
55
+ categoryName?: string;
56
+ tags?: string[];
57
+ level?: 'beginner' | 'intermediate' | 'advanced' | 'all';
58
+ language?: string;
59
+ duration?: number;
60
+ thumbnailUrl?: string;
61
+ coverImageUrl?: string;
62
+ promoVideoUrl?: string;
63
+ instructorId?: string;
64
+ instructorName?: string;
65
+ instructorBio?: string;
66
+ instructorAvatarUrl?: string;
67
+ totalUnits: number;
68
+ totalLessons: number;
69
+ totalQuizzes: number;
70
+ totalAssignments: number;
71
+ estimatedDuration?: number;
72
+ totalEnrollments: number;
73
+ activeEnrollments: number;
74
+ completionRate: number;
75
+ averageRating?: number;
76
+ totalReviews?: number;
77
+ createdAt: Date;
78
+ updatedAt: Date;
79
+ publishedAt?: Date;
80
+ enrollmentStartDate?: Date;
81
+ enrollmentEndDate?: Date;
82
+ requiresApproval: boolean;
83
+ hasPrerequisites: boolean;
84
+ prerequisites?: string[];
85
+ certificateAvailable: boolean;
86
+ objectives?: string[];
87
+ targetAudience?: string[];
88
+ requirements?: string[];
89
+ }
90
+
91
+ /**
92
+ * Standard representation of a LearnWorlds enrollment
93
+ */
94
+ export interface LearnWorldsEnrollment {
95
+ id: string;
96
+ userId: string;
97
+ courseId: string;
98
+ enrolledAt: string;
99
+ startsAt?: string;
100
+ expiresAt?: string;
101
+ status: string;
102
+ price: number;
103
+ progress: {
104
+ percentage: number;
105
+ completedUnits: number;
106
+ totalUnits: number;
107
+ lastAccessedAt?: string;
108
+ };
109
+ certificateEligible: boolean;
110
+ certificateIssuedAt?: string;
111
+ }
112
+
113
+ /**
114
+ * Standard representation of a LearnWorlds bundle
115
+ */
116
+ export interface LearnWorldsBundle {
117
+ id: string;
118
+ title: string;
119
+ description?: string;
120
+ price?: number;
121
+ currency?: string;
122
+ courses: string[];
123
+ isActive: boolean;
124
+ createdAt: string;
125
+ updatedAt: string;
126
+ thumbnailUrl?: string;
127
+ totalCourses: number;
128
+ totalEnrollments: number;
129
+ }
130
+
131
+ /**
132
+ * Standard representation of a LearnWorlds certificate
133
+ */
134
+ export interface LearnWorldsCertificate {
135
+ id: string;
136
+ userId: string;
137
+ courseId: string;
138
+ certificateNumber?: string;
139
+ issuedAt: string;
140
+ expiresAt?: string;
141
+ status: string;
142
+ grade?: number;
143
+ score?: number;
144
+ completionPercentage: number;
145
+ }
146
+
147
+ /**
148
+ * Progress data from LearnWorlds API (snake_case)
149
+ */
150
+ export interface LearnWorldsCourseProgress {
151
+ percentage: number;
152
+ completedUnits: number;
153
+ totalUnits: number;
154
+ timeSpent: number;
155
+ }
156
+
157
+ /**
158
+ * Paginated response structure from LearnWorlds API
159
+ */
160
+ export interface LearnWorldsPaginatedResponse<T> {
161
+ data: T[];
162
+ meta?: {
163
+ page: number;
164
+ totalPages: number;
165
+ totalItems: number;
166
+ };
167
+ }
168
+
169
+ /**
170
+ * Error shape returned by the LearnWorlds API
171
+ */
172
+ export interface LearnWorldsAPIError {
173
+ error?: {
174
+ message?: string;
175
+ code?: string;
176
+ };
177
+ message?: string;
178
+ statusCode?: number;
179
+ }
180
+
181
+ /**
182
+ * Raw LearnWorlds API user shape (snake_case)
183
+ */
184
+ export interface LWApiUser {
185
+ id?: string;
186
+ _id?: string;
187
+ email: string;
188
+ username?: string;
189
+ first_name?: string;
190
+ last_name?: string;
191
+ full_name?: string;
192
+ status?: string;
193
+ role?: string;
194
+ is_active?: boolean;
195
+ created?: string | number;
196
+ created_at?: string;
197
+ last_login?: string | number;
198
+ tags?: string[];
199
+ custom_fields?: Record<string, unknown>;
200
+ course_stats?: {
201
+ total?: number;
202
+ completed?: number;
203
+ in_progress?: number;
204
+ total_time_spent?: number;
205
+ };
206
+ avatar_url?: string;
207
+ bio?: string;
208
+ location?: string;
209
+ timezone?: string;
210
+ login_url?: string;
211
+ reset_password_url?: string;
212
+ send_welcome_email?: boolean;
213
+ }
214
+
215
+ /**
216
+ * Raw LearnWorlds API enrollment status shape
217
+ */
218
+ export interface LWApiEnrollmentStatus {
219
+ completed?: boolean;
220
+ expired?: boolean;
221
+ suspended?: boolean;
222
+ active?: boolean;
223
+ }
224
+
225
+ /**
226
+ * Raw progress data shape from LearnWorlds API
227
+ */
228
+ export interface LWApiProgressData {
229
+ percentage?: number;
230
+ completed_units?: number;
231
+ total_units?: number;
232
+ time_spent?: number;
233
+ }