-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathaltimate-core-export-ddl.ts
More file actions
29 lines (28 loc) · 1.14 KB
/
altimate-core-export-ddl.ts
File metadata and controls
29 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import z from "zod"
import { Tool } from "../../tool/tool"
import { Dispatcher } from "../native"
export const AltimateCoreExportDdlTool = Tool.define("altimate_core_export_ddl", {
description:
"Export a YAML/JSON schema as CREATE TABLE DDL statements. Provide schema_context or schema_path for accurate table/column resolution.",
parameters: z.object({
schema_path: z.string().optional().describe("Path to YAML/JSON schema file"),
schema_context: z.record(z.string(), z.any()).optional().describe("Inline schema definition"),
}),
async execute(args, ctx) {
try {
const result = await Dispatcher.call("altimate_core.export_ddl", {
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
})
const data = result.data as Record<string, any>
return {
title: "Export DDL: done",
metadata: { success: result.success },
output: data.ddl ?? JSON.stringify(data, null, 2),
}
} catch (e) {
const msg = e instanceof Error ? e.message : String(e)
return { title: "Export DDL: ERROR", metadata: { success: false }, output: `Failed: ${msg}` }
}
},
})