@beff/cli 0.0.103 → 0.0.104

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @beff/cli
2
2
 
3
+ ## 0.0.104
4
+
5
+ ### Patch Changes
6
+
7
+ - fix semtypes
8
+
3
9
  ## 0.0.103
4
10
 
5
11
  ### Patch Changes
package/dist-cli/cli.js CHANGED
@@ -45781,7 +45781,7 @@ var fs = __toESM(require("fs"));
45781
45781
  var path = __toESM(require("path"));
45782
45782
 
45783
45783
  // ts-node/generated/bundle.ts
45784
- var bundle_default = { "codegen-v2.js": '"use strict";\nimport {\n printErrors\n} from "@beff/client";\nconst JSON_PROTO = Object.getPrototypeOf({});\nfunction deepmergeConstructor(options) {\n function isNotPrototypeKey(value) {\n return value !== "constructor" && value !== "prototype" && value !== "__proto__";\n }\n function cloneArray(value) {\n let i = 0;\n const il = value.length;\n const result = new Array(il);\n for (i; i < il; ++i) {\n result[i] = clone(value[i]);\n }\n return result;\n }\n function cloneObject(target) {\n const result = {};\n if (cloneProtoObject && Object.getPrototypeOf(target) !== JSON_PROTO) {\n return cloneProtoObject(target);\n }\n const targetKeys = getKeys(target);\n let i, il, key;\n for (i = 0, il = targetKeys.length; i < il; ++i) {\n isNotPrototypeKey(key = targetKeys[i]) && (result[key] = clone(target[key]));\n }\n return result;\n }\n function concatArrays(target, source) {\n const tl = target.length;\n const sl = source.length;\n let i = 0;\n const result = new Array(tl + sl);\n for (i; i < tl; ++i) {\n result[i] = clone(target[i]);\n }\n for (i = 0; i < sl; ++i) {\n result[i + tl] = clone(source[i]);\n }\n return result;\n }\n const propertyIsEnumerable = Object.prototype.propertyIsEnumerable;\n function getSymbolsAndKeys(value) {\n const result = Object.keys(value);\n const keys = Object.getOwnPropertySymbols(value);\n for (let i = 0, il = keys.length; i < il; ++i) {\n propertyIsEnumerable.call(value, keys[i]) && result.push(keys[i]);\n }\n return result;\n }\n const getKeys = options?.symbols ? getSymbolsAndKeys : Object.keys;\n const cloneProtoObject = typeof options?.cloneProtoObject === "function" ? options.cloneProtoObject : void 0;\n function isMergeableObject(value) {\n return typeof value === "object" && value !== null && !(value instanceof RegExp) && !(value instanceof Date);\n }\n function isPrimitive(value) {\n return typeof value !== "object" || value === null;\n }\n const isPrimitiveOrBuiltIn = (\n \n typeof Buffer !== "undefined" ? (value) => typeof value !== "object" || value === null || value instanceof RegExp || value instanceof Date || \n value instanceof Buffer : (value) => typeof value !== "object" || value === null || value instanceof RegExp || value instanceof Date\n );\n const mergeArray = options && typeof options.mergeArray === "function" ? options.mergeArray({ clone, deepmerge: _deepmerge, getKeys, isMergeableObject }) : concatArrays;\n function clone(entry) {\n return isMergeableObject(entry) ? Array.isArray(entry) ? cloneArray(entry) : cloneObject(entry) : entry;\n }\n function mergeObject(target, source) {\n const result = {};\n const targetKeys = getKeys(target);\n const sourceKeys = getKeys(source);\n let i, il, key;\n for (i = 0, il = targetKeys.length; i < il; ++i) {\n isNotPrototypeKey(key = targetKeys[i]) && sourceKeys.indexOf(key) === -1 && \n (result[key] = clone(target[key]));\n }\n for (i = 0, il = sourceKeys.length; i < il; ++i) {\n if (!isNotPrototypeKey(key = sourceKeys[i])) {\n continue;\n }\n if (key in target) {\n if (targetKeys.indexOf(key) !== -1) {\n if (cloneProtoObject && isMergeableObject(source[key]) && Object.getPrototypeOf(source[key]) !== JSON_PROTO) {\n result[key] = cloneProtoObject(source[key]);\n } else {\n result[key] = _deepmerge(target[key], source[key]);\n }\n }\n } else {\n result[key] = clone(source[key]);\n }\n }\n return result;\n }\n function _deepmerge(target, source) {\n const sourceIsArray = Array.isArray(source);\n const targetIsArray = Array.isArray(target);\n if (isPrimitive(source)) {\n return source;\n } else if (isPrimitiveOrBuiltIn(target)) {\n return clone(source);\n } else if (sourceIsArray && targetIsArray) {\n return mergeArray(target, source);\n } else if (sourceIsArray !== targetIsArray) {\n return clone(source);\n } else {\n return mergeObject(target, source);\n }\n }\n function _deepmergeAll() {\n switch (arguments.length) {\n case 0:\n return {};\n case 1:\n return clone(arguments[0]);\n case 2:\n return _deepmerge(arguments[0], arguments[1]);\n }\n let result;\n for (let i = 0, il = arguments.length; i < il; ++i) {\n result = _deepmerge(result, arguments[i]);\n }\n return result;\n }\n return _deepmergeAll;\n}\nfunction deepmergeArray(options) {\n const deepmerge2 = options.deepmerge;\n const clone = options.clone;\n return function(target, source) {\n let i = 0;\n const tl = target.length;\n const sl = source.length;\n const il = Math.max(target.length, source.length);\n const result = new Array(il);\n for (i = 0; i < il; ++i) {\n if (i < sl) {\n result[i] = deepmerge2(target[i], source[i]);\n } else {\n result[i] = clone(target[i]);\n }\n }\n return result;\n };\n}\nconst deepmerge = deepmergeConstructor({ mergeArray: deepmergeArray });\nfunction buildUnionError(ctx, errors, received) {\n return [\n {\n path: [...ctx.path],\n received,\n errors,\n isUnionError: true\n }\n ];\n}\nfunction buildError(ctx, message, received) {\n return [\n {\n message,\n path: [...ctx.path],\n received\n }\n ];\n}\nfunction pushPath(ctx, key) {\n ctx.path.push(key);\n}\nfunction popPath(ctx) {\n ctx.path.pop();\n}\nfunction printPath(ctx) {\n return ctx.path.join(".");\n}\nfunction buildSchemaErrorMessage(ctx, message) {\n return `Failed to print schema. At ${printPath(ctx)}: ${message}`;\n}\nconst limitedCommaJoinJson = (arr) => {\n const limit = 3;\n if (arr.length < limit) {\n return arr.map((it) => JSON.stringify(it)).join(", ");\n }\n return arr.slice(0, limit).map((it) => JSON.stringify(it)).join(", ") + `...`;\n};\nconst stringFormatters = {};\nfunction registerStringFormatter(name, validator) {\n stringFormatters[name] = validator;\n}\nconst numberFormatters = {};\nfunction registerNumberFormatter(name, validator) {\n numberFormatters[name] = validator;\n}\nclass TypeofRuntype {\n typeName;\n constructor(typeName) {\n this.typeName = typeName;\n }\n describe(_ctx) {\n return this.typeName;\n }\n schema(_ctx) {\n return { type: this.typeName };\n }\n validate(_ctx, input) {\n return typeof input === this.typeName;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected " + this.typeName, input);\n }\n}\nclass AnyRuntype {\n describe(_ctx) {\n return "any";\n }\n schema(_ctx) {\n return {};\n }\n validate(_ctx, _input) {\n return true;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected any", input);\n }\n}\nclass NullRuntype {\n describe(_ctx) {\n return "null";\n }\n schema(_ctx) {\n return { type: "null" };\n }\n validate(_ctx, input) {\n return input == null;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected nullish value", input);\n }\n}\nclass NeverRuntype {\n describe(_ctx) {\n return "never";\n }\n schema(_ctx) {\n return { anyOf: [] };\n }\n validate(_ctx, _input) {\n return false;\n }\n parseAfterValidation(_ctx, _input) {\n throw new Error("unreachable");\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected never", input);\n }\n}\nclass ConstRuntype {\n value;\n constructor(value) {\n this.value = value ?? null;\n }\n describe(_ctx) {\n return JSON.stringify(this.value);\n }\n schema(_ctx) {\n return { const: this.value };\n }\n validate(_ctx, input) {\n if (this.value == null) {\n return input == this.value;\n }\n return input === this.value;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected ${JSON.stringify(this.value)}`, input);\n }\n}\nclass RegexRuntype {\n regex;\n description;\n constructor(regex, description) {\n this.regex = regex;\n this.description = description;\n }\n describe(_ctx) {\n return "`" + this.description + "`";\n }\n schema(_ctx) {\n return { type: "string", pattern: this.description };\n }\n validate(_ctx, input) {\n if (typeof input === "string") {\n return this.regex.test(input);\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected string matching ${this.description}`, input);\n }\n}\nclass DateRuntype {\n describe(_ctx) {\n return "Date";\n }\n schema(ctx) {\n throw new Error(buildSchemaErrorMessage(ctx, "Cannot generate JSON Schema for Date"));\n }\n validate(_ctx, input) {\n return input instanceof Date;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected Date`, input);\n }\n}\nclass BigIntRuntype {\n describe(_ctx) {\n return "BigInt";\n }\n schema(ctx) {\n throw new Error(buildSchemaErrorMessage(ctx, "Cannot generate JSON Schema for BigInt"));\n }\n validate(_ctx, input) {\n return typeof input === "bigint";\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected BigInt`, input);\n }\n}\nclass StringWithFormatRuntype {\n formats;\n constructor(formats) {\n this.formats = formats;\n }\n describe(ctx) {\n if (this.formats.length === 0) {\n throw new Error("INTERNAL ERROR: No formats provided");\n }\n const [first, ...rest] = this.formats;\n let acc = `StringFormat<"${first}">`;\n for (const r of rest) {\n acc = `StringFormatExtends<${acc}, "${r}">`;\n }\n return acc;\n }\n schema(ctx) {\n return {\n type: "string",\n format: this.formats.join(" and ")\n };\n }\n validate(ctx, input) {\n if (typeof input !== "string") {\n return false;\n }\n for (const f of this.formats) {\n const validator = stringFormatters[f];\n if (validator == null) {\n return false;\n }\n if (!validator(input)) {\n return false;\n }\n }\n return true;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected string with format "${this.formats.join(" and ")}"`, input);\n }\n}\nclass NumberWithFormatRuntype {\n formats;\n constructor(formats) {\n this.formats = formats;\n }\n describe(ctx) {\n if (this.formats.length === 0) {\n throw new Error("INTERNAL ERROR: No formats provided");\n }\n const [first, ...rest] = this.formats;\n let acc = `NumberFormat<"${first}">`;\n for (const r of rest) {\n acc = `NumberFormatExtends<${acc}, "${r}">`;\n }\n return acc;\n }\n schema(ctx) {\n return {\n type: "number",\n format: this.formats.join(" and ")\n };\n }\n validate(ctx, input) {\n if (typeof input !== "number") {\n return false;\n }\n for (const f of this.formats) {\n const validator = numberFormatters[f];\n if (validator == null) {\n return false;\n }\n if (!validator(input)) {\n return false;\n }\n }\n return true;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected number with format "${this.formats.join(" and ")}"`, input);\n }\n}\nclass AnyOfConstsRuntype {\n values;\n constructor(values) {\n this.values = values;\n }\n describe(ctx) {\n const parts = this.values.map((it) => JSON.stringify(it));\n return parts.join(" | ");\n }\n schema(ctx) {\n return {\n enum: this.values\n };\n }\n validate(ctx, input) {\n if (input == null) {\n if (this.values.includes(null)) {\n return true;\n }\n }\n return this.values.includes(input);\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected one of ${limitedCommaJoinJson(this.values)}`, input);\n }\n}\nclass TupleRuntype {\n prefix;\n rest;\n constructor(prefix, rest) {\n this.prefix = prefix;\n this.rest = rest;\n }\n describe(ctx) {\n const prefix = this.prefix.map((it) => it.describe(ctx)).join(", ");\n const rest = this.rest != null ? `...Array<${this.rest.describe(ctx)}>` : null;\n const inner = [prefix, rest].filter((it) => it != null && it.length > 0).join(", ");\n return `[${inner}]`;\n }\n schema(ctx) {\n pushPath(ctx, "[]");\n const prefixItems = this.prefix.map((it) => it.schema(ctx));\n const items = this.rest != null ? this.rest.schema(ctx) : false;\n popPath(ctx);\n return {\n type: "array",\n prefixItems,\n items\n };\n }\n validate(ctx, input) {\n if (Array.isArray(input)) {\n let idx = 0;\n for (const prefixItem of this.prefix) {\n if (!prefixItem.validate(ctx, input[idx])) {\n return false;\n }\n idx++;\n }\n if (this.rest != null) {\n for (let i = idx; i < input.length; i++) {\n if (!this.rest.validate(ctx, input[i])) {\n return false;\n }\n }\n } else {\n if (input.length > idx) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n let idx = 0;\n let acc = [];\n for (const prefixItem of this.prefix) {\n acc.push(prefixItem.parseAfterValidation(ctx, input[idx]));\n idx++;\n }\n if (this.rest != null) {\n for (let i = idx; i < input.length; i++) {\n acc.push(this.rest.parseAfterValidation(ctx, input[i]));\n }\n }\n return acc;\n }\n reportDecodeError(ctx, input) {\n if (!Array.isArray(input)) {\n return buildError(ctx, "expected tuple", input);\n }\n let idx = 0;\n let acc = [];\n for (const prefixItem of this.prefix) {\n const ok = prefixItem.validate(ctx, input[idx]);\n if (!ok) {\n pushPath(ctx, `[${idx}]`);\n const errors = prefixItem.reportDecodeError(ctx, input[idx]);\n acc.push(...errors);\n popPath(ctx);\n }\n idx++;\n }\n if (this.rest != null) {\n for (let i = idx; i < input.length; i++) {\n const ok = this.rest.validate(ctx, input[i]);\n if (!ok) {\n pushPath(ctx, `[${i}]`);\n const errors = this.rest.reportDecodeError(ctx, input[i]);\n acc.push(...errors);\n popPath(ctx);\n }\n }\n }\n return acc;\n }\n}\nclass AllOfRuntype {\n schemas;\n constructor(schemas) {\n this.schemas = schemas;\n }\n describe(ctx) {\n return `(${this.schemas.map((it) => it.describe(ctx)).join(" & ")})`;\n }\n schema(ctx) {\n return {\n allOf: this.schemas.map((it) => it.schema(ctx))\n };\n }\n validate(ctx, input) {\n for (const it of this.schemas) {\n const isObj = typeof input === "object";\n if (!isObj) {\n return false;\n }\n if (!it.validate(ctx, input)) {\n return false;\n }\n }\n return true;\n }\n parseAfterValidation(ctx, input) {\n let acc = {};\n for (const it of this.schemas) {\n const parsed = it.parseAfterValidation(ctx, input);\n if (typeof parsed !== "object") {\n throw new Error("INTERNAL ERROR: AllOfParser: Expected object");\n }\n acc = { ...acc, ...parsed };\n }\n return acc;\n }\n reportDecodeError(ctx, input) {\n const acc = [];\n for (const v of this.schemas) {\n const errors = v.reportDecodeError(ctx, input);\n acc.push(...errors);\n }\n return acc;\n }\n}\nclass AnyOfRuntype {\n schemas;\n constructor(schemas) {\n this.schemas = schemas;\n }\n schema(ctx) {\n return {\n anyOf: this.schemas.map((it) => it.schema(ctx))\n };\n }\n validate(ctx, input) {\n for (const it of this.schemas) {\n if (it.validate(ctx, input)) {\n return true;\n }\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n const items = [];\n for (const it of this.schemas) {\n if (it.validate(ctx, input)) {\n items.push(it.parseAfterValidation(ctx, input));\n }\n }\n return deepmerge(...items);\n }\n reportDecodeError(ctx, input) {\n const acc = [];\n const oldPaths = ctx.path;\n ctx.path = [];\n for (const v of this.schemas) {\n const errors = v.reportDecodeError(ctx, input);\n acc.push(...errors);\n }\n ctx.path = oldPaths;\n return buildUnionError(ctx, acc, input);\n }\n describe(ctx) {\n return `(${this.schemas.map((it) => it.describe(ctx)).join(" | ")})`;\n }\n}\nclass ArrayRuntype {\n itemParser;\n constructor(itemParser) {\n this.itemParser = itemParser;\n }\n schema(ctx) {\n pushPath(ctx, "[]");\n const items = this.itemParser.schema(ctx);\n popPath(ctx);\n return {\n type: "array",\n items\n };\n }\n validate(ctx, input) {\n if (Array.isArray(input)) {\n for (let i = 0; i < input.length; i++) {\n const v = input[i];\n const ok = this.itemParser.validate(ctx, v);\n if (!ok) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n return input.map((v) => this.itemParser.parseAfterValidation(ctx, v));\n }\n reportDecodeError(ctx, input) {\n if (!Array.isArray(input)) {\n return buildError(ctx, "expected array", input);\n }\n let acc = [];\n for (let i = 0; i < input.length; i++) {\n const ok = this.itemParser.validate(ctx, input[i]);\n if (!ok) {\n pushPath(ctx, `[${i}]`);\n const v = input[i];\n const arr2 = this.itemParser.reportDecodeError(ctx, v);\n acc.push(...arr2);\n popPath(ctx);\n }\n }\n return acc;\n }\n describe(ctx) {\n return `Array<${this.itemParser.describe(ctx)}>`;\n }\n}\nclass AnyOfDiscriminatedRuntype {\n schemas;\n discriminator;\n mapping;\n constructor(schemas, discriminator, mapping) {\n this.schemas = schemas;\n this.discriminator = discriminator;\n this.mapping = mapping;\n }\n schema(ctx) {\n return {\n anyOf: this.schemas.map((it) => it.schema(ctx))\n };\n }\n validate(ctx, input) {\n if (typeof input !== "object" || input == null) {\n return false;\n }\n const d = input[this.discriminator];\n if (d == null) {\n return false;\n }\n const v = this.mapping[d];\n if (v == null) {\n return false;\n }\n return v.validate(ctx, input);\n }\n parseAfterValidation(ctx, input) {\n const parser = this.mapping[input[this.discriminator]];\n if (parser == null) {\n throw new Error(\n "INTERNAL ERROR: Missing parser for discriminator " + JSON.stringify(input[this.discriminator])\n );\n }\n return {\n ...parser.parseAfterValidation(ctx, input),\n [this.discriminator]: input[this.discriminator]\n };\n }\n reportDecodeError(ctx, input) {\n if (input == null || typeof input !== "object") {\n return buildError(ctx, "expected object", input);\n }\n const d = input[this.discriminator];\n if (d == null) {\n return buildError(ctx, "expected discriminator key " + JSON.stringify(this.discriminator), input);\n }\n const v = this.mapping[d];\n if (v == null) {\n pushPath(ctx, this.discriminator);\n const errs = buildError(\n ctx,\n "expected one of " + Object.keys(this.mapping).map((it) => JSON.stringify(it)).join(", "),\n d\n );\n popPath(ctx);\n return errs;\n }\n return v.reportDecodeError(ctx, input);\n }\n describe(ctx) {\n return `(${this.schemas.map((it) => it.describe(ctx)).join(" | ")})`;\n }\n}\nclass MappedRecordRuntype {\n keyParser;\n valueParser;\n constructor(keyParser, valueParser) {\n this.keyParser = keyParser;\n this.valueParser = valueParser;\n }\n describe(ctx) {\n const k = this.keyParser.describe(ctx);\n const v = this.valueParser.describe(ctx);\n return `Record<${k}, ${v}>`;\n }\n schema(ctx) {\n return {\n type: "object",\n additionalProperties: this.valueParser.schema(ctx),\n propertyNames: this.keyParser.schema(ctx)\n };\n }\n validate(ctx, input) {\n if (typeof input !== "object" || input == null) {\n return false;\n }\n for (const k in input) {\n const v = input[k];\n if (!this.keyParser.validate(ctx, k) || !this.valueParser.validate(ctx, v)) {\n return false;\n }\n }\n return true;\n }\n parseAfterValidation(ctx, input) {\n const result = {};\n for (const k in input) {\n const parsedKey = this.keyParser.parseAfterValidation(ctx, k);\n const parsedValue = this.valueParser.parseAfterValidation(ctx, input[k]);\n result[parsedKey] = parsedValue;\n }\n return result;\n }\n reportDecodeError(ctx, input) {\n if (typeof input !== "object" || input == null) {\n return buildError(ctx, "expected object", input);\n }\n let acc = [];\n for (const k in input) {\n const v = input[k];\n const okKey = this.keyParser.validate(ctx, k);\n if (!okKey) {\n pushPath(ctx, k);\n const errs = this.keyParser.reportDecodeError(ctx, k);\n acc.push(...errs);\n popPath(ctx);\n }\n const okValue = this.valueParser.validate(ctx, v);\n if (!okValue) {\n pushPath(ctx, k);\n const errs = this.valueParser.reportDecodeError(ctx, v);\n acc.push(...errs);\n popPath(ctx);\n }\n }\n return acc;\n }\n}\nclass ObjectRuntype {\n properties;\n restParser;\n constructor(properties, restParser) {\n this.properties = properties;\n this.restParser = restParser;\n }\n describe(ctx) {\n const sortedKeys = Object.keys(this.properties).sort();\n const props = sortedKeys.map((k) => {\n const it = this.properties[k];\n return `${k}: ${it.describe(ctx)}`;\n }).join(", ");\n const rest = this.restParser != null ? `[K in string]: ${this.restParser.describe(ctx)}` : null;\n const content = [props, rest].filter((it) => it != null && it.length > 0).join(", ");\n return `{ ${content} }`;\n }\n schema(ctx) {\n const properties = {};\n for (const k in this.properties) {\n pushPath(ctx, k);\n properties[k] = this.properties[k].schema(ctx);\n popPath(ctx);\n }\n const required = Object.keys(this.properties);\n const additionalProperties = this.restParser != null ? this.restParser.schema(ctx) : false;\n return {\n type: "object",\n properties,\n required,\n additionalProperties\n };\n }\n validate(ctx, input) {\n if (typeof input === "object" && !Array.isArray(input) && input !== null) {\n const configKeys = Object.keys(this.properties);\n for (const k of configKeys) {\n const validator = this.properties[k];\n if (!validator.validate(ctx, input[k])) {\n return false;\n }\n }\n if (this.restParser != null) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n for (const k of extraKeys) {\n const v = input[k];\n if (!this.restParser.validate(ctx, v)) {\n return false;\n }\n }\n } else {\n if (ctx.disallowExtraProperties) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n if (extraKeys.length > 0) {\n return false;\n }\n }\n }\n return true;\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n let acc = {};\n const inputKeys = Object.keys(input);\n for (const k of inputKeys) {\n const v = input[k];\n if (k in this.properties) {\n const itemParsed = this.properties[k].parseAfterValidation(ctx, v);\n acc[k] = itemParsed;\n } else if (this.restParser != null) {\n const restParsed = this.restParser.parseAfterValidation(ctx, v);\n acc[k] = restParsed;\n }\n }\n return acc;\n }\n reportDecodeError(ctx, input) {\n if (typeof input !== "object" || Array.isArray(input) || input === null) {\n return buildError(ctx, "expected object", input);\n }\n let acc = [];\n const configKeys = Object.keys(this.properties);\n for (const k of configKeys) {\n const ok = this.properties[k].validate(ctx, input[k]);\n if (!ok) {\n pushPath(ctx, k);\n const arr2 = this.properties[k].reportDecodeError(ctx, input[k]);\n acc.push(...arr2);\n popPath(ctx);\n }\n }\n if (this.restParser != null) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n for (const k of extraKeys) {\n const ok = this.restParser.validate(ctx, input[k]);\n if (!ok) {\n pushPath(ctx, k);\n const arr2 = this.restParser.reportDecodeError(ctx, input[k]);\n acc.push(...arr2);\n popPath(ctx);\n }\n }\n } else {\n if (ctx.disallowExtraProperties) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n if (extraKeys.length > 0) {\n return extraKeys.flatMap((k) => {\n pushPath(ctx, k);\n const err = buildError(ctx, `extra property`, input[k]);\n popPath(ctx);\n return err;\n });\n }\n }\n }\n return acc;\n }\n}\nclass RefRuntype {\n refName;\n constructor(refName) {\n this.refName = refName;\n }\n describe(ctx) {\n const name = this.refName;\n const to = namedRuntypes[this.refName];\n if (ctx.measure) {\n ctx.deps_counter[name] = (ctx.deps_counter[name] || 0) + 1;\n if (ctx.deps[name]) {\n return name;\n }\n ctx.deps[name] = true;\n ctx.deps[name] = to.describe(ctx);\n return name;\n } else {\n if (ctx.deps_counter[name] > 1) {\n if (!ctx.deps[name]) {\n ctx.deps[name] = true;\n ctx.deps[name] = to.describe(ctx);\n }\n return name;\n } else {\n return to.describe(ctx);\n }\n }\n }\n schema(ctx) {\n const name = this.refName;\n const to = namedRuntypes[this.refName];\n if (ctx.seen[name]) {\n return {};\n }\n ctx.seen[name] = true;\n var tmp = to.schema(ctx);\n delete ctx.seen[name];\n return tmp;\n }\n validate(ctx, input) {\n const to = namedRuntypes[this.refName];\n return to.validate(ctx, input);\n }\n parseAfterValidation(ctx, input) {\n const to = namedRuntypes[this.refName];\n return to.parseAfterValidation(ctx, input);\n }\n reportDecodeError(ctx, input) {\n const to = namedRuntypes[this.refName];\n return to.reportDecodeError(ctx, input);\n }\n}\nconst buildParsers = (args) => {\n const stringFormats = args?.stringFormats ?? {};\n for (const k of RequiredStringFormats) {\n if (stringFormats[k] == null) {\n throw new Error(`Missing custom format ${k}`);\n }\n }\n Object.keys(stringFormats).forEach((k) => {\n const v = stringFormats[k];\n registerStringFormatter(k, v);\n });\n const numberFormats = args?.numberFormats ?? {};\n for (const k of RequiredNumberFormats) {\n if (numberFormats[k] == null) {\n throw new Error(`Missing custom format ${k}`);\n }\n }\n Object.keys(numberFormats).forEach((k) => {\n const v = numberFormats[k];\n registerNumberFormatter(k, v);\n });\n let acc = {};\n for (const k of Object.keys(buildParsersInput)) {\n const impl = buildParsersInput[k];\n const validate = (input, options) => {\n const disallowExtraProperties = options?.disallowExtraProperties ?? false;\n const ctx = { disallowExtraProperties };\n const ok = impl.validate(ctx, input);\n if (typeof ok !== "boolean") {\n throw new Error("INTERNAL ERROR: Expected boolean");\n }\n return ok;\n };\n const schema = () => {\n const ctx = {\n path: [],\n seen: {}\n };\n return impl.schema(ctx);\n };\n const describe = () => {\n const ctx = {\n deps: {},\n deps_counter: {},\n measure: true\n };\n let out = impl.describe(ctx);\n ctx["deps"] = {};\n ctx["measure"] = false;\n out = impl.describe(ctx);\n let sortedDepsKeys = Object.keys(ctx.deps).sort();\n const depsPart = sortedDepsKeys.map((key) => {\n return `type ${key} = ${ctx.deps[key]};`;\n }).join("\\n\\n");\n const outPart = `type Codec${k} = ${out};`;\n return [depsPart, outPart].filter((it2) => it2 != null && it2.length > 0).join("\\n\\n");\n };\n const safeParse = (input, options) => {\n const disallowExtraProperties = options?.disallowExtraProperties ?? false;\n const ok = validate(input, options);\n if (ok) {\n let ctx2 = { disallowExtraProperties };\n const parsed = impl.parseAfterValidation(ctx2, input);\n return { success: true, data: parsed };\n }\n let ctx = { path: [], disallowExtraProperties };\n return {\n success: false,\n errors: impl.reportDecodeError(ctx, input).slice(0, 10)\n };\n };\n const parse = (input, options) => {\n const safe = safeParse(input, options);\n if (safe.success) {\n return safe.data;\n }\n const explained = printErrors(safe.errors, []);\n throw new Error(`Failed to parse ${k} - ${explained}`);\n };\n const zod = () => {\n return z.custom(\n (data) => validate(data),\n (val) => {\n const errors = impl.reportDecodeError({ path: [], disallowExtraProperties: false }, val);\n return printErrors(errors, []);\n }\n );\n };\n const it = {\n validate,\n schema,\n describe,\n safeParse,\n parse,\n zod,\n name: k\n };\n acc[k] = it;\n }\n return acc;\n};\n', "parser.d.ts": 'import { BuildParserFunction } from "@beff/client";\n\ndeclare const _exports: {\n buildParsers: BuildParserFunction;\n};\n\nexport default _exports;\n' };
45784
+ var bundle_default = { "codegen-v2.js": '"use strict";\nimport {\n printErrors\n} from "@beff/client";\nconst JSON_PROTO = Object.getPrototypeOf({});\nfunction deepmergeConstructor(options) {\n function isNotPrototypeKey(value) {\n return value !== "constructor" && value !== "prototype" && value !== "__proto__";\n }\n function cloneArray(value) {\n let i = 0;\n const il = value.length;\n const result = new Array(il);\n for (i; i < il; ++i) {\n result[i] = clone(value[i]);\n }\n return result;\n }\n function cloneObject(target) {\n const result = {};\n if (cloneProtoObject && Object.getPrototypeOf(target) !== JSON_PROTO) {\n return cloneProtoObject(target);\n }\n const targetKeys = getKeys(target);\n let i, il, key;\n for (i = 0, il = targetKeys.length; i < il; ++i) {\n isNotPrototypeKey(key = targetKeys[i]) && (result[key] = clone(target[key]));\n }\n return result;\n }\n function concatArrays(target, source) {\n const tl = target.length;\n const sl = source.length;\n let i = 0;\n const result = new Array(tl + sl);\n for (i; i < tl; ++i) {\n result[i] = clone(target[i]);\n }\n for (i = 0; i < sl; ++i) {\n result[i + tl] = clone(source[i]);\n }\n return result;\n }\n const propertyIsEnumerable = Object.prototype.propertyIsEnumerable;\n function getSymbolsAndKeys(value) {\n const result = Object.keys(value);\n const keys = Object.getOwnPropertySymbols(value);\n for (let i = 0, il = keys.length; i < il; ++i) {\n propertyIsEnumerable.call(value, keys[i]) && result.push(keys[i]);\n }\n return result;\n }\n const getKeys = options?.symbols ? getSymbolsAndKeys : Object.keys;\n const cloneProtoObject = typeof options?.cloneProtoObject === "function" ? options.cloneProtoObject : void 0;\n function isMergeableObject(value) {\n return typeof value === "object" && value !== null && !(value instanceof RegExp) && !(value instanceof Date);\n }\n function isPrimitive(value) {\n return typeof value !== "object" || value === null;\n }\n const isPrimitiveOrBuiltIn = (\n \n typeof Buffer !== "undefined" ? (value) => typeof value !== "object" || value === null || value instanceof RegExp || value instanceof Date || \n value instanceof Buffer : (value) => typeof value !== "object" || value === null || value instanceof RegExp || value instanceof Date\n );\n const mergeArray = options && typeof options.mergeArray === "function" ? options.mergeArray({ clone, deepmerge: _deepmerge, getKeys, isMergeableObject }) : concatArrays;\n function clone(entry) {\n return isMergeableObject(entry) ? Array.isArray(entry) ? cloneArray(entry) : cloneObject(entry) : entry;\n }\n function mergeObject(target, source) {\n const result = {};\n const targetKeys = getKeys(target);\n const sourceKeys = getKeys(source);\n let i, il, key;\n for (i = 0, il = targetKeys.length; i < il; ++i) {\n isNotPrototypeKey(key = targetKeys[i]) && sourceKeys.indexOf(key) === -1 && \n (result[key] = clone(target[key]));\n }\n for (i = 0, il = sourceKeys.length; i < il; ++i) {\n if (!isNotPrototypeKey(key = sourceKeys[i])) {\n continue;\n }\n if (key in target) {\n if (targetKeys.indexOf(key) !== -1) {\n if (cloneProtoObject && isMergeableObject(source[key]) && Object.getPrototypeOf(source[key]) !== JSON_PROTO) {\n result[key] = cloneProtoObject(source[key]);\n } else {\n result[key] = _deepmerge(target[key], source[key]);\n }\n }\n } else {\n result[key] = clone(source[key]);\n }\n }\n return result;\n }\n function _deepmerge(target, source) {\n const sourceIsArray = Array.isArray(source);\n const targetIsArray = Array.isArray(target);\n if (isPrimitive(source)) {\n return source;\n } else if (isPrimitiveOrBuiltIn(target)) {\n return clone(source);\n } else if (sourceIsArray && targetIsArray) {\n return mergeArray(target, source);\n } else if (sourceIsArray !== targetIsArray) {\n return clone(source);\n } else {\n return mergeObject(target, source);\n }\n }\n function _deepmergeAll() {\n switch (arguments.length) {\n case 0:\n return {};\n case 1:\n return clone(arguments[0]);\n case 2:\n return _deepmerge(arguments[0], arguments[1]);\n }\n let result;\n for (let i = 0, il = arguments.length; i < il; ++i) {\n result = _deepmerge(result, arguments[i]);\n }\n return result;\n }\n return _deepmergeAll;\n}\nfunction deepmergeArray(options) {\n const deepmerge2 = options.deepmerge;\n const clone = options.clone;\n return function(target, source) {\n let i = 0;\n const tl = target.length;\n const sl = source.length;\n const il = Math.max(target.length, source.length);\n const result = new Array(il);\n for (i = 0; i < il; ++i) {\n if (i < sl) {\n result[i] = deepmerge2(target[i], source[i]);\n } else {\n result[i] = clone(target[i]);\n }\n }\n return result;\n };\n}\nconst deepmerge = deepmergeConstructor({ mergeArray: deepmergeArray });\nfunction buildUnionError(ctx, errors, received) {\n return [\n {\n path: [...ctx.path],\n received,\n errors,\n isUnionError: true\n }\n ];\n}\nfunction buildError(ctx, message, received) {\n return [\n {\n message,\n path: [...ctx.path],\n received\n }\n ];\n}\nfunction pushPath(ctx, key) {\n ctx.path.push(key);\n}\nfunction popPath(ctx) {\n ctx.path.pop();\n}\nfunction printPath(ctx) {\n return ctx.path.join(".");\n}\nfunction buildSchemaErrorMessage(ctx, message) {\n return `Failed to print schema. At ${printPath(ctx)}: ${message}`;\n}\nconst limitedCommaJoinJson = (arr) => {\n const limit = 3;\n if (arr.length < limit) {\n return arr.map((it) => JSON.stringify(it)).join(", ");\n }\n return arr.slice(0, limit).map((it) => JSON.stringify(it)).join(", ") + `...`;\n};\nconst stringFormatters = {};\nfunction registerStringFormatter(name, validator) {\n stringFormatters[name] = validator;\n}\nconst numberFormatters = {};\nfunction registerNumberFormatter(name, validator) {\n numberFormatters[name] = validator;\n}\nclass TypeofRuntype {\n typeName;\n constructor(typeName) {\n this.typeName = typeName;\n }\n describe(_ctx) {\n return this.typeName;\n }\n schema(_ctx) {\n return { type: this.typeName };\n }\n validate(_ctx, input) {\n return typeof input === this.typeName;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected " + this.typeName, input);\n }\n}\nclass AnyRuntype {\n describe(_ctx) {\n return "any";\n }\n schema(_ctx) {\n return {};\n }\n validate(_ctx, _input) {\n return true;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected any", input);\n }\n}\nclass NullRuntype {\n describe(_ctx) {\n return "null";\n }\n schema(_ctx) {\n return { type: "null" };\n }\n validate(_ctx, input) {\n return input == null;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected nullish value", input);\n }\n}\nclass NeverRuntype {\n describe(_ctx) {\n return "never";\n }\n schema(_ctx) {\n return { anyOf: [] };\n }\n validate(_ctx, _input) {\n return false;\n }\n parseAfterValidation(_ctx, _input) {\n throw new Error("unreachable");\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, "expected never", input);\n }\n}\nclass ConstRuntype {\n value;\n constructor(value) {\n this.value = value ?? null;\n }\n describe(_ctx) {\n return JSON.stringify(this.value);\n }\n schema(_ctx) {\n return { const: this.value };\n }\n validate(_ctx, input) {\n if (this.value == null) {\n return input == this.value;\n }\n return input === this.value;\n }\n parseAfterValidation(_ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected ${JSON.stringify(this.value)}`, input);\n }\n}\nclass RegexRuntype {\n regex;\n description;\n constructor(regex, description) {\n this.regex = regex;\n this.description = description;\n }\n describe(_ctx) {\n return this.description;\n }\n schema(_ctx) {\n return { type: "string", pattern: this.description };\n }\n validate(_ctx, input) {\n if (typeof input === "string") {\n return this.regex.test(input);\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected string matching ${this.description}`, input);\n }\n}\nclass DateRuntype {\n describe(_ctx) {\n return "Date";\n }\n schema(ctx) {\n throw new Error(buildSchemaErrorMessage(ctx, "Cannot generate JSON Schema for Date"));\n }\n validate(_ctx, input) {\n return input instanceof Date;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected Date`, input);\n }\n}\nclass BigIntRuntype {\n describe(_ctx) {\n return "BigInt";\n }\n schema(ctx) {\n throw new Error(buildSchemaErrorMessage(ctx, "Cannot generate JSON Schema for BigInt"));\n }\n validate(_ctx, input) {\n return typeof input === "bigint";\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected BigInt`, input);\n }\n}\nclass StringWithFormatRuntype {\n formats;\n constructor(formats) {\n this.formats = formats;\n }\n describe(ctx) {\n if (this.formats.length === 0) {\n throw new Error("INTERNAL ERROR: No formats provided");\n }\n const [first, ...rest] = this.formats;\n let acc = `StringFormat<"${first}">`;\n for (const r of rest) {\n acc = `StringFormatExtends<${acc}, "${r}">`;\n }\n return acc;\n }\n schema(ctx) {\n return {\n type: "string",\n format: this.formats.join(" and ")\n };\n }\n validate(ctx, input) {\n if (typeof input !== "string") {\n return false;\n }\n for (const f of this.formats) {\n const validator = stringFormatters[f];\n if (validator == null) {\n return false;\n }\n if (!validator(input)) {\n return false;\n }\n }\n return true;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected string with format "${this.formats.join(" and ")}"`, input);\n }\n}\nclass NumberWithFormatRuntype {\n formats;\n constructor(formats) {\n this.formats = formats;\n }\n describe(ctx) {\n if (this.formats.length === 0) {\n throw new Error("INTERNAL ERROR: No formats provided");\n }\n const [first, ...rest] = this.formats;\n let acc = `NumberFormat<"${first}">`;\n for (const r of rest) {\n acc = `NumberFormatExtends<${acc}, "${r}">`;\n }\n return acc;\n }\n schema(ctx) {\n return {\n type: "number",\n format: this.formats.join(" and ")\n };\n }\n validate(ctx, input) {\n if (typeof input !== "number") {\n return false;\n }\n for (const f of this.formats) {\n const validator = numberFormatters[f];\n if (validator == null) {\n return false;\n }\n if (!validator(input)) {\n return false;\n }\n }\n return true;\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected number with format "${this.formats.join(" and ")}"`, input);\n }\n}\nclass AnyOfConstsRuntype {\n values;\n constructor(values) {\n this.values = values;\n }\n describe(ctx) {\n const parts = this.values.map((it) => JSON.stringify(it));\n return parts.join(" | ");\n }\n schema(ctx) {\n return {\n enum: this.values\n };\n }\n validate(ctx, input) {\n if (input == null) {\n if (this.values.includes(null)) {\n return true;\n }\n }\n return this.values.includes(input);\n }\n parseAfterValidation(ctx, input) {\n return input;\n }\n reportDecodeError(ctx, input) {\n return buildError(ctx, `expected one of ${limitedCommaJoinJson(this.values)}`, input);\n }\n}\nclass TupleRuntype {\n prefix;\n rest;\n constructor(prefix, rest) {\n this.prefix = prefix;\n this.rest = rest;\n }\n describe(ctx) {\n const prefix = this.prefix.map((it) => it.describe(ctx)).join(", ");\n const rest = this.rest != null ? `...Array<${this.rest.describe(ctx)}>` : null;\n const inner = [prefix, rest].filter((it) => it != null && it.length > 0).join(", ");\n return `[${inner}]`;\n }\n schema(ctx) {\n pushPath(ctx, "[]");\n const prefixItems = this.prefix.map((it) => it.schema(ctx));\n const items = this.rest != null ? this.rest.schema(ctx) : false;\n popPath(ctx);\n return {\n type: "array",\n prefixItems,\n items\n };\n }\n validate(ctx, input) {\n if (Array.isArray(input)) {\n let idx = 0;\n for (const prefixItem of this.prefix) {\n if (!prefixItem.validate(ctx, input[idx])) {\n return false;\n }\n idx++;\n }\n if (this.rest != null) {\n for (let i = idx; i < input.length; i++) {\n if (!this.rest.validate(ctx, input[i])) {\n return false;\n }\n }\n } else {\n if (input.length > idx) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n let idx = 0;\n let acc = [];\n for (const prefixItem of this.prefix) {\n acc.push(prefixItem.parseAfterValidation(ctx, input[idx]));\n idx++;\n }\n if (this.rest != null) {\n for (let i = idx; i < input.length; i++) {\n acc.push(this.rest.parseAfterValidation(ctx, input[i]));\n }\n }\n return acc;\n }\n reportDecodeError(ctx, input) {\n if (!Array.isArray(input)) {\n return buildError(ctx, "expected tuple", input);\n }\n let idx = 0;\n let acc = [];\n for (const prefixItem of this.prefix) {\n const ok = prefixItem.validate(ctx, input[idx]);\n if (!ok) {\n pushPath(ctx, `[${idx}]`);\n const errors = prefixItem.reportDecodeError(ctx, input[idx]);\n acc.push(...errors);\n popPath(ctx);\n }\n idx++;\n }\n if (this.rest != null) {\n for (let i = idx; i < input.length; i++) {\n const ok = this.rest.validate(ctx, input[i]);\n if (!ok) {\n pushPath(ctx, `[${i}]`);\n const errors = this.rest.reportDecodeError(ctx, input[i]);\n acc.push(...errors);\n popPath(ctx);\n }\n }\n }\n return acc;\n }\n}\nclass AllOfRuntype {\n schemas;\n constructor(schemas) {\n this.schemas = schemas;\n }\n describe(ctx) {\n return `(${this.schemas.map((it) => it.describe(ctx)).join(" & ")})`;\n }\n schema(ctx) {\n return {\n allOf: this.schemas.map((it) => it.schema(ctx))\n };\n }\n validate(ctx, input) {\n for (const it of this.schemas) {\n const isObj = typeof input === "object";\n if (!isObj) {\n return false;\n }\n if (!it.validate(ctx, input)) {\n return false;\n }\n }\n return true;\n }\n parseAfterValidation(ctx, input) {\n let acc = {};\n for (const it of this.schemas) {\n const parsed = it.parseAfterValidation(ctx, input);\n if (typeof parsed !== "object") {\n throw new Error("INTERNAL ERROR: AllOfParser: Expected object");\n }\n acc = { ...acc, ...parsed };\n }\n return acc;\n }\n reportDecodeError(ctx, input) {\n const acc = [];\n for (const v of this.schemas) {\n const errors = v.reportDecodeError(ctx, input);\n acc.push(...errors);\n }\n return acc;\n }\n}\nclass AnyOfRuntype {\n schemas;\n constructor(schemas) {\n this.schemas = schemas;\n }\n schema(ctx) {\n return {\n anyOf: this.schemas.map((it) => it.schema(ctx))\n };\n }\n validate(ctx, input) {\n for (const it of this.schemas) {\n if (it.validate(ctx, input)) {\n return true;\n }\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n const items = [];\n for (const it of this.schemas) {\n if (it.validate(ctx, input)) {\n items.push(it.parseAfterValidation(ctx, input));\n }\n }\n return deepmerge(...items);\n }\n reportDecodeError(ctx, input) {\n const acc = [];\n const oldPaths = ctx.path;\n ctx.path = [];\n for (const v of this.schemas) {\n const errors = v.reportDecodeError(ctx, input);\n acc.push(...errors);\n }\n ctx.path = oldPaths;\n return buildUnionError(ctx, acc, input);\n }\n describe(ctx) {\n return `(${this.schemas.map((it) => it.describe(ctx)).join(" | ")})`;\n }\n}\nclass ArrayRuntype {\n itemParser;\n constructor(itemParser) {\n this.itemParser = itemParser;\n }\n schema(ctx) {\n pushPath(ctx, "[]");\n const items = this.itemParser.schema(ctx);\n popPath(ctx);\n return {\n type: "array",\n items\n };\n }\n validate(ctx, input) {\n if (Array.isArray(input)) {\n for (let i = 0; i < input.length; i++) {\n const v = input[i];\n const ok = this.itemParser.validate(ctx, v);\n if (!ok) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n return input.map((v) => this.itemParser.parseAfterValidation(ctx, v));\n }\n reportDecodeError(ctx, input) {\n if (!Array.isArray(input)) {\n return buildError(ctx, "expected array", input);\n }\n let acc = [];\n for (let i = 0; i < input.length; i++) {\n const ok = this.itemParser.validate(ctx, input[i]);\n if (!ok) {\n pushPath(ctx, `[${i}]`);\n const v = input[i];\n const arr2 = this.itemParser.reportDecodeError(ctx, v);\n acc.push(...arr2);\n popPath(ctx);\n }\n }\n return acc;\n }\n describe(ctx) {\n return `Array<${this.itemParser.describe(ctx)}>`;\n }\n}\nclass AnyOfDiscriminatedRuntype {\n schemas;\n discriminator;\n mapping;\n constructor(schemas, discriminator, mapping) {\n this.schemas = schemas;\n this.discriminator = discriminator;\n this.mapping = mapping;\n }\n schema(ctx) {\n return {\n anyOf: this.schemas.map((it) => it.schema(ctx))\n };\n }\n validate(ctx, input) {\n if (typeof input !== "object" || input == null) {\n return false;\n }\n const d = input[this.discriminator];\n if (d == null) {\n return false;\n }\n const v = this.mapping[d];\n if (v == null) {\n return false;\n }\n return v.validate(ctx, input);\n }\n parseAfterValidation(ctx, input) {\n const parser = this.mapping[input[this.discriminator]];\n if (parser == null) {\n throw new Error(\n "INTERNAL ERROR: Missing parser for discriminator " + JSON.stringify(input[this.discriminator])\n );\n }\n return {\n ...parser.parseAfterValidation(ctx, input),\n [this.discriminator]: input[this.discriminator]\n };\n }\n reportDecodeError(ctx, input) {\n if (input == null || typeof input !== "object") {\n return buildError(ctx, "expected object", input);\n }\n const d = input[this.discriminator];\n if (d == null) {\n return buildError(ctx, "expected discriminator key " + JSON.stringify(this.discriminator), input);\n }\n const v = this.mapping[d];\n if (v == null) {\n pushPath(ctx, this.discriminator);\n const errs = buildError(\n ctx,\n "expected one of " + Object.keys(this.mapping).map((it) => JSON.stringify(it)).join(", "),\n d\n );\n popPath(ctx);\n return errs;\n }\n return v.reportDecodeError(ctx, input);\n }\n describe(ctx) {\n return `(${this.schemas.map((it) => it.describe(ctx)).join(" | ")})`;\n }\n}\nclass ObjectRuntype {\n properties;\n indexedPropertiesParser;\n constructor(properties, indexedPropertiesParser) {\n this.properties = properties;\n this.indexedPropertiesParser = indexedPropertiesParser;\n }\n describe(ctx) {\n const sortedKeys = Object.keys(this.properties).sort();\n const props = sortedKeys.map((k) => {\n const it = this.properties[k];\n return `${k}: ${it.describe(ctx)}`;\n }).join(", ");\n const indexPropsParats = this.indexedPropertiesParser.map(({ key, value }) => {\n return `[K in ${key.describe(ctx)}]: ${value.describe(ctx)}`;\n });\n const rest = indexPropsParats.join(", ");\n const content = [props, rest].filter((it) => it != null && it.length > 0).join(", ");\n return `{ ${content} }`;\n }\n schema(ctx) {\n const properties = {};\n for (const k in this.properties) {\n pushPath(ctx, k);\n properties[k] = this.properties[k].schema(ctx);\n popPath(ctx);\n }\n const required = Object.keys(this.properties);\n const base = {\n type: "object",\n properties,\n required\n };\n const indexSchemas = this.indexedPropertiesParser.map(({ key, value }) => {\n pushPath(ctx, "[key]");\n const keySchema = key.schema(ctx);\n popPath(ctx);\n pushPath(ctx, "[value]");\n const valueSchema = value.schema(ctx);\n popPath(ctx);\n return {\n type: "object",\n additionalProperties: valueSchema,\n propertyNames: keySchema\n };\n });\n if (indexSchemas.length === 0) {\n return base;\n }\n return {\n allOf: [base, ...indexSchemas]\n };\n }\n validate(ctx, input) {\n if (typeof input === "object" && !Array.isArray(input) && input !== null) {\n const configKeys = Object.keys(this.properties);\n for (const k of configKeys) {\n const validator = this.properties[k];\n if (!validator.validate(ctx, input[k])) {\n return false;\n }\n }\n if (this.indexedPropertiesParser.length > 0) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n for (const k of extraKeys) {\n let isValid = false;\n for (const p of this.indexedPropertiesParser) {\n if (!p.key.validate(ctx, k)) {\n continue;\n }\n const v = input[k];\n if (!p.value.validate(ctx, v)) {\n continue;\n }\n isValid = true;\n break;\n }\n if (!isValid) {\n return false;\n }\n }\n } else {\n if (ctx.disallowExtraProperties) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n if (extraKeys.length > 0) {\n return false;\n }\n }\n }\n return true;\n }\n return false;\n }\n parseAfterValidation(ctx, input) {\n let acc = {};\n const inputKeys = Object.keys(input);\n for (const k of inputKeys) {\n const v = input[k];\n if (k in this.properties) {\n const itemParsed = this.properties[k].parseAfterValidation(ctx, v);\n acc[k] = itemParsed;\n } else if (this.indexedPropertiesParser.length > 0) {\n for (const p of this.indexedPropertiesParser) {\n const isValid = p.key.validate(ctx, k) && p.value.validate(ctx, v);\n if (isValid) {\n const itemParsed = p.value.parseAfterValidation(ctx, v);\n const keyParsed = p.key.parseAfterValidation(ctx, k);\n acc[keyParsed] = itemParsed;\n }\n }\n }\n }\n return acc;\n }\n reportDecodeError(ctx, input) {\n if (typeof input !== "object" || Array.isArray(input) || input === null) {\n return buildError(ctx, "expected object", input);\n }\n let acc = [];\n const configKeys = Object.keys(this.properties);\n for (const k of configKeys) {\n const ok = this.properties[k].validate(ctx, input[k]);\n if (!ok) {\n pushPath(ctx, k);\n const arr2 = this.properties[k].reportDecodeError(ctx, input[k]);\n acc.push(...arr2);\n popPath(ctx);\n }\n }\n if (this.indexedPropertiesParser.length > 0) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n for (const k of extraKeys) {\n for (const p of this.indexedPropertiesParser) {\n const keyOk = p.key.validate(ctx, k);\n const valueOk = p.value.validate(ctx, input[k]);\n const ok = keyOk && valueOk;\n if (!ok) {\n pushPath(ctx, k);\n if (!keyOk) {\n const keyReported = p.key.reportDecodeError(ctx, k);\n acc.push(...keyReported);\n }\n if (!valueOk) {\n const valueReported = p.value.reportDecodeError(ctx, input[k]);\n acc.push(...valueReported);\n }\n popPath(ctx);\n }\n }\n }\n } else {\n if (ctx.disallowExtraProperties) {\n const inputKeys = Object.keys(input);\n const extraKeys = inputKeys.filter((k) => !configKeys.includes(k));\n if (extraKeys.length > 0) {\n return extraKeys.flatMap((k) => {\n pushPath(ctx, k);\n const err = buildError(ctx, `extra property`, input[k]);\n popPath(ctx);\n return err;\n });\n }\n }\n }\n return acc;\n }\n}\nclass RefRuntype {\n refName;\n constructor(refName) {\n this.refName = refName;\n }\n describe(ctx) {\n const name = this.refName;\n const to = namedRuntypes[this.refName];\n if (ctx.measure) {\n ctx.deps_counter[name] = (ctx.deps_counter[name] || 0) + 1;\n if (ctx.deps[name]) {\n return name;\n }\n ctx.deps[name] = true;\n ctx.deps[name] = to.describe(ctx);\n return name;\n } else {\n if (ctx.deps_counter[name] > 1) {\n if (!ctx.deps[name]) {\n ctx.deps[name] = true;\n ctx.deps[name] = to.describe(ctx);\n }\n return name;\n } else {\n return to.describe(ctx);\n }\n }\n }\n schema(ctx) {\n const name = this.refName;\n const to = namedRuntypes[this.refName];\n if (ctx.seen[name]) {\n return {};\n }\n ctx.seen[name] = true;\n var tmp = to.schema(ctx);\n delete ctx.seen[name];\n return tmp;\n }\n validate(ctx, input) {\n const to = namedRuntypes[this.refName];\n return to.validate(ctx, input);\n }\n parseAfterValidation(ctx, input) {\n const to = namedRuntypes[this.refName];\n return to.parseAfterValidation(ctx, input);\n }\n reportDecodeError(ctx, input) {\n const to = namedRuntypes[this.refName];\n return to.reportDecodeError(ctx, input);\n }\n}\nconst buildParsers = (args) => {\n const stringFormats = args?.stringFormats ?? {};\n for (const k of RequiredStringFormats) {\n if (stringFormats[k] == null) {\n throw new Error(`Missing custom format ${k}`);\n }\n }\n Object.keys(stringFormats).forEach((k) => {\n const v = stringFormats[k];\n registerStringFormatter(k, v);\n });\n const numberFormats = args?.numberFormats ?? {};\n for (const k of RequiredNumberFormats) {\n if (numberFormats[k] == null) {\n throw new Error(`Missing custom format ${k}`);\n }\n }\n Object.keys(numberFormats).forEach((k) => {\n const v = numberFormats[k];\n registerNumberFormatter(k, v);\n });\n let acc = {};\n for (const k of Object.keys(buildParsersInput)) {\n const impl = buildParsersInput[k];\n const validate = (input, options) => {\n const disallowExtraProperties = options?.disallowExtraProperties ?? false;\n const ctx = { disallowExtraProperties };\n const ok = impl.validate(ctx, input);\n if (typeof ok !== "boolean") {\n throw new Error("INTERNAL ERROR: Expected boolean");\n }\n return ok;\n };\n const schema = () => {\n const ctx = {\n path: [],\n seen: {}\n };\n return impl.schema(ctx);\n };\n const describe = () => {\n const ctx = {\n deps: {},\n deps_counter: {},\n measure: true\n };\n let out = impl.describe(ctx);\n ctx["deps"] = {};\n ctx["measure"] = false;\n out = impl.describe(ctx);\n let sortedDepsKeys = Object.keys(ctx.deps).sort();\n const depsPart = sortedDepsKeys.map((key) => {\n return `type ${key} = ${ctx.deps[key]};`;\n }).join("\\n\\n");\n const outPart = `type Codec${k} = ${out};`;\n return [depsPart, outPart].filter((it2) => it2 != null && it2.length > 0).join("\\n\\n");\n };\n const safeParse = (input, options) => {\n const disallowExtraProperties = options?.disallowExtraProperties ?? false;\n const ok = validate(input, options);\n if (ok) {\n let ctx2 = { disallowExtraProperties };\n const parsed = impl.parseAfterValidation(ctx2, input);\n return { success: true, data: parsed };\n }\n let ctx = { path: [], disallowExtraProperties };\n return {\n success: false,\n errors: impl.reportDecodeError(ctx, input).slice(0, 10)\n };\n };\n const parse = (input, options) => {\n const safe = safeParse(input, options);\n if (safe.success) {\n return safe.data;\n }\n const explained = printErrors(safe.errors, []);\n throw new Error(`Failed to parse ${k} - ${explained}`);\n };\n const zod = () => {\n return z.custom(\n (data) => validate(data),\n (val) => {\n const errors = impl.reportDecodeError({ path: [], disallowExtraProperties: false }, val);\n return printErrors(errors, []);\n }\n );\n };\n const it = {\n validate,\n schema,\n describe,\n safeParse,\n parse,\n zod,\n name: k\n };\n acc[k] = it;\n }\n return acc;\n};\n', "parser.d.ts": 'import { BuildParserFunction } from "@beff/client";\n\ndeclare const _exports: {\n buildParsers: BuildParserFunction;\n};\n\nexport default _exports;\n' };
45785
45785
 
