@databricks/appkit 0.75.0 → 0.75.1
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 +1 -1
- package/dist/appkit/package.js +1 -1
- package/dist/beta.d.ts +1 -1
- package/dist/beta.js +2 -1
- package/dist/cache/index.js +2 -2
- package/dist/cache/storage/persistent.js +1 -1
- package/dist/connectors/index.js +1 -1
- package/dist/connectors/jobs/client.js +1 -1
- package/dist/connectors/lakebase/index.d.ts +2 -2
- package/dist/connectors/lakebase/index.d.ts.map +1 -1
- package/dist/connectors/lakebase/index.js +25 -2
- package/dist/connectors/lakebase/index.js.map +1 -1
- package/dist/connectors/mcp/client.js +1 -1
- package/dist/connectors/sql-warehouse/client.js +1 -1
- package/dist/context/service-context.js +1 -1
- package/dist/core/appkit.js +1 -1
- package/dist/database/errors.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin/dev-reader.js +1 -1
- package/dist/plugin/interceptors/retry.js +1 -1
- package/dist/plugin/plugin.js +1 -1
- package/dist/plugins/analytics/analytics.js +1 -1
- package/dist/plugins/analytics/result-delivery.js +1 -1
- package/dist/plugins/beta-exports.generated.d.ts +1 -3
- package/dist/plugins/beta-exports.generated.js +0 -2
- package/dist/plugins/database/config.js +14 -0
- package/dist/plugins/database/config.js.map +1 -0
- package/dist/plugins/database/database.d.ts +22 -5
- package/dist/plugins/database/database.d.ts.map +1 -1
- package/dist/plugins/database/database.js +23 -8
- package/dist/plugins/database/database.js.map +1 -1
- package/dist/plugins/database/lifecycle.js +3 -3
- package/dist/plugins/database/lifecycle.js.map +1 -1
- package/dist/plugins/database/load-schema.js +40 -0
- package/dist/plugins/database/load-schema.js.map +1 -0
- package/dist/plugins/database/manifest.js +1 -1
- package/dist/plugins/database/types.d.ts +12 -3
- package/dist/plugins/database/types.d.ts.map +1 -1
- package/dist/plugins/files/plugin.js +1 -1
- package/dist/plugins/jobs/plugin.js +1 -1
- package/dist/plugins/lakebase/lakebase.js +1 -1
- package/dist/plugins/server/index.js +3 -3
- package/dist/plugins/server/index.js.map +1 -1
- package/dist/plugins/server/remote-tunnel/remote-tunnel-manager.js +3 -3
- package/dist/plugins/server/remote-tunnel/remote-tunnel-manager.js.map +1 -1
- package/dist/plugins/server/static-server.js +3 -3
- package/dist/plugins/server/static-server.js.map +1 -1
- package/dist/plugins/server/utils.js +3 -3
- package/dist/plugins/server/utils.js.map +1 -1
- package/dist/plugins/server/vite-dev-server.js +5 -5
- package/dist/plugins/server/vite-dev-server.js.map +1 -1
- package/dist/registry/manifest-loader.js +1 -1
- package/dist/registry/resource-registry.js +1 -1
- package/dist/stream/arrow-stream-processor.js +1 -1
- package/dist/stream/stream-manager.js +1 -1
- package/dist/type-generator/database/generate.js +3 -3
- package/dist/type-generator/database/generate.js.map +1 -1
- package/dist/type-generator/migration.js +2 -2
- package/dist/type-generator/migration.js.map +1 -1
- package/dist/type-generator/serving/server-file-extractor.js +3 -3
- package/dist/type-generator/serving/server-file-extractor.js.map +1 -1
- package/docs/api/appkit/Function.database.md +30 -29
- package/docs/api/appkit/TypeAlias.IDatabaseConfig.md +8 -6
- package/docs/api/appkit.md +1 -1
- package/docs/plugins/database.md +46 -18
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
package/docs/plugins/database.md
CHANGED
|
@@ -4,7 +4,7 @@ Beta plugin
|
|
|
4
4
|
|
|
5
5
|
This plugin is currently **beta**. APIs may change between minor releases. Import from `@databricks/appkit/beta`. See [Plugin Stability Tiers](./docs/plugins/stability.md).
|
|
6
6
|
|
|
7
|
-
Declare
|
|
7
|
+
Declare your tables in `config/database/schema.ts` and register `database()` to get generated HTTP CRUD and a server-side database client. CRUD is enabled for every declared table by default. Use `api` to restrict the generated routes without disabling server-side access.
|
|
8
8
|
|
|
9
9
|
Shared application access
|
|
10
10
|
|
|
@@ -16,19 +16,30 @@ Restrict access to the app and grant its service principal only the database per
|
|
|
16
16
|
|
|
17
17
|
Configure a Lakebase `postgres` resource and its connection environment variables as described in [Lakebase configuration](./docs/plugins/lakebase.md#environment-variables). The database tables must already exist and match the declared schema. This plugin checks connectivity during setup; it does not create or migrate tables.
|
|
18
18
|
|
|
19
|
+
Apps scaffolded with the Database plugin selected include an empty `config/database/schema.ts`, so `database()` can start without requiring sample tables. Replace the empty declaration with your models when their PostgreSQL tables are ready.
|
|
20
|
+
|
|
21
|
+
For local development, the PostgreSQL username is resolved from your Databricks credentials when `PGUSER` and `DATABRICKS_CLIENT_ID` are absent. An explicitly configured username takes precedence.
|
|
22
|
+
|
|
19
23
|
```ts
|
|
20
|
-
|
|
21
|
-
import {
|
|
24
|
+
// config/database/schema.ts
|
|
25
|
+
import { defineSchema, id, text } from "@databricks/appkit/beta";
|
|
22
26
|
|
|
23
|
-
const schema = defineSchema((builder) => ({
|
|
27
|
+
export const schema = defineSchema((builder) => ({
|
|
24
28
|
notes: builder.table("notes", {
|
|
25
29
|
id: id(),
|
|
26
30
|
body: text().notNull(),
|
|
27
31
|
}),
|
|
28
32
|
}));
|
|
29
33
|
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// server/index.ts
|
|
38
|
+
import { createApp, server } from "@databricks/appkit";
|
|
39
|
+
import { database } from "@databricks/appkit/beta";
|
|
40
|
+
|
|
30
41
|
const AppKit = await createApp({
|
|
31
|
-
plugins: [server(), database(
|
|
42
|
+
plugins: [server(), database()],
|
|
32
43
|
});
|
|
33
44
|
|
|
34
45
|
```
|
|
@@ -45,41 +56,59 @@ With the server plugin enabled, this registers:
|
|
|
45
56
|
|
|
46
57
|
A table without a public primary key supports list and create only. `upsert` is available to server code but has no generated HTTP route.
|
|
47
58
|
|
|
59
|
+
## Schema discovery and overrides[](#schema-discovery-and-overrides "Direct link to Schema discovery and overrides")
|
|
60
|
+
|
|
61
|
+
`database()` and `database({})` use the same defaults. During setup, the plugin loads the named `schema` export from `config/database/schema.ts`, relative to the application's working directory. The file must export a finalized `defineSchema()` result. Missing files, import failures, and invalid exports fail setup before the plugin creates a connection pool; they do not silently create an empty schema.
|
|
62
|
+
|
|
63
|
+
Keep `config/database/schema.ts` and its local imports in your deployment. The plugin loads TypeScript through Jiti, so a plain Node production process does not need a separate TypeScript loader. The schema module should only declare tables, not connect to the database or start the app.
|
|
64
|
+
|
|
65
|
+
For a different layout or a deployment that contains only a server bundle, import the schema explicitly and pass it to the plugin:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { schema } from "../config/database/schema";
|
|
69
|
+
|
|
70
|
+
database({ schema });
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
An explicit schema always takes precedence and skips file discovery. An invalid explicit schema fails setup instead of falling back to another file.
|
|
75
|
+
|
|
76
|
+
Run `appkit generate-types` to generate the database registry. With that registry, configuration without an explicit schema still infers table names and hook payloads. An explicitly supplied schema also checks configuration keys against its own table names.
|
|
77
|
+
|
|
48
78
|
## Restrict the generated API[](#restrict-the-generated-api "Direct link to Restrict the generated API")
|
|
49
79
|
|
|
50
80
|
Omitting `api`, or setting it to `true` or `{}`, enables full CRUD. Restrictions are optional. There is no separate write opt-in.
|
|
51
81
|
|
|
52
82
|
```ts
|
|
53
83
|
// No generated HTTP routes. The server-side client still works.
|
|
54
|
-
database({
|
|
84
|
+
database({ api: false });
|
|
55
85
|
|
|
56
86
|
// Read-only routes for every table.
|
|
57
|
-
database({
|
|
87
|
+
database({ api: { writes: false } });
|
|
58
88
|
|
|
59
89
|
// Full CRUD for selected tables only.
|
|
60
|
-
database({
|
|
90
|
+
database({ api: { tables: ["notes"] } });
|
|
61
91
|
|
|
62
92
|
// Allow reads, create, and update, but not delete.
|
|
63
93
|
database({
|
|
64
|
-
schema,
|
|
65
94
|
api: { writes: { operations: ["create", "update"] } },
|
|
66
95
|
});
|
|
67
96
|
|
|
68
97
|
// Read every table, but allow writes only to notes.
|
|
69
98
|
database({
|
|
70
|
-
schema,
|
|
71
99
|
api: { writes: { tables: ["notes"] } },
|
|
72
100
|
});
|
|
73
101
|
|
|
74
102
|
```
|
|
75
103
|
|
|
76
|
-
| Option | Default
|
|
77
|
-
| ----------------------- |
|
|
78
|
-
| `
|
|
79
|
-
| `api
|
|
80
|
-
| `api.
|
|
81
|
-
| `api.writes
|
|
82
|
-
| `api.writes.
|
|
104
|
+
| Option | Default | Effect |
|
|
105
|
+
| ----------------------- | ------------------------------------------- | ----------------------------------------- |
|
|
106
|
+
| `schema` | Named export in `config/database/schema.ts` | Overrides automatic schema loading |
|
|
107
|
+
| `api` | `true` | `false` disables all generated routes |
|
|
108
|
+
| `api.tables` | All declared tables | Limits which tables have routes |
|
|
109
|
+
| `api.writes` | `true` | `false` keeps only read routes |
|
|
110
|
+
| `api.writes.tables` | All exposed tables | Limits which exposed tables accept writes |
|
|
111
|
+
| `api.writes.operations` | `create`, `update`, `delete` | Limits which writes are enabled |
|
|
83
112
|
|
|
84
113
|
`api.tables: []` disables all generated routes. An empty write-table or write-operation list keeps reads and disables writes. Tables omitted from `api.tables` also cannot be included through relations on exposed tables. These restrictions apply to HTTP only, not to the server-side client or hooks.
|
|
85
114
|
|
|
@@ -114,7 +143,6 @@ A table can declare `beforeCreate`, `afterCreate`, `beforeUpdate`, `afterUpdate`
|
|
|
114
143
|
import { DatabaseValidationError } from "@databricks/appkit";
|
|
115
144
|
|
|
116
145
|
database({
|
|
117
|
-
schema,
|
|
118
146
|
hooks: {
|
|
119
147
|
notes: {
|
|
120
148
|
beforeCreate(values) {
|
package/llms.txt
CHANGED
|
@@ -97,7 +97,7 @@ npx @databricks/appkit docs <query>
|
|
|
97
97
|
- [Function: createLakebasePool()](./docs/api/appkit/Function.createLakebasePool.md): Create a Lakebase pool with appkit's logger integration.
|
|
98
98
|
- [Function: createLakebasePoolManager()](./docs/api/appkit/Function.createLakebasePoolManager.md): Create a pool manager that maintains per-key Lakebase connection pools.
|
|
99
99
|
- [Function: createWorkspaceClient()](./docs/api/appkit/Function.createWorkspaceClient.md): Construct an AppKit workspace client.
|
|
100
|
-
- [Function: database()](./docs/api/appkit/Function.database.md):
|
|
100
|
+
- [Function: database()](./docs/api/appkit/Function.database.md): Call Signature
|
|
101
101
|
- [Function: defineEval()](./docs/api/appkit/Function.defineEval.md): Define an agent eval. Default-export the result from a
|
|
102
102
|
- [Function: defineEvalConfig()](./docs/api/appkit/Function.defineEvalConfig.md): Define per-directory eval config. Default-export from evals.config.ts.
|
|
103
103
|
- [Function: defineManifest()](./docs/api/appkit/Function.defineManifest.md): Validates a raw manifest (typically a manifest.json import) against the
|