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