@adaptivestone/framework 5.0.0-beta.45 → 5.0.0-beta.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/codegen/appTypes.d.ts +19 -0
  3. package/dist/codegen/appTypes.js +49 -0
  4. package/dist/codegen/appTypes.js.map +1 -0
  5. package/dist/codegen/collectMetadata.d.ts +37 -0
  6. package/dist/codegen/collectMetadata.js +51 -0
  7. package/dist/codegen/collectMetadata.js.map +1 -0
  8. package/dist/codegen/emit.d.ts +29 -0
  9. package/dist/codegen/emit.js +214 -0
  10. package/dist/codegen/emit.js.map +1 -0
  11. package/dist/codegen/index.d.ts +16 -0
  12. package/dist/codegen/index.js +18 -0
  13. package/dist/codegen/index.js.map +1 -0
  14. package/dist/codegen/routeTypes.d.ts +13 -0
  15. package/dist/codegen/routeTypes.js +126 -0
  16. package/dist/codegen/routeTypes.js.map +1 -0
  17. package/dist/commands/GenerateTypes.d.ts +0 -4
  18. package/dist/commands/GenerateTypes.js +4 -42
  19. package/dist/commands/GenerateTypes.js.map +1 -1
  20. package/dist/controllers/Auth.d.ts +15 -124
  21. package/dist/controllers/Auth.js.map +1 -1
  22. package/dist/controllers/Auth.routes.gen.d.ts +57 -0
  23. package/dist/controllers/Auth.routes.gen.js +10 -0
  24. package/dist/controllers/Auth.routes.gen.js.map +1 -0
  25. package/dist/controllers/Home.routes.gen.d.ts +14 -0
  26. package/dist/controllers/Home.routes.gen.js +10 -0
  27. package/dist/controllers/Home.routes.gen.js.map +1 -0
  28. package/dist/controllers/index.d.ts +23 -3
  29. package/dist/controllers/index.js +355 -8
  30. package/dist/controllers/index.js.map +1 -1
  31. package/dist/helpers/files.js +2 -0
  32. package/dist/helpers/files.js.map +1 -1
  33. package/dist/models/Sequence.js +1 -1
  34. package/dist/models/Sequence.js.map +1 -1
  35. package/dist/models/User.d.ts +28 -28
  36. package/dist/models/UserOld.d.ts +16 -6
  37. package/dist/modules/AbstractController.d.ts +7 -29
  38. package/dist/modules/AbstractController.js +1 -253
  39. package/dist/modules/AbstractController.js.map +1 -1
  40. package/dist/server.d.ts +0 -1
  41. package/dist/server.js +11 -1
  42. package/dist/server.js.map +1 -1
  43. package/dist/services/http/HttpServer.d.ts +9 -0
  44. package/dist/services/http/HttpServer.js +20 -9
  45. package/dist/services/http/HttpServer.js.map +1 -1
  46. package/dist/services/http/middleware/AbstractMiddleware.d.ts +19 -4
  47. package/dist/services/http/middleware/AbstractMiddleware.js +16 -5
  48. package/dist/services/http/middleware/AbstractMiddleware.js.map +1 -1
  49. package/dist/services/http/middleware/GetUserByToken.d.ts +9 -0
  50. package/dist/services/http/middleware/GetUserByToken.js +9 -0
  51. package/dist/services/http/middleware/GetUserByToken.js.map +1 -1
  52. package/dist/services/http/routing/ExpressAdapter.d.ts +12 -0
  53. package/dist/services/http/routing/ExpressAdapter.js +93 -0
  54. package/dist/services/http/routing/ExpressAdapter.js.map +1 -0
  55. package/dist/services/http/routing/RouteNode.d.ts +99 -0
  56. package/dist/services/http/routing/RouteNode.js +21 -0
  57. package/dist/services/http/routing/RouteNode.js.map +1 -0
  58. package/dist/services/http/routing/RouteRegistry.d.ts +37 -0
  59. package/dist/services/http/routing/RouteRegistry.js +207 -0
  60. package/dist/services/http/routing/RouteRegistry.js.map +1 -0
  61. package/dist/services/http/routing/formatTree.d.ts +23 -0
  62. package/dist/services/http/routing/formatTree.js +158 -0
  63. package/dist/services/http/routing/formatTree.js.map +1 -0
  64. package/dist/services/http/routing/match.d.ts +30 -0
  65. package/dist/services/http/routing/match.js +128 -0
  66. package/dist/services/http/routing/match.js.map +1 -0
  67. package/dist/services/http/routing/middlewareNormalization.d.ts +16 -0
  68. package/dist/services/http/routing/middlewareNormalization.js +28 -0
  69. package/dist/services/http/routing/middlewareNormalization.js.map +1 -0
  70. package/dist/services/http/types.d.ts +74 -0
  71. package/dist/services/http/types.js +8 -0
  72. package/dist/services/http/types.js.map +1 -0
  73. package/dist/services/validate/ValidateService.d.ts +46 -23
  74. package/dist/services/validate/ValidateService.js +101 -74
  75. package/dist/services/validate/ValidateService.js.map +1 -1
  76. package/dist/services/validate/ValidationError.d.ts +35 -0
  77. package/dist/services/validate/ValidationError.js +77 -0
  78. package/dist/services/validate/ValidationError.js.map +1 -0
  79. package/dist/services/validate/drivers/StandardSchemaDriver.d.ts +15 -0
  80. package/dist/services/validate/drivers/StandardSchemaDriver.js +34 -0
  81. package/dist/services/validate/drivers/StandardSchemaDriver.js.map +1 -0
  82. package/dist/services/validate/drivers/YupDriver.d.ts +21 -0
  83. package/dist/services/validate/drivers/YupDriver.js +66 -0
  84. package/dist/services/validate/drivers/YupDriver.js.map +1 -0
  85. package/dist/services/validate/types.d.ts +104 -0
  86. package/dist/services/validate/types.js +11 -0
  87. package/dist/services/validate/types.js.map +1 -0
  88. package/dist/tests/setupVitest.js +4 -1
  89. package/dist/tests/setupVitest.js.map +1 -1
  90. package/dist/tests/testHelpers.d.ts +18 -16
  91. package/package.json +17 -8
  92. package/dist/commands/Documentation.d.ts +0 -5
  93. package/dist/commands/Documentation.js +0 -15
  94. package/dist/commands/Documentation.js.map +0 -1
  95. package/dist/commands/GetOpenApiJson.d.ts +0 -17
  96. package/dist/commands/GetOpenApiJson.js +0 -272
  97. package/dist/commands/GetOpenApiJson.js.map +0 -1
  98. package/dist/services/documentation/DocumentationGenerator.d.ts +0 -11
  99. package/dist/services/documentation/DocumentationGenerator.js +0 -130
  100. package/dist/services/documentation/DocumentationGenerator.js.map +0 -1
  101. package/dist/services/validate/drivers/AbstractValidator.d.ts +0 -14
  102. package/dist/services/validate/drivers/AbstractValidator.js +0 -29
  103. package/dist/services/validate/drivers/AbstractValidator.js.map +0 -1
  104. package/dist/services/validate/drivers/CustomValidator.d.ts +0 -14
  105. package/dist/services/validate/drivers/CustomValidator.js +0 -48
  106. package/dist/services/validate/drivers/CustomValidator.js.map +0 -1
  107. package/dist/services/validate/drivers/YupValidator.d.ts +0 -13
  108. package/dist/services/validate/drivers/YupValidator.js +0 -86
  109. package/dist/services/validate/drivers/YupValidator.js.map +0 -1
