adorn-api 1.0.1 → 1.0.3

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 (139) hide show
  1. package/README.md +4 -1
  2. package/dist/adapters/express/createApp.d.ts +149 -11
  3. package/dist/adapters/express/createApp.d.ts.map +1 -1
  4. package/dist/adapters/express/createApp.js +112 -6
  5. package/dist/adapters/express/createApp.js.map +1 -1
  6. package/dist/adapters/express/middleware/errorHandler.d.ts +193 -2
  7. package/dist/adapters/express/middleware/errorHandler.d.ts.map +1 -1
  8. package/dist/adapters/express/middleware/errorHandler.js +164 -3
  9. package/dist/adapters/express/middleware/errorHandler.js.map +1 -1
  10. package/dist/adapters/express/router.d.ts +1 -1
  11. package/dist/adapters/express/router.d.ts.map +1 -1
  12. package/dist/adapters/express/router.js +6 -4
  13. package/dist/adapters/express/router.js.map +1 -1
  14. package/dist/adapters/express/transport/request.js.map +1 -1
  15. package/dist/adapters/express/transport/response.d.ts +1 -1
  16. package/dist/adapters/express/transport/response.d.ts.map +1 -1
  17. package/dist/adapters/express/transport/response.js.map +1 -1
  18. package/dist/contracts/openapi-v3.d.ts +461 -0
  19. package/dist/contracts/openapi-v3.d.ts.map +1 -1
  20. package/dist/contracts/reply.d.ts +109 -1
  21. package/dist/contracts/reply.d.ts.map +1 -1
  22. package/dist/contracts/reply.js +40 -1
  23. package/dist/contracts/reply.js.map +1 -1
  24. package/dist/contracts/response-types.d.ts +5 -5
  25. package/dist/contracts/response-types.d.ts.map +1 -1
  26. package/dist/contracts/responses.d.ts +84 -4
  27. package/dist/contracts/responses.d.ts.map +1 -1
  28. package/dist/contracts/route-options.d.ts +134 -3
  29. package/dist/contracts/route-options.d.ts.map +1 -1
  30. package/dist/contracts/validator.d.ts +121 -0
  31. package/dist/contracts/validator.d.ts.map +1 -1
  32. package/dist/core/binding/binder.d.ts +56 -1
  33. package/dist/core/binding/binder.d.ts.map +1 -1
  34. package/dist/core/binding/binder.js +33 -0
  35. package/dist/core/binding/binder.js.map +1 -1
  36. package/dist/core/binding/coerce/primitives.d.ts +68 -1
  37. package/dist/core/binding/coerce/primitives.d.ts.map +1 -1
  38. package/dist/core/binding/coerce/primitives.js +82 -12
  39. package/dist/core/binding/coerce/primitives.js.map +1 -1
  40. package/dist/core/errors/http-error.d.ts +54 -0
  41. package/dist/core/errors/http-error.d.ts.map +1 -1
  42. package/dist/core/errors/http-error.js +54 -0
  43. package/dist/core/errors/http-error.js.map +1 -1
  44. package/dist/core/errors/validation-error.d.ts +65 -0
  45. package/dist/core/errors/validation-error.d.ts.map +1 -1
  46. package/dist/core/errors/validation-error.js +65 -0
  47. package/dist/core/errors/validation-error.js.map +1 -1
  48. package/dist/core/openapi/buildOpenApi.d.ts +65 -0
  49. package/dist/core/openapi/buildOpenApi.d.ts.map +1 -1
  50. package/dist/core/openapi/buildOpenApi.js +66 -4
  51. package/dist/core/openapi/buildOpenApi.js.map +1 -1
  52. package/dist/core/openapi/schema/registry.d.ts +1 -1
  53. package/dist/core/openapi/schema/registry.d.ts.map +1 -1
  54. package/dist/core/openapi/schema/registry.js.map +1 -1
  55. package/dist/core/registry/buildRegistry.d.ts.map +1 -1
  56. package/dist/core/registry/buildRegistry.js +49 -5
  57. package/dist/core/registry/buildRegistry.js.map +1 -1
  58. package/dist/core/registry/types.d.ts +194 -1
  59. package/dist/core/registry/types.d.ts.map +1 -1
  60. package/dist/core/reply/reply.d.ts +94 -0
  61. package/dist/core/reply/reply.d.ts.map +1 -1
  62. package/dist/core/reply/reply.js +87 -0
  63. package/dist/core/reply/reply.js.map +1 -1
  64. package/dist/core/reply/typed.d.ts +137 -3
  65. package/dist/core/reply/typed.d.ts.map +1 -1
  66. package/dist/core/reply/typed.js +137 -2
  67. package/dist/core/reply/typed.js.map +1 -1
  68. package/dist/core/responses/helpers.d.ts +1 -1
  69. package/dist/core/responses/helpers.d.ts.map +1 -1
  70. package/dist/core/responses/normalize.d.ts.map +1 -1
  71. package/dist/core/responses/normalize.js +2 -1
  72. package/dist/core/responses/normalize.js.map +1 -1
  73. package/dist/core/route/defineRoute.d.ts +48 -1
  74. package/dist/core/route/defineRoute.d.ts.map +1 -1
  75. package/dist/core/route/defineRoute.js +42 -1
  76. package/dist/core/route/defineRoute.js.map +1 -1
  77. package/dist/decorators/binding.d.ts +1 -1
  78. package/dist/decorators/binding.d.ts.map +1 -1
  79. package/dist/decorators/binding.js.map +1 -1
  80. package/dist/decorators/controller.d.ts +1 -1
  81. package/dist/decorators/controller.d.ts.map +1 -1
  82. package/dist/decorators/controller.js.map +1 -1
  83. package/dist/decorators/docs.d.ts +6 -0
  84. package/dist/decorators/docs.d.ts.map +1 -1
  85. package/dist/decorators/docs.js +45 -2
  86. package/dist/decorators/docs.js.map +1 -1
  87. package/dist/decorators/index.d.ts +3 -0
  88. package/dist/decorators/index.d.ts.map +1 -1
  89. package/dist/decorators/index.js +3 -0
  90. package/dist/decorators/index.js.map +1 -1
  91. package/dist/decorators/methods.d.ts +128 -6
  92. package/dist/decorators/methods.d.ts.map +1 -1
  93. package/dist/decorators/methods.js +124 -0
  94. package/dist/decorators/methods.js.map +1 -1
  95. package/dist/decorators/responses.d.ts +5 -0
  96. package/dist/decorators/responses.d.ts.map +1 -1
  97. package/dist/decorators/responses.js +43 -2
  98. package/dist/decorators/responses.js.map +1 -1
  99. package/dist/decorators/security.d.ts +6 -0
  100. package/dist/decorators/security.d.ts.map +1 -1
  101. package/dist/decorators/security.js +38 -2
  102. package/dist/decorators/security.js.map +1 -1
  103. package/dist/index.d.ts +5 -2
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +17 -2
  106. package/dist/index.js.map +1 -1
  107. package/dist/integrations/metal-orm/schema/column-map.d.ts +91 -0
  108. package/dist/integrations/metal-orm/schema/column-map.d.ts.map +1 -1
  109. package/dist/integrations/metal-orm/schema/column-map.js +129 -2
  110. package/dist/integrations/metal-orm/schema/column-map.js.map +1 -1
  111. package/dist/integrations/metal-orm/schema/dto.d.ts +2 -2
  112. package/dist/integrations/metal-orm/schema/dto.d.ts.map +1 -1
  113. package/dist/integrations/metal-orm/schema/dto.js.map +1 -1
  114. package/dist/integrations/metal-orm/schema/entity.d.ts +90 -8
  115. package/dist/integrations/metal-orm/schema/entity.d.ts.map +1 -1
  116. package/dist/integrations/metal-orm/schema/entity.js +78 -6
  117. package/dist/integrations/metal-orm/schema/entity.js.map +1 -1
  118. package/dist/integrations/metal-orm/schema/filters.d.ts +1 -1
  119. package/dist/integrations/metal-orm/schema/filters.d.ts.map +1 -1
  120. package/dist/integrations/metal-orm/schema/filters.js +2 -1
  121. package/dist/integrations/metal-orm/schema/filters.js.map +1 -1
  122. package/dist/integrations/metal-orm/schema/tabledef.d.ts +1 -1
  123. package/dist/integrations/metal-orm/schema/tabledef.d.ts.map +1 -1
  124. package/dist/metadata/bag.d.ts +2 -1
  125. package/dist/metadata/bag.d.ts.map +1 -1
  126. package/dist/metadata/bag.js +2 -1
  127. package/dist/metadata/bag.js.map +1 -1
  128. package/dist/metadata/keys.d.ts +203 -1
  129. package/dist/metadata/keys.d.ts.map +1 -1
  130. package/dist/metadata/keys.js +3 -9
  131. package/dist/metadata/keys.js.map +1 -1
  132. package/dist/metadata/merge.d.ts.map +1 -1
  133. package/dist/metadata/merge.js +4 -1
  134. package/dist/metadata/merge.js.map +1 -1
  135. package/dist/validation/native/schema.d.ts +2 -2
  136. package/dist/validation/native/schema.d.ts.map +1 -1
  137. package/dist/validation/native/validator.d.ts +1 -1
  138. package/dist/validation/native/validator.d.ts.map +1 -1
  139. package/package.json +6 -2
