@unchainedshop/core-enrollments 4.8.29 → 5.0.0-alpha.10

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.
package/README.md CHANGED
@@ -13,97 +13,21 @@ npm install @unchainedshop/core-enrollments
13
13
 
14
14
  ## Usage
15
15
 
16
- ```typescript
17
- import { configureEnrollmentsModule, EnrollmentStatus } from '@unchainedshop/core-enrollments';
16
+ The platform initializes this module as `platform.unchainedAPI.modules.enrollments`.
18
17
 
19
- const enrollmentsModule = await configureEnrollmentsModule({ db });
18
+ ```typescript
19
+ import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
20
20
 
21
- // Create an enrollment
22
- const enrollmentId = await enrollmentsModule.create({
21
+ const { enrollments } = platform.unchainedAPI.modules;
22
+ const activeEnrollments = await enrollments.findEnrollments({
23
+ status: [EnrollmentStatus.ACTIVE],
23
24
  userId: 'user-123',
24
- productId: 'plan-product-456',
25
- quantity: 1,
26
- });
27
-
28
- // Activate enrollment
29
- await enrollmentsModule.activate(enrollmentId);
30
-
31
- // Find active enrollments
32
- const enrollments = await enrollmentsModule.findEnrollments({
33
- status: EnrollmentStatus.ACTIVE,
34
25
  });
35
26
  ```
36
27
 
37
- ## API Overview
38
-
39
- ### Module Configuration
40
-
41
- | Export | Description |
42
- |--------|-------------|
43
- | `configureEnrollmentsModule` | Configure and return the enrollments module |
44
-
45
- ### Queries
46
-
47
- | Method | Description |
48
- |--------|-------------|
49
- | `findEnrollment` | Find enrollment by ID |
50
- | `findEnrollments` | Find enrollments with filtering and pagination |
51
- | `count` | Count enrollments matching query |
52
- | `enrollmentExists` | Check if enrollment exists |
53
-
54
- ### Mutations
55
-
56
- | Method | Description |
57
- |--------|-------------|
58
- | `create` | Create a new enrollment |
59
- | `update` | Update enrollment data |
60
- | `delete` | Delete an enrollment |
61
- | `activate` | Activate an enrollment |
62
- | `terminate` | Terminate an enrollment |
63
-
64
- ### Period Management
65
-
66
- | Method | Description |
67
- |--------|-------------|
68
- | `addPeriod` | Add a billing period |
69
- | `findPeriod` | Find a specific period |
70
- | `isExpired` | Check if enrollment is expired |
71
-
72
- ### Utilities
73
-
74
- | Export | Description |
75
- |--------|-------------|
76
- | `addToDate` | Add time interval to date |
77
-
78
- ### Constants
79
-
80
- | Export | Description |
81
- |--------|-------------|
82
- | `EnrollmentStatus` | Status values (INITIAL, ACTIVE, PAUSED, TERMINATED) |
83
-
84
- ### Settings
85
-
86
- | Export | Description |
87
- |--------|-------------|
88
- | `enrollmentsSettings` | Access enrollment module settings |
89
-
90
- ### Types
91
-
92
- | Export | Description |
93
- |--------|-------------|
94
- | `Enrollment` | Enrollment document type |
95
- | `EnrollmentPeriod` | Period document type |
96
- | `EnrollmentsModule` | Module interface type |
97
-
98
- ## Events
28
+ Status filters accept arrays. Enrollment lifecycle operations and recurring order generation are coordinated by `unchainedAPI.services.enrollments` and the registered enrollment and worker plugins. The module stores enrollments and their periods (`addEnrollmentPeriod`).
99
29
 
100
- | Event | Description |
101
- |-------|-------------|
102
- | `ENROLLMENT_CREATE` | Enrollment created |
103
- | `ENROLLMENT_UPDATE` | Enrollment updated |
104
- | `ENROLLMENT_REMOVE` | Enrollment deleted |
105
- | `ENROLLMENT_ACTIVATE` | Enrollment activated |
106
- | `ENROLLMENT_TERMINATE` | Enrollment terminated |
30
+ See the [module guide](https://docs.unchained.shop/platform-configuration/modules/enrollments), [public exports](src/enrollments-index.ts), and [module implementation](src/module/configureEnrollmentsModule.ts).
107
31
 
108
32
  ## License
109
33
 
@@ -7,7 +7,7 @@ export interface EnrollmentPeriod {
7
7
  isTrial?: boolean;
8
8
  }
9
9
  export interface EnrollmentPlan {
10
- configuration: {
10
+ configuration?: {
11
11
  key: string;
12
12
  value: string;
13
13
  }[] | null;
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-enrollments",
3
3
  "description": "Subscription and recurring billing module for the Unchained Engine",
4
- "version": "4.8.29",
4
+ "version": "5.0.0-alpha.10",
5
+ "files": [
6
+ "lib"
7
+ ],
5
8
  "main": "lib/enrollments-index.js",
6
9
  "types": "lib/enrollments-index.d.ts",
7
10
  "type": "module",
@@ -35,12 +38,12 @@
35
38
  },
36
39
  "homepage": "https://github.com/unchainedshop/unchained#readme",
37
40
  "dependencies": {
38
- "@unchainedshop/events": "^4.8.27",
39
- "@unchainedshop/mongodb": "^4.8.27",
40
- "@unchainedshop/utils": "^4.8.27"
41
+ "@unchainedshop/events": "^5.0.0-alpha.10",
42
+ "@unchainedshop/mongodb": "^5.0.0-alpha.10",
43
+ "@unchainedshop/utils": "^5.0.0-alpha.10"
41
44
  },
42
45
  "devDependencies": {
43
46
  "@types/node": "^26.2.0",
44
- "typescript": "^5.8.3"
47
+ "typescript": "^6.0.3"
45
48
  }
46
49
  }