zeti-framework-backend 0.2.7 → 0.2.8

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.
@@ -1,197 +0,0 @@
1
- import { ZodRawShape, ZodTypeAny, ZodObject, z } from 'zod';
2
- import { Context, Next } from 'hono';
3
- import { Z as ZetiSwaggerConfig } from './config-VWgz0Iq_.js';
4
-
5
- /**
6
- * Handler de middleware com db injetado automaticamente.
7
- *
8
- * O `db` é obtido do contexto (setado pelo framework) e já vem com:
9
- * - Filtro de tenant aplicado (se connectionStrategy = 'dynamic')
10
- * - Cache por URL (reutiliza instância base)
11
- */
12
- type MiddlewareHandler<TDb = any> = (c: Context, next: Next, db: TDb) => Promise<void | Response>;
13
- /**
14
- * Cria um middleware com o `db` injetado automaticamente.
15
- *
16
- * O `db` é obtido do contexto (setado pelo framework) e já vem com:
17
- * - Filtro de tenant aplicado (se connectionStrategy = 'dynamic')
18
- * - Cache por URL (reutiliza instância base)
19
- *
20
- * @example
21
- * ```typescript
22
- * import { PrismaClient } from '@prisma/client';
23
- *
24
- * const authMiddleware = createMiddleware<PrismaClient>(async (c, next, db) => {
25
- * // db já vem tipado e com filtro de tenant
26
- * const user = await db.user.findUnique({
27
- * where: { id: c.req.header('x-user-id') }
28
- * });
29
- *
30
- * if (!user) {
31
- * return c.json({ error: 'Unauthorized' }, 401);
32
- * }
33
- *
34
- * c.set('user', user);
35
- * await next();
36
- * });
37
- * ```
38
- */
39
- declare function createMiddleware<TDb = any>(handler: MiddlewareHandler<TDb>): (c: Context, next: Next) => Promise<void | Response>;
40
- type MiddlewareFactory<T extends any[], TDb = any> = (...args: T) => (c: Context, next: Next) => Promise<void | Response>;
41
- /**
42
- * Cria uma factory de middleware com db injetado.
43
- *
44
- * @example
45
- * ```typescript
46
- * const requirePermission = createMiddlewareFactory<[string[]], PrismaClient>(
47
- * (permissions: string[]) => async (c, next, db) => {
48
- * const user = c.get('user');
49
- * const userPermissions = await db.permission.findMany({
50
- * where: { userId: user.id }
51
- * });
52
- *
53
- * const hasPermission = permissions.every(p =>
54
- * userPermissions.some(up => up.name === p)
55
- * );
56
- *
57
- * if (!hasPermission) {
58
- * return c.json({ error: 'Forbidden' }, 403);
59
- * }
60
- *
61
- * await next();
62
- * }
63
- * );
64
- *
65
- * // Uso:
66
- * app.use('/admin/*', requirePermission(['admin:read']));
67
- * ```
68
- */
69
- declare function createMiddlewareFactory<T extends any[], TDb = any>(factory: (...args: T) => MiddlewareHandler<TDb>): MiddlewareFactory<T, TDb>;
70
- /**
71
- * Helper para obter o db do contexto de forma tipada.
72
- * Útil quando você precisa acessar o db fora do createMiddleware.
73
- *
74
- * @throws Error se o db não estiver disponível
75
- *
76
- * @example
77
- * ```typescript
78
- * // Em um handler de rota Hono puro
79
- * app.get('/users', async (c) => {
80
- * const db = getDb<PrismaClient>(c);
81
- * const users = await db.user.findMany();
82
- * return c.json(users);
83
- * });
84
- * ```
85
- */
86
- declare function getDb<TDb = any>(c: Context): TDb;
87
- /**
88
- * Helper para obter o db do contexto de forma segura (pode retornar undefined).
89
- *
90
- * @example
91
- * ```typescript
92
- * // Em um handler de rota Hono puro
93
- * app.get('/health', async (c) => {
94
- * const db = getDbSafe<PrismaClient>(c);
95
- * if (!db) {
96
- * return c.json({ status: 'degraded', db: false });
97
- * }
98
- * return c.json({ status: 'ok', db: true });
99
- * });
100
- * ```
101
- */
102
- declare function getDbSafe<TDb = any>(c: Context): TDb | undefined;
103
-
104
- type SchemaDefinition = {
105
- body?: ZodRawShape | ZodTypeAny;
106
- query?: ZodRawShape | ZodTypeAny;
107
- response?: ZodRawShape | ZodTypeAny;
108
- formData?: ZodRawShape | ZodTypeAny;
109
- };
110
- type NormalizeFormData<T> = T extends ZodTypeAny ? T : T extends ZodRawShape ? ZodObject<T> : never;
111
- type InferFormData<S extends SchemaDefinition> = S['formData'] extends undefined ? unknown : NormalizeFormData<S['formData']> extends never ? unknown : z.infer<NormalizeFormData<S['formData']>>;
112
- type NormalizeZod<T> = T extends ZodTypeAny ? T : T extends ZodRawShape ? ZodObject<T> : never;
113
- type InferBody<S extends SchemaDefinition> = S['body'] extends undefined ? unknown : NormalizeZod<S['body']> extends never ? unknown : z.infer<NormalizeZod<S['body']>>;
114
- type InferQuery<S extends SchemaDefinition> = S['query'] extends undefined ? unknown : NormalizeZod<S['query']> extends never ? unknown : z.infer<NormalizeZod<S['query']>>;
115
- type ExtractParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
116
- [K in Param]: string;
117
- } & ExtractParams<Rest> : T extends `${infer _Start}:${infer Param}` ? {
118
- [K in Param]: string;
119
- } : {};
120
- type ZetiZod = typeof z;
121
- type ZetiContextExtensions = {
122
- ipAddress?: string;
123
- userAgent?: string;
124
- timezone: string;
125
- tenantId: string;
126
- };
127
- type ZetiContext<TContext extends Context = Context> = TContext & ZetiContextExtensions;
128
- interface ZetiRouteProps<TParams extends Record<string, string>, TBody, TQuery, TFormData, TPrisma = any, TUser = any> {
129
- context: ZetiContext;
130
- next: Next;
131
- params: TParams;
132
- body: TBody;
133
- query: TQuery;
134
- formData: TFormData;
135
- user?: TUser;
136
- db: TPrisma;
137
- res: ZetiResponseHelpers;
138
- }
139
- interface ZetiResponseHelpers {
140
- goneError: (params: {
141
- message: string;
142
- code?: string;
143
- }) => never;
144
- unauthorizedError: (message: string) => never;
145
- badRequestError: (message: string) => never;
146
- }
147
- interface ZetiMethodOptions<TPath extends string, TSchema extends SchemaDefinition, TPrisma = any, TUser = any> {
148
- middleware?: {
149
- use?: MiddlewareHandler[];
150
- schema?: (z: ZetiZod) => TSchema;
151
- database?: string;
152
- tenant?: boolean;
153
- /** Exige auth (injeta `auth` antes dos demais). */
154
- auth?: boolean;
155
- /** Claims exigidas (usa `requireClaim` de named). */
156
- claims?: string[];
157
- /** Roles exigidas (usa `requireRole` de named). */
158
- roles?: string[];
159
- };
160
- route: (props: ZetiRouteProps<ExtractParams<TPath>, InferBody<TSchema>, InferQuery<TSchema>, InferFormData<TSchema>, TPrisma, TUser>) => Promise<any>;
161
- }
162
- interface RouteMetadata {
163
- path: string;
164
- method: 'get' | 'post' | 'put' | 'delete' | 'patch';
165
- auth: boolean;
166
- tenant?: boolean;
167
- claims?: string[];
168
- roles?: string[];
169
- bodySchema?: ZodTypeAny;
170
- querySchema?: ZodTypeAny;
171
- responseSchema?: ZodTypeAny;
172
- formDataSchema?: ZodTypeAny;
173
- summary?: string;
174
- description?: string;
175
- tags?: string[];
176
- }
177
- type ZetiRouteMiddleware<TSchema extends SchemaDefinition> = ZetiMethodOptions<any, TSchema>['middleware'];
178
-
179
- declare class SwaggerRegistry {
180
- private routes;
181
- register(metadata: RouteMetadata): void;
182
- getAll(): RouteMetadata[];
183
- clear(): void;
184
- }
185
-
186
- interface SwaggerGeneratorOptions {
187
- loadGeneratedSchemas?: () => Promise<{
188
- routeResponseSchemas?: Record<string, Record<string, {
189
- schema: ZodTypeAny;
190
- ref: string | null;
191
- }>>;
192
- namedSchemas?: Record<string, ZodTypeAny>;
193
- }>;
194
- }
195
- declare function generateSwagger(registry: SwaggerRegistry, config: ZetiSwaggerConfig, options?: SwaggerGeneratorOptions): Promise<object>;
196
-
197
- export { type ExtractParams as E, type InferBody as I, type MiddlewareFactory as M, type RouteMetadata as R, type SwaggerGeneratorOptions as S, type ZetiMethodOptions as Z, SwaggerRegistry as a, type SchemaDefinition as b, type InferFormData as c, type InferQuery as d, type MiddlewareHandler as e, type ZetiContext as f, generateSwagger as g, type ZetiContextExtensions as h, type ZetiResponseHelpers as i, type ZetiRouteMiddleware as j, type ZetiRouteProps as k, type ZetiZod as l, createMiddleware as m, createMiddlewareFactory as n, getDb as o, getDbSafe as p };
package/dist/index.d.ts DELETED
@@ -1,281 +0,0 @@
1
- import * as hono_types from 'hono/types';
2
- import { Context, Next, Hono } from 'hono';
3
- import { a as ZetiConfigInternal, W as WorkerConfig, b as ZetiPrismaConnectionConfig, R as RedisConfig } from './config-VWgz0Iq_.js';
4
- export { C as ConnectionStrategy, E as ErrorResponse, c as ErrorTrace, M as Middleware, P as Prisma, d as PrismaClientBase, S as SecurityScope, T as TenantSelection, V as ValidationError, e as WorkersConfig, f as ZetiConfig, g as ZetiCorsConfig, h as ZetiDatabaseConfig, i as ZetiDevConfig, j as ZetiErrorHandlerConfig, k as ZetiHeadersConfig, l as ZetiMiddlewareConfig, m as ZetiPrismaConfig, Z as ZetiSwaggerConfig, n as ZetiSwaggerHeaderParam, o as ZetiTenantConfig, p as closeRedis, q as createErrorHandler, r as defineZetiConfig, s as getRedisClient, t as getRedisConfig, u as handleError, v as initRedis } from './config-VWgz0Iq_.js';
5
- import { b as SchemaDefinition, Z as ZetiMethodOptions, a as SwaggerRegistry } from './generator-CK-ZmWQj.js';
6
- export { E as ExtractParams, I as InferBody, c as InferFormData, d as InferQuery, M as MiddlewareFactory, e as MiddlewareHandler, R as RouteMetadata, S as SwaggerGeneratorOptions, f as ZetiContext, h as ZetiContextExtensions, i as ZetiResponseHelpers, j as ZetiRouteMiddleware, k as ZetiRouteProps, l as ZetiZod, m as createMiddleware, n as createMiddlewareFactory, g as generateSwagger, o as getDb, p as getDbSafe } from './generator-CK-ZmWQj.js';
7
- import { TenantManager } from './tenants/index.js';
8
- export { MetricsCollector, TenantMetrics } from './tenants/index.js';
9
- import Redis from 'ioredis';
10
- export { default as Redis } from 'ioredis';
11
- export { PrismaConfigOptions, definePrismaConfig, getAllDatabaseUrls } from './prisma/index.js';
12
- import { z } from 'zod';
13
- export { GenerateRegistryOptions, GenerateSwaggerTypesOptions, generateRegistry, generateSwaggerTypes, runPrebuild } from './scripts/index.js';
14
- import 'hono/http-exception';
15
-
16
- /**
17
- * Handler de middleware tipado com o PrismaClient do projeto.
18
- */
19
- type ZetiMiddlewareHandler<TPrisma = any> = (c: Context, next: Next, db: TPrisma) => Promise<void | Response>;
20
- interface ZetiApp<TPrisma = any, TUser = any> {
21
- get: <TPath extends string, TSchema extends SchemaDefinition = {}>(url: TPath, options: ZetiMethodOptions<TPath, TSchema, TPrisma, TUser>) => void;
22
- post: <TPath extends string, TSchema extends SchemaDefinition = {}>(url: TPath, options: ZetiMethodOptions<TPath, TSchema, TPrisma, TUser>) => void;
23
- put: <TPath extends string, TSchema extends SchemaDefinition = {}>(url: TPath, options: ZetiMethodOptions<TPath, TSchema, TPrisma, TUser>) => void;
24
- del: <TPath extends string, TSchema extends SchemaDefinition = {}>(url: TPath, options: ZetiMethodOptions<TPath, TSchema, TPrisma, TUser>) => void;
25
- patch: <TPath extends string, TSchema extends SchemaDefinition = {}>(url: TPath, options: ZetiMethodOptions<TPath, TSchema, TPrisma, TUser>) => void;
26
- /**
27
- * Cria um middleware com o db tipado automaticamente.
28
- *
29
- * @example
30
- * ```typescript
31
- * const authMiddleware = app.createMiddleware(async (c, next, db) => {
32
- * const user = await db.user.findUnique({
33
- * where: { id: c.req.header('x-user-id') }
34
- * });
35
- * if (!user) return c.json({ error: 'Unauthorized' }, 401);
36
- * c.set('user', user);
37
- * await next();
38
- * });
39
- * ```
40
- */
41
- createMiddleware: (handler: ZetiMiddlewareHandler<TPrisma>) => (c: Context, next: Next) => Promise<void | Response>;
42
- honoApp: Hono;
43
- swaggerRegistry: SwaggerRegistry;
44
- tenantManager: TenantManager;
45
- shutdown: () => Promise<void>;
46
- }
47
- /**
48
- * Cria uma instância do Zeti App
49
- *
50
- * @template TPrisma - Tipo do PrismaClient do projeto do usuário
51
- * @template TUser - Tipo do usuário autenticado (opcional)
52
- *
53
- * @example
54
- * ```typescript
55
- * import { PrismaClient } from '@prisma/client';
56
- *
57
- * const app = createZetiApp<PrismaClient>({
58
- * config,
59
- * prismaClient: PrismaClient,
60
- * });
61
- *
62
- * // Agora todas as rotas terão db tipado como PrismaClient do usuário
63
- * app.get('/users', {
64
- * route: async ({ db }) => {
65
- * // db é tipado como PrismaClient do usuário
66
- * // Com todos os modelos do schema.prisma
67
- * const users = await db.user.findMany();
68
- * return { data: users };
69
- * },
70
- * });
71
- * ```
72
- */
73
- declare function createZetiApp<TPrisma = any, TUser = any>(options: {
74
- config: ZetiConfigInternal;
75
- prismaClient: new (...args: any[]) => TPrisma;
76
- }): ZetiApp<TPrisma, TUser>;
77
- declare function initializeZetiApp<TPrisma = any, TUser = any>(options: {
78
- config: ZetiConfigInternal;
79
- prismaClient: new (...args: any[]) => TPrisma;
80
- }): ZetiApp<TPrisma, TUser>;
81
- declare function getZetiApp(): ZetiApp<any, any> | null;
82
- declare function getZetiAppTyped<TPrisma = any, TUser = any>(): ZetiApp<TPrisma, TUser>;
83
- declare function autoInitializeZetiApp<TPrisma = any, TUser = any>(options?: {
84
- configPath?: string;
85
- prismaClient?: new (...args: any[]) => TPrisma;
86
- }): Promise<ZetiApp<TPrisma, TUser> | null>;
87
- declare const honoRoutesZeti: Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
88
-
89
- /**
90
- * Função para obter conexão do banco
91
- * Para multi-tenant, recebe o tenantId e retorna o banco do tenant
92
- */
93
- type GetDbFn = (tenantId?: string) => any | Promise<any>;
94
- /**
95
- * Instância de um Worker em execução
96
- */
97
- declare class WorkerInstance {
98
- private name;
99
- private config;
100
- private intervalId;
101
- private isRunning;
102
- private isProcessing;
103
- private isStopping;
104
- private getDb;
105
- private getTenants?;
106
- private executionCount;
107
- private startedAt;
108
- constructor(name: string, config: WorkerConfig, getDb: GetDbFn, getTenants?: () => string[]);
109
- start(): void;
110
- /**
111
- * Para o worker de forma graciosa, aguardando execução atual terminar
112
- */
113
- stop(): Promise<void>;
114
- /**
115
- * Verifica se está processando
116
- */
117
- getIsProcessing(): boolean;
118
- private run;
119
- }
120
- /**
121
- * Gerenciador de Workers com Graceful Shutdown
122
- */
123
- declare class WorkerManager {
124
- private workers;
125
- private isShuttingDown;
126
- constructor();
127
- /**
128
- * Configura listeners para sinais de shutdown
129
- */
130
- private setupGracefulShutdown;
131
- startAll(workersConfig: Record<string, WorkerConfig>, getDb: GetDbFn, getTenants?: () => string[]): void;
132
- /**
133
- * Para todos os workers de forma graciosa
134
- */
135
- stopAll(): Promise<void>;
136
- /**
137
- * Para um worker específico
138
- */
139
- stop(name: string): Promise<void>;
140
- getActiveWorkers(): string[];
141
- /**
142
- * Verifica se algum worker está processando
143
- */
144
- hasActiveProcessing(): boolean;
145
- }
146
-
147
- interface StartZetiOptions<TPrisma = any, TUser = any> {
148
- config: ZetiConfigInternal;
149
- prisma?: ZetiPrismaConnectionConfig<TPrisma>;
150
- redis?: RedisConfig;
151
- port?: number;
152
- registryPath?: string;
153
- onReady?: (app: ZetiApp<TPrisma, TUser>) => void | Promise<void>;
154
- }
155
- declare function startZeti<TPrisma = any, TUser = any>(options: StartZetiOptions<TPrisma, TUser>): Promise<ZetiApp<TPrisma, TUser>>;
156
- declare function getPrismaClient<TPrisma = any>(tenantId?: string): TPrisma;
157
- declare function createAppProxy<TPrisma = any, TUser = any>(): ZetiApp<TPrisma, TUser>;
158
- declare function getPrismaConnectionConfig(): ZetiPrismaConnectionConfig | null;
159
- declare function getWorkerManager(): WorkerManager | null;
160
- declare function stopAllWorkers(): void;
161
- declare function getRedis(): Redis;
162
- declare function hasRedis(): boolean;
163
- declare function getRedisConfiguration(): RedisConfig | null;
164
- declare function shutdownZeti(): Promise<void>;
165
-
166
- declare function badRequestError(message: string, cause?: any): never;
167
- declare function unauthorizedError(message: string, cause?: any): never;
168
- declare function forbiddenError(message: string, cause?: any): never;
169
- declare function notFoundError(message: string, cause?: any): never;
170
- declare function conflictError(message: string, cause?: any): never;
171
- declare function goneError(message: string, cause?: any): never;
172
- declare function unprocessableEntityError(message: string, cause?: any): never;
173
- declare function internalServerError(message: string, cause?: any): never;
174
-
175
- declare function loadEnv(): void;
176
- /**
177
- * Retorna o valor de uma variável de ambiente.
178
- *
179
- * @param key - Nome da variável de ambiente
180
- * @param fallback - Valor padrão se a variável não existir (padrão: undefined = obrigatório)
181
- * @returns O valor da variável ou o fallback
182
- * @throws Error se a variável não existir e não houver fallback
183
- *
184
- * @example
185
- * ```typescript
186
- * // Obrigatório - lança erro se não existir
187
- * const dbUrl = env("DATABASE_URL");
188
- *
189
- * // Opcional - retorna fallback
190
- * const port = env("PORT", "3000");
191
- * ```
192
- */
193
- declare function env(key: string, fallback?: string): string;
194
-
195
- /**
196
- * Symbol usado para identificar schemas de arquivo
197
- */
198
- declare const FILE_SCHEMA_SYMBOL: unique symbol;
199
- /**
200
- * Cria um schema Zod para upload de arquivo
201
- *
202
- * @example
203
- * ```typescript
204
- * app.post("/upload", {
205
- * middleware: {
206
- * schema: (zod) => ({
207
- * formData: zod.object({
208
- * file: zFile(),
209
- * avatar: zFile("Foto de perfil"),
210
- * documents: zFiles("Documentos PDF"),
211
- * }),
212
- * }),
213
- * },
214
- * route: async ({ formData }) => {
215
- * const file = formData.file as File;
216
- * // ...
217
- * },
218
- * });
219
- * ```
220
- */
221
- declare function zFile(description?: string): z.ZodAny;
222
- /**
223
- * Cria um schema Zod para upload de múltiplos arquivos
224
- */
225
- declare function zFiles(description?: string): z.ZodArray<z.ZodAny, "many">;
226
- /**
227
- * Verifica se um schema Zod é um schema de arquivo
228
- */
229
- declare function isFileSchema(schema: z.ZodTypeAny): boolean;
230
- /**
231
- * Verifica se um schema Zod é um schema de múltiplos arquivos
232
- */
233
- declare function isMultipleFileSchema(schema: z.ZodTypeAny): boolean;
234
-
235
- /**
236
- * Cria middleware que resolve o banco de dados e coloca no contexto.
237
- *
238
- * Este middleware usa o TenantManager.getContextualClient() para:
239
- * 1. Resolver a URL do banco (single ou dynamic)
240
- * 2. Aplicar $extends com filtro de tenantId (se aplicável)
241
- * 3. Colocar o cliente no contexto via c.set('db', client)
242
- *
243
- * @param tenantManager - Instância do TenantManager
244
- * @returns Middleware do Hono
245
- *
246
- * @example
247
- * ```typescript
248
- * // No framework.ts
249
- * const dbMiddleware = createDatabaseMiddleware(tenantManager);
250
- * honoApp.use('*', dbMiddleware);
251
- *
252
- * // Nas rotas
253
- * app.get('/users', {
254
- * route: async ({ db }) => {
255
- * // db já vem com filtro de tenant aplicado
256
- * const users = await db.user.findMany();
257
- * return { data: users };
258
- * },
259
- * });
260
- * ```
261
- */
262
- declare function createDatabaseMiddleware(tenantManager: TenantManager): (c: Context, next: Next) => Promise<void>;
263
- /**
264
- * Tipo do contexto com db disponível.
265
- * Útil para tipar middlewares customizados.
266
- */
267
- interface DatabaseContext {
268
- db: any;
269
- }
270
- /**
271
- * Helper para obter db do contexto de forma tipada.
272
- *
273
- * @example
274
- * ```typescript
275
- * const db = getDbFromContext<PrismaClient>(c);
276
- * const users = await db.user.findMany();
277
- * ```
278
- */
279
- declare function getDbFromContext<TPrisma = any>(c: Context): TPrisma;
280
-
281
- export { type DatabaseContext, FILE_SCHEMA_SYMBOL, RedisConfig, SchemaDefinition, type StartZetiOptions, SwaggerRegistry, TenantManager, WorkerConfig, WorkerInstance, WorkerManager, type ZetiApp, ZetiConfigInternal, ZetiMethodOptions, type ZetiMiddlewareHandler, ZetiPrismaConnectionConfig, autoInitializeZetiApp, badRequestError, conflictError, createAppProxy, createDatabaseMiddleware, createZetiApp, env, forbiddenError, getDbFromContext, getPrismaClient, getPrismaConnectionConfig, getRedis, getRedisConfiguration, getWorkerManager, getZetiApp, getZetiAppTyped, goneError, hasRedis, honoRoutesZeti, initializeZetiApp, internalServerError, isFileSchema, isMultipleFileSchema, loadEnv, notFoundError, shutdownZeti, startZeti, stopAllWorkers, unauthorizedError, unprocessableEntityError, zFile, zFiles };
@@ -1,59 +0,0 @@
1
- import { a as ZetiConfigInternal } from '../config-VWgz0Iq_.js';
2
- import 'hono';
3
- import 'ioredis';
4
- import 'hono/http-exception';
5
-
6
- interface PrismaConfigOptions {
7
- /** Caminho do schema. Default: "prisma/schema.prisma" */
8
- schema?: string;
9
- /** Caminho das migrations. Default: "prisma/migrations" */
10
- migrationsPath?: string;
11
- }
12
- interface PrismaDefineConfig {
13
- schema: string;
14
- migrations: {
15
- path: string;
16
- };
17
- datasource: {
18
- url: string;
19
- };
20
- }
21
- /**
22
- * Gera a configuração do Prisma.
23
- *
24
- * Aceita opcionalmente um ZetiConfig, mas NÃO É NECESSÁRIO passá-lo.
25
- * A função busca automaticamente a URL do banco no .env.
26
- *
27
- * @example Uso simples (recomendado para evitar importar zeti.config.ts)
28
- * ```typescript
29
- * // prisma.config.ts
30
- * import { definePrismaConfig } from "zeti-framework";
31
- *
32
- * export default definePrismaConfig();
33
- * ```
34
- *
35
- * @example Uso com config (opcional)
36
- * ```typescript
37
- * // prisma.config.ts
38
- * import { zetiConfig } from "./zeti.config";
39
- * import { definePrismaConfig } from "zeti-framework";
40
- *
41
- * export default definePrismaConfig(zetiConfig);
42
- * ```
43
- */
44
- declare function definePrismaConfig(zetiConfigOrOptions?: ZetiConfigInternal | PrismaConfigOptions, options?: PrismaConfigOptions): PrismaDefineConfig;
45
- /**
46
- * Retorna todas as URLs de banco de dados configuradas (para multi-tenant migrations).
47
- *
48
- * @example
49
- * ```typescript
50
- * const urls = getAllDatabaseUrls(zetiConfig);
51
- * for (const [name, url] of Object.entries(urls)) {
52
- * console.log(`Migrating ${name}...`);
53
- * // executar migration para cada tenant
54
- * }
55
- * ```
56
- */
57
- declare function getAllDatabaseUrls(zetiConfig: ZetiConfigInternal): Record<string, string>;
58
-
59
- export { type PrismaConfigOptions, definePrismaConfig, getAllDatabaseUrls };
@@ -1,34 +0,0 @@
1
- import { a as ZetiConfigInternal } from '../config-VWgz0Iq_.js';
2
- import 'hono';
3
- import 'ioredis';
4
- import 'hono/http-exception';
5
-
6
- interface GenerateRegistryOptions {
7
- controllersPath: string;
8
- indexPath: string;
9
- startMarker?: string;
10
- endMarker?: string;
11
- /** Se true, escreve apenas os imports no arquivo (para .zeti/registry.ts) */
12
- outputMode?: 'inject' | 'standalone';
13
- }
14
- declare function generateRegistry(options: GenerateRegistryOptions): Promise<void>;
15
-
16
- interface GenerateSwaggerTypesOptions {
17
- controllersPath: string;
18
- outputPath: string;
19
- }
20
- declare function generateSwaggerTypes(options: GenerateSwaggerTypesOptions): Promise<void>;
21
-
22
- interface RunPrebuildOptions {
23
- projectRoot?: string;
24
- zetiConfig?: ZetiConfigInternal;
25
- controllersPath?: string;
26
- registryPath?: string;
27
- swaggerOutputPath?: string;
28
- prismaImport?: string;
29
- /** Forçar regeneração mesmo se não houver mudanças */
30
- force?: boolean;
31
- }
32
- declare function runPrebuild(options?: RunPrebuildOptions): Promise<void>;
33
-
34
- export { type GenerateRegistryOptions, type GenerateSwaggerTypesOptions, type RunPrebuildOptions, generateRegistry, generateSwaggerTypes, runPrebuild };
@@ -1,10 +0,0 @@
1
- export { S as SwaggerGeneratorOptions, a as SwaggerRegistry, g as generateSwagger } from '../generator-CK-ZmWQj.js';
2
- import { ZodTypeAny } from 'zod';
3
- import 'hono';
4
- import '../config-VWgz0Iq_.js';
5
- import 'ioredis';
6
- import 'hono/http-exception';
7
-
8
- declare function zodToJsonSchema(schema: ZodTypeAny): any;
9
-
10
- export { zodToJsonSchema };