@nmtjs/type 0.14.4 → 0.14.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/types/_plain.d.ts +13 -0
- package/dist/types/_plain.js +2 -0
- package/dist/types/_type.d.ts +8 -0
- package/dist/types/array.d.ts +2 -1
- package/dist/types/base.d.ts +3 -1
- package/dist/types/base.js +2 -0
- package/dist/types/object.d.ts +11 -3
- package/dist/types/object.js +3 -2
- package/dist/types/tuple.d.ts +2 -1
- package/dist/types/union.d.ts +3 -2
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
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
CHANGED
|
@@ -21,4 +21,12 @@ export declare namespace infer {
|
|
|
21
21
|
type input<T extends BaseTypeAny> = T['encodeZodType']['_zod']['input'];
|
|
22
22
|
type output<T extends BaseTypeAny> = T['encodeZodType']['_zod']['output'];
|
|
23
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
|
+
}
|
|
24
32
|
}
|
package/dist/types/array.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { core, ZodMiniArray } from 'zod/mini';
|
|
2
|
+
import type { ZodPlainType } from './_plain.ts';
|
|
2
3
|
import { BaseType } from './base.ts';
|
|
3
4
|
type Check = core.CheckFn<any[]> | core.$ZodCheck<any[]>;
|
|
4
5
|
export declare class ArrayType<T extends BaseType = BaseType> extends BaseType<ZodMiniArray<T['encodeZodType']>, ZodMiniArray<T['decodeZodType']>, {
|
|
5
6
|
element: T;
|
|
6
|
-
}
|
|
7
|
+
}, ZodPlainType<ZodMiniArray<T['encodeZodType']>>, ZodPlainType<ZodMiniArray<T['encodeZodType']>>> {
|
|
7
8
|
static factory<T extends BaseType>(element: T, ...checks: Check[]): ArrayType<T>;
|
|
8
9
|
min(value: number): ArrayType<T>;
|
|
9
10
|
max(value: number): ArrayType<T>;
|
package/dist/types/base.d.ts
CHANGED
|
@@ -24,9 +24,11 @@ export type BaseTypeAny<EncodedZodType extends SimpleZodType = SimpleZodType, De
|
|
|
24
24
|
export declare const typesRegistry: core.$ZodRegistry<TypeMetadata<any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>;
|
|
25
25
|
export declare const NeemataTypeError: core.$constructor<core.$ZodError<unknown>, core.$ZodIssue[]>;
|
|
26
26
|
export type NeemataTypeError = core.$ZodError;
|
|
27
|
-
export declare abstract class BaseType<EncodeZodType extends SimpleZodType = SimpleZodType, DecodeZodType extends ZodType = EncodeZodType, Props extends TypeProps = TypeProps> {
|
|
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
28
|
readonly encodeZodType: EncodeZodType;
|
|
29
29
|
readonly decodeZodType: DecodeZodType;
|
|
30
|
+
readonly encodeRawZodType: RawEncodeZodType;
|
|
31
|
+
readonly decodeRawZodType: RawDecodeZodType;
|
|
30
32
|
readonly props: Props;
|
|
31
33
|
readonly params: TypeParams;
|
|
32
34
|
constructor({ encodeZodType, decodeZodType, props, params, }: {
|
package/dist/types/base.js
CHANGED
package/dist/types/object.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { core, ZodMiniObject, ZodMiniRecord } from 'zod/mini';
|
|
2
|
+
import type { ZodPlainType } from './_plain.ts';
|
|
2
3
|
import type { BaseTypeAny, OptionalType } from './base.ts';
|
|
3
4
|
import type { LiteralType } from './literal.ts';
|
|
4
5
|
import type { StringType } from './string.ts';
|
|
@@ -14,13 +15,20 @@ export declare class ObjectType<T extends ObjectTypeProps = {}> extends BaseType
|
|
|
14
15
|
[K in keyof T]: T[K]['decodeZodType'];
|
|
15
16
|
}, core.$strict>, {
|
|
16
17
|
properties: T;
|
|
17
|
-
}
|
|
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>>> {
|
|
18
23
|
static factory<T extends ObjectTypeProps = {}>(properties: T): ObjectType<T>;
|
|
19
24
|
}
|
|
20
|
-
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']
|
|
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']>>> {
|
|
21
29
|
static factory<K extends LiteralType<string | number> | EnumType | StringType, E extends BaseType>(key: K, element: E): RecordType<K, E>;
|
|
22
30
|
}
|
|
23
|
-
export declare function keyof<T extends
|
|
31
|
+
export declare function keyof<T extends AnyObjectType>(type: T): EnumType<core.util.ToEnum<Extract<keyof T['props']['properties'], string>>>;
|
|
24
32
|
export declare function pick<T extends AnyObjectType, P extends {
|
|
25
33
|
[K in keyof T['props']['properties']]?: true;
|
|
26
34
|
}>(source: T, pick: P): ObjectType<{
|
package/dist/types/object.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { object as zodObject, record as zodRecord } from 'zod/mini';
|
|
2
|
+
import { zodPlainType } from "./_plain.js";
|
|
2
3
|
import { BaseType } from "./base.js";
|
|
3
4
|
import { EnumType } from "./enum.js";
|
|
4
5
|
export class ObjectType extends BaseType {
|
|
@@ -19,8 +20,8 @@ export class ObjectType extends BaseType {
|
|
|
19
20
|
export class RecordType extends BaseType {
|
|
20
21
|
static factory(key, element) {
|
|
21
22
|
return new RecordType({
|
|
22
|
-
encodeZodType: zodRecord(key.encodeZodType, element.encodeZodType),
|
|
23
|
-
decodeZodType: zodRecord(key.decodeZodType, element.decodeZodType),
|
|
23
|
+
encodeZodType: zodPlainType(zodRecord(key.encodeZodType, element.encodeZodType)),
|
|
24
|
+
decodeZodType: zodPlainType(zodRecord(key.decodeZodType, element.decodeZodType)),
|
|
24
25
|
props: { key, element },
|
|
25
26
|
});
|
|
26
27
|
}
|
package/dist/types/tuple.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ArrayMap } from '@nmtjs/common';
|
|
2
2
|
import type { ZodMiniTuple } from 'zod/mini';
|
|
3
|
+
import type { ZodPlainType } from './_plain.ts';
|
|
3
4
|
import { BaseType } from './base.ts';
|
|
4
5
|
export declare class TupleType<T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
5
6
|
BaseType,
|
|
@@ -7,7 +8,7 @@ export declare class TupleType<T extends readonly [BaseType, ...BaseType[]] = re
|
|
|
7
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>, {
|
|
8
9
|
elements: T;
|
|
9
10
|
rest?: R;
|
|
10
|
-
}
|
|
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>>> {
|
|
11
12
|
static factory<T extends readonly [BaseType, ...BaseType[]], R extends BaseType | null = null>(elements: T, rest?: R): TupleType<T, R>;
|
|
12
13
|
}
|
|
13
14
|
export declare const tuple: typeof TupleType.factory;
|
package/dist/types/union.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ArrayMap } from '@nmtjs/common';
|
|
2
2
|
import type { ZodMiniDiscriminatedUnion, ZodMiniIntersection, ZodMiniUnion } from 'zod/mini';
|
|
3
|
+
import type { ZodPlainType } from './_plain.ts';
|
|
3
4
|
import type { BaseTypeAny } from './base.ts';
|
|
4
5
|
import type { LiteralType } from './literal.ts';
|
|
5
6
|
import type { ObjectType, ObjectTypeProps } from './object.ts';
|
|
@@ -9,7 +10,7 @@ export declare class UnionType<T extends readonly [BaseType, ...BaseType[]] = re
|
|
|
9
10
|
...BaseType[]
|
|
10
11
|
]> extends BaseType<ZodMiniUnion<ArrayMap<T, 'encodeZodType'>>, ZodMiniUnion<ArrayMap<T, 'decodeZodType'>>, {
|
|
11
12
|
options: T;
|
|
12
|
-
}
|
|
13
|
+
}, ZodPlainType<ZodMiniUnion<ArrayMap<T, 'encodeZodType'>>>, ZodPlainType<ZodMiniUnion<ArrayMap<T, 'decodeZodType'>>>> {
|
|
13
14
|
static factory<T extends readonly [BaseType, ...BaseType[]] = readonly [
|
|
14
15
|
BaseType,
|
|
15
16
|
...BaseType[]
|
|
@@ -31,7 +32,7 @@ export type DiscriminatedUnionOptionType<K extends string> = ObjectType<ObjectTy
|
|
|
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'>>, {
|
|
32
33
|
key: K;
|
|
33
34
|
options: T;
|
|
34
|
-
}
|
|
35
|
+
}, ZodPlainType<ZodMiniDiscriminatedUnion<ArrayMap<T, 'encodeZodType'>>>, ZodPlainType<ZodMiniDiscriminatedUnion<ArrayMap<T, 'decodeZodType'>>>> {
|
|
35
36
|
static factory<K extends string = string, T extends readonly DiscriminatedUnionOptionType<K>[] = DiscriminatedUnionOptionType<K>[]>(key: K, ...options: T): DiscriminatedUnionType<K, T>;
|
|
36
37
|
}
|
|
37
38
|
export declare const union: typeof UnionType.factory;
|
package/package.json
CHANGED
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"temporal-polyfill": "^0.3.0",
|
|
36
36
|
"zod": "^4.0.0",
|
|
37
|
-
"@nmtjs/common": "0.14.
|
|
37
|
+
"@nmtjs/common": "0.14.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"temporal-polyfill": "^0.3.0",
|
|
41
41
|
"zod": "^4.0.0",
|
|
42
|
-
"@nmtjs/common": "0.14.
|
|
42
|
+
"@nmtjs/common": "0.14.5"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"temporal-polyfill": {
|
|
46
46
|
"optional": true
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
-
"version": "0.14.
|
|
49
|
+
"version": "0.14.5",
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsc",
|
|
52
52
|
"type-check": "tsc --noEmit"
|