@compas/code-gen
Version:
Generate various boring parts of your server
2,098 lines (2,094 loc) • 224 kB
JavaScript
// Generated by @compas/code-gen
/* eslint-disable no-unused-vars */
import { isNil } from "@compas/stdlib";
/**
* @typedef {{
* propertyPath: string,
* key: string,
* info: any,
* }} InternalError
*/
/**
* @template T
* @typedef {import("@compas/stdlib").EitherN<T, InternalError>} EitherN
*/
const objectKeys1083503971 = new Set(["group", "name", "uniqueName"]);
const objectKeys360864099 = new Set(["key", "field"]);
const objectKeys2029084423 = new Set(["errorString"]);
const objectKeys980814292 = new Set([
"options",
"structure",
"extension",
"importExtension",
"outputFiles",
"errors",
]);
const objectKeys682118687 = new Set(["relativePath", "contents"]);
const objectKeys1664519436 = new Set(["phase"]);
const objectKeys1287070944 = new Set([
"isJSON",
"useDefaults",
"useTypescript",
"isNode",
"isBrowser",
"suffix",
"isCommonFile",
"isTypeFile",
"fileTypeIO",
]);
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<"anyOf">}
*/
export function anonymousValidator1403126410(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 1) {
const min = 1;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
if (value !== "anyOf") {
const oneOf = ["anyOf"];
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.oneOf",
info: { oneOf, value },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<string>}
*/
export function anonymousValidator650450947(value, propertyPath) {
if (isNil(value)) {
return { value: "" };
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length === 0) {
return { value: "" };
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<boolean>}
*/
export function anonymousValidator897743470(value, propertyPath) {
if (isNil(value)) {
return { value: false };
}
if (typeof value !== "boolean") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.boolean.type",
info: {},
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<string>}
*/
export function anonymousValidator1051394131(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 0) {
const min = 0;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<boolean>}
*/
export function anonymousValidator2029691740(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.boolean.undefined",
info: {},
},
],
};
}
if (typeof value !== "boolean") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.boolean.type",
info: {},
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<number>}
*/
export function anonymousValidator1415318131(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.undefined",
info: {},
},
],
};
}
if (typeof value !== "number" || isNaN(value) || !isFinite(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.type",
info: {},
},
],
};
}
if (!Number.isInteger(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.integer",
info: {},
},
],
};
}
if (value < -2147483647) {
const min = -2147483647;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.min",
info: { min },
},
],
};
}
if (value > 2147483647) {
const max = 2147483647;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.max",
info: { max },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|string|boolean|number>}
*/
export function anonymousValidator1783921317(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
/** @type {InternalError[]} */
let errors = [];
/** @type {EitherN<undefined|string|boolean|number>} */
let result = { errors: [] };
result = anonymousValidator1051394131(value, propertyPath);
if (result.errors) {
errors.push(result.errors[0]);
} else {
return result;
}
result = anonymousValidator2029691740(value, propertyPath);
if (result.errors) {
errors.push(result.errors[0]);
} else {
return result;
}
result = anonymousValidator1415318131(value, propertyPath);
if (result.errors) {
errors.push(result.errors[0]);
} else {
return result;
}
for (const err of errors) {
err.info.via = "validator.anyOf";
}
return {
errors,
};
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|string>}
*/
export function anonymousValidator714133621(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length === 0) {
return {
value: undefined,
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|{"primary": boolean, "searchable": boolean, "hasDefaultValue": boolean, }>}
*/
export function anonymousValidator1598336448(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator897743470(
value["primary"],
`${propertyPath}.primary`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["primary"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["searchable"],
`${propertyPath}.searchable`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["searchable"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["hasDefaultValue"],
`${propertyPath}.hasDefaultValue`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["hasDefaultValue"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{}>}
*/
export function anonymousValidator579880416(value, propertyPath) {
if (isNil(value)) {
return { value: {} };
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<"any">}
*/
export function anonymousValidator1619378803(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 1) {
const min = 1;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
if (value !== "any") {
const oneOf = ["any"];
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.oneOf",
info: { oneOf, value },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"allowNull": boolean, }>}
*/
export function anonymousValidator122717361(value, propertyPath) {
if (isNil(value)) {
return { value: { allowNull: false } };
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator897743470(
value["allowNull"],
`${propertyPath}.allowNull`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["allowNull"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"javaScript"?: undefined|string, "typeScript"?: undefined|string, }>}
*/
export function anonymousValidator937994972(value, propertyPath) {
if (isNil(value)) {
return { value: {} };
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator714133621(
value["javaScript"],
`${propertyPath}.javaScript`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["javaScript"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["typeScript"],
`${propertyPath}.typeScript`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["typeScript"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"type": "any", "docString": string, "isOptional": boolean, "defaultValue"?: undefined|string|boolean|number, "uniqueName"?: undefined|string, "group"?: undefined|string, "name"?: undefined|string, "sql"?: undefined|{"primary": boolean, "searchable": boolean, "hasDefaultValue": boolean, }, "validator": {"allowNull": boolean, }, "internalSettings": {}, "rawValue"?: undefined|string, "rawValueImport": {"javaScript"?: undefined|string, "typeScript"?: undefined|string, }, "rawValidator"?: undefined|string, "rawValidatorImport": {"javaScript"?: undefined|string, "typeScript"?: undefined|string, }, }>}
*/
export function anonymousValidator1519740867(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.undefined",
info: {},
},
],
};
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator1619378803(
value["type"],
`${propertyPath}.type`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["type"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator650450947(
value["docString"],
`${propertyPath}.docString`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["docString"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["isOptional"],
`${propertyPath}.isOptional`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["isOptional"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1783921317(
value["defaultValue"],
`${propertyPath}.defaultValue`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["defaultValue"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["uniqueName"],
`${propertyPath}.uniqueName`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["uniqueName"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["group"],
`${propertyPath}.group`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["group"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["name"],
`${propertyPath}.name`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["name"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1598336448(
value["sql"],
`${propertyPath}.sql`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["sql"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator122717361(
value["validator"],
`${propertyPath}.validator`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["validator"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator579880416(
value["internalSettings"],
`${propertyPath}.internalSettings`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["internalSettings"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["rawValue"],
`${propertyPath}.rawValue`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["rawValue"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator937994972(
value["rawValueImport"],
`${propertyPath}.rawValueImport`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["rawValueImport"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["rawValidator"],
`${propertyPath}.rawValidator`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["rawValidator"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator937994972(
value["rawValidatorImport"],
`${propertyPath}.rawValidatorImport`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["rawValidatorImport"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<"array">}
*/
export function anonymousValidator1963673664(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 1) {
const min = 1;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
if (value !== "array") {
const oneOf = ["array"];
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.oneOf",
info: { oneOf, value },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|number>}
*/
export function anonymousValidator233585750(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
if (typeof value !== "number" || isNaN(value) || !isFinite(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.type",
info: {},
},
],
};
}
if (!Number.isInteger(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.integer",
info: {},
},
],
};
}
if (value < -2147483647) {
const min = -2147483647;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.min",
info: { min },
},
],
};
}
if (value > 2147483647) {
const max = 2147483647;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.number.max",
info: { max },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"convert": boolean, "min"?: undefined|number, "max"?: undefined|number, }>}
*/
export function anonymousValidator369441652(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.undefined",
info: {},
},
],
};
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator897743470(
value["convert"],
`${propertyPath}.convert`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["convert"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator233585750(
value["min"],
`${propertyPath}.min`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["min"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator233585750(
value["max"],
`${propertyPath}.max`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["max"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<import("./types").CodeGenType>}
*/
export function anonymousValidator169184843(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.reference.undefined",
info: {},
},
],
};
}
return anonymousValidator682551261(value, propertyPath);
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"type": "array", "docString": string, "isOptional": boolean, "defaultValue"?: undefined|string|boolean|number, "uniqueName"?: undefined|string, "group"?: undefined|string, "name"?: undefined|string, "sql"?: undefined|{"primary": boolean, "searchable": boolean, "hasDefaultValue": boolean, }, "validator": {"convert": boolean, "min"?: undefined|number, "max"?: undefined|number, }, "internalSettings": {}, "values": import("./types").CodeGenType, }>}
*/
export function anonymousValidator1312175728(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.undefined",
info: {},
},
],
};
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator1963673664(
value["type"],
`${propertyPath}.type`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["type"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator650450947(
value["docString"],
`${propertyPath}.docString`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["docString"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["isOptional"],
`${propertyPath}.isOptional`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["isOptional"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1783921317(
value["defaultValue"],
`${propertyPath}.defaultValue`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["defaultValue"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["uniqueName"],
`${propertyPath}.uniqueName`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["uniqueName"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["group"],
`${propertyPath}.group`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["group"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["name"],
`${propertyPath}.name`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["name"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1598336448(
value["sql"],
`${propertyPath}.sql`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["sql"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator369441652(
value["validator"],
`${propertyPath}.validator`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["validator"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator579880416(
value["internalSettings"],
`${propertyPath}.internalSettings`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["internalSettings"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator169184843(
value["values"],
`${propertyPath}.values`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["values"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<"boolean">}
*/
export function anonymousValidator2039173551(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 1) {
const min = 1;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
if (value !== "boolean") {
const oneOf = ["boolean"];
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.oneOf",
info: { oneOf, value },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"convert": boolean, "allowNull": boolean, }>}
*/
export function anonymousValidator1589927592(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.undefined",
info: {},
},
],
};
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator897743470(
value["convert"],
`${propertyPath}.convert`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["convert"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["allowNull"],
`${propertyPath}.allowNull`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["allowNull"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|boolean>}
*/
export function anonymousValidator510366599(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
if (typeof value !== "boolean") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.boolean.type",
info: {},
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"type": "boolean", "docString": string, "isOptional": boolean, "defaultValue"?: undefined|string|boolean|number, "uniqueName"?: undefined|string, "group"?: undefined|string, "name"?: undefined|string, "sql"?: undefined|{"primary": boolean, "searchable": boolean, "hasDefaultValue": boolean, }, "validator": {"convert": boolean, "allowNull": boolean, }, "internalSettings": {}, "oneOf"?: undefined|boolean, }>}
*/
export function anonymousValidator17476225(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.undefined",
info: {},
},
],
};
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator2039173551(
value["type"],
`${propertyPath}.type`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["type"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator650450947(
value["docString"],
`${propertyPath}.docString`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["docString"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["isOptional"],
`${propertyPath}.isOptional`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["isOptional"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1783921317(
value["defaultValue"],
`${propertyPath}.defaultValue`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["defaultValue"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["uniqueName"],
`${propertyPath}.uniqueName`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["uniqueName"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["group"],
`${propertyPath}.group`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["group"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["name"],
`${propertyPath}.name`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["name"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1598336448(
value["sql"],
`${propertyPath}.sql`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["sql"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1589927592(
value["validator"],
`${propertyPath}.validator`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["validator"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator579880416(
value["internalSettings"],
`${propertyPath}.internalSettings`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["internalSettings"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator510366599(
value["oneOf"],
`${propertyPath}.oneOf`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["oneOf"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<"date">}
*/
export function anonymousValidator668449731(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 1) {
const min = 1;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
if (value !== "date") {
const oneOf = ["date"];
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.oneOf",
info: { oneOf, value },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|Date>}
*/
export function anonymousValidator685440859(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
if (
typeof value !== "string" &&
typeof value !== "number" &&
!(value instanceof Date)
) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.date.invalid",
info: {},
},
],
};
}
const date = new Date(value);
if (isNaN(date.getTime())) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.date.invalid",
info: {},
},
],
};
}
return { value: date };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"allowNull": boolean, "min"?: undefined|Date, "max"?: undefined|Date, "inFuture"?: undefined|boolean, "inPast"?: undefined|boolean, }>}
*/
export function anonymousValidator1911770642(value, propertyPath) {
if (isNil(value)) {
return { value: { allowNull: false } };
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator897743470(
value["allowNull"],
`${propertyPath}.allowNull`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["allowNull"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator685440859(
value["min"],
`${propertyPath}.min`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["min"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator685440859(
value["max"],
`${propertyPath}.max`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["max"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator510366599(
value["inFuture"],
`${propertyPath}.inFuture`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["inFuture"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator510366599(
value["inPast"],
`${propertyPath}.inPast`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["inPast"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|"dateOnly"|"timeOnly">}
*/
export function anonymousValidator1020934975(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length === 0) {
return {
value: undefined,
};
}
if (value !== "dateOnly" && value !== "timeOnly") {
const oneOf = ["dateOnly", "timeOnly"];
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.oneOf",
info: { oneOf, value },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"type": "date", "docString": string, "isOptional": boolean, "defaultValue"?: undefined|string|boolean|number, "uniqueName"?: undefined|string, "group"?: undefined|string, "name"?: undefined|string, "sql"?: undefined|{"primary": boolean, "searchable": boolean, "hasDefaultValue": boolean, }, "validator": {"allowNull": boolean, "min"?: undefined|Date, "max"?: undefined|Date, "inFuture"?: undefined|boolean, "inPast"?: undefined|boolean, }, "internalSettings": {}, "specifier"?: undefined|"dateOnly"|"timeOnly", }>}
*/
export function anonymousValidator2019605291(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.undefined",
info: {},
},
],
};
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator668449731(
value["type"],
`${propertyPath}.type`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["type"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator650450947(
value["docString"],
`${propertyPath}.docString`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["docString"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["isOptional"],
`${propertyPath}.isOptional`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["isOptional"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1783921317(
value["defaultValue"],
`${propertyPath}.defaultValue`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["defaultValue"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["uniqueName"],
`${propertyPath}.uniqueName`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["uniqueName"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["group"],
`${propertyPath}.group`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["group"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["name"],
`${propertyPath}.name`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["name"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1598336448(
value["sql"],
`${propertyPath}.sql`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["sql"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1911770642(
value["validator"],
`${propertyPath}.validator`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["validator"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator579880416(
value["internalSettings"],
`${propertyPath}.internalSettings`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["internalSettings"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1020934975(
value["specifier"],
`${propertyPath}.specifier`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["specifier"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<"file">}
*/
export function anonymousValidator1328202671(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 1) {
const min = 1;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
if (value !== "file") {
const oneOf = ["file"];
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.oneOf",
info: { oneOf, value },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<string>}
*/
export function anonymousValidator1895866002(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.undefined",
info: {},
},
],
};
}
if (typeof value !== "string") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.type",
info: {},
},
],
};
}
if (value.length < 1) {
const min = 1;
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.string.min",
info: { min },
},
],
};
}
return { value };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<undefined|(string)[]>}
*/
export function anonymousValidator1749769805(value, propertyPath) {
if (isNil(value)) {
return { value: undefined };
}
if (!Array.isArray(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.array.type",
info: {},
},
],
};
}
const result = Array.from({ length: value.length });
let errors = [];
for (let i = 0; i < value.length; ++i) {
const arrVar = anonymousValidator1895866002(
value[i],
propertyPath + "[" + i + "]",
);
if (arrVar.errors) {
errors.push(...arrVar.errors);
} else {
result[i] = arrVar.value;
}
}
if (errors.length > 0) {
/** @type {{ errors: InternalError[] }} */
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"mimeTypes"?: undefined|(string)[], }>}
*/
export function anonymousValidator916804786(value, propertyPath) {
if (isNil(value)) {
return { value: {} };
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator1749769805(
value["mimeTypes"],
`${propertyPath}.mimeTypes`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["mimeTypes"] = validatorResult.value;
}
}
if (errors.length > 0) {
return { errors };
}
return { value: result };
}
/**
* @param {*} value
* @param {string} propertyPath
* @returns {EitherN<{"type": "file", "docString": string, "isOptional": boolean, "defaultValue"?: undefined|string|boolean|number, "uniqueName"?: undefined|string, "group"?: undefined|string, "name"?: undefined|string, "sql"?: undefined|{"primary": boolean, "searchable": boolean, "hasDefaultValue": boolean, }, "validator": {"mimeTypes"?: undefined|(string)[], }, "internalSettings": {}, }>}
*/
export function anonymousValidator508679687(value, propertyPath) {
if (isNil(value)) {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.undefined",
info: {},
},
],
};
}
if (typeof value !== "object") {
/** @type {{ errors: InternalError[] }} */
return {
errors: [
{
propertyPath,
key: "validator.object.type",
info: {},
},
],
};
}
const result = Object.create(null);
let errors = [];
{
const validatorResult = anonymousValidator1328202671(
value["type"],
`${propertyPath}.type`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["type"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator650450947(
value["docString"],
`${propertyPath}.docString`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["docString"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator897743470(
value["isOptional"],
`${propertyPath}.isOptional`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["isOptional"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator1783921317(
value["defaultValue"],
`${propertyPath}.defaultValue`,
);
if (validatorResult.errors) {
errors.push(...validatorResult.errors);
} else {
result["defaultValue"] = validatorResult.value;
}
}
{
const validatorResult = anonymousValidator714133621(
value["uniqueName"],
`${propertyPath}.uniqueName`,
);
if (validato