adminforth 1.0.83 → 1.0.86

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 (48) hide show
  1. package/dist/index.js +34 -16
  2. package/dist/modules/codeInjector.js +19 -10
  3. package/dist/plugins/ForeignInlineListPlugin/index.js +3 -2
  4. package/dist/servers/express.js +0 -3
  5. package/dist/spa/spa/package-lock.json +13 -0
  6. package/dist/spa/spa/package.json +1 -0
  7. package/dist/spa/spa/src/App.vue +44 -19
  8. package/dist/spa/spa/src/components/AcceptModal.vue +2 -9
  9. package/dist/spa/spa/src/components/Toast.vue +65 -0
  10. package/dist/spa/spa/src/components/ValueRenderer.vue +8 -8
  11. package/dist/spa/spa/src/composables/useStores.ts +51 -0
  12. package/dist/spa/spa/src/stores/core.ts +5 -1
  13. package/dist/spa/spa/src/stores/modal.ts +13 -2
  14. package/dist/spa/spa/src/stores/toast.ts +15 -0
  15. package/dist/spa/spa/src/views/CreateView.vue +25 -2
  16. package/dist/spa/spa/src/views/EditView.vue +28 -3
  17. package/dist/spa/spa/src/views/ListView.vue +28 -5
  18. package/dist/spa/spa/src/views/ShowView.vue +33 -7
  19. package/dist/types/AdminForthConfig.js +54 -0
  20. package/dist/types/FrontendAPI.js +7 -0
  21. package/documentation/docs/Getting Started.md +374 -0
  22. package/documentation/docs/Glossary.md +37 -0
  23. package/documentation/docs/image.png +0 -0
  24. package/documentation/docusaurus.config.ts +4 -4
  25. package/documentation/static/CNAME +1 -0
  26. package/index.ts +50 -35
  27. package/modules/codeInjector.ts +15 -6
  28. package/package.json +1 -1
  29. package/plugins/ForeignInlineListPlugin/index.ts +3 -3
  30. package/servers/express.ts +4 -9
  31. package/spa/package-lock.json +13 -0
  32. package/spa/package.json +1 -0
  33. package/spa/src/App.vue +44 -19
  34. package/spa/src/components/AcceptModal.vue +2 -9
  35. package/spa/src/components/Toast.vue +65 -0
  36. package/spa/src/components/ValueRenderer.vue +8 -8
  37. package/spa/src/composables/useStores.ts +51 -0
  38. package/spa/src/stores/core.ts +5 -1
  39. package/spa/src/stores/modal.ts +13 -2
  40. package/spa/src/stores/toast.ts +15 -0
  41. package/spa/src/views/CreateView.vue +25 -2
  42. package/spa/src/views/EditView.vue +28 -3
  43. package/spa/src/views/ListView.vue +28 -5
  44. package/spa/src/views/ShowView.vue +33 -7
  45. package/types/AdminForthConfig.ts +469 -42
  46. package/types/FrontendAPI.ts +73 -0
  47. package/documentation/static/img/docusaurus-social-card.jpg +0 -0
  48. package/documentation/static/img/tail.png:Zone.Identifier +0 -0
@@ -1,13 +1,89 @@
1
+ import { Express } from 'express';
1
2
 
