import { i as Response, n as LogConfig, r as RequestContext, t as ApiHandler } from "./types-6NFtxov5.mjs"; import { QueryOptions } from "@zenstackhq/orm"; import { SchemaDef } from "@zenstackhq/orm/schema"; import * as _$openapi_types0 from "openapi-types"; import { OpenAPIV3_1 } from "openapi-types"; //#region src/api/common/types.d.ts type CommonHandlerOptions = { /** Query options that affect the behavior of the OpenAPI provider. */queryOptions?: QueryOptions; }; type OpenApiSpecOptions = { /** Spec title. Defaults to 'ZenStack Generated API' */title?: string; /** Spec version. Defaults to '1.0.0' */ version?: string; /** Spec description. */ description?: string; /** Spec summary. */ summary?: string; /** * When true, assumes that the schema includes access policies, and adds * 403 responses to operations that can potentially be rejected. */ respectAccessPolicies?: boolean; }; /** * Interface for generating OpenAPI specifications. */ interface OpenApiSpecGenerator { /** * Generates an OpenAPI v3.1 specification document. */ generateSpec(options?: OpenApiSpecOptions): Promise; } //#endregion //#region src/api/rest/index.d.ts /** * Options for {@link RestApiHandler} */ type RestApiHandlerOptions = { /** * The schema */ schema: Schema; /** * Logging configuration */ log?: LogConfig; /** * The base endpoint of the RESTful API, must be a valid URL */ endpoint: string; /** * The default page size for limiting the number of results returned * from collection queries, including resource collection, related data * of collection types, and relationship of collection types. * * Defaults to 100. Set to Infinity to disable pagination. */ pageSize?: number; /** * The divider used to separate compound ID fields in the URL. * Defaults to '_'. */ idDivider?: string; /** * The charset used for URL segment values. Defaults to `a-zA-Z0-9-_~ %`. You can change it if your entity's ID values * allow different characters. Specifically, if your models use compound IDs and the idDivider is set to a different value, * it should be included in the charset. */ urlSegmentCharset?: string; /** * Mapping from model names to URL segment names. */ modelNameMapping?: Record; /** * Mapping from model names to unique field name to be used as resource's ID. */ externalIdMapping?: Record; /** * When `true`, enables nested route handling for all to-many relations: * `/:parentType/:parentId/:relationName` (collection) and * `/:parentType/:parentId/:relationName/:childId` (single). * * Defaults to `false`. */ nestedRoutes?: boolean; } & CommonHandlerOptions; /** * RESTful-style API request handler (compliant with JSON:API) */ declare class RestApiHandler implements ApiHandler, OpenApiSpecGenerator { private readonly options; private serializers; private readonly errors; private filterParamPattern; private createUpdatePayloadSchema; private updateSingleRelationSchema; private updateCollectionRelationSchema; private upsertMetaSchema; private typeMap; private idDivider; private urlPatternMap; private modelNameMapping; private reverseModelNameMapping; private externalIdMapping; private nestedRoutes; constructor(options: RestApiHandlerOptions); private validateOptions; get schema(): Schema; get log(): LogConfig | undefined; private buildUrlPatternMap; private mapModelName; /** * Resolves child model type and reverse relation from a parent relation name. * e.g. given parentType='user', parentRelation='posts', returns { childType:'post', reverseRelation:'author' } */ private resolveNestedRelation; private mergeFilters; /** * Builds a WHERE filter for the child model that constrains results to those belonging to the given parent. * @param parentType lowercased parent model name * @param parentId parent resource ID string * @param parentRelation relation field name on the parent model (e.g. 'posts') */ private buildNestedParentFilter; private matchUrlPattern; handleRequest({ client, method, path, query, requestBody }: RequestContext): Promise; private handleGenericError; private processProcedureRequest; private makeProcBadInputErrorResponse; private makeProcGenericErrorResponse; /** * Builds the ORM `args` object (include, select) shared by single-read operations. * Returns the args to pass to findUnique/findFirst and the resolved `include` list for serialization, * or an error response if query params are invalid. */ private buildSingleReadArgs; private processSingleRead; private processFetchRelated; private processReadRelationship; private processCollectionRead; /** * Builds link URL for a nested resource using parent type, parent ID, relation name, and optional child ID. * Uses the parent model name mapping for the parent segment; the relation name is used as-is. */ private makeNestedLinkUrl; private processNestedSingleRead; private processNestedCreate; /** * Builds the ORM `data` payload for a nested update, shared by both to-many (childId present) * and to-one (childId absent) variants. Returns either `{ updateData }` or `{ error }`. */ private buildNestedUpdatePayload; /** * Handles PATCH /:type/:id/:relationship/:childId (to-many) and * PATCH /:type/:id/:relationship (to-one, childId undefined). */ private processNestedUpdate; private processNestedDelete; private buildPartialSelect; private addTotalCountToMeta; private makePaginator; private processRequestBody; private processCreate; private processUpsert; private getUniqueFieldSets; private processRelationshipCRUD; private processUpdate; private processDelete; private requireModel; private getIdFields; private requireField; private buildTypeMap; private getModelInfo; private makeLinkUrl; private buildSerializers; private getId; private serializeItems; private injectCompoundId; private toPlainObject; private replaceURLSearchParams; private makeIdFilter; private makeIdSelect; private makeIdConnect; private makeIdKey; private makeDefaultIdKey; private makeCompoundId; private makeUpsertWhere; private includeRelationshipIds; private coerce; private makeNormalizedUrl; private getPagination; private buildFilter; private buildSort; private buildRelationSelect; private makeFilterValue; private injectRelationQuery; private handleORMError; private makeError; private makeUnsupportedModelError; private makeUnsupportedRelationshipError; generateSpec(options?: OpenApiSpecOptions): Promise<_$openapi_types0.OpenAPIV3_1.Document<{}>>; } //#endregion //#region src/api/rpc/index.d.ts /** * Options for {@link RPCApiHandler} */ type RPCApiHandlerOptions = { /** * The schema */ schema: Schema; /** * Logging configuration */ log?: LogConfig; } & CommonHandlerOptions; /** * RPC style API request handler that mirrors the ZenStackClient API */ declare class RPCApiHandler implements ApiHandler, OpenApiSpecGenerator { private readonly options; constructor(options: RPCApiHandlerOptions); private validateOptions; get schema(): Schema; get log(): LogConfig | undefined; handleRequest({ client, method, path, query, requestBody }: RequestContext): Promise; private handleTransaction; private handleProcedureRequest; private isValidModel; private makeBadInputErrorResponse; private makeGenericErrorResponse; private makeORMErrorResponse; generateSpec(options?: OpenApiSpecOptions): Promise<_$openapi_types0.OpenAPIV3_1.Document<{}>>; private processRequestPayload; } //#endregion export { type OpenApiSpecGenerator, type OpenApiSpecOptions, RPCApiHandler, type RPCApiHandlerOptions, RestApiHandler, type RestApiHandlerOptions }; //# sourceMappingURL=api.d.mts.map