@windrun-huaiin/backend-core 13.0.0 → 14.1.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 (110) hide show
  1. package/dist/_virtual/index.js +7 -3
  2. package/dist/_virtual/index.mjs +5 -3
  3. package/dist/_virtual/index2.js +2 -6
  4. package/dist/_virtual/index2.mjs +2 -6
  5. package/dist/index.js +3 -1
  6. package/dist/index.mjs +2 -2
  7. package/dist/lib/index.js +3 -1
  8. package/dist/lib/index.mjs +2 -2
  9. package/dist/lib/stripe-config.d.ts +1 -1
  10. package/dist/lib/stripe-config.d.ts.map +1 -1
  11. package/dist/lib/stripe-config.js +25 -16
  12. package/dist/lib/stripe-config.mjs +25 -16
  13. package/dist/lib/upstash/qstash.d.ts.map +1 -1
  14. package/dist/lib/upstash/qstash.js +66 -62
  15. package/dist/lib/upstash/qstash.mjs +67 -63
  16. package/dist/lib/upstash/redis-counter.d.ts.map +1 -1
  17. package/dist/lib/upstash/redis-counter.js +9 -24
  18. package/dist/lib/upstash/redis-counter.mjs +10 -25
  19. package/dist/lib/upstash/redis-favorite.d.ts.map +1 -1
  20. package/dist/lib/upstash/redis-favorite.js +22 -36
  21. package/dist/lib/upstash/redis-favorite.mjs +23 -37
  22. package/dist/lib/upstash/redis-like.d.ts.map +1 -1
  23. package/dist/lib/upstash/redis-like.js +22 -36
  24. package/dist/lib/upstash/redis-like.mjs +23 -37
  25. package/dist/lib/upstash/redis-lock.d.ts.map +1 -1
  26. package/dist/lib/upstash/redis-lock.js +22 -38
  27. package/dist/lib/upstash/redis-lock.mjs +23 -39
  28. package/dist/lib/upstash/redis-structures.d.ts.map +1 -1
  29. package/dist/lib/upstash/redis-structures.js +77 -113
  30. package/dist/lib/upstash/redis-structures.mjs +78 -114
  31. package/dist/lib/upstash-config.d.ts +9 -1
  32. package/dist/lib/upstash-config.d.ts.map +1 -1
  33. package/dist/lib/upstash-config.js +221 -27
  34. package/dist/lib/upstash-config.mjs +220 -28
  35. package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.js → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js} +897 -468
  36. package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.mjs → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs} +895 -468
  37. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.js → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.js} +657 -40
  38. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.mjs → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.mjs} +657 -41
  39. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.js +6 -5
  40. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.mjs +2 -2
  41. package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js +1 -1
  42. package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +1 -1
  43. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js +6 -6
  44. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js +1 -1
  45. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js +2 -2
  46. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js +3 -1
  47. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js +3 -1
  48. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js +1 -1
  49. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js +3 -1
  50. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js +7 -5
  51. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js +3 -1
  52. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js +3 -1
  53. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js +3 -1
  54. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js +3 -1
  55. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js +3 -1
  56. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js +4 -2
  57. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js +3 -1
  58. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js +3 -1
  59. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js +1 -1
  60. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js +3 -1
  61. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js +3 -1
  62. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js +6 -4
  63. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js +6 -4
  64. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js +7 -5
  65. package/dist/services/stripe/webhook-handler.js +4 -2
  66. package/dist/services/stripe/webhook-handler.mjs +3 -1
  67. package/package.json +5 -5
  68. package/src/lib/stripe-config.ts +27 -15
  69. package/src/lib/upstash/qstash.ts +64 -62
  70. package/src/lib/upstash/redis-counter.ts +10 -26
  71. package/src/lib/upstash/redis-favorite.ts +23 -42
  72. package/src/lib/upstash/redis-like.ts +23 -42
  73. package/src/lib/upstash/redis-lock.ts +23 -49
  74. package/src/lib/upstash/redis-structures.ts +82 -131
  75. package/src/lib/upstash-config.ts +231 -24
  76. package/src/services/stripe/webhook-handler.ts +3 -1
  77. package/dist/_virtual/index3.js +0 -5
  78. package/dist/_virtual/index3.mjs +0 -3
  79. package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.js +0 -191
  80. package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.mjs +0 -189
  81. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +0 -54
  82. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +0 -51
  83. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +0 -44
  84. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +0 -35
  85. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +0 -31
  86. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +0 -18
  87. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +0 -587
  88. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +0 -527
  89. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +0 -447
  90. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +0 -399
  91. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +0 -245
  92. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +0 -232
  93. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +0 -68
  94. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +0 -62
  95. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +0 -39
  96. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +0 -37
  97. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +0 -80
  98. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +0 -75
  99. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +0 -101
  100. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +0 -86
  101. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +0 -102
  102. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +0 -76
  103. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +0 -56
  104. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +0 -52
  105. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +0 -1205
  106. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +0 -1157
  107. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +0 -407
  108. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +0 -374
  109. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +0 -9
  110. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +0 -7
