/** * Next.js App Router projection for Manifest IR. * * Generates Next.js API route handlers using App Router conventions. * Configurable for different auth providers and database setups. */ import type { IR } from '../../ir'; import type { ProjectionRequest, ProjectionResult, ProjectionTarget } from '../interface'; export type { NextJsProjectionOptions, ProjectionArtifact, ProjectionDiagnostic, ProjectionRequest, ProjectionResult, ProjectionTarget, } from '../interface'; /** * Re-export the canonical defaults so consumers of * `@angriff36/manifest/projections/nextjs` get the defaults from the same * entry point as the projection class. Anything that needs to render or * snapshot the defaults (CLI inspect, tests, downstream tooling) must use * these names, not redeclare them. */ export { CONCRETE_COMMAND_ROUTES_DEFAULTS, DEFAULT_TENANT_PROVIDER, DISPATCHER_DEFAULTS, getManifestDefaultsSnapshot, type ManifestDefaultsSnapshot, NEXTJS_DEFAULTS, READ_ROUTES_DEFAULTS, ROUTES_DEFAULTS, } from './defaults.js'; /** * Next.js projection implementation. */ export declare class NextJsProjection implements ProjectionTarget { readonly name = "nextjs"; readonly description = "Next.js App Router API routes with configurable auth and database support"; readonly surfaces: readonly ["nextjs.route", "nextjs.detail", "nextjs.command", "nextjs.dispatcher", "nextjs.subscribe", "nextjs.subscriptionHook", "nextjs.sharedRuntime", "nextjs.schedule", "nextjs.webhook", "nextjs.companions", "ts.types", "ts.client"]; readonly descriptorMeta: import("..").ProjectionDescriptorMeta; generate(ir: IR, request: ProjectionRequest): ProjectionResult; private _route; private _types; /** * Generate the plain-TypeScript client SDK: typed list/detail read callers and * typed command callers. Every URL comes from the shared route contract (so it * tracks appDir/routeSegments/routeCasing and can never desync from the emitted * routes) and every envelope key comes from the same helper the server routes * use. Command callers POST the canonical dispatcher at its RAW entity/command * path and return the dispatcher's response envelope. */ private _client; private _command; /** * Generate POST command handler for an entity command. * Writes MUST flow through runtime.runCommand() to enforce guards, policies, and constraints. */ private _generatePostCommandHandler; /** * Generate the canonical dispatcher route. Single dynamic file at * /manifest/[entity]/commands/[command]/route.ts * Resolves entity+command at request time and delegates to * RuntimeEngine.runCommand. Single canonical write path for governed * mutations; downstream integrations may add aliases or CI gates. */ private _dispatcher; private _generateDispatcherHandler; /** * Generate the SSE subscription route for a realtime entity. * GET //subscribe/route.ts — streams runtime events whose * subject.entity matches, over the shared singleton engine. */ private _subscribe; /** * Generate a typed client-side EventSource hook for a realtime entity, * with exponential-backoff reconnect. */ private _subscriptionHook; /** * Generate the module-scoped singleton runtime accessor. Emitted only when * the IR contains at least one realtime entity — SSE routes and command * routes must share ONE engine instance for subscriptions to observe * command events (the event stream is per-engine and in-memory). */ private _sharedRuntime; /** * Generate the companion modules that generated route/dispatcher code * imports but no other surface writes: the runtime factory, the HTTP * envelope helpers, the Prisma client, an auth stub, and a tenant lookup. * Each lands at the pathHint derived from its CONFIGURED import path — so a * custom `responseImportPath: '@/shared/rsp'` places the module at * 'shared/rsp.ts'. A companion whose import path is a package specifier is * skipped (never emitted at a colliding wrong path) — that module is the * user's. When `emitCompanions` is false, nothing is emitted. */ private _companions; /** * Resolve which auth symbol/import the generated routes expect and whether it * points at a local module worth stubbing. Mirrors `generateAuthImport`: * clerk/next-auth default to package imports (returned here, but skipped * downstream because their path is a package); 'custom' points at an app * module; 'none' imports nothing. */ private _authCompanionSpec; /** Canonical HTTP envelope module (next/server NextResponse). */ private _companionResponseModule; /** Prisma client singleton (standard globalThis dev-reuse pattern). */ private _companionDatabaseModule; /** * Fail-closed auth stub. Compiles (correct types so routes type-check) but * throws at runtime with a "wire your auth provider" message so unfinished * auth never silently allows access. */ private _companionAuthStub; /** * Tenant lookup helper. Implements the `userTenantMapping` lookup the * generated tenant filtering assumes, via the database companion, and throws * a clear error when that delegate is absent so the assumption is explicit. */ private _companionTenantModule; /** * Generate detail (getById) route handler for an entity. * Uses direct Prisma findUnique (bypassing runtime) for efficiency. */ private _detail; /** * Generate GET route for an entity. * Uses direct Prisma query (bypassing runtime) for efficiency. */ private _generateGetRoute; /** * Generate GET detail route for a single entity instance. * Uses direct Prisma findUnique (bypassing runtime) for efficiency. */ private _generateDetailRoute; } //# sourceMappingURL=generator.d.ts.map