@nmtjs/type 0.15.0-beta.37 → 0.15.0-beta.38

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.
Files changed (84) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +8 -3
  5. package/dist/index.js.map +1 -0
  6. package/dist/temporal/global.d.ts +8 -7
  7. package/dist/temporal/global.js +2 -1
  8. package/dist/temporal/global.js.map +1 -0
  9. package/dist/temporal/polyfill.d.ts +8 -8
  10. package/dist/temporal/polyfill.js +2 -1
  11. package/dist/temporal/polyfill.js.map +1 -0
  12. package/dist/types/_convert.d.ts +5 -0
  13. package/dist/types/_convert.js +56 -0
  14. package/dist/types/_convert.js.map +1 -0
  15. package/dist/types/_type.d.ts +2 -0
  16. package/dist/types/_type.js +16 -13
  17. package/dist/types/_type.js.map +1 -0
  18. package/dist/types/{_plain.d.ts → _utils.d.ts} +2 -0
  19. package/dist/types/{_plain.js → _utils.js} +1 -0
  20. package/dist/types/_utils.js.map +1 -0
  21. package/dist/types/any.js +2 -1
  22. package/dist/types/any.js.map +1 -0
  23. package/dist/types/array.d.ts +1 -1
  24. package/dist/types/array.js +2 -1
  25. package/dist/types/array.js.map +1 -0
  26. package/dist/types/base.d.ts +1 -1
  27. package/dist/types/base.js +1 -0
  28. package/dist/types/base.js.map +1 -0
  29. package/dist/types/boolean.js +2 -1
  30. package/dist/types/boolean.js.map +1 -0
  31. package/dist/types/custom.d.ts +7 -1
  32. package/dist/types/custom.js +23 -6
  33. package/dist/types/custom.js.map +1 -0
  34. package/dist/types/date.d.ts +2 -2
  35. package/dist/types/date.js +3 -1
  36. package/dist/types/date.js.map +1 -0
  37. package/dist/types/enum.js +2 -1
  38. package/dist/types/enum.js.map +1 -0
  39. package/dist/types/literal.js +2 -1
  40. package/dist/types/literal.js.map +1 -0
  41. package/dist/types/never.js +2 -1
  42. package/dist/types/never.js.map +1 -0
  43. package/dist/types/null.d.ts +7 -0
  44. package/dist/types/null.js +10 -0
  45. package/dist/types/null.js.map +1 -0
  46. package/dist/types/number.js +3 -2
  47. package/dist/types/number.js.map +1 -0
  48. package/dist/types/object.d.ts +42 -15
  49. package/dist/types/object.js +21 -4
  50. package/dist/types/object.js.map +1 -0
  51. package/dist/types/string.js +2 -1
  52. package/dist/types/string.js.map +1 -0
  53. package/dist/types/temporal.d.ts +8 -8
  54. package/dist/types/temporal.js +2 -1
  55. package/dist/types/temporal.js.map +1 -0
  56. package/dist/types/tuple.d.ts +1 -1
  57. package/dist/types/tuple.js +2 -1
  58. package/dist/types/tuple.js.map +1 -0
  59. package/dist/types/union.d.ts +1 -1
  60. package/dist/types/union.js +2 -1
  61. package/dist/types/union.js.map +1 -0
  62. package/package.json +11 -27
  63. package/src/index.ts +14 -0
  64. package/src/temporal/global.ts +32 -0
  65. package/src/temporal/polyfill.ts +31 -0
  66. package/src/types/_convert.ts +68 -0
  67. package/src/types/_type.ts +54 -0
  68. package/src/types/_utils.ts +24 -0
  69. package/src/types/any.ts +12 -0
  70. package/src/types/array.ts +53 -0
  71. package/src/types/base.ts +209 -0
  72. package/src/types/boolean.ts +12 -0
  73. package/src/types/custom.ts +109 -0
  74. package/src/types/date.ts +23 -0
  75. package/src/types/enum.ts +23 -0
  76. package/src/types/literal.ts +18 -0
  77. package/src/types/never.ts +12 -0
  78. package/src/types/null.ts +14 -0
  79. package/src/types/number.ts +73 -0
  80. package/src/types/object.ts +225 -0
  81. package/src/types/string.ts +95 -0
  82. package/src/types/temporal.ts +155 -0
  83. package/src/types/tuple.ts +49 -0
  84. package/src/types/union.ts +120 -0
package/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2024 Denis Ilchyshyn
1
+ Copyright (c) 2025 Denys Ilchyshyn
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -6,4 +6,4 @@
6
6
  - binary data streaming and event subscriptions
7
7
  - contract-based API
8
8
  - end-to-end type safety
9
- - CPU-intensive task execution on separate workers
9
+ - CPU-intensive task execution on separate workers
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import * as type from './types/_type.ts';
2
+ export * from './types/_convert.ts';
3
+ export * from './types/_utils.ts';
2
4
  export * from './types/base.ts';
