@nmtjs/type 0.12.5 → 0.12.6
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/index.d.ts +4 -0
- package/dist/index.js +1 -3
- package/dist/temporal.d.ts +1 -0
- package/dist/temporal.js +0 -2
- package/dist/types/any.d.ts +6 -0
- package/dist/types/any.js +6 -6
- package/dist/types/array.d.ts +13 -0
- package/dist/types/array.js +21 -23
- package/dist/types/base.d.ts +62 -0
- package/dist/types/base.js +67 -65
- package/dist/types/boolean.d.ts +6 -0
- package/dist/types/boolean.js +6 -6
- package/dist/types/custom.d.ts +14 -0
- package/dist/types/custom.js +21 -21
- package/dist/types/date.d.ts +6 -0
- package/dist/types/date.js +8 -10
- package/dist/types/enum.d.ts +10 -0
- package/dist/types/enum.js +7 -9
- package/dist/types/literal.d.ts +8 -0
- package/dist/types/literal.js +7 -9
- package/dist/types/never.d.ts +6 -0
- package/dist/types/never.js +6 -6
- package/dist/types/number.d.ts +23 -0
- package/dist/types/number.js +36 -38
- package/dist/types/object.d.ts +43 -0
- package/dist/types/object.js +39 -44
- package/dist/types/string.d.ts +22 -0
- package/dist/types/string.js +49 -51
- package/dist/types/temporal.d.ts +45 -0
- package/dist/types/temporal.js +74 -76
- package/dist/types/tuple.d.ts +13 -0
- package/dist/types/tuple.js +12 -15
- package/dist/types/type.d.ts +24 -0
- package/dist/types/type.js +0 -2
- package/dist/types/union.d.ts +40 -0
- package/dist/types/union.js +29 -32
- package/package.json +8 -6
- package/dist/index.js.map +0 -1
- package/dist/temporal.js.map +0 -1
- package/dist/types/any.js.map +0 -1
- package/dist/types/array.js.map +0 -1
- package/dist/types/base.js.map +0 -1
- package/dist/types/boolean.js.map +0 -1
- package/dist/types/custom.js.map +0 -1
- package/dist/types/date.js.map +0 -1
- package/dist/types/enum.js.map +0 -1
- package/dist/types/literal.js.map +0 -1
- package/dist/types/never.js.map +0 -1
- package/dist/types/number.js.map +0 -1
- package/dist/types/object.js.map +0 -1
- package/dist/types/string.js.map +0 -1
- package/dist/types/temporal.js.map +0 -1
- package/dist/types/tuple.js.map +0 -1
- package/dist/types/type.js.map +0 -1
- package/dist/types/union.js.map +0 -1
package/dist/types/union.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
import * as zod from
|
|
1
|
+
import * as zod from 'zod/v4-mini';
|
|
2
2
|
import { BaseType } from "./base.js";
|
|
3
3
|
export class UnionType extends BaseType {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
static factory(...options) {
|
|
5
|
+
const encoded = options.map((t) => t.encodedZodType);
|
|
6
|
+
const decoded = options.map((t) => t.decodedZodType);
|
|
7
|
+
return new UnionType({
|
|
8
|
+
encodedZodType: zod.union(encoded),
|
|
9
|
+
decodedZodType: zod.union(decoded),
|
|
10
|
+
props: { options },
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
13
|
}
|
|
14
14
|
export class IntersactionType extends BaseType {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
static factory(...options) {
|
|
16
|
+
const [first, second] = options;
|
|
17
|
+
return new IntersactionType({
|
|
18
|
+
encodedZodType: zod.intersection(first.encodedZodType, second.encodedZodType),
|
|
19
|
+
decodedZodType: zod.intersection(first.decodedZodType, second.decodedZodType),
|
|
20
|
+
props: { options },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
23
|
}
|
|
24
24
|
export class DiscriminatedUnionType extends BaseType {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
25
|
+
static factory(key, ...options) {
|
|
26
|
+
const encoded = options.map((t) => t.encodedZodType);
|
|
27
|
+
const decoded = options.map((t) => t.decodedZodType);
|
|
28
|
+
return new DiscriminatedUnionType({
|
|
29
|
+
// @ts-expect-error
|
|
30
|
+
encodedZodType: zod.discriminatedUnion(key, encoded),
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
decodedZodType: zod.discriminatedUnion(key, decoded),
|
|
33
|
+
props: { key, options },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
37
36
|
}
|
|
38
37
|
export const union = UnionType.factory;
|
|
39
38
|
export const or = UnionType.factory;
|
|
40
39
|
export const intersection = IntersactionType.factory;
|
|
41
40
|
export const and = IntersactionType.factory;
|
|
42
41
|
export const discriminatedUnion = DiscriminatedUnionType.factory;
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=union.js.map
|
package/package.json
CHANGED
|
@@ -3,23 +3,25 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
6
7
|
"import": "./dist/index.js",
|
|
7
|
-
"
|
|
8
|
+
"module-sync": "./dist/index.js"
|
|
8
9
|
},
|
|
9
10
|
"./temporal": {
|
|
11
|
+
"types": "./dist/temporal.d.ts",
|
|
10
12
|
"import": "./dist/temporal.js",
|
|
11
|
-
"
|
|
13
|
+
"module-sync": "./dist/temporal.js"
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"peerDependencies": {
|
|
15
17
|
"temporal-polyfill": "^0.3.0",
|
|
16
18
|
"zod": "^3.25.0",
|
|
17
|
-
"@nmtjs/common": "0.12.
|
|
19
|
+
"@nmtjs/common": "0.12.6"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
22
|
"temporal-polyfill": "^0.3.0",
|
|
21
23
|
"zod": "^3.25.0",
|
|
22
|
-
"@nmtjs/common": "0.12.
|
|
24
|
+
"@nmtjs/common": "0.12.6"
|
|
23
25
|
},
|
|
24
26
|
"files": [
|
|
25
27
|
"src",
|
|
@@ -27,9 +29,9 @@
|
|
|
27
29
|
"LICENSE.md",
|
|
28
30
|
"README.md"
|
|
29
31
|
],
|
|
30
|
-
"version": "0.12.
|
|
32
|
+
"version": "0.12.6",
|
|
31
33
|
"scripts": {
|
|
32
|
-
"build": "
|
|
34
|
+
"build": "tsc",
|
|
33
35
|
"type-check": "tsc --noEmit"
|
|
34
36
|
}
|
|
35
37
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,YAAY,UAAU,iBAAiB;AAEvC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC;AAEjC,cAAc;AACd,SAAS,MAAM,QAAQ;AACvB,eAAe","names":[],"sources":["../src/index.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport * as type from './types/type.ts'\n\nzod.config(zod.core.locales.en())\n\nexport * from './types/base.ts'\nexport { type, type as t }\nexport default type\n"],"version":3,"file":"index.js"}
|
package/dist/temporal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,cAAc","names":[],"sources":["../src/temporal.ts"],"sourcesContent":["export * from './types/temporal.ts'\n"],"version":3,"file":"temporal.js"}
|
package/dist/types/any.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAgB,WAAW;AAEpC,OAAO,MAAM,gBAAgB,SAAyB;CACpD,OAAO,UAAU;AACf,SAAO,IAAI,QAAQ,EACjB,gBAAgB,IAAI,KAAK,CAC1B;CACF;AACF;AAED,OAAO,MAAM,MAAM,QAAQ","names":[],"sources":["../../src/types/any.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType } from './base.ts'\n\nexport class AnyType extends BaseType<zod.ZodMiniAny> {\n static factory() {\n return new AnyType({\n encodedZodType: zod.any(),\n })\n }\n}\n\nexport const any = AnyType.factory\n"],"version":3,"file":"any.js"}
|
package/dist/types/array.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAgB,WAAW;AAIpC,OAAO,MAAM,kBAAiD,SAI5D;CACA,OAAO,QAA4BA,SAAY,GAAG,QAAiB;AACjE,SAAO,IAAI,UAAa;GACtB,gBAAgB,IAAI,MAAM,QAAQ,eAAe,CAAC,MAAM,GAAG,OAAO;GAClE,gBAAgB,IAAI,MAAM,QAAQ,eAAe,CAAC,MAAM,GAAG,OAAO;GAClE,QAAQ,EAAE,OAAQ;GAClB,OAAO,EAAE,QAAS;EACnB;CACF;CAED,IAAIC,OAAe;EACjB,MAAM,QAAQ,IAAI,UAAU,MAAM;AAClC,SAAO,UAAU,QACf,KAAK,MAAM,SACX,GAAG,KAAK,OAAO,QACf,MACD;CACF;CAED,IAAIA,OAAe;EACjB,MAAM,QAAQ,IAAI,UAAU,MAAM;AAClC,SAAO,UAAU,QACf,KAAK,MAAM,SACX,GAAG,KAAK,OAAO,QACf,MACD;CACF;CAED,OAAOA,OAAe;EACpB,MAAM,QAAQ,IAAI,OAAO,MAAM;AAC/B,SAAO,UAAU,QACf,KAAK,MAAM,SACX,GAAG,KAAK,OAAO,QACf,MACD;CACF;AACF;AAED,OAAO,MAAM,QAAQ,UAAU","names":["element: T","value: number"],"sources":["../../src/types/array.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType } from './base.ts'\n\ntype Check = zod.core.CheckFn<any[]> | zod.core.$ZodCheck<any[]>\n\nexport class ArrayType<T extends BaseType = BaseType> extends BaseType<\n zod.ZodMiniArray<T['encodedZodType']>,\n zod.ZodMiniArray<T['decodedZodType']>,\n { element: T }\n> {\n static factory<T extends BaseType>(element: T, ...checks: Check[]) {\n return new ArrayType<T>({\n encodedZodType: zod.array(element.encodedZodType).check(...checks),\n decodedZodType: zod.array(element.decodedZodType).check(...checks),\n params: { checks },\n props: { element },\n })\n }\n\n min(value: number) {\n const check = zod.minLength(value)\n return ArrayType.factory<T>(\n this.props.element,\n ...this.params.checks,\n check,\n )\n }\n\n max(value: number) {\n const check = zod.maxLength(value)\n return ArrayType.factory<T>(\n this.props.element,\n ...this.params.checks,\n check,\n )\n }\n\n length(value: number) {\n const check = zod.length(value)\n return ArrayType.factory<T>(\n this.props.element,\n ...this.params.checks,\n check,\n )\n }\n}\n\nexport const array = ArrayType.factory\n"],"version":3,"file":"array.js"}
|
package/dist/types/base.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAkDlC,OAAO,MAAM,gBAAgB,IAAI,UAAwB;AAEzD,OAAO,MAAM,mBAAmB,IAAI,KAAK;AAGzC,OAAO,MAAe,SAIpB;CACA,AAAS;CACT,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAY,EACV,gBACA,iBAAiB,gBACjB,QAAQ,CAAE,GACV,SAAS,CAAE,GAMZ,EAAE;AACD,OAAK,iBAAiB;AACtB,OAAK,iBAAiB;AAEtB,OAAK,QAAQ;AACb,OAAK,SAAS,OAAO,OAAO,EAAE,QAAQ,CAAE,EAAE,GAAE,OAAO;CACpD;CAED,WAA+B;AAC7B,SAAO,aAAa,QAAQ,KAAK;CAClC;CAED,WAA+B;AAC7B,SAAO,aAAa,QAAQ,KAAK;CAClC;CAED,UAAU;AACR,SAAO,KAAK,UAAU,CAAC,UAAU;CAClC;CAED,QAAQA,OAAmE;AACzE,SAAO,YAAY,QAAQ,MAAM,MAAM;CACxC;CAED,MAAMC,OAAqB;AACzB,SAAO,KAAK,KAAK,EAAE,MAAO,EAAC;CAC5B;CAED,YAAYC,aAA2B;AACrC,SAAO,KAAK,KAAK,EAAE,YAAa,EAAC;CAClC;CAED,SAAS,GAAG,UAA2D;AACrE,SAAO,KAAK,KAAK,EACf,UAAU,KAAK,OAAO,SAClB,SAAS,IAAI,KAAK,OAAO,OAAO,GAChC,SACL,EAAC;CACH;CAED,KAAKC,aAAiC;EACpC,MAAM,WAAW,cAAc,IAAI,KAAK,eAAe,IAAI,CAAE;AAC7D,SAAO,OAAO,UAAU,YAAY;AACpC,gBAAc,IAAI,KAAK,gBAAgB,SAAS;AAChD,SAAO;CACR;CAED,OACEC,MAC0C;AAC1C,SAAO,KAAK,eAAe,MAAM,MAAM,EAAE,aAAa,KAAM,EAAC;CAC9D;CAED,OACEC,MAC0C;AAC1C,SAAO,KAAK,eAAe,MAAM,MAAM,EAAE,aAAa,KAAM,EAAC;CAC9D;AACF;AAED,OAAO,MAAM,qBAEH,SAIR;CACA,OAAO,QAA+BC,MAAS;AAC7C,SAAO,IAAI,aAAgB;GACzB,gBAAgB,IAAI,SAAS,KAAK,eAAe;GACjD,OAAO,EAAE,OAAO,KAAM;EACvB;CACF;AACF;AAED,OAAO,MAAM,qBAEH,SAIR;CACA,OAAO,QAAoCA,MAAS;AAClD,SAAO,IAAI,aAAgB;GACzB,gBAAgB,IAAI,SAAS,KAAK,eAAe;GACjD,OAAO,EAAE,OAAO,KAAM;EACvB;CACF;AACF;AAED,OAAO,MAAM,oBAEH,SAIR;CACA,OAAO,QAAoCA,MAASC,cAAmB;AACrE,SAAO,IAAI,YAAe;GACxB,gBAAgB,IAAI,SAClB,KAAK,gBACL,KAAK,OAAO,SAAS,aAAa,IAAI,aACvC;GACD,gBAAgB,IAAI,SAAS,KAAK,gBAAgB,aAAa;GAC/D,OAAO,EAAE,OAAO,KAAM;EACvB;CACF;AACF","names":["value: this['encodedZodType']['_zod']['input']","title: string","description: string","newMetadata: TypeMetadata","data: this['encodedZodType']['_zod']['input']","data: this['decodedZodType']['_zod']['input']","type: T","defaultValue: any"],"sources":["../../src/types/base.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\n\nexport type PrimitiveValueType = string | number | boolean | null\n\nexport type PrimitiveZodType =\n | zod.ZodMiniNever\n | zod.ZodMiniDefault\n | zod.ZodMiniNullable\n | zod.ZodMiniOptional\n | zod.ZodMiniString\n | zod.ZodMiniObject\n | zod.ZodMiniAny\n | zod.ZodMiniArray\n | zod.ZodMiniBoolean\n | zod.ZodMiniNumber\n | zod.ZodMiniEnum<any>\n | zod.ZodMiniLiteral<PrimitiveValueType>\n | zod.ZodMiniUnion\n | zod.ZodMiniIntersection\n | zod.ZodMiniRecord\n\nexport type SimpleZodType = zod.ZodMiniType\n\nexport type ZodType = SimpleZodType | zod.ZodMiniType\n\nexport type TypeProps = Record<string, any>\n\nexport type TypeMetadata<T = any> = {\n id?: string\n description?: string\n examples?: T[]\n title?: string\n}\n\nexport type TypeParams = {\n encode?: (value: any) => any\n metadata?: TypeMetadata\n checks: Array<zod.core.CheckFn<any> | zod.core.$ZodCheck<any>>\n}\n\nexport type DefaultTypeParams = {\n encode?: TypeParams['encode']\n metadata?: TypeMetadata\n}\n\nexport type BaseTypeAny<\n EncodedZodType extends SimpleZodType = SimpleZodType,\n DecodedZodType extends ZodType = zod.ZodMiniType,\n> = BaseType<EncodedZodType, DecodedZodType, TypeProps>\n\nexport const typesRegistry = zod.registry<TypeMetadata>()\n\nexport const NeemataTypeError = zod.core.$ZodError\nexport type NeemataTypeError = zod.core.$ZodError\n\nexport abstract class BaseType<\n EncodedZodType extends SimpleZodType = SimpleZodType,\n DecodedZodType extends ZodType = EncodedZodType,\n Props extends TypeProps = TypeProps,\n> {\n readonly encodedZodType: EncodedZodType\n readonly decodedZodType: DecodedZodType\n readonly props: Props\n readonly params: TypeParams\n\n constructor({\n encodedZodType,\n decodedZodType = encodedZodType as unknown as DecodedZodType,\n props = {} as Props,\n params = {} as Partial<TypeParams>,\n }: {\n encodedZodType: EncodedZodType\n decodedZodType?: DecodedZodType\n props?: Props\n params?: Partial<TypeParams>\n }) {\n this.encodedZodType = encodedZodType\n this.decodedZodType = decodedZodType\n\n this.props = props\n this.params = Object.assign({ checks: [] }, params)\n }\n\n optional(): OptionalType<this> {\n return OptionalType.factory(this)\n }\n\n nullable(): NullableType<this> {\n return NullableType.factory(this)\n }\n\n nullish() {\n return this.nullable().optional()\n }\n\n default(value: this['encodedZodType']['_zod']['input']): DefaultType<this> {\n return DefaultType.factory(this, value)\n }\n\n title(title: string): this {\n return this.meta({ title })\n }\n\n description(description: string): this {\n return this.meta({ description })\n }\n\n examples(...examples: this['encodedZodType']['_zod']['input'][]): this {\n return this.meta({\n examples: this.params.encode\n ? examples.map(this.params.encode)\n : examples,\n })\n }\n\n meta(newMetadata: TypeMetadata): this {\n const metadata = typesRegistry.get(this.encodedZodType) ?? {}\n Object.assign(metadata, newMetadata)\n typesRegistry.add(this.encodedZodType, metadata)\n return this\n }\n\n encode(\n data: this['encodedZodType']['_zod']['input'],\n ): this['encodedZodType']['_zod']['output'] {\n return this.encodedZodType.parse(data, { reportInput: true })\n }\n\n decode(\n data: this['decodedZodType']['_zod']['input'],\n ): this['decodedZodType']['_zod']['output'] {\n return this.decodedZodType.parse(data, { reportInput: true })\n }\n}\n\nexport class OptionalType<\n Type extends BaseTypeAny = BaseTypeAny,\n> extends BaseType<\n zod.ZodMiniOptional<Type['encodedZodType']>,\n zod.ZodMiniOptional<Type['decodedZodType']>,\n { inner: Type }\n> {\n static factory<T extends BaseTypeAny>(type: T) {\n return new OptionalType<T>({\n encodedZodType: zod.optional(type.encodedZodType) as any,\n props: { inner: type },\n })\n }\n}\n\nexport class NullableType<\n Type extends BaseTypeAny<any> = BaseTypeAny<any>,\n> extends BaseType<\n zod.ZodMiniNullable<Type['encodedZodType']>,\n zod.ZodMiniNullable<Type['decodedZodType']>,\n { inner: Type }\n> {\n static factory<T extends BaseTypeAny<any>>(type: T) {\n return new NullableType<T>({\n encodedZodType: zod.nullable(type.encodedZodType),\n props: { inner: type },\n })\n }\n}\n\nexport class DefaultType<\n Type extends BaseTypeAny = BaseTypeAny,\n> extends BaseType<\n zod.ZodMiniDefault<Type['encodedZodType']>,\n zod.ZodMiniDefault<Type['decodedZodType']>,\n { inner: Type }\n> {\n static factory<T extends BaseTypeAny<any>>(type: T, defaultValue: any) {\n return new DefaultType<T>({\n encodedZodType: zod._default(\n type.encodedZodType,\n type.params.encode?.(defaultValue) ?? defaultValue,\n ) as any,\n decodedZodType: zod._default(type.decodedZodType, defaultValue) as any,\n props: { inner: type },\n })\n }\n}\n"],"version":3,"file":"base.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAgB,WAAW;AAEpC,OAAO,MAAM,oBAAoB,SAAsC;CACrE,OAAO,UAAU;AACf,SAAO,IAAI,YAAY,EACrB,gBAAgB,IAAI,SAAS,CAC9B;CACF;AACF;AAED,OAAO,MAAM,UAAU,YAAY","names":[],"sources":["../../src/types/boolean.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType } from './base.ts'\n\nexport class BooleanType extends BaseType<zod.ZodMiniBoolean<boolean>> {\n static factory() {\n return new BooleanType({\n encodedZodType: zod.boolean(),\n })\n }\n}\n\nexport const boolean = BooleanType.factory\n"],"version":3,"file":"boolean.js"}
|
package/dist/types/custom.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAkD,WAAW;AAGtE,OAAO,MAAe,sBAIZ,SAYR,CAAE;AAEJ,OAAO,MAAM,mBAIH,cAA8C;CACtD,OAAO,QAIL,EACA,QACA,QACA,OACA,OAAO,IAAI,KAAK,EAYjB,EAAE;AACD,SAAO,IAAI,WAA2C;GACpD,gBAAgB,IAAI,KAClB,IAAI,QAAQ,CAAC,MACX,IAAI,OAAO,CAAC,eAAe,QAAQ,aAAa;IAC9C;IACA,OAAO;GACR,EAAC,EACF,IAAI,UAAU,OAAO,CACtB,EACD,KACD;GAED,gBAAgB,IAAI;IAClB;;IAEA,IACG,QAAQ,CACR,MACC,IAAI,OAAO,CAAC,eAAe,QAAQ,aAAa;KAC9C;KACA,OAAO;IACR,EAAC,EACF,IAAI,UAAU,OAAO,CACtB;CACJ;GACD,QAAQ,EAAE,OAAQ;EACnB;CACF;AACF;AAED,OAAO,MAAM,SAAS,WAAW","names":[],"sources":["../../src/types/custom.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType, type SimpleZodType, type ZodType } from './base.ts'\n\nexport type CustomTransformFn<I, O> = (value: I) => O\nexport abstract class TransformType<\n Type,\n EncodedType extends SimpleZodType = zod.ZodMiniType<Type, Type>,\n DecodedType extends ZodType = zod.ZodMiniType<Type, Type>,\n> extends BaseType<\n zod.ZodMiniPipe<\n zod.ZodMiniType<\n DecodedType['_zod']['output'],\n DecodedType['_zod']['input']\n >,\n EncodedType\n >,\n zod.ZodMiniPipe<\n EncodedType,\n zod.ZodMiniType<DecodedType['_zod']['output'], DecodedType['_zod']['input']>\n >\n> {}\n\nexport class CustomType<\n Type,\n EncodedType extends SimpleZodType = zod.ZodMiniType<Type, Type>,\n DecodedType extends ZodType = zod.ZodMiniType<Type, Type>,\n> extends TransformType<Type, EncodedType, DecodedType> {\n static factory<\n Type,\n EncodedType extends SimpleZodType = zod.ZodMiniType<Type, Type>,\n DecodedType extends ZodType = zod.ZodMiniType<Type, Type>,\n >({\n decode,\n encode,\n error,\n type = zod.any() as unknown as EncodedType,\n }: {\n decode: CustomTransformFn<\n EncodedType['_zod']['input'],\n DecodedType['_zod']['output']\n >\n encode: CustomTransformFn<\n DecodedType['_zod']['input'],\n EncodedType['_zod']['output']\n >\n error?: string | zod.core.$ZodErrorMap<zod.core.$ZodIssueBase>\n type?: EncodedType\n }) {\n return new CustomType<Type, EncodedType, DecodedType>({\n encodedZodType: zod.pipe(\n zod.custom().check(\n zod.refine((val) => typeof val !== 'undefined', {\n error,\n abort: true,\n }),\n zod.overwrite(encode),\n ),\n type,\n ),\n // @ts-expect-error\n decodedZodType: zod.pipe(\n type,\n // @ts-expect-error\n zod\n .custom()\n .check(\n zod.refine((val) => typeof val !== 'undefined', {\n error,\n abort: true,\n }),\n zod.overwrite(decode),\n ),\n ),\n params: { encode },\n })\n }\n}\n\nexport const custom = CustomType.factory\n"],"version":3,"file":"custom.js"}
|
package/dist/types/date.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,YAAY,qBAAqB,aAAa;AAEvD,OAAO,MAAM,iBAAiB,cAG5B;CACA,OAAO,UAAU;AACf,SAAO,WAAW,QAGhB;GACA,QAAQ,CAACA,UAAwB,IAAI,KAAK;GAC1C,QAAQ,CAACC,UAAwB,MAAM,aAAa;GACpD,MAAM,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,EAAE,IAAI,IAAI,UAAU,AAAC,EAAC;EACtD,EAAC;CACH;AACF;AAED,OAAO,MAAM,OAAO,SAAS","names":["value: string","value: Date"],"sources":["../../src/types/date.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { CustomType, TransformType } from './custom.ts'\n\nexport class DateType extends TransformType<\n Date,\n zod.ZodMiniUnion<[zod.iso.ZodMiniISODate, zod.iso.ZodMiniISODateTime]>\n> {\n static factory() {\n return CustomType.factory<\n Date,\n zod.ZodMiniUnion<[zod.iso.ZodMiniISODate, zod.iso.ZodMiniISODateTime]>\n >({\n decode: (value: string): Date => new Date(value),\n encode: (value: Date): string => value.toISOString(),\n type: zod.union([zod.iso.date(), zod.iso.datetime()]),\n })\n }\n}\n\nexport const date = DateType.factory\n"],"version":3,"file":"date.js"}
|
package/dist/types/enum.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAgB,WAAW;AAEpC,OAAO,MAAM,iBAEH,SAAgE;CAKxE,OAAO,QAAqDA,QAAW;AACrE,SAAO,IAAI,SAAS;GAClB,gBAAgB,IAAI,KAAK,OAAc;GACvC,OAAO,EAAE,OAAQ;EAClB;CACF;AACF;AAED,MAAM,QAAQ,SAAS;AAEvB,SAAS,SAAS","names":["values: T"],"sources":["../../src/types/enum.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType } from './base.ts'\n\nexport class EnumType<\n T extends zod.core.util.EnumLike = zod.core.util.EnumLike,\n> extends BaseType<zod.ZodMiniEnum<T>, zod.ZodMiniEnum<T>, { values: T }> {\n static factory<T extends zod.core.util.EnumLike>(values: T): EnumType<T>\n static factory<T extends string[]>(\n values: T,\n ): EnumType<zod.core.util.ToEnum<T[number]>>\n static factory<T extends zod.core.util.EnumLike | string[]>(values: T) {\n return new EnumType({\n encodedZodType: zod.enum(values as any),\n props: { values },\n })\n }\n}\n\nconst _enum = EnumType.factory\n\nexport { _enum as enum }\n"],"version":3,"file":"enum.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAyC,WAAW;AAE7D,OAAO,MAAM,oBAEH,SAAqE;CAC7E,OAAO,QAAsCA,OAAU;AACrD,SAAO,IAAI,YAAe;GACxB,gBAAgB,IAAI,QAAQ,MAAM;GAClC,OAAO,EAAE,MAAO;EACjB;CACF;AACF;AAED,OAAO,MAAM,UAAU,YAAY","names":["value: T"],"sources":["../../src/types/literal.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType, type PrimitiveValueType } from './base.ts'\n\nexport class LiteralType<\n T extends PrimitiveValueType = PrimitiveValueType,\n> extends BaseType<zod.ZodMiniLiteral<T>, zod.ZodMiniLiteral<T>, { value: T }> {\n static factory<T extends PrimitiveValueType>(value: T) {\n return new LiteralType<T>({\n encodedZodType: zod.literal(value),\n props: { value },\n })\n }\n}\n\nexport const literal = LiteralType.factory\n"],"version":3,"file":"literal.js"}
|
package/dist/types/never.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAgB,WAAW;AAEpC,OAAO,MAAM,kBAAkB,SAA2B;CACxD,OAAO,UAAU;AACf,SAAO,IAAI,UAAU,EACnB,gBAAgB,IAAI,OAAO,CAC5B;CACF;AACF;AAED,OAAO,MAAM,QAAQ,UAAU","names":[],"sources":["../../src/types/never.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType } from './base.ts'\n\nexport class NeverType extends BaseType<zod.ZodMiniNever> {\n static factory() {\n return new NeverType({\n encodedZodType: zod.never(),\n })\n }\n}\n\nexport const never = NeverType.factory\n"],"version":3,"file":"never.js"}
|
package/dist/types/number.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAgB,WAAW;AACpC,SAAS,YAAY,qBAAqB,aAAa;AAIvD,OAAO,MAAM,mBAAmB,SAG9B;CACA,OAAO,QAAQ,GAAG,QAAiB;AACjC,SAAO,IAAI,WAAW;GACpB,gBAAgB,IAAI,QAAQ,CAAC,MAAM,GAAG,OAAO;GAC7C,QAAQ,EAAE,OAAQ;EACnB;CACF;CAED,WAAW;AACT,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,IAAI,EAAE,CAAC;CAC7D;CAED,WAAW;AACT,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,IAAI,EAAE,CAAC;CAC7D;CAED,GAAGA,OAAe;AAChB,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,MAAM,CAAC;CAChE;CAED,IAAIA,OAAe;AACjB,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,IAAI,MAAM,CAAC;CACjE;CAED,IAAIA,OAAe;AACjB,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,IAAI,MAAM,CAAC;CACjE;CAED,GAAGA,OAAe;AAChB,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,GAAG,MAAM,CAAC;CAChE;AACF;AAED,OAAO,MAAM,oBAAoB,WAAW;CAC1C,OAAO,QAAQ,GAAG,QAAiB;AACjC,SAAO,WAAW,QAAQ,GAAG,QAAQ,IAAI,KAAK,CAAC;CAChD;AACF;AAED,OAAO,MAAM,mBAAmB,cAG9B;CACA,OAAO,UAAU;AACf,SAAO,WAAW,QAA2C;GAC3D,QAAQ,CAAC,UAAU,OAAO,MAAM;GAChC,QAAQ,CAAC,UAAU,MAAM,UAAU;GACnC,MAAM,IAAI,QAAQ,CAAC,MAAM,IAAI,MAAM,UAAU,CAAC;GAC9C,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,SAAS,WAAW;AACjC,OAAO,MAAM,UAAU,YAAY;AACnC,OAAO,MAAM,SAAS,WAAW","names":["value: number"],"sources":["../../src/types/number.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\nimport { BaseType } from './base.ts'\nimport { CustomType, TransformType } from './custom.ts'\n\ntype Check = zod.core.CheckFn<number> | zod.core.$ZodCheck<number>\n\nexport class NumberType extends BaseType<\n zod.ZodMiniNumber<number>,\n zod.ZodMiniNumber<number>\n> {\n static factory(...checks: Check[]) {\n return new NumberType({\n encodedZodType: zod.number().check(...checks),\n params: { checks },\n })\n }\n\n positive() {\n return NumberType.factory(...this.params.checks, zod.gte(0))\n }\n\n negative() {\n return NumberType.factory(...this.params.checks, zod.lte(0))\n }\n\n lt(value: number) {\n return NumberType.factory(...this.params.checks, zod.lt(value))\n }\n\n lte(value: number) {\n return NumberType.factory(...this.params.checks, zod.lte(value))\n }\n\n gte(value: number) {\n return NumberType.factory(...this.params.checks, zod.gte(value))\n }\n\n gt(value: number) {\n return NumberType.factory(...this.params.checks, zod.gt(value))\n }\n}\n\nexport class IntegerType extends NumberType {\n static factory(...checks: Check[]) {\n return NumberType.factory(...checks, zod.int())\n }\n}\n\nexport class BigIntType extends TransformType<\n bigint,\n zod.ZodMiniString<string>\n> {\n static factory() {\n return CustomType.factory<bigint, zod.ZodMiniString<string>>({\n decode: (value) => BigInt(value),\n encode: (value) => value.toString(),\n type: zod.string().check(zod.regex(/^-?\\d+$/)),\n error: 'Invalid bigint format',\n })\n }\n}\n\nexport const number = NumberType.factory\nexport const integer = IntegerType.factory\nexport const bigInt = BigIntType.factory\n"],"version":3,"file":"number.js"}
|
package/dist/types/object.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAElC,SAAS,gBAAqD,WAAW;AACzE,SAAS,gBAAgB,WAAW;AAMpC,OAAO,MAAM,mBAAmD,SAU9D;CACA,OAAO,QAAwCA,YAAe;EAC5D,MAAM,mBAAmB,CAAE;EAG3B,MAAM,mBAAmB,CAAE;AAI3B,OAAK,MAAM,OAAO,YAAY;AAC5B,oBAAiB,OAAO,WAAW,KAAK;AACxC,oBAAiB,OAAO,WAAW,KAAK;EACzC;AAED,SAAO,IAAI,WAAc;GACvB,gBAAgB,IAAI,OAAO,iBAAiB;GAC5C,gBAAgB,IAAI,OAAO,iBAAiB;GAC5C,OAAO,EAAE,WAAY;EACtB;CACF;AACF;AAED,OAAO,MAAM,mBAGH,SAGR;CACA,OAAO,QAGLC,KAAQC,SAAY;AACpB,SAAO,IAAI,WAAiB;GAC1B,gBAAgB,IAAI,OACjB,IAAY,gBACb,QAAQ,eACT;GACD,gBAAgB,IAAI,OACjB,IAAY,gBACb,QAAQ,eACT;GACD,OAAO;IAAE;IAAK;GAAS;EACxB;CACF;AACF;AAED,OAAO,SAAS,MACdC,MAGA;AACA,QAAO,SAAS,QAAQ,OAAO,KAAK,KAAK,MAAM,WAAW,CAAQ;AACnE;AAED,OAAO,SAAS,KAIdC,QACAC,MAOC;CACD,MAAM,aAAa,OAAO,YACxB,OAAO,QAAQ,OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,KAAK,KAAK,CACrE;AACD,QAAO,WAAW,QAAQ,WAAW;AACtC;AAED,OAAO,SAAS,KAIdD,QACAE,MAKC;CACD,MAAM,aAAa,OAAO,YACxB,OAAO,QAAQ,OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,MAAM,KAAK,KAAK,CACtE;AACD,QAAO,WAAW,QAAQ,WAAW;AACtC;AAED,OAAO,SAAS,OACdC,SACAC,YAOC;AACD,QAAO,WAAW,QAAQ;EACxB,GAAG,QAAQ,MAAM;EACjB,GAAG;CACJ,EAAC;AACH;AAED,OAAO,SAAS,MACdC,SACAC,SASC;AACD,QAAO,WAAW,QAAQ;EACxB,GAAG,QAAQ,MAAM;EACjB,GAAG,QAAQ,MAAM;CAClB,EAAC;AACH;AAED,OAAO,SAAS,QAIdC,QAGC;CACD,MAAM,aAAa,CAAE;AAErB,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,OAAO,MAAM,WAAW,EAAE;AAClE,aAAW,OAAO,MAAM,UAAU;CACnC;AAED,QAAO,WAAW,QAAQ,WAAW;AACtC;AAED,OAAO,MAAM,SAAS,WAAW;AACjC,OAAO,MAAM,SAAS,WAAW","names":["properties: T","key: K","element: E","type: T","source: T","pick: P","omit: P","object1: T","properties: P","object1: T1","object2: T2","object: T"],"sources":["../../src/types/object.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\n\nimport { BaseType, type BaseTypeAny, type OptionalType } from './base.ts'\nimport { EnumType } from './enum.ts'\nimport type { LiteralType } from './literal.ts'\nimport type { StringType } from './string.ts'\n\nexport type ObjectTypeProps = { [k: string]: BaseTypeAny }\nexport type AnyObjectType = ObjectType<ObjectTypeProps>\nexport class ObjectType<T extends ObjectTypeProps = {}> extends BaseType<\n zod.ZodMiniObject<\n { [K in keyof T]: T[K]['encodedZodType'] },\n zod.core.$strict\n >,\n zod.ZodMiniObject<\n { [K in keyof T]: T[K]['decodedZodType'] },\n zod.core.$strict\n >,\n { properties: T }\n> {\n static factory<T extends ObjectTypeProps = {}>(properties: T) {\n const encodeProperties = {} as {\n [K in keyof T]: T[K]['encodedZodType']\n }\n const decodeProperties = {} as {\n [K in keyof T]: T[K]['decodedZodType']\n }\n\n for (const key in properties) {\n encodeProperties[key] = properties[key].encodedZodType\n decodeProperties[key] = properties[key].decodedZodType\n }\n\n return new ObjectType<T>({\n encodedZodType: zod.object(encodeProperties),\n decodedZodType: zod.object(decodeProperties),\n props: { properties },\n })\n }\n}\n\nexport class RecordType<\n K extends LiteralType<string | number> | EnumType | StringType,\n E extends BaseType,\n> extends BaseType<\n zod.ZodMiniRecord<K['encodedZodType'], E['encodedZodType']>,\n zod.ZodMiniRecord<K['decodedZodType'], E['decodedZodType']>\n> {\n static factory<\n K extends LiteralType<string | number> | EnumType | StringType,\n E extends BaseType,\n >(key: K, element: E) {\n return new RecordType<K, E>({\n encodedZodType: zod.record(\n (key as any).encodedZodType,\n element.encodedZodType,\n ),\n decodedZodType: zod.record(\n (key as any).decodedZodType,\n element.decodedZodType,\n ),\n props: { key, element },\n })\n }\n}\n\nexport function keyof<T extends ObjectType>(\n type: T,\n): EnumType<\n zod.core.util.ToEnum<Extract<keyof T['props']['properties'], string>>\n> {\n return EnumType.factory(Object.keys(type.props.properties) as any)\n}\n\nexport function pick<\n T extends AnyObjectType,\n P extends { [K in keyof T['props']['properties']]?: true },\n>(\n source: T,\n pick: P,\n): ObjectType<{\n [K in keyof P]: P[K] extends true\n ? K extends keyof T['props']['properties']\n ? T['props']['properties'][K]\n : never\n : never\n}> {\n const properties = Object.fromEntries(\n Object.entries(source.props.properties).filter(([key]) => pick[key]),\n )\n return ObjectType.factory(properties) as any\n}\n\nexport function omit<\n T extends AnyObjectType,\n P extends { [K in keyof T['props']['properties']]?: true },\n>(\n source: T,\n omit: P,\n): ObjectType<{\n [K in keyof T['props']['properties'] as K extends keyof P\n ? never\n : K]: T['props']['properties'][K]\n}> {\n const properties = Object.fromEntries(\n Object.entries(source.props.properties).filter(([key]) => !omit[key]),\n )\n return ObjectType.factory(properties) as any\n}\n\nexport function extend<T extends AnyObjectType, P extends ObjectTypeProps>(\n object1: T,\n properties: P,\n): ObjectType<{\n [K in keyof T['props']['properties'] | keyof P]: K extends keyof P\n ? P[K]\n : K extends keyof T['props']['properties']\n ? T['props']['properties'][K]\n : never\n}> {\n return ObjectType.factory({\n ...object1.props.properties,\n ...properties,\n }) as any\n}\n\nexport function merge<T1 extends AnyObjectType, T2 extends AnyObjectType>(\n object1: T1,\n object2: T2,\n): ObjectType<{\n [K in\n | keyof T1['props']['properties']\n | keyof T2['props']['properties']]: K extends keyof T2['props']['properties']\n ? T2['props']['properties'][K]\n : K extends keyof T1['props']['properties']\n ? T1['props']['properties'][K]\n : never\n}> {\n return ObjectType.factory({\n ...object1.props.properties,\n ...object2.props.properties,\n }) as any\n}\n\nexport function partial<\n T extends AnyObjectType,\n P extends T extends ObjectType<infer Props> ? Props : never,\n>(\n object: T,\n): ObjectType<{\n [K in keyof P]: OptionalType<P[K]>\n}> {\n const properties = {} as any\n\n for (const [key, value] of Object.entries(object.props.properties)) {\n properties[key] = value.optional()\n }\n\n return ObjectType.factory(properties)\n}\n\nexport const object = ObjectType.factory\nexport const record = RecordType.factory\n"],"version":3,"file":"object.js"}
|
package/dist/types/string.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAElC,SAAS,gBAAgB,WAAW;AAIpC,OAAO,MAAM,mBAAmB,SAG9B;CACA,OAAO,QAAQ,GAAG,QAAiB;AACjC,SAAO,IAAI,WAAW;GACpB,gBAAgB,IAAI,QAAQ,CAAC,MAAM,GAAG,OAAO;GAC7C,QAAQ,EAAE,OAAQ;EACnB;CACF;CAED,IAAIA,OAAe;AACjB,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,UAAU,MAAM,CAAC;CACvE;CAED,IAAIA,OAAe;AACjB,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,UAAU,MAAM,CAAC;CACvE;CAED,QAAQC,SAA0B;AAChC,SAAO,WAAW,QAChB,GAAG,KAAK,OAAO,QACf,IAAI,aAAa,YAAY,WAAW,IAAI,OAAO,WAAW,QAAQ,CACvE;CACF;CAED,MAAMC,SAAoC;AACxC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,MAAM,QAAQ,CAAC;CACrE;CAED,IAAIC,SAAkC;AACpC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,IAAI,QAAQ,CAAC;CACnE;CAED,KAAKC,SAAmC;AACtC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ,CAAC;CACpE;CAED,KAAKC,SAAmC;AACtC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ,CAAC;CACpE;CAED,KAAKC,SAAmC;AACtC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ,CAAC;CACpE;CAED,MAAMC,SAAoC;AACxC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,MAAM,QAAQ,CAAC;CACrE;CAED,OAAOC,SAAqC;AAC1C,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,OAAO,QAAQ,CAAC;CACtE;CAED,KAAKC,SAAmC;AACtC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ,CAAC;CACpE;CAED,MAAMC,SAAoC;AACxC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,MAAM,QAAQ,CAAC;CACrE;CAED,KAAKC,SAAmC;AACtC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,KAAK,QAAQ,CAAC;CACpE;CAED,IAAIC,SAAkC;AACpC,SAAO,WAAW,QAAQ,GAAG,KAAK,OAAO,QAAQ,IAAI,IAAI,QAAQ,CAAC;CACnE;AACF;AAED,OAAO,MAAM,SAAS,WAAW","names":["value: number","pattern: string | RegExp","options?: zod.core.$ZodEmailParams","options?: zod.core.$ZodURLParams","options?: zod.core.$ZodIPv4Params","options?: zod.core.$ZodIPv6Params","options?: zod.core.$ZodUUIDParams","options?: zod.core.$ZodEmojiParams","options?: zod.core.$ZodNanoIDParams","options?: zod.core.$ZodCUIDParams","options?: zod.core.$ZodCUID2Params","options?: zod.core.$ZodE164Params","options?: zod.core.$ZodJWTParams"],"sources":["../../src/types/string.ts"],"sourcesContent":["import * as zod from 'zod/v4-mini'\n\nimport { BaseType } from './base.ts'\n\ntype Check = zod.core.CheckFn<string> | zod.core.$ZodCheck<string>\n\nexport class StringType extends BaseType<\n zod.ZodMiniString<string>,\n zod.ZodMiniString<string>\n> {\n static factory(...checks: Check[]) {\n return new StringType({\n encodedZodType: zod.string().check(...checks),\n params: { checks },\n })\n }\n\n max(value: number) {\n return StringType.factory(...this.params.checks, zod.maxLength(value))\n }\n\n min(value: number) {\n return StringType.factory(...this.params.checks, zod.minLength(value))\n }\n\n pattern(pattern: string | RegExp) {\n return StringType.factory(\n ...this.params.checks,\n zod.regex(typeof pattern === 'string' ? new RegExp(pattern) : pattern),\n )\n }\n\n email(options?: zod.core.$ZodEmailParams) {\n return StringType.factory(...this.params.checks, zod.email(options))\n }\n\n url(options?: zod.core.$ZodURLParams) {\n return StringType.factory(...this.params.checks, zod.url(options))\n }\n\n ipv4(options?: zod.core.$ZodIPv4Params) {\n return StringType.factory(...this.params.checks, zod.ipv4(options))\n }\n\n ipv6(options?: zod.core.$ZodIPv6Params) {\n return StringType.factory(...this.params.checks, zod.ipv6(options))\n }\n\n uuid(options?: zod.core.$ZodUUIDParams) {\n return StringType.factory(...this.params.checks, zod.uuid(options))\n }\n\n emoji(options?: zod.core.$ZodEmojiParams) {\n return StringType.factory(...this.params.checks, zod.emoji(options))\n }\n\n nanoid(options?: zod.core.$ZodNanoIDParams) {\n return StringType.factory(...this.params.checks, zod.nanoid(options))\n }\n\n cuid(options?: zod.core.$ZodCUIDParams) {\n return StringType.factory(...this.params.checks, zod.cuid(options))\n }\n\n cuid2(options?: zod.core.$ZodCUID2Params) {\n return StringType.factory(...this.params.checks, zod.cuid2(options))\n }\n\n e164(options?: zod.core.$ZodE164Params) {\n return StringType.factory(...this.params.checks, zod.e164(options))\n }\n\n jwt(options?: zod.core.$ZodJWTParams) {\n return StringType.factory(...this.params.checks, zod.jwt(options))\n }\n}\n\nexport const string = StringType.factory\n"],"version":3,"file":"string.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,KAAK,OAAO,cAAkC,aAAa;AACpE,SAAS,YAAY,qBAAqB,aAAa;AAYvD,MAAM,4BAA4B,CAChCA,MACA,SAAS,CAACC,UAAkB,SAAS,MAAM,KAAK,MAAM,KACnD;CACH,MAAM,SAAS,CAACC,UACd,MAAM,SAAS;EACb,cAAc;EACd,cAAc;EACd,cAAc;CACf,EAAC;AAEJ,QAAO;EACL;EACA;CACD;AACF;AAID,OAAO,MAAM,sBAAsB,cAGjC;CACA,OAAO,cAAc,0BAA0B,YAAY;CAE3D,OAAO,UAAU;AACf,SAAO,WAAW,QAAyC;GACzD,QAAQ,cAAc,YAAY;GAClC,QAAQ,cAAc,YAAY;GAClC,MAAM,IAAI,MAAM;GAChB,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,0BAA0B,cAGrC;CACA,OAAO,cAAc,0BAA0B,gBAAgB;CAE/D,OAAO,UAAU;AACf,SAAO,WAAW,QAA6C;GAC7D,QAAQ,kBAAkB,YAAY;GACtC,QAAQ,kBAAkB,YAAY;GACtC,MAAM,IAAI,SAAS,EAAE,OAAO,KAAM,EAAC;GACnC,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,0BAA0B,cAGrC;CACA,OAAO,cAAc,0BAA0B,iBAAiB,CAAC,UAC/D,SAAS,QAAQ,KAAK,MAAM,CAAC,mBAAmB,MAAM,CACvD;CAED,OAAO,UAAU;AACf,SAAO,WAAW,QAA6C;GAC7D,QAAQ,kBAAkB,YAAY;GACtC,QAAQ,kBAAkB,YAAY;GACtC,MAAM,IAAI,SAAS,EAAE,OAAO,KAAM,EAAC;GACnC,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,sBAAsB,cAGjC;CACA,OAAO,cAAc,0BAA0B,YAAY;CAE3D,OAAO,UAAU;AACf,SAAO,WAAW,QAAyC;GACzD,QAAQ,cAAc,YAAY;GAClC,QAAQ,cAAc,YAAY;GAClC,MAAM,IAAI,MAAM;GAChB,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,qBAAqB,cAGhC;CACA,OAAO,cAAc,0BAA0B,WAAW;CAE1D,OAAO,UAAU;AACf,SAAO,WAAW,QAAwC;GACxD,QAAQ,aAAa,YAAY;GACjC,QAAQ,aAAa,YAAY;GACjC,MAAM,IAAI,UAAU;GACpB,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,2BAA2B,cAGtC;CACA,OAAO,cAAc,0BAA0B,iBAAiB;CAEhE,OAAO,UAAU;AACf,SAAO,WAAW,QAA8C;GAC9D,QAAQ,mBAAmB,YAAY;GACvC,QAAQ,mBAAmB,YAAY;GACvC,MAAM,QAAQ,CAAC,MAAM,MAAM,gBAAgB,CAAC;GAC5C,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,0BAA0B,cAGrC;CACA,OAAO,cAAc,0BAA0B,gBAAgB;CAE/D,OAAO,UAAU;AACf,SAAO,WAAW,QAA6C;GAC7D,QAAQ,kBAAkB,YAAY;GACtC,QAAQ,kBAAkB,YAAY;GACtC,MAAM,QAAQ,CAAC,MAAM,MAAM,gBAAgB,CAAC;GAC5C,OAAO;EACR,EAAC;CACH;AACF;AAED,OAAO,MAAM,YAAY,cAAc;AACvC,OAAO,MAAM,gBAAgB,kBAAkB;AAC/C,OAAO,MAAM,YAAY,cAAc;AACvC,OAAO,MAAM,gBAAgB,kBAAkB;AAC/C,OAAO,MAAM,WAAW,aAAa;AACrC,OAAO,MAAM,iBAAiB,mBAAmB;AACjD,OAAO,MAAM,gBAAgB,kBAAkB","names":["type: T","value: string","value: ReturnType<(typeof Temporal)[T]['from']>"],"sources":["../../src/types/temporal.ts"],"sourcesContent":["import { Temporal } from 'temporal-polyfill'\nimport { iso, regex, string, type ZodMiniString } from 'zod/v4-mini'\nimport { CustomType, TransformType } from './custom.ts'\n\ntype Types = Exclude<\n keyof typeof Temporal,\n 'Now' | 'Instant' | 'Calendar' | 'TimeZone'\n>\n\ntype TemporalTransformer<T extends Types> = {\n decode: (value: string) => ReturnType<(typeof Temporal)[T]['from']>\n encode: (value: ReturnType<(typeof Temporal)[T]['from']>) => string\n}\n\nconst createTemporalTransformer = <T extends Types>(\n type: T,\n decode = (value: string) => Temporal[type].from(value),\n) => {\n const encode = (value: ReturnType<(typeof Temporal)[T]['from']>) =>\n value.toString({\n calendarName: 'never',\n smallestUnit: 'microsecond',\n timeZoneName: 'never',\n })\n\n return {\n decode,\n encode,\n } as TemporalTransformer<T>\n}\n\ntype EncodedType = ZodMiniString<string>\n\nexport class PlainDateType extends TransformType<\n Temporal.PlainDate,\n EncodedType\n> {\n static transformer = createTemporalTransformer('PlainDate')\n\n static factory() {\n return CustomType.factory<Temporal.PlainDate, EncodedType>({\n decode: PlainDateType.transformer.decode,\n encode: PlainDateType.transformer.encode,\n type: iso.date(),\n error: 'Invalid date format',\n })\n }\n}\n\nexport class PlainDateTimeType extends TransformType<\n Temporal.PlainDateTime,\n EncodedType\n> {\n static transformer = createTemporalTransformer('PlainDateTime')\n\n static factory() {\n return CustomType.factory<Temporal.PlainDateTime, EncodedType>({\n decode: PlainDateTimeType.transformer.decode,\n encode: PlainDateTimeType.transformer.encode,\n type: iso.datetime({ local: true }),\n error: 'Invalid datetime format',\n })\n }\n}\n\nexport class ZonedDateTimeType extends TransformType<\n Temporal.ZonedDateTime,\n EncodedType\n> {\n static transformer = createTemporalTransformer('ZonedDateTime', (value) =>\n Temporal.Instant.from(value).toZonedDateTimeISO('UTC'),\n )\n\n static factory() {\n return CustomType.factory<Temporal.ZonedDateTime, EncodedType>({\n decode: ZonedDateTimeType.transformer.decode,\n encode: ZonedDateTimeType.transformer.encode,\n type: iso.datetime({ local: true }),\n error: 'Invalid datetime format',\n })\n }\n}\n\nexport class PlainTimeType extends TransformType<\n Temporal.PlainTime,\n EncodedType\n> {\n static transformer = createTemporalTransformer('PlainTime')\n\n static factory() {\n return CustomType.factory<Temporal.PlainTime, EncodedType>({\n decode: PlainTimeType.transformer.decode,\n encode: PlainTimeType.transformer.encode,\n type: iso.time(),\n error: 'Invalid time format',\n })\n }\n}\n\nexport class DurationType extends TransformType<\n Temporal.Duration,\n EncodedType\n> {\n static transformer = createTemporalTransformer('Duration')\n\n static factory() {\n return CustomType.factory<Temporal.Duration, EncodedType>({\n decode: DurationType.transformer.decode,\n encode: DurationType.transformer.encode,\n type: iso.duration(),\n error: 'Invalid duration format',\n })\n }\n}\n\nexport class PlainYearMonthType extends TransformType<\n Temporal.PlainYearMonth,\n EncodedType\n> {\n static transformer = createTemporalTransformer('PlainYearMonth')\n\n static factory() {\n return CustomType.factory<Temporal.PlainYearMonth, EncodedType>({\n decode: PlainYearMonthType.transformer.decode,\n encode: PlainYearMonthType.transformer.encode,\n type: string().check(regex(/^\\d{4}-\\d{2}$/)),\n error: 'Invalid year-month format',\n })\n }\n}\n\nexport class PlainMonthDayType extends TransformType<\n Temporal.PlainMonthDay,\n EncodedType\n> {\n static transformer = createTemporalTransformer('PlainMonthDay')\n\n static factory() {\n return CustomType.factory<Temporal.PlainMonthDay, EncodedType>({\n decode: PlainMonthDayType.transformer.decode,\n encode: PlainMonthDayType.transformer.encode,\n type: string().check(regex(/^\\d{2}-\\d{2}$/)),\n error: 'Invalid month-day format',\n })\n }\n}\n\nexport const plainDate = PlainDateType.factory\nexport const plainDatetime = PlainDateTimeType.factory\nexport const plainTime = PlainTimeType.factory\nexport const zonedDatetime = ZonedDateTimeType.factory\nexport const duration = DurationType.factory\nexport const plainYearMonth = PlainYearMonthType.factory\nexport const plainMonthDay = PlainMonthDayType.factory\n"],"version":3,"file":"temporal.js"}
|
package/dist/types/tuple.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AACA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAgB,WAAW;AAEpC,OAAO,MAAM,kBAMH,SAQR;CACA,OAAO,QAGLA,UAAaC,OAAU,MAAW;EAClC,MAAM,UAAU,SAAS,IAAI,CAAC,OAAO,GAAG,eAAe;EACvD,MAAM,UAAU,SAAS,IAAI,CAAC,OAAO,GAAG,eAAe;AACvD,SAAO,IAAI,UAAgB;GAEzB,gBAAgB,IAAI,MAAM,SAAS,MAAM,eAAe;GAExD,gBAAgB,IAAI,MAAM,SAAS,MAAM,eAAe;GACxD,OAAO;IAAE;IAAU;GAAM;EAC1B;CACF;AACF;AAED,OAAO,MAAM,QAAQ,UAAU","names":["elements: T","rest: R"],"sources":["../../src/types/tuple.ts"],"sourcesContent":["import type { ArrayMap } from '@nmtjs/common'\nimport * as zod from 'zod/v4-mini'\nimport { BaseType } from './base.ts'\n\nexport class TupleType<\n T extends readonly [BaseType, ...BaseType[]] = readonly [\n BaseType,\n ...BaseType[],\n ],\n R extends BaseType | null = BaseType | null,\n> extends BaseType<\n R extends BaseType\n ? zod.ZodMiniTuple<ArrayMap<T, 'encodedZodType'>, R['encodedZodType']>\n : zod.ZodMiniTuple<ArrayMap<T, 'encodedZodType'>, null>,\n R extends BaseType\n ? zod.ZodMiniTuple<ArrayMap<T, 'decodedZodType'>, R['decodedZodType']>\n : zod.ZodMiniTuple<ArrayMap<T, 'decodedZodType'>, null>,\n { elements: T; rest?: R }\n> {\n static factory<\n T extends readonly [BaseType, ...BaseType[]],\n R extends BaseType | null = null,\n >(elements: T, rest: R = null as R) {\n const encoded = elements.map((el) => el.encodedZodType)\n const decoded = elements.map((el) => el.decodedZodType)\n return new TupleType<T, R>({\n // @ts-expect-error\n encodedZodType: zod.tuple(encoded, rest?.encodedZodType),\n // @ts-expect-error\n decodedZodType: zod.tuple(decoded, rest?.decodedZodType),\n props: { elements, rest },\n })\n }\n}\n\nexport const tuple = TupleType.factory\n"],"version":3,"file":"tuple.js"}
|
package/dist/types/type.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAEA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","names":[],"sources":["../../src/types/type.ts"],"sourcesContent":["import type { BaseTypeAny } from './base.ts'\n\nexport * from './any.ts'\nexport * from './array.ts'\nexport * from './boolean.ts'\nexport * from './custom.ts'\nexport * from './date.ts'\nexport * from './enum.ts'\nexport * from './literal.ts'\nexport * from './never.ts'\nexport * from './number.ts'\nexport * from './object.ts'\nexport * from './string.ts'\nexport * from './tuple.ts'\nexport * from './union.ts'\n\nexport namespace infer {\n export namespace decoded {\n export type input<T extends BaseTypeAny> =\n T['decodedZodType']['_zod']['input']\n export type output<T extends BaseTypeAny> =\n T['decodedZodType']['_zod']['output']\n }\n\n export namespace encoded {\n export type input<T extends BaseTypeAny> =\n T['encodedZodType']['_zod']['input']\n export type output<T extends BaseTypeAny> =\n T['encodedZodType']['_zod']['output']\n }\n}\n"],"version":3,"file":"type.js"}
|
package/dist/types/union.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AACA,YAAY,SAAS,aAAa;AAClC,SAAS,gBAAkC,WAAW;AAItD,OAAO,MAAM,kBAKH,SAIR;CACA,OAAO,QAKL,GAAG,SAAY;EACf,MAAM,UAAU,QAAQ,IAAI,CAAC,MAAM,EAAE,eAAe;EAIpD,MAAM,UAAU,QAAQ,IAAI,CAAC,MAAM,EAAE,eAAe;AAIpD,SAAO,IAAI,UAAa;GACtB,gBAAgB,IAAI,MAAM,QAAQ;GAClC,gBAAgB,IAAI,MAAM,QAAQ;GAClC,OAAO,EAAE,QAAS;EACnB;CACF;AACF;AAED,OAAO,MAAM,yBAEH,SAIR;CACA,OAAO,QAEL,GAAG,SAAY;EACf,MAAM,CAAC,OAAO,OAAO,GAAG;AACxB,SAAO,IAAI,iBAAoB;GAC7B,gBAAgB,IAAI,aAClB,MAAM,gBACN,OAAO,eACR;GACD,gBAAgB,IAAI,aAClB,MAAM,gBACN,OAAO,eACR;GACD,OAAO,EAAE,QAAS;EACnB;CACF;AACF;AAYD,OAAO,MAAM,+BAIH,SAOR;CACA,OAAO,QAILA,KAAQ,GAAG,SAAY;EACvB,MAAM,UAAU,QAAQ,IAAI,CAAC,MAAM,EAAE,eAAe;EAIpD,MAAM,UAAU,QAAQ,IAAI,CAAC,MAAM,EAAE,eAAe;AAIpD,SAAO,IAAI,uBAA6B;GAEtC,gBAAgB,IAAI,mBAAmB,KAAK,QAAQ;GAEpD,gBAAgB,IAAI,mBAAmB,KAAK,QAAQ;GACpD,OAAO;IAAE;IAAK;GAAS;EACxB;CACF;AACF;AAED,OAAO,MAAM,QAAQ,UAAU;AAC/B,OAAO,MAAM,KAAK,UAAU;AAC5B,OAAO,MAAM,eAAe,iBAAiB;AAC7C,OAAO,MAAM,MAAM,iBAAiB;AACpC,OAAO,MAAM,qBAAqB,uBAAuB","names":["key: K"],"sources":["../../src/types/union.ts"],"sourcesContent":["import type { ArrayMap } from '@nmtjs/common'\nimport * as zod from 'zod/v4-mini'\nimport { BaseType, type BaseTypeAny } from './base.ts'\nimport type { LiteralType } from './literal.ts'\nimport type { ObjectType, ObjectTypeProps } from './object.ts'\n\nexport class UnionType<\n T extends readonly [BaseType, ...BaseType[]] = readonly [\n BaseType,\n ...BaseType[],\n ],\n> extends BaseType<\n zod.ZodMiniUnion<ArrayMap<T, 'encodedZodType'>>,\n zod.ZodMiniUnion<ArrayMap<T, 'decodedZodType'>>,\n { options: T }\n> {\n static factory<\n T extends readonly [BaseType, ...BaseType[]] = readonly [\n BaseType,\n ...BaseType[],\n ],\n >(...options: T) {\n const encoded = options.map((t) => t.encodedZodType) as ArrayMap<\n T,\n 'encodedZodType'\n >\n const decoded = options.map((t) => t.decodedZodType) as ArrayMap<\n T,\n 'decodedZodType'\n >\n return new UnionType<T>({\n encodedZodType: zod.union(encoded),\n decodedZodType: zod.union(decoded),\n props: { options },\n })\n }\n}\n\nexport class IntersactionType<\n T extends readonly [BaseType, BaseType] = readonly [BaseType, BaseType],\n> extends BaseType<\n zod.ZodMiniIntersection<T[0]['encodedZodType'], T[1]['encodedZodType']>,\n zod.ZodMiniIntersection<T[0]['decodedZodType'], T[1]['decodedZodType']>,\n { options: T }\n> {\n static factory<\n T extends readonly [BaseType, BaseType] = readonly [BaseType, BaseType],\n >(...options: T) {\n const [first, second] = options\n return new IntersactionType<T>({\n encodedZodType: zod.intersection(\n first.encodedZodType,\n second.encodedZodType,\n ),\n decodedZodType: zod.intersection(\n first.decodedZodType,\n second.decodedZodType,\n ),\n props: { options },\n })\n }\n}\n\nexport type DiscriminatedUnionProperties<K extends string = string> = {\n [OK in K]: LiteralType<string>\n} & {\n [OK in string]: any\n}\n\nexport type DiscriminatedUnionOptionType<K extends string> = ObjectType<\n ObjectTypeProps & { [_ in K]: BaseTypeAny }\n>\n\nexport class DiscriminatedUnionType<\n K extends string = string,\n T extends\n readonly DiscriminatedUnionOptionType<K>[] = DiscriminatedUnionOptionType<K>[],\n> extends BaseType<\n zod.ZodMiniDiscriminatedUnion<ArrayMap<T, 'encodedZodType'>>,\n zod.ZodMiniDiscriminatedUnion<ArrayMap<T, 'decodedZodType'>>,\n {\n key: K\n options: T\n }\n> {\n static factory<\n K extends string = string,\n T extends\n readonly DiscriminatedUnionOptionType<K>[] = DiscriminatedUnionOptionType<K>[],\n >(key: K, ...options: T) {\n const encoded = options.map((t) => t.encodedZodType) as ArrayMap<\n T,\n 'encodedZodType'\n >\n const decoded = options.map((t) => t.decodedZodType) as ArrayMap<\n T,\n 'decodedZodType'\n >\n return new DiscriminatedUnionType<K, T>({\n // @ts-expect-error\n encodedZodType: zod.discriminatedUnion(key, encoded),\n // @ts-expect-error\n decodedZodType: zod.discriminatedUnion(key, decoded),\n props: { key, options },\n })\n }\n}\n\nexport const union = UnionType.factory\nexport const or = UnionType.factory\nexport const intersection = IntersactionType.factory\nexport const and = IntersactionType.factory\nexport const discriminatedUnion = DiscriminatedUnionType.factory\n"],"version":3,"file":"union.js"}
|