import type * as FunctionSpec from "@confect/core/FunctionSpec"; import type * as GroupSpec from "@confect/core/GroupSpec"; import type * as Spec from "@confect/core/Spec"; import type { Layer, Types } from "effect"; import type * as DatabaseSchema from "./DatabaseSchema"; import type * as GroupImpl from "./GroupImpl"; import type * as RegisteredFunction from "./RegisteredFunction"; export type RegisteredFunctions = Types.Simplify>>; type RegisteredFunctionsHelper = { [GroupName in GroupSpec.Name]: GroupSpec.WithName extends infer Group extends GroupSpec.AnyWithProps ? RegisteredFunctionsForGroupSpec : never; }; /** * The `RegisteredFunction` record for a group's own declared functions. */ type RegisteredFunctionsOf = { [FunctionName in FunctionSpec.Name>]: FunctionSpec.WithName, FunctionName> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? RegisteredFunction.RegisteredFunction : never; }; /** * The registered-functions record for a single group, derived from the group's * own `GroupSpec`: its declared functions, plus any nested subgroups it carries * directly. This is the node that `buildForGroup` returns—computed from the * leaf `GroupSpec` itself rather than by navigating the project-wide assembled * `Spec` to a dot-path, so the per-group registry's type depends only on its * own leaf. For the filesystem layout a leaf `GroupSpec` carries no subgroups * (subdirectory children are assembled separately into `_generated/spec.ts`), * so this resolves to just the leaf's functions. */ export type RegisteredFunctionsForGroupSpec = GroupSpec.Groups extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify & RegisteredFunctionsOf> : RegisteredFunctionsOf; export interface AnyWithProps { readonly [key: string]: RegisteredFunction.Any | AnyWithProps; } /** * Build the registered Convex functions for a single group from its finalized * `GroupImpl` layer. * * The `groupLayer` parameter requires `GroupImpl<"Finalized">`, so impls that * were never piped through `GroupImpl.finalize` (and impls with unmet * `FunctionImpl` requirements, which cannot be finalized) are rejected at the * codegen boundary, not just deep inside Convex at runtime. * * The group layer is built with a fresh, isolated `Registry` (rather than the * globally-cached default `Context.Reference`), so each `FunctionImpl.make` * registers under its flat, single-segment function-name key without colliding * with any other group built in the same process—the built registry holds * exactly this group's functions at the top level. * * Only the runtime `databaseSchema` value is needed at runtime (it is forwarded * to isolate registration to build each function's ctx services); the group's * `GroupSpec` is supplied purely as the `Group` type parameter to shape the * returned record. Generated isolate modules instead prepare definitions with * `ConvexFunctionDefinitions.buildForGroup` and add local forwarding handlers * before shared registration. Node groups use * `RegisteredNodeFunction.buildForGroup` from the Node entry. */ export declare const buildForGroup: (databaseSchema: DatabaseSchema.AnyWithProps, groupLayer: Layer.Layer>) => RegisteredFunctionsForGroupSpec; export {}; //# sourceMappingURL=RegisteredFunctions.d.ts.map