@brutal-ai/server 0.1.0 → 0.2.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/cli.js +123 -2
- package/config.d.ts +2 -0
- package/config.js +7 -1
- package/package.json +1 -1
- package/worker/index.js +343 -231
- package/worker/index.js.map +1 -1
package/worker/index.js
CHANGED
|
@@ -23940,13 +23940,13 @@ function initializeContext(params) {
|
|
|
23940
23940
|
};
|
|
23941
23941
|
}
|
|
23942
23942
|
__name(initializeContext, "initializeContext");
|
|
23943
|
-
function handleUnrepresentable(schema, ctx,
|
|
23943
|
+
function handleUnrepresentable(schema, ctx, json3, params, message) {
|
|
23944
23944
|
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
23945
23945
|
if (result === "any")
|
|
23946
23946
|
return false;
|
|
23947
23947
|
if (result === void 0 || result === "throw")
|
|
23948
23948
|
throw new Error(message);
|
|
23949
|
-
Object.assign(
|
|
23949
|
+
Object.assign(json3, result);
|
|
23950
23950
|
return true;
|
|
23951
23951
|
}
|
|
23952
23952
|
__name(handleUnrepresentable, "handleUnrepresentable");
|
|
@@ -24189,12 +24189,12 @@ function foldObjects(members2) {
|
|
|
24189
24189
|
return folded;
|
|
24190
24190
|
}
|
|
24191
24191
|
__name(foldObjects, "foldObjects");
|
|
24192
|
-
function foldIntersection(
|
|
24193
|
-
const allOf =
|
|
24192
|
+
function foldIntersection(json3) {
|
|
24193
|
+
const allOf = json3.allOf;
|
|
24194
24194
|
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
24195
24195
|
return;
|
|
24196
24196
|
for (const key of FOLDABLE_KEYS)
|
|
24197
|
-
if (key in
|
|
24197
|
+
if (key in json3)
|
|
24198
24198
|
return;
|
|
24199
24199
|
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
24200
24200
|
let folded = null;
|
|
@@ -24213,8 +24213,8 @@ function foldIntersection(json2) {
|
|
|
24213
24213
|
}
|
|
24214
24214
|
if (!folded)
|
|
24215
24215
|
return;
|
|
24216
|
-
delete
|
|
24217
|
-
assignProps(
|
|
24216
|
+
delete json3.allOf;
|
|
24217
|
+
assignProps(json3, folded);
|
|
24218
24218
|
}
|
|
24219
24219
|
__name(foldIntersection, "foldIntersection");
|
|
24220
24220
|
function finalize(ctx, schema) {
|
|
@@ -24297,20 +24297,20 @@ function finalize(ctx, schema) {
|
|
|
24297
24297
|
if (ctx.intersections.length) {
|
|
24298
24298
|
const carriers = /* @__PURE__ */ new Map();
|
|
24299
24299
|
for (const seen of ctx.seen.values()) {
|
|
24300
|
-
for (const
|
|
24301
|
-
const allOf =
|
|
24300
|
+
for (const json3 of [seen.schema, seen.def]) {
|
|
24301
|
+
const allOf = json3?.allOf;
|
|
24302
24302
|
if (!Array.isArray(allOf))
|
|
24303
24303
|
continue;
|
|
24304
24304
|
const existing = carriers.get(allOf);
|
|
24305
24305
|
if (existing)
|
|
24306
|
-
existing.push(
|
|
24306
|
+
existing.push(json3);
|
|
24307
24307
|
else
|
|
24308
|
-
carriers.set(allOf, [
|
|
24308
|
+
carriers.set(allOf, [json3]);
|
|
24309
24309
|
}
|
|
24310
24310
|
}
|
|
24311
24311
|
for (const allOf of ctx.intersections) {
|
|
24312
|
-
for (const
|
|
24313
|
-
foldIntersection(
|
|
24312
|
+
for (const json3 of carriers.get(allOf) ?? [])
|
|
24313
|
+
foldIntersection(json3);
|
|
24314
24314
|
}
|
|
24315
24315
|
}
|
|
24316
24316
|
}
|
|
@@ -24548,29 +24548,29 @@ var exactPatterns = /* @__PURE__ */ new Map([
|
|
|
24548
24548
|
]);
|
|
24549
24549
|
var exactPattern = /* @__PURE__ */ __name((p) => exactPatterns.get(p) ?? p, "exactPattern");
|
|
24550
24550
|
var stringProcessor = /* @__PURE__ */ __name((schema, ctx, _json, _params) => {
|
|
24551
|
-
const
|
|
24552
|
-
|
|
24551
|
+
const json3 = _json;
|
|
24552
|
+
json3.type = "string";
|
|
24553
24553
|
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
24554
24554
|
if (typeof minimum === "number")
|
|
24555
|
-
|
|
24555
|
+
json3.minLength = minimum;
|
|
24556
24556
|
if (typeof maximum === "number")
|
|
24557
|
-
|
|
24557
|
+
json3.maxLength = maximum;
|
|
24558
24558
|
if (format) {
|
|
24559
|
-
|
|
24560
|
-
if (
|
|
24561
|
-
delete
|
|
24559
|
+
json3.format = formatMap[format] ?? format;
|
|
24560
|
+
if (json3.format === "")
|
|
24561
|
+
delete json3.format;
|
|
24562
24562
|
if (format === "time" || laxFormat) {
|
|
24563
|
-
delete
|
|
24563
|
+
delete json3.format;
|
|
24564
24564
|
}
|
|
24565
24565
|
}
|
|
24566
24566
|
if (contentEncoding)
|
|
24567
|
-
|
|
24567
|
+
json3.contentEncoding = contentEncoding;
|
|
24568
24568
|
if (patterns && patterns.size > 0) {
|
|
24569
24569
|
const patternList = [...patterns].map(exactPattern);
|
|
24570
24570
|
if (patternList.length === 1)
|
|
24571
|
-
|
|
24571
|
+
json3.pattern = patternList[0].source;
|
|
24572
24572
|
else if (patternList.length > 1) {
|
|
24573
|
-
|
|
24573
|
+
json3.allOf = [
|
|
24574
24574
|
...patternList.map((regex) => ({
|
|
24575
24575
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
24576
24576
|
pattern: regex.source
|
|
@@ -24580,31 +24580,31 @@ var stringProcessor = /* @__PURE__ */ __name((schema, ctx, _json, _params) => {
|
|
|
24580
24580
|
}
|
|
24581
24581
|
}, "stringProcessor");
|
|
24582
24582
|
var numberProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
24583
|
-
const
|
|
24583
|
+
const json3 = _json;
|
|
24584
24584
|
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
24585
|
-
|
|
24585
|
+
json3.type = isInt ? "integer" : "number";
|
|
24586
24586
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
24587
24587
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
24588
24588
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
24589
24589
|
if (exMin) {
|
|
24590
24590
|
if (legacy) {
|
|
24591
|
-
|
|
24592
|
-
|
|
24591
|
+
json3.minimum = exclusiveMinimum;
|
|
24592
|
+
json3.exclusiveMinimum = true;
|
|
24593
24593
|
} else {
|
|
24594
|
-
|
|
24594
|
+
json3.exclusiveMinimum = exclusiveMinimum;
|
|
24595
24595
|
}
|
|
24596
24596
|
} else if (typeof minimum === "number") {
|
|
24597
|
-
|
|
24597
|
+
json3.minimum = minimum;
|
|
24598
24598
|
}
|
|
24599
24599
|
if (exMax) {
|
|
24600
24600
|
if (legacy) {
|
|
24601
|
-
|
|
24602
|
-
|
|
24601
|
+
json3.maximum = exclusiveMaximum;
|
|
24602
|
+
json3.exclusiveMaximum = true;
|
|
24603
24603
|
} else {
|
|
24604
|
-
|
|
24604
|
+
json3.exclusiveMaximum = exclusiveMaximum;
|
|
24605
24605
|
}
|
|
24606
24606
|
} else if (typeof maximum === "number") {
|
|
24607
|
-
|
|
24607
|
+
json3.maximum = maximum;
|
|
24608
24608
|
}
|
|
24609
24609
|
if (multipleOf) {
|
|
24610
24610
|
const divisors = /* @__PURE__ */ new Set();
|
|
@@ -24612,75 +24612,75 @@ var numberProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
|
24612
24612
|
if (Number.isFinite(divisor) && divisor !== 0)
|
|
24613
24613
|
divisors.add(Math.abs(divisor));
|
|
24614
24614
|
else
|
|
24615
|
-
handleUnrepresentable(schema, ctx,
|
|
24615
|
+
handleUnrepresentable(schema, ctx, json3, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
24616
24616
|
}
|
|
24617
24617
|
const [first, ...rest] = divisors;
|
|
24618
24618
|
if (first !== void 0)
|
|
24619
|
-
|
|
24619
|
+
json3.multipleOf = first;
|
|
24620
24620
|
if (rest.length)
|
|
24621
|
-
|
|
24621
|
+
json3.allOf = [...json3.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
24622
24622
|
}
|
|
24623
24623
|
}, "numberProcessor");
|
|
24624
|
-
var booleanProcessor = /* @__PURE__ */ __name((_schema, _ctx,
|
|
24625
|
-
|
|
24624
|
+
var booleanProcessor = /* @__PURE__ */ __name((_schema, _ctx, json3, _params) => {
|
|
24625
|
+
json3.type = "boolean";
|
|
24626
24626
|
}, "booleanProcessor");
|
|
24627
|
-
var bigintProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24628
|
-
handleUnrepresentable(schema, ctx,
|
|
24627
|
+
var bigintProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24628
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt cannot be represented in JSON Schema");
|
|
24629
24629
|
}, "bigintProcessor");
|
|
24630
|
-
var symbolProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24631
|
-
handleUnrepresentable(schema, ctx,
|
|
24630
|
+
var symbolProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24631
|
+
handleUnrepresentable(schema, ctx, json3, params, "Symbols cannot be represented in JSON Schema");
|
|
24632
24632
|
}, "symbolProcessor");
|
|
24633
|
-
var nullProcessor = /* @__PURE__ */ __name((_schema, ctx,
|
|
24633
|
+
var nullProcessor = /* @__PURE__ */ __name((_schema, ctx, json3, _params) => {
|
|
24634
24634
|
if (ctx.target === "openapi-3.0") {
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
24635
|
+
json3.type = "string";
|
|
24636
|
+
json3.nullable = true;
|
|
24637
|
+
json3.enum = [null];
|
|
24638
24638
|
} else {
|
|
24639
|
-
|
|
24639
|
+
json3.type = "null";
|
|
24640
24640
|
}
|
|
24641
24641
|
}, "nullProcessor");
|
|
24642
|
-
var undefinedProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24643
|
-
handleUnrepresentable(schema, ctx,
|
|
24642
|
+
var undefinedProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24643
|
+
handleUnrepresentable(schema, ctx, json3, params, "Undefined cannot be represented in JSON Schema");
|
|
24644
24644
|
}, "undefinedProcessor");
|
|
24645
|
-
var voidProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24646
|
-
handleUnrepresentable(schema, ctx,
|
|
24645
|
+
var voidProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24646
|
+
handleUnrepresentable(schema, ctx, json3, params, "Void cannot be represented in JSON Schema");
|
|
24647
24647
|
}, "voidProcessor");
|
|
24648
|
-
var neverProcessor = /* @__PURE__ */ __name((_schema, _ctx,
|
|
24649
|
-
|
|
24648
|
+
var neverProcessor = /* @__PURE__ */ __name((_schema, _ctx, json3, _params) => {
|
|
24649
|
+
json3.not = {};
|
|
24650
24650
|
}, "neverProcessor");
|
|
24651
24651
|
var anyProcessor = /* @__PURE__ */ __name((_schema, _ctx, _json, _params) => {
|
|
24652
24652
|
}, "anyProcessor");
|
|
24653
24653
|
var unknownProcessor = /* @__PURE__ */ __name((_schema, _ctx, _json, _params) => {
|
|
24654
24654
|
}, "unknownProcessor");
|
|
24655
|
-
var dateProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24656
|
-
handleUnrepresentable(schema, ctx,
|
|
24655
|
+
var dateProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24656
|
+
handleUnrepresentable(schema, ctx, json3, params, "Date cannot be represented in JSON Schema");
|
|
24657
24657
|
}, "dateProcessor");
|
|
24658
|
-
var enumProcessor = /* @__PURE__ */ __name((schema, _ctx,
|
|
24658
|
+
var enumProcessor = /* @__PURE__ */ __name((schema, _ctx, json3, _params) => {
|
|
24659
24659
|
const def = schema._zod.def;
|
|
24660
24660
|
const values = getEnumValues(def.entries);
|
|
24661
24661
|
if (values.length === 0) {
|
|
24662
|
-
|
|
24662
|
+
json3.not = {};
|
|
24663
24663
|
return;
|
|
24664
24664
|
}
|
|
24665
24665
|
if (values.every((v) => typeof v === "number"))
|
|
24666
|
-
|
|
24666
|
+
json3.type = "number";
|
|
24667
24667
|
if (values.every((v) => typeof v === "string"))
|
|
24668
|
-
|
|
24669
|
-
|
|
24668
|
+
json3.type = "string";
|
|
24669
|
+
json3.enum = values;
|
|
24670
24670
|
}, "enumProcessor");
|
|
24671
|
-
var literalProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24671
|
+
var literalProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24672
24672
|
const def = schema._zod.def;
|
|
24673
24673
|
if (def.values.length === 0) {
|
|
24674
|
-
|
|
24674
|
+
json3.not = {};
|
|
24675
24675
|
return;
|
|
24676
24676
|
}
|
|
24677
24677
|
const vals = [];
|
|
24678
24678
|
for (const val of def.values) {
|
|
24679
24679
|
if (val === void 0) {
|
|
24680
|
-
if (handleUnrepresentable(schema, ctx,
|
|
24680
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
24681
24681
|
return;
|
|
24682
24682
|
} else if (typeof val === "bigint") {
|
|
24683
|
-
if (handleUnrepresentable(schema, ctx,
|
|
24683
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
24684
24684
|
return;
|
|
24685
24685
|
vals.push(Number(val));
|
|
24686
24686
|
} else {
|
|
@@ -24690,37 +24690,37 @@ var literalProcessor = /* @__PURE__ */ __name((schema, ctx, json2, params) => {
|
|
|
24690
24690
|
if (vals.length === 0) {
|
|
24691
24691
|
} else if (vals.length === 1) {
|
|
24692
24692
|
const val = vals[0];
|
|
24693
|
-
|
|
24693
|
+
json3.type = val === null ? "null" : typeof val;
|
|
24694
24694
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
24695
|
-
|
|
24695
|
+
json3.enum = [val];
|
|
24696
24696
|
} else {
|
|
24697
|
-
|
|
24697
|
+
json3.const = val;
|
|
24698
24698
|
}
|
|
24699
24699
|
} else {
|
|
24700
24700
|
if (vals.every((v) => typeof v === "number"))
|
|
24701
|
-
|
|
24701
|
+
json3.type = "number";
|
|
24702
24702
|
if (vals.every((v) => typeof v === "string"))
|
|
24703
|
-
|
|
24703
|
+
json3.type = "string";
|
|
24704
24704
|
if (vals.every((v) => typeof v === "boolean"))
|
|
24705
|
-
|
|
24705
|
+
json3.type = "boolean";
|
|
24706
24706
|
if (vals.every((v) => v === null))
|
|
24707
|
-
|
|
24708
|
-
|
|
24707
|
+
json3.type = "null";
|
|
24708
|
+
json3.enum = vals;
|
|
24709
24709
|
}
|
|
24710
24710
|
}, "literalProcessor");
|
|
24711
|
-
var nanProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24712
|
-
handleUnrepresentable(schema, ctx,
|
|
24711
|
+
var nanProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24712
|
+
handleUnrepresentable(schema, ctx, json3, params, "NaN cannot be represented in JSON Schema");
|
|
24713
24713
|
}, "nanProcessor");
|
|
24714
|
-
var templateLiteralProcessor = /* @__PURE__ */ __name((schema, _ctx,
|
|
24715
|
-
const _json =
|
|
24714
|
+
var templateLiteralProcessor = /* @__PURE__ */ __name((schema, _ctx, json3, _params) => {
|
|
24715
|
+
const _json = json3;
|
|
24716
24716
|
const pattern = schema._zod.pattern;
|
|
24717
24717
|
if (!pattern)
|
|
24718
24718
|
throw new Error("Pattern not found in template literal");
|
|
24719
24719
|
_json.type = "string";
|
|
24720
24720
|
_json.pattern = pattern.source;
|
|
24721
24721
|
}, "templateLiteralProcessor");
|
|
24722
|
-
var fileProcessor = /* @__PURE__ */ __name((schema, _ctx,
|
|
24723
|
-
const _json =
|
|
24722
|
+
var fileProcessor = /* @__PURE__ */ __name((schema, _ctx, json3, _params) => {
|
|
24723
|
+
const _json = json3;
|
|
24724
24724
|
_json.type = "string";
|
|
24725
24725
|
_json.format = "binary";
|
|
24726
24726
|
_json.contentEncoding = "binary";
|
|
@@ -24738,34 +24738,34 @@ var fileProcessor = /* @__PURE__ */ __name((schema, _ctx, json2, _params) => {
|
|
|
24738
24738
|
else
|
|
24739
24739
|
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
24740
24740
|
}, "fileProcessor");
|
|
24741
|
-
var successProcessor = /* @__PURE__ */ __name((_schema, _ctx,
|
|
24742
|
-
|
|
24741
|
+
var successProcessor = /* @__PURE__ */ __name((_schema, _ctx, json3, _params) => {
|
|
24742
|
+
json3.type = "boolean";
|
|
24743
24743
|
}, "successProcessor");
|
|
24744
|
-
var customProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24745
|
-
handleUnrepresentable(schema, ctx,
|
|
24744
|
+
var customProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24745
|
+
handleUnrepresentable(schema, ctx, json3, params, "Custom types cannot be represented in JSON Schema");
|
|
24746
24746
|
}, "customProcessor");
|
|
24747
|
-
var functionProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24748
|
-
handleUnrepresentable(schema, ctx,
|
|
24747
|
+
var functionProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24748
|
+
handleUnrepresentable(schema, ctx, json3, params, "Function types cannot be represented in JSON Schema");
|
|
24749
24749
|
}, "functionProcessor");
|
|
24750
|
-
var transformProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24751
|
-
handleUnrepresentable(schema, ctx,
|
|
24750
|
+
var transformProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24751
|
+
handleUnrepresentable(schema, ctx, json3, params, "Transforms cannot be represented in JSON Schema");
|
|
24752
24752
|
}, "transformProcessor");
|
|
24753
|
-
var mapProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24754
|
-
handleUnrepresentable(schema, ctx,
|
|
24753
|
+
var mapProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24754
|
+
handleUnrepresentable(schema, ctx, json3, params, "Map cannot be represented in JSON Schema");
|
|
24755
24755
|
}, "mapProcessor");
|
|
24756
|
-
var setProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24757
|
-
handleUnrepresentable(schema, ctx,
|
|
24756
|
+
var setProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24757
|
+
handleUnrepresentable(schema, ctx, json3, params, "Set cannot be represented in JSON Schema");
|
|
24758
24758
|
}, "setProcessor");
|
|
24759
24759
|
var arrayProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
24760
|
-
const
|
|
24760
|
+
const json3 = _json;
|
|
24761
24761
|
const def = schema._zod.def;
|
|
24762
24762
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
24763
24763
|
if (typeof minimum === "number")
|
|
24764
|
-
|
|
24764
|
+
json3.minItems = minimum;
|
|
24765
24765
|
if (typeof maximum === "number")
|
|
24766
|
-
|
|
24767
|
-
|
|
24768
|
-
|
|
24766
|
+
json3.maxItems = maximum;
|
|
24767
|
+
json3.type = "array";
|
|
24768
|
+
json3.items = processSchema(def.element, ctx, {
|
|
24769
24769
|
...params,
|
|
24770
24770
|
path: [...params.path, "items"]
|
|
24771
24771
|
});
|
|
@@ -24782,17 +24782,17 @@ function inputOptin(schema) {
|
|
|
24782
24782
|
}
|
|
24783
24783
|
__name(inputOptin, "inputOptin");
|
|
24784
24784
|
var objectProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
24785
|
-
const
|
|
24785
|
+
const json3 = _json;
|
|
24786
24786
|
const def = schema._zod.def;
|
|
24787
24787
|
const shape = def.shape;
|
|
24788
24788
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
24789
|
-
if (symbolKeys.length && handleUnrepresentable(schema, ctx,
|
|
24789
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json3, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
24790
24790
|
return;
|
|
24791
24791
|
}
|
|
24792
|
-
|
|
24793
|
-
|
|
24792
|
+
json3.type = "object";
|
|
24793
|
+
json3.properties = {};
|
|
24794
24794
|
for (const key in shape) {
|
|
24795
|
-
assignProp(
|
|
24795
|
+
assignProp(json3.properties, key, processSchema(shape[key], ctx, {
|
|
24796
24796
|
...params,
|
|
24797
24797
|
path: [...params.path, "properties", key]
|
|
24798
24798
|
}));
|
|
@@ -24805,21 +24805,21 @@ var objectProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
|
24805
24805
|
}
|
|
24806
24806
|
}
|
|
24807
24807
|
if (requiredKeys.length > 0) {
|
|
24808
|
-
|
|
24808
|
+
json3.required = requiredKeys;
|
|
24809
24809
|
}
|
|
24810
24810
|
if (def.catchall?._zod.def.type === "never") {
|
|
24811
|
-
|
|
24811
|
+
json3.additionalProperties = false;
|
|
24812
24812
|
} else if (!def.catchall) {
|
|
24813
24813
|
if (ctx.io === "output")
|
|
24814
|
-
|
|
24814
|
+
json3.additionalProperties = false;
|
|
24815
24815
|
} else if (def.catchall) {
|
|
24816
|
-
|
|
24816
|
+
json3.additionalProperties = processSchema(def.catchall, ctx, {
|
|
24817
24817
|
...params,
|
|
24818
24818
|
path: [...params.path, "additionalProperties"]
|
|
24819
24819
|
});
|
|
24820
24820
|
}
|
|
24821
24821
|
}, "objectProcessor");
|
|
24822
|
-
var unionProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24822
|
+
var unionProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24823
24823
|
const def = schema._zod.def;
|
|
24824
24824
|
const isExclusive = def.inclusive === false;
|
|
24825
24825
|
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
@@ -24827,12 +24827,12 @@ var unionProcessor = /* @__PURE__ */ __name((schema, ctx, json2, params) => {
|
|
|
24827
24827
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
24828
24828
|
}));
|
|
24829
24829
|
if (isExclusive) {
|
|
24830
|
-
|
|
24830
|
+
json3.oneOf = options;
|
|
24831
24831
|
} else {
|
|
24832
|
-
|
|
24832
|
+
json3.anyOf = options;
|
|
24833
24833
|
}
|
|
24834
24834
|
}, "unionProcessor");
|
|
24835
|
-
var intersectionProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
24835
|
+
var intersectionProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
24836
24836
|
const def = schema._zod.def;
|
|
24837
24837
|
const a = processSchema(def.left, ctx, {
|
|
24838
24838
|
...params,
|
|
@@ -24847,13 +24847,13 @@ var intersectionProcessor = /* @__PURE__ */ __name((schema, ctx, json2, params)
|
|
|
24847
24847
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
24848
24848
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
24849
24849
|
];
|
|
24850
|
-
|
|
24850
|
+
json3.allOf = allOf;
|
|
24851
24851
|
ctx.intersections.push(allOf);
|
|
24852
24852
|
}, "intersectionProcessor");
|
|
24853
24853
|
var tupleProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
24854
|
-
const
|
|
24854
|
+
const json3 = _json;
|
|
24855
24855
|
const def = schema._zod.def;
|
|
24856
|
-
|
|
24856
|
+
json3.type = "array";
|
|
24857
24857
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
24858
24858
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
24859
24859
|
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
@@ -24875,70 +24875,70 @@ var tupleProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
|
24875
24875
|
const maxItems = def.items.length;
|
|
24876
24876
|
const isClosed = !def.rest;
|
|
24877
24877
|
if (ctx.target === "draft-2020-12") {
|
|
24878
|
-
|
|
24878
|
+
json3.prefixItems = prefixItems;
|
|
24879
24879
|
if (isClosed) {
|
|
24880
|
-
|
|
24880
|
+
json3.items = false;
|
|
24881
24881
|
} else if (rest) {
|
|
24882
|
-
|
|
24882
|
+
json3.items = rest;
|
|
24883
24883
|
}
|
|
24884
24884
|
if (minItems > 0)
|
|
24885
|
-
|
|
24885
|
+
json3.minItems = minItems;
|
|
24886
24886
|
if (isClosed)
|
|
24887
|
-
|
|
24887
|
+
json3.maxItems = maxItems;
|
|
24888
24888
|
} else if (ctx.target === "openapi-3.0") {
|
|
24889
|
-
|
|
24889
|
+
json3.items = {
|
|
24890
24890
|
anyOf: prefixItems
|
|
24891
24891
|
};
|
|
24892
24892
|
if (rest) {
|
|
24893
|
-
|
|
24893
|
+
json3.items.anyOf.push(rest);
|
|
24894
24894
|
}
|
|
24895
24895
|
if (minItems > 0)
|
|
24896
|
-
|
|
24896
|
+
json3.minItems = minItems;
|
|
24897
24897
|
if (isClosed)
|
|
24898
|
-
|
|
24898
|
+
json3.maxItems = maxItems;
|
|
24899
24899
|
} else {
|
|
24900
|
-
|
|
24900
|
+
json3.items = prefixItems;
|
|
24901
24901
|
if (isClosed) {
|
|
24902
|
-
|
|
24902
|
+
json3.additionalItems = false;
|
|
24903
24903
|
} else if (rest) {
|
|
24904
|
-
|
|
24904
|
+
json3.additionalItems = rest;
|
|
24905
24905
|
}
|
|
24906
24906
|
if (minItems > 0)
|
|
24907
|
-
|
|
24907
|
+
json3.minItems = minItems;
|
|
24908
24908
|
if (isClosed)
|
|
24909
|
-
|
|
24909
|
+
json3.maxItems = maxItems;
|
|
24910
24910
|
}
|
|
24911
24911
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
24912
24912
|
if (typeof minimum === "number")
|
|
24913
|
-
|
|
24913
|
+
json3.minItems = minimum;
|
|
24914
24914
|
if (typeof maximum === "number")
|
|
24915
|
-
|
|
24915
|
+
json3.maxItems = maximum;
|
|
24916
24916
|
}, "tupleProcessor");
|
|
24917
|
-
function stringifyKeyNames(bySchema,
|
|
24918
|
-
if (
|
|
24919
|
-
if (visited.has(
|
|
24920
|
-
return
|
|
24921
|
-
visited.add(
|
|
24922
|
-
const def = bySchema.get(
|
|
24917
|
+
function stringifyKeyNames(bySchema, json3, visited) {
|
|
24918
|
+
if (json3.$ref) {
|
|
24919
|
+
if (visited.has(json3))
|
|
24920
|
+
return json3;
|
|
24921
|
+
visited.add(json3);
|
|
24922
|
+
const def = bySchema.get(json3)?.def;
|
|
24923
24923
|
if (!def)
|
|
24924
|
-
return
|
|
24924
|
+
return json3;
|
|
24925
24925
|
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
24926
|
-
return inlined === def ?
|
|
24926
|
+
return inlined === def ? json3 : inlined;
|
|
24927
24927
|
}
|
|
24928
24928
|
for (const keyword of ["anyOf", "oneOf"]) {
|
|
24929
|
-
const branches =
|
|
24929
|
+
const branches = json3[keyword];
|
|
24930
24930
|
if (!Array.isArray(branches))
|
|
24931
24931
|
continue;
|
|
24932
24932
|
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
24933
24933
|
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
24934
|
-
|
|
24934
|
+
json3 = { ...json3, [keyword]: mapped };
|
|
24935
24935
|
}
|
|
24936
|
-
const types = Array.isArray(
|
|
24936
|
+
const types = Array.isArray(json3.type) ? json3.type : [json3.type];
|
|
24937
24937
|
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
24938
|
-
const values =
|
|
24938
|
+
const values = json3.enum ?? (json3.const !== void 0 ? [json3.const] : void 0);
|
|
24939
24939
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
24940
|
-
return
|
|
24941
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } =
|
|
24940
|
+
return json3;
|
|
24941
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json3;
|
|
24942
24942
|
if (rest.enum)
|
|
24943
24943
|
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
24944
24944
|
else if (typeof rest.const === "number")
|
|
@@ -24980,9 +24980,9 @@ function rewriteKeyNames(ctx) {
|
|
|
24980
24980
|
}
|
|
24981
24981
|
__name(rewriteKeyNames, "rewriteKeyNames");
|
|
24982
24982
|
var recordProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
24983
|
-
const
|
|
24983
|
+
const json3 = _json;
|
|
24984
24984
|
const def = schema._zod.def;
|
|
24985
|
-
|
|
24985
|
+
json3.type = "object";
|
|
24986
24986
|
const keyType = def.keyType;
|
|
24987
24987
|
const patterns = aggregateChecks(keyType).patterns;
|
|
24988
24988
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
@@ -24990,13 +24990,13 @@ var recordProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
|
24990
24990
|
...params,
|
|
24991
24991
|
path: [...params.path, "patternProperties", "*"]
|
|
24992
24992
|
});
|
|
24993
|
-
|
|
24993
|
+
json3.patternProperties = {};
|
|
24994
24994
|
for (const pattern of patterns) {
|
|
24995
|
-
assignProp(
|
|
24995
|
+
assignProp(json3.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
24996
24996
|
}
|
|
24997
24997
|
} else {
|
|
24998
24998
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
24999
|
-
|
|
24999
|
+
json3.propertyNames = processSchema(def.keyType, ctx, {
|
|
25000
25000
|
...params,
|
|
25001
25001
|
path: [...params.path, "propertyNames"]
|
|
25002
25002
|
});
|
|
@@ -25008,7 +25008,7 @@ var recordProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
|
25008
25008
|
}
|
|
25009
25009
|
pending.push(schema);
|
|
25010
25010
|
}
|
|
25011
|
-
|
|
25011
|
+
json3.additionalProperties = processSchema(def.valueType, ctx, {
|
|
25012
25012
|
...params,
|
|
25013
25013
|
path: [...params.path, "additionalProperties"]
|
|
25014
25014
|
});
|
|
@@ -25018,19 +25018,19 @@ var recordProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
|
25018
25018
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
25019
25019
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
25020
25020
|
if (validKeyValues.length > 0) {
|
|
25021
|
-
|
|
25021
|
+
json3.required = validKeyValues.map(String);
|
|
25022
25022
|
}
|
|
25023
25023
|
}
|
|
25024
25024
|
}, "recordProcessor");
|
|
25025
|
-
var nullableProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
25025
|
+
var nullableProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
25026
25026
|
const def = schema._zod.def;
|
|
25027
25027
|
const inner = processSchema(def.innerType, ctx, params);
|
|
25028
25028
|
const seen = ctx.seen.get(schema);
|
|
25029
25029
|
if (ctx.target === "openapi-3.0") {
|
|
25030
25030
|
seen.ref = def.innerType;
|
|
25031
|
-
|
|
25031
|
+
json3.nullable = true;
|
|
25032
25032
|
} else {
|
|
25033
|
-
|
|
25033
|
+
json3.anyOf = [inner, { type: "null" }];
|
|
25034
25034
|
}
|
|
25035
25035
|
}, "nullableProcessor");
|
|
25036
25036
|
var nonoptionalProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
@@ -25040,7 +25040,7 @@ var nonoptionalProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) =
|
|
|
25040
25040
|
seen.ref = def.innerType;
|
|
25041
25041
|
}, "nonoptionalProcessor");
|
|
25042
25042
|
var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
|
|
25043
|
-
function serializeDefaultValue(value, schema, ctx,
|
|
25043
|
+
function serializeDefaultValue(value, schema, ctx, json3, params) {
|
|
25044
25044
|
let unrepresentable = false;
|
|
25045
25045
|
const serialized = JSON.stringify(value, (_, val) => {
|
|
25046
25046
|
if (typeof val !== "bigint")
|
|
@@ -25050,31 +25050,31 @@ function serializeDefaultValue(value, schema, ctx, json2, params) {
|
|
|
25050
25050
|
});
|
|
25051
25051
|
if (!unrepresentable)
|
|
25052
25052
|
return JSON.parse(serialized);
|
|
25053
|
-
handleUnrepresentable(schema, ctx,
|
|
25053
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
25054
25054
|
return UNREPRESENTABLE_DEFAULT;
|
|
25055
25055
|
}
|
|
25056
25056
|
__name(serializeDefaultValue, "serializeDefaultValue");
|
|
25057
|
-
var defaultProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
25057
|
+
var defaultProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
25058
25058
|
const def = schema._zod.def;
|
|
25059
25059
|
processSchema(def.innerType, ctx, params);
|
|
25060
25060
|
const seen = ctx.seen.get(schema);
|
|
25061
25061
|
seen.ref = def.innerType;
|
|
25062
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
25062
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
25063
25063
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
25064
|
-
|
|
25064
|
+
json3.default = value;
|
|
25065
25065
|
}, "defaultProcessor");
|
|
25066
|
-
var prefaultProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
25066
|
+
var prefaultProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
25067
25067
|
const def = schema._zod.def;
|
|
25068
25068
|
processSchema(def.innerType, ctx, params);
|
|
25069
25069
|
const seen = ctx.seen.get(schema);
|
|
25070
25070
|
seen.ref = def.innerType;
|
|
25071
25071
|
if (ctx.io !== "input")
|
|
25072
25072
|
return;
|
|
25073
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
25073
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
25074
25074
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
25075
|
-
|
|
25075
|
+
json3._prefault = value;
|
|
25076
25076
|
}, "prefaultProcessor");
|
|
25077
|
-
var catchProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
25077
|
+
var catchProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
25078
25078
|
const def = schema._zod.def;
|
|
25079
25079
|
processSchema(def.innerType, ctx, params);
|
|
25080
25080
|
const seen = ctx.seen.get(schema);
|
|
@@ -25083,10 +25083,10 @@ var catchProcessor = /* @__PURE__ */ __name((schema, ctx, json2, params) => {
|
|
|
25083
25083
|
try {
|
|
25084
25084
|
catchValue = def.catchValue(void 0);
|
|
25085
25085
|
} catch {
|
|
25086
|
-
handleUnrepresentable(schema, ctx,
|
|
25086
|
+
handleUnrepresentable(schema, ctx, json3, params, "Dynamic catch values are not supported in JSON Schema");
|
|
25087
25087
|
return;
|
|
25088
25088
|
}
|
|
25089
|
-
|
|
25089
|
+
json3.default = catchValue;
|
|
25090
25090
|
}, "catchProcessor");
|
|
25091
25091
|
var pipeProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
25092
25092
|
const def = schema._zod.def;
|
|
@@ -25096,12 +25096,12 @@ var pipeProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
|
25096
25096
|
const seen = ctx.seen.get(schema);
|
|
25097
25097
|
seen.ref = innerType;
|
|
25098
25098
|
}, "pipeProcessor");
|
|
25099
|
-
var readonlyProcessor = /* @__PURE__ */ __name((schema, ctx,
|
|
25099
|
+
var readonlyProcessor = /* @__PURE__ */ __name((schema, ctx, json3, params) => {
|
|
25100
25100
|
const def = schema._zod.def;
|
|
25101
25101
|
processSchema(def.innerType, ctx, params);
|
|
25102
25102
|
const seen = ctx.seen.get(schema);
|
|
25103
25103
|
seen.ref = def.innerType;
|
|
25104
|
-
|
|
25104
|
+
json3.readOnly = true;
|
|
25105
25105
|
}, "readonlyProcessor");
|
|
25106
25106
|
var promiseProcessor = /* @__PURE__ */ __name((schema, ctx, _json, params) => {
|
|
25107
25107
|
const def = schema._zod.def;
|
|
@@ -25750,7 +25750,7 @@ var _ZodString = /* @__PURE__ */ $constructor(
|
|
|
25750
25750
|
(inst, def) => {
|
|
25751
25751
|
$ZodString.init(inst, def);
|
|
25752
25752
|
ZodType.init(inst, def);
|
|
25753
|
-
inst._zod.processJSONSchema = (ctx,
|
|
25753
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => stringProcessor(inst, ctx, json3, params);
|
|
25754
25754
|
},
|
|
25755
25755
|
/* @__PURE__ */ util_exports.derived({
|
|
25756
25756
|
format: /* @__PURE__ */ __name((inst) => aggregateChecks(inst).format ?? null, "format"),
|
|
@@ -26141,7 +26141,7 @@ var ZodNumber = /* @__PURE__ */ $constructor(
|
|
|
26141
26141
|
(inst, def) => {
|
|
26142
26142
|
$ZodNumber.init(inst, def);
|
|
26143
26143
|
ZodType.init(inst, def);
|
|
26144
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26144
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => numberProcessor(inst, ctx, json3, params);
|
|
26145
26145
|
inst.isFinite = true;
|
|
26146
26146
|
},
|
|
26147
26147
|
/* @__PURE__ */ util_exports.derived({
|
|
@@ -26237,7 +26237,7 @@ __name(uint32, "uint32");
|
|
|
26237
26237
|
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
26238
26238
|
$ZodBoolean.init(inst, def);
|
|
26239
26239
|
ZodType.init(inst, def);
|
|
26240
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26240
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => booleanProcessor(inst, ctx, json3, params);
|
|
26241
26241
|
});
|
|
26242
26242
|
function boolean2(params) {
|
|
26243
26243
|
return _boolean(ZodBoolean, params);
|
|
@@ -26248,7 +26248,7 @@ var ZodBigInt = /* @__PURE__ */ $constructor(
|
|
|
26248
26248
|
(inst, def) => {
|
|
26249
26249
|
$ZodBigInt.init(inst, def);
|
|
26250
26250
|
ZodType.init(inst, def);
|
|
26251
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26251
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => bigintProcessor(inst, ctx, json3, params);
|
|
26252
26252
|
},
|
|
26253
26253
|
/* @__PURE__ */ util_exports.derived({
|
|
26254
26254
|
minValue: /* @__PURE__ */ __name((inst) => aggregateChecks(inst).minimum ?? null, "minValue"),
|
|
@@ -26309,7 +26309,7 @@ __name(uint64, "uint64");
|
|
|
26309
26309
|
var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
26310
26310
|
$ZodSymbol.init(inst, def);
|
|
26311
26311
|
ZodType.init(inst, def);
|
|
26312
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26312
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => symbolProcessor(inst, ctx, json3, params);
|
|
26313
26313
|
});
|
|
26314
26314
|
function symbol(params) {
|
|
26315
26315
|
return _symbol(ZodSymbol, params);
|
|
@@ -26318,7 +26318,7 @@ __name(symbol, "symbol");
|
|
|
26318
26318
|
var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
26319
26319
|
$ZodUndefined.init(inst, def);
|
|
26320
26320
|
ZodType.init(inst, def);
|
|
26321
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26321
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => undefinedProcessor(inst, ctx, json3, params);
|
|
26322
26322
|
});
|
|
26323
26323
|
function _undefined3(params) {
|
|
26324
26324
|
return _undefined2(ZodUndefined, params);
|
|
@@ -26327,7 +26327,7 @@ __name(_undefined3, "_undefined");
|
|
|
26327
26327
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
26328
26328
|
$ZodNull.init(inst, def);
|
|
26329
26329
|
ZodType.init(inst, def);
|
|
26330
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26330
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullProcessor(inst, ctx, json3, params);
|
|
26331
26331
|
});
|
|
26332
26332
|
function _null3(params) {
|
|
26333
26333
|
return _null2(ZodNull, params);
|
|
@@ -26336,7 +26336,7 @@ __name(_null3, "_null");
|
|
|
26336
26336
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
26337
26337
|
$ZodAny.init(inst, def);
|
|
26338
26338
|
ZodType.init(inst, def);
|
|
26339
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26339
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => anyProcessor(inst, ctx, json3, params);
|
|
26340
26340
|
});
|
|
26341
26341
|
function any() {
|
|
26342
26342
|
return _any(ZodAny);
|
|
@@ -26345,7 +26345,7 @@ __name(any, "any");
|
|
|
26345
26345
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
26346
26346
|
$ZodUnknown.init(inst, def);
|
|
26347
26347
|
ZodType.init(inst, def);
|
|
26348
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26348
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unknownProcessor(inst, ctx, json3, params);
|
|
26349
26349
|
});
|
|
26350
26350
|
function unknown() {
|
|
26351
26351
|
return _unknown(ZodUnknown);
|
|
@@ -26354,7 +26354,7 @@ __name(unknown, "unknown");
|
|
|
26354
26354
|
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
26355
26355
|
$ZodNever.init(inst, def);
|
|
26356
26356
|
ZodType.init(inst, def);
|
|
26357
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26357
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => neverProcessor(inst, ctx, json3, params);
|
|
26358
26358
|
});
|
|
26359
26359
|
function never(params) {
|
|
26360
26360
|
return _never(ZodNever, params);
|
|
@@ -26363,7 +26363,7 @@ __name(never, "never");
|
|
|
26363
26363
|
var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
26364
26364
|
$ZodVoid.init(inst, def);
|
|
26365
26365
|
ZodType.init(inst, def);
|
|
26366
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26366
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => voidProcessor(inst, ctx, json3, params);
|
|
26367
26367
|
});
|
|
26368
26368
|
function _void2(params) {
|
|
26369
26369
|
return _void(ZodVoid, params);
|
|
@@ -26374,7 +26374,7 @@ var ZodDate = /* @__PURE__ */ $constructor(
|
|
|
26374
26374
|
(inst, def) => {
|
|
26375
26375
|
$ZodDate.init(inst, def);
|
|
26376
26376
|
ZodType.init(inst, def);
|
|
26377
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26377
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => dateProcessor(inst, ctx, json3, params);
|
|
26378
26378
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
26379
26379
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
26380
26380
|
},
|
|
@@ -26397,7 +26397,7 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
26397
26397
|
_ensureDefaultMemoizer();
|
|
26398
26398
|
$ZodArray.init(inst, def);
|
|
26399
26399
|
ZodType.init(inst, def);
|
|
26400
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26400
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => arrayProcessor(inst, ctx, json3, params);
|
|
26401
26401
|
inst.element = def.element;
|
|
26402
26402
|
}, {
|
|
26403
26403
|
min(n, params) {
|
|
@@ -26429,7 +26429,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
26429
26429
|
_ensureDefaultMemoizer();
|
|
26430
26430
|
$ZodObjectJIT.init(inst, def);
|
|
26431
26431
|
ZodType.init(inst, def);
|
|
26432
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26432
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => objectProcessor(inst, ctx, json3, params);
|
|
26433
26433
|
util_exports.installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
26434
26434
|
}, {
|
|
26435
26435
|
keyof() {
|
|
@@ -26505,7 +26505,7 @@ __name(looseObject, "looseObject");
|
|
|
26505
26505
|
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
26506
26506
|
$ZodUnion.init(inst, def);
|
|
26507
26507
|
ZodType.init(inst, def);
|
|
26508
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26508
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
26509
26509
|
inst.options = def.options;
|
|
26510
26510
|
});
|
|
26511
26511
|
function union(options, params) {
|
|
@@ -26519,7 +26519,7 @@ __name(union, "union");
|
|
|
26519
26519
|
var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
26520
26520
|
ZodUnion.init(inst, def);
|
|
26521
26521
|
$ZodXor.init(inst, def);
|
|
26522
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26522
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
26523
26523
|
inst.options = def.options;
|
|
26524
26524
|
});
|
|
26525
26525
|
function xor(options, params) {
|
|
@@ -26547,7 +26547,7 @@ __name(discriminatedUnion, "discriminatedUnion");
|
|
|
26547
26547
|
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
26548
26548
|
$ZodIntersection.init(inst, def);
|
|
26549
26549
|
ZodType.init(inst, def);
|
|
26550
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26550
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => intersectionProcessor(inst, ctx, json3, params);
|
|
26551
26551
|
});
|
|
26552
26552
|
function intersection(left, right) {
|
|
26553
26553
|
return new ZodIntersection({
|
|
@@ -26561,7 +26561,7 @@ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
|
26561
26561
|
_ensureDefaultMemoizer();
|
|
26562
26562
|
$ZodTuple.init(inst, def);
|
|
26563
26563
|
ZodType.init(inst, def);
|
|
26564
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26564
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => tupleProcessor(inst, ctx, json3, params);
|
|
26565
26565
|
}, {
|
|
26566
26566
|
rest(rest) {
|
|
26567
26567
|
return this.clone({
|
|
@@ -26595,7 +26595,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
26595
26595
|
_ensureDefaultMemoizer();
|
|
26596
26596
|
$ZodRecord.init(inst, def);
|
|
26597
26597
|
ZodType.init(inst, def);
|
|
26598
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26598
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => recordProcessor(inst, ctx, json3, params);
|
|
26599
26599
|
inst.keyType = def.keyType;
|
|
26600
26600
|
inst.valueType = def.valueType;
|
|
26601
26601
|
});
|
|
@@ -26640,7 +26640,7 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
26640
26640
|
_ensureDefaultMemoizer();
|
|
26641
26641
|
$ZodMap.init(inst, def);
|
|
26642
26642
|
ZodType.init(inst, def);
|
|
26643
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26643
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => mapProcessor(inst, ctx, json3, params);
|
|
26644
26644
|
inst.keyType = def.keyType;
|
|
26645
26645
|
inst.valueType = def.valueType;
|
|
26646
26646
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -26661,7 +26661,7 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
|
26661
26661
|
_ensureDefaultMemoizer();
|
|
26662
26662
|
$ZodSet.init(inst, def);
|
|
26663
26663
|
ZodType.init(inst, def);
|
|
26664
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26664
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => setProcessor(inst, ctx, json3, params);
|
|
26665
26665
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
26666
26666
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
26667
26667
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -26678,7 +26678,7 @@ __name(set, "set");
|
|
|
26678
26678
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
26679
26679
|
$ZodEnum.init(inst, def);
|
|
26680
26680
|
ZodType.init(inst, def);
|
|
26681
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26681
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => enumProcessor(inst, ctx, json3, params);
|
|
26682
26682
|
inst.enum = def.entries;
|
|
26683
26683
|
inst.options = [...inst._zod.values];
|
|
26684
26684
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -26733,7 +26733,7 @@ __name(nativeEnum, "nativeEnum");
|
|
|
26733
26733
|
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
26734
26734
|
$ZodLiteral.init(inst, def);
|
|
26735
26735
|
ZodType.init(inst, def);
|
|
26736
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26736
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => literalProcessor(inst, ctx, json3, params);
|
|
26737
26737
|
inst.values = new Set(def.values);
|
|
26738
26738
|
Object.defineProperty(inst, "value", {
|
|
26739
26739
|
get() {
|
|
@@ -26755,7 +26755,7 @@ __name(literal, "literal");
|
|
|
26755
26755
|
var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
26756
26756
|
$ZodFile.init(inst, def);
|
|
26757
26757
|
ZodType.init(inst, def);
|
|
26758
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26758
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => fileProcessor(inst, ctx, json3, params);
|
|
26759
26759
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
26760
26760
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
26761
26761
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
@@ -26768,7 +26768,7 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
26768
26768
|
_ensureDefaultMemoizer();
|
|
26769
26769
|
$ZodTransform.init(inst, def);
|
|
26770
26770
|
ZodType.init(inst, def);
|
|
26771
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26771
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => transformProcessor(inst, ctx, json3, params);
|
|
26772
26772
|
inst._zod.parse = (payload, _ctx) => {
|
|
26773
26773
|
if (_ctx.direction === "backward") {
|
|
26774
26774
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -26808,7 +26808,7 @@ __name(transform, "transform");
|
|
|
26808
26808
|
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
26809
26809
|
$ZodOptional.init(inst, def);
|
|
26810
26810
|
ZodType.init(inst, def);
|
|
26811
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26811
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
26812
26812
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26813
26813
|
});
|
|
26814
26814
|
function optional(innerType) {
|
|
@@ -26821,7 +26821,7 @@ __name(optional, "optional");
|
|
|
26821
26821
|
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
26822
26822
|
$ZodExactOptional.init(inst, def);
|
|
26823
26823
|
ZodType.init(inst, def);
|
|
26824
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26824
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
26825
26825
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26826
26826
|
});
|
|
26827
26827
|
function exactOptional(innerType) {
|
|
@@ -26834,7 +26834,7 @@ __name(exactOptional, "exactOptional");
|
|
|
26834
26834
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
26835
26835
|
$ZodNullable.init(inst, def);
|
|
26836
26836
|
ZodType.init(inst, def);
|
|
26837
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26837
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullableProcessor(inst, ctx, json3, params);
|
|
26838
26838
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26839
26839
|
});
|
|
26840
26840
|
function nullable(innerType) {
|
|
@@ -26851,7 +26851,7 @@ __name(nullish2, "nullish");
|
|
|
26851
26851
|
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
26852
26852
|
$ZodDefault.init(inst, def);
|
|
26853
26853
|
ZodType.init(inst, def);
|
|
26854
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26854
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => defaultProcessor(inst, ctx, json3, params);
|
|
26855
26855
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26856
26856
|
inst.removeDefault = inst.unwrap;
|
|
26857
26857
|
});
|
|
@@ -26868,7 +26868,7 @@ __name(_default2, "_default");
|
|
|
26868
26868
|
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
26869
26869
|
$ZodPrefault.init(inst, def);
|
|
26870
26870
|
ZodType.init(inst, def);
|
|
26871
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26871
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => prefaultProcessor(inst, ctx, json3, params);
|
|
26872
26872
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26873
26873
|
});
|
|
26874
26874
|
function prefault(innerType, defaultValue) {
|
|
@@ -26884,7 +26884,7 @@ __name(prefault, "prefault");
|
|
|
26884
26884
|
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
26885
26885
|
$ZodNonOptional.init(inst, def);
|
|
26886
26886
|
ZodType.init(inst, def);
|
|
26887
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26887
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nonoptionalProcessor(inst, ctx, json3, params);
|
|
26888
26888
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26889
26889
|
});
|
|
26890
26890
|
function nonoptional(innerType, params) {
|
|
@@ -26898,7 +26898,7 @@ __name(nonoptional, "nonoptional");
|
|
|
26898
26898
|
var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
26899
26899
|
$ZodSuccess.init(inst, def);
|
|
26900
26900
|
ZodType.init(inst, def);
|
|
26901
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26901
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => successProcessor(inst, ctx, json3, params);
|
|
26902
26902
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26903
26903
|
});
|
|
26904
26904
|
function success(innerType) {
|
|
@@ -26911,7 +26911,7 @@ __name(success, "success");
|
|
|
26911
26911
|
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
26912
26912
|
$ZodCatch.init(inst, def);
|
|
26913
26913
|
ZodType.init(inst, def);
|
|
26914
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26914
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => catchProcessor(inst, ctx, json3, params);
|
|
26915
26915
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26916
26916
|
inst.removeCatch = inst.unwrap;
|
|
26917
26917
|
});
|
|
@@ -26926,7 +26926,7 @@ __name(_catch2, "_catch");
|
|
|
26926
26926
|
var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
26927
26927
|
$ZodNaN.init(inst, def);
|
|
26928
26928
|
ZodType.init(inst, def);
|
|
26929
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26929
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nanProcessor(inst, ctx, json3, params);
|
|
26930
26930
|
});
|
|
26931
26931
|
function nan(params) {
|
|
26932
26932
|
return _nan(ZodNaN, params);
|
|
@@ -26935,7 +26935,7 @@ __name(nan, "nan");
|
|
|
26935
26935
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
26936
26936
|
$ZodPipe.init(inst, def);
|
|
26937
26937
|
ZodType.init(inst, def);
|
|
26938
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26938
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => pipeProcessor(inst, ctx, json3, params);
|
|
26939
26939
|
inst.in = def.in;
|
|
26940
26940
|
inst.out = def.out;
|
|
26941
26941
|
});
|
|
@@ -26980,7 +26980,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
|
|
|
26980
26980
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
26981
26981
|
$ZodReadonly.init(inst, def);
|
|
26982
26982
|
ZodType.init(inst, def);
|
|
26983
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26983
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => readonlyProcessor(inst, ctx, json3, params);
|
|
26984
26984
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
26985
26985
|
});
|
|
26986
26986
|
function readonly(innerType) {
|
|
@@ -26993,7 +26993,7 @@ __name(readonly, "readonly");
|
|
|
26993
26993
|
var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
26994
26994
|
$ZodTemplateLiteral.init(inst, def);
|
|
26995
26995
|
ZodType.init(inst, def);
|
|
26996
|
-
inst._zod.processJSONSchema = (ctx,
|
|
26996
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => templateLiteralProcessor(inst, ctx, json3, params);
|
|
26997
26997
|
});
|
|
26998
26998
|
function templateLiteral(parts, params) {
|
|
26999
26999
|
return new ZodTemplateLiteral({
|
|
@@ -27006,7 +27006,7 @@ __name(templateLiteral, "templateLiteral");
|
|
|
27006
27006
|
var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
27007
27007
|
$ZodLazy.init(inst, def);
|
|
27008
27008
|
ZodType.init(inst, def);
|
|
27009
|
-
inst._zod.processJSONSchema = (ctx,
|
|
27009
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => lazyProcessor(inst, ctx, json3, params);
|
|
27010
27010
|
inst.unwrap = () => inst._zod.def.getter();
|
|
27011
27011
|
});
|
|
27012
27012
|
function lazy(getter) {
|
|
@@ -27019,7 +27019,7 @@ __name(lazy, "lazy");
|
|
|
27019
27019
|
var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
27020
27020
|
$ZodPromise.init(inst, def);
|
|
27021
27021
|
ZodType.init(inst, def);
|
|
27022
|
-
inst._zod.processJSONSchema = (ctx,
|
|
27022
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => promiseProcessor(inst, ctx, json3, params);
|
|
27023
27023
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
27024
27024
|
});
|
|
27025
27025
|
function promise(innerType) {
|
|
@@ -27032,7 +27032,7 @@ __name(promise, "promise");
|
|
|
27032
27032
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
27033
27033
|
$ZodFunction.init(inst, def);
|
|
27034
27034
|
ZodType.init(inst, def);
|
|
27035
|
-
inst._zod.processJSONSchema = (ctx,
|
|
27035
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => functionProcessor(inst, ctx, json3, params);
|
|
27036
27036
|
});
|
|
27037
27037
|
function _function(params) {
|
|
27038
27038
|
return new ZodFunction({
|
|
@@ -27045,7 +27045,7 @@ __name(_function, "_function");
|
|
|
27045
27045
|
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
27046
27046
|
$ZodCustom.init(inst, def);
|
|
27047
27047
|
ZodType.init(inst, def);
|
|
27048
|
-
inst._zod.processJSONSchema = (ctx,
|
|
27048
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => customProcessor(inst, ctx, json3, params);
|
|
27049
27049
|
});
|
|
27050
27050
|
function check(fn) {
|
|
27051
27051
|
const ch = new $ZodCheck({
|
|
@@ -28358,13 +28358,13 @@ var getPattern = /* @__PURE__ */ __name((label, next) => {
|
|
|
28358
28358
|
}
|
|
28359
28359
|
return null;
|
|
28360
28360
|
}, "getPattern");
|
|
28361
|
-
var tryDecode = /* @__PURE__ */ __name((str,
|
|
28361
|
+
var tryDecode = /* @__PURE__ */ __name((str, decoder2) => {
|
|
28362
28362
|
try {
|
|
28363
|
-
return
|
|
28363
|
+
return decoder2(str);
|
|
28364
28364
|
} catch {
|
|
28365
28365
|
return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match2) => {
|
|
28366
28366
|
try {
|
|
28367
|
-
return
|
|
28367
|
+
return decoder2(match2);
|
|
28368
28368
|
} catch {
|
|
28369
28369
|
return match2;
|
|
28370
28370
|
}
|
|
@@ -30148,6 +30148,90 @@ var Hono3 = class extends Hono {
|
|
|
30148
30148
|
// ../node_modules/.bun/hono@4.13.16/node_modules/hono/dist/helper/factory/index.js
|
|
30149
30149
|
var createMiddleware = /* @__PURE__ */ __name((middleware) => middleware, "createMiddleware");
|
|
30150
30150
|
|
|
30151
|
+
// src/access.ts
|
|
30152
|
+
function accessConfig(env) {
|
|
30153
|
+
if (!env.ACCESS_TEAM || !env.ACCESS_AUD) return null;
|
|
30154
|
+
const emails = (env.ACCESS_EMAILS ?? "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean);
|
|
30155
|
+
return { team: env.ACCESS_TEAM, aud: env.ACCESS_AUD, emails };
|
|
30156
|
+
}
|
|
30157
|
+
__name(accessConfig, "accessConfig");
|
|
30158
|
+
var decoder = new TextDecoder();
|
|
30159
|
+
function b64url(s) {
|
|
30160
|
+
const pad = s.replace(/-/g, "+").replace(/_/g, "/") + "===".slice((s.length + 3) % 4);
|
|
30161
|
+
const bin = atob(pad);
|
|
30162
|
+
const out = new Uint8Array(new ArrayBuffer(bin.length));
|
|
30163
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
30164
|
+
return out;
|
|
30165
|
+
}
|
|
30166
|
+
__name(b64url, "b64url");
|
|
30167
|
+
function json2(part) {
|
|
30168
|
+
try {
|
|
30169
|
+
const v = JSON.parse(decoder.decode(b64url(part)));
|
|
30170
|
+
return v && typeof v === "object" ? v : null;
|
|
30171
|
+
} catch {
|
|
30172
|
+
return null;
|
|
30173
|
+
}
|
|
30174
|
+
}
|
|
30175
|
+
__name(json2, "json");
|
|
30176
|
+
async function verifyAccess(token, cfg, keys, now = Date.now()) {
|
|
30177
|
+
if (!token) return { ok: false, why: "no token" };
|
|
30178
|
+
const parts = token.split(".");
|
|
30179
|
+
if (parts.length !== 3) return { ok: false, why: "malformed" };
|
|
30180
|
+
const [h = "", p = "", s = ""] = parts;
|
|
30181
|
+
const header = json2(h);
|
|
30182
|
+
const payload = json2(p);
|
|
30183
|
+
if (!header || !payload) return { ok: false, why: "malformed" };
|
|
30184
|
+
if (header.alg !== "RS256" || typeof header.kid !== "string") {
|
|
30185
|
+
return { ok: false, why: "unexpected algorithm" };
|
|
30186
|
+
}
|
|
30187
|
+
let signature;
|
|
30188
|
+
try {
|
|
30189
|
+
signature = b64url(s);
|
|
30190
|
+
} catch {
|
|
30191
|
+
return { ok: false, why: "malformed" };
|
|
30192
|
+
}
|
|
30193
|
+
const byKid = /* @__PURE__ */ __name((list) => list.find((k) => k.kid === header.kid), "byKid");
|
|
30194
|
+
const jwk = byKid(await keys(cfg.team, false)) ?? byKid(await keys(cfg.team, true));
|
|
30195
|
+
if (!jwk) return { ok: false, why: "unknown key" };
|
|
30196
|
+
const key = await crypto.subtle.importKey(
|
|
30197
|
+
"jwk",
|
|
30198
|
+
{ kty: jwk.kty, n: jwk.n, e: jwk.e },
|
|
30199
|
+
{ name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
|
|
30200
|
+
false,
|
|
30201
|
+
["verify"]
|
|
30202
|
+
);
|
|
30203
|
+
const signed = new TextEncoder().encode(`${h}.${p}`);
|
|
30204
|
+
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, signed)) {
|
|
30205
|
+
return { ok: false, why: "bad signature" };
|
|
30206
|
+
}
|
|
30207
|
+
const aud = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
|
|
30208
|
+
if (!aud.includes(cfg.aud)) return { ok: false, why: "wrong audience" };
|
|
30209
|
+
if (payload.iss !== `https://${cfg.team}`) return { ok: false, why: "wrong issuer" };
|
|
30210
|
+
const secs = now / 1e3;
|
|
30211
|
+
if (typeof payload.exp !== "number" || payload.exp <= secs) return { ok: false, why: "expired" };
|
|
30212
|
+
if (typeof payload.nbf === "number" && payload.nbf > secs + 60) {
|
|
30213
|
+
return { ok: false, why: "not yet valid" };
|
|
30214
|
+
}
|
|
30215
|
+
const email3 = typeof payload.email === "string" ? payload.email.trim().toLowerCase() : "";
|
|
30216
|
+
if (!email3 || !cfg.emails.includes(email3)) return { ok: false, why: "email not allowed" };
|
|
30217
|
+
return { ok: true, email: email3 };
|
|
30218
|
+
}
|
|
30219
|
+
__name(verifyAccess, "verifyAccess");
|
|
30220
|
+
function fetchedKeys(fetcher = fetch) {
|
|
30221
|
+
let cached2 = null;
|
|
30222
|
+
return async (team, fresh) => {
|
|
30223
|
+
if (!fresh && cached2 && cached2.team === team && Date.now() - cached2.at < 6e5) {
|
|
30224
|
+
return cached2.keys;
|
|
30225
|
+
}
|
|
30226
|
+
const r = await fetcher(`https://${team}/cdn-cgi/access/certs`);
|
|
30227
|
+
if (!r.ok) return cached2?.team === team ? cached2.keys : [];
|
|
30228
|
+
const body = await r.json();
|
|
30229
|
+
cached2 = { team, keys: body.keys ?? [], at: Date.now() };
|
|
30230
|
+
return cached2.keys;
|
|
30231
|
+
};
|
|
30232
|
+
}
|
|
30233
|
+
__name(fetchedKeys, "fetchedKeys");
|
|
30234
|
+
|
|
30151
30235
|
// ../node_modules/.bun/hono@4.13.16/node_modules/hono/dist/helper/html/index.js
|
|
30152
30236
|
var html = /* @__PURE__ */ __name((strings, ...values) => {
|
|
30153
30237
|
const buffer = [""];
|
|
@@ -30182,9 +30266,16 @@ th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #ddd;
|
|
|
30182
30266
|
pre { background: #f5f5f5; padding: .75rem; overflow-x: auto; white-space: pre-wrap; }
|
|
30183
30267
|
form.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
|
|
30184
30268
|
.muted { color: #666; }
|
|
30269
|
+
p.nav { display: flex; justify-content: space-between; gap: 1rem; }
|
|
30185
30270
|
code.key { display: block; padding: .5rem; background: #f5f5f5; margin: .25rem 0 1rem; }
|
|
30186
30271
|
`;
|
|
30187
|
-
function
|
|
30272
|
+
function nav(who) {
|
|
30273
|
+
if (!who) return html`<p><a href="/dashboard">Brutal</a></p>`;
|
|
30274
|
+
const account = who.via === "access" ? html`${who.email} · <a href="/cdn-cgi/access/logout">Sign out</a>` : html`Signed in with the read key (close the browser to sign out)`;
|
|
30275
|
+
return html`<p class="nav"><a href="/dashboard">Brutal</a> <span class="muted">${account}</span></p>`;
|
|
30276
|
+
}
|
|
30277
|
+
__name(nav, "nav");
|
|
30278
|
+
function layout(title, body, who) {
|
|
30188
30279
|
return html`<!doctype html>
|
|
30189
30280
|
<html lang="en">
|
|
30190
30281
|
<head>
|
|
@@ -30196,8 +30287,7 @@ function layout(title, body) {
|
|
|
30196
30287
|
</style>
|
|
30197
30288
|
</head>
|
|
30198
30289
|
<body>
|
|
30199
|
-
|
|
30200
|
-
${body}
|
|
30290
|
+
${nav(who)} ${body}
|
|
30201
30291
|
</body>
|
|
30202
30292
|
</html>`;
|
|
30203
30293
|
}
|
|
@@ -30209,7 +30299,7 @@ function select(name, options, current) {
|
|
|
30209
30299
|
</select>`;
|
|
30210
30300
|
}
|
|
30211
30301
|
__name(select, "select");
|
|
30212
|
-
function reportsPage(reports, q, next) {
|
|
30302
|
+
function reportsPage(reports, q, next, who) {
|
|
30213
30303
|
const nextQuery = next ? new URLSearchParams({ ...q, before: next }).toString() : null;
|
|
30214
30304
|
return layout(
|
|
30215
30305
|
"Reports",
|
|
@@ -30229,7 +30319,7 @@ function reportsPage(reports, q, next) {
|
|
|
30229
30319
|
(r) => html`<tr>
|
|
30230
30320
|
<td class="muted">${r.created_at.slice(0, 16).replace("T", " ")}</td>
|
|
30231
30321
|
<td>${r.kind}</td>
|
|
30232
|
-
<td><a href="/reports/${r.id}">${r.title}</a></td>
|
|
30322
|
+
<td><a href="/dashboard/reports/${r.id}">${r.title}</a></td>
|
|
30233
30323
|
<td>${r.tool_name ?? ""}</td>
|
|
30234
30324
|
<td>${r.impact ?? ""}</td>
|
|
30235
30325
|
<td>${r.status}</td>
|
|
@@ -30237,11 +30327,12 @@ function reportsPage(reports, q, next) {
|
|
|
30237
30327
|
)}
|
|
30238
30328
|
</tbody>
|
|
30239
30329
|
</table>`}
|
|
30240
|
-
${nextQuery ? html`<p><a href="
|
|
30330
|
+
${nextQuery ? html`<p><a href="/dashboard?${nextQuery}">Older</a></p>` : ""}`,
|
|
30331
|
+
who
|
|
30241
30332
|
);
|
|
30242
30333
|
}
|
|
30243
30334
|
__name(reportsPage, "reportsPage");
|
|
30244
|
-
function reportPage(r) {
|
|
30335
|
+
function reportPage(r, who) {
|
|
30245
30336
|
const { recent_tool_calls: calls = [], ...context } = r.context;
|
|
30246
30337
|
return layout(
|
|
30247
30338
|
r.title,
|
|
@@ -30270,7 +30361,8 @@ function reportPage(r) {
|
|
|
30270
30361
|
</tbody>
|
|
30271
30362
|
</table>`}
|
|
30272
30363
|
<h2>Context</h2>
|
|
30273
|
-
<pre>${JSON.stringify(context, null, 2)}</pre
|
|
30364
|
+
<pre>${JSON.stringify(context, null, 2)}</pre>`,
|
|
30365
|
+
who
|
|
30274
30366
|
);
|
|
30275
30367
|
}
|
|
30276
30368
|
__name(reportPage, "reportPage");
|
|
@@ -30285,7 +30377,7 @@ function setupPage(state) {
|
|
|
30285
30377
|
<code class="key">${keys.ingest}</code>
|
|
30286
30378
|
<p>Read key, for the dashboard, the CLI and coding agents (it reads and triages):</p>
|
|
30287
30379
|
<code class="key">${keys.read}</code>
|
|
30288
|
-
<p><a href="/">Open the dashboard</a> with any username and the read key as the password
|
|
30380
|
+
<p><a href="/dashboard">Open the dashboard</a> with any username and the read key as the password, or set up Cloudflare Access with <code>brutal-server access</code>.</p>`
|
|
30289
30381
|
);
|
|
30290
30382
|
}
|
|
30291
30383
|
if (state.claimed) {
|
|
@@ -40405,7 +40497,7 @@ async function readRequestBody(request, maxBytes = DEFAULT_MAX_REQUEST_BODY_SIZE
|
|
|
40405
40497
|
return { tooLarge: false, text: "" };
|
|
40406
40498
|
}
|
|
40407
40499
|
const reader = request.body.getReader();
|
|
40408
|
-
const
|
|
40500
|
+
const decoder2 = new TextDecoder();
|
|
40409
40501
|
let received = 0;
|
|
40410
40502
|
let text = "";
|
|
40411
40503
|
try {
|
|
@@ -40418,12 +40510,12 @@ async function readRequestBody(request, maxBytes = DEFAULT_MAX_REQUEST_BODY_SIZE
|
|
|
40418
40510
|
if (received > maxBytes) {
|
|
40419
40511
|
return { tooLarge: true };
|
|
40420
40512
|
}
|
|
40421
|
-
text +=
|
|
40513
|
+
text += decoder2.decode(value, { stream: true });
|
|
40422
40514
|
}
|
|
40423
40515
|
} finally {
|
|
40424
40516
|
reader.releaseLock();
|
|
40425
40517
|
}
|
|
40426
|
-
return { tooLarge: false, text: text +
|
|
40518
|
+
return { tooLarge: false, text: text + decoder2.decode() };
|
|
40427
40519
|
}
|
|
40428
40520
|
__name(readRequestBody, "readRequestBody");
|
|
40429
40521
|
|
|
@@ -41189,7 +41281,7 @@ data:
|
|
|
41189
41281
|
// src/mcp.ts
|
|
41190
41282
|
function buildServer(db, key) {
|
|
41191
41283
|
const server = new McpServer({ name: "brutal", version: "0.1.0" });
|
|
41192
|
-
const
|
|
41284
|
+
const json3 = /* @__PURE__ */ __name((value) => ({
|
|
41193
41285
|
content: [{ type: "text", text: JSON.stringify(value, null, 2) }]
|
|
41194
41286
|
}), "json");
|
|
41195
41287
|
if (key.kind === "ingest") {
|
|
@@ -41226,7 +41318,7 @@ function buildServer(db, key) {
|
|
|
41226
41318
|
async (filter) => {
|
|
41227
41319
|
const { reports, next } = await listReports(db, filter);
|
|
41228
41320
|
const rows = reports.map(({ details: _d, context: _c, ...r }) => r);
|
|
41229
|
-
return
|
|
41321
|
+
return json3({ reports: rows, next });
|
|
41230
41322
|
}
|
|
41231
41323
|
);
|
|
41232
41324
|
server.registerTool(
|
|
@@ -41238,7 +41330,7 @@ function buildServer(db, key) {
|
|
|
41238
41330
|
async ({ id }) => {
|
|
41239
41331
|
const report = await getReport(db, id);
|
|
41240
41332
|
if (!report) return { isError: true, content: [{ type: "text", text: `No report ${id}.` }] };
|
|
41241
|
-
return
|
|
41333
|
+
return json3(report);
|
|
41242
41334
|
}
|
|
41243
41335
|
);
|
|
41244
41336
|
server.registerTool(
|
|
@@ -41254,7 +41346,7 @@ function buildServer(db, key) {
|
|
|
41254
41346
|
async ({ id, ...update }) => {
|
|
41255
41347
|
const report = await updateReport(db, id, update);
|
|
41256
41348
|
if (!report) return { isError: true, content: [{ type: "text", text: `No report ${id}.` }] };
|
|
41257
|
-
return
|
|
41349
|
+
return json3(report);
|
|
41258
41350
|
}
|
|
41259
41351
|
);
|
|
41260
41352
|
server.registerTool(
|
|
@@ -41266,7 +41358,7 @@ function buildServer(db, key) {
|
|
|
41266
41358
|
limit: external_exports.number().int().min(1).max(200).optional()
|
|
41267
41359
|
}
|
|
41268
41360
|
},
|
|
41269
|
-
async ({ before, limit }) =>
|
|
41361
|
+
async ({ before, limit }) => json3(await listReports(db, { kind: "eval_candidate", before, limit }))
|
|
41270
41362
|
);
|
|
41271
41363
|
return server;
|
|
41272
41364
|
}
|
|
@@ -41334,8 +41426,9 @@ __name(claim2, "claim");
|
|
|
41334
41426
|
|
|
41335
41427
|
// src/app.ts
|
|
41336
41428
|
var problem = /* @__PURE__ */ __name((error62, status, extra = {}) => Response.json({ error: error62, ...extra }, { status }), "problem");
|
|
41337
|
-
function createApp() {
|
|
41429
|
+
function createApp(options = {}) {
|
|
41338
41430
|
const app = new Hono3();
|
|
41431
|
+
const accessKeys = options.accessKeys ?? fetchedKeys();
|
|
41339
41432
|
app.use(async (c, next) => {
|
|
41340
41433
|
c.set("db", await migrated(c.env.DB));
|
|
41341
41434
|
await next();
|
|
@@ -41388,6 +41481,22 @@ function createApp() {
|
|
|
41388
41481
|
return c.html(setupPage({ wrongCode: true }), 403);
|
|
41389
41482
|
});
|
|
41390
41483
|
const dashboard = createMiddleware(async (c, next) => {
|
|
41484
|
+
const access = accessConfig(c.env);
|
|
41485
|
+
if (access) {
|
|
41486
|
+
const verdict = await verifyAccess(
|
|
41487
|
+
c.req.header("cf-access-jwt-assertion"),
|
|
41488
|
+
access,
|
|
41489
|
+
accessKeys
|
|
41490
|
+
);
|
|
41491
|
+
if (!verdict.ok) {
|
|
41492
|
+
return c.text(
|
|
41493
|
+
"Sign in through Cloudflare Access to see this dashboard. If you came here through it, your email is not one this instance lets in.",
|
|
41494
|
+
403
|
|
41495
|
+
);
|
|
41496
|
+
}
|
|
41497
|
+
c.set("signedIn", { via: "access", email: verdict.email });
|
|
41498
|
+
return next();
|
|
41499
|
+
}
|
|
41391
41500
|
const secret = secretFrom(c.req.header("authorization"));
|
|
41392
41501
|
const key = secret ? await findKey(c.var.db, secret) : null;
|
|
41393
41502
|
if (key?.kind !== "read") {
|
|
@@ -41396,16 +41505,19 @@ function createApp() {
|
|
|
41396
41505
|
headers: { "WWW-Authenticate": 'Basic realm="brutal", charset="UTF-8"' }
|
|
41397
41506
|
});
|
|
41398
41507
|
}
|
|
41508
|
+
c.set("signedIn", { via: "read-key" });
|
|
41399
41509
|
await next();
|
|
41400
41510
|
});
|
|
41401
|
-
app.get("/",
|
|
41511
|
+
app.get("/", (c) => c.redirect("/dashboard"));
|
|
41512
|
+
app.get("/reports/:id", (c) => c.redirect(`/dashboard/reports/${c.req.param("id")}`, 301));
|
|
41513
|
+
app.get("/dashboard", dashboard, async (c) => {
|
|
41402
41514
|
const q = c.req.query();
|
|
41403
41515
|
const page = await listReports(c.var.db, q);
|
|
41404
|
-
return c.html(reportsPage(page.reports, q, page.next));
|
|
41516
|
+
return c.html(reportsPage(page.reports, q, page.next, c.var.signedIn));
|
|
41405
41517
|
});
|
|
41406
|
-
app.get("/reports/:id", dashboard, async (c) => {
|
|
41518
|
+
app.get("/dashboard/reports/:id", dashboard, async (c) => {
|
|
41407
41519
|
const report = await getReport(c.var.db, c.req.param("id"));
|
|
41408
|
-
return report ? c.html(reportPage(report)) : c.notFound();
|
|
41520
|
+
return report ? c.html(reportPage(report, c.var.signedIn)) : c.notFound();
|
|
41409
41521
|
});
|
|
41410
41522
|
return app;
|
|
41411
41523
|
}
|