@brickkit/core 0.3.0 → 0.4.0
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 +47 -27
- package/dist/chunks/client.d.ts +1 -0
- package/dist/chunks/client.d.ts.map +1 -1
- package/dist/client.js +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +156 -61
- package/dist/index.js.map +1 -1
- package/package.json +20 -7
package/README.md
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
# @brickkit/core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Services, actions, resources, and databases for the Brick-TS framework. You define typed services with TypeBox schemas, mount them with `brick()`, and get an Elysia HTTP server with OpenAPI output and a typed client.
|
|
4
|
+
|
|
5
|
+
You need Bun 1.2 or later. Bun-only APIs are lazy-loaded, so the package imports cleanly under strict Node ESM too.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun add @brickkit/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Define a service
|
|
12
|
+
|
|
13
|
+
Create a service, register an action on it, and serve it. Each action exposes one route: `POST /api/{service}/{action}` by default.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { brick, defineAction, defineService } from "@brickkit/core";
|
|
17
|
+
|
|
18
|
+
const healthService = defineService("system");
|
|
19
|
+
const ping = defineAction({
|
|
20
|
+
name: "ping",
|
|
21
|
+
execute: async () => ({ status: "ok" }),
|
|
22
|
+
});
|
|
23
|
+
healthService.action(ping);
|
|
24
|
+
|
|
25
|
+
const app = brick({ services: [healthService] });
|
|
26
|
+
app.listen(4000);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Set `method: "GET"` on the action config to serve reads over GET, or `path` to replace the default route. Add `input` and `output` TypeBox schemas to validate at the boundary. Add `authorize` to require a user; without it the action is public. To call an action in process with the same pipeline, use `action.run(input, ctx)` or `service.getAction("ping")`.
|
|
30
|
+
|
|
31
|
+
`brick()` also accepts `prefix`, `title`, and `version`. `generateOpenApiSpec({ services, prefix })` returns the OpenAPI 3.1 document without starting a server.
|
|
32
|
+
|
|
33
|
+
## Exports
|
|
34
|
+
|
|
35
|
+
| Path | What it holds |
|
|
36
|
+
| ----------------------- | --------------------------------------------------------------- |
|
|
37
|
+
| `@brickkit/core` | `brick`, `defineService`, `defineAction`, `defineDatabase`, MCP |
|
|
38
|
+
| `@brickkit/core/client` | `createBrickClient`, the Eden-style typed browser client |
|
|
39
|
+
| `@brickkit/core/pg` | Postgres Drizzle table helpers such as `pgTable` |
|
|
40
|
+
|
|
41
|
+
Databases use Drizzle tables through `defineDatabase({ engine, tables, url })` with `"sqlite"` or `"postgres"` engines. Database setup is documented in `DATABASES.md`.
|
|
6
42
|
|
|
7
43
|
```sh
|
|
8
44
|
bun add @brickkit/core drizzle-orm postgres
|
|
@@ -24,16 +60,11 @@ export const db = defineDatabase({
|
|
|
24
60
|
});
|
|
25
61
|
```
|
|
26
62
|
|
|
27
|
-
Bun-only APIs are lazy-loaded, so the package imports cleanly under
|
|
28
|
-
strict Node ESM too. Source: <https://github.com/Chandraprakash-Darji/brick>.
|
|
29
|
-
|
|
30
63
|
## Typed client
|
|
31
64
|
|
|
32
|
-
`@brickkit/core/client` (also re-exported from the package root) offers an
|
|
33
|
-
Eden-style HTTP client inferred from your contract type — no OpenAPI codegen:
|
|
65
|
+
`@brickkit/core/client` (also re-exported from the package root) offers an Eden-style HTTP client inferred from your contract type — no OpenAPI codegen:
|
|
34
66
|
|
|
35
|
-
With the Brick Vite plugin configured for your default-exported app, Vite
|
|
36
|
-
creates `_brick/contract.ts` automatically:
|
|
67
|
+
With the Brick Vite plugin configured for your default-exported app, Vite creates `_brick/contract.ts` automatically:
|
|
37
68
|
|
|
38
69
|
```ts
|
|
39
70
|
import { createBrickClient } from "@brickkit/core/client";
|
|
@@ -43,11 +74,7 @@ const api = createBrickClient({ baseUrl: "http://localhost:4000", contract });
|
|
|
43
74
|
const pages = await api.page.list({ limit: 10 });
|
|
44
75
|
```
|
|
45
76
|
|
|
46
|
-
The generated contract contains browser-safe route metadata and inferred
|
|
47
|
-
input/output/error types. It honors custom action paths and methods, encodes
|
|
48
|
-
path parameters, and removes them from the remaining payload. No backend
|
|
49
|
-
handlers are bundled. See the CLI README and
|
|
50
|
-
`www/content/docs/(brick)/typed-client.mdx` for Vite setup and error handling.
|
|
77
|
+
The generated contract contains browser-safe route metadata and inferred input/output/error types. It honors custom action paths and methods, encodes path parameters, and removes them from the remaining payload. No backend handlers are bundled. See the CLI README and `www/content/docs/(brick)/typed-client.mdx` for Vite setup and error handling.
|
|
51
78
|
|
|
52
79
|
## MCP tools
|
|
53
80
|
|
|
@@ -84,15 +111,8 @@ const handleMcp = createMcpHandler({
|
|
|
84
111
|
// return handleMcp(request, { user: { id: verifiedSubject } });
|
|
85
112
|
```
|
|
86
113
|
|
|
87
|
-
Tools use action validation, authorization, and service context. They are stored
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
The registry accepts `services` and/or an explicit `tools` array, rejects duplicate
|
|
94
|
-
names, and reads annotations directly from definitions. The handler is a
|
|
95
|
-
stateless POST JSON-RPC helper for initialize, ping, tools/list, and tools/call;
|
|
96
|
-
notifications receive an empty 202 response. Authentication and mounting remain
|
|
97
|
-
in your app. Its default protocol version is `2025-06-18`, following the
|
|
98
|
-
[MCP tools specification](https://modelcontextprotocol.io/specification/2025-06-18/server/tools).
|
|
114
|
+
Tools use action validation, authorization, and service context. They are stored separately from HTTP actions and stay out of routes and OpenAPI by default, including when their service is passed to `brick()`. Add `http: true` to a tool definition, or register it with `crm.action(whoami)`, to expose it over HTTP as well.
|
|
115
|
+
|
|
116
|
+
The registry accepts `services` and/or an explicit `tools` array, rejects duplicate names, and reads annotations directly from definitions. The handler is a stateless POST JSON-RPC helper for initialize, ping, tools/list, and tools/call; notifications receive an empty 202 response. Authentication and mounting remain in your app. Its default protocol version is `2025-06-18`, following the [MCP tools specification](https://modelcontextprotocol.io/specification/2025-06-18/server/tools).
|
|
117
|
+
|
|
118
|
+
Source: <https://github.com/Chandraprakash-Darji/brick>.
|
package/dist/chunks/client.d.ts
CHANGED
|
@@ -738,6 +738,7 @@ interface ProxyOptions {
|
|
|
738
738
|
* including plugin routes and consumer overrides. Without runtime metadata,
|
|
739
739
|
* callers use `POST /api/<service>/<action>` with dotted action names.
|
|
740
740
|
* GET/DELETE input is serialized as a query string; other methods send JSON.
|
|
741
|
+
|
|
741
742
|
*/
|
|
742
743
|
interface BrickClientOptions {
|
|
743
744
|
/** Server origin, e.g. `"http://localhost:4000"`. No trailing slash required. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":["BunSQLiteDatabase","_$__plugin0.ResourcePluginAPI","BunSQLiteDatabase"],"sources":["../../src/plugin.ts","../../src/db/sqlite.ts","../../src/secrets.ts","../../src/db/postgres.ts","../../src/db/define.ts","../../src/types.ts","../../src/client.ts"],"mappings":";;;;;;;;KAcY;KACA;KACA,aAAa,UAAU,mBAAmB,4BAElD,SAAS;EAAyB;EAAe,QAAQ;;KAExD,UAAU,KACb,UAAU,cAAc,SAAS,KAAK,YAAY,KAAK;UAExC,sBACf,UAAU,gBAAgB;EAE1B,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT,SAAS;EACT;IAAO;IAAiB,SAAS;;EACjC,KAAK;;UAGU,qBACf,UAAU,gBAAgB,eAC1B,UAAU,mBAAmB;EAE7B,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,0BAA0B,GAAG,GAAG,GAAG;IACzC;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,6BAA6B,GAAG,GAAG,GAAG;IAC5C;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,SAAS;IACP;IACA;IACA,QAAQ;IACR,QAAQ;IACR,UAAU,SAAS,sBAAsB,iBAAiB;IAC1D;IACA;IACA;;;UAIa,qBACf,UAAU,oBAAoB;EAE9B,SAAS;EACT,QAAQ,qBAAqB,UAAU;;UAExB,sBACf,UAAU,oBAAoB,mBAC9B,UAAU,0BAA0B,cAAc,UAAU;EAE5D,SAAS;EACT,UAAU;EACV,QAAQ,qBAAqB,UAAU;;;UAIxB;WACN;WACA;WACA;WACA;;KAEC,kBAAkB,GAAG,GAAG,GAAG,eAAe;WAC3C,aAAa,UAAU;KAE7B;WACU,OAAO;WACP,SAAS;WACT,UAAU;YAErB,UAAU,+BAA+B,KACvC;cAIA;UACW,cAAc,UAAU,mBAAmB;YAChD;WACD;WACA,SAAS;WACT,QAAQ,SAAS,qBAAqB,OAAO;;UAEvC,eACf,UAAU,mBACV,UAAU,yBACV;YAEU;WACD;WACA,SAAS;WACT,QAAQ,SAAS,sBAAsB,GAAG,OAAO;;iBAG5C,oBACd,UAAU,oBAAoB,mBAC9B,aAEA,YAAY,KAAK,cAAc,GAAG,WAAW;EAC3C,QACE,SAAS,qBAAqB,OAC3B,KAAK,UAAU;IAErB,cAAc,GAAG;iBAQJ,qBACd,UAAU,oBAAoB,mBAC9B,UAAU,0BAA0B,cAAc,UAAU,UAC5D,2BAEA,YAAY,KAAK,eAAe,GAAG,GAAG,WAAW;EAC/C,QACE,SAAS,sBAAsB,GAAG,OAC/B,KAAK,UAAU;IAErB,eAAe,GAAG,GAAG;iBA+GR,qBACd,QAAQ,4BACR;;UADQ;;;;;iBAiBM,mBACd,SAAS,mBACT;;;;;;;EAW6B,UAAA,SAAA,KAAK,kCAA6B;;;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":["BunSQLiteDatabase","_$__plugin0.ResourcePluginAPI","BunSQLiteDatabase"],"sources":["../../src/plugin.ts","../../src/db/sqlite.ts","../../src/secrets.ts","../../src/db/postgres.ts","../../src/db/define.ts","../../src/types.ts","../../src/client.ts"],"mappings":";;;;;;;;KAcY;KACA;KACA,aAAa,UAAU,mBAAmB,4BAElD,SAAS;EAAyB;EAAe,QAAQ;;KAExD,UAAU,KACb,UAAU,cAAc,SAAS,KAAK,YAAY,KAAK;UAExC,sBACf,UAAU,gBAAgB;EAE1B,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT,SAAS;EACT;IAAO;IAAiB,SAAS;;EACjC,KAAK;;UAGU,qBACf,UAAU,gBAAgB,eAC1B,UAAU,mBAAmB;EAE7B,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,0BAA0B,GAAG,GAAG,GAAG;IACzC;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,6BAA6B,GAAG,GAAG,GAAG;IAC5C;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,SAAS;IACP;IACA;IACA,QAAQ;IACR,QAAQ;IACR,UAAU,SAAS,sBAAsB,iBAAiB;IAC1D;IACA;IACA;;;UAIa,qBACf,UAAU,oBAAoB;EAE9B,SAAS;EACT,QAAQ,qBAAqB,UAAU;;UAExB,sBACf,UAAU,oBAAoB,mBAC9B,UAAU,0BAA0B,cAAc,UAAU;EAE5D,SAAS;EACT,UAAU;EACV,QAAQ,qBAAqB,UAAU;;;UAIxB;WACN;WACA;WACA;WACA;;KAEC,kBAAkB,GAAG,GAAG,GAAG,eAAe;WAC3C,aAAa,UAAU;KAE7B;WACU,OAAO;WACP,SAAS;WACT,UAAU;YAErB,UAAU,+BAA+B,KACvC;cAIA;UACW,cAAc,UAAU,mBAAmB;YAChD;WACD;WACA,SAAS;WACT,QAAQ,SAAS,qBAAqB,OAAO;;UAEvC,eACf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B;WACA;WACA;WACA;WACS;EAGhB,YAAA,iBACA;IAAQ;IAAiB;IAAa;IAAgB;;;;;;;cAe7C,yBAAyB;WAC3B;WACA;WACA;WACA;EAGP,YAAA,iBACA;IAAQ;IAAgB;IAAa;;;iBAUzB,sBACd,eACC,OAAO;iBAIM,mBAAmB,eAAe,OAAO;;KAK7C,iBAAiB,KAC3B,UAAU,wBAAwB,eAC9B,IACA;EACI;IAAU,cAAc,UAAU;;IAEpC,OAAO,KACP;EACI,QAAQ;IAAU,cAAc;IAAG;;IAErC,IACA;EAAY,IAAI,cAAc,GAAG;IAC/B,IACA,YAAW;EAAU,cAAc;EAAG;aACpC;;KAIF,kBAAkB,KAC5B,UAAU,6BAA6B,UACnC,IACA,eAAc,gBAAgB,cAAc,MAC1C,IACA;EAAY,QAAQ,cAAc,cAAc;IAC9C;;KAIE,sBAAsB,KAChC,UAAU,kCAAkC,KACxC,cAAc,aACd;EACI;IAAU,eAAe;;IAE3B,UAAU,eAAe,yBACvB,cAAc;;;;;;;;;;;;;KAgBZ,mBAAmB,KAAK;EAClC,MACI,sBAAsB;;;;;;KAchB,kBAAkB,uBACV,iBAAiB,MAE7B,QAAQ,iBAAiB,IACzB,UAAU,qBACP,QAAQ,kBAAkB,OAE7B,OAAO,iBAAiB,IACxB,UAAU,qBACP,QAAQ,kBAAkB;;KAGzB,YAAY,KAAK,UACzB,mCACA,6BACA,kBAAkB,KAClB,eAAc,uBACZ,kBAAkB,KAClB,sBACK,WAAW,IAAI,YAAY,EAAE,SAChC;;;;;;iBAiSQ,kBAAkB,aAAa,qBAC7C,SAAS;EAAuB,UAAU;IACzC,YAAY;iBACC,kBAAkB,aAAa,qBAC7C,SAAS,qBACR,YAAY"}
|
package/dist/client.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { BrickServerError, BrickTransportError, createBrickClient, isBrickServerError, isBrickTransportError };
|
|
1
|
+
export { t as BrickServerError, n as BrickTransportError, r as createBrickClient, i as isBrickServerError, a as isBrickTransportError } from "./chunks/client.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ interface CompiledApplication {
|
|
|
149
149
|
readonly ir: BrickIR;
|
|
150
150
|
readonly routes: readonly CompiledRoute[];
|
|
151
151
|
}
|
|
152
|
-
/** Startup compiler: analyzes once,
|
|
152
|
+
/** Startup compiler: analyzes once, then binds live callbacks. */
|
|
153
153
|
export declare function compileBrickApplication(options: {
|
|
154
154
|
services: Service<any, any>[];
|
|
155
155
|
prefix?: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__0.ValidationErrorItem","_$__endpoints0.BrickApp","TSchema","TSchema","TSchema"],"sources":["../src/compiler/ir.ts","../src/endpoints.ts","../src/compiler/runtime.ts","../src/compiler.ts","../src/request-logger.ts","../src/docs.ts","../src/action-handler.ts","../src/server.ts","../src/app-entry.ts","../src/compiler/emit.ts","../src/db/index.ts","../src/service.ts","../src/access.ts","../src/action.ts","../src/resource.ts","../src/rpc.ts","../src/registry.ts","../src/typebox.ts","../src/openapi.ts","../src/tool.ts","../src/mcp.ts"],"mappings":";;;;;;KAGY;UACK;WACN,QAAQ;WACR;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;aACE;aACA;;;WAGF;WACA;;UAEM;WACN;WACA;WACA;WACA;WACA,iBAAiB;WACjB;IACP;IACA;IACA;;WAEO;;;;KC5BC;;UAGK;EACf,UAAU;EACV,UAAU;EACV,WAAW;EACX,WAAW;;;UAII;EACf,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT,SAAS;;EAET;IAAO;IAAiB,SAAS;;;EAEjC;EACA,QAAQ;EACR;EACA;;UAGe;EACf,QAAQ;;EAER;EACA,UAAU,KAAK,8BAA8B;;EAE7C,UAAU;;EAEV,WAAW;EACX;EACA;EACA;;;wBAIc,kBACd,SAAS,wCACT,UAAU;;wBAiBI,sBACd,KAAK,oBACL,UAAU,uBACR,mBAAmB;;wBA8DP,cAAc;;wBAUd,cAAc,MAAM,uBAAuB;;KAuB/C,WAAW;;WAEZ;aACE,iBAAiB;aACjB,mBAAmB;aACnB;;;EAGX,SAAS,KAAK;;EAEd,iBAAiB;;;;KCxKP,mBAAmB,2BAA2B;KAC9C,kBACV,SAAS,mBACT,gBAAgB,oBACb;;iBAcI,WAAW,YAAY,aAAa;iBAiCpC,WAAW,gBAAgB;iBAO3B,SACP,OAAO,YAAY,oCACnB,gBACA,gBACA;iBAeO,SAAS,UAAU;;;;;;;;;;UAAnBA;;;;;;qBAaI,iBAAe;;;;;;;;EAQN,aAAA;EAEL,OAAA;;;;KC1FZ,qBAAqB,UAAU,wBAAwB;;wBAWtC,qBACpB,YAAY;EAAU;IACtB,IAAI,SACJ,MAAM,oBAAiB,QAAjBC;UAoBS;WACN,IAAI;WACJ,SAAS;;UAEH;WACN,IAAI;WACJ,iBAAiB;;;wBAsBZ,wBAAwB;EACtC,UAAU;EACV;EACA;IACE;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__0.ValidationErrorItem","_$__endpoints0.BrickApp","TSchema","TSchema","TSchema"],"sources":["../src/compiler/ir.ts","../src/endpoints.ts","../src/compiler/runtime.ts","../src/compiler.ts","../src/request-logger.ts","../src/docs.ts","../src/action-handler.ts","../src/server.ts","../src/app-entry.ts","../src/compiler/emit.ts","../src/db/index.ts","../src/service.ts","../src/access.ts","../src/action.ts","../src/resource.ts","../src/rpc.ts","../src/registry.ts","../src/typebox.ts","../src/openapi.ts","../src/tool.ts","../src/mcp.ts"],"mappings":";;;;;;KAGY;UACK;WACN,QAAQ;WACR;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;aACE;aACA;;;WAGF;WACA;;UAEM;WACN;WACA;WACA;WACA;WACA,iBAAiB;WACjB;IACP;IACA;IACA;;WAEO;;;;KC5BC;;UAGK;EACf,UAAU;EACV,UAAU;EACV,WAAW;EACX,WAAW;;;UAII;EACf,Q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AAsBA,mCACtB,gBAAgB,eAAe,yBAAyB,eAEtD,wBAEF,iBAAiB,gBAAgB,eAEjC,QAAQ,wBACN,cACA,eACA,SACA,YAED,KAAK,cAAc,eAAe,SAAS;wBAE9B,WACd,qBAAqBA,mCACrB,sBAAsBA,mCACtB,gBAAgB,eAAe,yBAAyB,eAEtD,wBAEF,iBAAiB,gBAAgB,eAEjC,QAAQ,2BACN,cACA,eACA,SACA,YAED,KAAK,cAAc,eAAe,SAAS;wBAW9B,OAAO,iBAAiB,SAAS;;;UCnDhC;EACf;EACA;EACA;EACA;EACA,aAAa;;UAGE;EACf,oBAAoB,KAAK;EACzB,iBAAiB;;UAGF;EACf,aAAa;EACb,SACE,cACA,OAAO,yBACP,MAAM,QAAQ,iBACb;;qBAGQ,yBAAyB;EACxB,YAAA;;;wBAOE,kBAAkB,SAAS,qBAAqB;UAsC/C;EACf,UAAU;EACV;IAAc;IAAc;IAAiB;;;EAE7C;;;wBAcc,iBAAiB,SAAS,qBAKtC,SAAS,SACT,MAAM,QAAQ,mBACb,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as isBrickTransportError, i as isBrickServerError, n as BrickTransportError, o as ActionExecutionError, r as createBrickClient, s as ValidationError, t as BrickServerError } from "./chunks/client.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { Type, Type as t } from "@sinclair/typebox";
|
|
4
4
|
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
5
5
|
import { Elysia } from "elysia";
|
|
6
6
|
import { blob, foreignKey, index, integer, primaryKey, real, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
@@ -874,58 +874,103 @@ function createActionHandler(service, action, routePath, method) {
|
|
|
874
874
|
return (elysiaCtx) => executeCompiledRoute(plan, elysiaCtx);
|
|
875
875
|
}
|
|
876
876
|
//#endregion
|
|
877
|
-
//#region src/compiler/
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
const input = ["let input;"];
|
|
883
|
-
if (route.input) {
|
|
884
|
-
input.push("let coercedQuery = query;");
|
|
885
|
-
if (route.coercions.length) {
|
|
886
|
-
input.push("if (query) {", "coercedQuery = { ...query };");
|
|
887
|
-
for (const [index, coercion] of route.coercions.entries()) {
|
|
888
|
-
const key = JSON.stringify(coercion.key);
|
|
889
|
-
input.push(`const v${index} = query[${key}];`);
|
|
890
|
-
if (coercion.type === "number") input.push(`if (v${index} !== undefined) { const n${index} = Number(v${index}); if (!Number.isNaN(n${index})) coercedQuery[${key}] = n${index}; }`);
|
|
891
|
-
else input.push(`if (v${index} === "true" || v${index} === "1") coercedQuery[${key}] = true; else if (v${index} === "false" || v${index} === "0") coercedQuery[${key}] = false;`);
|
|
892
|
-
}
|
|
893
|
-
input.push("}");
|
|
894
|
-
}
|
|
895
|
-
input.push(`input = mergeInput(${route.inputPrecedence.map((source) => source === "query" ? "coercedQuery" : source).join(", ")});`);
|
|
896
|
-
if (route.inputSchema?.type === "object") input.push("input ??= {};");
|
|
877
|
+
//#region src/compiler/handler.ts
|
|
878
|
+
function coerceQueryValue(value, type) {
|
|
879
|
+
if (type === "number" && value !== void 0) {
|
|
880
|
+
const number = Number(value);
|
|
881
|
+
return Number.isNaN(number) ? value : number;
|
|
897
882
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
if (
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
883
|
+
if (type === "boolean") {
|
|
884
|
+
if (value === "true" || value === "1") return true;
|
|
885
|
+
if (value === "false" || value === "0") return false;
|
|
886
|
+
}
|
|
887
|
+
return value;
|
|
888
|
+
}
|
|
889
|
+
/** Bind route metadata with ordinary closures; emitted factories remain build-only. */
|
|
890
|
+
function createHandlerFactory(route) {
|
|
891
|
+
return (binding, runtime) => {
|
|
892
|
+
const { execute, contextHook, authorize, inputChecker, outputChecker, errorBuilder, logger, cachedDb, service } = binding;
|
|
893
|
+
const readLike = route.inputPrecedence[0] === "query";
|
|
894
|
+
const objectInput = binding.action.config.input?.type === "object";
|
|
895
|
+
const readInput = route.input ? ({ params, body, query }) => {
|
|
896
|
+
let coercedQuery = query;
|
|
897
|
+
if (query && route.coercions.length) {
|
|
898
|
+
coercedQuery = { ...query };
|
|
899
|
+
for (const { key, type } of route.coercions) if (query[key] !== void 0) coercedQuery[key] = coerceQueryValue(query[key], type);
|
|
900
|
+
}
|
|
901
|
+
let input = readLike ? runtime.mergeInput(coercedQuery, params, body) : runtime.mergeInput(params, body, coercedQuery);
|
|
902
|
+
if (objectInput) input ??= {};
|
|
903
|
+
return input;
|
|
904
|
+
} : () => void 0;
|
|
905
|
+
const validateInput = (input) => {
|
|
906
|
+
if (inputChecker) {
|
|
907
|
+
runtime.checkDepth(input, route.action);
|
|
908
|
+
runtime.validate(inputChecker, input, route.action, "input");
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
const validateOutput = (result) => {
|
|
912
|
+
if (route.output && outputChecker) runtime.validate(outputChecker, result, route.action, "output");
|
|
913
|
+
return result;
|
|
914
|
+
};
|
|
915
|
+
const createContext = ({ headers, request, set }) => {
|
|
916
|
+
const seq = runtime.nextSequence();
|
|
917
|
+
const traceId = headers?.["x-trace-id"] || "tr_" + seq;
|
|
918
|
+
const requestId = headers?.["x-request-id"] || "req_" + seq;
|
|
919
|
+
if (set?.headers) {
|
|
920
|
+
set.headers["x-trace-id"] = traceId;
|
|
921
|
+
set.headers["x-request-id"] = requestId;
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
request: request instanceof Request ? request : runtime.defaultRequest,
|
|
925
|
+
traceId,
|
|
926
|
+
requestId,
|
|
927
|
+
db: cachedDb ?? service.getDb(),
|
|
928
|
+
logger,
|
|
929
|
+
services: runtime.emptyServices,
|
|
930
|
+
metadata: { headers },
|
|
931
|
+
_resolved: true
|
|
932
|
+
};
|
|
933
|
+
};
|
|
934
|
+
if (contextHook || authorize) return async function brickAction(context) {
|
|
935
|
+
const input = readInput(context);
|
|
936
|
+
const ctx = createContext(context);
|
|
937
|
+
try {
|
|
938
|
+
if (contextHook) {
|
|
939
|
+
const extra = await contextHook(ctx);
|
|
940
|
+
if (extra) Object.assign(ctx, extra);
|
|
941
|
+
}
|
|
942
|
+
validateInput(input);
|
|
943
|
+
if (authorize && !await authorize({
|
|
944
|
+
ctx,
|
|
945
|
+
input,
|
|
946
|
+
user: ctx.user
|
|
947
|
+
})) runtime.deny(route.action);
|
|
948
|
+
return validateOutput(await execute({
|
|
949
|
+
input,
|
|
950
|
+
ctx,
|
|
951
|
+
error: errorBuilder
|
|
952
|
+
}));
|
|
953
|
+
} catch (err) {
|
|
954
|
+
return runtime.mapError(err, context.set);
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
return function brickAction(context) {
|
|
958
|
+
const input = readInput(context);
|
|
959
|
+
const ctx = createContext(context);
|
|
960
|
+
try {
|
|
961
|
+
validateInput(input);
|
|
962
|
+
const result = execute({
|
|
963
|
+
input,
|
|
964
|
+
ctx,
|
|
965
|
+
error: errorBuilder
|
|
966
|
+
});
|
|
967
|
+
if (runtime.isThenable(result)) return Promise.resolve(result).then(validateOutput).catch((err) => runtime.mapError(err, context.set));
|
|
968
|
+
return validateOutput(result);
|
|
969
|
+
} catch (err) {
|
|
970
|
+
return runtime.mapError(err, context.set);
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
};
|
|
929
974
|
}
|
|
930
975
|
//#endregion
|
|
931
976
|
//#region src/app-entry.ts
|
|
@@ -973,12 +1018,12 @@ function bindAnalyzed(ir, bindings, factories) {
|
|
|
973
1018
|
routes: Object.freeze(routes)
|
|
974
1019
|
});
|
|
975
1020
|
}
|
|
976
|
-
/** Startup compiler: analyzes once,
|
|
1021
|
+
/** Startup compiler: analyzes once, then binds live callbacks. */
|
|
977
1022
|
function compileBrickApplication(options) {
|
|
978
1023
|
const bind = buildBindings.get(applicationKey(options.services, options.prefix));
|
|
979
1024
|
if (bind && options.mode !== "generic") return bind(options.services);
|
|
980
1025
|
const { ir, bindings } = analyzeApplication(options.services, options.prefix);
|
|
981
|
-
const factories = options.mode === "generic" ? ir.routes.map(() => (plan) => (context) => executeCompiledRoute(plan, context)) : ir.routes.map(
|
|
1026
|
+
const factories = options.mode === "generic" ? ir.routes.map(() => (plan) => (context) => executeCompiledRoute(plan, context)) : ir.routes.map(createHandlerFactory);
|
|
982
1027
|
if (options.mode !== "generic") for (const service of options.services) service.prepareContributions();
|
|
983
1028
|
return bindAnalyzed(ir, bindings, factories);
|
|
984
1029
|
}
|
|
@@ -1705,6 +1750,60 @@ function cachedJsonRoute(build, revision) {
|
|
|
1705
1750
|
};
|
|
1706
1751
|
}
|
|
1707
1752
|
//#endregion
|
|
1753
|
+
//#region src/compiler/emit.ts
|
|
1754
|
+
/** Emits framework code only. User callbacks remain closures bound separately. */
|
|
1755
|
+
function emitHandlerFactory(route) {
|
|
1756
|
+
const name = JSON.stringify(route.action);
|
|
1757
|
+
const fields = route.input ? "params, body, query, headers, request, set" : "headers, request, set";
|
|
1758
|
+
const input = ["let input;"];
|
|
1759
|
+
if (route.input) {
|
|
1760
|
+
input.push("let coercedQuery = query;");
|
|
1761
|
+
if (route.coercions.length) {
|
|
1762
|
+
input.push("if (query) {", "coercedQuery = { ...query };");
|
|
1763
|
+
for (const [index, coercion] of route.coercions.entries()) {
|
|
1764
|
+
const key = JSON.stringify(coercion.key);
|
|
1765
|
+
input.push(`const v${index} = query[${key}];`);
|
|
1766
|
+
if (coercion.type === "number") input.push(`if (v${index} !== undefined) { const n${index} = Number(v${index}); if (!Number.isNaN(n${index})) coercedQuery[${key}] = n${index}; }`);
|
|
1767
|
+
else input.push(`if (v${index} === "true" || v${index} === "1") coercedQuery[${key}] = true; else if (v${index} === "false" || v${index} === "0") coercedQuery[${key}] = false;`);
|
|
1768
|
+
}
|
|
1769
|
+
input.push("}");
|
|
1770
|
+
}
|
|
1771
|
+
input.push(`input = mergeInput(${route.inputPrecedence.map((source) => source === "query" ? "coercedQuery" : source).join(", ")});`);
|
|
1772
|
+
if (route.inputSchema?.type === "object") input.push("input ??= {};");
|
|
1773
|
+
}
|
|
1774
|
+
const asyncStages = route.context || route.authorize;
|
|
1775
|
+
const context = route.context ? "const extra = await contextHook(ctx); if (extra) Object.assign(ctx, extra);" : "";
|
|
1776
|
+
const validation = route.input ? `checkDepth(input, ${name}); validate(inputChecker, input, ${name}, "input");` : "";
|
|
1777
|
+
const authorization = route.authorize ? `if (!await authorize({ ctx, input, user: ctx.user })) deny(${name});` : "";
|
|
1778
|
+
const output = route.output ? `validate(outputChecker, result, ${name}, "output");` : "";
|
|
1779
|
+
const execute = asyncStages ? `const result = await execute({ input, ctx, error: errorBuilder });\n${output}\nreturn result;` : `const result = execute({ input, ctx, error: errorBuilder });
|
|
1780
|
+
if (isThenable(result)) return Promise.resolve(result).then(value => {
|
|
1781
|
+
${route.output ? `validate(outputChecker, value, ${name}, "output");` : ""}
|
|
1782
|
+
return value;
|
|
1783
|
+
}).catch(err => mapError(err, set));
|
|
1784
|
+
${output}
|
|
1785
|
+
return result;`;
|
|
1786
|
+
return `function bindAction(binding, runtime) {
|
|
1787
|
+
const { execute, contextHook, authorize, inputChecker, outputChecker, errorBuilder, logger, cachedDb, service } = binding;
|
|
1788
|
+
const { nextSequence, defaultRequest, emptyServices, mergeInput, checkDepth, validate, deny, mapError, isThenable } = runtime;
|
|
1789
|
+
return ${asyncStages ? "async " : ""}function brickAction({ ${fields} }) {
|
|
1790
|
+
const seq = nextSequence();
|
|
1791
|
+
const traceId = (headers && headers["x-trace-id"]) || "tr_" + seq;
|
|
1792
|
+
const requestId = (headers && headers["x-request-id"]) || "req_" + seq;
|
|
1793
|
+
if (set?.headers) { set.headers["x-trace-id"] = traceId; set.headers["x-request-id"] = requestId; }
|
|
1794
|
+
${input.join("\n")}
|
|
1795
|
+
const ctx = { request: request instanceof Request ? request : defaultRequest, traceId, requestId,
|
|
1796
|
+
db: cachedDb ?? service.getDb(), logger, services: emptyServices, metadata: { headers }, _resolved: true };
|
|
1797
|
+
try {
|
|
1798
|
+
${context}
|
|
1799
|
+
${validation}
|
|
1800
|
+
${authorization}
|
|
1801
|
+
${execute}
|
|
1802
|
+
} catch (err) { return mapError(err, set); }
|
|
1803
|
+
};
|
|
1804
|
+
}`;
|
|
1805
|
+
}
|
|
1806
|
+
//#endregion
|
|
1708
1807
|
//#region src/tool.ts
|
|
1709
1808
|
function defineTool(config) {
|
|
1710
1809
|
if (config.input && config.input.type !== "object") throw new Error(`Tool '${config.name}' input must be an object schema`);
|
|
@@ -1716,12 +1815,8 @@ function isTool(value) {
|
|
|
1716
1815
|
return typeof value === "function" && value.kind === "tool";
|
|
1717
1816
|
}
|
|
1718
1817
|
//#endregion
|
|
1719
|
-
//#region src/db/load.ts
|
|
1720
|
-
function loadDriver(id) {
|
|
1721
|
-
return (globalThis.require ?? createRequire(import.meta.url))(id);
|
|
1722
|
-
}
|
|
1723
|
-
//#endregion
|
|
1724
1818
|
//#region src/db/sqlite.ts
|
|
1819
|
+
const requireSQLite = createRequire(import.meta.url);
|
|
1725
1820
|
/**
|
|
1726
1821
|
* Creates a zero-config SQLite database using Bun's native `bun:sqlite` engine
|
|
1727
1822
|
* and Drizzle ORM. Defaults to an ultra-fast in-memory database (`:memory:`).
|
|
@@ -1734,7 +1829,7 @@ function createSQLiteDatabase(config = {}) {
|
|
|
1734
1829
|
let Database;
|
|
1735
1830
|
let drizzle;
|
|
1736
1831
|
try {
|
|
1737
|
-
({Database} =
|
|
1832
|
+
({Database} = requireSQLite("bun:sqlite"));
|
|
1738
1833
|
({drizzle} = __require("drizzle-orm/bun-sqlite"));
|
|
1739
1834
|
} catch (err) {
|
|
1740
1835
|
throw new Error(`[Brick-TS DB] SQLite engine requires the Bun runtime ('bun:sqlite' is unavailable here). Original error: ${err?.message ?? err}`);
|
|
@@ -2471,6 +2566,6 @@ function createMcpHandler(options) {
|
|
|
2471
2566
|
};
|
|
2472
2567
|
}
|
|
2473
2568
|
//#endregion
|
|
2474
|
-
export { ACTION_ACCESS_KEY, ActionExecutionError, BrickServerError, BrickTransportError, SecretRef, ServiceImpl, ServiceRegistry, Table, Type,
|
|
2569
|
+
export { ACTION_ACCESS_KEY, ActionExecutionError, BrickServerError, BrickTransportError, SecretRef, ServiceImpl, ServiceRegistry, Table, Type, UnknownToolError, ValidationError, and, asc, attachDatabase, bindCompiledApplication, blob, brick, buildErrorHelpers, buildFtsMatchQuery, compileBrickApplication, compileRoutePlan, compilerRuntime, createActionHandler, createBrickClient, createDatabase, createEndpointHandler, createMcpHandler, createMcpRegistry, createPostgresDatabase, createSQLiteDatabase, createServiceProxy, defineAction, defineDatabase, defineResource, defineResourcePlugin, defineService, defineServicePlugin, defineTool, desc, emitHandlerFactory, endpointPaths, ensureResourceIndexes, ensureSQLiteFts, envSource, eq, executeCompiledRoute, foreignKey, generateOpenApiSpec, generateSQLiteIndexDdl, generateSQLiteTableDdl, getActionAccess, getCompiledCheck, getGlobalRegistry, getPluginActionRoute, getPluginEndpoints, getTableColumns, getTableName, gt, gte, ilike, inArray, index, integer, is, isBrickApp, isBrickServerError, isBrickTransportError, isDatabaseHandle, isNotNull, isNull, isTool, like, listSecrets, loadCompiledBrickApp, lt, lte, ne, not, notInArray, or, overrideSecret, overrideSecrets, primaryKey, real, referencePlugin, registerReferenceRoute, relations, requestLoggingPlugin, requireBrickApp, resetGlobalRegistry, resetSecrets, resolveEndpointDb, resolveSecrets, scalarDocsHTML, secret, setActionAccess, sql, sqliteTable, swaggerDocsHTML, syncSchema, t, text, toOpenApiPath, uniqueIndex, validateWithSchema };
|
|
2475
2570
|
|
|
2476
2571
|
//# sourceMappingURL=index.js.map
|