@camunda8/orchestration-cluster-api 10.0.3 → 10.1.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.
@@ -13722,8 +13722,40 @@ var liveRandom = {
13722
13722
  var MASK_64 = (1n << 64n) - 1n;
13723
13723
  var UNIT = 2 ** -53;
13724
13724
 
13725
- // src/runtime/auth.ts
13725
+ // src/runtime/version.ts
13726
+ var packageVersion = "10.1.0";
13727
+
13728
+ // src/runtime/userAgent.ts
13726
13729
  var import_platform = require("#platform");
13730
+ var SDK_USER_AGENT = `camunda-orchestration-sdk-js/${packageVersion}`;
13731
+ function userAgentHeaderName() {
13732
+ return import_platform.node ? "User-Agent" : null;
13733
+ }
13734
+ function buildUserAgent(appUserAgent) {
13735
+ const extra = appUserAgent?.trim();
13736
+ return extra ? `${SDK_USER_AGENT} ${extra}` : SDK_USER_AGENT;
13737
+ }
13738
+ function userAgentHeaders(appUserAgent, name = userAgentHeaderName()) {
13739
+ return name ? { [name]: buildUserAgent(appUserAgent) } : {};
13740
+ }
13741
+ function withUserAgent(base, getAppUserAgent, name = userAgentHeaderName()) {
13742
+ return (input, init) => {
13743
+ const fetchImpl = base ?? ((i, n) => fetch(i, n));
13744
+ if (!name) return fetchImpl(input, init);
13745
+ const value = buildUserAgent(getAppUserAgent());
13746
+ if (!init?.headers && typeof Request !== "undefined" && input instanceof Request) {
13747
+ const headers2 = new Headers(input.headers);
13748
+ headers2.set(name, value);
13749
+ return fetchImpl(new Request(input, { headers: headers2 }), init);
13750
+ }
13751
+ const headers = new Headers(init?.headers);
13752
+ headers.set(name, value);
13753
+ return fetchImpl(input, { ...init || {}, headers });
13754
+ };
13755
+ }
13756
+
13757
+ // src/runtime/auth.ts
13758
+ var import_platform2 = require("#platform");
13727
13759
  var CamundaAuthError = class extends Error {
13728
13760
  constructor(code, message, cause) {
13729
13761
  super(`${code}: ${message}`);
@@ -13781,9 +13813,9 @@ var OAuthManager = class {
13781
13813
  } catch {
13782
13814
  }
13783
13815
  }
13784
- if (!this.session && this.cfg.oauth.cacheDir && import_platform.node && this.isNode()) {
13816
+ if (!this.session && this.cfg.oauth.cacheDir && import_platform2.node && this.isNode()) {
13785
13817
  try {
13786
- const { fs, path } = import_platform.node;
13818
+ const { fs, path } = import_platform2.node;
13787
13819
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
13788
13820
  if (fs.existsSync(file)) {
13789
13821
  const raw = fs.readFileSync(file, "utf8");
@@ -13800,9 +13832,9 @@ var OAuthManager = class {
13800
13832
  this.session.setItem(this.storageKey, JSON.stringify(this.token));
13801
13833
  } catch {
13802
13834
  }
13803
- } else if (this.cfg.oauth.cacheDir && import_platform.node && this.isNode()) {
13835
+ } else if (this.cfg.oauth.cacheDir && import_platform2.node && this.isNode()) {
13804
13836
  try {
13805
- const { fs, path } = import_platform.node;
13837
+ const { fs, path } = import_platform2.node;
13806
13838
  if (!fs.existsSync(this.cfg.oauth.cacheDir))
13807
13839
  fs.mkdirSync(this.cfg.oauth.cacheDir, { recursive: true });
13808
13840
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
@@ -13855,9 +13887,9 @@ var OAuthManager = class {
13855
13887
  if (opts.disk) {
13856
13888
  if (this.session) {
13857
13889
  this.session.removeItem(this.storageKey);
13858
- } else if (this.cfg.oauth.cacheDir && import_platform.node && this.isNode()) {
13890
+ } else if (this.cfg.oauth.cacheDir && import_platform2.node && this.isNode()) {
13859
13891
  try {
13860
- const { fs, path } = import_platform.node;
13892
+ const { fs, path } = import_platform2.node;
13861
13893
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
13862
13894
  if (fs.existsSync(file)) fs.unlinkSync(file);
13863
13895
  } catch {
@@ -13905,7 +13937,10 @@ var OAuthManager = class {
13905
13937
  this.logger.debug(`OAuth token attempt ${attempt + 1}/${max}`);
13906
13938
  const res = await fetcher(this.cfg.oauth.oauthUrl, {
13907
13939
  method: "POST",
13908
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
13940
+ headers: {
13941
+ "Content-Type": "application/x-www-form-urlencoded",
13942
+ ...userAgentHeaders(this.cfg.userAgent)
13943
+ },
13909
13944
  body: body.toString(),
13910
13945
  signal: controller.signal
13911
13946
  });
@@ -14063,9 +14098,9 @@ function createAuthFacade(config, opts) {
14063
14098
  else if (cfg.auth.strategy === "BASIC") basic = new BasicAuthManager(cfg);
14064
14099
  const fetcher = (input, init) => opts?.fetch ? opts.fetch(input, init) : fetch(input, init);
14065
14100
  let nodeAgent = null;
14066
- if (cfg.mtls && import_platform.node && typeof process !== "undefined" && process.versions?.node) {
14101
+ if (cfg.mtls && import_platform2.node && typeof process !== "undefined" && process.versions?.node) {
14067
14102
  try {
14068
- const { fs, https } = import_platform.node;
14103
+ const { fs, https } = import_platform2.node;
14069
14104
  const material = {};
14070
14105
  const pem = (inline, path) => inline || (path ? fs.readFileSync(path, "utf8") : inline);
14071
14106
  if (cfg.mtls.cert || cfg.mtls.certPath) material.cert = pem(cfg.mtls.cert, cfg.mtls.certPath);
@@ -14669,9 +14704,6 @@ async function executeWithHttpRetry(fn, policy, logger, classify = defaultHttpCl
14669
14704
  return exec(fn, classify);
14670
14705
  }
14671
14706
 
14672
- // src/runtime/version.ts
14673
- var packageVersion = "10.0.3";
14674
-
14675
14707
  // src/runtime/configSchema.ts
14676
14708
  var SCHEMA = {
14677
14709
  CAMUNDA_REST_ADDRESS: {
@@ -14766,6 +14798,10 @@ var SCHEMA = {
14766
14798
  doc: "Basic auth password (required when CAMUNDA_AUTH_STRATEGY=BASIC).",
14767
14799
  requiredWhen: { key: "CAMUNDA_AUTH_STRATEGY", equals: "BASIC" }
14768
14800
  },
14801
+ CAMUNDA_USER_AGENT: {
14802
+ type: "string",
14803
+ doc: "Application user agent appended after the SDK identifier (camunda-orchestration-sdk-js/<version>) in the User-Agent header. Never replaces the SDK identifier."
14804
+ },
14769
14805
  CAMUNDA_SDK_VALIDATION: {
14770
14806
  type: "string",
14771
14807
  default: "req:none,res:none",
@@ -14928,7 +14964,7 @@ function allKeys() {
14928
14964
  }
14929
14965
 
14930
14966
  // src/runtime/supportLogger.ts
14931
- var import_platform2 = require("#platform");
14967
+ var import_platform3 = require("#platform");
14932
14968
  var NoopSupportLogger = class {
14933
14969
  log(_message, _addTimestamp = true) {
14934
14970
  }
@@ -14977,9 +15013,9 @@ var CamundaSupportLogger = class {
14977
15013
  constructor(config) {
14978
15014
  const enabled = !!config.supportLog?.enabled;
14979
15015
  this.enabled = enabled;
14980
- this.filepath = config.supportLog?.filePath || (import_platform2.node && typeof process !== "undefined" ? import_platform2.node.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log");
14981
- if (!this.enabled || !isNode() || !import_platform2.node) return;
14982
- const { fs } = import_platform2.node;
15016
+ this.filepath = config.supportLog?.filePath || (import_platform3.node && typeof process !== "undefined" ? import_platform3.node.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log");
15017
+ if (!this.enabled || !isNode() || !import_platform3.node) return;
15018
+ const { fs } = import_platform3.node;
14983
15019
  if (fs.existsSync(this.filepath)) {
14984
15020
  let n = 1;
14985
15021
  const base = this.filepath;
@@ -14996,8 +15032,8 @@ var CamundaSupportLogger = class {
14996
15032
  writeSupportLogPreamble(this, config);
14997
15033
  }
14998
15034
  log(message, addTimestamp = true) {
14999
- if (!this.enabled || !isNode() || !import_platform2.node) return;
15000
- const { fs } = import_platform2.node;
15035
+ if (!this.enabled || !isNode() || !import_platform3.node) return;
15036
+ const { fs } = import_platform3.node;
15001
15037
  const msg = typeof message === "object" ? safeStringify(message) : String(message);
15002
15038
  const line = addTimestamp ? `[${(/* @__PURE__ */ new Date()).toISOString()}]: ${msg}
15003
15039
  ` : `${msg}
@@ -15040,8 +15076,8 @@ function writeSupportLogPreamble(logger, config) {
15040
15076
  );
15041
15077
  logger.log(`Camunda SDK version: ${packageVersion}`, false);
15042
15078
  try {
15043
- if (!import_platform2.node) throw new Error("node:os unavailable");
15044
- const { os } = import_platform2.node;
15079
+ if (!import_platform3.node) throw new Error("node:os unavailable");
15080
+ const { os } = import_platform3.node;
15045
15081
  const osInfo = {
15046
15082
  platform: os.platform(),
15047
15083
  release: os.release(),
@@ -15417,7 +15453,7 @@ async function withCorrelation(id, fn) {
15417
15453
 
15418
15454
  // src/runtime/unifiedConfiguration.ts
15419
15455
  var import_typed_env = require("typed-env");
15420
- var import_platform3 = require("#platform");
15456
+ var import_platform4 = require("#platform");
15421
15457
  var CamundaConfigurationError = class extends Error {
15422
15458
  errors;
15423
15459
  constructor(errors) {
@@ -15774,6 +15810,14 @@ function hydrateConfig(options = {}) {
15774
15810
  message: "CAMUNDA_MTLS_KEY_PASSPHRASE is set but no client key was provided."
15775
15811
  });
15776
15812
  }
15813
+ const userAgentRaw = rawMap.CAMUNDA_USER_AGENT?.trim();
15814
+ if (userAgentRaw && !/^[\t\x20-\x7E\x80-\xFF]*$/.test(userAgentRaw)) {
15815
+ errors.push({
15816
+ code: "CONFIG_INVALID_VALUE" /* CONFIG_INVALID_VALUE */,
15817
+ key: "CAMUNDA_USER_AGENT",
15818
+ message: "CAMUNDA_USER_AGENT is not a valid HTTP header value: it must contain only printable Latin-1 characters (no control characters such as CR/LF, and no characters above U+00FF)."
15819
+ });
15820
+ }
15777
15821
  const validationRaw = reqStr("CAMUNDA_SDK_VALIDATION");
15778
15822
  const validation = parseValidation(validationRaw, errors);
15779
15823
  if (errors.length) {
@@ -15914,6 +15958,7 @@ function hydrateConfig(options = {}) {
15914
15958
  },
15915
15959
  validation: { req: validation.req, res: validation.res, raw: validation.raw },
15916
15960
  logLevel: reqStr("CAMUNDA_SDK_LOG_LEVEL"),
15961
+ userAgent: rawMap.CAMUNDA_USER_AGENT?.trim() || void 0,
15917
15962
  eventual: {
15918
15963
  pollDefaultMs: reqInt("CAMUNDA_SDK_EVENTUAL_POLL_DEFAULT_MS")
15919
15964
  },
@@ -15932,7 +15977,7 @@ function hydrateConfig(options = {}) {
15932
15977
  },
15933
15978
  supportLog: {
15934
15979
  enabled: reqBool("CAMUNDA_SUPPORT_LOG_ENABLED"),
15935
- filePath: rawMap.CAMUNDA_SUPPORT_LOG_FILE_PATH || (import_platform3.node && typeof process !== "undefined" && typeof process.cwd === "function" ? import_platform3.node.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log")
15980
+ filePath: rawMap.CAMUNDA_SUPPORT_LOG_FILE_PATH || (import_platform4.node && typeof process !== "undefined" && typeof process.cwd === "function" ? import_platform4.node.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log")
15936
15981
  },
15937
15982
  workerDefaults: rawMap.CAMUNDA_WORKER_TIMEOUT || rawMap.CAMUNDA_WORKER_MAX_CONCURRENT_JOBS || rawMap.CAMUNDA_WORKER_REQUEST_TIMEOUT || rawMap.CAMUNDA_WORKER_NAME || rawMap.CAMUNDA_WORKER_STARTUP_JITTER_MAX_SECONDS ? {
15938
15983
  jobTimeoutMs: rawMap.CAMUNDA_WORKER_TIMEOUT ? parseInt(rawMap.CAMUNDA_WORKER_TIMEOUT, 10) : void 0,
@@ -16200,7 +16245,7 @@ async function applySchemaValidation(opts) {
16200
16245
 
16201
16246
  // src/runtime/validationExtras.ts
16202
16247
  var import_zod3 = require("zod");
16203
- var import_platform4 = require("#platform");
16248
+ var import_platform5 = require("#platform");
16204
16249
  var seenCaptures = /* @__PURE__ */ new Set();
16205
16250
  function hash(str) {
16206
16251
  let h = 0, i = 0;
@@ -16245,8 +16290,8 @@ function detectExtrasAndMaybeThrow(opts) {
16245
16290
  }
16246
16291
  if (settings.captureDir) {
16247
16292
  try {
16248
- if (!import_platform4.node) throw new Error("node:fs unavailable");
16249
- const { fs, path: pathMod } = import_platform4.node;
16293
+ if (!import_platform5.node) throw new Error("node:fs unavailable");
16294
+ const { fs, path: pathMod } = import_platform5.node;
16250
16295
  if (!fs.existsSync(settings.captureDir))
16251
16296
  fs.mkdirSync(settings.captureDir, { recursive: true, mode: 448 });
16252
16297
  const sig = `${operationId}|${flatIssues.sort().join("|")}`;
@@ -16426,7 +16471,7 @@ var CamundaCore = class _CamundaCore {
16426
16471
  });
16427
16472
  const baseFetch = opts.fetch;
16428
16473
  this._baseFetch = baseFetch;
16429
- this._fetch = baseFetch;
16474
+ this._fetch = withUserAgent(baseFetch, () => this._config.userAgent);
16430
16475
  if (opts.telemetry) {
16431
16476
  this._fetch = wrapFetch(this._fetch || fetch, {
16432
16477
  hooks: opts.telemetry.hooks,
@@ -16538,11 +16583,12 @@ var CamundaCore = class _CamundaCore {
16538
16583
  }
16539
16584
  // Merge new overrides and re-hydrate.
16540
16585
  configure(next) {
16541
- if (next.config) this._setOverrides({ ...this._getOverrides(), ...next.config });
16542
- if (next.fetch) this._baseFetch = next.fetch;
16543
- this._fetch = this._baseFetch;
16544
- const { config } = hydrateConfig({ overrides: this._getOverrides(), env: next.env });
16586
+ const candidate = next.config ? { ...this._getOverrides(), ...next.config } : this._getOverrides();
16587
+ const { config } = hydrateConfig({ overrides: candidate, env: next.env });
16588
+ if (next.config) this._setOverrides(candidate);
16545
16589
  this._config = deepFreeze2(config);
16590
+ if (next.fetch) this._baseFetch = next.fetch;
16591
+ this._fetch = withUserAgent(this._baseFetch, () => this._config.userAgent);
16546
16592
  if (next.telemetry) {
16547
16593
  this._fetch = wrapFetch(this._fetch || fetch, {
16548
16594
  hooks: next.telemetry.hooks,
@@ -17744,7 +17790,7 @@ function installClientCallHandler(port, client2) {
17744
17790
  }
17745
17791
 
17746
17792
  // src/runtime/threadPool.ts
17747
- var import_platform5 = require("#platform");
17793
+ var import_platform6 = require("#platform");
17748
17794
  var import_meta = {};
17749
17795
  var ThreadPool = class {
17750
17796
  _pool = [];
@@ -17758,7 +17804,7 @@ var ThreadPool = class {
17758
17804
  _Worker;
17759
17805
  _onThreadReady;
17760
17806
  constructor(client2, size) {
17761
- if (!import_platform5.node) {
17807
+ if (!import_platform6.node) {
17762
17808
  throw new Error("Threaded job workers are only available in Node.js environments");
17763
17809
  }
17764
17810
  this._client = client2;
@@ -17935,7 +17981,7 @@ var ThreadPool = class {
17935
17981
  return pw;
17936
17982
  }
17937
17983
  async _init(requestedSize) {
17938
- const n = import_platform5.node;
17984
+ const n = import_platform6.node;
17939
17985
  const workerThreads = await n.loadWorkerThreads();
17940
17986
  const { path: pathMod, crypto, fs, url: url2 } = n;
17941
17987
  this._Worker = workerThreads.Worker;
@@ -18180,7 +18226,7 @@ function createVariableSearchFetchPage(params) {
18180
18226
  }
18181
18227
 
18182
18228
  // src/gen/CamundaClient.ts
18183
- var import_platform6 = require("#platform");
18229
+ var import_platform7 = require("#platform");
18184
18230
 
18185
18231
  // src/runtime/eventual.ts
18186
18232
  function toCancelable2(factory) {
@@ -35750,13 +35796,13 @@ var CamundaClientBase = class extends CamundaCore {
35750
35796
  if (!Array.isArray(resourceFilenames) || resourceFilenames.length === 0) {
35751
35797
  throw new Error("resourceFilenames must be a non-empty string[]");
35752
35798
  }
35753
- if (!import_platform6.node || typeof process === "undefined" || !process.versions?.node) {
35799
+ if (!import_platform7.node || typeof process === "undefined" || !process.versions?.node) {
35754
35800
  throw new Error("deployResourcesFromFiles is only available in Node.js environments");
35755
35801
  }
35756
35802
  const {
35757
35803
  fsPromises: { readFile },
35758
35804
  path: pathMod
35759
- } = import_platform6.node;
35805
+ } = import_platform7.node;
35760
35806
  const mimeFor = (filename) => {
35761
35807
  const ext = filename.toLowerCase().split(".").pop() || "";
35762
35808
  switch (ext) {