import { ConditionWithValueQuery, FieldType, FieldTypeOf, FieldTypeOfCondition, FormulaFunctionExp, FunctionExp, GroupByClause, HavingClause, NegationCondition, OrderByClause, Query, Subquery, ValueQueryCondition, WhereClause, WithDataCategoryClause } from '../api/api-models'; /** * Leaf renderers and the shared clause sequence, used by both the plain composer and the formatter. * * Every renderer in this module turns one node of the parsed query into a string * *without* making any whitespace/newline/indentation decisions and *without* rendering subqueries - * that is the job of the callers (`composePlain()` and `Formatter`). * `queryClauses()` owns the order and presence of the clauses themselves, so the two callers * only decide layout. None of these functions mutate their input. */ /** * Renders a function expression, e.g. `COUNT(Id) total` or `FORMULA('Amount - Cost')`. * A FORMULA that carries a nested `formula` AST is always rebuilt from that AST and its `rawValue` is ignored. * Every other function, including a FORMULA without `formula`, prefers `rawValue` when populated, * otherwise it is built from `functionName` and `parameters`. */ export declare function renderFn(fn: FunctionExp | FormulaFunctionExp): string; /** * Renders the text of a SELECT field. Subquery fields are not handled here since they require * rendering a nested query - callers must handle `FieldSubquery` themselves. * TYPEOF fields are rendered on a single line (see `renderTypeOfParts` for the individual parts). */ export declare function renderFieldText(field: Exclude): string; /** * Renders a TYPEOF field as its individual parts, e.g. * `['TYPEOF What', 'WHEN Account THEN Phone, NumberOfEmployees', 'ELSE Name, Email', 'END']` */ export declare function renderTypeOfParts(field: FieldTypeOf): string[]; export declare function renderTypeOfCondition(condition: FieldTypeOfCondition): string; /** * Renders the FROM target (object or relationship, with optional alias), or an empty string if there is none. * e.g. `Account a`, `Account.Contacts c` */ export declare function renderFrom(query: Query | Subquery): string; /** Any condition other than a bare `NOT` - i.e. one that carries an operator and either a `field` or an `fn`. */ export type NonNegationCondition = Exclude; /** A condition that is rendered as ` ` - excludes `NOT` and subquery (`IN (SELECT ...)`) conditions. */ export type SimpleCondition = Exclude; /** * Renders the left-hand side of a condition, including the operator, e.g. `Name LIKE`, `COUNT(Id) >` */ export declare function renderConditionLhs(condition: NonNegationCondition): string; /** * Renders the value of a (non-subquery) condition, e.g. `'foo'`, `('a', 'b')`, `TRUE`, `LAST_N_DAYS:7` */ export declare function renderConditionValue(condition: SimpleCondition): string; /** e.g. `Name`, `COUNT(Id)` */ export declare function renderGroupByItem(groupBy: GroupByClause): string; /** e.g. `Name ASC NULLS LAST`, `COUNT(Id) DESC` */ export declare function renderOrderByItem(orderBy: OrderByClause): string; /** e.g. `Geography__c AT (usa__c, uk__c) AND Product__c ABOVE mobile_phones__c` */ export declare function renderWithDataCategory(withDataCategory: WithDataCategoryClause): string; /** True if the query has a GROUP BY clause that should be rendered (a non-empty array or a single clause) */ export declare function hasGroupBy(query: Query | Subquery): boolean; /** True if the query has an ORDER BY clause that should be rendered (a non-empty array or a single clause) */ export declare function hasOrderBy(query: Query | Subquery): boolean; /** Wraps a single clause or array of clauses in an array */ export declare function asArray(value: T | T[]): T[]; /** * One clause of a query, tagged by how it is laid out. The SELECT fields are passed through unrendered * because subquery fields have to be rendered by the caller. */ export type ClausePart = { kind: 'select'; fields: FieldType[]; } | { kind: 'value'; keyword: string; value: string; } | { kind: 'bare'; keyword: string; } | { kind: 'list'; keyword: string; items: string[]; } | { kind: 'conditions'; keyword: string; clause: WhereClause | HavingClause; }; /** * Yields the clauses of a query in the order SOQL requires, skipping any that are absent or empty. * * This is the single source of truth for clause ordering and presence - both `composePlain()` and * `Formatter.query()` walk this sequence and only decide how each part is laid out. Adding support for a * new clause means adding it here once, not in each renderer. */ export declare function queryClauses(query: Query | Subquery): Generator;