3
5
  export { type, type as t };
4
6
  export default type;
7
+ export declare function registerDefaultLocale(): void;
package/dist/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  import { en } from 'zod/locales';
2
2
  import { config } from 'zod/mini';
3
- import * as type from "./types/_type.js";
4
- config(en());
5
- export * from "./types/base.js";
3
+ import * as type from './types/_type.js';
4
+ export * from './types/_convert.js';
5
+ export * from './types/_utils.js';
6
+ export * from './types/base.js';
6
7
  export { type, type as t };
7
8
  export default type;
9
+ export function registerDefaultLocale() {
10
+ config(en());
11
+ }
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AAExC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,CAAA;AAC1B,eAAe,IAAI,CAAA;AAEnB,MAAM,UAAU,qBAAqB,GAAG;IACtC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;AAAA,CACb"}
@@ -1,8 +1,9 @@
1
1
  import 'temporal-spec/global';
2
- export declare const plainDate: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainDate, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainDate, import("temporal-spec").Temporal.PlainDate, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainDate, import("temporal-spec").Temporal.PlainDate>>>;
3
- export declare const plainDatetime: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainDateTime, import("temporal-spec").Temporal.PlainDateTime, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainDateTime, import("temporal-spec").Temporal.PlainDateTime>>>;
4
- export declare const plainTime: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainTime, import("temporal-spec").Temporal.PlainTime, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainTime, import("temporal-spec").Temporal.PlainTime>>>;
5
- export declare const zonedDatetime: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.ZonedDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.ZonedDateTime, import("temporal-spec").Temporal.ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.ZonedDateTime, import("temporal-spec").Temporal.ZonedDateTime>>>;
6
- export declare const duration: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.Duration, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.Duration, import("temporal-spec").Temporal.Duration, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.Duration, import("temporal-spec").Temporal.Duration>>>;
7
- export declare const plainYearMonth: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainYearMonth, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainYearMonth, import("temporal-spec").Temporal.PlainYearMonth, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainYearMonth, import("temporal-spec").Temporal.PlainYearMonth>>>;
8
- export declare const plainMonthDay: () => import("../types/custom.ts").CustomType<import("temporal-spec").Temporal.PlainMonthDay, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<import("temporal-spec").Temporal.PlainMonthDay, import("temporal-spec").Temporal.PlainMonthDay, import("zod/v4/core").$ZodTypeInternals<import("temporal-spec").Temporal.PlainMonthDay, import("temporal-spec").Temporal.PlainMonthDay>>>;
2
+ import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType } from '../types/temporal.ts';
3
+ export declare const plainDate: () => PlainDateType;
4
+ export declare const plainDatetime: () => PlainDateTimeType;
5
+ export declare const plainTime: () => PlainTimeType;
6
+ export declare const zonedDatetime: () => ZonedDateTimeType;
7
+ export declare const duration: () => DurationType;
8
+ export declare const plainYearMonth: () => PlainYearMonthType;
9
+ export declare const plainMonthDay: () => PlainMonthDayType;
@@ -1,5 +1,5 @@
1
1
  import 'temporal-spec/global';
2
- import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from "../types/temporal.js";
2
+ import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
3
3
  export const plainDate = PlainDateType.factory.bind(PlainDateType, Temporal);
4
4
  export const plainDatetime = PlainDateTimeType.factory.bind(PlainDateTimeType, Temporal);
5
5
  export const plainTime = PlainTimeType.factory.bind(PlainTimeType, Temporal);
@@ -7,3 +7,4 @@ export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType, T
7
7
  export const duration = DurationType.factory.bind(DurationType, Temporal);
8
8
  export const plainYearMonth = PlainYearMonthType.factory.bind(PlainYearMonthType, Temporal);
9
9
  export const plainMonthDay = PlainMonthDayType.factory.bind(PlainMonthDayType, Temporal);
