feat: pgpm-based ORM generation for constructive_infra_public (sdk/)#62
Open
pyramation wants to merge 2 commits into
Open
feat: pgpm-based ORM generation for constructive_infra_public (sdk/)#62pyramation wants to merge 2 commits into
pyramation wants to merge 2 commits into
Conversation
🤖 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
Adds a typed ORM for the
constructive_infra_publicschema, generated from the pgpm module — not hand-written — mirroringconstructive-db's Pattern A (deploy pgpm → ephemeral DB → introspect SDL → codegen ORM), plus the GitHub Actions to automate that generation. Todaywww/server/index.tsreads functions/secrets/invocations with rawpgSQL; this gives those callers a typed client they can migrate to later (migration is out of scope here).Pipeline (two new workspace packages under
sdk/):Root scripts:
Generated client surface (6 tables):
CI automation (workflows)
Three workflows under
.github/workflows/mirror constructive-db's generate-all / schema-sdk-update / validate-introspection split, so the ORM stays in sync with the pgpm module without manual local regen:generate-orm.yml— reusable (workflow_call+ dispatch), the single source of truth. Spins upconstructiveio/postgres-plus:18, bootstraps roles, runspnpm run generate:orm(ephemeral deploy → SDL → ORM), detects drift, uploads the generated tree as an artifact, and exposeshas_changes/ref_shaoutputs. It only generates/reports — callers decide what to do.validate-orm.yml— PR check onpgpm/**/sdk/**. Regenerates viagenerate-orm.ymland fails the PR if the committed output is stale (forces contributors to commit fresh codegen).pull_request→main.sdk-update.yml— manualworkflow_dispatch. Regenerates, downloads the artifact, and opens achore/regenerate-orm-*PR with the fresh output when anything changed.Notes for reviewers
Two non-obvious bits live in
sdk/functions-sdk/scripts/generate-sdk.ts(the hand-written generator), both working around current@constructive-io/graphql-codegenbehavior so a single-target package builds cleanly:generateMultionly writes the top-levelsrc/index.tswhen there are 2+ targets. With one target (infra) it writes nothing, so the script emits the barrel itself (export * as infra from './infra'). Works unchanged when more targets are added.function_requirementcomposite as bothFunctionRequirement(object) andFunctionRequirementInput(input). Codegen stubs the object form asexport type FunctionRequirement = unknown;but omits the*Inputcounterpart, leaving dangling references that breaktsc. The script appendsexport type FunctionRequirementInput = unknown;for anyinput X {from the SDL that is referenced but undeclared — derived from the SDL so it stays in sync.eslint.config.mjsignores the generated SDK output (sdk/functions-sdk/src/**,sdk/functions-schema/src/**) — these are codegen artifacts (a newerno-empty-object-typerule flags them) and must not be hand-edited. Hand-writtenscripts/are still linted.Generated — do not edit (regenerate via
pnpm run generate:orm)sdk/functions-schema/schemas/*.graphql,sdk/functions-schema/src/index.tssdk/functions-sdk/src/**.agents/skills/orm-infra/Requires
constructiveio/postgres-plus:18for the ephemeral DB (Postgres 18uuidv7()).Verification
pnpm run generate:ormreproducible end-to-end (ephemeral deploy → SDL → ORM)pnpm --filter @constructive-io/functions-schema --filter @constructive-io/functions-sdk run build— cleantscpnpm run lint(full repo) — passesLink to Devin session: https://app.devin.ai/sessions/633efc205f0c445dbbb61c40679c2f78
Requested by: @pyramation