identity-admin 1.28.6 → 1.28.8
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 +294 -294
- package/lib/Dashboard.d.ts +14 -14
- package/lib/Dashboard.js +95 -95
- package/lib/container/helpers/HelperInversify.d.ts +6 -6
- package/lib/container/helpers/HelperInversify.js +10 -10
- package/lib/container/helpers/HelperTypes.d.ts +5 -5
- package/lib/container/helpers/HelperTypes.js +7 -7
- package/lib/container/index.d.ts +1 -1
- package/lib/container/index.js +14 -14
- package/lib/container/repositories/RepositoryInversify.d.ts +4 -4
- package/lib/container/repositories/RepositoryInversify.js +13 -13
- package/lib/container/repositories/RepositoryTypes.d.ts +4 -4
- package/lib/container/repositories/RepositoryTypes.js +6 -6
- package/lib/container/types.d.ts +8 -8
- package/lib/container/types.js +9 -9
- package/lib/controllers/ActionController.d.ts +9 -8
- package/lib/controllers/ActionController.js +136 -96
- package/lib/controllers/AdminNotificationController.d.ts +8 -8
- package/lib/controllers/AdminNotificationController.js +69 -69
- package/lib/controllers/DashboardController.d.ts +44 -44
- package/lib/controllers/DashboardController.js +787 -787
- package/lib/controllers/ResourceController.d.ts +15 -15
- package/lib/controllers/ResourceController.js +135 -135
- package/lib/helpers/ActionsGenerator.d.ts +11 -11
- package/lib/helpers/ActionsGenerator.js +179 -179
- package/lib/helpers/AdminNotifications/AdminNotificationCreation.d.ts +49 -49
- package/lib/helpers/AdminNotifications/AdminNotificationCreation.js +66 -66
- package/lib/helpers/AdminNotifications/AdminNotificationFetcher.d.ts +51 -51
- package/lib/helpers/AdminNotifications/AdminNotificationFetcher.js +39 -39
- package/lib/helpers/FilterQueryHelper.d.ts +9 -9
- package/lib/helpers/FilterQueryHelper.js +83 -83
- package/lib/helpers/FiltersHelper.d.ts +9 -9
- package/lib/helpers/FiltersHelper.js +126 -126
- package/lib/helpers/LocalesHelper.d.ts +4 -4
- package/lib/helpers/LocalesHelper.js +73 -73
- package/lib/helpers/LocalizedStringHelper.d.ts +11 -11
- package/lib/helpers/LocalizedStringHelper.js +74 -74
- package/lib/helpers/Permissions/PermissionFetcher.d.ts +8 -8
- package/lib/helpers/Permissions/PermissionFetcher.js +95 -95
- package/lib/helpers/Permissions/PermissionLabel.d.ts +2 -2
- package/lib/helpers/Permissions/PermissionLabel.js +42 -42
- package/lib/helpers/Permissions/PermissionMapper.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionMapper.js +35 -35
- package/lib/helpers/Permissions/PermissionResource.d.ts +6 -6
- package/lib/helpers/Permissions/PermissionResource.js +62 -62
- package/lib/helpers/Permissions/PermissionSavingService.d.ts +13 -13
- package/lib/helpers/Permissions/PermissionSavingService.js +32 -32
- package/lib/helpers/Permissions/SavePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/SavePermissionGroup.js +32 -32
- package/lib/helpers/Permissions/UpdatePermissionGroup.d.ts +6 -6
- package/lib/helpers/Permissions/UpdatePermissionGroup.js +50 -50
- package/lib/helpers/Permissions/types.d.ts +17 -17
- package/lib/helpers/Permissions/types.js +2 -2
- package/lib/helpers/PopulationHelper.d.ts +12 -12
- package/lib/helpers/PopulationHelper.js +50 -50
- package/lib/helpers/RecordsCounter.d.ts +10 -10
- package/lib/helpers/RecordsCounter.js +33 -33
- package/lib/helpers/ReportsGenerator.d.ts +26 -26
- package/lib/helpers/ReportsGenerator.js +162 -162
- package/lib/helpers/ResourceGenerator.d.ts +9 -9
- package/lib/helpers/ResourceGenerator.js +172 -172
- package/lib/helpers/ResourceHelper.d.ts +28 -28
- package/lib/helpers/ResourceHelper.js +395 -395
- package/lib/helpers/RportsGenerator.d.ts +10 -10
- package/lib/helpers/RportsGenerator.js +21 -21
- package/lib/helpers/SchemaGenerator.d.ts +7 -7
- package/lib/helpers/SchemaGenerator.js +132 -130
- package/lib/helpers/SchemaHelper.d.ts +5 -5
- package/lib/helpers/SchemaHelper.js +21 -21
- package/lib/helpers/UserActionsLog/UserActionsLogHelper.d.ts +2 -2
- package/lib/helpers/UserActionsLog/UserActionsLogHelper.js +49 -49
- package/lib/locales/en.json +53 -53
- package/lib/middlewares/cache/decorator.d.ts +3 -3
- package/lib/middlewares/cache/decorator.js +60 -60
- package/lib/middlewares/cache/deletionMethods.d.ts +3 -3
- package/lib/middlewares/cache/deletionMethods.js +23 -23
- package/lib/middlewares/isAuth.d.ts +13 -13
- package/lib/middlewares/isAuth.js +43 -43
- package/lib/models/ModelNames.d.ts +10 -9
- package/lib/models/ModelNames.js +13 -12
- package/lib/models/adminNotification/AdminNotification.d.ts +5 -5
- package/lib/models/adminNotification/AdminNotification.js +53 -53
- package/lib/models/adminNotification/IAdminNotification.d.ts +30 -30
- package/lib/models/adminNotification/IAdminNotification.js +15 -15
- package/lib/models/adminpermission/AdminPermission.d.ts +11 -11
- package/lib/models/adminpermission/AdminPermission.js +23 -23
- package/lib/models/adminpermission/IAdminPermission.d.ts +13 -13
- package/lib/models/adminpermission/IAdminPermission.js +2 -2
- package/lib/models/customPage/CustomPage.d.ts +2 -2
- package/lib/models/customPage/CustomPage.js +38 -38
- package/lib/models/customPage/ICustomPage.d.ts +17 -17
- package/lib/models/customPage/ICustomPage.js +2 -2
- package/lib/models/file/File.d.ts +2 -2
- package/lib/models/file/File.js +23 -23
- package/lib/models/file/IFile.d.ts +15 -15
- package/lib/models/file/IFile.js +2 -2
- package/lib/models/location/ILocation.d.ts +14 -14
- package/lib/models/location/ILocation.js +2 -2
- package/lib/models/location/Location.d.ts +2 -2
- package/lib/models/location/Location.js +21 -21
- package/lib/models/mailLog/IMailLog.d.ts +14 -0
- package/lib/models/mailLog/IMailLog.js +2 -0
- package/lib/models/mailLog/MailLog.d.ts +3 -0
- package/lib/models/mailLog/MailLog.js +23 -0
- package/lib/models/modelConfiguration/IModelConfigurations.d.ts +29 -29
- package/lib/models/modelConfiguration/IModelConfigurations.js +2 -2
- package/lib/models/modelConfiguration/ModelConfiguration.d.ts +13 -13
- package/lib/models/modelConfiguration/ModelConfiguration.js +95 -95
- package/lib/models/permission/IPermission.d.ts +14 -14
- package/lib/models/permission/IPermission.js +2 -2
- package/lib/models/permission/Permission.d.ts +2 -2
- package/lib/models/permission/Permission.js +21 -21
- package/lib/models/request-log/IRequestLog.d.ts +22 -22
- package/lib/models/request-log/IRequestLog.js +2 -2
- package/lib/models/request-log/RequestLog.d.ts +3 -3
- package/lib/models/request-log/RequestLog.js +51 -51
- package/lib/models/userActionsLog/IUserActionsLog.d.ts +26 -26
- package/lib/models/userActionsLog/IUserActionsLog.js +11 -11
- package/lib/models/userActionsLog/UserActionsLog.d.ts +3 -3
- package/lib/models/userActionsLog/UserActionsLog.js +41 -41
- package/lib/pdf/ReportTemplate.d.ts +71 -71
- package/lib/pdf/ReportTemplate.js +94 -94
- package/lib/repositories/AdminNotificationRepository.d.ts +7 -7
- package/lib/repositories/AdminNotificationRepository.js +23 -23
- package/lib/repositories/DashboardRepository.d.ts +5 -5
- package/lib/repositories/DashboardRepository.js +12 -12
- package/lib/repositories/Repository.d.ts +68 -68
- package/lib/repositories/Repository.js +215 -215
- package/lib/repositories/RequestLogRepository.d.ts +10 -10
- package/lib/repositories/RequestLogRepository.js +54 -54
- package/lib/repositories/SaveResult.d.ts +14 -14
- package/lib/repositories/SaveResult.js +18 -18
- package/lib/resources/AdminNotificationsResource.d.ts +3 -3
- package/lib/resources/AdminNotificationsResource.js +23 -23
- package/lib/resources/parents.d.ts +4 -4
- package/lib/resources/parents.js +7 -7
- package/lib/router/index.d.ts +8 -8
- package/lib/router/index.js +104 -104
- package/lib/types/DashbordConfig.d.ts +21 -21
- package/lib/types/DashbordConfig.js +2 -2
- package/lib/types/IConfigurationFile.d.ts +11 -11
- package/lib/types/IConfigurationFile.js +2 -2
- package/lib/types/IResourceFile.d.ts +719 -710
- package/lib/types/IResourceFile.js +2 -2
- package/lib/types/IResourceResponse.d.ts +95 -95
- package/lib/types/IResourceResponse.js +2 -2
- package/lib/types/helpers.d.ts +67 -67
- package/lib/types/helpers.js +82 -82
- package/lib/utils/DateUtils.d.ts +7 -7
- package/lib/utils/DateUtils.js +45 -45
- package/lib/utils/ResourceUtils.d.ts +2 -2
- package/lib/utils/ResourceUtils.js +7 -7
- package/lib/utils/ResponseUtils.d.ts +11 -11
- package/lib/utils/ResponseUtils.js +41 -41
- package/lib/utils/StringUtils.d.ts +9 -9
- package/lib/utils/StringUtils.js +46 -46
- package/lib/view/asset-manifest.json +18 -18
- package/lib/view/assets/icons/delete_icon.svg +3 -3
- package/lib/view/assets/icons/flags/ic_flag_cn.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_sa.svg +9 -9
- package/lib/view/assets/icons/flags/ic_flag_vn.svg +9 -9
- package/lib/view/assets/icons/info_icon.svg +3 -3
- package/lib/view/assets/icons/navbar/ic_banking.svg +5 -5
- package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -4
- package/lib/view/assets/icons/navbar/ic_kanban.svg +7 -7
- package/lib/view/assets/icons/navbar/ic_menu_item.svg +8 -8
- package/lib/view/assets/icons/small_info_icon.svg +3 -3
- package/lib/view/assets/illustrations/Group 16.svg +4 -4
- package/lib/view/assets/illustrations/logo.svg +5 -5
- package/lib/view/favicon/browserconfig.xml +9 -9
- package/lib/view/favicon/safari-pinned-tab.svg +182 -182
- package/lib/view/favicon/site.webmanifest +19 -19
- package/lib/view/fonts/index.css +18 -18
- package/lib/view/index.html +52 -52
- package/lib/view/manifest.json +20 -20
- package/lib/view/robots.txt +3 -3
- package/lib/view/static/css/main.54de06ef.css +1 -1
- package/lib/view/static/js/574.778b5963.chunk.js +1 -1
- package/lib/view/static/js/678.521704a3.chunk.js +1 -1
- package/lib/view/static/js/798.54856416.chunk.js +1 -1
- package/lib/view/static/js/main.4687f255.js +2 -2
- package/lib/view/static/js/main.4687f255.js.LICENSE.txt +214 -214
- package/package.json +63 -63
|
@@ -1,710 +1,719 @@
|
|
|
1
|
-
import { ValidationChain } from 'express-validator';
|
|
2
|
-
import { Document, Model } from 'mongoose';
|
|
3
|
-
import { IRequest } from '../middlewares/isAuth';
|
|
4
|
-
import { IRepository, PageInfo, PaginateParams } from '../repositories/Repository';
|
|
5
|
-
import SaveResult from '../repositories/SaveResult';
|
|
6
|
-
import { ActionNames, ActionTypes, FieldTypes, FileTypes, HandlerStrategy, ImageOptimizingCategories, NeighborTypes, Virtuals } from './helpers';
|
|
7
|
-
import * as Yup from 'yup';
|
|
8
|
-
declare type orderTypes = 'asc' | 'desc';
|
|
9
|
-
declare type VirtualFieldTypes = 'password' | 'ref' | 'Array';
|
|
10
|
-
declare type Severity = 'success' | 'info' | 'warning' | 'error';
|
|
11
|
-
declare type ButtonColors = 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
|
|
12
|
-
declare type ButtonVariants = 'text' | 'outlined' | 'contained';
|
|
13
|
-
declare type ButtonSizes = 'small' | 'medium' | 'large';
|
|
14
|
-
declare type PopulateFunction = (populatedString: any) => Promise<any>;
|
|
15
|
-
interface Parent {
|
|
16
|
-
/**
|
|
17
|
-
* Name of the parent
|
|
18
|
-
*/
|
|
19
|
-
name: string;
|
|
20
|
-
/**
|
|
21
|
-
* Icon of the parent. You can get the icons from
|
|
22
|
-
* {@link https://mui.com/material-ui/material-icons/}
|
|
23
|
-
*/
|
|
24
|
-
icon: string;
|
|
25
|
-
}
|
|
26
|
-
interface IPopulate {
|
|
27
|
-
/**
|
|
28
|
-
* This function is called for all the endpoints to have an access over the populated string
|
|
29
|
-
*/
|
|
30
|
-
all?: PopulateFunction;
|
|
31
|
-
/**
|
|
32
|
-
* This function is called for the list endpoint to have an access over the populated string
|
|
33
|
-
*/
|
|
34
|
-
list?: PopulateFunction;
|
|
35
|
-
/**
|
|
36
|
-
* This function is called for the get one endpoint either in show or form an access over the populated string
|
|
37
|
-
*/
|
|
38
|
-
show?: PopulateFunction;
|
|
39
|
-
}
|
|
40
|
-
interface Action {
|
|
41
|
-
/**
|
|
42
|
-
* Specify if this action is accessible or not.
|
|
43
|
-
* @default True for show, edit, delete, and new.
|
|
44
|
-
* @default false for bulk delete.
|
|
45
|
-
* You can ovveride any of these values here.
|
|
46
|
-
*/
|
|
47
|
-
isAccessible?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Specify if the page requires to be reloaded after executing the action
|
|
50
|
-
* @default Fale for show, edit, delete, and new.
|
|
51
|
-
*/
|
|
52
|
-
reloadAfterAction?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* The property that manages which admin role can use this action.
|
|
55
|
-
* This function's result alters the isAccessible value. So no need to use both properties.
|
|
56
|
-
* If both are used then isAccessible has the higher priority.
|
|
57
|
-
* @default 'Same as isAccessible'
|
|
58
|
-
*/
|
|
59
|
-
isAllowed?: (currentUser: Document) => boolean;
|
|
60
|
-
/**
|
|
61
|
-
* The property that manages which action will be extracted from action menu in list.
|
|
62
|
-
* @default true for edit and show false for others
|
|
63
|
-
*/
|
|
64
|
-
isMainAction?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Specify if this action is visible or not per record.
|
|
67
|
-
* @default 'Same as isAccessible'
|
|
68
|
-
*/
|
|
69
|
-
isVisible?: (data: ActionData) => Promise<boolean>;
|
|
70
|
-
}
|
|
71
|
-
interface ICrudOperations {
|
|
72
|
-
index?: {
|
|
73
|
-
/**
|
|
74
|
-
* Before handler that gives you the access to the filter object.
|
|
75
|
-
* You can add to the filter object any key and value that will be used in the filter query before getting the records for list.
|
|
76
|
-
* @returns the filter object
|
|
77
|
-
*/
|
|
78
|
-
before?: (req: IRequest, filter: {
|
|
79
|
-
[key: string]: any;
|
|
80
|
-
}, currentUser: Document) => Promise<{
|
|
81
|
-
[key: string]: any;
|
|
82
|
-
}>;
|
|
83
|
-
/**
|
|
84
|
-
* After handler that gives you the access to the array of documents.
|
|
85
|
-
* @returns the array of documents
|
|
86
|
-
*/
|
|
87
|
-
after?: (req: IRequest, documents: Document[], currentUser: Document) => Promise<Document[]>;
|
|
88
|
-
/**
|
|
89
|
-
* index handler that gives you the access to the run custom index method with custom query.
|
|
90
|
-
* @returns result list of records
|
|
91
|
-
*/
|
|
92
|
-
index?: (req: IRequest, filter: {
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
}, sortQuery: {
|
|
95
|
-
[key: string]: any;
|
|
96
|
-
}, paginateParams: PaginateParams | undefined, populate: any, currentUser: Document) => Promise<{
|
|
97
|
-
records: Document[];
|
|
98
|
-
pageInfo?: PageInfo;
|
|
99
|
-
}>;
|
|
100
|
-
};
|
|
101
|
-
create?: {
|
|
102
|
-
/**
|
|
103
|
-
* Before handler that is called before creating a new record.
|
|
104
|
-
* This function gives you the access to the record params before saving it, you can perform any update to the params before saving it.
|
|
105
|
-
* @returns the params
|
|
106
|
-
*/
|
|
107
|
-
before?: (req: IRequest, params: any, currentUser: Document) => Promise<any>;
|
|
108
|
-
/**
|
|
109
|
-
* After handler that gives you the access to the saved document.
|
|
110
|
-
* @returns the saved document
|
|
111
|
-
*/
|
|
112
|
-
after?: (req: IRequest, document: Document, currentUser: Document, params: any) => Promise<Document>;
|
|
113
|
-
/**
|
|
114
|
-
* Validators consist of an array of Express ValidationChain, each comprising validation functions that are executed before triggering the save query.
|
|
115
|
-
*/
|
|
116
|
-
validators?: ValidationChain[];
|
|
117
|
-
};
|
|
118
|
-
update?: {
|
|
119
|
-
/**
|
|
120
|
-
* Before handler that is called before updating a record.
|
|
121
|
-
* This function gives you the access to the record params before saving it, you can perform any update to the params before saving it.
|
|
122
|
-
* @returns the params
|
|
123
|
-
*/
|
|
124
|
-
before?: (req: IRequest, params: any, currentUser: Document) => Promise<any>;
|
|
125
|
-
/**
|
|
126
|
-
* After handler that gives you the access to the updated document.
|
|
127
|
-
* @returns the updated document
|
|
128
|
-
*/
|
|
129
|
-
after?: (req: IRequest, document: Document, params: any, currentUser: Document) => Promise<Document>;
|
|
130
|
-
/**
|
|
131
|
-
* update handler that gives you the access to the run custom update method with custom query.
|
|
132
|
-
* @returns saved result with updated document
|
|
133
|
-
*/
|
|
134
|
-
update?: (req: IRequest, record: Document, recordParams: any, currentUser: Document) => Promise<SaveResult<any>>;
|
|
135
|
-
/**
|
|
136
|
-
* Validators consist of an array of Express ValidationChain, each comprising validation functions that are executed before triggering the update query.
|
|
137
|
-
*/
|
|
138
|
-
validators?: ValidationChain[];
|
|
139
|
-
};
|
|
140
|
-
show?: {
|
|
141
|
-
/**
|
|
142
|
-
* Before handler that gives you the access to the filter object.
|
|
143
|
-
* You can add to the filter object any key and value that will be used in the filter query before getting the records for list.
|
|
144
|
-
* @returns the filter object
|
|
145
|
-
*/
|
|
146
|
-
before?: (req: IRequest, filter: {
|
|
147
|
-
[key: string]: any;
|
|
148
|
-
}, currentUser: Document) => Promise<{
|
|
149
|
-
[key: string]: any;
|
|
150
|
-
}>;
|
|
151
|
-
after?: (req: IRequest, record: Document) => Promise<{
|
|
152
|
-
record: Document;
|
|
153
|
-
[key: string]: any;
|
|
154
|
-
}>;
|
|
155
|
-
/**
|
|
156
|
-
* A function that is called before getting the next or the previous record. It gives you the access to the filter object.
|
|
157
|
-
* @returns The filter object
|
|
158
|
-
*/
|
|
159
|
-
nextPreviousButtonHandler?: (req: IRequest, filter: {
|
|
160
|
-
[key: string]: any;
|
|
161
|
-
}, currentUser: Document, direction: NeighborTypes) => Promise<{
|
|
162
|
-
[key: string]: any;
|
|
163
|
-
}>;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
export interface ActionData {
|
|
167
|
-
/**
|
|
168
|
-
* Record document
|
|
169
|
-
*/
|
|
170
|
-
record: any;
|
|
171
|
-
/**
|
|
172
|
-
* Current user data
|
|
173
|
-
*/
|
|
174
|
-
currentUser: Document;
|
|
175
|
-
/**
|
|
176
|
-
* Resource data to which this record belongs
|
|
177
|
-
*/
|
|
178
|
-
resource: {
|
|
179
|
-
/**
|
|
180
|
-
* Model name of this table.
|
|
181
|
-
*/
|
|
182
|
-
name: string;
|
|
183
|
-
/**
|
|
184
|
-
* Path of the resource to which you can redirect.
|
|
185
|
-
*/
|
|
186
|
-
path: string;
|
|
187
|
-
/**
|
|
188
|
-
* Repository of this resource.
|
|
189
|
-
*/
|
|
190
|
-
repository: IRepository<Document>;
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
interface IFilters {
|
|
194
|
-
/**
|
|
195
|
-
* Scope filter props.
|
|
196
|
-
* Can be either auto or manual. It cannot be both.
|
|
197
|
-
* This filter is not accessible by default
|
|
198
|
-
*/
|
|
199
|
-
scopes?: {
|
|
200
|
-
/**
|
|
201
|
-
* Specify if this filter is accessible or not
|
|
202
|
-
* @default false
|
|
203
|
-
*/
|
|
204
|
-
isAccessible: boolean;
|
|
205
|
-
/**
|
|
206
|
-
* Show All tab
|
|
207
|
-
* @default true
|
|
208
|
-
*/
|
|
209
|
-
showAll?: boolean;
|
|
210
|
-
/**
|
|
211
|
-
* Automatic scope that filters by the specified key with one of the given options
|
|
212
|
-
* This filter works automatically by mentioning the key as saved in the database along with the values that this key can has.
|
|
213
|
-
* It doesn't need a handler
|
|
214
|
-
*/
|
|
215
|
-
auto?: IAutoScope;
|
|
216
|
-
/**
|
|
217
|
-
* Manual scope by using a handler.
|
|
218
|
-
* In this case you can put the options you like with specifying in the handler what to do with each option.
|
|
219
|
-
*/
|
|
220
|
-
manual?: IManualScope;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* Search bar filter props
|
|
224
|
-
*/
|
|
225
|
-
searchBar?: {
|
|
226
|
-
/**
|
|
227
|
-
* Specify if this filter is accessible or not
|
|
228
|
-
* @default true
|
|
229
|
-
*/
|
|
230
|
-
isAccessible: boolean;
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
interface IAutoScope {
|
|
234
|
-
/**
|
|
235
|
-
* Key of property as specified in the database
|
|
236
|
-
*/
|
|
237
|
-
key: string;
|
|
238
|
-
/**
|
|
239
|
-
* Array of values that this key can have
|
|
240
|
-
*/
|
|
241
|
-
options: string[];
|
|
242
|
-
}
|
|
243
|
-
interface IManualScope {
|
|
244
|
-
/**
|
|
245
|
-
* Array of values that will be appeared in the scope
|
|
246
|
-
*/
|
|
247
|
-
options: string[];
|
|
248
|
-
/**
|
|
249
|
-
* A handler that will be called when scope filter is used.
|
|
250
|
-
* This handler should perform a switch case on the specified options values, each case set the filter on its way.
|
|
251
|
-
*/
|
|
252
|
-
handler: (filter: {
|
|
253
|
-
[key: string]: any;
|
|
254
|
-
}, scope: string, currentUser: Document) => Promise<{
|
|
255
|
-
[key: string]: any;
|
|
256
|
-
}>;
|
|
257
|
-
}
|
|
258
|
-
export interface IFieldValue {
|
|
259
|
-
/**
|
|
260
|
-
* If the field is required in the schema and you don't want it to be required in the form, you can override this here.
|
|
261
|
-
* @default 'same as schema'
|
|
262
|
-
*/
|
|
263
|
-
required?: boolean;
|
|
264
|
-
/**
|
|
265
|
-
* Specify either this field can be edited or not.
|
|
266
|
-
* @default true
|
|
267
|
-
*/
|
|
268
|
-
isEditable?: boolean;
|
|
269
|
-
/**
|
|
270
|
-
* Specify the type of the field. Can be used for specifying localized string, image,... etc.
|
|
271
|
-
* @default 'Same as schema''
|
|
272
|
-
*/
|
|
273
|
-
type?: FieldTypes;
|
|
274
|
-
/**
|
|
275
|
-
* Specify the enum values if the field type is an enum.
|
|
276
|
-
* You can give custom labels with custom background color of the chib as color and label color as labelColor
|
|
277
|
-
* @default 'Same as schema''
|
|
278
|
-
*/
|
|
279
|
-
enumValues?: string[] | {
|
|
280
|
-
[key: string]: {
|
|
281
|
-
label: string;
|
|
282
|
-
color: string;
|
|
283
|
-
labelColor: string;
|
|
284
|
-
};
|
|
285
|
-
};
|
|
286
|
-
/**
|
|
287
|
-
* Specify the allowed country codes.
|
|
288
|
-
* @required if the type is phone number
|
|
289
|
-
* ex: ["sa", "eg", ...]
|
|
290
|
-
*/
|
|
291
|
-
countryCodes?: string[];
|
|
292
|
-
/**
|
|
293
|
-
* Specify the default country code.
|
|
294
|
-
* ex: ["sa", "eg", ...]
|
|
295
|
-
* @default 'First country of provided country codes or sa if no country codes provided'
|
|
296
|
-
*/
|
|
297
|
-
defaultCountryCode?: string;
|
|
298
|
-
/**
|
|
299
|
-
* Specify the array type if the field is of type array.
|
|
300
|
-
* @default 'Same as schema''
|
|
301
|
-
*/
|
|
302
|
-
arrayType?: FieldTypes;
|
|
303
|
-
/**
|
|
304
|
-
* Specify if the array is draggable. Only used when the field type is an array.
|
|
305
|
-
* @default 'true''
|
|
306
|
-
*/
|
|
307
|
-
isDraggable?: boolean;
|
|
308
|
-
/**
|
|
309
|
-
* Can be used only if this field is a reference to the Image collection
|
|
310
|
-
*/
|
|
311
|
-
mediaUploader?: boolean;
|
|
312
|
-
/**
|
|
313
|
-
* Used only if this field is of type image. It specifies what is the optimizing level of an image before upload
|
|
314
|
-
* @default NORMAL
|
|
315
|
-
*/
|
|
316
|
-
imageOptimizingCategory?: ImageOptimizingCategories;
|
|
317
|
-
/**
|
|
318
|
-
* Specify the type of the file to be uploaded. Only required if the media uploader is true.
|
|
319
|
-
* @default image
|
|
320
|
-
*/
|
|
321
|
-
fileType?: FileTypes;
|
|
322
|
-
/**
|
|
323
|
-
* Specify if the date is shown with time or not. Only used if the field type is Date
|
|
324
|
-
* @default false
|
|
325
|
-
*/
|
|
326
|
-
withTime?: boolean;
|
|
327
|
-
/**
|
|
328
|
-
* Specify the api route that to be called for getting the referenced values
|
|
329
|
-
* @default undefined
|
|
330
|
-
*/
|
|
331
|
-
apiRoute?: string;
|
|
332
|
-
/**
|
|
333
|
-
* Path of the value inside the model schema
|
|
334
|
-
* @default undefined
|
|
335
|
-
*/
|
|
336
|
-
valuePath?: string;
|
|
337
|
-
/**
|
|
338
|
-
* Specify if this property is clickable or not in the list view.
|
|
339
|
-
* @default undefined
|
|
340
|
-
*/
|
|
341
|
-
isClickable?: boolean;
|
|
342
|
-
/**
|
|
343
|
-
* Specify the keys that will be shown in the nested schema. Only used when the type is nested schema
|
|
344
|
-
* @default undefined
|
|
345
|
-
*/
|
|
346
|
-
keys?: string[];
|
|
347
|
-
/**
|
|
348
|
-
* Specify the nested schema. Only used if the type is nested schema.
|
|
349
|
-
* @default undefined
|
|
350
|
-
*/
|
|
351
|
-
schema?: IModel | {
|
|
352
|
-
[key: string]: IFieldValue;
|
|
353
|
-
};
|
|
354
|
-
/**
|
|
355
|
-
* Specify if this field is filtered by multiple values not only one value. Only used if this value is one of the quick filters.
|
|
356
|
-
* @default undefined
|
|
357
|
-
*/
|
|
358
|
-
multipleInFilter?: boolean;
|
|
359
|
-
/**
|
|
360
|
-
* Used if you want to override the validation of the original field. For example if you want to add your customized condition for password validations.
|
|
361
|
-
* @default 'Same as schema'
|
|
362
|
-
*/
|
|
363
|
-
yupValidationSchema?: Yup.Schema;
|
|
364
|
-
/**
|
|
365
|
-
* Used to add the create new icon on the reference field. Only used when the type of the field is reference
|
|
366
|
-
* @default false
|
|
367
|
-
*/
|
|
368
|
-
enableCreateNewButtonOnReference?: boolean;
|
|
369
|
-
/**
|
|
370
|
-
* Used only with text field types like Text field or Localized string
|
|
371
|
-
* @default false
|
|
372
|
-
*/
|
|
373
|
-
textArea?: boolean;
|
|
374
|
-
/**
|
|
375
|
-
* Used to add the relatedFields option in the field. Only used when the type of the field is reference
|
|
376
|
-
* @default undefined
|
|
377
|
-
*/
|
|
378
|
-
relatedFields?: string[];
|
|
379
|
-
/**
|
|
380
|
-
* Only used if the field type is REFERENCE. Used to filter the list of referenced items.
|
|
381
|
-
*/
|
|
382
|
-
filter?: {
|
|
383
|
-
formList?: Record<string, any>;
|
|
384
|
-
filterList?: Record<string, any>;
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* Path to access the resource.
|
|
388
|
-
*/
|
|
389
|
-
path?: string;
|
|
390
|
-
/**
|
|
391
|
-
* Determines the minimum width for column in list
|
|
392
|
-
*/
|
|
393
|
-
minWidth?: number;
|
|
394
|
-
}
|
|
395
|
-
export interface IVirtualValue {
|
|
396
|
-
/**
|
|
397
|
-
* For now we have some virtual fields that can be added
|
|
398
|
-
* 1) Password: If you want to add password field in the creation form for example
|
|
399
|
-
* 2) ref: If it is a one to many realtion. For example, if you want to get all subCatogeries that belong to a category when you show the category record
|
|
400
|
-
* 3) array: If this field is an array
|
|
401
|
-
*/
|
|
402
|
-
type: VirtualFieldTypes;
|
|
403
|
-
/**
|
|
404
|
-
* Specify the key that should be filtered by in case of 1 to many realtionship
|
|
405
|
-
*/
|
|
406
|
-
filterBy?: string;
|
|
407
|
-
/**
|
|
408
|
-
* Array type exists only if the type is array
|
|
409
|
-
*/
|
|
410
|
-
arrayType?: string;
|
|
411
|
-
/**
|
|
412
|
-
* Defines where this virtaul field need to be appeared
|
|
413
|
-
*/
|
|
414
|
-
showIn: Virtuals;
|
|
415
|
-
required: boolean;
|
|
416
|
-
/**
|
|
417
|
-
* Define Virtual field's resource in case of ref type or array of ref type
|
|
418
|
-
*/
|
|
419
|
-
resource?: Model<any, any>;
|
|
420
|
-
/**
|
|
421
|
-
* Define Filter query creator required in case of showIn Filter
|
|
422
|
-
*/
|
|
423
|
-
handler?: (filterQuery: {
|
|
424
|
-
[key: string]: any;
|
|
425
|
-
}, value: any | any[]) => Promise<{
|
|
426
|
-
[key: string]: any;
|
|
427
|
-
}>;
|
|
428
|
-
}
|
|
429
|
-
export interface IModel {
|
|
430
|
-
/**
|
|
431
|
-
* virtual data props
|
|
432
|
-
*/
|
|
433
|
-
virtuals?: {
|
|
434
|
-
[key: string]: IVirtualValue;
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
interface ActionOptions {
|
|
438
|
-
show?: Action;
|
|
439
|
-
new?: Action;
|
|
440
|
-
edit?: Action;
|
|
441
|
-
delete?: Action;
|
|
442
|
-
bulkDelete?: Action;
|
|
443
|
-
/**
|
|
444
|
-
* Any extra action to be added.
|
|
445
|
-
*/
|
|
446
|
-
extras?: ExtraAction[];
|
|
447
|
-
}
|
|
448
|
-
export interface ExtraAction {
|
|
449
|
-
/**
|
|
450
|
-
* Key of this action.
|
|
451
|
-
* Should be unique in the same resource file
|
|
452
|
-
*/
|
|
453
|
-
key: string;
|
|
454
|
-
/**
|
|
455
|
-
* Name of this action
|
|
456
|
-
*/
|
|
457
|
-
name: string;
|
|
458
|
-
/**
|
|
459
|
-
* Icon of this action.
|
|
460
|
-
* {@link https://mui.com/material-ui/material-icons/}
|
|
461
|
-
*/
|
|
462
|
-
icon: string;
|
|
463
|
-
/**
|
|
464
|
-
* Color of the action button
|
|
465
|
-
* In case of bulk actions it is one of the button colors. @default inherit
|
|
466
|
-
* In case of record actions it is any color like red, green, ... @default black
|
|
467
|
-
*/
|
|
468
|
-
color?: string | ButtonColors;
|
|
469
|
-
/**
|
|
470
|
-
* Size of the action button. Only used in case of bulk actions
|
|
471
|
-
* @default small
|
|
472
|
-
*/
|
|
473
|
-
size?: ButtonSizes;
|
|
474
|
-
/**
|
|
475
|
-
* Variant of the action button. Only used in case of bulk actions
|
|
476
|
-
* @default contained
|
|
477
|
-
*/
|
|
478
|
-
variant?: ButtonVariants;
|
|
479
|
-
/**
|
|
480
|
-
* Action type if it is record action or resource action.
|
|
481
|
-
*/
|
|
482
|
-
actionType: ActionTypes;
|
|
483
|
-
/**
|
|
484
|
-
* Guard message title that appears before executing the action to confirm execution.
|
|
485
|
-
* @default 'No guard message'
|
|
486
|
-
*/
|
|
487
|
-
guardTitle?: string;
|
|
488
|
-
/**
|
|
489
|
-
* Guard message body that appears before executing the action to confirm execution.
|
|
490
|
-
* @default 'No guard message'
|
|
491
|
-
*/
|
|
492
|
-
guard?: string;
|
|
493
|
-
/**
|
|
494
|
-
* Alert message appear after executing this action.
|
|
495
|
-
* @default 'Action was executed successfully'
|
|
496
|
-
*/
|
|
497
|
-
message?: string;
|
|
498
|
-
/**
|
|
499
|
-
* Specify if you need the alert message to appear after executing this action
|
|
500
|
-
* @default 'true'
|
|
501
|
-
*/
|
|
502
|
-
showAlertMessage?: boolean;
|
|
503
|
-
/**
|
|
504
|
-
* The severity of the alert. This defines the color and icon used.
|
|
505
|
-
* @default 'success'
|
|
506
|
-
*/
|
|
507
|
-
severity?: Severity;
|
|
508
|
-
/**
|
|
509
|
-
* Specify if you need the dialog to be in full screen or not. Used only in case of custom component strategy
|
|
510
|
-
* @default 'false'
|
|
511
|
-
*/
|
|
512
|
-
fullScreen?: boolean;
|
|
513
|
-
/**
|
|
514
|
-
* @returns boolean value.
|
|
515
|
-
* This value Specifies to which records should this action appears.
|
|
516
|
-
* @default 'Action is shown to all records'
|
|
517
|
-
*/
|
|
518
|
-
isVisible?: (data: ActionData) => Promise<boolean>;
|
|
519
|
-
/**
|
|
520
|
-
* Handler function that is executed after clicking the action.
|
|
521
|
-
*/
|
|
522
|
-
handler: (req: IRequest, res: any, data: ActionData) => Promise<IActionHandlerResponse>;
|
|
523
|
-
/**
|
|
524
|
-
* Icon of this action.
|
|
525
|
-
* {@link https://mui.com/material-ui/material-icons/}
|
|
526
|
-
*/
|
|
527
|
-
handlerStrategy?: HandlerStrategy;
|
|
528
|
-
/**
|
|
529
|
-
* The property that manages which action will be extracted from action menu in list.
|
|
530
|
-
* @default true for edit and show false for others
|
|
531
|
-
*/
|
|
532
|
-
isMainAction?: boolean;
|
|
533
|
-
}
|
|
534
|
-
export interface IActionHandlerResponse {
|
|
535
|
-
/**
|
|
536
|
-
* The action taken after executing the action.
|
|
537
|
-
* For example, if you would like to go to list after executing the action, just set this value by list
|
|
538
|
-
*/
|
|
539
|
-
action: ActionNames;
|
|
540
|
-
/**
|
|
541
|
-
* Path of the resource that is intended to redirect.
|
|
542
|
-
* Is set to resource.path if you would like to be in the same table
|
|
543
|
-
*/
|
|
544
|
-
path: string;
|
|
545
|
-
/**
|
|
546
|
-
* Id of the record that is used in actions that needs record id like show or edit
|
|
547
|
-
*/
|
|
548
|
-
recordId?: string;
|
|
549
|
-
/**
|
|
550
|
-
* Path of the uploaded file in case of file download handling strategy
|
|
551
|
-
*/
|
|
552
|
-
filePath?: string;
|
|
553
|
-
}
|
|
554
|
-
export interface IResourceFile {
|
|
555
|
-
properties: {
|
|
556
|
-
/**
|
|
557
|
-
* The model
|
|
558
|
-
*/
|
|
559
|
-
resource: Model<any, any>;
|
|
560
|
-
/**
|
|
561
|
-
* Model name as saved in the data base.
|
|
562
|
-
*/
|
|
563
|
-
modelName: string;
|
|
564
|
-
/**
|
|
565
|
-
* Name of this model appeared on the nav bar.
|
|
566
|
-
* @default 'Model name'
|
|
567
|
-
*/
|
|
568
|
-
name?: string;
|
|
569
|
-
/**
|
|
570
|
-
* Property of this table that is shown as the link for the record.
|
|
571
|
-
* Used to be searched by in the search bar.
|
|
572
|
-
* If not mentioned explicitly, a search is done on the schema to check for property title, name, or email.
|
|
573
|
-
* If these properties are not found, _id is taken.
|
|
574
|
-
*/
|
|
575
|
-
title?: string;
|
|
576
|
-
/**
|
|
577
|
-
* The property to be sorted by the documents.
|
|
578
|
-
* @default 'The schema title'
|
|
579
|
-
*/
|
|
580
|
-
defaultOrderBy?: string;
|
|
581
|
-
/**
|
|
582
|
-
* The property that controls the permission of this model according to the current user role.
|
|
583
|
-
* Specify either this user is allowed to see this model or not.
|
|
584
|
-
* @default true
|
|
585
|
-
*/
|
|
586
|
-
isAllowed?: (currentUser: Document) => Promise<boolean>;
|
|
587
|
-
/**
|
|
588
|
-
* The property that controls the visibility of this resource in the nav bar
|
|
589
|
-
* @default true
|
|
590
|
-
*/
|
|
591
|
-
isVisible?: (currentUser: Document) => Promise<boolean>;
|
|
592
|
-
/**
|
|
593
|
-
* The property that controls the ability of logging changes of this resource.
|
|
594
|
-
* @default false
|
|
595
|
-
*/
|
|
596
|
-
enableLog?: (currentUser: Document) => Promise<boolean>;
|
|
597
|
-
/**
|
|
598
|
-
* The default order
|
|
599
|
-
* @default asc
|
|
600
|
-
*/
|
|
601
|
-
defaultOrder?: orderTypes;
|
|
602
|
-
/**
|
|
603
|
-
* Number of rows per page
|
|
604
|
-
* @default 10
|
|
605
|
-
*/
|
|
606
|
-
defaultrowsPerPage?: number;
|
|
607
|
-
/**
|
|
608
|
-
* The parent that this model is belong to in the nav bar.
|
|
609
|
-
* @default 'Set up parent'
|
|
610
|
-
*/
|
|
611
|
-
parent?: Parent;
|
|
612
|
-
/**
|
|
613
|
-
* Array of fields that are completely hidden from all pages
|
|
614
|
-
*/
|
|
615
|
-
hiddenProperties?: string[];
|
|
616
|
-
/**
|
|
617
|
-
* Action options for overriding existing actions accessibility or adding custom actions
|
|
618
|
-
*/
|
|
619
|
-
actions?: ActionOptions;
|
|
620
|
-
/**
|
|
621
|
-
* Filters options
|
|
622
|
-
*/
|
|
623
|
-
filters?: IFilters;
|
|
624
|
-
/**
|
|
625
|
-
* Using before or after handlers of any crud operation
|
|
626
|
-
*/
|
|
627
|
-
crudOperations?: ICrudOperations;
|
|
628
|
-
/**
|
|
629
|
-
* Translation object of the fields' names.
|
|
630
|
-
*/
|
|
631
|
-
keysTranslations?: {
|
|
632
|
-
[key: string]: any;
|
|
633
|
-
};
|
|
634
|
-
/**
|
|
635
|
-
* Translation object of the actions' names.
|
|
636
|
-
*/
|
|
637
|
-
actionsTranslations?: {
|
|
638
|
-
[key: string]: any;
|
|
639
|
-
};
|
|
640
|
-
/**
|
|
641
|
-
* Override some props of a field's schema structure
|
|
642
|
-
* Add a new virtual property
|
|
643
|
-
*/
|
|
644
|
-
model?: {
|
|
645
|
-
[key: string]: IFieldValue;
|
|
646
|
-
} | IModel;
|
|
647
|
-
/**
|
|
648
|
-
* Override the populated object
|
|
649
|
-
*/
|
|
650
|
-
populate?: IPopulate;
|
|
651
|
-
/**
|
|
652
|
-
* Disable the display of next and previous buttons in the show page
|
|
653
|
-
* @default false
|
|
654
|
-
*/
|
|
655
|
-
disableNextPreviousButtonsInShowPage?: boolean;
|
|
656
|
-
/**
|
|
657
|
-
* Disable the display of next and previous buttons in the edit page
|
|
658
|
-
* @default false
|
|
659
|
-
*/
|
|
660
|
-
disableNextPreviousButtonsInEditPage?: boolean;
|
|
661
|
-
/**
|
|
662
|
-
* The option to display the edit page instead of the show page
|
|
663
|
-
* @default false
|
|
664
|
-
*/
|
|
665
|
-
displayEditPageInShowPage?: boolean;
|
|
666
|
-
/**
|
|
667
|
-
* Specify the path of image to be shown beside the name in the reference options
|
|
668
|
-
* @default undefined
|
|
669
|
-
*/
|
|
670
|
-
imageOnReferencePath?: string;
|
|
671
|
-
/**
|
|
672
|
-
* The option to disable displaying the image beside the name in the reference options
|
|
673
|
-
* @default false
|
|
674
|
-
*/
|
|
675
|
-
disableImageOnReference?: boolean;
|
|
676
|
-
/**
|
|
677
|
-
* An object for any extra data need to be sent with the resource file
|
|
678
|
-
* @default undefined
|
|
679
|
-
*/
|
|
680
|
-
extras?: {
|
|
681
|
-
[key: string]: any;
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
*
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
*
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
*
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1
|
+
import { ValidationChain } from 'express-validator';
|
|
2
|
+
import { Document, Model } from 'mongoose';
|
|
3
|
+
import { IRequest } from '../middlewares/isAuth';
|
|
4
|
+
import { IRepository, PageInfo, PaginateParams } from '../repositories/Repository';
|
|
5
|
+
import SaveResult from '../repositories/SaveResult';
|
|
6
|
+
import { ActionNames, ActionTypes, FieldTypes, FileTypes, HandlerStrategy, ImageOptimizingCategories, NeighborTypes, Virtuals } from './helpers';
|
|
7
|
+
import * as Yup from 'yup';
|
|
8
|
+
declare type orderTypes = 'asc' | 'desc';
|
|
9
|
+
declare type VirtualFieldTypes = 'password' | 'ref' | 'Array';
|
|
10
|
+
declare type Severity = 'success' | 'info' | 'warning' | 'error';
|
|
11
|
+
declare type ButtonColors = 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
|
|
12
|
+
declare type ButtonVariants = 'text' | 'outlined' | 'contained';
|
|
13
|
+
declare type ButtonSizes = 'small' | 'medium' | 'large';
|
|
14
|
+
declare type PopulateFunction = (populatedString: any) => Promise<any>;
|
|
15
|
+
interface Parent {
|
|
16
|
+
/**
|
|
17
|
+
* Name of the parent
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* Icon of the parent. You can get the icons from
|
|
22
|
+
* {@link https://mui.com/material-ui/material-icons/}
|
|
23
|
+
*/
|
|
24
|
+
icon: string;
|
|
25
|
+
}
|
|
26
|
+
interface IPopulate {
|
|
27
|
+
/**
|
|
28
|
+
* This function is called for all the endpoints to have an access over the populated string
|
|
29
|
+
*/
|
|
30
|
+
all?: PopulateFunction;
|
|
31
|
+
/**
|
|
32
|
+
* This function is called for the list endpoint to have an access over the populated string
|
|
33
|
+
*/
|
|
34
|
+
list?: PopulateFunction;
|
|
35
|
+
/**
|
|
36
|
+
* This function is called for the get one endpoint either in show or form an access over the populated string
|
|
37
|
+
*/
|
|
38
|
+
show?: PopulateFunction;
|
|
39
|
+
}
|
|
40
|
+
interface Action {
|
|
41
|
+
/**
|
|
42
|
+
* Specify if this action is accessible or not.
|
|
43
|
+
* @default True for show, edit, delete, and new.
|
|
44
|
+
* @default false for bulk delete.
|
|
45
|
+
* You can ovveride any of these values here.
|
|
46
|
+
*/
|
|
47
|
+
isAccessible?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Specify if the page requires to be reloaded after executing the action
|
|
50
|
+
* @default Fale for show, edit, delete, and new.
|
|
51
|
+
*/
|
|
52
|
+
reloadAfterAction?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The property that manages which admin role can use this action.
|
|
55
|
+
* This function's result alters the isAccessible value. So no need to use both properties.
|
|
56
|
+
* If both are used then isAccessible has the higher priority.
|
|
57
|
+
* @default 'Same as isAccessible'
|
|
58
|
+
*/
|
|
59
|
+
isAllowed?: (currentUser: Document) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The property that manages which action will be extracted from action menu in list.
|
|
62
|
+
* @default true for edit and show false for others
|
|
63
|
+
*/
|
|
64
|
+
isMainAction?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Specify if this action is visible or not per record.
|
|
67
|
+
* @default 'Same as isAccessible'
|
|
68
|
+
*/
|
|
69
|
+
isVisible?: (data: ActionData) => Promise<boolean>;
|
|
70
|
+
}
|
|
71
|
+
interface ICrudOperations {
|
|
72
|
+
index?: {
|
|
73
|
+
/**
|
|
74
|
+
* Before handler that gives you the access to the filter object.
|
|
75
|
+
* You can add to the filter object any key and value that will be used in the filter query before getting the records for list.
|
|
76
|
+
* @returns the filter object
|
|
77
|
+
*/
|
|
78
|
+
before?: (req: IRequest, filter: {
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}, currentUser: Document) => Promise<{
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* After handler that gives you the access to the array of documents.
|
|
85
|
+
* @returns the array of documents
|
|
86
|
+
*/
|
|
87
|
+
after?: (req: IRequest, documents: Document[], currentUser: Document) => Promise<Document[]>;
|
|
88
|
+
/**
|
|
89
|
+
* index handler that gives you the access to the run custom index method with custom query.
|
|
90
|
+
* @returns result list of records
|
|
91
|
+
*/
|
|
92
|
+
index?: (req: IRequest, filter: {
|
|
93
|
+
[key: string]: any;
|
|
94
|
+
}, sortQuery: {
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
}, paginateParams: PaginateParams | undefined, populate: any, currentUser: Document) => Promise<{
|
|
97
|
+
records: Document[];
|
|
98
|
+
pageInfo?: PageInfo;
|
|
99
|
+
}>;
|
|
100
|
+
};
|
|
101
|
+
create?: {
|
|
102
|
+
/**
|
|
103
|
+
* Before handler that is called before creating a new record.
|
|
104
|
+
* This function gives you the access to the record params before saving it, you can perform any update to the params before saving it.
|
|
105
|
+
* @returns the params
|
|
106
|
+
*/
|
|
107
|
+
before?: (req: IRequest, params: any, currentUser: Document) => Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* After handler that gives you the access to the saved document.
|
|
110
|
+
* @returns the saved document
|
|
111
|
+
*/
|
|
112
|
+
after?: (req: IRequest, document: Document, currentUser: Document, params: any) => Promise<Document>;
|
|
113
|
+
/**
|
|
114
|
+
* Validators consist of an array of Express ValidationChain, each comprising validation functions that are executed before triggering the save query.
|
|
115
|
+
*/
|
|
116
|
+
validators?: ValidationChain[];
|
|
117
|
+
};
|
|
118
|
+
update?: {
|
|
119
|
+
/**
|
|
120
|
+
* Before handler that is called before updating a record.
|
|
121
|
+
* This function gives you the access to the record params before saving it, you can perform any update to the params before saving it.
|
|
122
|
+
* @returns the params
|
|
123
|
+
*/
|
|
124
|
+
before?: (req: IRequest, params: any, currentUser: Document) => Promise<any>;
|
|
125
|
+
/**
|
|
126
|
+
* After handler that gives you the access to the updated document.
|
|
127
|
+
* @returns the updated document
|
|
128
|
+
*/
|
|
129
|
+
after?: (req: IRequest, document: Document, params: any, currentUser: Document) => Promise<Document>;
|
|
130
|
+
/**
|
|
131
|
+
* update handler that gives you the access to the run custom update method with custom query.
|
|
132
|
+
* @returns saved result with updated document
|
|
133
|
+
*/
|
|
134
|
+
update?: (req: IRequest, record: Document, recordParams: any, currentUser: Document) => Promise<SaveResult<any>>;
|
|
135
|
+
/**
|
|
136
|
+
* Validators consist of an array of Express ValidationChain, each comprising validation functions that are executed before triggering the update query.
|
|
137
|
+
*/
|
|
138
|
+
validators?: ValidationChain[];
|
|
139
|
+
};
|
|
140
|
+
show?: {
|
|
141
|
+
/**
|
|
142
|
+
* Before handler that gives you the access to the filter object.
|
|
143
|
+
* You can add to the filter object any key and value that will be used in the filter query before getting the records for list.
|
|
144
|
+
* @returns the filter object
|
|
145
|
+
*/
|
|
146
|
+
before?: (req: IRequest, filter: {
|
|
147
|
+
[key: string]: any;
|
|
148
|
+
}, currentUser: Document) => Promise<{
|
|
149
|
+
[key: string]: any;
|
|
150
|
+
}>;
|
|
151
|
+
after?: (req: IRequest, record: Document) => Promise<{
|
|
152
|
+
record: Document;
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* A function that is called before getting the next or the previous record. It gives you the access to the filter object.
|
|
157
|
+
* @returns The filter object
|
|
158
|
+
*/
|
|
159
|
+
nextPreviousButtonHandler?: (req: IRequest, filter: {
|
|
160
|
+
[key: string]: any;
|
|
161
|
+
}, currentUser: Document, direction: NeighborTypes) => Promise<{
|
|
162
|
+
[key: string]: any;
|
|
163
|
+
}>;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export interface ActionData {
|
|
167
|
+
/**
|
|
168
|
+
* Record document
|
|
169
|
+
*/
|
|
170
|
+
record: any;
|
|
171
|
+
/**
|
|
172
|
+
* Current user data
|
|
173
|
+
*/
|
|
174
|
+
currentUser: Document;
|
|
175
|
+
/**
|
|
176
|
+
* Resource data to which this record belongs
|
|
177
|
+
*/
|
|
178
|
+
resource: {
|
|
179
|
+
/**
|
|
180
|
+
* Model name of this table.
|
|
181
|
+
*/
|
|
182
|
+
name: string;
|
|
183
|
+
/**
|
|
184
|
+
* Path of the resource to which you can redirect.
|
|
185
|
+
*/
|
|
186
|
+
path: string;
|
|
187
|
+
/**
|
|
188
|
+
* Repository of this resource.
|
|
189
|
+
*/
|
|
190
|
+
repository: IRepository<Document>;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
interface IFilters {
|
|
194
|
+
/**
|
|
195
|
+
* Scope filter props.
|
|
196
|
+
* Can be either auto or manual. It cannot be both.
|
|
197
|
+
* This filter is not accessible by default
|
|
198
|
+
*/
|
|
199
|
+
scopes?: {
|
|
200
|
+
/**
|
|
201
|
+
* Specify if this filter is accessible or not
|
|
202
|
+
* @default false
|
|
203
|
+
*/
|
|
204
|
+
isAccessible: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Show All tab
|
|
207
|
+
* @default true
|
|
208
|
+
*/
|
|
209
|
+
showAll?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Automatic scope that filters by the specified key with one of the given options
|
|
212
|
+
* This filter works automatically by mentioning the key as saved in the database along with the values that this key can has.
|
|
213
|
+
* It doesn't need a handler
|
|
214
|
+
*/
|
|
215
|
+
auto?: IAutoScope;
|
|
216
|
+
/**
|
|
217
|
+
* Manual scope by using a handler.
|
|
218
|
+
* In this case you can put the options you like with specifying in the handler what to do with each option.
|
|
219
|
+
*/
|
|
220
|
+
manual?: IManualScope;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Search bar filter props
|
|
224
|
+
*/
|
|
225
|
+
searchBar?: {
|
|
226
|
+
/**
|
|
227
|
+
* Specify if this filter is accessible or not
|
|
228
|
+
* @default true
|
|
229
|
+
*/
|
|
230
|
+
isAccessible: boolean;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
interface IAutoScope {
|
|
234
|
+
/**
|
|
235
|
+
* Key of property as specified in the database
|
|
236
|
+
*/
|
|
237
|
+
key: string;
|
|
238
|
+
/**
|
|
239
|
+
* Array of values that this key can have
|
|
240
|
+
*/
|
|
241
|
+
options: string[];
|
|
242
|
+
}
|
|
243
|
+
interface IManualScope {
|
|
244
|
+
/**
|
|
245
|
+
* Array of values that will be appeared in the scope
|
|
246
|
+
*/
|
|
247
|
+
options: string[];
|
|
248
|
+
/**
|
|
249
|
+
* A handler that will be called when scope filter is used.
|
|
250
|
+
* This handler should perform a switch case on the specified options values, each case set the filter on its way.
|
|
251
|
+
*/
|
|
252
|
+
handler: (filter: {
|
|
253
|
+
[key: string]: any;
|
|
254
|
+
}, scope: string, currentUser: Document) => Promise<{
|
|
255
|
+
[key: string]: any;
|
|
256
|
+
}>;
|
|
257
|
+
}
|
|
258
|
+
export interface IFieldValue {
|
|
259
|
+
/**
|
|
260
|
+
* If the field is required in the schema and you don't want it to be required in the form, you can override this here.
|
|
261
|
+
* @default 'same as schema'
|
|
262
|
+
*/
|
|
263
|
+
required?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Specify either this field can be edited or not.
|
|
266
|
+
* @default true
|
|
267
|
+
*/
|
|
268
|
+
isEditable?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Specify the type of the field. Can be used for specifying localized string, image,... etc.
|
|
271
|
+
* @default 'Same as schema''
|
|
272
|
+
*/
|
|
273
|
+
type?: FieldTypes;
|
|
274
|
+
/**
|
|
275
|
+
* Specify the enum values if the field type is an enum.
|
|
276
|
+
* You can give custom labels with custom background color of the chib as color and label color as labelColor
|
|
277
|
+
* @default 'Same as schema''
|
|
278
|
+
*/
|
|
279
|
+
enumValues?: string[] | {
|
|
280
|
+
[key: string]: {
|
|
281
|
+
label: string;
|
|
282
|
+
color: string;
|
|
283
|
+
labelColor: string;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Specify the allowed country codes.
|
|
288
|
+
* @required if the type is phone number
|
|
289
|
+
* ex: ["sa", "eg", ...]
|
|
290
|
+
*/
|
|
291
|
+
countryCodes?: string[];
|
|
292
|
+
/**
|
|
293
|
+
* Specify the default country code.
|
|
294
|
+
* ex: ["sa", "eg", ...]
|
|
295
|
+
* @default 'First country of provided country codes or sa if no country codes provided'
|
|
296
|
+
*/
|
|
297
|
+
defaultCountryCode?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Specify the array type if the field is of type array.
|
|
300
|
+
* @default 'Same as schema''
|
|
301
|
+
*/
|
|
302
|
+
arrayType?: FieldTypes;
|
|
303
|
+
/**
|
|
304
|
+
* Specify if the array is draggable. Only used when the field type is an array.
|
|
305
|
+
* @default 'true''
|
|
306
|
+
*/
|
|
307
|
+
isDraggable?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Can be used only if this field is a reference to the Image collection
|
|
310
|
+
*/
|
|
311
|
+
mediaUploader?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Used only if this field is of type image. It specifies what is the optimizing level of an image before upload
|
|
314
|
+
* @default NORMAL
|
|
315
|
+
*/
|
|
316
|
+
imageOptimizingCategory?: ImageOptimizingCategories;
|
|
317
|
+
/**
|
|
318
|
+
* Specify the type of the file to be uploaded. Only required if the media uploader is true.
|
|
319
|
+
* @default image
|
|
320
|
+
*/
|
|
321
|
+
fileType?: FileTypes;
|
|
322
|
+
/**
|
|
323
|
+
* Specify if the date is shown with time or not. Only used if the field type is Date
|
|
324
|
+
* @default false
|
|
325
|
+
*/
|
|
326
|
+
withTime?: boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Specify the api route that to be called for getting the referenced values
|
|
329
|
+
* @default undefined
|
|
330
|
+
*/
|
|
331
|
+
apiRoute?: string;
|
|
332
|
+
/**
|
|
333
|
+
* Path of the value inside the model schema
|
|
334
|
+
* @default undefined
|
|
335
|
+
*/
|
|
336
|
+
valuePath?: string;
|
|
337
|
+
/**
|
|
338
|
+
* Specify if this property is clickable or not in the list view.
|
|
339
|
+
* @default undefined
|
|
340
|
+
*/
|
|
341
|
+
isClickable?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Specify the keys that will be shown in the nested schema. Only used when the type is nested schema
|
|
344
|
+
* @default undefined
|
|
345
|
+
*/
|
|
346
|
+
keys?: string[];
|
|
347
|
+
/**
|
|
348
|
+
* Specify the nested schema. Only used if the type is nested schema.
|
|
349
|
+
* @default undefined
|
|
350
|
+
*/
|
|
351
|
+
schema?: IModel | {
|
|
352
|
+
[key: string]: IFieldValue;
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Specify if this field is filtered by multiple values not only one value. Only used if this value is one of the quick filters.
|
|
356
|
+
* @default undefined
|
|
357
|
+
*/
|
|
358
|
+
multipleInFilter?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Used if you want to override the validation of the original field. For example if you want to add your customized condition for password validations.
|
|
361
|
+
* @default 'Same as schema'
|
|
362
|
+
*/
|
|
363
|
+
yupValidationSchema?: Yup.Schema;
|
|
364
|
+
/**
|
|
365
|
+
* Used to add the create new icon on the reference field. Only used when the type of the field is reference
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
368
|
+
enableCreateNewButtonOnReference?: boolean;
|
|
369
|
+
/**
|
|
370
|
+
* Used only with text field types like Text field or Localized string
|
|
371
|
+
* @default false
|
|
372
|
+
*/
|
|
373
|
+
textArea?: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Used to add the relatedFields option in the field. Only used when the type of the field is reference
|
|
376
|
+
* @default undefined
|
|
377
|
+
*/
|
|
378
|
+
relatedFields?: string[];
|
|
379
|
+
/**
|
|
380
|
+
* Only used if the field type is REFERENCE. Used to filter the list of referenced items.
|
|
381
|
+
*/
|
|
382
|
+
filter?: {
|
|
383
|
+
formList?: Record<string, any>;
|
|
384
|
+
filterList?: Record<string, any>;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Path to access the resource.
|
|
388
|
+
*/
|
|
389
|
+
path?: string;
|
|
390
|
+
/**
|
|
391
|
+
* Determines the minimum width for column in list
|
|
392
|
+
*/
|
|
393
|
+
minWidth?: number;
|
|
394
|
+
}
|
|
395
|
+
export interface IVirtualValue {
|
|
396
|
+
/**
|
|
397
|
+
* For now we have some virtual fields that can be added
|
|
398
|
+
* 1) Password: If you want to add password field in the creation form for example
|
|
399
|
+
* 2) ref: If it is a one to many realtion. For example, if you want to get all subCatogeries that belong to a category when you show the category record
|
|
400
|
+
* 3) array: If this field is an array
|
|
401
|
+
*/
|
|
402
|
+
type: VirtualFieldTypes;
|
|
403
|
+
/**
|
|
404
|
+
* Specify the key that should be filtered by in case of 1 to many realtionship
|
|
405
|
+
*/
|
|
406
|
+
filterBy?: string;
|
|
407
|
+
/**
|
|
408
|
+
* Array type exists only if the type is array
|
|
409
|
+
*/
|
|
410
|
+
arrayType?: string;
|
|
411
|
+
/**
|
|
412
|
+
* Defines where this virtaul field need to be appeared
|
|
413
|
+
*/
|
|
414
|
+
showIn: Virtuals;
|
|
415
|
+
required: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Define Virtual field's resource in case of ref type or array of ref type
|
|
418
|
+
*/
|
|
419
|
+
resource?: Model<any, any>;
|
|
420
|
+
/**
|
|
421
|
+
* Define Filter query creator required in case of showIn Filter
|
|
422
|
+
*/
|
|
423
|
+
handler?: (filterQuery: {
|
|
424
|
+
[key: string]: any;
|
|
425
|
+
}, value: any | any[]) => Promise<{
|
|
426
|
+
[key: string]: any;
|
|
427
|
+
}>;
|
|
428
|
+
}
|
|
429
|
+
export interface IModel {
|
|
430
|
+
/**
|
|
431
|
+
* virtual data props
|
|
432
|
+
*/
|
|
433
|
+
virtuals?: {
|
|
434
|
+
[key: string]: IVirtualValue;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
interface ActionOptions {
|
|
438
|
+
show?: Action;
|
|
439
|
+
new?: Action;
|
|
440
|
+
edit?: Action;
|
|
441
|
+
delete?: Action;
|
|
442
|
+
bulkDelete?: Action;
|
|
443
|
+
/**
|
|
444
|
+
* Any extra action to be added.
|
|
445
|
+
*/
|
|
446
|
+
extras?: ExtraAction[];
|
|
447
|
+
}
|
|
448
|
+
export interface ExtraAction {
|
|
449
|
+
/**
|
|
450
|
+
* Key of this action.
|
|
451
|
+
* Should be unique in the same resource file
|
|
452
|
+
*/
|
|
453
|
+
key: string;
|
|
454
|
+
/**
|
|
455
|
+
* Name of this action
|
|
456
|
+
*/
|
|
457
|
+
name: string;
|
|
458
|
+
/**
|
|
459
|
+
* Icon of this action.
|
|
460
|
+
* {@link https://mui.com/material-ui/material-icons/}
|
|
461
|
+
*/
|
|
462
|
+
icon: string;
|
|
463
|
+
/**
|
|
464
|
+
* Color of the action button
|
|
465
|
+
* In case of bulk actions it is one of the button colors. @default inherit
|
|
466
|
+
* In case of record actions it is any color like red, green, ... @default black
|
|
467
|
+
*/
|
|
468
|
+
color?: string | ButtonColors;
|
|
469
|
+
/**
|
|
470
|
+
* Size of the action button. Only used in case of bulk actions
|
|
471
|
+
* @default small
|
|
472
|
+
*/
|
|
473
|
+
size?: ButtonSizes;
|
|
474
|
+
/**
|
|
475
|
+
* Variant of the action button. Only used in case of bulk actions
|
|
476
|
+
* @default contained
|
|
477
|
+
*/
|
|
478
|
+
variant?: ButtonVariants;
|
|
479
|
+
/**
|
|
480
|
+
* Action type if it is record action or resource action.
|
|
481
|
+
*/
|
|
482
|
+
actionType: ActionTypes;
|
|
483
|
+
/**
|
|
484
|
+
* Guard message title that appears before executing the action to confirm execution.
|
|
485
|
+
* @default 'No guard message'
|
|
486
|
+
*/
|
|
487
|
+
guardTitle?: string;
|
|
488
|
+
/**
|
|
489
|
+
* Guard message body that appears before executing the action to confirm execution.
|
|
490
|
+
* @default 'No guard message'
|
|
491
|
+
*/
|
|
492
|
+
guard?: string;
|
|
493
|
+
/**
|
|
494
|
+
* Alert message appear after executing this action.
|
|
495
|
+
* @default 'Action was executed successfully'
|
|
496
|
+
*/
|
|
497
|
+
message?: string;
|
|
498
|
+
/**
|
|
499
|
+
* Specify if you need the alert message to appear after executing this action
|
|
500
|
+
* @default 'true'
|
|
501
|
+
*/
|
|
502
|
+
showAlertMessage?: boolean;
|
|
503
|
+
/**
|
|
504
|
+
* The severity of the alert. This defines the color and icon used.
|
|
505
|
+
* @default 'success'
|
|
506
|
+
*/
|
|
507
|
+
severity?: Severity;
|
|
508
|
+
/**
|
|
509
|
+
* Specify if you need the dialog to be in full screen or not. Used only in case of custom component strategy
|
|
510
|
+
* @default 'false'
|
|
511
|
+
*/
|
|
512
|
+
fullScreen?: boolean;
|
|
513
|
+
/**
|
|
514
|
+
* @returns boolean value.
|
|
515
|
+
* This value Specifies to which records should this action appears.
|
|
516
|
+
* @default 'Action is shown to all records'
|
|
517
|
+
*/
|
|
518
|
+
isVisible?: (data: ActionData) => Promise<boolean>;
|
|
519
|
+
/**
|
|
520
|
+
* Handler function that is executed after clicking the action.
|
|
521
|
+
*/
|
|
522
|
+
handler: (req: IRequest, res: any, data: ActionData) => Promise<IActionHandlerResponse>;
|
|
523
|
+
/**
|
|
524
|
+
* Icon of this action.
|
|
525
|
+
* {@link https://mui.com/material-ui/material-icons/}
|
|
526
|
+
*/
|
|
527
|
+
handlerStrategy?: HandlerStrategy;
|
|
528
|
+
/**
|
|
529
|
+
* The property that manages which action will be extracted from action menu in list.
|
|
530
|
+
* @default true for edit and show false for others
|
|
531
|
+
*/
|
|
532
|
+
isMainAction?: boolean;
|
|
533
|
+
}
|
|
534
|
+
export interface IActionHandlerResponse {
|
|
535
|
+
/**
|
|
536
|
+
* The action taken after executing the action.
|
|
537
|
+
* For example, if you would like to go to list after executing the action, just set this value by list
|
|
538
|
+
*/
|
|
539
|
+
action: ActionNames;
|
|
540
|
+
/**
|
|
541
|
+
* Path of the resource that is intended to redirect.
|
|
542
|
+
* Is set to resource.path if you would like to be in the same table
|
|
543
|
+
*/
|
|
544
|
+
path: string;
|
|
545
|
+
/**
|
|
546
|
+
* Id of the record that is used in actions that needs record id like show or edit
|
|
547
|
+
*/
|
|
548
|
+
recordId?: string;
|
|
549
|
+
/**
|
|
550
|
+
* Path of the uploaded file in case of file download handling strategy
|
|
551
|
+
*/
|
|
552
|
+
filePath?: string;
|
|
553
|
+
}
|
|
554
|
+
export interface IResourceFile {
|
|
555
|
+
properties: {
|
|
556
|
+
/**
|
|
557
|
+
* The model
|
|
558
|
+
*/
|
|
559
|
+
resource: Model<any, any>;
|
|
560
|
+
/**
|
|
561
|
+
* Model name as saved in the data base.
|
|
562
|
+
*/
|
|
563
|
+
modelName: string;
|
|
564
|
+
/**
|
|
565
|
+
* Name of this model appeared on the nav bar.
|
|
566
|
+
* @default 'Model name'
|
|
567
|
+
*/
|
|
568
|
+
name?: string;
|
|
569
|
+
/**
|
|
570
|
+
* Property of this table that is shown as the link for the record.
|
|
571
|
+
* Used to be searched by in the search bar.
|
|
572
|
+
* If not mentioned explicitly, a search is done on the schema to check for property title, name, or email.
|
|
573
|
+
* If these properties are not found, _id is taken.
|
|
574
|
+
*/
|
|
575
|
+
title?: string;
|
|
576
|
+
/**
|
|
577
|
+
* The property to be sorted by the documents.
|
|
578
|
+
* @default 'The schema title'
|
|
579
|
+
*/
|
|
580
|
+
defaultOrderBy?: string;
|
|
581
|
+
/**
|
|
582
|
+
* The property that controls the permission of this model according to the current user role.
|
|
583
|
+
* Specify either this user is allowed to see this model or not.
|
|
584
|
+
* @default true
|
|
585
|
+
*/
|
|
586
|
+
isAllowed?: (currentUser: Document) => Promise<boolean>;
|
|
587
|
+
/**
|
|
588
|
+
* The property that controls the visibility of this resource in the nav bar
|
|
589
|
+
* @default true
|
|
590
|
+
*/
|
|
591
|
+
isVisible?: (currentUser: Document) => Promise<boolean>;
|
|
592
|
+
/**
|
|
593
|
+
* The property that controls the ability of logging changes of this resource.
|
|
594
|
+
* @default false
|
|
595
|
+
*/
|
|
596
|
+
enableLog?: (currentUser: Document) => Promise<boolean>;
|
|
597
|
+
/**
|
|
598
|
+
* The default order
|
|
599
|
+
* @default asc
|
|
600
|
+
*/
|
|
601
|
+
defaultOrder?: orderTypes;
|
|
602
|
+
/**
|
|
603
|
+
* Number of rows per page
|
|
604
|
+
* @default 10
|
|
605
|
+
*/
|
|
606
|
+
defaultrowsPerPage?: number;
|
|
607
|
+
/**
|
|
608
|
+
* The parent that this model is belong to in the nav bar.
|
|
609
|
+
* @default 'Set up parent'
|
|
610
|
+
*/
|
|
611
|
+
parent?: Parent;
|
|
612
|
+
/**
|
|
613
|
+
* Array of fields that are completely hidden from all pages
|
|
614
|
+
*/
|
|
615
|
+
hiddenProperties?: string[];
|
|
616
|
+
/**
|
|
617
|
+
* Action options for overriding existing actions accessibility or adding custom actions
|
|
618
|
+
*/
|
|
619
|
+
actions?: ActionOptions;
|
|
620
|
+
/**
|
|
621
|
+
* Filters options
|
|
622
|
+
*/
|
|
623
|
+
filters?: IFilters;
|
|
624
|
+
/**
|
|
625
|
+
* Using before or after handlers of any crud operation
|
|
626
|
+
*/
|
|
627
|
+
crudOperations?: ICrudOperations;
|
|
628
|
+
/**
|
|
629
|
+
* Translation object of the fields' names.
|
|
630
|
+
*/
|
|
631
|
+
keysTranslations?: {
|
|
632
|
+
[key: string]: any;
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* Translation object of the actions' names.
|
|
636
|
+
*/
|
|
637
|
+
actionsTranslations?: {
|
|
638
|
+
[key: string]: any;
|
|
639
|
+
};
|
|
640
|
+
/**
|
|
641
|
+
* Override some props of a field's schema structure
|
|
642
|
+
* Add a new virtual property
|
|
643
|
+
*/
|
|
644
|
+
model?: {
|
|
645
|
+
[key: string]: IFieldValue;
|
|
646
|
+
} | IModel;
|
|
647
|
+
/**
|
|
648
|
+
* Override the populated object
|
|
649
|
+
*/
|
|
650
|
+
populate?: IPopulate;
|
|
651
|
+
/**
|
|
652
|
+
* Disable the display of next and previous buttons in the show page
|
|
653
|
+
* @default false
|
|
654
|
+
*/
|
|
655
|
+
disableNextPreviousButtonsInShowPage?: boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Disable the display of next and previous buttons in the edit page
|
|
658
|
+
* @default false
|
|
659
|
+
*/
|
|
660
|
+
disableNextPreviousButtonsInEditPage?: boolean;
|
|
661
|
+
/**
|
|
662
|
+
* The option to display the edit page instead of the show page
|
|
663
|
+
* @default false
|
|
664
|
+
*/
|
|
665
|
+
displayEditPageInShowPage?: boolean;
|
|
666
|
+
/**
|
|
667
|
+
* Specify the path of image to be shown beside the name in the reference options
|
|
668
|
+
* @default undefined
|
|
669
|
+
*/
|
|
670
|
+
imageOnReferencePath?: string;
|
|
671
|
+
/**
|
|
672
|
+
* The option to disable displaying the image beside the name in the reference options
|
|
673
|
+
* @default false
|
|
674
|
+
*/
|
|
675
|
+
disableImageOnReference?: boolean;
|
|
676
|
+
/**
|
|
677
|
+
* An object for any extra data need to be sent with the resource file
|
|
678
|
+
* @default undefined
|
|
679
|
+
*/
|
|
680
|
+
extras?: {
|
|
681
|
+
[key: string]: any;
|
|
682
|
+
};
|
|
683
|
+
/**
|
|
684
|
+
* Used for sending draft mails in mail log
|
|
685
|
+
* @default undefined
|
|
686
|
+
*/
|
|
687
|
+
sendDraftMail?: (data: {
|
|
688
|
+
to: string;
|
|
689
|
+
subject: string;
|
|
690
|
+
html: string;
|
|
691
|
+
}) => Promise<void>;
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* Array of properties that should be appeared in the list action.
|
|
695
|
+
* @default 'The whole fields'
|
|
696
|
+
*/
|
|
697
|
+
listProperties?: string[];
|
|
698
|
+
/**
|
|
699
|
+
* Arrays of properties that should be appeared in the show action.
|
|
700
|
+
* @default 'The whole fields'
|
|
701
|
+
*/
|
|
702
|
+
showProperties?: string[];
|
|
703
|
+
/**
|
|
704
|
+
* Array of properties that should be appeared in the create/edit form.
|
|
705
|
+
* @default 'The whole fields'
|
|
706
|
+
*/
|
|
707
|
+
formProperties?: string[];
|
|
708
|
+
/**
|
|
709
|
+
* Array of properties that should be appeared in the filter.
|
|
710
|
+
* @default 'The whole fields'
|
|
711
|
+
*/
|
|
712
|
+
filterProperties?: string[];
|
|
713
|
+
/**
|
|
714
|
+
* Array of properties that should be appeared in the quick filters.
|
|
715
|
+
* @default 'Empty array'
|
|
716
|
+
*/
|
|
717
|
+
quickFilterProperties?: string[];
|
|
718
|
+
}
|
|
719
|
+
export {};
|