@@ -1,4 +1,43 @@
1
+ /**
2
+ * Type guard function to check if an object is an Adorn Reply.
3
+ *
4
+ * This function is used to safely check if an object conforms to
5
+ * the Reply type structure.
6
+ *
7
+ * @param x - Object to check
8
+ * @returns true if the object is a Reply, false otherwise
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * function handleResponse(response: unknown) {
13
+ * if (isReply(response)) {
14
+ * // TypeScript now knows response is a Reply
15
+ * console.log('Status:', response.status);
16
+ * console.log('Body:', response.body);
17
+ * } else {
18
+ * console.log('Not a reply object');
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // In middleware or error handling
26
+ * if (isReply(error)) {
27
+ * // It's a reply object, can be sent directly to client
28
+ * res.status(error.status).json(error.body);
29
+ * } else {
30
+ * // Handle non-reply errors
31
+ * res.status(500).json({ error: 'Internal Server Error' });
32
+ * }
33
+ * ```
34
+ *
35
+ * @see Reply for the reply object type
36
+ */
1
37
  export function isReply(x) {
2
- return !!x && typeof x === 'object' && x.__adornReply === true && typeof x.status === 'number';
38
+ if (!x || typeof x !== 'object')
39
+ return false;
40
+ const candidate = x;
41
+ return candidate.__adornReply === true && typeof candidate.status === 'number';
3
42
  }