@@ -0,0 +1,74 @@
1
+ /**
2
+ * HTTP type contracts. Pure type-only — no runtime, no behavior.
3
+ *
4
+ * Per-controller `<File>.routes.gen.ts` files (hand-written today, codegen-emitted
5
+ * later) compose these primitives into per-route `Request<M, P>` helpers.
6
+ */
7
+ import type { TFunction } from 'i18next';
8
+ import type { IApp } from '../../server.ts';
9
+ import type { FrameworkRequest } from './HttpServer.ts';
10
+ /**
11
+ * Module-augmentation point for app-wide `appInfo` extensions. Users add:
12
+ *
13
+ * declare module '@adaptivestone/framework' {
14
+ * interface AppInfoExtensions {
15
+ * requestId: string;
16
+ * sentryTransaction?: SentryTransaction;
17
+ * }
18
+ * }
19
+ *
20
+ * Per-route precision (e.g. `appInfo.user` from a route's middleware stack)
21
+ * comes from the per-controller `Request<M, P>` helper, not from this interface.
22
+ */
23
+ export interface AppInfoExtensions {
24
+ }
25
+ /**
26
+ * `appInfo` shape populated by the framework's built-in middlewares before any
27
+ * user middleware runs. Mirrors what `HttpServer`'s middleware chain sets per
28
+ * request (`PrepareAppInfo`, `IpDetector`, `I18n`) plus the slots that the
29
+ * route-level validation populates (`request`, `query`).
30
+ *
31
+ * `i18n` is required — `I18nMiddleware` is part of `HttpServer`'s default
32
+ * chain (`HttpServer.ts:63`) and runs on every HTTP request before any
33
+ * controller. If a user removes it, they should augment `BaseAppInfo` to
34
+ * relax the field.
35
+ */
36
+ export interface BaseAppInfo {
37
+ app: IApp;
38
+ ip?: string | undefined;
39
+ i18n: {
40
+ t: TFunction;
41
+ language: string;
42
+ };
43
+ request: Record<string, unknown>;
44
+ query: Record<string, unknown>;
45
+ }
46
+ /**
47
+ * Default request context handlers see when no per-route `Request<M, P>` is
48
+ * imported. Equivalent to today's `FrameworkRequest` plus `AppInfoExtensions`.
49
+ */
50
+ export type BaseRequestContext = FrameworkRequest & {
51
+ appInfo: BaseAppInfo & AppInfoExtensions;
52
+ };
53
+ /**
54
+ * Extract the static `provides` shape from a middleware class. Middlewares
55
+ * declare what they add to `appInfo` via:
56
+ *
57
+ * class GetUserByToken extends AbstractMiddleware {
58
+ * static get provides() {
59
+ * return {} as { user?: InstanceType<TUser> };
60
+ * }
61
+ * }
62
+ *
63
+ * `ProvidesOf<typeof GetUserByToken>` resolves to `{ user?: InstanceType<TUser> }`.
64
+ * Returns `Record<never, never>` for middlewares without `provides`.
65
+ */
66
+ export type ProvidesOf<T> = T extends {
67
+ provides: infer P;
68
+ } ? P : Record<never, never>;
69
+ /**
70
+ * Reduce a tuple of middleware classes (or `[Class, params]` tuples) to the
71
+ * intersection of their `provides` shapes. Used by per-route `Request<M, P>`
72
+ * to layer middleware-contributed `appInfo` fields onto the base context.
73
+ */
74
+ export type UnionAppInfoProvides<MWs extends readonly unknown[]> = MWs extends readonly [infer Head, ...infer Tail extends readonly unknown[]] ? ProvidesOf<Head extends readonly [infer C, unknown] ? C : Head> & UnionAppInfoProvides<Tail> : Record<never, never>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * HTTP type contracts. Pure type-only — no runtime, no behavior.
3
+ *
4
+ * Per-controller `<File>.routes.gen.ts` files (hand-written today, codegen-emitted
5
+ * later) compose these primitives into per-route `Request<M, P>` helpers.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/http/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,31 +1,54 @@
1
- export default ValidateService;
1
+ import type { TFunction } from 'i18next';
2
+ import Base from '../../modules/Base.ts';
3
+ import type { IApp } from '../../server.ts';
4
+ import type { ValidatorDriver } from './types.ts';
5
+ /**
6
+ * Per-route validator dispatcher. Resolves a `ValidatorDriver` once at
7
+ * construction (cheap sync property check) and delegates per-request
8
+ * validation to it. Drivers are vendor-aware — see `./drivers/`.
9
+ *
10
+ * User-extension API: `ValidateService.register(myDriver)` prepends
11
+ * a custom driver, giving it priority over the built-ins. Drivers
12
+ * are matched in order via `canHandle(body)`; first match wins.
13
+ *
14
+ * Built-in resolution order (most specific first):
15
+ * 1. yupDriver — Standard Schema with `vendor: 'yup'` (strip-unknown)
16
+ * 2. standardSchemaDriver — any other `~standard`-conformant lib
17
+ *
18
+ * Schemas that match no driver throw at construction with a migration
19
+ * message — including legacy `{validate, cast}` plain objects (removed
20
+ * in 5.0; wrap as Standard Schema, ~10 lines).
21
+ */
2
22
  declare class ValidateService extends Base {
3
- static drivers: {
4
- YupValidator: typeof YupValidator;
5
- CustomValidator: typeof CustomValidator;
6
- };
7
- static isValidatorExists(validator: any): boolean;
8
- static getDriverByValidatorBody(app: any, body?: {}): {};
9
- constructor(app: any, validator: any);
10
- validator: {} | null;
23
+ schema: unknown;
24
+ driver: ValidatorDriver | null;
25
+ static drivers: ValidatorDriver[];
26
+ constructor(app: IApp, schema: unknown | null);
11
27
  /**
12
- * Filter middlewares by route path and select all parameters
28
+ * Find the first registered driver whose `canHandle(schema)` returns true.
13
29
  */
14
- filterRelatedParametersByRoute(middlewares: any, method: any, path: any): any;
30
+ static resolve(schema: unknown): ValidatorDriver | null;
15
31
  /**
16
- * Group all middleware(routes + controller) parameters
32
+ * Register a custom driver. By default prepends so user drivers take
33
+ * priority over the built-ins (e.g., to override yup-strip behavior
34
+ * or to add a non-Standard-Schema lib like raw Joi).
17
35
  */
18
- getMiddlewareParams(controllerMiddlewares: any, AllrouteMiddlewares: any, options: any): {
19
- request: any[];
20
- query: any[];
21
- };
22
- validateSchema(req: any, validator: any, data: any): Promise<any>;
23
- validateArrayOfSchemas(req: any, validators: any, data: any): Promise<any[]>;
36
+ static register(driver: ValidatorDriver, position?: 'first' | 'last'): void;
24
37
  /**
25
- * Validate req data. For example req.body, req.query
38
+ * Validate `data` against the route's schema. Returns the cast value
39
+ * on success; throws `ValidationError` on failure. If no schema was
40
+ * provided, returns `data` unchanged.
41
+ *
42
+ * If `i18n` is supplied, error messages are translated through `i18n.t`
43
+ * before the error is re-thrown — both `.message` (wire-shape) and
44
+ * `.issues` (structured). Skip the argument and consumers that don't
45
+ * need translation (workers, RPC, tests) get raw keys back. The HTTP
46
+ * controller path passes `req.appInfo.i18n` so users never have to
47
+ * remember a translation step.
26
48
  */
27
- validateReqData(req: any, options: any): Promise<any>;
49
+ validate(data: unknown, i18n?: {
50
+ t: TFunction;
51
+ } | null): Promise<unknown>;
52
+ static get loggerGroup(): string;
28
53
  }
