@atolljs/core 0.1.4 → 0.1.6

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 (45) hide show
  1. package/dist/contract/listSchema.d.ts +2 -2
  2. package/dist/contract/msgpackrCodec.d.ts +1 -1
  3. package/dist/contract/reef.d.ts +140 -80
  4. package/dist/contract/sharedMemory.d.ts +2 -2
  5. package/dist/contract/types.d.ts +1 -1
  6. package/dist/contract/zod.d.ts +114 -14
  7. package/dist/index.d.ts +31 -29
  8. package/dist/index.js +18 -17
  9. package/dist/index10.js +0 -2
  10. package/dist/index11.js +0 -2
  11. package/dist/index12.js +0 -2
  12. package/dist/index13.js +0 -2
  13. package/dist/index14.js +0 -2
  14. package/dist/index15.js +0 -2
  15. package/dist/index16.js +46 -38
  16. package/dist/index17.js +20 -21
  17. package/dist/index18.js +64 -37
  18. package/dist/index19.js +0 -2
  19. package/dist/index2.js +0 -2
  20. package/dist/index20.js +0 -2
  21. package/dist/index3.js +101 -43
  22. package/dist/index4.js +0 -2
  23. package/dist/index5.js +0 -2
  24. package/dist/index6.js +0 -2
  25. package/dist/index7.js +0 -2
  26. package/dist/index8.js +0 -2
  27. package/dist/index9.js +0 -2
  28. package/dist/observable.d.ts +2 -2
  29. package/dist/pool/memory.d.ts +1 -1
  30. package/dist/pool/workerClient.d.ts +6 -6
  31. package/dist/pool/workerPool.d.ts +2 -2
  32. package/dist/reactive.d.ts +1 -1
  33. package/dist/service.d.ts +1 -1
  34. package/dist/shared/sharedWorkerClient.d.ts +2 -2
  35. package/dist/task.d.ts +1 -1
  36. package/dist/testing/inProcessWorker.d.ts +27 -0
  37. package/dist/worker/defineWorker.d.ts +3 -4
  38. package/dist/worker/registry.d.ts +1 -1
  39. package/dist/worker/workerBootstrap.d.ts +9 -1
  40. package/package.json +6 -3
  41. package/src/contract/zod.ts +130 -14
  42. package/src/index.ts +2 -0
  43. package/src/reactive.ts +107 -42
  44. package/src/worker/defineWorker.ts +6 -2
  45. package/src/worker/workerBootstrap.ts +53 -37
@@ -1,5 +1,5 @@
1
- import { z, type Fluent } from './zod';
2
- import type { ListFieldSpec, ListFields, ListMember } from './sharedMemory';
1
+ import { z, type Fluent } from './zod.js';
2
+ import type { ListFieldSpec, ListFields, ListMember } from './sharedMemory.js';
3
3
  /** Maps a list member to the zod shape whose inferred output type is
4
4
  * identical to `ListRecord<F>[K]` — zod members pass through as
5
5
  * themselves so declared bounds (e.g. `.max(3)`) stay in effect. */
@@ -1,2 +1,2 @@
1
- import type { Codec } from './sharedMemory';
1
+ import type { Codec } from './sharedMemory.js';
2
2
  export declare const msgpackrCodec: Codec;
@@ -1,4 +1,4 @@
1
- import { z } from './zod';
1
+ import { z } from './zod.js';
2
2
  /**
3
3
  * Reef — the atoll's structural barrier: the fixed-width schema
4
4
  * vocabulary standing between your data and the raw buffer. Every helper
@@ -24,11 +24,11 @@ import { z } from './zod';
24
24
  * `_zod.def`, so `reef.object({ id: z.uint32() })` mixes freely.
25
25
  */
