import { ContractBuilder } from "./contract-builder.js"; import { type ContractDeprecationMeta } from "./lifecycle.js"; import type { ContractErrorResponses, ContractHeaderSchemas, ContractMeta, ContractResponses, MergeContractMeta, MergedContractErrorResponses, OmitMetaKeys, ResponsesFromErrorDefinitions, StandardSchema } from "./types.js"; type TrimLeadingSlash = T extends `/${infer Rest}` ? TrimLeadingSlash : T; type TrimTrailingSlash = T extends "/" ? "" : T extends `${infer Rest}/` ? TrimTrailingSlash : T; type NormalizedPrefix = T extends "" | "/" ? "" : TrimTrailingSlash; type NormalizedChildPath = TrimTrailingSlash>; type JoinPaths = string extends TPrefix | TPath ? string : NormalizedPrefix extends "" ? TPath : NormalizedChildPath extends "" ? NormalizedPrefix : `${NormalizedPrefix}/${NormalizedChildPath}`; /** * Feature-scoped factory for related HTTP contracts. * * Contract groups let a feature share a namespace, path prefix, headers, * responses, errors, and metadata across multiple endpoint contracts. The group * is immutable: every configuration method returns a new group. */ export declare class ContractGroup, TSharedMeta extends ContractMeta = ContractMeta, TSharedHeaders extends ContractHeaderSchemas = null, TPathPrefix extends string = ""> { private readonly _namespace; private readonly _meta; private readonly _responses; private readonly _headers; private readonly _pathPrefix; constructor(state?: { namespace?: string; meta?: TSharedMeta; responses?: TSharedResponses; headers?: TSharedHeaders; pathPrefix?: TPathPrefix; }); /** * Set the namespace for contracts created from this group. * * The namespace prefixes contract names, not paths. Use `prefix(...)` for * path composition. */ namespace(ns: string): ContractGroup; /** * Add a path prefix to contracts created from this group. * * Prefixes compose immutably, so `prefix("/api").prefix("/v1")` produces * paths under `/api/v1`. */ prefix(pathPrefix: TNewPrefix): ContractGroup>; /** * Merge shared metadata into contracts created from this group. */ meta(meta: TNewMeta): ContractGroup, TSharedHeaders, TPathPrefix>; /** * Mark every contract created from this group as deprecated. */ deprecated(deprecation: TDeprecation): ContractGroup, TSharedHeaders, TPathPrefix>; /** * Add shared route-owned response schemas to contracts created from this group. * * Framework-owned responses, such as validation or auth hook failures, do not * need to be declared here. */ responses(responseSchemas: TNewResponses): ContractGroup & TNewResponses, TSharedMeta, TSharedHeaders, TPathPrefix>; /** * Declare shared route-owned application errors for contracts in this group. * * Catalog errors use Beignet's standard error envelope and remain separate * from framework-owned errors. Declarations merge with previously declared * group errors, and contracts created from the group merge these shared * errors with route-level `.errors()` declarations; later declarations win * when the same catalog key is declared twice. */ errors(errorDefs: TErrorDefs): ContractGroup> & ResponsesFromErrorDefinitions, OmitMetaKeys & { errors: MergedContractErrorResponses; }, TSharedHeaders, TPathPrefix>; /** * Add a shared request header schema to contracts created from this group. */ headers(schema: TNewHeaders): ContractGroup; /** * Create a GET contract under this group. */ get(path: TPath, name?: string): ContractBuilder<"GET", null, null, null, TSharedHeaders, TSharedResponses, TSharedMeta, JoinPaths>; /** * Create a POST contract under this group. */ post(path: TPath, name?: string): ContractBuilder<"POST", null, null, null, TSharedHeaders, TSharedResponses, TSharedMeta, JoinPaths>; /** * Create a PUT contract under this group. */ put(path: TPath, name?: string): ContractBuilder<"PUT", null, null, null, TSharedHeaders, TSharedResponses, TSharedMeta, JoinPaths>; /** * Create a PATCH contract under this group. */ patch(path: TPath, name?: string): ContractBuilder<"PATCH", null, null, null, TSharedHeaders, TSharedResponses, TSharedMeta, JoinPaths>; /** * Create a DELETE contract under this group. */ delete(path: TPath, name?: string): ContractBuilder<"DELETE", null, null, null, TSharedHeaders, TSharedResponses, TSharedMeta, JoinPaths>; /** * Create a HEAD contract under this group. */ head(path: TPath, name?: string): ContractBuilder<"HEAD", null, null, null, TSharedHeaders, TSharedResponses, TSharedMeta, JoinPaths>; /** * Create an OPTIONS contract under this group. */ options(path: TPath, name?: string): ContractBuilder<"OPTIONS", null, null, null, TSharedHeaders, TSharedResponses, TSharedMeta, JoinPaths>; /** * Internal helper to create a contract builder with shared config */ private createBuilder; } /** * Create a new feature contract group. * * Start here for most feature HTTP surfaces, then add a namespace and path * prefix before defining individual contracts. * * @example * ```ts * const todos = defineContractGroup() * .namespace("todos") * .prefix("/api/todos") * .meta({ auth: "required" }) * .responses({ * 401: z.object({ message: z.literal("Unauthorized") }), * }); * * const getTodo = todos.get("/:id")... * ``` * * @returns An empty immutable contract group. */ export declare function defineContractGroup(): ContractGroup, ContractMeta, null, "">; export {}; //# sourceMappingURL=contract-group.d.ts.map