Skip to content

Commit 4c13873

Browse files
authored
Merge pull request #1001 from constructive-io/devin/1776493787-relation-spatial-blueprint-fields
feat(node-type-registry): add source_field/target_field to RelationSpatial BlueprintRelation arm (v0.15.0)
2 parents dc6cad7 + 6e028c0 commit 4c13873

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

graphql/node-type-registry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-type-registry",
3-
"version": "0.14.0",
3+
"version": "0.15.0",
44
"description": "Node type definitions for the Constructive blueprint system. Single source of truth for all Authz*, Data*, Relation*, and View* node types.",
55
"author": "Constructive <developers@constructive.io>",
66
"main": "index.js",

graphql/node-type-registry/src/blueprint-types.generated.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,8 @@ export type BlueprintRelation = {
10541054
target_table: string;
10551055
source_schema_name?: string;
10561056
target_schema_name?: string;
1057+
/** Name of the geometry/geography column on source_table that carries the @spatialRelation smart tag. */source_field: string;
1058+
/** Name of the geometry/geography column on target_table that the predicate is evaluated against. */target_field: string;
10571059
} & Partial<RelationSpatialParams>;
10581060
/**
10591061
* ===========================================================================

graphql/node-type-registry/src/codegen/generate-types.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,34 @@ function buildRelationTypes(
537537
relationNodes: NodeTypeDefinition[]
538538
): t.ExportNamedDeclaration[] {
539539
const relationMembers: t.TSType[] = relationNodes.map((nt) => {
540-
const baseType = t.tsTypeLiteral([
540+
const baseMembers: t.TSTypeElement[] = [
541541
requiredProp('$type', strLit(nt.name)),
542542
requiredProp('source_table', t.tsStringKeyword()),
543543
requiredProp('target_table', t.tsStringKeyword()),
544544
optionalProp('source_schema_name', t.tsStringKeyword()),
545545
optionalProp('target_schema_name', t.tsStringKeyword()),
546-
]);
546+
];
547+
548+
// RelationSpatial is the only relation type that references *existing*
549+
// columns rather than creating FK/junction fields. Its blueprint JSON
550+
// therefore needs source_field / target_field (column *names* resolved
551+
// server-side by resolve_blueprint_field), which have no ID-space
552+
// equivalent in parameter_schema. Surface them here so blueprint authors
553+
// get autocomplete without a cast.
554+
if (nt.name === 'RelationSpatial') {
555+
baseMembers.push(
556+
addJSDoc(
557+
requiredProp('source_field', t.tsStringKeyword()),
558+
'Name of the geometry/geography column on source_table that carries the @spatialRelation smart tag.'
559+
),
560+
addJSDoc(
561+
requiredProp('target_field', t.tsStringKeyword()),
562+
'Name of the geometry/geography column on target_table that the predicate is evaluated against.'
563+
)
564+
);
565+
}
566+
567+
const baseType = t.tsTypeLiteral(baseMembers);
547568

548569
return t.tsIntersectionType([
549570
baseType,

0 commit comments

Comments
 (0)