UNPKG

5.82 kBTypeScriptView Raw
1import { Constructable, Entity, EntityIdentifiable } from '../entity';
2import { ODataRequest, ODataUpdateRequestConfig } from '../request';
3import { ODataUri } from '../uri-conversion';
4import { Selectable } from '../selectable';
5import { EntitySerializer } from '../entity-serializer';
6import { HttpResponse } from '../../http-client';
7import { MethodRequestBuilder } from './request-builder-base';
8/**
9 * Abstract class to create OData query to update an entity containing methods shared for OData v2 and v4.
10 * @typeparam EntityT - Type of the entity to be updated
11 */
12export declare abstract class UpdateRequestBuilder<EntityT extends Entity> extends MethodRequestBuilder<ODataUpdateRequestConfig<EntityT>> implements EntityIdentifiable<EntityT> {
13 readonly _entityConstructor: Constructable<EntityT>;
14 readonly _entity: EntityT;
15 readonly oDataUri: ODataUri;
16 readonly entitySerializer: EntitySerializer;
17 readonly extractODataEtag: (json: Record<string, any>) => string | undefined;
18 readonly payloadManipulator: (body: Record<string, any>) => Record<string, any>;
19 private ignored;
20 private required;
21 /**
22 * Creates an instance of UpdateRequestBuilder.
23 * @param _entityConstructor - Constructor type of the entity to be updated
24 * @param _entity - Entity to be updated
25 * @param oDataUri - Collection of URI conversion methods
26 * @param entitySerializer - Entity serializer
27 * @param extractODataEtag - Extractor for ETag from payload
28 * @param payloadManipulator - Manipulator for the payload.
29 */
30 constructor(_entityConstructor: Constructable<EntityT>, _entity: EntityT, oDataUri: ODataUri, entitySerializer: EntitySerializer, extractODataEtag: (json: Record<string, any>) => string | undefined, payloadManipulator: (body: Record<string, any>) => Record<string, any>);
31 get entity(): EntityT;
32 /**
33 * @deprecated Since v1.29.0. This method should never be called, it has severe side effects.
34 * Builds the payload and the entity keys of the query.
35 * @returns the builder itself
36 */
37 prepare(): this;
38 /**
39 * Explicitly configure 'PUT' as the method of the update request. By default, only the properties that have changed compared to the last known remote state are sent using 'PATCH', while with 'PUT', the whole entity is sent.
40 * @returns The entity itself, to facilitate method chaining.
41 */
42 replaceWholeEntityWithPut(): this;
43 /**
44 * @deprecated Since version 1.34.0 Use [[setRequiredFields]] instead.
45 * Specifies required entity keys for the update request.
46 * @param fields - Enumeration of the fields to be required.
47 * @returns The entity itself, to facilitate method chaining.
48 */
49 requiredFields(...fields: Selectable<EntityT>[]): this;
50 requiredFields(fields: Selectable<EntityT>[]): this;
51 /**
52 * Sets required entity keys for the update request.
53 * @param fields - Enumeration of the fields to be required.
54 * @returns The entity itself, to facilitate method chaining.
55 */
56 setRequiredFields(...fields: Selectable<EntityT>[]): this;
57 setRequiredFields(fields: Selectable<EntityT>[]): this;
58 /**
59 * @deprecated Since version 1.34.0 Use [[setIgnoredFields]] instead.
60 * Specifies entity fields to ignore by the update request.
61 * @param fields - Enumeration of the fields to be ignored.
62 * @returns The entity itself, to facilitate method chaining.
63 */
64 ignoredFields(...fields: Selectable<EntityT>[]): this;
65 ignoredFields(fields: Selectable<EntityT>[]): this;
66 /**
67 * Sets entity fields to ignore by the update request.
68 * @param fields - Enumeration of the fields to be ignored.
69 * @returns The entity itself, to facilitate method chaining.
70 */
71 setIgnoredFields(...fields: Selectable<EntityT>[]): this;
72 setIgnoredFields(fields: Selectable<EntityT>[]): this;
73 /**
74 * Instructs the request to force an overwrite of the entity by sending an 'If-Match: *' header instead of sending the ETag version identifier.
75 * @returns The request itself to ease chaining while executing the request.
76 */
77 ignoreVersionIdentifier(): this;
78 /**
79 * @deprecated Since version 1.34.0 Use [[setVersionIdentifier]] instead.
80 * Specifies a custom ETag version identifier of the entity to update.
81 * @param etag - Custom ETag version identifier to be sent in the header of the request.
82 * @returns The request itself to ease chaining while executing the request.
83 */
84 withCustomVersionIdentifier(etag: string): this;
85 /**
86 * Sets ETag version identifier of the entity to update.
87 * @param etag - Custom ETag version identifier to be sent in the header of the request.
88 * @returns The request itself to ease chaining while executing the request.
89 */
90 setVersionIdentifier(etag: string): this;
91 /**
92 * Executes the query.
93 * @param request - Request object to be executed.
94 * @returns A promise resolving to the entity once it was updated.
95 */
96 protected executeRequest(request: ODataRequest<ODataUpdateRequestConfig<EntityT>>): Promise<EntityT>;
97 protected executeRequestRaw(request: ODataRequest<ODataUpdateRequestConfig<EntityT>>): Promise<HttpResponse>;
98 protected getPayload(): Record<string, any>;
99 protected isEmptyObject(obj: any): boolean;
100 private addRequiredFields;
101 private getKeyFieldNames;
102 private toSet;
103 private serializedDiff;
104 private removeKeyFields;
105 private removeIgnoredFields;
106}
107/**
108 * @hidden
109 */
110export declare function removePropertyOnCondition(condition: (objectEntry: [string, any]) => boolean, body: Record<string, any>): Record<string, any>;
111export { UpdateRequestBuilder as UpdateRequestBuilderBase };
112//# sourceMappingURL=update-request-builder-base.d.ts.map
\No newline at end of file