mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 10:25:42 +00:00
feat(javascript): retain queryable static route inventories (#6019)
This commit is contained in:
1 parent
933af60eba
commit
7d0efef62d
67 files changed
+74345
-231
No files matched your search
@@ -1,3 +1,6 @@
|
||||
import { fitJavaScriptRouteSourceFacts } from "../../domain/javascript/javascriptRouteResultBudget.js";
|
||||
import { jsonValueByteLength } from "../../domain/jsonValueByteLength.js";
|
||||
import type { JsonValue } from "../../domain/jsonValue.js";
|
||||
import type { JavaScriptSemanticProjectionCapacity } from "../../domain/javascript/javascriptSemanticFileProjection.js";
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
@@ -117,7 +120,24 @@ const analyzeJob = async (
|
||||
{
|
||||
phase: async (phase) => send({ kind: "phase", id: request.id, phase }),
|
||||
checkpoint: async (facts) => {
|
||||
const value = javaScriptWorkerStaticAnalysisSchema.parse(facts);
|
||||
let value = javaScriptWorkerStaticAnalysisSchema.parse(facts);
|
||||
if (value.routes !== undefined) {
|
||||
const { routes, ...existing } = value;
|
||||
// This is schema-checked, producer-owned JSON. Interface optional
|
||||
// members can only make the size estimate conservative.
|
||||
const available =
|
||||
DEFAULTS.checkpointBytes -
|
||||
jsonValueByteLength(
|
||||
existing as JsonValue,
|
||||
DEFAULTS.checkpointBytes,
|
||||
) -
|
||||
Buffer.byteLength(',"routes":');
|
||||
const admitted = fitJavaScriptRouteSourceFacts(routes, available);
|
||||
value =
|
||||
admitted === undefined
|
||||
? existing
|
||||
: { ...existing, routes: admitted };
|
||||
}
|
||||
const text = JSON.stringify(value);
|
||||
const bytes = Buffer.byteLength(text);
|
||||
if (bytes > DEFAULTS.checkpointBytes)
|
||||
|
||||
Reference in new issue
Block a user