matrix-nodejs-homeserver 0.2.0 → 0.3.2

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 (99) hide show
  1. package/README.md +89 -11
  2. package/dist/adapters/cluster.d.ts +1 -26
  3. package/dist/adapters/cluster.js +50 -103
  4. package/dist/api/account.js +407 -354
  5. package/dist/api/admin.js +82 -61
  6. package/dist/api/appservice.js +37 -25
  7. package/dist/api/backup.js +73 -62
  8. package/dist/api/federation.js +172 -138
  9. package/dist/api/filters.js +4 -3
  10. package/dist/api/legacy.js +91 -78
  11. package/dist/api/media.js +71 -55
  12. package/dist/api/misc.js +46 -37
  13. package/dist/api/preview.js +37 -73
  14. package/dist/api/profile.js +108 -97
  15. package/dist/api/push.js +114 -99
  16. package/dist/api/relationships.js +64 -58
  17. package/dist/api/rooms.js +703 -580
  18. package/dist/api/rtc.d.ts +0 -1
  19. package/dist/api/rtc.js +48 -34
  20. package/dist/api/search.js +133 -127
  21. package/dist/api/slidingsync.js +41 -31
  22. package/dist/api/spaces.js +82 -77
  23. package/dist/api/sync.js +325 -135
  24. package/dist/api/threadsubs.js +72 -61
  25. package/dist/api/threepid.js +99 -66
  26. package/dist/api/uia.js +17 -16
  27. package/dist/api/user.js +221 -178
  28. package/dist/core/admin.d.ts +0 -1
  29. package/dist/core/admin.js +6 -5
  30. package/dist/core/adminroom.js +9 -8
  31. package/dist/core/appservices.d.ts +2 -1
  32. package/dist/core/appservices.js +5 -4
  33. package/dist/core/audit.d.ts +0 -1
  34. package/dist/core/authrules.js +26 -25
  35. package/dist/core/cluster.d.ts +12 -5
  36. package/dist/core/cluster.js +46 -29
  37. package/dist/core/delayed.js +2 -1
  38. package/dist/core/events.js +11 -10
  39. package/dist/core/html.js +13 -0
  40. package/dist/core/identity.js +1 -1
  41. package/dist/core/invitefilter.js +2 -1
  42. package/dist/core/json.js +10 -1
  43. package/dist/core/keys.d.ts +10 -1
  44. package/dist/core/keys.js +62 -42
  45. package/dist/core/m.d.ts +209 -0
  46. package/dist/core/m.js +182 -0
  47. package/dist/core/outbound.d.ts +16 -0
  48. package/dist/core/outbound.js +172 -0
  49. package/dist/core/partialstate.js +2 -1
  50. package/dist/core/policy.js +4 -3
  51. package/dist/core/push.d.ts +0 -1
  52. package/dist/core/push.js +41 -28
  53. package/dist/core/pushrules.js +36 -35
  54. package/dist/core/ratelimit.d.ts +1 -1
  55. package/dist/core/rooms.d.ts +10 -1
  56. package/dist/core/rooms.js +101 -74
  57. package/dist/core/semaphore.js +23 -0
  58. package/dist/core/sso.d.ts +15 -1
  59. package/dist/core/sso.js +38 -2
  60. package/dist/core/stateres.js +7 -6
  61. package/dist/core/threepid.js +1 -9
  62. package/dist/federation/client.js +9 -1
  63. package/dist/federation/index.d.ts +2 -2
  64. package/dist/federation/index.js +43 -35
  65. package/dist/homeserver.d.ts +23 -4
  66. package/dist/homeserver.js +12 -3
  67. package/dist/http/handler.js +2 -23
  68. package/dist/http/input.js +2 -2
  69. package/dist/http/procedure.js +25 -0
  70. package/dist/http/router.d.ts +9 -26
  71. package/dist/http/router.js +10 -30
  72. package/dist/index.d.ts +4 -3
  73. package/dist/index.js +3 -2
  74. package/dist/storage/batch.js +11 -0
  75. package/dist/storage/memory.js +1 -0
  76. package/dist/storage/schema.js +1 -1
  77. package/dist/storage/sql.js +20 -1
  78. package/dist/storage/types.d.ts +16 -0
  79. package/dist/vendor/zod/LICENSE +21 -0
  80. package/dist/vendor/zod/v4/classic/errors.js +54 -0
  81. package/dist/vendor/zod/v4/classic/parse.js +17 -0
  82. package/dist/vendor/zod/v4/classic/schemas.js +865 -0
  83. package/dist/vendor/zod/v4/core/api.js +512 -0
  84. package/dist/vendor/zod/v4/core/checks.js +300 -0
  85. package/dist/vendor/zod/v4/core/core.js +109 -0
  86. package/dist/vendor/zod/v4/core/doc.js +35 -0
  87. package/dist/vendor/zod/v4/core/errors.js +118 -0
  88. package/dist/vendor/zod/v4/core/json-schema-processors.js +428 -0
  89. package/dist/vendor/zod/v4/core/memoizer.js +255 -0
  90. package/dist/vendor/zod/v4/core/parse.js +206 -0
  91. package/dist/vendor/zod/v4/core/regexes.js +73 -0
  92. package/dist/vendor/zod/v4/core/registries.js +48 -0
  93. package/dist/vendor/zod/v4/core/schemas.js +1378 -0
  94. package/dist/vendor/zod/v4/core/to-json-schema.js +448 -0
  95. package/dist/vendor/zod/v4/core/util.js +537 -0
  96. package/dist/vendor/zod/v4/core/versions.js +8 -0
  97. package/dist/vendor/zod/v4/locales/en.js +110 -0
  98. package/package.json +8 -6
  99. package/dist/core/pushrules.d.ts +0 -1
