better-review 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -17
- package/dist/cli.js +1394 -1762
- package/dist/web/assets/highlight.worker-BOqhB448.js +153 -0
- package/dist/web/assets/{html-Bv1KyTF7.js → html-B3xvRgDO.js} +1 -1
- package/dist/web/assets/html-BHZv6uqE.js +1 -0
- package/dist/web/assets/index-B9sCIpY8.js +111 -0
- package/dist/web/assets/{index-rNKORPVq.css → index-Dp_ug4Zx.css} +1 -1
- package/dist/web/assets/{json-B88Oqtu5.js → json-qhed-kSA.js} +1 -1
- package/dist/web/assets/{jsx-D3KKoC5L.js → jsx-Bz0zcwM4.js} +1 -1
- package/dist/web/assets/{markdown-CboqBxpY.js → markdown-BYOwaDjH.js} +1 -1
- package/dist/web/assets/scss-8bKmll0B.js +1 -0
- package/dist/web/assets/{tsx-BOvsFOI6.js → tsx-udAQXfEw.js} +1 -1
- package/dist/web/assets/{typescript-j_1H8WHN.js → typescript-bsJCZSQ-.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/astro-BGCLva2-.js +0 -1
- package/dist/web/assets/bat-qdxAdBWQ.js +0 -1
- package/dist/web/assets/c-Cz4nF6n_.js +0 -1
- package/dist/web/assets/c-SSSlmE39.js +0 -1
- package/dist/web/assets/clojure-DqKBuwfJ.js +0 -1
- package/dist/web/assets/cmake-Bj61d0ZC.js +0 -1
- package/dist/web/assets/cpp-DK5F0KO4.js +0 -1
- package/dist/web/assets/cpp-pF_afpy8.js +0 -1
- package/dist/web/assets/csharp-dmMxLVLW.js +0 -1
- package/dist/web/assets/dart-CHZY9Xhz.js +0 -1
- package/dist/web/assets/diff-woXpYk--.js +0 -1
- package/dist/web/assets/dockerfile-IyjqRm3v.js +0 -1
- package/dist/web/assets/dotenv-CuH5my32.js +0 -1
- package/dist/web/assets/elixir-DcSoMxCm.js +0 -1
- package/dist/web/assets/erlang-59ohNboI.js +0 -1
- package/dist/web/assets/fsharp-D2W_zG4w.js +0 -1
- package/dist/web/assets/gleam-CSRkHgEL.js +0 -1
- package/dist/web/assets/go-rLFTqkRN.js +0 -1
- package/dist/web/assets/graphql-BoW1g5X9.js +0 -1
- package/dist/web/assets/graphql-C2HCcBds.js +0 -1
- package/dist/web/assets/groovy-CacY0gHj.js +0 -1
- package/dist/web/assets/haskell-D8IpX4py.js +0 -1
- package/dist/web/assets/hcl-Dh228itO.js +0 -1
- package/dist/web/assets/highlight.worker-D2jBd466.js +0 -153
- package/dist/web/assets/html-DZNlqGBh.js +0 -1
- package/dist/web/assets/index-DuH6feCh.js +0 -110
- package/dist/web/assets/ini-0B7NLFlx.js +0 -1
- package/dist/web/assets/ini-DiZ1IqbV.js +0 -1
- package/dist/web/assets/java-BtIQNnN0.js +0 -1
- package/dist/web/assets/java-_ATy9zCa.js +0 -1
- package/dist/web/assets/json-C3WlssX3.js +0 -1
- package/dist/web/assets/json5-BR5RXkoi.js +0 -1
- package/dist/web/assets/jsx-C4yDKi0A.js +0 -1
- package/dist/web/assets/julia-CBcsyk3j.js +0 -1
- package/dist/web/assets/kotlin-DhhofPvG.js +0 -1
- package/dist/web/assets/lua-B0e3uOiv.js +0 -1
- package/dist/web/assets/lua-pjIdZuk8.js +0 -1
- package/dist/web/assets/makefile-Dixweg8N.js +0 -1
- package/dist/web/assets/markdown-CjQmuOi1.js +0 -1
- package/dist/web/assets/mdx-DQZ5AkYe.js +0 -1
- package/dist/web/assets/nginx-DbUAZ-J7.js +0 -1
- package/dist/web/assets/nix-Cl_7024t.js +0 -1
- package/dist/web/assets/objective-c-D1A_Heim.js +0 -1
- package/dist/web/assets/ocaml-O90oeIOV.js +0 -1
- package/dist/web/assets/perl-CCy4CjC0.js +0 -1
- package/dist/web/assets/php-3goRFXPs.js +0 -1
- package/dist/web/assets/postcss-D_Wz94rJ.js +0 -1
- package/dist/web/assets/powershell-QtSnmXcu.js +0 -1
- package/dist/web/assets/prisma-DMgNhnYS.js +0 -1
- package/dist/web/assets/properties-DiZ1IqbV.js +0 -1
- package/dist/web/assets/proto-DB4EqR-F.js +0 -1
- package/dist/web/assets/python-C5TF47hQ.js +0 -1
- package/dist/web/assets/python-CzFU0dpx.js +0 -1
- package/dist/web/assets/r-BXEss897.js +0 -1
- package/dist/web/assets/r-DWzjseEo.js +0 -1
- package/dist/web/assets/ruby-ChLscevq.js +0 -1
- package/dist/web/assets/rust-DpiIf5JO.js +0 -1
- package/dist/web/assets/scala-BiFt_7mu.js +0 -1
- package/dist/web/assets/shellscript-CVTB3cr6.js +0 -1
- package/dist/web/assets/shellscript-CqHdAlCp.js +0 -1
- package/dist/web/assets/sql-CNu3Or2W.js +0 -1
- package/dist/web/assets/sql-CfM2IJm3.js +0 -1
- package/dist/web/assets/svelte-Bte6OA2r.js +0 -1
- package/dist/web/assets/swift-CyEgAFGc.js +0 -1
- package/dist/web/assets/terraform-DswuEJGm.js +0 -1
- package/dist/web/assets/toml-CcmNWLt0.js +0 -1
- package/dist/web/assets/tsx-CGosfAUg.js +0 -1
- package/dist/web/assets/typescript-Bb1J8qyy.js +0 -1
- package/dist/web/assets/vue-CcmjViMa.js +0 -1
- package/dist/web/assets/xml-Bvlx11yh.js +0 -1
- package/dist/web/assets/xml-Byfru430.js +0 -1
- package/dist/web/assets/yaml-DDA_XMNu.js +0 -1
- package/dist/web/assets/yaml-DijMHRDA.js +0 -1
- package/dist/web/assets/zig-CMLA9XwU.js +0 -1
package/dist/cli.js
CHANGED
|
@@ -1782,8 +1782,8 @@ function getStatusCodeFromKey(code) {
|
|
|
1782
1782
|
var _JSONRPC2_TO_HTTP_COD;
|
|
1783
1783
|
return (_JSONRPC2_TO_HTTP_COD = JSONRPC2_TO_HTTP_CODE[code]) !== null && _JSONRPC2_TO_HTTP_COD !== void 0 ? _JSONRPC2_TO_HTTP_COD : 500;
|
|
1784
1784
|
}
|
|
1785
|
-
function getHTTPStatusCode(
|
|
1786
|
-
const httpStatuses = new Set((Array.isArray(
|
|
1785
|
+
function getHTTPStatusCode(json4) {
|
|
1786
|
+
const httpStatuses = new Set((Array.isArray(json4) ? json4 : [json4]).map((res) => {
|
|
1787
1787
|
if ("error" in res && isObject(res.error.data)) {
|
|
1788
1788
|
var _res$error$data;
|
|
1789
1789
|
if (typeof ((_res$error$data = res.error.data) === null || _res$error$data === void 0 ? void 0 : _res$error$data["httpStatus"]) === "number") return res.error.data["httpStatus"];
|
|
@@ -4226,7 +4226,7 @@ var HonoRequest = class {
|
|
|
4226
4226
|
* ```
|
|
4227
4227
|
*/
|
|
4228
4228
|
json() {
|
|
4229
|
-
return this.#cachedBody("text").then((
|
|
4229
|
+
return this.#cachedBody("text").then((text2) => JSON.parse(text2));
|
|
4230
4230
|
}
|
|
4231
4231
|
/**
|
|
4232
4232
|
* `.text()` can parse Request body of type `text/plain`
|
|
@@ -4744,8 +4744,8 @@ var Context = class {
|
|
|
4744
4744
|
* })
|
|
4745
4745
|
* ```
|
|
4746
4746
|
*/
|
|
4747
|
-
text = (
|
|
4748
|
-
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(
|
|
4747
|
+
text = (text2, arg, headers) => {
|
|
4748
|
+
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text2) : this.#newResponse(text2, arg, setDefaultContentType(TEXT_PLAIN, headers));
|
|
4749
4749
|
};
|
|
4750
4750
|
/**
|
|
4751
4751
|
* `.json()` can render JSON as `Content-Type:application/json`.
|
|
@@ -4762,9 +4762,9 @@ var Context = class {
|
|
|
4762
4762
|
json = (object2, arg, headers) => {
|
|
4763
4763
|
return this.#newResponse(JSON.stringify(object2), arg, setDefaultContentType("application/json", headers));
|
|
4764
4764
|
};
|
|
4765
|
-
html = (
|
|
4766
|
-
const res = (
|
|
4767
|
-
return typeof
|
|
4765
|
+
html = (html2, arg, headers) => {
|
|
4766
|
+
const res = (html3) => this.#newResponse(html3, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
|
|
4767
|
+
return typeof html2 === "object" ? resolveCallback(html2, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html2);
|
|
4768
4768
|
};
|
|
4769
4769
|
/**
|
|
4770
4770
|
* `.redirect()` can Redirect, default status code is 302.
|
|
@@ -5519,12 +5519,12 @@ var Node3 = class Node4 {
|
|
|
5519
5519
|
const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
|
|
5520
5520
|
const isParam = Array.isArray(pattern);
|
|
5521
5521
|
const key = isParam ? pattern[0] : pattern || p;
|
|
5522
|
-
const
|
|
5523
|
-
if (pattern && !
|
|
5524
|
-
|
|
5525
|
-
curNode.#patterns.push(
|
|
5522
|
+
const child = curNode.#children[key] ||= new Node4();
|
|
5523
|
+
if (pattern && !child.#pattern) {
|
|
5524
|
+
child.#pattern = pattern;
|
|
5525
|
+
curNode.#patterns.push(child);
|
|
5526
5526
|
}
|
|
5527
|
-
curNode =
|
|
5527
|
+
curNode = child;
|
|
5528
5528
|
if (isParam) possibleKeys.add(pattern[1]);
|
|
5529
5529
|
}
|
|
5530
5530
|
curNode.#methods.push({ [method]: {
|
|
@@ -5569,15 +5569,15 @@ var Node3 = class Node4 {
|
|
|
5569
5569
|
this.#pushHandlerSets(handlerSets, nextNode, method, node2.#params);
|
|
5570
5570
|
} else tempNodes.push(nextNode);
|
|
5571
5571
|
}
|
|
5572
|
-
for (const
|
|
5573
|
-
const pattern =
|
|
5572
|
+
for (const child of node2.#patterns) {
|
|
5573
|
+
const pattern = child.#pattern;
|
|
5574
5574
|
const params = node2.#params === emptyParams ? {} : { ...node2.#params };
|
|
5575
5575
|
if (typeof pattern === "string") {
|
|
5576
5576
|
if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
|
|
5577
|
-
this.#pushHandlerSets(handlerSets,
|
|
5577
|
+
this.#pushHandlerSets(handlerSets, child, method, node2.#params);
|
|
5578
5578
|
if (pattern === "*") {
|
|
5579
|
-
|
|
5580
|
-
tempNodes.push(
|
|
5579
|
+
child.#params = params;
|
|
5580
|
+
tempNodes.push(child);
|
|
5581
5581
|
}
|
|
5582
5582
|
}
|
|
5583
5583
|
continue;
|
|
@@ -5597,12 +5597,12 @@ var Node3 = class Node4 {
|
|
|
5597
5597
|
const m = matcher.exec(restPathString);
|
|
5598
5598
|
if (m) {
|
|
5599
5599
|
params[name] = m[0];
|
|
5600
|
-
this.#pushHandlerSets(handlerSets,
|
|
5601
|
-
if (m[0].length === restPathString.length &&
|
|
5602
|
-
for (const _ in
|
|
5603
|
-
|
|
5600
|
+
this.#pushHandlerSets(handlerSets, child, method, node2.#params, params);
|
|
5601
|
+
if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node2.#params, params);
|
|
5602
|
+
for (const _ in child.#children) {
|
|
5603
|
+
child.#params = params;
|
|
5604
5604
|
const componentCount = m[0].match(/\//g)?.length ?? 0;
|
|
5605
|
-
(curNodesQueue[componentCount] ||= []).push(
|
|
5605
|
+
(curNodesQueue[componentCount] ||= []).push(child);
|
|
5606
5606
|
break;
|
|
5607
5607
|
}
|
|
5608
5608
|
continue;
|
|
@@ -5611,11 +5611,11 @@ var Node3 = class Node4 {
|
|
|
5611
5611
|
if (matcher === true || matcher.test(part)) {
|
|
5612
5612
|
params[name] = part;
|
|
5613
5613
|
if (isLast) {
|
|
5614
|
-
this.#pushHandlerSets(handlerSets,
|
|
5615
|
-
if (
|
|
5614
|
+
this.#pushHandlerSets(handlerSets, child, method, params, node2.#params);
|
|
5615
|
+
if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node2.#params);
|
|
5616
5616
|
} else {
|
|
5617
|
-
|
|
5618
|
-
tempNodes.push(
|
|
5617
|
+
child.#params = params;
|
|
5618
|
+
tempNodes.push(child);
|
|
5619
5619
|
}
|
|
5620
5620
|
}
|
|
5621
5621
|
}
|
|
@@ -5742,9 +5742,9 @@ function hashString(input2, seed = 0) {
|
|
|
5742
5742
|
}
|
|
5743
5743
|
var LINE_PREFIX = { context: " ", add: "+", del: "-" };
|
|
5744
5744
|
function hunkHash(path, lines) {
|
|
5745
|
-
let
|
|
5746
|
-
for (const line of lines)
|
|
5747
|
-
return hashString(
|
|
5745
|
+
let text2 = path + "\n";
|
|
5746
|
+
for (const line of lines) text2 += LINE_PREFIX[line.type] + line.content + "\n";
|
|
5747
|
+
return hashString(text2);
|
|
5748
5748
|
}
|
|
5749
5749
|
var HUNK_HEADER = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@ ?(.*)$/;
|
|
5750
5750
|
function unquote(path) {
|
|
@@ -5786,9 +5786,9 @@ function pathsFromGitHeader(rest) {
|
|
|
5786
5786
|
const idx = rest.indexOf(" b/");
|
|
5787
5787
|
return idx === -1 ? [rest, rest] : [stripPrefix(rest.slice(0, idx)), stripPrefix(rest.slice(idx + 1))];
|
|
5788
5788
|
}
|
|
5789
|
-
function parseUnifiedDiff(
|
|
5789
|
+
function parseUnifiedDiff(text2) {
|
|
5790
5790
|
const files = [];
|
|
5791
|
-
const lines =
|
|
5791
|
+
const lines = text2.split("\n");
|
|
5792
5792
|
let file2 = null;
|
|
5793
5793
|
let hunk = null;
|
|
5794
5794
|
let oldNo = 0;
|
|
@@ -10982,9 +10982,9 @@ function isRecursive(inst, stack, resolve) {
|
|
|
10982
10982
|
return PROVEN;
|
|
10983
10983
|
stack.add(inst);
|
|
10984
10984
|
let result = NONE;
|
|
10985
|
-
const check2 = (
|
|
10986
|
-
if (result !== PROVEN &&
|
|
10987
|
-
const answer = isRecursive(
|
|
10985
|
+
const check2 = (child) => {
|
|
10986
|
+
if (result !== PROVEN && child?._zod) {
|
|
10987
|
+
const answer = isRecursive(child, stack, resolve);
|
|
10988
10988
|
if (answer > result)
|
|
10989
10989
|
result = answer;
|
|
10990
10990
|
}
|
|
@@ -10995,9 +10995,9 @@ function isRecursive(inst, stack, resolve) {
|
|
|
10995
10995
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
10996
10996
|
if (spread && !desc.enumerable)
|
|
10997
10997
|
continue;
|
|
10998
|
-
const
|
|
10999
|
-
if (
|
|
11000
|
-
answer =
|
|
10998
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
10999
|
+
if (child > answer)
|
|
11000
|
+
answer = child;
|
|
11001
11001
|
}
|
|
11002
11002
|
return answer;
|
|
11003
11003
|
};
|
|
@@ -15257,8 +15257,8 @@ function ko_default() {
|
|
|
15257
15257
|
}
|
|
15258
15258
|
|
|
15259
15259
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/lt.js
|
|
15260
|
-
var capitalizeFirstCharacter = (
|
|
15261
|
-
return
|
|
15260
|
+
var capitalizeFirstCharacter = (text2) => {
|
|
15261
|
+
return text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
15262
15262
|
};
|
|
15263
15263
|
function getUnitTypeFromNumber(number4) {
|
|
15264
15264
|
const abs = Math.abs(number4);
|
|
@@ -21554,13 +21554,13 @@ function initializeContext(params) {
|
|
|
21554
21554
|
external: params?.external ?? void 0
|
|
21555
21555
|
};
|
|
21556
21556
|
}
|
|
21557
|
-
function handleUnrepresentable(schema, ctx,
|
|
21557
|
+
function handleUnrepresentable(schema, ctx, json4, params, message) {
|
|
21558
21558
|
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
21559
21559
|
if (result === "any")
|
|
21560
21560
|
return false;
|
|
21561
21561
|
if (result === void 0 || result === "throw")
|
|
21562
21562
|
throw new Error(message);
|
|
21563
|
-
Object.assign(
|
|
21563
|
+
Object.assign(json4, result);
|
|
21564
21564
|
return true;
|
|
21565
21565
|
}
|
|
21566
21566
|
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
@@ -21796,12 +21796,12 @@ function foldObjects(members2) {
|
|
|
21796
21796
|
}
|
|
21797
21797
|
return folded;
|
|
21798
21798
|
}
|
|
21799
|
-
function foldIntersection(
|
|
21800
|
-
const allOf =
|
|
21799
|
+
function foldIntersection(json4) {
|
|
21800
|
+
const allOf = json4.allOf;
|
|
21801
21801
|
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
21802
21802
|
return;
|
|
21803
21803
|
for (const key of FOLDABLE_KEYS)
|
|
21804
|
-
if (key in
|
|
21804
|
+
if (key in json4)
|
|
21805
21805
|
return;
|
|
21806
21806
|
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
21807
21807
|
let folded = null;
|
|
@@ -21820,8 +21820,8 @@ function foldIntersection(json3) {
|
|
|
21820
21820
|
}
|
|
21821
21821
|
if (!folded)
|
|
21822
21822
|
return;
|
|
21823
|
-
delete
|
|
21824
|
-
assignProps(
|
|
21823
|
+
delete json4.allOf;
|
|
21824
|
+
assignProps(json4, folded);
|
|
21825
21825
|
}
|
|
21826
21826
|
function finalize(ctx, schema) {
|
|
21827
21827
|
const root = ctx.seen.get(schema);
|
|
@@ -21903,20 +21903,20 @@ function finalize(ctx, schema) {
|
|
|
21903
21903
|
if (ctx.intersections.length) {
|
|
21904
21904
|
const carriers = /* @__PURE__ */ new Map();
|
|
21905
21905
|
for (const seen of ctx.seen.values()) {
|
|
21906
|
-
for (const
|
|
21907
|
-
const allOf =
|
|
21906
|
+
for (const json4 of [seen.schema, seen.def]) {
|
|
21907
|
+
const allOf = json4?.allOf;
|
|
21908
21908
|
if (!Array.isArray(allOf))
|
|
21909
21909
|
continue;
|
|
21910
21910
|
const existing = carriers.get(allOf);
|
|
21911
21911
|
if (existing)
|
|
21912
|
-
existing.push(
|
|
21912
|
+
existing.push(json4);
|
|
21913
21913
|
else
|
|
21914
|
-
carriers.set(allOf, [
|
|
21914
|
+
carriers.set(allOf, [json4]);
|
|
21915
21915
|
}
|
|
21916
21916
|
}
|
|
21917
21917
|
for (const allOf of ctx.intersections) {
|
|
21918
|
-
for (const
|
|
21919
|
-
foldIntersection(
|
|
21918
|
+
for (const json4 of carriers.get(allOf) ?? [])
|
|
21919
|
+
foldIntersection(json4);
|
|
21920
21920
|
}
|
|
21921
21921
|
}
|
|
21922
21922
|
}
|
|
@@ -22151,29 +22151,29 @@ var exactPatterns = /* @__PURE__ */ new Map([
|
|
|
22151
22151
|
]);
|
|
22152
22152
|
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
22153
22153
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
22154
|
-
const
|
|
22155
|
-
|
|
22154
|
+
const json4 = _json;
|
|
22155
|
+
json4.type = "string";
|
|
22156
22156
|
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
22157
22157
|
if (typeof minimum === "number")
|
|
22158
|
-
|
|
22158
|
+
json4.minLength = minimum;
|
|
22159
22159
|
if (typeof maximum === "number")
|
|
22160
|
-
|
|
22160
|
+
json4.maxLength = maximum;
|
|
22161
22161
|
if (format) {
|
|
22162
|
-
|
|
22163
|
-
if (
|
|
22164
|
-
delete
|
|
22162
|
+
json4.format = formatMap[format] ?? format;
|
|
22163
|
+
if (json4.format === "")
|
|
22164
|
+
delete json4.format;
|
|
22165
22165
|
if (format === "time" || laxFormat) {
|
|
22166
|
-
delete
|
|
22166
|
+
delete json4.format;
|
|
22167
22167
|
}
|
|
22168
22168
|
}
|
|
22169
22169
|
if (contentEncoding)
|
|
22170
|
-
|
|
22170
|
+
json4.contentEncoding = contentEncoding;
|
|
22171
22171
|
if (patterns && patterns.size > 0) {
|
|
22172
22172
|
const patternList = [...patterns].map(exactPattern);
|
|
22173
22173
|
if (patternList.length === 1)
|
|
22174
|
-
|
|
22174
|
+
json4.pattern = patternList[0].source;
|
|
22175
22175
|
else if (patternList.length > 1) {
|
|
22176
|
-
|
|
22176
|
+
json4.allOf = [
|
|
22177
22177
|
...patternList.map((regex) => ({
|
|
22178
22178
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
22179
22179
|
pattern: regex.source
|
|
@@ -22183,31 +22183,31 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
22183
22183
|
}
|
|
22184
22184
|
};
|
|
22185
22185
|
var numberProcessor = (schema, ctx, _json, params) => {
|
|
22186
|
-
const
|
|
22186
|
+
const json4 = _json;
|
|
22187
22187
|
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
22188
|
-
|
|
22188
|
+
json4.type = isInt ? "integer" : "number";
|
|
22189
22189
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
22190
22190
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
22191
22191
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
22192
22192
|
if (exMin) {
|
|
22193
22193
|
if (legacy) {
|
|
22194
|
-
|
|
22195
|
-
|
|
22194
|
+
json4.minimum = exclusiveMinimum;
|
|
22195
|
+
json4.exclusiveMinimum = true;
|
|
22196
22196
|
} else {
|
|
22197
|
-
|
|
22197
|
+
json4.exclusiveMinimum = exclusiveMinimum;
|
|
22198
22198
|
}
|
|
22199
22199
|
} else if (typeof minimum === "number") {
|
|
22200
|
-
|
|
22200
|
+
json4.minimum = minimum;
|
|
22201
22201
|
}
|
|
22202
22202
|
if (exMax) {
|
|
22203
22203
|
if (legacy) {
|
|
22204
|
-
|
|
22205
|
-
|
|
22204
|
+
json4.maximum = exclusiveMaximum;
|
|
22205
|
+
json4.exclusiveMaximum = true;
|
|
22206
22206
|
} else {
|
|
22207
|
-
|
|
22207
|
+
json4.exclusiveMaximum = exclusiveMaximum;
|
|
22208
22208
|
}
|
|
22209
22209
|
} else if (typeof maximum === "number") {
|
|
22210
|
-
|
|
22210
|
+
json4.maximum = maximum;
|
|
22211
22211
|
}
|
|
22212
22212
|
if (multipleOf) {
|
|
22213
22213
|
const divisors = /* @__PURE__ */ new Set();
|
|
@@ -22215,75 +22215,75 @@ var numberProcessor = (schema, ctx, _json, params) => {
|
|
|
22215
22215
|
if (Number.isFinite(divisor) && divisor !== 0)
|
|
22216
22216
|
divisors.add(Math.abs(divisor));
|
|
22217
22217
|
else
|
|
22218
|
-
handleUnrepresentable(schema, ctx,
|
|
22218
|
+
handleUnrepresentable(schema, ctx, json4, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
22219
22219
|
}
|
|
22220
22220
|
const [first, ...rest] = divisors;
|
|
22221
22221
|
if (first !== void 0)
|
|
22222
|
-
|
|
22222
|
+
json4.multipleOf = first;
|
|
22223
22223
|
if (rest.length)
|
|
22224
|
-
|
|
22224
|
+
json4.allOf = [...json4.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
22225
22225
|
}
|
|
22226
22226
|
};
|
|
22227
|
-
var booleanProcessor = (_schema, _ctx,
|
|
22228
|
-
|
|
22227
|
+
var booleanProcessor = (_schema, _ctx, json4, _params) => {
|
|
22228
|
+
json4.type = "boolean";
|
|
22229
22229
|
};
|
|
22230
|
-
var bigintProcessor = (schema, ctx,
|
|
22231
|
-
handleUnrepresentable(schema, ctx,
|
|
22230
|
+
var bigintProcessor = (schema, ctx, json4, params) => {
|
|
22231
|
+
handleUnrepresentable(schema, ctx, json4, params, "BigInt cannot be represented in JSON Schema");
|
|
22232
22232
|
};
|
|
22233
|
-
var symbolProcessor = (schema, ctx,
|
|
22234
|
-
handleUnrepresentable(schema, ctx,
|
|
22233
|
+
var symbolProcessor = (schema, ctx, json4, params) => {
|
|
22234
|
+
handleUnrepresentable(schema, ctx, json4, params, "Symbols cannot be represented in JSON Schema");
|
|
22235
22235
|
};
|
|
22236
|
-
var nullProcessor = (_schema, ctx,
|
|
22236
|
+
var nullProcessor = (_schema, ctx, json4, _params) => {
|
|
22237
22237
|
if (ctx.target === "openapi-3.0") {
|
|
22238
|
-
|
|
22239
|
-
|
|
22240
|
-
|
|
22238
|
+
json4.type = "string";
|
|
22239
|
+
json4.nullable = true;
|
|
22240
|
+
json4.enum = [null];
|
|
22241
22241
|
} else {
|
|
22242
|
-
|
|
22242
|
+
json4.type = "null";
|
|
22243
22243
|
}
|
|
22244
22244
|
};
|
|
22245
|
-
var undefinedProcessor = (schema, ctx,
|
|
22246
|
-
handleUnrepresentable(schema, ctx,
|
|
22245
|
+
var undefinedProcessor = (schema, ctx, json4, params) => {
|
|
22246
|
+
handleUnrepresentable(schema, ctx, json4, params, "Undefined cannot be represented in JSON Schema");
|
|
22247
22247
|
};
|
|
22248
|
-
var voidProcessor = (schema, ctx,
|
|
22249
|
-
handleUnrepresentable(schema, ctx,
|
|
22248
|
+
var voidProcessor = (schema, ctx, json4, params) => {
|
|
22249
|
+
handleUnrepresentable(schema, ctx, json4, params, "Void cannot be represented in JSON Schema");
|
|
22250
22250
|
};
|
|
22251
|
-
var neverProcessor = (_schema, _ctx,
|
|
22252
|
-
|
|
22251
|
+
var neverProcessor = (_schema, _ctx, json4, _params) => {
|
|
22252
|
+
json4.not = {};
|
|
22253
22253
|
};
|
|
22254
22254
|
var anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
22255
22255
|
};
|
|
22256
22256
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
22257
22257
|
};
|
|
22258
|
-
var dateProcessor = (schema, ctx,
|
|
22259
|
-
handleUnrepresentable(schema, ctx,
|
|
22258
|
+
var dateProcessor = (schema, ctx, json4, params) => {
|
|
22259
|
+
handleUnrepresentable(schema, ctx, json4, params, "Date cannot be represented in JSON Schema");
|
|
22260
22260
|
};
|
|
22261
|
-
var enumProcessor = (schema, _ctx,
|
|
22261
|
+
var enumProcessor = (schema, _ctx, json4, _params) => {
|
|
22262
22262
|
const def = schema._zod.def;
|
|
22263
22263
|
const values = getEnumValues(def.entries);
|
|
22264
22264
|
if (values.length === 0) {
|
|
22265
|
-
|
|
22265
|
+
json4.not = {};
|
|
22266
22266
|
return;
|
|
22267
22267
|
}
|
|
22268
22268
|
if (values.every((v) => typeof v === "number"))
|
|
22269
|
-
|
|
22269
|
+
json4.type = "number";
|
|
22270
22270
|
if (values.every((v) => typeof v === "string"))
|
|
22271
|
-
|
|
22272
|
-
|
|
22271
|
+
json4.type = "string";
|
|
22272
|
+
json4.enum = values;
|
|
22273
22273
|
};
|
|
22274
|
-
var literalProcessor = (schema, ctx,
|
|
22274
|
+
var literalProcessor = (schema, ctx, json4, params) => {
|
|
22275
22275
|
const def = schema._zod.def;
|
|
22276
22276
|
if (def.values.length === 0) {
|
|
22277
|
-
|
|
22277
|
+
json4.not = {};
|
|
22278
22278
|
return;
|
|
22279
22279
|
}
|
|
22280
22280
|
const vals = [];
|
|
22281
22281
|
for (const val of def.values) {
|
|
22282
22282
|
if (val === void 0) {
|
|
22283
|
-
if (handleUnrepresentable(schema, ctx,
|
|
22283
|
+
if (handleUnrepresentable(schema, ctx, json4, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
22284
22284
|
return;
|
|
22285
22285
|
} else if (typeof val === "bigint") {
|
|
22286
|
-
if (handleUnrepresentable(schema, ctx,
|
|
22286
|
+
if (handleUnrepresentable(schema, ctx, json4, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
22287
22287
|
return;
|
|
22288
22288
|
vals.push(Number(val));
|
|
22289
22289
|
} else {
|
|
@@ -22293,37 +22293,37 @@ var literalProcessor = (schema, ctx, json3, params) => {
|
|
|
22293
22293
|
if (vals.length === 0) {
|
|
22294
22294
|
} else if (vals.length === 1) {
|
|
22295
22295
|
const val = vals[0];
|
|
22296
|
-
|
|
22296
|
+
json4.type = val === null ? "null" : typeof val;
|
|
22297
22297
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
22298
|
-
|
|
22298
|
+
json4.enum = [val];
|
|
22299
22299
|
} else {
|
|
22300
|
-
|
|
22300
|
+
json4.const = val;
|
|
22301
22301
|
}
|
|
22302
22302
|
} else {
|
|
22303
22303
|
if (vals.every((v) => typeof v === "number"))
|
|
22304
|
-
|
|
22304
|
+
json4.type = "number";
|
|
22305
22305
|
if (vals.every((v) => typeof v === "string"))
|
|
22306
|
-
|
|
22306
|
+
json4.type = "string";
|
|
22307
22307
|
if (vals.every((v) => typeof v === "boolean"))
|
|
22308
|
-
|
|
22308
|
+
json4.type = "boolean";
|
|
22309
22309
|
if (vals.every((v) => v === null))
|
|
22310
|
-
|
|
22311
|
-
|
|
22310
|
+
json4.type = "null";
|
|
22311
|
+
json4.enum = vals;
|
|
22312
22312
|
}
|
|
22313
22313
|
};
|
|
22314
|
-
var nanProcessor = (schema, ctx,
|
|
22315
|
-
handleUnrepresentable(schema, ctx,
|
|
22314
|
+
var nanProcessor = (schema, ctx, json4, params) => {
|
|
22315
|
+
handleUnrepresentable(schema, ctx, json4, params, "NaN cannot be represented in JSON Schema");
|
|
22316
22316
|
};
|
|
22317
|
-
var templateLiteralProcessor = (schema, _ctx,
|
|
22318
|
-
const _json =
|
|
22317
|
+
var templateLiteralProcessor = (schema, _ctx, json4, _params) => {
|
|
22318
|
+
const _json = json4;
|
|
22319
22319
|
const pattern = schema._zod.pattern;
|
|
22320
22320
|
if (!pattern)
|
|
22321
22321
|
throw new Error("Pattern not found in template literal");
|
|
22322
22322
|
_json.type = "string";
|
|
22323
22323
|
_json.pattern = pattern.source;
|
|
22324
22324
|
};
|
|
22325
|
-
var fileProcessor = (schema, _ctx,
|
|
22326
|
-
const _json =
|
|
22325
|
+
var fileProcessor = (schema, _ctx, json4, _params) => {
|
|
22326
|
+
const _json = json4;
|
|
22327
22327
|
_json.type = "string";
|
|
22328
22328
|
_json.format = "binary";
|
|
22329
22329
|
_json.contentEncoding = "binary";
|
|
@@ -22341,34 +22341,34 @@ var fileProcessor = (schema, _ctx, json3, _params) => {
|
|
|
22341
22341
|
else
|
|
22342
22342
|
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
22343
22343
|
};
|
|
22344
|
-
var successProcessor = (_schema, _ctx,
|
|
22345
|
-
|
|
22344
|
+
var successProcessor = (_schema, _ctx, json4, _params) => {
|
|
22345
|
+
json4.type = "boolean";
|
|
22346
22346
|
};
|
|
22347
|
-
var customProcessor = (schema, ctx,
|
|
22348
|
-
handleUnrepresentable(schema, ctx,
|
|
22347
|
+
var customProcessor = (schema, ctx, json4, params) => {
|
|
22348
|
+
handleUnrepresentable(schema, ctx, json4, params, "Custom types cannot be represented in JSON Schema");
|
|
22349
22349
|
};
|
|
22350
|
-
var functionProcessor = (schema, ctx,
|
|
22351
|
-
handleUnrepresentable(schema, ctx,
|
|
22350
|
+
var functionProcessor = (schema, ctx, json4, params) => {
|
|
22351
|
+
handleUnrepresentable(schema, ctx, json4, params, "Function types cannot be represented in JSON Schema");
|
|
22352
22352
|
};
|
|
22353
|
-
var transformProcessor = (schema, ctx,
|
|
22354
|
-
handleUnrepresentable(schema, ctx,
|
|
22353
|
+
var transformProcessor = (schema, ctx, json4, params) => {
|
|
22354
|
+
handleUnrepresentable(schema, ctx, json4, params, "Transforms cannot be represented in JSON Schema");
|
|
22355
22355
|
};
|
|
22356
|
-
var mapProcessor = (schema, ctx,
|
|
22357
|
-
handleUnrepresentable(schema, ctx,
|
|
22356
|
+
var mapProcessor = (schema, ctx, json4, params) => {
|
|
22357
|
+
handleUnrepresentable(schema, ctx, json4, params, "Map cannot be represented in JSON Schema");
|
|
22358
22358
|
};
|
|
22359
|
-
var setProcessor = (schema, ctx,
|
|
22360
|
-
handleUnrepresentable(schema, ctx,
|
|
22359
|
+
var setProcessor = (schema, ctx, json4, params) => {
|
|
22360
|
+
handleUnrepresentable(schema, ctx, json4, params, "Set cannot be represented in JSON Schema");
|
|
22361
22361
|
};
|
|
22362
22362
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
22363
|
-
const
|
|
22363
|
+
const json4 = _json;
|
|
22364
22364
|
const def = schema._zod.def;
|
|
22365
22365
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
22366
22366
|
if (typeof minimum === "number")
|
|
22367
|
-
|
|
22367
|
+
json4.minItems = minimum;
|
|
22368
22368
|
if (typeof maximum === "number")
|
|
22369
|
-
|
|
22370
|
-
|
|
22371
|
-
|
|
22369
|
+
json4.maxItems = maximum;
|
|
22370
|
+
json4.type = "array";
|
|
22371
|
+
json4.items = processSchema(def.element, ctx, {
|
|
22372
22372
|
...params,
|
|
22373
22373
|
path: [...params.path, "items"]
|
|
22374
22374
|
});
|
|
@@ -22384,17 +22384,17 @@ function inputOptin(schema) {
|
|
|
22384
22384
|
return schema._zod.optin;
|
|
22385
22385
|
}
|
|
22386
22386
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
22387
|
-
const
|
|
22387
|
+
const json4 = _json;
|
|
22388
22388
|
const def = schema._zod.def;
|
|
22389
22389
|
const shape = def.shape;
|
|
22390
22390
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
22391
|
-
if (symbolKeys.length && handleUnrepresentable(schema, ctx,
|
|
22391
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json4, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
22392
22392
|
return;
|
|
22393
22393
|
}
|
|
22394
|
-
|
|
22395
|
-
|
|
22394
|
+
json4.type = "object";
|
|
22395
|
+
json4.properties = {};
|
|
22396
22396
|
for (const key in shape) {
|
|
22397
|
-
assignProp(
|
|
22397
|
+
assignProp(json4.properties, key, processSchema(shape[key], ctx, {
|
|
22398
22398
|
...params,
|
|
22399
22399
|
path: [...params.path, "properties", key]
|
|
22400
22400
|
}));
|
|
@@ -22407,21 +22407,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
22407
22407
|
}
|
|
22408
22408
|
}
|
|
22409
22409
|
if (requiredKeys.length > 0) {
|
|
22410
|
-
|
|
22410
|
+
json4.required = requiredKeys;
|
|
22411
22411
|
}
|
|
22412
22412
|
if (def.catchall?._zod.def.type === "never") {
|
|
22413
|
-
|
|
22413
|
+
json4.additionalProperties = false;
|
|
22414
22414
|
} else if (!def.catchall) {
|
|
22415
22415
|
if (ctx.io === "output")
|
|
22416
|
-
|
|
22416
|
+
json4.additionalProperties = false;
|
|
22417
22417
|
} else if (def.catchall) {
|
|
22418
|
-
|
|
22418
|
+
json4.additionalProperties = processSchema(def.catchall, ctx, {
|
|
22419
22419
|
...params,
|
|
22420
22420
|
path: [...params.path, "additionalProperties"]
|
|
22421
22421
|
});
|
|
22422
22422
|
}
|
|
22423
22423
|
};
|
|
22424
|
-
var unionProcessor = (schema, ctx,
|
|
22424
|
+
var unionProcessor = (schema, ctx, json4, params) => {
|
|
22425
22425
|
const def = schema._zod.def;
|
|
22426
22426
|
const isExclusive = def.inclusive === false;
|
|
22427
22427
|
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
@@ -22429,12 +22429,12 @@ var unionProcessor = (schema, ctx, json3, params) => {
|
|
|
22429
22429
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
22430
22430
|
}));
|
|
22431
22431
|
if (isExclusive) {
|
|
22432
|
-
|
|
22432
|
+
json4.oneOf = options;
|
|
22433
22433
|
} else {
|
|
22434
|
-
|
|
22434
|
+
json4.anyOf = options;
|
|
22435
22435
|
}
|
|
22436
22436
|
};
|
|
22437
|
-
var intersectionProcessor = (schema, ctx,
|
|
22437
|
+
var intersectionProcessor = (schema, ctx, json4, params) => {
|
|
22438
22438
|
const def = schema._zod.def;
|
|
22439
22439
|
const a = processSchema(def.left, ctx, {
|
|
22440
22440
|
...params,
|
|
@@ -22449,13 +22449,13 @@ var intersectionProcessor = (schema, ctx, json3, params) => {
|
|
|
22449
22449
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
22450
22450
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
22451
22451
|
];
|
|
22452
|
-
|
|
22452
|
+
json4.allOf = allOf;
|
|
22453
22453
|
ctx.intersections.push(allOf);
|
|
22454
22454
|
};
|
|
22455
22455
|
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
22456
|
-
const
|
|
22456
|
+
const json4 = _json;
|
|
22457
22457
|
const def = schema._zod.def;
|
|
22458
|
-
|
|
22458
|
+
json4.type = "array";
|
|
22459
22459
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
22460
22460
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
22461
22461
|
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
@@ -22477,70 +22477,70 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
22477
22477
|
const maxItems = def.items.length;
|
|
22478
22478
|
const isClosed = !def.rest;
|
|
22479
22479
|
if (ctx.target === "draft-2020-12") {
|
|
22480
|
-
|
|
22480
|
+
json4.prefixItems = prefixItems;
|
|
22481
22481
|
if (isClosed) {
|
|
22482
|
-
|
|
22482
|
+
json4.items = false;
|
|
22483
22483
|
} else if (rest) {
|
|
22484
|
-
|
|
22484
|
+
json4.items = rest;
|
|
22485
22485
|
}
|
|
22486
22486
|
if (minItems > 0)
|
|
22487
|
-
|
|
22487
|
+
json4.minItems = minItems;
|
|
22488
22488
|
if (isClosed)
|
|
22489
|
-
|
|
22489
|
+
json4.maxItems = maxItems;
|
|
22490
22490
|
} else if (ctx.target === "openapi-3.0") {
|
|
22491
|
-
|
|
22491
|
+
json4.items = {
|
|
22492
22492
|
anyOf: prefixItems
|
|
22493
22493
|
};
|
|
22494
22494
|
if (rest) {
|
|
22495
|
-
|
|
22495
|
+
json4.items.anyOf.push(rest);
|
|
22496
22496
|
}
|
|
22497
22497
|
if (minItems > 0)
|
|
22498
|
-
|
|
22498
|
+
json4.minItems = minItems;
|
|
22499
22499
|
if (isClosed)
|
|
22500
|
-
|
|
22500
|
+
json4.maxItems = maxItems;
|
|
22501
22501
|
} else {
|
|
22502
|
-
|
|
22502
|
+
json4.items = prefixItems;
|
|
22503
22503
|
if (isClosed) {
|
|
22504
|
-
|
|
22504
|
+
json4.additionalItems = false;
|
|
22505
22505
|
} else if (rest) {
|
|
22506
|
-
|
|
22506
|
+
json4.additionalItems = rest;
|
|
22507
22507
|
}
|
|
22508
22508
|
if (minItems > 0)
|
|
22509
|
-
|
|
22509
|
+
json4.minItems = minItems;
|
|
22510
22510
|
if (isClosed)
|
|
22511
|
-
|
|
22511
|
+
json4.maxItems = maxItems;
|
|
22512
22512
|
}
|
|
22513
22513
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
22514
22514
|
if (typeof minimum === "number")
|
|
22515
|
-
|
|
22515
|
+
json4.minItems = minimum;
|
|
22516
22516
|
if (typeof maximum === "number")
|
|
22517
|
-
|
|
22518
|
-
};
|
|
22519
|
-
function stringifyKeyNames(bySchema,
|
|
22520
|
-
if (
|
|
22521
|
-
if (visited.has(
|
|
22522
|
-
return
|
|
22523
|
-
visited.add(
|
|
22524
|
-
const def = bySchema.get(
|
|
22517
|
+
json4.maxItems = maximum;
|
|
22518
|
+
};
|
|
22519
|
+
function stringifyKeyNames(bySchema, json4, visited) {
|
|
22520
|
+
if (json4.$ref) {
|
|
22521
|
+
if (visited.has(json4))
|
|
22522
|
+
return json4;
|
|
22523
|
+
visited.add(json4);
|
|
22524
|
+
const def = bySchema.get(json4)?.def;
|
|
22525
22525
|
if (!def)
|
|
22526
|
-
return
|
|
22526
|
+
return json4;
|
|
22527
22527
|
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
22528
|
-
return inlined === def ?
|
|
22528
|
+
return inlined === def ? json4 : inlined;
|
|
22529
22529
|
}
|
|
22530
22530
|
for (const keyword of ["anyOf", "oneOf"]) {
|
|
22531
|
-
const branches =
|
|
22531
|
+
const branches = json4[keyword];
|
|
22532
22532
|
if (!Array.isArray(branches))
|
|
22533
22533
|
continue;
|
|
22534
22534
|
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
22535
22535
|
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
22536
|
-
|
|
22536
|
+
json4 = { ...json4, [keyword]: mapped };
|
|
22537
22537
|
}
|
|
22538
|
-
const types = Array.isArray(
|
|
22538
|
+
const types = Array.isArray(json4.type) ? json4.type : [json4.type];
|
|
22539
22539
|
const numericType = !types.includes("string") && types.some((t2) => t2 === "number" || t2 === "integer");
|
|
22540
|
-
const values =
|
|
22540
|
+
const values = json4.enum ?? (json4.const !== void 0 ? [json4.const] : void 0);
|
|
22541
22541
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
22542
|
-
return
|
|
22543
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } =
|
|
22542
|
+
return json4;
|
|
22543
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json4;
|
|
22544
22544
|
if (rest.enum)
|
|
22545
22545
|
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
22546
22546
|
else if (typeof rest.const === "number")
|
|
@@ -22580,9 +22580,9 @@ function rewriteKeyNames(ctx) {
|
|
|
22580
22580
|
}
|
|
22581
22581
|
}
|
|
22582
22582
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
22583
|
-
const
|
|
22583
|
+
const json4 = _json;
|
|
22584
22584
|
const def = schema._zod.def;
|
|
22585
|
-
|
|
22585
|
+
json4.type = "object";
|
|
22586
22586
|
const keyType = def.keyType;
|
|
22587
22587
|
const patterns = aggregateChecks(keyType).patterns;
|
|
22588
22588
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
@@ -22590,13 +22590,13 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
22590
22590
|
...params,
|
|
22591
22591
|
path: [...params.path, "patternProperties", "*"]
|
|
22592
22592
|
});
|
|
22593
|
-
|
|
22593
|
+
json4.patternProperties = {};
|
|
22594
22594
|
for (const pattern of patterns) {
|
|
22595
|
-
assignProp(
|
|
22595
|
+
assignProp(json4.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
22596
22596
|
}
|
|
22597
22597
|
} else {
|
|
22598
22598
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
22599
|
-
|
|
22599
|
+
json4.propertyNames = processSchema(def.keyType, ctx, {
|
|
22600
22600
|
...params,
|
|
22601
22601
|
path: [...params.path, "propertyNames"]
|
|
22602
22602
|
});
|
|
@@ -22608,7 +22608,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
22608
22608
|
}
|
|
22609
22609
|
pending.push(schema);
|
|
22610
22610
|
}
|
|
22611
|
-
|
|
22611
|
+
json4.additionalProperties = processSchema(def.valueType, ctx, {
|
|
22612
22612
|
...params,
|
|
22613
22613
|
path: [...params.path, "additionalProperties"]
|
|
22614
22614
|
});
|
|
@@ -22618,19 +22618,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
22618
22618
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
22619
22619
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
22620
22620
|
if (validKeyValues.length > 0) {
|
|
22621
|
-
|
|
22621
|
+
json4.required = validKeyValues.map(String);
|
|
22622
22622
|
}
|
|
22623
22623
|
}
|
|
22624
22624
|
};
|
|
22625
|
-
var nullableProcessor = (schema, ctx,
|
|
22625
|
+
var nullableProcessor = (schema, ctx, json4, params) => {
|
|
22626
22626
|
const def = schema._zod.def;
|
|
22627
22627
|
const inner = processSchema(def.innerType, ctx, params);
|
|
22628
22628
|
const seen = ctx.seen.get(schema);
|
|
22629
22629
|
if (ctx.target === "openapi-3.0") {
|
|
22630
22630
|
seen.ref = def.innerType;
|
|
22631
|
-
|
|
22631
|
+
json4.nullable = true;
|
|
22632
22632
|
} else {
|
|
22633
|
-
|
|
22633
|
+
json4.anyOf = [inner, { type: "null" }];
|
|
22634
22634
|
}
|
|
22635
22635
|
};
|
|
22636
22636
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -22640,7 +22640,7 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
|
22640
22640
|
seen.ref = def.innerType;
|
|
22641
22641
|
};
|
|
22642
22642
|
var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
|
|
22643
|
-
function serializeDefaultValue(value, schema, ctx,
|
|
22643
|
+
function serializeDefaultValue(value, schema, ctx, json4, params) {
|
|
22644
22644
|
let unrepresentable = false;
|
|
22645
22645
|
const serialized = JSON.stringify(value, (_, val) => {
|
|
22646
22646
|
if (typeof val !== "bigint")
|
|
@@ -22650,30 +22650,30 @@ function serializeDefaultValue(value, schema, ctx, json3, params) {
|
|
|
22650
22650
|
});
|
|
22651
22651
|
if (!unrepresentable)
|
|
22652
22652
|
return JSON.parse(serialized);
|
|
22653
|
-
handleUnrepresentable(schema, ctx,
|
|
22653
|
+
handleUnrepresentable(schema, ctx, json4, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
22654
22654
|
return UNREPRESENTABLE_DEFAULT;
|
|
22655
22655
|
}
|
|
22656
|
-
var defaultProcessor = (schema, ctx,
|
|
22656
|
+
var defaultProcessor = (schema, ctx, json4, params) => {
|
|
22657
22657
|
const def = schema._zod.def;
|
|
22658
22658
|
processSchema(def.innerType, ctx, params);
|
|
22659
22659
|
const seen = ctx.seen.get(schema);
|
|
22660
22660
|
seen.ref = def.innerType;
|
|
22661
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
22661
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json4, params);
|
|
22662
22662
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
22663
|
-
|
|
22663
|
+
json4.default = value;
|
|
22664
22664
|
};
|
|
22665
|
-
var prefaultProcessor = (schema, ctx,
|
|
22665
|
+
var prefaultProcessor = (schema, ctx, json4, params) => {
|
|
22666
22666
|
const def = schema._zod.def;
|
|
22667
22667
|
processSchema(def.innerType, ctx, params);
|
|
22668
22668
|
const seen = ctx.seen.get(schema);
|
|
22669
22669
|
seen.ref = def.innerType;
|
|
22670
22670
|
if (ctx.io !== "input")
|
|
22671
22671
|
return;
|
|
22672
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
22672
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json4, params);
|
|
22673
22673
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
22674
|
-
|
|
22674
|
+
json4._prefault = value;
|
|
22675
22675
|
};
|
|
22676
|
-
var catchProcessor = (schema, ctx,
|
|
22676
|
+
var catchProcessor = (schema, ctx, json4, params) => {
|
|
22677
22677
|
const def = schema._zod.def;
|
|
22678
22678
|
processSchema(def.innerType, ctx, params);
|
|
22679
22679
|
const seen = ctx.seen.get(schema);
|
|
@@ -22682,10 +22682,10 @@ var catchProcessor = (schema, ctx, json3, params) => {
|
|
|
22682
22682
|
try {
|
|
22683
22683
|
catchValue = def.catchValue(void 0);
|
|
22684
22684
|
} catch {
|
|
22685
|
-
handleUnrepresentable(schema, ctx,
|
|
22685
|
+
handleUnrepresentable(schema, ctx, json4, params, "Dynamic catch values are not supported in JSON Schema");
|
|
22686
22686
|
return;
|
|
22687
22687
|
}
|
|
22688
|
-
|
|
22688
|
+
json4.default = catchValue;
|
|
22689
22689
|
};
|
|
22690
22690
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
22691
22691
|
const def = schema._zod.def;
|
|
@@ -22695,12 +22695,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
22695
22695
|
const seen = ctx.seen.get(schema);
|
|
22696
22696
|
seen.ref = innerType;
|
|
22697
22697
|
};
|
|
22698
|
-
var readonlyProcessor = (schema, ctx,
|
|
22698
|
+
var readonlyProcessor = (schema, ctx, json4, params) => {
|
|
22699
22699
|
const def = schema._zod.def;
|
|
22700
22700
|
processSchema(def.innerType, ctx, params);
|
|
22701
22701
|
const seen = ctx.seen.get(schema);
|
|
22702
22702
|
seen.ref = def.innerType;
|
|
22703
|
-
|
|
22703
|
+
json4.readOnly = true;
|
|
22704
22704
|
};
|
|
22705
22705
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
22706
22706
|
const def = schema._zod.def;
|
|
@@ -23342,7 +23342,7 @@ var _ZodString = /* @__PURE__ */ $constructor(
|
|
|
23342
23342
|
(inst, def) => {
|
|
23343
23343
|
$ZodString.init(inst, def);
|
|
23344
23344
|
ZodType.init(inst, def);
|
|
23345
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23345
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => stringProcessor(inst, ctx, json4, params);
|
|
23346
23346
|
},
|
|
23347
23347
|
/* @__PURE__ */ util_exports.derived({
|
|
23348
23348
|
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
@@ -23701,7 +23701,7 @@ var ZodNumber = /* @__PURE__ */ $constructor(
|
|
|
23701
23701
|
(inst, def) => {
|
|
23702
23702
|
$ZodNumber.init(inst, def);
|
|
23703
23703
|
ZodType.init(inst, def);
|
|
23704
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23704
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => numberProcessor(inst, ctx, json4, params);
|
|
23705
23705
|
inst.isFinite = true;
|
|
23706
23706
|
},
|
|
23707
23707
|
/* @__PURE__ */ util_exports.derived({
|
|
@@ -23791,7 +23791,7 @@ function uint32(params) {
|
|
|
23791
23791
|
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
23792
23792
|
$ZodBoolean.init(inst, def);
|
|
23793
23793
|
ZodType.init(inst, def);
|
|
23794
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23794
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => booleanProcessor(inst, ctx, json4, params);
|
|
23795
23795
|
});
|
|
23796
23796
|
function boolean2(params) {
|
|
23797
23797
|
return _boolean(ZodBoolean, params);
|
|
@@ -23801,7 +23801,7 @@ var ZodBigInt = /* @__PURE__ */ $constructor(
|
|
|
23801
23801
|
(inst, def) => {
|
|
23802
23802
|
$ZodBigInt.init(inst, def);
|
|
23803
23803
|
ZodType.init(inst, def);
|
|
23804
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23804
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => bigintProcessor(inst, ctx, json4, params);
|
|
23805
23805
|
},
|
|
23806
23806
|
/* @__PURE__ */ util_exports.derived({
|
|
23807
23807
|
minValue: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
@@ -23859,7 +23859,7 @@ function uint64(params) {
|
|
|
23859
23859
|
var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
23860
23860
|
$ZodSymbol.init(inst, def);
|
|
23861
23861
|
ZodType.init(inst, def);
|
|
23862
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23862
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => symbolProcessor(inst, ctx, json4, params);
|
|
23863
23863
|
});
|
|
23864
23864
|
function symbol(params) {
|
|
23865
23865
|
return _symbol(ZodSymbol, params);
|
|
@@ -23867,7 +23867,7 @@ function symbol(params) {
|
|
|
23867
23867
|
var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
23868
23868
|
$ZodUndefined.init(inst, def);
|
|
23869
23869
|
ZodType.init(inst, def);
|
|
23870
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23870
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => undefinedProcessor(inst, ctx, json4, params);
|
|
23871
23871
|
});
|
|
23872
23872
|
function _undefined3(params) {
|
|
23873
23873
|
return _undefined2(ZodUndefined, params);
|
|
@@ -23875,7 +23875,7 @@ function _undefined3(params) {
|
|
|
23875
23875
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
23876
23876
|
$ZodNull.init(inst, def);
|
|
23877
23877
|
ZodType.init(inst, def);
|
|
23878
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23878
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => nullProcessor(inst, ctx, json4, params);
|
|
23879
23879
|
});
|
|
23880
23880
|
function _null3(params) {
|
|
23881
23881
|
return _null2(ZodNull, params);
|
|
@@ -23883,7 +23883,7 @@ function _null3(params) {
|
|
|
23883
23883
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
23884
23884
|
$ZodAny.init(inst, def);
|
|
23885
23885
|
ZodType.init(inst, def);
|
|
23886
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23886
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => anyProcessor(inst, ctx, json4, params);
|
|
23887
23887
|
});
|
|
23888
23888
|
function any() {
|
|
23889
23889
|
return _any(ZodAny);
|
|
@@ -23891,7 +23891,7 @@ function any() {
|
|
|
23891
23891
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
23892
23892
|
$ZodUnknown.init(inst, def);
|
|
23893
23893
|
ZodType.init(inst, def);
|
|
23894
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23894
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => unknownProcessor(inst, ctx, json4, params);
|
|
23895
23895
|
});
|
|
23896
23896
|
function unknown() {
|
|
23897
23897
|
return _unknown(ZodUnknown);
|
|
@@ -23899,7 +23899,7 @@ function unknown() {
|
|
|
23899
23899
|
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
23900
23900
|
$ZodNever.init(inst, def);
|
|
23901
23901
|
ZodType.init(inst, def);
|
|
23902
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23902
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => neverProcessor(inst, ctx, json4, params);
|
|
23903
23903
|
});
|
|
23904
23904
|
function never(params) {
|
|
23905
23905
|
return _never(ZodNever, params);
|
|
@@ -23907,7 +23907,7 @@ function never(params) {
|
|
|
23907
23907
|
var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
23908
23908
|
$ZodVoid.init(inst, def);
|
|
23909
23909
|
ZodType.init(inst, def);
|
|
23910
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23910
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => voidProcessor(inst, ctx, json4, params);
|
|
23911
23911
|
});
|
|
23912
23912
|
function _void2(params) {
|
|
23913
23913
|
return _void(ZodVoid, params);
|
|
@@ -23917,7 +23917,7 @@ var ZodDate = /* @__PURE__ */ $constructor(
|
|
|
23917
23917
|
(inst, def) => {
|
|
23918
23918
|
$ZodDate.init(inst, def);
|
|
23919
23919
|
ZodType.init(inst, def);
|
|
23920
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23920
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => dateProcessor(inst, ctx, json4, params);
|
|
23921
23921
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
23922
23922
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
23923
23923
|
},
|
|
@@ -23939,7 +23939,7 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
23939
23939
|
_ensureDefaultMemoizer();
|
|
23940
23940
|
$ZodArray.init(inst, def);
|
|
23941
23941
|
ZodType.init(inst, def);
|
|
23942
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23942
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => arrayProcessor(inst, ctx, json4, params);
|
|
23943
23943
|
inst.element = def.element;
|
|
23944
23944
|
}, {
|
|
23945
23945
|
min(n, params) {
|
|
@@ -23969,7 +23969,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
23969
23969
|
_ensureDefaultMemoizer();
|
|
23970
23970
|
$ZodObjectJIT.init(inst, def);
|
|
23971
23971
|
ZodType.init(inst, def);
|
|
23972
|
-
inst._zod.processJSONSchema = (ctx,
|
|
23972
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => objectProcessor(inst, ctx, json4, params);
|
|
23973
23973
|
util_exports.installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
23974
23974
|
}, {
|
|
23975
23975
|
keyof() {
|
|
@@ -24042,7 +24042,7 @@ function looseObject(shape, params) {
|
|
|
24042
24042
|
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
24043
24043
|
$ZodUnion.init(inst, def);
|
|
24044
24044
|
ZodType.init(inst, def);
|
|
24045
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24045
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => unionProcessor(inst, ctx, json4, params);
|
|
24046
24046
|
inst.options = def.options;
|
|
24047
24047
|
});
|
|
24048
24048
|
function union(options, params) {
|
|
@@ -24055,7 +24055,7 @@ function union(options, params) {
|
|
|
24055
24055
|
var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
24056
24056
|
ZodUnion.init(inst, def);
|
|
24057
24057
|
$ZodXor.init(inst, def);
|
|
24058
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24058
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => unionProcessor(inst, ctx, json4, params);
|
|
24059
24059
|
inst.options = def.options;
|
|
24060
24060
|
});
|
|
24061
24061
|
function xor(options, params) {
|
|
@@ -24081,7 +24081,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
24081
24081
|
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
24082
24082
|
$ZodIntersection.init(inst, def);
|
|
24083
24083
|
ZodType.init(inst, def);
|
|
24084
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24084
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => intersectionProcessor(inst, ctx, json4, params);
|
|
24085
24085
|
});
|
|
24086
24086
|
function intersection(left, right) {
|
|
24087
24087
|
return new ZodIntersection({
|
|
@@ -24094,7 +24094,7 @@ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
|
24094
24094
|
_ensureDefaultMemoizer();
|
|
24095
24095
|
$ZodTuple.init(inst, def);
|
|
24096
24096
|
ZodType.init(inst, def);
|
|
24097
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24097
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => tupleProcessor(inst, ctx, json4, params);
|
|
24098
24098
|
}, {
|
|
24099
24099
|
rest(rest) {
|
|
24100
24100
|
return this.clone({
|
|
@@ -24127,7 +24127,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
24127
24127
|
_ensureDefaultMemoizer();
|
|
24128
24128
|
$ZodRecord.init(inst, def);
|
|
24129
24129
|
ZodType.init(inst, def);
|
|
24130
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24130
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => recordProcessor(inst, ctx, json4, params);
|
|
24131
24131
|
inst.keyType = def.keyType;
|
|
24132
24132
|
inst.valueType = def.valueType;
|
|
24133
24133
|
});
|
|
@@ -24169,7 +24169,7 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
24169
24169
|
_ensureDefaultMemoizer();
|
|
24170
24170
|
$ZodMap.init(inst, def);
|
|
24171
24171
|
ZodType.init(inst, def);
|
|
24172
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24172
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => mapProcessor(inst, ctx, json4, params);
|
|
24173
24173
|
inst.keyType = def.keyType;
|
|
24174
24174
|
inst.valueType = def.valueType;
|
|
24175
24175
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -24189,7 +24189,7 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
|
24189
24189
|
_ensureDefaultMemoizer();
|
|
24190
24190
|
$ZodSet.init(inst, def);
|
|
24191
24191
|
ZodType.init(inst, def);
|
|
24192
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24192
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => setProcessor(inst, ctx, json4, params);
|
|
24193
24193
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
24194
24194
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
24195
24195
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -24205,7 +24205,7 @@ function set(valueType, params) {
|
|
|
24205
24205
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
24206
24206
|
$ZodEnum.init(inst, def);
|
|
24207
24207
|
ZodType.init(inst, def);
|
|
24208
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24208
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => enumProcessor(inst, ctx, json4, params);
|
|
24209
24209
|
inst.enum = def.entries;
|
|
24210
24210
|
inst.options = [...inst._zod.values];
|
|
24211
24211
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -24258,7 +24258,7 @@ function nativeEnum(entries, params) {
|
|
|
24258
24258
|
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
24259
24259
|
$ZodLiteral.init(inst, def);
|
|
24260
24260
|
ZodType.init(inst, def);
|
|
24261
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24261
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => literalProcessor(inst, ctx, json4, params);
|
|
24262
24262
|
inst.values = new Set(def.values);
|
|
24263
24263
|
Object.defineProperty(inst, "value", {
|
|
24264
24264
|
get() {
|
|
@@ -24279,7 +24279,7 @@ function literal(value, params) {
|
|
|
24279
24279
|
var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
24280
24280
|
$ZodFile.init(inst, def);
|
|
24281
24281
|
ZodType.init(inst, def);
|
|
24282
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24282
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => fileProcessor(inst, ctx, json4, params);
|
|
24283
24283
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
24284
24284
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
24285
24285
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
@@ -24291,7 +24291,7 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
24291
24291
|
_ensureDefaultMemoizer();
|
|
24292
24292
|
$ZodTransform.init(inst, def);
|
|
24293
24293
|
ZodType.init(inst, def);
|
|
24294
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24294
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => transformProcessor(inst, ctx, json4, params);
|
|
24295
24295
|
inst._zod.parse = (payload, _ctx) => {
|
|
24296
24296
|
if (_ctx.direction === "backward") {
|
|
24297
24297
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -24330,7 +24330,7 @@ function transform(fn) {
|
|
|
24330
24330
|
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
24331
24331
|
$ZodOptional.init(inst, def);
|
|
24332
24332
|
ZodType.init(inst, def);
|
|
24333
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24333
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => optionalProcessor(inst, ctx, json4, params);
|
|
24334
24334
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24335
24335
|
});
|
|
24336
24336
|
function optional(innerType) {
|
|
@@ -24342,7 +24342,7 @@ function optional(innerType) {
|
|
|
24342
24342
|
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
24343
24343
|
$ZodExactOptional.init(inst, def);
|
|
24344
24344
|
ZodType.init(inst, def);
|
|
24345
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24345
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => optionalProcessor(inst, ctx, json4, params);
|
|
24346
24346
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24347
24347
|
});
|
|
24348
24348
|
function exactOptional(innerType) {
|
|
@@ -24354,7 +24354,7 @@ function exactOptional(innerType) {
|
|
|
24354
24354
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
24355
24355
|
$ZodNullable.init(inst, def);
|
|
24356
24356
|
ZodType.init(inst, def);
|
|
24357
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24357
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => nullableProcessor(inst, ctx, json4, params);
|
|
24358
24358
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24359
24359
|
});
|
|
24360
24360
|
function nullable(innerType) {
|
|
@@ -24369,7 +24369,7 @@ function nullish2(innerType) {
|
|
|
24369
24369
|
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
24370
24370
|
$ZodDefault.init(inst, def);
|
|
24371
24371
|
ZodType.init(inst, def);
|
|
24372
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24372
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => defaultProcessor(inst, ctx, json4, params);
|
|
24373
24373
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24374
24374
|
inst.removeDefault = inst.unwrap;
|
|
24375
24375
|
});
|
|
@@ -24385,7 +24385,7 @@ function _default2(innerType, defaultValue) {
|
|
|
24385
24385
|
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
24386
24386
|
$ZodPrefault.init(inst, def);
|
|
24387
24387
|
ZodType.init(inst, def);
|
|
24388
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24388
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => prefaultProcessor(inst, ctx, json4, params);
|
|
24389
24389
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24390
24390
|
});
|
|
24391
24391
|
function prefault(innerType, defaultValue) {
|
|
@@ -24400,7 +24400,7 @@ function prefault(innerType, defaultValue) {
|
|
|
24400
24400
|
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
24401
24401
|
$ZodNonOptional.init(inst, def);
|
|
24402
24402
|
ZodType.init(inst, def);
|
|
24403
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24403
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => nonoptionalProcessor(inst, ctx, json4, params);
|
|
24404
24404
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24405
24405
|
});
|
|
24406
24406
|
function nonoptional(innerType, params) {
|
|
@@ -24413,7 +24413,7 @@ function nonoptional(innerType, params) {
|
|
|
24413
24413
|
var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
24414
24414
|
$ZodSuccess.init(inst, def);
|
|
24415
24415
|
ZodType.init(inst, def);
|
|
24416
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24416
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => successProcessor(inst, ctx, json4, params);
|
|
24417
24417
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24418
24418
|
});
|
|
24419
24419
|
function success(innerType) {
|
|
@@ -24425,7 +24425,7 @@ function success(innerType) {
|
|
|
24425
24425
|
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
24426
24426
|
$ZodCatch.init(inst, def);
|
|
24427
24427
|
ZodType.init(inst, def);
|
|
24428
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24428
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => catchProcessor(inst, ctx, json4, params);
|
|
24429
24429
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24430
24430
|
inst.removeCatch = inst.unwrap;
|
|
24431
24431
|
});
|
|
@@ -24439,7 +24439,7 @@ function _catch2(innerType, catchValue) {
|
|
|
24439
24439
|
var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
24440
24440
|
$ZodNaN.init(inst, def);
|
|
24441
24441
|
ZodType.init(inst, def);
|
|
24442
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24442
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => nanProcessor(inst, ctx, json4, params);
|
|
24443
24443
|
});
|
|
24444
24444
|
function nan(params) {
|
|
24445
24445
|
return _nan(ZodNaN, params);
|
|
@@ -24447,7 +24447,7 @@ function nan(params) {
|
|
|
24447
24447
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
24448
24448
|
$ZodPipe.init(inst, def);
|
|
24449
24449
|
ZodType.init(inst, def);
|
|
24450
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24450
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => pipeProcessor(inst, ctx, json4, params);
|
|
24451
24451
|
inst.in = def.in;
|
|
24452
24452
|
inst.out = def.out;
|
|
24453
24453
|
});
|
|
@@ -24489,7 +24489,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
|
|
|
24489
24489
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
24490
24490
|
$ZodReadonly.init(inst, def);
|
|
24491
24491
|
ZodType.init(inst, def);
|
|
24492
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24492
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => readonlyProcessor(inst, ctx, json4, params);
|
|
24493
24493
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24494
24494
|
});
|
|
24495
24495
|
function readonly(innerType) {
|
|
@@ -24501,7 +24501,7 @@ function readonly(innerType) {
|
|
|
24501
24501
|
var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
24502
24502
|
$ZodTemplateLiteral.init(inst, def);
|
|
24503
24503
|
ZodType.init(inst, def);
|
|
24504
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24504
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => templateLiteralProcessor(inst, ctx, json4, params);
|
|
24505
24505
|
});
|
|
24506
24506
|
function templateLiteral(parts, params) {
|
|
24507
24507
|
return new ZodTemplateLiteral({
|
|
@@ -24513,7 +24513,7 @@ function templateLiteral(parts, params) {
|
|
|
24513
24513
|
var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
24514
24514
|
$ZodLazy.init(inst, def);
|
|
24515
24515
|
ZodType.init(inst, def);
|
|
24516
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24516
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => lazyProcessor(inst, ctx, json4, params);
|
|
24517
24517
|
inst.unwrap = () => inst._zod.def.getter();
|
|
24518
24518
|
});
|
|
24519
24519
|
function lazy(getter) {
|
|
@@ -24525,7 +24525,7 @@ function lazy(getter) {
|
|
|
24525
24525
|
var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
24526
24526
|
$ZodPromise.init(inst, def);
|
|
24527
24527
|
ZodType.init(inst, def);
|
|
24528
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24528
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => promiseProcessor(inst, ctx, json4, params);
|
|
24529
24529
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
24530
24530
|
});
|
|
24531
24531
|
function promise(innerType) {
|
|
@@ -24537,7 +24537,7 @@ function promise(innerType) {
|
|
|
24537
24537
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
24538
24538
|
$ZodFunction.init(inst, def);
|
|
24539
24539
|
ZodType.init(inst, def);
|
|
24540
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24540
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => functionProcessor(inst, ctx, json4, params);
|
|
24541
24541
|
});
|
|
24542
24542
|
function _function(params) {
|
|
24543
24543
|
return new ZodFunction({
|
|
@@ -24549,7 +24549,7 @@ function _function(params) {
|
|
|
24549
24549
|
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
24550
24550
|
$ZodCustom.init(inst, def);
|
|
24551
24551
|
ZodType.init(inst, def);
|
|
24552
|
-
inst._zod.processJSONSchema = (ctx,
|
|
24552
|
+
inst._zod.processJSONSchema = (ctx, json4, params) => customProcessor(inst, ctx, json4, params);
|
|
24553
24553
|
});
|
|
24554
24554
|
function check(fn) {
|
|
24555
24555
|
const ch = new $ZodCheck({
|
|
@@ -25647,6 +25647,16 @@ var trackedEntrySchema = external_exports.union([
|
|
|
25647
25647
|
]);
|
|
25648
25648
|
var diffSideSchema = external_exports.enum(["LEFT", "RIGHT"]);
|
|
25649
25649
|
var reviewEventSchema = external_exports.enum(["COMMENT", "APPROVE", "REQUEST_CHANGES"]);
|
|
25650
|
+
var reactionContentSchema = external_exports.enum([
|
|
25651
|
+
"THUMBS_UP",
|
|
25652
|
+
"THUMBS_DOWN",
|
|
25653
|
+
"LAUGH",
|
|
25654
|
+
"HOORAY",
|
|
25655
|
+
"CONFUSED",
|
|
25656
|
+
"HEART",
|
|
25657
|
+
"ROCKET",
|
|
25658
|
+
"EYES"
|
|
25659
|
+
]);
|
|
25650
25660
|
var newThreadSchema = external_exports.discriminatedUnion("subjectType", [
|
|
25651
25661
|
external_exports.object({
|
|
25652
25662
|
subjectType: external_exports.literal("LINE"),
|
|
@@ -25782,148 +25792,15 @@ var GitHub = class {
|
|
|
25782
25792
|
};
|
|
25783
25793
|
|
|
25784
25794
|
// ../server/src/github/queries.ts
|
|
25785
|
-
var
|
|
25786
|
-
/* GraphQL */
|
|
25787
|
-
`
|
|
25788
|
-
fragment PrSummary on PullRequest {
|
|
25789
|
-
id
|
|
25790
|
-
number
|
|
25791
|
-
title
|
|
25792
|
-
url
|
|
25793
|
-
isDraft
|
|
25794
|
-
createdAt
|
|
25795
|
-
updatedAt
|
|
25796
|
-
additions
|
|
25797
|
-
deletions
|
|
25798
|
-
changedFiles
|
|
25799
|
-
headRefOid
|
|
25800
|
-
reviewDecision
|
|
25801
|
-
repository {
|
|
25802
|
-
nameWithOwner
|
|
25803
|
-
}
|
|
25804
|
-
author {
|
|
25805
|
-
login
|
|
25806
|
-
avatarUrl
|
|
25807
|
-
}
|
|
25808
|
-
labels(first: 10) {
|
|
25809
|
-
nodes {
|
|
25810
|
-
name
|
|
25811
|
-
color
|
|
25812
|
-
}
|
|
25813
|
-
}
|
|
25814
|
-
commits(last: 1) {
|
|
25815
|
-
nodes {
|
|
25816
|
-
commit {
|
|
25817
|
-
statusCheckRollup {
|
|
25818
|
-
state
|
|
25819
|
-
}
|
|
25820
|
-
}
|
|
25821
|
-
}
|
|
25822
|
-
}
|
|
25823
|
-
reviewRequests(first: 20) {
|
|
25824
|
-
totalCount
|
|
25825
|
-
nodes {
|
|
25826
|
-
requestedReviewer {
|
|
25827
|
-
__typename
|
|
25828
|
-
... on User {
|
|
25829
|
-
login
|
|
25830
|
-
}
|
|
25831
|
-
... on Team {
|
|
25832
|
-
slug
|
|
25833
|
-
}
|
|
25834
|
-
}
|
|
25835
|
-
}
|
|
25836
|
-
}
|
|
25837
|
-
latestOpinionatedReviews(first: 20) {
|
|
25838
|
-
nodes {
|
|
25839
|
-
state
|
|
25840
|
-
author {
|
|
25841
|
-
login
|
|
25842
|
-
avatarUrl
|
|
25843
|
-
}
|
|
25844
|
-
}
|
|
25845
|
-
}
|
|
25846
|
-
viewerLatestReview {
|
|
25847
|
-
state
|
|
25848
|
-
submittedAt
|
|
25849
|
-
commit {
|
|
25850
|
-
oid
|
|
25851
|
-
}
|
|
25852
|
-
}
|
|
25853
|
-
reviewThreads(first: 100) {
|
|
25854
|
-
nodes {
|
|
25855
|
-
isResolved
|
|
25856
|
-
comments(last: 1) {
|
|
25857
|
-
nodes {
|
|
25858
|
-
author {
|
|
25859
|
-
login
|
|
25860
|
-
}
|
|
25861
|
-
createdAt
|
|
25862
|
-
}
|
|
25863
|
-
}
|
|
25864
|
-
}
|
|
25865
|
-
}
|
|
25866
|
-
comments(last: 1) {
|
|
25867
|
-
nodes {
|
|
25868
|
-
author {
|
|
25869
|
-
login
|
|
25870
|
-
}
|
|
25871
|
-
createdAt
|
|
25872
|
-
}
|
|
25873
|
-
}
|
|
25874
|
-
files(first: 100) {
|
|
25875
|
-
totalCount
|
|
25876
|
-
nodes {
|
|
25877
|
-
viewerViewedState
|
|
25878
|
-
}
|
|
25879
|
-
}
|
|
25880
|
-
}
|
|
25881
|
-
`
|
|
25882
|
-
);
|
|
25883
|
-
var INBOX_SECTION_IDS = [
|
|
25884
|
-
"requested",
|
|
25885
|
-
"reviewed",
|
|
25886
|
-
"mine",
|
|
25887
|
-
"involved",
|
|
25888
|
-
"stale",
|
|
25889
|
-
"unreviewed"
|
|
25890
|
-
];
|
|
25891
|
-
var INBOX_IDS_QUERY = (
|
|
25892
|
-
/* GraphQL */
|
|
25893
|
-
`
|
|
25894
|
-
query InboxIds(${INBOX_SECTION_IDS.map((id) => `$${id}: String!`).join(", ")}) {
|
|
25895
|
-
viewer { login avatarUrl }
|
|
25896
|
-
${INBOX_SECTION_IDS.map(
|
|
25897
|
-
(id) => `${id}: search(query: $${id}, type: ISSUE, first: 50) {
|
|
25898
|
-
nodes { ... on PullRequest { id } }
|
|
25899
|
-
}`
|
|
25900
|
-
).join("\n")}
|
|
25901
|
-
}
|
|
25902
|
-
`
|
|
25903
|
-
);
|
|
25904
|
-
var PR_SUMMARIES_QUERY = (
|
|
25905
|
-
/* GraphQL */
|
|
25906
|
-
`
|
|
25907
|
-
query PrSummaries($ids: [ID!]!) {
|
|
25908
|
-
nodes(ids: $ids) {
|
|
25909
|
-
...PrSummary
|
|
25910
|
-
}
|
|
25911
|
-
}
|
|
25912
|
-
${PR_SUMMARY}
|
|
25913
|
-
`
|
|
25914
|
-
);
|
|
25915
|
-
var INBOX_FINGERPRINT_QUERY = (
|
|
25795
|
+
var REACTION_FIELDS = (
|
|
25916
25796
|
/* GraphQL */
|
|
25917
25797
|
`
|
|
25918
|
-
|
|
25919
|
-
|
|
25920
|
-
|
|
25921
|
-
|
|
25922
|
-
|
|
25923
|
-
|
|
25924
|
-
updatedAt
|
|
25925
|
-
headRefOid
|
|
25926
|
-
}
|
|
25798
|
+
fragment ReactionFields on Reactable {
|
|
25799
|
+
reactionGroups {
|
|
25800
|
+
content
|
|
25801
|
+
viewerHasReacted
|
|
25802
|
+
reactors {
|
|
25803
|
+
totalCount
|
|
25927
25804
|
}
|
|
25928
25805
|
}
|
|
25929
25806
|
}
|
|
@@ -25954,7 +25831,9 @@ var REVIEW_COMMENT_FIELDS = (
|
|
|
25954
25831
|
}
|
|
25955
25832
|
viewerCanUpdate
|
|
25956
25833
|
viewerCanDelete
|
|
25834
|
+
...ReactionFields
|
|
25957
25835
|
}
|
|
25836
|
+
${REACTION_FIELDS}
|
|
25958
25837
|
`
|
|
25959
25838
|
);
|
|
25960
25839
|
var THREAD_FIELDS = (
|
|
@@ -26009,6 +25888,7 @@ var PR_QUERY = (
|
|
|
26009
25888
|
updatedAt
|
|
26010
25889
|
body
|
|
26011
25890
|
bodyHTML
|
|
25891
|
+
...ReactionFields
|
|
26012
25892
|
baseRefName
|
|
26013
25893
|
headRefName
|
|
26014
25894
|
baseRefOid
|
|
@@ -26025,31 +25905,6 @@ var PR_QUERY = (
|
|
|
26025
25905
|
headRepository {
|
|
26026
25906
|
nameWithOwner
|
|
26027
25907
|
}
|
|
26028
|
-
lastCommit: commits(last: 1) {
|
|
26029
|
-
nodes {
|
|
26030
|
-
commit {
|
|
26031
|
-
statusCheckRollup {
|
|
26032
|
-
state
|
|
26033
|
-
contexts(first: 100) {
|
|
26034
|
-
nodes {
|
|
26035
|
-
__typename
|
|
26036
|
-
... on CheckRun {
|
|
26037
|
-
name
|
|
26038
|
-
conclusion
|
|
26039
|
-
status
|
|
26040
|
-
detailsUrl
|
|
26041
|
-
}
|
|
26042
|
-
... on StatusContext {
|
|
26043
|
-
context
|
|
26044
|
-
state
|
|
26045
|
-
targetUrl
|
|
26046
|
-
}
|
|
26047
|
-
}
|
|
26048
|
-
}
|
|
26049
|
-
}
|
|
26050
|
-
}
|
|
26051
|
-
}
|
|
26052
|
-
}
|
|
26053
25908
|
reviewRequests(first: 20) {
|
|
26054
25909
|
nodes {
|
|
26055
25910
|
requestedReviewer {
|
|
@@ -26111,6 +25966,7 @@ var PR_QUERY = (
|
|
|
26111
25966
|
url
|
|
26112
25967
|
body
|
|
26113
25968
|
bodyHTML
|
|
25969
|
+
...ReactionFields
|
|
26114
25970
|
createdAt
|
|
26115
25971
|
author {
|
|
26116
25972
|
login
|
|
@@ -26125,6 +25981,7 @@ var PR_QUERY = (
|
|
|
26125
25981
|
state
|
|
26126
25982
|
body
|
|
26127
25983
|
bodyHTML
|
|
25984
|
+
...ReactionFields
|
|
26128
25985
|
submittedAt
|
|
26129
25986
|
createdAt
|
|
26130
25987
|
url
|
|
@@ -26271,182 +26128,442 @@ async function fetchTexts(gh, ref, expressions) {
|
|
|
26271
26128
|
return texts;
|
|
26272
26129
|
}
|
|
26273
26130
|
|
|
26274
|
-
// ../server/src/
|
|
26275
|
-
var
|
|
26276
|
-
|
|
26277
|
-
|
|
26278
|
-
|
|
26279
|
-
|
|
26280
|
-
|
|
26281
|
-
|
|
26282
|
-
|
|
26283
|
-
|
|
26284
|
-
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
|
|
26292
|
-
|
|
26293
|
-
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
}
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
|
|
26300
|
-
|
|
26301
|
-
|
|
26302
|
-
|
|
26303
|
-
|
|
26304
|
-
|
|
26305
|
-
|
|
26306
|
-
|
|
26307
|
-
|
|
26131
|
+
// ../server/src/github/inboxQueries.ts
|
|
26132
|
+
var BOARD_FIELDS = (
|
|
26133
|
+
/* GraphQL */
|
|
26134
|
+
`
|
|
26135
|
+
fragment BoardFields on PullRequest {
|
|
26136
|
+
id
|
|
26137
|
+
number
|
|
26138
|
+
title
|
|
26139
|
+
url
|
|
26140
|
+
isDraft
|
|
26141
|
+
createdAt
|
|
26142
|
+
updatedAt
|
|
26143
|
+
headRefOid
|
|
26144
|
+
reviewDecision
|
|
26145
|
+
isInMergeQueue
|
|
26146
|
+
mergedAt
|
|
26147
|
+
repository {
|
|
26148
|
+
nameWithOwner
|
|
26149
|
+
}
|
|
26150
|
+
author {
|
|
26151
|
+
login
|
|
26152
|
+
avatarUrl
|
|
26153
|
+
}
|
|
26154
|
+
reviews {
|
|
26155
|
+
totalCount
|
|
26156
|
+
}
|
|
26157
|
+
latestOpinionatedReviews(first: 10) {
|
|
26158
|
+
nodes {
|
|
26159
|
+
state
|
|
26160
|
+
author {
|
|
26161
|
+
login
|
|
26162
|
+
avatarUrl
|
|
26163
|
+
}
|
|
26164
|
+
}
|
|
26165
|
+
}
|
|
26166
|
+
reviewRequests(first: 10) {
|
|
26167
|
+
nodes {
|
|
26168
|
+
requestedReviewer {
|
|
26169
|
+
__typename
|
|
26170
|
+
... on User {
|
|
26171
|
+
login
|
|
26172
|
+
}
|
|
26173
|
+
... on Team {
|
|
26174
|
+
slug
|
|
26175
|
+
}
|
|
26176
|
+
}
|
|
26177
|
+
}
|
|
26308
26178
|
}
|
|
26309
|
-
if (last && lastIsOther) lastOtherActivity = Math.max(lastOtherActivity, Date.parse(last.createdAt));
|
|
26310
26179
|
}
|
|
26311
|
-
|
|
26312
|
-
|
|
26313
|
-
|
|
26180
|
+
`
|
|
26181
|
+
);
|
|
26182
|
+
var BOARD_QUERY = (
|
|
26183
|
+
/* GraphQL */
|
|
26184
|
+
`
|
|
26185
|
+
query Board($ids: [ID!]!) {
|
|
26186
|
+
nodes(ids: $ids) {
|
|
26187
|
+
...BoardFields
|
|
26188
|
+
}
|
|
26314
26189
|
}
|
|
26315
|
-
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
|
|
26319
|
-
|
|
26320
|
-
|
|
26321
|
-
|
|
26322
|
-
|
|
26323
|
-
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
updatedAt: node2.updatedAt,
|
|
26328
|
-
additions: node2.additions,
|
|
26329
|
-
deletions: node2.deletions,
|
|
26330
|
-
changedFiles: node2.changedFiles,
|
|
26331
|
-
labels: node2.labels.nodes,
|
|
26332
|
-
ci: node2.commits.nodes[0]?.commit.statusCheckRollup?.state ?? null,
|
|
26333
|
-
reviewDecision: node2.reviewDecision,
|
|
26334
|
-
reviews: node2.latestOpinionatedReviews.nodes.flatMap(
|
|
26335
|
-
(r) => r.author ? [{ login: r.author.login, avatarUrl: r.author.avatarUrl, state: r.state }] : []
|
|
26336
|
-
),
|
|
26337
|
-
requested: node2.reviewRequests.nodes.flatMap((r) => {
|
|
26338
|
-
const name = r.requestedReviewer?.login ?? r.requestedReviewer?.slug;
|
|
26339
|
-
return name ? [name] : [];
|
|
26340
|
-
}),
|
|
26341
|
-
myReview: myReview ? {
|
|
26342
|
-
state: myReview.state,
|
|
26343
|
-
submittedAt: myReview.submittedAt,
|
|
26344
|
-
upToDate: myReview.commit?.oid === node2.headRefOid
|
|
26345
|
-
} : null,
|
|
26346
|
-
threads: { total: node2.reviewThreads.nodes.length, open: open2, awaitingMyReply },
|
|
26347
|
-
files: {
|
|
26348
|
-
viewed: files.filter((f) => f.viewerViewedState === "VIEWED").length,
|
|
26349
|
-
total: node2.files?.totalCount ?? node2.changedFiles
|
|
26350
|
-
},
|
|
26351
|
-
lastVisitAt: visit2?.visitedAt ?? null,
|
|
26352
|
-
unread: !visit2 || visit2.headOid !== node2.headRefOid || lastOtherActivity > visit2.visitedAt
|
|
26353
|
-
};
|
|
26354
|
-
}
|
|
26355
|
-
function classifyInbox(results, me, visits) {
|
|
26356
|
-
const make = (node2) => {
|
|
26357
|
-
const [owner = "", repo = ""] = node2.repository.nameWithOwner.split("/");
|
|
26358
|
-
return toInboxPr(node2, me, visits.get(prKey(owner, repo, node2.number)));
|
|
26359
|
-
};
|
|
26360
|
-
const placed = /* @__PURE__ */ new Set();
|
|
26361
|
-
const take = (nodes, keep = () => true) => {
|
|
26362
|
-
const out = [];
|
|
26363
|
-
for (const node2 of nodes) {
|
|
26364
|
-
if (placed.has(node2.id)) continue;
|
|
26365
|
-
const pr = make(node2);
|
|
26366
|
-
if (!keep(pr)) continue;
|
|
26367
|
-
placed.add(node2.id);
|
|
26368
|
-
out.push(pr);
|
|
26369
|
-
}
|
|
26370
|
-
return out;
|
|
26371
|
-
};
|
|
26372
|
-
const requested = take(results.requested);
|
|
26373
|
-
const rereview = take(results.reviewed, (pr) => pr.myReview !== null && !pr.myReview.upToDate);
|
|
26374
|
-
const mine = take(results.mine);
|
|
26375
|
-
const mineDraft = mine.filter((pr) => pr.isDraft);
|
|
26376
|
-
const mineTodo = mine.filter(
|
|
26377
|
-
(pr) => !pr.isDraft && (pr.threads.awaitingMyReply > 0 || pr.reviewDecision === "CHANGES_REQUESTED")
|
|
26378
|
-
);
|
|
26379
|
-
const mineReady = mine.filter(
|
|
26380
|
-
(pr) => !pr.isDraft && !mineTodo.includes(pr) && pr.reviewDecision === "APPROVED" && (pr.ci === null || pr.ci === "SUCCESS") && pr.threads.open === 0
|
|
26381
|
-
);
|
|
26382
|
-
const mineWaiting = mine.filter((pr) => !pr.isDraft && !mineTodo.includes(pr) && !mineReady.includes(pr));
|
|
26383
|
-
const involved = take(results.involved);
|
|
26384
|
-
const stale = results.stale.map(make);
|
|
26385
|
-
const unreviewed = results.unreviewed.map(make).filter((pr) => pr.requested.length === 0);
|
|
26386
|
-
const byUpdated = (a, b) => b.updatedAt.localeCompare(a.updatedAt);
|
|
26387
|
-
const sections = [
|
|
26388
|
-
{ id: "requested", prs: requested },
|
|
26389
|
-
{ id: "rereview", prs: rereview },
|
|
26390
|
-
{ id: "mine-todo", prs: mineTodo },
|
|
26391
|
-
{ id: "mine-waiting", prs: mineWaiting },
|
|
26392
|
-
{ id: "mine-ready", prs: mineReady },
|
|
26393
|
-
{ id: "mine-draft", prs: mineDraft },
|
|
26394
|
-
{ id: "involved", prs: involved },
|
|
26395
|
-
{ id: "stale", prs: stale.sort((a, b) => a.updatedAt.localeCompare(b.updatedAt)) },
|
|
26396
|
-
{ id: "unreviewed", prs: unreviewed }
|
|
26397
|
-
];
|
|
26398
|
-
for (const s of sections) if (s.id !== "stale") s.prs.sort(byUpdated);
|
|
26399
|
-
return sections;
|
|
26400
|
-
}
|
|
26401
|
-
async function runSearches(gh, config2, now) {
|
|
26402
|
-
const idsBySection = Object.fromEntries(INBOX_SECTION_IDS.map((id) => [id, []]));
|
|
26403
|
-
let viewer2 = null;
|
|
26404
|
-
for (const scope of scopeChunks(config2)) {
|
|
26405
|
-
const data = await gh.graphql(
|
|
26406
|
-
INBOX_IDS_QUERY,
|
|
26407
|
-
searchQueries(scope, config2.staleDays, now)
|
|
26408
|
-
);
|
|
26409
|
-
viewer2 = data.viewer;
|
|
26410
|
-
for (const section of INBOX_SECTION_IDS) {
|
|
26411
|
-
for (const node2 of data[section].nodes) {
|
|
26412
|
-
if (node2.id && !idsBySection[section].includes(node2.id)) idsBySection[section].push(node2.id);
|
|
26190
|
+
${BOARD_FIELDS}
|
|
26191
|
+
`
|
|
26192
|
+
);
|
|
26193
|
+
var CHECKS_FIELDS = (
|
|
26194
|
+
/* GraphQL */
|
|
26195
|
+
`
|
|
26196
|
+
commits(last: 1) {
|
|
26197
|
+
nodes {
|
|
26198
|
+
commit {
|
|
26199
|
+
statusCheckRollup {
|
|
26200
|
+
state
|
|
26201
|
+
}
|
|
26413
26202
|
}
|
|
26414
26203
|
}
|
|
26415
26204
|
}
|
|
26416
|
-
|
|
26417
|
-
|
|
26418
|
-
|
|
26419
|
-
|
|
26420
|
-
|
|
26205
|
+
`
|
|
26206
|
+
);
|
|
26207
|
+
var CHECKS_QUERY = (
|
|
26208
|
+
/* GraphQL */
|
|
26209
|
+
`
|
|
26210
|
+
query BoardChecks($ids: [ID!]!) {
|
|
26211
|
+
nodes(ids: $ids) {
|
|
26212
|
+
... on PullRequest {
|
|
26213
|
+
id
|
|
26214
|
+
${CHECKS_FIELDS}
|
|
26215
|
+
reviewThreads(first: 100) {
|
|
26216
|
+
nodes {
|
|
26217
|
+
isResolved
|
|
26218
|
+
}
|
|
26219
|
+
}
|
|
26220
|
+
}
|
|
26221
|
+
}
|
|
26421
26222
|
}
|
|
26422
|
-
|
|
26423
|
-
|
|
26424
|
-
|
|
26425
|
-
|
|
26426
|
-
|
|
26427
|
-
|
|
26428
|
-
|
|
26429
|
-
|
|
26430
|
-
|
|
26431
|
-
|
|
26432
|
-
|
|
26433
|
-
|
|
26434
|
-
|
|
26435
|
-
|
|
26436
|
-
|
|
26437
|
-
|
|
26438
|
-
|
|
26439
|
-
|
|
26440
|
-
|
|
26441
|
-
|
|
26223
|
+
`
|
|
26224
|
+
);
|
|
26225
|
+
var DETAILS_QUERY = (
|
|
26226
|
+
/* GraphQL */
|
|
26227
|
+
`
|
|
26228
|
+
query BoardDetails($ids: [ID!]!) {
|
|
26229
|
+
nodes(ids: $ids) {
|
|
26230
|
+
... on PullRequest {
|
|
26231
|
+
id
|
|
26232
|
+
additions
|
|
26233
|
+
deletions
|
|
26234
|
+
${CHECKS_FIELDS}
|
|
26235
|
+
viewerLatestReview {
|
|
26236
|
+
state
|
|
26237
|
+
commit {
|
|
26238
|
+
oid
|
|
26239
|
+
}
|
|
26240
|
+
}
|
|
26241
|
+
comments(last: 1) {
|
|
26242
|
+
nodes {
|
|
26243
|
+
author {
|
|
26244
|
+
login
|
|
26245
|
+
}
|
|
26246
|
+
createdAt
|
|
26247
|
+
}
|
|
26248
|
+
}
|
|
26249
|
+
reviewThreads(first: 100) {
|
|
26250
|
+
nodes {
|
|
26251
|
+
isResolved
|
|
26252
|
+
comments(last: 1) {
|
|
26253
|
+
nodes {
|
|
26254
|
+
author {
|
|
26255
|
+
login
|
|
26256
|
+
}
|
|
26257
|
+
createdAt
|
|
26258
|
+
}
|
|
26259
|
+
}
|
|
26260
|
+
}
|
|
26261
|
+
}
|
|
26262
|
+
files(first: 100) {
|
|
26263
|
+
totalCount
|
|
26264
|
+
nodes {
|
|
26265
|
+
viewerViewedState
|
|
26266
|
+
}
|
|
26267
|
+
}
|
|
26268
|
+
}
|
|
26269
|
+
}
|
|
26270
|
+
}
|
|
26271
|
+
`
|
|
26272
|
+
);
|
|
26273
|
+
var SEARCH_IDS_QUERY = (
|
|
26274
|
+
/* GraphQL */
|
|
26275
|
+
`
|
|
26276
|
+
query SearchIds($q: String!, $after: String) {
|
|
26277
|
+
viewer {
|
|
26278
|
+
login
|
|
26279
|
+
avatarUrl
|
|
26280
|
+
}
|
|
26281
|
+
search(query: $q, type: ISSUE, first: 100, after: $after) {
|
|
26282
|
+
issueCount
|
|
26283
|
+
pageInfo {
|
|
26284
|
+
hasNextPage
|
|
26285
|
+
endCursor
|
|
26286
|
+
}
|
|
26287
|
+
nodes {
|
|
26288
|
+
... on PullRequest {
|
|
26289
|
+
id
|
|
26290
|
+
}
|
|
26291
|
+
}
|
|
26292
|
+
}
|
|
26293
|
+
}
|
|
26294
|
+
`
|
|
26295
|
+
);
|
|
26296
|
+
var INBOX_FINGERPRINT_QUERY = (
|
|
26297
|
+
/* GraphQL */
|
|
26298
|
+
`
|
|
26299
|
+
query InboxFingerprint($q: String!) {
|
|
26300
|
+
search(query: $q, type: ISSUE, first: 100) {
|
|
26301
|
+
issueCount
|
|
26302
|
+
nodes {
|
|
26303
|
+
... on PullRequest {
|
|
26304
|
+
id
|
|
26305
|
+
updatedAt
|
|
26306
|
+
headRefOid
|
|
26307
|
+
reviewDecision
|
|
26308
|
+
isInMergeQueue
|
|
26309
|
+
${CHECKS_FIELDS}
|
|
26310
|
+
}
|
|
26311
|
+
}
|
|
26312
|
+
}
|
|
26313
|
+
}
|
|
26314
|
+
`
|
|
26315
|
+
);
|
|
26316
|
+
|
|
26317
|
+
// ../server/src/inbox.ts
|
|
26318
|
+
var MERGED_WINDOW_MS = 24 * 36e5;
|
|
26319
|
+
function scopeTerms(config2) {
|
|
26320
|
+
return [...config2.repos.map((r) => `repo:${r}`), ...config2.orgs.map((o) => `user:${o}`)];
|
|
26321
|
+
}
|
|
26322
|
+
var SCOPE_CHUNK = 20;
|
|
26323
|
+
function scopeChunks(config2) {
|
|
26324
|
+
const terms = scopeTerms(config2);
|
|
26325
|
+
const chunks = [];
|
|
26326
|
+
for (let i = 0; i < terms.length; i += SCOPE_CHUNK) chunks.push(terms.slice(i, i + SCOPE_CHUNK).join(" "));
|
|
26327
|
+
return chunks;
|
|
26328
|
+
}
|
|
26329
|
+
function searchQueries(scope, mergedSince) {
|
|
26330
|
+
const open2 = `is:pr is:open archived:false ${scope}`;
|
|
26331
|
+
const since = new Date(mergedSince).toISOString().replace(/\.\d+Z$/, "Z");
|
|
26332
|
+
return {
|
|
26333
|
+
open: `${open2} sort:updated-desc`,
|
|
26334
|
+
requested: `${open2} review-requested:@me`,
|
|
26335
|
+
involved: `${open2} involves:@me -author:@me`,
|
|
26336
|
+
reviewed: `${open2} reviewed-by:@me -author:@me`,
|
|
26337
|
+
merged: `is:pr is:merged archived:false ${scope} merged:>=${since} sort:updated-desc`
|
|
26338
|
+
};
|
|
26339
|
+
}
|
|
26340
|
+
function prKey(owner, repo, number4) {
|
|
26341
|
+
return `${owner}/${repo}#${number4}`.toLowerCase();
|
|
26342
|
+
}
|
|
26343
|
+
function isApproved(decision, states) {
|
|
26344
|
+
if (decision !== null) return decision === "APPROVED";
|
|
26345
|
+
return states.includes("APPROVED") && !states.includes("CHANGES_REQUESTED");
|
|
26346
|
+
}
|
|
26347
|
+
function toInboxPr(node2, me, visit2) {
|
|
26348
|
+
const [owner = "", repo = ""] = node2.repository.nameWithOwner.split("/");
|
|
26349
|
+
let threads;
|
|
26350
|
+
let lastOtherActivity = 0;
|
|
26351
|
+
if (node2.reviewThreads) {
|
|
26352
|
+
threads = { total: node2.reviewThreads.nodes.length, open: 0, awaitingMyReply: 0 };
|
|
26353
|
+
for (const thread of node2.reviewThreads.nodes) {
|
|
26354
|
+
const last = thread.comments?.nodes[0];
|
|
26355
|
+
const lastIsOther = last?.author?.login !== me;
|
|
26356
|
+
if (!thread.isResolved) {
|
|
26357
|
+
threads.open++;
|
|
26358
|
+
if (last && lastIsOther) threads.awaitingMyReply++;
|
|
26359
|
+
}
|
|
26360
|
+
if (last && lastIsOther) lastOtherActivity = Math.max(lastOtherActivity, Date.parse(last.createdAt));
|
|
26361
|
+
}
|
|
26362
|
+
}
|
|
26363
|
+
const lastComment = node2.comments?.nodes[0];
|
|
26364
|
+
if (lastComment && lastComment.author?.login !== me) {
|
|
26365
|
+
lastOtherActivity = Math.max(lastOtherActivity, Date.parse(lastComment.createdAt));
|
|
26366
|
+
}
|
|
26367
|
+
const myReview = node2.viewerLatestReview;
|
|
26368
|
+
return {
|
|
26369
|
+
id: node2.id,
|
|
26370
|
+
owner,
|
|
26371
|
+
repo,
|
|
26372
|
+
number: node2.number,
|
|
26373
|
+
title: node2.title,
|
|
26374
|
+
url: node2.url,
|
|
26375
|
+
isDraft: node2.isDraft,
|
|
26376
|
+
inMergeQueue: node2.isInMergeQueue,
|
|
26377
|
+
mergedAt: node2.mergedAt,
|
|
26378
|
+
author: node2.author,
|
|
26379
|
+
createdAt: node2.createdAt,
|
|
26380
|
+
updatedAt: node2.updatedAt,
|
|
26381
|
+
reviewDecision: node2.reviewDecision,
|
|
26382
|
+
reviewCount: node2.reviews.totalCount,
|
|
26383
|
+
reviews: node2.latestOpinionatedReviews.nodes.flatMap(
|
|
26384
|
+
(r) => r.author ? [{ login: r.author.login, avatarUrl: r.author.avatarUrl, state: r.state }] : []
|
|
26385
|
+
),
|
|
26386
|
+
requested: node2.reviewRequests.nodes.flatMap((r) => {
|
|
26387
|
+
const name = r.requestedReviewer?.login ?? r.requestedReviewer?.slug;
|
|
26388
|
+
return name ? [name] : [];
|
|
26389
|
+
}),
|
|
26390
|
+
...node2.commits ? { ci: node2.commits.nodes[0]?.commit.statusCheckRollup?.state ?? null } : {},
|
|
26391
|
+
...threads ? { threads } : {},
|
|
26392
|
+
...node2.additions !== void 0 ? { additions: node2.additions, deletions: node2.deletions ?? 0 } : {},
|
|
26393
|
+
...myReview !== void 0 ? {
|
|
26394
|
+
myReview: myReview && { state: myReview.state, upToDate: myReview.commit?.oid === node2.headRefOid }
|
|
26395
|
+
} : {},
|
|
26396
|
+
...node2.files ? {
|
|
26397
|
+
files: {
|
|
26398
|
+
viewed: node2.files.nodes.filter((f) => f.viewerViewedState === "VIEWED").length,
|
|
26399
|
+
total: node2.files.totalCount
|
|
26400
|
+
}
|
|
26401
|
+
} : {},
|
|
26402
|
+
lastVisitAt: visit2?.visitedAt ?? null,
|
|
26403
|
+
unread: !visit2 || visit2.headOid !== node2.headRefOid || lastOtherActivity > visit2.visitedAt
|
|
26404
|
+
};
|
|
26405
|
+
}
|
|
26406
|
+
function stageOf(pr) {
|
|
26407
|
+
if (pr.mergedAt !== null) return "merged";
|
|
26408
|
+
if (pr.inMergeQueue) return "queued";
|
|
26409
|
+
if (pr.isDraft) return "draft";
|
|
26410
|
+
if (isApproved(
|
|
26411
|
+
pr.reviewDecision,
|
|
26412
|
+
pr.reviews.map((r) => r.state)
|
|
26413
|
+
)) {
|
|
26414
|
+
const green = pr.ci === null || pr.ci === "SUCCESS";
|
|
26415
|
+
return green && (pr.threads?.open ?? 0) === 0 ? "ready" : "approved";
|
|
26416
|
+
}
|
|
26417
|
+
const reviewed = pr.reviewDecision === "CHANGES_REQUESTED" || pr.reviewCount > 0 || pr.reviews.length > 0 || (pr.threads?.total ?? 0) > 0;
|
|
26418
|
+
return reviewed ? "review" : "waiting";
|
|
26419
|
+
}
|
|
26420
|
+
function buildBoard(sources, me, visits, staleBefore) {
|
|
26421
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
26422
|
+
for (const node2 of [...sources.open, ...sources.merged]) nodes.set(node2.id, node2);
|
|
26423
|
+
const prs = [...nodes.values()].map((node2) => {
|
|
26424
|
+
const [owner = "", repo = ""] = node2.repository.nameWithOwner.split("/");
|
|
26425
|
+
const pr = toInboxPr(node2, me, visits.get(prKey(owner, repo, node2.number)));
|
|
26426
|
+
const stage = stageOf(pr);
|
|
26427
|
+
const mine = pr.author?.login === me;
|
|
26428
|
+
const tags = mine ? ["mine"] : [];
|
|
26429
|
+
if (stage === "merged") return { ...pr, stage, tags };
|
|
26430
|
+
if (mine) {
|
|
26431
|
+
const feedback = (pr.threads?.awaitingMyReply ?? 0) > 0 || pr.reviewDecision === "CHANGES_REQUESTED";
|
|
26432
|
+
if (!pr.isDraft && feedback) tags.push("todo");
|
|
26433
|
+
} else {
|
|
26434
|
+
if (sources.requested.has(node2.id)) tags.push("requested");
|
|
26435
|
+
if (pr.myReview && !pr.myReview.upToDate) tags.push("rereview");
|
|
26436
|
+
if (tags.length === 0 && (sources.involved.has(node2.id) || pr.myReview)) tags.push("involved");
|
|
26437
|
+
}
|
|
26438
|
+
if (Date.parse(pr.updatedAt) < staleBefore) tags.push("stale");
|
|
26439
|
+
if (stage === "waiting" && pr.requested.length === 0) tags.push("unreviewed");
|
|
26440
|
+
return { ...pr, stage, tags };
|
|
26441
|
+
});
|
|
26442
|
+
return prs.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
26443
|
+
}
|
|
26444
|
+
var MAX_SEARCH_PAGES = 10;
|
|
26445
|
+
var BATCH2 = 25;
|
|
26446
|
+
var PARALLEL = 12;
|
|
26447
|
+
async function retryOnTimeout(run2) {
|
|
26448
|
+
try {
|
|
26449
|
+
return await run2();
|
|
26450
|
+
} catch (error62) {
|
|
26451
|
+
if (error62 instanceof GitHubError && (error62.status === 502 || error62.status === 504)) return run2();
|
|
26452
|
+
throw error62;
|
|
26453
|
+
}
|
|
26454
|
+
}
|
|
26455
|
+
async function pool(tasks) {
|
|
26456
|
+
const results = new Array(tasks.length);
|
|
26457
|
+
let next = 0;
|
|
26458
|
+
const worker = async () => {
|
|
26459
|
+
while (next < tasks.length) {
|
|
26460
|
+
const i = next++;
|
|
26461
|
+
results[i] = await tasks[i]();
|
|
26462
|
+
}
|
|
26463
|
+
};
|
|
26464
|
+
await Promise.all(Array.from({ length: Math.min(PARALLEL, tasks.length) }, worker));
|
|
26465
|
+
return results;
|
|
26466
|
+
}
|
|
26467
|
+
async function fetchNodes(gh, query, ids) {
|
|
26468
|
+
const batches = [];
|
|
26469
|
+
for (let i = 0; i < ids.length; i += BATCH2) batches.push(ids.slice(i, i + BATCH2));
|
|
26470
|
+
const results = await pool(
|
|
26471
|
+
batches.map((batch) => () => retryOnTimeout(() => gh.graphql(query, { ids: batch })))
|
|
26472
|
+
);
|
|
26473
|
+
return results.flatMap((r) => r.nodes.filter((n) => n !== null));
|
|
26474
|
+
}
|
|
26475
|
+
async function searchIds(gh, q, pages) {
|
|
26476
|
+
const ids = [];
|
|
26477
|
+
let after = null;
|
|
26478
|
+
let viewer2 = null;
|
|
26479
|
+
let truncated = false;
|
|
26480
|
+
for (let page = 0; page < pages; page++) {
|
|
26481
|
+
const data = await gh.graphql(SEARCH_IDS_QUERY, { q, after });
|
|
26482
|
+
viewer2 = data.viewer;
|
|
26483
|
+
for (const node2 of data.search.nodes) if (node2.id) ids.push(node2.id);
|
|
26484
|
+
if (!data.search.pageInfo.hasNextPage) break;
|
|
26485
|
+
after = data.search.pageInfo.endCursor;
|
|
26486
|
+
truncated = page === pages - 1;
|
|
26487
|
+
}
|
|
26488
|
+
return { viewer: viewer2, ids, truncated };
|
|
26489
|
+
}
|
|
26490
|
+
var SIDE_SEARCHES = ["requested", "involved", "reviewed", "merged"];
|
|
26491
|
+
async function loadSources(gh, config2, now) {
|
|
26492
|
+
const open2 = scopeTerms(config2).map(
|
|
26493
|
+
(term) => () => searchIds(gh, searchQueries(term, 0).open, MAX_SEARCH_PAGES)
|
|
26494
|
+
);
|
|
26495
|
+
const side = scopeChunks(config2).flatMap((chunk) => {
|
|
26496
|
+
const queries = searchQueries(chunk, now - MERGED_WINDOW_MS);
|
|
26497
|
+
return SIDE_SEARCHES.map((name) => async () => ({ name, ...await searchIds(gh, queries[name], 1) }));
|
|
26498
|
+
});
|
|
26499
|
+
const [openResults, sideResults] = await Promise.all([pool(open2), pool(side)]);
|
|
26500
|
+
const viewer2 = openResults[0]?.viewer ?? sideResults[0]?.viewer ?? null;
|
|
26501
|
+
const sideIds = (name) => new Set(sideResults.filter((r) => r.name === name).flatMap((r) => r.ids));
|
|
26502
|
+
const requested = sideIds("requested");
|
|
26503
|
+
const involved = sideIds("involved");
|
|
26504
|
+
const reviewed = sideIds("reviewed");
|
|
26505
|
+
const mergedIds = [...sideIds("merged")];
|
|
26506
|
+
const openIds = [...new Set(openResults.flatMap((r) => r.ids))];
|
|
26507
|
+
const board = await fetchNodes(gh, BOARD_QUERY, [.../* @__PURE__ */ new Set([...openIds, ...mergedIds])]);
|
|
26508
|
+
const byId = new Map(board.map((node2) => [node2.id, node2]));
|
|
26509
|
+
const me = viewer2?.login;
|
|
26510
|
+
const personal = [];
|
|
26511
|
+
const approved = [];
|
|
26512
|
+
for (const node2 of board) {
|
|
26513
|
+
if (node2.mergedAt !== null) continue;
|
|
26514
|
+
const concernsMe = requested.has(node2.id) || involved.has(node2.id) || reviewed.has(node2.id) || node2.author?.login === me;
|
|
26515
|
+
if (concernsMe) personal.push(node2.id);
|
|
26516
|
+
else if (isApproved(
|
|
26517
|
+
node2.reviewDecision,
|
|
26518
|
+
node2.latestOpinionatedReviews.nodes.map((r) => r.state)
|
|
26519
|
+
)) {
|
|
26520
|
+
approved.push(node2.id);
|
|
26521
|
+
}
|
|
26522
|
+
}
|
|
26523
|
+
const [details, checks] = await Promise.all([
|
|
26524
|
+
fetchNodes(gh, DETAILS_QUERY, personal),
|
|
26525
|
+
fetchNodes(gh, CHECKS_QUERY, approved)
|
|
26526
|
+
]);
|
|
26527
|
+
for (const extra of [...details, ...checks]) {
|
|
26528
|
+
const node2 = byId.get(extra.id);
|
|
26529
|
+
if (node2) byId.set(extra.id, { ...node2, ...extra });
|
|
26530
|
+
}
|
|
26531
|
+
const nodesOf = (list) => list.flatMap((id) => byId.get(id) ?? []);
|
|
26532
|
+
return {
|
|
26533
|
+
viewer: viewer2,
|
|
26534
|
+
truncated: openResults.some((r) => r.truncated),
|
|
26535
|
+
sources: { open: nodesOf(openIds), merged: nodesOf(mergedIds), requested, involved }
|
|
26536
|
+
};
|
|
26537
|
+
}
|
|
26538
|
+
async function loadInbox(gh, config2, viewerFallback, lastVisits) {
|
|
26539
|
+
const now = Date.now();
|
|
26540
|
+
const { viewer: viewer2, truncated, sources } = await loadSources(gh, config2, now);
|
|
26541
|
+
const me = viewer2 ?? await viewerFallback();
|
|
26542
|
+
const keys = [...sources.open, ...sources.merged].map((n) => {
|
|
26543
|
+
const [owner = "", repo = ""] = n.repository.nameWithOwner.split("/");
|
|
26544
|
+
return prKey(owner, repo, n.number);
|
|
26545
|
+
});
|
|
26546
|
+
return {
|
|
26547
|
+
viewer: me,
|
|
26548
|
+
configured: config2.repos.length + config2.orgs.length > 0,
|
|
26549
|
+
prs: buildBoard(sources, me.login, lastVisits([...new Set(keys)]), now - config2.staleDays * 864e5),
|
|
26550
|
+
truncated,
|
|
26551
|
+
fetchedAt: now
|
|
26442
26552
|
};
|
|
26443
26553
|
}
|
|
26444
26554
|
async function inboxFingerprint(gh, config2, signal) {
|
|
26445
26555
|
const parts = [];
|
|
26446
26556
|
for (const scope of scopeChunks(config2)) {
|
|
26447
|
-
const data = await gh.graphql(
|
|
26557
|
+
const data = await gh.graphql(
|
|
26558
|
+
INBOX_FINGERPRINT_QUERY,
|
|
26559
|
+
{ q: `is:pr is:open archived:false ${scope} sort:updated-desc` },
|
|
26560
|
+
signal
|
|
26561
|
+
);
|
|
26448
26562
|
parts.push(String(data.search.issueCount));
|
|
26449
|
-
for (const n of data.search.nodes)
|
|
26563
|
+
for (const n of data.search.nodes) {
|
|
26564
|
+
const ci = n.commits?.nodes[0]?.commit.statusCheckRollup?.state ?? "";
|
|
26565
|
+
parts.push(`${n.id}:${n.updatedAt}:${n.headRefOid}:${n.reviewDecision}:${n.isInMergeQueue}:${ci}`);
|
|
26566
|
+
}
|
|
26450
26567
|
}
|
|
26451
26568
|
return parts.join("|");
|
|
26452
26569
|
}
|
|
@@ -26497,7 +26614,6 @@ async function loadPr(gh, store, ref) {
|
|
|
26497
26614
|
reviewers.set(rr.login, { login: rr.login, avatarUrl: rr.avatarUrl, state: "REQUESTED" });
|
|
26498
26615
|
else if (rr?.__typename === "Team") requestedTeams.push(rr.slug);
|
|
26499
26616
|
}
|
|
26500
|
-
const rollup = pr.lastCommit.nodes[0]?.commit.statusCheckRollup ?? null;
|
|
26501
26617
|
const timeline = [
|
|
26502
26618
|
...pr.comments.nodes.map((c) => ({
|
|
26503
26619
|
kind: "comment",
|
|
@@ -26505,6 +26621,7 @@ async function loadPr(gh, store, ref) {
|
|
|
26505
26621
|
url: c.url,
|
|
26506
26622
|
body: c.body,
|
|
26507
26623
|
bodyHTML: c.bodyHTML,
|
|
26624
|
+
reactions: toReactions(c.reactionGroups),
|
|
26508
26625
|
createdAt: c.createdAt,
|
|
26509
26626
|
author: c.author,
|
|
26510
26627
|
unread: c.author?.login !== me && Date.parse(c.createdAt) > lastVisitAt
|
|
@@ -26516,6 +26633,7 @@ async function loadPr(gh, store, ref) {
|
|
|
26516
26633
|
state: r.state,
|
|
26517
26634
|
body: r.body,
|
|
26518
26635
|
bodyHTML: r.bodyHTML,
|
|
26636
|
+
reactions: toReactions(r.reactionGroups),
|
|
26519
26637
|
createdAt: r.submittedAt ?? r.createdAt,
|
|
26520
26638
|
author: r.author,
|
|
26521
26639
|
unread: r.author?.login !== me && Date.parse(r.submittedAt ?? r.createdAt) > lastVisitAt
|
|
@@ -26537,6 +26655,7 @@ async function loadPr(gh, store, ref) {
|
|
|
26537
26655
|
updatedAt: pr.updatedAt,
|
|
26538
26656
|
body: pr.body,
|
|
26539
26657
|
bodyHTML: pr.bodyHTML,
|
|
26658
|
+
reactions: toReactions(pr.reactionGroups),
|
|
26540
26659
|
baseRefName: pr.baseRefName,
|
|
26541
26660
|
headRefName: pr.headRefName,
|
|
26542
26661
|
baseRefOid: pr.baseRefOid,
|
|
@@ -26549,12 +26668,6 @@ async function loadPr(gh, store, ref) {
|
|
|
26549
26668
|
author: pr.author,
|
|
26550
26669
|
sameRepo: pr.headRepository?.nameWithOwner.toLowerCase() === `${ref.owner}/${ref.repo}`.toLowerCase()
|
|
26551
26670
|
},
|
|
26552
|
-
checks: rollup ? {
|
|
26553
|
-
state: rollup.state,
|
|
26554
|
-
contexts: rollup.contexts.nodes.map(
|
|
26555
|
-
(c) => c.__typename === "CheckRun" ? { name: c.name, state: c.conclusion ?? c.status, url: c.detailsUrl } : { name: c.context, state: c.state, url: c.targetUrl }
|
|
26556
|
-
)
|
|
26557
|
-
} : null,
|
|
26558
26671
|
reviewers: [...reviewers.values()],
|
|
26559
26672
|
requestedTeams,
|
|
26560
26673
|
myReview: pr.viewerLatestReview ? {
|
|
@@ -26586,6 +26699,9 @@ async function loadPr(gh, store, ref) {
|
|
|
26586
26699
|
seenHunks: store.seenHunks(key)
|
|
26587
26700
|
};
|
|
26588
26701
|
}
|
|
26702
|
+
function toReactions(groups) {
|
|
26703
|
+
return (groups ?? []).filter((g) => g.reactors.totalCount > 0).map((g) => ({ content: g.content, count: g.reactors.totalCount, mine: g.viewerHasReacted }));
|
|
26704
|
+
}
|
|
26589
26705
|
function toComment(c) {
|
|
26590
26706
|
return {
|
|
26591
26707
|
id: c.id,
|
|
@@ -26593,6 +26709,7 @@ function toComment(c) {
|
|
|
26593
26709
|
url: c.url,
|
|
26594
26710
|
body: c.body,
|
|
26595
26711
|
bodyHTML: c.bodyHTML,
|
|
26712
|
+
reactions: toReactions(c.reactionGroups),
|
|
26596
26713
|
createdAt: c.createdAt,
|
|
26597
26714
|
author: c.author,
|
|
26598
26715
|
pending: c.state === "PENDING",
|
|
@@ -26669,9 +26786,9 @@ async function loadDiff(gh, store, ref, base, head, isFullPr) {
|
|
|
26669
26786
|
const res = await gh.request(`/repos/${ref.owner}/${ref.repo}/compare/${base}...${head}`, {
|
|
26670
26787
|
accept: "application/vnd.github.diff"
|
|
26671
26788
|
});
|
|
26672
|
-
const
|
|
26673
|
-
store.putDiff(cacheKey2,
|
|
26674
|
-
return { base, head, files: parseUnifiedDiff(
|
|
26789
|
+
const text2 = await res.text();
|
|
26790
|
+
store.putDiff(cacheKey2, text2);
|
|
26791
|
+
return { base, head, files: parseUnifiedDiff(text2), missingFiles: 0 };
|
|
26675
26792
|
} catch (error62) {
|
|
26676
26793
|
if (!(error62 instanceof GitHubError) || error62.status === 404) throw error62;
|
|
26677
26794
|
}
|
|
@@ -26704,9 +26821,9 @@ async function loadBlobs(gh, store, ref, oids) {
|
|
|
26704
26821
|
if (missing.length > 0) {
|
|
26705
26822
|
const texts = await fetchTexts(gh, ref, missing);
|
|
26706
26823
|
for (const oid of missing) {
|
|
26707
|
-
const
|
|
26708
|
-
store.putDiff(key(oid), JSON.stringify(
|
|
26709
|
-
out[oid] =
|
|
26824
|
+
const text2 = texts.get(oid) ?? null;
|
|
26825
|
+
store.putDiff(key(oid), JSON.stringify(text2));
|
|
26826
|
+
out[oid] = text2;
|
|
26710
26827
|
}
|
|
26711
26828
|
}
|
|
26712
26829
|
return out;
|
|
@@ -26720,6 +26837,17 @@ async function setFileViewed(gh, prId, path, viewed) {
|
|
|
26720
26837
|
{ id: prId, path }
|
|
26721
26838
|
);
|
|
26722
26839
|
}
|
|
26840
|
+
async function setReaction(gh, subjectId, content, on2) {
|
|
26841
|
+
const mutation = on2 ? "addReaction" : "removeReaction";
|
|
26842
|
+
const data = await gh.graphql(
|
|
26843
|
+
`mutation($id: ID!, $content: ReactionContent!) {
|
|
26844
|
+
${mutation}(input: { subjectId: $id, content: $content }) { subject { ...ReactionFields } }
|
|
26845
|
+
}
|
|
26846
|
+
${REACTION_FIELDS}`,
|
|
26847
|
+
{ id: subjectId, content }
|
|
26848
|
+
);
|
|
26849
|
+
return toReactions(data[mutation].subject.reactionGroups);
|
|
26850
|
+
}
|
|
26723
26851
|
async function replyToThread(gh, threadId, body, pendingReviewId) {
|
|
26724
26852
|
const data = await gh.graphql(
|
|
26725
26853
|
`mutation($thread: ID!, $body: String!, $review: ID) {
|
|
@@ -26816,7 +26944,7 @@ async function addIssueComment(gh, subjectId, body) {
|
|
|
26816
26944
|
}`,
|
|
26817
26945
|
{ id: subjectId, body }
|
|
26818
26946
|
);
|
|
26819
|
-
return { kind: "comment", ...data.addComment.commentEdge.node, unread: false };
|
|
26947
|
+
return { kind: "comment", ...data.addComment.commentEdge.node, reactions: [], unread: false };
|
|
26820
26948
|
}
|
|
26821
26949
|
async function deleteReviewComment(gh, commentId) {
|
|
26822
26950
|
await gh.graphql(
|
|
@@ -26846,9 +26974,9 @@ async function applySuggestion(gh, ref, input2) {
|
|
|
26846
26974
|
const file2 = await gh.rest(
|
|
26847
26975
|
`/repos/${ref.owner}/${ref.repo}/contents/${encodedPath}?ref=${input2.expectedHeadOid}`
|
|
26848
26976
|
);
|
|
26849
|
-
const
|
|
26850
|
-
const eol =
|
|
26851
|
-
const lines =
|
|
26977
|
+
const text2 = Buffer.from(file2.content, "base64").toString("utf8");
|
|
26978
|
+
const eol = text2.includes("\r\n") ? "\r\n" : "\n";
|
|
26979
|
+
const lines = text2.split(eol);
|
|
26852
26980
|
if (input2.endLine > lines.length || input2.startLine < 1 || input2.startLine > input2.endLine) {
|
|
26853
26981
|
throw new GitHubError("Lignes de la suggestion hors du fichier.", 422);
|
|
26854
26982
|
}
|
|
@@ -26873,10 +27001,103 @@ async function applySuggestion(gh, ref, input2) {
|
|
|
26873
27001
|
return res.commit.sha;
|
|
26874
27002
|
}
|
|
26875
27003
|
|
|
26876
|
-
// ../server/src/
|
|
26877
|
-
|
|
27004
|
+
// ../server/src/checks.ts
|
|
27005
|
+
var PR_CHECKS_QUERY = (
|
|
27006
|
+
/* GraphQL */
|
|
27007
|
+
`
|
|
27008
|
+
query PrChecks($owner: String!, $repo: String!, $number: Int!) {
|
|
27009
|
+
repository(owner: $owner, name: $repo) {
|
|
27010
|
+
pullRequest(number: $number) {
|
|
27011
|
+
commits(last: 1) {
|
|
27012
|
+
nodes {
|
|
27013
|
+
commit {
|
|
27014
|
+
statusCheckRollup {
|
|
27015
|
+
state
|
|
27016
|
+
contexts(first: 100) {
|
|
27017
|
+
nodes {
|
|
27018
|
+
__typename
|
|
27019
|
+
... on CheckRun {
|
|
27020
|
+
name
|
|
27021
|
+
conclusion
|
|
27022
|
+
status
|
|
27023
|
+
detailsUrl
|
|
27024
|
+
title
|
|
27025
|
+
checkSuite {
|
|
27026
|
+
workflowRun {
|
|
27027
|
+
workflow {
|
|
27028
|
+
name
|
|
27029
|
+
}
|
|
27030
|
+
}
|
|
27031
|
+
}
|
|
27032
|
+
}
|
|
27033
|
+
... on StatusContext {
|
|
27034
|
+
context
|
|
27035
|
+
state
|
|
27036
|
+
targetUrl
|
|
27037
|
+
description
|
|
27038
|
+
}
|
|
27039
|
+
}
|
|
27040
|
+
}
|
|
27041
|
+
}
|
|
27042
|
+
}
|
|
27043
|
+
}
|
|
27044
|
+
}
|
|
27045
|
+
}
|
|
27046
|
+
}
|
|
27047
|
+
}
|
|
27048
|
+
`
|
|
27049
|
+
);
|
|
27050
|
+
var FAILED = /* @__PURE__ */ new Set(["FAILURE", "TIMED_OUT", "STARTUP_FAILURE", "ACTION_REQUIRED", "CANCELLED", "ERROR"]);
|
|
27051
|
+
var SKIPPED = /* @__PURE__ */ new Set(["NEUTRAL", "SKIPPED", "STALE"]);
|
|
27052
|
+
var RANK = { failure: 0, pending: 1, success: 2, skipped: 3 };
|
|
27053
|
+
function outcomeOf(state) {
|
|
27054
|
+
if (FAILED.has(state)) return "failure";
|
|
27055
|
+
if (state === "SUCCESS") return "success";
|
|
27056
|
+
if (SKIPPED.has(state)) return "skipped";
|
|
27057
|
+
return "pending";
|
|
27058
|
+
}
|
|
27059
|
+
function toChecks(rollup) {
|
|
27060
|
+
if (!rollup) return null;
|
|
27061
|
+
const all = rollup.contexts.nodes.map((c) => {
|
|
27062
|
+
if (c.__typename === "StatusContext") {
|
|
27063
|
+
return {
|
|
27064
|
+
name: c.context,
|
|
27065
|
+
outcome: outcomeOf(c.state),
|
|
27066
|
+
state: c.state.toLowerCase(),
|
|
27067
|
+
url: c.targetUrl,
|
|
27068
|
+
summary: c.description || null
|
|
27069
|
+
};
|
|
27070
|
+
}
|
|
27071
|
+
const state = c.conclusion ?? c.status;
|
|
27072
|
+
const workflow = c.checkSuite?.workflowRun?.workflow.name;
|
|
27073
|
+
return {
|
|
27074
|
+
name: workflow ? `${workflow} / ${c.name}` : c.name,
|
|
27075
|
+
outcome: outcomeOf(state),
|
|
27076
|
+
state: state.toLowerCase(),
|
|
27077
|
+
url: c.detailsUrl,
|
|
27078
|
+
summary: c.title || null
|
|
27079
|
+
};
|
|
27080
|
+
});
|
|
27081
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27082
|
+
const checks = all.filter((c) => {
|
|
27083
|
+
const key = `${c.name}\0${c.outcome}`;
|
|
27084
|
+
if (seen.has(key)) return false;
|
|
27085
|
+
seen.add(key);
|
|
27086
|
+
return true;
|
|
27087
|
+
});
|
|
27088
|
+
checks.sort((a, b) => RANK[a.outcome] - RANK[b.outcome] || a.name.localeCompare(b.name));
|
|
27089
|
+
return { state: rollup.state, checks };
|
|
27090
|
+
}
|
|
27091
|
+
async function loadChecks(gh, ref) {
|
|
27092
|
+
const data = await gh.graphql(PR_CHECKS_QUERY, {
|
|
27093
|
+
owner: ref.owner,
|
|
27094
|
+
repo: ref.repo,
|
|
27095
|
+
number: ref.number
|
|
27096
|
+
});
|
|
27097
|
+
return toChecks(data.repository?.pullRequest?.commits.nodes[0]?.commit.statusCheckRollup ?? null);
|
|
27098
|
+
}
|
|
26878
27099
|
|
|
26879
|
-
//
|
|
27100
|
+
// ../../packages/language/src/paths.ts
|
|
26880
27101
|
function normalizePath(path) {
|
|
26881
27102
|
const segments = [];
|
|
26882
27103
|
for (const segment of path.split("/")) {
|
|
@@ -26915,74 +27136,200 @@ function sharedPrefixLength(a, b) {
|
|
|
26915
27136
|
return count;
|
|
26916
27137
|
}
|
|
26917
27138
|
|
|
26918
|
-
//
|
|
26919
|
-
var
|
|
26920
|
-
|
|
26921
|
-
|
|
26922
|
-
|
|
26923
|
-
|
|
26924
|
-
|
|
26925
|
-
|
|
26926
|
-
|
|
26927
|
-
|
|
27139
|
+
// ../../packages/language/src/registry.ts
|
|
27140
|
+
var LanguageRegistry = class {
|
|
27141
|
+
#byId = /* @__PURE__ */ new Map();
|
|
27142
|
+
#byFilename = /* @__PURE__ */ new Map();
|
|
27143
|
+
/** Longest extension first. */
|
|
27144
|
+
#byExtension = [];
|
|
27145
|
+
constructor(languages2) {
|
|
27146
|
+
const extensions = /* @__PURE__ */ new Map();
|
|
27147
|
+
for (const language of languages2) {
|
|
27148
|
+
const { id, extensions: exts, filenames = [] } = language.info;
|
|
27149
|
+
if (this.#byId.has(id)) throw new Error(`Langage d\xE9clar\xE9 deux fois : ${id}`);
|
|
27150
|
+
this.#byId.set(id, language);
|
|
27151
|
+
for (const name of filenames) claim2(this.#byFilename, name.toLowerCase(), language);
|
|
27152
|
+
for (const ext of exts) claim2(extensions, ext.toLowerCase(), language);
|
|
27153
|
+
}
|
|
27154
|
+
this.#byExtension = [...extensions].sort(([a], [b]) => b.length - a.length);
|
|
27155
|
+
}
|
|
27156
|
+
/** Every language, in declaration order. */
|
|
27157
|
+
all() {
|
|
27158
|
+
return [...this.#byId.values()];
|
|
27159
|
+
}
|
|
27160
|
+
byId(id) {
|
|
27161
|
+
return this.#byId.get(id);
|
|
27162
|
+
}
|
|
27163
|
+
/** Language of a repository path, or null when no registered language handles it. */
|
|
27164
|
+
detect(path) {
|
|
27165
|
+
const name = basename(path).toLowerCase();
|
|
27166
|
+
const exact = this.#byFilename.get(name);
|
|
27167
|
+
if (exact !== void 0) return exact;
|
|
27168
|
+
for (const [extension, language] of this.#byExtension) {
|
|
27169
|
+
if (name.length > extension.length && name.endsWith(extension)) return language;
|
|
27170
|
+
}
|
|
27171
|
+
return null;
|
|
27172
|
+
}
|
|
26928
27173
|
};
|
|
26929
|
-
|
|
26930
|
-
|
|
26931
|
-
|
|
26932
|
-
|
|
26933
|
-
jsx: ts.ScriptKind.JSX
|
|
26934
|
-
};
|
|
26935
|
-
var EXTRACTORS = {
|
|
26936
|
-
typescript: extractScriptFile,
|
|
26937
|
-
javascript: extractScriptFile,
|
|
26938
|
-
vue: extractComponentScripts,
|
|
26939
|
-
svelte: extractComponentScripts,
|
|
26940
|
-
python: extractPython,
|
|
26941
|
-
css: extractStyle,
|
|
26942
|
-
go: extractGo,
|
|
26943
|
-
java: extractJvm,
|
|
26944
|
-
kotlin: extractJvm,
|
|
26945
|
-
c: extractInclude,
|
|
26946
|
-
cpp: extractInclude,
|
|
26947
|
-
rust: extractRust,
|
|
26948
|
-
ruby: extractRuby,
|
|
26949
|
-
markdown: () => []
|
|
26950
|
-
};
|
|
26951
|
-
function extractImports(text, path, language) {
|
|
26952
|
-
return language === null ? [] : EXTRACTORS[language](text, path);
|
|
26953
|
-
}
|
|
26954
|
-
function extractScriptFile(text, path) {
|
|
26955
|
-
return parseScript(text, path, SCRIPT_KIND_BY_EXTENSION[extname(path).toLowerCase()] ?? ts.ScriptKind.TS);
|
|
26956
|
-
}
|
|
26957
|
-
function extractComponentScripts(text, path) {
|
|
26958
|
-
const refs = [];
|
|
26959
|
-
for (const match2 of text.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)) {
|
|
26960
|
-
const lang = /\blang\s*=\s*["']?(tsx?|jsx|typescript)\b/i.exec(match2[1] ?? "")?.[1]?.toLowerCase() ?? "";
|
|
26961
|
-
refs.push(...parseScript(match2[2] ?? "", path, SCRIPT_KIND_BY_LANG[lang] ?? ts.ScriptKind.JS));
|
|
27174
|
+
function claim2(map2, key, language) {
|
|
27175
|
+
const owner = map2.get(key);
|
|
27176
|
+
if (owner !== void 0 && owner !== language) {
|
|
27177
|
+
throw new Error(`\xAB ${key} \xBB revendiqu\xE9 par ${owner.info.id} et ${language.info.id}`);
|
|
26962
27178
|
}
|
|
26963
|
-
|
|
27179
|
+
map2.set(key, language);
|
|
26964
27180
|
}
|
|
26965
|
-
|
|
26966
|
-
|
|
27181
|
+
|
|
27182
|
+
// ../../packages/lang-css/src/info.ts
|
|
27183
|
+
var cssInfo = { id: "css", label: "CSS", extensions: [".css"] };
|
|
27184
|
+
var scssInfo = { id: "scss", label: "SCSS", extensions: [".scss"] };
|
|
27185
|
+
var sassInfo = { id: "sass", label: "Sass", extensions: [".sass"] };
|
|
27186
|
+
var lessInfo = { id: "less", label: "Less", extensions: [".less"] };
|
|
27187
|
+
|
|
27188
|
+
// ../../packages/lang-css/src/analysis.ts
|
|
27189
|
+
function extractImports(text2) {
|
|
26967
27190
|
const refs = [];
|
|
26968
|
-
const
|
|
26969
|
-
|
|
26970
|
-
|
|
26971
|
-
|
|
26972
|
-
|
|
26973
|
-
|
|
27191
|
+
const source = text2.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
27192
|
+
for (const match2 of source.matchAll(/@(import|use|forward)\s+([^;\n]+)/g)) {
|
|
27193
|
+
const urls = [...(match2[2] ?? "").matchAll(/url\(\s*["']?([^"')\s]+)["']?\s*\)|["']([^"'\n]+)["']/g)];
|
|
27194
|
+
for (const url2 of match2[1] === "import" ? urls : urls.slice(0, 1)) {
|
|
27195
|
+
const specifier = url2[1] ?? url2[2];
|
|
27196
|
+
if (specifier !== void 0) refs.push({ specifier, names: [] });
|
|
27197
|
+
}
|
|
27198
|
+
}
|
|
26974
27199
|
return refs;
|
|
26975
27200
|
}
|
|
26976
|
-
|
|
26977
|
-
|
|
26978
|
-
|
|
26979
|
-
|
|
26980
|
-
|
|
26981
|
-
|
|
26982
|
-
|
|
26983
|
-
|
|
26984
|
-
|
|
26985
|
-
|
|
27201
|
+
var STYLE_EXTENSIONS = [".scss", ".sass", ".css", ".less"];
|
|
27202
|
+
function candidates(base) {
|
|
27203
|
+
const dir = dirname(base);
|
|
27204
|
+
const partial2 = `${dir === "" ? "" : `${dir}/`}_${basename(base)}`;
|
|
27205
|
+
if (STYLE_EXTENSIONS.includes(extname(base))) return [base, partial2];
|
|
27206
|
+
return [
|
|
27207
|
+
base,
|
|
27208
|
+
...STYLE_EXTENSIONS.flatMap((ext) => [base + ext, partial2 + ext]),
|
|
27209
|
+
...STYLE_EXTENSIONS.flatMap((ext) => [`${base}/_index${ext}`, `${base}/index${ext}`])
|
|
27210
|
+
];
|
|
27211
|
+
}
|
|
27212
|
+
function resolveImport(ref, from, index) {
|
|
27213
|
+
const specifier = ref.specifier.replace(/^~/, "");
|
|
27214
|
+
if (/^(?:[a-z]+:|\/\/)/i.test(specifier)) return [];
|
|
27215
|
+
const paths = candidates(specifier);
|
|
27216
|
+
const relative2 = index.firstRelative(dirname(from), paths);
|
|
27217
|
+
if (relative2 !== null) return [{ path: relative2, names: ref.names }];
|
|
27218
|
+
if (specifier.startsWith(".")) return [];
|
|
27219
|
+
return index.closestWithSuffix(from, paths).map((path) => ({ path, names: ref.names }));
|
|
27220
|
+
}
|
|
27221
|
+
var stylesheet = (info) => ({ info, extractImports, resolveImport });
|
|
27222
|
+
var css = stylesheet(cssInfo);
|
|
27223
|
+
var scss = stylesheet(scssInfo);
|
|
27224
|
+
var sass = stylesheet(sassInfo);
|
|
27225
|
+
var less = stylesheet(lessInfo);
|
|
27226
|
+
|
|
27227
|
+
// ../../packages/lang-html/src/info.ts
|
|
27228
|
+
var htmlInfo = { id: "html", label: "HTML", extensions: [".html", ".htm"] };
|
|
27229
|
+
|
|
27230
|
+
// ../../packages/lang-html/src/analysis.ts
|
|
27231
|
+
function extractImports2(text2) {
|
|
27232
|
+
const source = text2.replace(/<!--[\s\S]*?-->/g, "");
|
|
27233
|
+
const refs = [];
|
|
27234
|
+
for (const tag of source.matchAll(/<(script|link)\b[^>]*>/gi)) {
|
|
27235
|
+
const attribute = tag[1].toLowerCase() === "script" ? "src" : "href";
|
|
27236
|
+
const value = new RegExp(`\\s${attribute}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(tag[0]);
|
|
27237
|
+
const url2 = value?.[1] ?? value?.[2] ?? value?.[3];
|
|
27238
|
+
if (url2) refs.push({ specifier: url2, names: [] });
|
|
27239
|
+
}
|
|
27240
|
+
return refs;
|
|
27241
|
+
}
|
|
27242
|
+
function resolveImport2(ref, from, index) {
|
|
27243
|
+
const url2 = ref.specifier.replace(/[?#].*$/, "");
|
|
27244
|
+
if (url2 === "" || /^(?:[a-z]+:|\/\/)/i.test(url2)) return [];
|
|
27245
|
+
const rooted = url2.startsWith("/");
|
|
27246
|
+
const relative2 = index.firstRelative(dirname(from), [rooted ? url2.slice(1) : url2]);
|
|
27247
|
+
if (relative2 !== null) return [{ path: relative2, names: ref.names }];
|
|
27248
|
+
if (!rooted) return [];
|
|
27249
|
+
return index.closestWithSuffix(from, [url2.slice(1)]).map((path) => ({ path, names: ref.names }));
|
|
27250
|
+
}
|
|
27251
|
+
var html = { info: htmlInfo, extractImports: extractImports2, resolveImport: resolveImport2 };
|
|
27252
|
+
|
|
27253
|
+
// ../../packages/lang-json/src/info.ts
|
|
27254
|
+
var jsonInfo = {
|
|
27255
|
+
id: "json",
|
|
27256
|
+
label: "JSON",
|
|
27257
|
+
extensions: [".json", ".jsonc"],
|
|
27258
|
+
// JSON configuration files without the extension.
|
|
27259
|
+
filenames: [".babelrc", ".eslintrc", ".prettierrc", ".swcrc"]
|
|
27260
|
+
};
|
|
27261
|
+
|
|
27262
|
+
// ../../packages/lang-json/src/analysis.ts
|
|
27263
|
+
var json3 = { info: jsonInfo };
|
|
27264
|
+
|
|
27265
|
+
// ../../packages/lang-markdown/src/info.ts
|
|
27266
|
+
var markdownInfo = {
|
|
27267
|
+
id: "markdown",
|
|
27268
|
+
label: "MD",
|
|
27269
|
+
extensions: [".md", ".markdown"]
|
|
27270
|
+
};
|
|
27271
|
+
|
|
27272
|
+
// ../../packages/lang-markdown/src/analysis.ts
|
|
27273
|
+
var markdown = { info: markdownInfo };
|
|
27274
|
+
|
|
27275
|
+
// ../../packages/lang-text/src/info.ts
|
|
27276
|
+
var textInfo = {
|
|
27277
|
+
id: "text",
|
|
27278
|
+
label: "TXT",
|
|
27279
|
+
extensions: [".txt"]
|
|
27280
|
+
};
|
|
27281
|
+
|
|
27282
|
+
// ../../packages/lang-text/src/analysis.ts
|
|
27283
|
+
var text = { info: textInfo };
|
|
27284
|
+
|
|
27285
|
+
// ../../packages/lang-typescript/src/analysis.ts
|
|
27286
|
+
import ts from "typescript";
|
|
27287
|
+
|
|
27288
|
+
// ../../packages/lang-typescript/src/info.ts
|
|
27289
|
+
var typescriptInfo = {
|
|
27290
|
+
id: "typescript",
|
|
27291
|
+
label: "TS",
|
|
27292
|
+
extensions: [".ts", ".tsx", ".mts", ".cts"]
|
|
27293
|
+
};
|
|
27294
|
+
var javascriptInfo = {
|
|
27295
|
+
id: "javascript",
|
|
27296
|
+
label: "JS",
|
|
27297
|
+
extensions: [".js", ".jsx", ".mjs", ".cjs"]
|
|
27298
|
+
};
|
|
27299
|
+
|
|
27300
|
+
// ../../packages/lang-typescript/src/analysis.ts
|
|
27301
|
+
var SCRIPT_KIND_BY_EXTENSION = {
|
|
27302
|
+
".ts": ts.ScriptKind.TS,
|
|
27303
|
+
".mts": ts.ScriptKind.TS,
|
|
27304
|
+
".cts": ts.ScriptKind.TS,
|
|
27305
|
+
".tsx": ts.ScriptKind.TSX,
|
|
27306
|
+
".js": ts.ScriptKind.JS,
|
|
27307
|
+
".mjs": ts.ScriptKind.JS,
|
|
27308
|
+
".cjs": ts.ScriptKind.JS,
|
|
27309
|
+
".jsx": ts.ScriptKind.JSX
|
|
27310
|
+
};
|
|
27311
|
+
function extractImports3(text2, path) {
|
|
27312
|
+
const kind = SCRIPT_KIND_BY_EXTENSION[extname(path).toLowerCase()] ?? ts.ScriptKind.TS;
|
|
27313
|
+
const source = ts.createSourceFile(path, text2, ts.ScriptTarget.Latest, true, kind);
|
|
27314
|
+
const refs = [];
|
|
27315
|
+
const visit2 = (node2) => {
|
|
27316
|
+
const ref = scriptImport(node2);
|
|
27317
|
+
if (ref !== null) refs.push(ref);
|
|
27318
|
+
ts.forEachChild(node2, visit2);
|
|
27319
|
+
};
|
|
27320
|
+
visit2(source);
|
|
27321
|
+
return refs;
|
|
27322
|
+
}
|
|
27323
|
+
function scriptImport(node2) {
|
|
27324
|
+
if (ts.isImportDeclaration(node2)) return withSpecifier(node2.moduleSpecifier, importClauseNames(node2));
|
|
27325
|
+
if (ts.isExportDeclaration(node2)) {
|
|
27326
|
+
return node2.moduleSpecifier === void 0 ? null : withSpecifier(node2.moduleSpecifier, exportNames(node2));
|
|
27327
|
+
}
|
|
27328
|
+
if (ts.isImportEqualsDeclaration(node2) && ts.isExternalModuleReference(node2.moduleReference)) {
|
|
27329
|
+
const name = `${node2.isTypeOnly ? "type " : ""}${node2.name.text}`;
|
|
27330
|
+
return withSpecifier(node2.moduleReference.expression, [name]);
|
|
27331
|
+
}
|
|
27332
|
+
if (ts.isImportTypeNode(node2) && ts.isLiteralTypeNode(node2.argument)) {
|
|
26986
27333
|
const names = node2.qualifier === void 0 ? [] : [`type ${node2.qualifier.getText()}`];
|
|
26987
27334
|
return withSpecifier(node2.argument.literal, names);
|
|
26988
27335
|
}
|
|
@@ -27034,162 +27381,228 @@ function boundNames(call) {
|
|
|
27034
27381
|
return ts.isIdentifier(key) ? [key.text] : [];
|
|
27035
27382
|
});
|
|
27036
27383
|
}
|
|
27037
|
-
|
|
27038
|
-
|
|
27039
|
-
|
|
27040
|
-
|
|
27041
|
-
|
|
27042
|
-
|
|
27043
|
-
|
|
27044
|
-
|
|
27045
|
-
|
|
27046
|
-
|
|
27384
|
+
var SCRIPT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".d.ts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
27385
|
+
var TS_COUNTERPARTS = {
|
|
27386
|
+
".js": [".ts", ".tsx"],
|
|
27387
|
+
".jsx": [".tsx"],
|
|
27388
|
+
".mjs": [".mts"],
|
|
27389
|
+
".cjs": [".cts"]
|
|
27390
|
+
};
|
|
27391
|
+
var ALIAS_PREFIX = /^(?:@\/|~\/|#\/?)/;
|
|
27392
|
+
function scriptCandidates(base) {
|
|
27393
|
+
const extension = extname(base);
|
|
27394
|
+
const counterparts = (TS_COUNTERPARTS[extension] ?? []).map((ts2) => base.slice(0, -extension.length) + ts2);
|
|
27395
|
+
return [
|
|
27396
|
+
base,
|
|
27397
|
+
...counterparts,
|
|
27398
|
+
...SCRIPT_EXTENSIONS.map((ext) => base + ext),
|
|
27399
|
+
...SCRIPT_EXTENSIONS.map((ext) => `${base}/index${ext}`)
|
|
27400
|
+
];
|
|
27401
|
+
}
|
|
27402
|
+
function resolveImport3(ref, from, index) {
|
|
27403
|
+
const { specifier, names } = ref;
|
|
27404
|
+
if (specifier.startsWith("./") || specifier.startsWith("../") || specifier === "." || specifier === "..") {
|
|
27405
|
+
const path = index.firstRelative(dirname(from), scriptCandidates(specifier));
|
|
27406
|
+
return path === null ? [] : [{ path, names }];
|
|
27047
27407
|
}
|
|
27048
|
-
|
|
27049
|
-
|
|
27050
|
-
|
|
27051
|
-
}
|
|
27408
|
+
const workspace = index.packageFor(specifier);
|
|
27409
|
+
if (workspace !== null) {
|
|
27410
|
+
const path = resolveWorkspaceImport(workspace.pkg, workspace.subpath, index);
|
|
27411
|
+
return path === null ? [] : [{ path, names }];
|
|
27052
27412
|
}
|
|
27053
|
-
return
|
|
27413
|
+
if (!ALIAS_PREFIX.test(specifier) && !specifier.startsWith("/")) return [];
|
|
27414
|
+
const remainder = specifier.replace(ALIAS_PREFIX, "").replace(/^\/+/, "");
|
|
27415
|
+
if (remainder === "") return [];
|
|
27416
|
+
return index.closestWithSuffix(from, scriptCandidates(remainder)).map((path) => ({ path, names }));
|
|
27054
27417
|
}
|
|
27055
|
-
function
|
|
27056
|
-
|
|
27057
|
-
|
|
27058
|
-
).filter((name) => name !== "");
|
|
27418
|
+
function resolveWorkspaceImport(pkg, subpath, index) {
|
|
27419
|
+
if (subpath === "") return index.entryOf(pkg);
|
|
27420
|
+
return index.firstRelative(pkg.root, scriptCandidates(subpath)) ?? index.firstRelative(pkg.root, scriptCandidates(`src/${subpath}`));
|
|
27059
27421
|
}
|
|
27060
|
-
function
|
|
27061
|
-
|
|
27062
|
-
|
|
27063
|
-
|
|
27064
|
-
|
|
27065
|
-
|
|
27066
|
-
|
|
27067
|
-
|
|
27422
|
+
function importedPackageRoot(ref, index) {
|
|
27423
|
+
return ref.specifier.startsWith(".") ? null : index.packageFor(ref.specifier)?.pkg.root ?? null;
|
|
27424
|
+
}
|
|
27425
|
+
var typescript = {
|
|
27426
|
+
info: typescriptInfo,
|
|
27427
|
+
extractImports: extractImports3,
|
|
27428
|
+
resolveImport: resolveImport3,
|
|
27429
|
+
importedPackageRoot
|
|
27430
|
+
};
|
|
27431
|
+
var javascript = {
|
|
27432
|
+
info: javascriptInfo,
|
|
27433
|
+
extractImports: extractImports3,
|
|
27434
|
+
resolveImport: resolveImport3,
|
|
27435
|
+
importedPackageRoot
|
|
27436
|
+
};
|
|
27437
|
+
var DeclaredName = external_exports.string().optional().catch(void 0);
|
|
27438
|
+
var DependencyMap = external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0);
|
|
27439
|
+
var PackageJson = external_exports.object({
|
|
27440
|
+
name: DeclaredName,
|
|
27441
|
+
dependencies: DependencyMap,
|
|
27442
|
+
devDependencies: DependencyMap,
|
|
27443
|
+
peerDependencies: DependencyMap,
|
|
27444
|
+
optionalDependencies: DependencyMap
|
|
27445
|
+
});
|
|
27446
|
+
var NPM_LOCAL_SPEC = /^(?:file|link|portal):(.+)$/;
|
|
27447
|
+
function readPackageJson(text2) {
|
|
27448
|
+
const data = PackageJson.parse(JSON.parse(text2));
|
|
27449
|
+
const deps = [];
|
|
27450
|
+
const paths = [];
|
|
27451
|
+
for (const entries of [
|
|
27452
|
+
data.dependencies,
|
|
27453
|
+
data.devDependencies,
|
|
27454
|
+
data.peerDependencies,
|
|
27455
|
+
data.optionalDependencies
|
|
27456
|
+
]) {
|
|
27457
|
+
for (const [dep, spec] of Object.entries(entries ?? {})) {
|
|
27458
|
+
deps.push(dep);
|
|
27459
|
+
const local = typeof spec === "string" ? NPM_LOCAL_SPEC.exec(spec)?.[1] : void 0;
|
|
27460
|
+
if (local !== void 0) paths.push(local);
|
|
27068
27461
|
}
|
|
27069
27462
|
}
|
|
27070
|
-
|
|
27463
|
+
const name = data.name?.trim();
|
|
27464
|
+
return { name: name === void 0 || name === "" ? null : name, deps, paths };
|
|
27071
27465
|
}
|
|
27072
|
-
|
|
27073
|
-
|
|
27074
|
-
|
|
27075
|
-
|
|
27076
|
-
|
|
27077
|
-
|
|
27466
|
+
var SRC_EXTENSIONS = [".ts", ".tsx", ".mts", ".js", ".jsx"];
|
|
27467
|
+
function exportTargets(value) {
|
|
27468
|
+
if (typeof value === "string") return [value];
|
|
27469
|
+
if (!value || typeof value !== "object") return [];
|
|
27470
|
+
const entries = Object.entries(value);
|
|
27471
|
+
const root = entries.find(([k]) => k === ".");
|
|
27472
|
+
const ordered = root ? [root] : entries.filter(([k]) => !k.startsWith("./"));
|
|
27473
|
+
return ordered.flatMap(([, v]) => exportTargets(v));
|
|
27474
|
+
}
|
|
27475
|
+
function entryCandidates(root, manifestText) {
|
|
27476
|
+
if (!manifestText) return [];
|
|
27477
|
+
const join5 = (rel) => {
|
|
27478
|
+
const clean = rel.replace(/^\.\//, "");
|
|
27479
|
+
return root ? `${root}/${clean}` : clean;
|
|
27078
27480
|
};
|
|
27079
|
-
|
|
27080
|
-
|
|
27081
|
-
|
|
27082
|
-
|
|
27083
|
-
|
|
27481
|
+
const out = [];
|
|
27482
|
+
let manifest = null;
|
|
27483
|
+
try {
|
|
27484
|
+
manifest = JSON.parse(manifestText);
|
|
27485
|
+
} catch {
|
|
27084
27486
|
}
|
|
27085
|
-
|
|
27086
|
-
|
|
27087
|
-
|
|
27088
|
-
|
|
27089
|
-
|
|
27090
|
-
const
|
|
27091
|
-
|
|
27487
|
+
if (manifest && typeof manifest === "object") {
|
|
27488
|
+
const fields = ["exports", "module", "main", "types", "typings"];
|
|
27489
|
+
for (const field of fields) {
|
|
27490
|
+
if (!(field in manifest)) continue;
|
|
27491
|
+
const value = Reflect.get(manifest, field);
|
|
27492
|
+
for (const target of exportTargets(value)) {
|
|
27493
|
+
out.push(join5(target));
|
|
27494
|
+
const source = target.replace(/^\.?\/?(dist|build|lib|out)\//, "src/").replace(/(\.d)?\.(m|c)?[jt]sx?$/, "");
|
|
27495
|
+
if (source !== target) for (const ext of SRC_EXTENSIONS) out.push(join5(source + ext));
|
|
27496
|
+
}
|
|
27092
27497
|
}
|
|
27093
|
-
|
|
27094
|
-
|
|
27095
|
-
|
|
27096
|
-
|
|
27097
|
-
|
|
27098
|
-
);
|
|
27498
|
+
}
|
|
27499
|
+
for (const base of ["src/index", "index", "src/main"]) {
|
|
27500
|
+
for (const ext of SRC_EXTENSIONS) out.push(join5(base + ext));
|
|
27501
|
+
}
|
|
27502
|
+
return [...new Set(out)];
|
|
27099
27503
|
}
|
|
27100
|
-
|
|
27101
|
-
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27105
|
-
|
|
27106
|
-
|
|
27107
|
-
|
|
27108
|
-
|
|
27109
|
-
|
|
27504
|
+
var npm = {
|
|
27505
|
+
id: "npm",
|
|
27506
|
+
manifests: ["package.json"],
|
|
27507
|
+
readManifest: readPackageJson,
|
|
27508
|
+
entryCandidates
|
|
27509
|
+
};
|
|
27510
|
+
|
|
27511
|
+
// ../server/src/languages.ts
|
|
27512
|
+
var languages = new LanguageRegistry([
|
|
27513
|
+
typescript,
|
|
27514
|
+
javascript,
|
|
27515
|
+
html,
|
|
27516
|
+
css,
|
|
27517
|
+
scss,
|
|
27518
|
+
sass,
|
|
27519
|
+
less,
|
|
27520
|
+
markdown,
|
|
27521
|
+
json3,
|
|
27522
|
+
text
|
|
27523
|
+
]);
|
|
27524
|
+
var ecosystems = [npm];
|
|
27525
|
+
|
|
27526
|
+
// ../../packages/language/src/analysis.ts
|
|
27527
|
+
var FileIndex = class {
|
|
27528
|
+
#paths = /* @__PURE__ */ new Set();
|
|
27529
|
+
#byBasename = /* @__PURE__ */ new Map();
|
|
27530
|
+
#byDir = /* @__PURE__ */ new Map();
|
|
27531
|
+
/** Longest name first, so that `@acme/ui/forms` prefers a package named `@acme/ui/forms` over `@acme/ui`. */
|
|
27532
|
+
#packages = [];
|
|
27533
|
+
constructor(paths, packages = []) {
|
|
27534
|
+
for (const path of paths) {
|
|
27535
|
+
if (this.#paths.has(path)) continue;
|
|
27536
|
+
this.#paths.add(path);
|
|
27537
|
+
pushTo(this.#byBasename, basename(path), path);
|
|
27538
|
+
pushTo(this.#byDir, dirname(path), path);
|
|
27539
|
+
}
|
|
27540
|
+
for (const ref of packages) {
|
|
27541
|
+
const root = ref.root === "" ? "" : normalizePath(ref.root);
|
|
27542
|
+
if (ref.name === "" || root === null) continue;
|
|
27543
|
+
const entries = ref.entries.flatMap((entry) => normalizePath(entry) ?? []);
|
|
27544
|
+
this.#packages.push({ name: ref.name, root, entries });
|
|
27545
|
+
}
|
|
27546
|
+
this.#packages.sort((a, b) => b.name.length - a.name.length);
|
|
27547
|
+
}
|
|
27548
|
+
/** Package named by a bare specifier (`name` or `name/sub/path`), with the remaining subpath. */
|
|
27549
|
+
packageFor(specifier) {
|
|
27550
|
+
for (const pkg of this.#packages) {
|
|
27551
|
+
if (specifier === pkg.name) return { pkg, subpath: "" };
|
|
27552
|
+
if (specifier.startsWith(`${pkg.name}/`)) return { pkg, subpath: specifier.slice(pkg.name.length + 1) };
|
|
27553
|
+
}
|
|
27554
|
+
return null;
|
|
27110
27555
|
}
|
|
27111
|
-
|
|
27112
|
-
|
|
27556
|
+
/** First entry candidate of a package that is a changed file. */
|
|
27557
|
+
entryOf(pkg) {
|
|
27558
|
+
return pkg.entries.find((entry) => this.#paths.has(entry)) ?? null;
|
|
27113
27559
|
}
|
|
27114
|
-
|
|
27115
|
-
|
|
27116
|
-
|
|
27117
|
-
const
|
|
27118
|
-
|
|
27119
|
-
|
|
27120
|
-
const last = segments.at(-1);
|
|
27121
|
-
if (last === "*") segments.pop();
|
|
27122
|
-
refs.push({ specifier: segments.join("::"), names: last === void 0 ? [] : [last] });
|
|
27560
|
+
/** Root of the package containing `path`: the root that is its longest segment prefix; null when none. */
|
|
27561
|
+
ownPackageRoot(path) {
|
|
27562
|
+
let best = null;
|
|
27563
|
+
for (const { root } of this.#packages) {
|
|
27564
|
+
const contains = root === "" || path === root || path.startsWith(`${root}/`);
|
|
27565
|
+
if (contains && (best === null || root.length > best.length)) best = root;
|
|
27123
27566
|
}
|
|
27567
|
+
return best;
|
|
27124
27568
|
}
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
)
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
let depth = 0;
|
|
27139
|
-
let start = 0;
|
|
27140
|
-
for (let i = 0; i < list.length; i++) {
|
|
27141
|
-
const char = list[i];
|
|
27142
|
-
if (char === "{") depth++;
|
|
27143
|
-
else if (char === "}") depth--;
|
|
27144
|
-
else if (char === "," && depth === 0) {
|
|
27145
|
-
parts.push(list.slice(start, i));
|
|
27146
|
-
start = i + 1;
|
|
27569
|
+
has(path) {
|
|
27570
|
+
return path !== null && this.#paths.has(path);
|
|
27571
|
+
}
|
|
27572
|
+
/** Paths equal to `suffix` or ending with `/suffix`. */
|
|
27573
|
+
withSuffix(suffix) {
|
|
27574
|
+
const candidates2 = this.#byBasename.get(basename(suffix)) ?? [];
|
|
27575
|
+
return candidates2.filter((path) => path === suffix || path.endsWith(`/${suffix}`));
|
|
27576
|
+
}
|
|
27577
|
+
/** First candidate path present in the index, relative to `dir`. */
|
|
27578
|
+
firstRelative(dir, candidates2) {
|
|
27579
|
+
for (const candidate of candidates2) {
|
|
27580
|
+
const path = joinPath(dir, candidate);
|
|
27581
|
+
if (this.has(path)) return path;
|
|
27147
27582
|
}
|
|
27583
|
+
return null;
|
|
27148
27584
|
}
|
|
27149
|
-
|
|
27150
|
-
|
|
27151
|
-
|
|
27152
|
-
|
|
27153
|
-
|
|
27154
|
-
(
|
|
27155
|
-
|
|
27156
|
-
|
|
27157
|
-
|
|
27158
|
-
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
|
|
27163
|
-
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
|
|
27167
|
-
|
|
27168
|
-
|
|
27169
|
-
|
|
27170
|
-
".scss": "css",
|
|
27171
|
-
".sass": "css",
|
|
27172
|
-
".less": "css",
|
|
27173
|
-
".go": "go",
|
|
27174
|
-
".java": "java",
|
|
27175
|
-
".kt": "kotlin",
|
|
27176
|
-
".kts": "kotlin",
|
|
27177
|
-
".c": "c",
|
|
27178
|
-
".h": "c",
|
|
27179
|
-
".cpp": "cpp",
|
|
27180
|
-
".cc": "cpp",
|
|
27181
|
-
".cxx": "cpp",
|
|
27182
|
-
".hpp": "cpp",
|
|
27183
|
-
".hh": "cpp",
|
|
27184
|
-
".rs": "rust",
|
|
27185
|
-
".rb": "ruby",
|
|
27186
|
-
".vue": "vue",
|
|
27187
|
-
".svelte": "svelte",
|
|
27188
|
-
".md": "markdown",
|
|
27189
|
-
".mdx": "markdown"
|
|
27190
|
-
};
|
|
27191
|
-
function detectLanguage(path) {
|
|
27192
|
-
return LANGUAGE_BY_EXTENSION[extname(path).toLowerCase()] ?? null;
|
|
27585
|
+
/**
|
|
27586
|
+
* Suffix match of the first candidate that matches anything. Among several matches, keeps those sharing
|
|
27587
|
+
* the most leading directories with the importing file (the closest source root / package wins).
|
|
27588
|
+
*/
|
|
27589
|
+
closestWithSuffix(from, candidates2) {
|
|
27590
|
+
for (const candidate of candidates2) {
|
|
27591
|
+
const suffix = normalizePath(candidate);
|
|
27592
|
+
const matches = suffix === null ? [] : this.withSuffix(suffix);
|
|
27593
|
+
if (matches.length === 0) continue;
|
|
27594
|
+
const fromDir = dirname(from);
|
|
27595
|
+
const scores = matches.map((path) => sharedPrefixLength(fromDir, dirname(path)));
|
|
27596
|
+
const best = Math.max(...scores);
|
|
27597
|
+
return matches.filter((_, i) => scores[i] === best);
|
|
27598
|
+
}
|
|
27599
|
+
return [];
|
|
27600
|
+
}
|
|
27601
|
+
};
|
|
27602
|
+
function pushTo(map2, key, value) {
|
|
27603
|
+
const list = map2.get(key);
|
|
27604
|
+
if (list === void 0) map2.set(key, [value]);
|
|
27605
|
+
else list.push(value);
|
|
27193
27606
|
}
|
|
27194
27607
|
|
|
27195
27608
|
// ../server/src/links/mentions.ts
|
|
@@ -27278,365 +27691,81 @@ function findMentions(files, skip) {
|
|
|
27278
27691
|
const add = (to, token) => {
|
|
27279
27692
|
if (to === file2.path || skip(file2.path, to)) return;
|
|
27280
27693
|
const tokens = tokensByTarget.get(to) ?? /* @__PURE__ */ new Set();
|
|
27281
|
-
tokens.add(token);
|
|
27282
|
-
tokensByTarget.set(to, tokens);
|
|
27283
|
-
};
|
|
27284
|
-
for (const path of mentionedPaths(file2.path, file2.text, paths)) add(path, path);
|
|
27285
|
-
const words = wordSet(file2.text);
|
|
27286
|
-
for (const [token, owner] of distinctiveTokens)
|
|
27287
|
-
if (!tokensByTarget.has(owner) && words.has(token)) add(owner, token);
|
|
27288
|
-
for (const [to, tokens] of tokensByTarget) mentions.push({ from: file2.path, to, tokens: [...tokens] });
|
|
27289
|
-
}
|
|
27290
|
-
return mentions;
|
|
27291
|
-
}
|
|
27292
|
-
function mentionedPaths(from, text, paths) {
|
|
27293
|
-
const found = /* @__PURE__ */ new Set();
|
|
27294
|
-
const seen = /* @__PURE__ */ new Set();
|
|
27295
|
-
for (const [raw2] of text.matchAll(/[\w.\-/@$+~[\]]+/g)) {
|
|
27296
|
-
const token = raw2.replace(/^\[+/, "").replace(/[.\]]+$/, "");
|
|
27297
|
-
if (seen.has(token) || !token.includes(".") && !token.includes("/")) continue;
|
|
27298
|
-
seen.add(token);
|
|
27299
|
-
const relative2 = token.startsWith(".") ? joinPath(dirname(from), token) : null;
|
|
27300
|
-
if (relative2 !== null && paths.has(relative2)) {
|
|
27301
|
-
found.add(relative2);
|
|
27302
|
-
continue;
|
|
27303
|
-
}
|
|
27304
|
-
let start = 0;
|
|
27305
|
-
while (true) {
|
|
27306
|
-
const tail = token.slice(start);
|
|
27307
|
-
if (paths.has(tail)) {
|
|
27308
|
-
found.add(tail);
|
|
27309
|
-
break;
|
|
27310
|
-
}
|
|
27311
|
-
const slash = token.indexOf("/", start);
|
|
27312
|
-
if (slash === -1) break;
|
|
27313
|
-
start = slash + 1;
|
|
27314
|
-
}
|
|
27315
|
-
}
|
|
27316
|
-
return found;
|
|
27317
|
-
}
|
|
27318
|
-
function wordSet(text) {
|
|
27319
|
-
const words = /* @__PURE__ */ new Set();
|
|
27320
|
-
for (const match2 of text.matchAll(/[\w$]+(?:[.-][\w$]+)*/g)) {
|
|
27321
|
-
const word = match2[0];
|
|
27322
|
-
const before = text[match2.index - 1];
|
|
27323
|
-
const after = text[match2.index + word.length];
|
|
27324
|
-
if (before === "/" || before === "\\" || after === "/" || after === "\\") continue;
|
|
27325
|
-
words.add(word);
|
|
27326
|
-
const parts = word.split(/([.-])/);
|
|
27327
|
-
if (parts.length === 1) continue;
|
|
27328
|
-
const chunkCount = (parts.length + 1) / 2;
|
|
27329
|
-
const maxRun = chunkCount > MAX_COMPOUND_CHUNKS ? 1 : chunkCount;
|
|
27330
|
-
for (let first = 0; first < chunkCount; first++) {
|
|
27331
|
-
for (let last = first; last < Math.min(chunkCount, first + maxRun); last++) {
|
|
27332
|
-
words.add(parts.slice(first * 2, last * 2 + 1).join(""));
|
|
27333
|
-
}
|
|
27334
|
-
}
|
|
27335
|
-
}
|
|
27336
|
-
return words;
|
|
27337
|
-
}
|
|
27338
|
-
|
|
27339
|
-
// ../server/src/links/resolve.ts
|
|
27340
|
-
var FileIndex = class {
|
|
27341
|
-
#paths = /* @__PURE__ */ new Set();
|
|
27342
|
-
#byBasename = /* @__PURE__ */ new Map();
|
|
27343
|
-
#byDir = /* @__PURE__ */ new Map();
|
|
27344
|
-
/** Longest name first, so that `@acme/ui/forms` prefers a package named `@acme/ui/forms` over `@acme/ui`. */
|
|
27345
|
-
#packages = [];
|
|
27346
|
-
/** By crate name (`-` → `_`). */
|
|
27347
|
-
#crates = /* @__PURE__ */ new Map();
|
|
27348
|
-
constructor(paths, packages = []) {
|
|
27349
|
-
for (const path of paths) {
|
|
27350
|
-
if (this.#paths.has(path)) continue;
|
|
27351
|
-
this.#paths.add(path);
|
|
27352
|
-
pushTo(this.#byBasename, basename(path), path);
|
|
27353
|
-
pushTo(this.#byDir, dirname(path), path);
|
|
27354
|
-
}
|
|
27355
|
-
for (const ref of packages) {
|
|
27356
|
-
const root = ref.root === "" ? "" : normalizePath(ref.root);
|
|
27357
|
-
if (ref.name === "" || root === null) continue;
|
|
27358
|
-
const entries = ref.entries.flatMap((entry) => normalizePath(entry) ?? []);
|
|
27359
|
-
const pkg = { name: ref.name, root, entries };
|
|
27360
|
-
this.#packages.push(pkg);
|
|
27361
|
-
const crate = ref.name.replaceAll("-", "_");
|
|
27362
|
-
if (!this.#crates.has(crate)) this.#crates.set(crate, pkg);
|
|
27363
|
-
}
|
|
27364
|
-
this.#packages.sort((a, b) => b.name.length - a.name.length);
|
|
27365
|
-
}
|
|
27366
|
-
/** Package named by a bare specifier (`name` or `name/sub/path`), with the remaining subpath. */
|
|
27367
|
-
packageFor(specifier) {
|
|
27368
|
-
for (const pkg of this.#packages) {
|
|
27369
|
-
if (specifier === pkg.name) return { pkg, subpath: "" };
|
|
27370
|
-
if (specifier.startsWith(`${pkg.name}/`)) return { pkg, subpath: specifier.slice(pkg.name.length + 1) };
|
|
27371
|
-
}
|
|
27372
|
-
return null;
|
|
27373
|
-
}
|
|
27374
|
-
crate(name) {
|
|
27375
|
-
return this.#crates.get(name);
|
|
27376
|
-
}
|
|
27377
|
-
/** First entry candidate of a package that is a changed file. */
|
|
27378
|
-
entryOf(pkg) {
|
|
27379
|
-
return pkg.entries.find((entry) => this.#paths.has(entry)) ?? null;
|
|
27380
|
-
}
|
|
27381
|
-
/** Root of the package containing `path`: the root that is its longest segment prefix; null when none. */
|
|
27382
|
-
ownPackageRoot(path) {
|
|
27383
|
-
let best = null;
|
|
27384
|
-
for (const { root } of this.#packages) {
|
|
27385
|
-
const contains = root === "" || path === root || path.startsWith(`${root}/`);
|
|
27386
|
-
if (contains && (best === null || root.length > best.length)) best = root;
|
|
27387
|
-
}
|
|
27388
|
-
return best;
|
|
27389
|
-
}
|
|
27390
|
-
has(path) {
|
|
27391
|
-
return path !== null && this.#paths.has(path);
|
|
27392
|
-
}
|
|
27393
|
-
/** Paths equal to `suffix` or ending with `/suffix`. */
|
|
27394
|
-
withSuffix(suffix) {
|
|
27395
|
-
const candidates = this.#byBasename.get(basename(suffix)) ?? [];
|
|
27396
|
-
return candidates.filter((path) => path === suffix || path.endsWith(`/${suffix}`));
|
|
27397
|
-
}
|
|
27398
|
-
/** Paths whose directory equals `dirSuffix` or ends with `/dirSuffix`. */
|
|
27399
|
-
inDirWithSuffix(dirSuffix) {
|
|
27400
|
-
return [...this.#byDir].flatMap(
|
|
27401
|
-
([dir, paths]) => dir === dirSuffix || dir.endsWith(`/${dirSuffix}`) ? paths : []
|
|
27402
|
-
);
|
|
27403
|
-
}
|
|
27404
|
-
directories() {
|
|
27405
|
-
return this.#byDir.entries();
|
|
27406
|
-
}
|
|
27407
|
-
};
|
|
27408
|
-
function pushTo(map2, key, value) {
|
|
27409
|
-
const list = map2.get(key);
|
|
27410
|
-
if (list === void 0) map2.set(key, [value]);
|
|
27411
|
-
else list.push(value);
|
|
27412
|
-
}
|
|
27413
|
-
var RESOLVERS = {
|
|
27414
|
-
typescript: resolveScript,
|
|
27415
|
-
javascript: resolveScript,
|
|
27416
|
-
vue: resolveScript,
|
|
27417
|
-
svelte: resolveScript,
|
|
27418
|
-
python: resolvePython,
|
|
27419
|
-
css: resolveStyle,
|
|
27420
|
-
go: resolveGo,
|
|
27421
|
-
java: resolveJvm,
|
|
27422
|
-
kotlin: resolveJvm,
|
|
27423
|
-
c: resolveInclude,
|
|
27424
|
-
cpp: resolveInclude,
|
|
27425
|
-
rust: resolveRust,
|
|
27426
|
-
ruby: resolveRuby,
|
|
27427
|
-
markdown: () => []
|
|
27428
|
-
};
|
|
27429
|
-
function resolveImport(ref, from, language, index) {
|
|
27430
|
-
return language === null ? [] : RESOLVERS[language](ref, from, index);
|
|
27431
|
-
}
|
|
27432
|
-
function importedPackageRoot(ref, language, index) {
|
|
27433
|
-
if (language === "rust") {
|
|
27434
|
-
const crate = ref.specifier.split("::")[0];
|
|
27435
|
-
return (crate === void 0 ? void 0 : index.crate(crate))?.root ?? null;
|
|
27436
|
-
}
|
|
27437
|
-
const scriptLike = language === "typescript" || language === "javascript" || language === "vue" || language === "svelte";
|
|
27438
|
-
return scriptLike && !ref.specifier.startsWith(".") ? index.packageFor(ref.specifier)?.pkg.root ?? null : null;
|
|
27439
|
-
}
|
|
27440
|
-
function firstRelative(dir, candidates, index) {
|
|
27441
|
-
for (const candidate of candidates) {
|
|
27442
|
-
const path = joinPath(dir, candidate);
|
|
27443
|
-
if (index.has(path)) return path;
|
|
27444
|
-
}
|
|
27445
|
-
return null;
|
|
27446
|
-
}
|
|
27447
|
-
function closestWithSuffix(from, candidates, index) {
|
|
27448
|
-
for (const candidate of candidates) {
|
|
27449
|
-
const suffix = normalizePath(candidate);
|
|
27450
|
-
const matches = suffix === null ? [] : index.withSuffix(suffix);
|
|
27451
|
-
if (matches.length === 0) continue;
|
|
27452
|
-
const fromDir = dirname(from);
|
|
27453
|
-
const scores = matches.map((path) => sharedPrefixLength(fromDir, dirname(path)));
|
|
27454
|
-
const best = Math.max(...scores);
|
|
27455
|
-
return matches.filter((_, i) => scores[i] === best);
|
|
27456
|
-
}
|
|
27457
|
-
return [];
|
|
27458
|
-
}
|
|
27459
|
-
var SCRIPT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".d.ts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
27460
|
-
var TS_COUNTERPARTS = {
|
|
27461
|
-
".js": [".ts", ".tsx"],
|
|
27462
|
-
".jsx": [".tsx"],
|
|
27463
|
-
".mjs": [".mts"],
|
|
27464
|
-
".cjs": [".cts"]
|
|
27465
|
-
};
|
|
27466
|
-
var ALIAS_PREFIX = /^(?:@\/|~\/|#\/?)/;
|
|
27467
|
-
function scriptCandidates(base) {
|
|
27468
|
-
const extension = extname(base);
|
|
27469
|
-
const counterparts = (TS_COUNTERPARTS[extension] ?? []).map((ts2) => base.slice(0, -extension.length) + ts2);
|
|
27470
|
-
return [
|
|
27471
|
-
base,
|
|
27472
|
-
...counterparts,
|
|
27473
|
-
...SCRIPT_EXTENSIONS.map((ext) => base + ext),
|
|
27474
|
-
...SCRIPT_EXTENSIONS.map((ext) => `${base}/index${ext}`)
|
|
27475
|
-
];
|
|
27476
|
-
}
|
|
27477
|
-
function resolveScript(ref, from, index) {
|
|
27478
|
-
const { specifier, names } = ref;
|
|
27479
|
-
if (specifier.startsWith("./") || specifier.startsWith("../") || specifier === "." || specifier === "..") {
|
|
27480
|
-
const path = firstRelative(dirname(from), scriptCandidates(specifier), index);
|
|
27481
|
-
return path === null ? [] : [{ path, names }];
|
|
27482
|
-
}
|
|
27483
|
-
const workspace = index.packageFor(specifier);
|
|
27484
|
-
if (workspace !== null) {
|
|
27485
|
-
const path = resolveWorkspaceImport(workspace.pkg, workspace.subpath, index);
|
|
27486
|
-
return path === null ? [] : [{ path, names }];
|
|
27694
|
+
tokens.add(token);
|
|
27695
|
+
tokensByTarget.set(to, tokens);
|
|
27696
|
+
};
|
|
27697
|
+
for (const path of mentionedPaths(file2.path, file2.text, paths)) add(path, path);
|
|
27698
|
+
const words = wordSet(file2.text);
|
|
27699
|
+
for (const [token, owner] of distinctiveTokens)
|
|
27700
|
+
if (!tokensByTarget.has(owner) && words.has(token)) add(owner, token);
|
|
27701
|
+
for (const [to, tokens] of tokensByTarget) mentions.push({ from: file2.path, to, tokens: [...tokens] });
|
|
27487
27702
|
}
|
|
27488
|
-
|
|
27489
|
-
const remainder = specifier.replace(ALIAS_PREFIX, "").replace(/^\/+/, "");
|
|
27490
|
-
if (remainder === "") return [];
|
|
27491
|
-
return closestWithSuffix(from, scriptCandidates(remainder), index).map((path) => ({ path, names }));
|
|
27492
|
-
}
|
|
27493
|
-
function resolveWorkspaceImport(pkg, subpath, index) {
|
|
27494
|
-
if (subpath === "") return index.entryOf(pkg);
|
|
27495
|
-
return firstRelative(pkg.root, scriptCandidates(subpath), index) ?? firstRelative(pkg.root, scriptCandidates(`src/${subpath}`), index);
|
|
27496
|
-
}
|
|
27497
|
-
function resolvePython(ref, from, index) {
|
|
27498
|
-
const targets = [];
|
|
27499
|
-
const memberNames = [];
|
|
27500
|
-
for (const name of ref.names) {
|
|
27501
|
-
const submoduleName = ref.specifier.endsWith(".") ? ref.specifier + name : `${ref.specifier}.${name}`;
|
|
27502
|
-
const submodule = name === "*" ? [] : findPythonModule(submoduleName, from, index);
|
|
27503
|
-
if (submodule.length === 0) memberNames.push(name);
|
|
27504
|
-
for (const path of submodule) targets.push({ path, names: [name] });
|
|
27505
|
-
}
|
|
27506
|
-
if (ref.names.length === 0 || memberNames.length > 0) {
|
|
27507
|
-
const names = ref.names.length === 0 ? [ref.specifier] : memberNames;
|
|
27508
|
-
for (const path of findPythonModule(ref.specifier, from, index)) targets.push({ path, names });
|
|
27509
|
-
}
|
|
27510
|
-
return targets;
|
|
27511
|
-
}
|
|
27512
|
-
function findPythonModule(module, from, index) {
|
|
27513
|
-
const dots = /^\.*/.exec(module)?.[0].length ?? 0;
|
|
27514
|
-
const modulePath = module.slice(dots).split(".").filter(Boolean).join("/");
|
|
27515
|
-
const candidates = modulePath === "" ? ["__init__.py"] : [`${modulePath}.py`, `${modulePath}/__init__.py`];
|
|
27516
|
-
if (dots === 0) return closestWithSuffix(from, candidates, index);
|
|
27517
|
-
let base = dirname(from);
|
|
27518
|
-
for (let level = 1; level < dots && base !== null; level++) base = base === "" ? null : dirname(base);
|
|
27519
|
-
const path = base === null ? null : firstRelative(base, candidates, index);
|
|
27520
|
-
return path === null ? [] : [path];
|
|
27521
|
-
}
|
|
27522
|
-
var STYLE_EXTENSIONS = [".scss", ".sass", ".css", ".less"];
|
|
27523
|
-
function styleCandidates(base) {
|
|
27524
|
-
const dir = dirname(base);
|
|
27525
|
-
const partial2 = `${dir === "" ? "" : `${dir}/`}_${basename(base)}`;
|
|
27526
|
-
if (STYLE_EXTENSIONS.includes(extname(base))) return [base, partial2];
|
|
27527
|
-
return [
|
|
27528
|
-
base,
|
|
27529
|
-
...STYLE_EXTENSIONS.flatMap((ext) => [base + ext, partial2 + ext]),
|
|
27530
|
-
...STYLE_EXTENSIONS.flatMap((ext) => [`${base}/_index${ext}`, `${base}/index${ext}`])
|
|
27531
|
-
];
|
|
27703
|
+
return mentions;
|
|
27532
27704
|
}
|
|
27533
|
-
function
|
|
27534
|
-
const
|
|
27535
|
-
|
|
27536
|
-
const
|
|
27537
|
-
|
|
27538
|
-
|
|
27539
|
-
|
|
27540
|
-
|
|
27541
|
-
|
|
27542
|
-
|
|
27543
|
-
|
|
27544
|
-
|
|
27545
|
-
|
|
27546
|
-
|
|
27547
|
-
|
|
27548
|
-
|
|
27549
|
-
|
|
27550
|
-
|
|
27551
|
-
|
|
27552
|
-
|
|
27553
|
-
|
|
27554
|
-
|
|
27555
|
-
|
|
27556
|
-
|
|
27557
|
-
|
|
27558
|
-
function trailingMatch(a, b) {
|
|
27559
|
-
let count = 0;
|
|
27560
|
-
while (count < a.length && count < b.length && a[a.length - 1 - count] === b[b.length - 1 - count]) count++;
|
|
27561
|
-
return count;
|
|
27705
|
+
function mentionedPaths(from, text2, paths) {
|
|
27706
|
+
const found = /* @__PURE__ */ new Set();
|
|
27707
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27708
|
+
for (const [raw2] of text2.matchAll(/[\w.\-/@$+~[\]]+/g)) {
|
|
27709
|
+
const token = raw2.replace(/^\[+/, "").replace(/[.\]]+$/, "");
|
|
27710
|
+
if (seen.has(token) || !token.includes(".") && !token.includes("/")) continue;
|
|
27711
|
+
seen.add(token);
|
|
27712
|
+
const relative2 = token.startsWith(".") ? joinPath(dirname(from), token) : null;
|
|
27713
|
+
if (relative2 !== null && paths.has(relative2)) {
|
|
27714
|
+
found.add(relative2);
|
|
27715
|
+
continue;
|
|
27716
|
+
}
|
|
27717
|
+
let start = 0;
|
|
27718
|
+
while (true) {
|
|
27719
|
+
const tail = token.slice(start);
|
|
27720
|
+
if (paths.has(tail)) {
|
|
27721
|
+
found.add(tail);
|
|
27722
|
+
break;
|
|
27723
|
+
}
|
|
27724
|
+
const slash = token.indexOf("/", start);
|
|
27725
|
+
if (slash === -1) break;
|
|
27726
|
+
start = slash + 1;
|
|
27727
|
+
}
|
|
27728
|
+
}
|
|
27729
|
+
return found;
|
|
27562
27730
|
}
|
|
27563
|
-
|
|
27564
|
-
|
|
27565
|
-
const
|
|
27566
|
-
|
|
27567
|
-
|
|
27568
|
-
|
|
27569
|
-
|
|
27570
|
-
|
|
27571
|
-
const
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
)
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
|
|
27579
|
-
}
|
|
27580
|
-
|
|
27581
|
-
|
|
27582
|
-
const paths = relative2 === null ? closestWithSuffix(from, [ref.specifier], index) : [relative2];
|
|
27583
|
-
return paths.map((path) => ({ path, names: ref.names }));
|
|
27584
|
-
}
|
|
27585
|
-
var RUST_ROOT_STEMS = { mod: true, lib: true, main: true };
|
|
27586
|
-
function rustModuleDir(file2) {
|
|
27587
|
-
const stem = fileStem(file2);
|
|
27588
|
-
const dir = dirname(file2);
|
|
27589
|
-
if (Object.hasOwn(RUST_ROOT_STEMS, stem)) return dir;
|
|
27590
|
-
return dir === "" ? stem : `${dir}/${stem}`;
|
|
27591
|
-
}
|
|
27592
|
-
function resolveRust(ref, from, index) {
|
|
27593
|
-
const [root, ...rest] = ref.specifier.split("::");
|
|
27594
|
-
let base = null;
|
|
27595
|
-
if (root === "self" || root === "super") {
|
|
27596
|
-
base = rustModuleDir(from);
|
|
27597
|
-
if (root === "super") base = base === "" ? null : dirname(base);
|
|
27598
|
-
while (rest[0] === "super" && base !== null) {
|
|
27599
|
-
rest.shift();
|
|
27600
|
-
base = base === "" ? null : dirname(base);
|
|
27601
|
-
}
|
|
27602
|
-
if (base === null) return [];
|
|
27603
|
-
} else if (root !== "crate") {
|
|
27604
|
-
const crate = root === void 0 ? void 0 : index.crate(root);
|
|
27605
|
-
const entry = crate === void 0 ? null : index.entryOf(crate);
|
|
27606
|
-
return entry === null ? [] : [{ path: entry, names: ref.names }];
|
|
27607
|
-
}
|
|
27608
|
-
for (let length = rest.length; length >= 1; length--) {
|
|
27609
|
-
const modulePath = rest.slice(0, length).join("/");
|
|
27610
|
-
const candidates = [`${modulePath}.rs`, `${modulePath}/mod.rs`];
|
|
27611
|
-
const relative2 = base === null ? null : firstRelative(base, candidates, index);
|
|
27612
|
-
const paths = base === null ? closestWithSuffix(from, candidates, index) : relative2 === null ? [] : [relative2];
|
|
27613
|
-
if (paths.length > 0) return paths.map((path) => ({ path, names: ref.names }));
|
|
27614
|
-
}
|
|
27615
|
-
return [];
|
|
27616
|
-
}
|
|
27617
|
-
function resolveRuby(ref, from, index) {
|
|
27618
|
-
const candidate = ref.specifier.endsWith(".rb") ? ref.specifier : `${ref.specifier}.rb`;
|
|
27619
|
-
const path = firstRelative(dirname(from), [candidate], index);
|
|
27620
|
-
return path === null ? [] : [{ path, names: ref.names }];
|
|
27731
|
+
function wordSet(text2) {
|
|
27732
|
+
const words = /* @__PURE__ */ new Set();
|
|
27733
|
+
for (const match2 of text2.matchAll(/[\w$]+(?:[.-][\w$]+)*/g)) {
|
|
27734
|
+
const word = match2[0];
|
|
27735
|
+
const before = text2[match2.index - 1];
|
|
27736
|
+
const after = text2[match2.index + word.length];
|
|
27737
|
+
if (before === "/" || before === "\\" || after === "/" || after === "\\") continue;
|
|
27738
|
+
words.add(word);
|
|
27739
|
+
const parts = word.split(/([.-])/);
|
|
27740
|
+
if (parts.length === 1) continue;
|
|
27741
|
+
const chunkCount = (parts.length + 1) / 2;
|
|
27742
|
+
const maxRun = chunkCount > MAX_COMPOUND_CHUNKS ? 1 : chunkCount;
|
|
27743
|
+
for (let first = 0; first < chunkCount; first++) {
|
|
27744
|
+
for (let last = first; last < Math.min(chunkCount, first + maxRun); last++) {
|
|
27745
|
+
words.add(parts.slice(first * 2, last * 2 + 1).join(""));
|
|
27746
|
+
}
|
|
27747
|
+
}
|
|
27748
|
+
}
|
|
27749
|
+
return words;
|
|
27621
27750
|
}
|
|
27622
27751
|
|
|
27623
27752
|
// ../server/src/links/index.ts
|
|
27624
27753
|
var MAX_PARSED_TEXT = 1e6;
|
|
27625
27754
|
var MAX_DETAIL = 8;
|
|
27626
|
-
function buildLinkGraph(files, options = {}) {
|
|
27627
|
-
const
|
|
27755
|
+
function buildLinkGraph(files, languages2, options = {}) {
|
|
27756
|
+
const languageIds = {};
|
|
27628
27757
|
const externalImports = {};
|
|
27629
27758
|
const packageImports = {};
|
|
27630
27759
|
const indexed = /* @__PURE__ */ new Map();
|
|
27631
27760
|
for (const file2 of files) {
|
|
27632
|
-
const language =
|
|
27633
|
-
|
|
27761
|
+
const language = languages2.detect(file2.path);
|
|
27762
|
+
languageIds[file2.path] = language?.info.id ?? null;
|
|
27634
27763
|
externalImports[file2.path] = 0;
|
|
27635
27764
|
packageImports[file2.path] = [];
|
|
27636
27765
|
const key = normalizePath(file2.path);
|
|
27637
27766
|
if (key === null || indexed.has(key)) continue;
|
|
27638
|
-
const
|
|
27639
|
-
indexed.set(key, { path: file2.path, key, language, text });
|
|
27767
|
+
const readable = language !== null && file2.text !== null && file2.text.length <= MAX_PARSED_TEXT;
|
|
27768
|
+
indexed.set(key, { path: file2.path, key, language, text: readable ? file2.text : null });
|
|
27640
27769
|
}
|
|
27641
27770
|
const edges = /* @__PURE__ */ new Map();
|
|
27642
27771
|
const addEdge = (from, toKey, kind, detail) => {
|
|
@@ -27658,7 +27787,7 @@ function buildLinkGraph(files, options = {}) {
|
|
|
27658
27787
|
for (const target of targets.resolved) addEdge(file2, target.path, "import", target.names);
|
|
27659
27788
|
}
|
|
27660
27789
|
const mentions = findMentions(
|
|
27661
|
-
[...indexed.values()].map(({ key, text }) => ({ path: key, text })),
|
|
27790
|
+
[...indexed.values()].map(({ key, text: text2 }) => ({ path: key, text: text2 })),
|
|
27662
27791
|
(from, to) => edges.has(`import\0${from}\0${to}`)
|
|
27663
27792
|
);
|
|
27664
27793
|
for (const mention of mentions) {
|
|
@@ -27672,7 +27801,7 @@ function buildLinkGraph(files, options = {}) {
|
|
|
27672
27801
|
...edge,
|
|
27673
27802
|
detail: [...detail].slice(0, MAX_DETAIL)
|
|
27674
27803
|
})),
|
|
27675
|
-
languages,
|
|
27804
|
+
languages: languageIds,
|
|
27676
27805
|
externalImports,
|
|
27677
27806
|
packageImports
|
|
27678
27807
|
};
|
|
@@ -27681,14 +27810,16 @@ function importTargets(file2, index) {
|
|
|
27681
27810
|
const resolved = [];
|
|
27682
27811
|
const packageRoots = /* @__PURE__ */ new Set();
|
|
27683
27812
|
let unresolved = 0;
|
|
27684
|
-
|
|
27813
|
+
const { language, text: text2 } = file2;
|
|
27814
|
+
if (language?.extractImports === void 0 || text2 === null)
|
|
27815
|
+
return { resolved, unresolved, packageRoots: [] };
|
|
27685
27816
|
const ownRoot = index.ownPackageRoot(file2.key);
|
|
27686
27817
|
try {
|
|
27687
|
-
for (const ref of extractImports(
|
|
27688
|
-
const targets = resolveImport(ref, file2.key,
|
|
27818
|
+
for (const ref of language.extractImports(text2, file2.key)) {
|
|
27819
|
+
const targets = language.resolveImport?.(ref, file2.key, index) ?? [];
|
|
27689
27820
|
if (targets.length === 0) unresolved++;
|
|
27690
27821
|
resolved.push(...targets);
|
|
27691
|
-
const root = importedPackageRoot(ref,
|
|
27822
|
+
const root = language.importedPackageRoot?.(ref, index) ?? null;
|
|
27692
27823
|
if (root !== null && root !== ownRoot) packageRoots.add(root);
|
|
27693
27824
|
}
|
|
27694
27825
|
} catch {
|
|
@@ -27697,459 +27828,6 @@ function importTargets(file2, index) {
|
|
|
27697
27828
|
return { resolved, unresolved, packageRoots: [...packageRoots].sort() };
|
|
27698
27829
|
}
|
|
27699
27830
|
|
|
27700
|
-
// ../server/src/packages/toml.ts
|
|
27701
|
-
var TomlSyntaxError = class extends Error {
|
|
27702
|
-
};
|
|
27703
|
-
var ESCAPES = {
|
|
27704
|
-
b: "\b",
|
|
27705
|
-
t: " ",
|
|
27706
|
-
n: "\n",
|
|
27707
|
-
f: "\f",
|
|
27708
|
-
r: "\r",
|
|
27709
|
-
e: "\x1B",
|
|
27710
|
-
'"': '"',
|
|
27711
|
-
"\\": "\\"
|
|
27712
|
-
};
|
|
27713
|
-
var BARE_KEY = /[A-Za-z0-9_-]+/y;
|
|
27714
|
-
var BARE_VALUE = /[^,\]}\r\n#]+/y;
|
|
27715
|
-
var BASIC_STRING = /"((?:\\.|[^"\\\r\n])*)"/y;
|
|
27716
|
-
function parseToml(text) {
|
|
27717
|
-
return new TomlReader(text).document();
|
|
27718
|
-
}
|
|
27719
|
-
var TomlReader = class {
|
|
27720
|
-
text;
|
|
27721
|
-
pos = 0;
|
|
27722
|
-
constructor(text) {
|
|
27723
|
-
this.text = text;
|
|
27724
|
-
}
|
|
27725
|
-
document() {
|
|
27726
|
-
const root = /* @__PURE__ */ new Map();
|
|
27727
|
-
let current = root;
|
|
27728
|
-
while (this.pos < this.text.length) {
|
|
27729
|
-
this.skipBlank();
|
|
27730
|
-
const ch = this.text[this.pos];
|
|
27731
|
-
if (ch === void 0) break;
|
|
27732
|
-
if (ch === "\n" || ch === "\r" || ch === "#") {
|
|
27733
|
-
this.skipLine();
|
|
27734
|
-
continue;
|
|
27735
|
-
}
|
|
27736
|
-
try {
|
|
27737
|
-
if (ch === "[") current = this.header(root);
|
|
27738
|
-
else this.keyValue(current);
|
|
27739
|
-
this.endOfLine();
|
|
27740
|
-
} catch (error62) {
|
|
27741
|
-
if (!(error62 instanceof TomlSyntaxError)) throw error62;
|
|
27742
|
-
if (ch === "[") current = /* @__PURE__ */ new Map();
|
|
27743
|
-
this.skipLine();
|
|
27744
|
-
}
|
|
27745
|
-
}
|
|
27746
|
-
return root;
|
|
27747
|
-
}
|
|
27748
|
-
/** `[a.b]` or `[[a.b]]`; returns the table that receives the following keys. */
|
|
27749
|
-
header(root) {
|
|
27750
|
-
const isArray = this.text.startsWith("[[", this.pos);
|
|
27751
|
-
this.pos += isArray ? 2 : 1;
|
|
27752
|
-
const { parents, last } = this.key();
|
|
27753
|
-
this.expect(isArray ? "]]" : "]");
|
|
27754
|
-
const table = parents.reduce(child, root);
|
|
27755
|
-
if (!isArray) return child(table, last);
|
|
27756
|
-
const existing = table.get(last);
|
|
27757
|
-
const list = Array.isArray(existing) ? existing : [];
|
|
27758
|
-
const created = /* @__PURE__ */ new Map();
|
|
27759
|
-
list.push(created);
|
|
27760
|
-
table.set(last, list);
|
|
27761
|
-
return created;
|
|
27762
|
-
}
|
|
27763
|
-
keyValue(table) {
|
|
27764
|
-
const { parents, last } = this.key();
|
|
27765
|
-
this.expect("=");
|
|
27766
|
-
this.skipBlank();
|
|
27767
|
-
parents.reduce(child, table).set(last, this.value());
|
|
27768
|
-
}
|
|
27769
|
-
/** A possibly dotted key, split into its parent path and final segment. */
|
|
27770
|
-
key() {
|
|
27771
|
-
const parents = [];
|
|
27772
|
-
let last = this.simpleKey();
|
|
27773
|
-
for (; ; ) {
|
|
27774
|
-
this.skipBlank();
|
|
27775
|
-
if (this.text[this.pos] !== ".") return { parents, last };
|
|
27776
|
-
this.pos++;
|
|
27777
|
-
parents.push(last);
|
|
27778
|
-
last = this.simpleKey();
|
|
27779
|
-
}
|
|
27780
|
-
}
|
|
27781
|
-
simpleKey() {
|
|
27782
|
-
this.skipBlank();
|
|
27783
|
-
const ch = this.text[this.pos];
|
|
27784
|
-
if (ch === '"') return this.basicString();
|
|
27785
|
-
if (ch === "'") return this.literalString();
|
|
27786
|
-
BARE_KEY.lastIndex = this.pos;
|
|
27787
|
-
const match2 = BARE_KEY.exec(this.text);
|
|
27788
|
-
if (match2 === null) throw new TomlSyntaxError(`Invalid key at ${this.pos}`);
|
|
27789
|
-
this.pos = BARE_KEY.lastIndex;
|
|
27790
|
-
return match2[0];
|
|
27791
|
-
}
|
|
27792
|
-
value() {
|
|
27793
|
-
if (this.text.startsWith('"""', this.pos)) return this.multilineString('"""');
|
|
27794
|
-
if (this.text.startsWith("'''", this.pos)) return this.multilineString("'''");
|
|
27795
|
-
switch (this.text[this.pos]) {
|
|
27796
|
-
case '"':
|
|
27797
|
-
return this.basicString();
|
|
27798
|
-
case "'":
|
|
27799
|
-
return this.literalString();
|
|
27800
|
-
case "[":
|
|
27801
|
-
return this.array();
|
|
27802
|
-
case "{":
|
|
27803
|
-
return this.inlineTable();
|
|
27804
|
-
default: {
|
|
27805
|
-
BARE_VALUE.lastIndex = this.pos;
|
|
27806
|
-
const match2 = BARE_VALUE.exec(this.text);
|
|
27807
|
-
if (match2 === null || match2[0].trim() === "")
|
|
27808
|
-
throw new TomlSyntaxError(`Missing value at ${this.pos}`);
|
|
27809
|
-
this.pos = BARE_VALUE.lastIndex;
|
|
27810
|
-
return null;
|
|
27811
|
-
}
|
|
27812
|
-
}
|
|
27813
|
-
}
|
|
27814
|
-
basicString() {
|
|
27815
|
-
BASIC_STRING.lastIndex = this.pos;
|
|
27816
|
-
const match2 = BASIC_STRING.exec(this.text);
|
|
27817
|
-
if (match2 === null) throw new TomlSyntaxError(`Unterminated string at ${this.pos}`);
|
|
27818
|
-
this.pos = BASIC_STRING.lastIndex;
|
|
27819
|
-
return decodeEscapes(match2[1] ?? "");
|
|
27820
|
-
}
|
|
27821
|
-
literalString() {
|
|
27822
|
-
const start = this.pos + 1;
|
|
27823
|
-
const end = this.text.indexOf("'", start);
|
|
27824
|
-
const newline = this.text.indexOf("\n", start);
|
|
27825
|
-
if (end === -1 || newline !== -1 && newline < end) {
|
|
27826
|
-
throw new TomlSyntaxError(`Unterminated string at ${this.pos}`);
|
|
27827
|
-
}
|
|
27828
|
-
this.pos = end + 1;
|
|
27829
|
-
return this.text.slice(start, end);
|
|
27830
|
-
}
|
|
27831
|
-
/** `"""…"""` (with escapes and line-ending backslashes) or `'''…'''` (verbatim). */
|
|
27832
|
-
multilineString(delimiter) {
|
|
27833
|
-
let start = this.pos + 3;
|
|
27834
|
-
if (this.text.startsWith("\r\n", start)) start += 2;
|
|
27835
|
-
else if (this.text[start] === "\n") start++;
|
|
27836
|
-
let end = this.text.indexOf(delimiter, start);
|
|
27837
|
-
if (end === -1) throw new TomlSyntaxError(`Unterminated string at ${this.pos}`);
|
|
27838
|
-
for (let extra = 0; extra < 2 && this.text[end + 3] === delimiter[0]; extra++) end++;
|
|
27839
|
-
this.pos = end + 3;
|
|
27840
|
-
const raw2 = this.text.slice(start, end);
|
|
27841
|
-
return delimiter === "'''" ? raw2 : decodeEscapes(raw2.replace(/\\[ \t]*\r?\n\s*/g, ""));
|
|
27842
|
-
}
|
|
27843
|
-
array() {
|
|
27844
|
-
this.pos++;
|
|
27845
|
-
const items = [];
|
|
27846
|
-
for (; ; ) {
|
|
27847
|
-
this.skipInsignificant();
|
|
27848
|
-
if (this.text[this.pos] === "]") {
|
|
27849
|
-
this.pos++;
|
|
27850
|
-
return items;
|
|
27851
|
-
}
|
|
27852
|
-
items.push(this.value());
|
|
27853
|
-
this.skipInsignificant();
|
|
27854
|
-
const ch = this.text[this.pos];
|
|
27855
|
-
this.pos++;
|
|
27856
|
-
if (ch === "]") return items;
|
|
27857
|
-
if (ch !== ",") throw new TomlSyntaxError(`Expected , or ] at ${this.pos - 1}`);
|
|
27858
|
-
}
|
|
27859
|
-
}
|
|
27860
|
-
/** `{ a = 1, b.c = "x" }`; newlines are tolerated inside, as many real manifests use them. */
|
|
27861
|
-
inlineTable() {
|
|
27862
|
-
this.pos++;
|
|
27863
|
-
const table = /* @__PURE__ */ new Map();
|
|
27864
|
-
for (; ; ) {
|
|
27865
|
-
this.skipInsignificant();
|
|
27866
|
-
if (this.text[this.pos] === "}") {
|
|
27867
|
-
this.pos++;
|
|
27868
|
-
return table;
|
|
27869
|
-
}
|
|
27870
|
-
this.keyValue(table);
|
|
27871
|
-
this.skipInsignificant();
|
|
27872
|
-
const ch = this.text[this.pos];
|
|
27873
|
-
this.pos++;
|
|
27874
|
-
if (ch === "}") return table;
|
|
27875
|
-
if (ch !== ",") throw new TomlSyntaxError(`Expected , or } at ${this.pos - 1}`);
|
|
27876
|
-
}
|
|
27877
|
-
}
|
|
27878
|
-
expect(token) {
|
|
27879
|
-
this.skipBlank();
|
|
27880
|
-
if (!this.text.startsWith(token, this.pos)) throw new TomlSyntaxError(`Expected ${token} at ${this.pos}`);
|
|
27881
|
-
this.pos += token.length;
|
|
27882
|
-
}
|
|
27883
|
-
endOfLine() {
|
|
27884
|
-
this.skipBlank();
|
|
27885
|
-
const ch = this.text[this.pos];
|
|
27886
|
-
if (ch === void 0 || ch === "#") this.skipLine();
|
|
27887
|
-
else if (ch === "\n") this.pos++;
|
|
27888
|
-
else if (this.text.startsWith("\r\n", this.pos)) this.pos += 2;
|
|
27889
|
-
else throw new TomlSyntaxError(`Unexpected ${ch} at ${this.pos}`);
|
|
27890
|
-
}
|
|
27891
|
-
skipBlank() {
|
|
27892
|
-
while (this.text[this.pos] === " " || this.text[this.pos] === " ") this.pos++;
|
|
27893
|
-
}
|
|
27894
|
-
/** Whitespace, newlines and comments, as allowed between array or inline-table items. */
|
|
27895
|
-
skipInsignificant() {
|
|
27896
|
-
for (; ; ) {
|
|
27897
|
-
const ch = this.text[this.pos];
|
|
27898
|
-
if (ch === " " || ch === " " || ch === "\n" || ch === "\r") this.pos++;
|
|
27899
|
-
else if (ch === "#") this.skipLine();
|
|
27900
|
-
else return;
|
|
27901
|
-
}
|
|
27902
|
-
}
|
|
27903
|
-
skipLine() {
|
|
27904
|
-
const newline = this.text.indexOf("\n", this.pos);
|
|
27905
|
-
this.pos = newline === -1 ? this.text.length : newline + 1;
|
|
27906
|
-
}
|
|
27907
|
-
};
|
|
27908
|
-
function child(table, key) {
|
|
27909
|
-
const existing = table.get(key);
|
|
27910
|
-
if (existing instanceof Map) return existing;
|
|
27911
|
-
if (Array.isArray(existing)) {
|
|
27912
|
-
const last = existing.at(-1);
|
|
27913
|
-
if (last instanceof Map) return last;
|
|
27914
|
-
}
|
|
27915
|
-
const created = /* @__PURE__ */ new Map();
|
|
27916
|
-
table.set(key, created);
|
|
27917
|
-
return created;
|
|
27918
|
-
}
|
|
27919
|
-
function decodeEscapes(raw2) {
|
|
27920
|
-
return raw2.replace(
|
|
27921
|
-
/\\(?:u([0-9A-Fa-f]{4})|U([0-9A-Fa-f]{8})|([\s\S]))/g,
|
|
27922
|
-
(match2, short, long, ch) => {
|
|
27923
|
-
const hex3 = short ?? long;
|
|
27924
|
-
if (hex3 !== void 0) {
|
|
27925
|
-
const codePoint = Number.parseInt(hex3, 16);
|
|
27926
|
-
return codePoint <= 1114111 ? String.fromCodePoint(codePoint) : "\uFFFD";
|
|
27927
|
-
}
|
|
27928
|
-
return ch !== void 0 && Object.hasOwn(ESCAPES, ch) ? ESCAPES[ch] ?? match2 : match2;
|
|
27929
|
-
}
|
|
27930
|
-
);
|
|
27931
|
-
}
|
|
27932
|
-
|
|
27933
|
-
// ../server/src/packages/manifests.ts
|
|
27934
|
-
var MANIFEST_KINDS = {
|
|
27935
|
-
"package.json": { ecosystem: "npm", priority: 0, read: readPackageJson },
|
|
27936
|
-
"pyproject.toml": { ecosystem: "python", priority: 1, read: readPyproject },
|
|
27937
|
-
"setup.py": { ecosystem: "python", priority: 2, read: readSetupPy },
|
|
27938
|
-
"Cargo.toml": { ecosystem: "rust", priority: 3, read: readCargoToml },
|
|
27939
|
-
"go.mod": { ecosystem: "go", priority: 4, read: readGoMod },
|
|
27940
|
-
"pom.xml": { ecosystem: "maven", priority: 5, read: readPom },
|
|
27941
|
-
"build.gradle": { ecosystem: "gradle", priority: 6, read: readGradle },
|
|
27942
|
-
"build.gradle.kts": { ecosystem: "gradle", priority: 6, read: readGradle },
|
|
27943
|
-
"composer.json": { ecosystem: "composer", priority: 7, read: readComposerJson }
|
|
27944
|
-
};
|
|
27945
|
-
function manifestKind(basename2) {
|
|
27946
|
-
return Object.hasOwn(MANIFEST_KINDS, basename2) ? MANIFEST_KINDS[basename2] : void 0;
|
|
27947
|
-
}
|
|
27948
|
-
function readManifest(kind, text) {
|
|
27949
|
-
if (text !== null) {
|
|
27950
|
-
try {
|
|
27951
|
-
return kind.read(text);
|
|
27952
|
-
} catch {
|
|
27953
|
-
}
|
|
27954
|
-
}
|
|
27955
|
-
return { name: null, deps: [], paths: [] };
|
|
27956
|
-
}
|
|
27957
|
-
function nonEmptyString(value) {
|
|
27958
|
-
return typeof value === "string" && value.trim() !== "" ? value.trim() : null;
|
|
27959
|
-
}
|
|
27960
|
-
var DeclaredName = external_exports.string().optional().catch(void 0);
|
|
27961
|
-
var DependencyMap = external_exports.record(external_exports.string(), external_exports.unknown()).optional().catch(void 0);
|
|
27962
|
-
var PackageJson = external_exports.object({
|
|
27963
|
-
name: DeclaredName,
|
|
27964
|
-
dependencies: DependencyMap,
|
|
27965
|
-
devDependencies: DependencyMap,
|
|
27966
|
-
peerDependencies: DependencyMap,
|
|
27967
|
-
optionalDependencies: DependencyMap
|
|
27968
|
-
});
|
|
27969
|
-
var ComposerJson = external_exports.object({ name: DeclaredName, require: DependencyMap, "require-dev": DependencyMap });
|
|
27970
|
-
var NPM_LOCAL_SPEC = /^(?:file|link|portal):(.+)$/;
|
|
27971
|
-
function readPackageJson(text) {
|
|
27972
|
-
const data = PackageJson.parse(JSON.parse(text));
|
|
27973
|
-
const deps = [];
|
|
27974
|
-
const paths = [];
|
|
27975
|
-
for (const entries of [
|
|
27976
|
-
data.dependencies,
|
|
27977
|
-
data.devDependencies,
|
|
27978
|
-
data.peerDependencies,
|
|
27979
|
-
data.optionalDependencies
|
|
27980
|
-
]) {
|
|
27981
|
-
for (const [dep, spec] of Object.entries(entries ?? {})) {
|
|
27982
|
-
deps.push(dep);
|
|
27983
|
-
const local = typeof spec === "string" ? NPM_LOCAL_SPEC.exec(spec)?.[1] : void 0;
|
|
27984
|
-
if (local !== void 0) paths.push(local);
|
|
27985
|
-
}
|
|
27986
|
-
}
|
|
27987
|
-
return { name: nonEmptyString(data.name), deps, paths };
|
|
27988
|
-
}
|
|
27989
|
-
function readComposerJson(text) {
|
|
27990
|
-
const data = ComposerJson.parse(JSON.parse(text));
|
|
27991
|
-
const deps = [...Object.keys(data.require ?? {}), ...Object.keys(data["require-dev"] ?? {})];
|
|
27992
|
-
return { name: nonEmptyString(data.name), deps, paths: [] };
|
|
27993
|
-
}
|
|
27994
|
-
function tomlAt(table, ...keys) {
|
|
27995
|
-
let value = table;
|
|
27996
|
-
for (const key of keys) value = value instanceof Map ? value.get(key) : void 0;
|
|
27997
|
-
return value;
|
|
27998
|
-
}
|
|
27999
|
-
function requirementName(requirement) {
|
|
28000
|
-
return /^\s*([A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?)/.exec(requirement)?.[1] ?? null;
|
|
28001
|
-
}
|
|
28002
|
-
function readPyproject(text) {
|
|
28003
|
-
const doc = parseToml(text);
|
|
28004
|
-
const deps = [];
|
|
28005
|
-
const paths = [];
|
|
28006
|
-
const requirements = (value) => {
|
|
28007
|
-
if (!Array.isArray(value)) return;
|
|
28008
|
-
for (const item of value) {
|
|
28009
|
-
const name2 = typeof item === "string" ? requirementName(item) : null;
|
|
28010
|
-
if (name2 !== null) deps.push(name2);
|
|
28011
|
-
}
|
|
28012
|
-
};
|
|
28013
|
-
const keyedDependencies = (value) => {
|
|
28014
|
-
if (!(value instanceof Map)) return;
|
|
28015
|
-
for (const [dep, spec] of value) {
|
|
28016
|
-
if (dep !== "python") deps.push(dep);
|
|
28017
|
-
const path = nonEmptyString(tomlAt(spec instanceof Map ? spec : void 0, "path"));
|
|
28018
|
-
if (path !== null) paths.push(path);
|
|
28019
|
-
}
|
|
28020
|
-
};
|
|
28021
|
-
requirements(tomlAt(doc, "project", "dependencies"));
|
|
28022
|
-
const optional2 = tomlAt(doc, "project", "optional-dependencies");
|
|
28023
|
-
if (optional2 instanceof Map) for (const group of optional2.values()) requirements(group);
|
|
28024
|
-
const dependencyGroups = tomlAt(doc, "dependency-groups");
|
|
28025
|
-
if (dependencyGroups instanceof Map) for (const group of dependencyGroups.values()) requirements(group);
|
|
28026
|
-
const poetry = tomlAt(doc, "tool", "poetry");
|
|
28027
|
-
keyedDependencies(tomlAt(doc, "tool", "poetry", "dependencies"));
|
|
28028
|
-
keyedDependencies(tomlAt(doc, "tool", "poetry", "dev-dependencies"));
|
|
28029
|
-
const poetryGroups = tomlAt(doc, "tool", "poetry", "group");
|
|
28030
|
-
if (poetryGroups instanceof Map) {
|
|
28031
|
-
for (const group of poetryGroups.values()) {
|
|
28032
|
-
keyedDependencies(tomlAt(group instanceof Map ? group : void 0, "dependencies"));
|
|
28033
|
-
}
|
|
28034
|
-
}
|
|
28035
|
-
keyedDependencies(tomlAt(doc, "tool", "uv", "sources"));
|
|
28036
|
-
const name = nonEmptyString(tomlAt(doc, "project", "name")) ?? nonEmptyString(tomlAt(poetry instanceof Map ? poetry : void 0, "name"));
|
|
28037
|
-
return { name, deps, paths };
|
|
28038
|
-
}
|
|
28039
|
-
var CARGO_DEPENDENCY_TABLES = ["dependencies", "dev-dependencies", "build-dependencies"];
|
|
28040
|
-
function readCargoToml(text) {
|
|
28041
|
-
const doc = parseToml(text);
|
|
28042
|
-
const deps = [];
|
|
28043
|
-
const paths = [];
|
|
28044
|
-
const tables = [
|
|
28045
|
-
...CARGO_DEPENDENCY_TABLES.map((key) => doc.get(key)),
|
|
28046
|
-
tomlAt(doc, "workspace", "dependencies")
|
|
28047
|
-
];
|
|
28048
|
-
const targets = doc.get("target");
|
|
28049
|
-
if (targets instanceof Map) {
|
|
28050
|
-
for (const target of targets.values()) {
|
|
28051
|
-
if (target instanceof Map) tables.push(...CARGO_DEPENDENCY_TABLES.map((key) => target.get(key)));
|
|
28052
|
-
}
|
|
28053
|
-
}
|
|
28054
|
-
for (const table of tables) {
|
|
28055
|
-
if (!(table instanceof Map)) continue;
|
|
28056
|
-
for (const [key, spec] of table) {
|
|
28057
|
-
const detail = spec instanceof Map ? spec : void 0;
|
|
28058
|
-
deps.push(nonEmptyString(tomlAt(detail, "package")) ?? key);
|
|
28059
|
-
const path = nonEmptyString(tomlAt(detail, "path"));
|
|
28060
|
-
if (path !== null) paths.push(path);
|
|
28061
|
-
}
|
|
28062
|
-
}
|
|
28063
|
-
return { name: nonEmptyString(tomlAt(doc, "package", "name")), deps, paths };
|
|
28064
|
-
}
|
|
28065
|
-
var PYTHON_LIST_TOKEN = /(['"])((?:\\.|(?!\1)[^\\\n])*)\1|#[^\n]*|[\])]/g;
|
|
28066
|
-
function readSetupPy(text) {
|
|
28067
|
-
const name = /\bname\s*=\s*(['"])([^'"\n]+)\1/.exec(text)?.[2] ?? null;
|
|
28068
|
-
const deps = [];
|
|
28069
|
-
const opener = /\binstall_requires\s*=\s*[[(]/.exec(text);
|
|
28070
|
-
if (opener !== null) {
|
|
28071
|
-
PYTHON_LIST_TOKEN.lastIndex = opener.index + opener[0].length;
|
|
28072
|
-
for (let token = PYTHON_LIST_TOKEN.exec(text); token !== null; token = PYTHON_LIST_TOKEN.exec(text)) {
|
|
28073
|
-
if (token[0] === "]" || token[0] === ")") break;
|
|
28074
|
-
const dep = token[1] !== void 0 ? requirementName(token[2] ?? "") : null;
|
|
28075
|
-
if (dep !== null) deps.push(dep);
|
|
28076
|
-
}
|
|
28077
|
-
}
|
|
28078
|
-
return { name: nonEmptyString(name), deps, paths: [] };
|
|
28079
|
-
}
|
|
28080
|
-
function readGoMod(text) {
|
|
28081
|
-
let name = null;
|
|
28082
|
-
const deps = [];
|
|
28083
|
-
const paths = [];
|
|
28084
|
-
const directive = (verb, args) => {
|
|
28085
|
-
const first = args.split(/\s+/)[0]?.replace(/^"(.*)"$/, "$1") ?? "";
|
|
28086
|
-
if (verb === "module" && first !== "") name = first;
|
|
28087
|
-
else if (verb === "require" && first !== "") deps.push(first);
|
|
28088
|
-
else if (verb === "replace") {
|
|
28089
|
-
const target = args.split("=>")[1]?.trim().split(/\s+/)[0] ?? "";
|
|
28090
|
-
if (/^\.\.?(?:\/|$)/.test(target)) paths.push(target);
|
|
28091
|
-
}
|
|
28092
|
-
};
|
|
28093
|
-
let block = null;
|
|
28094
|
-
for (const raw2 of text.split("\n")) {
|
|
28095
|
-
const commentAt = raw2.indexOf("//");
|
|
28096
|
-
const line = (commentAt === -1 ? raw2 : raw2.slice(0, commentAt)).trim();
|
|
28097
|
-
if (line === "") continue;
|
|
28098
|
-
if (block !== null) {
|
|
28099
|
-
if (line === ")") block = null;
|
|
28100
|
-
else directive(block, line);
|
|
28101
|
-
continue;
|
|
28102
|
-
}
|
|
28103
|
-
const match2 = /^([a-z]+)\s*(.*)$/.exec(line);
|
|
28104
|
-
const verb = match2?.[1];
|
|
28105
|
-
const args = match2?.[2] ?? "";
|
|
28106
|
-
if (verb === void 0) continue;
|
|
28107
|
-
if (args === "(") block = verb;
|
|
28108
|
-
else directive(verb, args);
|
|
28109
|
-
}
|
|
28110
|
-
return { name, deps, paths };
|
|
28111
|
-
}
|
|
28112
|
-
var XML_TAG = /<(\/?)([A-Za-z_][\w.:-]*)[^>]*?(\/?)>/g;
|
|
28113
|
-
function readPom(text) {
|
|
28114
|
-
const xml = text.replace(/<!--[\s\S]*?-->/g, "").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, "");
|
|
28115
|
-
const stack = [];
|
|
28116
|
-
let name = null;
|
|
28117
|
-
const deps = [];
|
|
28118
|
-
for (const match2 of xml.matchAll(XML_TAG)) {
|
|
28119
|
-
const [whole, closing, qualified = "", selfClosing] = match2;
|
|
28120
|
-
const tag = qualified.slice(qualified.lastIndexOf(":") + 1);
|
|
28121
|
-
if (selfClosing === "/") continue;
|
|
28122
|
-
if (closing !== "/") {
|
|
28123
|
-
stack.push({ tag, contentStart: match2.index + whole.length });
|
|
28124
|
-
continue;
|
|
28125
|
-
}
|
|
28126
|
-
const openAt = stack.findLastIndex((element) => element.tag === tag);
|
|
28127
|
-
const open2 = stack[openAt];
|
|
28128
|
-
if (open2 === void 0) continue;
|
|
28129
|
-
if (tag === "artifactId") {
|
|
28130
|
-
const value = nonEmptyString(xml.slice(open2.contentStart, match2.index));
|
|
28131
|
-
const ancestors = stack.slice(0, openAt).map((element) => element.tag);
|
|
28132
|
-
if (value !== null && ancestors.length === 1 && ancestors[0] === "project") name ??= value;
|
|
28133
|
-
else if (value !== null && ancestors.at(-1) === "dependency" && !ancestors.includes("dependencyManagement")) {
|
|
28134
|
-
deps.push(value);
|
|
28135
|
-
}
|
|
28136
|
-
}
|
|
28137
|
-
stack.length = openAt;
|
|
28138
|
-
}
|
|
28139
|
-
return { name, deps, paths: [] };
|
|
28140
|
-
}
|
|
28141
|
-
var C_COMMENT_OR_STRING = /("(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*')|\/\/[^\n]*|\/\*[\s\S]*?\*\//g;
|
|
28142
|
-
var GRADLE_PROJECT_REF = /\bproject\s*\(\s*(?:path\s*[:=]\s*)?(['"])(:[^'"]*)\1/g;
|
|
28143
|
-
function readGradle(text) {
|
|
28144
|
-
const code = text.replace(C_COMMENT_OR_STRING, (_match, literal2) => literal2 ?? "");
|
|
28145
|
-
const deps = [];
|
|
28146
|
-
for (const match2 of code.matchAll(GRADLE_PROJECT_REF)) {
|
|
28147
|
-
const path = (match2[2] ?? "").split(":").filter(Boolean).join("/");
|
|
28148
|
-
if (path !== "") deps.push(path);
|
|
28149
|
-
}
|
|
28150
|
-
return { name: null, deps, paths: [] };
|
|
28151
|
-
}
|
|
28152
|
-
|
|
28153
27831
|
// ../server/src/packages/index.ts
|
|
28154
27832
|
var REPO_ROOT_NAME = "(racine)";
|
|
28155
27833
|
var EXCLUDED_DIRS = {
|
|
@@ -28157,53 +27835,72 @@ var EXCLUDED_DIRS = {
|
|
|
28157
27835
|
vendor: true,
|
|
28158
27836
|
dist: true,
|
|
28159
27837
|
build: true,
|
|
28160
|
-
target: true,
|
|
28161
27838
|
out: true,
|
|
28162
27839
|
".git": true,
|
|
28163
|
-
".venv": true,
|
|
28164
|
-
venv: true,
|
|
28165
|
-
__pycache__: true,
|
|
28166
27840
|
coverage: true,
|
|
28167
27841
|
fixtures: true,
|
|
28168
27842
|
__fixtures__: true,
|
|
28169
27843
|
testdata: true,
|
|
28170
27844
|
__mocks__: true
|
|
28171
27845
|
};
|
|
28172
|
-
function
|
|
27846
|
+
function manifestKind(basename2, ecosystems2) {
|
|
27847
|
+
let priority = 0;
|
|
27848
|
+
for (const ecosystem of ecosystems2) {
|
|
27849
|
+
for (const manifest of ecosystem.manifests) {
|
|
27850
|
+
if (manifest === basename2) return { ecosystem, priority };
|
|
27851
|
+
priority++;
|
|
27852
|
+
}
|
|
27853
|
+
}
|
|
27854
|
+
return void 0;
|
|
27855
|
+
}
|
|
27856
|
+
function isManifestPath(path, ecosystems2) {
|
|
28173
27857
|
const segments = path.split("/");
|
|
28174
27858
|
const basename2 = segments.pop() ?? "";
|
|
28175
|
-
return manifestKind(basename2) !== void 0 && !segments.some((segment) => Object.hasOwn(EXCLUDED_DIRS, segment));
|
|
27859
|
+
return manifestKind(basename2, ecosystems2) !== void 0 && !segments.some((segment) => Object.hasOwn(EXCLUDED_DIRS, segment));
|
|
27860
|
+
}
|
|
27861
|
+
function readManifest(ecosystem, path, text2) {
|
|
27862
|
+
if (text2 !== null) {
|
|
27863
|
+
try {
|
|
27864
|
+
return ecosystem.readManifest(text2, path.slice(path.lastIndexOf("/") + 1));
|
|
27865
|
+
} catch {
|
|
27866
|
+
}
|
|
27867
|
+
}
|
|
27868
|
+
return { name: null, deps: [], paths: [] };
|
|
28176
27869
|
}
|
|
28177
|
-
function parseWorkspace(manifests) {
|
|
27870
|
+
function parseWorkspace(manifests, ecosystems2) {
|
|
28178
27871
|
const chosen = /* @__PURE__ */ new Map();
|
|
28179
27872
|
for (const file2 of manifests) {
|
|
28180
27873
|
const slash = file2.path.lastIndexOf("/");
|
|
28181
|
-
const kind = isManifestPath(file2.path) ? manifestKind(file2.path.slice(slash + 1)) : void 0;
|
|
27874
|
+
const kind = isManifestPath(file2.path, ecosystems2) ? manifestKind(file2.path.slice(slash + 1), ecosystems2) : void 0;
|
|
28182
27875
|
if (kind === void 0) continue;
|
|
28183
27876
|
const root = slash === -1 ? "" : file2.path.slice(0, slash);
|
|
28184
27877
|
const current = chosen.get(root);
|
|
28185
27878
|
const wins = current === void 0 || kind.priority < current.kind.priority || kind.priority === current.kind.priority && file2.path < current.file.path;
|
|
28186
27879
|
if (wins) chosen.set(root, { file: file2, kind });
|
|
28187
27880
|
}
|
|
28188
|
-
const parsed = [...chosen].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([root, { file: file2, kind }]) => ({
|
|
27881
|
+
const parsed = [...chosen].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([root, { file: file2, kind }]) => ({
|
|
27882
|
+
root,
|
|
27883
|
+
path: file2.path,
|
|
27884
|
+
ecosystem: kind.ecosystem,
|
|
27885
|
+
info: readManifest(kind.ecosystem, file2.path, file2.text)
|
|
27886
|
+
}));
|
|
28189
27887
|
const byName = /* @__PURE__ */ new Map();
|
|
28190
|
-
|
|
27888
|
+
const matchKey = (ecosystem, name) => ecosystem.normalizeName?.(name) ?? name;
|
|
27889
|
+
for (const { root, ecosystem, info } of parsed) {
|
|
28191
27890
|
if (info.name === null) continue;
|
|
28192
|
-
let names = byName.get(
|
|
27891
|
+
let names = byName.get(ecosystem);
|
|
28193
27892
|
if (names === void 0) {
|
|
28194
27893
|
names = /* @__PURE__ */ new Map();
|
|
28195
|
-
byName.set(
|
|
27894
|
+
byName.set(ecosystem, names);
|
|
28196
27895
|
}
|
|
28197
|
-
const key = matchKey(
|
|
27896
|
+
const key = matchKey(ecosystem, info.name);
|
|
28198
27897
|
if (!names.has(key)) names.set(key, root);
|
|
28199
27898
|
}
|
|
28200
27899
|
const roots = new Set(parsed.map(({ root }) => root));
|
|
28201
|
-
|
|
28202
|
-
return parsed.map(({ root, path, kind, info }) => {
|
|
28203
|
-
const { ecosystem } = kind;
|
|
27900
|
+
return parsed.map(({ root, path, ecosystem, info }) => {
|
|
28204
27901
|
const targets = /* @__PURE__ */ new Set();
|
|
28205
27902
|
for (const dep of info.deps) {
|
|
28206
|
-
const target =
|
|
27903
|
+
const target = byName.get(ecosystem)?.get(matchKey(ecosystem, dep));
|
|
28207
27904
|
if (target !== void 0) targets.add(target);
|
|
28208
27905
|
}
|
|
28209
27906
|
for (const relative2 of info.paths) {
|
|
@@ -28211,11 +27908,10 @@ function parseWorkspace(manifests) {
|
|
|
28211
27908
|
if (target !== null && roots.has(target)) targets.add(target);
|
|
28212
27909
|
}
|
|
28213
27910
|
targets.delete(root);
|
|
28214
|
-
const fallback = ecosystem === "gradle" ? root.slice(root.lastIndexOf("/") + 1) : root;
|
|
28215
27911
|
return {
|
|
28216
27912
|
root,
|
|
28217
|
-
name: info.name ?? (
|
|
28218
|
-
ecosystem,
|
|
27913
|
+
name: info.name ?? (root === "" ? REPO_ROOT_NAME : root),
|
|
27914
|
+
ecosystem: ecosystem.id,
|
|
28219
27915
|
manifest: path,
|
|
28220
27916
|
dependsOn: [...targets].sort()
|
|
28221
27917
|
};
|
|
@@ -28229,16 +27925,6 @@ function packageRootOf(path, roots) {
|
|
|
28229
27925
|
}
|
|
28230
27926
|
return best;
|
|
28231
27927
|
}
|
|
28232
|
-
function matchKey(ecosystem, name) {
|
|
28233
|
-
switch (ecosystem) {
|
|
28234
|
-
case "python":
|
|
28235
|
-
return name.toLowerCase().replace(/[-_.]+/g, "-");
|
|
28236
|
-
case "rust":
|
|
28237
|
-
return name.toLowerCase().replace(/_/g, "-");
|
|
28238
|
-
default:
|
|
28239
|
-
return name;
|
|
28240
|
-
}
|
|
28241
|
-
}
|
|
28242
27928
|
function resolvePath(dir, relative2) {
|
|
28243
27929
|
const normalized = relative2.replace(/\\/g, "/");
|
|
28244
27930
|
if (normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized)) return null;
|
|
@@ -28250,42 +27936,9 @@ function resolvePath(dir, relative2) {
|
|
|
28250
27936
|
}
|
|
28251
27937
|
return segments.join("/");
|
|
28252
27938
|
}
|
|
28253
|
-
function resolveGradleProject(projectPath, from, gradleRoots) {
|
|
28254
|
-
let best;
|
|
28255
|
-
let bestDepth = -1;
|
|
28256
|
-
for (const root of gradleRoots) {
|
|
28257
|
-
if (root !== projectPath && !root.endsWith(`/${projectPath}`)) continue;
|
|
28258
|
-
const base = root.slice(0, Math.max(0, root.length - projectPath.length - 1));
|
|
28259
|
-
const depth = base === "" || from === base || from.startsWith(`${base}/`) ? base.length : -1;
|
|
28260
|
-
if (best === void 0 || depth > bestDepth) {
|
|
28261
|
-
best = root;
|
|
28262
|
-
bestDepth = depth;
|
|
28263
|
-
}
|
|
28264
|
-
}
|
|
28265
|
-
if (best !== void 0) return best;
|
|
28266
|
-
const projectName = projectPath.slice(projectPath.lastIndexOf("/") + 1);
|
|
28267
|
-
const byBasename = gradleRoots.filter((root) => root.slice(root.lastIndexOf("/") + 1) === projectName);
|
|
28268
|
-
return byBasename.length === 1 ? byBasename[0] : void 0;
|
|
28269
|
-
}
|
|
28270
27939
|
|
|
28271
27940
|
// ../server/src/prLinks.ts
|
|
28272
|
-
var LINKS_VERSION =
|
|
28273
|
-
var languageSchema = external_exports.enum([
|
|
28274
|
-
"typescript",
|
|
28275
|
-
"javascript",
|
|
28276
|
-
"python",
|
|
28277
|
-
"css",
|
|
28278
|
-
"go",
|
|
28279
|
-
"java",
|
|
28280
|
-
"kotlin",
|
|
28281
|
-
"c",
|
|
28282
|
-
"cpp",
|
|
28283
|
-
"rust",
|
|
28284
|
-
"ruby",
|
|
28285
|
-
"vue",
|
|
28286
|
-
"svelte",
|
|
28287
|
-
"markdown"
|
|
28288
|
-
]).nullable();
|
|
27941
|
+
var LINKS_VERSION = 7;
|
|
28289
27942
|
var cachedSchema = external_exports.object({
|
|
28290
27943
|
edges: external_exports.array(
|
|
28291
27944
|
external_exports.object({
|
|
@@ -28295,7 +27948,7 @@ var cachedSchema = external_exports.object({
|
|
|
28295
27948
|
detail: external_exports.array(external_exports.string())
|
|
28296
27949
|
})
|
|
28297
27950
|
),
|
|
28298
|
-
languages: external_exports.record(external_exports.string(),
|
|
27951
|
+
languages: external_exports.record(external_exports.string(), external_exports.string().nullable()),
|
|
28299
27952
|
externalImports: external_exports.record(external_exports.string(), external_exports.number()),
|
|
28300
27953
|
packageImports: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
|
|
28301
27954
|
files: external_exports.array(external_exports.object({ path: external_exports.string(), status: external_exports.enum(["added", "deleted", "modified", "renamed"]) })),
|
|
@@ -28304,7 +27957,7 @@ var cachedSchema = external_exports.object({
|
|
|
28304
27957
|
external_exports.object({
|
|
28305
27958
|
root: external_exports.string(),
|
|
28306
27959
|
name: external_exports.string(),
|
|
28307
|
-
ecosystem: external_exports.
|
|
27960
|
+
ecosystem: external_exports.string(),
|
|
28308
27961
|
files: external_exports.array(external_exports.string()),
|
|
28309
27962
|
dependsOn: external_exports.array(external_exports.string()),
|
|
28310
27963
|
usedBy: external_exports.array(external_exports.string())
|
|
@@ -28314,7 +27967,7 @@ var cachedSchema = external_exports.object({
|
|
|
28314
27967
|
external_exports.object({
|
|
28315
27968
|
root: external_exports.string(),
|
|
28316
27969
|
name: external_exports.string(),
|
|
28317
|
-
ecosystem: external_exports.
|
|
27970
|
+
ecosystem: external_exports.string(),
|
|
28318
27971
|
touched: external_exports.boolean()
|
|
28319
27972
|
})
|
|
28320
27973
|
),
|
|
@@ -28330,49 +27983,10 @@ async function manifestPaths(gh, store, ref, head) {
|
|
|
28330
27983
|
const tree = await gh.rest(
|
|
28331
27984
|
`/repos/${ref.owner}/${ref.repo}/git/trees/${head}?recursive=1`
|
|
28332
27985
|
);
|
|
28333
|
-
const paths = tree.tree.filter((t2) => t2.type === "blob" && isManifestPath(t2.path)).map((t2) => t2.path);
|
|
27986
|
+
const paths = tree.tree.filter((t2) => t2.type === "blob" && isManifestPath(t2.path, ecosystems)).map((t2) => t2.path);
|
|
28334
27987
|
store.putDiff(key, JSON.stringify(paths));
|
|
28335
27988
|
return paths;
|
|
28336
27989
|
}
|
|
28337
|
-
var SRC_EXTENSIONS = [".ts", ".tsx", ".mts", ".js", ".jsx"];
|
|
28338
|
-
function exportTargets(value) {
|
|
28339
|
-
if (typeof value === "string") return [value];
|
|
28340
|
-
if (!value || typeof value !== "object") return [];
|
|
28341
|
-
const entries = Object.entries(value);
|
|
28342
|
-
const root = entries.find(([k]) => k === ".");
|
|
28343
|
-
const ordered = root ? [root] : entries.filter(([k]) => !k.startsWith("./"));
|
|
28344
|
-
return ordered.flatMap(([, v]) => exportTargets(v));
|
|
28345
|
-
}
|
|
28346
|
-
function entryCandidates(pkg, manifestText) {
|
|
28347
|
-
const join5 = (rel) => {
|
|
28348
|
-
const clean = rel.replace(/^\.\//, "");
|
|
28349
|
-
return pkg.root ? `${pkg.root}/${clean}` : clean;
|
|
28350
|
-
};
|
|
28351
|
-
const out = [];
|
|
28352
|
-
if (pkg.ecosystem === "npm" && manifestText) {
|
|
28353
|
-
let manifest = null;
|
|
28354
|
-
try {
|
|
28355
|
-
manifest = JSON.parse(manifestText);
|
|
28356
|
-
} catch {
|
|
28357
|
-
}
|
|
28358
|
-
if (manifest && typeof manifest === "object") {
|
|
28359
|
-
const fields = ["exports", "module", "main", "types", "typings"];
|
|
28360
|
-
for (const field of fields) {
|
|
28361
|
-
if (!(field in manifest)) continue;
|
|
28362
|
-
const value = Reflect.get(manifest, field);
|
|
28363
|
-
for (const target of exportTargets(value)) {
|
|
28364
|
-
out.push(join5(target));
|
|
28365
|
-
const source = target.replace(/^\.?\/?(dist|build|lib|out)\//, "src/").replace(/(\.d)?\.(m|c)?[jt]sx?$/, "");
|
|
28366
|
-
if (source !== target) for (const ext of SRC_EXTENSIONS) out.push(join5(source + ext));
|
|
28367
|
-
}
|
|
28368
|
-
}
|
|
28369
|
-
}
|
|
28370
|
-
for (const base of ["src/index", "index", "src/main"])
|
|
28371
|
-
for (const ext of SRC_EXTENSIONS) out.push(join5(base + ext));
|
|
28372
|
-
}
|
|
28373
|
-
if (pkg.ecosystem === "rust") out.push(join5("src/lib.rs"), join5("src/main.rs"));
|
|
28374
|
-
return [...new Set(out)];
|
|
28375
|
-
}
|
|
28376
27990
|
async function loadWorkspace(gh, store, ref, head) {
|
|
28377
27991
|
const manifests = await manifestPaths(gh, store, ref, head);
|
|
28378
27992
|
const dirs = new Set(manifests.map((p) => p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : ""));
|
|
@@ -28383,11 +27997,14 @@ async function loadWorkspace(gh, store, ref, head) {
|
|
|
28383
27997
|
manifests.map((path) => `${head}:${path}`)
|
|
28384
27998
|
);
|
|
28385
27999
|
const textOf = (path) => texts.get(`${head}:${path}`) ?? null;
|
|
28386
|
-
const packages = parseWorkspace(
|
|
28000
|
+
const packages = parseWorkspace(
|
|
28001
|
+
manifests.map((path) => ({ path, text: textOf(path) })),
|
|
28002
|
+
ecosystems
|
|
28003
|
+
);
|
|
28387
28004
|
const refs = packages.map((p) => ({
|
|
28388
28005
|
name: p.name,
|
|
28389
28006
|
root: p.root,
|
|
28390
|
-
entries: entryCandidates(p, textOf(p.manifest))
|
|
28007
|
+
entries: ecosystems.find((e) => e.id === p.ecosystem)?.entryCandidates(p.root, textOf(p.manifest)) ?? []
|
|
28391
28008
|
}));
|
|
28392
28009
|
return { packages, refs };
|
|
28393
28010
|
}
|
|
@@ -28446,26 +28063,76 @@ async function loadLinks(gh, store, ref, base, head, fullPr) {
|
|
|
28446
28063
|
if (parsed.success) return parsed.data;
|
|
28447
28064
|
}
|
|
28448
28065
|
const diff = await loadDiff(gh, store, ref, base, head, fullPr);
|
|
28449
|
-
const
|
|
28066
|
+
const analysed = diff.files.filter((f) => languages.detect(f.path) !== null);
|
|
28450
28067
|
const expression = (f) => f.status === "deleted" ? `${base}:${f.oldPath}` : `${head}:${f.path}`;
|
|
28451
|
-
const texts = await fetchTexts(gh, ref,
|
|
28452
|
-
const
|
|
28453
|
-
|
|
28454
|
-
text: f.binary ? null : texts.get(expression(f)) ?? null
|
|
28455
|
-
}));
|
|
28068
|
+
const texts = await fetchTexts(gh, ref, analysed.filter((f) => !f.binary).map(expression));
|
|
28069
|
+
const textOf = (f) => f.binary ? null : texts.get(expression(f)) ?? null;
|
|
28070
|
+
const sources = diff.files.map((f) => ({ path: f.path, text: textOf(f) }));
|
|
28456
28071
|
const workspace = await loadWorkspace(gh, store, ref, head);
|
|
28457
|
-
const graph = buildLinkGraph(sources, workspace ? { packages: workspace.refs } : void 0);
|
|
28072
|
+
const graph = buildLinkGraph(sources, languages, workspace ? { packages: workspace.refs } : void 0);
|
|
28458
28073
|
const paths = diff.files.map((f) => f.path);
|
|
28459
28074
|
const links = {
|
|
28460
28075
|
...graph,
|
|
28461
28076
|
files: diff.files.map((f) => ({ path: f.path, status: f.status })),
|
|
28462
|
-
unreadable:
|
|
28077
|
+
unreadable: analysed.filter((f) => textOf(f) === null).map((f) => f.path),
|
|
28463
28078
|
...workspace ? orderPackages(workspace.packages, paths, graph.edges) : { packages: [], workspace: [], packageEdges: [] }
|
|
28464
28079
|
};
|
|
28465
28080
|
store.putDiff(cacheKey2, JSON.stringify(links));
|
|
28466
28081
|
return links;
|
|
28467
28082
|
}
|
|
28468
28083
|
|
|
28084
|
+
// ../server/src/poll.ts
|
|
28085
|
+
function sleep(ms, signal) {
|
|
28086
|
+
const { promise: promise2, resolve } = Promise.withResolvers();
|
|
28087
|
+
const timer = setTimeout(resolve, ms);
|
|
28088
|
+
signal?.addEventListener(
|
|
28089
|
+
"abort",
|
|
28090
|
+
() => {
|
|
28091
|
+
clearTimeout(timer);
|
|
28092
|
+
resolve();
|
|
28093
|
+
},
|
|
28094
|
+
{ once: true }
|
|
28095
|
+
);
|
|
28096
|
+
return promise2;
|
|
28097
|
+
}
|
|
28098
|
+
async function* pollChanges(intervalMs, signal, fingerprint, extraTrigger) {
|
|
28099
|
+
let last = null;
|
|
28100
|
+
try {
|
|
28101
|
+
last = await fingerprint();
|
|
28102
|
+
} catch (error62) {
|
|
28103
|
+
console.warn("[poll]", error62 instanceof Error ? error62.message : error62);
|
|
28104
|
+
}
|
|
28105
|
+
const triggerIt = extraTrigger?.[Symbol.asyncIterator]();
|
|
28106
|
+
const nextTrigger = () => {
|
|
28107
|
+
const promise2 = triggerIt?.next();
|
|
28108
|
+
promise2?.catch(() => void 0);
|
|
28109
|
+
return promise2;
|
|
28110
|
+
};
|
|
28111
|
+
let pendingTrigger = signal?.aborted ? void 0 : nextTrigger();
|
|
28112
|
+
try {
|
|
28113
|
+
while (!signal?.aborted) {
|
|
28114
|
+
const tick = sleep(intervalMs, signal).then(() => "tick");
|
|
28115
|
+
const winner = pendingTrigger ? await Promise.race([tick, pendingTrigger.then(() => "trigger")]) : await tick;
|
|
28116
|
+
if (signal?.aborted) return;
|
|
28117
|
+
if (winner === "trigger") {
|
|
28118
|
+
pendingTrigger = nextTrigger();
|
|
28119
|
+
last = null;
|
|
28120
|
+
yield { at: Date.now() };
|
|
28121
|
+
continue;
|
|
28122
|
+
}
|
|
28123
|
+
try {
|
|
28124
|
+
const next = await fingerprint();
|
|
28125
|
+
if (last !== null && next !== last) yield { at: Date.now() };
|
|
28126
|
+
last = next;
|
|
28127
|
+
} catch (error62) {
|
|
28128
|
+
console.warn("[poll]", error62 instanceof Error ? error62.message : error62);
|
|
28129
|
+
}
|
|
28130
|
+
}
|
|
28131
|
+
} finally {
|
|
28132
|
+
await triggerIt?.return?.().catch(() => void 0);
|
|
28133
|
+
}
|
|
28134
|
+
}
|
|
28135
|
+
|
|
28469
28136
|
// ../../node_modules/.pnpm/@trpc+server@11.19.0_typescript@6.0.3/node_modules/@trpc/server/dist/initTRPC-B259os3T.mjs
|
|
28470
28137
|
var middlewareMarker = "middlewareMarker";
|
|
28471
28138
|
function createMiddlewareFactory() {
|
|
@@ -28811,51 +28478,10 @@ var procedure = t.procedure.use(githubErrors);
|
|
|
28811
28478
|
|
|
28812
28479
|
// ../server/src/router.ts
|
|
28813
28480
|
var PR_POLL_MS = 3e4;
|
|
28814
|
-
var INBOX_POLL_MS =
|
|
28481
|
+
var INBOX_POLL_MS = 6e4;
|
|
28815
28482
|
async function viewer(ctx) {
|
|
28816
28483
|
return (await ctx.gh.graphql("{ viewer { login avatarUrl } }")).viewer;
|
|
28817
28484
|
}
|
|
28818
|
-
function sleep(ms, signal) {
|
|
28819
|
-
const { promise: promise2, resolve } = Promise.withResolvers();
|
|
28820
|
-
const timer = setTimeout(resolve, ms);
|
|
28821
|
-
signal?.addEventListener(
|
|
28822
|
-
"abort",
|
|
28823
|
-
() => {
|
|
28824
|
-
clearTimeout(timer);
|
|
28825
|
-
resolve();
|
|
28826
|
-
},
|
|
28827
|
-
{ once: true }
|
|
28828
|
-
);
|
|
28829
|
-
return promise2;
|
|
28830
|
-
}
|
|
28831
|
-
async function* pollChanges(intervalMs, signal, fingerprint, extraTrigger) {
|
|
28832
|
-
let last = null;
|
|
28833
|
-
try {
|
|
28834
|
-
last = await fingerprint();
|
|
28835
|
-
} catch (error62) {
|
|
28836
|
-
console.warn("[poll]", error62 instanceof Error ? error62.message : error62);
|
|
28837
|
-
}
|
|
28838
|
-
const triggerIt = extraTrigger?.[Symbol.asyncIterator]();
|
|
28839
|
-
let pendingTrigger = triggerIt?.next();
|
|
28840
|
-
while (!signal?.aborted) {
|
|
28841
|
-
const tick = sleep(intervalMs, signal).then(() => "tick");
|
|
28842
|
-
const winner = pendingTrigger ? await Promise.race([tick, pendingTrigger.then(() => "trigger")]) : await tick;
|
|
28843
|
-
if (signal?.aborted) return;
|
|
28844
|
-
if (winner === "trigger") {
|
|
28845
|
-
pendingTrigger = triggerIt?.next();
|
|
28846
|
-
last = null;
|
|
28847
|
-
yield { at: Date.now() };
|
|
28848
|
-
continue;
|
|
28849
|
-
}
|
|
28850
|
-
try {
|
|
28851
|
-
const next = await fingerprint();
|
|
28852
|
-
if (last !== null && next !== last) yield { at: Date.now() };
|
|
28853
|
-
last = next;
|
|
28854
|
-
} catch (error62) {
|
|
28855
|
-
console.warn("[poll]", error62 instanceof Error ? error62.message : error62);
|
|
28856
|
-
}
|
|
28857
|
-
}
|
|
28858
|
-
}
|
|
28859
28485
|
var configRouter = router({
|
|
28860
28486
|
get: procedure.query(({ ctx }) => ctx.config.get()),
|
|
28861
28487
|
add: procedure.input(trackedEntrySchema).mutation(async ({ ctx, input: input2 }) => {
|
|
@@ -28885,6 +28511,8 @@ var inboxRouter = router({
|
|
|
28885
28511
|
});
|
|
28886
28512
|
var prRouter = router({
|
|
28887
28513
|
get: procedure.input(prRefSchema).query(({ ctx, input: input2 }) => loadPr(ctx.gh, ctx.store, input2)),
|
|
28514
|
+
/** Polled by the PR page while checks run. */
|
|
28515
|
+
checks: procedure.input(prRefSchema).query(({ ctx, input: input2 }) => loadChecks(ctx.gh, input2)),
|
|
28888
28516
|
diff: procedure.input(external_exports.object({ ref: prRefSchema, base: shaSchema, head: shaSchema, fullPr: external_exports.boolean() })).query(({ ctx, input: input2 }) => loadDiff(ctx.gh, ctx.store, input2.ref, input2.base, input2.head, input2.fullPr)),
|
|
28889
28517
|
links: procedure.input(external_exports.object({ ref: prRefSchema, base: shaSchema, head: shaSchema, fullPr: external_exports.boolean() })).query(({ ctx, input: input2 }) => loadLinks(ctx.gh, ctx.store, input2.ref, input2.base, input2.head, input2.fullPr)),
|
|
28890
28518
|
blobs: procedure.input(external_exports.object({ ref: prRefSchema, oids: external_exports.array(shaSchema).min(1).max(2) })).query(({ ctx, input: input2 }) => loadBlobs(ctx.gh, ctx.store, input2.ref, input2.oids)),
|
|
@@ -28925,6 +28553,7 @@ var prRouter = router({
|
|
|
28925
28553
|
({ ctx, input: input2 }) => replyToThread(ctx.gh, input2.threadId, input2.body, input2.pendingReviewId)
|
|
28926
28554
|
),
|
|
28927
28555
|
setResolved: procedure.input(external_exports.object({ threadId: external_exports.string(), resolved: external_exports.boolean() })).mutation(({ ctx, input: input2 }) => setThreadResolved(ctx.gh, input2.threadId, input2.resolved)),
|
|
28556
|
+
react: procedure.input(external_exports.object({ subjectId: external_exports.string(), content: reactionContentSchema, on: external_exports.boolean() })).mutation(({ ctx, input: input2 }) => setReaction(ctx.gh, input2.subjectId, input2.content, input2.on)),
|
|
28928
28557
|
addThread: procedure.input(
|
|
28929
28558
|
external_exports.object({
|
|
28930
28559
|
prId: external_exports.string(),
|
|
@@ -29023,8 +28652,11 @@ function createApp(options) {
|
|
|
29023
28652
|
);
|
|
29024
28653
|
if (options.webDist && existsSync2(options.webDist)) {
|
|
29025
28654
|
const root = relative(process.cwd(), options.webDist);
|
|
29026
|
-
|
|
29027
|
-
|
|
28655
|
+
const onFound = (path, c) => {
|
|
28656
|
+
if (path.endsWith("index.html")) c.header("Cache-Control", "no-cache");
|
|
28657
|
+
};
|
|
28658
|
+
app.use("/*", serveStatic({ root, onFound }));
|
|
28659
|
+
app.get("*", serveStatic({ root, rewriteRequestPath: () => "/index.html", onFound }));
|
|
29028
28660
|
}
|
|
29029
28661
|
return app;
|
|
29030
28662
|
}
|
|
@@ -29088,11 +28720,11 @@ var ConfigStore = class extends EventEmitter {
|
|
|
29088
28720
|
}
|
|
29089
28721
|
}
|
|
29090
28722
|
#write(next) {
|
|
29091
|
-
const
|
|
28723
|
+
const text2 = JSON.stringify(next, null, 2) + "\n";
|
|
29092
28724
|
const tmp = this.path + ".tmp";
|
|
29093
|
-
writeFileSync(tmp,
|
|
28725
|
+
writeFileSync(tmp, text2);
|
|
29094
28726
|
renameSync(tmp, this.path);
|
|
29095
|
-
this.#lastWritten =
|
|
28727
|
+
this.#lastWritten = text2;
|
|
29096
28728
|
this.#config = next;
|
|
29097
28729
|
this.emit("change", next);
|
|
29098
28730
|
return next;
|