identity-admin 1.28.2 → 1.28.4

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