@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,232 +0,0 @@
1
- import { $constructor } from './core.mjs';
2
- import { lowercase, uppercase } from './regexes.mjs';
3
- import { escapeRegex, nullish, getLengthableOrigin } from './util.mjs';
4
-
5
- // import { $ZodType } from "./schemas.js";
6
- const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
7
- var _a;
8
- inst._zod ?? (inst._zod = {});
9
- inst._zod.def = def;
10
- (_a = inst._zod).onattach ?? (_a.onattach = []);
11
- });
12
- const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
13
- var _a;
14
- $ZodCheck.init(inst, def);
15
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
16
- const val = payload.value;
17
- return !nullish(val) && val.length !== undefined;
18
- });
19
- inst._zod.onattach.push((inst) => {
20
- const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
21
- if (def.maximum < curr)
22
- inst._zod.bag.maximum = def.maximum;
23
- });
24
- inst._zod.check = (payload) => {
25
- const input = payload.value;
26
- const length = input.length;
27
- if (length <= def.maximum)
28
- return;
29
- const origin = getLengthableOrigin(input);
30
- payload.issues.push({
31
- origin,
32
- code: "too_big",
33
- maximum: def.maximum,
34
- inclusive: true,
35
- input,
36
- inst,
37
- continue: !def.abort,
38
- });
39
- };
40
- });
41
- const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
42
- var _a;
43
- $ZodCheck.init(inst, def);
44
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
45
- const val = payload.value;
46
- return !nullish(val) && val.length !== undefined;
47
- });
48
- inst._zod.onattach.push((inst) => {
49
- const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
50
- if (def.minimum > curr)
51
- inst._zod.bag.minimum = def.minimum;
52
- });
53
- inst._zod.check = (payload) => {
54
- const input = payload.value;
55
- const length = input.length;
56
- if (length >= def.minimum)
57
- return;
58
- const origin = getLengthableOrigin(input);
59
- payload.issues.push({
60
- origin,
61
- code: "too_small",
62
- minimum: def.minimum,
63
- inclusive: true,
64
- input,
65
- inst,
66
- continue: !def.abort,
67
- });
68
- };
69
- });
70
- const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
71
- var _a;
72
- $ZodCheck.init(inst, def);
73
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
74
- const val = payload.value;
75
- return !nullish(val) && val.length !== undefined;
76
- });
77
- inst._zod.onattach.push((inst) => {
78
- const bag = inst._zod.bag;
79
- bag.minimum = def.length;
80
- bag.maximum = def.length;
81
- bag.length = def.length;
82
- });
83
- inst._zod.check = (payload) => {
84
- const input = payload.value;
85
- const length = input.length;
86
- if (length === def.length)
87
- return;
88
- const origin = getLengthableOrigin(input);
89
- const tooBig = length > def.length;
90
- payload.issues.push({
91
- origin,
92
- ...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
93
- inclusive: true,
94
- exact: true,
95
- input: payload.value,
96
- inst,
97
- continue: !def.abort,
98
- });
99
- };
100
- });
101
- const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
102
- var _a, _b;
103
- $ZodCheck.init(inst, def);
104
- inst._zod.onattach.push((inst) => {
105
- const bag = inst._zod.bag;
106
- bag.format = def.format;
107
- if (def.pattern) {
108
- bag.patterns ?? (bag.patterns = new Set());
109
- bag.patterns.add(def.pattern);
110
- }
111
- });
112
- if (def.pattern)
113
- (_a = inst._zod).check ?? (_a.check = (payload) => {
114
- def.pattern.lastIndex = 0;
115
- if (def.pattern.test(payload.value))
116
- return;
117
- payload.issues.push({
118
- origin: "string",
119
- code: "invalid_format",
120
- format: def.format,
121
- input: payload.value,
122
- ...(def.pattern ? { pattern: def.pattern.toString() } : {}),
123
- inst,
124
- continue: !def.abort,
125
- });
126
- });
127
- else
128
- (_b = inst._zod).check ?? (_b.check = () => { });
129
- });
130
- const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
131
- $ZodCheckStringFormat.init(inst, def);
132
- inst._zod.check = (payload) => {
133
- def.pattern.lastIndex = 0;
134
- if (def.pattern.test(payload.value))
135
- return;
136
- payload.issues.push({
137
- origin: "string",
138
- code: "invalid_format",
139
- format: "regex",
140
- input: payload.value,
141
- pattern: def.pattern.toString(),
142
- inst,
143
- continue: !def.abort,
144
- });
145
- };
146
- });
147
- const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
148
- def.pattern ?? (def.pattern = lowercase);
149
- $ZodCheckStringFormat.init(inst, def);
150
- });
151
- const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
152
- def.pattern ?? (def.pattern = uppercase);
153
- $ZodCheckStringFormat.init(inst, def);
154
- });
155
- const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
156
- $ZodCheck.init(inst, def);
157
- const escapedRegex = escapeRegex(def.includes);
158
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
159
- def.pattern = pattern;
160
- inst._zod.onattach.push((inst) => {
161
- const bag = inst._zod.bag;
162
- bag.patterns ?? (bag.patterns = new Set());
163
- bag.patterns.add(pattern);
164
- });
165
- inst._zod.check = (payload) => {
166
- if (payload.value.includes(def.includes, def.position))
167
- return;
168
- payload.issues.push({
169
- origin: "string",
170
- code: "invalid_format",
171
- format: "includes",
172
- includes: def.includes,
173
- input: payload.value,
174
- inst,
175
- continue: !def.abort,
176
- });
177
- };
178
- });
179
- const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
180
- $ZodCheck.init(inst, def);
181
- const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
182
- def.pattern ?? (def.pattern = pattern);
183
- inst._zod.onattach.push((inst) => {
184
- const bag = inst._zod.bag;
185
- bag.patterns ?? (bag.patterns = new Set());
186
- bag.patterns.add(pattern);
187
- });
188
- inst._zod.check = (payload) => {
189
- if (payload.value.startsWith(def.prefix))
190
- return;
191
- payload.issues.push({
192
- origin: "string",
193
- code: "invalid_format",
194
- format: "starts_with",
195
- prefix: def.prefix,
196
- input: payload.value,
197
- inst,
198
- continue: !def.abort,
199
- });
200
- };
201
- });
202
- const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
203
- $ZodCheck.init(inst, def);
204
- const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
205
- def.pattern ?? (def.pattern = pattern);
206
- inst._zod.onattach.push((inst) => {
207
- const bag = inst._zod.bag;
208
- bag.patterns ?? (bag.patterns = new Set());
209
- bag.patterns.add(pattern);
210
- });
211
- inst._zod.check = (payload) => {
212
- if (payload.value.endsWith(def.suffix))
213
- return;
214
- payload.issues.push({
215
- origin: "string",
216
- code: "invalid_format",
217
- format: "ends_with",
218
- suffix: def.suffix,
219
- input: payload.value,
220
- inst,
221
- continue: !def.abort,
222
- });
223
- };
224
- });
225
- const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
226
- $ZodCheck.init(inst, def);
227
- inst._zod.check = (payload) => {
228
- payload.value = def.tx(payload.value);
229
- };
230
- });
231
-
232
- export { $ZodCheck, $ZodCheckEndsWith, $ZodCheckIncludes, $ZodCheckLengthEquals, $ZodCheckLowerCase, $ZodCheckMaxLength, $ZodCheckMinLength, $ZodCheckOverwrite, $ZodCheckRegex, $ZodCheckStartsWith, $ZodCheckStringFormat, $ZodCheckUpperCase };
@@ -1,68 +0,0 @@
1
- 'use strict';
2
-
3
- /** A special constant with type `never` */
4
- function $constructor(name, initializer, params) {
5
- function init(inst, def) {
6
- var _a;
7
- Object.defineProperty(inst, "_zod", {
8
- value: inst._zod ?? {},
9
- enumerable: false,
10
- });
11
- (_a = inst._zod).traits ?? (_a.traits = new Set());
12
- inst._zod.traits.add(name);
13
- initializer(inst, def);
14
- // support prototype modifications
15
- for (const k in _.prototype) {
16
- if (!(k in inst))
17
- Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
18
- }
19
- inst._zod.constr = _;
20
- inst._zod.def = def;
21
- }
22
- // doesn't work if Parent has a constructor with arguments
23
- const Parent = params?.Parent ?? Object;
24
- class Definition extends Parent {
25
- }
26
- Object.defineProperty(Definition, "name", { value: name });
27
- function _(def) {
28
- var _a;
29
- const inst = params?.Parent ? new Definition() : this;
30
- init(inst, def);
31
- (_a = inst._zod).deferred ?? (_a.deferred = []);
32
- for (const fn of inst._zod.deferred) {
33
- fn();
34
- }
35
- return inst;
36
- }
37
- Object.defineProperty(_, "init", { value: init });
38
- Object.defineProperty(_, Symbol.hasInstance, {
39
- value: (inst) => {
40
- if (params?.Parent && inst instanceof params.Parent)
41
- return true;
42
- return inst?._zod?.traits?.has(name);
43
- },
44
- });
45
- Object.defineProperty(_, "name", { value: name });
46
- return _;
47
- }
48
- class $ZodAsyncError extends Error {
49
- constructor() {
50
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
51
- }
52
- }
53
- class $ZodEncodeError extends Error {
54
- constructor(name) {
55
- super(`Encountered unidirectional transform during encode: ${name}`);
56
- this.name = "ZodEncodeError";
57
- }
58
- }
59
- const globalConfig = {};
60
- function config(newConfig) {
61
- return globalConfig;
62
- }
63
-
64
- exports.$ZodAsyncError = $ZodAsyncError;
65
- exports.$ZodEncodeError = $ZodEncodeError;
66
- exports.$constructor = $constructor;
67
- exports.config = config;
68
- exports.globalConfig = globalConfig;
@@ -1,62 +0,0 @@
1
- /** A special constant with type `never` */
2
- function $constructor(name, initializer, params) {
3
- function init(inst, def) {
4
- var _a;
5
- Object.defineProperty(inst, "_zod", {
6
- value: inst._zod ?? {},
7
- enumerable: false,
8
- });
9
- (_a = inst._zod).traits ?? (_a.traits = new Set());
10
- inst._zod.traits.add(name);
11
- initializer(inst, def);
12
- // support prototype modifications
13
- for (const k in _.prototype) {
14
- if (!(k in inst))
15
- Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
16
- }
17
- inst._zod.constr = _;
18
- inst._zod.def = def;
19
- }
20
- // doesn't work if Parent has a constructor with arguments
21
- const Parent = params?.Parent ?? Object;
22
- class Definition extends Parent {
23
- }
24
- Object.defineProperty(Definition, "name", { value: name });
25
- function _(def) {
26
- var _a;
27
- const inst = params?.Parent ? new Definition() : this;
28
- init(inst, def);
29
- (_a = inst._zod).deferred ?? (_a.deferred = []);
30
- for (const fn of inst._zod.deferred) {
31
- fn();
32
- }
33
- return inst;
34
- }
35
- Object.defineProperty(_, "init", { value: init });
36
- Object.defineProperty(_, Symbol.hasInstance, {
37
- value: (inst) => {
38
- if (params?.Parent && inst instanceof params.Parent)
39
- return true;
40
- return inst?._zod?.traits?.has(name);
41
- },
42
- });
43
- Object.defineProperty(_, "name", { value: name });
44
- return _;
45
- }
46
- class $ZodAsyncError extends Error {
47
- constructor() {
48
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
49
- }
50
- }
51
- class $ZodEncodeError extends Error {
52
- constructor(name) {
53
- super(`Encountered unidirectional transform during encode: ${name}`);
54
- this.name = "ZodEncodeError";
55
- }
56
- }
57
- const globalConfig = {};
58
- function config(newConfig) {
59
- return globalConfig;
60
- }
61
-
62
- export { $ZodAsyncError, $ZodEncodeError, $constructor, config, globalConfig };
@@ -1,39 +0,0 @@
1
- 'use strict';
2
-
3
- class Doc {
4
- constructor(args = []) {
5
- this.content = [];
6
- this.indent = 0;
7
- if (this)
8
- this.args = args;
9
- }
10
- indented(fn) {
11
- this.indent += 1;
12
- fn(this);
13
- this.indent -= 1;
14
- }
15
- write(arg) {
16
- if (typeof arg === "function") {
17
- arg(this, { execution: "sync" });
18
- arg(this, { execution: "async" });
19
- return;
20
- }
21
- const content = arg;
22
- const lines = content.split("\n").filter((x) => x);
23
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
24
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
25
- for (const line of dedented) {
26
- this.content.push(line);
27
- }
28
- }
29
- compile() {
30
- const F = Function;
31
- const args = this?.args;
32
- const content = this?.content ?? [``];
33
- const lines = [...content.map((x) => ` ${x}`)];
34
- // console.log(lines.join("\n"));
35
- return new F(...args, lines.join("\n"));
36
- }
37
- }
38
-
39
- exports.Doc = Doc;
@@ -1,37 +0,0 @@
1
- class Doc {
2
- constructor(args = []) {
3
- this.content = [];
4
- this.indent = 0;
5
- if (this)
6
- this.args = args;
7
- }
8
- indented(fn) {
9
- this.indent += 1;
10
- fn(this);
11
- this.indent -= 1;
12
- }
13
- write(arg) {
14
- if (typeof arg === "function") {
15
- arg(this, { execution: "sync" });
16
- arg(this, { execution: "async" });
17
- return;
18
- }
19
- const content = arg;
20
- const lines = content.split("\n").filter((x) => x);
21
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
22
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
23
- for (const line of dedented) {
24
- this.content.push(line);
25
- }
26
- }
27
- compile() {
28
- const F = Function;
29
- const args = this?.args;
30
- const content = this?.content ?? [``];
31
- const lines = [...content.map((x) => ` ${x}`)];
32
- // console.log(lines.join("\n"));
33
- return new F(...args, lines.join("\n"));
34
- }
35
- }
36
-
37
- export { Doc };
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('./core.js');
4
- var util = require('./util.js');
5
-
6
- const initializer = (inst, def) => {
7
- inst.name = "$ZodError";
8
- Object.defineProperty(inst, "_zod", {
9
- value: inst._zod,
10
- enumerable: false,
11
- });
12
- Object.defineProperty(inst, "issues", {
13
- value: def,
14
- enumerable: false,
15
- });
16
- inst.message = JSON.stringify(def, util.jsonStringifyReplacer, 2);
17
- Object.defineProperty(inst, "toString", {
18
- value: () => inst.message,
19
- enumerable: false,
20
- });
21
- };
22
- const $ZodError = core.$constructor("$ZodError", initializer);
23
- const $ZodRealError = core.$constructor("$ZodError", initializer, { Parent: Error });
24
- function flattenError(error, mapper = (issue) => issue.message) {
25
- const fieldErrors = {};
26
- const formErrors = [];
27
- for (const sub of error.issues) {
28
- if (sub.path.length > 0) {
29
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
30
- fieldErrors[sub.path[0]].push(mapper(sub));
31
- }
32
- else {
33
- formErrors.push(mapper(sub));
34
- }
35
- }
36
- return { formErrors, fieldErrors };
37
- }
38
- function formatError(error, mapper = (issue) => issue.message) {
39
- const fieldErrors = { _errors: [] };
40
- const processError = (error) => {
41
- for (const issue of error.issues) {
42
- if (issue.code === "invalid_union" && issue.errors.length) {
43
- issue.errors.map((issues) => processError({ issues }));
44
- }
45
- else if (issue.code === "invalid_key") {
46
- processError({ issues: issue.issues });
47
- }
48
- else if (issue.code === "invalid_element") {
49
- processError({ issues: issue.issues });
50
- }
51
- else if (issue.path.length === 0) {
52
- fieldErrors._errors.push(mapper(issue));
53
- }
54
- else {
55
- let curr = fieldErrors;
56
- let i = 0;
57
- while (i < issue.path.length) {
58
- const el = issue.path[i];
59
- const terminal = i === issue.path.length - 1;
60
- if (!terminal) {
61
- curr[el] = curr[el] || { _errors: [] };
62
- }
63
- else {
64
- curr[el] = curr[el] || { _errors: [] };
65
- curr[el]._errors.push(mapper(issue));
66
- }
67
- curr = curr[el];
68
- i++;
69
- }
70
- }
71
- }
72
- };
73
- processError(error);
74
- return fieldErrors;
75
- }
76
-
77
- exports.$ZodError = $ZodError;
78
- exports.$ZodRealError = $ZodRealError;
79
- exports.flattenError = flattenError;
80
- exports.formatError = formatError;
@@ -1,75 +0,0 @@
1
- import { $constructor } from './core.mjs';
2
- import { jsonStringifyReplacer } from './util.mjs';
3
-
4
- const initializer = (inst, def) => {
5
- inst.name = "$ZodError";
6
- Object.defineProperty(inst, "_zod", {
7
- value: inst._zod,
8
- enumerable: false,
9
- });
10
- Object.defineProperty(inst, "issues", {
11
- value: def,
12
- enumerable: false,
13
- });
14
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
15
- Object.defineProperty(inst, "toString", {
16
- value: () => inst.message,
17
- enumerable: false,
18
- });
19
- };
20
- const $ZodError = $constructor("$ZodError", initializer);
21
- const $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
22
- function flattenError(error, mapper = (issue) => issue.message) {
23
- const fieldErrors = {};
24
- const formErrors = [];
25
- for (const sub of error.issues) {
26
- if (sub.path.length > 0) {
27
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
28
- fieldErrors[sub.path[0]].push(mapper(sub));
29
- }
30
- else {
31
- formErrors.push(mapper(sub));
32
- }
33
- }
34
- return { formErrors, fieldErrors };
35
- }
36
- function formatError(error, mapper = (issue) => issue.message) {
37
- const fieldErrors = { _errors: [] };
38
- const processError = (error) => {
39
- for (const issue of error.issues) {
40
- if (issue.code === "invalid_union" && issue.errors.length) {
41
- issue.errors.map((issues) => processError({ issues }));
42
- }
43
- else if (issue.code === "invalid_key") {
44
- processError({ issues: issue.issues });
45
- }
46
- else if (issue.code === "invalid_element") {
47
- processError({ issues: issue.issues });
48
- }
49
- else if (issue.path.length === 0) {
50
- fieldErrors._errors.push(mapper(issue));
51
- }
52
- else {
53
- let curr = fieldErrors;
54
- let i = 0;
55
- while (i < issue.path.length) {
56
- const el = issue.path[i];
57
- const terminal = i === issue.path.length - 1;
58
- if (!terminal) {
59
- curr[el] = curr[el] || { _errors: [] };
60
- }
61
- else {
62
- curr[el] = curr[el] || { _errors: [] };
63
- curr[el]._errors.push(mapper(issue));
64
- }
65
- curr = curr[el];
66
- i++;
67
- }
68
- }
69
- }
70
- };
71
- processError(error);
72
- return fieldErrors;
73
- }
74
-
75
- export { $ZodError, $ZodRealError, flattenError, formatError };
@@ -1,101 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('./core.js');
4
- var errors = require('./errors.js');
5
- var util = require('./util.js');
6
-
7
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
8
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
9
- const result = schema._zod.run({ value, issues: [] }, ctx);
10
- if (result instanceof Promise) {
11
- throw new core.$ZodAsyncError();
12
- }
13
- if (result.issues.length) {
14
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
15
- util.captureStackTrace(e, _params?.callee);
16
- throw e;
17
- }
18
- return result.value;
19
- };
20
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
21
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
22
- let result = schema._zod.run({ value, issues: [] }, ctx);
23
- if (result instanceof Promise)
24
- result = await result;
25
- if (result.issues.length) {
26
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
27
- util.captureStackTrace(e, params?.callee);
28
- throw e;
29
- }
30
- return result.value;
31
- };
32
- const _safeParse = (_Err) => (schema, value, _ctx) => {
33
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
34
- const result = schema._zod.run({ value, issues: [] }, ctx);
35
- if (result instanceof Promise) {
36
- throw new core.$ZodAsyncError();
37
- }
38
- return result.issues.length
39
- ? {
40
- success: false,
41
- error: new (_Err ?? errors.$ZodError)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
42
- }
43
- : { success: true, data: result.value };
44
- };
45
- const safeParse = /* @__PURE__*/ _safeParse(errors.$ZodRealError);
46
- const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
47
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
48
- let result = schema._zod.run({ value, issues: [] }, ctx);
49
- if (result instanceof Promise)
50
- result = await result;
51
- return result.issues.length
52
- ? {
53
- success: false,
54
- error: new _Err(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
55
- }
56
- : { success: true, data: result.value };
57
- };
58
- const safeParseAsync = /* @__PURE__*/ _safeParseAsync(errors.$ZodRealError);
59
- const _encode = (_Err) => (schema, value, _ctx) => {
60
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
61
- return _parse(_Err)(schema, value, ctx);
62
- };
63
- const _decode = (_Err) => (schema, value, _ctx) => {
64
- return _parse(_Err)(schema, value, _ctx);
65
- };
66
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
67
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
68
- return _parseAsync(_Err)(schema, value, ctx);
69
- };
70
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
71
- return _parseAsync(_Err)(schema, value, _ctx);
72
- };
73
- const _safeEncode = (_Err) => (schema, value, _ctx) => {
74
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
75
- return _safeParse(_Err)(schema, value, ctx);
76
- };
77
- const _safeDecode = (_Err) => (schema, value, _ctx) => {
78
- return _safeParse(_Err)(schema, value, _ctx);
79
- };
80
- const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
81
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
82
- return _safeParseAsync(_Err)(schema, value, ctx);
83
- };
84
- const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
85
- return _safeParseAsync(_Err)(schema, value, _ctx);
86
- };
87
-
88
- exports._decode = _decode;
89
- exports._decodeAsync = _decodeAsync;
90
- exports._encode = _encode;
91
- exports._encodeAsync = _encodeAsync;
92
- exports._parse = _parse;
93
- exports._parseAsync = _parseAsync;
94
- exports._safeDecode = _safeDecode;
95
- exports._safeDecodeAsync = _safeDecodeAsync;
96
- exports._safeEncode = _safeEncode;
97
- exports._safeEncodeAsync = _safeEncodeAsync;
98
- exports._safeParse = _safeParse;
99
- exports._safeParseAsync = _safeParseAsync;
100
- exports.safeParse = safeParse;
101
- exports.safeParseAsync = safeParseAsync;