45786
45786
  // ts-node/bundle-to-disk.ts
45787
45787
  var esmTag = (mod) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beff/cli",
3
- "version": "0.0.103",
3
+ "version": "0.0.104",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "beff": "./bin/index.js"
package/pkg/beff_wasm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
- const { TextDecoder, TextEncoder } = require(`util`);
4
+ const { TextEncoder, TextDecoder } = require(`util`);
5
5
 
6
6
  const heap = new Array(128).fill(undefined);
7
7
 
@@ -23,9 +23,7 @@ function takeObject(idx) {
23
23
  return ret;
24
24
  }
25
25
 
26
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
27
-
28
- cachedTextDecoder.decode();
26
+ let WASM_VECTOR_LEN = 0;
29
27
 
30
28
  let cachedUint8Memory0 = null;
31
29
 
@@ -36,22 +34,6 @@ function getUint8Memory0() {
36
34
  return cachedUint8Memory0;
37
35
  }
38
36
 
39
- function getStringFromWasm0(ptr, len) {
40
- ptr = ptr >>> 0;
41
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
42
- }
43
-
44
- function addHeapObject(obj) {
45
- if (heap_next === heap.length) heap.push(heap.length + 1);
46
- const idx = heap_next;
47
- heap_next = heap[idx];
48
-
49
- heap[idx] = obj;
50
- return idx;
51
- }
52
-
53
- let WASM_VECTOR_LEN = 0;
54
-
55
37
  let cachedTextEncoder = new TextEncoder('utf-8');