10
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/temporal/global.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,SAAS,GAAwB,aAAa,CAAC,OAAO,CAAC,IAAI,CACtE,aAAa,EACb,QAAQ,CACT,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GACxB,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA;AAC7D,MAAM,CAAC,MAAM,SAAS,GAAwB,aAAa,CAAC,OAAO,CAAC,IAAI,CACtE,aAAa,EACb,QAAQ,CACT,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GACxB,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA;AAC7D,MAAM,CAAC,MAAM,QAAQ,GAAuB,YAAY,CAAC,OAAO,CAAC,IAAI,CACnE,YAAY,EACZ,QAAQ,CACT,CAAA;AACD,MAAM,CAAC,MAAM,cAAc,GACzB,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAA;AAC/D,MAAM,CAAC,MAAM,aAAa,GACxB,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA"}
@@ -1,8 +1,8 @@
1
- import { Temporal } from 'temporal-polyfill';
2
- export declare const plainDate: () => import("../types/custom.ts").CustomType<Temporal.PlainDate, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainDate, Temporal.PlainDate, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainDate, Temporal.PlainDate>>>;
3
- export declare const plainDatetime: () => import("../types/custom.ts").CustomType<Temporal.PlainDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainDateTime, Temporal.PlainDateTime, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainDateTime, Temporal.PlainDateTime>>>;
4
- export declare const plainTime: () => import("../types/custom.ts").CustomType<Temporal.PlainTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainTime, Temporal.PlainTime, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainTime, Temporal.PlainTime>>>;
5
- export declare const zonedDatetime: () => import("../types/custom.ts").CustomType<Temporal.ZonedDateTime, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.ZonedDateTime, Temporal.ZonedDateTime, import("zod/v4/core").$ZodTypeInternals<Temporal.ZonedDateTime, Temporal.ZonedDateTime>>>;
6
- export declare const duration: () => import("../types/custom.ts").CustomType<Temporal.Duration, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.Duration, Temporal.Duration, import("zod/v4/core").$ZodTypeInternals<Temporal.Duration, Temporal.Duration>>>;
7
- export declare const plainYearMonth: () => import("../types/custom.ts").CustomType<Temporal.PlainYearMonth, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainYearMonth, Temporal.PlainYearMonth, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainYearMonth, Temporal.PlainYearMonth>>>;
8
- export declare const plainMonthDay: () => import("../types/custom.ts").CustomType<Temporal.PlainMonthDay, import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniType<Temporal.PlainMonthDay, Temporal.PlainMonthDay, import("zod/v4/core").$ZodTypeInternals<Temporal.PlainMonthDay, Temporal.PlainMonthDay>>>;
1
+ import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType } from '../types/temporal.ts';
2
+ export declare const plainDate: () => PlainDateType;
3
+ export declare const plainDatetime: () => PlainDateTimeType;
4
+ export declare const plainTime: () => PlainTimeType;
5
+ export declare const zonedDatetime: () => ZonedDateTimeType;
6
+ export declare const duration: () => DurationType;
7
+ export declare const plainYearMonth: () => PlainYearMonthType;
8
+ export declare const plainMonthDay: () => PlainMonthDayType;
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from "../types/temporal.js";
2
+ import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
3
3
  export const plainDate = PlainDateType.factory.bind(PlainDateType, Temporal);
4
4
  export const plainDatetime = PlainDateTimeType.factory.bind(PlainDateTimeType, Temporal);
5
5
  export const plainTime = PlainTimeType.factory.bind(PlainTimeType, Temporal);
@@ -7,3 +7,4 @@ export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType, T
7
7
  export const duration = DurationType.factory.bind(DurationType, Temporal);
8
8
  export const plainYearMonth = PlainYearMonthType.factory.bind(PlainYearMonthType, Temporal);
9
9
  export const plainMonthDay = PlainMonthDayType.factory.bind(PlainMonthDayType, Temporal);
10
+ //# sourceMappingURL=polyfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../src/temporal/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CACzD,iBAAiB,EACjB,QAAQ,CACT,CAAA;AACD,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CACzD,iBAAiB,EACjB,QAAQ,CACT,CAAA;AACD,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;AACzE,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAC3D,kBAAkB,EAClB,QAAQ,CACT,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CACzD,iBAAiB,EACjB,QAAQ,CACT,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { core } from 'zod/mini';
2
+ import { toJSONSchema } from 'zod/mini';
3
+ import type { BaseType } from './base.ts';
4
+ export declare function typeToString(type: BaseType): string;
5
+ export declare function typeToJsonSchema(type: BaseType, mode: 'encode' | 'decode', options?: Parameters<typeof toJSONSchema>[1]): core.JSONSchema.JSONSchema;
@@ -0,0 +1,56 @@
1
+ import { toJSONSchema } from 'zod/mini';
2
+ import { AnyType } from './any.js';
3
+ import { ArrayType } from './array.js';
4
+ import { NullableType, OptionalType } from './base.js';
5
+ import { BooleanType } from './boolean.js';
6
+ import { CustomType } from './custom.js';
7
+ import { DateType } from './date.js';
8
+ import { LiteralType } from './literal.js';
9
+ import { NumberType } from './number.js';
10
+ import { ObjectType } from './object.js';
11
+ import { StringType } from './string.js';
12
+ import { TupleType } from './tuple.js';
13
+ export function typeToString(type) {
14
+ switch (true) {
15
+ case type instanceof OptionalType:
16
+ return `?<${typeToString(type.props.inner)}>`;
17
+ case type instanceof NullableType:
18
+ return `null | ${typeToString(type.props.inner)}`;
19
+ case type instanceof StringType:
20
+ return 'string';
21
+ case type instanceof NumberType:
22
+ return 'number';
23
+ case type instanceof LiteralType:
24
+ return `literal(${type.props.value})`;
25
+ case type instanceof BooleanType:
26
+ return 'boolean';
27
+ case type instanceof DateType:
28
+ return 'string';
29
+ case type instanceof ArrayType:
30
+ return `array<${typeToString(type.props.element)}>`;
31
+ case type instanceof ObjectType: {
32
+ const props = type.props.properties;
33
+ const propsStrings = Object.keys(props).map((key) => `${key}: ${typeToString(props[key])}`);
34
+ return `{ ${propsStrings.join(', ')} }`;
35
+ }
36
+ case type instanceof TupleType: {
37
+ const elements = type.props.elements;
38
+ const elementsStrings = elements.map((el) => typeToString(el));
39
+ const rest = type.props.rest
40
+ ? `, ...${typeToString(type.props.rest)}`
41
+ : '';
42
+ return `[${elementsStrings.join(', ')}${rest}]`;
43
+ }
44
+ case type instanceof AnyType:
45
+ return 'any';
46
+ case type instanceof CustomType:
47
+ return typeToJsonSchema(type, 'decode').type || 'custom';
48
+ default:
49
+ return 'unknown';
50
+ }
51
+ }
52
+ export function typeToJsonSchema(type, mode, options) {
53
+ const zodType = { encode: type.encodeZodType, decode: type.decodeZodType }[mode];
54
+ return toJSONSchema(zodType, options);
55
+ }
56
+ //# sourceMappingURL=_convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_convert.js","sourceRoot":"","sources":["../../src/types/_convert.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAA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base.ts';
2
2
  export * from './any.ts';
3
3
  export * from './array.ts';
4
+ export { BaseType, type BaseTypeAny, DefaultType, NeemataTypeError, NullableType, OptionalType, } from './base.ts';
4
5
  export * from './boolean.ts';
5
6
  export * from './custom.ts';
6
7
  export * from './date.ts';
7
8
  export * from './enum.ts';
8
9
  export * from './literal.ts';
9
10
  export * from './never.ts';
11
+ export * from './null.ts';
10
12
  export * from './number.ts';
11
13
  export * from './object.ts';
12
14
  export * from './string.ts';
@@ -1,13 +1,16 @@
1
- export * from "./any.js";
2
- export * from "./array.js";
3
- export * from "./boolean.js";
4
- export * from "./custom.js";
5
- export * from "./date.js";
6
- export * from "./enum.js";
7
- export * from "./literal.js";
8
- export * from "./never.js";
9
- export * from "./number.js";
10
- export * from "./object.js";
11
- export * from "./string.js";
12
- export * from "./tuple.js";
13
- export * from "./union.js";
1
+ export * from './any.js';
2
+ export * from './array.js';
3
+ export { BaseType, DefaultType, NeemataTypeError, NullableType, OptionalType, } from './base.js';
4
+ export * from './boolean.js';
5
+ export * from './custom.js';
6
+ export * from './date.js';
7
+ export * from './enum.js';
8
+ export * from './literal.js';
9
+ export * from './never.js';
10
+ export * from './null.js';
11
+ export * from './number.js';
12
+ export * from './object.js';
13
+ export * from './string.js';
14
+ export * from './tuple.js';
15
+ export * from './union.js';
16
+ //# sourceMappingURL=_type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_type.js","sourceRoot":"","sources":["../../src/types/_type.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,OAAO,EACL,QAAQ,EAER,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,WAAW,CAAA;AAClB,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import type { core, ZodMiniType } from 'zod/mini';
2
+ import type { BaseType } from './base.ts';
2
3
  export declare const PlainType: unique symbol;
3
4
  export type PlainType = typeof PlainType;
4
5
  export type ZodPlainType<T extends ZodMiniType<any, any, any>> = T & ZodMiniType<T['_zod']['output'] & {
@@ -11,3 +12,4 @@ export type ZodPlainType<T extends ZodMiniType<any, any, any>> = T & ZodMiniType
11
12
  [PlainType]?: true;
12
13
  }>>;
13
14
  export declare const zodPlainType: <T extends ZodMiniType<any, any, any>>(type: T) => ZodPlainType<T>;
15
+ export type AnyCompatibleType<Encoded = any, Decoded = any> = BaseType<ZodMiniType<any, Decoded>, ZodMiniType<any, Encoded>>;
@@ -1,2 +1,3 @@
1
1
  export const PlainType = Symbol('PlainType');
2
2
  export const zodPlainType = (type) => type;
3
+ //# sourceMappingURL=_utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_utils.js","sourceRoot":"","sources":["../../src/types/_utils.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,SAAS,GAAkB,MAAM,CAAC,WAAW,CAAC,CAAA;AAa3D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAuC,IAAO,EAAE,EAAE,CAC5E,IAAuB,CAAA"}
package/dist/types/any.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { any as zodAny } from 'zod/mini';
2
- import { BaseType } from "./base.js";
2
+ import { BaseType } from './base.js';
3
3
  export class AnyType extends BaseType {
4
4
  static factory() {
5
5
  return new AnyType({ encodeZodType: zodAny() });
6
6
  }
7
7
  }
8
8
  export const any = AnyType.factory;
9
+ //# sourceMappingURL=any.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any.js","sourceRoot":"","sources":["../../src/types/any.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,OAAQ,SAAQ,QAAoB;IAC/C,MAAM,CAAC,OAAO,GAAG;QACf,OAAO,IAAI,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC,CAAA;IAAA,CAChD;CACF;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { core, ZodMiniArray } from 'zod/mini';
2
- import type { ZodPlainType } from './_plain.ts';
2
+ import type { ZodPlainType } from './_utils.ts';
3
3
  import { BaseType } from './base.ts';
4
4
  type Check = core.CheckFn<any[]> | core.$ZodCheck<any[]>;
