@nifrajs/core 1.13.0 → 2.0.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 +10 -1
- package/dist/assurance.d.ts +11 -2
- package/dist/assurance.d.ts.map +1 -1
- package/dist/assurance.js +20 -0
- package/dist/assurance.js.map +1 -1
- package/dist/effect-ledger.d.ts +9 -0
- package/dist/effect-ledger.d.ts.map +1 -0
- package/dist/effect-ledger.js +8 -0
- package/dist/effect-ledger.js.map +1 -0
- package/dist/idempotency-plugin.d.ts +8 -0
- package/dist/idempotency-plugin.d.ts.map +1 -0
- package/dist/idempotency-plugin.js +8 -0
- package/dist/idempotency-plugin.js.map +1 -0
- package/dist/index.d.ts +6 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -31
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +56 -0
- package/dist/mcp.js.map +1 -0
- package/dist/node-direct.d.ts +5 -0
- package/dist/node-direct.d.ts.map +1 -0
- package/dist/node-direct.js +27 -0
- package/dist/node-direct.js.map +1 -0
- package/dist/reflection.d.ts +5 -0
- package/dist/reflection.d.ts.map +1 -1
- package/dist/reflection.js +2 -0
- package/dist/reflection.js.map +1 -1
- package/dist/server/client-ip.d.ts +35 -0
- package/dist/server/client-ip.d.ts.map +1 -0
- package/dist/server/client-ip.js +42 -0
- package/dist/server/client-ip.js.map +1 -0
- package/dist/server/context.d.ts +47 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/contract.d.ts +14 -4
- package/dist/server/contract.d.ts.map +1 -1
- package/dist/server/contract.js +8 -2
- package/dist/server/contract.js.map +1 -1
- package/dist/server/http.d.ts +14 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +45 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server/idempotency-lane.d.ts +44 -0
- package/dist/server/idempotency-lane.d.ts.map +1 -0
- package/dist/server/idempotency-lane.js +181 -0
- package/dist/server/idempotency-lane.js.map +1 -0
- package/dist/server/install.d.ts +21 -0
- package/dist/server/install.d.ts.map +1 -0
- package/dist/server/install.js +21 -0
- package/dist/server/install.js.map +1 -0
- package/dist/server/ledger-lane.d.ts +53 -0
- package/dist/server/ledger-lane.d.ts.map +1 -0
- package/dist/server/ledger-lane.js +82 -0
- package/dist/server/ledger-lane.js.map +1 -0
- package/dist/server/mcp-hook.d.ts +28 -0
- package/dist/server/mcp-hook.d.ts.map +1 -0
- package/dist/server/mcp-hook.js +2 -0
- package/dist/server/mcp-hook.js.map +1 -0
- package/dist/server/node-outcome-hook.d.ts +9 -0
- package/dist/server/node-outcome-hook.d.ts.map +1 -0
- package/dist/server/node-outcome-hook.js +2 -0
- package/dist/server/node-outcome-hook.js.map +1 -0
- package/dist/server/node-outcome.d.ts +37 -0
- package/dist/server/node-outcome.d.ts.map +1 -0
- package/dist/server/node-outcome.js +75 -0
- package/dist/server/node-outcome.js.map +1 -0
- package/dist/server/plugin.d.ts +78 -0
- package/dist/server/plugin.d.ts.map +1 -0
- package/dist/server/plugin.js +57 -0
- package/dist/server/plugin.js.map +1 -0
- package/dist/server/query.d.ts +18 -0
- package/dist/server/query.d.ts.map +1 -0
- package/dist/server/query.js +102 -0
- package/dist/server/query.js.map +1 -0
- package/dist/server/registry.d.ts +31 -6
- package/dist/server/registry.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +51 -0
- package/dist/server/request-context.d.ts.map +1 -0
- package/dist/server/request-context.js +184 -0
- package/dist/server/request-context.js.map +1 -0
- package/dist/server/respond.d.ts +17 -0
- package/dist/server/respond.d.ts.map +1 -0
- package/dist/server/respond.js +81 -0
- package/dist/server/respond.js.map +1 -0
- package/dist/server/runtime-core.d.ts +36 -0
- package/dist/server/runtime-core.d.ts.map +1 -0
- package/dist/server/runtime-core.js +51 -0
- package/dist/server/runtime-core.js.map +1 -0
- package/dist/server/server-types.d.ts +203 -0
- package/dist/server/server-types.d.ts.map +1 -0
- package/dist/server/server-types.js +2 -0
- package/dist/server/server-types.js.map +1 -0
- package/dist/server/server.d.ts +107 -345
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +214 -831
- package/dist/server/server.js.map +1 -1
- package/dist/server/sse-hook.d.ts +10 -0
- package/dist/server/sse-hook.d.ts.map +1 -0
- package/dist/server/sse-hook.js +2 -0
- package/dist/server/sse-hook.js.map +1 -0
- package/dist/server/sse.d.ts +7 -23
- package/dist/server/sse.d.ts.map +1 -1
- package/dist/server/sse.js +18 -0
- package/dist/server/sse.js.map +1 -1
- package/dist/server/websocket.d.ts +17 -1
- package/dist/server/websocket.d.ts.map +1 -1
- package/dist/server/websocket.js.map +1 -1
- package/dist/server/ws-hook.d.ts +8 -11
- package/dist/server/ws-hook.d.ts.map +1 -1
- package/dist/server/ws-hook.js +7 -14
- package/dist/server/ws-hook.js.map +1 -1
- package/dist/server.d.ts +21 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +16 -0
- package/dist/server.js.map +1 -0
- package/dist/ws.d.ts +16 -7
- package/dist/ws.d.ts.map +1 -1
- package/dist/ws.js +25 -10
- package/dist/ws.js.map +1 -1
- package/package.json +77 -6
- package/src/assurance.ts +36 -1
- package/src/effect-ledger.ts +9 -0
- package/src/idempotency-plugin.ts +7 -0
- package/src/index.ts +6 -133
- package/src/mcp.ts +65 -0
- package/src/node-direct.ts +37 -0
- package/src/reflection.ts +7 -0
- package/src/server/client-ip.ts +60 -0
- package/src/server/context.ts +50 -2
- package/src/server/contract.ts +26 -7
- package/src/server/http.ts +58 -0
- package/src/server/idempotency-lane.ts +287 -0
- package/src/server/install.ts +28 -0
- package/src/server/ledger-lane.ts +125 -0
- package/src/server/mcp-hook.ts +41 -0
- package/src/server/node-outcome-hook.ts +9 -0
- package/src/server/node-outcome.ts +112 -0
- package/src/server/plugin.ts +92 -0
- package/src/server/query.ts +119 -0
- package/src/server/registry.ts +36 -6
- package/src/server/request-context.ts +271 -0
- package/src/server/respond.ts +93 -0
- package/src/server/runtime-core.ts +74 -0
- package/src/server/server-types.ts +204 -0
- package/src/server/server.ts +402 -1314
- package/src/server/sse-hook.ts +14 -0
- package/src/server/sse.ts +26 -0
- package/src/server/websocket.ts +20 -0
- package/src/server/ws-hook.ts +8 -19
- package/src/server.ts +92 -0
- package/src/ws.ts +33 -10
- package/dist/invariants.d.ts +0 -70
- package/dist/invariants.d.ts.map +0 -1
- package/dist/invariants.js +0 -487
- package/dist/invariants.js.map +0 -1
- package/src/invariants.ts +0 -604
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The opt-in per-request effect ledger. Installed by `.use(effectLedger())` and reached only by routes
|
|
3
|
+
* that declare `schema.capabilities`, so the kernel never statically imports this code: a bare
|
|
4
|
+
* `server()` tree-shakes the ledger machinery out.
|
|
5
|
+
*
|
|
6
|
+
* The kernel resolves a capability-declaring route's ledger wiring at registration (via
|
|
7
|
+
* {@link EffectLedgerRuntime.resolve}) and, on the request path, creates + attaches a ledger before the
|
|
8
|
+
* handler and settles it after (via {@link EffectLedgerRuntime.create}/`attach`/`settle`). Nothing here
|
|
9
|
+
* depends on server internals; the sink-error log is supplied per settle.
|
|
10
|
+
*/
|
|
11
|
+
import { type EffectLedgerOptions, type RequestLedger } from "../ledger.js";
|
|
12
|
+
import type { IdentityPlugin } from "./server.js";
|
|
13
|
+
/** Registration-resolved effect-ledger wiring for one capability-declaring route. */
|
|
14
|
+
export interface ResolvedEffectLedger {
|
|
15
|
+
readonly sink: EffectLedgerOptions["sink"];
|
|
16
|
+
readonly maxEntries: number;
|
|
17
|
+
readonly chain: boolean;
|
|
18
|
+
/** The registered route pattern - what the sealed ledger names (never the concrete URL). */
|
|
19
|
+
readonly method: string;
|
|
20
|
+
readonly path: string;
|
|
21
|
+
/** The route's declared capability tokens, surfaced on the sealed ledger. */
|
|
22
|
+
readonly declared: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
/** The injected effect-ledger implementation the kernel calls through when the plugin is installed. */
|
|
25
|
+
export interface EffectLedgerRuntime {
|
|
26
|
+
/** Resolve a capability-declaring route into its ledger wiring, or `undefined` when it declares none. */
|
|
27
|
+
resolve(capabilities: readonly string[], method: string, path: string): ResolvedEffectLedger | undefined;
|
|
28
|
+
/** Create the per-request ledger for a ledgered route. */
|
|
29
|
+
create(resolved: ResolvedEffectLedger): RequestLedger;
|
|
30
|
+
/** Attach a ledger to the request context so `useCapability` can append to it. */
|
|
31
|
+
attach(context: object, ledger: RequestLedger): void;
|
|
32
|
+
/** Seal the ledger and deliver it to the sink (empty ledgers are not delivered). */
|
|
33
|
+
settle<T>(ledger: RequestLedger, resolved: ResolvedEffectLedger, value: T, onSinkError: (fields: {
|
|
34
|
+
method: string;
|
|
35
|
+
path: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}) => void): Promise<T>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build an effect-ledger runtime from the app-wide options. `sink` receives the sealed, token-only
|
|
41
|
+
* ledger when a capability-declaring route settles with recorded entries; `maxEntries` bounds a single
|
|
42
|
+
* request's ledger; `chain` opts into the per-entry hash chain.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createEffectLedgerRuntime(options: EffectLedgerOptions): EffectLedgerRuntime;
|
|
45
|
+
/**
|
|
46
|
+
* Enable the per-request effect ledger. Each route that declares `schema.capabilities` gets a bounded,
|
|
47
|
+
* token-only ledger; `useCapability(c, id, …)` appends one entry per effect, and the sink receives the
|
|
48
|
+
* sealed ledger when the response settles (only when it recorded entries). Token-only by construction -
|
|
49
|
+
* capability ids, phases, counters, digests; never payloads, values, or the concrete URL (the route
|
|
50
|
+
* pattern is recorded). Without this plugin, capability-declaring routes simply carry no ledger.
|
|
51
|
+
*/
|
|
52
|
+
export declare function effectLedger(options: EffectLedgerOptions): IdentityPlugin;
|
|
53
|
+
//# sourceMappingURL=ledger-lane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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A;CACd;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,CA6C3F;AAOD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,cAAc,CAOzE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The opt-in per-request effect ledger. Installed by `.use(effectLedger())` and reached only by routes
|
|
3
|
+
* that declare `schema.capabilities`, so the kernel never statically imports this code: a bare
|
|
4
|
+
* `server()` tree-shakes the ledger machinery out.
|
|
5
|
+
*
|
|
6
|
+
* The kernel resolves a capability-declaring route's ledger wiring at registration (via
|
|
7
|
+
* {@link EffectLedgerRuntime.resolve}) and, on the request path, creates + attaches a ledger before the
|
|
8
|
+
* handler and settles it after (via {@link EffectLedgerRuntime.create}/`attach`/`settle`). Nothing here
|
|
9
|
+
* depends on server internals; the sink-error log is supplied per settle.
|
|
10
|
+
*/
|
|
11
|
+
import { attachEffectLedger, createRequestLedger, DEFAULT_MAX_ENTRIES, } from "../ledger.js";
|
|
12
|
+
import { INSTALL_EFFECT_LEDGER } from "./install.js";
|
|
13
|
+
/**
|
|
14
|
+
* Build an effect-ledger runtime from the app-wide options. `sink` receives the sealed, token-only
|
|
15
|
+
* ledger when a capability-declaring route settles with recorded entries; `maxEntries` bounds a single
|
|
16
|
+
* request's ledger; `chain` opts into the per-entry hash chain.
|
|
17
|
+
*/
|
|
18
|
+
export function createEffectLedgerRuntime(options) {
|
|
19
|
+
if (typeof options.sink !== "function") {
|
|
20
|
+
throw new TypeError("effectLedger.sink must be a function");
|
|
21
|
+
}
|
|
22
|
+
const maxEntries = options.maxEntries ?? DEFAULT_MAX_ENTRIES;
|
|
23
|
+
if (!Number.isSafeInteger(maxEntries) || maxEntries < 1) {
|
|
24
|
+
throw new RangeError("effectLedger.maxEntries must be a positive safe integer");
|
|
25
|
+
}
|
|
26
|
+
const chain = options.chain ?? false;
|
|
27
|
+
const sink = options.sink;
|
|
28
|
+
return {
|
|
29
|
+
resolve(capabilities, method, path) {
|
|
30
|
+
if (capabilities.length === 0)
|
|
31
|
+
return undefined;
|
|
32
|
+
return Object.freeze({ sink, maxEntries, chain, method, path, declared: capabilities });
|
|
33
|
+
},
|
|
34
|
+
create(resolved) {
|
|
35
|
+
return createRequestLedger({
|
|
36
|
+
method: resolved.method,
|
|
37
|
+
path: resolved.path,
|
|
38
|
+
declared: resolved.declared,
|
|
39
|
+
maxEntries: resolved.maxEntries,
|
|
40
|
+
chain: resolved.chain,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
attach(context, ledger) {
|
|
44
|
+
attachEffectLedger(context, ledger);
|
|
45
|
+
},
|
|
46
|
+
async settle(ledger, resolved, value, onSinkError) {
|
|
47
|
+
const sealed = await ledger.seal();
|
|
48
|
+
if (sealed.entries.length === 0)
|
|
49
|
+
return value;
|
|
50
|
+
try {
|
|
51
|
+
await resolved.sink(sealed);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
// Token-only: the route pattern and the failure name - never entry payloads (there are none)
|
|
55
|
+
// and never the request. The ledger is observational, so a sink outage never fails the effect.
|
|
56
|
+
onSinkError({
|
|
57
|
+
method: resolved.method,
|
|
58
|
+
path: resolved.path,
|
|
59
|
+
name: err instanceof Error ? err.name : "Error",
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Enable the per-request effect ledger. Each route that declares `schema.capabilities` gets a bounded,
|
|
68
|
+
* token-only ledger; `useCapability(c, id, …)` appends one entry per effect, and the sink receives the
|
|
69
|
+
* sealed ledger when the response settles (only when it recorded entries). Token-only by construction -
|
|
70
|
+
* capability ids, phases, counters, digests; never payloads, values, or the concrete URL (the route
|
|
71
|
+
* pattern is recorded). Without this plugin, capability-declaring routes simply carry no ledger.
|
|
72
|
+
*/
|
|
73
|
+
export function effectLedger(options) {
|
|
74
|
+
const runtime = createEffectLedgerRuntime(options);
|
|
75
|
+
const apply = (app) => {
|
|
76
|
+
;
|
|
77
|
+
app[INSTALL_EFFECT_LEDGER](runtime);
|
|
78
|
+
return app;
|
|
79
|
+
};
|
|
80
|
+
return Object.assign(apply, { pluginName: "nifra:effect-ledger" });
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=ledger-lane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-lane.js","sourceRoot":"","sources":["../../src/server/ledger-lane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAoCpD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAA4B;IACpE,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACvC,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAA;IAC7D,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,mBAAmB,CAAA;IAC5D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,UAAU,CAAC,yDAAyD,CAAC,CAAA;IACjF,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAA;IACpC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAEzB,OAAO;QACL,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI;YAChC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,SAAS,CAAA;YAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,E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AsB,GAAM,EAAK,EAAE;QAC/C,CAAC;QAAC,GAA0C,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAA;QAC5E,OAAO,GAAG,CAAA;IACZ,CAAC,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAmB,CAAA;AACtF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from "../schema/standard.js";
|
|
2
|
+
import type { Context, RouteSchema } from "./context.js";
|
|
3
|
+
import type { McpPromptDescriptor, McpResourceDescriptor, PromptArgument, RouteDescriptor, ToolAnnotations } from "./server-types.js";
|
|
4
|
+
export interface McpToolConfig {
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly input: StandardSchemaV1;
|
|
7
|
+
readonly output?: StandardSchemaV1;
|
|
8
|
+
readonly annotations?: ToolAnnotations;
|
|
9
|
+
}
|
|
10
|
+
export interface McpToolPlan {
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly schema: RouteSchema;
|
|
13
|
+
readonly run: (context: Context) => unknown;
|
|
14
|
+
readonly descriptor: NonNullable<RouteDescriptor["tool"]>;
|
|
15
|
+
}
|
|
16
|
+
export interface McpRuntime {
|
|
17
|
+
tool(name: string, config: McpToolConfig, handler: (input: unknown, context: Context) => unknown): McpToolPlan;
|
|
18
|
+
resource(uri: string, config: {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
readonly mimeType?: string;
|
|
22
|
+
}, read: McpResourceDescriptor["read"]): McpResourceDescriptor;
|
|
23
|
+
prompt(name: string, config: {
|
|
24
|
+
readonly description: string;
|
|
25
|
+
readonly arguments?: readonly PromptArgument[];
|
|
26
|
+
}, handler: McpPromptDescriptor["handler"]): McpPromptDescriptor;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=mcp-hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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,GAClC,qBAAqB,CAAA;IACxB,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE;QAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;KAAE,EACxF,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,GACtC,mBAAmB,CAAA;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-hook.js","sourceRoot":"","sources":["../../src/server/mcp-hook.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Lazy Node-direct renderer seam. The base server retains the typed method but not its renderer. */
|
|
2
|
+
import type { NodeServeOutcome } from "./node-outcome.js";
|
|
3
|
+
import type { CtxSet } from "./server.js";
|
|
4
|
+
export interface NodeOutcomeRuntime {
|
|
5
|
+
toOutcome(result: unknown, set: CtxSet): NodeServeOutcome;
|
|
6
|
+
fromResponse(response: Response): NodeServeOutcome;
|
|
7
|
+
timeout(): NodeServeOutcome;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=node-outcome-hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-outcome-hook.d.ts","sourceRoot":"","sources":["../../src/server/node-outcome-hook.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;IACzD,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAAA;IAClD,OAAO,IAAI,gBAAgB,CAAA;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-outcome-hook.js","sourceRoot":"","sources":["../../src/server/node-outcome-hook.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type HandlerResult } from "./runtime-core.js";
|
|
2
|
+
import type { CtxSet } from "./server.js";
|
|
3
|
+
/**
|
|
4
|
+
* What {@link Server.resolveNode} returns: either a plain-data render the `@nifrajs/node` adapter writes
|
|
5
|
+
* to the socket directly (`kind: "json"` - status + headers + cookies + a pre-stringified body, **no**
|
|
6
|
+
* undici `Response` built or drained), a marked buffered response body (`kind: "body"` - e.g.
|
|
7
|
+
* @nifrajs/web's non-deferred SSR HTML), or a `Response` (`kind: "response"`) for everything else
|
|
8
|
+
* (redirects, 404/405/errors, unmarked or streaming bodies). Internal to the nifra<->node bridge.
|
|
9
|
+
*/
|
|
10
|
+
export type NodeServeOutcome = {
|
|
11
|
+
readonly kind: "response";
|
|
12
|
+
readonly response: Response;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "json";
|
|
15
|
+
readonly status: number;
|
|
16
|
+
/** `c.set.headers` backing, or `undefined` when the handler never set a header. */
|
|
17
|
+
readonly headers: Readonly<Record<string, string>> | undefined;
|
|
18
|
+
/** Queued `Set-Cookie` lines, or `undefined`; the adapter emits one header line each. */
|
|
19
|
+
readonly cookies: readonly string[] | undefined;
|
|
20
|
+
/** The JSON body already stringified, or `null` for an empty (204) response. */
|
|
21
|
+
readonly body: string | null;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "body";
|
|
24
|
+
readonly status: number;
|
|
25
|
+
readonly headers: Readonly<Record<string, string | readonly string[]>> | undefined;
|
|
26
|
+
readonly body: string | Uint8Array;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* `finalize` for the node-direct path - mirror of `toResponse` that skips the `Response` build:
|
|
30
|
+
* a plain value becomes pre-stringified JSON primitives (the adapter `JSON.stringify`s once, here, not
|
|
31
|
+
* via `Response.json` + a body drain); a handler-returned `Response` is wrapped as-is, with queued
|
|
32
|
+
* cookies appended exactly as `toResponse` does (so the set-cookie-then-`redirect()` pattern still
|
|
33
|
+
* works on Node).
|
|
34
|
+
*/
|
|
35
|
+
export declare function toNodeOutcome(result: HandlerResult, set: CtxSet): NodeServeOutcome;
|
|
36
|
+
export declare function nodeOutcomeFromResponse(response: Response): NodeServeOutcome;
|
|
37
|
+
//# sourceMappingURL=node-outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-outcome.d.ts","sourceRoot":"","sources":["../../src/server/node-outcome.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,mBAAmB,CAAA;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC1D;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,mFAAmF;IACnF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAA;IAC9D,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IAC/C,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAA;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CACnC,CAAA;AAEL;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAwBlF;AAID,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAK5E"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-direct outcome shaping: the `@nifrajs/node` bridge's render form and the `Response` -> outcome
|
|
3
|
+
* conversion. Mirrors `respond.ts` but skips the undici `Response` build where the adapter can write a
|
|
4
|
+
* plain-data render straight to the socket. Imports only runtime-core + respond + the spine types.
|
|
5
|
+
*/
|
|
6
|
+
import { appendCookiesToResponse } from "./respond.js";
|
|
7
|
+
import { isResponseResult } from "./runtime-core.js";
|
|
8
|
+
/**
|
|
9
|
+
* `finalize` for the node-direct path - mirror of `toResponse` that skips the `Response` build:
|
|
10
|
+
* a plain value becomes pre-stringified JSON primitives (the adapter `JSON.stringify`s once, here, not
|
|
11
|
+
* via `Response.json` + a body drain); a handler-returned `Response` is wrapped as-is, with queued
|
|
12
|
+
* cookies appended exactly as `toResponse` does (so the set-cookie-then-`redirect()` pattern still
|
|
13
|
+
* works on Node).
|
|
14
|
+
*/
|
|
15
|
+
export function toNodeOutcome(result, set) {
|
|
16
|
+
if (isResponseResult(result)) {
|
|
17
|
+
const body = result.toNodeBody?.();
|
|
18
|
+
if (body !== undefined) {
|
|
19
|
+
return {
|
|
20
|
+
kind: "body",
|
|
21
|
+
status: body.status,
|
|
22
|
+
headers: appendCookiesToNodeHeaders(body.headers, set._cookies),
|
|
23
|
+
body: body.body,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return nodeOutcomeFromResponse(appendCookiesToResponse(result.toResponse(), set));
|
|
27
|
+
}
|
|
28
|
+
if (result instanceof Response) {
|
|
29
|
+
return nodeOutcomeFromResponse(appendCookiesToResponse(result, set));
|
|
30
|
+
}
|
|
31
|
+
const status = set.status ?? (result === undefined ? 204 : 200);
|
|
32
|
+
return {
|
|
33
|
+
kind: "json",
|
|
34
|
+
status,
|
|
35
|
+
headers: set._headers,
|
|
36
|
+
cookies: set._cookies,
|
|
37
|
+
body: result === undefined ? null : JSON.stringify(result),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const NODE_RESPONSE_BODY = Symbol.for("nifra.response.body");
|
|
41
|
+
export function nodeOutcomeFromResponse(response) {
|
|
42
|
+
const body = nodeResponseBody(response);
|
|
43
|
+
return body === undefined
|
|
44
|
+
? { kind: "response", response }
|
|
45
|
+
: { kind: "body", status: response.status, headers: responseHeadersForNode(response), body };
|
|
46
|
+
}
|
|
47
|
+
function nodeResponseBody(response) {
|
|
48
|
+
if (response.bodyUsed)
|
|
49
|
+
return undefined;
|
|
50
|
+
const body = response[NODE_RESPONSE_BODY];
|
|
51
|
+
return typeof body === "string" || body instanceof Uint8Array ? body : undefined;
|
|
52
|
+
}
|
|
53
|
+
function responseHeadersForNode(response) {
|
|
54
|
+
let headers;
|
|
55
|
+
response.headers.forEach((value, key) => {
|
|
56
|
+
headers ??= {};
|
|
57
|
+
headers[key] = value;
|
|
58
|
+
});
|
|
59
|
+
const setCookies = response.headers.getSetCookie?.();
|
|
60
|
+
if (setCookies !== undefined && setCookies.length > 0) {
|
|
61
|
+
headers ??= {};
|
|
62
|
+
headers["set-cookie"] = setCookies;
|
|
63
|
+
}
|
|
64
|
+
return headers;
|
|
65
|
+
}
|
|
66
|
+
function appendCookiesToNodeHeaders(headers, cookies) {
|
|
67
|
+
if (cookies === undefined || cookies.length === 0)
|
|
68
|
+
return headers;
|
|
69
|
+
const out = headers === undefined ? {} : { ...headers };
|
|
70
|
+
const existing = out["set-cookie"];
|
|
71
|
+
const setCookies = existing === undefined ? [] : typeof existing === "string" ? [existing] : [...existing];
|
|
72
|
+
out["set-cookie"] = [...setCookies, ...cookies];
|
|
73
|
+
return out;
|
|
74
|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AO,CAAC,YAAY,CAAC,GAAG,UAAU,CAAA;IACpC,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,0BAA0B,CACjC,OAAyE,EACzE,OAAsC;IAEtC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAA;IACjE,MAAM,GAAG,GACP,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAA;IAC7C,MAAM,QAAQ,GAAG,GAAG,CAAC,YAAY,CAAC,CAAA;IAClC,MAAM,UAAU,GACd,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAA;IACzF,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,CAAA;IAC/C,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin definers and their types. A plugin is a function that augments an app (calling
|
|
3
|
+
* `use`/`derive`/`decorate` and/or registering routes) and returns it; these helpers attach a name
|
|
4
|
+
* for idempotent dedupe and pin the type-threading so `.use()` preserves the caller's typed server.
|
|
5
|
+
*/
|
|
6
|
+
import type { AnyServer } from "./server.js";
|
|
7
|
+
/**
|
|
8
|
+
* A nifra **plugin**: a function that augments an app - calling `use`/`derive`/`decorate` and/or
|
|
9
|
+
* registering routes - and returns it. Because `derive`/`decorate` are type-threaded, an **inline**
|
|
10
|
+
* `app.use((a) => a.derive(...).decorate(...))` carries the added context to handlers defined after
|
|
11
|
+
* it (the `use` overload is generic over the concrete `this`). Wrap with {@link definePlugin} to
|
|
12
|
+
* attach a name for idempotent dedupe (applying the same named plugin twice - e.g. transitively - is
|
|
13
|
+
* a no-op).
|
|
14
|
+
*/
|
|
15
|
+
export type NifraPlugin<In extends AnyServer = AnyServer, Out extends AnyServer = In> = ((app: In) => Out) & {
|
|
16
|
+
readonly pluginName?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A named type-identity plugin built with {@link defineIdentityPlugin}. It returns the same concrete
|
|
20
|
+
* server type it receives, preserving the caller's typed registry and context across `.use()` while
|
|
21
|
+
* still allowing the plugin to register runtime hooks or handlers.
|
|
22
|
+
*/
|
|
23
|
+
export type IdentityPlugin = (<S extends AnyServer>(app: S) => S) & {
|
|
24
|
+
readonly pluginName?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Name + ergonomics for a plugin that **adds typed context** (`derive`/`decorate`). `app.use(myPlugin)`
|
|
28
|
+
* applies it once; a second `use` of the same name is skipped (idempotent), so plugins can depend on each
|
|
29
|
+
* other without double-registering hooks.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* export const requestId = definePlugin("requestId", (app) => app.derive(() => ({ requestId: uuid() })))
|
|
33
|
+
* app.use(requestId) // downstream handlers see c.requestId
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* FOOTGUN: only use this for a plugin that adds context. For a plugin that **mounts routes/hooks but adds
|
|
37
|
+
* NO context** (an auth router, an audit logger), use {@link defineRouterPlugin} ({@link defineIdentityPlugin}).
|
|
38
|
+
* `definePlugin((app) => app.get(...))` infers `app: Server<any, any>`, so `.use()` returns `Server<any, any>`
|
|
39
|
+
* and your whole typed client silently collapses to `any` - no type error, no runtime error.
|
|
40
|
+
*/
|
|
41
|
+
export declare function definePlugin<In extends AnyServer, Out extends AnyServer>(name: string, apply: (app: In) => Out): NifraPlugin<In, Out>;
|
|
42
|
+
/**
|
|
43
|
+
* Define a type-**identity** plugin: it registers routes/hooks as a side effect but returns the app with
|
|
44
|
+
* its `Registry` + `Context` UNCHANGED. Use this (not {@link definePlugin}) for any plugin that doesn't
|
|
45
|
+
* add context types - e.g. one mounting an auth handler. It threads the caller's *concrete* server type
|
|
46
|
+
* through `use`, so routes declared after `app.use(plugin)` keep their types.
|
|
47
|
+
*
|
|
48
|
+
* Why a dedicated helper: `definePlugin((app) => app)` infers `app: Server<any, any>`, so `use` returns
|
|
49
|
+
* `Server<any, any>` and the whole typed client collapses to `any`. The explicit generic return type here
|
|
50
|
+
* (which a plain `Object.assign` can't preserve) is what keeps `use` returning the precise server type.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* export const audit = defineIdentityPlugin("audit", (app) => app.onResponse(logResponse))
|
|
54
|
+
* const api = server().get("/a", h).use(audit).get("/b", h) // /a AND /b stay typed
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function defineIdentityPlugin(name: string, apply: <S extends AnyServer>(app: S) => S): IdentityPlugin;
|
|
58
|
+
/**
|
|
59
|
+
* Alias of {@link defineIdentityPlugin} with a name that says what it's FOR: a plugin that **mounts
|
|
60
|
+
* routes/hooks but adds no context type** (an auth router, an audit logger). Use this - not
|
|
61
|
+
* {@link definePlugin} - for any such plugin, or the typed client silently collapses to `any`. The
|
|
62
|
+
* "identity" in {@link defineIdentityPlugin} refers to the type-identity it preserves; `defineRouterPlugin`
|
|
63
|
+
* is the same thing under a clearer name.
|
|
64
|
+
*
|
|
65
|
+
* Mount routes as a **side effect**, then return the app unchanged (registering via `.get`/`.post` would
|
|
66
|
+
* change the type away from the identity `S`; the mounted routes run but aren't in the caller's typed
|
|
67
|
+
* registry - that's the trade that keeps everything else typed):
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* export const scim = defineRouterPlugin("scim", (app) => {
|
|
71
|
+
* app.get("/scim/v2/Users", listUsers) // side effect: mounted at runtime
|
|
72
|
+
* return app // return S unchanged → routes added after .use(scim) stay typed
|
|
73
|
+
* })
|
|
74
|
+
* const api = server().get("/a", h).use(scim).get("/b", h) // /a AND /b stay typed
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare const defineRouterPlugin: typeof defineIdentityPlugin;
|
|
78
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/server/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CAAC,EAAE,SAAS,SAAS,GAAG,SAAS,EAAE,GAAG,SAAS,SAAS,GAAG,EAAE,IAAI,CAAC,CACvF,GAAG,EAAE,EAAE,KACJ,GAAG,CAAC,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5C;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,SAAS,EACtE,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,KAAK,GAAG,GACtB,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAEtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GACxC,cAAc,CAEhB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,oBAA2C,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name + ergonomics for a plugin that **adds typed context** (`derive`/`decorate`). `app.use(myPlugin)`
|
|
3
|
+
* applies it once; a second `use` of the same name is skipped (idempotent), so plugins can depend on each
|
|
4
|
+
* other without double-registering hooks.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* export const requestId = definePlugin("requestId", (app) => app.derive(() => ({ requestId: uuid() })))
|
|
8
|
+
* app.use(requestId) // downstream handlers see c.requestId
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* FOOTGUN: only use this for a plugin that adds context. For a plugin that **mounts routes/hooks but adds
|
|
12
|
+
* NO context** (an auth router, an audit logger), use {@link defineRouterPlugin} ({@link defineIdentityPlugin}).
|
|
13
|
+
* `definePlugin((app) => app.get(...))` infers `app: Server<any, any>`, so `.use()` returns `Server<any, any>`
|
|
14
|
+
* and your whole typed client silently collapses to `any` - no type error, no runtime error.
|
|
15
|
+
*/
|
|
16
|
+
export function definePlugin(name, apply) {
|
|
17
|
+
return Object.assign(apply, { pluginName: name });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Define a type-**identity** plugin: it registers routes/hooks as a side effect but returns the app with
|
|
21
|
+
* its `Registry` + `Context` UNCHANGED. Use this (not {@link definePlugin}) for any plugin that doesn't
|
|
22
|
+
* add context types - e.g. one mounting an auth handler. It threads the caller's *concrete* server type
|
|
23
|
+
* through `use`, so routes declared after `app.use(plugin)` keep their types.
|
|
24
|
+
*
|
|
25
|
+
* Why a dedicated helper: `definePlugin((app) => app)` infers `app: Server<any, any>`, so `use` returns
|
|
26
|
+
* `Server<any, any>` and the whole typed client collapses to `any`. The explicit generic return type here
|
|
27
|
+
* (which a plain `Object.assign` can't preserve) is what keeps `use` returning the precise server type.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* export const audit = defineIdentityPlugin("audit", (app) => app.onResponse(logResponse))
|
|
31
|
+
* const api = server().get("/a", h).use(audit).get("/b", h) // /a AND /b stay typed
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function defineIdentityPlugin(name, apply) {
|
|
35
|
+
return Object.assign(apply, { pluginName: name });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Alias of {@link defineIdentityPlugin} with a name that says what it's FOR: a plugin that **mounts
|
|
39
|
+
* routes/hooks but adds no context type** (an auth router, an audit logger). Use this - not
|
|
40
|
+
* {@link definePlugin} - for any such plugin, or the typed client silently collapses to `any`. The
|
|
41
|
+
* "identity" in {@link defineIdentityPlugin} refers to the type-identity it preserves; `defineRouterPlugin`
|
|
42
|
+
* is the same thing under a clearer name.
|
|
43
|
+
*
|
|
44
|
+
* Mount routes as a **side effect**, then return the app unchanged (registering via `.get`/`.post` would
|
|
45
|
+
* change the type away from the identity `S`; the mounted routes run but aren't in the caller's typed
|
|
46
|
+
* registry - that's the trade that keeps everything else typed):
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* export const scim = defineRouterPlugin("scim", (app) => {
|
|
50
|
+
* app.get("/scim/v2/Users", listUsers) // side effect: mounted at runtime
|
|
51
|
+
* return app // return S unchanged → routes added after .use(scim) stay typed
|
|
52
|
+
* })
|
|
53
|
+
* const api = server().get("/a", h).use(scim).get("/b", h) // /a AND /b stay typed
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export const defineRouterPlugin = defineIdentityPlugin;
|
|
57
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/server/plugin.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,KAAuB;IAEvB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAyB,CAAA;AAC3E,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,KAAyC;IAEzC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAmB,CAAA;AACrE,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgC,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RequestSource } from "./server.js";
|
|
2
|
+
export declare function searchOf(url: string): string;
|
|
3
|
+
/** A query value: a single occurrence is a string; a repeated key promotes to a string[] so an
|
|
4
|
+
* array query schema (`t.array(t.string())`) can validate `?tag=a&tag=b` - last-wins silently
|
|
5
|
+
* dropped values before (audit 2026-06). Single-occurrence keys stay plain strings, so existing
|
|
6
|
+
* `t.string()` schemas are untouched; a repeated key against a string schema now FAILS validation
|
|
7
|
+
* (an explicit 400 beats silently picking one). */
|
|
8
|
+
export type QueryValue = string | string[];
|
|
9
|
+
export declare function queryObjectOf(search: string): Record<string, QueryValue>;
|
|
10
|
+
/** `application/x-www-form-urlencoded`, with or without a charset suffix. */
|
|
11
|
+
export declare function isUrlEncodedForm(contentType: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Read an HTML-form body (urlencoded) into the plain object a body schema validates - same byte
|
|
14
|
+
* cap as the JSON path (a lying/absent Content-Length can't force an oversized buffer), same
|
|
15
|
+
* repeated-key -> `string[]` promotion as query parsing, same `__proto__` guard.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readBoundedForm(req: RequestSource, maxBytes: number): Promise<Record<string, QueryValue> | Response>;
|
|
18
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/server/query.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAMhD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;mDAImD;AACnD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AAqC1C,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAyBxE;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAK7D;AAID;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAchD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-string and urlencoded-form parsing. Pure request-shaping helpers with no server internals:
|
|
3
|
+
* the fast scanner for `c.query`, the repeated-key -> `string[]` promotion shared by query + form,
|
|
4
|
+
* and the byte-capped HTML-form reader. Split out of the server kernel so the file stays one domain.
|
|
5
|
+
*/
|
|
6
|
+
import { readBoundedBytes } from "./body.js";
|
|
7
|
+
import { jsonError, urlPartsOf } from "./http.js";
|
|
8
|
+
// The query string ("?a=1", or "" when absent) - for lazily building `c.query` only when read.
|
|
9
|
+
// The fragment (after the first `#`) bounds the search: a `?` that appears only inside the fragment
|
|
10
|
+
// is NOT a query (matches WHATWG). Fragments never reach the server in `req.url`, so this is purely
|
|
11
|
+
// for provable equivalence with `new URL(req.url).search`.
|
|
12
|
+
export function searchOf(url) {
|
|
13
|
+
return urlPartsOf(url).search;
|
|
14
|
+
}
|
|
15
|
+
/** Accumulate into a NULL-PROTOTYPE record (every call site below creates one): with no inherited
|
|
16
|
+
* `constructor`/`toString`/`__proto__` accessors, a hostile key is just an own data key - the
|
|
17
|
+
* promotion logic can't collide with `Object.prototype` members, and `__proto__` needs no special
|
|
18
|
+
* case (direct assignment on a null-proto object creates an own property). */
|
|
19
|
+
function setQueryValue(out, key, value) {
|
|
20
|
+
const existing = out[key];
|
|
21
|
+
if (existing === undefined) {
|
|
22
|
+
out[key] = value;
|
|
23
|
+
}
|
|
24
|
+
else if (typeof existing === "string") {
|
|
25
|
+
out[key] = [existing, value];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
existing.push(value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function queryObjectFallback(search) {
|
|
32
|
+
// Manual iteration instead of Object.fromEntries: repeated keys must promote to arrays
|
|
33
|
+
// (fromEntries is last-wins), and __proto__ needs the same own-property guard.
|
|
34
|
+
const out = Object.create(null);
|
|
35
|
+
for (const [key, value] of new URLSearchParams(search)) {
|
|
36
|
+
setQueryValue(out, key, value);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Build the plain object passed to query schemas. Plain ASCII-ish queries avoid
|
|
42
|
+
* `URLSearchParams` + iterator allocations; encoded queries fall back to the Web API so `+`,
|
|
43
|
+
* percent-decoding, malformed escapes, and empty-key behavior stay exact. Repeated keys promote
|
|
44
|
+
* to `string[]` on BOTH paths (see {@link setQueryValue}).
|
|
45
|
+
*/
|
|
46
|
+
// Shared empty result for no-query requests: frozen + null-prototype (same shape contract as the
|
|
47
|
+
// populated path), allocated once instead of per request.
|
|
48
|
+
const EMPTY_QUERY = Object.freeze(Object.create(null));
|
|
49
|
+
export function queryObjectOf(search) {
|
|
50
|
+
const start = search.charCodeAt(0) === 63 /* ? */ ? 1 : 0;
|
|
51
|
+
if (start >= search.length)
|
|
52
|
+
return EMPTY_QUERY;
|
|
53
|
+
for (let i = start; i < search.length; i++) {
|
|
54
|
+
const c = search.charCodeAt(i);
|
|
55
|
+
if (c === 37 /* % */ || c === 43 /* + */)
|
|
56
|
+
return queryObjectFallback(search);
|
|
57
|
+
}
|
|
58
|
+
const out = Object.create(null);
|
|
59
|
+
let pos = start;
|
|
60
|
+
while (pos <= search.length) {
|
|
61
|
+
const amp = search.indexOf("&", pos);
|
|
62
|
+
const end = amp === -1 ? search.length : amp;
|
|
63
|
+
if (end > pos) {
|
|
64
|
+
const eq = search.indexOf("=", pos);
|
|
65
|
+
const split = eq !== -1 && eq < end ? eq : end;
|
|
66
|
+
const key = search.slice(pos, split);
|
|
67
|
+
const value = split === end ? "" : search.slice(split + 1, end);
|
|
68
|
+
setQueryValue(out, key, value);
|
|
69
|
+
}
|
|
70
|
+
if (amp === -1)
|
|
71
|
+
break;
|
|
72
|
+
pos = amp + 1;
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/** `application/x-www-form-urlencoded`, with or without a charset suffix. */
|
|
77
|
+
export function isUrlEncodedForm(contentType) {
|
|
78
|
+
return (contentType === "application/x-www-form-urlencoded" ||
|
|
79
|
+
contentType.startsWith("application/x-www-form-urlencoded;"));
|
|
80
|
+
}
|
|
81
|
+
const FORM_DECODER = new TextDecoder();
|
|
82
|
+
/**
|
|
83
|
+
* Read an HTML-form body (urlencoded) into the plain object a body schema validates - same byte
|
|
84
|
+
* cap as the JSON path (a lying/absent Content-Length can't force an oversized buffer), same
|
|
85
|
+
* repeated-key -> `string[]` promotion as query parsing, same `__proto__` guard.
|
|
86
|
+
*/
|
|
87
|
+
export async function readBoundedForm(req, maxBytes) {
|
|
88
|
+
const read = await readBoundedBytes(req, maxBytes);
|
|
89
|
+
if (!read.ok) {
|
|
90
|
+
return read.status === 413
|
|
91
|
+
? jsonError(413, "payload_too_large")
|
|
92
|
+
: jsonError(400, "invalid_content_length");
|
|
93
|
+
}
|
|
94
|
+
const out = Object.create(null);
|
|
95
|
+
// URLSearchParams owns the format's quirks (`+` as space, percent-decoding, empty keys);
|
|
96
|
+
// it never throws on junk input, so no try/catch is needed here.
|
|
97
|
+
for (const [key, value] of new URLSearchParams(FORM_DECODER.decode(read.bytes))) {
|
|
98
|
+
setQueryValue(out, key, value);
|
|
99
|
+
}
|
|
100
|
+
return out;
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