coakka-v2-connector-node 1.3.6 → 1.3.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
@@ -27,13 +27,17 @@ bash run.sh runtime node basic
27
27
  No-checkout npm smoke:
28
28
  https://github.com/phuong-tran/coakka-samples/blob/main/docs/first-npm-smoke.md
29
29
 
30
- Try the npm package without cloning any CoAkka repo:
30
+ Samples docs directory:
31
+ https://github.com/phuong-tran/coakka-samples/tree/main/docs
32
+
33
+ Try the npm package without cloning any CoAkka repo. The example uses the same
34
+ customer command that often becomes fake backend HTTP in a growing app:
31
35
 
32
36
  ```sh
33
37
  mkdir coakka-runtime-first-run
34
38
  cd coakka-runtime-first-run
35
39
  npm init -y
36
- npm install coakka-v2-connector-node@1.3.6
40
+ npm install coakka-v2-connector-node@1.3.8
37
41
  ```
38
42
 
39
43
  ```js
@@ -46,10 +50,12 @@ import {
46
50
  RuntimeHost,
47
51
  } from "coakka-v2-connector-node";
48
52
 
49
- const target = "first.user.echo";
53
+ const target = "samples.customer.store.create";
54
+ const store = new Map();
55
+
50
56
  const runtime = RuntimeHost.start({
51
- systemName: "first-user-runtime",
52
- nodeId: "first-user-runtime-node",
57
+ systemName: "customer-app",
58
+ nodeId: "customer-app-node-1",
53
59
  queueCapacity: 64,
54
60
  strictNoDrop: true,
55
61
  generation: 1,
@@ -57,16 +63,25 @@ const runtime = RuntimeHost.start({
57
63
  });
58
64
 
59
65
  try {
60
- runtime.registerHandler(target, (request) =>
61
- NodeRuntimeClient.makeJsonReplyFromRequestIdentity(request, target, { ok: true }),
62
- );
66
+ runtime.registerHandler(target, (request) => {
67
+ const draft = JSON.parse(Buffer.from(request.payload).toString("utf8"));
68
+ const customer = { id: draft.id, name: draft.name, createdBy: request.source };
69
+ store.set(customer.id, customer);
70
+
71
+ return NodeRuntimeClient.makeJsonReplyFromRequestIdentity(request, target, {
72
+ status: "created",
73
+ customer,
74
+ storedCount: store.size,
75
+ });
76
+ });
77
+
63
78
  const response = await runtime.askJson(
64
- "first-user-client",
79
+ "customer-api",
65
80
  target,
66
- { hello: "coakka" },
67
- new PayloadIdentity("first.user.echo.request.v1", 1, PayloadFormat.JSON),
81
+ { id: "cust-001", name: "Ada Lovelace" },
82
+ new PayloadIdentity("samples.customer.create.request.v1", 1, PayloadFormat.JSON),
68
83
  2000,
69
- "echo",
84
+ "create_customer",
70
85
  DeliveryHint.ROUTER_DEFAULT,
71
86
  );
72
87
  console.log(response);
@@ -101,75 +116,53 @@ Request/reply lane in Node.js now has two host API shapes over the same runtime
101
116
 
102
117
  ## Before / After
103
118
 
104
- Before, local application code had to start from the connector-internal
105
- orchestration name:
106
-
107
- ```ts
108
- import {
109
- ConnectorOrchestrator,
110
- PayloadFormat,
111
- PayloadIdentity,
112
- } from "coakka-v2-connector-node";
119
+ Before, the browser/API edge can be real HTTP, but teams often add a second
120
+ private backend HTTP endpoint only so work owned by the same app or team has
121
+ an address:
113
122
 
