kontract 0.1.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.
Files changed (138) hide show
  1. package/README.md +435 -0
  2. package/dist/builder/define-controller.d.ts +115 -0
  3. package/dist/builder/define-controller.d.ts.map +1 -0
  4. package/dist/builder/define-controller.js +80 -0
  5. package/dist/builder/define-controller.js.map +1 -0
  6. package/dist/builder/define-endpoint.d.ts +157 -0
  7. package/dist/builder/define-endpoint.d.ts.map +1 -0
  8. package/dist/builder/define-endpoint.js +103 -0
  9. package/dist/builder/define-endpoint.js.map +1 -0
  10. package/dist/builder/define-route.d.ts +191 -0
  11. package/dist/builder/define-route.d.ts.map +1 -0
  12. package/dist/builder/define-route.js +124 -0
  13. package/dist/builder/define-route.js.map +1 -0
  14. package/dist/builder/index.d.ts +5 -0
  15. package/dist/builder/index.d.ts.map +1 -0
  16. package/dist/builder/index.js +7 -0
  17. package/dist/builder/index.js.map +1 -0
  18. package/dist/builder/openapi-builder.d.ts +120 -0
  19. package/dist/builder/openapi-builder.d.ts.map +1 -0
  20. package/dist/builder/openapi-builder.js +349 -0
  21. package/dist/builder/openapi-builder.js.map +1 -0
  22. package/dist/builder/path-params.d.ts +129 -0
  23. package/dist/builder/path-params.d.ts.map +1 -0
  24. package/dist/builder/path-params.js +85 -0
  25. package/dist/builder/path-params.js.map +1 -0
  26. package/dist/builder/types.d.ts +149 -0
  27. package/dist/builder/types.d.ts.map +1 -0
  28. package/dist/builder/types.js +6 -0
  29. package/dist/builder/types.js.map +1 -0
  30. package/dist/config/defaults.d.ts +10 -0
  31. package/dist/config/defaults.d.ts.map +1 -0
  32. package/dist/config/defaults.js +28 -0
  33. package/dist/config/defaults.js.map +1 -0
  34. package/dist/config/define-config.d.ts +50 -0
  35. package/dist/config/define-config.d.ts.map +1 -0
  36. package/dist/config/define-config.js +80 -0
  37. package/dist/config/define-config.js.map +1 -0
  38. package/dist/config/index.d.ts +4 -0
  39. package/dist/config/index.d.ts.map +1 -0
  40. package/dist/config/index.js +5 -0
  41. package/dist/config/index.js.map +1 -0
  42. package/dist/config/types.d.ts +103 -0
  43. package/dist/config/types.d.ts.map +1 -0
  44. package/dist/config/types.js +2 -0
  45. package/dist/config/types.js.map +1 -0
  46. package/dist/decorators/api.d.ts +35 -0
  47. package/dist/decorators/api.d.ts.map +1 -0
  48. package/dist/decorators/api.js +34 -0
  49. package/dist/decorators/api.js.map +1 -0
  50. package/dist/decorators/controller.d.ts +35 -0
  51. package/dist/decorators/controller.d.ts.map +1 -0
  52. package/dist/decorators/controller.js +34 -0
  53. package/dist/decorators/controller.js.map +1 -0
  54. package/dist/decorators/endpoint.d.ts +93 -0
  55. package/dist/decorators/endpoint.d.ts.map +1 -0
  56. package/dist/decorators/endpoint.js +108 -0
  57. package/dist/decorators/endpoint.js.map +1 -0
  58. package/dist/decorators/index.d.ts +5 -0
  59. package/dist/decorators/index.d.ts.map +1 -0
  60. package/dist/decorators/index.js +6 -0
  61. package/dist/decorators/index.js.map +1 -0
  62. package/dist/decorators/route.d.ts +93 -0
  63. package/dist/decorators/route.d.ts.map +1 -0
  64. package/dist/decorators/route.js +108 -0
  65. package/dist/decorators/route.js.map +1 -0
  66. package/dist/errors/base.d.ts +8 -0
  67. package/dist/errors/base.d.ts.map +1 -0
  68. package/dist/errors/base.js +13 -0
  69. package/dist/errors/base.js.map +1 -0
  70. package/dist/errors/configuration.d.ts +22 -0
  71. package/dist/errors/configuration.d.ts.map +1 -0
  72. package/dist/errors/configuration.js +33 -0
  73. package/dist/errors/configuration.js.map +1 -0
  74. package/dist/errors/index.d.ts +4 -0
  75. package/dist/errors/index.d.ts.map +1 -0
  76. package/dist/errors/index.js +4 -0
  77. package/dist/errors/index.js.map +1 -0
  78. package/dist/errors/validation.d.ts +46 -0
  79. package/dist/errors/validation.d.ts.map +1 -0
  80. package/dist/errors/validation.js +52 -0
  81. package/dist/errors/validation.js.map +1 -0
  82. package/dist/index.d.ts +48 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +44 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/metadata/index.d.ts +2 -0
  87. package/dist/metadata/index.d.ts.map +1 -0
  88. package/dist/metadata/index.js +2 -0
  89. package/dist/metadata/index.js.map +1 -0
  90. package/dist/metadata/storage.d.ts +50 -0
  91. package/dist/metadata/storage.d.ts.map +1 -0
  92. package/dist/metadata/storage.js +100 -0
  93. package/dist/metadata/storage.js.map +1 -0
  94. package/dist/metadata/types.d.ts +142 -0
  95. package/dist/metadata/types.d.ts.map +1 -0
  96. package/dist/metadata/types.js +2 -0
  97. package/dist/metadata/types.js.map +1 -0
  98. package/dist/response/helpers.d.ts +132 -0
  99. package/dist/response/helpers.d.ts.map +1 -0
  100. package/dist/response/helpers.js +197 -0
  101. package/dist/response/helpers.js.map +1 -0
  102. package/dist/response/index.d.ts +4 -0
  103. package/dist/response/index.d.ts.map +1 -0
  104. package/dist/response/index.js +4 -0
  105. package/dist/response/index.js.map +1 -0
  106. package/dist/response/types.d.ts +59 -0
  107. package/dist/response/types.d.ts.map +1 -0
  108. package/dist/response/types.js +26 -0
  109. package/dist/response/types.js.map +1 -0
  110. package/dist/runtime/adapter-types.d.ts +119 -0
  111. package/dist/runtime/adapter-types.d.ts.map +1 -0
  112. package/dist/runtime/adapter-types.js +2 -0
  113. package/dist/runtime/adapter-types.js.map +1 -0
  114. package/dist/runtime/index.d.ts +12 -0
  115. package/dist/runtime/index.d.ts.map +1 -0
  116. package/dist/runtime/index.js +10 -0
  117. package/dist/runtime/index.js.map +1 -0
  118. package/dist/runtime/response-helpers.d.ts +138 -0
  119. package/dist/runtime/response-helpers.d.ts.map +1 -0
  120. package/dist/runtime/response-helpers.js +105 -0
  121. package/dist/runtime/response-helpers.js.map +1 -0
  122. package/dist/runtime/route-utils.d.ts +22 -0
  123. package/dist/runtime/route-utils.d.ts.map +1 -0
  124. package/dist/runtime/route-utils.js +47 -0
  125. package/dist/runtime/route-utils.js.map +1 -0
  126. package/dist/runtime/types.d.ts +125 -0
  127. package/dist/runtime/types.d.ts.map +1 -0
  128. package/dist/runtime/types.js +2 -0
  129. package/dist/runtime/types.js.map +1 -0
  130. package/dist/validation/index.d.ts +3 -0
  131. package/dist/validation/index.d.ts.map +1 -0
  132. package/dist/validation/index.js +3 -0
  133. package/dist/validation/index.js.map +1 -0
  134. package/dist/validation/types.d.ts +55 -0
  135. package/dist/validation/types.d.ts.map +1 -0
  136. package/dist/validation/types.js +2 -0
  137. package/dist/validation/types.js.map +1 -0
  138. package/package.json +93 -0
