@unchainedshop/core-enrollments 4.8.10 → 4.8.12
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mongodb, buildDbIndexes
|
|
1
|
+
import { mongodb, buildDbIndexes } from '@unchainedshop/mongodb';
|
|
2
2
|
import {} from '@unchainedshop/mongodb';
|
|
3
3
|
export const EnrollmentStatus = {
|
|
4
4
|
INITIAL: 'INITIAL',
|
|
@@ -8,34 +8,33 @@ export const EnrollmentStatus = {
|
|
|
8
8
|
};
|
|
9
9
|
export const EnrollmentsCollection = async (db) => {
|
|
10
10
|
const Enrollments = db.collection('enrollments');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
status: 1,
|
|
30
|
-
},
|
|
31
|
-
name: 'enrollment_fulltext_search',
|
|
11
|
+
await buildDbIndexes(Enrollments, [
|
|
12
|
+
{
|
|
13
|
+
index: {
|
|
14
|
+
_id: 'text',
|
|
15
|
+
userId: 'text',
|
|
16
|
+
enrollmentNumber: 'text',
|
|
17
|
+
status: 'text',
|
|
18
|
+
'contact.telNumber': 'text',
|
|
19
|
+
'contact.emailAddress': 'text',
|
|
20
|
+
},
|
|
21
|
+
options: {
|
|
22
|
+
weights: {
|
|
23
|
+
_id: 8,
|
|
24
|
+
userId: 3,
|
|
25
|
+
enrollmentNumber: 6,
|
|
26
|
+
'contact.telNumber': 5,
|
|
27
|
+
'contact.emailAddress': 4,
|
|
28
|
+
status: 1,
|
|
32
29
|
},
|
|
30
|
+
name: 'enrollment_fulltext_search',
|
|
33
31
|
},
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
36
34
|
await buildDbIndexes(Enrollments, [
|
|
37
|
-
{ index: {
|
|
38
|
-
{ index: {
|
|
35
|
+
{ index: { 'periods.orderId': 1 } },
|
|
36
|
+
{ index: { userId: 1, status: 1 } },
|
|
37
|
+
{ index: { productId: 1, status: 1 } },
|
|
39
38
|
{ index: { status: 1 } },
|
|
40
39
|
{ index: { enrollmentNumber: 1 } },
|
|
41
40
|
]);
|
|
@@ -18,6 +18,9 @@ export declare const configureEnrollmentsModule: ({ db, options: enrollmentOptio
|
|
|
18
18
|
} | {
|
|
19
19
|
orderId: string;
|
|
20
20
|
}, options?: mongodb.FindOptions) => Promise<Enrollment | null>;
|
|
21
|
+
findEnrollmentsByOrderIds: ({ orderIds }: {
|
|
22
|
+
orderIds: string[];
|
|
23
|
+
}, options?: mongodb.FindOptions) => Promise<Enrollment[]>;
|
|
21
24
|
findEnrollments: ({ limit, offset, sort, ...query }: EnrollmentQuery & {
|
|
22
25
|
limit?: number;
|
|
23
26
|
offset?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SortDirection } from '@unchainedshop/utils';
|
|
2
2
|
import { EnrollmentStatus, } from "../db/EnrollmentsCollection.js";
|
|
3
3
|
import { emit, registerEvents } from '@unchainedshop/events';
|
|
4
|
-
import { generateDbFilterById, buildSortOptions, mongodb, generateDbObjectId,
|
|
4
|
+
import { generateDbFilterById, buildSortOptions, mongodb, generateDbObjectId, } from '@unchainedshop/mongodb';
|
|
5
5
|
import { EnrollmentsCollection } from "../db/EnrollmentsCollection.js";
|
|
6
6
|
import { enrollmentsSettings } from "../enrollments-settings.js";
|
|
7
7
|
const ENROLLMENT_EVENTS = [
|
|
@@ -19,7 +19,6 @@ export const buildFindSelector = ({ queryString, status, userId }) => {
|
|
|
19
19
|
if (userId)
|
|
20
20
|
selector.userId = userId;
|
|
21
21
|
if (queryString) {
|
|
22
|
-
assertDocumentDBCompatMode();
|
|
23
22
|
selector.$text = { $search: queryString };
|
|
24
23
|
}
|
|
25
24
|
return selector;
|
|
@@ -102,6 +101,11 @@ export const configureEnrollmentsModule = async ({ db, options: enrollmentOption
|
|
|
102
101
|
}
|
|
103
102
|
return Enrollments.findOne({ 'periods.orderId': params.orderId, deleted: null }, options);
|
|
104
103
|
},
|
|
104
|
+
findEnrollmentsByOrderIds: async ({ orderIds }, options) => {
|
|
105
|
+
if (!orderIds?.length)
|
|
106
|
+
return [];
|
|
107
|
+
return Enrollments.find({ 'periods.orderId': { $in: orderIds }, deleted: null }, options).toArray();
|
|
108
|
+
},
|
|
105
109
|
findEnrollments: async ({ limit, offset, sort, ...query }) => {
|
|
106
110
|
const defaultSortOption = [{ key: 'created', value: SortDirection.ASC }];
|
|
107
111
|
const enrollments = Enrollments.find(buildFindSelector(query), {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-enrollments",
|
|
3
3
|
"description": "Subscription and recurring billing module for the Unchained Engine",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.12",
|
|
5
5
|
"main": "lib/enrollments-index.js",
|
|
6
6
|
"types": "lib/enrollments-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@unchainedshop/events": "^4.
|
|
39
|
-
"@unchainedshop/logger": "^4.
|
|
40
|
-
"@unchainedshop/utils": "^4.
|
|
38
|
+
"@unchainedshop/events": "^4.8.12",
|
|
39
|
+
"@unchainedshop/logger": "^4.8.12",
|
|
40
|
+
"@unchainedshop/utils": "^4.8.12"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^25.0.0",
|