@nifrajs/cli 5.9.0 → 5.10.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/CHANGELOG.md +57 -0
- package/dist/check-diagnostics.d.ts +1 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +4 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +1 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +8 -1
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +7 -2
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -8
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +1 -5
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +2 -21
- package/dist/command-catalog.js.map +1 -1
- package/dist/internal/source-facts.d.ts +30 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +127 -0
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/load.d.ts +2 -0
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +5 -0
- package/dist/load.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-tool-meta.d.ts.map +1 -1
- package/dist/mcp-tool-meta.js +0 -1
- package/dist/mcp-tool-meta.js.map +1 -1
- package/dist/recipes/5.10.0.d.ts +12 -0
- package/dist/recipes/5.10.0.d.ts.map +1 -0
- package/dist/recipes/5.10.0.js +44 -0
- package/dist/recipes/5.10.0.js.map +1 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +3 -0
- package/dist/review.js.map +1 -1
- package/dist/rules/codes.d.ts +3 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +3 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/explanations.d.ts.map +1 -1
- package/dist/rules/explanations.js +15 -0
- package/dist/rules/explanations.js.map +1 -1
- package/dist/rules/internal-links.d.ts +5 -0
- package/dist/rules/internal-links.d.ts.map +1 -0
- package/dist/rules/internal-links.js +418 -0
- package/dist/rules/internal-links.js.map +1 -0
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +20 -0
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/server-fn-namespace.d.ts +8 -0
- package/dist/rules/server-fn-namespace.d.ts.map +1 -0
- package/dist/rules/server-fn-namespace.js +43 -0
- package/dist/rules/server-fn-namespace.js.map +1 -0
- package/dist/rules/source-scan.d.ts +29 -0
- package/dist/rules/source-scan.d.ts.map +1 -0
- package/dist/rules/source-scan.js +38 -0
- package/dist/rules/source-scan.js.map +1 -0
- package/dist/rules/text-slot-boolean.d.ts.map +1 -1
- package/dist/rules/text-slot-boolean.js +21 -43
- package/dist/rules/text-slot-boolean.js.map +1 -1
- package/dist/source-rewrites.d.ts.map +1 -1
- package/dist/source-rewrites.js +118 -3
- package/dist/source-rewrites.js.map +1 -1
- package/dist/typecheck-coverage.d.ts +9 -0
- package/dist/typecheck-coverage.d.ts.map +1 -1
- package/dist/typecheck-coverage.js +16 -0
- package/dist/typecheck-coverage.js.map +1 -1
- package/docs/examples.json +19 -7
- package/docs/llms-full.txt +555 -200
- package/docs/types.json +560 -115
- package/package.json +11 -11
- package/src/check-diagnostics.ts +5 -0
- package/src/check-scan.ts +9 -1
- package/src/check.ts +15 -3
- package/src/cli.ts +16 -8
- package/src/command-catalog.ts +2 -26
- package/src/internal/source-facts.ts +155 -0
- package/src/load.ts +9 -0
- package/src/mcp-http.ts +1 -1
- package/src/mcp-tool-meta.ts +0 -1
- package/src/recipes/5.10.0.ts +45 -0
- package/src/recipes/index.ts +2 -0
- package/src/review.ts +3 -0
- package/src/rules/codes.ts +3 -0
- package/src/rules/explanations.ts +15 -0
- package/src/rules/internal-links.ts +490 -0
- package/src/rules/legacy.ts +21 -0
- package/src/rules/server-fn-namespace.ts +47 -0
- package/src/rules/source-scan.ts +66 -0
- package/src/rules/text-slot-boolean.ts +26 -42
- package/src/source-rewrites.ts +133 -4
- package/src/typecheck-coverage.ts +23 -0
- package/dist/sync-routes.d.ts +0 -29
- package/dist/sync-routes.d.ts.map +0 -1
- package/dist/sync-routes.js +0 -56
- package/dist/sync-routes.js.map +0 -1
- package/src/sync-routes.ts +0 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "The nifra CLI - zero-config dev/build/start for a nifra app (`nifra dev`, `nifra build`, `nifra start`).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -70,16 +70,16 @@
|
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@nifrajs/client": "5.
|
|
74
|
-
"@nifrajs/core": "5.
|
|
75
|
-
"@nifrajs/agent-review": "5.
|
|
76
|
-
"@nifrajs/i18n": "5.
|
|
77
|
-
"@nifrajs/mcp": "5.
|
|
78
|
-
"@nifrajs/mcp-db": "5.
|
|
79
|
-
"@nifrajs/runner": "5.
|
|
80
|
-
"@nifrajs/schema": "5.
|
|
81
|
-
"@nifrajs/testing": "5.
|
|
82
|
-
"@nifrajs/web": "5.
|
|
73
|
+
"@nifrajs/client": "5.10.0",
|
|
74
|
+
"@nifrajs/core": "5.10.0",
|
|
75
|
+
"@nifrajs/agent-review": "5.10.0",
|
|
76
|
+
"@nifrajs/i18n": "5.10.0",
|
|
77
|
+
"@nifrajs/mcp": "5.10.0",
|
|
78
|
+
"@nifrajs/mcp-db": "5.10.0",
|
|
79
|
+
"@nifrajs/runner": "5.10.0",
|
|
80
|
+
"@nifrajs/schema": "5.10.0",
|
|
81
|
+
"@nifrajs/testing": "5.10.0",
|
|
82
|
+
"@nifrajs/web": "5.10.0"
|
|
83
83
|
},
|
|
84
84
|
"repository": {
|
|
85
85
|
"type": "git",
|
package/src/check-diagnostics.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { freezeProjectFacts, type ProjectFactsSeed } from "./project-facts.ts"
|
|
|
25
25
|
import { contractVisibilityRule } from "./rules/contract-visibility.ts"
|
|
26
26
|
import { dataGuardRules } from "./rules/data-guard.ts"
|
|
27
27
|
import { parseRulePacks, runRuleRegistry } from "./rules/index.ts"
|
|
28
|
+
import { internalLinkRules } from "./rules/internal-links.ts"
|
|
28
29
|
import { islandRules } from "./rules/islands.ts"
|
|
29
30
|
import { retiredLayoutRule } from "./rules/layout.ts"
|
|
30
31
|
import { LEGACY_RULE_CODES, LEGACY_RULE_ORDER, legacyRules } from "./rules/legacy.ts"
|
|
@@ -35,6 +36,7 @@ import { routeStatementRule } from "./rules/route-statement.ts"
|
|
|
35
36
|
import { routeRules } from "./rules/routes.ts"
|
|
36
37
|
import { secretRules } from "./rules/secrets.ts"
|
|
37
38
|
import { securityRules } from "./rules/security.ts"
|
|
39
|
+
import { serverFnNamespaceRule } from "./rules/server-fn-namespace.ts"
|
|
38
40
|
import { swapRules } from "./rules/swap.ts"
|
|
39
41
|
import { textSlotBooleanRule } from "./rules/text-slot-boolean.ts"
|
|
40
42
|
import { undeclaredResponseRule } from "./rules/undeclared-response.ts"
|
|
@@ -381,6 +383,7 @@ export interface CheckTypecheckResult {
|
|
|
381
383
|
/** TypeScript sources found with no tsconfig.json to typecheck them. */
|
|
382
384
|
readonly sourcesWithoutTsconfig?: number
|
|
383
385
|
readonly outsideProgram?: readonly string[]
|
|
386
|
+
readonly routeTableOutsideProgram?: string
|
|
384
387
|
}
|
|
385
388
|
|
|
386
389
|
export interface CheckAnalysisInput {
|
|
@@ -507,6 +510,8 @@ export async function collectCheckDiagnostics(
|
|
|
507
510
|
routeStatementRule,
|
|
508
511
|
undeclaredResponseRule,
|
|
509
512
|
textSlotBooleanRule,
|
|
513
|
+
...internalLinkRules,
|
|
514
|
+
serverFnNamespaceRule,
|
|
510
515
|
...zoneRules,
|
|
511
516
|
...dataGuardRules,
|
|
512
517
|
...secretRules,
|
package/src/check-scan.ts
CHANGED
|
@@ -78,7 +78,7 @@ const IGNORED_DIR =
|
|
|
78
78
|
// legitimately drives `fetch`, hand-rolls a client, and calls a route directly. It is NOT excluded from
|
|
79
79
|
// `nifra doctor`: tsc typechecks tests, so an import a test declares nowhere is a real broken build.
|
|
80
80
|
const TEST_FILE = /\.(test|spec)\.[cm]?[jt]sx?$/
|
|
81
|
-
const IGNORED = new RegExp(`${IGNORED_DIR.source}|${TEST_FILE.source}`)
|
|
81
|
+
export const IGNORED = new RegExp(`${IGNORED_DIR.source}|${TEST_FILE.source}`)
|
|
82
82
|
|
|
83
83
|
/** Paths crossing the scanner boundary are project-relative identifiers, not filesystem paths. Keep
|
|
84
84
|
* them stable across runtimes so rules, diagnostics, ignore globs, and import chains have one shape. */
|
|
@@ -2150,6 +2150,14 @@ function writesTo(ts: TypeScriptApi, root: TSApi.Node, name: string): SqlWrite[]
|
|
|
2150
2150
|
}
|
|
2151
2151
|
|
|
2152
2152
|
function mentionsName(ts: TypeScriptApi, node: TSApi.Node, name: string): boolean {
|
|
2153
|
+
// A member/key named like the variable does not read that variable (`record = client.record()`).
|
|
2154
|
+
if (ts.isPropertyAccessExpression(node)) return mentionsName(ts, node.expression, name)
|
|
2155
|
+
if (ts.isPropertyAssignment(node)) {
|
|
2156
|
+
return (
|
|
2157
|
+
mentionsName(ts, node.initializer, name) ||
|
|
2158
|
+
(ts.isComputedPropertyName(node.name) && mentionsName(ts, node.name.expression, name))
|
|
2159
|
+
)
|
|
2160
|
+
}
|
|
2153
2161
|
if (ts.isIdentifier(node)) return node.text === name
|
|
2154
2162
|
return ts.forEachChild(node, (child) => mentionsName(ts, child, name) || undefined) === true
|
|
2155
2163
|
}
|
package/src/check.ts
CHANGED
|
@@ -50,7 +50,12 @@ import {
|
|
|
50
50
|
import type { ContractCheckFacts, ProjectFactsSeed } from "./project-facts.ts"
|
|
51
51
|
import { RULE_CODES } from "./rules/codes.ts"
|
|
52
52
|
import { sourceIndex } from "./rules/index.ts"
|
|
53
|
-
import {
|
|
53
|
+
import {
|
|
54
|
+
filesOutsideProgram,
|
|
55
|
+
routeTableOutsideProgram,
|
|
56
|
+
splitListedFiles,
|
|
57
|
+
typecheckProjects,
|
|
58
|
+
} from "./typecheck-coverage.ts"
|
|
54
59
|
|
|
55
60
|
export type {
|
|
56
61
|
CheckAnalysisInput,
|
|
@@ -110,6 +115,8 @@ interface TypecheckResult {
|
|
|
110
115
|
readonly programFiles?: readonly string[]
|
|
111
116
|
/** Zoned TypeScript files outside the program, project-relative: the typecheck never read them. */
|
|
112
117
|
readonly outsideProgram?: readonly string[]
|
|
118
|
+
/** The generated route table, when it exists and the program does not hold it. */
|
|
119
|
+
readonly routeTableOutsideProgram?: string
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
/**
|
|
@@ -384,7 +391,7 @@ function withoutTsconfig(
|
|
|
384
391
|
function withProgramCoverage(
|
|
385
392
|
cwd: string,
|
|
386
393
|
result: TypecheckResult,
|
|
387
|
-
sourceFiles: ReadonlyArray<{ readonly file: string }>,
|
|
394
|
+
sourceFiles: ReadonlyArray<{ readonly file: string; readonly content: string }>,
|
|
388
395
|
checkConfig: CheckConfig,
|
|
389
396
|
): TypecheckResult {
|
|
390
397
|
const { programFiles, ...rest } = result
|
|
@@ -395,7 +402,12 @@ function withProgramCoverage(
|
|
|
395
402
|
sourceFiles.map((source) => source.file),
|
|
396
403
|
programFiles,
|
|
397
404
|
).filter((file) => !ignore?.some((pattern) => safeIgnoreGlobMatch(pattern, file)))
|
|
398
|
-
|
|
405
|
+
const table = routeTableOutsideProgram(cwd, programFiles, sourceFiles)
|
|
406
|
+
return {
|
|
407
|
+
...rest,
|
|
408
|
+
...(outside.length === 0 ? {} : { outsideProgram: outside }),
|
|
409
|
+
...(table === undefined ? {} : { routeTableOutsideProgram: table }),
|
|
410
|
+
}
|
|
399
411
|
}
|
|
400
412
|
|
|
401
413
|
/** Build the rule input from one source walk and the other check-wide scans. */
|
package/src/cli.ts
CHANGED
|
@@ -159,6 +159,8 @@ Usage:
|
|
|
159
159
|
_routes.json. The server entry is generated from your
|
|
160
160
|
backend/framework.ts (adapter) + backend/app.ts + routes/.
|
|
161
161
|
--report prints a per-chunk size + gzip table (biggest first).
|
|
162
|
+
Vercel defaults to Edge; export vercelRuntime = "node" from
|
|
163
|
+
nifra.config.ts for ordinary Node.js 22 serverless SSR.
|
|
162
164
|
[--vite | --bun] Force the bundler. Without a flag it follows your config: Bun
|
|
163
165
|
(faster, Bun-native) unless your ONLY transforms are
|
|
164
166
|
\`vitePlugins\`, which the Bun build cannot run - then Vite,
|
|
@@ -238,9 +240,6 @@ Usage:
|
|
|
238
240
|
nifra sync-manifest Regenerate a committed web server-manifest.ts from routes/ WITHOUT
|
|
239
241
|
a full build - clears server-manifest drift after a route add/rename
|
|
240
242
|
(a new hydrating component still needs a full build).
|
|
241
|
-
nifra sync-routes Regenerate nifra-routes.d.ts from routes/ so navigate({ to, search })
|
|
242
|
-
is typed against each static route's searchSchema (a stale shape is a
|
|
243
|
-
tsc error). Include the file in your tsconfig. Pure file write.
|
|
244
243
|
nifra snapshot [--out <file>] Write the backend's API contract (routes + schemas) as plain
|
|
245
244
|
JSON - the baseline for \`nifra diff\`. Default api-snapshot.json.
|
|
246
245
|
nifra diff [<baseline>] [--json] Breaking-change gate: re-snapshot the contract and compare
|
|
@@ -310,14 +309,15 @@ Usage:
|
|
|
310
309
|
(--zones keeps them in place and lists them in package.json
|
|
311
310
|
"nifra.zones"). Dry-run by default; --write applies.
|
|
312
311
|
nifra scaffold hole <route> <name> [--shared] [--interactive] [--timeout <ms>] [--server] [--json]
|
|
313
|
-
|
|
312
|
+
Add a partially prerendered hole to a route whose
|
|
314
313
|
backend half exports shellLoader - its definition and <Hole> in
|
|
315
314
|
the page, its loader and output schema in the backend half. A
|
|
316
315
|
Vue or Svelte page gets the code to paste; --server writes a
|
|
317
316
|
React server component for the hole.
|
|
318
317
|
nifra types [--check] [--json] Generate each route's ./+types module under .nifra/types: its
|
|
319
318
|
params, the data its output schemas let through, and api typed
|
|
320
|
-
by backend/app.ts
|
|
319
|
+
by backend/app.ts, plus routes.d.ts, the table href() checks
|
|
320
|
+
links against. dev, build and check refresh them too;
|
|
321
321
|
--check fails when one is stale.
|
|
322
322
|
nifra schemas [--write] [--check] [--json]
|
|
323
323
|
Draft loaderOutput/actionOutput from each loader's and
|
|
@@ -354,7 +354,7 @@ set in the process environment is never overwritten by a file.
|
|
|
354
354
|
${renderCommandCatalogHelp()}`
|
|
355
355
|
|
|
356
356
|
// Kept in lockstep with packages/cli/package.json by check:publish's version-consistency gate.
|
|
357
|
-
const CLI_VERSION = "5.
|
|
357
|
+
const CLI_VERSION = "5.10.0"
|
|
358
358
|
|
|
359
359
|
// A render adapter + nifra server are opaque to the CLI (it just forwards them); cast at the seam.
|
|
360
360
|
const asAdapter = (v: unknown): RenderAdapter => v as RenderAdapter
|
|
@@ -830,7 +830,9 @@ async function buildForTarget(
|
|
|
830
830
|
flag: string | undefined,
|
|
831
831
|
flags: Flags,
|
|
832
832
|
): Promise<void> {
|
|
833
|
-
const { parseBuildTarget, renderSizeReport } = await import(
|
|
833
|
+
const { parseBuildTarget, renderSizeReport, validateVercelRuntime } = await import(
|
|
834
|
+
"@nifrajs/web/build"
|
|
835
|
+
)
|
|
834
836
|
const target = parseBuildTarget(
|
|
835
837
|
flag ?? app.framework.target ?? "bun",
|
|
836
838
|
flag === undefined ? "target in nifra.config.ts" : "--target",
|
|
@@ -839,7 +841,13 @@ async function buildForTarget(
|
|
|
839
841
|
throw new Error("[nifra] `nifra build` takes `--vite` or `--bun`, not both.")
|
|
840
842
|
}
|
|
841
843
|
const { framework: fw } = app
|
|
844
|
+
validateVercelRuntime(target, fw.vercelRuntime)
|
|
842
845
|
if (fw.componentPipeline !== undefined) {
|
|
846
|
+
// The component pipeline already owns its Vercel Node handler; this selector is ordinary SSR only.
|
|
847
|
+
if (fw.vercelRuntime !== undefined)
|
|
848
|
+
throw new Error(
|
|
849
|
+
"[nifra/components] vercelRuntime selects ordinary SSR only; omit it for the component pipeline",
|
|
850
|
+
)
|
|
843
851
|
if (flags.bun)
|
|
844
852
|
throw new Error(
|
|
845
853
|
"[nifra/components] Components require the Vite 8 pipeline; Bun remains a server runtime",
|
|
@@ -954,6 +962,7 @@ async function buildForTarget(
|
|
|
954
962
|
...(fw.cssCodeSplit !== undefined ? { cssCodeSplit: fw.cssCodeSplit } : {}),
|
|
955
963
|
...(fw.cssLoading !== undefined ? { cssLoading: fw.cssLoading } : {}),
|
|
956
964
|
...(fw.clientIp !== undefined ? { clientIp: fw.clientIp } : {}),
|
|
965
|
+
...(fw.vercelRuntime !== undefined ? { vercelRuntime: fw.vercelRuntime } : {}),
|
|
957
966
|
...(fw.selfHost !== undefined ? { selfHost: fw.selfHost } : {}),
|
|
958
967
|
live: fw.live?.clientEntry,
|
|
959
968
|
// Prerendering drives a built app: the static target is made of its pages, and a bun or node server
|
|
@@ -1150,7 +1159,6 @@ const READ_ONLY_COMMANDS: ReadonlySet<string> = new Set([
|
|
|
1150
1159
|
"openapi",
|
|
1151
1160
|
"routes",
|
|
1152
1161
|
"sync-manifest",
|
|
1153
|
-
"sync-routes",
|
|
1154
1162
|
])
|
|
1155
1163
|
|
|
1156
1164
|
const HELD_OPEN_GRACE_MS = 2_000
|
package/src/command-catalog.ts
CHANGED
|
@@ -533,10 +533,6 @@ interface ContractsCommandOutput {
|
|
|
533
533
|
readonly present?: boolean
|
|
534
534
|
readonly vacuous?: boolean
|
|
535
535
|
}
|
|
536
|
-
interface SyncCommandOutput {
|
|
537
|
-
readonly ok: true
|
|
538
|
-
readonly results: readonly unknown[]
|
|
539
|
-
}
|
|
540
536
|
interface SyncManifestCommandOutput {
|
|
541
537
|
readonly ok: boolean
|
|
542
538
|
readonly results: readonly SyncManifestResult[]
|
|
@@ -1674,7 +1670,7 @@ const scaffoldSpec: CommandSpec<ScaffoldInput, HoleScaffoldResult> = {
|
|
|
1674
1670
|
required: ["ok", "page", "backend", "changed", "snippets", "next"],
|
|
1675
1671
|
}),
|
|
1676
1672
|
transports: ["cli"],
|
|
1677
|
-
stability: "
|
|
1673
|
+
stability: "stable",
|
|
1678
1674
|
argv: {
|
|
1679
1675
|
positionals: ["kind", "route", "name"],
|
|
1680
1676
|
flags: [
|
|
@@ -1785,7 +1781,7 @@ const targetSpec: CommandSpec<TargetInput, TargetOutput> = {
|
|
|
1785
1781
|
const typesSpec: CommandSpec<TypesInput, RouteTypesReport> = {
|
|
1786
1782
|
name: "types",
|
|
1787
1783
|
summary:
|
|
1788
|
-
"Generate each route's `./+types` module (params, schema-typed data, typed `api`); `--check` fails when one is stale.",
|
|
1784
|
+
"Generate each route's `./+types` module (params, schema-typed data, typed `api`) and `.nifra/types/routes.d.ts`, the route table `href()` checks links against; `--check` fails when one is stale.",
|
|
1789
1785
|
input: TYPES_SCHEMA,
|
|
1790
1786
|
output: output({
|
|
1791
1787
|
type: "object",
|
|
@@ -2031,25 +2027,6 @@ const syncManifestSpec: CommandSpec<SyncInput, SyncManifestCommandOutput> = {
|
|
|
2031
2027
|
success: (out) => out.ok,
|
|
2032
2028
|
}
|
|
2033
2029
|
|
|
2034
|
-
const syncRoutesSpec: CommandSpec<SyncInput, SyncCommandOutput> = {
|
|
2035
|
-
name: "sync-routes",
|
|
2036
|
-
summary: "Regenerate nifra-routes.d.ts so typed navigation follows route search schemas.",
|
|
2037
|
-
input: SYNC_SCHEMA,
|
|
2038
|
-
output: syncOutput(),
|
|
2039
|
-
transports: ["cli", "mcp"],
|
|
2040
|
-
stability: "stable",
|
|
2041
|
-
argv: SYNC_ARGV,
|
|
2042
|
-
async run(_value, ctx) {
|
|
2043
|
-
const result = await (await import("./sync-routes.ts")).syncRouteTypes(ctx.cwd)
|
|
2044
|
-
return { ok: true, results: result === null ? [] : [result] }
|
|
2045
|
-
},
|
|
2046
|
-
render: (out) => [
|
|
2047
|
-
out.results.length === 0
|
|
2048
|
-
? "nifra sync-routes: no routes/ directory found. Run from your project root."
|
|
2049
|
-
: `✓ checked ${out.results.length} route type output`,
|
|
2050
|
-
],
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
2030
|
const proveSpec: CommandSpec<ProveInput, ProjectWorkGraphResult> = {
|
|
2054
2031
|
name: "prove",
|
|
2055
2032
|
summary:
|
|
@@ -2209,7 +2186,6 @@ export const commandSpecs = Object.freeze([
|
|
|
2209
2186
|
diffSpec,
|
|
2210
2187
|
contractsSpec,
|
|
2211
2188
|
syncManifestSpec,
|
|
2212
|
-
syncRoutesSpec,
|
|
2213
2189
|
proveSpec,
|
|
2214
2190
|
replaySpec,
|
|
2215
2191
|
smokeSpec,
|
|
@@ -36,6 +36,28 @@ export interface TextSlotBooleanCoercion {
|
|
|
36
36
|
readonly path: string
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** An `<a href>` whose value is a path of this origin, from {@link SourceFacts.internalAnchors}. */
|
|
40
|
+
export interface InternalAnchor {
|
|
41
|
+
/** The start of the `href` attribute. */
|
|
42
|
+
readonly position: number
|
|
43
|
+
/** The path as written; each `${...}` of a template literal is {@link ANCHOR_HOLE}. */
|
|
44
|
+
readonly path: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Stands for one `${...}` in {@link InternalAnchor.path}. */
|
|
48
|
+
export const ANCHOR_HOLE = "\u0000"
|
|
49
|
+
|
|
50
|
+
/** A `serverFunctions("namespace", module)` mount of a `*.fn.ts` module, from {@link SourceFacts.serverFunctionMounts}. */
|
|
51
|
+
export interface ServerFunctionMount {
|
|
52
|
+
/** The start of the namespace literal. */
|
|
53
|
+
readonly position: number
|
|
54
|
+
/** The start of the `serverFunctions(...)` call, where a `nifra-expect` comment is written above. */
|
|
55
|
+
readonly callPosition: number
|
|
56
|
+
readonly namespace: string
|
|
57
|
+
/** The specifier the mounted module namespace was imported from. */
|
|
58
|
+
readonly specifier: string
|
|
59
|
+
}
|
|
60
|
+
|
|
39
61
|
export interface SourceFacts {
|
|
40
62
|
parse(file: string, content: string): TSApi.SourceFile | undefined
|
|
41
63
|
isValueImportAt(
|
|
@@ -92,6 +114,17 @@ export interface SourceFacts {
|
|
|
92
114
|
* another file is not followed.
|
|
93
115
|
*/
|
|
94
116
|
textSlotBooleanCoercions(source: TSApi.SourceFile): readonly TextSlotBooleanCoercion[]
|
|
117
|
+
/**
|
|
118
|
+
* The `serverFunctions("namespace", module)` calls in `source` whose `module` is a namespace import
|
|
119
|
+
* (`import * as todos from "./todos.fn"`) of a `*.fn` file. A module reached any other way is left out.
|
|
120
|
+
*/
|
|
121
|
+
serverFunctionMounts(source: TSApi.SourceFile): readonly ServerFunctionMount[]
|
|
122
|
+
/**
|
|
123
|
+
* The `<a>` elements of `source` whose `href` is a string or template literal that starts with
|
|
124
|
+
* exactly one `/`. A value that is built (`href={url}`, `href={href({ to })}`), an external URL, a
|
|
125
|
+
* `#hash` and a `//host` are left out.
|
|
126
|
+
*/
|
|
127
|
+
internalAnchors(source: TSApi.SourceFile): readonly InternalAnchor[]
|
|
95
128
|
/** Whether the function `source` exports as `name` returns a raw `Response` on some path. */
|
|
96
129
|
exportReturnsResponse(source: TSApi.SourceFile, name: string): boolean
|
|
97
130
|
/** Whether the `import` keyword at `position` starts a runtime `import(specifier)` call (true) or a
|
|
@@ -172,6 +205,9 @@ function routeRegistration(
|
|
|
172
205
|
return { name: node.expression.name, method, path: first.text, rest }
|
|
173
206
|
}
|
|
174
207
|
|
|
208
|
+
const SERVER_FN_MODULE_ID = "@nifrajs/web/fn"
|
|
209
|
+
const SERVER_FN_FILE = /\.fn(?:\.[cm]?[jt]sx?)?$/
|
|
210
|
+
|
|
175
211
|
const ZOD_MODULES: ReadonlySet<string> = new Set(["zod", "zod/v4", "zod/mini", "zod/v4/mini"])
|
|
176
212
|
|
|
177
213
|
/** The names `source` binds zod's namespace to (`z`), and those it binds zod's `coerce` to. */
|
|
@@ -202,6 +238,23 @@ function zodBindings(
|
|
|
202
238
|
return { namespaces, coerce }
|
|
203
239
|
}
|
|
204
240
|
|
|
241
|
+
/** Every name `source` declares other than by import: variables, parameters, functions and classes, any scope. */
|
|
242
|
+
function declaredNames(ts: TypeScriptApi, source: TSApi.SourceFile): Set<string> {
|
|
243
|
+
const names = new Set<string>()
|
|
244
|
+
const bind = (name: TSApi.BindingName): void => {
|
|
245
|
+
if (ts.isIdentifier(name)) names.add(name.text)
|
|
246
|
+
else for (const element of name.elements) if (ts.isBindingElement(element)) bind(element.name)
|
|
247
|
+
}
|
|
248
|
+
const visit = (node: TSApi.Node): void => {
|
|
249
|
+
if (ts.isVariableDeclaration(node) || ts.isParameter(node)) bind(node.name)
|
|
250
|
+
else if ((ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)) && node.name)
|
|
251
|
+
names.add(node.name.text)
|
|
252
|
+
ts.forEachChild(node, visit)
|
|
253
|
+
}
|
|
254
|
+
visit(source)
|
|
255
|
+
return names
|
|
256
|
+
}
|
|
257
|
+
|
|
205
258
|
/** The initializer of each variable of `source`, any scope, by name: the first one wins. */
|
|
206
259
|
function variableInitializers(
|
|
207
260
|
ts: TypeScriptApi,
|
|
@@ -747,6 +800,40 @@ export function createSourceFacts(
|
|
|
747
800
|
return routes.sort((a, b) => a.position - b.position)
|
|
748
801
|
}
|
|
749
802
|
|
|
803
|
+
const internalAnchors = (source: TSApi.SourceFile): readonly InternalAnchor[] => {
|
|
804
|
+
const found: InternalAnchor[] = []
|
|
805
|
+
const pathOf = (node: TSApi.Expression): string | undefined => {
|
|
806
|
+
if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return node.text
|
|
807
|
+
if (!ts.isTemplateExpression(node)) return undefined
|
|
808
|
+
return (
|
|
809
|
+
node.head.text + node.templateSpans.map((span) => ANCHOR_HOLE + span.literal.text).join("")
|
|
810
|
+
)
|
|
811
|
+
}
|
|
812
|
+
const visit = (node: TSApi.Node): void => {
|
|
813
|
+
if (
|
|
814
|
+
(ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) &&
|
|
815
|
+
ts.isIdentifier(node.tagName) &&
|
|
816
|
+
node.tagName.text === "a"
|
|
817
|
+
) {
|
|
818
|
+
for (const attribute of node.attributes.properties) {
|
|
819
|
+
if (!ts.isJsxAttribute(attribute) || attribute.name.getText(source) !== "href") continue
|
|
820
|
+
const init = attribute.initializer
|
|
821
|
+
if (init === undefined) continue
|
|
822
|
+
const path = ts.isStringLiteral(init)
|
|
823
|
+
? init.text
|
|
824
|
+
: ts.isJsxExpression(init) && init.expression !== undefined
|
|
825
|
+
? pathOf(init.expression)
|
|
826
|
+
: undefined
|
|
827
|
+
if (path?.startsWith("/") && !path.startsWith("//"))
|
|
828
|
+
found.push({ position: attribute.getStart(source), path })
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
ts.forEachChild(node, visit)
|
|
832
|
+
}
|
|
833
|
+
visit(source)
|
|
834
|
+
return found
|
|
835
|
+
}
|
|
836
|
+
|
|
750
837
|
const textSlotBooleanCoercions = (
|
|
751
838
|
source: TSApi.SourceFile,
|
|
752
839
|
): readonly TextSlotBooleanCoercion[] => {
|
|
@@ -853,6 +940,72 @@ export function createSourceFacts(
|
|
|
853
940
|
}
|
|
854
941
|
}
|
|
855
942
|
|
|
943
|
+
const serverFunctionMounts = (source: TSApi.SourceFile): readonly ServerFunctionMount[] => {
|
|
944
|
+
const callees = new Set<string>()
|
|
945
|
+
const members = new Set<string>()
|
|
946
|
+
const modules = new Map<string, string>()
|
|
947
|
+
for (const statement of source.statements) {
|
|
948
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))
|
|
949
|
+
continue
|
|
950
|
+
const clause = statement.importClause
|
|
951
|
+
if (clause === undefined || clause.isTypeOnly) continue
|
|
952
|
+
const specifier = statement.moduleSpecifier.text
|
|
953
|
+
const bindings = clause.namedBindings
|
|
954
|
+
if (bindings === undefined) continue
|
|
955
|
+
if (ts.isNamespaceImport(bindings)) {
|
|
956
|
+
if (specifier === SERVER_FN_MODULE_ID) members.add(bindings.name.text)
|
|
957
|
+
else if (SERVER_FN_FILE.test(specifier)) modules.set(bindings.name.text, specifier)
|
|
958
|
+
} else if (specifier === SERVER_FN_MODULE_ID) {
|
|
959
|
+
for (const element of bindings.elements) {
|
|
960
|
+
if (
|
|
961
|
+
!element.isTypeOnly &&
|
|
962
|
+
(element.propertyName ?? element.name).text === "serverFunctions"
|
|
963
|
+
)
|
|
964
|
+
callees.add(element.name.text)
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
if (modules.size === 0 || (callees.size === 0 && members.size === 0)) return []
|
|
969
|
+
// A name the file declares again (a local `serverFunctions`, a parameter called like the module) is
|
|
970
|
+
// not the import, whatever scope it sits in: leave those calls out rather than guess the scope.
|
|
971
|
+
for (const name of declaredNames(ts, source)) {
|
|
972
|
+
callees.delete(name)
|
|
973
|
+
members.delete(name)
|
|
974
|
+
modules.delete(name)
|
|
975
|
+
}
|
|
976
|
+
const mounts: ServerFunctionMount[] = []
|
|
977
|
+
const visit = (node: TSApi.Node): void => {
|
|
978
|
+
if (ts.isCallExpression(node)) {
|
|
979
|
+
const callee = node.expression
|
|
980
|
+
const [namespace, module] = node.arguments
|
|
981
|
+
if (
|
|
982
|
+
(ts.isIdentifier(callee)
|
|
983
|
+
? callees.has(callee.text)
|
|
984
|
+
: ts.isPropertyAccessExpression(callee) &&
|
|
985
|
+
ts.isIdentifier(callee.expression) &&
|
|
986
|
+
members.has(callee.expression.text) &&
|
|
987
|
+
callee.name.text === "serverFunctions") &&
|
|
988
|
+
namespace !== undefined &&
|
|
989
|
+
ts.isStringLiteralLike(namespace) &&
|
|
990
|
+
module !== undefined &&
|
|
991
|
+
ts.isIdentifier(module)
|
|
992
|
+
) {
|
|
993
|
+
const specifier = modules.get(module.text)
|
|
994
|
+
if (specifier !== undefined)
|
|
995
|
+
mounts.push({
|
|
996
|
+
position: namespace.getStart(source),
|
|
997
|
+
callPosition: node.getStart(source),
|
|
998
|
+
namespace: namespace.text,
|
|
999
|
+
specifier,
|
|
1000
|
+
})
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
ts.forEachChild(node, visit)
|
|
1004
|
+
}
|
|
1005
|
+
visit(source)
|
|
1006
|
+
return mounts
|
|
1007
|
+
}
|
|
1008
|
+
|
|
856
1009
|
return {
|
|
857
1010
|
parse,
|
|
858
1011
|
isValueImportAt,
|
|
@@ -863,6 +1016,8 @@ export function createSourceFacts(
|
|
|
863
1016
|
untypedResponseRoutes,
|
|
864
1017
|
undeclaredResponseRoutes,
|
|
865
1018
|
textSlotBooleanCoercions,
|
|
1019
|
+
internalAnchors,
|
|
1020
|
+
serverFunctionMounts,
|
|
866
1021
|
exportReturnsResponse,
|
|
867
1022
|
isDynamicImportAt,
|
|
868
1023
|
}
|
package/src/load.ts
CHANGED
|
@@ -71,6 +71,8 @@ export interface NifraFramework {
|
|
|
71
71
|
/** The deploy target `nifra build` emits without `--target` (default `"bun"`); `nifra target <t>`
|
|
72
72
|
* rewrites it. */
|
|
73
73
|
readonly target?: string
|
|
74
|
+
/** Ordinary Vercel SSR: Edge by default, or opt into a Node.js 22 serverless handler. */
|
|
75
|
+
readonly vercelRuntime?: "edge" | "node"
|
|
74
76
|
/** `"platform"` makes a `cloudflare` / `vercel` build read `c.clientIp` from the header that
|
|
75
77
|
* platform's edge overwrites (`cf-connecting-ip` / `x-real-ip`). Left out, an edge build has no
|
|
76
78
|
* caller address, so a per-caller `rateLimit` refuses every request. Declare it only while that edge
|
|
@@ -230,6 +232,13 @@ function assertFrameworkWebOptions(fw: Partial<NifraFramework>, configFile: stri
|
|
|
230
232
|
if (fw.target !== undefined && typeof fw.target !== "string") {
|
|
231
233
|
wrong("target", 'a deploy target name such as "bun"')
|
|
232
234
|
}
|
|
235
|
+
if (
|
|
236
|
+
fw.vercelRuntime !== undefined &&
|
|
237
|
+
fw.vercelRuntime !== "edge" &&
|
|
238
|
+
fw.vercelRuntime !== "node"
|
|
239
|
+
) {
|
|
240
|
+
wrong("vercelRuntime", '"edge" or "node" (only for target "vercel")')
|
|
241
|
+
}
|
|
233
242
|
if (fw.clientIp !== undefined && fw.clientIp !== "platform") {
|
|
234
243
|
wrong("clientIp", '"platform" (trust the edge platform\'s client-address header), or left out')
|
|
235
244
|
}
|
package/src/mcp-http.ts
CHANGED
|
@@ -30,7 +30,7 @@ export { docsTools } from "./mcp-docs-tools.ts"
|
|
|
30
30
|
export type { TypeEntry } from "./types-search.ts"
|
|
31
31
|
|
|
32
32
|
// Kept in lockstep with packages/cli/package.json by check:publish's version-consistency gate.
|
|
33
|
-
const VERSION = "5.
|
|
33
|
+
const VERSION = "5.10.0"
|
|
34
34
|
const SERVER_INFO = { name: "nifra-docs", version: VERSION }
|
|
35
35
|
// Derive the GET/health tool list from the tools actually served, so the line can never drift from them.
|
|
36
36
|
const docsHealth = (tools: McpTool[]): string =>
|
package/src/mcp-tool-meta.ts
CHANGED
|
@@ -177,7 +177,6 @@ export const PROJECT_TOOL_META: Readonly<Record<string, ToolMeta>> = {
|
|
|
177
177
|
},
|
|
178
178
|
},
|
|
179
179
|
nifra_sync_manifest: { annotations: WRITE, fields: { json: JSON_RESULT, dir: DIR } },
|
|
180
|
-
nifra_sync_routes: { annotations: WRITE, fields: { json: JSON_RESULT, dir: DIR } },
|
|
181
180
|
nifra_prove: {
|
|
182
181
|
annotations: EXECUTE,
|
|
183
182
|
fields: {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { UpgradeRecipe } from "./index.ts"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Upgrade recipe for Nifra 5.10.
|
|
5
|
+
*
|
|
6
|
+
* No import or dependency moves. Partial prerendering is stable, so `createWebApp` takes it as `ppr`
|
|
7
|
+
* and the `ppr-option` source rewrite moves `experimental: { ppr }`. In-app links are typed: `navigate`,
|
|
8
|
+
* `redirect` and React's `Link` take an `Href`, and the route table that types it replaces
|
|
9
|
+
* `RouteSearch`. The query cache sends nothing to the browser unless the app names the queries, and
|
|
10
|
+
* an identity change cancels a mutation still running; the notes say what an app sees differently.
|
|
11
|
+
*/
|
|
12
|
+
export const recipe: UpgradeRecipe = {
|
|
13
|
+
version: "5.10.0",
|
|
14
|
+
pins: [
|
|
15
|
+
{ match: "@nifrajs/", to: "5.10.0" },
|
|
16
|
+
{ match: "create-nifra", to: "5.10.0" },
|
|
17
|
+
{ match: "nifra", to: "5.10.0" },
|
|
18
|
+
],
|
|
19
|
+
importMoves: [],
|
|
20
|
+
sourceRewrites: ["ppr-option"],
|
|
21
|
+
affects: [
|
|
22
|
+
"@nifrajs/core",
|
|
23
|
+
"@nifrajs/client",
|
|
24
|
+
"@nifrajs/testing",
|
|
25
|
+
"@nifrajs/web",
|
|
26
|
+
"@nifrajs/web-react",
|
|
27
|
+
"@nifrajs/web-preact",
|
|
28
|
+
"@nifrajs/web-vue",
|
|
29
|
+
"@nifrajs/web-svelte",
|
|
30
|
+
"@nifrajs/web-solid",
|
|
31
|
+
"@nifrajs/cli",
|
|
32
|
+
"nifra",
|
|
33
|
+
],
|
|
34
|
+
notes: [
|
|
35
|
+
"Partial prerendering is stable: `createWebApp({ ppr: partialPrerendering(...) })` replaces `experimental: { ppr: partialPrerendering(...) }`, and the `experimental` option is removed. Passing it throws a `TypeError` that names `ppr`. The startup errors name `ppr.origin`, `ppr.deployment`, `ppr.store` and `ppr.storeSecret`. The `ppr-option` rewrite moves `experimental: { ppr }` in a `createWebApp` options literal; options with a spread, a second key under `experimental`, or an `experimental` built in another file are listed by line or left for you to check.",
|
|
36
|
+
'`navigate()`, `redirect()` and the React `Link`, `NavLink` and `Navigate` take an `Href`, built by `href({ to, params, search, hash })` from `@nifrajs/web` (or an adapter\'s `/router` entry), or by `rawHref(path)` for a same-origin path built elsewhere. A string path, a template literal and the `{ to, search }` form of `navigate` are compile errors, so `tsc` lists each call: `navigate("/users/7")` becomes `navigate(href({ to: "/users/:id", params: { id: "7" } }))`, `redirect("/login")` becomes `redirect(href({ to: "/login" }))`, `<Link to="/pricing">` becomes `<Link to={href({ to: "/pricing" })}>`, and `navigate({ to, search, replace: true })` becomes `navigate(href({ to, search }), { replace: true })`. `redirect(url, { external: true })` is unchanged. `resolveNavigate`, `NavigateTargetInput` and `NavigateSearchOf` are removed from `@nifrajs/web`. `Link` and `NavLink` render the anchor without an `href`, and log a `console.error`, when `to` is not a same-origin path; `rawHref` throws a `TypeError` for one. `tsc` cannot see plain anchors, so search for `href="/` and ``href={`/``.',
|
|
37
|
+
'`nifra dev`, `nifra build`, `nifra check` and `nifra types` write `.nifra/types/routes.d.ts`, which fills `RouteTable` with one `{ params, search }` entry per URL pattern, and `href()` reads it. A route file that imports no `./+types/...` module does not load it: `nifra check` warns when a source imports a navigation API and no program loads the table, and listing `.nifra/types/routes.d.ts` under `files` in tsconfig.json clears it. `RouteSearch`, `generateRouteSearchTypes`, `GenerateRouteSearchTypesOptions`, `nifra sync-routes` and the `nifra_sync_routes` MCP tool are removed: delete `nifra-routes.d.ts` and its tsconfig `include` entry, and move a hand-written `RouteSearch` entry to `RouteTable` as `"/path": { params: ...; search: ... }`. A route file whose name holds `#` or `?` is an error that names the file.',
|
|
38
|
+
"`dehydrate()` on a query client sends nothing unless `shouldDehydrateQuery` selects the queries, where a bare call sent every successful query, regular and infinite. Every dehydrated value is serialized into the page and readable by the visitor. Pass `shouldDehydrateQuery` naming the keys that are safe to send, or `() => true` when every successful query in that client is meant for the browser. Without it the browser starts with no cache for those queries and fetches them itself, so a component that rendered their data on the server can differ from it on the first client render.",
|
|
39
|
+
"A mutation still running when the visitor's identity changes, in this tab or another tab of the site, is cancelled: its `mutate` promise rejects with `MutationCancelledError`, and its `onSuccess`, `onError` and `onSettled` callbacks do not run. The mutation function takes a second argument, `{ signal }`, an `AbortSignal` that is aborted at that moment; pass it to `fetch` to stop the request. A call site that awaits `mutateAsync` across a sign-in or sign-out catches that error.",
|
|
40
|
+
'`nifra check` reports NF-C056 (error) for `serverFunctions("todo", todos)` where `todos` is a namespace import of `todos.fn.ts`: the client stubs call the namespace the file names, so a mount under another word answers 404 on every call. Rename the mount, or put `// nifra-expect NF-C056: <reason>` above a call kept on purpose.',
|
|
41
|
+
"Closing a modal route with Back shows the page kept under it as it was, and the route's loader is not called again for it, unless that page was loaded for a previous visitor or marked stale.",
|
|
42
|
+
'`nifra check` reports NF-C057 (warn) for an `<a href="/path">` that no page, backend route or file in `public/` serves, and NF-C058 (info) for one that is a page today, with the `href()` call that replaces it. Neither fails a check unless `--strict` is set for the warning. Raise, lower or silence either with `rules` in `nifra.config`, or keep one link as written with `rawHref(path)` or `// nifra-expect NF-C058: <reason>` above the attribute.',
|
|
43
|
+
"A path segment has one spelling in `getStaticPaths` output, the prerender report and written files, `enumerateStaticRoutes`, the typed client's path params and the requests `@nifrajs/testing` builds: characters outside `A-Za-z0-9 -._~!$&'()*+,:=@` are percent-encoded in upper-case hex, so `;`, `[`, `]` and `|` are escaped. A `getStaticPaths` entry that leaves out a param, or holds one no path can carry (`.`, `..`, a lone surrogate), is skipped, and the prerender report names the param. Adjacent route parameter values that the router would split differently are rejected, and translated pathnames refuse segments nested deeper than three percent-encodings.",
|
|
44
|
+
],
|
|
45
|
+
}
|
package/src/recipes/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { recipe as v5_6_0 } from "./5.6.0.ts"
|
|
|
21
21
|
import { recipe as v5_7_0 } from "./5.7.0.ts"
|
|
22
22
|
import { recipe as v5_8_0 } from "./5.8.0.ts"
|
|
23
23
|
import { recipe as v5_9_0 } from "./5.9.0.ts"
|
|
24
|
+
import { recipe as v5_10_0 } from "./5.10.0.ts"
|
|
24
25
|
|
|
25
26
|
/** A pin rule: every dependency whose name starts with `match` is set to version `to`. */
|
|
26
27
|
export interface PinRule {
|
|
@@ -101,6 +102,7 @@ const RECIPES: Record<string, UpgradeRecipe> = {
|
|
|
101
102
|
[v5_7_0.version]: v5_7_0,
|
|
102
103
|
[v5_8_0.version]: v5_8_0,
|
|
103
104
|
[v5_9_0.version]: v5_9_0,
|
|
105
|
+
[v5_10_0.version]: v5_10_0,
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
export function getRecipe(version: string): UpgradeRecipe | undefined {
|
package/src/review.ts
CHANGED
|
@@ -162,6 +162,9 @@ export const CHECK_CODES: Readonly<Record<string, ReviewCheckId>> = {
|
|
|
162
162
|
"NF-C045": "typed-client",
|
|
163
163
|
"NF-C054": "typed-client",
|
|
164
164
|
"NF-C055": "route-boundary",
|
|
165
|
+
"NF-C056": "route-boundary",
|
|
166
|
+
"NF-C057": "typed-client",
|
|
167
|
+
"NF-C058": "typed-client",
|
|
165
168
|
"NF-C046": "dependency",
|
|
166
169
|
"NF-D001": "dependency",
|
|
167
170
|
"NF-D002": "dependency",
|
package/src/rules/codes.ts
CHANGED
|
@@ -54,6 +54,9 @@ export const RULE_CODES = Object.freeze({
|
|
|
54
54
|
"NF-C053": "Partially prerendered page reads the request",
|
|
55
55
|
"NF-C054": "Route without a response schema in a published document",
|
|
56
56
|
"NF-C055": "zod coerce.boolean() reads request text",
|
|
57
|
+
"NF-C056": "serverFunctions namespace differs from its module's filename",
|
|
58
|
+
"NF-C057": "Internal link to a path no page serves",
|
|
59
|
+
"NF-C058": "Internal link written as a path string",
|
|
57
60
|
"NF-D001": "Doctor check",
|
|
58
61
|
"NF-D002": "Mixed nifra versions",
|
|
59
62
|
"NF-D003": "Stale file: dependencies in bun.lock",
|
|
@@ -289,6 +289,21 @@ export const RULE_EXPLANATIONS: Readonly<Record<BuiltInCode, RuleExplanation>> =
|
|
|
289
289
|
fix: "Use `z.stringbool()`, which reads `true`/`1`/`yes`/`on` as true, `false`/`0`/`no`/`off` as false, and refuses other text. A use kept on purpose takes `// nifra-expect NF-C055: <reason>` above the call.",
|
|
290
290
|
docs: "/docs/api",
|
|
291
291
|
},
|
|
292
|
+
"NF-C056": {
|
|
293
|
+
why: "The client build calls the namespace named by a `*.fn.ts` file (`todos.fn.ts` posts under `todos`). A `serverFunctions` mount under another word serves routes the stubs never reach, so every call 404s.",
|
|
294
|
+
fix: 'Pass the filename\'s namespace to `serverFunctions` (`serverFunctions("todos", todos)` for `todos.fn.ts`), or rename the file. A mount kept on purpose takes `// nifra-expect NF-C056: <reason>` above the call.',
|
|
295
|
+
docs: "/docs/server-functions",
|
|
296
|
+
},
|
|
297
|
+
"NF-C057": {
|
|
298
|
+
why: "An `<a href>` names a path that no page of the app, no backend route and no file in `public/` serves, so following it is a 404. Nothing fails at build time: a path string is invisible to the types, and a renamed or removed page leaves every link to it dead.",
|
|
299
|
+
fix: "Build the link with `href({ to, params })` (exported by `@nifrajs/web-<framework>/router`): `to` is a route of the app, so a route that does not exist is a compile error. A path some other server answers takes `rawHref(path)`; a link kept on purpose takes `// nifra-expect NF-C057: <reason>` above the attribute.",
|
|
300
|
+
docs: "/docs/routing",
|
|
301
|
+
},
|
|
302
|
+
"NF-C058": {
|
|
303
|
+
why: "An `<a href>` writes a page's path as a string. It works today, but renaming or removing the page leaves the link dead and nothing fails: `href()` checks a link against the app's routes, a path string is not checked.",
|
|
304
|
+
fix: "Build the link with `href({ to, params, search, hash })`, which `nifra check` and `tsc` hold to the app's routes. A path built elsewhere, such as a CMS link, takes `rawHref(path)`; a link kept on purpose takes `// nifra-expect NF-C058: <reason>` above the attribute. Silence the code for the project with `rules` in `nifra.config`.",
|
|
305
|
+
docs: "/docs/routing",
|
|
306
|
+
},
|
|
292
307
|
"NF-D001": {
|
|
293
308
|
why: "The doctor gate of `nifra assure` found an undeclared import or a package installed more than once.",
|
|
294
309
|
fix: "Run `nifra doctor` for the details and the fix of each finding.",
|