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