@camunda8/orchestration-cluster-api 10.0.0-alpha.33 → 10.0.0-alpha.35

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.
@@ -656,6 +656,85 @@ var JobWorker = class {
656
656
  }
657
657
  };
658
658
 
659
+ // src/runtime/pagination.ts
660
+ function abortError() {
661
+ const e = new Error("Pagination aborted");
662
+ e.name = "AbortError";
663
+ return e;
664
+ }
665
+ function limitOf(body) {
666
+ const l = body.page?.limit;
667
+ return typeof l === "number" ? l : void 0;
668
+ }
669
+ function advancePage(prev, advance) {
670
+ const rest = { ...prev ?? {} };
671
+ delete rest.after;
672
+ delete rest.from;
673
+ delete rest.before;
674
+ return { ...rest, ...advance };
675
+ }
676
+ function nextPageRequest(body, response, mode = "auto") {
677
+ const limit = limitOf(body);
678
+ const count = response.items.length;
679
+ if (count === 0) return null;
680
+ if (limit !== void 0 && count < limit) return null;
681
+ const endCursor = response.page?.endCursor ?? null;
682
+ const hasCursor = body.page?.after !== void 0 || body.page?.before !== void 0;
683
+ const hasFrom = typeof body.page?.from === "number";
684
+ let useCursor;
685
+ if (mode === "cursor") useCursor = true;
686
+ else if (mode === "offset") useCursor = false;
687
+ else if (hasCursor && !hasFrom) useCursor = true;
688
+ else if (hasFrom && !hasCursor) useCursor = false;
689
+ else useCursor = endCursor !== null;
690
+ if (useCursor) {
691
+ if (endCursor === null) return null;
692
+ if (body.page?.after === endCursor) return null;
693
+ return {
694
+ ...body,
695
+ page: advancePage(body.page, { after: endCursor })
696
+ };
697
+ }
698
+ const prevFrom = typeof body.page?.from === "number" ? body.page.from : 0;
699
+ return {
700
+ ...body,
701
+ page: advancePage(body.page, { from: prevFrom + count })
702
+ };
703
+ }
704
+ function paginate(fetchPage, body, opts = {}) {
705
+ const { signal, maxPages = Number.POSITIVE_INFINITY, mode = "auto" } = opts;
706
+ async function* pages() {
707
+ let current = body;
708
+ let fetched = 0;
709
+ while (true) {
710
+ if (fetched >= maxPages) return;
711
+ if (signal?.aborted) throw abortError();
712
+ const response = await fetchPage(current, signal, fetched === 0);
713
+ const next = nextPageRequest(current, response, mode);
714
+ yield response;
715
+ fetched += 1;
716
+ if (next === null) return;
717
+ current = next;
718
+ }
719
+ }
720
+ async function* items() {
721
+ for await (const page of pages()) {
722
+ yield* page.items;
723
+ }
724
+ }
725
+ async function toArray() {
726
+ const out = [];
727
+ for await (const item of items()) out.push(item);
728
+ return out;
729
+ }
730
+ return {
731
+ pages,
732
+ items,
733
+ toArray,
734
+ [Symbol.asyncIterator]: pages
735
+ };
736
+ }
737
+
659
738
  // src/gen/core/serverSentEvents.gen.ts
660
739
  var __STANDARD_REQUEST_INIT_KEYS = [
661
740
  "method",
@@ -3542,6 +3621,31 @@ var changeClusterModeAsClusterAdmin = (options) => (options.client ?? client).pa
3542
3621
  url: "/cluster/v2/mode",
3543
3622
  ...options
3544
3623
  });
