@nifrajs/cli 5.6.0 → 5.8.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 +175 -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 +6 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +1 -30
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +35 -12
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +53 -5
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +5 -0
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +18 -6
- package/dist/command-catalog.js.map +1 -1
- package/dist/contracts.d.ts +42 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +288 -9
- package/dist/contracts.js.map +1 -1
- package/dist/doctor.d.ts +6 -4
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +20 -6
- package/dist/doctor.js.map +1 -1
- package/dist/internal/git-ignored.d.ts +12 -0
- package/dist/internal/git-ignored.d.ts.map +1 -0
- package/dist/internal/git-ignored.js +49 -0
- package/dist/internal/git-ignored.js.map +1 -0
- package/dist/internal/source-facts.d.ts +29 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +160 -0
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/load.d.ts +4 -1
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +10 -0
- package/dist/load.js.map +1 -1
- package/dist/local-cli.d.ts +15 -0
- package/dist/local-cli.d.ts.map +1 -0
- package/dist/local-cli.js +74 -0
- package/dist/local-cli.js.map +1 -0
- package/dist/lock-links.d.ts +0 -7
- package/dist/lock-links.d.ts.map +1 -1
- package/dist/lock-links.js +5 -44
- package/dist/lock-links.js.map +1 -1
- package/dist/mcp-delegate.d.ts +13 -5
- package/dist/mcp-delegate.d.ts.map +1 -1
- package/dist/mcp-delegate.js +24 -8
- package/dist/mcp-delegate.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/openapi-types.d.ts.map +1 -1
- package/dist/openapi-types.js +45 -2
- package/dist/openapi-types.js.map +1 -1
- package/dist/recipes/5.7.0.d.ts +12 -0
- package/dist/recipes/5.7.0.d.ts.map +1 -0
- package/dist/recipes/5.7.0.js +70 -0
- package/dist/recipes/5.7.0.js.map +1 -0
- package/dist/recipes/5.8.0.d.ts +9 -0
- package/dist/recipes/5.8.0.d.ts.map +1 -0
- package/dist/recipes/5.8.0.js +20 -0
- package/dist/recipes/5.8.0.js.map +1 -0
- package/dist/recipes/index.d.ts +13 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +4 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +2 -0
- package/dist/review.js.map +1 -1
- package/dist/rules/codes.d.ts +2 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +2 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/explanations.d.ts.map +1 -1
- package/dist/rules/explanations.js +13 -3
- package/dist/rules/explanations.js.map +1 -1
- package/dist/rules/legacy.js +1 -1
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/text-slot-boolean.d.ts +8 -0
- package/dist/rules/text-slot-boolean.d.ts.map +1 -0
- package/dist/rules/text-slot-boolean.js +57 -0
- package/dist/rules/text-slot-boolean.js.map +1 -0
- package/dist/rules/undeclared-response.d.ts +9 -0
- package/dist/rules/undeclared-response.d.ts.map +1 -0
- package/dist/rules/undeclared-response.js +93 -0
- package/dist/rules/undeclared-response.js.map +1 -0
- package/dist/upgrade.d.ts +34 -8
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +197 -25
- package/dist/upgrade.js.map +1 -1
- package/dist/version-drift.js +1 -1
- package/dist/version-drift.js.map +1 -1
- package/dist/web-app-options.d.ts +1 -1
- package/dist/web-app-options.d.ts.map +1 -1
- package/dist/web-app-options.js.map +1 -1
- package/docs/examples.json +7 -1
- package/docs/llms-full.txt +441 -105
- package/docs/types.json +164 -43
- package/package.json +11 -11
- package/src/check-diagnostics.ts +4 -0
- package/src/check-scan.ts +1 -29
- package/src/check.ts +32 -10
- package/src/cli.ts +58 -5
- package/src/command-catalog.ts +23 -6
- package/src/contracts.ts +348 -14
- package/src/doctor.ts +28 -12
- package/src/internal/git-ignored.ts +47 -0
- package/src/internal/source-facts.ts +198 -0
- package/src/load.ts +16 -0
- package/src/local-cli.ts +83 -0
- package/src/lock-links.ts +5 -43
- package/src/mcp-delegate.ts +30 -9
- package/src/mcp-http.ts +1 -1
- package/src/openapi-types.ts +43 -2
- package/src/recipes/5.7.0.ts +72 -0
- package/src/recipes/5.8.0.ts +21 -0
- package/src/recipes/index.ts +18 -0
- package/src/review.ts +2 -0
- package/src/rules/codes.ts +2 -0
- package/src/rules/explanations.ts +13 -3
- package/src/rules/legacy.ts +1 -1
- package/src/rules/text-slot-boolean.ts +56 -0
- package/src/rules/undeclared-response.ts +92 -0
- package/src/upgrade.ts +229 -33
- package/src/version-drift.ts +1 -1
- package/src/web-app-options.ts +1 -0
|
@@ -19,6 +19,23 @@ export interface UntypedResponseRoutes {
|
|
|
19
19
|
readonly indirectReturns: readonly number[]
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/** A route registration of one file that declares no `response`, from {@link SourceFacts.undeclaredResponseRoutes}. */
|
|
23
|
+
export interface UndeclaredResponseRoute {
|
|
24
|
+
/** The start of the registration's method name (`get` in `.get("/x", h)`). */
|
|
25
|
+
readonly position: number
|
|
26
|
+
readonly method: string
|
|
27
|
+
readonly path: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A zod `coerce.boolean()` that a route's text slot reaches, from {@link SourceFacts.textSlotBooleanCoercions}. */
|
|
31
|
+
export interface TextSlotBooleanCoercion {
|
|
32
|
+
/** The start of the `coerce.boolean()` call. */
|
|
33
|
+
readonly position: number
|
|
34
|
+
readonly slot: "query" | "headers" | "cookies"
|
|
35
|
+
readonly method: string
|
|
36
|
+
readonly path: string
|
|
37
|
+
}
|
|
38
|
+
|
|
22
39
|
export interface SourceFacts {
|
|
23
40
|
parse(file: string, content: string): TSApi.SourceFile | undefined
|
|
24
41
|
isValueImportAt(
|
|
@@ -61,6 +78,20 @@ export interface SourceFacts {
|
|
|
61
78
|
source: TSApi.SourceFile,
|
|
62
79
|
importReturnsResponse?: (specifier: string, name: string) => boolean,
|
|
63
80
|
): UntypedResponseRoutes
|
|
81
|
+
/**
|
|
82
|
+
* The `.get("/path", …)` registrations (and the other methods) whose options are all object
|
|
83
|
+
* literals and none declares `response`, leaving out those whose handlers {@link untypedResponseRoutes}
|
|
84
|
+
* reports: a raw `Response` has no JSON body to declare. One whose options are a variable or a call is
|
|
85
|
+
* left out too, since the file does not show whether it declares one.
|
|
86
|
+
*/
|
|
87
|
+
undeclaredResponseRoutes(source: TSApi.SourceFile): readonly UndeclaredResponseRoute[]
|
|
88
|
+
/**
|
|
89
|
+
* The zod `coerce.boolean()` calls a route's `query`, `headers` or `cookies` schema reaches in
|
|
90
|
+
* `source`: written in the route's options, or in a variable of the file the options name, at any
|
|
91
|
+
* depth. Each call is reported once, for the first route that reaches it. A schema imported from
|
|
92
|
+
* another file is not followed.
|
|
93
|
+
*/
|
|
94
|
+
textSlotBooleanCoercions(source: TSApi.SourceFile): readonly TextSlotBooleanCoercion[]
|
|
64
95
|
/** Whether the function `source` exports as `name` returns a raw `Response` on some path. */
|
|
65
96
|
exportReturnsResponse(source: TSApi.SourceFile, name: string): boolean
|
|
66
97
|
/** Whether the `import` keyword at `position` starts a runtime `import(specifier)` call (true) or a
|
|
@@ -120,6 +151,56 @@ const REGISTRATION_METHODS: ReadonlySet<string> = new Set([
|
|
|
120
151
|
"all",
|
|
121
152
|
])
|
|
122
153
|
|
|
154
|
+
const ZOD_MODULES: ReadonlySet<string> = new Set(["zod", "zod/v4", "zod/mini", "zod/v4/mini"])
|
|
155
|
+
|
|
156
|
+
/** The names `source` binds zod's namespace to (`z`), and those it binds zod's `coerce` to. */
|
|
157
|
+
function zodBindings(
|
|
158
|
+
ts: TypeScriptApi,
|
|
159
|
+
source: TSApi.SourceFile,
|
|
160
|
+
): { readonly namespaces: ReadonlySet<string>; readonly coerce: ReadonlySet<string> } {
|
|
161
|
+
const namespaces = new Set<string>()
|
|
162
|
+
const coerce = new Set<string>()
|
|
163
|
+
for (const statement of source.statements) {
|
|
164
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))
|
|
165
|
+
continue
|
|
166
|
+
const clause = statement.importClause
|
|
167
|
+
if (!ZOD_MODULES.has(statement.moduleSpecifier.text) || clause === undefined) continue
|
|
168
|
+
if (clause.isTypeOnly) continue
|
|
169
|
+
if (clause.name !== undefined) namespaces.add(clause.name.text)
|
|
170
|
+
const bindings = clause.namedBindings
|
|
171
|
+
if (bindings !== undefined && ts.isNamespaceImport(bindings)) namespaces.add(bindings.name.text)
|
|
172
|
+
else if (bindings !== undefined) {
|
|
173
|
+
for (const element of bindings.elements) {
|
|
174
|
+
const imported = (element.propertyName ?? element.name).text
|
|
175
|
+
if (element.isTypeOnly) continue
|
|
176
|
+
if (imported === "z") namespaces.add(element.name.text)
|
|
177
|
+
if (imported === "coerce") coerce.add(element.name.text)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { namespaces, coerce }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The initializer of each variable of `source`, any scope, by name: the first one wins. */
|
|
185
|
+
function variableInitializers(
|
|
186
|
+
ts: TypeScriptApi,
|
|
187
|
+
source: TSApi.SourceFile,
|
|
188
|
+
): Map<string, TSApi.Expression> {
|
|
189
|
+
const consts = new Map<string, TSApi.Expression>()
|
|
190
|
+
const visit = (node: TSApi.Node): void => {
|
|
191
|
+
if (
|
|
192
|
+
ts.isVariableDeclaration(node) &&
|
|
193
|
+
ts.isIdentifier(node.name) &&
|
|
194
|
+
node.initializer !== undefined &&
|
|
195
|
+
!consts.has(node.name.text)
|
|
196
|
+
)
|
|
197
|
+
consts.set(node.name.text, node.initializer)
|
|
198
|
+
ts.forEachChild(node, visit)
|
|
199
|
+
}
|
|
200
|
+
visit(source)
|
|
201
|
+
return consts
|
|
202
|
+
}
|
|
203
|
+
|
|
123
204
|
function unwrapExpression(ts: TypeScriptApi, node: TSApi.Expression): TSApi.Expression {
|
|
124
205
|
let current = node
|
|
125
206
|
while (
|
|
@@ -618,6 +699,121 @@ export function createSourceFacts(
|
|
|
618
699
|
}
|
|
619
700
|
}
|
|
620
701
|
|
|
702
|
+
const undeclaredResponseRoutes = (
|
|
703
|
+
source: TSApi.SourceFile,
|
|
704
|
+
): readonly UndeclaredResponseRoute[] => {
|
|
705
|
+
const locals = localFunctions(ts, source)
|
|
706
|
+
const raw = untypedResponseRoutes(source)
|
|
707
|
+
const routes: UndeclaredResponseRoute[] = []
|
|
708
|
+
const visit = (node: TSApi.Node): void => {
|
|
709
|
+
ts.forEachChild(node, visit)
|
|
710
|
+
if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression)) return
|
|
711
|
+
const method = node.expression.name.text
|
|
712
|
+
const [first, ...rest] = node.arguments
|
|
713
|
+
if (
|
|
714
|
+
!REGISTRATION_METHODS.has(method) ||
|
|
715
|
+
first === undefined ||
|
|
716
|
+
!ts.isStringLiteralLike(first)
|
|
717
|
+
)
|
|
718
|
+
return
|
|
719
|
+
const handlers: FunctionNode[] = []
|
|
720
|
+
for (const argument of rest.map((value) => unwrapExpression(ts, value))) {
|
|
721
|
+
const local = ts.isIdentifier(argument) ? locals.get(argument.text) : undefined
|
|
722
|
+
if (isFunctionValue(ts, argument)) handlers.push(argument)
|
|
723
|
+
else if (local !== undefined) handlers.push(...local)
|
|
724
|
+
else if (!ts.isObjectLiteralExpression(argument) || declaresResponse(ts, argument)) return
|
|
725
|
+
}
|
|
726
|
+
if (handlers.length > 0 && handlers.every((fn) => raw.isUntypedAt(fn.getStart(source))))
|
|
727
|
+
return
|
|
728
|
+
routes.push({
|
|
729
|
+
position: node.expression.name.getStart(source),
|
|
730
|
+
method: method.toUpperCase(),
|
|
731
|
+
path: first.text,
|
|
732
|
+
})
|
|
733
|
+
}
|
|
734
|
+
visit(source)
|
|
735
|
+
return routes.sort((a, b) => a.position - b.position)
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
const textSlotBooleanCoercions = (
|
|
739
|
+
source: TSApi.SourceFile,
|
|
740
|
+
): readonly TextSlotBooleanCoercion[] => {
|
|
741
|
+
const zod = zodBindings(ts, source)
|
|
742
|
+
if (zod.namespaces.size === 0 && zod.coerce.size === 0) return []
|
|
743
|
+
const consts = variableInitializers(ts, source)
|
|
744
|
+
const isCoerceBoolean = (node: TSApi.Node): boolean => {
|
|
745
|
+
if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression))
|
|
746
|
+
return false
|
|
747
|
+
const { expression, name } = node.expression
|
|
748
|
+
if (name.text !== "boolean") return false
|
|
749
|
+
if (ts.isIdentifier(expression)) return zod.coerce.has(expression.text)
|
|
750
|
+
return (
|
|
751
|
+
ts.isPropertyAccessExpression(expression) &&
|
|
752
|
+
expression.name.text === "coerce" &&
|
|
753
|
+
ts.isIdentifier(expression.expression) &&
|
|
754
|
+
zod.namespaces.has(expression.expression.text)
|
|
755
|
+
)
|
|
756
|
+
}
|
|
757
|
+
const found: TextSlotBooleanCoercion[] = []
|
|
758
|
+
const reported = new Set<number>()
|
|
759
|
+
const reach = (
|
|
760
|
+
node: TSApi.Node,
|
|
761
|
+
seen: Set<TSApi.Node>,
|
|
762
|
+
route: Omit<TextSlotBooleanCoercion, "position">,
|
|
763
|
+
): void => {
|
|
764
|
+
if (ts.isIdentifier(node)) {
|
|
765
|
+
const initializer = consts.get(node.text)
|
|
766
|
+
if (initializer !== undefined && !seen.has(initializer)) {
|
|
767
|
+
seen.add(initializer)
|
|
768
|
+
reach(initializer, seen, route)
|
|
769
|
+
}
|
|
770
|
+
return
|
|
771
|
+
}
|
|
772
|
+
if (isCoerceBoolean(node)) {
|
|
773
|
+
const position = node.getStart(source)
|
|
774
|
+
if (!reported.has(position)) {
|
|
775
|
+
reported.add(position)
|
|
776
|
+
found.push({ position, ...route })
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
// Only the value side: a property name or a member name is never a schema.
|
|
780
|
+
if (ts.isPropertyAccessExpression(node)) reach(node.expression, seen, route)
|
|
781
|
+
else if (ts.isPropertyAssignment(node)) reach(node.initializer, seen, route)
|
|
782
|
+
else ts.forEachChild(node, (child) => reach(child, seen, route))
|
|
783
|
+
}
|
|
784
|
+
const visit = (node: TSApi.Node): void => {
|
|
785
|
+
ts.forEachChild(node, visit)
|
|
786
|
+
if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression)) return
|
|
787
|
+
const method = node.expression.name.text
|
|
788
|
+
const [first, ...rest] = node.arguments
|
|
789
|
+
if (
|
|
790
|
+
!REGISTRATION_METHODS.has(method) ||
|
|
791
|
+
first === undefined ||
|
|
792
|
+
!ts.isStringLiteralLike(first)
|
|
793
|
+
)
|
|
794
|
+
return
|
|
795
|
+
for (const argument of rest) {
|
|
796
|
+
let options = unwrapExpression(ts, argument)
|
|
797
|
+
const named = ts.isIdentifier(options) ? consts.get(options.text) : undefined
|
|
798
|
+
if (named !== undefined) options = unwrapExpression(ts, named)
|
|
799
|
+
if (!ts.isObjectLiteralExpression(options)) continue
|
|
800
|
+
for (const property of options.properties) {
|
|
801
|
+
if (!ts.isPropertyAssignment(property) && !ts.isShorthandPropertyAssignment(property))
|
|
802
|
+
continue
|
|
803
|
+
const slot =
|
|
804
|
+
ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)
|
|
805
|
+
? property.name.text
|
|
806
|
+
: undefined
|
|
807
|
+
if (slot !== "query" && slot !== "headers" && slot !== "cookies") continue
|
|
808
|
+
const value = ts.isPropertyAssignment(property) ? property.initializer : property.name
|
|
809
|
+
reach(value, new Set(), { slot, method: method.toUpperCase(), path: first.text })
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
visit(source)
|
|
814
|
+
return found.sort((a, b) => a.position - b.position)
|
|
815
|
+
}
|
|
816
|
+
|
|
621
817
|
const exportReturnsResponse = (source: TSApi.SourceFile, name: string): boolean => {
|
|
622
818
|
const local = exportedLocal(ts, source, name)
|
|
623
819
|
if (local === undefined) return false
|
|
@@ -655,6 +851,8 @@ export function createSourceFacts(
|
|
|
655
851
|
isFunctionRouteCallAt,
|
|
656
852
|
isResponseSyntaxAt,
|
|
657
853
|
untypedResponseRoutes,
|
|
854
|
+
undeclaredResponseRoutes,
|
|
855
|
+
textSlotBooleanCoercions,
|
|
658
856
|
exportReturnsResponse,
|
|
659
857
|
isDynamicImportAt,
|
|
660
858
|
}
|
package/src/load.ts
CHANGED
|
@@ -122,6 +122,9 @@ export interface NifraFramework {
|
|
|
122
122
|
/** Live data refresh, the runtime `live()` from `@nifrajs/web/live` returns: the app serves its
|
|
123
123
|
* endpoints and the client entry keeps what is on screen fresh, in `nifra dev` and in the build. */
|
|
124
124
|
readonly live?: CreateWebAppOptions["live"]
|
|
125
|
+
/** Which cookies say who is signed in, for an app with a `keepAlive` route: a sign-in or sign-out
|
|
126
|
+
* through one drops every tab's kept pages. See `createWebApp`'s `keepAlive`. */
|
|
127
|
+
readonly keepAlive?: CreateWebAppOptions["keepAlive"]
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
/** The {@link NifraFramework} fields forwarded to `createWebApp` and imported by the generated server
|
|
@@ -136,6 +139,7 @@ export const FRAMEWORK_WEB_OPTIONS = [
|
|
|
136
139
|
"i18n",
|
|
137
140
|
"hostPolicy",
|
|
138
141
|
"live",
|
|
142
|
+
"keepAlive",
|
|
139
143
|
] as const
|
|
140
144
|
export type FrameworkWebOption = (typeof FRAMEWORK_WEB_OPTIONS)[number]
|
|
141
145
|
|
|
@@ -200,6 +204,18 @@ function assertFrameworkWebOptions(fw: Partial<NifraFramework>, configFile: stri
|
|
|
200
204
|
) {
|
|
201
205
|
wrong("live", "the runtime live() from @nifrajs/web/live returns")
|
|
202
206
|
}
|
|
207
|
+
if (fw.keepAlive !== undefined) {
|
|
208
|
+
const names = (value: unknown): boolean =>
|
|
209
|
+
value === undefined ||
|
|
210
|
+
(Array.isArray(value) && value.every((name) => typeof name === "string" && name !== ""))
|
|
211
|
+
if (
|
|
212
|
+
typeof fw.keepAlive !== "object" ||
|
|
213
|
+
fw.keepAlive === null ||
|
|
214
|
+
!names(Reflect.get(fw.keepAlive, "identityCookies")) ||
|
|
215
|
+
!names(Reflect.get(fw.keepAlive, "ignoreCookies"))
|
|
216
|
+
)
|
|
217
|
+
wrong("keepAlive", 'an object such as { identityCookies: ["sid"] }')
|
|
218
|
+
}
|
|
203
219
|
if (fw.publicEnvPrefix !== undefined && typeof fw.publicEnvPrefix !== "string") {
|
|
204
220
|
wrong("publicEnvPrefix", 'a string such as "PUBLIC_", or "" to expose no environment variable')
|
|
205
221
|
}
|
package/src/local-cli.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One nifra per project command: the copy the project installs.
|
|
3
|
+
*
|
|
4
|
+
* `dev`, `build`, `start` and `check` run the app inside this process, beside this CLI's own
|
|
5
|
+
* `@nifrajs/core`. A global or `bun link`ed CLI therefore loads a second core next to the project's,
|
|
6
|
+
* and `nifra check` cannot see it: its scan reads the project, not the CLI that runs it. So a command
|
|
7
|
+
* started from another install hands itself to the project's `@nifrajs/cli`, and when there is none to
|
|
8
|
+
* hand to, says which two copies the app is about to load.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs"
|
|
11
|
+
import { dirname, join } from "node:path"
|
|
12
|
+
import { fileURLToPath } from "node:url"
|
|
13
|
+
import { findProjectCli, handOffSession, isOtherInstall, OWN_CLI_DIR } from "./mcp-delegate.ts"
|
|
14
|
+
|
|
15
|
+
/** `0` runs the CLI as invoked. Set on the hand-off child, and by hand to try a linked CLI. */
|
|
16
|
+
export const LOCAL_CLI_ENV = "NIFRA_LOCAL_CLI"
|
|
17
|
+
|
|
18
|
+
/** The commands that run the project with this CLI's copy of nifra in the process. */
|
|
19
|
+
export const PROJECT_COMMANDS: ReadonlySet<string> = new Set(["dev", "build", "start", "check"])
|
|
20
|
+
|
|
21
|
+
const MAX_ANCESTOR_DIRS = 8
|
|
22
|
+
|
|
23
|
+
/** The nearest `@nifrajs/core` install at or above `dir`, resolved through its links. */
|
|
24
|
+
function projectCore(dir: string): string | undefined {
|
|
25
|
+
for (let depth = 0; depth < MAX_ANCESTOR_DIRS; depth++) {
|
|
26
|
+
const pkg = join(dir, "node_modules", "@nifrajs", "core")
|
|
27
|
+
if (existsSync(join(pkg, "package.json"))) return realpathSync(pkg)
|
|
28
|
+
const parent = dirname(dir)
|
|
29
|
+
if (parent === dir) return undefined
|
|
30
|
+
dir = parent
|
|
31
|
+
}
|
|
32
|
+
return undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The `@nifrajs/core` this CLI imports: the package directory above its resolved entry. */
|
|
36
|
+
function ownCore(): string | undefined {
|
|
37
|
+
try {
|
|
38
|
+
let dir = dirname(fileURLToPath(import.meta.resolve("@nifrajs/core")))
|
|
39
|
+
for (let depth = 0; depth < MAX_ANCESTOR_DIRS; depth++) {
|
|
40
|
+
const manifest = join(dir, "package.json")
|
|
41
|
+
if (
|
|
42
|
+
existsSync(manifest) &&
|
|
43
|
+
JSON.parse(readFileSync(manifest, "utf8")).name === "@nifrajs/core"
|
|
44
|
+
)
|
|
45
|
+
return realpathSync(dir)
|
|
46
|
+
dir = dirname(dir)
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
// Unresolvable from here: nothing to compare.
|
|
50
|
+
}
|
|
51
|
+
return undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Run `command` through the project's own CLI when this one is another install. Resolves to the
|
|
56
|
+
* child's exit code, or `undefined` when this process should run the command itself: then, if the
|
|
57
|
+
* project resolves another `@nifrajs/core` than this CLI, it warns with both paths first.
|
|
58
|
+
*/
|
|
59
|
+
export async function runThroughLocalCli(options: {
|
|
60
|
+
readonly cwd: string
|
|
61
|
+
readonly version: string
|
|
62
|
+
readonly args: readonly string[]
|
|
63
|
+
}): Promise<number | undefined> {
|
|
64
|
+
if (process.env[LOCAL_CLI_ENV] !== "0") {
|
|
65
|
+
const cli = await findProjectCli(options.cwd)
|
|
66
|
+
if (cli?.bin !== undefined && isOtherInstall(cli.dir)) {
|
|
67
|
+
const exit = await handOffSession([process.execPath, cli.bin, ...options.args], {
|
|
68
|
+
cwd: options.cwd,
|
|
69
|
+
env: { ...process.env, [LOCAL_CLI_ENV]: "0" },
|
|
70
|
+
announce: `[nifra] this nifra CLI (${options.version}, ${OWN_CLI_DIR}) is not the project's; running its @nifrajs/cli ${cli.version} from ${cli.dir} (${LOCAL_CLI_ENV}=0 runs this one)`,
|
|
71
|
+
})
|
|
72
|
+
if (exit !== undefined) return exit
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const project = projectCore(options.cwd)
|
|
76
|
+
const own = ownCore()
|
|
77
|
+
if (project !== undefined && own !== undefined && project !== own) {
|
|
78
|
+
console.warn(
|
|
79
|
+
`[nifra] this nifra CLI (${OWN_CLI_DIR}) runs its own @nifrajs/core from ${own}, and the project resolves ${project}: the app loads both, and \`nifra check\` cannot see this CLI's copy. Run the project's CLI (\`./node_modules/.bin/nifra\`, or add it: \`bun add -d @nifrajs/cli\`).`,
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
return undefined
|
|
83
|
+
}
|
package/src/lock-links.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* A `file:` dependency's own dependencies, as bun.lock records them. Bun records them when it first
|
|
3
3
|
* installs the linked package and does not read its package.json again, so once the linked package
|
|
4
4
|
* moves to another version of a dependency the lock still names the old one and Bun installs a second
|
|
5
|
-
* copy under the linked package. Checked on Bun 1.4.2: `bun install --force` keeps the stale entry
|
|
6
|
-
* `bun update <name
|
|
5
|
+
* copy under the linked package. Checked on Bun 1.4.2: `bun install --force` keeps the stale entry, and
|
|
6
|
+
* `bun update <name>` refreshes it alone; Bun 1.4.4 refreshes it on any install. Deleting the entry
|
|
7
|
+
* instead makes either re-resolve every package in the lock, and 1.4.4 rewrites lockfileVersion 1 as 2.
|
|
7
8
|
*/
|
|
8
9
|
import { existsSync, readFileSync } from "node:fs"
|
|
9
10
|
import { dirname, join, resolve } from "node:path"
|
|
@@ -113,45 +114,6 @@ export function staleLinkLocks(
|
|
|
113
114
|
export const describeChange = (change: LinkLockChange): string =>
|
|
114
115
|
`${change.name} ${change.recorded ?? "(none)"} -> ${change.declared ?? "(none)"}`
|
|
115
116
|
|
|
116
|
-
const ENTRY_KEY = /^ {4}("(?:[^"\\]|\\.)*"): \[/
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* bun.lock text without the `packages` entries of `names` and the dependencies scoped under them,
|
|
120
|
-
* so the next `bun install` reads each linked package.json again. `undefined` unless the text is laid
|
|
121
|
-
* out one entry per line, as Bun writes it, and the result parses to the same lock less those
|
|
122
|
-
* entries: the caller names `bun update` instead.
|
|
123
|
-
*/
|
|
124
|
-
export function pruneLinkLocks(text: string, names: readonly string[]): string | undefined {
|
|
125
|
-
const lines = text.split("\n")
|
|
126
|
-
const start = lines.findIndex((line) => /^ {2}"packages": \{\s*$/.test(line))
|
|
127
|
-
if (start === -1) return undefined
|
|
128
|
-
const end = lines.findIndex((line, index) => index > start && /^ {2}\}/.test(line))
|
|
129
|
-
if (end === -1) return undefined
|
|
130
|
-
const dropped = (key: string): boolean =>
|
|
131
|
-
names.some((name) => key === name || key.startsWith(`${name}/`))
|
|
132
|
-
const kept = lines.filter((line, index) => {
|
|
133
|
-
if (index <= start || index >= end) return true
|
|
134
|
-
const key = ENTRY_KEY.exec(line)?.[1]
|
|
135
|
-
return key === undefined || !dropped(String(JSON.parse(key)))
|
|
136
|
-
})
|
|
137
|
-
const pruned = kept.join("\n")
|
|
138
|
-
try {
|
|
139
|
-
const before = recordOf(parseJsonc(text))
|
|
140
|
-
const after = recordOf(parseJsonc(pruned))
|
|
141
|
-
const expected = Object.fromEntries(
|
|
142
|
-
Object.entries(recordOf(before.packages)).filter(([key]) => !dropped(key)),
|
|
143
|
-
)
|
|
144
|
-
const same = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b)
|
|
145
|
-
if (!same(recordOf(after.packages), expected)) return undefined
|
|
146
|
-
for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
147
|
-
if (key !== "packages" && !same(before[key], after[key])) return undefined
|
|
148
|
-
}
|
|
149
|
-
} catch {
|
|
150
|
-
return undefined
|
|
151
|
-
}
|
|
152
|
-
return pruned
|
|
153
|
-
}
|
|
154
|
-
|
|
155
117
|
/** The `bun update` that makes Bun read each linked package.json again. */
|
|
156
118
|
export const linkLockUpdate = (entries: readonly StaleLinkLock[]): string =>
|
|
157
119
|
`bun update ${entries.map((entry) => entry.package).join(" ")}`
|
|
@@ -169,7 +131,7 @@ export function staleLinkLockMessage(stale: {
|
|
|
169
131
|
})
|
|
170
132
|
.join("; ")
|
|
171
133
|
return (
|
|
172
|
-
`${stale.lock} records dependencies its file: packages no longer declare, and Bun never reads a linked package.json again, so it installs those versions beside the declared ones: ${listed}. ` +
|
|
173
|
-
`Run \`${linkLockUpdate(stale.entries)}
|
|
134
|
+
`${stale.lock} records dependencies its file: packages no longer declare, and Bun 1.4.2 never reads a linked package.json again, so it installs those versions beside the declared ones: ${listed}. ` +
|
|
135
|
+
`Run \`${linkLockUpdate(stale.entries)}\`: it refreshes those entries and keeps every other pin, where deleting them makes the next install re-resolve the whole lock. Review the bun.lock diff: Bun records each linked package.json as it is on disk, uncommitted edits included.`
|
|
174
136
|
)
|
|
175
137
|
}
|
package/src/mcp-delegate.ts
CHANGED
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* instead of answering for the wrong release.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { existsSync } from "node:fs"
|
|
15
|
+
import { existsSync, realpathSync } from "node:fs"
|
|
16
16
|
import { readFile } from "node:fs/promises"
|
|
17
17
|
import { dirname, join } from "node:path"
|
|
18
|
+
import { fileURLToPath } from "node:url"
|
|
18
19
|
import type { McpTool, McpToolResult } from "./mcp-protocol.ts"
|
|
19
20
|
import type { ToolingDrift } from "./mcp-root.ts"
|
|
20
21
|
|
|
@@ -31,9 +32,11 @@ export const VERSION_SENSITIVE_TOOLS: ReadonlySet<string> = new Set([
|
|
|
31
32
|
"nifra_contracts",
|
|
32
33
|
])
|
|
33
34
|
|
|
34
|
-
/** The project's own CLI: its version and, when it is on disk, the script
|
|
35
|
+
/** The project's own CLI: its version, its package directory, and, when it is on disk, the script
|
|
36
|
+
* its `bin` names. */
|
|
35
37
|
export interface ProjectCli {
|
|
36
38
|
readonly version: string
|
|
39
|
+
readonly dir: string
|
|
37
40
|
readonly bin?: string
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -60,8 +63,8 @@ export async function findProjectCli(root: string): Promise<ProjectCli | undefin
|
|
|
60
63
|
const script = binScript(meta.bin)
|
|
61
64
|
const bin = script === undefined ? undefined : join(pkg, script)
|
|
62
65
|
return bin !== undefined && existsSync(bin)
|
|
63
|
-
? { version: meta.version, bin }
|
|
64
|
-
: { version: meta.version }
|
|
66
|
+
? { version: meta.version, dir: pkg, bin }
|
|
67
|
+
: { version: meta.version, dir: pkg }
|
|
65
68
|
}
|
|
66
69
|
} catch {
|
|
67
70
|
// Not installed at this level - keep walking up.
|
|
@@ -73,11 +76,25 @@ export async function findProjectCli(root: string): Promise<ProjectCli | undefin
|
|
|
73
76
|
return undefined
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
/** This CLI's package directory: the parent of `src/` or `dist/`, where this module sits. */
|
|
80
|
+
export const OWN_CLI_DIR = fileURLToPath(new URL("..", import.meta.url))
|
|
81
|
+
|
|
82
|
+
/** Whether `dir` is another install than this CLI's own: a version can match while the copy, and the
|
|
83
|
+
* `@nifrajs/core` beside it, does not. */
|
|
84
|
+
export function isOtherInstall(dir: string): boolean {
|
|
85
|
+
try {
|
|
86
|
+
return realpathSync(dir) !== realpathSync(OWN_CLI_DIR)
|
|
87
|
+
} catch {
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
76
92
|
/**
|
|
77
|
-
* Hand this stdio session to the project's own CLI when it installs a different version
|
|
78
|
-
* the child's exit code once the session ends, or
|
|
79
|
-
*
|
|
80
|
-
*
|
|
93
|
+
* Hand this stdio session to the project's own CLI when it installs a different version, or the same
|
|
94
|
+
* version from another directory. Resolves to the child's exit code once the session ends, or
|
|
95
|
+
* `undefined` when this process should serve itself (this is the project's CLI, no project CLI or
|
|
96
|
+
* bin, already a hand-off, or the spawn failed). Must run before anything reads stdin: the child
|
|
97
|
+
* inherits the descriptor and owns the whole conversation.
|
|
81
98
|
*/
|
|
82
99
|
export async function delegateToProjectCli(options: {
|
|
83
100
|
readonly cwd: string
|
|
@@ -87,7 +104,11 @@ export async function delegateToProjectCli(options: {
|
|
|
87
104
|
}): Promise<number | undefined> {
|
|
88
105
|
if (process.env[MCP_DELEGATED_ENV] === "1") return undefined
|
|
89
106
|
const cli = await findProjectCli(options.root)
|
|
90
|
-
if (
|
|
107
|
+
if (
|
|
108
|
+
cli === undefined ||
|
|
109
|
+
cli.bin === undefined ||
|
|
110
|
+
(cli.version === options.version && !isOtherInstall(cli.dir))
|
|
111
|
+
)
|
|
91
112
|
return undefined
|
|
92
113
|
// Not the `.bin` shim: its `bun` would load the project's `.env`, and the inherited
|
|
93
114
|
// NIFRA_MCP_WITHOUT_ENV_FILES then tells that CLI the values are already gone.
|
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.8.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/openapi-types.ts
CHANGED
|
@@ -39,6 +39,43 @@ type TypeChecker = TSApi.TypeChecker
|
|
|
39
39
|
|
|
40
40
|
const hasFlag = (type: Type, flag: number): boolean => (type.flags & flag) !== 0
|
|
41
41
|
|
|
42
|
+
/** A `bigint` as a nifra JSON response writes it: its decimal string. */
|
|
43
|
+
const BIGINT_SCHEMA: JsonSchema = { type: "string", pattern: "^-?(0|[1-9][0-9]*)$" }
|
|
44
|
+
|
|
45
|
+
/** `JSON.stringify` writes a typed array as an object keyed by index. */
|
|
46
|
+
const NUMBER_ARRAYS: ReadonlySet<string> = new Set([
|
|
47
|
+
"Int8Array",
|
|
48
|
+
"Uint8Array",
|
|
49
|
+
"Uint8ClampedArray",
|
|
50
|
+
"Int16Array",
|
|
51
|
+
"Uint16Array",
|
|
52
|
+
"Int32Array",
|
|
53
|
+
"Uint32Array",
|
|
54
|
+
"Float32Array",
|
|
55
|
+
"Float64Array",
|
|
56
|
+
])
|
|
57
|
+
const NUMBER_ARRAY_SCHEMA: JsonSchema = { type: "object", additionalProperties: { type: "number" } }
|
|
58
|
+
/** A `BigInt64Array` or `BigUint64Array`: keyed by index too, each entry a `bigint`'s decimal string. */
|
|
59
|
+
const BIGINT_ARRAYS: ReadonlySet<string> = new Set(["BigInt64Array", "BigUint64Array"])
|
|
60
|
+
const BIGINT_ARRAY_SCHEMA: JsonSchema = { type: "object", additionalProperties: BIGINT_SCHEMA }
|
|
61
|
+
/** What a Node `Buffer`'s `toJSON` writes in place of the index object. */
|
|
62
|
+
const BUFFER_SCHEMA: JsonSchema = {
|
|
63
|
+
type: "object",
|
|
64
|
+
properties: {
|
|
65
|
+
type: { const: "Buffer" },
|
|
66
|
+
data: { type: "array", items: { type: "integer", minimum: 0, maximum: 255 } },
|
|
67
|
+
},
|
|
68
|
+
required: ["type", "data"],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The schema of a typed array or `Buffer` named `name`, as `JSON.stringify` writes it. */
|
|
72
|
+
function binarySchema(name: string | undefined): JsonSchema | undefined {
|
|
73
|
+
if (name === undefined) return undefined
|
|
74
|
+
if (name === "Buffer") return BUFFER_SCHEMA
|
|
75
|
+
if (BIGINT_ARRAYS.has(name)) return BIGINT_ARRAY_SCHEMA
|
|
76
|
+
return NUMBER_ARRAYS.has(name) ? NUMBER_ARRAY_SCHEMA : undefined
|
|
77
|
+
}
|
|
78
|
+
|
|
42
79
|
function schemaForType(
|
|
43
80
|
ts: TypeScriptApi,
|
|
44
81
|
checker: TypeChecker,
|
|
@@ -66,7 +103,7 @@ function schemaForType(
|
|
|
66
103
|
if (hasFlag(type, ts.TypeFlags.StringLike)) return { type: "string" }
|
|
67
104
|
if (hasFlag(type, ts.TypeFlags.NumberLike)) return { type: "number" }
|
|
68
105
|
if (hasFlag(type, ts.TypeFlags.BooleanLike)) return { type: "boolean" }
|
|
69
|
-
if (hasFlag(type, ts.TypeFlags.BigIntLike)) return
|
|
106
|
+
if (hasFlag(type, ts.TypeFlags.BigIntLike)) return BIGINT_SCHEMA
|
|
70
107
|
if (hasFlag(type, ts.TypeFlags.Null)) return { type: "null" }
|
|
71
108
|
|
|
72
109
|
if (type.isUnion()) {
|
|
@@ -93,6 +130,8 @@ function schemaForType(
|
|
|
93
130
|
}
|
|
94
131
|
|
|
95
132
|
if (type.symbol?.name === "Date") return { type: "string", format: "date-time" }
|
|
133
|
+
const binary = binarySchema(type.symbol?.name)
|
|
134
|
+
if (binary !== undefined) return binary
|
|
96
135
|
if ((type.flags & ts.TypeFlags.Object) === 0) return undefined
|
|
97
136
|
|
|
98
137
|
seen.add(type)
|
|
@@ -255,7 +294,7 @@ async function schemaForType7(
|
|
|
255
294
|
if ((input.flags & stringLikeFlag) !== 0) return { type: "string" }
|
|
256
295
|
if ((input.flags & numberLikeFlag) !== 0) return { type: "number" }
|
|
257
296
|
if ((input.flags & booleanLikeFlag) !== 0) return { type: "boolean" }
|
|
258
|
-
if ((input.flags & bigintLikeFlag) !== 0) return
|
|
297
|
+
if ((input.flags & bigintLikeFlag) !== 0) return BIGINT_SCHEMA
|
|
259
298
|
if ((input.flags & nullFlag) !== 0) return { type: "null" }
|
|
260
299
|
|
|
261
300
|
if ((input.flags & unionFlag) !== 0) {
|
|
@@ -291,6 +330,8 @@ async function schemaForType7(
|
|
|
291
330
|
|
|
292
331
|
const symbol = await input.getSymbol()
|
|
293
332
|
if (symbol?.name === "Date") return { type: "string", format: "date-time" }
|
|
333
|
+
const binary = binarySchema(symbol?.name)
|
|
334
|
+
if (binary !== undefined) return binary
|
|
294
335
|
if ((input.flags & objectFlag) === 0) return undefined
|
|
295
336
|
|
|
296
337
|
seen.add(input)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { UpgradeRecipe } from "./index.ts"
|
|
2
|
+
|
|
3
|
+
const ADAPTERS = [
|
|
4
|
+
"@nifrajs/web-react",
|
|
5
|
+
"@nifrajs/web-vue",
|
|
6
|
+
"@nifrajs/web-svelte",
|
|
7
|
+
"@nifrajs/web-solid",
|
|
8
|
+
"@nifrajs/web-preact",
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Upgrade recipe for Nifra 5.7.
|
|
13
|
+
*
|
|
14
|
+
* The React Auth.js bindings move from `@nifrajs/web-react/auth` to `@nifrajs/authjs/react`, so the
|
|
15
|
+
* React adapter no longer names Auth.js at all. The import moves mechanically. The UI adapters take
|
|
16
|
+
* `@nifrajs/image` and `@nifrajs/i18n` as optional peers, and web-react drops `@nifrajs/schema`, so
|
|
17
|
+
* each package an app reached only through an adapter is added beside it where a file imports it.
|
|
18
|
+
* The notes name every other change an app can observe, and `affects` lists the packages they touch.
|
|
19
|
+
*/
|
|
20
|
+
export const recipe: UpgradeRecipe = {
|
|
21
|
+
version: "5.7.0",
|
|
22
|
+
pins: [
|
|
23
|
+
{ match: "@nifrajs/", to: "5.7.0" },
|
|
24
|
+
{ match: "create-nifra", to: "5.7.0" },
|
|
25
|
+
{ match: "nifra", to: "5.7.0" },
|
|
26
|
+
],
|
|
27
|
+
importMoves: [{ from: "@nifrajs/web-react/auth", to: "@nifrajs/authjs/react" }],
|
|
28
|
+
dependencyAdds: [
|
|
29
|
+
{ imports: ["@nifrajs/authjs"], add: "@nifrajs/authjs", beside: ["@nifrajs/web-react"] },
|
|
30
|
+
{ imports: ADAPTERS.map((adapter) => `${adapter}/image`), add: "@nifrajs/image" },
|
|
31
|
+
{ imports: ADAPTERS.map((adapter) => `${adapter}/i18n`), add: "@nifrajs/i18n" },
|
|
32
|
+
{ imports: ["@nifrajs/schema"], add: "@nifrajs/schema", beside: ["@nifrajs/web-react"] },
|
|
33
|
+
],
|
|
34
|
+
notes: [
|
|
35
|
+
"`<AuthSessionProvider>` and `useAuthSession()` are imported from `@nifrajs/authjs/react`; `@nifrajs/web-react/auth` is removed. `@nifrajs/web-react` no longer brings `@nifrajs/authjs` in, so `nifra upgrade` adds it beside `@nifrajs/web-react` in each package.json above a file that imports it without listing it. `@nifrajs/authjs` takes `react` as an optional peer. The useAuthSession error outside a provider reads `[nifra/authjs]`, where it read `[nifra/web-react]`.",
|
|
36
|
+
"`@nifrajs/image` and `@nifrajs/i18n` are optional peers of `@nifrajs/web-react`, `web-vue`, `web-svelte`, `web-solid` and `web-preact`, where they were dependencies, so an adapter's `/image` or `/i18n` entry fails to resolve unless the app lists the package. `nifra upgrade` adds it beside the adapter in each package.json above a file that imports the entry; an app that already lists it needs no change.",
|
|
37
|
+
"`@nifrajs/web-react` no longer depends on `@nifrajs/schema`, so `nifra upgrade` adds `@nifrajs/schema` beside `@nifrajs/web-react` in each package.json above a file that imports it without listing it.",
|
|
38
|
+
'`healthcheck()`\'s `/ready` body changes shape: each check is `{ status: "pass" | "fail" | "timeout", ms }` (plus `optional: true`) where it was a boolean, and the top-level `status` can also be `degraded` or `stopping`, so a monitor that reads the body rather than the status code needs updating. `/ready` answers `503` from the moment a stop begins, a check slower than `timeoutMs` (default 2 s) fails as `timeout`, and a finished run answers probes for `cacheMs` (default 1 s).',
|
|
39
|
+
'A `bigint` in a JSON answer is written as its decimal string on every runtime, where the route answered a 500, and the typed client reads such a field as `string`. A typed array in an answer is typed on the client as the index object it is sent as (string entries for a `BigInt64Array`), and a Node `Buffer` as `{ type: "Buffer", data: number[] }`; declare the field `t.bytes()` to send base64 instead.',
|
|
40
|
+
"A document from `toOpenAPI`, `buildOpenApiDocument` or `openapi()` lists `500` on every operation, `404` where a path parameter has a pattern, and `429` with `Retry-After` on a `rateLimit()` route, as the shared `NifraError` component, so a client generated from it gains those responses. An array query parameter is declared `style: form, explode: true`.",
|
|
41
|
+
"A `t.object` in a `query`, `headers` or `cookies` slot converts the text it receives to the types it declares (`?archived=true` is `true`, `?page=2` is `2`), where such a request was a 422; a `body` slot still converts nothing.",
|
|
42
|
+
'`nifra check` adds NF-C054 (info), a route with no `response` schema in a project that builds its document from the running routes, and NF-C055 (warn), zod\'s `z.coerce.boolean()` in a `query`, `headers` or `cookies` schema, which reads `"false"` as `true` (use `z.stringbool()`). It also reports a single-copy declaration as not enforced when `bunfig.toml` preloads the registrar for only one of `bun run` and `bun test`, or writes the `preload` line under another table such as `[install]`.',
|
|
43
|
+
"`logger()` logs the matched route template as `path` (`/share/:token`) instead of the request path and never logs the query string; `rawPath: true` logs the pathname. A request no route matched logs its pathname.",
|
|
44
|
+
"A `rateLimit()` or `rateLimitTiers()` `key` that throws or rejects is charged to the client IP instead of failing the request.",
|
|
45
|
+
"A `mount()` authentication refusal is final even when its status is 404 and child-miss fallthrough is on, for HTTP and WebSockets, so a later route no longer answers a request the mount's gate refused.",
|
|
46
|
+
"The typed client sends its configured response codec's `Accept` on GET, bodyless and multipart requests too, not only on JSON ones; an explicit `Accept` header still wins.",
|
|
47
|
+
"Validation issue paths decode JSON Pointer escapes, so a field named `a/b` is reported as `a/b` rather than `a~1b`, by the runtime and the precompiled validators alike.",
|
|
48
|
+
"A server-rendered page no longer runs its loaders a second time when its live socket opens (partial prerendering, server-component routes and Workers hub mode keep the full first load), and a page polling while its socket is down reloads all its data on each poll. `live.close()` ends every socket with `1001`; call it in `onStop` before closing the Redis clients.",
|
|
49
|
+
"Kept pages are dropped on a sign-in or sign-out through a Better Auth session cookie under any `advanced.cookiePrefix` and on an explicit bearer-auth identity change, cross-tab signals included, and a page Back restores is kept again only under the visitor it was restored for.",
|
|
50
|
+
"A client navigation requests its data before the view transition starts, and the swap waits at most 100 ms for a frame before skipping the animation. A navigation that a newer one supersedes settles quietly instead of rejecting and loading the older page as a document.",
|
|
51
|
+
"A `Date` in a streamed partial-prerendering interactive prop or a signed shared-cache entry arrives as a `Date` across processes, and a cache entry with an invalid Date tag is a miss. A production server bundle reads `NODE_ENV` at build time in partial prerendering, the Vue adapter's streamed render and the Solid adapter's error serialization.",
|
|
52
|
+
"`nifra dev`, `build`, `start` and `check` started from a global or linked CLI run through the project's own `@nifrajs/cli`, at any version (`NIFRA_LOCAL_CLI=0` runs the CLI as invoked), and `nifra mcp` hands a session over on the same rule.",
|
|
53
|
+
"`nifra upgrade --write` leaves bun.lock as it is and lists its stale `file:` entries with the `bun update` that refreshes them, so the `--json` plan no longer carries `lockPruned`. It skips gitignored files.",
|
|
54
|
+
"`nifra contracts snapshot` records each route part with its own digest, so after the next snapshot `nifra contracts check` and the `nifra check` contract gate also catch a change to a headers or cookies schema. A lock written before then compares as before.",
|
|
55
|
+
],
|
|
56
|
+
affects: [
|
|
57
|
+
"@nifrajs/authjs",
|
|
58
|
+
"@nifrajs/cli",
|
|
59
|
+
"@nifrajs/client",
|
|
60
|
+
"@nifrajs/core",
|
|
61
|
+
"@nifrajs/edge",
|
|
62
|
+
"@nifrajs/middleware",
|
|
63
|
+
"@nifrajs/node",
|
|
64
|
+
"@nifrajs/schema",
|
|
65
|
+
"@nifrajs/web",
|
|
66
|
+
"@nifrajs/web-preact",
|
|
67
|
+
"@nifrajs/web-react",
|
|
68
|
+
"@nifrajs/web-solid",
|
|
69
|
+
"@nifrajs/web-svelte",
|
|
70
|
+
"@nifrajs/web-vue",
|
|
71
|
+
],
|
|
72
|
+
}
|