@memberjunction/actions-bizapps-lms 6.2.2 → 6.3.0-edge.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 (34) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +120 -23
  3. package/dist/base/base-lms.action.d.ts +1 -1
  4. package/dist/base/base-lms.action.d.ts.map +1 -1
  5. package/dist/base/base-lms.action.js +12 -16
  6. package/dist/base/base-lms.action.js.map +1 -1
  7. package/dist/providers/learnworlds/learnworlds-base.action.d.ts.map +1 -1
  8. package/dist/providers/learnworlds/learnworlds-base.action.js +4 -4
  9. package/dist/providers/learnworlds/learnworlds-base.action.js.map +1 -1
  10. package/dist/tsconfig.tsbuildinfo +1 -0
  11. package/package.json +7 -7
  12. package/src/__tests__/attach-tags.action.test.ts +2 -1
  13. package/src/__tests__/create-user.action.test.ts +2 -1
  14. package/src/__tests__/detach-tags.action.test.ts +2 -1
  15. package/src/__tests__/enroll-user.action.test.ts +2 -1
  16. package/src/__tests__/get-bulk-data.action.test.ts +2 -1
  17. package/src/__tests__/get-bundles.action.test.ts +2 -1
  18. package/src/__tests__/get-certificates.action.test.ts +2 -1
  19. package/src/__tests__/get-course-analytics.action.test.ts +2 -1
  20. package/src/__tests__/get-course-details.action.test.ts +2 -1
  21. package/src/__tests__/get-courses.action.test.ts +2 -1
  22. package/src/__tests__/get-quiz-results.action.test.ts +2 -1
  23. package/src/__tests__/get-user-details.action.test.ts +2 -1
  24. package/src/__tests__/get-user-enrollments.action.test.ts +2 -1
  25. package/src/__tests__/get-user-progress.action.test.ts +2 -1
  26. package/src/__tests__/get-users.action.test.ts +2 -1
  27. package/src/__tests__/lms.test.ts +2 -1
  28. package/src/__tests__/onboard-learner.action.test.ts +2 -1
  29. package/src/__tests__/rate-limit-retry.test.ts +2 -1
  30. package/src/__tests__/sso-login.action.test.ts +2 -1
  31. package/src/__tests__/update-user-progress.action.test.ts +2 -1
  32. package/src/__tests__/update-user.action.test.ts +2 -1
  33. package/src/base/base-lms.action.ts +13 -23
  34. package/src/providers/learnworlds/learnworlds-base.action.ts +4 -4
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -9,7 +9,8 @@ vi.mock('@memberjunction/actions', () => ({
9
9
  },
10
10
  }));
11
11
 
12
- vi.mock('@memberjunction/global', () => ({
12
+ vi.mock('@memberjunction/global', async (importOriginal) => ({
13
+ IsEmailShaped: (await importOriginal<typeof import('@memberjunction/global')>()).IsEmailShaped,
13
14
  RegisterClass: () => (target: unknown) => target,
14
15
  }));
15
16
 
@@ -1,9 +1,9 @@
1
- import { ActionParam, ActionResultSimple } from '@memberjunction/actions-base';
1
+ import { ActionParam, ActionResultSimple, ResolveCompanyIntegration } from '@memberjunction/actions-base';
2
2
  import { BaseAction } from '@memberjunction/actions';
3
3
  import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
4
4
  import { UserInfo } from '@memberjunction/core';
5
5
  import { MJCompanyIntegrationEntity } from '@memberjunction/core-entities';
6
- import { Metadata, RunView } from '@memberjunction/core';
6
+
7
7
 
8
8
  /**
9
9
  * Base class for all LMS-related actions.
@@ -68,36 +68,26 @@ export abstract class BaseLMSAction extends BaseAction {
68
68
  /**
69
69
  * Gets the company integration record for the specified company and LMS
70
70
  */
71
- protected async getCompanyIntegration(companyId: string, contextUser: UserInfo): Promise<MJCompanyIntegrationEntity> {
71
+ protected async getCompanyIntegration(companyId: string, contextUser: UserInfo, companyIntegrationId?: string | null): Promise<MJCompanyIntegrationEntity> {
72
72
  this.validateUUID(companyId, 'CompanyID');
73
73
 
74
74
  // Validate integration name before SQL interpolation
75
75
  const safeIntegrationName = this.validateIntegrationName(this.integrationName);
76
76
 
77
77
  // Check cache first
78
- if (this._companyIntegration && UUIDsEqual(this._companyIntegration.CompanyID, companyId)) {
78
+ if (this._companyIntegration && UUIDsEqual(this._companyIntegration.CompanyID, companyId)
79
+ && (!companyIntegrationId || UUIDsEqual(this._companyIntegration.ID, companyIntegrationId))) {
79
80
  return this._companyIntegration;
80
81
  }
81
82
 
82
- const rv = new RunView();
83
- const result = await rv.RunView<MJCompanyIntegrationEntity>(
84
- {
85
- EntityName: 'MJ: Company Integrations',
86
- ExtraFilter: `CompanyID = '${companyId}' AND Integration = '${safeIntegrationName}'`,
87
- ResultType: 'entity_object',
88
- },
89
- contextUser,
90
- );
91
-
92
- if (!result.Success) {
93
- throw new Error(`Failed to retrieve company integration: ${result.ErrorMessage}`);
94
- }
95
-
96
- if (!result.Results || result.Results.length === 0) {
97
- throw new Error(`No ${this.integrationName} integration found for company ${companyId}. Please configure the integration first.`);
98
- }
99
-
100
- this._companyIntegration = result.Results[0];
83
+ // #4929: active connections only, and a refusal naming the candidates when there are several, instead of the
84
+ // first row.
85
+ this._companyIntegration = await ResolveCompanyIntegration({
86
+ CompanyID: companyId,
87
+ IntegrationNames: [safeIntegrationName],
88
+ CompanyIntegrationID: companyIntegrationId,
89
+ ContextUser: contextUser,
90
+ });
101
91
  return this._companyIntegration;
102
92
  }
103
93
 
@@ -1,4 +1,4 @@
1
- import { RegisterClass } from '@memberjunction/global';
1
+ import { RegisterClass, IsEmailShaped } from '@memberjunction/global';
2
2
  import { BaseLMSAction } from '../../base/base-lms.action';
3
3
  import { UserInfo } from '@memberjunction/core';
4
4
  import { MJCompanyIntegrationEntity } from '@memberjunction/core-entities';
@@ -135,7 +135,8 @@ export abstract class LearnWorldsBaseAction extends BaseLMSAction {
135
135
  throw new Error('CompanyID parameter is required');
136
136
  }
137
137
 
138
- const integration = await this.getCompanyIntegration(companyId, contextUser);
138
+ const companyIntegrationId = this.getParamValue(this.params, 'CompanyIntegrationID') as string | undefined;
139
+ const integration = await this.getCompanyIntegration(companyId, contextUser, companyIntegrationId);
139
140
  const credentials = await this.getAPICredentials(integration);
140
141
 
141
142
  if (!credentials.apiKey) {
@@ -400,8 +401,7 @@ export abstract class LearnWorldsBaseAction extends BaseLMSAction {
400
401
  * Validates that a string is a plausible email address.
401
402
  */
402
403
  protected validateEmail(email: string, paramName: string = 'Email'): string {
403
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
404
- if (!emailRegex.test(email)) {
404
+ if (!IsEmailShaped(email)) {
405
405
  throw new Error(`Invalid ${paramName} format: '${email}'`);
406
406
  }
407
407
  return email;