@nmtjs/type 0.11.5 → 0.11.7
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/base.js.map +1 -1
- package/dist/types/custom.js.map +1 -1
- package/dist/types/date.js +1 -1
- package/dist/types/date.js.map +1 -1
- package/package.json +3 -3
- package/src/types/base.ts +1 -1
- package/src/types/custom.ts +1 -1
- package/src/types/date.ts +2 -4
package/dist/types/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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['
|
|
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"}
|
package/dist/types/custom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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<
|
|
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
CHANGED
|
@@ -5,7 +5,7 @@ export class DateType extends TransformType {
|
|
|
5
5
|
return CustomType.factory({
|
|
6
6
|
decode: (value) => new Date(value),
|
|
7
7
|
encode: (value) => value.toISOString(),
|
|
8
|
-
type: zod.union([zod.iso.
|
|
8
|
+
type: zod.union([zod.iso.date(), zod.iso.datetime()])
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
}
|
package/dist/types/date.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,YAAY,SAAS,aAAa;AAClC,SAAS,YAAY,qBAAqB,aAAa;AAEvD,OAAO,MAAM,iBAAiB,cAG5B;CACA,OAAO,UAAU;AACf,SAAO,WAAW,
|
|
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/package.json
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"temporal-polyfill": "^0.3.0",
|
|
16
16
|
"zod": "^3.25.0",
|
|
17
|
-
"@nmtjs/common": "0.11.
|
|
17
|
+
"@nmtjs/common": "0.11.7"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"temporal-polyfill": "^0.3.0",
|
|
21
21
|
"zod": "^3.25.0",
|
|
22
|
-
"@nmtjs/common": "0.11.
|
|
22
|
+
"@nmtjs/common": "0.11.7"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"src",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"LICENSE.md",
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
|
-
"version": "0.11.
|
|
30
|
+
"version": "0.11.7",
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "neemata-build --root=./src './**/*.ts'",
|
|
33
33
|
"type-check": "tsc --noEmit"
|
package/src/types/base.ts
CHANGED
|
@@ -105,7 +105,7 @@ export abstract class BaseType<
|
|
|
105
105
|
return this.meta({ description })
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
examples(...examples: this['
|
|
108
|
+
examples(...examples: this['encodedZodType']['_zod']['input'][]): this {
|
|
109
109
|
return this.meta({
|
|
110
110
|
examples: this.params.encode
|
|
111
111
|
? examples.map(this.params.encode)
|
package/src/types/custom.ts
CHANGED
package/src/types/date.ts
CHANGED
|
@@ -8,13 +8,11 @@ export class DateType extends TransformType<
|
|
|
8
8
|
static factory() {
|
|
9
9
|
return CustomType.factory<
|
|
10
10
|
Date,
|
|
11
|
-
zod.ZodMiniUnion<
|
|
12
|
-
Array<zod.iso.ZodMiniISODate | zod.iso.ZodMiniISODateTime>
|
|
13
|
-
>
|
|
11
|
+
zod.ZodMiniUnion<[zod.iso.ZodMiniISODate, zod.iso.ZodMiniISODateTime]>
|
|
14
12
|
>({
|
|
15
13
|
decode: (value: string): Date => new Date(value),
|
|
16
14
|
encode: (value: Date): string => value.toISOString(),
|
|
17
|
-
type: zod.union([zod.iso.
|
|
15
|
+
type: zod.union([zod.iso.date(), zod.iso.datetime()]),
|
|
18
16
|
})
|
|
19
17
|
}
|
|
20
18
|
}
|