Open
Conversation
Phase A: Extract 4 inline function groups from build-data.mjs into separate modules in apps/longterm/scripts/lib/: - computed-facts.mjs: parseNumericValue, resolveComputedFacts - statistics.mjs: computeStats - unconverted-links.mjs: buildUrlToResourceMap, findUnconvertedLinks, countConvertedLinks - mdx-generator.mjs: generateMdxFromYaml Phase B: Move entity transformation from runtime (index.ts) to build time: - Create entity-transform.mjs with transformEntities orchestrator that handles type mapping, expert/org merging, risk categories, and entity overrides - Add typedEntities to database.json output from build-data.mjs - Simplify getTypedEntities() in index.ts to read pre-transformed entities - Remove ~287 lines of dead runtime transform code from index.ts Results: build-data.mjs 1124→592 lines, index.ts 1246→959 lines. https://claude.ai/code/session_01DL2zdVVyQUfB3UXYjA7Sj7
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR moves entity transformation (type mapping, expert/org merging, risk categorization) from runtime to build time. Entities are now pre-transformed into typed entities during the build process and stored in
database.jsonastypedEntities, eliminating runtime transformation overhead and simplifying the data loading layer.Key Changes
apps/longterm/scripts/lib/entity-transform.mjsto handle all entity transformation logic (type mapping, expert/org merging, risk categories) during buildapps/longterm-next/src/data/index.ts; now just validates pre-transformed entities via ZodapplyEntityOverrides()and related override logic; type remapping now happens at build timeapps/longterm/scripts/lib/computed-facts.mjsand unconverted links detection toapps/longterm/scripts/lib/unconverted-links.mjsfor better modularitytypedEntitiesfield toDatabaseShape; runtime now requires this field and throws helpful error if missingtypedEntitiesto mock database in testsImplementation Details
build-data.mjsviatransformEntities()which handles:Benefits
https://claude.ai/code/session_01DL2zdVVyQUfB3UXYjA7Sj7