Skip to content

Commit 0fdddaf

Browse files
committed
feat(appkit): introduce workspace-client wrapper over the Databricks SDK
Add packages/appkit/src/workspace-client/ — a facade over the legacy @databricks/sdk-experimental client that mirrors the modular Databricks SDK's multi-client shape. This prepares the library for an incremental, per-service migration to the modular SDK without migrating anything yet. - legacy.ts is the ONLY module importing @databricks/sdk-experimental; it constructs the client and re-exports the SDK symbols AppKit uses. - The WorkspaceClient facade exposes per-service accessors (files, warehouses, genie, jobs, statementExecution, servingEndpoints, currentUser, config, apiClient), each legacy-typed and delegating to the underlying client. Migrating a service later is a localized swap: one getter + its accessor type + one connector. - createWorkspaceClient() replaces every `new WorkspaceClient(...)` site (runtime + build-time type-generator); toLegacyWorkspaceClient() is the escape hatch for @databricks/lakebase. - createApp({ client }) and the public index now expose the wrapper type instead of the raw SDK client. - A Biome noRestrictedImports boundary rule forbids importing @databricks/sdk-experimental outside workspace-client/, keeping the seam enforceable. Tests mock the wrapper rather than the SDK. Time is sourced off the SDK namespace (SDK.Time ?? SDK.default.Time) because the SDK's CommonJS `Time` export is a getter that defeats Node's static ESM named-export detection — a direct `export { Time }` throws at link time. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
1 parent 92cb8bb commit 0fdddaf

81 files changed

Lines changed: 886 additions & 212 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/dev-playground/server/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "reflect-metadata";
22
import {
33
analytics,
44
createApp,
5+
createWorkspaceClient,
56
type FilePolicy,
67
files,
78
genie,
@@ -12,14 +13,13 @@ import {
1213
WRITE_ACTIONS,
1314
} from "@databricks/appkit";
1415
import { agents, createAgent, tool } from "@databricks/appkit/beta";
15-
import { WorkspaceClient } from "@databricks/sdk-experimental";
1616
import { z } from "zod";
1717
import { lakebaseExamples } from "./lakebase-examples-plugin";
1818
import { reconnect } from "./reconnect-plugin";
1919
import { telemetryExamples } from "./telemetry-example-plugin";
2020

2121
function createMockClient() {
22-
const client = new WorkspaceClient({
22+
const client = createWorkspaceClient({
2323
host: "http://localhost",
2424
token: "e2e",
2525
authType: "pat",

biome.json

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@
4141
},
4242
"security": {
4343
"noDangerouslySetInnerHtml": "off"
44+
},
45+
"style": {
46+
"noRestrictedImports": {
47+
"level": "error",
48+
"options": {
49+
"patterns": [
50+
{
51+
"group": [
52+
"@databricks/sdk-experimental",
53+
"@databricks/sdk-experimental/**"
54+
],
55+
"message": "Import the Databricks SDK only through the wrapper in packages/appkit/src/workspace-client. Add a re-export there if you need a new symbol."
56+
}
57+
]
58+
}
59+
}
4460
}
4561
}
4662
},
@@ -56,5 +72,20 @@
5672
"organizeImports": "on"
5773
}
5874
}
59-
}
75+
},
76+
"overrides": [
77+
{
78+
"includes": [
79+
"packages/appkit/src/workspace-client/**",
80+
"packages/lakebase/**"
81+
],
82+
"linter": {
83+
"rules": {
84+
"style": {
85+
"noRestrictedImports": "off"
86+
}
87+
}
88+
}
89+
}
90+
]
6091
}

docs/docs/api/appkit/Class.DatabricksAdapter.md

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Function.createApp.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Function.createWorkspaceClient.md

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Interface.WorkspaceClient.md

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/Interface.WorkspaceClientOptions.md

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/index.md

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs/api/appkit/typedoc-sidebar.ts

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/appkit/src/agents/databricks.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
} from "shared";
88
import { stream as servingStream } from "../connectors/serving/client";
99
import { APPKIT_USER_AGENT, getClientOptions } from "../context/client-options";
10+
import { createWorkspaceClient } from "../workspace-client";
1011

1112
/** Default cap for a single incomplete SSE line tail (DoS guard). */
1213
const DEFAULT_MAX_SSE_LINE_CHARS = 1024 * 1024;
@@ -246,12 +247,11 @@ interface DeltaToolCall {
246247
*
247248
* @example Using the factory (recommended)
248249
* ```ts
249-
* import { createApp, createAgent, agents } from "@databricks/appkit";
250+
* import { createApp, createAgent, agents, createWorkspaceClient } from "@databricks/appkit";
250251
* import { DatabricksAdapter } from "@databricks/appkit/beta";
251-
* import { WorkspaceClient } from "@databricks/sdk-experimental";
252252
*
253253
* const adapter = DatabricksAdapter.fromServingEndpoint({
254-
* workspaceClient: new WorkspaceClient({}),
254+
* workspaceClient: createWorkspaceClient(),
255255
* endpointName: "my-endpoint",
256256
* });
257257
*
@@ -405,11 +405,9 @@ export class DatabricksAdapter implements AgentAdapter {
405405
let workspaceClient: WorkspaceClientLike | undefined =
406406
options?.workspaceClient;
407407
if (!workspaceClient) {
408-
const sdk = await import("@databricks/sdk-experimental");
409-
workspaceClient = new sdk.WorkspaceClient(
410-
{},
411-
getClientOptions(),
412-
) as unknown as WorkspaceClientLike;
408+
workspaceClient = createWorkspaceClient({
409+
clientOptions: getClientOptions(),
410+
}) as unknown as WorkspaceClientLike;
413411
}
414412

415413
return DatabricksAdapter.fromServingEndpoint({

0 commit comments

Comments
 (0)