56
38
 
57
39
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -119,6 +101,24 @@ function getInt32Memory0() {
119
101
  return cachedInt32Memory0;
120
102
  }
121
103
 
104
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
105
+
106
+ cachedTextDecoder.decode();
107
+
108
+ function getStringFromWasm0(ptr, len) {
109
+ ptr = ptr >>> 0;
110
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
111
+ }
112
+
113
+ function addHeapObject(obj) {
114
+ if (heap_next === heap.length) heap.push(heap.length + 1);
115
+ const idx = heap_next;
116
+ heap_next = heap[idx];
117
+
118
+ heap[idx] = obj;
119
+ return idx;
120
+ }
121
+
122
122
  let cachedFloat64Memory0 = null;
123
123
 
124
124
  function getFloat64Memory0() {
@@ -255,23 +255,6 @@ module.exports.__wbg_readfilecontent_43e9ae3fbe1ceeb4 = function(arg0, arg1, arg
255
255
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
256
256
  };
257
257
 
258
- module.exports.__wbg_emitdiagnostic_eee08920b60ef69d = function(arg0) {
259
- emit_diagnostic(takeObject(arg0));
260
- };
261
-
262
- module.exports.__wbg_resolveimport_0872cceae2662468 = function(arg0, arg1, arg2, arg3, arg4) {
263
- const ret = resolve_import(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
264
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
265
- var len1 = WASM_VECTOR_LEN;
266
- getInt32Memory0()[arg0 / 4 + 1] = len1;
267
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
268
- };
269
-
270
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
271
- const ret = getStringFromWasm0(arg0, arg1);
272
- return addHeapObject(ret);
273
- };
274
-
275
258
  module.exports.__wbindgen_is_undefined = function(arg0) {
276
259
  const ret = getObject(arg0) === undefined;
277
260
  return ret;
@@ -297,6 +280,23 @@ module.exports.__wbindgen_is_object = function(arg0) {
297
280
  return ret;
298
281
  };
299
282
 
283
+ module.exports.__wbg_emitdiagnostic_eee08920b60ef69d = function(arg0) {
284
+ emit_diagnostic(takeObject(arg0));
285
+ };
286
+
287
+ module.exports.__wbg_resolveimport_0872cceae2662468 = function(arg0, arg1, arg2, arg3, arg4) {
288
+ const ret = resolve_import(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
289
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
290
+ var len1 = WASM_VECTOR_LEN;
291
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
292
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
293
+ };
294
+
295
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
296
+ const ret = getStringFromWasm0(arg0, arg1);
297
+ return addHeapObject(ret);
298
+ };
299
+
300
300
  module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
301
301
  const ret = getObject(arg0) == getObject(arg1);
302
302
  return ret;
Binary file