@newhomestar/sdk 0.8.18 → 0.8.19
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 +0 -18
- package/dist/index.js +6 -2
- package/package.json +64 -64
package/dist/events.js
CHANGED
|
@@ -257,21 +257,9 @@ 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;
|
|
271
260
|
const fullPayload = {
|
|
272
261
|
event_slug: staged.topic,
|
|
273
262
|
source_service: serviceSlug ?? undefined,
|
|
274
|
-
entity_id: entityId,
|
|
275
263
|
attributes: staged.payload,
|
|
276
264
|
metadata: {
|
|
277
265
|
source: xSource,
|
|
@@ -594,15 +582,9 @@ export async function withWebhookEvent(db, opts, handler) {
|
|
|
594
582
|
result = await handler(tx, emit);
|
|
595
583
|
// ── 4. Write outbox rows for staged events ────────────────────────
|
|
596
584
|
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;
|
|
602
585
|
const fullPayload = {
|
|
603
586
|
event_slug: staged.topic,
|
|
604
587
|
source_service: serviceSlug ?? undefined,
|
|
605
|
-
entity_id: entityId,
|
|
606
588
|
attributes: staged.payload,
|
|
607
589
|
metadata: { source: 'webhook' },
|
|
608
590
|
};
|
package/dist/index.js
CHANGED
|
@@ -903,9 +903,13 @@ export function runHttpServer(def, opts = {}) {
|
|
|
903
903
|
message: 'optionsFetcher requires a valid Bearer token',
|
|
904
904
|
});
|
|
905
905
|
}
|
|
906
|
-
// Resolve credentials (same flow as action handlers)
|
|
906
|
+
// Resolve credentials (same flow as action handlers).
|
|
907
|
+
// Extract userId from the request body (forwarded by the proxy)
|
|
908
|
+
// or from the JWT `sub` claim so the auth server resolves OAuth
|
|
909
|
+
// credentials for the *actual* caller — not the "system" default.
|
|
907
910
|
const credCtx = buildCredentialCtx(def.name, authToken);
|
|
908
|
-
const
|
|
911
|
+
const userId = req.body?.userId ?? req.auth?.sub ?? undefined;
|
|
912
|
+
const credentials = await credCtx.resolveCredentials(undefined, userId);
|
|
909
913
|
// Extract and normalize the scope identifiers from the request body.
|
|
910
914
|
// The UI posts `{ config, remoteId, remoteType }`. Both may be null
|
|
911
915
|
// for legacy / unscoped lookups. We keep them typed so handlers
|
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.19",
|
|
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
|
+
}
|