@databricks/appkit-ui 0.23.0 → 0.25.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 +9 -1
- package/dist/cli/commands/docs.js +7 -1
- package/dist/cli/commands/docs.js.map +1 -1
- package/dist/cli/commands/generate-types.js +20 -10
- package/dist/cli/commands/generate-types.js.map +1 -1
- package/dist/cli/commands/lint.js +3 -1
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/plugin/add-resource/add-resource.js +73 -8
- package/dist/cli/commands/plugin/add-resource/add-resource.js.map +1 -1
- package/dist/cli/commands/plugin/create/create.js +164 -20
- package/dist/cli/commands/plugin/create/create.js.map +1 -1
- package/dist/cli/commands/plugin/create/resource-defaults.js +5 -1
- package/dist/cli/commands/plugin/create/resource-defaults.js.map +1 -1
- package/dist/cli/commands/plugin/index.js +7 -1
- package/dist/cli/commands/plugin/index.js.map +1 -1
- package/dist/cli/commands/plugin/list/list.js +7 -1
- package/dist/cli/commands/plugin/list/list.js.map +1 -1
- package/dist/cli/commands/plugin/sync/sync.js +27 -14
- package/dist/cli/commands/plugin/sync/sync.js.map +1 -1
- package/dist/cli/commands/plugin/validate/validate.js +39 -9
- package/dist/cli/commands/plugin/validate/validate.js.map +1 -1
- package/dist/cli/commands/setup.js +6 -5
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/react/hooks/types.d.ts +1 -1
- package/docs/api/appkit/Class.PolicyDeniedError.md +52 -0
- package/docs/api/appkit/Interface.FilePolicyUser.md +23 -0
- package/docs/api/appkit/Interface.FileResource.md +36 -0
- package/docs/api/appkit/TypeAlias.FileAction.md +18 -0
- package/docs/api/appkit/TypeAlias.FilePolicy.md +20 -0
- package/docs/api/appkit/TypeAlias.ServingFactory.md +9 -5
- package/docs/api/appkit/Variable.READ_ACTIONS.md +8 -0
- package/docs/api/appkit/Variable.WRITE_ACTIONS.md +8 -0
- package/docs/api/appkit.md +19 -12
- package/docs/development/type-generation.md +6 -5
- package/docs/faq.md +8 -8
- package/docs/plugins/analytics.md +1 -1
- package/docs/plugins/custom-plugins.md +4 -0
- package/docs/plugins/execution-context.md +0 -1
- package/docs/plugins/files.md +150 -2
- package/docs/plugins/{serving.md → model-serving.md} +1 -1
- package/docs/plugins/plugin-management.md +22 -6
- package/docs/plugins/vector-search.md +247 -0
- package/llms.txt +9 -1
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
package/docs/plugins/files.md
CHANGED
|
@@ -12,6 +12,7 @@ File operations against Databricks Unity Catalog Volumes. Supports listing, read
|
|
|
12
12
|
* Automatic cache invalidation on write operations
|
|
13
13
|
* Custom content type mappings
|
|
14
14
|
* Per-user execution context (OBO)
|
|
15
|
+
* **Access policies**: Per-volume policy functions that gate read and write operations
|
|
15
16
|
|
|
16
17
|
## Basic usage[](#basic-usage "Direct link to Basic usage")
|
|
17
18
|
|
|
@@ -75,6 +76,8 @@ interface IFilesConfig {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
interface VolumeConfig {
|
|
79
|
+
/** Access policy for this volume. */
|
|
80
|
+
policy?: FilePolicy;
|
|
78
81
|
/** Maximum upload size in bytes for this volume. Overrides plugin-level default. */
|
|
79
82
|
maxUploadSize?: number;
|
|
80
83
|
/** Map of file extensions to MIME types for this volume. Overrides plugin-level default. */
|
|
@@ -99,6 +102,121 @@ files({
|
|
|
99
102
|
|
|
100
103
|
```
|
|
101
104
|
|
|
105
|
+
### Permission model[](#permission-model "Direct link to Permission model")
|
|
106
|
+
|
|
107
|
+
There are three layers of access control in the files plugin. Understanding how they interact is critical for securing your app:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
┌─────────────────────────────────────────────────┐
|
|
111
|
+
│ Unity Catalog grants │
|
|
112
|
+
│ (WRITE_VOLUME on the SP — set at deploy time) │
|
|
113
|
+
├─────────────────────────────────────────────────┤
|
|
114
|
+
│ Execution identity │
|
|
115
|
+
│ HTTP routes → always service principal │
|
|
116
|
+
│ Programmatic → SP by default, asUser() for OBO │
|
|
117
|
+
├─────────────────────────────────────────────────┤
|
|
118
|
+
│ File policies │
|
|
119
|
+
│ Per-volume (action, resource, user) → boolean │
|
|
120
|
+
│ Only app-level gate for HTTP routes │
|
|
121
|
+
└─────────────────────────────────────────────────┘
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
* **UC grants** control what the service principal can do at the Databricks level. These are set at deploy time via `app.yaml` resource bindings. The SP needs `WRITE_VOLUME` — the plugin declares this via resource requirements.
|
|
126
|
+
* **Execution identity** determines whose credentials are used for the actual API call. HTTP routes always use the SP. The programmatic API uses SP by default but supports `asUser(req)` for OBO.
|
|
127
|
+
* **File policies** are application-level checks evaluated **before** the API call. They receive the requesting user's identity (from the `x-forwarded-user` header) and decide allow/deny. This is the only gate that distinguishes between users on HTTP routes.
|
|
128
|
+
|
|
129
|
+
warning
|
|
130
|
+
|
|
131
|
+
Since HTTP routes always execute as the service principal, removing a user's UC `WRITE_VOLUME` grant has **no effect** on HTTP access — the SP's grant is what's used. Policies are how you restrict what individual users can do through your app.
|
|
132
|
+
|
|
133
|
+
New in v0.21.0
|
|
134
|
+
|
|
135
|
+
File policies are new. Volumes without an explicit policy now default to `publicRead()`, which **denies all write operations** (`upload`, `mkdir`, `delete`). If your app relies on write access, set an explicit policy — for example `files.policy.allowAll()` — on each volume that needs it.
|
|
136
|
+
|
|
137
|
+
#### Access policies[](#access-policies "Direct link to Access policies")
|
|
138
|
+
|
|
139
|
+
Attach a policy to a volume to control which actions are allowed:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { files } from "@databricks/appkit";
|
|
143
|
+
|
|
144
|
+
files({
|
|
145
|
+
volumes: {
|
|
146
|
+
uploads: { policy: files.policy.publicRead() },
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Actions[](#actions "Direct link to Actions")
|
|
153
|
+
|
|
154
|
+
Policies receive an action string. The full list, split by category:
|
|
155
|
+
|
|
156
|
+
| Category | Actions |
|
|
157
|
+
| -------- | ------------------------------------------------------------------ |
|
|
158
|
+
| Read | `list`, `read`, `download`, `raw`, `exists`, `metadata`, `preview` |
|
|
159
|
+
| Write | `upload`, `mkdir`, `delete` |
|
|
160
|
+
|
|
161
|
+
#### Built-in policies[](#built-in-policies "Direct link to Built-in policies")
|
|
162
|
+
|
|
163
|
+
| Helper | Allows | Denies |
|
|
164
|
+
| --------------------------- | ---------------- | ----------------- |
|
|
165
|
+
| `files.policy.publicRead()` | all read actions | all write actions |
|
|
166
|
+
| `files.policy.allowAll()` | everything | nothing |
|
|
167
|
+
| `files.policy.denyAll()` | nothing | everything |
|
|
168
|
+
|
|
169
|
+
#### Composing policies[](#composing-policies "Direct link to Composing policies")
|
|
170
|
+
|
|
171
|
+
Combine built-in and custom policies with three combinators:
|
|
172
|
+
|
|
173
|
+
* **`files.policy.all(a, b)`** — AND: all policies must allow. Short-circuits on first denial.
|
|
174
|
+
* **`files.policy.any(a, b)`** — OR: at least one policy must allow. Short-circuits on first allow.
|
|
175
|
+
* **`files.policy.not(p)`** — Inverts a policy. For example, `not(publicRead())` yields a write-only policy (useful for ingestion/drop-box volumes).
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
// Read-only for regular users, full access for the service principal
|
|
179
|
+
files({
|
|
180
|
+
volumes: {
|
|
181
|
+
shared: {
|
|
182
|
+
policy: files.policy.any(
|
|
183
|
+
(_action, _resource, user) => !!user.isServicePrincipal,
|
|
184
|
+
files.policy.publicRead(),
|
|
185
|
+
),
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Custom policies[](#custom-policies "Direct link to Custom policies")
|
|
193
|
+
|
|
194
|
+
`FilePolicy` is a function `(action, resource, user) → boolean | Promise<boolean>`, so you can inline arbitrary logic:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
import { type FilePolicy, WRITE_ACTIONS } from "@databricks/appkit";
|
|
198
|
+
|
|
199
|
+
const ADMIN_IDS = ["admin-sp-id", "lead-user-id"];
|
|
200
|
+
|
|
201
|
+
const adminOnly: FilePolicy = (action, _resource, user) => {
|
|
202
|
+
if (WRITE_ACTIONS.has(action)) {
|
|
203
|
+
return ADMIN_IDS.includes(user.id);
|
|
204
|
+
}
|
|
205
|
+
return true; // reads allowed for everyone
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
files({
|
|
209
|
+
volumes: { reports: { policy: adminOnly } },
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Enforcement[](#enforcement "Direct link to Enforcement")
|
|
215
|
+
|
|
216
|
+
* **HTTP routes**: Policy checked before every operation. Denied → `403` JSON response with `Policy denied "{action}" on volume "{volumeKey}"`.
|
|
217
|
+
* **Programmatic API**: Policy checked on both `appkit.files("vol").list()` (SP identity, `isServicePrincipal: true`) and `appkit.files("vol").asUser(req).list()` (user identity). Denied → throws `PolicyDeniedError`.
|
|
218
|
+
* **No policy configured**: Defaults to `files.policy.publicRead()` — read actions are allowed, write actions are denied. A startup warning is logged encouraging you to set an explicit policy.
|
|
219
|
+
|
|
102
220
|
### Custom content types[](#custom-content-types "Direct link to Custom content types")
|
|
103
221
|
|
|
104
222
|
Override or extend the built-in extension → MIME map:
|
|
@@ -118,7 +236,7 @@ Dangerous MIME types (`text/html`, `text/javascript`, `application/javascript`,
|
|
|
118
236
|
|
|
119
237
|
## HTTP routes[](#http-routes "Direct link to HTTP routes")
|
|
120
238
|
|
|
121
|
-
Routes are mounted at `/api/files/*`. All routes
|
|
239
|
+
Routes are mounted at `/api/files/*`. All routes execute as the service principal. Policy enforcement checks user identity (from the `x-forwarded-user` header) before allowing operations — see [Access policies](#access-policies).
|
|
122
240
|
|
|
123
241
|
| Method | Path | Query / Body | Response |
|
|
124
242
|
| ------ | ---------------------- | ---------------------------- | ------------------------------------------------------------ |
|
|
@@ -242,7 +360,36 @@ interface FilePreview extends FileMetadata {
|
|
|
242
360
|
isImage: boolean;
|
|
243
361
|
}
|
|
244
362
|
|
|
363
|
+
type FileAction =
|
|
364
|
+
| "list" | "read" | "download" | "raw"
|
|
365
|
+
| "exists" | "metadata" | "preview"
|
|
366
|
+
| "upload" | "mkdir" | "delete";
|
|
367
|
+
|
|
368
|
+
interface FileResource {
|
|
369
|
+
/** Relative path within the volume. */
|
|
370
|
+
path: string;
|
|
371
|
+
/** The volume key (e.g. `"uploads"`). */
|
|
372
|
+
volume: string;
|
|
373
|
+
/** Content length in bytes — only present for uploads. */
|
|
374
|
+
size?: number;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
interface FilePolicyUser {
|
|
378
|
+
/** User ID from the `x-forwarded-user` header. */
|
|
379
|
+
id: string;
|
|
380
|
+
/** `true` when the caller is the service principal (direct SDK call, not `asUser`). */
|
|
381
|
+
isServicePrincipal?: boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
type FilePolicy = (
|
|
385
|
+
action: FileAction,
|
|
386
|
+
resource: FileResource,
|
|
387
|
+
user: FilePolicyUser,
|
|
388
|
+
) => boolean | Promise<boolean>;
|
|
389
|
+
|
|
245
390
|
interface VolumeConfig {
|
|
391
|
+
/** Access policy for this volume. */
|
|
392
|
+
policy?: FilePolicy;
|
|
246
393
|
/** Maximum upload size in bytes for this volume. */
|
|
247
394
|
maxUploadSize?: number;
|
|
248
395
|
/** Map of file extensions to MIME types for this volume. */
|
|
@@ -280,7 +427,7 @@ Built-in extensions: `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.svg`, `.bmp`, `
|
|
|
280
427
|
|
|
281
428
|
## User context[](#user-context "Direct link to User context")
|
|
282
429
|
|
|
283
|
-
|
|
430
|
+
HTTP routes always execute as the **service principal** — the SP's Databricks credentials are used for all API calls. User identity is extracted from the `x-forwarded-user` header and passed to the volume's [access policy](#access-policies) for authorization. This means UC grants on the SP (not individual users) determine what operations are possible, while policies control what each user is allowed to do through the app.
|
|
284
431
|
|
|
285
432
|
The programmatic API returns a `VolumeHandle` that exposes all `VolumeAPI` methods directly (service principal) and an `asUser(req)` method for OBO access. Calling any method without `asUser()` logs a warning encouraging OBO usage but does not throw. OBO access is strongly recommended for production use.
|
|
286
433
|
|
|
@@ -305,6 +452,7 @@ All errors return JSON:
|
|
|
305
452
|
| Status | Description |
|
|
306
453
|
| ------ | ------------------------------------------------------------- |
|
|
307
454
|
| 400 | Missing or invalid `path` parameter |
|
|
455
|
+
| 403 | Policy denied "`{action}`" on volume "`{volumeKey}`" |
|
|
308
456
|
| 404 | Unknown volume key |
|
|
309
457
|
| 413 | Upload exceeds `maxUploadSize` |
|
|
310
458
|
| 500 | Operation failed (SDK, network, upstream, or unhandled error) |
|
|
@@ -6,19 +6,30 @@ AppKit includes a CLI for managing plugins. All commands are available under `np
|
|
|
6
6
|
|
|
7
7
|
## Create a plugin[](#create-a-plugin "Direct link to Create a plugin")
|
|
8
8
|
|
|
9
|
-
Scaffold a new plugin interactively:
|
|
9
|
+
Scaffold a new plugin interactively or via flags:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
+
# Interactive mode (prompts for all options)
|
|
12
13
|
npx @databricks/appkit plugin create
|
|
13
14
|
|
|
15
|
+
# Non-interactive mode (all required flags provided)
|
|
16
|
+
npx @databricks/appkit plugin create \
|
|
17
|
+
--placement in-repo \
|
|
18
|
+
--path plugins/my-plugin \
|
|
19
|
+
--name my-plugin \
|
|
20
|
+
--description "My custom plugin" \
|
|
21
|
+
--resources sql_warehouse \
|
|
22
|
+
--force
|
|
23
|
+
|
|
14
24
|
```
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
In interactive mode, the wizard walks you through:
|
|
17
27
|
|
|
18
28
|
* **Placement**: In your repository (e.g. `plugins/my-plugin`) or as a standalone package
|
|
19
29
|
* **Metadata**: Name, display name, description
|
|
20
30
|
* **Resources**: Which Databricks resources the plugin needs (SQL Warehouse, Secret, etc.) and whether each is required or optional
|
|
21
|
-
|
|
31
|
+
|
|
32
|
+
In non-interactive mode, `--placement`, `--path`, `--name`, and `--description` are required. Resources can be specified as a comma-separated list (`--resources sql_warehouse,volume`) or as JSON for full control (`--resources-json '[{"type":"sql_warehouse","permission":"CAN_MANAGE"}]'`). For all available options, run `npx @databricks/appkit plugin create --help`.
|
|
22
33
|
|
|
23
34
|
The command generates a complete plugin scaffold with `manifest.json` and a TypeScript plugin class that imports the manifest directly — ready to register in your app.
|
|
24
35
|
|
|
@@ -91,12 +102,17 @@ npx @databricks/appkit plugin list --json
|
|
|
91
102
|
|
|
92
103
|
## Add a resource to a plugin[](#add-a-resource-to-a-plugin "Direct link to Add a resource to a plugin")
|
|
93
104
|
|
|
94
|
-
|
|
105
|
+
Add a new resource requirement to an existing plugin manifest. **Requires `manifest.json`** in the plugin directory (the command edits it in place; it does not modify `manifest.js`):
|
|
95
106
|
|
|
96
107
|
```bash
|
|
108
|
+
# Interactive mode
|
|
97
109
|
npx @databricks/appkit plugin add-resource
|
|
98
|
-
|
|
99
|
-
# Or specify the plugin directory
|
|
100
110
|
npx @databricks/appkit plugin add-resource --path plugins/my-plugin
|
|
101
111
|
|
|
112
|
+
# Non-interactive mode (--type triggers flag-based mode)
|
|
113
|
+
npx @databricks/appkit plugin add-resource --path plugins/my-plugin --type sql_warehouse
|
|
114
|
+
npx @databricks/appkit plugin add-resource --path plugins/my-plugin --type volume --no-required --dry-run
|
|
115
|
+
|
|
102
116
|
```
|
|
117
|
+
|
|
118
|
+
In non-interactive mode, only `--type` is required — all other fields (permission, resource key, field env vars) default to sensible values from the schema. Use `--dry-run` to preview the updated manifest without writing. For all available options, run `npx @databricks/appkit plugin add-resource --help`.
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Vector Search plugin
|
|
2
|
+
|
|
3
|
+
Query Databricks Vector Search indexes with hybrid search, reranking, and cursor pagination from your AppKit application.
|
|
4
|
+
|
|
5
|
+
**Key features:**
|
|
6
|
+
|
|
7
|
+
* Named index aliases for multiple Vector Search indexes
|
|
8
|
+
* Hybrid, ANN, and full-text query modes
|
|
9
|
+
* Optional reranking with column-level control
|
|
10
|
+
* Cursor-based pagination for large result sets
|
|
11
|
+
* Service principal (default) and on-behalf-of-user auth
|
|
12
|
+
* Self-managed embedding indexes via custom `embeddingFn`
|
|
13
|
+
|
|
14
|
+
## Basic usage[](#basic-usage "Direct link to Basic usage")
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { createApp, vectorSearch, server } from "@databricks/appkit";
|
|
18
|
+
|
|
19
|
+
await createApp({
|
|
20
|
+
plugins: [
|
|
21
|
+
server(),
|
|
22
|
+
vectorSearch({
|
|
23
|
+
indexes: {
|
|
24
|
+
products: {
|
|
25
|
+
indexName: "catalog.schema.products_idx",
|
|
26
|
+
columns: ["id", "name", "description"],
|
|
27
|
+
queryType: "hybrid",
|
|
28
|
+
numResults: 20,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration options[](#configuration-options "Direct link to Configuration options")
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
| --------- | ----------------------------- | ------- | -------------------------------------------------------- |
|
|
41
|
+
| `indexes` | `Record<string, IndexConfig>` | — | **Required.** Map of alias names to index configurations |
|
|
42
|
+
| `timeout` | `number` | `30000` | Query timeout in ms |
|
|
43
|
+
|
|
44
|
+
### Index aliases[](#index-aliases "Direct link to Index aliases")
|
|
45
|
+
|
|
46
|
+
Index aliases let you reference multiple Vector Search indexes by name. The alias is used in API routes and programmatic calls:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
vectorSearch({
|
|
50
|
+
indexes: {
|
|
51
|
+
products: {
|
|
52
|
+
indexName: "catalog.schema.products_idx",
|
|
53
|
+
columns: ["id", "name", "description"],
|
|
54
|
+
},
|
|
55
|
+
docs: {
|
|
56
|
+
indexName: "catalog.schema.docs_idx",
|
|
57
|
+
columns: ["id", "title", "content", "url"],
|
|
58
|
+
queryType: "full_text",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## IndexConfig[](#indexconfig "Direct link to IndexConfig")
|
|
66
|
+
|
|
67
|
+
| Field | Type | Default | Description |
|
|
68
|
+
| -------------- | -------------------------------------------- | --------------------- | ------------------------------------------------------------------------------- |
|
|
69
|
+
| `indexName` | `string` | — | **Required.** Three-level Unity Catalog name (`catalog.schema.index`) |
|
|
70
|
+
| `columns` | `string[]` | — | **Required.** Columns to return in query results |
|
|
71
|
+
| `queryType` | `"ann" \| "hybrid" \| "full_text"` | `"hybrid"` | Search mode |
|
|
72
|
+
| `numResults` | `number` | `20` | Maximum results per query |
|
|
73
|
+
| `reranker` | `boolean \| { columnsToRerank: string[] }` | — | Enable reranking. Pass `true` to rerank all result columns, or specify a subset |
|
|
74
|
+
| `auth` | `"service-principal" \| "on-behalf-of-user"` | `"service-principal"` | Authentication mode for query execution |
|
|
75
|
+
| `pagination` | `boolean` | — | Enable cursor-based pagination |
|
|
76
|
+
| `endpointName` | `string` | — | Vector Search endpoint name. Required when `pagination` is `true` |
|
|
77
|
+
| `embeddingFn` | `(text: string) => Promise<number[]>` | — | Custom embedding function for self-managed embedding indexes |
|
|
78
|
+
|
|
79
|
+
### Query types[](#query-types "Direct link to Query types")
|
|
80
|
+
|
|
81
|
+
* **`hybrid`** — Combines vector similarity and keyword search. Best for general-purpose retrieval.
|
|
82
|
+
* **`ann`** — Approximate nearest neighbor search using embeddings only. Best for semantic similarity.
|
|
83
|
+
* **`full_text`** — Keyword-based search with no embedding required.
|
|
84
|
+
|
|
85
|
+
### Reranking[](#reranking "Direct link to Reranking")
|
|
86
|
+
|
|
87
|
+
Reranking improves result relevance by running a second-stage model over the initial candidates:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
vectorSearch({
|
|
91
|
+
indexes: {
|
|
92
|
+
products: {
|
|
93
|
+
indexName: "catalog.schema.products_idx",
|
|
94
|
+
columns: ["id", "name", "description", "category"],
|
|
95
|
+
reranker: { columnsToRerank: ["name", "description"] },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Pass `reranker: true` to rerank across all returned columns.
|
|
103
|
+
|
|
104
|
+
### On-behalf-of-user auth[](#on-behalf-of-user-auth "Direct link to On-behalf-of-user auth")
|
|
105
|
+
|
|
106
|
+
By default, queries run as the app's service principal. Set `auth: "on-behalf-of-user"` to execute queries as the signed-in user instead:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
vectorSearch({
|
|
110
|
+
indexes: {
|
|
111
|
+
documents: {
|
|
112
|
+
indexName: "catalog.schema.documents_idx",
|
|
113
|
+
columns: ["id", "title", "body"],
|
|
114
|
+
auth: "on-behalf-of-user",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Pagination[](#pagination "Direct link to Pagination")
|
|
122
|
+
|
|
123
|
+
Enable cursor pagination to page through large result sets:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
vectorSearch({
|
|
127
|
+
indexes: {
|
|
128
|
+
products: {
|
|
129
|
+
indexName: "catalog.schema.products_idx",
|
|
130
|
+
columns: ["id", "name", "description"],
|
|
131
|
+
pagination: true,
|
|
132
|
+
endpointName: "my-vector-search-endpoint",
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`endpointName` is required when `pagination` is `true`. Use the `/:alias/next-page` route to fetch subsequent pages.
|
|
140
|
+
|
|
141
|
+
### Self-managed embedding indexes[](#self-managed-embedding-indexes "Direct link to Self-managed embedding indexes")
|
|
142
|
+
|
|
143
|
+
For indexes that manage their own embeddings, provide an `embeddingFn` that takes a query string and returns a vector:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { embed } from "./my-embedding-client";
|
|
147
|
+
|
|
148
|
+
vectorSearch({
|
|
149
|
+
indexes: {
|
|
150
|
+
products: {
|
|
151
|
+
indexName: "catalog.schema.products_idx",
|
|
152
|
+
columns: ["id", "name", "description"],
|
|
153
|
+
queryType: "ann",
|
|
154
|
+
embeddingFn: (text) => embed(text),
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## HTTP routes[](#http-routes "Direct link to HTTP routes")
|
|
162
|
+
|
|
163
|
+
Routes are mounted at `/api/vector-search`.
|
|
164
|
+
|
|
165
|
+
| Method | Path | Description |
|
|
166
|
+
| ------ | ------------------- | ------------------------------------------------------------ |
|
|
167
|
+
| `POST` | `/:alias/query` | Query an index by alias |
|
|
168
|
+
| `POST` | `/:alias/next-page` | Fetch the next page of results (requires `pagination: true`) |
|
|
169
|
+
| `GET` | `/:alias/config` | Return the resolved config for an index alias |
|
|
170
|
+
|
|
171
|
+
### Query an index[](#query-an-index "Direct link to Query an index")
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
POST /api/vector-search/:alias/query
|
|
175
|
+
Content-Type: application/json
|
|
176
|
+
|
|
177
|
+
{
|
|
178
|
+
"queryText": "machine learning guide",
|
|
179
|
+
"numResults": 10
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Response:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"results": [
|
|
189
|
+
{ "id": "42", "name": "Intro to ML", "description": "..." }
|
|
190
|
+
],
|
|
191
|
+
"nextPageToken": "eyJvZmZzZXQiOjEwfQ=="
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
`nextPageToken` is only present when `pagination` is enabled and more results are available.
|
|
197
|
+
|
|
198
|
+
### Fetch the next page[](#fetch-the-next-page "Direct link to Fetch the next page")
|
|
199
|
+
|
|
200
|
+
```text
|
|
201
|
+
POST /api/vector-search/:alias/next-page
|
|
202
|
+
Content-Type: application/json
|
|
203
|
+
|
|
204
|
+
{
|
|
205
|
+
"queryText": "machine learning guide",
|
|
206
|
+
"pageToken": "eyJvZmZzZXQiOjEwfQ=="
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Get index config[](#get-index-config "Direct link to Get index config")
|
|
212
|
+
|
|
213
|
+
```text
|
|
214
|
+
GET /api/vector-search/:alias/config
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Returns the resolved `IndexConfig` for the alias (excluding `embeddingFn`).
|
|
219
|
+
|
|
220
|
+
## Programmatic access[](#programmatic-access "Direct link to Programmatic access")
|
|
221
|
+
|
|
222
|
+
The plugin exposes a `query` method for server-side use:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
const AppKit = await createApp({
|
|
226
|
+
plugins: [
|
|
227
|
+
server(),
|
|
228
|
+
vectorSearch({
|
|
229
|
+
indexes: {
|
|
230
|
+
products: {
|
|
231
|
+
indexName: "catalog.schema.products_idx",
|
|
232
|
+
columns: ["id", "name", "description"],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
}),
|
|
236
|
+
],
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const result = await AppKit.vectorSearch.query("products", {
|
|
240
|
+
queryText: "machine learning guide",
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
console.log(result.results);
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Pass optional overrides as a second argument to `query` to adjust `numResults` or other per-call settings.
|
package/llms.txt
CHANGED
|
@@ -49,9 +49,10 @@ npx @databricks/appkit docs <query>
|
|
|
49
49
|
- [Files plugin](./docs/plugins/files.md): File operations against Databricks Unity Catalog Volumes. Supports listing, reading, downloading, uploading, deleting, and previewing files with built-in caching, retry, and timeout handling via the execution interceptor pipeline.
|
|
50
50
|
- [Genie plugin](./docs/plugins/genie.md): Integrates Databricks AI/BI Genie spaces into your AppKit application, enabling natural language data queries via a conversational interface.
|
|
51
51
|
- [Lakebase plugin](./docs/plugins/lakebase.md): Provides a PostgreSQL connection pool for Databricks Lakebase Autoscaling with automatic OAuth token refresh.
|
|
52
|
+
- [Model Serving plugin](./docs/plugins/model-serving.md): Provides an authenticated proxy to Databricks Model Serving endpoints, with invoke and streaming support.
|
|
52
53
|
- [Plugin management](./docs/plugins/plugin-management.md): AppKit includes a CLI for managing plugins. All commands are available under npx @databricks/appkit plugin.
|
|
53
54
|
- [Server plugin](./docs/plugins/server.md): Provides HTTP server capabilities with development and production modes.
|
|
54
|
-
- [
|
|
55
|
+
- [Vector Search plugin](./docs/plugins/vector-search.md): Query Databricks Vector Search indexes with hybrid search, reranking, and cursor pagination from your AppKit application.
|
|
55
56
|
|
|
56
57
|
## appkit API reference [collapsed]
|
|
57
58
|
|
|
@@ -63,6 +64,7 @@ npx @databricks/appkit docs <query>
|
|
|
63
64
|
- [Class: ExecutionError](./docs/api/appkit/Class.ExecutionError.md): Error thrown when an operation execution fails.
|
|
64
65
|
- [Class: InitializationError](./docs/api/appkit/Class.InitializationError.md): Error thrown when a service or component is not properly initialized.
|
|
65
66
|
- [Abstract Class: Plugin<TConfig>](./docs/api/appkit/Class.Plugin.md): Base abstract class for creating AppKit plugins.
|
|
67
|
+
- [Class: PolicyDeniedError](./docs/api/appkit/Class.PolicyDeniedError.md): Thrown when a policy denies an action.
|
|
66
68
|
- [Class: ResourceRegistry](./docs/api/appkit/Class.ResourceRegistry.md): Central registry for tracking plugin resource requirements.
|
|
67
69
|
- [Class: ServerError](./docs/api/appkit/Class.ServerError.md): Error thrown when server lifecycle operations fail.
|
|
68
70
|
- [Class: TunnelError](./docs/api/appkit/Class.TunnelError.md): Error thrown when remote tunnel operations fail.
|
|
@@ -88,6 +90,8 @@ npx @databricks/appkit docs <query>
|
|
|
88
90
|
- [Interface: CacheConfig](./docs/api/appkit/Interface.CacheConfig.md): Configuration for the CacheInterceptor. Controls TTL, size limits, storage backend, and probabilistic cleanup.
|
|
89
91
|
- [Interface: DatabaseCredential](./docs/api/appkit/Interface.DatabaseCredential.md): Database credentials with OAuth token for Postgres connection
|
|
90
92
|
- [Interface: EndpointConfig](./docs/api/appkit/Interface.EndpointConfig.md): Properties
|
|
93
|
+
- [Interface: FilePolicyUser](./docs/api/appkit/Interface.FilePolicyUser.md): Minimal user identity passed to the policy function.
|
|
94
|
+
- [Interface: FileResource](./docs/api/appkit/Interface.FileResource.md): Describes the file or directory being acted upon.
|
|
91
95
|
- [Interface: GenerateDatabaseCredentialRequest](./docs/api/appkit/Interface.GenerateDatabaseCredentialRequest.md): Request parameters for generating database OAuth credentials
|
|
92
96
|
- [Interface: ITelemetry](./docs/api/appkit/Interface.ITelemetry.md): Plugin-facing interface for OpenTelemetry instrumentation.
|
|
93
97
|
- [Interface: LakebasePoolConfig](./docs/api/appkit/Interface.LakebasePoolConfig.md): Configuration for creating a Lakebase connection pool
|
|
@@ -104,12 +108,16 @@ npx @databricks/appkit docs <query>
|
|
|
104
108
|
- [Interface: ValidationResult](./docs/api/appkit/Interface.ValidationResult.md): Result of validating all registered resources against the environment.
|
|
105
109
|
- [Type Alias: ConfigSchema](./docs/api/appkit/TypeAlias.ConfigSchema.md): Configuration schema definition for plugin config.
|
|
106
110
|
- [Type Alias: ExecutionResult<T>](./docs/api/appkit/TypeAlias.ExecutionResult.md): Discriminated union for plugin execution results.
|
|
111
|
+
- [Type Alias: FileAction](./docs/api/appkit/TypeAlias.FileAction.md): Every action the files plugin can perform.
|
|
112
|
+
- [Type Alias: FilePolicy()](./docs/api/appkit/TypeAlias.FilePolicy.md): A policy function that decides whether user may perform action on
|
|
107
113
|
- [Type Alias: IAppRouter](./docs/api/appkit/TypeAlias.IAppRouter.md): Express router type for plugin route registration
|
|
108
114
|
- [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().
|
|
109
115
|
- [Type Alias: ResourcePermission](./docs/api/appkit/TypeAlias.ResourcePermission.md): Union of all possible permission levels across all resource types.
|
|
110
116
|
- [Type Alias: ServingFactory](./docs/api/appkit/TypeAlias.ServingFactory.md): Factory function returned by AppKit.serving.
|
|
111
117
|
- [Type Alias: ToPlugin()<T, U, N>](./docs/api/appkit/TypeAlias.ToPlugin.md): Factory function type returned by toPlugin(). Accepts optional config and returns a PluginData tuple.
|
|
118
|
+
- [Variable: READ_ACTIONS](./docs/api/appkit/Variable.READ_ACTIONS.md): Actions that only read data.
|
|
112
119
|
- [Variable: sql](./docs/api/appkit/Variable.sql.md): SQL helper namespace
|
|
120
|
+
- [Variable: WRITE_ACTIONS](./docs/api/appkit/Variable.WRITE_ACTIONS.md): Actions that mutate data.
|
|
113
121
|
|
|
114
122
|
## appkit-ui API reference [collapsed]
|
|
115
123
|
|