@databricks/appkit-ui 0.65.0 → 0.66.0
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/CLAUDE.md +18 -0
- package/dist/cli/commands/generate-types.js +12 -3
- package/dist/cli/commands/generate-types.js.map +1 -1
- package/dist/react/ui/badge.d.ts +1 -1
- package/dist/react/ui/button-group.d.ts +1 -1
- package/dist/react/ui/button.d.ts +2 -2
- package/dist/react/ui/field.d.ts +1 -1
- package/dist/react/ui/input-group.d.ts +1 -1
- package/docs/api/appkit/Function.bigid.md +10 -0
- package/docs/api/appkit/Function.bigint.md +10 -0
- package/docs/api/appkit/Function.boolean.md +10 -0
- package/docs/api/appkit/Function.database.md +56 -0
- package/docs/api/appkit/Function.defineSchema.md +17 -0
- package/docs/api/appkit/Function.enumColumn.md +17 -0
- package/docs/api/appkit/Function.fk.md +18 -0
- package/docs/api/appkit/Function.id.md +10 -0
- package/docs/api/appkit/Function.integer.md +10 -0
- package/docs/api/appkit/Function.jsonb.md +10 -0
- package/docs/api/appkit/Function.text.md +10 -0
- package/docs/api/appkit/Function.timestamp.md +19 -0
- package/docs/api/appkit/Function.uuid.md +10 -0
- package/docs/api/appkit/Function.varchar.md +16 -0
- package/docs/api/appkit/Interface.DatabaseRegistry.md +3 -0
- package/docs/api/appkit/Interface.Schema.md +28 -0
- package/docs/api/appkit/TypeAlias.DatabaseExports.md +35 -0
- package/docs/api/appkit/TypeAlias.IDatabaseConfig.md +25 -0
- package/docs/api/appkit.md +18 -0
- package/llms.txt +18 -0
- package/package.json +2 -2
- package/sbom.cdx.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -83,16 +83,23 @@ npx @databricks/appkit docs <query>
|
|
|
83
83
|
- [Function: agentIdFromMarkdownPath()](./docs/api/appkit/Function.agentIdFromMarkdownPath.md): Derives the logical agent id from a markdown path. When the file is named
|
|
84
84
|
- [Function: appKitServingTypesPlugin()](./docs/api/appkit/Function.appKitServingTypesPlugin.md): Vite plugin to generate TypeScript types for AppKit serving endpoints.
|
|
85
85
|
- [Function: appKitTypesPlugin()](./docs/api/appkit/Function.appKitTypesPlugin.md): Vite plugin to generate types for AppKit queries.
|
|
86
|
+
- [Function: bigid()](./docs/api/appkit/Function.bigid.md): Returns
|
|
87
|
+
- [Function: bigint()](./docs/api/appkit/Function.bigint.md): Returns
|
|
88
|
+
- [Function: boolean()](./docs/api/appkit/Function.boolean.md): Returns
|
|
86
89
|
- [Function: createAgent()](./docs/api/appkit/Function.createAgent.md): Pure factory for agent definitions: cycle-detects the sub-agent graph and
|
|
87
90
|
- [Function: createApp()](./docs/api/appkit/Function.createApp.md): Bootstraps AppKit with the provided configuration.
|
|
88
91
|
- [Function: createLakebasePool()](./docs/api/appkit/Function.createLakebasePool.md): Create a Lakebase pool with appkit's logger integration.
|
|
89
92
|
- [Function: createLakebasePoolManager()](./docs/api/appkit/Function.createLakebasePoolManager.md): Create a pool manager that maintains per-key Lakebase connection pools.
|
|
90
93
|
- [Function: createWorkspaceClient()](./docs/api/appkit/Function.createWorkspaceClient.md): Construct an AppKit workspace client.
|
|
94
|
+
- [Function: database()](./docs/api/appkit/Function.database.md): Create a typed database plugin registration for a finalized schema.
|
|
91
95
|
- [Function: defineManifest()](./docs/api/appkit/Function.defineManifest.md): Validates a raw manifest (typically a manifest.json import) against the
|
|
96
|
+
- [Function: defineSchema()](./docs/api/appkit/Function.defineSchema.md): Parameters
|
|
92
97
|
- [Function: defineTool()](./docs/api/appkit/Function.defineTool.md): Defines a single tool entry for a plugin's internal registry.
|
|
98
|
+
- [Function: enumColumn()](./docs/api/appkit/Function.enumColumn.md): Parameters
|
|
93
99
|
- [Function: executeFromRegistry()](./docs/api/appkit/Function.executeFromRegistry.md): Validates tool-call arguments against the entry's schema and invokes its
|
|
94
100
|
- [Function: extractServingEndpoints()](./docs/api/appkit/Function.extractServingEndpoints.md): Extract serving endpoint config from a server file by AST-parsing it.
|
|
95
101
|
- [Function: findServerFile()](./docs/api/appkit/Function.findServerFile.md): Find the server entry file by checking candidate paths in order.
|
|
102
|
+
- [Function: fk()](./docs/api/appkit/Function.fk.md): Declare foreign-key to another column.
|
|
96
103
|
- [Function: fromSupervisorApi()](./docs/api/appkit/Function.fromSupervisorApi.md): Creates an AgentAdapter backed by the Databricks AI Gateway
|
|
97
104
|
- [Function: functionToolToDefinition()](./docs/api/appkit/Function.functionToolToDefinition.md): Parameters
|
|
98
105
|
- [Function: generateDatabaseCredential()](./docs/api/appkit/Function.generateDatabaseCredential.md): Generate OAuth credentials for Postgres database connection using the proper Postgres API.
|
|
@@ -103,19 +110,26 @@ npx @databricks/appkit docs <query>
|
|
|
103
110
|
- [Function: getResourceRequirements()](./docs/api/appkit/Function.getResourceRequirements.md): Gets the resource requirements from a plugin's manifest.
|
|
104
111
|
- [Function: getUsernameWithApiLookup()](./docs/api/appkit/Function.getUsernameWithApiLookup.md): Resolves the PostgreSQL username for a Lakebase connection.
|
|
105
112
|
- [Function: getWorkspaceClient()](./docs/api/appkit/Function.getWorkspaceClient.md): Get workspace client from config or SDK default auth chain
|
|
113
|
+
- [Function: id()](./docs/api/appkit/Function.id.md): Returns
|
|
114
|
+
- [Function: integer()](./docs/api/appkit/Function.integer.md): Returns
|
|
106
115
|
- [Function: isFunctionTool()](./docs/api/appkit/Function.isFunctionTool.md): Parameters
|
|
107
116
|
- [Function: isHostedTool()](./docs/api/appkit/Function.isHostedTool.md): Parameters
|
|
108
117
|
- [Function: isSQLTypeMarker()](./docs/api/appkit/Function.isSQLTypeMarker.md): Type guard to check if a value is a SQL type marker
|
|
109
118
|
- [Function: isSupervisorTool()](./docs/api/appkit/Function.isSupervisorTool.md): Type guard for HostedSupervisorTool. Used by the agents plugin
|
|
110
119
|
- [Function: isToolkitEntry()](./docs/api/appkit/Function.isToolkitEntry.md): Type guard for ToolkitEntry — used by the agents plugin to differentiate
|
|
120
|
+
- [Function: jsonb()](./docs/api/appkit/Function.jsonb.md): Returns
|
|
111
121
|
- [Function: loadAgentFromFile()](./docs/api/appkit/Function.loadAgentFromFile.md): Loads a single markdown agent file and resolves its frontmatter against
|
|
112
122
|
- [Function: loadAgentsFromDir()](./docs/api/appkit/Function.loadAgentsFromDir.md): Scans a directory for one subdirectory per agent, each containing
|
|
113
123
|
- [Function: mcpServer()](./docs/api/appkit/Function.mcpServer.md): Factory for declaring a custom MCP server tool.
|
|
114
124
|
- [Function: parseTextToolCalls()](./docs/api/appkit/Function.parseTextToolCalls.md): Parses text-based tool calls from model output.
|
|
115
125
|
- [Function: resolveHostedTools()](./docs/api/appkit/Function.resolveHostedTools.md): Parameters
|
|
116
126
|
- [Function: runAgent()](./docs/api/appkit/Function.runAgent.md): Standalone agent execution without createApp. Resolves the adapter, binds
|
|
127
|
+
- [Function: text()](./docs/api/appkit/Function.text.md): Returns
|
|
128
|
+
- [Function: timestamp()](./docs/api/appkit/Function.timestamp.md): Parameters
|
|
117
129
|
- [Function: tool()](./docs/api/appkit/Function.tool.md): Factory for defining function tools with Zod schemas.
|
|
118
130
|
- [Function: toolsFromRegistry()](./docs/api/appkit/Function.toolsFromRegistry.md): Produces the AgentToolDefinition[] a ToolProvider exposes to the LLM,
|
|
131
|
+
- [Function: uuid()](./docs/api/appkit/Function.uuid.md): Returns
|
|
132
|
+
- [Function: varchar()](./docs/api/appkit/Function.varchar.md): Parameters
|
|
119
133
|
- [Interface: AgentAdapter](./docs/api/appkit/Interface.AgentAdapter.md): Properties
|
|
120
134
|
- [Interface: AgentDefinition](./docs/api/appkit/Interface.AgentDefinition.md): Properties
|
|
121
135
|
- [Interface: AgentInput](./docs/api/appkit/Interface.AgentInput.md): Properties
|
|
@@ -126,6 +140,7 @@ npx @databricks/appkit docs <query>
|
|
|
126
140
|
- [Interface: BasePluginConfig](./docs/api/appkit/Interface.BasePluginConfig.md): Base configuration interface for AppKit plugins
|
|
127
141
|
- [Interface: CacheConfig](./docs/api/appkit/Interface.CacheConfig.md): Configuration for the CacheInterceptor. Controls TTL, size limits, storage backend, and probabilistic cleanup.
|
|
128
142
|
- [Interface: DatabaseCredential](./docs/api/appkit/Interface.DatabaseCredential.md): Database credentials with OAuth token for Postgres connection
|
|
143
|
+
- [Interface: DatabaseRegistry](./docs/api/appkit/Interface.DatabaseRegistry.md): CANONICAL augmentation target. Empty by default; the generated database.d.ts
|
|
129
144
|
- [Interface: EndpointConfig](./docs/api/appkit/Interface.EndpointConfig.md): Properties
|
|
130
145
|
- [Interface: FilePolicyUser](./docs/api/appkit/Interface.FilePolicyUser.md): Minimal user identity passed to the policy function.
|
|
131
146
|
- [Interface: FileResource](./docs/api/appkit/Interface.FileResource.md): Describes the file or directory being acted upon.
|
|
@@ -156,6 +171,7 @@ npx @databricks/appkit docs <query>
|
|
|
156
171
|
- [Interface: ResourceRequirement](./docs/api/appkit/Interface.ResourceRequirement.md): Declares a resource requirement for a plugin.
|
|
157
172
|
- [Interface: RunAgentInput](./docs/api/appkit/Interface.RunAgentInput.md): Properties
|
|
158
173
|
- [Interface: RunAgentResult](./docs/api/appkit/Interface.RunAgentResult.md): Properties
|
|
174
|
+
- [Interface: Schema](./docs/api/appkit/Interface.Schema.md): Properties
|
|
159
175
|
- [Interface: SearchRequest](./docs/api/appkit/Interface.SearchRequest.md): Properties
|
|
160
176
|
- [Interface: SearchResponse<T>](./docs/api/appkit/Interface.SearchResponse.md): Type Parameters
|
|
161
177
|
- [Interface: SearchResult<T>](./docs/api/appkit/Interface.SearchResult.md): Type Parameters
|
|
@@ -183,11 +199,13 @@ npx @databricks/appkit docs <query>
|
|
|
183
199
|
- [Type Alias: AgentToolsFn()](./docs/api/appkit/TypeAlias.AgentToolsFn.md): Function form of AgentDefinition.tools. Receives the typed
|
|
184
200
|
- [Type Alias: BaseSystemPromptOption](./docs/api/appkit/TypeAlias.BaseSystemPromptOption.md)
|
|
185
201
|
- [Type Alias: ConfigSchema](./docs/api/appkit/TypeAlias.ConfigSchema.md): Configuration schema definition for plugin config.
|
|
202
|
+
- [Type Alias: DatabaseExports](./docs/api/appkit/TypeAlias.DatabaseExports.md): Typed database API published by the plugin.
|
|
186
203
|
- [Type Alias: ExecutionResult<T>](./docs/api/appkit/TypeAlias.ExecutionResult.md): Discriminated union for plugin execution results.
|
|
187
204
|
- [Type Alias: FileAction](./docs/api/appkit/TypeAlias.FileAction.md): Every action the files plugin can perform.
|
|
188
205
|
- [Type Alias: FilePolicy()](./docs/api/appkit/TypeAlias.FilePolicy.md): A policy function that decides whether user may perform action on
|
|
189
206
|
- [Type Alias: HostedTool](./docs/api/appkit/TypeAlias.HostedTool.md)
|
|
190
207
|
- [Type Alias: IAppRouter](./docs/api/appkit/TypeAlias.IAppRouter.md): Express router type for plugin route registration
|
|
208
|
+
- [Type Alias: IDatabaseConfig<TSchema>](./docs/api/appkit/TypeAlias.IDatabaseConfig.md): Configuration for one schema-bound DatabasePlugin instance.
|
|
191
209
|
- [Type Alias: JobsExport()](./docs/api/appkit/TypeAlias.JobsExport.md): Public API shape of the jobs plugin.
|
|
192
210
|
- [Type Alias: PluginData<T, U, N>](./docs/api/appkit/TypeAlias.PluginData.md): Tuple of plugin class, config, and name. Created by toPlugin() and passed to createApp().
|
|
193
211
|
- [Type Alias: Plugins](./docs/api/appkit/TypeAlias.Plugins.md): Plugin map passed to the function form of AgentDefinition.tools.
|
|
@@ -30,9 +30,9 @@ async function runGenerateTypes(rootDir, outFile, warehouseId, options) {
|
|
|
30
30
|
const noCache = options?.noCache || false;
|
|
31
31
|
const mode = resolveTypegenMode(options);
|
|
32
32
|
const typeGen = await import("@databricks/appkit/type-generator");
|
|
33
|
+
const resolvedOutFile = outFile || path.join(process.cwd(), "shared/appkit-types/analytics.d.ts");
|
|
33
34
|
const resolvedWarehouseId = warehouseId || process.env.DATABRICKS_WAREHOUSE_ID;
|
|
34
35
|
if (resolvedWarehouseId) {
|
|
35
|
-
const resolvedOutFile = outFile || path.join(process.cwd(), "shared/appkit-types/analytics.d.ts");
|
|
36
36
|
const queryFolder = path.join(resolvedRootDir, "config/queries");
|
|
37
37
|
const metricViewsFolder = path.join(resolvedRootDir, "config/metric-views");
|
|
38
38
|
const hasQueries = fs.existsSync(queryFolder);
|
|
@@ -60,13 +60,22 @@ async function runGenerateTypes(rootDir, outFile, warehouseId, options) {
|
|
|
60
60
|
noCache
|
|
61
61
|
});
|
|
62
62
|
console.log(`Generated serving types: ${servingOutFile}`);
|
|
63
|
+
const databaseSchemaFile = path.join(resolvedRootDir, "config/database/schema.ts");
|
|
64
|
+
const databaseOutFile = path.join(path.dirname(resolvedOutFile), typeGen.DATABASE_TYPES_FILE);
|
|
65
|
+
if (fs.existsSync(databaseSchemaFile) || fs.existsSync(databaseOutFile)) {
|
|
66
|
+
await typeGen.generateDatabaseTypes({
|
|
67
|
+
schemaFile: databaseSchemaFile,
|
|
68
|
+
outFile: databaseOutFile
|
|
69
|
+
});
|
|
70
|
+
console.log(`Generated database types: ${databaseOutFile}`);
|
|
71
|
+
}
|
|
63
72
|
} catch (error) {
|
|
64
73
|
if (error instanceof Error && error.message.includes("Cannot find module")) {
|
|
65
74
|
console.error("Error: The 'generate-types' command is only available in @databricks/appkit.");
|
|
66
75
|
console.error("Please install @databricks/appkit to use this command.");
|
|
67
76
|
process.exit(1);
|
|
68
77
|
}
|
|
69
|
-
if (error instanceof Error && (error.name === "TypegenSyntaxError" || error.name === "TypegenFatalError")) {
|
|
78
|
+
if (error instanceof Error && (error.name === "TypegenSyntaxError" || error.name === "TypegenFatalError" || error.name === "DatabaseTypegenError")) {
|
|
70
79
|
console.error(error.message);
|
|
71
80
|
process.exit(1);
|
|
72
81
|
}
|
|
@@ -158,7 +167,7 @@ async function generateTypesAction(rootDir, outFile, warehouseId, options) {
|
|
|
158
167
|
else console.log("Type refresh already in progress, skipping.");
|
|
159
168
|
}
|
|
160
169
|
}
|
|
161
|
-
const generateTypesCommand = new Command("generate-types").description("Generate TypeScript types from
|
|
170
|
+
const generateTypesCommand = new Command("generate-types").description("Generate TypeScript types from AppKit configuration").argument("[rootDir]", "Root directory of the project", process.cwd()).argument("[outFile]", "Output file path", path.join(process.cwd(), "shared/appkit-types/analytics.d.ts")).argument("[warehouseId]", "Databricks warehouse ID").option("--no-cache", "Disable caching for type generation").option("--wait", "Wait for warehouse readiness instead of degrading (use for CI)").addOption(new Option("--worker-lock <path>", "Internal: detached worker lock path").hideHelp()).addHelpText("after", `
|
|
162
171
|
Examples:
|
|
163
172
|
$ appkit generate-types
|
|
164
173
|
$ appkit generate-types . shared/appkit-types/analytics.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-types.js","names":[],"sources":["../../../src/cli/commands/generate-types.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { Command, Option } from \"commander\";\n\nimport { METRIC_CONFIG_FILE } from \"../../schemas/metric-fqn\";\nimport {\n acquireSpawnLock,\n getSpawnLockPath,\n releaseSpawnLock,\n} from \"./spawn-lock.js\";\n\n/**\n * Resolve the typegen pre-flight mode for the CLI. Defaults to \"non-blocking\" —\n * a one-shot CLI can't describe in the background, so by default it never\n * describes at all: it skips the warehouse probe AND every DESCRIBE, emits\n * best-available types (cache where the SQL hash matches, else `result: unknown`)\n * and returns immediately, never blocking on — or failing because of — a\n * warehouse, even a RUNNING one. Pass `--wait` (commander sets `wait: true`)\n * for a deliberate/CI invocation that should wait for a starting warehouse and\n * fail fast on a stopped one.\n */\nexport function resolveTypegenMode(options?: {\n wait?: boolean;\n}): \"non-blocking\" | \"blocking\" {\n return options?.wait ? \"blocking\" : \"non-blocking\";\n}\n\n/** Options parsed by commander for the generate-types command. */\ninterface GenerateTypesOptions {\n noCache?: boolean;\n wait?: boolean;\n /**\n * Internal: present only on the detached worker invocation. Carries the path\n * of the single-flight lock this worker must release when it finishes. Its\n * presence is what marks an invocation as \"the worker\" — workers always run\n * with `--wait`, so they never spawn another worker (only non-blocking runs\n * spawn), which terminates the recursion.\n */\n workerLock?: string;\n}\n\n/**\n * Generate types command implementation. Runs the library generate (which, in\n * non-blocking mode, writes degraded types and returns immediately). This is the\n * SAME work the worker performs in blocking mode in the background.\n */\nasync function runGenerateTypes(\n rootDir?: string,\n outFile?: string,\n warehouseId?: string,\n options?: GenerateTypesOptions,\n) {\n try {\n const resolvedRootDir = rootDir || process.cwd();\n const noCache = options?.noCache || false;\n const mode = resolveTypegenMode(options);\n\n const typeGen = await import(\"@databricks/appkit/type-generator\");\n\n // Generate analytics query types (requires warehouse ID)\n const resolvedWarehouseId =\n warehouseId || process.env.DATABRICKS_WAREHOUSE_ID;\n\n if (resolvedWarehouseId) {\n const resolvedOutFile =\n outFile ||\n path.join(process.cwd(), \"shared/appkit-types/analytics.d.ts\");\n\n const queryFolder = path.join(resolvedRootDir, \"config/queries\");\n const metricViewsFolder = path.join(\n resolvedRootDir,\n \"config/metric-views\",\n );\n const hasQueries = fs.existsSync(queryFolder);\n const hasMetricViews = fs.existsSync(metricViewsFolder);\n\n // Generate when either config surface exists. Metric-view types are\n // independent of `.sql` queries — an app can declare metric views in\n // `config/metric-views/` without a `config/queries/` folder.\n if (hasQueries || hasMetricViews) {\n await typeGen.generateFromEntryPoint({\n queryFolder: hasQueries ? queryFolder : undefined,\n metricViewsFolder: hasMetricViews ? metricViewsFolder : undefined,\n outFile: resolvedOutFile,\n warehouseId: resolvedWarehouseId,\n noCache,\n mode,\n });\n\n if (hasQueries) {\n console.log(`Generated query types: ${resolvedOutFile}`);\n }\n\n const metricConfig = path.join(metricViewsFolder, METRIC_CONFIG_FILE);\n if (fs.existsSync(metricConfig)) {\n const typesDir = path.dirname(resolvedOutFile);\n console.log(\n `Generated metric types: ${path.join(typesDir, \"metric-views.ts\")}`,\n );\n }\n }\n } else {\n console.error(\n \"Skipping query type generation: no warehouse ID. Set DATABRICKS_WAREHOUSE_ID or pass as argument.\",\n );\n }\n\n // Generate serving endpoint types (no warehouse required)\n const servingOutFile = path.join(\n process.cwd(),\n \"shared/appkit-types/serving.d.ts\",\n );\n await typeGen.generateServingTypes({\n outFile: servingOutFile,\n noCache,\n });\n console.log(`Generated serving types: ${servingOutFile}`);\n } catch (error) {\n if (\n error instanceof Error &&\n error.message.includes(\"Cannot find module\")\n ) {\n console.error(\n \"Error: The 'generate-types' command is only available in @databricks/appkit.\",\n );\n console.error(\"Please install @databricks/appkit to use this command.\");\n process.exit(1);\n }\n // TypegenSyntaxError / TypegenFatalError carry a complete, actionable\n // message (which queries failed and how to debug them). The stack trace\n // points into appkit internals and is noise for app developers, so print\n // only the message and exit non-zero instead of letting it bubble up.\n if (\n error instanceof Error &&\n (error.name === \"TypegenSyntaxError\" ||\n error.name === \"TypegenFatalError\")\n ) {\n console.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n}\n\n/**\n * Spawn the detached blocking worker that refreshes real types in the background\n * after the foreground non-blocking generate has already written degraded types.\n *\n * Re-invokes THIS CLI (`process.execPath` + `process.argv[1]` — the bin entry\n * that launched us) with `generate-types --wait --worker-lock <lockPath>` plus\n * the same positional target options the foreground used, so the worker writes\n * to the same out file / reads the same query folder. The worker is:\n * - `detached: true` + `.unref()` so it outlives this process (install/dev-setup\n * can finish and exit while the worker keeps warming the warehouse).\n * - `stdio: \"ignore\"` so it never holds the parent's pipes open or interleaves\n * output into the install/dev log.\n *\n * Spawning is wrapped so any failure is non-fatal: the caller still has degraded\n * types and exits 0.\n *\n * @param lockPath - the acquired single-flight lock; passed to the worker so it\n * releases the SAME lock when it finishes.\n * @param targets - the foreground's positional args, forwarded verbatim.\n * @returns true if the worker was spawned, false if spawning threw.\n */\nexport function spawnTypegenWorker(\n lockPath: string,\n targets: { rootDir?: string; outFile?: string; warehouseId?: string },\n): boolean {\n // The script the runtime launched us with (the `appkit` bin shim). Re-running\n // it under the same node binary reproduces this exact CLI in the worker.\n const cliEntry = process.argv[1];\n\n // Forward the positionals in declaration order (rootDir, outFile,\n // warehouseId). Stop at the first undefined so we never pass a literal\n // \"undefined\" — commander would treat it as a positional value. (rootDir is\n // effectively always set by commander's default, but guard anyway.)\n const positionals: string[] = [];\n for (const value of [targets.rootDir, targets.outFile, targets.warehouseId]) {\n if (value === undefined) break;\n positionals.push(value);\n }\n\n const args = [\n // Forward the parent's node/loader flags so the worker runs under the same\n // runtime. Critically this carries tsx's `--require`/`--import` when the CLI\n // is run from source (`tsx index.ts …`); without them the worker would be\n // `node index.ts …`, which can't parse TypeScript and dies silently — the\n // degraded types would then never refresh. Empty for the built bin (plain\n // `node bin/appkit.js`), so production behaviour is unchanged.\n ...process.execArgv,\n cliEntry,\n \"generate-types\",\n \"--wait\",\n \"--worker-lock\",\n lockPath,\n ...positionals,\n ];\n\n try {\n const child = spawn(process.execPath, args, {\n detached: true,\n stdio: \"ignore\",\n });\n child.unref();\n return true;\n } catch (error) {\n // Non-fatal: the foreground already wrote degraded types. Log and move on.\n console.error(\n `Could not start background type refresh: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n return false;\n }\n}\n\n/**\n * The command action. Orchestrates the non-blocking foreground contract:\n * 1. Run the library generate (writes degraded types immediately in non-blocking\n * mode; does the full blocking lifecycle when this is the worker).\n * 2. If this is a non-blocking, non-worker invocation, try to spawn the detached\n * blocking worker behind the single-flight lock. If the lock is already held\n * by a live worker, skip (single-flight) with a one-line note. Either way the\n * foreground returns normally (exit 0).\n * 3. If this IS the worker (`--worker-lock` present), it ran blocking above and\n * releases the lock here (and via a process-exit guard, so a hard failure /\n * process.exit still frees it).\n */\nasync function generateTypesAction(\n rootDir: string | undefined,\n outFile: string | undefined,\n warehouseId: string | undefined,\n options: GenerateTypesOptions,\n) {\n const isWorker = typeof options.workerLock === \"string\";\n\n // A worker must always free its lock, even if the blocking generate throws or\n // calls process.exit (TypegenFatalError → exit 1). The exit handler covers the\n // process.exit / uncaught paths; the finally covers the normal return.\n if (isWorker && options.workerLock) {\n const lockPath = options.workerLock;\n process.once(\"exit\", () => releaseSpawnLock(lockPath));\n }\n\n try {\n await runGenerateTypes(rootDir, outFile, warehouseId, options);\n } finally {\n if (isWorker && options.workerLock) {\n releaseSpawnLock(options.workerLock);\n }\n }\n\n // Only a non-blocking, non-worker invocation spawns. A worker is always\n // --wait (so resolveTypegenMode → \"blocking\"), which both prevents recursion\n // and means we never get here for a worker.\n if (!isWorker && resolveTypegenMode(options) === \"non-blocking\") {\n const resolvedRootDir = rootDir || process.cwd();\n const lockPath = getSpawnLockPath(resolvedRootDir);\n\n if (acquireSpawnLock(lockPath)) {\n spawnTypegenWorker(lockPath, { rootDir, outFile, warehouseId });\n } else {\n console.log(\"Type refresh already in progress, skipping.\");\n }\n }\n}\n\nexport const generateTypesCommand = new Command(\"generate-types\")\n .description(\"Generate TypeScript types from SQL queries\")\n .argument(\"[rootDir]\", \"Root directory of the project\", process.cwd())\n .argument(\n \"[outFile]\",\n \"Output file path\",\n path.join(process.cwd(), \"shared/appkit-types/analytics.d.ts\"),\n )\n .argument(\"[warehouseId]\", \"Databricks warehouse ID\")\n .option(\"--no-cache\", \"Disable caching for type generation\")\n .option(\n \"--wait\",\n \"Wait for warehouse readiness instead of degrading (use for CI)\",\n )\n // Internal: marks the detached background worker and carries the lock it must\n // release. Hidden from --help; users should never pass it.\n .addOption(\n new Option(\n \"--worker-lock <path>\",\n \"Internal: detached worker lock path\",\n ).hideHelp(),\n )\n .addHelpText(\n \"after\",\n `\nExamples:\n $ appkit generate-types\n $ appkit generate-types . shared/appkit-types/analytics.d.ts\n $ appkit generate-types . shared/appkit-types/analytics.d.ts my-warehouse-id\n $ appkit generate-types --no-cache\n $ appkit generate-types --wait # CI: wait for the warehouse and fail on a cold one`,\n )\n .action(generateTypesAction);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,SAAgB,mBAAmB,SAEH;AAC9B,QAAO,SAAS,OAAO,aAAa;;;;;;;AAsBtC,eAAe,iBACb,SACA,SACA,aACA,SACA;AACA,KAAI;EACF,MAAM,kBAAkB,WAAW,QAAQ,KAAK;EAChD,MAAM,UAAU,SAAS,WAAW;EACpC,MAAM,OAAO,mBAAmB,QAAQ;EAExC,MAAM,UAA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,IAAI,OACF,wBACA,sCACD,CAAC,UAAU,CACb,CACA,YACC,SACA;;;;;;wFAOD,CACA,OAAO,oBAAoB"}
|
|
1
|
+
{"version":3,"file":"generate-types.js","names":[],"sources":["../../../src/cli/commands/generate-types.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { Command, Option } from \"commander\";\n\nimport { METRIC_CONFIG_FILE } from \"../../schemas/metric-fqn\";\nimport {\n acquireSpawnLock,\n getSpawnLockPath,\n releaseSpawnLock,\n} from \"./spawn-lock.js\";\n\n/**\n * Resolve the typegen pre-flight mode for the CLI. Defaults to \"non-blocking\" —\n * a one-shot CLI can't describe in the background, so by default it never\n * describes at all: it skips the warehouse probe AND every DESCRIBE, emits\n * best-available types (cache where the SQL hash matches, else `result: unknown`)\n * and returns immediately, never blocking on — or failing because of — a\n * warehouse, even a RUNNING one. Pass `--wait` (commander sets `wait: true`)\n * for a deliberate/CI invocation that should wait for a starting warehouse and\n * fail fast on a stopped one.\n */\nexport function resolveTypegenMode(options?: {\n wait?: boolean;\n}): \"non-blocking\" | \"blocking\" {\n return options?.wait ? \"blocking\" : \"non-blocking\";\n}\n\n/** Options parsed by commander for the generate-types command. */\ninterface GenerateTypesOptions {\n noCache?: boolean;\n wait?: boolean;\n /**\n * Internal: present only on the detached worker invocation. Carries the path\n * of the single-flight lock this worker must release when it finishes. Its\n * presence is what marks an invocation as \"the worker\" — workers always run\n * with `--wait`, so they never spawn another worker (only non-blocking runs\n * spawn), which terminates the recursion.\n */\n workerLock?: string;\n}\n\n/**\n * Generate types command implementation. Runs the library generate (which, in\n * non-blocking mode, writes degraded types and returns immediately). This is the\n * SAME work the worker performs in blocking mode in the background.\n */\nasync function runGenerateTypes(\n rootDir?: string,\n outFile?: string,\n warehouseId?: string,\n options?: GenerateTypesOptions,\n) {\n try {\n const resolvedRootDir = rootDir || process.cwd();\n const noCache = options?.noCache || false;\n const mode = resolveTypegenMode(options);\n\n const typeGen = await import(\"@databricks/appkit/type-generator\");\n const resolvedOutFile =\n outFile || path.join(process.cwd(), \"shared/appkit-types/analytics.d.ts\");\n\n // Generate analytics query types (requires warehouse ID)\n const resolvedWarehouseId =\n warehouseId || process.env.DATABRICKS_WAREHOUSE_ID;\n\n if (resolvedWarehouseId) {\n const queryFolder = path.join(resolvedRootDir, \"config/queries\");\n const metricViewsFolder = path.join(\n resolvedRootDir,\n \"config/metric-views\",\n );\n const hasQueries = fs.existsSync(queryFolder);\n const hasMetricViews = fs.existsSync(metricViewsFolder);\n\n // Generate when either config surface exists. Metric-view types are\n // independent of `.sql` queries — an app can declare metric views in\n // `config/metric-views/` without a `config/queries/` folder.\n if (hasQueries || hasMetricViews) {\n await typeGen.generateFromEntryPoint({\n queryFolder: hasQueries ? queryFolder : undefined,\n metricViewsFolder: hasMetricViews ? metricViewsFolder : undefined,\n outFile: resolvedOutFile,\n warehouseId: resolvedWarehouseId,\n noCache,\n mode,\n });\n\n if (hasQueries) {\n console.log(`Generated query types: ${resolvedOutFile}`);\n }\n\n const metricConfig = path.join(metricViewsFolder, METRIC_CONFIG_FILE);\n if (fs.existsSync(metricConfig)) {\n const typesDir = path.dirname(resolvedOutFile);\n console.log(\n `Generated metric types: ${path.join(typesDir, \"metric-views.ts\")}`,\n );\n }\n }\n } else {\n console.error(\n \"Skipping query type generation: no warehouse ID. Set DATABRICKS_WAREHOUSE_ID or pass as argument.\",\n );\n }\n\n // Generate serving endpoint types (no warehouse required)\n const servingOutFile = path.join(\n process.cwd(),\n \"shared/appkit-types/serving.d.ts\",\n );\n await typeGen.generateServingTypes({\n outFile: servingOutFile,\n noCache,\n });\n console.log(`Generated serving types: ${servingOutFile}`);\n\n // Generate database declarations.\n const databaseSchemaFile = path.join(\n resolvedRootDir,\n \"config/database/schema.ts\",\n );\n const databaseOutFile = path.join(\n path.dirname(resolvedOutFile),\n typeGen.DATABASE_TYPES_FILE,\n );\n if (fs.existsSync(databaseSchemaFile) || fs.existsSync(databaseOutFile)) {\n await typeGen.generateDatabaseTypes({\n schemaFile: databaseSchemaFile,\n outFile: databaseOutFile,\n });\n console.log(`Generated database types: ${databaseOutFile}`);\n }\n } catch (error) {\n if (\n error instanceof Error &&\n error.message.includes(\"Cannot find module\")\n ) {\n console.error(\n \"Error: The 'generate-types' command is only available in @databricks/appkit.\",\n );\n console.error(\"Please install @databricks/appkit to use this command.\");\n process.exit(1);\n }\n // TypegenSyntaxError / TypegenFatalError carry a complete, actionable\n // message (which queries failed and how to debug them). The stack trace\n // points into appkit internals and is noise for app developers, so print\n // only the message and exit non-zero instead of letting it bubble up.\n if (\n error instanceof Error &&\n (error.name === \"TypegenSyntaxError\" ||\n error.name === \"TypegenFatalError\" ||\n error.name === \"DatabaseTypegenError\")\n ) {\n console.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n}\n\n/**\n * Spawn the detached blocking worker that refreshes real types in the background\n * after the foreground non-blocking generate has already written degraded types.\n *\n * Re-invokes THIS CLI (`process.execPath` + `process.argv[1]` — the bin entry\n * that launched us) with `generate-types --wait --worker-lock <lockPath>` plus\n * the same positional target options the foreground used, so the worker writes\n * to the same out file / reads the same query folder. The worker is:\n * - `detached: true` + `.unref()` so it outlives this process (install/dev-setup\n * can finish and exit while the worker keeps warming the warehouse).\n * - `stdio: \"ignore\"` so it never holds the parent's pipes open or interleaves\n * output into the install/dev log.\n *\n * Spawning is wrapped so any failure is non-fatal: the caller still has degraded\n * types and exits 0.\n *\n * @param lockPath - the acquired single-flight lock; passed to the worker so it\n * releases the SAME lock when it finishes.\n * @param targets - the foreground's positional args, forwarded verbatim.\n * @returns true if the worker was spawned, false if spawning threw.\n */\nexport function spawnTypegenWorker(\n lockPath: string,\n targets: { rootDir?: string; outFile?: string; warehouseId?: string },\n): boolean {\n // The script the runtime launched us with (the `appkit` bin shim). Re-running\n // it under the same node binary reproduces this exact CLI in the worker.\n const cliEntry = process.argv[1];\n\n // Forward the positionals in declaration order (rootDir, outFile,\n // warehouseId). Stop at the first undefined so we never pass a literal\n // \"undefined\" — commander would treat it as a positional value. (rootDir is\n // effectively always set by commander's default, but guard anyway.)\n const positionals: string[] = [];\n for (const value of [targets.rootDir, targets.outFile, targets.warehouseId]) {\n if (value === undefined) break;\n positionals.push(value);\n }\n\n const args = [\n // Forward the parent's node/loader flags so the worker runs under the same\n // runtime. Critically this carries tsx's `--require`/`--import` when the CLI\n // is run from source (`tsx index.ts …`); without them the worker would be\n // `node index.ts …`, which can't parse TypeScript and dies silently — the\n // degraded types would then never refresh. Empty for the built bin (plain\n // `node bin/appkit.js`), so production behaviour is unchanged.\n ...process.execArgv,\n cliEntry,\n \"generate-types\",\n \"--wait\",\n \"--worker-lock\",\n lockPath,\n ...positionals,\n ];\n\n try {\n const child = spawn(process.execPath, args, {\n detached: true,\n stdio: \"ignore\",\n });\n child.unref();\n return true;\n } catch (error) {\n // Non-fatal: the foreground already wrote degraded types. Log and move on.\n console.error(\n `Could not start background type refresh: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n return false;\n }\n}\n\n/**\n * The command action. Orchestrates the non-blocking foreground contract:\n * 1. Run the library generate (writes degraded types immediately in non-blocking\n * mode; does the full blocking lifecycle when this is the worker).\n * 2. If this is a non-blocking, non-worker invocation, try to spawn the detached\n * blocking worker behind the single-flight lock. If the lock is already held\n * by a live worker, skip (single-flight) with a one-line note. Either way the\n * foreground returns normally (exit 0).\n * 3. If this IS the worker (`--worker-lock` present), it ran blocking above and\n * releases the lock here (and via a process-exit guard, so a hard failure /\n * process.exit still frees it).\n */\nasync function generateTypesAction(\n rootDir: string | undefined,\n outFile: string | undefined,\n warehouseId: string | undefined,\n options: GenerateTypesOptions,\n) {\n const isWorker = typeof options.workerLock === \"string\";\n\n // A worker must always free its lock, even if the blocking generate throws or\n // calls process.exit (TypegenFatalError → exit 1). The exit handler covers the\n // process.exit / uncaught paths; the finally covers the normal return.\n if (isWorker && options.workerLock) {\n const lockPath = options.workerLock;\n process.once(\"exit\", () => releaseSpawnLock(lockPath));\n }\n\n try {\n await runGenerateTypes(rootDir, outFile, warehouseId, options);\n } finally {\n if (isWorker && options.workerLock) {\n releaseSpawnLock(options.workerLock);\n }\n }\n\n // Only a non-blocking, non-worker invocation spawns. A worker is always\n // --wait (so resolveTypegenMode → \"blocking\"), which both prevents recursion\n // and means we never get here for a worker.\n if (!isWorker && resolveTypegenMode(options) === \"non-blocking\") {\n const resolvedRootDir = rootDir || process.cwd();\n const lockPath = getSpawnLockPath(resolvedRootDir);\n\n if (acquireSpawnLock(lockPath)) {\n spawnTypegenWorker(lockPath, { rootDir, outFile, warehouseId });\n } else {\n console.log(\"Type refresh already in progress, skipping.\");\n }\n }\n}\n\nexport const generateTypesCommand = new Command(\"generate-types\")\n .description(\"Generate TypeScript types from AppKit configuration\")\n .argument(\"[rootDir]\", \"Root directory of the project\", process.cwd())\n .argument(\n \"[outFile]\",\n \"Output file path\",\n path.join(process.cwd(), \"shared/appkit-types/analytics.d.ts\"),\n )\n .argument(\"[warehouseId]\", \"Databricks warehouse ID\")\n .option(\"--no-cache\", \"Disable caching for type generation\")\n .option(\n \"--wait\",\n \"Wait for warehouse readiness instead of degrading (use for CI)\",\n )\n // Internal: marks the detached background worker and carries the lock it must\n // release. Hidden from --help; users should never pass it.\n .addOption(\n new Option(\n \"--worker-lock <path>\",\n \"Internal: detached worker lock path\",\n ).hideHelp(),\n )\n .addHelpText(\n \"after\",\n `\nExamples:\n $ appkit generate-types\n $ appkit generate-types . shared/appkit-types/analytics.d.ts\n $ appkit generate-types . shared/appkit-types/analytics.d.ts my-warehouse-id\n $ appkit generate-types --no-cache\n $ appkit generate-types --wait # CI: wait for the warehouse and fail on a cold one`,\n )\n .action(generateTypesAction);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,SAAgB,mBAAmB,SAEH;AAC9B,QAAO,SAAS,OAAO,aAAa;;;;;;;AAsBtC,eAAe,iBACb,SACA,SACA,aACA,SACA;AACA,KAAI;EACF,MAAM,kBAAkB,WAAW,QAAQ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AAQ,KAAK,CACE;AAElD,MAAI,iBAAiB,SAAS,CAC5B,oBAAmB,UAAU;GAAE;GAAS;GAAS;GAAa,CAAC;MAE/D,SAAQ,IAAI,8CAA8C;;;AAKhE,MAAa,uBAAuB,IAAI,QAAQ,iBAAiB,CAC9D,YAAY,sDAAsD,CAClE,SAAS,aAAa,iCAAiC,QAAQ,KAAK,CAAC,CACrE,SACC,aACA,oBACA,KAAK,KAAK,QAAQ,KAAK,EAAE,qCAAqC,CAC/D,CACA,SAAS,iBAAiB,0BAA0B,CACpD,OAAO,cAAc,sCAAsC,CAC3D,OACC,UACA,iEACD,CAGA,UACC,IAAI,OACF,wBACA,sCACD,CAAC,UAAU,CACb,CACA,YACC,SACA;;;;;;wFAOD,CACA,OAAO,oBAAoB"}
|
package/dist/react/ui/badge.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
5
5
|
|
|
6
6
|
//#region src/react/ui/badge.d.ts
|
|
7
7
|
declare const badgeVariants: (props?: ({
|
|
8
|
-
variant?: "default" | "
|
|
8
|
+
variant?: "default" | "destructive" | "secondary" | "outline" | null | undefined;
|
|
9
9
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
10
10
|
/** Small label for displaying status, categories, or counts */
|
|
11
11
|
declare function Badge({
|
|
@@ -5,7 +5,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
5
5
|
|
|
6
6
|
//#region src/react/ui/button-group.d.ts
|
|
7
7
|
declare const buttonGroupVariants: (props?: ({
|
|
8
|
-
orientation?: "
|
|
8
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
9
9
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
10
10
|
/** Container for grouping related buttons together with shared borders */
|
|
11
11
|
declare function ButtonGroup({
|
|
@@ -5,8 +5,8 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
5
5
|
|
|
6
6
|
//#region src/react/ui/button.d.ts
|
|
7
7
|
declare const buttonVariants: (props?: ({
|
|
8
|
-
variant?: "default" | "
|
|
9
|
-
size?: "default" | "
|
|
8
|
+
variant?: "default" | "destructive" | "secondary" | "outline" | "ghost" | "link" | null | undefined;
|
|
9
|
+
size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
|
|
10
10
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
11
|
/** Clickable button with multiple variants and sizes */
|
|
12
12
|
declare function Button({
|
package/dist/react/ui/field.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ declare function FieldGroup({
|
|
|
23
23
|
...props
|
|
24
24
|
}: React.ComponentProps<"div">): react_jsx_runtime0.JSX.Element;
|
|
25
25
|
declare const fieldVariants: (props?: ({
|
|
26
|
-
orientation?: "
|
|
26
|
+
orientation?: "horizontal" | "vertical" | "responsive" | null | undefined;
|
|
27
27
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
28
28
|
/** Form field wrapper with label and input positioning */
|
|
29
29
|
declare function Field({
|
|
@@ -20,7 +20,7 @@ declare function InputGroupAddon({
|
|
|
20
20
|
...props
|
|
21
21
|
}: React$1.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>): react_jsx_runtime0.JSX.Element;
|
|
22
22
|
declare const inputGroupButtonVariants: (props?: ({
|
|
23
|
-
size?: "
|
|
23
|
+
size?: "sm" | "icon-sm" | "xs" | "icon-xs" | null | undefined;
|
|
24
24
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
25
25
|
/** Button integrated within an input group */
|
|
26
26
|
declare function InputGroupButton({
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Function: database()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function database<TSchema>(config: IDatabaseConfig<TSchema>): {
|
|
5
|
+
config: IDatabaseConfig<TSchema>;
|
|
6
|
+
name: "database";
|
|
7
|
+
plugin: PluginConstructor<BasePluginConfig, DatabasePlugin<TSchema>>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Create a typed database plugin registration for a finalized schema.
|
|
13
|
+
|
|
14
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
15
|
+
|
|
16
|
+
| Type Parameter |
|
|
17
|
+
| --------------------------------------------------------------------------- |
|
|
18
|
+
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md) |
|
|
19
|
+
|
|
20
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
21
|
+
|
|
22
|
+
| Parameter | Type |
|
|
23
|
+
| --------- | ------------------------------------------------------------------------------------ |
|
|
24
|
+
| `config` | [`IDatabaseConfig`](./docs/api/appkit/TypeAlias.IDatabaseConfig.md)<`TSchema`> |
|
|
25
|
+
|
|
26
|
+
## Returns[](#returns "Direct link to Returns")
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
{
|
|
30
|
+
config: IDatabaseConfig<TSchema>;
|
|
31
|
+
name: "database";
|
|
32
|
+
plugin: PluginConstructor<BasePluginConfig, DatabasePlugin<TSchema>>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### config[](#config "Direct link to config")
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
config: IDatabaseConfig<TSchema>;
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### name[](#name "Direct link to name")
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
name: "database";
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### plugin[](#plugin "Direct link to plugin")
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
plugin: PluginConstructor<BasePluginConfig, DatabasePlugin<TSchema>>;
|
|
55
|
+
|
|
56
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Function: defineSchema()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function defineSchema(builder: (context: SchemaBuilderContext) => Record<string, AppKitTable>, options?: DefineSchemaOptions): Schema;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
9
|
+
|
|
10
|
+
| Parameter | Type |
|
|
11
|
+
| ---------- | ------------------------------------------------------------------------ |
|
|
12
|
+
| `builder` | (`context`: `SchemaBuilderContext`) => `Record`<`string`, `AppKitTable`> |
|
|
13
|
+
| `options?` | `DefineSchemaOptions` |
|
|
14
|
+
|
|
15
|
+
## Returns[](#returns "Direct link to Returns")
|
|
16
|
+
|
|
17
|
+
[`Schema`](./docs/api/appkit/Interface.Schema.md)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Function: enumColumn()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function enumColumn(name: string, values: readonly string[]): ColumnBuilder;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
9
|
+
|
|
10
|
+
| Parameter | Type |
|
|
11
|
+
| --------- | -------------------- |
|
|
12
|
+
| `name` | `string` |
|
|
13
|
+
| `values` | readonly `string`\[] |
|
|
14
|
+
|
|
15
|
+
## Returns[](#returns "Direct link to Returns")
|
|
16
|
+
|
|
17
|
+
`ColumnBuilder`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Function: fk()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function fk(ref: FkRef): ColumnBuilder;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Declare foreign-key to another column.
|
|
9
|
+
|
|
10
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
11
|
+
|
|
12
|
+
| Parameter | Type |
|
|
13
|
+
| --------- | ------- |
|
|
14
|
+
| `ref` | `FkRef` |
|
|
15
|
+
|
|
16
|
+
## Returns[](#returns "Direct link to Returns")
|
|
17
|
+
|
|
18
|
+
`ColumnBuilder`
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Function: timestamp()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function timestamp(opts?: {
|
|
5
|
+
withTimezone?: boolean;
|
|
6
|
+
}): ColumnBuilder;
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
11
|
+
|
|
12
|
+
| Parameter | Type |
|
|
13
|
+
| -------------------- | ------------------------------- |
|
|
14
|
+
| `opts?` | { `withTimezone?`: `boolean`; } |
|
|
15
|
+
| `opts.withTimezone?` | `boolean` |
|
|
16
|
+
|
|
17
|
+
## Returns[](#returns "Direct link to Returns")
|
|
18
|
+
|
|
19
|
+
`ColumnBuilder`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Function: varchar()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
function varchar(length: number): ColumnBuilder;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
9
|
+
|
|
10
|
+
| Parameter | Type | Default value |
|
|
11
|
+
| --------- | -------- | ------------- |
|
|
12
|
+
| `length` | `number` | `255` |
|
|
13
|
+
|
|
14
|
+
## Returns[](#returns "Direct link to Returns")
|
|
15
|
+
|
|
16
|
+
`ColumnBuilder`
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Interface: Schema
|
|
2
|
+
|
|
3
|
+
## Properties[](#properties "Direct link to Properties")
|
|
4
|
+
|
|
5
|
+
### $engine[](#engine "Direct link to $engine")
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
readonly $engine: Readonly<Record<string, EngineTable>>;
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
***
|
|
13
|
+
|
|
14
|
+
### $schemaName[](#schemaname "Direct link to $schemaName")
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
readonly $schemaName: string;
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### $tables[](#tables "Direct link to $tables")
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
readonly $tables: Readonly<Record<string, AppKitTable>>;
|
|
27
|
+
|
|
28
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Type Alias: DatabaseExports
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type DatabaseExports = TransactionClient & {
|
|
5
|
+
transaction: Promise<T>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Typed database API published by the plugin.
|
|
11
|
+
|
|
12
|
+
## Type Declaration[](#type-declaration "Direct link to Type Declaration")
|
|
13
|
+
|
|
14
|
+
### transaction()[](#transaction "Direct link to transaction()")
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
transaction<T>(callback: (tx: TransactionClient) => Promise<T>): Promise<T>;
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
22
|
+
|
|
23
|
+
| Type Parameter |
|
|
24
|
+
| -------------- |
|
|
25
|
+
| `T` |
|
|
26
|
+
|
|
27
|
+
#### Parameters[](#parameters "Direct link to Parameters")
|
|
28
|
+
|
|
29
|
+
| Parameter | Type |
|
|
30
|
+
| ---------- | --------------------------------------------- |
|
|
31
|
+
| `callback` | (`tx`: `TransactionClient`) => `Promise`<`T`> |
|
|
32
|
+
|
|
33
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
34
|
+
|
|
35
|
+
`Promise`<`T`>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Type Alias: IDatabaseConfig\<TSchema>
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type IDatabaseConfig<TSchema> = {
|
|
5
|
+
schema: TSchema;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Configuration for one schema-bound DatabasePlugin instance.
|
|
11
|
+
|
|
12
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
13
|
+
|
|
14
|
+
| Type Parameter |
|
|
15
|
+
| --------------------------------------------------------------------------- |
|
|
16
|
+
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md) |
|
|
17
|
+
|
|
18
|
+
## Properties[](#properties "Direct link to Properties")
|
|
19
|
+
|
|
20
|
+
### schema[](#schema "Direct link to schema")
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
readonly schema: TSchema;
|
|
24
|
+
|
|
25
|
+
```
|