@memberjunction/actions-bizapps-lms 5.3.0 → 5.4.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 (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,359 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { RegisterClass } from '@memberjunction/global';
8
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action.js';
9
+ import { BaseAction } from '@memberjunction/actions';
10
+ import { GetLearnWorldsUsersAction } from './get-users.action.js';
11
+ import { GetLearnWorldsCoursesAction } from './get-courses.action.js';
12
+ import { GetBundlesAction } from './get-bundles.action.js';
13
+ import { GetUserEnrollmentsAction } from './get-user-enrollments.action.js';
14
+ import { GetLearnWorldsUserProgressAction } from './get-user-progress.action.js';
15
+ import { GetCertificatesAction } from './get-certificates.action.js';
16
+ import { GetQuizResultsAction } from './get-quiz-results.action.js';
17
+ /**
18
+ * Orchestrates bulk data retrieval from all LearnWorlds retrieval actions
19
+ * into a single LearnWorldsSyncPayload for downstream consumers.
20
+ */
21
+ let GetLearnWorldsBulkDataAction = class GetLearnWorldsBulkDataAction extends LearnWorldsBaseAction {
22
+ /**
23
+ * Retrieves bulk data from LearnWorlds, orchestrating multiple retrieval actions.
24
+ * Each data type is optional and controlled via Include* boolean params.
25
+ * Partial failures are collected into errors without aborting the whole operation.
26
+ */
27
+ async GetBulkData(params, contextUser) {
28
+ this.SetCompanyContext(params.CompanyID);
29
+ const errors = [];
30
+ let totalApiCalls = 0;
31
+ const includeAll = this.shouldIncludeAll(params);
32
+ const maxResults = params.MaxResultsPerEntity ?? 100;
33
+ // Fetch users first (enrollments and progress depend on user IDs)
34
+ let users;
35
+ if (includeAll || params.IncludeUsers || params.IncludeEnrollments || params.IncludeProgress) {
36
+ const result = await this.fetchUsers(params.CompanyID, maxResults, contextUser, errors);
37
+ users = result.data;
38
+ totalApiCalls += result.apiCalls;
39
+ }
40
+ // Fetch remaining data types in parallel
41
+ const [coursesResult, bundlesResult, enrollmentsResult, progressResult, certificatesResult, quizResultsResult] = await Promise.all([
42
+ this.shouldFetch(includeAll, params.IncludeCourses) ? this.fetchCourses(params.CompanyID, maxResults, contextUser, errors) : Promise.resolve(undefined),
43
+ this.shouldFetch(includeAll, params.IncludeBundles) ? this.fetchBundles(params.CompanyID, maxResults, contextUser, errors) : Promise.resolve(undefined),
44
+ this.shouldFetch(includeAll, params.IncludeEnrollments) ? this.fetchEnrollmentsForUsers(params.CompanyID, users || [], maxResults, contextUser, errors) : Promise.resolve(undefined),
45
+ this.shouldFetch(includeAll, params.IncludeProgress) ? this.fetchProgressForUsers(params.CompanyID, users || [], contextUser, errors) : Promise.resolve(undefined),
46
+ this.shouldFetch(includeAll, params.IncludeCertificates) ? this.fetchCertificates(params.CompanyID, maxResults, contextUser, errors) : Promise.resolve(undefined),
47
+ this.shouldFetch(includeAll, params.IncludeQuizResults) ? this.fetchQuizResults(params.CompanyID, maxResults, contextUser, errors) : Promise.resolve(undefined),
48
+ ]);
49
+ if (coursesResult)
50
+ totalApiCalls += coursesResult.apiCalls;
51
+ if (bundlesResult)
52
+ totalApiCalls += bundlesResult.apiCalls;
53
+ if (enrollmentsResult)
54
+ totalApiCalls += enrollmentsResult.apiCalls;
55
+ if (progressResult)
56
+ totalApiCalls += progressResult.apiCalls;
57
+ if (certificatesResult)
58
+ totalApiCalls += certificatesResult.apiCalls;
59
+ if (quizResultsResult)
60
+ totalApiCalls += quizResultsResult.apiCalls;
61
+ // Only include user data in output if explicitly requested (not just fetched for enrollments)
62
+ const includeUsersInOutput = includeAll || params.IncludeUsers === true;
63
+ return {
64
+ users: includeUsersInOutput ? users : undefined,
65
+ courses: coursesResult?.data,
66
+ bundles: bundlesResult?.data,
67
+ enrollments: enrollmentsResult?.data,
68
+ progress: progressResult?.data,
69
+ certificates: certificatesResult?.data,
70
+ quizResults: quizResultsResult?.data,
71
+ syncedAt: new Date().toISOString(),
72
+ companyId: params.CompanyID,
73
+ totalApiCalls,
74
+ errors,
75
+ };
76
+ }
77
+ /**
78
+ * If no Include* flags are explicitly set, include everything by default.
79
+ */
80
+ shouldIncludeAll(params) {
81
+ return (params.IncludeUsers === undefined &&
82
+ params.IncludeCourses === undefined &&
83
+ params.IncludeBundles === undefined &&
84
+ params.IncludeEnrollments === undefined &&
85
+ params.IncludeProgress === undefined &&
86
+ params.IncludeCertificates === undefined &&
87
+ params.IncludeQuizResults === undefined);
88
+ }
89
+ /**
90
+ * Helper to determine if a data type should be fetched.
91
+ */
92
+ shouldFetch(includeAll, flag) {
93
+ return includeAll || flag === true;
94
+ }
95
+ /**
96
+ * Fetch users, collecting errors on failure.
97
+ */
98
+ async fetchUsers(companyId, maxResults, contextUser, errors) {
99
+ const action = new GetLearnWorldsUsersAction();
100
+ try {
101
+ const result = await action.GetUsers({ CompanyID: companyId, MaxResults: maxResults }, contextUser);
102
+ return { data: result.Users, apiCalls: action.ApiCallCount };
103
+ }
104
+ catch (error) {
105
+ this.collectError(errors, 'user', error);
106
+ return { data: [], apiCalls: action.ApiCallCount || 1 };
107
+ }
108
+ }
109
+ /**
110
+ * Fetch courses, collecting errors on failure.
111
+ */
112
+ async fetchCourses(companyId, maxResults, contextUser, errors) {
113
+ const action = new GetLearnWorldsCoursesAction();
114
+ try {
115
+ const result = await action.GetCourses({ CompanyID: companyId, MaxResults: maxResults }, contextUser);
116
+ return { data: result.Courses, apiCalls: action.ApiCallCount };
117
+ }
118
+ catch (error) {
119
+ this.collectError(errors, 'course', error);
120
+ return { data: [], apiCalls: action.ApiCallCount || 1 };
121
+ }
122
+ }
123
+ /**
124
+ * Fetch bundles, collecting errors on failure.
125
+ */
126
+ async fetchBundles(companyId, maxResults, contextUser, errors) {
127
+ const action = new GetBundlesAction();
128
+ try {
129
+ const result = await action.GetBundles({ CompanyID: companyId, MaxResults: maxResults }, contextUser);
130
+ return { data: result.Bundles, apiCalls: action.ApiCallCount };
131
+ }
132
+ catch (error) {
133
+ this.collectError(errors, 'bundle', error);
134
+ return { data: [], apiCalls: action.ApiCallCount || 1 };
135
+ }
136
+ }
137
+ /**
138
+ * Fetch enrollments for all provided users with controlled concurrency.
139
+ * Processes users in batches of CONCURRENCY_LIMIT to avoid overwhelming the API.
140
+ */
141
+ async fetchEnrollmentsForUsers(companyId, users, maxResults, contextUser, errors) {
142
+ if (users.length === 0) {
143
+ return { data: [], apiCalls: 0 };
144
+ }
145
+ const allEnrollments = [];
146
+ let apiCalls = 0;
147
+ const results = await this.processInBatches(users, async (user) => {
148
+ const action = new GetUserEnrollmentsAction();
149
+ try {
150
+ const result = await action.GetUserEnrollments({ CompanyID: companyId, UserID: user.id, MaxResults: maxResults }, contextUser);
151
+ apiCalls += action.ApiCallCount;
152
+ return { enrollments: result.Enrollments, userId: user.id, error: null };
153
+ }
154
+ catch (error) {
155
+ apiCalls += action.ApiCallCount || 1;
156
+ this.collectError(errors, 'enrollment', error, user.id);
157
+ return { enrollments: [], userId: user.id, error };
158
+ }
159
+ });
160
+ for (const result of results) {
161
+ for (const enrollment of result.enrollments) {
162
+ allEnrollments.push({
163
+ id: enrollment.id,
164
+ userId: result.userId,
165
+ courseId: enrollment.courseId,
166
+ enrolledAt: enrollment.enrolledAt || '',
167
+ startsAt: enrollment.startsAt,
168
+ expiresAt: enrollment.expiresAt,
169
+ status: enrollment.status,
170
+ price: 0,
171
+ progress: {
172
+ percentage: enrollment.progress.percentage,
173
+ completedUnits: enrollment.progress.completedUnits,
174
+ totalUnits: enrollment.progress.totalUnits,
175
+ lastAccessedAt: enrollment.progress.lastAccessedAt,
176
+ },
177
+ certificateEligible: enrollment.certificateEligible,
178
+ certificateIssuedAt: enrollment.certificateIssuedAt,
179
+ });
180
+ }
181
+ }
182
+ return { data: allEnrollments, apiCalls };
183
+ }
184
+ /**
185
+ * Fetch learning progress for all provided users with controlled concurrency.
186
+ * Processes users in batches of CONCURRENCY_LIMIT to avoid overwhelming the API.
187
+ */
188
+ async fetchProgressForUsers(companyId, users, contextUser, errors) {
189
+ if (users.length === 0) {
190
+ return { data: [], apiCalls: 0 };
191
+ }
192
+ const allProgress = [];
193
+ let apiCalls = 0;
194
+ const results = await this.processInBatches(users, async (user) => {
195
+ const action = new GetLearnWorldsUserProgressAction();
196
+ try {
197
+ const result = await action.GetUserProgress({ CompanyID: companyId, UserID: user.id }, contextUser);
198
+ apiCalls += action.ApiCallCount;
199
+ return { progress: result.UserProgress, error: null };
200
+ }
201
+ catch (error) {
202
+ apiCalls += action.ApiCallCount || 1;
203
+ this.collectError(errors, 'progress', error, user.id);
204
+ return { progress: null, error };
205
+ }
206
+ });
207
+ for (const result of results) {
208
+ if (result.progress) {
209
+ allProgress.push(result.progress);
210
+ }
211
+ }
212
+ return { data: allProgress, apiCalls };
213
+ }
214
+ /**
215
+ * Fetch certificates, collecting errors on failure.
216
+ */
217
+ async fetchCertificates(companyId, maxResults, contextUser, errors) {
218
+ const action = new GetCertificatesAction();
219
+ try {
220
+ const result = await action.GetCertificates({ CompanyID: companyId, MaxResults: maxResults, IncludeDownloadLinks: false }, contextUser);
221
+ // Map FormattedCertificate to LearnWorldsCertificate
222
+ const certificates = result.Certificates.map((cert) => ({
223
+ id: cert.id,
224
+ userId: cert.userId,
225
+ courseId: cert.courseId,
226
+ certificateNumber: cert.certificateNumber,
227
+ issuedAt: cert.issuedAt || '',
228
+ expiresAt: cert.expiresAt,
229
+ status: cert.status,
230
+ grade: cert.grade,
231
+ score: cert.score,
232
+ completionPercentage: cert.completionPercentage,
233
+ }));
234
+ return { data: certificates, apiCalls: action.ApiCallCount };
235
+ }
236
+ catch (error) {
237
+ this.collectError(errors, 'certificate', error);
238
+ return { data: [], apiCalls: action.ApiCallCount || 1 };
239
+ }
240
+ }
241
+ /**
242
+ * Fetch quiz results, collecting errors on failure.
243
+ */
244
+ async fetchQuizResults(companyId, maxResults, contextUser, errors) {
245
+ const action = new GetQuizResultsAction();
246
+ try {
247
+ const result = await action.GetQuizResults({ CompanyID: companyId, MaxResults: maxResults, IncludeQuestions: false, IncludeAnswers: false }, contextUser);
248
+ return { data: result.QuizResults, apiCalls: action.ApiCallCount };
249
+ }
250
+ catch (error) {
251
+ this.collectError(errors, 'quizResult', error);
252
+ return { data: [], apiCalls: action.ApiCallCount || 1 };
253
+ }
254
+ }
255
+ /**
256
+ * Adds a SyncError to the errors collection from a caught exception.
257
+ */
258
+ collectError(errors, entity, error, entityId = '') {
259
+ const message = error instanceof Error ? error.message : String(error);
260
+ errors.push({
261
+ entity,
262
+ entityId,
263
+ operation: 'read',
264
+ message,
265
+ timestamp: new Date().toISOString(),
266
+ });
267
+ }
268
+ /**
269
+ * Framework entry point that delegates to the typed public method
270
+ */
271
+ async InternalRunAction(params) {
272
+ const { Params, ContextUser } = params;
273
+ this.params = Params;
274
+ try {
275
+ const bulkParams = this.extractBulkDataParams(Params);
276
+ const result = await this.GetBulkData(bulkParams, ContextUser);
277
+ this.setOutputParam(Params, 'SyncPayload', result);
278
+ this.setOutputParam(Params, 'TotalApiCalls', result.totalApiCalls);
279
+ this.setOutputParam(Params, 'Errors', result.errors);
280
+ const dataCounts = this.buildDataCountsSummary(result);
281
+ if (result.errors.length > 0) {
282
+ return this.buildErrorResult('PARTIAL_FAILURE', `Bulk data retrieval partially succeeded. ${dataCounts}. ${result.errors.length} error(s) occurred.`, Params);
283
+ }
284
+ return this.buildSuccessResult(`Bulk data retrieval complete. ${dataCounts}.`, Params);
285
+ }
286
+ catch (error) {
287
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
288
+ return this.buildErrorResult('ERROR', `Error during bulk data retrieval: ${errorMessage}`, Params);
289
+ }
290
+ }
291
+ /**
292
+ * Extract typed params from the generic ActionParam array
293
+ */
294
+ extractBulkDataParams(params) {
295
+ return {
296
+ CompanyID: this.getRequiredStringParam(params, 'CompanyID'),
297
+ IncludeUsers: this.getOptionalBooleanParam(params, 'IncludeUsers', undefined),
298
+ IncludeCourses: this.getOptionalBooleanParam(params, 'IncludeCourses', undefined),
299
+ IncludeBundles: this.getOptionalBooleanParam(params, 'IncludeBundles', undefined),
300
+ IncludeEnrollments: this.getOptionalBooleanParam(params, 'IncludeEnrollments', undefined),
301
+ IncludeProgress: this.getOptionalBooleanParam(params, 'IncludeProgress', undefined),
302
+ IncludeCertificates: this.getOptionalBooleanParam(params, 'IncludeCertificates', undefined),
303
+ IncludeQuizResults: this.getOptionalBooleanParam(params, 'IncludeQuizResults', undefined),
304
+ MaxResultsPerEntity: this.getOptionalNumberParam(params, 'MaxResultsPerEntity', undefined),
305
+ };
306
+ }
307
+ /**
308
+ * Builds a human-readable summary of data counts in the payload.
309
+ */
310
+ buildDataCountsSummary(payload) {
311
+ const parts = [];
312
+ if (payload.users)
313
+ parts.push(`${payload.users.length} user(s)`);
314
+ if (payload.courses)
315
+ parts.push(`${payload.courses.length} course(s)`);
316
+ if (payload.bundles)
317
+ parts.push(`${payload.bundles.length} bundle(s)`);
318
+ if (payload.enrollments)
319
+ parts.push(`${payload.enrollments.length} enrollment(s)`);
320
+ if (payload.progress)
321
+ parts.push(`${payload.progress.length} progress record(s)`);
322
+ if (payload.certificates)
323
+ parts.push(`${payload.certificates.length} certificate(s)`);
324
+ if (payload.quizResults)
325
+ parts.push(`${payload.quizResults.length} quiz result(s)`);
326
+ return parts.length > 0 ? `Retrieved: ${parts.join(', ')}` : 'No data retrieved';
327
+ }
328
+ /**
329
+ * Define the parameters this action expects
330
+ */
331
+ get Params() {
332
+ const baseParams = this.getCommonLMSParams();
333
+ const specificParams = [
334
+ { Name: 'IncludeUsers', Type: 'Input', Value: null },
335
+ { Name: 'IncludeCourses', Type: 'Input', Value: null },
336
+ { Name: 'IncludeBundles', Type: 'Input', Value: null },
337
+ { Name: 'IncludeEnrollments', Type: 'Input', Value: null },
338
+ { Name: 'IncludeProgress', Type: 'Input', Value: null },
339
+ { Name: 'IncludeCertificates', Type: 'Input', Value: null },
340
+ { Name: 'IncludeQuizResults', Type: 'Input', Value: null },
341
+ { Name: 'MaxResultsPerEntity', Type: 'Input', Value: 100 },
342
+ { Name: 'SyncPayload', Type: 'Output', Value: null },
343
+ { Name: 'TotalApiCalls', Type: 'Output', Value: null },
344
+ { Name: 'Errors', Type: 'Output', Value: null },
345
+ ];
346
+ return [...baseParams, ...specificParams];
347
+ }
348
+ /**
349
+ * Metadata about this action
350
+ */
351
+ get Description() {
352
+ return 'Orchestrates bulk data retrieval from LearnWorlds, fetching users, courses, bundles, enrollments, progress, certificates, and quiz results into a single sync payload';
353
+ }
354
+ };
355
+ GetLearnWorldsBulkDataAction = __decorate([
356
+ RegisterClass(BaseAction, 'GetLearnWorldsBulkDataAction')
357
+ ], GetLearnWorldsBulkDataAction);
358
+ export { GetLearnWorldsBulkDataAction };
359
+ //# sourceMappingURL=get-bulk-data.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bulk-data.action.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/get-bulk-data.action.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAcrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;GAGG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,qBAAqB;IACrE;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,WAAqB;QACpE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEzC,MAAM,MAAM,GAAgB,EAAE,CAAC;QAC/B,IAAI,aAAa,GA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AAQ,EAAE,KAAK,EAAE,IAAI,EAAE;YACpD,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;YACtD,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;SAChD,CAAC;QACF,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,uKAAuK,CAAC;IACjL,CAAC;CACF,CAAA;AAvZY,4BAA4B;IADxC,aAAa,CAAC,UAAU,EAAE,8BAA8B,CAAC;GAC7C,4BAA4B,CAuZxC"}
@@ -0,0 +1,34 @@
1
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action.js';
2
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
3
+ import { UserInfo } from '@memberjunction/core';
4
+ import { GetBundlesParams, GetBundlesResult } from '../interfaces/index.js';
5
+ /**
6
+ * Action to retrieve bundles from LearnWorlds
7
+ */
8
+ export declare class GetBundlesAction extends LearnWorldsBaseAction {
9
+ /**
10
+ * Retrieves bundles from LearnWorlds with optional search filtering.
11
+ */
12
+ GetBundles(params: GetBundlesParams, contextUser: UserInfo): Promise<GetBundlesResult>;
13
+ /**
14
+ * Builds query parameters for the bundles API request
15
+ */
16
+ private buildBundleQueryParams;
17
+ /**
18
+ * Maps a raw LearnWorlds API bundle to the standard LearnWorldsBundle interface
19
+ */
20
+ private mapApiBundle;
21
+ /**
22
+ * Framework entry point that delegates to the typed public method
23
+ */
24
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
25
+ /**
26
+ * Define the parameters this action expects
27
+ */
28
+ get Params(): ActionParam[];
29
+ /**
30
+ * Metadata about this action
31
+ */
32
+ get Description(): string;
33
+ }
34
+ //# sourceMappingURL=get-bundles.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bundles.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/get-bundles.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,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAqB,MAAM,eAAe,CAAC;AAyBtF;;GAEG;AACH,qBACa,gBAAiB,SAAQ,qBAAqB;IACzD;;OAEG;IACU,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAcnG;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAc9B;;OAEG;IACH,OAAO,CAAC,YAAY;IAoBpB;;OAEG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuBvF;;OAEG;IACH,IAAW,MAAM,IAAI,WAAW,EAAE,CASjC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;CACF"}
@@ -0,0 +1,107 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { RegisterClass } from '@memberjunction/global';
8
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action.js';
9
+ import { BaseAction } from '@memberjunction/actions';
10
+ /**
11
+ * Action to retrieve bundles from LearnWorlds
12
+ */
13
+ let GetBundlesAction = class GetBundlesAction extends LearnWorldsBaseAction {
14
+ /**
15
+ * Retrieves bundles from LearnWorlds with optional search filtering.
16
+ */
17
+ async GetBundles(params, contextUser) {
18
+ this.SetCompanyContext(params.CompanyID);
19
+ const queryParams = this.buildBundleQueryParams(params);
20
+ const rawBundles = await this.makeLearnWorldsPaginatedRequest('bundles', queryParams, contextUser);
21
+ const bundles = rawBundles.map((b) => this.mapApiBundle(b));
22
+ return {
23
+ Bundles: bundles,
24
+ TotalCount: bundles.length,
25
+ };
26
+ }
27
+ /**
28
+ * Builds query parameters for the bundles API request
29
+ */
30
+ buildBundleQueryParams(params) {
31
+ const queryParams = {};
32
+ if (params.SearchText) {
33
+ queryParams.search = params.SearchText;
34
+ }
35
+ if (params.MaxResults) {
36
+ queryParams.limit = Math.min(params.MaxResults, 100);
37
+ }
38
+ return queryParams;
39
+ }
40
+ /**
41
+ * Maps a raw LearnWorlds API bundle to the standard LearnWorldsBundle interface
42
+ */
43
+ mapApiBundle(raw) {
44
+ const createdRaw = raw.created || raw.created_at || '';
45
+ const updatedRaw = raw.updated || raw.updated_at || '';
46
+ return {
47
+ id: raw.id || raw._id || '',
48
+ title: raw.title || '',
49
+ description: raw.description,
50
+ price: raw.price,
51
+ currency: raw.currency,
52
+ courses: raw.courses || [],
53
+ isActive: raw.is_active !== false,
54
+ createdAt: createdRaw ? this.parseLearnWorldsDate(createdRaw).toISOString() : '',
55
+ updatedAt: updatedRaw ? this.parseLearnWorldsDate(updatedRaw).toISOString() : '',
56
+ thumbnailUrl: raw.thumbnail_url || raw.image,
57
+ totalCourses: raw.total_courses || (raw.courses ? raw.courses.length : 0),
58
+ totalEnrollments: raw.total_enrollments || raw.students_count || 0,
59
+ };
60
+ }
61
+ /**
62
+ * Framework entry point that delegates to the typed public method
63
+ */
64
+ async InternalRunAction(params) {
65
+ const { Params, ContextUser } = params;
66
+ this.params = Params;
67
+ try {
68
+ const bundleParams = {
69
+ CompanyID: this.getRequiredStringParam(Params, 'CompanyID'),
70
+ SearchText: this.getOptionalStringParam(Params, 'SearchText'),
71
+ MaxResults: this.getOptionalNumberParam(Params, 'MaxResults', LearnWorldsBaseAction.LW_MAX_PAGE_SIZE),
72
+ };
73
+ const result = await this.GetBundles(bundleParams, ContextUser);
74
+ this.setOutputParam(Params, 'Bundles', result.Bundles);
75
+ this.setOutputParam(Params, 'TotalCount', result.TotalCount);
76
+ return this.buildSuccessResult(`Successfully retrieved ${result.TotalCount} bundle(s) from LearnWorlds`, Params);
77
+ }
78
+ catch (error) {
79
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
80
+ return this.buildErrorResult('ERROR', `Error retrieving bundles: ${errorMessage}`, Params);
81
+ }
82
+ }
83
+ /**
84
+ * Define the parameters this action expects
85
+ */
86
+ get Params() {
87
+ const baseParams = this.getCommonLMSParams();
88
+ const specificParams = [
89
+ { Name: 'SearchText', Type: 'Input', Value: null },
90
+ { Name: 'MaxResults', Type: 'Input', Value: null },
91
+ { Name: 'Bundles', Type: 'Output', Value: null },
92
+ { Name: 'TotalCount', Type: 'Output', Value: null },
93
+ ];
94
+ return [...baseParams, ...specificParams];
95
+ }
96
+ /**
97
+ * Metadata about this action
98
+ */
99
+ get Description() {
100
+ return 'Retrieves course bundles from LearnWorlds with optional search filtering';
101
+ }
102
+ };
103
+ GetBundlesAction = __decorate([
104
+ RegisterClass(BaseAction, 'GetBundlesAction')
105
+ ], GetBundlesAction);
106
+ export { GetBundlesAction };
107
+ //# sourceMappingURL=get-bundles.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bundles.action.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/get-bundles.action.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAA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ACH,IAAW,WAAW;QACpB,OAAO,0EAA0E,CAAC;IACpF,CAAC;CACF,CAAA;AAxGY,gBAAgB;IAD5B,aAAa,CAAC,UAAU,EAAE,kBAAkB,CAAC;GACjC,gBAAgB,CAwG5B"}
@@ -1,13 +1,44 @@
1
1
  import { LearnWorldsBaseAction } from '../learnworlds-base.action.js';
2
2
  import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
3
+ import { UserInfo } from '@memberjunction/core';
4
+ import { GetCertificatesParams, GetCertificatesResult } from '../interfaces/index.js';
3
5
  /**
4
6
  * Action to retrieve certificates earned by users in LearnWorlds
5
7
  */
6
8
  export declare class GetCertificatesAction extends LearnWorldsBaseAction {
7
9
  /**
8
- * Get certificates for a user or course
10
+ * Get certificates for a user or course.
11
+ * Throws on any error.
9
12
  */
10
- InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
13
+ GetCertificates(params: GetCertificatesParams, contextUser: UserInfo): Promise<GetCertificatesResult>;
14
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
15
+ private extractCertificatesParams;
16
+ private buildCertificatesEndpoint;
17
+ private buildQueryString;
18
+ private extractCertificatesArray;
19
+ private processCertificates;
20
+ /**
21
+ * Extracts inline user info when the cert already includes user data.
22
+ */
23
+ private extractInlineUserInfo;
24
+ /**
25
+ * Extracts inline course info when the cert already includes course data.
26
+ */
27
+ private extractInlineCourseInfo;
28
+ /**
29
+ * Batch-fetches user info for all certificates that need external lookup.
30
+ * Returns a map from userId to user info.
31
+ */
32
+ private batchResolveUserInfo;
33
+ /**
34
+ * Batch-fetches course info for all certificates that need external lookup.
35
+ * Returns a map from courseId to course info.
36
+ */
37
+ private batchResolveCourseInfo;
38
+ private buildBaseCertificate;
39
+ private buildCertificatesSummary;
40
+ private groupCertificatesByCourse;
41
+ private groupCertificatesByUser;
11
42
  /**
12
43
  * Define the parameters this action expects
13
44
  */
@@ -1 +1 @@
1
- {"version":3,"file":"get-certificates.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/get-certificates.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGhG;;GAEG;AACH,qBACa,qBAAsB,SAAQ,qBAAqB;IAC5D;;OAEG;IACU,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwPpF;;OAEG;IACH,IAAW,MAAM,IAAI,WAAW,EAAE,CA4DjC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;CACJ"}
1
+ {"version":3,"file":"get-certificates.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/get-certificates.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,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAA6C,MAAM,eAAe,CAAC;AA0FxH;;GAEG;AACH,qBACa,qBAAsB,SAAQ,qBAAqB;IAK9D;;;OAGG;IACU,eAAe,CAAC,MAAM,EAAE,qBAAqB,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,qBAAqB,CAAC;cA0ElG,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuBvF,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,yBAAyB;IAWjC,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,wBAAwB;YAiBlB,mBAAmB;IA0CjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAS/B;;;OAGG;YACW,oBAAoB;IAwClC;;;OAGG;YACW,sBAAsB;IAwCpC,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,wBAAwB;IAsChC,OAAO,CAAC,yBAAyB;IAYjC,OAAO,CAAC,uBAAuB;IAgB/B;;OAEG;IACH,IAAW,MAAM,IAAI,WAAW,EAAE,CAgBjC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;CACF"}