@web-ts-toolkit/access-router 0.3.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/index.js CHANGED
@@ -37,6 +37,17 @@ __export(index_exports, {
37
37
  combineRoutes: () => combineRoutes,
38
38
  createAccessRuntime: () => createAccessRuntime,
39
39
  default: () => index_default,
40
+ defineRequestSchema: () => defineRequestSchema,
41
+ fromAjv: () => fromAjv,
42
+ fromArkType: () => fromArkType,
43
+ fromIoTs: () => fromIoTs,
44
+ fromJoi: () => fromJoi,
45
+ fromStandardSchema: () => fromStandardSchema,
46
+ fromSuperstruct: () => fromSuperstruct,
47
+ fromValibot: () => fromValibot,
48
+ fromVine: () => fromVine,
49
+ fromYup: () => fromYup,
50
+ fromZod: () => fromZod,
40
51
  getDefaultModelOption: () => getDefaultModelOption,
41
52
  getDefaultModelOptions: () => getDefaultModelOptions,
42
53
  getGlobalOption: () => getGlobalOption,
@@ -3202,7 +3213,7 @@ var clientErrors = import_express_json_router4.default.clientErrors;
3202
3213
  function parsePathParam(value, parameter) {
3203
3214
  const result = stringOrStringArray.safeParse(value);
3204
3215
  if (!result.success) {
3205
- throwValidationError(result.error.issues, parameter, "parameter");
3216
+ throwValidationError(normalizeIssues(result.error.issues), parameter, "parameter");
3206
3217
  }
3207
3218
  const param = Array.isArray(result.data) ? result.data[0] : result.data;
3208
3219
  if (!param) {
@@ -3215,49 +3226,333 @@ function parsePathParam(value, parameter) {
3215
3226
  function parseQuery(schema, value) {
3216
3227
  const result = schema.safeParse(value);
3217
3228
  if (!result.success) {
3218
- throwValidationError(result.error.issues, void 0, "parameter");
3229
+ throwValidationError(normalizeIssues(result.error.issues), void 0, "parameter");
3219
3230
  }
3220
3231
  return result.data;
3221
3232
  }
3222
3233
  function parseBody(schema, value) {
3223
3234
  const result = schema.safeParse(value ?? {});
3224
3235
  if (!result.success) {
3225
- throwValidationError(result.error.issues, void 0, "pointer");
3236
+ throwValidationError(normalizeIssues(result.error.issues), void 0, "pointer");
3226
3237
  }
3227
3238
  return result.data;
3228
3239
  }
3229
3240
  function parseBodyWithSchema(schema, value, userSchema) {
3230
3241
  const body = parseBody(schema, value);
3231
- return isZodSchema(userSchema) ? parseUserSchema(userSchema, body) : body;
3242
+ return isRequestSchema(userSchema) ? parseUserSchema(userSchema, body) : Promise.resolve(body);
3232
3243
  }
3233
- function parseNestedBodyWithSchema(schema, value, nestedKey, userSchema) {
3244
+ async function parseNestedBodyWithSchema(schema, value, nestedKey, userSchema) {
3234
3245
  const body = parseBody(schema, value);
3235
- if (!isZodSchema(userSchema)) return body;
3246
+ if (!isRequestSchema(userSchema)) return body;
3236
3247
  return {
3237
3248
  ...body,
3238
- [nestedKey]: parseUserSchema(userSchema, body?.[nestedKey], [nestedKey])
3249
+ [nestedKey]: await parseUserSchema(userSchema, body?.[nestedKey], [nestedKey])
3239
3250
  };
3240
3251
  }
3241
3252
  function throwValidationError(issues, key, location = "pointer") {
3242
3253
  const errors = issues.map((issue) => formatIssue(issue, key, location));
3243
3254
  throw new clientErrors.BadRequestError("Bad Request", { errors });
3244
3255
  }
3245
- function parseUserSchema(schema, value, prefix = []) {
3246
- const result = schema.safeParse(value);
3247
- if (!result.success) {
3248
- const issues = result.error.issues.map((issue) => ({
3249
- ...issue,
3250
- path: prefix.concat(issue.path.map(String))
3251
- }));
3252
- throwValidationError(issues, void 0, "pointer");
3253
- }
3254
- return result.data;
3256
+ async function parseUserSchema(schema, value, prefix = []) {
3257
+ const validator = toRequestSchemaValidator(schema);
3258
+ const result = await validator(value);
3259
+ if (!isRequestSchemaFailure(result)) {
3260
+ return result.data;
3261
+ }
3262
+ const issues = result.issues.map((issue) => ({
3263
+ ...issue,
3264
+ path: prefix.concat((issue.path ?? []).map(String))
3265
+ }));
3266
+ throwValidationError(issues, void 0, "pointer");
3255
3267
  }
3256
3268
  function isZodSchema(schema) {
3257
3269
  return typeof schema === "object" && schema !== null && "safeParse" in schema && typeof schema.safeParse === "function";
3258
3270
  }
3271
+ function isRequestSchema(schema) {
3272
+ return isZodSchema(schema) || isStandardSchema(schema) || isRequestSchemaValidator(schema) || isRequestSchemaAdapter(schema);
3273
+ }
3274
+ function isRequestSchemaValidator(schema) {
3275
+ return typeof schema === "function";
3276
+ }
3277
+ function isRequestSchemaAdapter(schema) {
3278
+ return typeof schema === "object" && schema !== null && "validate" in schema && typeof schema.validate === "function";
3279
+ }
3280
+ function isStandardSchema(schema) {
3281
+ 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";
3282
+ }
3283
+ function isRequestSchemaFailure(result) {
3284
+ return result.success === false;
3285
+ }
3286
+ function toRequestSchemaValidator(schema) {
3287
+ if (isZodSchema(schema)) return fromZod(schema);
3288
+ if (isStandardSchema(schema)) return fromStandardSchema(schema);
3289
+ if (isRequestSchemaValidator(schema)) return schema;
3290
+ return schema.validate;
3291
+ }
3292
+ function defineRequestSchema(validator) {
3293
+ return validator;
3294
+ }
3295
+ function fromZod(schema) {
3296
+ return (value) => {
3297
+ const result = schema.safeParse(value);
3298
+ if (result.success) {
3299
+ return {
3300
+ success: true,
3301
+ data: result.data
3302
+ };
3303
+ }
3304
+ return {
3305
+ success: false,
3306
+ issues: normalizeIssues(result.error.issues)
3307
+ };
3308
+ };
3309
+ }
3310
+ function fromStandardSchema(schema) {
3311
+ return async (value) => {
3312
+ const result = await schema["~standard"].validate(value);
3313
+ if (!isStandardSchemaFailure(result)) {
3314
+ return {
3315
+ success: true,
3316
+ data: result.value
3317
+ };
3318
+ }
3319
+ return {
3320
+ success: false,
3321
+ issues: normalizeIssues(result.issues)
3322
+ };
3323
+ };
3324
+ }
3325
+ function fromYup(schema) {
3326
+ return async (value) => {
3327
+ try {
3328
+ const data = await schema.validate(value, { abortEarly: false });
3329
+ return {
3330
+ success: true,
3331
+ data
3332
+ };
3333
+ } catch (error) {
3334
+ return {
3335
+ success: false,
3336
+ issues: normalizeYupIssues(error)
3337
+ };
3338
+ }
3339
+ };
3340
+ }
3341
+ function fromJoi(schema) {
3342
+ return async (value) => {
3343
+ const result = await schema.validate(value, { abortEarly: false });
3344
+ if (!result.error?.details?.length) {
3345
+ return {
3346
+ success: true,
3347
+ data: result.value
3348
+ };
3349
+ }
3350
+ return {
3351
+ success: false,
3352
+ issues: normalizeJoiIssues(result.error.details)
3353
+ };
3354
+ };
3355
+ }
3356
+ function fromAjv(validator) {
3357
+ return async (value) => {
3358
+ const valid = await validator(value);
3359
+ if (valid) {
3360
+ return {
3361
+ success: true,
3362
+ data: value
3363
+ };
3364
+ }
3365
+ return {
3366
+ success: false,
3367
+ issues: normalizeAjvIssues(validator.errors ?? [])
3368
+ };
3369
+ };
3370
+ }
3371
+ function fromValibot(schema, safeParse) {
3372
+ return async (value) => {
3373
+ const result = await safeParse(schema, value, { abortEarly: false });
3374
+ if (result.success) {
3375
+ return {
3376
+ success: true,
3377
+ data: result.output
3378
+ };
3379
+ }
3380
+ return {
3381
+ success: false,
3382
+ issues: normalizeValibotIssues(result.issues)
3383
+ };
3384
+ };
3385
+ }
3386
+ function fromArkType(type) {
3387
+ return async (value) => {
3388
+ const result = await type(value);
3389
+ if (!isArkTypeErrors(result)) {
3390
+ return {
3391
+ success: true,
3392
+ data: result
3393
+ };
3394
+ }
3395
+ return {
3396
+ success: false,
3397
+ issues: normalizeArkTypeIssues(result)
3398
+ };
3399
+ };
3400
+ }
3401
+ function fromIoTs(decoder) {
3402
+ return async (value) => {
3403
+ const result = decoder.decode(value);
3404
+ if (result._tag === "Right") {
3405
+ return {
3406
+ success: true,
3407
+ data: result.right
3408
+ };
3409
+ }
3410
+ return {
3411
+ success: false,
3412
+ issues: normalizeIoTsIssues(result.left)
3413
+ };
3414
+ };
3415
+ }
3416
+ function fromSuperstruct(struct, validate) {
3417
+ return async (value) => {
3418
+ const [failure, output] = await validate(value, struct);
3419
+ if (!failure) {
3420
+ return {
3421
+ success: true,
3422
+ data: output
3423
+ };
3424
+ }
3425
+ return {
3426
+ success: false,
3427
+ issues: normalizeSuperstructFailure(failure)
3428
+ };
3429
+ };
3430
+ }
3431
+ function fromVine(validator) {
3432
+ return async (value) => {
3433
+ try {
3434
+ const output = await validator.validate(value);
3435
+ return {
3436
+ success: true,
3437
+ data: output
3438
+ };
3439
+ } catch (error) {
3440
+ return {
3441
+ success: false,
3442
+ issues: normalizeVineError(error)
3443
+ };
3444
+ }
3445
+ };
3446
+ }
3447
+ function isStandardSchemaFailure(result) {
3448
+ return Array.isArray(result.issues);
3449
+ }
3450
+ function normalizeIssues(issues) {
3451
+ return issues.map((issue) => ({
3452
+ message: issue.message,
3453
+ path: issue.path?.flatMap((segment) => normalizePathSegment(segment))
3454
+ }));
3455
+ }
3456
+ function normalizePathSegment(segment) {
3457
+ const key = isStandardSchemaPathSegment(segment) ? segment.key : segment;
3458
+ return typeof key === "string" || typeof key === "number" ? [key] : [];
3459
+ }
3460
+ function isStandardSchemaPathSegment(segment) {
3461
+ return typeof segment === "object" && segment !== null && "key" in segment;
3462
+ }
3463
+ function normalizeYupIssues(error) {
3464
+ if (!isYupValidationError(error)) {
3465
+ return [{ message: "Validation failed" }];
3466
+ }
3467
+ const issues = error.inner?.length ? error.inner : [error];
3468
+ return issues.map((issue) => ({
3469
+ message: issue.message,
3470
+ path: parsePathString(issue.path)
3471
+ }));
3472
+ }
3473
+ function normalizeJoiIssues(issues) {
3474
+ return issues.map((issue) => ({
3475
+ message: issue.message,
3476
+ path: issue.path ? [...issue.path] : void 0
3477
+ }));
3478
+ }
3479
+ function normalizeAjvIssues(issues) {
3480
+ return issues.map((issue) => ({
3481
+ message: issue.message ?? "Validation failed",
3482
+ path: parseAjvPath(issue)
3483
+ }));
3484
+ }
3485
+ function normalizeValibotIssues(issues) {
3486
+ return issues.map((issue) => ({
3487
+ message: issue.message,
3488
+ path: issue.path?.flatMap(
3489
+ (item) => typeof item.key === "string" || typeof item.key === "number" ? [item.key] : []
3490
+ )
3491
+ }));
3492
+ }
3493
+ function normalizeArkTypeIssues(issues) {
3494
+ const normalized = issues.map((issue) => ({
3495
+ message: issue.message ?? issue.problem ?? issues.summary ?? "Validation failed",
3496
+ path: issue.path ? [...issue.path] : void 0
3497
+ }));
3498
+ return normalized.length ? normalized : [{ message: issues.summary ?? "Validation failed" }];
3499
+ }
3500
+ function normalizeIoTsIssues(issues) {
3501
+ return issues.map((issue) => ({
3502
+ message: issue.message ?? "Validation failed",
3503
+ path: issue.context.map((entry) => entry.key).filter(Boolean)
3504
+ }));
3505
+ }
3506
+ function normalizeSuperstructFailure(failure) {
3507
+ const failures = failure.failures?.() ?? [failure];
3508
+ return failures.map((entry) => ({
3509
+ message: entry.message ?? "Validation failed",
3510
+ path: normalizeSuperstructPath(entry)
3511
+ }));
3512
+ }
3513
+ function normalizeSuperstructPath(failure) {
3514
+ if (failure.path?.length) return [...failure.path];
3515
+ if (typeof failure.key === "string" || typeof failure.key === "number") return [failure.key];
3516
+ return void 0;
3517
+ }
3518
+ function normalizeVineError(error) {
3519
+ if (!isVineValidationError(error)) {
3520
+ return [{ message: "Validation failed" }];
3521
+ }
3522
+ return error.messages.map((message) => ({
3523
+ message: message.message,
3524
+ path: normalizeVineField(message)
3525
+ }));
3526
+ }
3527
+ function normalizeVineField(message) {
3528
+ const path = message.field.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
3529
+ if (typeof message.index === "number" && path.length === 0) {
3530
+ return [message.index];
3531
+ }
3532
+ return path.length ? path : void 0;
3533
+ }
3534
+ function parseAjvPath(issue) {
3535
+ const path = issue.instancePath?.split("/").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
3536
+ if (issue.params?.missingProperty) {
3537
+ return (path ?? []).concat(issue.params.missingProperty);
3538
+ }
3539
+ return path;
3540
+ }
3541
+ function parsePathString(path) {
3542
+ if (!path) return void 0;
3543
+ return path.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
3544
+ }
3545
+ function isYupValidationError(error) {
3546
+ return typeof error === "object" && error !== null && "message" in error;
3547
+ }
3548
+ function isArkTypeErrors(value) {
3549
+ return Array.isArray(value);
3550
+ }
3551
+ function isVineValidationError(error) {
3552
+ return typeof error === "object" && error !== null && "messages" in error && Array.isArray(error.messages);
3553
+ }
3259
3554
  function formatIssue(issue, key, location = "pointer") {
3260
- const path = issue.path.map(String);
3555
+ const path = (issue.path ?? []).map(String);
3261
3556
  const joinedPath = path.join(".");
3262
3557
  if (location === "parameter") {
3263
3558
  return {
@@ -3694,7 +3989,7 @@ function setModelCollectionRoutes(context) {
3694
3989
  });
3695
3990
  router.post(`/${options.queryRouteSegment}`, async (req) => {
3696
3991
  await context.assertAllowed(req, "list");
3697
- const body = parseBodyWithSchema(
3992
+ const body = await parseBodyWithSchema(
3698
3993
  listBodySchema,
3699
3994
  req.body,
3700
3995
  context.getRequestSchema("requestSchemas.advancedList")
@@ -3720,7 +4015,11 @@ function setModelCollectionRoutes(context) {
3720
4015
  router.post("", async (req) => {
3721
4016
  await context.assertAllowed(req, "create");
3722
4017
  const { include_permissions } = parseQuery(requestSchemas.createQuery, req.query);
3723
- const data = parseBodyWithSchema(createBodySchema, req.body, context.getRequestSchema("requestSchemas.create"));
4018
+ const data = await parseBodyWithSchema(
4019
+ createBodySchema,
4020
+ req.body,
4021
+ context.getRequestSchema("requestSchemas.create")
4022
+ );
3724
4023
  const svc = context.getPublicService(req);
3725
4024
  const result = await svc._create(data, {}, { includePermissions: parseBooleanString(include_permissions) });
3726
4025
  handleResultError(result);
@@ -3729,7 +4028,7 @@ function setModelCollectionRoutes(context) {
3729
4028
  router.post(`/${options.mutationRouteSegment}`, async (req) => {
3730
4029
  await context.assertAllowed(req, "create");
3731
4030
  const { include_permissions } = parseQuery(requestSchemas.createQuery, req.query);
3732
- const body = parseNestedBodyWithSchema(
4031
+ const body = await parseNestedBodyWithSchema(
3733
4032
  advancedCreateBodySchema,
3734
4033
  req.body,
3735
4034
  "data",
@@ -3737,7 +4036,7 @@ function setModelCollectionRoutes(context) {
3737
4036
  );
3738
4037
  const { data, select, populate, tasks } = body;
3739
4038
  const advancedOptions = body.options ?? {};
3740
- parseBodyWithSchema(
4039
+ await parseBodyWithSchema(
3741
4040
  advancedCreateBodySchema,
3742
4041
  { data, select, populate, tasks, options: advancedOptions },
3743
4042
  context.getRequestSchema("requestSchemas.advancedCreate.default") ?? context.getRequestSchema("requestSchemas.advancedCreate")
@@ -3775,7 +4074,7 @@ function setModelDocumentRoutes(context) {
3775
4074
  });
3776
4075
  router.post("/count", async (req) => {
3777
4076
  await context.assertAllowed(req, "count");
3778
- const { filter: filter2, options: countOptions = {} } = parseBodyWithSchema(
4077
+ const { filter: filter2, options: countOptions = {} } = await parseBodyWithSchema(
3779
4078
  countBodySchema,
3780
4079
  req.body,
3781
4080
  context.getRequestSchema("requestSchemas.count")
@@ -3806,7 +4105,7 @@ function setModelDocumentRoutes(context) {
3806
4105
  });
3807
4106
  router.post(`/${options.queryRouteSegment}/__filter`, async (req) => {
3808
4107
  await context.assertAllowed(req, "read");
3809
- const body = parseBodyWithSchema(
4108
+ const body = await parseBodyWithSchema(
3810
4109
  readFilterBodySchema,
3811
4110
  req.body,
3812
4111
  context.getRequestSchema("requestSchemas.advancedReadFilter")
@@ -3826,7 +4125,7 @@ function setModelDocumentRoutes(context) {
3826
4125
  router.post(`/${options.queryRouteSegment}/:${options.idParam}`, async (req) => {
3827
4126
  await context.assertAllowed(req, "read");
3828
4127
  const id = parsePathParam(req.params[options.idParam], options.idParam);
3829
- const body = parseBodyWithSchema(
4128
+ const body = await parseBodyWithSchema(
3830
4129
  readByIdBodySchema,
3831
4130
  req.body,
3832
4131
  context.getRequestSchema("requestSchemas.advancedRead")
@@ -3847,7 +4146,11 @@ function setModelDocumentRoutes(context) {
3847
4146
  await context.assertAllowed(req, "update");
3848
4147
  const id = parsePathParam(req.params[options.idParam], options.idParam);
3849
4148
  const { returning_all, include_permissions } = parseQuery(requestSchemas.updateQuery, req.query);
3850
- const data = parseBodyWithSchema(updateBodySchema, req.body, context.getRequestSchema("requestSchemas.update"));
4149
+ const data = await parseBodyWithSchema(
4150
+ updateBodySchema,
4151
+ req.body,
4152
+ context.getRequestSchema("requestSchemas.update")
4153
+ );
3851
4154
  const svc = context.getPublicService(req);
3852
4155
  const result = await svc._update(
3853
4156
  id,
@@ -3865,7 +4168,7 @@ function setModelDocumentRoutes(context) {
3865
4168
  await context.assertAllowed(req, "update");
3866
4169
  const id = parsePathParam(req.params[options.idParam], options.idParam);
3867
4170
  const { returning_all, include_permissions } = parseQuery(requestSchemas.updateQuery, req.query);
3868
- const body = parseNestedBodyWithSchema(
4171
+ const body = await parseNestedBodyWithSchema(
3869
4172
  advancedUpdateBodySchema,
3870
4173
  req.body,
3871
4174
  "data",
@@ -3873,7 +4176,7 @@ function setModelDocumentRoutes(context) {
3873
4176
  );
3874
4177
  const { data, select, populate, tasks } = body;
3875
4178
  const advancedOptions = body.options ?? {};
3876
- parseBodyWithSchema(
4179
+ await parseBodyWithSchema(
3877
4180
  advancedUpdateBodySchema,
3878
4181
  { data, select, populate, tasks, options: advancedOptions },
3879
4182
  context.getRequestSchema("requestSchemas.advancedUpdate.default") ?? context.getRequestSchema("requestSchemas.advancedUpdate")
@@ -3897,7 +4200,11 @@ function setModelDocumentRoutes(context) {
3897
4200
  await context.assertAllowed(req, "upsert");
3898
4201
  const svc = context.getPublicService(req);
3899
4202
  const { returning_all, include_permissions } = parseQuery(requestSchemas.upsertQuery, req.query);
3900
- const body = parseBodyWithSchema(upsertBodySchema, req.body, context.getRequestSchema("requestSchemas.upsert"));
4203
+ const body = await parseBodyWithSchema(
4204
+ upsertBodySchema,
4205
+ req.body,
4206
+ context.getRequestSchema("requestSchemas.upsert")
4207
+ );
3901
4208
  const result = await svc._upsert(
3902
4209
  body,
3903
4210
  {},
@@ -3913,7 +4220,7 @@ function setModelDocumentRoutes(context) {
3913
4220
  await context.assertAllowed(req, "upsert");
3914
4221
  const svc = context.getPublicService(req);
3915
4222
  const { returning_all, include_permissions } = parseQuery(requestSchemas.upsertQuery, req.query);
3916
- const body = parseNestedBodyWithSchema(
4223
+ const body = await parseNestedBodyWithSchema(
3917
4224
  advancedUpsertBodySchema,
3918
4225
  req.body,
3919
4226
  "data",
@@ -3921,7 +4228,7 @@ function setModelDocumentRoutes(context) {
3921
4228
  );
3922
4229
  const { data, select, populate, tasks } = body;
3923
4230
  const advancedOptions = body.options ?? {};
3924
- parseBodyWithSchema(
4231
+ await parseBodyWithSchema(
3925
4232
  advancedUpsertBodySchema,
3926
4233
  { data, select, populate, tasks, options: advancedOptions },
3927
4234
  context.getRequestSchema("requestSchemas.advancedUpsert.default") ?? context.getRequestSchema("requestSchemas.advancedUpsert")
@@ -3958,7 +4265,7 @@ function setModelDocumentRoutes(context) {
3958
4265
  router.post("/distinct/:field", async (req) => {
3959
4266
  await context.assertAllowed(req, "distinct");
3960
4267
  const field = parsePathParam(req.params.field, "field");
3961
- const { filter: filter2 } = parseBodyWithSchema(
4268
+ const { filter: filter2 } = await parseBodyWithSchema(
3962
4269
  distinctBodySchema,
3963
4270
  req.body,
3964
4271
  context.getRequestSchema("requestSchemas.distinct")
@@ -3989,7 +4296,7 @@ function setModelSubDocumentRoutes(context) {
3989
4296
  async (req) => {
3990
4297
  await context.assertAllowed(req, `subs.${sub}.list`);
3991
4298
  const id = parsePathParam(req.params[context.options.idParam], context.options.idParam);
3992
- const body = parseBodyWithSchema(
4299
+ const body = await parseBodyWithSchema(
3993
4300
  subListBodySchema,
3994
4301
  req.body,
3995
4302
  context.getRequestSchema("requestSchemas.subList")
@@ -4003,7 +4310,7 @@ function setModelSubDocumentRoutes(context) {
4003
4310
  context.router.patch(`/:${context.options.idParam}/${sub}`, async (req) => {
4004
4311
  await context.assertAllowed(req, `subs.${sub}.update`);
4005
4312
  const id = parsePathParam(req.params[context.options.idParam], context.options.idParam);
4006
- const data = parseBodyWithSchema(
4313
+ const data = await parseBodyWithSchema(
4007
4314
  subMutationBodySchema,
4008
4315
  req.body,
4009
4316
  context.getRequestSchema("requestSchemas.subBulkUpdate")
@@ -4028,7 +4335,7 @@ function setModelSubDocumentRoutes(context) {
4028
4335
  await context.assertAllowed(req, `subs.${sub}.read`);
4029
4336
  const id = parsePathParam(req.params[context.options.idParam], context.options.idParam);
4030
4337
  const subId = parsePathParam(req.params.subId, "subId");
4031
- const body = parseBodyWithSchema(
4338
+ const body = await parseBodyWithSchema(
4032
4339
  subReadBodySchema,
4033
4340
  req.body,
4034
4341
  context.getRequestSchema("requestSchemas.subRead")
@@ -4045,7 +4352,7 @@ function setModelSubDocumentRoutes(context) {
4045
4352
  await context.assertAllowed(req, `subs.${sub}.update`);
4046
4353
  const id = parsePathParam(req.params[context.options.idParam], context.options.idParam);
4047
4354
  const subId = parsePathParam(req.params.subId, "subId");
4048
- const data = parseBodyWithSchema(
4355
+ const data = await parseBodyWithSchema(
4049
4356
  subMutationBodySchema,
4050
4357
  req.body,
4051
4358
  context.getRequestSchema("requestSchemas.subUpdate")
@@ -4058,7 +4365,7 @@ function setModelSubDocumentRoutes(context) {
4058
4365
  context.router.post(`/:${context.options.idParam}/${sub}`, async (req) => {
4059
4366
  await context.assertAllowed(req, `subs.${sub}.create`);
4060
4367
  const id = parsePathParam(req.params[context.options.idParam], context.options.idParam);
4061
- const data = parseBodyWithSchema(
4368
+ const data = await parseBodyWithSchema(
4062
4369
  subMutationBodySchema,
4063
4370
  req.body,
4064
4371
  context.getRequestSchema("requestSchemas.subCreate")
@@ -4781,7 +5088,7 @@ var DataRouter = class {
4781
5088
  page,
4782
5089
  pageSize,
4783
5090
  options = {}
4784
- } = parseBodyWithSchema(dataListBodySchema, req.body, this.getRequestSchema("requestSchemas.advancedList"));
5091
+ } = await parseBodyWithSchema(dataListBodySchema, req.body, this.getRequestSchema("requestSchemas.advancedList"));
4785
5092
  const { includeCount, includeExtraHeaders } = options;
4786
5093
  const svc = this.getService(req);
4787
5094
  const result = await svc.find(
@@ -4809,7 +5116,7 @@ var DataRouter = class {
4809
5116
  });
4810
5117
  this.router.post(`/${this.options.queryRouteSegment}/__filter`, async (req) => {
4811
5118
  await this.assertAllowed(req, "read");
4812
- let { filter: filter2, select } = parseBodyWithSchema(
5119
+ let { filter: filter2, select } = await parseBodyWithSchema(
4813
5120
  dataReadFilterBodySchema,
4814
5121
  req.body,
4815
5122
  this.getRequestSchema("requestSchemas.advancedReadFilter")
@@ -4823,7 +5130,7 @@ var DataRouter = class {
4823
5130
  this.router.post(`/${this.options.queryRouteSegment}/:${this.options.idParam}`, async (req) => {
4824
5131
  await this.assertAllowed(req, "read");
4825
5132
  const id = parsePathParam(req.params[this.options.idParam], this.options.idParam);
4826
- let { select } = parseBodyWithSchema(
5133
+ let { select } = await parseBodyWithSchema(
4827
5134
  dataReadByIdBodySchema,
4828
5135
  req.body,
4829
5136
  this.getRequestSchema("requestSchemas.advancedRead")
@@ -4952,6 +5259,17 @@ var index_default = acl;
4952
5259
  acl,
4953
5260
  combineRoutes,
4954
5261
  createAccessRuntime,
5262
+ defineRequestSchema,
5263
+ fromAjv,
5264
+ fromArkType,
5265
+ fromIoTs,
5266
+ fromJoi,
5267
+ fromStandardSchema,
5268
+ fromSuperstruct,
5269
+ fromValibot,
5270
+ fromVine,
5271
+ fromYup,
5272
+ fromZod,
4955
5273
  getDefaultModelOption,
4956
5274
  getDefaultModelOptions,
4957
5275
  getGlobalOption,