adminforth 1.5.4-next.13 → 1.5.4-next.14

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/auth.js +4 -4
  2. package/dist/auth.js.map +1 -1
  3. package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
  4. package/dist/dataConnectors/clickhouse.js +0 -1
  5. package/dist/dataConnectors/clickhouse.js.map +1 -1
  6. package/dist/index.d.ts +0 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -13
  9. package/dist/index.js.map +1 -1
  10. package/dist/modules/codeInjector.d.ts.map +1 -1
  11. package/dist/modules/codeInjector.js +4 -4
  12. package/dist/modules/codeInjector.js.map +1 -1
  13. package/dist/modules/configValidator.d.ts +11 -5
  14. package/dist/modules/configValidator.d.ts.map +1 -1
  15. package/dist/modules/configValidator.js +387 -379
  16. package/dist/modules/configValidator.js.map +1 -1
  17. package/dist/modules/restApi.d.ts.map +1 -1
  18. package/dist/modules/restApi.js +10 -9
  19. package/dist/modules/restApi.js.map +1 -1
  20. package/dist/servers/express.js +2 -2
  21. package/dist/servers/express.js.map +1 -1
  22. package/dist/spa/src/App.vue +8 -6
  23. package/dist/spa/src/afcl/Input.vue +1 -1
  24. package/dist/spa/src/afcl/Link.vue +9 -1
  25. package/dist/spa/src/afcl/LinkButton.vue +5 -3
  26. package/dist/spa/src/afcl/VerticalTabs.vue +1 -1
  27. package/dist/spa/src/components/AcceptModal.vue +1 -2
  28. package/dist/spa/src/components/ResourceListTable.vue +4 -3
  29. package/dist/spa/src/components/SkeleteLoader.vue +5 -10
  30. package/dist/spa/src/components/ValueRenderer.vue +13 -14
  31. package/dist/spa/src/spa_types/core.ts +2 -4
  32. package/dist/spa/src/stores/core.ts +15 -16
  33. package/dist/spa/src/types/Back.ts +310 -327
  34. package/dist/spa/src/types/Common.ts +219 -10
  35. package/dist/spa/src/types/FrontendAPI.ts +5 -4
  36. package/dist/spa/src/utils.ts +5 -1
  37. package/dist/types/Back.d.ts +262 -287
  38. package/dist/types/Back.d.ts.map +1 -1
  39. package/dist/types/Back.js +1 -46
  40. package/dist/types/Back.js.map +1 -1
  41. package/dist/types/Common.d.ts +193 -9
  42. package/dist/types/Common.d.ts.map +1 -1
  43. package/dist/types/Common.js +46 -0
  44. package/dist/types/Common.js.map +1 -1
  45. package/dist/types/FrontendAPI.d.ts +4 -4
  46. package/dist/types/FrontendAPI.d.ts.map +1 -1
  47. package/dist/types/FrontendAPI.js.map +1 -1
  48. package/package.json +1 -1
