feat(semantics): extract statement-classification facts into @pgsql/semantics - #334
Merged
Conversation
…emantics Move facts.ts (classifyStatements + StatementFacts and friends) verbatim out of @pgsql/transform into a new @pgsql/semantics package. @pgsql/transform depends on it and re-exports the same symbols from src/facts.ts, so all existing consumers are unaffected. Transform-specific rewriting drivers stay in @pgsql/transform.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Extracts the statement-classification facts layer out of
@pgsql/transforminto a new package,@pgsql/semantics. This is a move, not a redesign — no new API surface. What moved is semantics (which relations/functions/types a statement reads and creates, which namespaces it touches, security relevance), which had grown up inside@pgsql/transformas a gate for bundle namespace validation but is not itself transformation.facts.tsmoves across verbatim (543 lines, unchanged) along with its test.@pgsql/transformnow depends on@pgsql/semanticsand re-exports the same symbols from the same path, so every existing consumer — this repo's ownqualify/restructure/naming/graphdrivers,@pgpmjs/transform'scategorize.ts, and any other — is untouched. The transform-specific rewriting drivers stay in@pgsql/transform.What moved
packages/transform/src/facts.ts→packages/semantics/src/facts.ts(git-tracked as a rename of the test; the source shows as add+delete because the transform-side file is replaced by a re-export stub). IncludesclassifyStatementsand the typesStatementFacts,StatementKind,QualifiedName,ExtensionFact,ExtensionAction,StatementSpan. Its test (facts.test.ts, 16 cases) moved too.What stayed
Everything transform-specific:
transformSql,SchemaRouter/RoleRouter/extension routers,qualifyUnqualified, round-trip validation,buildStatementGraph,identityOf,restructureSql, etc.Compatibility seam
@pgsql/transform's internal drivers importclassifyStatements/StatementFactsfrom./facts, and itsindex.tsre-exports them. Rather than repoint every import,transform/src/facts.tsbecomes a one-line re-export so both the public path and internal paths keep working:New package
@pgsql/semanticsfollows the sibling-package layout exactly (copied from@pgsql/traverse/@pgsql/quotes): samepackage.jsonscripts (tscCJS + ESM,makage assets),tsconfig.json/tsconfig.esm.json,jest.config.js,.gitignore,publishConfig.directory: dist. Dependencies are@pgsql/traverse+plpgsql-parser(whatfacts.tsactually imports). Version starts at18.0.0. Added to the CI test matrix in.github/workflows/run-tests.yaml.Verification
pnpm build— all packages compile (CJS + ESM).pnpm --filter @pgsql/semantics test— 16 passed;pnpm --filter @pgsql/transform test— 236 passed.@pgsql/clifails ("No tests found"), which is preexisting onmainand not in the CI matrix.pnpm lint— no new errors.link:entries only; regenerated with pnpm 9 to match CI and verified with--frozen-lockfile).Link to Devin session: https://app.devin.ai/sessions/af81a09043504701874ca63e67a9cd4b
Requested by: @pyramation