@nifrajs/cli 1.0.0-beta.3 → 1.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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +5 -0
- package/dist/introspect.js.map +1 -1
- package/dist/mcp-docs-tools.d.ts +3 -2
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +34 -3
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +12 -15
- package/dist/mcp-http.d.ts.map +1 -1
- package/dist/mcp-http.js +15 -101
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-protocol.d.ts +4 -94
- package/dist/mcp-protocol.d.ts.map +1 -1
- package/dist/mcp-protocol.js +4 -245
- package/dist/mcp-protocol.js.map +1 -1
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +7 -1
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp.d.ts +22 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +10 -5
- package/dist/mcp.js.map +1 -1
- package/dist/types-search.d.ts +37 -0
- package/dist/types-search.d.ts.map +1 -0
- package/dist/types-search.js +90 -0
- package/dist/types-search.js.map +1 -0
- package/docs/examples.json +1 -1
- package/docs/llms-full.txt +78 -17
- package/docs/types.json +6386 -0
- package/package.json +7 -6
- package/src/cli.ts +1 -1
- package/src/introspect.ts +5 -0
- package/src/mcp-docs-tools.ts +37 -2
- package/src/mcp-http.ts +19 -109
- package/src/mcp-protocol.ts +4 -323
- package/src/mcp-run.ts +7 -1
- package/src/mcp.ts +10 -5
- package/src/types-search.ts +113 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nifra_types` — the EXACT TypeScript of every exported `@nifrajs/*` symbol. The corpus is `types.json`
|
|
3
|
+
* (written into this package by `bun run gen:llms`): each entry's `signature` is the literal declaration
|
|
4
|
+
* parsed from the package's BUILT `.d.ts` with the TS compiler — a clean signature, never prose, never
|
|
5
|
+
* truncated. So an agent that needs the precise shape of a type (`RateLimitStore`, `RouteSchema`, a
|
|
6
|
+
* function signature) gets the authoritative source here and never has to read a `.d.ts` file.
|
|
7
|
+
*
|
|
8
|
+
* Lookup by `name` is exact (case-insensitive); `query` keyword-scores over the name (heavy) + the
|
|
9
|
+
* signature/doc body; no args → a per-package index of the available type names.
|
|
10
|
+
*/
|
|
11
|
+
import { countBodyHits, queryTermGroups, tokenize, tokenSetHas } from "./search-terms.js";
|
|
12
|
+
/** Exact (case-insensitive) name lookup — returns every declaration with that name (a name can exist in
|
|
13
|
+
* more than one package). */
|
|
14
|
+
export function lookupType(types, name) {
|
|
15
|
+
const wanted = name.trim().toLowerCase();
|
|
16
|
+
return types.filter((t) => t.name.toLowerCase() === wanted);
|
|
17
|
+
}
|
|
18
|
+
/** Keyword-score types: a term in the name is worth far more than one in the signature/doc body. */
|
|
19
|
+
export function searchTypes(types, query, limit) {
|
|
20
|
+
const terms = queryTermGroups(query);
|
|
21
|
+
if (terms.length === 0)
|
|
22
|
+
return [];
|
|
23
|
+
const scored = [];
|
|
24
|
+
for (const t of types) {
|
|
25
|
+
const nameTokens = new Set(tokenize(t.name));
|
|
26
|
+
const body = `${t.signature} ${t.doc ?? ""}`.toLowerCase();
|
|
27
|
+
let score = 0;
|
|
28
|
+
for (const term of terms) {
|
|
29
|
+
if (tokenSetHas(nameTokens, term))
|
|
30
|
+
score += 8;
|
|
31
|
+
score += countBodyHits(body, term, 4);
|
|
32
|
+
}
|
|
33
|
+
if (score > 0)
|
|
34
|
+
scored.push({ ...t, score });
|
|
35
|
+
}
|
|
36
|
+
return scored.sort((a, b) => b.score - a.score || a.name.localeCompare(b.name)).slice(0, limit);
|
|
37
|
+
}
|
|
38
|
+
function renderEntry(t) {
|
|
39
|
+
const head = `## ${t.name} — ${t.kind}, \`${t.package}\``;
|
|
40
|
+
const doc = t.doc ? `${t.doc}\n` : "";
|
|
41
|
+
return `${head}\n\n\`\`\`ts\n${doc}${t.signature}\n\`\`\``;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render the tool result. `name` → the exact declaration(s); else `query` → the top matches; else a
|
|
45
|
+
* per-package index of type names. The signatures are authoritative (generated from the built `.d.ts`),
|
|
46
|
+
* so this is the complete answer — there is no need to read a `.d.ts` file.
|
|
47
|
+
*/
|
|
48
|
+
export function renderTypesResult(types, name, query, limit) {
|
|
49
|
+
if (name !== undefined && name.trim() !== "") {
|
|
50
|
+
const hits = lookupType(types, name);
|
|
51
|
+
if (hits.length === 0) {
|
|
52
|
+
return `No exported type named ${JSON.stringify(name)} in @nifrajs/*. Call nifra_types with a \`query\` (e.g. "rate limit") or no args for the per-package index of names.`;
|
|
53
|
+
}
|
|
54
|
+
return hits.map(renderEntry).join("\n\n---\n\n");
|
|
55
|
+
}
|
|
56
|
+
if (query !== undefined && query.trim() !== "") {
|
|
57
|
+
const matches = searchTypes(types, query, limit);
|
|
58
|
+
if (matches.length === 0) {
|
|
59
|
+
return `No types matched ${JSON.stringify(query)}. Try a broader term, pass an exact \`name\`, or call with no args for the index.`;
|
|
60
|
+
}
|
|
61
|
+
return matches.map(renderEntry).join("\n\n---\n\n");
|
|
62
|
+
}
|
|
63
|
+
const byPkg = new Map();
|
|
64
|
+
for (const t of types) {
|
|
65
|
+
const list = byPkg.get(t.package) ?? [];
|
|
66
|
+
list.push(t.name);
|
|
67
|
+
byPkg.set(t.package, list);
|
|
68
|
+
}
|
|
69
|
+
const index = [...byPkg.entries()]
|
|
70
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
71
|
+
.map(([pkg, names]) => `- **${pkg}**: ${names.sort().join(", ")}`)
|
|
72
|
+
.join("\n");
|
|
73
|
+
return `# nifra types — index (${types.length} exported symbols; pass \`name\` for the exact declaration, or \`query\` to search)\n\nSignatures are generated from the built \`.d.ts\` — authoritative + complete. Use this instead of reading any \`.d.ts\` file.\n\n${index}`;
|
|
74
|
+
}
|
|
75
|
+
/** Load the bundled type corpus (`docs/types.json`), resolved relative to this module so it works from
|
|
76
|
+
* `src/` (dev) and `dist/` (published) alike. */
|
|
77
|
+
export async function loadTypesCorpus() {
|
|
78
|
+
const url = new URL("../docs/types.json", import.meta.url);
|
|
79
|
+
try {
|
|
80
|
+
const text = await Bun.file(url).text();
|
|
81
|
+
if (text.length === 0)
|
|
82
|
+
return undefined;
|
|
83
|
+
const parsed = JSON.parse(text);
|
|
84
|
+
return Array.isArray(parsed) && parsed.length > 0 ? parsed : undefined;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=types-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-search.js","sourceRoot":"","sources":["../src/types-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAgBzF;6BAC6B;AAC7B,MAAM,UAAU,UAAU,CAAC,KAA2B,EAAE,IAAY;IAClE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACxC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAA;AAC7D,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,WAAW,CACzB,KAA2B,EAC3B,KAAa,EACb,KAAa;IAEb,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACjC,MAAM,MAAM,GAAiB,EAAE,CAAA;IAC/B,KAAK,MAAM,CA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E,CAAC;SAC/B,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,GAAG,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACjE,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,OAAO,0BAA0B,KAAK,CAAC,MAAM,2NAA2N,KAAK,EAAE,CAAA;AACjR,CAAC;AAED;iDACiD;AACjD,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;QACvC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAA;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAgB,CAAA;QAC9C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
package/docs/examples.json
CHANGED
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"name": "IDENTITY",
|
|
160
160
|
"topic": "Nifra — Plugins & middleware",
|
|
161
161
|
"slug": "plugins",
|
|
162
|
-
"code": "import {
|
|
162
|
+
"code": "import { defineRouterPlugin, server } from \"@nifrajs/core\"\n\n// A plugin that mounts routes/hooks but adds NO context type: defineRouterPlugin (the clearer name for\n// defineIdentityPlugin) keeps app.use()'s return type EXACTLY the caller's server, so routes added after\n// .use() stay typed — and the typed client derived from them stays intact.\nexport const scim = defineRouterPlugin(\"scim\", (app) => {\n app.get(\"/scim/v2/Users\", () => ({ Resources: [] })) // mount as a SIDE EFFECT (a runtime-only route)\n return app // return the app unchanged → caller's registry preserved\n})\n\n// /a AND /b stay fully typed across the .use():\nconst api = server().get(\"/a\", () => ({ a: 1 })).use(scim).get(\"/b\", () => ({ b: 2 }))"
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
165
|
"name": "JWT_BASIC",
|
package/docs/llms-full.txt
CHANGED
|
@@ -404,6 +404,19 @@ return makes the typed client infer `data: never`, so you silently lose drift
|
|
|
404
404
|
detection for that route (`nifra check` flags it). `c.set` keeps your
|
|
405
405
|
plain-object return fully typed.
|
|
406
406
|
|
|
407
|
+
When you genuinely want a `Response` — an **error short-circuit** from a
|
|
408
|
+
`derive` / `beforeHandle` (auth, rate limits) — `c.json(body, status?)`
|
|
409
|
+
and `c.text(body, status?)` build one in a line:
|
|
410
|
+
`throw c.json({ error: "unauthorized" }, 401)` instead of
|
|
411
|
+
`new Response(JSON.stringify(…), { status: 401, headers: … })`. The second arg is a
|
|
412
|
+
status number or a full `ResponseInit`, and both work whether you `return` or
|
|
413
|
+
`throw` them. (In a route's happy path keep returning a plain object, as above, so the
|
|
414
|
+
typed client stays in sync.)
|
|
415
|
+
|
|
416
|
+
The request is on `c.req`, also available as `c.request` — the same name a
|
|
417
|
+
page loader/action receives (which in turn also accepts `ctx.req`), so one name works
|
|
418
|
+
in both places.
|
|
419
|
+
|
|
407
420
|
### Contract-first (defineContract + implement)
|
|
408
421
|
|
|
409
422
|
For larger apps — or when the contract is shared across services — declare it with
|
|
@@ -1174,29 +1187,37 @@ app
|
|
|
1174
1187
|
app.use((a) => a.decorate("db", db).derive((c) => ({ now: Date.now() })))
|
|
1175
1188
|
```
|
|
1176
1189
|
|
|
1177
|
-
### Route/hook plugins: keep types with
|
|
1190
|
+
### Route/hook plugins: keep types with defineRouterPlugin
|
|
1178
1191
|
|
|
1179
1192
|
A plugin that registers routes or hooks but adds **no context type** — e.g. mounting an auth
|
|
1180
|
-
|
|
1181
|
-
It threads the app's
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
`
|
|
1185
|
-
|
|
1193
|
+
router — should be built with `defineRouterPlugin` (the clearer-named alias of
|
|
1194
|
+
`defineIdentityPlugin`), not `definePlugin`. It threads the app's
|
|
1195
|
+
_exact_ type through `use`, so the route registry (and the typed client derived
|
|
1196
|
+
from it) survives the plugin. Mount routes as a **side effect** then `return app`
|
|
1197
|
+
(registering with `.get`/`.post` directly would change the type away from the
|
|
1198
|
+
identity, so those routes run but aren't in the typed registry — the trade that keeps everything
|
|
1199
|
+
else typed).
|
|
1200
|
+
|
|
1201
|
+
**Footgun:** reach for `definePlugin` here instead and a plain
|
|
1202
|
+
`definePlugin((app) => app.get(...))` infers `app` as
|
|
1203
|
+
`Server`, collapsing `use()`'s result — and your whole typed
|
|
1204
|
+
client — to `any`, with **no type error and no runtime error**.
|
|
1205
|
+
`@nifrajs/better-auth` is built with the identity form, so
|
|
1186
1206
|
`server().use(betterAuth(auth)).get(...)` keeps every route typed.
|
|
1187
1207
|
|
|
1188
1208
|
```ts
|
|
1189
|
-
import {
|
|
1209
|
+
import { defineRouterPlugin, server } from "@nifrajs/core"
|
|
1190
1210
|
|
|
1191
|
-
// A plugin that
|
|
1192
|
-
// defineIdentityPlugin keeps app.use()'s return type EXACTLY the caller's server, so routes added
|
|
1193
|
-
//
|
|
1194
|
-
export const
|
|
1195
|
-
app.
|
|
1196
|
-
|
|
1211
|
+
// A plugin that mounts routes/hooks but adds NO context type: defineRouterPlugin (the clearer name for
|
|
1212
|
+
// defineIdentityPlugin) keeps app.use()'s return type EXACTLY the caller's server, so routes added after
|
|
1213
|
+
// .use() stay typed — and the typed client derived from them stays intact.
|
|
1214
|
+
export const scim = defineRouterPlugin("scim", (app) => {
|
|
1215
|
+
app.get("/scim/v2/Users", () => ({ Resources: [] })) // mount as a SIDE EFFECT (a runtime-only route)
|
|
1216
|
+
return app // return the app unchanged → caller's registry preserved
|
|
1217
|
+
})
|
|
1197
1218
|
|
|
1198
1219
|
// /a AND /b stay fully typed across the .use():
|
|
1199
|
-
const api = server().get("/a", () => ({ a: 1 })).use(
|
|
1220
|
+
const api = server().get("/a", () => ({ a: 1 })).use(scim).get("/b", () => ({ b: 2 }))
|
|
1200
1221
|
```
|
|
1201
1222
|
|
|
1202
1223
|
### Lifecycle hooks
|
|
@@ -3030,6 +3051,42 @@ Vue, Solid, Svelte). Nifra dedupes the active adapter's runtime in build and dev
|
|
|
3030
3051
|
[Dev & HMR](/docs/dev) and the `file:`-linked-package note in
|
|
3031
3052
|
`AGENTS.md`.
|
|
3032
3053
|
|
|
3054
|
+
###
|
|
3055
|
+
`client` resolves to `never` (or `data: never`)
|
|
3056
|
+
|
|
3057
|
+
The typed client is derived from your backend's type. Two things collapse it:
|
|
3058
|
+
|
|
3059
|
+
-
|
|
3060
|
+
**
|
|
3061
|
+
A route returns a raw `Response`.
|
|
3062
|
+
**
|
|
3063
|
+
That route's `data` infers `never` (Nifra can't see the shape). Return a
|
|
3064
|
+
plain object and shape the response with `c.set` — reach for `c.json` /
|
|
3065
|
+
`c.text` only for an error short-circuit (`throw` from a
|
|
3066
|
+
`derive` / `beforeHandle`), not a route's happy path. See
|
|
3067
|
+
[API & typed client](/docs/api).
|
|
3068
|
+
|
|
3069
|
+
-
|
|
3070
|
+
**A plugin widened the app's type.** A plugin that registers routes/hooks but whose return
|
|
3071
|
+
type isn't the concrete server (e.g. an untyped `app => app.onResponse(…)`)
|
|
3072
|
+
makes `.use()` return `Server` and the client loses your
|
|
3073
|
+
registry. Build it with `defineRouterPlugin(name, …)` (the clearer-named
|
|
3074
|
+
`defineIdentityPlugin`) so `.use()` returns your server unchanged and
|
|
3075
|
+
routes added after it stay typed. See
|
|
3076
|
+
[Plugins → keep types with defineRouterPlugin](/docs/plugins).
|
|
3077
|
+
|
|
3078
|
+
`nifra check` flags the raw-`Response` case; the plugin case surfaces as a
|
|
3079
|
+
`never` client at the call site.
|
|
3080
|
+
|
|
3081
|
+
####
|
|
3082
|
+
Call site rejects `{ query: {…} }`
|
|
3083
|
+
|
|
3084
|
+
If `api.thing.get({ query: { … } })` errors, the route declares no
|
|
3085
|
+
`query` schema — its query types as `never`, so the client can't accept query
|
|
3086
|
+
params. The error reads out the fix; add a schema to the route:
|
|
3087
|
+
`.get("/thing", { query: z.object({ page: z.string() }) }, h)`. Then
|
|
3088
|
+
`c.query` is the validated type and the client accepts a typed `query`.
|
|
3089
|
+
|
|
3033
3090
|
### Still stuck?
|
|
3034
3091
|
|
|
3035
3092
|
Run `nifra check --json` as the done-gate — it surfaces the import-chain leaks,
|
|
@@ -5543,7 +5600,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
5543
5600
|
|
|
5544
5601
|
## @nifrajs/core
|
|
5545
5602
|
|
|
5546
|
-
`AnyServer`, `attachWebSocket`, `commonSecretPatterns`, `Context`, `ContextForOp`, `ContractShape`, `CookieOptions`, `defineContract`, `defineIdentityPlugin`, `definePlugin`, `DurableObjectNamespaceLike`, `ExecutionContext`, `FRAMEWORK_NAME`, `FrameworkError`, `FrameworkName`, `Handler`, `HandlersFor`, `IdentityPlugin`, `implement`, `InferInput`, `InferOutput`, `jsonLogger`, `LogFields`, `Logger`, `Method`, `METHODS`, `Middleware`, `NifraPlugin`, `NifraWebSocket`, `NodeServeOutcome`, `OnRequestResult`, `OperationDef`, `Params`, `parseCookies`, `Platform`, `Prettify`, `redactLogFields`, `RedactOptions`, `Registry`, `RegistryFor`, `RegistryFromImpl`, `ResponseControls`, `ResponseDef`, `robots`, `RobotsOptions`, `RobotsRule`, `RouteConfigError`, `RouteConfigErrorCode`, `RouteDescriptor`, `RouteInfo`, `Router`, `RouterMatch`, `RouteSchema`, `RunningServer`, `ScheduledController`, `ScheduledHandler`, `serializeCookie`, `server`, `Server`, `ServerOptions`, `SignatureEncoding`, `signValue`, `silentLogger`, `sitemap`, `SitemapChangeFreq`, `SitemapEntry`, `SitemapOptions`, `sse`, `SSEContext`, `SSEInit`, `SSEMessage`, `SSEStream`, `StandardIssue`, `StandardResult`, `StandardSchemaV1`, `StandardTypes`, `StandardWebSocket`, `toFetchHandler`, `TopicRegistry`, `unsignValue`, `validateStandard`, `ValidationOutcome`, `verifyWebhook`, `VerifyWebhookOptions`, `Version`, `VERSION`, `WebhookFailureReason`, `WebhookProvider`, `WebhookResult`, `WebSocketContext`, `WebSocketData`, `WebSocketHandler`, `WebSocketUpgradeOutcome`
|
|
5603
|
+
`AnyServer`, `attachWebSocket`, `commonSecretPatterns`, `Context`, `ContextForOp`, `ContractShape`, `CookieOptions`, `defineContract`, `defineIdentityPlugin`, `definePlugin`, `defineRouterPlugin`, `DurableObjectNamespaceLike`, `ExecutionContext`, `FRAMEWORK_NAME`, `FrameworkError`, `FrameworkName`, `Handler`, `HandlersFor`, `IdentityPlugin`, `implement`, `InferInput`, `InferOutput`, `jsonLogger`, `LogFields`, `Logger`, `Method`, `METHODS`, `Middleware`, `NifraPlugin`, `NifraWebSocket`, `NodeServeOutcome`, `OnRequestResult`, `OperationDef`, `Params`, `parseCookies`, `Platform`, `Prettify`, `redactLogFields`, `RedactOptions`, `Registry`, `RegistryFor`, `RegistryFromImpl`, `ResponseControls`, `ResponseDef`, `robots`, `RobotsOptions`, `RobotsRule`, `RouteConfigError`, `RouteConfigErrorCode`, `RouteDescriptor`, `RouteInfo`, `Router`, `RouterMatch`, `RouteSchema`, `RunningServer`, `ScheduledController`, `ScheduledHandler`, `serializeCookie`, `server`, `Server`, `ServerOptions`, `SignatureEncoding`, `signValue`, `silentLogger`, `sitemap`, `SitemapChangeFreq`, `SitemapEntry`, `SitemapOptions`, `sse`, `SSEContext`, `SSEInit`, `SSEMessage`, `SSEStream`, `StandardIssue`, `StandardResult`, `StandardSchemaV1`, `StandardTypes`, `StandardWebSocket`, `toFetchHandler`, `TopicRegistry`, `unsignValue`, `validateStandard`, `ValidationOutcome`, `verifyWebhook`, `VerifyWebhookOptions`, `Version`, `VERSION`, `WebhookFailureReason`, `WebhookProvider`, `WebhookResult`, `WebSocketContext`, `WebSocketData`, `WebSocketHandler`, `WebSocketUpgradeOutcome`
|
|
5547
5604
|
|
|
5548
5605
|
## @nifrajs/cron
|
|
5549
5606
|
|
|
@@ -5569,6 +5626,10 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
5569
5626
|
|
|
5570
5627
|
`batch`, `BindableElement`, `BindableRoot`, `bindScope`, `computed`, `effect`, `island`, `IslandContext`, `IslandHost`, `IslandScope`, `IslandSetup`, `islandState`, `mountIslands`, `signal`, `Signal`
|
|
5571
5628
|
|
|
5629
|
+
## @nifrajs/mcp
|
|
5630
|
+
|
|
5631
|
+
`bridgeScript`, `createMcpServer`, `CreateMcpServerOptions`, `defineMcpTool`, `DefineMcpToolOptions`, `defineMcpWidget`, `DefineMcpWidgetOptions`, `McpAppBridge`, `McpHttpOptions`, `McpServer`, `McpToolHandlerResult`, `McpUiIntent`, `McpWidget`, `respondMcpHttp`, `uiResourceMeta`, `widgetDocument`
|
|
5632
|
+
|
|
5572
5633
|
## @nifrajs/middleware
|
|
5573
5634
|
|
|
5574
5635
|
`apiKey`, `ApiKeyStaticOptions`, `ApiKeyVerifyOptions`, `appendTrailingSlash`, `AuthPlugin`, `basicAuth`, `BasicAuthPlugin`, `BasicAuthStaticOptions`, `BasicAuthVerifyOptions`, `bearer`, `BearerOptions`, `bodyLimit`, `BodyLimitOptions`, `buildOpenApiDocument`, `cache`, `cacheControl`, `CacheControlOptions`, `CachedResponse`, `CacheOptions`, `combine`, `Composable`, `compression`, `CompressionOptions`, `cors`, `CorsOptions`, `createCsrfToken`, `csrf`, `CsrfOptions`, `etag`, `ETagOptions`, `healthcheck`, `HealthcheckOptions`, `idempotency`, `IdempotencyClaim`, `IdempotencyOptions`, `IdempotencyRecord`, `IdempotencyStore`, `IpMatcher`, `ipRestriction`, `IpRestrictionOptions`, `jwk`, `JwkKey`, `jwks`, `JwksOptions`, `jwt`, `JwtAlgorithm`, `JwtClaims`, `JwtHeader`, `JwtKeyResolver`, `JwtOptions`, `JwtPlugin`, `JwtVerificationKey`, `language`, `LanguageMatch`, `LanguageOptions`, `logger`, `LoggerOptions`, `MemoryIdempotencyStore`, `MemoryIdempotencyStoreOptions`, `MemoryResponseCache`, `MemoryResponseCacheOptions`, `MemoryStore`, `MemoryStoreOptions`, `methodOverride`, `MethodOverrideOptions`, `namedCombine`, `openapi`, `OpenApiInfo`, `OpenApiOptions`, `OpenApiServer`, `OpenApiTag`, `OpenApiUiOptions`, `pickLanguage`, `poweredBy`, `PoweredByOptions`, `prettyJson`, `PrettyJsonOptions`, `rateLimit`, `RateLimitOptions`, `RateLimitResult`, `RateLimitStore`, `requestId`, `RequestIdOptions`, `RequestLogFields`, `responseCache`, `ResponseCacheStore`, `RouteLike`, `securityHeaders`, `SecurityHeadersOptions`, `SecurityRequirement`, `timing`, `TimingControls`, `TimingMetric`, `TimingOptions`, `TrailingSlashOptions`, `trimTrailingSlash`, `tryVerifyJwt`, `VerifiedJwt`, `verifyCsrfToken`, `verifyJwt`, `VerifyJwtOptions`, `VerifyJwtResult`
|
|
@@ -5595,7 +5656,7 @@ done-gate, or `nifra mcp` to give the agent live project tools.
|
|
|
5595
5656
|
|
|
5596
5657
|
## @nifrajs/web
|
|
5597
5658
|
|
|
5598
|
-
`Action`, `ACTION_GLOBAL`, `apiKey`, `buildManifest`, `CachedResponse`, `CacheStore`, `canonical`, `clientEntry`, `ClientRouter`, `ClientRouterOptions`, `createClientRouter`, `createMatcher`, `createQueryClient`, `createWebApp`, `CreateWebAppOptions`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_DEV_PORT`, `defer`, `Deferred`, `disableDraft`, `DRAFT_COOKIE`, `DraftCookieControls`, `enableDraft`, `EnableDraftOptions`, `enumeratePrerenderedPaths`, `enumerateStaticRoutes`, `Fetcher`, `FetcherState`, `FetchRouteData`, `filePathToPattern`, `filePathToPatterns`, `FontDisplay`, `fontFace`, `FontFace`, `fontPreload`, `FontPreloadInput`, `FontSource`, `generateClientEntry`, `GenerateClientEntryOptions`, `generateServerManifest`, `GenerateServerManifestOptions`, `GetStaticPaths`, `hashQueryKey`, `isDraftEnabled`, `ISR_REVALIDATE_HEADER`, `ISR_STATUS_HEADER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `jsonLd`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `LayoutEntry`, `LinkDescriptor`, `Loader`, `LoaderContext`, `manifest`, `Manifest`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `mergeHeads`, `meta`, `Meta`, `MetaArgs`, `MetaInput`, `MountRouterOptions`, `openGraph`, `OpenGraphInput`, `PRE_HYDRATION_GUARD`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryState`, `QueryStatus`, `redirect`, `REDIRECT_HEADER`, `RedirectOptions`, `RenderAdapter`, `RenderedPage`, `renderPage`, `RenderPageOptions`, `renderPageResult`, `RenderProps`, `resolveMeta`, `revalidate`, `REVALIDATE_HEADER`, `revalidateEndpoint`, `RevalidateEndpointOptions`, `RevalidateResult`, `ROUTE_GLOBAL`, `RouteEntry`, `RouteMatch`, `RouteModule`, `RoutePattern`, `RouterState`, `ScriptDescriptor`, `serializeData`, `ServerOnly`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `Submission`, `SubmitOptions`, `withISR`
|
|
5659
|
+
`Action`, `ACTION_GLOBAL`, `apiKey`, `buildManifest`, `CachedResponse`, `CacheStore`, `canonical`, `clientEntry`, `ClientRouter`, `ClientRouterOptions`, `createClientRouter`, `createMatcher`, `createQueryClient`, `createWebApp`, `CreateWebAppOptions`, `DATA_GLOBAL`, `DATA_HEADER`, `DEFAULT_DEV_PORT`, `defer`, `Deferred`, `disableDraft`, `DRAFT_COOKIE`, `DraftCookieControls`, `enableDraft`, `EnableDraftOptions`, `enumeratePrerenderedPaths`, `enumerateStaticRoutes`, `Fetcher`, `FetcherState`, `FetchRouteData`, `filePathToPattern`, `filePathToPatterns`, `FontDisplay`, `fontFace`, `FontFace`, `fontPreload`, `FontPreloadInput`, `FontSource`, `generateClientEntry`, `GenerateClientEntryOptions`, `generateServerManifest`, `GenerateServerManifestOptions`, `GetStaticPaths`, `hashQueryKey`, `isDraftEnabled`, `ISR_REVALIDATE_HEADER`, `ISR_STATUS_HEADER`, `ISRApp`, `ISROptions`, `ISRPlatform`, `jsonLd`, `KVCacheStore`, `KVCacheStoreOptions`, `KVNamespaceLike`, `LayoutEntry`, `LinkDescriptor`, `Loader`, `LoaderContext`, `manifest`, `Manifest`, `MemoryCacheStore`, `MemoryCacheStoreOptions`, `mergeHeads`, `meta`, `Meta`, `MetaArgs`, `MetaInput`, `MountRouterOptions`, `openGraph`, `OpenGraphInput`, `PRE_HYDRATION_GUARD`, `QueryClient`, `QueryClientOptions`, `QueryHandle`, `QueryState`, `QueryStatus`, `redirect`, `REDIRECT_HEADER`, `RedirectOptions`, `RenderAdapter`, `RenderedPage`, `renderPage`, `RenderPageOptions`, `renderPageResult`, `RenderProps`, `resolveMeta`, `revalidate`, `REVALIDATE_HEADER`, `revalidateEndpoint`, `RevalidateEndpointOptions`, `RevalidateResult`, `ROUTE_GLOBAL`, `RouteEntry`, `RouteMatch`, `RouteModule`, `RoutePattern`, `RouterState`, `routeStyles`, `ScriptDescriptor`, `serializeData`, `ServerOnly`, `StaticPath`, `StaticPaths`, `StaticRoutes`, `styles`, `Submission`, `SubmitOptions`, `withISR`
|
|
5599
5660
|
|
|
5600
5661
|
## @nifrajs/web-preact
|
|
5601
5662
|
|