adminforth 2.4.0-next.22 → 2.4.0-next.221

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 (194) hide show
  1. package/commands/callTsProxy.js +14 -4
  2. package/commands/cli.js +10 -3
  3. package/commands/createApp/templates/custom/tsconfig.json.hbs +2 -3
  4. package/commands/createApp/templates/index.ts.hbs +10 -2
  5. package/commands/createApp/templates/package.json.hbs +1 -1
  6. package/commands/createApp/utils.js +27 -2
  7. package/commands/createCustomComponent/configLoader.js +17 -4
  8. package/commands/createCustomComponent/main.js +1 -0
  9. package/commands/createCustomComponent/templates/customCrud/beforeActionButtons.vue.hbs +38 -0
  10. package/commands/createPlugin/templates/custom/tsconfig.json.hbs +2 -5
  11. package/commands/createPlugin/templates/package.json.hbs +1 -1
  12. package/commands/generateModels.js +30 -22
  13. package/dist/auth.d.ts +9 -1
  14. package/dist/auth.d.ts.map +1 -1
  15. package/dist/auth.js +15 -2
  16. package/dist/auth.js.map +1 -1
  17. package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
  18. package/dist/dataConnectors/baseConnector.js +46 -15
  19. package/dist/dataConnectors/baseConnector.js.map +1 -1
  20. package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
  21. package/dist/dataConnectors/clickhouse.js +15 -0
  22. package/dist/dataConnectors/clickhouse.js.map +1 -1
  23. package/dist/dataConnectors/mongo.d.ts.map +1 -1
  24. package/dist/dataConnectors/mongo.js +50 -15
  25. package/dist/dataConnectors/mongo.js.map +1 -1
  26. package/dist/dataConnectors/mysql.d.ts.map +1 -1
  27. package/dist/dataConnectors/mysql.js +11 -0
  28. package/dist/dataConnectors/mysql.js.map +1 -1
  29. package/dist/dataConnectors/postgres.d.ts.map +1 -1
  30. package/dist/dataConnectors/postgres.js +11 -0
  31. package/dist/dataConnectors/postgres.js.map +1 -1
  32. package/dist/dataConnectors/sqlite.d.ts.map +1 -1
  33. package/dist/dataConnectors/sqlite.js +11 -0
  34. package/dist/dataConnectors/sqlite.js.map +1 -1
  35. package/dist/index.d.ts +2 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +23 -9
  38. package/dist/index.js.map +1 -1
  39. package/dist/modules/codeInjector.d.ts +2 -0
  40. package/dist/modules/codeInjector.d.ts.map +1 -1
  41. package/dist/modules/codeInjector.js +52 -8
  42. package/dist/modules/codeInjector.js.map +1 -1
  43. package/dist/modules/configValidator.d.ts +6 -0
  44. package/dist/modules/configValidator.d.ts.map +1 -1
  45. package/dist/modules/configValidator.js +140 -19
  46. package/dist/modules/configValidator.js.map +1 -1
  47. package/dist/modules/restApi.d.ts.map +1 -1
  48. package/dist/modules/restApi.js +154 -26
  49. package/dist/modules/restApi.js.map +1 -1
  50. package/dist/modules/styles.d.ts +503 -13
  51. package/dist/modules/styles.d.ts.map +1 -1
  52. package/dist/modules/styles.js +559 -31
  53. package/dist/modules/styles.js.map +1 -1
  54. package/dist/modules/utils.d.ts +2 -0
  55. package/dist/modules/utils.d.ts.map +1 -1
  56. package/dist/modules/utils.js +16 -0
  57. package/dist/modules/utils.js.map +1 -1
  58. package/dist/servers/express.d.ts.map +1 -1
  59. package/dist/servers/express.js +14 -0
  60. package/dist/servers/express.js.map +1 -1
  61. package/dist/spa/index.html +1 -1
  62. package/dist/spa/package-lock.json +5 -4
  63. package/dist/spa/package.json +1 -1
  64. package/dist/spa/src/App.vue +54 -169
  65. package/dist/spa/src/adminforth.ts +42 -18
  66. package/dist/spa/src/afcl/BarChart.vue +2 -2
  67. package/dist/spa/src/afcl/Button.vue +6 -6
  68. package/dist/spa/src/afcl/ButtonGroup.vue +91 -0
  69. package/dist/spa/src/afcl/Card.vue +25 -0
  70. package/dist/spa/src/afcl/Checkbox.vue +21 -13
  71. package/dist/spa/src/afcl/CountryFlag.vue +4 -1
  72. package/dist/spa/src/{components/CustomDatePicker.vue → afcl/DatePicker.vue} +95 -9
  73. package/dist/spa/src/afcl/Dialog.vue +47 -27
  74. package/dist/spa/src/afcl/Dropzone.vue +12 -12
  75. package/dist/spa/src/afcl/Input.vue +5 -5
  76. package/dist/spa/src/afcl/JsonViewer.vue +25 -0
  77. package/dist/spa/src/afcl/LinkButton.vue +3 -3
  78. package/dist/spa/src/afcl/PieChart.vue +5 -5
  79. package/dist/spa/src/afcl/ProgressBar.vue +7 -7
  80. package/dist/spa/src/afcl/Select.vue +68 -34
  81. package/dist/spa/src/afcl/Skeleton.vue +6 -6
  82. package/dist/spa/src/afcl/Table.vue +213 -74
  83. package/dist/spa/src/afcl/Textarea.vue +31 -0
  84. package/dist/spa/src/afcl/Toggle.vue +32 -0
  85. package/dist/spa/src/afcl/Tooltip.vue +26 -18
  86. package/dist/spa/src/afcl/VerticalTabs.vue +16 -7
  87. package/dist/spa/src/afcl/index.ts +6 -3
  88. package/dist/spa/src/components/AcceptModal.vue +7 -7
  89. package/dist/spa/src/components/Breadcrumbs.vue +5 -5
  90. package/dist/spa/src/components/ColumnValueInput.vue +38 -18
  91. package/dist/spa/src/components/ColumnValueInputWrapper.vue +4 -3
  92. package/dist/spa/src/components/CustomDateRangePicker.vue +9 -8
  93. package/dist/spa/src/components/CustomRangePicker.vue +37 -8
  94. package/dist/spa/src/components/ErrorMessage.vue +21 -0
  95. package/dist/spa/src/components/Filters.vue +85 -39
  96. package/dist/spa/src/components/GroupsTable.vue +9 -8
  97. package/dist/spa/src/components/MenuLink.vue +90 -23
  98. package/dist/spa/src/components/ResourceForm.vue +94 -51
  99. package/dist/spa/src/components/ResourceListTable.vue +75 -77
  100. package/dist/spa/src/components/ResourceListTableVirtual.vue +71 -73
  101. package/dist/spa/src/components/ShowTable.vue +17 -12
  102. package/dist/spa/src/components/Sidebar.vue +448 -0
  103. package/dist/spa/src/components/SingleSkeletLoader.vue +6 -6
  104. package/dist/spa/src/components/SkeleteLoader.vue +3 -3
  105. package/dist/spa/src/components/ThreeDotsMenu.vue +73 -14
  106. package/dist/spa/src/components/Toast.vue +27 -9
  107. package/dist/spa/src/components/UserMenuSettingsButton.vue +70 -0
  108. package/dist/spa/src/components/ValueRenderer.vue +43 -16
  109. package/dist/spa/src/controls/BoolToggle.vue +34 -0
  110. package/dist/spa/src/i18n.ts +1 -1
  111. package/dist/spa/src/renderers/CompactField.vue +1 -1
  112. package/dist/spa/src/renderers/CompactUUID.vue +1 -1
  113. package/dist/spa/src/router/index.ts +8 -0
  114. package/dist/spa/src/shims-vue.d.ts +5 -0
  115. package/dist/spa/src/spa_types/core.ts +13 -1
  116. package/dist/spa/src/stores/core.ts +1 -1
  117. package/dist/spa/src/stores/filters.ts +29 -2
  118. package/dist/spa/src/stores/modal.ts +6 -1
  119. package/dist/spa/src/stores/toast.ts +22 -3
  120. package/dist/spa/src/types/Back.ts +140 -22
  121. package/dist/spa/src/types/Common.ts +67 -32
  122. package/dist/spa/src/types/FrontendAPI.ts +31 -5
  123. package/dist/spa/src/types/adapters/CaptchaAdapter.ts +34 -0
  124. package/dist/spa/src/types/adapters/CompletionAdapter.ts +25 -0
  125. package/dist/spa/src/types/adapters/EmailAdapter.ts +27 -0
  126. package/dist/spa/src/types/adapters/ImageGenerationAdapter.ts +50 -0
  127. package/dist/spa/src/types/adapters/ImageVisionAdapter.ts +30 -0
  128. package/dist/spa/src/types/adapters/KeyValueAdapter.ts +16 -0
  129. package/dist/spa/src/types/adapters/OAuth2Adapter.ts +34 -0
  130. package/dist/spa/src/types/adapters/StorageAdapter.ts +73 -0
  131. package/dist/spa/src/types/adapters/index.ts +8 -0
  132. package/dist/spa/src/utils.ts +222 -9
  133. package/dist/spa/src/views/CreateView.vue +18 -19
  134. package/dist/spa/src/views/EditView.vue +25 -19
  135. package/dist/spa/src/views/ListView.vue +139 -86
  136. package/dist/spa/src/views/LoginView.vue +37 -37
  137. package/dist/spa/src/views/ResourceParent.vue +2 -2
  138. package/dist/spa/src/views/SettingsView.vue +121 -0
  139. package/dist/spa/src/views/ShowView.vue +59 -39
  140. package/dist/spa/src/websocket.ts +6 -1
  141. package/dist/spa/tsconfig.app.json +1 -1
  142. package/dist/spa/vite.config.ts +45 -2
  143. package/dist/types/Back.d.ts +118 -14
  144. package/dist/types/Back.d.ts.map +1 -1
  145. package/dist/types/Back.js +15 -0
  146. package/dist/types/Back.js.map +1 -1
  147. package/dist/types/Common.d.ts +59 -29
  148. package/dist/types/Common.d.ts.map +1 -1
  149. package/dist/types/Common.js.map +1 -1
  150. package/dist/types/FrontendAPI.d.ts +31 -3
  151. package/dist/types/FrontendAPI.d.ts.map +1 -1
  152. package/dist/types/FrontendAPI.js.map +1 -1
  153. package/dist/types/adapters/CaptchaAdapter.d.ts +30 -0
  154. package/dist/types/adapters/CaptchaAdapter.d.ts.map +1 -0
  155. package/dist/types/adapters/CaptchaAdapter.js +5 -0
  156. package/dist/types/adapters/CaptchaAdapter.js.map +1 -0
  157. package/dist/types/adapters/CompletionAdapter.d.ts +20 -0
  158. package/dist/types/adapters/CompletionAdapter.d.ts.map +1 -0
  159. package/dist/types/adapters/CompletionAdapter.js +2 -0
  160. package/dist/types/adapters/CompletionAdapter.js.map +1 -0
  161. package/dist/types/adapters/EmailAdapter.d.ts +20 -0
  162. package/dist/types/adapters/EmailAdapter.d.ts.map +1 -0
  163. package/dist/types/adapters/EmailAdapter.js +2 -0
  164. package/dist/types/adapters/EmailAdapter.js.map +1 -0
  165. package/dist/types/adapters/ImageGenerationAdapter.d.ts +37 -0
  166. package/dist/types/adapters/ImageGenerationAdapter.d.ts.map +1 -0
  167. package/dist/types/adapters/ImageGenerationAdapter.js +2 -0
  168. package/dist/types/adapters/ImageGenerationAdapter.js.map +1 -0
  169. package/dist/types/adapters/ImageVisionAdapter.d.ts +25 -0
  170. package/dist/types/adapters/ImageVisionAdapter.d.ts.map +1 -0
  171. package/dist/types/adapters/ImageVisionAdapter.js +2 -0
  172. package/dist/types/adapters/ImageVisionAdapter.js.map +1 -0
  173. package/dist/types/adapters/KeyValueAdapter.d.ts +10 -0
  174. package/dist/types/adapters/KeyValueAdapter.d.ts.map +1 -0
  175. package/dist/types/adapters/KeyValueAdapter.js +2 -0
  176. package/dist/types/adapters/KeyValueAdapter.js.map +1 -0
  177. package/dist/types/adapters/OAuth2Adapter.d.ts +32 -0
  178. package/dist/types/adapters/OAuth2Adapter.d.ts.map +1 -0
  179. package/dist/types/adapters/OAuth2Adapter.js +2 -0
  180. package/dist/types/adapters/OAuth2Adapter.js.map +1 -0
  181. package/dist/types/adapters/StorageAdapter.d.ts +63 -0
  182. package/dist/types/adapters/StorageAdapter.d.ts.map +1 -0
  183. package/dist/types/adapters/StorageAdapter.js +2 -0
  184. package/dist/types/adapters/StorageAdapter.js.map +1 -0
  185. package/dist/types/adapters/index.d.ts +9 -0
  186. package/dist/types/adapters/index.d.ts.map +1 -0
  187. package/dist/types/adapters/index.js +2 -0
  188. package/dist/types/adapters/index.js.map +1 -0
  189. package/package.json +3 -2
  190. package/dist/spa/src/types/Adapters.ts +0 -213
  191. package/dist/types/Adapters.d.ts +0 -168
  192. package/dist/types/Adapters.d.ts.map +0 -1
  193. package/dist/types/Adapters.js +0 -2
  194. package/dist/types/Adapters.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { Express } from 'express';