@@ -0,0 +1,46 @@
1
+ import type { TSchema } from '@sinclair/typebox';
2
+ import { OpenApiDecoratorError } from './base.js';
3
+ /**
4
+ * Validation error detail for a single field.
5
+ */
6
+ export interface ValidationErrorDetail {
7
+ field: string;
8
+ message: string;
9
+ code?: string;
10
+ }
11
+ /**
12
+ * Response format for validation errors.
13
+ */
14
+ export interface ValidationErrorResponse {
15
+ status: number;
16
+ code: string;
17
+ message: string;
18
+ errors: ValidationErrorDetail[];
19
+ }
20
+ /**
21
+ * Error thrown when request validation fails.
22
+ */
23
+ export declare class RequestValidationError extends OpenApiDecoratorError {
24
+ readonly status = 422;
25
+ readonly errors: ValidationErrorDetail[];
26
+ readonly schema: TSchema;
27
+ readonly data: unknown;
28
+ readonly source: 'body' | 'query' | 'params';
29
+ constructor(schema: TSchema, data: unknown, errors: ValidationErrorDetail[], source: 'body' | 'query' | 'params');
30
+ /**
31
+ * Convert to a response object suitable for sending to the client.
32
+ */
33
+ toResponse(): ValidationErrorResponse;
34
+ }
35
+ /**
36
+ * Error thrown when response validation fails (development only).
37
+ * This indicates a bug in the handler - the returned data doesn't match the declared schema.
38
+ */
39
+ export declare class ResponseValidationError extends OpenApiDecoratorError {
40
+ readonly status = 500;
41
+ readonly errors: ValidationErrorDetail[];
42
+ readonly schema: TSchema;
43
+ readonly data: unknown;
44
+ constructor(schema: TSchema, data: unknown, errors: ValidationErrorDetail[]);
45
+ }
46
+ //# sourceMapp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,EAAE;CAWlC"}
@@ -0,0 +1,52 @@
1
+ import { OpenApiDecoratorError } from './base.js';
2
+ /**
3
+ * Error thrown when request validation fails.
4
+ */
5
+ export class RequestValidationError extends OpenApiDecoratorError {
6
+ status = 422;
7
+ errors;
8
+ schema;
9
+ data;
10
+ source;
11
+ constructor(schema, data, errors, source) {
12
+ const schemaName = schema.$id ?? schema.title ?? 'Request';
13
+ const errorSummary = errors.map((e) => `${e.field}: ${e.message}`).join(', ');
14
+ super('E_VALIDATION_ERROR', `${source} validation failed for ${schemaName}: ${errorSummary}`);
15
+ this.name = 'RequestValidationError';
16
+ this.schema = schema;
17
+ this.data = data;
18
+ this.errors = errors;
19
+ this.source = source;
20
+ }
21
+ /**
22
+ * Convert to a response object suitable for sending to the client.
23
+ */
24
+ toResponse() {
25
+ return {
26
+ status: this.status,
27
+ code: this.code,
28
+ message: 'Validation failed',
29
+ errors: this.errors,
30
+ };
31
+ }
32
+ }
33
+ /**
34
+ * Error thrown when response validation fails (development only).
35
+ * This indicates a bug in the handler - the returned data doesn't match the declared schema.
36
+ */
37
+ export class ResponseValidationError extends OpenApiDecoratorError {
38
+ status = 500;
39
+ errors;
40
+ schema;
41
+ data;
42
+ constructor(schema, data, errors) {
43
+ const schemaName = schema.$id ?? schema.title ?? 'Response';
44
+ const errorSummary = errors.map((e) => `${e.field}: ${e.message}`).join(', ');
45
+ super('E_RESPONSE_VALIDATION', `Response validation failed for ${schemaName}: ${errorSummary}`);
46
+ this.name = 'ResponseValidationError';
47
+ this.schema = schema;
48
+ this.data = data;
49
+ this.errors = errors;
50
+ }
51
+ }
52
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/errors/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAqBjD;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,qBAAqB;IAC/C,MAAM,GAAG,GAA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AAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC7E,KAAK,CAAC,uBAAuB,EAAE,kCAAkC,UAAU,KAAK,YAAY,EAAE,CAAC,CAAA;QAE/F,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CACF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * kontract
3
+ *
4
+ * Framework-agnostic library for building type-safe, documented APIs with TypeBox schema support.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { defineRoute, defineController } from 'kontract'
9
+ * import { Type } from '@sinclair/typebox'
10
+ *
11
+ * const User = Type.Object({
12
+ * id: Type.Number(),
13
+ * name: Type.String(),
14
+ * })
15
+ *
16
+ * const getUser = defineRoute({
17
+ * route: 'GET /api/v1/users/:id',
18
+ * params: Type.Object({ id: Type.String() }),
19
+ * responses: { 200: { schema: User }, 404: null },
20
+ * }, async ({ params, reply }) => {
21
+ * const user = await findUser(params.id)
22
+ * if (!user) return reply.notFound()
23
+ * return reply.ok(user)
24
+ * })
25
+ *
26
+ * export const usersController = defineController({ tag: 'Users' }, { getUser })
27
+ * ```
28
+ */
29
+ export type { HttpMethod, AuthLevel, RouteString, ResponseDefinition, ResponseExample, ResponseHeader, FileUploadConfig, ApiMetadata, EndpointMetadata, ControllerMetadata, } from './metadata/types.js';
30
+ export type { ApiResponse, BinaryResponse, AnyResponse, ApiErrorBody, ErrorCode, } from './response/types.js';
31
+ export { isBinaryResponse, ErrorCodes } from './response/types.js';
32
+ export { respond, ok, created, accepted, noContent, badRequest, unauthorized, forbidden, notFound, conflict, unprocessableEntity, tooManyRequests, internalServerError, badGateway, serviceUnavailable, binary, apiError, } from './response/helpers.js';
33
+ export type { OpenApiInfo, OpenApiServer, ValidatorFn, SerializerFn, SerializerRegistration, OpenApiDecoratorConfig, UserConfig, } from './config/types.js';
34
+ export { defineConfig, getConfig, getConfigOrUndefined, isConfigured, resetConfig, } from './config/define-config.js';
35
+ export { OpenApiDecoratorError } from './errors/base.js';
36
+ export { RequestValidationError, ResponseValidationError, type ValidationErrorDetail, } from './errors/validation.js';
37
+ export { ConfigurationError, AdapterNotFoundError, SerializerNotFoundError, } from './errors/configuration.js';
38
+ export type { RequestContext, AuthUser, AuthResult, AdapterRouteHandler, RouterAdapter, AuthAdapter, ContainerAdapter, ResponseAdapter, LoggerAdapter, FrameworkAdapters, } from './runtime/types.js';
39
+ export type { ResponsesConfig, NormalizedResponse, NormalizedResponses, ExtractResponseSchema, ResponseSchemaFor, TypedHelper, TypedErrorHelper, ReplyHelpers, ErrorHelpers, BaseHandlerContext, } from './runtime/adapter-types.js';
40
+ export { ERROR_CODES, createSuccessHelper, createErrorHelper, getErrorMessage, createResponseHelpers, } from './runtime/response-helpers.js';
41
+ export { parseRouteString, normalizeResponses, isApiResponse, } from './runtime/route-utils.js';
42
+ export type { Validator, CompiledValidator, ValidatorOptions, } from './validation/types.js';
43
+ export type { OpenApiVersion, OpenApiDocument, OpenApiPathItem, OpenApiOperation, OpenApiParameter, OpenApiRequestBody, OpenApiResponse, OpenApiMediaType, OpenApiHeader, OpenApiSchema, OpenApiSecurityScheme, } from './builder/types.js';
44
+ export { OpenApiBuilder, type OpenApiBuilderOptions } from './builder/openapi-builder.js';
45
+ export { defineRoute, isRouteDefinition, type RouteConfig, type HandlerContext, type RouteHandler, type RouteDefinition, } from './builder/define-route.js';
46
+ export { defineController, isControllerDefinition, getControllerRoutes, type ControllerConfig, type ControllerDefinition, type RouteRecord, type AnyRouteDefinition, } from './builder/define-controller.js';
47
+ export { extractParamNames, createParamsSchema, getParamsSchema, type ExtractRouteParams, type HasPathParams, type ParamsFromPath, type InferParams, } from './builder/path-params.js';
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,YAAY,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,qBAAqB,CAAA;AAG5B,YAAY,EACV,WAAW,EACX,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,GACV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAElE,OAAO,EACL,OAAO,EACP,EAAE,EACF,OAAO,EACP,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,MAAM,EACN,QAAQ,GACT,MAAM,uBAAuB,CAAA;AAG9B,YAAY,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,UAAU,GACX,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,WAAW,GACZ,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,2BAA2B,CAAA;AAGlC,YAAY,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB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js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * kontract
3
+ *
4
+ * Framework-agnostic library for building type-safe, documented APIs with TypeBox schema support.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { defineRoute, defineController } from 'kontract'
9
+ * import { Type } from '@sinclair/typebox'
10
+ *
11
+ * const User = Type.Object({
12
+ * id: Type.Number(),
13
+ * name: Type.String(),
14
+ * })
15
+ *
16
+ * const getUser = defineRoute({
17
+ * route: 'GET /api/v1/users/:id',
18
+ * params: Type.Object({ id: Type.String() }),
19
+ * responses: { 200: { schema: User }, 404: null },
20
+ * }, async ({ params, reply }) => {
21
+ * const user = await findUser(params.id)
22
+ * if (!user) return reply.notFound()
23
+ * return reply.ok(user)
24
+ * })
25
+ *
26
+ * export const usersController = defineController({ tag: 'Users' }, { getUser })
27
+ * ```
28
+ */
29
+ export { isBinaryResponse, ErrorCodes } from './response/types.js';
30
+ export { respond, ok, created, accepted, noContent, badRequest, unauthorized, forbidden, notFound, conflict, unprocessableEntity, tooManyRequests, internalServerError, badGateway, serviceUnavailable, binary, apiError, } from './response/helpers.js';
31
+ export { defineConfig, getConfig, getConfigOrUndefined, isConfigured, resetConfig, } from './config/define-config.js';
32
+ // ============ Errors ============
33
+ export { OpenApiDecoratorError } from './errors/base.js';
34
+ export { RequestValidationError, ResponseValidationError, } from './errors/validation.js';
35
+ export { ConfigurationError, AdapterNotFoundError, SerializerNotFoundError, } from './errors/configuration.js';
36
+ export { ERROR_CODES, createSuccessHelper, createErrorHelper, getErrorMessage, createResponseHelpers, } from './runtime/response-helpers.js';
37
+ export { parseRouteString, normalizeResponses, isApiResponse, } from './runtime/route-utils.js';
38
+ export { OpenApiBuilder } from './builder/openapi-builder.js';
39
+ // ============ Route Builder ============
40
+ export { defineRoute, isRouteDefinition, } from './builder/define-route.js';
41
+ export { defineController, isControllerDefinition, getControllerRoutes, } from './builder/define-controller.js';
42
+ // ============ Path Parameter Utilities ============
43
+ export { extractParamNames, createParamsSchema, getParamsSchema, } from './builder/path-params.js';
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAyBH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAElE,OAAO,EACL,OAAO,EACP,EAAE,EACF,OAAO,EACP,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,MAAM,EACN,QAAQ,GACT,MAAM,uBAAuB,CAAA;AAa9B,OAAO,EACL,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,WAAW,GACZ,MAAM,2BAA2B,CAAA;AAElC,mCAAmC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAExB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,2BAA2B,CAAA;AA+BlC,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,GACtB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,GACd,MAAM,0BAA0B,CAAA;AAwBjC,OAAO,EAAE,cAAc,EAA8B,MAAM,8BAA8B,CAAA;AAEzF,0CAA0C;AAC1C,OAAO,EACL,WAAW,EACX,iBAAiB,GAKlB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,GAKpB,MAAM,gCAAgC,CAAA;AAEvC,qDAAqD;AACrD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAKhB,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export type { HttpMethod, AuthLevel, RouteString, ResponseDefinition, ResponseExample, ResponseHeader, FileUploadConfig, ApiMetadata, EndpointMetadata, ControllerMetadata, } from './types.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import type { ApiMetadata, EndpointMetadata, ControllerMetadata } from './types.js';
2
+ /**
3
+ * Store API metadata for a controller class.
4
+ */
5
+ export declare function setApiMetadata(target: object, metadata: ApiMetadata): void;
6
+ /**
7
+ * Retrieve API metadata for a controller class.
8
+ */
9
+ export declare function getApiMetadata(target: object): ApiMetadata | undefined;
10
+ /**
11
+ * Check if a target has API metadata.
12
+ */
13
+ export declare function hasApiMetadata(target: object): boolean;
14
+ /**
15
+ * Add endpoint metadata to a controller class.
16
+ * Multiple endpoints can be added to the same controller.
17
+ */
18
+ export declare function addEndpointMetadata(target: object, metadata: EndpointMetadata): void;
19
+ /**
20
+ * Retrieve all endpoint metadata for a controller class.
21
+ */
22
+ export declare function getEndpointMetadata(target: object): EndpointMetadata[];
23
+ /**
24
+ * Check if a target has any endpoint metadata.
25
+ */
26
+ export declare function hasEndpointMetadata(target: object): boolean;
27
+ /**
28
+ * Get all registered controller classes.
29
+ * Controllers are registered when decorated with @Api.
30
+ */
31
+ export declare function getRegisteredControllers(): object[];
32
+ /**
33
+ * Clear the controller registry.
34
+ * Useful for testing or hot reloading.
35
+ */
36
+ export declare function clearRegistry(): void;
37
+ /**
38
+ * Get the number of registered controllers.
39
+ */
40
+ export declare function getRegistrySize(): number;
41
+ /**
42
+ * Get complete metadata for a controller, including API info and all endpoints.
43
+ * Returns undefined if the controller doesn't have @Api metadata.
44
+ */
45
+ export declare function getControllerMetadata(controller: object): ControllerMetadata | undefined;
46
+ /**
47
+ * Get complete metadata for all registered controllers.
48
+ */
49
+ export declare function getAllControllerMetadata(): ControllerMetadata[];
50
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/metadata/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAYnF;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,CAG1E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEtE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEtD;AAID;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAIpF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAEtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE3D;AAID;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAID;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAWxF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,kBAAkB,EAAE,CAW/D"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * WeakMap-based storage for decorator metadata.
3
+ * Using WeakMaps ensures metadata is garbage collected when controllers are.
4
+ */
5
+ const apiMetadataMap = new WeakMap();
6
+ const endpointMetadataMap = new WeakMap();
7
+ const controllerRegistry = new Set();
8
+ // ============ API Metadata ============
9
+ /**
10
+ * Store API metadata for a controller class.
11
+ */
12
+ export function setApiMetadata(target, metadata) {
13
+ apiMetadataMap.set(target, metadata);
14
+ controllerRegistry.add(target);
15
+ }
16
+ /**
17
+ * Retrieve API metadata for a controller class.
18
+ */
19
+ export function getApiMetadata(target) {
20
+ return apiMetadataMap.get(target);
21
+ }
22
+ /**
23
+ * Check if a target has API metadata.
24
+ */
25
+ export function hasApiMetadata(target) {
26
+ return apiMetadataMap.has(target);
27
+ }
28
+ // ============ Endpoint Metadata ============
29
+ /**
30
+ * Add endpoint metadata to a controller class.
31
+ * Multiple endpoints can be added to the same controller.
32
+ */
33
+ export function addEndpointMetadata(target, metadata) {
34
+ const existing = endpointMetadataMap.get(target) ?? [];
35
+ existing.push(metadata);
36
+ endpointMetadataMap.set(target, existing);
37
+ }
38
+ /**
39
+ * Retrieve all endpoint metadata for a controller class.
40
+ */
41
+ export function getEndpointMetadata(target) {
42
+ return endpointMetadataMap.get(target) ?? [];
43
+ }
44
+ /**
45
+ * Check if a target has any endpoint metadata.
46
+ */
47
+ export function hasEndpointMetadata(target) {
48
+ return endpointMetadataMap.has(target);
49
+ }
50
+ // ============ Registry ============
51
+ /**
52
+ * Get all registered controller classes.
53
+ * Controllers are registered when decorated with @Api.
54
+ */
55
+ export function getRegisteredControllers() {
56
+ return Array.from(controllerRegistry);
57
+ }
58
+ /**
59
+ * Clear the controller registry.
60
+ * Useful for testing or hot reloading.
61
+ */
62
+ export function clearRegistry() {
63
+ controllerRegistry.clear();
64
+ }
65
+ /**
66
+ * Get the number of registered controllers.
67
+ */
68
+ export function getRegistrySize() {
69
+ return controllerRegistry.size;
70
+ }
71
+ // ============ Combined Metadata ============
72
+ /**
73
+ * Get complete metadata for a controller, including API info and all endpoints.
74
+ * Returns undefined if the controller doesn't have @Api metadata.
75
+ */
76
+ export function getControllerMetadata(controller) {
77
+ const api = getApiMetadata(controller);
78
+ if (!api) {
79
+ return undefined;
80
+ }
81
+ return {
82
+ controller,
83
+ api,
84
+ endpoints: getEndpointMetadata(controller),
85
+ };
86
+ }
87
+ /**
88
+ * Get complete metadata for all registered controllers.
89
+ */
90
+ export function getAllControllerMetadata() {
91
+ const result = [];
92
+ for (const controller of controllerRegistry) {
93
+ const metadata = getControllerMetadata(controller);
94
+ if (metadata) {
95
+ result.push(metadata);
96
+ }
97
+ }
98
+ return result;
99
+ }
100
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/metadata/storage.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,cAAc,GAAG,IAAI,OAAO,EAAuB,CAAA;AACzD,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAA8B,CAAA;AACrE,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAA;AAE5C,yCAAyC;AAEzC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,QAAqB;IAClE,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACpC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAO,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC;AAED;;GAEG;AACH,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GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAyB,EAAE,CAAA;IAEvC,KAAK,MAAM,UAAU,IAAI,kBAAkB,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAClD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACvB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,142 @@
1
+ import type { TSchema, Static } from '@sinclair/typebox';
2
+ /**
3
+ * HTTP methods supported by the framework.
4
+ */
5
+ export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
6
+ /**
7
+ * Authentication requirement levels for endpoints.
8
+ */
9
+ export type AuthLevel = 'required' | 'optional' | 'none';
10
+ /**
11
+ * Route string format: "METHOD /path" (path must start with /)
12
+ * @example "GET /api/v1/users"
13
+ * @example "POST /api/v1/users/:id"
14
+ */
15
+ export type RouteString = `${'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'} /${string}`;
16
+ /**
17
+ * Example value for documentation.
18
+ * Used in response definitions to provide sample data for OpenAPI docs.
19
+ */
20
+ export interface ResponseExample<T = unknown> {
21
+ /** Example value matching the response schema */
22
+ value: T;
23
+ /** Short summary of what this example demonstrates */
24
+ summary?: string;
25
+ }
26
+ /**
27
+ * Response header definition for OpenAPI.
28
+ * Describes headers returned in the response.
29
+ */
30
+ export interface ResponseHeader {
31
+ /** Header description */
32
+ description?: string;
33
+ /** Header schema (typically Type.String() or Type.Number()) */
34
+ schema: TSchema;
35
+ /** Whether this header is required (default: false) */
36
+ required?: boolean;
37
+ }
38
+ /**
39
+ * Response definition for an endpoint.
40
+ * Generic parameter T is inferred from the schema for type-safe examples.
41
+ *
42
+ * @example Basic usage
43
+ * ```typescript
44
+ * responses: {
45
+ * 200: { schema: UserSchema, description: 'User found' }
46
+ * }
47
+ * ```
48
+ *
49
+ * @example With type-safe examples
50
+ * ```typescript
51
+ * responses: {
52
+ * 200: {
53
+ * schema: UserSchema,
54
+ * description: 'User found',
55
+ * example: { id: '1', name: 'John' } // TypeScript will validate this matches UserSchema
56
+ * }
57
+ * }
58
+ * ```
59
+ */
60
+ export interface ResponseDefinition<T extends TSchema | null = TSchema | null> {
61
+ /** The TypeBox schema for the response body, or null for empty responses */
62
+ schema: T;
63
+ /** Description of this response (for OpenAPI docs) */
64
+ description?: string;
65
+ /** Response headers */
66
+ headers?: Record<string, ResponseHeader>;
67
+ /** Multiple named examples (type-checked against schema) */
68
+ examples?: T extends TSchema ? Record<string, ResponseExample<Static<T>>> : never;
69
+ /** Single example value (type-checked against schema) */
70
+ example?: T extends TSchema ? Static<T> : never;
71
+ }
72
+ /**
73
+ * File upload configuration for multipart/form-data endpoints.
74
+ */
75
+ export interface FileUploadConfig {
76
+ /** Field name for the file input */
77
+ fieldName: string;
78
+ /** Description for the file field */
79
+ description?: string;
80
+ /** Allowed file extensions (e.g., ['csv', 'json']) */
81
+ allowedExtensions?: string[];
82
+ /** Maximum file size (e.g., '10mb') */
83
+ maxSize?: string;
84
+ /** Whether to accept multiple files (default: false) */
85
+ multiple?: boolean;
86
+ }
87
+ /**
88
+ * Metadata for a controller class decorated with @Api.
89
+ */
90
+ export interface ApiMetadata {
91
+ /** OpenAPI tag for grouping endpoints */
92
+ tag: string;
93
+ /** Description of the API group */
94
+ description?: string;
95
+ /** Optional path prefix for all endpoints in this controller */
96
+ prefix?: string;
97
+ }
98
+ /**
99
+ * Metadata for an endpoint method decorated with @Endpoint.
100
+ */
101
+ export interface EndpointMetadata {
102
+ /** HTTP method (lowercase) */
103
+ method: HttpMethod;
104
+ /** URL path pattern */
105
+ path: string;
106
+ /** Name of the decorated method */
107
+ methodName: string;
108
+ /** Short summary for OpenAPI */
109
+ summary?: string;
110
+ /** Detailed description for OpenAPI */
111
+ description?: string;
112
+ /** Unique operation ID for OpenAPI */
113
+ operationId?: string;
114
+ /** Whether this endpoint is deprecated */
115
+ deprecated?: boolean;
116
+ /** Authentication requirement */
117
+ auth: AuthLevel;
118
+ /** Request body schema */
119
+ body?: TSchema;
120
+ /** Query parameters schema */
121
+ query?: TSchema;
122
+ /** Path parameters schema */
123
+ params?: TSchema;
124
+ /** File upload configuration */
125
+ file?: FileUploadConfig;
126
+ /** Response definitions by status code */
127
+ responses: Record<number, ResponseDefinition>;
128
+ /** Framework-specific middleware (opaque to core) */
129
+ middleware?: unknown[];
130
+ }
131
+ /**
132
+ * Combined metadata for a controller with all its endpoints.
133
+ */
134
+ export interface ControllerMetadata {
135
+ /** The controller class constructor */
136
+ controller: object;
137
+ /** Controller-level metadata */
138
+ api: ApiMetadata;
139
+ /** All endpoint metadata for this controller */
140
+ endpoints: EndpointMetadata[];
141
+ }
142
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAExD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEpE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAA;AAExD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,KAAK,MAAM,EAAE,CAAA;AAErF;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,iDAAiD;IACjD,KAAK,EAAE,CAAC,CAAA;IACR,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,yBAAyB;IACzB,WAAW,CAAC,E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MAAM,EAAE,UAAU,CAAA;IAClB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iCAAiC;IACjC,IAAI,EAAE,SAAS,CAAA;IACf,0BAA0B;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,8BAA8B;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,6BAA6B;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gCAAgC;IAChC,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAC7C,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,EAAE,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,gCAAgC;IAChC,GAAG,EAAE,WAAW,CAAA;IAChB,gDAAgD;IAChD,SAAS,EAAE,gBAAgB,EAAE,CAAA;CAC9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/metadata/types.ts"],"names":[],"mappings":""}