2
-
3
- export interface CodeInjector {
3
+ export interface CodeInjectorType {
4
4
  srcFoldersToSync: Object;
5
5
  allComponentNames: Object;
6
6
  }
7
7
 
8
+ /**
9
+ * Implement this interface to create custom HTTP server adapter for AdminForth.
10
+ */
11
+ export interface GenericHttpServer {
12
+
13
+ // constructor(adminforth: AdminForthClass): void;
14
+
15
+ /**
16
+ * Sets up HTTP server to serve AdminForth SPA.
17
+ * if hotReload is true, it should proxy all requests and headers to Vite dev server at `http://localhost:5173$\{req.url\}`
18
+ * otherwise it should serve AdminForth SPA from dist folder. See Express for example.
19
+ */
20
+ setupSpaServer(): void;
21
+
22
+ }
23
+
24
+ export interface ExpressHttpServer extends GenericHttpServer {
25
+
26
+ /**
27
+ * Call this method to serve AdminForth SPA from Express instance.
28
+ * @param app : Express instance
29
+ */
30
+ serve(app: Express): void;
31
+
32
+ /**
33
+ * Method (middleware) to wrap express endpoints with authorization check.
34
+ * Adds adminUser to request object if user is authorized. Drops request with 401 status if user is not authorized.
35
+ * @param callable : Function which will be called if user is authorized.
36
+ *
37
+ * Example:
38
+ *
39
+ * ```ts
40
+ * expressApp.get('/myApi', authorize((req, res) => \{
41
+ * console.log('User is authorized', req.adminUser);
42
+ * res.json(\{ message: 'Hello World' \});
43
+ * \}));
44
+ * ``
45
+ *
46
+ */
47
+ authorize(callable: Function): void;
48
+ }
49
+
50
+
8
51
  export interface AdminForthClass {
9
52
  config: AdminForthConfig;
10
- codeInjector: CodeInjector;
53
+ codeInjector: CodeInjectorType;
54
+ express: GenericHttpServer;
55
+
56
+ auth: {
57
+
58
+ verify(jwt : string): any;
59
+ }
60
+
61
+ /**
62
+ * Internal flag which indicates if AdminForth is running in hot reload mode.
63
+ */
64
+ runningHotReload: boolean;
65
+
66
+
67
+ /**
68
+ * Connects to databases defined in datasources and fetches described resource columns to find out data types and constraints.
69
+ * You must call this method as soon as possible after AdminForth class is instantiated.
70
+ */
71
+ discoverDatabases(): Promise<void>;
72
+
73
+ /**
74
+ * Bundles AdminForth SPA by injecting custom components into internal pre-made SPA source code. It generates internally dist which then will be
75
+ * served by AdminForth HTTP adapter.
76
+ * Bundle is generated in /tmp folder so if you have ramfs or tmpfs this operation will be faster.
77
+ *
78
+ * We recommend calling this method from dedicated script which will be run by CI/CD pipeline in build time. This ensures lowest downtime for your users.
79
+ * However for simple setup you can call it from your main script, and users will see some "AdminForth is bundling" message in the admin panel while app is bundling.
80
+ */
81
+ bundleNow({ hotReload, verbose }: { hotReload: boolean, verbose: boolean }): Promise<void>;
82
+
83
+ /**
84
+ * This method will be automatically called from AdminForth HTTP adapter to serve AdminForth SPA.
85
+ */
86
+ setupEndpoints(server: GenericHttpServer): void;
11
87
  }
12
88
 
13
89
 
@@ -19,49 +95,285 @@ export interface AdminForthPluginType {
19
95
  componentPath(componentFile: string): string;
20
96
  }
21
97
 
98
+ export enum AdminForthMenuTypes {
99
+ /**
100
+ * HEADING is just a label in the menu.
101
+ * Respect `label` and `icon` property in {@link AdminForthConfigMenuItem}
102
+ */
103
+ heading = 'heading',
104
+
105
+ /**
106
+ * GROUP is a group of menu items.
107
+ * Respects `label`, `icon` and `children` properties in {@link AdminForthConfigMenuItem}
108
+ * use @AdminForthMenuTypes.open to set if group is open by default
109
+ */
110
+ group = 'group',
111
+
112
+ /**
113
+ * RESOURCE is a link to a resource.
114
+ * Respects `label`, `icon`, `resourceId`, `homepage`, `isStaticRoute` properties in {@link AdminForthConfigMenuItem}
115
+ */
116
+ resource = 'resource',
117
+
118
+ /**
119
+ * PAGE is a link to a custom page.
120
+ * Respects `label`, `icon`, `path`, `component`, `homepage`, `isStaticRoute`, properties in {@link AdminForthConfigMenuItem}
121
+ *
122
+ * Example:
123
+ *
124
+ * ```ts
125
+ * \{
126
+ * type: AdminForthMenuTypes.PAGE,
127
+ * label: 'Custom Page',
128
+ * icon: 'home',
129
+ * path: '/dash',
130
+ * component: '@@/Dashboard.vue',
131
+ * homepage: true,
132
+ * \}
133
+ * ```
134
+ *
135
+ */
136
+ page = 'page',
137
+
138
+ /**
139
+ * GAP ads some space between menu items.
140
+ */
141
+ gap = 'gap',
142
+
143
+ /**
144
+ * DIVIDER is a divider between menu items.
145
+ */
146
+ divider = 'divider',
147
+ }
148
+
149
+ export enum AdminForthResourcePages {
150
+ list = 'list',
151
+ show = 'show',
152
+ edit = 'edit',
153
+ create = 'create',
154
+ filter = 'filter',
155
+ }
156
+
157
+
158
+ /**
159
+ * Menu item which displayed in the left sidebar of the admin panel.
160
+ */
22
161
  export type AdminForthConfigMenuItem = {
23
- type?: 'heading' | 'group' | 'resource' | 'page' | 'gap' | 'divider',
162
+ type?: AdminForthMenuTypes | keyof typeof AdminForthMenuTypes,
163
+
164
+ /**
165
+ * Label for menu item which will be displayed in the admin panel.
166
+ */
24
167
  label?: string,
168
+
169
+ /**
170
+ * Icon for menu item which will be displayed in the admin panel.
171
+ * Supports iconify icons in format `<icon set name>:<icon name>`
172
+ * Browse available icons here: https://icon-sets.iconify.design/
173
+ *
174
+ * Example:
175
+ *
176
+ * ```ts
177
+ * icon: 'flowbite:brain-solid',
178
+ * ```
179
+ *
180
+ */
25
181
  icon?: string,
182
+
183
+ /**
184
+ * Path to custom component which will be displayed in the admin panel.
185
+ *
186
+ */
26
187
  path?: string,
188
+
189
+ /**
190
+ * Component to be used for this menu item. Component should be placed in custom folder and referenced with `@@/` prefix.
191
+ * Supported for AdminForthMenuTypes.PAGE only!
192
+ * Example:
193
+ *
194
+ * ```ts
195
+ * component: '@@/Dashboard.vue',
196
+ * ```
197
+ *
198
+ */
27
199
  component?: string,
200
+
201
+ /**
202
+ * Resource ID which will be used to fetch data from.
203
+ * Supported for AdminForthMenuTypes.RESOURCE only!
204
+ *
205
+ */
28
206
  resourceId?: string,
207
+
208
+ /**
209
+ * If true, group will be open by default after user login to the admin panel.
210
+ * Also will be used to redirect from root path.
211
+ */
29
212
  homepage?: boolean,
213
+
214
+ /**
215
+ * Where Group is open by default
216
+ * Supported for AdminForthMenuTypes.GROUP only!
217
+ *
218
+ */
30
219
  open?: boolean,
220
+
221
+ /**
222
+ * Children menu items which will be displayed in this group.
223
+ * Supported for AdminForthMenuTypes.GROUP only!
224
+ */
31
225
  children?: Array<AdminForthConfigMenuItem>,
226
+
227
+ /**
228
+ * By default all pages are imported dynamically with lazy import().
229
+ * If you wish to import page statically, set this option to true.
230
+ * Homepage will be imported statically by default. but you can override it with this option.
231
+ */
32
232
  isStaticRoute?: boolean,
233
+
33
234
  meta?: {
34
235
  title?: string,
35
236
  },
36
237
  }
37
238
 
38
-
239
+
240
+ /**
241
+ * Column describes one field in the table or collection in database.
242
+ */
39
243
  export type AdminForthResourceColumn = {
244
+ /**
245
+ * Column name in database.
246
+ */
40
247
  name: string,
248
+
249
+ /**
250
+ * How column can be labled in the admin panel.
251
+ * Use it for renaming columns. Defaulted to column name with Uppercased first letter.
252
+ */
41
253
  label?: string,
254
+
255
+ /**
256
+ * Type of data in column.
257
+ * AdminForth will use this information to render proper input fields in the admin panel.
258
+ * AdminForth tries to guess type of data from database column type automatically for typed databases like SQL-based.
259
+ * However you can explicitly set it to any value. E.g. set AdminForthDataTypes.DATETIME for your string column in SQLite, which stores ISO date strings.
260
+ */
42
261
  type?: AdminForthDataTypes,
262
+
263
+ /**
264
+ * Whether to use this column as record identifier.
265
+ * Only one column can be primary key.
266
+ * AdminForth tries to guess primary key automatically first.
267
+ */
43
268
  primaryKey?: boolean,
44
- required?: boolean | { create: boolean, edit: boolean },
45
- editingNote?: string | { create: string, edit: string },
46
- showIn?: Array<string>,
269
+
270
+ /**
271
+ * Whether AdminForth will require this field to be filled in create and edit forms.
272
+ * Can be set to boolean or object with create and edit properties.
273
+ * If boolean, it will be used for both create and edit forms.
274
+ */
275
+ required?: boolean | { create?: boolean, edit?: boolean },
276
+
277
+ /**
278
+ * Whether AdminForth will show editing note near the field in edit/create form.
279
+ */
280
+ editingNote?: string | { create?: string, edit?: string },
281
+
282
+ /**
283
+ * On which AdminForth pages this field will be shown. By default all.
284
+ * Example: if you want to show field only in create and edit pages, set it to
285
+ *
286
+ * ```ts
287
+ * showIn: [AdminForthResourcePages.CREATE, AdminForthResourcePages.EDIT]
288
+ * ```
289
+ *
290
+ */
291
+ showIn?: Array<AdminForthResourcePages | keyof typeof AdminForthResourcePages>,
292
+
293
+ /**
294
+ * Whether AdminForth will show this field in show view.
295
+ */
47
296
  fillOnCreate?: Function,
297
+
298
+ /**
299
+ * Whether AdminForth will request user to enter unique value during creating or editing record.
300
+ * This option causes AdminForth to make a request to database to check if value is unique.
301
+ * (Constraints are not used, so for large-tables performance make sure you have unique index in database if you set this option to true)
302
+ */
48
303
  isUnique?: boolean,
304
+
305
+
306
+ /**
307
+ * Runtime validation Regexp rules for this field.
308
+ */
49
309
  validation?: Array<ValidationObject>,
310
+
311
+ /**
312
+ * Allows to make the field which does not exist in database table.
313
+ * Examples: add custom show field with user country flag:
314
+ *
315
+ * ```ts
316
+ * {
317
+ * label: 'Country',
318
+ * type: AdminForthDataTypes.STRING,
319
+ * virtual: true,
320
+ * showIn: [AdminForthResourcePages.SHOW, AdminForthResourcePages.LIST],
321
+ * components: {
322
+ * show: '@@/CountryFlag.vue',
323
+ * list: '@@/CountryFlag.vue',
324
+ * },
325
+ * }
326
+ * ```
327
+ *
328
+ * This field will be displayed in show and list views with custom component `CountryFlag.vue`. CountryFlag.vue should be placed in custom folder and can be next:
329
+ *
330
+ * ```vue
331
+ * <template>
332
+ * {{ getFlagEmojiFromIso(record.ipCountry) }}
333
+ * </template>
334
+ *
335
+ * <script setup>
336
+ * const props = defineProps(['record']);
337
+ *
338
+ * function getFlagEmojiFromIso(iso) {
339
+ * return iso.toUpperCase().replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397));
340
+ * }
341
+ * </script>
342
+ * ```
343
+ *
344
+ */
50
345
  virtual?: boolean,
346
+
347
+ /**
348
+ * Whether AdminForth will show this field in list view.
349
+ */
51
350
  allowMinMaxQuery?: boolean,
52
- component?: AdminForthResourceColumnComponent
351
+
352
+ /**
353
+ * Custom components which will be used to render this field in the admin panel.
354
+ */
355
+ components?: AdminForthFieldComponents
53
356
  maxLength?: number,
54
357
  minLength?: number,
55
358
  min?: number,
56
359
  max?: number,
57
360
  minValue?: number,
58
361
  maxValue?: number,
59
- enum?: Array<AdminForthResourceColumnEnumElement>,
60
- foreignResource?:AdminForthResourceColumnForeignResource,
362
+ enum?: Array<AdminForthColumnEnumItem>,
363
+ foreignResource?:AdminForthForeignResource,
61
364
  sortable?: boolean,
62
365
  backendOnly?: boolean, // if true field will not be passed to UI under no circumstances, but will be presented in hooks
63
- }
366
+
367
+ /**
368
+ * Masked fields will be displayed as `*****` on Edit and Create pages.
369
+ */
370
+ masked?: boolean,
371
+ }
64
372
 
