@camunda8/orchestration-cluster-api 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,8 @@ var ORDER = {
17
17
  warn: 2,
18
18
  info: 3,
19
19
  debug: 4,
20
- trace: 5
20
+ trace: 5,
21
+ silly: 6
21
22
  };
22
23
  function createLogger(opts = {}) {
23
24
  let currentLevel = opts.level || "error";
@@ -71,6 +72,7 @@ function createLogger(opts = {}) {
71
72
  info: (...a) => emit("info", scope, a),
72
73
  debug: (...a) => emit("debug", scope, a),
73
74
  trace: (...a) => emit("trace", scope, a),
75
+ silly: (...a) => emit("silly", scope, a),
74
76
  scope(child) {
75
77
  return make(scope ? `${scope}:${child}` : child);
76
78
  },
@@ -86,4 +88,4 @@ export {
86
88
  __export,
87
89
  createLogger
88
90
  };
89
- //# sourceMappingURL=chunk-IEZVLX66.js.map
91
+ //# sourceMappingURL=chunk-W6JB7JZH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/logger.ts"],"sourcesContent":["// Per-client logger (no global singleton). Construct via createLogger.\n\n// Added 'silly' for deep diagnostics (unsafe: logs HTTP bodies when enabled elsewhere)\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silly';\nexport interface LogEvent {\n level: LogLevel;\n scope: string;\n ts: number;\n args: any[];\n code?: string;\n data?: any;\n}\nexport type LogTransport = (e: LogEvent) => void;\nconst ORDER: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n trace: 5,\n silly: 6,\n};\n\nexport interface Logger {\n level(): LogLevel;\n setLevel(level: LogLevel): void; // internal use\n setTransport(t?: LogTransport): void; // internal use\n error(...a: any[]): void;\n warn(...a: any[]): void;\n info(...a: any[]): void;\n debug(...a: any[]): void;\n trace(...a: any[]): void;\n silly(...a: any[]): void;\n scope(child: string): Logger;\n code(level: LogLevel, code: string, msg: string, data?: any): void;\n}\n\nexport interface CreateLoggerOptions {\n level?: LogLevel;\n transport?: LogTransport;\n scope?: string;\n}\n\nexport function createLogger(opts: CreateLoggerOptions = {}): Logger {\n let currentLevel: LogLevel = opts.level || 'error';\n let transport: LogTransport | undefined = opts.transport;\n const baseScope = opts.scope || '';\n\n function isEnabled(need: LogLevel) {\n return ORDER[currentLevel] >= ORDER[need];\n }\n function evalArgs(args: any[]): any[] {\n // Support lazy function args: if an arg is a function with zero arity, call it.\n return args.map((a) => (typeof a === 'function' && a.length === 0 ? a() : a)).flat();\n }\n function emit(level: LogLevel, scope: string, rawArgs: any[]) {\n if (!isEnabled(level)) return;\n const args = evalArgs(rawArgs);\n const evt: LogEvent = { level, scope, ts: Date.now(), args };\n if (transport) {\n try {\n transport(evt);\n } catch {\n /* ignore transport errors */\n }\n } else {\n const tag = `[camunda-sdk][${level}]${scope ? `[${scope}]` : ''}`;\n const method = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log';\n // eslint-disable-next-line no-console\n console[method](tag, ...args);\n }\n }\n function emitCode(level: LogLevel, scope: string, code: string, msg: string, data?: any) {\n if (!isEnabled(level)) return;\n const evt: LogEvent = { level, scope, ts: Date.now(), args: [msg], code, data };\n if (transport) {\n try {\n transport(evt);\n // eslint-disable-next-line no-empty\n } catch {}\n } else {\n const tag = `[camunda-sdk][${level}]${scope ? `[${scope}]` : ''}`;\n const method = level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'log';\n // eslint-disable-next-line no-console\n console[method](tag, code + ':', msg, data ?? '');\n }\n }\n const make = (scope: string): Logger => ({\n level: () => currentLevel,\n setLevel(l: LogLevel) {\n currentLevel = l;\n },\n setTransport(t?: LogTransport) {\n transport = t;\n },\n error: (...a: any[]) => emit('error', scope, a),\n warn: (...a: any[]) => emit('warn', scope, a),\n info: (...a: any[]) => emit('info', scope, a),\n debug: (...a: any[]) => emit('debug', scope, a),\n trace: (...a: any[]) => emit('trace', scope, a),\n silly: (...a: any[]) => emit('silly', scope, a),\n scope(child: string) {\n return make(scope ? `${scope}:${child}` : child);\n },\n code(l: LogLevel, code: string, msg: string, data?: any) {\n emitCode(l, scope, code, msg, data);\n },\n });\n return make(baseScope);\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAM,QAAkC;AAAA,EACtC,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;AAsBO,SAAS,aAAa,OAA4B,CAAC,GAAW;AACnE,MAAI,eAAyB,KAAK,SAAS;AAC3C,MAAI,YAAsC,KAAK;AAC/C,QAAM,YAAY,KAAK,SAAS;AAEhC,WAAS,UAAU,MAAgB;AACjC,WAAO,MAAM,YAAY,KAAK,MAAM,IAAI;AAAA,EAC1C;AACA,WAAS,SAAS,MAAoB;AAEpC,WAAO,KAAK,IAAI,CAAC,MAAO,OAAO,MAAM,cAAc,EAAE,WAAW,IAAI,EAAE,IAAI,CAAE,EAAE,KAAK;AAAA,EACrF;AACA,WAAS,KAAK,OAAiB,OAAe,SAAgB;AAC5D,QAAI,CAAC,UAAU,KAAK,EAAG;AACvB,UAAM,OAAO,SAAS,OAAO;AAC7B,UAAM,MAAgB,EAAE,OAAO,OAAO,IAAI,KAAK,IAAI,GAAG,KAAK;AAC3D,QAAI,WAAW;AACb,UAAI;AACF,kBAAU,GAAG;AAAA,MACf,QAAQ;AAAA,MAER;AAAA,IACF,OAAO;AACL,YAAM,MAAM,iBAAiB,KAAK,IAAI,QAAQ,IAAI,KAAK,MAAM,EAAE;AAC/D,YAAM,SAAS,UAAU,UAAU,UAAU,UAAU,SAAS,SAAS;AAEzE,cAAQ,MAAM,EAAE,KAAK,GAAG,IAAI;AAAA,IAC9B;AAAA,EACF;AACA,WAAS,SAAS,OAAiB,OAAe,MAAc,KAAa,MAAY;AACvF,QAAI,CAAC,UAAU,KAAK,EAAG;AACvB,UAAM,MAAgB,EAAE,OAAO,OA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"error", "warn", "info", "debug", "trace"],
8582
+ choices: ["silent", "error", "warn", "info", "debug", "trace", "silly"],
8583
8583
  default: "error",
8584
- doc: "SDK log level."
8584
+ doc: 'SDK log level. "silly" adds unsafe deep diagnostics including HTTP request and response bodies.'
8585
8585
  },
8586
8586
  CAMUNDA_SDK_TELEMETRY_LOG: {
8587
8587
  type: "boolean",
@@ -9451,7 +9451,8 @@ var ORDER = {
9451
9451
  warn: 2,
9452
9452
  info: 3,
9453
9453
  debug: 4,
9454
- trace: 5
9454
+ trace: 5,
9455
+ silly: 6
9455
9456
  };
9456
9457
  function createLogger(opts = {}) {
9457
9458
  let currentLevel = opts.level || "error";
@@ -9505,6 +9506,7 @@ function createLogger(opts = {}) {
9505
9506
  info: (...a) => emit("info", scope, a),
9506
9507
  debug: (...a) => emit("debug", scope, a),
9507
9508
  trace: (...a) => emit("trace", scope, a),
9509
+ silly: (...a) => emit("silly", scope, a),
9508
9510
  scope(child) {
9509
9511
  return make(scope ? `${scope}:${child}` : child);
9510
9512
  },
@@ -9516,7 +9518,7 @@ function createLogger(opts = {}) {
9516
9518
  }
9517
9519
 
9518
9520
  // src/runtime/version.ts
9519
- var packageVersion = "1.1.5";
9521
+ var packageVersion = "1.2.0";
9520
9522
 
9521
9523
  // src/runtime/supportLogger.ts
9522
9524
  var NoopSupportLogger = class {
@@ -9717,6 +9719,46 @@ function wrapFetch(orig, opts) {
9717
9719
  const requestId = "r" + (++globalRequestCounter).toString(36);
9718
9720
  const correlationId = opts.correlation ? opts.correlation() : void 0;
9719
9721
  const start = Date.now();
9722
+ let bodyPreview;
9723
+ try {
9724
+ const lvl = logger?.level?.();
9725
+ if (lvl === "silly" && (method === "POST" || method === "PUT" || method === "PATCH")) {
9726
+ let body = init?.body;
9727
+ if (body === void 0 && typeof Request !== "undefined" && input instanceof Request) {
9728
+ try {
9729
+ body = await input.clone().text();
9730
+ } catch {
9731
+ body = void 0;
9732
+ }
9733
+ }
9734
+ if (body !== void 0 && body !== null) {
9735
+ if (typeof body === "string") bodyPreview = body;
9736
+ else if (body instanceof URLSearchParams) bodyPreview = body.toString();
9737
+ else if (typeof FormData !== "undefined" && body instanceof FormData) {
9738
+ const entries = [];
9739
+ for (const [k, v] of body.entries()) {
9740
+ entries.push(`${k}=${typeof v === "string" ? v.slice(0, 200) : "[File]"}`);
9741
+ }
9742
+ bodyPreview = entries.join("&");
9743
+ } else if (body instanceof Blob) {
9744
+ bodyPreview = `[Blob size=${body.size}]`;
9745
+ } else if (body instanceof ArrayBuffer) {
9746
+ bodyPreview = `[ArrayBuffer byteLength=${body.byteLength}]`;
9747
+ } else if (body instanceof Uint8Array) {
9748
+ bodyPreview = `[Uint8Array length=${body.length}]`;
9749
+ } else if (typeof body === "object") {
9750
+ try {
9751
+ bodyPreview = JSON.stringify(body).slice(0, 4e3);
9752
+ } catch {
9753
+ bodyPreview = "[Unstringifiable object body]";
9754
+ }
9755
+ }
9756
+ if (bodyPreview && bodyPreview.length > 4e3)
9757
+ bodyPreview = bodyPreview.slice(0, 4e3) + "\u2026";
9758
+ }
9759
+ }
9760
+ } catch {
9761
+ }
9720
9762
  const startEvt = {
9721
9763
  type: "http.start",
9722
9764
  ts: start,
@@ -9729,6 +9771,11 @@ function wrapFetch(orig, opts) {
9729
9771
  try {
9730
9772
  hooks?.beforeRequest?.(startEvt);
9731
9773
  mirrorLog(startEvt);
9774
+ if (bodyPreview && logger?.level?.() === "silly") {
9775
+ logger.silly(() => [
9776
+ `op=${method} ${redactedUrl} http.body requestId=${requestId} size=${bodyPreview.length} preview=${bodyPreview}`
9777
+ ]);
9778
+ }
9732
9779
  } catch {
9733
9780
  }
9734
9781
  try {
@@ -9750,6 +9797,44 @@ function wrapFetch(orig, opts) {
9750
9797
  mirrorLog(endEvt);
9751
9798
  } catch {
9752
9799
  }
9800
+ try {
9801
+ if (logger?.level?.() === "silly") {
9802
+ let respPreview;
9803
+ const cloned = res.clone();
9804
+ const ctype = cloned.headers.get("Content-Type") || "";
9805
+ let originalSize;
9806
+ if (/^(application\/json|text\/)/i.test(ctype)) {
9807
+ try {
9808
+ const text = await cloned.text();
9809
+ originalSize = text.length;
9810
+ respPreview = text.slice(0, 4e3);
9811
+ if (text.length > 4e3) respPreview += "\u2026";
9812
+ } catch {
9813
+ respPreview = void 0;
9814
+ }
9815
+ } else if (/multipart\//i.test(ctype)) {
9816
+ respPreview = "[multipart body omitted]";
9817
+ } else if (/octet-stream|binary/i.test(ctype)) {
9818
+ respPreview = "[binary body omitted]";
9819
+ } else {
9820
+ try {
9821
+ const text = await cloned.text();
9822
+ if (text) {
9823
+ originalSize = text.length;
9824
+ respPreview = text.slice(0, 200);
9825
+ if (text.length > 200) respPreview += "\u2026";
9826
+ }
9827
+ } catch {
9828
+ }
9829
+ }
9830
+ if (respPreview) {
9831
+ logger.silly(() => [
9832
+ `op=${method} ${redactedUrl} http.response requestId=${requestId} status=${res.status} size=${originalSize} preview=${respPreview}`
9833
+ ]);
9834
+ }
9835
+ }
9836
+ } catch {
9837
+ }
9753
9838
  try {
9754
9839
  const opName = `${endEvt.method} ${endEvt.url}`;
9755
9840
  opts.supportLogger?.log(
@@ -10768,7 +10853,7 @@ var CamundaClient = class {
10768
10853
  });
10769
10854
  } else if (
10770
10855
  // Auto-enable mirror telemetry when trace level and user did not explicitly set CAMUNDA_SDK_TELEMETRY_LOG to a disabling value.
10771
- this._log.level() === "trace" && !this._config.telemetry?.log && // No explicit override provided
10856
+ /^(trace|silly)$/.test(this._log.level()) && !this._config.telemetry?.log && // No explicit override provided
10772
10857
  this._overrides["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 && // And env var either absent or truthy enabling value
10773
10858
  (typeof process === "undefined" || process.env["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 || /^(1|true|yes|on)$/i.test(process.env["CAMUNDA_SDK_TELEMETRY_LOG"] || ""))
10774
10859
  ) {
@@ -10785,6 +10870,12 @@ var CamundaClient = class {
10785
10870
  fetch: this._fetch,
10786
10871
  throwOnError: opts.throwOnError !== false
10787
10872
  });
10873
+ if (this._log.level() === "silly") {
10874
+ this._log.warn(
10875
+ "log.level.silly.enabled",
10876
+ "HTTP request and response bodies will be logged; this may leak sensitive information. Use only for local debugging."
10877
+ );
10878
+ }
10788
10879
  installAuthInterceptor(
10789
10880
  this._client,
10790
10881
  () => this._config.auth.strategy,
@@ -10863,7 +10954,7 @@ var CamundaClient = class {
10863
10954
  supportLogger: this._supportLogger,
10864
10955
  mirrorToLog: true
10865
10956
  });
10866
- } else if (this._log.level() === "trace" && !this._config.telemetry?.log && this._overrides["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 && (typeof process === "undefined" || process.env["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 || /^(1|true|yes|on)$/i.test(process.env["CAMUNDA_SDK_TELEMETRY_LOG"] || ""))) {
10957
+ } else if (/^(trace|silly)$/.test(this._log.level()) && !this._config.telemetry?.log && this._overrides["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 && (typeof process === "undefined" || process.env["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 || /^(1|true|yes|on)$/i.test(process.env["CAMUNDA_SDK_TELEMETRY_LOG"] || ""))) {
10867
10958
  this._fetch = wrapFetch(this._fetch || fetch, {
10868
10959
  hooks: void 0,
10869
10960
  correlation: this._config.telemetry?.correlation ? () => getCorrelation() : void 0,