UNPKG

arvox-backend

Version:

Un framework backend moderne et modulaire basé sur Hono, TypeScript et l'architecture hexagonale avec authentification Better Auth + Drizzle intégrée

595 lines 21.7 kB
import { z } from 'zod'; /** * Helper pour créer des routes OpenAPI avec documentation standardisée */ export declare class DocumentationHelper { /** * Créer une route GET avec pagination */ static createListRoute<TResponse>(config: { path: string; tag: string; summary: string; description?: string; responseSchema: z.ZodSchema<TResponse>; queryParams?: z.ZodSchema<any>; security?: boolean; }): { method: "get"; path: string; tags: string[]; summary: string; description: string | undefined; security: { bearerAuth: never[]; }[] | undefined; request: { query: z.ZodObject<{ page: z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>; limit: z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>; search: z.ZodOptional<z.ZodString>; sort: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { page: number; limit: number; search?: string | undefined; sort?: string | undefined; }, { page?: string | undefined; limit?: string | undefined; search?: string | undefined; sort?: string | undefined; }>; }; responses: { 200: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodObject<{ items: z.ZodArray<z.ZodType<TResponse, z.ZodTypeDef, TResponse>, "many">; pagination: z.ZodObject<{ total: z.ZodNumber; page: z.ZodNumber; limit: z.ZodNumber; totalPages: z.ZodNumber; hasNext: z.ZodBoolean; hasPrev: z.ZodBoolean; }, "strip", z.ZodTypeAny, { page: number; limit: number; total: number; totalPages: number; hasNext: boolean; hasPrev: boolean; }, { page: number; limit: number; total: number; totalPages: number; hasNext: boolean; hasPrev: boolean; }>; }, "strip", z.ZodTypeAny, { items: TResponse[]; pagination: { page: number; limit: number; total: number; totalPages: number; hasNext: boolean; hasPrev: boolean; }; }, { items: TResponse[]; pagination: { page: number; limit: number; total: number; totalPages: number; hasNext: boolean; hasPrev: boolean; }; }>; }, "strip", z.ZodTypeAny, { data: { items: TResponse[]; pagination: { page: number; limit: number; total: number; totalPages: number; hasNext: boolean; hasPrev: boolean; }; }; success: boolean; }, { data: { items: TResponse[]; pagination: { page: number; limit: number; total: number; totalPages: number; hasNext: boolean; hasPrev: boolean; }; }; success: boolean; }>; }; }; }; 400: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; 401: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; }; } & { getRoutingPath(): string; }; /** * Créer une route GET par ID */ static createGetByIdRoute<TResponse>(config: { path: string; tag: string; summary: string; description?: string; responseSchema: z.ZodSchema<TResponse>; security?: boolean; }): { method: "get"; path: string; tags: string[]; summary: string; description: string | undefined; security: { bearerAuth: never[]; }[] | undefined; request: { params: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; }; responses: { 200: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }>, any> extends infer T ? { [k in keyof T]: T[k]; } : never, z.baseObjectInputType<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }> extends infer T_1 ? { [k_1 in keyof T_1]: T_1[k_1]; } : never>; }; }; }; 404: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; 401: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; }; } & { getRoutingPath(): string; }; /** * Créer une route POST */ static createPostRoute<TRequest, TResponse>(config: { path: string; tag: string; summary: string; description?: string; requestSchema: z.ZodSchema<TRequest>; responseSchema: z.ZodSchema<TResponse>; security?: boolean; multipart?: boolean; }): { method: "post"; path: string; tags: string[]; summary: string; description: string | undefined; security: { bearerAuth: never[]; }[] | undefined; request: { body: { content: { [x: string]: { schema: z.ZodType<TRequest, z.ZodTypeDef, TRequest>; }; }; }; }; responses: { 201: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }>, any> extends infer T ? { [k in keyof T]: T[k]; } : never, z.baseObjectInputType<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }> extends infer T_1 ? { [k_1 in keyof T_1]: T_1[k_1]; } : never>; }; }; }; 400: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; details: z.ZodOptional<z.ZodArray<z.ZodObject<{ field: z.ZodString; message: z.ZodString; }, "strip", z.ZodTypeAny, { message: string; field: string; }, { message: string; field: string; }>, "many">>; }, "strip", z.ZodTypeAny, { error: string; success: boolean; details?: { message: string; field: string; }[] | undefined; }, { error: string; success: boolean; details?: { message: string; field: string; }[] | undefined; }>; }; }; }; 401: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; }; } & { getRoutingPath(): string; }; /** * Créer une route PUT */ static createPutRoute<TRequest, TResponse>(config: { path: string; tag: string; summary: string; description?: string; requestSchema: z.ZodSchema<TRequest>; responseSchema: z.ZodSchema<TResponse>; security?: boolean; multipart?: boolean; }): { method: "put"; path: string; tags: string[]; summary: string; description: string | undefined; security: { bearerAuth: never[]; }[] | undefined; request: { params: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; body: { content: { [x: string]: { schema: z.ZodType<TRequest, z.ZodTypeDef, TRequest>; }; }; }; }; responses: { 200: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }>, any> extends infer T ? { [k in keyof T]: T[k]; } : never, z.baseObjectInputType<{ success: z.ZodBoolean; data: z.ZodType<TResponse, z.ZodTypeDef, TResponse>; }> extends infer T_1 ? { [k_1 in keyof T_1]: T_1[k_1]; } : never>; }; }; }; 400: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; 404: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; 401: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; }; } & { getRoutingPath(): string; }; /** * Créer une route DELETE */ static createDeleteRoute(config: { path: string; tag: string; summary: string; description?: string; security?: boolean; }): { method: "delete"; path: string; tags: string[]; summary: string; description: string | undefined; security: { bearerAuth: never[]; }[] | undefined; request: { params: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; }; responses: { 200: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodObject<{ deleted: z.ZodBoolean; }, "strip", z.ZodTypeAny, { deleted: boolean; }, { deleted: boolean; }>; }, "strip", z.ZodTypeAny, { data: { deleted: boolean; }; success: boolean; }, { data: { deleted: boolean; }; success: boolean; }>; }; }; }; 404: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; 401: { description: string; content: { 'application/json': { schema: z.ZodObject<{ success: z.ZodBoolean; error: z.ZodString; }, "strip", z.ZodTypeAny, { error: string; success: boolean; }, { error: string; success: boolean; }>; }; }; }; }; } & { getRoutingPath(): string; }; /** * Créer un schéma de base pour une entité */ static createBaseEntitySchema(): z.ZodObject<{ id: z.ZodString; createdAt: z.ZodDate; updatedAt: z.ZodDate; }, "strip", z.ZodTypeAny, { id: string; createdAt: Date; updatedAt: Date; }, { id: string; createdAt: Date; updatedAt: Date; }>; /** * Créer un schéma de création (sans id, createdAt, updatedAt) */ static createCreateSchema<T extends z.ZodRawShape>(entitySchema: z.ZodObject<T>): any; /** * Créer un schéma de mise à jour (partial sans id, createdAt, updatedAt) */ static omitTimestamps<T extends z.ZodTypeAny>(entitySchema: T): any; static omitTimestampsAndMakePartial<T extends z.ZodTypeAny>(entitySchema: T): any; /** * Ajouter des exemples à un schéma */ static addExamples<T>(schema: z.ZodSchema<T>, examples: Record<string, any>): z.ZodType<T, z.ZodTypeDef, T>; /** * Créer un header d'autorisation */ static createAuthHeader(): z.ZodObject<{ authorization: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { authorization?: string | undefined; }, { authorization?: string | undefined; }>; } //# sourceMappingURL=documentation-helper.d.ts.map