@databricks/appkit 0.75.0 → 0.76.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 +2 -2
- package/dist/appkit/package.js +1 -1
- package/dist/beta.d.ts +1 -1
- package/dist/beta.js +2 -1
- package/dist/cache/index.d.ts +10 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +15 -2
- package/dist/cache/index.js.map +1 -1
- 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 +14 -2
- package/dist/connectors/sql-warehouse/client.js.map +1 -1
- package/dist/context/service-context.js +1 -1
- package/dist/core/appkit.d.ts +1 -1
- package/dist/core/appkit.d.ts.map +1 -1
- package/dist/core/appkit.js +27 -6
- package/dist/core/appkit.js.map +1 -1
- package/dist/core/lifecycle-manager.js +47 -27
- package/dist/core/lifecycle-manager.js.map +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/shared/src/schemas/manifest.d.ts +33 -33
- package/dist/stream/arrow-stream-processor.js +1 -1
- package/dist/stream/stream-manager.js +1 -1
- package/dist/telemetry/telemetry-manager.js +17 -0
- package/dist/telemetry/telemetry-manager.js.map +1 -1
- package/dist/testing/create-test-app.d.ts +111 -0
- package/dist/testing/create-test-app.d.ts.map +1 -0
- package/dist/testing/create-test-app.js +187 -0
- package/dist/testing/create-test-app.js.map +1 -0
- package/dist/testing/create-test-plugin.d.ts +17 -0
- package/dist/testing/create-test-plugin.d.ts.map +1 -0
- package/dist/testing/create-test-plugin.js +22 -0
- package/dist/testing/create-test-plugin.js.map +1 -0
- package/dist/testing/fixtures.d.ts +51 -35
- package/dist/testing/fixtures.d.ts.map +1 -1
- package/dist/testing/fixtures.js +129 -54
- package/dist/testing/fixtures.js.map +1 -1
- package/dist/testing/index.d.ts +8 -3
- package/dist/testing/index.js +7 -2
- package/dist/testing/mock-workspace-client.d.ts +47 -0
- package/dist/testing/mock-workspace-client.d.ts.map +1 -0
- package/dist/testing/mock-workspace-client.js +192 -0
- package/dist/testing/mock-workspace-client.js.map +1 -0
- package/dist/testing/reset-singletons.js +39 -0
- package/dist/testing/reset-singletons.js.map +1 -0
- package/dist/testing/test-app.d.ts +54 -0
- package/dist/testing/test-app.d.ts.map +1 -0
- package/dist/testing/test-app.js +55 -0
- package/dist/testing/test-app.js.map +1 -0
- package/dist/testing/test-cache.d.ts +60 -0
- package/dist/testing/test-cache.d.ts.map +1 -0
- package/dist/testing/test-cache.js +65 -0
- package/dist/testing/test-cache.js.map +1 -0
- package/dist/testing/test-plugin-context.d.ts +43 -2
- package/dist/testing/test-plugin-context.d.ts.map +1 -1
- package/dist/testing/test-plugin-context.js +47 -2
- package/dist/testing/test-plugin-context.js.map +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.createApp.md +9 -9
- 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/docs/plugins/testing.md +440 -14
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
|
@@ -24,15 +24,15 @@ Initializes telemetry, cache, and service context, then registers plugins in pha
|
|
|
24
24
|
|
|
25
25
|
## Parameters[](#parameters "Direct link to Parameters")
|
|
26
26
|
|
|
27
|
-
| Parameter | Type |
|
|
28
|
-
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
-
| `config` | { `cache?`: [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md); `client?`: [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md); `disableInternalTelemetry?`: `boolean`; `onPluginsReady?`: (`appkit`: `PluginMap`<`T`>) => `void` \| `Promise`<`void`>; `plugins?`: `T`; `telemetry?`: [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md); } |
|
|
30
|
-
| `config.cache?` | [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md) |
|
|
31
|
-
| `config.client?` | [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md) |
|
|
32
|
-
| `config.disableInternalTelemetry?` | `boolean` |
|
|
33
|
-
| `config.onPluginsReady?` | (`appkit`: `PluginMap`<`T`>) => `void` \| `Promise`<`void`> |
|
|
34
|
-
| `config.plugins?` | `T` |
|
|
35
|
-
| `config.telemetry?` | [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md) |
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
|
|
29
|
+
| `config` | { `cache?`: [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md); `client?`: [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md); `disableInternalTelemetry?`: `boolean`; `onPluginsReady?`: (`appkit`: `PluginMap`<`T`>) => `void` \| `Promise`<`void`>; `plugins?`: `T`; `telemetry?`: [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md); } | - |
|
|
30
|
+
| `config.cache?` | [`CacheConfig`](./docs/api/appkit/Interface.CacheConfig.md) | - |
|
|
31
|
+
| `config.client?` | [`WorkspaceClient`](./docs/api/appkit/Interface.WorkspaceClient.md) | - |
|
|
32
|
+
| `config.disableInternalTelemetry?` | `boolean` | - |
|
|
33
|
+
| `config.onPluginsReady?` | (`appkit`: `PluginMap`<`T`>) => `void` \| `Promise`<`void`> | Runs after plugin setup but **before** the server starts. |
|
|
34
|
+
| `config.plugins?` | `T` | - |
|
|
35
|
+
| `config.telemetry?` | [`TelemetryConfig`](./docs/api/appkit/Interface.TelemetryConfig.md) | - |
|
|
36
36
|
|
|
37
37
|
## Returns[](#returns "Direct link to Returns")
|
|
38
38
|
|
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
# Function: database()
|
|
2
2
|
|
|
3
|
+
## Call Signature[](#call-signature "Direct link to Call Signature")
|
|
4
|
+
|
|
3
5
|
```ts
|
|
4
|
-
function database<TSchema>(config: IDatabaseConfig<TSchema>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
function database<TSchema>(config: IDatabaseConfig<TSchema> & {
|
|
7
|
+
schema: TSchema;
|
|
8
|
+
}): DatabaseRegistration<TSchema> & {
|
|
9
|
+
config: IDatabaseConfig<TSchema> & {
|
|
10
|
+
schema: TSchema;
|
|
11
|
+
};
|
|
8
12
|
};
|
|
9
13
|
|
|
10
14
|
```
|
|
11
15
|
|
|
12
|
-
Create
|
|
16
|
+
Create the database plugin. Omit configuration to load `config/database/schema.ts`, or supply a typed schema override.
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
### Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
15
19
|
|
|
16
20
|
| Type Parameter |
|
|
17
21
|
| ------------------------------------------------------------------------------------- |
|
|
18
22
|
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md)<`string`> |
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
### Parameters[](#parameters "Direct link to Parameters")
|
|
21
25
|
|
|
22
|
-
| Parameter | Type
|
|
23
|
-
| --------- |
|
|
24
|
-
| `config` | [`IDatabaseConfig`](./docs/api/appkit/TypeAlias.IDatabaseConfig.md)<`TSchema`> |
|
|
26
|
+
| Parameter | Type |
|
|
27
|
+
| --------- | --------------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| `config` | [`IDatabaseConfig`](./docs/api/appkit/TypeAlias.IDatabaseConfig.md)<`TSchema`> & { `schema`: `TSchema`; } |
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
### Returns[](#returns "Direct link to Returns")
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
config: IDatabaseConfig<TSchema>;
|
|
31
|
-
name: "database";
|
|
32
|
-
plugin: PluginConstructor<BasePluginConfig, DatabasePlugin<TSchema>>;
|
|
33
|
-
}
|
|
32
|
+
`DatabaseRegistration`<`TSchema`> & { `config`: [`IDatabaseConfig`](./docs/api/appkit/TypeAlias.IDatabaseConfig.md)<`TSchema`> & { `schema`: `TSchema`; }; }
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### config[](#config "Direct link to config")
|
|
34
|
+
## Call Signature[](#call-signature-1 "Direct link to Call Signature")
|
|
38
35
|
|
|
39
36
|
```ts
|
|
40
|
-
config
|
|
37
|
+
function database<TSchema>(config?: IDatabaseConfig<TSchema>): DatabaseRegistration<TSchema>;
|
|
41
38
|
|
|
42
39
|
```
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
Register the database plugin with opinionated defaults and full HTTP CRUD. By default, setup loads the named `schema` export from the application's `config/database/schema.ts`. Registration itself performs no file or database I/O.
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
name: "database";
|
|
43
|
+
### Type Parameters[](#type-parameters-1 "Direct link to Type Parameters")
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
| Type Parameter | Default type |
|
|
46
|
+
| ------------------------------------------------------------------------------------- | ----------------------- |
|
|
47
|
+
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md)<`string`> | `DefaultDatabaseSchema` |
|
|
50
48
|
|
|
51
|
-
###
|
|
49
|
+
### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
| Parameter | Type |
|
|
52
|
+
| --------- | ------------------------------------------------------------------------------------ |
|
|
53
|
+
| `config?` | [`IDatabaseConfig`](./docs/api/appkit/TypeAlias.IDatabaseConfig.md)<`TSchema`> |
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
### Returns[](#returns-1 "Direct link to Returns")
|
|
56
|
+
|
|
57
|
+
`DatabaseRegistration`<`TSchema`>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
type IDatabaseConfig<TSchema> = {
|
|
5
5
|
api?: DatabaseApiConfig<TSchema>;
|
|
6
6
|
hooks?: { readonly [TTable in SchemaTableName<TSchema>]?: EntityHooks<TTable> };
|
|
7
|
-
schema
|
|
7
|
+
schema?: TSchema;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
```
|
|
@@ -13,9 +13,9 @@ Configuration for one schema-bound DatabasePlugin instance.
|
|
|
13
13
|
|
|
14
14
|
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
15
15
|
|
|
16
|
-
| Type Parameter |
|
|
17
|
-
| --------------------------------------------------------------------------- |
|
|
18
|
-
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md) |
|
|
16
|
+
| Type Parameter | Default type |
|
|
17
|
+
| --------------------------------------------------------------------------- | ----------------------- |
|
|
18
|
+
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md) | `DefaultDatabaseSchema` |
|
|
19
19
|
|
|
20
20
|
## Properties[](#properties "Direct link to Properties")
|
|
21
21
|
|
|
@@ -48,9 +48,11 @@ readonly optional hooks: { readonly [TTable in SchemaTableName<TSchema>]?: Entit
|
|
|
48
48
|
|
|
49
49
|
***
|
|
50
50
|
|
|
51
|
-
### schema[](#schema "Direct link to schema")
|
|
51
|
+
### schema?[](#schema "Direct link to schema?")
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
readonly schema: TSchema;
|
|
54
|
+
readonly optional schema: TSchema;
|
|
55
55
|
|
|
56
56
|
```
|
|
57
|
+
|
|
58
|
+
Explicit schema override. When omitted, setup loads the named `schema` export from `config/database/schema.ts` under the application's working directory. Missing or invalid declarations fail setup before pool creation.
|
package/docs/api/appkit.md
CHANGED
|
@@ -198,7 +198,7 @@ Documentation merge entry for Typedoc — combines the stable `@databricks/appki
|
|
|
198
198
|
| [createLakebasePool](./docs/api/appkit/Function.createLakebasePool.md) | Create a Lakebase pool with appkit's logger integration. Telemetry automatically uses appkit's OpenTelemetry configuration via global registry. |
|
|
199
199
|
| [createLakebasePoolManager](./docs/api/appkit/Function.createLakebasePoolManager.md) | Create a pool manager that maintains per-key Lakebase connection pools. |
|
|
200
200
|
| [createWorkspaceClient](./docs/api/appkit/Function.createWorkspaceClient.md) | Construct an AppKit workspace client. |
|
|
201
|
-
| [database](./docs/api/appkit/Function.database.md) | Create
|
|
201
|
+
| [database](./docs/api/appkit/Function.database.md) | Create the database plugin. Omit configuration to load `config/database/schema.ts`, or supply a typed schema override. |
|
|
202
202
|
| [defineEval](./docs/api/appkit/Function.defineEval.md) | Define an agent eval. Default-export the result from a `server/agents/<id>/evals/*.eval.ts` file. |
|
|
203
203
|
| [defineEvalConfig](./docs/api/appkit/Function.defineEvalConfig.md) | Define per-directory eval config. Default-export from `evals.config.ts`. |
|
|
204
204
|
| [defineManifest](./docs/api/appkit/Function.defineManifest.md) | Validates a raw manifest (typically a `manifest.json` import) against the canonical Zod schema and returns it as a strict [PluginManifest](./docs/api/appkit/Interface.PluginManifest.md). |
|
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) {
|