UNPKG

json-to-sql-parser

Version:

A TypeScript library that converts JSON-based query specifications into safe SQL queries

32 lines 1.58 kB
/** biome-ignore-all lint/suspicious/noThenProperty: we use then and else in our $cond spec **/ import type { AnyScalar, Condition } from "../schemas"; import type { Config, Field, ParserState } from "../types"; import type { ExpressionTypeMap } from "../utils/expression-map"; export declare function parseNewRowValue(value: unknown, fieldConfig: Field, context: EvaluationContext, expressions: ExpressionTypeMap): AnyScalar | UnresolvedExpression; type ParsedRow = Record<string, AnyScalar | UnresolvedExpression>; export declare function parseNewRow(context: Omit<EvaluationContext, "newRow">, expressions: ExpressionTypeMap, newRow: Record<string, unknown>): ParsedRow; type UnresolvedExpression = { $field: string; } | { $func: Record<string, EvaluationResult[]>; } | { $cond: { if: Condition; then: EvaluationResult; else: EvaluationResult; }; }; export declare function parseNewRowWithDefaults(context: Omit<EvaluationContext, "newRow">, expressions: ExpressionTypeMap, newRow: ParsedRow): ParsedRow; export type EvaluationContext = { table?: string; mutationType?: "INSERT" | "UPDATE" | "DELETE"; rootTable: string; newRow: ParsedRow; fields: Field[]; config: Config; }; type EvaluationResult = AnyScalar | UnresolvedExpression; export declare function processMutationFields(newRow: Record<string, unknown>, state: ParserState): Record<string, string>; export declare function evaluateCondition(condition: Condition, context: EvaluationContext): Condition; export {}; //# sourceMappingURL=mutations.d.ts.map