5
5
  export declare class ArrayType<T extends BaseType = BaseType> extends BaseType<ZodMiniArray<T['encodeZodType']>, ZodMiniArray<T['decodeZodType']>, {
@@ -1,5 +1,5 @@
1
1
  import { length, maxLength, minLength, array as zodArray } from 'zod/mini';
2
- import { BaseType } from "./base.js";
2
+ import { BaseType } from './base.js';
3
3
  export class ArrayType extends BaseType {
4
4
  static factory(element, ...checks) {
5
5
  return new ArrayType({
@@ -23,3 +23,4 @@ export class ArrayType extends BaseType {
23
23
  }
24
24
  }
25
25
  export const array = ArrayType.factory;
26
+ //# sourceMappingURL=array.js.map
@@ -0,0 +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;AAG1E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,MAAM,OAAO,SAAyC,SAAQ,QAM7D;IACC,MAAM,CAAC,OAAO,CAAqB,OAAU,EAAE,GAAG,MAAe,EAAE;QACjE,OAAO,IAAI,SAAS,CAAI;YACtB,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;YAC/D,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;YAC/D,MAAM,EAAE,EAAE,MAAM,EAAE;YAClB,KAAK,EAAE,EAAE,OAAO,EAAE;SACnB,CAAC,CAAA;IAAA,CACH;IAED,GAAG,CAAC,KAAa,EAAE;QACjB,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAC9B,OAAO,SAAS,CAAC,OAAO,CACtB,IAAI,CAAC,KAAK,CAAC,OAAO,EAClB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EACrB,KAAK,CACN,CAAA;IAAA,CACF;IAED,GAAG,CAAC,KAAa,EAAE;QACjB,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAC9B,OAAO,SAAS,CAAC,OAAO,CACtB,IAAI,CAAC,KAAK,CAAC,OAAO,EAClB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EACrB,KAAK,CACN,CAAA;IAAA,CACF;IAED,MAAM,CAAC,KAAa,EAAE;QACpB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3B,OAAO,SAAS,CAAC,OAAO,CACtB,IAAI,CAAC,KAAK,CAAC,OAAO,EAClB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EACrB,KAAK,CACN,CAAA;IAAA,CACF;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAA"}
@@ -31,7 +31,7 @@ export declare abstract class BaseType<EncodeZodType extends SimpleZodType = Sim
31
31
  readonly decodeRawZodType: RawDecodeZodType;
32
32
  readonly props: Props;
33
33
  readonly params: TypeParams;
34
- constructor({ encodeZodType, decodeZodType, props, params, }: {
34
+ constructor({ encodeZodType, decodeZodType, props, params }: {
35
35
  encodeZodType: EncodeZodType;
36
36
  decodeZodType?: DecodeZodType;
37
37
  props?: Props;
@@ -79,3 +79,4 @@ export class DefaultType extends BaseType {
79
79
  });
80
80
  }
81
81
  }
82
+ //# sourceMappingURL=base.js.map
@@ -0,0 +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,QAAQ,EAAE,MAAM,UAAU,CAAA;AAkDvE,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,EAAgB,CAAA;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAA;AAG9C,MAAM,OAAgB,QAAQ;IAOnB,aAAa,CAAe;IAC5B,aAAa,CAAe;IAC5B,gBAAgB,CAAmB;IACnC,gBAAgB,CAAmB;IACnC,KAAK,CAAO;IACZ,MAAM,CAAY;IAE3B,YAAY,EACV,aAAa,EACb,aAAa,GAAG,aAAyC,EACzD,KAAK,GAAG,EAAW,EACnB,MAAM,GAAG,EAAyB,GAMnC,EAAE;QACD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAElC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;IAAA,CACpD;IAED,QAAQ,GAAuB;QAC7B,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAAA,CAClC;IAED,QAAQ,GAAuB;QAC7B,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAAA,CAClC;IAED,OAAO,GAAG;QACR,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAA;IA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OAAO,EAAE,CAAC,CAAA;IAAA,CACzE;CACF;AAED,MAAM,OAAO,YAEX,SAAQ,QAIT;IACC,MAAM,CAAC,OAAO,CAAwB,IAAO,EAAE;QAC7C,OAAO,IAAI,YAAY,CAAI;YACzB,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;YAC3C,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;YAC3C,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;SACvB,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,OAAO,YAEX,SAAQ,QAIT;IACC,MAAM,CAAC,OAAO,CAA6B,IAAO,EAAE;QAClD,OAAO,IAAI,YAAY,CAAI;YACzB,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;YAC3C,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;YAC3C,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;SACvB,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,OAAO,WAEX,SAAQ,QAIT;IACC,MAAM,CAAC,OAAO,CAA6B,IAAO,EAAE,YAAiB,EAAE;QACrE,OAAO,IAAI,WAAW,CAAI;YACxB,aAAa,EAAE,QAAQ,CACrB,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,IAAI,YAAY,CACnD;YACD,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC;YACzD,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;SACvB,CAAC,CAAA;IAAA,CACH;CACF"}
@@ -1,8 +1,9 @@
1
1
  import { boolean as zodBoolean } from 'zod/mini';
2
- import { BaseType } from "./base.js";
2
+ import { BaseType } from './base.js';
3
3
  export class BooleanType extends BaseType {
4
4
  static factory() {
5
5
  return new BooleanType({ encodeZodType: zodBoolean() });
6
6
  }
7
7
  }
8
8
  export const boolean = BooleanType.factory;
9
+ //# sourceMappingURL=boolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src/types/boolean.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,WAAY,SAAQ,QAAiC;IAChE,MAAM,CAAC,OAAO,GAAG;QACf,OAAO,IAAI,WAAW,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;IAAA,CACxD;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAA"}
@@ -1,3 +1,4 @@
1
+ import type { MaybePromise } from '@nmtjs/common';
1
2
  import type { core, ZodMiniType } from 'zod/mini';
2
3
  import type { SimpleZodType, ZodType } from './base.ts';
3
4
  import { BaseType } from './base.ts';
@@ -5,11 +6,16 @@ export type CustomTransformFn<I, O> = (value: I) => O;
5
6
  export declare abstract class TransformType<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>> extends BaseType<ZodMiniType<EncodeType['_zod']['output'], DecodeType['_zod']['input']>, ZodMiniType<DecodeType['_zod']['output'], EncodeType['_zod']['input']>> {
6
7
  }
7
8
  export declare class CustomType<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>> extends TransformType<Type, EncodeType, DecodeType> {
8
- static factory<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>>({ decode, encode, error, type, }: {
9
+ static factory<Type, EncodeType extends SimpleZodType = ZodMiniType<Type, Type>, DecodeType extends ZodType = ZodMiniType<Type, Type>>({ decode, encode, validation, error, type, prototype }: {
9
10
  decode: CustomTransformFn<EncodeType['_zod']['input'], DecodeType['_zod']['output']>;
10
11
  encode: CustomTransformFn<DecodeType['_zod']['input'], EncodeType['_zod']['output']>;
12
+ validation?: ((value: EncodeType['_zod']['input'] | DecodeType['_zod']['output'], payload: core.$RefinementCtx<EncodeType['_zod']['output'] | DecodeType['_zod']['output']>) => MaybePromise<void>) | {
13
+ encode?: (value: EncodeType['_zod']['input'], payload: core.$RefinementCtx<EncodeType['_zod']['output']>) => MaybePromise<void>;
14
+ decode?: (value: DecodeType['_zod']['output'], payload: core.$RefinementCtx<DecodeType['_zod']['output']>) => MaybePromise<void>;
15
+ };
11
16
  error?: string | core.$ZodErrorMap<core.$ZodIssueBase>;
12
17
  type?: EncodeType;
18
+ prototype?: object;
13
19
  }): CustomType<Type, EncodeType, DecodeType>;
14
20
  }
15
21
  export declare const custom: typeof CustomType.factory;
@@ -1,16 +1,33 @@
1
- import { any, overwrite, pipe, refine, custom as zodCustom } from 'zod/mini';
2
- import { BaseType } from "./base.js";
1
+ import { any, overwrite, pipe, refine, superRefine, custom as zodCustom, } from 'zod/mini';
2
+ import { BaseType } from './base.js';
3
3
  export class TransformType extends BaseType {
4
4
  }
5
5
  export class CustomType extends TransformType {
6
- static factory({ decode, encode, error, type = any(), }) {
7
- return new CustomType({
8
- encodeZodType: pipe(zodCustom().check(refine((val) => typeof val !== 'undefined', { error, abort: true }), overwrite(encode)), type),
6
+ static factory({ decode, encode, validation, error, type = any(), prototype, }) {
7
+ const _validation = validation
8
+ ? typeof validation === 'function'
9
+ ? { encode: validation, decode: validation }
10
+ : validation
11
+ : undefined;
12
+ const instance = new CustomType({
13
+ encodeZodType: pipe(zodCustom().check(...[
14
+ refine((val) => typeof val !== 'undefined', { abort: true }),
15
+ _validation?.encode ? superRefine(_validation.encode) : undefined,
16
+ overwrite(encode),
17
+ ].filter((v) => !!v)), type),
9
18
  decodeZodType: pipe(type,
10
19
  // @ts-expect-error
11
- zodCustom().check(refine((val) => typeof val !== 'undefined', { error, abort: true }), overwrite(decode))),
20
+ zodCustom().check(...[
21
+ refine((val) => typeof val !== 'undefined', { abort: true }),
22
+ overwrite(decode),
23
+ _validation?.decode ? superRefine(_validation.decode) : undefined,
24
+ ].filter((v) => !!v))),
12
25
  params: { encode },
13
26
  });
27
+ if (prototype)
28
+ Object.setPrototypeOf(instance, prototype);
29
+ return instance;
14
30
  }
15
31
  }
16
32
  export const custom = CustomType.factory;
33
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/types/custom.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,SAAS,EACT,IAAI,EACJ,MAAM,EACN,WAAW,EACX,MAAM,IAAI,SAAS,GACpB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,MAAM,OAAgB,aAIpB,SAAQ,QAGT;CAAG;AAEJ,MAAM,OAAO,UAIX,SAAQ,aAA2C;IACnD,MAAM,CAAC,OAAO,CAIZ,EACA,MAAM,EACN,MAAM,EACN,UAAU,EACV,KAAK,EACL,IAAI,GAAG,GAAG,EAA2B,EACrC,SAAS,GA+BV,EAA4C;QAC3C,MAAM,WAAW,GAAG,UAAU;YAC5B,CAAC,CAAC,OAAO,UAAU,KAAK,UAAU;gBAChC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE;gBAC5C,CAAC,CAAC,UAAU;YACd,CAAC,CAAC,SAAS,CAAA;QAEb,MAAM,QAAQ,GAAG,IAAI,UAAU,CAA+B;YAC5D,aAAa,EAAE,IAAI,CACjB,SAAS,EAAE,CAAC,KAAK,CACf,GAAG;gBACD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBAC5D,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;gBACjE,SAAS,CAAC,MAAM,CAAC;aAClB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CACrB,EACD,IAAI,CACL;YACD,aAAa,EAAE,IAAI,CACjB,IAAI;YACJ,mBAAmB;YACnB,SAAS,EAAE,CAAC,KAAK,CACf,GAAG;gBACD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBAC5D,SAAS,CAAC,MAAM,CAAC;gBACjB,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;aAClE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CACrB,CACF;YACD,MAAM,EAAE,EAAE,MAAM,EAAE;SACnB,CAAC,CAAA;QAEF,IAAI,SAAS;YAAE,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAEzD,OAAO,QAAQ,CAAA;IAAA,CAChB;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import type { ZodMiniUnion } from 'zod/mini';
2
2
  import { iso } from 'zod/mini';
3
- import { CustomType, TransformType } from './custom.ts';
3
+ import { TransformType } from './custom.ts';
4
4
  export declare class DateType extends TransformType<Date, ZodMiniUnion<[iso.ZodMiniISODate, iso.ZodMiniISODateTime]>> {
5
- static factory(): CustomType<Date, ZodMiniUnion<[iso.ZodMiniISODate, iso.ZodMiniISODateTime]>, import("zod/mini").ZodMiniType<Date, Date, import("zod/v4/core").$ZodTypeInternals<Date, Date>>>;
5
+ static factory(): DateType;
6
6
  }
7
7
  export declare const date: typeof DateType.factory;
@@ -1,12 +1,14 @@
1
1
  import { iso, union } from 'zod/mini';
2
- import { CustomType, TransformType } from "./custom.js";
2
+ import { CustomType, TransformType } from './custom.js';
3
3
  export class DateType extends TransformType {
4
4
  static factory() {
5
5
  return CustomType.factory({
6
6
  decode: (value) => new Date(value),
7
7
  encode: (value) => value.toISOString(),
8
8
  type: union([iso.date(), iso.datetime()]),
9
+ prototype: DateType.prototype,
9
10
  });
10
11
  }
11
12
  }
12
13
  export const date = DateType.factory;
14
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/types/date.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEvD,MAAM,OAAO,QAAS,SAAQ,aAG7B;IACC,MAAM,CAAC,OAAO,GAAa;QACzB,OAAO,UAAU,CAAC,OAAO,CAGvB;YACA,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC;YAClC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE;YACtC,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACzC,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { enum as zodEnum } from 'zod/mini';
2
- import { BaseType } from "./base.js";
2
+ import { BaseType } from './base.js';
3
3
  export class EnumType extends BaseType {
4
4
  static factory(values) {
5
5
  return new EnumType({
@@ -10,3 +10,4 @@ export class EnumType extends BaseType {
10
10
  }
11
11
  const _enum = EnumType.factory;
12
12
  export { _enum as enum };
13
+ //# sourceMappingURL=enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/types/enum.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,QAEX,SAAQ,QAAuD;IAK/D,MAAM,CAAC,OAAO,CAA0C,MAAS,EAAE;QACjE,OAAO,IAAI,QAAQ,CAAC;YAClB,aAAa,EAAE,OAAO,CAAC,MAAa,CAAC;YACrC,KAAK,EAAE,EAAE,MAAM,EAAE;SAClB,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAA;AAE9B,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { literal as zodLiteral } from 'zod/mini';
2
- import { BaseType } from "./base.js";
2
+ import { BaseType } from './base.js';
3
3
  export class LiteralType extends BaseType {
4
4
  static factory(value) {
5
5
  return new LiteralType({
@@ -9,3 +9,4 @@ export class LiteralType extends BaseType {
9
9
  }
10
10
  }
11
11
  export const literal = LiteralType.factory;
12
+ //# sourceMappingURL=literal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literal.js","sourceRoot":"","sources":["../../src/types/literal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,WAEX,SAAQ,QAA4D;IACpE,MAAM,CAAC,OAAO,CAA+B,KAAQ,EAAE;QACrD,OAAO,IAAI,WAAW,CAAI;YACxB,aAAa,EAAE,UAAU,CAAC,KAAK,CAAC;YAChC,KAAK,EAAE,EAAE,KAAK,EAAE;SACjB,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAA"}
@@ -1,8 +1,9 @@
1
1
  import { never as zodNever } from 'zod/mini';
2
- import { BaseType } from "./base.js";
2
+ import { BaseType } from './base.js';
3
3
  export class NeverType extends BaseType {
4
4
  static factory() {
5
5
  return new NeverType({ encodeZodType: zodNever() });
6
6
  }
7
7
  }
8
8
  export const never = NeverType.factory;
9
+ //# sourceMappingURL=never.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"never.js","sourceRoot":"","sources":["../../src/types/never.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,SAAU,SAAQ,QAAsB;IACnD,MAAM,CAAC,OAAO,GAAG;QACf,OAAO,IAAI,SAAS,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;IAAA,CACpD;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { ZodMiniNull } from 'zod/mini';
2
+ import { BaseType } from './base.ts';
3
+ export declare class NullType extends BaseType<ZodMiniNull> {
4
+ static factory(): NullType;
5
+ }
6
+ declare const _null: typeof NullType.factory;
7
+ export { _null as null };
@@ -0,0 +1,10 @@
1
+ import { null as zodNull } from 'zod/mini';
2
+ import { BaseType } from './base.js';
3
+ export class NullType extends BaseType {
4
+ static factory() {
5
+ return new NullType({ encodeZodType: zodNull() });
6
+ }
7
+ }
8
+ const _null = NullType.factory;
9
+ export { _null as null };
10
+ //# sourceMappingURL=null.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"null.js","sourceRoot":"","sources":["../../src/types/null.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,OAAO,QAAS,SAAQ,QAAqB;IACjD,MAAM,CAAC,OAAO,GAAG;QACf,OAAO,IAAI,QAAQ,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA;IAAA,CAClD;CACF;AAED,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAA;AAE9B,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { gt, gte, int, lt, lte, regex, number as zodNumber, string as zodString, } from 'zod/mini';
2
- import { BaseType } from "./base.js";
3
- import { CustomType, TransformType } from "./custom.js";
2
+ import { BaseType } from './base.js';
3
+ import { CustomType, TransformType } from './custom.js';
4
4
  export class NumberType extends BaseType {
5
5
  static factory(...checks) {
6
6
  return new NumberType({
@@ -45,3 +45,4 @@ export class BigIntType extends TransformType {
45
45
  export const number = NumberType.factory;
46
46
  export const integer = IntegerType.factory;
47
47
  export const bigInt = BigIntType.factory;
48
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../src/types/number.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,GAAG,EACH,EAAE,EACF,GAAG,EACH,KAAK,EACL,MAAM,IAAI,SAAS,EACnB,MAAM,IAAI,SAAS,GACpB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIvD,MAAM,OAAO,UAAW,SAAQ,QAG/B;IACC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAe,EAAE;QACjC,OAAO,IAAI,UAAU,CAAC;YACpB,aAAa,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;YAC3C,MAAM,EAAE,EAAE,MAAM,E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