identity-admin 1.26.12 → 1.26.13

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