@windrun-huaiin/backend-core 10.0.1

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 (198) hide show
  1. package/LICENSE +21 -0
  2. package/dist/app/api/stripe/checkout/route.d.ts +19 -0
  3. package/dist/app/api/stripe/checkout/route.d.ts.map +1 -0
  4. package/dist/app/api/stripe/checkout/route.js +120 -0
  5. package/dist/app/api/stripe/checkout/route.mjs +118 -0
  6. package/dist/app/api/stripe/customer-portal/route.d.ts +11 -0
  7. package/dist/app/api/stripe/customer-portal/route.d.ts.map +1 -0
  8. package/dist/app/api/stripe/customer-portal/route.js +73 -0
  9. package/dist/app/api/stripe/customer-portal/route.mjs +71 -0
  10. package/dist/app/api/user/anonymous/init/route.d.ts +7 -0
  11. package/dist/app/api/user/anonymous/init/route.d.ts.map +1 -0
  12. package/dist/app/api/user/anonymous/init/route.js +210 -0
  13. package/dist/app/api/user/anonymous/init/route.mjs +208 -0
  14. package/dist/app/api/webhook/clerk/user/route.d.ts +7 -0
  15. package/dist/app/api/webhook/clerk/user/route.d.ts.map +1 -0
  16. package/dist/app/api/webhook/clerk/user/route.js +202 -0
  17. package/dist/app/api/webhook/clerk/user/route.mjs +200 -0
  18. package/dist/app/api/webhook/stripe/route.d.ts +8 -0
  19. package/dist/app/api/webhook/stripe/route.d.ts.map +1 -0
  20. package/dist/app/api/webhook/stripe/route.js +70 -0
  21. package/dist/app/api/webhook/stripe/route.mjs +67 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +83 -0
  25. package/dist/index.mjs +18 -0
  26. package/dist/lib/auth-utils.d.ts +46 -0
  27. package/dist/lib/auth-utils.d.ts.map +1 -0
  28. package/dist/lib/auth-utils.js +107 -0
  29. package/dist/lib/auth-utils.mjs +102 -0
  30. package/dist/lib/credit-init.d.ts +8 -0
  31. package/dist/lib/credit-init.d.ts.map +1 -0
  32. package/dist/lib/credit-init.js +16 -0
  33. package/dist/lib/credit-init.mjs +10 -0
  34. package/dist/lib/index.d.ts +5 -0
  35. package/dist/lib/index.d.ts.map +1 -0
  36. package/dist/lib/index.js +31 -0
  37. package/dist/lib/index.mjs +4 -0
  38. package/dist/lib/money-price-config.d.ts +51 -0
  39. package/dist/lib/money-price-config.d.ts.map +1 -0
  40. package/dist/lib/money-price-config.js +156 -0
  41. package/dist/lib/money-price-config.mjs +151 -0
  42. package/dist/lib/stripe-config.d.ts +31 -0
  43. package/dist/lib/stripe-config.d.ts.map +1 -0
  44. package/dist/lib/stripe-config.js +278 -0
  45. package/dist/lib/stripe-config.mjs +268 -0
  46. package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js +48 -0
  47. package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs +45 -0
  48. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +54 -0
  49. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +51 -0
  50. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +44 -0
  51. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +35 -0
  52. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +31 -0
  53. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +18 -0
  54. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +587 -0
  55. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +527 -0
  56. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +447 -0
  57. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +399 -0
  58. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +245 -0
  59. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +232 -0
  60. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +68 -0
  61. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +62 -0
  62. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +39 -0
  63. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +37 -0
  64. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +80 -0
  65. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +75 -0
  66. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +101 -0
  67. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +86 -0
  68. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +102 -0
  69. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +76 -0
  70. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +56 -0
  71. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +52 -0
  72. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +1205 -0
  73. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +1157 -0
  74. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +407 -0
  75. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +374 -0
  76. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +9 -0
  77. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +7 -0
  78. package/dist/prisma/client.d.ts +2 -0
  79. package/dist/prisma/client.d.ts.map +1 -0
  80. package/dist/prisma/client.js +12 -0
  81. package/dist/prisma/client.mjs +1 -0
  82. package/dist/prisma/index.d.ts +4 -0
  83. package/dist/prisma/index.d.ts.map +1 -0
  84. package/dist/prisma/index.js +10 -0
  85. package/dist/prisma/index.mjs +2 -0
  86. package/dist/prisma/prisma-transaction-util.d.ts +3 -0
  87. package/dist/prisma/prisma-transaction-util.d.ts.map +1 -0
  88. package/dist/prisma/prisma-transaction-util.js +29 -0
  89. package/dist/prisma/prisma-transaction-util.mjs +27 -0
  90. package/dist/prisma/prisma.d.ts +4 -0
  91. package/dist/prisma/prisma.d.ts.map +1 -0
  92. package/dist/prisma/prisma.js +109 -0
  93. package/dist/prisma/prisma.mjs +106 -0
  94. package/dist/services/aggregate/billing.aggregate.service.d.ts +83 -0
  95. package/dist/services/aggregate/billing.aggregate.service.d.ts.map +1 -0
  96. package/dist/services/aggregate/billing.aggregate.service.js +308 -0
  97. package/dist/services/aggregate/billing.aggregate.service.mjs +306 -0
  98. package/dist/services/aggregate/index.d.ts +3 -0
  99. package/dist/services/aggregate/index.d.ts.map +1 -0
  100. package/dist/services/aggregate/index.js +9 -0
  101. package/dist/services/aggregate/index.mjs +2 -0
  102. package/dist/services/aggregate/user.aggregate.service.d.ts +34 -0
  103. package/dist/services/aggregate/user.aggregate.service.d.ts.map +1 -0
  104. package/dist/services/aggregate/user.aggregate.service.js +136 -0
  105. package/dist/services/aggregate/user.aggregate.service.mjs +133 -0
  106. package/dist/services/context/index.d.ts +2 -0
  107. package/dist/services/context/index.d.ts.map +1 -0
  108. package/dist/services/context/index.js +13 -0
  109. package/dist/services/context/index.mjs +1 -0
  110. package/dist/services/context/user-context-service.d.ts +30 -0
  111. package/dist/services/context/user-context-service.d.ts.map +1 -0
  112. package/dist/services/context/user-context-service.js +170 -0
  113. package/dist/services/context/user-context-service.mjs +162 -0
  114. package/dist/services/database/apilog.service.d.ts +39 -0
  115. package/dist/services/database/apilog.service.d.ts.map +1 -0
  116. package/dist/services/database/apilog.service.js +174 -0
  117. package/dist/services/database/apilog.service.mjs +170 -0
  118. package/dist/services/database/constants.d.ts +73 -0
  119. package/dist/services/database/constants.d.ts.map +1 -0
  120. package/dist/services/database/constants.js +135 -0
  121. package/dist/services/database/constants.mjs +117 -0
  122. package/dist/services/database/credit.service.d.ts +107 -0
  123. package/dist/services/database/credit.service.d.ts.map +1 -0
  124. package/dist/services/database/credit.service.js +515 -0
  125. package/dist/services/database/credit.service.mjs +512 -0
  126. package/dist/services/database/creditAuditLog.service.d.ts +73 -0
  127. package/dist/services/database/creditAuditLog.service.d.ts.map +1 -0
  128. package/dist/services/database/creditAuditLog.service.js +305 -0
  129. package/dist/services/database/creditAuditLog.service.mjs +302 -0
  130. package/dist/services/database/index.d.ts +10 -0
  131. package/dist/services/database/index.d.ts.map +1 -0
  132. package/dist/services/database/index.js +38 -0
  133. package/dist/services/database/index.mjs +8 -0
  134. package/dist/services/database/prisma-model-type.d.ts +3 -0
  135. package/dist/services/database/prisma-model-type.d.ts.map +1 -0
  136. package/dist/services/database/subscription.service.d.ts +48 -0
  137. package/dist/services/database/subscription.service.d.ts.map +1 -0
  138. package/dist/services/database/subscription.service.js +267 -0
  139. package/dist/services/database/subscription.service.mjs +264 -0
  140. package/dist/services/database/transaction.service.d.ts +92 -0
  141. package/dist/services/database/transaction.service.d.ts.map +1 -0
  142. package/dist/services/database/transaction.service.js +326 -0
  143. package/dist/services/database/transaction.service.mjs +323 -0
  144. package/dist/services/database/user.service.d.ts +45 -0
  145. package/dist/services/database/user.service.d.ts.map +1 -0
  146. package/dist/services/database/user.service.js +180 -0
  147. package/dist/services/database/user.service.mjs +177 -0
  148. package/dist/services/database/userBackup.service.d.ts +45 -0
  149. package/dist/services/database/userBackup.service.d.ts.map +1 -0
  150. package/dist/services/database/userBackup.service.js +249 -0
  151. package/dist/services/database/userBackup.service.mjs +246 -0
  152. package/dist/services/stripe/index.d.ts +2 -0
  153. package/dist/services/stripe/index.d.ts.map +1 -0
  154. package/dist/services/stripe/index.js +7 -0
  155. package/dist/services/stripe/index.mjs +1 -0
  156. package/dist/services/stripe/webhook-handler.d.ts +6 -0
  157. package/dist/services/stripe/webhook-handler.d.ts.map +1 -0
  158. package/dist/services/stripe/webhook-handler.js +537 -0
  159. package/dist/services/stripe/webhook-handler.mjs +535 -0
  160. package/migrations/create.sql +176 -0
  161. package/migrations/db.init.sql +13 -0
  162. package/migrations/init-schema.sql +19 -0
  163. package/migrations/purge.sql +27 -0
  164. package/migrations/test-check.sql +167 -0
  165. package/package.json +123 -0
  166. package/prisma/schema.prisma +191 -0
  167. package/src/app/api/stripe/checkout/route.ts +145 -0
  168. package/src/app/api/stripe/customer-portal/route.ts +83 -0
  169. package/src/app/api/user/anonymous/init/route.ts +284 -0
  170. package/src/app/api/webhook/clerk/user/route.ts +249 -0
  171. package/src/app/api/webhook/stripe/route.ts +93 -0
  172. package/src/index.ts +6 -0
  173. package/src/lib/auth-utils.ts +101 -0
  174. package/src/lib/credit-init.ts +9 -0
  175. package/src/lib/index.ts +4 -0
  176. package/src/lib/money-price-config.ts +168 -0
  177. package/src/lib/stripe-config.ts +333 -0
  178. package/src/prisma/client.ts +2 -0
  179. package/src/prisma/index.ts +3 -0
  180. package/src/prisma/prisma-transaction-util.ts +24 -0
  181. package/src/prisma/prisma.ts +122 -0
  182. package/src/services/aggregate/billing.aggregate.service.ts +498 -0
  183. package/src/services/aggregate/index.ts +2 -0
  184. package/src/services/aggregate/user.aggregate.service.ts +168 -0
  185. package/src/services/context/index.ts +1 -0
  186. package/src/services/context/user-context-service.ts +200 -0
  187. package/src/services/database/apilog.service.ts +185 -0
  188. package/src/services/database/constants.ts +148 -0
  189. package/src/services/database/credit.service.ts +747 -0
  190. package/src/services/database/creditAuditLog.service.ts +402 -0
  191. package/src/services/database/index.ts +41 -0
  192. package/src/services/database/prisma-model-type.ts +13 -0
  193. package/src/services/database/subscription.service.ts +319 -0
  194. package/src/services/database/transaction.service.ts +447 -0
  195. package/src/services/database/user.service.ts +218 -0
  196. package/src/services/database/userBackup.service.ts +290 -0
  197. package/src/services/stripe/index.ts +1 -0
  198. package/src/services/stripe/webhook-handler.ts +648 -0
