From 6dcaa7e41992fac5e57acb4c0779c32b8bee1619 Mon Sep 17 00:00:00 2001 From: MarioCadenas Date: Thu, 13 Aug 2026 16:54:09 +0200 Subject: [PATCH 1/3] refactor(shared): relocate the Databricks SDK facade to shared MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the workspace-client facade from packages/appkit/src/workspace-client to packages/shared/src/workspace-client so both appkit and the CLI (which lives in shared) reach the SDK through one sanctioned import site. - appkit's workspace-client becomes a thin re-export from shared/workspace-client; its ~47 importers are unchanged. - biome noRestrictedImports allow-list repoints to the new location. - shared gains the @databricks/sdk-experimental dep and a ./workspace-client export (tsdown entry added so it's emitted independently); appkit drops the now-unused direct SDK dep. - Adds a `profile` option to WorkspaceClientOptions. Pure relocation — no behavior change beyond the additive `profile` option. Extracted from the registry-CLI work so it can land on its own. Signed-off-by: MarioCadenas --- biome.json | 4 +-- packages/appkit/package.json | 1 - packages/appkit/src/workspace-client/index.ts | 22 +++++++------- packages/shared/package.json | 8 ++++- .../src/workspace-client/client.ts | 0 .../src/workspace-client/errors.ts | 0 .../src/workspace-client/factory.ts | 0 packages/shared/src/workspace-client/index.ts | 30 +++++++++++++++++++ .../src/workspace-client/legacy.ts | 6 +++- .../src/workspace-client/tests/legacy.test.ts | 0 .../src/workspace-client/types.ts | 0 packages/shared/tsdown.config.ts | 2 +- pnpm-lock.yaml | 6 ++-- 13 files changed, 58 insertions(+), 21 deletions(-) rename packages/{appkit => shared}/src/workspace-client/client.ts (100%) rename packages/{appkit => shared}/src/workspace-client/errors.ts (100%) rename packages/{appkit => shared}/src/workspace-client/factory.ts (100%) create mode 100644 packages/shared/src/workspace-client/index.ts rename packages/{appkit => shared}/src/workspace-client/legacy.ts (96%) rename packages/{appkit => shared}/src/workspace-client/tests/legacy.test.ts (100%) rename packages/{appkit => shared}/src/workspace-client/types.ts (100%) diff --git a/biome.json b/biome.json index 826b75319..d0e60cae8 100644 --- a/biome.json +++ b/biome.json @@ -53,7 +53,7 @@ "@databricks/sdk-experimental", "@databricks/sdk-experimental/**" ], - "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." + "message": "Import the Databricks SDK only through the wrapper in packages/shared/src/workspace-client. Add a re-export there if you need a new symbol." } ] } @@ -77,7 +77,7 @@ "overrides": [ { "includes": [ - "packages/appkit/src/workspace-client/**", + "packages/shared/src/workspace-client/**", "packages/lakebase/**" ], "linter": { diff --git a/packages/appkit/package.json b/packages/appkit/package.json index 7bc8e25a1..1f0869209 100644 --- a/packages/appkit/package.json +++ b/packages/appkit/package.json @@ -61,7 +61,6 @@ "dependencies": { "@ast-grep/napi": "0.37.0", "@databricks/lakebase": "workspace:*", - "@databricks/sdk-experimental": "0.17.0", "@opentelemetry/api": "1.9.0", "@opentelemetry/api-logs": "0.219.0", "@opentelemetry/auto-instrumentations-node": "0.77.0", diff --git a/packages/appkit/src/workspace-client/index.ts b/packages/appkit/src/workspace-client/index.ts index 152e8080f..8ecc9114d 100644 --- a/packages/appkit/src/workspace-client/index.ts +++ b/packages/appkit/src/workspace-client/index.ts @@ -4,26 +4,24 @@ * to `./legacy.ts` so services can migrate to the modular SDK incrementally * behind a stable facade. */ -export { ApiError } from "./errors"; -export { createWorkspaceClient } from "./factory"; + export type { CancellationToken, ClientOptions, + files, GenieMessage, + jobs, + serving, + sql, Waiter, + WorkspaceClient, WorkspaceClientOptions, -} from "./legacy"; -// SDK value + type re-exports so AppKit modules import them from the wrapper. +} from "shared/workspace-client"; export { + ApiError, ConfigError, Context, + createWorkspaceClient, Time, TimeUnits, -} from "./legacy"; -export type { - files, - jobs, - serving, - sql, - WorkspaceClient, -} from "./types"; +} from "shared/workspace-client"; diff --git a/packages/shared/package.json b/packages/shared/package.json index e155769ae..ef5a1c7b5 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -15,6 +15,10 @@ "development": "./src/cli/index.ts", "default": "./dist/cli/index.js" }, + "./workspace-client": { + "development": "./src/workspace-client/index.ts", + "default": "./dist/workspace-client/index.js" + }, "./package.json": "./package.json" }, "scripts": { @@ -36,13 +40,15 @@ "exports": { ".": "./dist/index.js", "./cli": "./dist/cli/index.js", + "./workspace-client": "./dist/workspace-client/index.js", "./package.json": "./package.json" } }, "dependencies": { "@ast-grep/napi": "0.37.0", - "@standard-schema/spec": "1.1.0", "@clack/prompts": "1.0.1", + "@databricks/sdk-experimental": "0.17.0", + "@standard-schema/spec": "1.1.0", "commander": "12.1.0", "dotenv": "16.6.1", "js-yaml": "4.2.0", diff --git a/packages/appkit/src/workspace-client/client.ts b/packages/shared/src/workspace-client/client.ts similarity index 100% rename from packages/appkit/src/workspace-client/client.ts rename to packages/shared/src/workspace-client/client.ts diff --git a/packages/appkit/src/workspace-client/errors.ts b/packages/shared/src/workspace-client/errors.ts similarity index 100% rename from packages/appkit/src/workspace-client/errors.ts rename to packages/shared/src/workspace-client/errors.ts diff --git a/packages/appkit/src/workspace-client/factory.ts b/packages/shared/src/workspace-client/factory.ts similarity index 100% rename from packages/appkit/src/workspace-client/factory.ts rename to packages/shared/src/workspace-client/factory.ts diff --git a/packages/shared/src/workspace-client/index.ts b/packages/shared/src/workspace-client/index.ts new file mode 100644 index 000000000..7645328e2 --- /dev/null +++ b/packages/shared/src/workspace-client/index.ts @@ -0,0 +1,30 @@ +/** + * AppKit workspace-client wrapper — the single entry point every AppKit module + * uses to reach a Databricks SDK client. Isolates `@databricks/sdk-experimental` + * to `./legacy.ts` so services can migrate to the modular SDK incrementally + * behind a stable facade. + */ +export { ApiError } from "./errors"; +export { createWorkspaceClient } from "./factory"; +export type { + CancellationToken, + ClientOptions, + GenieMessage, + LegacyWorkspaceClient, + Waiter, + WorkspaceClientOptions, +} from "./legacy"; +// SDK value + type re-exports so AppKit modules import them from the wrapper. +export { + ConfigError, + Context, + Time, + TimeUnits, +} from "./legacy"; +export type { + files, + jobs, + serving, + sql, + WorkspaceClient, +} from "./types"; diff --git a/packages/appkit/src/workspace-client/legacy.ts b/packages/shared/src/workspace-client/legacy.ts similarity index 96% rename from packages/appkit/src/workspace-client/legacy.ts rename to packages/shared/src/workspace-client/legacy.ts index b53f9157d..b8f467f4e 100644 --- a/packages/appkit/src/workspace-client/legacy.ts +++ b/packages/shared/src/workspace-client/legacy.ts @@ -29,6 +29,8 @@ export type LegacyWorkspaceClient = SdkWorkspaceClient; export interface WorkspaceClientOptions { /** Databricks host, e.g. https://my-workspace.cloud.databricks.com. Defaults to DATABRICKS_HOST / profile resolution. */ host?: string; + /** `~/.databrickscfg` profile name. Used when no host/token is provided. */ + profile?: string; /** Bearer token. When set, `authType` defaults to "pat". */ token?: string; /** Authentication strategy passed to the legacy client. */ @@ -60,7 +62,9 @@ export function buildLegacyWorkspaceClient( ? { host: opts.host, token: opts.token, authType: opts.authType ?? "pat" } : opts.host ? { host: opts.host } - : {}; + : opts.profile + ? { profile: opts.profile } + : {}; return new SdkWorkspaceClientCtor(cfg, opts.clientOptions); } diff --git a/packages/appkit/src/workspace-client/tests/legacy.test.ts b/packages/shared/src/workspace-client/tests/legacy.test.ts similarity index 100% rename from packages/appkit/src/workspace-client/tests/legacy.test.ts rename to packages/shared/src/workspace-client/tests/legacy.test.ts diff --git a/packages/appkit/src/workspace-client/types.ts b/packages/shared/src/workspace-client/types.ts similarity index 100% rename from packages/appkit/src/workspace-client/types.ts rename to packages/shared/src/workspace-client/types.ts diff --git a/packages/shared/tsdown.config.ts b/packages/shared/tsdown.config.ts index 9db6274a7..96ab2f226 100644 --- a/packages/shared/tsdown.config.ts +++ b/packages/shared/tsdown.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from "tsdown"; export default defineConfig({ name: "shared", - entry: ["src/index.ts", "src/cli/index.ts"], + entry: ["src/index.ts", "src/cli/index.ts", "src/workspace-client/index.ts"], outDir: "dist", minify: false, format: "esm", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c2eeca07..86f24f334 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -255,9 +255,6 @@ importers: '@databricks/lakebase': specifier: workspace:* version: link:../lakebase - '@databricks/sdk-experimental': - specifier: 0.17.0 - version: 0.17.0 '@opentelemetry/api': specifier: 1.9.0 version: 1.9.0 @@ -561,6 +558,9 @@ importers: '@clack/prompts': specifier: 1.0.1 version: 1.0.1 + '@databricks/sdk-experimental': + specifier: 0.17.0 + version: 0.17.0 '@standard-schema/spec': specifier: 1.1.0 version: 1.1.0 From e9b0a26ed6e6f6d5dd11133cb7033b0764d77ab2 Mon Sep 17 00:00:00 2001 From: MarioCadenas Date: Thu, 13 Aug 2026 18:16:29 +0200 Subject: [PATCH 2/3] fix(appkit): bundle workspace-client via the shared root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The workspace-client facade re-exported runtime values from the `shared/workspace-client` subpath. tsdown resolves that subpath export to shared's built dist and, under unbundle, leaves it as a bare `shared/workspace-client` import; dist-appkit then drops the `shared` dependency, so the published tarball fails with ERR_MODULE_NOT_FOUND at `appkit generate-types`. Route the values through the `shared` root instead (the import style the bundler inlines). Only values move to the root — the SDK `sql` type would collide with the `sql` query helper from ./sql, so workspace-client types stay on the subpath (type-only, no runtime cost). Signed-off-by: MarioCadenas --- packages/appkit/src/workspace-client/index.ts | 16 ++++++++-------- packages/shared/src/index.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/appkit/src/workspace-client/index.ts b/packages/appkit/src/workspace-client/index.ts index 8ecc9114d..581cb79a8 100644 --- a/packages/appkit/src/workspace-client/index.ts +++ b/packages/appkit/src/workspace-client/index.ts @@ -5,6 +5,14 @@ * behind a stable facade. */ +export { + ApiError, + ConfigError, + Context, + createWorkspaceClient, + Time, + TimeUnits, +} from "shared"; export type { CancellationToken, ClientOptions, @@ -17,11 +25,3 @@ export type { WorkspaceClient, WorkspaceClientOptions, } from "shared/workspace-client"; -export { - ApiError, - ConfigError, - Context, - createWorkspaceClient, - Time, - TimeUnits, -} from "shared/workspace-client"; diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index e1dfb7ac6..df3cbdd81 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -8,3 +8,16 @@ export * from "./plugin"; export * from "./sql"; export * from "./sse/analytics"; export * from "./tunnel"; +// Re-export the workspace-client's runtime *values* from the root so AppKit +// (and other consumers) reach them via `shared` — the import style the bundler +// inlines. Only values: the SDK `sql` type would collide with the `sql` query +// helper from `./sql`, so workspace-client types stay on `shared/workspace-client` +// (type-only imports carry no runtime cost). +export { + ApiError, + ConfigError, + Context, + createWorkspaceClient, + Time, + TimeUnits, +} from "./workspace-client"; From 62cc5cd8d969767d46c2c31b77f1608a372801f9 Mon Sep 17 00:00:00 2001 From: MarioCadenas Date: Thu, 13 Aug 2026 18:44:00 +0200 Subject: [PATCH 3/3] fix(docs): stub node builtins in the docs client bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Routing the workspace-client values through the `shared` root pulls @databricks/sdk-experimental (a Node-only SDK) into shared's export graph, so the docs' webpack client build failed trying to bundle fs/crypto/stream/etc. appkit is a Node package and the docs only reference its API — they never run the SDK in the browser — so stub every Node builtin via resolve.fallback and strip the node: scheme prefix. fallback only triggers on unresolvable modules, so the Node-target server bundle is unaffected. Signed-off-by: MarioCadenas --- docs/docusaurus.config.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/docusaurus.config.ts b/docs/docusaurus.config.ts index a4386ab8c..9a890662c 100644 --- a/docs/docusaurus.config.ts +++ b/docs/docusaurus.config.ts @@ -1,3 +1,4 @@ +import { builtinModules } from "node:module"; import path from "node:path"; import type * as Preset from "@docusaurus/preset-classic"; import type { Config } from "@docusaurus/types"; @@ -5,12 +6,22 @@ import type { PluginOptions } from "@signalwire/docusaurus-plugin-llms-txt/publi import { themes as prismThemes } from "prism-react-renderer"; import webpack from "webpack"; +// appkit is a Node/server package; the docs only reference its API (they never +// execute the SDK in the browser). Stub every Node built-in for the client +// bundle so webpack doesn't try to bundle `@databricks/sdk-experimental`'s +// Node deps (fs, crypto, stream, …). `fallback` only triggers when a module is +// unresolvable, so it's a no-op for the Node-target server bundle. +const nodeBuiltinFallbacks = Object.fromEntries( + builtinModules.map((m) => [m, false]), +) as Record; + function appKitAliasPlugin() { return { name: "appkit-aliases", configureWebpack() { return { resolve: { + fallback: nodeBuiltinFallbacks, alias: { "@": path.resolve(__dirname, "../packages/appkit-ui/src"), shared: path.resolve(__dirname, "../packages/shared/src"), @@ -34,6 +45,11 @@ function appKitAliasPlugin() { "import.meta.env.DEV": JSON.stringify(false), "import.meta.hot": JSON.stringify(undefined), }), + // Rewrite `node:fs` → `fs` so scheme imports fall through to the + // built-in fallbacks above instead of erroring as unhandled schemes. + new webpack.NormalModuleReplacementPlugin(/^node:/, (resource) => { + resource.request = resource.request.replace(/^node:/, ""); + }), ], }; },