adminforth 2.27.0-next.5 → 2.27.0-next.51
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 +28 -9
- package/commands/createApp/templates/package.json.hbs +2 -1
- 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 +13 -7
- package/dist/servers/express.d.ts.map +1 -1
- package/dist/servers/express.js +141 -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 +137 -26
- 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 +140 -32
- 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 +11 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow"
|
|
2
|
+
<div class="overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow border dark:border-gray-700"
|
|
3
3
|
:class="{'rounded-default' : isRounded}"
|
|
4
4
|
>
|
|
5
5
|
<div v-if="groupName && !noTitle" class="text-md font-semibold px-6 py-3 flex flex-1 items-center text-lightShowTableHeadingText bg-lightShowTableHeadingBackground dark:bg-darkShowTableHeadingBackground dark:text-darkShowTableHeadingText rounded-t-lg">
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
>
|
|
72
72
|
<component v-if="item.icon" :is="getIcon(item.icon)" class="w-5 h-5 text-lightSidebarIcons group-hover:text-lightSidebarIconsHover transition duration-75 dark:group-hover:text-darkSidebarIconsHover dark:text-darkSidebarIcons" ></component>
|
|
73
73
|
<span class="overflow-hidden flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">{{ item.label }}
|
|
74
|
-
<span v-if="item.badge" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
74
|
+
<span v-if="item.badge || item.badge === 0" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
75
75
|
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">
|
|
76
76
|
<Tooltip v-if="item.badgeTooltip">
|
|
77
77
|
{{ item.badge }}
|
|
@@ -90,13 +90,15 @@
|
|
|
90
90
|
</svg>
|
|
91
91
|
</button>
|
|
92
92
|
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
|
|
93
|
+
<transition name="slow-drop">
|
|
94
|
+
<ul v-show="opened.includes(i)" :id="`dropdown-example${i}`" role="none" class="af-sidebar-dropdown pt-1 space-y-1 overflow-hidden">
|
|
95
|
+
<template v-for="(child, j) in item.children" :key="`menu-${i}-${j}`">
|
|
96
|
+
<li class="af-sidebar-menu-link">
|
|
97
|
+
<MenuLink :item="child" isChild="true" @click="$emit('hideSidebar')"/>
|
|
97
98
|
</li>
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
</template>
|
|
100
|
+
</ul>
|
|
101
|
+
</transition>
|
|
100
102
|
</li>
|
|
101
103
|
<li v-else class="af-sidebar-menu-link">
|
|
102
104
|
<MenuLink :item="item" @click="$emit('hideSidebar')"/>
|
|
@@ -129,7 +131,7 @@
|
|
|
129
131
|
} : {}"
|
|
130
132
|
>{{ item.label }}
|
|
131
133
|
|
|
132
|
-
<span v-if="item.badge" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
134
|
+
<span v-if="item.badge || item.badge === 0" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
133
135
|
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">
|
|
134
136
|
<Tooltip v-if="item.badgeTooltip">
|
|
135
137
|
{{ item.badge }}
|
|
@@ -292,6 +294,25 @@
|
|
|
292
294
|
background-color: rgba(75, 85, 99, 0.4);
|
|
293
295
|
}
|
|
294
296
|
|
|
297
|
+
/* Custom animation for dropdown */
|
|
298
|
+
.slow-drop-enter-active,
|
|
299
|
+
.slow-drop-leave-active {
|
|
300
|
+
overflow: hidden;
|
|
301
|
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.slow-drop-enter-from,
|
|
305
|
+
.slow-drop-leave-to {
|
|
306
|
+
opacity: 0;
|
|
307
|
+
transform: translateY(-4px);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.slow-drop-enter-to,
|
|
311
|
+
.slow-drop-leave-from {
|
|
312
|
+
opacity: 1;
|
|
313
|
+
transform: translateY(0);
|
|
314
|
+
}
|
|
315
|
+
|
|
295
316
|
/* For browsers that support overlay scrollbars natively */
|
|
296
317
|
@supports (overflow: overlay) {
|
|
297
318
|
.sidebar-scroll {
|
|
@@ -43,21 +43,28 @@
|
|
|
43
43
|
</div>
|
|
44
44
|
</div>
|
|
45
45
|
</li>
|
|
46
|
-
<li v-for="action in customActions" :key="action.id">
|
|
47
|
-
<div
|
|
46
|
+
<li v-for="(action, i) in customActions" :key="action.id">
|
|
47
|
+
<div
|
|
48
|
+
class="wrapper"
|
|
49
|
+
@click="injectedComponentClick(threeDotsDropdownItems ? threeDotsDropdownItems.length + i : i)"
|
|
50
|
+
>
|
|
48
51
|
<component
|
|
49
|
-
|
|
52
|
+
:ref="(el: any) => setComponentRef(el, threeDotsDropdownItems ? threeDotsDropdownItems.length + i : i)"
|
|
50
53
|
:is="(action.customComponent && getCustomComponent(formatComponent(action.customComponent))) || CallActionWrapper"
|
|
51
54
|
:meta="formatComponent(action.customComponent).meta"
|
|
52
55
|
@callAction="(payload? : Object) => handleActionClick(action, payload)"
|
|
53
|
-
>
|
|
54
|
-
<a @click.prevent class="block
|
|
55
|
-
<div class="flex items-center gap-2">
|
|
56
|
+
] >
|
|
57
|
+
<a @click.prevent class="block">
|
|
58
|
+
<div class="flex items-center gap-2 hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover">
|
|
56
59
|
<component
|
|
57
|
-
v-if="action.icon"
|
|
60
|
+
v-if="action.icon && !actionLoadingStates[action.id!]"
|
|
58
61
|
:is="getIcon(action.icon)"
|
|
59
62
|
class="w-4 h-4 text-lightPrimary dark:text-darkPrimary"
|
|
60
63
|
/>
|
|
64
|
+
<Spinner
|
|
65
|
+
v-if="actionLoadingStates[action.id!]"
|
|
66
|
+
class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
|
|
67
|
+
/>
|
|
61
68
|
{{ action.name }}
|
|
62
69
|
</div>
|
|
63
70
|
</a>
|
|
@@ -92,12 +99,12 @@
|
|
|
92
99
|
import { getCustomComponent, getIcon, formatComponent, executeCustomAction } from '@/utils';
|
|
93
100
|
import { useCoreStore } from '@/stores/core';
|
|
94
101
|
import { useAdminforth } from '@/adminforth';
|
|
95
|
-
import { callAdminForthApi } from '@/utils';
|
|
96
102
|
import { useRoute, useRouter } from 'vue-router';
|
|
97
103
|
import CallActionWrapper from '@/components/CallActionWrapper.vue'
|
|
98
104
|
import { ref, type ComponentPublicInstance, onMounted, onUnmounted } from 'vue';
|
|
99
105
|
import type { AdminForthActionFront, AdminForthBulkActionFront, AdminForthComponentDeclarationFull } from '@/types/Common';
|
|
100
106
|
import type { AdminForthActionInput } from '@/types/Back';
|
|
107
|
+
import { Spinner } from '@/afcl';
|
|
101
108
|
|
|
102
109
|
const { list, alert} = useAdminforth();
|
|
103
110
|
const route = useRoute();
|
|
@@ -105,6 +112,7 @@ const coreStore = useCoreStore();
|
|
|
105
112
|
const router = useRouter();
|
|
106
113
|
const threeDotsDropdownItemsRefs = ref<Array<ComponentPublicInstance | null>>([]);
|
|
107
114
|
const showDropdown = ref(false);
|
|
115
|
+
const actionLoadingStates = ref<Record<string, boolean>>({});
|
|
108
116
|
const dropdownRef = ref<HTMLElement | null>(null);
|
|
109
117
|
const buttonTriggerRef = ref<HTMLElement | null>(null);
|
|
110
118
|
|
|
@@ -136,6 +144,9 @@ async function handleActionClick(action: AdminForthActionInput, payload: any) {
|
|
|
136
144
|
resourceId: route.params.resourceId as string,
|
|
137
145
|
recordId: route.params.primaryKey as string,
|
|
138
146
|
extra: payload || {},
|
|
147
|
+
setLoadingState: (loading: boolean) => {
|
|
148
|
+
actionLoadingStates.value[action.id!] = loading;
|
|
149
|
+
},
|
|
139
150
|
onSuccess: async (data: any) => {
|
|
140
151
|
await coreStore.fetchRecord({
|
|
141
152
|
resourceId: route.params.resourceId as string,
|
|
@@ -166,6 +177,7 @@ function startBulkAction(actionId: string) {
|
|
|
166
177
|
}
|
|
167
178
|
|
|
168
179
|
async function injectedComponentClick(index: number) {
|
|
180
|
+
console.log('Injected component click triggered for index:', index);
|
|
169
181
|
const componentRef = threeDotsDropdownItemsRefs.value[index];
|
|
170
182
|
if (componentRef && 'click' in componentRef) {
|
|
171
183
|
(componentRef as any).click?.();
|
|
@@ -196,8 +208,11 @@ onUnmounted(() => {
|
|
|
196
208
|
</script>
|
|
197
209
|
|
|
198
210
|
<style lang="scss" scoped>
|
|
199
|
-
.wrapper
|
|
200
|
-
@apply px-4 py-2
|
|
211
|
+
.wrapper {
|
|
212
|
+
@apply px-4 py-2
|
|
213
|
+
hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover
|
|
214
|
+
dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover
|
|
215
|
+
cursor-pointer;
|
|
201
216
|
}
|
|
202
217
|
</style>
|
|
203
218
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
class="rounded-md m-0.5 bg-lightAnnouncementBG dark:bg-darkAnnouncementBG text-lightAnnouncementText dark:text-darkAnnouncementText py-0.5 px-2.5 text-sm"
|
|
12
12
|
>
|
|
13
13
|
<RouterLink
|
|
14
|
+
v-if="foreignResource && foreignResource?.pk"
|
|
14
15
|
class="font-medium text-lightSidebarText dark:text-darkSidebarText hover:brightness-110 whitespace-nowrap"
|
|
15
16
|
:to="{
|
|
16
17
|
name: 'resource-show',
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AdminForthResource, AdminForthResourceColumn } from '../types/Back.js';
|
|
2
|
+
import type { FilterParams } from '@/types/Common';
|
|
3
|
+
import type { Ref, ComputedRef } from 'vue';
|
|
2
4
|
|
|
3
5
|
export type resourceById = {
|
|
4
6
|
[key: string]: AdminForthResource;
|
|
@@ -61,3 +63,33 @@ export type AllowedActions = {
|
|
|
61
63
|
delete: boolean,
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
|
|
67
|
+
export type sortType = {
|
|
68
|
+
field: string,
|
|
69
|
+
direction: 'ask' | 'desc'
|
|
70
|
+
} | null;
|
|
71
|
+
|
|
72
|
+
export type AdminforthFilterStore = {
|
|
73
|
+
filters: Ref<FilterParams[]>,
|
|
74
|
+
|
|
75
|
+
setSort: (sort: sortType) => void,
|
|
76
|
+
getSort: () => sortType,
|
|
77
|
+
|
|
78
|
+
setFilter: (filters: FilterParams) => void,
|
|
79
|
+
setFilters: (filters: FilterParams[]) => void,
|
|
80
|
+
|
|
81
|
+
getFilters: () => FilterParams[],
|
|
82
|
+
|
|
83
|
+
clearFilter: (fieldName: string) => void,
|
|
84
|
+
clearFilters: () => void,
|
|
85
|
+
|
|
86
|
+
shouldFilterBeHidden: (fieldName: string) => boolean,
|
|
87
|
+
|
|
88
|
+
visibleFiltersCount: ComputedRef<number>,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface AdminforthFilterStoreUnwrapped extends Omit<AdminforthFilterStore, 'filters' | 'visibleFiltersCount'> {
|
|
92
|
+
filters: FilterParams[],
|
|
93
|
+
visibleFiltersCount: number,
|
|
94
|
+
}
|
|
95
|
+
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import { ref, computed, type Ref } from 'vue';
|
|
2
2
|
import { defineStore } from 'pinia';
|
|
3
3
|
import { useCoreStore } from './core';
|
|
4
|
+
import type { FilterParams } from '@/types/Common';
|
|
5
|
+
import type { AdminforthFilterStore, sortType } from '../spa_types/core';
|
|
4
6
|
|
|
5
7
|
export const useFiltersStore = defineStore('filters', () => {
|
|
6
|
-
const filters: Ref<
|
|
7
|
-
const sort: Ref<
|
|
8
|
+
const filters: Ref<FilterParams[]> = ref([]);
|
|
9
|
+
const sort: Ref<sortType> = ref(null);
|
|
8
10
|
const coreStore = useCoreStore();
|
|
9
11
|
|
|
10
|
-
const setSort = (s:
|
|
12
|
+
const setSort = (s: sortType): void => {
|
|
11
13
|
sort.value = s;
|
|
12
14
|
}
|
|
13
|
-
const getSort = () => {
|
|
15
|
+
const getSort = (): sortType => {
|
|
14
16
|
return sort.value;
|
|
15
17
|
}
|
|
16
|
-
const setFilter = (filter:
|
|
18
|
+
const setFilter = (filter: FilterParams) => {
|
|
17
19
|
const index = filters.value.findIndex(f => f.field === filter.field);
|
|
18
|
-
if (filters.value[index] && filters.value[index].operator === filter.
|
|
20
|
+
if (filters.value[index] && filters.value[index].operator === filter.operator) {
|
|
19
21
|
filters.value[index] = filter;
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
filters.value.push(filter);
|
|
23
25
|
}
|
|
24
|
-
const setFilters = (f:
|
|
26
|
+
const setFilters = (f: FilterParams[]) => {
|
|
25
27
|
filters.value = f;
|
|
26
28
|
}
|
|
27
|
-
const getFilters = () => {
|
|
29
|
+
const getFilters = (): FilterParams[] => {
|
|
28
30
|
return filters.value;
|
|
29
31
|
}
|
|
30
|
-
const clearFilter = (fieldName: string) => {
|
|
32
|
+
const clearFilter = (fieldName: string): void => {
|
|
31
33
|
filters.value = filters.value.filter(f => f.field !== fieldName);
|
|
32
34
|
}
|
|
33
|
-
const clearFilters = () => {
|
|
35
|
+
const clearFilters = (): void => {
|
|
34
36
|
filters.value = [];
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
const shouldFilterBeHidden = (fieldName: string) => {
|
|
39
|
+
const shouldFilterBeHidden = (fieldName: string): boolean => {
|
|
38
40
|
if (coreStore.resource?.columns) {
|
|
39
41
|
const column = coreStore.resource.columns.find((col: any) => col.name === fieldName);
|
|
40
42
|
if (column?.showIn?.filter !== true) {
|
|
@@ -48,7 +50,7 @@ export const useFiltersStore = defineStore('filters', () => {
|
|
|
48
50
|
return filters.value.filter(f => !shouldFilterBeHidden(f.field)).length;
|
|
49
51
|
});
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
const store = {
|
|
52
54
|
setFilter,
|
|
53
55
|
getFilters,
|
|
54
56
|
clearFilters,
|
|
@@ -60,4 +62,6 @@ export const useFiltersStore = defineStore('filters', () => {
|
|
|
60
62
|
shouldFilterBeHidden,
|
|
61
63
|
clearFilter
|
|
62
64
|
}
|
|
65
|
+
|
|
66
|
+
return store as AdminforthFilterStore;
|
|
63
67
|
})
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Express, Request, Response } from 'express';
|
|
2
|
+
import type { AnySchemaObject } from 'ajv';
|
|
2
3
|
import type { Writable } from 'stream';
|
|
4
|
+
import type { ZodType } from 'zod';
|
|
3
5
|
|
|
4
6
|
import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum, AdminForthResourcePages,
|
|
5
7
|
type AdminForthComponentDeclaration,
|
|
@@ -13,6 +15,7 @@ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections,
|
|
|
13
15
|
type AdminForthConfigMenuItem,
|
|
14
16
|
type AnnouncementBadgeResponse,
|
|
15
17
|
type AdminForthResourceColumnInputCommon,
|
|
18
|
+
type ColumnMinMaxValue,
|
|
16
19
|
} from './Common.js';
|
|
17
20
|
|
|
18
21
|
export interface ICodeInjector {
|
|
@@ -37,6 +40,81 @@ export interface IAdminForthHttpResponse {
|
|
|
37
40
|
blobStream: () => Writable,
|
|
38
41
|
};
|
|
39
42
|
|
|
43
|
+
export interface IAdminForthEndpointHandlerInput {
|
|
44
|
+
body: any;
|
|
45
|
+
adminUser: AdminUser | undefined;
|
|
46
|
+
query: {[key: string]: any};
|
|
47
|
+
headers: {[key: string]: any};
|
|
48
|
+
cookies: Array<{ key: string, value: string }>;
|
|
49
|
+
response: IAdminForthHttpResponse;
|
|
50
|
+
requestUrl: string;
|
|
51
|
+
abortSignal: AbortSignal;
|
|
52
|
+
_raw_express_req: Request;
|
|
53
|
+
_raw_express_res: Response;
|
|
54
|
+
tr: ITranslateFunction;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface IAdminForthEndpointOptions {
|
|
58
|
+
method: string,
|
|
59
|
+
noAuth?: boolean,
|
|
60
|
+
path: string,
|
|
61
|
+
description?: string,
|
|
62
|
+
request_schema?: AnySchemaObject,
|
|
63
|
+
response_schema?: AnySchemaObject,
|
|
64
|
+
responce_schema?: AnySchemaObject,
|
|
65
|
+
handler: (input: IAdminForthEndpointHandlerInput) => void | Promise<any>,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type AdminForthExpressSchemaInput = AnySchemaObject | ZodType;
|
|
69
|
+
|
|
70
|
+
export interface IAdminForthExpressRouteSchema {
|
|
71
|
+
/**
|
|
72
|
+
* Detailed OpenAPI operation description for a custom Express route.
|
|
73
|
+
*/
|
|
74
|
+
description?: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* JSON schema or Zod schema describing the request body for a custom Express route.
|
|
78
|
+
*/
|
|
79
|
+
request?: AdminForthExpressSchemaInput;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* JSON schema or Zod schema describing the JSON response body for a custom Express route.
|
|
83
|
+
*/
|
|
84
|
+
response?: AdminForthExpressSchemaInput;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface IRegisteredApiSchema {
|
|
88
|
+
method: string;
|
|
89
|
+
path: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
request_schema?: AnySchemaObject;
|
|
92
|
+
response_schema?: AnySchemaObject;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface IAdminForthApiValidationError {
|
|
96
|
+
instancePath: string;
|
|
97
|
+
schemaPath: string;
|
|
98
|
+
keyword: string;
|
|
99
|
+
message?: string;
|
|
100
|
+
params: {[key: string]: any};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface IAdminForthApiValidationResult {
|
|
104
|
+
valid: boolean;
|
|
105
|
+
errors?: IAdminForthApiValidationError[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface IOpenApiRegistry {
|
|
109
|
+
registeredSchemas: IRegisteredApiSchema[];
|
|
110
|
+
|
|
111
|
+
registerApiSchema(options: IAdminForthEndpointOptions): IRegisteredApiSchema;
|
|
112
|
+
register_api_schema(options: IAdminForthEndpointOptions): IRegisteredApiSchema;
|
|
113
|
+
validateRequestSchema(route: IRegisteredApiSchema | null, payload: any): IAdminForthApiValidationResult;
|
|
114
|
+
validateResponseSchema(route: IRegisteredApiSchema | null, payload: any): IAdminForthApiValidationResult;
|
|
115
|
+
renderOpenApiDocument(): {[key: string]: any};
|
|
116
|
+
}
|
|
117
|
+
|
|
40
118
|
/**
|
|
41
119
|
* Implement this interface to create custom HTTP server adapter for AdminForth.
|
|
42
120
|
*/
|
|
@@ -56,23 +134,7 @@ export interface IHttpServer {
|
|
|
56
134
|
*
|
|
57
135
|
* @param options : Object with method, path and handler properties.
|
|
58
136
|
*/
|
|
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;
|
|
137
|
+
endpoint(options: IAdminForthEndpointOptions): void;
|
|
76
138
|
|
|
77
139
|
}
|
|
78
140
|
|
|
@@ -106,14 +168,38 @@ export interface IExpressHttpServer extends IHttpServer {
|
|
|
106
168
|
* ```
|
|
107
169
|
*
|
|
108
170
|
*/
|
|
109
|
-
authorize(callable:
|
|
171
|
+
authorize(callable: (...args: any[]) => any): (...args: any[]) => any;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Method (middleware) to inject translation helper into Express request object.
|
|
175
|
+
*/
|
|
176
|
+
translatable(callable: (...args: any[]) => any): (...args: any[]) => any;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Registers OpenAPI schemas for a custom Express route.
|
|
180
|
+
*
|
|
181
|
+
* Wrap this around the handler passed to `app.get/post/...`.
|
|
182
|
+
* If you also need authorization, make `withSchema` the outer wrapper:
|
|
183
|
+
*
|
|
184
|
+
* ```ts
|
|
185
|
+
* import * as z from 'zod';
|
|
186
|
+
*
|
|
187
|
+
* app.get('/myApi', admin.express.withSchema({
|
|
188
|
+
* description: 'Returns current user profile',
|
|
189
|
+
* response: z.object({ user: z.unknown() }),
|
|
190
|
+
* }, admin.express.authorize((req, res) => {
|
|
191
|
+
* res.json({ user: req.adminUser });
|
|
192
|
+
* })));
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
withSchema(schema: IAdminForthExpressRouteSchema, callable: (...args: any[]) => any): (...args: any[]) => any;
|
|
110
196
|
}
|
|
111
197
|
|
|
112
198
|
export interface ITranslateFunction {
|
|
113
199
|
(
|
|
114
200
|
msg: string,
|
|
115
201
|
category: string,
|
|
116
|
-
params
|
|
202
|
+
params?: any,
|
|
117
203
|
pluralizationNumber?: number
|
|
118
204
|
): Promise<string>;
|
|
119
205
|
}
|
|
@@ -256,7 +342,7 @@ export interface IAdminForthDataSourceConnector {
|
|
|
256
342
|
*
|
|
257
343
|
* Internally should call {@link IAdminForthDataSourceConnector.getFieldValue} for both min and max values.
|
|
258
344
|
*/
|
|
259
|
-
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<
|
|
345
|
+
getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
|
|
260
346
|
|
|
261
347
|
|
|
262
348
|
/**
|
|
@@ -309,7 +395,7 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
|
|
|
309
395
|
newValues: any,
|
|
310
396
|
}): Promise<{ok: boolean, error?: string}>;
|
|
311
397
|
|
|
312
|
-
getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<
|
|
398
|
+
getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
|
|
313
399
|
|
|
314
400
|
deleteMany?({resource, recordIds}:{resource: AdminForthResource, recordIds: any[]}): Promise<number>;
|
|
315
401
|
}
|
|
@@ -358,7 +444,8 @@ export interface IAdminForthRestAPI {
|
|
|
358
444
|
export interface IAdminForth {
|
|
359
445
|
config: AdminForthConfig;
|
|
360
446
|
codeInjector: ICodeInjector;
|
|
361
|
-
express:
|
|
447
|
+
express: IExpressHttpServer;
|
|
448
|
+
openApi: IOpenApiRegistry;
|
|
362
449
|
|
|
363
450
|
restApi: IAdminForthRestAPI;
|
|
364
451
|
activatedPlugins: Array<IAdminForthPlugin>;
|
|
@@ -455,6 +542,8 @@ export interface IAdminForth {
|
|
|
455
542
|
* ```
|
|
456
543
|
*/
|
|
457
544
|
getPluginById<T>(id: string): T;
|
|
545
|
+
|
|
546
|
+
refreshMenuBadge(menuItemId: string, adminUser: AdminUser): Promise<void>;
|
|
458
547
|
}
|
|
459
548
|
|
|
460
549
|
|
|
@@ -532,7 +621,7 @@ export type BeforeDataSourceRequestFunction = (params: {
|
|
|
532
621
|
body: any,
|
|
533
622
|
query: Record<string, string>,
|
|
534
623
|
headers: Record<string, string>,
|
|
535
|
-
cookies:
|
|
624
|
+
cookies: { key: string, value: string }[],
|
|
536
625
|
requestUrl: string,
|
|
537
626
|
},
|
|
538
627
|
filtersTools: any,
|
|
@@ -570,7 +659,7 @@ export interface HttpExtra {
|
|
|
570
659
|
body: any,
|
|
571
660
|
query: Record<string, string>,
|
|
572
661
|
headers: Record<string, string>,
|
|
573
|
-
cookies:
|
|
662
|
+
cookies: { key: string, value: string }[],
|
|
574
663
|
requestUrl: string,
|
|
575
664
|
meta?: any,
|
|
576
665
|
response: IAdminForthHttpResponse
|
|
@@ -1305,6 +1394,19 @@ export interface AdminForthActionInput {
|
|
|
1305
1394
|
standardAllowedActions: AllowedActions;
|
|
1306
1395
|
}) => boolean;
|
|
1307
1396
|
url?: string;
|
|
1397
|
+
bulkHandler?: (params: {
|
|
1398
|
+
adminforth: IAdminForth;
|
|
1399
|
+
resource: AdminForthResource;
|
|
1400
|
+
recordIds: (string | number)[];
|
|
1401
|
+
adminUser: AdminUser;
|
|
1402
|
+
response: IAdminForthHttpResponse;
|
|
1403
|
+
extra?: HttpExtra;
|
|
1404
|
+
tr: ITranslateFunction;
|
|
1405
|
+
}) => Promise<{
|
|
1406
|
+
ok: boolean;
|
|
1407
|
+
error?: string;
|
|
1408
|
+
successMessage?: string;
|
|
1409
|
+
}>;
|
|
1308
1410
|
action?: (params: {
|
|
1309
1411
|
adminforth: IAdminForth;
|
|
1310
1412
|
resource: AdminForthResource;
|
|
@@ -1312,7 +1414,7 @@ export interface AdminForthActionInput {
|
|
|
1312
1414
|
adminUser: AdminUser;
|
|
1313
1415
|
response: IAdminForthHttpResponse;
|
|
1314
1416
|
extra?: HttpExtra;
|
|
1315
|
-
tr:
|
|
1417
|
+
tr: ITranslateFunction;
|
|
1316
1418
|
}) => Promise<{
|
|
1317
1419
|
ok: boolean;
|
|
1318
1420
|
error?: string;
|
|
@@ -1837,6 +1939,8 @@ export interface ResourceOptionsInput extends Omit<NonNullable<AdminForthResourc
|
|
|
1837
1939
|
/**
|
|
1838
1940
|
* Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
|
|
1839
1941
|
* using checkboxes.
|
|
1942
|
+
* @deprecated Since 2.26.5. Will be removed in 3.0.0. Use `actions` instead.
|
|
1943
|
+
|
|
1840
1944
|
*/
|
|
1841
1945
|
bulkActions?: Array<AdminForthBulkAction>,
|
|
1842
1946
|
|
|
@@ -2003,7 +2107,7 @@ export interface AdminForthBulkAction extends AdminForthBulkActionCommon {
|
|
|
2003
2107
|
* It should return Promise which will be resolved when action is done.
|
|
2004
2108
|
*/
|
|
2005
2109
|
action: ({ resource, selectedIds, adminUser, response, tr }: {
|
|
2006
|
-
resource: AdminForthResource, selectedIds: Array<any>, adminUser: AdminUser, response: IAdminForthHttpResponse, tr:
|
|
2110
|
+
resource: AdminForthResource, selectedIds: Array<any>, adminUser: AdminUser, response: IAdminForthHttpResponse, tr: ITranslateFunction
|
|
2007
2111
|
}) => Promise<{ ok: boolean, error?: string, successMessage?: string }>,
|
|
2008
2112
|
|
|
2009
2113
|
/**
|
|
@@ -2136,4 +2240,11 @@ export interface IWebSocketBroker {
|
|
|
2136
2240
|
publish: (topic: string, data: any, filterUsers?: (adminUser: AdminUser) => Promise<boolean>) => void;
|
|
2137
2241
|
|
|
2138
2242
|
registerWsClient: (client: IWebSocketClient) => void;
|
|
2243
|
+
}
|
|
2244
|
+
export interface PluginsCommonOptions {
|
|
2245
|
+
/**
|
|
2246
|
+
* Id of the plugin. It should be unique across all plugins.
|
|
2247
|
+
* It is required if you want to log custom actions, otherwise it is optional.
|
|
2248
|
+
*/
|
|
2249
|
+
id?: string;
|
|
2139
2250
|
}
|
|
@@ -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
|
+
}
|