@databricks/sql 1.12.0 → 1.14.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/dist/DBSQLClient.d.ts +13 -0
- package/dist/DBSQLClient.js +58 -1
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation.d.ts +1 -0
- package/dist/DBSQLOperation.js +23 -2
- package/dist/DBSQLOperation.js.map +1 -1
- package/dist/DBSQLSession.js +5 -1
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.d.ts +37 -0
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.js +79 -0
- package/dist/connection/auth/tokenProvider/CachedTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.d.ts +28 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.js +37 -0
- package/dist/connection/auth/tokenProvider/ExternalTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.d.ts +57 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.js +218 -0
- package/dist/connection/auth/tokenProvider/FederationProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.d.ts +17 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.js +3 -0
- package/dist/connection/auth/tokenProvider/ITokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.d.ts +24 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.js +43 -0
- package/dist/connection/auth/tokenProvider/StaticTokenProvider.js.map +1 -0
- package/dist/connection/auth/tokenProvider/Token.d.ts +75 -0
- package/dist/connection/auth/tokenProvider/Token.js +120 -0
- package/dist/connection/auth/tokenProvider/Token.js.map +1 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.d.ts +21 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.js +38 -0
- package/dist/connection/auth/tokenProvider/TokenProviderAuthenticator.js.map +1 -0
- package/dist/connection/auth/tokenProvider/index.d.ts +8 -0
- package/dist/connection/auth/tokenProvider/index.js +23 -0
- package/dist/connection/auth/tokenProvider/index.js.map +1 -0
- package/dist/connection/auth/tokenProvider/utils.d.ts +24 -0
- package/dist/connection/auth/tokenProvider/utils.js +83 -0
- package/dist/connection/auth/tokenProvider/utils.js.map +1 -0
- package/dist/contracts/IClientContext.d.ts +15 -0
- package/dist/contracts/IDBSQLClient.d.ts +24 -0
- package/dist/contracts/IDBSQLSession.d.ts +6 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/result/ArrowResultHandler.js +2 -2
- package/dist/result/ArrowResultHandler.js.map +1 -1
- package/dist/result/CloudFetchResultHandler.js +2 -2
- package/dist/result/CloudFetchResultHandler.js.map +1 -1
- package/dist/telemetry/CircuitBreaker.d.ts +73 -0
- package/dist/telemetry/CircuitBreaker.js +176 -0
- package/dist/telemetry/CircuitBreaker.js.map +1 -0
- package/dist/telemetry/DatabricksTelemetryExporter.d.ts +76 -0
- package/dist/telemetry/DatabricksTelemetryExporter.js +324 -0
- package/dist/telemetry/DatabricksTelemetryExporter.js.map +1 -0
- package/dist/telemetry/ExceptionClassifier.d.ts +48 -0
- package/dist/telemetry/ExceptionClassifier.js +112 -0
- package/dist/telemetry/ExceptionClassifier.js.map +1 -0
- package/dist/telemetry/FeatureFlagCache.d.ts +61 -0
- package/dist/telemetry/FeatureFlagCache.js +208 -0
- package/dist/telemetry/FeatureFlagCache.js.map +1 -0
- package/dist/telemetry/MetricsAggregator.d.ts +72 -0
- package/dist/telemetry/MetricsAggregator.js +375 -0
- package/dist/telemetry/MetricsAggregator.js.map +1 -0
- package/dist/telemetry/TelemetryClient.d.ts +41 -0
- package/dist/telemetry/TelemetryClient.js +64 -0
- package/dist/telemetry/TelemetryClient.js.map +1 -0
- package/dist/telemetry/TelemetryClientProvider.d.ts +67 -0
- package/dist/telemetry/TelemetryClientProvider.js +148 -0
- package/dist/telemetry/TelemetryClientProvider.js.map +1 -0
- package/dist/telemetry/TelemetryEventEmitter.d.ts +93 -0
- package/dist/telemetry/TelemetryEventEmitter.js +172 -0
- package/dist/telemetry/TelemetryEventEmitter.js.map +1 -0
- package/dist/telemetry/telemetryUtils.d.ts +56 -0
- package/dist/telemetry/telemetryUtils.js +222 -0
- package/dist/telemetry/telemetryUtils.js.map +1 -0
- package/dist/telemetry/types.d.ts +209 -0
- package/dist/telemetry/types.js +52 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/telemetry/urlUtils.d.ts +22 -0
- package/dist/telemetry/urlUtils.js +35 -0
- package/dist/telemetry/urlUtils.js.map +1 -0
- package/dist/utils/agentDetector.d.ts +20 -0
- package/dist/utils/agentDetector.js +39 -0
- package/dist/utils/agentDetector.js.map +1 -0
- package/dist/utils/buildUserAgentString.js +7 -1
- package/dist/utils/buildUserAgentString.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/lz4.d.ts +2 -2
- package/dist/utils/lz4.js +13 -1
- package/dist/utils/lz4.js.map +1 -1
- package/dist/utils/queryTags.d.ts +12 -0
- package/dist/utils/queryTags.js +35 -0
- package/dist/utils/queryTags.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Build an HTTPS telemetry URL from a host and a path.
|
|
18
|
+
*
|
|
19
|
+
* Refuses anything beyond a bare `host[:port]` so a compromised or mistyped
|
|
20
|
+
* host cannot redirect the authenticated request to an attacker-controlled
|
|
21
|
+
* endpoint. Defeated historical bypasses include:
|
|
22
|
+
* - protocol-relative prefix: `//attacker.com`
|
|
23
|
+
* - zero-width / ASCII whitespace in the host
|
|
24
|
+
* - userinfo (`user:pass@host`)
|
|
25
|
+
* - path/query/fragment
|
|
26
|
+
* - CRLF (header injection on some fetch backends)
|
|
27
|
+
* - loopback / link-local / RFC1918 / cloud-metadata addresses
|
|
28
|
+
*
|
|
29
|
+
* Returns `null` when the host fails any check; callers drop the batch.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildTelemetryUrl(host: string, path: string): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Strips common secret shapes from a free-form error string and caps length.
|
|
34
|
+
* Applied before anything is shipped off-box. Redaction happens before
|
|
35
|
+
* truncation so a long stack cannot bury a secret past the cap; truncation
|
|
36
|
+
* then runs a second pass to catch anything that appeared only in the tail.
|
|
37
|
+
*/
|
|
38
|
+
export declare function redactSensitive(value: string | undefined, maxLen?: number): string;
|
|
39
|
+
/**
|
|
40
|
+
* Normalises any `HeadersInit` shape (`Headers`, `[string,string][]`, or
|
|
41
|
+
* `Record<string, string>`) into a plain string dictionary. Non-string
|
|
42
|
+
* values are dropped. Shared by the exporter and FeatureFlagCache so there
|
|
43
|
+
* is one source of truth for auth-header handling.
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeHeaders(raw: unknown): Record<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Case-insensitive check for a non-empty `Authorization` header.
|
|
48
|
+
*/
|
|
49
|
+
export declare function hasAuthorization(headers: Record<string, string>): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Returns a safe `process_name` value: the basename of the first whitespace-
|
|
52
|
+
* delimited token, with trailing whitespace trimmed. This defeats both the
|
|
53
|
+
* absolute-path PII leak (`/home/<user>/app.js`) and the argv-leak shape
|
|
54
|
+
* (`node --db-password=X app.js`) that some producers pass in.
|
|
55
|
+
*/
|
|
56
|
+
export declare function sanitizeProcessName(name: string | undefined): string;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.sanitizeProcessName = exports.hasAuthorization = exports.normalizeHeaders = exports.redactSensitive = exports.buildTelemetryUrl = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Hosts we always refuse to send authenticated telemetry to. Targeted at the
|
|
21
|
+
* `/api/2.0/sql/telemetry-ext` exfil vector: an attacker-influenced `host`
|
|
22
|
+
* (env var, tampered config, etc.) must not be able to redirect the Bearer
|
|
23
|
+
* token to a loopback/IMDS/RFC1918 endpoint.
|
|
24
|
+
*/
|
|
25
|
+
const BLOCKED_HOST_PATTERNS = [
|
|
26
|
+
/^(?:127\.|0\.|10\.|169\.254\.|172\.(?:1[6-9]|2[0-9]|3[01])\.|192\.168\.)/,
|
|
27
|
+
/^(?:localhost|metadata\.google\.internal|metadata\.azure\.com)$/i,
|
|
28
|
+
/^\[?::1\]?$/,
|
|
29
|
+
/^\[?(?:fc|fd)[0-9a-f]{2}:/i,
|
|
30
|
+
/^\[?::ffff:(?:127|10|0|169\.254)\./i,
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Build an HTTPS telemetry URL from a host and a path.
|
|
34
|
+
*
|
|
35
|
+
* Refuses anything beyond a bare `host[:port]` so a compromised or mistyped
|
|
36
|
+
* host cannot redirect the authenticated request to an attacker-controlled
|
|
37
|
+
* endpoint. Defeated historical bypasses include:
|
|
38
|
+
* - protocol-relative prefix: `//attacker.com`
|
|
39
|
+
* - zero-width / ASCII whitespace in the host
|
|
40
|
+
* - userinfo (`user:pass@host`)
|
|
41
|
+
* - path/query/fragment
|
|
42
|
+
* - CRLF (header injection on some fetch backends)
|
|
43
|
+
* - loopback / link-local / RFC1918 / cloud-metadata addresses
|
|
44
|
+
*
|
|
45
|
+
* Returns `null` when the host fails any check; callers drop the batch.
|
|
46
|
+
*/
|
|
47
|
+
function buildTelemetryUrl(host, path) {
|
|
48
|
+
if (typeof host !== 'string' || host.length === 0) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
// Reject ASCII whitespace + common zero-width/BOM codepoints that JS `\s`
|
|
52
|
+
// does not cover but `new URL` silently strips.
|
|
53
|
+
if (/[\s\u200b-\u200f\u2060\ufeff]/.test(host)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const cleanHost = host.replace(/^https?:\/\//, '').replace(/\/+$/, '');
|
|
57
|
+
if (cleanHost.length === 0) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
// Reject anything that looks like userinfo / path / protocol-relative
|
|
61
|
+
// prefix before URL parsing. `new URL('https://' + '//x')` would otherwise
|
|
62
|
+
// normalise the doubled slash and accept `x` as the host.
|
|
63
|
+
if (/[/\\@]/.test(cleanHost)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
let parsed;
|
|
67
|
+
try {
|
|
68
|
+
parsed = new URL(`https://${cleanHost}`);
|
|
69
|
+
}
|
|
70
|
+
catch (_a) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
if (parsed.pathname !== '/' ||
|
|
74
|
+
parsed.search !== '' ||
|
|
75
|
+
parsed.hash !== '' ||
|
|
76
|
+
parsed.username !== '' ||
|
|
77
|
+
parsed.password !== '') {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
// Defence in depth: ensure `new URL` did not silently rewrite the host we
|
|
81
|
+
// validated (e.g. by stripping a codepoint we missed above). `new URL`
|
|
82
|
+
// normalises away the default :443 for https, so compare using the
|
|
83
|
+
// port-stripped hostname instead of .host.
|
|
84
|
+
const expectedHost = cleanHost.toLowerCase().replace(/:443$/, '');
|
|
85
|
+
const actualHost = parsed.host.toLowerCase().replace(/:443$/, '');
|
|
86
|
+
if (actualHost !== expectedHost) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (BLOCKED_HOST_PATTERNS.some((r) => r.test(parsed.hostname))) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return `https://${parsed.host}${path}`;
|
|
93
|
+
}
|
|
94
|
+
exports.buildTelemetryUrl = buildTelemetryUrl;
|
|
95
|
+
/**
|
|
96
|
+
* Prefixes the Databricks driver uses for internal token formats. Kept in
|
|
97
|
+
* sync with `lib/utils/buildUserAgentString.ts`'s `redactInternalToken`.
|
|
98
|
+
* Extending one list should extend the other.
|
|
99
|
+
*/
|
|
100
|
+
const DATABRICKS_TOKEN_PREFIXES = ['dkea', 'dskea', 'dapi', 'dsapi', 'dose'];
|
|
101
|
+
const SECRET_PATTERNS = [
|
|
102
|
+
// `Authorization: Bearer <token>` / `Bearer <token>` anywhere in a stack.
|
|
103
|
+
[/Bearer\s+[A-Za-z0-9._\-+/=]+/gi, 'Bearer <REDACTED>'],
|
|
104
|
+
// `Authorization: Basic <base64>`.
|
|
105
|
+
[/Basic\s+[A-Za-z0-9+/=]+/gi, 'Basic <REDACTED>'],
|
|
106
|
+
// URL userinfo: `https://user:pass@host/…`.
|
|
107
|
+
[/([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+:[^/\s@]+@/gi, '$1<REDACTED>@'],
|
|
108
|
+
// Databricks PATs / service-token prefixes without `Bearer`, e.g.
|
|
109
|
+
// `token is dapi0123…` — appears in error stacks that echo the raw value.
|
|
110
|
+
[new RegExp(`\\b(?:${DATABRICKS_TOKEN_PREFIXES.join('|')})[A-Za-z0-9]{8,}`, 'g'), '<REDACTED>'],
|
|
111
|
+
// JWTs (three base64url segments separated by dots).
|
|
112
|
+
[/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g, '<REDACTED_JWT>'],
|
|
113
|
+
// JSON-encoded secrets: `"client_secret":"..."`, `"access_token":"..."` etc.
|
|
114
|
+
[
|
|
115
|
+
/"(password|token|client_secret|refresh_token|access_token|id_token|secret|api[_-]?key|apikey)"\s*:\s*"[^"]*"/gi,
|
|
116
|
+
'"$1":"<REDACTED>"',
|
|
117
|
+
],
|
|
118
|
+
// Form-URL-encoded / key=value secrets.
|
|
119
|
+
[
|
|
120
|
+
/\b(token|password|client_secret|refresh_token|access_token|id_token|secret|api[_-]?key|apikey)=[^\s&"']+/gi,
|
|
121
|
+
'$1=<REDACTED>',
|
|
122
|
+
],
|
|
123
|
+
];
|
|
124
|
+
/**
|
|
125
|
+
* Strips common secret shapes from a free-form error string and caps length.
|
|
126
|
+
* Applied before anything is shipped off-box. Redaction happens before
|
|
127
|
+
* truncation so a long stack cannot bury a secret past the cap; truncation
|
|
128
|
+
* then runs a second pass to catch anything that appeared only in the tail.
|
|
129
|
+
*/
|
|
130
|
+
function redactSensitive(value, maxLen = 2048) {
|
|
131
|
+
if (!value) {
|
|
132
|
+
return '';
|
|
133
|
+
}
|
|
134
|
+
let redacted = value;
|
|
135
|
+
for (const [pattern, replacement] of SECRET_PATTERNS) {
|
|
136
|
+
redacted = redacted.replace(pattern, replacement);
|
|
137
|
+
}
|
|
138
|
+
if (redacted.length > maxLen) {
|
|
139
|
+
redacted = `${redacted.slice(0, maxLen)}…[truncated]`;
|
|
140
|
+
for (const [pattern, replacement] of SECRET_PATTERNS) {
|
|
141
|
+
redacted = redacted.replace(pattern, replacement);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return redacted;
|
|
145
|
+
}
|
|
146
|
+
exports.redactSensitive = redactSensitive;
|
|
147
|
+
/**
|
|
148
|
+
* Normalises any `HeadersInit` shape (`Headers`, `[string,string][]`, or
|
|
149
|
+
* `Record<string, string>`) into a plain string dictionary. Non-string
|
|
150
|
+
* values are dropped. Shared by the exporter and FeatureFlagCache so there
|
|
151
|
+
* is one source of truth for auth-header handling.
|
|
152
|
+
*/
|
|
153
|
+
function normalizeHeaders(raw) {
|
|
154
|
+
if (!raw || typeof raw !== 'object') {
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
157
|
+
// Avoid importing node-fetch here; use structural check.
|
|
158
|
+
if (typeof raw.forEach === 'function' && !Array.isArray(raw)) {
|
|
159
|
+
const out = {};
|
|
160
|
+
raw.forEach((value, key) => {
|
|
161
|
+
if (typeof key === 'string' && typeof value === 'string') {
|
|
162
|
+
out[key] = value;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
if (Array.isArray(raw)) {
|
|
168
|
+
const out = {};
|
|
169
|
+
for (const entry of raw) {
|
|
170
|
+
if (Array.isArray(entry) && entry.length === 2 && typeof entry[0] === 'string' && typeof entry[1] === 'string') {
|
|
171
|
+
const [key, value] = entry;
|
|
172
|
+
out[key] = value;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
const out = {};
|
|
178
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
179
|
+
if (typeof v === 'string') {
|
|
180
|
+
out[k] = v;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
exports.normalizeHeaders = normalizeHeaders;
|
|
186
|
+
/**
|
|
187
|
+
* Case-insensitive check for a non-empty `Authorization` header.
|
|
188
|
+
*/
|
|
189
|
+
function hasAuthorization(headers) {
|
|
190
|
+
for (const key of Object.keys(headers)) {
|
|
191
|
+
if (key.toLowerCase() === 'authorization' && headers[key]) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
exports.hasAuthorization = hasAuthorization;
|
|
198
|
+
/**
|
|
199
|
+
* Returns a safe `process_name` value: the basename of the first whitespace-
|
|
200
|
+
* delimited token, with trailing whitespace trimmed. This defeats both the
|
|
201
|
+
* absolute-path PII leak (`/home/<user>/app.js`) and the argv-leak shape
|
|
202
|
+
* (`node --db-password=X app.js`) that some producers pass in.
|
|
203
|
+
*/
|
|
204
|
+
function sanitizeProcessName(name) {
|
|
205
|
+
if (!name) {
|
|
206
|
+
return '';
|
|
207
|
+
}
|
|
208
|
+
const trimmed = name.trim();
|
|
209
|
+
if (trimmed.length === 0) {
|
|
210
|
+
return '';
|
|
211
|
+
}
|
|
212
|
+
// Drop argv tail: anything after the first whitespace — argv[0] shouldn't
|
|
213
|
+
// contain spaces, but producers sometimes pass `argv.join(' ')`.
|
|
214
|
+
const firstToken = trimmed.split(/\s/, 1)[0];
|
|
215
|
+
if (!firstToken) {
|
|
216
|
+
return '';
|
|
217
|
+
}
|
|
218
|
+
const lastSep = Math.max(firstToken.lastIndexOf('/'), firstToken.lastIndexOf('\\'));
|
|
219
|
+
return lastSep < 0 ? firstToken : firstToken.slice(lastSep + 1);
|
|
220
|
+
}
|
|
221
|
+
exports.sanitizeProcessName = sanitizeProcessName;
|
|
222
|
+
//# sourceMappingURL=telemetryUtils.js.map
|
|
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AAC;KACX;IACD,0EAA0E;IAC1E,iEAAiE;IACjE,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,EAAE,CAAC;KACX;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACpF,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;AAClE,CAAC;AAhBD,kDAgBC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Driver name constant for telemetry
|
|
18
|
+
*/
|
|
19
|
+
export declare const DRIVER_NAME = "nodejs-sql-driver";
|
|
20
|
+
/**
|
|
21
|
+
* Event types emitted by the telemetry system
|
|
22
|
+
*/
|
|
23
|
+
export declare enum TelemetryEventType {
|
|
24
|
+
CONNECTION_OPEN = "connection.open",
|
|
25
|
+
STATEMENT_START = "statement.start",
|
|
26
|
+
STATEMENT_COMPLETE = "statement.complete",
|
|
27
|
+
CLOUDFETCH_CHUNK = "cloudfetch.chunk",
|
|
28
|
+
ERROR = "telemetry.error"
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for telemetry components
|
|
32
|
+
*/
|
|
33
|
+
export interface TelemetryConfiguration {
|
|
34
|
+
/** Whether telemetry is enabled */
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
/** Maximum number of metrics to batch before flushing */
|
|
37
|
+
batchSize?: number;
|
|
38
|
+
/** Interval in milliseconds to flush metrics */
|
|
39
|
+
flushIntervalMs?: number;
|
|
40
|
+
/** Maximum retry attempts for export (attempts *after* the initial call) */
|
|
41
|
+
maxRetries?: number;
|
|
42
|
+
/** Minimum backoff delay in ms for retry backoff */
|
|
43
|
+
backoffBaseMs?: number;
|
|
44
|
+
/** Maximum backoff delay in ms (includes jitter) */
|
|
45
|
+
backoffMaxMs?: number;
|
|
46
|
+
/** Upper bound of added jitter in ms */
|
|
47
|
+
backoffJitterMs?: number;
|
|
48
|
+
/** Whether to use authenticated export endpoint */
|
|
49
|
+
authenticatedExport?: boolean;
|
|
50
|
+
/** Circuit breaker failure threshold */
|
|
51
|
+
circuitBreakerThreshold?: number;
|
|
52
|
+
/** Circuit breaker timeout in milliseconds */
|
|
53
|
+
circuitBreakerTimeout?: number;
|
|
54
|
+
/** Maximum number of pending metrics buffered before dropping oldest */
|
|
55
|
+
maxPendingMetrics?: number;
|
|
56
|
+
/** Maximum number of error events buffered per statement before dropping oldest */
|
|
57
|
+
maxErrorsPerStatement?: number;
|
|
58
|
+
/** TTL in ms after which abandoned statement aggregations are evicted */
|
|
59
|
+
statementTtlMs?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Default telemetry configuration values
|
|
63
|
+
*/
|
|
64
|
+
export declare const DEFAULT_TELEMETRY_CONFIG: Readonly<Required<TelemetryConfiguration>>;
|
|
65
|
+
/**
|
|
66
|
+
* Runtime telemetry event emitted by the driver
|
|
67
|
+
*/
|
|
68
|
+
export interface TelemetryEvent {
|
|
69
|
+
/** Type of the event */
|
|
70
|
+
eventType: TelemetryEventType;
|
|
71
|
+
/** Timestamp when the event occurred (milliseconds since epoch) */
|
|
72
|
+
timestamp: number;
|
|
73
|
+
/** Session ID for correlation */
|
|
74
|
+
sessionId?: string;
|
|
75
|
+
/** Statement ID for correlation */
|
|
76
|
+
statementId?: string;
|
|
77
|
+
/** Workspace ID */
|
|
78
|
+
workspaceId?: string;
|
|
79
|
+
/** Driver configuration */
|
|
80
|
+
driverConfig?: DriverConfiguration;
|
|
81
|
+
/** Type of operation (SELECT, INSERT, etc.) */
|
|
82
|
+
operationType?: string;
|
|
83
|
+
/** Execution latency in milliseconds */
|
|
84
|
+
latencyMs?: number;
|
|
85
|
+
/** Result format (inline, cloudfetch, arrow) */
|
|
86
|
+
resultFormat?: string;
|
|
87
|
+
/** Number of result chunks */
|
|
88
|
+
chunkCount?: number;
|
|
89
|
+
/** Total bytes downloaded */
|
|
90
|
+
bytesDownloaded?: number;
|
|
91
|
+
/** Number of poll operations */
|
|
92
|
+
pollCount?: number;
|
|
93
|
+
/** Chunk index in the result set */
|
|
94
|
+
chunkIndex?: number;
|
|
95
|
+
/** Number of bytes in this chunk */
|
|
96
|
+
bytes?: number;
|
|
97
|
+
/** Whether compression was used */
|
|
98
|
+
compressed?: boolean;
|
|
99
|
+
/** Error name/type */
|
|
100
|
+
errorName?: string;
|
|
101
|
+
/** Error message */
|
|
102
|
+
errorMessage?: string;
|
|
103
|
+
/** Stack trace, captured at emission site; redacted before export */
|
|
104
|
+
errorStack?: string;
|
|
105
|
+
/** Whether the error is terminal (non-retryable) */
|
|
106
|
+
isTerminal?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Aggregated telemetry metric for export to Databricks
|
|
110
|
+
*/
|
|
111
|
+
export interface TelemetryMetric {
|
|
112
|
+
/** Type of metric */
|
|
113
|
+
metricType: 'connection' | 'statement' | 'error';
|
|
114
|
+
/** Timestamp when the metric was created (milliseconds since epoch) */
|
|
115
|
+
timestamp: number;
|
|
116
|
+
/** Session ID for correlation */
|
|
117
|
+
sessionId?: string;
|
|
118
|
+
/** Statement ID for correlation */
|
|
119
|
+
statementId?: string;
|
|
120
|
+
/** Workspace ID */
|
|
121
|
+
workspaceId?: string;
|
|
122
|
+
/** Driver configuration (for connection metrics) */
|
|
123
|
+
driverConfig?: DriverConfiguration;
|
|
124
|
+
/** Execution latency in milliseconds */
|
|
125
|
+
latencyMs?: number;
|
|
126
|
+
/** Result format (inline, cloudfetch, arrow) */
|
|
127
|
+
resultFormat?: string;
|
|
128
|
+
/** Number of result chunks */
|
|
129
|
+
chunkCount?: number;
|
|
130
|
+
/** Total bytes downloaded */
|
|
131
|
+
bytesDownloaded?: number;
|
|
132
|
+
/** Number of poll operations */
|
|
133
|
+
pollCount?: number;
|
|
134
|
+
/** Error name/type */
|
|
135
|
+
errorName?: string;
|
|
136
|
+
/** Error message */
|
|
137
|
+
errorMessage?: string;
|
|
138
|
+
/** Stack trace, captured at emission site; redacted before export */
|
|
139
|
+
errorStack?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Driver configuration metadata collected once per connection
|
|
143
|
+
*/
|
|
144
|
+
export interface DriverConfiguration {
|
|
145
|
+
/** Driver version */
|
|
146
|
+
driverVersion: string;
|
|
147
|
+
/** Driver name */
|
|
148
|
+
driverName: string;
|
|
149
|
+
/** Node.js version */
|
|
150
|
+
nodeVersion: string;
|
|
151
|
+
/** Platform (linux, darwin, win32) */
|
|
152
|
+
platform: string;
|
|
153
|
+
/** OS version */
|
|
154
|
+
osVersion: string;
|
|
155
|
+
/** OS architecture (x64, arm64, etc.) */
|
|
156
|
+
osArch: string;
|
|
157
|
+
/** Runtime vendor (Node.js Foundation) */
|
|
158
|
+
runtimeVendor: string;
|
|
159
|
+
/** Locale name (e.g., en_US) */
|
|
160
|
+
localeName: string;
|
|
161
|
+
/** Character set encoding (e.g., UTF-8) */
|
|
162
|
+
charSetEncoding: string;
|
|
163
|
+
/**
|
|
164
|
+
* Process name. Producers MUST pass only a basename (no absolute path) —
|
|
165
|
+
* `sanitizeProcessName()` is applied at export time as a defence in depth.
|
|
166
|
+
*/
|
|
167
|
+
processName: string;
|
|
168
|
+
/** Whether CloudFetch is enabled */
|
|
169
|
+
cloudFetchEnabled: boolean;
|
|
170
|
+
/** Whether LZ4 compression is enabled */
|
|
171
|
+
lz4Enabled: boolean;
|
|
172
|
+
/** Whether Arrow format is enabled */
|
|
173
|
+
arrowEnabled: boolean;
|
|
174
|
+
/** Whether direct results are enabled */
|
|
175
|
+
directResultsEnabled: boolean;
|
|
176
|
+
/** Socket timeout in milliseconds */
|
|
177
|
+
socketTimeout: number;
|
|
178
|
+
/** Maximum retry attempts */
|
|
179
|
+
retryMaxAttempts: number;
|
|
180
|
+
/** Number of concurrent CloudFetch downloads */
|
|
181
|
+
cloudFetchConcurrentDownloads: number;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Per-statement metrics aggregated from multiple events
|
|
185
|
+
*/
|
|
186
|
+
export interface StatementMetrics {
|
|
187
|
+
/** Statement ID */
|
|
188
|
+
statementId: string;
|
|
189
|
+
/** Session ID */
|
|
190
|
+
sessionId: string;
|
|
191
|
+
/** Type of operation */
|
|
192
|
+
operationType?: string;
|
|
193
|
+
/** Start timestamp (milliseconds since epoch) */
|
|
194
|
+
startTime: number;
|
|
195
|
+
/** Total execution latency in milliseconds */
|
|
196
|
+
executionLatencyMs?: number;
|
|
197
|
+
/** Number of poll operations */
|
|
198
|
+
pollCount: number;
|
|
199
|
+
/** Total poll latency in milliseconds */
|
|
200
|
+
pollLatencyMs: number;
|
|
201
|
+
/** Result format (inline, cloudfetch, arrow) */
|
|
202
|
+
resultFormat?: string;
|
|
203
|
+
/** Number of CloudFetch chunks downloaded */
|
|
204
|
+
chunkCount: number;
|
|
205
|
+
/** Total bytes downloaded */
|
|
206
|
+
totalBytesDownloaded: number;
|
|
207
|
+
/** Whether compression was used */
|
|
208
|
+
compressionEnabled?: boolean;
|
|
209
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DEFAULT_TELEMETRY_CONFIG = exports.TelemetryEventType = exports.DRIVER_NAME = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Driver name constant for telemetry
|
|
21
|
+
*/
|
|
22
|
+
exports.DRIVER_NAME = 'nodejs-sql-driver';
|
|
23
|
+
/**
|
|
24
|
+
* Event types emitted by the telemetry system
|
|
25
|
+
*/
|
|
26
|
+
var TelemetryEventType;
|
|
27
|
+
(function (TelemetryEventType) {
|
|
28
|
+
TelemetryEventType["CONNECTION_OPEN"] = "connection.open";
|
|
29
|
+
TelemetryEventType["STATEMENT_START"] = "statement.start";
|
|
30
|
+
TelemetryEventType["STATEMENT_COMPLETE"] = "statement.complete";
|
|
31
|
+
TelemetryEventType["CLOUDFETCH_CHUNK"] = "cloudfetch.chunk";
|
|
32
|
+
TelemetryEventType["ERROR"] = "telemetry.error";
|
|
33
|
+
})(TelemetryEventType = exports.TelemetryEventType || (exports.TelemetryEventType = {}));
|
|
34
|
+
/**
|
|
35
|
+
* Default telemetry configuration values
|
|
36
|
+
*/
|
|
37
|
+
exports.DEFAULT_TELEMETRY_CONFIG = Object.freeze({
|
|
38
|
+
enabled: false,
|
|
39
|
+
batchSize: 100,
|
|
40
|
+
flushIntervalMs: 5000,
|
|
41
|
+
maxRetries: 3,
|
|
42
|
+
backoffBaseMs: 100,
|
|
43
|
+
backoffMaxMs: 1000,
|
|
44
|
+
backoffJitterMs: 100,
|
|
45
|
+
authenticatedExport: true,
|
|
46
|
+
circuitBreakerThreshold: 5,
|
|
47
|
+
circuitBreakerTimeout: 60000,
|
|
48
|
+
maxPendingMetrics: 500,
|
|
49
|
+
maxErrorsPerStatement: 50,
|
|
50
|
+
statementTtlMs: 60 * 60 * 1000, // 1 hour
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/telemetry/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;GAEG;AACU,QAAA,WAAW,GAAG,mBAAmB,CAAC;AAE/C;;GAEG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,yDAAmC,CAAA;IACnC,yDAAmC,CAAA;IACnC,+DAAyC,CAAA;IACzC,2DAAqC,CAAA;IACrC,+CAAyB,CAAA;AAC3B,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B;AA8CD;;GAEG;AACU,QAAA,wBAAwB,GAA+C,MAAM,CAAC,MAAM,CAAC;IAChG,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,IAAI;IACrB,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,GAAG;IACpB,mBAAmB,EAAE,IAAI;IACzB,uBAAuB,EAAE,CAAC;IAC1B,qBAAqB,EAAE,KAAK;IAC5B,iBAAiB,EAAE,GAAG;IACtB,qBAAqB,EAAE,EAAE;IACzB,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS;CAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Build full URL from host and path, handling protocol correctly.
|
|
18
|
+
* @param host The hostname (with or without protocol)
|
|
19
|
+
* @param path The path to append (should start with /)
|
|
20
|
+
* @returns Full URL with protocol
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildUrl(host: string, path: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Databricks Contributors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.buildUrl = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Build full URL from host and path, handling protocol correctly.
|
|
21
|
+
* @param host The hostname (with or without protocol)
|
|
22
|
+
* @param path The path to append (should start with /)
|
|
23
|
+
* @returns Full URL with protocol
|
|
24
|
+
*/
|
|
25
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
26
|
+
function buildUrl(host, path) {
|
|
27
|
+
// Check if host already has protocol
|
|
28
|
+
if (host.startsWith('http://') || host.startsWith('https://')) {
|
|
29
|
+
return `${host}${path}`;
|
|
30
|
+
}
|
|
31
|
+
// Add https:// if no protocol present
|
|
32
|
+
return `https://${host}${path}`;
|
|
33
|
+
}
|
|
34
|
+
exports.buildUrl = buildUrl;
|
|
35
|
+
//# sourceMappingURL=urlUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../../lib/telemetry/urlUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;;GAKG;AACH,wDAAwD;AACxD,SAAgB,QAAQ,CAAC,IAAY,EAAE,IAAY;IACjD,qCAAqC;IACrC,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC7D,OAAO,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;KACzB;IACD,sCAAsC;IACtC,OAAO,WAAW,IAAI,GAAG,IAAI,EAAE,CAAC;AAClC,CAAC;AAPD,4BAOC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects whether the Node.js SQL driver is being invoked by an AI coding agent
|
|
3
|
+
* by checking for well-known environment variables that agents set in their
|
|
4
|
+
* spawned shell processes.
|
|
5
|
+
*
|
|
6
|
+
* Detection only succeeds when exactly one agent environment variable is present,
|
|
7
|
+
* to avoid ambiguous attribution when multiple agent environments overlap.
|
|
8
|
+
*
|
|
9
|
+
* Adding a new agent requires only a new entry in `knownAgents`.
|
|
10
|
+
*
|
|
11
|
+
* References for each environment variable:
|
|
12
|
+
* - ANTIGRAVITY_AGENT: Closed source. Google Antigravity sets this variable.
|
|
13
|
+
* - CLAUDECODE: https://github.com/anthropics/claude-code (sets CLAUDECODE=1)
|
|
14
|
+
* - CLINE_ACTIVE: https://github.com/cline/cline (shipped in v3.24.0)
|
|
15
|
+
* - CODEX_CI: https://github.com/openai/codex (part of UNIFIED_EXEC_ENV array in codex-rs)
|
|
16
|
+
* - CURSOR_AGENT: Closed source. Referenced in a gist by johnlindquist.
|
|
17
|
+
* - GEMINI_CLI: https://google-gemini.github.io/gemini-cli/docs/tools/shell.html (sets GEMINI_CLI=1)
|
|
18
|
+
* - OPENCODE: https://github.com/opencode-ai/opencode (sets OPENCODE=1)
|
|
19
|
+
*/
|
|
20
|
+
export default function detectAgent(env?: Record<string, string | undefined>): string;
|