114
- const connector = ConnectorOrchestrator.start({
115
- systemName: "customer-local",
116
- nodeId: "customer-local-node",
117
- routes: [],
123
+ ```js
124
+ app.post("/backend/customers", async (req, res) => {
125
+ const customer = await store.create(req.body);
126
+ res.json({ status: "created", customer });
118
127
  });
119
- const requestIdentity = new PayloadIdentity(
120
- "customer.create.request.v1",
121
- 1,
122
- PayloadFormat.JSON,
123
- );
124
-
125
- try {
126
- const response = await connector.askJson(
127
- "customer-api",
128
- "customer.create",
129
- { name: "Ada" },
130
- requestIdentity,
131
- );
132
- } finally {
133
- connector.close();
134
- }
135
- ```
136
128
 
137
- After, the same single-process runtime is named as the application-owned host:
129
+ app.post("/api/customers", async (req, res) => {
130
+ const reply = await fetch("http://customer-store/backend/customers", {
131
+ method: "POST",
132
+ headers: { "content-type": "application/json" },
133
+ body: JSON.stringify(req.body),
134
+ });
138
135
 
139
- ```ts
140
- import {
141
- PayloadFormat,
142
- PayloadIdentity,
143
- RuntimeHost,
144
- } from "coakka-v2-connector-node";
145
-
146
- const runtime = RuntimeHost.start({
147
- systemName: "customer-local",
148
- nodeId: "customer-local-node",
149
- routes: [],
136
+ res.json(await reply.json());
150
137
  });
151
- const requestIdentity = new PayloadIdentity(
152
- "customer.create.request.v1",
153
- 1,
154
- PayloadFormat.JSON,
155
- );
138
+ ```
156
139
 
157
- try {
140
+ After, the public API can stay HTTP, but the fake backend URL becomes a CoAkka
141
+ target:
142
+
143
+ ```js
144
+ app.post("/api/customers", async (req, res) => {
158
145
  const response = await runtime.askJson(
159
146
  "customer-api",
160
- "customer.create",
161
- { name: "Ada" },
162
- requestIdentity,
147
+ "samples.customer.store.create",
148
+ req.body,
149
+ new PayloadIdentity("samples.customer.create.request.v1", 1, PayloadFormat.JSON),
150
+ 5000,
151
+ "create_customer",
152
+ DeliveryHint.ROUTER_DEFAULT,
163
153
  );
164
- } finally {
165
- runtime.close();
166
- }
154
+
155
+ res.json(response);
156
+ });
167
157
  ```
168
158
 
169
- `ConnectorOrchestrator` remains available for existing code. New local-first
170
- Spring Boot, Quarkus, CRUD, and script-style examples should prefer
171
- `RuntimeHost` so the first screen reads as one embedded runtime owner, not a
172
- remote connector setup.
159
+ The change is not "replace HTTP." HTTP still belongs at real browser/API or
160
+ legacy edges. CoAkka removes backend HTTP that exists only to call capabilities
161
+ owned by the same app or team by URL.
162
+
163
+ `ConnectorOrchestrator` remains available for existing code. New examples
164
+ prefer `RuntimeHost` so the first screen reads as one embedded runtime owner,
165
+ not a remote connector setup.
173
166
 
174
167
  `separateDeliveredRequestLane` defaults to `true`. Most request/reply services
175
168
  should leave it alone so inbound handler work stays separate from
@@ -1,4 +1,4 @@
1
- export declare const COAKKA_V2_NODE_VERSION = "1.3.6";
1
+ export declare const COAKKA_V2_NODE_VERSION = "1.3.8";
2
2
  export declare const COAKKA_V2_NATIVE_CORE_VERSION = "1.3.1";
3
3
  export declare const COAKKA_V2_NATIVE_GIT_COMMIT = "0da8c2d9";
4
4
  export declare const COAKKA_V2_NATIVE_PACKAGE_VERSION = "1.3.1+0da8c2d9";
package/dist/packaging.js CHANGED
@@ -1,4 +1,4 @@
1
- export const COAKKA_V2_NODE_VERSION = "1.3.6";
1
+ export const COAKKA_V2_NODE_VERSION = "1.3.8";
2
2
  export const COAKKA_V2_NATIVE_CORE_VERSION = "1.3.1";
3
3
  export const COAKKA_V2_NATIVE_GIT_COMMIT = "0da8c2d9";
4
4
  export const COAKKA_V2_NATIVE_PACKAGE_VERSION = "1.3.1+0da8c2d9";
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "coakka-v2-connector-node",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Node.js connector package for the CoAkka runtime v2",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/phuong-tran/coakkaJVMConnector.git",
9
- "directory": "node"
8
+ "url": "git+https://github.com/phuong-tran/coakka-publish.git"
10
9
  },
11
10
  "homepage": "https://github.com/phuong-tran/coakka-samples/blob/main/docs/first-npm-smoke.md",
12
11
  "bugs": {
13
- "url": "https://github.com/phuong-tran/coakkaJVMConnector/issues"
12
+ "url": "https://github.com/phuong-tran/coakka-samples/issues"
14
13
  },
15
14
  "keywords": [
16
15
  "coakka",