373
+ /**
374
+ * Resource describes one table or collection in database.
375
+ * AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.
376
+ */
65
377
  export type AdminForthResource = {
66
378
  /**
67
379
  * Unique identifier of resource. By default it equals to table name in database.
@@ -92,28 +404,23 @@ export type AdminForthResource = {
92
404
  */
93
405
  columns: Array<AdminForthResourceColumn>,
94
406
 
407
+
95
408
  dataSourceColumns?: Array<AdminForthResourceColumn>, // TODO, mark as private
96
409
 
97
410
  /**
98
- * Hook which allow you to modify item label
411
+ * Hook which allow you to modify record label
99
412
  *
100
413
  * Example:
101
414
  *
102
415
  * ```ts
103
- * itemLabel: (item) => `${item.name} - ${item.id}`,
416
+ * recordLabel: (record) => `${record.name} - ${record.id}`,
104
417
  * ```
105
418
  *
106
419
  */
107
- itemLabel?: Function,
420
+ recordLabel?: Function,
108
421
 
109
422
  /**
110
- * Hook which allow you to modify item title
111
- *
112
- * Example:
113
- *
114
- * ```ts
115
- * itemTitle: (item) => `${item.name} - ${item.id}`,
116
- * ```
423
+ * Array of plugins which will be used to modify resource configuration.
117
424
  *
118
425
  */
119
426
  plugins?: Array<AdminForthPluginType>,
@@ -148,15 +455,98 @@ export type AdminForthResource = {
148
455
  id?: string,
149
456
  }>,
150
457
  allowedActions?: AllowedActions,
458
+
459
+ /**
460
+ * Page size for list view
461
+ */
151
462
  listPageSize?: number,
463
+
464
+ /**
465
+ * Custom components which can be injected into AdminForth CRUD pages.
466
+ * Each injection is a path to a custom component which will be displayed in the admin panel.
467
+ * Can be also array to render multiple injections one after another.
468
+ *
469
+ * Example:
470
+ *
471
+ * ```ts
472
+ * pageInjections: {
473
+ * list: {
474
+ * beforeBreadcrumbs: '@@/Announcement.vue',
475
+ * }
476
+ * }
477
+ * ```
478
+ *
479
+ *
480
+ */
481
+ pageInjections?: {
482
+ /**
483
+ * Custom components which can be injected into resource list page.
484
+ *
485
+ * Component accepts next props: [resource, adminUser]
486
+ */
487
+ list?: {
488
+ beforeBreadcrumbs?: string | Array<string>,
489
+ afterBreadcrumbs?: string | Array<string>,
490
+ bottom?: string | Array<string>,
491
+ },
492
+
493
+ /**
494
+ * Custom components which can be injected into resource show page.
495
+ *
496
+ * Component accepts next props: [record, resource, adminUser]
497
+ */
498
+ show?: {
499
+ beforeBreadcrumbs?: string | Array<string>,
500
+ afterBreadcrumbs?: string | Array<string>,
501
+ bottom?: string | Array<string>,
502
+ },
503
+
504
+ /**
505
+ * Custom components which can be injected into resource edit page.
506
+ *
507
+ * Component accepts next props: [record, resource, adminUser]
508
+ */
509
+ edit?: {
510
+ beforeBreadcrumbs?: string | Array<string>,
511
+ afterBreadcrumbs?: string | Array<string>,
512
+ bottom?: string | Array<string>,
513
+ },
514
+
515
+ /**
516
+ * Custom components which can be injected into resource create page.
517
+ *
518
+ * Component accepts next props: [resource, adminUser]
519
+ */
520
+ create?: {
521
+ beforeBreadcrumbs?: string | Array<string>,
522
+ afterBreadcrumbs?: string | Array<string>,
523
+ bottom?: string | Array<string>,
524
+ },
525
+ }
152
526
  },
