@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.d.cts CHANGED
@@ -449,6 +449,12 @@ declare class HttpTransport {
449
449
  constructor(options: TransportOptions);
450
450
  /** Whether {@link close} was called. */
451
451
  get closed(): boolean;
452
+ /**
453
+ * Throws `CancelledError` (`"<operation>: client is closed"`, not retryable) once {@link close}
454
+ * was called (SPEC §2.4). Requests check this themselves; service methods that send no request
455
+ * (cached reads, local helpers) call it first.
456
+ */
457
+ ensureOpen(operation: string): void;
452
458
  /** Builds the absolute URL for a path and query. */
453
459
  buildUrl(path: string, query?: Readonly<Record<string, QueryValue>>): URL;
454
460
  /** Redacts known secrets from a text (error messages, vendor text). */
@@ -479,13 +485,13 @@ declare class HttpTransport {
479
485
  declare function redactSecretsInText(text: string): string;
480
486
 
481
487
  /** Package version (kept in sync by release-please). */
482
- declare const SDK_VERSION = "0.1.0";
488
+ declare const SDK_VERSION = "0.1.1";
483
489
  /** Catalog key of the service (`grafana-loki`). */
484
490
  declare const PACKAGE_KEY = "grafana-loki";
485
491
  /** Language tag used in the User-Agent. */
486
492
  declare const LANGUAGE = "typescript";
487
493
  /** sdk-kit version this package was generated from. */
488
- declare const SDK_KIT_VERSION = "0.2.0";
494
+ declare const SDK_KIT_VERSION = "0.3.0";
489
495
 
490
496
  declare const INSPECT: unique symbol;
491
497
  /** Longest tenant id Loki accepts (bytes). */
package/lib/index.d.ts CHANGED
@@ -449,6 +449,12 @@ declare class HttpTransport {
449
449
  constructor(options: TransportOptions);
450
450
  /** Whether {@link close} was called. */
451
451
  get closed(): boolean;
452
+ /**
453
+ * Throws `CancelledError` (`"<operation>: client is closed"`, not retryable) once {@link close}
454
+ * was called (SPEC §2.4). Requests check this themselves; service methods that send no request
455
+ * (cached reads, local helpers) call it first.
456
+ */
457
+ ensureOpen(operation: string): void;
452
458
  /** Builds the absolute URL for a path and query. */
453
459
  buildUrl(path: string, query?: Readonly<Record<string, QueryValue>>): URL;
454
460
  /** Redacts known secrets from a text (error messages, vendor text). */
@@ -479,13 +485,13 @@ declare class HttpTransport {
479
485
  declare function redactSecretsInText(text: string): string;
480
486
 
481
487
  /** Package version (kept in sync by release-please). */
482
- declare const SDK_VERSION = "0.1.0";
488
+ declare const SDK_VERSION = "0.1.1";
483
489
  /** Catalog key of the service (`grafana-loki`). */
484
490
  declare const PACKAGE_KEY = "grafana-loki";
485
491
  /** Language tag used in the User-Agent. */
486
492
  declare const LANGUAGE = "typescript";
487
493
  /** sdk-kit version this package was generated from. */
488
- declare const SDK_KIT_VERSION = "0.2.0";
494
+ declare const SDK_KIT_VERSION = "0.3.0";
489
495
 
490
496
  declare const INSPECT: unique symbol;
491
497
  /** Longest tenant id Loki accepts (bytes). */
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ConfigError, LokiError, ErrorCode, sleep, CancelledError, TimeoutError, errorForStatus, UnavailableError, logRecordByteSize, toAttributes, severityText, normalizeHexId, parseSeverity, ValidationError, BaseLogQueryClient, UnsupportedError } from './chunk-KTHP35QG.js';
2
- export { AuthenticationError, BaseLogQueryClient, CancelledError, ConfigError, ConflictError, ErrorCode, LokiError, NotFoundError, PermissionDeniedError, RateLimitError, Severity, TimeoutError, UnavailableError, UnsupportedError, UnsupportedLogQueryClient, ValidationError, canonicalSeverity, codeForStatus, errorForCode, errorForStatus, isLokiError, logRecordByteSize, logRecordFromJson, logRecordToJson, parseLogRecord, parseSeverity, pollTail, pollUntil, reasonForCode, serializeLogRecord, severityText, sleep, throwIfAborted, toAttrValue, toAttributes, waitForLog } from './chunk-KTHP35QG.js';
1
+ import { ConfigError, LokiError, ErrorCode, sleep, CancelledError, TimeoutError, errorForStatus, UnavailableError, logRecordByteSize, toAttributes, severityText, normalizeHexId, parseSeverity, ValidationError, BaseLogQueryClient, UnsupportedError } from './chunk-ZH5T5C4R.js';
2
+ export { AuthenticationError, BaseLogQueryClient, CancelledError, ConfigError, ConflictError, ErrorCode, LokiError, NotFoundError, PermissionDeniedError, RateLimitError, Severity, TimeoutError, UnavailableError, UnsupportedError, UnsupportedLogQueryClient, ValidationError, canonicalSeverity, codeForStatus, errorForCode, errorForStatus, isLokiError, logRecordByteSize, logRecordFromJson, logRecordToJson, parseLogRecord, parseSeverity, pollTail, pollUntil, reasonForCode, serializeLogRecord, severityText, sleep, throwIfAborted, toAttrValue, toAttributes, waitForLog } from './chunk-ZH5T5C4R.js';
3
3
  import { readFileSync } from 'fs';
4
4
  import { ProxyAgent, Agent, fetch } from 'undici';
5
5
  import { gzipSync } from 'zlib';
@@ -101,7 +101,7 @@ function redactUrl(url) {
101
101
  }
102
102
  function redactQueryString(text) {
103
103
  return text.replace(
104
- /([?&])([^=&#\s]+)=([^&#\s]*)/g,
104
+ /([?&])([^=&#?\s]+)=([^&#\s]*)/g,
105
105
  (m, sep, k) => isSensitiveField(k) ? `${sep}${k}=${REDACTED}` : m
106
106
  );
107
107
  }
@@ -206,20 +206,33 @@ var UNIT_MS = {
206
206
  m: 6e4,
207
207
  h: 36e5
208
208
  };
209
- var DURATION_PART = /(\d+(?:\.\d+)?|\.\d+)(ns|us|µs|ms|s|m|h)/gy;
209
+ var DURATION_UNITS = ["ns", "us", "\xB5s", "ms", "s", "m", "h"];
210
210
  function parseDuration(raw) {
211
211
  const text = raw.trim();
212
212
  if (/^\d+$/.test(text)) return Number(text);
213
213
  if (text === "") return void 0;
214
- DURATION_PART.lastIndex = 0;
215
214
  let total = 0;
216
- let pos = 0;
217
- let match;
218
- while ((match = DURATION_PART.exec(text)) !== null) {
219
- total += Number(match[1]) * UNIT_MS[match[2]];
220
- pos = DURATION_PART.lastIndex;
215
+ let i = 0;
216
+ const isDigit = (at) => at < text.length && text.charCodeAt(at) >= 48 && text.charCodeAt(at) <= 57;
217
+ while (i < text.length) {
218
+ const start = i;
219
+ while (isDigit(i)) i += 1;
220
+ const intDigits = i - start;
221
+ if (text[i] === ".") {
222
+ i += 1;
223
+ const fracStart = i;
224
+ while (isDigit(i)) i += 1;
225
+ if (i === fracStart) return void 0;
226
+ } else if (intDigits === 0) {
227
+ return void 0;
228
+ }
229
+ const value = Number(text.slice(start, i));
230
+ const unit = DURATION_UNITS.find((u) => text.startsWith(u, i));
231
+ if (unit === void 0) return void 0;
232
+ total += value * UNIT_MS[unit];
233
+ i += unit.length;
221
234
  }
222
- return pos === text.length && pos > 0 ? Math.round(total) : void 0;
235
+ return Math.round(total);
223
236
  }
224
237
  var TRUE_WORDS = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
225
238
  var FALSE_WORDS = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
@@ -590,10 +603,10 @@ function secretValues(...values) {
590
603
  }
591
604
 
592
605
  // src/core/version.ts
593
- var SDK_VERSION = "0.1.0";
606
+ var SDK_VERSION = "0.1.1";
594
607
  var PACKAGE_KEY = "grafana-loki";
595
608
  var LANGUAGE = "typescript";
596
- var SDK_KIT_VERSION = "0.2.0";
609
+ var SDK_KIT_VERSION = "0.3.0";
597
610
 
598
611
  // src/core/transport.ts
599
612
  var DEFAULT_REQUEST_ID_HEADERS = [
@@ -694,6 +707,14 @@ var HttpTransport = class {
694
707
  get closed() {
695
708
  return this.#closed;
696
709
  }
710
+ /**
711
+ * Throws `CancelledError` (`"<operation>: client is closed"`, not retryable) once {@link close}
712
+ * was called (SPEC §2.4). Requests check this themselves; service methods that send no request
713
+ * (cached reads, local helpers) call it first.
714
+ */
715
+ ensureOpen(operation) {
716
+ if (this.#closed) throw new CancelledError(`${operation}: client is closed`);
717
+ }
697
718
  /** Builds the absolute URL for a path and query. */
698
719
  buildUrl(path, query) {
699
720
  let url;
@@ -756,7 +777,7 @@ var HttpTransport = class {
756
777
  async #request(options) {
757
778
  const method = (options.method ?? "GET").toUpperCase();
758
779
  const operation = options.operation ?? `${method} ${options.path.split("?")[0] ?? ""}`;
759
- if (this.#closed) throw new CancelledError(`${operation}: client is closed`);
780
+ this.ensureOpen(operation);
760
781
  const signal = options.signal;
761
782
  if (signal?.aborted === true) throw new CancelledError(`${operation}: cancelled`);
762
783
  const url = this.buildUrl(options.path, options.query);