@nmtjs/type 0.14.5 → 0.15.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/dist/index.js +5 -1
- package/dist/types/_convert.js +55 -0
- package/dist/types/_type.js +1 -0
- package/dist/types/custom.js +21 -5
- package/dist/types/date.js +1 -0
- package/dist/types/null.js +9 -0
- package/dist/types/object.js +18 -2
- package/package.json +11 -25
- package/dist/index.d.ts +0 -4
- package/dist/temporal/global.d.ts +0 -8
- package/dist/temporal/polyfill.d.ts +0 -8
- package/dist/types/_plain.d.ts +0 -13
- package/dist/types/_type.d.ts +0 -32
- package/dist/types/any.d.ts +0 -6
- package/dist/types/array.d.ts +0 -14
- package/dist/types/base.d.ts +0 -65
- package/dist/types/boolean.d.ts +0 -6
- package/dist/types/custom.d.ts +0 -15
- package/dist/types/date.d.ts +0 -7
- package/dist/types/enum.d.ts +0 -10
- package/dist/types/literal.d.ts +0 -9
- package/dist/types/never.d.ts +0 -6
- package/dist/types/number.d.ts +0 -23
- package/dist/types/object.d.ts +0 -52
- package/dist/types/string.d.ts +0 -22
- package/dist/types/temporal.d.ts +0 -26
- package/dist/types/tuple.d.ts +0 -14
- package/dist/types/union.d.ts +0 -42
- /package/dist/types/{_plain.js → _utils.js} +0 -0
package/LICENSE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2025 Denys Ilchyshyn
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { en } from 'zod/locales';
|
|
2
2
|
import { config } from 'zod/mini';
|
|
3
3
|
import * as type from "./types/_type.js";
|
|
4
|
-
|
|
4
|
+
export * from "./types/_convert.js";
|
|
5
|
+
export * from "./types/_utils.js";
|
|
5
6
|
export * from "./types/base.js";
|
|
6
7
|
export { type, type as t };
|
|
7
8
|
export default type;
|
|
9
|
+
export function registerDefaultLocale() {
|
|
10
|
+
config(en());
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { toJSONSchema } from 'zod/mini';
|
|
2
|
+
import { AnyType } from "./any.js";
|
|
3
|
+
import { ArrayType } from "./array.js";
|
|
4
|
+
import { NullableType, OptionalType } from "./base.js";
|
|
5
|
+
import { BooleanType } from "./boolean.js";
|
|
6
|
+
import { CustomType } from "./custom.js";
|
|
7
|
+
import { DateType } from "./date.js";
|
|
8
|
+
import { LiteralType } from "./literal.js";
|
|
9
|
+
import { NumberType } from "./number.js";
|
|
10
|
+
import { ObjectType } from "./object.js";
|
|
11
|
+
import { StringType } from "./string.js";
|
|
12
|
+
import { TupleType } from "./tuple.js";
|
|
13
|
+
export function typeToString(type) {
|
|
14
|
+
switch (true) {
|
|
15
|
+
case type instanceof OptionalType:
|
|
16
|
+
return `?<${typeToString(type.props.inner)}>`;
|
|
17
|
+
case type instanceof NullableType:
|
|
18
|
+
return `null | ${typeToString(type.props.inner)}`;
|
|
19
|
+
case type instanceof StringType:
|
|
20
|
+
return 'string';
|
|
21
|
+
case type instanceof NumberType:
|
|
22
|
+
return 'number';
|
|
23
|
+
case type instanceof LiteralType:
|
|
24
|
+
return `literal(${type.props.value})`;
|
|
25
|
+
case type instanceof BooleanType:
|
|
26
|
+
return 'boolean';
|
|
27
|
+
case type instanceof DateType:
|
|
28
|
+
return 'string';
|
|
29
|
+
case type instanceof ArrayType:
|
|
30
|
+
return `array<${typeToString(type.props.element)}>`;
|
|
31
|
+
case type instanceof ObjectType: {
|
|
32
|
+
const props = type.props.properties;
|
|
33
|
+
const propsStrings = Object.keys(props).map((key) => `${key}: ${typeToString(props[key])}`);
|
|
34
|
+
return `{ ${propsStrings.join(', ')} }`;
|
|
35
|
+
}
|
|
36
|
+
case type instanceof TupleType: {
|
|
37
|
+
const elements = type.props.elements;
|
|
38
|
+
const elementsStrings = elements.map((el) => typeToString(el));
|
|
39
|
+
const rest = type.props.rest
|
|
40
|
+
? `, ...${typeToString(type.props.rest)}`
|
|
41
|
+
: '';
|
|
42
|
+
return `[${elementsStrings.join(', ')}${rest}]`;
|
|
43
|
+
}
|
|
44
|
+
case type instanceof AnyType:
|
|
45
|
+
return 'any';
|
|
46
|
+
case type instanceof CustomType:
|
|
47
|
+
return typeToJsonSchema(type, 'decode').type || 'custom';
|
|
48
|
+
default:
|
|
49
|
+
return 'unknown';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function typeToJsonSchema(type, mode, options) {
|
|
53
|
+
const zodType = { encode: type.encodeZodType, decode: type.decodeZodType }[mode];
|
|
54
|
+
return toJSONSchema(zodType, options);
|
|
55
|
+
}
|
package/dist/types/_type.js
CHANGED
package/dist/types/custom.js
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
import { any, overwrite, pipe, refine, custom as zodCustom } from 'zod/mini';
|
|
1
|
+
import { any, overwrite, pipe, refine, superRefine, custom as zodCustom, } from 'zod/mini';
|
|
2
2
|
import { BaseType } from "./base.js";
|
|
3
3
|
export class TransformType extends BaseType {
|
|
4
4
|
}
|
|
5
5
|
export class CustomType extends TransformType {
|
|
6
|
-
static factory({ decode, encode, error, type = any(), }) {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
static factory({ decode, encode, validation, error, type = any(), prototype, }) {
|
|
7
|
+
const _validation = validation
|
|
8
|
+
? typeof validation === 'function'
|
|
9
|
+
? { encode: validation, decode: validation }
|
|
10
|
+
: validation
|
|
11
|
+
: undefined;
|
|
12
|
+
const instance = new CustomType({
|
|
13
|
+
encodeZodType: pipe(zodCustom().check(...[
|
|
14
|
+
refine((val) => typeof val !== 'undefined', { abort: true }),
|
|
15
|
+
_validation?.encode ? superRefine(_validation.encode) : undefined,
|
|
16
|
+
overwrite(encode),
|
|
17
|
+
].filter((v) => !!v)), type),
|
|
9
18
|
decodeZodType: pipe(type,
|
|
10
19
|
// @ts-expect-error
|
|
11
|
-
zodCustom().check(
|
|
20
|
+
zodCustom().check(...[
|
|
21
|
+
refine((val) => typeof val !== 'undefined', { abort: true }),
|
|
22
|
+
overwrite(decode),
|
|
23
|
+
_validation?.decode ? superRefine(_validation.decode) : undefined,
|
|
24
|
+
].filter((v) => !!v))),
|
|
12
25
|
params: { encode },
|
|
13
26
|
});
|
|
27
|
+
if (prototype)
|
|
28
|
+
Object.setPrototypeOf(instance, prototype);
|
|
29
|
+
return instance;
|
|
14
30
|
}
|
|
15
31
|
}
|
|
16
32
|
export const custom = CustomType.factory;
|
package/dist/types/date.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { null as zodNull } from 'zod/mini';
|
|
2
|
+
import { BaseType } from "./base.js";
|
|
3
|
+
export class NullType extends BaseType {
|
|
4
|
+
static factory() {
|
|
5
|
+
return new NullType({ encodeZodType: zodNull() });
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
const _null = NullType.factory;
|
|
9
|
+
export { _null as null };
|
package/dist/types/object.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { object as zodObject, record as zodRecord } from 'zod/mini';
|
|
2
|
-
import { zodPlainType } from "./
|
|
1
|
+
import { looseObject as zodLooseObject, object as zodObject, record as zodRecord, } from 'zod/mini';
|
|
2
|
+
import { zodPlainType } from "./_utils.js";
|
|
3
3
|
import { BaseType } from "./base.js";
|
|
4
4
|
import { EnumType } from "./enum.js";
|
|
5
5
|
export class ObjectType extends BaseType {
|
|
@@ -17,6 +17,21 @@ export class ObjectType extends BaseType {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
export class LooseObjectType extends BaseType {
|
|
21
|
+
static factory(properties) {
|
|
22
|
+
const encodeProperties = {};
|
|
23
|
+
const decodeProperties = {};
|
|
24
|
+
for (const key in properties) {
|
|
25
|
+
encodeProperties[key] = properties[key].encodeZodType;
|
|
26
|
+
decodeProperties[key] = properties[key].decodeZodType;
|
|
27
|
+
}
|
|
28
|
+
return new LooseObjectType({
|
|
29
|
+
encodeZodType: zodLooseObject(encodeProperties),
|
|
30
|
+
decodeZodType: zodLooseObject(decodeProperties),
|
|
31
|
+
props: { properties },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
20
35
|
export class RecordType extends BaseType {
|
|
21
36
|
static factory(key, element) {
|
|
22
37
|
return new RecordType({
|
|
@@ -57,4 +72,5 @@ export function partial(object) {
|
|
|
57
72
|
return ObjectType.factory(properties);
|
|
58
73
|
}
|
|
59
74
|
export const object = ObjectType.factory;
|
|
75
|
+
export const looseObject = LooseObjectType.factory;
|
|
60
76
|
export const record = RecordType.factory;
|
package/package.json
CHANGED
|
@@ -7,48 +7,34 @@
|
|
|
7
7
|
"README.md"
|
|
8
8
|
],
|
|
9
9
|
"exports": {
|
|
10
|
-
".":
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
"./*": {
|
|
16
|
-
"types": "./dist/types/*.d.ts",
|
|
17
|
-
"import": "./dist/types/*.js",
|
|
18
|
-
"module-sync": "./dist/types/*.js"
|
|
19
|
-
},
|
|
20
|
-
"./temporal": {
|
|
21
|
-
"types": "./dist/temporal/global.d.ts",
|
|
22
|
-
"import": "./dist/temporal/global.js",
|
|
23
|
-
"module-sync": "./dist/temporal/global.js"
|
|
24
|
-
},
|
|
25
|
-
"./temporal-polyfill": {
|
|
26
|
-
"types": "./dist/temporal/polyfill.d.ts",
|
|
27
|
-
"import": "./dist/temporal/polyfill.js",
|
|
28
|
-
"module-sync": "./dist/temporal/polyfill.js"
|
|
29
|
-
}
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./*": "./dist/types/*.js",
|
|
12
|
+
"./temporal": "./dist/temporal/global.js",
|
|
13
|
+
"./temporal-polyfill": "./dist/temporal/polyfill.js"
|
|
30
14
|
},
|
|
31
15
|
"dependencies": {
|
|
32
16
|
"temporal-spec": "^0.3.0"
|
|
33
17
|
},
|
|
34
18
|
"peerDependencies": {
|
|
35
19
|
"temporal-polyfill": "^0.3.0",
|
|
36
|
-
"zod": "^4.
|
|
37
|
-
"@nmtjs/common": "0.
|
|
20
|
+
"zod": "^4.1.0",
|
|
21
|
+
"@nmtjs/common": "0.15.0-beta.2"
|
|
38
22
|
},
|
|
39
23
|
"devDependencies": {
|
|
40
24
|
"temporal-polyfill": "^0.3.0",
|
|
41
|
-
"zod": "^4.
|
|
42
|
-
"@nmtjs/common": "0.
|
|
25
|
+
"zod": "^4.1.0",
|
|
26
|
+
"@nmtjs/common": "0.15.0-beta.2"
|
|
43
27
|
},
|
|
44
28
|
"peerDependenciesMeta": {
|
|
45
29
|
"temporal-polyfill": {
|
|
46
30
|
"optional": true
|
|
47
31
|
}
|
|
48
32
|
},
|
|
49
|
-
"version": "0.
|
|
33
|
+
"version": "0.15.0-beta.2",
|
|
50
34
|
"scripts": {
|
|
35
|
+
"clean-build": "rm -rf ./dist",
|
|
51
36
|
"build": "tsc",
|
|
37
|
+
"dev": "tsc --watch",
|
|
52
38
|
"type-check": "tsc --noEmit"
|
|
53
39
|
}
|
|
54
40
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import 'temporal-spec/global';
|
|
2
|
-
export declare const plainDate: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainDate, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainDate, import("temporal-spec").Temporal.PlainDate, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainDate, import("temporal-spec").Temporal.PlainDate>>>;
|
|
3
|
-
export declare const plainDatetime: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainDateTime, import("temporal-spec").Temporal.PlainDateTime, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainDateTime, import("temporal-spec").Temporal.PlainDateTime>>>;
|
|
4
|
-
export declare const plainTime: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainTime, import("temporal-spec").Temporal.PlainTime, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainTime, import("temporal-spec").Temporal.PlainTime>>>;
|
|
5
|
-
export declare const zonedDatetime: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.ZonedDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.ZonedDateTime, import("temporal-spec").Temporal.ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.ZonedDateTime, import("temporal-spec").Temporal.ZonedDateTime>>>;
|
|
6
|
-
export declare const duration: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.Duration, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.Duration, import("temporal-spec").Temporal.Duration, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.Duration, import("temporal-spec").Temporal.Duration>>>;
|
|
7
|
-
export declare const plainYearMonth: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainYearMonth, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainYearMonth, import("temporal-spec").Temporal.PlainYearMonth, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainYearMonth, import("temporal-spec").Temporal.PlainYearMonth>>>;
|
|
8
|
-
export declare const plainMonthDay: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainMonthDay, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainMonthDay, import("temporal-spec").Temporal.PlainMonthDay, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainMonthDay, import("temporal-spec").Temporal.PlainMonthDay>>>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
export declare const plainDate: () => import("../types/custom.ts").CustomType<Temporal.PlainDate, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainDate, Temporal.PlainDate, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainDate, Temporal.PlainDate>>>;
|
|
3
|
-
export declare const plainDatetime: () => import("../types/custom.ts").CustomType<Temporal.PlainDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainDateTime, Temporal.PlainDateTime, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainDateTime, Temporal.PlainDateTime>>>;
|
|
4
|
-
export declare const plainTime: () => import("../types/custom.ts").CustomType<Temporal.PlainTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainTime, Temporal.PlainTime, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainTime, Temporal.PlainTime>>>;
|
|
5
|
-
export declare const zonedDatetime: () => import("../types/custom.ts").CustomType<Temporal.ZonedDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.ZonedDateTime, Temporal.ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<Temporal.ZonedDateTime, Temporal.ZonedDateTime>>>;
|
|
6
|
-
export declare const duration: () => import("../types/custom.ts").CustomType<Temporal.Duration, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.Duration, Temporal.Duration, import("zod/v4/core").$ZodTypeInternals<Temporal.Duration, Temporal.Duration>>>;
|
|
7
|
-
export declare const plainYearMonth: () => import("../types/custom.ts").CustomType<Temporal.PlainYearMonth, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainYearMonth, Temporal.PlainYearMonth, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainYearMonth, Temporal.PlainYearMonth>>>;
|
|
8
|
-
export declare const plainMonthDay: () => import("../types/custom.ts").CustomType<Temporal.PlainMonthDay, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainMonthDay, Temporal.PlainMonthDay, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainMonthDay, Temporal.PlainMonthDay>>>;
|
package/dist/types/_plain.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { core, ZodMiniType } from 'zod/mini';
|
|
2
|
-
export declare const PlainType: unique symbol;
|
|
3
|
-
export type PlainType = typeof PlainType;
|
|
4
|
-
export type ZodPlainType<T extends ZodMiniType<any, any, any>> = T & ZodMiniType<T['_zod']['output'] & {
|
|
5
|
-
[PlainType]?: true;
|
|
6
|
-
}, T['_zod']['input'] & {
|
|
7
|
-
[PlainType]?: true;
|
|
8
|
-
}, core.$ZodTypeInternals<T['_zod']['output'] & {
|
|
9
|
-
[PlainType]?: true;
|
|
10
|
-
}, T['_zod']['input'] & {
|
|
11
|
-
[PlainType]?: true;
|
|
12
|
-
}>>;
|
|
13
|
-
export declare const zodPlainType: <T extends ZodMiniType<any, any, any>>(type: T) => ZodPlainType<T>;
|
package/dist/types/_type.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { BaseTypeAny } from './base.ts';
|
|
2
|
-
export * from './any.ts';
|
|
3
|
-
export * from './array.ts';
|
|
4
|
-
export * from './boolean.ts';
|
|
5
|
-
export * from './custom.ts';
|
|
6
|
-
export * from './date.ts';
|
|
7
|
-
export * from './enum.ts';
|
|
8
|
-
export * from './literal.ts';
|
|
9
|
-
export * from './never.ts';
|
|
10
|
-
export * from './number.ts';
|
|
11
|
-
export * from './object.ts';
|
|
12
|
-
export * from './string.ts';
|
|
13
|
-
export * from './tuple.ts';
|
|
14
|
-
export * from './union.ts';
|
|
15
|
-
export declare namespace infer {
|
|
16
|
-
namespace decode {
|
|
17
|
-
type input<T extends BaseTypeAny> = T['decodeZodType']['_zod']['input'];
|
|
18
|
-
type output<T extends BaseTypeAny> = T['decodeZodType']['_zod']['output'];
|
|
19
|
-
}
|
|
20
|
-
namespace encode {
|
|
21
|
-
type input<T extends BaseTypeAny> = T['encodeZodType']['_zod']['input'];
|
|
22
|
-
type output<T extends BaseTypeAny> = T['encodeZodType']['_zod']['output'];
|
|
23
|
-
}
|
|
24
|
-
namespace decodeRaw {
|
|
25
|
-
type input<T extends BaseTypeAny> = T['decodeRawZodType']['_zod']['input'];
|
|
26
|
-
type output<T extends BaseTypeAny> = T['decodeRawZodType']['_zod']['output'];
|
|
27
|
-
}
|
|
28
|
-
namespace encodeRaw {
|
|
29
|
-
type input<T extends BaseTypeAny> = T['encodeRawZodType']['_zod']['input'];
|
|
30
|
-
type output<T extends BaseTypeAny> = T['encodeRawZodType']['_zod']['output'];
|
|
31
|
-
}
|
|
32
|
-
}
|
package/dist/types/any.d.ts
DELETED
package/dist/types/array.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { core, ZodMiniArray } from 'zod/mini';
|
|
2
|
-
import type { ZodPlainType } from './_plain.ts';
|
|
3
|
-
import { BaseType } from './base.ts';
|
|
4
|
-
type Check = core.CheckFn<any[]> | core.$ZodCheck<any[]>;
|
|
5
|
-
export declare class ArrayType<T extends BaseType = BaseType> extends BaseType<ZodMiniArray<T['encodeZodType']>, ZodMiniArray<T['decodeZodType']>, {
|
|
6
|
-
element: T;
|
|
7
|
-
}, ZodPlainType<ZodMiniArray<T['encodeZodType']>>, ZodPlainType<ZodMiniArray<T['encodeZodType']>>> {
|
|
8
|
-
static factory<T extends BaseType>(element: T, ...checks: Check[]): ArrayType<T>;
|
|
9
|
-
min(value: number): ArrayType<T>;
|
|
10
|
-
max(value: number): ArrayType<T>;
|
|
11
|
-
length(value: number): ArrayType<T>;
|
|
12
|
-
}
|
|
13
|
-
export declare const array: typeof ArrayType.factory;
|
|
14
|
-
export {};
|
package/dist/types/base.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { ZodMiniAny, ZodMiniArray, ZodMiniBoolean, ZodMiniDefault, ZodMiniEnum, ZodMiniIntersection, ZodMiniLiteral, ZodMiniNever, ZodMiniNullable, ZodMiniNumber, ZodMiniObject, ZodMiniOptional, ZodMiniRecord, ZodMiniString, ZodMiniType, ZodMiniUnion } from 'zod/mini';
|
|
2
|
-
import { core } from 'zod/mini';
|
|
3
|
-
export type PrimitiveValueType = string | number | boolean | null;
|
|
4
|
-
export type PrimitiveZodType = ZodMiniNever | ZodMiniDefault | ZodMiniNullable | ZodMiniOptional | ZodMiniString | ZodMiniObject | ZodMiniAny | ZodMiniArray | ZodMiniBoolean | ZodMiniNumber | ZodMiniEnum<any> | ZodMiniLiteral<PrimitiveValueType> | ZodMiniUnion | ZodMiniIntersection | ZodMiniRecord;
|
|
5
|
-
export type SimpleZodType = ZodMiniType;
|
|
6
|
-
export type ZodType = SimpleZodType | ZodMiniType;
|
|
7
|
-
export type TypeProps = Record<string, any>;
|
|
8
|
-
export type TypeMetadata<T = any> = {
|
|
9
|
-
id?: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
examples?: T[];
|
|
12
|
-
title?: string;
|
|
13
|
-
};
|
|
14
|
-
export type TypeParams = {
|
|
15
|
-
encode?: (value: any) => any;
|
|
16
|
-
metadata?: TypeMetadata;
|
|
17
|
-
checks: Array<core.CheckFn<any> | core.$ZodCheck<any>>;
|
|
18
|
-
};
|
|
19
|
-
export type DefaultTypeParams = {
|
|
20
|
-
encode?: TypeParams['encode'];
|
|
21
|
-
metadata?: TypeMetadata;
|
|
22
|
-
};
|
|
23
|
-
export type BaseTypeAny<EncodedZodType extends SimpleZodType = SimpleZodType, DecodedZodType extends ZodType = ZodMiniType> = BaseType<EncodedZodType, DecodedZodType, TypeProps>;
|
|
24
|
-
export declare const typesRegistry: core.$ZodRegistry<TypeMetadata<any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>;
|
|
25
|
-
export declare const NeemataTypeError: core.$constructor<core.$ZodError<unknown>, core.$ZodIssue[]>;
|
|
26
|
-
export type NeemataTypeError = core.$ZodError;
|
|
27
|
-
export declare abstract class BaseType<EncodeZodType extends SimpleZodType = SimpleZodType, DecodeZodType extends ZodType = EncodeZodType, Props extends TypeProps = TypeProps, RawEncodeZodType extends SimpleZodType = EncodeZodType, RawDecodeZodType extends ZodType = DecodeZodType> {
|
|
28
|
-
readonly encodeZodType: EncodeZodType;
|
|
29
|
-
readonly decodeZodType: DecodeZodType;
|
|
30
|
-
readonly encodeRawZodType: RawEncodeZodType;
|
|
31
|
-
readonly decodeRawZodType: RawDecodeZodType;
|
|
32
|
-
readonly props: Props;
|
|
33
|
-
readonly params: TypeParams;
|
|
34
|
-
constructor({ encodeZodType, decodeZodType, props, params, }: {
|
|
35
|
-
encodeZodType: EncodeZodType;
|
|
36
|
-
decodeZodType?: DecodeZodType;
|
|
37
|
-
props?: Props;
|
|
38
|
-
params?: Partial<TypeParams>;
|
|
39
|
-
});
|
|
40
|
-
optional(): OptionalType<this>;
|
|
41
|
-
nullable(): NullableType<this>;
|
|
42
|
-
nullish(): OptionalType<NullableType<this>>;
|
|
43
|
-
default(value: this['encodeZodType']['_zod']['input']): DefaultType<this>;
|
|
44
|
-
title(title: string): this;
|
|
45
|
-
description(description: string): this;
|
|
46
|
-
examples(...examples: this['encodeZodType']['_zod']['input'][]): this;
|
|
47
|
-
meta(newMetadata: TypeMetadata): this;
|
|
48
|
-
encode(data: this['encodeZodType']['_zod']['input'], context?: core.ParseContext<core.$ZodIssue>): this['encodeZodType']['_zod']['output'];
|
|
49
|
-
decode(data: this['decodeZodType']['_zod']['input'], context?: core.ParseContext<core.$ZodIssue>): this['decodeZodType']['_zod']['output'];
|
|
50
|
-
}
|
|
51
|
-
export declare class OptionalType<Type extends BaseTypeAny = BaseTypeAny> extends BaseType<ZodMiniOptional<Type['encodeZodType']>, ZodMiniOptional<Type['decodeZodType']>, {
|
|
52
|
-
inner: Type;
|
|
53
|
-
}> {
|
|
54
|
-
static factory<T extends BaseTypeAny>(type: T): OptionalType<T>;
|
|
55
|
-
}
|
|
56
|
-
export declare class NullableType<Type extends BaseTypeAny<any> = BaseTypeAny<any>> extends BaseType<ZodMiniNullable<Type['encodeZodType']>, ZodMiniNullable<Type['decodeZodType']>, {
|
|
57
|
-
inner: Type;
|
|
58
|
-
}> {
|
|
59
|
-
static factory<T extends BaseTypeAny<any>>(type: T): NullableType<T>;
|
|
60
|
-
}
|
|
61
|
-
export declare class DefaultType<Type extends BaseTypeAny = BaseTypeAny> extends BaseType<ZodMiniDefault<Type['encodeZodType']>, ZodMiniDefault<Type['decodeZodType']>, {
|
|
62
|
-
inner: Type;
|
|
63
|
-
}> {
|
|
64
|
-
static factory<T extends BaseTypeAny<any>>(type: T, defaultValue: any): DefaultType<T>;
|
|
65
|
-
}
|
package/dist/types/boolean.d.ts
DELETED
package/dist/types/custom.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { core, ZodMiniType } from 'zod/mini';
|
|
2
|
-
import type { SimpleZodType, ZodType } from './base.ts';
|
|
3
|
-
import { BaseType } from './base.ts';
|
|
4
|
-
export type CustomTransformFn<I, O> = (value: I) => O;
|
|
5
|
-
export declare abstract class TransformType<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>> extends BaseType<ZodMiniType<EncodeType['_zod']['output'], DecodeType['_zod']['input']>, ZodMiniType<DecodeType['_zod']['output'], EncodeType['_zod']['input']>> {
|
|
6
|
-
}
|
|
7
|
-
export declare class CustomType<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>> extends TransformType<Type, EncodeType, DecodeType> {
|
|
8
|
-
static factory<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>>({ decode, encode, error, type, }: {
|
|
9
|
-
decode: CustomTransformFn<EncodeType['_zod']['input'], DecodeType['_zod']['output']>;
|
|
10
|
-
encode: CustomTransformFn<DecodeType['_zod']['input'], EncodeType['_zod']['output']>;
|
|
11
|
-
error?: string | core.$ZodErrorMap<core.$ZodIssueBase>;
|
|
12
|
-
type?: EncodeType;
|
|
13
|
-
}): CustomType<Type, EncodeType, DecodeType>;
|
|
14
|
-
}
|
|
15
|
-
export declare const custom: typeof CustomType.factory;
|
package/dist/types/date.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ZodMiniUnion } from 'zod/mini';
|
|
2
|
-
import { iso } from 'zod/mini';
|
|
3
|
-
import { CustomType, TransformType } from './custom.ts';
|
|
4
|
-
export declare class DateType extends TransformType<Date, ZodMiniUnion<[iso.ZodMiniISODate, iso.ZodMiniISODateTime]>> {
|
|
5
|
-
static factory(): CustomType<Date, ZodMiniUnion<[iso.ZodMiniISODate, iso.ZodMiniISODateTime]>, import("zod/mini").ZodMiniType<Date, Date, import("zod/v4/core").$ZodTypeInternals<Date, Date>>>;
|
|
6
|
-
}
|
|
7
|
-
export declare const date: typeof DateType.factory;
|
package/dist/types/enum.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { core, ZodMiniEnum } from 'zod/mini';
|
|
2
|
-
import { BaseType } from './base.ts';
|
|
3
|
-
export declare class EnumType<T extends core.util.EnumLike = core.util.EnumLike> extends BaseType<ZodMiniEnum<T>, ZodMiniEnum<T>, {
|
|
4
|
-
values: T;
|
|
5
|
-
}> {
|
|
6
|
-
static factory<T extends core.util.EnumLike>(values: T): EnumType<T>;
|
|
7
|
-
static factory<T extends string[]>(values: T): EnumType<core.util.ToEnum<T[number]>>;
|
|
8
|
-
}
|
|
9
|
-
declare const _enum: typeof EnumType.factory;
|
|
10
|
-
export { _enum as enum };
|
package/dist/types/literal.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ZodMiniLiteral } from 'zod/mini';
|
|
2
|
-
import type { PrimitiveValueType } from './base.ts';
|
|
3
|
-
import { BaseType } from './base.ts';
|
|
4
|
-
export declare class LiteralType<T extends PrimitiveValueType = PrimitiveValueType> extends BaseType<ZodMiniLiteral<T>, ZodMiniLiteral<T>, {
|
|
5
|
-
value: T;
|
|
6
|
-
}> {
|
|
7
|
-
static factory<T extends PrimitiveValueType>(value: T): LiteralType<T>;
|
|
8
|
-
}
|
|
9
|
-
export declare const literal: typeof LiteralType.factory;
|
package/dist/types/never.d.ts
DELETED
package/dist/types/number.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { core, ZodMiniNumber, ZodMiniString } from 'zod/mini';
|
|
2
|
-
import { BaseType } from './base.ts';
|
|
3
|
-
import { CustomType, TransformType } from './custom.ts';
|
|
4
|
-
type Check = core.CheckFn<number> | core.$ZodCheck<number>;
|
|
5
|
-
export declare class NumberType extends BaseType<ZodMiniNumber<number>, ZodMiniNumber<number>> {
|
|
6
|
-
static factory(...checks: Check[]): NumberType;
|
|
7
|
-
positive(): NumberType;
|
|
8
|
-
negative(): NumberType;
|
|
9
|
-
lt(value: number): NumberType;
|
|
10
|
-
lte(value: number): NumberType;
|
|
11
|
-
gte(value: number): NumberType;
|
|
12
|
-
gt(value: number): NumberType;
|
|
13
|
-
}
|
|
14
|
-
export declare class IntegerType extends NumberType {
|
|
15
|
-
static factory(...checks: Check[]): NumberType;
|
|
16
|
-
}
|
|
17
|
-
export declare class BigIntType extends TransformType<bigint, ZodMiniString<string>> {
|
|
18
|
-
static factory(): CustomType<bigint, ZodMiniString<string>, import("zod/mini").ZodMiniType<bigint, bigint, core.$ZodTypeInternals<bigint, bigint>>>;
|
|
19
|
-
}
|
|
20
|
-
export declare const number: typeof NumberType.factory;
|
|
21
|
-
export declare const integer: typeof IntegerType.factory;
|
|
22
|
-
export declare const bigInt: typeof BigIntType.factory;
|
|
23
|
-
export {};
|
package/dist/types/object.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { core, ZodMiniObject, ZodMiniRecord } from 'zod/mini';
|
|
2
|
-
import type { ZodPlainType } from './_plain.ts';
|
|
3
|
-
import type { BaseTypeAny, OptionalType } from './base.ts';
|
|
4
|
-
import type { LiteralType } from './literal.ts';
|
|
5
|
-
import type { StringType } from './string.ts';
|
|
6
|
-
import { BaseType } from './base.ts';
|
|
7
|
-
import { EnumType } from './enum.ts';
|
|
8
|
-
export type ObjectTypeProps = {
|
|
9
|
-
[k: string]: BaseTypeAny;
|
|
10
|
-
};
|
|
11
|
-
export type AnyObjectType = ObjectType<ObjectTypeProps>;
|
|
12
|
-
export declare class ObjectType<T extends ObjectTypeProps = {}> extends BaseType<ZodMiniObject<{
|
|
13
|
-
[K in keyof T]: T[K]['encodeZodType'];
|
|
14
|
-
}, core.$strict>, ZodMiniObject<{
|
|
15
|
-
[K in keyof T]: T[K]['decodeZodType'];
|
|
16
|
-
}, core.$strict>, {
|
|
17
|
-
properties: T;
|
|
18
|
-
}, ZodPlainType<ZodMiniObject<{
|
|
19
|
-
[K in keyof T]: T[K]['encodeZodType'];
|
|
20
|
-
}, core.$strict>>, ZodPlainType<ZodMiniObject<{
|
|
21
|
-
[K in keyof T]: T[K]['decodeZodType'];
|
|
22
|
-
}, core.$strict>>> {
|
|
23
|
-
static factory<T extends ObjectTypeProps = {}>(properties: T): ObjectType<T>;
|
|
24
|
-
}
|
|
25
|
-
export declare class RecordType<K extends LiteralType<string | number> | EnumType | StringType, E extends BaseType> extends BaseType<ZodMiniRecord<K['encodeZodType'], E['encodeZodType']>, ZodMiniRecord<K['decodeZodType'], E['decodeZodType']>, {
|
|
26
|
-
key: K;
|
|
27
|
-
element: E;
|
|
28
|
-
}, ZodPlainType<ZodMiniRecord<K['encodeZodType'], E['encodeZodType']>>, ZodPlainType<ZodMiniRecord<K['decodeZodType'], E['decodeZodType']>>> {
|
|
29
|
-
static factory<K extends LiteralType<string | number> | EnumType | StringType, E extends BaseType>(key: K, element: E): RecordType<K, E>;
|
|
30
|
-
}
|
|
31
|
-
export declare function keyof<T extends AnyObjectType>(type: T): EnumType<core.util.ToEnum<Extract<keyof T['props']['properties'], string>>>;
|
|
32
|
-
export declare function pick<T extends AnyObjectType, P extends {
|
|
33
|
-
[K in keyof T['props']['properties']]?: true;
|
|
34
|
-
}>(source: T, pick: P): ObjectType<{
|
|
35
|
-
[K in keyof P]: P[K] extends true ? K extends keyof T['props']['properties'] ? T['props']['properties'][K] : never : never;
|
|
36
|
-
}>;
|
|
37
|
-
export declare function omit<T extends AnyObjectType, P extends {
|
|
38
|
-
[K in keyof T['props']['properties']]?: true;
|
|
39
|
-
}>(source: T, omit: P): ObjectType<{
|
|
40
|
-
[K in keyof T['props']['properties'] as K extends keyof P ? never : K]: T['props']['properties'][K];
|
|
41
|
-
}>;
|
|
42
|
-
export declare function extend<T extends AnyObjectType, P extends ObjectTypeProps>(object1: T, properties: P): ObjectType<{
|
|
43
|
-
[K in keyof T['props']['properties'] | keyof P]: K extends keyof P ? P[K] : K extends keyof T['props']['properties'] ? T['props']['properties'][K] : never;
|
|
44
|
-
}>;
|
|
45
|
-
export declare function merge<T1 extends AnyObjectType, T2 extends AnyObjectType>(object1: T1, object2: T2): ObjectType<{
|
|
46
|
-
[K in keyof T1['props']['properties'] | keyof T2['props']['properties']]: K extends keyof T2['props']['properties'] ? T2['props']['properties'][K] : K extends keyof T1['props']['properties'] ? T1['props']['properties'][K] : never;
|
|
47
|
-
}>;
|
|
48
|
-
export declare function partial<T extends AnyObjectType, P extends T extends ObjectType<infer Props> ? Props : never>(object: T): ObjectType<{
|
|
49
|
-
[K in keyof P]: OptionalType<P[K]>;
|
|
50
|
-
}>;
|
|
51
|
-
export declare const object: typeof ObjectType.factory;
|
|
52
|
-
export declare const record: typeof RecordType.factory;
|
package/dist/types/string.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { core, ZodMiniString } from 'zod/mini';
|
|
2
|
-
import { BaseType } from './base.ts';
|
|
3
|
-
type Check = core.CheckFn<string> | core.$ZodCheck<string>;
|
|
4
|
-
export declare class StringType extends BaseType<ZodMiniString<string>, ZodMiniString<string>> {
|
|
5
|
-
static factory(...checks: Check[]): StringType;
|
|
6
|
-
max(value: number): StringType;
|
|
7
|
-
min(value: number): StringType;
|
|
8
|
-
pattern(pattern: string | RegExp): StringType;
|
|
9
|
-
email(options?: core.$ZodEmailParams): StringType;
|
|
10
|
-
url(options?: core.$ZodURLParams): StringType;
|
|
11
|
-
ipv4(options?: core.$ZodIPv4Params): StringType;
|
|
12
|
-
ipv6(options?: core.$ZodIPv6Params): StringType;
|
|
13
|
-
uuid(options?: core.$ZodUUIDParams): StringType;
|
|
14
|
-
emoji(options?: core.$ZodEmojiParams): StringType;
|
|
15
|
-
nanoid(options?: core.$ZodNanoIDParams): StringType;
|
|
16
|
-
cuid(options?: core.$ZodCUIDParams): StringType;
|
|
17
|
-
cuid2(options?: core.$ZodCUID2Params): StringType;
|
|
18
|
-
e164(options?: core.$ZodE164Params): StringType;
|
|
19
|
-
jwt(options?: core.$ZodJWTParams): StringType;
|
|
20
|
-
}
|
|
21
|
-
export declare const string: typeof StringType.factory;
|
|
22
|
-
export {};
|
package/dist/types/temporal.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Temporal } from 'temporal-spec';
|
|
2
|
-
import type { ZodMiniString } from 'zod/mini';
|
|
3
|
-
import { CustomType, TransformType } from './custom.ts';
|
|
4
|
-
type EncodeType = ZodMiniString<string>;
|
|
5
|
-
export declare class PlainDateType extends TransformType<Temporal.PlainDate, EncodeType> {
|
|
6
|
-
static factory(implementation: typeof Temporal): CustomType<Temporal.PlainDate, EncodeType, import("zod/mini").ZodMiniType<Temporal.PlainDate, Temporal.PlainDate, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainDate, Temporal.PlainDate>>>;
|
|
7
|
-
}
|
|
8
|
-
export declare class PlainDateTimeType extends TransformType<Temporal.PlainDateTime, EncodeType> {
|
|
9
|
-
static factory(implementation: typeof Temporal): CustomType<Temporal.PlainDateTime, EncodeType, import("zod/mini").ZodMiniType<Temporal.PlainDateTime, Temporal.PlainDateTime, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainDateTime, Temporal.PlainDateTime>>>;
|
|
10
|
-
}
|
|
11
|
-
export declare class ZonedDateTimeType extends TransformType<Temporal.ZonedDateTime, EncodeType> {
|
|
12
|
-
static factory(implementation: typeof Temporal): CustomType<Temporal.ZonedDateTime, EncodeType, import("zod/mini").ZodMiniType<Temporal.ZonedDateTime, Temporal.ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<Temporal.ZonedDateTime, Temporal.ZonedDateTime>>>;
|
|
13
|
-
}
|
|
14
|
-
export declare class PlainTimeType extends TransformType<Temporal.PlainTime, EncodeType> {
|
|
15
|
-
static factory(implementation: typeof Temporal): CustomType<Temporal.PlainTime, EncodeType, import("zod/mini").ZodMiniType<Temporal.PlainTime, Temporal.PlainTime, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainTime, Temporal.PlainTime>>>;
|
|
16
|
-
}
|
|
17
|
-
export declare class DurationType extends TransformType<Temporal.Duration, EncodeType> {
|
|
18
|
-
static factory(implementation: typeof Temporal): CustomType<Temporal.Duration, EncodeType, import("zod/mini").ZodMiniType<Temporal.Duration, Temporal.Duration, import("zod/v4/core").$ZodTypeInternals<Temporal.Duration, Temporal.Duration>>>;
|
|
19
|
-
}
|
|
20
|
-
export declare class PlainYearMonthType extends TransformType<Temporal.PlainYearMonth, EncodeType> {
|
|
21
|
-
static factory(implementation: typeof Temporal): CustomType<Temporal.PlainYearMonth, EncodeType, import("zod/mini").ZodMiniType<Temporal.PlainYearMonth, Temporal.PlainYearMonth, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainYearMonth, Temporal.PlainYearMonth>>>;
|
|
22
|
-
}
|
|
23
|
-
export declare class PlainMonthDayType extends TransformType<Temporal.PlainMonthDay, EncodeType> {
|
|
24
|
-
static factory(implementation: typeof Temporal): CustomType<Temporal.PlainMonthDay, EncodeType, import("zod/mini").ZodMiniType<Temporal.PlainMonthDay, Temporal.PlainMonthDay, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainMonthDay, Temporal.PlainMonthDay>>>;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
package/dist/types/tuple.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ArrayMap } from '@nmtjs/common';
|
|
2
|
-
import type { ZodMiniTuple } from 'zod/mini';
|
|
3
|
-
import type { ZodPlainType } from './_plain.ts';
|
|
4
|
-
import { BaseType } from './base.ts';
|
|
5
|
-
export declare class TupleType<T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
6
|
-
BaseType,
|
|
7
|
-
...BaseType[]
|
|
8
|
-
], R extends BaseType | null = BaseType | null> extends BaseType<R extends BaseType ? ZodMiniTuple<ArrayMap<T, 'encodeZodType'>, R['encodeZodType']> : ZodMiniTuple<ArrayMap<T, 'encodeZodType'>, null>, R extends BaseType ? ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, R['decodeZodType']> : ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, null>, {
|
|
9
|
-
elements: T;
|
|
10
|
-
rest?: R;
|
|
11
|
-
}, R extends BaseType ? ZodPlainType<ZodMiniTuple<ArrayMap<T, 'encodeZodType'>, R['encodeZodType']>> : ZodPlainType<ZodMiniTuple<ArrayMap<T, 'encodeZodType'>, null>>, R extends BaseType ? ZodPlainType<ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, R['decodeZodType']>> : ZodPlainType<ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, null>>> {
|
|
12
|
-
static factory<T extends readonly [BaseType, ...BaseType[]], R extends BaseType | null = null>(elements: T, rest?: R): TupleType<T, R>;
|
|
13
|
-
}
|
|
14
|
-
export declare const tuple: typeof TupleType.factory;
|
package/dist/types/union.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ArrayMap } from '@nmtjs/common';
|
|
2
|
-
import type { ZodMiniDiscriminatedUnion, ZodMiniIntersection, ZodMiniUnion } from 'zod/mini';
|
|
3
|
-
import type { ZodPlainType } from './_plain.ts';
|
|
4
|
-
import type { BaseTypeAny } from './base.ts';
|
|
5
|
-
import type { LiteralType } from './literal.ts';
|
|
6
|
-
import type { ObjectType, ObjectTypeProps } from './object.ts';
|
|
7
|
-
import { BaseType } from './base.ts';
|
|
8
|
-
export declare class UnionType<T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
9
|
-
BaseType,
|
|
10
|
-
...BaseType[]
|
|
11
|
-
]> extends BaseType<ZodMiniUnion<ArrayMap<T, 'encodeZodType'>>, ZodMiniUnion<ArrayMap<T, 'decodeZodType'>>, {
|
|
12
|
-
options: T;
|
|
13
|
-
}, ZodPlainType<ZodMiniUnion<ArrayMap<T, 'encodeZodType'>>>, ZodPlainType<ZodMiniUnion<ArrayMap<T, 'decodeZodType'>>>> {
|
|
14
|
-
static factory<T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
15
|
-
BaseType,
|
|
16
|
-
...BaseType[]
|
|
17
|
-
]>(...options: T): UnionType<T>;
|
|
18
|
-
}
|
|
19
|
-
export declare class IntersactionType<T extends readonly [BaseType, BaseType] = readonly [BaseType, BaseType]> extends BaseType<ZodMiniIntersection<T[0]['encodeZodType'], T[1]['encodeZodType']>, ZodMiniIntersection<T[0]['decodeZodType'], T[1]['decodeZodType']>, {
|
|
20
|
-
options: T;
|
|
21
|
-
}> {
|
|
22
|
-
static factory<T extends readonly [BaseType, BaseType] = readonly [BaseType, BaseType]>(...options: T): IntersactionType<T>;
|
|
23
|
-
}
|
|
24
|
-
export type DiscriminatedUnionProperties<K extends string = string> = {
|
|
25
|
-
[OK in K]: LiteralType<string>;
|
|
26
|
-
} & {
|
|
27
|
-
[OK in string]: any;
|
|
28
|
-
};
|
|
29
|
-
export type DiscriminatedUnionOptionType<K extends string> = ObjectType<ObjectTypeProps & {
|
|
30
|
-
[_ in K]: BaseTypeAny;
|
|
31
|
-
}>;
|
|
32
|
-
export declare class DiscriminatedUnionType<K extends string = string, T extends readonly DiscriminatedUnionOptionType<K>[] = DiscriminatedUnionOptionType<K>[]> extends BaseType<ZodMiniDiscriminatedUnion<ArrayMap<T, 'encodeZodType'>>, ZodMiniDiscriminatedUnion<ArrayMap<T, 'decodeZodType'>>, {
|
|
33
|
-
key: K;
|
|
34
|
-
options: T;
|
|
35
|
-
}, ZodPlainType<ZodMiniDiscriminatedUnion<ArrayMap<T, 'encodeZodType'>>>, ZodPlainType<ZodMiniDiscriminatedUnion<ArrayMap<T, 'decodeZodType'>>>> {
|
|
36
|
-
static factory<K extends string = string, T extends readonly DiscriminatedUnionOptionType<K>[] = DiscriminatedUnionOptionType<K>[]>(key: K, ...options: T): DiscriminatedUnionType<K, T>;
|
|
37
|
-
}
|
|
38
|
-
export declare const union: typeof UnionType.factory;
|
|
39
|
-
export declare const or: typeof UnionType.factory;
|
|
40
|
-
export declare const intersection: typeof IntersactionType.factory;
|
|
41
|
-
export declare const and: typeof IntersactionType.factory;
|
|
42
|
-
export declare const discriminatedUnion: typeof DiscriminatedUnionType.factory;
|
|
File without changes
|