@nmtjs/type 0.15.0-beta.40 → 0.15.0-beta.42

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.
@@ -0,0 +1,12 @@
1
+ import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';
2
+ import type { ZodMiniType } from 'zod/mini';
3
+ import { core } from 'zod/mini';
4
+ import type { BaseType } from './types/_type.ts';
5
+ export declare namespace standard {
6
+ type Schema<T extends ZodMiniType> = StandardSchemaV1<T['_zod']['input'], T['_zod']['output']> & StandardJSONSchemaV1<T['_zod']['input'], T['_zod']['output']>;
7
+ type SchemaProps<T extends ZodMiniType> = StandardSchemaV1.Props<T['_zod']['input'], T['_zod']['output']> & StandardJSONSchemaV1.Props<T['_zod']['input'], T['_zod']['output']>;
8
+ type JSONProps<T extends ZodMiniType> = StandardJSONSchemaV1.Props<T['_zod']['input'], T['_zod']['output']>;
9
+ type Props<T extends ZodMiniType> = SchemaProps<T> & JSONProps<T>;
10
+ const decode: <T extends BaseType<import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType, import("./index.ts").TypeProps, import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType>>(type: T, registry: core.$ZodRegistry<import("./types/_metadata.ts").TypeMetadata<any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>) => Schema<T["decodeZodType"]>;
11
+ const encode: <T extends BaseType<import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType, import("./index.ts").TypeProps, import("./index.ts").SimpleZodType, import("./index.ts").SimpleZodType>>(type: T, registry: core.$ZodRegistry<import("./types/_metadata.ts").TypeMetadata<any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>) => Schema<T["encodeZodType"]>;
12
+ }
@@ -0,0 +1,103 @@
1
+ import { core, toJSONSchema } from 'zod/mini';
2
+ export { standard };
3
+ var standard;
4
+ (function (standard) {
5
+ standard.decode = (type, registry) => {
6
+ return Object.freeze({
7
+ '~standard': Object.freeze({
8
+ vendor: 'neemata-type',
9
+ version: 1,
10
+ validate: (value, options = {}) => {
11
+ try {
12
+ return { value: type.decode(value) };
13
+ }
14
+ catch (e) {
15
+ if (e instanceof core.$ZodError) {
16
+ const issues = e.issues.map((issue) => ({
17
+ message: issue.message,
18
+ path: issue.path.length > 0 ? issue.path : undefined,
19
+ }));
20
+ return { issues };
21
+ }
22
+ throw e;
23
+ }
24
+ },
25
+ jsonSchema: {
26
+ input: ({ target, libraryOptions }) => {
27
+ const { json = {} } = (libraryOptions || {});
28
+ const { cycles = 'throw', reused = 'inline' } = json;
29
+ return toJSONSchema(type.decodeZodType, {
30
+ target,
31
+ io: 'input',
32
+ cycles,
33
+ reused,
34
+ unrepresentable: 'any',
35
+ metadata: registry,
36
+ });
37
+ },
38
+ output: ({ target, libraryOptions }) => {
39
+ const { json = {} } = (libraryOptions || {});
40
+ const { cycles = 'throw', reused = 'inline' } = json;
41
+ return toJSONSchema(type.decodeZodType, {
42
+ target,
43
+ io: 'output',
44
+ cycles,
45
+ reused,
46
+ unrepresentable: 'any',
47
+ metadata: registry,
48
+ });
49
+ },
50
+ },
51
+ }),
52
+ });
53
+ };
54
+ standard.encode = (type, registry) => {
55
+ return Object.freeze({
56
+ '~standard': Object.freeze({
57
+ vendor: 'neemata-type',
58
+ version: 1,
59
+ validate: (value) => {
60
+ try {
61
+ return { value: type.encode(value) };
62
+ }
63
+ catch (e) {
64
+ if (e instanceof core.$ZodError) {
65
+ const issues = e.issues.map((issue) => ({
66
+ message: issue.message,
67
+ path: issue.path.length > 0 ? issue.path : undefined,
68
+ }));
69
+ return { issues };
70
+ }
71
+ throw e;
72
+ }
73
+ },
74
+ jsonSchema: {
75
+ input: ({ target, libraryOptions }) => {
76
+ const { json = {} } = (libraryOptions || {});
77
+ const { cycles = 'throw', reused = 'inline' } = json;
78
+ return toJSONSchema(type.encodeZodType, {
79
+ target,
80
+ io: 'input',
81
+ cycles,
82
+ reused,
83
+ unrepresentable: 'any',
84
+ metadata: registry,
85
+ });
86
+ },
87
+ output: ({ target, libraryOptions }) => {
88
+ const { json = {} } = (libraryOptions || {});
89
+ const { cycles = 'throw', reused = 'inline' } = json;
90
+ return toJSONSchema(type.encodeZodType, {
91
+ target,
92
+ io: 'output',
93
+ cycles,
94
+ reused,
95
+ unrepresentable: 'any',
96
+ });
97
+ },
98
+ },
99
+ }),
100
+ });
101
+ };
102
+ })(standard || (standard = {}));
103
+ //# sourceMappingURL=standart-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standart-schema.js","sourceRoot":"","sources":["../src/standart-schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;SAK5B,QAAQ;AAAzB,IAAiB,QAsIhB;AAtID,WAAiB,QAAQ,EAAC;IAoBX,eAAM,GAAG,CACpB,IAAO,EACP,QAA0B,EACE,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;gBACzB,MAAM,EAAE,cAAc;gBACtB,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC;oBACjC,IAAI,CAAC;wBACH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;oBACtC,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,EAAE,CAAC;4BAChC,MAAM,MAAM,GAA6B,CAAC,CAAC,MAAM,CAAC,GAAG,CACnD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gCACV,OAAO,EAAE,KAAK,CAAC,OAAO;gCACtB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC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AE,GAAG,CAAC,cAAc,IAAI,EAAE,CAE1C,CAAA;wBACD,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAA;wBACpD,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE;4BACtC,MAAM;4BACN,EAAE,EAAE,QAAQ;4BACZ,MAAM;4BACN,MAAM;4BACN,eAAe,EAAE,KAAK;yBACvB,CAAC,CAAA;oBAAA,CACH;iBACF;aACkC,CAAC;SACvC,CAAC,CAAA;IAAA,CACH,CAAA;AAAA,CACF,EAtIgB,QAAQ,KAAR,QAAQ,QAsIxB"}
@@ -0,0 +1,8 @@
1
+ export type TypeMetadata<T = any> = {
2
+ id?: string;
3
+ description?: string;
4
+ examples?: T[];
5
+ title?: string;
6
+ };
7
+ export declare const typesRegistry: import("zod/v4/core").$ZodRegistry<TypeMetadata<any>, import("zod/v4/core").$ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>;
8
+ export type MetadataRegistry = typeof typesRegistry;
@@ -0,0 +1,3 @@
1
+ import { registry } from 'zod/mini';
2
+ export const typesRegistry = registry();
3
+ //# sourceMappingURL=_metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_metadata.js","sourceRoot":"","sources":["../../src/types/_metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AASnC,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,EAAgB,CAAA"}
@@ -1,17 +1,12 @@
1
- import type { StandardSchemaV1 } from '@standard-schema/spec';
2
1
  import type { ZodMiniAny, ZodMiniArray, ZodMiniBoolean, ZodMiniDefault, ZodMiniEnum, ZodMiniIntersection, ZodMiniLiteral, ZodMiniNever, ZodMiniNullable, ZodMiniNumber, ZodMiniObject, ZodMiniOptional, ZodMiniRecord, ZodMiniString, ZodMiniType, ZodMiniUnion } from 'zod/mini';
