Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typia

Package Overview
Dependencies
Maintainers
1
Versions
588
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typia - npm Package Compare versions

Comparing version 3.3.12 to 3.4.0-dev.20221212

lib/executable/internal/TypiaSetupWizard.d.ts

2

lib/factories/CommentFactory.js

@@ -8,3 +8,3 @@ "use strict";

return comments
.map(function (part) { return "".concat(part.kind === "linkText" ? " " : "").concat(part.text); })
.map(function (part) { return part.text; })
.map(function (str) { return str.split("\r\n").join("\n"); })

@@ -11,0 +11,0 @@ .join("");

@@ -6,2 +6,3 @@ import ts from "typescript";

function isObject(input: ts.Expression, nullChecked: boolean): ts.Expression;
function isInstanceOf(input: ts.Expression, type: string): ts.Expression;
}

@@ -29,3 +29,7 @@ "use strict";

ExpressionFactory.isObject = isObject;
function isInstanceOf(input, type) {
return typescript_1.default.factory.createBinaryExpression(input, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.InstanceOfKeyword), typescript_1.default.factory.createIdentifier(type));
}
ExpressionFactory.isInstanceOf = isInstanceOf;
})(ExpressionFactory = exports.ExpressionFactory || (exports.ExpressionFactory = {}));
//# sourceMappingURL=ExpressionFactory.js.map

@@ -6,3 +6,3 @@ import ts from "typescript";

function postfix(str: string): string;
function parameter(name: string | ts.BindingName): ts.ParameterDeclaration;
function parameter(name: string | ts.BindingName, init?: ts.Expression): ts.ParameterDeclaration;
}

@@ -30,4 +30,6 @@ "use strict";

IdentifierFactory.postfix = postfix;
function parameter(name) {
return typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, name);
function parameter(name, init) {
if (typescript_1.default.version >= "4.8")
return typescript_1.default.factory.createParameterDeclaration(undefined, undefined, name, undefined, undefined, init);
return typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, undefined, init);
}

@@ -34,0 +36,0 @@ IdentifierFactory.parameter = parameter;

@@ -24,3 +24,3 @@ "use strict";

var e_1, _a;
var meta = Metadata_1.Metadata.initialize();
var meta = Metadata_1.Metadata.initialize(parentResolved);
if (type !== null)

@@ -27,0 +27,0 @@ (0, iterate_metadata_1.iterate_metadata)(checker)(options)(collection)(meta, type, parentResolved);

@@ -13,5 +13,4 @@ "use strict";

return false;
var elemType = type.getNumberIndexType() || null;
var elemMeta = (0, explore_metadata_1.explore_metadata)(checker)(options)(collection)(elemType, false);
ArrayUtil_1.ArrayUtil.set(meta.arrays, elemMeta, function (elem) { return elem.getName(); });
var value = type.getNumberIndexType() || null;
ArrayUtil_1.ArrayUtil.set(meta.arrays, (0, explore_metadata_1.explore_metadata)(checker)(options)(collection)(value, false), function (elem) { return elem.getName(); });
return true;

@@ -18,0 +17,0 @@ };

