@continuous-excellence/ze-great-dashboard-aws 0.31.45 → 0.31.47

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.
Files changed (4) hide show
  1. package/dist/cli.js +2129 -385
  2. package/dist/index.js +2104 -360
  3. package/dist/lambda.mjs +2250 -1343
  4. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -48,9 +48,6 @@ import { join, resolve } from "node:path";
48
48
  // packages/server/src/allowlist.ts
49
49
  import { ZodError } from "zod";
50
50
 
51
- // packages/server/src/adapters/azure-devops.ts
52
- import { readFile } from "node:fs/promises";
53
-
54
51
  // packages/shared/src/board-config.ts
55
52
  import { z as z2 } from "zod";
56
53
 
@@ -70,7 +67,8 @@ var visibleRunningAnimations = [
70
67
  "release-transit",
71
68
  "status-weather",
72
69
  "falling-shapes",
73
- "snowman"
70
+ "snowman",
71
+ "flight-path"
74
72
  ];
75
73
 
76
74
  // packages/shared/src/board-config.ts
@@ -110,6 +108,17 @@ var githubActionsBuildEventsSchema = z2.array(githubActionsBuildEventSchema).min
110
108
  var attentionTreatments = ["beacon", "alarm", "steady"];
111
109
  var attentionTreatmentSchema = z2.enum(attentionTreatments);
112
110
  var httpValueJsonPathSchema = z2.string().regex(/^\$(?:\.[A-Za-z_][A-Za-z0-9_]*|\[\d+\])*$/, "must be a simple JSON path");
111
+ var testResultsArtifactSchema = z2.object({
112
+ artifact: z2.string().min(1).max(128),
113
+ entry: z2.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*\.json$/, "must be a root-level JSON file")
114
+ });
115
+ var testCountPanelSchema = z2.object({
116
+ id: z2.string().min(1),
117
+ type: z2.literal("test-count"),
118
+ source: z2.string().min(1),
119
+ pipeline: z2.string().min(1),
120
+ test_results: testResultsArtifactSchema
121
+ });
113
122
  var httpValueFactSchema = z2.object({
114
123
  /** Stable address below the panel; labels and ordering may change without repointing it. */
115
124
  id: z2.string().min(1),
@@ -169,7 +178,9 @@ var panelSchema = z2.looseObject({
169
178
  /** Up to four independently fetched source-agnostic readings in one visual panel. */
170
179
  facts: httpValueGroupedPanelSchema.shape.facts.optional(),
171
180
  /** Optional GitHub Actions-only restriction on which workflow triggers count as build evidence. */
172
- build_events: githubActionsBuildEventsSchema.optional()
181
+ build_events: githubActionsBuildEventsSchema.optional(),
182
+ /** Workflow-run artifact carrying a test-count panel's summary. */
183
+ test_results: testResultsArtifactSchema.optional()
173
184
  }).superRefine((panel, ctx) => {
174
185
  if ("display" in panel) {
175
186
  ctx.addIssue({
@@ -179,6 +190,28 @@ var panelSchema = z2.looseObject({
179
190
  params: { constraint: "display was removed; use density" }
180
191
  });
181
192
  }
193
+ if (panel.type === "test-count") {
194
+ if (!panel.source)
195
+ ctx.addIssue({ code: "custom", path: ["source"], message: "test-count requires a source" });
196
+ if (typeof panel.pipeline !== "string" || !panel.pipeline)
197
+ ctx.addIssue({
198
+ code: "custom",
199
+ path: ["pipeline"],
200
+ message: "test-count requires a workflow filename"
201
+ });
202
+ if (!panel.test_results)
203
+ ctx.addIssue({
204
+ code: "custom",
205
+ path: ["test_results"],
206
+ message: "test-count requires test_results artifact configuration"
207
+ });
208
+ } else if (panel.test_results) {
209
+ ctx.addIssue({
210
+ code: "custom",
211
+ path: ["test_results"],
212
+ message: "test_results is only supported by test-count panels"
213
+ });
214
+ }
182
215
  if (panel.type !== "http-value") return;
183
216
  if (panel.facts) {
184
217
  if (panel.url !== void 0)
@@ -554,6 +587,18 @@ var pipelineStatusSchema = z4.object({
554
587
  /** When this workflow run was last updated by its source, distinct from our observation time. */
555
588
  sourceUpdatedAt: z4.iso.datetime().optional()
556
589
  });
590
+ var testCountSchema = z4.discriminatedUnion("status", [
591
+ z4.object({
592
+ type: z4.literal("test-count"),
593
+ status: z4.literal("reported"),
594
+ total: z4.number().int().nonnegative(),
595
+ passed: z4.number().int().nonnegative().optional(),
596
+ failed: z4.number().int().nonnegative().optional(),
597
+ skipped: z4.number().int().nonnegative().optional()
598
+ }),
599
+ z4.object({ type: z4.literal("test-count"), status: z4.literal("pending") }),
600
+ z4.object({ type: z4.literal("test-count"), status: z4.literal("not-reported") })
601
+ ]);
557
602
  var pullRequestHealthItemSchema = z4.object({
558
603
  label: z4.string().min(1),
559
604
  status: pipelineStatusSchema.shape.status,
@@ -612,112 +657,947 @@ var securityDetailsResponseSchema = z5.strictObject({
612
657
  ])
613
658
  });
614
659
 
615
- // packages/server/src/adapters/azure-devops.ts
616
- import { z as z6 } from "zod";
617
- var pipelinePanelSchema = z6.object({
618
- id: z6.string().min(1),
619
- type: z6.literal("pipeline-status"),
620
- source: z6.string().min(1),
621
- pipeline: z6.number().int().positive()
622
- });
623
- var buildSchema = z6.object({
624
- id: z6.number().int().positive(),
625
- buildNumber: z6.string().min(1),
626
- status: z6.string().nullable().optional(),
627
- result: z6.string().nullable().optional(),
628
- sourceBranch: z6.string().min(1).nullable().optional(),
629
- startTime: z6.string().nullable().optional(),
630
- finishTime: z6.string().nullable().optional(),
631
- lastChangedDate: z6.string().nullable().optional()
632
- });
633
- var buildsSchema = z6.object({ value: z6.array(buildSchema) });
634
- var timelineSchema = z6.object({
635
- records: z6.array(
636
- z6.object({
637
- id: z6.string().min(1),
638
- parentId: z6.string().min(1).nullable().optional(),
639
- type: z6.string().min(1),
640
- name: z6.string().min(1),
641
- state: z6.string().nullable().optional()
642
- })
643
- )
644
- });
645
- function permittedAzureDevOpsCalls(panel, source) {
646
- const { panel: parsedPanel, source: parsedSource } = z6.object({ panel: pipelinePanelSchema, source: azureDevOpsSourceSchema }).parse({ panel, source });
647
- return [buildsCall(parsedPanel.pipeline, parsedSource)];
660
+ // packages/server/src/adapters/github-actions.ts
661
+ import { z as z7 } from "zod";
662
+
663
+ // packages/server/src/credentials.ts
664
+ function environmentCredentials(env = process.env) {
665
+ return { get: (name) => env[name] };
648
666
  }
649
- var delegatedTokenFileSchema = z6.object({
650
- accessToken: z6.string().min(1),
651
- expiresAt: z6.string().min(1)
652
- });
653
- function buildsCall(definitionId, source) {
654
- const url = apiUrl(source, "build/builds");
655
- url.searchParams.set("definitions", String(definitionId));
656
- if (source.branch) url.searchParams.set("branchName", adoBranch(source.branch));
657
- url.searchParams.set("queryOrder", "queueTimeDescending");
658
- url.searchParams.set("$top", "1");
659
- return { url: url.toString(), headers: new Headers({ accept: "application/json" }) };
667
+
668
+ // packages/server/src/github-auth.ts
669
+ import { createSign } from "node:crypto";
670
+
671
+ // packages/server/src/upstream.ts
672
+ function publicErrorMessage(kind) {
673
+ switch (kind) {
674
+ case "unreachable":
675
+ return "The source could not be reached. Check its address and network connectivity.";
676
+ case "unauthorized":
677
+ return "The dashboard is not authorized to read this source. Check the configured access.";
678
+ case "not-found":
679
+ return "The configured source was not found. Check the board configuration.";
680
+ case "no-runs":
681
+ return "No matching workflow runs were found. Check the configured workflow and branch.";
682
+ case "upstream-error":
683
+ return "The source returned an unreadable response. Check the source service and configuration.";
684
+ }
660
685
  }
661
- function apiUrl(source, suffix) {
662
- const url = new URL(
663
- `https://dev.azure.com/${encodeURIComponent(source.organization)}/${encodeURIComponent(source.project)}/_apis/${suffix}`
664
- );
665
- url.searchParams.set("api-version", "7.1");
666
- return url;
686
+ function forwardValidators(requestHeaders, upstreamHeaders) {
687
+ for (const name of ["if-none-match", "if-modified-since"]) {
688
+ const value2 = requestHeaders.get(name);
689
+ if (value2) upstreamHeaders.set(name, value2);
690
+ }
667
691
  }
668
- function adoBranch(branch) {
669
- return branch.startsWith("refs/") ? branch : `refs/heads/${branch}`;
692
+ function observedAt(upstreamDate) {
693
+ const parsed = upstreamDate ? new Date(upstreamDate) : void 0;
694
+ return parsed && !Number.isNaN(parsed.valueOf()) ? parsed.toISOString() : (/* @__PURE__ */ new Date()).toISOString();
695
+ }
696
+ function upstreamErrorEnvelope(args2) {
697
+ return {
698
+ panelId: args2.panelId,
699
+ state: "error",
700
+ observedAt: observedAt(args2.upstreamDate),
701
+ link: publicLink(args2.link),
702
+ error: {
703
+ kind: args2.kind,
704
+ // Raw failures regularly contain URLs, query values, response fragments, or credentials.
705
+ // The specific evidence stays server-side; the browser gets this fixed actionable vocabulary.
706
+ message: publicErrorMessage(args2.kind)
707
+ }
708
+ };
709
+ }
710
+ function publicLink(value2) {
711
+ if (!value2) return null;
712
+ try {
713
+ const url = new URL(value2);
714
+ url.search = "";
715
+ url.hash = "";
716
+ return url.toString();
717
+ } catch {
718
+ return null;
719
+ }
720
+ }
721
+ function upstreamErrorResponse(envelope) {
722
+ return new Response(JSON.stringify(envelope), { status: 200 });
723
+ }
724
+ function upstreamErrorKind(status) {
725
+ if (status === 401 || status === 403) return "unauthorized";
726
+ if (status === 404) return "not-found";
727
+ return "upstream-error";
728
+ }
729
+ function safeNetworkCode(error) {
730
+ const code = error && typeof error === "object" ? error.code : void 0;
731
+ return code === "ECONNREFUSED" || code === "ENOTFOUND" || code === "ETIMEDOUT" || code === "EAI_AGAIN" ? code : void 0;
670
732
  }
671
733
 
672
- // packages/server/src/adapters/github-actions.ts
673
- import { z as z7 } from "zod";
674
- var pipelinePanelSchema2 = z7.object({
675
- id: z7.string().min(1),
676
- type: z7.literal("pipeline-status"),
677
- source: z7.string().min(1),
678
- /** GitHub accepts a workflow filename or numeric workflow id in this URL segment. */
679
- pipeline: z7.string().min(1)
680
- });
681
- var pullRequestHealthPanelSchema = z7.object({
682
- id: z7.string().min(1),
683
- type: z7.literal("pull-request-health"),
684
- source: z7.string().min(1),
685
- base_branch: z7.string().min(1),
686
- update_workflows: z7.array(
687
- z7.object({
688
- workflow: z7.string().min(1),
689
- branch_prefixes: z7.array(z7.string().min(1)).min(1)
690
- })
691
- ).min(1),
692
- build_workflow: z7.string().min(1),
693
- build_events: githubActionsBuildEventsSchema.optional()
694
- });
695
- var runSchema = z7.object({
696
- id: z7.number().int().positive().optional(),
697
- status: z7.string(),
698
- conclusion: z7.string().nullable(),
699
- name: z7.string().min(1),
700
- html_url: z7.url(),
701
- /** The GitHub Actions trigger that started this run. */
702
- event: z7.string().min(1).optional(),
703
- /** The branch that produced this run; absent for some event types. */
704
- head_branch: z7.string().min(1).nullable().optional(),
705
- // Timestamp quality should only remove timing advice, never make an otherwise useful run unreadable.
706
- run_started_at: z7.string().nullable().optional(),
707
- updated_at: z7.string().optional(),
708
- created_at: z7.string().optional()
709
- });
710
- var runsSchema = z7.object({ workflow_runs: z7.array(runSchema) });
711
- var jobsSchema = z7.object({
712
- jobs: z7.array(
713
- z7.object({
714
- name: z7.string().min(1),
715
- status: z7.string(),
716
- steps: z7.array(z7.object({ name: z7.string().min(1), status: z7.string() })).optional()
717
- })
718
- )
734
+ // packages/server/src/github-auth.ts
735
+ var GithubAuthenticationError = class extends Error {
736
+ constructor() {
737
+ super("GitHub authentication could not be completed.");
738
+ this.name = "GithubAuthenticationError";
739
+ }
740
+ };
741
+ function createGithubClient(credentials, now = Date.now) {
742
+ const tokens = /* @__PURE__ */ new Map();
743
+ const pending = /* @__PURE__ */ new Map();
744
+ async function installationToken(source, fetcher, refresh = false) {
745
+ const app = source.github_app;
746
+ if (!app) return void 0;
747
+ const appId = requiredCredential(credentials, app.app_id_env);
748
+ const privateKey = requiredCredential(credentials, app.private_key_env);
749
+ const installationId = requiredCredential(credentials, app.installation_id_env);
750
+ const cacheKey = `${appId}:${installationId}:${app.private_key_env}`;
751
+ const cached = tokens.get(cacheKey);
752
+ if (!refresh && cached && cached.expiresAt > now() + 6e4)
753
+ return { token: cached.token, cacheKey };
754
+ const existing = pending.get(cacheKey);
755
+ if (existing) return { token: await existing, cacheKey };
756
+ const exchange = exchangeInstallationToken({ appId, privateKey, installationId, fetcher, now }).then(({ token, expiresAt }) => {
757
+ tokens.set(cacheKey, { token, expiresAt });
758
+ return token;
759
+ }).catch((error) => {
760
+ if (error instanceof GithubAuthenticationError) throw error;
761
+ throw new GithubAuthenticationError();
762
+ });
763
+ pending.set(cacheKey, exchange);
764
+ try {
765
+ return { token: await exchange, cacheKey };
766
+ } finally {
767
+ pending.delete(cacheKey);
768
+ }
769
+ }
770
+ return {
771
+ async get({ source, url, requestHeaders, fetcher }) {
772
+ const headers = githubHeaders(requestHeaders);
773
+ if (source.token_env)
774
+ headers.set("authorization", `Bearer ${requiredCredential(credentials, source.token_env)}`);
775
+ const appToken = await installationToken(source, fetcher);
776
+ if (appToken) headers.set("authorization", `Bearer ${appToken.token}`);
777
+ const response = await fetcher(url, { headers });
778
+ if (!appToken || response.status !== 401) return response;
779
+ tokens.delete(appToken.cacheKey);
780
+ const refreshed = await installationToken(source, fetcher, true);
781
+ if (!refreshed) return response;
782
+ const replayHeaders = githubHeaders(requestHeaders);
783
+ replayHeaders.set("authorization", `Bearer ${refreshed.token}`);
784
+ return fetcher(url, { headers: replayHeaders });
785
+ }
786
+ };
787
+ }
788
+ function githubHeaders(requestHeaders) {
789
+ const headers = new Headers({ accept: "application/vnd.github+json" });
790
+ forwardValidators(requestHeaders, headers);
791
+ return headers;
792
+ }
793
+ async function exchangeInstallationToken(args2) {
794
+ let jwt;
795
+ try {
796
+ jwt = createAppJwt(args2.appId, args2.privateKey, args2.now());
797
+ } catch {
798
+ throw new GithubAuthenticationError();
799
+ }
800
+ let response;
801
+ try {
802
+ response = await args2.fetcher(
803
+ `https://api.github.com/app/installations/${encodeURIComponent(args2.installationId)}/access_tokens`,
804
+ {
805
+ method: "POST",
806
+ headers: new Headers({
807
+ accept: "application/vnd.github+json",
808
+ authorization: `Bearer ${jwt}`,
809
+ "content-type": "application/json"
810
+ })
811
+ }
812
+ );
813
+ } catch {
814
+ throw new GithubAuthenticationError();
815
+ }
816
+ if (!response.ok) throw new GithubAuthenticationError();
817
+ const body = await response.json();
818
+ if (!body.token || !body.expires_at) throw new GithubAuthenticationError();
819
+ const expiresAt = new Date(body.expires_at).valueOf();
820
+ if (!Number.isFinite(expiresAt)) throw new GithubAuthenticationError();
821
+ return { token: body.token, expiresAt };
822
+ }
823
+ function createAppJwt(appId, privateKey, now = Date.now()) {
824
+ const issuedAt = Math.floor(now / 1e3) - 60;
825
+ const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
826
+ const payload = base64url(JSON.stringify({ iat: issuedAt, exp: issuedAt + 540, iss: appId }));
827
+ const signingInput = `${header}.${payload}`;
828
+ const signer = createSign("RSA-SHA256");
829
+ signer.update(signingInput);
830
+ signer.end();
831
+ return `${signingInput}.${base64url(signer.sign(privateKey))}`;
832
+ }
833
+ function requiredCredential(credentials, name) {
834
+ const value2 = credentials.get(name);
835
+ if (value2) return value2;
836
+ throw new GithubAuthenticationError();
837
+ }
838
+ function base64url(value2) {
839
+ return Buffer.from(value2).toString("base64url");
840
+ }
841
+
842
+ // node_modules/fflate/esm/browser.js
843
+ var u8 = Uint8Array;
844
+ var u16 = Uint16Array;
845
+ var i32 = Int32Array;
846
+ var fleb = new u8([
847
+ 0,
848
+ 0,
849
+ 0,
850
+ 0,
851
+ 0,
852
+ 0,
853
+ 0,
854
+ 0,
855
+ 1,
856
+ 1,
857
+ 1,
858
+ 1,
859
+ 2,
860
+ 2,
861
+ 2,
862
+ 2,
863
+ 3,
864
+ 3,
865
+ 3,
866
+ 3,
867
+ 4,
868
+ 4,
869
+ 4,
870
+ 4,
871
+ 5,
872
+ 5,
873
+ 5,
874
+ 5,
875
+ 0,
876
+ /* unused */
877
+ 0,
878
+ 0,
879
+ /* impossible */
880
+ 0
881
+ ]);
882
+ var fdeb = new u8([
883
+ 0,
884
+ 0,
885
+ 0,
886
+ 0,
887
+ 1,
888
+ 1,
889
+ 2,
890
+ 2,
891
+ 3,
892
+ 3,
893
+ 4,
894
+ 4,
895
+ 5,
896
+ 5,
897
+ 6,
898
+ 6,
899
+ 7,
900
+ 7,
901
+ 8,
902
+ 8,
903
+ 9,
904
+ 9,
905
+ 10,
906
+ 10,
907
+ 11,
908
+ 11,
909
+ 12,
910
+ 12,
911
+ 13,
912
+ 13,
913
+ /* unused */
914
+ 0,
915
+ 0
916
+ ]);
917
+ var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
918
+ var freb = function(eb, start) {
919
+ var b = new u16(31);
920
+ for (var i3 = 0; i3 < 31; ++i3) {
921
+ b[i3] = start += 1 << eb[i3 - 1];
922
+ }
923
+ var r = new i32(b[30]);
924
+ for (var i3 = 1; i3 < 30; ++i3) {
925
+ for (var j = b[i3]; j < b[i3 + 1]; ++j) {
926
+ r[j] = j - b[i3] << 5 | i3;
927
+ }
928
+ }
929
+ return { b, r };
930
+ };
931
+ var _a = freb(fleb, 2);
932
+ var fl = _a.b;
933
+ var revfl = _a.r;
934
+ fl[28] = 258, revfl[258] = 28;
935
+ var _b = freb(fdeb, 0);
936
+ var fd = _b.b;
937
+ var revfd = _b.r;
938
+ var rev = new u16(32768);
939
+ for (i = 0; i < 32768; ++i) {
940
+ x = (i & 43690) >> 1 | (i & 21845) << 1;
941
+ x = (x & 52428) >> 2 | (x & 13107) << 2;
942
+ x = (x & 61680) >> 4 | (x & 3855) << 4;
943
+ rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
944
+ }
945
+ var x;
946
+ var i;
947
+ var hMap = (function(cd, mb, r) {
948
+ var s = cd.length;
949
+ var i3 = 0;
950
+ var l = new u16(mb);
951
+ for (; i3 < s; ++i3) {
952
+ if (cd[i3])
953
+ ++l[cd[i3] - 1];
954
+ }
955
+ var le = new u16(mb);
956
+ for (i3 = 1; i3 < mb; ++i3) {
957
+ le[i3] = le[i3 - 1] + l[i3 - 1] << 1;
958
+ }
959
+ var co;
960
+ if (r) {
961
+ co = new u16(1 << mb);
962
+ var rvb = 15 - mb;
963
+ for (i3 = 0; i3 < s; ++i3) {
964
+ if (cd[i3]) {
965
+ var sv = i3 << 4 | cd[i3];
966
+ var r_1 = mb - cd[i3];
967
+ var v = le[cd[i3] - 1]++ << r_1;
968
+ for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
969
+ co[rev[v] >> rvb] = sv;
970
+ }
971
+ }
972
+ }
973
+ } else {
974
+ co = new u16(s);
975
+ for (i3 = 0; i3 < s; ++i3) {
976
+ if (cd[i3]) {
977
+ co[i3] = rev[le[cd[i3] - 1]++] >> 15 - cd[i3];
978
+ }
979
+ }
980
+ }
981
+ return co;
719
982
  });
720
- var pullRequestsSchema = z7.array(
983
+ var flt = new u8(288);
984
+ for (i = 0; i < 144; ++i)
985
+ flt[i] = 8;
986
+ var i;
987
+ for (i = 144; i < 256; ++i)
988
+ flt[i] = 9;
989
+ var i;
990
+ for (i = 256; i < 280; ++i)
991
+ flt[i] = 7;
992
+ var i;
993
+ for (i = 280; i < 288; ++i)
994
+ flt[i] = 8;
995
+ var i;
996
+ var fdt = new u8(32);
997
+ for (i = 0; i < 32; ++i)
998
+ fdt[i] = 5;
999
+ var i;
1000
+ var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
1001
+ var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
1002
+ var max = function(a) {
1003
+ var m = a[0];
1004
+ for (var i3 = 1; i3 < a.length; ++i3) {
1005
+ if (a[i3] > m)
1006
+ m = a[i3];
1007
+ }
1008
+ return m;
1009
+ };
1010
+ var bits = function(d, p, m) {
1011
+ var o = p / 8 | 0;
1012
+ return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
1013
+ };
1014
+ var bits16 = function(d, p) {
1015
+ var o = p / 8 | 0;
1016
+ return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
1017
+ };
1018
+ var shft = function(p) {
1019
+ return (p + 7) / 8 | 0;
1020
+ };
1021
+ var slc = function(v, s, e) {
1022
+ if (s == null || s < 0)
1023
+ s = 0;
1024
+ if (e == null || e > v.length)
1025
+ e = v.length;
1026
+ return new u8(v.subarray(s, e));
1027
+ };
1028
+ var ec = [
1029
+ "unexpected EOF",
1030
+ "invalid block type",
1031
+ "invalid length/literal",
1032
+ "invalid distance",
1033
+ "stream finished",
1034
+ "no stream handler",
1035
+ ,
1036
+ // determined by compression function
1037
+ "no callback",
1038
+ "invalid UTF-8 data",
1039
+ "extra field too long",
1040
+ "date not in range 1980-2099",
1041
+ "filename too long",
1042
+ "stream finishing",
1043
+ "invalid zip data"
1044
+ // determined by unknown compression method
1045
+ ];
1046
+ var err = function(ind, msg, nt) {
1047
+ var e = new Error(msg || ec[ind]);
1048
+ e.code = ind;
1049
+ if (Error.captureStackTrace)
1050
+ Error.captureStackTrace(e, err);
1051
+ if (!nt)
1052
+ throw e;
1053
+ return e;
1054
+ };
1055
+ var inflt = function(dat, st, buf, dict) {
1056
+ var sl = dat.length, dl = dict ? dict.length : 0;
1057
+ if (!sl || st.f && !st.l)
1058
+ return buf || new u8(0);
1059
+ var noBuf = !buf;
1060
+ var resize = noBuf || st.i != 2;
1061
+ var noSt = st.i;
1062
+ if (noBuf)
1063
+ buf = new u8(sl * 3);
1064
+ var cbuf = function(l2) {
1065
+ var bl = buf.length;
1066
+ if (l2 > bl) {
1067
+ var nbuf = new u8(Math.max(bl * 2, l2));
1068
+ nbuf.set(buf);
1069
+ buf = nbuf;
1070
+ }
1071
+ };
1072
+ var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
1073
+ var tbts = sl * 8;
1074
+ do {
1075
+ if (!lm) {
1076
+ final = bits(dat, pos, 1);
1077
+ var type = bits(dat, pos + 1, 3);
1078
+ pos += 3;
1079
+ if (!type) {
1080
+ var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
1081
+ if (t > sl) {
1082
+ if (noSt)
1083
+ err(0);
1084
+ break;
1085
+ }
1086
+ if (resize)
1087
+ cbuf(bt + l);
1088
+ buf.set(dat.subarray(s, t), bt);
1089
+ st.b = bt += l, st.p = pos = t * 8, st.f = final;
1090
+ continue;
1091
+ } else if (type == 1)
1092
+ lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
1093
+ else if (type == 2) {
1094
+ var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
1095
+ var tl = hLit + bits(dat, pos + 5, 31) + 1;
1096
+ pos += 14;
1097
+ var ldt = new u8(tl);
1098
+ var clt = new u8(19);
1099
+ for (var i3 = 0; i3 < hcLen; ++i3) {
1100
+ clt[clim[i3]] = bits(dat, pos + i3 * 3, 7);
1101
+ }
1102
+ pos += hcLen * 3;
1103
+ var clb = max(clt), clbmsk = (1 << clb) - 1;
1104
+ var clm = hMap(clt, clb, 1);
1105
+ for (var i3 = 0; i3 < tl; ) {
1106
+ var r = clm[bits(dat, pos, clbmsk)];
1107
+ pos += r & 15;
1108
+ var s = r >> 4;
1109
+ if (s < 16) {
1110
+ ldt[i3++] = s;
1111
+ } else {
1112
+ var c = 0, n = 0;
1113
+ if (s == 16)
1114
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i3 - 1];
1115
+ else if (s == 17)
1116
+ n = 3 + bits(dat, pos, 7), pos += 3;
1117
+ else if (s == 18)
1118
+ n = 11 + bits(dat, pos, 127), pos += 7;
1119
+ while (n--)
1120
+ ldt[i3++] = c;
1121
+ }
1122
+ }
1123
+ var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
1124
+ lbt = max(lt);
1125
+ dbt = max(dt);
1126
+ lm = hMap(lt, lbt, 1);
1127
+ dm = hMap(dt, dbt, 1);
1128
+ } else
1129
+ err(1);
1130
+ if (pos > tbts) {
1131
+ if (noSt)
1132
+ err(0);
1133
+ break;
1134
+ }
1135
+ }
1136
+ if (resize)
1137
+ cbuf(bt + 131072);
1138
+ var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
1139
+ var lpos = pos;
1140
+ for (; ; lpos = pos) {
1141
+ var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
1142
+ pos += c & 15;
1143
+ if (pos > tbts) {
1144
+ if (noSt)
1145
+ err(0);
1146
+ break;
1147
+ }
1148
+ if (!c)
1149
+ err(2);
1150
+ if (sym < 256)
1151
+ buf[bt++] = sym;
1152
+ else if (sym == 256) {
1153
+ lpos = pos, lm = null;
1154
+ break;
1155
+ } else {
1156
+ var add = sym - 254;
1157
+ if (sym > 264) {
1158
+ var i3 = sym - 257, b = fleb[i3];
1159
+ add = bits(dat, pos, (1 << b) - 1) + fl[i3];
1160
+ pos += b;
1161
+ }
1162
+ var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
1163
+ if (!d)
1164
+ err(3);
1165
+ pos += d & 15;
1166
+ var dt = fd[dsym];
1167
+ if (dsym > 3) {
1168
+ var b = fdeb[dsym];
1169
+ dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
1170
+ }
1171
+ if (pos > tbts) {
1172
+ if (noSt)
1173
+ err(0);
1174
+ break;
1175
+ }
1176
+ if (resize)
1177
+ cbuf(bt + 131072);
1178
+ var end = bt + add;
1179
+ if (bt < dt) {
1180
+ var shift = dl - dt, dend = Math.min(dt, end);
1181
+ if (shift + bt < 0)
1182
+ err(3);
1183
+ for (; bt < dend; ++bt)
1184
+ buf[bt] = dict[shift + bt];
1185
+ }
1186
+ for (; bt < end; ++bt)
1187
+ buf[bt] = buf[bt - dt];
1188
+ }
1189
+ }
1190
+ st.l = lm, st.p = lpos, st.b = bt, st.f = final;
1191
+ if (lm)
1192
+ final = 1, st.m = lbt, st.d = dm, st.n = dbt;
1193
+ } while (!final);
1194
+ return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
1195
+ };
1196
+ var et = /* @__PURE__ */ new u8(0);
1197
+ var b2 = function(d, b) {
1198
+ return d[b] | d[b + 1] << 8;
1199
+ };
1200
+ var b4 = function(d, b) {
1201
+ return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
1202
+ };
1203
+ var b8 = function(d, b) {
1204
+ return b4(d, b) + b4(d, b + 4) * 4294967296;
1205
+ };
1206
+ var Inflate = /* @__PURE__ */ (function() {
1207
+ function Inflate2(opts, cb) {
1208
+ if (typeof opts == "function")
1209
+ cb = opts, opts = {};
1210
+ this.ondata = cb;
1211
+ var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);
1212
+ this.s = { i: 0, b: dict ? dict.length : 0 };
1213
+ this.o = new u8(32768);
1214
+ this.p = new u8(0);
1215
+ if (dict)
1216
+ this.o.set(dict);
1217
+ }
1218
+ Inflate2.prototype.e = function(c) {
1219
+ if (!this.ondata)
1220
+ err(5);
1221
+ if (this.d)
1222
+ err(4);
1223
+ if (!this.p.length)
1224
+ this.p = c;
1225
+ else if (c.length) {
1226
+ var n = new u8(this.p.length + c.length);
1227
+ n.set(this.p), n.set(c, this.p.length), this.p = n;
1228
+ }
1229
+ };
1230
+ Inflate2.prototype.c = function(final) {
1231
+ this.s.i = +(this.d = final || false);
1232
+ var bts = this.s.b;
1233
+ var dt = inflt(this.p, this.s, this.o);
1234
+ this.ondata(slc(dt, bts, this.s.b), this.d);
1235
+ this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
1236
+ this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
1237
+ };
1238
+ Inflate2.prototype.push = function(chunk, final) {
1239
+ this.e(chunk), this.c(final);
1240
+ };
1241
+ return Inflate2;
1242
+ })();
1243
+ var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
1244
+ var tds = 0;
1245
+ try {
1246
+ td.decode(et, { stream: true });
1247
+ tds = 1;
1248
+ } catch (e) {
1249
+ }
1250
+ var dutf8 = function(d) {
1251
+ for (var r = "", i3 = 0; ; ) {
1252
+ var c = d[i3++];
1253
+ var eb = (c > 127) + (c > 223) + (c > 239);
1254
+ if (i3 + eb > d.length)
1255
+ return { s: r, r: slc(d, i3 - 1) };
1256
+ if (!eb)
1257
+ r += String.fromCharCode(c);
1258
+ else if (eb == 3) {
1259
+ c = ((c & 15) << 18 | (d[i3++] & 63) << 12 | (d[i3++] & 63) << 6 | d[i3++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
1260
+ } else if (eb & 1)
1261
+ r += String.fromCharCode((c & 31) << 6 | d[i3++] & 63);
1262
+ else
1263
+ r += String.fromCharCode((c & 15) << 12 | (d[i3++] & 63) << 6 | d[i3++] & 63);
1264
+ }
1265
+ };
1266
+ function strFromU8(dat, latin1) {
1267
+ if (latin1) {
1268
+ var r = "";
1269
+ for (var i3 = 0; i3 < dat.length; i3 += 16384)
1270
+ r += String.fromCharCode.apply(null, dat.subarray(i3, i3 + 16384));
1271
+ return r;
1272
+ } else if (td) {
1273
+ return td.decode(dat);
1274
+ } else {
1275
+ var _a3 = dutf8(dat), s = _a3.s, r = _a3.r;
1276
+ if (r.length)
1277
+ err(8);
1278
+ return s;
1279
+ }
1280
+ }
1281
+ var z64hs = function(d, b, l, z11, sc, su, off) {
1282
+ var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;
1283
+ var nf = nsc + nsu + noff;
1284
+ if (z11 && nf) {
1285
+ for (; b + 4 < e; b += 4 + b2(d, b + 2)) {
1286
+ if (b2(d, b) == 1) {
1287
+ return [
1288
+ nsc ? b8(d, b + 4 + 8 * nsu) : sc,
1289
+ nsu ? b8(d, b + 4) : su,
1290
+ noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,
1291
+ 1
1292
+ ];
1293
+ }
1294
+ }
1295
+ if (z11 < 2)
1296
+ err(13);
1297
+ }
1298
+ return [sc, su, off, 0];
1299
+ };
1300
+ var UnzipPassThrough = /* @__PURE__ */ (function() {
1301
+ function UnzipPassThrough2() {
1302
+ }
1303
+ UnzipPassThrough2.prototype.push = function(chunk, final) {
1304
+ this.ondata(null, chunk, final);
1305
+ };
1306
+ UnzipPassThrough2.compression = 0;
1307
+ return UnzipPassThrough2;
1308
+ })();
1309
+ var UnzipInflate = /* @__PURE__ */ (function() {
1310
+ function UnzipInflate2() {
1311
+ var _this = this;
1312
+ this.i = new Inflate(function(dat, final) {
1313
+ _this.ondata(null, dat, final);
1314
+ });
1315
+ }
1316
+ UnzipInflate2.prototype.push = function(chunk, final) {
1317
+ try {
1318
+ this.i.push(chunk, final);
1319
+ } catch (e) {
1320
+ this.ondata(e, null, final);
1321
+ }
1322
+ };
1323
+ UnzipInflate2.compression = 8;
1324
+ return UnzipInflate2;
1325
+ })();
1326
+ var Unzip = /* @__PURE__ */ (function() {
1327
+ function Unzip2(cb) {
1328
+ this.onfile = cb;
1329
+ this.k = [];
1330
+ this.o = {
1331
+ 0: UnzipPassThrough
1332
+ };
1333
+ this.p = et;
1334
+ }
1335
+ Unzip2.prototype.push = function(chunk, final) {
1336
+ var _this = this;
1337
+ if (!this.onfile)
1338
+ err(5);
1339
+ if (!this.p)
1340
+ err(4);
1341
+ if (this.c > 0) {
1342
+ var len = Math.min(this.c, chunk.length);
1343
+ var toAdd = chunk.subarray(0, len);
1344
+ this.c -= len;
1345
+ if (this.d)
1346
+ this.d.push(toAdd, !this.c);
1347
+ else
1348
+ this.k[0].push(toAdd);
1349
+ chunk = chunk.subarray(len);
1350
+ if (chunk.length)
1351
+ return this.push(chunk, final);
1352
+ } else {
1353
+ var f = 0, i3 = 0, is = void 0, buf = void 0;
1354
+ if (!this.p.length)
1355
+ buf = chunk;
1356
+ else if (!chunk.length)
1357
+ buf = this.p;
1358
+ else {
1359
+ buf = new u8(this.p.length + chunk.length);
1360
+ buf.set(this.p), buf.set(chunk, this.p.length);
1361
+ }
1362
+ var l = buf.length, oc = this.c, add = oc && this.d;
1363
+ var _loop_2 = function() {
1364
+ var sig = b4(buf, i3);
1365
+ if (sig == 67324752) {
1366
+ f = 1, is = i3;
1367
+ this_1.d = null;
1368
+ this_1.c = 0;
1369
+ var bf = b2(buf, i3 + 6), cmp_1 = b2(buf, i3 + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i3 + 26), es = b2(buf, i3 + 28);
1370
+ if (l > i3 + 30 + fnl + es) {
1371
+ var chks_3 = [];
1372
+ this_1.k.unshift(chks_3);
1373
+ f = 2;
1374
+ var lsc = b4(buf, i3 + 18), lsu = b4(buf, i3 + 22);
1375
+ var fn_1 = strFromU8(buf.subarray(i3 + 30, i3 += 30 + fnl), !u);
1376
+ var _a3 = z64hs(buf, i3, es, 2, lsc, lsu, 0), sc_1 = _a3[0], su_1 = _a3[1], z64 = _a3[3];
1377
+ if (dd)
1378
+ sc_1 = -1 - z64;
1379
+ i3 += es;
1380
+ this_1.c = sc_1;
1381
+ var d_1;
1382
+ var file_1 = {
1383
+ name: fn_1,
1384
+ compression: cmp_1,
1385
+ start: function() {
1386
+ if (!file_1.ondata)
1387
+ err(5);
1388
+ if (!sc_1)
1389
+ file_1.ondata(null, et, true);
1390
+ else {
1391
+ var ctr = _this.o[cmp_1];
1392
+ if (!ctr)
1393
+ file_1.ondata(err(14, "unknown compression type " + cmp_1, 1), null, false);
1394
+ d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);
1395
+ d_1.ondata = function(err3, dat3, final2) {
1396
+ file_1.ondata(err3, dat3, final2);
1397
+ };
1398
+ for (var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++) {
1399
+ var dat2 = chks_4[_i];
1400
+ d_1.push(dat2, false);
1401
+ }
1402
+ if (_this.k[0] == chks_3 && _this.c)
1403
+ _this.d = d_1;
1404
+ else
1405
+ d_1.push(et, true);
1406
+ }
1407
+ },
1408
+ terminate: function() {
1409
+ if (d_1 && d_1.terminate)
1410
+ d_1.terminate();
1411
+ }
1412
+ };
1413
+ if (sc_1 >= 0)
1414
+ file_1.size = sc_1, file_1.originalSize = su_1;
1415
+ this_1.onfile(file_1);
1416
+ }
1417
+ return "break";
1418
+ } else if (oc) {
1419
+ if (sig == 134695760) {
1420
+ is = i3 += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;
1421
+ return "break";
1422
+ } else if (sig == 33639248) {
1423
+ is = i3 -= 4, f = 3, this_1.c = 0;
1424
+ return "break";
1425
+ }
1426
+ }
1427
+ };
1428
+ var this_1 = this;
1429
+ for (; i3 < l - 4; ++i3) {
1430
+ var state_1 = _loop_2();
1431
+ if (state_1 === "break")
1432
+ break;
1433
+ }
1434
+ this.p = et;
1435
+ if (oc < 0) {
1436
+ var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 134695760 && 4)) : buf.subarray(0, i3);
1437
+ if (add)
1438
+ add.push(dat, !!f);
1439
+ else
1440
+ this.k[+(f == 2)].push(dat);
1441
+ }
1442
+ if (f & 2)
1443
+ return this.push(buf.subarray(i3), final);
1444
+ this.p = buf.subarray(i3);
1445
+ }
1446
+ if (final) {
1447
+ if (this.c)
1448
+ err(13);
1449
+ this.p = null;
1450
+ }
1451
+ };
1452
+ Unzip2.prototype.register = function(decoder) {
1453
+ this.o[decoder.compression] = decoder;
1454
+ };
1455
+ return Unzip2;
1456
+ })();
1457
+
1458
+ // packages/server/src/workflow-artifact-summary.ts
1459
+ import { z as z6 } from "zod";
1460
+ var maxArtifactBytes = 64 * 1024;
1461
+ var testResultsSummarySchema = z6.object({
1462
+ schemaVersion: z6.literal(1),
1463
+ runId: z6.number().int().positive(),
1464
+ runAttempt: z6.number().int().positive(),
1465
+ headSha: z6.string().min(1),
1466
+ total: z6.number().int().nonnegative(),
1467
+ passed: z6.number().int().nonnegative().optional(),
1468
+ failed: z6.number().int().nonnegative().optional(),
1469
+ skipped: z6.number().int().nonnegative().optional(),
1470
+ metadata: z6.record(z6.string(), z6.unknown()).optional()
1471
+ }).superRefine((summary, ctx) => {
1472
+ const outcomeTotal = (summary.passed ?? 0) + (summary.failed ?? 0) + (summary.skipped ?? 0);
1473
+ for (const key of ["passed", "failed", "skipped"]) {
1474
+ if (summary[key] !== void 0 && summary[key] > summary.total)
1475
+ ctx.addIssue({ code: "custom", path: [key], message: "must not exceed total" });
1476
+ }
1477
+ if (outcomeTotal > summary.total)
1478
+ ctx.addIssue({ code: "custom", path: ["total"], message: "must cover the declared outcomes" });
1479
+ });
1480
+ async function readTestResultsArtifact(response, entry) {
1481
+ const reader = response.body?.getReader();
1482
+ if (!reader) throw new Error("Artifact archive has no readable body.");
1483
+ let compressedBytes = 0;
1484
+ let entryCount = 0;
1485
+ let outputBytes = 0;
1486
+ let complete = false;
1487
+ let failure2;
1488
+ const chunks = [];
1489
+ const archive = new Unzip((file) => {
1490
+ entryCount += 1;
1491
+ if (file.name !== entry || entryCount > 1) {
1492
+ failure2 = new Error("Artifact archive has an unexpected entry.");
1493
+ return;
1494
+ }
1495
+ if ((file.originalSize ?? 0) > maxArtifactBytes) {
1496
+ failure2 = new Error("Artifact entry exceeds the configured size limit.");
1497
+ return;
1498
+ }
1499
+ file.ondata = (error, data, final) => {
1500
+ if (error) {
1501
+ failure2 = error;
1502
+ return;
1503
+ }
1504
+ outputBytes += data.length;
1505
+ if (outputBytes > maxArtifactBytes) {
1506
+ failure2 = new Error("Artifact entry exceeds the configured size limit.");
1507
+ file.terminate();
1508
+ return;
1509
+ }
1510
+ chunks.push(data);
1511
+ if (final) complete = true;
1512
+ };
1513
+ file.start();
1514
+ });
1515
+ archive.register(UnzipInflate);
1516
+ try {
1517
+ for (; ; ) {
1518
+ const { done, value: value2 } = await reader.read();
1519
+ if (value2) {
1520
+ compressedBytes += value2.length;
1521
+ if (compressedBytes > maxArtifactBytes)
1522
+ throw new Error("Artifact archive exceeds the configured size limit.");
1523
+ archive.push(value2, done);
1524
+ } else if (done) archive.push(new Uint8Array(), true);
1525
+ if (done) break;
1526
+ if (failure2) throw failure2;
1527
+ }
1528
+ } finally {
1529
+ reader.releaseLock();
1530
+ }
1531
+ if (failure2) throw failure2;
1532
+ if (entryCount !== 1 || !complete)
1533
+ throw new Error("Artifact archive did not contain the configured summary.");
1534
+ return new TextDecoder("utf-8", { fatal: true }).decode(concat(chunks, outputBytes));
1535
+ }
1536
+ function concat(chunks, length) {
1537
+ const result = new Uint8Array(length);
1538
+ let offset = 0;
1539
+ for (const chunk of chunks) {
1540
+ result.set(chunk, offset);
1541
+ offset += chunk.length;
1542
+ }
1543
+ return result;
1544
+ }
1545
+
1546
+ // packages/server/src/adapters/github-actions.ts
1547
+ var pipelinePanelSchema = z7.object({
1548
+ id: z7.string().min(1),
1549
+ type: z7.literal("pipeline-status"),
1550
+ source: z7.string().min(1),
1551
+ /** GitHub accepts a workflow filename or numeric workflow id in this URL segment. */
1552
+ pipeline: z7.string().min(1)
1553
+ });
1554
+ var pullRequestHealthPanelSchema = z7.object({
1555
+ id: z7.string().min(1),
1556
+ type: z7.literal("pull-request-health"),
1557
+ source: z7.string().min(1),
1558
+ base_branch: z7.string().min(1),
1559
+ update_workflows: z7.array(
1560
+ z7.object({
1561
+ workflow: z7.string().min(1),
1562
+ branch_prefixes: z7.array(z7.string().min(1)).min(1)
1563
+ })
1564
+ ).min(1),
1565
+ build_workflow: z7.string().min(1),
1566
+ build_events: githubActionsBuildEventsSchema.optional()
1567
+ });
1568
+ var runSchema = z7.object({
1569
+ id: z7.number().int().positive().optional(),
1570
+ run_attempt: z7.number().int().positive().optional(),
1571
+ head_sha: z7.string().min(1).optional(),
1572
+ status: z7.string(),
1573
+ conclusion: z7.string().nullable(),
1574
+ name: z7.string().min(1),
1575
+ html_url: z7.url(),
1576
+ /** The GitHub Actions trigger that started this run. */
1577
+ event: z7.string().min(1).optional(),
1578
+ /** The branch that produced this run; absent for some event types. */
1579
+ head_branch: z7.string().min(1).nullable().optional(),
1580
+ // Timestamp quality should only remove timing advice, never make an otherwise useful run unreadable.
1581
+ run_started_at: z7.string().nullable().optional(),
1582
+ updated_at: z7.string().optional(),
1583
+ created_at: z7.string().optional()
1584
+ });
1585
+ var artifactsSchema = z7.object({
1586
+ artifacts: z7.array(
1587
+ z7.object({ id: z7.number().int().positive(), name: z7.string().min(1), expired: z7.boolean() })
1588
+ )
1589
+ });
1590
+ var runsSchema = z7.object({ workflow_runs: z7.array(runSchema) });
1591
+ var jobsSchema = z7.object({
1592
+ jobs: z7.array(
1593
+ z7.object({
1594
+ name: z7.string().min(1),
1595
+ status: z7.string(),
1596
+ steps: z7.array(z7.object({ name: z7.string().min(1), status: z7.string() })).optional()
1597
+ })
1598
+ )
1599
+ });
1600
+ var pullRequestsSchema = z7.array(
721
1601
  z7.object({
722
1602
  number: z7.number().int().positive(),
723
1603
  html_url: z7.url(),
@@ -726,7 +1606,7 @@ var pullRequestsSchema = z7.array(
726
1606
  })
727
1607
  );
728
1608
  function permittedGithubActionsCalls(panel, source, _credentials) {
729
- const { panel: parsedPanel, source: parsedSource } = z7.object({ panel: pipelinePanelSchema2, source: githubActionsSourceSchema }).parse({ panel, source });
1609
+ const { panel: parsedPanel, source: parsedSource } = z7.object({ panel: pipelinePanelSchema, source: githubActionsSourceSchema }).parse({ panel, source });
730
1610
  const url = new URL(
731
1611
  `https://api.github.com/repos/${parsedSource.repo}/actions/workflows/${encodeURIComponent(parsedPanel.pipeline)}/runs`
732
1612
  );
@@ -734,41 +1614,820 @@ function permittedGithubActionsCalls(panel, source, _credentials) {
734
1614
  url.searchParams.set("per_page", "1");
735
1615
  return [{ url: url.toString(), headers: new Headers() }];
736
1616
  }
737
- function pullRequestHealthCapabilities(panel) {
738
- const { panel: parsed } = z7.object({ panel: pullRequestHealthPanelSchema }).parse({ panel });
1617
+ function testCountCapabilities(panel, source) {
1618
+ return z7.object({ panel: testCountPanelSchema, source: githubActionsSourceSchema }).parse({ panel, source });
1619
+ }
1620
+ async function fetchGithubActionsTestCount(args2) {
1621
+ const { panel, source } = testCountCapabilities(args2.panel, args2.source);
1622
+ const githubClient = githubClientFor(args2);
1623
+ const noValidators = new Headers();
1624
+ let failureLink = sourceLinkForWorkflow(source, panel.pipeline);
1625
+ let failureObservedAt;
1626
+ try {
1627
+ const selected = await selectGithubWorkflowRun({
1628
+ ...args2,
1629
+ source,
1630
+ workflow: panel.pipeline,
1631
+ requestHeaders: noValidators,
1632
+ githubClient
1633
+ });
1634
+ if (!selected.response.ok) return testCountFailure(panel.id, source, selected.response);
1635
+ const { run: run2 } = selected;
1636
+ if (!run2?.id)
1637
+ return testCountEnvelope(
1638
+ noRunEnvelope(panel.id, source, panel.pipeline, selected.response.headers.get("date"))
1639
+ );
1640
+ const link = run2.html_url;
1641
+ const runObservedAt = selected.observedAt;
1642
+ failureLink = link;
1643
+ failureObservedAt = runObservedAt;
1644
+ if (run2.status !== "completed")
1645
+ return testCountEnvelope({
1646
+ panelId: panel.id,
1647
+ state: "ok",
1648
+ observedAt: runObservedAt,
1649
+ link,
1650
+ signal: { type: "test-count", status: "pending" }
1651
+ });
1652
+ const artifactsResponse = await githubFetch(
1653
+ githubArtifactsCall(source, run2.id, panel.test_results),
1654
+ {
1655
+ ...args2,
1656
+ source,
1657
+ requestHeaders: noValidators,
1658
+ githubClient
1659
+ }
1660
+ );
1661
+ if (!artifactsResponse.ok) return testCountFailure(panel.id, source, artifactsResponse, link);
1662
+ const artifactObservedAt = observedAt2(artifactsResponse.headers.get("date"));
1663
+ failureObservedAt = oldestObservation(runObservedAt, artifactObservedAt);
1664
+ const artifacts = artifactsSchema.parse(await artifactsResponse.json()).artifacts;
1665
+ const matches = artifacts.filter((artifact2) => artifact2.name === panel.test_results.artifact);
1666
+ if (matches.length === 0)
1667
+ return testCountEnvelope({
1668
+ panelId: panel.id,
1669
+ state: "ok",
1670
+ observedAt: oldestObservation(runObservedAt, artifactObservedAt),
1671
+ link,
1672
+ signal: { type: "test-count", status: "not-reported" }
1673
+ });
1674
+ if (matches.length !== 1 || matches[0]?.expired)
1675
+ return testCountEnvelope(
1676
+ errorEnvelope(
1677
+ panel.id,
1678
+ "upstream-error",
1679
+ "The test-results artifact is unavailable.",
1680
+ link
1681
+ )
1682
+ );
1683
+ const [artifact] = matches;
1684
+ if (!artifact)
1685
+ return testCountEnvelope(
1686
+ errorEnvelope(
1687
+ panel.id,
1688
+ "upstream-error",
1689
+ "The test-results artifact is unavailable.",
1690
+ link
1691
+ )
1692
+ );
1693
+ const archiveResponse = await githubFetch(githubArtifactDownloadCall(source, artifact.id), {
1694
+ ...args2,
1695
+ source,
1696
+ requestHeaders: noValidators,
1697
+ githubClient
1698
+ });
1699
+ if (!archiveResponse.ok) return testCountFailure(panel.id, source, archiveResponse, link);
1700
+ const archiveObservedAt = observedAt2(archiveResponse.headers.get("date"));
1701
+ failureObservedAt = oldestObservation(runObservedAt, artifactObservedAt, archiveObservedAt);
1702
+ const summary = testResultsSummarySchema.parse(
1703
+ JSON.parse(await readTestResultsArtifact(archiveResponse, panel.test_results.entry))
1704
+ );
1705
+ if (summary.runId !== run2.id || summary.runAttempt !== run2.run_attempt || summary.headSha !== run2.head_sha)
1706
+ throw new Error("Test-results manifest does not belong to the selected workflow run.");
1707
+ return testCountEnvelope({
1708
+ panelId: panel.id,
1709
+ state: "ok",
1710
+ observedAt: oldestObservation(runObservedAt, artifactObservedAt, archiveObservedAt),
1711
+ link,
1712
+ signal: {
1713
+ type: "test-count",
1714
+ status: "reported",
1715
+ total: summary.total,
1716
+ ...summary.passed === void 0 ? {} : { passed: summary.passed },
1717
+ ...summary.failed === void 0 ? {} : { failed: summary.failed },
1718
+ ...summary.skipped === void 0 ? {} : { skipped: summary.skipped }
1719
+ }
1720
+ });
1721
+ } catch (error) {
1722
+ return testCountEnvelope(
1723
+ errorEnvelope(
1724
+ panel.id,
1725
+ error instanceof GithubAuthenticationError ? "unauthorized" : "upstream-error",
1726
+ error,
1727
+ failureLink,
1728
+ failureObservedAt
1729
+ )
1730
+ );
1731
+ }
1732
+ }
1733
+ function pullRequestHealthCapabilities(panel) {
1734
+ const { panel: parsed } = z7.object({ panel: pullRequestHealthPanelSchema }).parse({ panel });
1735
+ return {
1736
+ panel: parsed,
1737
+ configuredUpdateWorkflow(workflow) {
1738
+ return parsed.update_workflows.find((candidate) => candidate.workflow === workflow);
1739
+ },
1740
+ permitsBuildBranch(branch) {
1741
+ return parsed.update_workflows.some(
1742
+ ({ branch_prefixes }) => branch_prefixes.some((prefix) => branch.startsWith(prefix))
1743
+ );
1744
+ }
1745
+ };
1746
+ }
1747
+ function githubRunsCall(source, workflow, branch, event, perPage = 1, created) {
1748
+ const url = new URL(
1749
+ `https://api.github.com/repos/${source.repo}/actions/workflows/${encodeURIComponent(workflow)}/runs`
1750
+ );
1751
+ if (branch) url.searchParams.set("branch", branch);
1752
+ if (event) url.searchParams.set("event", event);
1753
+ if (created) url.searchParams.set("created", `>=${created}`);
1754
+ url.searchParams.set("per_page", String(perPage));
1755
+ return { url: url.toString(), headers: new Headers() };
1756
+ }
1757
+ function sourceLinkForRepository(source) {
1758
+ return `https://github.com/${source.repo}`;
1759
+ }
1760
+ async function fetchGithubActionsPipeline(args2) {
1761
+ const parsedSource = githubActionsSourceSchema.parse(args2.source);
1762
+ const parsedPanel = pipelinePanelSchema.parse(args2.panel);
1763
+ const githubClient = githubClientFor(args2);
1764
+ let selected;
1765
+ try {
1766
+ selected = await selectGithubWorkflowRun({
1767
+ ...args2,
1768
+ source: parsedSource,
1769
+ workflow: parsedPanel.pipeline,
1770
+ githubClient
1771
+ });
1772
+ } catch (error) {
1773
+ return {
1774
+ response: new Response(
1775
+ JSON.stringify(
1776
+ errorEnvelope(
1777
+ args2.panel.id,
1778
+ error instanceof GithubAuthenticationError ? "unauthorized" : "unreachable",
1779
+ error,
1780
+ sourceLink(args2.panel, args2.source)
1781
+ )
1782
+ ),
1783
+ { status: 200 }
1784
+ ),
1785
+ failure: {
1786
+ kind: error instanceof GithubAuthenticationError ? "unauthorized" : "unreachable",
1787
+ ...safeNetworkCode(error) ? { networkCode: safeNetworkCode(error) } : {}
1788
+ }
1789
+ };
1790
+ }
1791
+ const upstream = selected.response;
1792
+ if (upstream.status === 304) return { response: upstream };
1793
+ if (!upstream.ok) return githubPipelineFailure(args2, upstream);
1794
+ try {
1795
+ const run2 = selected.run;
1796
+ if (!run2) {
1797
+ return {
1798
+ response: new Response(
1799
+ JSON.stringify(
1800
+ errorEnvelope(
1801
+ args2.panel.id,
1802
+ "no-runs",
1803
+ parsedSource.branch ? `No workflow runs found for branch "${parsedSource.branch}". Check the source's branch setting.` : "No workflow runs found.",
1804
+ sourceLink(args2.panel, args2.source),
1805
+ observedAt2(upstream.headers.get("date"))
1806
+ )
1807
+ ),
1808
+ { status: 200 }
1809
+ ),
1810
+ failure: { kind: "no-runs", upstreamStatus: upstream.status }
1811
+ };
1812
+ }
1813
+ const signal = {
1814
+ type: "pipeline-status",
1815
+ status: normalizeStatus(run2.status, run2.conclusion),
1816
+ rawStatus: run2.conclusion ?? run2.status,
1817
+ name: run2.name,
1818
+ ...run2.head_branch ?? parsedSource.branch ? { branch: run2.head_branch ?? parsedSource.branch } : {},
1819
+ ...timestamp(run2.updated_at) ? { sourceUpdatedAt: timestamp(run2.updated_at) } : {},
1820
+ ...timestamp(run2.run_started_at) ? { runStartedAt: timestamp(run2.run_started_at) } : {},
1821
+ ...run2.id !== void 0 ? { sourceRunId: String(run2.id) } : {},
1822
+ ...run2.status === "completed" ? completedRunDuration(run2) : {}
1823
+ };
1824
+ if (signal.status === "running" && run2.id !== void 0) {
1825
+ const activity = await activeGithubActivity({
1826
+ source: parsedSource,
1827
+ runId: run2.id,
1828
+ requestHeaders: args2.requestHeaders,
1829
+ fetcher: args2.fetcher,
1830
+ githubClient: githubClientFor(args2)
1831
+ });
1832
+ if (activity) signal.activity = activity;
1833
+ }
1834
+ const envelope = {
1835
+ panelId: args2.panel.id,
1836
+ state: "ok",
1837
+ observedAt: observedAt2(upstream.headers.get("date")),
1838
+ link: run2.html_url,
1839
+ signal
1840
+ };
1841
+ return { envelope, response: upstream };
1842
+ } catch (error) {
1843
+ return {
1844
+ response: new Response(
1845
+ JSON.stringify(
1846
+ errorEnvelope(
1847
+ args2.panel.id,
1848
+ "upstream-error",
1849
+ error,
1850
+ sourceLink(args2.panel, args2.source),
1851
+ observedAt2(upstream.headers.get("date"))
1852
+ )
1853
+ ),
1854
+ { status: 200 }
1855
+ ),
1856
+ failure: { kind: "upstream-error", upstreamStatus: upstream.status }
1857
+ };
1858
+ }
1859
+ }
1860
+ function githubPipelineFailure(args2, upstream) {
1861
+ return {
1862
+ response: new Response(
1863
+ JSON.stringify(
1864
+ errorEnvelope(
1865
+ args2.panel.id,
1866
+ errorKind(upstream.status),
1867
+ `${upstream.status} ${upstream.statusText}`,
1868
+ sourceLink(args2.panel, args2.source),
1869
+ observedAt2(upstream.headers.get("date"))
1870
+ )
1871
+ ),
1872
+ { status: 200 }
1873
+ ),
1874
+ failure: { kind: errorKind(upstream.status), upstreamStatus: upstream.status }
1875
+ };
1876
+ }
1877
+ function recentRunsCreatedAt(now = /* @__PURE__ */ new Date()) {
1878
+ return new Date(now.valueOf() - 30 * 24 * 60 * 60 * 1e3).toISOString();
1879
+ }
1880
+ function newestGithubRun(runs) {
1881
+ return runs.reduce((newest, candidate) => {
1882
+ if (!newest) return candidate;
1883
+ const candidateCreatedAt = Date.parse(candidate.created_at ?? "");
1884
+ const newestCreatedAt = Date.parse(newest.created_at ?? "");
1885
+ if (candidateCreatedAt > newestCreatedAt) return candidate;
1886
+ if (candidateCreatedAt < newestCreatedAt) return newest;
1887
+ return (candidate.id ?? 0) > (newest.id ?? 0) ? candidate : newest;
1888
+ }, void 0);
1889
+ }
1890
+ async function selectGithubWorkflowRun(args2) {
1891
+ let response = await githubFetch(
1892
+ githubRunsCall(
1893
+ args2.source,
1894
+ args2.workflow,
1895
+ args2.source.branch,
1896
+ void 0,
1897
+ 100,
1898
+ recentRunsCreatedAt()
1899
+ ),
1900
+ args2
1901
+ );
1902
+ if (response.status === 304 || !response.ok)
1903
+ return { response, observedAt: observedAt2(response.headers.get("date")), run: void 0 };
1904
+ let runs = runsSchema.parse(await response.json()).workflow_runs;
1905
+ if (runs.length === 0) {
1906
+ response = await githubFetch(
1907
+ githubRunsCall(args2.source, args2.workflow, args2.source.branch),
1908
+ args2
1909
+ );
1910
+ if (response.status === 304 || !response.ok)
1911
+ return { response, observedAt: observedAt2(response.headers.get("date")), run: void 0 };
1912
+ runs = runsSchema.parse(await response.json()).workflow_runs;
1913
+ }
1914
+ return {
1915
+ response,
1916
+ observedAt: observedAt2(response.headers.get("date")),
1917
+ run: newestGithubRun(runs)
1918
+ };
1919
+ }
1920
+ async function activeGithubActivity(args2) {
1921
+ const call = githubJobsCall(args2.source, args2.runId);
1922
+ try {
1923
+ const response = await githubFetch(call, args2);
1924
+ if (!response.ok) return void 0;
1925
+ const jobs = jobsSchema.parse(await response.json()).jobs;
1926
+ const job = jobs.find((candidate) => candidate.status === "in_progress") ?? jobs.find((candidate) => candidate.status === "queued");
1927
+ if (!job) return void 0;
1928
+ const step = job.steps?.find((candidate) => candidate.status === "in_progress");
1929
+ return step ? { kind: "step", name: step.name, parent: job.name } : { kind: "job", name: job.name };
1930
+ } catch {
1931
+ return void 0;
1932
+ }
1933
+ }
1934
+ async function githubFetch(call, args2) {
1935
+ return args2.githubClient.get({
1936
+ source: args2.source,
1937
+ url: call.url,
1938
+ requestHeaders: args2.requestHeaders,
1939
+ fetcher: args2.fetcher
1940
+ });
1941
+ }
1942
+ function githubClientFor(args2) {
1943
+ return args2.githubClient ?? createGithubClient(args2.credentials ?? environmentCredentials());
1944
+ }
1945
+ function githubJobsCall(source, runId) {
1946
+ const url = new URL(`https://api.github.com/repos/${source.repo}/actions/runs/${runId}/jobs`);
1947
+ url.searchParams.set("per_page", "100");
1948
+ return { url: url.toString(), headers: new Headers() };
1949
+ }
1950
+ function githubArtifactsCall(source, runId, testResults) {
1951
+ const url = new URL(`https://api.github.com/repos/${source.repo}/actions/runs/${runId}/artifacts`);
1952
+ url.searchParams.set("name", testResults.artifact);
1953
+ url.searchParams.set("per_page", "100");
1954
+ return { url: url.toString(), headers: new Headers() };
1955
+ }
1956
+ function githubArtifactDownloadCall(source, artifactId) {
1957
+ return {
1958
+ url: `https://api.github.com/repos/${source.repo}/actions/artifacts/${artifactId}/zip`,
1959
+ headers: new Headers()
1960
+ };
1961
+ }
1962
+ function noRunEnvelope(panelId, source, pipeline, date) {
1963
+ return {
1964
+ panelId,
1965
+ state: "error",
1966
+ observedAt: observedAt2(date),
1967
+ link: sourceLinkForWorkflow(source, pipeline),
1968
+ error: {
1969
+ kind: "no-runs",
1970
+ message: "No matching workflow runs were found. Check the configured workflow and branch."
1971
+ }
1972
+ };
1973
+ }
1974
+ function testCountFailure(panelId, source, response, link = sourceLinkForRepository(source)) {
1975
+ return testCountEnvelope(
1976
+ errorEnvelope(
1977
+ panelId,
1978
+ errorKind(response.status),
1979
+ `${response.status} ${response.statusText}`,
1980
+ link,
1981
+ observedAt2(response.headers.get("date"))
1982
+ ),
1983
+ { kind: errorKind(response.status), upstreamStatus: response.status }
1984
+ );
1985
+ }
1986
+ function testCountEnvelope(envelope, failure2) {
1987
+ return { envelope, response: new Response(null), ...failure2 ? { failure: failure2 } : {} };
1988
+ }
1989
+ function oldestObservation(...values) {
1990
+ return values.reduce((oldest, value2) => Date.parse(value2) < Date.parse(oldest) ? value2 : oldest);
1991
+ }
1992
+ function completedRunDuration(run2) {
1993
+ const startedAt = timestamp(run2.run_started_at);
1994
+ const updatedAt = timestamp(run2.updated_at);
1995
+ if (!startedAt || !updatedAt) return {};
1996
+ const durationMs = new Date(updatedAt).valueOf() - new Date(startedAt).valueOf();
1997
+ return Number.isFinite(durationMs) && durationMs >= 0 ? { durationMs } : {};
1998
+ }
1999
+ function timestamp(value2) {
2000
+ if (!value2 || !z7.iso.datetime().safeParse(value2).success) return void 0;
2001
+ return Number.isFinite(new Date(value2).valueOf()) ? value2 : void 0;
2002
+ }
2003
+ function normalizeStatus(status, conclusion) {
2004
+ if (status !== "completed") return "running";
2005
+ if (conclusion === "success") return "passed";
2006
+ if (conclusion === "failure" || conclusion === "timed_out") return "failed";
2007
+ if (conclusion === "cancelled") return "cancelled";
2008
+ return "unknown";
2009
+ }
2010
+ function errorKind(status) {
2011
+ return upstreamErrorKind(status);
2012
+ }
2013
+ function errorEnvelope(panelId, kind, error, link, observedAt4 = (/* @__PURE__ */ new Date()).toISOString()) {
2014
+ return upstreamErrorEnvelope({ panelId, kind, error, link, upstreamDate: observedAt4 });
2015
+ }
2016
+ function sourceLink(panel, source) {
2017
+ const parsedPanel = z7.object({ pipeline: z7.string().min(1) }).parse(panel);
2018
+ const parsedSource = githubActionsSourceSchema.parse(source);
2019
+ return sourceLinkForWorkflow(parsedSource, parsedPanel.pipeline);
2020
+ }
2021
+ function sourceLinkForWorkflow(source, pipeline) {
2022
+ return `https://github.com/${source.repo}/actions/workflows/${encodeURIComponent(pipeline)}`;
2023
+ }
2024
+ function observedAt2(value2) {
2025
+ return observedAt(value2);
2026
+ }
2027
+
2028
+ // packages/server/src/configuration-error.ts
2029
+ var ConfigurationError = class extends Error {
2030
+ constructor(message2, diagnostics) {
2031
+ super(message2);
2032
+ this.diagnostics = diagnostics;
2033
+ }
2034
+ diagnostics;
2035
+ };
2036
+ function configurationLocation(path) {
2037
+ return path.reduce(
2038
+ (location, part) => typeof part === "number" ? `${location}[${part}]` : `${location}${location ? "." : ""}${String(part)}`,
2039
+ ""
2040
+ ) || "configuration";
2041
+ }
2042
+ function boardConfigurationLocation(config, path) {
2043
+ const [record, key, ...rest] = path;
2044
+ if ((record === "boards" || record === "sources") && key !== void 0) {
2045
+ const entries = config && typeof config === "object" ? Reflect.get(config, record) : void 0;
2046
+ const index = entries && typeof entries === "object" ? Object.keys(entries).indexOf(String(key)) : -1;
2047
+ return configurationLocation([record, index, ...rest]);
2048
+ }
2049
+ return configurationLocation(path);
2050
+ }
2051
+ function schemaDiagnostics(error, locate, kind = "schema") {
2052
+ return error.issues.map((issue) => ({
2053
+ kind,
2054
+ location: locate(issue.path),
2055
+ constraint: correctiveConstraint(issue)
2056
+ }));
2057
+ }
2058
+ function correctiveConstraint(issue) {
2059
+ switch (issue.code) {
2060
+ case "invalid_type":
2061
+ return `Provide a value of type ${issue.expected}.`;
2062
+ case "too_big":
2063
+ return `Use ${issue.inclusive ? "at most" : "fewer than"} ${issue.maximum} ${issue.origin === "array" ? "entries" : issue.origin === "string" ? "characters" : "as the value"}.`;
2064
+ case "too_small":
2065
+ return `Use ${issue.inclusive ? "at least" : "more than"} ${issue.minimum} ${issue.origin === "array" ? "entries" : issue.origin === "string" ? "characters" : "as the value"}.`;
2066
+ // Format messages are fixed by our schemas (or Zod); unlike custom issues they contain no authored values.
2067
+ case "invalid_format":
2068
+ return issue.message;
2069
+ case "invalid_value":
2070
+ return "Use one of the values allowed by the board schema.";
2071
+ case "custom":
2072
+ return typeof issue.params?.constraint === "string" ? issue.params.constraint : "Correct this field according to the board schema.";
2073
+ default:
2074
+ return "Provide a value matching the board schema for this field.";
2075
+ }
2076
+ }
2077
+
2078
+ // packages/server/src/adapters/azure-devops.ts
2079
+ import { readFile } from "node:fs/promises";
2080
+ import { z as z8 } from "zod";
2081
+ var pipelinePanelSchema2 = z8.object({
2082
+ id: z8.string().min(1),
2083
+ type: z8.literal("pipeline-status"),
2084
+ source: z8.string().min(1),
2085
+ pipeline: z8.number().int().positive()
2086
+ });
2087
+ var buildSchema = z8.object({
2088
+ id: z8.number().int().positive(),
2089
+ buildNumber: z8.string().min(1),
2090
+ status: z8.string().nullable().optional(),
2091
+ result: z8.string().nullable().optional(),
2092
+ sourceBranch: z8.string().min(1).nullable().optional(),
2093
+ startTime: z8.string().nullable().optional(),
2094
+ finishTime: z8.string().nullable().optional(),
2095
+ lastChangedDate: z8.string().nullable().optional()
2096
+ });
2097
+ var buildsSchema = z8.object({ value: z8.array(buildSchema) });
2098
+ var timelineSchema = z8.object({
2099
+ records: z8.array(
2100
+ z8.object({
2101
+ id: z8.string().min(1),
2102
+ parentId: z8.string().min(1).nullable().optional(),
2103
+ type: z8.string().min(1),
2104
+ name: z8.string().min(1),
2105
+ state: z8.string().nullable().optional()
2106
+ })
2107
+ )
2108
+ });
2109
+ function permittedAzureDevOpsCalls(panel, source) {
2110
+ const { panel: parsedPanel, source: parsedSource } = z8.object({ panel: pipelinePanelSchema2, source: azureDevOpsSourceSchema }).parse({ panel, source });
2111
+ return [buildsCall(parsedPanel.pipeline, parsedSource)];
2112
+ }
2113
+ async function fetchAzureDevOpsPipeline(args2) {
2114
+ const panel = pipelinePanelSchema2.parse(args2.panel);
2115
+ const source = azureDevOpsSourceSchema.parse(args2.source);
2116
+ const authorization = await azureDevOpsAuthorization(source, args2.credentials);
2117
+ if (!authorization) {
2118
+ return {
2119
+ response: errorResponse(
2120
+ errorEnvelope2(
2121
+ panel.id,
2122
+ "unauthorized",
2123
+ "Azure DevOps credentials are not available.",
2124
+ sourceLink2(panel.pipeline, source)
2125
+ )
2126
+ ),
2127
+ failure: { kind: "unauthorized" }
2128
+ };
2129
+ }
2130
+ const call = buildsCall(panel.pipeline, source);
2131
+ copyValidators(args2.requestHeaders, call.headers);
2132
+ call.headers.set("authorization", authorization);
2133
+ let upstream;
2134
+ try {
2135
+ upstream = await args2.fetcher(call.url, { headers: call.headers });
2136
+ } catch (error) {
2137
+ return {
2138
+ response: errorResponse(
2139
+ errorEnvelope2(panel.id, "unreachable", error, sourceLink2(panel.pipeline, source))
2140
+ ),
2141
+ failure: {
2142
+ kind: "unreachable",
2143
+ ...safeNetworkCode(error) ? { networkCode: safeNetworkCode(error) } : {}
2144
+ }
2145
+ };
2146
+ }
2147
+ if (upstream.status === 304) return { response: upstream };
2148
+ if (!upstream.ok) {
2149
+ return {
2150
+ response: errorResponse(
2151
+ errorEnvelope2(
2152
+ panel.id,
2153
+ errorKind2(upstream.status),
2154
+ `${upstream.status} ${upstream.statusText}`,
2155
+ sourceLink2(panel.pipeline, source),
2156
+ observedAt3(upstream.headers.get("date"))
2157
+ )
2158
+ ),
2159
+ failure: { kind: errorKind2(upstream.status), upstreamStatus: upstream.status }
2160
+ };
2161
+ }
2162
+ try {
2163
+ const build = buildsSchema.parse(await upstream.json()).value[0];
2164
+ if (!build) {
2165
+ return {
2166
+ response: errorResponse(
2167
+ errorEnvelope2(
2168
+ panel.id,
2169
+ "no-runs",
2170
+ source.branch ? `No builds found for branch "${source.branch}". Check the source's branch setting.` : "No builds found.",
2171
+ sourceLink2(panel.pipeline, source),
2172
+ observedAt3(upstream.headers.get("date"))
2173
+ )
2174
+ ),
2175
+ failure: { kind: "no-runs", upstreamStatus: upstream.status }
2176
+ };
2177
+ }
2178
+ const signal = {
2179
+ type: "pipeline-status",
2180
+ status: normalizeStatus2(build.status, build.result),
2181
+ rawStatus: build.result ?? build.status ?? "unknown",
2182
+ name: build.buildNumber,
2183
+ ...build.sourceBranch ?? source.branch ? { branch: build.sourceBranch ?? source.branch } : {},
2184
+ ...timestamp2(build.startTime) ? { runStartedAt: timestamp2(build.startTime) } : {},
2185
+ ...timestamp2(build.lastChangedDate) ? { sourceUpdatedAt: timestamp2(build.lastChangedDate) } : {},
2186
+ sourceRunId: String(build.id),
2187
+ ...completedBuildDuration(build)
2188
+ };
2189
+ if (signal.status === "running") {
2190
+ const activity = await activeAzureDevOpsActivity({
2191
+ buildId: build.id,
2192
+ source,
2193
+ fetcher: args2.fetcher,
2194
+ authorization: call.headers.get("authorization") ?? ""
2195
+ });
2196
+ if (activity) signal.activity = activity;
2197
+ }
2198
+ return {
2199
+ envelope: {
2200
+ panelId: panel.id,
2201
+ state: "ok",
2202
+ observedAt: observedAt3(upstream.headers.get("date")),
2203
+ link: buildLink(build.id, source),
2204
+ signal
2205
+ },
2206
+ response: upstream
2207
+ };
2208
+ } catch (error) {
2209
+ return {
2210
+ response: errorResponse(
2211
+ errorEnvelope2(
2212
+ panel.id,
2213
+ "upstream-error",
2214
+ error,
2215
+ sourceLink2(panel.pipeline, source),
2216
+ observedAt3(upstream.headers.get("date"))
2217
+ )
2218
+ ),
2219
+ failure: { kind: "upstream-error", upstreamStatus: upstream.status }
2220
+ };
2221
+ }
2222
+ }
2223
+ var delegatedTokenFileSchema = z8.object({
2224
+ accessToken: z8.string().min(1),
2225
+ expiresAt: z8.string().min(1)
2226
+ });
2227
+ async function azureDevOpsAuthorization(source, credentials) {
2228
+ if (source.token_env) {
2229
+ const token = credentials.get(source.token_env);
2230
+ return token ? `Basic ${btoa(`:${token}`)}` : void 0;
2231
+ }
2232
+ if (!source.entra_token_file_env) return void 0;
2233
+ const tokenFile = credentials.get(source.entra_token_file_env);
2234
+ if (!tokenFile) return void 0;
2235
+ try {
2236
+ const token = delegatedTokenFileSchema.parse(JSON.parse(await readFile(tokenFile, "utf8")));
2237
+ const expiresAt = Date.parse(token.expiresAt);
2238
+ if (!Number.isFinite(expiresAt) || expiresAt <= Date.now()) return void 0;
2239
+ return `Bearer ${token.accessToken}`;
2240
+ } catch {
2241
+ return void 0;
2242
+ }
2243
+ }
2244
+ function buildsCall(definitionId, source) {
2245
+ const url = apiUrl(source, "build/builds");
2246
+ url.searchParams.set("definitions", String(definitionId));
2247
+ if (source.branch) url.searchParams.set("branchName", adoBranch(source.branch));
2248
+ url.searchParams.set("queryOrder", "queueTimeDescending");
2249
+ url.searchParams.set("$top", "1");
2250
+ return { url: url.toString(), headers: new Headers({ accept: "application/json" }) };
2251
+ }
2252
+ function timelineCall(buildId, source) {
739
2253
  return {
740
- panel: parsed,
741
- configuredUpdateWorkflow(workflow) {
742
- return parsed.update_workflows.find((candidate) => candidate.workflow === workflow);
743
- },
744
- permitsBuildBranch(branch) {
745
- return parsed.update_workflows.some(
746
- ({ branch_prefixes }) => branch_prefixes.some((prefix) => branch.startsWith(prefix))
747
- );
748
- }
2254
+ url: apiUrl(source, `build/builds/${buildId}/timeline`).toString(),
2255
+ headers: new Headers({ accept: "application/json" })
749
2256
  };
750
2257
  }
2258
+ function apiUrl(source, suffix) {
2259
+ const url = new URL(
2260
+ `https://dev.azure.com/${encodeURIComponent(source.organization)}/${encodeURIComponent(source.project)}/_apis/${suffix}`
2261
+ );
2262
+ url.searchParams.set("api-version", "7.1");
2263
+ return url;
2264
+ }
2265
+ function adoBranch(branch) {
2266
+ return branch.startsWith("refs/") ? branch : `refs/heads/${branch}`;
2267
+ }
2268
+ async function activeAzureDevOpsActivity(args2) {
2269
+ const call = timelineCall(args2.buildId, args2.source);
2270
+ call.headers.set("authorization", args2.authorization);
2271
+ try {
2272
+ const response = await args2.fetcher(call.url, { headers: call.headers });
2273
+ if (!response.ok) return void 0;
2274
+ const records = timelineSchema.parse(await response.json()).records;
2275
+ const active = records.find((record) => record.state === "inProgress");
2276
+ if (!active) return void 0;
2277
+ const parent = active.parentId ? records.find((record) => record.id === active.parentId) : void 0;
2278
+ const kind = active.type.toLowerCase();
2279
+ return {
2280
+ kind: kind === "stage" ? "stage" : kind === "job" ? "job" : "step",
2281
+ name: active.name,
2282
+ ...parent ? { parent: parent.name } : {}
2283
+ };
2284
+ } catch {
2285
+ return void 0;
2286
+ }
2287
+ }
2288
+ function normalizeStatus2(status, result) {
2289
+ if (status === "notStarted" || status === "postponed" || status === "inProgress" || status === "cancelling")
2290
+ return "running";
2291
+ if (status !== "completed") return "unknown";
2292
+ if (result === "succeeded") return "passed";
2293
+ if (result === "failed") return "failed";
2294
+ if (result === "partiallySucceeded") return "warning";
2295
+ if (result === "canceled") return "cancelled";
2296
+ return "unknown";
2297
+ }
2298
+ function completedBuildDuration(build) {
2299
+ const startedAt = timestamp2(build.startTime);
2300
+ const finishedAt = timestamp2(build.finishTime);
2301
+ if (!startedAt || !finishedAt) return {};
2302
+ const durationMs = new Date(finishedAt).valueOf() - new Date(startedAt).valueOf();
2303
+ return Number.isFinite(durationMs) && durationMs >= 0 ? { durationMs } : {};
2304
+ }
2305
+ function timestamp2(value2) {
2306
+ if (!value2 || !z8.iso.datetime().safeParse(value2).success) return void 0;
2307
+ return Number.isFinite(new Date(value2).valueOf()) ? value2 : void 0;
2308
+ }
2309
+ function copyValidators(requestHeaders, upstreamHeaders) {
2310
+ forwardValidators(requestHeaders, upstreamHeaders);
2311
+ }
2312
+ function buildLink(buildId, source) {
2313
+ return `https://dev.azure.com/${encodeURIComponent(source.organization)}/${encodeURIComponent(source.project)}/_build/results?buildId=${buildId}`;
2314
+ }
2315
+ function sourceLink2(definitionId, source) {
2316
+ return `https://dev.azure.com/${encodeURIComponent(source.organization)}/${encodeURIComponent(source.project)}/_build?definitionId=${definitionId}`;
2317
+ }
2318
+ function errorResponse(envelope) {
2319
+ return upstreamErrorResponse(envelope);
2320
+ }
2321
+ function errorEnvelope2(panelId, kind, error, link, date) {
2322
+ return upstreamErrorEnvelope({ panelId, kind, error, link, upstreamDate: date });
2323
+ }
2324
+ function errorKind2(status) {
2325
+ return upstreamErrorKind(status);
2326
+ }
2327
+ function observedAt3(value2) {
2328
+ return observedAt(value2);
2329
+ }
751
2330
 
752
2331
  // packages/server/src/adapters/gitlab-ci.ts
753
- import { z as z8 } from "zod";
754
- var pipelinePanelSchema3 = z8.object({
755
- id: z8.string().min(1),
756
- type: z8.literal("pipeline-status"),
757
- source: z8.string().min(1)
2332
+ import { z as z9 } from "zod";
2333
+ var pipelinePanelSchema3 = z9.object({
2334
+ id: z9.string().min(1),
2335
+ type: z9.literal("pipeline-status"),
2336
+ source: z9.string().min(1)
758
2337
  });
759
- var pipelineSchema = z8.object({
760
- id: z8.number().int().positive(),
761
- name: z8.string().min(1).nullable().optional(),
762
- status: z8.string(),
763
- ref: z8.string().min(1).nullable().optional(),
764
- created_at: z8.string().nullable().optional(),
765
- updated_at: z8.string().nullable().optional(),
766
- web_url: z8.url()
2338
+ var pipelineSchema = z9.object({
2339
+ id: z9.number().int().positive(),
2340
+ name: z9.string().min(1).nullable().optional(),
2341
+ status: z9.string(),
2342
+ ref: z9.string().min(1).nullable().optional(),
2343
+ created_at: z9.string().nullable().optional(),
2344
+ updated_at: z9.string().nullable().optional(),
2345
+ web_url: z9.url()
767
2346
  });
768
2347
  function permittedGitlabCiCalls(panel, source) {
769
- const { source: parsedSource } = z8.object({ panel: pipelinePanelSchema3, source: gitlabCiSourceSchema }).parse({ panel, source });
2348
+ const { source: parsedSource } = z9.object({ panel: pipelinePanelSchema3, source: gitlabCiSourceSchema }).parse({ panel, source });
770
2349
  return [pipelinesCall(parsedSource)];
771
2350
  }
2351
+ async function fetchGitlabCiPipeline(args2) {
2352
+ const panel = pipelinePanelSchema3.parse(args2.panel);
2353
+ const source = gitlabCiSourceSchema.parse(args2.source);
2354
+ const token = args2.credentials.get(source.token_env);
2355
+ if (!token)
2356
+ return failure(
2357
+ panel.id,
2358
+ "unauthorized",
2359
+ "GitLab credentials are not available.",
2360
+ sourceLink3(source)
2361
+ );
2362
+ const call = pipelinesCall(source);
2363
+ forwardValidators(args2.requestHeaders, call.headers);
2364
+ call.headers.set("private-token", token);
2365
+ let upstream;
2366
+ try {
2367
+ upstream = await args2.fetcher(call.url, { headers: call.headers });
2368
+ } catch (error) {
2369
+ return failure(panel.id, "unreachable", error, sourceLink3(source), void 0, {
2370
+ kind: "unreachable",
2371
+ ...safeNetworkCode(error) ? { networkCode: safeNetworkCode(error) } : {}
2372
+ });
2373
+ }
2374
+ if (upstream.status === 304) return { response: upstream };
2375
+ if (!upstream.ok) {
2376
+ const kind = upstreamErrorKind(upstream.status);
2377
+ return failure(
2378
+ panel.id,
2379
+ kind,
2380
+ `${upstream.status} ${upstream.statusText}`,
2381
+ sourceLink3(source),
2382
+ upstream.headers.get("date"),
2383
+ { kind, upstreamStatus: upstream.status }
2384
+ );
2385
+ }
2386
+ try {
2387
+ const pipeline = z9.array(pipelineSchema).parse(await upstream.json())[0];
2388
+ if (!pipeline) {
2389
+ const detail = source.branch ? `No pipelines found for ref "${source.branch}". Check the source's branch setting.` : "No pipelines found.";
2390
+ return failure(
2391
+ panel.id,
2392
+ "no-runs",
2393
+ detail,
2394
+ sourceLink3(source),
2395
+ upstream.headers.get("date"),
2396
+ {
2397
+ kind: "no-runs",
2398
+ upstreamStatus: upstream.status
2399
+ }
2400
+ );
2401
+ }
2402
+ const signal = {
2403
+ type: "pipeline-status",
2404
+ status: normalizeStatus3(pipeline.status),
2405
+ rawStatus: pipeline.status,
2406
+ name: pipeline.name ?? `Pipeline #${pipeline.id}`,
2407
+ ...pipeline.ref ?? source.branch ? { branch: pipeline.ref ?? source.branch } : {},
2408
+ ...timestamp3(pipeline.created_at) ? { runStartedAt: timestamp3(pipeline.created_at) } : {},
2409
+ ...timestamp3(pipeline.updated_at) ? { sourceUpdatedAt: timestamp3(pipeline.updated_at) } : {},
2410
+ sourceRunId: String(pipeline.id)
2411
+ };
2412
+ const envelope = {
2413
+ panelId: panel.id,
2414
+ state: "ok",
2415
+ observedAt: observedAt(upstream.headers.get("date")),
2416
+ link: publicLink(pipeline.web_url),
2417
+ signal
2418
+ };
2419
+ return { envelope, response: upstream };
2420
+ } catch (error) {
2421
+ return failure(
2422
+ panel.id,
2423
+ "upstream-error",
2424
+ error,
2425
+ sourceLink3(source),
2426
+ upstream.headers.get("date"),
2427
+ { kind: "upstream-error", upstreamStatus: upstream.status }
2428
+ );
2429
+ }
2430
+ }
772
2431
  function pipelinesCall(source) {
773
2432
  const url = new URL(source.url);
774
2433
  url.pathname = `${url.pathname.replace(/\/$/, "")}/api/v4/projects/${encodeURIComponent(source.project)}/pipelines`;
@@ -776,69 +2435,169 @@ function pipelinesCall(source) {
776
2435
  if (source.branch) url.searchParams.set("ref", source.branch);
777
2436
  return { url: url.toString(), headers: new Headers({ accept: "application/json" }) };
778
2437
  }
2438
+ function sourceLink3(source) {
2439
+ const url = new URL(source.url);
2440
+ url.pathname = `${url.pathname.replace(/\/$/, "")}/${source.project.split("/").map(encodeURIComponent).join("/")}/-/pipelines`;
2441
+ return url.toString();
2442
+ }
2443
+ function normalizeStatus3(status) {
2444
+ if (["created", "waiting_for_resource", "preparing", "pending", "running"].includes(status))
2445
+ return "running";
2446
+ if (status === "success") return "passed";
2447
+ if (status === "failed") return "failed";
2448
+ if (status === "canceled") return "cancelled";
2449
+ if (["manual", "skipped", "scheduled"].includes(status)) return "warning";
2450
+ return "unknown";
2451
+ }
2452
+ function timestamp3(value2) {
2453
+ if (!value2 || !z9.iso.datetime().safeParse(value2).success) return void 0;
2454
+ return Number.isFinite(new Date(value2).valueOf()) ? value2 : void 0;
2455
+ }
2456
+ function failure(panelId, kind, error, link, date, failure2) {
2457
+ return {
2458
+ response: upstreamErrorResponse(
2459
+ upstreamErrorEnvelope({ panelId, kind, error, link, upstreamDate: date })
2460
+ ),
2461
+ ...failure2 ? { failure: failure2 } : { failure: { kind } }
2462
+ };
2463
+ }
779
2464
 
780
2465
  // packages/server/src/adapters/http-value.ts
781
- import { z as z9 } from "zod";
2466
+ import { z as z10 } from "zod";
782
2467
  function permittedHttpValueCalls(panel) {
783
2468
  const grouped = httpValueGroupedPanelSchema.safeParse(panel);
784
- const urls = grouped.success ? grouped.data.facts.map((fact) => fact.url) : [z9.object({ panel: httpValueScalarPanelSchema }).parse({ panel }).panel.url];
2469
+ const urls = grouped.success ? grouped.data.facts.map((fact) => fact.url) : [z10.object({ panel: httpValueScalarPanelSchema }).parse({ panel }).panel.url];
785
2470
  return urls.map(permittedCall);
786
2471
  }
2472
+ async function fetchHttpValue(args2) {
2473
+ const panel = httpValueScalarPanelSchema.parse(args2.panel);
2474
+ const [call] = permittedHttpValueCalls(args2.panel);
2475
+ if (!call) throw new Error("http-value adapter declared no permitted call");
2476
+ forwardValidators(args2.requestHeaders, call.headers);
2477
+ let upstream;
2478
+ try {
2479
+ upstream = await args2.fetcher(call.url, { headers: call.headers });
2480
+ } catch (error) {
2481
+ return {
2482
+ response: errorResponse2("unreachable", error, panel),
2483
+ failure: {
2484
+ kind: "unreachable",
2485
+ ...safeNetworkCode(error) ? { networkCode: safeNetworkCode(error) } : {}
2486
+ }
2487
+ };
2488
+ }
2489
+ if (upstream.status === 304) return { response: upstream };
2490
+ if (!upstream.ok) {
2491
+ return {
2492
+ response: errorResponse2(
2493
+ upstreamErrorKind(upstream.status),
2494
+ `${upstream.status} ${upstream.statusText}`,
2495
+ panel,
2496
+ upstream
2497
+ ),
2498
+ failure: { kind: upstreamErrorKind(upstream.status), upstreamStatus: upstream.status }
2499
+ };
2500
+ }
2501
+ try {
2502
+ const text = await upstream.text();
2503
+ const value2 = panel.json_path ? extractJsonPath(JSON.parse(text), panel.json_path) : parseValue(text);
2504
+ const signal = { type: "http-value", value: value2 };
2505
+ return {
2506
+ envelope: {
2507
+ panelId: panel.id,
2508
+ state: "ok",
2509
+ observedAt: observedAt(upstream.headers.get("date")),
2510
+ link: publicLink(panel.link ?? panel.url),
2511
+ signal
2512
+ },
2513
+ response: upstream
2514
+ };
2515
+ } catch (error) {
2516
+ return {
2517
+ response: errorResponse2("upstream-error", error, panel, upstream),
2518
+ failure: { kind: "upstream-error", upstreamStatus: upstream.status }
2519
+ };
2520
+ }
2521
+ }
787
2522
  function permittedCall(value2) {
788
2523
  const url = new URL(value2);
789
2524
  if (url.protocol !== "http:" && url.protocol !== "https:")
790
2525
  throw new Error("http-value URLs must use http or https");
791
2526
  return { url: url.toString(), headers: new Headers({ accept: "application/json, text/plain" }) };
792
2527
  }
793
-
794
- // packages/server/src/configuration-error.ts
795
- var ConfigurationError = class extends Error {
796
- constructor(message2, diagnostics) {
797
- super(message2);
798
- this.diagnostics = diagnostics;
2528
+ function parseValue(text) {
2529
+ const trimmed = text.trim();
2530
+ try {
2531
+ const parsed = JSON.parse(trimmed);
2532
+ if (typeof parsed === "string" || typeof parsed === "number" || typeof parsed === "boolean")
2533
+ return parsed;
2534
+ } catch {
799
2535
  }
800
- diagnostics;
801
- };
802
- function configurationLocation(path) {
803
- return path.reduce(
804
- (location, part) => typeof part === "number" ? `${location}[${part}]` : `${location}${location ? "." : ""}${String(part)}`,
805
- ""
806
- ) || "configuration";
2536
+ return trimmed;
807
2537
  }
808
- function boardConfigurationLocation(config, path) {
809
- const [record, key, ...rest] = path;
810
- if ((record === "boards" || record === "sources") && key !== void 0) {
811
- const entries = config && typeof config === "object" ? Reflect.get(config, record) : void 0;
812
- const index = entries && typeof entries === "object" ? Object.keys(entries).indexOf(String(key)) : -1;
813
- return configurationLocation([record, index, ...rest]);
2538
+ function extractJsonPath(value2, path) {
2539
+ let current = value2;
2540
+ const segments = path === "$" ? [] : path.slice(1).split(/\.|\[|\]/).filter(Boolean);
2541
+ for (const segment of segments) {
2542
+ if (typeof current !== "object" || current === null || !(segment in current))
2543
+ throw new Error(`JSON path ${path} was not found`);
2544
+ current = current[segment];
814
2545
  }
815
- return configurationLocation(path);
2546
+ if (typeof current !== "string" && typeof current !== "number" && typeof current !== "boolean") {
2547
+ throw new Error(`JSON path ${path} did not select a scalar value`);
2548
+ }
2549
+ return current;
816
2550
  }
817
- function schemaDiagnostics(error, locate, kind = "schema") {
818
- return error.issues.map((issue) => ({
819
- kind,
820
- location: locate(issue.path),
821
- constraint: correctiveConstraint(issue)
822
- }));
2551
+ function errorResponse2(kind, error, panel, response) {
2552
+ return upstreamErrorResponse(
2553
+ upstreamErrorEnvelope({
2554
+ panelId: panel.id,
2555
+ kind,
2556
+ error,
2557
+ link: panel.link ?? panel.url,
2558
+ upstreamDate: response?.headers.get("date")
2559
+ })
2560
+ );
823
2561
  }
824
- function correctiveConstraint(issue) {
825
- switch (issue.code) {
826
- case "invalid_type":
827
- return `Provide a value of type ${issue.expected}.`;
828
- case "too_big":
829
- return `Use ${issue.inclusive ? "at most" : "fewer than"} ${issue.maximum} ${issue.origin === "array" ? "entries" : issue.origin === "string" ? "characters" : "as the value"}.`;
830
- case "too_small":
831
- return `Use ${issue.inclusive ? "at least" : "more than"} ${issue.minimum} ${issue.origin === "array" ? "entries" : issue.origin === "string" ? "characters" : "as the value"}.`;
832
- // Format messages are fixed by our schemas (or Zod); unlike custom issues they contain no authored values.
833
- case "invalid_format":
834
- return issue.message;
835
- case "invalid_value":
836
- return "Use one of the values allowed by the board schema.";
837
- case "custom":
838
- return typeof issue.params?.constraint === "string" ? issue.params.constraint : "Correct this field according to the board schema.";
839
- default:
840
- return "Provide a value matching the board schema for this field.";
2562
+
2563
+ // packages/server/src/panel-adapters.ts
2564
+ function readPanelAdapter(panel, source) {
2565
+ if (panel.type === "pipeline-status" && source?.type === "github-actions") {
2566
+ permittedGithubActionsCalls(panel, source);
2567
+ return {
2568
+ destination: () => "https://api.github.com",
2569
+ fetch: ({ source: _configuredSource, ...args2 }) => fetchGithubActionsPipeline({ ...args2, source })
2570
+ };
2571
+ }
2572
+ if (panel.type === "test-count" && source?.type === "github-actions") {
2573
+ testCountCapabilities(panel, source);
2574
+ return {
2575
+ destination: () => "https://api.github.com",
2576
+ fetch: ({ source: _configuredSource, ...args2 }) => fetchGithubActionsTestCount({ ...args2, source })
2577
+ };
2578
+ }
2579
+ if (panel.type === "pipeline-status" && source?.type === "azure-devops") {
2580
+ permittedAzureDevOpsCalls(panel, source);
2581
+ return {
2582
+ destination: () => "https://dev.azure.com",
2583
+ fetch: ({ source: _configuredSource, ...args2 }) => fetchAzureDevOpsPipeline({ ...args2, source })
2584
+ };
2585
+ }
2586
+ if (panel.type === "pipeline-status" && source?.type === "gitlab-ci") {
2587
+ permittedGitlabCiCalls(panel, source);
2588
+ return {
2589
+ destination: (_panel, resolvedSource) => resolvedSource && "url" in resolvedSource && typeof resolvedSource.url === "string" ? resolvedSource.url : "https://gitlab.com",
2590
+ fetch: ({ source: _configuredSource, ...args2 }) => fetchGitlabCiPipeline({ ...args2, source })
2591
+ };
2592
+ }
2593
+ if (panel.type === "http-value") {
2594
+ permittedHttpValueCalls(panel);
2595
+ return {
2596
+ destination: (configuredPanel) => configuredPanel.url ?? "",
2597
+ ...panel.facts ? {} : { fetch: (args2) => fetchHttpValue(args2) }
2598
+ };
841
2599
  }
2600
+ return void 0;
842
2601
  }
843
2602
 
844
2603
  // packages/server/src/allowlist.ts
@@ -891,22 +2650,7 @@ function derive(config, rejectUnsupported) {
891
2650
  return allowed;
892
2651
  }
893
2652
  function panelCapability(panel, source) {
894
- if (panel.type === "pipeline-status" && source?.type === "github-actions") {
895
- permittedGithubActionsCalls(panel, source);
896
- return { kind: "server", operations: ["read"] };
897
- }
898
- if (panel.type === "pipeline-status" && source?.type === "azure-devops") {
899
- permittedAzureDevOpsCalls(panel, source);
900
- return { kind: "server", operations: ["read"] };
901
- }
902
- if (panel.type === "pipeline-status" && source?.type === "gitlab-ci") {
903
- permittedGitlabCiCalls(panel, source);
904
- return { kind: "server", operations: ["read"] };
905
- }
906
- if (panel.type === "http-value") {
907
- permittedHttpValueCalls(panel);
908
- return { kind: "server", operations: ["read"] };
909
- }
2653
+ if (readPanelAdapter(panel, source)) return { kind: "server", operations: ["read"] };
910
2654
  if (panel.type === "pull-request-health" && source?.type === "github-actions") {
911
2655
  pullRequestHealthCapabilities(panel);
912
2656
  return {
@@ -1460,17 +3204,17 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
1460
3204
  // node_modules/fflate/esm/index.mjs
1461
3205
  import { createRequire } from "module";
1462
3206
  var require2 = createRequire("/");
1463
- var _a;
1464
- var Worker;
3207
+ var _a2;
3208
+ var Worker2;
1465
3209
  var isMarkedAsUntransferable;
1466
3210
  try {
1467
- _a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
3211
+ _a2 = require2("worker_threads"), Worker2 = _a2.Worker, isMarkedAsUntransferable = _a2.isMarkedAsUntransferable;
1468
3212
  } catch (e) {
1469
3213
  }
1470
- var u8 = Uint8Array;
1471
- var u16 = Uint16Array;
1472
- var i32 = Int32Array;
1473
- var fleb = new u8([
3214
+ var u82 = Uint8Array;
3215
+ var u162 = Uint16Array;
3216
+ var i322 = Int32Array;
3217
+ var fleb2 = new u82([
1474
3218
  0,
1475
3219
  0,
1476
3220
  0,
@@ -1506,7 +3250,7 @@ var fleb = new u8([
1506
3250
  /* impossible */
1507
3251
  0
1508
3252
  ]);
1509
- var fdeb = new u8([
3253
+ var fdeb2 = new u82([
1510
3254
  0,
1511
3255
  0,
1512
3256
  0,
@@ -1541,102 +3285,102 @@ var fdeb = new u8([
1541
3285
  0,
1542
3286
  0
1543
3287
  ]);
1544
- var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
1545
- var freb = function(eb, start) {
1546
- var b = new u16(31);
1547
- for (var i2 = 0; i2 < 31; ++i2) {
1548
- b[i2] = start += 1 << eb[i2 - 1];
3288
+ var clim2 = new u82([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
3289
+ var freb2 = function(eb, start) {
3290
+ var b = new u162(31);
3291
+ for (var i3 = 0; i3 < 31; ++i3) {
3292
+ b[i3] = start += 1 << eb[i3 - 1];
1549
3293
  }
1550
- var r = new i32(b[30]);
1551
- for (var i2 = 1; i2 < 30; ++i2) {
1552
- for (var j = b[i2]; j < b[i2 + 1]; ++j) {
1553
- r[j] = j - b[i2] << 5 | i2;
3294
+ var r = new i322(b[30]);
3295
+ for (var i3 = 1; i3 < 30; ++i3) {
3296
+ for (var j = b[i3]; j < b[i3 + 1]; ++j) {
3297
+ r[j] = j - b[i3] << 5 | i3;
1554
3298
  }
1555
3299
  }
1556
3300
  return { b, r };
1557
3301
  };
1558
- var _a = freb(fleb, 2);
1559
- var fl = _a.b;
1560
- var revfl = _a.r;
1561
- fl[28] = 258, revfl[258] = 28;
1562
- var _b = freb(fdeb, 0);
1563
- var fd = _b.b;
1564
- var revfd = _b.r;
1565
- var rev = new u16(32768);
1566
- for (i = 0; i < 32768; ++i) {
1567
- x = (i & 43690) >> 1 | (i & 21845) << 1;
1568
- x = (x & 52428) >> 2 | (x & 13107) << 2;
1569
- x = (x & 61680) >> 4 | (x & 3855) << 4;
1570
- rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
3302
+ var _a2 = freb2(fleb2, 2);
3303
+ var fl2 = _a2.b;
3304
+ var revfl2 = _a2.r;
3305
+ fl2[28] = 258, revfl2[258] = 28;
3306
+ var _b2 = freb2(fdeb2, 0);
3307
+ var fd2 = _b2.b;
3308
+ var revfd2 = _b2.r;
3309
+ var rev2 = new u162(32768);
3310
+ for (i2 = 0; i2 < 32768; ++i2) {
3311
+ x2 = (i2 & 43690) >> 1 | (i2 & 21845) << 1;
3312
+ x2 = (x2 & 52428) >> 2 | (x2 & 13107) << 2;
3313
+ x2 = (x2 & 61680) >> 4 | (x2 & 3855) << 4;
3314
+ rev2[i2] = ((x2 & 65280) >> 8 | (x2 & 255) << 8) >> 1;
1571
3315
  }
1572
- var x;
1573
- var i;
1574
- var hMap = (function(cd, mb, r) {
3316
+ var x2;
3317
+ var i2;
3318
+ var hMap2 = (function(cd, mb, r) {
1575
3319
  var s = cd.length;
1576
- var i2 = 0;
1577
- var l = new u16(mb);
1578
- for (; i2 < s; ++i2) {
1579
- if (cd[i2])
1580
- ++l[cd[i2] - 1];
3320
+ var i3 = 0;
3321
+ var l = new u162(mb);
3322
+ for (; i3 < s; ++i3) {
3323
+ if (cd[i3])
3324
+ ++l[cd[i3] - 1];
1581
3325
  }
1582
- var le = new u16(mb);
1583
- for (i2 = 1; i2 < mb; ++i2) {
1584
- le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
3326
+ var le = new u162(mb);
3327
+ for (i3 = 1; i3 < mb; ++i3) {
3328
+ le[i3] = le[i3 - 1] + l[i3 - 1] << 1;
1585
3329
  }
1586
3330
  var co;
1587
3331
  if (r) {
1588
- co = new u16(1 << mb);
3332
+ co = new u162(1 << mb);
1589
3333
  var rvb = 15 - mb;
1590
- for (i2 = 0; i2 < s; ++i2) {
1591
- if (cd[i2]) {
1592
- var sv = i2 << 4 | cd[i2];
1593
- var r_1 = mb - cd[i2];
1594
- var v = le[cd[i2] - 1]++ << r_1;
3334
+ for (i3 = 0; i3 < s; ++i3) {
3335
+ if (cd[i3]) {
3336
+ var sv = i3 << 4 | cd[i3];
3337
+ var r_1 = mb - cd[i3];
3338
+ var v = le[cd[i3] - 1]++ << r_1;
1595
3339
  for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
1596
- co[rev[v] >> rvb] = sv;
3340
+ co[rev2[v] >> rvb] = sv;
1597
3341
  }
1598
3342
  }
1599
3343
  }
1600
3344
  } else {
1601
- co = new u16(s);
1602
- for (i2 = 0; i2 < s; ++i2) {
1603
- if (cd[i2]) {
1604
- co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
3345
+ co = new u162(s);
3346
+ for (i3 = 0; i3 < s; ++i3) {
3347
+ if (cd[i3]) {
3348
+ co[i3] = rev2[le[cd[i3] - 1]++] >> 15 - cd[i3];
1605
3349
  }
1606
3350
  }
1607
3351
  }
1608
3352
  return co;
1609
3353
  });
1610
- var flt = new u8(288);
1611
- for (i = 0; i < 144; ++i)
1612
- flt[i] = 8;
1613
- var i;
1614
- for (i = 144; i < 256; ++i)
1615
- flt[i] = 9;
1616
- var i;
1617
- for (i = 256; i < 280; ++i)
1618
- flt[i] = 7;
1619
- var i;
1620
- for (i = 280; i < 288; ++i)
1621
- flt[i] = 8;
1622
- var i;
1623
- var fdt = new u8(32);
1624
- for (i = 0; i < 32; ++i)
1625
- fdt[i] = 5;
1626
- var i;
1627
- var flm = /* @__PURE__ */ hMap(flt, 9, 0);
1628
- var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
1629
- var shft = function(p) {
3354
+ var flt2 = new u82(288);
3355
+ for (i2 = 0; i2 < 144; ++i2)
3356
+ flt2[i2] = 8;
3357
+ var i2;
3358
+ for (i2 = 144; i2 < 256; ++i2)
3359
+ flt2[i2] = 9;
3360
+ var i2;
3361
+ for (i2 = 256; i2 < 280; ++i2)
3362
+ flt2[i2] = 7;
3363
+ var i2;
3364
+ for (i2 = 280; i2 < 288; ++i2)
3365
+ flt2[i2] = 8;
3366
+ var i2;
3367
+ var fdt2 = new u82(32);
3368
+ for (i2 = 0; i2 < 32; ++i2)
3369
+ fdt2[i2] = 5;
3370
+ var i2;
3371
+ var flm = /* @__PURE__ */ hMap2(flt2, 9, 0);
3372
+ var fdm = /* @__PURE__ */ hMap2(fdt2, 5, 0);
3373
+ var shft2 = function(p) {
1630
3374
  return (p + 7) / 8 | 0;
1631
3375
  };
1632
- var slc = function(v, s, e) {
3376
+ var slc2 = function(v, s, e) {
1633
3377
  if (s == null || s < 0)
1634
3378
  s = 0;
1635
3379
  if (e == null || e > v.length)
1636
3380
  e = v.length;
1637
- return new u8(v.subarray(s, e));
3381
+ return new u82(v.subarray(s, e));
1638
3382
  };
1639
- var ec = [
3383
+ var ec2 = [
1640
3384
  "unexpected EOF",
1641
3385
  "invalid block type",
1642
3386
  "invalid length/literal",
@@ -1654,11 +3398,11 @@ var ec = [
1654
3398
  "invalid zip data"
1655
3399
  // determined by unknown compression method
1656
3400
  ];
1657
- var err = function(ind, msg, nt) {
1658
- var e = new Error(msg || ec[ind]);
3401
+ var err2 = function(ind, msg, nt) {
3402
+ var e = new Error(msg || ec2[ind]);
1659
3403
  e.code = ind;
1660
3404
  if (Error.captureStackTrace)
1661
- Error.captureStackTrace(e, err);
3405
+ Error.captureStackTrace(e, err2);
1662
3406
  if (!nt)
1663
3407
  throw e;
1664
3408
  return e;
@@ -1678,16 +3422,16 @@ var wbits16 = function(d, p, v) {
1678
3422
  };
1679
3423
  var hTree = function(d, mb) {
1680
3424
  var t = [];
1681
- for (var i2 = 0; i2 < d.length; ++i2) {
1682
- if (d[i2])
1683
- t.push({ s: i2, f: d[i2] });
3425
+ for (var i3 = 0; i3 < d.length; ++i3) {
3426
+ if (d[i3])
3427
+ t.push({ s: i3, f: d[i3] });
1684
3428
  }
1685
3429
  var s = t.length;
1686
3430
  var t2 = t.slice();
1687
3431
  if (!s)
1688
- return { t: et, l: 0 };
3432
+ return { t: et2, l: 0 };
1689
3433
  if (s == 1) {
1690
- var v = new u8(t[0].s + 1);
3434
+ var v = new u82(t[0].s + 1);
1691
3435
  v[t[0].s] = 1;
1692
3436
  return { t: v, l: 1 };
1693
3437
  }
@@ -1703,20 +3447,20 @@ var hTree = function(d, mb) {
1703
3447
  t[i1++] = { s: -1, f: l.f + r.f, l, r };
1704
3448
  }
1705
3449
  var maxSym = t2[0].s;
1706
- for (var i2 = 1; i2 < s; ++i2) {
1707
- if (t2[i2].s > maxSym)
1708
- maxSym = t2[i2].s;
3450
+ for (var i3 = 1; i3 < s; ++i3) {
3451
+ if (t2[i3].s > maxSym)
3452
+ maxSym = t2[i3].s;
1709
3453
  }
1710
- var tr = new u16(maxSym + 1);
3454
+ var tr = new u162(maxSym + 1);
1711
3455
  var mbt = ln(t[i1 - 1], tr, 0);
1712
3456
  if (mbt > mb) {
1713
- var i2 = 0, dt = 0;
3457
+ var i3 = 0, dt = 0;
1714
3458
  var lft = mbt - mb, cst = 1 << lft;
1715
3459
  t2.sort(function(a, b) {
1716
3460
  return tr[b.s] - tr[a.s] || a.f - b.f;
1717
3461
  });
1718
- for (; i2 < s; ++i2) {
1719
- var i2_1 = t2[i2].s;
3462
+ for (; i3 < s; ++i3) {
3463
+ var i2_1 = t2[i3].s;
1720
3464
  if (tr[i2_1] > mb) {
1721
3465
  dt += cst - (1 << mbt - tr[i2_1]);
1722
3466
  tr[i2_1] = mb;
@@ -1725,14 +3469,14 @@ var hTree = function(d, mb) {
1725
3469
  }
1726
3470
  dt >>= lft;
1727
3471
  while (dt > 0) {
1728
- var i2_2 = t2[i2].s;
3472
+ var i2_2 = t2[i3].s;
1729
3473
  if (tr[i2_2] < mb)
1730
3474
  dt -= 1 << mb - tr[i2_2]++ - 1;
1731
3475
  else
1732
- ++i2;
3476
+ ++i3;
1733
3477
  }
1734
- for (; i2 >= 0 && dt; --i2) {
1735
- var i2_3 = t2[i2].s;
3478
+ for (; i3 >= 0 && dt; --i3) {
3479
+ var i2_3 = t2[i3].s;
1736
3480
  if (tr[i2_3] == mb) {
1737
3481
  --tr[i2_3];
1738
3482
  ++dt;
@@ -1740,7 +3484,7 @@ var hTree = function(d, mb) {
1740
3484
  }
1741
3485
  mbt = mb;
1742
3486
  }
1743
- return { t: new u8(tr), l: mbt };
3487
+ return { t: new u82(tr), l: mbt };
1744
3488
  };
1745
3489
  var ln = function(n, l, d) {
1746
3490
  return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
@@ -1749,13 +3493,13 @@ var lc = function(c) {
1749
3493
  var s = c.length;
1750
3494
  while (s && !c[--s])
1751
3495
  ;
1752
- var cl = new u16(++s);
3496
+ var cl = new u162(++s);
1753
3497
  var cli = 0, cln = c[0], cls = 1;
1754
3498
  var w = function(v) {
1755
3499
  cl[cli++] = v;
1756
3500
  };
1757
- for (var i2 = 1; i2 <= s; ++i2) {
1758
- if (c[i2] == cln && i2 != s)
3501
+ for (var i3 = 1; i3 <= s; ++i3) {
3502
+ if (c[i3] == cln && i3 != s)
1759
3503
  ++cls;
1760
3504
  else {
1761
3505
  if (!cln && cls > 2) {
@@ -1775,85 +3519,85 @@ var lc = function(c) {
1775
3519
  while (cls--)
1776
3520
  w(cln);
1777
3521
  cls = 1;
1778
- cln = c[i2];
3522
+ cln = c[i3];
1779
3523
  }
1780
3524
  }
1781
3525
  return { c: cl.subarray(0, cli), n: s };
1782
3526
  };
1783
3527
  var clen = function(cf, cl) {
1784
3528
  var l = 0;
1785
- for (var i2 = 0; i2 < cl.length; ++i2)
1786
- l += cf[i2] * cl[i2];
3529
+ for (var i3 = 0; i3 < cl.length; ++i3)
3530
+ l += cf[i3] * cl[i3];
1787
3531
  return l;
1788
3532
  };
1789
3533
  var wfblk = function(out, pos, dat) {
1790
3534
  var s = dat.length;
1791
- var o = shft(pos + 2);
3535
+ var o = shft2(pos + 2);
1792
3536
  out[o] = s & 255;
1793
3537
  out[o + 1] = s >> 8;
1794
3538
  out[o + 2] = out[o] ^ 255;
1795
3539
  out[o + 3] = out[o + 1] ^ 255;
1796
- for (var i2 = 0; i2 < s; ++i2)
1797
- out[o + i2 + 4] = dat[i2];
3540
+ for (var i3 = 0; i3 < s; ++i3)
3541
+ out[o + i3 + 4] = dat[i3];
1798
3542
  return (o + 4 + s) * 8;
1799
3543
  };
1800
3544
  var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
1801
3545
  wbits(out, p++, final);
1802
3546
  ++lf[256];
1803
- var _a2 = hTree(lf, 15), dlt = _a2.t, mlb = _a2.l;
1804
- var _b2 = hTree(df, 15), ddt = _b2.t, mdb = _b2.l;
3547
+ var _a3 = hTree(lf, 15), dlt = _a3.t, mlb = _a3.l;
3548
+ var _b3 = hTree(df, 15), ddt = _b3.t, mdb = _b3.l;
1805
3549
  var _c = lc(dlt), lclt = _c.c, nlc = _c.n;
1806
3550
  var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;
1807
- var lcfreq = new u16(19);
1808
- for (var i2 = 0; i2 < lclt.length; ++i2)
1809
- ++lcfreq[lclt[i2] & 31];
1810
- for (var i2 = 0; i2 < lcdt.length; ++i2)
1811
- ++lcfreq[lcdt[i2] & 31];
3551
+ var lcfreq = new u162(19);
3552
+ for (var i3 = 0; i3 < lclt.length; ++i3)
3553
+ ++lcfreq[lclt[i3] & 31];
3554
+ for (var i3 = 0; i3 < lcdt.length; ++i3)
3555
+ ++lcfreq[lcdt[i3] & 31];
1812
3556
  var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;
1813
3557
  var nlcc = 19;
1814
- for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
3558
+ for (; nlcc > 4 && !lct[clim2[nlcc - 1]]; --nlcc)
1815
3559
  ;
1816
3560
  var flen = bl + 5 << 3;
1817
- var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
3561
+ var ftlen = clen(lf, flt2) + clen(df, fdt2) + eb;
1818
3562
  var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
1819
3563
  if (bs >= 0 && flen <= ftlen && flen <= dtlen)
1820
3564
  return wfblk(out, p, dat.subarray(bs, bs + bl));
1821
3565
  var lm, ll, dm, dl;
1822
3566
  wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
1823
3567
  if (dtlen < ftlen) {
1824
- lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
1825
- var llm = hMap(lct, mlcb, 0);
3568
+ lm = hMap2(dlt, mlb, 0), ll = dlt, dm = hMap2(ddt, mdb, 0), dl = ddt;
3569
+ var llm = hMap2(lct, mlcb, 0);
1826
3570
  wbits(out, p, nlc - 257);
1827
3571
  wbits(out, p + 5, ndc - 1);
1828
3572
  wbits(out, p + 10, nlcc - 4);
1829
3573
  p += 14;
1830
- for (var i2 = 0; i2 < nlcc; ++i2)
1831
- wbits(out, p + 3 * i2, lct[clim[i2]]);
3574
+ for (var i3 = 0; i3 < nlcc; ++i3)
3575
+ wbits(out, p + 3 * i3, lct[clim2[i3]]);
1832
3576
  p += 3 * nlcc;
1833
3577
  var lcts = [lclt, lcdt];
1834
3578
  for (var it = 0; it < 2; ++it) {
1835
3579
  var clct = lcts[it];
1836
- for (var i2 = 0; i2 < clct.length; ++i2) {
1837
- var len = clct[i2] & 31;
3580
+ for (var i3 = 0; i3 < clct.length; ++i3) {
3581
+ var len = clct[i3] & 31;
1838
3582
  wbits(out, p, llm[len]), p += lct[len];
1839
3583
  if (len > 15)
1840
- wbits(out, p, clct[i2] >> 5 & 127), p += clct[i2] >> 12;
3584
+ wbits(out, p, clct[i3] >> 5 & 127), p += clct[i3] >> 12;
1841
3585
  }
1842
3586
  }
1843
3587
  } else {
1844
- lm = flm, ll = flt, dm = fdm, dl = fdt;
3588
+ lm = flm, ll = flt2, dm = fdm, dl = fdt2;
1845
3589
  }
1846
- for (var i2 = 0; i2 < li; ++i2) {
1847
- var sym = syms[i2];
3590
+ for (var i3 = 0; i3 < li; ++i3) {
3591
+ var sym = syms[i3];
1848
3592
  if (sym > 255) {
1849
3593
  var len = sym >> 18 & 31;
1850
3594
  wbits16(out, p, lm[len + 257]), p += ll[len + 257];
1851
3595
  if (len > 7)
1852
- wbits(out, p, sym >> 23 & 31), p += fleb[len];
3596
+ wbits(out, p, sym >> 23 & 31), p += fleb2[len];
1853
3597
  var dst = sym & 31;
1854
3598
  wbits16(out, p, dm[dst]), p += dl[dst];
1855
3599
  if (dst > 3)
1856
- wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
3600
+ wbits16(out, p, sym >> 5 & 8191), p += fdeb2[dst];
1857
3601
  } else {
1858
3602
  wbits16(out, p, lm[sym]), p += ll[sym];
1859
3603
  }
@@ -1861,11 +3605,11 @@ var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
1861
3605
  wbits16(out, p, lm[256]);
1862
3606
  return p + ll[256];
1863
3607
  };
1864
- var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
1865
- var et = /* @__PURE__ */ new u8(0);
3608
+ var deo = /* @__PURE__ */ new i322([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
3609
+ var et2 = /* @__PURE__ */ new u82(0);
1866
3610
  var dflt = function(dat, lvl, plvl, pre, post, st) {
1867
3611
  var s = st.z || dat.length;
1868
- var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
3612
+ var o = new u82(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
1869
3613
  var w = o.subarray(pre, o.length - post);
1870
3614
  var lst = st.l;
1871
3615
  var pos = (st.r || 0) & 7;
@@ -1875,38 +3619,38 @@ var dflt = function(dat, lvl, plvl, pre, post, st) {
1875
3619
  var opt = deo[lvl - 1];
1876
3620
  var n = opt >> 13, c = opt & 8191;
1877
3621
  var msk_1 = (1 << plvl) - 1;
1878
- var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
3622
+ var prev = st.p || new u162(32768), head = st.h || new u162(msk_1 + 1);
1879
3623
  var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
1880
- var hsh = function(i3) {
1881
- return (dat[i3] ^ dat[i3 + 1] << bs1_1 ^ dat[i3 + 2] << bs2_1) & msk_1;
3624
+ var hsh = function(i4) {
3625
+ return (dat[i4] ^ dat[i4 + 1] << bs1_1 ^ dat[i4 + 2] << bs2_1) & msk_1;
1882
3626
  };
1883
- var syms = new i32(25e3);
1884
- var lf = new u16(288), df = new u16(32);
1885
- var lc_1 = 0, eb = 0, i2 = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
1886
- for (; i2 + 2 < s; ++i2) {
1887
- var hv = hsh(i2);
1888
- var imod = i2 & 32767, pimod = head[hv];
3627
+ var syms = new i322(25e3);
3628
+ var lf = new u162(288), df = new u162(32);
3629
+ var lc_1 = 0, eb = 0, i3 = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
3630
+ for (; i3 + 2 < s; ++i3) {
3631
+ var hv = hsh(i3);
3632
+ var imod = i3 & 32767, pimod = head[hv];
1889
3633
  prev[imod] = pimod;
1890
3634
  head[hv] = imod;
1891
- if (wi <= i2) {
1892
- var rem = s - i2;
3635
+ if (wi <= i3) {
3636
+ var rem = s - i3;
1893
3637
  if ((lc_1 > 7e3 || li > 24576) && (rem > 423 || !lst)) {
1894
- pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i2 - bs, pos);
1895
- li = lc_1 = eb = 0, bs = i2;
3638
+ pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i3 - bs, pos);
3639
+ li = lc_1 = eb = 0, bs = i3;
1896
3640
  for (var j = 0; j < 286; ++j)
1897
3641
  lf[j] = 0;
1898
3642
  for (var j = 0; j < 30; ++j)
1899
3643
  df[j] = 0;
1900
3644
  }
1901
3645
  var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
1902
- if (rem > 2 && hv == hsh(i2 - dif)) {
3646
+ if (rem > 2 && hv == hsh(i3 - dif)) {
1903
3647
  var maxn = Math.min(n, rem) - 1;
1904
- var maxd = Math.min(32767, i2);
3648
+ var maxd = Math.min(32767, i3);
1905
3649
  var ml = Math.min(258, rem);
1906
3650
  while (dif <= maxd && --ch_1 && imod != pimod) {
1907
- if (dat[i2 + l] == dat[i2 + l - dif]) {
3651
+ if (dat[i3 + l] == dat[i3 + l - dif]) {
1908
3652
  var nl = 0;
1909
- for (; nl < ml && dat[i2 + nl] == dat[i2 + nl - dif]; ++nl)
3653
+ for (; nl < ml && dat[i3 + nl] == dat[i3 + nl - dif]; ++nl)
1910
3654
  ;
1911
3655
  if (nl > l) {
1912
3656
  l = nl, d = dif;
@@ -1915,7 +3659,7 @@ var dflt = function(dat, lvl, plvl, pre, post, st) {
1915
3659
  var mmd = Math.min(dif, nl - 2);
1916
3660
  var md = 0;
1917
3661
  for (var j = 0; j < mmd; ++j) {
1918
- var ti = i2 - dif + j & 32767;
3662
+ var ti = i3 - dif + j & 32767;
1919
3663
  var pti = prev[ti];
1920
3664
  var cd = ti - pti & 32767;
1921
3665
  if (cd > md)
@@ -1928,49 +3672,49 @@ var dflt = function(dat, lvl, plvl, pre, post, st) {
1928
3672
  }
1929
3673
  }
1930
3674
  if (d) {
1931
- syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
1932
- var lin = revfl[l] & 31, din = revfd[d] & 31;
1933
- eb += fleb[lin] + fdeb[din];
3675
+ syms[li++] = 268435456 | revfl2[l] << 18 | revfd2[d];
3676
+ var lin = revfl2[l] & 31, din = revfd2[d] & 31;
3677
+ eb += fleb2[lin] + fdeb2[din];
1934
3678
  ++lf[257 + lin];
1935
3679
  ++df[din];
1936
- wi = i2 + l;
3680
+ wi = i3 + l;
1937
3681
  ++lc_1;
1938
3682
  } else {
1939
- syms[li++] = dat[i2];
1940
- ++lf[dat[i2]];
3683
+ syms[li++] = dat[i3];
3684
+ ++lf[dat[i3]];
1941
3685
  }
1942
3686
  }
1943
3687
  }
1944
- for (i2 = Math.max(i2, wi); i2 < s; ++i2) {
1945
- syms[li++] = dat[i2];
1946
- ++lf[dat[i2]];
3688
+ for (i3 = Math.max(i3, wi); i3 < s; ++i3) {
3689
+ syms[li++] = dat[i3];
3690
+ ++lf[dat[i3]];
1947
3691
  }
1948
- pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i2 - bs, pos);
3692
+ pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i3 - bs, pos);
1949
3693
  if (!lst) {
1950
3694
  st.r = pos & 7 | w[pos / 8 | 0] << 3;
1951
3695
  pos -= 7;
1952
- st.h = head, st.p = prev, st.i = i2, st.w = wi;
3696
+ st.h = head, st.p = prev, st.i = i3, st.w = wi;
1953
3697
  }
1954
3698
  } else {
1955
- for (var i2 = st.w || 0; i2 < s + lst; i2 += 65535) {
1956
- var e = i2 + 65535;
3699
+ for (var i3 = st.w || 0; i3 < s + lst; i3 += 65535) {
3700
+ var e = i3 + 65535;
1957
3701
  if (e >= s) {
1958
3702
  w[pos / 8 | 0] = lst;
1959
3703
  e = s;
1960
3704
  }
1961
- pos = wfblk(w, pos + 1, dat.subarray(i2, e));
3705
+ pos = wfblk(w, pos + 1, dat.subarray(i3, e));
1962
3706
  }
1963
3707
  st.i = s;
1964
3708
  }
1965
- return slc(o, 0, pre + shft(pos) + post);
3709
+ return slc2(o, 0, pre + shft2(pos) + post);
1966
3710
  };
1967
3711
  var crct = /* @__PURE__ */ (function() {
1968
3712
  var t = new Int32Array(256);
1969
- for (var i2 = 0; i2 < 256; ++i2) {
1970
- var c = i2, k = 9;
3713
+ for (var i3 = 0; i3 < 256; ++i3) {
3714
+ var c = i3, k = 9;
1971
3715
  while (--k)
1972
3716
  c = (c & 1 && -306674912) ^ c >>> 1;
1973
- t[i2] = c;
3717
+ t[i3] = c;
1974
3718
  }
1975
3719
  return t;
1976
3720
  })();
@@ -1979,8 +3723,8 @@ var crc = function() {
1979
3723
  return {
1980
3724
  p: function(d) {
1981
3725
  var cr = c;
1982
- for (var i2 = 0; i2 < d.length; ++i2)
1983
- cr = crct[cr & 255 ^ d[i2]] ^ cr >>> 8;
3726
+ for (var i3 = 0; i3 < d.length; ++i3)
3727
+ cr = crct[cr & 255 ^ d[i3]] ^ cr >>> 8;
1984
3728
  c = cr;
1985
3729
  },
1986
3730
  d: function() {
@@ -1993,7 +3737,7 @@ var dopt = function(dat, opt, pre, post, st) {
1993
3737
  st = { l: 1 };
1994
3738
  if (opt.dictionary) {
1995
3739
  var dict = opt.dictionary.subarray(-32768);
1996
- var newDat = new u8(dict.length + dat.length);
3740
+ var newDat = new u82(dict.length + dat.length);
1997
3741
  newDat.set(dict);
1998
3742
  newDat.set(dat, dict.length);
1999
3743
  dat = newDat;
@@ -2025,51 +3769,51 @@ var fltn = function(d, p, t, o) {
2025
3769
  if (ArrayBuffer.isView(val))
2026
3770
  t[n] = [val, op];
2027
3771
  else {
2028
- t[n += "/"] = [new u8(0), op];
3772
+ t[n += "/"] = [new u82(0), op];
2029
3773
  fltn(val, n, t, o);
2030
3774
  }
2031
3775
  }
2032
3776
  };
2033
3777
  var te = typeof TextEncoder != "undefined" && /* @__PURE__ */ new TextEncoder();
2034
- var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
2035
- var tds = 0;
3778
+ var td2 = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
3779
+ var tds2 = 0;
2036
3780
  try {
2037
- td.decode(et, { stream: true });
2038
- tds = 1;
3781
+ td2.decode(et2, { stream: true });
3782
+ tds2 = 1;
2039
3783
  } catch (e) {
2040
3784
  }
2041
3785
  function strToU8(str, latin1) {
2042
3786
  if (latin1) {
2043
- var ar_1 = new u8(str.length);
2044
- for (var i2 = 0; i2 < str.length; ++i2)
2045
- ar_1[i2] = str.charCodeAt(i2);
3787
+ var ar_1 = new u82(str.length);
3788
+ for (var i3 = 0; i3 < str.length; ++i3)
3789
+ ar_1[i3] = str.charCodeAt(i3);
2046
3790
  return ar_1;
2047
3791
  }
2048
3792
  if (te)
2049
3793
  return te.encode(str);
2050
3794
  var l = str.length;
2051
- var ar = new u8(str.length + (str.length >> 1));
3795
+ var ar = new u82(str.length + (str.length >> 1));
2052
3796
  var ai = 0;
2053
3797
  var w = function(v) {
2054
3798
  ar[ai++] = v;
2055
3799
  };
2056
- for (var i2 = 0; i2 < l; ++i2) {
3800
+ for (var i3 = 0; i3 < l; ++i3) {
2057
3801
  if (ai + 5 > ar.length) {
2058
- var n = new u8(ai + 8 + (l - i2 << 1));
3802
+ var n = new u82(ai + 8 + (l - i3 << 1));
2059
3803
  n.set(ar);
2060
3804
  ar = n;
2061
3805
  }
2062
- var c = str.charCodeAt(i2);
3806
+ var c = str.charCodeAt(i3);
2063
3807
  if (c < 128 || latin1)
2064
3808
  w(c);
2065
3809
  else if (c < 2048)
2066
3810
  w(192 | c >> 6), w(128 | c & 63);
2067
3811
  else if (c > 55295 && c < 57344)
2068
- c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i2) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
3812
+ c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i3) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
2069
3813
  else
2070
3814
  w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
2071
3815
  }
2072
- return slc(ar, 0, ai);
3816
+ return slc2(ar, 0, ai);
2073
3817
  }
2074
3818
  var exfl = function(ex) {
2075
3819
  var le = 0;
@@ -2077,14 +3821,14 @@ var exfl = function(ex) {
2077
3821
  for (var k in ex) {
2078
3822
  var l = ex[k].length;
2079
3823
  if (l > 65535)
2080
- err(9);
3824
+ err2(9);
2081
3825
  le += l + 4;
2082
3826
  }
2083
3827
  }
2084
3828
  return le;
2085
3829
  };
2086
3830
  var wzh = function(d, b, f, fn, u, c, ce, co) {
2087
- var fl2 = fn.length, ex = f.extra, col = co && co.length;
3831
+ var fl3 = fn.length, ex = f.extra, col = co && co.length;
2088
3832
  var exl = exfl(ex);
2089
3833
  wbytes(d, b, ce != null ? 33639248 : 67324752), b += 4;
2090
3834
  if (ce != null)
@@ -2094,14 +3838,14 @@ var wzh = function(d, b, f, fn, u, c, ce, co) {
2094
3838
  d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
2095
3839
  var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
2096
3840
  if (y < 0 || y > 119)
2097
- err(10);
3841
+ err2(10);
2098
3842
  wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >> 1), b += 4;
2099
3843
  if (c != -1) {
2100
3844
  wbytes(d, b, f.crc);
2101
3845
  wbytes(d, b + 4, c < 0 ? -c - 2 : c);
2102
3846
  wbytes(d, b + 8, f.size);
2103
3847
  }
2104
- wbytes(d, b + 12, fl2);
3848
+ wbytes(d, b + 12, fl3);
2105
3849
  wbytes(d, b + 14, exl), b += 16;
2106
3850
  if (ce != null) {
2107
3851
  wbytes(d, b, col);
@@ -2109,7 +3853,7 @@ var wzh = function(d, b, f, fn, u, c, ce, co) {
2109
3853
  wbytes(d, b + 10, ce), b += 14;
2110
3854
  }
2111
3855
  d.set(fn, b);
2112
- b += fl2;
3856
+ b += fl3;
2113
3857
  if (exl) {
2114
3858
  for (var k in ex) {
2115
3859
  var exf = ex[k], l = exf.length;
@@ -2138,13 +3882,13 @@ function zipSync(data, opts) {
2138
3882
  var o = 0;
2139
3883
  var tot = 0;
2140
3884
  for (var fn in r) {
2141
- var _a2 = r[fn], file = _a2[0], p = _a2[1];
3885
+ var _a3 = r[fn], file = _a3[0], p = _a3[1];
2142
3886
  var compression = p.level == 0 ? 0 : 8;
2143
3887
  var f = strToU8(fn), s = f.length;
2144
3888
  var com = p.comment, m = com && strToU8(com), ms = m && m.length;
2145
3889
  var exl = exfl(p.extra);
2146
3890
  if (s > 65535)
2147
- err(11);
3891
+ err2(11);
2148
3892
  var d = compression ? deflateSync(file, p) : file, l = d.length;
2149
3893
  var c = crc();
2150
3894
  c.p(file);
@@ -2161,9 +3905,9 @@ function zipSync(data, opts) {
2161
3905
  o += 30 + s + exl + l;
2162
3906
  tot += 76 + 2 * (s + exl) + (ms || 0) + l;
2163
3907
  }
2164
- var out = new u8(tot + 22), oe = o, cdl = tot - o;
2165
- for (var i2 = 0; i2 < files.length; ++i2) {
2166
- var f = files[i2];
3908
+ var out = new u82(tot + 22), oe = o, cdl = tot - o;
3909
+ for (var i3 = 0; i3 < files.length; ++i3) {
3910
+ var f = files[i3];
2167
3911
  wzh(out, f.o, f, f.f, f.u, f.c.length);
2168
3912
  var badd = 30 + f.f.length + exfl(f.extra);
2169
3913
  out.set(f.c, f.o + badd);
@@ -3573,8 +5317,8 @@ async function runDoctor(options, dependencies = actualDependencies) {
3573
5317
  var args = process.argv.slice(2);
3574
5318
  var runCommand = promisify2(execFile2);
3575
5319
  var option = (name, fallback) => {
3576
- const i2 = args.indexOf(name);
3577
- return i2 >= 0 ? args[i2 + 1] : fallback;
5320
+ const i3 = args.indexOf(name);
5321
+ return i3 >= 0 ? args[i3 + 1] : fallback;
3578
5322
  };
3579
5323
  async function installedPackageVersion() {
3580
5324
  const packageManifest = JSON.parse(