3
2
  import { core } from 'zod/mini';
3
+ import type { TypeMetadata } from './_metadata.ts';
4
+ import { standard } from '../standart-schema.ts';
4
5
  export type PrimitiveValueType = string | number | boolean | null;
5
6
  export type PrimitiveZodType = ZodMiniNever | ZodMiniDefault | ZodMiniNullable | ZodMiniOptional | ZodMiniString | ZodMiniObject | ZodMiniAny | ZodMiniArray | ZodMiniBoolean | ZodMiniNumber | ZodMiniEnum<any> | ZodMiniLiteral<PrimitiveValueType> | ZodMiniUnion | ZodMiniIntersection | ZodMiniRecord;
6
7
  export type SimpleZodType = ZodMiniType;
7
8
  export type ZodType = SimpleZodType | ZodMiniType;
8
9
  export type TypeProps = Record<string, any>;
9
- export type TypeMetadata<T = any> = {
10
- id?: string;
11
- description?: string;
12
- examples?: T[];
13
- title?: string;
14
- };
15
10
  export type TypeParams = {
16
11
  encode?: (value: any) => any;
17
12
  metadata?: TypeMetadata;
@@ -22,16 +17,20 @@ export type DefaultTypeParams = {
22
17
  metadata?: TypeMetadata;
23
18
  };
24
19
  export type BaseTypeAny<EncodedZodType extends SimpleZodType = SimpleZodType, DecodedZodType extends ZodType = ZodMiniType> = BaseType<EncodedZodType, DecodedZodType, TypeProps>;
25
- export declare const typesRegistry: core.$ZodRegistry<TypeMetadata<any>, core.$ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>;
26
20
  export declare const NeemataTypeError: core.$constructor<core.$ZodError<unknown>, core.$ZodIssue[]>;
27
21
  export type NeemataTypeError = core.$ZodError;
28
- export declare abstract class BaseType<EncodeZodType extends SimpleZodType = SimpleZodType, DecodeZodType extends ZodType = EncodeZodType, Props extends TypeProps = TypeProps, RawEncodeZodType extends SimpleZodType = EncodeZodType, RawDecodeZodType extends ZodType = DecodeZodType> implements StandardSchemaV1<DecodeZodType['_zod']['input'], EncodeZodType['_zod']['output']> {
22
+ export declare abstract class BaseType<EncodeZodType extends SimpleZodType = SimpleZodType, DecodeZodType extends ZodType = EncodeZodType, Props extends TypeProps = TypeProps, RawEncodeZodType extends SimpleZodType = EncodeZodType, RawDecodeZodType extends ZodType = DecodeZodType> implements standard.Schema<DecodeZodType> {
29
23
  readonly encodeZodType: EncodeZodType;
30
24
  readonly decodeZodType: DecodeZodType;
31
25
  readonly encodeRawZodType: RawEncodeZodType;
32
26
  readonly decodeRawZodType: RawDecodeZodType;
33
27
  readonly props: Props;
34
28
  readonly params: TypeParams;
29
+ readonly standard: {
30
+ encode: standard.Schema<EncodeZodType>;
31
+ decode: standard.Schema<DecodeZodType>;
32
+ };
33
+ readonly '~standard': standard.Props<DecodeZodType>;
35
34
  constructor({ encodeZodType, decodeZodType, props, params }: {
36
35
  encodeZodType: EncodeZodType;
37
36
  decodeZodType?: DecodeZodType;
@@ -48,7 +47,6 @@ export declare abstract class BaseType<EncodeZodType extends SimpleZodType = Sim
48
47
  meta(newMetadata: TypeMetadata): this;
49
48
  encode(data: this['encodeZodType']['_zod']['input'], context?: core.ParseContext<core.$ZodIssue>): this['encodeZodType']['_zod']['output'];
50
49
  decode(data: this['decodeZodType']['_zod']['input'], context?: core.ParseContext<core.$ZodIssue>): this['decodeZodType']['_zod']['output'];
51
- '~standard': StandardSchemaV1.Props<this['decodeZodType']['_zod']['input'], this['encodeZodType']['_zod']['output']>;
52
50
  }
53
51
  export declare class OptionalType<Type extends BaseTypeAny = BaseTypeAny> extends BaseType<ZodMiniOptional<Type['encodeZodType']>, ZodMiniOptional<Type['decodeZodType']>, {
54
52
  inner: Type;
@@ -1,5 +1,6 @@
1
- import { _default, core, nullable, optional, registry } from 'zod/mini';
2
- export const typesRegistry = registry();
1
+ import { _default, core, nullable, optional } from 'zod/mini';
2
+ import { standard } from '../standart-schema.js';
3
+ import { typesRegistry } from './_metadata.js';
3
4
  export const NeemataTypeError = core.$ZodError;
4
5
  export class BaseType {
5
6
  encodeZodType;
@@ -8,11 +9,18 @@ export class BaseType {
8
9
  decodeRawZodType;
9
10
  props;
10
11
  params;
12
+ standard;
13
+ '~standard';
11
14
  constructor({ encodeZodType, decodeZodType = encodeZodType, props = {}, params = {}, }) {
12
15
  this.encodeZodType = encodeZodType;
13
16
  this.decodeZodType = decodeZodType;
14
17
  this.props = props;
15
18
  this.params = Object.assign({ checks: [] }, params);
19
+ this.standard = {
20
+ encode: standard.encode(this, typesRegistry),
21
+ decode: standard.decode(this, typesRegistry),
22
+ };
23
+ this['~standard'] = this.standard.decode['~standard'];
16
24
  }
17
25
  optional() {
18
26
  return OptionalType.factory(this);
@@ -51,30 +59,6 @@ export class BaseType {
51
59
  decode(data, context = {}) {
52
60
  return this.decodeZodType.parse(data, { reportInput: true, ...context });
53
61
  }
54
- '~standard' = {
55
- validate: (input, options) => {
56
- try {
57
- const value = this.decode(input, options?.libraryOptions?.context);
58
- return { value };
59
- }
60
- catch (e) {
61
- if (e instanceof core.$ZodError) {
62
- const issues = e.issues.map((issue) => ({
63
- message: issue.message,
64
- path: issue.path.length > 0 ? issue.path : undefined,
65
- }));
66
- return { issues };
67
- }
68
- throw e;
69
- }
70
- },
71
- types: {
72
- input: undefined,
73
- output: undefined,
74
- },
75
- vendor: 'neemata-type',
76
- version: 1,
77
- };
78
62
  }
79
63
  export class OptionalType extends BaseType {
80
64
  static factory(type) {
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/types/base.ts"],"names":[],"mappings":"AAmBA,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;IAYnB,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,G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B,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"}
@@ -17,6 +17,8 @@ export declare class StringType extends BaseType<ZodMiniString<string>, ZodMiniS
17
17
  cuid2(options?: core.$ZodCUID2Params): StringType;
18
18
  e164(options?: core.$ZodE164Params): StringType;
19
19
  jwt(options?: core.$ZodJWTParams): StringType;
20
+ base64(options?: core.$ZodBase64Params): StringType;
21
+ base64URL(options?: core.$ZodBase64URLParams): StringType;
20
22
  }
21
23
  export declare const string: typeof StringType.factory;
22
24
  export {};
@@ -1,4 +1,4 @@
1
- import { cuid, cuid2, e164, email, emoji, ipv4, ipv6, jwt, maxLength, minLength, nanoid, regex, url, uuid, string as zodString, } from 'zod/mini';
1
+ import { base64, base64url, cuid, cuid2, e164, email, emoji, ipv4, ipv6, jwt, maxLength, minLength, nanoid, regex, url, uuid, string as zodString, } from 'zod/mini';
2
2
  import { BaseType } from './base.js';
3
3
  export class StringType extends BaseType {
4
4
  static factory(...checks) {
@@ -49,6 +49,12 @@ export class StringType extends BaseType {
49
49
  jwt(options) {
50
50
  return StringType.factory(...this.params.checks, jwt(options));
51
51
  }
52
+ base64(options) {
53
+ return StringType.factory(...this.params.checks, base64(options));
54
+ }
55
+ base64URL(options) {
56
+ return StringType.factory(...this.params.checks, base64url(options));
57
+ }
52
58
  }
53
59
  export const string = StringType.factory;
54
60
  //# sourceMappingURL=string.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/types/string.ts"],"names":[],"mappings":"AACA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,SAAS,EACT,SAAS,EACT,MAAM,EACN,KAAK,EACL,GAAG,EACH,IAAI,EACJ,MAAM,IAAI,SAAS,GACpB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,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,EAAE;SACnB,CAAC,CAAA;IAAA,CACH;IAED,G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6B,EAAE;QAClC,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;IAAA,CAChE;IAED,GAAG,CAAC,OAA4B,EAAE;QAChC,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAAA,CAC/D;IAED,MAAM,CAAC,OAA+B,EAAE;QACtC,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAAA,CAClE;IAED,SAAS,CAAC,OAAkC,EAAE;QAC5C,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAAA,CACrE;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAA"}
package/package.json CHANGED
@@ -21,19 +21,19 @@
21
21
  "peerDependencies": {
22
22
  "temporal-polyfill": "^0.3.0",
23
23
  "zod": "^4.3.5",
24
- "@nmtjs/common": "0.15.0-beta.40"
24
+ "@nmtjs/common": "0.15.0-beta.42"
25
25
  },
26
26
  "devDependencies": {
27
27
  "temporal-polyfill": "^0.3.0",
28
28
  "zod": "^4.3.5",
29
- "@nmtjs/common": "0.15.0-beta.40"
29
+ "@nmtjs/common": "0.15.0-beta.42"
30
30
  },
31
31
  "peerDependenciesMeta": {
32
32
  "temporal-polyfill": {
33
33
  "optional": true
34
34
  }
35
35
  },
36
- "version": "0.15.0-beta.40",
36
+ "version": "0.15.0-beta.42",
37
37
  "scripts": {
38
38
  "clean-build": "rm -rf ./dist"
39
39
  }
@@ -0,0 +1,146 @@
1
+ import type {
2
+ StandardJSONSchemaV1,
3
+ StandardSchemaV1,
4
+ } from '@standard-schema/spec'
5
+ import type { ZodMiniType } from 'zod/mini'
6
+ import type { ToJSONSchemaParams } from 'zod/v4/core'
7
+ import { core, toJSONSchema } from 'zod/mini'
8
+
9
+ import type { MetadataRegistry } from './types/_metadata.ts'
10
+ import type { BaseType } from './types/_type.ts'
11
+
12
+ export namespace standard {
13
+ export type Schema<T extends ZodMiniType> = StandardSchemaV1<
14
+ T['_zod']['input'],
15
+ T['_zod']['output']
16
+ > &
17
+ StandardJSONSchemaV1<T['_zod']['input'], T['_zod']['output']>
18
+
19
+ export type SchemaProps<T extends ZodMiniType> = StandardSchemaV1.Props<
20
+ T['_zod']['input'],
21
+ T['_zod']['output']
22
+ > &
23
+ StandardJSONSchemaV1.Props<T['_zod']['input'], T['_zod']['output']>
24
+
25
+ export type JSONProps<T extends ZodMiniType> = StandardJSONSchemaV1.Props<
26
+ T['_zod']['input'],
27
+ T['_zod']['output']
28
+ >
29
+
30
+ export type Props<T extends ZodMiniType> = SchemaProps<T> & JSONProps<T>
31
+
32
+ export const decode = <T extends BaseType>(
33
+ type: T,
34
+ registry: MetadataRegistry,
35
+ ): Schema<T['decodeZodType']> => {
36
+ return Object.freeze({
37
+ '~standard': Object.freeze({
38
+ vendor: 'neemata-type',
39
+ version: 1,
40
+ validate: (value, options = {}) => {
41
+ try {
42
+ return { value: type.decode(value) }
43
+ } catch (e) {
44
+ if (e instanceof core.$ZodError) {
45
+ const issues: StandardSchemaV1.Issue[] = e.issues.map(
46
+ (issue) => ({
47
+ message: issue.message,
48
+ path: issue.path.length > 0 ? issue.path : undefined,
49
+ }),
50
+ )
51
+ return { issues }
52
+ }
53
+ throw e
54
+ }
55
+ },
56
+ jsonSchema: {
57
+ input: ({ target, libraryOptions }) => {
58
+ const { json = {} } = (libraryOptions || {}) as {
59
+ json: ToJSONSchemaParams
60
+ }
61
+ const { cycles = 'throw', reused = 'inline' } = json
62
+ return toJSONSchema(type.decodeZodType, {
63
+ target,
64
+ io: 'input',
65
+ cycles,
66
+ reused,
67
+ unrepresentable: 'any',
68
+ metadata: registry,
69
+ })
70
+ },
71
+ output: ({ target, libraryOptions }) => {
72
+ const { json = {} } = (libraryOptions || {}) as {
73
+ json: ToJSONSchemaParams
74
+ }
75
+ const { cycles = 'throw', reused = 'inline' } = json
76
+ return toJSONSchema(type.decodeZodType, {
77
+ target,
78
+ io: 'output',
79
+ cycles,
80
+ reused,
81
+ unrepresentable: 'any',
82
+ metadata: registry,
83
+ })
84
+ },
85
+ },
86
+ } satisfies Props<T['decodeZodType']>),
87
+ })
88
+ }
89
+
90
+ export const encode = <T extends BaseType>(
91
+ type: T,
92
+ registry: MetadataRegistry,
93
+ ): Schema<T['encodeZodType']> => {
94
+ return Object.freeze({
95
+ '~standard': Object.freeze({
96
+ vendor: 'neemata-type',
97
+ version: 1,
98
+ validate: (value) => {
99
+ try {
100
+ return { value: type.encode(value) }
101
+ } catch (e) {
102
+ if (e instanceof core.$ZodError) {
103
+ const issues: StandardSchemaV1.Issue[] = e.issues.map(
104
+ (issue) => ({
105
+ message: issue.message,
106
+ path: issue.path.length > 0 ? issue.path : undefined,
107
+ }),
108
+ )
109
+ return { issues }
110
+ }
111
+ throw e
112
+ }
113
+ },
114
+ jsonSchema: {
115
+ input: ({ target, libraryOptions }) => {
116
+ const { json = {} } = (libraryOptions || {}) as {
117
+ json: ToJSONSchemaParams
118
+ }
119
+ const { cycles = 'throw', reused = 'inline' } = json
120
+ return toJSONSchema(type.encodeZodType, {
121
+ target,
122
+ io: 'input',
123
+ cycles,
124
+ reused,
125
+ unrepresentable: 'any',
126
+ metadata: registry,
127
+ })
128
+ },
129
+ output: ({ target, libraryOptions }) => {
130
+ const { json = {} } = (libraryOptions || {}) as {
131
+ json: ToJSONSchemaParams
132
+ }
133
+ const { cycles = 'throw', reused = 'inline' } = json
134
+ return toJSONSchema(type.encodeZodType, {
135
+ target,
136
+ io: 'output',
137
+ cycles,
138
+ reused,
139
+ unrepresentable: 'any',
140
+ })
141
+ },
142
+ },
143
+ } satisfies Props<T['encodeZodType']>),
144
+ })
145
+ }
146
+ }
@@ -0,0 +1,12 @@
1
+ import { registry } from 'zod/mini'
2
+
3
+ export type TypeMetadata<T = any> = {
4
+ id?: string
5
+ description?: string
6
+ examples?: T[]
7
+ title?: string
8
+ }
9
+
10
+ export const typesRegistry = registry<TypeMetadata>()
11
+
12
+ export type MetadataRegistry = typeof typesRegistry
package/src/types/base.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { StandardSchemaV1 } from '@standard-schema/spec'
2
1
  import type {
3
2
  ZodMiniAny,
4
3
  ZodMiniArray,
@@ -17,7 +16,11 @@ import type {
17
16
  ZodMiniType,
18
17
  ZodMiniUnion,
19
18
  } from 'zod/mini'
20
- import { _default, core, nullable, optional, registry } from 'zod/mini'
19
+ import { _default, core, nullable, optional } from 'zod/mini'
20
+
21
+ import type { TypeMetadata } from './_metadata.ts'
22
+ import { standard } from '../standart-schema.ts'
23
+ import { typesRegistry } from './_metadata.ts'
21
24
 
22
25
  export type PrimitiveValueType = string | number | boolean | null
23
26
 
@@ -44,13 +47,6 @@ export type ZodType = SimpleZodType | ZodMiniType
44
47
 
45
48
  export type TypeProps = Record<string, any>
46
49
 
47
- export type TypeMetadata<T = any> = {
48
- id?: string
49
- description?: string
50
- examples?: T[]
51
- title?: string
52
- }
53
-
54
50
  export type TypeParams = {
55
51
  encode?: (value: any) => any
56
52
  metadata?: TypeMetadata
@@ -67,8 +63,6 @@ export type BaseTypeAny<
67
63
  DecodedZodType extends ZodType = ZodMiniType,
68
64
  > = BaseType<EncodedZodType, DecodedZodType, TypeProps>
69
65
 
70
- export const typesRegistry = registry<TypeMetadata>()
71
-
72
66
  export const NeemataTypeError = core.$ZodError
73
67
  export type NeemataTypeError = core.$ZodError
74
68
 
@@ -78,11 +72,7 @@ export abstract class BaseType<
78
72
  Props extends TypeProps = TypeProps,
79
73
  RawEncodeZodType extends SimpleZodType = EncodeZodType,
80
74
  RawDecodeZodType extends ZodType = DecodeZodType,
81
- > implements
82
- StandardSchemaV1<
83
- DecodeZodType['_zod']['input'],
84
- EncodeZodType['_zod']['output']
85
- >
75
+ > implements standard.Schema<DecodeZodType>
86
76
  {
87
77
  readonly encodeZodType: EncodeZodType
88
78
  readonly decodeZodType: DecodeZodType
@@ -90,6 +80,11 @@ export abstract class BaseType<
90
80
  readonly decodeRawZodType!: RawDecodeZodType
91
81
  readonly props: Props
92
82
  readonly params: TypeParams
83
+ readonly standard: {
84
+ encode: standard.Schema<EncodeZodType>
85
+ decode: standard.Schema<DecodeZodType>
86
+ }
87
+ readonly '~standard': standard.Props<DecodeZodType>
93
88
 
94
89
  constructor({
95
90
  encodeZodType,
@@ -107,6 +102,11 @@ export abstract class BaseType<
107
102
 
108
103
  this.props = props
109
104
  this.params = Object.assign({ checks: [] }, params)
105
+ this.standard = {
106
+ encode: standard.encode(this, typesRegistry),
107
+ decode: standard.decode(this, typesRegistry),
108
+ }
109
+ this['~standard'] = this.standard.decode['~standard']
110
110
  }
111
111
 
112
112
  optional(): OptionalType<this> {
@@ -161,39 +161,6 @@ export abstract class BaseType<
161
161
  ): this['decodeZodType']['_zod']['output'] {
162
162
  return this.decodeZodType.parse(data, { reportInput: true, ...context })
163
163
  }
164
-
165
- '~standard': StandardSchemaV1.Props<
166
- this['decodeZodType']['_zod']['input'],
167
- this['encodeZodType']['_zod']['output']
168
- > = {
169
- validate: (
170
- input: unknown,
171
- options?: StandardSchemaV1.Options | undefined,
172
- ) => {
173
- try {
174
- const value = this.decode(
175
- input,
176
- (options?.libraryOptions as any)?.context,
177
- )
178
- return { value }
179
- } catch (e) {
180
- if (e instanceof core.$ZodError) {
181
- const issues: StandardSchemaV1.Issue[] = e.issues.map((issue) => ({
182
- message: issue.message,
183
- path: issue.path.length > 0 ? issue.path : undefined,
184
- }))
185
- return { issues }
186
- }
187
- throw e
188
- }
189
- },
190
- types: {
191
- input: undefined as unknown as this['decodeZodType']['_zod']['input'],
192
- output: undefined as unknown as this['encodeZodType']['_zod']['output'],
193
- },
194
- vendor: 'neemata-type',
195
- version: 1,
196
- }
197
164
  }
198
165
 
199
166
  export class OptionalType<
@@ -50,7 +50,6 @@ export class CustomType<
50
50
  validation?:
51
51
  | ((
52
52
  value: EncodeType['_zod']['input'] | DecodeType['_zod']['output'],
53
-
54
53
  payload: core.$RefinementCtx<
55
54
  EncodeType['_zod']['output'] | DecodeType['_zod']['output']
56
55
  >,
@@ -1,5 +1,7 @@
1
1
  import type { core, ZodMiniString } from 'zod/mini'
2
2
  import {
3
+ base64,
4
+ base64url,
3
5
  cuid,
4
6
  cuid2,
5
7
  e164,
@@ -90,6 +92,14 @@ export class StringType extends BaseType<
90
92
  jwt(options?: core.$ZodJWTParams) {
91
93
  return StringType.factory(...this.params.checks, jwt(options))
92
94
  }
95
+
96
+ base64(options?: core.$ZodBase64Params) {
97
+ return StringType.factory(...this.params.checks, base64(options))
98
+ }
99
+
100
+ base64URL(options?: core.$ZodBase64URLParams) {
101
+ return StringType.factory(...this.params.checks, base64url(options))
102
+ }
93
103
  }
94
104
 
95
105
  export const string = StringType.factory