@databricks/appkit-ui 0.72.0 → 0.73.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 +17 -0
- package/NOTICE.md +1 -0
- package/dist/cli/commands/agent/eval.js +9 -1
- package/dist/cli/commands/agent/eval.js.map +1 -1
- package/dist/react/ui/button.d.ts +1 -1
- package/docs/api/appkit/Class.AppKitError.md +1 -0
- package/docs/api/appkit/Class.DatabaseValidationError.md +191 -0
- package/docs/api/appkit/Function.defineSchema.md +1 -1
- package/docs/api/appkit/Function.readEvalDataset.md +21 -0
- package/docs/api/appkit/Function.resolveWorkspaceClient.md +18 -0
- package/docs/api/appkit/Interface.AssertionHandle.md +1 -1
- package/docs/api/appkit/Interface.DatabaseValidationIssue.md +21 -0
- package/docs/api/appkit/Interface.DatasetRow.md +21 -0
- package/docs/api/appkit/Interface.EntityMutationHooks.md +173 -0
- package/docs/api/appkit/Interface.EvalDefinition.md +28 -0
- package/docs/api/appkit/Interface.EvalDriver.md +16 -1
- package/docs/api/appkit/Interface.HookApp.md +12 -0
- package/docs/api/appkit/Interface.HookContext.md +21 -0
- package/docs/api/appkit/Interface.ReadEvalDatasetOptions.md +34 -0
- package/docs/api/appkit/Interface.ReadSerializerContext.md +21 -0
- package/docs/api/appkit/Interface.RunEvalOptions.md +11 -0
- package/docs/api/appkit/Interface.RunEvalsOptions.md +22 -0
- package/docs/api/appkit/Interface.TestContext.md +41 -4
- package/docs/api/appkit/TypeAlias.DatabaseApiConfig.md +53 -0
- package/docs/api/appkit/TypeAlias.DatabaseApiWriteOperation.md +8 -0
- package/docs/api/appkit/TypeAlias.DatabaseApiWritesConfig.md +49 -0
- package/docs/api/appkit/TypeAlias.DatabaseExports.md +3 -3
- package/docs/api/appkit/TypeAlias.EntityHooks.md +25 -0
- package/docs/api/appkit/TypeAlias.IDatabaseConfig.md +16 -5
- package/docs/api/appkit/TypeAlias.ReadSerializer.md +19 -0
- package/docs/api/appkit/TypeAlias.TransactionClient.md +19 -0
- package/docs/api/appkit.md +135 -119
- package/docs/plugins/database.md +144 -0
- package/llms.txt +17 -0
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Interface: EntityMutationHooks\<TTable>
|
|
2
|
+
|
|
3
|
+
Mutation lifecycle for one entity. A before hook may return a replacement payload, which is revalidated against the trusted schema before it is persisted. Every hook, the mutation, and any write a hook issues through `ctx.app.database` share one transaction, so a rejection anywhere rolls all of them back. Throw `DatabaseValidationError` to answer a generated route with `422`; any other failure stays an opaque server error.
|
|
4
|
+
|
|
5
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
6
|
+
|
|
7
|
+
| Type Parameter | Default type |
|
|
8
|
+
| --------------------------- | ------------ |
|
|
9
|
+
| `TTable` *extends* `string` | `string` |
|
|
10
|
+
|
|
11
|
+
## Methods[](#methods "Direct link to Methods")
|
|
12
|
+
|
|
13
|
+
### afterCreate()?[](#aftercreate "Direct link to afterCreate()?")
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
optional afterCreate(row: FacetOf<TTable, "row">, context: HookContext): MaybePromise<void>;
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
#### Parameters[](#parameters "Direct link to Parameters")
|
|
21
|
+
|
|
22
|
+
| Parameter | Type |
|
|
23
|
+
| --------- | ----------------------------------------------------------------- |
|
|
24
|
+
| `row` | `FacetOf`<`TTable`, `"row"`> |
|
|
25
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
26
|
+
|
|
27
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
28
|
+
|
|
29
|
+
`MaybePromise`<`void`>
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### afterDelete()?[](#afterdelete "Direct link to afterDelete()?")
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
optional afterDelete(id: IdValue, context: HookContext): MaybePromise<void>;
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
41
|
+
|
|
42
|
+
| Parameter | Type |
|
|
43
|
+
| --------- | ----------------------------------------------------------------- |
|
|
44
|
+
| `id` | `IdValue` |
|
|
45
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
46
|
+
|
|
47
|
+
#### Returns[](#returns-1 "Direct link to Returns")
|
|
48
|
+
|
|
49
|
+
`MaybePromise`<`void`>
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### afterUpdate()?[](#afterupdate "Direct link to afterUpdate()?")
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
optional afterUpdate(row: FacetOf<TTable, "row">, context: HookContext): MaybePromise<void>;
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Parameters[](#parameters-2 "Direct link to Parameters")
|
|
61
|
+
|
|
62
|
+
| Parameter | Type |
|
|
63
|
+
| --------- | ----------------------------------------------------------------- |
|
|
64
|
+
| `row` | `FacetOf`<`TTable`, `"row"`> |
|
|
65
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
66
|
+
|
|
67
|
+
#### Returns[](#returns-2 "Direct link to Returns")
|
|
68
|
+
|
|
69
|
+
`MaybePromise`<`void`>
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### afterUpsert()?[](#afterupsert "Direct link to afterUpsert()?")
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
optional afterUpsert(row: FacetOf<TTable, "row">, context: HookContext): MaybePromise<void>;
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Parameters[](#parameters-3 "Direct link to Parameters")
|
|
81
|
+
|
|
82
|
+
| Parameter | Type |
|
|
83
|
+
| --------- | ----------------------------------------------------------------- |
|
|
84
|
+
| `row` | `FacetOf`<`TTable`, `"row"`> |
|
|
85
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
86
|
+
|
|
87
|
+
#### Returns[](#returns-3 "Direct link to Returns")
|
|
88
|
+
|
|
89
|
+
`MaybePromise`<`void`>
|
|
90
|
+
|
|
91
|
+
***
|
|
92
|
+
|
|
93
|
+
### beforeCreate()?[](#beforecreate "Direct link to beforeCreate()?")
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
optional beforeCreate(values: FacetOf<TTable, "insert">, context: HookContext): MaybePromise<void | FacetOf<TTable, "insert">>;
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Parameters[](#parameters-4 "Direct link to Parameters")
|
|
101
|
+
|
|
102
|
+
| Parameter | Type |
|
|
103
|
+
| --------- | ----------------------------------------------------------------- |
|
|
104
|
+
| `values` | `FacetOf`<`TTable`, `"insert"`> |
|
|
105
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
106
|
+
|
|
107
|
+
#### Returns[](#returns-4 "Direct link to Returns")
|
|
108
|
+
|
|
109
|
+
`MaybePromise`<`void` | `FacetOf`<`TTable`, `"insert"`>>
|
|
110
|
+
|
|
111
|
+
***
|
|
112
|
+
|
|
113
|
+
### beforeDelete()?[](#beforedelete "Direct link to beforeDelete()?")
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
optional beforeDelete(id: IdValue, context: HookContext): MaybePromise<void>;
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Parameters[](#parameters-5 "Direct link to Parameters")
|
|
121
|
+
|
|
122
|
+
| Parameter | Type |
|
|
123
|
+
| --------- | ----------------------------------------------------------------- |
|
|
124
|
+
| `id` | `IdValue` |
|
|
125
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
126
|
+
|
|
127
|
+
#### Returns[](#returns-5 "Direct link to Returns")
|
|
128
|
+
|
|
129
|
+
`MaybePromise`<`void`>
|
|
130
|
+
|
|
131
|
+
***
|
|
132
|
+
|
|
133
|
+
### beforeUpdate()?[](#beforeupdate "Direct link to beforeUpdate()?")
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
optional beforeUpdate(
|
|
137
|
+
id: IdValue,
|
|
138
|
+
values: FacetOf<TTable, "update">,
|
|
139
|
+
context: HookContext): MaybePromise<void | FacetOf<TTable, "update">>;
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Parameters[](#parameters-6 "Direct link to Parameters")
|
|
144
|
+
|
|
145
|
+
| Parameter | Type |
|
|
146
|
+
| --------- | ----------------------------------------------------------------- |
|
|
147
|
+
| `id` | `IdValue` |
|
|
148
|
+
| `values` | `FacetOf`<`TTable`, `"update"`> |
|
|
149
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
150
|
+
|
|
151
|
+
#### Returns[](#returns-6 "Direct link to Returns")
|
|
152
|
+
|
|
153
|
+
`MaybePromise`<`void` | `FacetOf`<`TTable`, `"update"`>>
|
|
154
|
+
|
|
155
|
+
***
|
|
156
|
+
|
|
157
|
+
### beforeUpsert()?[](#beforeupsert "Direct link to beforeUpsert()?")
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
optional beforeUpsert(values: FacetOf<TTable, "insert">, context: HookContext): MaybePromise<void | FacetOf<TTable, "insert">>;
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Parameters[](#parameters-7 "Direct link to Parameters")
|
|
165
|
+
|
|
166
|
+
| Parameter | Type |
|
|
167
|
+
| --------- | ----------------------------------------------------------------- |
|
|
168
|
+
| `values` | `FacetOf`<`TTable`, `"insert"`> |
|
|
169
|
+
| `context` | [`HookContext`](./docs/api/appkit/Interface.HookContext.md) |
|
|
170
|
+
|
|
171
|
+
#### Returns[](#returns-7 "Direct link to Returns")
|
|
172
|
+
|
|
173
|
+
`MaybePromise`<`void` | `FacetOf`<`TTable`, `"insert"`>>
|
|
@@ -15,6 +15,34 @@ Target agent id. Defaults to the eval's parent `server/agents/<id>` dir.
|
|
|
15
15
|
|
|
16
16
|
***
|
|
17
17
|
|
|
18
|
+
### dataset?[](#dataset "Direct link to dataset?")
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
optional dataset: {
|
|
22
|
+
limit?: number;
|
|
23
|
+
table: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Run this eval once per row of a Databricks managed evaluation dataset (a Unity Catalog `catalog.schema.table` with `inputs`/`expectations` columns). Each row is bound to `t.input`/`t.expected`. Requires the runner to have a workspace client + warehouse (`--warehouse-id`). Omit for a single-run eval.
|
|
29
|
+
|
|
30
|
+
#### limit?[](#limit "Direct link to limit?")
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
optional limit: number;
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### table[](#table "Direct link to table")
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
table: string;
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
***
|
|
45
|
+
|
|
18
46
|
### description?[](#description "Direct link to description?")
|
|
19
47
|
|
|
20
48
|
```ts
|
|
@@ -4,6 +4,21 @@ Abstraction over how the agent is driven. The HTTP driver posts to a running app
|
|
|
4
4
|
|
|
5
5
|
## Methods[](#methods "Direct link to Methods")
|
|
6
6
|
|
|
7
|
+
### reset()?[](#reset "Direct link to reset()?")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
optional reset(): void;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Drop the current conversation so the next `send` starts a fresh thread. Optional: drivers without a session concept omit it.
|
|
15
|
+
|
|
16
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
17
|
+
|
|
18
|
+
`void`
|
|
19
|
+
|
|
20
|
+
***
|
|
21
|
+
|
|
7
22
|
### send()[](#send "Direct link to send()")
|
|
8
23
|
|
|
9
24
|
```ts
|
|
@@ -17,6 +32,6 @@ send(message: string): Promise<DriveResult>;
|
|
|
17
32
|
| --------- | -------- |
|
|
18
33
|
| `message` | `string` |
|
|
19
34
|
|
|
20
|
-
#### Returns[](#returns "Direct link to Returns")
|
|
35
|
+
#### Returns[](#returns-1 "Direct link to Returns")
|
|
21
36
|
|
|
22
37
|
`Promise`<[`DriveResult`](./docs/api/appkit/Interface.DriveResult.md)>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Interface: HookApp
|
|
2
|
+
|
|
3
|
+
The only capability a hook receives: entities bound to its transaction.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### database[](#database "Direct link to database")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly database: TransactionClient;
|
|
11
|
+
|
|
12
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Interface: HookContext
|
|
2
|
+
|
|
3
|
+
Which entity is being mutated, and the surface a hook may write through.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### app[](#app "Direct link to app")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly app: HookApp;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### entity[](#entity "Direct link to entity")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
readonly entity: string;
|
|
20
|
+
|
|
21
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Interface: ReadEvalDatasetOptions
|
|
2
|
+
|
|
3
|
+
## Properties[](#properties "Direct link to Properties")
|
|
4
|
+
|
|
5
|
+
### limit?[](#limit "Direct link to limit?")
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
optional limit: number;
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Optional row cap.
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### table[](#table "Direct link to table")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
table: string;
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Fully-qualified UC table: `catalog.schema.table`.
|
|
24
|
+
|
|
25
|
+
***
|
|
26
|
+
|
|
27
|
+
### warehouseId[](#warehouseid "Direct link to warehouseId")
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
warehouseId: string;
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
SQL warehouse id to run the read against.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Interface: ReadSerializerContext
|
|
2
|
+
|
|
3
|
+
Which entity and generated operation produced the row being shaped.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### entity[](#entity "Direct link to entity")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly entity: string;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### operation[](#operation "Direct link to operation")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
readonly operation: "detail" | "list";
|
|
20
|
+
|
|
21
|
+
```
|
|
@@ -24,6 +24,17 @@ Stable id for the eval (e.g. its file path relative to the evals dir).
|
|
|
24
24
|
|
|
25
25
|
***
|
|
26
26
|
|
|
27
|
+
### row?[](#row "Direct link to row?")
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
optional row: DatasetRow;
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Dataset row bound to `t.input`/`t.expected` for dataset-driven evals.
|
|
35
|
+
|
|
36
|
+
***
|
|
37
|
+
|
|
27
38
|
### strict?[](#strict "Direct link to strict?")
|
|
28
39
|
|
|
29
40
|
```ts
|
|
@@ -190,3 +190,25 @@ optional timeoutMs: number;
|
|
|
190
190
|
```
|
|
191
191
|
|
|
192
192
|
Per-turn wall-clock timeout (ms) before a turn is failed. Defaults to 120s.
|
|
193
|
+
|
|
194
|
+
***
|
|
195
|
+
|
|
196
|
+
### warehouseId?[](#warehouseid "Direct link to warehouseId?")
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
optional warehouseId: string;
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
SQL warehouse id used to read managed evaluation datasets.
|
|
204
|
+
|
|
205
|
+
***
|
|
206
|
+
|
|
207
|
+
### workspaceClient?[](#workspaceclient "Direct link to workspaceClient?")
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
optional workspaceClient: WorkspaceClient;
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Workspace client used to read managed evaluation datasets (for evals that declare `dataset`). Required alongside [warehouseId](#warehouseid) for those evals.
|
|
@@ -4,6 +4,28 @@ The `t` context passed to an eval's `test` function.
|
|
|
4
4
|
|
|
5
5
|
## Properties[](#properties "Direct link to Properties")
|
|
6
6
|
|
|
7
|
+
### expected[](#expected "Direct link to expected")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly expected: Record<string, unknown> | undefined;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The current dataset row's `expectations` (ground truth / guidelines), or `undefined` when the row has none or the eval isn't dataset-driven.
|
|
15
|
+
|
|
16
|
+
***
|
|
17
|
+
|
|
18
|
+
### input[](#input "Direct link to input")
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
readonly input: Record<string, unknown>;
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The current dataset row's `inputs` when the eval is dataset-driven (see [EvalDefinition.dataset](./docs/api/appkit/Interface.EvalDefinition.md#dataset)); `{}` for a plain single-run eval.
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
7
29
|
### judge[](#judge "Direct link to judge")
|
|
8
30
|
|
|
9
31
|
```ts
|
|
@@ -15,7 +37,7 @@ judge: {
|
|
|
15
37
|
|
|
16
38
|
```
|
|
17
39
|
|
|
18
|
-
LLM-as-judge scoring of the last reply (via autoevals → a Databricks judge model). Each returns a scored
|
|
40
|
+
LLM-as-judge scoring of the last reply (via autoevals → a Databricks judge model). Each returns a scored assertion that gates by default (a miss fails the eval); chain `.atLeast(n)` to change the pass threshold or `.soft()` to demote to a tracked-only metric. Requires the judge to be configured (`--judge-model`).
|
|
19
41
|
|
|
20
42
|
#### closedQA()[](#closedqa "Direct link to closedQA()")
|
|
21
43
|
|
|
@@ -152,6 +174,21 @@ Assert a value against a matcher, e.g. `t.check(t.reply, includes("Sunny"))`.
|
|
|
152
174
|
|
|
153
175
|
***
|
|
154
176
|
|
|
177
|
+
### reset()[](#reset "Direct link to reset()")
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
reset(): void;
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Start a fresh conversation: the next `send` opens a new thread with no history. Use to run several independent one-shot checks in one test. Consecutive `send`s (without a `reset`) stay in one multi-turn conversation.
|
|
185
|
+
|
|
186
|
+
#### Returns[](#returns-5 "Direct link to Returns")
|
|
187
|
+
|
|
188
|
+
`void`
|
|
189
|
+
|
|
190
|
+
***
|
|
191
|
+
|
|
155
192
|
### send()[](#send "Direct link to send()")
|
|
156
193
|
|
|
157
194
|
```ts
|
|
@@ -167,7 +204,7 @@ Send a user message to the agent and capture its response.
|
|
|
167
204
|
| --------- | -------- |
|
|
168
205
|
| `message` | `string` |
|
|
169
206
|
|
|
170
|
-
#### Returns[](#returns-
|
|
207
|
+
#### Returns[](#returns-6 "Direct link to Returns")
|
|
171
208
|
|
|
172
209
|
`Promise`<`void`>
|
|
173
210
|
|
|
@@ -188,7 +225,7 @@ Skip this eval with an optional reason.
|
|
|
188
225
|
| --------- | -------- |
|
|
189
226
|
| `reason?` | `string` |
|
|
190
227
|
|
|
191
|
-
#### Returns[](#returns-
|
|
228
|
+
#### Returns[](#returns-7 "Direct link to Returns")
|
|
192
229
|
|
|
193
230
|
`never`
|
|
194
231
|
|
|
@@ -203,6 +240,6 @@ succeeded(): AssertionHandle;
|
|
|
203
240
|
|
|
204
241
|
Assert the last turn completed successfully (gate by default).
|
|
205
242
|
|
|
206
|
-
#### Returns[](#returns-
|
|
243
|
+
#### Returns[](#returns-8 "Direct link to Returns")
|
|
207
244
|
|
|
208
245
|
[`AssertionHandle`](./docs/api/appkit/Interface.AssertionHandle.md)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Type Alias: DatabaseApiConfig\<TSchema>
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type DatabaseApiConfig<TSchema> =
|
|
5
|
+
| boolean
|
|
6
|
+
| {
|
|
7
|
+
tables?: readonly SchemaTableName<TSchema>[];
|
|
8
|
+
writes?: DatabaseApiWritesConfig<TSchema>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Full generated CRUD for every declared table by default. Set false to disable all generated routes, or use an object to restrict tables and writes. Keyed routes require a public primary key; upsert stays programmatic. Route names must start with a letter, contain only letters, digits, `_`, or `-`, be at most 64 characters, and be unique ignoring case. Invalid names fail setup; exclude internal tables with `api.tables` or use `api: false`.
|
|
14
|
+
|
|
15
|
+
Routes run as the app's service principal and apply no per-user filter, so anyone the app admits receives every enabled operation. An exposed table also becomes includable from its neighbours; a relation whose target stays off cannot be included.
|
|
16
|
+
|
|
17
|
+
Text filters accept caller-supplied `like`/`ilike` patterns; a server-side `statement_timeout` cancels a pattern that would otherwise hold its pooled connection to completion.
|
|
18
|
+
|
|
19
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
20
|
+
|
|
21
|
+
| Type Parameter |
|
|
22
|
+
| --------------------------------------------------------------------------- |
|
|
23
|
+
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md) |
|
|
24
|
+
|
|
25
|
+
## Type Declaration[](#type-declaration "Direct link to Type Declaration")
|
|
26
|
+
|
|
27
|
+
`boolean`
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
{
|
|
31
|
+
tables?: readonly SchemaTableName<TSchema>[];
|
|
32
|
+
writes?: DatabaseApiWritesConfig<TSchema>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### tables?[](#tables "Direct link to tables?")
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
readonly optional tables: readonly SchemaTableName<TSchema>[];
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Tables that remain exposed. Defaults to every declared table.
|
|
45
|
+
|
|
46
|
+
### writes?[](#writes "Direct link to writes?")
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
readonly optional writes: DatabaseApiWritesConfig<TSchema>;
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
All writes by default. Set false for read-only routes.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Type Alias: DatabaseApiWritesConfig\<TSchema>
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type DatabaseApiWritesConfig<TSchema> =
|
|
5
|
+
| boolean
|
|
6
|
+
| {
|
|
7
|
+
operations?: readonly DatabaseApiWriteOperation[];
|
|
8
|
+
tables?: readonly SchemaTableName<TSchema>[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
All writes by default; false keeps reads only, and an object narrows writes.
|
|
14
|
+
|
|
15
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
16
|
+
|
|
17
|
+
| Type Parameter |
|
|
18
|
+
| --------------------------------------------------------------------------- |
|
|
19
|
+
| `TSchema` *extends* [`Schema`](./docs/api/appkit/Interface.Schema.md) |
|
|
20
|
+
|
|
21
|
+
## Type Declaration[](#type-declaration "Direct link to Type Declaration")
|
|
22
|
+
|
|
23
|
+
`boolean`
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
{
|
|
27
|
+
operations?: readonly DatabaseApiWriteOperation[];
|
|
28
|
+
tables?: readonly SchemaTableName<TSchema>[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### operations?[](#operations "Direct link to operations?")
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
readonly optional operations: readonly DatabaseApiWriteOperation[];
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Operations that remain enabled. Defaults to create, update, and delete.
|
|
41
|
+
|
|
42
|
+
### tables?[](#tables "Direct link to tables?")
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
readonly optional tables: readonly SchemaTableName<TSchema>[];
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Tables that remain writable. Defaults to every exposed table.
|
|
@@ -26,9 +26,9 @@ transaction<T>(callback: (tx: TransactionClient) => Promise<T>): Promise<T>;
|
|
|
26
26
|
|
|
27
27
|
#### Parameters[](#parameters "Direct link to Parameters")
|
|
28
28
|
|
|
29
|
-
| Parameter | Type
|
|
30
|
-
| ---------- |
|
|
31
|
-
| `callback` | (`tx`: `TransactionClient`) => `Promise`<`T`> |
|
|
29
|
+
| Parameter | Type |
|
|
30
|
+
| ---------- | ------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `callback` | (`tx`: [`TransactionClient`](./docs/api/appkit/TypeAlias.TransactionClient.md)) => `Promise`<`T`> |
|
|
32
32
|
|
|
33
33
|
#### Returns[](#returns "Direct link to Returns")
|
|
34
34
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Type Alias: EntityHooks\<TTable>
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type EntityHooks<TTable> = EntityMutationHooks<TTable> & {
|
|
5
|
+
serialize?: ReadSerializer;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Response shaping and mutation lifecycle declared for one table.
|
|
11
|
+
|
|
12
|
+
## Type Declaration[](#type-declaration "Direct link to Type Declaration")
|
|
13
|
+
|
|
14
|
+
### serialize?[](#serialize "Direct link to serialize?")
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
readonly optional serialize: ReadSerializer;
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
22
|
+
|
|
23
|
+
| Type Parameter | Default type |
|
|
24
|
+
| --------------------------- | ------------ |
|
|
25
|
+
| `TTable` *extends* `string` | `string` |
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
```ts
|
|
4
4
|
type IDatabaseConfig<TSchema> = {
|
|
5
|
-
|
|
6
|
-
hooks?: { readonly [TTable in SchemaTableName<TSchema>]?:
|
|
5
|
+
api?: DatabaseApiConfig<TSchema>;
|
|
6
|
+
hooks?: { readonly [TTable in SchemaTableName<TSchema>]?: EntityHooks<TTable> };
|
|
7
7
|
schema: TSchema;
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -19,10 +19,21 @@ Configuration for one schema-bound DatabasePlugin instance.
|
|
|
19
19
|
|
|
20
20
|
## Properties[](#properties "Direct link to Properties")
|
|
21
21
|
|
|
22
|
-
###
|
|
22
|
+
### api?[](#api "Direct link to api?")
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
readonly optional
|
|
25
|
+
readonly optional api: DatabaseApiConfig<TSchema>;
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Generated HTTP CRUD is enabled for all tables by default, using the app's service principal. Every admitted caller receives the enabled operations; no per-user or per-row authorization is applied. This plugin does not support OBO. Use custom routes for application-specific authorization.
|
|
30
|
+
|
|
31
|
+
Set `false` to disable routes, `{ writes: false }` for reads only, or `{ tables: ["notes"] }` to expose only selected tables. To disable delete, use `{ writes: { operations: ["create", "update"] } }`.
|
|
32
|
+
|
|
33
|
+
#### Default Value[](#default-value "Direct link to Default Value")
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
true
|
|
26
37
|
|
|
27
38
|
```
|
|
28
39
|
|
|
@@ -31,7 +42,7 @@ readonly optional crudRoutes: CrudRoutesConfig<TSchema>;
|
|
|
31
42
|
### hooks?[](#hooks "Direct link to hooks?")
|
|
32
43
|
|
|
33
44
|
```ts
|
|
34
|
-
readonly optional hooks: { readonly [TTable in SchemaTableName<TSchema>]?:
|
|
45
|
+
readonly optional hooks: { readonly [TTable in SchemaTableName<TSchema>]?: EntityHooks<TTable> };
|
|
35
46
|
|
|
36
47
|
```
|
|
37
48
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Type Alias: ReadSerializer()
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
type ReadSerializer = (row: Record<string, unknown>, context: ReadSerializerContext) => Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Shape one already private-safe row before it reaches the wire. A `Promise` is not assignable to the return type, so an async callback fails to compile: serializers run inside the response path and must not add latency there.
|
|
9
|
+
|
|
10
|
+
## Parameters[](#parameters "Direct link to Parameters")
|
|
11
|
+
|
|
12
|
+
| Parameter | Type |
|
|
13
|
+
| --------- | ------------------------------------------------------------------------------------- |
|
|
14
|
+
| `row` | `Record`<`string`, `unknown`> |
|
|
15
|
+
| `context` | [`ReadSerializerContext`](./docs/api/appkit/Interface.ReadSerializerContext.md) |
|
|
16
|
+
|
|
17
|
+
## Returns[](#returns "Direct link to Returns")
|
|
18
|
+
|
|
19
|
+
`Record`<`string`, `unknown`>
|