@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,6 +1,6 @@
1
1
  import {
2
2
  createLogger
3
- } from "./chunk-KQ4UL2WX.js";
3
+ } from "./chunk-LXWPMQOS.js";
4
4
  import {
5
5
  __require
6
6
  } from "./chunk-DGUM43GV.js";
@@ -63,7 +63,127 @@ function createLiveClock(source = () => Date.now()) {
63
63
  };
64
64
  return { now, sleep, deadline };
65
65
  }
66
+ function nextTick(fn) {
67
+ setTimeout(fn, 0);
68
+ }
69
+ function requireDuration(ms, label) {
70
+ if (!Number.isFinite(ms) || ms < 0) {
71
+ throw new RangeError(`${label} needs a finite, non-negative duration in ms, got ${ms}`);
72
+ }
73
+ }
66
74
  var liveClock = createLiveClock();
75
+ function createTestClock(options = {}) {
76
+ const { start = 0, autoAdvance = true } = options;
77
+ let current = start;
78
+ let nowCalls = 0;
79
+ const sleeps = [];
80
+ let waiters = [];
81
+ const settleDue = () => {
82
+ const due = waiters.filter((w) => w.at <= current);
83
+ waiters = waiters.filter((w) => w.at > current);
84
+ for (const w of due) {
85
+ w.detach();
86
+ w.resolve();
87
+ }
88
+ };
89
+ const now = () => {
90
+ nowCalls += 1;
91
+ return current;
92
+ };
93
+ const sleep = (ms, signal) => new Promise((resolve, reject) => {
94
+ requireDuration(ms, "clock.sleep");
95
+ if (signal?.aborted) {
96
+ reject(signal.reason);
97
+ return;
98
+ }
99
+ sleeps.push(ms);
100
+ const waiter = { at: current + ms, resolve, detach: () => {
101
+ } };
102
+ if (signal) {
103
+ const onAbort = () => {
104
+ waiters = waiters.filter((w) => w !== waiter);
105
+ reject(signal.reason);
106
+ };
107
+ signal.addEventListener("abort", onAbort, { once: true });
108
+ waiter.detach = () => signal.removeEventListener("abort", onAbort);
109
+ }
110
+ waiters.push(waiter);
111
+ if (autoAdvance) {
112
+ nextTick(() => {
113
+ if (!waiters.includes(waiter)) return;
114
+ current = Math.max(current, waiter.at);
115
+ settleDue();
116
+ });
117
+ }
118
+ });
119
+ const advance = async (ms) => {
120
+ requireDuration(ms, "clock.advance");
121
+ current += ms;
122
+ settleDue();
123
+ await new Promise((resolve) => nextTick(resolve));
124
+ };
125
+ return {
126
+ now,
127
+ sleep,
128
+ advance,
129
+ // A deadline bounds liveness rather than pacing cadence: it stays on real time even
130
+ // here, because code guarded by one should time out rather than hang on a pinned clock.
131
+ deadline: (ms) => liveClock.deadline(ms),
132
+ get sleeps() {
133
+ return sleeps;
134
+ },
135
+ get nowCalls() {
136
+ return nowCalls;
137
+ },
138
+ get pending() {
139
+ return waiters.length;
140
+ }
141
+ };
142
+ }
143
+ function createEngineClock(target, options = {}) {
144
+ const { start = Date.now() } = options;
145
+ let current = start;
146
+ const sleeps = [];
147
+ let queue = Promise.resolve();
148
+ const enqueue = (fn) => {
149
+ const run = queue.then(fn, fn);
150
+ queue = run.catch(() => {
151
+ });
152
+ return run;
153
+ };
154
+ const pinTo = (epochMs) => enqueue(async () => {
155
+ if (epochMs <= current) return;
156
+ await target.pinClock({ timestamp: epochMs });
157
+ current = epochMs;
158
+ });
159
+ const sleep = async (ms, signal) => {
160
+ requireDuration(ms, "clock.sleep");
161
+ if (signal?.aborted) throw signal.reason;
162
+ sleeps.push(ms);
163
+ await pinTo(current + ms);
164
+ await new Promise((resolve) => nextTick(resolve));
165
+ if (signal?.aborted) throw signal.reason;
166
+ };
167
+ return {
168
+ now: () => current,
169
+ sleep,
170
+ async pin(epochMs) {
171
+ if (!Number.isFinite(epochMs)) {
172
+ throw new RangeError(`clock.pin needs a finite epoch-ms instant, got ${epochMs}`);
173
+ }
174
+ await pinTo(epochMs);
175
+ },
176
+ async reset() {
177
+ await target.resetClock();
178
+ },
179
+ // A deadline bounds liveness, so it stays on real time: a request timeout must fire even
180
+ // though engine time only moves when something asks it to.
181
+ deadline: (ms) => liveClock.deadline(ms),
182
+ get sleeps() {
183
+ return sleeps;
184
+ }
185
+ };
186
+ }
67
187
 
