@mediusinc/mng-commons-class 8.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.
- package/README.md +7 -0
- package/fesm2022/mediusinc-mng-commons-class-model.mjs +100 -0
- package/fesm2022/mediusinc-mng-commons-class-model.mjs.map +1 -0
- package/fesm2022/mediusinc-mng-commons-class-table.mjs +205 -0
- package/fesm2022/mediusinc-mng-commons-class-table.mjs.map +1 -0
- package/fesm2022/mediusinc-mng-commons-class-tableview.mjs +375 -0
- package/fesm2022/mediusinc-mng-commons-class-tableview.mjs.map +1 -0
- package/fesm2022/mediusinc-mng-commons-class.mjs +191 -0
- package/fesm2022/mediusinc-mng-commons-class.mjs.map +1 -0
- package/model/README.md +8 -0
- package/package.json +41 -0
- package/table/README.md +10 -0
- package/tableview/README.md +13 -0
- package/types/mediusinc-mng-commons-class-model.d.ts +26 -0
- package/types/mediusinc-mng-commons-class-table.d.ts +78 -0
- package/types/mediusinc-mng-commons-class-tableview.d.ts +142 -0
- package/types/mediusinc-mng-commons-class.d.ts +77 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mediusinc-mng-commons-class.mjs","sources":["../../src/lib/reflect/type-enum-metadata.ts","../../src/lib/reflect/type-enum-decorator.ts","../../src/lib/registry/type-registry.ts","../../src/index.ts","../../src/mediusinc-mng-commons-class.ts"],"sourcesContent":["import 'reflect-metadata';\n\nimport {ClassType, EnumType, LoggerService} from '@mediusinc/mng-commons/core';\n\nexport const reflectTypeNameKey = 'typeName';\nexport const reflectEnumNameKey = 'enumName';\n\n/**\n * Defines type name decorator.\n * @param targetType class.\n * @param typeName Name of the type.\n */\nexport function defineReflectTypeName(targetType: ClassType<any>, typeName: string) {\n if (!Reflect.hasOwnMetadata(reflectTypeNameKey, targetType)) {\n Reflect.defineMetadata(reflectTypeNameKey, typeName, targetType);\n }\n}\n\n/**\n * Defines enum name decorator.\n * @param targetType enum object.\n * @param enumName Name of the enum.\n */\nexport function defineReflectEnumName(targetType: EnumType, enumName: string) {\n if (!Reflect.hasOwnMetadata(reflectEnumNameKey, targetType)) {\n Reflect.defineMetadata(reflectEnumNameKey, enumName, targetType);\n }\n}\n\n/**\n * Gets type name from reflect metadata.\n * @param type Class.\n */\nexport function findReflectTypeName<T>(type?: ClassType<T>): string | null {\n if (!type) {\n return null;\n }\n const typeName = Reflect.getMetadata(reflectTypeNameKey, type);\n if (typeName) {\n return typeName;\n }\n LoggerService.get().debug('WARNING: Reflect metadata could not be found for type, you might experience some issues in production build.', type?.name);\n return type.name;\n}\n\n/**\n * Gets type name from either decorator or reflect metadata.\n * @param type Class.\n */\nexport function reflectTypeNameExists(type: ClassType<any>): boolean {\n return Reflect.hasOwnMetadata(reflectTypeNameKey, type);\n}\n\n/**\n * Gets enum name from either decorator or reflect metadata.\n * @param enumType Class.\n */\nexport function findReflectEnumName(enumType: EnumType): string | null {\n const enumName = Reflect.getMetadata(reflectEnumNameKey, enumType);\n if (enumName) {\n return enumName;\n }\n LoggerService.get().debug(`WARNING: Reflect metadata could not be found for enum ${typeof enumType === 'object' ? Object.keys(enumType) : enumType}`, {\n name: 'TypeUtilsError',\n enumType: enumType\n });\n return null;\n}\n","import {defineReflectEnumName, defineReflectTypeName} from './type-enum-metadata';\n\nexport function TypeName(typeName: string): ClassDecorator {\n return function (target: any) {\n defineReflectTypeName(target, typeName);\n };\n}\n\nexport function EnumName(typeName: string): ClassDecorator {\n return function (target: any) {\n defineReflectEnumName(target, typeName);\n };\n}\n","import {ClassType, EnumType, LogLevelEnum, LoggerService} from '@mediusinc/mng-commons/core';\n\nimport {ClassAttributeDef} from '../models/class-attribute.model';\nimport {defineReflectEnumName, defineReflectTypeName, findReflectTypeName, reflectTypeNameExists} from '../reflect/type-enum-metadata';\nimport {RegistryEnumMap, RegistryTypeMap} from './registry.model';\n\nexport class TypeRegistry {\n private static _instance: TypeRegistry = new TypeRegistry();\n private readonly _logCategory = 'TypeRegistry';\n private readonly _typeMap: RegistryTypeMap = {};\n private readonly _enumMap: RegistryEnumMap = {};\n\n public get typeMap() {\n return this._typeMap;\n }\n\n public get enumMap() {\n return this._enumMap;\n }\n\n /**\n * Only use one instance of object (out of Angular context)\n */\n public static get(): TypeRegistry {\n return TypeRegistry._instance;\n }\n\n public findAttributeDefinitionByClassType(type: ClassType<any>, attributeName: string): ClassAttributeDef | null {\n const typeName = findReflectTypeName(type);\n return typeName ? this.findAttributeDefinition(typeName, attributeName) : null;\n }\n\n public findAttributeDefinition(typeName: string, attributeName: string): ClassAttributeDef | null {\n const attributeDefs = this.findAttributesDefinition(typeName);\n if (!attributeDefs) {\n return null;\n }\n for (const attribute of attributeDefs) {\n if (attribute.name === attributeName) {\n return attribute;\n }\n }\n return null;\n }\n\n public findAttributesDefinitionByClassType(type: ClassType<any>): Array<ClassAttributeDef> | null {\n const typeName = findReflectTypeName(type);\n return typeName ? this.findAttributesDefinition(typeName) : null;\n }\n\n public findAttributesDefinition(typeName: string): Array<ClassAttributeDef> | null {\n const typeDef = this.findType(typeName);\n if (!typeDef || typeof typeDef.getAttributeTypeMap !== 'function') {\n return null;\n }\n return typeDef.getAttributeTypeMap() as Array<ClassAttributeDef>;\n }\n\n public findByClassType(type: ClassType<any>): any {\n const typeName = findReflectTypeName(type);\n return typeName ? this.findType(typeName) : null;\n }\n\n public findType(typeName: string): any {\n return this._typeMap[typeName];\n }\n\n public findEnum(enumName: string): any {\n return this._enumMap[enumName];\n }\n\n public registerTypes(types: RegistryTypeMap) {\n for (const key in types) {\n this.registerType(types[key], key);\n }\n }\n\n public registerType(type: ClassType<any>, optTypeName?: string) {\n // try to find name from metadata\n let typeName: string | undefined;\n if (reflectTypeNameExists(type)) {\n // defined name from optional type name\n typeName = findReflectTypeName(type) ?? undefined;\n } else if (optTypeName) {\n typeName = optTypeName;\n // register metadata\n defineReflectTypeName(type, typeName);\n }\n\n if (!typeName) {\n // this._logger.debug(`WARNING: registering type ${type} failed, because typeName could not be determined and optional name was not provided.`);\n LoggerService.get().log(\n `WARNING: registering type ${type} failed, because typeName could not be determined and optional name was not provided.`,\n LogLevelEnum.Debug,\n this._logCategory\n );\n return;\n }\n if (typeof this._typeMap[typeName] !== 'undefined') {\n // this._logger.debug(`WARNING: registering type ${type} under key ${typeName} skipped, because type already exists for this key.`);\n LoggerService.get().log(\n `WARNING: registering type ${type} under key ${typeName} skipped, because type already exists for this key.`,\n LogLevelEnum.Debug,\n this._logCategory\n );\n } else {\n this._typeMap[typeName] = type;\n }\n }\n\n public clearTypes() {\n Object.keys(this._typeMap).forEach(key => delete this._typeMap[key]);\n }\n\n public registerEnums(enums: RegistryEnumMap) {\n for (const key in enums) {\n this.registerEnum(enums[key], key);\n }\n }\n\n public registerEnum(enumType: EnumType, enumName: string) {\n // try to find name from decorator\n defineReflectEnumName(enumType, enumName);\n if (typeof this._enumMap[enumName] !== 'undefined') {\n LoggerService.get().log(`Registering enum ${enumName} skipped, because enum already exists.`, LogLevelEnum.Debug, this._logCategory);\n } else {\n this._enumMap[enumName] = enumType;\n }\n }\n\n public clearEnums() {\n Object.keys(this._enumMap).forEach(key => delete this._enumMap[key]);\n }\n}\n","// model\nexport * from './lib/models/class-attribute.model';\n\n// reflect\nexport * from './lib/reflect/type-enum-decorator';\nexport * from './lib/reflect/type-enum-metadata';\n\n// registry\nexport * from './lib/registry/registry.model';\nexport * from './lib/registry/type-registry';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAIO,MAAM,kBAAkB,GAAG;AAC3B,MAAM,kBAAkB,GAAG;AAElC;;;;AAIG;AACG,SAAU,qBAAqB,CAAC,UAA0B,EAAE,QAAgB,EAAA;IAC9E,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAAE;QACzD,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,QAAQ,EAAE,UAAU,CAAC;IACpE;AACJ;AAEA;;;;AAIG;AACG,SAAU,q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AAA,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ;QACtC;IACJ;IAEO,UAAU,GAAA;QACb,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACxE;;;ACpIJ;;ACAA;;AAEG;;"}
|
package/model/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# @mediusinc/mng-commons/model/class
|
|
2
|
+
|
|
3
|
+
Secondary entry point of `@mediusinc/mng-commons`. It can be used by importing from `@mediusinc/mng-commons/model/class`.
|
|
4
|
+
|
|
5
|
+
## Dependencies within commons
|
|
6
|
+
|
|
7
|
+
- `@mediusinc/mng-commons/core`
|
|
8
|
+
- `@mediusinc/mng-commons/model`
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mediusinc/mng-commons-class",
|
|
3
|
+
"version": "8.0.0-rc.0",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^22.1.0",
|
|
6
|
+
"@angular/core": "^22.1.0",
|
|
7
|
+
"@mediusinc/mng-commons": "~8.0.0-rc.0"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"reflect-metadata": "^0.2.2",
|
|
11
|
+
"tslib": "^2.8.1"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"directory": "dist"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"module": "fesm2022/mediusinc-mng-commons-class.mjs",
|
|
18
|
+
"typings": "types/mediusinc-mng-commons-class.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./package.json": {
|
|
21
|
+
"default": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./types/mediusinc-mng-commons-class.d.ts",
|
|
25
|
+
"default": "./fesm2022/mediusinc-mng-commons-class.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./model": {
|
|
28
|
+
"types": "./types/mediusinc-mng-commons-class-model.d.ts",
|
|
29
|
+
"default": "./fesm2022/mediusinc-mng-commons-class-model.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./table": {
|
|
32
|
+
"types": "./types/mediusinc-mng-commons-class-table.d.ts",
|
|
33
|
+
"default": "./fesm2022/mediusinc-mng-commons-class-table.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./tableview": {
|
|
36
|
+
"types": "./types/mediusinc-mng-commons-class-tableview.d.ts",
|
|
37
|
+
"default": "./fesm2022/mediusinc-mng-commons-class-tableview.mjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"type": "module"
|
|
41
|
+
}
|
package/table/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @mediusinc/mng-commons/table/api
|
|
2
|
+
|
|
3
|
+
Secondary entry point of `@mediusinc/mng-commons`. It can be used by importing from `@mediusinc/mng-commons/table/api/class`.
|
|
4
|
+
|
|
5
|
+
## Dependencies within commons
|
|
6
|
+
|
|
7
|
+
- `@mediusinc/mng-commons/core`
|
|
8
|
+
- `@mediusinc/mng-commons/model`
|
|
9
|
+
- `@mediusinc/mng-commons/model/class`
|
|
10
|
+
- `@mediusinc/mng-commons/table/api`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @mediusinc/mng-commons/tableview/api
|
|
2
|
+
|
|
3
|
+
Secondary entry point of `@mediusinc/mng-commons`. It can be used by importing from `@mediusinc/mng-commons/tableview/api/class`.
|
|
4
|
+
|
|
5
|
+
## Dependencies within commons
|
|
6
|
+
|
|
7
|
+
- `@mediusinc/mng-commons/core`
|
|
8
|
+
- `@mediusinc/mng-commons/model`
|
|
9
|
+
- `@mediusinc/mng-commons/model/class`
|
|
10
|
+
- `@mediusinc/mng-commons/filter`
|
|
11
|
+
- `@mediusinc/mng-commons/form/api`
|
|
12
|
+
- `@mediusinc/mng-commons/table/api`
|
|
13
|
+
- `@mediusinc/mng-commons/tableview/api`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClassType, DataProviderInst, ServiceClassType, IModelDescriptor } from '@mediusinc/mng-commons/core';
|
|
2
|
+
import { ModelDescriptor, ModelDescriptorCreateOpts, TypeDescriptor } from '@mediusinc/mng-commons/model';
|
|
3
|
+
import { ClassAttributeDef } from '@mediusinc/mng-commons-class';
|
|
4
|
+
|
|
5
|
+
declare function dataProviderFromClass<Model>(type: ClassType<Model>): DataProviderInst<Model, undefined, undefined>;
|
|
6
|
+
declare function dataProviderFromClass<Model, Service = any>(type: ClassType<Model>, ServiceClass: ServiceClassType<Service>): DataProviderInst<Model, Service, ServiceClassType<Service>>;
|
|
7
|
+
|
|
8
|
+
declare class ModelClassDescriptor<Model> extends ModelDescriptor<Model> implements IModelDescriptor<Model> {
|
|
9
|
+
private readonly _classType;
|
|
10
|
+
constructor(_type: ClassType<Model>, idProperty?: string, titleProperty?: string | ((item: Model) => string), i18nBaseKey?: string);
|
|
11
|
+
get classType(): ClassType<Model>;
|
|
12
|
+
copy(): ModelClassDescriptor<Model>;
|
|
13
|
+
}
|
|
14
|
+
type ModelClassDescriptorCreateOpts<Model> = Omit<ModelDescriptorCreateOpts<Model>, 'i18nBase'> & {
|
|
15
|
+
i18nBase?: string | ClassType<unknown>;
|
|
16
|
+
};
|
|
17
|
+
declare function modelClass<Model>(type: ClassType<Model>, opts?: ModelClassDescriptorCreateOpts<Model>): ModelClassDescriptor<Model>;
|
|
18
|
+
|
|
19
|
+
declare function typeFromClass<Type>(type: ClassType<Type>): TypeDescriptor<Type>;
|
|
20
|
+
|
|
21
|
+
declare function findClassIdAttribute<T>(classType?: ClassType<T>): string | null;
|
|
22
|
+
declare function findClassTitleAttribute<T>(classType?: ClassType<T>): string | null;
|
|
23
|
+
declare function getClassAttributeDef<T>(classType?: ClassType<T>): ClassAttributeDef[] | null;
|
|
24
|
+
|
|
25
|
+
export { ModelClassDescriptor, dataProviderFromClass, findClassIdAttribute, findClassTitleAttribute, getClassAttributeDef, modelClass, typeFromClass };
|
|
26
|
+
export type { ModelClassDescriptorCreateOpts };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ClassAttributeDef } from '@mediusinc/mng-commons-class';
|
|
2
|
+
import { EnumType, ClassType, ServiceClassType, ILookupDataProvider } from '@mediusinc/mng-commons/core';
|
|
3
|
+
import { ColumnTypeEnum, ColumnDisplayTypeEnum, TableDataProviderInst, TableDescriptorCreateOptsType, TableDescriptorInst, ColumnDescriptor } from '@mediusinc/mng-commons/table/api';
|
|
4
|
+
import { FilterLookupDescriptor } from '@mediusinc/mng-commons/filter';
|
|
5
|
+
import { EnumDescriptor } from '@mediusinc/mng-commons/model';
|
|
6
|
+
|
|
7
|
+
interface TableClassAttributeDef extends ClassAttributeDef {
|
|
8
|
+
columnType: ColumnTypeEnum;
|
|
9
|
+
columnDisplayType: ColumnDisplayTypeEnum;
|
|
10
|
+
enumType?: EnumType;
|
|
11
|
+
classType?: ClassType<any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* converts string type to column type enum, default is string
|
|
16
|
+
* @param attributeType
|
|
17
|
+
*/
|
|
18
|
+
declare function getColumnTypeFromClassAttributeDefType(attributeType: string): ColumnTypeEnum;
|
|
19
|
+
declare function getColumnDisplayTypeFromColumnType(columnType: ColumnTypeEnum, attributeType: string): ColumnDisplayTypeEnum;
|
|
20
|
+
declare function expandClassAttributeDefWithTableDef(attributes?: Array<ClassAttributeDef> | null): TableClassAttributeDef[];
|
|
21
|
+
/**
|
|
22
|
+
* returns attributes from class type and extends to typed def with column and field enum type
|
|
23
|
+
* @param type class type
|
|
24
|
+
*/
|
|
25
|
+
declare function getTableClassAttributeDef<T>(type: ClassType<T>): TableClassAttributeDef[];
|
|
26
|
+
|
|
27
|
+
declare function tableDataProviderFromClass<Model, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>): TableDataProviderInst<Model, undefined, Sorts, Filters, undefined>;
|
|
28
|
+
declare function tableDataProviderFromClass<Model, Service = any, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>, serviceType: ServiceClassType<Service>): TableDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>>;
|
|
29
|
+
|
|
30
|
+
declare function tableDescriptorFromClass<TableModel, Sorts = keyof TableModel, Filters = keyof TableModel>(type: ClassType<TableModel>, opts?: TableDescriptorCreateOptsType<TableModel, Sorts, Filters>): TableDescriptorInst<TableModel, Sorts, Filters>;
|
|
31
|
+
/**
|
|
32
|
+
* generates descriptor based on type attribute definition
|
|
33
|
+
* @param type class type
|
|
34
|
+
* @param attributes
|
|
35
|
+
* @param opts
|
|
36
|
+
*/
|
|
37
|
+
declare function tableDescriptorFromClassAttrsDef<TableModel, Sorts = keyof TableModel, Filters = keyof TableModel>(type: ClassType<TableModel>, attributes?: TableClassAttributeDef[], opts?: TableDescriptorCreateOptsType<TableModel, Sorts, Filters>): TableDescriptorInst<TableModel, Sorts, Filters>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* generates column based on attributes
|
|
41
|
+
* @param desc Table descriptor
|
|
42
|
+
* @param attribute attribute map
|
|
43
|
+
* @param column if provided, replaced by new, otherwise new is created
|
|
44
|
+
* @param args additional parameters
|
|
45
|
+
*/
|
|
46
|
+
declare function upsertTableColumnFromAttributeDef<ColumnModel, TableModel>(desc: TableDescriptorInst<TableModel, any, any>, attribute: TableClassAttributeDef, column?: ColumnDescriptor<ColumnModel, TableModel>, ...args: any[]): ColumnDescriptor<ColumnModel, TableModel>;
|
|
47
|
+
/**
|
|
48
|
+
* defines modified type of column
|
|
49
|
+
* DO NOT USE with enum (use withCustomEnumType)
|
|
50
|
+
* @param descriptor table descriptor
|
|
51
|
+
* @param property column name
|
|
52
|
+
* @param columnType modified type
|
|
53
|
+
* @param args additional attributes
|
|
54
|
+
* @param columnDisplayType
|
|
55
|
+
*/
|
|
56
|
+
declare function modifyTableClassAttributeColumnType<TableModel, Property extends keyof TableModel, ColumnModel = NonNullable<TableModel[Property]>, ColumnValue = TableModel[Property]>(descriptor: TableDescriptorInst<TableModel, any, any>, property: Property, columnType?: ColumnTypeEnum, columnDisplayType?: ColumnDisplayTypeEnum, ...args: any[]): ColumnDescriptor<ColumnModel, TableModel, ColumnValue> | null;
|
|
57
|
+
declare function modifyTableClassAttributeColumnTypeUnsafe<TableModel, ColumnModel = any, ColumnValue = ColumnModel>(descriptor: TableDescriptorInst<TableModel, any, any>, property: string, columnType?: ColumnTypeEnum, columnDisplayType?: ColumnDisplayTypeEnum, ...args: any[]): ColumnDescriptor<ColumnModel, TableModel, ColumnValue> | null;
|
|
58
|
+
/**
|
|
59
|
+
* defines custom enum type for column
|
|
60
|
+
* @param descriptor table descriptor
|
|
61
|
+
* @param property column name
|
|
62
|
+
* @param enumDesc Enum descriptor.
|
|
63
|
+
*/
|
|
64
|
+
declare function modifyTableClassAttributeColumnEnum<TableModel, Property extends keyof TableModel, Enum extends NonNullable<TableModel[Property]>, ColumnModel = NonNullable<TableModel[Property]>, ColumnValue = TableModel[Property]>(descriptor: TableDescriptorInst<TableModel, any, any>, property: Property, enumDesc?: EnumDescriptor<Enum>): ColumnDescriptor<ColumnModel, TableModel, ColumnValue> | null;
|
|
65
|
+
declare function tableDescriptorModifyEnumColumnUnsafe<TableModel, Enum = any, ColumnModel = any, ColumnValue = ColumnModel>(descriptor: TableDescriptorInst<TableModel, any, any>, property: string, enumDesc?: EnumDescriptor<Enum>): ColumnDescriptor<ColumnModel, TableModel, ColumnValue> | null;
|
|
66
|
+
/**
|
|
67
|
+
* modifies column with class and lookup provider
|
|
68
|
+
* @param descriptor table descriptor
|
|
69
|
+
* @param property column name
|
|
70
|
+
* @param lookupProvider lookupProvider for class
|
|
71
|
+
* @param optionsLabelProperty
|
|
72
|
+
* @param filterProperty
|
|
73
|
+
*/
|
|
74
|
+
declare function modifyTableColumnFilterLookup<TableModel, Property extends keyof TableModel, Service, ColumnModel = NonNullable<TableModel[Property]>>(descriptor: TableDescriptorInst<TableModel, any, any>, property: Property, lookupProvider?: ILookupDataProvider<ColumnModel, any>, optionsLabelProperty?: keyof ColumnModel, filterProperty?: keyof ColumnModel): FilterLookupDescriptor<ColumnModel, TableModel, Service> | null;
|
|
75
|
+
declare function modifyTableColumnFilterLookupUnsafe<TableModel, Service, ColumnModel>(descriptor: TableDescriptorInst<TableModel, any, any>, property: string, lookupProvider?: ILookupDataProvider<ColumnModel, Service>, optionsLabelProperty?: string, filterProperty?: string): FilterLookupDescriptor<ColumnModel, TableModel, Service> | null;
|
|
76
|
+
|
|
77
|
+
export { expandClassAttributeDefWithTableDef, getColumnDisplayTypeFromColumnType, getColumnTypeFromClassAttributeDefType, getTableClassAttributeDef, modifyTableClassAttributeColumnEnum, modifyTableClassAttributeColumnType, modifyTableClassAttributeColumnTypeUnsafe, modifyTableColumnFilterLookup, modifyTableColumnFilterLookupUnsafe, tableDataProviderFromClass, tableDescriptorFromClass, tableDescriptorFromClassAttrsDef, tableDescriptorModifyEnumColumnUnsafe, upsertTableColumnFromAttributeDef };
|
|
78
|
+
export type { TableClassAttributeDef };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ClassAttributeDef } from '@mediusinc/mng-commons-class';
|
|
2
|
+
import { ClassType, EnumType, ServiceClassType, ILookupDataProvider } from '@mediusinc/mng-commons/core';
|
|
3
|
+
import { FieldInputTypeEnum, EditorDataProviderInst, EditorDescriptorCreateOptsType, EditorDescriptorInst, AFieldDescriptor, FieldLookupDescriptor, TableviewDescriptorCreateMultiModelWithModelDescriptorOptsType, TableviewDescriptorInst, TableviewDataProviderInst } from '@mediusinc/mng-commons/tableview/api';
|
|
4
|
+
import { ColumnTypeEnum, ColumnDisplayTypeEnum } from '@mediusinc/mng-commons/table/api';
|
|
5
|
+
import { EnumDescriptor } from '@mediusinc/mng-commons/model';
|
|
6
|
+
import { TableClassAttributeDef } from '@mediusinc/mng-commons-class/table';
|
|
7
|
+
|
|
8
|
+
interface EditorClassAttributeDef extends ClassAttributeDef {
|
|
9
|
+
classType?: ClassType<any>;
|
|
10
|
+
fieldType?: FieldInputTypeEnum;
|
|
11
|
+
enumType?: EnumType;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* converts string type to type enum, default is text
|
|
16
|
+
* @param attributeType
|
|
17
|
+
*/
|
|
18
|
+
declare function getFieldInputTypeFromClassAttributeDefType(attributeType: string): FieldInputTypeEnum;
|
|
19
|
+
/**
|
|
20
|
+
* convert column type to equivalent field input type
|
|
21
|
+
* @param type column type
|
|
22
|
+
* @param displayType column display type
|
|
23
|
+
*/
|
|
24
|
+
declare function getFieldInputTypeFromColumnType(type: ColumnTypeEnum, displayType?: ColumnDisplayTypeEnum): FieldInputTypeEnum;
|
|
25
|
+
declare function expandClassAttributeDefWithEditorDef(attributes?: Array<ClassAttributeDef> | null): EditorClassAttributeDef[];
|
|
26
|
+
/**
|
|
27
|
+
* returns attributes from class type and extends to typed def with column and field enum type
|
|
28
|
+
* @param type class type
|
|
29
|
+
*/
|
|
30
|
+
declare function getEditorClassAttributeDef<T>(type: ClassType<T>): EditorClassAttributeDef[];
|
|
31
|
+
|
|
32
|
+
declare function editorDataProviderFromClass<Model>(type: ClassType<Model>): EditorDataProviderInst<Model, undefined, undefined>;
|
|
33
|
+
declare function editorDataProviderFromClass<Model, Service = any>(type: ClassType<Model>, serviceType: ServiceClassType<Service>): EditorDataProviderInst<Model, Service, ServiceClassType<Service>>;
|
|
34
|
+
|
|
35
|
+
declare function editorDescriptorFromClass<EditorModel, ParentEditorModel = undefined>(type: ClassType<EditorModel>, opts?: EditorDescriptorCreateOptsType<EditorModel, ParentEditorModel>): EditorDescriptorInst<EditorModel, ParentEditorModel>;
|
|
36
|
+
/**
|
|
37
|
+
* Generates descriptor based on type attribute definition
|
|
38
|
+
* @param type class type
|
|
39
|
+
* @param attributes
|
|
40
|
+
* @param opts
|
|
41
|
+
*/
|
|
42
|
+
declare function editorDescriptorFromClassAttrsDef<EditorModel, ParentEditorModel = undefined>(type: ClassType<EditorModel>, attributes?: EditorClassAttributeDef[], opts?: EditorDescriptorCreateOptsType<EditorModel, ParentEditorModel>): EditorDescriptorInst<EditorModel, ParentEditorModel>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Generates field based on attribute definition, used for auto model
|
|
46
|
+
* @param descriptor Editor descriptor instance.
|
|
47
|
+
* @param attribute Attribute definition.
|
|
48
|
+
* @param field Optional, if defined will be replaced, otherwise new will be generated.
|
|
49
|
+
* @param args Optional additional arguments mapped to filed type. Arguments depend on possible arguments on fields.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
declare function upsertEditorFieldFromAttributeDef<T>(descriptor: EditorDescriptorInst<T, any>, attribute: EditorClassAttributeDef, field?: AFieldDescriptor<any, T>, ...args: any[]): AFieldDescriptor<any, T>;
|
|
53
|
+
/**
|
|
54
|
+
* Modifies selected field by field property. For enums use {withFieldModifiedEnum} instead.
|
|
55
|
+
* @param descriptor Editor descriptor.
|
|
56
|
+
* @param property Model's property name.
|
|
57
|
+
* @param fieldType new field type for selected field
|
|
58
|
+
* @param args additional parameters for field
|
|
59
|
+
*/
|
|
60
|
+
declare function modifyEditorClassAttributeFieldType<EditorModel, Property extends keyof EditorModel, FieldModel = NonNullable<EditorModel[Property]>, FieldValue = EditorModel[Property]>(descriptor: EditorDescriptorInst<EditorModel, any>, property: Property, fieldType: FieldInputTypeEnum, ...args: any[]): AFieldDescriptor<FieldModel, EditorModel, FieldValue> | null;
|
|
61
|
+
declare function modifyEditorClassAttributeFieldTypeUnsafe<EditorModel, FieldModel = any, FieldValue = FieldModel>(descriptor: EditorDescriptorInst<EditorModel, any>, property: string, fieldType: FieldInputTypeEnum, ...args: any[]): AFieldDescriptor<FieldModel, EditorModel, FieldValue> | null;
|
|
62
|
+
/**
|
|
63
|
+
* Modifies selected field with enum type.
|
|
64
|
+
* @param descriptor Editor descriptor.
|
|
65
|
+
* @param property Model's property name.
|
|
66
|
+
* @param enumModel Enum descriptor.
|
|
67
|
+
* @param values
|
|
68
|
+
*/
|
|
69
|
+
declare function modifyEditorClassAttributeFieldEnum<EditorModel, Property extends keyof EditorModel, Enum extends NonNullable<EditorModel[Property]>, FieldModel = NonNullable<EditorModel[Property]>, FieldValue = EditorModel[Property]>(descriptor: EditorDescriptorInst<EditorModel, any>, property: Property, enumModel?: EnumDescriptor<Enum>, values?: Array<Enum>): AFieldDescriptor<FieldModel, EditorModel, FieldValue> | null;
|
|
70
|
+
declare function modifyEditorClassAttributeFieldEnumUnsafe<EditorModel, Enum = any, FieldModel = any, FieldValue = FieldModel>(descriptor: EditorDescriptorInst<EditorModel, any>, property: string, enumDesc?: EnumDescriptor<Enum>, values?: Array<Enum>): AFieldDescriptor<FieldModel, EditorModel, FieldValue> | null;
|
|
71
|
+
/**
|
|
72
|
+
* Modifies selected field with lookup field.
|
|
73
|
+
* @param descriptor Editor descriptor.
|
|
74
|
+
* @param property Model's property name.
|
|
75
|
+
* @param lookupProvider provider to be added to field
|
|
76
|
+
* @param titleProperty
|
|
77
|
+
*/
|
|
78
|
+
declare function modifyEditorFieldLookup<EditorModel, Property extends keyof EditorModel, Service, FieldModel = NonNullable<EditorModel[Property]>, FieldValue = EditorModel[Property]>(descriptor: EditorDescriptorInst<EditorModel, any>, property: Property, lookupProvider: ILookupDataProvider<FieldModel, Service>, titleProperty?: keyof FieldModel): FieldLookupDescriptor<FieldModel, EditorModel, Service, FieldValue>;
|
|
79
|
+
declare function modifyEditorFieldLookupUnsafe<EditorModel, Service, FieldModel = any, FieldValue = FieldModel>(descriptor: EditorDescriptorInst<EditorModel, any>, property: string, lookupProvider: ILookupDataProvider<FieldModel, Service>, titleProperty?: string): FieldLookupDescriptor<FieldModel, EditorModel, Service, FieldValue>;
|
|
80
|
+
|
|
81
|
+
type TableviewClassAttributeDef = EditorClassAttributeDef & TableClassAttributeDef;
|
|
82
|
+
|
|
83
|
+
declare function expandClassAttributeDefWithTableviewDef(attributes?: Array<ClassAttributeDef> | null): TableviewClassAttributeDef[];
|
|
84
|
+
/**
|
|
85
|
+
* returns attributes from class type and extends to typed def with column and field enum type
|
|
86
|
+
* @param type class type
|
|
87
|
+
*/
|
|
88
|
+
declare function getTableviewClassAttributeDef<T>(type: ClassType<T>): TableviewClassAttributeDef[];
|
|
89
|
+
|
|
90
|
+
declare function tableviewDescriptorFromClass<TableviewModel, Sorts = keyof TableviewModel, Filters = keyof TableviewModel, ParentEditorModel = undefined>(type: ClassType<TableviewModel>, opts?: TableviewDescriptorCreateMultiModelWithModelDescriptorOptsType<TableviewModel>): TableviewDescriptorInst<TableviewModel, Sorts, Filters, ParentEditorModel>;
|
|
91
|
+
/**
|
|
92
|
+
* generates descriptor based on type attribute definition
|
|
93
|
+
* @param type class type
|
|
94
|
+
* @param columnAttributes
|
|
95
|
+
* @param fieldAttributes
|
|
96
|
+
* @param opts
|
|
97
|
+
*/
|
|
98
|
+
declare function tableviewDescriptorFromClassAttrsDef<TableviewModel, Sorts = keyof TableviewModel, Filters = keyof TableviewModel, ParentEditorModel = undefined>(type: ClassType<TableviewModel>, columnAttributes?: TableviewClassAttributeDef[], fieldAttributes?: TableviewClassAttributeDef[] | null, opts?: TableviewDescriptorCreateMultiModelWithModelDescriptorOptsType<TableviewModel, Sorts, Filters, ParentEditorModel>): TableviewDescriptorInst<TableviewModel, Sorts, Filters, ParentEditorModel>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* creates column and field with custom type, for example currency
|
|
102
|
+
* if field exists, it is replaced
|
|
103
|
+
* DO NOT USE WITH TYPES WHERE ARGS ARE REQUIRED - ERROR WILL BE THROWN
|
|
104
|
+
* for enum use withEnumType
|
|
105
|
+
* for custom class use withClassType
|
|
106
|
+
* @param descriptor Tableview descriptor
|
|
107
|
+
* @param property name of field
|
|
108
|
+
* @param columnType required column type
|
|
109
|
+
* @param fieldType optional, if not provided it is converted from column type
|
|
110
|
+
* @param columnDisplayType optional
|
|
111
|
+
*/
|
|
112
|
+
declare function modifyTableviewClassAttributeType<TableviewModel>(descriptor: TableviewDescriptorInst<TableviewModel, any, any>, property: keyof TableviewModel, columnType: ColumnTypeEnum, fieldType?: FieldInputTypeEnum, columnDisplayType?: ColumnDisplayTypeEnum): boolean;
|
|
113
|
+
declare function modifyTableviewClassAttributeTypeUnsafe<TableviewModel>(descriptor: TableviewDescriptorInst<TableviewModel, any, any>, property: string, columnType: ColumnTypeEnum, fieldType?: FieldInputTypeEnum, columnDisplayType?: ColumnDisplayTypeEnum): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* creates column with enum type
|
|
116
|
+
* if fields exists, it is replaced
|
|
117
|
+
* @param descriptor Tableview descriptor
|
|
118
|
+
* @param property property name
|
|
119
|
+
* @param enumDesc type of enum
|
|
120
|
+
* @param fieldType type of field, optional, default is Text
|
|
121
|
+
*/
|
|
122
|
+
declare function modifyTableviewClassAttributeEnum<TableviewModel, Property extends keyof TableviewModel, Enum extends NonNullable<TableviewModel[Property]>>(descriptor: TableviewDescriptorInst<TableviewModel, any, any>, property: Property, enumDesc?: EnumDescriptor<Enum>, fieldType?: FieldInputTypeEnum): boolean;
|
|
123
|
+
declare function modifyTableviewClassAttributeEnumUnsafe<TableviewModel, Enum = any>(descriptor: TableviewDescriptorInst<TableviewModel, any, any>, property: string, enumDesc?: EnumDescriptor<Enum>, fieldType?: FieldInputTypeEnum): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* generates column with custom class type
|
|
126
|
+
* field is generated only if lookupProvider is provided
|
|
127
|
+
* @param descriptor Tableview descriptor
|
|
128
|
+
* @param property property name
|
|
129
|
+
* @param type class type of object
|
|
130
|
+
* @param titleProperty
|
|
131
|
+
* @param lookupProvider
|
|
132
|
+
* @param optionsLabelProperty
|
|
133
|
+
* @param filterProperty
|
|
134
|
+
*/
|
|
135
|
+
declare function modifyTableviewLookup<TableviewModel, Property extends keyof TableviewModel, LookupModel = NonNullable<TableviewModel[Property]>>(descriptor: TableviewDescriptorInst<TableviewModel, any, any>, property: Property, type?: ClassType<LookupModel>, lookupProvider?: ILookupDataProvider<LookupModel>, titleProperty?: keyof LookupModel, optionsLabelProperty?: keyof LookupModel, filterProperty?: keyof LookupModel): boolean;
|
|
136
|
+
declare function modifyTableviewLookupUnsafe<TableviewModel, LookupModel>(descriptor: TableviewDescriptorInst<TableviewModel, any, any>, property: string, type?: ClassType<LookupModel>, lookupProvider?: ILookupDataProvider<LookupModel>, titleProperty?: string, optionsLabelProperty?: string, filterProperty?: string): boolean;
|
|
137
|
+
|
|
138
|
+
declare function tableviewDataProviderFromClass<Model, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>): TableviewDataProviderInst<Model, undefined, Sorts, Filters, undefined>;
|
|
139
|
+
declare function tableviewDataProviderFromClass<Model, Service = any, Sorts = keyof Model, Filters extends keyof any = keyof Model>(type: ClassType<Model>, serviceType: ServiceClassType<Service>): TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClassType<Service>>;
|
|
140
|
+
|
|
141
|
+
export { editorDataProviderFromClass, editorDescriptorFromClass, editorDescriptorFromClassAttrsDef, expandClassAttributeDefWithEditorDef, expandClassAttributeDefWithTableviewDef, getEditorClassAttributeDef, getFieldInputTypeFromClassAttributeDefType, getFieldInputTypeFromColumnType, getTableviewClassAttributeDef, modifyEditorClassAttributeFieldEnum, modifyEditorClassAttributeFieldEnumUnsafe, modifyEditorClassAttributeFieldType, modifyEditorClassAttributeFieldTypeUnsafe, modifyEditorFieldLookup, modifyEditorFieldLookupUnsafe, modifyTableviewClassAttributeEnum, modifyTableviewClassAttributeEnumUnsafe, modifyTableviewClassAttributeType, modifyTableviewClassAttributeTypeUnsafe, modifyTableviewLookup, modifyTableviewLookupUnsafe, tableviewDataProviderFromClass, tableviewDescriptorFromClass, tableviewDescriptorFromClassAttrsDef, upsertEditorFieldFromAttributeDef };
|
|
142
|
+
export type { EditorClassAttributeDef, TableviewClassAttributeDef };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { EnumType, ClassType } from '@mediusinc/mng-commons/core';
|
|
2
|
+
|
|
3
|
+
interface ClassAttributeDef {
|
|
4
|
+
name: string;
|
|
5
|
+
baseName: string;
|
|
6
|
+
type: string;
|
|
7
|
+
subtype?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare function TypeName(typeName: string): ClassDecorator;
|
|
11
|
+
declare function EnumName(typeName: string): ClassDecorator;
|
|
12
|
+
|
|
13
|
+
declare const reflectTypeNameKey = "typeName";
|
|
14
|
+
declare const reflectEnumNameKey = "enumName";
|
|
15
|
+
/**
|
|
16
|
+
* Defines type name decorator.
|
|
17
|
+
* @param targetType class.
|
|
18
|
+
* @param typeName Name of the type.
|
|
19
|
+
*/
|
|
20
|
+
declare function defineReflectTypeName(targetType: ClassType<any>, typeName: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Defines enum name decorator.
|
|
23
|
+
* @param targetType enum object.
|
|
24
|
+
* @param enumName Name of the enum.
|
|
25
|
+
*/
|
|
26
|
+
declare function defineReflectEnumName(targetType: EnumType, enumName: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Gets type name from reflect metadata.
|
|
29
|
+
* @param type Class.
|
|
30
|
+
*/
|
|
31
|
+
declare function findReflectTypeName<T>(type?: ClassType<T>): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Gets type name from either decorator or reflect metadata.
|
|
34
|
+
* @param type Class.
|
|
35
|
+
*/
|
|
36
|
+
declare function reflectTypeNameExists(type: ClassType<any>): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Gets enum name from either decorator or reflect metadata.
|
|
39
|
+
* @param enumType Class.
|
|
40
|
+
*/
|
|
41
|
+
declare function findReflectEnumName(enumType: EnumType): string | null;
|
|
42
|
+
|
|
43
|
+
interface RegistryTypeMap {
|
|
44
|
+
[index: string]: ClassType<any>;
|
|
45
|
+
}
|
|
46
|
+
interface RegistryEnumMap {
|
|
47
|
+
[index: string]: EnumType;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare class TypeRegistry {
|
|
51
|
+
private static _instance;
|
|
52
|
+
private readonly _logCategory;
|
|
53
|
+
private readonly _typeMap;
|
|
54
|
+
private readonly _enumMap;
|
|
55
|
+
get typeMap(): RegistryTypeMap;
|
|
56
|
+
get enumMap(): RegistryEnumMap;
|
|
57
|
+
/**
|
|
58
|
+
* Only use one instance of object (out of Angular context)
|
|
59
|
+
*/
|
|
60
|
+
static get(): TypeRegistry;
|
|
61
|
+
findAttributeDefinitionByClassType(type: ClassType<any>, attributeName: string): ClassAttributeDef | null;
|
|
62
|
+
findAttributeDefinition(typeName: string, attributeName: string): ClassAttributeDef | null;
|
|
63
|
+
findAttributesDefinitionByClassType(type: ClassType<any>): Array<ClassAttributeDef> | null;
|
|
64
|
+
findAttributesDefinition(typeName: string): Array<ClassAttributeDef> | null;
|
|
65
|
+
findByClassType(type: ClassType<any>): any;
|
|
66
|
+
findType(typeName: string): any;
|
|
67
|
+
findEnum(enumName: string): any;
|
|
68
|
+
registerTypes(types: RegistryTypeMap): void;
|
|
69
|
+
registerType(type: ClassType<any>, optTypeName?: string): void;
|
|
70
|
+
clearTypes(): void;
|
|
71
|
+
registerEnums(enums: RegistryEnumMap): void;
|
|
72
|
+
registerEnum(enumType: EnumType, enumName: string): void;
|
|
73
|
+
clearEnums(): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { EnumName, TypeName, TypeRegistry, defineReflectEnumName, defineReflectTypeName, findReflectEnumName, findReflectTypeName, reflectEnumNameKey, reflectTypeNameExists, reflectTypeNameKey };
|
|
77
|
+
export type { ClassAttributeDef, RegistryEnumMap, RegistryTypeMap };
|