29
- import Base from '../../modules/Base.ts';
30
- import YupValidator from './drivers/YupValidator.js';
31
- import CustomValidator from './drivers/CustomValidator.js';
54
+ export default ValidateService;
@@ -1,95 +1,122 @@
1
- import { isSchema } from 'yup';
2
1
  import Base from "../../modules/Base.js";
3
- import CustomValidator from './drivers/CustomValidator.js';
4
- import YupValidator from './drivers/YupValidator.js';
2
+ import { standardSchemaDriver } from "./drivers/StandardSchemaDriver.js";
3
+ import { yupDriver } from "./drivers/YupDriver.js";
4
+ import { issuesToPayload, ValidationError } from "./ValidationError.js";
5
+ /**
6
+ * Per-route validator dispatcher. Resolves a `ValidatorDriver` once at
7
+ * construction (cheap sync property check) and delegates per-request
8
+ * validation to it. Drivers are vendor-aware — see `./drivers/`.
9
+ *
10
+ * User-extension API: `ValidateService.register(myDriver)` prepends
11
+ * a custom driver, giving it priority over the built-ins. Drivers
12
+ * are matched in order via `canHandle(body)`; first match wins.
13
+ *
14
+ * Built-in resolution order (most specific first):
15
+ * 1. yupDriver — Standard Schema with `vendor: 'yup'` (strip-unknown)
16
+ * 2. standardSchemaDriver — any other `~standard`-conformant lib
17
+ *
18
+ * Schemas that match no driver throw at construction with a migration
19
+ * message — including legacy `{validate, cast}` plain objects (removed
20
+ * in 5.0; wrap as Standard Schema, ~10 lines).
21
+ */
5
22
  class ValidateService extends Base {
6
- constructor(app, validator) {
23
+ schema;
24
+ driver;
25
+ static drivers = [yupDriver, standardSchemaDriver];
26
+ constructor(app, schema) {
7
27
  super(app);
8
- this.validator = validator
9
- ? ValidateService.getDriverByValidatorBody(app, validator)
10
- : null;
11
- }
12
- static drivers = {
13
- YupValidator,
14
- CustomValidator,
15
- };
16
- static isValidatorExists(validator) {
17
- if (!(validator instanceof Object)) {
18
- return false;
19
- }
20
- return Object.values(ValidateService.drivers).some((driver) => validator instanceof driver);
21
- }
22
- static getDriverByValidatorBody(app, body = {}) {
23
- if (ValidateService.isValidatorExists(body)) {
24
- return body;
28
+ this.schema = schema;
29
+ if (schema) {
30
+ const driver = ValidateService.resolve(schema);
31
+ if (!driver) {
32
+ throw new Error(buildNoDriverMessage(schema));
33
+ }
34
+ this.driver = driver;
25
35
  }
26
- if (isSchema(body)) {
27
- const yupValidator = new YupValidator(app, body);
28
- return yupValidator;
36
+ else {
37
+ this.driver = null;
29
38
  }
30
- const customValidator = new CustomValidator(app, body);
31
- return customValidator;
32
39
  }
33
40
  /**
34
- * Filter middlewares by route path and select all parameters
41
+ * Find the first registered driver whose `canHandle(schema)` returns true.
35
42
  */
36
- filterRelatedParametersByRoute(middlewares, method, path) {
37
- const middlewaresParams = middlewares
38
- .filter((middleware) => middleware.method.toLowerCase() === method.toLowerCase() &&
39
- middleware.fullPath.toLowerCase() === path.toLowerCase())
40
- ?.map((middleware) => {
41
- const instance = new middleware.MiddlewareFunction(this.app, middleware.params);
42
- return instance.relatedReqParameters;
43
- });
44
- return middlewaresParams;
43
+ static resolve(schema) {
44
+ return (ValidateService.drivers.find((driver) => driver.canHandle(schema)) ?? null);
45
45
  }
46
46
  /**
47
- * Group all middleware(routes + controller) parameters
47
+ * Register a custom driver. By default prepends so user drivers take
48
+ * priority over the built-ins (e.g., to override yup-strip behavior
49
+ * or to add a non-Standard-Schema lib like raw Joi).
48
50
  */
49
- getMiddlewareParams(controllerMiddlewares, AllrouteMiddlewares, options) {
50
- const { method, path } = options;
51
- const routeMiddlewaresParams = this.filterRelatedParametersByRoute(AllrouteMiddlewares, method, path);
52
- const controllerMiddlewaresParams = this.filterRelatedParametersByRoute(controllerMiddlewares, method, path);
53
- return {
54
- request: [
55
- ...controllerMiddlewaresParams.map((x) => x.request),
56
- ...routeMiddlewaresParams.map((x) => x.request),
57
- ],
58
- query: [
59
- ...controllerMiddlewaresParams.map((x) => x.query),
60
- ...routeMiddlewaresParams.map((x) => x.query),
61
- ],
62
- };
63
- }
64
- async validateSchema(req, validator, data) {
65
- if (!validator) {
66
- return {};
51
+ static register(driver, position = 'first') {
52
+ if (position === 'first') {
53
+ ValidateService.drivers.unshift(driver);
67
54
  }
68
- await validator.validateFields(data, req);
69
- return validator.castFields(data, req);
70
- }
71
- async validateArrayOfSchemas(req, validators, data) {
72
- const result = [];
73
- for (const validator of validators) {
74
- const formatedValidator = ValidateService.getDriverByValidatorBody(this.app, validator);
75
- result.push(this.validateSchema(req, formatedValidator, data));
55
+ else {
56
+ ValidateService.drivers.push(driver);
76
57
  }
77
- return Promise.all(result);
78
58
  }
79
59
  /**
80
- * Validate req data. For example req.body, req.query
60
+ * Validate `data` against the route's schema. Returns the cast value
61
+ * on success; throws `ValidationError` on failure. If no schema was
62
+ * provided, returns `data` unchanged.
63
+ *
64
+ * If `i18n` is supplied, error messages are translated through `i18n.t`
65
+ * before the error is re-thrown — both `.message` (wire-shape) and
66
+ * `.issues` (structured). Skip the argument and consumers that don't
67
+ * need translation (workers, RPC, tests) get raw keys back. The HTTP
68
+ * controller path passes `req.appInfo.i18n` so users never have to
69
+ * remember a translation step.
81
70
  */
82
- async validateReqData(req, options) {
83
- const { selectedReqData, additionalMiddlewareFieldsData } = options;
84
- const { middlewaresInfo, routeMiddlewaresReg, options: routeOptions, } = additionalMiddlewareFieldsData;
85
- let validatedFields = await this.validateSchema(req, this.validator, selectedReqData);
86
- const additionalMiddlewareSchemas = this.getMiddlewareParams(middlewaresInfo, routeMiddlewaresReg, routeOptions)[routeOptions.prefix];
87
- if (additionalMiddlewareSchemas.length) {
88
- const middlewareValidatedFields = await this.validateArrayOfSchemas(req, additionalMiddlewareSchemas, selectedReqData);
89
- validatedFields = Object.assign({}, validatedFields, ...middlewareValidatedFields);
71
+ async validate(data, i18n) {
72
+ if (!this.driver) {
73
+ return data;
74
+ }
75
+ try {
76
+ return await this.driver.validate(this.schema, data);
90
77
  }
91
- return validatedFields;
78
+ catch (err) {
79
+ if (i18n?.t && err instanceof ValidationError) {
80
+ translateInPlace(err, i18n.t);
81
+ }
82
+ throw err;
83
+ }
84
+ }
85
+ static get loggerGroup() {
86
+ return 'service';
87
+ }
88
+ }
89
+ function translateInPlace(err, t) {
90
+ err.issues = err.issues.map((issue) => ({
91
+ ...issue,
92
+ message: t(issue.message, issue.message, issue.params),
93
+ }));
94
+ err.message = issuesToPayload(err.issues);
95
+ }
96
+ function buildNoDriverMessage(schema) {
97
+ const looksLegacy = typeof schema === 'object' &&
98
+ schema !== null &&
99
+ typeof schema.validate === 'function' &&
100
+ typeof schema.cast === 'function';
101
+ if (looksLegacy) {
102
+ return ('Schema appears to be a legacy `{validate, cast}` plain object. ' +
103
+ 'This pattern was removed in @adaptivestone/framework@5.0. Wrap as ' +
104
+ 'Standard Schema (https://standardschema.dev/) — ~10 lines:\n\n' +
105
+ ' const schema: StandardSchemaV1<Input, Output> = {\n' +
106
+ " '~standard': {\n" +
107
+ ' version: 1,\n' +
108
+ " vendor: 'mycustom',\n" +
109
+ ' validate(value) {\n' +
110
+ ' // your validation logic; return {value} on success or {issues} on failure\n' +
111
+ ' },\n' +
112
+ ' },\n' +
113
+ ' };');
92
114
  }
115
+ return ('No ValidatorDriver matches this schema. Schemas must implement ' +
116
+ 'Standard Schema (`~standard`). Yup ≥1.7, Zod ≥3.24, Valibot, and ArkType ' +
117
+ 'all conform — see https://standardschema.dev/. ' +
118
+ 'Custom validators: implement the `~standard` interface, or register ' +
119
+ 'a custom driver via `ValidateService.register(driver)`.');
93
120
  }
94
121
  export default ValidateService;
95
122
  //# sourceMappingURL=ValidateService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ValidateService.js","sourceRoot":"","s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2B,CAAC,MAAM,EAAE,CAAC;YACvC,MAAM,yBAAyB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CACjE,GAAG,EACH,2BAA2B,EAC3B,eAAe,CAChB,CAAC;YAEF,eAAe,GAAG,MAAM,CAAC,MAAM,CAC7B,EAAE,EACF,eAAe,EACf,GAAG,yBAAyB,CAC7B,CAAC;QACJ,CAAC;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;;AAGH,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ValidateService.js","sourceRoot":"","sources":["../../../src/services/validate/ValidateService.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,uBAAuB,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,eAAgB,SAAQ,IAAI;IAChC,MAAM,CAAU;IAChB,MAAM,CAAyB;IAE/B,MAAM,CAAC,OAAO,GAAsB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;IAEtE,YAAY,GAAS,EAAE,MAAsB;QAC3C,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;YAChD,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,C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C,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAsB;KAC5E,CAAC,CAAC,CAAC;IACJ,GAAG,CAAC,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAe;IAC3C,MAAM,WAAW,GACf,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,OAAQ,MAAiC,CAAC,QAAQ,KAAK,UAAU;QACjE,OAAQ,MAA6B,CAAC,IAAI,KAAK,UAAU,CAAC;IAE5D,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CACL,iEAAiE;YACjE,oEAAoE;YACpE,gEAAgE;YAChE,uDAAuD;YACvD,sBAAsB;YACtB,qBAAqB;YACrB,6BAA6B;YAC7B,2BAA2B;YAC3B,sFAAsF;YACtF,YAAY;YACZ,UAAU;YACV,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,iEAAiE;QACjE,2EAA2E;QAC3E,iDAAiD;QACjD,sEAAsE;QACtE,yDAAyD,CAC1D,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { ValidationIssue } from './types.ts';
2
+ /**
3
+ * The wire shape that goes out via `res.json({ errors: err.message })`.
4
+ *
5
+ * Each key is a field path. Each value is either a single message string
6
+ * or an array of messages. Both forms are preserved as-given — no
7
+ * normalization — so consumers see the same response bytes regardless
8
+ * of which validator produced the error.
9
+ */
10
+ export type ValidationErrorPayload = Record<string, string | string[]>;
11
+ /**
12
+ * Framework-owned validation error. Replaces yup's `ValidationError` at the
13
+ * framework layer.
14
+ *
15
+ * Wire compatibility note — `.message` is the path-keyed payload object,
16
+ * NOT a string. This mirrors yup's hack: `res.json({ errors: err.message })`
17
+ * in `AbstractController.ts:222` serializes the object directly to produce
18
+ * `{ "errors": { "fieldName": [...] | "...", ... } }`. Existing user
19
+ * catch-blocks that read `err.message` keep working unchanged.
20
+ *
21
+ * `.issues` is the canonical list (one entry per field/message pair) that
22
+ * non-wire consumers (logging, observability) should iterate.
23
+ */
24
+ export declare class ValidationError extends Error {
25
+ issues: ValidationIssue[];
26
+ message: ValidationErrorPayload;
27
+ constructor(payload: ValidationErrorPayload | ReadonlyArray<ValidationIssue>);
28
+ /**
29
+ * Cross-realm-safe duck check. Mirrors `yup.ValidationError.isError`.
30
+ * Use this in framework code instead of `instanceof` when the error
31
+ * may have crossed a module-graph boundary.
32
+ */
33
+ static isValidationError(err: unknown): err is ValidationError;
34
+ }
35
+ export declare function issuesToPayload(issues: ReadonlyArray<ValidationIssue>): ValidationErrorPayload;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Framework-owned validation error. Replaces yup's `ValidationError` at the
3
+ * framework layer.
4
+ *
5
+ * Wire compatibility note — `.message` is the path-keyed payload object,
6
+ * NOT a string. This mirrors yup's hack: `res.json({ errors: err.message })`
7
+ * in `AbstractController.ts:222` serializes the object directly to produce
8
+ * `{ "errors": { "fieldName": [...] | "...", ... } }`. Existing user
9
+ * catch-blocks that read `err.message` keep working unchanged.
10
+ *
11
+ * `.issues` is the canonical list (one entry per field/message pair) that
12
+ * non-wire consumers (logging, observability) should iterate.
13
+ */
14
+ export class ValidationError extends Error {
15
+ issues;
16
+ constructor(payload) {
17
+ super();
18
+ this.name = 'ValidationError';
19
+ if (Array.isArray(payload)) {
20
+ const issues = [...payload];
21
+ this.issues = issues;
22
+ this.message = issuesToPayload(issues);
23
+ }
24
+ else {
25
+ const obj = { ...payload };
26
+ this.issues = payloadToIssues(obj);
27
+ // Normalize: even when constructed from a string-valued payload,
28
+ // canonical .message is always-array.
29
+ this.message = issuesToPayload(this.issues);
30
+ }
31
+ }
32
+ /**
33
+ * Cross-realm-safe duck check. Mirrors `yup.ValidationError.isError`.
34
+ * Use this in framework code instead of `instanceof` when the error
35
+ * may have crossed a module-graph boundary.
36
+ */
37
+ static isValidationError(err) {
38
+ return (err instanceof Error &&
39
+ err.name === 'ValidationError');
40
+ }
41
+ }
42
+ function payloadToIssues(payload) {
43
+ const issues = [];
44
+ for (const [path, value] of Object.entries(payload)) {
45
+ const messages = Array.isArray(value) ? value : [value];
46
+ for (const message of messages) {
47
+ issues.push({ message, path: path === '' ? undefined : [path] });
48
+ }
49
+ }
50
+ return issues;
51
+ }
52
+ export function issuesToPayload(issues) {
53
+ // Always emit arrays per path, matching the existing yup-pipeline wire
54
+ // shape: `{path: ["msg"]}` even for a single error. Single-string form
55
+ // is still accepted as constructor input, but the canonical output is
56
+ // always an array.
57
+ const out = {};
58
+ for (const issue of issues) {
59
+ const path = pathToString(issue.path);
60
+ if (!out[path]) {
61
+ out[path] = [];
62
+ }
63
+ out[path].push(issue.message);
64
+ }
65
+ return out;
66
+ }
67
+ function pathToString(path) {
68
+ if (!path || path.length === 0) {
69
+ return '';
70
+ }
71
+ return path
72
+ .map((segment) => typeof segment === 'object' && segment !== null && 'key' in segment
73
+ ? String(segment.key)
74
+ : String(segment))
75
+ .join('.');
76
+ }
77
+ //# sourceMappingURL=ValidationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationError.js","sourceRoot":"","sources":["../../../src/services/validate/ValidationError.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,MAAM,CAAoB;IAQ1B,YACE,OAAgE;QAEhE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAE9B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,CAAC,GAAI,OAA0C,CAAC,CAAC;YAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,GAAG,EAAE,GAAI,OAAkC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AC,IAAI,CAAC,GAAG,EAAE,CAAC;QACjB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,YAAY,CAAC,IAAyC;IAC7D,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACf,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,KAAK,IAAI,OAAO;QACjE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB;SACA,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ValidatorDriver } from '../types.ts';
2
+ /**
3
+ * Generic Standard Schema driver. Handles any validator that implements
4
+ * the `~standard` interface (zod ≥3.24, valibot, arktype, custom user
5
+ * Standard-Schema-conformant shapes — and yup, when no more-specific
6
+ * driver is registered).
7
+ *
8
+ * Most popular libs strip unknown fields by default in their Standard
9
+ * Schema validate (zod, valibot, arktype). Yup is the outlier — see
10
+ * `YupDriver.ts` for the strip-preserving fast path.
11
+ *
12
+ * `toJsonSchema` returns null here; per-vendor drivers can override
13
+ * with their own native exporters when OpenAPI export is needed.
14
+ */
15
+ export declare const standardSchemaDriver: ValidatorDriver;
@@ -0,0 +1,34 @@
1
+ import { ValidationError } from "../ValidationError.js";
2
+ /**
3
+ * Generic Standard Schema driver. Handles any validator that implements
4
+ * the `~standard` interface (zod ≥3.24, valibot, arktype, custom user
5
+ * Standard-Schema-conformant shapes — and yup, when no more-specific
6
+ * driver is registered).
7
+ *
8
+ * Most popular libs strip unknown fields by default in their Standard
9
+ * Schema validate (zod, valibot, arktype). Yup is the outlier — see
10
+ * `YupDriver.ts` for the strip-preserving fast path.
11
+ *
12
+ * `toJsonSchema` returns null here; per-vendor drivers can override
13
+ * with their own native exporters when OpenAPI export is needed.
14
+ */
15
+ export const standardSchemaDriver = {
16
+ canHandle(body) {
17
+ return (typeof body === 'object' &&
18
+ body !== null &&
19
+ '~standard' in body &&
20
+ typeof body['~standard'] === 'object');
21
+ },
22
+ async validate(body, data) {
23
+ const std = body['~standard'];
24
+ const result = await std.validate(data);
25
+ if (result.issues) {
26
+ throw new ValidationError(result.issues);
27
+ }
28
+ return result.value;
29
+ },
30
+ toJsonSchema() {
31
+ return null;
32
+ },
33
+ };
34
+ //# sourceMappingURL=StandardSchemaDriver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StandardSchemaDriver.js","sourceRoot":"","sources":["../../../../src/services/validate/drivers/StandardSchemaDriver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoB;IACnD,SAAS,CAAC,IAAa;QACrB,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,IAAI;YACb,WAAW,IAAI,IAAI;YACnB,OAAQ,IAAkC,CAAC,WAAW,CAAC,KAAK,QAAQ,CACrE,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAa,EAAE,IAAa;QACzC,MAAM,GAAG,GAAI,IAAyB,CAAC,WAAW,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ValidatorDriver } from '../types.ts';
2
+ /**
3
+ * Yup-vendor driver. Handles `body['~standard'].vendor === 'yup'`.
4
+ *
5
+ * Two yup-specific behaviors that the generic Standard Schema driver
6
+ * doesn't cover:
7
+ *
8
+ * 1. **Strip unknown.** Yup's `~standard.validate(data)` does NOT strip
9
+ * unknown fields. Today's framework calls `cast(data, {stripUnknown: true})`
10
+ * explicitly. To preserve that behavior — and avoid a security
11
+ * regression in handlers that spread `req.appInfo.request` into
12
+ * `Model.create(...)` — this driver calls yup's native validate with
13
+ * `{ stripUnknown: true, abortEarly: false }` directly. One call:
14
+ * validates + casts + strips, throws on issues.
15
+ *
16
+ * 2. **Error translation.** Yup throws its own `ValidationError` with
17
+ * `.inner[]` (one entry per failed field) and `.errors[]` (messages).
18
+ * We translate to the framework's `ValidationError` via duck-typing
19
+ * (no top-level yup import — keeps the framework runtime decoupled).
20
+ */
21
+ export declare const yupDriver: ValidatorDriver;