@@ -1,399 +0,0 @@
1
- import { $ZodCheckOverwrite, $ZodCheckRegex, $ZodCheckIncludes, $ZodCheckStartsWith, $ZodCheckEndsWith, $ZodCheckMinLength, $ZodCheckMaxLength, $ZodCheckLengthEquals, $ZodCheckLowerCase, $ZodCheckUpperCase, $ZodCheck } from './checks.mjs';
2
- import { normalizeParams, issue } from './util.mjs';
3
-
4
- function _string(Class, params) {
5
- return new Class({
6
- type: "string",
7
- ...normalizeParams(params),
8
- });
9
- }
10
- function _email(Class, params) {
11
- return new Class({
12
- type: "string",
13
- format: "email",
14
- check: "string_format",
15
- abort: false,
16
- ...normalizeParams(params),
17
- });
18
- }
19
- function _guid(Class, params) {
20
- return new Class({
21
- type: "string",
22
- format: "guid",
23
- check: "string_format",
24
- abort: false,
25
- ...normalizeParams(params),
26
- });
27
- }
28
- function _uuid(Class, params) {
29
- return new Class({
30
- type: "string",
31
- format: "uuid",
32
- check: "string_format",
33
- abort: false,
34
- ...normalizeParams(params),
35
- });
36
- }
37
- function _uuidv4(Class, params) {
38
- return new Class({
39
- type: "string",
40
- format: "uuid",
41
- check: "string_format",
42
- abort: false,
43
- version: "v4",
44
- ...normalizeParams(params),
45
- });
46
- }
47
- function _uuidv6(Class, params) {
48
- return new Class({
49
- type: "string",
50
- format: "uuid",
51
- check: "string_format",
52
- abort: false,
53
- version: "v6",
54
- ...normalizeParams(params),
55
- });
56
- }
57
- function _uuidv7(Class, params) {
58
- return new Class({
59
- type: "string",
60
- format: "uuid",
61
- check: "string_format",
62
- abort: false,
63
- version: "v7",
64
- ...normalizeParams(params),
65
- });
66
- }
67
- function _url(Class, params) {
68
- return new Class({
69
- type: "string",
70
- format: "url",
71
- check: "string_format",
72
- abort: false,
73
- ...normalizeParams(params),
74
- });
75
- }
76
- function _emoji(Class, params) {
77
- return new Class({
78
- type: "string",
79
- format: "emoji",
80
- check: "string_format",
81
- abort: false,
82
- ...normalizeParams(params),
83
- });
84
- }
85
- function _nanoid(Class, params) {
86
- return new Class({
87
- type: "string",
88
- format: "nanoid",
89
- check: "string_format",
90
- abort: false,
91
- ...normalizeParams(params),
92
- });
93
- }
94
- function _cuid(Class, params) {
95
- return new Class({
96
- type: "string",
97
- format: "cuid",
98
- check: "string_format",
99
- abort: false,
100
- ...normalizeParams(params),
101
- });
102
- }
103
- function _cuid2(Class, params) {
104
- return new Class({
105
- type: "string",
106
- format: "cuid2",
107
- check: "string_format",
108
- abort: false,
109
- ...normalizeParams(params),
110
- });
111
- }
112
- function _ulid(Class, params) {
113
- return new Class({
114
- type: "string",
115
- format: "ulid",
116
- check: "string_format",
117
- abort: false,
118
- ...normalizeParams(params),
119
- });
120
- }
121
- function _xid(Class, params) {
122
- return new Class({
123
- type: "string",
124
- format: "xid",
125
- check: "string_format",
126
- abort: false,
127
- ...normalizeParams(params),
128
- });
129
- }
130
- function _ksuid(Class, params) {
131
- return new Class({
132
- type: "string",
133
- format: "ksuid",
134
- check: "string_format",
135
- abort: false,
136
- ...normalizeParams(params),
137
- });
138
- }
139
- function _ipv4(Class, params) {
140
- return new Class({
141
- type: "string",
142
- format: "ipv4",
143
- check: "string_format",
144
- abort: false,
145
- ...normalizeParams(params),
146
- });
147
- }
148
- function _ipv6(Class, params) {
149
- return new Class({
150
- type: "string",
151
- format: "ipv6",
152
- check: "string_format",
153
- abort: false,
154
- ...normalizeParams(params),
155
- });
156
- }
157
- function _cidrv4(Class, params) {
158
- return new Class({
159
- type: "string",
160
- format: "cidrv4",
161
- check: "string_format",
162
- abort: false,
163
- ...normalizeParams(params),
164
- });
165
- }
166
- function _cidrv6(Class, params) {
167
- return new Class({
168
- type: "string",
169
- format: "cidrv6",
170
- check: "string_format",
171
- abort: false,
172
- ...normalizeParams(params),
173
- });
174
- }
175
- function _base64(Class, params) {
176
- return new Class({
177
- type: "string",
178
- format: "base64",
179
- check: "string_format",
180
- abort: false,
181
- ...normalizeParams(params),
182
- });
183
- }
184
- function _base64url(Class, params) {
185
- return new Class({
186
- type: "string",
187
- format: "base64url",
188
- check: "string_format",
189
- abort: false,
190
- ...normalizeParams(params),
191
- });
192
- }
193
- function _e164(Class, params) {
194
- return new Class({
195
- type: "string",
196
- format: "e164",
197
- check: "string_format",
198
- abort: false,
199
- ...normalizeParams(params),
200
- });
201
- }
202
- function _jwt(Class, params) {
203
- return new Class({
204
- type: "string",
205
- format: "jwt",
206
- check: "string_format",
207
- abort: false,
208
- ...normalizeParams(params),
209
- });
210
- }
211
- function _isoDateTime(Class, params) {
212
- return new Class({
213
- type: "string",
214
- format: "datetime",
215
- check: "string_format",
216
- offset: false,
217
- local: false,
218
- precision: null,
219
- ...normalizeParams(params),
220
- });
221
- }
222
- function _isoDate(Class, params) {
223
- return new Class({
224
- type: "string",
225
- format: "date",
226
- check: "string_format",
227
- ...normalizeParams(params),
228
- });
229
- }
230
- function _isoTime(Class, params) {
231
- return new Class({
232
- type: "string",
233
- format: "time",
234
- check: "string_format",
235
- precision: null,
236
- ...normalizeParams(params),
237
- });
238
- }
239
- function _isoDuration(Class, params) {
240
- return new Class({
241
- type: "string",
242
- format: "duration",
243
- check: "string_format",
244
- ...normalizeParams(params),
245
- });
246
- }
247
- function _unknown(Class) {
248
- return new Class({
249
- type: "unknown",
250
- });
251
- }
252
- function _never(Class, params) {
253
- return new Class({
254
- type: "never",
255
- ...normalizeParams(params),
256
- });
257
- }
258
- function _maxLength(maximum, params) {
259
- const ch = new $ZodCheckMaxLength({
260
- check: "max_length",
261
- ...normalizeParams(params),
262
- maximum,
263
- });
264
- return ch;
265
- }
266
- function _minLength(minimum, params) {
267
- return new $ZodCheckMinLength({
268
- check: "min_length",
269
- ...normalizeParams(params),
270
- minimum,
271
- });
272
- }
273
- function _length(length, params) {
274
- return new $ZodCheckLengthEquals({
275
- check: "length_equals",
276
- ...normalizeParams(params),
277
- length,
278
- });
279
- }
280
- function _regex(pattern, params) {
281
- return new $ZodCheckRegex({
282
- check: "string_format",
283
- format: "regex",
284
- ...normalizeParams(params),
285
- pattern,
286
- });
287
- }
288
- function _lowercase(params) {
289
- return new $ZodCheckLowerCase({
290
- check: "string_format",
291
- format: "lowercase",
292
- ...normalizeParams(params),
293
- });
294
- }
295
- function _uppercase(params) {
296
- return new $ZodCheckUpperCase({
297
- check: "string_format",
298
- format: "uppercase",
299
- ...normalizeParams(params),
300
- });
301
- }
302
- function _includes(includes, params) {
303
- return new $ZodCheckIncludes({
304
- check: "string_format",
305
- format: "includes",
306
- ...normalizeParams(params),
307
- includes,
308
- });
309
- }
310
- function _startsWith(prefix, params) {
311
- return new $ZodCheckStartsWith({
312
- check: "string_format",
313
- format: "starts_with",
314
- ...normalizeParams(params),
315
- prefix,
316
- });
317
- }
318
- function _endsWith(suffix, params) {
319
- return new $ZodCheckEndsWith({
320
- check: "string_format",
321
- format: "ends_with",
322
- ...normalizeParams(params),
323
- suffix,
324
- });
325
- }
326
- function _overwrite(tx) {
327
- return new $ZodCheckOverwrite({
328
- check: "overwrite",
329
- tx,
330
- });
331
- }
332
- // normalize
333
- function _normalize(form) {
334
- return _overwrite((input) => input.normalize(form));
335
- }
336
- // trim
337
- function _trim() {
338
- return _overwrite((input) => input.trim());
339
- }
340
- // toLowerCase
341
- function _toLowerCase() {
342
- return _overwrite((input) => input.toLowerCase());
343
- }
344
- // toUpperCase
345
- function _toUpperCase() {
346
- return _overwrite((input) => input.toUpperCase());
347
- }
348
- function _array(Class, element, params) {
349
- return new Class({
350
- type: "array",
351
- element,
352
- // get element() {
353
- // return element;
354
- // },
355
- ...normalizeParams(params),
356
- });
357
- }
358
- // same as _custom but defaults to abort:false
359
- function _refine(Class, fn, _params) {
360
- const schema = new Class({
361
- type: "custom",
362
- check: "custom",
363
- fn: fn,
364
- ...normalizeParams(_params),
365
- });
366
- return schema;
367
- }
368
- function _superRefine(fn) {
369
- const ch = _check((payload) => {
370
- payload.addIssue = (issue$1) => {
371
- if (typeof issue$1 === "string") {
372
- payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
373
- }
374
- else {
375
- // for Zod 3 backwards compatibility
376
- const _issue = issue$1;
377
- if (_issue.fatal)
378
- _issue.continue = false;
379
- _issue.code ?? (_issue.code = "custom");
380
- _issue.input ?? (_issue.input = payload.value);
381
- _issue.inst ?? (_issue.inst = ch);
382
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort); // abort is always undefined, so this is always true...
383
- payload.issues.push(issue(_issue));
384
- }
385
- };
386
- return fn(payload.value, payload);
387
- });
388
- return ch;
389
- }
390
- function _check(fn, params) {
391
- const ch = new $ZodCheck({
392
- check: "custom",
393
- ...normalizeParams(params),
394
- });
395
- ch._zod.check = fn;
396
- return ch;
397
- }
398
-
399
- export { _array, _base64, _base64url, _check, _cidrv4, _cidrv6, _cuid, _cuid2, _e164, _email, _emoji, _endsWith, _guid, _includes, _ipv4, _ipv6, _isoDate, _isoDateTime, _isoDuration, _isoTime, _jwt, _ksuid, _length, _lowercase, _maxLength, _minLength, _nanoid, _never, _normalize, _overwrite, _refine, _regex, _startsWith, _string, _superRefine, _toLowerCase, _toUpperCase, _trim, _ulid, _unknown, _uppercase, _url, _uuid, _uuidv4, _uuidv6, _uuidv7, _xid };
@@ -1,245 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('./core.js');
4
- var regexes = require('./regexes.js');
5
- var util = require('./util.js');
6
-
7
- // import { $ZodType } from "./schemas.js";
8
- const $ZodCheck = /*@__PURE__*/ core.$constructor("$ZodCheck", (inst, def) => {
9
- var _a;
10
- inst._zod ?? (inst._zod = {});
11
- inst._zod.def = def;
12
- (_a = inst._zod).onattach ?? (_a.onattach = []);
13
- });
14
- const $ZodCheckMaxLength = /*@__PURE__*/ core.$constructor("$ZodCheckMaxLength", (inst, def) => {
15
- var _a;
16
- $ZodCheck.init(inst, def);
17
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
18
- const val = payload.value;
19
- return !util.nullish(val) && val.length !== undefined;
20
- });
21
- inst._zod.onattach.push((inst) => {
22
- const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
23
- if (def.maximum < curr)
24
- inst._zod.bag.maximum = def.maximum;
25
- });
26
- inst._zod.check = (payload) => {
27
- const input = payload.value;
28
- const length = input.length;
29
- if (length <= def.maximum)
30
- return;
31
- const origin = util.getLengthableOrigin(input);
32
- payload.issues.push({
33
- origin,
34
- code: "too_big",
35
- maximum: def.maximum,
36
- inclusive: true,
37
- input,
38
- inst,
39
- continue: !def.abort,
40
- });
41
- };
42
- });
43
- const $ZodCheckMinLength = /*@__PURE__*/ core.$constructor("$ZodCheckMinLength", (inst, def) => {
44
- var _a;
45
- $ZodCheck.init(inst, def);
46
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
47
- const val = payload.value;
48
- return !util.nullish(val) && val.length !== undefined;
49
- });
50
- inst._zod.onattach.push((inst) => {
51
- const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
52
- if (def.minimum > curr)
53
- inst._zod.bag.minimum = def.minimum;
54
- });
55
- inst._zod.check = (payload) => {
56
- const input = payload.value;
57
- const length = input.length;
58
- if (length >= def.minimum)
59
- return;
60
- const origin = util.getLengthableOrigin(input);
61
- payload.issues.push({
62
- origin,
63
- code: "too_small",
64
- minimum: def.minimum,
65
- inclusive: true,
66
- input,
67
- inst,
68
- continue: !def.abort,
69
- });
70
- };
71
- });
72
- const $ZodCheckLengthEquals = /*@__PURE__*/ core.$constructor("$ZodCheckLengthEquals", (inst, def) => {
73
- var _a;
74
- $ZodCheck.init(inst, def);
75
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
76
- const val = payload.value;
77
- return !util.nullish(val) && val.length !== undefined;
78
- });
79
- inst._zod.onattach.push((inst) => {
80
- const bag = inst._zod.bag;
81
- bag.minimum = def.length;
82
- bag.maximum = def.length;
83
- bag.length = def.length;
84
- });
85
- inst._zod.check = (payload) => {
86
- const input = payload.value;
87
- const length = input.length;
88
- if (length === def.length)
89
- return;
90
- const origin = util.getLengthableOrigin(input);
91
- const tooBig = length > def.length;
92
- payload.issues.push({
93
- origin,
94
- ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
95
- inclusive: true,
96
- exact: true,
97
- input: payload.value,
98
- inst,
99
- continue: !def.abort,
100
- });
101
- };
102
- });
103
- const $ZodCheckStringFormat = /*@__PURE__*/ core.$constructor("$ZodCheckStringFormat", (inst, def) => {
104
- var _a, _b;
105
- $ZodCheck.init(inst, def);
106
- inst._zod.onattach.push((inst) => {
107
- const bag = inst._zod.bag;
108
- bag.format = def.format;
109
- if (def.pattern) {
110
- bag.patterns ?? (bag.patterns = new Set());
111
- bag.patterns.add(def.pattern);
112
- }
113
- });
114
- if (def.pattern)
115
- (_a = inst._zod).check ?? (_a.check = (payload) => {
116
- def.pattern.lastIndex = 0;
117
- if (def.pattern.test(payload.value))
118
- return;
119
- payload.issues.push({
120
- origin: "string",
121
- code: "invalid_format",
122
- format: def.format,
123
- input: payload.value,
124
- ...(def.pattern ? { pattern: def.pattern.toString() } : {}),
125
- inst,
126
- continue: !def.abort,
127
- });
128
- });
129
- else
130
- (_b = inst._zod).check ?? (_b.check = () => { });
131
- });
132
- const $ZodCheckRegex = /*@__PURE__*/ core.$constructor("$ZodCheckRegex", (inst, def) => {
133
- $ZodCheckStringFormat.init(inst, def);
134
- inst._zod.check = (payload) => {
135
- def.pattern.lastIndex = 0;
136
- if (def.pattern.test(payload.value))
137
- return;
138
- payload.issues.push({
139
- origin: "string",
140
- code: "invalid_format",
141
- format: "regex",
142
- input: payload.value,
143
- pattern: def.pattern.toString(),
144
- inst,
145
- continue: !def.abort,
146
- });
147
- };
148
- });
149
- const $ZodCheckLowerCase = /*@__PURE__*/ core.$constructor("$ZodCheckLowerCase", (inst, def) => {
150
- def.pattern ?? (def.pattern = regexes.lowercase);
151
- $ZodCheckStringFormat.init(inst, def);
152
- });
153
- const $ZodCheckUpperCase = /*@__PURE__*/ core.$constructor("$ZodCheckUpperCase", (inst, def) => {
154
- def.pattern ?? (def.pattern = regexes.uppercase);
155
- $ZodCheckStringFormat.init(inst, def);
156
- });
157
- const $ZodCheckIncludes = /*@__PURE__*/ core.$constructor("$ZodCheckIncludes", (inst, def) => {
158
- $ZodCheck.init(inst, def);
159
- const escapedRegex = util.escapeRegex(def.includes);
160
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
161
- def.pattern = pattern;
162
- inst._zod.onattach.push((inst) => {
163
- const bag = inst._zod.bag;
164
- bag.patterns ?? (bag.patterns = new Set());
165
- bag.patterns.add(pattern);
166
- });
167
- inst._zod.check = (payload) => {
168
- if (payload.value.includes(def.includes, def.position))
169
- return;
170
- payload.issues.push({
171
- origin: "string",
172
- code: "invalid_format",
173
- format: "includes",
174
- includes: def.includes,
175
- input: payload.value,
176
- inst,
177
- continue: !def.abort,
178
- });
179
- };
180
- });
181
- const $ZodCheckStartsWith = /*@__PURE__*/ core.$constructor("$ZodCheckStartsWith", (inst, def) => {
182
- $ZodCheck.init(inst, def);
183
- const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
184
- def.pattern ?? (def.pattern = pattern);
185
- inst._zod.onattach.push((inst) => {
186
- const bag = inst._zod.bag;
187
- bag.patterns ?? (bag.patterns = new Set());
188
- bag.patterns.add(pattern);
189
- });
190
- inst._zod.check = (payload) => {
191
- if (payload.value.startsWith(def.prefix))
192
- return;
193
- payload.issues.push({
194
- origin: "string",
195
- code: "invalid_format",
196
- format: "starts_with",
197
- prefix: def.prefix,
198
- input: payload.value,
199
- inst,
200
- continue: !def.abort,
201
- });
202
- };
203
- });
204
- const $ZodCheckEndsWith = /*@__PURE__*/ core.$constructor("$ZodCheckEndsWith", (inst, def) => {
205
- $ZodCheck.init(inst, def);
206
- const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
207
- def.pattern ?? (def.pattern = pattern);
208
- inst._zod.onattach.push((inst) => {
209
- const bag = inst._zod.bag;
210
- bag.patterns ?? (bag.patterns = new Set());
211
- bag.patterns.add(pattern);
212
- });
213
- inst._zod.check = (payload) => {
214
- if (payload.value.endsWith(def.suffix))
215
- return;
216
- payload.issues.push({
217
- origin: "string",
218
- code: "invalid_format",
219
- format: "ends_with",
220
- suffix: def.suffix,
221
- input: payload.value,
222
- inst,
223
- continue: !def.abort,
224
- });
225
- };
226
- });
227
- const $ZodCheckOverwrite = /*@__PURE__*/ core.$constructor("$ZodCheckOverwrite", (inst, def) => {
228
- $ZodCheck.init(inst, def);
229
- inst._zod.check = (payload) => {
230
- payload.value = def.tx(payload.value);
231
- };
232
- });
233
-
234
- exports.$ZodCheck = $ZodCheck;
235
- exports.$ZodCheckEndsWith = $ZodCheckEndsWith;
236
- exports.$ZodCheckIncludes = $ZodCheckIncludes;
237
- exports.$ZodCheckLengthEquals = $ZodCheckLengthEquals;
238
- exports.$ZodCheckLowerCase = $ZodCheckLowerCase;
239
- exports.$ZodCheckMaxLength = $ZodCheckMaxLength;
240
- exports.$ZodCheckMinLength = $ZodCheckMinLength;
241
- exports.$ZodCheckOverwrite = $ZodCheckOverwrite;
242
- exports.$ZodCheckRegex = $ZodCheckRegex;
243
- exports.$ZodCheckStartsWith = $ZodCheckStartsWith;
244
- exports.$ZodCheckStringFormat = $ZodCheckStringFormat;
245
- exports.$ZodCheckUpperCase = $ZodCheckUpperCase;