matrix-nodejs-homeserver 0.0.0-stage → 0.3.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 +75 -0
- package/README.md +479 -2
- package/dist/adapters/auth.d.ts +50 -0
- package/dist/adapters/auth.js +18 -0
- package/dist/adapters/cluster.d.ts +55 -0
- package/dist/adapters/cluster.js +249 -0
- package/dist/adapters/media.d.ts +50 -0
- package/dist/adapters/media.js +63 -0
- package/dist/adapters/s3.d.ts +33 -0
- package/dist/adapters/s3.js +95 -0
- package/dist/api/account.js +594 -0
- package/dist/api/admin.js +267 -0
- package/dist/api/appservice.js +45 -0
- package/dist/api/backup.js +280 -0
- package/dist/api/federation.js +826 -0
- package/dist/api/filters.js +88 -0
- package/dist/api/index.js +47 -0
- package/dist/api/legacy.js +183 -0
- package/dist/api/media.js +271 -0
- package/dist/api/misc.js +95 -0
- package/dist/api/preview.js +201 -0
- package/dist/api/profile.js +176 -0
- package/dist/api/push.js +202 -0
- package/dist/api/relationships.js +270 -0
- package/dist/api/rooms.js +1487 -0
- package/dist/api/rtc.d.ts +23 -0
- package/dist/api/rtc.js +66 -0
- package/dist/api/search.js +161 -0
- package/dist/api/slidingsync.js +474 -0
- package/dist/api/spaces.js +177 -0
- package/dist/api/sync.js +609 -0
- package/dist/api/threadsubs.js +140 -0
- package/dist/api/threepid.js +155 -0
- package/dist/api/uia.js +127 -0
- package/dist/api/user.js +329 -0
- package/dist/core/admin.d.ts +84 -0
- package/dist/core/admin.js +308 -0
- package/dist/core/adminroom.d.ts +49 -0
- package/dist/core/adminroom.js +483 -0
- package/dist/core/appservices.d.ts +74 -0
- package/dist/core/appservices.js +369 -0
- package/dist/core/audit.d.ts +50 -0
- package/dist/core/audit.js +86 -0
- package/dist/core/auth.d.ts +48 -0
- package/dist/core/auth.js +237 -0
- package/dist/core/authrules.d.ts +4 -0
- package/dist/core/authrules.js +348 -0
- package/dist/core/cluster.d.ts +66 -0
- package/dist/core/cluster.js +191 -0
- package/dist/core/crypto.d.ts +10 -0
- package/dist/core/crypto.js +100 -0
- package/dist/core/delayed.d.ts +39 -0
- package/dist/core/delayed.js +160 -0
- package/dist/core/errors.d.ts +9 -0
- package/dist/core/errors.js +45 -0
- package/dist/core/events.d.ts +32 -0
- package/dist/core/events.js +186 -0
- package/dist/core/glob.js +66 -0
- package/dist/core/identity.d.ts +24 -0
- package/dist/core/identity.js +96 -0
- package/dist/core/ids.js +36 -0
- package/dist/core/invitefilter.js +36 -0
- package/dist/core/json.js +16 -0
- package/dist/core/keys.d.ts +36 -0
- package/dist/core/keys.js +450 -0
- package/dist/core/m.d.ts +209 -0
- package/dist/core/m.js +182 -0
- package/dist/core/notifier.d.ts +17 -0
- package/dist/core/notifier.js +54 -0
- package/dist/core/oauth.d.ts +38 -0
- package/dist/core/oauth.js +108 -0
- package/dist/core/partialstate.d.ts +32 -0
- package/dist/core/partialstate.js +198 -0
- package/dist/core/phone.js +268 -0
- package/dist/core/policy.d.ts +29 -0
- package/dist/core/policy.js +97 -0
- package/dist/core/profile.js +39 -0
- package/dist/core/push.d.ts +46 -0
- package/dist/core/push.js +307 -0
- package/dist/core/pushrules.js +229 -0
- package/dist/core/ratelimit.d.ts +23 -0
- package/dist/core/ratelimit.js +77 -0
- package/dist/core/rooms.d.ts +215 -0
- package/dist/core/rooms.js +1731 -0
- package/dist/core/settings.d.ts +11 -0
- package/dist/core/settings.js +29 -0
- package/dist/core/sso.d.ts +46 -0
- package/dist/core/sso.js +165 -0
- package/dist/core/stateres.d.ts +4 -0
- package/dist/core/stateres.js +209 -0
- package/dist/core/threepid.d.ts +80 -0
- package/dist/core/threepid.js +275 -0
- package/dist/core/typing.d.ts +16 -0
- package/dist/core/typing.js +60 -0
- package/dist/federation/client.d.ts +51 -0
- package/dist/federation/client.js +279 -0
- package/dist/federation/index.d.ts +153 -0
- package/dist/federation/index.js +1059 -0
- package/dist/federation/keyring.d.ts +26 -0
- package/dist/federation/keyring.js +122 -0
- package/dist/federation/sender.d.ts +26 -0
- package/dist/federation/sender.js +164 -0
- package/dist/homeserver.d.ts +224 -0
- package/dist/homeserver.js +302 -0
- package/dist/http/adapters.d.ts +40 -0
- package/dist/http/adapters.js +130 -0
- package/dist/http/handler.d.ts +8 -0
- package/dist/http/handler.js +181 -0
- package/dist/http/input.js +24 -0
- package/dist/http/procedure.js +25 -0
- package/dist/http/router.d.ts +43 -0
- package/dist/http/router.js +56 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +15 -0
- package/dist/storage/memory.d.ts +5 -0
- package/dist/storage/memory.js +122 -0
- package/dist/storage/schema.d.ts +4 -0
- package/dist/storage/schema.js +664 -0
- package/dist/storage/sql.d.ts +72 -0
- package/dist/storage/sql.js +274 -0
- package/dist/storage/types.d.ts +55 -0
- package/dist/vendor/zod/LICENSE +21 -0
- package/dist/vendor/zod/v4/classic/errors.js +54 -0
- package/dist/vendor/zod/v4/classic/parse.js +17 -0
- package/dist/vendor/zod/v4/classic/schemas.js +865 -0
- package/dist/vendor/zod/v4/core/api.js +512 -0
- package/dist/vendor/zod/v4/core/checks.js +300 -0
- package/dist/vendor/zod/v4/core/core.js +109 -0
- package/dist/vendor/zod/v4/core/doc.js +35 -0
- package/dist/vendor/zod/v4/core/errors.js +118 -0
- package/dist/vendor/zod/v4/core/json-schema-processors.js +428 -0
- package/dist/vendor/zod/v4/core/memoizer.js +255 -0
- package/dist/vendor/zod/v4/core/parse.js +206 -0
- package/dist/vendor/zod/v4/core/regexes.js +73 -0
- package/dist/vendor/zod/v4/core/registries.js +48 -0
- package/dist/vendor/zod/v4/core/schemas.js +1378 -0
- package/dist/vendor/zod/v4/core/to-json-schema.js +448 -0
- package/dist/vendor/zod/v4/core/util.js +537 -0
- package/dist/vendor/zod/v4/core/versions.js +8 -0
- package/dist/vendor/zod/v4/locales/en.js +110 -0
- package/package.json +65 -4
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { NUMBER_FORMAT_RANGES, codePointLength, escapeRegex, floatSafeRemainder, getLengthableOrigin, nullish } from "./util.js";
|
|
2
|
+
import { $constructor } from "./core.js";
|
|
3
|
+
import { lowercase, uppercase } from "./regexes.js";
|
|
4
|
+
//#region node_modules/zod/v4/core/checks.js
|
|
5
|
+
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
6
|
+
var _a;
|
|
7
|
+
inst._zod ?? (inst._zod = {});
|
|
8
|
+
inst._zod.def = def;
|
|
9
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
10
|
+
});
|
|
11
|
+
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
|
|
12
|
+
const _whenHasLength = (payload) => {
|
|
13
|
+
const val = payload.value;
|
|
14
|
+
return !nullish(val) && val.length !== void 0;
|
|
15
|
+
};
|
|
16
|
+
const numericOriginMap = {
|
|
17
|
+
number: "number",
|
|
18
|
+
bigint: "bigint",
|
|
19
|
+
object: "date"
|
|
20
|
+
};
|
|
21
|
+
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
22
|
+
$ZodCheck.init(inst, def);
|
|
23
|
+
const origin = numericOriginMap[typeof def.value];
|
|
24
|
+
inst._zod.check = (payload) => {
|
|
25
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
26
|
+
payload.issues.push({
|
|
27
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
28
|
+
code: "too_big",
|
|
29
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
30
|
+
input: payload.value,
|
|
31
|
+
inclusive: def.inclusive,
|
|
32
|
+
inst,
|
|
33
|
+
continue: !def.abort
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
38
|
+
$ZodCheck.init(inst, def);
|
|
39
|
+
const origin = numericOriginMap[typeof def.value];
|
|
40
|
+
inst._zod.check = (payload) => {
|
|
41
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
42
|
+
payload.issues.push({
|
|
43
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
44
|
+
code: "too_small",
|
|
45
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
46
|
+
input: payload.value,
|
|
47
|
+
inclusive: def.inclusive,
|
|
48
|
+
inst,
|
|
49
|
+
continue: !def.abort
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
54
|
+
$ZodCheck.init(inst, def);
|
|
55
|
+
inst._zod.check = (payload) => {
|
|
56
|
+
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
57
|
+
if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
58
|
+
payload.issues.push({
|
|
59
|
+
origin: typeof payload.value,
|
|
60
|
+
code: "not_multiple_of",
|
|
61
|
+
divisor: def.value,
|
|
62
|
+
input: payload.value,
|
|
63
|
+
inst,
|
|
64
|
+
continue: !def.abort
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
69
|
+
$ZodCheck.init(inst, def);
|
|
70
|
+
def.format = def.format || "float64";
|
|
71
|
+
const isInt = def.format?.includes("int");
|
|
72
|
+
const origin = isInt ? "int" : "number";
|
|
73
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
74
|
+
inst._zod.check = (payload) => {
|
|
75
|
+
const input = payload.value;
|
|
76
|
+
if (isInt) {
|
|
77
|
+
if (!Number.isInteger(input)) {
|
|
78
|
+
payload.issues.push({
|
|
79
|
+
expected: origin,
|
|
80
|
+
format: def.format,
|
|
81
|
+
code: "invalid_type",
|
|
82
|
+
continue: false,
|
|
83
|
+
input,
|
|
84
|
+
inst
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!Number.isSafeInteger(input)) {
|
|
89
|
+
if (input > 0) payload.issues.push({
|
|
90
|
+
input,
|
|
91
|
+
code: "too_big",
|
|
92
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
93
|
+
note: "Integers must be within the safe integer range.",
|
|
94
|
+
inst,
|
|
95
|
+
origin,
|
|
96
|
+
inclusive: true,
|
|
97
|
+
continue: !def.abort
|
|
98
|
+
});
|
|
99
|
+
else payload.issues.push({
|
|
100
|
+
input,
|
|
101
|
+
code: "too_small",
|
|
102
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
103
|
+
note: "Integers must be within the safe integer range.",
|
|
104
|
+
inst,
|
|
105
|
+
origin,
|
|
106
|
+
inclusive: true,
|
|
107
|
+
continue: !def.abort
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (input < minimum) payload.issues.push({
|
|
113
|
+
origin: "number",
|
|
114
|
+
input,
|
|
115
|
+
code: "too_small",
|
|
116
|
+
minimum,
|
|
117
|
+
inclusive: true,
|
|
118
|
+
inst,
|
|
119
|
+
continue: !def.abort
|
|
120
|
+
});
|
|
121
|
+
if (input > maximum) payload.issues.push({
|
|
122
|
+
origin: "number",
|
|
123
|
+
input,
|
|
124
|
+
code: "too_big",
|
|
125
|
+
maximum,
|
|
126
|
+
inclusive: true,
|
|
127
|
+
inst,
|
|
128
|
+
continue: !def.abort
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
133
|
+
var _a;
|
|
134
|
+
$ZodCheck.init(inst, def);
|
|
135
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
136
|
+
inst._zod.check = (payload) => {
|
|
137
|
+
const input = payload.value;
|
|
138
|
+
const units = input.length;
|
|
139
|
+
if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
|
|
140
|
+
const origin = getLengthableOrigin(input);
|
|
141
|
+
payload.issues.push({
|
|
142
|
+
origin,
|
|
143
|
+
code: "too_big",
|
|
144
|
+
maximum: def.maximum,
|
|
145
|
+
inclusive: true,
|
|
146
|
+
input,
|
|
147
|
+
inst,
|
|
148
|
+
continue: !def.abort
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
153
|
+
var _a;
|
|
154
|
+
$ZodCheck.init(inst, def);
|
|
155
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
156
|
+
inst._zod.check = (payload) => {
|
|
157
|
+
const input = payload.value;
|
|
158
|
+
const units = input.length;
|
|
159
|
+
if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
|
|
160
|
+
const origin = getLengthableOrigin(input);
|
|
161
|
+
payload.issues.push({
|
|
162
|
+
origin,
|
|
163
|
+
code: "too_small",
|
|
164
|
+
minimum: def.minimum,
|
|
165
|
+
inclusive: true,
|
|
166
|
+
input,
|
|
167
|
+
inst,
|
|
168
|
+
continue: !def.abort
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
173
|
+
var _a;
|
|
174
|
+
$ZodCheck.init(inst, def);
|
|
175
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
176
|
+
inst._zod.check = (payload) => {
|
|
177
|
+
const input = payload.value;
|
|
178
|
+
const units = input.length;
|
|
179
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
180
|
+
if (length === def.length) return;
|
|
181
|
+
const origin = getLengthableOrigin(input);
|
|
182
|
+
const tooBig = length > def.length;
|
|
183
|
+
payload.issues.push({
|
|
184
|
+
origin,
|
|
185
|
+
...tooBig ? {
|
|
186
|
+
code: "too_big",
|
|
187
|
+
maximum: def.length
|
|
188
|
+
} : {
|
|
189
|
+
code: "too_small",
|
|
190
|
+
minimum: def.length
|
|
191
|
+
},
|
|
192
|
+
inclusive: true,
|
|
193
|
+
exact: true,
|
|
194
|
+
input: payload.value,
|
|
195
|
+
inst,
|
|
196
|
+
continue: !def.abort
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
$ZodCheck.init(inst, def);
|
|
203
|
+
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
204
|
+
def.pattern.lastIndex = 0;
|
|
205
|
+
if (def.pattern.test(payload.value)) return;
|
|
206
|
+
payload.issues.push({
|
|
207
|
+
origin: "string",
|
|
208
|
+
code: "invalid_format",
|
|
209
|
+
format: def.format,
|
|
210
|
+
input: payload.value,
|
|
211
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
212
|
+
inst,
|
|
213
|
+
continue: !def.abort
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
else (_b = inst._zod).check ?? (_b.check = () => {});
|
|
217
|
+
});
|
|
218
|
+
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
219
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
220
|
+
inst._zod.check = (payload) => {
|
|
221
|
+
def.pattern.lastIndex = 0;
|
|
222
|
+
if (def.pattern.test(payload.value)) return;
|
|
223
|
+
payload.issues.push({
|
|
224
|
+
origin: "string",
|
|
225
|
+
code: "invalid_format",
|
|
226
|
+
format: "regex",
|
|
227
|
+
input: payload.value,
|
|
228
|
+
pattern: def.pattern.toString(),
|
|
229
|
+
inst,
|
|
230
|
+
continue: !def.abort
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
235
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
236
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
237
|
+
});
|
|
238
|
+
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
239
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
240
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
241
|
+
});
|
|
242
|
+
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
243
|
+
$ZodCheck.init(inst, def);
|
|
244
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
245
|
+
def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
246
|
+
inst._zod.check = (payload) => {
|
|
247
|
+
if (payload.value.includes(def.includes, def.position)) return;
|
|
248
|
+
payload.issues.push({
|
|
249
|
+
origin: "string",
|
|
250
|
+
code: "invalid_format",
|
|
251
|
+
format: "includes",
|
|
252
|
+
includes: def.includes,
|
|
253
|
+
input: payload.value,
|
|
254
|
+
inst,
|
|
255
|
+
continue: !def.abort
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
260
|
+
$ZodCheck.init(inst, def);
|
|
261
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
262
|
+
def.pattern ?? (def.pattern = pattern);
|
|
263
|
+
inst._zod.check = (payload) => {
|
|
264
|
+
if (payload.value.startsWith(def.prefix)) return;
|
|
265
|
+
payload.issues.push({
|
|
266
|
+
origin: "string",
|
|
267
|
+
code: "invalid_format",
|
|
268
|
+
format: "starts_with",
|
|
269
|
+
prefix: def.prefix,
|
|
270
|
+
input: payload.value,
|
|
271
|
+
inst,
|
|
272
|
+
continue: !def.abort
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
277
|
+
$ZodCheck.init(inst, def);
|
|
278
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
279
|
+
def.pattern ?? (def.pattern = pattern);
|
|
280
|
+
inst._zod.check = (payload) => {
|
|
281
|
+
if (payload.value.endsWith(def.suffix)) return;
|
|
282
|
+
payload.issues.push({
|
|
283
|
+
origin: "string",
|
|
284
|
+
code: "invalid_format",
|
|
285
|
+
format: "ends_with",
|
|
286
|
+
suffix: def.suffix,
|
|
287
|
+
input: payload.value,
|
|
288
|
+
inst,
|
|
289
|
+
continue: !def.abort
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
294
|
+
$ZodCheck.init(inst, def);
|
|
295
|
+
inst._zod.check = (payload) => {
|
|
296
|
+
payload.value = def.tx(payload.value);
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
//#endregion
|
|
300
|
+
export { $ZodCheck, $ZodCheckEndsWith, $ZodCheckGreaterThan, $ZodCheckIncludes, $ZodCheckLengthEquals, $ZodCheckLessThan, $ZodCheckLowerCase, $ZodCheckMaxLength, $ZodCheckMinLength, $ZodCheckMultipleOf, $ZodCheckNumberFormat, $ZodCheckOverwrite, $ZodCheckRegex, $ZodCheckStartsWith, $ZodCheckStringFormat, $ZodCheckUpperCase };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { members } from "./util.js";
|
|
2
|
+
//#region node_modules/zod/v4/core/core.js
|
|
3
|
+
var _a;
|
|
4
|
+
const _zodDesc = {
|
|
5
|
+
value: void 0,
|
|
6
|
+
enumerable: false
|
|
7
|
+
};
|
|
8
|
+
let _E = "captureStackTrace" in Error ? Error : null;
|
|
9
|
+
function newError(Definition) {
|
|
10
|
+
const E = _E;
|
|
11
|
+
if (E) {
|
|
12
|
+
const saved = E.stackTraceLimit;
|
|
13
|
+
if (typeof saved === "number") {
|
|
14
|
+
try {
|
|
15
|
+
E.stackTraceLimit = 0;
|
|
16
|
+
} catch {
|
|
17
|
+
_E = null;
|
|
18
|
+
return new Definition();
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
return new Definition();
|
|
22
|
+
} finally {
|
|
23
|
+
E.stackTraceLimit = saved;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return new Definition();
|
|
28
|
+
}
|
|
29
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
30
|
+
function $constructor(name, initializer, proto, params) {
|
|
31
|
+
const zodProto = {};
|
|
32
|
+
function Internals(def) {
|
|
33
|
+
this.def = def;
|
|
34
|
+
this.constr = _;
|
|
35
|
+
this.traits = /* @__PURE__ */ new Set();
|
|
36
|
+
}
|
|
37
|
+
Internals.prototype = zodProto;
|
|
38
|
+
const protoMembers = proto;
|
|
39
|
+
const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
|
|
40
|
+
function init(inst, def) {
|
|
41
|
+
if (!inst._zod) {
|
|
42
|
+
_zodDesc.value = new Internals(def);
|
|
43
|
+
try {
|
|
44
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
45
|
+
} finally {
|
|
46
|
+
_zodDesc.value = void 0;
|
|
47
|
+
}
|
|
48
|
+
} else if (inst._zod.traits.has(name)) return;
|
|
49
|
+
inst._zod.traits.add(name);
|
|
50
|
+
initializer(inst, def);
|
|
51
|
+
if (initialized) {
|
|
52
|
+
const own = Object.getPrototypeOf(inst);
|
|
53
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
54
|
+
let up = own;
|
|
55
|
+
while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
|
|
56
|
+
const target = up ?? own;
|
|
57
|
+
if (!initialized.has(target)) {
|
|
58
|
+
initialized.add(target);
|
|
59
|
+
members(target, protoMembers);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const proto = _.prototype;
|
|
63
|
+
for (const k in proto) {
|
|
64
|
+
if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
|
|
65
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const Parent = params?.Parent ?? Object;
|
|
69
|
+
class Definition extends Parent {}
|
|
70
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
71
|
+
function _(def) {
|
|
72
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
73
|
+
init(inst, def);
|
|
74
|
+
const deferred = inst._zod.deferred;
|
|
75
|
+
if (deferred) {
|
|
76
|
+
for (const fn of deferred) fn();
|
|
77
|
+
inst._zod.deferred = void 0;
|
|
78
|
+
}
|
|
79
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
80
|
+
if (pp) pp(inst);
|
|
81
|
+
return inst;
|
|
82
|
+
}
|
|
83
|
+
Object.defineProperty(_, "init", { value: init });
|
|
84
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
85
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
86
|
+
return inst?._zod?.traits?.has(name);
|
|
87
|
+
} });
|
|
88
|
+
Object.defineProperty(_, "name", { value: name });
|
|
89
|
+
return _;
|
|
90
|
+
}
|
|
91
|
+
var $ZodAsyncError = class extends Error {
|
|
92
|
+
constructor() {
|
|
93
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var $ZodEncodeError = class extends Error {
|
|
97
|
+
constructor(name) {
|
|
98
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
99
|
+
this.name = "ZodEncodeError";
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
103
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
104
|
+
function config(newConfig) {
|
|
105
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
106
|
+
return globalConfig;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { $ZodAsyncError, $ZodEncodeError, $constructor, config, globalConfig };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region node_modules/zod/v4/core/doc.js
|
|
2
|
+
var Doc = class {
|
|
3
|
+
constructor(args = [], closed = {}) {
|
|
4
|
+
this.content = [];
|
|
5
|
+
this.indent = 0;
|
|
6
|
+
this.args = args;
|
|
7
|
+
this.closed = closed;
|
|
8
|
+
}
|
|
9
|
+
indented(fn) {
|
|
10
|
+
this.indent += 1;
|
|
11
|
+
try {
|
|
12
|
+
fn(this);
|
|
13
|
+
} finally {
|
|
14
|
+
this.indent -= 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
write(arg) {
|
|
18
|
+
if (typeof arg === "function") {
|
|
19
|
+
arg(this, { execution: "sync" });
|
|
20
|
+
arg(this, { execution: "async" });
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const lines = arg.split("\n").filter((x) => x);
|
|
24
|
+
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
25
|
+
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
26
|
+
for (const line of dedented) this.content.push(line);
|
|
27
|
+
}
|
|
28
|
+
compile() {
|
|
29
|
+
const F = Function;
|
|
30
|
+
const content = this?.content ?? [``];
|
|
31
|
+
return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { Doc };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsonStringifyReplacer } from "./util.js";
|
|
2
|
+
import { $constructor } from "./core.js";
|
|
3
|
+
//#region node_modules/zod/v4/core/errors.js
|
|
4
|
+
function _getMessage() {
|
|
5
|
+
const internals = this._zod;
|
|
6
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
7
|
+
return internals.message;
|
|
8
|
+
}
|
|
9
|
+
function _setMessage(value) {
|
|
10
|
+
this._zod.message = value;
|
|
11
|
+
}
|
|
12
|
+
const _messageDesc = {
|
|
13
|
+
get: _getMessage,
|
|
14
|
+
set: _setMessage,
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true
|
|
17
|
+
};
|
|
18
|
+
const _issuesDesc = {
|
|
19
|
+
value: void 0,
|
|
20
|
+
enumerable: false
|
|
21
|
+
};
|
|
22
|
+
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
23
|
+
const initializer = (inst, def) => {
|
|
24
|
+
inst.name = "$ZodError";
|
|
25
|
+
_issuesDesc.value = def;
|
|
26
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
27
|
+
_issuesDesc.value = void 0;
|
|
28
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
29
|
+
const proto = Object.getPrototypeOf(inst);
|
|
30
|
+
if (!_installedToString.has(proto)) {
|
|
31
|
+
_installedToString.add(proto);
|
|
32
|
+
Object.defineProperty(proto, "toString", {
|
|
33
|
+
configurable: true,
|
|
34
|
+
enumerable: false,
|
|
35
|
+
get() {
|
|
36
|
+
const value = () => this.message;
|
|
37
|
+
Object.defineProperty(this, "toString", {
|
|
38
|
+
value,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true
|
|
41
|
+
});
|
|
42
|
+
return value;
|
|
43
|
+
},
|
|
44
|
+
set(value) {
|
|
45
|
+
Object.defineProperty(this, "toString", {
|
|
46
|
+
value,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const $ZodError = /* @__PURE__ */ $constructor("$ZodError", initializer);
|
|
55
|
+
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
|
|
56
|
+
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
|
|
57
|
+
* "__proto__" would hit the setter instead of creating a key. */
|
|
58
|
+
function node(obj, key, make) {
|
|
59
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
60
|
+
if (key === "__proto__") Object.defineProperty(obj, key, {
|
|
61
|
+
value: make(),
|
|
62
|
+
writable: true,
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true
|
|
65
|
+
});
|
|
66
|
+
else obj[key] = make();
|
|
67
|
+
}
|
|
68
|
+
return obj[key];
|
|
69
|
+
}
|
|
70
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
71
|
+
const fieldErrors = {};
|
|
72
|
+
const formErrors = [];
|
|
73
|
+
for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
74
|
+
else formErrors.push(mapper(sub));
|
|
75
|
+
return {
|
|
76
|
+
formErrors,
|
|
77
|
+
fieldErrors
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
81
|
+
const fieldErrors = { _errors: [] };
|
|
82
|
+
const processError = (error, path = []) => {
|
|
83
|
+
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
84
|
+
else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
85
|
+
else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
86
|
+
else {
|
|
87
|
+
const fullpath = [...path, ...issue.path];
|
|
88
|
+
if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
89
|
+
else {
|
|
90
|
+
let curr = fieldErrors;
|
|
91
|
+
let i = 0;
|
|
92
|
+
while (i < fullpath.length) {
|
|
93
|
+
const el = fullpath[i];
|
|
94
|
+
const terminal = i === fullpath.length - 1;
|
|
95
|
+
if (el === "_errors") {
|
|
96
|
+
if (terminal) curr._errors.push(mapper(issue));
|
|
97
|
+
i++;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
|
|
101
|
+
value: { _errors: [] },
|
|
102
|
+
enumerable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
106
|
+
const node = curr[el];
|
|
107
|
+
if (terminal) node._errors.push(mapper(issue));
|
|
108
|
+
curr = node;
|
|
109
|
+
i++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
processError(error);
|
|
115
|
+
return fieldErrors;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { $ZodError, flattenError, formatError };
|