26
26
  export declare const reef: {
27
- i8: () => import("./zod").Fluent<{
27
+ i8: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
28
28
  readonly _zod: {
29
29
  output: number;
30
30
  input: number;
31
- def: import("./zod").SchemaDef & {
31
+ def: import("./zod.js").SchemaDef & {
32
32
  type: 'number';
33
33
  };
34
34
  };
@@ -41,14 +41,14 @@ export declare const reef: {
41
41
  success: false;
42
42
  error: unknown;
43
43
  };
44
- check(...checks: import("./zod").Check[]): /*elided*/ any;
45
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): /*elided*/ any;
46
- }>;
47
- u8: () => import("./zod").Fluent<{
44
+ check(...checks: import("./zod.js").Check[]): /*elided*/ any;
45
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
46
+ }>>;
47
+ u8: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
48
48
  readonly _zod: {
49
49
  output: number;
50
50
  input: number;
51
- def: import("./zod").SchemaDef & {
51
+ def: import("./zod.js").SchemaDef & {
52
52
  type: 'number';
53
53
  };
54
54
  };
@@ -61,14 +61,14 @@ export declare const reef: {
61
61
  success: false;
62
62
  error: unknown;
63
63
  };
64
- check(...checks: import("./zod").Check[]): any;
65
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
66
- }>;
67
- i16: () => import("./zod").Fluent<{
64
+ check(...checks: import("./zod.js").Check[]): any;
65
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
66
+ }>>;
67
+ i16: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
68
68
  readonly _zod: {
69
69
  output: number;
70
70
  input: number;
71
- def: import("./zod").SchemaDef & {
71
+ def: import("./zod.js").SchemaDef & {
72
72
  type: 'number';
73
73
  };
74
74
  };
@@ -81,14 +81,14 @@ export declare const reef: {
81
81
  success: false;
82
82
  error: unknown;
83
83
  };
84
- check(...checks: import("./zod").Check[]): any;
85
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
86
- }>;
87
- u16: () => import("./zod").Fluent<{
84
+ check(...checks: import("./zod.js").Check[]): any;
85
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
86
+ }>>;
87
+ u16: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
88
88
  readonly _zod: {
89
89
  output: number;
90
90
  input: number;
91
- def: import("./zod").SchemaDef & {
91
+ def: import("./zod.js").SchemaDef & {
92
92
  type: 'number';
93
93
  };
94
94
  };
@@ -101,14 +101,14 @@ export declare const reef: {
101
101
  success: false;
102
102
  error: unknown;
103
103
  };
104
- check(...checks: import("./zod").Check[]): any;
105
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
106
- }>;
107
- i32: () => import("./zod").Fluent<{
104
+ check(...checks: import("./zod.js").Check[]): any;
105
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
106
+ }>>;
107
+ i32: () => import("./zod.js").Fluent<{
108
108
  readonly _zod: {
109
109
  output: number;
110
110
  input: number;
111
- def: import("./zod").SchemaDef & {
111
+ def: import("./zod.js").SchemaDef & {
112
112
  type: 'number';
113
113
  };
114
114
  };
@@ -121,14 +121,14 @@ export declare const reef: {
121
121
  success: false;
122
122
  error: unknown;
123
123
  };
124
- check(...checks: import("./zod").Check[]): any;
125
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
124
+ check(...checks: import("./zod.js").Check[]): any;
125
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
126
126
  }>;
127
- u32: () => import("./zod").Fluent<{
127
+ u32: () => import("./zod.js").Fluent<{
128
128
  readonly _zod: {
129
129
  output: number;
130
130
  input: number;
131
- def: import("./zod").SchemaDef & {
131
+ def: import("./zod.js").SchemaDef & {
132
132
  type: 'number';
133
133
  };
134
134
  };
@@ -141,14 +141,14 @@ export declare const reef: {
141
141
  success: false;
142
142
  error: unknown;
143
143
  };
144
- check(...checks: import("./zod").Check[]): any;
145
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
144
+ check(...checks: import("./zod.js").Check[]): any;
145
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
146
146
  }>;
147
- f32: () => import("./zod").Fluent<{
147
+ f32: () => import("./zod.js").Fluent<{
148
148
  readonly _zod: {
149
149
  output: number;
150
150
  input: number;
151
- def: import("./zod").SchemaDef & {
151
+ def: import("./zod.js").SchemaDef & {
152
152
  type: 'number';
153
153
  };
154
154
  };
@@ -161,14 +161,14 @@ export declare const reef: {
161
161
  success: false;
162
162
  error: unknown;
163
163
  };
164
- check(...checks: import("./zod").Check[]): any;
165
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
164
+ check(...checks: import("./zod.js").Check[]): any;
165
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
166
166
  }>;
167
- f64: () => import("./zod").Fluent<{
167
+ f64: () => import("./zod.js").Fluent<{
168
168
  readonly _zod: {
169
169
  output: number;
170
170
  input: number;
171
- def: import("./zod").SchemaDef & {
171
+ def: import("./zod.js").SchemaDef & {
172
172
  type: 'number';
173
173
  };
174
174
  };
@@ -181,14 +181,14 @@ export declare const reef: {
181
181
  success: false;
182
182
  error: unknown;
183
183
  };
184
- check(...checks: import("./zod").Check[]): any;
185
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
184
+ check(...checks: import("./zod.js").Check[]): any;
185
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
186
186
  }>;
187
- i64: () => import("./zod").Fluent<{
187
+ i64: () => import("./zod.js").Fluent<{
188
188
  readonly _zod: {
189
189
  output: bigint;
190
190
  input: bigint;
191
- def: import("./zod").SchemaDef & {
191
+ def: import("./zod.js").SchemaDef & {
192
192
  type: 'bigint';
193
193
  };
194
194
  };
@@ -201,14 +201,14 @@ export declare const reef: {
201
201
  success: false;
202
202
  error: unknown;
203
203
  };
204
- check(...checks: import("./zod").Check[]): /*elided*/ any;
205
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): /*elided*/ any;
204
+ check(...checks: import("./zod.js").Check[]): /*elided*/ any;
205
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
206
206
  }>;
207
- u64: () => import("./zod").Fluent<{
207
+ u64: () => import("./zod.js").Fluent<{
208
208
  readonly _zod: {
209
209
  output: bigint;
210
210
  input: bigint;
211
- def: import("./zod").SchemaDef & {
211
+ def: import("./zod.js").SchemaDef & {
212
212
  type: 'bigint';
213
213
  };
214
214
  };
@@ -221,15 +221,15 @@ export declare const reef: {
221
221
  success: false;
222
222
  error: unknown;
223
223
  };
224
- check(...checks: import("./zod").Check[]): any;
225
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): any;
224
+ check(...checks: import("./zod.js").Check[]): any;
225
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
226
226
  }>;
227
227
  /** Bounded int — compiles to the narrowest covering kind (0..3 → u8). */
228
- int: (min: number, max: number) => import("./zod").Fluent<{
228
+ int: (min: number, max: number) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
229
229
  readonly _zod: {
230
230
  output: number;
231
231
  input: number;
232
- def: import("./zod").SchemaDef & {
232
+ def: import("./zod.js").SchemaDef & {
233
233
  type: 'number';
234
234
  };
235
235
  };
@@ -242,15 +242,15 @@ export declare const reef: {
242
242
  success: false;
243
243
  error: unknown;
244
244
  };
245
- check(...checks: import("./zod").Check[]): /*elided*/ any;
246
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): /*elided*/ any;
247
- }>;
245
+ check(...checks: import("./zod.js").Check[]): /*elided*/ any;
246
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
247
+ }>>;
248
248
  /** A flag byte — reads and writes as boolean. */
249
- boolean: () => import("./zod").Fluent<{
249
+ boolean: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
250
250
  readonly _zod: {
251
251
  output: boolean;
252
252
  input: boolean;
253
- def: import("./zod").SchemaDef & {
253
+ def: import("./zod.js").SchemaDef & {
254
254
  type: 'boolean';
255
255
  };
256
256
  };
@@ -263,17 +263,17 @@ export declare const reef: {
263
263
  success: false;
264
264
  error: unknown;
265
265
  };
266
- check(...checks: import("./zod").Check[]): /*elided*/ any;
267
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): /*elided*/ any;
268
- }>;
266
+ check(...checks: import("./zod.js").Check[]): /*elided*/ any;
267
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
268
+ }>>;
269
269
  /** Fixed-capacity inline UTF-8 string — `bytes` is the byte budget. The
270
270
  * schema itself refuses over-budget values, so `.parse` and connector
271
271
  * writes enforce the same limit. */
272
- string: (bytes: number) => import("./zod").Fluent<{
272
+ string: (bytes: number) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
273
273
  readonly _zod: {
274
274
  output: string;
275
275
  input: string;
276
- def: import("./zod").SchemaDef & {
276
+ def: import("./zod.js").SchemaDef & {
277
277
  type: 'string';
278
278
  };
279
279
  };
@@ -286,54 +286,114 @@ export declare const reef: {
286
286
  success: false;
287
287
  error: unknown;
288
288
  };
289
- check(...checks: import("./zod").Check[]): /*elided*/ any;
290
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): /*elided*/ any;
291
- }>;
289
+ check(...checks: import("./zod.js").Check[]): /*elided*/ any;
290
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
291
+ }>>;
292
292
  /** A fixed-layout record shape — every member must be a fixed-width schema. */
293
- object: <S extends z.ZodRawShape>(shape: S) => import("./zod").Fluent<{
293
+ object: <S extends z.ZodRawShape>(shape: S) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
294
294
  readonly _zod: {
295
- output: { [K in keyof S]: S[K] extends {
295
+ output: { [K in keyof S as (S[K] extends {
296
+ _zod: {
297
+ output: infer O;
298
+ };
299
+ } ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
300
+ _zod: {
301
+ output: infer O_1;
302
+ };
303
+ } ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
296
304
  _zod: {
297
305
  output: infer O;
298
306
  };
299
- } ? O : never; };
300
- input: { [K in keyof S]: S[K] extends {
307
+ } ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
308
+ _zod: {
309
+ output: infer O_1;
310
+ };
311
+ } ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
312
+ input: { [K in keyof S as (S[K] extends {
301
313
  _zod: {
302
314
  output: infer O;
303
315
  };
304
- } ? O : never; };
305
- def: import("./zod").SchemaDef & {
316
+ } ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
317
+ _zod: {
318
+ output: infer O_1;
319
+ };
320
+ } ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
321
+ _zod: {
322
+ output: infer O;
323
+ };
324
+ } ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
325
+ _zod: {
326
+ output: infer O_1;
327
+ };
328
+ } ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
329
+ def: import("./zod.js").SchemaDef & {
306
330
  type: 'object';
307
331
  shape: S;
308
332
  };
309
333
  };
310
334
  get shape(): S;
311
- inner(v: unknown): { [K in keyof S]: S[K] extends {
335
+ inner(v: unknown): { [K in keyof S as (S[K] extends {
336
+ _zod: {
337
+ output: infer O;
338
+ };
339
+ } ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
340
+ _zod: {
341
+ output: infer O_1;
342
+ };
343
+ } ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
312
344
  _zod: {
313
345
  output: infer O;
314
346
  };
315
- } ? O : never; };
316
- parse(value: unknown): { [K in keyof S]: S[K] extends {
347
+ } ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
348
+ _zod: {
349
+ output: infer O_1;
350
+ };
351
+ } ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
352
+ parse(value: unknown): { [K in keyof S as (S[K] extends {
353
+ _zod: {
354
+ output: infer O;
355
+ };
356
+ } ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
357
+ _zod: {
358
+ output: infer O_1;
359
+ };
360
+ } ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
317
361
  _zod: {
318
362
  output: infer O;
319
363
  };
320
- } ? O : never; };
364
+ } ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
365
+ _zod: {
366
+ output: infer O_1;
367
+ };
368
+ } ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
321
369
  safeParse(value: unknown): {
322
370
  success: true;
323
- data: { [K in keyof S]: S[K] extends {
371
+ data: { [K in keyof S as (S[K] extends {
324
372
  _zod: {
325
373
  output: infer O;
326
374
  };
327
- } ? O : never; };
375
+ } ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
376
+ _zod: {
377
+ output: infer O_1;
378
+ };
379
+ } ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
380
+ _zod: {
381
+ output: infer O;
382
+ };
383
+ } ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
384
+ _zod: {
385
+ output: infer O_1;
386
+ };
387
+ } ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
328
388
  } | {
329
389
  success: false;
330
390
  error: unknown;
331
391
  };
332
- check(...checks: import("./zod").Check[]): /*elided*/ any;
333
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): /*elided*/ any;
334
- }>;
392
+ check(...checks: import("./zod.js").Check[]): /*elided*/ any;
393
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
394
+ }>>;
335
395
  /** A fixed-stride element — bound it with `.max(n)` or `.length(n)` before field.array. */
336
- array: <E extends z.ZodTypeAny>(element: E) => import("./zod").Fluent<{
396
+ array: <E extends z.ZodTypeAny>(element: E) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
337
397
  readonly _zod: {
338
398
  output: (E extends {
339
399
  _zod: {
@@ -345,7 +405,7 @@ export declare const reef: {
345
405
  output: infer O;
346
406
  };
347
407
  } ? O : never)[];
348
- def: import("./zod").SchemaDef & {
408
+ def: import("./zod.js").SchemaDef & {
349
409
  type: 'array';
350
410
  element: E;
351
411
  };
@@ -371,7 +431,7 @@ export declare const reef: {
371
431
  success: false;
372
432
  error: unknown;
373
433
  };
374
- check(...checks: import("./zod").Check[]): /*elided*/ any;
375
- register(registry: import("./zod").Registry, meta: Record<string, unknown>): /*elided*/ any;
376
- }>;
434
+ check(...checks: import("./zod.js").Check[]): /*elided*/ any;
435
+ register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
436
+ }>>;
377
437
  };
@@ -1,5 +1,5 @@
1
- import type { Prettify, Schema } from './types';
2
- import { z } from './zod';
1
+ import type { Prettify, Schema } from './types.js';
2
+ import { z } from './zod.js';
3
3
  /**
4
4
  * Declares the datatype of a single field in the shared memory contract.
5
5
  * `byteLength` is the fixed region reserved for the field; structured types
@@ -1,4 +1,4 @@
1
- import type { SharedAccess, SharedMemory, SharedSpec } from './sharedMemory';
1
+ import type { SharedAccess, SharedMemory, SharedSpec } from './sharedMemory.js';
2
2
  export type ViewType = 'Int32' | 'Float64' | 'BigInt64' | 'Uint8';
3
3
  /**
4
4
  * Minimal validation contract — compatible with zod schemas (`z.object(...)`)
@@ -52,6 +52,10 @@ export interface SchemaDef {
52
52
  format?: string;
53
53
  shape?: Record<string, ZodLike>;
54
54
  element?: ZodLike;
55
+ /** union members. */
56
+ options?: readonly ZodLike[];
57
+ /** literal value. */
58
+ literal?: unknown;
55
59
  cls?: abstract new (...args: any[]) => unknown;
56
60
  }
57
61
  export declare class SchemaError extends Error {
@@ -143,13 +147,23 @@ declare class ZodUnknown extends ZodType<unknown> {
143
147
  declare class ZodInstanceof<T> extends ZodType<T> {
144
148
  inner(v: unknown): T;
145
149
  }
146
- type ShapeOutput<S extends Record<string, ZodLike>> = {
147
- [K in keyof S]: S[K] extends {
148
- _zod: {
149
- output: infer O;
150
- };
151
- } ? O : never;
150
+ /** Members whose output admits `undefined` become optional keys — mirroring
151
+ * zod's `z.optional()` object-member semantics (message-domain schemas like
152
+ * island prop contracts need this; reef's fixed-width members never produce
153
+ * it, so the split preserves their all-required output). */
154
+ type IsOptional<S, K extends keyof S> = S[K] extends {
155
+ _zod: {
156
+ output: infer O;
157
+ };
158
+ } ? undefined extends O ? true : false : false;
159
+ type Flatten<T> = {
160
+ [K in keyof T]: T[K];
152
161
  };
162
+ type ShapeOutput<S extends Record<string, ZodLike>> = Flatten<{
163
+ [K in keyof S as IsOptional<S, K> extends true ? never : K]: OutputOf<S[K]>;
164
+ } & {
165
+ [K in keyof S as IsOptional<S, K> extends true ? K : never]?: OutputOf<S[K]>;
166
+ }>;
153
167
  /** Strips unknown keys like zod's object parse — output is the shape only. */
154
168
  declare class ZodObjectSchema<S extends Record<string, ZodLike>> extends ZodType<ShapeOutput<S>> {
155
169
  readonly _zod: {
@@ -179,14 +193,90 @@ type OutputOf<S> = S extends {
179
193
  output: infer O;
180
194
  };
181
195
  } ? O : never;
182
- declare const number: () => ZodNumber;
183
- declare const string: () => ZodString;
184
- declare const boolean_: () => ZodBoolean;
185
- declare const bigint_: () => ZodBigint;
186
- declare const unknown_: () => ZodUnknown;
187
- declare const instanceof_: <T extends abstract new (...args: any[]) => any>(cls: T) => ZodInstanceof<InstanceType<T>>;
188
- declare const object_: <S extends Record<string, ZodLike>>(shape: S) => ZodObjectSchema<S>;
189
- declare const array: <E extends ZodLike>(element: E) => ZodArraySchema<E>;
196
+ declare class ZodOptional<E extends ZodLike> extends ZodType<OutputOf<E> | undefined> {
197
+ readonly _zod: {
198
+ output: OutputOf<E> | undefined;
199
+ input: OutputOf<E> | undefined;
200
+ def: SchemaDef & {
201
+ type: 'optional';
202
+ element: E;
203
+ };
204
+ };
205
+ inner(v: unknown): OutputOf<E> | undefined;
206
+ }
207
+ declare class ZodNullable<E extends ZodLike> extends ZodType<OutputOf<E> | null> {
208
+ readonly _zod: {
209
+ output: OutputOf<E> | null;
210
+ input: OutputOf<E> | null;
211
+ def: SchemaDef & {
212
+ type: 'nullable';
213
+ element: E;
214
+ };
215
+ };
216
+ inner(v: unknown): OutputOf<E> | null;
217
+ }
218
+ declare class ZodLiteral<V extends string | number | boolean> extends ZodType<V> {
219
+ readonly _zod: {
220
+ output: V;
221
+ input: V;
222
+ def: SchemaDef & {
223
+ type: 'literal';
224
+ };
225
+ };
226
+ inner(v: unknown): V;
227
+ }
228
+ declare class ZodUnion<O extends readonly ZodLike[]> extends ZodType<OutputOf<O[number]>> {
229
+ readonly _zod: {
230
+ output: OutputOf<O[number]>;
231
+ input: OutputOf<O[number]>;
232
+ def: SchemaDef & {
233
+ type: 'union';
234
+ options: O;
235
+ };
236
+ };
237
+ inner(v: unknown): OutputOf<O[number]>;
238
+ }
239
+ declare class ZodRecord<E extends ZodLike> extends ZodType<Record<string, OutputOf<E>>> {
240
+ readonly _zod: {
241
+ output: Record<string, OutputOf<E>>;
242
+ input: Record<string, OutputOf<E>>;
243
+ def: SchemaDef & {
244
+ type: 'record';
245
+ element: E;
246
+ };
247
+ };
248
+ inner(v: unknown): Record<string, OutputOf<E>>;
249
+ }
250
+ /**
251
+ * Function-typed members — how a props schema declares a `callbackProp`
252
+ * slot: the wire carries a `{__cb:id}` handle that `unmarshalCallbackProps`
253
+ * restores to a callable BEFORE contract validation runs, so at parse time
254
+ * the member is a real function.
255
+ */
256
+ declare class ZodCallback<F extends (...args: any[]) => any = (...args: unknown[]) => unknown> extends ZodType<F> {
257
+ readonly _zod: {
258
+ output: F;
259
+ input: F;
260
+ def: SchemaDef & {
261
+ type: 'function';
262
+ };
263
+ };
264
+ inner(v: unknown): F;
265
+ }
266
+ declare const number: () => Fluent<ZodNumber>;
267
+ declare const string: () => Fluent<ZodString>;
268
+ declare const boolean_: () => Fluent<ZodBoolean>;
269
+ declare const bigint_: () => Fluent<ZodBigint>;
270
+ declare const unknown_: () => Fluent<ZodUnknown>;
271
+ declare const instanceof_: <T extends abstract new (...args: any[]) => any>(cls: T) => Fluent<ZodInstanceof<InstanceType<T>>>;
272
+ declare const object_: <S extends Record<string, ZodLike>>(shape: S) => Fluent<ZodObjectSchema<S>>;
273
+ declare const array: <E extends ZodLike>(element: E) => Fluent<ZodArraySchema<E>>;
274
+ declare const optional: <E extends ZodLike>(element: E) => Fluent<ZodOptional<E>>;
275
+ declare const nullable: <E extends ZodLike>(element: E) => Fluent<ZodNullable<E>>;
276
+ declare const literal: <V extends string | number | boolean>(value: V) => Fluent<ZodLiteral<V>>;
277
+ declare const union: <O extends readonly [ZodLike, ...ZodLike[]]>(options: O) => Fluent<ZodUnion<O>>;
278
+ declare const record: <E extends ZodLike>(element: E) => Fluent<ZodRecord<E>>;
279
+ declare const callback: <F extends (...args: any[]) => any = (...args: unknown[]) => unknown>() => Fluent<ZodCallback<F>>;
190
280
  declare const int32: () => ZodNumber;
191
281
  declare const uint32: () => ZodNumber;
192
282
  declare const float32: () => ZodNumber;
@@ -204,6 +294,10 @@ export type Fluent<S extends ZodLike> = S & {
204
294
  max(value: number | bigint): Fluent<S>;
205
295
  length(n: number): Fluent<S>;
206
296
  int(): Fluent<S>;
297
+ /** Wraps in an optional member — the `label?: string` spelling. */
298
+ optional(): Fluent<ZodOptional<S>>;
299
+ /** Wraps in a nullable member — `T | null`. */
300
+ nullable(): Fluent<ZodNullable<S>>;
207
301
  };
208
302
  /** Attaches the `Fluent` methods as non-enumerable own properties. */
209
303
  export declare function fluent<S extends ZodType>(schema: S): Fluent<S>;
@@ -216,6 +310,12 @@ export declare const z: {
216
310
  array: typeof array;
217
311
  instanceof: typeof instanceof_;
218
312
  unknown: typeof unknown_;
313
+ optional: typeof optional;
314
+ nullable: typeof nullable;
315
+ literal: typeof literal;
316
+ union: typeof union;
317
+ record: typeof record;
318
+ callback: typeof callback;
219
319
  int32: typeof int32;
220
320
  uint32: typeof uint32;
221
321
  float32: typeof float32;