@grow-codes/grafana-loki 0.1.0 → 0.1.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/lib/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk553Q2KB5_cjs = require('./chunk-553Q2KB5.cjs');
3
+ var chunkVGAJJR3M_cjs = require('./chunk-VGAJJR3M.cjs');
4
4
  var fs = require('fs');
5
5
  var undici = require('undici');
6
6
  var zlib = require('zlib');
@@ -106,7 +106,7 @@ function redactUrl(url) {
106
106
  }
107
107
  function redactQueryString(text) {
108
108
  return text.replace(
109
- /([?&])([^=&#\s]+)=([^&#\s]*)/g,
109
+ /([?&])([^=&#?\s]+)=([^&#\s]*)/g,
110
110
  (m, sep, k) => isSensitiveField(k) ? `${sep}${k}=${REDACTED}` : m
111
111
  );
112
112
  }
@@ -211,20 +211,33 @@ var UNIT_MS = {
211
211
  m: 6e4,
212
212
  h: 36e5
213
213
  };
214
- var DURATION_PART = /(\d+(?:\.\d+)?|\.\d+)(ns|us|µs|ms|s|m|h)/gy;
214
+ var DURATION_UNITS = ["ns", "us", "\xB5s", "ms", "s", "m", "h"];
215
215
  function parseDuration(raw) {
216
216
  const text = raw.trim();
217
217
  if (/^\d+$/.test(text)) return Number(text);
218
218
  if (text === "") return void 0;
219
- DURATION_PART.lastIndex = 0;
220
219
  let total = 0;
221
- let pos = 0;
222
- let match;
223
- while ((match = DURATION_PART.exec(text)) !== null) {
224
- total += Number(match[1]) * UNIT_MS[match[2]];
225
- pos = DURATION_PART.lastIndex;
220
+ let i = 0;
221
+ const isDigit = (at) => at < text.length && text.charCodeAt(at) >= 48 && text.charCodeAt(at) <= 57;
222
+ while (i < text.length) {
223
+ const start = i;
224
+ while (isDigit(i)) i += 1;
225
+ const intDigits = i - start;
226
+ if (text[i] === ".") {
227
+ i += 1;
228
+ const fracStart = i;
229
+ while (isDigit(i)) i += 1;
230
+ if (i === fracStart) return void 0;
231
+ } else if (intDigits === 0) {
232
+ return void 0;
233
+ }
234
+ const value = Number(text.slice(start, i));
235
+ const unit = DURATION_UNITS.find((u) => text.startsWith(u, i));
236
+ if (unit === void 0) return void 0;
237
+ total += value * UNIT_MS[unit];
238
+ i += unit.length;
226
239
  }
227
- return pos === text.length && pos > 0 ? Math.round(total) : void 0;
240
+ return Math.round(total);
228
241
  }
229
242
  var TRUE_WORDS = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
230
243
  var FALSE_WORDS = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
@@ -284,7 +297,7 @@ var EnvReader = class {
284
297
  if (hit === void 0) return void 0;
285
298
  const value = parse(hit.value);
286
299
  if (value === void 0) {
287
- throw new chunk553Q2KB5_cjs.ConfigError(
300
+ throw new chunkVGAJJR3M_cjs.ConfigError(
288
301
  `invalid value in environment variable ${hit.name}: expected ${expected}`
289
302
  );
290
303
  }
@@ -323,14 +336,14 @@ async function probeHealth(probe) {
323
336
  try {
324
337
  return await probe();
325
338
  } catch (err) {
326
- if (err instanceof chunk553Q2KB5_cjs.LokiError) {
327
- if (err.code === chunk553Q2KB5_cjs.ErrorCode.Cancelled || err.code === chunk553Q2KB5_cjs.ErrorCode.Config) throw err;
339
+ if (err instanceof chunkVGAJJR3M_cjs.LokiError) {
340
+ if (err.code === chunkVGAJJR3M_cjs.ErrorCode.Cancelled || err.code === chunkVGAJJR3M_cjs.ErrorCode.Config) throw err;
328
341
  if (err.httpStatus !== void 0) {
329
342
  return healthStatus("unhealthy", { httpStatus: err.httpStatus, error: err.code }, false);
330
343
  }
331
344
  return healthStatus("unreachable", { error: err.code }, false);
332
345
  }
333
- return healthStatus("unreachable", { error: chunk553Q2KB5_cjs.ErrorCode.Unavailable }, false);
346
+ return healthStatus("unreachable", { error: chunkVGAJJR3M_cjs.ErrorCode.Unavailable }, false);
334
347
  }
335
348
  }
336
349
 
@@ -520,7 +533,7 @@ function validateCommonConfig(config) {
520
533
  if (config.proxy !== void 0 && !isHttpUrl(config.proxy)) {
521
534
  problems.push("proxy must be an http or https URL");
522
535
  }
523
- if (problems.length > 0) throw new chunk553Q2KB5_cjs.ConfigError(`invalid configuration: ${problems.join("; ")}`);
536
+ if (problems.length > 0) throw new chunkVGAJJR3M_cjs.ConfigError(`invalid configuration: ${problems.join("; ")}`);
524
537
  }
525
538
  function readCommonEnv(reader, vendor = {}) {
526
539
  const out = {};
@@ -595,10 +608,10 @@ function secretValues(...values) {
595
608
  }
596
609
 
597
610
  // src/core/version.ts
598
- var SDK_VERSION = "0.1.0";
611
+ var SDK_VERSION = "0.1.1";
599
612
  var PACKAGE_KEY = "grafana-loki";
600
613
  var LANGUAGE = "typescript";
601
- var SDK_KIT_VERSION = "0.2.0";
614
+ var SDK_KIT_VERSION = "0.3.0";
602
615
 
603
616
  // src/core/transport.ts
604
617
  var DEFAULT_REQUEST_ID_HEADERS = [
@@ -688,7 +701,7 @@ var HttpTransport = class {
688
701
  this.#logger = safeLogger(options.config.logger);
689
702
  this.#hooks = options.config.hooks ?? {};
690
703
  this.#fetch = undici.fetch;
691
- this.#sleep = options.sleep ?? chunk553Q2KB5_cjs.sleep;
704
+ this.#sleep = options.sleep ?? chunkVGAJJR3M_cjs.sleep;
692
705
  this.#now = options.now ?? Date.now;
693
706
  this.#requestIdHeaders = options.requestIdHeaders ?? DEFAULT_REQUEST_ID_HEADERS;
694
707
  this.#dispatcher = options.dispatcher;
@@ -699,6 +712,14 @@ var HttpTransport = class {
699
712
  get closed() {
700
713
  return this.#closed;
701
714
  }
715
+ /**
716
+ * Throws `CancelledError` (`"<operation>: client is closed"`, not retryable) once {@link close}
717
+ * was called (SPEC §2.4). Requests check this themselves; service methods that send no request
718
+ * (cached reads, local helpers) call it first.
719
+ */
720
+ ensureOpen(operation) {
721
+ if (this.#closed) throw new chunkVGAJJR3M_cjs.CancelledError(`${operation}: client is closed`);
722
+ }
702
723
  /** Builds the absolute URL for a path and query. */
703
724
  buildUrl(path, query) {
704
725
  let url;
@@ -754,16 +775,16 @@ var HttpTransport = class {
754
775
  try {
755
776
  return await this.#request(options);
756
777
  } catch (err) {
757
- if (err instanceof chunk553Q2KB5_cjs.LokiError) err.message = this.redact(err.message);
778
+ if (err instanceof chunkVGAJJR3M_cjs.LokiError) err.message = this.redact(err.message);
758
779
  throw err;
759
780
  }
760
781
  }
761
782
  async #request(options) {
762
783
  const method = (options.method ?? "GET").toUpperCase();
763
784
  const operation = options.operation ?? `${method} ${options.path.split("?")[0] ?? ""}`;
764
- if (this.#closed) throw new chunk553Q2KB5_cjs.CancelledError(`${operation}: client is closed`);
785
+ this.ensureOpen(operation);
765
786
  const signal = options.signal;
766
- if (signal?.aborted === true) throw new chunk553Q2KB5_cjs.CancelledError(`${operation}: cancelled`);
787
+ if (signal?.aborted === true) throw new chunkVGAJJR3M_cjs.CancelledError(`${operation}: cancelled`);
767
788
  const url = this.buildUrl(options.path, options.query);
768
789
  const safeUrl = redactUrl(url);
769
790
  const headers = this.#buildHeaders(options);
@@ -777,7 +798,7 @@ var HttpTransport = class {
777
798
  for (let attempt = 1; ; attempt++) {
778
799
  const remaining = deadline - this.#now();
779
800
  if (remaining <= 0) {
780
- throw new chunk553Q2KB5_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`);
801
+ throw new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`);
781
802
  }
782
803
  const attemptTimeout = Math.min(requestTimeout, remaining);
783
804
  const isTotal = attemptTimeout < requestTimeout;
@@ -833,7 +854,7 @@ var HttpTransport = class {
833
854
  }
834
855
  const retryAfter = res.status === 429 || res.status === 503 ? parseRetryAfter(res.headers.get("retry-after"), this.#now()) : void 0;
835
856
  const reason = this.vendorText(res.text);
836
- const defaultError = chunk553Q2KB5_cjs.errorForStatus(operation, res.status, {
857
+ const defaultError = chunkVGAJJR3M_cjs.errorForStatus(operation, res.status, {
837
858
  ...reason === void 0 ? {} : { reason },
838
859
  ...requestId === void 0 ? {} : { requestId },
839
860
  ...retryAfter === void 0 ? {} : { retryAfterMs: retryAfter }
@@ -879,7 +900,7 @@ var HttpTransport = class {
879
900
  attempt,
880
901
  willRetry: false
881
902
  });
882
- throw new chunk553Q2KB5_cjs.TimeoutError(
903
+ throw new chunkVGAJJR3M_cjs.TimeoutError(
883
904
  `${operation}: total timeout of ${totalTimeout} ms exceeded after ${attempt} attempts`,
884
905
  {
885
906
  cause: failure,
@@ -906,7 +927,7 @@ var HttpTransport = class {
906
927
  waitMs: Math.round(waitMs)
907
928
  });
908
929
  await this.#sleep(waitMs, signal).catch((err) => {
909
- throw err instanceof chunk553Q2KB5_cjs.LokiError ? err : new chunk553Q2KB5_cjs.CancelledError(`${operation}: cancelled`);
930
+ throw err instanceof chunkVGAJJR3M_cjs.LokiError ? err : new chunkVGAJJR3M_cjs.CancelledError(`${operation}: cancelled`);
910
931
  });
911
932
  }
912
933
  }
@@ -981,30 +1002,30 @@ var HttpTransport = class {
981
1002
  try {
982
1003
  return JSON.parse(text);
983
1004
  } catch {
984
- throw new chunk553Q2KB5_cjs.UnavailableError(`invalid JSON in response (HTTP ${status})`, {
1005
+ throw new chunkVGAJJR3M_cjs.UnavailableError(`invalid JSON in response (HTTP ${status})`, {
985
1006
  retryable: false,
986
1007
  httpStatus: status
987
1008
  });
988
1009
  }
989
1010
  }
990
1011
  #classify(err, operation, timeoutMs, isTotal, totalTimeout) {
991
- if (err instanceof chunk553Q2KB5_cjs.LokiError) return err;
1012
+ if (err instanceof chunkVGAJJR3M_cjs.LokiError) return err;
992
1013
  if (err instanceof AbortedAttempt) {
993
- if (err.kind === CANCEL) return new chunk553Q2KB5_cjs.CancelledError(`${operation}: cancelled`);
994
- return isTotal ? new chunk553Q2KB5_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`) : new chunk553Q2KB5_cjs.TimeoutError(`${operation}: request timed out after ${timeoutMs} ms`);
1014
+ if (err.kind === CANCEL) return new chunkVGAJJR3M_cjs.CancelledError(`${operation}: cancelled`);
1015
+ return isTotal ? new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`) : new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: request timed out after ${timeoutMs} ms`);
995
1016
  }
996
1017
  const cause = redactError(err, this.#knownSecrets());
997
1018
  const code = errorCode(err);
998
1019
  if (code === "UND_ERR_CONNECT_TIMEOUT") {
999
- return new chunk553Q2KB5_cjs.TimeoutError(
1020
+ return new chunkVGAJJR3M_cjs.TimeoutError(
1000
1021
  `${operation}: connect timeout after ${this.#config.connectTimeoutMs} ms`,
1001
1022
  { cause }
1002
1023
  );
1003
1024
  }
1004
1025
  if (code !== void 0 && TLS_CODE.test(code)) {
1005
- return new chunk553Q2KB5_cjs.UnavailableError(`${operation}: TLS error (${code})`, { cause, retryable: false });
1026
+ return new chunkVGAJJR3M_cjs.UnavailableError(`${operation}: TLS error (${code})`, { cause, retryable: false });
1006
1027
  }
1007
- return new chunk553Q2KB5_cjs.UnavailableError(
1028
+ return new chunkVGAJJR3M_cjs.UnavailableError(
1008
1029
  `${operation}: network error${code === void 0 ? "" : ` (${code})`}`,
1009
1030
  { cause }
1010
1031
  );
@@ -1016,9 +1037,9 @@ var HttpTransport = class {
1016
1037
  try {
1017
1038
  mapped = classify(response);
1018
1039
  } catch (err) {
1019
- mapped = err instanceof chunk553Q2KB5_cjs.LokiError ? err : void 0;
1040
+ mapped = err instanceof chunkVGAJJR3M_cjs.LokiError ? err : void 0;
1020
1041
  }
1021
- if (mapped instanceof chunk553Q2KB5_cjs.LokiError) return mapped;
1042
+ if (mapped instanceof chunkVGAJJR3M_cjs.LokiError) return mapped;
1022
1043
  }
1023
1044
  return void 0;
1024
1045
  }
@@ -1253,7 +1274,7 @@ var LokiConfig = class _LokiConfig {
1253
1274
  }
1254
1275
  if (this.bearerToken?.reveal().trim() === "") problems.push("bearerToken must not be blank");
1255
1276
  if (problems.length > 0) {
1256
- throw new chunk553Q2KB5_cjs.ConfigError(`invalid configuration: ${problems.join("; ")}`);
1277
+ throw new chunkVGAJJR3M_cjs.ConfigError(`invalid configuration: ${problems.join("; ")}`);
1257
1278
  }
1258
1279
  }
1259
1280
  /** The `Authorization` header value, when credentials are configured. */
@@ -1384,14 +1405,14 @@ function resolveBatchOptions(options = {}) {
1384
1405
  for (const key of POSITIVE) {
1385
1406
  const v = resolved[key];
1386
1407
  if (!Number.isFinite(v) || v <= 0)
1387
- throw new chunk553Q2KB5_cjs.ConfigError(`logging.batch: ${key} must be a positive number`);
1408
+ throw new chunkVGAJJR3M_cjs.ConfigError(`logging.batch: ${key} must be a positive number`);
1388
1409
  }
1389
1410
  for (const key of NON_NEGATIVE) {
1390
1411
  const v = resolved[key];
1391
- if (!Number.isFinite(v) || v < 0) throw new chunk553Q2KB5_cjs.ConfigError(`logging.batch: ${key} must be >= 0`);
1412
+ if (!Number.isFinite(v) || v < 0) throw new chunkVGAJJR3M_cjs.ConfigError(`logging.batch: ${key} must be >= 0`);
1392
1413
  }
1393
1414
  if (!["drop_newest", "drop_oldest", "block"].includes(resolved.dropPolicy)) {
1394
- throw new chunk553Q2KB5_cjs.ConfigError("logging.batch: dropPolicy must be drop_newest, drop_oldest or block");
1415
+ throw new chunkVGAJJR3M_cjs.ConfigError("logging.batch: dropPolicy must be drop_newest, drop_oldest or block");
1395
1416
  }
1396
1417
  return resolved;
1397
1418
  }
@@ -1450,7 +1471,7 @@ var BatchProcessor = class {
1450
1471
  this.#forceUntil = Math.max(this.#forceUntil, this.#enqueued + 1);
1451
1472
  }
1452
1473
  }
1453
- const bytes = chunk553Q2KB5_cjs.logRecordByteSize(record);
1474
+ const bytes = chunkVGAJJR3M_cjs.logRecordByteSize(record);
1454
1475
  this.#queue.push({ record, bytes });
1455
1476
  this.#queuedBytes += bytes;
1456
1477
  this.#enqueued += 1;
@@ -1616,7 +1637,7 @@ var BatchProcessor = class {
1616
1637
  let timer;
1617
1638
  const timeout = new Promise((_, reject) => {
1618
1639
  timer = setTimeout(() => {
1619
- const error = new chunk553Q2KB5_cjs.TimeoutError(`logging.export: timed out after ${timeoutMs} ms`);
1640
+ const error = new chunkVGAJJR3M_cjs.TimeoutError(`logging.export: timed out after ${timeoutMs} ms`);
1620
1641
  controller.abort(error);
1621
1642
  reject(error);
1622
1643
  }, timeoutMs);
@@ -1646,7 +1667,7 @@ var BatchProcessor = class {
1646
1667
  let timer;
1647
1668
  const timeout = new Promise((_, reject) => {
1648
1669
  timer = setTimeout(() => {
1649
- reject(new chunk553Q2KB5_cjs.TimeoutError(`${operation}: timed out after ${timeoutMs} ms`));
1670
+ reject(new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: timed out after ${timeoutMs} ms`));
1650
1671
  }, timeoutMs);
1651
1672
  timer.unref();
1652
1673
  });
@@ -1772,7 +1793,7 @@ var BatchingLogClient = class {
1772
1793
  #closing = null;
1773
1794
  constructor(exporter, options = {}) {
1774
1795
  this.#processor = new BatchProcessor(exporter, options.batch);
1775
- this.#resource = chunk553Q2KB5_cjs.toAttributes(options.resource ?? {});
1796
+ this.#resource = chunkVGAJJR3M_cjs.toAttributes(options.resource ?? {});
1776
1797
  const redaction = options.redaction ?? {};
1777
1798
  this.#redaction = redaction === false ? null : redaction instanceof RedactionProcessor ? redaction : new RedactionProcessor(redaction);
1778
1799
  this.#minSeverity = options.minSeverity ?? 9 /* Info */;
@@ -1818,8 +1839,8 @@ var BatchingLogClient = class {
1818
1839
  if (isLogRecord(input)) {
1819
1840
  record = {
1820
1841
  ...input,
1821
- attributes: chunk553Q2KB5_cjs.toAttributes(input.attributes),
1822
- resource: { ...this.#resource, ...chunk553Q2KB5_cjs.toAttributes(input.resource) }
1842
+ attributes: chunkVGAJJR3M_cjs.toAttributes(input.attributes),
1843
+ resource: { ...this.#resource, ...chunkVGAJJR3M_cjs.toAttributes(input.resource) }
1823
1844
  };
1824
1845
  record.observedTimestamp ??= now;
1825
1846
  } else {
@@ -1828,17 +1849,17 @@ var BatchingLogClient = class {
1828
1849
  timestamp: input.timestamp ?? now,
1829
1850
  observedTimestamp: now,
1830
1851
  severity,
1831
- severityText: chunk553Q2KB5_cjs.severityText(severity),
1852
+ severityText: chunkVGAJJR3M_cjs.severityText(severity),
1832
1853
  body: input.message,
1833
- attributes: chunk553Q2KB5_cjs.toAttributes(input.attributes ?? {}),
1854
+ attributes: chunkVGAJJR3M_cjs.toAttributes(input.attributes ?? {}),
1834
1855
  resource: { ...this.#resource }
1835
1856
  };
1836
1857
  if (input.traceId !== void 0) record.traceId = input.traceId;
1837
1858
  if (input.spanId !== void 0) record.spanId = input.spanId;
1838
1859
  if (input.traceFlags !== void 0) record.traceFlags = input.traceFlags;
1839
1860
  }
1840
- const traceId = chunk553Q2KB5_cjs.normalizeHexId(record.traceId, 32);
1841
- const spanId = traceId === void 0 ? void 0 : chunk553Q2KB5_cjs.normalizeHexId(record.spanId, 16);
1861
+ const traceId = chunkVGAJJR3M_cjs.normalizeHexId(record.traceId, 32);
1862
+ const spanId = traceId === void 0 ? void 0 : chunkVGAJJR3M_cjs.normalizeHexId(record.spanId, 16);
1842
1863
  delete record.traceId;
1843
1864
  delete record.spanId;
1844
1865
  if (traceId === void 0) delete record.traceFlags;
@@ -1856,7 +1877,7 @@ function pinoLevelToSeverity(level) {
1856
1877
  if (level < 60) return 17 /* Error */;
1857
1878
  return 21 /* Fatal */;
1858
1879
  }
1859
- return typeof level === "string" ? chunk553Q2KB5_cjs.parseSeverity(level) ?? 9 /* Info */ : 9 /* Info */;
1880
+ return typeof level === "string" ? chunkVGAJJR3M_cjs.parseSeverity(level) ?? 9 /* Info */ : 9 /* Info */;
1860
1881
  }
1861
1882
  function pinoLineToRecord(line, opts = {}) {
1862
1883
  const consumed = /* @__PURE__ */ new Set();
@@ -1886,9 +1907,9 @@ function pinoLineToRecord(line, opts = {}) {
1886
1907
  const record = {
1887
1908
  timestamp: Number.isNaN(timestamp.getTime()) ? /* @__PURE__ */ new Date() : timestamp,
1888
1909
  severity,
1889
- severityText: typeof level === "string" ? level.toUpperCase() : chunk553Q2KB5_cjs.severityText(severity),
1910
+ severityText: typeof level === "string" ? level.toUpperCase() : chunkVGAJJR3M_cjs.severityText(severity),
1890
1911
  body: typeof message === "string" ? message : message === void 0 ? "" : JSON.stringify(message),
1891
- attributes: { ...opts.attributes, ...chunk553Q2KB5_cjs.toAttributes(rest) },
1912
+ attributes: { ...opts.attributes, ...chunkVGAJJR3M_cjs.toAttributes(rest) },
1892
1913
  resource
1893
1914
  };
1894
1915
  if (typeof traceId === "string") record.traceId = traceId;
@@ -1956,7 +1977,7 @@ var WINSTON_LEVELS = {
1956
1977
  };
1957
1978
  function winstonLevelToSeverity(level) {
1958
1979
  const lower = level.toLowerCase();
1959
- return WINSTON_LEVELS[lower] ?? chunk553Q2KB5_cjs.parseSeverity(lower) ?? 9 /* Info */;
1980
+ return WINSTON_LEVELS[lower] ?? chunkVGAJJR3M_cjs.parseSeverity(lower) ?? 9 /* Info */;
1960
1981
  }
1961
1982
  var WinstonTransport = class extends stream.Writable {
1962
1983
  #client;
@@ -1985,7 +2006,7 @@ var WinstonTransport = class extends stream.Writable {
1985
2006
  severity,
1986
2007
  severityText: rawLevel.toUpperCase(),
1987
2008
  body: typeof message === "string" ? message : message === void 0 ? "" : JSON.stringify(message),
1988
- attributes: { ...this.#attributes, ...chunk553Q2KB5_cjs.toAttributes(rest) },
2009
+ attributes: { ...this.#attributes, ...chunkVGAJJR3M_cjs.toAttributes(rest) },
1989
2010
  resource: {}
1990
2011
  };
1991
2012
  }
@@ -2026,7 +2047,7 @@ var NS_PER_MS = 1000000n;
2026
2047
  var DIGITS = /^\d+$/;
2027
2048
  function dateToNanos(date) {
2028
2049
  const ms = date.getTime();
2029
- if (!Number.isFinite(ms)) throw new chunk553Q2KB5_cjs.ValidationError("invalid date");
2050
+ if (!Number.isFinite(ms)) throw new chunkVGAJJR3M_cjs.ValidationError("invalid date");
2030
2051
  return (BigInt(ms) * NS_PER_MS).toString();
2031
2052
  }
2032
2053
  function nanosToDate(ns) {
@@ -2035,18 +2056,18 @@ function nanosToDate(ns) {
2035
2056
  }
2036
2057
  function toNanos(value, field = "time") {
2037
2058
  if (value instanceof Date) {
2038
- if (Number.isNaN(value.getTime())) throw new chunk553Q2KB5_cjs.ValidationError(`${field}: invalid date`);
2059
+ if (Number.isNaN(value.getTime())) throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: invalid date`);
2039
2060
  return dateToNanos(value);
2040
2061
  }
2041
2062
  if (typeof value === "bigint") {
2042
- if (value < 0n) throw new chunk553Q2KB5_cjs.ValidationError(`${field}: must not be negative`);
2063
+ if (value < 0n) throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: must not be negative`);
2043
2064
  return value.toString();
2044
2065
  }
2045
2066
  const text = value.trim();
2046
2067
  if (DIGITS.test(text)) return text;
2047
2068
  const parsed = Date.parse(text);
2048
2069
  if (text === "" || Number.isNaN(parsed)) {
2049
- throw new chunk553Q2KB5_cjs.ValidationError(`${field}: expected a Date, bigint nanoseconds or RFC 3339 text`);
2070
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: expected a Date, bigint nanoseconds or RFC 3339 text`);
2050
2071
  }
2051
2072
  return dateToNanos(new Date(parsed));
2052
2073
  }
@@ -2058,7 +2079,7 @@ function secondsToDate(seconds) {
2058
2079
  }
2059
2080
  function msToDuration(ms, field) {
2060
2081
  if (!Number.isFinite(ms) || ms <= 0) {
2061
- throw new chunk553Q2KB5_cjs.ValidationError(`${field}: must be a positive number of milliseconds`);
2082
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: must be a positive number of milliseconds`);
2062
2083
  }
2063
2084
  return `${Math.round(ms)}ms`;
2064
2085
  }
@@ -2089,19 +2110,19 @@ function isValidLabelName(name) {
2089
2110
  }
2090
2111
  function validateLabelName(name, what = "label name") {
2091
2112
  if (!LABEL_NAME_PATTERN.test(name)) {
2092
- throw new chunk553Q2KB5_cjs.ValidationError(
2113
+ throw new chunkVGAJJR3M_cjs.ValidationError(
2093
2114
  `invalid ${what} ${JSON.stringify(name)}: must match [a-zA-Z_][a-zA-Z0-9_]*`
2094
2115
  );
2095
2116
  }
2096
2117
  if (name.startsWith("__")) {
2097
- throw new chunk553Q2KB5_cjs.ValidationError(`invalid ${what} ${JSON.stringify(name)}: "__" names are reserved`);
2118
+ throw new chunkVGAJJR3M_cjs.ValidationError(`invalid ${what} ${JSON.stringify(name)}: "__" names are reserved`);
2098
2119
  }
2099
2120
  }
2100
2121
  function validateLabels(labels) {
2101
2122
  for (const [name, value] of Object.entries(labels)) {
2102
2123
  validateLabelName(name);
2103
2124
  if (typeof value !== "string" || value === "") {
2104
- throw new chunk553Q2KB5_cjs.ValidationError(`label ${name}: value must be a non-empty string`);
2125
+ throw new chunkVGAJJR3M_cjs.ValidationError(`label ${name}: value must be a non-empty string`);
2105
2126
  }
2106
2127
  }
2107
2128
  }
@@ -2170,7 +2191,7 @@ function recordsToStreams(records, options = {}) {
2170
2191
  };
2171
2192
  for (const [k, v] of Object.entries(record.resource)) place(k, v);
2172
2193
  for (const [k, v] of Object.entries(record.attributes)) place(k, v);
2173
- const text = record.severityText !== "" ? record.severityText : chunk553Q2KB5_cjs.severityText(record.severity);
2194
+ const text = record.severityText !== "" ? record.severityText : chunkVGAJJR3M_cjs.severityText(record.severity);
2174
2195
  if (allowed.has("level") && labels.level === void 0) labels.level = text.toLowerCase();
2175
2196
  metadata.severity_text = text;
2176
2197
  metadata.severity_number = String(record.severity);
@@ -2202,7 +2223,7 @@ async function exportWith(records, send) {
2202
2223
  await send();
2203
2224
  return { accepted: records.length, rejected: 0 };
2204
2225
  } catch (error) {
2205
- if (error instanceof chunk553Q2KB5_cjs.LokiError) return { accepted: 0, rejected: records.length, error };
2226
+ if (error instanceof chunkVGAJJR3M_cjs.LokiError) return { accepted: 0, rejected: records.length, error };
2206
2227
  throw error;
2207
2228
  }
2208
2229
  }
@@ -2411,13 +2432,13 @@ function quoteLogQL(value) {
2411
2432
  }
2412
2433
  function checkName(name, what) {
2413
2434
  if (!LABEL_NAME_PATTERN.test(name)) {
2414
- throw new chunk553Q2KB5_cjs.ValidationError(
2435
+ throw new chunkVGAJJR3M_cjs.ValidationError(
2415
2436
  `LogQL: invalid ${what} ${JSON.stringify(name)}: must match [a-zA-Z_][a-zA-Z0-9_]*`
2416
2437
  );
2417
2438
  }
2418
2439
  }
2419
2440
  function formatNumber(value) {
2420
- if (!Number.isFinite(value)) throw new chunk553Q2KB5_cjs.ValidationError("LogQL: numbers must be finite");
2441
+ if (!Number.isFinite(value)) throw new chunkVGAJJR3M_cjs.ValidationError("LogQL: numbers must be finite");
2421
2442
  return value.toLocaleString("en-US", { useGrouping: false, maximumFractionDigits: 20 });
2422
2443
  }
2423
2444
  function matchesEmpty(m) {
@@ -2457,7 +2478,7 @@ var LogQL = class _LogQL {
2457
2478
  /** Adds a stream-selector matcher (`=`, `!=`, `=~`, `!~`). */
2458
2479
  label(name, op, value) {
2459
2480
  checkName(name, "label name");
2460
- if (!MATCH_OPS.has(op)) throw new chunk553Q2KB5_cjs.ValidationError(`LogQL: invalid matcher operator ${op}`);
2481
+ if (!MATCH_OPS.has(op)) throw new chunkVGAJJR3M_cjs.ValidationError(`LogQL: invalid matcher operator ${op}`);
2461
2482
  return new _LogQL([...this.#matchers, { name, op, value }], this.#stages);
2462
2483
  }
2463
2484
  #stage(text) {
@@ -2511,12 +2532,12 @@ var LogQL = class _LogQL {
2511
2532
  checkName(field, "field name");
2512
2533
  if (typeof value === "number") {
2513
2534
  if (!NUMERIC_OPS.has(op)) {
2514
- throw new chunk553Q2KB5_cjs.ValidationError(`LogQL: operator ${op} cannot compare numbers`);
2535
+ throw new chunkVGAJJR3M_cjs.ValidationError(`LogQL: operator ${op} cannot compare numbers`);
2515
2536
  }
2516
2537
  return this.#stage(`| ${field} ${op} ${formatNumber(value)}`);
2517
2538
  }
2518
2539
  if (!MATCH_OPS.has(op)) {
2519
- throw new chunk553Q2KB5_cjs.ValidationError(`LogQL: operator ${op} cannot compare strings`);
2540
+ throw new chunkVGAJJR3M_cjs.ValidationError(`LogQL: operator ${op} cannot compare strings`);
2520
2541
  }
2521
2542
  return this.#stage(`| ${field} ${op} ${quoteLogQL(value)}`);
2522
2543
  }
@@ -2530,10 +2551,10 @@ var LogQL = class _LogQL {
2530
2551
  */
2531
2552
  toString() {
2532
2553
  if (this.#matchers.length === 0) {
2533
- throw new chunk553Q2KB5_cjs.ValidationError("LogQL: a stream selector needs at least one matcher");
2554
+ throw new chunkVGAJJR3M_cjs.ValidationError("LogQL: a stream selector needs at least one matcher");
2534
2555
  }
2535
2556
  if (this.#matchers.every(matchesEmpty)) {
2536
- throw new chunk553Q2KB5_cjs.ValidationError(
2557
+ throw new chunkVGAJJR3M_cjs.ValidationError(
2537
2558
  "LogQL: the selector needs at least one matcher that does not match the empty value"
2538
2559
  );
2539
2560
  }
@@ -2569,7 +2590,7 @@ function encodeCursor(ns, skip) {
2569
2590
  function decodeCursor(cursor) {
2570
2591
  const text = Buffer.from(cursor, "base64url").toString("utf8");
2571
2592
  const match = /^(\d+):(\d+)$/.exec(text);
2572
- if (match === null) throw new chunk553Q2KB5_cjs.ValidationError("logging.search: invalid cursor");
2593
+ if (match === null) throw new chunkVGAJJR3M_cjs.ValidationError("logging.search: invalid cursor");
2573
2594
  return { ns: match[1], skip: Number(match[2]) };
2574
2595
  }
2575
2596
  var CONSUMED_METADATA = /* @__PURE__ */ new Set([
@@ -2581,10 +2602,10 @@ var CONSUMED_METADATA = /* @__PURE__ */ new Set([
2581
2602
  "observed_timestamp"
2582
2603
  ]);
2583
2604
  function severityFrom(md, labels) {
2584
- const fromNumber = md.severity_number === void 0 ? null : chunk553Q2KB5_cjs.parseSeverity(md.severity_number);
2585
- const fromText = md.severity_text === void 0 ? null : chunk553Q2KB5_cjs.parseSeverity(md.severity_text);
2586
- const severity = fromNumber ?? fromText ?? (md.detected_level === void 0 ? null : chunk553Q2KB5_cjs.parseSeverity(md.detected_level)) ?? (labels.level === void 0 ? null : chunk553Q2KB5_cjs.parseSeverity(labels.level)) ?? 9 /* Info */;
2587
- return { severity, text: md.severity_text ?? chunk553Q2KB5_cjs.severityText(severity) };
2605
+ const fromNumber = md.severity_number === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(md.severity_number);
2606
+ const fromText = md.severity_text === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(md.severity_text);
2607
+ const severity = fromNumber ?? fromText ?? (md.detected_level === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(md.detected_level)) ?? (labels.level === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(labels.level)) ?? 9 /* Info */;
2608
+ return { severity, text: md.severity_text ?? chunkVGAJJR3M_cjs.severityText(severity) };
2588
2609
  }
2589
2610
  function entryToLogRecord(labels, entry) {
2590
2611
  const md = entry.structuredMetadata;
@@ -2637,7 +2658,7 @@ function mergeStreams(streams, order) {
2637
2658
  });
2638
2659
  return flat;
2639
2660
  }
2640
- var LokiLogQueryClient = class extends chunk553Q2KB5_cjs.BaseLogQueryClient {
2661
+ var LokiLogQueryClient = class extends chunkVGAJJR3M_cjs.BaseLogQueryClient {
2641
2662
  #source;
2642
2663
  constructor(source) {
2643
2664
  super();
@@ -2652,7 +2673,7 @@ var LokiLogQueryClient = class extends chunk553Q2KB5_cjs.BaseLogQueryClient {
2652
2673
  async search(query, opts = {}) {
2653
2674
  const limit = opts.limit ?? 100;
2654
2675
  if (!Number.isInteger(limit) || limit < 1 || limit > MAX_QUERY_LIMIT) {
2655
- throw new chunk553Q2KB5_cjs.ValidationError(`logging.search: limit must be an integer 1..${MAX_QUERY_LIMIT}`);
2676
+ throw new chunkVGAJJR3M_cjs.ValidationError(`logging.search: limit must be an integer 1..${MAX_QUERY_LIMIT}`);
2656
2677
  }
2657
2678
  const order = opts.order ?? "desc";
2658
2679
  let start = opts.start;
@@ -2763,7 +2784,7 @@ function isObject(v) {
2763
2784
  return typeof v === "object" && v !== null && !Array.isArray(v);
2764
2785
  }
2765
2786
  function bad(what) {
2766
- throw new chunk553Q2KB5_cjs.UnavailableError(`unexpected response from Loki: ${what}`, { retryable: false });
2787
+ throw new chunkVGAJJR3M_cjs.UnavailableError(`unexpected response from Loki: ${what}`, { retryable: false });
2767
2788
  }
2768
2789
  function stringMap(v) {
2769
2790
  const out = {};
@@ -2918,7 +2939,7 @@ function openTail(params, onFrame, callbacks = {}) {
2918
2939
  const op = "tail";
2919
2940
  return new Promise((resolve, reject) => {
2920
2941
  if (params.signal?.aborted === true) {
2921
- reject(new chunk553Q2KB5_cjs.CancelledError(`${op}: cancelled`));
2942
+ reject(new chunkVGAJJR3M_cjs.CancelledError(`${op}: cancelled`));
2922
2943
  return;
2923
2944
  }
2924
2945
  let settled = false;
@@ -2959,7 +2980,7 @@ function openTail(params, onFrame, callbacks = {}) {
2959
2980
  };
2960
2981
  function onAbort() {
2961
2982
  if (!settled) {
2962
- fail(new chunk553Q2KB5_cjs.CancelledError(`${op}: cancelled`));
2983
+ fail(new chunkVGAJJR3M_cjs.CancelledError(`${op}: cancelled`));
2963
2984
  ws.terminate();
2964
2985
  } else {
2965
2986
  handle.stop();
@@ -2973,7 +2994,7 @@ function openTail(params, onFrame, callbacks = {}) {
2973
2994
  res.on("end", () => {
2974
2995
  const status = res.statusCode ?? 0;
2975
2996
  const reason = vendorText(Buffer.concat(chunks).toString("utf8"), params.redact);
2976
- fail(chunk553Q2KB5_cjs.errorForStatus(op, status, reason === void 0 ? {} : { reason }));
2997
+ fail(chunkVGAJJR3M_cjs.errorForStatus(op, status, reason === void 0 ? {} : { reason }));
2977
2998
  socket.destroy();
2978
2999
  req.destroy();
2979
3000
  resolveClosed();
@@ -2993,7 +3014,7 @@ function openTail(params, onFrame, callbacks = {}) {
2993
3014
  );
2994
3015
  } catch (err) {
2995
3016
  report(
2996
- err instanceof chunk553Q2KB5_cjs.UnavailableError ? err : new chunk553Q2KB5_cjs.UnavailableError(`${op}: malformed frame`, { retryable: false })
3017
+ err instanceof chunkVGAJJR3M_cjs.UnavailableError ? err : new chunkVGAJJR3M_cjs.UnavailableError(`${op}: malformed frame`, { retryable: false })
2997
3018
  );
2998
3019
  return;
2999
3020
  }
@@ -3008,20 +3029,20 @@ function openTail(params, onFrame, callbacks = {}) {
3008
3029
  ws.on("error", (err) => {
3009
3030
  if (!settled) {
3010
3031
  fail(
3011
- /timed out/i.test(err.message) ? new chunk553Q2KB5_cjs.TimeoutError(`${op}: connect timeout after ${params.connectTimeoutMs} ms`) : new chunk553Q2KB5_cjs.UnavailableError(`${op}: ${params.redact(err.message)}`)
3032
+ /timed out/i.test(err.message) ? new chunkVGAJJR3M_cjs.TimeoutError(`${op}: connect timeout after ${params.connectTimeoutMs} ms`) : new chunkVGAJJR3M_cjs.UnavailableError(`${op}: ${params.redact(err.message)}`)
3012
3033
  );
3013
3034
  } else if (opened && !stopped) {
3014
- report(new chunk553Q2KB5_cjs.UnavailableError(`${op}: ${params.redact(err.message)}`));
3035
+ report(new chunkVGAJJR3M_cjs.UnavailableError(`${op}: ${params.redact(err.message)}`));
3015
3036
  }
3016
3037
  });
3017
3038
  ws.on("close", (code, reasonBuf) => {
3018
3039
  params.signal?.removeEventListener("abort", onAbort);
3019
3040
  const reason = vendorText(reasonBuf.toString("utf8"), params.redact);
3020
3041
  if (!settled) {
3021
- fail(new chunk553Q2KB5_cjs.UnavailableError(`${op}: connection closed before the upgrade (code ${code})`));
3042
+ fail(new chunkVGAJJR3M_cjs.UnavailableError(`${op}: connection closed before the upgrade (code ${code})`));
3022
3043
  } else if (opened && !stopped && code !== 1e3) {
3023
3044
  report(
3024
- new chunk553Q2KB5_cjs.UnavailableError(
3045
+ new chunkVGAJJR3M_cjs.UnavailableError(
3025
3046
  `${op}: connection closed (code ${code})${reason === void 0 ? "" : `: ${reason}`}`,
3026
3047
  { retryable: code === 1001 || code === 1006 }
3027
3048
  )
@@ -3038,9 +3059,9 @@ var ENCODING_FLAGS_HEADER = "x-loki-response-encoding-flags";
3038
3059
  var TENANT_HEADER = "x-scope-orgid";
3039
3060
  var SHUTTING_DOWN = /ingester is shutting down/i;
3040
3061
  function mapLokiError(err) {
3041
- if (!(err instanceof chunk553Q2KB5_cjs.LokiError) || !SHUTTING_DOWN.test(err.message)) return err;
3062
+ if (!(err instanceof chunkVGAJJR3M_cjs.LokiError) || !SHUTTING_DOWN.test(err.message)) return err;
3042
3063
  const message = err.message.includes("WAL") ? err.message : `${err.message} (the Loki ingester is stopping or its WAL disk is at least 90 % full)`;
3043
- return new chunk553Q2KB5_cjs.UnavailableError(message, {
3064
+ return new chunkVGAJJR3M_cjs.UnavailableError(message, {
3044
3065
  ...err.httpStatus === void 0 ? {} : { httpStatus: err.httpStatus },
3045
3066
  ...err.requestId === void 0 ? {} : { requestId: err.requestId },
3046
3067
  ...err.retryAfterMs === void 0 ? {} : { retryAfterMs: err.retryAfterMs },
@@ -3061,7 +3082,7 @@ function vectorToMatrix(result) {
3061
3082
  };
3062
3083
  }
3063
3084
  function cleanRpcStatus(err) {
3064
- if (!(err instanceof chunk553Q2KB5_cjs.LokiError)) return err;
3085
+ if (!(err instanceof chunkVGAJJR3M_cjs.LokiError)) return err;
3065
3086
  const match = /^(.*?: )([\s\S]*)( \(HTTP \d+\))$/.exec(err.message);
3066
3087
  if (match === null) return err;
3067
3088
  const raw = match[2];
@@ -3072,12 +3093,12 @@ function cleanRpcStatus(err) {
3072
3093
  }
3073
3094
  function checkLimit(limit, op, max = Number.MAX_SAFE_INTEGER) {
3074
3095
  if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1 || limit > max)) {
3075
- throw new chunk553Q2KB5_cjs.ValidationError(`${op}: limit must be an integer 1..${max}`);
3096
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: limit must be an integer 1..${max}`);
3076
3097
  }
3077
3098
  }
3078
3099
  function checkQuery(logql, op) {
3079
3100
  if (typeof logql !== "string" || logql.trim() === "") {
3080
- throw new chunk553Q2KB5_cjs.ValidationError(`${op}: query must not be empty`);
3101
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: query must not be empty`);
3081
3102
  }
3082
3103
  }
3083
3104
  var LokiClient = class _LokiClient {
@@ -3130,7 +3151,7 @@ var LokiClient = class _LokiClient {
3130
3151
  */
3131
3152
  withTenant(id) {
3132
3153
  const problem = tenantIdProblem(id, this.config.multiTenantQueries);
3133
- if (problem !== void 0) throw new chunk553Q2KB5_cjs.ValidationError(`withTenant: ${problem}`);
3154
+ if (problem !== void 0) throw new chunkVGAJJR3M_cjs.ValidationError(`withTenant: ${problem}`);
3134
3155
  return new _LokiClient(this.config.with({ tenantId: id }), {}, { transport: this.#transport });
3135
3156
  }
3136
3157
  #tenantHeaders() {
@@ -3138,7 +3159,7 @@ var LokiClient = class _LokiClient {
3138
3159
  }
3139
3160
  async #request(options) {
3140
3161
  if (this.#closed) {
3141
- throw new chunk553Q2KB5_cjs.CancelledError(`${options.operation ?? options.path}: client is closed`);
3162
+ throw new chunkVGAJJR3M_cjs.CancelledError(`${options.operation ?? options.path}: client is closed`);
3142
3163
  }
3143
3164
  try {
3144
3165
  return await this.#transport.request({
@@ -3180,7 +3201,7 @@ var LokiClient = class _LokiClient {
3180
3201
  });
3181
3202
  return healthStatus("ok", {});
3182
3203
  } catch (err) {
3183
- if (err instanceof chunk553Q2KB5_cjs.LokiError && err.httpStatus === 503) {
3204
+ if (err instanceof chunkVGAJJR3M_cjs.LokiError && err.httpStatus === 503) {
3184
3205
  const text = /^health: (.*) \(HTTP 503\)$/.exec(err.message)?.[1] ?? "unhealthy";
3185
3206
  return healthStatus(text, { httpStatus: 503 }, false);
3186
3207
  }
@@ -3219,7 +3240,7 @@ var LokiClient = class _LokiClient {
3219
3240
  async serverVersion(options = {}) {
3220
3241
  const info = await this.buildInfo(options);
3221
3242
  if (info.version === "") {
3222
- throw new chunk553Q2KB5_cjs.UnsupportedError("serverVersion: the service does not report a version");
3243
+ throw new chunkVGAJJR3M_cjs.UnsupportedError("serverVersion: the service does not report a version");
3223
3244
  }
3224
3245
  return info.version;
3225
3246
  }
@@ -3245,13 +3266,13 @@ var LokiClient = class _LokiClient {
3245
3266
  return {
3246
3267
  labels: s.labels,
3247
3268
  entries: s.entries.map((e) => {
3248
- if (typeof e.line !== "string") throw new chunk553Q2KB5_cjs.ValidationError(`${op}: line must be a string`);
3269
+ if (typeof e.line !== "string") throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: line must be a string`);
3249
3270
  for (const [k, v] of Object.entries(e.structuredMetadata ?? {})) {
3250
3271
  if (k === "") {
3251
- throw new chunk553Q2KB5_cjs.ValidationError(`${op}: structured metadata name must not be empty`);
3272
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: structured metadata name must not be empty`);
3252
3273
  }
3253
3274
  if (typeof v !== "string") {
3254
- throw new chunk553Q2KB5_cjs.ValidationError(`${op}: structured metadata ${k} must be a string`);
3275
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: structured metadata ${k} must be a string`);
3255
3276
  }
3256
3277
  }
3257
3278
  return { ...e, timestamp: toNanos(e.timestamp ?? now, "timestamp") };
@@ -3260,7 +3281,7 @@ var LokiClient = class _LokiClient {
3260
3281
  });
3261
3282
  const format = options.format ?? "json";
3262
3283
  if (format !== "json" && format !== "protobuf") {
3263
- throw new chunk553Q2KB5_cjs.ValidationError(`${op}: unknown format ${format}`);
3284
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: unknown format ${format}`);
3264
3285
  }
3265
3286
  let body;
3266
3287
  const headers = {};
@@ -3293,7 +3314,7 @@ var LokiClient = class _LokiClient {
3293
3314
  ...options.signal === void 0 ? {} : { signal: options.signal }
3294
3315
  });
3295
3316
  if (res.status === 260) {
3296
- throw new chunk553Q2KB5_cjs.UnavailableError(
3317
+ throw new chunkVGAJJR3M_cjs.UnavailableError(
3297
3318
  `${op}: ingestion is blocked by the Loki administrator (HTTP 260)`,
3298
3319
  {
3299
3320
  httpStatus: 260,
@@ -3339,7 +3360,7 @@ var LokiClient = class _LokiClient {
3339
3360
  async query(logql, options = {}) {
3340
3361
  checkQuery(logql, "query");
3341
3362
  if (logql.trim().startsWith("{")) {
3342
- throw new chunk553Q2KB5_cjs.ValidationError(
3363
+ throw new chunkVGAJJR3M_cjs.ValidationError(
3343
3364
  "query: log queries cannot run as instant queries; use queryRange or search"
3344
3365
  );
3345
3366
  }
@@ -3422,7 +3443,7 @@ var LokiClient = class _LokiClient {
3422
3443
  async series(matchers, options = {}) {
3423
3444
  const list = typeof matchers === "string" ? [matchers] : [...matchers];
3424
3445
  if (list.length === 0 || list.some((m) => m.trim() === "")) {
3425
- throw new chunk553Q2KB5_cjs.ValidationError("series: at least one non-empty matcher is required");
3446
+ throw new chunkVGAJJR3M_cjs.ValidationError("series: at least one non-empty matcher is required");
3426
3447
  }
3427
3448
  return decodeSeries(
3428
3449
  await this.#getJson(
@@ -3515,7 +3536,7 @@ var LokiClient = class _LokiClient {
3515
3536
  );
3516
3537
  const data = body?.data;
3517
3538
  if (typeof data !== "string") {
3518
- throw new chunk553Q2KB5_cjs.UnavailableError("formatQuery: unexpected response", { retryable: false });
3539
+ throw new chunkVGAJJR3M_cjs.UnavailableError("formatQuery: unexpected response", { retryable: false });
3519
3540
  }
3520
3541
  return data;
3521
3542
  }
@@ -3530,18 +3551,18 @@ var LokiClient = class _LokiClient {
3530
3551
  const op = "tail";
3531
3552
  checkQuery(logql, op);
3532
3553
  if (!logql.trim().startsWith("{")) {
3533
- throw new chunk553Q2KB5_cjs.ValidationError(`${op}: only log queries (starting with a selector) can be tailed`);
3554
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: only log queries (starting with a selector) can be tailed`);
3534
3555
  }
3535
3556
  checkLimit(options.limit, op);
3536
3557
  let delayFor;
3537
3558
  if (options.delayForMs !== void 0) {
3538
3559
  delayFor = Math.round(options.delayForMs / 1e3);
3539
3560
  if (!Number.isFinite(delayFor) || delayFor < 0 || delayFor > 5) {
3540
- throw new chunk553Q2KB5_cjs.ValidationError(`${op}: delayForMs must be between 0 and 5000`);
3561
+ throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: delayForMs must be between 0 and 5000`);
3541
3562
  }
3542
3563
  }
3543
3564
  if (this.#closed || this.#transport.closed) {
3544
- throw new chunk553Q2KB5_cjs.CancelledError(`${op}: client is closed`);
3565
+ throw new chunkVGAJJR3M_cjs.CancelledError(`${op}: client is closed`);
3545
3566
  }
3546
3567
  const url = this.#transport.buildUrl("/loki/api/v1/tail", {
3547
3568
  query: logql,
@@ -3623,147 +3644,147 @@ var LokiClient = class _LokiClient {
3623
3644
 
3624
3645
  Object.defineProperty(exports, "AuthenticationError", {
3625
3646
  enumerable: true,
3626
- get: function () { return chunk553Q2KB5_cjs.AuthenticationError; }
3647
+ get: function () { return chunkVGAJJR3M_cjs.AuthenticationError; }
3627
3648
  });
3628
3649
  Object.defineProperty(exports, "BaseLogQueryClient", {
3629
3650
  enumerable: true,
3630
- get: function () { return chunk553Q2KB5_cjs.BaseLogQueryClient; }
3651
+ get: function () { return chunkVGAJJR3M_cjs.BaseLogQueryClient; }
3631
3652
  });
3632
3653
  Object.defineProperty(exports, "CancelledError", {
3633
3654
  enumerable: true,
3634
- get: function () { return chunk553Q2KB5_cjs.CancelledError; }
3655
+ get: function () { return chunkVGAJJR3M_cjs.CancelledError; }
3635
3656
  });
3636
3657
  Object.defineProperty(exports, "ConfigError", {
3637
3658
  enumerable: true,
3638
- get: function () { return chunk553Q2KB5_cjs.ConfigError; }
3659
+ get: function () { return chunkVGAJJR3M_cjs.ConfigError; }
3639
3660
  });
3640
3661
  Object.defineProperty(exports, "ConflictError", {
3641
3662
  enumerable: true,
3642
- get: function () { return chunk553Q2KB5_cjs.ConflictError; }
3663
+ get: function () { return chunkVGAJJR3M_cjs.ConflictError; }
3643
3664
  });
3644
3665
  Object.defineProperty(exports, "ErrorCode", {
3645
3666
  enumerable: true,
3646
- get: function () { return chunk553Q2KB5_cjs.ErrorCode; }
3667
+ get: function () { return chunkVGAJJR3M_cjs.ErrorCode; }
3647
3668
  });
3648
3669
  Object.defineProperty(exports, "LokiError", {
3649
3670
  enumerable: true,
3650
- get: function () { return chunk553Q2KB5_cjs.LokiError; }
3671
+ get: function () { return chunkVGAJJR3M_cjs.LokiError; }
3651
3672
  });
3652
3673
  Object.defineProperty(exports, "NotFoundError", {
3653
3674
  enumerable: true,
3654
- get: function () { return chunk553Q2KB5_cjs.NotFoundError; }
3675
+ get: function () { return chunkVGAJJR3M_cjs.NotFoundError; }
3655
3676
  });
3656
3677
  Object.defineProperty(exports, "PermissionDeniedError", {
3657
3678
  enumerable: true,
3658
- get: function () { return chunk553Q2KB5_cjs.PermissionDeniedError; }
3679
+ get: function () { return chunkVGAJJR3M_cjs.PermissionDeniedError; }
3659
3680
  });
3660
3681
  Object.defineProperty(exports, "RateLimitError", {
3661
3682
  enumerable: true,
3662
- get: function () { return chunk553Q2KB5_cjs.RateLimitError; }
3683
+ get: function () { return chunkVGAJJR3M_cjs.RateLimitError; }
3663
3684
  });
3664
3685
  Object.defineProperty(exports, "Severity", {
3665
3686
  enumerable: true,
3666
- get: function () { return chunk553Q2KB5_cjs.Severity; }
3687
+ get: function () { return chunkVGAJJR3M_cjs.Severity; }
3667
3688
  });
3668
3689
  Object.defineProperty(exports, "TimeoutError", {
3669
3690
  enumerable: true,
3670
- get: function () { return chunk553Q2KB5_cjs.TimeoutError; }
3691
+ get: function () { return chunkVGAJJR3M_cjs.TimeoutError; }
3671
3692
  });
3672
3693
  Object.defineProperty(exports, "UnavailableError", {
3673
3694
  enumerable: true,
3674
- get: function () { return chunk553Q2KB5_cjs.UnavailableError; }
3695
+ get: function () { return chunkVGAJJR3M_cjs.UnavailableError; }
3675
3696
  });
3676
3697
  Object.defineProperty(exports, "UnsupportedError", {
3677
3698
  enumerable: true,
3678
- get: function () { return chunk553Q2KB5_cjs.UnsupportedError; }
3699
+ get: function () { return chunkVGAJJR3M_cjs.UnsupportedError; }
3679
3700
  });
3680
3701
  Object.defineProperty(exports, "UnsupportedLogQueryClient", {
3681
3702
  enumerable: true,
3682
- get: function () { return chunk553Q2KB5_cjs.UnsupportedLogQueryClient; }
3703
+ get: function () { return chunkVGAJJR3M_cjs.UnsupportedLogQueryClient; }
3683
3704
  });
3684
3705
  Object.defineProperty(exports, "ValidationError", {
3685
3706
  enumerable: true,
3686
- get: function () { return chunk553Q2KB5_cjs.ValidationError; }
3707
+ get: function () { return chunkVGAJJR3M_cjs.ValidationError; }
3687
3708
  });
3688
3709
  Object.defineProperty(exports, "canonicalSeverity", {
3689
3710
  enumerable: true,
3690
- get: function () { return chunk553Q2KB5_cjs.canonicalSeverity; }
3711
+ get: function () { return chunkVGAJJR3M_cjs.canonicalSeverity; }
3691
3712
  });
3692
3713
  Object.defineProperty(exports, "codeForStatus", {
3693
3714
  enumerable: true,
3694
- get: function () { return chunk553Q2KB5_cjs.codeForStatus; }
3715
+ get: function () { return chunkVGAJJR3M_cjs.codeForStatus; }
3695
3716
  });
3696
3717
  Object.defineProperty(exports, "errorForCode", {
3697
3718
  enumerable: true,
3698
- get: function () { return chunk553Q2KB5_cjs.errorForCode; }
3719
+ get: function () { return chunkVGAJJR3M_cjs.errorForCode; }
3699
3720
  });
3700
3721
  Object.defineProperty(exports, "errorForStatus", {
3701
3722
  enumerable: true,
3702
- get: function () { return chunk553Q2KB5_cjs.errorForStatus; }
3723
+ get: function () { return chunkVGAJJR3M_cjs.errorForStatus; }
3703
3724
  });
3704
3725
  Object.defineProperty(exports, "isLokiError", {
3705
3726
  enumerable: true,
3706
- get: function () { return chunk553Q2KB5_cjs.isLokiError; }
3727
+ get: function () { return chunkVGAJJR3M_cjs.isLokiError; }
3707
3728
  });
3708
3729
  Object.defineProperty(exports, "logRecordByteSize", {
3709
3730
  enumerable: true,
3710
- get: function () { return chunk553Q2KB5_cjs.logRecordByteSize; }
3731
+ get: function () { return chunkVGAJJR3M_cjs.logRecordByteSize; }
3711
3732
  });
3712
3733
  Object.defineProperty(exports, "logRecordFromJson", {
3713
3734
  enumerable: true,
3714
- get: function () { return chunk553Q2KB5_cjs.logRecordFromJson; }
3735
+ get: function () { return chunkVGAJJR3M_cjs.logRecordFromJson; }
3715
3736
  });
3716
3737
  Object.defineProperty(exports, "logRecordToJson", {
3717
3738
  enumerable: true,
3718
- get: function () { return chunk553Q2KB5_cjs.logRecordToJson; }
3739
+ get: function () { return chunkVGAJJR3M_cjs.logRecordToJson; }
3719
3740
  });
3720
3741
  Object.defineProperty(exports, "parseLogRecord", {
3721
3742
  enumerable: true,
3722
- get: function () { return chunk553Q2KB5_cjs.parseLogRecord; }
3743
+ get: function () { return chunkVGAJJR3M_cjs.parseLogRecord; }
3723
3744
  });
3724
3745
  Object.defineProperty(exports, "parseSeverity", {
3725
3746
  enumerable: true,
3726
- get: function () { return chunk553Q2KB5_cjs.parseSeverity; }
3747
+ get: function () { return chunkVGAJJR3M_cjs.parseSeverity; }
3727
3748
  });
3728
3749
  Object.defineProperty(exports, "pollTail", {
3729
3750
  enumerable: true,
3730
- get: function () { return chunk553Q2KB5_cjs.pollTail; }
3751
+ get: function () { return chunkVGAJJR3M_cjs.pollTail; }
3731
3752
  });
3732
3753
  Object.defineProperty(exports, "pollUntil", {
3733
3754
  enumerable: true,
3734
- get: function () { return chunk553Q2KB5_cjs.pollUntil; }
3755
+ get: function () { return chunkVGAJJR3M_cjs.pollUntil; }
3735
3756
  });
3736
3757
  Object.defineProperty(exports, "reasonForCode", {
3737
3758
  enumerable: true,
3738
- get: function () { return chunk553Q2KB5_cjs.reasonForCode; }
3759
+ get: function () { return chunkVGAJJR3M_cjs.reasonForCode; }
3739
3760
  });
3740
3761
  Object.defineProperty(exports, "serializeLogRecord", {
3741
3762
  enumerable: true,
3742
- get: function () { return chunk553Q2KB5_cjs.serializeLogRecord; }
3763
+ get: function () { return chunkVGAJJR3M_cjs.serializeLogRecord; }
3743
3764
  });
3744
3765
  Object.defineProperty(exports, "severityText", {
3745
3766
  enumerable: true,
3746
- get: function () { return chunk553Q2KB5_cjs.severityText; }
3767
+ get: function () { return chunkVGAJJR3M_cjs.severityText; }
3747
3768
  });
3748
3769
  Object.defineProperty(exports, "sleep", {
3749
3770
  enumerable: true,
3750
- get: function () { return chunk553Q2KB5_cjs.sleep; }
3771
+ get: function () { return chunkVGAJJR3M_cjs.sleep; }
3751
3772
  });
3752
3773
  Object.defineProperty(exports, "throwIfAborted", {
3753
3774
  enumerable: true,
3754
- get: function () { return chunk553Q2KB5_cjs.throwIfAborted; }
3775
+ get: function () { return chunkVGAJJR3M_cjs.throwIfAborted; }
3755
3776
  });
3756
3777
  Object.defineProperty(exports, "toAttrValue", {
3757
3778
  enumerable: true,
3758
- get: function () { return chunk553Q2KB5_cjs.toAttrValue; }
3779
+ get: function () { return chunkVGAJJR3M_cjs.toAttrValue; }
3759
3780
  });
3760
3781
  Object.defineProperty(exports, "toAttributes", {
3761
3782
  enumerable: true,
3762
- get: function () { return chunk553Q2KB5_cjs.toAttributes; }
3783
+ get: function () { return chunkVGAJJR3M_cjs.toAttributes; }
3763
3784
  });
3764
3785
  Object.defineProperty(exports, "waitForLog", {
3765
3786
  enumerable: true,
3766
- get: function () { return chunk553Q2KB5_cjs.waitForLog; }
3787
+ get: function () { return chunkVGAJJR3M_cjs.waitForLog; }
3767
3788
  });
3768
3789
  exports.ALL_STREAMS_SELECTOR = ALL_STREAMS_SELECTOR;
3769
3790
  exports.BatchProcessor = BatchProcessor;