import { ODataHttpClient } from "@odata2ts/http-client-api"; import { ODataCollectionResponseV2, ODataCollectionResponseV4, ODataEntityModelResponseV2, ODataModelResponseV4 } from "@odata2ts/odata-core"; import { CollectionQueryBuilderV2, ModelQueryBuilderV2 } from "@odata2ts/odata-query-builder"; import { QId, QueryObjectModel } from "@odata2ts/odata-query-objects"; import { ODataServiceOptionsInternalV2 } from "../ODataServiceOptions"; import { ConcurrencyOptions, UrlBuilderRequestCmdV2 } from "../request"; import { ServiceStateHelperV2 } from "./ServiceStateHelperV2.js"; /** * Service for an entity set: it queries the collection and creates entities in it. Creation is the one * write that may supply properties which can never change afterwards, so this is the only entity service * still typed on `EditableT`. Everything that writes to an entity which already exists - * {@link EntityTypeServiceV2} and friends - takes the updatable model instead. */ export declare abstract class EntitySetServiceV2 { protected readonly __base: ServiceStateHelperV2; protected readonly __idFunction: QId; protected constructor(client: ODataHttpClient, basePath: string, name: string, qModel: Q, idFunction: QId, options?: ODataServiceOptionsInternalV2); getPath(): string; /** * Build the entity-type service for a specific entity of this set - the concrete class differs per * generated entity type, so each generated collection service supplies its own construction here. */ protected abstract createEntityService(client: ODataHttpClient, path: string, name: string, options: ODataServiceOptionsInternalV2 | undefined): ES; /** * The entity-type service addressed by the given id. */ byId(id: EIdType): ES; /** * The entity-type service addressed by a batch request reference (`$`) rather than by a known key - * the single-entity twin of {@link byId} for the case where the key is not yet known because an earlier * sub-request in the same batch just created the entity. The service's path is the bare `$` under the * base, so a request built from it goes out as `$/…` in the batch. * * Not ETag-gated and carries no cache key - a reference is not a real address, so there is nothing to gate * on or to store under. */ byRef(id: number): ES; /** * The key specification for the given entity type. * Supports composite keys. */ getKeySpec(): import("@odata2ts/odata-query-objects").QParamModel[]; /** * Create an OData path for an entity with a given id. * Might be useful for routing. * * @example createKey(1234) => myEntity(1234) * @example createKey({id: 1234, name: "Test"}) => myEntity(id=1234,name='Test') * @param id either a primitive value (single key entities only) or an object * @param notEncoded if set to {@code true}, special chars are not escaped */ createKey(id: EIdType, notEncoded?: boolean): string; /** * Parse an OData path representing the id of an entity. * Might be useful for routing in combination with createKey. * * @example parseKey("myEntity(1234)") => 1234 * @example parseKey("myEntity(id=1234,name='Test')") => { id: 1234, name: "Test" } * @param keyPath e.g. myEntity(id=1234,name='Test') * @param notDecoded if set to {@code true}, encoded special chars are not decoded */ parseKey(keyPath: string, notDecoded?: boolean): EIdType; /** * Create a new model. * Spec: {@link https://www.odata.org/documentation/odata-version-2-0/operations/} - 2.4 Creating new Entries * * The service should respond with 201 (Created) and the newly created model. * * @param model the entity to create * @param queryFn additional query after the entity has been created, only $select and $expand apply here * @return */ /** * The URL of one entity of this set - the very string the entity service of that entity builds for * itself, which is what lets a collection read fill the store for entities nobody read singly. */ private entityKeyOf; /** * The concurrency options of a command over this collection. * * A raw V2 collection arrives as `{ d: { results: [...] } }` and states each ETag in `__metadata`; one * reshaped as V4 has had the envelope removed and the control information rewritten, so the reader is * chosen here rather than by a helper trying every spelling. */ protected getCollectionConcurrencyOptions(): ConcurrencyOptions; create(model: EditableT, queryFn?: (builder: ModelQueryBuilderV2, qObject: Q) => void): UrlBuilderRequestCmdV2 : ODataEntityModelResponseV2, Q, ModelQueryBuilderV2, EditableT>; /** * Query the entity set. * * @param queryFn provide the query logic with the help of the builder and the query-object */ query = T>(queryFn?: (builder: CollectionQueryBuilderV2, qObject: Q) => void): UrlBuilderRequestCmdV2 : ODataCollectionResponseV2, Q, CollectionQueryBuilderV2, undefined>; }