@sjawhar/pi-legion-envoy 5.30.1 → 5.30.3

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.
package/dist/envoy.js CHANGED
@@ -32406,6 +32406,27 @@ function requestSignal(signal) {
32406
32406
  const deadline = AbortSignal.timeout(DISPATCH_TOOL_DEADLINE_MS);
32407
32407
  return signal === undefined ? deadline : AbortSignal.any([signal, deadline]);
32408
32408
  }
32409
+ function whyNotAPage(answer) {
32410
+ if (typeof answer === "string") {
32411
+ return "text that is not a JSON page, which looks like a proxy or gateway page rather than " + "Dispatch's own answer, so a retry may succeed.";
32412
+ }
32413
+ let what;
32414
+ if (Array.isArray(answer)) {
32415
+ what = `a bare array of ${answer.length} entries, the unpaged listing, which means that Dispatch ` + "is older than sjawhar/legion#1612 or that change has regressed";
32416
+ } else if (answer === null || typeof answer !== "object") {
32417
+ what = answer === null ? "null" : `a ${typeof answer}`;
32418
+ } else {
32419
+ const fields = answer;
32420
+ const lacking = [
32421
+ ...Array.isArray(fields.issues) ? [] : ["an issues array"],
32422
+ ...["total", "limit", "offset"].filter((name) => typeof fields[name] !== "number").map((name) => `a numeric ${name}`)
32423
+ ];
32424
+ if (lacking.length === 0)
32425
+ return;
32426
+ what = `an object without ${lacking.join(" or ")}`;
32427
+ }
32428
+ return `${what}. Retrying will not help: the same request gets the same answer until that ` + "Dispatch is upgraded or fixed.";
32429
+ }
32409
32430
 
32410
32431
  class DispatchClient {
32411
32432
  token;
@@ -32426,25 +32447,13 @@ class DispatchClient {
32426
32447
  return this.#resolveIssue(issueReference);
32427
32448
  }
32428
32449
  async listIssuePage(options, page) {
32429
- const answer = await this.#json("GET", ["api", "v1", "issues"], undefined, {
32430
- ...options,
32431
- limit: page.limit,
32432
- offset: page.offset
32433
- });
32434
- if (Array.isArray(answer)) {
32435
- const issues = answer;
32436
- return {
32437
- issues: issues.slice(page.offset, page.offset + page.limit),
32438
- total: issues.length,
32439
- limit: page.limit,
32440
- offset: page.offset
32441
- };
32442
- }
32443
- const served = answer;
32444
- if (typeof served !== "object" || served === null || !Array.isArray(served.issues) || typeof served.total !== "number" || typeof served.limit !== "number" || typeof served.offset !== "number") {
32445
- throw new Error("GET /api/v1/issues answered neither a page ({issues, total, limit, offset}) nor an array of issues");
32446
- }
32447
- return served;
32450
+ const path2 = ["api", "v1", "issues"];
32451
+ const query = { ...options, limit: page.limit, offset: page.offset };
32452
+ const answer = await this.#json("GET", path2, undefined, query);
32453
+ const refusal = whyNotAPage(answer);
32454
+ if (refusal === undefined)
32455
+ return answer;
32456
+ throw new Error(`GET ${this.#url(path2, query)} asked for a page ({issues, total, limit, offset}) and got ` + refusal);
32448
32457
  }
32449
32458
  async listProjectArtifacts(project, unlinked = false) {
32450
32459
  return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
package/dist/legion.js CHANGED
@@ -31311,6 +31311,27 @@ function requestSignal(signal) {
31311
31311
  const deadline = AbortSignal.timeout(DISPATCH_TOOL_DEADLINE_MS);
31312
31312
  return signal === undefined ? deadline : AbortSignal.any([signal, deadline]);
31313
31313
  }
31314
+ function whyNotAPage(answer) {
31315
+ if (typeof answer === "string") {
31316
+ return "text that is not a JSON page, which looks like a proxy or gateway page rather than " + "Dispatch's own answer, so a retry may succeed.";
31317
+ }
31318
+ let what;
31319
+ if (Array.isArray(answer)) {
31320
+ what = `a bare array of ${answer.length} entries, the unpaged listing, which means that Dispatch ` + "is older than sjawhar/legion#1612 or that change has regressed";
31321
+ } else if (answer === null || typeof answer !== "object") {
31322
+ what = answer === null ? "null" : `a ${typeof answer}`;
31323
+ } else {
31324
+ const fields = answer;
31325
+ const lacking = [
31326
+ ...Array.isArray(fields.issues) ? [] : ["an issues array"],
31327
+ ...["total", "limit", "offset"].filter((name) => typeof fields[name] !== "number").map((name) => `a numeric ${name}`)
31328
+ ];
31329
+ if (lacking.length === 0)
31330
+ return;
31331
+ what = `an object without ${lacking.join(" or ")}`;
31332
+ }
31333
+ return `${what}. Retrying will not help: the same request gets the same answer until that ` + "Dispatch is upgraded or fixed.";
31334
+ }
31314
31335
 
31315
31336
  class DispatchClient {
31316
31337
  token;
@@ -31331,25 +31352,13 @@ class DispatchClient {
31331
31352
  return this.#resolveIssue(issueReference);
31332
31353
  }
31333
31354
  async listIssuePage(options, page) {
31334
- const answer = await this.#json("GET", ["api", "v1", "issues"], undefined, {
31335
- ...options,
31336
- limit: page.limit,
31337
- offset: page.offset
31338
- });
31339
- if (Array.isArray(answer)) {
31340
- const issues = answer;
31341
- return {
31342
- issues: issues.slice(page.offset, page.offset + page.limit),
31343
- total: issues.length,
31344
- limit: page.limit,
31345
- offset: page.offset
31346
- };
31347
- }
31348
- const served = answer;
31349
- if (typeof served !== "object" || served === null || !Array.isArray(served.issues) || typeof served.total !== "number" || typeof served.limit !== "number" || typeof served.offset !== "number") {
31350
- throw new Error("GET /api/v1/issues answered neither a page ({issues, total, limit, offset}) nor an array of issues");
31351
- }
31352
- return served;
31355
+ const path2 = ["api", "v1", "issues"];
31356
+ const query = { ...options, limit: page.limit, offset: page.offset };
31357
+ const answer = await this.#json("GET", path2, undefined, query);
31358
+ const refusal = whyNotAPage(answer);
31359
+ if (refusal === undefined)
31360
+ return answer;
31361
+ throw new Error(`GET ${this.#url(path2, query)} asked for a page ({issues, total, limit, offset}) and got ` + refusal);
31353
31362
  }
31354
31363
  async listProjectArtifacts(project, unlinked = false) {
31355
31364
  return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
@@ -33676,7 +33685,7 @@ import { logger } from "@oh-my-pi/pi-utils";
33676
33685
  // package.json
33677
33686
  var package_default = {
33678
33687
  name: "@sjawhar/pi-legion-envoy",
33679
- version: "5.30.1",
33688
+ version: "5.30.3",
33680
33689
  type: "module",
33681
33690
  omp: {
33682
33691
  extensions: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion-envoy",
3
- "version": "5.30.1",
3
+ "version": "5.30.3",
4
4
  "type": "module",
5
5
  "omp": {
6
6
  "extensions": [