4
43
  //# sourceMappingURL=reply.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reply.js","sourceRoot":"","sources":["../../src/contracts/reply.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAK,CAAS,CAAC,YAAY,KAAK,IAAI,IAAI,OAAQ,CAAS,CAAC,MAAM,KAAK,QAAQ,CAAC;AACnH,CAAC"}
1
+ {"version":3,"file":"reply.js","sourceRoot":"","sources":["../../src/contracts/reply.ts"],"names":[],"mappings":"AAoFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9C,MAAM,SAAS,GAAG,CAA2B,CAAC;IAC9C,OAAO,SAAS,CAAC,YAAY,KAAK,IAAI,IAAI,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ,CAAC;AACjF,CAAC"}
@@ -3,12 +3,12 @@ import type { ResponseSpec, ResponsesSpec } from './responses.js';
3
3
  export type StatusKey<R extends ResponsesSpec> = Extract<keyof R, `${number}`>;
4
4
  export type StatusNum<K extends string> = K extends `${infer N extends number}` ? N : never;
5
5
  export type AllowedStatus<R extends ResponsesSpec> = StatusNum<StatusKey<R>> | (R extends {
6
- default: any;
6
+ default: unknown;
7
7
  } ? number : never);
8
8
  export type ResAt<R extends ResponsesSpec, S extends number> = `${S}` extends keyof R ? R[`${S}`] : R extends {
9
9
  default: infer D;
10
10
  } ? D : never;
