@camunda8/orchestration-cluster-api 1.1.4 → 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",
@@ -8809,6 +8809,7 @@ function hydrateConfig(options = {}) {
8809
8809
  provided[k] = baseEnv[k].trim();
8810
8810
  }
8811
8811
  }
8812
+ const userSetStrategy = provided["CAMUNDA_AUTH_STRATEGY"] !== void 0 && provided["CAMUNDA_AUTH_STRATEGY"].trim() !== "";
8812
8813
  const parseErrors = [];
8813
8814
  function boolParserFactory(key) {
8814
8815
  return (v) => {
@@ -8873,6 +8874,12 @@ function hydrateConfig(options = {}) {
8873
8874
  if (envInput["CAMUNDA_SUPPORT_LOG_ENABLED"] === void 0 && envInput["CAMUNDA_SUPPORT_LOGGER"] !== void 0) {
8874
8875
  envInput["CAMUNDA_SUPPORT_LOG_ENABLED"] = envInput["CAMUNDA_SUPPORT_LOGGER"];
8875
8876
  }
8877
+ if (envInput["CAMUNDA_REST_ADDRESS"] === void 0 && baseEnv["ZEEBE_REST_ADDRESS"] !== void 0 && baseEnv["ZEEBE_REST_ADDRESS"].trim() !== "") {
8878
+ envInput["CAMUNDA_REST_ADDRESS"] = baseEnv["ZEEBE_REST_ADDRESS"].trim();
8879
+ }
8880
+ if ((envInput["CAMUNDA_AUTH_STRATEGY"] === void 0 || envInput["CAMUNDA_AUTH_STRATEGY"].trim() === "") && envInput["CAMUNDA_OAUTH_URL"] !== void 0 && envInput["CAMUNDA_OAUTH_URL"].trim() !== "" && envInput["CAMUNDA_CLIENT_ID"] !== void 0 && envInput["CAMUNDA_CLIENT_ID"].trim() !== "" && envInput["CAMUNDA_CLIENT_SECRET"] !== void 0 && envInput["CAMUNDA_CLIENT_SECRET"].trim() !== "") {
8881
+ envInput["CAMUNDA_AUTH_STRATEGY"] = "OAUTH";
8882
+ }
8876
8883
  let envTyped = {};
8877
8884
  envTyped = (0, import_typed_env.createEnv)(typedEnvSchema, { env: envInput });
8878
8885
  for (const k of allKeys()) {
@@ -8886,6 +8893,9 @@ function hydrateConfig(options = {}) {
8886
8893
  rawMap[k] = String(entry.default);
8887
8894
  }
8888
8895
  }
8896
+ if (!userSetStrategy && rawMap["CAMUNDA_AUTH_STRATEGY"] === "NONE" && rawMap["CAMUNDA_OAUTH_URL"] && rawMap["CAMUNDA_OAUTH_URL"].trim() !== "" && rawMap["CAMUNDA_CLIENT_ID"] && rawMap["CAMUNDA_CLIENT_ID"].trim() !== "" && rawMap["CAMUNDA_CLIENT_SECRET"] && rawMap["CAMUNDA_CLIENT_SECRET"].trim() !== "") {
8897
+ rawMap["CAMUNDA_AUTH_STRATEGY"] = "OAUTH";
8898
+ }
8889
8899
  const authStrategyRaw = (rawMap["CAMUNDA_AUTH_STRATEGY"] || "NONE").toString();
8890
8900
  const authStrategy = authStrategyRaw.trim().toUpperCase();
8891
8901
  if (!["NONE", "OAUTH", "BASIC"].includes(authStrategy)) {
@@ -9441,7 +9451,8 @@ var ORDER = {
9441
9451
  warn: 2,
9442
9452
  info: 3,
9443
9453
  debug: 4,
9444
- trace: 5
9454
+ trace: 5,
9455
+ silly: 6
9445
9456
  };
9446
9457
  function createLogger(opts = {}) {
9447
9458
  let currentLevel = opts.level || "error";
@@ -9495,6 +9506,7 @@ function createLogger(opts = {}) {
9495
9506
  info: (...a) => emit("info", scope, a),
9496
9507
  debug: (...a) => emit("debug", scope, a),
9497
9508
  trace: (...a) => emit("trace", scope, a),
9509
+ silly: (...a) => emit("silly", scope, a),
9498
9510
  scope(child) {
9499
9511
  return make(scope ? `${scope}:${child}` : child);
9500
9512
  },
@@ -9506,7 +9518,7 @@ function createLogger(opts = {}) {
9506
9518
  }
9507
9519
 
9508
9520
  // src/runtime/version.ts
9509
- var packageVersion = "1.1.4";
9521
+ var packageVersion = "1.2.0";
9510
9522
 
9511
9523
  // src/runtime/supportLogger.ts
9512
9524
  var NoopSupportLogger = class {
@@ -9707,6 +9719,46 @@ function wrapFetch(orig, opts) {
9707
9719
  const requestId = "r" + (++globalRequestCounter).toString(36);
9708
9720
  const correlationId = opts.correlation ? opts.correlation() : void 0;
9709
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
+ }
9710
9762
  const startEvt = {
9711
9763
  type: "http.start",
9712
9764
  ts: start,
@@ -9719,6 +9771,11 @@ function wrapFetch(orig, opts) {
9719
9771
  try {
9720
9772
  hooks?.beforeRequest?.(startEvt);
9721
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
+ }
9722
9779
  } catch {
9723
9780
  }
9724
9781
  try {
@@ -9740,6 +9797,44 @@ function wrapFetch(orig, opts) {
9740
9797
  mirrorLog(endEvt);
9741
9798
  } catch {
9742
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
+ }
9743
9838
  try {
9744
9839
  const opName = `${endEvt.method} ${endEvt.url}`;
9745
9840
  opts.supportLogger?.log(
@@ -10758,7 +10853,7 @@ var CamundaClient = class {
10758
10853
  });
10759
10854
  } else if (
10760
10855
  // Auto-enable mirror telemetry when trace level and user did not explicitly set CAMUNDA_SDK_TELEMETRY_LOG to a disabling value.
10761
- 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
10762
10857
  this._overrides["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 && // And env var either absent or truthy enabling value
10763
10858
  (typeof process === "undefined" || process.env["CAMUNDA_SDK_TELEMETRY_LOG"] === void 0 || /^(1|true|yes|on)$/i.test(process.env["CAMUNDA_SDK_TELEMETRY_LOG"] || ""))
10764
10859
  ) {
@@ -10775,6 +10870,12 @@ var CamundaClient = class {
10775
10870
  fetch: this._fetch,
10776
10871
  throwOnError: opts.throwOnError !== false
10777
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
+ }
10778
10879
  installAuthInterceptor(
10779
10880
  this._client,
10780
10881
  () => this._config.auth.strategy,
@@ -10853,7 +10954,7 @@ var CamundaClient = class {
10853
10954
  supportLogger: this._supportLogger,
10854
10955
  mirrorToLog: true
10855
10956
  });
10856
- } 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"] || ""))) {
10857
10958
  this._fetch = wrapFetch(this._fetch || fetch, {
10858
10959
  hooks: void 0,
10859
10960
  correlation: this._config.telemetry?.correlation ? () => getCorrelation() : void 0,