import { PrismaQlRelationType } from "./field-relation-collector.js"; export type BasePrismaQlDSLAction = "GET" | "ADD" | "DELETE" | "UPDATE" | "PRINT" | "VALIDATE"; export type BasePrismaQLDSLCommand = "MODELS" | "MODEL" | "FIELD" | "FIELDS" | "RELATIONS" | "DB" | "ENUM_RELATIONS" | "ENUMS" | "ENUM" | "MODELS_LIST" | "RELATION" | "GENERATOR" | "GENERATORS"; export type PrismaQlDSLAction = A; export type PrismaQLDSLCommand = C; export type PrismaQlDSLType = "query" | "mutation"; export type PrismaQlDSLMutationAction = "ADD" | "DELETE" | "UPDATE"; export type PrismaQlDSLQueryAction = "GET" | "PRINT" | "VALIDATE"; export type PrismaQLDSLArgs = { models?: string[]; fields?: string[]; enums?: string[]; generators?: string[]; }; export type DSLPrismaRelationType = PrismaQlRelationType; export type PrismaQlDSLOptionMap = { GET: { ENUMS: { raw?: boolean; }; RELATIONS: { depth?: number; }; }; ADD: { RELATION: { type: DSLPrismaRelationType; pivotTable?: string | true; pivotOnly?: boolean; fkHolder?: string; required?: boolean; relationName?: string; pluralName?: string; fkName?: string; refName?: string; }; MODEL: { empty?: boolean; }; }; UPDATE: { ENUM: { replace: boolean; }; GENERATOR: { output?: string; provider?: string; }; DB: { provider?: string; url?: string; }; }; DELETE: { RELATION: { fieldA?: string; fieldB?: string; relationName?: string; }; }; }; export type PrismaQlDSLOptions = A extends keyof PrismaQlDSLOptionMap ? C extends keyof PrismaQlDSLOptionMap[A] ? PrismaQlDSLOptionMap[A][C] : Record> : Record>; export interface PrismaQLParsedDSL { action: A; command?: C; args?: PrismaQLDSLArgs; options?: PrismaQlDSLOptions; prismaBlock?: string; raw: string; type: T; } export type PrismaQlDSLArgsProcessor = (parsedArgs: PrismaQLDSLArgs, rawArgs: string | undefined) => PrismaQLDSLArgs; export declare class PrismaQlDslParser { argsProcessors: Record; } & Partial>>>; private customCommands; private actionTypeMap; constructor(argsProcessors: Record; } & Partial>>>); registerCommand(action: A, command: C, type: PrismaQlDSLType): void; getCommands(): Record; parseCommand(input: string): PrismaQLParsedDSL; parseParams(input: string): PrismaQlDSLOptions; parseArgs(argsStr: string | undefined): PrismaQLDSLArgs; detectActionType(source: string): PrismaQlDSLType | null; isValid(source: string): boolean | Error; } export declare const basePrismaQlAgsProcessor: Record; } & Partial>>>; export declare const prismaQlParser: PrismaQlDslParser; /** * Example of extending the base parser with custom actions and commands * type CustomAction = BasePrismaQlDSLAction | "SAY"; type CustomCommand = BasePrismaQLDSLCommand | "HI"; type CustomParserArgsProcessors = Record< CustomAction, { default: PrismaQlDSLArgsProcessor; } & Partial>> >; const customArgsProcessors: CustomParserArgsProcessors = { ...basePrismaQlAgsProcessor, SAY: { default: (parsedArgs) => parsedArgs, HI: (parsedArgs, rawArgs) => { return { models: rawArgs ? rawArgs.split(",").map(m => m.trim()) : [], }; }, }, }; export const customParser = new PrismaQlDslParser( customArgsProcessors ); customParser.registerCommand("SAY", "HI", "query"); console.log('test', customParser.parseCommand('SAY HI model1, model2;')); */ //# sourceMappingURL=dsl.d.ts.map