@unchainedshop/core-events 5.0.0-alpha.5 → 5.0.0-alpha.8

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,71 +13,21 @@ npm install @unchainedshop/core-events
13
13
 
14
14
  ## Usage
15
15
 
16
- ```typescript
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
- const eventsModule = await configureEventsModule({ db });
18
+ ```typescript
19
+ const { events } = platform.unchainedAPI.modules;
20
20
 
21
- // Find events by type
22
- const orderEvents = await eventsModule.findEvents({
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
- ## API Overview
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
- This enables event sourcing patterns, audit trails, and analytics.
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
 
@@ -67,7 +67,7 @@ export const configureEventsModule = async ({ db }) => {
67
67
  conditions.push({ created: { $lte: toDate } });
68
68
  }
69
69
  if (conditions.length) {
70
- match.$or = conditions;
70
+ match.$and = conditions;
71
71
  }
72
72
  }
73
73
  if (types?.length) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-events",
3
3
  "description": "Event history and tracking module for the Unchained Engine",
4
- "version": "5.0.0-alpha.5",
4
+ "version": "5.0.0-alpha.8",
5
5
  "main": "lib/events-index.js",
6
6
  "types": "lib/events-index.d.ts",
7
7
  "type": "module",
@@ -35,10 +35,10 @@
35
35
  },
36
36
  "homepage": "https://github.com/unchainedshop/unchained#readme",
37
37
  "dependencies": {
38
- "@unchainedshop/events": "^5.0.0-alpha.5",
39
- "@unchainedshop/logger": "^5.0.0-alpha.5",
40
- "@unchainedshop/mongodb": "^5.0.0-alpha.5",
41
- "@unchainedshop/utils": "^5.0.0-alpha.5"
38
+ "@unchainedshop/events": "^5.0.0-alpha.8",
39
+ "@unchainedshop/logger": "^5.0.0-alpha.8",
40
+ "@unchainedshop/mongodb": "^5.0.0-alpha.8",
41
+ "@unchainedshop/utils": "^5.0.0-alpha.8"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^26.2.0",