@@ -0,0 +1,865 @@
1
+ import { clone, constantCatch, derived, extend, hide, installLazyProp, issue, merge, mergeDefs, normalizeParams, omit, own, partial, pick, required, safeExtend, shallowClone } from "../core/util.js";
2
+ import { $ZodEncodeError, $constructor, config, globalConfig } from "../core/core.js";
3
+ import { validate, validateAsync } from "../core/parse.js";
4
+ import { $ZodArray, $ZodBase64, $ZodBase64URL, $ZodBoolean, $ZodCIDRv4, $ZodCIDRv6, $ZodCUID, $ZodCUID2, $ZodCatch, $ZodCustom, $ZodDefault, $ZodE164, $ZodEmail, $ZodEmoji, $ZodEnum, $ZodExactOptional, $ZodGUID, $ZodIPv4, $ZodIPv6, $ZodISODate, $ZodISODateTime, $ZodISODuration, $ZodISOTime, $ZodIntersection, $ZodJWT, $ZodKSUID, $ZodNanoID, $ZodNever, $ZodNonOptional, $ZodNullable, $ZodNumber, $ZodNumberFormat, $ZodObjectJIT, $ZodOptional, $ZodPipe, $ZodPrefault, $ZodReadonly, $ZodRecord, $ZodString, $ZodStringFormat, $ZodTransform, $ZodType, $ZodULID, $ZodURL, $ZodUUID, $ZodUnion, $ZodUnknown, $ZodXID, standardProps } from "../core/schemas.js";
5
+ import { memoizer } from "../core/memoizer.js";
6
+ import en_default from "../locales/en.js";
7
+ import { globalRegistry } from "../core/registries.js";
8
+ import { _array, _base64, _base64url, _boolean, _cidrv4, _cidrv6, _cuid, _cuid2, _e164, _email, _emoji, _endsWith, _gt, _gte, _guid, _includes, _int, _ipv4, _ipv6, _isoDate, _isoDateTime, _isoDuration, _isoTime, _jwt, _ksuid, _length, _lowercase, _lt, _lte, _maxLength, _minLength, _multipleOf, _nanoid, _never, _normalize, _number, _overwrite, _refine, _regex, _slugify, _startsWith, _string, _superRefine, _toLowerCase, _toUpperCase, _trim, _ulid, _unknown, _uppercase, _url, _uuid, _uuidv4, _uuidv6, _uuidv7, _xid } from "../core/api.js";
9
+ import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../core/to-json-schema.js";
10
+ import { aggregateChecks, arrayProcessor, booleanProcessor, catchProcessor, customProcessor, defaultProcessor, enumProcessor, intersectionProcessor, neverProcessor, nonoptionalProcessor, nullableProcessor, numberProcessor, objectProcessor, optionalProcessor, pipeProcessor, prefaultProcessor, readonlyProcessor, recordProcessor, stringProcessor, transformProcessor, unionProcessor, unknownProcessor } from "../core/json-schema-processors.js";
11
+ import { decode, decodeAsync, encode, encodeAsync, parse, parseAsync, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync } from "./parse.js";
12
+ //#region node_modules/zod/v4/classic/schemas.js
13
+ function _ensureDefaultLocale() {
14
+ if (!globalConfig.localeError) config(en_default());
15
+ }
16
+ function _ensureDefaultMemoizer() {
17
+ if (!globalConfig.memoizer) config({ memoizer: memoizer() });
18
+ }
19
+ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
20
+ _ensureDefaultLocale();
21
+ $ZodType.init(inst, def);
22
+ inst.def = def;
23
+ inst.type = def.type;
24
+ return inst;
25
+ }, {
26
+ check(...chks) {
27
+ const def = this.def;
28
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
29
+ check: ch,
30
+ def: { check: "custom" },
31
+ onattach: []
32
+ } } : ch)] }), { parent: true });
33
+ },
34
+ with(...chks) {
35
+ return this.check(...chks);
36
+ },
37
+ clone(def, params) {
38
+ return clone(this, def, params);
39
+ },
40
+ brand() {
41
+ return this;
42
+ },
43
+ register(reg, meta) {
44
+ reg.add(this, meta);
45
+ return this;
46
+ },
47
+ refine(check, params) {
48
+ return this.check(refine(check, params));
49
+ },
50
+ superRefine(refinement, params) {
51
+ return this.check(superRefine(refinement, params));
52
+ },
53
+ overwrite(fn) {
54
+ return this.check(_overwrite(fn));
55
+ },
56
+ optional() {
57
+ return optional(this);
58
+ },
59
+ exactOptional() {
60
+ return exactOptional(this);
61
+ },
62
+ nullable() {
63
+ return nullable(this);
64
+ },
65
+ nullish() {
66
+ return optional(nullable(this));
67
+ },
68
+ nonoptional(params) {
69
+ return nonoptional(this, params);
70
+ },
71
+ array() {
72
+ return array(this);
73
+ },
74
+ or(arg) {
75
+ return union([this, arg]);
76
+ },
77
+ and(arg) {
78
+ return intersection(this, arg);
79
+ },
80
+ transform(tx) {
81
+ return pipe(this, transform(tx));
82
+ },
83
+ default(d) {
84
+ return _default(this, d);
85
+ },
86
+ prefault(d) {
87
+ return prefault(this, d);
88
+ },
89
+ catch(params) {
90
+ return _catch(this, params);
91
+ },
92
+ pipe(target) {
93
+ return pipe(this, target);
94
+ },
95
+ readonly() {
96
+ return readonly(this);
97
+ },
98
+ describe(description) {
99
+ const cl = this.clone();
100
+ globalRegistry.add(cl, { description });
101
+ return cl;
102
+ },
103
+ meta(...args) {
104
+ if (args.length === 0) return globalRegistry.get(this);
105
+ const cl = this.clone();
106
+ globalRegistry.add(cl, args[0]);
107
+ return cl;
108
+ },
109
+ isOptional() {
110
+ return this.safeParse(void 0).success;
111
+ },
112
+ isNullable() {
113
+ return this.safeParse(null).success;
114
+ },
115
+ apply(fn, ...args) {
116
+ return args.length === 0 ? fn(this) : fn(this, ...args);
117
+ },
118
+ get "~standard"() {
119
+ return hide(this, "~standard", {
120
+ ...standardProps(this),
121
+ jsonSchema: {
122
+ input: createStandardJSONSchemaMethod(this, "input"),
123
+ output: createStandardJSONSchemaMethod(this, "output")
124
+ }
125
+ });
126
+ },
127
+ set "~standard"(value) {
128
+ own(this, "~standard", value);
129
+ },
130
+ parse: function _parse(data, params) {
131
+ return parse(this, data, params, { callee: _parse });
132
+ },
133
+ parseAsync: async function _parseAsync(data, params) {
134
+ return await parseAsync(this, data, params, { callee: _parseAsync });
135
+ },
136
+ safeParse(data, params) {
137
+ return safeParse(this, data, params);
138
+ },
139
+ async safeParseAsync(data, params) {
140
+ return safeParseAsync(this, data, params);
141
+ },
142
+ get spa() {
143
+ return this?.safeParseAsync;
144
+ },
145
+ set spa(value) {
146
+ own(this, "spa", value);
147
+ },
148
+ validate(data, params) {
149
+ return validate(this, data, params);
150
+ },
151
+ validateAsync(data, params) {
152
+ return validateAsync(this, data, params);
153
+ },
154
+ encode: function _encode(data, params) {
155
+ return encode(this, data, params, { callee: _encode });
156
+ },
157
+ decode: function _decode(data, params) {
158
+ return decode(this, data, params, { callee: _decode });
159
+ },
160
+ encodeAsync: async function _encodeAsync(data, params) {
161
+ return await encodeAsync(this, data, params, { callee: _encodeAsync });
162
+ },
163
+ decodeAsync: async function _decodeAsync(data, params) {
164
+ return await decodeAsync(this, data, params, { callee: _decodeAsync });
165
+ },
166
+ safeEncode(data, params) {
167
+ return safeEncode(this, data, params);
168
+ },
169
+ safeDecode(data, params) {
170
+ return safeDecode(this, data, params);
171
+ },
172
+ async safeEncodeAsync(data, params) {
173
+ return safeEncodeAsync(this, data, params);
174
+ },
175
+ async safeDecodeAsync(data, params) {
176
+ return safeDecodeAsync(this, data, params);
177
+ },
178
+ toJSONSchema(params) {
179
+ return createToJSONSchemaMethod(this, {})(params);
180
+ },
181
+ get description() {
182
+ return globalRegistry.get(this)?.description;
183
+ },
184
+ get _def() {
185
+ return this._zod.def;
186
+ }
187
+ });
188
+ /** @internal */
189
+ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
190
+ $ZodString.init(inst, def);
191
+ ZodType.init(inst, def);
192
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
193
+ }, /*@__PURE__*/ derived({
194
+ format: (inst) => aggregateChecks(inst).format ?? null,
195
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
196
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
197
+ }, {
198
+ regex(...args) {
199
+ return this.check(_regex(...args));
200
+ },
201
+ includes(...args) {
202
+ return this.check(_includes(...args));
203
+ },
204
+ startsWith(...args) {
205
+ return this.check(_startsWith(...args));
206
+ },
207
+ endsWith(...args) {
208
+ return this.check(_endsWith(...args));
209
+ },
210
+ min(...args) {
211
+ return this.check(_minLength(...args));
212
+ },
213
+ max(...args) {
214
+ return this.check(_maxLength(...args));
215
+ },
216
+ length(...args) {
217
+ return this.check(_length(...args));
218
+ },
219
+ nonempty(...args) {
220
+ return this.check(_minLength(1, ...args));
221
+ },
222
+ lowercase(params) {
223
+ return this.check(_lowercase(params));
224
+ },
225
+ uppercase(params) {
226
+ return this.check(_uppercase(params));
227
+ },
228
+ trim() {
229
+ return this.check(_trim());
230
+ },
231
+ normalize(...args) {
232
+ return this.check(_normalize(...args));
233
+ },
234
+ toLowerCase() {
235
+ return this.check(_toLowerCase());
236
+ },
237
+ toUpperCase() {
238
+ return this.check(_toUpperCase());
239
+ },
240
+ slugify() {
241
+ return this.check(_slugify());
242
+ }
243
+ }));
244
+ const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
245
+ $ZodString.init(inst, def);
246
+ _ZodString.init(inst, def);
247
+ }, {
248
+ email(params) {
249
+ return this.check(_email(ZodEmail, params));
250
+ },
251
+ url(params) {
252
+ return this.check(_url(ZodURL, params));
253
+ },
254
+ jwt(params) {
255
+ return this.check(_jwt(ZodJWT, params));
256
+ },
257
+ emoji(params) {
258
+ return this.check(_emoji(ZodEmoji, params));
259
+ },
260
+ guid(params) {
261
+ return this.check(_guid(ZodGUID, params));
262
+ },
263
+ uuid(params) {
264
+ return this.check(_uuid(ZodUUID, params));
265
+ },
266
+ uuidv4(params) {
267
+ return this.check(_uuidv4(ZodUUID, params));
268
+ },
269
+ uuidv6(params) {
270
+ return this.check(_uuidv6(ZodUUID, params));
271
+ },
272
+ uuidv7(params) {
273
+ return this.check(_uuidv7(ZodUUID, params));
274
+ },
275
+ nanoid(params) {
276
+ return this.check(_nanoid(ZodNanoID, params));
277
+ },
278
+ cuid(params) {
279
+ return this.check(_cuid(ZodCUID, params));
280
+ },
281
+ cuid2(params) {
282
+ return this.check(_cuid2(ZodCUID2, params));
283
+ },
284
+ ulid(params) {
285
+ return this.check(_ulid(ZodULID, params));
286
+ },
287
+ base64(params) {
288
+ return this.check(_base64(ZodBase64, params));
289
+ },
290
+ base64url(params) {
291
+ return this.check(_base64url(ZodBase64URL, params));
292
+ },
293
+ xid(params) {
294
+ return this.check(_xid(ZodXID, params));
295
+ },
296
+ ksuid(params) {
297
+ return this.check(_ksuid(ZodKSUID, params));
298
+ },
299
+ ipv4(params) {
300
+ return this.check(_ipv4(ZodIPv4, params));
301
+ },
302
+ ipv6(params) {
303
+ return this.check(_ipv6(ZodIPv6, params));
304
+ },
305
+ cidrv4(params) {
306
+ return this.check(_cidrv4(ZodCIDRv4, params));
307
+ },
308
+ cidrv6(params) {
309
+ return this.check(_cidrv6(ZodCIDRv6, params));
310
+ },
311
+ e164(params) {
312
+ return this.check(_e164(ZodE164, params));
313
+ },
314
+ datetime(params) {
315
+ return this.check(_isoDateTime(ZodISODateTime, params));
316
+ },
317
+ date(params) {
318
+ return this.check(_isoDate(ZodISODate, params));
319
+ },
320
+ time(params) {
321
+ return this.check(_isoTime(ZodISOTime, params));
322
+ },
323
+ duration(params) {
324
+ return this.check(_isoDuration(ZodISODuration, params));
325
+ }
326
+ });
327
+ function string(params) {
328
+ return _string(ZodString, params);
329
+ }
330
+ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
331
+ $ZodStringFormat.init(inst, def);
332
+ _ZodString.init(inst, def);
333
+ });
334
+ const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
335
+ $ZodISODateTime.init(inst, def);
336
+ ZodStringFormat.init(inst, def);
337
+ });
338
+ const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
339
+ $ZodISODate.init(inst, def);
340
+ ZodStringFormat.init(inst, def);
341
+ });
342
+ const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
343
+ $ZodISOTime.init(inst, def);
344
+ ZodStringFormat.init(inst, def);
345
+ });
346
+ const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
347
+ $ZodISODuration.init(inst, def);
348
+ ZodStringFormat.init(inst, def);
349
+ });
350
+ const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
351
+ $ZodEmail.init(inst, def);
352
+ ZodStringFormat.init(inst, def);
353
+ });
354
+ const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
355
+ $ZodGUID.init(inst, def);
356
+ ZodStringFormat.init(inst, def);
357
+ });
358
+ const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
359
+ $ZodUUID.init(inst, def);
360
+ ZodStringFormat.init(inst, def);
361
+ });
362
+ const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
363
+ $ZodURL.init(inst, def);
364
+ ZodStringFormat.init(inst, def);
365
+ });
366
+ const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
367
+ $ZodEmoji.init(inst, def);
368
+ ZodStringFormat.init(inst, def);
369
+ });
370
+ const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
371
+ $ZodNanoID.init(inst, def);
372
+ ZodStringFormat.init(inst, def);
373
+ });
374
+ /**
375
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
376
+ * (timestamps embedded in the id). Use {@link ZodCUID2} instead.
377
+ * See https://github.com/paralleldrive/cuid.
378
+ */
379
+ const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
380
+ $ZodCUID.init(inst, def);
381
+ ZodStringFormat.init(inst, def);
382
+ });
383
+ const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
384
+ $ZodCUID2.init(inst, def);
385
+ ZodStringFormat.init(inst, def);
386
+ });
387
+ const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
388
+ $ZodULID.init(inst, def);
389
+ ZodStringFormat.init(inst, def);
390
+ });
391
+ const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
392
+ $ZodXID.init(inst, def);
393
+ ZodStringFormat.init(inst, def);
394
+ });
395
+ const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
396
+ $ZodKSUID.init(inst, def);
397
+ ZodStringFormat.init(inst, def);
398
+ });
399
+ const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
400
+ $ZodIPv4.init(inst, def);
401
+ ZodStringFormat.init(inst, def);
402
+ });
403
+ const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
404
+ $ZodIPv6.init(inst, def);
405
+ ZodStringFormat.init(inst, def);
406
+ });
407
+ const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
408
+ $ZodCIDRv4.init(inst, def);
409
+ ZodStringFormat.init(inst, def);
410
+ });
411
+ const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
412
+ $ZodCIDRv6.init(inst, def);
413
+ ZodStringFormat.init(inst, def);
414
+ });
415
+ const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
416
+ $ZodBase64.init(inst, def);
417
+ ZodStringFormat.init(inst, def);
418
+ });
419
+ const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
420
+ $ZodBase64URL.init(inst, def);
421
+ ZodStringFormat.init(inst, def);
422
+ });
423
+ const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
424
+ $ZodE164.init(inst, def);
425
+ ZodStringFormat.init(inst, def);
426
+ });
427
+ const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
428
+ $ZodJWT.init(inst, def);
429
+ ZodStringFormat.init(inst, def);
430
+ });
431
+ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
432
+ $ZodNumber.init(inst, def);
433
+ ZodType.init(inst, def);
434
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
435
+ inst.isFinite = true;
436
+ }, /*@__PURE__*/ derived({
437
+ minValue: (inst) => {
438
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
439
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
440
+ },
441
+ maxValue: (inst) => {
442
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
443
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
444
+ },
445
+ isInt: (inst) => {
446
+ const { isInt, multipleOf } = aggregateChecks(inst);
447
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
448
+ },
449
+ format: (inst) => aggregateChecks(inst).format ?? null
450
+ }, {
451
+ gt(value, params) {
452
+ return this.check(_gt(value, params));
453
+ },
454
+ gte(value, params) {
455
+ return this.check(_gte(value, params));
456
+ },
457
+ min(value, params) {
458
+ return this.check(_gte(value, params));
459
+ },
460
+ lt(value, params) {
461
+ return this.check(_lt(value, params));
462
+ },
463
+ lte(value, params) {
464
+ return this.check(_lte(value, params));
465
+ },
466
+ max(value, params) {
467
+ return this.check(_lte(value, params));
468
+ },
469
+ int(params) {
470
+ return this.check(int(params));
471
+ },
472
+ safe(params) {
473
+ return this.check(int(params));
474
+ },
475
+ positive(params) {
476
+ return this.check(_gt(0, params));
477
+ },
478
+ nonnegative(params) {
479
+ return this.check(_gte(0, params));
480
+ },
481
+ negative(params) {
482
+ return this.check(_lt(0, params));
483
+ },
484
+ nonpositive(params) {
485
+ return this.check(_lte(0, params));
486
+ },
487
+ multipleOf(value, params) {
488
+ return this.check(_multipleOf(value, params));
489
+ },
490
+ step(value, params) {
491
+ return this.check(_multipleOf(value, params));
492
+ },
493
+ finite() {
494
+ return this;
495
+ }
496
+ }));
497
+ function number(params) {
498
+ return _number(ZodNumber, params);
499
+ }
500
+ const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
501
+ $ZodNumberFormat.init(inst, def);
502
+ ZodNumber.init(inst, def);
503
+ });
504
+ function int(params) {
505
+ return _int(ZodNumberFormat, params);
506
+ }
507
+ const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
508
+ $ZodBoolean.init(inst, def);
509
+ ZodType.init(inst, def);
510
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
511
+ });
512
+ function boolean(params) {
513
+ return _boolean(ZodBoolean, params);
514
+ }
515
+ const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
516
+ $ZodUnknown.init(inst, def);
517
+ ZodType.init(inst, def);
518
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
519
+ });
520
+ function unknown() {
521
+ return _unknown(ZodUnknown);
522
+ }
523
+ const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
524
+ $ZodNever.init(inst, def);
525
+ ZodType.init(inst, def);
526
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
527
+ });
528
+ function never(params) {
529
+ return _never(ZodNever, params);
530
+ }
531
+ const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
532
+ _ensureDefaultMemoizer();
533
+ $ZodArray.init(inst, def);
534
+ ZodType.init(inst, def);
535
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
536
+ inst.element = def.element;
537
+ }, {
538
+ min(n, params) {
539
+ return this.check(_minLength(n, params));
540
+ },
541
+ nonempty(params) {
542
+ return this.check(_minLength(1, params));
543
+ },
544
+ max(n, params) {
545
+ return this.check(_maxLength(n, params));
546
+ },
547
+ length(n, params) {
548
+ return this.check(_length(n, params));
549
+ },
550
+ unwrap() {
551
+ return this.element;
552
+ }
553
+ });
554
+ function array(element, params) {
555
+ return _array(ZodArray, element, params);
556
+ }
557
+ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
558
+ _ensureDefaultMemoizer();
559
+ $ZodObjectJIT.init(inst, def);
560
+ ZodType.init(inst, def);
561
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
562
+ installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
563
+ }, {
564
+ keyof() {
565
+ return _enum(Object.keys(this._zod.def.shape));
566
+ },
567
+ catchall(catchall) {
568
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
569
+ },
570
+ passthrough() {
571
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
572
+ },
573
+ loose() {
574
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
575
+ },
576
+ strict() {
577
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
578
+ },
579
+ strip() {
580
+ return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
581
+ },
582
+ extend(incoming) {
583
+ return extend(this, incoming);
584
+ },
585
+ safeExtend(incoming) {
586
+ return safeExtend(this, incoming);
587
+ },
588
+ merge(other) {
589
+ return merge(this, other);
590
+ },
591
+ pick(mask) {
592
+ return pick(this, mask);
593
+ },
594
+ omit(mask) {
595
+ return omit(this, mask);
596
+ },
597
+ partial(...args) {
598
+ return partial(ZodOptional, this, args[0]);
599
+ },
600
+ exactPartial(...args) {
601
+ return partial(ZodExactOptional, this, args[0], "exactPartial");
602
+ },
603
+ required(...args) {
604
+ return required(ZodNonOptional, this, args[0]);
605
+ }
606
+ });
607
+ function looseObject(shape, params) {
608
+ return new ZodObject({
609
+ type: "object",
610
+ shape,
611
+ catchall: unknown(),
612
+ ...normalizeParams(params)
613
+ });
614
+ }
615
+ const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
616
+ $ZodUnion.init(inst, def);
617
+ ZodType.init(inst, def);
618
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
619
+ inst.options = def.options;
620
+ });
621
+ function union(options, params) {
622
+ return new ZodUnion({
623
+ type: "union",
624
+ options,
625
+ ...normalizeParams(params)
626
+ });
627
+ }
628
+ const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
629
+ $ZodIntersection.init(inst, def);
630
+ ZodType.init(inst, def);
631
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
632
+ });
633
+ function intersection(left, right) {
634
+ return new ZodIntersection({
635
+ type: "intersection",
636
+ left,
637
+ right
638
+ });
639
+ }
640
+ const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
641
+ _ensureDefaultMemoizer();
642
+ $ZodRecord.init(inst, def);
643
+ ZodType.init(inst, def);
644
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
645
+ inst.keyType = def.keyType;
646
+ inst.valueType = def.valueType;
647
+ });
648
+ function record(keyType, valueType, params) {
649
+ if (!valueType || !valueType._zod) return new ZodRecord({
650
+ type: "record",
651
+ keyType: string(),
652
+ valueType: keyType,
653
+ ...normalizeParams(valueType)
654
+ });
655
+ return new ZodRecord({
656
+ type: "record",
657
+ keyType,
658
+ valueType,
659
+ ...normalizeParams(params)
660
+ });
661
+ }
662
+ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
663
+ $ZodEnum.init(inst, def);
664
+ ZodType.init(inst, def);
665
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
666
+ inst.enum = def.entries;
667
+ inst.options = [...inst._zod.values];
668
+ const keys = new Set(Object.keys(def.entries));
669
+ inst.extract = (values, params) => {
670
+ const newEntries = {};
671
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
672
+ else throw new Error(`Key ${value} not found in enum`);
673
+ return new ZodEnum({
674
+ ...def,
675
+ checks: [],
676
+ ...normalizeParams(params),
677
+ entries: newEntries
678
+ });
679
+ };
680
+ inst.exclude = (values, params) => {
681
+ const newEntries = { ...def.entries };
682
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
683
+ else throw new Error(`Key ${value} not found in enum`);
684
+ return new ZodEnum({
685
+ ...def,
686
+ checks: [],
687
+ ...normalizeParams(params),
688
+ entries: newEntries
689
+ });
690
+ };
691
+ });
692
+ function _enum(values, params) {
693
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
694
+ return new ZodEnum({
695
+ type: "enum",
696
+ entries,
697
+ ...normalizeParams(params)
698
+ });
699
+ }
700
+ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
701
+ _ensureDefaultMemoizer();
702
+ $ZodTransform.init(inst, def);
703
+ ZodType.init(inst, def);
704
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
705
+ inst._zod.parse = (payload, _ctx) => {
706
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
707
+ payload.addIssue = (issue$1) => {
708
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
709
+ else {
710
+ const _issue = issue$1;
711
+ if (_issue.fatal) _issue.continue = false;
712
+ _issue.code ?? (_issue.code = "custom");
713
+ if (!("input" in _issue)) _issue.input = payload.value;
714
+ _issue.inst ?? (_issue.inst = inst);
715
+ payload.issues.push(issue(_issue));
716
+ }
717
+ };
718
+ const output = def.transform(payload.value, payload);
719
+ if (output instanceof Promise) return output.then((output) => {
720
+ payload.value = output;
721
+ return payload;
722
+ });
723
+ payload.value = output;
724
+ return payload;
725
+ };
726
+ });
727
+ function transform(fn) {
728
+ return new ZodTransform({
729
+ type: "transform",
730
+ transform: fn
731
+ });
732
+ }
733
+ const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
734
+ $ZodOptional.init(inst, def);
735
+ ZodType.init(inst, def);
736
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
737
+ inst.unwrap = () => inst._zod.def.innerType;
738
+ });
739
+ function optional(innerType) {
740
+ return new ZodOptional({
741
+ type: "optional",
742
+ innerType
743
+ });
744
+ }
745
+ const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
746
+ $ZodExactOptional.init(inst, def);
747
+ ZodType.init(inst, def);
748
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
749
+ inst.unwrap = () => inst._zod.def.innerType;
750
+ });
751
+ function exactOptional(innerType) {
752
+ return new ZodExactOptional({
753
+ type: "optional",
754
+ innerType
755
+ });
756
+ }
757
+ const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
758
+ $ZodNullable.init(inst, def);
759
+ ZodType.init(inst, def);
760
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
761
+ inst.unwrap = () => inst._zod.def.innerType;
762
+ });
763
+ function nullable(innerType) {
764
+ return new ZodNullable({
765
+ type: "nullable",
766
+ innerType
767
+ });
768
+ }
769
+ const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
770
+ $ZodDefault.init(inst, def);
771
+ ZodType.init(inst, def);
772
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
773
+ inst.unwrap = () => inst._zod.def.innerType;
774
+ inst.removeDefault = inst.unwrap;
775
+ });
776
+ function _default(innerType, defaultValue) {
777
+ return new ZodDefault({
778
+ type: "default",
779
+ innerType,
780
+ get defaultValue() {
781
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
782
+ }
783
+ });
784
+ }
785
+ const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
786
+ $ZodPrefault.init(inst, def);
787
+ ZodType.init(inst, def);
788
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
789
+ inst.unwrap = () => inst._zod.def.innerType;
790
+ });
791
+ function prefault(innerType, defaultValue) {
792
+ return new ZodPrefault({
793
+ type: "prefault",
794
+ innerType,
795
+ get defaultValue() {
796
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
797
+ }
798
+ });
799
+ }
800
+ const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
801
+ $ZodNonOptional.init(inst, def);
802
+ ZodType.init(inst, def);
803
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
804
+ inst.unwrap = () => inst._zod.def.innerType;
805
+ });
806
+ function nonoptional(innerType, params) {
807
+ return new ZodNonOptional({
808
+ type: "nonoptional",
809
+ innerType,
810
+ ...normalizeParams(params)
811
+ });
812
+ }
813
+ const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
814
+ $ZodCatch.init(inst, def);
815
+ ZodType.init(inst, def);
816
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
817
+ inst.unwrap = () => inst._zod.def.innerType;
818
+ inst.removeCatch = inst.unwrap;
819
+ });
820
+ function _catch(innerType, catchValue) {
821
+ return new ZodCatch({
822
+ type: "catch",
823
+ innerType,
824
+ catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
825
+ });
826
+ }
827
+ const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
828
+ $ZodPipe.init(inst, def);
829
+ ZodType.init(inst, def);
830
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
831
+ inst.in = def.in;
832
+ inst.out = def.out;
833
+ });
834
+ function pipe(in_, out) {
835
+ return new ZodPipe({
836
+ type: "pipe",
837
+ in: in_,
838
+ out
839
+ });
840
+ }
841
+ const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
842
+ $ZodReadonly.init(inst, def);
843
+ ZodType.init(inst, def);
844
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
845
+ inst.unwrap = () => inst._zod.def.innerType;
846
+ });
847
+ function readonly(innerType) {
848
+ return new ZodReadonly({
849
+ type: "readonly",
850
+ innerType
851
+ });
852
+ }
853
+ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
854
+ $ZodCustom.init(inst, def);
855
+ ZodType.init(inst, def);
856
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
857
+ });
858
+ function refine(fn, _params = {}) {
859
+ return _refine(ZodCustom, fn, _params);
860
+ }
861
+ function superRefine(fn, params) {
862
+ return _superRefine(fn, params);
863
+ }
864
+ //#endregion
865
+ export { ZodArray, ZodBase64, ZodBase64URL, ZodBoolean, ZodCIDRv4, ZodCIDRv6, ZodCUID, ZodCUID2, ZodCatch, ZodCustom, ZodDefault, ZodE164, ZodEmail, ZodEmoji, ZodEnum, ZodExactOptional, ZodGUID, ZodIPv4, ZodIPv6, ZodISODate, ZodISODateTime, ZodISODuration, ZodISOTime, ZodIntersection, ZodJWT, ZodKSUID, ZodNanoID, ZodNever, ZodNonOptional, ZodNullable, ZodNumber, ZodNumberFormat, ZodObject, ZodOptional, ZodPipe, ZodPrefault, ZodReadonly, ZodRecord, ZodString, ZodStringFormat, ZodTransform, ZodType, ZodULID, ZodURL, ZodUUID, ZodUnion, ZodUnknown, ZodXID, _ZodString, _default, array, boolean, _catch as catch, _enum as enum, exactOptional, int, intersection, looseObject, never, nonoptional, nullable, number, optional, pipe, prefault, readonly, record, refine, string, superRefine, transform, union, unknown };