@inaiat/fastify-papr
Version:
Fastify Papr Plugin Integration
1 lines • 1.56 kB
Source Map (JSON)
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Db, IndexDescription } from 'mongodb'\nimport type { BaseSchema, Model, SchemaOptions } from 'papr'\n\n/**\n * Main interface for the fastify-papr plugin\n * Contains all registered models and their connections\n */\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/no-explicit-any\nexport interface FastifyPapr<T extends BaseSchema = any, U extends SchemaOptions<Partial<T>> = any> {\n [key: string]: Model<T, U> | Record<string, Model<T, U>> | undefined\n}\n\n/**\n * Represents a model registration with its schema and optional indexes\n */\nexport type ModelRegistration = {\n /** Collection name in MongoDB */\n name: string\n /** Schema definition pair (schema and options) */\n schema: [BaseSchema, SchemaOptions<Partial<BaseSchema>>]\n /** Optional MongoDB indexes to create */\n indexes?: IndexDescription[]\n}\n\n/**\n * Maps model registrations to FastifyPapr property names\n */\nexport type ModelRegistrationPair<T> = {\n [U in keyof T]: ModelRegistration\n}\n\n/**\n * Configuration options for the fastify-papr plugin\n */\nexport type FastifyPaprOptions = {\n /** Optional name for multiple database support */\n name?: string\n /** MongoDB database instance */\n db: Db\n /** Models to register */\n models: ModelRegistrationPair<FastifyPapr>\n /** Whether to skip schema validation reconciliation */\n disableSchemaReconciliation?: boolean\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}