identity-admin 1.27.3 → 1.27.5

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