@opentig/cli 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1 -1
- package/dist/chunks/{cli-D_aggpu2.mjs → cli-DCPhUVBb.mjs} +1 -1
- package/dist/client/assets/App-CGiS2z40.js +74 -0
- package/dist/client/assets/CreatePullRequestDialog-dNbTTo9i.js +2 -0
- package/dist/client/assets/{DiffWorkspace-CeYQ0YtE.js → DiffWorkspace-XS025gbZ.js} +1 -1
- package/dist/client/assets/{EditableFileViewer-BhwE-QMO.js → EditableFileViewer-Cve4V9RS.js} +1 -1
- package/dist/client/assets/{File-C10_BxOu.js → File-BJuBDans.js} +1 -1
- package/dist/client/assets/{FilesView-BT4eHbFo.js → FilesView-BUAz46Qa.js} +1 -1
- package/dist/client/assets/GitHubAvatar-Depnd_JA.js +1 -0
- package/dist/client/assets/HistoryView-Dd4Kr4KN.js +1 -0
- package/dist/client/assets/{HtmlFileViewer-Cufzaec9.js → HtmlFileViewer-C3Qylr9B.js} +1 -1
- package/dist/client/assets/{IconEdit-RxH71_V-.js → IconEdit-BHqlqze_.js} +1 -1
- package/dist/client/assets/{IconFolderPlus-DSSB-ikf.js → IconFolderPlus-BJIo1hfe.js} +1 -1
- package/dist/client/assets/{ImageFileViewer-CFUkcXLH.js → ImageFileViewer-BJy0ptmR.js} +1 -1
- package/dist/client/assets/{LocalRefsDialog-B2jUCKTx.js → LocalRefsDialog-C1MWMkv1.js} +1 -1
- package/dist/client/assets/{MarkdownFileViewer-BLfJ-Vof.js → MarkdownFileViewer-pagMxv2y.js} +2 -2
- package/dist/client/assets/{PairingPage-C5Ggk-Z_.js → PairingPage-DOPAXy3a.js} +1 -1
- package/dist/client/assets/{PierreDiffViewer-DYj1ZThr.js → PierreDiffViewer-FmgbHdls.js} +1 -1
- package/dist/client/assets/PierreEditBoundary-mxtF7x3F.js +2 -0
- package/dist/client/assets/{PierreWorkerPool-7EVoquIB.js → PierreWorkerPool-B_NFnwU-.js} +9 -9
- package/dist/client/assets/{PullRequestDiff-DxLTcm6L.js → PullRequestDiff-Bcu8Gmrf.js} +1 -1
- package/dist/client/assets/PullRequestViewer-oeDoq-3g.js +2 -0
- package/dist/client/assets/PullRequestsView-DpTtagTX.js +1 -0
- package/dist/client/assets/{QuickOpenDialog-CasQU7pk.js → QuickOpenDialog-rjeV0l_J.js} +1 -1
- package/dist/client/assets/RepositoryProjectsDialog-QYXEt7Lg.js +1 -0
- package/dist/client/assets/SearchView-C-c6oCil.js +1 -0
- package/dist/client/assets/SettingsDialog-DHmWkKYV.js +9 -0
- package/dist/client/assets/Viewer-B6qUr83C.js +3 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-DrlQwm7W.js → abnfDiagram-N423BO3Z-BxGW6tGd.js} +1 -1
- package/dist/client/assets/{arc-B9cXI-QL.js → arc-CphVLv_F.js} +1 -1
- package/dist/client/assets/{architectureDiagram-T3A2C74G-DZz7ZXbI.js → architectureDiagram-T3A2C74G-D9IDzZ6u.js} +1 -1
- package/dist/client/assets/base-ui-DT3JsyND.js +1 -0
- package/dist/client/assets/{blockDiagram-VBNYF7ZC-DZFMT63B.js → blockDiagram-VBNYF7ZC-CzCatff9.js} +1 -1
- package/dist/client/assets/{c4Diagram-5PPSVZJV-BnHIZMZp.js → c4Diagram-5PPSVZJV-jvC7ACDE.js} +1 -1
- package/dist/client/assets/channel-BGbncBYv.js +1 -0
- package/dist/client/assets/{checkbox-BpmQTxn7.js → checkbox-DDpujnre.js} +1 -1
- package/dist/client/assets/{chunk-2GRJ4B5K-CJOlpI9g.js → chunk-2GRJ4B5K-CNRn3w2y.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-DhsnoUrJ.js → chunk-2Q5K7J3B-CnTjXDS8.js} +1 -1
- package/dist/client/assets/{chunk-5RXB4S5H-Nwsk3OIu.js → chunk-5RXB4S5H-8QZZSU3J.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-Dk9FYU9b.js → chunk-5VM5RSS4-B2MFN1L0.js} +1 -1
- package/dist/client/assets/{chunk-6Q2QTUOP-C8lX8T87.js → chunk-6Q2QTUOP-BRGuFKSr.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-DWHvTG6c.js → chunk-GF5L2VYU-CWTKyD7U.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-BLu2-FJl.js → chunk-JWPE2WC7-rGurufZY.js} +1 -1
- package/dist/client/assets/{chunk-KBJHAD2P-CEOb10I1.js → chunk-KBJHAD2P-DOwIHyo0.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-BcdMrb_e.js → chunk-RYQCIY6F-qrVd0AV3.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-CzPimvfs.js → chunk-XXDRQBXY-BGvaybJK.js} +1 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-BoYriqPM.js +1 -0
- package/dist/client/assets/classDiagram-v2-OCEON4UE-BoYriqPM.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-BYfzHUkR.js → cose-bilkent-JH36ORCC-CHgOt-vq.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-B4mEAleX.js → cynefin-VYW2F7L2-DX7Kb3Ft.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-CioMvT6V.js → cynefinDiagram-MW4NZA55-B4MgYgbV.js} +1 -1
- package/dist/client/assets/{dagre-VZM6K2ZE-DWPgHi5i.js → dagre-VZM6K2ZE-xG9l95NU.js} +1 -1
- package/dist/client/assets/{diagram-7IWD3JNH-94i9EwB_.js → diagram-7IWD3JNH-BQKb8ivh.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-BRgMOgy8.js → diagram-B4RE2ZJO-CyIMrtDr.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-DHaXTl1T.js → diagram-LBJQPF4R-WuCMu4WW.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-DtLuyYm1.js → diagram-Q27KOJAE--Oi1nRrR.js} +1 -1
- package/dist/client/assets/{diagram-UB23O5K3-D8R3grCW.js → diagram-UB23O5K3-CP1DXsa_.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-voe5GU7W.js → ebnfDiagram-BXEA7PRR-C-7jJg9C.js} +1 -1
- package/dist/client/assets/{erDiagram-JOGREHBK-BShMJhmY.js → erDiagram-JOGREHBK-FSyqgO_9.js} +1 -1
- package/dist/client/assets/{flowDiagram-UKHOOZJN-DASXB2wV.js → flowDiagram-UKHOOZJN-y2e2HZHu.js} +1 -1
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-Da1ElnJN.js → ganttDiagram-PKOTCBZU-kZ3m3wwW.js} +1 -1
- package/dist/client/assets/{gh-utils-D00lyruw.js → gh-utils-DxPHIkD8.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-DoGRli0p.js → gitGraphDiagram-DS77QQ5N-3Z9e4WPi.js} +1 -1
- package/dist/client/assets/index-ChKJF4C_.js +47 -0
- package/dist/client/assets/index-WwGOu_aM.css +1 -0
- package/dist/client/assets/{infoDiagram-6WML65LV-CxkxF5pn.js → infoDiagram-6WML65LV-TfCo0Rhw.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-l6dk2-PS.js → ishikawaDiagram-WSZJBQD7-DaXI89rw.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-wJY4ZF5o.js → journeyDiagram-NVQOT4AX-C4jS6BVn.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-CIcwUmJo.js → kanban-definition-27J2QSJJ-bwOtQiC8.js} +1 -1
- package/dist/client/assets/{linear-Tf-dXwQ9.js → linear-DfZM9J6Z.js} +1 -1
- package/dist/client/assets/{mermaid.core-DnaJSnLe.js → mermaid.core-B-iLnCqi.js} +4 -4
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-jFdJ2bLh.js → mindmap-definition-FAOFIHXS-DAdKdypB.js} +1 -1
- package/dist/client/assets/{pegDiagram-VL7TDLO6-vq0WE66k.js → pegDiagram-VL7TDLO6-Bl95_ELH.js} +1 -1
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-3edKDMpI.js → pieDiagram-7S7Q4E2Y-DXf4GTLI.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-B6M8U4XV.js → quadrantDiagram-CIZ2JOQS-CDiwouFY.js} +1 -1
- package/dist/client/assets/{railroadDiagram-AXF67PYL-C-d5-0YS.js → railroadDiagram-AXF67PYL-CZAR7rja.js} +1 -1
- package/dist/client/assets/{render-markdown-GXIpf9CM.js → render-markdown-BiKX2Zdv.js} +1 -1
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-FVzmEbFu.js → requirementDiagram-LRYGKXZP-BklWtcnl.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-B-qcUamt.js → sankeyDiagram-W5VNT64P-CpD7cM5j.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-DgFXRLSt.js → sequenceDiagram-SI44F4Z6-BnHPNl9l.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-CWi_pMb2.js → sizeCapture-X5ZJPWSS-D1eo0r-2.js} +1 -1
- package/dist/client/assets/{stateDiagram-OKZ733FA-amQwzlgU.js → stateDiagram-OKZ733FA-ClTacl-d.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-DAo7Tfh9.js +1 -0
- package/dist/client/assets/{swimlanes-SLNWSIFB-L88WlaUb.js → swimlanes-SLNWSIFB-_PLbkM5u.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-DHeOpgR_.js +8 -0
- package/dist/client/assets/{tanstack-Bsd5UOY4.js → tanstack-CtfgE41X.js} +1 -1
- package/dist/client/assets/{timeline-definition-Z64GVDOM-D4TJxxc3.js → timeline-definition-Z64GVDOM-C9U6VikV.js} +1 -1
- package/dist/client/assets/{vennDiagram-T6HMQDX7-ClJWOyzQ.js → vennDiagram-T6HMQDX7-Desj7KFU.js} +1 -1
- package/dist/client/assets/{viewer-tabs-Cp_MC_J3.js → viewer-tabs-BwMhis6Q.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-Cxfjpd6V.js → wardleyDiagram-T6FBY63Y-rlMEd5tV.js} +1 -1
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-BYqbTvmt.js → xychartDiagram-ELKLHX3M-CzFgA0NM.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/dev.mjs +1 -1
- package/dist/manifest.json +1 -1
- package/dist/server.mjs +560 -215
- package/package.json +1 -1
- package/dist/client/assets/App-CeDVj5Hh.js +0 -118
- package/dist/client/assets/CreatePullRequestDialog-DMHY_u8X.js +0 -2
- package/dist/client/assets/GitHubAvatar-Ch_PaCv3.js +0 -1
- package/dist/client/assets/HistoryView-CivGwdxV.js +0 -1
- package/dist/client/assets/PierreEditBoundary-UfvbKDbd.js +0 -2
- package/dist/client/assets/PullRequestViewer-CyW39MuF.js +0 -2
- package/dist/client/assets/PullRequestsView-BHcnarLS.js +0 -1
- package/dist/client/assets/RepositoryProjectsDialog-VAiZrDlA.js +0 -1
- package/dist/client/assets/SearchView-Bv4bA4UJ.js +0 -1
- package/dist/client/assets/SettingsDialog-D33V9Fry.js +0 -9
- package/dist/client/assets/Viewer-I1lC_oJU.js +0 -3
- package/dist/client/assets/base-ui-D4MeJpa3.js +0 -1
- package/dist/client/assets/channel-CE-pdA-6.js +0 -1
- package/dist/client/assets/classDiagram-JCYQIIEL-2elbt6qi.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-2elbt6qi.js +0 -1
- package/dist/client/assets/index-BdjG_WtS.js +0 -3
- package/dist/client/assets/index-Uku28hIV.css +0 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-TdV8eIV2.js +0 -1
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-AWimqvIC.js +0 -8
package/dist/server.mjs
CHANGED
|
@@ -9098,6 +9098,132 @@ function handleIntersectionResults(result, left, right) {
|
|
|
9098
9098
|
result.value = merged.data;
|
|
9099
9099
|
return result;
|
|
9100
9100
|
}
|
|
9101
|
+
const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
9102
|
+
$ZodType.init(inst, def);
|
|
9103
|
+
inst._zod.parse = (payload, ctx) => {
|
|
9104
|
+
const input = payload.value;
|
|
9105
|
+
if (!isPlainObject(input)) {
|
|
9106
|
+
payload.issues.push({
|
|
9107
|
+
expected: "record",
|
|
9108
|
+
code: "invalid_type",
|
|
9109
|
+
input,
|
|
9110
|
+
inst
|
|
9111
|
+
});
|
|
9112
|
+
return payload;
|
|
9113
|
+
}
|
|
9114
|
+
const proms = [];
|
|
9115
|
+
const values = def.keyType._zod.values;
|
|
9116
|
+
if (values) {
|
|
9117
|
+
payload.value = {};
|
|
9118
|
+
const recordKeys = /* @__PURE__ */ new Set();
|
|
9119
|
+
for (const key of values) {
|
|
9120
|
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
9121
|
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
9122
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
9123
|
+
if (keyResult instanceof Promise) {
|
|
9124
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
9125
|
+
}
|
|
9126
|
+
if (keyResult.issues.length) {
|
|
9127
|
+
payload.issues.push({
|
|
9128
|
+
code: "invalid_key",
|
|
9129
|
+
origin: "record",
|
|
9130
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
9131
|
+
input: key,
|
|
9132
|
+
path: [key],
|
|
9133
|
+
inst
|
|
9134
|
+
});
|
|
9135
|
+
continue;
|
|
9136
|
+
}
|
|
9137
|
+
const outKey = keyResult.value;
|
|
9138
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
9139
|
+
if (result instanceof Promise) {
|
|
9140
|
+
proms.push(result.then((result2) => {
|
|
9141
|
+
if (result2.issues.length) {
|
|
9142
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
9143
|
+
}
|
|
9144
|
+
payload.value[outKey] = result2.value;
|
|
9145
|
+
}));
|
|
9146
|
+
} else {
|
|
9147
|
+
if (result.issues.length) {
|
|
9148
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
9149
|
+
}
|
|
9150
|
+
payload.value[outKey] = result.value;
|
|
9151
|
+
}
|
|
9152
|
+
}
|
|
9153
|
+
}
|
|
9154
|
+
let unrecognized;
|
|
9155
|
+
for (const key in input) {
|
|
9156
|
+
if (!recordKeys.has(key)) {
|
|
9157
|
+
unrecognized = unrecognized ?? [];
|
|
9158
|
+
unrecognized.push(key);
|
|
9159
|
+
}
|
|
9160
|
+
}
|
|
9161
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
9162
|
+
payload.issues.push({
|
|
9163
|
+
code: "unrecognized_keys",
|
|
9164
|
+
input,
|
|
9165
|
+
inst,
|
|
9166
|
+
keys: unrecognized
|
|
9167
|
+
});
|
|
9168
|
+
}
|
|
9169
|
+
} else {
|
|
9170
|
+
payload.value = {};
|
|
9171
|
+
for (const key of Reflect.ownKeys(input)) {
|
|
9172
|
+
if (key === "__proto__")
|
|
9173
|
+
continue;
|
|
9174
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key))
|
|
9175
|
+
continue;
|
|
9176
|
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
9177
|
+
if (keyResult instanceof Promise) {
|
|
9178
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
9179
|
+
}
|
|
9180
|
+
const checkNumericKey = typeof key === "string" && number$1.test(key) && keyResult.issues.length;
|
|
9181
|
+
if (checkNumericKey) {
|
|
9182
|
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
9183
|
+
if (retryResult instanceof Promise) {
|
|
9184
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
9185
|
+
}
|
|
9186
|
+
if (retryResult.issues.length === 0) {
|
|
9187
|
+
keyResult = retryResult;
|
|
9188
|
+
}
|
|
9189
|
+
}
|
|
9190
|
+
if (keyResult.issues.length) {
|
|
9191
|
+
if (def.mode === "loose") {
|
|
9192
|
+
payload.value[key] = input[key];
|
|
9193
|
+
} else {
|
|
9194
|
+
payload.issues.push({
|
|
9195
|
+
code: "invalid_key",
|
|
9196
|
+
origin: "record",
|
|
9197
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
9198
|
+
input: key,
|
|
9199
|
+
path: [key],
|
|
9200
|
+
inst
|
|
9201
|
+
});
|
|
9202
|
+
}
|
|
9203
|
+
continue;
|
|
9204
|
+
}
|
|
9205
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
9206
|
+
if (result instanceof Promise) {
|
|
9207
|
+
proms.push(result.then((result2) => {
|
|
9208
|
+
if (result2.issues.length) {
|
|
9209
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
9210
|
+
}
|
|
9211
|
+
payload.value[keyResult.value] = result2.value;
|
|
9212
|
+
}));
|
|
9213
|
+
} else {
|
|
9214
|
+
if (result.issues.length) {
|
|
9215
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
9216
|
+
}
|
|
9217
|
+
payload.value[keyResult.value] = result.value;
|
|
9218
|
+
}
|
|
9219
|
+
}
|
|
9220
|
+
}
|
|
9221
|
+
if (proms.length) {
|
|
9222
|
+
return Promise.all(proms).then(() => payload);
|
|
9223
|
+
}
|
|
9224
|
+
return payload;
|
|
9225
|
+
};
|
|
9226
|
+
});
|
|
9101
9227
|
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
9102
9228
|
$ZodType.init(inst, def);
|
|
9103
9229
|
const values = getEnumValues(def.entries);
|
|
@@ -10304,29 +10430,29 @@ const formatMap = {
|
|
|
10304
10430
|
// do not set
|
|
10305
10431
|
};
|
|
10306
10432
|
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
10307
|
-
const
|
|
10308
|
-
|
|
10433
|
+
const json2 = _json;
|
|
10434
|
+
json2.type = "string";
|
|
10309
10435
|
const { minimum, maximum, format: format2, patterns, contentEncoding } = schema._zod.bag;
|
|
10310
10436
|
if (typeof minimum === "number")
|
|
10311
|
-
|
|
10437
|
+
json2.minLength = minimum;
|
|
10312
10438
|
if (typeof maximum === "number")
|
|
10313
|
-
|
|
10439
|
+
json2.maxLength = maximum;
|
|
10314
10440
|
if (format2) {
|
|
10315
|
-
|
|
10316
|
-
if (
|
|
10317
|
-
delete
|
|
10441
|
+
json2.format = formatMap[format2] ?? format2;
|
|
10442
|
+
if (json2.format === "")
|
|
10443
|
+
delete json2.format;
|
|
10318
10444
|
if (format2 === "time") {
|
|
10319
|
-
delete
|
|
10445
|
+
delete json2.format;
|
|
10320
10446
|
}
|
|
10321
10447
|
}
|
|
10322
10448
|
if (contentEncoding)
|
|
10323
|
-
|
|
10449
|
+
json2.contentEncoding = contentEncoding;
|
|
10324
10450
|
if (patterns && patterns.size > 0) {
|
|
10325
10451
|
const regexes = [...patterns];
|
|
10326
10452
|
if (regexes.length === 1)
|
|
10327
|
-
|
|
10453
|
+
json2.pattern = regexes[0].source;
|
|
10328
10454
|
else if (regexes.length > 1) {
|
|
10329
|
-
|
|
10455
|
+
json2.allOf = [
|
|
10330
10456
|
...regexes.map((regex) => ({
|
|
10331
10457
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
10332
10458
|
pattern: regex.source
|
|
@@ -10336,40 +10462,40 @@ const stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
10336
10462
|
}
|
|
10337
10463
|
};
|
|
10338
10464
|
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
10339
|
-
const
|
|
10465
|
+
const json2 = _json;
|
|
10340
10466
|
const { minimum, maximum, format: format2, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
10341
10467
|
if (typeof format2 === "string" && format2.includes("int"))
|
|
10342
|
-
|
|
10468
|
+
json2.type = "integer";
|
|
10343
10469
|
else
|
|
10344
|
-
|
|
10470
|
+
json2.type = "number";
|
|
10345
10471
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
10346
10472
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
10347
10473
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
10348
10474
|
if (exMin) {
|
|
10349
10475
|
if (legacy) {
|
|
10350
|
-
|
|
10351
|
-
|
|
10476
|
+
json2.minimum = exclusiveMinimum;
|
|
10477
|
+
json2.exclusiveMinimum = true;
|
|
10352
10478
|
} else {
|
|
10353
|
-
|
|
10479
|
+
json2.exclusiveMinimum = exclusiveMinimum;
|
|
10354
10480
|
}
|
|
10355
10481
|
} else if (typeof minimum === "number") {
|
|
10356
|
-
|
|
10482
|
+
json2.minimum = minimum;
|
|
10357
10483
|
}
|
|
10358
10484
|
if (exMax) {
|
|
10359
10485
|
if (legacy) {
|
|
10360
|
-
|
|
10361
|
-
|
|
10486
|
+
json2.maximum = exclusiveMaximum;
|
|
10487
|
+
json2.exclusiveMaximum = true;
|
|
10362
10488
|
} else {
|
|
10363
|
-
|
|
10489
|
+
json2.exclusiveMaximum = exclusiveMaximum;
|
|
10364
10490
|
}
|
|
10365
10491
|
} else if (typeof maximum === "number") {
|
|
10366
|
-
|
|
10492
|
+
json2.maximum = maximum;
|
|
10367
10493
|
}
|
|
10368
10494
|
if (typeof multipleOf === "number")
|
|
10369
|
-
|
|
10495
|
+
json2.multipleOf = multipleOf;
|
|
10370
10496
|
};
|
|
10371
|
-
const booleanProcessor = (_schema, _ctx,
|
|
10372
|
-
|
|
10497
|
+
const booleanProcessor = (_schema, _ctx, json2, _params) => {
|
|
10498
|
+
json2.type = "boolean";
|
|
10373
10499
|
};
|
|
10374
10500
|
const bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
10375
10501
|
if (ctx.unrepresentable === "throw") {
|
|
@@ -10381,13 +10507,13 @@ const symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
|
10381
10507
|
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
10382
10508
|
}
|
|
10383
10509
|
};
|
|
10384
|
-
const nullProcessor = (_schema, ctx,
|
|
10510
|
+
const nullProcessor = (_schema, ctx, json2, _params) => {
|
|
10385
10511
|
if (ctx.target === "openapi-3.0") {
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10512
|
+
json2.type = "string";
|
|
10513
|
+
json2.nullable = true;
|
|
10514
|
+
json2.enum = [null];
|
|
10389
10515
|
} else {
|
|
10390
|
-
|
|
10516
|
+
json2.type = "null";
|
|
10391
10517
|
}
|
|
10392
10518
|
};
|
|
10393
10519
|
const undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
@@ -10400,8 +10526,8 @@ const voidProcessor = (_schema, ctx, _json, _params) => {
|
|
|
10400
10526
|
throw new Error("Void cannot be represented in JSON Schema");
|
|
10401
10527
|
}
|
|
10402
10528
|
};
|
|
10403
|
-
const neverProcessor = (_schema, _ctx,
|
|
10404
|
-
|
|
10529
|
+
const neverProcessor = (_schema, _ctx, json2, _params) => {
|
|
10530
|
+
json2.not = {};
|
|
10405
10531
|
};
|
|
10406
10532
|
const anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
10407
10533
|
};
|
|
@@ -10412,16 +10538,16 @@ const dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
10412
10538
|
throw new Error("Date cannot be represented in JSON Schema");
|
|
10413
10539
|
}
|
|
10414
10540
|
};
|
|
10415
|
-
const enumProcessor = (schema, _ctx,
|
|
10541
|
+
const enumProcessor = (schema, _ctx, json2, _params) => {
|
|
10416
10542
|
const def = schema._zod.def;
|
|
10417
10543
|
const values = getEnumValues(def.entries);
|
|
10418
10544
|
if (values.every((v) => typeof v === "number"))
|
|
10419
|
-
|
|
10545
|
+
json2.type = "number";
|
|
10420
10546
|
if (values.every((v) => typeof v === "string"))
|
|
10421
|
-
|
|
10422
|
-
|
|
10547
|
+
json2.type = "string";
|
|
10548
|
+
json2.enum = values;
|
|
10423
10549
|
};
|
|
10424
|
-
const literalProcessor = (schema, ctx,
|
|
10550
|
+
const literalProcessor = (schema, ctx, json2, _params) => {
|
|
10425
10551
|
const def = schema._zod.def;
|
|
10426
10552
|
const vals = [];
|
|
10427
10553
|
for (const val of def.values) {
|
|
@@ -10442,22 +10568,22 @@ const literalProcessor = (schema, ctx, json, _params) => {
|
|
|
10442
10568
|
if (vals.length === 0) ;
|
|
10443
10569
|
else if (vals.length === 1) {
|
|
10444
10570
|
const val = vals[0];
|
|
10445
|
-
|
|
10571
|
+
json2.type = val === null ? "null" : typeof val;
|
|
10446
10572
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
10447
|
-
|
|
10573
|
+
json2.enum = [val];
|
|
10448
10574
|
} else {
|
|
10449
|
-
|
|
10575
|
+
json2.const = val;
|
|
10450
10576
|
}
|
|
10451
10577
|
} else {
|
|
10452
10578
|
if (vals.every((v) => typeof v === "number"))
|
|
10453
|
-
|
|
10579
|
+
json2.type = "number";
|
|
10454
10580
|
if (vals.every((v) => typeof v === "string"))
|
|
10455
|
-
|
|
10581
|
+
json2.type = "string";
|
|
10456
10582
|
if (vals.every((v) => typeof v === "boolean"))
|
|
10457
|
-
|
|
10583
|
+
json2.type = "boolean";
|
|
10458
10584
|
if (vals.every((v) => v === null))
|
|
10459
|
-
|
|
10460
|
-
|
|
10585
|
+
json2.type = "null";
|
|
10586
|
+
json2.enum = vals;
|
|
10461
10587
|
}
|
|
10462
10588
|
};
|
|
10463
10589
|
const nanProcessor = (_schema, ctx, _json, _params) => {
|
|
@@ -10465,16 +10591,16 @@ const nanProcessor = (_schema, ctx, _json, _params) => {
|
|
|
10465
10591
|
throw new Error("NaN cannot be represented in JSON Schema");
|
|
10466
10592
|
}
|
|
10467
10593
|
};
|
|
10468
|
-
const templateLiteralProcessor = (schema, _ctx,
|
|
10469
|
-
const _json =
|
|
10594
|
+
const templateLiteralProcessor = (schema, _ctx, json2, _params) => {
|
|
10595
|
+
const _json = json2;
|
|
10470
10596
|
const pattern = schema._zod.pattern;
|
|
10471
10597
|
if (!pattern)
|
|
10472
10598
|
throw new Error("Pattern not found in template literal");
|
|
10473
10599
|
_json.type = "string";
|
|
10474
10600
|
_json.pattern = pattern.source;
|
|
10475
10601
|
};
|
|
10476
|
-
const fileProcessor = (schema, _ctx,
|
|
10477
|
-
const _json =
|
|
10602
|
+
const fileProcessor = (schema, _ctx, json2, _params) => {
|
|
10603
|
+
const _json = json2;
|
|
10478
10604
|
const file = {
|
|
10479
10605
|
type: "string",
|
|
10480
10606
|
format: "binary",
|
|
@@ -10497,8 +10623,8 @@ const fileProcessor = (schema, _ctx, json, _params) => {
|
|
|
10497
10623
|
Object.assign(_json, file);
|
|
10498
10624
|
}
|
|
10499
10625
|
};
|
|
10500
|
-
const successProcessor = (_schema, _ctx,
|
|
10501
|
-
|
|
10626
|
+
const successProcessor = (_schema, _ctx, json2, _params) => {
|
|
10627
|
+
json2.type = "boolean";
|
|
10502
10628
|
};
|
|
10503
10629
|
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
10504
10630
|
if (ctx.unrepresentable === "throw") {
|
|
@@ -10526,27 +10652,27 @@ const setProcessor = (_schema, ctx, _json, _params) => {
|
|
|
10526
10652
|
}
|
|
10527
10653
|
};
|
|
10528
10654
|
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
10529
|
-
const
|
|
10655
|
+
const json2 = _json;
|
|
10530
10656
|
const def = schema._zod.def;
|
|
10531
10657
|
const { minimum, maximum } = schema._zod.bag;
|
|
10532
10658
|
if (typeof minimum === "number")
|
|
10533
|
-
|
|
10659
|
+
json2.minItems = minimum;
|
|
10534
10660
|
if (typeof maximum === "number")
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10661
|
+
json2.maxItems = maximum;
|
|
10662
|
+
json2.type = "array";
|
|
10663
|
+
json2.items = process$1(def.element, ctx, {
|
|
10538
10664
|
...params,
|
|
10539
10665
|
path: [...params.path, "items"]
|
|
10540
10666
|
});
|
|
10541
10667
|
};
|
|
10542
10668
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
10543
|
-
const
|
|
10669
|
+
const json2 = _json;
|
|
10544
10670
|
const def = schema._zod.def;
|
|
10545
|
-
|
|
10546
|
-
|
|
10671
|
+
json2.type = "object";
|
|
10672
|
+
json2.properties = {};
|
|
10547
10673
|
const shape = def.shape;
|
|
10548
10674
|
for (const key in shape) {
|
|
10549
|
-
|
|
10675
|
+
json2.properties[key] = process$1(shape[key], ctx, {
|
|
10550
10676
|
...params,
|
|
10551
10677
|
path: [...params.path, "properties", key]
|
|
10552
10678
|
});
|
|
@@ -10561,21 +10687,21 @@ const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
10561
10687
|
}
|
|
10562
10688
|
}));
|
|
10563
10689
|
if (requiredKeys.size > 0) {
|
|
10564
|
-
|
|
10690
|
+
json2.required = Array.from(requiredKeys);
|
|
10565
10691
|
}
|
|
10566
10692
|
if (def.catchall?._zod.def.type === "never") {
|
|
10567
|
-
|
|
10693
|
+
json2.additionalProperties = false;
|
|
10568
10694
|
} else if (!def.catchall) {
|
|
10569
10695
|
if (ctx.io === "output")
|
|
10570
|
-
|
|
10696
|
+
json2.additionalProperties = false;
|
|
10571
10697
|
} else if (def.catchall) {
|
|
10572
|
-
|
|
10698
|
+
json2.additionalProperties = process$1(def.catchall, ctx, {
|
|
10573
10699
|
...params,
|
|
10574
10700
|
path: [...params.path, "additionalProperties"]
|
|
10575
10701
|
});
|
|
10576
10702
|
}
|
|
10577
10703
|
};
|
|
10578
|
-
const unionProcessor = (schema, ctx,
|
|
10704
|
+
const unionProcessor = (schema, ctx, json2, params) => {
|
|
10579
10705
|
const def = schema._zod.def;
|
|
10580
10706
|
const isExclusive = def.inclusive === false;
|
|
10581
10707
|
const options = def.options.map((x, i2) => process$1(x, ctx, {
|
|
@@ -10583,12 +10709,12 @@ const unionProcessor = (schema, ctx, json, params) => {
|
|
|
10583
10709
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i2]
|
|
10584
10710
|
}));
|
|
10585
10711
|
if (isExclusive) {
|
|
10586
|
-
|
|
10712
|
+
json2.oneOf = options;
|
|
10587
10713
|
} else {
|
|
10588
|
-
|
|
10714
|
+
json2.anyOf = options;
|
|
10589
10715
|
}
|
|
10590
10716
|
};
|
|
10591
|
-
const intersectionProcessor = (schema, ctx,
|
|
10717
|
+
const intersectionProcessor = (schema, ctx, json2, params) => {
|
|
10592
10718
|
const def = schema._zod.def;
|
|
10593
10719
|
const a2 = process$1(def.left, ctx, {
|
|
10594
10720
|
...params,
|
|
@@ -10603,12 +10729,12 @@ const intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
10603
10729
|
...isSimpleIntersection(a2) ? a2.allOf : [a2],
|
|
10604
10730
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
10605
10731
|
];
|
|
10606
|
-
|
|
10732
|
+
json2.allOf = allOf;
|
|
10607
10733
|
};
|
|
10608
10734
|
const tupleProcessor = (schema, ctx, _json, params) => {
|
|
10609
|
-
const
|
|
10735
|
+
const json2 = _json;
|
|
10610
10736
|
const def = schema._zod.def;
|
|
10611
|
-
|
|
10737
|
+
json2.type = "array";
|
|
10612
10738
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
10613
10739
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
10614
10740
|
const prefixItems = def.items.map((x, i2) => process$1(x, ctx, {
|
|
@@ -10620,37 +10746,37 @@ const tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
10620
10746
|
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
10621
10747
|
}) : null;
|
|
10622
10748
|
if (ctx.target === "draft-2020-12") {
|
|
10623
|
-
|
|
10749
|
+
json2.prefixItems = prefixItems;
|
|
10624
10750
|
if (rest) {
|
|
10625
|
-
|
|
10751
|
+
json2.items = rest;
|
|
10626
10752
|
}
|
|
10627
10753
|
} else if (ctx.target === "openapi-3.0") {
|
|
10628
|
-
|
|
10754
|
+
json2.items = {
|
|
10629
10755
|
anyOf: prefixItems
|
|
10630
10756
|
};
|
|
10631
10757
|
if (rest) {
|
|
10632
|
-
|
|
10758
|
+
json2.items.anyOf.push(rest);
|
|
10633
10759
|
}
|
|
10634
|
-
|
|
10760
|
+
json2.minItems = prefixItems.length;
|
|
10635
10761
|
if (!rest) {
|
|
10636
|
-
|
|
10762
|
+
json2.maxItems = prefixItems.length;
|
|
10637
10763
|
}
|
|
10638
10764
|
} else {
|
|
10639
|
-
|
|
10765
|
+
json2.items = prefixItems;
|
|
10640
10766
|
if (rest) {
|
|
10641
|
-
|
|
10767
|
+
json2.additionalItems = rest;
|
|
10642
10768
|
}
|
|
10643
10769
|
}
|
|
10644
10770
|
const { minimum, maximum } = schema._zod.bag;
|
|
10645
10771
|
if (typeof minimum === "number")
|
|
10646
|
-
|
|
10772
|
+
json2.minItems = minimum;
|
|
10647
10773
|
if (typeof maximum === "number")
|
|
10648
|
-
|
|
10774
|
+
json2.maxItems = maximum;
|
|
10649
10775
|
};
|
|
10650
10776
|
const recordProcessor = (schema, ctx, _json, params) => {
|
|
10651
|
-
const
|
|
10777
|
+
const json2 = _json;
|
|
10652
10778
|
const def = schema._zod.def;
|
|
10653
|
-
|
|
10779
|
+
json2.type = "object";
|
|
10654
10780
|
const keyType = def.keyType;
|
|
10655
10781
|
const keyBag = keyType._zod.bag;
|
|
10656
10782
|
const patterns = keyBag?.patterns;
|
|
@@ -10659,18 +10785,18 @@ const recordProcessor = (schema, ctx, _json, params) => {
|
|
|
10659
10785
|
...params,
|
|
10660
10786
|
path: [...params.path, "patternProperties", "*"]
|
|
10661
10787
|
});
|
|
10662
|
-
|
|
10788
|
+
json2.patternProperties = {};
|
|
10663
10789
|
for (const pattern of patterns) {
|
|
10664
|
-
|
|
10790
|
+
json2.patternProperties[pattern.source] = valueSchema;
|
|
10665
10791
|
}
|
|
10666
10792
|
} else {
|
|
10667
10793
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
10668
|
-
|
|
10794
|
+
json2.propertyNames = process$1(def.keyType, ctx, {
|
|
10669
10795
|
...params,
|
|
10670
10796
|
path: [...params.path, "propertyNames"]
|
|
10671
10797
|
});
|
|
10672
10798
|
}
|
|
10673
|
-
|
|
10799
|
+
json2.additionalProperties = process$1(def.valueType, ctx, {
|
|
10674
10800
|
...params,
|
|
10675
10801
|
path: [...params.path, "additionalProperties"]
|
|
10676
10802
|
});
|
|
@@ -10679,19 +10805,19 @@ const recordProcessor = (schema, ctx, _json, params) => {
|
|
|
10679
10805
|
if (keyValues) {
|
|
10680
10806
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
10681
10807
|
if (validKeyValues.length > 0) {
|
|
10682
|
-
|
|
10808
|
+
json2.required = validKeyValues;
|
|
10683
10809
|
}
|
|
10684
10810
|
}
|
|
10685
10811
|
};
|
|
10686
|
-
const nullableProcessor = (schema, ctx,
|
|
10812
|
+
const nullableProcessor = (schema, ctx, json2, params) => {
|
|
10687
10813
|
const def = schema._zod.def;
|
|
10688
10814
|
const inner = process$1(def.innerType, ctx, params);
|
|
10689
10815
|
const seen = ctx.seen.get(schema);
|
|
10690
10816
|
if (ctx.target === "openapi-3.0") {
|
|
10691
10817
|
seen.ref = def.innerType;
|
|
10692
|
-
|
|
10818
|
+
json2.nullable = true;
|
|
10693
10819
|
} else {
|
|
10694
|
-
|
|
10820
|
+
json2.anyOf = [inner, { type: "null" }];
|
|
10695
10821
|
}
|
|
10696
10822
|
};
|
|
10697
10823
|
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -10700,22 +10826,22 @@ const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
|
10700
10826
|
const seen = ctx.seen.get(schema);
|
|
10701
10827
|
seen.ref = def.innerType;
|
|
10702
10828
|
};
|
|
10703
|
-
const defaultProcessor = (schema, ctx,
|
|
10829
|
+
const defaultProcessor = (schema, ctx, json2, params) => {
|
|
10704
10830
|
const def = schema._zod.def;
|
|
10705
10831
|
process$1(def.innerType, ctx, params);
|
|
10706
10832
|
const seen = ctx.seen.get(schema);
|
|
10707
10833
|
seen.ref = def.innerType;
|
|
10708
|
-
|
|
10834
|
+
json2.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
10709
10835
|
};
|
|
10710
|
-
const prefaultProcessor = (schema, ctx,
|
|
10836
|
+
const prefaultProcessor = (schema, ctx, json2, params) => {
|
|
10711
10837
|
const def = schema._zod.def;
|
|
10712
10838
|
process$1(def.innerType, ctx, params);
|
|
10713
10839
|
const seen = ctx.seen.get(schema);
|
|
10714
10840
|
seen.ref = def.innerType;
|
|
10715
10841
|
if (ctx.io === "input")
|
|
10716
|
-
|
|
10842
|
+
json2._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
10717
10843
|
};
|
|
10718
|
-
const catchProcessor = (schema, ctx,
|
|
10844
|
+
const catchProcessor = (schema, ctx, json2, params) => {
|
|
10719
10845
|
const def = schema._zod.def;
|
|
10720
10846
|
process$1(def.innerType, ctx, params);
|
|
10721
10847
|
const seen = ctx.seen.get(schema);
|
|
@@ -10726,7 +10852,7 @@ const catchProcessor = (schema, ctx, json, params) => {
|
|
|
10726
10852
|
} catch {
|
|
10727
10853
|
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
10728
10854
|
}
|
|
10729
|
-
|
|
10855
|
+
json2.default = catchValue;
|
|
10730
10856
|
};
|
|
10731
10857
|
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
10732
10858
|
const def = schema._zod.def;
|
|
@@ -10736,12 +10862,12 @@ const pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
10736
10862
|
const seen = ctx.seen.get(schema);
|
|
10737
10863
|
seen.ref = innerType;
|
|
10738
10864
|
};
|
|
10739
|
-
const readonlyProcessor = (schema, ctx,
|
|
10865
|
+
const readonlyProcessor = (schema, ctx, json2, params) => {
|
|
10740
10866
|
const def = schema._zod.def;
|
|
10741
10867
|
process$1(def.innerType, ctx, params);
|
|
10742
10868
|
const seen = ctx.seen.get(schema);
|
|
10743
10869
|
seen.ref = def.innerType;
|
|
10744
|
-
|
|
10870
|
+
json2.readOnly = true;
|
|
10745
10871
|
};
|
|
10746
10872
|
const promiseProcessor = (schema, ctx, _json, params) => {
|
|
10747
10873
|
const def = schema._zod.def;
|
|
@@ -11082,7 +11208,7 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
11082
11208
|
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
11083
11209
|
$ZodString.init(inst, def);
|
|
11084
11210
|
ZodType.init(inst, def);
|
|
11085
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11211
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => stringProcessor(inst, ctx, json2);
|
|
11086
11212
|
const bag = inst._zod.bag;
|
|
11087
11213
|
inst.format = bag.format ?? null;
|
|
11088
11214
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -11252,7 +11378,7 @@ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
|
11252
11378
|
const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
11253
11379
|
$ZodNumber.init(inst, def);
|
|
11254
11380
|
ZodType.init(inst, def);
|
|
11255
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11381
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => numberProcessor(inst, ctx, json2);
|
|
11256
11382
|
_installLazyMethods(inst, "ZodNumber", {
|
|
11257
11383
|
gt(value, params) {
|
|
11258
11384
|
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
@@ -11320,7 +11446,7 @@ function int(params) {
|
|
|
11320
11446
|
const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
11321
11447
|
$ZodBoolean.init(inst, def);
|
|
11322
11448
|
ZodType.init(inst, def);
|
|
11323
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11449
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => booleanProcessor(inst, ctx, json2);
|
|
11324
11450
|
});
|
|
11325
11451
|
function boolean(params) {
|
|
11326
11452
|
return /* @__PURE__ */ _boolean(ZodBoolean, params);
|
|
@@ -11328,7 +11454,7 @@ function boolean(params) {
|
|
|
11328
11454
|
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
11329
11455
|
$ZodUnknown.init(inst, def);
|
|
11330
11456
|
ZodType.init(inst, def);
|
|
11331
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11457
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => unknownProcessor();
|
|
11332
11458
|
});
|
|
11333
11459
|
function unknown() {
|
|
11334
11460
|
return /* @__PURE__ */ _unknown(ZodUnknown);
|
|
@@ -11336,7 +11462,7 @@ function unknown() {
|
|
|
11336
11462
|
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
11337
11463
|
$ZodNever.init(inst, def);
|
|
11338
11464
|
ZodType.init(inst, def);
|
|
11339
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11465
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => neverProcessor(inst, ctx, json2);
|
|
11340
11466
|
});
|
|
11341
11467
|
function never(params) {
|
|
11342
11468
|
return /* @__PURE__ */ _never(ZodNever, params);
|
|
@@ -11344,7 +11470,7 @@ function never(params) {
|
|
|
11344
11470
|
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
11345
11471
|
$ZodArray.init(inst, def);
|
|
11346
11472
|
ZodType.init(inst, def);
|
|
11347
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11473
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => arrayProcessor(inst, ctx, json2, params);
|
|
11348
11474
|
inst.element = def.element;
|
|
11349
11475
|
_installLazyMethods(inst, "ZodArray", {
|
|
11350
11476
|
min(n2, params) {
|
|
@@ -11370,7 +11496,7 @@ function array(element, params) {
|
|
|
11370
11496
|
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
11371
11497
|
$ZodObjectJIT.init(inst, def);
|
|
11372
11498
|
ZodType.init(inst, def);
|
|
11373
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11499
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => objectProcessor(inst, ctx, json2, params);
|
|
11374
11500
|
defineLazy(inst, "shape", () => {
|
|
11375
11501
|
return def.shape;
|
|
11376
11502
|
});
|
|
@@ -11435,7 +11561,7 @@ function looseObject(shape, params) {
|
|
|
11435
11561
|
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
11436
11562
|
$ZodUnion.init(inst, def);
|
|
11437
11563
|
ZodType.init(inst, def);
|
|
11438
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11564
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
|
|
11439
11565
|
inst.options = def.options;
|
|
11440
11566
|
});
|
|
11441
11567
|
function union(options, params) {
|
|
@@ -11448,7 +11574,7 @@ function union(options, params) {
|
|
|
11448
11574
|
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
11449
11575
|
$ZodIntersection.init(inst, def);
|
|
11450
11576
|
ZodType.init(inst, def);
|
|
11451
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11577
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => intersectionProcessor(inst, ctx, json2, params);
|
|
11452
11578
|
});
|
|
11453
11579
|
function intersection(left, right) {
|
|
11454
11580
|
return new ZodIntersection({
|
|
@@ -11457,10 +11583,33 @@ function intersection(left, right) {
|
|
|
11457
11583
|
right
|
|
11458
11584
|
});
|
|
11459
11585
|
}
|
|
11586
|
+
const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
11587
|
+
$ZodRecord.init(inst, def);
|
|
11588
|
+
ZodType.init(inst, def);
|
|
11589
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => recordProcessor(inst, ctx, json2, params);
|
|
11590
|
+
inst.keyType = def.keyType;
|
|
11591
|
+
inst.valueType = def.valueType;
|
|
11592
|
+
});
|
|
11593
|
+
function record(keyType, valueType, params) {
|
|
11594
|
+
if (!valueType || !valueType._zod) {
|
|
11595
|
+
return new ZodRecord({
|
|
11596
|
+
type: "record",
|
|
11597
|
+
keyType: string(),
|
|
11598
|
+
valueType: keyType,
|
|
11599
|
+
...normalizeParams(valueType)
|
|
11600
|
+
});
|
|
11601
|
+
}
|
|
11602
|
+
return new ZodRecord({
|
|
11603
|
+
type: "record",
|
|
11604
|
+
keyType,
|
|
11605
|
+
valueType,
|
|
11606
|
+
...normalizeParams(params)
|
|
11607
|
+
});
|
|
11608
|
+
}
|
|
11460
11609
|
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
11461
11610
|
$ZodEnum.init(inst, def);
|
|
11462
11611
|
ZodType.init(inst, def);
|
|
11463
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11612
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2);
|
|
11464
11613
|
inst.enum = def.entries;
|
|
11465
11614
|
inst.options = Object.values(def.entries);
|
|
11466
11615
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -11506,7 +11655,7 @@ function _enum(values, params) {
|
|
|
11506
11655
|
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
11507
11656
|
$ZodTransform.init(inst, def);
|
|
11508
11657
|
ZodType.init(inst, def);
|
|
11509
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11658
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => transformProcessor(inst, ctx);
|
|
11510
11659
|
inst._zod.parse = (payload, _ctx) => {
|
|
11511
11660
|
if (_ctx.direction === "backward") {
|
|
11512
11661
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -11546,7 +11695,7 @@ function transform(fn) {
|
|
|
11546
11695
|
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
11547
11696
|
$ZodOptional.init(inst, def);
|
|
11548
11697
|
ZodType.init(inst, def);
|
|
11549
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11698
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
|
|
11550
11699
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11551
11700
|
});
|
|
11552
11701
|
function optional(innerType) {
|
|
@@ -11558,7 +11707,7 @@ function optional(innerType) {
|
|
|
11558
11707
|
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
11559
11708
|
$ZodExactOptional.init(inst, def);
|
|
11560
11709
|
ZodType.init(inst, def);
|
|
11561
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11710
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
|
|
11562
11711
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11563
11712
|
});
|
|
11564
11713
|
function exactOptional(innerType) {
|
|
@@ -11570,7 +11719,7 @@ function exactOptional(innerType) {
|
|
|
11570
11719
|
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
11571
11720
|
$ZodNullable.init(inst, def);
|
|
11572
11721
|
ZodType.init(inst, def);
|
|
11573
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11722
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => nullableProcessor(inst, ctx, json2, params);
|
|
11574
11723
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11575
11724
|
});
|
|
11576
11725
|
function nullable(innerType) {
|
|
@@ -11582,7 +11731,7 @@ function nullable(innerType) {
|
|
|
11582
11731
|
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
11583
11732
|
$ZodDefault.init(inst, def);
|
|
11584
11733
|
ZodType.init(inst, def);
|
|
11585
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11734
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => defaultProcessor(inst, ctx, json2, params);
|
|
11586
11735
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11587
11736
|
inst.removeDefault = inst.unwrap;
|
|
11588
11737
|
});
|
|
@@ -11598,7 +11747,7 @@ function _default(innerType, defaultValue) {
|
|
|
11598
11747
|
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
11599
11748
|
$ZodPrefault.init(inst, def);
|
|
11600
11749
|
ZodType.init(inst, def);
|
|
11601
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11750
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => prefaultProcessor(inst, ctx, json2, params);
|
|
11602
11751
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11603
11752
|
});
|
|
11604
11753
|
function prefault(innerType, defaultValue) {
|
|
@@ -11613,7 +11762,7 @@ function prefault(innerType, defaultValue) {
|
|
|
11613
11762
|
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
11614
11763
|
$ZodNonOptional.init(inst, def);
|
|
11615
11764
|
ZodType.init(inst, def);
|
|
11616
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11765
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => nonoptionalProcessor(inst, ctx, json2, params);
|
|
11617
11766
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11618
11767
|
});
|
|
11619
11768
|
function nonoptional(innerType, params) {
|
|
@@ -11626,7 +11775,7 @@ function nonoptional(innerType, params) {
|
|
|
11626
11775
|
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
11627
11776
|
$ZodCatch.init(inst, def);
|
|
11628
11777
|
ZodType.init(inst, def);
|
|
11629
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11778
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => catchProcessor(inst, ctx, json2, params);
|
|
11630
11779
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11631
11780
|
inst.removeCatch = inst.unwrap;
|
|
11632
11781
|
});
|
|
@@ -11640,7 +11789,7 @@ function _catch(innerType, catchValue) {
|
|
|
11640
11789
|
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
11641
11790
|
$ZodPipe.init(inst, def);
|
|
11642
11791
|
ZodType.init(inst, def);
|
|
11643
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11792
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => pipeProcessor(inst, ctx, json2, params);
|
|
11644
11793
|
inst.in = def.in;
|
|
11645
11794
|
inst.out = def.out;
|
|
11646
11795
|
});
|
|
@@ -11655,7 +11804,7 @@ function pipe(in_, out) {
|
|
|
11655
11804
|
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
11656
11805
|
$ZodReadonly.init(inst, def);
|
|
11657
11806
|
ZodType.init(inst, def);
|
|
11658
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11807
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => readonlyProcessor(inst, ctx, json2, params);
|
|
11659
11808
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
11660
11809
|
});
|
|
11661
11810
|
function readonly(innerType) {
|
|
@@ -11667,7 +11816,7 @@ function readonly(innerType) {
|
|
|
11667
11816
|
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
11668
11817
|
$ZodCustom.init(inst, def);
|
|
11669
11818
|
ZodType.init(inst, def);
|
|
11670
|
-
inst._zod.processJSONSchema = (ctx,
|
|
11819
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx);
|
|
11671
11820
|
});
|
|
11672
11821
|
function refine(fn, _params = {}) {
|
|
11673
11822
|
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
@@ -11884,8 +12033,8 @@ class AiLogStore {
|
|
|
11884
12033
|
}
|
|
11885
12034
|
/** Records one run. Never rejects; failures are dropped on purpose. */
|
|
11886
12035
|
append(entry) {
|
|
11887
|
-
const
|
|
11888
|
-
const normalized = normalizeAiLogEntry(
|
|
12036
|
+
const record2 = { ...entry, id: randomUUID(), at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
12037
|
+
const normalized = normalizeAiLogEntry(record2);
|
|
11889
12038
|
if (!normalized) return;
|
|
11890
12039
|
this.pending = this.pending.then(async () => {
|
|
11891
12040
|
await mkdir(path.dirname(this.filePath), { recursive: true });
|
|
@@ -11990,18 +12139,18 @@ ${parsed.data.body}`.length > 1e4) throw invalidOutput$3();
|
|
|
11990
12139
|
}
|
|
11991
12140
|
function parseCommitSplitProposal(value, stagedPaths) {
|
|
11992
12141
|
if (!value || typeof value !== "object") return { status: "absent" };
|
|
11993
|
-
const
|
|
11994
|
-
if (
|
|
11995
|
-
if (!Array.isArray(
|
|
12142
|
+
const record2 = value;
|
|
12143
|
+
if (record2.commits === void 0 || Array.isArray(record2.commits) && record2.commits.length === 0) return { status: "absent" };
|
|
12144
|
+
if (!Array.isArray(record2.commits)) return { status: "rejected", reason: "commits was not a list" };
|
|
11996
12145
|
if (stagedPaths.length < 2) return { status: "absent" };
|
|
11997
|
-
if (
|
|
11998
|
-
if (
|
|
11999
|
-
const rationale = cleanText(
|
|
12146
|
+
if (record2.commits.length < 2) return { status: "rejected", reason: "fewer than two groups" };
|
|
12147
|
+
if (record2.commits.length > 8) return { status: "rejected", reason: `too many groups (${record2.commits.length})` };
|
|
12148
|
+
const rationale = cleanText(record2.rationale, 1e3);
|
|
12000
12149
|
if (rationale === null) return { status: "rejected", reason: "missing or unusable rationale" };
|
|
12001
12150
|
const allowed = new Set(stagedPaths);
|
|
12002
12151
|
const used = /* @__PURE__ */ new Set();
|
|
12003
12152
|
const commits = [];
|
|
12004
|
-
for (const candidate of
|
|
12153
|
+
for (const candidate of record2.commits) {
|
|
12005
12154
|
if (!candidate || typeof candidate !== "object") return { status: "rejected", reason: "a group was not an object" };
|
|
12006
12155
|
let parts;
|
|
12007
12156
|
try {
|
|
@@ -12323,8 +12472,8 @@ const AI_SERVER_TIMEOUT_MS = AI_PROVIDER_TIMEOUT_MS + 3e4;
|
|
|
12323
12472
|
const DEFAULT_MODEL = { id: "default", label: "Default (CLI)" };
|
|
12324
12473
|
function claudeUsage(envelope) {
|
|
12325
12474
|
if (!envelope || typeof envelope !== "object") return { ...EMPTY_AI_USAGE };
|
|
12326
|
-
const
|
|
12327
|
-
const usage =
|
|
12475
|
+
const record2 = envelope;
|
|
12476
|
+
const usage = record2.usage ?? {};
|
|
12328
12477
|
const details = usage.output_tokens_details ?? {};
|
|
12329
12478
|
return {
|
|
12330
12479
|
inputTokens: count(usage.input_tokens),
|
|
@@ -12332,7 +12481,7 @@ function claudeUsage(envelope) {
|
|
|
12332
12481
|
reasoningTokens: count(details.thinking_tokens),
|
|
12333
12482
|
cacheReadTokens: count(usage.cache_read_input_tokens),
|
|
12334
12483
|
cacheWriteTokens: count(usage.cache_creation_input_tokens),
|
|
12335
|
-
costUsd: count(
|
|
12484
|
+
costUsd: count(record2.total_cost_usd, true)
|
|
12336
12485
|
};
|
|
12337
12486
|
}
|
|
12338
12487
|
function codexUsage(stdout) {
|
|
@@ -12360,8 +12509,8 @@ function codexUsage(stdout) {
|
|
|
12360
12509
|
}
|
|
12361
12510
|
function openCodeUsage(info) {
|
|
12362
12511
|
if (!info || typeof info !== "object") return { ...EMPTY_AI_USAGE };
|
|
12363
|
-
const
|
|
12364
|
-
const tokens =
|
|
12512
|
+
const record2 = info;
|
|
12513
|
+
const tokens = record2.tokens ?? {};
|
|
12365
12514
|
const cache = tokens.cache ?? {};
|
|
12366
12515
|
return {
|
|
12367
12516
|
inputTokens: count(tokens.input),
|
|
@@ -12369,7 +12518,7 @@ function openCodeUsage(info) {
|
|
|
12369
12518
|
reasoningTokens: count(tokens.reasoning),
|
|
12370
12519
|
cacheReadTokens: count(cache.read),
|
|
12371
12520
|
cacheWriteTokens: count(cache.write),
|
|
12372
|
-
costUsd: count(
|
|
12521
|
+
costUsd: count(record2.cost, true)
|
|
12373
12522
|
};
|
|
12374
12523
|
}
|
|
12375
12524
|
function count(value, fractional = false) {
|
|
@@ -12431,29 +12580,29 @@ function toCodexOutputSchema(schema) {
|
|
|
12431
12580
|
function strictify(value) {
|
|
12432
12581
|
if (!value || typeof value !== "object") return value;
|
|
12433
12582
|
if (Array.isArray(value)) return value.map(strictify);
|
|
12434
|
-
const
|
|
12435
|
-
delete
|
|
12436
|
-
if (
|
|
12583
|
+
const record2 = { ...value };
|
|
12584
|
+
delete record2.$schema;
|
|
12585
|
+
if (record2.properties && typeof record2.properties === "object" && !Array.isArray(record2.properties)) {
|
|
12437
12586
|
const properties = Object.fromEntries(
|
|
12438
|
-
Object.entries(
|
|
12587
|
+
Object.entries(record2.properties).map(([key, item]) => [key, strictify(item)])
|
|
12439
12588
|
);
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12589
|
+
record2.properties = properties;
|
|
12590
|
+
record2.required = Object.keys(properties);
|
|
12591
|
+
record2.additionalProperties = false;
|
|
12443
12592
|
}
|
|
12444
|
-
if ("items" in
|
|
12593
|
+
if ("items" in record2) record2.items = strictify(record2.items);
|
|
12445
12594
|
for (const key of ["$defs", "definitions"]) {
|
|
12446
|
-
const defs =
|
|
12595
|
+
const defs = record2[key];
|
|
12447
12596
|
if (defs && typeof defs === "object" && !Array.isArray(defs)) {
|
|
12448
|
-
|
|
12597
|
+
record2[key] = Object.fromEntries(
|
|
12449
12598
|
Object.entries(defs).map(([name, item]) => [name, strictify(item)])
|
|
12450
12599
|
);
|
|
12451
12600
|
}
|
|
12452
12601
|
}
|
|
12453
12602
|
for (const key of ["anyOf", "oneOf", "allOf"]) {
|
|
12454
|
-
if (Array.isArray(
|
|
12603
|
+
if (Array.isArray(record2[key])) record2[key] = record2[key].map(strictify);
|
|
12455
12604
|
}
|
|
12456
|
-
return
|
|
12605
|
+
return record2;
|
|
12457
12606
|
}
|
|
12458
12607
|
function cliDiagnostic(result) {
|
|
12459
12608
|
let fromTurn = null;
|
|
@@ -16472,9 +16621,9 @@ function parseNumstat$1(output) {
|
|
|
16472
16621
|
const stats = /* @__PURE__ */ new Map();
|
|
16473
16622
|
const tokens = output.split("\0");
|
|
16474
16623
|
for (let index = 0; index < tokens.length; index += 1) {
|
|
16475
|
-
const
|
|
16476
|
-
if (!
|
|
16477
|
-
const match = /^(\d+|-)\t(\d+|-)\t(.*)$/s.exec(
|
|
16624
|
+
const record2 = tokens[index];
|
|
16625
|
+
if (!record2) continue;
|
|
16626
|
+
const match = /^(\d+|-)\t(\d+|-)\t(.*)$/s.exec(record2);
|
|
16478
16627
|
if (!match) continue;
|
|
16479
16628
|
const binary = match[1] === "-" || match[2] === "-";
|
|
16480
16629
|
const entry = {
|
|
@@ -16495,8 +16644,8 @@ const FIELD = "";
|
|
|
16495
16644
|
const RECORD = "";
|
|
16496
16645
|
const LOG_FORMAT = `%H${FIELD}%h${FIELD}%s${FIELD}%b${FIELD}%an${FIELD}%ae${FIELD}%aI${FIELD}%D${FIELD}%P${RECORD}`;
|
|
16497
16646
|
function parseLog(output) {
|
|
16498
|
-
return output.split(RECORD).map((
|
|
16499
|
-
const fields =
|
|
16647
|
+
return output.split(RECORD).map((record2) => record2.trim()).filter(Boolean).flatMap((record2) => {
|
|
16648
|
+
const fields = record2.split(FIELD);
|
|
16500
16649
|
if (fields.length < 9) return [];
|
|
16501
16650
|
const oid = fields[0] ?? "";
|
|
16502
16651
|
if (!/^[0-9a-f]{40,64}$/i.test(oid)) return [];
|
|
@@ -16517,6 +16666,21 @@ function parseLog(output) {
|
|
|
16517
16666
|
}];
|
|
16518
16667
|
});
|
|
16519
16668
|
}
|
|
16669
|
+
function selectHistoryBase(output, upstream) {
|
|
16670
|
+
const refs = output.trim().split("\n").map((line) => {
|
|
16671
|
+
const [ref = "", oid = "", target = ""] = line.split("\0");
|
|
16672
|
+
return { ref, oid, target };
|
|
16673
|
+
}).filter((ref) => /^[a-f0-9]{40,64}$/i.test(ref.oid));
|
|
16674
|
+
const remoteDefaults = refs.filter((ref) => ref.ref.startsWith("refs/remotes/") && ref.ref.endsWith("/HEAD") && ref.target);
|
|
16675
|
+
const preferred = remoteDefaults.filter((ref) => upstream?.startsWith(ref.ref.slice("refs/remotes/".length, -4))).sort((a2, b) => b.ref.length - a2.ref.length)[0] ?? remoteDefaults.find((ref) => ref.ref === "refs/remotes/origin/HEAD");
|
|
16676
|
+
if (preferred) return { ref: preferred.target.replace(/^refs\/(heads|remotes)\//, ""), oid: preferred.oid };
|
|
16677
|
+
const remotePrefix = upstream?.split("/")[0] ?? "origin";
|
|
16678
|
+
for (const name of [`refs/remotes/${remotePrefix}/main`, `refs/remotes/${remotePrefix}/master`, "refs/heads/main", "refs/heads/master"]) {
|
|
16679
|
+
const ref = refs.find((candidate) => candidate.ref === name);
|
|
16680
|
+
if (ref) return { ref: name.replace(/^refs\/(heads|remotes)\//, ""), oid: ref.oid };
|
|
16681
|
+
}
|
|
16682
|
+
return null;
|
|
16683
|
+
}
|
|
16520
16684
|
const REF_FORMAT = "%(refname)%00%(refname:short)%00%(HEAD)%00%(upstream:short)%00%(upstream:track)%00%(worktreepath)%00%(objectname)%00%(objectname:short)%00%(subject)%00%(authorname)%00%(committerdate:iso-strict)%00";
|
|
16521
16685
|
const FIELDS_PER_REF = 11;
|
|
16522
16686
|
function parseRefs(buffer) {
|
|
@@ -16618,25 +16782,25 @@ function parseStatus(buffer) {
|
|
|
16618
16782
|
};
|
|
16619
16783
|
const chunks = splitNul(buffer).map((chunk) => chunk.toString("utf8"));
|
|
16620
16784
|
for (let index = 0; index < chunks.length; index += 1) {
|
|
16621
|
-
const
|
|
16622
|
-
if (!
|
|
16623
|
-
if (
|
|
16624
|
-
parseHeader(
|
|
16785
|
+
const record2 = chunks[index] ?? "";
|
|
16786
|
+
if (!record2) continue;
|
|
16787
|
+
if (record2.startsWith("# ")) {
|
|
16788
|
+
parseHeader(record2, status);
|
|
16625
16789
|
continue;
|
|
16626
16790
|
}
|
|
16627
|
-
if (
|
|
16628
|
-
status.changes.push(makeChange(
|
|
16791
|
+
if (record2.startsWith("? ")) {
|
|
16792
|
+
status.changes.push(makeChange(record2.slice(2), "?", "?"));
|
|
16629
16793
|
continue;
|
|
16630
16794
|
}
|
|
16631
|
-
if (
|
|
16632
|
-
const fields =
|
|
16795
|
+
if (record2.startsWith("1 ") || record2.startsWith("u ")) {
|
|
16796
|
+
const fields = record2.split(" ");
|
|
16633
16797
|
const xy = fields[1] ?? "..";
|
|
16634
|
-
const pathIndex =
|
|
16798
|
+
const pathIndex = record2.startsWith("1 ") ? 8 : 10;
|
|
16635
16799
|
status.changes.push(makeChange(fields.slice(pathIndex).join(" "), xy[0] ?? ".", xy[1] ?? ".", fields[2] ?? ""));
|
|
16636
16800
|
continue;
|
|
16637
16801
|
}
|
|
16638
|
-
if (
|
|
16639
|
-
const fields =
|
|
16802
|
+
if (record2.startsWith("2 ")) {
|
|
16803
|
+
const fields = record2.split(" ");
|
|
16640
16804
|
const xy = fields[1] ?? "..";
|
|
16641
16805
|
const next = chunks[index + 1] ?? "";
|
|
16642
16806
|
const pathValue = fields.slice(9).join(" ");
|
|
@@ -16984,14 +17148,18 @@ ${base}
|
|
|
16984
17148
|
if (cursor && commits[0]?.oid === cursor) commits = commits.slice(1);
|
|
16985
17149
|
const hasMore = commits.length > 100;
|
|
16986
17150
|
commits = commits.slice(0, 100);
|
|
16987
|
-
const localOids = await
|
|
17151
|
+
const [localOids, base] = await Promise.all([
|
|
17152
|
+
this.localOnlyOids(repository.path, status.upstream, status.detached || status.unborn),
|
|
17153
|
+
this.historyBase(repository.path, revision2, status.upstream)
|
|
17154
|
+
]);
|
|
16988
17155
|
commits = commits.map((commit) => ({
|
|
16989
17156
|
...commit,
|
|
16990
17157
|
isHead: commit.oid === status.oid,
|
|
16991
|
-
upstreamState: localOids === null ? "unknown" : localOids.has(commit.oid) ? "local-only" : "published"
|
|
17158
|
+
upstreamState: localOids === null ? "unknown" : localOids.has(commit.oid) ? "local-only" : "published",
|
|
17159
|
+
baseState: base === null ? "unknown" : base.outside.has(commit.oid) ? "outside" : "included"
|
|
16992
17160
|
}));
|
|
16993
17161
|
for (const commit of commits) this.rememberOid(repositoryId, commit.oid);
|
|
16994
|
-
return { commits, nextCursor: hasMore ? commits.at(-1)?.oid ?? null : null };
|
|
17162
|
+
return { commits, nextCursor: hasMore ? commits.at(-1)?.oid ?? null : null, baseRef: base?.ref ?? null };
|
|
16995
17163
|
} catch (error) {
|
|
16996
17164
|
if (!cursor && error instanceof GitOperationError && /does not have any commits|unknown revision|bad revision/i.test(error.message)) return { commits: [], nextCursor: null };
|
|
16997
17165
|
throw error;
|
|
@@ -17215,13 +17383,13 @@ ${base}
|
|
|
17215
17383
|
const nextStatus = await this.repositories.status(repositoryId, false);
|
|
17216
17384
|
return { status: "success", commits, restoredLocalChanges: hasLocalChanges, rebased, localCommits: nextStatus.ahead };
|
|
17217
17385
|
}
|
|
17218
|
-
async push(repositoryId) {
|
|
17386
|
+
async push(repositoryId, publish) {
|
|
17219
17387
|
const repository = this.repositories.get(repositoryId);
|
|
17220
17388
|
let status = await this.repositories.status(repositoryId, false);
|
|
17221
17389
|
const existingConflicts = conflictPaths(status);
|
|
17222
17390
|
if (existingConflicts.length > 0) return { status: "blocked-conflicts", files: existingConflicts };
|
|
17223
17391
|
if (status.operation) return { status: "blocked-operation", operation: status.operation };
|
|
17224
|
-
if (!status.upstream) return
|
|
17392
|
+
if (!status.upstream || publish) return this.publishBranch(repositoryId, status.branch, status.oid, publish);
|
|
17225
17393
|
if (status.ahead === 0) return { status: "up-to-date" };
|
|
17226
17394
|
try {
|
|
17227
17395
|
await this.runFetch(repository.path, "push-fetch");
|
|
@@ -17247,6 +17415,48 @@ ${base}
|
|
|
17247
17415
|
}
|
|
17248
17416
|
return { status: "success", commits };
|
|
17249
17417
|
}
|
|
17418
|
+
async publishBranch(repositoryId, expectedBranch, expectedOid, publish) {
|
|
17419
|
+
const repository = this.repositories.get(repositoryId);
|
|
17420
|
+
const rejected = (message) => ({ status: "rejected", reason: "configuration", message });
|
|
17421
|
+
return this.git.runWriteTask(repository.path, async (run) => {
|
|
17422
|
+
const status = await this.repositories.status(repositoryId, false);
|
|
17423
|
+
if (status.operation || status.readOnly) return { status: "blocked-operation", operation: status.operation ?? "another Git operation" };
|
|
17424
|
+
const conflicts = conflictPaths(status);
|
|
17425
|
+
if (conflicts.length > 0) return { status: "blocked-conflicts", files: conflicts };
|
|
17426
|
+
if (status.detached || !status.branch) return rejected("Check out a branch before publishing.");
|
|
17427
|
+
if (status.unborn || !status.oid) return rejected("Create the first commit before publishing this branch.");
|
|
17428
|
+
if (status.upstream || status.branch !== (publish?.expectedBranch ?? expectedBranch) || status.oid !== (publish?.expectedOid ?? expectedOid)) {
|
|
17429
|
+
return rejected("The branch changed. Refresh and try publishing again.");
|
|
17430
|
+
}
|
|
17431
|
+
try {
|
|
17432
|
+
const remotes = (await run(["remote"], { operation: "publish-remotes", readOnly: true })).stdout.toString("utf8").trim().split(/\r?\n/).filter(Boolean);
|
|
17433
|
+
if (remotes.length === 0) return rejected("No remote is configured. Add a remote before publishing this branch.");
|
|
17434
|
+
let remote = publish?.remote;
|
|
17435
|
+
if (!remote) {
|
|
17436
|
+
for (const key of [`branch.${status.branch}.pushRemote`, "remote.pushDefault", `branch.${status.branch}.remote`]) {
|
|
17437
|
+
try {
|
|
17438
|
+
remote = (await run(["config", "--get", key], { operation: "publish-remote-config", readOnly: true })).stdout.toString("utf8").trim();
|
|
17439
|
+
} catch (error) {
|
|
17440
|
+
if (!(error instanceof GitOperationError) || error.detail.exitCode !== 1) throw error;
|
|
17441
|
+
}
|
|
17442
|
+
if (remote) break;
|
|
17443
|
+
}
|
|
17444
|
+
remote ||= remotes.length === 1 ? remotes[0] : void 0;
|
|
17445
|
+
}
|
|
17446
|
+
if (!remote) return { status: "remote-required", branch: status.branch, oid: status.oid, remotes };
|
|
17447
|
+
if (!remotes.includes(remote)) return rejected("The selected push remote is not configured. Check the repository remote settings.");
|
|
17448
|
+
const ref = `refs/heads/${status.branch}`;
|
|
17449
|
+
await run(["-c", `remote.${remote}.mirror=false`, "push", "--porcelain", "--set-upstream", "--no-follow-tags", "--", remote, `${ref}:${ref}`], {
|
|
17450
|
+
operation: "publish-branch",
|
|
17451
|
+
timeoutMs: 12e4,
|
|
17452
|
+
maxOutputBytes: 16 * 1024 * 1024
|
|
17453
|
+
});
|
|
17454
|
+
return { status: "published", branch: status.branch, remote };
|
|
17455
|
+
} catch (error) {
|
|
17456
|
+
return pushFailure(error);
|
|
17457
|
+
}
|
|
17458
|
+
}, repository.commonDir);
|
|
17459
|
+
}
|
|
17250
17460
|
async worktrees(repositoryId) {
|
|
17251
17461
|
const repository = this.repositories.get(repositoryId);
|
|
17252
17462
|
const output = await this.git.run(repository.path, ["worktree", "list", "--porcelain", "-z"], { operation: "worktrees", readOnly: true });
|
|
@@ -17522,6 +17732,18 @@ ${body}
|
|
|
17522
17732
|
const status = await this.repositories.status(repositoryId, false);
|
|
17523
17733
|
if (status.readOnly) throw new GitOperationError({ code: "INVALID_ARGUMENT", operation: "write", message: `The repository is in the middle of ${status.operation}; OpenTig keeps it read-only.` });
|
|
17524
17734
|
}
|
|
17735
|
+
async historyBase(repositoryPath, revision2, upstream) {
|
|
17736
|
+
try {
|
|
17737
|
+
const options = { operation: "history-base", readOnly: true, maxOutputBytes: 8 * 1024 * 1024 };
|
|
17738
|
+
const refs = await this.git.run(repositoryPath, ["for-each-ref", "--format=%(refname)%00%(objectname)%00%(symref)", "refs/heads/main", "refs/heads/master", "refs/remotes"], options);
|
|
17739
|
+
const base = selectHistoryBase(refs.stdout.toString("utf8"), upstream);
|
|
17740
|
+
if (!base) return null;
|
|
17741
|
+
const output = await this.git.run(repositoryPath, ["rev-list", revision2, `^${base.oid}`, "--"], options);
|
|
17742
|
+
return { ref: base.ref, outside: new Set(output.stdout.toString("utf8").trim().split("\n").filter(Boolean)) };
|
|
17743
|
+
} catch {
|
|
17744
|
+
return null;
|
|
17745
|
+
}
|
|
17746
|
+
}
|
|
17525
17747
|
async localOnlyOids(repositoryPath, upstream, unavailable) {
|
|
17526
17748
|
if (!upstream || unavailable) return null;
|
|
17527
17749
|
try {
|
|
@@ -18211,6 +18433,73 @@ function revision(bytes) {
|
|
|
18211
18433
|
function invalidReplacement(message) {
|
|
18212
18434
|
return new GitOperationError({ code: "INVALID_ARGUMENT", operation: "replace-search", message });
|
|
18213
18435
|
}
|
|
18436
|
+
const positive = number().int().positive().safe();
|
|
18437
|
+
const membershipSchema = object({
|
|
18438
|
+
stack: object({ number: positive, size: positive, baseRefName: string().min(1) }).nullable(),
|
|
18439
|
+
stackEntry: object({ position: positive }).nullable()
|
|
18440
|
+
});
|
|
18441
|
+
const stackSchema = object({
|
|
18442
|
+
number: positive,
|
|
18443
|
+
base: union([string().min(1), object({ ref: string().min(1) })]),
|
|
18444
|
+
pull_requests: array(object({
|
|
18445
|
+
number: positive,
|
|
18446
|
+
title: string().optional(),
|
|
18447
|
+
draft: boolean().optional(),
|
|
18448
|
+
head: object({ ref: string().min(1) }),
|
|
18449
|
+
state: _enum(["open", "closed", "merged"]),
|
|
18450
|
+
merged_at: string().nullable().optional()
|
|
18451
|
+
})).min(1)
|
|
18452
|
+
});
|
|
18453
|
+
function invalid() {
|
|
18454
|
+
return new GhOperationError({ code: "GH_INVALID_OUTPUT", operation: "gh-pr-stack", message: "GitHub returned unreadable stack information." });
|
|
18455
|
+
}
|
|
18456
|
+
function json(raw) {
|
|
18457
|
+
try {
|
|
18458
|
+
return JSON.parse(raw);
|
|
18459
|
+
} catch {
|
|
18460
|
+
throw invalid();
|
|
18461
|
+
}
|
|
18462
|
+
}
|
|
18463
|
+
function stackMembershipQuery(numbers) {
|
|
18464
|
+
if (!numbers.length || numbers.some((number2) => !positive.safeParse(number2).success)) throw invalid();
|
|
18465
|
+
return `query($owner:String!,$name:String!){repository(owner:$owner,name:$name){${numbers.map((number2) => `pr${number2}:pullRequest(number:${number2}){stack{number size baseRefName} stackEntry{position}}`).join(" ")}}}`;
|
|
18466
|
+
}
|
|
18467
|
+
function parseStackMemberships(raw, numbers) {
|
|
18468
|
+
const envelope = object({ data: object({ repository: record(string(), membershipSchema.nullable()) }), errors: array(unknown()).optional() }).safeParse(json(raw));
|
|
18469
|
+
if (!envelope.success || envelope.data.errors?.length) throw invalid();
|
|
18470
|
+
const result = /* @__PURE__ */ new Map();
|
|
18471
|
+
for (const number2 of numbers) {
|
|
18472
|
+
const entry = envelope.data.data.repository[`pr${number2}`];
|
|
18473
|
+
if (entry === void 0) throw invalid();
|
|
18474
|
+
if (!entry?.stack && !entry?.stackEntry) continue;
|
|
18475
|
+
if (!entry?.stack || !entry.stackEntry || entry.stackEntry.position > entry.stack.size) throw invalid();
|
|
18476
|
+
result.set(number2, { number: entry.stack.number, size: entry.stack.size, position: entry.stackEntry.position, base: entry.stack.baseRefName });
|
|
18477
|
+
}
|
|
18478
|
+
return result;
|
|
18479
|
+
}
|
|
18480
|
+
function parsePullRequestStack(raw, prNumber, listing = false) {
|
|
18481
|
+
let value = json(raw);
|
|
18482
|
+
if (listing) {
|
|
18483
|
+
if (!Array.isArray(value) || value.length > 1) throw invalid();
|
|
18484
|
+
if (!value.length) return null;
|
|
18485
|
+
value = value[0];
|
|
18486
|
+
}
|
|
18487
|
+
const parsed = stackSchema.safeParse(value);
|
|
18488
|
+
if (!parsed.success) throw invalid();
|
|
18489
|
+
const stack = parsed.data;
|
|
18490
|
+
if (!stack.pull_requests.some((pr) => pr.number === prNumber) || new Set(stack.pull_requests.map((pr) => pr.number)).size !== stack.pull_requests.length) throw invalid();
|
|
18491
|
+
return {
|
|
18492
|
+
number: stack.number,
|
|
18493
|
+
base: typeof stack.base === "string" ? stack.base : stack.base.ref,
|
|
18494
|
+
layers: stack.pull_requests.map((pr) => ({
|
|
18495
|
+
number: pr.number,
|
|
18496
|
+
title: pr.title || pr.head.ref,
|
|
18497
|
+
headRefName: pr.head.ref,
|
|
18498
|
+
state: pr.merged_at || pr.state === "merged" ? "MERGED" : pr.state === "closed" ? "CLOSED" : "OPEN",
|
|
18499
|
+
isDraft: pr.draft ?? false
|
|
18500
|
+
}))
|
|
18501
|
+
};
|
|
18502
|
+
}
|
|
18214
18503
|
const OWNER_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/;
|
|
18215
18504
|
const REPO_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
18216
18505
|
function parseGitHubRemote(url) {
|
|
@@ -18250,13 +18539,13 @@ function parsePullRequestList(raw) {
|
|
|
18250
18539
|
function parsePullRequestDetails(raw) {
|
|
18251
18540
|
const item = parseJson(raw, "gh-pr-view");
|
|
18252
18541
|
const summary = parseSummary(item, "gh-pr-view");
|
|
18253
|
-
const
|
|
18542
|
+
const record2 = item;
|
|
18254
18543
|
return {
|
|
18255
18544
|
...summary,
|
|
18256
|
-
body: typeof
|
|
18257
|
-
changedFiles: numberOrZero(
|
|
18258
|
-
labels: parseLabels(
|
|
18259
|
-
commits: parseCommits(
|
|
18545
|
+
body: typeof record2.body === "string" ? record2.body : "",
|
|
18546
|
+
changedFiles: numberOrZero(record2.changedFiles),
|
|
18547
|
+
labels: parseLabels(record2.labels),
|
|
18548
|
+
commits: parseCommits(record2.commits)
|
|
18260
18549
|
};
|
|
18261
18550
|
}
|
|
18262
18551
|
function sortPullRequestsNewestFirst(pulls) {
|
|
@@ -18283,27 +18572,27 @@ function parseCreatedPullRequestUrl(stdout) {
|
|
|
18283
18572
|
function parseSummary(item, operation) {
|
|
18284
18573
|
const parsed = summaryRecordSchema.safeParse(item);
|
|
18285
18574
|
if (!parsed.success) throw invalidOutput(operation);
|
|
18286
|
-
const
|
|
18575
|
+
const record2 = parsed.data;
|
|
18287
18576
|
const { number: number2, state } = parsed.data;
|
|
18288
|
-
const parsedAuthor = tolerantRecordSchema.safeParse(
|
|
18577
|
+
const parsedAuthor = tolerantRecordSchema.safeParse(record2.author);
|
|
18289
18578
|
const authorRecord = parsedAuthor.success ? parsedAuthor.data : null;
|
|
18290
18579
|
const author = authorRecord?.login;
|
|
18291
18580
|
const authorLogin = typeof author === "string" ? author : "unknown";
|
|
18292
18581
|
return {
|
|
18293
18582
|
number: number2,
|
|
18294
|
-
title: typeof
|
|
18583
|
+
title: typeof record2.title === "string" ? record2.title : "",
|
|
18295
18584
|
state,
|
|
18296
|
-
isDraft:
|
|
18585
|
+
isDraft: record2.isDraft === true,
|
|
18297
18586
|
author: authorLogin,
|
|
18298
18587
|
authorAvatarUrl: avatarUrl(authorLogin, authorRecord?.is_bot === true),
|
|
18299
|
-
headRefName: typeof
|
|
18300
|
-
baseRefName: typeof
|
|
18301
|
-
updatedAt: typeof
|
|
18302
|
-
url: typeof
|
|
18303
|
-
reviewDecision: typeof
|
|
18304
|
-
additions: numberOrZero(
|
|
18305
|
-
deletions: numberOrZero(
|
|
18306
|
-
checksState: parseChecksState(
|
|
18588
|
+
headRefName: typeof record2.headRefName === "string" ? record2.headRefName : "",
|
|
18589
|
+
baseRefName: typeof record2.baseRefName === "string" ? record2.baseRefName : "",
|
|
18590
|
+
updatedAt: typeof record2.updatedAt === "string" ? record2.updatedAt : "",
|
|
18591
|
+
url: typeof record2.url === "string" ? record2.url : "",
|
|
18592
|
+
reviewDecision: typeof record2.reviewDecision === "string" && record2.reviewDecision ? record2.reviewDecision : null,
|
|
18593
|
+
additions: numberOrZero(record2.additions),
|
|
18594
|
+
deletions: numberOrZero(record2.deletions),
|
|
18595
|
+
checksState: parseChecksState(record2.statusCheckRollup)
|
|
18307
18596
|
};
|
|
18308
18597
|
}
|
|
18309
18598
|
function parseLabels(value) {
|
|
@@ -18312,10 +18601,10 @@ function parseLabels(value) {
|
|
|
18312
18601
|
return parsed.data.flatMap((item) => {
|
|
18313
18602
|
const candidate = tolerantRecordSchema.safeParse(item);
|
|
18314
18603
|
if (!candidate.success) return [];
|
|
18315
|
-
const
|
|
18316
|
-
if (typeof
|
|
18317
|
-
const color = typeof
|
|
18318
|
-
return [{ name:
|
|
18604
|
+
const record2 = candidate.data;
|
|
18605
|
+
if (typeof record2.name !== "string" || !record2.name) return [];
|
|
18606
|
+
const color = typeof record2.color === "string" && /^[0-9a-f]{6}$/i.test(record2.color) ? record2.color : "6e7781";
|
|
18607
|
+
return [{ name: record2.name, color }];
|
|
18319
18608
|
});
|
|
18320
18609
|
}
|
|
18321
18610
|
function parseCommits(value) {
|
|
@@ -18324,16 +18613,16 @@ function parseCommits(value) {
|
|
|
18324
18613
|
return parsed.data.flatMap((item) => {
|
|
18325
18614
|
const candidate = tolerantRecordSchema.safeParse(item);
|
|
18326
18615
|
if (!candidate.success) return [];
|
|
18327
|
-
const
|
|
18328
|
-
if (typeof
|
|
18329
|
-
const authors = Array.isArray(
|
|
18616
|
+
const record2 = candidate.data;
|
|
18617
|
+
if (typeof record2.oid !== "string" || !record2.oid) return [];
|
|
18618
|
+
const authors = Array.isArray(record2.authors) ? record2.authors : [];
|
|
18330
18619
|
const authorRecord = authors.map((author) => tolerantRecordSchema.safeParse(author)).find((author) => author.success)?.data;
|
|
18331
18620
|
const login = typeof authorRecord?.login === "string" ? authorRecord.login : null;
|
|
18332
18621
|
const name = typeof authorRecord?.name === "string" && authorRecord.name ? authorRecord.name : login ?? "unknown";
|
|
18333
18622
|
return [{
|
|
18334
|
-
oid:
|
|
18335
|
-
messageHeadline: typeof
|
|
18336
|
-
authoredAt: typeof
|
|
18623
|
+
oid: record2.oid,
|
|
18624
|
+
messageHeadline: typeof record2.messageHeadline === "string" ? record2.messageHeadline : "",
|
|
18625
|
+
authoredAt: typeof record2.authoredDate === "string" ? record2.authoredDate : "",
|
|
18337
18626
|
author: name,
|
|
18338
18627
|
authorAvatarUrl: login ? avatarUrl(login, login.endsWith("[bot]")) : null
|
|
18339
18628
|
}];
|
|
@@ -18345,11 +18634,11 @@ function parseChecksState(value) {
|
|
|
18345
18634
|
for (const item of value) {
|
|
18346
18635
|
const parsed = tolerantRecordSchema.safeParse(item);
|
|
18347
18636
|
if (!parsed.success) continue;
|
|
18348
|
-
const
|
|
18349
|
-
const conclusion = typeof
|
|
18350
|
-
const state = typeof
|
|
18637
|
+
const record2 = parsed.data;
|
|
18638
|
+
const conclusion = typeof record2.conclusion === "string" ? record2.conclusion.toUpperCase() : "";
|
|
18639
|
+
const state = typeof record2.state === "string" ? record2.state.toUpperCase() : "";
|
|
18351
18640
|
if (["FAILURE", "ERROR", "TIMED_OUT", "CANCELLED", "ACTION_REQUIRED", "STARTUP_FAILURE"].includes(conclusion || state)) return "FAILING";
|
|
18352
|
-
const status = typeof
|
|
18641
|
+
const status = typeof record2.status === "string" ? record2.status.toUpperCase() : "";
|
|
18353
18642
|
if (status && status !== "COMPLETED" || ["PENDING", "EXPECTED"].includes(state)) pending = true;
|
|
18354
18643
|
}
|
|
18355
18644
|
return pending ? "PENDING" : "PASSING";
|
|
@@ -18414,7 +18703,7 @@ class GitHubService {
|
|
|
18414
18703
|
["pr", "list", "-R", nameWithOwner, "--state", state.toLowerCase(), "--json", PR_SUMMARY_FIELDS, "--limit", "50"],
|
|
18415
18704
|
{ cwd: repository.path, operation: "gh-pr-list", timeoutMs: NETWORK_TIMEOUT_MS, maxOutputBytes: 4 * 1024 * 1024 }
|
|
18416
18705
|
)));
|
|
18417
|
-
return selectPullRequestsNewestFirst(results.flatMap((result) => parsePullRequestList(result.stdout)), states);
|
|
18706
|
+
return this.withStackMembership(repository.path, nameWithOwner, selectPullRequestsNewestFirst(results.flatMap((result) => parsePullRequestList(result.stdout)), states));
|
|
18418
18707
|
}
|
|
18419
18708
|
async findPullRequestForBranch(repositoryId, branchName) {
|
|
18420
18709
|
const operation = "gh-pr-for-branch";
|
|
@@ -18432,7 +18721,51 @@ class GitHubService {
|
|
|
18432
18721
|
["pr", "view", String(prNumber), "-R", nameWithOwner, "--json", PR_DETAIL_FIELDS],
|
|
18433
18722
|
{ cwd: repository.path, operation: "gh-pr-view", timeoutMs: NETWORK_TIMEOUT_MS, maxOutputBytes: 4 * 1024 * 1024 }
|
|
18434
18723
|
);
|
|
18435
|
-
|
|
18724
|
+
const details = parsePullRequestDetails(result.stdout);
|
|
18725
|
+
return (await this.withStackMembership(repository.path, nameWithOwner, [details]))[0];
|
|
18726
|
+
}
|
|
18727
|
+
async withStackMembership(cwd, nameWithOwner, pulls) {
|
|
18728
|
+
const [owner, name] = nameWithOwner.split("/");
|
|
18729
|
+
const enriched = [];
|
|
18730
|
+
for (let start = 0; start < pulls.length; start += 25) {
|
|
18731
|
+
const batch = pulls.slice(start, start + 25);
|
|
18732
|
+
try {
|
|
18733
|
+
const numbers = batch.map((pr) => pr.number);
|
|
18734
|
+
const result = await this.runGh(["api", "graphql", "-f", `owner=${owner}`, "-f", `name=${name}`, "-f", `query=${stackMembershipQuery(numbers)}`], {
|
|
18735
|
+
cwd,
|
|
18736
|
+
operation: "gh-pr-stack-membership",
|
|
18737
|
+
timeoutMs: 1e4,
|
|
18738
|
+
maxOutputBytes: 1024 * 1024
|
|
18739
|
+
});
|
|
18740
|
+
const memberships = parseStackMemberships(result.stdout, numbers);
|
|
18741
|
+
enriched.push(...batch.map((pr) => {
|
|
18742
|
+
const stack = memberships.get(pr.number);
|
|
18743
|
+
return stack ? { ...pr, stack } : pr;
|
|
18744
|
+
}));
|
|
18745
|
+
} catch {
|
|
18746
|
+
enriched.push(...batch);
|
|
18747
|
+
}
|
|
18748
|
+
}
|
|
18749
|
+
return enriched;
|
|
18750
|
+
}
|
|
18751
|
+
async getPullRequestStack(repositoryId, prNumber) {
|
|
18752
|
+
const operation = "gh-pr-stack";
|
|
18753
|
+
const { repository, nameWithOwner } = await this.requireGitHub(repositoryId, operation);
|
|
18754
|
+
const options = { cwd: repository.path, operation, timeoutMs: NETWORK_TIMEOUT_MS, maxOutputBytes: 4 * 1024 * 1024 };
|
|
18755
|
+
const read = async (endpoint) => this.runGh(["api", endpoint], options);
|
|
18756
|
+
let listing;
|
|
18757
|
+
try {
|
|
18758
|
+
listing = await read(`repos/${nameWithOwner}/stacks?pull_request=${prNumber}`);
|
|
18759
|
+
} catch (error) {
|
|
18760
|
+
if (error instanceof GhOperationError && error.detail.code === "GH_PROCESS_FAILED" && /HTTP 404/.test(error.message)) return null;
|
|
18761
|
+
throw error;
|
|
18762
|
+
}
|
|
18763
|
+
const stack = parsePullRequestStack(listing.stdout, prNumber, true);
|
|
18764
|
+
if (!stack) return null;
|
|
18765
|
+
const details = await read(`repos/${nameWithOwner}/stacks/${stack.number}`);
|
|
18766
|
+
const complete = parsePullRequestStack(details.stdout, prNumber);
|
|
18767
|
+
if (complete?.number !== stack.number) throw new GhOperationError({ code: "GH_INVALID_OUTPUT", operation, message: "The stack changed while loading. Refresh to try again." });
|
|
18768
|
+
return complete;
|
|
18436
18769
|
}
|
|
18437
18770
|
async getPullRequestDiff(repositoryId, prNumber) {
|
|
18438
18771
|
const { repository, nameWithOwner } = await this.requireGitHub(repositoryId, "gh-pr-diff");
|
|
@@ -18676,7 +19009,7 @@ class ProblemsLogStore {
|
|
|
18676
19009
|
this.loaded = true;
|
|
18677
19010
|
}
|
|
18678
19011
|
record(entry) {
|
|
18679
|
-
const
|
|
19012
|
+
const record2 = {
|
|
18680
19013
|
id: randomUUID(),
|
|
18681
19014
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18682
19015
|
level: entry.level ?? "error",
|
|
@@ -18686,7 +19019,7 @@ class ProblemsLogStore {
|
|
|
18686
19019
|
message: entry.message,
|
|
18687
19020
|
repositoryId: entry.repositoryId ?? null
|
|
18688
19021
|
};
|
|
18689
|
-
const normalized = normalizeProblemLogEntry(
|
|
19022
|
+
const normalized = normalizeProblemLogEntry(record2);
|
|
18690
19023
|
if (!normalized) return;
|
|
18691
19024
|
this.pending = this.pending.then(async () => {
|
|
18692
19025
|
await mkdir(path.dirname(this.filePath), { recursive: true });
|
|
@@ -18785,10 +19118,10 @@ resolveShortcuts();
|
|
|
18785
19118
|
function sanitizeShortcutOverrides(value) {
|
|
18786
19119
|
const result = {};
|
|
18787
19120
|
if (!value || typeof value !== "object") return result;
|
|
18788
|
-
const
|
|
19121
|
+
const record2 = value;
|
|
18789
19122
|
const usedCombos = /* @__PURE__ */ new Set();
|
|
18790
19123
|
for (const def of SHORTCUT_DEFINITIONS) {
|
|
18791
|
-
const combo =
|
|
19124
|
+
const combo = record2[def.id];
|
|
18792
19125
|
if (typeof combo !== "string" || combo === def.defaultCombo) continue;
|
|
18793
19126
|
if (!isValidCombo(combo, def.allowBare)) continue;
|
|
18794
19127
|
if (RESERVED_COMBOS.has(combo) || usedCombos.has(combo)) continue;
|
|
@@ -19794,6 +20127,7 @@ const IPC = {
|
|
|
19794
20127
|
githubPrForBranch: "github:pr-for-branch",
|
|
19795
20128
|
githubPrList: "github:pr-list",
|
|
19796
20129
|
githubPrView: "github:pr-view",
|
|
20130
|
+
githubPrStack: "github:pr-stack",
|
|
19797
20131
|
githubPrDiff: "github:pr-diff",
|
|
19798
20132
|
githubPrCommitDiff: "github:pr-commit-diff",
|
|
19799
20133
|
githubPrCreate: "github:pr-create",
|
|
@@ -19878,6 +20212,7 @@ const OPEN_TIG_SERVER_COMMANDS = {
|
|
|
19878
20212
|
"github.findPullRequestForBranch": command(IPC.githubPrForBranch, "gh-pr-for-branch", false),
|
|
19879
20213
|
"github.listPullRequests": command(IPC.githubPrList, "gh-pr-list", false),
|
|
19880
20214
|
"github.getPullRequest": command(IPC.githubPrView, "gh-pr-view", false),
|
|
20215
|
+
"github.getPullRequestStack": command(IPC.githubPrStack, "gh-pr-stack", false),
|
|
19881
20216
|
"github.getPullRequestDiff": command(IPC.githubPrDiff, "gh-pr-diff", false),
|
|
19882
20217
|
"github.getPullRequestCommitDiff": command(IPC.githubPrCommitDiff, "gh-pr-commit-diff", false),
|
|
19883
20218
|
"github.createPullRequest": command(IPC.githubPrCreate, "gh-pr-create", true),
|
|
@@ -20127,28 +20462,28 @@ function filesTreeStateArg(repositoryId, value, operation) {
|
|
|
20127
20462
|
return { repositoryId, expandedPaths: normalizeExpandedPaths(expandedPaths) };
|
|
20128
20463
|
}
|
|
20129
20464
|
function openFilesStateArg(repositoryId, tabs, activePath, previewPath, operation) {
|
|
20130
|
-
const
|
|
20465
|
+
const invalid2 = () => new GitOperationError({ code: "INVALID_ARGUMENT", operation, message: "Invalid open files state." });
|
|
20131
20466
|
const parsedTabs = array(openFileTabSchema).max(MAX_OPEN_FILE_TABS).safeParse(tabs);
|
|
20132
|
-
if (!isOpenFilesRepositoryId(repositoryId) || !parsedTabs.success) throw
|
|
20467
|
+
if (!isOpenFilesRepositoryId(repositoryId) || !parsedTabs.success) throw invalid2();
|
|
20133
20468
|
const normalizedTabs = [];
|
|
20134
20469
|
const seen = /* @__PURE__ */ new Set();
|
|
20135
20470
|
for (const input of parsedTabs.data) {
|
|
20136
20471
|
const path2 = normalizeOpenFilePath(input.path);
|
|
20137
|
-
if (!path2 || typeof input.pinned !== "boolean") throw
|
|
20472
|
+
if (!path2 || typeof input.pinned !== "boolean") throw invalid2();
|
|
20138
20473
|
if (seen.has(path2)) continue;
|
|
20139
20474
|
seen.add(path2);
|
|
20140
20475
|
normalizedTabs.push({ path: path2, pinned: input.pinned });
|
|
20141
20476
|
}
|
|
20142
|
-
const active = optionalOpenFilePath(activePath,
|
|
20143
|
-
const preview = optionalOpenFilePath(previewPath,
|
|
20144
|
-
if (active && !seen.has(active)) throw
|
|
20145
|
-
if (preview && !seen.has(preview)) throw
|
|
20477
|
+
const active = optionalOpenFilePath(activePath, invalid2);
|
|
20478
|
+
const preview = optionalOpenFilePath(previewPath, invalid2);
|
|
20479
|
+
if (active && !seen.has(active)) throw invalid2();
|
|
20480
|
+
if (preview && !seen.has(preview)) throw invalid2();
|
|
20146
20481
|
return { repositoryId, tabs: normalizedTabs, activePath: active, previewPath: preview };
|
|
20147
20482
|
}
|
|
20148
|
-
function optionalOpenFilePath(value,
|
|
20483
|
+
function optionalOpenFilePath(value, invalid2) {
|
|
20149
20484
|
if (value === null || value === void 0) return null;
|
|
20150
20485
|
const normalized = normalizeOpenFilePath(value);
|
|
20151
|
-
if (!normalized) throw
|
|
20486
|
+
if (!normalized) throw invalid2();
|
|
20152
20487
|
return normalized;
|
|
20153
20488
|
}
|
|
20154
20489
|
function projectNameArg(value, operation) {
|
|
@@ -20182,6 +20517,15 @@ function oidArg(value, operation) {
|
|
|
20182
20517
|
}
|
|
20183
20518
|
const MAX_BRANCH_REF_LENGTH = 512;
|
|
20184
20519
|
const MAX_WORKTREE_PATH_LENGTH = 4096;
|
|
20520
|
+
function publishBranchArg(value) {
|
|
20521
|
+
if (value == null) return void 0;
|
|
20522
|
+
const request = requestObject(value, "push");
|
|
20523
|
+
return {
|
|
20524
|
+
remote: refsString(request.remote, "push", MAX_BRANCH_REF_LENGTH),
|
|
20525
|
+
expectedBranch: refsString(request.expectedBranch, "push", MAX_BRANCH_REF_LENGTH),
|
|
20526
|
+
expectedOid: oidArg(request.expectedOid, "push")
|
|
20527
|
+
};
|
|
20528
|
+
}
|
|
20185
20529
|
function branchDetailsArg(value, operation) {
|
|
20186
20530
|
const request = requestObject(value, operation);
|
|
20187
20531
|
return { repositoryId: refsString(request.repositoryId, operation, 64), fullName: refsString(request.fullName, operation, MAX_BRANCH_REF_LENGTH) };
|
|
@@ -20679,7 +21023,7 @@ function registerServerCommands(registry2, services, host) {
|
|
|
20679
21023
|
return services.operations.removeWorktree(repositoryId, path2, expectedOid, force, deleteBranch);
|
|
20680
21024
|
});
|
|
20681
21025
|
handle(IPC.refsPull, "pull", (id) => services.operations.pull(stringArg(id, "pull", 64)));
|
|
20682
|
-
handle(IPC.refsPush, "push", (id) => services.operations.push(stringArg(id, "push", 64)));
|
|
21026
|
+
handle(IPC.refsPush, "push", (id, publish) => services.operations.push(stringArg(id, "push", 64), publishBranchArg(publish)));
|
|
20683
21027
|
handle(IPC.refsFetch, "fetch", (id) => services.operations.fetch(stringArg(id, "fetch", 64)));
|
|
20684
21028
|
handle(IPC.aiStatuses, "ai-statuses", (forceRefresh) => services.ai.statuses(booleanArg(forceRefresh, "ai-statuses")));
|
|
20685
21029
|
handleWithContext(IPC.aiGenerateCommitMessage, "ai-generate-commit-message", (context, input) => services.ai.generate(generateCommitMessageArg(input), context.signal));
|
|
@@ -20719,6 +21063,7 @@ function registerServerCommands(registry2, services, host) {
|
|
|
20719
21063
|
pullRequestStatesArg(states, "gh-pr-list")
|
|
20720
21064
|
));
|
|
20721
21065
|
handle(IPC.githubPrView, "gh-pr-view", (id, prNumber) => services.github.getPullRequest(stringArg(id, "gh-pr-view", 64), prNumberArg(prNumber, "gh-pr-view")));
|
|
21066
|
+
handle(IPC.githubPrStack, "gh-pr-stack", (id, prNumber) => services.github.getPullRequestStack(stringArg(id, "gh-pr-stack", 64), prNumberArg(prNumber, "gh-pr-stack")));
|
|
20722
21067
|
handle(IPC.githubPrDiff, "gh-pr-diff", (id, prNumber) => services.github.getPullRequestDiff(stringArg(id, "gh-pr-diff", 64), prNumberArg(prNumber, "gh-pr-diff")));
|
|
20723
21068
|
handle(IPC.githubPrCommitDiff, "gh-pr-commit-diff", (id, oid) => services.github.getPullRequestCommitDiff(stringArg(id, "gh-pr-commit-diff", 64), oidArg(oid, "gh-pr-commit-diff")));
|
|
20724
21069
|
handle(IPC.githubPrCreate, "gh-pr-create", (input) => services.github.createPullRequest(createPullRequestArg(input)));
|