1 | import { EdmTypeShared, OrderableEdmType } from '../edm-types';
|
2 | import { Constructable, Entity } from '../entity';
|
3 | import { ComplexTypeField } from './complex-type-field';
|
4 | import { EdmTypeField } from './edm-type-field';
|
5 | import { OrderableEdmTypeField } from './orderable-edm-type-field';
|
6 | import { CollectionField, CollectionFieldType } from './collection-field';
|
7 | import { ConstructorOrField } from './constructor-or-field';
|
8 | import { FieldOptions } from './field';
|
9 | import { EnumField } from './enum-field';
|
10 | declare type ComplexTypeFieldConstructor<ComplexTypeFieldT extends ComplexTypeField<EntityT, ComplexT, NullableT, SelectableT>, EntityT extends Entity, ComplexT, NullableT extends boolean, SelectableT extends boolean> = new (fieldName: string, fieldOf: ConstructorOrField<EntityT>, fieldOptions?: FieldOptions<NullableT, SelectableT>) => ComplexTypeFieldT;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | export declare type IsSelectableField<FieldOfT extends ConstructorOrField<any>> = FieldOfT extends Constructable<any> ? true : false;
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export declare type IsOrderableField<EdmT extends EdmTypeShared<'any'>> = EdmT extends OrderableEdmType ? true : false;
|
21 | declare type EntityTypeFromFieldOf<FieldOfT extends ConstructorOrField<any>> = FieldOfT extends ConstructorOrField<infer EntityT> ? EntityT : never;
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export declare class FieldBuilder<FieldOfT extends ConstructorOrField<any>> {
|
27 | fieldOf: FieldOfT;
|
28 | |
29 |
|
30 |
|
31 |
|
32 | constructor(fieldOf: FieldOfT);
|
33 | buildEdmTypeField<EdmT extends OrderableEdmType, NullableT extends boolean>(fieldName: string, edmType: EdmT, isNullable: NullableT): OrderableEdmTypeField<EntityTypeFromFieldOf<FieldOfT>, EdmT, NullableT, IsSelectableField<FieldOfT>>;
|
34 | buildEdmTypeField<EdmT extends Exclude<EdmTypeShared<'any'>, OrderableEdmType>, NullableT extends boolean>(fieldName: string, edmType: EdmT, isNullable: NullableT): EdmTypeField<EntityTypeFromFieldOf<FieldOfT>, EdmT, NullableT, IsSelectableField<FieldOfT>>;
|
35 | /**
|
36 | * Build a field for a property with a complex type.
|
37 | * Fields of entities are selectable; fields of complex types are not selectable.
|
38 | * @param fieldName - Name of the field.
|
39 | * @param complexTypeFieldCtor - Constructor of the complex type field.
|
40 | * @param isNullable - Whether the field is nullable.
|
41 | * @returns A complex type field of the given type.
|
42 | */
|
43 | buildComplexTypeField<ComplexTypeFieldT extends ComplexTypeField<EntityTypeFromFieldOf<FieldOfT>, any, NullableT, IsSelectableField<FieldOfT>>, ComplexT, NullableT extends boolean>(fieldName: string, complexTypeFieldCtor: ComplexTypeFieldConstructor<ComplexTypeFieldT, EntityTypeFromFieldOf<FieldOfT>, ComplexT, NullableT, IsSelectableField<FieldOfT>>, isNullable: NullableT): ComplexTypeFieldT;
|
44 | /**
|
45 | * Build a field for a property with a collection type.
|
46 | * The type of the field can either be an EDM type or a complex type.
|
47 | * Fields of entities are selectable; fields of complex types are not selectable.
|
48 | * @param fieldName - Name of the field.
|
49 | * @param collectionFieldType - Type of the collection. Can either be an EDM type or complex type (not complex type field).
|
50 | * @param isNullable - Whether the field is nullable.
|
51 | * @returns A collection field with the given collection type.
|
52 | */
|
53 | buildCollectionField<CollectionFieldT extends EdmTypeShared<'any'> | Record<string, any>, NullableT extends boolean>(fieldName: string, collectionFieldType: CollectionFieldType<CollectionFieldT>, isNullable: NullableT): CollectionField<EntityTypeFromFieldOf<FieldOfT>, CollectionFieldT, NullableT, IsSelectableField<FieldOfT>>;
|
54 | /**
|
55 | * Build a field for a property with a enum type.
|
56 | * @param fieldName - Name of the field.
|
57 | * @param enumType - Enum type of this field.
|
58 | * @param isNullable - Whether the field is nullable.
|
59 | * @returns A collection field with the given collection type.
|
60 | */
|
61 | buildEnumField<EnumT extends string, NullableT extends boolean>(fieldName: string, enumType: Record<string, EnumT>, isNullable: NullableT): EnumField<EntityTypeFromFieldOf<FieldOfT>, EnumT, NullableT, IsSelectableField<FieldOfT>>;
|
62 | }
|
63 | export {};
|
64 |
|
\ | No newline at end of file |