@jskit-ai/realtime 0.1.96 → 0.1.97

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.
@@ -1,7 +1,7 @@
1
1
  export default Object.freeze({
2
2
  packageVersion: 1,
3
3
  packageId: "@jskit-ai/realtime",
4
- version: "0.1.96",
4
+ version: "0.1.97",
5
5
  kind: "runtime",
6
6
  description: "Thin, generic realtime runtime wrappers for socket.io server and client.",
7
7
  options: {
@@ -95,7 +95,7 @@ export default Object.freeze({
95
95
  mutations: {
96
96
  dependencies: {
97
97
  runtime: {
98
- "@jskit-ai/kernel": "0.1.98",
98
+ "@jskit-ai/kernel": "0.1.99",
99
99
  "@socket.io/redis-adapter": "^8.3.0",
100
100
  "redis": "^5.8.2",
101
101
  "socket.io": "^4.8.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/realtime",
3
- "version": "0.1.96",
3
+ "version": "0.1.97",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@socket.io/redis-adapter": "^8.3.0",
19
- "@jskit-ai/kernel": "0.1.98",
19
+ "@jskit-ai/kernel": "0.1.99",
20
20
  "redis": "^5.8.2",
21
21
  "socket.io": "^4.8.3",
22
22
  "socket.io-client": "^4.8.3"
@@ -169,16 +169,32 @@ function buildRealtimeDispatchIndex(registrations = []) {
169
169
 
170
170
  function mergeRealtimePayload(event, payloadPatch) {
171
171
  const basePayload = event && typeof event === "object" && !Array.isArray(event) ? event : {};
172
+ const action = normalizeText(basePayload?.meta?.action);
173
+ const reason = normalizeText(basePayload?.meta?.reason);
174
+ const semanticPatch = {};
175
+ if (action) {
176
+ semanticPatch.action = action;
177
+ }
178
+ if (reason) {
179
+ semanticPatch.reason = reason;
180
+ }
181
+
172
182
  if (payloadPatch == null) {
173
- return basePayload;
183
+ return Object.keys(semanticPatch).length > 0
184
+ ? {
185
+ ...semanticPatch,
186
+ ...basePayload
187
+ }
188
+ : basePayload;
174
189
  }
175
190
  if (!payloadPatch || typeof payloadPatch !== "object" || Array.isArray(payloadPatch)) {
176
191
  throw new TypeError("Realtime payload callback must return an object.");
177
192
  }
178
193
 
179
- // Keep canonical domain-event fields authoritative while allowing additive metadata.
194
+ // Keep canonical domain-event fields and standard lifecycle metadata authoritative.
180
195
  return {
181
196
  ...payloadPatch,
197
+ ...semanticPatch,
182
198
  ...basePayload
183
199
  };
184
200
  }
@@ -615,6 +615,8 @@ test("RealtimeServiceProvider merges custom realtime payload with canonical doma
615
615
  source: "workspace",
616
616
  entity: "settings",
617
617
  operation: "updated",
618
+ action: "settings-saved",
619
+ reason: "profile-update",
618
620
  realtime: {
619
621
  event: "workspace.settings.changed",
620
622
  payload: ({ result }) => ({
@@ -670,10 +672,14 @@ test("RealtimeServiceProvider merges custom realtime payload with canonical doma
670
672
  assert.equal(emitted.length, 1);
671
673
  assert.equal(emitted[0].room, "workspace:11");
672
674
  assert.equal(emitted[0].eventName, "workspace.settings.changed");
675
+ assert.equal(emitted[0].payload?.action, "settings-saved");
676
+ assert.equal(emitted[0].payload?.reason, "profile-update");
673
677
  assert.equal(emitted[0].payload?.workspaceSlug, "acme");
674
678
  assert.equal(emitted[0].payload?.source, "workspace");
675
679
  assert.equal(emitted[0].payload?.entity, "settings");
676
680
  assert.equal(emitted[0].payload?.operation, "updated");
681
+ assert.equal(emitted[0].payload?.meta?.action, "settings-saved");
682
+ assert.equal(emitted[0].payload?.meta?.reason, "profile-update");
677
683
  assert.equal(emitted[0].payload?.scope?.kind, "workspace");
678
684
  assert.equal(emitted[0].payload?.scope?.id, "11");
679
685
  });