@unchainedshop/core-events 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 +8 -58
- package/lib/module/configureEventsModule.js +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -13,71 +13,21 @@ npm install @unchainedshop/core-events
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
import { configureEventsModule } from '@unchainedshop/core-events';
|
|
16
|
+
The platform initializes this module as `platform.unchainedAPI.modules.events` and installs the database history adapter if none is already configured.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
```typescript
|
|
19
|
+
const { events } = platform.unchainedAPI.modules;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
types: ['ORDER_CREATE', 'ORDER_PAID'],
|
|
21
|
+
const orderEvents = await events.findEvents({
|
|
22
|
+
types: ['ORDER_CREATE', 'ORDER_PAY'],
|
|
24
23
|
limit: 100,
|
|
25
24
|
});
|
|
26
|
-
|
|
27
|
-
// Get event statistics
|
|
28
|
-
const report = await eventsModule.getReport({
|
|
29
|
-
types: ['ORDER_CREATE'],
|
|
30
|
-
dateRange: { start: '2024-01-01', end: '2024-12-31' },
|
|
31
|
-
});
|
|
25
|
+
const report = await events.getReport({ types: ['ORDER_CREATE'] });
|
|
32
26
|
```
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Module Configuration
|
|
37
|
-
|
|
38
|
-
| Export | Description |
|
|
39
|
-
|--------|-------------|
|
|
40
|
-
| `configureEventsModule` | Configure and return the events module |
|
|
41
|
-
|
|
42
|
-
### Queries
|
|
43
|
-
|
|
44
|
-
| Method | Description |
|
|
45
|
-
|--------|-------------|
|
|
46
|
-
| `findEvent` | Find a single event by ID or filter |
|
|
47
|
-
| `findEvents` | Find events with filtering, sorting, and pagination |
|
|
48
|
-
| `count` | Count events matching query |
|
|
49
|
-
| `getReport` | Get aggregated event statistics by type and date |
|
|
50
|
-
|
|
51
|
-
### Mutations
|
|
52
|
-
|
|
53
|
-
| Method | Description |
|
|
54
|
-
|--------|-------------|
|
|
55
|
-
| `create` | Create a new event record |
|
|
56
|
-
|
|
57
|
-
### Helper Methods
|
|
58
|
-
|
|
59
|
-
| Method | Description |
|
|
60
|
-
|--------|-------------|
|
|
61
|
-
| `type` | Get event type, returns 'UNKNOWN' for unregistered types |
|
|
62
|
-
|
|
63
|
-
### Types
|
|
64
|
-
|
|
65
|
-
| Export | Description |
|
|
66
|
-
|--------|-------------|
|
|
67
|
-
| `Event` | Event document type |
|
|
68
|
-
| `EventQuery` | Query parameters type |
|
|
69
|
-
| `EventReport` | Report output type |
|
|
70
|
-
| `EventsModule` | Module interface type |
|
|
71
|
-
|
|
72
|
-
## Event History
|
|
73
|
-
|
|
74
|
-
This module automatically integrates with `@unchainedshop/events` to persist all emitted events to the database. Events are stored with:
|
|
75
|
-
|
|
76
|
-
- Event type
|
|
77
|
-
- Payload data
|
|
78
|
-
- Timestamp
|
|
28
|
+
Records contain the event type, payload, and creation timestamp. The TTL index removes records after `EVENTS_TTL_SECONDS` (default: 172800 seconds, or two days). Configure long-term audit retention through your logging pipeline.
|
|
79
29
|
|
|
80
|
-
|
|
30
|
+
See the [module guide](https://docs.unchained.shop/platform-configuration/modules/events), [public exports](src/events-index.ts), and [module implementation](src/module/configureEventsModule.ts).
|
|
81
31
|
|
|
82
32
|
## License
|
|
83
33
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-events",
|
|
3
3
|
"description": "Event history and tracking module for the Unchained Engine",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-alpha.10",
|
|
5
|
+
"files": [
|
|
6
|
+
"lib"
|
|
7
|
+
],
|
|
5
8
|
"main": "lib/events-index.js",
|
|
6
9
|
"types": "lib/events-index.d.ts",
|
|
7
10
|
"type": "module",
|
|
@@ -35,13 +38,13 @@
|
|
|
35
38
|
},
|
|
36
39
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
40
|
"dependencies": {
|
|
38
|
-
"@unchainedshop/events": "^
|
|
39
|
-
"@unchainedshop/logger": "^
|
|
40
|
-
"@unchainedshop/mongodb": "^
|
|
41
|
-
"@unchainedshop/utils": "^
|
|
41
|
+
"@unchainedshop/events": "^5.0.0-alpha.10",
|
|
42
|
+
"@unchainedshop/logger": "^5.0.0-alpha.10",
|
|
43
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.10",
|
|
44
|
+
"@unchainedshop/utils": "^5.0.0-alpha.10"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
47
|
"@types/node": "^26.2.0",
|
|
45
|
-
"typescript": "^
|
|
48
|
+
"typescript": "^6.0.3"
|
|
46
49
|
}
|
|
47
50
|
}
|