openapi-tree-shaker
Version:
A tool to tree-shake OpenAPI specifications by removing unused paths and components
1,435 lines • 396 kB
JavaScript
#!/usr/bin/env node
import { readFileSync as rc } from "fs";
function nc(e) {
const r = e.match(/^#\/definitions\/(.+)$/);
if (r)
return { type: "schemas", name: r[1] };
const v = e.match(/^#\/securityDefinitions\/(.+)$/);
if (v)
return { type: "securitySchemes", name: v[1] };
const u = e.match(/^#\/components\/(\w+)\/(.+)$/);
if (u) {
const [, $, n] = u;
if ($ === "schemas" || $ === "parameters" || $ === "responses" || $ === "requestBodies" || $ === "securitySchemes")
return { type: $, name: n };
}
return null;
}
function Pt(e, r, v = /* @__PURE__ */ new Set()) {
if (!(!e || typeof e != "object") && !v.has(e)) {
if (v.add(e), Array.isArray(e)) {
e.forEach((u) => Pt(u, r, v));
return;
}
for (const [u, $] of Object.entries(e))
if (u === "$ref" && typeof $ == "string") {
const n = nc($);
if (n) {
const l = `${n.type}:${n.name}`;
Array.from(r).some((c) => `${c.type}:${c.name}` === l) || r.add(n);
}
} else u === "security" && Array.isArray($) ? $.forEach((n) => {
n && typeof n == "object" && Object.keys(n).forEach((l) => {
r.add({ type: "securitySchemes", name: l });
});
}) : typeof $ == "object" && Pt($, r, v);
}
}
function ic(e, r) {
var l, c, d, y;
const v = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Set(), n = [];
Pt(r, v, u);
for (const f of v) {
const w = `${f.type}:${f.name}`;
$.has(w) || n.push(f);
}
for (("security" in e) && Array.isArray(e.security) && Pt({ security: e.security }, v, u); n.length > 0; ) {
const f = n.shift(), w = `${f.type}:${f.name}`;
if ($.has(w)) continue;
$.add(w);
let S;
if (f.type === "schemas") {
const E = e, P = e;
E.definitions ? S = E.definitions[f.name] : (l = P.components) != null && l.schemas && (S = P.components.schemas[f.name]);
} else if (f.type === "securitySchemes") {
const E = e, P = e;
E.securityDefinitions ? S = E.securityDefinitions[f.name] : (c = P.components) != null && c.securitySchemes && (S = P.components.securitySchemes[f.name]);
} else "components" in e && (S = (y = (d = e.components) == null ? void 0 : d[f.type]) == null ? void 0 : y[f.name]);
if (S) {
const E = v.size;
if (Pt(S, v, u), v.size > E)
for (const P of v) {
const g = `${P.type}:${P.name}`;
!$.has(g) && !n.some(
(a) => a.type === P.type && a.name === P.name
) && n.push(P);
}
}
}
return v;
}
function sc(e, r = [".*"]) {
const v = r.map((f) => new RegExp(f)), u = {
removedPaths: [],
removedSchemas: [],
removedParameters: [],
removedResponses: [],
removedRequestBodies: [],
removedSecuritySchemes: []
}, $ = {}, n = e.paths || {};
for (const [f, w] of Object.entries(n))
v.some((S) => S.test(f)) ? $[f] = w : u.removedPaths.push(f);
const l = ic(e, $), c = { ...e, paths: $ }, d = e;
if ("swagger" in e) {
const f = c;
if (d.definitions) {
f.definitions = {};
for (const [w, S] of Object.entries(d.definitions))
Array.from(l).some(
(E) => E.type === "schemas" && E.name === w
) ? f.definitions[w] = S : u.removedSchemas.push(w);
}
if (d.securityDefinitions) {
f.securityDefinitions = {};
for (const [w, S] of Object.entries(d.securityDefinitions))
Array.from(l).some(
(E) => E.type === "securitySchemes" && E.name === w
) ? f.securityDefinitions[w] = S : u.removedSecuritySchemes.push(w);
}
}
const y = e;
if ("openapi" in e && y.components) {
const f = c;
f.components = {};
const w = (E) => {
var g;
const P = (g = y.components) == null ? void 0 : g[E];
if (P) {
f.components[E] = {};
for (const [a, o] of Object.entries(P))
if (Array.from(l).some(
(t) => t.type === E && t.name === a
))
f.components[E][a] = o;
else {
const t = `removed${E.charAt(0).toUpperCase() + E.slice(1)}`;
Array.isArray(u[t]) && u[t].push(a);
}
}
};
y.components.schemas && w("schemas"), y.components.parameters && w("parameters"), y.components.responses && w("responses"), y.components.requestBodies && w("requestBodies"), y.components.securitySchemes && w("securitySchemes");
const S = Object.keys(f.components);
for (const E of S) {
const P = f.components[E];
P && Object.keys(P).length === 0 && delete f.components[E];
}
Object.keys(f.components).length === 0 && delete f.components;
}
return { spec: c, summary: u };
}
var Nt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function oc(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var Pn = {}, It = { exports: {} }, En = {}, Le = {}, tt = {}, Sn = {}, On = {}, jn = {}, di;
function Zr() {
return di || (di = 1, function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e.regexpCode = e.getEsmExportName = e.getProperty = e.safeStringify = e.stringify = e.strConcat = e.addCodeArg = e.str = e._ = e.nil = e._Code = e.Name = e.IDENTIFIER = e._CodeOrName = void 0;
class r {
}
e._CodeOrName = r, e.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
class v extends r {
constructor(t) {
if (super(), !e.IDENTIFIER.test(t))
throw new Error("CodeGen: name must be a valid identifier");
this.str = t;
}
toString() {
return this.str;
}
emptyStr() {
return !1;
}
get names() {
return { [this.str]: 1 };
}
}
e.Name = v;
class u extends r {
constructor(t) {
super(), this._items = typeof t == "string" ? [t] : t;
}
toString() {
return this.str;
}
emptyStr() {
if (this._items.length > 1)
return !1;
const t = this._items[0];
return t === "" || t === '""';
}
get str() {
var t;
return (t = this._str) !== null && t !== void 0 ? t : this._str = this._items.reduce((s, h) => `${s}${h}`, "");
}
get names() {
var t;
return (t = this._names) !== null && t !== void 0 ? t : this._names = this._items.reduce((s, h) => (h instanceof v && (s[h.str] = (s[h.str] || 0) + 1), s), {});
}
}
e._Code = u, e.nil = new u("");
function $(o, ...t) {
const s = [o[0]];
let h = 0;
for (; h < t.length; )
c(s, t[h]), s.push(o[++h]);
return new u(s);
}
e._ = $;
const n = new u("+");
function l(o, ...t) {
const s = [E(o[0])];
let h = 0;
for (; h < t.length; )
s.push(n), c(s, t[h]), s.push(n, E(o[++h]));
return d(s), new u(s);
}
e.str = l;
function c(o, t) {
t instanceof u ? o.push(...t._items) : t instanceof v ? o.push(t) : o.push(w(t));
}
e.addCodeArg = c;
function d(o) {
let t = 1;
for (; t < o.length - 1; ) {
if (o[t] === n) {
const s = y(o[t - 1], o[t + 1]);
if (s !== void 0) {
o.splice(t - 1, 3, s);
continue;
}
o[t++] = "+";
}
t++;
}
}
function y(o, t) {
if (t === '""')
return o;
if (o === '""')
return t;
if (typeof o == "string")
return t instanceof v || o[o.length - 1] !== '"' ? void 0 : typeof t != "string" ? `${o.slice(0, -1)}${t}"` : t[0] === '"' ? o.slice(0, -1) + t.slice(1) : void 0;
if (typeof t == "string" && t[0] === '"' && !(o instanceof v))
return `"${o}${t.slice(1)}`;
}
function f(o, t) {
return t.emptyStr() ? o : o.emptyStr() ? t : l`${o}${t}`;
}
e.strConcat = f;
function w(o) {
return typeof o == "number" || typeof o == "boolean" || o === null ? o : E(Array.isArray(o) ? o.join(",") : o);
}
function S(o) {
return new u(E(o));
}
e.stringify = S;
function E(o) {
return JSON.stringify(o).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
}
e.safeStringify = E;
function P(o) {
return typeof o == "string" && e.IDENTIFIER.test(o) ? new u(`.${o}`) : $`[${o}]`;
}
e.getProperty = P;
function g(o) {
if (typeof o == "string" && e.IDENTIFIER.test(o))
return new u(`${o}`);
throw new Error(`CodeGen: invalid export name: ${o}, use explicit $id name mapping`);
}
e.getEsmExportName = g;
function a(o) {
return new u(o.toString());
}
e.regexpCode = a;
}(jn)), jn;
}
var Rn = {}, fi;
function li() {
return fi || (fi = 1, function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e.ValueScope = e.ValueScopeName = e.Scope = e.varKinds = e.UsedValueState = void 0;
const r = Zr();
class v extends Error {
constructor(y) {
super(`CodeGen: "code" for ${y} not defined`), this.value = y.value;
}
}
var u;
(function(d) {
d[d.Started = 0] = "Started", d[d.Completed = 1] = "Completed";
})(u || (e.UsedValueState = u = {})), e.varKinds = {
const: new r.Name("const"),
let: new r.Name("let"),
var: new r.Name("var")
};
class $ {
constructor({ prefixes: y, parent: f } = {}) {
this._names = {}, this._prefixes = y, this._parent = f;
}
toName(y) {
return y instanceof r.Name ? y : this.name(y);
}
name(y) {
return new r.Name(this._newName(y));
}
_newName(y) {
const f = this._names[y] || this._nameGroup(y);
return `${y}${f.index++}`;
}
_nameGroup(y) {
var f, w;
if (!((w = (f = this._parent) === null || f === void 0 ? void 0 : f._prefixes) === null || w === void 0) && w.has(y) || this._prefixes && !this._prefixes.has(y))
throw new Error(`CodeGen: prefix "${y}" is not allowed in this scope`);
return this._names[y] = { prefix: y, index: 0 };
}
}
e.Scope = $;
class n extends r.Name {
constructor(y, f) {
super(f), this.prefix = y;
}
setValue(y, { property: f, itemIndex: w }) {
this.value = y, this.scopePath = (0, r._)`.${new r.Name(f)}[${w}]`;
}
}
e.ValueScopeName = n;
const l = (0, r._)`\n`;
class c extends $ {
constructor(y) {
super(y), this._values = {}, this._scope = y.scope, this.opts = { ...y, _n: y.lines ? l : r.nil };
}
get() {
return this._scope;
}
name(y) {
return new n(y, this._newName(y));
}
value(y, f) {
var w;
if (f.ref === void 0)
throw new Error("CodeGen: ref must be passed in value");
const S = this.toName(y), { prefix: E } = S, P = (w = f.key) !== null && w !== void 0 ? w : f.ref;
let g = this._values[E];
if (g) {
const t = g.get(P);
if (t)
return t;
} else
g = this._values[E] = /* @__PURE__ */ new Map();
g.set(P, S);
const a = this._scope[E] || (this._scope[E] = []), o = a.length;
return a[o] = f.ref, S.setValue(f, { property: E, itemIndex: o }), S;
}
getValue(y, f) {
const w = this._values[y];
if (w)
return w.get(f);
}
scopeRefs(y, f = this._values) {
return this._reduceValues(f, (w) => {
if (w.scopePath === void 0)
throw new Error(`CodeGen: name "${w}" has no value`);
return (0, r._)`${y}${w.scopePath}`;
});
}
scopeCode(y = this._values, f, w) {
return this._reduceValues(y, (S) => {
if (S.value === void 0)
throw new Error(`CodeGen: name "${S}" has no value`);
return S.value.code;
}, f, w);
}
_reduceValues(y, f, w = {}, S) {
let E = r.nil;
for (const P in y) {
const g = y[P];
if (!g)
continue;
const a = w[P] = w[P] || /* @__PURE__ */ new Map();
g.forEach((o) => {
if (a.has(o))
return;
a.set(o, u.Started);
let t = f(o);
if (t) {
const s = this.opts.es5 ? e.varKinds.var : e.varKinds.const;
E = (0, r._)`${E}${s} ${o} = ${t};${this.opts._n}`;
} else if (t = S == null ? void 0 : S(o))
E = (0, r._)`${E}${t}${this.opts._n}`;
else
throw new v(o);
a.set(o, u.Completed);
});
}
return E;
}
}
e.ValueScope = c;
}(Rn)), Rn;
}
var pi;
function se() {
return pi || (pi = 1, function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e.or = e.and = e.not = e.CodeGen = e.operators = e.varKinds = e.ValueScopeName = e.ValueScope = e.Scope = e.Name = e.regexpCode = e.stringify = e.getProperty = e.nil = e.strConcat = e.str = e._ = void 0;
const r = Zr(), v = li();
var u = Zr();
Object.defineProperty(e, "_", { enumerable: !0, get: function() {
return u._;
} }), Object.defineProperty(e, "str", { enumerable: !0, get: function() {
return u.str;
} }), Object.defineProperty(e, "strConcat", { enumerable: !0, get: function() {
return u.strConcat;
} }), Object.defineProperty(e, "nil", { enumerable: !0, get: function() {
return u.nil;
} }), Object.defineProperty(e, "getProperty", { enumerable: !0, get: function() {
return u.getProperty;
} }), Object.defineProperty(e, "stringify", { enumerable: !0, get: function() {
return u.stringify;
} }), Object.defineProperty(e, "regexpCode", { enumerable: !0, get: function() {
return u.regexpCode;
} }), Object.defineProperty(e, "Name", { enumerable: !0, get: function() {
return u.Name;
} });
var $ = li();
Object.defineProperty(e, "Scope", { enumerable: !0, get: function() {
return $.Scope;
} }), Object.defineProperty(e, "ValueScope", { enumerable: !0, get: function() {
return $.ValueScope;
} }), Object.defineProperty(e, "ValueScopeName", { enumerable: !0, get: function() {
return $.ValueScopeName;
} }), Object.defineProperty(e, "varKinds", { enumerable: !0, get: function() {
return $.varKinds;
} }), e.operators = {
GT: new r._Code(">"),
GTE: new r._Code(">="),
LT: new r._Code("<"),
LTE: new r._Code("<="),
EQ: new r._Code("==="),
NEQ: new r._Code("!=="),
NOT: new r._Code("!"),
OR: new r._Code("||"),
AND: new r._Code("&&"),
ADD: new r._Code("+")
};
class n {
optimizeNodes() {
return this;
}
optimizeNames(i, _) {
return this;
}
}
class l extends n {
constructor(i, _, k) {
super(), this.varKind = i, this.name = _, this.rhs = k;
}
render({ es5: i, _n: _ }) {
const k = i ? v.varKinds.var : this.varKind, U = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
return `${k} ${this.name}${U};` + _;
}
optimizeNames(i, _) {
if (i[this.name.str])
return this.rhs && (this.rhs = B(this.rhs, i, _)), this;
}
get names() {
return this.rhs instanceof r._CodeOrName ? this.rhs.names : {};
}
}
class c extends n {
constructor(i, _, k) {
super(), this.lhs = i, this.rhs = _, this.sideEffects = k;
}
render({ _n: i }) {
return `${this.lhs} = ${this.rhs};` + i;
}
optimizeNames(i, _) {
if (!(this.lhs instanceof r.Name && !i[this.lhs.str] && !this.sideEffects))
return this.rhs = B(this.rhs, i, _), this;
}
get names() {
const i = this.lhs instanceof r.Name ? {} : { ...this.lhs.names };
return G(i, this.rhs);
}
}
class d extends c {
constructor(i, _, k, U) {
super(i, k, U), this.op = _;
}
render({ _n: i }) {
return `${this.lhs} ${this.op}= ${this.rhs};` + i;
}
}
class y extends n {
constructor(i) {
super(), this.label = i, this.names = {};
}
render({ _n: i }) {
return `${this.label}:` + i;
}
}
class f extends n {
constructor(i) {
super(), this.label = i, this.names = {};
}
render({ _n: i }) {
return `break${this.label ? ` ${this.label}` : ""};` + i;
}
}
class w extends n {
constructor(i) {
super(), this.error = i;
}
render({ _n: i }) {
return `throw ${this.error};` + i;
}
get names() {
return this.error.names;
}
}
class S extends n {
constructor(i) {
super(), this.code = i;
}
render({ _n: i }) {
return `${this.code};` + i;
}
optimizeNodes() {
return `${this.code}` ? this : void 0;
}
optimizeNames(i, _) {
return this.code = B(this.code, i, _), this;
}
get names() {
return this.code instanceof r._CodeOrName ? this.code.names : {};
}
}
class E extends n {
constructor(i = []) {
super(), this.nodes = i;
}
render(i) {
return this.nodes.reduce((_, k) => _ + k.render(i), "");
}
optimizeNodes() {
const { nodes: i } = this;
let _ = i.length;
for (; _--; ) {
const k = i[_].optimizeNodes();
Array.isArray(k) ? i.splice(_, 1, ...k) : k ? i[_] = k : i.splice(_, 1);
}
return i.length > 0 ? this : void 0;
}
optimizeNames(i, _) {
const { nodes: k } = this;
let U = k.length;
for (; U--; ) {
const K = k[U];
K.optimizeNames(i, _) || (Z(i, K.names), k.splice(U, 1));
}
return k.length > 0 ? this : void 0;
}
get names() {
return this.nodes.reduce((i, _) => H(i, _.names), {});
}
}
class P extends E {
render(i) {
return "{" + i._n + super.render(i) + "}" + i._n;
}
}
class g extends E {
}
class a extends P {
}
a.kind = "else";
class o extends P {
constructor(i, _) {
super(_), this.condition = i;
}
render(i) {
let _ = `if(${this.condition})` + super.render(i);
return this.else && (_ += "else " + this.else.render(i)), _;
}
optimizeNodes() {
super.optimizeNodes();
const i = this.condition;
if (i === !0)
return this.nodes;
let _ = this.else;
if (_) {
const k = _.optimizeNodes();
_ = this.else = Array.isArray(k) ? new a(k) : k;
}
if (_)
return i === !1 ? _ instanceof o ? _ : _.nodes : this.nodes.length ? this : new o(ve(i), _ instanceof o ? [_] : _.nodes);
if (!(i === !1 || !this.nodes.length))
return this;
}
optimizeNames(i, _) {
var k;
if (this.else = (k = this.else) === null || k === void 0 ? void 0 : k.optimizeNames(i, _), !!(super.optimizeNames(i, _) || this.else))
return this.condition = B(this.condition, i, _), this;
}
get names() {
const i = super.names;
return G(i, this.condition), this.else && H(i, this.else.names), i;
}
}
o.kind = "if";
class t extends P {
}
t.kind = "for";
class s extends t {
constructor(i) {
super(), this.iteration = i;
}
render(i) {
return `for(${this.iteration})` + super.render(i);
}
optimizeNames(i, _) {
if (super.optimizeNames(i, _))
return this.iteration = B(this.iteration, i, _), this;
}
get names() {
return H(super.names, this.iteration.names);
}
}
class h extends t {
constructor(i, _, k, U) {
super(), this.varKind = i, this.name = _, this.from = k, this.to = U;
}
render(i) {
const _ = i.es5 ? v.varKinds.var : this.varKind, { name: k, from: U, to: K } = this;
return `for(${_} ${k}=${U}; ${k}<${K}; ${k}++)` + super.render(i);
}
get names() {
const i = G(super.names, this.from);
return G(i, this.to);
}
}
class m extends t {
constructor(i, _, k, U) {
super(), this.loop = i, this.varKind = _, this.name = k, this.iterable = U;
}
render(i) {
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(i);
}
optimizeNames(i, _) {
if (super.optimizeNames(i, _))
return this.iterable = B(this.iterable, i, _), this;
}
get names() {
return H(super.names, this.iterable.names);
}
}
class p extends P {
constructor(i, _, k) {
super(), this.name = i, this.args = _, this.async = k;
}
render(i) {
return `${this.async ? "async " : ""}function ${this.name}(${this.args})` + super.render(i);
}
}
p.kind = "func";
class b extends E {
render(i) {
return "return " + super.render(i);
}
}
b.kind = "return";
class T extends P {
render(i) {
let _ = "try" + super.render(i);
return this.catch && (_ += this.catch.render(i)), this.finally && (_ += this.finally.render(i)), _;
}
optimizeNodes() {
var i, _;
return super.optimizeNodes(), (i = this.catch) === null || i === void 0 || i.optimizeNodes(), (_ = this.finally) === null || _ === void 0 || _.optimizeNodes(), this;
}
optimizeNames(i, _) {
var k, U;
return super.optimizeNames(i, _), (k = this.catch) === null || k === void 0 || k.optimizeNames(i, _), (U = this.finally) === null || U === void 0 || U.optimizeNames(i, _), this;
}
get names() {
const i = super.names;
return this.catch && H(i, this.catch.names), this.finally && H(i, this.finally.names), i;
}
}
class q extends P {
constructor(i) {
super(), this.error = i;
}
render(i) {
return `catch(${this.error})` + super.render(i);
}
}
q.kind = "catch";
class z extends P {
render(i) {
return "finally" + super.render(i);
}
}
z.kind = "finally";
class L {
constructor(i, _ = {}) {
this._values = {}, this._blockStarts = [], this._constants = {}, this.opts = { ..._, _n: _.lines ? `
` : "" }, this._extScope = i, this._scope = new v.Scope({ parent: i }), this._nodes = [new g()];
}
toString() {
return this._root.render(this.opts);
}
// returns unique name in the internal scope
name(i) {
return this._scope.name(i);
}
// reserves unique name in the external scope
scopeName(i) {
return this._extScope.name(i);
}
// reserves unique name in the external scope and assigns value to it
scopeValue(i, _) {
const k = this._extScope.value(i, _);
return (this._values[k.prefix] || (this._values[k.prefix] = /* @__PURE__ */ new Set())).add(k), k;
}
getScopeValue(i, _) {
return this._extScope.getValue(i, _);
}
// return code that assigns values in the external scope to the names that are used internally
// (same names that were returned by gen.scopeName or gen.scopeValue)
scopeRefs(i) {
return this._extScope.scopeRefs(i, this._values);
}
scopeCode() {
return this._extScope.scopeCode(this._values);
}
_def(i, _, k, U) {
const K = this._scope.toName(_);
return k !== void 0 && U && (this._constants[K.str] = k), this._leafNode(new l(i, K, k)), K;
}
// `const` declaration (`var` in es5 mode)
const(i, _, k) {
return this._def(v.varKinds.const, i, _, k);
}
// `let` declaration with optional assignment (`var` in es5 mode)
let(i, _, k) {
return this._def(v.varKinds.let, i, _, k);
}
// `var` declaration with optional assignment
var(i, _, k) {
return this._def(v.varKinds.var, i, _, k);
}
// assignment code
assign(i, _, k) {
return this._leafNode(new c(i, _, k));
}
// `+=` code
add(i, _) {
return this._leafNode(new d(i, e.operators.ADD, _));
}
// appends passed SafeExpr to code or executes Block
code(i) {
return typeof i == "function" ? i() : i !== r.nil && this._leafNode(new S(i)), this;
}
// returns code for object literal for the passed argument list of key-value pairs
object(...i) {
const _ = ["{"];
for (const [k, U] of i)
_.length > 1 && _.push(","), _.push(k), (k !== U || this.opts.es5) && (_.push(":"), (0, r.addCodeArg)(_, U));
return _.push("}"), new r._Code(_);
}
// `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
if(i, _, k) {
if (this._blockNode(new o(i)), _ && k)
this.code(_).else().code(k).endIf();
else if (_)
this.code(_).endIf();
else if (k)
throw new Error('CodeGen: "else" body without "then" body');
return this;
}
// `else if` clause - invalid without `if` or after `else` clauses
elseIf(i) {
return this._elseNode(new o(i));
}
// `else` clause - only valid after `if` or `else if` clauses
else() {
return this._elseNode(new a());
}
// end `if` statement (needed if gen.if was used only with condition)
endIf() {
return this._endBlockNode(o, a);
}
_for(i, _) {
return this._blockNode(i), _ && this.code(_).endFor(), this;
}
// a generic `for` clause (or statement if `forBody` is passed)
for(i, _) {
return this._for(new s(i), _);
}
// `for` statement for a range of values
forRange(i, _, k, U, K = this.opts.es5 ? v.varKinds.var : v.varKinds.let) {
const X = this._scope.toName(i);
return this._for(new h(K, X, _, k), () => U(X));
}
// `for-of` statement (in es5 mode replace with a normal for loop)
forOf(i, _, k, U = v.varKinds.const) {
const K = this._scope.toName(i);
if (this.opts.es5) {
const X = _ instanceof r.Name ? _ : this.var("_arr", _);
return this.forRange("_i", 0, (0, r._)`${X}.length`, (W) => {
this.var(K, (0, r._)`${X}[${W}]`), k(K);
});
}
return this._for(new m("of", U, K, _), () => k(K));
}
// `for-in` statement.
// With option `ownProperties` replaced with a `for-of` loop for object keys
forIn(i, _, k, U = this.opts.es5 ? v.varKinds.var : v.varKinds.const) {
if (this.opts.ownProperties)
return this.forOf(i, (0, r._)`Object.keys(${_})`, k);
const K = this._scope.toName(i);
return this._for(new m("in", U, K, _), () => k(K));
}
// end `for` loop
endFor() {
return this._endBlockNode(t);
}
// `label` statement
label(i) {
return this._leafNode(new y(i));
}
// `break` statement
break(i) {
return this._leafNode(new f(i));
}
// `return` statement
return(i) {
const _ = new b();
if (this._blockNode(_), this.code(i), _.nodes.length !== 1)
throw new Error('CodeGen: "return" should have one node');
return this._endBlockNode(b);
}
// `try` statement
try(i, _, k) {
if (!_ && !k)
throw new Error('CodeGen: "try" without "catch" and "finally"');
const U = new T();
if (this._blockNode(U), this.code(i), _) {
const K = this.name("e");
this._currNode = U.catch = new q(K), _(K);
}
return k && (this._currNode = U.finally = new z(), this.code(k)), this._endBlockNode(q, z);
}
// `throw` statement
throw(i) {
return this._leafNode(new w(i));
}
// start self-balancing block
block(i, _) {
return this._blockStarts.push(this._nodes.length), i && this.code(i).endBlock(_), this;
}
// end the current self-balancing block
endBlock(i) {
const _ = this._blockStarts.pop();
if (_ === void 0)
throw new Error("CodeGen: not in self-balancing block");
const k = this._nodes.length - _;
if (k < 0 || i !== void 0 && k !== i)
throw new Error(`CodeGen: wrong number of nodes: ${k} vs ${i} expected`);
return this._nodes.length = _, this;
}
// `function` heading (or definition if funcBody is passed)
func(i, _ = r.nil, k, U) {
return this._blockNode(new p(i, _, k)), U && this.code(U).endFunc(), this;
}
// end function definition
endFunc() {
return this._endBlockNode(p);
}
optimize(i = 1) {
for (; i-- > 0; )
this._root.optimizeNodes(), this._root.optimizeNames(this._root.names, this._constants);
}
_leafNode(i) {
return this._currNode.nodes.push(i), this;
}
_blockNode(i) {
this._currNode.nodes.push(i), this._nodes.push(i);
}
_endBlockNode(i, _) {
const k = this._currNode;
if (k instanceof i || _ && k instanceof _)
return this._nodes.pop(), this;
throw new Error(`CodeGen: not in block "${_ ? `${i.kind}/${_.kind}` : i.kind}"`);
}
_elseNode(i) {
const _ = this._currNode;
if (!(_ instanceof o))
throw new Error('CodeGen: "else" without "if"');
return this._currNode = _.else = i, this;
}
get _root() {
return this._nodes[0];
}
get _currNode() {
const i = this._nodes;
return i[i.length - 1];
}
set _currNode(i) {
const _ = this._nodes;
_[_.length - 1] = i;
}
}
e.CodeGen = L;
function H(j, i) {
for (const _ in i)
j[_] = (j[_] || 0) + (i[_] || 0);
return j;
}
function G(j, i) {
return i instanceof r._CodeOrName ? H(j, i.names) : j;
}
function B(j, i, _) {
if (j instanceof r.Name)
return k(j);
if (!U(j))
return j;
return new r._Code(j._items.reduce((K, X) => (X instanceof r.Name && (X = k(X)), X instanceof r._Code ? K.push(...X._items) : K.push(X), K), []));
function k(K) {
const X = _[K.str];
return X === void 0 || i[K.str] !== 1 ? K : (delete i[K.str], X);
}
function U(K) {
return K instanceof r._Code && K._items.some((X) => X instanceof r.Name && i[X.str] === 1 && _[X.str] !== void 0);
}
}
function Z(j, i) {
for (const _ in i)
j[_] = (j[_] || 0) - (i[_] || 0);
}
function ve(j) {
return typeof j == "boolean" || typeof j == "number" || j === null ? !j : (0, r._)`!${C(j)}`;
}
e.not = ve;
const _e = R(e.operators.AND);
function Q(...j) {
return j.reduce(_e);
}
e.and = Q;
const be = R(e.operators.OR);
function D(...j) {
return j.reduce(be);
}
e.or = D;
function R(j) {
return (i, _) => i === r.nil ? _ : _ === r.nil ? i : (0, r._)`${C(i)} ${j} ${C(_)}`;
}
function C(j) {
return j instanceof r.Name ? j : (0, r._)`(${j})`;
}
}(On)), On;
}
var te = {}, mi;
function ue() {
if (mi) return te;
mi = 1, Object.defineProperty(te, "__esModule", { value: !0 }), te.checkStrictMode = te.getErrorPath = te.Type = te.useFunc = te.setEvaluated = te.evaluatedPropsToName = te.mergeEvaluated = te.eachItem = te.unescapeJsonPointer = te.escapeJsonPointer = te.escapeFragment = te.unescapeFragment = te.schemaRefOrVal = te.schemaHasRulesButRef = te.schemaHasRules = te.checkUnknownRules = te.alwaysValidSchema = te.toHash = void 0;
const e = se(), r = Zr();
function v(m) {
const p = {};
for (const b of m)
p[b] = !0;
return p;
}
te.toHash = v;
function u(m, p) {
return typeof p == "boolean" ? p : Object.keys(p).length === 0 ? !0 : ($(m, p), !n(p, m.self.RULES.all));
}
te.alwaysValidSchema = u;
function $(m, p = m.schema) {
const { opts: b, self: T } = m;
if (!b.strictSchema || typeof p == "boolean")
return;
const q = T.RULES.keywords;
for (const z in p)
q[z] || h(m, `unknown keyword: "${z}"`);
}
te.checkUnknownRules = $;
function n(m, p) {
if (typeof m == "boolean")
return !m;
for (const b in m)
if (p[b])
return !0;
return !1;
}
te.schemaHasRules = n;
function l(m, p) {
if (typeof m == "boolean")
return !m;
for (const b in m)
if (b !== "$ref" && p.all[b])
return !0;
return !1;
}
te.schemaHasRulesButRef = l;
function c({ topSchemaRef: m, schemaPath: p }, b, T, q) {
if (!q) {
if (typeof b == "number" || typeof b == "boolean")
return b;
if (typeof b == "string")
return (0, e._)`${b}`;
}
return (0, e._)`${m}${p}${(0, e.getProperty)(T)}`;
}
te.schemaRefOrVal = c;
function d(m) {
return w(decodeURIComponent(m));
}
te.unescapeFragment = d;
function y(m) {
return encodeURIComponent(f(m));
}
te.escapeFragment = y;
function f(m) {
return typeof m == "number" ? `${m}` : m.replace(/~/g, "~0").replace(/\//g, "~1");
}
te.escapeJsonPointer = f;
function w(m) {
return m.replace(/~1/g, "/").replace(/~0/g, "~");
}
te.unescapeJsonPointer = w;
function S(m, p) {
if (Array.isArray(m))
for (const b of m)
p(b);
else
p(m);
}
te.eachItem = S;
function E({ mergeNames: m, mergeToName: p, mergeValues: b, resultToName: T }) {
return (q, z, L, H) => {
const G = L === void 0 ? z : L instanceof e.Name ? (z instanceof e.Name ? m(q, z, L) : p(q, z, L), L) : z instanceof e.Name ? (p(q, L, z), z) : b(z, L);
return H === e.Name && !(G instanceof e.Name) ? T(q, G) : G;
};
}
te.mergeEvaluated = {
props: E({
mergeNames: (m, p, b) => m.if((0, e._)`${b} !== true && ${p} !== undefined`, () => {
m.if((0, e._)`${p} === true`, () => m.assign(b, !0), () => m.assign(b, (0, e._)`${b} || {}`).code((0, e._)`Object.assign(${b}, ${p})`));
}),
mergeToName: (m, p, b) => m.if((0, e._)`${b} !== true`, () => {
p === !0 ? m.assign(b, !0) : (m.assign(b, (0, e._)`${b} || {}`), g(m, b, p));
}),
mergeValues: (m, p) => m === !0 ? !0 : { ...m, ...p },
resultToName: P
}),
items: E({
mergeNames: (m, p, b) => m.if((0, e._)`${b} !== true && ${p} !== undefined`, () => m.assign(b, (0, e._)`${p} === true ? true : ${b} > ${p} ? ${b} : ${p}`)),
mergeToName: (m, p, b) => m.if((0, e._)`${b} !== true`, () => m.assign(b, p === !0 ? !0 : (0, e._)`${b} > ${p} ? ${b} : ${p}`)),
mergeValues: (m, p) => m === !0 ? !0 : Math.max(m, p),
resultToName: (m, p) => m.var("items", p)
})
};
function P(m, p) {
if (p === !0)
return m.var("props", !0);
const b = m.var("props", (0, e._)`{}`);
return p !== void 0 && g(m, b, p), b;
}
te.evaluatedPropsToName = P;
function g(m, p, b) {
Object.keys(b).forEach((T) => m.assign((0, e._)`${p}${(0, e.getProperty)(T)}`, !0));
}
te.setEvaluated = g;
const a = {};
function o(m, p) {
return m.scopeValue("func", {
ref: p,
code: a[p.code] || (a[p.code] = new r._Code(p.code))
});
}
te.useFunc = o;
var t;
(function(m) {
m[m.Num = 0] = "Num", m[m.Str = 1] = "Str";
})(t || (te.Type = t = {}));
function s(m, p, b) {
if (m instanceof e.Name) {
const T = p === t.Num;
return b ? T ? (0, e._)`"[" + ${m} + "]"` : (0, e._)`"['" + ${m} + "']"` : T ? (0, e._)`"/" + ${m}` : (0, e._)`"/" + ${m}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
}
return b ? (0, e.getProperty)(m).toString() : "/" + f(m);
}
te.getErrorPath = s;
function h(m, p, b = m.opts.strictSchema) {
if (b) {
if (p = `strict mode: ${p}`, b === !0)
throw new Error(p);
m.self.logger.warn(p);
}
}
return te.checkStrictMode = h, te;
}
var Tt = {}, hi;
function Xe() {
if (hi) return Tt;
hi = 1, Object.defineProperty(Tt, "__esModule", { value: !0 });
const e = se(), r = {
// validation function arguments
data: new e.Name("data"),
// data passed to validation function
// args passed from referencing schema
valCxt: new e.Name("valCxt"),
// validation/data context - should not be used directly, it is destructured to the names below
instancePath: new e.Name("instancePath"),
parentData: new e.Name("parentData"),
parentDataProperty: new e.Name("parentDataProperty"),
rootData: new e.Name("rootData"),
// root data - same as the data passed to the first/top validation function
dynamicAnchors: new e.Name("dynamicAnchors"),
// used to support recursiveRef and dynamicRef
// function scoped variables
vErrors: new e.Name("vErrors"),
// null or array of validation errors
errors: new e.Name("errors"),
// counter of validation errors
this: new e.Name("this"),
// "globals"
self: new e.Name("self"),
scope: new e.Name("scope"),
// JTD serialize/parse name for JSON string and position
json: new e.Name("json"),
jsonPos: new e.Name("jsonPos"),
jsonLen: new e.Name("jsonLen"),
jsonPart: new e.Name("jsonPart")
};
return Tt.default = r, Tt;
}
var yi;
function nn() {
return yi || (yi = 1, function(e) {
Object.defineProperty(e, "__esModule", { value: !0 }), e.extendErrors = e.resetErrorsCount = e.reportExtraError = e.reportError = e.keyword$DataError = e.keywordError = void 0;
const r = se(), v = ue(), u = Xe();
e.keywordError = {
message: ({ keyword: a }) => (0, r.str)`must pass "${a}" keyword validation`
}, e.keyword$DataError = {
message: ({ keyword: a, schemaType: o }) => o ? (0, r.str)`"${a}" keyword must be ${o} ($data)` : (0, r.str)`"${a}" keyword is invalid ($data)`
};
function $(a, o = e.keywordError, t, s) {
const { it: h } = a, { gen: m, compositeRule: p, allErrors: b } = h, T = w(a, o, t);
s ?? (p || b) ? d(m, T) : y(h, (0, r._)`[${T}]`);
}
e.reportError = $;
function n(a, o = e.keywordError, t) {
const { it: s } = a, { gen: h, compositeRule: m, allErrors: p } = s, b = w(a, o, t);
d(h, b), m || p || y(s, u.default.vErrors);
}
e.reportExtraError = n;
function l(a, o) {
a.assign(u.default.errors, o), a.if((0, r._)`${u.default.vErrors} !== null`, () => a.if(o, () => a.assign((0, r._)`${u.default.vErrors}.length`, o), () => a.assign(u.default.vErrors, null)));
}
e.resetErrorsCount = l;
function c({ gen: a, keyword: o, schemaValue: t, data: s, errsCount: h, it: m }) {
if (h === void 0)
throw new Error("ajv implementation error");
const p = a.name("err");
a.forRange("i", h, u.default.errors, (b) => {
a.const(p, (0, r._)`${u.default.vErrors}[${b}]`), a.if((0, r._)`${p}.instancePath === undefined`, () => a.assign((0, r._)`${p}.instancePath`, (0, r.strConcat)(u.default.instancePath, m.errorPath))), a.assign((0, r._)`${p}.schemaPath`, (0, r.str)`${m.errSchemaPath}/${o}`), m.opts.verbose && (a.assign((0, r._)`${p}.schema`, t), a.assign((0, r._)`${p}.data`, s));
});
}
e.extendErrors = c;
function d(a, o) {
const t = a.const("err", o);
a.if((0, r._)`${u.default.vErrors} === null`, () => a.assign(u.default.vErrors, (0, r._)`[${t}]`), (0, r._)`${u.default.vErrors}.push(${t})`), a.code((0, r._)`${u.default.errors}++`);
}
function y(a, o) {
const { gen: t, validateName: s, schemaEnv: h } = a;
h.$async ? t.throw((0, r._)`new ${a.ValidationError}(${o})`) : (t.assign((0, r._)`${s}.errors`, o), t.return(!1));
}
const f = {
keyword: new r.Name("keyword"),
schemaPath: new r.Name("schemaPath"),
// also used in JTD errors
params: new r.Name("params"),
propertyName: new r.Name("propertyName"),
message: new r.Name("message"),
schema: new r.Name("schema"),
parentSchema: new r.Name("parentSchema")
};
function w(a, o, t) {
const { createErrors: s } = a.it;
return s === !1 ? (0, r._)`{}` : S(a, o, t);
}
function S(a, o, t = {}) {
const { gen: s, it: h } = a, m = [
E(h, t),
P(a, t)
];
return g(a, o, m), s.object(...m);
}
function E({ errorPath: a }, { instancePath: o }) {
const t = o ? (0, r.str)`${a}${(0, v.getErrorPath)(o, v.Type.Str)}` : a;
return [u.default.instancePath, (0, r.strConcat)(u.default.instancePath, t)];
}
function P({ keyword: a, it: { errSchemaPath: o } }, { schemaPath: t, parentSchema: s }) {
let h = s ? o : (0, r.str)`${o}/${a}`;
return t && (h = (0, r.str)`${h}${(0, v.getErrorPath)(t, v.Type.Str)}`), [f.schemaPath, h];
}
function g(a, { params: o, message: t }, s) {
const { keyword: h, data: m, schemaValue: p, it: b } = a, { opts: T, propertyName: q, topSchemaRef: z, schemaPath: L } = b;
s.push([f.keyword, h], [f.params, typeof o == "function" ? o(a) : o || (0, r._)`{}`]), T.messages && s.push([f.message, typeof t == "function" ? t(a) : t]), T.verbose && s.push([f.schema, p], [f.parentSchema, (0, r._)`${z}${L}`], [u.default.data, m]), q && s.push([f.propertyName, q]);
}
}(Sn)), Sn;
}
var $i;
function ac() {
if ($i) return tt;
$i = 1, Object.defineProperty(tt, "__esModule", { value: !0 }), tt.boolOrEmptySchema = tt.topBoolOrEmptySchema = void 0;
const e = nn(), r = se(), v = Xe(), u = {
message: "boolean schema is false"
};
function $(c) {
const { gen: d, schema: y, validateName: f } = c;
y === !1 ? l(c, !1) : typeof y == "object" && y.$async === !0 ? d.return(v.default.data) : (d.assign((0, r._)`${f}.errors`, null), d.return(!0));
}
tt.topBoolOrEmptySchema = $;
function n(c, d) {
const { gen: y, schema: f } = c;
f === !1 ? (y.var(d, !1), l(c)) : y.var(d, !0);
}
tt.boolOrEmptySchema = n;
function l(c, d) {
const { gen: y, data: f } = c, w = {
gen: y,
keyword: "false schema",
data: f,
schema: !1,
schemaCode: !1,
schemaValue: !1,
params: {},
it: c
};
(0, e.reportError)(w, u, void 0, d);
}
return tt;
}
var Pe = {}, rt = {}, gi;
function Fo() {
if (gi) return rt;
gi = 1, Object.defineProperty(rt, "__esModule", { value: !0 }), rt.getRules = rt.isJSONType = void 0;
const e = ["string", "number", "integer", "boolean", "null", "object", "array"], r = new Set(e);
function v($) {
return typeof $ == "string" && r.has($);
}
rt.isJSONType = v;
function u() {
const $ = {
number: { type: "number", rules: [] },
string: { type: "string", rules: [] },
array: { type: "array", rules: [] },
object: { type: "object", rules: [] }
};
return {
types: { ...$, integer: !0, boolean: !0, null: !0 },
rules: [{ rules: [] }, $.number, $.string, $.array, $.object],
post: { rules: [] },
all: {},
keywords: {}
};
}
return rt.getRules = u, rt;
}
var Ue = {}, vi;
function Lo() {
if (vi) return Ue;
vi = 1, Object.defineProperty(Ue, "__esModule", { value: !0 }), Ue.shouldUseRule = Ue.shouldUseGroup = Ue.schemaHasRulesForType = void 0;
function e({ schema: u, self: $ }, n) {
const l = $.RULES.types[n];
return l && l !== !0 && r(u, l);
}
Ue.schemaHasRulesForType = e;
function r(u, $) {
return $.rules.some((n) => v(u, n));
}
Ue.shouldUseGroup = r;
function v(u, $) {
var n;
return u[$.keyword] !== void 0 || ((n = $.definition.implements) === null || n === void 0 ? void 0 : n.some((l) => u[l] !== void 0));
}
return Ue.shouldUseRule = v, Ue;
}
var _i;
function en() {
if (_i) return Pe;
_i = 1, Object.defineProperty(Pe, "__esModule", { value: !0 }), Pe.reportTypeError = Pe.checkDataTypes = Pe.checkDataType = Pe.coerceAndCheckDataType = Pe.getJSONTypes = Pe.getSchemaTypes = Pe.DataType = void 0;
const e = Fo(), r = Lo(), v = nn(), u = se(), $ = ue();
var n;
(function(t) {
t[t.Correct = 0] = "Correct", t[t.Wrong = 1] = "Wrong";
})(n || (Pe.DataType = n = {}));
function l(t) {
const s = c(t.type);
if (s.includes("null")) {
if (t.nullable === !1)
throw new Error("type: null contradicts nullable: false");
} else {
if (!s.length && t.nullable !== void 0)
throw new Error('"nullable" cannot be used without "type"');
t.nullable === !0 && s.push("null");
}
return s;
}
Pe.getSchemaTypes = l;
function c(t) {
const s = Array.isArray(t) ? t : t ? [t] : [];
if (s.every(e.isJSONType))
return s;
throw new Error("type must be JSONType or JSONType[]: " + s.join(","));
}
Pe.getJSONTypes = c;
function d(t, s) {
const { gen: h, data: m, opts: p } = t, b = f(s, p.coerceTypes), T = s.length > 0 && !(b.length === 0 && s.length === 1 && (0, r.schemaHasRulesForType)(t, s[0]));
if (T) {
const q = P(s, m, p.strictNumbers, n.Wrong);
h.if(q, () => {
b.length ? w(t, s, b) : a(t);
});
}
return T;
}
Pe.coerceAndCheckDataType = d;
const y = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
function f(t, s) {
return s ? t.filter((h) => y.has(h) || s === "array" && h === "array") : [];
}
function w(t, s, h) {
const { gen: m, data: p, opts: b } = t, T = m.let("dataType", (0, u._)`typeof ${p}`), q = m.let("coerced", (0, u._)`undefined`);
b.coerceTypes === "array" && m.if((0, u._)`${T} == 'object' && Array.isArray(${p}) && ${p}.length == 1`, () => m.assign(p, (0, u._)`${p}[0]`).assign(T, (0, u._)`typeof ${p}`).if(P(s, p, b.strictNumbers), () => m.assign(q, p))), m.if((0, u._)`${q} !== undefined`);
for (const L of h)
(y.has(L) || L === "array" && b.coerceTypes === "array") && z(L);
m.else(), a(t), m.endIf(), m.if((0, u._)`${q} !== undefined`, () => {
m.assign(p, q), S(t, q);
});
function z(L) {
switch (L) {
case "string":
m.elseIf((0, u._)`${T} == "number" || ${T} == "boolean"`).assign(q, (0, u._)`"" + ${p}`).elseIf((0, u._)`${p} === null`).assign(q, (0, u._)`""`);
return;
case "number":
m.elseIf((0, u._)`${T} == "boolean" || ${p} === null
|| (${T} == "string" && ${p} && ${p} == +${p})`).assign(q, (0, u._)`+${p}`);
return;
case "integer":
m.elseIf((0, u._)`${T} === "boolean" || ${p} === null
|| (${T} === "string" && ${p} && ${p} == +${p} && !(${p} % 1))`).assign(q, (0, u._)`+${p}`);
return;
case "boolean":
m.elseIf((0, u._)`${p} === "false" || ${p} === 0 || ${p} === null`).assign(q, !1).elseIf((0, u._)`${p} === "true" || ${p} === 1`).assign(q, !0);
return;
case "null":
m.elseIf((0, u._)`${p} === "" || ${p} === 0 || ${p} === false`), m.assign(q, null);
return;
case "array":
m.elseIf((0, u._)`${T} === "string" || ${T} === "number"
|| ${T} === "boolean" || ${p} === null`).assign(q, (0, u._)`[${p}]`);
}
}
}
function S({ gen: t, parentData: s, parentDataProperty: h }, m) {
t.if((0, u._)`${s} !== undefined`, () => t.assign((0, u._)`${s}[${h}]`, m));
}
function E(t, s, h, m = n.Correct) {
const p = m === n.Correct ? u.operators.EQ : u.operators.NEQ;
let b;
switch (t) {
case "null":
return (0, u._)`${s} ${p} null`;
case "array":
b = (0, u._)`Array.isArray(${s})`;
break;
case "object":
b = (0, u._)`${s} && typeof ${s} == "object" && !Array.isArray(${s})`;
break;
case "integer":
b = T((0, u._)`!(${s} % 1) && !isNaN(${s})`);
break;
case "number":
b = T();
break;
default:
return (0, u._)`typeof ${s} ${p} ${t}`;
}
return m === n.Correct ? b : (0, u.not)(b);
function T(q = u.nil) {
return (0, u.and)((0, u._)`typeof ${s} == "number"`, q, h ? (0, u._)`isFinite(${s})` : u.nil);
}
}
Pe.checkDataType = E;
function P(t, s, h, m) {
if (t.length === 1)
return E(t[0], s, h, m);
let p;
const b = (0, $.toHash)(t);
if (b.array && b.object) {
const T = (0, u._)`typeof ${s} != "object"`;
p = b.null ? T : (0, u._)`!${s} || ${T}`, delete b.null, delete b.array, delete b.object;
} else
p = u.nil;
b.number && delete b.integer;
for (const T in b)
p = (0, u.and)(p, E(T, s, h, m));
return p;
}
Pe.checkDataTypes = P;
const g = {
message: ({ schema: t }) => `must be ${t}`,
params: ({ schema: t, schemaValue: s }) => typeof t == "string" ? (0, u._)`{type: ${t}}` : (0, u._)`{type: ${s}}`
};
function a(t) {
const s = o(t);
(0, v.reportError)(s, g);
}
Pe.reportTypeError = a;
function o(t) {
const { gen: s, data: h, schema: m } = t, p = (0, $.schemaRefOrVal)(t, m, "type");
return {
gen: s,
keyword: "type",
data: h,
schema: m.type,
schemaCode: p,
schemaValue: p,
parentSchema: m,
params: {},
it: t
};
}
return Pe;
}
var $t = {}, bi;
function cc() {
if (bi) return $t;
bi = 1, Object.defineProperty($t, "__esModule", { value: !0 }), $t.assignDefaults = void 0;
const e = se(), r = ue();
function v($, n) {
const { properties: l, items: c } = $.schema;
if (n === "object" && l)
for (const d in l)
u($, d, l[d].default);
else n === "array" && Array.isArray(c) && c.forEach((d, y) => u($, y, d.default));
}
$t.assignDefaults = v;
function u($, n, l) {
const { gen: c, compositeRule: d, data: y, opts: f } = $;
if (l === void 0)
return