@databricks/appkit 0.3.0 → 0.4.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 +121 -1231
- package/NOTICE.md +1 -1
- package/bin/appkit.js +3 -0
- package/dist/appkit/package.js +1 -1
- package/dist/cache/index.js +3 -3
- package/dist/cache/index.js.map +1 -1
- package/dist/cli/commands/docs.js +47 -0
- package/dist/cli/commands/docs.js.map +1 -0
- package/dist/cli/commands/generate-types.js +38 -0
- package/dist/cli/commands/generate-types.js.map +1 -0
- package/dist/cli/commands/lint.js +104 -0
- package/dist/cli/commands/lint.js.map +1 -0
- package/dist/cli/commands/setup.js +121 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +24 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin/plugin.d.ts +1 -0
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +1 -0
- package/dist/plugin/plugin.js.map +1 -1
- package/dist/server/remote-tunnel/remote-tunnel-manager.js +9 -9
- package/dist/server/remote-tunnel/remote-tunnel-manager.js.map +1 -1
- package/dist/server/utils.js +6 -6
- package/dist/server/utils.js.map +1 -1
- package/dist/shared/src/execute.d.ts +1 -0
- package/dist/shared/src/execute.d.ts.map +1 -1
- package/dist/shared/src/plugin.d.ts +3 -0
- package/dist/shared/src/plugin.d.ts.map +1 -1
- package/dist/telemetry/types.d.ts +1 -0
- package/dist/telemetry/types.d.ts.map +1 -1
- package/dist/type-generator/index.js +1 -1
- package/dist/type-generator/index.js.map +1 -1
- package/docs/docs/api/appkit/Class.AppKitError/index.html +77 -0
- package/docs/docs/api/appkit/Class.AppKitError.md +154 -0
- package/docs/docs/api/appkit/Class.AuthenticationError/index.html +110 -0
- package/docs/docs/api/appkit/Class.AuthenticationError.md +236 -0
- package/docs/docs/api/appkit/Class.ConfigurationError/index.html +112 -0
- package/docs/docs/api/appkit/Class.ConfigurationError.md +243 -0
- package/docs/docs/api/appkit/Class.ConnectionError/index.html +120 -0
- package/docs/docs/api/appkit/Class.ConnectionError.md +265 -0
- package/docs/docs/api/appkit/Class.ExecutionError/index.html +116 -0
- package/docs/docs/api/appkit/Class.ExecutionError.md +250 -0
- package/docs/docs/api/appkit/Class.InitializationError/index.html +104 -0
- package/docs/docs/api/appkit/Class.InitializationError.md +222 -0
- package/docs/docs/api/appkit/Class.Plugin/index.html +149 -0
- package/docs/docs/api/appkit/Class.Plugin.md +392 -0
- package/docs/docs/api/appkit/Class.ServerError/index.html +108 -0
- package/docs/docs/api/appkit/Class.ServerError.md +229 -0
- package/docs/docs/api/appkit/Class.TunnelError/index.html +108 -0
- package/docs/docs/api/appkit/Class.TunnelError.md +231 -0
- package/docs/docs/api/appkit/Class.ValidationError/index.html +106 -0
- package/docs/docs/api/appkit/Class.ValidationError.md +225 -0
- package/docs/docs/api/appkit/Function.appKitTypesPlugin/index.html +24 -0
- package/docs/docs/api/appkit/Function.appKitTypesPlugin.md +20 -0
- package/docs/docs/api/appkit/Function.createApp/index.html +24 -0
- package/docs/docs/api/appkit/Function.createApp.md +31 -0
- package/docs/docs/api/appkit/Function.isSQLTypeMarker/index.html +25 -0
- package/docs/docs/api/appkit/Function.isSQLTypeMarker.md +32 -0
- package/docs/docs/api/appkit/Interface.BasePluginConfig/index.html +28 -0
- package/docs/docs/api/appkit/Interface.BasePluginConfig.md +37 -0
- package/docs/docs/api/appkit/Interface.CacheConfig/index.html +63 -0
- package/docs/docs/api/appkit/Interface.CacheConfig.md +131 -0
- package/docs/docs/api/appkit/Interface.ITelemetry/index.html +73 -0
- package/docs/docs/api/appkit/Interface.ITelemetry.md +144 -0
- package/docs/docs/api/appkit/Interface.StreamExecutionSettings/index.html +26 -0
- package/docs/docs/api/appkit/Interface.StreamExecutionSettings.md +30 -0
- package/docs/docs/api/appkit/Interface.TelemetryConfig/index.html +32 -0
- package/docs/docs/api/appkit/Interface.TelemetryConfig.md +48 -0
- package/docs/docs/api/appkit/TypeAlias.IAppRouter/index.html +18 -0
- package/docs/docs/api/appkit/TypeAlias.IAppRouter.md +8 -0
- package/docs/docs/api/appkit/Variable.sql/index.html +98 -0
- package/docs/docs/api/appkit/Variable.sql.md +260 -0
- package/docs/docs/api/appkit/index.html +28 -0
- package/docs/docs/api/appkit-ui/data/AreaChart/index.html +29 -0
- package/docs/docs/api/appkit-ui/data/AreaChart.md +79 -0
- package/docs/docs/api/appkit-ui/data/BarChart/index.html +29 -0
- package/docs/docs/api/appkit-ui/data/BarChart.md +74 -0
- package/docs/docs/api/appkit-ui/data/DataTable/index.html +36 -0
- package/docs/docs/api/appkit-ui/data/DataTable.md +69 -0
- package/docs/docs/api/appkit-ui/data/DonutChart/index.html +29 -0
- package/docs/docs/api/appkit-ui/data/DonutChart.md +72 -0
- package/docs/docs/api/appkit-ui/data/HeatmapChart/index.html +35 -0
- package/docs/docs/api/appkit-ui/data/HeatmapChart.md +91 -0
- package/docs/docs/api/appkit-ui/data/LineChart/index.html +29 -0
- package/docs/docs/api/appkit-ui/data/LineChart.md +77 -0
- package/docs/docs/api/appkit-ui/data/PieChart/index.html +29 -0
- package/docs/docs/api/appkit-ui/data/PieChart.md +72 -0
- package/docs/docs/api/appkit-ui/data/RadarChart/index.html +29 -0
- package/docs/docs/api/appkit-ui/data/RadarChart.md +74 -0
- package/docs/docs/api/appkit-ui/data/ScatterChart/index.html +29 -0
- package/docs/docs/api/appkit-ui/data/ScatterChart.md +76 -0
- package/docs/docs/api/appkit-ui/index.html +23 -0
- package/docs/docs/api/appkit-ui/styling/index.html +74 -0
- package/docs/docs/api/appkit-ui/styling.md +81 -0
- package/docs/docs/api/appkit-ui/ui/Accordion/index.html +48 -0
- package/docs/docs/api/appkit-ui/ui/Accordion.md +139 -0
- package/docs/docs/api/appkit-ui/ui/Alert/index.html +41 -0
- package/docs/docs/api/appkit-ui/ui/Alert.md +89 -0
- package/docs/docs/api/appkit-ui/ui/AlertDialog/index.html +97 -0
- package/docs/docs/api/appkit-ui/ui/AlertDialog.md +282 -0
- package/docs/docs/api/appkit-ui/ui/AspectRatio/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/AspectRatio.md +46 -0
- package/docs/docs/api/appkit-ui/ui/Avatar/index.html +41 -0
- package/docs/docs/api/appkit-ui/ui/Avatar.md +90 -0
- package/docs/docs/api/appkit-ui/ui/Badge/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Badge.md +38 -0
- package/docs/docs/api/appkit-ui/ui/Breadcrumb/index.html +69 -0
- package/docs/docs/api/appkit-ui/ui/Breadcrumb.md +193 -0
- package/docs/docs/api/appkit-ui/ui/Button/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Button.md +39 -0
- package/docs/docs/api/appkit-ui/ui/ButtonGroup/index.html +38 -0
- package/docs/docs/api/appkit-ui/ui/ButtonGroup.md +68 -0
- package/docs/docs/api/appkit-ui/ui/Calendar/index.html +34 -0
- package/docs/docs/api/appkit-ui/ui/Calendar.md +154 -0
- package/docs/docs/api/appkit-ui/ui/Card/index.html +69 -0
- package/docs/docs/api/appkit-ui/ui/Card.md +222 -0
- package/docs/docs/api/appkit-ui/ui/Carousel/index.html +55 -0
- package/docs/docs/api/appkit-ui/ui/Carousel.md +152 -0
- package/docs/docs/api/appkit-ui/ui/ChartContainer/index.html +58 -0
- package/docs/docs/api/appkit-ui/ui/ChartContainer.md +343 -0
- package/docs/docs/api/appkit-ui/ui/Checkbox/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Checkbox.md +53 -0
- package/docs/docs/api/appkit-ui/ui/Collapsible/index.html +41 -0
- package/docs/docs/api/appkit-ui/ui/Collapsible.md +125 -0
- package/docs/docs/api/appkit-ui/ui/Command/index.html +83 -0
- package/docs/docs/api/appkit-ui/ui/Command.md +287 -0
- package/docs/docs/api/appkit-ui/ui/ContextMenu/index.html +111 -0
- package/docs/docs/api/appkit-ui/ui/ContextMenu.md +419 -0
- package/docs/docs/api/appkit-ui/ui/Dialog/index.html +90 -0
- package/docs/docs/api/appkit-ui/ui/Dialog.md +285 -0
- package/docs/docs/api/appkit-ui/ui/Drawer/index.html +90 -0
- package/docs/docs/api/appkit-ui/ui/Drawer.md +387 -0
- package/docs/docs/api/appkit-ui/ui/DropdownMenu/index.html +111 -0
- package/docs/docs/api/appkit-ui/ui/DropdownMenu.md +478 -0
- package/docs/docs/api/appkit-ui/ui/Empty/index.html +54 -0
- package/docs/docs/api/appkit-ui/ui/Empty.md +109 -0
- package/docs/docs/api/appkit-ui/ui/Field/index.html +87 -0
- package/docs/docs/api/appkit-ui/ui/Field.md +201 -0
- package/docs/docs/api/appkit-ui/ui/FormControl/index.html +59 -0
- package/docs/docs/api/appkit-ui/ui/FormControl.md +128 -0
- package/docs/docs/api/appkit-ui/ui/HoverCard/index.html +39 -0
- package/docs/docs/api/appkit-ui/ui/HoverCard.md +131 -0
- package/docs/docs/api/appkit-ui/ui/Input/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Input.md +35 -0
- package/docs/docs/api/appkit-ui/ui/InputGroup/index.html +59 -0
- package/docs/docs/api/appkit-ui/ui/InputGroup.md +123 -0
- package/docs/docs/api/appkit-ui/ui/InputOTP/index.html +48 -0
- package/docs/docs/api/appkit-ui/ui/InputOTP.md +124 -0
- package/docs/docs/api/appkit-ui/ui/Item/index.html +78 -0
- package/docs/docs/api/appkit-ui/ui/Item.md +185 -0
- package/docs/docs/api/appkit-ui/ui/Kbd/index.html +30 -0
- package/docs/docs/api/appkit-ui/ui/Kbd.md +39 -0
- package/docs/docs/api/appkit-ui/ui/Label/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Label.md +44 -0
- package/docs/docs/api/appkit-ui/ui/Menubar/index.html +117 -0
- package/docs/docs/api/appkit-ui/ui/Menubar.md +484 -0
- package/docs/docs/api/appkit-ui/ui/NavigationMenu/index.html +76 -0
- package/docs/docs/api/appkit-ui/ui/NavigationMenu.md +338 -0
- package/docs/docs/api/appkit-ui/ui/Pagination/index.html +69 -0
- package/docs/docs/api/appkit-ui/ui/Pagination.md +191 -0
- package/docs/docs/api/appkit-ui/ui/Popover/index.html +45 -0
- package/docs/docs/api/appkit-ui/ui/Popover.md +173 -0
- package/docs/docs/api/appkit-ui/ui/Progress/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Progress.md +51 -0
- package/docs/docs/api/appkit-ui/ui/RadioGroup/index.html +33 -0
- package/docs/docs/api/appkit-ui/ui/RadioGroup.md +83 -0
- package/docs/docs/api/appkit-ui/ui/ResizableHandle/index.html +41 -0
- package/docs/docs/api/appkit-ui/ui/ResizableHandle.md +136 -0
- package/docs/docs/api/appkit-ui/ui/ScrollArea/index.html +34 -0
- package/docs/docs/api/appkit-ui/ui/ScrollArea.md +83 -0
- package/docs/docs/api/appkit-ui/ui/Select/index.html +82 -0
- package/docs/docs/api/appkit-ui/ui/Select.md +267 -0
- package/docs/docs/api/appkit-ui/ui/Separator/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Separator.md +56 -0
- package/docs/docs/api/appkit-ui/ui/Sheet/index.html +76 -0
- package/docs/docs/api/appkit-ui/ui/Sheet.md +236 -0
- package/docs/docs/api/appkit-ui/ui/Sidebar/index.html +183 -0
- package/docs/docs/api/appkit-ui/ui/Sidebar.md +490 -0
- package/docs/docs/api/appkit-ui/ui/Skeleton/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Skeleton.md +43 -0
- package/docs/docs/api/appkit-ui/ui/Slider/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Slider.md +61 -0
- package/docs/docs/api/appkit-ui/ui/Spinner/index.html +24 -0
- package/docs/docs/api/appkit-ui/ui/Spinner.md +22 -0
- package/docs/docs/api/appkit-ui/ui/Switch/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Switch.md +46 -0
- package/docs/docs/api/appkit-ui/ui/Table/index.html +69 -0
- package/docs/docs/api/appkit-ui/ui/Table.md +236 -0
- package/docs/docs/api/appkit-ui/ui/Tabs/index.html +48 -0
- package/docs/docs/api/appkit-ui/ui/Tabs.md +177 -0
- package/docs/docs/api/appkit-ui/ui/Textarea/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Textarea.md +35 -0
- package/docs/docs/api/appkit-ui/ui/Toaster/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Toaster.md +75 -0
- package/docs/docs/api/appkit-ui/ui/Toggle/index.html +27 -0
- package/docs/docs/api/appkit-ui/ui/Toggle.md +48 -0
- package/docs/docs/api/appkit-ui/ui/ToggleGroup/index.html +33 -0
- package/docs/docs/api/appkit-ui/ui/ToggleGroup.md +88 -0
- package/docs/docs/api/appkit-ui/ui/Tooltip/index.html +46 -0
- package/docs/docs/api/appkit-ui/ui/Tooltip.md +134 -0
- package/docs/docs/api/appkit-ui.md +15 -0
- package/docs/docs/api/appkit.md +48 -0
- package/docs/docs/api/index.html +28 -0
- package/docs/docs/api.md +24 -0
- package/docs/docs/app-management/index.html +106 -0
- package/docs/docs/app-management.md +171 -0
- package/docs/docs/architecture/index.html +71 -0
- package/docs/docs/architecture.md +69 -0
- package/docs/docs/category/development/index.html +16 -0
- package/docs/docs/category/development.md +3 -0
- package/docs/docs/configuration/index.html +66 -0
- package/docs/docs/configuration.md +150 -0
- package/docs/docs/core-principles/index.html +38 -0
- package/docs/docs/core-principles.md +31 -0
- package/docs/docs/development/index.html +34 -0
- package/docs/docs/development/llm-guide/index.html +74 -0
- package/docs/docs/development/llm-guide.md +74 -0
- package/docs/docs/development/local-development/index.html +27 -0
- package/docs/docs/development/local-development.md +20 -0
- package/docs/docs/development/project-setup/index.html +69 -0
- package/docs/docs/development/project-setup.md +246 -0
- package/docs/docs/development/remote-bridge/index.html +76 -0
- package/docs/docs/development/remote-bridge.md +80 -0
- package/docs/docs/development/type-generation/index.html +65 -0
- package/docs/docs/development/type-generation.md +110 -0
- package/docs/docs/development.md +21 -0
- package/docs/docs/index.html +58 -0
- package/docs/docs/plugins/index.html +151 -0
- package/docs/docs/plugins.md +313 -0
- package/docs/docs.md +64 -0
- package/llms.txt +121 -1231
- package/package.json +11 -11
- package/scripts/postinstall.js +1 -1
- package/AGENTS.md +0 -1234
- package/bin/appkit-lint.js +0 -129
- package/bin/generate-types.js +0 -27
- package/bin/setup-claude.js +0 -190
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Plugins
|
|
2
|
+
|
|
3
|
+
Plugins are modular extensions that add capabilities to your AppKit application. They follow a defined lifecycle and have access to shared services like caching, telemetry, and streaming.
|
|
4
|
+
|
|
5
|
+
For complete API documentation, see the [`Plugin`](/appkit/docs/api/appkit/Class.Plugin.md) class reference.
|
|
6
|
+
|
|
7
|
+
## Built-in plugins[](#built-in-plugins "Direct link to Built-in plugins")
|
|
8
|
+
|
|
9
|
+
### Server plugin[](#server-plugin "Direct link to Server plugin")
|
|
10
|
+
|
|
11
|
+
Provides HTTP server capabilities with development and production modes.
|
|
12
|
+
|
|
13
|
+
**Key features:**
|
|
14
|
+
|
|
15
|
+
* Express server for REST APIs
|
|
16
|
+
* Vite dev server with hot module reload
|
|
17
|
+
* Static file serving for production
|
|
18
|
+
* Remote tunneling to deployed backends
|
|
19
|
+
|
|
20
|
+
The Server plugin uses the deferred initialization phase to access routes from other plugins.
|
|
21
|
+
|
|
22
|
+
#### What it does[](#what-it-does "Direct link to What it does")
|
|
23
|
+
|
|
24
|
+
* Starts an Express server (default `host=0.0.0.0`, `port=8000`)
|
|
25
|
+
|
|
26
|
+
* Mounts plugin routes under `/api/<pluginName>/...`
|
|
27
|
+
|
|
28
|
+
* Adds `/health` endpoint (returns `{ status: "ok" }`)
|
|
29
|
+
|
|
30
|
+
* Serves frontend:
|
|
31
|
+
|
|
32
|
+
<!-- -->
|
|
33
|
+
|
|
34
|
+
* **Development** (`NODE_ENV=development`): runs a Vite dev server in middleware mode
|
|
35
|
+
* **Production**: auto-detects static frontend directory (checks `dist`, `client/dist`, `build`, `public`, `out`)
|
|
36
|
+
|
|
37
|
+
#### Minimal server example[](#minimal-server-example "Direct link to Minimal server example")
|
|
38
|
+
|
|
39
|
+
The smallest valid AppKit server:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// server/index.ts
|
|
43
|
+
import { createApp, server } from "@databricks/appkit";
|
|
44
|
+
|
|
45
|
+
await createApp({
|
|
46
|
+
plugins: [server()],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### Manual server start example[](#manual-server-start-example "Direct link to Manual server start example")
|
|
52
|
+
|
|
53
|
+
When you need to extend Express with custom routes:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { createApp, server } from "@databricks/appkit";
|
|
57
|
+
|
|
58
|
+
const appkit = await createApp({
|
|
59
|
+
plugins: [server({ autoStart: false })],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
appkit.server.extend((app) => {
|
|
63
|
+
app.get("/custom", (_req, res) => res.json({ ok: true }));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await appkit.server.start();
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Configuration options[](#configuration-options "Direct link to Configuration options")
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { createApp, server } from "@databricks/appkit";
|
|
74
|
+
|
|
75
|
+
await createApp({
|
|
76
|
+
plugins: [
|
|
77
|
+
server({
|
|
78
|
+
port: 8000, // default: Number(process.env.DATABRICKS_APP_PORT) || 8000
|
|
79
|
+
host: "0.0.0.0", // default: process.env.FLASK_RUN_HOST || "0.0.0.0"
|
|
80
|
+
autoStart: true, // default: true
|
|
81
|
+
staticPath: "dist", // optional: force a specific static directory
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Analytics plugin[](#analytics-plugin "Direct link to Analytics plugin")
|
|
89
|
+
|
|
90
|
+
Enables SQL query execution against Databricks SQL Warehouses.
|
|
91
|
+
|
|
92
|
+
**Key features:**
|
|
93
|
+
|
|
94
|
+
* File-based SQL queries with automatic type generation
|
|
95
|
+
* Parameterized queries with type-safe [SQL helpers](/appkit/docs/api/appkit/Variable.sql.md)
|
|
96
|
+
* JSON and Arrow format support
|
|
97
|
+
* Built-in caching and retry logic
|
|
98
|
+
* Server-Sent Events (SSE) streaming
|
|
99
|
+
|
|
100
|
+
#### Basic usage[](#basic-usage "Direct link to Basic usage")
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { analytics, createApp, server } from "@databricks/appkit";
|
|
104
|
+
|
|
105
|
+
await createApp({
|
|
106
|
+
plugins: [server(), analytics({})],
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Where queries live[](#where-queries-live "Direct link to Where queries live")
|
|
112
|
+
|
|
113
|
+
* Put `.sql` files in `config/queries/`
|
|
114
|
+
* Query key is the filename without `.sql` (e.g. `spend_summary.sql` → `"spend_summary"`)
|
|
115
|
+
|
|
116
|
+
#### SQL parameters[](#sql-parameters "Direct link to SQL parameters")
|
|
117
|
+
|
|
118
|
+
Use `:paramName` placeholders and optionally annotate parameter types using SQL comments:
|
|
119
|
+
|
|
120
|
+
```sql
|
|
121
|
+
-- @param startDate DATE
|
|
122
|
+
-- @param endDate DATE
|
|
123
|
+
-- @param limit NUMERIC
|
|
124
|
+
SELECT ...
|
|
125
|
+
WHERE usage_date BETWEEN :startDate AND :endDate
|
|
126
|
+
LIMIT :limit
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Supported `-- @param` types** (case-insensitive):
|
|
131
|
+
|
|
132
|
+
* `STRING`, `NUMERIC`, `BOOLEAN`, `DATE`, `TIMESTAMP`, `BINARY`
|
|
133
|
+
|
|
134
|
+
#### Server-injected parameters[](#server-injected-parameters "Direct link to Server-injected parameters")
|
|
135
|
+
|
|
136
|
+
`:workspaceId` is **injected by the server** and **must not** be annotated:
|
|
137
|
+
|
|
138
|
+
```sql
|
|
139
|
+
WHERE workspace_id = :workspaceId
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### HTTP endpoints[](#http-endpoints "Direct link to HTTP endpoints")
|
|
144
|
+
|
|
145
|
+
The analytics plugin exposes these endpoints (mounted under `/api/analytics`):
|
|
146
|
+
|
|
147
|
+
* `POST /api/analytics/query/:query_key`
|
|
148
|
+
* `POST /api/analytics/users/me/query/:query_key`
|
|
149
|
+
* `GET /api/analytics/arrow-result/:jobId`
|
|
150
|
+
* `GET /api/analytics/users/me/arrow-result/:jobId`
|
|
151
|
+
|
|
152
|
+
#### Format options[](#format-options "Direct link to Format options")
|
|
153
|
+
|
|
154
|
+
* `format: "JSON"` (default) returns JSON rows
|
|
155
|
+
* `format: "ARROW"` returns an Arrow "statement\_id" payload over SSE, then the client fetches binary Arrow from `/api/analytics/arrow-result/:jobId`
|
|
156
|
+
|
|
157
|
+
### Execution context and `asUser(req)`[](#execution-context-and-asuserreq "Direct link to execution-context-and-asuserreq")
|
|
158
|
+
|
|
159
|
+
AppKit manages Databricks authentication via two contexts:
|
|
160
|
+
|
|
161
|
+
* **ServiceContext** (singleton): Initialized at app startup with service principal credentials
|
|
162
|
+
* **ExecutionContext**: Determined at runtime - either service principal or user context
|
|
163
|
+
|
|
164
|
+
#### Headers for user context[](#headers-for-user-context "Direct link to Headers for user context")
|
|
165
|
+
|
|
166
|
+
* `x-forwarded-user`: required in production; identifies the user
|
|
167
|
+
* `x-forwarded-access-token`: required for user token passthrough
|
|
168
|
+
|
|
169
|
+
#### Using `asUser(req)` for user-scoped operations[](#using-asuserreq-for-user-scoped-operations "Direct link to using-asuserreq-for-user-scoped-operations")
|
|
170
|
+
|
|
171
|
+
The `asUser(req)` pattern allows plugins to execute operations using the requesting user's credentials:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// In a custom plugin route handler
|
|
175
|
+
router.post("/users/me/data", async (req, res) => {
|
|
176
|
+
// Execute as the user (uses their Databricks permissions)
|
|
177
|
+
const result = await this.asUser(req).query("SELECT ...");
|
|
178
|
+
res.json(result);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Service principal execution (default)
|
|
182
|
+
router.post("/system/data", async (req, res) => {
|
|
183
|
+
const result = await this.query("SELECT ...");
|
|
184
|
+
res.json(result);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### Context helper functions[](#context-helper-functions "Direct link to Context helper functions")
|
|
190
|
+
|
|
191
|
+
Exported from `@databricks/appkit`:
|
|
192
|
+
|
|
193
|
+
* `getCurrentUserId()`: Returns user ID in user context, service user ID otherwise
|
|
194
|
+
* `getWorkspaceClient()`: Returns the appropriate WorkspaceClient for current context
|
|
195
|
+
* `getWarehouseId()`: `Promise<string>` (from `DATABRICKS_WAREHOUSE_ID` or auto-selected in dev)
|
|
196
|
+
* `getWorkspaceId()`: `Promise<string>` (from `DATABRICKS_WORKSPACE_ID` or fetched)
|
|
197
|
+
* `isInUserContext()`: Returns `true` if currently executing in user context
|
|
198
|
+
|
|
199
|
+
#### Development mode behavior[](#development-mode-behavior "Direct link to Development mode behavior")
|
|
200
|
+
|
|
201
|
+
In local development (`NODE_ENV=development`), if `asUser(req)` is called without a user token, it logs a warning and falls back to the service principal.
|
|
202
|
+
|
|
203
|
+
## Using plugins[](#using-plugins "Direct link to Using plugins")
|
|
204
|
+
|
|
205
|
+
Configure plugins when creating your AppKit instance:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { createApp, server, analytics } from "@databricks/app-kit";
|
|
209
|
+
|
|
210
|
+
const AppKit = await createApp({
|
|
211
|
+
plugins: [
|
|
212
|
+
server({ port: 8000 }),
|
|
213
|
+
analytics(),
|
|
214
|
+
],
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
For complete configuration options, see [`createApp`](/appkit/docs/api/appkit/Function.createApp.md).
|
|
220
|
+
|
|
221
|
+
## Creating custom plugins[](#creating-custom-plugins "Direct link to Creating custom plugins")
|
|
222
|
+
|
|
223
|
+
If you need custom API routes or background logic, implement an AppKit plugin.
|
|
224
|
+
|
|
225
|
+
### Basic plugin example[](#basic-plugin-example "Direct link to Basic plugin example")
|
|
226
|
+
|
|
227
|
+
Extend the [`Plugin`](/appkit/docs/api/appkit/Class.Plugin.md) class and export with `toPlugin()`:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
import { Plugin, toPlugin } from "@databricks/appkit";
|
|
231
|
+
import type express from "express";
|
|
232
|
+
|
|
233
|
+
class MyPlugin extends Plugin {
|
|
234
|
+
name = "myPlugin";
|
|
235
|
+
envVars = []; // list required env vars here
|
|
236
|
+
|
|
237
|
+
injectRoutes(router: express.Router) {
|
|
238
|
+
this.route(router, {
|
|
239
|
+
name: "hello",
|
|
240
|
+
method: "get",
|
|
241
|
+
path: "/hello",
|
|
242
|
+
handler: async (_req, res) => {
|
|
243
|
+
res.json({ ok: true });
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export const myPlugin = toPlugin<typeof MyPlugin, Record<string, never>, "myPlugin">(
|
|
250
|
+
MyPlugin,
|
|
251
|
+
"myPlugin",
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Key extension points[](#key-extension-points "Direct link to Key extension points")
|
|
257
|
+
|
|
258
|
+
* **Route injection**: Implement `injectRoutes()` to add custom endpoints using [`IAppRouter`](/appkit/docs/api/appkit/TypeAlias.IAppRouter.md)
|
|
259
|
+
|
|
260
|
+
* **Lifecycle hooks**: Override `setup()`, `shutdown()`, and `validateEnv()` methods
|
|
261
|
+
|
|
262
|
+
* **Shared services**:
|
|
263
|
+
|
|
264
|
+
<!-- -->
|
|
265
|
+
|
|
266
|
+
* **Cache management**: Access the cache service via `this.cache`. See [`CacheConfig`](/appkit/docs/api/appkit/Interface.CacheConfig.md) for configuration.
|
|
267
|
+
* **Telemetry**: Instrument your plugin with traces and metrics via `this.telemetry`. See [`ITelemetry`](/appkit/docs/api/appkit/Interface.ITelemetry.md).
|
|
268
|
+
|
|
269
|
+
* **Execution interceptors**: Use `execute()` and `executeStream()` with [`StreamExecutionSettings`](/appkit/docs/api/appkit/Interface.StreamExecutionSettings.md)
|
|
270
|
+
|
|
271
|
+
See the [`Plugin`](/appkit/docs/api/appkit/Class.Plugin.md) API reference for complete documentation.
|
|
272
|
+
|
|
273
|
+
## Caching[](#caching "Direct link to Caching")
|
|
274
|
+
|
|
275
|
+
AppKit provides both global and plugin-level caching capabilities.
|
|
276
|
+
|
|
277
|
+
### Global cache configuration[](#global-cache-configuration "Direct link to Global cache configuration")
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
await createApp({
|
|
281
|
+
plugins: [server(), analytics({})],
|
|
282
|
+
cache: {
|
|
283
|
+
enabled: true,
|
|
284
|
+
ttl: 3600, // seconds
|
|
285
|
+
strictPersistence: false,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Storage auto-selects **Lakebase persistent cache when healthy**, otherwise falls back to in-memory.
|
|
292
|
+
|
|
293
|
+
### Plugin-level caching[](#plugin-level-caching "Direct link to Plugin-level caching")
|
|
294
|
+
|
|
295
|
+
Inside a Plugin subclass:
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
const value = await this.cache.getOrExecute(
|
|
299
|
+
["myPlugin", "data", userId],
|
|
300
|
+
async () => expensiveWork(),
|
|
301
|
+
userKey,
|
|
302
|
+
{ ttl: 300 },
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Plugin phases[](#plugin-phases "Direct link to Plugin phases")
|
|
308
|
+
|
|
309
|
+
Plugins initialize in three phases:
|
|
310
|
+
|
|
311
|
+
* **Core**: Reserved for framework-level plugins. Initializes first.
|
|
312
|
+
* **Normal**: Default phase for application plugins. Initializes after core.
|
|
313
|
+
* **Deferred**: Initializes last with access to other plugin instances via `config.plugins`. Use when your plugin depends on other plugins (e.g., Server Plugin).
|
package/docs/docs.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
Learn how to get started with AppKit.
|
|
4
|
+
|
|
5
|
+
<!-- -->
|
|
6
|
+
|
|
7
|
+
## Introduction[](#introduction "Direct link to Introduction")
|
|
8
|
+
|
|
9
|
+
AppKit is a TypeScript SDK for building production-ready Databricks applications with a plugin-based architecture. It provides opinionated defaults, built-in observability, and seamless integration with Databricks services.
|
|
10
|
+
|
|
11
|
+
AppKit simplifies building data applications on Databricks by providing:
|
|
12
|
+
|
|
13
|
+
* **Plugin architecture**: Modular design with built-in server and analytics plugins
|
|
14
|
+
* **Type safety**: End-to-end TypeScript with automatic query type generation
|
|
15
|
+
* **Production-ready features**: Built-in caching, telemetry, retry logic, and error handling
|
|
16
|
+
* **Developer experience**: Remote hot reload, file-based queries, optimized for AI-assisted development
|
|
17
|
+
* **Databricks native**: Seamless integration with SQL Warehouses, Unity Catalog, and other workspace resources
|
|
18
|
+
|
|
19
|
+
## Prerequisites[](#prerequisites "Direct link to Prerequisites")
|
|
20
|
+
|
|
21
|
+
* [Node.js](https://nodejs.org) environment
|
|
22
|
+
* Databricks CLI: install and configure it according to the [official tutorial](https://docs.databricks.com/aws/en/dev-tools/cli/tutorial).
|
|
23
|
+
|
|
24
|
+
## Quick start[](#quick-start "Direct link to Quick start")
|
|
25
|
+
|
|
26
|
+
Learn how to create and deploy a sample Databricks application that uses AppKit with the Databricks CLI.
|
|
27
|
+
|
|
28
|
+
### Bootstrap a new Databricks app[](#bootstrap-a-new-databricks-app "Direct link to Bootstrap a new Databricks app")
|
|
29
|
+
|
|
30
|
+
Run the following command to bootstrap the new Databricks app with AppKit:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
databricks apps init
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Follow the prompts to bootstrap the app codebase in the current working directory.
|
|
38
|
+
|
|
39
|
+
The command will guide you through the process of:
|
|
40
|
+
|
|
41
|
+
* creating a new Databricks app
|
|
42
|
+
* scaffolding the app codebase with selected features
|
|
43
|
+
* installing dependencies
|
|
44
|
+
* (optionally) deploying the app to Databricks
|
|
45
|
+
* (optionally) running the app in development mode
|
|
46
|
+
|
|
47
|
+
Learn more about the various [development flows](/appkit/docs/development.md) available with AppKit.
|
|
48
|
+
|
|
49
|
+
### Deploy the app to Databricks[](#deploy-the-app-to-databricks "Direct link to Deploy the app to Databricks")
|
|
50
|
+
|
|
51
|
+
Run the following command to deploy the app to Databricks:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
databricks apps deploy
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This deploys the sample app to Databricks.
|
|
59
|
+
|
|
60
|
+
## Next steps[](#next-steps "Direct link to Next steps")
|
|
61
|
+
|
|
62
|
+
* **[App management](/appkit/docs/app-management.md)**: Manage your AppKit application throughout its lifecycle using the Databricks CLI
|
|
63
|
+
* **[API reference](/appkit/docs/api/appkit.md)**: Explore the complete API documentation
|
|
64
|
+
* **[Core concepts](/appkit/docs/core-principles.md)**: Learn about AppKit's design principles and architecture
|