@@ -0,0 +1,527 @@
1
+ import { $constructor, $ZodEncodeError } from '../core/core.mjs';
2
+ import { normalizeParams, defineLazy, extend, safeExtend, merge, pick, omit, partial, required, mergeDefs, clone, shallowClone, issue } from '../core/util.mjs';
3
+ import { $ZodObjectJIT, $ZodOptional, $ZodNonOptional, $ZodString, $ZodType, $ZodEnum, $ZodNullable, $ZodUnion, $ZodIntersection, $ZodPipe, $ZodTransform, $ZodDefault, $ZodPrefault, $ZodCatch, $ZodReadonly, $ZodStringFormat, $ZodEmail, $ZodGUID, $ZodUUID, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodIPv4, $ZodIPv6, $ZodCIDRv4, $ZodCIDRv6, $ZodBase64, $ZodBase64URL, $ZodE164, $ZodJWT, $ZodUnknown, $ZodNever, $ZodArray, $ZodCustom } from '../core/schemas.mjs';
4
+ import { globalRegistry } from '../core/registries.mjs';
5
+ import { _string, _email, _url, _jwt, _emoji, _guid, _uuid, _uuidv4, _uuidv6, _uuidv7, _nanoid, _cuid, _cuid2, _ulid, _base64, _base64url, _xid, _ksuid, _ipv4, _ipv6, _cidrv4, _cidrv6, _e164, _overwrite, _unknown, _never, _regex, _includes, _startsWith, _endsWith, _minLength, _maxLength, _length, _lowercase, _uppercase, _trim, _normalize, _toLowerCase, _toUpperCase, _refine, _superRefine, _array } from '../core/api.mjs';
6
+ import { datetime, date, time, duration } from './iso.mjs';
7
+ import { parse, safeParse, parseAsync, safeParseAsync, encode, decode, encodeAsync, decodeAsync, safeEncode, safeDecode, safeEncodeAsync, safeDecodeAsync } from './parse.mjs';
8
+
9
+ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
10
+ $ZodType.init(inst, def);
11
+ inst.def = def;
12
+ inst.type = def.type;
13
+ Object.defineProperty(inst, "_def", { value: def });
14
+ // base methods
15
+ inst.check = (...checks) => {
16
+ return inst.clone(mergeDefs(def, {
17
+ checks: [
18
+ ...(def.checks ?? []),
19
+ ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
20
+ ],
21
+ }));
22
+ };
23
+ inst.clone = (def, params) => clone(inst, def, params);
24
+ inst.brand = () => inst;
25
+ inst.register = ((reg, meta) => {
26
+ reg.add(inst, meta);
27
+ return inst;
28
+ });
29
+ // parsing
30
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
31
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
32
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
33
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
34
+ inst.spa = inst.safeParseAsync;
35
+ // encoding/decoding
36
+ inst.encode = (data, params) => encode(inst, data, params);
37
+ inst.decode = (data, params) => decode(inst, data, params);
38
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
39
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
40
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
41
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
42
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
43
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
44
+ // refinements
45
+ inst.refine = (check, params) => inst.check(refine(check, params));
46
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
47
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
48
+ // wrappers
49
+ inst.optional = () => optional(inst);
50
+ inst.nullable = () => nullable(inst);
51
+ inst.nullish = () => optional(nullable(inst));
52
+ inst.nonoptional = (params) => nonoptional(inst, params);
53
+ inst.array = () => array(inst);
54
+ inst.or = (arg) => union([inst, arg]);
55
+ inst.and = (arg) => intersection(inst, arg);
56
+ inst.transform = (tx) => pipe(inst, transform(tx));
57
+ inst.default = (def) => _default(inst, def);
58
+ inst.prefault = (def) => prefault(inst, def);
59
+ // inst.coalesce = (def, params) => coalesce(inst, def, params);
60
+ inst.catch = (params) => _catch(inst, params);
61
+ inst.pipe = (target) => pipe(inst, target);
62
+ inst.readonly = () => readonly(inst);
63
+ // meta
64
+ inst.describe = (description) => {
65
+ const cl = inst.clone();
66
+ globalRegistry.add(cl, { description });
67
+ return cl;
68
+ };
69
+ Object.defineProperty(inst, "description", {
70
+ get() {
71
+ return globalRegistry.get(inst)?.description;
72
+ },
73
+ configurable: true,
74
+ });
75
+ inst.meta = (...args) => {
76
+ if (args.length === 0) {
77
+ return globalRegistry.get(inst);
78
+ }
79
+ const cl = inst.clone();
80
+ globalRegistry.add(cl, args[0]);
81
+ return cl;
82
+ };
83
+ // helpers
84
+ inst.isOptional = () => inst.safeParse(undefined).success;
85
+ inst.isNullable = () => inst.safeParse(null).success;
86
+ return inst;
87
+ });
88
+ /** @internal */
89
+ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
90
+ $ZodString.init(inst, def);
91
+ ZodType.init(inst, def);
92
+ const bag = inst._zod.bag;
93
+ inst.format = bag.format ?? null;
94
+ inst.minLength = bag.minimum ?? null;
95
+ inst.maxLength = bag.maximum ?? null;
96
+ // validations
97
+ inst.regex = (...args) => inst.check(_regex(...args));
98
+ inst.includes = (...args) => inst.check(_includes(...args));
99
+ inst.startsWith = (...args) => inst.check(_startsWith(...args));
100
+ inst.endsWith = (...args) => inst.check(_endsWith(...args));
101
+ inst.min = (...args) => inst.check(_minLength(...args));
102
+ inst.max = (...args) => inst.check(_maxLength(...args));
103
+ inst.length = (...args) => inst.check(_length(...args));
104
+ inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
105
+ inst.lowercase = (params) => inst.check(_lowercase(params));
106
+ inst.uppercase = (params) => inst.check(_uppercase(params));
107
+ // transforms
108
+ inst.trim = () => inst.check(_trim());
109
+ inst.normalize = (...args) => inst.check(_normalize(...args));
110
+ inst.toLowerCase = () => inst.check(_toLowerCase());
111
+ inst.toUpperCase = () => inst.check(_toUpperCase());
112
+ });
113
+ const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
114
+ $ZodString.init(inst, def);
115
+ _ZodString.init(inst, def);
116
+ inst.email = (params) => inst.check(_email(ZodEmail, params));
117
+ inst.url = (params) => inst.check(_url(ZodURL, params));
118
+ inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
119
+ inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
120
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
121
+ inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
122
+ inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
123
+ inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
124
+ inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
125
+ inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
126
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
127
+ inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
128
+ inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
129
+ inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
130
+ inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
131
+ inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
132
+ inst.xid = (params) => inst.check(_xid(ZodXID, params));
133
+ inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
134
+ inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
135
+ inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
136
+ inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
137
+ inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
138
+ inst.e164 = (params) => inst.check(_e164(ZodE164, params));
139
+ // iso
140
+ inst.datetime = (params) => inst.check(datetime(params));
141
+ inst.date = (params) => inst.check(date(params));
142
+ inst.time = (params) => inst.check(time(params));
143
+ inst.duration = (params) => inst.check(duration(params));
144
+ });
145
+ function string(params) {
146
+ return _string(ZodString, params);
147
+ }
148
+ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
149
+ $ZodStringFormat.init(inst, def);
150
+ _ZodString.init(inst, def);
151
+ });
152
+ const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
153
+ // ZodStringFormat.init(inst, def);
154
+ $ZodEmail.init(inst, def);
155
+ ZodStringFormat.init(inst, def);
156
+ });
157
+ const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
158
+ // ZodStringFormat.init(inst, def);
159
+ $ZodGUID.init(inst, def);
160
+ ZodStringFormat.init(inst, def);
161
+ });
162
+ const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
163
+ // ZodStringFormat.init(inst, def);
164
+ $ZodUUID.init(inst, def);
165
+ ZodStringFormat.init(inst, def);
166
+ });
167
+ const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
168
+ // ZodStringFormat.init(inst, def);
169
+ $ZodURL.init(inst, def);
170
+ ZodStringFormat.init(inst, def);
171
+ });
172
+ const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
173
+ // ZodStringFormat.init(inst, def);
174
+ $ZodEmoji.init(inst, def);
175
+ ZodStringFormat.init(inst, def);
176
+ });
177
+ const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
178
+ // ZodStringFormat.init(inst, def);
179
+ $ZodNanoID.init(inst, def);
180
+ ZodStringFormat.init(inst, def);
181
+ });
182
+ const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
183
+ // ZodStringFormat.init(inst, def);
184
+ $ZodCUID.init(inst, def);
185
+ ZodStringFormat.init(inst, def);
186
+ });
187
+ const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
188
+ // ZodStringFormat.init(inst, def);
189
+ $ZodCUID2.init(inst, def);
190
+ ZodStringFormat.init(inst, def);
191
+ });
192
+ const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
193
+ // ZodStringFormat.init(inst, def);
194
+ $ZodULID.init(inst, def);
195
+ ZodStringFormat.init(inst, def);
196
+ });
197
+ const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
198
+ // ZodStringFormat.init(inst, def);
199
+ $ZodXID.init(inst, def);
200
+ ZodStringFormat.init(inst, def);
201
+ });
202
+ const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
203
+ // ZodStringFormat.init(inst, def);
204
+ $ZodKSUID.init(inst, def);
205
+ ZodStringFormat.init(inst, def);
206
+ });
207
+ const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
208
+ // ZodStringFormat.init(inst, def);
209
+ $ZodIPv4.init(inst, def);
210
+ ZodStringFormat.init(inst, def);
211
+ });
212
+ const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
213
+ // ZodStringFormat.init(inst, def);
214
+ $ZodIPv6.init(inst, def);
215
+ ZodStringFormat.init(inst, def);
216
+ });
217
+ const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
218
+ $ZodCIDRv4.init(inst, def);
219
+ ZodStringFormat.init(inst, def);
220
+ });
221
+ const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
222
+ $ZodCIDRv6.init(inst, def);
223
+ ZodStringFormat.init(inst, def);
224
+ });
225
+ const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
226
+ // ZodStringFormat.init(inst, def);
227
+ $ZodBase64.init(inst, def);
228
+ ZodStringFormat.init(inst, def);
229
+ });
230
+ const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
231
+ // ZodStringFormat.init(inst, def);
232
+ $ZodBase64URL.init(inst, def);
233
+ ZodStringFormat.init(inst, def);
234
+ });
235
+ const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
236
+ // ZodStringFormat.init(inst, def);
237
+ $ZodE164.init(inst, def);
238
+ ZodStringFormat.init(inst, def);
239
+ });
240
+ const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
241
+ // ZodStringFormat.init(inst, def);
242
+ $ZodJWT.init(inst, def);
243
+ ZodStringFormat.init(inst, def);
244
+ });
245
+ const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
246
+ $ZodUnknown.init(inst, def);
247
+ ZodType.init(inst, def);
248
+ });
249
+ function unknown() {
250
+ return _unknown(ZodUnknown);
251
+ }
252
+ const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
253
+ $ZodNever.init(inst, def);
254
+ ZodType.init(inst, def);
255
+ });
256
+ function never(params) {
257
+ return _never(ZodNever, params);
258
+ }
259
+ const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
260
+ $ZodArray.init(inst, def);
261
+ ZodType.init(inst, def);
262
+ inst.element = def.element;
263
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
264
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
265
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
266
+ inst.length = (len, params) => inst.check(_length(len, params));
267
+ inst.unwrap = () => inst.element;
268
+ });
269
+ function array(element, params) {
270
+ return _array(ZodArray, element, params);
271
+ }
272
+ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
273
+ $ZodObjectJIT.init(inst, def);
274
+ ZodType.init(inst, def);
275
+ defineLazy(inst, "shape", () => {
276
+ return def.shape;
277
+ });
278
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
279
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall });
280
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
281
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
282
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
283
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
284
+ inst.extend = (incoming) => {
285
+ return extend(inst, incoming);
286
+ };
287
+ inst.safeExtend = (incoming) => {
288
+ return safeExtend(inst, incoming);
289
+ };
290
+ inst.merge = (other) => merge(inst, other);
291
+ inst.pick = (mask) => pick(inst, mask);
292
+ inst.omit = (mask) => omit(inst, mask);
293
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
294
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
295
+ });
296
+ function object(shape, params) {
297
+ const def = {
298
+ type: "object",
299
+ shape: shape ?? {},
300
+ ...normalizeParams(params),
301
+ };
302
+ return new ZodObject(def);
303
+ }
304
+ const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
305
+ $ZodUnion.init(inst, def);
306
+ ZodType.init(inst, def);
307
+ inst.options = def.options;
308
+ });
309
+ function union(options, params) {
310
+ return new ZodUnion({
311
+ type: "union",
312
+ options: options,
313
+ ...normalizeParams(params),
314
+ });
315
+ }
316
+ const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
317
+ $ZodIntersection.init(inst, def);
318
+ ZodType.init(inst, def);
319
+ });
320
+ function intersection(left, right) {
321
+ return new ZodIntersection({
322
+ type: "intersection",
323
+ left: left,
324
+ right: right,
325
+ });
326
+ }
327
+ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
328
+ $ZodEnum.init(inst, def);
329
+ ZodType.init(inst, def);
330
+ inst.enum = def.entries;
331
+ inst.options = Object.values(def.entries);
332
+ const keys = new Set(Object.keys(def.entries));
333
+ inst.extract = (values, params) => {
334
+ const newEntries = {};
335
+ for (const value of values) {
336
+ if (keys.has(value)) {
337
+ newEntries[value] = def.entries[value];
338
+ }
339
+ else
340
+ throw new Error(`Key ${value} not found in enum`);
341
+ }
342
+ return new ZodEnum({
343
+ ...def,
344
+ checks: [],
345
+ ...normalizeParams(params),
346
+ entries: newEntries,
347
+ });
348
+ };
349
+ inst.exclude = (values, params) => {
350
+ const newEntries = { ...def.entries };
351
+ for (const value of values) {
352
+ if (keys.has(value)) {
353
+ delete newEntries[value];
354
+ }
355
+ else
356
+ throw new Error(`Key ${value} not found in enum`);
357
+ }
358
+ return new ZodEnum({
359
+ ...def,
360
+ checks: [],
361
+ ...normalizeParams(params),
362
+ entries: newEntries,
363
+ });
364
+ };
365
+ });
366
+ function _enum(values, params) {
367
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
368
+ return new ZodEnum({
369
+ type: "enum",
370
+ entries,
371
+ ...normalizeParams(params),
372
+ });
373
+ }
374
+ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
375
+ $ZodTransform.init(inst, def);
376
+ ZodType.init(inst, def);
377
+ inst._zod.parse = (payload, _ctx) => {
378
+ if (_ctx.direction === "backward") {
379
+ throw new $ZodEncodeError(inst.constructor.name);
380
+ }
381
+ payload.addIssue = (issue$1) => {
382
+ if (typeof issue$1 === "string") {
383
+ payload.issues.push(issue(issue$1, payload.value, def));
384
+ }
385
+ else {
386
+ // for Zod 3 backwards compatibility
387
+ const _issue = issue$1;
388
+ if (_issue.fatal)
389
+ _issue.continue = false;
390
+ _issue.code ?? (_issue.code = "custom");
391
+ _issue.input ?? (_issue.input = payload.value);
392
+ _issue.inst ?? (_issue.inst = inst);
393
+ // _issue.continue ??= true;
394
+ payload.issues.push(issue(_issue));
395
+ }
396
+ };
397
+ const output = def.transform(payload.value, payload);
398
+ if (output instanceof Promise) {
399
+ return output.then((output) => {
400
+ payload.value = output;
401
+ return payload;
402
+ });
403
+ }
404
+ payload.value = output;
405
+ return payload;
406
+ };
407
+ });
408
+ function transform(fn) {
409
+ return new ZodTransform({
410
+ type: "transform",
411
+ transform: fn,
412
+ });
413
+ }
414
+ const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
415
+ $ZodOptional.init(inst, def);
416
+ ZodType.init(inst, def);
417
+ inst.unwrap = () => inst._zod.def.innerType;
418
+ });
419
+ function optional(innerType) {
420
+ return new ZodOptional({
421
+ type: "optional",
422
+ innerType: innerType,
423
+ });
424
+ }
425
+ const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
426
+ $ZodNullable.init(inst, def);
427
+ ZodType.init(inst, def);
428
+ inst.unwrap = () => inst._zod.def.innerType;
429
+ });
430
+ function nullable(innerType) {
431
+ return new ZodNullable({
432
+ type: "nullable",
433
+ innerType: innerType,
434
+ });
435
+ }
436
+ const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
437
+ $ZodDefault.init(inst, def);
438
+ ZodType.init(inst, def);
439
+ inst.unwrap = () => inst._zod.def.innerType;
440
+ inst.removeDefault = inst.unwrap;
441
+ });
442
+ function _default(innerType, defaultValue) {
443
+ return new ZodDefault({
444
+ type: "default",
445
+ innerType: innerType,
446
+ get defaultValue() {
447
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
448
+ },
449
+ });
450
+ }
451
+ const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
452
+ $ZodPrefault.init(inst, def);
453
+ ZodType.init(inst, def);
454
+ inst.unwrap = () => inst._zod.def.innerType;
455
+ });
456
+ function prefault(innerType, defaultValue) {
457
+ return new ZodPrefault({
458
+ type: "prefault",
459
+ innerType: innerType,
460
+ get defaultValue() {
461
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
462
+ },
463
+ });
464
+ }
465
+ const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
466
+ $ZodNonOptional.init(inst, def);
467
+ ZodType.init(inst, def);
468
+ inst.unwrap = () => inst._zod.def.innerType;
469
+ });
470
+ function nonoptional(innerType, params) {
471
+ return new ZodNonOptional({
472
+ type: "nonoptional",
473
+ innerType: innerType,
474
+ ...normalizeParams(params),
475
+ });
476
+ }
477
+ const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
478
+ $ZodCatch.init(inst, def);
479
+ ZodType.init(inst, def);
480
+ inst.unwrap = () => inst._zod.def.innerType;
481
+ inst.removeCatch = inst.unwrap;
482
+ });
483
+ function _catch(innerType, catchValue) {
484
+ return new ZodCatch({
485
+ type: "catch",
486
+ innerType: innerType,
487
+ catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue),
488
+ });
489
+ }
490
+ const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
491
+ $ZodPipe.init(inst, def);
492
+ ZodType.init(inst, def);
493
+ inst.in = def.in;
494
+ inst.out = def.out;
495
+ });
496
+ function pipe(in_, out) {
497
+ return new ZodPipe({
498
+ type: "pipe",
499
+ in: in_,
500
+ out: out,
501
+ // ...util.normalizeParams(params),
502
+ });
503
+ }
504
+ const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
505
+ $ZodReadonly.init(inst, def);
506
+ ZodType.init(inst, def);
507
+ inst.unwrap = () => inst._zod.def.innerType;
508
+ });
509
+ function readonly(innerType) {
510
+ return new ZodReadonly({
511
+ type: "readonly",
512
+ innerType: innerType,
513
+ });
514
+ }
515
+ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
516
+ $ZodCustom.init(inst, def);
517
+ ZodType.init(inst, def);
518
+ });
519
+ function refine(fn, _params = {}) {
520
+ return _refine(ZodCustom, fn, _params);
521
+ }
522
+ // superRefine
523
+ function superRefine(fn) {
524
+ return _superRefine(fn);
525
+ }
526
+
527
+ export { ZodArray, ZodBase64, ZodBase64URL, ZodCIDRv4, ZodCIDRv6, ZodCUID, ZodCUID2, ZodCatch, ZodCustom, ZodDefault, ZodE164, ZodEmail, ZodEmoji, ZodEnum, ZodGUID, ZodIPv4, ZodIPv6, ZodIntersection, ZodJWT, ZodKSUID, ZodNanoID, ZodNever, ZodNonOptional, ZodNullable, ZodObject, ZodOptional, ZodPipe, ZodPrefault, ZodReadonly, ZodString, ZodStringFormat, ZodTransform, ZodType, ZodULID, ZodURL, ZodUUID, ZodUnion, ZodUnknown, ZodXID, _ZodString, _default, array, _catch as catch, _enum as enum, intersection, never, nonoptional, nullable, object, optional, pipe, prefault, readonly, refine, string, superRefine, transform, union, unknown };