@@ -62,7 +62,7 @@ export enum AllowedActionsEnum {
62
62
 
63
63
 
64
64
  export type AllowedActionsResolved = {
65
- [key in AllowedActionsEnum]?: boolean
65
+ [key in AllowedActionsEnum]: boolean
66
66
  }
67
67
 
68
68
  export interface AdminUser {
@@ -235,7 +235,7 @@ export type AdminForthComponentDeclaration = AdminForthComponentDeclarationFull
235
235
  * Resource describes one table or collection in database.
236
236
  * AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.
237
237
  */
238
- export interface AdminForthResourceCommon {
238
+ export interface AdminForthResourceInputCommon {
239
239
  /**
240
240
  * Unique identifier of resource. By default it equals to table name in database.
241
241
  * If you wish you can explicitly set it to any string.
@@ -263,12 +263,7 @@ export interface AdminForthResourceCommon {
263
263
  * Array of columns which will be displayed in the admin panel.
264
264
  * Each column has its own configuration.
265
265
  */
266
- columns: Array<AdminForthResourceColumnCommon>,
267
-
268
- /**
269
- * Internal array of columns which are not virtual. You should not edit it.
270
- */
271
- dataSourceColumns?: Array<AdminForthResourceColumnCommon>, // TODO, mark as private
266
+ columns: Array<AdminForthResourceColumnInputCommon>,
272
267
 
273
268
  /**
274
269
  * Hook which allow you to modify record label
@@ -280,7 +275,7 @@ export interface AdminForthResourceCommon {
280
275
  * ```
281
276
  *
282
277
  */
283
- recordLabel?: Function,
278
+ recordLabel?: (item: any) => string,
284
279
 
285
280
 
286
281
  /**
@@ -459,6 +454,13 @@ export interface AdminForthResourceCommon {
459
454
  },
460
455
  }
461
456
 
457
+ export interface AdminForthResourceCommon extends AdminForthResourceInputCommon {
458
+ resourceId: string,
459
+ label: string,
460
+
461
+ columns: Array<AdminForthResourceColumnCommon>,
462
+ }
463
+
462
464
 
463
465
  export type ValidationObject = {
464
466
  /**
@@ -516,7 +518,7 @@ export interface AdminForthForeignResourceCommon {
516
518
  /**
517
519
  * Column describes one field in the table or collection in database.
518
520
  */
519
- export type AdminForthResourceColumnCommon = {
521
+ export interface AdminForthResourceColumnInputCommon {
520
522
  /**
521
523
  * Column name in database.
522
524
  */
@@ -699,9 +701,216 @@ export type AdminForthResourceColumnCommon = {
699
701
  */
700
702
  masked?: boolean,
701
703
 
704
+ }
705
+
706
+ export interface AdminForthResourceColumnCommon extends AdminForthResourceColumnInputCommon {
702
707
 
703
708
  /**
704
709
  * Internal type which indicates original type of column in database.
705
710
  */
706
711
  _underlineType?: string,
712
+
713
+ }
714
+
715
+ export enum AdminForthMenuTypes {
716
+ /**
717
+ * HEADING is just a label in the menu.
718
+ * Respect `label` and `icon` property in {@link AdminForthConfigMenuItem}
719
+ */
720
+ heading = 'heading',
721
+
722
+ /**
723
+ * GROUP is a group of menu items.
724
+ * Respects `label`, `icon` and `children` properties in {@link AdminForthConfigMenuItem}
725
+ * use @AdminForthMenuTypes.open to set if group is open by default
726
+ */
727
+ group = 'group',
728
+
729
+ /**
730
+ * RESOURCE is a link to a resource.
731
+ * Respects `label`, `icon`, `resourceId`, `homepage`, `isStaticRoute` properties in {@link AdminForthConfigMenuItem}
732
+ */
733
+ resource = 'resource',
734
+
735
+ /**
736
+ * PAGE is a link to a custom page.
737
+ * Respects `label`, `icon`, `path`, `component`, `homepage`, `isStaticRoute`, properties in {@link AdminForthConfigMenuItem}
738
+ *
739
+ * Example:
740
+ *
741
+ * ```ts
742
+ * \{
743
+ * type: AdminForthMenuTypes.PAGE,
744
+ * label: 'Custom Page',
745
+ * icon: 'home',
746
+ * path: '/dash',
747
+ * component: '@@/Dashboard.vue',
748
+ * homepage: true,
749
+ * \}
750
+ * ```
751
+ *
752
+ */
753
+ page = 'page',
754
+
755
+ /**
756
+ * GAP ads some space between menu items.
757
+ */
758
+ gap = 'gap',
759
+
760
+ /**
761
+ * DIVIDER is a divider between menu items.
762
+ */
763
+ divider = 'divider',
764
+ }
765
+
766
+
767
+ /**
768
+ * Menu item which displayed in the left sidebar of the admin panel.
769
+ */
770
+ export interface AdminForthConfigMenuItem {
771
+ type?: AdminForthMenuTypes | keyof typeof AdminForthMenuTypes,
772
+
773
+ /**
774
+ * Label for menu item which will be displayed in the admin panel.
775
+ */
776
+ label?: string,
777
+
778
+ /**
779
+ * Icon for menu item which will be displayed in the admin panel.
780
+ * Supports iconify icons in format `<icon set name>:<icon name>`
781
+ * Browse available icons here: https://icon-sets.iconify.design/
782
+ *
783
+ * Example:
784
+ *
785
+ * ```ts
786
+ * icon: 'flowbite:brain-solid',
787
+ * ```
788
+ *
789
+ */
790
+ icon?: string,
791
+
792
+ /**
793
+ * Path to custom component which will be displayed in the admin panel.
794
+ *
795
+ */
796
+ path?: string,
797
+
798
+ /**
799
+ * Component to be used for this menu item. Component should be placed in custom folder and referenced with `@@/` prefix.
800
+ * Supported for AdminForthMenuTypes.PAGE only!
801
+ * Example:
802
+ *
803
+ * ```ts
804
+ * component: '@@/Dashboard.vue',
805
+ * ```
806
+ *
807
+ */
808
+ component?: string,
809
+
810
+ /**
811
+ * Resource ID which will be used to fetch data from.
812
+ * Supported for AdminForthMenuTypes.RESOURCE only!
813
+ *
814
+ */
815
+ resourceId?: string,
816
+
817
+ /**
818
+ * If true, group will be open by default after user login to the admin panel.
819
+ * Also will be used to redirect from root path.
820
+ */
821
+ homepage?: boolean,
822
+
823
+ /**
824
+ * Where Group is open by default
825
+ * Supported for AdminForthMenuTypes.GROUP only!
826
+ *
827
+ */
828
+ open?: boolean,
829
+
830
+ /**
831
+ * Children menu items which will be displayed in this group.
832
+ * Supported for AdminForthMenuTypes.GROUP only!
833
+ */
834
+ children?: Array<AdminForthConfigMenuItem>,
835
+
836
+ /**
837
+ * By default all pages are imported dynamically with lazy import().
838
+ * If you wish to import page statically, set this option to true.
839
+ * Homepage will be imported statically by default. but you can override it with this option.
840
+ */
841
+ isStaticRoute?: boolean,
842
+
843
+ meta?: {
844
+ title?: string,
845
+ },
846
+
847
+ /**
848
+ * Optional callback which will be called before rendering the menu for each item.
849
+ * You can use it to hide menu items depending on some user
850
+ */
851
+ visible?: (user: AdminUser) => boolean,
852
+
853
+ /**
854
+ * Optional callback which will be called before rendering the menu for each item.
855
+ * Result of callback if not null will be used as a small badge near the menu item.
856
+ */
857
+ badge?: string | ((user: AdminUser) => Promise<string>),
858
+
859
+ /**
860
+ * Item id will be automatically generated from hashed resourceId+Path+label
861
+ */
862
+ _itemId?: string,
863
+ }
864
+
865
+
866
+ export interface ResourceVeryShort {
867
+ resourceId: string,
868
+ label: string,
707
869
  }
870
+
871
+ export interface UserData {
872
+ pk: string,
873
+ [key: string]: any,
874
+ }
875
+
876
+ export type AnnouncementBadgeResponse = { text?: string, html?: string, closable?: boolean, title?: string };
877
+
878
+ export interface AdminForthConfigForFrontend {
879
+ brandName: string,
880
+ usernameFieldName: string,
881
+ loginBackgroundImage: string,
882
+ loginBackgroundPosition: string,
883
+ title?: string,
884
+ demoCredentials?: string,
885
+ loginPromptHTML?: string,
886
+ loginPageInjections: {
887
+ underInputs: Array<AdminForthComponentDeclaration>,
888
+ },
889
+ rememberMeDays: number,
890
+ showBrandNameInSidebar: boolean,
891
+ brandLogo?: string,
892
+ datesFormat: string,
893
+ timeFormat: string,
894
+ auth: any,
895
+ userFullnameField: string,
896
+ usernameField: string,
897
+ emptyFieldPlaceholder?: string | {
898
+ show?: string,
899
+ list?: string,
900
+ },
901
+ announcementBadge?: AnnouncementBadgeResponse | null,
902
+ globalInjections: {
903
+ userMenu: Array<AdminForthComponentDeclarationFull>,
904
+ header: Array<AdminForthComponentDeclarationFull>,
905
+ sidebar: Array<AdminForthComponentDeclarationFull>,
906
+ }
907
+ }
908
+
909
+ export interface GetBaseConfigResponse {
910
+ user: UserData,
911
+ resources: ResourceVeryShort[],
912
+ menu: AdminForthConfigMenuItem[],
913
+ config: AdminForthConfigForFrontend,
914
+ adminUser: AdminUser,
915
+ version: string,
916
+ }
@@ -60,10 +60,6 @@ export interface FrontendAPIInterface {
60
60
  */
61
61
  closeThreeDotsDropdown(): void;
62
62
 
63
- /**
64
- * Close the user menu dropdown
65
- */
66
- closeUserMenuDropdown(): void;
67
63
 
68
64
  /**
69
65
  * Set a filter in the list
@@ -105,6 +101,11 @@ export interface FrontendAPIInterface {
105
101
  */
106
102
  refreshMenuBadges(): void;
107
103
  }
104
+
105
+ /**
106
+ * Close the user menu dropdown
107
+ */
108
+ closeUserMenuDropdown(): void;
108
109
  }
109
110
 
110
111
  export type ConfirmParams = {
@@ -43,7 +43,7 @@ export async function callAdminForthApi({ path, method, body=undefined }: {
43
43
  }
44
44
  }
45
45
 
46
- export function getCustomComponent({ file, meta }: { file: string, meta: any }) {
46
+ export function getCustomComponent({ file, meta }: { file: string, meta?: any }) {
47
47
  const name = file.replace(/@/g, '').replace(/\./g, '').replace(/\//g, '');
48
48
  return resolveComponent(name);
49
49
  }
@@ -157,4 +157,8 @@ export function setQuery(query: any) {
157
157
  router.replace({
158
158
  query: currentQuery,
159
159
  });
160
+ }
161
+
162
+ export function verySimpleHash(str: string): string {
163
+ return `${str.split('').reduce((a, b)=>{a=((a<<5)-a)+b.charCodeAt(0);return a&a},0)}`;
160
164
  }