1
+ import type { Express, Request } from 'express';
2
2
  import type { Writable } from 'stream';
3
3
 
4
4
  import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum,
@@ -8,12 +8,12 @@ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections,
8
8
  type AdminForthBulkActionCommon,
9
9
  type AdminForthForeignResourceCommon,
10
10
  type AdminForthResourceColumnCommon,
11
- AdminForthResourceInputCommon,
12
- AdminForthComponentDeclarationFull,
13
- AdminForthConfigMenuItem,
14
- AnnouncementBadgeResponse,
11
+ type AdminForthResourceInputCommon,
12
+ type AdminForthComponentDeclarationFull,
13
+ type AdminForthConfigMenuItem,
14
+ type AnnouncementBadgeResponse,
15
15
  AdminForthResourcePages,
16
- AdminForthResourceColumnInputCommon,
16
+ type AdminForthResourceColumnInputCommon,
17
17
  } from './Common.js';
18
18
 
19
19
  export interface ICodeInjector {
@@ -22,12 +22,13 @@ export interface ICodeInjector {
22
22
  devServerPort: number;
23
23
 
24
24
  getServeDir(): string;
25
-
25
+ registerCustomComponent(filePath: string): void;
26
26
  spaTmpPath(): string;
27
27
  }
28
28
 
29
29
  export interface IConfigValidator {
30
30
  validateConfig(): void;
31
+ validateAfterPluginsActivation(): void;
31
32
  postProcessAfterDiscover(resource: AdminForthResource): void;
32
33
  }
33
34
 
@@ -92,19 +93,36 @@ export interface IExpressHttpServer extends IHttpServer {
92
93
  * Adds adminUser to request object if user is authorized. Drops request with 401 status if user is not authorized.
93
94
  * @param callable : Function which will be called if user is authorized.
94
95
  *
95
- * Example:
96
96
  *
97
+ * @example
97
98
  * ```ts
98
- * expressApp.get('/myApi', authorize((req, res) => \{
99
+ * expressApp.get('/myApi', authorize((req, res) => {
99
100
  * console.log('User is authorized', req.adminUser);
100
- * res.json(\{ message: 'Hello World' \});
101
- * \}));
102
- * ``
101
+ * res.json({ message: 'Hello World' });
102
+ * }));
103
+ * ```
103
104
  *
104
- */
105
+ */
105
106
  authorize(callable: Function): void;
106
107
  }
107
108
 
109
+ export interface ITranslateFunction {
110
+ (
111
+ msg: string,
112
+ category: string,
113
+ params: any,
114
+ pluralizationNumber?: number
115
+ ): Promise<string>;
116
+ }
117
+
118
+ // Omit <Request, 'param'> is used to remove 'param' method from Request type for correct docs generation
119
+ export interface IAdminUserExpressRequest extends Omit<Request, 'protocol' | 'param' | 'unshift'> {
120
+ adminUser: AdminUser;
121
+ }
122
+
123
+ export interface ITranslateExpressRequest extends Omit<Request, 'protocol' | 'param' | 'unshift'> {
124
+ tr: ITranslateFunction;
125
+ }
108
126
 
109
127
  export interface IAdminForthSingleFilter {
110
128
  field?: string;
@@ -113,7 +131,9 @@ export interface IAdminForthSingleFilter {
113
131
  | AdminForthFilterOperators.LTE | AdminForthFilterOperators.LIKE | AdminForthFilterOperators.ILIKE
114
132
  | AdminForthFilterOperators.IN | AdminForthFilterOperators.NIN;
115
133
  value?: any;
134
+ rightField?: string;
116
135
  insecureRawSQL?: string;
136
+ insecureRawNoSQL?: any;
117
137
  }
118
138
  export interface IAdminForthAndOrFilter {
119
139
  operator: AdminForthFilterOperators.AND | AdminForthFilterOperators.OR;
@@ -287,6 +307,10 @@ export interface IAdminForthAuth {
287
307
 
288
308
  removeCustomCookie({response, name}: {response: any, name: string}): void;
289
309
 
310
+ setCustomCookie({response, payload}: {response: any, payload: {name: string, value: string, expiry: number, expirySeconds: number, httpOnly: boolean}}): void;
311
+
312
+ getCustomCookie({cookies, name}: {cookies: {key: string, value: string}[], name: string}): string | null;
313
+
290
314
  setAuthCookie({expireInDays, response, username, pk,}: {expireInDays?: number, response: any, username: string, pk: string}): void;
291
315
 
292
316
  removeAuthCookie(response: any): void;
@@ -336,7 +360,7 @@ export interface IAdminForth {
336
360
 
337
361
  createResourceRecord(
338
362
  params: { resource: AdminForthResource, record: any, adminUser: AdminUser, extra?: HttpExtra }
339
- ): Promise<{ error?: string, createdRecord?: any }>;
363
+ ): Promise<{ error?: string, createdRecord?: any, newRecordId?: any }>;
340
364
 
341
365
  updateResourceRecord(
342
366
  params: { resource: AdminForthResource, recordId: any, record: any, oldRecord: any, adminUser: AdminUser, extra?: HttpExtra }
@@ -474,7 +498,7 @@ export type BeforeDataSourceRequestFunction = (params: {
474
498
  requestUrl: string,
475
499
  },
476
500
  adminforth: IAdminForth,
477
- }) => Promise<{ok: boolean, error?: string}>;
501
+ }) => Promise<{ok: boolean, error?: string, newRecordId?: string}>;
478
502
 
479
503
  /**
480
504
  * Modify response to change how data is returned after fetching from database.
@@ -525,7 +549,7 @@ export type BeforeEditSaveFunction = (params: {
525
549
  oldRecord: any,
526
550
  adminforth: IAdminForth,
527
551
  extra?: HttpExtra,
528
- }) => Promise<{ok: boolean, error?: string}>;
552
+ }) => Promise<{ok: boolean, error?: string | null}>;
529
553
 
530
554
 
531
555
 
@@ -535,7 +559,7 @@ export type BeforeCreateSaveFunction = (params: {
535
559
  record: any,
536
560
  adminforth: IAdminForth,
537
561
  extra?: HttpExtra,
538
- }) => Promise<{ok: boolean, error?: string}>;
562
+ }) => Promise<{ok: boolean, error?: string | null, newRecordId?: string}>;
539
563
 
540
564
  export type AfterCreateSaveFunction = (params: {
541
565
  resource: AdminForthResource,
@@ -619,12 +643,23 @@ interface AdminForthInputConfigCustomization {
619
643
  */
620
644
  brandName?: string,
621
645
 
646
+ /**
647
+ * Whether to use single theme for the app
648
+ */
649
+ singleTheme?: 'light' | 'dark',
650
+
622
651
  /**
623
652
  * Whether to show brand name in sidebar
624
653
  * default is true
625
654
  */
626
655
  showBrandNameInSidebar?: boolean,
627
656
 
657
+ /**
658
+ * Whether to show brand logo in sidebar
659
+ * default is true
660
+ */
661
+ showBrandLogoInSidebar?: boolean,
662
+
628
663
  /**
629
664
  * Path to your app logo
630
665
  *
@@ -638,6 +673,19 @@ interface AdminForthInputConfigCustomization {
638
673
  */
639
674
  brandLogo?: string,
640
675
 
676
+
677
+ /**
678
+ * Path to your app logo for icon only sidebar
679
+ *
680
+ * Example:
681
+ * Place file `logo.svg` to `./custom` folder and set this option:
682
+ *
683
+ */
684
+ iconOnlySidebar?: {
685
+ logo?: string,
686
+ enabled?: boolean,
687
+ },
688
+
641
689
  /**
642
690
  * Path to your app favicon
643
691
  *
@@ -747,6 +795,7 @@ interface AdminForthInputConfigCustomization {
747
795
  */
748
796
  loginPageInjections?: {
749
797
  underInputs?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
798
+ underLoginButton?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
750
799
  panelHeader?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
751
800
  }
752
801
 
@@ -757,8 +806,20 @@ interface AdminForthInputConfigCustomization {
757
806
  userMenu?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
758
807
  header?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
759
808
  sidebar?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
809
+ sidebarTop?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
760
810
  everyPageBottom?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
761
811
  }
812
+
813
+ /**
814
+ * Allows adding custom elements (e.g., &lt;link&gt;, &lt;script&gt;, &lt;meta&gt;) to the &lt;head&gt; of the HTML document.
815
+ * Each item must include a tag name and a set of attributes.
816
+ */
817
+ customHeadItems?: {
818
+ tagName: string;
819
+ attributes: Record<string, string | boolean>;
820
+ innerCode?: string;
821
+ }[];
822
+
762
823
  }
763
824
 
764
825
  export interface AdminForthActionInput {
@@ -935,6 +996,13 @@ export interface AdminForthInputConfig {
935
996
  */
936
997
  loginBackgroundPosition?: 'over' | '1/2' | '1/3' | '2/3' | '3/4' | '2/5' | '3/5',
937
998
 
999
+ /**
1000
+ * If true, background blend mode will be removed from login background image when position is 'over'
1001
+ *
1002
+ * Default: false
1003
+ */
1004
+ removeBackgroundBlendMode?: boolean,
1005
+
938
1006
  /**
939
1007
  * Function or functions which will be called before user try to login.
940
1008
  * Each function will resive User object as an argument
@@ -956,7 +1024,7 @@ export interface AdminForthInputConfig {
956
1024
  /**
957
1025
  * Any prompt to show users on login. Supports HTML.
958
1026
  */
959
- loginPromptHTML?: string,
1027
+ loginPromptHTML?: string | (() => string | void | undefined | Promise<string | void | undefined>) | undefined
960
1028
 
961
1029
  /**
962
1030
  * Remember me days for "Remember Me" checkbox on login page.
@@ -988,6 +1056,16 @@ export interface AdminForthInputConfig {
988
1056
  * If you are using Cloudflare, set this to 'CF-Connecting-IP'. Case-insensitive.
989
1057
  */
990
1058
  clientIpHeader?: string,
1059
+
1060
+ /**
1061
+ * Add custom page to the settings page
1062
+ */
1063
+ userMenuSettingsPages: {
1064
+ icon?: string,
1065
+ pageLabel: string,
1066
+ slug?: string,
1067
+ component: string
1068
+ }[],
991
1069
  },
992
1070
 
993
1071
  /**
@@ -1055,6 +1133,7 @@ export interface AdminForthConfigCustomization extends Omit<AdminForthInputConfi
1055
1133
 
1056
1134
  loginPageInjections: {
1057
1135
  underInputs: Array<AdminForthComponentDeclarationFull>,
1136
+ underLoginButton?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
1058
1137
  panelHeader: Array<AdminForthComponentDeclarationFull>,
1059
1138
  },
1060
1139
 
@@ -1062,8 +1141,16 @@ export interface AdminForthConfigCustomization extends Omit<AdminForthInputConfi
1062
1141
  userMenu: Array<AdminForthComponentDeclarationFull>,
1063
1142
  header: Array<AdminForthComponentDeclarationFull>,
1064
1143
  sidebar: Array<AdminForthComponentDeclarationFull>,
1144
+ sidebarTop: Array<AdminForthComponentDeclarationFull>,
1065
1145
  everyPageBottom: Array<AdminForthComponentDeclarationFull>,
1066
1146
  },
1147
+
1148
+ customHeadItems?: {
1149
+ tagName: string;
1150
+ attributes: Record<string, string | boolean>;
1151
+ innerCode?: string;
1152
+ }[];
1153
+
1067
1154
  }
1068
1155
 
1069
1156
  export interface AdminForthConfig extends Omit<AdminForthInputConfig, 'customization' | 'resources'> {
@@ -1111,6 +1198,21 @@ export class Filters {
1111
1198
  static LIKE(field: string, value: any): IAdminForthSingleFilter {
1112
1199
  return { field, operator: AdminForthFilterOperators.LIKE, value };
1113
1200
  }
1201
+ static ILIKE(field: string, value: any): IAdminForthSingleFilter {
1202
+ return { field, operator: AdminForthFilterOperators.ILIKE, value };
1203
+ }
1204
+ static GT_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
1205
+ return { field: leftField, operator: AdminForthFilterOperators.GT, rightField };
1206
+ }
1207
+ static GTE_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
1208
+ return { field: leftField, operator: AdminForthFilterOperators.GTE, rightField };
1209
+ }
1210
+ static LT_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
1211
+ return { field: leftField, operator: AdminForthFilterOperators.LT, rightField };
1212
+ }
1213
+ static LTE_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
1214
+ return { field: leftField, operator: AdminForthFilterOperators.LTE, rightField };
1215
+ }
1114
1216
  static AND(
1115
1217
  ...args: (IAdminForthSingleFilter | IAdminForthAndOrFilter | Array<IAdminForthSingleFilter | IAdminForthAndOrFilter>)[]
1116
1218
  ): IAdminForthAndOrFilter {
@@ -1318,9 +1420,13 @@ export interface AdminForthResource extends Omit<AdminForthResourceInput, 'optio
1318
1420
  },
1319
1421
  create?: {
1320
1422
  /**
1423
+ * Should return `ok: true` to continue saving pipeline and allow creating record in database, and `ok: false` to interrupt pipeline and prevent record creation.
1424
+ * If you need to show error on UI, set `error: \<error message\>` in response.
1425
+ *
1321
1426
  * Typical use-cases:
1322
- * - Validate record before saving to database and interrupt execution if validation failed (`allowedActions.create` should be preferred in most cases)
1323
- * - fill-in adminUser as creator of record
1427
+ * - Create record by custom code (return `{ ok: false, newRecordId: <id of created record from custom code> }`)
1428
+ * - Validate record before saving to database and interrupt execution if validation failed (return `{ ok: false, error: <validation error> }`), though `allowedActions.create` should be preferred in most cases
1429
+ * - fill-in adminUser as creator of record (set `record.<some field> = x; return \{ ok: true \}`)
1324
1430
  * - Attach additional data to record before saving to database (mostly fillOnCreate should be used instead)
1325
1431
  */
1326
1432
  beforeSave?: Array<BeforeCreateSaveFunction>,
@@ -1471,15 +1577,27 @@ export type ShowInInput = ShowInModernInput | ShowInLegacyInput;
1471
1577
  export type ShowIn = {
1472
1578
  [key in AdminForthResourcePages]: AllowedActionValue
1473
1579
  }
1580
+ export type BackendOnlyInput =
1581
+ | boolean
1582
+ | ((p: {
1583
+ adminUser: AdminUser;
1584
+ resource: AdminForthResource;
1585
+ meta: any;
1586
+ source: ActionCheckSource;
1587
+ adminforth: IAdminForth;
1588
+ }) => boolean | Promise<boolean>);
1589
+
1474
1590
 
1475
- export interface AdminForthResourceColumnInput extends Omit<AdminForthResourceColumnInputCommon, 'showIn'> {
1591
+ export interface AdminForthResourceColumnInput extends Omit<AdminForthResourceColumnInputCommon, 'showIn' | 'backendOnly'> {
1476
1592
  showIn?: ShowInInput,
1477
1593
  foreignResource?: AdminForthForeignResource,
1594
+ backendOnly?: BackendOnlyInput;
1478
1595
  }
1479
1596
 
1480
- export interface AdminForthResourceColumn extends Omit<AdminForthResourceColumnCommon, 'showIn'> {
1597
+ export interface AdminForthResourceColumn extends Omit<AdminForthResourceColumnCommon, 'showIn' | 'backendOnly'> {
1481
1598
  showIn?: ShowIn,
1482
1599
  foreignResource?: AdminForthForeignResource,
1600
+ backendOnly?: BackendOnlyInput;
1483
1601
  }
1484
1602
 
1485
1603
  export interface IWebSocketClient {
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Types that are common for both frontend side (SPA) and backend side (server).
4
3
  */
@@ -95,12 +94,9 @@ export interface AdminForthBulkActionCommon {
95
94
  label: string,
96
95
 
97
96
  /**
98
- * Bulk Action button state 'danger'|success|'active',
99
- * * 'danger' - red button
100
- * * 'success' - green button
101
- * * 'active' - blue button
97
+ * Add custom class
102
98
  **/
103
- state?: 'danger' | 'success' | 'active';
99
+ buttonCustomCssClass?: string;
104
100
 
105
101
  /**
106
102
  * Optional small badge for button which will be displayed in the list view
@@ -122,6 +118,10 @@ export interface AdminForthBulkActionCommon {
122
118
  */
123
119
  successMessage?: string,
124
120
 
121
+ /**
122
+ * Show in three dots dropdown menu in list view.
123
+ */
124
+ showInThreeDotsDropdown?: boolean,
125
125
  }
126
126
 
127
127
  export interface AdminForthFieldComponents {
@@ -261,11 +261,29 @@ export interface AdminForthComponentDeclarationFull {
261
261
  * </script>
262
262
  *
263
263
  */
264
- meta?: any,
264
+ meta?: {
265
+ /**
266
+ * Controls sidebar and header visibility for custom pages
267
+ * - 'default': Show both sidebar and header (default behavior)
268
+ * - 'none': Hide both sidebar and header (full custom layout)
269
+ * - 'preferIconOnly': Show header but prefer icon-only sidebar
270
+ */
271
+ sidebarAndHeader?: 'default' | 'none' | 'preferIconOnly',
272
+
273
+ [key: string]: any,
274
+ }
265
275
  }
276
+ import { type AdminForthActionInput } from './Back.js'
277
+ export { type AdminForthActionInput } from './Back.js'
266
278
 
267
279
  export type AdminForthComponentDeclaration = AdminForthComponentDeclarationFull | string;
268
280
 
281
+ export type FieldGroup = {
282
+ groupName: string;
283
+ columns: string[];
284
+ noTitle?: boolean;
285
+ };
286
+
269
287
  /**
270
288
  * Resource describes one table or collection in database.
271
289
  * AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.
@@ -347,6 +365,11 @@ export interface AdminForthResourceInputCommon {
347
365
  direction: AdminForthSortDirections | string,
348
366
  }
349
367
 
368
+ /*
369
+ * Custom actions list. Actions available in show, edit and create views.
370
+ */
371
+ actions?: AdminForthActionInput[],
372
+
350
373
  /**
351
374
  * Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
352
375
  * using checkboxes.
@@ -374,26 +397,10 @@ export interface AdminForthResourceInputCommon {
374
397
  /**
375
398
  * Allows to make groups of columns in show, create and edit resource pages.
376
399
  */
377
- fieldGroups?: {
378
- groupName: string;
379
- columns: string[];
380
- noTitle?: boolean;
381
- }[];
382
- createFieldGroups?: {
383
- groupName: string;
384
- columns: string[];
385
- noTitle?: boolean;
386
- }[];
387
- editFieldGroups?: {
388
- groupName: string;
389
- columns: string[];
390
- noTitle?: boolean;
391
- }[];
392
- showFieldGroups?: {
393
- groupName: string;
394
- columns: string[];
395
- noTitle?: boolean;
396
- }[];
400
+ fieldGroups?: FieldGroup[];
401
+ createFieldGroups?: FieldGroup[];
402
+ editFieldGroups?: FieldGroup[];
403
+ showFieldGroups?: FieldGroup[];
397
404
 
398
405
  /**
399
406
  * Page size for list view
@@ -471,6 +478,7 @@ export interface AdminForthResourceInputCommon {
471
478
  list?: {
472
479
  beforeBreadcrumbs?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
473
480
  afterBreadcrumbs?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
481
+ beforeActionButtons?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
474
482
  bottom?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
475
483
  threeDotsDropdownItems?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
476
484
  customActionIcons?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
@@ -584,6 +592,8 @@ export interface AdminForthForeignResourceCommon {
584
592
  polymorphicResources?: Array<AdminForthPolymorphicForeignResource>,
585
593
  polymorphicOn?: string,
586
594
  unsetLabel?: string,
595
+ searchableFields?: string | string[],
596
+ searchIsCaseSensitive?: boolean,
587
597
  }
588
598
 
589
599
  export type FillOnCreateFunction = (params: {
@@ -810,9 +820,6 @@ export interface AdminForthResourceColumnInputCommon {
810
820
  */
811
821
  minLength?: number,
812
822
 
813
- min?: number,
814
- max?: number,
815
-
816
823
  /**
817
824
  * Minimum value that can be entered in this field.
818
825
  */
@@ -878,6 +885,15 @@ export interface AdminForthResourceColumnCommon extends AdminForthResourceColumn
878
885
 
879
886
  editingNote?: { create?: string, edit?: string },
880
887
 
888
+ /**
889
+ * Minimal value stored in this field.
890
+ */
891
+ min?: number,
892
+
893
+ /**
894
+ * Maximum value stored in this field.
895
+ */
896
+ max?: number,
881
897
  }
882
898
 
883
899
  export enum AdminForthMenuTypes {
@@ -1055,16 +1071,23 @@ export interface AdminForthConfigForFrontend {
1055
1071
  usernameFieldName: string,
1056
1072
  loginBackgroundImage: string,
1057
1073
  loginBackgroundPosition: string,
1074
+ removeBackgroundBlendMode: boolean,
1058
1075
  title?: string,
1059
1076
  demoCredentials?: string,
1060
- loginPromptHTML?: string,
1077
+ loginPromptHTML?: string | (() => string | Promise<string> | void | Promise<void> | Promise<undefined>) | undefined
1061
1078
  loginPageInjections: {
1062
1079
  underInputs: Array<AdminForthComponentDeclaration>,
1063
1080
  panelHeader: Array<AdminForthComponentDeclaration>,
1064
1081
  },
1065
1082
  rememberMeDays: number,
1066
1083
  showBrandNameInSidebar: boolean,
1084
+ showBrandLogoInSidebar: boolean,
1067
1085
  brandLogo?: string,
1086
+ iconOnlySidebar?: {
1087
+ logo?: string,
1088
+ enabled?: boolean,
1089
+ },
1090
+ singleTheme?: 'light' | 'dark',
1068
1091
  datesFormat: string,
1069
1092
  timeFormat: string,
1070
1093
  auth: any,
@@ -1079,8 +1102,20 @@ export interface AdminForthConfigForFrontend {
1079
1102
  userMenu: Array<AdminForthComponentDeclarationFull>,
1080
1103
  header: Array<AdminForthComponentDeclarationFull>,
1081
1104
  sidebar: Array<AdminForthComponentDeclarationFull>,
1105
+ sidebarTop: Array<AdminForthComponentDeclarationFull>,
1082
1106
  everyPageBottom: Array<AdminForthComponentDeclarationFull>,
1083
- }
1107
+ },
1108
+ customHeadItems?: {
1109
+ tagName: string;
1110
+ attributes: Record<string, string | boolean>;
1111
+ innerCode?: string;
1112
+ }[],
1113
+ settingPages?:{
1114
+ icon?: string,
1115
+ pageLabel: string,
1116
+ slug?: string,
1117
+ component: string,
1118
+ }[],
1084
1119
  }
1085
1120
 
1086
1121
  export interface GetBaseConfigResponse {
@@ -55,7 +55,7 @@ export interface FrontendAPIInterface {
55
55
  *
56
56
  * @param params - The parameters of the alert
57
57
  */
58
- alert(params:AlertParams): void;
58
+ alert(params:AlertParams): void | Promise<string> | string;
59
59
 
60
60
 
61
61
  list: {
@@ -82,27 +82,40 @@ export interface FrontendAPIInterface {
82
82
  */
83
83
  closeThreeDotsDropdown(): void;
84
84
 
85
-
86
85
  /**
87
- * Set a filter in the list
88
- * Works only when user located on the list page.
86
+ * Set a filter in the list.
87
+ * Works only when user located on the list page. If filter already exists, it will be replaced with the new one.
89
88
  * Can be used to set filter from charts or other components in pageInjections.
90
89
  *
90
+ * Filters are automatically marked as hidden (won't count in badge) if:
91
+ * - Column has showIn.filter: false
92
+ *
91
93
  * Example:
92
94
  *
93
95
  * ```ts
94
96
  * import adminforth from '@/adminforth'
95
97
  *
98
+ * // Regular filter (will show in badge if column.showIn.filter !== false)
96
99
  * adminforth.list.setFilter({field: 'name', operator: 'ilike', value: 'john'})
100
+ *
101
+ * // Hidden filter (won't show in badge if column.showIn.filter === false)
102
+ * adminforth.list.setFilter({field: 'internal_status', operator: 'eq', value: 'active'})
97
103
  * ```
98
104
  *
105
+ * Please note that you can set/update filter even for fields which have showIn.filter=false in resource configuration.
106
+ * Also you can set filter for virtual columns. For example Universal search plugin calls updateFilter for virtual column which has showIn.filter=false (because we dont want to show this column in filter dropdown, plugin renders its own filter UI)
107
+ *
99
108
  * @param filter - The filter to set
100
109
  */
101
110
  setFilter(filter: FilterParams): void;
102
111
 
103
112
  /**
113
+ * DEPRECATED: does the same as setFilter, kept for backward compatibility
104
114
  * Update a filter in the list
105
115
  *
116
+ * Filters visibility in badge is automatically determined by column configuration:
117
+ * - Hidden if column has showIn.filter: false
118
+ *
106
119
  * Example:
107
120
  *
108
121
  * ```ts
@@ -121,6 +134,14 @@ export interface FrontendAPIInterface {
121
134
  clearFilters(): void;
122
135
  }
123
136
 
137
+ show: {
138
+ /**
139
+ * Full refresh the current record on the show page. Loader may be shown during fetching.
140
+ * Fire-and-forget; you don't need to await it.
141
+ */
142
+ refresh(): void;
143
+ }
144
+
124
145
  menu: {
125
146
  /**
126
147
  * Refreshes the badges in the menu, by recalling the badge function for each menu item
@@ -171,7 +192,12 @@ export type AlertParams = {
171
192
  * Default is 10 seconds;
172
193
  */
173
194
  timeout?: number | 'unlimited';
174
-
195
+
196
+ /**
197
+ * Optional buttons to display in the alert
198
+ */
199
+ buttons?: {value: any, label: string}[];
200
+
175
201
  }
176
202
 
177
203
 
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Interface for Captcha adapters.
3
+ */
4
+
5
+ export interface CaptchaAdapter {
6
+ /**
7
+ * Returns the script source URL for the captcha widget.
8
+ */
9
+ getScriptSrc(): string;
10
+
11
+ /**
12
+ * Returns the site key for the captcha.
13
+ */
14
+ getSiteKey(): string;
15
+
16
+ /**
17
+ * Returns the widget ID for the captcha.
18
+ */
19
+ getWidgetId(): string;
20
+
21
+ /**
22
+ * Returns the script HTML for the captcha widget.
23
+ */
24
+ getRenderWidgetCode(): string;
25
+
26
+ /**
27
+ * Returns the function name to render the captcha widget.
28
+ */
29
+ getRenderWidgetFunctionName(): string;
30
+ /**
31
+ * Validates the captcha token.
32
+ */
33
+ validate(token: string, ip: string): Promise<Record<string, any>>;
34
+ }
@@ -0,0 +1,25 @@
1
+ export interface CompletionAdapter {
2
+
3
+ /**
4
+ * This method is called to validate the configuration of the adapter
5
+ * and should throw a clear user-readbale error if the configuration is invalid.
6
+ */
7
+ validate(): void;
8
+
9
+ /**
10
+ * This method should return a text completion based on the provided content and stop sequence.
11
+ * @param content - The input text to complete
12
+ * @param stop - An array of stop sequences to indicate where to stop the completion
13
+ * @param maxTokens - The maximum number of tokens to generate
14
+ * @returns A promise that resolves to an object containing the completed text and other metadata
15
+ */
16
+ complete(
17
+ content: string,
18
+ stop: string[],
19
+ maxTokens: number,
20
+ ): Promise<{
21
+ content?: string;
22
+ finishReason?: string;
23
+ error?: string;
24
+ }>;
25
+ }