@camunda8/orchestration-cluster-api 10.0.2 → 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.
@@ -1,7 +1,7 @@
1
1
  import * as effect_Cause from 'effect/Cause';
2
2
  import * as effect_Types from 'effect/Types';
3
3
  import { Context, Effect, Stream, Duration, Layer, Schedule, Cause, Scope } from 'effect';
4
- import { S as SearchPaginateOptions, P as Paginator, a as PaginationMode, C as ConsistencyOptions, b as SearchResponse, c as CamundaClient, d as CamundaOptions, A as ActivatedJobResult } from '../index-Ce2Ltqyu.cjs';
4
+ import { S as SearchPaginateOptions, P as Paginator, a as PaginationMode, C as ConsistencyOptions, b as SearchResponse, c as CamundaClient, d as CamundaOptions, A as ActivatedJobResult } from '../index-_oadktPd.cjs';
5
5
  import '../logger-DAFkqj8L.cjs';
6
6
  import 'zod';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import * as effect_Cause from 'effect/Cause';
2
2
  import * as effect_Types from 'effect/Types';
3
3
  import { Context, Effect, Stream, Duration, Layer, Schedule, Cause, Scope } from 'effect';
4
- import { S as SearchPaginateOptions, P as Paginator, a as PaginationMode, C as ConsistencyOptions, b as SearchResponse, c as CamundaClient, d as CamundaOptions, A as ActivatedJobResult } from '../index-C3R3Adrl.js';
4
+ import { S as SearchPaginateOptions, P as Paginator, a as PaginationMode, C as ConsistencyOptions, b as SearchResponse, c as CamundaClient, d as CamundaOptions, A as ActivatedJobResult } from '../index-DYNe-dK6.js';
5
5
  import '../logger-DAFkqj8L.js';
6
6
  import 'zod';
7
7
 
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  createCamundaClient,
3
3
  nextPageRequest
4
- } from "../chunk-PNUSMIUV.js";
4
+ } from "../chunk-JTOYRGYR.js";
5
5
  import {
6
6
  CamundaValidationError,
7
7
  EventualConsistencyTimeoutError,
8
8
  isPresentWhenUnsupportedError
9
- } from "../chunk-INHWJ5AA.js";
9
+ } from "../chunk-UQZHR5EN.js";
10
10
  import "../chunk-LXWPMQOS.js";
11
11
 
12
12
  // src/effect.ts
package/dist/fn/index.cjs CHANGED
@@ -11792,6 +11792,10 @@ var SCHEMA = {
11792
11792
  doc: "Basic auth password (required when CAMUNDA_AUTH_STRATEGY=BASIC).",
11793
11793
  requiredWhen: { key: "CAMUNDA_AUTH_STRATEGY", equals: "BASIC" }
11794
11794
  },
11795
+ CAMUNDA_USER_AGENT: {
11796
+ type: "string",
11797
+ doc: "Application user agent appended after the SDK identifier (camunda-orchestration-sdk-js/<version>) in the User-Agent header. Never replaces the SDK identifier."
11798
+ },
11795
11799
  CAMUNDA_SDK_VALIDATION: {
11796
11800
  type: "string",
11797
11801
  default: "req:none,res:none",
@@ -12311,6 +12315,14 @@ function hydrateConfig(options = {}) {
12311
12315
  message: "CAMUNDA_MTLS_KEY_PASSPHRASE is set but no client key was provided."
12312
12316
  });
12313
12317
  }
12318
+ const userAgentRaw = rawMap.CAMUNDA_USER_AGENT?.trim();
12319
+ if (userAgentRaw && !/^[\t\x20-\x7E\x80-\xFF]*$/.test(userAgentRaw)) {
12320
+ errors.push({
12321
+ code: "CONFIG_INVALID_VALUE" /* CONFIG_INVALID_VALUE */,
12322
+ key: "CAMUNDA_USER_AGENT",
12323
+ 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)."
12324
+ });
12325
+ }
12314
12326
  const validationRaw = reqStr("CAMUNDA_SDK_VALIDATION");
12315
12327
  const validation = parseValidation(validationRaw, errors);
