import { QFilterExpression, QOrderByExpression, QPathModel, QSearchTerm, QSelectExpression, QueryObjectModel } from "@odata2ts/odata-query-objects"; import { ExpandingCollectionQueryBuilderV4, NestingType, NullableParam, NullableParamList, ODataQueryBuilderConfig, SelectType } from "./ODataQueryBuilderModel.js"; /** * Bundles all the logic about handling system query params for OData (V2 and V4). */ export declare class ODataQueryBuilder { private readonly path; private readonly entity; private readonly unencoded; private readonly config?; private itemsCount; private itemsToSkip; private itemsTop; private selects; private filters; private orderBys; private expands; private groupBys; private searchTerms; /** * Expand fragments that were reached via a complex-typed property and therefore cannot be embedded inline * (a `$select=Prop(...)` clause cannot contain `$expand`) - they are relayed here, already path-prefixed by * the complex hop, until they reach a context that can embed them (see `expanding()` / `buildNested()`). */ private hoistedExpandsBucket; constructor(path: string, qEntity: Q, config?: ODataQueryBuilderConfig); copyState(builder: ODataQueryBuilder): ODataQueryBuilder; getPath(): string; private getSelects; private getExpands; private getHoistedExpandsBucket; addSelects: (...paths: NullableParamList) => void; addExpands: (...paths: NullableParamList) => void; /** * Helper method to retrieve a typed property from the entity. * * @param prop */ getEntityProp(prop: keyof Q): PropType; count(doCount?: boolean): void; countV2(doCount?: boolean): void; filterSelectAndMapPath(props: NullableParamList>): Array; select(props: NullableParamList>): void; filter(expressions: NullableParamList): void; expand(props: NullableParamList): void; /** * V4 only method used by regular and expanding builder. * The regular V2 builder has an own and quite special implementation. * * Whether `prop` is an entity/entity-collection navigation property or a complex/complex-collection property * is resolved dynamically here (via `instanceof`), which decides whether the nested builder's content is * embedded as `$expand=prop(...)` or `$select=prop(...)`. In the complex case, any `expand`/`expanding` calls * made inside the nested builder cannot be embedded inline (a `$select=...` clause cannot contain `$expand`, * per real-world OData server behavior even though the spec grammar technically allows it) - they are instead * relayed up (path-prefixed) via `hoistedExpandsBucket` until they reach a context that can embed them * (either an ancestor `expanding()` call reached via a navigation property, or the top-level builder). * * @param creator * @param prop * @param builderFn */ expanding>(creator: (property: string, qEntity: Q) => ExpandingCollectionQueryBuilderV4 & { getEngine(): unknown; }, prop: Prop, builderFn: (builder: any, qObject: any) => void): void; /** * Takes over what a nested builder collected for a flattened complex property. Since that property has no * representation of its own, there is no clause to embed the content in - its selects are paths of this * very entity and simply become this builder's own. * * The nested builder was handed a query object which already carries the prefix, so everything it * produced is fully qualified and none of it is prefixed again here. That also holds for a navigation * property reached through it, which still cannot be embedded and is relayed on like any other expand * reached through a complex hop. */ private absorbFlat; /** * Skip n items from the result set. * To be used in combination with top. * * @param itemsToSkip amount of items to skip * @returns this query builder */ skip(itemsToSkip: NullableParam): void; /** * Returns this many items. * To be used in combination with skip. * * @param itemsTop amount of items to fetch * @returns this query builder */ top(itemsTop: NullableParam): void; /** * Specify order by expressions by facilitating qObjects and their * ascending and descending methods. * * This method can be called multiple times in order to add orderBy expressions successively. * * @param expressions possibly multiple order by expressions at once * @returns this query builder */ orderBy(expressions: NullableParamList): void; groupBy(props: NullableParamList): void; search(terms: NullableParamList): void; private param; private paramEncoded; private buildQuery; build(): string; /** * Internal-only: used exclusively by `expanding()` to decide `$expand` vs `$select` placement for this * builder's own content, and to compute anything that must be hoisted past this context. * * - Entity context (`isComplexContext === false`, "sink"): behaves exactly like `build()` - embeds `$expand` * inline and folds in anything relayed up from complex-typed descendants. * - Complex context (`isComplexContext === true`, "relay"): excludes `$expand` from its own rendered content * entirely (a `$select=Prop(...)` clause cannot contain `$expand`) and instead returns its own `expands` * plus anything already relayed from its own descendants, unprefixed, for the caller to prefix and forward. */ buildNested(isComplexContext: boolean): { content: string; hoistedExpands: Array; }; }