@nwire/messages 0.7.0 → 0.7.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.
- package/README.md +0 -29
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -12,30 +12,6 @@ Typed message primitives for the CQRS surface: `defineCommand` for intent (one h
|
|
|
12
12
|
pnpm add @nwire/messages
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## Standalone use
|
|
16
|
-
|
|
17
|
-
For developers who want a typed message contract layer for their own architecture — works against any in-process bus, queue, or RPC.
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { z } from "zod";
|
|
21
|
-
import { defineCommand, defineEvent } from "@nwire/messages";
|
|
22
|
-
|
|
23
|
-
export const EnrolStudent = defineCommand("EnrolStudent", {
|
|
24
|
-
schema: z.object({ studentId: z.string(), courseId: z.string() }),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export const StudentWasEnrolled = defineEvent("StudentWasEnrolled", {
|
|
28
|
-
schema: z.object({ studentId: z.string(), courseId: z.string() }),
|
|
29
|
-
scope: "domain",
|
|
30
|
-
visibility: "public",
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Validate at the edge:
|
|
34
|
-
const payload = EnrolStudent.schema.parse(req.body);
|
|
35
|
-
// Construct an event message:
|
|
36
|
-
const msg = StudentWasEnrolled({ studentId: "s-1", courseId: "c-1" });
|
|
37
|
-
```
|
|
38
|
-
|
|
39
15
|
## Within nwire-app
|
|
40
16
|
|
|
41
17
|
For developers using this package as part of the Nwire stack. `@nwire/forge`'s `defineEvent` wraps this one with extra hooks (bus republish, projection fan-out). Touch `@nwire/messages` directly when you need just the contracts — typically in shared kits a foreign service imports.
|
|
@@ -54,8 +30,3 @@ const StudentWasEnrolled = defineEvent("StudentWasEnrolled", {
|
|
|
54
30
|
- `CommandDefinition`, `EventDefinition`, `EventMessageOf`, `CommandPayload`, `EventPayload` — inferred types.
|
|
55
31
|
- `EventVisibility` / `EventScope` / `EventOutcome` — enums (`public`/`internal`, `domain`/`integration`, success/failure tags).
|
|
56
32
|
- `ServiceBootedEvent`, `NoopCommand` — built-in baseline contracts.
|
|
57
|
-
|
|
58
|
-
## See also
|
|
59
|
-
|
|
60
|
-
- [Architecture sketch §05 — Primitives tier](../../architecture-sketch.html#packages)
|
|
61
|
-
- Sibling packages: [@nwire/forge](../nwire-forge), [@nwire/bus](../nwire-bus), [@nwire/envelope](../nwire-envelope)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwire/messages",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Nwire — typed command and event contracts. defineCommand, defineEvent with public/internal visibility. Zod-validated; shareable across the backend, frontends, BFFs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"commands",
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
"messages",
|
|
10
10
|
"nwire"
|
|
11
11
|
],
|
|
12
|
+
"license": "MIT",
|
|
12
13
|
"files": [
|
|
13
14
|
"dist",
|
|
14
|
-
"README.md"
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
15
17
|
],
|
|
16
18
|
"type": "module",
|
|
17
19
|
"main": "./dist/messages.js",
|