@odata2ts/odata-service
Version:
Main runtime dependency of odata2ts for generated odata client services
66 lines (65 loc) • 3.32 kB
TypeScript
import { ODataHttpClient, ODataHttpClientConfig, ODataResponse } from "@odata2ts/http-client-api";
import { ODataCollectionResponseV4, ODataModelPayloadV4, ODataModelResponseV4 } from "@odata2ts/odata-core";
import { ODataQueryBuilderV4 } from "@odata2ts/odata-query-builder";
import { QId, QueryObjectModel } from "@odata2ts/odata-query-objects";
import { ODataServiceOptionsInternal } from "../ODataServiceOptions";
import { ServiceStateHelperV4, SubtypeOptions } from "./ServiceStateHelperV4.js";
export declare abstract class EntitySetServiceV4<in out ClientType extends ODataHttpClient, T, EditableT, Q extends QueryObjectModel, EIdType> {
protected readonly __base: ServiceStateHelperV4<ClientType, Q>;
protected readonly __idFunction: QId<EIdType>;
/**
* 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: ClientType, basePath: string, name: string, qModel: Q, idFunction: QId<EIdType>, options?: ODataServiceOptionsInternal);
getPath(): string;
/**
* The key specification for the given entity type.
* Supports composite keys.
*/
getKeySpec(): import("@odata2ts/odata-query-objects").QParamModel<any, any>[];
/**
* 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.
*
* @param model
* @param requestConfig
* @param createOptions
* @return
*/
create<ReturnType extends Partial<T> | void = T>(model: ODataModelPayloadV4<EditableT>, requestConfig?: ODataHttpClientConfig<ClientType>, createOptions?: SubtypeOptions): ODataResponse<ODataModelResponseV4<ReturnType>>;
/**
* Query the entity set.
*
* @param queryFn provide the query logic with the help of the builder and the query-object
* @param requestConfig any special configurations for this request
*/
query<ReturnType extends Partial<T> = T>(queryFn?: (builder: ODataQueryBuilderV4<Q>, qObject: Q) => void, requestConfig?: ODataHttpClientConfig<ClientType>): ODataResponse<ODataCollectionResponseV4<ReturnType>>;
}