Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@databricks/sdk-postgres",
"@databricks/sdk-modelserving",
"@databricks/sdk-uc-tables",
"@databricks/sdk-uc-volumes",
"@databricks/sdk-vectorsearch",
"@databricks/sdk-options",
"@databricks/sdk-scim",
Expand Down
1 change: 1 addition & 0 deletions packages/appkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"@databricks/sdk-jobs": "0.57.0",
"@databricks/sdk-modelserving": "0.53.0",
"@databricks/sdk-uc-tables": "0.52.0",
"@databricks/sdk-uc-volumes": "0.51.0",
"@databricks/sdk-vectorsearch": "0.51.0",
"@databricks/sdk-options": "0.51.0",
"@databricks/sdk-postgres": "0.52.0",
Expand Down
1 change: 1 addition & 0 deletions packages/appkit/src/testing/mock-workspace-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const FACADE_SERVICES = [
"vectorSearch",
"tables",
"postgres",
"volumes",
"statementExecution",
"modelServing",
"servingEndpoints",
Expand Down
1 change: 1 addition & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@databricks/sdk-jobs": "0.57.0",
"@databricks/sdk-modelserving": "0.53.0",
"@databricks/sdk-uc-tables": "0.52.0",
"@databricks/sdk-uc-volumes": "0.51.0",
"@databricks/sdk-vectorsearch": "0.51.0",
"@databricks/sdk-options": "0.51.0",
"@databricks/sdk-postgres": "0.52.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/shared/src/workspace-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
type TablesClient,
buildPostgresClient,
type PostgresClient,
buildVolumesClient,
type VolumesClient,
buildVectorSearchClient,
type VectorSearchClient,
type StatementExecutionClient,
Expand All @@ -53,6 +55,7 @@ export class AppKitWorkspaceClient implements WorkspaceClient {
#vectorSearch?: VectorSearchClient;
#tables?: TablesClient;
#postgres?: PostgresClient;
#volumes?: VolumesClient;

constructor(opts: WorkspaceClientOptions) {
this.#opts = opts;
Expand Down Expand Up @@ -114,6 +117,14 @@ export class AppKitWorkspaceClient implements WorkspaceClient {
return this.#postgres;
}

// Migrated to the modular SDK — built lazily, independent of the legacy client.
get volumes(): VolumesClient {
if (!this.#volumes) {
this.#volumes = buildVolumesClient(this.#opts);
}
return this.#volumes;
}

// Migrated to the modular SDK — built lazily, independent of the legacy client.
get statementExecution(): StatementExecutionClient {
if (!this.#statementExecution) {
Expand Down
16 changes: 16 additions & 0 deletions packages/shared/src/workspace-client/modular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import type { PostgresClient } from "@databricks/sdk-postgres/v1";
import { ScimClient } from "@databricks/sdk-scim/v1";
import { StatementExecutionClient } from "@databricks/sdk-statementexecution/v1";
import type { TablesClient } from "@databricks/sdk-uc-tables/v1";
import type { VolumesClient } from "@databricks/sdk-uc-volumes/v1";
import type { VectorSearchClient } from "@databricks/sdk-vectorsearch/v1";
import { WarehousesClient } from "@databricks/sdk-warehouses/v1";

Expand Down Expand Up @@ -638,6 +639,16 @@ export function buildTablesClient(opts: WorkspaceClientOptions): TablesClient {
);
}

/** Build a modular Unity Catalog Volumes client from wrapper options. */
export function buildVolumesClient(
opts: WorkspaceClientOptions,
): VolumesClient {
return lazyClient(
() => import("@databricks/sdk-uc-volumes/v1").then((m) => m.VolumesClient),
mapToClientOptions(opts),
);
}

/**
* Build a modular Lakebase Postgres (autoscaling: projects, branches,
* endpoints) client from wrapper options. Distinct from the provisioned
Expand Down Expand Up @@ -665,6 +676,7 @@ export type { PostgresClient } from "@databricks/sdk-postgres/v1";
export type { ScimClient } from "@databricks/sdk-scim/v1";
export type { StatementExecutionClient } from "@databricks/sdk-statementexecution/v1";
export type { TablesClient } from "@databricks/sdk-uc-tables/v1";
export type { VolumesClient } from "@databricks/sdk-uc-volumes/v1";
export type { VectorSearchClient } from "@databricks/sdk-vectorsearch/v1";
export type { WarehousesClient } from "@databricks/sdk-warehouses/v1";

Expand Down Expand Up @@ -724,3 +736,7 @@ export type {
QueryVectorIndexRequest,
QueryVectorIndexResponse,
} from "@databricks/sdk-vectorsearch/v1";
export type {
GetVolumeRequest,
VolumeInfo,
} from "@databricks/sdk-uc-volumes/v1";
39 changes: 39 additions & 0 deletions packages/shared/src/workspace-client/tests/modular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ vi.mock("@databricks/sdk-modelserving/v1", () => ({
return { opts, getInferenceEndpoint: async () => ({}) };
}),
}));
vi.mock("@databricks/sdk-uc-volumes/v1", () => ({
VolumesClient: vi.fn().mockImplementation((opts) => {
ctorOpts.push(opts);
return { opts, getVolume: async () => ({}) };
}),
}));
vi.mock("@databricks/sdk-postgres/v1", () => ({
PostgresClient: vi.fn().mockImplementation((opts) => {
ctorOpts.push(opts);
Expand Down Expand Up @@ -132,6 +138,7 @@ import { ApiError } from "../errors";
import {
buildGenieClient,
buildModelServingClient,
buildVolumesClient,
buildWarehousesClient,
buildPostgresClient,
buildWorkspaceAuth,
Expand Down Expand Up @@ -384,6 +391,38 @@ describe("modular mapToClientOptions (via buildWarehousesClient)", () => {
expect(m2mOpts).toEqual([]);
});

test("volumes: SP env creds → M2M with the scheme-normalized host", async () => {
process.env.DATABRICKS_HOST = "envhost.cloud.databricks.com";
process.env.DATABRICKS_CLIENT_ID = "sp-client-id";
process.env.DATABRICKS_CLIENT_SECRET = "sp-secret";
await buildVolumesClient({}).getVolume({} as never);
expect(ctorOpts[0].host).toBe("https://envhost.cloud.databricks.com");
expect(m2mOpts).toEqual([
{
host: "https://envhost.cloud.databricks.com",
clientId: "sp-client-id",
clientSecret: "sp-secret",
},
]);
expect((ctorOpts[0].credentials as { name: () => string }).name()).toBe(
"oauth-m2m",
);
});

test("volumes (asUser) uses the OBO token as PAT", async () => {
process.env.DATABRICKS_CLIENT_ID = "sp-client-id";
process.env.DATABRICKS_CLIENT_SECRET = "sp-secret";
await buildVolumesClient({
token: "user-token",
host: "https://x",
}).getVolume({} as never);
expect(ctorOpts[0].credentials).toMatchObject({
kind: "pat",
token: "user-token",
});
expect(m2mOpts).toEqual([]);
});

test("postgres normalizes the host and passes SP M2M credentials", async () => {
process.env.DATABRICKS_HOST = "envhost.cloud.databricks.com";
process.env.DATABRICKS_CLIENT_ID = "sp-client-id";
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/workspace-client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
ModelServingClient,
FilesClient,
TablesClient,
VolumesClient,
VectorSearchClient,
PostgresClient,
} from "./modular";
Expand Down Expand Up @@ -69,6 +70,9 @@ export interface WorkspaceClient extends WorkspaceAuth {
/** Lakebase Postgres: autoscaling projects, branches, endpoints (modular SDK). */
readonly postgres: PostgresClient;

/** Unity Catalog Volumes (modular SDK). */
readonly volumes: VolumesClient;

/** Statement Execution (modular SDK). */
readonly statementExecution: StatementExecutionClient;

Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading