@nmtjs/type 0.16.0-beta.3 → 0.16.0-beta.5
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/dist/standart-schema.d.ts +2 -2
- package/dist/types/_type.d.ts +0 -8
- package/dist/types/_utils.d.ts +1 -13
- package/dist/types/_utils.js +1 -2
- package/dist/types/_utils.js.map +1 -1
- package/dist/types/array.d.ts +1 -2
- package/dist/types/array.js.map +1 -1
- package/dist/types/base.d.ts +1 -3
- package/dist/types/base.js +0 -2
- package/dist/types/base.js.map +1 -1
- package/dist/types/object.d.ts +3 -12
- package/dist/types/object.js +2 -3
- package/dist/types/object.js.map +1 -1
- package/dist/types/tuple.d.ts +1 -2
- package/dist/types/tuple.js.map +1 -1
- package/dist/types/union.d.ts +2 -3
- package/dist/types/union.js.map +1 -1
- package/package.json +3 -3
- package/src/types/_type.ts +0 -14
- package/src/types/_utils.ts +1 -17
- package/src/types/array.ts +1 -4
- package/src/types/base.ts +0 -4
- package/src/types/object.ts +5 -25
- package/src/types/tuple.ts +1 -12
- package/src/types/union.ts +2 -7
|
@@ -7,6 +7,6 @@ export declare namespace standard {
|
|
|
7
7
|
type SchemaProps<T extends ZodMiniType> = StandardSchemaV1.Props<T['_zod']['input'], T['_zod']['output']> & StandardJSONSchemaV1.Props<T['_zod']['input'], T['_zod']['output']>;
|
|
8
8
|
type JSONProps<T extends ZodMiniType> = StandardJSONSchemaV1.Props<T['_zod']['input'], T['_zod']['output']>;
|
|
9
9
|
type Props<T extends ZodMiniType> = SchemaProps<T> & JSONProps<T>;
|
|
10
|
-
const decode: <T extends BaseType<import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType, import("./index.ts").TypeProps
|
|
11
|
-
const encode: <T extends BaseType<import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType, import("./index.ts").TypeProps
|
|
10
|
+
const decode: <T extends BaseType<import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType, import("./index.ts").TypeProps>>(type: T, registry: core.$ZodRegistry<import("./types/_metadata.ts").TypeMetadata<any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>) => Schema<T["decodeZodType"]>;
|
|
11
|
+
const encode: <T extends BaseType<import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType, import("./index.ts").TypeProps>>(type: T, registry: core.$ZodRegistry<import("./types/_metadata.ts").TypeMetadata<any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>) => Schema<T["encodeZodType"]>;
|
|
12
12
|
}
|
package/dist/types/_type.d.ts
CHANGED
|
@@ -24,12 +24,4 @@ export declare namespace infer {
|
|
|
24
24
|
type input<T extends BaseTypeAny> = T['encodeZodType']['_zod']['input'];
|
|
25
25
|
type output<T extends BaseTypeAny> = T['encodeZodType']['_zod']['output'];
|
|
26
26
|
}
|
|
27
|
-
namespace decodeRaw {
|
|
28
|
-
type input<T extends BaseTypeAny> = T['decodeRawZodType']['_zod']['input'];
|
|
29
|
-
type output<T extends BaseTypeAny> = T['decodeRawZodType']['_zod']['output'];
|
|
30
|
-
}
|
|
31
|
-
namespace encodeRaw {
|
|
32
|
-
type input<T extends BaseTypeAny> = T['encodeRawZodType']['_zod']['input'];
|
|
33
|
-
type output<T extends BaseTypeAny> = T['encodeRawZodType']['_zod']['output'];
|
|
34
|
-
}
|
|
35
27
|
}
|
package/dist/types/_utils.d.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZodMiniType } from 'zod/mini';
|
|
2
2
|
import type { BaseType } from './base.ts';
|
|
3
|
-
export declare const PlainType: unique symbol;
|
|
4
|
-
export type PlainType = typeof PlainType;
|
|
5
|
-
export type ZodPlainType<T extends ZodMiniType<any, any, any>> = T & ZodMiniType<T['_zod']['output'] & {
|
|
6
|
-
[PlainType]?: true;
|
|
7
|
-
}, T['_zod']['input'] & {
|
|
8
|
-
[PlainType]?: true;
|
|
9
|
-
}, core.$ZodTypeInternals<T['_zod']['output'] & {
|
|
10
|
-
[PlainType]?: true;
|
|
11
|
-
}, T['_zod']['input'] & {
|
|
12
|
-
[PlainType]?: true;
|
|
13
|
-
}>>;
|
|
14
|
-
export declare const zodPlainType: <T extends ZodMiniType<any, any, any>>(type: T) => ZodPlainType<T>;
|
|
15
3
|
export type AnyCompatibleType<Encoded = any, Decoded = any> = BaseType<ZodMiniType<any, Decoded>, ZodMiniType<any, Encoded>>;
|
package/dist/types/_utils.js
CHANGED
package/dist/types/_utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_utils.js","sourceRoot":"","sources":["../../src/types/_utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_utils.js","sourceRoot":"","sources":["../../src/types/_utils.ts"],"names":[],"mappings":""}
|
package/dist/types/array.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { core, ZodMiniArray } from 'zod/mini';
|
|
2
|
-
import type { ZodPlainType } from './_utils.ts';
|
|
3
2
|
import { BaseType } from './base.ts';
|
|
4
3
|
type Check = core.CheckFn<any[]> | core.$ZodCheck<any[]>;
|
|
5
4
|
export declare class ArrayType<T extends BaseType = BaseType> extends BaseType<ZodMiniArray<T['encodeZodType']>, ZodMiniArray<T['decodeZodType']>, {
|
|
6
5
|
element: T;
|
|
7
|
-
}
|
|
6
|
+
}> {
|
|
8
7
|
static factory<T extends BaseType>(element: T, ...checks: Check[]): ArrayType<T>;
|
|
9
8
|
min(value: number): ArrayType<T>;
|
|
10
9
|
max(value: number): ArrayType<T>;
|
package/dist/types/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/types/array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"array.js","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C,MAAM,CAAC,MAAM,EACrB,KAAK,CACN,CAAA;IAAA,CACF;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAA"}
|
package/dist/types/base.d.ts
CHANGED
|
@@ -19,11 +19,9 @@ export type DefaultTypeParams = {
|
|
|
19
19
|
export type BaseTypeAny<EncodedZodType extends SimpleZodType = SimpleZodType, DecodedZodType extends ZodType = ZodMiniType> = BaseType<EncodedZodType, DecodedZodType, TypeProps>;
|
|
20
20
|
export declare const NeemataTypeError: core.$constructor<core.$ZodError<unknown>, core.$ZodIssue[]>;
|
|
21
21
|
export type NeemataTypeError = core.$ZodError;
|
|
22
|
-
export declare abstract class BaseType<EncodeZodType extends SimpleZodType = SimpleZodType, DecodeZodType extends ZodType = EncodeZodType, Props extends TypeProps = TypeProps
|
|
22
|
+
export declare abstract class BaseType<EncodeZodType extends SimpleZodType = SimpleZodType, DecodeZodType extends ZodType = EncodeZodType, Props extends TypeProps = TypeProps> implements standard.Schema<DecodeZodType> {
|
|
23
23
|
readonly encodeZodType: EncodeZodType;
|
|
24
24
|
readonly decodeZodType: DecodeZodType;
|
|
25
|
-
readonly encodeRawZodType: RawEncodeZodType;
|
|
26
|
-
readonly decodeRawZodType: RawDecodeZodType;
|
|
27
25
|
readonly props: Props;
|
|
28
26
|
readonly params: TypeParams;
|
|
29
27
|
readonly standard: {
|
package/dist/types/base.js
CHANGED
package/dist/types/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/types/base.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAG7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AA2C9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAA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.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { core, ZodMiniObject, ZodMiniRecord } from 'zod/mini';
|
|
2
|
-
import type { ZodPlainType } from './_utils.ts';
|
|
3
2
|
import type { BaseTypeAny, OptionalType } from './base.ts';
|
|
4
3
|
import type { LiteralType } from './literal.ts';
|
|
5
4
|
import type { StringType } from './string.ts';
|
|
@@ -14,11 +13,7 @@ export declare class ObjectType<T extends ObjectTypeProps = {}> extends BaseType
|
|
|
14
13
|
[K in keyof T]: T[K]['decodeZodType'];
|
|
15
14
|
}, core.$strip>, {
|
|
16
15
|
properties: T;
|
|
17
|
-
}
|
|
18
|
-
[K in keyof T]: T[K]['encodeZodType'];
|
|
19
|
-
}, core.$strip>>, ZodPlainType<ZodMiniObject<{
|
|
20
|
-
[K in keyof T]: T[K]['decodeZodType'];
|
|
21
|
-
}, core.$strip>>> {
|
|
16
|
+
}> {
|
|
22
17
|
static factory<T extends ObjectTypeProps = {}>(properties: T): ObjectType<T>;
|
|
23
18
|
}
|
|
24
19
|
export declare class LooseObjectType<T extends ObjectTypeProps = {}> extends BaseType<ZodMiniObject<{
|
|
@@ -27,11 +22,7 @@ export declare class LooseObjectType<T extends ObjectTypeProps = {}> extends Bas
|
|
|
27
22
|
[K in keyof T]: T[K]['decodeZodType'];
|
|
28
23
|
}, core.$loose>, {
|
|
29
24
|
properties: T;
|
|
30
|
-
}
|
|
31
|
-
[K in keyof T]: T[K]['encodeZodType'];
|
|
32
|
-
}, core.$loose>>, ZodPlainType<ZodMiniObject<{
|
|
33
|
-
[K in keyof T]: T[K]['decodeZodType'];
|
|
34
|
-
}, core.$loose>>> {
|
|
25
|
+
}> {
|
|
35
26
|
static factory<T extends ObjectTypeProps = {}>(properties: T): LooseObjectType<T>;
|
|
36
27
|
}
|
|
37
28
|
export type ObjectLikeType<T extends ObjectTypeProps> = ObjectType<T> | LooseObjectType<T>;
|
|
@@ -41,7 +32,7 @@ export type AnyObjectLikeType = AnyObjectType | AnyLooseObjectType;
|
|
|
41
32
|
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']>, {
|
|
42
33
|
key: K;
|
|
43
34
|
element: E;
|
|
44
|
-
}
|
|
35
|
+
}> {
|
|
45
36
|
static factory<K extends LiteralType<string | number> | EnumType | StringType, E extends BaseType>(key: K, element: E): RecordType<K, E>;
|
|
46
37
|
}
|
|
47
38
|
export type KeyofType<T extends AnyObjectLikeType> = EnumType<core.util.ToEnum<Extract<keyof T['props']['properties'], string>>>;
|
package/dist/types/object.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { looseObject as zodLooseObject, object as zodObject, record as zodRecord, } from 'zod/mini';
|
|
2
|
-
import { zodPlainType } from './_utils.js';
|
|
3
2
|
import { BaseType } from './base.js';
|
|
4
3
|
import { EnumType } from './enum.js';
|
|
5
4
|
export class ObjectType extends BaseType {
|
|
@@ -35,8 +34,8 @@ export class LooseObjectType extends BaseType {
|
|
|
35
34
|
export class RecordType extends BaseType {
|
|
36
35
|
static factory(key, element) {
|
|
37
36
|
return new RecordType({
|
|
38
|
-
encodeZodType:
|
|
39
|
-
decodeZodType:
|
|
37
|
+
encodeZodType: zodRecord(key.encodeZodType, element.encodeZodType),
|
|
38
|
+
decodeZodType: zodRecord(key.decodeZodType, element.decodeZodType),
|
|
40
39
|
props: { key, element },
|
|
41
40
|
});
|
|
42
41
|
}
|
package/dist/types/object.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/types/object.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,IAAI,cAAc,EAC7B,MAAM,IAAI,SAAS,EACnB,MAAM,IAAI,SAAS,GACpB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/types/object.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AI,CAAC,GAAG,CAAC,CAAC,CACtE,CAAA;IACD,OAAO,UAAU,CAAC,OAAO,CAAC,UAAU,CAAQ,CAAA;AAAA,CAC7C;AAaD,MAAM,UAAU,MAAM,CACpB,OAAU,EACV,UAAa,EACW;IACxB,OAAO,UAAU,CAAC,OAAO,CAAC;QACxB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU;QAC3B,GAAG,UAAU;KACd,CAAQ,CAAA;AAAA,CACV;AAeD,MAAM,UAAU,KAAK,CAGnB,OAAW,EAAE,OAAW,EAA4B;IACpD,OAAO,UAAU,CAAC,OAAO,CAAC;QACxB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU;QAC3B,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU;KAC5B,CAAQ,CAAA;AAAA,CACV;AAOD,MAAM,UAAU,OAAO,CACrB,MAAS,EACa;IACtB,MAAM,UAAU,GAAG,EAAS,CAAA;IAE5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACnE,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAA;IACpC,CAAC;IAED,OAAO,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAAA,CACtC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAA;AACxC,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAA;AAClD,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAA"}
|
package/dist/types/tuple.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ArrayMap } from '@nmtjs/common';
|
|
2
2
|
import type { ZodMiniTuple } from 'zod/mini';
|
|
3
|
-
import type { ZodPlainType } from './_utils.ts';
|
|
4
3
|
import { BaseType } from './base.ts';
|
|
5
4
|
export declare class TupleType<T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
6
5
|
BaseType,
|
|
@@ -8,7 +7,7 @@ export declare class TupleType<T extends readonly [BaseType, ...BaseType[]] = re
|
|
|
8
7
|
], 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
8
|
elements: T;
|
|
10
9
|
rest?: R;
|
|
11
|
-
}
|
|
10
|
+
}> {
|
|
12
11
|
static factory<T extends readonly [BaseType, ...BaseType[]], R extends BaseType | null = null>(elements: T, rest?: R): TupleType<T, R>;
|
|
13
12
|
}
|
|
14
13
|
export declare const tuple: typeof TupleType.factory;
|
package/dist/types/tuple.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../src/types/tuple.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"tuple.js","sourceRoot":"","sources":["../../src/types/tuple.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,SAMX,SAAQ,QAQT;IACC,MAAM,CAAC,OAAO,CAGZ,QAAW,EAAE,IAAI,GAAM,IAAS,EAAE;QAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;QACrD,OAAO,IAAI,SAAS,CAAO;YACzB,mBAAmB;YACnB,aAAa,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC;YACpD,mBAAmB;YACnB,aAAa,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC;YACpD,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC1B,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAA"}
|
package/dist/types/union.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ArrayMap } from '@nmtjs/common';
|
|
2
2
|
import type { ZodMiniDiscriminatedUnion, ZodMiniIntersection, ZodMiniUnion } from 'zod/mini';
|
|
3
|
-
import type { ZodPlainType } from './_utils.ts';
|
|
4
3
|
import type { BaseTypeAny } from './base.ts';
|
|
5
4
|
import type { LiteralType } from './literal.ts';
|
|
6
5
|
import type { ObjectType, ObjectTypeProps } from './object.ts';
|
|
@@ -10,7 +9,7 @@ export declare class UnionType<T extends readonly [BaseType, ...BaseType[]] = re
|
|
|
10
9
|
...BaseType[]
|
|
11
10
|
]> extends BaseType<ZodMiniUnion<ArrayMap<T, 'encodeZodType'>>, ZodMiniUnion<ArrayMap<T, 'decodeZodType'>>, {
|
|
12
11
|
options: T;
|
|
13
|
-
}
|
|
12
|
+
}> {
|
|
14
13
|
static factory<T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
15
14
|
BaseType,
|
|
16
15
|
...BaseType[]
|
|
@@ -32,7 +31,7 @@ export type DiscriminatedUnionOptionType<K extends string> = ObjectType<ObjectTy
|
|
|
32
31
|
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
32
|
key: K;
|
|
34
33
|
options: T;
|
|
35
|
-
}
|
|
34
|
+
}> {
|
|
36
35
|
static factory<K extends string = string, T extends readonly DiscriminatedUnionOptionType<K>[] = DiscriminatedUnionOptionType<K>[]>(key: K, ...options: T): DiscriminatedUnionType<K, T>;
|
|
37
36
|
}
|
|
38
37
|
export declare const union: typeof UnionType.factory;
|
package/dist/types/union.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../src/types/union.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,IAAI,qBAAqB,EAC3C,YAAY,IAAI,eAAe,EAC/B,KAAK,IAAI,QAAQ,GAClB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../src/types/union.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,IAAI,qBAAqB,EAC3C,YAAY,IAAI,eAAe,EAC/B,KAAK,IAAI,QAAQ,GAClB,MAAM,UAAU,CAAA;AAKjB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,SAKX,SAAQ,QAIT;IACC,MAAM,CAAC,OAAO,CAKZ,GAAG,OAAU,EAAE;QACf,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAGhD,CAAA;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAGhD,CAAA;QACD,OAAO,IAAI,SAAS,CAAI;YACtB,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC;YAC/B,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC;YAC/B,KAAK,EAAE,EAAE,OAAO,EAAE;SACnB,C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AC,OAAO,CAAA;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"temporal-polyfill": "^0.3.2",
|
|
43
43
|
"zod": "^4.0.0",
|
|
44
|
-
"@nmtjs/common": "0.16.0-beta.
|
|
44
|
+
"@nmtjs/common": "0.16.0-beta.5"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"temporal-polyfill": "^0.3.2",
|
|
48
48
|
"zod": "^4.0.0",
|
|
49
|
-
"@nmtjs/common": "0.16.0-beta.
|
|
49
|
+
"@nmtjs/common": "0.16.0-beta.5"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"temporal-polyfill": {
|
|
53
53
|
"optional": true
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"version": "0.16.0-beta.
|
|
56
|
+
"version": "0.16.0-beta.5",
|
|
57
57
|
"scripts": {
|
|
58
58
|
"clean-build": "rm -rf ./dist"
|
|
59
59
|
}
|
package/src/types/_type.ts
CHANGED
|
@@ -38,18 +38,4 @@ export namespace infer {
|
|
|
38
38
|
export type output<T extends BaseTypeAny> =
|
|
39
39
|
T['encodeZodType']['_zod']['output']
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
export namespace decodeRaw {
|
|
43
|
-
export type input<T extends BaseTypeAny> =
|
|
44
|
-
T['decodeRawZodType']['_zod']['input']
|
|
45
|
-
export type output<T extends BaseTypeAny> =
|
|
46
|
-
T['decodeRawZodType']['_zod']['output']
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export namespace encodeRaw {
|
|
50
|
-
export type input<T extends BaseTypeAny> =
|
|
51
|
-
T['encodeRawZodType']['_zod']['input']
|
|
52
|
-
export type output<T extends BaseTypeAny> =
|
|
53
|
-
T['encodeRawZodType']['_zod']['output']
|
|
54
|
-
}
|
|
55
41
|
}
|
package/src/types/_utils.ts
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZodMiniType } from 'zod/mini'
|
|
2
2
|
|
|
3
3
|
import type { BaseType } from './base.ts'
|
|
4
4
|
|
|
5
|
-
export const PlainType: unique symbol = Symbol('PlainType')
|
|
6
|
-
export type PlainType = typeof PlainType
|
|
7
|
-
|
|
8
|
-
export type ZodPlainType<T extends ZodMiniType<any, any, any>> = T &
|
|
9
|
-
ZodMiniType<
|
|
10
|
-
T['_zod']['output'] & { [PlainType]?: true },
|
|
11
|
-
T['_zod']['input'] & { [PlainType]?: true },
|
|
12
|
-
core.$ZodTypeInternals<
|
|
13
|
-
T['_zod']['output'] & { [PlainType]?: true },
|
|
14
|
-
T['_zod']['input'] & { [PlainType]?: true }
|
|
15
|
-
>
|
|
16
|
-
>
|
|
17
|
-
|
|
18
|
-
export const zodPlainType = <T extends ZodMiniType<any, any, any>>(type: T) =>
|
|
19
|
-
type as ZodPlainType<T>
|
|
20
|
-
|
|
21
5
|
export type AnyCompatibleType<Encoded = any, Decoded = any> = BaseType<
|
|
22
6
|
ZodMiniType<any, Decoded>,
|
|
23
7
|
ZodMiniType<any, Encoded>
|
package/src/types/array.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { core, ZodMiniArray } from 'zod/mini'
|
|
2
2
|
import { length, maxLength, minLength, array as zodArray } from 'zod/mini'
|
|
3
3
|
|
|
4
|
-
import type { ZodPlainType } from './_utils.ts'
|
|
5
4
|
import { BaseType } from './base.ts'
|
|
6
5
|
|
|
7
6
|
type Check = core.CheckFn<any[]> | core.$ZodCheck<any[]>
|
|
@@ -9,9 +8,7 @@ type Check = core.CheckFn<any[]> | core.$ZodCheck<any[]>
|
|
|
9
8
|
export class ArrayType<T extends BaseType = BaseType> extends BaseType<
|
|
10
9
|
ZodMiniArray<T['encodeZodType']>,
|
|
11
10
|
ZodMiniArray<T['decodeZodType']>,
|
|
12
|
-
{ element: T }
|
|
13
|
-
ZodPlainType<ZodMiniArray<T['encodeZodType']>>,
|
|
14
|
-
ZodPlainType<ZodMiniArray<T['encodeZodType']>>
|
|
11
|
+
{ element: T }
|
|
15
12
|
> {
|
|
16
13
|
static factory<T extends BaseType>(element: T, ...checks: Check[]) {
|
|
17
14
|
return new ArrayType<T>({
|
package/src/types/base.ts
CHANGED
|
@@ -70,14 +70,10 @@ export abstract class BaseType<
|
|
|
70
70
|
EncodeZodType extends SimpleZodType = SimpleZodType,
|
|
71
71
|
DecodeZodType extends ZodType = EncodeZodType,
|
|
72
72
|
Props extends TypeProps = TypeProps,
|
|
73
|
-
RawEncodeZodType extends SimpleZodType = EncodeZodType,
|
|
74
|
-
RawDecodeZodType extends ZodType = DecodeZodType,
|
|
75
73
|
> implements standard.Schema<DecodeZodType>
|
|
76
74
|
{
|
|
77
75
|
readonly encodeZodType: EncodeZodType
|
|
78
76
|
readonly decodeZodType: DecodeZodType
|
|
79
|
-
readonly encodeRawZodType!: RawEncodeZodType
|
|
80
|
-
readonly decodeRawZodType!: RawDecodeZodType
|
|
81
77
|
readonly props: Props
|
|
82
78
|
readonly params: TypeParams
|
|
83
79
|
readonly standard: {
|
package/src/types/object.ts
CHANGED
|
@@ -5,11 +5,9 @@ import {
|
|
|
5
5
|
record as zodRecord,
|
|
6
6
|
} from 'zod/mini'
|
|
7
7
|
|
|
8
|
-
import type { ZodPlainType } from './_utils.ts'
|
|
9
8
|
import type { BaseTypeAny, OptionalType } from './base.ts'
|
|
10
9
|
import type { LiteralType } from './literal.ts'
|
|
11
10
|
import type { StringType } from './string.ts'
|
|
12
|
-
import { zodPlainType } from './_utils.ts'
|
|
13
11
|
import { BaseType } from './base.ts'
|
|
14
12
|
import { EnumType } from './enum.ts'
|
|
15
13
|
|
|
@@ -18,13 +16,7 @@ export type ObjectTypeProps = { [k: string]: BaseTypeAny }
|
|
|
18
16
|
export class ObjectType<T extends ObjectTypeProps = {}> extends BaseType<
|
|
19
17
|
ZodMiniObject<{ [K in keyof T]: T[K]['encodeZodType'] }, core.$strip>,
|
|
20
18
|
ZodMiniObject<{ [K in keyof T]: T[K]['decodeZodType'] }, core.$strip>,
|
|
21
|
-
{ properties: T }
|
|
22
|
-
ZodPlainType<
|
|
23
|
-
ZodMiniObject<{ [K in keyof T]: T[K]['encodeZodType'] }, core.$strip>
|
|
24
|
-
>,
|
|
25
|
-
ZodPlainType<
|
|
26
|
-
ZodMiniObject<{ [K in keyof T]: T[K]['decodeZodType'] }, core.$strip>
|
|
27
|
-
>
|
|
19
|
+
{ properties: T }
|
|
28
20
|
> {
|
|
29
21
|
static factory<T extends ObjectTypeProps = {}>(properties: T) {
|
|
30
22
|
const encodeProperties = {} as {
|
|
@@ -50,13 +42,7 @@ export class ObjectType<T extends ObjectTypeProps = {}> extends BaseType<
|
|
|
50
42
|
export class LooseObjectType<T extends ObjectTypeProps = {}> extends BaseType<
|
|
51
43
|
ZodMiniObject<{ [K in keyof T]: T[K]['encodeZodType'] }, core.$loose>,
|
|
52
44
|
ZodMiniObject<{ [K in keyof T]: T[K]['decodeZodType'] }, core.$loose>,
|
|
53
|
-
{ properties: T }
|
|
54
|
-
ZodPlainType<
|
|
55
|
-
ZodMiniObject<{ [K in keyof T]: T[K]['encodeZodType'] }, core.$loose>
|
|
56
|
-
>,
|
|
57
|
-
ZodPlainType<
|
|
58
|
-
ZodMiniObject<{ [K in keyof T]: T[K]['decodeZodType'] }, core.$loose>
|
|
59
|
-
>
|
|
45
|
+
{ properties: T }
|
|
60
46
|
> {
|
|
61
47
|
static factory<T extends ObjectTypeProps = {}>(properties: T) {
|
|
62
48
|
const encodeProperties = {} as {
|
|
@@ -93,21 +79,15 @@ export class RecordType<
|
|
|
93
79
|
> extends BaseType<
|
|
94
80
|
ZodMiniRecord<K['encodeZodType'], E['encodeZodType']>,
|
|
95
81
|
ZodMiniRecord<K['decodeZodType'], E['decodeZodType']>,
|
|
96
|
-
{ key: K; element: E }
|
|
97
|
-
ZodPlainType<ZodMiniRecord<K['encodeZodType'], E['encodeZodType']>>,
|
|
98
|
-
ZodPlainType<ZodMiniRecord<K['decodeZodType'], E['decodeZodType']>>
|
|
82
|
+
{ key: K; element: E }
|
|
99
83
|
> {
|
|
100
84
|
static factory<
|
|
101
85
|
K extends LiteralType<string | number> | EnumType | StringType,
|
|
102
86
|
E extends BaseType,
|
|
103
87
|
>(key: K, element: E) {
|
|
104
88
|
return new RecordType<K, E>({
|
|
105
|
-
encodeZodType:
|
|
106
|
-
|
|
107
|
-
),
|
|
108
|
-
decodeZodType: zodPlainType(
|
|
109
|
-
zodRecord(key.decodeZodType, element.decodeZodType),
|
|
110
|
-
),
|
|
89
|
+
encodeZodType: zodRecord(key.encodeZodType, element.encodeZodType),
|
|
90
|
+
decodeZodType: zodRecord(key.decodeZodType, element.decodeZodType),
|
|
111
91
|
props: { key, element },
|
|
112
92
|
})
|
|
113
93
|
}
|
package/src/types/tuple.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { ArrayMap } from '@nmtjs/common'
|
|
|
2
2
|
import type { ZodMiniTuple } from 'zod/mini'
|
|
3
3
|
import { tuple as zodTuple } from 'zod/mini'
|
|
4
4
|
|
|
5
|
-
import type { ZodPlainType } from './_utils.ts'
|
|
6
5
|
import { BaseType } from './base.ts'
|
|
7
6
|
|
|
8
7
|
export class TupleType<
|
|
@@ -18,17 +17,7 @@ export class TupleType<
|
|
|
18
17
|
R extends BaseType
|
|
19
18
|
? ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, R['decodeZodType']>
|
|
20
19
|
: ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, null>,
|
|
21
|
-
{ elements: T; rest?: R }
|
|
22
|
-
R extends BaseType
|
|
23
|
-
? ZodPlainType<
|
|
24
|
-
ZodMiniTuple<ArrayMap<T, 'encodeZodType'>, R['encodeZodType']>
|
|
25
|
-
>
|
|
26
|
-
: ZodPlainType<ZodMiniTuple<ArrayMap<T, 'encodeZodType'>, null>>,
|
|
27
|
-
R extends BaseType
|
|
28
|
-
? ZodPlainType<
|
|
29
|
-
ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, R['decodeZodType']>
|
|
30
|
-
>
|
|
31
|
-
: ZodPlainType<ZodMiniTuple<ArrayMap<T, 'decodeZodType'>, null>>
|
|
20
|
+
{ elements: T; rest?: R }
|
|
32
21
|
> {
|
|
33
22
|
static factory<
|
|
34
23
|
T extends readonly [BaseType, ...BaseType[]],
|
package/src/types/union.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
union as zodUnion,
|
|
11
11
|
} from 'zod/mini'
|
|
12
12
|
|
|
13
|
-
import type { ZodPlainType } from './_utils.ts'
|
|
14
13
|
import type { BaseTypeAny } from './base.ts'
|
|
15
14
|
import type { LiteralType } from './literal.ts'
|
|
16
15
|
import type { ObjectType, ObjectTypeProps } from './object.ts'
|
|
@@ -24,9 +23,7 @@ export class UnionType<
|
|
|
24
23
|
> extends BaseType<
|
|
25
24
|
ZodMiniUnion<ArrayMap<T, 'encodeZodType'>>,
|
|
26
25
|
ZodMiniUnion<ArrayMap<T, 'decodeZodType'>>,
|
|
27
|
-
{ options: T }
|
|
28
|
-
ZodPlainType<ZodMiniUnion<ArrayMap<T, 'encodeZodType'>>>,
|
|
29
|
-
ZodPlainType<ZodMiniUnion<ArrayMap<T, 'decodeZodType'>>>
|
|
26
|
+
{ options: T }
|
|
30
27
|
> {
|
|
31
28
|
static factory<
|
|
32
29
|
T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
@@ -86,9 +83,7 @@ export class DiscriminatedUnionType<
|
|
|
86
83
|
> extends BaseType<
|
|
87
84
|
ZodMiniDiscriminatedUnion<ArrayMap<T, 'encodeZodType'>>,
|
|
88
85
|
ZodMiniDiscriminatedUnion<ArrayMap<T, 'decodeZodType'>>,
|
|
89
|
-
{ key: K; options: T }
|
|
90
|
-
ZodPlainType<ZodMiniDiscriminatedUnion<ArrayMap<T, 'encodeZodType'>>>,
|
|
91
|
-
ZodPlainType<ZodMiniDiscriminatedUnion<ArrayMap<T, 'decodeZodType'>>>
|
|
86
|
+
{ key: K; options: T }
|
|
92
87
|
> {
|
|
93
88
|
static factory<
|
|
94
89
|
K extends string = string,
|