adminforth 2.4.0-next.18 → 2.4.0-next.181
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.
- package/commands/callTsProxy.js +14 -4
- package/commands/cli.js +12 -4
- package/commands/createApp/templates/custom/tsconfig.json.hbs +2 -3
- package/commands/createApp/templates/index.ts.hbs +10 -2
- package/commands/createApp/templates/package.json.hbs +1 -1
- package/commands/createApp/utils.js +27 -2
- package/commands/createCustomComponent/configLoader.js +3 -0
- package/commands/createCustomComponent/main.js +1 -0
- package/commands/createCustomComponent/templates/customCrud/beforeActionButtons.vue.hbs +38 -0
- package/commands/createPlugin/templates/custom/tsconfig.json.hbs +2 -5
- package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
- package/dist/dataConnectors/baseConnector.js +46 -15
- package/dist/dataConnectors/baseConnector.js.map +1 -1
- package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
- package/dist/dataConnectors/clickhouse.js +15 -0
- package/dist/dataConnectors/clickhouse.js.map +1 -1
- package/dist/dataConnectors/mongo.d.ts.map +1 -1
- package/dist/dataConnectors/mongo.js +44 -15
- package/dist/dataConnectors/mongo.js.map +1 -1
- package/dist/dataConnectors/mysql.d.ts.map +1 -1
- package/dist/dataConnectors/mysql.js +11 -0
- package/dist/dataConnectors/mysql.js.map +1 -1
- package/dist/dataConnectors/postgres.d.ts.map +1 -1
- package/dist/dataConnectors/postgres.js +11 -0
- package/dist/dataConnectors/postgres.js.map +1 -1
- package/dist/dataConnectors/sqlite.d.ts.map +1 -1
- package/dist/dataConnectors/sqlite.js +11 -0
- package/dist/dataConnectors/sqlite.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/modules/codeInjector.d.ts +1 -0
- package/dist/modules/codeInjector.d.ts.map +1 -1
- package/dist/modules/codeInjector.js +42 -5
- package/dist/modules/codeInjector.js.map +1 -1
- package/dist/modules/configValidator.d.ts.map +1 -1
- package/dist/modules/configValidator.js +80 -6
- package/dist/modules/configValidator.js.map +1 -1
- package/dist/modules/restApi.d.ts.map +1 -1
- package/dist/modules/restApi.js +149 -25
- package/dist/modules/restApi.js.map +1 -1
- package/dist/modules/styles.d.ts +457 -13
- package/dist/modules/styles.d.ts.map +1 -1
- package/dist/modules/styles.js +513 -31
- package/dist/modules/styles.js.map +1 -1
- package/dist/modules/utils.d.ts +2 -0
- package/dist/modules/utils.d.ts.map +1 -1
- package/dist/modules/utils.js +16 -0
- package/dist/modules/utils.js.map +1 -1
- package/dist/spa/index.html +1 -1
- package/dist/spa/package-lock.json +5 -4
- package/dist/spa/package.json +1 -1
- package/dist/spa/src/App.vue +54 -169
- package/dist/spa/src/adminforth.ts +42 -18
- package/dist/spa/src/afcl/BarChart.vue +2 -2
- package/dist/spa/src/afcl/Button.vue +6 -6
- package/dist/spa/src/afcl/Checkbox.vue +21 -13
- package/dist/spa/src/afcl/CountryFlag.vue +4 -1
- package/dist/spa/src/{components/CustomDatePicker.vue → afcl/DatePicker.vue} +95 -9
- package/dist/spa/src/afcl/Dialog.vue +44 -27
- package/dist/spa/src/afcl/Dropzone.vue +12 -12
- package/dist/spa/src/afcl/Input.vue +6 -6
- package/dist/spa/src/afcl/JsonViewer.vue +25 -0
- package/dist/spa/src/afcl/LinkButton.vue +1 -1
- package/dist/spa/src/afcl/PieChart.vue +5 -5
- package/dist/spa/src/afcl/ProgressBar.vue +7 -7
- package/dist/spa/src/afcl/Select.vue +68 -34
- package/dist/spa/src/afcl/Skeleton.vue +6 -6
- package/dist/spa/src/afcl/Table.vue +207 -72
- package/dist/spa/src/afcl/Textarea.vue +31 -0
- package/dist/spa/src/afcl/Toggle.vue +32 -0
- package/dist/spa/src/afcl/Tooltip.vue +1 -2
- package/dist/spa/src/afcl/VerticalTabs.vue +16 -7
- package/dist/spa/src/afcl/index.ts +4 -3
- package/dist/spa/src/components/AcceptModal.vue +7 -7
- package/dist/spa/src/components/Breadcrumbs.vue +5 -5
- package/dist/spa/src/components/ColumnValueInput.vue +38 -18
- package/dist/spa/src/components/ColumnValueInputWrapper.vue +4 -3
- package/dist/spa/src/components/CustomDateRangePicker.vue +9 -8
- package/dist/spa/src/components/CustomRangePicker.vue +37 -8
- package/dist/spa/src/components/ErrorMessage.vue +21 -0
- package/dist/spa/src/components/Filters.vue +85 -39
- package/dist/spa/src/components/GroupsTable.vue +9 -8
- package/dist/spa/src/components/MenuLink.vue +90 -23
- package/dist/spa/src/components/ResourceForm.vue +94 -51
- package/dist/spa/src/components/ResourceListTable.vue +78 -80
- package/dist/spa/src/components/ResourceListTableVirtual.vue +70 -72
- package/dist/spa/src/components/ShowTable.vue +17 -12
- package/dist/spa/src/components/Sidebar.vue +443 -0
- package/dist/spa/src/components/SingleSkeletLoader.vue +6 -6
- package/dist/spa/src/components/SkeleteLoader.vue +3 -3
- package/dist/spa/src/components/ThreeDotsMenu.vue +73 -14
- package/dist/spa/src/components/Toast.vue +27 -9
- package/dist/spa/src/components/UserMenuSettingsButton.vue +68 -0
- package/dist/spa/src/components/ValueRenderer.vue +43 -16
- package/dist/spa/src/controls/BoolToggle.vue +34 -0
- package/dist/spa/src/i18n.ts +1 -1
- package/dist/spa/src/renderers/CompactField.vue +1 -1
- package/dist/spa/src/renderers/CompactUUID.vue +1 -1
- package/dist/spa/src/router/index.ts +9 -0
- package/dist/spa/src/shims-vue.d.ts +5 -0
- package/dist/spa/src/spa_types/core.ts +12 -1
- package/dist/spa/src/stores/core.ts +1 -1
- package/dist/spa/src/stores/filters.ts +29 -2
- package/dist/spa/src/stores/modal.ts +6 -1
- package/dist/spa/src/stores/toast.ts +22 -3
- package/dist/spa/src/types/Back.ts +131 -22
- package/dist/spa/src/types/Common.ts +66 -32
- package/dist/spa/src/types/FrontendAPI.ts +31 -5
- package/dist/spa/src/types/adapters/CaptchaAdapter.ts +35 -0
- package/dist/spa/src/types/adapters/CompletionAdapter.ts +25 -0
- package/dist/spa/src/types/adapters/EmailAdapter.ts +27 -0
- package/dist/spa/src/types/adapters/ImageGenerationAdapter.ts +50 -0
- package/dist/spa/src/types/adapters/ImageVisionAdapter.ts +30 -0
- package/dist/spa/src/types/adapters/KeyValueAdapter.ts +16 -0
- package/dist/spa/src/types/adapters/OAuth2Adapter.ts +34 -0
- package/dist/spa/src/types/adapters/StorageAdapter.ts +73 -0
- package/dist/spa/src/types/adapters/index.ts +8 -0
- package/dist/spa/src/utils.ts +217 -7
- package/dist/spa/src/views/CreateView.vue +18 -19
- package/dist/spa/src/views/EditView.vue +25 -19
- package/dist/spa/src/views/ListView.vue +139 -86
- package/dist/spa/src/views/LoginView.vue +24 -33
- package/dist/spa/src/views/ResourceParent.vue +2 -2
- package/dist/spa/src/views/SettingsView.vue +121 -0
- package/dist/spa/src/views/ShowView.vue +59 -39
- package/dist/spa/src/websocket.ts +6 -1
- package/dist/spa/tsconfig.app.json +1 -1
- package/dist/spa/vite.config.ts +45 -2
- package/dist/types/Back.d.ts +96 -14
- package/dist/types/Back.d.ts.map +1 -1
- package/dist/types/Back.js +15 -0
- package/dist/types/Back.js.map +1 -1
- package/dist/types/Common.d.ts +58 -29
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/dist/types/FrontendAPI.d.ts +31 -3
- package/dist/types/FrontendAPI.d.ts.map +1 -1
- package/dist/types/FrontendAPI.js.map +1 -1
- package/dist/types/adapters/CaptchaAdapter.d.ts +30 -0
- package/dist/types/adapters/CaptchaAdapter.d.ts.map +1 -0
- package/dist/types/adapters/CaptchaAdapter.js +5 -0
- package/dist/types/adapters/CaptchaAdapter.js.map +1 -0
- package/dist/types/adapters/CompletionAdapter.d.ts +20 -0
- package/dist/types/adapters/CompletionAdapter.d.ts.map +1 -0
- package/dist/types/adapters/CompletionAdapter.js +2 -0
- package/dist/types/adapters/CompletionAdapter.js.map +1 -0
- package/dist/types/adapters/EmailAdapter.d.ts +20 -0
- package/dist/types/adapters/EmailAdapter.d.ts.map +1 -0
- package/dist/types/adapters/EmailAdapter.js +2 -0
- package/dist/types/adapters/EmailAdapter.js.map +1 -0
- package/dist/types/adapters/ImageGenerationAdapter.d.ts +37 -0
- package/dist/types/adapters/ImageGenerationAdapter.d.ts.map +1 -0
- package/dist/types/adapters/ImageGenerationAdapter.js +2 -0
- package/dist/types/adapters/ImageGenerationAdapter.js.map +1 -0
- package/dist/types/adapters/ImageVisionAdapter.d.ts +25 -0
- package/dist/types/adapters/ImageVisionAdapter.d.ts.map +1 -0
- package/dist/types/adapters/ImageVisionAdapter.js +2 -0
- package/dist/types/adapters/ImageVisionAdapter.js.map +1 -0
- package/dist/types/adapters/KeyValueAdapter.d.ts +10 -0
- package/dist/types/adapters/KeyValueAdapter.d.ts.map +1 -0
- package/dist/types/adapters/KeyValueAdapter.js +2 -0
- package/dist/types/adapters/KeyValueAdapter.js.map +1 -0
- package/dist/types/adapters/OAuth2Adapter.d.ts +32 -0
- package/dist/types/adapters/OAuth2Adapter.d.ts.map +1 -0
- package/dist/types/adapters/OAuth2Adapter.js +2 -0
- package/dist/types/adapters/OAuth2Adapter.js.map +1 -0
- package/dist/types/adapters/StorageAdapter.d.ts +63 -0
- package/dist/types/adapters/StorageAdapter.d.ts.map +1 -0
- package/dist/types/adapters/StorageAdapter.js +2 -0
- package/dist/types/adapters/StorageAdapter.js.map +1 -0
- package/dist/types/adapters/index.d.ts +9 -0
- package/dist/types/adapters/index.d.ts.map +1 -0
- package/dist/types/adapters/index.js +2 -0
- package/dist/types/adapters/index.js.map +1 -0
- package/package.json +3 -2
- package/dist/spa/src/types/Adapters.ts +0 -213
- package/dist/types/Adapters.d.ts +0 -168
- package/dist/types/Adapters.d.ts.map +0 -1
- package/dist/types/Adapters.js +0 -2
- 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,7 +22,7 @@ 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
|
|
|
@@ -92,19 +92,36 @@ export interface IExpressHttpServer extends IHttpServer {
|
|
|
92
92
|
* Adds adminUser to request object if user is authorized. Drops request with 401 status if user is not authorized.
|
|
93
93
|
* @param callable : Function which will be called if user is authorized.
|
|
94
94
|
*
|
|
95
|
-
* Example:
|
|
96
95
|
*
|
|
96
|
+
* @example
|
|
97
97
|
* ```ts
|
|
98
|
-
* expressApp.get('/myApi', authorize((req, res) =>
|
|
98
|
+
* expressApp.get('/myApi', authorize((req, res) => {
|
|
99
99
|
* console.log('User is authorized', req.adminUser);
|
|
100
|
-
* res.json(
|
|
101
|
-
*
|
|
102
|
-
*
|
|
100
|
+
* res.json({ message: 'Hello World' });
|
|
101
|
+
* }));
|
|
102
|
+
* ```
|
|
103
103
|
*
|
|
104
|
-
*/
|
|
104
|
+
*/
|
|
105
105
|
authorize(callable: Function): void;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
export interface ITranslateFunction {
|
|
109
|
+
(
|
|
110
|
+
msg: string,
|
|
111
|
+
category: string,
|
|
112
|
+
params: any,
|
|
113
|
+
pluralizationNumber?: number
|
|
114
|
+
): Promise<string>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Omit <Request, 'param'> is used to remove 'param' method from Request type for correct docs generation
|
|
118
|
+
export interface IAdminUserExpressRequest extends Omit<Request, 'protocol' | 'param' | 'unshift'> {
|
|
119
|
+
adminUser: AdminUser;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ITranslateExpressRequest extends Omit<Request, 'protocol' | 'param' | 'unshift'> {
|
|
123
|
+
tr: ITranslateFunction;
|
|
124
|
+
}
|
|
108
125
|
|
|
109
126
|
export interface IAdminForthSingleFilter {
|
|
110
127
|
field?: string;
|
|
@@ -113,7 +130,9 @@ export interface IAdminForthSingleFilter {
|
|
|
113
130
|
| AdminForthFilterOperators.LTE | AdminForthFilterOperators.LIKE | AdminForthFilterOperators.ILIKE
|
|
114
131
|
| AdminForthFilterOperators.IN | AdminForthFilterOperators.NIN;
|
|
115
132
|
value?: any;
|
|
133
|
+
rightField?: string;
|
|
116
134
|
insecureRawSQL?: string;
|
|
135
|
+
insecureRawNoSQL?: any;
|
|
117
136
|
}
|
|
118
137
|
export interface IAdminForthAndOrFilter {
|
|
119
138
|
operator: AdminForthFilterOperators.AND | AdminForthFilterOperators.OR;
|
|
@@ -336,7 +355,7 @@ export interface IAdminForth {
|
|
|
336
355
|
|
|
337
356
|
createResourceRecord(
|
|
338
357
|
params: { resource: AdminForthResource, record: any, adminUser: AdminUser, extra?: HttpExtra }
|
|
339
|
-
): Promise<{ error?: string, createdRecord?: any }>;
|
|
358
|
+
): Promise<{ error?: string, createdRecord?: any, newRecordId?: any }>;
|
|
340
359
|
|
|
341
360
|
updateResourceRecord(
|
|
342
361
|
params: { resource: AdminForthResource, recordId: any, record: any, oldRecord: any, adminUser: AdminUser, extra?: HttpExtra }
|
|
@@ -474,7 +493,7 @@ export type BeforeDataSourceRequestFunction = (params: {
|
|
|
474
493
|
requestUrl: string,
|
|
475
494
|
},
|
|
476
495
|
adminforth: IAdminForth,
|
|
477
|
-
}) => Promise<{ok: boolean, error?: string}>;
|
|
496
|
+
}) => Promise<{ok: boolean, error?: string, newRecordId?: string}>;
|
|
478
497
|
|
|
479
498
|
/**
|
|
480
499
|
* Modify response to change how data is returned after fetching from database.
|
|
@@ -525,7 +544,7 @@ export type BeforeEditSaveFunction = (params: {
|
|
|
525
544
|
oldRecord: any,
|
|
526
545
|
adminforth: IAdminForth,
|
|
527
546
|
extra?: HttpExtra,
|
|
528
|
-
}) => Promise<{ok: boolean, error?: string}>;
|
|
547
|
+
}) => Promise<{ok: boolean, error?: string | null}>;
|
|
529
548
|
|
|
530
549
|
|
|
531
550
|
|
|
@@ -535,7 +554,7 @@ export type BeforeCreateSaveFunction = (params: {
|
|
|
535
554
|
record: any,
|
|
536
555
|
adminforth: IAdminForth,
|
|
537
556
|
extra?: HttpExtra,
|
|
538
|
-
}) => Promise<{ok: boolean, error?: string}>;
|
|
557
|
+
}) => Promise<{ok: boolean, error?: string | null, newRecordId?: string}>;
|
|
539
558
|
|
|
540
559
|
export type AfterCreateSaveFunction = (params: {
|
|
541
560
|
resource: AdminForthResource,
|
|
@@ -619,12 +638,23 @@ interface AdminForthInputConfigCustomization {
|
|
|
619
638
|
*/
|
|
620
639
|
brandName?: string,
|
|
621
640
|
|
|
641
|
+
/**
|
|
642
|
+
* Whether to use single theme for the app
|
|
643
|
+
*/
|
|
644
|
+
singleTheme?: 'light' | 'dark',
|
|
645
|
+
|
|
622
646
|
/**
|
|
623
647
|
* Whether to show brand name in sidebar
|
|
624
648
|
* default is true
|
|
625
649
|
*/
|
|
626
650
|
showBrandNameInSidebar?: boolean,
|
|
627
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Whether to show brand logo in sidebar
|
|
654
|
+
* default is true
|
|
655
|
+
*/
|
|
656
|
+
showBrandLogoInSidebar?: boolean,
|
|
657
|
+
|
|
628
658
|
/**
|
|
629
659
|
* Path to your app logo
|
|
630
660
|
*
|
|
@@ -638,6 +668,19 @@ interface AdminForthInputConfigCustomization {
|
|
|
638
668
|
*/
|
|
639
669
|
brandLogo?: string,
|
|
640
670
|
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Path to your app logo for icon only sidebar
|
|
674
|
+
*
|
|
675
|
+
* Example:
|
|
676
|
+
* Place file `logo.svg` to `./custom` folder and set this option:
|
|
677
|
+
*
|
|
678
|
+
*/
|
|
679
|
+
iconOnlySidebar?: {
|
|
680
|
+
logo?: string,
|
|
681
|
+
enabled?: boolean,
|
|
682
|
+
},
|
|
683
|
+
|
|
641
684
|
/**
|
|
642
685
|
* Path to your app favicon
|
|
643
686
|
*
|
|
@@ -757,8 +800,19 @@ interface AdminForthInputConfigCustomization {
|
|
|
757
800
|
userMenu?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
758
801
|
header?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
759
802
|
sidebar?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
803
|
+
sidebarTop?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
760
804
|
everyPageBottom?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
761
805
|
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Allows adding custom elements (e.g., <link>, <script>, <meta>) to the <head> of the HTML document.
|
|
809
|
+
* Each item must include a tag name and a set of attributes.
|
|
810
|
+
*/
|
|
811
|
+
customHeadItems?: {
|
|
812
|
+
tagName: string;
|
|
813
|
+
attributes: Record<string, string | boolean>;
|
|
814
|
+
}[];
|
|
815
|
+
|
|
762
816
|
}
|
|
763
817
|
|
|
764
818
|
export interface AdminForthActionInput {
|
|
@@ -935,6 +989,13 @@ export interface AdminForthInputConfig {
|
|
|
935
989
|
*/
|
|
936
990
|
loginBackgroundPosition?: 'over' | '1/2' | '1/3' | '2/3' | '3/4' | '2/5' | '3/5',
|
|
937
991
|
|
|
992
|
+
/**
|
|
993
|
+
* If true, background blend mode will be removed from login background image when position is 'over'
|
|
994
|
+
*
|
|
995
|
+
* Default: false
|
|
996
|
+
*/
|
|
997
|
+
removeBackgroundBlendMode?: boolean,
|
|
998
|
+
|
|
938
999
|
/**
|
|
939
1000
|
* Function or functions which will be called before user try to login.
|
|
940
1001
|
* Each function will resive User object as an argument
|
|
@@ -956,7 +1017,7 @@ export interface AdminForthInputConfig {
|
|
|
956
1017
|
/**
|
|
957
1018
|
* Any prompt to show users on login. Supports HTML.
|
|
958
1019
|
*/
|
|
959
|
-
loginPromptHTML?: string
|
|
1020
|
+
loginPromptHTML?: string | (() => string | void | undefined | Promise<string | void | undefined>) | undefined
|
|
960
1021
|
|
|
961
1022
|
/**
|
|
962
1023
|
* Remember me days for "Remember Me" checkbox on login page.
|
|
@@ -988,6 +1049,16 @@ export interface AdminForthInputConfig {
|
|
|
988
1049
|
* If you are using Cloudflare, set this to 'CF-Connecting-IP'. Case-insensitive.
|
|
989
1050
|
*/
|
|
990
1051
|
clientIpHeader?: string,
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Add custom page to the settings page
|
|
1055
|
+
*/
|
|
1056
|
+
userMenuSettingsPages: {
|
|
1057
|
+
icon?: string,
|
|
1058
|
+
pageLabel: string,
|
|
1059
|
+
slug?: string,
|
|
1060
|
+
component: string
|
|
1061
|
+
}[],
|
|
991
1062
|
},
|
|
992
1063
|
|
|
993
1064
|
/**
|
|
@@ -1062,8 +1133,15 @@ export interface AdminForthConfigCustomization extends Omit<AdminForthInputConfi
|
|
|
1062
1133
|
userMenu: Array<AdminForthComponentDeclarationFull>,
|
|
1063
1134
|
header: Array<AdminForthComponentDeclarationFull>,
|
|
1064
1135
|
sidebar: Array<AdminForthComponentDeclarationFull>,
|
|
1136
|
+
sidebarTop: Array<AdminForthComponentDeclarationFull>,
|
|
1065
1137
|
everyPageBottom: Array<AdminForthComponentDeclarationFull>,
|
|
1066
1138
|
},
|
|
1139
|
+
|
|
1140
|
+
customHeadItems?: {
|
|
1141
|
+
tagName: string;
|
|
1142
|
+
attributes: Record<string, string | boolean>;
|
|
1143
|
+
}[];
|
|
1144
|
+
|
|
1067
1145
|
}
|
|
1068
1146
|
|
|
1069
1147
|
export interface AdminForthConfig extends Omit<AdminForthInputConfig, 'customization' | 'resources'> {
|
|
@@ -1111,6 +1189,21 @@ export class Filters {
|
|
|
1111
1189
|
static LIKE(field: string, value: any): IAdminForthSingleFilter {
|
|
1112
1190
|
return { field, operator: AdminForthFilterOperators.LIKE, value };
|
|
1113
1191
|
}
|
|
1192
|
+
static ILIKE(field: string, value: any): IAdminForthSingleFilter {
|
|
1193
|
+
return { field, operator: AdminForthFilterOperators.ILIKE, value };
|
|
1194
|
+
}
|
|
1195
|
+
static GT_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
|
|
1196
|
+
return { field: leftField, operator: AdminForthFilterOperators.GT, rightField };
|
|
1197
|
+
}
|
|
1198
|
+
static GTE_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
|
|
1199
|
+
return { field: leftField, operator: AdminForthFilterOperators.GTE, rightField };
|
|
1200
|
+
}
|
|
1201
|
+
static LT_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
|
|
1202
|
+
return { field: leftField, operator: AdminForthFilterOperators.LT, rightField };
|
|
1203
|
+
}
|
|
1204
|
+
static LTE_FIELD(leftField: string, rightField: string): IAdminForthSingleFilter {
|
|
1205
|
+
return { field: leftField, operator: AdminForthFilterOperators.LTE, rightField };
|
|
1206
|
+
}
|
|
1114
1207
|
static AND(
|
|
1115
1208
|
...args: (IAdminForthSingleFilter | IAdminForthAndOrFilter | Array<IAdminForthSingleFilter | IAdminForthAndOrFilter>)[]
|
|
1116
1209
|
): IAdminForthAndOrFilter {
|
|
@@ -1318,9 +1411,13 @@ export interface AdminForthResource extends Omit<AdminForthResourceInput, 'optio
|
|
|
1318
1411
|
},
|
|
1319
1412
|
create?: {
|
|
1320
1413
|
/**
|
|
1414
|
+
* Should return `ok: true` to continue saving pipeline and allow creating record in database, and `ok: false` to interrupt pipeline and prevent record creation.
|
|
1415
|
+
* If you need to show error on UI, set `error: \<error message\>` in response.
|
|
1416
|
+
*
|
|
1321
1417
|
* Typical use-cases:
|
|
1322
|
-
* -
|
|
1323
|
-
* -
|
|
1418
|
+
* - Create record by custom code (return `{ ok: false, newRecordId: <id of created record from custom code> }`)
|
|
1419
|
+
* - 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
|
|
1420
|
+
* - fill-in adminUser as creator of record (set `record.<some field> = x; return \{ ok: true \}`)
|
|
1324
1421
|
* - Attach additional data to record before saving to database (mostly fillOnCreate should be used instead)
|
|
1325
1422
|
*/
|
|
1326
1423
|
beforeSave?: Array<BeforeCreateSaveFunction>,
|
|
@@ -1471,15 +1568,27 @@ export type ShowInInput = ShowInModernInput | ShowInLegacyInput;
|
|
|
1471
1568
|
export type ShowIn = {
|
|
1472
1569
|
[key in AdminForthResourcePages]: AllowedActionValue
|
|
1473
1570
|
}
|
|
1571
|
+
export type BackendOnlyInput =
|
|
1572
|
+
| boolean
|
|
1573
|
+
| ((p: {
|
|
1574
|
+
adminUser: AdminUser;
|
|
1575
|
+
resource: AdminForthResource;
|
|
1576
|
+
meta: any;
|
|
1577
|
+
source: ActionCheckSource;
|
|
1578
|
+
adminforth: IAdminForth;
|
|
1579
|
+
}) => boolean | Promise<boolean>);
|
|
1580
|
+
|
|
1474
1581
|
|
|
1475
|
-
export interface AdminForthResourceColumnInput extends Omit<AdminForthResourceColumnInputCommon, 'showIn'> {
|
|
1582
|
+
export interface AdminForthResourceColumnInput extends Omit<AdminForthResourceColumnInputCommon, 'showIn' | 'backendOnly'> {
|
|
1476
1583
|
showIn?: ShowInInput,
|
|
1477
1584
|
foreignResource?: AdminForthForeignResource,
|
|
1585
|
+
backendOnly?: BackendOnlyInput;
|
|
1478
1586
|
}
|
|
1479
1587
|
|
|
1480
|
-
export interface AdminForthResourceColumn extends Omit<AdminForthResourceColumnCommon, 'showIn'> {
|
|
1588
|
+
export interface AdminForthResourceColumn extends Omit<AdminForthResourceColumnCommon, 'showIn' | 'backendOnly'> {
|
|
1481
1589
|
showIn?: ShowIn,
|
|
1482
1590
|
foreignResource?: AdminForthForeignResource,
|
|
1591
|
+
backendOnly?: BackendOnlyInput;
|
|
1483
1592
|
}
|
|
1484
1593
|
|
|
1485
1594
|
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
|
-
*
|
|
99
|
-
* * 'danger' - red button
|
|
100
|
-
* * 'success' - green button
|
|
101
|
-
* * 'active' - blue button
|
|
97
|
+
* Add custom class
|
|
102
98
|
**/
|
|
103
|
-
|
|
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?:
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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,19 @@ 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
|
+
}[],
|
|
1112
|
+
settingPages?:{
|
|
1113
|
+
icon?: string,
|
|
1114
|
+
pageLabel: string,
|
|
1115
|
+
slug?: string,
|
|
1116
|
+
component: string,
|
|
1117
|
+
}[],
|
|
1084
1118
|
}
|
|
1085
1119
|
|
|
1086
1120
|
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,35 @@
|
|
|
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 token for the captcha.
|
|
23
|
+
*/
|
|
24
|
+
getToken(): Promise<string> | string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Renders the captcha widget HTML.
|
|
28
|
+
*/
|
|
29
|
+
renderWidget(): void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Validates the captcha token.
|
|
33
|
+
*/
|
|
34
|
+
validate(token: string, ip: string): Promise<Record<string, any>>;
|
|
35
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface EmailAdapter {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This method is called to validate the configuration of the adapter
|
|
5
|
+
* and should throw a clear user-readable error if the configuration is invalid.
|
|
6
|
+
*/
|
|
7
|
+
validate(): Promise<void>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This method should send an email using the adapter
|
|
11
|
+
* @param from - The sender's email address
|
|
12
|
+
* @param to - The recipient's email address
|
|
13
|
+
* @param text - The plain text version of the email
|
|
14
|
+
* @param html - The HTML version of the email
|
|
15
|
+
* @param subject - The subject of the email
|
|
16
|
+
*/
|
|
17
|
+
sendEmail(
|
|
18
|
+
from: string,
|
|
19
|
+
to: string,
|
|
20
|
+
text: string,
|
|
21
|
+
html: string,
|
|
22
|
+
subject: string
|
|
23
|
+
): Promise<{
|
|
24
|
+
error?: string;
|
|
25
|
+
ok?: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
}
|