@tsgonest/types 0.0.1
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 +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/tags.d.ts +237 -0
- package/dist/tags.d.ts.map +1 -0
- package/dist/tags.js +29 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tsgonest/types — Zero-runtime branded types for type-safe validation constraints.
|
|
3
|
+
*
|
|
4
|
+
* This package provides phantom branded types that the tsgonest compiler
|
|
5
|
+
* inspects at build time to generate validation and serialization code.
|
|
6
|
+
* No runtime code is emitted — these types exist purely for type safety
|
|
7
|
+
* and IDE autocomplete.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { tags } from "@tsgonest/types";
|
|
12
|
+
*
|
|
13
|
+
* interface CreateUserDto {
|
|
14
|
+
* email: string & tags.Format<"email">;
|
|
15
|
+
* name: string & tags.MinLength<1> & tags.MaxLength<255>;
|
|
16
|
+
* age: number & tags.Minimum<0> & tags.Maximum<150>;
|
|
17
|
+
* tags: string[] & tags.MinItems<1> & tags.UniqueItems;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Convenience aliases for common patterns:
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { tags } from "@tsgonest/types";
|
|
24
|
+
*
|
|
25
|
+
* interface User {
|
|
26
|
+
* email: string & tags.Email; // same as tags.Format<"email">
|
|
27
|
+
* id: string & tags.Uuid; // same as tags.Format<"uuid">
|
|
28
|
+
* website: string & tags.Url; // same as tags.Format<"url">
|
|
29
|
+
* age: number & tags.Int & tags.NonNegative; // int32 & >= 0
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export * as tags from "./tags.js";
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tsgonest/types — Zero-runtime branded types for type-safe validation constraints.
|
|
3
|
+
*
|
|
4
|
+
* This package provides phantom branded types that the tsgonest compiler
|
|
5
|
+
* inspects at build time to generate validation and serialization code.
|
|
6
|
+
* No runtime code is emitted — these types exist purely for type safety
|
|
7
|
+
* and IDE autocomplete.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { tags } from "@tsgonest/types";
|
|
12
|
+
*
|
|
13
|
+
* interface CreateUserDto {
|
|
14
|
+
* email: string & tags.Format<"email">;
|
|
15
|
+
* name: string & tags.MinLength<1> & tags.MaxLength<255>;
|
|
16
|
+
* age: number & tags.Minimum<0> & tags.Maximum<150>;
|
|
17
|
+
* tags: string[] & tags.MinItems<1> & tags.UniqueItems;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Convenience aliases for common patterns:
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { tags } from "@tsgonest/types";
|
|
24
|
+
*
|
|
25
|
+
* interface User {
|
|
26
|
+
* email: string & tags.Email; // same as tags.Format<"email">
|
|
27
|
+
* id: string & tags.Uuid; // same as tags.Format<"uuid">
|
|
28
|
+
* website: string & tags.Url; // same as tags.Format<"url">
|
|
29
|
+
* age: number & tags.Int & tags.NonNegative; // int32 & >= 0
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export * as tags from "./tags.js";
|
package/dist/tags.d.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tsgonest/types — Zero-runtime branded types for type-safe validation constraints.
|
|
3
|
+
*
|
|
4
|
+
* These types exist purely at compile time. They produce NO runtime code.
|
|
5
|
+
* The tsgonest compiler inspects the phantom intersection properties
|
|
6
|
+
* (prefixed with `__tsgonest_`) to extract validation constraints.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { tags } from "@tsgonest/types";
|
|
10
|
+
*
|
|
11
|
+
* interface CreateUserDto {
|
|
12
|
+
* email: string & tags.Format<"email">;
|
|
13
|
+
* name: string & tags.MinLength<1> & tags.MaxLength<255>;
|
|
14
|
+
* age: number & tags.Minimum<0> & tags.Maximum<150>;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* This is equivalent to using JSDoc tags:
|
|
18
|
+
* interface CreateUserDto {
|
|
19
|
+
* // @format email
|
|
20
|
+
* email: string;
|
|
21
|
+
* // @minLength 1
|
|
22
|
+
* // @maxLength 255
|
|
23
|
+
* name: string;
|
|
24
|
+
* // @minimum 0
|
|
25
|
+
* // @maximum 150
|
|
26
|
+
* age: number;
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* All supported string format values.
|
|
31
|
+
* Includes standard JSON Schema formats, plus Zod 4 / typia extras.
|
|
32
|
+
*/
|
|
33
|
+
export type FormatValue = "email" | "idn-email" | "url" | "uri" | "uri-reference" | "uri-template" | "iri" | "iri-reference" | "uuid" | "ipv4" | "ipv6" | "hostname" | "idn-hostname" | "date-time" | "date" | "time" | "duration" | "json-pointer" | "relative-json-pointer" | "byte" | "password" | "regex" | "nanoid" | "cuid" | "cuid2" | "ulid" | "jwt" | "base64url" | "hex" | "mac" | "cidrv4" | "cidrv6" | "emoji";
|
|
34
|
+
/**
|
|
35
|
+
* Constrain a string to match a specific format (e.g. "email", "uuid", "url").
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* type Email = string & tags.Format<"email">;
|
|
39
|
+
* type UserId = string & tags.Format<"uuid">;
|
|
40
|
+
*/
|
|
41
|
+
export type Format<F extends FormatValue> = {
|
|
42
|
+
readonly __tsgonest_format: F;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Constrain minimum string length.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* type NonEmpty = string & tags.MinLength<1>;
|
|
49
|
+
*/
|
|
50
|
+
export type MinLength<N extends number> = {
|
|
51
|
+
readonly __tsgonest_minLength: N;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Constrain maximum string length.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* type ShortName = string & tags.MaxLength<50>;
|
|
58
|
+
*/
|
|
59
|
+
export type MaxLength<N extends number> = {
|
|
60
|
+
readonly __tsgonest_maxLength: N;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Constrain string to exact length (sets both minLength and maxLength).
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* type CountryCode = string & tags.Length<2>;
|
|
67
|
+
*/
|
|
68
|
+
export type Length<N extends number> = MinLength<N> & MaxLength<N>;
|
|
69
|
+
/**
|
|
70
|
+
* Constrain a string to match a regex pattern.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* type AlphaNumeric = string & tags.Pattern<"^[a-zA-Z0-9]+$">;
|
|
74
|
+
*/
|
|
75
|
+
export type Pattern<P extends string> = {
|
|
76
|
+
readonly __tsgonest_pattern: P;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Constrain a string to start with a specific prefix.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* type HttpUrl = string & tags.StartsWith<"https://">;
|
|
83
|
+
*/
|
|
84
|
+
export type StartsWith<S extends string> = {
|
|
85
|
+
readonly __tsgonest_startsWith: S;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Constrain a string to end with a specific suffix.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* type JsonFile = string & tags.EndsWith<".json">;
|
|
92
|
+
*/
|
|
93
|
+
export type EndsWith<S extends string> = {
|
|
94
|
+
readonly __tsgonest_endsWith: S;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Constrain a string to include a specific substring.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* type ContainsAt = string & tags.Includes<"@">;
|
|
101
|
+
*/
|
|
102
|
+
export type Includes<S extends string> = {
|
|
103
|
+
readonly __tsgonest_includes: S;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Constrain minimum numeric value (inclusive).
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* type NonNegative = number & tags.Minimum<0>;
|
|
110
|
+
*/
|
|
111
|
+
export type Minimum<N extends number> = {
|
|
112
|
+
readonly __tsgonest_minimum: N;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Constrain maximum numeric value (inclusive).
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* type Percentage = number & tags.Minimum<0> & tags.Maximum<100>;
|
|
119
|
+
*/
|
|
120
|
+
export type Maximum<N extends number> = {
|
|
121
|
+
readonly __tsgonest_maximum: N;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Constrain exclusive minimum (value must be > N).
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* type Positive = number & tags.ExclusiveMinimum<0>;
|
|
128
|
+
*/
|
|
129
|
+
export type ExclusiveMinimum<N extends number> = {
|
|
130
|
+
readonly __tsgonest_exclusiveMinimum: N;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Constrain exclusive maximum (value must be < N).
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* type Negative = number & tags.ExclusiveMaximum<0>;
|
|
137
|
+
*/
|
|
138
|
+
export type ExclusiveMaximum<N extends number> = {
|
|
139
|
+
readonly __tsgonest_exclusiveMaximum: N;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Constrain numeric value to be a multiple of N.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* type Even = number & tags.MultipleOf<2>;
|
|
146
|
+
*/
|
|
147
|
+
export type MultipleOf<N extends number> = {
|
|
148
|
+
readonly __tsgonest_multipleOf: N;
|
|
149
|
+
};
|
|
150
|
+
/** Valid numeric type values. */
|
|
151
|
+
export type NumericTypeValue = "int32" | "uint32" | "int64" | "uint64" | "float" | "double";
|
|
152
|
+
/**
|
|
153
|
+
* Constrain a number to a specific numeric type (range/precision).
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* type Port = number & tags.Type<"uint32">;
|
|
157
|
+
* type SafeInt = number & tags.Type<"int64">;
|
|
158
|
+
*/
|
|
159
|
+
export type Type<T extends NumericTypeValue> = {
|
|
160
|
+
readonly __tsgonest_type: T;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Constrain minimum array length.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* type NonEmptyArray<T> = T[] & tags.MinItems<1>;
|
|
167
|
+
*/
|
|
168
|
+
export type MinItems<N extends number> = {
|
|
169
|
+
readonly __tsgonest_minItems: N;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Constrain maximum array length.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* type LimitedArray<T> = T[] & tags.MaxItems<100>;
|
|
176
|
+
*/
|
|
177
|
+
export type MaxItems<N extends number> = {
|
|
178
|
+
readonly __tsgonest_maxItems: N;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Constrain array items to be unique.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* type UniqueIds = string[] & tags.UniqueItems;
|
|
185
|
+
*/
|
|
186
|
+
export type UniqueItems = {
|
|
187
|
+
readonly __tsgonest_uniqueItems: true;
|
|
188
|
+
};
|
|
189
|
+
/** String validated as email format. */
|
|
190
|
+
export type Email = Format<"email">;
|
|
191
|
+
/** String validated as UUID format. */
|
|
192
|
+
export type Uuid = Format<"uuid">;
|
|
193
|
+
/** String validated as URL format. */
|
|
194
|
+
export type Url = Format<"url">;
|
|
195
|
+
/** String validated as URI format. */
|
|
196
|
+
export type Uri = Format<"uri">;
|
|
197
|
+
/** String validated as IPv4 format. */
|
|
198
|
+
export type IPv4 = Format<"ipv4">;
|
|
199
|
+
/** String validated as IPv6 format. */
|
|
200
|
+
export type IPv6 = Format<"ipv6">;
|
|
201
|
+
/** String validated as date-time (ISO 8601) format. */
|
|
202
|
+
export type DateTime = Format<"date-time">;
|
|
203
|
+
/** String validated as date (YYYY-MM-DD) format. */
|
|
204
|
+
export type DateOnly = Format<"date">;
|
|
205
|
+
/** String validated as time (HH:MM:SS) format. */
|
|
206
|
+
export type Time = Format<"time">;
|
|
207
|
+
/** String validated as duration (ISO 8601 duration) format. */
|
|
208
|
+
export type Duration = Format<"duration">;
|
|
209
|
+
/** String validated as JWT format. */
|
|
210
|
+
export type Jwt = Format<"jwt">;
|
|
211
|
+
/** String validated as ULID format. */
|
|
212
|
+
export type Ulid = Format<"ulid">;
|
|
213
|
+
/** String validated as CUID format. */
|
|
214
|
+
export type Cuid = Format<"cuid">;
|
|
215
|
+
/** String validated as CUID2 format. */
|
|
216
|
+
export type Cuid2 = Format<"cuid2">;
|
|
217
|
+
/** String validated as Nano ID format. */
|
|
218
|
+
export type NanoId = Format<"nanoid">;
|
|
219
|
+
/** Number constrained to be > 0. */
|
|
220
|
+
export type Positive = ExclusiveMinimum<0>;
|
|
221
|
+
/** Number constrained to be < 0. */
|
|
222
|
+
export type Negative = ExclusiveMaximum<0>;
|
|
223
|
+
/** Number constrained to be >= 0. */
|
|
224
|
+
export type NonNegative = Minimum<0>;
|
|
225
|
+
/** Number constrained to be <= 0. */
|
|
226
|
+
export type NonPositive = Maximum<0>;
|
|
227
|
+
/** Number constrained to 32-bit integer range. */
|
|
228
|
+
export type Int = Type<"int32">;
|
|
229
|
+
/** Number constrained to JS safe integer range (-2^53+1 to 2^53-1). */
|
|
230
|
+
export type SafeInt = Type<"int64">;
|
|
231
|
+
/** Number constrained to finite values (no Infinity/NaN). */
|
|
232
|
+
export type Finite = Type<"float">;
|
|
233
|
+
/** Number constrained to 32-bit unsigned integer range. */
|
|
234
|
+
export type Uint = Type<"uint32">;
|
|
235
|
+
/** Number constrained to double precision float. */
|
|
236
|
+
export type Double = Type<"double">;
|
|
237
|
+
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH;;;GAGG;AACH,MAAM,MAAM,WAAW,GAEnB,OAAO,GACP,WAAW,GACX,KAAK,GACL,KAAK,GACL,eAAe,GACf,cAAc,GACd,KAAK,GACL,eAAe,GACf,MAAM,GACN,MAAM,GACN,MAAM,GACN,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,MAAM,GACN,UAAU,GACV,cAAc,GACd,uBAAuB,GACvB,MAAM,GACN,UAAU,GACV,OAAO,GAEP,QAAQ,GACR,MAAM,GACN,OAAO,GACP,MAAM,GACN,KAAK,GACL,WAAW,GACX,KAAK,GACL,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,OAAO,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,WAAW,IAAI;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC;CAC/B,CAAC;AAIF;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;IACxC,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,CA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AI,CAAC,QAAQ,CAAC,CAAC;AAElC,oDAAoD;AACpD,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/tags.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tsgonest/types — Zero-runtime branded types for type-safe validation constraints.
|
|
3
|
+
*
|
|
4
|
+
* These types exist purely at compile time. They produce NO runtime code.
|
|
5
|
+
* The tsgonest compiler inspects the phantom intersection properties
|
|
6
|
+
* (prefixed with `__tsgonest_`) to extract validation constraints.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { tags } from "@tsgonest/types";
|
|
10
|
+
*
|
|
11
|
+
* interface CreateUserDto {
|
|
12
|
+
* email: string & tags.Format<"email">;
|
|
13
|
+
* name: string & tags.MinLength<1> & tags.MaxLength<255>;
|
|
14
|
+
* age: number & tags.Minimum<0> & tags.Maximum<150>;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* This is equivalent to using JSDoc tags:
|
|
18
|
+
* interface CreateUserDto {
|
|
19
|
+
* // @format email
|
|
20
|
+
* email: string;
|
|
21
|
+
* // @minLength 1
|
|
22
|
+
* // @maxLength 255
|
|
23
|
+
* name: string;
|
|
24
|
+
* // @minimum 0
|
|
25
|
+
* // @maximum 150
|
|
26
|
+
* age: number;
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsgonest/types",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Zero-runtime branded types for tsgonest validation constraints — type-safe alternative to JSDoc tags",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./tags": {
|
|
14
|
+
"types": "./dist/tags.d.ts",
|
|
15
|
+
"import": "./dist/tags.mjs",
|
|
16
|
+
"require": "./dist/tags.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"typescript",
|
|
24
|
+
"validation",
|
|
25
|
+
"branded-types",
|
|
26
|
+
"phantom-types",
|
|
27
|
+
"tsgonest",
|
|
28
|
+
"type-safe"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/tsgonest/tsgonest"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^5.7.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"test": "tsc --noEmit"
|
|
42
|
+
}
|
|
43
|
+
}
|