1 | import type { Constructable, Entity } from './entity';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | declare type FromJsonType<JsonT> = {
|
9 | [key: string]: any;
|
10 | } & {
|
11 | [P in keyof JsonT]?: JsonT[P] extends (infer U)[] ? U extends Record<string, any> ? FromJsonType<U>[] : JsonT[P] : JsonT[P] extends Record<string, any> | null | undefined ? FromJsonType<JsonT[P]> | null | undefined : JsonT[P];
|
12 | };
|
13 |
|
14 |
|
15 |
|
16 | export declare class EntityBuilder<EntityT extends Entity, JsonT> {
|
17 | private _entityConstructor;
|
18 | protected entity: EntityT;
|
19 | constructor(_entityConstructor: Constructable<EntityT, JsonT>);
|
20 | /**
|
21 | * Sets the custom fields for the entity.
|
22 | * @param customFields - The custom fields you want to add.
|
23 | * @returns The entity builder itself for method chaining
|
24 | */
|
25 | withCustomFields(customFields: Record<string, any>): this;
|
26 | /**
|
27 | * Builds the entity.
|
28 | * @returns The entity.
|
29 | */
|
30 | build(): EntityT;
|
31 | /**
|
32 | * Builds an entity from JSON representation.
|
33 | * If you have obtained the JSON as a request payload use the [[deserializeEntity]] methods.
|
34 | * Note that fields not mappable to a field in the target entity are silently ignored.
|
35 | * @param json - Representation of the entity in JSON format.
|
36 | * @returns Entity constructed from JSON representation.
|
37 | */
|
38 | fromJson(json: FromJsonType<JsonT>): EntityT;
|
39 | private filterCustomFields;
|
40 | }
|
41 | export {};
|
42 |
|
\ | No newline at end of file |