import * as Generator from '@postxl/generator';
import { FieldDiscriminatedUnion, FieldName } from '@postxl/schema';
import { WithBackend } from '../backend-core';
import { WithBase } from '../base';
import { WithTypes } from '../types';
export type ContextRequirements = WithTypes<WithBackend<WithBase<Generator.Context>>>;
export type ContextResult = WithDecoders<ContextRequirements>;
export type ModelContextRequirements = Generator.InferModelContext<ContextRequirements>;
export type ModelResult = Generator.InferModelContext<ContextResult>;
export type EnumContextRequirements = Generator.InferEnumContext<ContextRequirements>;
export type EnumResult = Generator.InferEnumContext<ContextResult>;
export type WithDecoders<Context> = Generator.ExtendContextAndModelAndEnum<Context, {
    decoders: ContextDecoders;
}, {
    decoder: ModelContextDecoders;
}, {
    decoder: EnumContextDecoders;
}>;
export type ContextDecoders = {
    /**
     * Location of the decoders module (e.g. `@decoders`)
     *
     * Note: We do not provide a NestJS module for decoders - instead, all decoders are exposed directly as index.ts exports.
     */
    location: Generator.BackendModuleLocation;
    /**
     * The codec that encodes/decodes the data model to a flattened version
     */
    dataModel: CodecDefinition<DecoderWithoutTransformer>;
    /**
     * The codec that encodes/decodes the data model to a flattened version for Excel
     */
    excelDataModel: CodecDefinition<DecoderWithoutTransformer>;
};
export type ModelContextDecoders = DecoderDefinition<DecoderWithTransformer, DecoderWithTransformer> & {
    discriminatedUnions: Map<FieldName, DiscriminatedUnionDecoderDefinition>;
    /**
     * Name of the data model property for the model
     */
    dataModelEntry: string;
};
export type DiscriminatedUnionDecoderDefinition = DecoderDefinition<DecoderWithoutTransformer, DecoderWithTransformer> & {
    field: FieldDiscriminatedUnion;
};
export type EnumContextDecoders = {
    /**
     * The decoder that checks that the input is a valid enum
     */
    decoder: DecoderWithTransformer;
    /**
     * Function that encodes an enum. Currently this is returning the same value as the input.
     */
    encoder: Generator.ImportableFunction;
};
export type DecoderDefinition<DecoderType extends Decoder, FlattenedDecoderType extends Decoder> = {
    /**
     * The default decoder that checks that the input is a valid model
     */
    decoder: DecoderType;
    /**
     * Type, decoder and encoder for the flattened model. The flattened model is the model converted
     * to a column structure (e.g. database, CSV), i.e. nested properties are flattened to a single level.
     *
     * Difference to the excel model is that the flattened version uses snake_case for the keys while Excel uses PascalCase.
     */
    flattened: CodecDefinition<FlattenedDecoderType>;
    /**
     * Type, decoder and encoder for the flattened Excel model. The flattened model is the model converted
     * to a column structure for Excel, i.e. nested properties are flattened to a single level.
     *
     * Difference to the flattened model is that the Excel version uses PascalCase for the keys while the flattened version uses snake_case.
     */
    excel: CodecDefinition<FlattenedDecoderType>;
};
export type Decoder = DecoderWithoutTransformer | DecoderWithTransformer;
type DecoderBase = {
    /**
     * The Zod decoder for the model
     * Typically applies the rawInputValidation and the transformer
     */
    zodDecoder: Generator.ImportableConstant;
    /**
     * The decoder function that parses any input with the Zod decoder and returns a model
     */
    parseFunction: Generator.ImportableFunction;
};
type DecoderWithoutTransformer = DecoderBase & {
    /**
     * The discriminator
     */
    hasTransformer: false;
};
export type DecoderWithTransformer = DecoderBase & {
    /**
     * The discriminator
     */
    hasTransformer: true;
    /**
     * A Zod decoder that checks the raw input format and does simple type transformations, e.g. convert string to brands
     */
    rawInputValidation: Generator.ImportableConstant;
    /**
     * The intermediate type that is the result of the rawInputValidation and the input for the transformer
     *
     * We expose it as it can be useful when composing more complex decoders
     */
    rawInputType: Generator.ImportableType;
    /**
     * A Zod decoder that transforms the raw input to the model/discriminated union type
     */
    transformer: Generator.ImportableFunction;
};
export type CodecDefinition<DecoderType extends Decoder> = {
    /**
     * The type that is generated by the decoder and expected by the encoder
     */
    decodedType: Generator.ImportableType;
    /**
     * The type that is generated by the encoder and expected by the decoder
     */
    encodedType: Generator.ImportableType;
    /**
     * The decoder that decodes the codec type back to the original model
     */
    decoder: DecoderType;
    /**
     * The function that takes a model and encodes it to the codec type
     */
    encoder: Generator.ImportableFunction;
};
export declare const generatorId: string & import("zod").$brand<"PXL.GeneratorInterfaceId">;
export declare const generator: Generator.GeneratorInterface;
export {};
