@agentic-kit/db-tools 0.10.3 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/tools/add-relation.js +1 -13
- package/esm/tools/provision-blueprint.js +1 -20
- package/esm/tools/templates.js +12 -4
- package/package.json +4 -4
- package/tools/add-relation.js +1 -13
- package/tools/provision-blueprint.js +1 -20
- package/tools/templates.js +12 -4
|
@@ -55,21 +55,9 @@ export const addRelationTool = {
|
|
|
55
55
|
const blueprintId = created.createBlueprint?.blueprint?.id;
|
|
56
56
|
if (!blueprintId)
|
|
57
57
|
throw new Error('Failed to create relation blueprint');
|
|
58
|
-
|
|
58
|
+
await modules.mutation
|
|
59
59
|
.constructBlueprint({ input: { blueprintId, schemaId } }, { select: { result: true } })
|
|
60
60
|
.unwrap();
|
|
61
|
-
if (!constructResult.constructBlueprint?.result) {
|
|
62
|
-
const constructions = await modules.blueprintConstruction
|
|
63
|
-
.findMany({
|
|
64
|
-
where: { blueprintId: { equalTo: blueprintId } },
|
|
65
|
-
orderBy: ['ID_DESC'],
|
|
66
|
-
first: 1,
|
|
67
|
-
select: { status: true, errorDetails: true },
|
|
68
|
-
})
|
|
69
|
-
.unwrap();
|
|
70
|
-
const error = constructions?.blueprintConstructions?.nodes?.[0]?.errorDetails ?? 'Unknown error';
|
|
71
|
-
return fail(`Failed to add relation: ${typeof error === 'string' ? error : JSON.stringify(error)}`);
|
|
72
|
-
}
|
|
73
61
|
}
|
|
74
62
|
catch (err) {
|
|
75
63
|
return fail(`Failed to add relation: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -54,28 +54,9 @@ export const provisionBlueprintTool = {
|
|
|
54
54
|
const blueprintId = createResult.createBlueprint?.blueprint?.id;
|
|
55
55
|
if (!blueprintId)
|
|
56
56
|
throw new Error('Failed to create blueprint');
|
|
57
|
-
|
|
57
|
+
await modules.mutation
|
|
58
58
|
.constructBlueprint({ input: { blueprintId, schemaId } }, { select: { result: true } })
|
|
59
59
|
.unwrap();
|
|
60
|
-
const result = constructResult.constructBlueprint?.result;
|
|
61
|
-
if (!result) {
|
|
62
|
-
const constructions = await modules.blueprintConstruction
|
|
63
|
-
.findMany({
|
|
64
|
-
where: { blueprintId: { equalTo: blueprintId } },
|
|
65
|
-
orderBy: ['ID_DESC'],
|
|
66
|
-
first: 1,
|
|
67
|
-
select: { status: true, errorDetails: true },
|
|
68
|
-
})
|
|
69
|
-
.unwrap();
|
|
70
|
-
const error = constructions?.blueprintConstructions?.nodes?.[0]?.errorDetails ?? 'Unknown error';
|
|
71
|
-
const details = {
|
|
72
|
-
created: 0,
|
|
73
|
-
total: params.definition.tables.length,
|
|
74
|
-
tables: [],
|
|
75
|
-
error: typeof error === 'string' ? error : JSON.stringify(error),
|
|
76
|
-
};
|
|
77
|
-
return { content: [{ type: 'text', text: formatText(params.name, details) }], details };
|
|
78
|
-
}
|
|
79
60
|
const relations = params.definition.relations ?? [];
|
|
80
61
|
const details = {
|
|
81
62
|
created: params.definition.tables.length,
|
package/esm/tools/templates.js
CHANGED
|
@@ -255,10 +255,18 @@ export const applyTemplateTool = {
|
|
|
255
255
|
const constructResult = await modules.mutation
|
|
256
256
|
.constructBlueprint({ input: { blueprintId, schemaId } }, { select: { result: true } })
|
|
257
257
|
.unwrap();
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
260
|
-
|
|
261
|
-
const
|
|
258
|
+
const constructionId = constructResult.constructBlueprint?.result;
|
|
259
|
+
if (!constructionId)
|
|
260
|
+
throw new Error('constructBlueprint returned no construction id');
|
|
261
|
+
const constructions = await modules.blueprintConstruction
|
|
262
|
+
.findMany({
|
|
263
|
+
where: { id: { equalTo: constructionId } },
|
|
264
|
+
first: 1,
|
|
265
|
+
select: { tableMap: true },
|
|
266
|
+
})
|
|
267
|
+
.unwrap();
|
|
268
|
+
const tableMap = (constructions?.blueprintConstructions?.nodes?.[0]?.tableMap ?? {});
|
|
269
|
+
const createdCount = Object.keys(tableMap).length;
|
|
262
270
|
return done(true, `Applied template "${params.templateName}" — created ${createdCount} table${createdCount === 1 ? '' : 's'}`);
|
|
263
271
|
}
|
|
264
272
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentic-kit/db-tools",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "harness-neutral Constructive database tools — provisioning, schema, policies, records, templates and codegen as HarnessTools any adapter can bind",
|
|
6
6
|
"main": "index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"12factor-env": "^1.34.0",
|
|
33
33
|
"@agentic-kit/harness": "^0.18.0",
|
|
34
|
-
"@constructive-io/graphql-query": "^4.21.
|
|
35
|
-
"@constructive-io/sdk": "^1.20.
|
|
34
|
+
"@constructive-io/graphql-query": "^4.21.4",
|
|
35
|
+
"@constructive-io/sdk": "^1.20.4",
|
|
36
36
|
"node-type-registry": "^1.21.0",
|
|
37
37
|
"zod": "^4.4.3"
|
|
38
38
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"database",
|
|
46
46
|
"constructive"
|
|
47
47
|
],
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "b6c80da2ba0532a4aaf0d0154901efa7911974d8"
|
|
49
49
|
}
|
package/tools/add-relation.js
CHANGED
|
@@ -58,21 +58,9 @@ exports.addRelationTool = {
|
|
|
58
58
|
const blueprintId = created.createBlueprint?.blueprint?.id;
|
|
59
59
|
if (!blueprintId)
|
|
60
60
|
throw new Error('Failed to create relation blueprint');
|
|
61
|
-
|
|
61
|
+
await modules.mutation
|
|
62
62
|
.constructBlueprint({ input: { blueprintId, schemaId } }, { select: { result: true } })
|
|
63
63
|
.unwrap();
|
|
64
|
-
if (!constructResult.constructBlueprint?.result) {
|
|
65
|
-
const constructions = await modules.blueprintConstruction
|
|
66
|
-
.findMany({
|
|
67
|
-
where: { blueprintId: { equalTo: blueprintId } },
|
|
68
|
-
orderBy: ['ID_DESC'],
|
|
69
|
-
first: 1,
|
|
70
|
-
select: { status: true, errorDetails: true },
|
|
71
|
-
})
|
|
72
|
-
.unwrap();
|
|
73
|
-
const error = constructions?.blueprintConstructions?.nodes?.[0]?.errorDetails ?? 'Unknown error';
|
|
74
|
-
return fail(`Failed to add relation: ${typeof error === 'string' ? error : JSON.stringify(error)}`);
|
|
75
|
-
}
|
|
76
64
|
}
|
|
77
65
|
catch (err) {
|
|
78
66
|
return fail(`Failed to add relation: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -57,28 +57,9 @@ exports.provisionBlueprintTool = {
|
|
|
57
57
|
const blueprintId = createResult.createBlueprint?.blueprint?.id;
|
|
58
58
|
if (!blueprintId)
|
|
59
59
|
throw new Error('Failed to create blueprint');
|
|
60
|
-
|
|
60
|
+
await modules.mutation
|
|
61
61
|
.constructBlueprint({ input: { blueprintId, schemaId } }, { select: { result: true } })
|
|
62
62
|
.unwrap();
|
|
63
|
-
const result = constructResult.constructBlueprint?.result;
|
|
64
|
-
if (!result) {
|
|
65
|
-
const constructions = await modules.blueprintConstruction
|
|
66
|
-
.findMany({
|
|
67
|
-
where: { blueprintId: { equalTo: blueprintId } },
|
|
68
|
-
orderBy: ['ID_DESC'],
|
|
69
|
-
first: 1,
|
|
70
|
-
select: { status: true, errorDetails: true },
|
|
71
|
-
})
|
|
72
|
-
.unwrap();
|
|
73
|
-
const error = constructions?.blueprintConstructions?.nodes?.[0]?.errorDetails ?? 'Unknown error';
|
|
74
|
-
const details = {
|
|
75
|
-
created: 0,
|
|
76
|
-
total: params.definition.tables.length,
|
|
77
|
-
tables: [],
|
|
78
|
-
error: typeof error === 'string' ? error : JSON.stringify(error),
|
|
79
|
-
};
|
|
80
|
-
return { content: [{ type: 'text', text: formatText(params.name, details) }], details };
|
|
81
|
-
}
|
|
82
63
|
const relations = params.definition.relations ?? [];
|
|
83
64
|
const details = {
|
|
84
65
|
created: params.definition.tables.length,
|
package/tools/templates.js
CHANGED
|
@@ -259,10 +259,18 @@ exports.applyTemplateTool = {
|
|
|
259
259
|
const constructResult = await modules.mutation
|
|
260
260
|
.constructBlueprint({ input: { blueprintId, schemaId } }, { select: { result: true } })
|
|
261
261
|
.unwrap();
|
|
262
|
-
const
|
|
263
|
-
if (!
|
|
264
|
-
|
|
265
|
-
const
|
|
262
|
+
const constructionId = constructResult.constructBlueprint?.result;
|
|
263
|
+
if (!constructionId)
|
|
264
|
+
throw new Error('constructBlueprint returned no construction id');
|
|
265
|
+
const constructions = await modules.blueprintConstruction
|
|
266
|
+
.findMany({
|
|
267
|
+
where: { id: { equalTo: constructionId } },
|
|
268
|
+
first: 1,
|
|
269
|
+
select: { tableMap: true },
|
|
270
|
+
})
|
|
271
|
+
.unwrap();
|
|
272
|
+
const tableMap = (constructions?.blueprintConstructions?.nodes?.[0]?.tableMap ?? {});
|
|
273
|
+
const createdCount = Object.keys(tableMap).length;
|
|
266
274
|
return done(true, `Applied template "${params.templateName}" — created ${createdCount} table${createdCount === 1 ? '' : 's'}`);
|
|
267
275
|
}
|
|
268
276
|
catch (err) {
|