@newhomestar/sdk 0.8.17 → 0.8.18
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 +1187 -1187
- package/dist/events.js +18 -0
- package/package.json +64 -64
package/dist/events.js
CHANGED
|
@@ -257,9 +257,21 @@ export async function withServiceEventOutbox(db, reqOrCallback, maybeCallback) {
|
|
|
257
257
|
for (const staged of stagedEmits) {
|
|
258
258
|
// Pass the topic directly as event_slug — no decomposition needed.
|
|
259
259
|
// The Events Service uses event_slug to look up the event_type and fan-out.
|
|
260
|
+
//
|
|
261
|
+
// Auto-derive entity_id from attributes.id when the producer's mapRow()
|
|
262
|
+
// puts the row's primary key there. This is the convention used across
|
|
263
|
+
// every Nova service route handler ({ id: row.id, ... }) and downstream
|
|
264
|
+
// consumers (integration write-back, decision logging) rely on entity_id
|
|
265
|
+
// to PATCH the correct row. Falls back to undefined when there is no
|
|
266
|
+
// string-typed `id` in the attributes (e.g. composite-key entities or
|
|
267
|
+
// system-level events).
|
|
268
|
+
const entityId = typeof staged.payload?.id === 'string'
|
|
269
|
+
? staged.payload.id
|
|
270
|
+
: undefined;
|
|
260
271
|
const fullPayload = {
|
|
261
272
|
event_slug: staged.topic,
|
|
262
273
|
source_service: serviceSlug ?? undefined,
|
|
274
|
+
entity_id: entityId,
|
|
263
275
|
attributes: staged.payload,
|
|
264
276
|
metadata: {
|
|
265
277
|
source: xSource,
|
|
@@ -582,9 +594,15 @@ export async function withWebhookEvent(db, opts, handler) {
|
|
|
582
594
|
result = await handler(tx, emit);
|
|
583
595
|
// ── 4. Write outbox rows for staged events ────────────────────────
|
|
584
596
|
for (const staged of stagedEmits) {
|
|
597
|
+
// Auto-derive entity_id from attributes.id — see the matching
|
|
598
|
+
// comment in withServiceEventOutbox for rationale.
|
|
599
|
+
const entityId = typeof staged.payload?.id === 'string'
|
|
600
|
+
? staged.payload.id
|
|
601
|
+
: undefined;
|
|
585
602
|
const fullPayload = {
|
|
586
603
|
event_slug: staged.topic,
|
|
587
604
|
source_service: serviceSlug ?? undefined,
|
|
605
|
+
entity_id: entityId,
|
|
588
606
|
attributes: staged.payload,
|
|
589
607
|
metadata: { source: 'webhook' },
|
|
590
608
|
};
|
package/package.json
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@newhomestar/sdk",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "Type-safe SDK for building Nova pipelines (workers & functions)",
|
|
5
|
-
"homepage": "https://github.com/newhomestar/nova-node-sdk#readme",
|
|
6
|
-
"bugs": {
|
|
7
|
-
"url": "https://github.com/newhomestar/nova-node-sdk/issues"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/newhomestar/nova-node-sdk.git"
|
|
12
|
-
},
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"author": "Christian Gomez",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"main": "dist/index.js",
|
|
17
|
-
"types": "dist/index.d.ts",
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"import": "./dist/index.js",
|
|
21
|
-
"types": "./dist/index.d.ts"
|
|
22
|
-
},
|
|
23
|
-
"./next": {
|
|
24
|
-
"import": "./dist/next.js",
|
|
25
|
-
"types": "./dist/next.d.ts"
|
|
26
|
-
},
|
|
27
|
-
"./events": {
|
|
28
|
-
"import": "./dist/events.js",
|
|
29
|
-
"types": "./dist/events.d.ts"
|
|
30
|
-
},
|
|
31
|
-
"./connections": {
|
|
32
|
-
"import": "./dist/connections.js",
|
|
33
|
-
"types": "./dist/connections.d.ts"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"files": [
|
|
37
|
-
"dist"
|
|
38
|
-
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsc"
|
|
41
|
-
},
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"@openfga/sdk": "^0.9.0",
|
|
44
|
-
"@orpc/openapi": "1.7.4",
|
|
45
|
-
"@orpc/server": "1.7.4",
|
|
46
|
-
"@supabase/supabase-js": "^2.39.0",
|
|
47
|
-
"body-parser": "^1.20.2",
|
|
48
|
-
"cors": "^2.8.6",
|
|
49
|
-
"dotenv": "^16.4.3",
|
|
50
|
-
"express": "^4.18.2",
|
|
51
|
-
"express-oauth2-jwt-bearer": "^1.7.4",
|
|
52
|
-
"undici": "^7.24.4",
|
|
53
|
-
"yaml": "^2.7.1"
|
|
54
|
-
},
|
|
55
|
-
"peerDependencies": {
|
|
56
|
-
"zod": ">=4.0.0"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@types/cors": "^2.8.19",
|
|
60
|
-
"@types/node": "^20.11.17",
|
|
61
|
-
"typescript": "^5.4.4",
|
|
62
|
-
"zod": "^4.3.0"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@newhomestar/sdk",
|
|
3
|
+
"version": "0.8.18",
|
|
4
|
+
"description": "Type-safe SDK for building Nova pipelines (workers & functions)",
|
|
5
|
+
"homepage": "https://github.com/newhomestar/nova-node-sdk#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/newhomestar/nova-node-sdk/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/newhomestar/nova-node-sdk.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"author": "Christian Gomez",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./next": {
|
|
24
|
+
"import": "./dist/next.js",
|
|
25
|
+
"types": "./dist/next.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./events": {
|
|
28
|
+
"import": "./dist/events.js",
|
|
29
|
+
"types": "./dist/events.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./connections": {
|
|
32
|
+
"import": "./dist/connections.js",
|
|
33
|
+
"types": "./dist/connections.d.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@openfga/sdk": "^0.9.0",
|
|
44
|
+
"@orpc/openapi": "1.7.4",
|
|
45
|
+
"@orpc/server": "1.7.4",
|
|
46
|
+
"@supabase/supabase-js": "^2.39.0",
|
|
47
|
+
"body-parser": "^1.20.2",
|
|
48
|
+
"cors": "^2.8.6",
|
|
49
|
+
"dotenv": "^16.4.3",
|
|
50
|
+
"express": "^4.18.2",
|
|
51
|
+
"express-oauth2-jwt-bearer": "^1.7.4",
|
|
52
|
+
"undici": "^7.24.4",
|
|
53
|
+
"yaml": "^2.7.1"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"zod": ">=4.0.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/cors": "^2.8.19",
|
|
60
|
+
"@types/node": "^20.11.17",
|
|
61
|
+
"typescript": "^5.4.4",
|
|
62
|
+
"zod": "^4.3.0"
|
|
63
|
+
}
|
|
64
|
+
}
|