@databricks/sql 1.13.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 +8 -0
- package/dist/DBSQLClient.js +25 -0
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLSession.js +4 -0
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/contracts/IClientContext.d.ts +7 -0
- package/dist/contracts/IDBSQLClient.d.ts +6 -0
- package/dist/contracts/IDBSQLSession.d.ts +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -1
- package/dist/index.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.js +12 -0
- package/dist/telemetry/ExceptionClassifier.js.map +1 -1
- 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 +37 -4
- package/dist/telemetry/types.js +15 -5
- package/dist/telemetry/types.js.map +1 -1
- 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/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,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetryUtils.js","sourceRoot":"","sources":["../../lib/telemetry/telemetryUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;;GAKG;AACH,MAAM,qBAAqB,GAAa;IACtC,0EAA0E;IAC1E,kEAAkE;IAClE,aAAa;IACb,4BAA4B;IAC5B,qCAAqC;CACtC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,SAAgB,iBAAiB,CAAC,IAAY,EAAE,IAAY;IAC1D,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACjD,OAAO,IAAI,CAAC;KACb;IAED,0EAA0E;IAC1E,gDAAgD;IAChD,IAAI,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC9C,OAAO,IAAI,CAAC;KACb;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAED,sEAAsE;IACtE,2EAA2E;IAC3E,0DAA0D;IAC1D,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC5B,OA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AE,KAAK,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC;SACb;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,4CAOC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,IAAwB;IAC1D,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,EAAE,CAAC;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"}
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* Driver name constant for telemetry
|
|
18
|
+
*/
|
|
19
|
+
export declare const DRIVER_NAME = "nodejs-sql-driver";
|
|
16
20
|
/**
|
|
17
21
|
* Event types emitted by the telemetry system
|
|
18
22
|
*/
|
|
@@ -21,7 +25,7 @@ export declare enum TelemetryEventType {
|
|
|
21
25
|
STATEMENT_START = "statement.start",
|
|
22
26
|
STATEMENT_COMPLETE = "statement.complete",
|
|
23
27
|
CLOUDFETCH_CHUNK = "cloudfetch.chunk",
|
|
24
|
-
ERROR = "error"
|
|
28
|
+
ERROR = "telemetry.error"
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* Configuration for telemetry components
|
|
@@ -33,25 +37,37 @@ export interface TelemetryConfiguration {
|
|
|
33
37
|
batchSize?: number;
|
|
34
38
|
/** Interval in milliseconds to flush metrics */
|
|
35
39
|
flushIntervalMs?: number;
|
|
36
|
-
/** Maximum retry attempts for export */
|
|
40
|
+
/** Maximum retry attempts for export (attempts *after* the initial call) */
|
|
37
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;
|
|
38
48
|
/** Whether to use authenticated export endpoint */
|
|
39
49
|
authenticatedExport?: boolean;
|
|
40
50
|
/** Circuit breaker failure threshold */
|
|
41
51
|
circuitBreakerThreshold?: number;
|
|
42
52
|
/** Circuit breaker timeout in milliseconds */
|
|
43
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;
|
|
44
60
|
}
|
|
45
61
|
/**
|
|
46
62
|
* Default telemetry configuration values
|
|
47
63
|
*/
|
|
48
|
-
export declare const DEFAULT_TELEMETRY_CONFIG: Required<TelemetryConfiguration
|
|
64
|
+
export declare const DEFAULT_TELEMETRY_CONFIG: Readonly<Required<TelemetryConfiguration>>;
|
|
49
65
|
/**
|
|
50
66
|
* Runtime telemetry event emitted by the driver
|
|
51
67
|
*/
|
|
52
68
|
export interface TelemetryEvent {
|
|
53
69
|
/** Type of the event */
|
|
54
|
-
eventType: TelemetryEventType
|
|
70
|
+
eventType: TelemetryEventType;
|
|
55
71
|
/** Timestamp when the event occurred (milliseconds since epoch) */
|
|
56
72
|
timestamp: number;
|
|
57
73
|
/** Session ID for correlation */
|
|
@@ -84,6 +100,8 @@ export interface TelemetryEvent {
|
|
|
84
100
|
errorName?: string;
|
|
85
101
|
/** Error message */
|
|
86
102
|
errorMessage?: string;
|
|
103
|
+
/** Stack trace, captured at emission site; redacted before export */
|
|
104
|
+
errorStack?: string;
|
|
87
105
|
/** Whether the error is terminal (non-retryable) */
|
|
88
106
|
isTerminal?: boolean;
|
|
89
107
|
}
|
|
@@ -117,6 +135,8 @@ export interface TelemetryMetric {
|
|
|
117
135
|
errorName?: string;
|
|
118
136
|
/** Error message */
|
|
119
137
|
errorMessage?: string;
|
|
138
|
+
/** Stack trace, captured at emission site; redacted before export */
|
|
139
|
+
errorStack?: string;
|
|
120
140
|
}
|
|
121
141
|
/**
|
|
122
142
|
* Driver configuration metadata collected once per connection
|
|
@@ -132,6 +152,19 @@ export interface DriverConfiguration {
|
|
|
132
152
|
platform: string;
|
|
133
153
|
/** OS version */
|
|
134
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;
|
|
135
168
|
/** Whether CloudFetch is enabled */
|
|
136
169
|
cloudFetchEnabled: boolean;
|
|
137
170
|
/** Whether LZ4 compression is enabled */
|
package/dist/telemetry/types.js
CHANGED
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DEFAULT_TELEMETRY_CONFIG = exports.TelemetryEventType = void 0;
|
|
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';
|
|
19
23
|
/**
|
|
20
24
|
* Event types emitted by the telemetry system
|
|
21
25
|
*/
|
|
@@ -25,18 +29,24 @@ var TelemetryEventType;
|
|
|
25
29
|
TelemetryEventType["STATEMENT_START"] = "statement.start";
|
|
26
30
|
TelemetryEventType["STATEMENT_COMPLETE"] = "statement.complete";
|
|
27
31
|
TelemetryEventType["CLOUDFETCH_CHUNK"] = "cloudfetch.chunk";
|
|
28
|
-
TelemetryEventType["ERROR"] = "error";
|
|
32
|
+
TelemetryEventType["ERROR"] = "telemetry.error";
|
|
29
33
|
})(TelemetryEventType = exports.TelemetryEventType || (exports.TelemetryEventType = {}));
|
|
30
34
|
/**
|
|
31
35
|
* Default telemetry configuration values
|
|
32
36
|
*/
|
|
33
|
-
exports.DEFAULT_TELEMETRY_CONFIG = {
|
|
37
|
+
exports.DEFAULT_TELEMETRY_CONFIG = Object.freeze({
|
|
34
38
|
enabled: false,
|
|
35
39
|
batchSize: 100,
|
|
36
40
|
flushIntervalMs: 5000,
|
|
37
41
|
maxRetries: 3,
|
|
42
|
+
backoffBaseMs: 100,
|
|
43
|
+
backoffMaxMs: 1000,
|
|
44
|
+
backoffJitterMs: 100,
|
|
38
45
|
authenticatedExport: true,
|
|
39
46
|
circuitBreakerThreshold: 5,
|
|
40
|
-
circuitBreakerTimeout: 60000,
|
|
41
|
-
|
|
47
|
+
circuitBreakerTimeout: 60000,
|
|
48
|
+
maxPendingMetrics: 500,
|
|
49
|
+
maxErrorsPerStatement: 50,
|
|
50
|
+
statementTtlMs: 60 * 60 * 1000, // 1 hour
|
|
51
|
+
});
|
|
42
52
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/telemetry/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;GAEG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,yDAAmC,CAAA;IACnC,yDAAmC,CAAA;IACnC,+DAAyC,CAAA;IACzC,2DAAqC,CAAA;IACrC,
|
|
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;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Detects whether the Node.js SQL driver is being invoked by an AI coding agent
|
|
4
|
+
* by checking for well-known environment variables that agents set in their
|
|
5
|
+
* spawned shell processes.
|
|
6
|
+
*
|
|
7
|
+
* Detection only succeeds when exactly one agent environment variable is present,
|
|
8
|
+
* to avoid ambiguous attribution when multiple agent environments overlap.
|
|
9
|
+
*
|
|
10
|
+
* Adding a new agent requires only a new entry in `knownAgents`.
|
|
11
|
+
*
|
|
12
|
+
* References for each environment variable:
|
|
13
|
+
* - ANTIGRAVITY_AGENT: Closed source. Google Antigravity sets this variable.
|
|
14
|
+
* - CLAUDECODE: https://github.com/anthropics/claude-code (sets CLAUDECODE=1)
|
|
15
|
+
* - CLINE_ACTIVE: https://github.com/cline/cline (shipped in v3.24.0)
|
|
16
|
+
* - CODEX_CI: https://github.com/openai/codex (part of UNIFIED_EXEC_ENV array in codex-rs)
|
|
17
|
+
* - CURSOR_AGENT: Closed source. Referenced in a gist by johnlindquist.
|
|
18
|
+
* - GEMINI_CLI: https://google-gemini.github.io/gemini-cli/docs/tools/shell.html (sets GEMINI_CLI=1)
|
|
19
|
+
* - OPENCODE: https://github.com/opencode-ai/opencode (sets OPENCODE=1)
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const knownAgents = [
|
|
23
|
+
{ envVar: 'ANTIGRAVITY_AGENT', product: 'antigravity' },
|
|
24
|
+
{ envVar: 'CLAUDECODE', product: 'claude-code' },
|
|
25
|
+
{ envVar: 'CLINE_ACTIVE', product: 'cline' },
|
|
26
|
+
{ envVar: 'CODEX_CI', product: 'codex' },
|
|
27
|
+
{ envVar: 'CURSOR_AGENT', product: 'cursor' },
|
|
28
|
+
{ envVar: 'GEMINI_CLI', product: 'gemini-cli' },
|
|
29
|
+
{ envVar: 'OPENCODE', product: 'opencode' },
|
|
30
|
+
];
|
|
31
|
+
function detectAgent(env = process.env) {
|
|
32
|
+
const detected = knownAgents.filter((a) => env[a.envVar]).map((a) => a.product);
|
|
33
|
+
if (detected.length === 1) {
|
|
34
|
+
return detected[0];
|
|
35
|
+
}
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
exports.default = detectAgent;
|
|
39
|
+
//# sourceMappingURL=agentDetector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentDetector.js","sourceRoot":"","sources":["../../lib/utils/agentDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;AAEH,MAAM,WAAW,GAA+C;IAC9D,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,EAAE;IACvD,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE;IAChD,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE;IAC5C,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE;IACxC,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE;IAC7C,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE;IAC/C,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE;CAC5C,CAAC;AAEF,SAAwB,WAAW,CAAC,MAA0C,OAAO,CAAC,GAAG;IACvF,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAEhF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;KACpB;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAPD,8BAOC"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const os_1 = __importDefault(require("os"));
|
|
7
7
|
const version_1 = __importDefault(require("../version"));
|
|
8
|
+
const agentDetector_1 = __importDefault(require("./agentDetector"));
|
|
8
9
|
const productName = 'NodejsDatabricksSqlConnector';
|
|
9
10
|
function getNodeVersion() {
|
|
10
11
|
return `Node.js ${process.versions.node}`;
|
|
@@ -26,7 +27,12 @@ function buildUserAgentString(userAgentEntry) {
|
|
|
26
27
|
userAgentEntry = redactInternalToken(userAgentEntry);
|
|
27
28
|
}
|
|
28
29
|
const extra = [userAgentEntry, getNodeVersion(), getOperatingSystemVersion()].filter(Boolean);
|
|
29
|
-
|
|
30
|
+
let ua = `${productName}/${version_1.default} (${extra.join('; ')})`;
|
|
31
|
+
const agentProduct = (0, agentDetector_1.default)();
|
|
32
|
+
if (agentProduct) {
|
|
33
|
+
ua += ` agent/${agentProduct}`;
|
|
34
|
+
}
|
|
35
|
+
return ua;
|
|
30
36
|
}
|
|
31
37
|
exports.default = buildUserAgentString;
|
|
32
38
|
//# sourceMappingURL=buildUserAgentString.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUserAgentString.js","sourceRoot":"","sources":["../../lib/utils/buildUserAgentString.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,yDAAwC;
|
|
1
|
+
{"version":3,"file":"buildUserAgentString.js","sourceRoot":"","sources":["../../lib/utils/buildUserAgentString.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,yDAAwC;AACxC,oEAA0C;AAE1C,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAEnD,SAAS,cAAc;IACrB,OAAO,WAAW,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,yBAAyB;IAChC,OAAO,GAAG,YAAE,CAAC,IAAI,EAAE,IAAI,YAAE,CAAC,OAAO,EAAE,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,mBAAmB,CAAC,cAAsB;IACjD,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzE,KAAK,MAAM,MAAM,IAAI,qBAAqB,EAAE;QAC1C,IAAI,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YACrC,OAAO,YAAY,CAAC;SACrB;KACF;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAwB,oBAAoB,CAAC,cAAuB;IAClE,IAAI,cAAc,EAAE;QAClB,cAAc,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAAC;KACtD;IAED,MAAM,KAAK,GAAG,CAAC,cAAc,EAAE,cAAc,EAAE,EAAE,yBAAyB,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9F,IAAI,EAAE,GAAG,GAAG,WAAW,IAAI,iBAAc,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAElE,MAAM,YAAY,GAAG,IAAA,uBAAW,GAAE,CAAC;IACnC,IAAI,YAAY,EAAE;QAChB,EAAE,IAAI,UAAU,YAAY,EAAE,CAAC;KAChC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAdD,uCAcC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import buildUserAgentString from './buildUserAgentString';
|
|
|
3
3
|
import formatProgress, { ProgressUpdateTransformer } from './formatProgress';
|
|
4
4
|
import LZ4 from './lz4';
|
|
5
5
|
import * as ProtocolVersion from './protocolVersion';
|
|
6
|
-
|
|
6
|
+
import serializeQueryTags from './queryTags';
|
|
7
|
+
export { definedOrError, buildUserAgentString, formatProgress, ProgressUpdateTransformer, LZ4, ProtocolVersion, serializeQueryTags, };
|
package/dist/utils/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ProtocolVersion = exports.LZ4 = exports.ProgressUpdateTransformer = exports.formatProgress = exports.buildUserAgentString = exports.definedOrError = void 0;
|
|
29
|
+
exports.serializeQueryTags = exports.ProtocolVersion = exports.LZ4 = exports.ProgressUpdateTransformer = exports.formatProgress = exports.buildUserAgentString = exports.definedOrError = void 0;
|
|
30
30
|
const definedOrError_1 = __importDefault(require("./definedOrError"));
|
|
31
31
|
exports.definedOrError = definedOrError_1.default;
|
|
32
32
|
const buildUserAgentString_1 = __importDefault(require("./buildUserAgentString"));
|
|
@@ -38,4 +38,6 @@ const lz4_1 = __importDefault(require("./lz4"));
|
|
|
38
38
|
exports.LZ4 = lz4_1.default;
|
|
39
39
|
const ProtocolVersion = __importStar(require("./protocolVersion"));
|
|
40
40
|
exports.ProtocolVersion = ProtocolVersion;
|
|
41
|
+
const queryTags_1 = __importDefault(require("./queryTags"));
|
|
42
|
+
exports.serializeQueryTags = queryTags_1.default;
|
|
41
43
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA8C;AAQ5C,yBARK,wBAAc,CAQL;AAPhB,kFAA0D;AAQxD,+BARK,8BAAoB,CAQL;AAPtB,mEAA6E;AAQ3E,yBARK,wBAAc,CAQL;AACd,0GATuB,0CAAyB,OASvB;AAR3B,gDAAwB;AAStB,cATK,aAAG,CASL;AARL,mEAAqD;AASnD,0CAAe;AARjB,4DAA6C;AAS3C,6BATK,mBAAkB,CASL"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes a query tags dictionary into a string for use in confOverlay.
|
|
3
|
+
*
|
|
4
|
+
* Format: comma-separated key:value pairs, e.g. "key1:value1,key2:value2"
|
|
5
|
+
* - If a value is null or undefined, the key is included without a colon or value
|
|
6
|
+
* - Backslashes in keys are escaped; other special characters in keys are not escaped
|
|
7
|
+
* - Special characters (backslash, colon, comma) in values are backslash-escaped
|
|
8
|
+
*
|
|
9
|
+
* @param queryTags - dictionary of query tag key-value pairs
|
|
10
|
+
* @returns serialized string, or undefined if input is empty/null/undefined
|
|
11
|
+
*/
|
|
12
|
+
export default function serializeQueryTags(queryTags: Record<string, string | null | undefined> | null | undefined): string | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Serializes a query tags dictionary into a string for use in confOverlay.
|
|
5
|
+
*
|
|
6
|
+
* Format: comma-separated key:value pairs, e.g. "key1:value1,key2:value2"
|
|
7
|
+
* - If a value is null or undefined, the key is included without a colon or value
|
|
8
|
+
* - Backslashes in keys are escaped; other special characters in keys are not escaped
|
|
9
|
+
* - Special characters (backslash, colon, comma) in values are backslash-escaped
|
|
10
|
+
*
|
|
11
|
+
* @param queryTags - dictionary of query tag key-value pairs
|
|
12
|
+
* @returns serialized string, or undefined if input is empty/null/undefined
|
|
13
|
+
*/
|
|
14
|
+
function serializeQueryTags(queryTags) {
|
|
15
|
+
if (queryTags == null) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const keys = Object.keys(queryTags);
|
|
19
|
+
if (keys.length === 0) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return keys
|
|
23
|
+
.map((key) => {
|
|
24
|
+
const escapedKey = key.replace(/\\/g, '\\\\');
|
|
25
|
+
const value = queryTags[key];
|
|
26
|
+
if (value == null) {
|
|
27
|
+
return escapedKey;
|
|
28
|
+
}
|
|
29
|
+
const escapedValue = value.replace(/[\\:,]/g, (c) => `\\${c}`);
|
|
30
|
+
return `${escapedKey}:${escapedValue}`;
|
|
31
|
+
})
|
|
32
|
+
.join(',');
|
|
33
|
+
}
|
|
34
|
+
exports.default = serializeQueryTags;
|
|
35
|
+
//# sourceMappingURL=queryTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryTags.js","sourceRoot":"","sources":["../../lib/utils/queryTags.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;GAUG;AACH,SAAwB,kBAAkB,CACxC,SAAuE;IAEvE,IAAI,SAAS,IAAI,IAAI,EAAE;QACrB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,OAAO,UAAU,CAAC;SACnB;QACD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/D,OAAO,GAAG,UAAU,IAAI,YAAY,EAAE,CAAC;IACzC,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAvBD,qCAuBC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.14.0";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED