adminforth 2.27.0-next.6 → 2.27.0-next.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/commands/callTsProxy.js +10 -5
  2. package/commands/createApp/templates/api.ts.hbs +28 -9
  3. package/commands/createApp/templates/package.json.hbs +2 -1
  4. package/commands/proxy.ts +18 -10
  5. package/dist/basePlugin.js +1 -1
  6. package/dist/basePlugin.js.map +1 -1
  7. package/dist/commands/proxy.js +14 -10
  8. package/dist/commands/proxy.js.map +1 -1
  9. package/dist/dataConnectors/clickhouse.d.ts +5 -2
  10. package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
  11. package/dist/dataConnectors/clickhouse.js +73 -9
  12. package/dist/dataConnectors/clickhouse.js.map +1 -1
  13. package/dist/index.d.ts +4 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +17 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/modules/configValidator.d.ts.map +1 -1
  18. package/dist/modules/configValidator.js +16 -9
  19. package/dist/modules/configValidator.js.map +1 -1
  20. package/dist/modules/restApi.d.ts.map +1 -1
  21. package/dist/modules/restApi.js +574 -9
  22. package/dist/modules/restApi.js.map +1 -1
  23. package/dist/modules/styles.js +1 -1
  24. package/dist/modules/utils.d.ts +1 -1
  25. package/dist/modules/utils.d.ts.map +1 -1
  26. package/dist/modules/utils.js +3 -5
  27. package/dist/modules/utils.js.map +1 -1
  28. package/dist/servers/express.d.ts +18 -7
  29. package/dist/servers/express.d.ts.map +1 -1
  30. package/dist/servers/express.js +141 -1
  31. package/dist/servers/express.js.map +1 -1
  32. package/dist/servers/openapi.d.ts +25 -0
  33. package/dist/servers/openapi.d.ts.map +1 -0
  34. package/dist/servers/openapi.js +92 -0
  35. package/dist/servers/openapi.js.map +1 -0
  36. package/dist/servers/openapiDocument.d.ts +12 -0
  37. package/dist/servers/openapiDocument.d.ts.map +1 -0
  38. package/dist/servers/openapiDocument.js +313 -0
  39. package/dist/servers/openapiDocument.js.map +1 -0
  40. package/dist/spa/package-lock.json +41 -0
  41. package/dist/spa/package.json +4 -0
  42. package/dist/spa/pnpm-lock.yaml +384 -310
  43. package/dist/spa/pnpm-workspace.yaml +4 -0
  44. package/dist/spa/src/App.vue +78 -76
  45. package/dist/spa/src/afcl/Button.vue +2 -3
  46. package/dist/spa/src/afcl/Dialog.vue +1 -1
  47. package/dist/spa/src/afcl/Input.vue +1 -1
  48. package/dist/spa/src/afcl/Select.vue +8 -2
  49. package/dist/spa/src/afcl/Skeleton.vue +5 -0
  50. package/dist/spa/src/afcl/Spinner.vue +1 -1
  51. package/dist/spa/src/components/CallActionWrapper.vue +1 -1
  52. package/dist/spa/src/components/ColumnValueInput.vue +16 -3
  53. package/dist/spa/src/components/ColumnValueInputWrapper.vue +25 -2
  54. package/dist/spa/src/components/CustomRangePicker.vue +10 -14
  55. package/dist/spa/src/components/Filters.vue +95 -63
  56. package/dist/spa/src/components/GroupsTable.vue +9 -6
  57. package/dist/spa/src/components/MenuLink.vue +2 -2
  58. package/dist/spa/src/components/ResourceForm.vue +101 -7
  59. package/dist/spa/src/components/ResourceListTable.vue +14 -8
  60. package/dist/spa/src/components/ShowTable.vue +1 -1
  61. package/dist/spa/src/components/Sidebar.vue +29 -8
  62. package/dist/spa/src/components/ThreeDotsMenu.vue +25 -10
  63. package/dist/spa/src/components/ValueRenderer.vue +1 -0
  64. package/dist/spa/src/spa_types/core.ts +32 -0
  65. package/dist/spa/src/stores/core.ts +15 -1
  66. package/dist/spa/src/stores/filters.ts +16 -12
  67. package/dist/spa/src/types/Back.ts +137 -26
  68. package/dist/spa/src/types/Common.ts +24 -5
  69. package/dist/spa/src/types/adapters/CompletionAdapter.ts +27 -5
  70. package/dist/spa/src/types/adapters/index.ts +2 -2
  71. package/dist/spa/src/utils/createEditUtils.ts +65 -0
  72. package/dist/spa/src/utils/index.ts +2 -1
  73. package/dist/spa/src/utils/utils.ts +42 -7
  74. package/dist/spa/src/utils.ts +2 -1
  75. package/dist/spa/src/views/CreateEditSkeleton.vue +93 -0
  76. package/dist/spa/src/views/CreateView.vue +24 -50
  77. package/dist/spa/src/views/EditView.vue +23 -40
  78. package/dist/spa/src/views/ListView.vue +22 -32
  79. package/dist/spa/src/views/ShowView.vue +66 -24
  80. package/dist/types/Back.d.ts +140 -32
  81. package/dist/types/Back.d.ts.map +1 -1
  82. package/dist/types/Back.js.map +1 -1
  83. package/dist/types/Common.d.ts +31 -5
  84. package/dist/types/Common.d.ts.map +1 -1
  85. package/dist/types/Common.js.map +1 -1
  86. package/dist/types/adapters/CompletionAdapter.d.ts +18 -3
  87. package/dist/types/adapters/CompletionAdapter.d.ts.map +1 -1
  88. package/dist/types/adapters/index.d.ts +1 -1
  89. package/dist/types/adapters/index.d.ts.map +1 -1
  90. package/package.json +11 -6
@@ -2,10 +2,11 @@
2
2
  <div class="relative flex flex-col max-w-full w-full">
3
3
  <Teleport to="body">
4
4
  <Filters
5
- :columns="coreStore.resource?.columns"
5
+ :columns="coreStore.resource?.columns as AdminForthResourceColumnCommon[] || []"
6
6
  :columnsMinMax="columnsMinMax"
7
7
  :show="filtersShow"
8
8
  @hide="filtersShow = false"
9
+ :filtersStore="filtersStore"
9
10
  />
10
11
  </Teleport>
11
12
 
@@ -69,19 +70,10 @@
69
70
  v-if="action.icon && !bulkActionLoadingStates[action.id!]"
70
71
  :is="getIcon(action.icon)"
71
72
  class="w-5 h-5 transition duration-75 group-hover:text-gray-900 dark:group-hover:text-white"></component>
72
- <div v-if="bulkActionLoadingStates[action.id!]">
73
- <svg
74
- aria-hidden="true"
75
- class="w-5 h-5 animate-spin text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
76
- viewBox="0 0 100 101"
77
- fill="none"
78
- xmlns="http://www.w3.org/2000/svg"
79
- >
80
- <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
81
- <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
82
- </svg>
83
- <span class="sr-only">Loading...</span>
84
- </div>
73
+ <Spinner
74
+ v-if="bulkActionLoadingStates[action.id!]"
75
+ class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
76
+ />
85
77
  {{ `${action.label} (${checkboxes.length})` }}
86
78
  <div v-if="action.badge" class="text-white bg-gradient-to-r from-purple-500
87
79
  via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none
@@ -98,25 +90,22 @@
98
90
  <button
99
91
  :key="action.id"
100
92
  @click="startCustomBulkActionInner(action.id!)"
101
- class="flex gap-1 items-center py-1 px-3 text-sm font-medium text-lightListViewButtonText focus:outline-none bg-lightListViewButtonBackground rounded-default border border-lightListViewButtonBorder hover:bg-lightListViewButtonBackgroundHover hover:text-lightListViewButtonTextHover focus:z-10 focus:ring-4 focus:ring-lightListViewButtonFocusRing dark:focus:ring-darkListViewButtonFocusRing dark:bg-darkListViewButtonBackground dark:text-darkListViewButtonText dark:border-darkListViewButtonBorder dark:hover:text-darkListViewButtonTextHover dark:hover:bg-darkListViewButtonBackgroundHover"
93
+ class="flex gap-1 items-center py-1 px-3 text-sm font-medium text-lightListViewButtonText
94
+ focus:outline-none bg-lightListViewButtonBackground rounded-default border h-[34px]
95
+ border-lightListViewButtonBorder hover:bg-lightListViewButtonBackgroundHover
96
+ hover:text-lightListViewButtonTextHover focus:z-10 focus:ring-4 af-button-shadow
97
+ focus:ring-lightListViewButtonFocusRing dark:focus:ring-darkListViewButtonFocusRing
98
+ dark:bg-darkListViewButtonBackground dark:text-darkListViewButtonText dark:border-darkListViewButtonBorder
99
+ dark:hover:text-darkListViewButtonTextHover dark:hover:bg-darkListViewButtonBackgroundHover"
102
100
  >
103
101
  <component
104
102
  v-if="action.icon && !customActionLoadingStates[action.id!]"
105
103
  :is="getIcon(action.icon)"
106
104
  class="w-5 h-5 transition duration-75 group-hover:text-gray-900 dark:group-hover:text-white"></component>
107
- <div v-if="customActionLoadingStates[action.id!]">
108
- <svg
109
- aria-hidden="true"
110
- class="w-5 h-5 animate-spin text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
111
- viewBox="0 0 100 101"
112
- fill="none"
113
- xmlns="http://www.w3.org/2000/svg"
114
- >
115
- <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
116
- <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
117
- </svg>
118
- <span class="sr-only">Loading...</span>
119
- </div>
105
+ <Spinner
106
+ v-if="customActionLoadingStates[action.id!]"
107
+ class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
108
+ />
120
109
  {{ `${action.name} (${checkboxes.length})` }}
121
110
  </button>
122
111
  </div>
@@ -233,8 +222,8 @@ import { computed, onMounted, onUnmounted, ref, watch, type Ref } from 'vue';
233
222
  import { useRoute } from 'vue-router';
234
223
  import { getCustomComponent, initThreeDotsDropdown, getList, startBulkAction } from '@/utils';
235
224
  import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
236
- import { Tooltip } from '@/afcl'
237
- import type { AdminForthComponentDeclaration, AdminForthComponentDeclarationFull } from '@/types/Common';
225
+ import { Tooltip, Spinner } from '@/afcl'
226
+ import type { AdminForthComponentDeclaration, AdminForthComponentDeclarationFull, AdminForthFilterOperators, AdminForthResourceColumnCommon } from '@/types/Common';
238
227
 
239
228
 
240
229
  import {
@@ -344,6 +333,7 @@ async function startCustomBulkActionInner(actionId: string | number) {
344
333
  resourceId: route.params.resourceId as string,
345
334
  recordIds: checkboxes.value,
346
335
  confirmMessage: action?.bulkConfirmationMessage,
336
+ resource: coreStore.resource!,
347
337
  setLoadingState: (loading: boolean) => {
348
338
  customActionLoadingStates.value[actionId] = loading;
349
339
  },
@@ -354,7 +344,7 @@ async function startCustomBulkActionInner(actionId: string | number) {
354
344
  const successResults = results.filter(r => r?.successMessage);
355
345
  if (successResults.length > 0) {
356
346
  alert({
357
- message: action?.bulkSuccessMessage || `${successResults.length} out of ${results.length} items processed successfully`,
347
+ message: action?.bulkSuccessMessage ? action.bulkSuccessMessage : action?.hasBulkHandler ? successResults[0].successMessage : `${successResults.length} out of ${results.length} items processed successfully`,
358
348
  variant: 'success'
359
349
  });
360
350
  }
@@ -413,7 +403,7 @@ async function init() {
413
403
  const [_, field, operator] = k.split('__');
414
404
  return {
415
405
  field,
416
- operator,
406
+ operator: operator as AdminForthFilterOperators,
417
407
  value: JSON.parse((route.query[k] as string))
418
408
  }
419
409
  });
@@ -12,7 +12,7 @@
12
12
  <BreadcrumbsWithButtons>
13
13
  <template v-if="coreStore.resource?.options?.actions">
14
14
 
15
- <template v-for="action in coreStore.resource.options.actions.filter(a => a.showIn?.showButton)" :key="action.id">
15
+ <div class="flex gap-1" v-for="action in coreStore.resource.options.actions.filter(a => a.showIn?.showButton)" :key="action.id">
16
16
  <component
17
17
  :is="action?.customComponent ? getCustomComponent(formatComponent(action.customComponent)) : CallActionWrapper"
18
18
  :meta="action.customComponent ? formatComponent(action.customComponent).meta : undefined"
@@ -29,23 +29,14 @@
29
29
  :is="getIcon(action.icon)"
30
30
  class="w-4 h-4 me-2 text-lightPrimary dark:text-darkPrimary"
31
31
  />
32
- <div v-if="actionLoadingStates[action.id!]" class="me-2">
33
- <svg
34
- aria-hidden="true"
35
- class="w-4 h-4 animate-spin text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
36
- viewBox="0 0 100 101"
37
- fill="none"
38
- xmlns="http://www.w3.org/2000/svg"
39
- >
40
- <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
41
- <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
42
- </svg>
43
- <span class="sr-only">Loading...</span>
44
- </div>
32
+ <Spinner
33
+ v-if="actionLoadingStates[action.id!]"
34
+ class="w-5 h-5 me-2 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
35
+ />
45
36
  {{ action.name }}
46
37
  </button>
47
38
  </component>
48
- </template>
39
+ </div>
49
40
  </template>
50
41
  <RouterLink v-if="coreStore.resource?.options?.allowedActions?.create"
51
42
  :to="{ name: 'resource-create', params: { resourceId: $route.params.resourceId } }"
@@ -85,14 +76,52 @@
85
76
  :adminUser="coreStore.adminUser"
86
77
  />
87
78
 
88
- <div v-if="loading" role="status" class="max-w-sm animate-pulse">
89
- <div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
90
- <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px] mb-2.5"></div>
91
- <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div>
92
- <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[330px] mb-2.5"></div>
93
- <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[300px] mb-2.5"></div>
94
- <div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"></div>
95
- <span class="sr-only">{{ $t('Loading...') }}</span>
79
+ <div
80
+ v-if="loading"
81
+ role="status"
82
+ class="animate-pulse overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow rounded-lg overflow-hidden border border-lightShowTableBodyBorder dark:border-darkShowTableBodyBorder"
83
+ >
84
+ <div
85
+ v-if="groups && groups.length > 0"
86
+ class="text-md font-semibold px-6 py-3 flex flex-1 items-center bg-lightShowTableHeadingBackground dark:bg-darkShowTableHeadingBackground dark:text-darkShowTableHeadingText border-b border-lightShowTableBodyBorder dark:border-darkShowTableBodyBorder"
87
+ >
88
+ <div class="h-4 bg-gray-300 dark:bg-gray-600 rounded-full w-32"></div>
89
+ </div>
90
+
91
+ <table class="w-full text-sm text-left table-fixed border-collapse">
92
+ <thead class="bg-lightShowTableUnderHeadingBackground dark:bg-darkShowTableUnderHeadingBackground block md:table-row-group">
93
+ <tr class="block md:table-row">
94
+ <th scope="col" class="px-6 py-3 text-xs uppercase hidden md:w-52 md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
95
+ {{ $t('Field') }}
96
+ </th>
97
+ <th scope="col" class="px-6 py-3 text-xs uppercase hidden md:table-cell text-lightShowTableUnderHeadingText dark:text-darkShowTableUnderHeadingText">
98
+ {{ $t('Value') }}
99
+ </th>
100
+ </tr>
101
+ </thead>
102
+
103
+ <tbody>
104
+ <tr
105
+ v-for="i in skeletonRowsCount"
106
+ :key="i"
107
+ class="bg-lightShowTablesBodyBackground border-t border-lightShowTableBodyBorder dark:bg-darkShowTablesBodyBackground dark:border-darkShowTableBodyBorder block md:table-row"
108
+ >
109
+ <td class="px-6 py-[15.5px] relative block md:table-cell pb-0 md:pb-[15.5px]">
110
+ <div class="md:absolute md:inset-0 flex items-center px-6 py-[15.5px]">
111
+ <div class="h-2.5 bg-gray-200 dark:bg-gray-700 rounded-full w-24"></div>
112
+ </div>
113
+ </td>
114
+
115
+ <td class="px-6 py-[15.5px] whitespace-pre-wrap block md:table-cell">
116
+ <div class="flex items-center h-full min-h-[21px]">
117
+ <div class="h-2.5 bg-gray-200 dark:bg-gray-700 rounded-full w-full max-w-[280px]"></div>
118
+ </div>
119
+ </td>
120
+ </tr>
121
+ </tbody>
122
+ </table>
123
+
124
+ <span class="sr-only">{{ $t('Loading...') }}</span>
96
125
  </div>
97
126
  <div
98
127
  v-else-if="coreStore.record"
@@ -163,6 +192,7 @@ import { useI18n } from 'vue-i18n';
163
192
  import { getIcon } from '@/utils';
164
193
  import { type AdminForthComponentDeclarationFull, type AdminForthResourceColumnCommon, type FieldGroup } from '@/types/Common.js';
165
194
  import CallActionWrapper from '@/components/CallActionWrapper.vue'
195
+ import { Spinner } from '@/afcl';
166
196
 
167
197
  const route = useRoute();
168
198
  const router = useRouter();
@@ -177,6 +207,18 @@ const customActions = computed(() => {
177
207
  return coreStore.resource?.options?.actions?.filter((a: any) => a.showIn?.showThreeDotsMenu) || [];
178
208
  });
179
209
 
210
+ const skeletonRowsCount = computed(() => {
211
+ const allCols = coreStore.resource?.columns || [];
212
+
213
+ const isEnabledInConfig = (col: any) => {
214
+ return col.showIn?.list !== false;
215
+ };
216
+
217
+ const finalCount = allCols.filter(isEnabledInConfig).length;
218
+
219
+ return finalCount > 0 ? finalCount : 10;
220
+ });
221
+
180
222
  onMounted(async () => {
181
223
  loading.value = true;
182
224
  await coreStore.fetchResourceFull({
@@ -216,7 +258,7 @@ const groups = computed(() => {
216
258
  });
217
259
 
218
260
  const allColumns = computed(() => {
219
- return coreStore.resource?.columns.filter(col => col.showIn?.show);
261
+ return coreStore.resource?.columns?.filter(col => col.showIn?.show);
220
262
  });
221
263
 
222
264
  const otherColumns = computed(() => {
@@ -1,6 +1,8 @@
1
1
  import type { Express, Request, Response } from 'express';
2
+ import type { AnySchemaObject } from 'ajv';
2
3
  import type { Writable } from 'stream';
3
- import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum, AdminForthResourcePages, type AdminForthComponentDeclaration, type AdminUser, type AllowedActionsResolved, type AdminForthBulkActionCommon, type AdminForthForeignResourceCommon, type AdminForthResourceColumnCommon, type AdminForthResourceInputCommon, type AdminForthComponentDeclarationFull, type AdminForthConfigMenuItem, type AnnouncementBadgeResponse, type AdminForthResourceColumnInputCommon } from './Common.js';
4
+ import type { ZodType } from 'zod';
5
+ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections, AllowedActionsEnum, AdminForthResourcePages, type AdminForthComponentDeclaration, type AdminUser, type AllowedActionsResolved, type AdminForthBulkActionCommon, type AdminForthForeignResourceCommon, type AdminForthResourceColumnCommon, type AdminForthResourceInputCommon, type AdminForthComponentDeclarationFull, type AdminForthConfigMenuItem, type AnnouncementBadgeResponse, type AdminForthResourceColumnInputCommon, type ColumnMinMaxValue } from './Common.js';
4
6
  export interface ICodeInjector {
5
7
  srcFoldersToSync: Object;
6
8
  allComponentNames: Object;
@@ -19,6 +21,81 @@ export interface IAdminForthHttpResponse {
19
21
  setStatus: (code: number, message: string) => void;
20
22
  blobStream: () => Writable;
21
23
  }
24
+ export interface IAdminForthEndpointHandlerInput {
25
+ body: any;
26
+ adminUser: AdminUser | undefined;
27
+ query: {
28
+ [key: string]: any;
29
+ };
30
+ headers: {
31
+ [key: string]: any;
32
+ };
33
+ cookies: Array<{
34
+ key: string;
35
+ value: string;
36
+ }>;
37
+ response: IAdminForthHttpResponse;
38
+ requestUrl: string;
39
+ abortSignal: AbortSignal;
40
+ _raw_express_req: Request;
41
+ _raw_express_res: Response;
42
+ tr: ITranslateFunction;
43
+ }
44
+ export interface IAdminForthEndpointOptions {
45
+ method: string;
46
+ noAuth?: boolean;
47
+ path: string;
48
+ description?: string;
49
+ request_schema?: AnySchemaObject;
50
+ response_schema?: AnySchemaObject;
51
+ responce_schema?: AnySchemaObject;
52
+ handler: (input: IAdminForthEndpointHandlerInput) => void | Promise<any>;
53
+ }
54
+ export type AdminForthExpressSchemaInput = AnySchemaObject | ZodType;
55
+ export interface IAdminForthExpressRouteSchema {
56
+ /**
57
+ * Detailed OpenAPI operation description for a custom Express route.
58
+ */
59
+ description?: string;
60
+ /**
61
+ * JSON schema or Zod schema describing the request body for a custom Express route.
62
+ */
63
+ request?: AdminForthExpressSchemaInput;
64
+ /**
65
+ * JSON schema or Zod schema describing the JSON response body for a custom Express route.
66
+ */
67
+ response?: AdminForthExpressSchemaInput;
68
+ }
69
+ export interface IRegisteredApiSchema {
70
+ method: string;
71
+ path: string;
72
+ description?: string;
73
+ request_schema?: AnySchemaObject;
74
+ response_schema?: AnySchemaObject;
75
+ }
76
+ export interface IAdminForthApiValidationError {
77
+ instancePath: string;
78
+ schemaPath: string;
79
+ keyword: string;
80
+ message?: string;
81
+ params: {
82
+ [key: string]: any;
83
+ };
84
+ }
85
+ export interface IAdminForthApiValidationResult {
86
+ valid: boolean;
87
+ errors?: IAdminForthApiValidationError[];
88
+ }
89
+ export interface IOpenApiRegistry {
90
+ registeredSchemas: IRegisteredApiSchema[];
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(): {
96
+ [key: string]: any;
97
+ };
98
+ }
22
99
  /**
23
100
  * Implement this interface to create custom HTTP server adapter for AdminForth.
24
101
  */
@@ -34,18 +111,7 @@ export interface IHttpServer {
34
111
  *
35
112
  * @param options : Object with method, path and handler properties.
36
113
  */
37
- endpoint(options: {
38
- method: string;
39
- noAuth?: boolean;
40
- path: string;
41
- handler: (body: any, adminUser: any, query: {
42
- [key: string]: string;
43
- }, headers: {
44
- [key: string]: string;
45
- }, cookies: {
46
- [key: string]: string;
47
- }, response: IAdminForthHttpResponse, requestUrl: string, abortSignal: AbortSignal, _raw_express_req: Request, _raw_express_res: Response) => void;
48
- }): void;
114
+ endpoint(options: IAdminForthEndpointOptions): void;
49
115
  }
50
116
  export interface IExpressHttpServer extends IHttpServer {
51
117
  /**
@@ -73,10 +139,32 @@ export interface IExpressHttpServer extends IHttpServer {
73
139
  * ```
74
140
  *
75
141
  */
76
- authorize(callable: Function): void;
142
+ authorize(callable: (...args: any[]) => any): (...args: any[]) => any;
143
+ /**
144
+ * Method (middleware) to inject translation helper into Express request object.
145
+ */
146
+ translatable(callable: (...args: any[]) => any): (...args: any[]) => any;
147
+ /**
148
+ * Registers OpenAPI schemas for a custom Express route.
149
+ *
150
+ * Wrap this around the handler passed to `app.get/post/...`.
151
+ * If you also need authorization, make `withSchema` the outer wrapper:
152
+ *
153
+ * ```ts
154
+ * import * as z from 'zod';
155
+ *
156
+ * app.get('/myApi', admin.express.withSchema({
157
+ * description: 'Returns current user profile',
158
+ * response: z.object({ user: z.unknown() }),
159
+ * }, admin.express.authorize((req, res) => {
160
+ * res.json({ user: req.adminUser });
161
+ * })));
162
+ * ```
163
+ */
164
+ withSchema(schema: IAdminForthExpressRouteSchema, callable: (...args: any[]) => any): (...args: any[]) => any;
77
165
  }
78
166
  export interface ITranslateFunction {
79
- (msg: string, category: string, params: any, pluralizationNumber?: number): Promise<string>;
167
+ (msg: string, category: string, params?: any, pluralizationNumber?: number): Promise<string>;
80
168
  }
81
169
  export interface IAdminUserExpressRequest extends Omit<Request, 'protocol' | 'param' | 'unshift'> {
82
170
  adminUser: AdminUser;
@@ -206,12 +294,7 @@ export interface IAdminForthDataSourceConnector {
206
294
  getMinMaxForColumnsWithOriginalTypes({ resource, columns }: {
207
295
  resource: AdminForthResource;
208
296
  columns: AdminForthResourceColumn[];
209
- }): Promise<{
210
- [key: string]: {
211
- min: any;
212
- max: any;
213
- };
214
- }>;
297
+ }): Promise<ColumnMinMaxValue>;
215
298
  /**
216
299
  * Used to create record in database. Should return value of primary key column of created record.
217
300
  */
@@ -274,12 +357,7 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
274
357
  getMinMaxForColumns({ resource, columns }: {
275
358
  resource: AdminForthResource;
276
359
  columns: AdminForthResourceColumn[];
277
- }): Promise<{
278
- [key: string]: {
279
- min: any;
280
- max: any;
281
- };
282
- }>;
360
+ }): Promise<ColumnMinMaxValue>;
283
361
  deleteMany?({ resource, recordIds }: {
284
362
  resource: AdminForthResource;
285
363
  recordIds: any[];
@@ -343,7 +421,8 @@ export interface IAdminForthRestAPI {
343
421
  export interface IAdminForth {
344
422
  config: AdminForthConfig;
345
423
  codeInjector: ICodeInjector;
346
- express: IHttpServer;
424
+ express: IExpressHttpServer;
425
+ openApi: IOpenApiRegistry;
347
426
  restApi: IAdminForthRestAPI;
348
427
  activatedPlugins: Array<IAdminForthPlugin>;
349
428
  websocket: IWebSocketBroker;
@@ -418,6 +497,7 @@ export interface IAdminForth {
418
497
  * ```
419
498
  */
420
499
  getPluginById<T>(id: string): T;
500
+ refreshMenuBadge(menuItemId: string, adminUser: AdminUser): Promise<void>;
421
501
  }
422
502
  export interface IAdminForthPlugin {
423
503
  adminforth: IAdminForth;
@@ -486,7 +566,10 @@ export type BeforeDataSourceRequestFunction = (params: {
486
566
  body: any;
487
567
  query: Record<string, string>;
488
568
  headers: Record<string, string>;
489
- cookies: Record<string, string>;
569
+ cookies: {
570
+ key: string;
571
+ value: string;
572
+ }[];
490
573
  requestUrl: string;
491
574
  };
492
575
  filtersTools: any;
@@ -528,7 +611,10 @@ export interface HttpExtra {
528
611
  body: any;
529
612
  query: Record<string, string>;
530
613
  headers: Record<string, string>;
531
- cookies: Record<string, string>;
614
+ cookies: {
615
+ key: string;
616
+ value: string;
617
+ }[];
532
618
  requestUrl: string;
533
619
  meta?: any;
534
620
  response: IAdminForthHttpResponse;
@@ -1205,6 +1291,19 @@ export interface AdminForthActionInput {
1205
1291
  standardAllowedActions: AllowedActions;
1206
1292
  }) => boolean;
1207
1293
  url?: string;
1294
+ bulkHandler?: (params: {
1295
+ adminforth: IAdminForth;
1296
+ resource: AdminForthResource;
1297
+ recordIds: (string | number)[];
1298
+ adminUser: AdminUser;
1299
+ response: IAdminForthHttpResponse;
1300
+ extra?: HttpExtra;
1301
+ tr: ITranslateFunction;
1302
+ }) => Promise<{
1303
+ ok: boolean;
1304
+ error?: string;
1305
+ successMessage?: string;
1306
+ }>;
1208
1307
  action?: (params: {
1209
1308
  adminforth: IAdminForth;
1210
1309
  resource: AdminForthResource;
@@ -1212,7 +1311,7 @@ export interface AdminForthActionInput {
1212
1311
  adminUser: AdminUser;
1213
1312
  response: IAdminForthHttpResponse;
1214
1313
  extra?: HttpExtra;
1215
- tr: Function;
1314
+ tr: ITranslateFunction;
1216
1315
  }) => Promise<{
1217
1316
  ok: boolean;
1218
1317
  error?: string;
@@ -1597,6 +1696,8 @@ export interface ResourceOptionsInput extends Omit<NonNullable<AdminForthResourc
1597
1696
  /**
1598
1697
  * Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
1599
1698
  * using checkboxes.
1699
+ * @deprecated Since 2.26.5. Will be removed in 3.0.0. Use `actions` instead.
1700
+
1600
1701
  */
1601
1702
  bulkActions?: Array<AdminForthBulkAction>;
1602
1703
  /**
@@ -1750,7 +1851,7 @@ export interface AdminForthBulkAction extends AdminForthBulkActionCommon {
1750
1851
  selectedIds: Array<any>;
1751
1852
  adminUser: AdminUser;
1752
1853
  response: IAdminForthHttpResponse;
1753
- tr: (key: string, category?: string, params?: any) => string;
1854
+ tr: ITranslateFunction;
1754
1855
  }) => Promise<{
1755
1856
  ok: boolean;
1756
1857
  error?: string;
@@ -1869,5 +1970,12 @@ export interface IWebSocketBroker {
1869
1970
  publish: (topic: string, data: any, filterUsers?: (adminUser: AdminUser) => Promise<boolean>) => void;
1870
1971
  registerWsClient: (client: IWebSocketClient) => void;
1871
1972
  }
1973
+ export interface PluginsCommonOptions {
1974
+ /**
1975
+ * Id of the plugin. It should be unique across all plugins.
1976
+ * It is required if you want to log custom actions, otherwise it is optional.
1977
+ */
1978
+ id?: string;
1979
+ }
1872
1980
  export {};
1873
1981
  //# sourceMappingURL=Back.d.ts.map