68
188
  // src/runtime/errors.ts
69
189
  function isSdkError(e) {
@@ -4081,6 +4201,7 @@ var OAuthManager = class {
4081
4201
  if (attempt === 0) {
4082
4202
  const evt = {
4083
4203
  type: "auth.start",
4204
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4084
4205
  ts: Date.now(),
4085
4206
  audience: this.cfg.tokenAudience,
4086
4207
  endpoint: this.cfg.oauth.oauthUrl,
@@ -4132,6 +4253,7 @@ var OAuthManager = class {
4132
4253
  try {
4133
4254
  const evt = {
4134
4255
  type: "auth.success",
4256
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4135
4257
  ts: Date.now(),
4136
4258
  audience: this.cfg.tokenAudience,
4137
4259
  endpoint: this.cfg.oauth.oauthUrl,
@@ -4156,6 +4278,7 @@ var OAuthManager = class {
4156
4278
  try {
4157
4279
  this.tHooks?.retry?.({
4158
4280
  type: "retry",
4281
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4159
4282
  ts: Date.now(),
4160
4283
  attempt,
4161
4284
  nextDelayMs: Math.round(sleep),
@@ -4171,6 +4294,7 @@ var OAuthManager = class {
4171
4294
  try {
4172
4295
  const evt = {
4173
4296
  type: "auth.error",
4297
+ // biome-ignore lint/plugin: telemetry event timestamp: must be real wall-clock so emitted events correlate with external logs, and never drives cadence
4174
4298
  ts: Date.now(),
4175
4299
  audience: this.cfg.tokenAudience,
4176
4300
  endpoint: this.cfg.oauth.oauthUrl,
@@ -5285,7 +5409,7 @@ function installAuthInterceptor(client2, getStrategy, getAuthHeaders) {
5285
5409
  }
5286
5410
 
5287
5411
  // src/runtime/version.ts
5288
- var packageVersion = "10.0.0-alpha.41";
5412
+ var packageVersion = "10.0.0-alpha.43";
5289
5413
 
5290
5414
  // src/runtime/supportLogger.ts
5291
5415
  var NoopSupportLogger = class {
@@ -5933,6 +6057,7 @@ function detectExtrasAndMaybeThrow(opts) {
5933
6057
  const payload = {
5934
6058
  operationId,
5935
6059
  extras,
6060
+ // biome-ignore lint/plugin: capture-artifact timestamp: records when the capture was written, not cadence
5936
6061
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
5937
6062
  sample: value
5938
6063
  };
@@ -6104,8 +6229,8 @@ var BackpressureManager = class {
6104
6229
  // current backoff delay in ms (0 = no backoff)
6105
6230
  constructor(opts = {}) {
6106
6231
  this.logger = opts.logger;
6107
- this.now = opts.now || (() => Date.now());
6108
- this.sleep = opts.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
6232
+ this.now = opts.now || (() => liveClock.now());
6233
+ this.sleep = opts.sleep || ((ms) => liveClock.sleep(ms));
6109
6234
  this.cfg = {
6110
6235
  enabled: true,
6111
6236
  initialMaxConcurrency: null,
@@ -21471,6 +21596,8 @@ var CamundaClient = CamundaClientBase;
21471
21596
  export {
21472
21597
  createLiveClock,
21473
21598
  liveClock,
21599
+ createTestClock,
21600
+ createEngineClock,
21474
21601
  isSdkError,
21475
21602
  CamundaValidationError,
21476
21603
  EventualConsistencyTimeoutError,
@@ -21488,4 +21615,4 @@ export {
21488
21615
  createCamundaClient,
21489
21616
  CamundaClient
21490
21617
  };
21491
- //# sourceMappingURL=chunk-267HUCFY.js.map
21618
+ //# sourceMappingURL=chunk-JKBNNUPT.js.map