import { ODataHttpClient } from "@odata2ts/http-client-api"; import { ODataCollectionResponseFor, ODataModelPayloadFor, ODataVersionV4 } from "@odata2ts/odata-core"; import { CollectionQueryBuilderV4, ModelQueryBuilderV4 } from "@odata2ts/odata-query-builder"; import { QId, QueryObjectModel } from "@odata2ts/odata-query-objects"; import { ODataServiceOptionsInternal } from "../ODataServiceOptions"; import { ConcurrencyOptions, UrlBuilderRequestCmdV4 } from "../request"; import { EntityModificationResponseV4 } from "./ResponseTypeChoicesV4"; import { ServiceStateHelperV4, SubtypeOptions } from "./ServiceStateHelperV4.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 EntityTypeServiceV4} and friends - takes the updatable model instead. */ export declare abstract class EntitySetServiceV4 { protected readonly __base: ServiceStateHelperV4; protected readonly __idFunction: QId; /** * Overriding the constructor to support creation of EntityTypeService from within this service. * Also support key spec. * * @param client the odata client responsible for data requests * @param basePath the base URL path * @param name name of the service * @param qModel query object * @param idFunction the id function * @param options * @protected */ protected constructor(client: ODataHttpClient, basePath: string, name: string, qModel: Q, idFunction: QId, options?: ODataServiceOptionsInternal); getPath(): string; /** * Build the entity-type service for a specific entity of this set - the concrete class differs per * generated entity type (e.g. `MediumService` vs. `PrintMediumService`), so each generated collection * service supplies its own construction here. */ protected abstract createEntityService(client: ODataHttpClient, path: string, name: string, options: ODataServiceOptionsInternal | undefined): ES; /** * The entity-type service addressed by the given id - primary or, where declared, an alternate key. * * Works the same after a subtype cast (e.g. {@link asPrintMediumCollectionService}-style getters): * the cast segment is already part of this service's path, so the id only ever needs to add the key * predicate - which is what makes addressing by a subtype's own alternate key possible at all, since * the entity set's own id type never carries a subtype's alternate key. */ 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. This is the URL reference: the service's path is * the bare `$` under the base, so a request built from it goes out as `$/…` in the batch and the * service rewrites it against the preceding sub-request's answer. * * 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, i.e. the primary key. * Supports composite keys. */ getKeySpec(): import("@odata2ts/odata-query-objects").QParamModel[]; /** * The key specification of every alternate key declared for this entity type * (`Core.AlternateKeys`) - empty where none are declared. One entry per alternate key, in the same * order {@link createKey}/{@link parseKey} try them in after the primary key. */ getAlternateKeySpecs(): 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({number: 1234, name: "Test"})` => `"myEntity(number=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; /** * 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 has read singly. * * Built from the mapped, user-facing property names, so it only works on a converted response. */ private entityKeyOf; /** * The concurrency options of a command over this collection: every row states its own ETag, and each is * stored under the URL of the entity it describes - which is what makes "read the list, then patch one * row" work without reading that row again. * * A single object is handled too, since a create answers with the entity it made. */ protected getCollectionConcurrencyOptions(): ConcurrencyOptions; /** * Create a new model. * Spec: {@link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_CreateanEntity}). * * The response of this operation is status 201 with the proper and complete model including the usually required id. * With a header field of "Prefer" and value "return=minimal" the OData server should respond with * status 204 and comes with no response data at all. * Both implementations have to supply the URL to the resource in the header field "Location", so you can always * extract the ID as part of this URL (the appropriate QId object can help parsing here). * * If you know in which way your server responds, you can easily supply this information via a boolean switch * to get the correct typing. `true` (default) means that the complete entity is returned, while `false` determines * that no data is returned, e.g. `create(...)`. * * @param model * @param createOptions * @param queryFn * @return command object for request execution */ create(model: ODataModelPayloadFor, createOptions?: SubtypeOptions, queryFn?: (builder: ModelQueryBuilderV4, qObject: Q) => void): UrlBuilderRequestCmdV4, Q, ModelQueryBuilderV4, ODataModelPayloadFor>; /** * Query the entity set. * Spec: {@link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_QueryingCollections} * * @param queryFn provide the query logic with the help of the builder and the query-object */ query = T>(queryFn?: (builder: CollectionQueryBuilderV4, qObject: Q) => void): UrlBuilderRequestCmdV4, Q, CollectionQueryBuilderV4, undefined>; }