153
527
  }
154
528
 
529
+ /**
530
+ * Data source describes database connection which will be used to fetch data for resources.
531
+ * Each resource should use one data source.
532
+ */
155
533
  export type AdminForthDataSource = {
156
- id: string,
157
- url: string,
534
+ /**
535
+ * ID of datasource which you will use in resources to specify from which database to fetch data from
536
+ */
537
+ id: string,
538
+
539
+ /**
540
+ * URL to database. Examples:
541
+ *
542
+ * - MongoDB: `mongodb://<user>:<password>@<host>:<port>/<database>`
543
+ * - PostgreSQL: `postgresql://<user>:<password>@<host>:<port>/<database>`
544
+ * - SQLite: `sqlite://<path>`
545
+ */
546
+ url: string,
158
547
  }
159
548
 
549
+
160
550
  /**
161
551
  * Main configuration object for AdminForth
162
552
  */
@@ -245,7 +635,7 @@ export type AdminForthConfig = {
245
635
  * Datasource is one database connection
246
636
  *
247
637
  */
248
- dataSources: Array<DataSource>,
638
+ dataSources: Array<AdminForthDataSource>,
249
639
 
250
640
  /**
251
641
  * Settings which allow you to customize AdminForth
@@ -298,9 +688,10 @@ export type AdminForthConfig = {
298
688
  * For example if file path is `./custom/comp/my.vue`, you can use it in AdminForth config like this:
299
689
  *
300
690
  * ```ts
301
- * component: {
691
+ * components: {
302
692
  * show: '@@/comp/my.vue',
303
693
  * }
694
+ * ```
304
695
  *
305
696
  */
306
697
  customComponentsDir?: string,
@@ -355,6 +746,7 @@ export type AllowedActions = {
355
746
  edit?: boolean,
356
747
  show?: boolean,
357
748
  delete?: boolean,
749
+ filter?: boolean,
358
750
  }
359
751
 
360
752
  export type ValidationObject = {
@@ -379,27 +771,62 @@ export type ValidationObject = {
379
771
  message: string,
380
772
  }
381
773
 
382
- export type DataSource = {
774
+
775
+ export type AdminForthFieldComponents = {
383
776
  /**
384
- * ID of datasource which you will use in resources to specify from which database to fetch data from
777
+ * Show component is used to redefine cell which renders field value in show view.
778
+ * Component accepts next properties: [record, column, resource, adminUser].
779
+ *
780
+ * Example: `FullName.vue`
781
+ *
782
+ * ```vue
783
+ * <template>
784
+ * {{ record.firstName }} {{ record.lastName }}
785
+ * </template>
786
+ *
787
+ * <script setup>
788
+ * defineProps(['record']);
789
+ * </script>
790
+ *
791
+ * ```ts
792
+ * {
793
+ * label: 'Full Name',
794
+ * virtual: true,
795
+ * showIn: [AdminForthResourcePages.SHOW, AdminForthResourcePages.LIST],
796
+ * components: {
797
+ * show: '@@/FullName.vue',
798
+ * list: '@@/FullName.vue',
799
+ * },
800
+ * }
801
+ * ```
802
+ *
385
803
  */
386
- id: string,
804
+ show?: string,
387
805
 
388
806
  /**
389
- * URL to database. Examples:
390
- *
391
- * - MongoDB: `mongodb://<user>:<password>@<host>:<port>/<database>`
392
- * - PostgreSQL: `postgresql://<user>:<password>@<host>:<port>/<database>`
393
- * - SQLite: `sqlite://<path>`
807
+ * showRow component is similar to {@link AdminForthFieldComponent.show} but rewrites full table row (both \<td\> tags)
808
+ * Accepts next properties: [record, column, resource, adminUser]
394
809
  */
395
- url: string,
396
- }
810
+ showRow?: string,
397
811
 
398
- export type AdminForthResourceColumnComponent = {
399
- show?: string, // rewrite value in show
400
- showRow?: string, // rewrite full view table row (both <td> tags)
812
+ /**
813
+ * Create component is used to redefine input field in create view.
814
+ * Component accepts next properties: [record, column, resource, adminUser].
815
+ */
401
816
  create?: string,
817
+
818
+ /**
819
+ * Edit component is used to redefine input field in edit view.
820
+ * Component accepts next properties: [record, column, resource, adminUser].
821
+ */
402
822
  edit?: string,
823
+
824
+ /**
825
+ * List component is used to redefine cell which renders field value in list view.
826
+ * Component accepts next properties: [record, column, resource, adminUser].
827
+ *
828
+ * Exa
829
+ */
403
830
  list?: string,
404
831
  }
405
832
 
@@ -435,12 +862,12 @@ export enum AdminForthSortDirections {
435
862
  };
436
863
 
437
864
 
438
- export type AdminForthResourceColumnEnumElement = {
439
- value: string | null,
865
+ export type AdminForthColumnEnumItem = {
866
+ value: any | null,
440
867
  label: string,
441
868
  }
442
869
 
443
- export type AdminForthResourceColumnForeignResource = {
870
+ export type AdminForthForeignResource = {
444
871
  resourceId: string,
445
872
  hooks?: {
446
873
  dropdownList?: {
@@ -0,0 +1,73 @@
1
+
2
+ export interface FrontendAPIInterface {
3
+
4
+ /**
5
+ * Show a confirmation dialog
6
+ *
7
+ * The dialog will be displayed to the user
8
+ *
9
+ * Example:
10
+ *
11
+ * ```ts
12
+ * const isConfirmed = await window.adminforth.confirm({message: 'Are you sure?', yes: 'Yes', no: 'No'})
13
+ * if (isConfirmed) {
14
+ * your code...
15
+ * }
16
+ * ```
17
+ *
18
+ * @param params - The parameters of the dialog
19
+ * @returns A promise that resolves when the user confirms the dialog
20
+ */
21
+ confirm(params:ConfirmParams ): Promise<void>;
22
+ /**
23
+ * Show an alert
24
+ *
25
+ * The alert will be displayed to the user
26
+ *
27
+ * Example:
28
+ *
29
+ * ```ts
30
+ * window.adminforth.alert({message: 'Hello', variant: 'success'})
31
+ * ```
32
+ *
33
+ * @param params - The parameters of the alert
34
+ */
35
+ alert(params:AlertParams): void;
36
+ }
37
+
38
+ export type ConfirmParams = {
39
+ /**
40
+ * The message to display in the dialog
41
+ */
42
+ message?: string;
43
+ /**
44
+ * The text to display in the "accept" button
45
+ */
46
+ yes?: string;
47
+ /**
48
+ * The text to display in the "cancel" button
49
+ */
50
+ no?: string;
51
+
52
+ }
53
+
54
+ export type AlertParams = {
55
+ /**
56
+ * The message to display in the alert
57
+ */
58
+ message?: string;
59
+ /**
60
+ * The variant of the alert
61
+ */
62
+ variant?: AlertVariant;
63
+ }
64
+
65
+ export enum AlertVariant {
66
+ Danger = 'danger',
67
+ Success = 'success',
68
+ Warning = 'warning',
69
+ Info = 'info'
70
+ }
71
+
72
+
73
+