@mediusinc/mng-commons-data-api 6.2.0 → 7.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +0,0 @@
1
- export interface ApiVersion {
2
- appName?: string;
3
- description?: string;
4
- version?: string;
5
- infoEmail?: string;
6
- infoUrl?: string;
7
- licenseInfo?: string;
8
- licenseUrl?: string;
9
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Default (expected) type without filters, which are "dynamic" keys.
3
- */
4
- export type GetAllParamsDefaultWoFiltersType<Sort = GetAllParamsSortType[] | string, GlobalFilter = GetAllParamsGlobalFilterType | string> = {
5
- offset?: number;
6
- limit?: number;
7
- globalFilter?: GlobalFilter;
8
- sort?: Sort;
9
- };
10
- /**
11
- * Represents the sort direction type for a get all request params (ascending or descending).
12
- */
13
- export type GetAllParamsSortDirectionType = 'ASCENDING' | 'DESCENDING';
14
- /**
15
- * Represents the sort type for a get all request params.
16
- *
17
- * @typeparam Property The type of the property to sort by.
18
- * @typeparam Direction The type of the sort direction.
19
- */
20
- export type GetAllParamsSortType<Property = string, Direction = GetAllParamsSortDirectionType> = {
21
- property: Property;
22
- direction: Direction;
23
- };
24
- /**
25
- * Represents the possible match types for filters in get all request params.
26
- */
27
- export type GetAllParamsFilterMatchType = 'EQUALS' | 'NOT_EQUALS' | 'BETWEEN' | 'CONTAINS' | 'NOT_CONTAINS' | 'STARTS_WITH' | 'ENDS_WITH' | 'IN' | 'NOT_IN' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL_TO' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL_TO' | 'EXISTS' | 'DOES_NOT_EXIST';
28
- /**
29
- * Describes the possible case sensitivity for filter in get all request params.
30
- */
31
- export type GetAllParamsFilterCaseSensitivityType = 'CASE_SENSITIVE' | 'CASE_INSENSITIVE';
32
- /**
33
- * Describes the global filter (search) in get all request params.
34
- */
35
- export type GetAllParamsGlobalFilterType<CaseSensitivity = GetAllParamsFilterCaseSensitivityType> = {
36
- value: string;
37
- caseSensitivity?: CaseSensitivity;
38
- };
39
- /**
40
- * Describes the filters in get all request params.
41
- */
42
- export type GetAllParamsFiltersType<FilterType, FilterProperties extends keyof any> = {
43
- [P in FilterProperties]?: FilterType;
44
- };
45
- /**
46
- * Represents a filter type for get all request params.
47
- */
48
- export type GetAllParamsFilterType<Value, CaseSensitivity = GetAllParamsFilterCaseSensitivityType, MatchType = GetAllParamsFilterMatchType> = {
49
- value?: Value;
50
- values?: Array<Value>;
51
- caseSensitivity?: CaseSensitivity;
52
- filterMatchType: MatchType;
53
- };
54
- /**
55
- * Describes get all params with values as objects (for POST requests).
56
- */
57
- export type GetAllParamsType<Sorts = string, Filters extends keyof any = string> = GetAllParamsDefaultWoFiltersType<GetAllParamsSortType<Sorts>[], GetAllParamsGlobalFilterType> & GetAllParamsFiltersType<GetAllParamsFilterType<any>, Filters>;
58
- /**
59
- * Describes get all params with values as URL queries (for GET requests).
60
- */
61
- export type GetAllParamsUrlQueryType<Filters extends keyof any> = GetAllParamsDefaultWoFiltersType<string, string> & GetAllParamsFiltersType<string, Filters>;
62
- /**
63
- * Describes get all params with values as URL queries (for GET requests) where filters are places as object under root {FilterKey} property.
64
- */
65
- export type GetAllParamsUrlQueryWithFiltersInKeyType<FilterKey extends string | number | symbol, Filters extends keyof any> = GetAllParamsDefaultWoFiltersType<string, string> & {
66
- [key in FilterKey]?: GetAllParamsFiltersType<string, Filters>;
67
- };
@@ -1,31 +0,0 @@
1
- export interface SchemaModel<Model = any> {
2
- name: string;
3
- properties: Record<keyof Model, SchemaProperty>;
4
- }
5
- export interface SchemaEnum<EnumType> {
6
- name: string;
7
- values: EnumType[];
8
- constants: string[];
9
- type: string;
10
- }
11
- export interface SchemaProperty {
12
- type: string;
13
- objectType?: string;
14
- isReadOnly?: boolean;
15
- required?: boolean;
16
- isNullable?: boolean;
17
- minLength?: number;
18
- maxLength?: number;
19
- minimum?: number;
20
- maximum?: number;
21
- exclusiveMinimum?: boolean;
22
- exclusiveMaximum?: boolean;
23
- isInteger?: boolean;
24
- pattern?: string;
25
- maxItems?: number;
26
- minItems?: number;
27
- enumModel?: any;
28
- enumName?: string;
29
- isEmail?: boolean;
30
- isPassword?: boolean;
31
- }
@@ -1,30 +0,0 @@
1
- import { HttpResponse } from '@angular/common/http';
2
- import { Observable } from 'rxjs';
3
- import { ClassFunctionKeysWithAnyArgsAndReturnType } from '@mediusinc/mng-commons/core';
4
- import { GetAllParamsDefaultWoFiltersType, GetAllParamsSortType } from '../models/request-params.model';
5
- /**
6
- * Represents the type definition for the `GetAllParamsDefaultWoFiltersType` class - excludes offset, limit, search and sort properties.
7
- * All other properties are expected to be filters.
8
- *
9
- * @typeparam Request - The type parameter representing the extended GetAllParamsDefaultWoFiltersType object.
10
- */
11
- export type ExtractGetAllParamsFilterType<Request extends GetAllParamsDefaultWoFiltersType> = Request extends GetAllParamsDefaultWoFiltersType ? keyof Omit<Request, 'offset' | 'limit' | 'globalFilter' | 'sort'> : never;
12
- /**
13
- * Represents the type definition for the `GetAllParamsDefaultWoFiltersType` class - extracts allowed sort properties (usually an enum) on property key within array type.
14
- *
15
- * @typeparam Request - The type parameter representing the extended GetAllParamsDefaultWoFiltersType object.
16
- */
17
- export type ExtractGetAllParamsSortType<Request extends GetAllParamsDefaultWoFiltersType<GetAllParamsSortType<any, any>[] | string, any>> = NonNullable<Request['sort']> extends Array<infer U> | string ? ('property' extends keyof U ? NonNullable<U['property']> : never) : never;
18
- export type GetAllHttpResponseType<Model> = {
19
- data?: Array<Model>;
20
- totalCount?: number;
21
- } | HttpResponse<{
22
- data?: Array<Model>;
23
- totalCount?: number;
24
- }>;
25
- export type ApiServiceGetAllFilterType<Service, Model, Fn extends ClassFunctionKeysWithAnyArgsAndReturnType<Service, Observable<GetAllHttpResponseType<Model>>>> = Service[Fn] extends (...args: any[]) => any ? NonNullable<Parameters<Service[Fn]>[0]> : never;
26
- export type ExtractServiceGetAllDataType<Service, Fn extends keyof Service> = Service[Fn] extends (...args: any[]) => Observable<{
27
- data?: Array<infer Model>;
28
- } | HttpResponse<{
29
- data?: Array<infer Model>;
30
- }>> ? Model : never;
@@ -1,55 +0,0 @@
1
- import { Type } from '@angular/core';
2
- import { Observable, OperatorFunction } from 'rxjs';
3
- import { ClassFunctionKeysWithParamAndReturnType, ClassFunctionKeysWithReturnType, ItemOrObservable } from '@mediusinc/mng-commons/core';
4
- import { FilterDateOptsType, FilterGenericProperty, FilterNumberOptsType, FilterTypeEnum } from '@mediusinc/mng-commons/filter';
5
- import { LookupDataProviderInst } from '@mediusinc/mng-commons/form/api';
6
- export interface FilterGenericPropertyOptsType {
7
- numberOpts?: FilterNumberOptsType;
8
- dateOpts?: FilterDateOptsType;
9
- }
10
- /**
11
- * Maps a property type to its corresponding filter type enum and applies default
12
- * filter options if no custom options are provided. If the property type is not recognized,
13
- * it returns a filter type value of null.
14
- *
15
- * @param propertyType - The property type to convert.
16
- * @param [opts] - The custom options to use for conversion.
17
- */
18
- export declare function convertPropertyTypeToFilterType(propertyType?: string, opts?: FilterGenericPropertyOptsType): {
19
- filterType: FilterTypeEnum | null;
20
- opts?: FilterDateOptsType | FilterNumberOptsType;
21
- };
22
- type FilterGenericPropertiesMetadataType = {
23
- [key: string]: string | undefined;
24
- };
25
- /**
26
- * Converts an object of properties and types into an array of filterable properties with the corresponding filter types and options.
27
- * @param properties - The object containing the properties.
28
- * @param [opts] - Custom filter options.
29
- */
30
- export declare function convertPropertyToFilterGenericProperties(properties: FilterGenericPropertiesMetadataType, opts?: FilterGenericPropertyOptsType): FilterGenericProperty[];
31
- /**
32
- * Maps an Observable of properties to filter generic properties.
33
- */
34
- export declare function mapToFilterGenericProperties(opts?: FilterGenericPropertyOptsType): OperatorFunction<FilterGenericPropertiesMetadataType, FilterGenericProperty[]>;
35
- type FilterPropertyLookupFnType<Service> = (service: Service) => ItemOrObservable<FilterGenericPropertiesMetadataType>;
36
- /**
37
- * Creates a data provider for generic filter properties that can be used with the TableDescriptor's generic filter functionality.
38
- *
39
- * @param serviceType - The service to fetch the properties from.
40
- * @param lookupFn - The name of the service function to call for properties or function impl returning properties.
41
- * @param [opts] - Optional custom options for filter descriptors, such as date and number formatting.
42
- */
43
- export declare function filterPropertyLookupProvider<Service>(serviceType: Type<Service>, lookupFn: FilterPropertyLookupFnType<Service> | ClassFunctionKeysWithReturnType<Service, Observable<FilterGenericPropertiesMetadataType>>, opts?: FilterGenericPropertyOptsType): LookupDataProviderInst<FilterGenericProperty, Service, keyof FilterGenericProperty, keyof FilterGenericProperty, Service extends undefined ? undefined : import("@mediusinc/mng-commons/core").ServiceClassType<Service>>;
44
- type FilterValueSuggestionLookupFnType<Service> = (service: Service, field: string, search?: string) => ItemOrObservable<string[]>;
45
- /**
46
- * Creates a data provider for generic filter value suggestions that can be used with the TableDescriptor's generic filter functionality.
47
- *
48
- * @param service - The service to use for suggesting filter values.
49
- * @param lookupFn - The function name of the service to call for suggestion or function impl returning suggestions.
50
- */
51
- export declare function filterValueSuggestionLookupProvider<Service>(service: Type<Service>, lookupFn: FilterValueSuggestionLookupFnType<Service> | ClassFunctionKeysWithParamAndReturnType<Service, {
52
- field: string;
53
- text?: string;
54
- }, Observable<string[]>>): LookupDataProviderInst<string, Service, string, 'field'>;
55
- export {};
@@ -1,29 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { ApiServiceGetAllFilterType, ExtractGetAllParamsFilterType, ExtractGetAllParamsSortType, ExtractServiceGetAllDataType, GetAllHttpResponseType } from '@mediusinc/mng-commons-data-api';
3
- import { ClassFunctionKeysWithAnyArgsAndReturnType, DataListSort, FilterMatchModeExtendedType, ServiceClassType } from '@mediusinc/mng-commons/core';
4
- import { LookupDataProviderInst } from '@mediusinc/mng-commons/form/api';
5
- /**
6
- * Creates lookup data provider with predefined lookup function based on API service GetAll function.
7
- *
8
- * @param {ServiceClassType<Service>} service - The API service instance used to perform the `getAll` call.
9
- * @param {GetAllFn} getAllFn - The function key of the `getAll` method in the service to be invoked.
10
- * @param [opts] - Optional configuration for the lookup.
11
- * @param [opts.search] - Search parameter definition for mapping to filter property or global search property - both cannot be used at the same time.
12
- * @param {ExtractGetAllParamsFilterType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>} [opts.search.filter.property] - The filter field used for search criteria.
13
- * @param {FilterMatchModeType} [opts.search.filter.matchMode] - The match mode used for the filter (e.g., contains, startsWith, etc.).
14
- * @param {FilterMatchModeType} [opts.search.globalSearch] - If search term is to be applied to global filter.
15
- * @param {Array<DataListSort<ExtractGetAllParamsSortType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>>>} [opts.sorts] - The sorting options to order the fetched data.
16
- * @param {number} [opts.limit] - The number of records to fetch.
17
- * @return {LookupDataProviderInst<ExtractServiceGetAllDataType<Service, GetAllFn>, Service, ExtractGetAllParamsSortType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>, ExtractGetAllParamsFilterType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>>} The lookup data provider instance configured with the lookup function.
18
- */
19
- export declare function lookupWithApiServiceGetAll<Service, GetAllFn extends ClassFunctionKeysWithAnyArgsAndReturnType<Service, Observable<GetAllHttpResponseType<any>>>>(service: ServiceClassType<Service>, getAllFn: GetAllFn, opts?: {
20
- search?: {
21
- filter?: {
22
- property: ExtractGetAllParamsFilterType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>;
23
- matchMode?: FilterMatchModeExtendedType;
24
- };
25
- globalFilter?: boolean;
26
- };
27
- sort?: DataListSort<ExtractGetAllParamsSortType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>>[];
28
- limit?: number;
29
- }): LookupDataProviderInst<ExtractServiceGetAllDataType<Service, GetAllFn>, Service, ExtractGetAllParamsSortType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>, ExtractGetAllParamsFilterType<ApiServiceGetAllFilterType<Service, any, GetAllFn>>>;
@@ -1,54 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { ApiServiceGetAllFilterType, ExtractGetAllParamsFilterType, ExtractGetAllParamsSortType, ExtractServiceGetAllDataType, GetAllHttpResponseType, GetAllParamsDefaultWoFiltersType } from '@mediusinc/mng-commons-data-api';
3
- import { ClassFunctionKeysWithAnyArgsAndReturnType, ServiceClassType } from '@mediusinc/mng-commons/core';
4
- import { ModelDescriptor, TypeDescriptor } from '@mediusinc/mng-commons/model';
5
- import { TableviewDataProviderInst, TableviewDescriptorFieldsManageMultiType, TableviewDescriptorInst, TableviewDescriptorInstConstructorOpts, TableviewInputBuilder } from '@mediusinc/mng-commons/tableview/api';
6
- type TableviewWithGetAllParamsOpts<RequestParam, TableModel, AddModel, EditModel> = {
7
- requestParamsType: TypeDescriptor<RequestParam>;
8
- } & TableviewDescriptorInstConstructorOpts<TableModel, AddModel, EditModel>;
9
- /**
10
- * Creates a tableview with a given model, service and sorts/filters extracted from Data API Get All request params, service, and optional build function.
11
- *
12
- * @param {ModelDescriptor<Model>} model - The model descriptor.
13
- * @param {ServiceClassType<Service>} service - The class type of the service.
14
- * @param {TypeDescriptor<RequestParam> | TableviewWithGetAllParamsOpts<RequestParam, TableModel>} paramsOrOpts - The request param of get all request. Filters and sorts will be taken from here.
15
- * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
16
- *
17
- * @returns A tableview instance with descriptor, data provider and actions.
18
- */
19
- export declare function tableviewWithGetAllParams<Model, Service, RequestParam extends GetAllParamsDefaultWoFiltersType, Sorts = ExtractGetAllParamsSortType<RequestParam>, Filters extends keyof any = ExtractGetAllParamsFilterType<RequestParam>>(model: ModelDescriptor<Model>, service: ServiceClassType<Service>, params: TypeDescriptor<RequestParam>, buildFn?: (builder: TableviewInputBuilder<Model, Service, TableviewDescriptorInst<Model, Sorts, Filters, undefined, Model, Model, Model, Model>, TableviewDataProviderInst<Model, Service, Sorts, Filters>, Sorts, Filters, Model, Model, Model, Model>) => void): import("@mediusinc/mng-commons/tableview/api").TableviewInput<Model, Service, Sorts, Filters, Model, Model, Model, TableviewDescriptorInst<Model, Sorts, Filters, undefined, Model, Model, Model, Model>, TableviewDataProviderInst<Model, Service, Sorts, Filters, import("@mediusinc/mng-commons/core").ServiceClassOptType<Service>, Model, Model, Model>>;
20
- /**
21
- * Creates a tableview with a mulit-model (separate for add, edit and details), service and sorts/filters from API service's provided getAll function.
22
- *
23
- * @param {ModelDescriptor<Model>} model - The model descriptor.
24
- * @param {ServiceClassType<Service>} service - The class type of the service.
25
- * @param {TableviewWithGetAllParamsOpts} opts - Options providing get all request parameters and models for table, add and edit.
26
- * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
27
- *
28
- * @returns A tableview instance with descriptor, data provider and actions.
29
- */
30
- export declare function tableviewMultiModelWithGetAllParams<Model, Service, RequestParam extends GetAllParamsDefaultWoFiltersType, Sorts = ExtractGetAllParamsSortType<RequestParam>, Filters extends keyof any = ExtractGetAllParamsFilterType<RequestParam>, TableModel = Model, AddModel = Model, EditModel = Model, FieldsModel = TableviewDescriptorFieldsManageMultiType<Model, AddModel, EditModel>>(model: ModelDescriptor<Model>, service: ServiceClassType<Service>, opts: Required<TableviewWithGetAllParamsOpts<RequestParam, TableModel, AddModel, EditModel>>, buildFn?: (builder: TableviewInputBuilder<Model, Service, TableviewDescriptorInst<Model, Sorts, Filters, undefined, TableModel, AddModel, EditModel, FieldsModel>, TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>, TableModel, AddModel, EditModel>, Sorts, Filters, TableModel, AddModel, EditModel, FieldsModel>) => void): import("@mediusinc/mng-commons/tableview/api").TableviewInput<Model, Service, Sorts, Filters, TableModel, AddModel, EditModel, TableviewDescriptorInst<Model, Sorts, Filters, undefined, TableModel, AddModel, EditModel, FieldsModel>, TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>, TableModel, AddModel, EditModel>>;
31
- /**
32
- * Creates a tableview with a given model, service and sorts/filters from API service's provided getAll function.
33
- *
34
- * @param {ModelDescriptor<Model>} model - The model descriptor.
35
- * @param {ServiceClassType<Service>} service - The class type of the service.
36
- * @param {GetAllFn} getAllFn - The function from service for executing getAll requests. Filters and sorts will be taken from here.
37
- * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
38
- *
39
- * @returns A tableview instance with descriptor, data provider and actions.
40
- */
41
- export declare function tableviewWithApiServiceGetAll<Model, Service, GetAllFn extends ClassFunctionKeysWithAnyArgsAndReturnType<Service, Observable<GetAllHttpResponseType<TableModel>>>, TableModel = ExtractServiceGetAllDataType<Service, GetAllFn>, RequestParams extends GetAllParamsDefaultWoFiltersType = ApiServiceGetAllFilterType<Service, TableModel, GetAllFn>, Sorts = ExtractGetAllParamsSortType<RequestParams>, Filters extends keyof any = ExtractGetAllParamsFilterType<RequestParams>>(model: ModelDescriptor<Model>, service: ServiceClassType<Service>, getAllFn: GetAllFn, buildFn?: (builder: TableviewInputBuilder<Model, Service, TableviewDescriptorInst<Model, Sorts, Filters, undefined, TableModel, Model, Model, Model>, TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>, TableModel>, Sorts, Filters, TableModel, Model, Model, Model>) => void): import("@mediusinc/mng-commons/tableview/api").TableviewInput<Model, Service, Sorts, Filters, TableModel, Model, Model, TableviewDescriptorInst<Model, Sorts, Filters, undefined, TableModel, Model, Model, Model>, TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>, TableModel, Model, Model>>;
42
- /**
43
- * Creates a tableview with a given model, service and sorts/filters from API service's provided getAll function.
44
- *
45
- * @param {ModelDescriptor<Model>} model - The model descriptor.
46
- * @param {ServiceClassType<Service>} service - The class type of the service.
47
- * @param {GetAllFn} serviceGetAllFn - The function from service for executing getAll requests. Filters and sorts will be taken from here.
48
- * @param {Required<TableviewDescriptorInstConstructorOpts<TableModel, AddModel, EditModel>>} - Required options: all remaining models for multi-tableview must be defined here.
49
- * @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
50
- *
51
- * @returns A tableview instance with descriptor, data provider and actions.
52
- */
53
- export declare function tableviewMultiModelWithApiServiceGetAll<Model, Service, ServiceGetAllFn extends ClassFunctionKeysWithAnyArgsAndReturnType<Service, Observable<GetAllHttpResponseType<TableModel>>>, TableModel, AddModel, EditModel, ServiceGetAllRequestParams extends GetAllParamsDefaultWoFiltersType = ApiServiceGetAllFilterType<Service, TableModel, ServiceGetAllFn>, Sorts = ExtractGetAllParamsSortType<ServiceGetAllRequestParams>, Filters extends keyof any = ExtractGetAllParamsFilterType<ServiceGetAllRequestParams>, FieldsModel = TableviewDescriptorFieldsManageMultiType<Model, AddModel, EditModel>>(model: ModelDescriptor<Model>, service: ServiceClassType<Service>, serviceGetAllFn: ServiceGetAllFn, opts: Required<TableviewDescriptorInstConstructorOpts<TableModel, AddModel, EditModel>>, buildFn?: (builder: TableviewInputBuilder<Model, Service, TableviewDescriptorInst<Model, Sorts, Filters, undefined, TableModel, AddModel, EditModel, FieldsModel>, TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>, TableModel, AddModel, EditModel>, Sorts, Filters, TableModel, AddModel, EditModel, FieldsModel>) => void): import("@mediusinc/mng-commons/tableview/api").TableviewInput<Model, Service, Sorts, Filters, TableModel, AddModel, EditModel, TableviewDescriptorInst<Model, Sorts, Filters, undefined, TableModel, AddModel, EditModel, FieldsModel>, TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>, TableModel, AddModel, EditModel>>;
54
- export {};
@@ -1,122 +0,0 @@
1
- import { SchemaEnum, SchemaModel, SchemaProperty } from '@mediusinc/mng-commons-data-api';
2
- import { GetterFn } from '@mediusinc/mng-commons/core';
3
- import { EnumDescriptor } from '@mediusinc/mng-commons/model';
4
- import { ColumnDescriptor, TableDescriptorInst } from '@mediusinc/mng-commons/table/api';
5
- import { TableviewDescriptorInst } from '@mediusinc/mng-commons/tableview/api';
6
- type ColumnType = 'number' | 'currency' | 'boolean' | 'string' | 'text' | 'textarea' | 'date' | 'date-time' | 'enum' | 'object';
7
- type ColumnFromSchemaCommonOptsType<Model> = {
8
- currencyProperty?: keyof Model;
9
- currency?: string;
10
- currencyDisplay?: 'symbol' | 'code' | 'name';
11
- dateFormat?: string;
12
- dateTimeFormat?: string;
13
- numberMinIntegerDigits?: number;
14
- numberMinFractionDigits?: number;
15
- numberMaxFractionDigits?: number;
16
- };
17
- type ColumnsFromSchemaOptsType<Model = any> = ColumnFromSchemaCommonOptsType<Model> & {
18
- columnTypes?: Partial<Record<keyof Model, ColumnType>>;
19
- enumModels?: Partial<Record<keyof Model, EnumDescriptor<any>>>;
20
- enumSchemas?: Partial<Record<keyof Model, SchemaEnum<any>>>;
21
- getters?: {
22
- [K in keyof Model]?: GetterFn<Model[K], Model>;
23
- };
24
- };
25
- type ColumnFromSchemaOptsType<Column = any, Model = any, Enum = any> = ColumnFromSchemaCommonOptsType<Model> & {
26
- columnType?: ColumnType;
27
- getter?: GetterFn<Column, Model>;
28
- enumModel?: EnumDescriptor<Enum>;
29
- enumSchema?: SchemaEnum<Enum>;
30
- };
31
- /**
32
- * <em>Experimental:</em> Builder for adding columns to table.
33
- *
34
- * @experimental
35
- */
36
- export declare class SchemaColumnsBuilder<Model, SchModel = Model> {
37
- private readonly descriptor;
38
- private readonly schema;
39
- private opts?;
40
- constructor(descriptor: TableviewDescriptorInst<Model, any, any, any> | TableDescriptorInst<Model, any, any>, schema: SchemaModel<SchModel>, opts?: ColumnsFromSchemaOptsType<SchModel> | undefined);
41
- private mergeColumnsOpts;
42
- private mergeColumnOpts;
43
- /**
44
- * <em>Experimental:</em> Adds a single column via {addColumnFromSchema}.
45
- *
46
- * @experimental
47
- *
48
- * @param {Property} property - The property to add the column for.
49
- * @param {ColumnFromSchemaOptsType<SchModel[Property], SchModel, any, Model>} opts - Additional options.
50
- *
51
- * @return {ColumnDescriptor<NonNullable<Model[Property]>, Model, Model[Property]>} The added column descriptor.
52
- */
53
- add<Property extends Extract<keyof Model, keyof SchModel>>(property: Property, opts?: ColumnFromSchemaOptsType<SchModel[Property], SchModel, any>): ColumnDescriptor<NonNullable<Model[Property]>, Model, Model[Property]>;
54
- /**
55
- * <em>Experimental:</em> Adds all columns from the non-array schema properties via {addColumnFromSchema}.
56
- *
57
- * @experimental
58
- *
59
- * @param {ColumnsFromSchemaOptsType<SchModel>} opts - Additional options.
60
- *
61
- * @return {this} - The current instance of the builder.
62
- */
63
- withAddAll(opts?: ColumnsFromSchemaOptsType<SchModel>): this;
64
- /**
65
- * <em>Experimental:</em> Adds columns for properties via {addColumnFromSchema}.
66
- *
67
- * @experimental
68
- *
69
- * @param {ColumnsFromSchemaOptsType<SchModel>} opts - Additional options.
70
- * @param {...Property[]} properties - Properties to add columns for. If non provided, all non-array properties from schema will be added.
71
- *
72
- * @return {this} - The current instance of the builder.
73
- */
74
- withAdd<Property extends Extract<keyof Model, keyof SchModel>>(opts: ColumnsFromSchemaOptsType<SchModel>, ...properties: Property[]): this;
75
- /**
76
- * <em>Experimental:</em> Adds columns for properties via {addColumnFromSchema}.
77
- *
78
- * @experimental
79
- *
80
- * @param {...Property[]} properties - Properties to add columns for. If non provided, all non-array properties from schema will be added.
81
- *
82
- * @return {this} - The current instance of the builder.
83
- */
84
- withAdd<Property extends Extract<keyof Model, keyof SchModel>>(...properties: Property[]): this;
85
- /**
86
- * <em>Experimental:</em> Adds a single column via {addColumnFromSchema} where property schema is manually provided.
87
- *
88
- * @experimental
89
- *
90
- * @param {Property} property - The property to add the column for.
91
- * @param {SchemaProperty} schemaProperty - Manually provided schema property.
92
- * @param {ColumnFromSchemaOptsType} opts - Additional options.
93
- *
94
- * @return {ColumnDescriptor<NonNullable<Model[Property]>, Model, Model[Property]>} The added column descriptor.
95
- */
96
- addFromSchema<Property extends keyof Model>(property: Property, schemaProperty: SchemaProperty, opts?: ColumnFromSchemaOptsType<Model[Property], Model>): ColumnDescriptor<NonNullable<Model[Property]>, Model, Model[Property]>;
97
- private addColumns;
98
- }
99
- /**
100
- * <em>Experimental:</em> Creates builder for adding columns to descriptor based on provided model schema.
101
- *
102
- * @experimental
103
- *
104
- * @param {TableviewDescriptorInst<Model, any, any, any> | TableDescriptorInst<Model, any, any>} descriptor - Descriptor to add columns to.
105
- * @param {SchemaModel<SchModel>} schema - The schema with metadata about properties for fields.
106
- * @param {ColumnsFromSchemaOptsType<SchModel>} [opts] - Additional options.
107
- *
108
- * @return {SchemaColumnsBuilder<Model, SchModel>} - The column schema builder instance.
109
- */
110
- export declare function columnsFromSchema<Model, SchModel = Model>(descriptor: TableviewDescriptorInst<any, any, any, any, Model, any, any, any> | TableDescriptorInst<Model, any, any>, schema: SchemaModel<SchModel>, opts?: ColumnsFromSchemaOptsType<SchModel>): SchemaColumnsBuilder<Model, SchModel>;
111
- /**
112
- * <em>Experimental:</em> Adds a column to table descriptor based on the given schema property and options.
113
- *
114
- * @param {TableviewDescriptorInst<Model, any, any, any> | TableDescriptorInst<Model, any, any>} descriptor - The table view descriptor or table descriptor to add the column to.
115
- * @param {Property} property - The property key of the model to create the column for.
116
- * @param {SchemaProperty} propertySchema - The schema property for the property.
117
- * @param {ColumnFromSchemaOptsType<Model[Property], Model, any, Model>} [opts] - The options for the column.
118
- *
119
- * @return {ColumnDescriptor<NonNullable<Model[Property]>, Model, Model[Property]>} - The added column descriptor.
120
- */
121
- export declare function addColumnFromSchema<Property extends keyof TableModel, Model, TableModel = Model>(descriptor: TableviewDescriptorInst<Model, any, any, any, TableModel, any, any, any> | TableDescriptorInst<TableModel, any, any>, property: Property, propertySchema: SchemaProperty, opts?: ColumnFromSchemaOptsType<TableModel[Property], TableModel, any>): ColumnDescriptor<NonNullable<TableModel[Property]>, TableModel, TableModel[Property]>;
122
- export {};
@@ -1,12 +0,0 @@
1
- import { SchemaEnum } from '@mediusinc/mng-commons-data-api';
2
- import { EnumDescriptor } from '@mediusinc/mng-commons/model';
3
- /**
4
- * <em>Experimental:</em> Emulates an enum model object from enum schema.
5
- *
6
- * @experimental
7
- *
8
- * @param {SchemaEnum<Enum>} enumSchema - The schema of the enum.
9
- *
10
- * @returns {EnumDescriptor<Enum>} - The generated enum model descriptor.
11
- */
12
- export declare function enumModelFromSchema<Enum>(enumSchema: SchemaEnum<Enum>): EnumDescriptor<Enum>;