@spine-event-engine/transport 2.0.0-snapshot.2 → 2.0.0-snapshot.5

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.
Files changed (2) hide show
  1. package/README.md +78 -9
  2. package/package.json +3 -4
package/README.md CHANGED
@@ -1,12 +1,81 @@
1
- # Transport
1
+ # Local transport for Spine TS
2
2
 
3
- `@spine-event-engine/transport` provides process-local typed message channels
4
- for IntegrationBroker external-message exchange.
3
+ `@spine-event-engine/transport` gives a Spine application typed, process-local
4
+ message channels. It is for application and infrastructure developers who need
5
+ to connect the external-message broker in a local or test process; it is not a
6
+ general internet messaging client.
5
7
 
6
- Use `InMemoryTransportFactory` for local and test environments. The package
7
- exports `TransportFactory`, `MessageChannel`, `Publisher`, `Subscriber`,
8
- and `ConsumerHandle`; channels carry generated `ExternalMessage` values and
9
- canonical target type URLs.
8
+ This is an experimental snapshot package. Use Node 24 or newer and generated
9
+ Spine Protobuf contracts before integrating it. Start with the package
10
+ [reference](REFERENCE.md) for the complete lifecycle and channel contract.
10
11
 
11
- For lifecycle and channel semantics, see the
12
- [REFERENCE documentation for agents](REFERENCE.md).
12
+ ## Install
13
+
14
+ ```sh
15
+ pnpm add @spine-event-engine/transport@snapshot
16
+ ```
17
+
18
+ The `snapshot` tag is intentionally experimental and can change before a
19
+ stable release.
20
+
21
+ ## First success: create a local channel
22
+
23
+ Create an `InMemoryTransportFactory`, then let the broker-facing application
24
+ code request its typed `MessageChannel`. The channel carries generated
25
+ `ExternalMessage` values and canonical target type URLs; it does not serialize
26
+ them for another process.
27
+
28
+ <!-- docs-snippet-path: packages/transport/test/memory/message-transport.test.ts -->
29
+
30
+ ```ts
31
+ import { create, toBinary } from "@bufbuild/protobuf";
32
+ import { AnySchema, StringValueSchema } from "@bufbuild/protobuf/wkt";
33
+ import {
34
+ BoundedContextNameSchema,
35
+ ChannelIdSchema,
36
+ ExternalMessageSchema,
37
+ } from "@spine-event-engine/proto";
38
+ import { InMemoryTransportFactory } from "@spine-event-engine/transport";
39
+
40
+ const factory = new InMemoryTransportFactory();
41
+ const channel = create(ChannelIdSchema, { targetType: "type.spine.io/acme.tasks.Task" });
42
+ const subscriber = await factory.createSubscriber(channel);
43
+ const received: string[] = [];
44
+ const consumer = await subscriber.addConsumer((message) => {
45
+ received.push(message.id?.typeUrl ?? "");
46
+ });
47
+ const publisher = await factory.createPublisher(channel);
48
+ const id = create(AnySchema, {
49
+ typeUrl: "type.spine.io/google.protobuf.StringValue",
50
+ value: toBinary(StringValueSchema, create(StringValueSchema, { value: "task-42" })),
51
+ });
52
+
53
+ try {
54
+ await publisher.publish(
55
+ id,
56
+ create(ExternalMessageSchema, {
57
+ id,
58
+ originalMessage: id,
59
+ boundedContextName: create(BoundedContextNameSchema, { value: "tasks" }),
60
+ }),
61
+ );
62
+ if (received[0] !== id.typeUrl) throw new Error("The consumer did not receive the frame.");
63
+ } finally {
64
+ await consumer.close();
65
+ await subscriber.close();
66
+ await publisher.close();
67
+ await factory.close();
68
+ }
69
+ ```
70
+
71
+ ## What it does not provide
72
+
73
+ This package has no network listener, persistence, cross-process delivery,
74
+ authentication, or broker retry policy. Use it for local composition and tests;
75
+ choose a deployment-specific transport for communication across processes.
76
+
77
+ ## Next steps
78
+
79
+ - Read the [transport reference for coding agents](REFERENCE.md) for publisher,
80
+ subscriber, and `ConsumerHandle` lifecycle rules.
81
+ - See [Protobuf contracts](https://github.com/SpineEventEngine/spine-ts/blob/main/packages/proto/README.md) for generated message types.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spine-event-engine/transport",
3
- "version": "2.0.0-snapshot.2",
3
+ "version": "2.0.0-snapshot.5",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {
@@ -10,8 +10,7 @@
10
10
  },
11
11
  "publishConfig": {
12
12
  "registry": "https://registry.npmjs.org/",
13
- "access": "public",
14
- "tag": "snapshot"
13
+ "access": "public"
15
14
  },
16
15
  "description": "Spine TS transport package skeleton.",
17
16
  "exports": {
@@ -27,6 +26,6 @@
27
26
  ],
28
27
  "dependencies": {
29
28
  "@bufbuild/protobuf": "2.12.1",
30
- "@spine-event-engine/proto": "2.0.0-snapshot.2"
29
+ "@spine-event-engine/proto": "2.0.0-snapshot.5"
31
30
  }
32
31
  }