From 34441ae68ffb013f7858c2c54a9cc77b370c2fc3 Mon Sep 17 00:00:00 2001 From: MarioCadenas Date: Wed, 7 Oct 2026 16:10:30 +0200 Subject: [PATCH] feat(shared): migrate currentUser to the modular @databricks/sdk-scim client The facade's currentUser accessor now returns a lazily built ScimClient (sdk-scim 0.51.0, same core/auth/options 0.51.0) via mapToClientOptions, so SP and OBO auth resolve exactly like warehouses/statementExecution. Legacy currentUser.me() becomes ScimClient.me({}); it hits the same /api/2.0/preview/scim/v2/Me endpoint and the unmarshal keeps id and userName, the only fields AppKit reads. The CLI doctor check and the lakebase connector stay on the legacy client. Co-authored-by: Isaac Signed-off-by: MarioCadenas --- knip.json | 1 + packages/appkit/package.json | 1 + .../appkit/src/context/service-context.ts | 2 +- packages/shared/package.json | 1 + .../shared/src/workspace-client/client.ts | 11 +++++++++-- .../shared/src/workspace-client/modular.ts | 10 ++++++++++ packages/shared/src/workspace-client/types.ts | 5 +++-- pnpm-lock.yaml | 19 +++++++++++++++++++ 8 files changed, 45 insertions(+), 5 deletions(-) diff --git a/knip.json b/knip.json index 21f7b9ca0..b46121129 100644 --- a/knip.json +++ b/knip.json @@ -14,6 +14,7 @@ "@databricks/sdk-core", "@databricks/sdk-experimental", "@databricks/sdk-options", + "@databricks/sdk-scim", "@databricks/sdk-statementexecution", "@databricks/sdk-warehouses", "@mlflow/core", diff --git a/packages/appkit/package.json b/packages/appkit/package.json index f3d8a8c32..fb1ce78ec 100644 --- a/packages/appkit/package.json +++ b/packages/appkit/package.json @@ -75,6 +75,7 @@ "@databricks/sdk-core": "0.51.0", "@databricks/sdk-experimental": "0.17.0", "@databricks/sdk-options": "0.51.0", + "@databricks/sdk-scim": "0.51.0", "@databricks/sdk-statementexecution": "0.52.0", "@databricks/sdk-warehouses": "0.53.0", "@opentelemetry/api": "1.9.0", diff --git a/packages/appkit/src/context/service-context.ts b/packages/appkit/src/context/service-context.ts index 789457c93..c73cd31c0 100644 --- a/packages/appkit/src/context/service-context.ts +++ b/packages/appkit/src/context/service-context.ts @@ -186,7 +186,7 @@ export class ServiceContext { const [resolvedWorkspaceId, currentUser, resolvedResources] = await Promise.all([ ServiceContext.getWorkspaceId(wsClient), - wsClient.currentUser.me(), + wsClient.currentUser.me({}), WarehouseResource.resolve(wsClient, options?.warehouseId), ]); diff --git a/packages/shared/package.json b/packages/shared/package.json index 85d2a0672..867a9f2b4 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -52,6 +52,7 @@ "@databricks/sdk-core": "0.51.0", "@databricks/sdk-experimental": "0.17.0", "@databricks/sdk-options": "0.51.0", + "@databricks/sdk-scim": "0.51.0", "@databricks/sdk-statementexecution": "0.52.0", "@databricks/sdk-warehouses": "0.53.0", "@standard-schema/spec": "1.1.0", diff --git a/packages/shared/src/workspace-client/client.ts b/packages/shared/src/workspace-client/client.ts index db0fab36e..29494bb3c 100644 --- a/packages/shared/src/workspace-client/client.ts +++ b/packages/shared/src/workspace-client/client.ts @@ -13,9 +13,11 @@ import { type WorkspaceClientOptions, } from "./legacy"; import { + buildScimClient, buildStatementExecutionClient, buildWarehousesClient, buildWorkspaceAuth, + type ScimClient, type StatementExecutionClient, type WarehousesClient, type WorkspaceAuth, @@ -29,6 +31,7 @@ export class AppKitWorkspaceClient implements WorkspaceClient { #warehouses?: WarehousesClient; #statementExecution?: StatementExecutionClient; #auth?: WorkspaceAuth; + #currentUser?: ScimClient; constructor(opts: WorkspaceClientOptions) { this.#opts = opts; @@ -66,8 +69,12 @@ export class AppKitWorkspaceClient implements WorkspaceClient { return this.#getLegacy().servingEndpoints; } - get currentUser() { - return this.#getLegacy().currentUser; + // Migrated to the modular SDK (SCIM) — built lazily, independent of the legacy client. + get currentUser(): ScimClient { + if (!this.#currentUser) { + this.#currentUser = buildScimClient(this.#opts); + } + return this.#currentUser; } // Modular auth + raw-request seam — built lazily, independent of the legacy client. diff --git a/packages/shared/src/workspace-client/modular.ts b/packages/shared/src/workspace-client/modular.ts index 1b1c78754..377836417 100644 --- a/packages/shared/src/workspace-client/modular.ts +++ b/packages/shared/src/workspace-client/modular.ts @@ -36,6 +36,7 @@ import { } from "@databricks/sdk-core/http"; import { resolve } from "@databricks/sdk-core/profiles"; import type { ClientOptions } from "@databricks/sdk-options/client"; +import { ScimClient } from "@databricks/sdk-scim/v1"; import { StatementExecutionClient } from "@databricks/sdk-statementexecution/v1"; import { WarehousesClient } from "@databricks/sdk-warehouses/v1"; @@ -312,7 +313,16 @@ export function buildStatementExecutionClient( return new StatementExecutionClient(mapToClientOptions(opts)); } +/** + * Build a modular SCIM client from wrapper options. Backs the facade's + * `currentUser` accessor: legacy `currentUser.me()` is `ScimClient.me({})`. + */ +export function buildScimClient(opts: WorkspaceClientOptions): ScimClient { + return new ScimClient(mapToClientOptions(opts)); +} + // ── Client type re-exports (for the facade accessor types) ─────────────── +export type { ScimClient } from "@databricks/sdk-scim/v1"; export type { StatementExecutionClient } from "@databricks/sdk-statementexecution/v1"; export type { WarehousesClient } from "@databricks/sdk-warehouses/v1"; diff --git a/packages/shared/src/workspace-client/types.ts b/packages/shared/src/workspace-client/types.ts index b627afb23..bce944dc1 100644 --- a/packages/shared/src/workspace-client/types.ts +++ b/packages/shared/src/workspace-client/types.ts @@ -18,6 +18,7 @@ import type { StatementExecutionClient, WarehousesClient, WorkspaceAuth, + ScimClient, } from "./modular"; // Legacy SDK type namespaces for un-migrated services, re-exported so AppKit @@ -59,8 +60,8 @@ export interface WorkspaceClient extends WorkspaceAuth { /** Serving Endpoints. */ readonly servingEndpoints: LegacyWorkspaceClient["servingEndpoints"]; - /** Current user. */ - readonly currentUser: LegacyWorkspaceClient["currentUser"]; + /** Current user (modular SDK SCIM client; `me({})` returns the caller). */ + readonly currentUser: ScimClient; /** * Legacy SDK `Config`. Prefer `getHost()` / `authenticate(headers)` (modular, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 929d9c01e..ba0ae702c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -291,6 +291,9 @@ importers: '@databricks/sdk-options': specifier: 0.51.0 version: 0.51.0 + '@databricks/sdk-scim': + specifier: 0.51.0 + version: 0.51.0 '@databricks/sdk-statementexecution': specifier: 0.52.0 version: 0.52.0(patch_hash=9377a46b883b548d47116662bf73b159a4da51ec28b9ff1896a7e4a7841c240c) @@ -621,6 +624,9 @@ importers: '@databricks/sdk-options': specifier: 0.51.0 version: 0.51.0 + '@databricks/sdk-scim': + specifier: 0.51.0 + version: 0.51.0 '@databricks/sdk-statementexecution': specifier: 0.52.0 version: 0.52.0(patch_hash=9377a46b883b548d47116662bf73b159a4da51ec28b9ff1896a7e4a7841c240c) @@ -2012,6 +2018,10 @@ packages: resolution: {integrity: sha512-p5uBh64Y1onnvwlEwfRsmKmGRI23Y4Ly8fZiCgNUwVDe4Z9d0ctI0mo1v4gnDqlmBaBml3TZfqn5BJBROCXsEw==} engines: {node: '>=22.0.0'} + '@databricks/sdk-scim@0.51.0': + resolution: {integrity: sha512-WSTpuID4gRoTxVApyxujW+MsI5ANvmn8/DqPK6fXqxCkSINLEbtR+GTk/th8xnADtJekKNIWzeORFblXd3idcg==} + engines: {node: '>=22.0.0'} + '@databricks/sdk-statementexecution@0.52.0': resolution: {integrity: sha512-ymDGDW67PJ/0VujM89mUrE6mbbrabsKJP5LvPv8ZbgzPR0bm0DwXMcQzvS0XUt0UGITjV2gqbx5jQwP3ijtOmg==} engines: {node: '>=22.0.0'} @@ -14321,6 +14331,15 @@ snapshots: '@databricks/sdk-auth': 0.51.0 '@databricks/sdk-core': 0.51.0 + '@databricks/sdk-scim@0.51.0': + dependencies: + '@databricks/sdk-auth': 0.51.0 + '@databricks/sdk-core': 0.51.0 + '@databricks/sdk-options': 0.51.0 + '@js-temporal/polyfill': 0.5.1 + json-bigint: 1.0.0 + zod: 4.3.6 + '@databricks/sdk-statementexecution@0.52.0(patch_hash=9377a46b883b548d47116662bf73b159a4da51ec28b9ff1896a7e4a7841c240c)': dependencies: '@databricks/sdk-auth': 0.51.0