12316
12328
  if (errors.length) {
@@ -12451,6 +12463,7 @@ function hydrateConfig(options = {}) {
12451
12463
  },
12452
12464
  validation: { req: validation.req, res: validation.res, raw: validation.raw },
12453
12465
  logLevel: reqStr("CAMUNDA_SDK_LOG_LEVEL"),
12466
+ userAgent: rawMap.CAMUNDA_USER_AGENT?.trim() || void 0,
12454
12467
  eventual: {
12455
12468
  pollDefaultMs: reqInt("CAMUNDA_SDK_EVENTUAL_POLL_DEFAULT_MS")
12456
12469
  },
@@ -15996,7 +16009,7 @@ function activateJobs2(core, arg, options) {
15996
16009
  let envelope = {};
15997
16010
  envelope.body = _body;
15998
16011
  if (envelope.body && rt._config.defaultTenantId !== void 0 && rt._config.defaultTenantId !== null && (!Array.isArray(envelope.body.tenantIds) || envelope.body.tenantIds.length === 0)) {
15999
- envelope.body.tenantIds = [rt._config.defaultTenantId];
16012
+ envelope.body = { ...envelope.body, tenantIds: [rt._config.defaultTenantId] };
16000
16013
  rt._log.trace(() => ["tenant.default.inject", { op: "activateJobs", tenantIds: [rt._config.defaultTenantId] }]);
16001
16014
  }
16002
16015
  if (rt._validation.settings.req !== "none") {
@@ -16850,7 +16863,7 @@ function broadcastSignal2(core, arg, options) {
16850
16863
  let envelope = {};
16851
16864
  envelope.body = _body;
16852
16865
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
16853
- envelope.body.tenantId = rt._config.defaultTenantId;
16866
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
16854
16867
  rt._log.trace(() => ["tenant.default.inject", { op: "broadcastSignal", tenant: rt._config.defaultTenantId }]);
16855
16868
  }
16856
16869
  if (rt._validation.settings.req !== "none") {
@@ -17362,7 +17375,7 @@ function correlateMessage2(core, arg, options) {
17362
17375
  let envelope = {};
17363
17376
  envelope.body = _body;
17364
17377
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
17365
- envelope.body.tenantId = rt._config.defaultTenantId;
17378
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
17366
17379
  rt._log.trace(() => ["tenant.default.inject", { op: "correlateMessage", tenant: rt._config.defaultTenantId }]);
17367
17380
  }
17368
17381
  if (rt._validation.settings.req !== "none") {
@@ -17586,7 +17599,7 @@ function createDeployment2(core, arg, options) {
17586
17599
  let envelope = {};
17587
17600
  envelope.body = _body;
17588
17601
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
17589
- envelope.body.tenantId = rt._config.defaultTenantId;
17602
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
17590
17603
  rt._log.trace(() => ["tenant.default.inject", { op: "createDeployment", tenant: rt._config.defaultTenantId }]);
17591
17604
  }
17592
17605
  if (rt._validation.settings.req !== "none") {
@@ -18129,7 +18142,7 @@ function createProcessInstance2(core, arg, options) {
18129
18142
  let envelope = {};
18130
18143
  envelope.body = _body;
18131
18144
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
18132
- envelope.body.tenantId = rt._config.defaultTenantId;
18145
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
18133
18146
  rt._log.trace(() => ["tenant.default.inject", { op: "createProcessInstance", tenant: rt._config.defaultTenantId }]);
18134
18147
  }
18135
18148
  if (rt._validation.settings.req !== "none") {
@@ -19594,7 +19607,7 @@ function evaluateConditionals2(core, arg, options) {
19594
19607
  let envelope = {};
19595
19608
  envelope.body = _body;
19596
19609
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
19597
- envelope.body.tenantId = rt._config.defaultTenantId;
19610
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
19598
19611
  rt._log.trace(() => ["tenant.default.inject", { op: "evaluateConditionals", tenant: rt._config.defaultTenantId }]);
19599
19612
  }
19600
19613
  if (rt._validation.settings.req !== "none") {
@@ -19653,7 +19666,7 @@ function evaluateDecision2(core, arg, options) {
19653
19666
  let envelope = {};
19654
19667
  envelope.body = _body;
19655
19668
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
19656
- envelope.body.tenantId = rt._config.defaultTenantId;
19669
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
19657
19670
  rt._log.trace(() => ["tenant.default.inject", { op: "evaluateDecision", tenant: rt._config.defaultTenantId }]);
19658
19671
  }
19659
19672
  if (rt._validation.settings.req !== "none") {
@@ -19712,7 +19725,7 @@ function evaluateExpression2(core, arg, options) {
19712
19725
  let envelope = {};
19713
19726
  envelope.body = _body;
19714
19727
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
19715
- envelope.body.tenantId = rt._config.defaultTenantId;
19728
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
19716
19729
  rt._log.trace(() => ["tenant.default.inject", { op: "evaluateExpression", tenant: rt._config.defaultTenantId }]);
19717
19730
  }
19718
19731
  if (rt._validation.settings.req !== "none") {
@@ -24203,7 +24216,7 @@ function publishMessage2(core, arg, options) {
24203
24216
  let envelope = {};
24204
24217
  envelope.body = _body;
24205
24218
  if (envelope.body && (envelope.body.tenantId === void 0 || envelope.body.tenantId === null)) {
24206
- envelope.body.tenantId = rt._config.defaultTenantId;
24219
+ envelope.body = { ...envelope.body, tenantId: rt._config.defaultTenantId };
24207
24220
  rt._log.trace(() => ["tenant.default.inject", { op: "publishMessage", tenant: rt._config.defaultTenantId }]);
24208
24221
  }
24209
24222
  if (rt._validation.settings.req !== "none") {
@@ -30036,8 +30049,40 @@ function _jobActionsClient(core) {
30036
30049
  };
30037
30050
  }
30038
30051
 
30039
- // src/runtime/auth.ts
30052
+ // src/runtime/version.ts
30053
+ var packageVersion = "10.1.0";
30054
+
30055
+ // src/runtime/userAgent.ts
30040
30056
  var import_platform2 = require("#platform");
30057
+ var SDK_USER_AGENT = `camunda-orchestration-sdk-js/${packageVersion}`;
30058
+ function userAgentHeaderName() {
30059
+ return import_platform2.node ? "User-Agent" : null;
30060
+ }
30061
+ function buildUserAgent(appUserAgent) {
30062
+ const extra = appUserAgent?.trim();
30063
+ return extra ? `${SDK_USER_AGENT} ${extra}` : SDK_USER_AGENT;
30064
+ }
30065
+ function userAgentHeaders(appUserAgent, name = userAgentHeaderName()) {
30066
+ return name ? { [name]: buildUserAgent(appUserAgent) } : {};
30067
+ }
30068
+ function withUserAgent(base, getAppUserAgent, name = userAgentHeaderName()) {
30069
+ return (input, init) => {
30070
+ const fetchImpl = base ?? ((i, n) => fetch(i, n));
30071
+ if (!name) return fetchImpl(input, init);
30072
+ const value = buildUserAgent(getAppUserAgent());
30073
+ if (!init?.headers && typeof Request !== "undefined" && input instanceof Request) {
30074
+ const headers2 = new Headers(input.headers);
30075
+ headers2.set(name, value);
30076
+ return fetchImpl(new Request(input, { headers: headers2 }), init);
30077
+ }
30078
+ const headers = new Headers(init?.headers);
30079
+ headers.set(name, value);
30080
+ return fetchImpl(input, { ...init || {}, headers });
30081
+ };
30082
+ }
30083
+
30084
+ // src/runtime/auth.ts
30085
+ var import_platform3 = require("#platform");
30041
30086
  var CamundaAuthError = class extends Error {
30042
30087
  constructor(code, message, cause) {
30043
30088
  super(`${code}: ${message}`);
@@ -30095,9 +30140,9 @@ var OAuthManager = class {
30095
30140
  } catch {
30096
30141
  }
30097
30142
  }
30098
- if (!this.session && this.cfg.oauth.cacheDir && import_platform2.node && this.isNode()) {
30143
+ if (!this.session && this.cfg.oauth.cacheDir && import_platform3.node && this.isNode()) {
30099
30144
  try {
30100
- const { fs, path } = import_platform2.node;
30145
+ const { fs, path } = import_platform3.node;
30101
30146
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
30102
30147
  if (fs.existsSync(file)) {
30103
30148
  const raw = fs.readFileSync(file, "utf8");
@@ -30114,9 +30159,9 @@ var OAuthManager = class {
30114
30159
  this.session.setItem(this.storageKey, JSON.stringify(this.token));
30115
30160
  } catch {
30116
30161
  }
30117
- } else if (this.cfg.oauth.cacheDir && import_platform2.node && this.isNode()) {
30162
+ } else if (this.cfg.oauth.cacheDir && import_platform3.node && this.isNode()) {
30118
30163
  try {
30119
- const { fs, path } = import_platform2.node;
30164
+ const { fs, path } = import_platform3.node;
30120
30165
  if (!fs.existsSync(this.cfg.oauth.cacheDir))
30121
30166
  fs.mkdirSync(this.cfg.oauth.cacheDir, { recursive: true });
30122
30167
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
@@ -30169,9 +30214,9 @@ var OAuthManager = class {
30169
30214
  if (opts.disk) {
30170
30215
  if (this.session) {
30171
30216
  this.session.removeItem(this.storageKey);
30172
- } else if (this.cfg.oauth.cacheDir && import_platform2.node && this.isNode()) {
30217
+ } else if (this.cfg.oauth.cacheDir && import_platform3.node && this.isNode()) {
30173
30218
  try {
30174
- const { fs, path } = import_platform2.node;
30219
+ const { fs, path } = import_platform3.node;
30175
30220
  const file = path.join(this.cfg.oauth.cacheDir, `${this.storageKey}.json`);
30176
30221
  if (fs.existsSync(file)) fs.unlinkSync(file);
30177
30222
  } catch {
@@ -30219,7 +30264,10 @@ var OAuthManager = class {
30219
30264
  this.logger.debug(`OAuth token attempt ${attempt + 1}/${max}`);
30220
30265
  const res = await fetcher(this.cfg.oauth.oauthUrl, {
30221
30266
  method: "POST",
30222
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
30267
+ headers: {
30268
+ "Content-Type": "application/x-www-form-urlencoded",
30269
+ ...userAgentHeaders(this.cfg.userAgent)
30270
+ },
30223
30271
  body: body.toString(),
30224
30272
  signal: controller.signal
30225
30273
  });
@@ -30377,9 +30425,9 @@ function createAuthFacade(config, opts) {
30377
30425
  else if (cfg.auth.strategy === "BASIC") basic = new BasicAuthManager(cfg);
30378
30426
  const fetcher = (input, init) => opts?.fetch ? opts.fetch(input, init) : fetch(input, init);
30379
30427
  let nodeAgent = null;
30380
- if (cfg.mtls && import_platform2.node && typeof process !== "undefined" && process.versions?.node) {
30428
+ if (cfg.mtls && import_platform3.node && typeof process !== "undefined" && process.versions?.node) {
30381
30429
  try {
30382
- const { fs, https } = import_platform2.node;
30430
+ const { fs, https } = import_platform3.node;
30383
30431
  const material = {};
30384
30432
  const pem = (inline, path) => inline || (path ? fs.readFileSync(path, "utf8") : inline);
30385
30433
  if (cfg.mtls.cert || cfg.mtls.certPath) material.cert = pem(cfg.mtls.cert, cfg.mtls.certPath);
@@ -30873,11 +30921,8 @@ async function executeWithHttpRetry(fn, policy, logger, classify = defaultHttpCl
30873
30921
  return exec(fn, classify);
30874
30922
  }
30875
30923
 
30876
- // src/runtime/version.ts
30877
- var packageVersion = "10.0.2";
30878
-
30879
30924
  // src/runtime/supportLogger.ts
30880
- var import_platform3 = require("#platform");
30925
+ var import_platform4 = require("#platform");
30881
30926
  var NoopSupportLogger = class {
30882
30927
  log(_message, _addTimestamp = true) {
30883
30928
  }
@@ -30926,9 +30971,9 @@ var CamundaSupportLogger = class {
30926
30971
  constructor(config) {
30927
30972
  const enabled = !!config.supportLog?.enabled;
30928
30973
  this.enabled = enabled;
30929
- this.filepath = config.supportLog?.filePath || (import_platform3.node && typeof process !== "undefined" ? import_platform3.node.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log");
30930
- if (!this.enabled || !isNode() || !import_platform3.node) return;
30931
- const { fs } = import_platform3.node;
30974
+ this.filepath = config.supportLog?.filePath || (import_platform4.node && typeof process !== "undefined" ? import_platform4.node.path.join(process.cwd(), "camunda-support.log") : "camunda-support.log");
30975
+ if (!this.enabled || !isNode() || !import_platform4.node) return;
30976
+ const { fs } = import_platform4.node;
30932
30977
  if (fs.existsSync(this.filepath)) {
30933
30978
  let n = 1;
30934
30979
  const base = this.filepath;
@@ -30945,8 +30990,8 @@ var CamundaSupportLogger = class {
30945
30990
  writeSupportLogPreamble(this, config);
30946
30991
  }
30947
30992
  log(message, addTimestamp = true) {
30948
- if (!this.enabled || !isNode() || !import_platform3.node) return;
30949
- const { fs } = import_platform3.node;
30993
+ if (!this.enabled || !isNode() || !import_platform4.node) return;
30994
+ const { fs } = import_platform4.node;
30950
30995
  const msg = typeof message === "object" ? safeStringify(message) : String(message);
30951
30996
  const line = addTimestamp ? `[${(/* @__PURE__ */ new Date()).toISOString()}]: ${msg}
30952
30997
  ` : `${msg}
@@ -30989,8 +31034,8 @@ function writeSupportLogPreamble(logger, config) {
30989
31034
  );
30990
31035
  logger.log(`Camunda SDK version: ${packageVersion}`, false);
30991
31036
  try {
30992
- if (!import_platform3.node) throw new Error("node:os unavailable");
30993
- const { os } = import_platform3.node;
31037
+ if (!import_platform4.node) throw new Error("node:os unavailable");
31038
+ const { os } = import_platform4.node;
30994
31039
  const osInfo = {
30995
31040
  platform: os.platform(),
30996
31041
  release: os.release(),
@@ -31584,7 +31629,7 @@ async function applySchemaValidation(opts) {
31584
31629
 
31585
31630
  // src/runtime/validationExtras.ts
31586
31631
  var import_zod247 = require("zod");
31587
- var import_platform4 = require("#platform");
31632
+ var import_platform5 = require("#platform");
31588
31633
  var seenCaptures = /* @__PURE__ */ new Set();
31589
31634
  function hash(str) {
31590
31635
  let h = 0, i = 0;
@@ -31629,8 +31674,8 @@ function detectExtrasAndMaybeThrow(opts) {
31629
31674
  }
31630
31675
  if (settings.captureDir) {
31631
31676
  try {
31632
- if (!import_platform4.node) throw new Error("node:fs unavailable");
31633
- const { fs, path: pathMod } = import_platform4.node;
31677
+ if (!import_platform5.node) throw new Error("node:fs unavailable");
31678
+ const { fs, path: pathMod } = import_platform5.node;
31634
31679
  if (!fs.existsSync(settings.captureDir))
31635
31680
  fs.mkdirSync(settings.captureDir, { recursive: true, mode: 448 });
31636
31681
  const sig = `${operationId}|${flatIssues.sort().join("|")}`;
@@ -31813,7 +31858,7 @@ var CamundaCore = class _CamundaCore {
31813
31858
  });
31814
31859
  const baseFetch = opts.fetch;
31815
31860
  this._baseFetch = baseFetch;
31816
- this._fetch = baseFetch;
31861
+ this._fetch = withUserAgent(baseFetch, () => this._config.userAgent);
31817
31862
  if (opts.telemetry) {
31818
31863
  this._fetch = wrapFetch(this._fetch || fetch, {
31819
31864
  hooks: opts.telemetry.hooks,
@@ -31925,11 +31970,12 @@ var CamundaCore = class _CamundaCore {
31925
31970
  }
31926
31971
  // Merge new overrides and re-hydrate.
31927
31972
  configure(next) {
31928
- if (next.config) this._setOverrides({ ...this._getOverrides(), ...next.config });
31929
- if (next.fetch) this._baseFetch = next.fetch;
31930
- this._fetch = this._baseFetch;
31931
- const { config } = hydrateConfig({ overrides: this._getOverrides(), env: next.env });
31973
+ const candidate = next.config ? { ...this._getOverrides(), ...next.config } : this._getOverrides();
31974
+ const { config } = hydrateConfig({ overrides: candidate, env: next.env });
31975
+ if (next.config) this._setOverrides(candidate);
31932
31976
  this._config = deepFreeze2(config);
31977
+ if (next.fetch) this._baseFetch = next.fetch;
31978
+ this._fetch = withUserAgent(this._baseFetch, () => this._config.userAgent);
31933
31979
  if (next.telemetry) {
31934
31980
  this._fetch = wrapFetch(this._fetch || fetch, {
31935
31981
  hooks: next.telemetry.hooks,