/** * Deployment-local module + extension discovery (consolidated-deployments RFC — * the "20%" extension seams: *custom module* and *custom route on an existing * module*, neither requiring a fork). * * A deployment drops a unit into a conventional directory and it is auto-mounted * — no edit to a framework-owned file, no hand-wiring in the deployment's * composition: * * - `src/modules//index.ts` → a new module (own routes + schema) * - `src/extensions//index.ts` → a {@link ApiExtension} adding routes to * an EXISTING module's surface * * Discovery is **build-time**: the deployment feeds a Vite * `import.meta.glob("./modules/*\/index.ts", { eager: true })` (statically * compiled to static imports — Workers-safe) into {@link modulesFromGlob} / * {@link extensionsFromGlob}, which key each unit by its `` directory * segment. * * // src/api/composition.ts (deployment-owned) * const modules = modulesFromGlob( * import.meta.glob("../modules/*\/index.ts", { eager: true }), * ) * const extensions = extensionsFromGlob( * import.meta.glob("../extensions/*\/index.ts", { eager: true }), * ) * * // src/modules/loyalty/index.ts * export default defineDeploymentModule({ module: { name: "loyalty" }, adminRoutes }) * // src/extensions/booking-notes/index.ts * export default defineDeploymentExtension({ * extension: { module: "bookings" }, adminRoutes, // → /v1/admin/bookings/* * }) * * Schema owned by a custom module/extension (`//schema.ts`) is picked * up by the deployment's drizzle config glob (a *deployment* migration source, * applied after the framework bundle by the D.1 collector). */ import type { ExtensionFactory, ModuleFactory } from "@voyant-travel/hono/composition"; import type { ApiExtension, ApiModule } from "@voyant-travel/hono/module"; /** A deployment module declaration: a ready unit, or a factory that builds one. */ export type DeploymentModuleDeclaration = ApiModule | ApiModule[] | ModuleFactory; /** A deployment extension declaration: a ready unit, or a factory that builds one. */ export type DeploymentExtensionDeclaration = ApiExtension | ExtensionFactory; /** * Normalize a deployment-local module declaration into a {@link ModuleFactory}. * Accepts a ready {@link ApiModule} (or array) or a factory; returns a factory * either way. Use it as the `export default` of a `src/modules//index.ts`. */ export declare function defineDeploymentModule(declaration: DeploymentModuleDeclaration): ModuleFactory; /** * Normalize a deployment-local extension declaration into an * {@link ExtensionFactory}. Accepts a ready {@link ApiExtension} or a factory. * Use it as the `export default` of a `src/extensions//index.ts`. */ export declare function defineDeploymentExtension(declaration: DeploymentExtensionDeclaration): ExtensionFactory; /** A Vite `import.meta.glob(..., { eager: true })` result: path → module namespace. */ export type EagerModuleGlob = Record; /** * Build a deployment-local **module** registry from a Vite `import.meta.glob` * (eager) of `src/modules//index.ts` files. Each entry's `default` export * is a {@link ApiModule} or {@link ModuleFactory} (wrap with * {@link defineDeploymentModule}); the registry key is the `` directory * segment, which becomes the module's composition specifier. * * @throws if a matched file has no default export. */ export declare function modulesFromGlob(glob: EagerModuleGlob): Record>; /** * Build a deployment-local **extension** registry from a Vite `import.meta.glob` * (eager) of `src/extensions//index.ts` files. Each entry's `default` * export is a {@link ApiExtension} or {@link ExtensionFactory} (wrap with * {@link defineDeploymentExtension}); the registry key is the `` directory * segment. * * @throws if a matched file has no default export. */ export declare function extensionsFromGlob(glob: EagerModuleGlob): Record>;