fix(provision): extend blueprint types with client-side cross-ref fields#30
Closed
pyramation wants to merge 1 commit intomainfrom
Closed
fix(provision): extend blueprint types with client-side cross-ref fields#30pyramation wants to merge 1 commit intomainfrom
pyramation wants to merge 1 commit intomainfrom
Conversation
packages/provision declares tables, relations, and indexes using local `ref` / `table_ref` / `source_ref` / `target_ref` IDs so schemas can be written out-of-order; provisionBlueprint resolves these to `table_name` / `source_table` / `target_table` before sending the blueprint to construct_blueprint. node-type-registry@0.16.0 no longer carries these client-side fields on BlueprintTable / BlueprintIndex / BlueprintRelation. Extend the types locally in blueprint.ts (and re-export under the canonical names) so the 10 schema files and blueprint.ts itself type-check without touching any caller or weakening the server wire format. Also fixes TS7018 implicit-any[] errors on empty grant_roles / grants / policies / grant_privileges arrays inside the serverDef builder.
🤖 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:
|
|
Superseded by #32 (merged). Safe to close. |
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
packages/provisiondeclares tables, relations, and indexes using localref/table_ref/source_ref/target_refIDs so schemas can be written out-of-order.provisionBlueprint()then resolves these totable_name/source_table/target_tablebefore sending the blueprint toconstruct_blueprintserver-side.node-type-registry@0.16.0(pulled in as part of the PR #29 dep bump) no longer carries these client-side fields onBlueprintTable/BlueprintIndex/BlueprintRelation— they weren't part of the canonical server wire format. That caused ~260 TS2353/TS2339 errors acrosssrc/blueprint.tsand all 10 files undersrc/schemas/*, which broke the fullpnpm buildeven though the CLI publish (PR #29) is now unblocked.This PR fixes it entirely at the type level in a single file —
packages/provision/src/blueprint.ts:BlueprintTableasBaseBlueprintTable & { ref?: string }.BlueprintIndexwithtable_namerelaxed to optional andtable_ref?: stringadded.AddRelationRefs<T>over theBlueprintRelationunion so every arm gains optionalsource_ref/target_refwhile keepingsource_table/target_tableassignable.BlueprintDefinitionwith those extended table/relation/index arrays.Schemas already import from
'../blueprint'(notnode-type-registrydirectly), so zero caller changes — 10 schema files now type-check unchanged.Also fixes 6 TS7018 implicit-any[] errors on the empty
grant_roles/grants/policies/grant_privilegesarrays inside theserverDefbuilder by annotating the map callback return type and array element types.Full workspace
pnpm buildruns clean end-to-end (all 12 projects) after this patch.Follow-up (separate PR, upstream)
The generated embedder in
sdk/cli/generated/cli/embedder.tsthat unblocked PR #29 should also be pushed upstream to the template atgraphql/codegen/src/core/codegen/templates/embedder.tsinconstructive-io/constructive— otherwise the nextpnpm generate:allwill regenerate the narrowRecord<string, unknown>signatures and re-break publish. I have that change prepared locally onfeat/auto-embed-generic-helpersin that repo; will open the PR after this one lands.Review & Testing Checklist for Human
pnpm buildat the repo root and confirm all 12 workspace projects compile (provision + 11 others).pnpm -r testor at least the provision-adjacent tests to make sure the type relaxation didn't mask a real consumer bug.src/schemas/crm.ts) in your editor to confirm you still get IntelliSense on bothref(new) and the canonicalBlueprintTablefields.construct_blueprintpayload — the resolver inblueprint.ts(lines 122–159 in the new file) is unchanged, but worth a spot check thatreffields are correctly stripped/resolved intotable_name/source_table/target_tableon the wire.Notes
asannotations on empty literals.AddRelationRefs<T>helper distributes correctly over theBlueprintRelationunion because each arm satisfies{ source_table: string; target_table: string }— including theRelationSpatialarm, whose requiredsource_field/target_fieldpass through unchanged.ref/table_ref/source_ref/target_refas optional siblings rather than replacing the canonical names means schemas can freely mix both styles (already the case inspatial-relations.tsandcross-relations.ts).Link to Devin session: https://app.devin.ai/sessions/fabecb6a46504fc293feca22d9cc91d4
Requested by: @pyramation