@xylabs/zod 7.0.6 → 8.0.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.
Files changed (2) hide show
  1. package/README.md +1 -371
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,373 +1,3 @@
1
- > **Deprecated.** Use [`@ariestools/sdk`](../../ariestools-sdk/README.md) instead. This package is a backward-compatibility re-export shim.
2
-
3
- [![logo][]](https://xylabs.com)
4
-
5
1
  # @xylabs/zod
6
2
 
7
- [![npm][npm-badge]][npm-link]
8
- [![license][license-badge]][license-link]
9
-
10
- > Base functionality used throughout XY Labs TypeScript/JavaScript libraries
11
-
12
- ## Install
13
-
14
- Using npm:
15
-
16
- ```sh
17
- npm install @xylabs/zod
18
- ```
19
-
20
- Using yarn:
21
-
22
- ```sh
23
- yarn add @xylabs/zod
24
- ```
25
-
26
- Using pnpm:
27
-
28
- ```sh
29
- pnpm add @xylabs/zod
30
- ```
31
-
32
- Using bun:
33
-
34
- ```sh
35
- bun add @xylabs/zod
36
- ```
37
-
38
-
39
- ## License
40
-
41
- See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
42
-
43
- ## Reference
44
-
45
- ### packages
46
-
47
- ### zod
48
-
49
- ### .temp-typedoc
50
-
51
- ### functions
52
-
53
- ### <a id="zodAllFactory"></a>zodAllFactory
54
-
55
- [**@xylabs/zod**](#../README)
56
-
57
- ***
58
-
59
- ```ts
60
- function zodAllFactory<T, TName>(zod, name): object;
61
- ```
62
-
63
- **`Alpha`**
64
-
65
- Creates a bundle of `is`, `as`, and `to` factory functions for a given zod schema.
66
-
67
- ## Type Parameters
68
-
69
- ### T
70
-
71
- `T`
72
-
73
- ### TName
74
-
75
- `TName` *extends* `string`
76
-
77
- ## Parameters
78
-
79
- ### zod
80
-
81
- `ZodType`\<`T`\>
82
-
83
- The zod schema to validate against
84
-
85
- ### name
86
-
87
- `TName`
88
-
89
- The name used to suffix the generated function names (e.g. 'Address' produces `isAddress`, `asAddress`, `toAddress`)
90
-
91
- ## Returns
92
-
93
- `object`
94
-
95
- An object containing `is<Name>`, `as<Name>`, and `to<Name>` functions
96
-
97
- ### <a id="zodAsAsyncFactory"></a>zodAsAsyncFactory
98
-
99
- [**@xylabs/zod**](#../README)
100
-
101
- ***
102
-
103
- ```ts
104
- function zodAsAsyncFactory<TZod>(zod, name): {
105
- <T> (value): Promise<T & TZod | undefined>;
106
- <T> (value, assert): Promise<T & TZod>;
107
- };
108
- ```
109
-
110
- Creates an async function that validates a value against a zod schema and returns it with a narrowed type.
111
- Uses `safeParseAsync` for schemas with async refinements. When called without an assert config, returns undefined on failure.
112
-
113
- ## Type Parameters
114
-
115
- ### TZod
116
-
117
- `TZod`
118
-
119
- ## Parameters
120
-
121
- ### zod
122
-
123
- `ZodType`\<`TZod`\>
124
-
125
- The zod schema to validate against
126
-
127
- ### name
128
-
129
- `string`
130
-
131
- A name used in error messages for identification
132
-
133
- ## Returns
134
-
135
- An async function that validates and narrows the type of a value
136
-
137
- \{
138
- \<`T`\> (`value`): `Promise`\<`T` & `TZod` \| `undefined`\>;
139
- \<`T`\> (`value`, `assert`): `Promise`\<`T` & `TZod`\>;
140
- \}
141
-
142
- ### <a id="zodAsFactory"></a>zodAsFactory
143
-
144
- [**@xylabs/zod**](#../README)
145
-
146
- ***
147
-
148
- ```ts
149
- function zodAsFactory<TZod>(zod, name): {
150
- <T> (value): T & TZod | undefined;
151
- <T> (value, assert): T & TZod;
152
- };
153
- ```
154
-
155
- Creates a function that validates a value against a zod schema and returns it with a narrowed type.
156
- When called without an assert config, returns undefined on failure. When called with an assert config, throws on failure.
157
-
158
- ## Type Parameters
159
-
160
- ### TZod
161
-
162
- `TZod`
163
-
164
- ## Parameters
165
-
166
- ### zod
167
-
168
- `ZodType`\<`TZod`\>
169
-
170
- The zod schema to validate against
171
-
172
- ### name
173
-
174
- `string`
175
-
176
- A name used in error messages for identification
177
-
178
- ## Returns
179
-
180
- A function that validates and narrows the type of a value
181
-
182
- \{
183
- \<`T`\> (`value`): `T` & `TZod` \| `undefined`;
184
- \<`T`\> (`value`, `assert`): `T` & `TZod`;
185
- \}
186
-
187
- ### <a id="zodIsFactory"></a>zodIsFactory
188
-
189
- [**@xylabs/zod**](#../README)
190
-
191
- ***
192
-
193
- ```ts
194
- function zodIsFactory<TZod>(zod): <T>(value) => value is T & TZod;
195
- ```
196
-
197
- Creates a type guard function that checks if a value matches a zod schema.
198
-
199
- ## Type Parameters
200
-
201
- ### TZod
202
-
203
- `TZod`
204
-
205
- ## Parameters
206
-
207
- ### zod
208
-
209
- `ZodType`\<`TZod`\>
210
-
211
- The zod schema to validate against
212
-
213
- ## Returns
214
-
215
- A type guard function that returns true if the value passes validation
216
-
217
- \<`T`\>(`value`) => `value is T & TZod`
218
-
219
- ### <a id="zodToAsyncFactory"></a>zodToAsyncFactory
220
-
221
- [**@xylabs/zod**](#../README)
222
-
223
- ***
224
-
225
- ```ts
226
- function zodToAsyncFactory<TZod>(zod, name): {
227
- <T> (value): Promise<T & TZod | undefined>;
228
- <T> (value, assert): Promise<T & TZod>;
229
- };
230
- ```
231
-
232
- Creates an async function that converts a value to the zod schema type, delegating to `zodAsAsyncFactory` internally.
233
- Provides overloads for optional assertion: without assert config resolves to undefined on failure, with assert config throws on failure.
234
-
235
- ## Type Parameters
236
-
237
- ### TZod
238
-
239
- `TZod`
240
-
241
- ## Parameters
242
-
243
- ### zod
244
-
245
- `ZodType`\<`TZod`\>
246
-
247
- The zod schema to validate against
248
-
249
- ### name
250
-
251
- `string`
252
-
253
- A name used in error messages for identification
254
-
255
- ## Returns
256
-
257
- An async function that validates and converts a value to the schema type
258
-
259
- \{
260
- \<`T`\> (`value`): `Promise`\<`T` & `TZod` \| `undefined`\>;
261
- \<`T`\> (`value`, `assert`): `Promise`\<`T` & `TZod`\>;
262
- \}
263
-
264
- ### <a id="zodToFactory"></a>zodToFactory
265
-
266
- [**@xylabs/zod**](#../README)
267
-
268
- ***
269
-
270
- ```ts
271
- function zodToFactory<TZod>(zod, name): {
272
- <T> (value): T & TZod | undefined;
273
- <T> (value, assert): T & TZod;
274
- };
275
- ```
276
-
277
- Creates a function that converts a value to the zod schema type, delegating to `zodAsFactory` internally.
278
- Provides overloads for optional assertion: without assert config returns undefined on failure, with assert config throws on failure.
279
-
280
- ## Type Parameters
281
-
282
- ### TZod
283
-
284
- `TZod`
285
-
286
- ## Parameters
287
-
288
- ### zod
289
-
290
- `ZodType`\<`TZod`\>
291
-
292
- The zod schema to validate against
293
-
294
- ### name
295
-
296
- `string`
297
-
298
- A name used in error messages for identification
299
-
300
- ## Returns
301
-
302
- A function that validates and converts a value to the schema type
303
-
304
- \{
305
- \<`T`\> (`value`): `T` & `TZod` \| `undefined`;
306
- \<`T`\> (`value`, `assert`): `T` & `TZod`;
307
- \}
308
-
309
- ### interfaces
310
-
311
- ### <a id="ZodFactoryConfigObject"></a>ZodFactoryConfigObject
312
-
313
- [**@xylabs/zod**](#../README)
314
-
315
- ***
316
-
317
- Configuration object for zod factory functions, providing a name for error messages.
318
-
319
- ## Properties
320
-
321
- ### name
322
-
323
- ```ts
324
- name: string;
325
- ```
326
-
327
- ### type-aliases
328
-
329
- ### <a id="AllZodFactories"></a>AllZodFactories
330
-
331
- [**@xylabs/zod**](#../README)
332
-
333
- ***
334
-
335
- ```ts
336
- type AllZodFactories<TType, TName> = Record<`is${TName}`, ReturnType<typeof zodIsFactory>> & Record<`as${TName}`, ReturnType<typeof zodAsFactory>> & Record<`to${TName}`, ReturnType<typeof zodToFactory>>;
337
- ```
338
-
339
- **`Alpha`**
340
-
341
- ## Type Parameters
342
-
343
- ### TType
344
-
345
- `TType`
346
-
347
- ### TName
348
-
349
- `TName` *extends* `string`
350
-
351
- ### <a id="ZodFactoryConfig"></a>ZodFactoryConfig
352
-
353
- [**@xylabs/zod**](#../README)
354
-
355
- ***
356
-
357
- ```ts
358
- type ZodFactoryConfig =
359
- | AssertConfig
360
- | ZodFactoryConfigObject;
361
- ```
362
-
363
- Configuration for zod factory assertion behavior, either an AssertConfig or a named config object.
364
-
365
- ## Credits
366
-
367
- [Made with 🔥 and ❄️ by XY Labs](https://xylabs.com)
368
-
369
- [npm-badge]: https://img.shields.io/npm/v/@xylabs/zod.svg
370
- [npm-link]: https://www.npmjs.com/package/@xylabs/zod
371
- [license-badge]: https://img.shields.io/npm/l/@xylabs/zod.svg
372
- [license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
373
- [logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
3
+ DEPRECATED — use `@ariestools/sdk/zod` instead.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/zod",
3
- "version": "7.0.6",
3
+ "version": "8.0.0",
4
4
  "description": "DEPRECATED — use @ariestools/sdk/zod. Backward-compatibility re-export shim.",
5
5
  "keywords": [
6
6
  "xylabs",
@@ -44,13 +44,13 @@
44
44
  "README.md"
45
45
  ],
46
46
  "dependencies": {
47
- "@ariestools/sdk": "~7.0.6"
47
+ "@ariestools/sdk": "~8.0.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@opentelemetry/api": "~1.9.1",
51
51
  "@opentelemetry/sdk-trace-base": "~2.9.0",
52
- "@xylabs/toolchain": "~8.6.0",
53
- "@xylabs/tsconfig": "~8.6.0",
52
+ "@xylabs/toolchain": "~8.6.2",
53
+ "@xylabs/tsconfig": "~8.6.2",
54
54
  "async-mutex": "~0.5.0",
55
55
  "browserslist": "~4.28.4",
56
56
  "eslint": "~10.6.0",