@camunda8/orchestration-cluster-api 10.0.0-alpha.41 → 10.0.0-alpha.43

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 '../CamundaClient-HroU9acH.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 '../CamundaClient-DwHGY8e9.cjs';
5
5
  import 'zod';
6
6
  import '../logger-D-p21VHo.cjs';
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 '../CamundaClient-BlKXG8gE.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 '../CamundaClient-Dxa-jdNc.js';
5
5
  import 'zod';
6
6
  import '../logger-D-p21VHo.js';
7
7
 
@@ -3,8 +3,8 @@ import {
3
3
  EventualConsistencyTimeoutError,
4
4
  createCamundaClient,
5
5
  nextPageRequest
6
- } from "../chunk-267HUCFY.js";
7
- import "../chunk-KQ4UL2WX.js";
6
+ } from "../chunk-JKBNNUPT.js";
7
+ import "../chunk-LXWPMQOS.js";
8
8
  import "../chunk-DGUM43GV.js";
9
9
 
10
10
  // src/effect.ts
package/dist/index.cjs CHANGED
@@ -9608,7 +9608,9 @@ __export(index_exports, {
9608
9608
  createCamundaClient: () => createCamundaClient,
9609
9609
  createCamundaClientLoose: () => createCamundaClientLoose,
9610
9610
  createCamundaResultClient: () => createCamundaResultClient,
9611
+ createEngineClock: () => createEngineClock,
9611
9612
  createLiveClock: () => createLiveClock,
9613
+ createTestClock: () => createTestClock,
9612
9614
  default: () => index_default,
9613
9615
  isErr: () => isErr,
9614
9616
  isOk: () => isOk,
@@ -12766,7 +12768,127 @@ function createLiveClock(source = () => Date.now()) {
12766
12768
  };
12767
12769
  return { now, sleep, deadline };
12768
12770
  }
12771
+ function nextTick(fn) {
12772
+ setTimeout(fn, 0);
12773
+ }
12774
+ function requireDuration(ms, label) {
12775
+ if (!Number.isFinite(ms) || ms < 0) {
12776
+ throw new RangeError(`${label} needs a finite, non-negative duration in ms, got ${ms}`);
12777
+ }
12778
+ }
12769
12779
  var liveClock = createLiveClock();
12780
+ function createTestClock(options = {}) {
12781
+ const { start = 0, autoAdvance = true } = options;
12782
+ let current = start;
12783
+ let nowCalls = 0;
12784
+ const sleeps = [];
12785
+ let waiters = [];
12786
+ const settleDue = () => {
12787
+ const due = waiters.filter((w) => w.at <= current);
12788
+ waiters = waiters.filter((w) => w.at > current);
12789
+ for (const w of due) {
12790
+ w.detach();
12791
+ w.resolve();
12792
+ }
12793
+ };
12794
+ const now = () => {
12795
+ nowCalls += 1;
12796
+ return current;
12797
+ };
12798
+ const sleep = (ms, signal) => new Promise((resolve, reject) => {
12799
+ requireDuration(ms, "clock.sleep");
12800
+ if (signal?.aborted) {
12801
+ reject(signal.reason);
12802
+ return;
12803
+ }
12804
+ sleeps.push(ms);
12805
+ const waiter = { at: current + ms, resolve, detach: () => {
12806
+ } };
12807
+ if (signal) {
12808
+ const onAbort = () => {
12809
+ waiters = waiters.filter((w) => w !== waiter);
12810
+ reject(signal.reason);
12811
+ };
12812
+ signal.addEventListener("abort", onAbort, { once: true });
12813
+ waiter.detach = () => signal.removeEventListener("abort", onAbort);
12814
+ }
12815
+ waiters.push(waiter);
12816
+ if (autoAdvance) {
12817
+ nextTick(() => {
12818
+ if (!waiters.includes(waiter)) return;
12819
+ current = Math.max(current, waiter.at);
12820
+ settleDue();
12821
+ });
12822
+ }
12823
+ });
12824
+ const advance = async (ms) => {
12825
+ requireDuration(ms, "clock.advance");
12826
+ current += ms;
12827
+ settleDue();
12828
+ await new Promise((resolve) => nextTick(resolve));
12829
+ };
12830
+ return {
12831
+ now,
12832
+ sleep,
12833
+ advance,
12834
+ // A deadline bounds liveness rather than pacing cadence: it stays on real time even
12835
+ // here, because code guarded by one should time out rather than hang on a pinned clock.
12836
+ deadline: (ms) => liveClock.deadline(ms),
12837
+ get sleeps() {
12838
+ return sleeps;
12839
+ },
12840
+ get nowCalls() {
12841
+ return nowCalls;
12842
+ },
12843
+ get pending() {
12844
+ return waiters.length;
12845
+ }
12846
+ };
12847
+ }
12848
+ function createEngineClock(target, options = {}) {
12849
+ const { start = Date.now() } = options;
12850
+ let current = start;
12851
+ const sleeps = [];
12852
+ let queue = Promise.resolve();
12853
+ const enqueue = (fn) => {
12854
+ const run = queue.then(fn, fn);
12855
+ queue = run.catch(() => {
12856
+ });
12857
+ return run;
12858
+ };
12859
+ const pinTo = (epochMs) => enqueue(async () => {
12860
+ if (epochMs <= current) return;
12861
+ await target.pinClock({ timestamp: epochMs });
12862
+ current = epochMs;
12863
+ });
12864
+ const sleep = async (ms, signal) => {
12865
+ requireDuration(ms, "clock.sleep");
12866
+ if (signal?.aborted) throw signal.reason;
12867
+ sleeps.push(ms);
12868
+ await pinTo(current + ms);
12869
+ await new Promise((resolve) => nextTick(resolve));
12870
+ if (signal?.aborted) throw signal.reason;
12871
+ };
12872
+ return {
12873
+ now: () => current,
12874
+ sleep,
12875
+ async pin(epochMs) {
12876
+ if (!Number.isFinite(epochMs)) {
12877
+ throw new RangeError(`clock.pin needs a finite epoch-ms instant, got ${epochMs}`);
12878
+ }
12879
+ await pinTo(epochMs);
12880
+ },
12881
+ async reset() {
12882
+ await target.resetClock();
12883
+ },
12884
+ // A deadline bounds liveness, so it stays on real time: a request timeout must fire even
12885
+ // though engine time only moves when something asks it to.
12886
+ deadline: (ms) => liveClock.deadline(ms),
12887
+ get sleeps() {
12888
+ return sleeps;
12889
+ }
12890
+ };
12891
+ }
12770
12892
 
12771
12893
  // src/runtime/auth.ts
12772
12894
  var CamundaAuthError = class extends Error {
@@ -12936,6 +13058,7 @@ var OAuthManager = class {
12936
13058
  if (attempt === 0) {
12937
13059
  const evt = {
12938
13060
  type: "auth.start",
13061
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
12939
13062
  ts: Date.now(),
12940
13063
  audience: this.cfg.tokenAudience,
12941
13064
  endpoint: this.cfg.oauth.oauthUrl,
@@ -12987,6 +13110,7 @@ var OAuthManager = class {
12987
13110
  try {
12988
13111
  const evt = {
12989
13112
  type: "auth.success",
13113
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
12990
13114
  ts: Date.now(),
12991
13115
  audience: this.cfg.tokenAudience,
12992
13116
  endpoint: this.cfg.oauth.oauthUrl,
@@ -13011,6 +13135,7 @@ var OAuthManager = class {
13011
13135
  try {
13012
13136
  this.tHooks?.retry?.({
13013
13137
  type: "retry",
13138
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
13014
13139
  ts: Date.now(),
13015
13140
  attempt,
13016
13141
  nextDelayMs: Math.round(sleep),
@@ -13026,6 +13151,7 @@ var OAuthManager = class {
13026
13151
  try {
13027
13152
  const evt = {
13028
13153
  type: "auth.error",
13154
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
13029
13155
  ts: Date.now(),
13030
13156
  audience: this.cfg.tokenAudience,
13031
13157
  endpoint: this.cfg.oauth.oauthUrl,
@@ -14319,7 +14445,7 @@ function createLogger(opts = {}) {
14319
14445
  }
14320
14446
 
14321
14447
  // src/runtime/version.ts
14322
- var packageVersion = "10.0.0-alpha.41";
14448
+ var packageVersion = "10.0.0-alpha.43";
14323
14449
 
14324
14450
  // src/runtime/supportLogger.ts
14325
14451
  var NoopSupportLogger = class {
@@ -14965,6 +15091,7 @@ function detectExtrasAndMaybeThrow(opts) {
14965
15091
  const payload = {
14966
15092
  operationId,
14967
15093
  extras,
15094
+ // biome-ignore lint/plugin: capture-artifact timestamp: records when the capture was written, not cadence
14968
15095
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
14969
15096
  sample: value
14970
15097
  };
@@ -15136,8 +15263,8 @@ var BackpressureManager = class {
15136
15263
  // current backoff delay in ms (0 = no backoff)
15137
15264
  constructor(opts = {}) {
15138
15265
  this.logger = opts.logger;
15139
- this.now = opts.now || (() => Date.now());
15140
- this.sleep = opts.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
15266
+ this.now = opts.now || (() => liveClock.now());
15267
+ this.sleep = opts.sleep || ((ms) => liveClock.sleep(ms));
15141
15268
  this.cfg = {
15142
15269
  enabled: true,
15143
15270
  initialMaxConcurrency: null,
@@ -32516,7 +32643,9 @@ var index_default = createCamundaClient;
32516
32643
  createCamundaClient,
32517
32644
  createCamundaClientLoose,
32518
32645
  createCamundaResultClient,
32646
+ createEngineClock,
32519
32647
  createLiveClock,
32648
+ createTestClock,
32520
32649
  isErr,
32521
32650
  isOk,
32522
32651
  isSdkError,