1 | import { EntityBuilder } from './entity-builder';
|
2 | import { Link, Field, Selectable, CustomField } from './selectable';
|
3 | import { RequestBuilder } from './request-builder';
|
4 | export declare type ODataVersionOf<T extends Entity> = T['_oDataVersion'];
|
5 |
|
6 |
|
7 |
|
8 | export interface Constructable<EntityT extends Entity, EntityTypeT = unknown> {
|
9 | _serviceName: string;
|
10 | _entityName: string;
|
11 | _defaultServicePath: string;
|
12 | _allFields: (Selectable<EntityT> | Field<EntityT, boolean, boolean> | Link<EntityT>)[];
|
13 | _keyFields: (Selectable<EntityT> | Field<EntityT, boolean, boolean>)[];
|
14 | _keys: {
|
15 | [keys: string]: Selectable<EntityT> | Field<EntityT, boolean, boolean>;
|
16 | };
|
17 | new (...args: any[]): EntityT;
|
18 | requestBuilder(): RequestBuilder<EntityT>;
|
19 | builder(): EntityBuilderType<EntityT, EntityTypeT>;
|
20 | customField(fieldName: string, isNullable?: boolean): CustomField<EntityT, boolean>;
|
21 | }
|
22 | export declare type EntityBuilderType<EntityT extends Entity, EntityTypeT> = {
|
23 | [property in keyof Required<EntityTypeT>]: (value: EntityTypeT[property]) => EntityBuilderType<EntityT, EntityTypeT>;
|
24 | } & EntityBuilder<EntityT, EntityTypeT>;
|
25 |
|
26 |
|
27 |
|
28 | export declare abstract class Entity {
|
29 | static _serviceName: string;
|
30 | static _entityName: string;
|
31 | static _defaultServicePath: string;
|
32 | protected static entityBuilder<EntityT extends Entity, EntityTypeT>(entityConstructor: Constructable<EntityT, EntityTypeT>): EntityBuilderType<EntityT, EntityTypeT>;
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 | protected remoteState: {
|
39 | [keys: string]: any;
|
40 | };
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 | protected _versionIdentifier: string;
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 | protected _customFields: Record<string, any>;
|
53 | abstract readonly _oDataVersion: any;
|
54 | constructor();
|
55 | /**
|
56 | * ETag version identifier accessor.
|
57 | * @returns The ETag version identifier of the retrieved entity, returns `undefined` if not retrieved.
|
58 | */
|
59 | get versionIdentifier(): string;
|
60 | /**
|
61 | * Returns a map that contains all entity custom fields.
|
62 | * @returns A map of all defined custom fields in the entity
|
63 | */
|
64 | getCustomFields(): Record<string, any>;
|
65 | /**
|
66 | * Custom field value getter.
|
67 | * @param fieldName - The name of the custom field
|
68 | * @returns The value of the corresponding custom field
|
69 | */
|
70 | getCustomField(fieldName: string): any;
|
71 | /**
|
72 | * Sets a new custom field in the entity or updates it.
|
73 | * Throws an error, if the provided custom field name is already defined by an original field in entity.
|
74 | * @param fieldName - The name of the custom field to update
|
75 | * @param value - The value of the field
|
76 | * @returns The entity itself, to facilitate method chaining
|
77 | */
|
78 | setCustomField(fieldName: string, value: any): this;
|
79 | /**
|
80 | * Validates whether a custom field exists in the entity.
|
81 | * @param fieldName - The name of the custom field to update
|
82 | * @returns A boolean value, that indicates whether a custom field is defined in entity
|
83 | */
|
84 | hasCustomField(fieldName: string): boolean;
|
85 | /**
|
86 | * Sets custom fields on an entity.
|
87 | * @param customFields - Custom fields to set on the entity.
|
88 | * @returns The entity itself, to facilitate method chaining
|
89 | */
|
90 | setCustomFields(customFields: Record<string, any>): this;
|
91 | /**
|
92 | * @deprecated Since v1.34.1. Use [[setCustomFields]] instead.
|
93 | * Sets all retrieved custom fields in entity.
|
94 | * @param customFields - Extracted custom fields from a retrieved entity.
|
95 | * @returns The entity itself, to facilitate method chaining.
|
96 | */
|
97 | initializeCustomFields(customFields: Record<string, any>): this;
|
98 | /**
|
99 | * Set the ETag version identifier of the retrieved entity.
|
100 | * @param etag - The returned ETag version of the entity.
|
101 | * @returns The entity itself, to facilitate method chaining.
|
102 | */
|
103 | setVersionIdentifier(etag: string | undefined): this;
|
104 | /**
|
105 | * @deprecated Since 1.12.0. Will be hidden in version 2.0.
|
106 | * Initializes or sets the remoteState of the entity.
|
107 | * This function is called on all read, create and update requests.
|
108 | * This function should be called after [[initializeCustomFields]], if custom fields are defined.
|
109 | * @param state - State to be set as remote state.
|
110 | * @returns The entity itself, to facilitate method chaining
|
111 | */
|
112 | setOrInitializeRemoteState(state?: Record<string, any>): this;
|
113 | /**
|
114 | * Returns all updated custom field properties compared to the last known remote state.
|
115 | * @returns An object containing all updated custom properties, with their new values.
|
116 | */
|
117 | getUpdatedCustomFields(): Record<string, any>;
|
118 | /**
|
119 | * Returns all changed properties compared to the last known remote state.
|
120 | * The returned properties do not include custom fields.
|
121 | * Use [[getUpdatedCustomFields]], if you need custom fields.
|
122 | * @returns Entity with all properties that changed
|
123 | */
|
124 | getUpdatedProperties(): Record<string, any>;
|
125 | /**
|
126 | * Returns all changed property names compared to the last known remote state.
|
127 | * The returned properties names do not include custom fields.
|
128 | * Use [[getUpdatedCustomFields]], if you need custom fields.
|
129 | * @returns Entity with all properties that changed
|
130 | */
|
131 | getUpdatedPropertyNames(): string[];
|
132 | /**
|
133 | * @deprecated Since v1.34.1. Use [[asObject]] instead.
|
134 | * Returns a map of all defined fields in entity to their current values.
|
135 | * @param visitedEntities - List of entities to check in case of circular dependencies.
|
136 | * @returns Entity with all defined entity fields
|
137 | */
|
138 | protected getCurrentMapKeys(visitedEntities?: Entity[]): any;
|
139 | protected isVisitedEntity<EntityT extends Entity>(entity: EntityT, visitedEntities?: Entity[]): boolean;
|
140 | protected getCurrentStateForKey(key: string, visitedEntities?: Entity[]): any;
|
141 | /**
|
142 | * Validates whether a field name does not conflict with an original field name and thus can be defined as custom fields.
|
143 | * @param customFieldName - Field name to check
|
144 | * @returns Boolean value that describes whether a field name can be defined as custom field
|
145 | */
|
146 | protected isConflictingCustomField(customFieldName: string): boolean;
|
147 | /**
|
148 | * Creates an object containing all defined properties, navigation properties and custom fields in the entity.
|
149 | * @param visitedEntities - List of entities to check in case of circular dependencies.
|
150 | * @returns Entity as an object with all defined entity fields
|
151 | */
|
152 | protected asObject(visitedEntities?: Entity[]): Record<string, any>;
|
153 | }
|
154 | /**
|
155 | * @hidden
|
156 | */
|
157 | export interface EntityIdentifiable<T extends Entity> {
|
158 | readonly _entityConstructor: Constructable<T>;
|
159 | readonly _entity: T;
|
160 | }
|
161 |
|
162 |
|
163 |
|
164 | export declare function isSelectedProperty<EntityT extends Entity>(json: any, field: Field<EntityT> | Link<EntityT>): boolean;
|
165 |
|
166 |
|
167 |
|
168 | export declare function isExistentProperty<EntityT extends Entity, LinkedEntityT extends Entity>(json: any, link: Link<EntityT, LinkedEntityT>): boolean;
|
169 |
|
170 |
|
171 |
|
172 | export declare function isExpandedProperty<EntityT extends Entity, LinkedEntityT extends Entity>(json: any, link: Link<EntityT, LinkedEntityT>): boolean;
|
173 | export { Entity as EntityBase };
|
174 |
|
\ | No newline at end of file |