mirror of
https://github.com/morluto/rea.git
synced 2026-10-29 02:45:58 +00:00
fix(javascript): bind Next page admission to source context
This commit is contained in:
1 parent
c20b707680
commit
5ee5e49cb4
13 files changed
+532
-53
No files matched your search
@@ -16,6 +16,8 @@ import {
|
||||
import {
|
||||
classifyNextAppRoutePath,
|
||||
nextScriptBasePath,
|
||||
nextAppSourceContextSchema,
|
||||
type NextAppSourceContext,
|
||||
} from "./javascriptRoutePaths.js";
|
||||
|
||||
const sourceStatus = z.enum(["complete", "partial", "unavailable", "unknown"]);
|
||||
@@ -30,6 +32,7 @@ const sourceShape = {
|
||||
status: sourceStatus,
|
||||
reported_route_capacity: javaScriptRouteSourceFactsSchema.shape.capacity,
|
||||
reason: z.string().nullable(),
|
||||
next_app_context: nextAppSourceContextSchema.exactOptional(),
|
||||
base_path: z
|
||||
.strictObject({
|
||||
value: z.string(),
|
||||
@@ -134,13 +137,16 @@ export const javaScriptRouteInventorySchema = inventoryShape.superRefine(
|
||||
source.url,
|
||||
source.sha256,
|
||||
source.container_sha256,
|
||||
...(source.next_app_context === undefined
|
||||
? []
|
||||
: [source.next_app_context]),
|
||||
])
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["sources"],
|
||||
message:
|
||||
"Route source identity must be unique and bind its source/content fields",
|
||||
"Route source identity must be unique and bind source/content/applicability fields",
|
||||
});
|
||||
sources.add(source.id);
|
||||
}
|
||||
@@ -268,6 +274,7 @@ export type JavaScriptRouteInventorySource = z.infer<
|
||||
typeof javaScriptRouteInventorySourceSchema
|
||||
>;
|
||||
export interface JavaScriptRouteInventoryInput {
|
||||
readonly next_app_context?: NextAppSourceContext;
|
||||
readonly key: string;
|
||||
readonly path: string | null;
|
||||
readonly url: string | null;
|
||||
@@ -429,12 +436,28 @@ export function* buildJavaScriptRouteInventorySteps(
|
||||
const manifestIds: string[] = [];
|
||||
for (const input of inputs) {
|
||||
yield;
|
||||
const metadata = classifyNextAppRoutePath(
|
||||
input.url ?? input.path ?? "",
|
||||
input.url !== null
|
||||
? { kind: "script-url" }
|
||||
: {
|
||||
kind: "source-path",
|
||||
source: input.next_app_context ?? {
|
||||
kind: "unknown",
|
||||
package: null,
|
||||
reason: "Next App Router source applicability was not measured.",
|
||||
},
|
||||
},
|
||||
);
|
||||
const nextContext =
|
||||
metadata === undefined ? undefined : input.next_app_context;
|
||||
const id = lookupId("jss", [
|
||||
input.key,
|
||||
input.path,
|
||||
input.url,
|
||||
input.sha256,
|
||||
input.container_sha256,
|
||||
...(nextContext === undefined ? [] : [nextContext]),
|
||||
]);
|
||||
manifestIds.push(id);
|
||||
const prefix =
|
||||
@@ -447,6 +470,7 @@ export function* buildJavaScriptRouteInventorySteps(
|
||||
sha256: input.sha256,
|
||||
container_sha256: input.container_sha256,
|
||||
status: input.status,
|
||||
...(nextContext === undefined ? {} : { next_app_context: nextContext }),
|
||||
reported_route_capacity: input.facts?.capacity ?? null,
|
||||
reason: input.reason,
|
||||
base_path: prefix
|
||||
@@ -455,7 +479,6 @@ export function* buildJavaScriptRouteInventorySteps(
|
||||
};
|
||||
if (!reserve(source)) continue;
|
||||
sources.push(source);
|
||||
const metadata = classifyNextAppRoutePath(input.url ?? input.path ?? "");
|
||||
const metadataPath = metadata?.kind === "known" ? metadata.path : undefined;
|
||||
contexts.push({ input, source, metadataPath });
|
||||
if (metadata?.kind === "unknown") {
|
||||
|
||||
Reference in new issue
Block a user