@smartsoft001/models 2.21.0 → 2.23.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@smartsoft001/models",
3
3
  "type": "commonjs",
4
4
  "dependencies": {
5
- "@smartsoft001/utils": "2.21.0",
5
+ "@smartsoft001/utils": "^2.23.0",
6
6
  "flatted": "3.2.9",
7
7
  "guid-typescript": "^1.0.9",
8
8
  "lodash": "4.17.21",
@@ -11,7 +11,7 @@
11
11
  "rxjs": "^7.8.1",
12
12
  "tslib": "^2.3.0"
13
13
  },
14
- "version": "2.21.0",
15
- "main": "./index.cjs",
14
+ "version": "2.23.0",
15
+ "main": "./src/index.js",
16
16
  "typings": "./src/index.d.ts"
17
- }
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./lib/symbols";
2
+ export * from './lib/interfaces';
3
+ export * from './lib/decorators';
4
+ export * from './lib/utils';
@@ -0,0 +1,4 @@
1
+ import 'reflect-metadata';
2
+ import { IFieldOptions } from "../../interfaces";
3
+ export declare const Field: typeof FieldDecorator;
4
+ export declare function FieldDecorator(options?: IFieldOptions): <T>(target: T, key: string) => void;
@@ -0,0 +1,2 @@
1
+ export * from './model/model.decorator';
2
+ export * from './field/field.decorator';
@@ -0,0 +1,4 @@
1
+ import 'reflect-metadata';
2
+ import { IModelOptions } from "../../interfaces";
3
+ export declare const Model: typeof ModelDecorator;
4
+ export declare function ModelDecorator(options?: IModelOptions): <T>(target: any) => void;
@@ -0,0 +1,141 @@
1
+ import { Observable } from "rxjs";
2
+ export declare enum FieldTypeDef {
3
+ address = "address",
4
+ currency = "currency",
5
+ date = "date",
6
+ dateTime = "dateTime",
7
+ dateWithEdit = "dateWithEdit",
8
+ email = "email",
9
+ enum = "enum",
10
+ file = "file",
11
+ flag = "flag",
12
+ int = "int",
13
+ nip = "nip",
14
+ object = "object",
15
+ array = "array",
16
+ password = "password",
17
+ radio = "radio",
18
+ text = "text",
19
+ strings = "strings",
20
+ ints = "ints",
21
+ longText = "longText",
22
+ color = "color",
23
+ logo = "logo",
24
+ check = "check",
25
+ phoneNumber = "phoneNumber",
26
+ phoneNumberPl = "phoneNumberPl",
27
+ pesel = "pesel",
28
+ pdf = "pdf",
29
+ video = "video",
30
+ attachment = "attachment",
31
+ dateRange = "dateRange",
32
+ image = "image",
33
+ float = "float"
34
+ }
35
+ export declare const FieldType: typeof FieldTypeDef;
36
+ export interface ISpecification {
37
+ criteria: any;
38
+ }
39
+ export interface IModelFilter {
40
+ label?: string;
41
+ fieldType?: FieldTypeDef;
42
+ key: string;
43
+ type: '=' | '!=' | '>=' | '<=' | '<' | '>' | '~=';
44
+ possibilities$?: Observable<{
45
+ id: any;
46
+ text: string;
47
+ }[]>;
48
+ }
49
+ export interface IModelStep {
50
+ number: number;
51
+ name: string;
52
+ }
53
+ export interface IModelMetadata {
54
+ titleKey?: string;
55
+ permissions?: Array<string>;
56
+ filters?: Array<IModelFilter>;
57
+ }
58
+ export interface IFieldMetadata extends IFieldModifyMetadata {
59
+ type?: FieldTypeDef;
60
+ classType?: any;
61
+ possibilities?: Array<any> | any;
62
+ }
63
+ export interface IFieldModifyMetadata {
64
+ required?: boolean;
65
+ focused?: boolean;
66
+ confirm?: boolean;
67
+ permissions?: Array<string>;
68
+ unique?: boolean | IFieldUniqueMetadata;
69
+ defaltValue?: () => any;
70
+ enabled?: ISpecification;
71
+ hide?: boolean;
72
+ /**
73
+ * @desc - Model step configuration
74
+ */
75
+ step?: IModelStep;
76
+ }
77
+ export interface IFieldEditMetadata extends IFieldModifyMetadata {
78
+ multi?: boolean;
79
+ }
80
+ export interface IFieldListMetadata {
81
+ order?: number;
82
+ filter?: boolean;
83
+ permissions?: Array<string>;
84
+ /**
85
+ * Configuration for dynamic list table data
86
+ * @param {string} dynamic.headerKey - column header object key
87
+ * @param {string} dynamic.rowKey - column row value object key
88
+ */
89
+ dynamic?: {
90
+ headerKey: string;
91
+ rowKey: string;
92
+ };
93
+ }
94
+ export interface IFieldDetailsMetadata {
95
+ order?: number;
96
+ permissions?: Array<string>;
97
+ enabled?: ISpecification;
98
+ }
99
+ export interface IModelOptions {
100
+ titleKey?: string;
101
+ filters?: Array<IModelFilter>;
102
+ create?: IModelModeOptions;
103
+ update?: IModelModeOptions;
104
+ list?: IModelModeOptions;
105
+ details?: IModelModeOptions;
106
+ remove?: IModelModeOptions;
107
+ customs?: Array<IModelModeOptionsCustom>;
108
+ /**
109
+ * @desc - Allow export field data
110
+ */
111
+ export?: boolean;
112
+ /**
113
+ * @desc - Allow import field data
114
+ */
115
+ import?: boolean;
116
+ }
117
+ export interface IModelModeOptions {
118
+ permissions?: Array<string>;
119
+ enabled?: ISpecification;
120
+ }
121
+ export interface IModelModeOptionsCustom extends IModelModeOptions {
122
+ mode: string;
123
+ }
124
+ export interface IFieldOptions extends IFieldMetadata {
125
+ create?: IFieldModifyMetadata | boolean;
126
+ update?: IFieldEditMetadata | boolean;
127
+ list?: IFieldListMetadata | boolean;
128
+ details?: IFieldDetailsMetadata | boolean;
129
+ customs?: Array<IModelMetadataCustom>;
130
+ search?: boolean;
131
+ info?: string;
132
+ }
133
+ export interface IModelMetadataCustom extends IModelMetadata {
134
+ mode: string;
135
+ }
136
+ export interface IFieldUniqueMetadata {
137
+ withFields?: Array<string>;
138
+ }
139
+ export interface IFieldCustomMetadata extends IFieldModifyMetadata, IFieldListMetadata {
140
+ mode: string;
141
+ }
@@ -0,0 +1,2 @@
1
+ export declare const SYMBOL_MODEL: unique symbol;
2
+ export declare const SYMBOL_FIELD: unique symbol;
@@ -0,0 +1,11 @@
1
+ import { IFieldOptions, IModelOptions } from "./interfaces";
2
+ export declare function getModelFieldKeys<T>(type: T): Array<string>;
3
+ export declare function getModelFieldOptions<T>(instance: T, fieldKey: string): IFieldOptions;
4
+ export declare function getModelFieldsWithOptions<T>(instance: T): Array<{
5
+ key: string;
6
+ options: IFieldOptions;
7
+ }>;
8
+ export declare function getModelOptions(type: any): IModelOptions;
9
+ export declare function isModel<T>(instance: T): boolean;
10
+ export declare function getInvalidFields<T>(instance: T, mode: "create" | "update" | string, permissions: Array<string>): Array<string>;
11
+ export declare function castModel<T>(instance: T, mode: "create" | "update" | string, permissions: Array<string>): void;