@databricks/sql 2.0.0 → 2.2.0
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/README.md +6 -0
- package/dist/DBSQLClient.d.ts +1 -0
- package/dist/DBSQLClient.js +74 -5
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/ReydenWarehouseCache.d.ts +57 -0
- package/dist/ReydenWarehouseCache.js +101 -0
- package/dist/ReydenWarehouseCache.js.map +1 -0
- package/dist/connection/connections/HttpConnection.js +4 -1
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/connection/contracts/IConnectionOptions.d.ts +2 -1
- package/dist/contracts/IClientContext.d.ts +1 -0
- package/dist/contracts/IDBSQLClient.d.ts +55 -0
- package/dist/errors/StatusError.d.ts +1 -0
- package/dist/errors/StatusError.js +1 -0
- package/dist/errors/StatusError.js.map +1 -1
- package/dist/kernel/KernelAuth.d.ts +106 -24
- package/dist/kernel/KernelAuth.js +331 -75
- package/dist/kernel/KernelAuth.js.map +1 -1
- package/dist/kernel/KernelBackend.d.ts +5 -4
- package/dist/kernel/KernelBackend.js +8 -7
- package/dist/kernel/KernelBackend.js.map +1 -1
- package/dist/kernel/KernelNativeLoader.d.ts +2 -3
- package/dist/kernel/KernelNativeLoader.js.map +1 -1
- package/dist/kernel/KernelOperationBackend.js +2 -1
- package/dist/kernel/KernelOperationBackend.js.map +1 -1
- package/dist/kernel/KernelPositionalParams.d.ts +6 -6
- package/dist/kernel/KernelPositionalParams.js +11 -15
- package/dist/kernel/KernelPositionalParams.js.map +1 -1
- package/dist/kernel/KernelSessionBackend.js +4 -5
- package/dist/kernel/KernelSessionBackend.js.map +1 -1
- package/dist/result/ArrowResultConverter.d.ts +3 -1
- package/dist/result/ArrowResultConverter.js +9 -4
- package/dist/result/ArrowResultConverter.js.map +1 -1
- package/dist/telemetry/telemetryUtils.d.ts +10 -0
- package/dist/telemetry/telemetryUtils.js +15 -0
- package/dist/telemetry/telemetryUtils.js.map +1 -1
- package/dist/thrift-backend/ThriftBackend.d.ts +22 -2
- package/dist/thrift-backend/ThriftBackend.js +120 -2
- package/dist/thrift-backend/ThriftBackend.js.map +1 -1
- package/dist/thrift-backend/ThriftOperationBackend.js +9 -3
- package/dist/thrift-backend/ThriftOperationBackend.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/normalizePemBytes.d.ts +20 -0
- package/dist/utils/normalizePemBytes.js +49 -0
- package/dist/utils/normalizePemBytes.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/native/kernel/README.md +1 -1
- package/native/kernel/index.d.ts +1120 -883
- package/native/kernel/index.js +653 -265
- package/package.json +10 -10
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ConnectionOptions } from '../contracts/IDBSQLClient';
|
|
2
|
+
import { ClientConfig } from '../contracts/IClientContext';
|
|
3
|
+
import IDBSQLLogger from '../contracts/IDBSQLLogger';
|
|
4
|
+
import { isTelemetryDisabledByEnv } from '../telemetry/telemetryUtils';
|
|
2
5
|
/**
|
|
3
6
|
* Shape consumed by the napi-binding's `openSession()` (see
|
|
4
7
|
* `native/kernel/index.d.ts`). Mirrors `ConnectionOptions` in the binding's
|
|
@@ -13,6 +16,10 @@ import { ConnectionOptions } from '../contracts/IDBSQLClient';
|
|
|
13
16
|
* everything else (client_id, scopes, callback timeout,
|
|
14
17
|
* token_url_override) uses kernel defaults.
|
|
15
18
|
*
|
|
19
|
+
* `static-token` reuses the native PAT bearer-token mode, where federation is
|
|
20
|
+
* always enabled. `enableTokenFederation` is ignored; a non-empty
|
|
21
|
+
* `federationClientId` selects SP-wide WIF and omission selects account-wide.
|
|
22
|
+
*
|
|
16
23
|
* The `authMode` string literals MUST match the napi-emitted `AuthMode`
|
|
17
24
|
* variant names verbatim (`'Pat'`, `'OAuthM2m'`, `'OAuthU2m'` — napi-rs's
|
|
18
25
|
* `#[napi(string_enum)]` without an explicit case option emits the
|
|
@@ -78,6 +85,31 @@ export interface KernelSessionDefaults {
|
|
|
78
85
|
retryMaxAttempts?: number;
|
|
79
86
|
retryOverallTimeoutSecs?: number;
|
|
80
87
|
}
|
|
88
|
+
export interface KernelTelemetryOptions {
|
|
89
|
+
/** Driver/runtime identity forwarded to kernel-owned telemetry. */
|
|
90
|
+
driverName?: string;
|
|
91
|
+
driverVersion?: string;
|
|
92
|
+
runtimeName?: string;
|
|
93
|
+
runtimeVersion?: string;
|
|
94
|
+
runtimeVendor?: string;
|
|
95
|
+
osName?: string;
|
|
96
|
+
osVersion?: string;
|
|
97
|
+
osArch?: string;
|
|
98
|
+
clientAppName?: string;
|
|
99
|
+
localeName?: string;
|
|
100
|
+
charSetEncoding?: string;
|
|
101
|
+
processName?: string;
|
|
102
|
+
/** Kernel-owned telemetry switch and batching. */
|
|
103
|
+
telemetryEnabled?: boolean;
|
|
104
|
+
telemetryBatchSize?: number;
|
|
105
|
+
telemetryFlushIntervalMs?: number;
|
|
106
|
+
telemetryMaxRetries?: number;
|
|
107
|
+
telemetryRetryDelayMs?: number;
|
|
108
|
+
telemetryCloseFlushTimeoutMs?: number;
|
|
109
|
+
telemetryCircuitBreakerEnabled?: boolean;
|
|
110
|
+
telemetryCircuitBreakerThreshold?: number;
|
|
111
|
+
telemetryCircuitBreakerTimeoutMs?: number;
|
|
112
|
+
}
|
|
81
113
|
/**
|
|
82
114
|
* TLS options shared across all auth-mode variants. Mirror the napi
|
|
83
115
|
* binding's `ConnectionOptions.checkServerCertificate` / `.customCaCert`
|
|
@@ -163,7 +195,14 @@ export interface KernelProxyOptions {
|
|
|
163
195
|
bypassHosts?: string;
|
|
164
196
|
};
|
|
165
197
|
}
|
|
166
|
-
export
|
|
198
|
+
export interface KernelFederationOptions {
|
|
199
|
+
/**
|
|
200
|
+
* SP-wide Workload Identity Federation client id. Omitted selects BYOT /
|
|
201
|
+
* account-wide WIF.
|
|
202
|
+
*/
|
|
203
|
+
identityFederationClientId?: string;
|
|
204
|
+
}
|
|
205
|
+
export type KernelNativeConnectionOptions = KernelSessionDefaults & KernelTlsOptions & KernelHttpOptions & KernelTelemetryOptions & KernelProxyOptions & KernelFederationOptions & ({
|
|
167
206
|
hostName: string;
|
|
168
207
|
httpPath: string;
|
|
169
208
|
authMode: 'Pat';
|
|
@@ -182,6 +221,14 @@ export type KernelNativeConnectionOptions = KernelSessionDefaults & KernelTlsOpt
|
|
|
182
221
|
oauthRedirectPort: number;
|
|
183
222
|
oauthScopes?: Array<string>;
|
|
184
223
|
oauthClientId?: string;
|
|
224
|
+
tokenCacheEnabled?: boolean;
|
|
225
|
+
} | {
|
|
226
|
+
hostName: string;
|
|
227
|
+
httpPath: string;
|
|
228
|
+
authMode: 'AzureSpM2m';
|
|
229
|
+
azureClientId: string;
|
|
230
|
+
azureClientSecret: string;
|
|
231
|
+
azureTenantId?: string;
|
|
185
232
|
});
|
|
186
233
|
/**
|
|
187
234
|
* Reject inputs that pass `typeof === 'string' && length > 0` but are
|
|
@@ -205,11 +252,13 @@ export declare function isBlankOrReserved(s: string): boolean;
|
|
|
205
252
|
* master verify toggle is on). Mirrors Python's `tls_verify_hostname`.
|
|
206
253
|
* - `customCaCert` accepts a PEM string or `Buffer`; normalised to a
|
|
207
254
|
* `Buffer` via {@link normalizePemBytes}.
|
|
208
|
-
* - `clientCertPem` / `clientKeyPem`
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
255
|
+
* - `clientCertPem` / `clientKeyPem` (or their public aliases
|
|
256
|
+
* `clientCert` / `clientKey`) carry the mutual-TLS client identity. The
|
|
257
|
+
* internal `*Pem` names win when both are present. They must be supplied
|
|
258
|
+
* **together** — supplying only one is rejected here with an actionable
|
|
259
|
+
* error (rather than waiting for the kernel's `InvalidArgument` at
|
|
260
|
+
* `openSession`). Each accepts a PEM string or `Buffer`, normalised the
|
|
261
|
+
* same way.
|
|
213
262
|
*
|
|
214
263
|
* Throws `HiveDriverError` when a cert/key is empty, mis-typed, lacks the
|
|
215
264
|
* expected PEM header, or when only one half of the mTLS pair is set.
|
|
@@ -224,6 +273,10 @@ export declare function buildKernelHttpOptions(options: ConnectionOptions): Kern
|
|
|
224
273
|
* - PAT: `authType: 'access-token'` (or undefined, which already means
|
|
225
274
|
* PAT throughout the existing driver — see
|
|
226
275
|
* `DBSQLClient.createAuthProvider`).
|
|
276
|
+
* - Static token: `authType: 'static-token'` + `staticToken`. The token is
|
|
277
|
+
* forwarded through the native PAT bearer-token mode, where federation is
|
|
278
|
+
* always enabled. `federationClientId` selects SP-wide WIF; omission
|
|
279
|
+
* selects account-wide WIF. `enableTokenFederation` is ignored.
|
|
227
280
|
* - OAuth M2M: `authType: 'databricks-oauth'` + `oauthClientId` +
|
|
228
281
|
* `oauthClientSecret`. Kernel handles OIDC discovery, client_credentials
|
|
229
282
|
* exchange, and re-auth on expiry internally.
|
|
@@ -232,27 +285,38 @@ export declare function buildKernelHttpOptions(options: ConnectionOptions): Kern
|
|
|
232
285
|
* a browser, listens on localhost:8030, exchanges the code, persists
|
|
233
286
|
* to `~/.config/databricks-sql-kernel/oauth/{sha256}.json`).
|
|
234
287
|
*
|
|
235
|
-
* **Flow selection —
|
|
288
|
+
* **Flow selection — MIRRORS THRIFT.** Thrift's
|
|
236
289
|
* `DBSQLClient.createAuthProvider` (`DBSQLClient.ts:216`) keys off the
|
|
237
290
|
* *secret* (`oauthClientSecret === undefined ? U2M : M2M`), so a custom
|
|
238
|
-
* `oauthClientId` with no secret runs U2M with that id.
|
|
239
|
-
* off
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
291
|
+
* `oauthClientId` with no secret runs U2M with that id. This adapter keys
|
|
292
|
+
* off the same signal: `oauthClientSecret === undefined` ⇒ U2M, else M2M
|
|
293
|
+
* (see `buildKernelConnectionOptions` below). A custom `oauthClientId` is
|
|
294
|
+
* forwarded verbatim on the U2M arm; when absent the napi binding applies
|
|
295
|
+
* its own default `client_id`. The adapter therefore does NOT throw an M2M
|
|
296
|
+
* "secret required" error for `oauthClientId` + no secret, and does NOT
|
|
297
|
+
* reject a custom `oauthClientId` on U2M — those decisions, if the native
|
|
298
|
+
* binding makes them, happen below the TypeScript layer and are not
|
|
299
|
+
* observable from this repo.
|
|
300
|
+
*
|
|
301
|
+
* Azure (Entra) on the OAuth path. The kernel runs a single, cloud-blind
|
|
302
|
+
* in-house U2M flow and workspace-OIDC M2M; only Entra-direct **M2M** gets a
|
|
303
|
+
* dedicated kernel mode:
|
|
304
|
+
* - **U2M (no secret), any cloud, any `useDatabricksOAuthInAzure`** →
|
|
305
|
+
* `OAuthU2m`. The kernel uses the workspace's OIDC-discovered authorize
|
|
306
|
+
* endpoint (`{host}/oidc/v1/authorize`) verbatim; that in-house
|
|
307
|
+
* workspace-federated flow works against Azure workspaces too (they federate
|
|
308
|
+
* the browser login to Entra server-side — verified E2E). So Azure U2M is
|
|
309
|
+
* NOT special-cased and NOT rejected — it forwards the in-house app
|
|
310
|
+
* (`databricks-sql-connector`) + `sql offline_access`, exactly like AWS/GCP.
|
|
311
|
+
* - **M2M (secret) with `useDatabricksOAuthInAzure: true`** (or non-Azure) →
|
|
312
|
+
* `OAuthM2m` (workspace-OIDC client-credentials).
|
|
313
|
+
* - **M2M (secret) on an Azure host with `useDatabricksOAuthInAzure` absent/
|
|
314
|
+
* `false`** (Entra-direct) → Azure service-principal M2M (`AzureSpM2m`); the
|
|
315
|
+
* Entra SP creds ride `oauthClientId`/`oauthClientSecret`, `azureTenantId`
|
|
316
|
+
* optional (kernel auto-discovers).
|
|
317
|
+
* - On a non-Azure host `useDatabricksOAuthInAzure` is inert.
|
|
250
318
|
*
|
|
251
319
|
* Out of scope on the OAuth paths (rejected with a clear error):
|
|
252
|
-
* - `azureTenantId` / `useDatabricksOAuthInAzure` → Microsoft Entra
|
|
253
|
-
* direct flow. The kernel uses workspace-OIDC discovery (which works
|
|
254
|
-
* against Azure workspaces too — they serve `/oidc/.well-known/...`)
|
|
255
|
-
* and does not implement the Entra-direct scope-rewrite path.
|
|
256
320
|
* - `persistence` on M2M → M2M tokens are not cached (re-issuing is
|
|
257
321
|
* cheap; no refresh token).
|
|
258
322
|
* - `persistence` on U2M → custom token store is a parity gap;
|
|
@@ -266,7 +330,7 @@ export declare function buildKernelHttpOptions(options: ConnectionOptions): Kern
|
|
|
266
330
|
*
|
|
267
331
|
* Throws:
|
|
268
332
|
* - `AuthenticationError` for missing/blank required credentials.
|
|
269
|
-
* - `HiveDriverError` for unsupported auth modes /
|
|
333
|
+
* - `HiveDriverError` for unsupported auth modes /
|
|
270
334
|
* custom persistence / ambiguous combinations.
|
|
271
335
|
*/
|
|
272
336
|
/**
|
|
@@ -284,6 +348,24 @@ export declare function buildKernelRetryOptions(config: {
|
|
|
284
348
|
retryDelayMin?: number;
|
|
285
349
|
retryDelayMax?: number;
|
|
286
350
|
}): Pick<KernelSessionDefaults, 'retryMinWaitSecs' | 'retryMaxWaitSecs' | 'retryMaxAttempts' | 'retryOverallTimeoutSecs'>;
|
|
351
|
+
export { isTelemetryDisabledByEnv };
|
|
352
|
+
/**
|
|
353
|
+
* Build the kernel telemetry options block from the driver's `ClientConfig`.
|
|
354
|
+
*
|
|
355
|
+
* **Always-forward is intentional, mirroring `buildKernelRetryOptions`.** On the
|
|
356
|
+
* real `DBSQLClient` path `getDefaultConfig()` seeds every one of these knobs from
|
|
357
|
+
* `DEFAULT_TELEMETRY_CONFIG`, so they are never `undefined` and always propagate to
|
|
358
|
+
* the kernel's `openSession` — the driver's telemetry-tuning defaults deliberately
|
|
359
|
+
* govern both backends from one `ClientConfig` (same rationale as the retry knobs),
|
|
360
|
+
* rather than letting the kernel's independent defaults apply. The kernel's own
|
|
361
|
+
* `"Omitted ⇒ kernel default"` branch is therefore only reachable via a bare
|
|
362
|
+
* `configOverrides`-style config (e.g. unit tests), not the default-populated one a
|
|
363
|
+
* live client uses. The `Number.isFinite(...) && > 0` guards below are NOT an
|
|
364
|
+
* opt-in gate: they exist to reject a caller-supplied out-of-range value (warning
|
|
365
|
+
* via `warnRejected`) and to tolerate sparse test configs, not to compare against
|
|
366
|
+
* the default.
|
|
367
|
+
*/
|
|
368
|
+
export declare function buildKernelTelemetryOptions(config: Pick<ClientConfig, 'telemetryBatchSize' | 'telemetryFlushIntervalMs' | 'telemetryMaxRetries' | 'telemetryBackoffBaseMs' | 'telemetryCloseTimeoutMs' | 'telemetryCircuitBreakerThreshold' | 'telemetryCircuitBreakerTimeout'>, options?: Pick<ConnectionOptions, 'telemetryEnabled'>, logger?: IDBSQLLogger): KernelTelemetryOptions;
|
|
287
369
|
/**
|
|
288
370
|
* Map the public `ConnectionOptions.proxy` (`{protocol, host, port, auth}` —
|
|
289
371
|
* the same shape the Thrift backend accepts) onto the kernel's structured napi
|