@web-ts-toolkit/access-router 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -358
- package/advanced.d.mts +941 -0
- package/advanced.d.ts +941 -0
- package/advanced.js +1025 -0
- package/advanced.mjs +941 -0
- package/index.d.mts +179 -1435
- package/index.d.ts +179 -1435
- package/index.js +3232 -1965
- package/index.mjs +3167 -1866
- package/package.json +9 -3
- package/parsers-CsyGHYQR.d.mts +1418 -0
- package/parsers-CsyGHYQR.d.ts +1418 -0
package/advanced.mjs
ADDED
|
@@ -0,0 +1,941 @@
|
|
|
1
|
+
// src/symbols.ts
|
|
2
|
+
var MIDDLEWARE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/middleware");
|
|
3
|
+
var DATA_MIDDLEWARE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/data-middleware");
|
|
4
|
+
var CORE = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/core");
|
|
5
|
+
var PERMISSIONS = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/permissions");
|
|
6
|
+
var PERMISSION_KEYS = /* @__PURE__ */ Symbol.for("@web-ts-toolkit/access-router/permission-keys");
|
|
7
|
+
|
|
8
|
+
// src/enums.ts
|
|
9
|
+
var StatusCodes = /* @__PURE__ */ ((StatusCodes2) => {
|
|
10
|
+
StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
|
|
11
|
+
StatusCodes2[StatusCodes2["Created"] = 201] = "Created";
|
|
12
|
+
StatusCodes2[StatusCodes2["BadRequest"] = 400] = "BadRequest";
|
|
13
|
+
StatusCodes2[StatusCodes2["Unauthorized"] = 401] = "Unauthorized";
|
|
14
|
+
StatusCodes2[StatusCodes2["Forbidden"] = 403] = "Forbidden";
|
|
15
|
+
StatusCodes2[StatusCodes2["NotFound"] = 404] = "NotFound";
|
|
16
|
+
StatusCodes2[StatusCodes2["UnprocessableContent"] = 422] = "UnprocessableContent";
|
|
17
|
+
return StatusCodes2;
|
|
18
|
+
})(StatusCodes || {});
|
|
19
|
+
var Codes = /* @__PURE__ */ ((Codes2) => {
|
|
20
|
+
Codes2["Success"] = "success";
|
|
21
|
+
Codes2["Created"] = "created";
|
|
22
|
+
Codes2["BadRequest"] = "bad_request";
|
|
23
|
+
Codes2["Unauthorized"] = "unauthorized";
|
|
24
|
+
Codes2["Forbidden"] = "forbidden";
|
|
25
|
+
Codes2["NotFound"] = "not_found";
|
|
26
|
+
return Codes2;
|
|
27
|
+
})(Codes || {});
|
|
28
|
+
var CustomHeaders = /* @__PURE__ */ ((CustomHeaders2) => {
|
|
29
|
+
CustomHeaders2["TotalCount"] = "wtt-total-count";
|
|
30
|
+
CustomHeaders2["ReturnedCount"] = "wtt-returned-count";
|
|
31
|
+
CustomHeaders2["Page"] = "wtt-page";
|
|
32
|
+
CustomHeaders2["PageSize"] = "wtt-page-size";
|
|
33
|
+
CustomHeaders2["TotalPages"] = "wtt-total-pages";
|
|
34
|
+
CustomHeaders2["HasNextPage"] = "wtt-has-next-page";
|
|
35
|
+
CustomHeaders2["HasPreviousPage"] = "wtt-has-previous-page";
|
|
36
|
+
return CustomHeaders2;
|
|
37
|
+
})(CustomHeaders || {});
|
|
38
|
+
var FilterOperator = /* @__PURE__ */ ((FilterOperator2) => {
|
|
39
|
+
FilterOperator2[FilterOperator2["SubQuery"] = 0] = "SubQuery";
|
|
40
|
+
FilterOperator2[FilterOperator2["Date"] = 1] = "Date";
|
|
41
|
+
return FilterOperator2;
|
|
42
|
+
})(FilterOperator || {});
|
|
43
|
+
|
|
44
|
+
// src/validation/parsers.ts
|
|
45
|
+
import JsonRouter from "@web-ts-toolkit/express-json-router";
|
|
46
|
+
|
|
47
|
+
// src/validation/common.ts
|
|
48
|
+
import { z } from "zod";
|
|
49
|
+
var stringOrStringArray = z.union([z.string(), z.array(z.string())]);
|
|
50
|
+
var queryBooleanString = z.enum(["true", "false"]);
|
|
51
|
+
var positiveIntegerString = z.string().regex(/^\d+$/, "Expected a non-negative integer");
|
|
52
|
+
var nonNegativeIntegerSchema = z.number().int().min(0);
|
|
53
|
+
var unknownRecord = z.record(z.string(), z.unknown());
|
|
54
|
+
var projectionObjectSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));
|
|
55
|
+
var projectionSchema = z.union([z.string(), z.array(z.string()), projectionObjectSchema]);
|
|
56
|
+
var sortOrderSchema = z.union([
|
|
57
|
+
z.literal(-1),
|
|
58
|
+
z.literal(1),
|
|
59
|
+
z.literal("asc"),
|
|
60
|
+
z.literal("ascending"),
|
|
61
|
+
z.literal("desc"),
|
|
62
|
+
z.literal("descending")
|
|
63
|
+
]);
|
|
64
|
+
var sortSchema = z.union([
|
|
65
|
+
z.string(),
|
|
66
|
+
z.record(z.string(), sortOrderSchema),
|
|
67
|
+
z.array(z.tuple([z.string(), sortOrderSchema])),
|
|
68
|
+
z.null()
|
|
69
|
+
]);
|
|
70
|
+
var populateSchema = z.union([
|
|
71
|
+
z.string(),
|
|
72
|
+
z.array(
|
|
73
|
+
z.union([
|
|
74
|
+
z.string(),
|
|
75
|
+
z.object({
|
|
76
|
+
path: z.string().min(1),
|
|
77
|
+
select: projectionSchema.optional(),
|
|
78
|
+
match: z.unknown().optional(),
|
|
79
|
+
access: z.enum(["list", "read"]).optional()
|
|
80
|
+
}).passthrough()
|
|
81
|
+
])
|
|
82
|
+
),
|
|
83
|
+
z.object({
|
|
84
|
+
path: z.string().min(1),
|
|
85
|
+
select: projectionSchema.optional(),
|
|
86
|
+
match: z.unknown().optional(),
|
|
87
|
+
access: z.enum(["list", "read"]).optional()
|
|
88
|
+
}).passthrough()
|
|
89
|
+
]);
|
|
90
|
+
var subPopulateSchema = z.union([
|
|
91
|
+
z.string(),
|
|
92
|
+
z.array(
|
|
93
|
+
z.union([
|
|
94
|
+
z.string(),
|
|
95
|
+
z.object({
|
|
96
|
+
path: z.string().min(1),
|
|
97
|
+
select: projectionSchema.optional()
|
|
98
|
+
}).passthrough()
|
|
99
|
+
])
|
|
100
|
+
),
|
|
101
|
+
z.object({
|
|
102
|
+
path: z.string().min(1),
|
|
103
|
+
select: projectionSchema.optional()
|
|
104
|
+
}).passthrough()
|
|
105
|
+
]);
|
|
106
|
+
var includeItemSchema = z.object({
|
|
107
|
+
model: z.string().min(1),
|
|
108
|
+
op: z.enum(["list", "read", "count"]),
|
|
109
|
+
path: z.string().min(1),
|
|
110
|
+
filter: z.record(z.string(), z.unknown()).optional(),
|
|
111
|
+
localField: z.string().min(1),
|
|
112
|
+
foreignField: z.string().min(1),
|
|
113
|
+
args: z.unknown().optional(),
|
|
114
|
+
options: z.unknown().optional()
|
|
115
|
+
}).passthrough();
|
|
116
|
+
var includeSchema = z.union([includeItemSchema, z.array(includeItemSchema)]);
|
|
117
|
+
var fieldsSchema = z.array(z.string().min(1));
|
|
118
|
+
var taskSchema = z.object({
|
|
119
|
+
type: z.string().min(1),
|
|
120
|
+
args: z.unknown(),
|
|
121
|
+
options: unknownRecord.optional()
|
|
122
|
+
});
|
|
123
|
+
var tasksSchema = z.union([taskSchema, z.array(taskSchema)]);
|
|
124
|
+
var objectOrArraySchema = z.union([z.record(z.string(), z.unknown()), z.array(z.unknown())]);
|
|
125
|
+
function rejectKeys(body, ctx, keys) {
|
|
126
|
+
for (const key of keys) {
|
|
127
|
+
if (key in body) {
|
|
128
|
+
ctx.addIssue({
|
|
129
|
+
code: z.ZodIssueCode.custom,
|
|
130
|
+
message: `Unsupported field: ${key}`,
|
|
131
|
+
path: [key]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/validation/parsers.ts
|
|
138
|
+
var clientErrors = JsonRouter.clientErrors;
|
|
139
|
+
function parsePathParam(value, parameter) {
|
|
140
|
+
const result = stringOrStringArray.safeParse(value);
|
|
141
|
+
if (!result.success) {
|
|
142
|
+
throwValidationError(normalizeIssues(result.error.issues), parameter, "parameter");
|
|
143
|
+
}
|
|
144
|
+
const param = Array.isArray(result.data) ? result.data[0] : result.data;
|
|
145
|
+
if (!param) {
|
|
146
|
+
throw new clientErrors.BadRequestError("Bad Request", {
|
|
147
|
+
errors: [{ detail: "Required", parameter }]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return param;
|
|
151
|
+
}
|
|
152
|
+
function parseQuery(schema, value) {
|
|
153
|
+
const result = schema.safeParse(value);
|
|
154
|
+
if (!result.success) {
|
|
155
|
+
throwValidationError(normalizeIssues(result.error.issues), void 0, "parameter");
|
|
156
|
+
}
|
|
157
|
+
return result.data;
|
|
158
|
+
}
|
|
159
|
+
function parseBody(schema, value) {
|
|
160
|
+
const result = schema.safeParse(value ?? {});
|
|
161
|
+
if (!result.success) {
|
|
162
|
+
throwValidationError(normalizeIssues(result.error.issues), void 0, "pointer");
|
|
163
|
+
}
|
|
164
|
+
return result.data;
|
|
165
|
+
}
|
|
166
|
+
function parseBodyWithSchema(schema, value, userSchema) {
|
|
167
|
+
const body = parseBody(schema, value);
|
|
168
|
+
return isRequestSchema(userSchema) ? parseUserSchema(userSchema, body) : Promise.resolve(body);
|
|
169
|
+
}
|
|
170
|
+
async function parseNestedBodyWithSchema(schema, value, nestedKey, userSchema) {
|
|
171
|
+
const body = parseBody(schema, value);
|
|
172
|
+
if (!isRequestSchema(userSchema)) return body;
|
|
173
|
+
return {
|
|
174
|
+
...body,
|
|
175
|
+
[nestedKey]: await parseUserSchema(userSchema, body?.[nestedKey], [nestedKey])
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function throwValidationError(issues, key, location = "pointer") {
|
|
179
|
+
const errors = issues.map((issue) => formatIssue(issue, key, location));
|
|
180
|
+
throw new clientErrors.BadRequestError("Bad Request", { errors });
|
|
181
|
+
}
|
|
182
|
+
async function parseUserSchema(schema, value, prefix = []) {
|
|
183
|
+
const validator = toRequestSchemaValidator(schema);
|
|
184
|
+
const result = await validator(value);
|
|
185
|
+
if (!isRequestSchemaFailure(result)) {
|
|
186
|
+
return result.data;
|
|
187
|
+
}
|
|
188
|
+
const issues = result.issues.map((issue) => ({
|
|
189
|
+
...issue,
|
|
190
|
+
path: prefix.concat((issue.path ?? []).map(String))
|
|
191
|
+
}));
|
|
192
|
+
throwValidationError(issues, void 0, "pointer");
|
|
193
|
+
}
|
|
194
|
+
function isZodSchema(schema) {
|
|
195
|
+
return typeof schema === "object" && schema !== null && "safeParse" in schema && typeof schema.safeParse === "function";
|
|
196
|
+
}
|
|
197
|
+
function isRequestSchema(schema) {
|
|
198
|
+
return isZodSchema(schema) || isStandardSchema(schema) || isRequestSchemaValidator(schema) || isRequestSchemaAdapter(schema);
|
|
199
|
+
}
|
|
200
|
+
function isRequestSchemaValidator(schema) {
|
|
201
|
+
return typeof schema === "function";
|
|
202
|
+
}
|
|
203
|
+
function isRequestSchemaAdapter(schema) {
|
|
204
|
+
return typeof schema === "object" && schema !== null && "validate" in schema && typeof schema.validate === "function";
|
|
205
|
+
}
|
|
206
|
+
function isStandardSchema(schema) {
|
|
207
|
+
return typeof schema === "object" && schema !== null && "~standard" in schema && typeof schema["~standard"] === "object" && schema["~standard"] !== null && "validate" in schema["~standard"] && typeof schema["~standard"].validate === "function";
|
|
208
|
+
}
|
|
209
|
+
function isRequestSchemaFailure(result) {
|
|
210
|
+
return result.success === false;
|
|
211
|
+
}
|
|
212
|
+
function toRequestSchemaValidator(schema) {
|
|
213
|
+
if (isZodSchema(schema)) return fromZod(schema);
|
|
214
|
+
if (isStandardSchema(schema)) return fromStandardSchema(schema);
|
|
215
|
+
if (isRequestSchemaValidator(schema)) return schema;
|
|
216
|
+
return schema.validate;
|
|
217
|
+
}
|
|
218
|
+
function defineRequestSchema(validator) {
|
|
219
|
+
return validator;
|
|
220
|
+
}
|
|
221
|
+
function fromZod(schema) {
|
|
222
|
+
return (value) => {
|
|
223
|
+
const result = schema.safeParse(value);
|
|
224
|
+
if (result.success) {
|
|
225
|
+
return {
|
|
226
|
+
success: true,
|
|
227
|
+
data: result.data
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
success: false,
|
|
232
|
+
issues: normalizeIssues(result.error.issues)
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function fromStandardSchema(schema) {
|
|
237
|
+
return async (value) => {
|
|
238
|
+
const result = await schema["~standard"].validate(value);
|
|
239
|
+
if (!isStandardSchemaFailure(result)) {
|
|
240
|
+
return {
|
|
241
|
+
success: true,
|
|
242
|
+
data: result.value
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
success: false,
|
|
247
|
+
issues: normalizeIssues(result.issues)
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function fromYup(schema) {
|
|
252
|
+
return async (value) => {
|
|
253
|
+
try {
|
|
254
|
+
const data = await schema.validate(value, { abortEarly: false });
|
|
255
|
+
return {
|
|
256
|
+
success: true,
|
|
257
|
+
data
|
|
258
|
+
};
|
|
259
|
+
} catch (error) {
|
|
260
|
+
return {
|
|
261
|
+
success: false,
|
|
262
|
+
issues: normalizeYupIssues(error)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function fromJoi(schema) {
|
|
268
|
+
return async (value) => {
|
|
269
|
+
const result = await schema.validate(value, { abortEarly: false });
|
|
270
|
+
if (!result.error?.details?.length) {
|
|
271
|
+
return {
|
|
272
|
+
success: true,
|
|
273
|
+
data: result.value
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
success: false,
|
|
278
|
+
issues: normalizeJoiIssues(result.error.details)
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function fromAjv(validator) {
|
|
283
|
+
return async (value) => {
|
|
284
|
+
const valid = await validator(value);
|
|
285
|
+
if (valid) {
|
|
286
|
+
return {
|
|
287
|
+
success: true,
|
|
288
|
+
data: value
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
success: false,
|
|
293
|
+
issues: normalizeAjvIssues(validator.errors ?? [])
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function fromValibot(schema, safeParse) {
|
|
298
|
+
return async (value) => {
|
|
299
|
+
const result = await safeParse(schema, value, { abortEarly: false });
|
|
300
|
+
if (result.success) {
|
|
301
|
+
return {
|
|
302
|
+
success: true,
|
|
303
|
+
data: result.output
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
success: false,
|
|
308
|
+
issues: normalizeValibotIssues(result.issues)
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function fromArkType(type) {
|
|
313
|
+
return async (value) => {
|
|
314
|
+
const result = await type(value);
|
|
315
|
+
if (!isArkTypeErrors(result)) {
|
|
316
|
+
return {
|
|
317
|
+
success: true,
|
|
318
|
+
data: result
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
success: false,
|
|
323
|
+
issues: normalizeArkTypeIssues(result)
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function fromIoTs(decoder) {
|
|
328
|
+
return async (value) => {
|
|
329
|
+
const result = decoder.decode(value);
|
|
330
|
+
if (result._tag === "Right") {
|
|
331
|
+
return {
|
|
332
|
+
success: true,
|
|
333
|
+
data: result.right
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
success: false,
|
|
338
|
+
issues: normalizeIoTsIssues(result.left)
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function fromSuperstruct(struct, validate) {
|
|
343
|
+
return async (value) => {
|
|
344
|
+
const [failure, output] = await validate(value, struct);
|
|
345
|
+
if (!failure) {
|
|
346
|
+
return {
|
|
347
|
+
success: true,
|
|
348
|
+
data: output
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
success: false,
|
|
353
|
+
issues: normalizeSuperstructFailure(failure)
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function fromVine(validator) {
|
|
358
|
+
return async (value) => {
|
|
359
|
+
try {
|
|
360
|
+
const output = await validator.validate(value);
|
|
361
|
+
return {
|
|
362
|
+
success: true,
|
|
363
|
+
data: output
|
|
364
|
+
};
|
|
365
|
+
} catch (error) {
|
|
366
|
+
return {
|
|
367
|
+
success: false,
|
|
368
|
+
issues: normalizeVineError(error)
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function isStandardSchemaFailure(result) {
|
|
374
|
+
return Array.isArray(result.issues);
|
|
375
|
+
}
|
|
376
|
+
function normalizeIssues(issues) {
|
|
377
|
+
return issues.map((issue) => ({
|
|
378
|
+
message: issue.message,
|
|
379
|
+
path: issue.path?.flatMap((segment) => normalizePathSegment(segment))
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
function normalizePathSegment(segment) {
|
|
383
|
+
const key = isStandardSchemaPathSegment(segment) ? segment.key : segment;
|
|
384
|
+
return typeof key === "string" || typeof key === "number" ? [key] : [];
|
|
385
|
+
}
|
|
386
|
+
function isStandardSchemaPathSegment(segment) {
|
|
387
|
+
return typeof segment === "object" && segment !== null && "key" in segment;
|
|
388
|
+
}
|
|
389
|
+
function normalizeYupIssues(error) {
|
|
390
|
+
if (!isYupValidationError(error)) {
|
|
391
|
+
return [{ message: "Validation failed" }];
|
|
392
|
+
}
|
|
393
|
+
const issues = error.inner?.length ? error.inner : [error];
|
|
394
|
+
return issues.map((issue) => ({
|
|
395
|
+
message: issue.message,
|
|
396
|
+
path: parsePathString(issue.path)
|
|
397
|
+
}));
|
|
398
|
+
}
|
|
399
|
+
function normalizeJoiIssues(issues) {
|
|
400
|
+
return issues.map((issue) => ({
|
|
401
|
+
message: issue.message,
|
|
402
|
+
path: issue.path ? [...issue.path] : void 0
|
|
403
|
+
}));
|
|
404
|
+
}
|
|
405
|
+
function normalizeAjvIssues(issues) {
|
|
406
|
+
return issues.map((issue) => ({
|
|
407
|
+
message: issue.message ?? "Validation failed",
|
|
408
|
+
path: parseAjvPath(issue)
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
function normalizeValibotIssues(issues) {
|
|
412
|
+
return issues.map((issue) => ({
|
|
413
|
+
message: issue.message,
|
|
414
|
+
path: issue.path?.flatMap(
|
|
415
|
+
(item) => typeof item.key === "string" || typeof item.key === "number" ? [item.key] : []
|
|
416
|
+
)
|
|
417
|
+
}));
|
|
418
|
+
}
|
|
419
|
+
function normalizeArkTypeIssues(issues) {
|
|
420
|
+
const normalized = issues.map((issue) => ({
|
|
421
|
+
message: issue.message ?? issue.problem ?? issues.summary ?? "Validation failed",
|
|
422
|
+
path: issue.path ? [...issue.path] : void 0
|
|
423
|
+
}));
|
|
424
|
+
return normalized.length ? normalized : [{ message: issues.summary ?? "Validation failed" }];
|
|
425
|
+
}
|
|
426
|
+
function normalizeIoTsIssues(issues) {
|
|
427
|
+
return issues.map((issue) => ({
|
|
428
|
+
message: issue.message ?? "Validation failed",
|
|
429
|
+
path: issue.context.map((entry) => entry.key).filter(Boolean)
|
|
430
|
+
}));
|
|
431
|
+
}
|
|
432
|
+
function normalizeSuperstructFailure(failure) {
|
|
433
|
+
const failures = failure.failures?.() ?? [failure];
|
|
434
|
+
return failures.map((entry) => ({
|
|
435
|
+
message: entry.message ?? "Validation failed",
|
|
436
|
+
path: normalizeSuperstructPath(entry)
|
|
437
|
+
}));
|
|
438
|
+
}
|
|
439
|
+
function normalizeSuperstructPath(failure) {
|
|
440
|
+
if (failure.path?.length) return [...failure.path];
|
|
441
|
+
if (typeof failure.key === "string" || typeof failure.key === "number") return [failure.key];
|
|
442
|
+
return void 0;
|
|
443
|
+
}
|
|
444
|
+
function normalizeVineError(error) {
|
|
445
|
+
if (!isVineValidationError(error)) {
|
|
446
|
+
return [{ message: "Validation failed" }];
|
|
447
|
+
}
|
|
448
|
+
return error.messages.map((message) => ({
|
|
449
|
+
message: message.message,
|
|
450
|
+
path: normalizeVineField(message)
|
|
451
|
+
}));
|
|
452
|
+
}
|
|
453
|
+
function normalizeVineField(message) {
|
|
454
|
+
const path = message.field.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
455
|
+
if (typeof message.index === "number" && path.length === 0) {
|
|
456
|
+
return [message.index];
|
|
457
|
+
}
|
|
458
|
+
return path.length ? path : void 0;
|
|
459
|
+
}
|
|
460
|
+
function parseAjvPath(issue) {
|
|
461
|
+
const path = issue.instancePath?.split("/").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
462
|
+
if (issue.params?.missingProperty) {
|
|
463
|
+
return (path ?? []).concat(issue.params.missingProperty);
|
|
464
|
+
}
|
|
465
|
+
return path;
|
|
466
|
+
}
|
|
467
|
+
function parsePathString(path) {
|
|
468
|
+
if (!path) return void 0;
|
|
469
|
+
return path.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
470
|
+
}
|
|
471
|
+
function isYupValidationError(error) {
|
|
472
|
+
return typeof error === "object" && error !== null && "message" in error;
|
|
473
|
+
}
|
|
474
|
+
function isArkTypeErrors(value) {
|
|
475
|
+
return Array.isArray(value);
|
|
476
|
+
}
|
|
477
|
+
function isVineValidationError(error) {
|
|
478
|
+
return typeof error === "object" && error !== null && "messages" in error && Array.isArray(error.messages);
|
|
479
|
+
}
|
|
480
|
+
function formatIssue(issue, key, location = "pointer") {
|
|
481
|
+
const path = (issue.path ?? []).map(String);
|
|
482
|
+
const joinedPath = path.join(".");
|
|
483
|
+
if (location === "parameter") {
|
|
484
|
+
return {
|
|
485
|
+
detail: issue.message,
|
|
486
|
+
parameter: (key ?? joinedPath) || void 0
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
detail: issue.message,
|
|
491
|
+
pointer: buildPointer(path)
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function buildPointer(path) {
|
|
495
|
+
return path.length === 0 ? "#" : `#/${path.join("/")}`;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/validation/model-router.ts
|
|
499
|
+
import { z as z2 } from "zod";
|
|
500
|
+
var listQuerySchema = z2.object({
|
|
501
|
+
skip: positiveIntegerString.optional(),
|
|
502
|
+
limit: positiveIntegerString.optional(),
|
|
503
|
+
page: positiveIntegerString.optional(),
|
|
504
|
+
page_size: positiveIntegerString.optional(),
|
|
505
|
+
skim: queryBooleanString.optional(),
|
|
506
|
+
include_permissions: queryBooleanString.optional(),
|
|
507
|
+
include_count: queryBooleanString.optional(),
|
|
508
|
+
include_extra_headers: queryBooleanString.optional()
|
|
509
|
+
}).passthrough();
|
|
510
|
+
var createQuerySchema = z2.object({
|
|
511
|
+
include_permissions: queryBooleanString.optional()
|
|
512
|
+
}).passthrough();
|
|
513
|
+
var readQuerySchema = z2.object({
|
|
514
|
+
include_permissions: queryBooleanString.optional(),
|
|
515
|
+
try_list: queryBooleanString.optional()
|
|
516
|
+
}).passthrough();
|
|
517
|
+
var updateQuerySchema = z2.object({
|
|
518
|
+
returning_all: queryBooleanString.optional(),
|
|
519
|
+
include_permissions: queryBooleanString.optional()
|
|
520
|
+
}).passthrough();
|
|
521
|
+
var upsertQuerySchema = z2.object({
|
|
522
|
+
returning_all: queryBooleanString.optional(),
|
|
523
|
+
include_permissions: queryBooleanString.optional()
|
|
524
|
+
}).passthrough();
|
|
525
|
+
var listBodySchema = z2.object({
|
|
526
|
+
filter: objectOrArraySchema.optional(),
|
|
527
|
+
select: projectionSchema.optional(),
|
|
528
|
+
sort: sortSchema.optional(),
|
|
529
|
+
populate: populateSchema.optional(),
|
|
530
|
+
include: includeSchema.optional(),
|
|
531
|
+
tasks: tasksSchema.optional(),
|
|
532
|
+
skip: z2.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
533
|
+
limit: z2.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
534
|
+
page: z2.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
535
|
+
pageSize: z2.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
536
|
+
options: z2.object({
|
|
537
|
+
skim: z2.boolean().optional(),
|
|
538
|
+
includePermissions: z2.boolean().optional(),
|
|
539
|
+
includeCount: z2.boolean().optional(),
|
|
540
|
+
includeExtraHeaders: z2.boolean().optional(),
|
|
541
|
+
populateAccess: z2.unknown().optional()
|
|
542
|
+
}).passthrough().optional()
|
|
543
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
|
|
544
|
+
var countBodySchema = z2.object({
|
|
545
|
+
filter: objectOrArraySchema.optional(),
|
|
546
|
+
options: z2.object({
|
|
547
|
+
access: z2.unknown().optional()
|
|
548
|
+
}).passthrough().optional()
|
|
549
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query", "access"]));
|
|
550
|
+
var readFilterBodySchema = z2.object({
|
|
551
|
+
filter: objectOrArraySchema.optional(),
|
|
552
|
+
select: projectionSchema.optional(),
|
|
553
|
+
sort: sortSchema.optional(),
|
|
554
|
+
populate: populateSchema.optional(),
|
|
555
|
+
include: includeSchema.optional(),
|
|
556
|
+
tasks: tasksSchema.optional(),
|
|
557
|
+
options: z2.object({
|
|
558
|
+
skim: z2.boolean().optional(),
|
|
559
|
+
includePermissions: z2.boolean().optional(),
|
|
560
|
+
tryList: z2.boolean().optional(),
|
|
561
|
+
populateAccess: z2.unknown().optional()
|
|
562
|
+
}).passthrough().optional()
|
|
563
|
+
}).passthrough();
|
|
564
|
+
var readByIdBodySchema = z2.object({
|
|
565
|
+
select: projectionSchema.optional(),
|
|
566
|
+
populate: populateSchema.optional(),
|
|
567
|
+
include: includeSchema.optional(),
|
|
568
|
+
tasks: tasksSchema.optional(),
|
|
569
|
+
options: z2.object({
|
|
570
|
+
skim: z2.boolean().optional(),
|
|
571
|
+
includePermissions: z2.boolean().optional(),
|
|
572
|
+
tryList: z2.boolean().optional(),
|
|
573
|
+
populateAccess: z2.unknown().optional()
|
|
574
|
+
}).passthrough().optional()
|
|
575
|
+
}).passthrough();
|
|
576
|
+
var advancedCreateBodySchema = z2.object({
|
|
577
|
+
data: z2.unknown(),
|
|
578
|
+
select: projectionSchema.optional(),
|
|
579
|
+
populate: populateSchema.optional(),
|
|
580
|
+
tasks: tasksSchema.optional(),
|
|
581
|
+
options: z2.object({
|
|
582
|
+
includePermissions: z2.boolean().optional(),
|
|
583
|
+
populateAccess: z2.unknown().optional()
|
|
584
|
+
}).passthrough().optional()
|
|
585
|
+
}).passthrough();
|
|
586
|
+
var createBodySchema = z2.union([
|
|
587
|
+
z2.record(z2.string(), z2.unknown()),
|
|
588
|
+
z2.array(z2.record(z2.string(), z2.unknown()))
|
|
589
|
+
]);
|
|
590
|
+
var updateBodySchema = z2.record(z2.string(), z2.unknown());
|
|
591
|
+
var advancedUpdateBodySchema = z2.object({
|
|
592
|
+
data: z2.unknown(),
|
|
593
|
+
select: projectionSchema.optional(),
|
|
594
|
+
populate: populateSchema.optional(),
|
|
595
|
+
tasks: tasksSchema.optional(),
|
|
596
|
+
options: z2.object({
|
|
597
|
+
returningAll: z2.boolean().optional(),
|
|
598
|
+
includePermissions: z2.boolean().optional(),
|
|
599
|
+
populateAccess: z2.unknown().optional()
|
|
600
|
+
}).passthrough().optional()
|
|
601
|
+
}).passthrough();
|
|
602
|
+
var upsertBodySchema = z2.record(z2.string(), z2.unknown());
|
|
603
|
+
var advancedUpsertBodySchema = z2.object({
|
|
604
|
+
data: z2.record(z2.string(), z2.unknown()),
|
|
605
|
+
select: projectionSchema.optional(),
|
|
606
|
+
populate: populateSchema.optional(),
|
|
607
|
+
tasks: tasksSchema.optional(),
|
|
608
|
+
options: z2.object({
|
|
609
|
+
returningAll: z2.boolean().optional(),
|
|
610
|
+
includePermissions: z2.boolean().optional(),
|
|
611
|
+
populateAccess: z2.unknown().optional()
|
|
612
|
+
}).passthrough().optional()
|
|
613
|
+
}).passthrough();
|
|
614
|
+
var distinctBodySchema = z2.object({
|
|
615
|
+
filter: objectOrArraySchema.optional()
|
|
616
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["query"]));
|
|
617
|
+
var subListBodySchema = z2.object({
|
|
618
|
+
filter: z2.record(z2.string(), z2.unknown()).optional(),
|
|
619
|
+
select: fieldsSchema.optional()
|
|
620
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
|
|
621
|
+
var subMutationBodySchema = z2.union([
|
|
622
|
+
z2.record(z2.string(), z2.unknown()),
|
|
623
|
+
z2.array(z2.record(z2.string(), z2.unknown()))
|
|
624
|
+
]);
|
|
625
|
+
var subReadBodySchema = z2.object({
|
|
626
|
+
select: fieldsSchema.optional(),
|
|
627
|
+
populate: subPopulateSchema.optional()
|
|
628
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["fields"]));
|
|
629
|
+
var requestSchemas = {
|
|
630
|
+
listQuery: listQuerySchema,
|
|
631
|
+
createQuery: createQuerySchema,
|
|
632
|
+
readQuery: readQuerySchema,
|
|
633
|
+
updateQuery: updateQuerySchema,
|
|
634
|
+
upsertQuery: upsertQuerySchema
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
// src/validation/data-router.ts
|
|
638
|
+
import { z as z3 } from "zod";
|
|
639
|
+
var dataListBodySchema = z3.object({
|
|
640
|
+
filter: objectOrArraySchema.optional(),
|
|
641
|
+
select: projectionSchema.optional(),
|
|
642
|
+
sort: z3.string().optional(),
|
|
643
|
+
skip: z3.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
644
|
+
limit: z3.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
645
|
+
page: z3.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
646
|
+
pageSize: z3.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
647
|
+
options: z3.object({
|
|
648
|
+
includeCount: z3.boolean().optional(),
|
|
649
|
+
includeExtraHeaders: z3.boolean().optional()
|
|
650
|
+
}).passthrough().optional()
|
|
651
|
+
}).passthrough();
|
|
652
|
+
var dataReadFilterBodySchema = z3.object({
|
|
653
|
+
filter: objectOrArraySchema.optional(),
|
|
654
|
+
select: projectionSchema.optional()
|
|
655
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
|
|
656
|
+
var dataReadByIdBodySchema = z3.object({
|
|
657
|
+
select: projectionSchema.optional()
|
|
658
|
+
}).passthrough().superRefine((body, ctx) => rejectKeys(body, ctx, ["options"]));
|
|
659
|
+
|
|
660
|
+
// src/validation/root-router.ts
|
|
661
|
+
import { z as z4 } from "zod";
|
|
662
|
+
var rootEntryBaseSchema = {
|
|
663
|
+
target: z4.enum(["model", "data"]),
|
|
664
|
+
name: z4.string().min(1),
|
|
665
|
+
order: z4.number().int().optional()
|
|
666
|
+
};
|
|
667
|
+
var rootModelListArgsSchema = z4.object({
|
|
668
|
+
select: projectionSchema.optional(),
|
|
669
|
+
populate: populateSchema.optional(),
|
|
670
|
+
include: includeSchema.optional(),
|
|
671
|
+
sort: sortSchema.optional(),
|
|
672
|
+
skip: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
673
|
+
limit: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
674
|
+
page: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
675
|
+
pageSize: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
676
|
+
tasks: tasksSchema.optional()
|
|
677
|
+
}).passthrough();
|
|
678
|
+
var rootModelListOptionsSchema = z4.object({
|
|
679
|
+
skim: z4.boolean().optional(),
|
|
680
|
+
includePermissions: z4.boolean().optional(),
|
|
681
|
+
includeCount: z4.boolean().optional(),
|
|
682
|
+
populateAccess: z4.unknown().optional(),
|
|
683
|
+
lean: z4.boolean().optional()
|
|
684
|
+
}).passthrough();
|
|
685
|
+
var rootModelReadArgsSchema = z4.object({
|
|
686
|
+
select: projectionSchema.optional(),
|
|
687
|
+
populate: populateSchema.optional(),
|
|
688
|
+
include: includeSchema.optional(),
|
|
689
|
+
tasks: tasksSchema.optional()
|
|
690
|
+
}).passthrough();
|
|
691
|
+
var rootModelReadFilterArgsSchema = rootModelReadArgsSchema.extend({
|
|
692
|
+
sort: sortSchema.optional()
|
|
693
|
+
});
|
|
694
|
+
var rootModelReadOptionsSchema = z4.object({
|
|
695
|
+
skim: z4.boolean().optional(),
|
|
696
|
+
includePermissions: z4.boolean().optional(),
|
|
697
|
+
tryList: z4.boolean().optional(),
|
|
698
|
+
populateAccess: z4.unknown().optional(),
|
|
699
|
+
lean: z4.boolean().optional()
|
|
700
|
+
}).passthrough();
|
|
701
|
+
var rootModelCreateArgsSchema = z4.object({
|
|
702
|
+
select: projectionSchema.optional(),
|
|
703
|
+
populate: populateSchema.optional(),
|
|
704
|
+
tasks: tasksSchema.optional()
|
|
705
|
+
}).passthrough();
|
|
706
|
+
var rootModelCreateOptionsSchema = z4.object({
|
|
707
|
+
skim: z4.boolean().optional(),
|
|
708
|
+
includePermissions: z4.boolean().optional(),
|
|
709
|
+
populateAccess: z4.unknown().optional()
|
|
710
|
+
}).passthrough();
|
|
711
|
+
var rootModelUpdateArgsSchema = z4.object({
|
|
712
|
+
select: projectionSchema.optional(),
|
|
713
|
+
populate: populateSchema.optional(),
|
|
714
|
+
tasks: tasksSchema.optional()
|
|
715
|
+
}).passthrough();
|
|
716
|
+
var rootModelUpdateOptionsSchema = z4.object({
|
|
717
|
+
skim: z4.boolean().optional(),
|
|
718
|
+
returningAll: z4.boolean().optional(),
|
|
719
|
+
includePermissions: z4.boolean().optional(),
|
|
720
|
+
populateAccess: z4.unknown().optional()
|
|
721
|
+
}).passthrough();
|
|
722
|
+
var rootModelUpsertArgsSchema = rootModelUpdateArgsSchema;
|
|
723
|
+
var rootModelUpsertOptionsSchema = rootModelUpdateOptionsSchema;
|
|
724
|
+
var rootModelSubListArgsSchema = z4.object({
|
|
725
|
+
select: fieldsSchema.optional()
|
|
726
|
+
}).passthrough();
|
|
727
|
+
var rootModelSubReadArgsSchema = z4.object({
|
|
728
|
+
select: fieldsSchema.optional(),
|
|
729
|
+
populate: subPopulateSchema.optional()
|
|
730
|
+
}).passthrough();
|
|
731
|
+
var rootModelCountOptionsSchema = z4.object({
|
|
732
|
+
access: z4.unknown().optional()
|
|
733
|
+
}).passthrough();
|
|
734
|
+
var rootDataListArgsSchema = z4.object({
|
|
735
|
+
select: projectionSchema.optional(),
|
|
736
|
+
sort: z4.string().optional(),
|
|
737
|
+
skip: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
738
|
+
limit: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
739
|
+
page: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional(),
|
|
740
|
+
pageSize: z4.union([nonNegativeIntegerSchema, positiveIntegerString]).optional()
|
|
741
|
+
}).passthrough();
|
|
742
|
+
var rootDataListOptionsSchema = z4.object({
|
|
743
|
+
includeCount: z4.boolean().optional()
|
|
744
|
+
}).passthrough();
|
|
745
|
+
var rootDataReadArgsSchema = z4.object({
|
|
746
|
+
select: projectionSchema.optional()
|
|
747
|
+
}).passthrough();
|
|
748
|
+
var rootModelQueryEntrySchema = z4.union([
|
|
749
|
+
z4.object({ ...rootEntryBaseSchema, target: z4.literal("model"), op: z4.literal("new") }).passthrough(),
|
|
750
|
+
z4.object({
|
|
751
|
+
...rootEntryBaseSchema,
|
|
752
|
+
target: z4.literal("model"),
|
|
753
|
+
op: z4.literal("list"),
|
|
754
|
+
filter: objectOrArraySchema.optional(),
|
|
755
|
+
args: rootModelListArgsSchema.optional(),
|
|
756
|
+
options: rootModelListOptionsSchema.optional()
|
|
757
|
+
}).passthrough(),
|
|
758
|
+
z4.object({
|
|
759
|
+
...rootEntryBaseSchema,
|
|
760
|
+
target: z4.literal("model"),
|
|
761
|
+
op: z4.literal("read"),
|
|
762
|
+
id: z4.string().min(1),
|
|
763
|
+
args: rootModelReadArgsSchema.optional(),
|
|
764
|
+
options: rootModelReadOptionsSchema.optional()
|
|
765
|
+
}).passthrough(),
|
|
766
|
+
z4.object({
|
|
767
|
+
...rootEntryBaseSchema,
|
|
768
|
+
target: z4.literal("model"),
|
|
769
|
+
op: z4.literal("read"),
|
|
770
|
+
filter: objectOrArraySchema,
|
|
771
|
+
args: rootModelReadFilterArgsSchema.optional(),
|
|
772
|
+
options: rootModelReadOptionsSchema.optional()
|
|
773
|
+
}).passthrough(),
|
|
774
|
+
z4.object({
|
|
775
|
+
...rootEntryBaseSchema,
|
|
776
|
+
target: z4.literal("model"),
|
|
777
|
+
op: z4.literal("create"),
|
|
778
|
+
data: z4.unknown(),
|
|
779
|
+
args: rootModelCreateArgsSchema.optional(),
|
|
780
|
+
options: rootModelCreateOptionsSchema.optional()
|
|
781
|
+
}).passthrough(),
|
|
782
|
+
z4.object({
|
|
783
|
+
...rootEntryBaseSchema,
|
|
784
|
+
target: z4.literal("model"),
|
|
785
|
+
op: z4.literal("update"),
|
|
786
|
+
id: z4.string().min(1),
|
|
787
|
+
data: z4.unknown(),
|
|
788
|
+
args: rootModelUpdateArgsSchema.optional(),
|
|
789
|
+
options: rootModelUpdateOptionsSchema.optional()
|
|
790
|
+
}).passthrough(),
|
|
791
|
+
z4.object({
|
|
792
|
+
...rootEntryBaseSchema,
|
|
793
|
+
target: z4.literal("model"),
|
|
794
|
+
op: z4.literal("upsert"),
|
|
795
|
+
data: z4.record(z4.string(), z4.unknown()),
|
|
796
|
+
args: rootModelUpsertArgsSchema.optional(),
|
|
797
|
+
options: rootModelUpsertOptionsSchema.optional()
|
|
798
|
+
}).passthrough(),
|
|
799
|
+
z4.object({ ...rootEntryBaseSchema, target: z4.literal("model"), op: z4.literal("delete"), id: z4.string().min(1) }).passthrough(),
|
|
800
|
+
z4.object({
|
|
801
|
+
...rootEntryBaseSchema,
|
|
802
|
+
target: z4.literal("model"),
|
|
803
|
+
op: z4.literal("subList"),
|
|
804
|
+
id: z4.string().min(1),
|
|
805
|
+
sub: z4.string().min(1),
|
|
806
|
+
filter: z4.record(z4.string(), z4.unknown()).optional(),
|
|
807
|
+
args: rootModelSubListArgsSchema.optional()
|
|
808
|
+
}).passthrough(),
|
|
809
|
+
z4.object({
|
|
810
|
+
...rootEntryBaseSchema,
|
|
811
|
+
target: z4.literal("model"),
|
|
812
|
+
op: z4.literal("subRead"),
|
|
813
|
+
id: z4.string().min(1),
|
|
814
|
+
sub: z4.string().min(1),
|
|
815
|
+
subId: z4.string().min(1),
|
|
816
|
+
args: rootModelSubReadArgsSchema.optional()
|
|
817
|
+
}).passthrough(),
|
|
818
|
+
z4.object({
|
|
819
|
+
...rootEntryBaseSchema,
|
|
820
|
+
target: z4.literal("model"),
|
|
821
|
+
op: z4.literal("subCreate"),
|
|
822
|
+
id: z4.string().min(1),
|
|
823
|
+
sub: z4.string().min(1),
|
|
824
|
+
data: z4.union([z4.record(z4.string(), z4.unknown()), z4.array(z4.record(z4.string(), z4.unknown()))])
|
|
825
|
+
}).passthrough(),
|
|
826
|
+
z4.object({
|
|
827
|
+
...rootEntryBaseSchema,
|
|
828
|
+
target: z4.literal("model"),
|
|
829
|
+
op: z4.literal("subUpdate"),
|
|
830
|
+
id: z4.string().min(1),
|
|
831
|
+
sub: z4.string().min(1),
|
|
832
|
+
subId: z4.string().min(1),
|
|
833
|
+
data: z4.union([z4.record(z4.string(), z4.unknown()), z4.array(z4.record(z4.string(), z4.unknown()))])
|
|
834
|
+
}).passthrough(),
|
|
835
|
+
z4.object({
|
|
836
|
+
...rootEntryBaseSchema,
|
|
837
|
+
target: z4.literal("model"),
|
|
838
|
+
op: z4.literal("subBulkUpdate"),
|
|
839
|
+
id: z4.string().min(1),
|
|
840
|
+
sub: z4.string().min(1),
|
|
841
|
+
data: z4.union([z4.record(z4.string(), z4.unknown()), z4.array(z4.record(z4.string(), z4.unknown()))])
|
|
842
|
+
}).passthrough(),
|
|
843
|
+
z4.object({
|
|
844
|
+
...rootEntryBaseSchema,
|
|
845
|
+
target: z4.literal("model"),
|
|
846
|
+
op: z4.literal("subDelete"),
|
|
847
|
+
id: z4.string().min(1),
|
|
848
|
+
sub: z4.string().min(1),
|
|
849
|
+
subId: z4.string().min(1)
|
|
850
|
+
}).passthrough(),
|
|
851
|
+
z4.object({
|
|
852
|
+
...rootEntryBaseSchema,
|
|
853
|
+
target: z4.literal("model"),
|
|
854
|
+
op: z4.literal("distinct"),
|
|
855
|
+
field: z4.string().min(1),
|
|
856
|
+
filter: objectOrArraySchema.optional()
|
|
857
|
+
}).passthrough(),
|
|
858
|
+
z4.object({
|
|
859
|
+
...rootEntryBaseSchema,
|
|
860
|
+
target: z4.literal("model"),
|
|
861
|
+
op: z4.literal("count"),
|
|
862
|
+
filter: objectOrArraySchema.optional(),
|
|
863
|
+
options: rootModelCountOptionsSchema.optional()
|
|
864
|
+
}).passthrough()
|
|
865
|
+
]);
|
|
866
|
+
var rootDataQueryEntrySchema = z4.union([
|
|
867
|
+
z4.object({
|
|
868
|
+
...rootEntryBaseSchema,
|
|
869
|
+
target: z4.literal("data"),
|
|
870
|
+
op: z4.literal("list"),
|
|
871
|
+
filter: objectOrArraySchema.optional(),
|
|
872
|
+
args: rootDataListArgsSchema.optional(),
|
|
873
|
+
options: rootDataListOptionsSchema.optional()
|
|
874
|
+
}).passthrough(),
|
|
875
|
+
z4.object({
|
|
876
|
+
...rootEntryBaseSchema,
|
|
877
|
+
target: z4.literal("data"),
|
|
878
|
+
op: z4.literal("read"),
|
|
879
|
+
id: z4.string().min(1),
|
|
880
|
+
args: rootDataReadArgsSchema.optional()
|
|
881
|
+
}).passthrough(),
|
|
882
|
+
z4.object({
|
|
883
|
+
...rootEntryBaseSchema,
|
|
884
|
+
target: z4.literal("data"),
|
|
885
|
+
op: z4.literal("read"),
|
|
886
|
+
filter: objectOrArraySchema,
|
|
887
|
+
args: rootDataReadArgsSchema.optional()
|
|
888
|
+
}).passthrough()
|
|
889
|
+
]);
|
|
890
|
+
var rootQuerySchema = z4.array(z4.union([rootModelQueryEntrySchema, rootDataQueryEntrySchema]));
|
|
891
|
+
export {
|
|
892
|
+
CORE,
|
|
893
|
+
Codes,
|
|
894
|
+
CustomHeaders,
|
|
895
|
+
DATA_MIDDLEWARE,
|
|
896
|
+
FilterOperator,
|
|
897
|
+
MIDDLEWARE,
|
|
898
|
+
PERMISSIONS,
|
|
899
|
+
PERMISSION_KEYS,
|
|
900
|
+
StatusCodes,
|
|
901
|
+
advancedCreateBodySchema,
|
|
902
|
+
advancedUpdateBodySchema,
|
|
903
|
+
advancedUpsertBodySchema,
|
|
904
|
+
countBodySchema,
|
|
905
|
+
createBodySchema,
|
|
906
|
+
createQuerySchema,
|
|
907
|
+
dataListBodySchema,
|
|
908
|
+
dataReadByIdBodySchema,
|
|
909
|
+
dataReadFilterBodySchema,
|
|
910
|
+
defineRequestSchema,
|
|
911
|
+
distinctBodySchema,
|
|
912
|
+
fromAjv,
|
|
913
|
+
fromArkType,
|
|
914
|
+
fromIoTs,
|
|
915
|
+
fromJoi,
|
|
916
|
+
fromStandardSchema,
|
|
917
|
+
fromSuperstruct,
|
|
918
|
+
fromValibot,
|
|
919
|
+
fromVine,
|
|
920
|
+
fromYup,
|
|
921
|
+
fromZod,
|
|
922
|
+
listBodySchema,
|
|
923
|
+
listQuerySchema,
|
|
924
|
+
parseBody,
|
|
925
|
+
parseBodyWithSchema,
|
|
926
|
+
parseNestedBodyWithSchema,
|
|
927
|
+
parsePathParam,
|
|
928
|
+
parseQuery,
|
|
929
|
+
readByIdBodySchema,
|
|
930
|
+
readFilterBodySchema,
|
|
931
|
+
readQuerySchema,
|
|
932
|
+
requestSchemas,
|
|
933
|
+
rootQuerySchema,
|
|
934
|
+
subListBodySchema,
|
|
935
|
+
subMutationBodySchema,
|
|
936
|
+
subReadBodySchema,
|
|
937
|
+
updateBodySchema,
|
|
938
|
+
updateQuerySchema,
|
|
939
|
+
upsertBodySchema,
|
|
940
|
+
upsertQuerySchema
|
|
941
|
+
};
|