Skip to content

Commit 57df971

Browse files
authored
Merge pull request #32 from constructive-io/feat/provision-blueprint-and-codegen-bump
fix(provision): extend blueprint types with client-side cross-ref fields + bump @constructive-io/graphql-codegen to 4.30.2
2 parents 38eabdb + 9a9eefc commit 57df971

11 files changed

Lines changed: 107 additions & 66 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
}
4545
},
4646
"devDependencies": {
47-
"@constructive-io/graphql-codegen": "4.30.1",
47+
"@constructive-io/graphql-codegen": "4.30.2",
4848
"@types/jest": "^30.0.0",
4949
"@types/node": "^25.0.3",
5050
"@typescript-eslint/eslint-plugin": "^8.58.0",

packages/cli-e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"devDependencies": {
1313
"@agentic-db/sdk": "workspace:*",
14-
"graphql-server-test": "^2.10.6",
14+
"graphql-server-test": "^2.12.2",
1515
"pgsql-test": "^4.9.0"
1616
}
1717
}

packages/integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"devDependencies": {
1616
"@0no-co/graphql.web": "^1.2.0",
1717
"@agentic-kit/ollama": "^1.0.3",
18-
"@constructive-io/graphql-codegen": "4.30.1",
18+
"@constructive-io/graphql-codegen": "4.30.2",
1919
"@constructive-io/graphql-query": "3.14.1",
2020
"@constructive-io/graphql-types": "3.5.0",
2121
"@types/pg": "^8.16.0",

packages/provision/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"provision": "tsx src/provision.ts"
1717
},
1818
"dependencies": {
19-
"@constructive-io/node": "^0.10.2",
19+
"@constructive-io/node": "^0.10.3",
2020
"dotenv": "^16.4.5",
2121
"node-type-registry": "^0.16.0",
2222
"pg": "^8.20.0"

packages/provision/src/blueprint.ts

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
*/
1414

1515
import type {
16-
BlueprintDefinition,
17-
BlueprintTable,
16+
BlueprintDefinition as BaseBlueprintDefinition,
17+
BlueprintTable as BaseBlueprintTable,
1818
BlueprintNode,
19-
BlueprintRelation,
19+
BlueprintRelation as BaseBlueprintRelation,
2020
BlueprintField,
21-
BlueprintIndex,
21+
BlueprintIndex as BaseBlueprintIndex,
2222
BlueprintFullTextSearch,
2323
} from 'node-type-registry';
2424

@@ -29,17 +29,58 @@ import {
2929
type PlatformClient,
3030
} from './helpers';
3131

32-
// Re-export blueprint types for consumers
33-
export type {
34-
BlueprintDefinition,
35-
BlueprintTable,
36-
BlueprintNode,
37-
BlueprintRelation,
38-
BlueprintField,
39-
BlueprintIndex,
40-
BlueprintFullTextSearch,
32+
// ---------------------------------------------------------------------------
33+
// Blueprint types with client-side cross-ref support
34+
// ---------------------------------------------------------------------------
35+
//
36+
// The canonical node-type-registry blueprint shapes require concrete
37+
// table_name / source_table / target_table strings. In provision schemas we
38+
// want to declare tables and cross-references by a local ref ID so schemas
39+
// can be written in any order — provisionBlueprint then resolves
40+
// ref → table_name before sending to construct_blueprint.
41+
//
42+
// These extended types add ref / table_ref / source_ref / target_ref as
43+
// optional siblings of the canonical fields.
44+
45+
export type BlueprintTable = BaseBlueprintTable & {
46+
/** Client-side cross-ref ID; resolved to `table_name` by provisionBlueprint. */
47+
ref?: string;
48+
};
49+
50+
export type BlueprintIndex = Omit<BaseBlueprintIndex, 'table_name'> & {
51+
table_name?: string;
52+
/** Client-side cross-ref to a table by its `ref`; resolved to `table_name`. */
53+
table_ref?: string;
4154
};
4255

56+
type AddRelationRefs<T> = T extends {
57+
source_table: string;
58+
target_table: string;
59+
}
60+
? Omit<T, 'source_table' | 'target_table'> & {
61+
source_table?: string;
62+
target_table?: string;
63+
/** Client-side cross-ref; resolved to `source_table` by provisionBlueprint. */
64+
source_ref?: string;
65+
/** Client-side cross-ref; resolved to `target_table` by provisionBlueprint. */
66+
target_ref?: string;
67+
}
68+
: T;
69+
70+
export type BlueprintRelation = AddRelationRefs<BaseBlueprintRelation>;
71+
72+
export type BlueprintDefinition = Omit<
73+
BaseBlueprintDefinition,
74+
'tables' | 'relations' | 'indexes'
75+
> & {
76+
tables: BlueprintTable[];
77+
relations?: BlueprintRelation[];
78+
indexes?: BlueprintIndex[];
79+
};
80+
81+
// Re-export passthrough blueprint types for consumers
82+
export type { BlueprintNode, BlueprintField, BlueprintFullTextSearch };
83+
4384
// ---------------------------------------------------------------------------
4485
// Shared constants — standard org-scoped table defaults
4586
// ---------------------------------------------------------------------------
@@ -129,24 +170,24 @@ export async function provisionBlueprint(
129170
});
130171

131172
const serverDef: Record<string, unknown> = {
132-
tables: definition.tables.map((t) => ({
173+
tables: definition.tables.map((t): Record<string, unknown> => ({
133174
ref: t.ref,
134175
table_name: t.table_name,
135176
nodes: t.nodes,
136177
fields: t.fields,
137178
// Explicitly disable security — prevents construct_blueprint from
138179
// defaulting grant_roles to ['authenticated'] which would generate
139180
// invalid GRANT SQL when the grants array is empty.
140-
grant_roles: [],
141-
grants: [],
142-
policies: [],
181+
grant_roles: [] as string[],
182+
grants: [] as unknown[],
183+
policies: [] as unknown[],
143184
use_rls: false,
144185
})),
145-
relations: resolvedRelations.map((r) => ({
186+
relations: resolvedRelations.map((r): Record<string, unknown> => ({
146187
...r,
147-
grant_roles: [],
148-
grant_privileges: [],
149-
policies: [],
188+
grant_roles: [] as string[],
189+
grant_privileges: [] as unknown[],
190+
policies: [] as unknown[],
150191
})),
151192
indexes: resolvedIndexes,
152193
full_text_searches: definition.full_text_searches ?? [],

packages/rag/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@agentic-db/sdk": "workspace:*",
2323
"@agentic-kit/anthropic": "^1.0.3",
2424
"@agentic-kit/ollama": "^1.0.3",
25-
"@constructive-io/node": "^0.10.2",
25+
"@constructive-io/node": "^0.10.3",
2626
"agentic-kit": "^1.0.3",
2727
"dotenv": "^16.0.0"
2828
},

packages/worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"dependencies": {
2020
"@agentic-db/sdk": "workspace:*",
2121
"@agentic-kit/ollama": "^1.0.3",
22-
"@constructive-io/node": "^0.10.2",
22+
"@constructive-io/node": "^0.10.3",
2323
"agentic-kit": "^1.0.3",
2424
"dotenv": "^17.3.1",
2525
"graphile-worker": "^0.16.6"

0 commit comments

Comments
 (0)