3624
+ var cancelClusterRebalance = (options) => (options?.client ?? client).delete({
3625
+ requestValidator: void 0,
3626
+ responseValidator: void 0,
3627
+ security: [{ scheme: "bearer", type: "http" }, { scheme: "basic", type: "http" }],
3628
+ url: "/cluster/v2/rebalance",
3629
+ ...options
3630
+ });
3631
+ var getClusterRebalance = (options) => (options?.client ?? client).get({
3632
+ requestValidator: void 0,
3633
+ responseValidator: void 0,
3634
+ security: [{ scheme: "bearer", type: "http" }, { scheme: "basic", type: "http" }],
3635
+ url: "/cluster/v2/rebalance",
3636
+ ...options
3637
+ });
3638
+ var triggerClusterRebalance = (options) => (options?.client ?? client).post({
3639
+ requestValidator: void 0,
3640
+ responseValidator: void 0,
3641
+ security: [{ scheme: "bearer", type: "http" }, { scheme: "basic", type: "http" }],
3642
+ url: "/cluster/v2/rebalance",
3643
+ ...options,
3644
+ headers: {
3645
+ "Content-Type": "application/json",
3646
+ ...options?.headers
3647
+ }
3648
+ });
3545
3649
  var restoreAsClusterAdmin = (options) => (options.client ?? client).post({
3546
3650
  requestValidator: void 0,
3547
3651
  responseValidator: void 0,
@@ -5080,7 +5184,7 @@ function installAuthInterceptor(client2, getStrategy, getAuthHeaders) {
5080
5184
  }
5081
5185
 
5082
5186
  // src/runtime/version.ts
5083
- var packageVersion = "10.0.0-alpha.33";
5187
+ var packageVersion = "10.0.0-alpha.35";
5084
5188
 
5085
5189
  // src/runtime/supportLogger.ts
5086
5190
  var NoopSupportLogger = class {
@@ -6785,6 +6889,70 @@ function evaluateSdkResponse(raw, opts) {
6785
6889
  return raw.data !== void 0 ? raw.data : raw;
6786
6890
  }
6787
6891
 
6892
+ // src/runtime/searchPagination.ts
6893
+ var NON_PAGINATED_SEARCH_METHODS = /* @__PURE__ */ new Set(["searchVariablesAsDto"]);
6894
+ function mergeAbortSignals(outer, inner) {
6895
+ if (!inner) return outer;
6896
+ const anyFn = AbortSignal.any;
6897
+ if (typeof anyFn === "function") return anyFn([outer, inner]);
6898
+ const ac = new AbortController();
6899
+ if (outer.aborted || inner.aborted) {
6900
+ ac.abort();
6901
+ return ac.signal;
6902
+ }
6903
+ const onAbort = () => ac.abort();
6904
+ outer.addEventListener("abort", onAbort, { once: true });
6905
+ inner.addEventListener("abort", onAbort, { once: true });
6906
+ return ac.signal;
6907
+ }
6908
+ function installSearchPagination(client2) {
6909
+ const seen = /* @__PURE__ */ new Set();
6910
+ let proto = Object.getPrototypeOf(client2);
6911
+ while (proto && proto !== Object.prototype) {
6912
+ for (const name of Object.getOwnPropertyNames(proto)) {
6913
+ if (seen.has(name)) continue;
6914
+ if (!/^search[A-Z]/.test(name)) continue;
6915
+ if (NON_PAGINATED_SEARCH_METHODS.has(name)) continue;
6916
+ const method = proto[name];
6917
+ if (typeof method !== "function") continue;
6918
+ seen.add(name);
6919
+ const call = method.bind(client2);
6920
+ const wrapper = ((...args) => call(...args));
6921
+ wrapper.paginate = (body, opts = {}) => {
6922
+ const { consistency, ...pageOpts } = opts;
6923
+ const fetchPage = (b, signal, isFirstPage = false) => {
6924
+ const baseConsistency = isFirstPage ? consistency ?? { waitUpToMs: 0 } : { waitUpToMs: 0 };
6925
+ const consistencyValue = signal ? {
6926
+ ...baseConsistency,
6927
+ abortSignal: mergeAbortSignals(
6928
+ signal,
6929
+ baseConsistency.abortSignal
6930
+ )
6931
+ } : baseConsistency;
6932
+ const consistencyArg = { consistency: consistencyValue };
6933
+ const p = call(b, consistencyArg);
6934
+ if (signal) {
6935
+ const onAbort = () => p.cancel?.();
6936
+ signal.addEventListener("abort", onAbort, { once: true });
6937
+ const cleanup = () => signal.removeEventListener("abort", onAbort);
6938
+ p.then(cleanup, cleanup);
6939
+ if (signal.aborted) p.cancel?.();
6940
+ }
6941
+ return p;
6942
+ };
6943
+ return paginate(fetchPage, body, pageOpts);
6944
+ };
6945
+ Object.defineProperty(client2, name, {
6946
+ value: wrapper,
6947
+ writable: true,
6948
+ enumerable: false,
6949
+ configurable: true
6950
+ });
6951
+ }
6952
+ proto = Object.getPrototypeOf(proto);
6953
+ }
6954
+ }
6955
+
6788
6956
  // src/gen/CamundaClient.ts
6789
6957
  function deepFreeze2(obj) {
6790
6958
  if (obj && typeof obj === "object" && !Object.isFrozen(obj)) {
@@ -6835,7 +7003,7 @@ function toCancelable2(factory) {
6835
7003
  function createCamundaClient(options) {
6836
7004
  return new CamundaClient(options);
6837
7005
  }
6838
- var CamundaClient = class {
7006
+ var CamundaClientBase = class {
6839
7007
  _client;
6840
7008
  _config;
6841
7009
  _auth = createAuthFacade({
@@ -6962,6 +7130,7 @@ var CamundaClient = class {
6962
7130
  return ["config.hydrated"];
6963
7131
  }
6964
7132
  });
7133
+ installSearchPagination(this);
6965
7134
  }
6966
7135
  get config() {
6967
7136
  return this._config;
@@ -7099,7 +7268,7 @@ var CamundaClient = class {
7099
7268
  _schemasPromise = null;
7100
7269
  _loadSchemas() {
7101
7270
  if (!this._schemasPromise) {
7102
- this._schemasPromise = import("./zod.gen-GHFW5D76.js");
7271
+ this._schemasPromise = import("./zod.gen-JARMY5IR.js");
7103
7272
  }
7104
7273
  return this._schemasPromise;
7105
7274
  }
@@ -8184,6 +8353,49 @@ var CamundaClient = class {
8184
8353
  return this._invokeWithRetry(() => call(), { opId: "cancelBatchOperation", exempt: false, retryOverride: options?.retry });
8185
8354
  });
8186
8355
  }
8356
+ cancelClusterRebalance(arg, options) {
8357
+ return toCancelable2(async (signal) => {
8358
+ const opts = { client: this._client, signal, throwOnError: false };
8359
+ const call = async () => {
8360
+ try {
8361
+ const _raw = await cancelClusterRebalance(opts);
8362
+ let data = this._evaluateResponse(_raw, "cancelClusterRebalance", (resp) => {
8363
+ const st = resp.status ?? resp.response?.status;
8364
+ if (!st) return void 0;
8365
+ const candidate = st === 429 || st === 503 || st === 500;
8366
+ if (!candidate) return void 0;
8367
+ let prob = void 0;
8368
+ if (resp.error && typeof resp.error === "object") prob = resp.error;
8369
+ const err = new Error(prob && (prob.title || prob.detail) ? prob.title || prob.detail : "HTTP " + st);
8370
+ err.status = st;
8371
+ err.name = "HttpSdkError";
8372
+ if (prob) {
8373
+ for (const k of ["type", "title", "detail", "instance"]) if (prob[k] !== void 0) err[k] = prob[k];
8374
+ }
8375
+ const isBp = st === 429 || st === 503 && err.title === "RESOURCE_EXHAUSTED" || st === 500 && (typeof err.detail === "string" && /RESOURCE_EXHAUSTED/.test(err.detail));
8376
+ if (!isBp) err.nonRetryable = true;
8377
+ return err;
8378
+ });
8379
+ const _respSchemaName = "zCancelClusterRebalanceResponse";
8380
+ if (this._isVoidResponse(_respSchemaName)) {
8381
+ data = void 0;
8382
+ }
8383
+ if (this._validation.settings.res !== "none") {
8384
+ const _schemas = await this._loadSchemas();
8385
+ const _schema = _schemas.zCancelClusterRebalanceResponse;
8386
+ if (_schema) {
8387
+ const maybeR = await this._validation.gateResponse("cancelClusterRebalance", _schema, data);
8388
+ if (this._validation.settings.res === "strict") data = maybeR;
8389
+ }
8390
+ }
8391
+ return data;
8392
+ } catch (e) {
8393
+ throw e;
8394
+ }
8395
+ };
8396
+ return this._invokeWithRetry(() => call(), { opId: "cancelClusterRebalance", exempt: false, retryOverride: options?.retry });
8397
+ });
8398
+ }
8187
8399
  cancelProcessInstance(arg, options) {
8188
8400
  return toCancelable2(async (signal) => {
8189
8401
  const { processInstanceKey, ..._body } = arg || {};
@@ -11389,6 +11601,49 @@ var CamundaClient = class {
11389
11601
  return this._invokeWithRetry(() => call(), { opId: "getClusterExportingStatus", exempt: false, retryOverride: options?.retry });
11390
11602
  });
11391
11603
  }
11604
+ getClusterRebalance(arg, options) {
11605
+ return toCancelable2(async (signal) => {
11606
+ const opts = { client: this._client, signal, throwOnError: false };
11607
+ const call = async () => {
11608
+ try {
11609
+ const _raw = await getClusterRebalance(opts);
11610
+ let data = this._evaluateResponse(_raw, "getClusterRebalance", (resp) => {
11611
+ const st = resp.status ?? resp.response?.status;
11612
+ if (!st) return void 0;
11613
+ const candidate = st === 429 || st === 503 || st === 500;
11614
+ if (!candidate) return void 0;
11615
+ let prob = void 0;
11616
+ if (resp.error && typeof resp.error === "object") prob = resp.error;
11617
+ const err = new Error(prob && (prob.title || prob.detail) ? prob.title || prob.detail : "HTTP " + st);
11618
+ err.status = st;
11619
+ err.name = "HttpSdkError";
11620
+ if (prob) {
11621
+ for (const k of ["type", "title", "detail", "instance"]) if (prob[k] !== void 0) err[k] = prob[k];
11622
+ }
11623
+ const isBp = st === 429 || st === 503 && err.title === "RESOURCE_EXHAUSTED" || st === 500 && (typeof err.detail === "string" && /RESOURCE_EXHAUSTED/.test(err.detail));
11624
+ if (!isBp) err.nonRetryable = true;
11625
+ return err;
11626
+ });
11627
+ const _respSchemaName = "zGetClusterRebalanceResponse";
11628
+ if (this._isVoidResponse(_respSchemaName)) {
11629
+ data = void 0;
11630
+ }
11631
+ if (this._validation.settings.res !== "none") {
11632
+ const _schemas = await this._loadSchemas();
11633
+ const _schema = _schemas.zGetClusterRebalanceResponse;
11634
+ if (_schema) {
11635
+ const maybeR = await this._validation.gateResponse("getClusterRebalance", _schema, data);
11636
+ if (this._validation.settings.res === "strict") data = maybeR;
11637
+ }
11638
+ }
11639
+ return data;
11640
+ } catch (e) {
11641
+ throw e;
11642
+ }
11643
+ };
11644
+ return this._invokeWithRetry(() => call(), { opId: "getClusterRebalance", exempt: false, retryOverride: options?.retry });
11645
+ });
11646
+ }
11392
11647
  getClusterStatus(arg, options) {
11393
11648
  return toCancelable2(async (signal) => {
11394
11649
  const opts = { client: this._client, signal, throwOnError: false };
@@ -19410,6 +19665,66 @@ var CamundaClient = class {
19410
19665
  return this._invokeWithRetry(() => call(), { opId: "throwJobError", exempt: true, retryOverride: options?.retry });
19411
19666
  });
19412
19667
  }
19668
+ triggerClusterRebalance(arg, options) {
19669
+ return toCancelable2(async (signal) => {
19670
+ const { dryRun, ..._body } = arg || {};
19671
+ let envelope = {};
19672
+ envelope.query = { dryRun };
19673
+ envelope.body = _body;
19674
+ if (this._validation.settings.req !== "none") {
19675
+ const _schemas = await this._loadSchemas();
19676
+ if (envelope.body !== void 0) {
19677
+ const maybeBody = await this._validation.gateRequest("triggerClusterRebalance", _schemas.zTriggerClusterRebalanceBody, envelope.body);
19678
+ if (this._validation.settings.req === "strict") envelope.body = maybeBody;
19679
+ }
19680
+ if (envelope.query !== void 0) {
19681
+ const maybeQuery = await this._validation.gateRequest("triggerClusterRebalance", _schemas.zTriggerClusterRebalanceQuery, envelope.query);
19682
+ if (this._validation.settings.req === "strict") envelope.query = maybeQuery;
19683
+ }
19684
+ }
19685
+ const opts = { client: this._client, signal, throwOnError: false };
19686
+ if (envelope.query) opts.query = envelope.query;
19687
+ if (envelope.body !== void 0) opts.body = envelope.body;
19688
+ const call = async () => {
19689
+ try {
19690
+ const _raw = await triggerClusterRebalance(opts);
19691
+ let data = this._evaluateResponse(_raw, "triggerClusterRebalance", (resp) => {
19692
+ const st = resp.status ?? resp.response?.status;
19693
+ if (!st) return void 0;
19694
+ const candidate = st === 429 || st === 503 || st === 500;
19695
+ if (!candidate) return void 0;
19696
+ let prob = void 0;
19697
+ if (resp.error && typeof resp.error === "object") prob = resp.error;
19698
+ const err = new Error(prob && (prob.title || prob.detail) ? prob.title || prob.detail : "HTTP " + st);
19699
+ err.status = st;
19700
+ err.name = "HttpSdkError";
19701
+ if (prob) {
19702
+ for (const k of ["type", "title", "detail", "instance"]) if (prob[k] !== void 0) err[k] = prob[k];
19703
+ }
19704
+ const isBp = st === 429 || st === 503 && err.title === "RESOURCE_EXHAUSTED" || st === 500 && (typeof err.detail === "string" && /RESOURCE_EXHAUSTED/.test(err.detail));
19705
+ if (!isBp) err.nonRetryable = true;
19706
+ return err;
19707
+ });
19708
+ const _respSchemaName = "zTriggerClusterRebalanceResponse";
19709
+ if (this._isVoidResponse(_respSchemaName)) {
19710
+ data = void 0;
19711
+ }
19712
+ if (this._validation.settings.res !== "none") {
19713
+ const _schemas = await this._loadSchemas();
19714
+ const _schema = _schemas.zTriggerClusterRebalanceResponse;
19715
+ if (_schema) {
19716
+ const maybeR = await this._validation.gateResponse("triggerClusterRebalance", _schema, data);
19717
+ if (this._validation.settings.res === "strict") data = maybeR;
19718
+ }
19719
+ }
19720
+ return data;
19721
+ } catch (e) {
19722
+ throw e;
19723
+ }
19724
+ };
19725
+ return this._invokeWithRetry(() => call(), { opId: "triggerClusterRebalance", exempt: false, retryOverride: options?.retry });
19726
+ });
19727
+ }
19413
19728
  unassignClientFromGroup(arg, options) {
19414
19729
  return toCancelable2(async (signal) => {
19415
19730
  const { groupId, clientId } = arg || {};
@@ -21111,6 +21426,7 @@ var CamundaClient = class {
21111
21426
  });
21112
21427
  }
21113
21428
  };
21429
+ var CamundaClient = CamundaClientBase;
21114
21430
 
21115
21431
  export {
21116
21432
  isSdkError,
@@ -21124,8 +21440,10 @@ export {
21124
21440
  VariableCollector,
21125
21441
  collectTypedVariables,
21126
21442
  JobActionReceipt,
21443
+ nextPageRequest,
21444
+ paginate,
21127
21445
  CancelError,
21128
21446
  createCamundaClient,
21129
21447
  CamundaClient
21130
21448
  };
21131
- //# sourceMappingURL=chunk-AH6BQSBI.js.map
21449
+ //# sourceMappingURL=chunk-2SYK2XZI.js.map