@databricks/appkit-ui 0.96.0 → 0.97.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 +16 -7
- package/dist/js/database/client.d.ts +2 -2
- package/dist/js/database/client.js +1 -1
- package/dist/js/database/client.js.map +1 -1
- package/dist/react/beta.d.ts +2 -2
- package/dist/react/beta.js +1 -2
- package/dist/react/hooks/use-database-list.d.ts +4 -4
- package/dist/react/hooks/use-database-list.d.ts.map +1 -1
- package/dist/react/hooks/use-database-list.js +1 -2
- package/dist/react/hooks/use-database-list.js.map +1 -1
- package/dist/react/hooks/use-database-read.d.ts +4 -41
- package/dist/react/hooks/use-database-read.d.ts.map +1 -1
- package/dist/react/hooks/use-database-read.js +7 -68
- package/dist/react/hooks/use-database-read.js.map +1 -1
- package/dist/react/hooks/use-database-record.d.ts +3 -3
- package/dist/react/hooks/use-database-record.d.ts.map +1 -1
- package/dist/react/hooks/use-database-record.js +2 -3
- package/dist/react/hooks/use-database-record.js.map +1 -1
- package/dist/react/hooks/use-database-write.d.ts +3 -3
- package/dist/react/hooks/use-database-write.js.map +1 -1
- package/dist/shared/src/database/api-types.d.ts +1 -4
- package/dist/shared/src/database/api-types.d.ts.map +1 -1
- package/dist/shared/src/database/index.d.ts +3 -0
- package/dist/shared/src/database/operations.d.ts +11 -0
- package/dist/shared/src/database/operations.d.ts.map +1 -0
- package/dist/shared/src/index.d.ts +1 -0
- package/dist/workspace-client/modular.d.ts.map +1 -1
- package/dist/workspace-client/modular.js +19 -2
- package/dist/workspace-client/modular.js.map +1 -1
- package/docs/api/appkit/Class.DatabaseValidationError.md +1 -1
- package/docs/api/appkit/Function.defineOperation.md +61 -0
- package/docs/api/appkit/Function.definePolicy.md +52 -0
- package/docs/api/appkit/Function.defineSchema.md +1 -1
- package/docs/api/appkit/Interface.Actor.md +21 -0
- package/docs/api/appkit/Interface.DatabaseOperationContract.md +30 -0
- package/docs/api/appkit/Interface.DatabaseRoutes.md +30 -0
- package/docs/api/appkit/Interface.OperationContext.md +75 -0
- package/docs/api/appkit/Interface.OperationDefinition.md +77 -0
- package/docs/api/appkit/Interface.PolicyContext.md +49 -0
- package/docs/api/appkit/Interface.PolicyDenial.md +21 -0
- package/docs/api/appkit/TypeAlias.DatabricksAppKitDatabaseOperations.md +8 -0
- package/docs/api/appkit/TypeAlias.IDatabaseConfig.md +0 -10
- package/docs/api/appkit/TypeAlias.OperationMethod.md +8 -0
- package/docs/api/appkit/TypeAlias.OperationWireInput.md +14 -0
- package/docs/api/appkit/TypeAlias.OperationWireOutput.md +14 -0
- package/docs/api/appkit/TypeAlias.Policy.md +15 -0
- package/docs/api/appkit/TypeAlias.PolicyDecision.md +8 -0
- package/docs/api/appkit.md +60 -51
- package/docs/plugins/database.md +17 -70
- package/llms.txt +16 -7
- package/package.json +1 -1
- package/sbom.cdx.json +1 -1
- package/docs/api/appkit/Interface.EntityMutationHooks.md +0 -173
- package/docs/api/appkit/Interface.HookApp.md +0 -12
- package/docs/api/appkit/Interface.HookContext.md +0 -21
- package/docs/api/appkit/Interface.ReadSerializerContext.md +0 -21
- package/docs/api/appkit/TypeAlias.EntityHooks.md +0 -25
- package/docs/api/appkit/TypeAlias.ReadSerializer.md +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-database-record.js","names":[],"sources":["../../../src/react/hooks/use-database-record.ts"],"sourcesContent":["import {\n DatabaseQueryEncodingError,\n encodeDatabaseRecordQuery,\n type ExactDatabaseParams,\n} from \"shared\";\n\nimport { isDatabaseRow } from \"@/js/database/client\";\nimport type {\n DatabaseId,\n DatabaseKeyedEntity,\n DatabaseRecordParams,\n DatabaseRecordRow,\n} from \"@/js/database/types\";\n\nimport {\n type DatabaseReadRequest,\n type UseDatabaseReadOptions,\n type UseDatabaseReadResult,\n useDatabaseRead,\n} from \"./use-database-read\";\n\n/** Options for {@link useDatabaseRecord}. */\nexport type UseDatabaseRecordOptions
|
|
1
|
+
{"version":3,"file":"use-database-record.js","names":[],"sources":["../../../src/react/hooks/use-database-record.ts"],"sourcesContent":["import {\n DatabaseQueryEncodingError,\n encodeDatabaseRecordQuery,\n type ExactDatabaseParams,\n} from \"shared\";\n\nimport { isDatabaseRow } from \"@/js/database/client\";\nimport type {\n DatabaseId,\n DatabaseKeyedEntity,\n DatabaseRecordParams,\n DatabaseRecordRow,\n} from \"@/js/database/types\";\n\nimport {\n type DatabaseReadRequest,\n type UseDatabaseReadOptions,\n type UseDatabaseReadResult,\n useDatabaseRead,\n} from \"./use-database-read\";\n\n/** Options for {@link useDatabaseRecord}. */\nexport type UseDatabaseRecordOptions = UseDatabaseReadOptions;\n\n/** What {@link useDatabaseRecord} returns: one row and its state. */\nexport type UseDatabaseRecordResult<Row> = UseDatabaseReadResult<Row>;\n\n/**\n * Subscribe to one row from `GET /api/database/<entity>/:id`. Only entities\n * with a public primary key have this route; a missing row surfaces as a\n * `NOT_FOUND` error, and a refetch that finds the row gone clears `data`.\n *\n * A `null` or `undefined` id holds the hook idle without a request, so a\n * record that depends on another read needs no separate `enabled` flag. An\n * empty, `\".\"`, or `\"..\"` id reports `INVALID_REQUEST` without a request.\n *\n * @param entity - A table the generated registry exposes with a public key\n * @param id - The row's public key, or `null`/`undefined` to wait\n * @param params - `select` and `include`; pass `{}` to reach `options` alone\n * @param options - `enabled` and `keepPreviousData`\n * @returns The row, loading and error state, and `refetch`\n *\n * @example\n * ```tsx\n * const board = useDatabaseRecord(\"boards\", selectedId, {\n * include: { notes: { limit: 20 } },\n * });\n * board.data?.notes.length;\n * ```\n */\nexport function useDatabaseRecord<\n K extends DatabaseKeyedEntity,\n const P extends DatabaseRecordParams<K> = Record<never, never>,\n>(\n entity: K,\n id: DatabaseId<K> | null | undefined,\n params?: P & ExactDatabaseParams<P, DatabaseRecordParams<K>>,\n options: UseDatabaseRecordOptions = {},\n): UseDatabaseRecordResult<DatabaseRecordRow<K, P>> {\n const enabled = (options.enabled ?? true) && id !== null && id !== undefined;\n const recordParams = (params ?? {}) as { include?: unknown };\n // Encode only an enabled read: a held read's params may still be incomplete.\n let query: DatabaseReadRequest[\"query\"] = \"\";\n if (enabled) {\n try {\n query = encodeDatabaseRecordQuery(recordParams);\n } catch (error) {\n query = error instanceof DatabaseQueryEncodingError ? error : null;\n }\n }\n const read = useDatabaseRead({\n entity,\n operation: \"detail\",\n id: id ?? undefined,\n query,\n include: recordParams.include,\n enabled,\n accept: isDatabaseRow,\n keepPreviousData: options.keepPreviousData ?? false,\n });\n // The server projected and encoded the row; the types describe that wire.\n return read as UseDatabaseRecordResult<DatabaseRecordRow<K, P>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,kBAId,QACA,IACA,QACA,UAAoC,EAAE,EACY;CAClD,MAAM,WAAW,QAAQ,WAAW,SAAS,OAAO,QAAQ,OAAO;CACnE,MAAM,eAAgB,UAAU,EAAE;CAElC,IAAI,QAAsC;AAC1C,KAAI,QACF,KAAI;AACF,UAAQ,0BAA0B,aAAa;UACxC,OAAO;AACd,UAAQ,iBAAiB,6BAA6B,QAAQ;;AAclE,QAXa,gBAAgB;EAC3B;EACA,WAAW;EACX,IAAI,MAAM;EACV;EACA,SAAS,aAAa;EACtB;EACA,QAAQ;EACR,kBAAkB,QAAQ,oBAAoB;EAC/C,CAAC"}
|
|
@@ -21,9 +21,9 @@ interface UseDatabaseWriteState<T> {
|
|
|
21
21
|
interface UseDatabaseWriteOptions {
|
|
22
22
|
/**
|
|
23
23
|
* Reads to restart once a write succeeds. Default `true`: every mounted
|
|
24
|
-
* database read, since a
|
|
25
|
-
*
|
|
26
|
-
* directly or through an include; `false` restarts none.
|
|
24
|
+
* database read, since a foreign key declared with `onDelete("cascade")` can
|
|
25
|
+
* change other tables too. A table list restarts only the reads that show
|
|
26
|
+
* those tables, directly or through an include; `false` restarts none.
|
|
27
27
|
*/
|
|
28
28
|
invalidate?: DatabaseInvalidation;
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-database-write.js","names":[],"sources":["../../../src/react/hooks/use-database-write.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { DatabaseApiError } from \"@/js/database/errors\";\n\nimport {\n asDatabaseApiError,\n type DatabaseInvalidation,\n invalidateDatabaseReads,\n} from \"./database-request-store\";\n\nexport type { DatabaseInvalidation } from \"./database-request-store\";\n\n/** Latest state of a database write hook. */\nexport interface UseDatabaseWriteState<T> {\n /** The latest call's result, or `null` before it answers. */\n data: T | null;\n /**\n * Whether the latest call is in flight, including the reload of the reads\n * it restarts.\n */\n loading: boolean;\n /**\n * Why the latest call failed: `NOT_EXPOSED` when no route exists,\n * `OUTCOME_UNKNOWN` when it may have committed without an answer.\n */\n error: DatabaseApiError | null;\n}\n\n/** Options every database write hook takes. */\nexport interface UseDatabaseWriteOptions {\n /**\n * Reads to restart once a write succeeds. Default `true`: every mounted\n * database read, since a
|
|
1
|
+
{"version":3,"file":"use-database-write.js","names":[],"sources":["../../../src/react/hooks/use-database-write.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { DatabaseApiError } from \"@/js/database/errors\";\n\nimport {\n asDatabaseApiError,\n type DatabaseInvalidation,\n invalidateDatabaseReads,\n} from \"./database-request-store\";\n\nexport type { DatabaseInvalidation } from \"./database-request-store\";\n\n/** Latest state of a database write hook. */\nexport interface UseDatabaseWriteState<T> {\n /** The latest call's result, or `null` before it answers. */\n data: T | null;\n /**\n * Whether the latest call is in flight, including the reload of the reads\n * it restarts.\n */\n loading: boolean;\n /**\n * Why the latest call failed: `NOT_EXPOSED` when no route exists,\n * `OUTCOME_UNKNOWN` when it may have committed without an answer.\n */\n error: DatabaseApiError | null;\n}\n\n/** Options every database write hook takes. */\nexport interface UseDatabaseWriteOptions {\n /**\n * Reads to restart once a write succeeds. Default `true`: every mounted\n * database read, since a foreign key declared with `onDelete(\"cascade\")` can\n * change other tables too. A table list restarts only the reads that show\n * those tables, directly or through an include; `false` restarts none.\n */\n invalidate?: DatabaseInvalidation;\n}\n\n/** The generic write lifecycle's callbacks, before each hook names its args. */\ninterface WriteCallbacks<Args extends unknown[], T> {\n invalidate?: DatabaseInvalidation;\n onSuccess?: (data: T, args: Args) => void;\n onError?: (error: DatabaseApiError, args: Args) => void;\n}\n\ninterface DatabaseWrite<\n Args extends unknown[],\n T,\n> extends UseDatabaseWriteState<T> {\n mutate(...args: Args): Promise<T | null>;\n reset(): void;\n}\n\nconst IDLE: UseDatabaseWriteState<never> = Object.freeze({\n data: null,\n loading: false,\n error: null,\n});\n\n/**\n * Run a caller's callback without letting it break the write's promise: the\n * call still resolves, and the exception still reaches the page's error\n * handling (and any error tracker) as an uncaught error.\n */\nfunction runCallback(callback: () => void): void {\n try {\n callback();\n } catch (error) {\n if (typeof globalThis.reportError === \"function\") {\n globalThis.reportError(error);\n } else {\n setTimeout(() => {\n throw error;\n });\n }\n }\n}\n\n/**\n * One write hook's state around `send`, which must be stable per entity.\n *\n * A call never rejects, like `useServingInvoke`: it resolves with the result,\n * or with `null` once the failure is in `error`, so a handler needs no\n * `try/catch`. Callers that want an exception use `databaseApi` directly.\n *\n * A write is never aborted: cancelling the request would not undo a committed\n * transaction. A successful call restarts the reads `invalidate` names and\n * resolves once they have reloaded, so a handler that clears its form sees the\n * new rows already on screen. Only the latest call of a hook updates its\n * state; callbacks run for every call, even after the hook unmounts, since the\n * rows did change.\n */\nexport function useDatabaseWrite<Args extends unknown[], T>(\n send: (...args: Args) => Promise<T>,\n options: WriteCallbacks<Args, T>,\n): DatabaseWrite<Args, T> {\n const [state, setState] = useState<UseDatabaseWriteState<T>>(IDLE);\n const latest = useRef<symbol | null>(null);\n\n // Read at call time, so inline callbacks and an inline `invalidate` list do\n // not change `mutate`'s identity on every render.\n const optionsRef = useRef(options);\n useEffect(() => {\n optionsRef.current = options;\n });\n\n const mutate = useCallback(\n async (...args: Args): Promise<T | null> => {\n const call = Symbol(\"database write\");\n latest.current = call;\n // React ignores a state update after unmount, so only staleness matters.\n const settle = (next: UseDatabaseWriteState<T>) => {\n if (latest.current === call) setState(next);\n };\n\n settle({ data: null, loading: true, error: null });\n let data: T;\n try {\n data = await send(...args);\n } catch (cause) {\n const error = asDatabaseApiError(cause);\n settle({ data: null, loading: false, error });\n const { onError } = optionsRef.current;\n if (onError) runCallback(() => onError(error, args));\n return null;\n }\n // Hold `loading` until the restarted reads answer, so the hook does not\n // report success beside rows that still show the old state.\n await invalidateDatabaseReads(optionsRef.current.invalidate ?? true);\n settle({ data, loading: false, error: null });\n const { onSuccess } = optionsRef.current;\n if (onSuccess) runCallback(() => onSuccess(data, args));\n return data;\n },\n [send],\n );\n\n // A call still in flight keeps running, but no longer reports here.\n const reset = useCallback(() => {\n latest.current = null;\n setState(IDLE);\n }, []);\n\n return { ...state, mutate, reset };\n}\n"],"mappings":";;;;AAsDA,MAAM,OAAqC,OAAO,OAAO;CACvD,MAAM;CACN,SAAS;CACT,OAAO;CACR,CAAC;;;;;;AAOF,SAAS,YAAY,UAA4B;AAC/C,KAAI;AACF,YAAU;UACH,OAAO;AACd,MAAI,OAAO,WAAW,gBAAgB,WACpC,YAAW,YAAY,MAAM;MAE7B,kBAAiB;AACf,SAAM;IACN;;;;;;;;;;;;;;;;;AAmBR,SAAgB,iBACd,MACA,SACwB;CACxB,MAAM,CAAC,OAAO,YAAY,SAAmC,KAAK;CAClE,MAAM,SAAS,OAAsB,KAAK;CAI1C,MAAM,aAAa,OAAO,QAAQ;AAClC,iBAAgB;AACd,aAAW,UAAU;GACrB;CAEF,MAAM,SAAS,YACb,OAAO,GAAG,SAAkC;EAC1C,MAAM,OAAO,OAAO,iBAAiB;AACrC,SAAO,UAAU;EAEjB,MAAM,UAAU,SAAmC;AACjD,OAAI,OAAO,YAAY,KAAM,UAAS,KAAK;;AAG7C,SAAO;GAAE,MAAM;GAAM,SAAS;GAAM,OAAO;GAAM,CAAC;EAClD,IAAI;AACJ,MAAI;AACF,UAAO,MAAM,KAAK,GAAG,KAAK;WACnB,OAAO;GACd,MAAM,QAAQ,mBAAmB,MAAM;AACvC,UAAO;IAAE,MAAM;IAAM,SAAS;IAAO;IAAO,CAAC;GAC7C,MAAM,EAAE,YAAY,WAAW;AAC/B,OAAI,QAAS,mBAAkB,QAAQ,OAAO,KAAK,CAAC;AACpD,UAAO;;AAIT,QAAM,wBAAwB,WAAW,QAAQ,cAAc,KAAK;AACpE,SAAO;GAAE;GAAM,SAAS;GAAO,OAAO;GAAM,CAAC;EAC7C,MAAM,EAAE,cAAc,WAAW;AACjC,MAAI,UAAW,mBAAkB,UAAU,MAAM,KAAK,CAAC;AACvD,SAAO;IAET,CAAC,KAAK,CACP;CAGD,MAAM,QAAQ,kBAAkB;AAC9B,SAAO,UAAU;AACjB,WAAS,KAAK;IACb,EAAE,CAAC;AAEN,QAAO;EAAE,GAAG;EAAO;EAAQ;EAAO"}
|
|
@@ -103,10 +103,7 @@ type RecordRowFor<R, K, P> = ListRowFor<R, K, P>;
|
|
|
103
103
|
type InsertFor<R, K> = WireInput<ApiOf<R, K>["insert"]>;
|
|
104
104
|
/** The body a generated update route accepts for `K`, as JSON carries it. */
|
|
105
105
|
type UpdateFor<R, K> = WireInput<ApiOf<R, K>["update"]>;
|
|
106
|
-
/**
|
|
107
|
-
* The public row a generated create or update route answers with. A read
|
|
108
|
-
* serializer never reshapes a write's response, so this is always the row.
|
|
109
|
-
*/
|
|
106
|
+
/** The public row a generated create or update route answers with. */
|
|
110
107
|
type PublicRowFor<R, K> = WireOutput<PublicRowOf<R, K>>;
|
|
111
108
|
/** The envelope a generated list route answers with. */
|
|
112
109
|
interface DatabaseListPage<Row> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-types.d.ts","names":[],"sources":["../../../../../shared/src/database/api-types.ts"],"mappings":";;AAOA;;;;;UAAiB,gBAAA;EAIN;EAAA,SAFA,SAAA,EAAW,MAAA;EAIX;EAAA,SAFA,QAAA,EAAU,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I,UAAA,CAAW,YAAA,CAAa,KAAA,GAAQ,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { DatabaseApiEntityFor, DatabaseApiEntry, DatabaseListPage, ExactDatabaseParams, HttpIncludeArgFor, IdFor, InsertFor, KeyedEntityFor, ListParamsFor, ListRowFor, PublicRowFor, RecordParamsFor, RecordRowFor, UpdateFor, WireInput, WireOutput } from "./api-types.js";
|
|
2
|
+
import { DatabaseErrorCategory, DatabaseErrorDetail } from "./errors.js";
|
|
3
|
+
import "./operations.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region ../shared/src/database/operations.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Names the UI resolves without importing a server module. Empty until
|
|
4
|
+
* generation adds one entry per operation name. The declaration is global so
|
|
5
|
+
* a generated `database.d.ts` can augment it without importing this module.
|
|
6
|
+
*/
|
|
7
|
+
declare global {
|
|
8
|
+
interface DatabricksAppKitDatabaseOperations {}
|
|
9
|
+
}
|
|
10
|
+
/** The same global registry, available as a module type for package exports. */
|
|
11
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","names":[],"sources":["../../../../../shared/src/database/operations.ts"],"mappings":";;;;;;QAuBQ,MAAA;EAAA,UAEI,kCAAA;AAAA"}
|
|
@@ -5,6 +5,7 @@ import { PluginClientConfigs, PluginEndpointMap, PluginEndpoints } from "./plugi
|
|
|
5
5
|
import "./cache.js";
|
|
6
6
|
import { DatabaseApiEntityFor, DatabaseApiEntry, DatabaseListPage, ExactDatabaseParams, HttpIncludeArgFor, IdFor, InsertFor, KeyedEntityFor, ListParamsFor, ListRowFor, PublicRowFor, RecordParamsFor, RecordRowFor, UpdateFor, WireInput, WireOutput } from "./database/api-types.js";
|
|
7
7
|
import { DatabaseErrorCategory, DatabaseErrorDetail } from "./database/errors.js";
|
|
8
|
+
import "./database/index.js";
|
|
8
9
|
import { GenieAttachmentResponse, GenieMessageResponse, GenieStatementResponse, GenieStreamEvent } from "./genie.js";
|
|
9
10
|
import { MetricFilter, MetricFilterOperatorName, MetricOrderBy, MetricOrderDirection, MetricPredicate } from "./metric-filter.js";
|
|
10
11
|
import { MetricViewColumnDisplay } from "./metric-metadata.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modular.d.ts","names":[],"sources":["../../src/workspace-client/modular.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;cA6La,eAAA,SAAwB,KAAA;EAC1B,IAAA;AAAA;AADX;AAAA,iBAKgB,iBAAA,CAAkB,CAAA,YAAa,CAAA,IAAK,KAAA;;
|
|
1
|
+
{"version":3,"file":"modular.d.ts","names":[],"sources":["../../src/workspace-client/modular.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;cA6La,eAAA,SAAwB,KAAA;EAC1B,IAAA;AAAA;AADX;AAAA,iBAKgB,iBAAA,CAAkB,CAAA,YAAa,CAAA,IAAK,KAAA;;UAwOnC,gBAAA;EACf,MAAA;EAzOc;EA2Od,IAAA;EACA,KAAA,GAAQ,MAAA;EACR,OAAA,GAAU,OAAA;EACV,IAAA,GAAO,WAAA;EACP,MAAA,GAAS,WAAA;AAAA;;UAIM,aAAA;EAXA;EAaf,OAAA,IAAW,OAAA;;EAEX,YAAA,CAAa,OAAA,EAAS,OAAA,GAAU,OAAA;EAVtB;;;;;EAgBV,OAAA,CAAQ,GAAA,EAAK,gBAAA,GAAmB,OAAA,CAAQ,QAAA;AAAA;;;;;;;;iBAU1B,kBAAA,CACd,IAAA,EAAM,sBAAA,GACL,aAAA;;iBAsGa,qBAAA,CACd,IAAA,EAAM,sBAAA,GACL,gBAAA;AA9HH;AAAA,iBAmIgB,6BAAA,CACd,IAAA,EAAM,sBAAA,GACL,wBAAA;;;;;iBAYa,eAAA,CAAgB,IAAA,EAAM,sBAAA,GAAyB,UAAA;;iBAK/C,eAAA,CAAgB,IAAA,EAAM,sBAAA,GAAyB,UAAA;;iBAsC/C,gBAAA,CAAiB,IAAA,EAAM,sBAAA,GAAyB,WAAA;;iBAQhD,eAAA,CAAgB,IAAA,EAAM,sBAAA,GAAyB,UAAA;;;;;;;iBAa/C,gBAAA,CAAiB,IAAA,EAAM,sBAAA,GAAyB,WAAA;;;;AA7LhE;iBAwMgB,uBAAA,CACd,IAAA,EAAM,sBAAA,GACL,kBAAA;;iBAWa,uBAAA,CACd,IAAA,EAAM,sBAAA,GACL,kBAAA;;iBAWa,sBAAA,CACd,IAAA,EAAM,sBAAA,GACL,iBAAA;;iBASa,iBAAA,CAAkB,IAAA,EAAM,sBAAA,GAAyB,YAAA;;iBAQjD,kBAAA,CACd,IAAA,EAAM,sBAAA,GACL,aAAA;;iBAQa,oBAAA,CACd,IAAA,EAAM,sBAAA,GACL,eAAA;;iBASa,sBAAA,CACd,IAAA,EAAM,sBAAA,GACL,iBAAA;;iBAWa,mBAAA,CACd,IAAA,EAAM,sBAAA,GACL,cAAA;;;;;;iBAkBa,mBAAA,CACd,IAAA,EAAM,sBAAA,GACL,cAAA"}
|
|
@@ -255,13 +255,30 @@ async function sendWithRetry(base, request) {
|
|
|
255
255
|
const text = new TextDecoder().decode(body);
|
|
256
256
|
const retryable = response.statusCode === 429 || TRANSIENT_ERROR_MESSAGES.some((m) => text.includes(m));
|
|
257
257
|
const waitMs = Math.min(attempt * 1e3 + 50 + Math.random() * 700, 1e4);
|
|
258
|
-
if (!retryable ||
|
|
258
|
+
if (!retryable || Date.now() + waitMs > deadline) return {
|
|
259
259
|
...response,
|
|
260
260
|
body: new Response(body).body
|
|
261
261
|
};
|
|
262
|
-
await
|
|
262
|
+
await abortableWait(waitMs, request.signal);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
+
function abortableWait(ms, signal) {
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
267
|
+
if (signal?.aborted) {
|
|
268
|
+
reject(signal.reason);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const timer = setTimeout(() => {
|
|
272
|
+
signal?.removeEventListener("abort", onAbort);
|
|
273
|
+
resolve();
|
|
274
|
+
}, ms);
|
|
275
|
+
const onAbort = () => {
|
|
276
|
+
clearTimeout(timer);
|
|
277
|
+
reject(signal?.reason);
|
|
278
|
+
};
|
|
279
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
280
|
+
});
|
|
281
|
+
}
|
|
265
282
|
/**
|
|
266
283
|
* Build host/credential resolution from {@link mapToClientOptions}, mirroring
|
|
267
284
|
* the modular SDK's `resolveClientConfig` (sdk-warehouses `dist/v1/transport.js`):
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modular.js","names":["ApiError"],"sources":["../../src/workspace-client/modular.ts"],"sourcesContent":["/**\n * The single module allowed to import the modular `@databricks/sdk-*` SDK\n * directly — the new-SDK sibling of {@link ./legacy.ts}. Every other AppKit\n * module reaches these clients through the {@link WorkspaceClient} facade and\n * the type re-exports below, so the modular SDK stays isolated exactly like the\n * legacy one (the oxlint `no-restricted-imports` boundary walls `@databricks/sdk-*`\n * off everywhere outside `packages/shared/src/workspace-client/`).\n *\n * Migrated services are built here as per-service clients; the facade delegates\n * their accessors to these instead of the legacy monolithic client. Currently\n * `warehouses`, `statementExecution`, `currentUser` (SCIM), `genie`, `jobs`,\n * `files`, `vectorSearch`, `tables`, `modelServing`, `volumes`, `functions`,\n * `connections`, `database`, `postgres`, `experiments` and `apps` are\n * migrated, plus the auth + raw-request seam ({@link buildWorkspaceAuth}).\n * Only `servingEndpoints`, `config` and `apiClient` still route through\n * `legacy.ts`.\n *\n * NOTE: statementExecution relies on a pinned pnpm patch\n * (`patches/@databricks__sdk-statementexecution@0.52.0.patch`) that restores the\n * undocumented Reyden `attachment` response field, which the SDK's generated\n * unmarshal transform would otherwise strip.\n *\n * NOTE: vectorSearch relies on a pinned pnpm patch\n * (`patches/@databricks__sdk-vectorsearch@0.51.0.patch`): it adds the\n * undocumented query `debug_level` request / `debug_info` response fields (the\n * source of ai-search `queryTimeMs`), and lets row values be `bigint`, since the\n * SDK parses with json-bigint and the unpatched schema rejects ints over 2^53.\n *\n * NOTE: genie relies on a pinned pnpm patch\n * (`patches/@databricks__sdk-genie@0.54.0.patch`): the generated model types the\n * query result's `data_array` as protobuf `ListValue[]` (`{ values: [...] }`), but\n * the API returns plain `JSON_ARRAY` rows (`[[\"a\", null], ...]`), so the unmarshal\n * schema rejected every real query result. The patch restores `(string | null)[][]`.\n */\nimport { execFile } from \"node:child_process\";\nimport { STATUS_CODES } from \"node:http\";\nimport { promisify } from \"node:util\";\n\nimport type { AppsClient } from \"@databricks/sdk-apps/v1\";\nimport {\n type Credentials,\n newTokenCredentials,\n type Token,\n type TokenCredentials,\n tokenProviderFn,\n} from \"@databricks/sdk-auth\";\nimport {\n DefaultCredentialsError,\n defaultCredentials,\n M2mCredentialsError,\n newM2mCredentials,\n newPatCredentials,\n newU2mCredentials,\n PatCredentialsError,\n U2mCredentialsError,\n} from \"@databricks/sdk-auth/credentials\";\nimport {\n type HttpClient,\n type HttpRequest,\n newFetchHttpClient,\n} from \"@databricks/sdk-core/http\";\nimport { type ProfileOptions, resolve } from \"@databricks/sdk-core/profiles\";\nimport type { DatabaseClient } from \"@databricks/sdk-database/v1\";\nimport type { ExperimentsClient } from \"@databricks/sdk-experiments/v1\";\nimport type { FilesClient } from \"@databricks/sdk-files/v2\";\nimport type { GenieClient } from \"@databricks/sdk-genie/v1\";\nimport type { JobsClient } from \"@databricks/sdk-jobs/v2\";\nimport type { ModelServingClient } from \"@databricks/sdk-modelserving/v1\";\nimport type { ClientOptions } from \"@databricks/sdk-options/client\";\nimport type { PostgresClient } from \"@databricks/sdk-postgres/v1\";\nimport { ScimClient } from \"@databricks/sdk-scim/v1\";\nimport { StatementExecutionClient } from \"@databricks/sdk-statementexecution/v1\";\nimport type { ConnectionsClient } from \"@databricks/sdk-uc-connections/v1\";\nimport type { FunctionsClient } from \"@databricks/sdk-uc-functions/v1\";\nimport type { TablesClient } from \"@databricks/sdk-uc-tables/v1\";\nimport type { VolumesClient } from \"@databricks/sdk-uc-volumes/v1\";\nimport type { VectorSearchClient } from \"@databricks/sdk-vectorsearch/v1\";\nimport { WarehousesClient } from \"@databricks/sdk-warehouses/v1\";\n\nimport { ApiError } from \"./errors\";\nimport type { WorkspaceClientOptions } from \"./options\";\n\n/**\n * Prepend `https://` to a scheme-less host. The legacy SDK normalized the host\n * this way; the modular SDK does NOT — it passes the host straight into `fetch`,\n * so a bare `DATABRICKS_HOST=my-workspace.cloud.databricks.com` (the common form,\n * and what the Databricks Apps runtime sets) yields `TypeError: Invalid URL`.\n */\nfunction normalizeHost(host: string | undefined): string | undefined {\n const trimmed = host?.trim();\n if (!trimmed) return undefined;\n return /^https?:\\/\\//i.test(trimmed) ? trimmed : `https://${trimmed}`;\n}\n\n// Same margin as the legacy SDK: refresh 40s early, since Azure Databricks\n// rejects tokens that expire in 30s or less.\nconst TOKEN_REFRESH_MARGIN_MS = 40_000;\n\n/**\n * Cache a token until shortly before it expires. The modular `newM2mCredentials`\n * caches only the token endpoint and mints a fresh OAuth token on EVERY request;\n * the legacy SDK reused it until expiry. Concurrent callers share one in-flight\n * fetch. Like the legacy SDK, a token without an expiry is reused indefinitely.\n */\nfunction withTokenCache(credentials: TokenCredentials): TokenCredentials {\n let current: Token | undefined;\n let inflight: Promise<Token> | undefined;\n const isFresh = (t: Token) =>\n t.expiry === undefined ||\n t.expiry.getTime() - TOKEN_REFRESH_MARGIN_MS > Date.now();\n return newTokenCredentials(\n credentials.name(),\n tokenProviderFn(async () => {\n if (current && isFresh(current)) return current;\n inflight ??= credentials\n .token()\n .then((t) => (current = t))\n .finally(() => {\n inflight = undefined;\n });\n return inflight;\n }),\n );\n}\n\n/**\n * The SDK default chain (profile / `~/.databrickscfg`), with the token cache the\n * chain lacks: its CLI strategy shells out to `databricks auth token` and its\n * M2M strategy mints a new OAuth token on EVERY request. `DefaultCredentials`\n * hides the token behind `authHeaders()`, so mirror its strategy order (PAT →\n * M2M → CLI) to get a cacheable `TokenCredentials`. A profile `authType` naming\n * one of these (`databricks auth login` writes `databricks-cli`) pins that\n * strategy; other auth types and `groupId` keep the SDK's own (uncached) logic.\n * TODO: drop once sdk-auth caches tokens in its M2M and CLI credentials.\n */\nfunction cachedDefaultCredentials(\n profileOptions?: ProfileOptions,\n): Credentials {\n const select = async (): Promise<Credentials> => {\n const profile = await resolve(profileOptions);\n // Same as env M2M: OAuth discovery needs a scheme, which a profile may omit.\n const host = normalizeHost(profile.host)?.replace(/\\/+$/, \"\");\n const { name, token, clientId, clientSecret, authType } = profile;\n const allows = (strategy: string) => !authType || authType === strategy;\n if (host && !profile.groupId) {\n if (token && allows(\"pat\")) return newPatCredentials(token.value);\n if (clientId && clientSecret && allows(\"oauth-m2m\")) {\n return withTokenCache(\n newM2mCredentials({\n host,\n clientId,\n clientSecret: clientSecret.value,\n ...(profile.accountId !== undefined && {\n accountId: profile.accountId,\n }),\n }),\n );\n }\n if (name && allows(\"databricks-cli\")) {\n return withTokenCache(\n newU2mCredentials({\n profile: name,\n ...(profile.databricksCliPath !== undefined && {\n cliPath: profile.databricksCliPath,\n }),\n }),\n );\n }\n }\n return defaultCredentials({\n profile: { ...profile, ...(host && { host }) },\n });\n };\n let selected: Promise<Credentials> | undefined;\n return {\n name: () => \"default\",\n async authHeaders() {\n selected ??= select().catch((e) => {\n selected = undefined;\n throw e;\n });\n return (await selected).authHeaders();\n },\n };\n}\n\nconst execFileAsync = promisify(execFile);\n\n/** Auth could not be configured (missing or unsupported credentials). */\nexport class AuthConfigError extends Error {\n override name = \"AuthConfigError\";\n}\n\n/** Whether `e` means auth isn't set up, from AppKit or the modular SDK. */\nexport function isAuthConfigError(e: unknown): e is Error {\n return (\n e instanceof AuthConfigError ||\n e instanceof DefaultCredentialsError ||\n e instanceof M2mCredentialsError ||\n e instanceof PatCredentialsError ||\n e instanceof U2mCredentialsError\n );\n}\n\n/**\n * Databricks CLI auth for a host, not a profile: what the legacy SDK used when\n * only a host was configured. The modular CLI strategy needs a profile name.\n */\nfunction cliHostCredentials(host: string): TokenCredentials {\n return withTokenCache(\n newTokenCredentials(\n \"databricks-cli\",\n tokenProviderFn(async () => {\n let stdout: string;\n try {\n ({ stdout } = await execFileAsync(\"databricks\", [\n \"auth\",\n \"token\",\n \"--host\",\n host,\n ]));\n } catch (e) {\n const err = e as { stderr?: unknown; message?: string };\n const detail = String(err.stderr ?? err.message ?? e).trim();\n throw new AuthConfigError(\n `cannot get an access token for ${host} from the Databricks CLI: ${detail}`,\n );\n }\n const parsed = JSON.parse(stdout) as {\n access_token: string;\n expiry?: string;\n };\n return {\n value: parsed.access_token,\n ...(parsed.expiry && { expiry: new Date(parsed.expiry) }),\n };\n }),\n ),\n );\n}\n\n/** Credentials that fail on use with `message`, so boot surfaces it clearly. */\nfunction unsupportedCredentials(message: string): Credentials {\n return {\n name: () => \"unsupported\",\n authHeaders: async () => {\n throw new AuthConfigError(message);\n },\n };\n}\n\n/**\n * Map wrapper options onto the modular SDK's `ClientOptions`, reproducing the\n * legacy SDK's auth resolution: explicit token → PAT (the OBO path); profile →\n * profile file; otherwise the service principal from the environment. It carries\n * the privilege-escalation guard — check `token !== undefined` (NOT truthiness)\n * so an explicitly-passed token, even an empty string, pins the PAT path and\n * fails loudly at request time rather than silently falling through to the\n * service-principal env credentials (which would be an OBO privilege escalation).\n */\nfunction mapToClientOptions(opts: WorkspaceClientOptions): ClientOptions {\n const clientOptions: ClientOptions = {};\n // Resolve + scheme-normalize the host the way the legacy SDK did. Explicit\n // `opts.host` wins; otherwise fall back to `DATABRICKS_HOST` (env is where the\n // Apps runtime and dev set it). When a profile is selected without an explicit\n // host, defer to the SDK's profile-file resolution instead of the env.\n const host = normalizeHost(\n opts.host ?? (opts.profile ? undefined : process.env.DATABRICKS_HOST),\n );\n if (host) {\n clientOptions.host = host;\n }\n if (opts.token !== undefined) {\n // Explicit token (this is the OBO path: `asUser` passes the user's token).\n clientOptions.credentials = newPatCredentials(opts.token);\n } else if (opts.profile) {\n clientOptions.profileOptions = { profile: opts.profile };\n clientOptions.credentials = cachedDefaultCredentials({\n profile: opts.profile,\n });\n } else {\n // No token, no profile: authenticate as the service principal from the\n // environment. The SDK's own default chain DOES read the DATABRICKS_* env\n // vars (host, client id/secret, token) — but its M2M strategy feeds the RAW\n // `DATABRICKS_HOST` straight into OAuth token-endpoint discovery, and the\n // Databricks Apps runtime sets that host scheme-less (e.g.\n // `x.cloud.databricks.com`), so discovery fails with `Invalid URL` and every\n // request dies as \"Warehouse readiness check failed\". Resolve the SP here\n // with the scheme-normalized `host` instead: M2M from client id + secret\n // (what Apps injects), else PAT from `DATABRICKS_TOKEN`, else fall through to\n // the SDK default chain (local dev, where a `~/.databrickscfg` host already\n // carries a scheme).\n // `DATABRICKS_AUTH_TYPE`, like in the legacy SDK, pins the strategy.\n const clientId = process.env.DATABRICKS_CLIENT_ID;\n const clientSecret = process.env.DATABRICKS_CLIENT_SECRET;\n const envToken = process.env.DATABRICKS_TOKEN;\n const authType = process.env.DATABRICKS_AUTH_TYPE?.trim() || undefined;\n const allows = (strategy: string) => !authType || authType === strategy;\n if (host && clientId && clientSecret && allows(\"oauth-m2m\")) {\n clientOptions.credentials = withTokenCache(\n newM2mCredentials({ host, clientId, clientSecret }),\n );\n } else if (envToken && allows(\"pat\")) {\n clientOptions.credentials = newPatCredentials(envToken);\n } else if (host && allows(\"databricks-cli\")) {\n // A configured host means ~/.databrickscfg is NOT consulted (legacy\n // rule): a profile's credentials must never be sent to another host.\n clientOptions.credentials = cliHostCredentials(host);\n } else if (!host && !authType) {\n // Local dev with no host anywhere: the profile-based default chain.\n clientOptions.credentials = cachedDefaultCredentials();\n } else {\n clientOptions.credentials = unsupportedCredentials(\n `DATABRICKS_AUTH_TYPE=${authType ?? \"\"} cannot be satisfied: supported types are pat (DATABRICKS_TOKEN), oauth-m2m (DATABRICKS_CLIENT_ID/SECRET) and databricks-cli (\\`databricks auth login\\`).`,\n );\n }\n }\n clientOptions.httpClient = buildHttpClient(opts);\n return clientOptions;\n}\n\n/**\n * Wrap the SDK's default fetch transport to prepend AppKit's product segment\n * (e.g. `databricks-appkit/0.88.1`) to the outgoing `User-Agent`, which\n * Databricks-side dashboards match on.\n *\n * Why the transport and not the SDK's `setProduct`: that is process-global,\n * while the header on the `httpClient` is per-client, and the wrapper ships\n * inside appkit's bundled `dist`, so it also reaches deployed apps. The SDK's\n * own client-info (`sdk-js-core/…`, runtime) is already on `request.headers`,\n * so prepending keeps it intact after AppKit's segment.\n *\n * The wrapper also retries (see `sendWithRetry`). With no product configured\n * (build-time callers) it adds no AppKit segment, like the legacy behavior.\n */\nfunction buildHttpClient(opts: WorkspaceClientOptions): HttpClient {\n const co = opts.clientOptions;\n let appkitUserAgent: string | undefined;\n if (co?.product && co?.productVersion) {\n const segments = [`${co.product}/${co.productVersion}`];\n if (co.userAgentExtra) {\n for (const [key, value] of Object.entries(co.userAgentExtra)) {\n segments.push(`${key}/${String(value)}`);\n }\n }\n appkitUserAgent = segments.join(\" \");\n }\n const base = newFetchHttpClient();\n return {\n send(request) {\n if (appkitUserAgent) {\n const existing = request.headers.get(\"User-Agent\");\n request.headers.set(\n \"User-Agent\",\n existing ? `${appkitUserAgent} ${existing}` : appkitUserAgent,\n );\n }\n return sendWithRetry(base, request);\n },\n };\n}\n\n// The legacy SDK's retry policy: 429, or an error body naming a transient\n// failure; backoff of `attempt` seconds plus jitter, capped at 10s, for up to\n// 300s in total. The modular SDK retries nothing outside long-running waits.\nconst RETRY_TIMEOUT_MS = 300_000;\nconst TRANSIENT_ERROR_MESSAGES = [\n \"com.databricks.backend.manager.util.UnknownWorkerEnvironmentException\",\n \"does not have any associated worker environments\",\n \"There is no worker environment with id\",\n \"Unknown worker environment\",\n \"ClusterNotReadyException\",\n \"connection reset by peer\",\n \"TLS handshake timeout\",\n \"connection refused\",\n \"Unexpected error\",\n \"i/o timeout\",\n];\n\nasync function sendWithRetry(\n base: HttpClient,\n request: Parameters<HttpClient[\"send\"]>[0],\n): ReturnType<HttpClient[\"send\"]> {\n // A streamed body (e.g. a file upload) can only be sent once.\n if (request.body instanceof ReadableStream) return base.send(request);\n const deadline = Date.now() + RETRY_TIMEOUT_MS;\n for (let attempt = 1; ; attempt++) {\n const response = await base.send(request);\n if (response.statusCode < 400) return response;\n const body = new Uint8Array(\n await new Response(response.body).arrayBuffer(),\n );\n const text = new TextDecoder().decode(body);\n const retryable =\n response.statusCode === 429 ||\n TRANSIENT_ERROR_MESSAGES.some((m) => text.includes(m));\n const waitMs = Math.min(attempt * 1000 + 50 + Math.random() * 700, 10_000);\n if (\n !retryable ||\n request.signal?.aborted ||\n Date.now() + waitMs > deadline\n ) {\n return { ...response, body: new Response(body).body };\n }\n await new Promise((resolve) => setTimeout(resolve, waitMs));\n }\n}\n\n/** A raw REST call against the workspace host. */\nexport interface WorkspaceRequest {\n method: string;\n /** Path on the workspace host, e.g. `/api/2.0/preview/scim/v2/Me`. */\n path: string;\n query?: Record<string, string>;\n headers?: Headers;\n body?: HttpRequest[\"body\"];\n signal?: AbortSignal;\n}\n\n/** Host, auth headers, and raw requests resolved exactly like the modular clients. */\nexport interface WorkspaceAuth {\n /** Scheme-normalized workspace host, without a trailing slash. */\n getHost(): Promise<string>;\n /** Set the auth header(s) (e.g. `Authorization`) on `headers`. */\n authenticate(headers: Headers): Promise<void>;\n /**\n * Send a request through the modular transport (AppKit User-Agent + auth).\n * Returns the raw `Response` (body unread, so it can stream); throws\n * {@link ApiError} on a non-2xx status.\n */\n request(req: WorkspaceRequest): Promise<Response>;\n}\n\n/**\n * Build host/credential resolution from {@link mapToClientOptions}, mirroring\n * the modular SDK's `resolveClientConfig` (sdk-warehouses `dist/v1/transport.js`):\n * resolve the profile from config file + env, explicit options win, and fall\n * back to `defaultCredentials` over the resolved profile. Resolved once, lazily;\n * a failed resolution is retried on the next call.\n */\nexport function buildWorkspaceAuth(\n opts: WorkspaceClientOptions,\n): WorkspaceAuth {\n const options = mapToClientOptions(opts);\n const transport = options.httpClient ?? newFetchHttpClient();\n let resolved: Promise<{ host: string; credentials: Credentials }> | undefined;\n const resolveOnce = () => {\n resolved ??= (async () => {\n const profile = await resolve(options.profileOptions);\n const host = normalizeHost(options.host ?? profile.host)?.replace(\n /\\/+$/,\n \"\",\n );\n if (!host) throw new Error(\"Host is required.\");\n const credentials =\n options.credentials ??\n defaultCredentials({ profile: { ...profile, host } });\n return { host, credentials };\n })().catch((e) => {\n resolved = undefined;\n throw e;\n });\n return resolved;\n };\n const authenticate = async (headers: Headers) => {\n const { credentials } = await resolveOnce();\n for (const h of await credentials.authHeaders()) {\n headers.set(h.key, h.value);\n }\n };\n return {\n getHost: async () => (await resolveOnce()).host,\n authenticate,\n async request(req) {\n const url = new URL(req.path, (await resolveOnce()).host);\n for (const [k, v] of Object.entries(req.query ?? {})) {\n url.searchParams.set(k, v);\n }\n const headers = new Headers(req.headers);\n await authenticate(headers);\n const res = await transport.send({\n url: url.toString(),\n method: req.method,\n headers,\n body: req.body,\n signal: req.signal,\n });\n // `Response` rejects any body (even empty) on null-body statuses.\n const nullBody = [204, 205, 304].includes(res.statusCode);\n const response = new Response(nullBody ? null : res.body, {\n status: res.statusCode,\n // The modular transport drops the reason phrase; legacy error messages\n // include it (see toApiError).\n statusText: STATUS_CODES[res.statusCode],\n headers: res.headers,\n });\n if (!response.ok) throw await toApiError(response);\n return response;\n },\n };\n}\n\n/**\n * Same error class the legacy `apiClient.request` threw, so existing catch\n * sites (`instanceof ApiError`, `.statusCode`, `.errorCode`) keep working.\n * Message + code follow the legacy `parseErrorFromResponse` so callers that\n * surface `err.message` (e.g. the serving plugin's 502 body) are unchanged:\n * a body without both `error_code` and `message` (plain text, HTML, or a\n * model-specific error JSON) becomes `Response from server (<status text>) <body>`.\n */\nasync function toApiError(response: Response): Promise<ApiError> {\n const text = await response.text();\n let json:\n | { error_code?: string; message?: string; error?: string; details?: [] }\n | undefined;\n try {\n json = JSON.parse(text);\n } catch {\n // Non-JSON error body (HTML or plain text).\n }\n if (json?.message && json.error_code) {\n return new ApiError(\n json.error || json.message,\n json.error_code,\n response.status,\n json,\n json.details ?? [],\n );\n }\n const html =\n text.match(/<pre>(.*)<\\/pre>/) ??\n text.match(/<title>(Error \\d+.*?)<\\/title>/);\n return new ApiError(\n html\n ? html[1].trim().replace(/([\\s.])*$/, \"\")\n : `Response from server (${response.statusText}) ${text}`,\n response.statusText || \"UNKNOWN\",\n response.status,\n json ?? text,\n [],\n );\n}\n\n/** Build a modular Warehouses client from wrapper options. */\nexport function buildWarehousesClient(\n opts: WorkspaceClientOptions,\n): WarehousesClient {\n return new WarehousesClient(mapToClientOptions(opts));\n}\n\n/** Build a modular Statement Execution client from wrapper options. */\nexport function buildStatementExecutionClient(\n opts: WorkspaceClientOptions,\n): StatementExecutionClient {\n return new StatementExecutionClient(mapToClientOptions(opts));\n}\n\n// The modular SDK's error class, for tests that must throw what typed calls\n// really throw (status in `httpStatusCode`, not the wrapper's `statusCode`).\nexport { ApiError as ModularApiError } from \"@databricks/sdk-core/apierror\";\n\n/**\n * Build a modular SCIM client from wrapper options. Backs the facade's\n * `currentUser` accessor: legacy `currentUser.me()` is `ScimClient.me({})`.\n */\nexport function buildScimClient(opts: WorkspaceClientOptions): ScimClient {\n return new ScimClient(mapToClientOptions(opts));\n}\n\n/** Build a modular Apps client from wrapper options. */\nexport function buildAppsClient(opts: WorkspaceClientOptions): AppsClient {\n return lazyClient(\n () => import(\"@databricks/sdk-apps/v1\").then((m) => m.AppsClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Defer loading an SDK client's module until its first method call, so app\n * boot doesn't pay for clients it never uses. Generated methods return either\n * a Promise or (`*Iter`) an AsyncGenerator, so each proxied call returns the\n * pending result as a Promise that is also async-iterable.\n */\nfunction lazyClient<T extends object>(\n load: () => Promise<new (options: ClientOptions) => T>,\n options: ClientOptions,\n): T {\n let client: Promise<T> | undefined;\n return new Proxy({} as T, {\n get(_target, prop) {\n // Not thenable, or `await facade.someClient` would hang.\n if (typeof prop === \"symbol\" || prop === \"then\") return undefined;\n return (...args: unknown[]) => {\n client ??= load().then((Client) => new Client(options));\n const result = client.then((c) =>\n (c as Record<string, (...a: unknown[]) => unknown>)[prop](...args),\n );\n return Object.assign(result, {\n async *[Symbol.asyncIterator]() {\n yield* (await result) as AsyncIterable<unknown>;\n },\n });\n };\n },\n });\n}\n\n/** Build a modular Genie client from wrapper options. */\nexport function buildGenieClient(opts: WorkspaceClientOptions): GenieClient {\n return lazyClient(\n () => import(\"@databricks/sdk-genie/v1\").then((m) => m.GenieClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Jobs (API 2.2) client from wrapper options. */\nexport function buildJobsClient(opts: WorkspaceClientOptions): JobsClient {\n return lazyClient(\n () => import(\"@databricks/sdk-jobs/v2\").then((m) => m.JobsClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Build a modular Files client from wrapper options. `getFileMetadata` is not\n * used: its generated HEAD call parses the (empty) body and drops the response\n * headers that carry the metadata, so the connector issues that HEAD through\n * {@link WorkspaceAuth.request} instead.\n */\nexport function buildFilesClient(opts: WorkspaceClientOptions): FilesClient {\n return lazyClient(\n () => import(\"@databricks/sdk-files/v2\").then((m) => m.FilesClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Build a modular Vector Search client from wrapper options. Query calls rely\n * on the sdk-vectorsearch pnpm patch (`debugLevel` / `debugInfo`, `bigint` rows).\n */\nexport function buildVectorSearchClient(\n opts: WorkspaceClientOptions,\n): VectorSearchClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-vectorsearch/v1\").then(\n (m) => m.VectorSearchClient,\n ),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Model Serving (serving endpoints) client from wrapper options. */\nexport function buildModelServingClient(\n opts: WorkspaceClientOptions,\n): ModelServingClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-modelserving/v1\").then(\n (m) => m.ModelServingClient,\n ),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular MLflow Experiments client from wrapper options. */\nexport function buildExperimentsClient(\n opts: WorkspaceClientOptions,\n): ExperimentsClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-experiments/v1\").then((m) => m.ExperimentsClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Tables client from wrapper options. */\nexport function buildTablesClient(opts: WorkspaceClientOptions): TablesClient {\n return lazyClient(\n () => import(\"@databricks/sdk-uc-tables/v1\").then((m) => m.TablesClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Volumes client from wrapper options. */\nexport function buildVolumesClient(\n opts: WorkspaceClientOptions,\n): VolumesClient {\n return lazyClient(\n () => import(\"@databricks/sdk-uc-volumes/v1\").then((m) => m.VolumesClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Functions client from wrapper options. */\nexport function buildFunctionsClient(\n opts: WorkspaceClientOptions,\n): FunctionsClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-uc-functions/v1\").then((m) => m.FunctionsClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Connections client from wrapper options. */\nexport function buildConnectionsClient(\n opts: WorkspaceClientOptions,\n): ConnectionsClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-uc-connections/v1\").then(\n (m) => m.ConnectionsClient,\n ),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Lakebase (provisioned) Database client from wrapper options. */\nexport function buildDatabaseClient(\n opts: WorkspaceClientOptions,\n): DatabaseClient {\n return lazyClient(\n () => import(\"@databricks/sdk-database/v1\").then((m) => m.DatabaseClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Resolve a `~/.databrickscfg` profile (+ env overlay, unless disabled). Exposed\n * so the CLI can read a profile offline without importing the SDK directly.\n */\nexport { resolve as resolveProfile } from \"@databricks/sdk-core/profiles\";\n\n/**\n * Build a modular Lakebase Postgres (autoscaling: projects, branches,\n * endpoints) client from wrapper options. Distinct from the provisioned\n * `/api/2.0/database` instance API.\n */\nexport function buildPostgresClient(\n opts: WorkspaceClientOptions,\n): PostgresClient {\n return lazyClient(\n () => import(\"@databricks/sdk-postgres/v1\").then((m) => m.PostgresClient),\n mapToClientOptions(opts),\n );\n}\n\n// ── Client type re-exports (for the facade accessor types) ───────────────\nexport type { DatabaseClient } from \"@databricks/sdk-database/v1\";\nexport type { ExperimentsClient } from \"@databricks/sdk-experiments/v1\";\nexport type { AppsClient } from \"@databricks/sdk-apps/v1\";\nexport type { FilesClient } from \"@databricks/sdk-files/v2\";\nexport type {\n DirectoryEntry as FilesDirectoryEntry,\n DownloadFileResponse as FilesDownloadResponse,\n} from \"@databricks/sdk-files/v2\";\nexport type { GenieClient } from \"@databricks/sdk-genie/v1\";\nexport type { JobsClient } from \"@databricks/sdk-jobs/v2\";\nexport type { ModelServingClient } from \"@databricks/sdk-modelserving/v1\";\nexport type { PostgresClient } from \"@databricks/sdk-postgres/v1\";\nexport type { ScimClient } from \"@databricks/sdk-scim/v1\";\nexport type { StatementExecutionClient } from \"@databricks/sdk-statementexecution/v1\";\nexport type { FunctionsClient } from \"@databricks/sdk-uc-functions/v1\";\nexport type { ConnectionsClient } from \"@databricks/sdk-uc-connections/v1\";\nexport type { TablesClient } from \"@databricks/sdk-uc-tables/v1\";\nexport type { VolumesClient } from \"@databricks/sdk-uc-volumes/v1\";\nexport type { VectorSearchClient } from \"@databricks/sdk-vectorsearch/v1\";\nexport type { WarehousesClient } from \"@databricks/sdk-warehouses/v1\";\n\n// ── Model type re-exports ────────────────────────────────────────────────\n// AppKit modules import request/response/enum types from the wrapper rather\n// than the SDK, so the import boundary holds. Type-only: the connector compares\n// state against string literals, which satisfy the SDK's `Enum | (string & {})`\n// field unions — no runtime enum values needed.\nexport type {\n ConnectionInfo,\n GetConnectionRequest,\n ListConnectionsRequest,\n ListConnectionsResponse,\n} from \"@databricks/sdk-uc-connections/v1\";\nexport type {\n ColumnInfo,\n Disposition,\n ExecuteStatementRequest,\n ExternalLink,\n Format,\n ResultData,\n ResultManifest,\n Schema,\n ServiceError,\n StatementParameter,\n StatementResponse,\n StatementStatus,\n StatementStatus_State,\n} from \"@databricks/sdk-statementexecution/v1\";\nexport type {\n DatabaseCredential,\n DatabaseInstance,\n GenerateDatabaseCredentialRequest,\n ListDatabaseInstancesRequest,\n ListDatabaseInstancesResponse,\n} from \"@databricks/sdk-database/v1\";\nexport type {\n App,\n ListAppsRequest,\n ListAppsResponse,\n} from \"@databricks/sdk-apps/v1\";\nexport type {\n GenieGetMessageQueryResultResponse,\n GenieMessage,\n} from \"@databricks/sdk-genie/v1\";\nexport type {\n FunctionInfo,\n GetFunctionRequest,\n} from \"@databricks/sdk-uc-functions/v1\";\nexport type {\n Experiment,\n ListExperimentsRequest,\n ListExperimentsResponse,\n} from \"@databricks/sdk-experiments/v1\";\nexport type {\n BaseRun,\n CancelRunRequest,\n GetJobRequest,\n GetJobResponse,\n GetRunOutputRequest,\n GetRunOutputResponse,\n GetRunRequest,\n GetRunResponse,\n ListRunsRequest,\n RunNowRequest,\n RunNowResponse,\n SubmitRunRequest,\n SubmitRunResponse,\n} from \"@databricks/sdk-jobs/v2\";\nexport type {\n GetInferenceEndpointRequest,\n InferenceEndpoint,\n InferenceEndpointDetailed,\n ListInferenceEndpointsRequest,\n ListInferenceEndpointsResponse,\n} from \"@databricks/sdk-modelserving/v1\";\nexport type {\n EndpointHealth,\n EndpointInfo,\n EndpointState,\n GetWarehouseResponse,\n} from \"@databricks/sdk-warehouses/v1\";\nexport type {\n QueryVectorIndexRequest,\n QueryVectorIndexResponse,\n} from \"@databricks/sdk-vectorsearch/v1\";\nexport type {\n GetVolumeRequest,\n VolumeInfo,\n} from \"@databricks/sdk-uc-volumes/v1\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,SAAS,cAAc,MAA8C;CACnE,MAAM,UAAU,MAAM,MAAM;AAC5B,KAAI,CAAC,QAAS,QAAO;AACrB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,MAAM,EAAE,YAAY,EACnE,mBAAmB,KAAK,CACzB;;;;;;AAOH,SAAgB,wBACd,MACoB;AACpB,QAAO,iBAEH,OAAO,mCAAmC,MACvC,MAAM,EAAE,mBACV,EACH,mBAAmB,KAAK,CACzB;;;AAIH,SAAgB,wBACd,MACoB;AACpB,QAAO,iBAEH,OAAO,mCAAmC,MACvC,MAAM,EAAE,mBACV,EACH,mBAAmB,KAAK,CACzB;;;AAIH,SAAgB,uBACd,MACmB;AACnB,QAAO,iBAEH,OAAO,kCAAkC,MAAM,MAAM,EAAE,kBAAkB,EAC3E,mBAAmB,KAAK,CACzB;;;AAIH,SAAgB,kBAAkB,MAA4C;AAC5E,QAAO,iBACC,OAAO,gCAAgC,MAAM,MAAM,EAAE,aAAa,EACxE,mBAAmB,KAAK,CACzB;;;AAIH,SAAgB,mBACd,MACe;AACf,QAAO,iBACC,OAAO,iCAAiC,MAAM,MAAM,EAAE,cAAc,EAC1E,mBAAmB,KAAK,CACzB;;;AAIH,SAAgB,qBACd,MACiB;AACjB,QAAO,iBAEH,OAAO,mCAAmC,MAAM,MAAM,EAAE,gBAAgB,EAC1E,mBAAmB,KAAK,CACzB;;;AAIH,SAAgB,uBACd,MACmB;AACnB,QAAO,iBAEH,OAAO,qCAAqC,MACzC,MAAM,EAAE,kBACV,EACH,mBAAmB,KAAK,CACzB;;;AAIH,SAAgB,oBACd,MACgB;AAChB,QAAO,iBACC,OAAO,+BAA+B,MAAM,MAAM,EAAE,eAAe,EACzE,mBAAmB,KAAK,CACzB;;;;;;;AAcH,SAAgB,oBACd,MACgB;AAChB,QAAO,iBACC,OAAO,+BAA+B,MAAM,MAAM,EAAE,eAAe,EACzE,mBAAmB,KAAK,CACzB"}
|
|
1
|
+
{"version":3,"file":"modular.js","names":["ApiError"],"sources":["../../src/workspace-client/modular.ts"],"sourcesContent":["/**\n * The single module allowed to import the modular `@databricks/sdk-*` SDK\n * directly — the new-SDK sibling of {@link ./legacy.ts}. Every other AppKit\n * module reaches these clients through the {@link WorkspaceClient} facade and\n * the type re-exports below, so the modular SDK stays isolated exactly like the\n * legacy one (the oxlint `no-restricted-imports` boundary walls `@databricks/sdk-*`\n * off everywhere outside `packages/shared/src/workspace-client/`).\n *\n * Migrated services are built here as per-service clients; the facade delegates\n * their accessors to these instead of the legacy monolithic client. Currently\n * `warehouses`, `statementExecution`, `currentUser` (SCIM), `genie`, `jobs`,\n * `files`, `vectorSearch`, `tables`, `modelServing`, `volumes`, `functions`,\n * `connections`, `database`, `postgres`, `experiments` and `apps` are\n * migrated, plus the auth + raw-request seam ({@link buildWorkspaceAuth}).\n * Only `servingEndpoints`, `config` and `apiClient` still route through\n * `legacy.ts`.\n *\n * NOTE: statementExecution relies on a pinned pnpm patch\n * (`patches/@databricks__sdk-statementexecution@0.52.0.patch`) that restores the\n * undocumented Reyden `attachment` response field, which the SDK's generated\n * unmarshal transform would otherwise strip.\n *\n * NOTE: vectorSearch relies on a pinned pnpm patch\n * (`patches/@databricks__sdk-vectorsearch@0.51.0.patch`): it adds the\n * undocumented query `debug_level` request / `debug_info` response fields (the\n * source of ai-search `queryTimeMs`), and lets row values be `bigint`, since the\n * SDK parses with json-bigint and the unpatched schema rejects ints over 2^53.\n *\n * NOTE: genie relies on a pinned pnpm patch\n * (`patches/@databricks__sdk-genie@0.54.0.patch`): the generated model types the\n * query result's `data_array` as protobuf `ListValue[]` (`{ values: [...] }`), but\n * the API returns plain `JSON_ARRAY` rows (`[[\"a\", null], ...]`), so the unmarshal\n * schema rejected every real query result. The patch restores `(string | null)[][]`.\n */\nimport { execFile } from \"node:child_process\";\nimport { STATUS_CODES } from \"node:http\";\nimport { promisify } from \"node:util\";\n\nimport type { AppsClient } from \"@databricks/sdk-apps/v1\";\nimport {\n type Credentials,\n newTokenCredentials,\n type Token,\n type TokenCredentials,\n tokenProviderFn,\n} from \"@databricks/sdk-auth\";\nimport {\n DefaultCredentialsError,\n defaultCredentials,\n M2mCredentialsError,\n newM2mCredentials,\n newPatCredentials,\n newU2mCredentials,\n PatCredentialsError,\n U2mCredentialsError,\n} from \"@databricks/sdk-auth/credentials\";\nimport {\n type HttpClient,\n type HttpRequest,\n newFetchHttpClient,\n} from \"@databricks/sdk-core/http\";\nimport { type ProfileOptions, resolve } from \"@databricks/sdk-core/profiles\";\nimport type { DatabaseClient } from \"@databricks/sdk-database/v1\";\nimport type { ExperimentsClient } from \"@databricks/sdk-experiments/v1\";\nimport type { FilesClient } from \"@databricks/sdk-files/v2\";\nimport type { GenieClient } from \"@databricks/sdk-genie/v1\";\nimport type { JobsClient } from \"@databricks/sdk-jobs/v2\";\nimport type { ModelServingClient } from \"@databricks/sdk-modelserving/v1\";\nimport type { ClientOptions } from \"@databricks/sdk-options/client\";\nimport type { PostgresClient } from \"@databricks/sdk-postgres/v1\";\nimport { ScimClient } from \"@databricks/sdk-scim/v1\";\nimport { StatementExecutionClient } from \"@databricks/sdk-statementexecution/v1\";\nimport type { ConnectionsClient } from \"@databricks/sdk-uc-connections/v1\";\nimport type { FunctionsClient } from \"@databricks/sdk-uc-functions/v1\";\nimport type { TablesClient } from \"@databricks/sdk-uc-tables/v1\";\nimport type { VolumesClient } from \"@databricks/sdk-uc-volumes/v1\";\nimport type { VectorSearchClient } from \"@databricks/sdk-vectorsearch/v1\";\nimport { WarehousesClient } from \"@databricks/sdk-warehouses/v1\";\n\nimport { ApiError } from \"./errors\";\nimport type { WorkspaceClientOptions } from \"./options\";\n\n/**\n * Prepend `https://` to a scheme-less host. The legacy SDK normalized the host\n * this way; the modular SDK does NOT — it passes the host straight into `fetch`,\n * so a bare `DATABRICKS_HOST=my-workspace.cloud.databricks.com` (the common form,\n * and what the Databricks Apps runtime sets) yields `TypeError: Invalid URL`.\n */\nfunction normalizeHost(host: string | undefined): string | undefined {\n const trimmed = host?.trim();\n if (!trimmed) return undefined;\n return /^https?:\\/\\//i.test(trimmed) ? trimmed : `https://${trimmed}`;\n}\n\n// Same margin as the legacy SDK: refresh 40s early, since Azure Databricks\n// rejects tokens that expire in 30s or less.\nconst TOKEN_REFRESH_MARGIN_MS = 40_000;\n\n/**\n * Cache a token until shortly before it expires. The modular `newM2mCredentials`\n * caches only the token endpoint and mints a fresh OAuth token on EVERY request;\n * the legacy SDK reused it until expiry. Concurrent callers share one in-flight\n * fetch. Like the legacy SDK, a token without an expiry is reused indefinitely.\n */\nfunction withTokenCache(credentials: TokenCredentials): TokenCredentials {\n let current: Token | undefined;\n let inflight: Promise<Token> | undefined;\n const isFresh = (t: Token) =>\n t.expiry === undefined ||\n t.expiry.getTime() - TOKEN_REFRESH_MARGIN_MS > Date.now();\n return newTokenCredentials(\n credentials.name(),\n tokenProviderFn(async () => {\n if (current && isFresh(current)) return current;\n inflight ??= credentials\n .token()\n .then((t) => (current = t))\n .finally(() => {\n inflight = undefined;\n });\n return inflight;\n }),\n );\n}\n\n/**\n * The SDK default chain (profile / `~/.databrickscfg`), with the token cache the\n * chain lacks: its CLI strategy shells out to `databricks auth token` and its\n * M2M strategy mints a new OAuth token on EVERY request. `DefaultCredentials`\n * hides the token behind `authHeaders()`, so mirror its strategy order (PAT →\n * M2M → CLI) to get a cacheable `TokenCredentials`. A profile `authType` naming\n * one of these (`databricks auth login` writes `databricks-cli`) pins that\n * strategy; other auth types and `groupId` keep the SDK's own (uncached) logic.\n * TODO: drop once sdk-auth caches tokens in its M2M and CLI credentials.\n */\nfunction cachedDefaultCredentials(\n profileOptions?: ProfileOptions,\n): Credentials {\n const select = async (): Promise<Credentials> => {\n const profile = await resolve(profileOptions);\n // Same as env M2M: OAuth discovery needs a scheme, which a profile may omit.\n const host = normalizeHost(profile.host)?.replace(/\\/+$/, \"\");\n const { name, token, clientId, clientSecret, authType } = profile;\n const allows = (strategy: string) => !authType || authType === strategy;\n if (host && !profile.groupId) {\n if (token && allows(\"pat\")) return newPatCredentials(token.value);\n if (clientId && clientSecret && allows(\"oauth-m2m\")) {\n return withTokenCache(\n newM2mCredentials({\n host,\n clientId,\n clientSecret: clientSecret.value,\n ...(profile.accountId !== undefined && {\n accountId: profile.accountId,\n }),\n }),\n );\n }\n if (name && allows(\"databricks-cli\")) {\n return withTokenCache(\n newU2mCredentials({\n profile: name,\n ...(profile.databricksCliPath !== undefined && {\n cliPath: profile.databricksCliPath,\n }),\n }),\n );\n }\n }\n return defaultCredentials({\n profile: { ...profile, ...(host && { host }) },\n });\n };\n let selected: Promise<Credentials> | undefined;\n return {\n name: () => \"default\",\n async authHeaders() {\n selected ??= select().catch((e) => {\n selected = undefined;\n throw e;\n });\n return (await selected).authHeaders();\n },\n };\n}\n\nconst execFileAsync = promisify(execFile);\n\n/** Auth could not be configured (missing or unsupported credentials). */\nexport class AuthConfigError extends Error {\n override name = \"AuthConfigError\";\n}\n\n/** Whether `e` means auth isn't set up, from AppKit or the modular SDK. */\nexport function isAuthConfigError(e: unknown): e is Error {\n return (\n e instanceof AuthConfigError ||\n e instanceof DefaultCredentialsError ||\n e instanceof M2mCredentialsError ||\n e instanceof PatCredentialsError ||\n e instanceof U2mCredentialsError\n );\n}\n\n/**\n * Databricks CLI auth for a host, not a profile: what the legacy SDK used when\n * only a host was configured. The modular CLI strategy needs a profile name.\n */\nfunction cliHostCredentials(host: string): TokenCredentials {\n return withTokenCache(\n newTokenCredentials(\n \"databricks-cli\",\n tokenProviderFn(async () => {\n let stdout: string;\n try {\n ({ stdout } = await execFileAsync(\"databricks\", [\n \"auth\",\n \"token\",\n \"--host\",\n host,\n ]));\n } catch (e) {\n const err = e as { stderr?: unknown; message?: string };\n const detail = String(err.stderr ?? err.message ?? e).trim();\n throw new AuthConfigError(\n `cannot get an access token for ${host} from the Databricks CLI: ${detail}`,\n );\n }\n const parsed = JSON.parse(stdout) as {\n access_token: string;\n expiry?: string;\n };\n return {\n value: parsed.access_token,\n ...(parsed.expiry && { expiry: new Date(parsed.expiry) }),\n };\n }),\n ),\n );\n}\n\n/** Credentials that fail on use with `message`, so boot surfaces it clearly. */\nfunction unsupportedCredentials(message: string): Credentials {\n return {\n name: () => \"unsupported\",\n authHeaders: async () => {\n throw new AuthConfigError(message);\n },\n };\n}\n\n/**\n * Map wrapper options onto the modular SDK's `ClientOptions`, reproducing the\n * legacy SDK's auth resolution: explicit token → PAT (the OBO path); profile →\n * profile file; otherwise the service principal from the environment. It carries\n * the privilege-escalation guard — check `token !== undefined` (NOT truthiness)\n * so an explicitly-passed token, even an empty string, pins the PAT path and\n * fails loudly at request time rather than silently falling through to the\n * service-principal env credentials (which would be an OBO privilege escalation).\n */\nfunction mapToClientOptions(opts: WorkspaceClientOptions): ClientOptions {\n const clientOptions: ClientOptions = {};\n // Resolve + scheme-normalize the host the way the legacy SDK did. Explicit\n // `opts.host` wins; otherwise fall back to `DATABRICKS_HOST` (env is where the\n // Apps runtime and dev set it). When a profile is selected without an explicit\n // host, defer to the SDK's profile-file resolution instead of the env.\n const host = normalizeHost(\n opts.host ?? (opts.profile ? undefined : process.env.DATABRICKS_HOST),\n );\n if (host) {\n clientOptions.host = host;\n }\n if (opts.token !== undefined) {\n // Explicit token (this is the OBO path: `asUser` passes the user's token).\n clientOptions.credentials = newPatCredentials(opts.token);\n } else if (opts.profile) {\n clientOptions.profileOptions = { profile: opts.profile };\n clientOptions.credentials = cachedDefaultCredentials({\n profile: opts.profile,\n });\n } else {\n // No token, no profile: authenticate as the service principal from the\n // environment. The SDK's own default chain DOES read the DATABRICKS_* env\n // vars (host, client id/secret, token) — but its M2M strategy feeds the RAW\n // `DATABRICKS_HOST` straight into OAuth token-endpoint discovery, and the\n // Databricks Apps runtime sets that host scheme-less (e.g.\n // `x.cloud.databricks.com`), so discovery fails with `Invalid URL` and every\n // request dies as \"Warehouse readiness check failed\". Resolve the SP here\n // with the scheme-normalized `host` instead: M2M from client id + secret\n // (what Apps injects), else PAT from `DATABRICKS_TOKEN`, else fall through to\n // the SDK default chain (local dev, where a `~/.databrickscfg` host already\n // carries a scheme).\n // `DATABRICKS_AUTH_TYPE`, like in the legacy SDK, pins the strategy.\n const clientId = process.env.DATABRICKS_CLIENT_ID;\n const clientSecret = process.env.DATABRICKS_CLIENT_SECRET;\n const envToken = process.env.DATABRICKS_TOKEN;\n const authType = process.env.DATABRICKS_AUTH_TYPE?.trim() || undefined;\n const allows = (strategy: string) => !authType || authType === strategy;\n if (host && clientId && clientSecret && allows(\"oauth-m2m\")) {\n clientOptions.credentials = withTokenCache(\n newM2mCredentials({ host, clientId, clientSecret }),\n );\n } else if (envToken && allows(\"pat\")) {\n clientOptions.credentials = newPatCredentials(envToken);\n } else if (host && allows(\"databricks-cli\")) {\n // A configured host means ~/.databrickscfg is NOT consulted (legacy\n // rule): a profile's credentials must never be sent to another host.\n clientOptions.credentials = cliHostCredentials(host);\n } else if (!host && !authType) {\n // Local dev with no host anywhere: the profile-based default chain.\n clientOptions.credentials = cachedDefaultCredentials();\n } else {\n clientOptions.credentials = unsupportedCredentials(\n `DATABRICKS_AUTH_TYPE=${authType ?? \"\"} cannot be satisfied: supported types are pat (DATABRICKS_TOKEN), oauth-m2m (DATABRICKS_CLIENT_ID/SECRET) and databricks-cli (\\`databricks auth login\\`).`,\n );\n }\n }\n clientOptions.httpClient = buildHttpClient(opts);\n return clientOptions;\n}\n\n/**\n * Wrap the SDK's default fetch transport to prepend AppKit's product segment\n * (e.g. `databricks-appkit/0.88.1`) to the outgoing `User-Agent`, which\n * Databricks-side dashboards match on.\n *\n * Why the transport and not the SDK's `setProduct`: that is process-global,\n * while the header on the `httpClient` is per-client, and the wrapper ships\n * inside appkit's bundled `dist`, so it also reaches deployed apps. The SDK's\n * own client-info (`sdk-js-core/…`, runtime) is already on `request.headers`,\n * so prepending keeps it intact after AppKit's segment.\n *\n * The wrapper also retries (see `sendWithRetry`). With no product configured\n * (build-time callers) it adds no AppKit segment, like the legacy behavior.\n */\nfunction buildHttpClient(opts: WorkspaceClientOptions): HttpClient {\n const co = opts.clientOptions;\n let appkitUserAgent: string | undefined;\n if (co?.product && co?.productVersion) {\n const segments = [`${co.product}/${co.productVersion}`];\n if (co.userAgentExtra) {\n for (const [key, value] of Object.entries(co.userAgentExtra)) {\n segments.push(`${key}/${String(value)}`);\n }\n }\n appkitUserAgent = segments.join(\" \");\n }\n const base = newFetchHttpClient();\n return {\n send(request) {\n if (appkitUserAgent) {\n const existing = request.headers.get(\"User-Agent\");\n request.headers.set(\n \"User-Agent\",\n existing ? `${appkitUserAgent} ${existing}` : appkitUserAgent,\n );\n }\n return sendWithRetry(base, request);\n },\n };\n}\n\n// The legacy SDK's retry policy: 429, or an error body naming a transient\n// failure; backoff of `attempt` seconds plus jitter, capped at 10s, for up to\n// 300s in total. The modular SDK retries nothing outside long-running waits.\nconst RETRY_TIMEOUT_MS = 300_000;\nconst TRANSIENT_ERROR_MESSAGES = [\n \"com.databricks.backend.manager.util.UnknownWorkerEnvironmentException\",\n \"does not have any associated worker environments\",\n \"There is no worker environment with id\",\n \"Unknown worker environment\",\n \"ClusterNotReadyException\",\n \"connection reset by peer\",\n \"TLS handshake timeout\",\n \"connection refused\",\n \"Unexpected error\",\n \"i/o timeout\",\n];\n\nasync function sendWithRetry(\n base: HttpClient,\n request: Parameters<HttpClient[\"send\"]>[0],\n): ReturnType<HttpClient[\"send\"]> {\n // A streamed body (e.g. a file upload) can only be sent once.\n if (request.body instanceof ReadableStream) return base.send(request);\n const deadline = Date.now() + RETRY_TIMEOUT_MS;\n for (let attempt = 1; ; attempt++) {\n const response = await base.send(request);\n if (response.statusCode < 400) return response;\n const body = new Uint8Array(\n await new Response(response.body).arrayBuffer(),\n );\n const text = new TextDecoder().decode(body);\n const retryable =\n response.statusCode === 429 ||\n TRANSIENT_ERROR_MESSAGES.some((m) => text.includes(m));\n const waitMs = Math.min(attempt * 1000 + 50 + Math.random() * 700, 10_000);\n if (!retryable || Date.now() + waitMs > deadline) {\n return { ...response, body: new Response(body).body };\n }\n await abortableWait(waitMs, request.signal);\n }\n}\n\n// Waits `ms`, or rejects with `signal.reason` as soon as `signal` aborts, like\n// the SDK's own retry sleep, so a cancel or timeout ends the backoff and still\n// reaches the caller as that abort.\nfunction abortableWait(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(signal.reason);\n return;\n }\n const timer = setTimeout(() => {\n signal?.removeEventListener(\"abort\", onAbort);\n resolve();\n }, ms);\n const onAbort = () => {\n clearTimeout(timer);\n reject(signal?.reason);\n };\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n\n/** A raw REST call against the workspace host. */\nexport interface WorkspaceRequest {\n method: string;\n /** Path on the workspace host, e.g. `/api/2.0/preview/scim/v2/Me`. */\n path: string;\n query?: Record<string, string>;\n headers?: Headers;\n body?: HttpRequest[\"body\"];\n signal?: AbortSignal;\n}\n\n/** Host, auth headers, and raw requests resolved exactly like the modular clients. */\nexport interface WorkspaceAuth {\n /** Scheme-normalized workspace host, without a trailing slash. */\n getHost(): Promise<string>;\n /** Set the auth header(s) (e.g. `Authorization`) on `headers`. */\n authenticate(headers: Headers): Promise<void>;\n /**\n * Send a request through the modular transport (AppKit User-Agent + auth).\n * Returns the raw `Response` (body unread, so it can stream); throws\n * {@link ApiError} on a non-2xx status.\n */\n request(req: WorkspaceRequest): Promise<Response>;\n}\n\n/**\n * Build host/credential resolution from {@link mapToClientOptions}, mirroring\n * the modular SDK's `resolveClientConfig` (sdk-warehouses `dist/v1/transport.js`):\n * resolve the profile from config file + env, explicit options win, and fall\n * back to `defaultCredentials` over the resolved profile. Resolved once, lazily;\n * a failed resolution is retried on the next call.\n */\nexport function buildWorkspaceAuth(\n opts: WorkspaceClientOptions,\n): WorkspaceAuth {\n const options = mapToClientOptions(opts);\n const transport = options.httpClient ?? newFetchHttpClient();\n let resolved: Promise<{ host: string; credentials: Credentials }> | undefined;\n const resolveOnce = () => {\n resolved ??= (async () => {\n const profile = await resolve(options.profileOptions);\n const host = normalizeHost(options.host ?? profile.host)?.replace(\n /\\/+$/,\n \"\",\n );\n if (!host) throw new Error(\"Host is required.\");\n const credentials =\n options.credentials ??\n defaultCredentials({ profile: { ...profile, host } });\n return { host, credentials };\n })().catch((e) => {\n resolved = undefined;\n throw e;\n });\n return resolved;\n };\n const authenticate = async (headers: Headers) => {\n const { credentials } = await resolveOnce();\n for (const h of await credentials.authHeaders()) {\n headers.set(h.key, h.value);\n }\n };\n return {\n getHost: async () => (await resolveOnce()).host,\n authenticate,\n async request(req) {\n const url = new URL(req.path, (await resolveOnce()).host);\n for (const [k, v] of Object.entries(req.query ?? {})) {\n url.searchParams.set(k, v);\n }\n const headers = new Headers(req.headers);\n await authenticate(headers);\n const res = await transport.send({\n url: url.toString(),\n method: req.method,\n headers,\n body: req.body,\n signal: req.signal,\n });\n // `Response` rejects any body (even empty) on null-body statuses.\n const nullBody = [204, 205, 304].includes(res.statusCode);\n const response = new Response(nullBody ? null : res.body, {\n status: res.statusCode,\n // The modular transport drops the reason phrase; legacy error messages\n // include it (see toApiError).\n statusText: STATUS_CODES[res.statusCode],\n headers: res.headers,\n });\n if (!response.ok) throw await toApiError(response);\n return response;\n },\n };\n}\n\n/**\n * Same error class the legacy `apiClient.request` threw, so existing catch\n * sites (`instanceof ApiError`, `.statusCode`, `.errorCode`) keep working.\n * Message + code follow the legacy `parseErrorFromResponse` so callers that\n * surface `err.message` (e.g. the serving plugin's 502 body) are unchanged:\n * a body without both `error_code` and `message` (plain text, HTML, or a\n * model-specific error JSON) becomes `Response from server (<status text>) <body>`.\n */\nasync function toApiError(response: Response): Promise<ApiError> {\n const text = await response.text();\n let json:\n | { error_code?: string; message?: string; error?: string; details?: [] }\n | undefined;\n try {\n json = JSON.parse(text);\n } catch {\n // Non-JSON error body (HTML or plain text).\n }\n if (json?.message && json.error_code) {\n return new ApiError(\n json.error || json.message,\n json.error_code,\n response.status,\n json,\n json.details ?? [],\n );\n }\n const html =\n text.match(/<pre>(.*)<\\/pre>/) ??\n text.match(/<title>(Error \\d+.*?)<\\/title>/);\n return new ApiError(\n html\n ? html[1].trim().replace(/([\\s.])*$/, \"\")\n : `Response from server (${response.statusText}) ${text}`,\n response.statusText || \"UNKNOWN\",\n response.status,\n json ?? text,\n [],\n );\n}\n\n/** Build a modular Warehouses client from wrapper options. */\nexport function buildWarehousesClient(\n opts: WorkspaceClientOptions,\n): WarehousesClient {\n return new WarehousesClient(mapToClientOptions(opts));\n}\n\n/** Build a modular Statement Execution client from wrapper options. */\nexport function buildStatementExecutionClient(\n opts: WorkspaceClientOptions,\n): StatementExecutionClient {\n return new StatementExecutionClient(mapToClientOptions(opts));\n}\n\n// The modular SDK's error class, for tests that must throw what typed calls\n// really throw (status in `httpStatusCode`, not the wrapper's `statusCode`).\nexport { ApiError as ModularApiError } from \"@databricks/sdk-core/apierror\";\n\n/**\n * Build a modular SCIM client from wrapper options. Backs the facade's\n * `currentUser` accessor: legacy `currentUser.me()` is `ScimClient.me({})`.\n */\nexport function buildScimClient(opts: WorkspaceClientOptions): ScimClient {\n return new ScimClient(mapToClientOptions(opts));\n}\n\n/** Build a modular Apps client from wrapper options. */\nexport function buildAppsClient(opts: WorkspaceClientOptions): AppsClient {\n return lazyClient(\n () => import(\"@databricks/sdk-apps/v1\").then((m) => m.AppsClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Defer loading an SDK client's module until its first method call, so app\n * boot doesn't pay for clients it never uses. Generated methods return either\n * a Promise or (`*Iter`) an AsyncGenerator, so each proxied call returns the\n * pending result as a Promise that is also async-iterable.\n */\nfunction lazyClient<T extends object>(\n load: () => Promise<new (options: ClientOptions) => T>,\n options: ClientOptions,\n): T {\n let client: Promise<T> | undefined;\n return new Proxy({} as T, {\n get(_target, prop) {\n // Not thenable, or `await facade.someClient` would hang.\n if (typeof prop === \"symbol\" || prop === \"then\") return undefined;\n return (...args: unknown[]) => {\n client ??= load().then((Client) => new Client(options));\n const result = client.then((c) =>\n (c as Record<string, (...a: unknown[]) => unknown>)[prop](...args),\n );\n return Object.assign(result, {\n async *[Symbol.asyncIterator]() {\n yield* (await result) as AsyncIterable<unknown>;\n },\n });\n };\n },\n });\n}\n\n/** Build a modular Genie client from wrapper options. */\nexport function buildGenieClient(opts: WorkspaceClientOptions): GenieClient {\n return lazyClient(\n () => import(\"@databricks/sdk-genie/v1\").then((m) => m.GenieClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Jobs (API 2.2) client from wrapper options. */\nexport function buildJobsClient(opts: WorkspaceClientOptions): JobsClient {\n return lazyClient(\n () => import(\"@databricks/sdk-jobs/v2\").then((m) => m.JobsClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Build a modular Files client from wrapper options. `getFileMetadata` is not\n * used: its generated HEAD call parses the (empty) body and drops the response\n * headers that carry the metadata, so the connector issues that HEAD through\n * {@link WorkspaceAuth.request} instead.\n */\nexport function buildFilesClient(opts: WorkspaceClientOptions): FilesClient {\n return lazyClient(\n () => import(\"@databricks/sdk-files/v2\").then((m) => m.FilesClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Build a modular Vector Search client from wrapper options. Query calls rely\n * on the sdk-vectorsearch pnpm patch (`debugLevel` / `debugInfo`, `bigint` rows).\n */\nexport function buildVectorSearchClient(\n opts: WorkspaceClientOptions,\n): VectorSearchClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-vectorsearch/v1\").then(\n (m) => m.VectorSearchClient,\n ),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Model Serving (serving endpoints) client from wrapper options. */\nexport function buildModelServingClient(\n opts: WorkspaceClientOptions,\n): ModelServingClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-modelserving/v1\").then(\n (m) => m.ModelServingClient,\n ),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular MLflow Experiments client from wrapper options. */\nexport function buildExperimentsClient(\n opts: WorkspaceClientOptions,\n): ExperimentsClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-experiments/v1\").then((m) => m.ExperimentsClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Tables client from wrapper options. */\nexport function buildTablesClient(opts: WorkspaceClientOptions): TablesClient {\n return lazyClient(\n () => import(\"@databricks/sdk-uc-tables/v1\").then((m) => m.TablesClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Volumes client from wrapper options. */\nexport function buildVolumesClient(\n opts: WorkspaceClientOptions,\n): VolumesClient {\n return lazyClient(\n () => import(\"@databricks/sdk-uc-volumes/v1\").then((m) => m.VolumesClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Functions client from wrapper options. */\nexport function buildFunctionsClient(\n opts: WorkspaceClientOptions,\n): FunctionsClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-uc-functions/v1\").then((m) => m.FunctionsClient),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Unity Catalog Connections client from wrapper options. */\nexport function buildConnectionsClient(\n opts: WorkspaceClientOptions,\n): ConnectionsClient {\n return lazyClient(\n () =>\n import(\"@databricks/sdk-uc-connections/v1\").then(\n (m) => m.ConnectionsClient,\n ),\n mapToClientOptions(opts),\n );\n}\n\n/** Build a modular Lakebase (provisioned) Database client from wrapper options. */\nexport function buildDatabaseClient(\n opts: WorkspaceClientOptions,\n): DatabaseClient {\n return lazyClient(\n () => import(\"@databricks/sdk-database/v1\").then((m) => m.DatabaseClient),\n mapToClientOptions(opts),\n );\n}\n\n/**\n * Resolve a `~/.databrickscfg` profile (+ env overlay, unless disabled). Exposed\n * so the CLI can read a profile offline without importing the SDK directly.\n */\nexport { resolve as resolveProfile } from \"@databricks/sdk-core/profiles\";\n\n/**\n * Build a modular Lakebase Postgres (autoscaling: projects, branches,\n * endpoints) client from wrapper options. Distinct from the provisioned\n * `/api/2.0/database` instance API.\n */\nexport function buildPostgresClient(\n opts: WorkspaceClientOptions,\n): PostgresClient {\n return lazyClient(\n () => import(\"@databricks/sdk-postgres/v1\").then((m) => m.PostgresClient),\n mapToClientOptions(opts),\n );\n}\n\n// ── Client type re-exports (for the facade accessor types) ───────────────\nexport type { DatabaseClient } from \"@databricks/sdk-database/v1\";\nexport type { ExperimentsClient } from \"@databricks/sdk-experiments/v1\";\nexport type { AppsClient } from \"@databricks/sdk-apps/v1\";\nexport type { FilesClient } from \"@databricks/sdk-files/v2\";\nexport type {\n DirectoryEntry as FilesDirectoryEntry,\n DownloadFileResponse as FilesDownloadResponse,\n} from \"@databricks/sdk-files/v2\";\nexport type { GenieClient } from \"@databricks/sdk-genie/v1\";\nexport type { JobsClient } from \"@databricks/sdk-jobs/v2\";\nexport type { ModelServingClient } from \"@databricks/sdk-modelserving/v1\";\nexport type { PostgresClient } from \"@databricks/sdk-postgres/v1\";\nexport type { ScimClient } from \"@databricks/sdk-scim/v1\";\nexport type { StatementExecutionClient } from \"@databricks/sdk-statementexecution/v1\";\nexport type { FunctionsClient } from \"@databricks/sdk-uc-functions/v1\";\nexport type { ConnectionsClient } from \"@databricks/sdk-uc-connections/v1\";\nexport type { TablesClient } from \"@databricks/sdk-uc-tables/v1\";\nexport type { VolumesClient } from \"@databricks/sdk-uc-volumes/v1\";\nexport type { VectorSearchClient } from \"@databricks/sdk-vectorsearch/v1\";\nexport type { WarehousesClient } from \"@databricks/sdk-warehouses/v1\";\n\n// ── Model type re-exports ────────────────────────────────────────────────\n// AppKit modules import request/response/enum types from the wrapper rather\n// than the SDK, so the import boundary holds. Type-only: the connector compares\n// state against string literals, which satisfy the SDK's `Enum | (string & {})`\n// field unions — no runtime enum values needed.\nexport type {\n ConnectionInfo,\n GetConnectionRequest,\n ListConnectionsRequest,\n ListConnectionsResponse,\n} from \"@databricks/sdk-uc-connections/v1\";\nexport type {\n ColumnInfo,\n Disposition,\n ExecuteStatementRequest,\n ExternalLink,\n Format,\n ResultData,\n ResultManifest,\n Schema,\n ServiceError,\n StatementParameter,\n StatementResponse,\n StatementStatus,\n StatementStatus_State,\n} from \"@databricks/sdk-statementexecution/v1\";\nexport type {\n DatabaseCredential,\n DatabaseInstance,\n GenerateDatabaseCredentialRequest,\n ListDatabaseInstancesRequest,\n ListDatabaseInstancesResponse,\n} from \"@databricks/sdk-database/v1\";\nexport type {\n App,\n ListAppsRequest,\n ListAppsResponse,\n} from \"@databricks/sdk-apps/v1\";\nexport type {\n GenieGetMessageQueryResultResponse,\n GenieMessage,\n} from \"@databricks/sdk-genie/v1\";\nexport type {\n FunctionInfo,\n GetFunctionRequest,\n} from \"@databricks/sdk-uc-functions/v1\";\nexport type {\n Experiment,\n ListExperimentsRequest,\n ListExperimentsResponse,\n} from \"@databricks/sdk-experiments/v1\";\nexport type {\n BaseRun,\n CancelRunRequest,\n GetJobRequest,\n GetJobResponse,\n GetRunOutputRequest,\n GetRunOutputResponse,\n GetRunRequest,\n GetRunResponse,\n ListRunsRequest,\n RunNowRequest,\n RunNowResponse,\n SubmitRunRequest,\n SubmitRunResponse,\n} from \"@databricks/sdk-jobs/v2\";\nexport type {\n GetInferenceEndpointRequest,\n InferenceEndpoint,\n InferenceEndpointDetailed,\n ListInferenceEndpointsRequest,\n ListInferenceEndpointsResponse,\n} from \"@databricks/sdk-modelserving/v1\";\nexport type {\n EndpointHealth,\n EndpointInfo,\n EndpointState,\n GetWarehouseResponse,\n} from \"@databricks/sdk-warehouses/v1\";\nexport type {\n QueryVectorIndexRequest,\n QueryVectorIndexResponse,\n} from \"@databricks/sdk-vectorsearch/v1\";\nexport type {\n GetVolumeRequest,\n VolumeInfo,\n} from \"@databricks/sdk-uc-volumes/v1\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,SAAS,cAAc,MAA8C;CACnE,MAAM,UAAU,MAAM,MAAM;AAC5B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,gBAAgB,KAAK,QAAQ,GAAG,UAAU,WAAW;;AAK9D,MAAM,0BAA0B;;;;;;;AAQhC,SAAS,eAAe,aAAiD;CACvE,IAAI;CACJ,IAAI;CACJ,MAAM,WAAW,MACf,EAAE,WAAW,UACb,EAAE,OAAO,SAAS,GAAG,0BAA0B,KAAK,KAAK;AAC3D,QAAO,oBACL,YAAY,M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
3
|
+
Deliberate validation failure. An explicit transaction callback can throw it, and the transaction rethrows that same error. Generated routes answer `422` and echo only the issues naming a public column. Every other failure stays an opaque server error.
|
|
4
4
|
|
|
5
5
|
## Extends[](#extends "Direct link to Extends")
|
|
6
6
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Function: defineOperation()
|
|
2
|
+
|
|
3
|
+
## Call Signature[](#call-signature "Direct link to Call Signature")
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function defineOperation<Name, M, I, O, R>(definition: OperationFields<M, I, O, Name> & {
|
|
7
|
+
authorize: ResourcePolicy<ParsedInput<I>, R>;
|
|
8
|
+
execute: (context: OperationContext<ParsedInput<I>, NonNullable<Awaited<R>>>) => Awaitable<ExecuteResult<M, O>>;
|
|
9
|
+
}): OperationDefinition<M, I, O, R, Name>;
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Declare one database operation. `name` is its public identifier. Declare an `input` Zod schema to accept parameters; without one, callbacks receive `undefined`. Declare an `output` Zod schema to answer a body; without one, the operation answers none. Definition only freezes a descriptor.
|
|
14
|
+
|
|
15
|
+
### Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
16
|
+
|
|
17
|
+
| Type Parameter |
|
|
18
|
+
| --------------------------------------- |
|
|
19
|
+
| `Name` *extends* `string` |
|
|
20
|
+
| `M` *extends* `DatabaseOperationMethod` |
|
|
21
|
+
| `I` *extends* `SchemaSlot` |
|
|
22
|
+
| `O` *extends* `SchemaSlot` |
|
|
23
|
+
| `R` *extends* { } |
|
|
24
|
+
|
|
25
|
+
### Parameters[](#parameters "Direct link to Parameters")
|
|
26
|
+
|
|
27
|
+
| Parameter | Type |
|
|
28
|
+
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| `definition` | `OperationFields`<`M`, `I`, `O`, `Name`> & { `authorize`: `ResourcePolicy`<`ParsedInput`<`I`>, `R`>; `execute`: (`context`: [`OperationContext`](./docs/api/appkit/Interface.OperationContext.md)<`ParsedInput`<`I`>, `NonNullable`<`Awaited`<`R`>>>) => `Awaitable`<`ExecuteResult`<`M`, `O`>>; } |
|
|
30
|
+
|
|
31
|
+
### Returns[](#returns "Direct link to Returns")
|
|
32
|
+
|
|
33
|
+
[`OperationDefinition`](./docs/api/appkit/Interface.OperationDefinition.md)<`M`, `I`, `O`, `R`, `Name`>
|
|
34
|
+
|
|
35
|
+
## Call Signature[](#call-signature-1 "Direct link to Call Signature")
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
function defineOperation<Name, M, I, O>(definition: OperationOptions<M, I, O, undefined, Name>): OperationDefinition<M, I, O, undefined, Name>;
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Declare one database operation. `name` is its public identifier. Declare an `input` Zod schema to accept parameters; without one, callbacks receive `undefined`. Declare an `output` Zod schema to answer a body; without one, the operation answers none. Definition only freezes a descriptor.
|
|
43
|
+
|
|
44
|
+
### Type Parameters[](#type-parameters-1 "Direct link to Type Parameters")
|
|
45
|
+
|
|
46
|
+
| Type Parameter | Default type |
|
|
47
|
+
| --------------------------------------- | ------------ |
|
|
48
|
+
| `Name` *extends* `string` | - |
|
|
49
|
+
| `M` *extends* `DatabaseOperationMethod` | - |
|
|
50
|
+
| `I` *extends* `SchemaSlot` | `undefined` |
|
|
51
|
+
| `O` *extends* `SchemaSlot` | `undefined` |
|
|
52
|
+
|
|
53
|
+
### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
54
|
+
|
|
55
|
+
| Parameter | Type |
|
|
56
|
+
| ------------ | ------------------------------------------------------ |
|
|
57
|
+
| `definition` | `OperationOptions`<`M`, `I`, `O`, `undefined`, `Name`> |
|
|
58
|
+
|
|
59
|
+
### Returns[](#returns-1 "Direct link to Returns")
|
|
60
|
+
|
|
61
|
+
[`OperationDefinition`](./docs/api/appkit/Interface.OperationDefinition.md)<`M`, `I`, `O`, `undefined`, `Name`>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Function: definePolicy()
|
|
2
|
+
|
|
3
|
+
## Call Signature[](#call-signature "Direct link to Call Signature")
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
function definePolicy<In>(policy: AllowPolicy<In>): AllowPolicy<In>;
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Declare a reusable authorization rule. Without `resource` it decides from the actor and input. With `resource` it loads one record first, from the same context every callback receives, `actor` included; annotate the lookup context to fix the input the policy needs. `allow` may return `true`, `false`, or `{ deny }`.
|
|
11
|
+
|
|
12
|
+
### Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
13
|
+
|
|
14
|
+
| Type Parameter | Default type |
|
|
15
|
+
| -------------- | ------------ |
|
|
16
|
+
| `In` | `unknown` |
|
|
17
|
+
|
|
18
|
+
### Parameters[](#parameters "Direct link to Parameters")
|
|
19
|
+
|
|
20
|
+
| Parameter | Type |
|
|
21
|
+
| --------- | ------------------- |
|
|
22
|
+
| `policy` | `AllowPolicy`<`In`> |
|
|
23
|
+
|
|
24
|
+
### Returns[](#returns "Direct link to Returns")
|
|
25
|
+
|
|
26
|
+
`AllowPolicy`<`In`>
|
|
27
|
+
|
|
28
|
+
## Call Signature[](#call-signature-1 "Direct link to Call Signature")
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
function definePolicy<In, R>(policy: ResourcePolicy<In, R>): ResourcePolicy<In, R>;
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Declare a reusable authorization rule. Without `resource` it decides from the actor and input. With `resource` it loads one record first, from the same context every callback receives, `actor` included; annotate the lookup context to fix the input the policy needs. `allow` may return `true`, `false`, or `{ deny }`.
|
|
36
|
+
|
|
37
|
+
### Type Parameters[](#type-parameters-1 "Direct link to Type Parameters")
|
|
38
|
+
|
|
39
|
+
| Type Parameter |
|
|
40
|
+
| -------------- |
|
|
41
|
+
| `In` |
|
|
42
|
+
| `R` |
|
|
43
|
+
|
|
44
|
+
### Parameters[](#parameters-1 "Direct link to Parameters")
|
|
45
|
+
|
|
46
|
+
| Parameter | Type |
|
|
47
|
+
| --------- | --------------------------- |
|
|
48
|
+
| `policy` | `ResourcePolicy`<`In`, `R`> |
|
|
49
|
+
|
|
50
|
+
### Returns[](#returns-1 "Direct link to Returns")
|
|
51
|
+
|
|
52
|
+
`ResourcePolicy`<`In`, `R`>
|
|
@@ -5,7 +5,7 @@ function defineSchema<TTables>(builder: (context: SchemaBuilderContext) => TTabl
|
|
|
5
5
|
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
Compile one declared schema. The returned type keeps the table names the builder returned, so `api.tables`
|
|
8
|
+
Compile one declared schema. The returned type keeps the table names the builder returned, so `api.tables` can name only real tables.
|
|
9
9
|
|
|
10
10
|
## Type Parameters[](#type-parameters "Direct link to Type Parameters")
|
|
11
11
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Interface: Actor
|
|
2
|
+
|
|
3
|
+
The authenticated caller. The HTTP boundary resolves it before any policy runs.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### email?[](#email "Direct link to email?")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly optional email: string;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### id[](#id "Direct link to id")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
readonly id: string;
|
|
20
|
+
|
|
21
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Interface: DatabaseOperationContract
|
|
2
|
+
|
|
3
|
+
The browser-safe contract of one generated operation. `input` and `output` are JSON types. A generated `database.d.ts` fills this interface by name.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### input[](#input "Direct link to input")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly input: unknown;
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### method[](#method "Direct link to method")
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
readonly method: DatabaseOperationMethod;
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### output[](#output "Direct link to output")
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
readonly output: unknown;
|
|
29
|
+
|
|
30
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Interface: DatabaseRoutes
|
|
2
|
+
|
|
3
|
+
The generated route entry. `schema` and each module stay lazy, so importing the registry evaluates neither the schema nor an operation.
|
|
4
|
+
|
|
5
|
+
## Properties[](#properties "Direct link to Properties")
|
|
6
|
+
|
|
7
|
+
### modules[](#modules "Direct link to modules")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
readonly modules: readonly {
|
|
11
|
+
file: string;
|
|
12
|
+
load: () => Promise<Record<string, unknown>>;
|
|
13
|
+
}[];
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
***
|
|
18
|
+
|
|
19
|
+
### schema()[](#schema "Direct link to schema()")
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
readonly schema: () => Promise<{
|
|
23
|
+
schema: Schema;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Returns[](#returns "Direct link to Returns")
|
|
29
|
+
|
|
30
|
+
`Promise`<{ `schema`: [`Schema`](./docs/api/appkit/Interface.Schema.md); }>
|