11
- export type NormalizeRes<X> = X extends Schema<any> ? {
11
+ export type NormalizeRes<X> = X extends Schema<unknown> ? {
12
12
  content: {
13
13
  'application/json': {
14
14
  schema: X;
@@ -18,10 +18,10 @@ export type NormalizeRes<X> = X extends Schema<any> ? {
18
18
  export type ContentOf<X> = NormalizeRes<X> extends {
19
19
  content: infer C;
20
20
  } ? C : never;
21
- export type SchemaFromContent<C> = C extends Record<PropertyKey, any> ? ('application/json' extends keyof C ? C['application/json'] extends {
22
- schema: infer S extends Schema<any>;
21
+ export type SchemaFromContent<C> = C extends Record<PropertyKey, unknown> ? ('application/json' extends keyof C ? C['application/json'] extends {
22
+ schema: infer S extends Schema<unknown>;
23
23
  } ? S : never : C[keyof C] extends {
24
- schema: infer S extends Schema<any>;
24
+ schema: infer S extends Schema<unknown>;
25
25
  } ? S : never) : never;
26
26
  export type BodySchemaFor<R extends ResponsesSpec, S extends number> = SchemaFromContent<ContentOf<ResAt<R, S>>>;
27
27
  export type HeadersDefFor<R extends ResponsesSpec, S extends number> = NormalizeRes<ResAt<R, S>> extends {
@@ -1 +1 @@
1
- {"version":3,"file":"response-types.d.ts","sourceRoot":"","sources":["../../src/contracts/response-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,aAAa,IA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* Specification for response content including schema and example.
4
+ *
5
+ * @template T - The type that the schema validates
6
+ */
2
7
  export type ResponseContentSpec = {
3
- schema: Schema<any>;
8
+ /** Schema defining the structure and validation rules for the response content */
9
+ schema: Schema<unknown>;
10
+ /** Example value that matches the schema */
4
11
  example?: unknown;
5
12
  };
13
+ /**
14
+ * Specification for HTTP response headers.
15
+ *
16
+ * @template T - The type that the schema validates
17
+ */
6
18
  export type HeaderSpec = {
7
- schema: Schema<any>;
19
+ /** Schema defining the structure and validation rules for the header */
20
+ schema: Schema<unknown>;
21
+ /** Human-readable description of the header */
8
22
  description?: string;
23
+ /** Whether the header is required */
9
24
  required?: boolean;
10
25
  };
26
+ /**
27
+ * Complete specification for an HTTP response.
28
+ *
29
+ * This type defines all aspects of an HTTP response including status codes,
30
+ * content types, headers, and schemas. It's used to document and validate
31
+ * API responses.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const successResponse: ResponseSpec = {
36
+ * description: 'User created successfully',
37
+ * headers: {
38
+ * 'X-Request-ID': {
39
+ * schema: Schema.String(),
40
+ * description: 'Unique request identifier',
41
+ * required: true
42
+ * }
43
+ * },
44
+ * content: {
45
+ * 'application/json': {
46
+ * schema: userSchema,
47
+ * example: { id: '123', name: 'John Doe', email: 'john@example.com' }
48
+ * }
49
+ * }
50
+ * };
51
+ * ```
52
+ *
53
+ * @see Schema for schema definition
54
+ */
11
55
  export type ResponseSpec = {
56
+ /** Human-readable description of the response */
12
57
  description?: string;
58
+ /** Response headers specification */
13
59
  headers?: Record<string, HeaderSpec>;
60
+ /** Response content by media type */
14
61
  content?: Record<string, ResponseContentSpec>;
15
- schema?: Schema<any>;
62
+ /** Legacy schema property (use content instead for proper media type handling) */
63
+ schema?: Schema<unknown>;
16
64
  };
17
- export type ResponsesSpec = Record<string, ResponseSpec | Schema<any>>;
65
+ /**
66
+ * Collection of response specifications keyed by HTTP status code.
67
+ *
68
+ * This type represents all possible responses for a given endpoint,
69
+ * with status codes as keys and ResponseSpec objects as values.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const userResponses: ResponsesSpec = {
74
+ * '200': {
75
+ * description: 'User found',
76
+ * content: {
77
+ * 'application/json': {
78
+ * schema: userSchema,
79
+ * example: { id: '123', name: 'John Doe' }
80
+ * }
81
+ * }
82
+ * },
83
+ * '404': {
84
+ * description: 'User not found',
85
+ * content: {
86
+ * 'application/json': {
87
+ * schema: errorSchema,
88
+ * example: { error: 'User not found', code: 'USER_NOT_FOUND' }
89
+ * }
90
+ * }
91
+ * }
92
+ * };
93
+ * ```
94
+ *
95
+ * @see ResponseSpec for individual response specification
96
+ */
97
+ export type ResponsesSpec = Record<string, ResponseSpec | Schema<unknown>>;
18
98
  //# sourceMappingURL=responses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/contracts/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/contracts/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACxB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACxB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC9C,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -1,24 +1,155 @@
1
1
  import type { ResponsesSpec } from './responses.js';
2
2
  import type { Schema } from '../validation/native/schema.js';
3
3
  import type { ExtractPathParams } from '../core/typing/path-params.js';
4
+ import type { SecurityRequirementObject } from './openapi-v3.js';
5
+ /**
6
+ * Type hints for path parameter coercion.
7
+ *
8
+ * These hints are used to automatically convert path parameters
9
+ * to specific types during request processing.
10
+ */
4
11
  export type ScalarHint = 'string' | 'int' | 'number' | 'boolean' | 'uuid';
12
+ /**
13
+ * Validation configuration for route parameters.
14
+ *
15
+ * Specifies schemas for validating different parts of the request.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const routeValidation: RouteValidate = {
20
+ * params: Schema.Object({
21
+ * id: Schema.String().format('uuid')
22
+ * }),
23
+ * query: Schema.Object({
24
+ * limit: Schema.Number().min(1).max(100),
25
+ * offset: Schema.Number().min(0)
26
+ * }),
27
+ * body: Schema.Object({
28
+ * title: Schema.String().minLength(3),
29
+ * content: Schema.String().minLength(10)
30
+ * })
31
+ * };
32
+ * ```
33
+ *
34
+ * @see Schema for schema definition
35
+ */
5
36
  export type RouteValidate = {
6
- params?: Schema<any>;
7
- query?: Schema<any>;
8
- body?: Schema<any>;
37
+ /** Schema for validating path parameters */
38
+ params?: Schema<unknown>;
39
+ /** Schema for validating query parameters */
40
+ query?: Schema<unknown>;
41
+ /** Schema for validating request body */
42
+ body?: Schema<unknown>;
9
43
  };
44
+ /**
45
+ * Parameter binding configuration for routes.
46
+ *
47
+ * Specifies how path parameters should be coerced to specific types.
48
+ *
49
+ * @template Path - The route path as a string literal
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // For route '/users/:id/:status'
54
+ * const routeBindings: RouteBindings<'/users/:id/:status'> = {
55
+ * path: {
56
+ * id: 'uuid', // Coerce to UUID format
57
+ * status: 'string' // Keep as string
58
+ * }
59
+ * };
60
+ * ```
61
+ *
62
+ * @see ScalarHint for available type hints
63
+ */
10
64
  export type RouteBindings<Path extends string> = {
65
+ /** Type hints for path parameters */
11
66
  path?: Partial<Record<ExtractPathParams<Path>, ScalarHint>>;
12
67
  };
68
+ /**
69
+ * Complete route configuration options.
70
+ *
71
+ * This type defines all available options for configuring a route,
72
+ * including OpenAPI documentation, validation, parameter binding,
73
+ * and response specifications.
74
+ *
75
+ * @template Path - The route path as a string literal
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const userRouteOptions: RouteOptions<'/users/:id'> = {
80
+ * summary: 'Get user by ID',
81
+ * description: 'Retrieves a user by their unique identifier',
82
+ * tags: ['Users'],
83
+ * operationId: 'getUserById',
84
+ * deprecated: false,
85
+ * security: [{ bearerAuth: [] }],
86
+ *
87
+ * validate: {
88
+ * params: Schema.Object({
89
+ * id: Schema.String().format('uuid')
90
+ * })
91
+ * },
92
+ *
93
+ * bindings: {
94
+ * path: { id: 'uuid' }
95
+ * },
96
+ *
97
+ * responses: {
98
+ * '200': {
99
+ * description: 'User found',
100
+ * content: {
101
+ * 'application/json': {
102
+ * schema: userSchema,
103
+ * example: { id: '123', name: 'John Doe' }
104
+ * }
105
+ * }
106
+ * },
107
+ * '404': {
108
+ * description: 'User not found'
109
+ * }
110
+ * },
111
+ *
112
+ * successStatus: 200
113
+ * };
114
+ * ```
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * // Minimal route options
119
+ * const simpleRouteOptions: RouteOptions = {
120
+ * summary: 'Health check',
121
+ * responses: {
122
+ * '200': { description: 'Service is healthy' }
123
+ * }
124
+ * };
125
+ * ```
126
+ *
127
+ * @see ResponsesSpec for response specification format
128
+ * @see RouteValidate for validation configuration
129
+ * @see RouteBindings for parameter binding configuration
130
+ */
13
131
  export type RouteOptions<Path extends string = string> = {
132
+ /** Short summary of the endpoint */
14
133
  summary?: string;
134
+ /** Detailed description of the endpoint */
15
135
  description?: string;
136
+ /** Tags for grouping endpoints in documentation */
16
137
  tags?: string[];
138
+ /** Unique identifier for the operation */
139
+ operationId?: string;
140
+ /** Whether the endpoint is deprecated */
17
141
  deprecated?: boolean;
142
+ /** Security requirements for the endpoint */
143
+ security?: SecurityRequirementObject[];
144
+ /** Validation configuration for request parts */
18
145
  validate?: RouteValidate;
146
+ /** Parameter binding configuration */
19
147
  bindings?: RouteBindings<Path>;
148
+ /** Response specifications by status code */
20
149
  responses?: ResponsesSpec;
150
+ /** Default success status code */
21
151
  successStatus?: number;
152
+ /** Allow additional custom properties */
22
153
  [k: string]: unknown;
23
154
  };
24
155
  //# sourceMappingURL=route-options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-options.d.ts","sourceRoot":"","sources":["../../src/contracts/route-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1E,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,IAAI,SAAS,MAAM,IAAI;IAC/C,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAE/B,SAAS,CAAC,EAAE,aAAa,CAAC;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;IACjB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAEvC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAE/B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,kCAAkC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,yCAAyC;IACzC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB,CAAC"}
@@ -1,11 +1,77 @@
1
+ /**
2
+ * Path to a validation issue within the request data.
3
+ *
4
+ * Represents the location of a validation failure using an array
5
+ * where each element is a property name or array index.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // For body: { user: { email: 'invalid' } }
10
+ * const path: ValidationPath = ['body', 'user', 'email'];
11
+ *
12
+ * // For query: { filters: { page: 'not-a-number' } }
13
+ * const path: ValidationPath = ['query', 'filters', 'page'];
14
+ *
15
+ * // For array: { items: [{ id: 'invalid' }] }
16
+ * const path: ValidationPath = ['body', 'items', 0, 'id'];
17
+ * ```
18
+ */
1
19
  export type ValidationPath = Array<string | number>;
20
+ /**
21
+ * Individual validation issue with path and details.
22
+ *
23
+ * Represents a single validation failure with information about
24
+ * where it occurred, what was expected, and what was received.
25
+ */
2
26
  export type ValidationIssue = {
27
+ /** Path to the invalid data within the request */
3
28
  path: ValidationPath;
29
+ /** Human-readable error message */
4
30
  message: string;
31
+ /** Machine-readable error code */
5
32
  code?: string;
33
+ /** Expected value or type */
6
34
  expected?: unknown;
35
+ /** Received value that failed validation */
7
36
  received?: unknown;
8
37
  };
38
+ /**
39
+ * Result of a validation operation.
40
+ *
41
+ * This discriminated union represents either a successful validation
42
+ * with the validated value, or a failed validation with issues.
43
+ *
44
+ * @template T - The expected type after successful validation
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Successful validation
49
+ * const success: ValidationResult<User> = {
50
+ * ok: true,
51
+ * value: { id: '123', name: 'John Doe', email: 'john@example.com' }
52
+ * };
53
+ *
54
+ * // Failed validation
55
+ * const failure: ValidationResult<User> = {
56
+ * ok: false,
57
+ * issues: [
58
+ * { path: ['body', 'email'], message: 'Invalid email format', code: 'invalid_string' }
59
+ * ]
60
+ * };
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Usage in validation logic
66
+ * const result = validator.validateBody(request.body, 'createUserSchema');
67
+ *
68
+ * if (!result.ok) {
69
+ * throw new ValidationError('Invalid user data', result.issues);
70
+ * }
71
+ *
72
+ * const validatedUser = result.value;
73
+ * ```
74
+ */
9
75
  export type ValidationResult<T> = {
10
76
  ok: true;
11
77
  value: T;
@@ -15,11 +81,66 @@ export type ValidationResult<T> = {
15
81
  };
16
82
  /**
17
83
  * Optional pluggable validator interface.
84
+ *
18
85
  * You can implement adapters later (zod/ajv/valibot).
86
+ *
87
+ * This interface defines the contract for validation services
88
+ * that can be plugged into the Adorn API framework.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Custom validator implementation
93
+ * class MyValidator implements Validator {
94
+ * validateBody<T>(body: unknown, schemaId: string): ValidationResult<T> {
95
+ * // Implement body validation logic
96
+ * }
97
+ *
98
+ * validateQuery<T>(query: unknown, schemaId: string): ValidationResult<T> {
99
+ * // Implement query validation logic
100
+ * }
101
+ *
102
+ * validateParams<T>(params: unknown, schemaId: string): ValidationResult<T> {
103
+ * // Implement params validation logic
104
+ * }
105
+ * }
106
+ *
107
+ * // Usage in Express adapter
108
+ * const app = createAdornExpressApp({
109
+ * controllers: [UserController],
110
+ * validator: new MyValidator()
111
+ * });
112
+ * ```
113
+ *
114
+ * @see ValidationResult for the result type
115
+ * @see ValidationIssue for issue details
19
116
  */
20
117
  export interface Validator {
118
+ /**
119
+ * Validates request body against a schema.
120
+ *
121
+ * @template T - Expected type after validation
122
+ * @param body - Request body to validate
123
+ * @param schemaId - Identifier for the schema to use
124
+ * @returns Validation result
125
+ */
21
126
  validateBody<T = unknown>(body: unknown, schemaId: string): ValidationResult<T>;
127
+ /**
128
+ * Validates query parameters against a schema.
129
+ *
130
+ * @template T - Expected type after validation
131
+ * @param query - Query parameters to validate
132
+ * @param schemaId - Identifier for the schema to use
133
+ * @returns Validation result
134
+ */
22
135
  validateQuery<T = unknown>(query: unknown, schemaId: string): ValidationResult<T>;
136
+ /**
137
+ * Validates path parameters against a schema.
138
+ *
139
+ * @template T - Expected type after validation
140
+ * @param params - Path parameters to validate
141
+ * @param schemaId - Identifier for the schema to use
142
+ * @returns Validation result
143
+ */
23
144
  validateParams<T = unknown>(params: unknown, schemaId: string): ValidationResult<T>;
24
145
  }
25
146
  //# sourceMappingURL=validator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/contracts/validator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACtB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CA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AAS;IACxB;;;;;;;OAOG;IACH,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAEhF;;;;;;;OAOG;IACH,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAElF;;;;;;;OAOG;IACH,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;CACrF"}
@@ -1,19 +1,74 @@
1
1
  import type { RequestContext } from '../../contracts/context.js';
2
2
  import type { RouteEntry } from '../registry/types.js';
3
3
  import type { CoerceMode } from './coerce/primitives.js';
4
+ type HandlerFunction = (...args: unknown[]) => unknown;
5
+ /**
6
+ * Prepared binding data after argument binding.
7
+ * Contains the processed params, query, and body data.
8
+ */
4
9
  export type BindingPrepared = {
10
+ /** Path parameters extracted and coerced from the URL */
5
11
  params: Record<string, unknown>;
12
+ /** Query parameters extracted and processed from the URL query string */
6
13
  query: Record<string, unknown>;
14
+ /** Request body parsed and processed */
7
15
  body: unknown;
8
16
  };
17
+ /**
18
+ * Result of the bindArgs function containing:
19
+ * - args: The arguments to pass to the handler function
20
+ * - prepared: The processed binding data
21
+ */
9
22
  export type BindArgsResult = {
23
+ /** Arguments to pass to the handler function in order */
10
24
  args: unknown[];
25
+ /** Prepared binding data for reference */
11
26
  prepared: BindingPrepared;
12
27
  };
28
+ /**
29
+ * Options for the bindArgs function to control binding behavior.
30
+ */
13
31
  export type BindOptions = {
32
+ /** Coercion mode for automatic type conversion ('smart', 'strict', or 'none') */
14
33
  coerce?: CoerceMode;
34
+ /** Whether to parse CSV values in query parameters */
15
35
  csv?: boolean;
36
+ /** Whether to pass the request context as the last argument */
16
37
  passContext?: boolean;
17
38
  };
18
- export declare function bindArgs(route: RouteEntry, handler: Function, ctx: RequestContext, opts?: BindOptions): BindArgsResult;
39
+ /**
40
+ * Binds request data to handler function arguments based on route configuration.
41
+ *
42
+ * This function automatically maps path parameters, query parameters, and request body
43
+ * to the handler function arguments based on the route's binding configuration and
44
+ * HTTP method conventions.
45
+ *
46
+ * @param route - The route entry containing metadata about the handler
47
+ * @param handler - The handler function to bind arguments for
48
+ * @param ctx - The request context containing params, query, and body
49
+ * @param opts - Binding options to control behavior
50
+ * @returns Object containing args to pass to handler and prepared binding data
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // For a route like: @Get('/users/:id')
55
+ * // With handler: async getUser(id: string, ctx: RequestContext)
56
+ * const { args } = bindArgs(route, handler, requestContext);
57
+ * const result = await handler(...args); // Automatically passes id and ctx
58
+ * ```
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // For a POST route with body
63
+ * // @Post('/users')
64
+ * // async createUser(@Body() userData: CreateUserDto)
65
+ * const { args } = bindArgs(route, handler, requestContext);
66
+ * const result = await handler(...args); // Automatically passes parsed body
67
+ * ```
68
+ *
69
+ * @see RouteEntry for route metadata structure
70
+ * @see RequestContext for request data structure
71
+ */
72
+ export declare function bindArgs(route: RouteEntry, handler: HandlerFunction, ctx: RequestContext, opts?: BindOptions): BindArgsResult;
73
+ export {};
19
74
  //# sourceMappingURL=binder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"binder.d.ts","sourceRoot":"","sources":["../../../src/core/binding/binder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAA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AEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,iFAAiF;IACjF,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,sDAAsD;IACtD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,cAAc,EACnB,IAAI,GAAE,WAAgB,GACrB,cAAc,CAoEhB"}
@@ -2,6 +2,39 @@ import { HttpError } from '../errors/http-error.js';
2
2
  import { getPathTokenNames } from './rules/inferFromPath.js';
3
3
  import { conventionForMethod } from './rules/inferFromHttpMethod.js';
4
4
  import { coerceObjectSmart, coerceValueSmart } from './coerce/arrays.js';
5
+ /**
6
+ * Binds request data to handler function arguments based on route configuration.
7
+ *
8
+ * This function automatically maps path parameters, query parameters, and request body
9
+ * to the handler function arguments based on the route's binding configuration and
10
+ * HTTP method conventions.
11
+ *
12
+ * @param route - The route entry containing metadata about the handler
13
+ * @param handler - The handler function to bind arguments for
14
+ * @param ctx - The request context containing params, query, and body
15
+ * @param opts - Binding options to control behavior
16
+ * @returns Object containing args to pass to handler and prepared binding data
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // For a route like: @Get('/users/:id')
21
+ * // With handler: async getUser(id: string, ctx: RequestContext)
22
+ * const { args } = bindArgs(route, handler, requestContext);
23
+ * const result = await handler(...args); // Automatically passes id and ctx
24
+ * ```
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // For a POST route with body
29
+ * // @Post('/users')
30
+ * // async createUser(@Body() userData: CreateUserDto)
31
+ * const { args } = bindArgs(route, handler, requestContext);
32
+ * const result = await handler(...args); // Automatically passes parsed body
33
+ * ```
34
+ *
35
+ * @see RouteEntry for route metadata structure
36
+ * @see RequestContext for request data structure
37
+ */
5
38
  export function bindArgs(route, handler, ctx, opts = {}) {
6
39
  const passContext = opts.passContext ?? true;
7
40
  const coerceMode = opts.coerce ?? 'smart';