adminforth 2.27.0-next.5 → 2.27.0-next.50
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 +10 -5
- package/commands/createApp/templates/api.ts.hbs +12 -2
- package/commands/proxy.ts +18 -10
- package/dist/commands/proxy.js +14 -10
- package/dist/commands/proxy.js.map +1 -1
- package/dist/dataConnectors/clickhouse.d.ts +5 -2
- package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
- package/dist/dataConnectors/clickhouse.js +73 -9
- package/dist/dataConnectors/clickhouse.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/configValidator.d.ts.map +1 -1
- package/dist/modules/configValidator.js +16 -9
- package/dist/modules/configValidator.js.map +1 -1
- package/dist/modules/restApi.d.ts.map +1 -1
- package/dist/modules/restApi.js +515 -9
- package/dist/modules/restApi.js.map +1 -1
- package/dist/modules/styles.js +1 -1
- package/dist/modules/utils.d.ts +1 -1
- package/dist/modules/utils.d.ts.map +1 -1
- package/dist/modules/utils.js +3 -5
- package/dist/modules/utils.js.map +1 -1
- package/dist/servers/express.d.ts +2 -6
- package/dist/servers/express.d.ts.map +1 -1
- package/dist/servers/express.js +46 -1
- package/dist/servers/express.js.map +1 -1
- package/dist/servers/openapi.d.ts +25 -0
- package/dist/servers/openapi.d.ts.map +1 -0
- package/dist/servers/openapi.js +126 -0
- package/dist/servers/openapi.js.map +1 -0
- package/dist/spa/package-lock.json +41 -0
- package/dist/spa/package.json +4 -0
- package/dist/spa/pnpm-lock.yaml +38 -0
- package/dist/spa/src/App.vue +77 -76
- package/dist/spa/src/afcl/Button.vue +2 -3
- package/dist/spa/src/afcl/Dialog.vue +1 -1
- package/dist/spa/src/afcl/Input.vue +1 -1
- package/dist/spa/src/afcl/Select.vue +8 -2
- package/dist/spa/src/afcl/Skeleton.vue +5 -0
- package/dist/spa/src/afcl/Spinner.vue +1 -1
- package/dist/spa/src/components/CallActionWrapper.vue +1 -1
- package/dist/spa/src/components/ColumnValueInput.vue +16 -3
- package/dist/spa/src/components/ColumnValueInputWrapper.vue +25 -2
- package/dist/spa/src/components/CustomRangePicker.vue +16 -14
- package/dist/spa/src/components/Filters.vue +95 -63
- package/dist/spa/src/components/GroupsTable.vue +9 -6
- package/dist/spa/src/components/MenuLink.vue +2 -2
- package/dist/spa/src/components/ResourceForm.vue +101 -7
- package/dist/spa/src/components/ResourceListTable.vue +14 -8
- package/dist/spa/src/components/ShowTable.vue +1 -1
- package/dist/spa/src/components/Sidebar.vue +29 -8
- package/dist/spa/src/components/ThreeDotsMenu.vue +25 -10
- package/dist/spa/src/components/ValueRenderer.vue +1 -0
- package/dist/spa/src/spa_types/core.ts +32 -0
- package/dist/spa/src/stores/filters.ts +16 -12
- package/dist/spa/src/types/Back.ts +91 -24
- package/dist/spa/src/types/Common.ts +24 -5
- package/dist/spa/src/types/adapters/CompletionAdapter.ts +27 -5
- package/dist/spa/src/types/adapters/index.ts +2 -2
- package/dist/spa/src/utils/createEditUtils.ts +65 -0
- package/dist/spa/src/utils/index.ts +2 -1
- package/dist/spa/src/utils/utils.ts +42 -7
- package/dist/spa/src/utils.ts +2 -1
- package/dist/spa/src/views/CreateEditSkeleton.vue +78 -0
- package/dist/spa/src/views/CreateView.vue +24 -50
- package/dist/spa/src/views/EditView.vue +23 -40
- package/dist/spa/src/views/ListView.vue +22 -32
- package/dist/spa/src/views/ShowView.vue +66 -24
- package/dist/types/Back.d.ts +100 -30
- package/dist/types/Back.d.ts.map +1 -1
- package/dist/types/Back.js.map +1 -1
- package/dist/types/Common.d.ts +31 -5
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/dist/types/adapters/CompletionAdapter.d.ts +18 -3
- package/dist/types/adapters/CompletionAdapter.d.ts.map +1 -1
- package/dist/types/adapters/index.d.ts +1 -1
- package/dist/types/adapters/index.d.ts.map +1 -1
- package/package.json +9 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Express, Request, Response } from 'express';
|
|
2
|
+
import type { AnySchemaObject } from 'ajv';
|
|
2
3
|
import type { Writable } from 'stream';
|
|
3
4
|
|
|
4
5
|
import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum, AdminForthResourcePages,
|
|
@@ -13,6 +14,7 @@ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections,
|
|
|
13
14
|
type AdminForthConfigMenuItem,
|
|
14
15
|
type AnnouncementBadgeResponse,
|
|
15
16
|
type AdminForthResourceColumnInputCommon,
|
|
17
|
+
type ColumnMinMaxValue,
|
|
16
18
|
} from './Common.js';
|
|
17
19
|
|
|
18
20
|
export interface ICodeInjector {
|
|
@@ -37,6 +39,62 @@ export interface IAdminForthHttpResponse {
|
|
|
37
39
|
blobStream: () => Writable,
|
|
38
40
|
};
|
|
39
41
|
|
|
42
|
+
export interface IAdminForthEndpointHandlerInput {
|
|
43
|
+
body: any;
|
|
44
|
+
adminUser: AdminUser | undefined;
|
|
45
|
+
query: {[key: string]: any};
|
|
46
|
+
headers: {[key: string]: any};
|
|
47
|
+
cookies: Array<{ key: string, value: string }>;
|
|
48
|
+
response: IAdminForthHttpResponse;
|
|
49
|
+
requestUrl: string;
|
|
50
|
+
abortSignal: AbortSignal;
|
|
51
|
+
_raw_express_req: Request;
|
|
52
|
+
_raw_express_res: Response;
|
|
53
|
+
tr: ITranslateFunction;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IAdminForthEndpointOptions {
|
|
57
|
+
method: string,
|
|
58
|
+
noAuth?: boolean,
|
|
59
|
+
path: string,
|
|
60
|
+
description?: string,
|
|
61
|
+
request_schema?: AnySchemaObject,
|
|
62
|
+
response_schema?: AnySchemaObject,
|
|
63
|
+
responce_schema?: AnySchemaObject,
|
|
64
|
+
handler: (input: IAdminForthEndpointHandlerInput) => void | Promise<any>,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface IRegisteredApiSchema {
|
|
68
|
+
method: string;
|
|
69
|
+
path: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
request_schema?: AnySchemaObject;
|
|
72
|
+
response_schema?: AnySchemaObject;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface IAdminForthApiValidationError {
|
|
76
|
+
instancePath: string;
|
|
77
|
+
schemaPath: string;
|
|
78
|
+
keyword: string;
|
|
79
|
+
message?: string;
|
|
80
|
+
params: {[key: string]: any};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface IAdminForthApiValidationResult {
|
|
84
|
+
valid: boolean;
|
|
85
|
+
errors?: IAdminForthApiValidationError[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface IOpenApiRegistry {
|
|
89
|
+
registeredSchemas: IRegisteredApiSchema[];
|
|
90
|
+
|
|
91
|
+
registerApiSchema(options: IAdminForthEndpointOptions): IRegisteredApiSchema;
|
|
92
|
+
register_api_schema(options: IAdminForthEndpointOptions): IRegisteredApiSchema;
|
|
93
|
+
validateRequestSchema(route: IRegisteredApiSchema | null, payload: any): IAdminForthApiValidationResult;
|
|
94
|
+
validateResponseSchema(route: IRegisteredApiSchema | null, payload: any): IAdminForthApiValidationResult;
|
|
95
|
+
renderOpenApiDocument(): {[key: string]: any};
|
|
96
|
+
}
|
|
97
|
+
|
|
40
98
|
/**
|
|
41
99
|
* Implement this interface to create custom HTTP server adapter for AdminForth.
|
|
42
100
|
*/
|
|
@@ -56,23 +114,7 @@ export interface IHttpServer {
|
|
|
56
114
|
*
|
|
57
115
|
* @param options : Object with method, path and handler properties.
|
|
58
116
|
*/
|
|
59
|
-
endpoint(options:
|
|
60
|
-
method: string,
|
|
61
|
-
noAuth?: boolean,
|
|
62
|
-
path: string,
|
|
63
|
-
handler: (
|
|
64
|
-
body: any,
|
|
65
|
-
adminUser: any,
|
|
66
|
-
query: {[key: string]: string},
|
|
67
|
-
headers: {[key: string]: string},
|
|
68
|
-
cookies: {[key: string]: string},
|
|
69
|
-
response: IAdminForthHttpResponse,
|
|
70
|
-
requestUrl: string,
|
|
71
|
-
abortSignal: AbortSignal,
|
|
72
|
-
_raw_express_req: Request,
|
|
73
|
-
_raw_express_res: Response,
|
|
74
|
-
) => void,
|
|
75
|
-
}): void;
|
|
117
|
+
endpoint(options: IAdminForthEndpointOptions): void;
|
|
76
118
|
|
|
77
119
|
}
|
|
78
120
|
|
|
@@ -113,7 +155,7 @@ export interface ITranslateFunction {
|
|
|
113
155
|
(
|
|
114
156
|
msg: string,
|
|
115
157
|
category: string,
|
|
116
|
-
params
|
|
158
|
+
params?: any,
|
|
117
159
|
pluralizationNumber?: number
|
|
118
160
|
): Promise<string>;
|
|
119
161
|
}
|
|
@@ -256,7 +298,7 @@ export interface IAdminForthDataSourceConnector {
|
|
|
256
298
|
*
|
|
257
299
|
* Internally should call {@link IAdminForthDataSourceConnector.getFieldValue} for both min and max values.
|
|
258
300
|
*/
|
|
259
|
-
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<
|
|
301
|
+
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
|
|
260
302
|
|
|
261
303
|
|
|
262
304
|
/**
|
|
@@ -309,7 +351,7 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
|
|
|
309
351
|
newValues: any,
|
|
310
352
|
}): Promise<{ok: boolean, error?: string}>;
|
|
311
353
|
|
|
312
|
-
getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<
|
|
354
|
+
getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
|
|
313
355
|
|
|
314
356
|
deleteMany?({resource, recordIds}:{resource: AdminForthResource, recordIds: any[]}): Promise<number>;
|
|
315
357
|
}
|
|
@@ -359,6 +401,7 @@ export interface IAdminForth {
|
|
|
359
401
|
config: AdminForthConfig;
|
|
360
402
|
codeInjector: ICodeInjector;
|
|
361
403
|
express: IHttpServer;
|
|
404
|
+
openApi: IOpenApiRegistry;
|
|
362
405
|
|
|
363
406
|
restApi: IAdminForthRestAPI;
|
|
364
407
|
activatedPlugins: Array<IAdminForthPlugin>;
|
|
@@ -455,6 +498,8 @@ export interface IAdminForth {
|
|
|
455
498
|
* ```
|
|
456
499
|
*/
|
|
457
500
|
getPluginById<T>(id: string): T;
|
|
501
|
+
|
|
502
|
+
refreshMenuBadge(menuItemId: string, adminUser: AdminUser): Promise<void>;
|
|
458
503
|
}
|
|
459
504
|
|
|
460
505
|
|
|
@@ -532,7 +577,7 @@ export type BeforeDataSourceRequestFunction = (params: {
|
|
|
532
577
|
body: any,
|
|
533
578
|
query: Record<string, string>,
|
|
534
579
|
headers: Record<string, string>,
|
|
535
|
-
cookies:
|
|
580
|
+
cookies: { key: string, value: string }[],
|
|
536
581
|
requestUrl: string,
|
|
537
582
|
},
|
|
538
583
|
filtersTools: any,
|
|
@@ -570,7 +615,7 @@ export interface HttpExtra {
|
|
|
570
615
|
body: any,
|
|
571
616
|
query: Record<string, string>,
|
|
572
617
|
headers: Record<string, string>,
|
|
573
|
-
cookies:
|
|
618
|
+
cookies: { key: string, value: string }[],
|
|
574
619
|
requestUrl: string,
|
|
575
620
|
meta?: any,
|
|
576
621
|
response: IAdminForthHttpResponse
|
|
@@ -1305,6 +1350,19 @@ export interface AdminForthActionInput {
|
|
|
1305
1350
|
standardAllowedActions: AllowedActions;
|
|
1306
1351
|
}) => boolean;
|
|
1307
1352
|
url?: string;
|
|
1353
|
+
bulkHandler?: (params: {
|
|
1354
|
+
adminforth: IAdminForth;
|
|
1355
|
+
resource: AdminForthResource;
|
|
1356
|
+
recordIds: (string | number)[];
|
|
1357
|
+
adminUser: AdminUser;
|
|
1358
|
+
response: IAdminForthHttpResponse;
|
|
1359
|
+
extra?: HttpExtra;
|
|
1360
|
+
tr: ITranslateFunction;
|
|
1361
|
+
}) => Promise<{
|
|
1362
|
+
ok: boolean;
|
|
1363
|
+
error?: string;
|
|
1364
|
+
successMessage?: string;
|
|
1365
|
+
}>;
|
|
1308
1366
|
action?: (params: {
|
|
1309
1367
|
adminforth: IAdminForth;
|
|
1310
1368
|
resource: AdminForthResource;
|
|
@@ -1312,7 +1370,7 @@ export interface AdminForthActionInput {
|
|
|
1312
1370
|
adminUser: AdminUser;
|
|
1313
1371
|
response: IAdminForthHttpResponse;
|
|
1314
1372
|
extra?: HttpExtra;
|
|
1315
|
-
tr:
|
|
1373
|
+
tr: ITranslateFunction;
|
|
1316
1374
|
}) => Promise<{
|
|
1317
1375
|
ok: boolean;
|
|
1318
1376
|
error?: string;
|
|
@@ -1837,6 +1895,8 @@ export interface ResourceOptionsInput extends Omit<NonNullable<AdminForthResourc
|
|
|
1837
1895
|
/**
|
|
1838
1896
|
* Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
|
|
1839
1897
|
* using checkboxes.
|
|
1898
|
+
* @deprecated Since 2.26.5. Will be removed in 3.0.0. Use `actions` instead.
|
|
1899
|
+
|
|
1840
1900
|
*/
|
|
1841
1901
|
bulkActions?: Array<AdminForthBulkAction>,
|
|
1842
1902
|
|
|
@@ -2003,7 +2063,7 @@ export interface AdminForthBulkAction extends AdminForthBulkActionCommon {
|
|
|
2003
2063
|
* It should return Promise which will be resolved when action is done.
|
|
2004
2064
|
*/
|
|
2005
2065
|
action: ({ resource, selectedIds, adminUser, response, tr }: {
|
|
2006
|
-
resource: AdminForthResource, selectedIds: Array<any>, adminUser: AdminUser, response: IAdminForthHttpResponse, tr:
|
|
2066
|
+
resource: AdminForthResource, selectedIds: Array<any>, adminUser: AdminUser, response: IAdminForthHttpResponse, tr: ITranslateFunction
|
|
2007
2067
|
}) => Promise<{ ok: boolean, error?: string, successMessage?: string }>,
|
|
2008
2068
|
|
|
2009
2069
|
/**
|
|
@@ -2136,4 +2196,11 @@ export interface IWebSocketBroker {
|
|
|
2136
2196
|
publish: (topic: string, data: any, filterUsers?: (adminUser: AdminUser) => Promise<boolean>) => void;
|
|
2137
2197
|
|
|
2138
2198
|
registerWsClient: (client: IWebSocketClient) => void;
|
|
2199
|
+
}
|
|
2200
|
+
export interface PluginsCommonOptions {
|
|
2201
|
+
/**
|
|
2202
|
+
* Id of the plugin. It should be unique across all plugins.
|
|
2203
|
+
* It is required if you want to log custom actions, otherwise it is optional.
|
|
2204
|
+
*/
|
|
2205
|
+
id?: string;
|
|
2139
2206
|
}
|
|
@@ -303,7 +303,7 @@ export interface AdminForthComponentDeclarationFull {
|
|
|
303
303
|
[key: string]: any,
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
import { type AdminForthActionInput, type AdminForthResource } from './Back.js'
|
|
306
|
+
import { type IAdminForth, type AdminForthActionInput, type AdminForthResource } from './Back.js'
|
|
307
307
|
export { type AdminForthActionInput } from './Back.js'
|
|
308
308
|
|
|
309
309
|
export type AdminForthComponentDeclaration = AdminForthComponentDeclarationFull | string;
|
|
@@ -314,8 +314,9 @@ export type FieldGroup = {
|
|
|
314
314
|
noTitle?: boolean;
|
|
315
315
|
};
|
|
316
316
|
|
|
317
|
-
export interface AdminForthActionFront extends Omit<AdminForthActionInput, 'id'> {
|
|
317
|
+
export interface AdminForthActionFront extends Omit<AdminForthActionInput, 'id' | 'bulkHandler' | 'action' | 'allowed'> {
|
|
318
318
|
id: string;
|
|
319
|
+
hasBulkHandler?: boolean;
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
export interface AdminForthBulkActionFront extends Omit<AdminForthBulkActionCommon, 'id'> {
|
|
@@ -610,14 +611,14 @@ export type ValidationObject = {
|
|
|
610
611
|
* ```
|
|
611
612
|
*
|
|
612
613
|
*/
|
|
613
|
-
regExp
|
|
614
|
+
regExp?: string,
|
|
614
615
|
|
|
615
616
|
/**
|
|
616
617
|
* Error message shown to user if validation fails
|
|
617
618
|
*
|
|
618
619
|
* Example: "Invalid email format"
|
|
619
620
|
*/
|
|
620
|
-
message
|
|
621
|
+
message?: string,
|
|
621
622
|
|
|
622
623
|
/**
|
|
623
624
|
* Whether to check case sensitivity (i flag)
|
|
@@ -633,6 +634,20 @@ export type ValidationObject = {
|
|
|
633
634
|
* Whether to check global strings (g flag)
|
|
634
635
|
*/
|
|
635
636
|
global?: boolean
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Custom validator function.
|
|
640
|
+
*
|
|
641
|
+
* Example:
|
|
642
|
+
*
|
|
643
|
+
* ```ts
|
|
644
|
+
* validator: async (value) => {
|
|
645
|
+
* // custom validation logic
|
|
646
|
+
* return { isValid: true, message: 'Validation passed' }; // or { isValid: false, message: 'Validation failed' }
|
|
647
|
+
* }
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
validator?: (value: any, record: any, adminForth: IAdminForth) => {isValid: boolean, message?: string} | Promise<{isValid: boolean, message?: string}> | boolean,
|
|
636
651
|
}
|
|
637
652
|
|
|
638
653
|
|
|
@@ -1149,7 +1164,7 @@ export interface AdminForthConfigMenuItem {
|
|
|
1149
1164
|
* Optional callback which will be called before rendering the menu for each item.
|
|
1150
1165
|
* Result of callback if not null will be used as a small badge near the menu item.
|
|
1151
1166
|
*/
|
|
1152
|
-
badge?: string | ((user: AdminUser) => Promise<string>),
|
|
1167
|
+
badge?: string | number | ((user: AdminUser, adminForth: IAdminForth) => Promise<string | number> | string | number),
|
|
1153
1168
|
|
|
1154
1169
|
/**
|
|
1155
1170
|
* Tooltip shown on hover for badge
|
|
@@ -1242,4 +1257,8 @@ export interface GetBaseConfigResponse {
|
|
|
1242
1257
|
config: AdminForthConfigForFrontend,
|
|
1243
1258
|
adminUser: AdminUser,
|
|
1244
1259
|
version: string,
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
export interface ColumnMinMaxValue {
|
|
1263
|
+
[key: string]: { min: any, max: any }
|
|
1245
1264
|
}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import type { JSONSchemaType } from "ajv";
|
|
2
|
+
|
|
3
|
+
export type CompletionStreamEvent = {
|
|
4
|
+
type: "output" | "reasoning";
|
|
5
|
+
delta: string;
|
|
6
|
+
text: string;
|
|
7
|
+
source?: "summary" | "text";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type CompletionTool<Input = Record<string, any>, Output = any> = {
|
|
11
|
+
name: string;
|
|
12
|
+
input_schema: JSONSchemaType<Input>;
|
|
13
|
+
description?: string;
|
|
14
|
+
handler: (input: Input) => Promise<Output> | Output;
|
|
15
|
+
};
|
|
1
16
|
export interface CompletionAdapter {
|
|
2
17
|
|
|
3
18
|
/**
|
|
@@ -7,17 +22,24 @@ export interface CompletionAdapter {
|
|
|
7
22
|
validate(): void;
|
|
8
23
|
|
|
9
24
|
/**
|
|
10
|
-
* This method should return a text completion based on the provided content
|
|
25
|
+
* This method should return a text completion based on the provided content.
|
|
11
26
|
* @param content - The input text to complete
|
|
12
|
-
* @param stop - An array of stop sequences to indicate where to stop the completion
|
|
13
27
|
* @param maxTokens - The maximum number of tokens to generate
|
|
28
|
+
* @param outputSchema - Optional structured output schema for the response
|
|
29
|
+
* @param reasoningEffort - Optional parameter to indicate the level of reasoning effort for the completion
|
|
30
|
+
* @param onChunk - Optional callback invoked for each streamed chunk or reasoning event
|
|
14
31
|
* @returns A promise that resolves to an object containing the completed text and other metadata
|
|
15
32
|
*/
|
|
16
33
|
complete(
|
|
17
34
|
content: string,
|
|
18
|
-
stop: string[],
|
|
19
35
|
maxTokens: number,
|
|
20
|
-
outputSchema?: any
|
|
36
|
+
outputSchema?: any,
|
|
37
|
+
reasoningEffort?: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh',
|
|
38
|
+
tools?: CompletionTool[],
|
|
39
|
+
onChunk?: (
|
|
40
|
+
chunk: string,
|
|
41
|
+
event?: CompletionStreamEvent,
|
|
42
|
+
) => void | Promise<void>,
|
|
21
43
|
): Promise<{
|
|
22
44
|
content?: string;
|
|
23
45
|
finishReason?: string;
|
|
@@ -30,4 +52,4 @@ export interface CompletionAdapter {
|
|
|
30
52
|
* @returns The number of tokens in the input content
|
|
31
53
|
*/
|
|
32
54
|
measureTokensCount(content: string): Promise<number> | number;
|
|
33
|
-
}
|
|
55
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { EmailAdapter } from './EmailAdapter.js';
|
|
2
|
-
export type { CompletionAdapter } from './CompletionAdapter.js';
|
|
2
|
+
export type { CompletionAdapter, CompletionStreamEvent } from './CompletionAdapter.js';
|
|
3
3
|
export type { ImageGenerationAdapter } from './ImageGenerationAdapter.js';
|
|
4
4
|
export type { KeyValueAdapter } from './KeyValueAdapter.js';
|
|
5
5
|
export type { ImageVisionAdapter } from './ImageVisionAdapter.js';
|
|
6
6
|
export type { OAuth2Adapter } from './OAuth2Adapter.js';
|
|
7
7
|
export type { StorageAdapter } from './StorageAdapter.js';
|
|
8
|
-
export type { CaptchaAdapter } from './CaptchaAdapter.js';
|
|
8
|
+
export type { CaptchaAdapter } from './CaptchaAdapter.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AdminForthResourceColumn } from '@/types/Back';
|
|
2
|
+
import { useAdminforth } from '@/adminforth';
|
|
3
|
+
import { type Ref, nextTick } from 'vue';
|
|
4
|
+
|
|
5
|
+
export function scrollToInvalidField(resourceFormRef: any, t: (key: string) => string) {
|
|
6
|
+
const { alert } = useAdminforth();
|
|
7
|
+
let columnsWithErrors: {column: AdminForthResourceColumn, error: string}[] = [];
|
|
8
|
+
for (const column of resourceFormRef.value?.editableColumns || []) {
|
|
9
|
+
if (resourceFormRef.value?.columnsWithErrors[column.name]) {
|
|
10
|
+
columnsWithErrors.push({
|
|
11
|
+
column,
|
|
12
|
+
error: resourceFormRef.value?.columnsWithErrors[column.name]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const errorMessage = t('Failed to save. Please fix errors for the following fields:') + '<ul class="mt-2 list-disc list-inside">' + columnsWithErrors.map(c => `<li><strong>${c.column.label || c.column.name}</strong>: ${c.error}</li>`).join('') + '</ul>';
|
|
17
|
+
alert({
|
|
18
|
+
messageHtml: errorMessage,
|
|
19
|
+
variant: 'danger'
|
|
20
|
+
});
|
|
21
|
+
const firstInvalidElement = document.querySelector('.af-invalid-field-message');
|
|
22
|
+
if (firstInvalidElement) {
|
|
23
|
+
firstInvalidElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function saveRecordPreparations(
|
|
28
|
+
viewMode: 'create' | 'edit',
|
|
29
|
+
validatingMode: Ref<boolean>,
|
|
30
|
+
resourceFormRef: Ref<any>,
|
|
31
|
+
isValid: Ref<boolean>,
|
|
32
|
+
t: (key: string) => string,
|
|
33
|
+
saving: Ref<boolean>,
|
|
34
|
+
runSaveInterceptors: any,
|
|
35
|
+
record: Ref<Record<string, any>>,
|
|
36
|
+
coreStore: any,
|
|
37
|
+
route: any
|
|
38
|
+
) {
|
|
39
|
+
validatingMode.value = true;
|
|
40
|
+
await nextTick();
|
|
41
|
+
//wait for response for the user validation function if it exists
|
|
42
|
+
while (1) {
|
|
43
|
+
if (resourceFormRef.value?.isValidating) {
|
|
44
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
45
|
+
} else {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!isValid.value) {
|
|
50
|
+
await nextTick();
|
|
51
|
+
scrollToInvalidField(resourceFormRef, t);
|
|
52
|
+
return;
|
|
53
|
+
} else {
|
|
54
|
+
validatingMode.value = false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
saving.value = true;
|
|
58
|
+
const interceptorsResult = await runSaveInterceptors({
|
|
59
|
+
action: viewMode,
|
|
60
|
+
values: record.value,
|
|
61
|
+
resource: coreStore.resource,
|
|
62
|
+
resourceId: route.params.resourceId as string,
|
|
63
|
+
});
|
|
64
|
+
return interceptorsResult;
|
|
65
|
+
}
|
|
@@ -8,7 +8,7 @@ import { Dropdown } from 'flowbite';
|
|
|
8
8
|
import adminforth, { useAdminforth } from '../adminforth';
|
|
9
9
|
import sanitizeHtml from 'sanitize-html'
|
|
10
10
|
import debounce from 'debounce';
|
|
11
|
-
import type { AdminForthResourceColumnInputCommon, Predicate } from '@/types/Common';
|
|
11
|
+
import type { AdminForthActionFront, AdminForthResourceColumnInputCommon, AdminForthResourceCommon, Predicate } from '@/types/Common';
|
|
12
12
|
import { i18nInstance } from '../i18n'
|
|
13
13
|
import { useI18n } from 'vue-i18n';
|
|
14
14
|
import { onBeforeRouteLeave } from 'vue-router';
|
|
@@ -101,11 +101,13 @@ export async function callAdminForthApi(
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export function formatComponent(component: AdminForthComponentDeclaration): AdminForthComponentDeclarationFull {
|
|
104
|
+
export function formatComponent(component: AdminForthComponentDeclaration | undefined): AdminForthComponentDeclarationFull {
|
|
105
105
|
if (typeof component === 'string') {
|
|
106
106
|
return { file: component, meta: {} };
|
|
107
|
-
} else {
|
|
107
|
+
} else if (typeof component === 'object') {
|
|
108
108
|
return { file: component.file, meta: component.meta };
|
|
109
|
+
} else {
|
|
110
|
+
return { file: '', meta: {} };
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -191,7 +193,8 @@ export function applyRegexValidation(value: any, validation: ValidationObject[]
|
|
|
191
193
|
if ( validation?.length ) {
|
|
192
194
|
const validationArray = validation;
|
|
193
195
|
for (let i = 0; i < validationArray.length; i++) {
|
|
194
|
-
|
|
196
|
+
const regExpPattern = validationArray[i].regExp;
|
|
197
|
+
if (regExpPattern) {
|
|
195
198
|
let flags = '';
|
|
196
199
|
if (validationArray[i].caseSensitive) {
|
|
197
200
|
flags += 'i';
|
|
@@ -203,7 +206,7 @@ export function applyRegexValidation(value: any, validation: ValidationObject[]
|
|
|
203
206
|
flags += 'g';
|
|
204
207
|
}
|
|
205
208
|
|
|
206
|
-
const regExp = new RegExp(
|
|
209
|
+
const regExp = new RegExp(regExpPattern, flags);
|
|
207
210
|
if (value === undefined || value === null) {
|
|
208
211
|
value = '';
|
|
209
212
|
}
|
|
@@ -766,6 +769,7 @@ export async function executeCustomBulkAction({
|
|
|
766
769
|
onError,
|
|
767
770
|
setLoadingState,
|
|
768
771
|
confirmMessage,
|
|
772
|
+
resource,
|
|
769
773
|
}: {
|
|
770
774
|
actionId: string | number | undefined,
|
|
771
775
|
resourceId: string,
|
|
@@ -775,6 +779,7 @@ export async function executeCustomBulkAction({
|
|
|
775
779
|
onError?: (error: string) => void,
|
|
776
780
|
setLoadingState?: (loading: boolean) => void,
|
|
777
781
|
confirmMessage?: string,
|
|
782
|
+
resource?: AdminForthResourceCommon,
|
|
778
783
|
}): Promise<any> {
|
|
779
784
|
if (!recordIds || recordIds.length === 0) {
|
|
780
785
|
if (onError) {
|
|
@@ -796,7 +801,38 @@ export async function executeCustomBulkAction({
|
|
|
796
801
|
setLoadingState?.(true);
|
|
797
802
|
|
|
798
803
|
try {
|
|
799
|
-
|
|
804
|
+
const action = resource?.options?.actions?.find((a: any) => a.id === actionId) as AdminForthActionFront | undefined;
|
|
805
|
+
|
|
806
|
+
if (action?.hasBulkHandler && action?.showIn?.bulkButton) {
|
|
807
|
+
const result = await callAdminForthApi({
|
|
808
|
+
path: '/start_custom_bulk_action',
|
|
809
|
+
method: 'POST',
|
|
810
|
+
body: {
|
|
811
|
+
resourceId,
|
|
812
|
+
actionId,
|
|
813
|
+
recordIds,
|
|
814
|
+
extra: extra || {},
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
if (result?.ok) {
|
|
819
|
+
if (onSuccess) {
|
|
820
|
+
await onSuccess([result]);
|
|
821
|
+
}
|
|
822
|
+
return { ok: true, results: [result] };
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
if (result?.error) {
|
|
826
|
+
if (onError) {
|
|
827
|
+
onError(result.error);
|
|
828
|
+
}
|
|
829
|
+
return { error: result.error };
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
return result;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// Per-record parallel calls (legacy path)
|
|
800
836
|
const results = await Promise.all(
|
|
801
837
|
recordIds.map(recordId =>
|
|
802
838
|
callAdminForthApi({
|
|
@@ -811,7 +847,6 @@ export async function executeCustomBulkAction({
|
|
|
811
847
|
})
|
|
812
848
|
)
|
|
813
849
|
);
|
|
814
|
-
|
|
815
850
|
const lastResult = results[results.length - 1];
|
|
816
851
|
if (lastResult?.redirectUrl) {
|
|
817
852
|
if (lastResult.redirectUrl.includes('target=_blank')) {
|
package/dist/spa/src/utils.ts
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="w-full mt-[36px]">
|
|
3
|
+
<div class="w-full border dark:border-darkFormBorder border-gray-200 rounded-lg overflow-hidden shadow-resourseFormShadow dark:shadow-darkResourseFormShadow bg-white dark:bg-darkForm">
|
|
4
|
+
|
|
5
|
+
<div class="flex px-6 items-center border-b border-gray-200 dark:border-darkFormBorder bg-lightFormHeading dark:bg-darkFormHeading" style="height: 40px;">
|
|
6
|
+
<div class="w-[208px] flex-shrink-0 pr-6 text-xs text-lightListTableHeadingText uppercase dark:text-darkListTableHeadingText font-bold">
|
|
7
|
+
{{ $t('Field') }}
|
|
8
|
+
</div>
|
|
9
|
+
<div class="flex-1 text-xs text-lightListTableHeadingText uppercase dark:text-darkListTableHeadingText font-bold">
|
|
10
|
+
{{ $t('Value') }}
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div v-for="i in 5" :key="i"
|
|
15
|
+
class="flex items-center bg-lightForm dark:bg-darkForm border-b border-gray-100 dark:border-darkFormBorder"
|
|
16
|
+
:style="{ height: i === 2 ? '95px' : '75px' }"
|
|
17
|
+
>
|
|
18
|
+
<div class="w-[208px] flex-shrink-0 px-6 flex items-center gap-1">
|
|
19
|
+
<Skeleton class="w-24 h-[10px]" />
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div class="flex-1 px-6">
|
|
23
|
+
<div v-if="i === 2">
|
|
24
|
+
<Skeleton type="input" class="h-[42px] w-[160px]" />
|
|
25
|
+
<Skeleton class="mt-1 h-[12px] w-20" />
|
|
26
|
+
</div>
|
|
27
|
+
<Skeleton type="input" v-else-if="i === 4 || i === 5" class="h-[42px] w-[160px]" />
|
|
28
|
+
<Skeleton v-else type="input" class="h-[42px] w-full" />
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="flex items-start bg-lightForm dark:bg-darkForm" style="height: 759px;">
|
|
33
|
+
<div class="w-[208px] flex-shrink-0 px-6 pt-7">
|
|
34
|
+
<Skeleton class="w-24 h-[10px]" />
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="flex-1 px-6 pt-4 h-full flex flex-col">
|
|
38
|
+
<div class="flex flex-wrap items-center gap-3 p-1.5 border border-gray-300 dark:border-gray-600 rounded-t-lg bg-gray-50 dark:bg-gray-800 w-full box-border h-[44px]">
|
|
39
|
+
<template v-for="btn in skeletonButtons" :key="btn.id">
|
|
40
|
+
<div class=" animate-pulse flex items-center justify-center h-8 px-1 text-gray-300 dark:text-gray-600">
|
|
41
|
+
<component :is="btn.icon" class="w-5 h-5" />
|
|
42
|
+
</div>
|
|
43
|
+
<div v-if="btn.sep" class="w-px h-4 bg-gray-300 dark:bg-gray-600 mx-1"></div>
|
|
44
|
+
</template>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="flex-1 animate-pulse bg-white dark:bg-gray-950 border-x border-b border-gray-200 dark:border-gray-700 rounded-b-lg w-full shadow-inner"></div>
|
|
47
|
+
<div class="h-10"></div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script setup lang="ts">
|
|
55
|
+
import { markRaw } from 'vue';
|
|
56
|
+
import { IconExclamationCircleSolid } from '@iconify-prerendered/vue-flowbite';
|
|
57
|
+
import {
|
|
58
|
+
IconLinkOutline, IconCodeOutline, IconRectangleListOutline,
|
|
59
|
+
IconOrderedListOutline, IconLetterBoldOutline, IconLetterUnderlineOutline,
|
|
60
|
+
IconLetterItalicOutline, IconTextSlashOutline
|
|
61
|
+
} from '@iconify-prerendered/vue-flowbite';
|
|
62
|
+
import { IconH116Solid, IconH216Solid, IconH316Solid } from '@iconify-prerendered/vue-heroicons';
|
|
63
|
+
import { Skeleton } from '@/afcl';
|
|
64
|
+
|
|
65
|
+
const skeletonButtons = [
|
|
66
|
+
{ id: 'bold', icon: markRaw(IconLetterBoldOutline), sep: false },
|
|
67
|
+
{ id: 'italic', icon: markRaw(IconLetterItalicOutline), sep: false },
|
|
68
|
+
{ id: 'underline', icon: markRaw(IconLetterUnderlineOutline), sep: false },
|
|
69
|
+
{ id: 'strike', icon: markRaw(IconTextSlashOutline), sep: true },
|
|
70
|
+
{ id: 'h1', icon: markRaw(IconH116Solid), sep: false },
|
|
71
|
+
{ id: 'h2', icon: markRaw(IconH216Solid), sep: false },
|
|
72
|
+
{ id: 'h3', icon: markRaw(IconH316Solid), sep: true },
|
|
73
|
+
{ id: 'ul', icon: markRaw(IconRectangleListOutline), sep: false },
|
|
74
|
+
{ id: 'ol', icon: markRaw(IconOrderedListOutline), sep: false },
|
|
75
|
+
{ id: 'link', icon: markRaw(IconLinkOutline), sep: false },
|
|
76
|
+
{ id: 'codeBlock', icon: markRaw(IconCodeOutline), sep: false },
|
|
77
|
+
];
|
|
78
|
+
</script>
|