"use strict";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -36,11 +9,12 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var ArrayUtil_1 = require("../../utils/ArrayUtil");
var same = function (type) {
if (type === null)
return function () { return false; };
return function (flag) { return (type.getFlags() & flag) !== 0; };
};
var iterate_metadata_atomic = function (meta, type) {
var e_1, _a;
var filter = function (flag) { return (type.getFlags() & flag) !== 0; };
var check = function (flag, literal, className) {
var _a;
if (filter(flag) ||
filter(literal) ||
((_a = type.symbol) === null || _a === void 0 ? void 0 : _a.escapedName) === className) {
ArrayUtil_1.ArrayUtil.add(meta.atomics, className.toLowerCase());
var filter = same(type);
var check = function (info) {
if (filter(info.atomic) || filter(info.literal)) {
ArrayUtil_1.ArrayUtil.add(meta.atomics, info.name);
return true;

@@ -50,26 +24,27 @@ }

};
try {
for (var ATOMICS_1 = __values(ATOMICS), ATOMICS_1_1 = ATOMICS_1.next(); !ATOMICS_1_1.done; ATOMICS_1_1 = ATOMICS_1.next()) {
var _b = __read(ATOMICS_1_1.value, 3), flag = _b[0], literal = _b[1], className = _b[2];
if (check(flag, literal, className) === true) {
return true;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (ATOMICS_1_1 && !ATOMICS_1_1.done && (_a = ATOMICS_1.return)) _a.call(ATOMICS_1);
}
finally { if (e_1) throw e_1.error; }
}
return false;
return ATOMICS.some(function (info) { return check(info); });
};
exports.iterate_metadata_atomic = iterate_metadata_atomic;
var ATOMICS = [
[typescript_1.default.TypeFlags.BooleanLike, typescript_1.default.TypeFlags.BooleanLiteral, "Boolean"],
[typescript_1.default.TypeFlags.NumberLike, typescript_1.default.TypeFlags.NumberLiteral, "Number"],
[typescript_1.default.TypeFlags.BigIntLike, typescript_1.default.TypeFlags.BigIntLiteral, "BigInt"],
[typescript_1.default.TypeFlags.StringLike, typescript_1.default.TypeFlags.StringLiteral, "String"],
{
name: "boolean",
atomic: typescript_1.default.TypeFlags.BooleanLike,
literal: typescript_1.default.TypeFlags.BooleanLiteral,
},
{
name: "number",
atomic: typescript_1.default.TypeFlags.NumberLike,
literal: typescript_1.default.TypeFlags.NumberLiteral,
},
{
name: "bigint",
atomic: typescript_1.default.TypeFlags.BigInt,
literal: typescript_1.default.TypeFlags.BigIntLiteral,
},
{
name: "string",
atomic: typescript_1.default.TypeFlags.StringLike,
literal: typescript_1.default.TypeFlags.StringLiteral,
},
];
//# sourceMappingURL=iterate_metadata_atomic.js.map

@@ -12,5 +12,3 @@ "use strict";

var filter = function (flag) { return (type.getFlags() & flag) !== 0; };
if (filter(typescript_1.default.TypeFlags.Unknown) ||
filter(typescript_1.default.TypeFlags.Never) ||
filter(typescript_1.default.TypeFlags.Any)) {
if (filter(typescript_1.default.TypeFlags.Unknown) || filter(typescript_1.default.TypeFlags.Any)) {
(0, Writable_1.Writable)(meta).any = true;

@@ -24,2 +22,3 @@ return true;

else if (filter(typescript_1.default.TypeFlags.Undefined) ||
filter(typescript_1.default.TypeFlags.Never) ||
filter(typescript_1.default.TypeFlags.Void) ||

@@ -26,0 +25,0 @@ filter(typescript_1.default.TypeFlags.VoidLike)) {

@@ -5,2 +5,2 @@ import ts from "typescript";

import { MetadataFactory } from "../MetadataFactory";
export declare const iterate_metadata_tuple: (checker: ts.TypeChecker) => (options: MetadataFactory.IOptions) => (collection: MetadataCollection) => (meta: Metadata, type: ts.Type) => boolean;
export declare const iterate_metadata_tuple: (checker: ts.TypeChecker) => (options: MetadataFactory.IOptions) => (collection: MetadataCollection) => (meta: Metadata, type: ts.Type, node: ts.TypeNode) => boolean;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.iterate_metadata_tuple = void 0;
var typescript_1 = __importDefault(require("typescript"));
var Metadata_1 = require("../../metadata/Metadata");
var Writable_1 = require("../../typings/Writable");
var ArrayUtil_1 = require("../../utils/ArrayUtil");

@@ -9,9 +15,25 @@ var explore_metadata_1 = require("./explore_metadata");

return function (collection) {
return function (meta, type) {
return function (meta, type, node) {
var _a, _b;
if (!checker.isTupleType(type))
return false;
while (typescript_1.default.isTypeReferenceNode(node)) {
var declarations = (_b = (_a = node.typeName) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.declarations;
if (!(declarations === null || declarations === void 0 ? void 0 : declarations.length))
break;
var alias = declarations[0];
if (!alias || !typescript_1.default.isTypeAliasDeclaration(alias))
break;
node = alias.type;
}
var elements = typescript_1.default.isTupleTypeNode(node) ? node.elements : undefined;
var children = checker
.getTypeArguments(type)
.map(function (elem) {
return (0, explore_metadata_1.explore_metadata)(checker)(options)(collection)(elem, false);
.map(function (elem, i) {
var child = (0, explore_metadata_1.explore_metadata)(checker)(options)(collection)(elem, false);
if (elements === undefined || !typescript_1.default.isRestTypeNode(elements[i]))
return child;
var wrapper = Metadata_1.Metadata.initialize();
(0, Writable_1.Writable)(wrapper).rest = child;
return wrapper;
});

@@ -18,0 +40,0 @@ ArrayUtil_1.ArrayUtil.set(meta.tuples, children, join_tuple_names);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.iterate_metadata = void 0;
var ArrayUtil_1 = require("../../utils/ArrayUtil");
var iterate_metadata_array_1 = require("./iterate_metadata_array");

@@ -8,4 +9,7 @@ var iterate_metadata_atomic_1 = require("./iterate_metadata_atomic");

var iterate_metadata_constant_1 = require("./iterate_metadata_constant");
var iterate_metadata_map_1 = require("./iterate_metadata_map");
var iterate_metadata_native_1 = require("./iterate_metadata_native");
var iterate_metadata_object_1 = require("./iterate_metadata_object");
var iterate_metadata_resolve_1 = require("./iterate_metadata_resolve");
var iterate_metadata_set_1 = require("./iterate_metadata_set");
var iterate_metadata_template_1 = require("./iterate_metadata_template");

@@ -19,3 +23,3 @@ var iterate_metadata_tuple_1 = require("./iterate_metadata_tuple");

if (type.isTypeParameter() === true)
throw new Error("Error on TSON.MetadataFactory.generate(): non-specified generic argument on ".concat(meta.getName(), "."));
throw new Error("Error on typia.MetadataFactory.generate(): non-specified generic argument on ".concat(meta.getName(), "."));
if ((0, iterate_metadata_union_1.iterate_metadata_union)(checker)(options)(collection)(meta, type, parentResolved) ||

@@ -25,4 +29,6 @@ (0, iterate_metadata_resolve_1.iterate_metadata_resolve)(checker)(options)(collection)(meta, type, parentResolved))

var node = checker.typeToTypeNode(type, undefined, undefined);
if (node === undefined)
if (node === undefined) {
ArrayUtil_1.ArrayUtil.set(meta.tuples, [], function () { return "[]"; });
return;
}
(0, iterate_metadata_coalesce_1.iterate_metadata_coalesce)(meta, type) ||

@@ -32,4 +38,7 @@ (0, iterate_metadata_constant_1.iterate_metadata_constant)(checker)(options)(meta, type) ||

(0, iterate_metadata_atomic_1.iterate_metadata_atomic)(meta, type) ||
(0, iterate_metadata_tuple_1.iterate_metadata_tuple)(checker)(options)(collection)(meta, type) ||
(0, iterate_metadata_tuple_1.iterate_metadata_tuple)(checker)(options)(collection)(meta, type, node) ||
(0, iterate_metadata_array_1.iterate_metadata_array)(checker)(options)(collection)(meta, type) ||
(0, iterate_metadata_native_1.iterate_metadata_native)(checker)(meta, type) ||
(0, iterate_metadata_map_1.iterate_metadata_map)(checker)(options)(collection)(meta, type) ||
(0, iterate_metadata_set_1.iterate_metadata_set)(checker)(options)(collection)(meta, type) ||
(0, iterate_metadata_object_1.iterate_metadata_object)(checker)(options)(collection)(meta, type, parentResolved);

@@ -36,0 +45,0 @@ };

@@ -17,5 +17,6 @@ import ts from "typescript";

interface IOptions {
replace(str: string): string;
replace?(str: string): string;
}
function replace(str: string): string;
function escape(str: string): string;
}

@@ -82,3 +82,3 @@ "use strict";

MapUtil_1.MapUtil.take(this.unions_, key, function () { return meta.objects; });
return this.unions_.size - 1;
return __spreadArray([], __read(this.unions_.keys()), false).indexOf(key);
};

@@ -124,2 +124,21 @@ MetadataCollection.prototype.get_name = function (checker, type) {

MetadataCollection.replace = replace;
function escape(str) {
var e_2, _a;
try {
for (var REPLACERS_2 = __values(REPLACERS), REPLACERS_2_1 = REPLACERS_2.next(); !REPLACERS_2_1.done; REPLACERS_2_1 = REPLACERS_2.next()) {
var _b = __read(REPLACERS_2_1.value, 2), before = _b[0], after = _b[1];
if (after !== "")
str = str.split(after).join(before);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (REPLACERS_2_1 && !REPLACERS_2_1.done && (_a = REPLACERS_2.return)) _a.call(REPLACERS_2);
}
finally { if (e_2) throw e_2.error; }
}
return str;
}
MetadataCollection.escape = escape;
})(MetadataCollection = exports.MetadataCollection || (exports.MetadataCollection = {}));

@@ -138,7 +157,7 @@ exports.MetadataCollection = MetadataCollection;

[",", "_comma_"],
["`", ""],
["'", ""],
['"', ""],
[" ", ""],
["`", "_backquote_"],
["'", "_singlequote_"],
['"', "_doublequote_"],
[" ", "_space_"],
];
//# sourceMappingURL=MetadataCollection.js.map

@@ -273,3 +273,3 @@ "use strict";

}
var LABEL = "Error on TSON.MetadataTagFactory.generate()";
var LABEL = "Error on typia.MetadataTagFactory.generate()";
var LEFT_PARENTHESIS = ["[", "("];

@@ -276,0 +276,0 @@ var RIGHT_PARENTHESIS = ["]", ")"];

import ts from "typescript";
export declare namespace StatementFactory {
function variable(flag: ts.NodeFlags, name: string, initializer?: ts.Expression): ts.VariableStatement;
function constant(name: string, initializer?: ts.Expression): ts.VariableStatement;
function transpile(script: string): ts.ExpressionStatement;
function require(variable: string, location: string): ts.ImportDeclaration;
function importModulo(variable: string, location: string): ts.ImportDeclaration;
}

@@ -10,8 +10,8 @@ "use strict";

(function (StatementFactory) {
function variable(flag, name, initializer) {
function constant(name, initializer) {
return typescript_1.default.factory.createVariableStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([
typescript_1.default.factory.createVariableDeclaration(name, undefined, undefined, initializer),
], flag));
], typescript_1.default.NodeFlags.Const));
}
StatementFactory.variable = variable;
StatementFactory.constant = constant;
function transpile(script) {

@@ -21,13 +21,3 @@ return typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createIdentifier(typescript_1.default.transpile(script)));

StatementFactory.transpile = transpile;
function require(variable, location) {
return typescript_1.default.factory.createImportDeclaration(undefined, undefined, typescript_1.default.factory.createImportClause(false, undefined, typescript_1.default.factory.createNamespaceImport(typescript_1.default.factory.createIdentifier(variable))), typescript_1.default.factory.createStringLiteral(location));
}
StatementFactory.require = require;
function importModulo(variable, location) {
return typescript_1.default.factory.createImportDeclaration(undefined, undefined, typescript_1.default.factory.createImportClause(false, undefined, typescript_1.default.factory.createNamedImports([
typescript_1.default.factory.createImportSpecifier(false, undefined, typescript_1.default.factory.createIdentifier(variable)),
])), typescript_1.default.factory.createStringLiteral(location));
}
StatementFactory.importModulo = importModulo;
})(StatementFactory = exports.StatementFactory || (exports.StatementFactory = {}));
//# sourceMappingURL=StatementFactory.js.map

@@ -11,2 +11,6 @@ "use strict";

function generate(expressions) {
if (expressions.every(function (exp) { return typescript_1.default.isStringLiteral(exp); }))
return typescript_1.default.factory.createStringLiteral(expressions
.map(function (str) { return str.text; })
.join(""));
var it = {

@@ -13,0 +17,0 @@ value: "",

@@ -5,3 +5,4 @@ import ts from "typescript";

function isFunction(type: ts.Type): boolean;
function getFullName(checker: ts.TypeChecker, type: ts.Type): string;
function getReturnType(checker: ts.TypeChecker, type: ts.Type, name: string): ts.Type | null;
function getFullName(checker: ts.TypeChecker, type: ts.Type, symbol?: ts.Symbol): string;
}

@@ -11,3 +11,3 @@ "use strict";

function resolve(checker, type) {
return get_return_type(checker, type, "toJSON");
return getReturnType(checker, type, "toJSON");
}

@@ -32,3 +32,3 @@ TypeFactory.resolve = resolve;

}
function get_return_type(checker, type, name) {
function getReturnType(checker, type, name) {
var symbol = type.getProperty(name);

@@ -43,6 +43,7 @@ if (!symbol)

}
function getFullName(checker, type) {
var symbol = type.getSymbol() || type.aliasSymbol;
TypeFactory.getReturnType = getReturnType;
function getFullName(checker, type, symbol) {
symbol || (symbol = type.aliasSymbol || type.getSymbol());
if (symbol === undefined)
return checker.typeToString(type, undefined, undefined);
return checker.typeToString(type);
if (type.aliasSymbol === undefined && type.isUnionOrIntersection()) {

@@ -55,3 +56,5 @@ var joiner = type.isIntersection() ? " & " : " | ";

var name = get_name(symbol);
var generic = checker.getTypeArguments(type);
var generic = type.aliasSymbol
? type.aliasTypeArguments || []
: checker.getTypeArguments(type);
return generic.length

@@ -72,5 +75,9 @@ ? name === "Promise"

function get_name(symbol) {
return explore_name(symbol.escapedName.toString(), symbol.getDeclarations()[0].parent);
var _a, _b;
var parent = (_b = (_a = symbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.parent;
return parent
? explore_name(symbol.escapedName.toString(), parent)
: "__type";
}
})(TypeFactory = exports.TypeFactory || (exports.TypeFactory = {}));
//# sourceMappingURL=TypeFactory.js.map

@@ -8,13 +8,13 @@ "use strict";

throw new TypeGuardError_1.TypeGuardError({
method: "TSON.stringify",
method: "typia.stringify",
expected: "number",
value: value,
message: "Error on TSON.stringify(): infinite number.",
message: "Error on typia.stringify(): infinite number.",
});
else if (isNaN(value))
throw new TypeGuardError_1.TypeGuardError({
method: "TSON.stringify",
method: "typia.stringify",
expected: "number",
value: value,
message: "Error on TSON.stringify(): not a valid number.",
message: "Error on typia.stringify(): not a valid number.",
});

@@ -21,0 +21,0 @@ return value;

@@ -1,3 +0,3 @@

import * as TSON from "./module";
export default TSON;
import * as typia from "./module";
export default typia;
export * from "./module";

@@ -29,5 +29,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var TSON = __importStar(require("./module"));
exports.default = TSON;
var typia = __importStar(require("./module"));
exports.default = typia;
__exportStar(require("./module"), exports);
//# sourceMappingURL=index.js.map

@@ -1,6 +0,12 @@

export interface IValidation {
success: boolean;
errors: IValidation.IError[];
}
export type IValidation<T = unknown> = IValidation.ISuccess<T> | IValidation.IFailure;
export declare namespace IValidation {
interface ISuccess<T = unknown> {
success: true;
data: T;
errors: [];
}
interface IFailure {
success: false;
errors: IError[];
}
interface IError {

@@ -7,0 +13,0 @@ path: string;

import { Atomic } from "../typings/Atomic";
import { IMetadataConstant } from "./IMetadataConstant";
import { IMetadataEntry } from "./IMetadataEntry";
export interface IMetadata {

@@ -12,5 +13,9 @@ any: boolean;

resolved: IMetadata | null;
rest: IMetadata | null;
arrays: IMetadata[];
tuples: IMetadata[][];
objects: string[];
natives: string[];
sets: IMetadata[];
maps: IMetadataEntry[];
}
import { Atomic } from "../typings/Atomic";
export declare type IMetadataConstant = IMetadataConstant.IBase<"boolean", boolean> | IMetadataConstant.IBase<"number", number> | IMetadataConstant.IBase<"string", string> | IMetadataConstant.IBase<"bigint", bigint>;
export type IMetadataConstant = IMetadataConstant.IBase<"boolean", boolean> | IMetadataConstant.IBase<"number", number> | IMetadataConstant.IBase<"string", string> | IMetadataConstant.IBase<"bigint", bigint>;
export declare namespace IMetadataConstant {

@@ -4,0 +4,0 @@ interface IBase<Type extends Atomic.Literal, Value extends Atomic.Type> {

@@ -1,2 +0,2 @@

export declare type IMetadataTag = IMetadataTag.IItems | IMetadataTag.IMinItems | IMetadataTag.IMaxItems | IMetadataTag.IFormat | IMetadataTag.IPattern | IMetadataTag.ILength | IMetadataTag.IMinLength | IMetadataTag.IMaxLength | IMetadataTag.IType | IMetadataTag.IRange | IMetadataTag.IMinimum | IMetadataTag.IMaximum | IMetadataTag.IExclusiveMinimum | IMetadataTag.IExclusiveMaximum | IMetadataTag.IMultipleOf | IMetadataTag.IStep;
export type IMetadataTag = IMetadataTag.IItems | IMetadataTag.IMinItems | IMetadataTag.IMaxItems | IMetadataTag.IFormat | IMetadataTag.IPattern | IMetadataTag.ILength | IMetadataTag.IMinLength | IMetadataTag.IMaxLength | IMetadataTag.IType | IMetadataTag.IRange | IMetadataTag.IMinimum | IMetadataTag.IMaximum | IMetadataTag.IExclusiveMinimum | IMetadataTag.IExclusiveMaximum | IMetadataTag.IMultipleOf | IMetadataTag.IStep;
export declare namespace IMetadataTag {

@@ -3,0 +3,0 @@ interface IItems {

@@ -15,5 +15,9 @@ import { Atomic } from "../typings/Atomic";

readonly templates: Metadata[][];
readonly rest: Metadata | null;
readonly arrays: Metadata[];
readonly tuples: Metadata[][];
readonly objects: MetadataObject[];
readonly natives: string[];
readonly sets: Metadata[];
readonly maps: Metadata.Entry[];
/**

@@ -35,1 +39,7 @@ * @hidden

}
export declare namespace Metadata {
interface Entry {
key: Metadata;
value: Metadata;
}
}

@@ -45,2 +45,3 @@ "use strict";

this.name_ = undefined;
this.parent_resolved_ = false;
this.any = props.any;

@@ -54,5 +55,9 @@ this.required = props.required;

this.templates = props.templates;
this.rest = props.rest;
this.arrays = props.arrays;
this.tuples = props.tuples;
this.objects = props.objects;
this.natives = props.natives;
this.sets = props.sets;
this.maps = props.maps;
}

@@ -62,4 +67,5 @@ Metadata.create = function (props) {

};
Metadata.initialize = function () {
return this.create({
Metadata.initialize = function (parentResolved) {
if (parentResolved === void 0) { parentResolved = false; }
var meta = this.create({
any: false,

@@ -76,3 +82,9 @@ nullable: false,

objects: [],
rest: null,
natives: [],
sets: [],
maps: [],
});
meta.parent_resolved_ = parentResolved;
return meta;
};

@@ -91,2 +103,3 @@ Metadata.prototype.toJSON = function () {

resolved: this.resolved ? this.resolved.toJSON() : null,
rest: this.rest ? this.rest.toJSON() : null,
arrays: this.arrays.map(function (meta) { return meta.toJSON(); }),

@@ -97,2 +110,8 @@ tuples: this.tuples.map(function (meta) {

objects: this.objects.map(function (obj) { return obj.name; }),
natives: this.natives.slice(),
sets: this.sets.map(function (meta) { return meta.toJSON(); }),
maps: this.maps.map(function (entry) { return ({
key: entry.key.toJSON(),
value: entry.value.toJSON(),
}); }),
};

@@ -147,2 +166,3 @@ };

resolved: meta.resolved ? this._From(meta.resolved, objects) : null,
rest: meta.rest ? this._From(meta.rest, objects) : null,
arrays: meta.arrays.map(function (meta) { return _this._From(meta, objects); }),

@@ -158,2 +178,8 @@ tuples: meta.tuples.map(function (tuple) {

}),
natives: meta.natives.slice(),
sets: meta.sets.map(function (meta) { return _this._From(meta, objects); }),
maps: meta.maps.map(function (entry) { return ({
key: _this._From(entry.key, objects),
value: _this._From(entry.value, objects),
}); }),
});

@@ -176,5 +202,9 @@ };

.reduce(function (x, y) { return x + y; }, 0) +
(this.rest ? this.rest.size() : 0) +
this.arrays.length +
this.tuples.length +
this.objects.length);
this.objects.length +
this.natives.length +
this.sets.length +
this.maps.length);
};

@@ -187,5 +217,9 @@ Metadata.prototype.bucket = function () {

(this.constants.length ? 1 : 0) +
(this.rest ? this.rest.size() : 0) +
(this.arrays.length ? 1 : 0) +
(this.tuples.length ? 1 : 0) +
(this.objects.length ? 1 : 0));
(this.objects.length ? 1 : 0) +
(this.natives.length ? 1 : 0) +
(this.sets.length ? 1 : 0) +
(this.maps.length ? 1 : 0));
};

@@ -212,2 +246,5 @@ Metadata.prototype.isConstant = function () {

};
Metadata.prototype.isParentResolved = function () {
return this.parent_resolved_;
};
return Metadata;

@@ -363,3 +400,3 @@ }());

function covers(x, y) {
var e_11, _a, e_12, _b, e_13, _c, e_14, _d;
var e_11, _a, e_12, _b, e_13, _c, e_14, _d, e_15, _e;
if (x.any)

@@ -374,4 +411,4 @@ return true;

try {
for (var _e = __values(y.arrays), _f = _e.next(); !_f.done; _f = _e.next()) {
var ya = _f.value;
for (var _f = __values(y.arrays), _g = _f.next(); !_g.done; _g = _f.next()) {
var ya = _g.value;
var state_3 = _loop_3(ya);

@@ -385,3 +422,3 @@ if (typeof state_3 === "object")

try {
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
}

@@ -395,4 +432,4 @@ finally { if (e_11) throw e_11.error; }

try {
for (var _g = __values(y.objects), _h = _g.next(); !_h.done; _h = _g.next()) {
var yo = _h.value;
for (var _h = __values(y.objects), _j = _h.next(); !_j.done; _j = _h.next()) {
var yo = _j.value;
var state_4 = _loop_4(yo);

@@ -406,3 +443,3 @@ if (typeof state_4 === "object")

try {
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
}

@@ -421,4 +458,4 @@ finally { if (e_12) throw e_12.error; }

try {
for (var _j = __values(y.tuples), _k = _j.next(); !_k.done; _k = _j.next()) {
var yt = _k.value;
for (var _k = __values(y.tuples), _l = _k.next(); !_l.done; _l = _k.next()) {
var yt = _l.value;
var state_5 = _loop_5(yt);

@@ -432,9 +469,28 @@ if (typeof state_5 === "object")

try {
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
}
finally { if (e_13) throw e_13.error; }
}
var _loop_6 = function (ys) {
if (x.sets.some(function (xs) { return covers(xs, ys); }) === false)
return { value: false };
};
try {
for (var _m = __values(y.sets), _o = _m.next(); !_o.done; _o = _m.next()) {
var ys = _o.value;
var state_6 = _loop_6(ys);
if (typeof state_6 === "object")
return state_6.value;
}
}
catch (e_14_1) { e_14 = { error: e_14_1 }; }
finally {
try {
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
}
finally { if (e_14) throw e_14.error; }
}
if (y.atomics.some(function (atomic) { return x.atomics.includes(atomic) === false; }))
return false;
var _loop_6 = function (yc) {
var _loop_7 = function (yc) {
var xc = x.constants.find(function (elem) { return elem.type === yc.type; });

@@ -447,15 +503,15 @@ if (xc === undefined)

try {
for (var _l = __values(y.constants), _m = _l.next(); !_m.done; _m = _l.next()) {
var yc = _m.value;
var state_6 = _loop_6(yc);
if (typeof state_6 === "object")
return state_6.value;
for (var _p = __values(y.constants), _q = _p.next(); !_q.done; _q = _p.next()) {
var yc = _q.value;
var state_7 = _loop_7(yc);
if (typeof state_7 === "object")
return state_7.value;
}
}
catch (e_14_1) { e_14 = { error: e_14_1 }; }
catch (e_15_1) { e_15 = { error: e_15_1 }; }
finally {
try {
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
}
finally { if (e_14) throw e_14.error; }
finally { if (e_15) throw e_15.error; }
}

@@ -470,3 +526,3 @@ if (x.functional === false && y.functional)

function getName(metadata) {
var e_15, _a, e_16, _b, e_17, _c, e_18, _d, e_19, _e, e_20, _f, e_21, _g;
var e_16, _a, e_17, _b, e_18, _c, e_19, _d, e_20, _e, e_21, _f, e_22, _g, e_23, _h, e_24, _j, e_25, _k;
if (metadata.any === true)

@@ -480,42 +536,42 @@ return "any";

try {
for (var _h = __values(metadata.atomics), _j = _h.next(); !_j.done; _j = _h.next()) {
var type = _j.value;
for (var _l = __values(metadata.atomics), _m = _l.next(); !_m.done; _m = _l.next()) {
var type = _m.value;
elements.push(type);
}
}
catch (e_15_1) { e_15 = { error: e_15_1 }; }
catch (e_16_1) { e_16 = { error: e_16_1 }; }
finally {
try {
if (_j && !_j.done && (_a = _h.return)) _a.call(_h);
if (_m && !_m.done && (_a = _l.return)) _a.call(_l);
}
finally { if (e_15) throw e_15.error; }
finally { if (e_16) throw e_16.error; }
}
try {
for (var _k = __values(metadata.constants), _l = _k.next(); !_l.done; _l = _k.next()) {
var constant = _l.value;
for (var _o = __values(metadata.constants), _p = _o.next(); !_p.done; _p = _o.next()) {
var constant = _p.value;
try {
for (var _m = (e_17 = void 0, __values(constant.values)), _o = _m.next(); !_o.done; _o = _m.next()) {
var value = _o.value;
for (var _q = (e_18 = void 0, __values(constant.values)), _r = _q.next(); !_r.done; _r = _q.next()) {
var value = _r.value;
elements.push(JSON.stringify(value));
}
}
catch (e_17_1) { e_17 = { error: e_17_1 }; }
catch (e_18_1) { e_18 = { error: e_18_1 }; }
finally {
try {
if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
if (_r && !_r.done && (_c = _q.return)) _c.call(_q);
}
finally { if (e_17) throw e_17.error; }
finally { if (e_18) throw e_18.error; }
}
}
}
catch (e_16_1) { e_16 = { error: e_16_1 }; }
catch (e_17_1) { e_17 = { error: e_17_1 }; }
finally {
try {
if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
if (_p && !_p.done && (_b = _o.return)) _b.call(_o);
}
finally { if (e_16) throw e_16.error; }
finally { if (e_17) throw e_17.error; }
}
try {
for (var _p = __values(metadata.templates), _q = _p.next(); !_q.done; _q = _p.next()) {
var template = _q.value;
for (var _s = __values(metadata.templates), _t = _s.next(); !_t.done; _t = _s.next()) {
var template = _t.value;
elements.push("`" +

@@ -534,50 +590,91 @@ template

}
catch (e_18_1) { e_18 = { error: e_18_1 }; }
catch (e_19_1) { e_19 = { error: e_19_1 }; }
finally {
try {
if (_q && !_q.done && (_d = _p.return)) _d.call(_p);
if (_t && !_t.done && (_d = _s.return)) _d.call(_s);
}
finally { if (e_18) throw e_18.error; }
finally { if (e_19) throw e_19.error; }
}
if (metadata.rest !== null)
elements.push("...".concat(metadata.rest.getName()));
try {
for (var _r = __values(metadata.tuples), _s = _r.next(); !_s.done; _s = _r.next()) {
var tuple = _s.value;
for (var _u = __values(metadata.tuples), _v = _u.next(); !_v.done; _v = _u.next()) {
var tuple = _v.value;
elements.push("[".concat(tuple.map(function (elem) { return elem.getName(); }).join(", "), "]"));
}
}
catch (e_19_1) { e_19 = { error: e_19_1 }; }
catch (e_20_1) { e_20 = { error: e_20_1 }; }
finally {
try {
if (_s && !_s.done && (_e = _r.return)) _e.call(_r);
if (_v && !_v.done && (_e = _u.return)) _e.call(_u);
}
finally { if (e_19) throw e_19.error; }
finally { if (e_20) throw e_20.error; }
}
try {
for (var _t = __values(metadata.arrays), _u = _t.next(); !_u.done; _u = _t.next()) {
var array = _u.value;
for (var _w = __values(metadata.arrays), _x = _w.next(); !_x.done; _x = _w.next()) {
var array = _x.value;
elements.push("Array<".concat(array.getName(), ">"));
}
}
catch (e_20_1) { e_20 = { error: e_20_1 }; }
catch (e_21_1) { e_21 = { error: e_21_1 }; }
finally {
try {
if (_u && !_u.done && (_f = _t.return)) _f.call(_t);
if (_x && !_x.done && (_f = _w.return)) _f.call(_w);
}
finally { if (e_20) throw e_20.error; }
finally { if (e_21) throw e_21.error; }
}
try {
for (var _v = __values(metadata.objects), _w = _v.next(); !_w.done; _w = _v.next()) {
var object = _w.value;
for (var _y = __values(metadata.objects), _z = _y.next(); !_z.done; _z = _y.next()) {
var object = _z.value;
elements.push("Resolve<".concat(object.name, ">"));
}
}
catch (e_21_1) { e_21 = { error: e_21_1 }; }
catch (e_22_1) { e_22 = { error: e_22_1 }; }
finally {
try {
if (_w && !_w.done && (_g = _v.return)) _g.call(_v);
if (_z && !_z.done && (_g = _y.return)) _g.call(_y);
}
finally { if (e_21) throw e_21.error; }
finally { if (e_22) throw e_22.error; }
}
if (metadata.resolved !== null)
elements.push(metadata.resolved.getName());
try {
for (var _0 = __values(metadata.natives), _1 = _0.next(); !_1.done; _1 = _0.next()) {
var native = _1.value;
elements.push(native);
}
}
catch (e_23_1) { e_23 = { error: e_23_1 }; }
finally {
try {
if (_1 && !_1.done && (_h = _0.return)) _h.call(_0);
}
finally { if (e_23) throw e_23.error; }
}
try {
for (var _2 = __values(metadata.sets), _3 = _2.next(); !_3.done; _3 = _2.next()) {
var set = _3.value;
elements.push("Set<".concat(set.getName(), ">"));
}
}
catch (e_24_1) { e_24 = { error: e_24_1 }; }
finally {
try {
if (_3 && !_3.done && (_j = _2.return)) _j.call(_2);
}
finally { if (e_24) throw e_24.error; }
}
try {
for (var _4 = __values(metadata.maps), _5 = _4.next(); !_5.done; _5 = _4.next()) {
var map = _5.value;
elements.push("Map<".concat(map.key.getName(), ", ").concat(map.value.getName(), ">"));
}
}
catch (e_25_1) { e_25 = { error: e_25_1 }; }
finally {
try {
if (_5 && !_5.done && (_k = _4.return)) _k.call(_4);
}
finally { if (e_25) throw e_25.error; }
}
if (elements.length === 0)

@@ -584,0 +681,0 @@ return "unknown";

@@ -13,4 +13,3 @@ import { IJsDocTagInfo } from "./IJsDocTagInfo";

private constructor();
static _From_without_properties(obj: IMetadataObject): MetadataObject;
toJSON(): IMetadataObject;
}

@@ -31,2 +31,12 @@ "use strict";

};
MetadataObject.prototype._Is_simple = function () {
return (this.properties.length < 4 &&
this.properties.every(function (property) {
return property.key.isSoleLiteral() &&
property.value.size() === 1 &&
property.value.atomics.length === 1 &&
property.value.nullable === false &&
property.value.required === true;
}));
};
MetadataObject.prototype.toJSON = function () {

@@ -33,0 +43,0 @@ return {

@@ -6,2 +6,3 @@ import { IJsonApplication } from "./schemas/IJsonApplication";

export * from "./schemas/IJsonSchema";
export * from "./Primitive";
export * from "./TypeGuardError";

@@ -30,3 +31,3 @@ export * from "./IValidation";

*/
export declare function assertType<T>(input: T): T;
export declare function assert<T>(input: T): T;
/**

@@ -41,3 +42,3 @@ * Asserts a value type.

* following the type `T` or not, you can choose the {@link is} function instead.
* Otherwise you want to know all the errors, {@link validate} is the way to go.
* Otherwise, you want to know all the errors, {@link validate} is the way to go.
*

@@ -54,2 +55,30 @@ * On the other and, if you don't want to allow any superfluous property that is not

*/
export declare function assert<T>(input: unknown): T;
/**
* Asserts a value type.
*
* Duplicated function of {@link assert} for `typescript-is` users.
*
* @template T Type of the input value
* @param input A value to be asserted
* @returns Parametric input value
* @throws A {@link TypeGuardError} instance with detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
* @deprecated
*/
export declare function assertType<T>(input: T): T;
/**
* Asserts a value type.
*
* Duplicated function of {@link assert} for `typescript-is` users.
*
* @template T Type of the input value
* @param input A value to be asserted
* @returns Parametric input value
* @throws A {@link TypeGuardError} instance with detailed reason
*
* @author Jeongho Nam - https://github.com/samchon
* @deprecated
*/
export declare function assertType<T>(input: unknown): T;

@@ -66,3 +95,3 @@ /**

* type `T` or not, but throwing an exception with detailed reason, you can choose
* {@link assertType} function instead. Also, if you want to know all the errors with
* {@link assert} function instead. Also, if you want to know all the errors with
* detailed reasons, {@link validate} function would be useful.

@@ -90,3 +119,3 @@ *

* type `T` or not, but throwing an exception with detailed reason, you can choose
* {@link assertType} function instead. Also, if you want to know all the errors with
* {@link assert} function instead. Also, if you want to know all the errors with
* detailed reasons, {@link validate} function would be useful.

@@ -114,3 +143,3 @@ *

* If what you want is not finding all the error, but asserting the parametric value
* type with exception throwing, you can choose {@link assertType} function instead.
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, you just want to know whether the parametric value is matched with the

@@ -125,4 +154,6 @@ * type `T`, {@link is} function is the way to go.

* @returns Validation result
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function validate<T>(input: T): IValidation;
export declare function validate<T>(input: T): IValidation<T>;
/**

@@ -138,3 +169,3 @@ * Validates a value type.

* If what you want is not finding all the error, but asserting the parametric value
* type with exception throwing, you can choose {@link assertType} function instead.
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, you just want to know whether the parametric value is matched with the

@@ -149,4 +180,6 @@ * type `T`, {@link is} function is the way to go.

* @returns Validation result
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function validate<T>(input: unknown): IValidation;
export declare function validate<T>(input: unknown): IValidation<T>;
/**

@@ -163,6 +196,6 @@ * Asserts equality between a value and its type.

* following the type `T` or not, you can choose the {@link equals} function instead.
* Otherwise you want to know all the errors, {@link validateEquals} is the way to go.
* Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link assertType} function instead.
* to the type `T`, you can use {@link assert} function instead.
*

@@ -188,6 +221,6 @@ * @template T Type of the input value

* following the type `T` or not, you can choose the {@link equals} function instead.
* Otherwise you want to know all the errors, {@link validateEquals} is the way to go.
* Otherwise, you want to know all the errors, {@link validateEquals} is the way to go.
*
* On the other hand, if you want to allow superfluous property that is not enrolled
* to the type `T`, you can use {@link assertType} function instead.
* to the type `T`, you can use {@link assert} function instead.
*

@@ -251,3 +284,3 @@ * @template T Type of the input value

/**
* Validates equaility between a value and itstype.
* Validates equality between a value and its type.
*

@@ -262,3 +295,3 @@ * Validates a parametric value type and archives all the type errors into an

* If what you want is not finding all the error, but asserting the parametric value
* type with exception throwing, you can choose {@link assertType} function instead.
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, you just want to know whether the parametric value is matched with the

@@ -273,6 +306,8 @@ * type `T`, {@link is} function is the way to go.

* @returns Validation result
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function validateEquals<T>(input: T): IValidation;
export declare function validateEquals<T>(input: T): IValidation<T>;
/**
* Validates equaility between a value and itstype.
* Validates equality between a value and its type.
*

@@ -287,3 +322,3 @@ * Validates a parametric value type and archives all the type errors into an

* If what you want is not finding all the error, but asserting the parametric value
* type with exception throwing, you can choose {@link assertType} function instead.
* type with exception throwing, you can choose {@link assert} function instead.
* Otherwise, you just want to know whether the parametric value is matched with the

@@ -298,56 +333,7 @@ * type `T`, {@link is} function is the way to go.

* @returns Validation result
*/
export declare function validateEquals<T>(input: unknown): IValidation;
/**
* 5x faster `JSON.stringify()` function.
*
* Converts an input value to a JSON (JavaSript Object Noation) string, about 5x faster
* than the native `JSON.stringify()` function. The 5x faster principle is because
* it writes an optmized JSON conversion plan, only for the type `T`.
*
* If you want to create a stringify function which is reusable, just assign this function
* to a (constant) variable like below, with the generic argument `T`. Then the variable
* would be a stringify fuction reusable.
*
* ```typescript
* const stringify = TSON.stringify<MyType>;
* stringify(x);
* stringify(y);
* stringify(z);
* ```
*
* For reference, this `TSON.stringify()` does not validate the input value type. It
* just believes that the input value is following the type `T`. Therefore, if you
* can't ensure the input value type, it would better to call {@link assertType} or
* {@link is} function before.
*
* @template T Type of the input value
* @param input A value to be converted
* @return JSON string value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function stringify<T>(input: T): string;
export declare function validateEquals<T>(input: unknown): IValidation<T>;
/**
* 2x faster constant object creator.
*
* You know what? `JSON.parse()` is faster than literal object construction, when the
* object would be constructed only one time.
*
* - [Faster apps with JSON.parse (Chrome Dev Summit 2019)](https://www.youtube.com/watch?v=ff4fgQxPaO0)
* - [The cost of parsing JSON](https://v8.dev/blog/cost-of-javascript-2019#json)
*
* `TSON.create()` is a transformer function which converts a literal object construction
* to a `JSON.parse()` function call expression with JSON string argument. Therefore, if
* you construct a literal object via this `TSON.create()`, you can get benefit from both
* type safe and performance tuning at the same time.
*
* @template T Type of the input value
* @param input A value to be converted
* @return Same with the parametric value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function create<T>(input: T): T;
/**
* > You must configure the generic argument `T`.

@@ -361,5 +347,5 @@ *

*
* Also, `TSON.application()` has additional generic arguments, *Purpose*.
* Also, `typia.application()` has additional generic arguments, *Purpose*.
* As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
* you should configure the *Purpose* apprpriately.
* you should configure the *Purpose* appropriately.
*

@@ -371,3 +357,3 @@ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists

* @template Types Tuple of target types
* @template Purpose Purpose of the JSON schema
* @template Purpose Purpose of the JSON schema`
* @template Prefix Prefix of the JSON components referenced by `$ref` tag

@@ -386,5 +372,5 @@ * @return JSON schema application

*
* Also, `TSON.application()` has additional generic arguments, *Purpose*.
* Also, `typia.application()` has additional generic arguments, *Purpose*.
* As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
* you should configure the *Purpose* apprpriately.
* you should configure the *Purpose* appropriately.
*

@@ -403,1 +389,546 @@ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists

export declare function application<Types extends unknown[], Purpose extends "swagger" | "ajv" = "swagger", Prefix extends string = Purpose extends "swagger" ? "#/components/schemas" : "components#/schemas">(): IJsonApplication;
/**
* > You must configure the generic argument `T`.
*
* Safe `JSON.parse()` function with type assertion.
*
* `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
* Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
* instance with type assertion.
*
* In such reason, when parsed JSON string value is not matched with the type `T`, it
* throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
* the parsed value would be returned.
*
* @template T Expected type of parsed value
* @param input JSON string
* @returns Parsed value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function assertParse(input: string): never;
/**
* Safe `JSON.parse()` function with type assertion.
*
* `typia.assertParse()` is a combination function of `JSON.parse()` and {@link assert}.
* Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
* instance with type assertion.
*
* In such reason, when parsed JSON string value is not matched with the type `T`, it
* throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
* the parsed value would be returned.
*
* @template T Expected type of parsed value
* @param input JSON string
* @returns Parsed value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function assertParse<T>(input: string): T;
/**
* > You must configure the generic argument `T`.
*
* Safe `JSON.parse()` function with type checking.
*
* `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
* Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
* instance with type checking.
*
* In such reason, when parsed JSON string value is not matched with the type `T`, it
* returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
* value would be returned.
*
* @template T Expected type of parsed value
* @param input JSON string
* @returns Parsed value when exact type, otherwise `null`
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function isParse(input: string): never;
/**
* Safe `JSON.parse()` function with type checking.
*
* `typia.isParse()` is a combination function of `JSON.parse()` and {@link is}.
* Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
* instance with type checking.
*
* In such reason, when parsed JSON string value is not matched with the type `T`, it
* returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
* value would be returned.
*
* @template T Expected type of parsed value
* @param input JSON string
* @returns Parsed value when exact type, otherwise `null`
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function isParse<T>(input: string): T | null;
/**
* > You must configure the generic argument `T`.
*
* Safe `JSON.parse()` function with detailed type validation.
*
* `typia.validateParse()` is a combination function of `JSON.parse()` and
* {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
* to a `T` typed instance with detailed type validation.
*
* In such reason, when parsed JSON string value is not matched with the type `T`, it
* returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
* there's no problem on the parsed value, the parsed value would be stored in `data`
* property of the output {@link IValidation.ISuccess} instance.
*
* @template T Expected type of parsed value
* @param input JSON string
* @returns Validation result with JSON parsed value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function validateParse(input: string): never;
/**
* Safe `JSON.parse()` function with detailed type validation.
*
* `typia.validateParse()` is a combination function of `JSON.parse()` and
* {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
* to a `T` typed instance with detailed type validation.
*
* In such reason, when parsed JSON string value is not matched with the type `T`, it
* returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
* there's no problem on the parsed value, the parsed value would be stored in `data`
* property of the output {@link IValidation.ISuccess} instance.
*
* @template T Expected type of parsed value
* @param input JSON string
* @returns Validation result with JSON parsed value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function validateParse<T>(input: string): IValidation<T>;
/**
* 8x faster `JSON.stringify()` function.
*
* Converts an input value to a JSON (JavaScript Object Notation) string, about 8x faster
* than the native `JSON.stringify()` function. The 5x faster principle is because
* it writes an optimized JSON conversion plan, only for the type `T`.
*
* For reference, this `typia.stringify()` does not validate the input value type. It
* just believes that the input value is following the type `T`. Therefore, if you
* can't ensure the input value type, it would be better to call one of below functions
* instead.
*
* - {@link assertStringify}
* - {@link isStringify}
* - {@link validateStringify}
*
* @template T Type of the input value
* @param input A value to be converted
* @return JSON string value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function stringify<T>(input: T): string;
/**
* 5x faster `JSON.stringify()` function with type assertion.
*
* `typia.assertStringify()` is a combination function of {@link assert} and
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
* Notation) string, with type assertion.
*
* In such reason, when `input` value is not matched with the type `T`, it throws an
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
* string would be returned.
*
* For reference, with type assertion, it is even 5x times faster than the native
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
* with confidence.
*
* @template T Type of the input value
* @param input A value to be asserted and converted
* @return JSON string value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function assertStringify<T>(input: T): string;
/**
* 5x faster `JSON.stringify()` function with type assertion.
*
* `typia.assertStringify()` is a combination function of {@link assert} and
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
* Notation) string, with type assertion.
*
* In such reason, when `input` value is not matched with the type `T`, it throws an
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
* string would be returned.
*
* For reference, with type assertion, it is even 5x times faster than the native
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
* with confidence.
*
* @template T Type of the input value
* @param input A value to be asserted and converted
* @return JSON string value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function assertStringify<T>(input: T): unknown;
/**
* 7x faster `JSON.stringify()` function with type checking.
*
* `typia.stringify()` is a combination function of {@link is} and
* {@link stringify}. Therefore, it converts an input value to JSON
* (JavaScript Object Notation) string, with type checking.
*
* In such reason, when `input` value is not matched with the type `T`, it returns
* `null` value. Otherwise, there's no problem on the `input` value, JSON string would
* be returned.
*
* For reference, with type checking, it is even 7x times faster than the native
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
* with confidence.
*
* @template T Type of the input value
* @param input A value to be checked and converted
* @return JSON string value when exact type, otherwise null
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function isStringify<T>(input: T): string | null;
/**
* 7x faster `JSON.stringify()` function with type checking.
*
* `typia.isStringify()` is a combination function of {@link is} and
* {@link stringify}. Therefore, it converts an input value to JSON
* (JavaScript Object Notation) string, with type checking.
*
* In such reason, when `input` value is not matched with the type `T`, it returns
* `null` value. Otherwise, there's no problem on the `input` value, JSON string would
* be returned.
*
* For reference, with type checking, it is even 7x times faster than the native
* `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
* with confidence.
*
* @template T Type of the input value
* @param input A value to be checked and converted
* @return JSON string value when exact type, otherwise null
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function isStringify<T>(input: unknown): string | null;
/**
* 5x faster `JSON.stringify()` function with detailed type validation.
*
* `typia.validateStringify()` is a combination function of {@link validate} and
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
* Notation) string, with detailed type validation.
*
* In such reason, when `input` value is not matched with the type `T`, it returns
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
* problem on the `input` value, JSON string would be stored in `data` property of
* the output {@link IValidation.ISuccess} instance.
*
* For reference, with detailed type validation, it is even 5x times faster than the
* native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
* with confidence.
*
* @template T Type of the input value
* @param input A value to be checked and converted
* @returns Validation result with JSON string value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function validateStringify<T>(input: T): IValidation<string>;
/**
* 5x faster `JSON.stringify()` function with detailed type validation.
*
* `typia.validateStringify()` is a combination function of {@link validate} and
* {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
* Notation) string, with detailed type validation.
*
* In such reason, when `input` value is not matched with the type `T`, it returns
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's no
* problem on the `input` value, JSON string would be stored in `data` property of
* the output {@link IValidation.ISuccess} instance.
*
* For reference, with detailed type validation, it is even 5x times faster than the
* native `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
* with confidence.
*
* @template T Type of the input value
* @param input A value to be checked and converted
* @returns Validation result with JSON string value
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function validateStringify<T>(input: unknown): IValidation<string>;
/**
* Creates a reusable {@link assert} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssert(): never;
/**
* Creates a reusable {@link assert} function.
*
* @template T Type of the input value
* @returns A reusable `assert` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssert<T>(): (input: unknown) => T;
/**
* Creates a reusable {@link assertType} function.
*
* Duplicated function of {@link createAssert} for `typescript-is` users.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
* @deprecated
*/
export declare function createAssertType(): never;
/**
* Creates a reusable {@link assertType} function.
*
* Duplicated function of {@link createAssert} for `typescript-is` users.
*
* @template T Type of the input value
* @returns A reusable `assert` function
*
* @author Jeongho Nam - https://github.com/samchon
* @deprecated
*/
export declare function createAssertType<T>(): (input: unknown) => T;
/**
* Creates a reusable {@link is} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createIs(): never;
/**
* Creates a reusable {@link is} function.
*
* @template T Type of the input value
* @returns A reusable `is` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createIs<T>(): (input: unknown) => input is T;
/**
* Creates a reusable {@link validate} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidate(): never;
/**
* Creates a reusable {@link validate} function.
*
* @template T Type of the input value
* @returns A reusable `validate` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidate<T>(): (input: unknown) => IValidation<T>;
/**
* Creates a reusable {@link assertEquals} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssertEquals(): never;
/**
* Creates a reusable {@link assertEquals} function.
*
* @template T Type of the input value
* @returns A reusable `assertEquals` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssertEquals<T>(): (input: unknown) => T;
/**
* Creates a reusable {@link equals} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createEquals(): never;
/**
* Creates a reusable {@link equals} function.
*
* @template T Type of the input value
* @returns A reusable `equals` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createEquals<T>(): (input: unknown) => input is T;
/**
* Creates a reusable {@link validateEquals} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidateEquals(): never;
/**
* Creates a reusable {@link validateEquals} function.
*
* @template T Type of the input value
* @returns A reusable `validateEquals` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidateEquals<T>(): (input: unknown) => IValidation;
/**
* Creates a reusable {@link isParse} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createIsParse(): never;
/**
* Creates a reusable {@link isParse} function.
*
* @template T Expected type of parsed value
* @returns A reusable `isParse` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createIsParse<T>(): (input: string) => T | null;
/**
* Creates a reusable {@link assertParse} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssertParse(): never;
/**
* Creates a reusable {@link assertParse} function.
*
* @template T Expected type of parsed value
* @returns A reusable `assertParse` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssertParse<T>(): (input: string) => T;
/**
* Creates a reusable {@link validateParse} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidateParse(): never;
/**
* Creates a reusable {@link validateParse} function.
*
* @template T Expected type of parsed value
* @returns A reusable `validateParse` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidateParse<T>(): (input: string) => IValidation<T>;
/**
* Creates a reusable {@link stringify} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createStringify(): never;
/**
* Creates a reusable {@link stringify} function.
*
* @template T Type of the input value
* @returns A reusable `stringify` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createStringify<T>(): (input: T) => string;
/**
* Creates a reusable {@link assertStringify} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssertStringify(): never;
/**
* Creates a reusable {@link assertStringify} function.
*
* @template T Type of the input value
* @returns A reusable `assertStringify` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createAssertStringify<T>(): (input: unknown) => string;
/**
* Creates a reusable {@link isStringify} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createIsStringify(): never;
/**
* Creates a reusable {@link isStringify} function.
*
* @template T Type of the input value
* @returns A reusable `isStringify` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createIsStringify<T>(): (input: unknown) => string | null;
/**
* Creates a reusable {@link validateStringify} function.
*
* @danger You have to specify the generic argument `T`
* @return Nothing until specifying the generic argument `T`
* @throws compile error
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidateStringify(): never;
/**
* Creates a reusable {@link validateStringify} function.
*
* @template T Type of the input value
* @returns A reusable `validateStringify` function
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare function createValidateStringify<T>(): (input: unknown) => IValidation<string>;

@@ -28,3 +28,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.application = exports.create = exports.stringify = exports.validateEquals = exports.equals = exports.assertEquals = exports.validate = exports.is = exports.assertType = void 0;
exports.metadata = exports.createValidateStringify = exports.createIsStringify = exports.createAssertStringify = exports.createStringify = exports.createValidateParse = exports.createAssertParse = exports.createIsParse = exports.createValidateEquals = exports.createEquals = exports.createAssertEquals = exports.createValidate = exports.createIs = exports.createAssertType = exports.createAssert = exports.validateStringify = exports.isStringify = exports.assertStringify = exports.stringify = exports.validateParse = exports.isParse = exports.assertParse = exports.application = exports.validateEquals = exports.equals = exports.assertEquals = exports.validate = exports.is = exports.assertType = exports.assert = void 0;
var _every_1 = require("./functional/$every");
var _guard_1 = require("./functional/$guard");
var _is_email_1 = require("./functional/$is_email");

@@ -37,2 +39,4 @@ var _is_ipv4_1 = require("./functional/$is_ipv4");

var _number_1 = require("./functional/$number");
var _report_1 = require("./functional/$report");
var _rest_1 = require("./functional/$rest");
var _string_1 = require("./functional/$string");

@@ -44,4 +48,19 @@ var _tail_1 = require("./functional/$tail");

__exportStar(require("./schemas/IJsonSchema"), exports);
__exportStar(require("./Primitive"), exports);
__exportStar(require("./TypeGuardError"), exports);
__exportStar(require("./IValidation"), exports);
function assert() {
halt("assert");
}
exports.assert = assert;
(function (assert) {
assert.is_uuid = _is_uuid_1.$is_uuid;
assert.is_email = _is_email_1.$is_email;
assert.is_url = _is_url_1.$is_url;
assert.is_ipv4 = _is_ipv4_1.$is_ipv4;
assert.is_ipv6 = _is_ipv6_1.$is_ipv6;
assert.join = _join_1.$join;
assert.every = _every_1.$every;
assert.guard = (0, _guard_1.$guard)("typia.assert");
})(assert = exports.assert || (exports.assert = {}));
function assertType() {

@@ -52,11 +71,5 @@ halt("assertType");

(function (assertType) {
assertType.is_uuid = _is_uuid_1.$is_uuid;
assertType.is_email = _is_email_1.$is_email;
assertType.is_url = _is_url_1.$is_url;
assertType.is_ipv4 = _is_ipv4_1.$is_ipv4;
assertType.is_ipv6 = _is_ipv6_1.$is_ipv6;
assertType.join = _join_1.$join;
function predicate(matched, exceptionable, closure) {
if (matched === false && exceptionable === true)
throw new TypeGuardError_1.TypeGuardError(__assign({ method: "TSON.assertType" }, closure()));
throw new TypeGuardError_1.TypeGuardError(__assign({ method: "typia.assertType" }, closure()));
return matched;

@@ -66,2 +79,3 @@ }

})(assertType = exports.assertType || (exports.assertType = {}));
Object.assign(assertType, assert);
function is() {

@@ -89,2 +103,3 @@ halt("is");

validate.join = _join_1.$join;
validate.report = _report_1.$report;
validate.predicate = function (res) {

@@ -95,5 +110,6 @@ return function (matched, exceptionable, closure) {

res.success && (res.success = false);
var errorList = res.errors;
var error = closure();
if (res.errors.length) {
var last = res.errors[res.errors.length - 1].path;
if (errorList.length) {
var last = errorList[errorList.length - 1].path;
if (last.length >= error.path.length &&

@@ -103,3 +119,3 @@ last.substring(0, error.path.length) === error.path)

}
res.errors.push(error);
errorList.push(error);
return;

@@ -122,5 +138,7 @@ })();

assertEquals.join = _join_1.$join;
assertEquals.every = _every_1.$every;
assertEquals.guard = (0, _guard_1.$guard)("typia.assertEquals");
function predicate(matched, exceptionable, closure) {
if (matched === false && exceptionable === true)
throw new TypeGuardError_1.TypeGuardError(__assign({ method: "TSON.assertEquals" }, closure()));
throw new TypeGuardError_1.TypeGuardError(__assign({ method: "typia.assertEquals" }, closure()));
return matched;

@@ -153,2 +171,3 @@ }

validateEquals.join = _join_1.$join;
validateEquals.report = validate.report;
validateEquals.predicate = function (res) {

@@ -159,5 +178,6 @@ return function (matched, exceptionable, closure) {

res.success && (res.success = false);
var errorList = res.errors;
var error = closure();
if (res.errors.length) {
var last = res.errors[res.errors.length - 1].path;
if (errorList.length) {
var last = errorList[errorList.length - 1].path;
if (last.length >= error.path.length &&

@@ -167,3 +187,3 @@ last.substring(0, error.path.length) === error.path)

}
res.errors.push(error);
errorList.push(error);
return;

@@ -175,2 +195,30 @@ })();

})(validateEquals = exports.validateEquals || (exports.validateEquals = {}));
function application() {
halt("application");
}
exports.application = application;
function assertParse() {
halt("assertParse");
}
exports.assertParse = assertParse;
(function (assertParse) {
assertParse.is_uuid = _is_uuid_1.$is_uuid;
assertParse.is_email = _is_email_1.$is_email;
assertParse.is_url = _is_url_1.$is_url;
assertParse.is_ipv4 = _is_ipv4_1.$is_ipv4;
assertParse.is_ipv6 = _is_ipv6_1.$is_ipv6;
assertParse.join = _join_1.$join;
assertParse.every = _every_1.$every;
assertParse.guard = (0, _guard_1.$guard)("typia.assertParse");
})(assertParse = exports.assertParse || (exports.assertParse = {}));
function isParse() {
halt("isParse");
}
exports.isParse = isParse;
Object.assign(isParse, is);
function validateParse() {
halt("validateParse");
}
exports.validateParse = validateParse;
Object.assign(validateParse, validate);
function stringify() {

@@ -184,18 +232,132 @@ halt("stringify");

stringify.tail = _tail_1.$tail;
stringify.rest = _rest_1.$rest;
function throws(props) {
throw new TypeGuardError_1.TypeGuardError(__assign(__assign({}, props), { method: "TSON.stringify" }));
throw new TypeGuardError_1.TypeGuardError(__assign(__assign({}, props), { method: "typia.stringify" }));
}
stringify.throws = throws;
})(stringify = exports.stringify || (exports.stringify = {}));
function create() {
halt("create");
function assertStringify() {
halt("assertStringify");
}
exports.create = create;
function application() {
halt("application");
exports.assertStringify = assertStringify;
(function (assertStringify) {
assertStringify.is_uuid = _is_uuid_1.$is_uuid;
assertStringify.is_email = _is_email_1.$is_email;
assertStringify.is_url = _is_url_1.$is_url;
assertStringify.is_ipv4 = _is_ipv4_1.$is_ipv4;
assertStringify.is_ipv6 = _is_ipv6_1.$is_ipv6;
assertStringify.number = _number_1.$number;
assertStringify.string = _string_1.$string;
assertStringify.tail = _tail_1.$tail;
assertStringify.rest = _rest_1.$rest;
assertStringify.join = _join_1.$join;
assertStringify.guard = (0, _guard_1.$guard)("typia.assertStringify");
assertStringify.every = _every_1.$every;
assertStringify.throws = function () { };
function predicate(matched, exceptionable, closure) {
if (matched === false && exceptionable === true)
throw new TypeGuardError_1.TypeGuardError(__assign({ method: "typia.assertStringify" }, closure()));
return matched;
}
assertStringify.predicate = predicate;
})(assertStringify = exports.assertStringify || (exports.assertStringify = {}));
function isStringify() {
halt("isStringify");
}
exports.application = application;
exports.isStringify = isStringify;
(function (isStringify) {
isStringify.is_uuid = _is_uuid_1.$is_uuid;
isStringify.is_email = _is_email_1.$is_email;
isStringify.is_url = _is_url_1.$is_url;
isStringify.is_ipv4 = _is_ipv4_1.$is_ipv4;
isStringify.is_ipv6 = _is_ipv6_1.$is_ipv6;
isStringify.number = _number_1.$number;
isStringify.string = _string_1.$string;
isStringify.tail = _tail_1.$tail;
isStringify.rest = _rest_1.$rest;
isStringify.throws = function () { };
})(isStringify = exports.isStringify || (exports.isStringify = {}));
function validateStringify() {
halt("validateStringify");
}
exports.validateStringify = validateStringify;
Object.assign(validateStringify, validate);
Object.assign(validateStringify, stringify);
function createAssert() {
halt("createAssert");
}
exports.createAssert = createAssert;
Object.assign(createAssert, assert);
function createAssertType() {
halt("createAssertType");
}
exports.createAssertType = createAssertType;
Object.assign(createAssertType, assertType);
function createIs() {
halt("createIs");
}
exports.createIs = createIs;
Object.assign(createIs, is);
function createValidate() {
halt("createValidate");
}
exports.createValidate = createValidate;
Object.assign(createValidate, validate);
function createAssertEquals() {
halt("createAssertEquals");
}
exports.createAssertEquals = createAssertEquals;
Object.assign(createAssertEquals, assertEquals);
function createEquals() {
halt("createEquals");
}
exports.createEquals = createEquals;
Object.assign(createEquals, equals);
function createValidateEquals() {
halt("createValidateEquals");
}
exports.createValidateEquals = createValidateEquals;
Object.assign(createValidateEquals, validateEquals);
function createIsParse() {
halt("createIsParse");
}
exports.createIsParse = createIsParse;
Object.assign(createIsParse, isParse);
function createAssertParse() {
halt("createAssertParse");
}
exports.createAssertParse = createAssertParse;
Object.assign(createAssertParse, assertParse);
function createValidateParse() {
halt("createValidateParse");
}
exports.createValidateParse = createValidateParse;
Object.assign(createValidateParse, validateParse);
function createStringify() {
halt("createStringify");
}
exports.createStringify = createStringify;
Object.assign(createStringify, stringify);
function createAssertStringify() {
halt("createAssertStringify");
}
exports.createAssertStringify = createAssertStringify;
Object.assign(createAssertStringify, assertStringify);
function createIsStringify() {
halt("createIsStringify");
}
exports.createIsStringify = createIsStringify;
Object.assign(createIsStringify, isStringify);
function createValidateStringify() {
halt("createValidateStringify");
}
exports.createValidateStringify = createValidateStringify;
Object.assign(createValidateStringify, validateStringify);
function metadata() {
halt("metadata");
}
exports.metadata = metadata;
function halt(name) {
throw new Error("Error on TSON.".concat(name, "(): no transform has been configured. Configure the \"tsconfig.json\" file following the [README.md#setup](https://github.com/samchon/typescript-json#setup)"));
throw new Error("Error on typia.".concat(name, "(): no transform has been configured. Configure the \"tsconfig.json\" file following the [README.md#setup](https://github.com/samchon/typia#setup)"));
}
//# sourceMappingURL=module.js.map

@@ -39,6 +39,6 @@ "use strict";

var generator = (0, application_schema_1.application_schema)(fullOptions)(components)(true);
return __assign({ schemas: metadatas.map(function (meta) {
return __assign({ schemas: metadatas.map(function (meta, i) {
var schema = generator(meta, {});
if (schema === null)
throw new Error("Error on TSON.application(): never type on argument.");
throw new Error("Error on typia.application(): invalid type on argument - (".concat(meta.getName(), ", ").concat(i, ")"));
return schema;

@@ -45,0 +45,0 @@ }), components: components }, fullOptions);

import ts from "typescript";
import { IProject } from "../transformers/IProject";
export declare namespace AssertProgrammer {
function generate(project: IProject, modulo: ts.LeftHandSideExpression, equals?: boolean): (type: ts.Type) => ts.ArrowFunction;
const generate: (project: IProject, modulo: ts.LeftHandSideExpression, equals?: boolean) => (type: ts.Type) => ts.ArrowFunction;
}
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -8,3 +33,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var typescript_1 = __importDefault(require("typescript"));
var ValueFactory_1 = require("../factories/ValueFactory");
var IdentifierFactory_1 = require("../factories/IdentifierFactory");
var CheckerProgrammer_1 = require("./CheckerProgrammer");

@@ -16,66 +41,116 @@ var IsProgrammer_1 = require("./IsProgrammer");

(function (AssertProgrammer) {
function generate(project, modulo, equals) {
AssertProgrammer.generate = function (project, modulo, equals) {
if (equals === void 0) { equals = false; }
var importer = new FunctionImporeter_1.FunctionImporter();
return function (type) {
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, ValueFactory_1.ValueFactory.INPUT()),
], undefined, undefined, typescript_1.default.factory.createBlock([
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(CheckerProgrammer_1.CheckerProgrammer.generate(project, {
functors: "$ao",
unioners: "$au",
trace: true,
numeric: !!project.options.numeric,
equals: equals,
combiner: combine(equals)(importer),
joiner: CheckerProgrammer_1.CheckerProgrammer.DEFAULT_JOINER(assert_object(equals)(importer)),
}, modulo, importer)(type), undefined, [ValueFactory_1.ValueFactory.INPUT()])),
typescript_1.default.factory.createReturnStatement(ValueFactory_1.ValueFactory.INPUT()),
]));
var importer = new FunctionImporeter_1.FunctionImporter();
var program = CheckerProgrammer_1.CheckerProgrammer.generate(project, {
functors: "$ao",
unioners: "$au",
path: true,
trace: true,
numeric: !!project.options.numeric,
equals: equals,
combiner: combiner(equals)(importer),
joiner: joiner(equals)(importer),
success: typescript_1.default.factory.createTrue(),
}, importer)(type);
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("input")], undefined, undefined, typescript_1.default.factory.createBlock(__spreadArray(__spreadArray([], __read(importer.declare(modulo)), false), [
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(program, undefined, [
typescript_1.default.factory.createIdentifier("input"),
typescript_1.default.factory.createStringLiteral("$input"),
typescript_1.default.factory.createTrue(),
])),
typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createIdentifier("input")),
], false), true));
};
}
AssertProgrammer.generate = generate;
})(AssertProgrammer = exports.AssertProgrammer || (exports.AssertProgrammer = {}));
var combine = function (equals) {
return function (importer) {
return function (explore) {
var combiner = IsProgrammer_1.IsProgrammer.CONFIG({
object: assert_object(equals)(importer),
numeric: true,
}).combiner;
if (explore.tracable === false && explore.from !== "top")
return combiner(explore);
var path = explore.postfix
? "path + ".concat(explore.postfix)
: "path";
return function (logic) { return function (input, expressions, expected) {
return typescript_1.default.factory.createCallExpression(importer.use("predicate"), [], [
combiner(explore)(logic)(input, expressions, expected),
explore.source === "top"
};
var combiner = function (equals) {
return function (importer) {
return function (explore) {
if (explore.tracable === false && explore.from !== "top")
return IsProgrammer_1.IsProgrammer.CONFIG({
object: assert_object(equals)(importer),
numeric: true,
}).combiner(explore);
var path = explore.postfix
? "path + ".concat(explore.postfix)
: "path";
return function (logic) { return function (input, binaries, expected) {
return logic === "and"
? binaries
.map(function (binary) {
return binary.combined
? binary.expression
: typescript_1.default.factory.createLogicalOr(binary.expression, create_guard_call(importer)(explore.source === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"))(typescript_1.default.factory.createIdentifier(path), expected, input));
})
.reduce(typescript_1.default.factory.createLogicalAnd)
: (function () {
var addicted = binaries.slice();
if (addicted[addicted.length - 1].combined === false) {
addicted.push({
combined: true,
expression: create_guard_call(importer)(explore.source === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"))(typescript_1.default.factory.createIdentifier(path), expected, input),
});
}
return addicted
.map(function (b) { return b.expression; })
.reduce(typescript_1.default.factory.createLogicalOr);
})();
}; };
};
};
};
var assert_object = function (equals) { return function (importer) {
return (0, check_object_1.check_object)({
equals: equals,
assert: true,
reduce: typescript_1.default.factory.createLogicalAnd,
positive: typescript_1.default.factory.createTrue(),
superfluous: function (value) {
return create_guard_call(importer)()(typescript_1.default.factory.createAdd(typescript_1.default.factory.createIdentifier("path"), typescript_1.default.factory.createCallExpression(importer.use("join"), undefined, [typescript_1.default.factory.createIdentifier("key")])), "undefined", value);
},
halt: function (expr) {
return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createIdentifier("exceptionable")), expr);
},
});
}; };
var joiner = function (equals) {
return function (importer) { return ({
object: assert_object(equals)(importer),
array: function (input, arrow) {
return typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "every"), undefined, [arrow]);
},
failure: function (value, expected, explore) {
return create_guard_call(importer)((explore === null || explore === void 0 ? void 0 : explore.from) === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"))(typescript_1.default.factory.createIdentifier((explore === null || explore === void 0 ? void 0 : explore.postfix) ? "path + ".concat(explore.postfix) : "path"), expected, value);
},
full: equals
? undefined
: function (condition) { return function (input, expected, explore) {
return typescript_1.default.factory.createLogicalOr(condition, create_guard_call(importer)(explore.from === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"),
create_throw_function(typescript_1.default.factory.createIdentifier(path), expected, input),
: typescript_1.default.factory.createIdentifier("exceptionable"))(typescript_1.default.factory.createIdentifier("path"), expected, input));
}; },
}); };
};
var create_guard_call = function (importer) {
return function (exceptionable) {
return function (path, expected, value) {
return typescript_1.default.factory.createCallExpression(importer.use("guard"), undefined, [
exceptionable || typescript_1.default.factory.createIdentifier("exceptionable"),
typescript_1.default.factory.createObjectLiteralExpression([
typescript_1.default.factory.createPropertyAssignment("path", path),
typescript_1.default.factory.createPropertyAssignment("expected", typescript_1.default.factory.createStringLiteral(expected)),
typescript_1.default.factory.createPropertyAssignment("value", value),
], true),
]);
}; };
};
};
};
};
var assert_object = function (equals) { return function (importer) {
return (0, check_object_1.check_object)(equals)(true)(function (expr) {
return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createIdentifier("exceptionable")), expr);
})(function (expr) {
return typescript_1.default.factory.createCallExpression(importer.use("predicate"), undefined, [
expr,
typescript_1.default.factory.createIdentifier("exceptionable"),
create_throw_function(typescript_1.default.factory.createAdd(typescript_1.default.factory.createIdentifier("path"), typescript_1.default.factory.createCallExpression(importer.use("join"), undefined, [typescript_1.default.factory.createIdentifier("key")])), "undefined", typescript_1.default.factory.createIdentifier("value")),
]);
});
}; };
function create_throw_function(path, expected, value) {
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, typescript_1.default.factory.createObjectLiteralExpression([
typescript_1.default.factory.createPropertyAssignment("path", path),
typescript_1.default.factory.createPropertyAssignment("expected", typescript_1.default.factory.createStringLiteral(expected)),
typescript_1.default.factory.createPropertyAssignment("value", value),
], true));
}
})(AssertProgrammer = exports.AssertProgrammer || (exports.AssertProgrammer = {}));
//# sourceMappingURL=AssertProgrammer.js.map

@@ -14,2 +14,3 @@ import ts from "typescript";

unioners: string;
path: boolean;
trace: boolean;

@@ -19,3 +20,5 @@ equals: boolean;

combiner: IConfig.Combiner;
decoder?: FeatureProgrammer.Decoder<Metadata>;
joiner: IConfig.IJoiner;
success: ts.Expression;
}

@@ -26,3 +29,3 @@ namespace IConfig {

(logic: "and" | "or"): {
(input: ts.Expression, expressions: ts.Expression[], expected: string): ts.Expression;
(input: ts.Expression, binaries: IBinary[], expected: string): ts.Expression;
};

@@ -33,13 +36,20 @@ };

object(entries: IExpressionEntry[]): ts.Expression;
array(input: ts.Expression, arrow: ts.ArrowFunction, tags: IMetadataTag[]): ts.Expression;
tuple(binaries: ts.Expression[]): ts.Expression;
array(input: ts.Expression, arrow: ts.ArrowFunction): ts.Expression;
tuple?(exprs: ts.Expression[]): ts.Expression;
failure(value: ts.Expression, expected: string, explore?: FeatureProgrammer.IExplore): ts.Expression;
is?(expression: ts.Expression): ts.Expression;
required?(exp: ts.Expression): ts.Expression;
full?: (condition: ts.Expression) => (input: ts.Expression, expected: string, explore: IExplore) => ts.Expression;
}
}
export import IExplore = FeatureProgrammer.IExplore;
function generate(project: IProject, config: IConfig, modulo: ts.LeftHandSideExpression, importer: FunctionImporter, addition?: () => ts.Statement[]): (type: ts.Type) => ts.ArrowFunction;
const generate_functors: (project: IProject, config: IConfig, importer: FunctionImporter) => (collection: MetadataCollection) => ts.VariableDeclaration | null;
const generate_unioners: (project: IProject, config: IConfig, importer: FunctionImporter) => (collection: MetadataCollection) => ts.VariableDeclaration | null;
const DEFAULT_JOINER: (object: (entries: IExpressionEntry[]) => ts.Expression) => IConfig.IJoiner;
interface IBinary {
expression: ts.Expression;
combined: boolean;
}
function generate(project: IProject, config: IConfig, importer: FunctionImporter, addition?: () => ts.Statement[]): (type: ts.Type) => ts.ArrowFunction;
const generate_functors: (project: IProject, config: IConfig, importer: FunctionImporter) => (collection: MetadataCollection) => ts.VariableStatement[];
const generate_unioners: (project: IProject, config: IConfig, importer: FunctionImporter) => (collection: MetadataCollection) => ts.VariableStatement[];
function decode(project: IProject, config: IConfig, importer: FunctionImporter): (input: ts.Expression, meta: Metadata, explore: IExplore, tags: IMetadataTag[]) => ts.Expression;
function decode_object(config: IConfig): (input: ts.Expression, obj: MetadataObject, explore: IExplore) => ts.CallExpression;
}

@@ -13,2 +13,13 @@ "use strict";

};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {

@@ -39,13 +50,2 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -58,5 +58,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var ExpressionFactory_1 = require("../factories/ExpressionFactory");
var IdentifierFactory_1 = require("../factories/IdentifierFactory");
var MetadataCollection_1 = require("../factories/MetadataCollection");
var MetadataFactory_1 = require("../factories/MetadataFactory");
var ValueFactory_1 = require("../factories/ValueFactory");
var Metadata_1 = require("../metadata/Metadata");
var FeatureProgrammer_1 = require("./FeatureProgrammer");

@@ -66,2 +68,3 @@ var OptionPredicator_1 = require("./helpers/OptionPredicator");

var check_array_1 = require("./internal/check_array");
var check_native_1 = require("./internal/check_native");
var check_number_1 = require("./internal/check_number");

@@ -73,23 +76,16 @@ var check_string_1 = require("./internal/check_string");

(function (CheckerProgrammer) {
function generate(project, config, modulo, importer, addition) {
return FeatureProgrammer_1.FeatureProgrammer.generate(project, CONFIG(project, config, importer), function () {
return !importer.empty() || addition
? __spreadArray(__spreadArray([], __read(importer.declare(modulo)), false), __read((addition ? addition() : [])), false) : undefined;
});
function generate(project, config, importer, addition) {
return FeatureProgrammer_1.FeatureProgrammer.generate(project, CONFIG(project, config, importer), importer, function () { return (addition ? (addition ? addition() : []) : undefined); });
}
CheckerProgrammer.generate = generate;
CheckerProgrammer.generate_functors = function (project, config, importer) { return FeatureProgrammer_1.FeatureProgrammer.generate_functors(CONFIG(project, config, importer)); };
CheckerProgrammer.generate_functors = function (project, config, importer) {
return FeatureProgrammer_1.FeatureProgrammer.generate_functors(CONFIG(project, config, importer), importer);
};
CheckerProgrammer.generate_unioners = function (project, config, importer) {
return FeatureProgrammer_1.FeatureProgrammer.generate_unioners(CONFIG(project, __assign(__assign({}, config), { numeric: false }), importer));
};
CheckerProgrammer.DEFAULT_JOINER = function (object) { return ({
object: object,
array: check_array_1.check_array,
tuple: function (binaries) {
return binaries.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); });
},
}); };
function CONFIG(project, config, importer) {
var output = {
trace: config.trace,
path: config.path,
functors: config.functors,

@@ -106,5 +102,5 @@ unioners: config.unioners,

},
decoder: decode(project, config, importer),
decoder: config.decoder || decode(project, config, importer),
objector: {
checker: decode(project, config, importer),
checker: config.decoder || decode(project, config, importer),
decoder: decode_object(config),

@@ -115,13 +111,17 @@ joiner: config.joiner.object,

return decode_object(config)(input, obj, __assign(__assign({}, explore), { tracable: true }));
})(function () {
return typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createFalse());
})(config.joiner.is || (function (expr) { return expr; }))(function (value, expected) {
return typescript_1.default.factory.createReturnStatement(config.joiner.failure(value, expected));
})
: function (input, targets, explore) {
return config.combiner(explore)("or")(input, targets.map(function (obj) {
return decode_object(config)(input, obj, explore);
}), "(".concat(targets.map(function (t) { return t.name; }).join(" | "), ")"));
return config.combiner(explore)("or")(input, targets.map(function (obj) { return ({
expression: decode_object(config)(input, obj, explore),
combined: true,
}); }), "(".concat(targets.map(function (t) { return t.name; }).join(" | "), ")"));
},
failure: function () {
return typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createFalse());
failure: function (value, expected) {
return typescript_1.default.factory.createReturnStatement(config.joiner.failure(value, expected));
},
is: config.joiner.is,
required: config.joiner.required,
full: config.joiner.full,
},

@@ -135,7 +135,8 @@ };

}
function decode(project, config, importer) {
function decode(project, config, importer, checkTupleLength) {
if (checkTupleLength === void 0) { checkTupleLength = true; }
return function (input, meta, explore, tags) {
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
if (meta.any)
return ValueFactory_1.ValueFactory.BOOLEAN(true);
return config.success;
var top = [];

@@ -150,16 +151,22 @@ var binaries = [];

var checkOptional = meta.empty() || meta.isUnionBucket();
if (checkOptional || meta.nullable || meta.objects.length)
if (checkOptional ||
meta.nullable)
(meta.nullable ? add : create_add(top)(input))(meta.nullable, ValueFactory_1.ValueFactory.NULL());
if (checkOptional || !meta.required)
(meta.required ? create_add(top)(input) : add)(!meta.required, ValueFactory_1.ValueFactory.UNDEFINED());
if (meta.functional === true &&
(OptionPredicator_1.OptionPreditor.functional(project.options) ||
meta.size() !== 1))
add(true, typescript_1.default.factory.createStringLiteral("function"), ValueFactory_1.ValueFactory.TYPEOF(input));
if (meta.functional === true)
if (OptionPredicator_1.OptionPredicator.functional(project.options) ||
meta.size() !== 1)
add(true, typescript_1.default.factory.createStringLiteral("function"), ValueFactory_1.ValueFactory.TYPEOF(input));
else
binaries.push({
combined: false,
expression: config.success,
});
try {
for (var _e = __values(meta.constants), _f = _e.next(); !_f.done; _f = _e.next()) {
var constant = _f.value;
for (var _f = __values(meta.constants), _g = _f.next(); !_g.done; _g = _f.next()) {
var constant = _g.value;
try {
for (var _g = (e_2 = void 0, __values(constant.values)), _h = _g.next(); !_h.done; _h = _g.next()) {
var val = _h.value;
for (var _h = (e_2 = void 0, __values(constant.values)), _j = _h.next(); !_j.done; _j = _h.next()) {
var val = _j.value;
add(true, getConstantValue(val));

@@ -171,3 +178,3 @@ }

try {
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
}

@@ -181,3 +188,3 @@ finally { if (e_2) throw e_2.error; }

try {
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
}

@@ -187,8 +194,14 @@ finally { if (e_1) throw e_1.error; }

try {
for (var _j = __values(meta.atomics), _k = _j.next(); !_k.done; _k = _j.next()) {
var type = _k.value;
for (var _k = __values(meta.atomics), _l = _k.next(); !_l.done; _l = _k.next()) {
var type = _l.value;
if (type === "number")
binaries.push((0, check_number_1.check_number)(project, config.numeric)(input, tags));
binaries.push({
expression: (0, check_number_1.check_number)(project, config.numeric)(input, tags),
combined: false,
});
else if (type === "string")
binaries.push((0, check_string_1.check_string)(importer)(input, tags));
binaries.push({
expression: (0, check_string_1.check_string)(importer)(input, tags),
combined: false,
});
else

@@ -201,3 +214,3 @@ add(true, typescript_1.default.factory.createStringLiteral(type), ValueFactory_1.ValueFactory.TYPEOF(input));

try {
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
}

@@ -207,9 +220,12 @@ finally { if (e_3) throw e_3.error; }

if (meta.templates.length)
binaries.push((0, check_template_1.check_template)(importer)(input, meta.templates, tags));
binaries.push({
expression: (0, check_template_1.check_template)(importer)(input, meta.templates, tags),
combined: false,
});
if (meta.tuples.length > 0) {
var inner = [];
try {
for (var _l = __values(meta.tuples), _m = _l.next(); !_m.done; _m = _l.next()) {
var tuple = _m.value;
inner.push(decode_tuple(project, config, importer)(input, tuple, explore, tags));
for (var _m = __values(meta.tuples), _o = _m.next(); !_o.done; _o = _m.next()) {
var tuple = _o.value;
inner.push(decode_tuple(project, config, importer, checkTupleLength)(input, tuple, explore, tags));
}

@@ -220,28 +236,132 @@ }

try {
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
}
finally { if (e_4) throw e_4.error; }
}
binaries.push(typescript_1.default.factory.createLogicalAnd(ExpressionFactory_1.ExpressionFactory.isArray(input), inner.length === 1
? inner[0]
: inner.reduce(function (x, y) {
return typescript_1.default.factory.createLogicalOr(x, y);
})));
binaries.push({
expression: config.combiner(explore)("and")(input, __spreadArray(__spreadArray([], __read((checkTupleLength
? [
{
expression: ExpressionFactory_1.ExpressionFactory.isArray(input),
combined: false,
},
]
: [])), false), __read(inner.map(function (expression) { return ({
expression: expression,
combined: true,
}); })), false), meta.getName()),
combined: true,
});
}
if (meta.arrays.length > 0)
binaries.push(typescript_1.default.factory.createLogicalAnd(ExpressionFactory_1.ExpressionFactory.isArray(input), explore_array(project, config, importer)(input, meta.arrays, __assign(__assign({}, explore), { from: "array" }), tags)));
if (meta.arrays.every(function (elem) { return elem.any; }))
binaries.push({
expression: (0, check_array_1.check_array)(input, tags),
combined: false,
});
else
binaries.push({
expression: config.combiner(explore)("and")(input, __spreadArray(__spreadArray([], __read((checkTupleLength
? [
{
expression: (0, check_array_1.check_array)(input, tags),
combined: false,
},
]
: [])), false), [
{
expression: explore_array(project, config, importer)(input, meta.arrays, __assign(__assign({}, explore), { from: "array" }), tags),
combined: true,
},
], false), meta.getName()),
combined: true,
});
if (meta.objects.length > 0)
binaries.push(typescript_1.default.factory.createLogicalAnd(ExpressionFactory_1.ExpressionFactory.isObject(input, true), explore_objects(config)(input, meta, __assign(__assign({}, explore), { from: "object" }))));
return top.length !== 0
binaries.push({
expression: config.combiner(explore)("and")(input, [
{
expression: ExpressionFactory_1.ExpressionFactory.isObject(input, true),
combined: false,
},
{
expression: explore_objects(config)(input, meta, __assign(__assign({}, explore), { from: "object" })),
combined: true,
},
], meta.getName()),
combined: true,
});
try {
for (var _p = __values(meta.natives), _q = _p.next(); !_q.done; _q = _p.next()) {
var native = _q.value;
binaries.push({
expression: (0, check_native_1.check_native)(native)(input),
combined: false,
});
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
}
finally { if (e_5) throw e_5.error; }
}
if (meta.sets.length)
if (meta.sets.every(function (elem) { return elem.any; }))
binaries.push({
combined: false,
expression: (0, check_native_1.check_native)("Set")(input),
});
else
binaries.push({
combined: true,
expression: config.combiner(explore)("and")(input, [
{
combined: false,
expression: (0, check_native_1.check_native)("Set")(input),
},
{
combined: true,
expression: explore_set(project, config, importer)(input, meta.sets, __assign(__assign({}, explore), { from: "array" }), []),
},
], meta.getName()),
});
if (meta.maps.length)
if (meta.maps.every(function (elem) { return elem.key.any && elem.value.any; }))
binaries.push({
expression: (0, check_native_1.check_native)("Map")(input),
combined: false,
});
else
binaries.push({
combined: true,
expression: config.combiner(explore)("and")(input, [
{
combined: false,
expression: (0, check_native_1.check_native)("Map")(input),
},
{
combined: true,
expression: explore_map(project, config, importer)(input, meta.maps.map(function (m) { return [m.key, m.value]; }), __assign(__assign({}, explore), { from: "array" }), []),
},
], meta.getName()),
});
return top.length && binaries.length
? config.combiner(explore)("and")(input, __spreadArray(__spreadArray([], __read(top), false), [
config.combiner(explore)("or")(input, binaries, meta.getName()),
{
expression: config.combiner(explore)("or")(input, binaries, meta.getName()),
combined: true,
},
], false), meta.getName())
: config.combiner(explore)("or")(input, binaries, meta.getName());
: binaries.length
? config.combiner(explore)("or")(input, binaries, meta.getName())
: config.success;
};
}
CheckerProgrammer.decode = decode;
function decode_tuple(project, config, importer) {
function decode_tuple(project, config, importer, checkLength) {
return function (input, tuple, explore, tagList) {
var length = typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createPropertyAccessExpression(input, "length"), typescript_1.default.factory.createNumericLiteral(tuple.length));
var binaries = tuple.map(function (meta, index) {
var binaries = tuple
.filter(function (meta) { return meta.rest === null; })
.map(function (meta, index) {
return decode(project, config, importer)(typescript_1.default.factory.createElementAccessExpression(input, index), meta, __assign(__assign({}, explore), { from: "array", postfix: explore.postfix.length

@@ -251,12 +371,43 @@ ? "".concat(explore.postfix.slice(0, -1), "[").concat(index, "]\"")

});
if (binaries.length === 0)
return length;
else
return typescript_1.default.factory.createLogicalAnd(length, config.joiner.tuple(binaries));
var rest = tuple.length && tuple[tuple.length - 1].rest !== null
? decode(project, config, importer, false)(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "slice"), undefined, [
typescript_1.default.factory.createNumericLiteral(tuple.length - 1),
]), (function () {
var wrapper = Metadata_1.Metadata.initialize();
wrapper.arrays.push(tuple[tuple.length - 1].rest);
return wrapper;
})(), __assign(__assign({}, explore), { start: tuple.length - 1 }), tagList)
: null;
return config.combiner(explore)("and")(input, __spreadArray(__spreadArray(__spreadArray([], __read((checkLength && rest === null
? [
{
combined: false,
expression: typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createPropertyAccessExpression(input, "length"), typescript_1.default.factory.createNumericLiteral(tuple.length)),
},
]
: [])), false), __read((config.joiner.tuple
? [
{
expression: config.joiner.tuple(binaries),
combined: true,
},
]
: binaries.map(function (expression) { return ({
expression: expression,
combined: true,
}); }))), false), __read((rest !== null
? [
{
expression: rest,
combined: true,
},
]
: [])), false), "[".concat(tuple.map(function (t) { return t.getName(); }).join(", "), "]"));
};
}
function decode_array(project, config, importer) {
function decode_array(project, config, importer, checkTupleLength) {
return FeatureProgrammer_1.FeatureProgrammer.decode_array({
trace: config.trace,
decoder: decode(project, config, importer),
path: config.path,
decoder: decode(project, config, importer, checkTupleLength),
}, importer, config.joiner.array);

@@ -273,4 +424,55 @@ }

var explore_array = function (project, config, importer) {
return UnionExplorer_1.UnionExplorer.array(decode(project, config, importer), decode_array(project, config, importer), function () { return typescript_1.default.factory.createTrue(); }, function () { return typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createFalse()); });
return UnionExplorer_1.UnionExplorer.array({
checker: decode(project, config, importer),
decoder: decode_array(project, config, importer, true),
empty: config.success,
success: config.success,
failure: function (input, expected, explore) {
return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
},
});
};
var explore_set = function (project, config, importer) {
return UnionExplorer_1.UnionExplorer.set({
checker: decode(project, config, importer),
decoder: decode_array(project, config, importer, true),
empty: config.success,
success: config.success,
failure: function (input, expected, explore) {
return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
},
});
};
var explore_map = function (project, config, importer) {
return UnionExplorer_1.UnionExplorer.map({
checker: function (input, entry, explore) {
var func = decode(project, config, importer);
return typescript_1.default.factory.createLogicalAnd(func(typescript_1.default.factory.createElementAccessExpression(input, 0), entry[0], __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[0]") }), []), func(typescript_1.default.factory.createElementAccessExpression(input, 1), entry[1], __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[1]") }), []));
},
decoder: function (input, target, explore) {
return decode_array(project, config, importer, false)(input, Metadata_1.Metadata.create({
any: false,
nullable: false,
required: true,
functional: false,
resolved: null,
constants: [],
atomics: [],
templates: [],
rest: null,
arrays: [],
tuples: [target],
objects: [],
natives: [],
sets: [],
maps: [],
}), explore, []);
},
empty: config.success,
success: config.success,
failure: function (input, expected, explore) {
return typescript_1.default.factory.createReturnStatement(config.joiner.failure(input, expected, explore));
},
});
};
var explore_objects = function (config) {

@@ -281,3 +483,3 @@ var objector = decode_object(config);

return objector(input, meta.objects[0], explore);
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("".concat(config.unioners, "[").concat(meta.union_index, "]")), undefined, FeatureProgrammer_1.FeatureProgrammer.get_object_arguments(config.trace, explore)(input));
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("".concat(config.unioners).concat(meta.union_index)), undefined, FeatureProgrammer_1.FeatureProgrammer.get_object_arguments(config)(explore)(input));
};

@@ -293,3 +495,6 @@ };

: typescript_1.default.factory.createStrictInequality;
binaries.push(factory(left, right));
binaries.push({
expression: factory(left, right),
combined: false,
});
};

@@ -296,0 +501,0 @@ };

@@ -13,2 +13,3 @@ import ts from "typescript";

unioners: string;
path: boolean;
trace: boolean;

@@ -26,7 +27,10 @@ initializer: Initializer;

unionizer: Decoder<MetadataObject[]>;
failure: (expression: ts.Expression, targets: MetadataObject[]) => ts.Statement;
failure: (value: ts.Expression, expected: string, explore?: IExplore) => ts.Statement;
is?: (exp: ts.Expression) => ts.Expression;
required?: (exp: ts.Expression) => ts.Expression;
full?: (condition: ts.Expression) => (input: ts.Expression, expected: string, explore: IExplore) => ts.Expression;
}
interface IGenerator {
functors(col: MetadataCollection): ts.VariableDeclaration | null;
unioners(col: MetadataCollection): ts.VariableDeclaration | null;
functors(col: MetadataCollection): ts.VariableStatement[];
unioners(col: MetadataCollection): ts.VariableStatement[];
}

@@ -39,2 +43,3 @@ }

postfix: string;
start?: number;
}

@@ -50,8 +55,8 @@ interface Initializer {

}
const generate: (project: IProject, config: IConfig, addition: (collection: MetadataCollection) => ts.Statement[] | undefined) => (type: ts.Type) => ts.ArrowFunction;
function generate_functors(config: IConfig): (collection: MetadataCollection) => ts.VariableDeclaration | null;
function generate_unioners(config: IConfig): (collection: MetadataCollection) => ts.VariableDeclaration | null;
function decode_array(config: Pick<IConfig, "trace" | "decoder">, importer: FunctionImporter, combiner: (input: ts.Expression, arrow: ts.ArrowFunction, tags: IMetadataTag[]) => ts.Expression): (input: ts.Expression, meta: Metadata, explore: IExplore, tags: IMetadataTag[]) => ts.Expression;
const decode_object: (config: Pick<IConfig, "trace" | "functors">) => (input: ts.Expression, obj: MetadataObject, explore: IExplore) => ts.CallExpression;
const get_object_arguments: (trace: boolean, explore: FeatureProgrammer.IExplore) => (input: ts.Expression) => ts.Expression[];
const generate: (project: IProject, config: IConfig, importer: FunctionImporter, addition: (collection: MetadataCollection) => ts.Statement[] | undefined) => (type: ts.Type) => ts.ArrowFunction;
const generate_functors: (config: IConfig, importer: FunctionImporter) => (collection: MetadataCollection) => ts.VariableStatement[];
const generate_unioners: (config: IConfig) => (collection: MetadataCollection) => ts.VariableStatement[];
function decode_array(config: Pick<IConfig, "trace" | "path" | "decoder">, importer: FunctionImporter, combiner: (input: ts.Expression, arrow: ts.ArrowFunction, tags: IMetadataTag[]) => ts.Expression): (input: ts.Expression, meta: Metadata, explore: IExplore, tags: IMetadataTag[]) => ts.Expression;
const decode_object: (config: Pick<IConfig, "trace" | "path" | "functors">) => (input: ts.Expression, obj: MetadataObject, explore: IExplore) => ts.CallExpression;
const get_object_arguments: (config: Pick<IConfig, "path" | "trace">) => (explore: FeatureProgrammer.IExplore) => (input: ts.Expression) => ts.Expression[];
}

@@ -27,13 +27,2 @@ "use strict";

};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -46,8 +35,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var IdentifierFactory_1 = require("../factories/IdentifierFactory");
var StatementFactory_1 = require("../factories/StatementFactory");
var ValueFactory_1 = require("../factories/ValueFactory");
var Escaper_1 = require("../utils/Escaper");
var UnionExplorer_1 = require("./helpers/UnionExplorer");
var feature_object_entries_1 = require("./internal/feature_object_entries");
var FeatureProgrammer;
(function (FeatureProgrammer) {
FeatureProgrammer.generate = function (project, config, addition) {
FeatureProgrammer.generate = function (project, config, importer, addition) {
return function (type) {

@@ -57,3 +47,3 @@ var _a, _b;

var output = config.decoder(ValueFactory_1.ValueFactory.INPUT(), meta, {
tracable: config.trace,
tracable: config.path || config.trace,
source: "top",

@@ -65,16 +55,8 @@ from: "top",

? config.generator.functors(collection)
: generate_functors(config)(collection);
: FeatureProgrammer.generate_functors(config, importer)(collection);
var unioners = ((_b = config.generator) === null || _b === void 0 ? void 0 : _b.unioners) !== undefined
? config.generator.unioners(collection)
: generate_unioners(config)(collection);
: FeatureProgrammer.generate_unioners(config)(collection);
var added = addition(collection);
return typescript_1.default.factory.createArrowFunction(undefined, undefined, PARAMETERS(config.trace ? true : null)(ValueFactory_1.ValueFactory.INPUT()), undefined, undefined, typescript_1.default.factory.createBlock(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((added || [])), false), __read((functors !== null
? [
typescript_1.default.factory.createVariableStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([functors], typescript_1.default.NodeFlags.Const)),
]
: [])), false), __read((unioners !== null
? [
typescript_1.default.factory.createVariableStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([unioners], typescript_1.default.NodeFlags.Const)),
]
: [])), false), [
return typescript_1.default.factory.createArrowFunction(undefined, undefined, PARAMETERS(config)(ValueFactory_1.ValueFactory.INPUT()), undefined, undefined, typescript_1.default.factory.createBlock(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((added || [])), false), __read(functors), false), __read(unioners), false), [
typescript_1.default.factory.createReturnStatement(output),

@@ -84,64 +66,31 @@ ], false), true));

};
function generate_functors(config) {
FeatureProgrammer.generate_functors = function (config, importer) {
return function (collection) {
var objects = collection.objects();
if (objects.length === 0)
return null;
return typescript_1.default.factory.createVariableDeclaration(config.functors, undefined, undefined, typescript_1.default.factory.createArrayLiteralExpression(objects.map(function (obj) { return generate_object(config)(obj); }), true));
return collection
.objects()
.map(function (obj, i) {
return StatementFactory_1.StatementFactory.constant("".concat(config.functors).concat(i), generate_object(config, importer)(obj));
});
};
}
FeatureProgrammer.generate_functors = generate_functors;
function generate_unioners(config) {
return function (collection) {
var unions = collection.unions();
if (unions.length === 0)
return null;
return typescript_1.default.factory.createVariableDeclaration(config.unioners, undefined, undefined, typescript_1.default.factory.createArrayLiteralExpression(unions.map(function (meta) { return generate_union(config)(meta); }), true));
};
}
FeatureProgrammer.generate_unioners = generate_unioners;
function generate_object(config) {
};
FeatureProgrammer.generate_unioners = function (config) { return function (collection) {
return collection
.unions()
.map(function (union, i) {
return StatementFactory_1.StatementFactory.constant("".concat(config.unioners).concat(i), generate_union(config)(union));
});
}; };
function generate_object(config, importer) {
if (config.path === true)
importer.use("join");
return function (obj) {
var e_1, _a;
var entries = [];
try {
for (var _b = __values(obj.properties), _c = _b.next(); !_c.done; _c = _b.next()) {
var prop = _c.value;
var key = prop.key.getSoleLiteral();
var input = key === null
? typescript_1.default.factory.createIdentifier("value")
: Escaper_1.Escaper.variable(key)
? typescript_1.default.factory.createPropertyAccessExpression(ValueFactory_1.ValueFactory.INPUT(), typescript_1.default.factory.createIdentifier(key))
: typescript_1.default.factory.createElementAccessExpression(ValueFactory_1.ValueFactory.INPUT(), typescript_1.default.factory.createStringLiteral(key));
entries.push({
input: input,
key: prop.key,
meta: prop.value,
expression: config.decoder(input, prop.value, {
tracable: config.trace,
source: "object",
from: "object",
postfix: key !== null
? IdentifierFactory_1.IdentifierFactory.postfix(key)
: "$join(key)",
}, prop.tags),
});
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
return typescript_1.default.factory.createArrowFunction(undefined, undefined, PARAMETERS(config.trace ? false : null)(ValueFactory_1.ValueFactory.INPUT()), undefined, undefined, config.objector.joiner(entries, obj));
return typescript_1.default.factory.createArrowFunction(undefined, undefined, PARAMETERS(config)(ValueFactory_1.ValueFactory.INPUT()), undefined, undefined, config.objector.joiner((0, feature_object_entries_1.feature_object_entries)(config)(obj)(typescript_1.default.factory.createIdentifier("input")), obj));
};
}
function generate_union(config) {
var explorer = UnionExplorer_1.UnionExplorer.object(config, config.objector.checker, config.objector.decoder, config.objector.unionizer, config.objector.failure);
var explorer = UnionExplorer_1.UnionExplorer.object(config);
var input = ValueFactory_1.ValueFactory.INPUT();
return function (meta) {
return typescript_1.default.factory.createArrowFunction(undefined, undefined, PARAMETERS(config.trace ? false : null)(ValueFactory_1.ValueFactory.INPUT()), undefined, undefined, explorer(input, meta, {
tracable: config.trace,
return typescript_1.default.factory.createArrowFunction(undefined, undefined, PARAMETERS(config)(ValueFactory_1.ValueFactory.INPUT()), undefined, undefined, explorer(input, meta, {
tracable: config.path || config.trace,
source: "object",

@@ -155,15 +104,12 @@ from: "object",

var rand = importer.increment().toString();
var tail = config.trace
? [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, ValueFactory_1.ValueFactory.INPUT("index" + rand)),
]
var tail = config.path || config.trace
? [IdentifierFactory_1.IdentifierFactory.parameter("index" + rand)]
: [];
return function (input, meta, explore, tags) {
var arrow = typescript_1.default.factory.createArrowFunction(undefined, undefined, __spreadArray([
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, ValueFactory_1.ValueFactory.INPUT("elem"))
], __read(tail), false), undefined, undefined, config.decoder(ValueFactory_1.ValueFactory.INPUT("elem"), meta, {
var _a;
var arrow = typescript_1.default.factory.createArrowFunction(undefined, undefined, __spreadArray([IdentifierFactory_1.IdentifierFactory.parameter("elem")], __read(tail), false), undefined, undefined, config.decoder(ValueFactory_1.ValueFactory.INPUT("elem"), meta, {
tracable: explore.tracable,
source: explore.source,
from: "array",
postfix: INDEX_SYMBOL(explore.postfix)(rand),
postfix: INDEX_SYMBOL((_a = explore.start) !== null && _a !== void 0 ? _a : null)(explore.postfix)(rand),
}, tags));

@@ -176,23 +122,41 @@ return combiner(input, arrow, tags);

return function (input, obj, explore) {
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createElementAccessExpression(typescript_1.default.factory.createIdentifier(config.functors), obj.index), undefined, FeatureProgrammer.get_object_arguments(config.trace, explore)(input));
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("".concat(config.functors).concat(obj.index)), undefined, FeatureProgrammer.get_object_arguments(config)(explore)(input));
};
};
FeatureProgrammer.get_object_arguments = function (trace, explore) {
var tail = trace === false
? []
: [
typescript_1.default.factory.createIdentifier(explore.postfix
? "path + ".concat(explore.postfix)
: "path"),
explore.source === "object"
? typescript_1.default.factory.createIdentifier("".concat(explore.tracable, " && exceptionable"))
: explore.tracable
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createFalse(),
];
return function (input) { return __spreadArray([input], __read(tail), false); };
FeatureProgrammer.get_object_arguments = function (config) {
return function (explore) {
var tail = config.path === false && config.trace === false
? []
: config.path === true && config.trace === true
? [
typescript_1.default.factory.createIdentifier(explore.postfix
? "path + ".concat(explore.postfix)
: "path"),
explore.source === "object"
? typescript_1.default.factory.createIdentifier("".concat(explore.tracable, " && exceptionable"))
: explore.tracable
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createFalse(),
]
: config.path === true
? [
typescript_1.default.factory.createIdentifier(explore.postfix
? "path + ".concat(explore.postfix)
: "path"),
]
: [
explore.source === "object"
? typescript_1.default.factory.createIdentifier("".concat(explore.tracable, " && exceptionable"))
: explore.tracable
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createFalse(),
];
return function (input) { return __spreadArray([input], __read(tail), false); };
};
};
})(FeatureProgrammer = exports.FeatureProgrammer || (exports.FeatureProgrammer = {}));
var INDEX_SYMBOL = function (prev) { return function (rand) {
var tail = "\"[\" + index".concat(rand, " + \"]\"");
var INDEX_SYMBOL = function (start) { return function (prev) { return function (rand) {
var tail = start !== null
? "\"[\" + (".concat(start, " + index").concat(rand, ") + \"]\"")
: "\"[\" + index".concat(rand, " + \"]\"");
if (prev === "")

@@ -203,17 +167,13 @@ return tail;

return prev + " + ".concat(tail);
}; };
var PARAMETERS = function (initialize) {
var tail = initialize === null
? []
: [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, "path", undefined, undefined, initialize
? typescript_1.default.factory.createStringLiteral("$input")
: undefined),
];
if (initialize === false)
tail.push(typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, "exceptionable"));
}; }; };
var PARAMETERS = function (props) {
var tail = [];
if (props.path)
tail.push(IdentifierFactory_1.IdentifierFactory.parameter("path"));
if (props.trace)
tail.push(IdentifierFactory_1.IdentifierFactory.parameter("exceptionable"));
return function (input) { return __spreadArray([
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, input)
IdentifierFactory_1.IdentifierFactory.parameter(input)
], __read(tail), false); };
};
//# sourceMappingURL=FeatureProgrammer.js.map

@@ -49,3 +49,3 @@ "use strict";

return __spreadArray([], __read(this.used_), false).map(function (name) {
return StatementFactory_1.StatementFactory.variable(typescript_1.default.NodeFlags.Const, "$" + name, IdentifierFactory_1.IdentifierFactory.join(modulo, name));
return StatementFactory_1.StatementFactory.constant("$" + name, IdentifierFactory_1.IdentifierFactory.join(modulo, name));
});

@@ -52,0 +52,0 @@ };

import { ITransformOptions } from "../../transformers/ITransformOptions";
export declare namespace OptionPreditor {
export declare namespace OptionPredicator {
function functional(options: ITransformOptions): boolean;
function numeric(options: ITransformOptions, from: "checker" | "stringify"): boolean;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptionPreditor = void 0;
var OptionPreditor;
(function (OptionPreditor) {
exports.OptionPredicator = void 0;
var OptionPredicator;
(function (OptionPredicator) {
function functional(options) {
return options.functional === undefined || options.functional === true;
return options.functional !== false;
}
OptionPreditor.functional = functional;
OptionPredicator.functional = functional;
function numeric(options, from) {

@@ -15,4 +15,4 @@ return (options.numeric === undefined ||

}
OptionPreditor.numeric = numeric;
})(OptionPreditor = exports.OptionPreditor || (exports.OptionPreditor = {}));
OptionPredicator.numeric = numeric;
})(OptionPredicator = exports.OptionPredicator || (exports.OptionPredicator = {}));
//# sourceMappingURL=OptionPredicator.js.map

@@ -5,5 +5,5 @@ import ts from "typescript";

export declare namespace StringifyJoiner {
const object: (importer: FunctionImporter) => (entries: IExpressionEntry[]) => ts.ConciseBody;
const object: (importer: FunctionImporter) => (entries: IExpressionEntry[]) => ts.Expression;
function array(input: ts.Expression, arrow: ts.ArrowFunction): ts.Expression;
function tuple(children: ts.Expression[]): ts.Expression;
function tuple(children: ts.Expression[], rest: ts.Expression | null): ts.Expression;
}

@@ -75,6 +75,7 @@ "use strict";

StringifyJoiner.array = array;
function tuple(children) {
function tuple(children, rest) {
if (children.length === 0)
return typescript_1.default.factory.createStringLiteral("[]");
if (children.every(function (child) { return typescript_1.default.isStringLiteral(child); }))
if (rest === null &&
children.every(function (child) { return typescript_1.default.isStringLiteral(child); }))
return typescript_1.default.factory.createStringLiteral("[" +

@@ -91,2 +92,4 @@ children

});
if (rest !== null)
elements.push(rest);
elements.push(typescript_1.default.factory.createStringLiteral("]"));

@@ -93,0 +96,0 @@ return TemplateFactory_1.TemplateFactory.generate(elements);

@@ -5,10 +5,39 @@ import ts from "typescript";

import { MetadataObject } from "../../metadata/MetadataObject";
import { CheckerProgrammer } from "../CheckerProgrammer";
import { FeatureProgrammer } from "../FeatureProgrammer";
export declare namespace UnionExplorer {
interface Decoder<T> {
export interface Decoder<T> {
(input: ts.Expression, target: T, explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]): ts.Expression;
}
type ObjectCombiner = Decoder<MetadataObject[]>;
function object(config: FeatureProgrammer.IConfig, checker: (input: ts.Expression, metadata: Metadata, explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression, decoder: Decoder<MetadataObject>, combiner: ObjectCombiner, failure: (input: ts.Expression, targets: MetadataObject[]) => ts.Statement, level?: number): (input: ts.Expression, targets: MetadataObject[], explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression;
function array(checker: (input: ts.Expression, metadata: Metadata, explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression, decoder: Decoder<Metadata>, empty: () => ts.Expression, failure: (input: ts.Expression, targets: Metadata[]) => ts.Statement): (input: ts.Expression, targets: Metadata[], explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression;
export type ObjectCombiner = Decoder<MetadataObject[]>;
export function object(config: FeatureProgrammer.IConfig, level?: number): (input: ts.Expression, targets: MetadataObject[], explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression;
export const array: (props: array.IProps) => (input: ts.Expression, targets: Metadata[], explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression;
export namespace array {
type IProps = iterate.IProps<Metadata>;
}
export const set: (props: set.IProps) => (input: ts.Expression, targets: Metadata[], explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression;
export namespace set {
type IProps = iterate.IProps<Metadata>;
}
export const map: (props: map.IProps) => (input: ts.Expression, targets: [Metadata, Metadata][], explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression;
export namespace map {
type IProps = iterate.IProps<[Metadata, Metadata]>;
}
const iterate: <T>(accessor: iterate.IAccessor<T>) => (props: iterate.IProps<T>) => (input: ts.Expression, targets: T[], explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]) => ts.Expression;
namespace iterate {
interface IProps<T> {
checker(input: ts.Expression, target: T, explore: FeatureProgrammer.IExplore, tags: IMetadataTag[]): ts.Expression;
decoder: Decoder<T>;
empty: ts.Expression;
success: ts.Expression;
failure(input: ts.Expression, expected: string, explore: CheckerProgrammer.IExplore): ts.Statement;
}
interface IAccessor<T> {
name(metadata: T): string;
size(input: ts.Expression): ts.Expression;
front(input: ts.Expression): ts.Expression;
array(input: ts.Expression): ts.Expression;
}
}
export {};
}

@@ -50,10 +50,17 @@ "use strict";

(function (UnionExplorer) {
function object(config, checker, decoder, combiner, failure, level) {
function object(config, level) {
if (level === void 0) { level = 0; }
return function (input, targets, explore, tags) {
if (targets.length === 1)
return decoder(input, targets[0], explore, tags);
return config.objector.decoder(input, targets[0], explore, tags);
var expected = "(".concat(targets
.map(function (t) { return t.name; })
.join(" | "), ")");
var specList = UnionPredicator_1.UnionPredicator.object(targets);
if (specList.length === 0)
return combiner(input, targets, __assign(__assign({}, explore), { tracable: false }), tags);
if (specList.length === 0) {
var condition = config.objector.unionizer(input, targets, __assign(__assign({}, explore), { tracable: false }), tags);
return config.objector.full
? config.objector.full(condition)(input, expected, explore)
: condition;
}
var remained = targets.filter(function (t) { return specList.find(function (s) { return s.object === t; }) === undefined; });

@@ -66,10 +73,10 @@ var conditions = specList

var pred = spec.neighbour
? checker(accessor, spec.property.value, __assign(__assign({}, explore), { tracable: false, postfix: IdentifierFactory_1.IdentifierFactory.postfix(key) }), tags)
: ExpressionFactory_1.ExpressionFactory.isRequired(accessor);
return typescript_1.default.factory.createIfStatement(pred, typescript_1.default.factory.createReturnStatement(decoder(input, spec.object, explore, tags)));
? config.objector.checker(accessor, spec.property.value, __assign(__assign({}, explore), { tracable: false, postfix: IdentifierFactory_1.IdentifierFactory.postfix(key) }), tags)
: (config.objector.required || (function (exp) { return exp; }))(ExpressionFactory_1.ExpressionFactory.isRequired(accessor));
return typescript_1.default.factory.createIfStatement((config.objector.is || (function (exp) { return exp; }))(pred), typescript_1.default.factory.createReturnStatement(config.objector.decoder(input, spec.object, explore, tags)));
});
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, typescript_1.default.factory.createBlock(__spreadArray(__spreadArray([], __read(conditions), false), [
remained.length
? typescript_1.default.factory.createReturnStatement(object(config, checker, decoder, combiner, failure, level + 1)(input, remained, explore, tags))
: failure(input, targets),
? typescript_1.default.factory.createReturnStatement(object(config, level + 1)(input, remained, explore, tags))
: config.objector.failure(input, expected, explore),
], false), true)), undefined, undefined);

@@ -79,42 +86,73 @@ };

UnionExplorer.object = object;
function array(checker, decoder, empty, failure) {
return function (input, targets, explore, tags) {
if (targets.length === 1)
return decoder(input, targets[0], explore, tags);
var top = typescript_1.default.factory.createElementAccessExpression(input, 0);
var tupleListVariable = StatementFactory_1.StatementFactory.variable(typescript_1.default.NodeFlags.Const, "tupleList", typescript_1.default.factory.createArrayLiteralExpression(targets.map(function (meta) {
return typescript_1.default.factory.createArrayLiteralExpression([
typescript_1.default.factory.createArrowFunction(undefined, undefined, [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, "branch"),
], undefined, undefined, checker(typescript_1.default.factory.createIdentifier("branch"), meta, __assign(__assign({}, explore), { tracable: false, postfix: "\"[0]\"" }), tags)),
typescript_1.default.factory.createArrowFunction(undefined, undefined, [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, "branch"),
], undefined, undefined, decoder(typescript_1.default.factory.createIdentifier("branch"), meta, __assign(__assign({}, explore), { tracable: true }), tags)),
]);
})));
var filteredVariable = StatementFactory_1.StatementFactory.variable(typescript_1.default.NodeFlags.Const, "filtered", typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tupleList.filter"), undefined, [
typescript_1.default.factory.createArrowFunction(undefined, undefined, [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, "tuple"),
], undefined, undefined, typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createTrue(), typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tuple[0]"), undefined, [top]))),
]));
var uniqueStatement = typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createNumericLiteral(1), typescript_1.default.factory.createIdentifier("filtered.length")), typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("filtered[0][1]"), undefined, [input])));
var forOfStatement = typescript_1.default.factory.createForOfStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([typescript_1.default.factory.createVariableDeclaration("tuple")], typescript_1.default.NodeFlags.Const), typescript_1.default.factory.createIdentifier("filtered"), typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "every"), undefined, [
typescript_1.default.factory.createArrowFunction(undefined, undefined, [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, "value"),
], undefined, undefined, typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tuple[0]"), undefined, [typescript_1.default.factory.createIdentifier("value")])),
]), typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tuple[1]"), undefined, [input]))));
var unionStatement = typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createLessThan(typescript_1.default.factory.createNumericLiteral(1), typescript_1.default.factory.createIdentifier("filtered.length")), forOfStatement);
var block = [
typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createNumericLiteral(0), IdentifierFactory_1.IdentifierFactory.join(input, "length")), typescript_1.default.factory.createReturnStatement(empty())),
tupleListVariable,
filteredVariable,
uniqueStatement,
unionStatement,
failure(input, targets),
];
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, typescript_1.default.factory.createBlock(block, true)), undefined, undefined);
UnionExplorer.array = function (props) {
return iterate({
size: function (input) { return IdentifierFactory_1.IdentifierFactory.join(input, "length"); },
front: function (input) {
return typescript_1.default.factory.createElementAccessExpression(input, 0);
},
array: function (input) { return input; },
name: function (t) { return "Array<".concat(t.getName(), ">"); },
})(props);
};
UnionExplorer.set = function (props) {
return iterate({
size: function (input) { return IdentifierFactory_1.IdentifierFactory.join(input, "size"); },
front: function (input) {
return IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "values"), undefined, undefined), "next"), undefined, undefined), "value");
},
array: function (input) {
return typescript_1.default.factory.createArrayLiteralExpression([typescript_1.default.factory.createSpreadElement(input)], false);
},
name: function (t) { return "Set<".concat(t.getName(), ">"); },
})(props);
};
UnionExplorer.map = function (props) {
return iterate({
size: function (input) { return IdentifierFactory_1.IdentifierFactory.join(input, "size"); },
front: function (input) {
return IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "entries"), undefined, undefined), "next"), undefined, undefined), "value");
},
array: function (input) {
return typescript_1.default.factory.createArrayLiteralExpression([typescript_1.default.factory.createSpreadElement(input)], false);
},
name: function (_a) {
var _b = __read(_a, 2), k = _b[0], v = _b[1];
return "Map<".concat(k.getName(), ", ").concat(v.getName(), ">");
},
})(props);
};
var iterate = function (accessor) {
return function (props) {
return function (input, targets, explore, tags) {
if (targets.length === 1)
return props.decoder(accessor.array(input), targets[0], explore, tags);
var tupleListVariable = StatementFactory_1.StatementFactory.constant("tupleList", typescript_1.default.factory.createArrayLiteralExpression(targets.map(function (meta) {
return typescript_1.default.factory.createArrayLiteralExpression([
typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("branch")], undefined, undefined, props.checker(typescript_1.default.factory.createIdentifier("branch"), meta, __assign(__assign({}, explore), { tracable: false, postfix: "\"[0]\"" }), tags)),
typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("branch")], undefined, undefined, props.decoder(typescript_1.default.factory.createIdentifier("branch"), meta, __assign(__assign({}, explore), { tracable: true }), tags)),
]);
})));
var filteredVariable = StatementFactory_1.StatementFactory.constant("filtered", typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tupleList.filter"), undefined, [
typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("tuple")], undefined, undefined, typescript_1.default.factory.createStrictEquality(props.success, typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tuple[0]"), undefined, [typescript_1.default.factory.createIdentifier("front")]))),
]));
var uniqueStatement = typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createNumericLiteral(1), typescript_1.default.factory.createIdentifier("filtered.length")), typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("filtered[0][1]"), undefined, [accessor.array(input)])));
var forOfStatement = typescript_1.default.factory.createForOfStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([typescript_1.default.factory.createVariableDeclaration("tuple")], typescript_1.default.NodeFlags.Const), typescript_1.default.factory.createIdentifier("filtered"), typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createIdentifier("array"), "every"), undefined, [
typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("value")], undefined, undefined, typescript_1.default.factory.createStrictEquality(props.success, typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tuple[0]"), undefined, [typescript_1.default.factory.createIdentifier("value")]))),
]), typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("tuple[1]"), undefined, [typescript_1.default.factory.createIdentifier("array")]))));
var unionStatement = typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createLessThan(typescript_1.default.factory.createNumericLiteral(1), typescript_1.default.factory.createIdentifier("filtered.length")), forOfStatement);
var block = [
typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createNumericLiteral(0), accessor.size(input)), typescript_1.default.factory.createReturnStatement(props.empty)),
tupleListVariable,
StatementFactory_1.StatementFactory.constant("front", accessor.front(input)),
filteredVariable,
uniqueStatement,
StatementFactory_1.StatementFactory.constant("array", accessor.array(input)),
unionStatement,
props.failure(input, "(".concat(targets.map(function (t) { return accessor.name(t); }).join(" | "), ")"), explore),
];
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, typescript_1.default.factory.createBlock(block, true)), undefined, undefined);
};
};
}
UnionExplorer.array = array;
};
})(UnionExplorer = exports.UnionExplorer || (exports.UnionExplorer = {}));
//# sourceMappingURL=UnionExplorer.js.map

@@ -33,3 +33,3 @@ "use strict";

try {
for (var _b = __values(attribute["x-tson-metaTags"] || []), _c = _b.next(); !_c.done; _c = _b.next()) {
for (var _b = __values(attribute["x-typia-metaTags"] || []), _c = _b.next(); !_c.done; _c = _b.next()) {
var tag = _c.value;

@@ -36,0 +36,0 @@ if (tag.kind === "minItems")

@@ -20,3 +20,3 @@ "use strict";

var _b;
var defaults = (attribute["x-tson-jsDocTags"] || []).filter(function (tag) { return tag.name === "default"; });
var defaults = (attribute["x-typia-jsDocTags"] || []).filter(function (tag) { return tag.name === "default"; });
try {

@@ -23,0 +23,0 @@ for (var defaults_1 = __values(defaults), defaults_1_1 = defaults_1.next(); !defaults_1_1.done; defaults_1_1 = defaults_1.next()) {

@@ -31,3 +31,3 @@ "use strict";

try {
for (var _b = __values(attribute["x-tson-metaTags"] || []), _c = _b.next(); !_c.done; _c = _b.next()) {
for (var _b = __values(attribute["x-typia-metaTags"] || []), _c = _b.next(); !_c.done; _c = _b.next()) {
var tag = _c.value;

@@ -53,2 +53,4 @@ if (tag.kind === "type" &&

}
else if (tag.kind === "multipleOf")
output.multipleOf = tag.value;
}

@@ -64,3 +66,3 @@ }

if (output.type === "integer" &&
(attribute["x-tson-metaTags"] || []).find(function (tag) { return tag.kind === "type" && tag.value === "uint"; }))
(attribute["x-typia-metaTags"] || []).find(function (tag) { return tag.kind === "type" && tag.value === "uint"; }))
if (output.minimum === undefined || output.minimum < 0)

@@ -84,2 +86,4 @@ output.minimum = 0;

conditions.push(value < output.exclusiveMaximum);
if (output.multipleOf !== undefined)
conditions.push(value % output.multipleOf === 0);
return conditions.every(function (cond) { return cond; });

@@ -86,0 +90,0 @@ })(function (str) { return Number(str); });

@@ -15,2 +15,3 @@ "use strict";

exports.application_object = void 0;
var CommentFactory_1 = require("../../factories/CommentFactory");
var PatternUtil_1 = require("../../utils/PatternUtil");

@@ -30,35 +31,47 @@ var application_schema_1 = require("./application_schema");

var required = [];
var _loop_1 = function (property) {
if (property.value.functional === true &&
property.value.nullable === false &&
property.value.required === true &&
property.value.size() === 0)
return "continue";
var key_1 = property.key.getSoleLiteral();
var value = (0, application_schema_1.application_schema)(options)(components)(true)(property.value, {
deprecated: !!property.jsDocTags.find(function (tag) { return tag.name === "deprecated"; }) || undefined,
title: (function () {
var _a;
var info = property.jsDocTags.find(function (tag) { return tag.name === "title"; });
return ((_a = info === null || info === void 0 ? void 0 : info.text) === null || _a === void 0 ? void 0 : _a.length)
? CommentFactory_1.CommentFactory.generate(info.text)
: undefined;
})(),
description: property.description,
"x-typia-metaTags": property.tags.length
? property.tags
: undefined,
"x-typia-jsDocTags": property.jsDocTags.length
? property.jsDocTags
: undefined,
"x-typia-required": property.value.required,
});
if (value === null)
return "continue";
else if (key_1 !== null) {
properties[key_1] = value;
if (property.value.required === true)
required.push(key_1);
}
else {
var pattern = (0, metadata_to_pattern_1.metadata_to_pattern)(true)(property.key);
if (options.purpose === "swagger" ||
pattern === PatternUtil_1.PatternUtil.STRING)
additionalProperties.push(value);
else
patternProperties[pattern] = value;
}
};
try {
for (var _b = __values(obj.properties), _c = _b.next(); !_c.done; _c = _b.next()) {
var property = _c.value;
if (property.value.functional === true &&
property.value.nullable === false &&
property.value.required === true &&
property.value.size() === 0)
continue;
var key_1 = property.key.getSoleLiteral();
var value = (0, application_schema_1.application_schema)(options)(components)(true)(property.value, {
description: property.description,
"x-tson-metaTags": property.tags.length
? property.tags
: undefined,
"x-tson-jsDocTags": property.jsDocTags.length
? property.jsDocTags
: undefined,
});
if (value === null)
continue;
else if (key_1 !== null) {
properties[key_1] = value;
if (property.value.required === true)
required.push(key_1);
}
else {
var pattern = (0, metadata_to_pattern_1.metadata_to_pattern)(true)(property.key);
if (options.purpose === "swagger" ||
pattern === PatternUtil_1.PatternUtil.STRING)
additionalProperties.push(value);
else
patternProperties[pattern] = value;
}
_loop_1(property);
}

@@ -91,3 +104,3 @@ }

description: obj.description,
"x-tson_jsDocTags": obj.jsDocTags,
"x-typia_jsDocTags": obj.jsDocTags,
};

@@ -94,0 +107,0 @@ components.schemas[key] = schema;

@@ -53,5 +53,7 @@ "use strict";

var ArrayUtil_1 = require("../../utils/ArrayUtil");
var AtomicPredicator_1 = require("../helpers/AtomicPredicator");
var application_array_1 = require("./application_array");
var application_boolean_1 = require("./application_boolean");
var application_constant_1 = require("./application_constant");
var application_native_1 = require("./application_native");
var application_number_1 = require("./application_number");

@@ -66,3 +68,3 @@ var application_object_1 = require("./application_object");

return function (meta, attribute) {
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
if (meta.any === true)

@@ -73,10 +75,16 @@ return {};

var union = [];
if (meta.templates.length) {
if (meta.resolved !== null) {
var resolved = (0, exports.application_schema)(options)(components)(blockNever)(meta.resolved, attribute);
if (resolved !== null)
union.push(resolved);
}
if (meta.templates.length && AtomicPredicator_1.AtomicPredicator.template(meta))
union.push((0, application_templates_1.application_templates)(meta, attribute));
}
try {
for (var _f = __values(meta.constants), _g = _f.next(); !_g.done; _g = _f.next()) {
var constant = _g.value;
for (var _g = __values(meta.constants), _h = _g.next(); !_h.done; _h = _g.next()) {
var constant = _h.value;
if (constant.type === "string" && meta.templates.length)
continue;
else if (!AtomicPredicator_1.AtomicPredicator.constant(meta)(constant.type))
continue;
union.push((0, application_constant_1.application_constant)(constant, meta.nullable, attribute));

@@ -88,3 +96,3 @@ }

try {
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
}

@@ -94,9 +102,9 @@ finally { if (e_1) throw e_1.error; }

try {
for (var _h = __values(meta.atomics), _j = _h.next(); !_j.done; _j = _h.next()) {
var type = _j.value;
for (var _j = __values(meta.atomics), _k = _j.next(); !_k.done; _k = _j.next()) {
var type = _k.value;
union.push(type === "string"
? (0, application_string_1.application_string)(meta, attribute)
: type === "number"
? (0, application_number_1.application_number)(meta.nullable, attribute)
: (0, application_boolean_1.application_boolean)(meta.nullable, attribute));
: type === "boolean"
? (0, application_boolean_1.application_boolean)(meta.nullable, attribute)
: (0, application_number_1.application_number)(meta.nullable, attribute));
}

@@ -107,3 +115,3 @@ }

try {
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
}

@@ -113,4 +121,4 @@ finally { if (e_2) throw e_2.error; }

try {
for (var _k = __values(meta.arrays.values()), _l = _k.next(); !_l.done; _l = _k.next()) {
var schema = _l.value;
for (var _l = __values(meta.arrays.values()), _m = _l.next(); !_m.done; _m = _l.next()) {
var schema = _m.value;
union.push((0, application_array_1.application_array)(options)(components)(schema, meta.nullable, attribute));

@@ -122,3 +130,3 @@ }

try {
if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
if (_m && !_m.done && (_c = _l.return)) _c.call(_l);
}

@@ -128,5 +136,6 @@ finally { if (e_3) throw e_3.error; }

try {
for (var _m = __values(meta.tuples), _o = _m.next(); !_o.done; _o = _m.next()) {
var items = _o.value;
if (options.purpose === "ajv")
for (var _o = __values(meta.tuples), _p = _o.next(); !_p.done; _p = _o.next()) {
var items = _p.value;
if (options.purpose === "ajv" &&
items.every(function (i) { return i.rest === null; }))
union.push((0, application_tuple_1.application_tuple)(options)(components)(items, meta.nullable, attribute));

@@ -144,3 +153,3 @@ else {

try {
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
if (_p && !_p.done && (_d = _o.return)) _d.call(_o);
}

@@ -150,4 +159,21 @@ finally { if (e_4) throw e_4.error; }

try {
for (var _p = __values(meta.objects), _q = _p.next(); !_q.done; _q = _p.next()) {
var obj = _q.value;
for (var _q = __values(meta.natives), _r = _q.next(); !_r.done; _r = _q.next()) {
var native = _r.value;
union.push((0, application_native_1.application_native)(options)(components)(native)(meta.nullable, attribute));
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_r && !_r.done && (_e = _q.return)) _e.call(_q);
}
finally { if (e_5) throw e_5.error; }
}
if (meta.sets.length)
union.push((0, application_native_1.application_native)(options)(components)("Set")(meta.nullable, attribute));
if (meta.maps.length)
union.push((0, application_native_1.application_native)(options)(components)("Map")(meta.nullable, attribute));
try {
for (var _s = __values(meta.objects), _t = _s.next(); !_t.done; _t = _s.next()) {
var obj = _t.value;
var key = obj.name + (meta.nullable ? ".Nullable" : "");

@@ -160,11 +186,11 @@ (0, application_object_1.application_object)(options)(components)(key, obj, meta.nullable);

}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
catch (e_6_1) { e_6 = { error: e_6_1 }; }
finally {
try {
if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
if (_t && !_t.done && (_f = _s.return)) _f.call(_s);
}
finally { if (e_5) throw e_5.error; }
finally { if (e_6) throw e_6.error; }
}
if (union.length === 0)
return blockNever === true ? null : __assign({}, attribute);
return blockNever === true ? null : {};
else if (union.length === 1)

@@ -181,3 +207,3 @@ return union[0];

function merge_metadata(x, y) {
var e_6, _a, e_7, _b, e_8, _c;
var e_7, _a, e_8, _b, e_9, _c;
var output = Metadata_1.Metadata.create({

@@ -194,8 +220,12 @@ any: x.any || y.any,

templates: x.templates.slice(),
rest: null,
arrays: x.arrays.slice(),
tuples: x.tuples.slice(),
objects: x.objects.slice(),
natives: __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(x.natives), false), __read(y.natives), false))), false),
sets: x.sets.slice(),
maps: x.maps.slice(),
});
var _loop_1 = function (constant) {
var e_9, _k;
var e_10, _k;
var target = ArrayUtil_1.ArrayUtil.take(output.constants, function (elem) { return elem.type === constant.type; }, function () { return ({

@@ -206,3 +236,3 @@ type: constant.type,

try {
for (var _l = (e_9 = void 0, __values(constant.values)), _m = _l.next(); !_m.done; _m = _l.next()) {
for (var _l = (e_10 = void 0, __values(constant.values)), _m = _l.next(); !_m.done; _m = _l.next()) {
var value = _m.value;

@@ -212,3 +242,3 @@ ArrayUtil_1.ArrayUtil.add(target.values, value);

}
catch (e_9_1) { e_9 = { error: e_9_1 }; }
catch (e_10_1) { e_10 = { error: e_10_1 }; }
finally {

@@ -218,3 +248,3 @@ try {

}
finally { if (e_9) throw e_9.error; }
finally { if (e_10) throw e_10.error; }
}

@@ -228,3 +258,3 @@ };

}
catch (e_6_1) { e_6 = { error: e_6_1 }; }
catch (e_7_1) { e_7 = { error: e_7_1 }; }
finally {

@@ -234,3 +264,3 @@ try {

}
finally { if (e_6) throw e_6.error; }
finally { if (e_7) throw e_7.error; }
}

@@ -243,3 +273,3 @@ try {

}
catch (e_7_1) { e_7 = { error: e_7_1 }; }
catch (e_8_1) { e_8 = { error: e_8_1 }; }
finally {

@@ -249,3 +279,3 @@ try {

}
finally { if (e_7) throw e_7.error; }
finally { if (e_8) throw e_8.error; }
}

@@ -258,3 +288,3 @@ try {

}
catch (e_8_1) { e_8 = { error: e_8_1 }; }
catch (e_9_1) { e_9 = { error: e_9_1 }; }
finally {

@@ -264,6 +294,10 @@ try {

}
finally { if (e_8) throw e_8.error; }
finally { if (e_9) throw e_9.error; }
}
if (x.rest !== null)
ArrayUtil_1.ArrayUtil.set(output.arrays, x.rest, function (elem) { return elem.getName(); });
if (y.rest !== null)
ArrayUtil_1.ArrayUtil.set(output.arrays, y.rest, function (elem) { return elem.getName(); });
return output;
}
//# sourceMappingURL=application_schema.js.map

@@ -31,7 +31,7 @@ "use strict";

var output = __assign({ type: "string", nullable: meta.nullable }, attribute);
var formatJsdocTag = (_b = attribute["x-tson-jsDocTags"]) === null || _b === void 0 ? void 0 : _b.find(function (tag) { return tag.name === "format"; });
var formatJsdocTag = (_b = attribute["x-typia-jsDocTags"]) === null || _b === void 0 ? void 0 : _b.find(function (tag) { return tag.name === "format"; });
if ((_c = formatJsdocTag === null || formatJsdocTag === void 0 ? void 0 : formatJsdocTag.text) === null || _c === void 0 ? void 0 : _c.length)
output.format = formatJsdocTag === null || formatJsdocTag === void 0 ? void 0 : formatJsdocTag.text.map(function (t) { return t.text; }).join(" ");
try {
for (var _d = __values(attribute["x-tson-metaTags"] || []), _e = _d.next(); !_e.done; _e = _d.next()) {
for (var _d = __values(attribute["x-typia-metaTags"] || []), _e = _d.next(); !_e.done; _e = _d.next()) {
var tag = _e.value;

@@ -38,0 +38,0 @@ if (tag.kind === "minLength")

@@ -19,10 +19,8 @@ "use strict";

var typescript_1 = __importDefault(require("typescript"));
var ExpressionFactory_1 = require("../../factories/ExpressionFactory");
var IdentifierFactory_1 = require("../../factories/IdentifierFactory");
var check_length_1 = require("./check_length");
function check_array(input, arrow, tagList, every) {
function check_array(input, tagList) {
var e_1, _a;
var conditions = [
every ||
typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "every"), undefined, [arrow]),
];
var conditions = [ExpressionFactory_1.ExpressionFactory.isArray(input)];
try {

@@ -46,9 +44,5 @@ for (var tagList_1 = __values(tagList), tagList_1_1 = tagList_1.next(); !tagList_1_1.done; tagList_1_1 = tagList_1.next()) {

}
return conditions.length === 1
? conditions[0]
: conditions
.reverse()
.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); });
return conditions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); });
}
exports.check_array = check_array;
//# sourceMappingURL=check_array.js.map

@@ -45,59 +45,49 @@ "use strict";

var IdentifierFactory_1 = require("../../factories/IdentifierFactory");
var StatementFactory_1 = require("../../factories/StatementFactory");
var check_everything_1 = require("./check_everything");
var metadata_to_pattern_1 = require("./metadata_to_pattern");
var check_dynamic_properties = function (equals) {
return function (assert) {
return function (halter) {
return function (wrapper) {
return function (regular, dynamic) {
var criteria = typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Object.entries"), undefined, [typescript_1.default.factory.createIdentifier("input")]), assert ? "every" : "map"), undefined, [check_dynamic_property(equals)(wrapper)(regular, dynamic)]);
return (halter || (function (elem) { return elem; }))(assert ? criteria : (0, check_everything_1.check_everything)(criteria));
};
};
};
var check_dynamic_properties = function (props) {
return function (regular, dynamic) {
var criteria = props.entries
? typescript_1.default.factory.createCallExpression(props.entries, undefined, [
typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Object.keys"), undefined, [typescript_1.default.factory.createIdentifier("input")]),
check_dynamic_property(props)(regular, dynamic),
])
: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Object.keys"), undefined, [typescript_1.default.factory.createIdentifier("input")]), props.assert ? "every" : "map"), undefined, [check_dynamic_property(props)(regular, dynamic)]);
return (props.halt || (function (elem) { return elem; }))(props.assert ? criteria : (0, check_everything_1.check_everything)(criteria));
};
};
exports.check_dynamic_properties = check_dynamic_properties;
var check_dynamic_property = function (equals) {
return function (wrapper) {
return function (regular, dynamic) {
var e_1, _a;
var key = typescript_1.default.factory.createIdentifier("key");
var value = typescript_1.default.factory.createIdentifier("value");
var statements = [
typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createIdentifier("undefined"), value), typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createTrue())),
];
var add = function (exp, output) {
return statements.push(typescript_1.default.factory.createIfStatement(exp, typescript_1.default.factory.createReturnStatement(output)));
};
if (equals === true)
add(is_regular_property(regular), typescript_1.default.factory.createTrue());
var check_dynamic_property = function (props) {
return function (regular, dynamic) {
var e_1, _a;
var key = typescript_1.default.factory.createIdentifier("key");
var value = typescript_1.default.factory.createIdentifier("value");
var statements = [];
var add = function (exp, output) {
return statements.push(typescript_1.default.factory.createIfStatement(exp, typescript_1.default.factory.createReturnStatement(output)));
};
if (props.equals === true && regular.length)
add(is_regular_property(regular), props.positive);
statements.push(StatementFactory_1.StatementFactory.constant("value", typescript_1.default.factory.createIdentifier("input[key]")));
add(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createIdentifier("undefined"), value), props.positive);
try {
for (var dynamic_1 = __values(dynamic), dynamic_1_1 = dynamic_1.next(); !dynamic_1_1.done; dynamic_1_1 = dynamic_1.next()) {
var entry = dynamic_1_1.value;
add(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("RegExp(/".concat((0, metadata_to_pattern_1.metadata_to_pattern)(true)(entry.key), "/).test")), undefined, [key]), entry.expression);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
for (var dynamic_1 = __values(dynamic), dynamic_1_1 = dynamic_1.next(); !dynamic_1_1.done; dynamic_1_1 = dynamic_1.next()) {
var entry = dynamic_1_1.value;
add(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("RegExp(/".concat((0, metadata_to_pattern_1.metadata_to_pattern)(true)(entry.key), "/).test")), undefined, [key]), entry.expression);
}
if (dynamic_1_1 && !dynamic_1_1.done && (_a = dynamic_1.return)) _a.call(dynamic_1);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (dynamic_1_1 && !dynamic_1_1.done && (_a = dynamic_1.return)) _a.call(dynamic_1);
}
finally { if (e_1) throw e_1.error; }
}
var block = typescript_1.default.factory.createBlock(__spreadArray(__spreadArray([], __read(statements), false), [
typescript_1.default.factory.createReturnStatement(equals === true
? typescript_1.default.factory.createFalse()
: typescript_1.default.factory.createTrue()),
], false), true);
var body = wrapper
? wrapper(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, block), undefined, undefined))
: block;
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [
IdentifierFactory_1.IdentifierFactory.parameter(typescript_1.default.factory.createArrayBindingPattern([
typescript_1.default.factory.createBindingElement(undefined, undefined, "key"),
typescript_1.default.factory.createBindingElement(undefined, undefined, "value"),
])),
], undefined, undefined, body);
};
finally { if (e_1) throw e_1.error; }
}
var block = typescript_1.default.factory.createBlock(__spreadArray(__spreadArray([], __read(statements), false), [
typescript_1.default.factory.createReturnStatement(props.equals === true
? props.superfluous(value)
: props.positive),
], false), true);
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("key")], undefined, undefined, block);
};

@@ -104,0 +94,0 @@ };

@@ -11,5 +11,3 @@ "use strict";

return typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(array, "every"), undefined, [
typescript_1.default.factory.createArrowFunction(undefined, undefined, [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, "flag"),
], undefined, undefined, typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createTrue(), typescript_1.default.factory.createIdentifier("flag"))),
typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("flag")], undefined, undefined, typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createTrue(), typescript_1.default.factory.createIdentifier("flag"))),
]);

@@ -16,0 +14,0 @@ };

@@ -23,4 +23,4 @@ "use strict";

conditions.push((tag.maximum.include
? typescript_1.default.factory.createLessThanEquals
: typescript_1.default.factory.createLessThan)(length, typescript_1.default.factory.createNumericLiteral(tag.maximum.value)));
? typescript_1.default.factory.createGreaterThanEquals
: typescript_1.default.factory.createGreaterThan)(typescript_1.default.factory.createNumericLiteral(tag.maximum.value), length));
}

@@ -27,0 +27,0 @@ }

@@ -112,3 +112,3 @@ "use strict";

if (numeric &&
OptionPredicator_1.OptionPreditor.numeric(project.options, "checker") === false) {
OptionPredicator_1.OptionPredicator.numeric(project.options, "checker") === false) {
if (finite === false)

@@ -115,0 +115,0 @@ conditions.push(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Number.isFinite"), undefined, [input]));

@@ -1,1 +0,12 @@

export {};
import ts from "typescript";
export declare namespace check_object {
interface IProps {
equals: boolean;
assert: boolean;
halt?: (exp: ts.Expression) => ts.Expression;
reduce: (a: ts.Expression, b: ts.Expression) => ts.Expression;
positive: ts.Expression;
superfluous: (value: ts.Expression) => ts.Expression;
entries?: ts.Identifier;
}
}

@@ -10,27 +10,17 @@ "use strict";

var check_everything_1 = require("./check_everything");
var check_object = function (equals) {
return function (assert) {
return function (halter) {
return function (wrapper) {
return function (entries) {
var regular = entries.filter(function (entry) { return entry.key.isSoleLiteral(); });
var dynamic = entries.filter(function (entry) { return !entry.key.isSoleLiteral(); });
var flags = regular.map(function (entry) { return entry.expression; });
if (equals === false && dynamic.length === 0)
return regular.length === 0
? typescript_1.default.factory.createTrue()
: reduce(assert)(flags);
flags.push((0, check_dynamic_properties_1.check_dynamic_properties)(equals)(assert)(halter)(wrapper)(regular, dynamic));
return reduce(assert)(flags);
};
};
};
};
};
var check_object = function (props) { return function (entries) {
var regular = entries.filter(function (entry) { return entry.key.isSoleLiteral(); });
var dynamic = entries.filter(function (entry) { return !entry.key.isSoleLiteral(); });
var flags = regular.map(function (entry) { return entry.expression; });
if (props.equals === false && dynamic.length === 0)
return regular.length === 0 ? props.positive : reduce(props)(flags);
flags.push((0, check_dynamic_properties_1.check_dynamic_properties)(props)(regular, dynamic));
return reduce(props)(flags);
}; };
exports.check_object = check_object;
var reduce = function (assert) { return function (expressions) {
return assert
? expressions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); })
var reduce = function (props) { return function (expressions) {
return props.assert
? expressions.reduce(props.reduce)
: (0, check_everything_1.check_everything)(typescript_1.default.factory.createArrayLiteralExpression(expressions));
}; };
//# sourceMappingURL=check_object.js.map

@@ -35,9 +35,11 @@ "use strict";

return function (decoder) {
return function (escaper) {
return function (input, targets, explore) {
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, iterate(escaper)(input, targets.map(function (obj) { return ({
type: "object",
is: function () { return checker(input, obj, explore); },
value: function () { return decoder(input, obj, explore); },
}); }), "(".concat(targets.map(function (t) { return t.name; }).join(" | "), ")"))), undefined, undefined);
return function (success) {
return function (escaper) {
return function (input, targets, explore) {
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, iterate(escaper)(input, targets.map(function (obj) { return ({
type: "object",
is: function () { return success(checker(input, obj, explore)); },
value: function () { return decoder(input, obj, explore); },
}); }), "(".concat(targets.map(function (t) { return t.name; }).join(" | "), ")"))), undefined, undefined);
};
};

@@ -44,0 +46,0 @@ };

@@ -42,5 +42,7 @@ "use strict";

if (regular.length)
statements.push(typescript_1.default.factory.createIfStatement(IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createArrayLiteralExpression(regular.map(function (key) {
statements.push(typescript_1.default.factory.createIfStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(typescript_1.default.factory.createArrayLiteralExpression(regular.map(function (key) {
return typescript_1.default.factory.createStringLiteral(key);
})), "some"), typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createStringLiteral(""))));
})), "some"), undefined, [
typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("regular")], undefined, undefined, typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createIdentifier("regular"), typescript_1.default.factory.createIdentifier("key"))),
]), typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createStringLiteral(""))));
var simple = dynamic.length === 1 &&

@@ -47,0 +49,0 @@ dynamic[0].key.size() === 1 &&

import ts from "typescript";
import { MetadataObject } from "../metadata/MetadataObject";
import { IProject } from "../transformers/IProject";

@@ -7,3 +8,3 @@ import { CheckerProgrammer } from "./CheckerProgrammer";

export declare namespace IsProgrammer {
function CONFIG(options?: Partial<CONFIG.IOptions>): CheckerProgrammer.IConfig;
const CONFIG: (options?: Partial<CONFIG.IOptions>) => CheckerProgrammer.IConfig;
namespace CONFIG {

@@ -16,8 +17,8 @@ interface IOptions {

function generate(project: IProject, modulo: ts.LeftHandSideExpression, equals?: boolean): (type: ts.Type) => ts.ArrowFunction;
const generate_functors: (project: IProject, importer: FunctionImporter) => (collection: import("../factories/MetadataCollection").MetadataCollection) => ts.VariableDeclaration | null;
const generate_unioners: (project: IProject, importer: FunctionImporter) => (collection: import("../factories/MetadataCollection").MetadataCollection) => ts.VariableDeclaration | null;
const generate_functors: (project: IProject, importer: FunctionImporter) => (collection: import("../factories/MetadataCollection").MetadataCollection) => ts.VariableStatement[];
const generate_unioners: (project: IProject, importer: FunctionImporter) => (collection: import("../factories/MetadataCollection").MetadataCollection) => ts.VariableStatement[];
const decode: (project: IProject, importer: FunctionImporter) => (input: ts.Expression, meta: import("../metadata/Metadata").Metadata, explore: CheckerProgrammer.IExplore, tags: import("../metadata/IMetadataTag").IMetadataTag[]) => ts.Expression;
const decode_object: () => (input: ts.Expression, obj: import("../metadata/MetadataObject").MetadataObject, explore: CheckerProgrammer.IExplore) => ts.CallExpression;
const decode_object: () => (input: ts.Expression, obj: MetadataObject, explore: CheckerProgrammer.IExplore) => ts.CallExpression;
function decode_to_json(input: ts.Expression): ts.Expression;
function decode_functional(input: ts.Expression): ts.BinaryExpression;
}
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -19,2 +8,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var typescript_1 = __importDefault(require("typescript"));
var ExpressionFactory_1 = require("../factories/ExpressionFactory");
var IdentifierFactory_1 = require("../factories/IdentifierFactory");

@@ -25,46 +15,81 @@ var ValueFactory_1 = require("../factories/ValueFactory");

var check_object_1 = require("./internal/check_object");
var feature_object_entries_1 = require("./internal/feature_object_entries");
var IsProgrammer;
(function (IsProgrammer) {
function CONFIG(options) {
return {
functors: "$io",
unioners: "$iu",
trace: false,
equals: !!(options === null || options === void 0 ? void 0 : options.object),
numeric: !!(options === null || options === void 0 ? void 0 : options.numeric),
combiner: function () { return function (type) {
var initial = type === "and"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createFalse();
var binder = type === "and"
? typescript_1.default.factory.createLogicalAnd
: typescript_1.default.factory.createLogicalOr;
return function (_input, expressions) {
return expressions.length
? expressions.reduce(function (x, y) { return binder(x, y); })
: initial;
};
}; },
joiner: CheckerProgrammer_1.CheckerProgrammer.DEFAULT_JOINER((options === null || options === void 0 ? void 0 : options.object) || (0, check_object_1.check_object)(false)(true)()()),
};
}
IsProgrammer.CONFIG = CONFIG;
IsProgrammer.CONFIG = function (options) { return ({
functors: "$io",
unioners: "$iu",
trace: false,
path: false,
equals: !!(options === null || options === void 0 ? void 0 : options.object),
numeric: !!(options === null || options === void 0 ? void 0 : options.numeric),
combiner: function () { return function (type) {
var initial = type === "and"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createFalse();
var binder = type === "and"
? typescript_1.default.factory.createLogicalAnd
: typescript_1.default.factory.createLogicalOr;
return function (_input, binaries) {
return binaries.length
? binaries
.map(function (binary) { return binary.expression; })
.reduce(function (x, y) { return binder(x, y); })
: initial;
};
}; },
joiner: {
object: (options === null || options === void 0 ? void 0 : options.object) ||
(0, check_object_1.check_object)({
equals: !!(options === null || options === void 0 ? void 0 : options.object),
assert: true,
reduce: typescript_1.default.factory.createLogicalAnd,
positive: typescript_1.default.factory.createTrue(),
superfluous: function () { return typescript_1.default.factory.createFalse(); },
}),
array: function (input, arrow) {
return typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "every"), undefined, [arrow]);
},
failure: function () { return typescript_1.default.factory.createFalse(); },
},
success: typescript_1.default.factory.createTrue(),
}); };
function generate(project, modulo, equals) {
if (equals === void 0) { equals = false; }
var importer = new FunctionImporeter_1.FunctionImporter();
if (equals === true)
importer.use("join");
return CheckerProgrammer_1.CheckerProgrammer.generate(project, __assign(__assign({}, CONFIG({
object: (0, check_object_1.check_object)(equals)(true)()(),
var config = IsProgrammer.CONFIG({
object: (0, check_object_1.check_object)({
equals: equals,
assert: true,
reduce: typescript_1.default.factory.createLogicalAnd,
positive: typescript_1.default.factory.createTrue(),
superfluous: function () { return typescript_1.default.factory.createFalse(); },
}),
numeric: !!project.options.numeric,
})), { trace: equals }), modulo, importer);
});
config.trace = equals;
if (equals === false)
config.decoder = function (input, target, explore, tags) {
if (target.size() === 1 &&
target.objects.length === 1 &&
target.required === true &&
target.nullable === false) {
var obj = target.objects[0];
if (obj._Is_simple())
return typescript_1.default.factory.createLogicalAnd(ExpressionFactory_1.ExpressionFactory.isObject(input, true), config.joiner.object((0, feature_object_entries_1.feature_object_entries)(config)(obj)(input)));
}
return CheckerProgrammer_1.CheckerProgrammer.decode(project, config, importer)(input, target, explore, tags);
};
return CheckerProgrammer_1.CheckerProgrammer.generate(project, config, importer, function () {
return importer.declare(modulo);
});
}
IsProgrammer.generate = generate;
IsProgrammer.generate_functors = function (project, importer) { return CheckerProgrammer_1.CheckerProgrammer.generate_functors(project, CONFIG(), importer); };
IsProgrammer.generate_unioners = function (project, importer) { return CheckerProgrammer_1.CheckerProgrammer.generate_unioners(project, CONFIG(), importer); };
IsProgrammer.generate_functors = function (project, importer) { return CheckerProgrammer_1.CheckerProgrammer.generate_functors(project, IsProgrammer.CONFIG(), importer); };
IsProgrammer.generate_unioners = function (project, importer) { return CheckerProgrammer_1.CheckerProgrammer.generate_unioners(project, IsProgrammer.CONFIG(), importer); };
IsProgrammer.decode = function (project, importer) {
return CheckerProgrammer_1.CheckerProgrammer.decode(project, CONFIG(), importer);
return CheckerProgrammer_1.CheckerProgrammer.decode(project, IsProgrammer.CONFIG(), importer);
};
IsProgrammer.decode_object = function () {
return CheckerProgrammer_1.CheckerProgrammer.decode_object(CONFIG());
return CheckerProgrammer_1.CheckerProgrammer.decode_object(IsProgrammer.CONFIG());
};

@@ -71,0 +96,0 @@ function decode_to_json(input) {

@@ -64,2 +64,3 @@ "use strict";

var IsProgrammer_1 = require("./IsProgrammer");
var AtomicPredicator_1 = require("./helpers/AtomicPredicator");
var FunctionImporeter_1 = require("./helpers/FunctionImporeter");

@@ -71,2 +72,3 @@ var OptionPredicator_1 = require("./helpers/OptionPredicator");

var decode_union_object_1 = require("./internal/decode_union_object");
var feature_object_entries_1 = require("./internal/feature_object_entries");
var StringifyProgrammer;

@@ -76,14 +78,6 @@ (function (StringifyProgrammer) {

var importer = new FunctionImporeter_1.FunctionImporter();
return FeatureProgrammer_1.FeatureProgrammer.generate(project, CONFIG(project, importer), function (collection) {
return FeatureProgrammer_1.FeatureProgrammer.generate(project, CONFIG(project, importer), importer, function (collection) {
var isFunctors = IsProgrammer_1.IsProgrammer.generate_functors(project, importer)(collection);
var isUnioners = IsProgrammer_1.IsProgrammer.generate_unioners(project, importer)(collection);
return __spreadArray(__spreadArray(__spreadArray([], __read(importer.declare(modulo)), false), __read((isFunctors
? [
typescript_1.default.factory.createVariableStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([isFunctors], typescript_1.default.NodeFlags.Const)),
]
: [])), false), __read((isUnioners
? [
typescript_1.default.factory.createVariableStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([isUnioners], typescript_1.default.NodeFlags.Const)),
]
: [])), false);
return __spreadArray(__spreadArray(__spreadArray([], __read(importer.declare(modulo)), false), __read(isFunctors), false), __read(isUnioners), false);
});

@@ -94,3 +88,3 @@ }

return function (input, meta, explore, tags) {
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
if (meta.any === true)

@@ -132,3 +126,3 @@ return wrap_required(input, meta, explore)(wrap_functional(input, meta, explore)(typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("JSON.stringify"), undefined, [input])));

ArrayUtil_1.ArrayUtil.has(meta.constants, function (c) { return c.type === "string"; }))
if (!ArrayUtil_1.ArrayUtil.has(meta.atomics, function (type) { return type === "string"; })) {
if (AtomicPredicator_1.AtomicPredicator.template(meta)) {
var partial_1 = Metadata_1.Metadata.initialize();

@@ -147,5 +141,4 @@ partial_1.atomics.push("string"),

var _loop_1 = function (constant) {
if (ArrayUtil_1.ArrayUtil.has(meta.atomics, function (type) { return type === constant.type; }))
return "continue";
else if (constant.type !== "string")
if (constant.type !== "string" &&
AtomicPredicator_1.AtomicPredicator.constant(meta)(constant.type))
unions.push({

@@ -180,4 +173,4 @@ type: "atomic",

try {
for (var _e = __values(meta.constants), _f = _e.next(); !_f.done; _f = _e.next()) {
var constant = _f.value;
for (var _f = __values(meta.constants), _g = _f.next(); !_g.done; _g = _f.next()) {
var constant = _g.value;
_loop_1(constant);

@@ -189,3 +182,3 @@ }

try {
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
}

@@ -210,4 +203,4 @@ finally { if (e_1) throw e_1.error; }

try {
for (var _g = __values(meta.atomics), _h = _g.next(); !_h.done; _h = _g.next()) {
var type = _h.value;
for (var _h = __values(meta.atomics), _j = _h.next(); !_j.done; _j = _h.next()) {
var type = _j.value;
_loop_2(type);

@@ -219,3 +212,3 @@ }

try {
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
}

@@ -225,16 +218,16 @@ finally { if (e_2) throw e_2.error; }

var _loop_3 = function (tuple) {
var e_5, _o;
var e_6, _r;
try {
for (var tuple_1 = (e_5 = void 0, __values(tuple)), tuple_1_1 = tuple_1.next(); !tuple_1_1.done; tuple_1_1 = tuple_1.next()) {
for (var tuple_1 = (e_6 = void 0, __values(tuple)), tuple_1_1 = tuple_1.next(); !tuple_1_1.done; tuple_1_1 = tuple_1.next()) {
var child = tuple_1_1.value;
if (StringifyPredicator_1.StringifyPredicator.undefindable(meta))
throw new Error("Error on TSON.stringify(): tuple cannot contain undefined value - (".concat(child.getName(), ")."));
throw new Error("Error on typia.stringify(): tuple cannot contain undefined value - (".concat(child.getName(), ")."));
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
catch (e_6_1) { e_6 = { error: e_6_1 }; }
finally {
try {
if (tuple_1_1 && !tuple_1_1.done && (_o = tuple_1.return)) _o.call(tuple_1);
if (tuple_1_1 && !tuple_1_1.done && (_r = tuple_1.return)) _r.call(tuple_1);
}
finally { if (e_5) throw e_5.error; }
finally { if (e_6) throw e_6.error; }
}

@@ -256,4 +249,4 @@ unions.push({

try {
for (var _j = __values(meta.tuples), _k = _j.next(); !_k.done; _k = _j.next()) {
var tuple = _k.value;
for (var _k = __values(meta.tuples), _l = _k.next(); !_l.done; _l = _k.next()) {
var tuple = _l.value;
_loop_3(tuple);

@@ -265,3 +258,3 @@ }

try {
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
}

@@ -272,6 +265,6 @@ finally { if (e_3) throw e_3.error; }

try {
for (var _l = __values(meta.arrays), _m = _l.next(); !_m.done; _m = _l.next()) {
var child = _m.value;
for (var _m = __values(meta.arrays), _o = _m.next(); !_o.done; _o = _m.next()) {
var child = _o.value;
if (StringifyPredicator_1.StringifyPredicator.undefindable(child))
throw new Error("Error on TSON.stringify(): array cannot contain undefined value (".concat(child.getName(), ")."));
throw new Error("Error on typia.stringify(): array cannot contain undefined value (".concat(child.getName(), ")."));
}

@@ -282,14 +275,53 @@ }

try {
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
}
finally { if (e_4) throw e_4.error; }
}
var value = meta.arrays.some(function (elem) { return elem.any; })
? function () {
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("JSON.stringify"), undefined, [input]);
}
: function () {
return explore_arrays(project, importer)(input, meta.arrays, __assign(__assign({}, explore), { from: "array" }), []);
};
unions.push({
type: "array",
is: function () { return ExpressionFactory_1.ExpressionFactory.isArray(input); },
value: function () {
return explore_arrays(project, importer)(input, meta.arrays, __assign(__assign({}, explore), { from: "array" }), []);
},
value: value,
});
}
if (meta.natives.length) {
var _loop_4 = function (native) {
unions.push({
type: "object",
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf(input, native); },
value: function () { return typescript_1.default.factory.createStringLiteral("{}"); },
});
};
try {
for (var _p = __values(meta.natives), _q = _p.next(); !_q.done; _q = _p.next()) {
var native = _q.value;
_loop_4(native);
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
}
finally { if (e_5) throw e_5.error; }
}
}
if (meta.sets.length)
unions.push({
type: "object",
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf(input, "Set"); },
value: function () { return typescript_1.default.factory.createStringLiteral("{}"); },
});
if (meta.maps.length)
unions.push({
type: "object",
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf(input, "Map"); },
value: function () { return typescript_1.default.factory.createStringLiteral("{}"); },
});
if (meta.objects.length)

@@ -300,3 +332,15 @@ unions.push({

value: function () {
return explore_objects(input, meta, __assign(__assign({}, explore), { from: "object" }));
return meta.isParentResolved() === false &&
meta.objects.length === 1 &&
meta.objects[0]._Is_simple()
? (function () {
var obj = meta.objects[0];
var entries = (0, feature_object_entries_1.feature_object_entries)({
decoder: decode(project, importer),
trace: false,
path: false,
})(obj)(input);
return StringifyJoinder_1.StringifyJoiner.object(importer)(entries);
})()
: explore_objects(input, meta, __assign(__assign({}, explore), { from: "object" }));
},

@@ -320,2 +364,3 @@ });

trace: false,
path: false,
functors: FUNCTORS,

@@ -326,6 +371,21 @@ });

return function (input, tuple, explore, tags) {
var children = tuple.map(function (elem, index) {
var children = tuple
.filter(function (elem) { return elem.rest === null; })
.map(function (elem, index) {
return decode(project, importer)(typescript_1.default.factory.createElementAccessExpression(input, index), elem, __assign(__assign({}, explore), { from: "array" }), tags);
});
return StringifyJoinder_1.StringifyJoiner.tuple(children);
var rest = (function () {
if (tuple.length === 0)
return null;
var last = tuple[tuple.length - 1];
if (last.rest === null)
return null;
var code = decode(project, importer)(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "slice"), undefined, [typescript_1.default.factory.createNumericLiteral(tuple.length - 1)]), (function () {
var wrapper = Metadata_1.Metadata.initialize();
wrapper.arrays.push(tuple[tuple.length - 1].rest);
return wrapper;
})(), __assign(__assign({}, explore), { start: tuple.length - 1 }), tags);
return typescript_1.default.factory.createCallExpression(importer.use("rest"), undefined, [code]);
})();
return StringifyJoinder_1.StringifyJoiner.tuple(children, rest);
};

@@ -345,3 +405,3 @@ };

else if (type === "number" &&
OptionPredicator_1.OptionPreditor.numeric(project.options, "stringify"))
OptionPredicator_1.OptionPredicator.numeric(project.options, "stringify"))
input = typescript_1.default.factory.createCallExpression(importer.use("number"), undefined, [input]);

@@ -376,4 +436,10 @@ return explore.from !== "top"

var explore_arrays = function (project, importer) {
return UnionExplorer_1.UnionExplorer.array(IsProgrammer_1.IsProgrammer.decode(project, importer), decode_array(project, importer), function () { return typescript_1.default.factory.createStringLiteral("[]"); }, function (input, targets) {
return create_throw_error(importer, input, "(".concat(targets.map(function (t) { return t.getName(); }).join(" | "), ")"));
return UnionExplorer_1.UnionExplorer.array({
checker: IsProgrammer_1.IsProgrammer.decode(project, importer),
decoder: decode_array(project, importer),
empty: typescript_1.default.factory.createStringLiteral("[]"),
success: typescript_1.default.factory.createTrue(),
failure: function (input, expected) {
return create_throw_error(importer, input, expected);
},
});

@@ -384,3 +450,3 @@ };

return decode_object()(input, meta.objects[0], explore);
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("".concat(UNIONERS, "[").concat(meta.union_index, "]")), undefined, [input]);
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("".concat(UNIONERS).concat(meta.union_index)), undefined, [input]);
};

@@ -423,2 +489,3 @@ function wrap_required(input, meta, explore) {

trace: false,
path: false,
initializer: initializer,

@@ -441,6 +508,10 @@ decoder: decode(project, importer),

joiner: StringifyJoinder_1.StringifyJoiner.object(importer),
unionizer: (0, decode_union_object_1.decode_union_object)(IsProgrammer_1.IsProgrammer.decode_object())(decode_object())(function (value, expected) { return create_throw_error(importer, value, expected); }),
failure: function (input, targets) {
return create_throw_error(importer, input, "(".concat(targets.map(function (t) { return t.name; }).join(" | "), ")"));
unionizer: (0, decode_union_object_1.decode_union_object)(IsProgrammer_1.IsProgrammer.decode_object())(decode_object())(function (exp) { return exp; })(function (value, expected) {
return create_throw_error(importer, value, expected);
}),
failure: function (input, expected) {
return create_throw_error(importer, input, expected);
},
is: function (expr) { return expr; },
required: function (expr) { return expr; },
}); };

@@ -447,0 +518,0 @@ function create_throw_error(importer, value, expected) {

import ts from "typescript";
import { IProject } from "../transformers/IProject";
export declare namespace ValidateProgrammer {
function generate(project: IProject, modulo: ts.LeftHandSideExpression, equals?: boolean): (type: ts.Type) => ts.ArrowFunction;
const generate: (project: IProject, modulo: ts.LeftHandSideExpression, equals?: boolean) => (type: ts.Type) => ts.ArrowFunction;
}
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -10,7 +35,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var StatementFactory_1 = require("../factories/StatementFactory");
var ValueFactory_1 = require("../factories/ValueFactory");
var CheckerProgrammer_1 = require("./CheckerProgrammer");
var IsProgrammer_1 = require("./IsProgrammer");
var FunctionImporeter_1 = require("./helpers/FunctionImporeter");
var check_array_1 = require("./internal/check_array");
var check_everything_1 = require("./internal/check_everything");

@@ -20,79 +43,112 @@ var check_object_1 = require("./internal/check_object");

(function (ValidateProgrammer) {
function generate(project, modulo, equals) {
ValidateProgrammer.generate = function (project, modulo, equals) {
if (equals === void 0) { equals = false; }
var importer = new FunctionImporeter_1.FunctionImporter();
return function (type) {
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [
typescript_1.default.factory.createParameterDeclaration(undefined, undefined, undefined, ValueFactory_1.ValueFactory.INPUT()),
], undefined, undefined, typescript_1.default.factory.createBlock([
StatementFactory_1.StatementFactory.variable(typescript_1.default.NodeFlags.Const, "$out", create_output()),
StatementFactory_1.StatementFactory.variable(typescript_1.default.NodeFlags.Const, "$pred", typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(modulo, "predicate"), [], [typescript_1.default.factory.createIdentifier("$out")])),
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(CheckerProgrammer_1.CheckerProgrammer.generate(project, {
functors: "$vo",
unioners: "$vu",
trace: true,
numeric: !!project.options.numeric,
equals: equals,
combiner: combine(equals)(importer),
joiner: join(equals)(importer),
}, modulo, importer)(type), undefined, [ValueFactory_1.ValueFactory.INPUT()])),
typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createIdentifier("$out")),
]));
var importer = new FunctionImporeter_1.FunctionImporter();
var program = CheckerProgrammer_1.CheckerProgrammer.generate(project, {
functors: "$vo",
unioners: "$vu",
path: true,
trace: true,
numeric: !!project.options.numeric,
equals: equals,
combiner: combine(equals)(importer),
joiner: joiner(equals)(importer),
success: typescript_1.default.factory.createTrue(),
}, importer)(type);
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [IdentifierFactory_1.IdentifierFactory.parameter("input")], undefined, undefined, typescript_1.default.factory.createBlock(__spreadArray(__spreadArray([
StatementFactory_1.StatementFactory.constant("errors", typescript_1.default.factory.createArrayLiteralExpression([])),
StatementFactory_1.StatementFactory.constant("$report", typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(modulo, "report"), [], [typescript_1.default.factory.createIdentifier("errors")]))
], __read(importer.declare(modulo)), false), [
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(program, undefined, [
typescript_1.default.factory.createIdentifier("input"),
typescript_1.default.factory.createStringLiteral("$input"),
typescript_1.default.factory.createTrue(),
])),
StatementFactory_1.StatementFactory.constant("success", typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createNumericLiteral(0), typescript_1.default.factory.createIdentifier("errors.length"))),
typescript_1.default.factory.createReturnStatement(create_output()),
], false), true));
};
}
ValidateProgrammer.generate = generate;
};
})(ValidateProgrammer = exports.ValidateProgrammer || (exports.ValidateProgrammer = {}));
var combine = function (equals) { return function (importer) { return function (explore) {
var combiner = IsProgrammer_1.IsProgrammer.CONFIG({
object: validate_object(equals)(importer),
numeric: true,
}).combiner;
if (explore.tracable === false && explore.from !== "top")
return combiner(explore);
var path = explore.postfix
? "path + ".concat(explore.postfix)
: "path";
return function (logic) { return function (input, expressions, expected) {
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("$pred"), [], [
combiner(explore)(logic)(input, expressions, expected),
explore.source === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"),
create_report_function(typescript_1.default.factory.createIdentifier(path), expected, input),
]);
}; };
}; }; };
var combine = function (equals) {
return function (importer) {
return function (explore) {
if (explore.tracable === false && explore.from !== "top")
return IsProgrammer_1.IsProgrammer.CONFIG({
object: validate_object(equals)(importer),
numeric: true,
}).combiner(explore);
var path = explore.postfix
? "path + ".concat(explore.postfix)
: "path";
return function (logic) { return function (input, binaries, expected) {
return logic === "and"
? binaries
.map(function (binary) {
return binary.combined
? binary.expression
: typescript_1.default.factory.createLogicalOr(binary.expression, create_report_call(explore.source === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"))(typescript_1.default.factory.createIdentifier(path), expected, input));
})
.reduce(typescript_1.default.factory.createLogicalAnd)
: typescript_1.default.factory.createLogicalOr(binaries
.map(function (binary) { return binary.expression; })
.reduce(typescript_1.default.factory.createLogicalOr), create_report_call(explore.source === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"))(typescript_1.default.factory.createIdentifier(path), expected, input));
}; };
};
};
};
var validate_object = function (equals) { return function (importer) {
return (0, check_object_1.check_object)(equals)(false)(function (expr) {
return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createIdentifier("exceptionable")), expr);
})(function (expr) {
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("$pred"), undefined, [
expr,
typescript_1.default.factory.createIdentifier("exceptionable"),
create_report_function(typescript_1.default.factory.createAdd(typescript_1.default.factory.createIdentifier("path"), typescript_1.default.factory.createCallExpression(importer.use("join"), undefined, [typescript_1.default.factory.createIdentifier("key")])), "undefined", typescript_1.default.factory.createIdentifier("value")),
]);
return (0, check_object_1.check_object)({
equals: equals,
assert: false,
reduce: typescript_1.default.factory.createLogicalAnd,
positive: typescript_1.default.factory.createTrue(),
superfluous: function (value) {
return create_report_call()(typescript_1.default.factory.createAdd(typescript_1.default.factory.createIdentifier("path"), typescript_1.default.factory.createCallExpression(importer.use("join"), undefined, [typescript_1.default.factory.createIdentifier("key")])), "undefined", value);
},
halt: function (expr) {
return typescript_1.default.factory.createLogicalOr(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createIdentifier("exceptionable")), expr);
},
});
}; };
var join = function (equals) { return function (importer) { return ({
object: validate_object(equals)(importer),
array: function (input, arrow, tags) {
return (0, check_array_1.check_array)(input, arrow, tags, (0, check_everything_1.check_everything)(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "map"), undefined, [arrow])));
},
tuple: function (binaries) {
return (0, check_everything_1.check_everything)(typescript_1.default.factory.createArrayLiteralExpression(binaries, true));
},
}); }; };
var joiner = function (equals) {
return function (importer) { return ({
object: validate_object(equals)(importer),
array: function (input, arrow) {
return (0, check_everything_1.check_everything)(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.join(input, "map"), undefined, [arrow]));
},
failure: function (value, expected, explore) {
return create_report_call((explore === null || explore === void 0 ? void 0 : explore.from) === "top"
? typescript_1.default.factory.createTrue()
: typescript_1.default.factory.createIdentifier("exceptionable"))(typescript_1.default.factory.createIdentifier((explore === null || explore === void 0 ? void 0 : explore.postfix) ? "path + ".concat(explore.postfix) : "path"), expected, value);
},
tuple: function (binaries) {
return (0, check_everything_1.check_everything)(typescript_1.default.factory.createArrayLiteralExpression(binaries, true));
},
}); };
};
function create_output() {
return typescript_1.default.factory.createObjectLiteralExpression([
typescript_1.default.factory.createPropertyAssignment("success", typescript_1.default.factory.createTrue()),
typescript_1.default.factory.createPropertyAssignment("errors", typescript_1.default.factory.createArrayLiteralExpression([], true)),
typescript_1.default.factory.createShorthandPropertyAssignment("success"),
typescript_1.default.factory.createShorthandPropertyAssignment("errors"),
typescript_1.default.factory.createPropertyAssignment("data", typescript_1.default.factory.createConditionalExpression(typescript_1.default.factory.createIdentifier("success"), undefined, typescript_1.default.factory.createIdentifier("input"), undefined, typescript_1.default.factory.createIdentifier("undefined"))),
], true);
}
function create_report_function(path, expected, value) {
return typescript_1.default.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, typescript_1.default.factory.createObjectLiteralExpression([
typescript_1.default.factory.createPropertyAssignment("path", path),
typescript_1.default.factory.createPropertyAssignment("expected", typescript_1.default.factory.createStringLiteral(expected)),
typescript_1.default.factory.createPropertyAssignment("value", value),
], true));
}
var create_report_call = function (exceptionable) {
return function (path, expected, value) {
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("$report"), undefined, [
exceptionable || typescript_1.default.factory.createIdentifier("exceptionable"),
typescript_1.default.factory.createObjectLiteralExpression([
typescript_1.default.factory.createPropertyAssignment("path", path),
typescript_1.default.factory.createPropertyAssignment("expected", typescript_1.default.factory.createStringLiteral(expected)),
typescript_1.default.factory.createPropertyAssignment("value", value),
], true),
]);
};
};
//# sourceMappingURL=ValidateProgrammer.js.map

@@ -16,5 +16,5 @@ import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";

description?: string;
"x-tson_jsDocTags"?: IJsDocTagInfo[];
"x-typia_jsDocTags"?: IJsDocTagInfo[];
$recursiveAnchor?: boolean;
}
}
import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
import { IMetadataTag } from "../metadata/IMetadataTag";
import { Atomic } from "../typings/Atomic";
export declare type IJsonSchema = IJsonSchema.NotUnknown | IJsonSchema.IUnkown;
export type IJsonSchema = IJsonSchema.NotUnknown | IJsonSchema.IUnknown;
export declare namespace IJsonSchema {

@@ -10,5 +10,3 @@ type NotUnknown = IEnumeration<"boolean"> | IEnumeration<"number"> | IEnumeration<"bigint"> | IEnumeration<"string"> | IBoolean | INumber | IBigInt | IString | IArray | ITuple | IOneOf | IReference | IRecursiveReference | INullOnly;

}
interface IAtomic<Literal extends Atomic.Literal> extends IAttribute {
type: Literal;
nullable: boolean;
interface IAtomic<Literal extends Atomic.Literal> extends ISignificant<Literal> {
default?: Atomic.Mapper[Literal];

@@ -27,2 +25,3 @@ }

exclusiveMaximum?: number;
multipleOf?: number;
}

@@ -53,5 +52,5 @@ interface IBoolean extends IAtomic<"boolean"> {

}
interface IUnkown {
interface IUnknown {
}
interface ISignificant<Literal extends string> {
interface ISignificant<Literal extends string> extends IAttribute {
type: Literal;

@@ -61,6 +60,9 @@ nullable: boolean;

interface IAttribute {
deprecated?: boolean;
title?: string;
description?: string;
"x-tson-metaTags"?: IMetadataTag[];
"x-tson-jsDocTags"?: IJsDocTagInfo[];
"x-typia-metaTags"?: IMetadataTag[];
"x-typia-jsDocTags"?: IJsDocTagInfo[];
"x-typia-required"?: boolean;
}
}

@@ -8,8 +8,24 @@ "use strict";

var path_1 = __importDefault(require("path"));
var ApplicationTransformer_1 = require("./features/ApplicationTransformer");
var AssertTransformer_1 = require("./features/AssertTransformer");
var CreateTransformer_1 = require("./features/CreateTransformer");
var IsTransformer_1 = require("./features/IsTransformer");
var StringifyTransformer_1 = require("./features/StringifyTransformer");
var ValidateTransformer_1 = require("./features/ValidateTransformer");
var ApplicationTransformer_1 = require("./features/miscellaneous/ApplicationTransformer");
var MetadataTransformer_1 = require("./features/miscellaneous/MetadataTransformer");
var AssertParseTransformer_1 = require("./features/parsers/AssertParseTransformer");
var CreateAssertParseTransformer_1 = require("./features/parsers/CreateAssertParseTransformer");
var CreateIsParseTransformer_1 = require("./features/parsers/CreateIsParseTransformer");
var CreateValidateParseTransformer_1 = require("./features/parsers/CreateValidateParseTransformer");
var IsParseTransformer_1 = require("./features/parsers/IsParseTransformer");
var ValidateParseTransformer_1 = require("./features/parsers/ValidateParseTransformer");
var AssertStringifyTransformer_1 = require("./features/stringifiers/AssertStringifyTransformer");
var CreateAssertStringifyTransformer_1 = require("./features/stringifiers/CreateAssertStringifyTransformer");
var CreateIsStringifyTransformer_1 = require("./features/stringifiers/CreateIsStringifyTransformer");
var CreateStringifyTransformer_1 = require("./features/stringifiers/CreateStringifyTransformer");
var CreateValidateStringifyProgrammer_1 = require("./features/stringifiers/CreateValidateStringifyProgrammer");
var IsStringifyTransformer_1 = require("./features/stringifiers/IsStringifyTransformer");
var StringifyTransformer_1 = require("./features/stringifiers/StringifyTransformer");
var ValidateStringifyTransformer_1 = require("./features/stringifiers/ValidateStringifyTransformer");
var AssertTransformer_1 = require("./features/validators/AssertTransformer");
var CreateAssertTransformer_1 = require("./features/validators/CreateAssertTransformer");
var CreateIsTransformer_1 = require("./features/validators/CreateIsTransformer");
var CreateValidateTransformer_1 = require("./features/validators/CreateValidateTransformer");
var IsTransformer_1 = require("./features/validators/IsTransformer");
var ValidateTransformer_1 = require("./features/validators/ValidateTransformer");
var CallExpressionTransformer;

@@ -23,3 +39,3 @@ (function (CallExpressionTransformer) {

var file = path_1.default.resolve(declaration.getSourceFile().fileName);
if (file !== LIB_PATH && file !== SRC_PATH)
if (file.indexOf(LIB_PATH) === -1 && file !== SRC_PATH)
return expression;

@@ -34,5 +50,6 @@ var name = project.checker.getTypeAtLocation(declaration).symbol.name;

})(CallExpressionTransformer = exports.CallExpressionTransformer || (exports.CallExpressionTransformer = {}));
var LIB_PATH = path_1.default.resolve(path_1.default.join(__dirname, "..", "module.d.ts"));
var LIB_PATH = path_1.default.join("node_modules", "typia", "lib", "module.d.ts");
var SRC_PATH = path_1.default.resolve(path_1.default.join(__dirname, "..", "module.ts"));
var FUNCTORS = {
assert: function () { return AssertTransformer_1.AssertTransformer.transform(false); },
assertType: function () { return AssertTransformer_1.AssertTransformer.transform(false); },

@@ -44,6 +61,26 @@ is: function () { return IsTransformer_1.IsTransformer.transform(false); },

validateEquals: function () { return ValidateTransformer_1.ValidateTransformer.transform(true); },
isParse: function () { return IsParseTransformer_1.IsParseTransformer.transform; },
assertParse: function () { return AssertParseTransformer_1.AssertParseTransformer.transform; },
validateParse: function () { return ValidateParseTransformer_1.ValidateParseTransformer.transform; },
stringify: function () { return StringifyTransformer_1.StringifyTransformer.transform; },
assertStringify: function () { return AssertStringifyTransformer_1.AssertStringifyTransformer.transform; },
isStringify: function () { return IsStringifyTransformer_1.IsStringifyTransformer.transform; },
validateStringify: function () { return ValidateStringifyTransformer_1.ValidateStringifyTransformer.transform; },
application: function () { return ApplicationTransformer_1.ApplicationTransformer.transform; },
create: function () { return CreateTransformer_1.CreateTransformer.transform; },
stringify: function () { return StringifyTransformer_1.StringifyTransformer.transform; },
metadata: function () { return MetadataTransformer_1.MetadataTransformer.transform; },
createAssert: function () { return CreateAssertTransformer_1.CreateAssertTransformer.transform(false); },
createAssertType: function () { return CreateAssertTransformer_1.CreateAssertTransformer.transform(false); },
createIs: function () { return CreateIsTransformer_1.CreateIsTransformer.transform(false); },
createValidate: function () { return CreateValidateTransformer_1.CreateValidateTransformer.transform(false); },
createAssertEquals: function () { return CreateAssertTransformer_1.CreateAssertTransformer.transform(true); },
createEquals: function () { return CreateIsTransformer_1.CreateIsTransformer.transform(true); },
createValidateEquals: function () { return CreateValidateTransformer_1.CreateValidateTransformer.transform(true); },
createIsParse: function () { return CreateIsParseTransformer_1.CreateIsParseTransformer.transform; },
createAssertParse: function () { return CreateAssertParseTransformer_1.CreateAssertParseTransformer.transform; },
createValidateParse: function () { return CreateValidateParseTransformer_1.CreateValidateParseTransformer.transform; },
createStringify: function () { return CreateStringifyTransformer_1.CreateStringifyTransformer.transform; },
createAssertStringify: function () { return CreateAssertStringifyTransformer_1.CreateAssertStringifyTransformer.transform; },
createIsStringify: function () { return CreateIsStringifyTransformer_1.CreateIsStringifyTransformer.transform; },
createValidateStringify: function () { return CreateValidateStringifyProgrammer_1.CreateValidateStringifyTransformer.transform; },
};
//# sourceMappingURL=CallExpressionTransformer.js.map

@@ -29,3 +29,3 @@ "use strict";

var _a = file.getLineAndCharacterOfPosition(node.pos), line = _a.line, character = _a.character;
exp.message += " - ".concat(file.fileName, ".").concat(line + 1, ":").concat(character + 1);
exp.message += " - ".concat(file.fileName, ":").concat(line + 1, ":").concat(character + 1);
throw exp;

@@ -32,0 +32,0 @@ }

import { OmitNever } from "./OmitNever";
export declare type ClassProperties<T extends object> = OmitNever<{
export type ClassProperties<T extends object> = OmitNever<{
[K in keyof T]: T[K] extends Function ? never : T[K];
}>;
import { SpecialFields } from "./SpecialFields";
export declare type OmitNever<T extends object> = Omit<T, SpecialFields<T, never>>;
export type OmitNever<T extends object> = Omit<T, SpecialFields<T, never>>;

@@ -1,3 +0,3 @@

export declare type SpecialFields<Instance extends object, Target> = {
export type SpecialFields<Instance extends object, Target> = {
[P in keyof Instance]: Instance[P] extends Target ? P : never;
}[keyof Instance & string];
import { ClassProperties } from "./ClassProperties";
export declare type Writable<T extends object> = {
export type Writable<T extends object> = {
-readonly [P in keyof T]: T[P];
};
export declare function Writable<T extends object>(elem: T): Writable<ClassProperties<T>>;

@@ -31,3 +31,3 @@ "use strict";

return str
.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&")
.replace(/[|\\/{}()[\]^$+*?.]/g, "\\$&")
.replace(/-/g, "\\x2d");

@@ -34,0 +34,0 @@ }

{
"name": "typia",
"version": "3.3.12",
"version": "3.4.0-dev.20221212",
"description": "Runtime type checkers and 5x faster JSON.stringify() function",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"bin": {
"typia": "./lib/executable/typia.js"
},
"scripts": {
"benchmark": "node benchmark/index.js",
"benchmark": "npm run build:test && node bin/benchmark",
"build": "rimraf lib && ttsc --removeComments --declaration false && ttsc --emitDeclarationOnly",
"build:test": "rimraf bin && ttsc -p tsconfig.test.json && prettier --write ./bin/**/*.js",
"build:test": "rimraf bin && ttsc -p tsconfig.test.json",
"build:test:prettier": "npm run build:test && prettier --write ./bin/**/*.js",
"dev": "npm run build -- --watch",

@@ -16,4 +20,6 @@ "dev:test": "rimraf bin && ttsc -p tsconfig.test.json --watch",

"issue": "node test/issue",
"publish": "ts-node build/publish.ts",
"prettier": "prettier --write ./**/*.ts",
"test": "node test",
"test": "node bin/test",
"test:generate": "ts-node -P tsconfig.test.json build/test.ts",
"test:manual": "node test/manual",

@@ -24,3 +30,3 @@ "test:application:replace": "node test/features/application/replace && npm run prettier"

"type": "git",
"url": "https://github.com/samchon/typescript-json"
"url": "https://github.com/samchon/typia"
},

@@ -39,2 +45,3 @@ "keywords": [

"assert",
"clone",
"is",

@@ -45,4 +52,7 @@ "validate",

"type",
"typebox",
"checker",
"validator"
"validator",
"safe",
"parse"
],

@@ -52,14 +62,25 @@ "author": "Jeongho Nam",

"bugs": {
"url": "https://github.com/samchon/typescript-json/issues"
"url": "https://github.com/samchon/typia/issues"
},
"homepage": "https://github.com/samchon/typescript-json#readme",
"homepage": "https://github.com/samchon/typia#readme",
"peerDependencies": {
"ttypescript": ">= 1.5.15",
"typescript": ">= 4.5.2"
},
"devDependencies": {
"@fastify/type-provider-typebox": "^2.3.0",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"@types/autocannon": "^7.9.0",
"@types/benchmark": "^2.1.2",
"@types/cli": "^0.11.20",
"@types/d3": "^7.4.0",
"@types/express": "^4.17.14",
"@types/jsdom": "^20.0.0",
"@types/nested-error-stacks": "^2.1.0",
"@types/node": "^17.0.24",
"@types/physical-cpu-count": "^2.0.0",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"autocannon": "^7.10.0",
"benchmark": "^2.1.4",

@@ -70,4 +91,11 @@ "chalk": "^4.1.0",

"cli": "^1.0.1",
"comment-json": "^4.2.3",
"d3": "^5.16.0",
"eslint-plugin-deprecation": "^1.3.2",
"express": "^4.18.2",
"fast-json-stringify": "^5.4.0",
"fastify": "^4.9.2",
"io-ts": "^2.2.19",
"jsdom": "^20.0.2",
"physical-cpu-count": "^2.0.0",
"prettier": "^2.6.2",

@@ -77,9 +105,17 @@ "reflect-metadata": "^0.1.13",

"sloc": "^0.2.1",
"source-map-support": "^0.5.21",
"suppress-warnings": "^1.0.2",
"ts-node": "^10.9.1",
"ttypescript": "^1.5.13",
"typescript": "^4.8.4",
"ttypescript": "^1.5.15",
"typescript": "^4.9.4",
"uuid": "^8.3.2",
"zod": "^3.19.1"
}
}
},
"files": [
"LICENSE",
"README.md",
"package.json",
"lib",
"src"
]
}

@@ -1,111 +0,97 @@

# TypeScript-JSON
Super-fast Runtime validators and `JSON.stringify()` functions, with only one line.
# Typia
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/typia/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/typia.svg)](https://www.npmjs.com/package/typia)
[![Downloads](https://img.shields.io/npm/dm/typia.svg)](https://www.npmjs.com/package/typia)
[![Build Status](https://github.com/samchon/typia/workflows/build/badge.svg)](https://github.com/samchon/typia/actions?query=workflow%3Abuild)
[![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/samchon/typia/wiki)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/typescript-json/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/typescript-json.svg)](https://www.npmjs.com/package/typescript-json)
[![Downloads](https://img.shields.io/npm/dm/typescript-json.svg)](https://www.npmjs.com/package/typescript-json)
[![Build Status](https://github.com/samchon/typescript-json/workflows/build/badge.svg)](https://github.com/samchon/typescript-json/actions?query=workflow%3Abuild)
[![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/samchon/typescript-json/wiki)
- Github: https://github.com/samchon/typescript-json
- NPM: https://www.npmjs.com/package/typescript-json
- Guide Documents: https://github.com/samchon/typescript-json/wiki
```typescript
import TSON from "typescript-json";
//----
// RUNTIME VALIDATORS
//----
// ALLOW SUPERFLUOUS PROPERTIES
TSON.assertType<T>(input); // throws exception
TSON.is<T>(input); // returns boolean value
TSON.validate<T>(input); // archives all errors
export function is<T>(input: unknown | T): input is T; // returns boolean
export function assert<T>(input: unknown | T): T; // throws TypeGuardError
export function validate<T>(input: unknown | T): IValidation<T>; // detailed
// DO NOT ALLOW SUPERFLUOUS PROPERTIES
TSON.equals<T>(input); // returns boolean value
TSON.assertEquals<T>(input); // throws exception
TSON.validateEquals<T>(input); // archives all errors
// STRICT VALIDATORS
export function equals<T>(input: unknown: T): input is T;
export function assertEquals<T>(input: unknown | T): T;
export function validateEquals<T>(input: unknown | T): IValidation<T>;
//----
// APPENDIX FUNCTIONS
//----
TSON.stringify<T>(input); // 5x faster JSON.stringify()
TSON.application<[T, U, V], "swagger">(); // JSON schema application generator
TSON.create<T>(input); // 2x faster object creator (only one-time construction)
// JSON
export function application<T>(): IJsonApplication; // JSON schema
export function assertParse<T>(input: string): T; // type safe parser
export function assertStringify<T>(input: T): string; // safe and faster
// +) isParse, validateParse
// +) stringify, isStringify, validateStringify
```
`typescript-json` is a transformer library providing JSON related functions.
`typia` is a transformer library of TypeScript, supporting below features:
- Powerful Runtime type checkers:
- Performed by only one line, `TSON.assertType<T>(input)`
- Only one library which can validate union type
- Maximum 2,000x faster than other libraries
- 5x faster `JSON.stringify()` function:
- Performed by only one line: `TSON.stringify<T>(input)`
- Only one library which can stringify union type
- 10,000x faster optimizer construction time than similar libraries
- Super-fast Runtime Validators
- Safe JSON parse and fast stringify functions
- JSON schema generator
![Is Function Benchmark](https://user-images.githubusercontent.com/13158709/196679891-d06ef698-603b-49f8-98c8-d140b813a06d.png)
All functions in `typia` require **only one line**. You don't need any extra dedication like JSON schema definitions or decorator function calls. Just call `typia` function with only one line like `typia.assert<T>(input)`.
> Measured on AMD R9 5900HX, ASUS Rog Strix G15 (numeric option: `false`)
Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance is much faster than other competitive libaries. For an example, when comparing validate function `is()` with other competitive libraries, `typia` is maximum **15,000x times faster** than `class-validator`.
![Is Function Benchmark](https://github.com/samchon/typia/raw/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz/images/is.svg)
> Measured on [Intel i5-1135g7, Surface Pro 8](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz#is)
## Setup
### NPM Package
At first, install this `typescript-json` by the `npm install` command.
Also, you need additional `devDependencies` to compile the TypeScript code with transformation. Therefore, install those all libraries `typescript`, `ttypescript` and `ts-node`. Inform that, `ttypescript` is not mis-writing. Do not forget to install the `ttypescript`.
## Setup
### Setup Wizard
```bash
npm install --save typescript-json
# ENSURE THOSE PACKAGES ARE INSTALLED
npm install --save-dev typescript
npm install --save-dev ttypescript
npm install --save-dev ts-node
npx typia setup
```
### tsconfig.json
After the installation, you've to configure `tsconfig.json` file like below.
Just type `npx typia setup`, that's all.
Add a property `transform` and its value as `typescript-json/lib/transform` into `compilerOptions.plugins` array. When configuring, I recommend you to use the `strict` option, to enforce developers to distinguish whether each property is nullable or undefindable.
After the setup, you can compile `typia` utilized code by using `ttsc` ([`ttypescript`](https://github.com/cevek/ttypescript)) command. If you want to run your TypeScript file directly through `ts-node`, add `-C ttypescript` argument like below:
Also, you can configure additional properties like `numeric` and `functional`. The first, `numeric` is an option whether to test `Number.isNaN()` and `Number.isFinite()` to numeric value or not. The second, `functional` is an option whether to test function type or not. Default values of those options are all `true`.
<!-- ```bash
# COMPILE THROUGH TTYPESCRIPT
npx ttsc
```typescript
{
"compilerOptions": {
"strict": true,
"plugins": [
{
"transform": "typescript-json/lib/transform",
// "functional": true, // test function type
// "numeric": true, // test `isNaN()` and `isFinite()`
}
]
}
}
# RUN TS-NODE WITH TTYPESCRIPT
npx ts-node -C ttypescript src/index.ts
```
After the `tsconfig.json` definition, you can compile `typescript-json` utilized code by using `ttypescript`. If you want to run your TypeScript file through `ts-node`, use `-C ttypescript` argument like below:
> If you want to use only `tsc` command, you can choose another option: [`ts-patch`](https://github.com/nonara/ts-patch).
>
> Set it up through `npx typia setup ts-patch` command and compile your project with pure(?) TypeScript compiler (`tsc`). When you want to run your TypeScript file directly, just use the pure `ts-node`, too.
>
> However, note that, the `ts-patch` will modify JavaScript files in `node_modules/typescript` directly. Therefore, it may cause some problems when you update typescript version after the `setup` process, until running `npm run prepare` command.
>
> ```bash
> # SETUP
> npx typia setup ts-patch
>
> #COMPILE
> npx tsc
> npx ts-node src/index.ts
>
> # AFTER UPDATE, HAVE TO RUN PREPARE COMMAND
> npm install --save-dev typescript@latest
> npm run prepare
> ``` -->
```bash
# COMPILE
npx ttsc
### Manual Setup
If you want to install and setup `typia` manually, read [Guide Documents - Setup](https://github.com/samchon/typia/wiki/Setup).
# WITH TS-NODE
npx ts-node -C ttypescript
```
- [NPM Packages](https://github.com/samchon/typia/wiki/Setup#npm-packages)
- [`tsconfig.json`](https://github.com/samchon/typia/wiki/Setup#tsconfigjson)
- [vite](https://github.com/samchon/typia/wiki/Setup#vite)
- [webpack](https://github.com/samchon/typia/wiki/Setup#webpack)
### vite
Just open `vite.config.ts` file and assign `typescript: ttsc` property like below.
When you want to setup `typia` on your frontend project with [`vite`](https://vitejs.dev/), just configure `vite.config.ts` like below.
For reference, don't forget configuring [`tsconfig.json`](#tsconfigjson) file of above.
For reference, don't forget [setting up](#setup) before.
```typescript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import typescript from "@rollup/plugin-typescript";

@@ -125,152 +111,86 @@ import ttsc from "ttypescript";

### webpack
If you're using `webpack` with `ts-loader`, configure the `webpack.config.js` file like below.
```javascript
const transform = require("typescript-json/lib/transform").default;
module.exports = {
// I am hiding the rest of the webpack config
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
getCustomTransformers: program => ({
before: [transform(program)]
// before: [
// transform(program, {
// functional: true,
// numeric: true
// })
// ]
})
}
}
]
}
};
```
## Features
[![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/samchon/typia/wiki)
In here README documents, only summarized informations are provided.
For more details, please refer to the [Guide Documents (wiki)](https://github.com/samchon/typia/wiki).
## Features
> - **Runtime Validators**
> - [powerful validator](https://github.com/samchon/typia/wiki/Runtime-Validators#powerful-validator)
> - [`is()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#is-function)
> - [`assert()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#assert-function)
> - [`validate()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#validate-function)
> - [strict validators](https://github.com/samchon/typia/wiki/Runtime-Validators#strict-validators)
> - [factory functions](https://github.com/samchon/typia/wiki/Runtime-Validators#factory-functions)
> - [comment tags](https://github.com/samchon/typia/wiki/Runtime-Validators#comment-tags)
> - **Enhanced JSON**
> - [JSON schema](https://github.com/samchon/typia/wiki/Enhanced-JSON#json-schema)
> - [`parse()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#parse-functions)
> - [`stringify()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#stringify-functions)
> - [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
### Runtime Validators
```typescript
// ALLOW SUPERFLUOUS PROPERTIES
export function is<T>(input: T): boolean; // true or false
export function assertType<T>(input: T): T; // throws `TypeGuardError`
export function validate<T>(input: T): IValidation; // detailed reasons
export function is<T>(input: T | unknown): input is T; // returns boolean
export function assert<T>(input: T | unknown): T; // throws `TypeGuardError`
export function validate<T>(input: T | unknown): IValidation<T>; // detailed
// DO NOT ALLOW SUPERFLUOUS PROPERTIES
export function equals<T>(input: T): boolean;
export function assertEquals<T>(input: T): T;
export function validateEquals<T>(input: T): IValidation;
export function equals<T>(input: T | unknown): boolean;
export function assertEquals<T>(input: T | unknown): T;
export function validateEquals<T>(input: T | unknown): IValidation<T>;
export interface IValidation {
success: boolean;
errors: IValidation.IError[];
}
export namespace IValidation {
export interface IError {
path: string;
expected: string;
value: any;
}
}
export class TypeGuardError extends Error {
public readonly method: string;
public readonly path: string | undefined;
public readonly expected: string;
public readonly value: any;
}
// REUSABLE FACTORY FUNCTIONS
export function createIs<T>(): (input: unknown) => T;
export function createAssert<T>(): (input: unknown) => T;
export function createValidate<T>(): (input: unknown) => IValidation<T>;
export function createEquals<T>(): (input: unknown) => boolean;
export function createAssertEquals<T>(): (input: unknown) => T;
export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
```
> You can enhance type constraint more by using [**Comment Tags**](#comment-tags).
`typia` supports three type of validator functions:
`typescript-json` provides three basic validator functions.
- `is()`: returns `false` if not matched with the type `T`
- `assert()`: throws a [`TypeGuardError`](https://github.com/samchon/typia/blob/master/src/TypeGuardError.ts) when not matched
- `validate()`
- when matched, returns [`IValidation.ISuccess<T>`](https://github.com/samchon/typia/blob/master/src/IValidation.ts) with `value` property
- when not matched, returns [`IValidation.IFailure`](https://github.com/samchon/typia/blob/master/src/IValidation.ts) with `errors` property
The first, `assertType()` is a function throwing `TypeGuardError` when an `input` value is different with its type, generic argument `T`. The second function, `is()` returns a `boolean` value meaning whether matched or not. The last `validate()` function archives all type errors into an `IValidation.errors` array.
Also, if you want more strict validator functions that even do not allowing superfluous properties not written in the type `T`, you can use those functions instead; `equals()`, `assertEquals()`, `validateEquals()`. Otherwise you want to create resuable validator functions, you can utilize factory functions like `createIs()` instead.
If you want much strict validators that do not allow superfluous properties, you can use below functions instead. `assertEquals()` function throws `TypeGuardError`, `equals()` function returns `boolean` value, and `validateEquals()` function archives all type errors into an `IValidation.errors` array.
When you want to add special validation logics, like limiting range of numeric values, you can do it through comment tags. If you want to know about it, please visit the Guide Documents ([Features > Runtime Validators > Comment Tags](https://github.com/samchon/typia/wiki/Runtime-Validators#comment-tags)).
Basic | Strict
------|--------
`assertType` | `assertEquals`
`is` | `equals`
`validate` | `validateEquals`
<!-- > By the way, comparing those validator functions with other competitive libaries, you can find that only `typia` is able to validate complicate union type. It is because `typia` is supporting entire TypeScript type specs. Therefore, adapt `typia` with confidence. It can validate everything.
>
> Moreover, validation speed of `typia` is extremely faster than any other validation libraries. For an example, `typia` is maximum 15,000x times faster than `class-validator`. Visit [benchmarks](https://github.com/samchon/typia/wiki/Benchmarks#validate-functions) section of Guide Documents and feel how fast `typia` is.
>
> Components | `typia` | `TypeBox` | `ajv` | `io-ts` | `zod` | `C.V.`
> -------------------------|--------|-----------|-------|---------|-------|------------------
> **Easy to use** | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
> [Object (simple)](https://github.com/samchon/typia/blob/master/test/structures/ObjectSimple.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
> [Object (hierarchical)](https://github.com/samchon/typia/blob/master/test/structures/ObjectHierarchical.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
> [Object (recursive)](https://github.com/samchon/typia/blob/master/test/structures/ObjectRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ | ✔
> [Object (union, implicit)](https://github.com/samchon/typia/blob/master/test/structures/ObjectUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
> [Object (union, explicit)](https://github.com/samchon/typia/blob/master/test/structures/ObjectUnionExplicit.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ❌
> [Object (additional tags)](https://github.com/samchon/typia/#comment-tags) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
> [Object (template literal types)](https://github.com/samchon/typia/blob/master/test/structures/TemplateUnion.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
> [Object (dynamic properties)](https://github.com/samchon/typia/blob/master/test/structures/DynamicTemplate.ts) | ✔ | ✔ | ✔ | ❌ | ❌ | ❌
> [Array (hierarchical)](https://github.com/samchon/typia/blob/master/test/structures/ArrayHierarchical.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔
> [Array (recursive)](https://github.com/samchon/typia/blob/master/test/structures/ArrayRecursive.ts) | ✔ | ✔ | ✔ | ✔ | ✔ | ❌
> [Array (recursive, union)](https://github.com/samchon/typia/blob/master/test/structures/ArrayRecursiveUnionExplicit.ts) | ✔ | ✔ | ❌ | ✔ | ✔ | ❌
> [Array (R+U, implicit)](https://github.com/samchon/typia/blob/master/test/structures/ArrayRecursiveUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
> [**Ultimate Union Type**](https://github.com/samchon/typia/blob/master/src/schemas/IJsonSchema.ts) | ✅ | ❌ | ❌ | ❌ | ❌ | ❌
>
> - typia: `typia`
> - C.V.: `class-validator` -->
### Enhanced JSON
```typescript
interface IPerson {
name: string;
age: number;
}
const person = {
name: "Jeongho Nam",
age: 34,
account: "samchon", // superfluous property
};
TSON.is<IPerson>(person); // -> true, allow superfluous property
TSON.equals<IPerson>(person); // -> false, do not allow
```
Comparing those type checker functions with other similar libraries, `typescript-json` is much easier than others. For example, `ajv` requires complicate JSON schema definition that is different with the TypeScript type. Besides, `typescript-json` requires only one line.
Also, only `typescript-json` can validate union typed structure exactly. All the other libraries can check simple object type, however, none of them can validate complicate union type. The fun thing is, `ajv` requires JSON schema definition for validation, but it can't validate the JSON schema type. How contradict it is.
Components | `TSON` | `ajv` | `io-ts` | `zod` | `C.V.`
-------------------------|-------------------|-----------------|-------|---------|------------------
**Easy to use** | ✅ | ❌ | ❌ | ❌ | ❌
[Object (simple)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectSimple.ts) | ✔ | ✔ | ✔ | ✔ | ✔
[Object (hierarchical)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectHierarchical.ts) | ✔ | ❌ | ✔ | ✔ | ✔
[Object (recursive)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔ | ✔
[Object (union, implicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌
[Object (union, explicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectUnionExplicit.ts) | ✔ | ✔ | ✔ | ✔ | ❌
[Object (additional tags)](https://github.com/samchon/typescript-json/#comment-tags) | ✔ | ✔ | ✔ | ✔ | ✔
[Object (template literal types)](https://github.com/samchon/typescript-json/blob/master/test/structures/TemplateUnion.ts) | ✔ | ✔ | ❌ | ❌ | ❌
[Object (dynamic properties)](https://github.com/samchon/typescript-json/blob/master/test/structures/DynamicTemplate.ts) | ✔ | ✔ | ❌ | ❌ | ❌
[Array (hierarchical)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayHierarchical.ts) | ✔ | ✔ | ✔ | ✔ | ✔
[Array (recursive)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔
[Array (recursive, union)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursiveUnionExplicit.ts) | ✔ | ❌ | ✔ | ✔ | ❌
[Array (R+U, implicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursiveUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌
[**Ultimate Union Type**](https://github.com/samchon/typescript-json/blob/master/src/schemas/IJsonSchema.ts) | ✅ | ❌ | ❌ | ❌ | ❌
> - TSON: `typescript-json`
> - C.V.: `class-validator`
Furthermore, when union type comes, `typescript-json` is extremely faster than others.
As you can see from the above table, `ajv` and `typescript-is` are fallen in the most union type cases. Also, they're even showing a huge different from `typescript-json`, in the time benchmark that does not care whether the validation is exact or not.
The extreme different is shown in the "ultimate union" type, when validating [JSON schema](https://github.com/samchon/typescript-json/blob/master/src/schemas/IJsonSchema.ts).
![Super-fast runtime validator](https://user-images.githubusercontent.com/13158709/196680107-f4e77835-3380-4dde-9fa3-d9d419c046e2.png)
> Measured on Intel i5-1135g7, Surface Pro 8
### Fastest JSON String Converter
```typescript
export function stringify<T>(input: T): string;
```
Super-fast JSON string conversion function.
If you call `TSON.stringify()` function instead of the native `JSON.stringify()`, the JSON conversion time would be 5x times faster. Also, you can perform such super-fast JSON string conversion very easily, by only one line: `TSON.stringify<T>(input)`.
On the other side, other similary library like `fast-json-stringify` requires complicate JSON schema definition. Furthermore, `typescript-json` can convert complicate structured data that `fast-json-stringify` cannot convert.
Comparing performance, `typescript-json` is about 5x times faster when comparing only JSON string conversion time. If compare optimizer construction time, `typescript-json` is even 10,000x times faster.
![JSON conversion speed on each CPU](https://user-images.githubusercontent.com/13158709/177259522-791578dc-fa96-4d62-9c96-b22cb9575450.png)
> AMD CPU shows dramatic improvement
### JSON Schema Generation
```typescript
// JSON SCHEMA GENERATOR
export function application<

@@ -283,190 +203,36 @@ Types extends unknown[],

>(): IJsonApplication;
```
> You can enhance JSON schema more by using [**Comment Tags**](#comment-tags).
// SAFE PARSER FUNCTIONS
export function isParse<T>(input: string): T | null;
export function assertParse<T>(input: string): T;
export function validateParse<T>(input: string): IValidation<T>;
`typescript-json` even supports JSON schema application generation.
// FASTER STRINGIFY FUNCTIONS
export function stringify<T>(input: T): string; // unsafe
export function isStringify<T>(input: T): string | null; // safe
export function assertStringify<T>(input: T): string;
export function validateStringify<T>(input: T): IValidation<string>;
When you need to share your TypeScript types to other language, this `application()` function would be useful. It generates JSON schema definition by analyzing your `Types`. Therefore, with `typescript-json` and its `application()` function, you don't need to write JSON schema definition manually.
// FACTORY FUNCTIONS
export function createAssertParse<T>(): (input: string) => T;
export function createAssertStringify<T>(): (input: T) => string;
// +) createIsParse, createValidateParse
// +) createStringify, createIsStringify, createValidateStringify
```
By the way, the reason why you're using this `application()` is for generating a swagger documents, I recommend you to use my another library [nestia](https://github.com/samchon/nestia). It will automate the swagger documents generation, by analyzing your entire backend server code.
`typia` supports enhanced JSON functions.
### Comment Tags
You can enhance [Runtime Validators](#runtime-validators) and [JSON Schema Generator](#json-schema-generation) by writing comment tags.
- `application()`: generate JSON schema with only one line
- you can complement JSON schema contents through [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
- `assertParse()`: parse JSON string safely with type validation
- `isStringify()`: maximum 10x faster JSON stringify fuction even type safe
Below table shows list of supported comment tags. You can utilize those tags by writing in comments like below example structure `TagExample`. Look at them and utilize those comment tags to make your TypeScript program to be safer and more convenient.
![JSON string conversion speed](https://github.com/samchon/typia/raw/master/benchmark/results/AMD%20Ryzen%207%205800H%20with%20Radeon%20Graphics/images/stringify.svg)
Also, don't worry about taking a mistake on using those comment tags. In that case, compile error would be occured. By the compile level error detection, `typescript-json` is much stronger than any other runtime validator libraries using decorator functions, which can't catch any mistake on the compilation level.
> Measured on [AMD R7 5800H](https://github.com/samchon/typia/tree/master/benchmark/results/AMD%20Ryzen%207%205800H%20with%20Radeon%20Graphics#stringify)
Tag Kind | Target Type
------------|-----------------
`@type {"int"\|"uint"}` | number
`@range (number, number]` | number
`@minimum {number}` | number
`@maximum {number}` | number
`@exclusiveMinimum {number}` | number
`@exclusiveMaximum {number}` | number
`@multipleOf {number}` | number
`@step {number}` | number
`@length {number} \| [number, number)` | string
`@minLength {number}` | string
`@maxLength {number}` | string
`@format {"email"\|"uuid"\|"url"\|"ipv4"\|"ipv6"}` | string
`@pattern {string}` | string
`@items {number} \| [number, number)` | array
`@minItems {number}` | array
`@maxItems {number}` | array
```typescript
export interface TagExample {
/* -----------------------------------------------------------
ARRAYS
----------------------------------------------------------- */
/**
* You can limit array length like below.
*
* @minItems 3
* @maxItems 10
*
* Also, you can use `@items` tag instead.
*
* @items (5, 10] --> 5 < length <= 10
* @items [7 --> 7 <= length
* @items 12) --> length < 12
*
* Furthermore, you can use additional tags for each item.
*
* @type uint
* @format uuid
*/
array: Array<string|number>;
/**
* If two-dimensional array comes, length limit would work for
* both 1st and 2nd level arraies. Also using additional tags
* for each item (string) would still work.
*
* @items (5, 10)
* @format url
*/
matrix: string[][];
/* -----------------------------------------------------------
NUMBERS
----------------------------------------------------------- */
/**
* Type of number.
*
* It must be one of integer or unsigned integer.
*
* @type int
* @type uint
*/
type: number;
/**
* You can limit range of numeric value like below.
*
* @minimum 5
* @maximum 10
*
* Also, you can use `@range` tag instead.
*
* @range (5, 10] --> 5 < x <= 10
* @range [7 --> 7 <= x
* @range 12) --> x < 12
*/
range: number;
/**
* Step tag requires minmum or exclusiveMinimum tag.
*
* 3, 13, 23, 33, ...
*
* @step 10
* @exclusiveMinimum 3
* @range [3
*/
step: number;
/**
* Value must be multiple of the given number.
*
* -5, 0, 5, 10, 15, ...
*
* @multipleOf 5
*/
multipleOf: number;
/* -----------------------------------------------------------
STRINGS
----------------------------------------------------------- */
/**
* You can limit string length like below.
*
* @minLength 3
* @maxLength 10
*
* Also, you can use `@length` tag instead.
*
* @length 10 --> length = 10
* @length [3, 7] --> 3 <= length && length <= 7
* @length (5, 10) --> 5 < length && length < 10
* @length [4 --> 4 < length
* @length 7) --> length < 7
*/
length: string;
/**
* Mobile number composed by only numbers.
*
* Note that, `typescript-json` does not support flag of regex,
* because JSON schema definition does not suppor it either.
* Therefore, write regex pattern without `/` characters and flag.
*
* @pattern ^0[0-9]{7,16}
* -> RegExp(/[0-9]{7,16}/).test("01012345678")
*/
mobile: string;
/**
* E-mail address.
*
* @format email
*/
email: string;
/**
* UUID value.
*
* @format uuid
*/
uuid: string;
/**
* URL address.
*
* @format url
*/
url: string;
/**
* IPv4 address.
*
* @format ipv4
*/
ipv4: string;
/**
* IPv6 address.
*
* @format ipv6
*/
ipv6: string;
}
```
## Appendix

@@ -556,5 +322,5 @@ ### Nestia

Helper library of `NestJS`, using this `typescript-json`.
Helper library of `NestJS`, using this `typia`.
`nestia-helper` is a helper library of `NestJS`, which boosts up the `JSON.stringify()` speed 5x times faster about the API responses, automatically. Also, `nestia-helper` supports automatic valiation of request body, too.
`nestia-helper` is a helper library of `NestJS`, which boosts up the `JSON.stringify()` speed 5x times faster about the API responses, automatically. Also, `nestia-helper` supports automatic validation of request body, that is maximum 15,000x times faster than legacy `class-validator` too.

@@ -568,6 +334,6 @@ ```typescript

{
// automatic TSON.stringify() for response body
// automatic typia.stringify() for response body
@helper.TypedRoute.Get()
public store(
// automatic TSON.assertType() for request body
// automatic typia.assert() for request body
@helper.TypedBody() input: IBbsArticle.IStore

@@ -574,0 +340,0 @@ ): Promise<IBbsArticle>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc