@arrirpc/schema 0.76.4 → 0.77.0
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/README.md +274 -109
- package/dist/adapters.d.cts +1 -1
- package/dist/adapters.d.mts +1 -1
- package/dist/adapters.d.ts +1 -1
- package/dist/index.d.cts +63 -21
- package/dist/index.d.mts +63 -21
- package/dist/index.d.ts +63 -21
- package/dist/shared/{schema.CGpRJ4kH.d.cts → schema.hMebmI3A.d.cts} +2 -1
- package/dist/shared/{schema.CGpRJ4kH.d.mts → schema.hMebmI3A.d.mts} +2 -1
- package/dist/shared/{schema.CGpRJ4kH.d.ts → schema.hMebmI3A.d.ts} +2 -1
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ Originally this library was created as a way for building schemas for [Json Type
|
|
|
28
28
|
- [Basic Example](#basic-example)
|
|
29
29
|
- [Usage with @arrirpc/server](#usage-with-arrirpcserver)
|
|
30
30
|
- [Compiling to other languages](#compiling-to-other-languages)
|
|
31
|
+
- [Tree-Shakeable Imports](#tree-shakeable-imports)
|
|
31
32
|
- [Supported Types](#supported-types)
|
|
32
33
|
- [Primitives](#primitives)
|
|
33
34
|
- [Enums](#enums)
|
|
@@ -79,9 +80,9 @@ const User = a.object({
|
|
|
79
80
|
|
|
80
81
|
type User = a.infer<typeof User>;
|
|
81
82
|
|
|
82
|
-
//
|
|
83
|
+
// returns ResultSuccess<User>
|
|
83
84
|
a.parse(User, `{"id": "1", "name": "John Doe"}`);
|
|
84
|
-
//
|
|
85
|
+
// returns ResultFailure
|
|
85
86
|
a.parse(User, `{"id": "1", "name": null}`);
|
|
86
87
|
|
|
87
88
|
// returns true
|
|
@@ -252,6 +253,67 @@ data class User(
|
|
|
252
253
|
|
|
253
254
|
See [here](/README.md#client-generators) for a list of all officially supported language generators.
|
|
254
255
|
|
|
256
|
+
## Tree-Shakeable Imports
|
|
257
|
+
|
|
258
|
+
For those that are concerned about bundle sizes you can use Arri's optional modular import syntax. This makes it so that bundlers can remove unused Arri functions from JS bundles at build time. You can also enforce this in your codebase using the [arri/prefer-modular-imports](/languages/ts/eslint-plugin/README.md) lint rule.
|
|
259
|
+
|
|
260
|
+
Using the modular import syntax Arri's bundle size can be as small as 4kb depending on how many functions you import.
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
// tree-shakeable (no `a` prefix)
|
|
264
|
+
import { string, boolean, object } from '@arrirpc/schema';
|
|
265
|
+
const User = object({
|
|
266
|
+
id: string(),
|
|
267
|
+
name: string(),
|
|
268
|
+
isAdmin: boolean(),
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// tree-shakeable (with `a` prefix)
|
|
272
|
+
import * as a from '@arrirpc/schema';
|
|
273
|
+
const User = a.object({
|
|
274
|
+
id: a.string(),
|
|
275
|
+
name: a.string(),
|
|
276
|
+
isAdmin: a.boolean(),
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// NOT tree-shakeable
|
|
280
|
+
import { a } from '@arrirpc/schema';
|
|
281
|
+
const User = a.object({
|
|
282
|
+
id: a.string(),
|
|
283
|
+
name: a.string(),
|
|
284
|
+
isAdmin: a.boolean(),
|
|
285
|
+
});
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Click [here](/languages/ts/ts-schema-benchmarks/README.md#bundle-size) to see how Arri Schema's bundle sizes compares to the rest of the ecosystem.
|
|
289
|
+
|
|
290
|
+
### Why isn't this the default?
|
|
291
|
+
|
|
292
|
+
Just personal preference. I find manually importing individual functions to be a bad developer experience.
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
// not a fan
|
|
296
|
+
import { foo, bar, baz } from 'foo';
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Additionally, having an explicitly exported `a` namespace means that when I type `a.{something}` that the TS language server will autocomplete the available functions even if I haven't imported `@arrirpc/schema` yet. If we didn't have that explicit export, then you would not get autocomplete for `a.{something}` until you added the `import * as a` line to your file.
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
// this has to be added before you get autocomplete for `a.{whatever}`
|
|
303
|
+
import * as a from '@arrirpc/schema';
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
However I understand that keeping small bundle sizes can be important which is why I've allowed both options:
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
// if you care about bundle size use one of these two
|
|
310
|
+
import * as a from '@arrirpc/schema';
|
|
311
|
+
import { string, object, etc } from '@arrirpc/schema';
|
|
312
|
+
|
|
313
|
+
// if you aren't as particular about bundle sizes then use this
|
|
314
|
+
import { a } from '@arrirpc/schema';
|
|
315
|
+
```
|
|
316
|
+
|
|
255
317
|
## Supported Types
|
|
256
318
|
|
|
257
319
|
### Primitives
|
|
@@ -1024,7 +1086,7 @@ $$User.compiledCode.serialize; // the generated serialization code
|
|
|
1024
1086
|
|
|
1025
1087
|
## Benchmarks
|
|
1026
1088
|
|
|
1027
|
-
_Last Updated:
|
|
1089
|
+
_Last Updated: 2025-03-19T21:46:43.732Z_
|
|
1028
1090
|
|
|
1029
1091
|
All benchmarks were run on my personal desktop. You can view the methodology used in [./benchmarks/src](./benchmark/src).
|
|
1030
1092
|
|
|
@@ -1035,123 +1097,226 @@ RAM - 32GB
|
|
|
1035
1097
|
Graphics - AMD® Radeon rx 6900 xt
|
|
1036
1098
|
```
|
|
1037
1099
|
|
|
1100
|
+
<!-- BENCHMARK_START -->
|
|
1101
|
+
|
|
1038
1102
|
### Objects
|
|
1039
1103
|
|
|
1040
|
-
The following
|
|
1104
|
+
The following type was used in these benchmarks. Equivalent schemas were created in each of the mentioned libraries.
|
|
1041
1105
|
|
|
1042
1106
|
```ts
|
|
1043
|
-
{
|
|
1044
|
-
id:
|
|
1045
|
-
role:
|
|
1046
|
-
name:
|
|
1047
|
-
email: null
|
|
1048
|
-
createdAt:
|
|
1049
|
-
updatedAt:
|
|
1050
|
-
settings:
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1107
|
+
interface TestUser {
|
|
1108
|
+
id: number; // integer,
|
|
1109
|
+
role: 'standard' | 'admin' | 'moderator';
|
|
1110
|
+
name: string;
|
|
1111
|
+
email: string | null;
|
|
1112
|
+
createdAt: number; // integer
|
|
1113
|
+
updatedAt: number; // integer
|
|
1114
|
+
settings:
|
|
1115
|
+
| {
|
|
1116
|
+
preferredTheme: 'light' | 'dark' | 'system';
|
|
1117
|
+
allowNotifications: boolean;
|
|
1118
|
+
}
|
|
1119
|
+
| undefined;
|
|
1120
|
+
recentNotifications: Array<
|
|
1121
|
+
| {
|
|
1122
|
+
type: 'POST_LIKE';
|
|
1123
|
+
userId: string;
|
|
1124
|
+
postId: string;
|
|
1125
|
+
}
|
|
1126
|
+
| {
|
|
1127
|
+
type: 'POST_COMMENT';
|
|
1128
|
+
userId: string;
|
|
1129
|
+
postId: string;
|
|
1130
|
+
commentText: string;
|
|
1131
|
+
}
|
|
1132
|
+
>;
|
|
1133
|
+
}
|
|
1068
1134
|
```
|
|
1069
1135
|
|
|
1070
|
-
#### Validation
|
|
1071
|
-
|
|
1072
|
-
| Library
|
|
1073
|
-
|
|
|
1074
|
-
| **Arri (Compiled)**
|
|
1075
|
-
|
|
|
1076
|
-
| Ajv -JTD (Compiled)
|
|
1077
|
-
|
|
|
1078
|
-
|
|
|
1079
|
-
|
|
|
1080
|
-
|
|
|
1081
|
-
|
|
|
1082
|
-
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
|
1087
|
-
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
|
1096
|
-
|
|
|
1097
|
-
|
|
|
1098
|
-
| **Arri (Compiled)
|
|
1099
|
-
| Ajv -
|
|
1100
|
-
|
|
|
1101
|
-
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
|
1106
|
-
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1136
|
+
#### Object Validation - Good Input
|
|
1137
|
+
|
|
1138
|
+
| Library | op/s |
|
|
1139
|
+
| ------------------------------------- | ---------- |
|
|
1140
|
+
| **Arri (Compiled)** | 54,124,628 |
|
|
1141
|
+
| TypeBox (Compiled) | 42,197,488 |
|
|
1142
|
+
| Ajv - JTD (Compiled) | 31,927,096 |
|
|
1143
|
+
| Arktype | 29,595,516 |
|
|
1144
|
+
| Typia | 28,381,607 |
|
|
1145
|
+
| **Arri (Compiled) - Standard Schema** | 18,826,632 |
|
|
1146
|
+
| Ajv - JSON Schema (Compiled) | 11,420,306 |
|
|
1147
|
+
| Ajv - JTD | 11,368,094 |
|
|
1148
|
+
| Ajv - JSON Schema | 8,370,741 |
|
|
1149
|
+
| **Arri** | 2,732,305 |
|
|
1150
|
+
| **Arri - Standard Schema** | 757,117 |
|
|
1151
|
+
| TypeBox | 733,853 |
|
|
1152
|
+
| Valibot | 607,841 |
|
|
1153
|
+
| Zod | 467,553 |
|
|
1154
|
+
|
|
1155
|
+
#### Object Validation - Bad Input
|
|
1156
|
+
|
|
1157
|
+
| Library | op/s |
|
|
1158
|
+
| ------------------------------------- | ---------- |
|
|
1159
|
+
| **Arri (Compiled)** | 63,206,923 |
|
|
1160
|
+
| TypeBox (Compiled) | 47,209,177 |
|
|
1161
|
+
| Typia | 30,610,871 |
|
|
1162
|
+
| Ajv - JTD (Compiled) | 25,543,957 |
|
|
1163
|
+
| Ajv - JTD | 13,095,043 |
|
|
1164
|
+
| **Arri (Compiled) - Standard Schema** | 8,184,643 |
|
|
1165
|
+
| Ajv - JSON Schema (Compiled) | 4,543,106 |
|
|
1166
|
+
| **Arri** | 4,237,065 |
|
|
1167
|
+
| Ajv - JSON Schema | 3,790,517 |
|
|
1168
|
+
| TypeBox | 906,797 |
|
|
1169
|
+
| **Arri - Standard-Schema** | 794,635 |
|
|
1170
|
+
| Valibot | 485,994 |
|
|
1171
|
+
| Zod | 321,011 |
|
|
1172
|
+
| Arktype | 139,720 |
|
|
1173
|
+
|
|
1174
|
+
#### Object Parsing - Good Input
|
|
1175
|
+
|
|
1176
|
+
| Library | op/s |
|
|
1177
|
+
| ------------------------------------- | ------- |
|
|
1178
|
+
| JSON.parse | 773,939 |
|
|
1179
|
+
| JSON.parse + Typebox (Compiled) | 746,709 |
|
|
1180
|
+
| Typia (json.createValidateParse) | 736,675 |
|
|
1181
|
+
| JSON.parse + Arktype | 736,157 |
|
|
1182
|
+
| **Arri (Compiled)** | 722,323 |
|
|
1183
|
+
| **Arri (Compiled) - Standard Schema** | 711,010 |
|
|
1184
|
+
| **Arri - Standard Schema** | 348,920 |
|
|
1185
|
+
| **Arri** | 348,467 |
|
|
1186
|
+
| JSON.parse + Valibot | 314,205 |
|
|
1187
|
+
| JSON.parse + Zod | 280,872 |
|
|
1188
|
+
| Ajv - JTD (Compiled) | 261,253 |
|
|
1189
|
+
| JSON.parse + Typebox | 215,239 |
|
|
1190
|
+
|
|
1191
|
+
#### Object Parsing - Bad Input
|
|
1192
|
+
|
|
1193
|
+
| Library | op/s |
|
|
1194
|
+
| ------------------------------------- | ------- |
|
|
1195
|
+
| JSON.parse | 871,925 |
|
|
1196
|
+
| **Arri (Compiled)** | 796,037 |
|
|
1197
|
+
| **Arri (Compiled) - Standard Schema** | 728,394 |
|
|
1198
|
+
| Typia (json.createValidateParse) | 556,550 |
|
|
1199
|
+
| **Arri** | 415,938 |
|
|
1200
|
+
| **Arri - StandardSchema** | 395,654 |
|
|
1201
|
+
| Ajv - JTD (Compiled) | 332,767 |
|
|
1202
|
+
| JSON.parse + Valibot | 300,625 |
|
|
1203
|
+
| JSON.parse + Zod | 215,862 |
|
|
1204
|
+
| JSON.parse + Arktype | 119,465 |
|
|
1205
|
+
| JSON.parse + Typebox (Compiled) | 96,386 |
|
|
1206
|
+
| JSON.parse + Typebox | 77,921 |
|
|
1207
|
+
|
|
1208
|
+
#### Object Serialization
|
|
1209
|
+
|
|
1210
|
+
| Library | op/s |
|
|
1211
|
+
| -------------------------------------------- | --------- |
|
|
1212
|
+
| **Arri (Compiled)** | 4,342,282 |
|
|
1213
|
+
| **Arri (Compiled) - Validate and Serialize** | 3,869,687 |
|
|
1214
|
+
| Ajv - JTD (Compiled) | 2,100,923 |
|
|
1215
|
+
| Typia | 1,823,903 |
|
|
1216
|
+
| JSON.stringify | 1,635,149 |
|
|
1217
|
+
| Typia - Validate and Serialize | 1,570,486 |
|
|
1218
|
+
| **Arri** | 471,954 |
|
|
1219
|
+
|
|
1220
|
+
#### Object Coercion
|
|
1221
|
+
|
|
1222
|
+
| Library | op/s |
|
|
1223
|
+
| ------------------- | ---------- |
|
|
1224
|
+
| **Arri (Compiled)** | 19,743,175 |
|
|
1225
|
+
| **Arri** | 787,241 |
|
|
1226
|
+
| Zod | 442,329 |
|
|
1227
|
+
| TypeBox | 403,062 |
|
|
1110
1228
|
|
|
1111
1229
|
### Integers
|
|
1112
1230
|
|
|
1113
1231
|
The following benchmarks measure how quickly each library operates on a single integer value.
|
|
1114
1232
|
|
|
1115
|
-
#### Validation
|
|
1116
|
-
|
|
1117
|
-
| Library
|
|
1118
|
-
|
|
|
1119
|
-
|
|
|
1120
|
-
|
|
|
1121
|
-
|
|
|
1122
|
-
| Ajv -
|
|
1123
|
-
| **Arri**
|
|
1124
|
-
|
|
|
1125
|
-
|
|
|
1126
|
-
|
|
|
1127
|
-
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
|
1132
|
-
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
|
1141
|
-
|
|
|
1142
|
-
|
|
|
1143
|
-
|
|
|
1144
|
-
| **Arri**
|
|
1145
|
-
| JSON
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
|
1150
|
-
|
|
|
1151
|
-
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1233
|
+
#### Int Validation
|
|
1234
|
+
|
|
1235
|
+
| Library | op/s |
|
|
1236
|
+
| ------------------------------------- | ----------- |
|
|
1237
|
+
| Ajv - JTD (Compiled) | 192,026,130 |
|
|
1238
|
+
| TypeBox (Compiled) | 190,783,837 |
|
|
1239
|
+
| **Arri (Compiled)** | 188,138,821 |
|
|
1240
|
+
| Ajv - JSON Schema (Compiled) | 182,920,826 |
|
|
1241
|
+
| **Arri - Standard Schema** | 110,055,872 |
|
|
1242
|
+
| **Arri (Compiled) - Standard Schema** | 109,070,056 |
|
|
1243
|
+
| **Arri** | 81,658,732 |
|
|
1244
|
+
| Typia | 61,029,032 |
|
|
1245
|
+
| Arktype | 54,370,348 |
|
|
1246
|
+
| TypeBox | 48,673,070 |
|
|
1247
|
+
| Ajv - JTD | 31,204,944 |
|
|
1248
|
+
| Ajv - JSON Schema | 31,075,953 |
|
|
1249
|
+
| Valibot | 23,309,004 |
|
|
1250
|
+
| Zod | 1,277,690 |
|
|
1251
|
+
|
|
1252
|
+
#### Int Validation (Bad Input)
|
|
1253
|
+
|
|
1254
|
+
| Library | op/s |
|
|
1255
|
+
| ------------------------------------- | ----------- |
|
|
1256
|
+
| TypeBox (Compiled) | 190,126,454 |
|
|
1257
|
+
| **Arri (Compiled)** | 189,172,106 |
|
|
1258
|
+
| Ajv - JSON Schema (Compiled) | 75,375,601 |
|
|
1259
|
+
| Ajv - JTD (Compiled) | 74,177,660 |
|
|
1260
|
+
| Typia | 58,363,051 |
|
|
1261
|
+
| TypeBox | 45,205,805 |
|
|
1262
|
+
| **Arri** | 42,222,871 |
|
|
1263
|
+
| Ajv - JSON Schema | 19,876,104 |
|
|
1264
|
+
| Ajv - JTD | 19,027,047 |
|
|
1265
|
+
| **Arri (Compiled) - Standard Schema** | 17,164,858 |
|
|
1266
|
+
| **Arri - Standard Schema** | 12,296,640 |
|
|
1267
|
+
| Valibot | 9,545,070 |
|
|
1268
|
+
| Zod | 799,307 |
|
|
1269
|
+
| Arktype | 451,199 |
|
|
1270
|
+
|
|
1271
|
+
#### Int Parsing (Good Input)
|
|
1272
|
+
|
|
1273
|
+
| Library | op/s |
|
|
1274
|
+
| -------------------- | ----------- |
|
|
1275
|
+
| **Arri (Compiled)** | 130,550,378 |
|
|
1276
|
+
| **Arri** | 49,495,612 |
|
|
1277
|
+
| JSON.parse() | 17,843,485 |
|
|
1278
|
+
| Ajv - JTD (Compiled) | 9,664,631 |
|
|
1279
|
+
|
|
1280
|
+
#### Int Parsing (Bad Input)
|
|
1281
|
+
|
|
1282
|
+
| Library | op/s |
|
|
1283
|
+
| -------------------- | ---------- |
|
|
1284
|
+
| **Arri (Compiled)** | 60,596,060 |
|
|
1285
|
+
| JSON.parse() | 11,390,955 |
|
|
1286
|
+
| **Arri** | 10,151,546 |
|
|
1287
|
+
| Ajv - JTD (Compiled) | 8,524,414 |
|
|
1288
|
+
|
|
1289
|
+
#### Int Serialization
|
|
1290
|
+
|
|
1291
|
+
| Library | op/s |
|
|
1292
|
+
| -------------------------------------------- | ----------- |
|
|
1293
|
+
| **Arri (Compiled)** | 199,750,275 |
|
|
1294
|
+
| **Arri (Compiled) - Validate and Serialize** | 190,585,727 |
|
|
1295
|
+
| Ajv - JTD (Compiled) | 188,008,270 |
|
|
1296
|
+
| Typia | 108,341,757 |
|
|
1297
|
+
| **Arri** | 62,210,662 |
|
|
1298
|
+
| Typia - Validate and Serialize | 45,562,047 |
|
|
1299
|
+
| JSON.stringify | 16,575,449 |
|
|
1300
|
+
|
|
1301
|
+
#### Int Coercion (Good Input)
|
|
1302
|
+
|
|
1303
|
+
| Library | op/s |
|
|
1304
|
+
| ----------------- | ---------- |
|
|
1305
|
+
| **Arri** | 51,421,819 |
|
|
1306
|
+
| TypeBox | 35,333,297 |
|
|
1307
|
+
| Ajv - JSON Schema | 21,583,903 |
|
|
1308
|
+
| Zod | 1,239,520 |
|
|
1309
|
+
|
|
1310
|
+
#### Int Coercion (Bad Input)
|
|
1311
|
+
|
|
1312
|
+
| Library | op/s |
|
|
1313
|
+
| ----------------- | ---------- |
|
|
1314
|
+
| **Arri** | 10,442,645 |
|
|
1315
|
+
| TypeBox | 7,919,097 |
|
|
1316
|
+
| Ajv - JSON Schema | 5,867,676 |
|
|
1317
|
+
| Zod | 737,348 |
|
|
1318
|
+
|
|
1319
|
+
<!-- BENCHMARK_END -->
|
|
1155
1320
|
|
|
1156
1321
|
## Development
|
|
1157
1322
|
|
package/dist/adapters.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { V as ValidationContext, A as ASchema } from './shared/schema.
|
|
2
|
+
import { V as ValidationContext, A as ASchema } from './shared/schema.hMebmI3A.cjs';
|
|
3
3
|
import '@arrirpc/type-defs';
|
|
4
4
|
|
|
5
5
|
declare function createStandardSchemaProperty<T>(validate: (input: unknown) => input is T, parse: (input: unknown, ctx: ValidationContext) => T | undefined, vendor?: string): StandardSchemaV1<T>['~standard'];
|
package/dist/adapters.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { V as ValidationContext, A as ASchema } from './shared/schema.
|
|
2
|
+
import { V as ValidationContext, A as ASchema } from './shared/schema.hMebmI3A.mjs';
|
|
3
3
|
import '@arrirpc/type-defs';
|
|
4
4
|
|
|
5
5
|
declare function createStandardSchemaProperty<T>(validate: (input: unknown) => input is T, parse: (input: unknown, ctx: ValidationContext) => T | undefined, vendor?: string): StandardSchemaV1<T>['~standard'];
|
package/dist/adapters.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { V as ValidationContext, A as ASchema } from './shared/schema.
|
|
2
|
+
import { V as ValidationContext, A as ASchema } from './shared/schema.hMebmI3A.js';
|
|
3
3
|
import '@arrirpc/type-defs';
|
|
4
4
|
|
|
5
5
|
declare function createStandardSchemaProperty<T>(validate: (input: unknown) => input is T, parse: (input: unknown, ctx: ValidationContext) => T | undefined, vendor?: string): StandardSchemaV1<T>['~standard'];
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from '@arrirpc/type-defs';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { A as ASchema, a as ASchemaStrict, I as InferType, R as Result, S as SchemaValidator, b as ASchemaOptions, c as ASchemaWithAdapters, d as AArraySchema, W as WithAdapters, e as AScalarSchemaWithAdapters, f as AObjectSchema, g as ADiscriminatorSchemaWithAdapters, h as ResolveObject, i as AStringEnumSchemaWithAdapters, j as AObjectSchemaWithAdapters, k as AObjectSchemaOptions, l as InferObjectOutput, V as ValidationContext, m as ARecordSchemaWithAdapters, n as ARefSchema, o as ValueError, p as InferSubType } from './shared/schema.
|
|
4
|
-
export { G as AArraySchemaWithAdapters, K as ADiscriminatorSchema, O as ARecordSchema, Z as ARefSchemaWithAdapters, C as AScalarSchema, H as AStringEnumSchema, U as InferObjectRawType, M as MaybeNullable, E as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, v as ResultFailure, u as ResultSuccess, y as SchemaMetadata, x as VALIDATOR_KEY, s as ValidationException, r as errorMessageFromErrors, F as isAAraySchema, L as isADiscriminatorSchema, T as isAObjectSchema, Q as isARecordSchema, Y as isARefSchema, D as isAScalarSchema, z as isASchema, J as isAStringEnumSchema, X as isObject, t as isValidationException, q as isValueError, w as newValidationContext } from './shared/schema.
|
|
3
|
+
import { A as ASchema, a as ASchemaStrict, I as InferType, R as Result, S as SchemaValidator, b as ASchemaOptions, c as ASchemaWithAdapters, d as AArraySchema, W as WithAdapters, e as AScalarSchemaWithAdapters, f as AObjectSchema, g as ADiscriminatorSchemaWithAdapters, h as ResolveObject, i as AStringEnumSchemaWithAdapters, j as AObjectSchemaWithAdapters, k as AObjectSchemaOptions, l as InferObjectOutput, V as ValidationContext, m as ARecordSchemaWithAdapters, n as ARefSchema, o as ValueError, p as InferSubType } from './shared/schema.hMebmI3A.cjs';
|
|
4
|
+
export { G as AArraySchemaWithAdapters, K as ADiscriminatorSchema, O as ARecordSchema, Z as ARefSchemaWithAdapters, C as AScalarSchema, H as AStringEnumSchema, U as InferObjectRawType, M as MaybeNullable, E as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, v as ResultFailure, u as ResultSuccess, y as SchemaMetadata, x as VALIDATOR_KEY, s as ValidationException, r as errorMessageFromErrors, F as isAAraySchema, L as isADiscriminatorSchema, T as isAObjectSchema, Q as isARecordSchema, Y as isARefSchema, D as isAScalarSchema, z as isASchema, J as isAStringEnumSchema, X as isObject, t as isValidationException, q as isValueError, w as newValidationContext } from './shared/schema.hMebmI3A.cjs';
|
|
5
5
|
|
|
6
6
|
declare function createParsingTemplate(input: string, schema: Schema, shouldCoerce?: boolean): string;
|
|
7
7
|
|
|
@@ -177,6 +177,23 @@ declare function nullable<T>(schema: ASchema<T>, opts?: ASchemaOptions): ASchema
|
|
|
177
177
|
declare function optional<T>(input: ASchema<T>, opts?: ASchemaOptions): ASchema<T | undefined>;
|
|
178
178
|
declare function clone<T>(input: ASchema<T>, opts?: ASchemaOptions): ASchemaWithAdapters<T>;
|
|
179
179
|
|
|
180
|
+
declare const int8Min = -128;
|
|
181
|
+
declare const int8Max = 127;
|
|
182
|
+
declare const uint8Min = 0;
|
|
183
|
+
declare const uint8Max = 255;
|
|
184
|
+
declare const int16Min = -32768;
|
|
185
|
+
declare const int16Max = 32767;
|
|
186
|
+
declare const uint16Min = 0;
|
|
187
|
+
declare const uint16Max = 65535;
|
|
188
|
+
declare const int32Min = -2147483648;
|
|
189
|
+
declare const int32Max = 2147483647;
|
|
190
|
+
declare const uint32Min = 0;
|
|
191
|
+
declare const uint32Max = 4294967295;
|
|
192
|
+
declare const int64Min: bigint;
|
|
193
|
+
declare const int64Max: bigint;
|
|
194
|
+
declare const uint64Min: bigint;
|
|
195
|
+
declare const uint64Max: bigint;
|
|
196
|
+
|
|
180
197
|
/**
|
|
181
198
|
* Alias for float64 as that is the only number type that Javascript uses
|
|
182
199
|
*
|
|
@@ -386,24 +403,49 @@ declare const _namespace_uint64: typeof uint64;
|
|
|
386
403
|
declare const _namespace_uint8: typeof uint8;
|
|
387
404
|
declare const _namespace_validate: typeof validate;
|
|
388
405
|
declare namespace _namespace {
|
|
389
|
-
export {
|
|
406
|
+
export {
|
|
407
|
+
_namespace_any as any,
|
|
408
|
+
_namespace_array as array,
|
|
409
|
+
_namespace_boolean as boolean,
|
|
410
|
+
_namespace_clone as clone,
|
|
411
|
+
_namespace_coerce as coerce,
|
|
412
|
+
_namespace_coerceUnsafe as coerceUnsafe,
|
|
413
|
+
_namespace_compile as compile,
|
|
414
|
+
_namespace_discriminator as discriminator,
|
|
415
|
+
_namespace_enumerator as enumerator,
|
|
416
|
+
_namespace_errors as errors,
|
|
417
|
+
_namespace_extend as extend,
|
|
418
|
+
_namespace_float32 as float32,
|
|
419
|
+
_namespace_float64 as float64,
|
|
420
|
+
InferType as infer,
|
|
421
|
+
InferSubType as inferSubType,
|
|
422
|
+
_namespace_int16 as int16,
|
|
423
|
+
_namespace_int32 as int32,
|
|
424
|
+
_namespace_int64 as int64,
|
|
425
|
+
_namespace_int8 as int8,
|
|
426
|
+
_namespace_nullable as nullable,
|
|
427
|
+
_namespace_number as number,
|
|
428
|
+
_namespace_object as object,
|
|
429
|
+
_namespace_omit as omit,
|
|
430
|
+
_namespace_optional as optional,
|
|
431
|
+
_namespace_parse as parse,
|
|
432
|
+
_namespace_parseUnsafe as parseUnsafe,
|
|
433
|
+
_namespace_partial as partial,
|
|
434
|
+
_namespace_pick as pick,
|
|
435
|
+
_namespace_record as record,
|
|
436
|
+
_namespace_recursive as recursive,
|
|
437
|
+
_namespace_serialize as serialize,
|
|
438
|
+
_namespace_serializeUnsafe as serializeUnsafe,
|
|
439
|
+
_namespace_string as string,
|
|
440
|
+
_namespace_stringEnum as stringEnum,
|
|
441
|
+
_namespace_timestamp as timestamp,
|
|
442
|
+
_namespace_uint16 as uint16,
|
|
443
|
+
_namespace_uint32 as uint32,
|
|
444
|
+
_namespace_uint64 as uint64,
|
|
445
|
+
_namespace_uint8 as uint8,
|
|
446
|
+
_namespace_validate as validate,
|
|
447
|
+
};
|
|
390
448
|
}
|
|
391
449
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
declare const uint8Min = 0;
|
|
395
|
-
declare const uint8Max = 255;
|
|
396
|
-
declare const int16Min = -32768;
|
|
397
|
-
declare const int16Max = 32767;
|
|
398
|
-
declare const uint16Min = 0;
|
|
399
|
-
declare const uint16Max = 65535;
|
|
400
|
-
declare const int32Min = -2147483648;
|
|
401
|
-
declare const int32Max = 2147483647;
|
|
402
|
-
declare const uint32Min = 0;
|
|
403
|
-
declare const uint32Max = 4294967295;
|
|
404
|
-
declare const int64Min: bigint;
|
|
405
|
-
declare const int64Max: bigint;
|
|
406
|
-
declare const uint64Min: bigint;
|
|
407
|
-
declare const uint64Max: bigint;
|
|
408
|
-
|
|
409
|
-
export { AArraySchema, ADiscriminatorSchemaWithAdapters, AObjectSchema, AObjectSchemaOptions, AObjectSchemaWithAdapters, ARecordSchemaWithAdapters, ARefSchema, AScalarSchemaWithAdapters, ASchema, ASchemaOptions, ASchemaStrict, ASchemaWithAdapters, AStringEnumSchemaWithAdapters, type CompiledValidator, type CompiledValidatorCompiledCode, InferObjectOutput, InferSubType, InferType, ResolveObject, Result, STR_ESCAPE, SchemaValidator, ValidationContext, ValueError, WithAdapters, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
|
|
450
|
+
export { AArraySchema, ADiscriminatorSchemaWithAdapters, AObjectSchema, AObjectSchemaOptions, AObjectSchemaWithAdapters, ARecordSchemaWithAdapters, ARefSchema, AScalarSchemaWithAdapters, ASchema, ASchemaOptions, ASchemaStrict, ASchemaWithAdapters, AStringEnumSchemaWithAdapters, InferObjectOutput, InferSubType, InferType, ResolveObject, Result, STR_ESCAPE, SchemaValidator, ValidationContext, ValueError, WithAdapters, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
|
|
451
|
+
export type { CompiledValidator, CompiledValidatorCompiledCode };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from '@arrirpc/type-defs';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { A as ASchema, a as ASchemaStrict, I as InferType, R as Result, S as SchemaValidator, b as ASchemaOptions, c as ASchemaWithAdapters, d as AArraySchema, W as WithAdapters, e as AScalarSchemaWithAdapters, f as AObjectSchema, g as ADiscriminatorSchemaWithAdapters, h as ResolveObject, i as AStringEnumSchemaWithAdapters, j as AObjectSchemaWithAdapters, k as AObjectSchemaOptions, l as InferObjectOutput, V as ValidationContext, m as ARecordSchemaWithAdapters, n as ARefSchema, o as ValueError, p as InferSubType } from './shared/schema.
|
|
4
|
-
export { G as AArraySchemaWithAdapters, K as ADiscriminatorSchema, O as ARecordSchema, Z as ARefSchemaWithAdapters, C as AScalarSchema, H as AStringEnumSchema, U as InferObjectRawType, M as MaybeNullable, E as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, v as ResultFailure, u as ResultSuccess, y as SchemaMetadata, x as VALIDATOR_KEY, s as ValidationException, r as errorMessageFromErrors, F as isAAraySchema, L as isADiscriminatorSchema, T as isAObjectSchema, Q as isARecordSchema, Y as isARefSchema, D as isAScalarSchema, z as isASchema, J as isAStringEnumSchema, X as isObject, t as isValidationException, q as isValueError, w as newValidationContext } from './shared/schema.
|
|
3
|
+
import { A as ASchema, a as ASchemaStrict, I as InferType, R as Result, S as SchemaValidator, b as ASchemaOptions, c as ASchemaWithAdapters, d as AArraySchema, W as WithAdapters, e as AScalarSchemaWithAdapters, f as AObjectSchema, g as ADiscriminatorSchemaWithAdapters, h as ResolveObject, i as AStringEnumSchemaWithAdapters, j as AObjectSchemaWithAdapters, k as AObjectSchemaOptions, l as InferObjectOutput, V as ValidationContext, m as ARecordSchemaWithAdapters, n as ARefSchema, o as ValueError, p as InferSubType } from './shared/schema.hMebmI3A.mjs';
|
|
4
|
+
export { G as AArraySchemaWithAdapters, K as ADiscriminatorSchema, O as ARecordSchema, Z as ARefSchemaWithAdapters, C as AScalarSchema, H as AStringEnumSchema, U as InferObjectRawType, M as MaybeNullable, E as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, v as ResultFailure, u as ResultSuccess, y as SchemaMetadata, x as VALIDATOR_KEY, s as ValidationException, r as errorMessageFromErrors, F as isAAraySchema, L as isADiscriminatorSchema, T as isAObjectSchema, Q as isARecordSchema, Y as isARefSchema, D as isAScalarSchema, z as isASchema, J as isAStringEnumSchema, X as isObject, t as isValidationException, q as isValueError, w as newValidationContext } from './shared/schema.hMebmI3A.mjs';
|
|
5
5
|
|
|
6
6
|
declare function createParsingTemplate(input: string, schema: Schema, shouldCoerce?: boolean): string;
|
|
7
7
|
|
|
@@ -177,6 +177,23 @@ declare function nullable<T>(schema: ASchema<T>, opts?: ASchemaOptions): ASchema
|
|
|
177
177
|
declare function optional<T>(input: ASchema<T>, opts?: ASchemaOptions): ASchema<T | undefined>;
|
|
178
178
|
declare function clone<T>(input: ASchema<T>, opts?: ASchemaOptions): ASchemaWithAdapters<T>;
|
|
179
179
|
|
|
180
|
+
declare const int8Min = -128;
|
|
181
|
+
declare const int8Max = 127;
|
|
182
|
+
declare const uint8Min = 0;
|
|
183
|
+
declare const uint8Max = 255;
|
|
184
|
+
declare const int16Min = -32768;
|
|
185
|
+
declare const int16Max = 32767;
|
|
186
|
+
declare const uint16Min = 0;
|
|
187
|
+
declare const uint16Max = 65535;
|
|
188
|
+
declare const int32Min = -2147483648;
|
|
189
|
+
declare const int32Max = 2147483647;
|
|
190
|
+
declare const uint32Min = 0;
|
|
191
|
+
declare const uint32Max = 4294967295;
|
|
192
|
+
declare const int64Min: bigint;
|
|
193
|
+
declare const int64Max: bigint;
|
|
194
|
+
declare const uint64Min: bigint;
|
|
195
|
+
declare const uint64Max: bigint;
|
|
196
|
+
|
|
180
197
|
/**
|
|
181
198
|
* Alias for float64 as that is the only number type that Javascript uses
|
|
182
199
|
*
|
|
@@ -386,24 +403,49 @@ declare const _namespace_uint64: typeof uint64;
|
|
|
386
403
|
declare const _namespace_uint8: typeof uint8;
|
|
387
404
|
declare const _namespace_validate: typeof validate;
|
|
388
405
|
declare namespace _namespace {
|
|
389
|
-
export {
|
|
406
|
+
export {
|
|
407
|
+
_namespace_any as any,
|
|
408
|
+
_namespace_array as array,
|
|
409
|
+
_namespace_boolean as boolean,
|
|
410
|
+
_namespace_clone as clone,
|
|
411
|
+
_namespace_coerce as coerce,
|
|
412
|
+
_namespace_coerceUnsafe as coerceUnsafe,
|
|
413
|
+
_namespace_compile as compile,
|
|
414
|
+
_namespace_discriminator as discriminator,
|
|
415
|
+
_namespace_enumerator as enumerator,
|
|
416
|
+
_namespace_errors as errors,
|
|
417
|
+
_namespace_extend as extend,
|
|
418
|
+
_namespace_float32 as float32,
|
|
419
|
+
_namespace_float64 as float64,
|
|
420
|
+
InferType as infer,
|
|
421
|
+
InferSubType as inferSubType,
|
|
422
|
+
_namespace_int16 as int16,
|
|
423
|
+
_namespace_int32 as int32,
|
|
424
|
+
_namespace_int64 as int64,
|
|
425
|
+
_namespace_int8 as int8,
|
|
426
|
+
_namespace_nullable as nullable,
|
|
427
|
+
_namespace_number as number,
|
|
428
|
+
_namespace_object as object,
|
|
429
|
+
_namespace_omit as omit,
|
|
430
|
+
_namespace_optional as optional,
|
|
431
|
+
_namespace_parse as parse,
|
|
432
|
+
_namespace_parseUnsafe as parseUnsafe,
|
|
433
|
+
_namespace_partial as partial,
|
|
434
|
+
_namespace_pick as pick,
|
|
435
|
+
_namespace_record as record,
|
|
436
|
+
_namespace_recursive as recursive,
|
|
437
|
+
_namespace_serialize as serialize,
|
|
438
|
+
_namespace_serializeUnsafe as serializeUnsafe,
|
|
439
|
+
_namespace_string as string,
|
|
440
|
+
_namespace_stringEnum as stringEnum,
|
|
441
|
+
_namespace_timestamp as timestamp,
|
|
442
|
+
_namespace_uint16 as uint16,
|
|
443
|
+
_namespace_uint32 as uint32,
|
|
444
|
+
_namespace_uint64 as uint64,
|
|
445
|
+
_namespace_uint8 as uint8,
|
|
446
|
+
_namespace_validate as validate,
|
|
447
|
+
};
|
|
390
448
|
}
|
|
391
449
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
declare const uint8Min = 0;
|
|
395
|
-
declare const uint8Max = 255;
|
|
396
|
-
declare const int16Min = -32768;
|
|
397
|
-
declare const int16Max = 32767;
|
|
398
|
-
declare const uint16Min = 0;
|
|
399
|
-
declare const uint16Max = 65535;
|
|
400
|
-
declare const int32Min = -2147483648;
|
|
401
|
-
declare const int32Max = 2147483647;
|
|
402
|
-
declare const uint32Min = 0;
|
|
403
|
-
declare const uint32Max = 4294967295;
|
|
404
|
-
declare const int64Min: bigint;
|
|
405
|
-
declare const int64Max: bigint;
|
|
406
|
-
declare const uint64Min: bigint;
|
|
407
|
-
declare const uint64Max: bigint;
|
|
408
|
-
|
|
409
|
-
export { AArraySchema, ADiscriminatorSchemaWithAdapters, AObjectSchema, AObjectSchemaOptions, AObjectSchemaWithAdapters, ARecordSchemaWithAdapters, ARefSchema, AScalarSchemaWithAdapters, ASchema, ASchemaOptions, ASchemaStrict, ASchemaWithAdapters, AStringEnumSchemaWithAdapters, type CompiledValidator, type CompiledValidatorCompiledCode, InferObjectOutput, InferSubType, InferType, ResolveObject, Result, STR_ESCAPE, SchemaValidator, ValidationContext, ValueError, WithAdapters, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
|
|
450
|
+
export { AArraySchema, ADiscriminatorSchemaWithAdapters, AObjectSchema, AObjectSchemaOptions, AObjectSchemaWithAdapters, ARecordSchemaWithAdapters, ARefSchema, AScalarSchemaWithAdapters, ASchema, ASchemaOptions, ASchemaStrict, ASchemaWithAdapters, AStringEnumSchemaWithAdapters, InferObjectOutput, InferSubType, InferType, ResolveObject, Result, STR_ESCAPE, SchemaValidator, ValidationContext, ValueError, WithAdapters, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
|
|
451
|
+
export type { CompiledValidator, CompiledValidatorCompiledCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from '@arrirpc/type-defs';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { A as ASchema, a as ASchemaStrict, I as InferType, R as Result, S as SchemaValidator, b as ASchemaOptions, c as ASchemaWithAdapters, d as AArraySchema, W as WithAdapters, e as AScalarSchemaWithAdapters, f as AObjectSchema, g as ADiscriminatorSchemaWithAdapters, h as ResolveObject, i as AStringEnumSchemaWithAdapters, j as AObjectSchemaWithAdapters, k as AObjectSchemaOptions, l as InferObjectOutput, V as ValidationContext, m as ARecordSchemaWithAdapters, n as ARefSchema, o as ValueError, p as InferSubType } from './shared/schema.
|
|
4
|
-
export { G as AArraySchemaWithAdapters, K as ADiscriminatorSchema, O as ARecordSchema, Z as ARefSchemaWithAdapters, C as AScalarSchema, H as AStringEnumSchema, U as InferObjectRawType, M as MaybeNullable, E as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, v as ResultFailure, u as ResultSuccess, y as SchemaMetadata, x as VALIDATOR_KEY, s as ValidationException, r as errorMessageFromErrors, F as isAAraySchema, L as isADiscriminatorSchema, T as isAObjectSchema, Q as isARecordSchema, Y as isARefSchema, D as isAScalarSchema, z as isASchema, J as isAStringEnumSchema, X as isObject, t as isValidationException, q as isValueError, w as newValidationContext } from './shared/schema.
|
|
3
|
+
import { A as ASchema, a as ASchemaStrict, I as InferType, R as Result, S as SchemaValidator, b as ASchemaOptions, c as ASchemaWithAdapters, d as AArraySchema, W as WithAdapters, e as AScalarSchemaWithAdapters, f as AObjectSchema, g as ADiscriminatorSchemaWithAdapters, h as ResolveObject, i as AStringEnumSchemaWithAdapters, j as AObjectSchemaWithAdapters, k as AObjectSchemaOptions, l as InferObjectOutput, V as ValidationContext, m as ARecordSchemaWithAdapters, n as ARefSchema, o as ValueError, p as InferSubType } from './shared/schema.hMebmI3A.js';
|
|
4
|
+
export { G as AArraySchemaWithAdapters, K as ADiscriminatorSchema, O as ARecordSchema, Z as ARefSchemaWithAdapters, C as AScalarSchema, H as AStringEnumSchema, U as InferObjectRawType, M as MaybeNullable, E as NumberType, N as NumberTypeValues, P as PartialBy, B as Resolve, v as ResultFailure, u as ResultSuccess, y as SchemaMetadata, x as VALIDATOR_KEY, s as ValidationException, r as errorMessageFromErrors, F as isAAraySchema, L as isADiscriminatorSchema, T as isAObjectSchema, Q as isARecordSchema, Y as isARefSchema, D as isAScalarSchema, z as isASchema, J as isAStringEnumSchema, X as isObject, t as isValidationException, q as isValueError, w as newValidationContext } from './shared/schema.hMebmI3A.js';
|
|
5
5
|
|
|
6
6
|
declare function createParsingTemplate(input: string, schema: Schema, shouldCoerce?: boolean): string;
|
|
7
7
|
|
|
@@ -177,6 +177,23 @@ declare function nullable<T>(schema: ASchema<T>, opts?: ASchemaOptions): ASchema
|
|
|
177
177
|
declare function optional<T>(input: ASchema<T>, opts?: ASchemaOptions): ASchema<T | undefined>;
|
|
178
178
|
declare function clone<T>(input: ASchema<T>, opts?: ASchemaOptions): ASchemaWithAdapters<T>;
|
|
179
179
|
|
|
180
|
+
declare const int8Min = -128;
|
|
181
|
+
declare const int8Max = 127;
|
|
182
|
+
declare const uint8Min = 0;
|
|
183
|
+
declare const uint8Max = 255;
|
|
184
|
+
declare const int16Min = -32768;
|
|
185
|
+
declare const int16Max = 32767;
|
|
186
|
+
declare const uint16Min = 0;
|
|
187
|
+
declare const uint16Max = 65535;
|
|
188
|
+
declare const int32Min = -2147483648;
|
|
189
|
+
declare const int32Max = 2147483647;
|
|
190
|
+
declare const uint32Min = 0;
|
|
191
|
+
declare const uint32Max = 4294967295;
|
|
192
|
+
declare const int64Min: bigint;
|
|
193
|
+
declare const int64Max: bigint;
|
|
194
|
+
declare const uint64Min: bigint;
|
|
195
|
+
declare const uint64Max: bigint;
|
|
196
|
+
|
|
180
197
|
/**
|
|
181
198
|
* Alias for float64 as that is the only number type that Javascript uses
|
|
182
199
|
*
|
|
@@ -386,24 +403,49 @@ declare const _namespace_uint64: typeof uint64;
|
|
|
386
403
|
declare const _namespace_uint8: typeof uint8;
|
|
387
404
|
declare const _namespace_validate: typeof validate;
|
|
388
405
|
declare namespace _namespace {
|
|
389
|
-
export {
|
|
406
|
+
export {
|
|
407
|
+
_namespace_any as any,
|
|
408
|
+
_namespace_array as array,
|
|
409
|
+
_namespace_boolean as boolean,
|
|
410
|
+
_namespace_clone as clone,
|
|
411
|
+
_namespace_coerce as coerce,
|
|
412
|
+
_namespace_coerceUnsafe as coerceUnsafe,
|
|
413
|
+
_namespace_compile as compile,
|
|
414
|
+
_namespace_discriminator as discriminator,
|
|
415
|
+
_namespace_enumerator as enumerator,
|
|
416
|
+
_namespace_errors as errors,
|
|
417
|
+
_namespace_extend as extend,
|
|
418
|
+
_namespace_float32 as float32,
|
|
419
|
+
_namespace_float64 as float64,
|
|
420
|
+
InferType as infer,
|
|
421
|
+
InferSubType as inferSubType,
|
|
422
|
+
_namespace_int16 as int16,
|
|
423
|
+
_namespace_int32 as int32,
|
|
424
|
+
_namespace_int64 as int64,
|
|
425
|
+
_namespace_int8 as int8,
|
|
426
|
+
_namespace_nullable as nullable,
|
|
427
|
+
_namespace_number as number,
|
|
428
|
+
_namespace_object as object,
|
|
429
|
+
_namespace_omit as omit,
|
|
430
|
+
_namespace_optional as optional,
|
|
431
|
+
_namespace_parse as parse,
|
|
432
|
+
_namespace_parseUnsafe as parseUnsafe,
|
|
433
|
+
_namespace_partial as partial,
|
|
434
|
+
_namespace_pick as pick,
|
|
435
|
+
_namespace_record as record,
|
|
436
|
+
_namespace_recursive as recursive,
|
|
437
|
+
_namespace_serialize as serialize,
|
|
438
|
+
_namespace_serializeUnsafe as serializeUnsafe,
|
|
439
|
+
_namespace_string as string,
|
|
440
|
+
_namespace_stringEnum as stringEnum,
|
|
441
|
+
_namespace_timestamp as timestamp,
|
|
442
|
+
_namespace_uint16 as uint16,
|
|
443
|
+
_namespace_uint32 as uint32,
|
|
444
|
+
_namespace_uint64 as uint64,
|
|
445
|
+
_namespace_uint8 as uint8,
|
|
446
|
+
_namespace_validate as validate,
|
|
447
|
+
};
|
|
390
448
|
}
|
|
391
449
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
declare const uint8Min = 0;
|
|
395
|
-
declare const uint8Max = 255;
|
|
396
|
-
declare const int16Min = -32768;
|
|
397
|
-
declare const int16Max = 32767;
|
|
398
|
-
declare const uint16Min = 0;
|
|
399
|
-
declare const uint16Max = 65535;
|
|
400
|
-
declare const int32Min = -2147483648;
|
|
401
|
-
declare const int32Max = 2147483647;
|
|
402
|
-
declare const uint32Min = 0;
|
|
403
|
-
declare const uint32Max = 4294967295;
|
|
404
|
-
declare const int64Min: bigint;
|
|
405
|
-
declare const int64Max: bigint;
|
|
406
|
-
declare const uint64Min: bigint;
|
|
407
|
-
declare const uint64Max: bigint;
|
|
408
|
-
|
|
409
|
-
export { AArraySchema, ADiscriminatorSchemaWithAdapters, AObjectSchema, AObjectSchemaOptions, AObjectSchemaWithAdapters, ARecordSchemaWithAdapters, ARefSchema, AScalarSchemaWithAdapters, ASchema, ASchemaOptions, ASchemaStrict, ASchemaWithAdapters, AStringEnumSchemaWithAdapters, type CompiledValidator, type CompiledValidatorCompiledCode, InferObjectOutput, InferSubType, InferType, ResolveObject, Result, STR_ESCAPE, SchemaValidator, ValidationContext, ValueError, WithAdapters, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
|
|
450
|
+
export { AArraySchema, ADiscriminatorSchemaWithAdapters, AObjectSchema, AObjectSchemaOptions, AObjectSchemaWithAdapters, ARecordSchemaWithAdapters, ARefSchema, AScalarSchemaWithAdapters, ASchema, ASchemaOptions, ASchemaStrict, ASchemaWithAdapters, AStringEnumSchemaWithAdapters, InferObjectOutput, InferSubType, InferType, ResolveObject, Result, STR_ESCAPE, SchemaValidator, ValidationContext, ValueError, WithAdapters, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
|
|
451
|
+
export type { CompiledValidator, CompiledValidatorCompiledCode };
|
|
@@ -169,4 +169,5 @@ interface ARefSchema<T> extends ASchema<T> {
|
|
|
169
169
|
declare function isARefSchema(input: unknown): input is ARefSchema<any>;
|
|
170
170
|
type ARefSchemaWithAdapters<T> = ARefSchema<T> & WithAdapters<T>;
|
|
171
171
|
|
|
172
|
-
export {
|
|
172
|
+
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T, isObject as X, isARefSchema as Y, isValueError as q, errorMessageFromErrors as r, ValidationException as s, isValidationException as t, newValidationContext as w, VALIDATOR_KEY as x, isASchema as z };
|
|
173
|
+
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S, InferObjectRawType as U, ValidationContext as V, WithAdapters as W, ARefSchemaWithAdapters as Z, ASchemaStrict as a, ASchemaOptions as b, ASchemaWithAdapters as c, AArraySchema as d, AScalarSchemaWithAdapters as e, AObjectSchema as f, ADiscriminatorSchemaWithAdapters as g, ResolveObject as h, AStringEnumSchemaWithAdapters as i, AObjectSchemaWithAdapters as j, AObjectSchemaOptions as k, InferObjectOutput as l, ARecordSchemaWithAdapters as m, ARefSchema as n, ValueError as o, InferSubType as p, ResultSuccess as u, ResultFailure as v, SchemaMetadata as y };
|
|
@@ -169,4 +169,5 @@ interface ARefSchema<T> extends ASchema<T> {
|
|
|
169
169
|
declare function isARefSchema(input: unknown): input is ARefSchema<any>;
|
|
170
170
|
type ARefSchemaWithAdapters<T> = ARefSchema<T> & WithAdapters<T>;
|
|
171
171
|
|
|
172
|
-
export {
|
|
172
|
+
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T, isObject as X, isARefSchema as Y, isValueError as q, errorMessageFromErrors as r, ValidationException as s, isValidationException as t, newValidationContext as w, VALIDATOR_KEY as x, isASchema as z };
|
|
173
|
+
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S, InferObjectRawType as U, ValidationContext as V, WithAdapters as W, ARefSchemaWithAdapters as Z, ASchemaStrict as a, ASchemaOptions as b, ASchemaWithAdapters as c, AArraySchema as d, AScalarSchemaWithAdapters as e, AObjectSchema as f, ADiscriminatorSchemaWithAdapters as g, ResolveObject as h, AStringEnumSchemaWithAdapters as i, AObjectSchemaWithAdapters as j, AObjectSchemaOptions as k, InferObjectOutput as l, ARecordSchemaWithAdapters as m, ARefSchema as n, ValueError as o, InferSubType as p, ResultSuccess as u, ResultFailure as v, SchemaMetadata as y };
|
|
@@ -169,4 +169,5 @@ interface ARefSchema<T> extends ASchema<T> {
|
|
|
169
169
|
declare function isARefSchema(input: unknown): input is ARefSchema<any>;
|
|
170
170
|
type ARefSchemaWithAdapters<T> = ARefSchema<T> & WithAdapters<T>;
|
|
171
171
|
|
|
172
|
-
export {
|
|
172
|
+
export { isAScalarSchema as D, isAAraySchema as F, isAStringEnumSchema as J, isADiscriminatorSchema as L, NumberTypeValues as N, isARecordSchema as Q, isAObjectSchema as T, isObject as X, isARefSchema as Y, isValueError as q, errorMessageFromErrors as r, ValidationException as s, isValidationException as t, newValidationContext as w, VALIDATOR_KEY as x, isASchema as z };
|
|
173
|
+
export type { ASchema as A, Resolve as B, AScalarSchema as C, NumberType as E, AArraySchemaWithAdapters as G, AStringEnumSchema as H, InferType as I, ADiscriminatorSchema as K, MaybeNullable as M, ARecordSchema as O, PartialBy as P, Result as R, SchemaValidator as S, InferObjectRawType as U, ValidationContext as V, WithAdapters as W, ARefSchemaWithAdapters as Z, ASchemaStrict as a, ASchemaOptions as b, ASchemaWithAdapters as c, AArraySchema as d, AScalarSchemaWithAdapters as e, AObjectSchema as f, ADiscriminatorSchemaWithAdapters as g, ResolveObject as h, AStringEnumSchemaWithAdapters as i, AObjectSchemaWithAdapters as j, AObjectSchemaOptions as k, InferObjectOutput as l, ARecordSchemaWithAdapters as m, ARefSchema as n, ValueError as o, InferSubType as p, ResultSuccess as u, ResultFailure as v, SchemaMetadata as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,10 +25,16 @@
|
|
|
25
25
|
"@standard-schema/spec": "1.0.0",
|
|
26
26
|
"scule": "^1.3.0",
|
|
27
27
|
"uncrypto": "^0.1.3",
|
|
28
|
-
"@arrirpc/type-defs": "0.
|
|
28
|
+
"@arrirpc/type-defs": "0.77.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"@ryoppippi/unplugin-typia": "^2.1.3",
|
|
32
|
+
"@sinclair/typebox": "^0.34.31",
|
|
31
33
|
"ajv": "^8.17.1",
|
|
32
|
-
"
|
|
34
|
+
"arktype": "^2.1.12",
|
|
35
|
+
"benny": "^3.7.1",
|
|
36
|
+
"typia": "^8.0.3",
|
|
37
|
+
"valibot": "1.0.0",
|
|
38
|
+
"zod": "^3.24.2"
|
|
33
39
|
}
|
|
34
40
|
}
|