adminizer 4.7.0-build.222 → 5.0.0-build.0
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/Readme.md +2 -1
- package/assets/add-a4odXvQk.js +1 -0
- package/assets/add-group-D-NleXth.js +1 -0
- package/assets/add-user-B4SVJT5P.js +1 -0
- package/assets/app-CtWuWD5N.css +1 -0
- package/assets/app-layout-eaSzcROf.js +1 -0
- package/assets/app.js +35 -39
- package/assets/catalog-ByUICd5z.js +6 -0
- package/assets/controls/chunks/_commonjsHelpers-C6fGbg64.js +6 -0
- package/assets/controls/chunks/index-CjiZ2FIa.js +93 -0
- package/assets/controls/chunks/jsx-runtime-jIxVPx5o.js +31 -0
- package/assets/controls/chunks/use-appearance-CFLOwiSX.js +38 -0
- package/assets/controls/chunks/use-window-size-BXgBKW65.js +19 -0
- package/assets/controls/chunks/vanilla-picker-Dg97NL4h.js +529 -0
- package/assets/{RelationDialogStack-CnHFOYyR.css → controls/ckeditor.css} +1 -1
- package/assets/controls/ckeditor.es.js +83663 -0
- package/assets/controls/handsontable.css +1 -0
- package/assets/controls/handsontable.es.js +70550 -0
- package/assets/controls/jsoneditor.css +1 -0
- package/assets/controls/jsoneditor.es.js +42009 -0
- package/assets/controls/leaflet.css +1 -0
- package/assets/controls/leaflet.es.js +10299 -0
- package/assets/controls/monaco.es.js +618 -0
- package/assets/controls/toast-ui.css +1 -0
- package/assets/controls/toast-ui.es.js +41768 -0
- package/assets/dashboard-BYd8G2cW.js +3 -0
- package/assets/debounce-BMmXVQ06.js +1 -0
- package/assets/history-B8KIDy44.js +1 -0
- package/assets/init-user-8aUohVDq.js +1 -0
- package/assets/list-ChmtBGjG.js +4 -0
- package/assets/login-CO4laf6m.js +1 -0
- package/assets/manifest.json +60 -615
- package/assets/{media-manager-WcKe1EvD.js → media-manager-BDbpSSjH.js} +3 -3
- package/assets/module-D59aE9uv.js +1 -0
- package/assets/notification-DNoyfNmT.js +20 -0
- package/assets/register-DBYIMXGQ.js +1 -0
- package/assets/{ru-eW0WKkga.js → ru-rYKdQbWF.js} +1 -1
- package/assets/use-appearance-_EbbjHTh.js +1 -0
- package/assets/user-filters-list-BMFRwkYF.js +1 -0
- package/assets/welcome-37rNVUHt.js +1 -0
- package/controllers/add.d.ts +1 -1
- package/controllers/addGroup.js +3 -3
- package/controllers/addUser.js +3 -3
- package/controllers/catalog/Catalog.d.ts +1 -1
- package/controllers/catalog/Catalog.js +2 -1
- package/controllers/catalog/FrontendCatalogAdapter.d.ts +2 -12
- package/controllers/catalog/FrontendCatalogAdapter.js +3 -16
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +2 -12
- package/controllers/catalog/FrontentCatalogAdapter.js +0 -16
- package/controllers/edit.js +6 -11
- package/controllers/editGroup.d.ts +1 -1
- package/controllers/editGroup.js +3 -3
- package/controllers/editUser.d.ts +1 -1
- package/controllers/editUser.js +3 -3
- package/controllers/feed.js +1 -1
- package/controllers/filter-fields/columns.js +1 -1
- package/controllers/filter-fields/getAllUserFilters.js +2 -2
- package/controllers/filter-fields/groups.js +2 -2
- package/controllers/filter-fields/savedFilters.js +1 -1
- package/controllers/history-actions/HistoryController.js +1 -1
- package/controllers/initUser.js +2 -2
- package/controllers/list.d.ts +1 -1
- package/controllers/login.d.ts +1 -1
- package/controllers/login.js +3 -3
- package/controllers/media-manager/ThumbController.js +2 -2
- package/controllers/media-manager/mediaManagerApi.js +13 -15
- package/controllers/register.d.ts +1 -1
- package/controllers/register.js +5 -5
- package/controllers/remove.d.ts +1 -1
- package/controllers/userApiKey.js +2 -2
- package/controllers/view.d.ts +1 -1
- package/controllers/view.js +5 -5
- package/controllers/widgets/Action.js +5 -2
- package/controllers/widgets/Info.js +1 -1
- package/controllers/widgets/filterInfo.js +1 -1
- package/files/favicon.png +0 -0
- package/helpers/accessRightsHelper.d.ts +6 -4
- package/helpers/accessRightsHelper.js +13 -0
- package/helpers/diffHelpers.js +1 -1
- package/helpers/fieldsHelper.d.ts +1 -1
- package/helpers/fieldsHelper.js +8 -4
- package/helpers/filterDatetimeHelper.d.ts +1 -1
- package/helpers/inertiaAddHelper.d.ts +6 -5
- package/helpers/inertiaAddHelper.js +45 -37
- package/helpers/inertiaAutHelper.js +5 -5
- package/helpers/inertiaGroupHelper.d.ts +4 -4
- package/helpers/inertiaMenuHelper.js +1 -1
- package/helpers/inertiaUserHelper.d.ts +3 -3
- package/helpers/inertiaUserHelper.js +1 -1
- package/helpers/menuHelper.d.ts +2 -2
- package/index.d.ts +18 -6
- package/index.js +18 -6
- package/interfaces/adminpanelConfig.d.ts +10 -33
- package/interfaces/global.d.ts +10 -15
- package/interfaces/listQueryBuilder.d.ts +1 -1
- package/lib/Adminizer.d.ts +25 -2
- package/lib/Adminizer.js +124 -50
- package/lib/DataAccessor.d.ts +9 -5
- package/lib/DataAccessor.js +89 -42
- package/lib/access-rights/AccessRightsHandler.d.ts +17 -0
- package/lib/access-rights/AccessRightsHandler.js +63 -0
- package/lib/ai-assistant/AbstractAiModelService.d.ts +5 -8
- package/lib/ai-assistant/AbstractAiModelService.js +3 -14
- package/lib/ai-assistant/AiAssistantHandler.d.ts +2 -2
- package/lib/app-manager/AdminizerApp.d.ts +228 -0
- package/lib/app-manager/AdminizerApp.js +17 -0
- package/lib/app-manager/AppManager.d.ts +18 -0
- package/lib/app-manager/AppManager.js +537 -0
- package/lib/app-manager/AssetHandler.d.ts +17 -0
- package/lib/app-manager/AssetHandler.js +67 -0
- package/lib/app-manager/ConfigLayerHandler.d.ts +18 -0
- package/lib/app-manager/ConfigLayerHandler.js +119 -0
- package/lib/app-manager/ControllerHandler.d.ts +25 -0
- package/lib/app-manager/ControllerHandler.js +140 -0
- package/lib/catalog/AbstractCatalog.d.ts +28 -19
- package/lib/catalog/AbstractCatalog.js +41 -10
- package/lib/catalog/CatalogHandler.d.ts +13 -0
- package/lib/catalog/CatalogHandler.js +48 -2
- package/lib/catalog/CatalogTemplateComponentHandler.d.ts +23 -0
- package/lib/catalog/CatalogTemplateComponentHandler.js +59 -0
- package/lib/controls/Control.d.ts +17 -0
- package/lib/controls/Control.js +1 -0
- package/lib/controls/ControlsHandler.d.ts +5 -6
- package/lib/controls/ControlsHandler.js +0 -13
- package/lib/controls/codeEditor/MonacoEditor.d.ts +3 -4
- package/lib/controls/codeEditor/MonacoEditor.js +13 -8
- package/lib/controls/geojsoneditor/GeoEditor.d.ts +3 -4
- package/lib/controls/geojsoneditor/GeoEditor.js +14 -9
- package/lib/controls/jsoneditor/JsonEditor.d.ts +5 -6
- package/lib/controls/jsoneditor/JsonEditor.js +14 -13
- package/lib/controls/markdown/ToastUiEditor.d.ts +5 -6
- package/lib/controls/markdown/ToastUiEditor.js +14 -13
- package/lib/controls/table/Handsontable.d.ts +5 -6
- package/lib/controls/table/Handsontable.js +14 -13
- package/lib/controls/wysiwyg/CKeditor.d.ts +5 -6
- package/lib/controls/wysiwyg/CKeditor.js +14 -13
- package/lib/filters/ConditionValidator.d.ts +1 -1
- package/lib/filters/FilterService.d.ts +18 -18
- package/lib/filters/FilterService.js +11 -11
- package/lib/history-actions/AbstractHistoryAdapter.d.ts +14 -14
- package/lib/history-actions/AbstractHistoryAdapter.js +5 -6
- package/lib/history-actions/DefaultHistoryAdapter.d.ts +7 -7
- package/lib/history-actions/DefaultHistoryAdapter.js +2 -2
- package/lib/list-query-builder/ListQueryBuilder.d.ts +1 -1
- package/lib/media-manager/AbstractMediaManager.d.ts +14 -3
- package/lib/media-manager/AbstractMediaManager.js +16 -5
- package/lib/media-manager/MediaManagerHandler.d.ts +3 -0
- package/lib/media-manager/MediaManagerHandler.js +30 -5
- package/lib/media-manager/Thumb.js +7 -13
- package/lib/media-manager/helpers/MediaManagerHelper.d.ts +6 -4
- package/lib/media-manager/helpers/MediaManagerHelper.js +18 -18
- package/lib/model/AbstractModel.d.ts +9 -5
- package/lib/model/AbstractModel.js +9 -13
- package/lib/model/InternalModelAccessFactory.js +9 -10
- package/lib/model/ModelHandler.d.ts +45 -7
- package/lib/model/ModelHandler.js +168 -11
- package/lib/model/adapter/sequelize.d.ts +2 -4
- package/lib/model/adapter/sequelize.js +16 -193
- package/lib/model/adapter/typeorm.d.ts +2 -4
- package/lib/model/adapter/typeorm.js +2 -35
- package/lib/notifications/AbstractNotificationService.d.ts +9 -9
- package/lib/notifications/AbstractNotificationService.js +8 -8
- package/lib/notifications/GeneralNotificationService.js +1 -1
- package/lib/notifications/SystemNotificationService.js +1 -1
- package/lib/ui-i18n/uiTranslationKeys.d.ts +1 -1
- package/lib/ui-i18n/uiTranslationKeys.js +1 -0
- package/lib/widgets/abstractCustom.d.ts +7 -2
- package/lib/widgets/abstractCustom.js +6 -0
- package/lib/widgets/abstractInfo.d.ts +4 -1
- package/lib/widgets/abstractWidgetBase.d.ts +2 -0
- package/lib/widgets/abstractWidgetBase.js +2 -0
- package/lib/widgets/widgetHandler.d.ts +6 -2
- package/lib/widgets/widgetHandler.js +70 -19
- package/models/{FilterAP.d.ts → Filter.d.ts} +4 -70
- package/models/Filter.js +1 -0
- package/models/FilterColumn.d.ts +10 -0
- package/models/FilterColumn.js +1 -0
- package/models/Group.d.ts +8 -0
- package/models/Group.js +1 -0
- package/models/HistoryActions.d.ts +14 -0
- package/models/HistoryActions.js +1 -0
- package/models/MediaManagerAP.d.ts +2 -54
- package/models/MediaManagerAP.js +1 -51
- package/models/MediaManagerAssociationsAP.d.ts +1 -35
- package/models/MediaManagerAssociationsAP.js +1 -33
- package/models/MediaManagerMetaAP.d.ts +2 -30
- package/models/MediaManagerMetaAP.js +1 -27
- package/models/Notification.d.ts +13 -0
- package/models/Notification.js +1 -0
- package/models/User.d.ts +23 -0
- package/models/User.js +1 -0
- package/models/UserNotification.d.ts +7 -0
- package/models/UserNotification.js +1 -0
- package/package.json +25 -30
- package/services/FeedService.d.ts +5 -5
- package/services/FeedService.js +1 -1
- package/system/Router.js +2 -10
- package/system/bindAccessRights.js +1 -1
- package/system/bindAuthorization.js +2 -2
- package/system/bindControls.js +7 -6
- package/system/bindDashboardWidgets.js +3 -2
- package/system/bindDev.js +1 -1
- package/system/bindHistory.d.ts +1 -1
- package/system/bindHistory.js +1 -1
- package/system/bindInertia.js +0 -6
- package/system/bindMediaManager.js +4 -17
- package/system/bindNotifications.d.ts +1 -1
- package/system/bindNotifications.js +1 -1
- package/system/bindReqFunctions.d.ts +1 -0
- package/system/bindReqFunctions.js +20 -3
- package/system/buildInternalModelAccess.js +2 -15
- package/system/defaults.js +5 -10
- package/system/systemModelContracts.d.ts +22 -0
- package/system/systemModelContracts.js +155 -0
- package/system/validateSystemModels.d.ts +2 -0
- package/system/validateSystemModels.js +101 -0
- package/translations/ar.json +2 -1
- package/translations/cn.json +2 -1
- package/translations/de.json +2 -1
- package/translations/en.json +1 -0
- package/translations/es.json +2 -1
- package/translations/fr.json +2 -1
- package/translations/hi.json +2 -1
- package/translations/jp.json +2 -1
- package/translations/ko.json +2 -1
- package/translations/pt.json +2 -1
- package/translations/ru.json +2 -1
- package/translations/ua.json +2 -1
- package/translations/uz.json +2 -1
- package/translations/vi.json +2 -1
- package/ui/components/VanillaJSONEditor.d.ts +1 -1
- package/ui/components/handsontable.d.ts +1 -1
- package/ui/components/ui/avatar.d.ts +3 -3
- package/ui/components/ui/badge.d.ts +1 -1
- package/ui/components/ui/breadcrumb.d.ts +7 -7
- package/ui/components/ui/button.d.ts +1 -1
- package/ui/components/ui/calendar.d.ts +1 -1
- package/ui/components/ui/card.d.ts +7 -7
- package/ui/components/ui/checkbox.d.ts +1 -1
- package/ui/components/ui/collapsible.d.ts +3 -3
- package/ui/components/ui/command.d.ts +9 -9
- package/ui/components/ui/context-menu.d.ts +15 -15
- package/ui/components/ui/dialog-stack.d.ts +10 -10
- package/ui/components/ui/dialog.d.ts +10 -10
- package/ui/components/ui/dropdown-menu.d.ts +15 -15
- package/ui/components/ui/input.d.ts +1 -1
- package/ui/components/ui/label.d.ts +1 -1
- package/ui/components/ui/menubar.d.ts +16 -16
- package/ui/components/ui/pagination.d.ts +7 -7
- package/ui/components/ui/popover.d.ts +4 -4
- package/ui/components/ui/select.d.ts +10 -10
- package/ui/components/ui/separator.d.ts +1 -1
- package/ui/components/ui/sheet.d.ts +8 -8
- package/ui/components/ui/sidebar.d.ts +23 -23
- package/ui/components/ui/skeleton.d.ts +1 -1
- package/ui/components/ui/slider.d.ts +1 -1
- package/ui/components/ui/sonner.d.ts +1 -1
- package/ui/components/ui/switch.d.ts +1 -1
- package/ui/components/ui/table.d.ts +8 -8
- package/ui/components/ui/tabs.d.ts +4 -4
- package/ui/components/ui/textarea.d.ts +1 -1
- package/ui/components/ui/tooltip.d.ts +4 -4
- package/assets/RelationDialogStack-DI2bZxQX.js +0 -20
- package/assets/add-DCQ7ZW4B.js +0 -1
- package/assets/add-group-DCVPryBo.js +0 -1
- package/assets/add-group-form-DKRXC2n-.js +0 -1
- package/assets/add-user-B7OOiYxv.js +0 -1
- package/assets/add-user-form-UXAToWQd.js +0 -1
- package/assets/app-AKbNCggP.css +0 -1
- package/assets/app-layout-6EwNBvnR.js +0 -1
- package/assets/app-shell-D8wtkECO.js +0 -1
- package/assets/app-sidebar-DfGjL-2K.js +0 -1
- package/assets/app-sidebar-header-BZbIBQjq.js +0 -1
- package/assets/breadcrumbs-CODaqVkB.js +0 -1
- package/assets/catalog-DVvFGa2X.js +0 -6
- package/assets/dashboard-BadoiH_a.js +0 -3
- package/assets/date-picker-DSOkNiNo.js +0 -1
- package/assets/del-modal-Cd4M7af8.js +0 -1
- package/assets/dynamic-controls-BsrJhPDY.js +0 -1
- package/assets/geo-json-CzR5JBXL.js +0 -1
- package/assets/handsontable-BI98OF5R.js +0 -336
- package/assets/history-D1iLA6rs.js +0 -1
- package/assets/home-DbWj-W_k.js +0 -2
- package/assets/icon-C2JNaLxH.js +0 -1
- package/assets/init-user-D2HSyXup.js +0 -1
- package/assets/input-error-CH2caTtO.js +0 -1
- package/assets/jsoneditor-DVNQmA6G.js +0 -3869
- package/assets/list-CVoljVUw.js +0 -4
- package/assets/login-DFSLEO17.js +0 -1
- package/assets/material-icon-Bx9pGQiQ.js +0 -1
- package/assets/module-DJsC37CM.js +0 -1
- package/assets/monaco-Bl4zdWCn.js +0 -11
- package/assets/nav-footer-BiSQkPt4.js +0 -1
- package/assets/nav-main-rTH0PfDw.js +0 -1
- package/assets/nav-user-Bj6cWs0a.js +0 -1
- package/assets/notification-DKrNfaAB.js +0 -20
- package/assets/pagination-render-AKJvTIRA.js +0 -1
- package/assets/register-BTP4uxsK.js +0 -1
- package/assets/theme-switcher-Dm8EOGzx.js +0 -1
- package/assets/toast-editor-DOg_gvSp.js +0 -668
- package/assets/user-filters-list-C9R9J6Om.js +0 -1
- package/assets/user-info-BgSbT02v.js +0 -1
- package/assets/user-menu-content-TQTXHIv6.js +0 -1
- package/assets/vanilla-picker-B3LgXoKV.js +0 -2
- package/assets/vendor-l0sNRNKZ.js +0 -1
- package/assets/welcome-BwDlAOGh.js +0 -1
- package/controllers/navigation/edit.d.ts +0 -1
- package/controllers/navigation/edit.js +0 -8
- package/lib/ai-assistant/DummyAiModelService.d.ts +0 -8
- package/lib/ai-assistant/DummyAiModelService.js +0 -14
- package/lib/ai-assistant/OpenAiModelService.d.ts +0 -24
- package/lib/ai-assistant/OpenAiModelService.js +0 -184
- package/lib/catalog/Navigation.d.ts +0 -49
- package/lib/catalog/Navigation.js +0 -492
- package/lib/controls/AbstractControls.d.ts +0 -30
- package/lib/controls/AbstractControls.js +0 -14
- package/lib/media-manager/DefaultMediaManager.d.ts +0 -20
- package/lib/media-manager/DefaultMediaManager.js +0 -127
- package/lib/media-manager/Items.d.ts +0 -50
- package/lib/media-manager/Items.js +0 -296
- package/models/FilterAP.js +0 -68
- package/models/FilterColumnAP.d.ts +0 -32
- package/models/FilterColumnAP.js +0 -21
- package/models/GroupAP.d.ts +0 -31
- package/models/GroupAP.js +0 -22
- package/models/HistoryActionsAP.d.ts +0 -56
- package/models/HistoryActionsAP.js +0 -42
- package/models/NavigationAP.d.ts +0 -22
- package/models/NavigationAP.js +0 -16
- package/models/NotificationAP.d.ts +0 -44
- package/models/NotificationAP.js +0 -30
- package/models/UserAP.d.ts +0 -81
- package/models/UserAP.js +0 -57
- package/models/UserNotificationAP.d.ts +0 -26
- package/models/UserNotificationAP.js +0 -18
- package/system/bindAiAssistant.d.ts +0 -2
- package/system/bindAiAssistant.js +0 -30
- package/system/bindModels.d.ts +0 -2
- package/system/bindModels.js +0 -48
- package/system/bindNavigation.d.ts +0 -2
- package/system/bindNavigation.js +0 -38
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HistoryActions } from "../../models/HistoryActions";
|
|
2
|
+
import { User } from "../../models/User";
|
|
3
3
|
import { Adminizer } from "../Adminizer";
|
|
4
4
|
import { Fields } from "../../helpers/fieldsHelper";
|
|
5
5
|
import { ActionType } from "../../interfaces/adminpanelConfig";
|
|
@@ -49,7 +49,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
49
49
|
* @param modelName - Name of the model.
|
|
50
50
|
* @returns Promise resolving to an array of history records.
|
|
51
51
|
*/
|
|
52
|
-
abstract getAllModelHistory(modelId: string | number, modelName: string, user:
|
|
52
|
+
abstract getAllModelHistory(modelId: string | number, modelName: string, user: User): Promise<HistoryActions[]>;
|
|
53
53
|
/**
|
|
54
54
|
* Retrieves all accessible history records for a user.
|
|
55
55
|
*
|
|
@@ -57,8 +57,8 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
57
57
|
* @param modelName - Optional model name to filter results.
|
|
58
58
|
* @returns Promise resolving to a record of history data.
|
|
59
59
|
*/
|
|
60
|
-
abstract getAllHistory(user:
|
|
61
|
-
data:
|
|
60
|
+
abstract getAllHistory(user: User, forUserName: string, modelName: string, limit?: number, offset?: number, from?: Date, to?: Date): Promise<{
|
|
61
|
+
data: HistoryActions[];
|
|
62
62
|
}>;
|
|
63
63
|
/**
|
|
64
64
|
* Saves a new history record.
|
|
@@ -66,7 +66,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
66
66
|
* @param data - History data excluding auto-generated fields (`id`, `createdAt`, `updatedAt`, `isCurrent`).
|
|
67
67
|
* @returns Promise resolving when the record is saved.
|
|
68
68
|
*/
|
|
69
|
-
abstract setHistory(data: Omit<
|
|
69
|
+
abstract setHistory(data: Omit<HistoryActions, "id" | "createdAt" | "updatedAt" | "isCurrent" | "user"> & {
|
|
70
70
|
user: string | number;
|
|
71
71
|
}): Promise<void>;
|
|
72
72
|
/**
|
|
@@ -77,7 +77,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
77
77
|
* @param user - User requesting the data (used for access control).
|
|
78
78
|
* @returns Promise resolving to formatted history data.
|
|
79
79
|
*/
|
|
80
|
-
abstract getModelFieldsHistory(historyId: number, user:
|
|
80
|
+
abstract getModelFieldsHistory(historyId: number, user: User): Promise<Record<string, any>>;
|
|
81
81
|
/**
|
|
82
82
|
* Gets a list of models for which the user has update permissions.
|
|
83
83
|
* Excludes internal models defined in `excludedModels`.
|
|
@@ -85,7 +85,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
85
85
|
* @param user - User whose permissions are checked.
|
|
86
86
|
* @returns Array of model names (in lowercase) the user can access.
|
|
87
87
|
*/
|
|
88
|
-
getModels(user:
|
|
88
|
+
getModels(user: User): string[];
|
|
89
89
|
/**
|
|
90
90
|
* Filters history records based on user access rights.
|
|
91
91
|
* If the user lacks "users-history" permission, only their own records are returned.
|
|
@@ -95,7 +95,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
95
95
|
* @returns A promise resolving to filtered history records accessible to the user.
|
|
96
96
|
* @protected
|
|
97
97
|
*/
|
|
98
|
-
protected _getAllModelHistory(history:
|
|
98
|
+
protected _getAllModelHistory(history: HistoryActions[], user: User): Promise<HistoryActions[]>;
|
|
99
99
|
/**
|
|
100
100
|
* Filters and enhances history records with display names based on model configurations.
|
|
101
101
|
* Ensures only models the user can access are included.
|
|
@@ -105,7 +105,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
105
105
|
* @returns A promise resolving to enhanced history records with `displayName` property.
|
|
106
106
|
* @protected
|
|
107
107
|
*/
|
|
108
|
-
protected _getAllHistory(history:
|
|
108
|
+
protected _getAllHistory(history: HistoryActions[], user: User): Promise<(HistoryActions & {
|
|
109
109
|
displayName: string;
|
|
110
110
|
})[]>;
|
|
111
111
|
/**
|
|
@@ -117,7 +117,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
117
117
|
* @returns Promise resolving to formatted data object.
|
|
118
118
|
* @protected
|
|
119
119
|
*/
|
|
120
|
-
protected _getModelFieldsHistory(history:
|
|
120
|
+
protected _getModelFieldsHistory(history: HistoryActions, user: User): Promise<Record<string, any>>;
|
|
121
121
|
/**
|
|
122
122
|
* Enhances history records with a human-readable display name based on model configuration.
|
|
123
123
|
* Falls back to model ID if display name cannot be determined.
|
|
@@ -126,7 +126,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
126
126
|
* @returns A promise resolving to an array of records with `displayName` property.
|
|
127
127
|
* @protected
|
|
128
128
|
*/
|
|
129
|
-
protected setModelsDisplayName(history:
|
|
129
|
+
protected setModelsDisplayName(history: HistoryActions[]): Promise<(HistoryActions & {
|
|
130
130
|
displayName: string;
|
|
131
131
|
})[]>;
|
|
132
132
|
/**
|
|
@@ -147,7 +147,7 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
147
147
|
* @returns ModelResource object with name, URI, model instance, and config.
|
|
148
148
|
* @protected
|
|
149
149
|
*/
|
|
150
|
-
protected findModelResource(history:
|
|
150
|
+
protected findModelResource(history: HistoryActions): ModelResource;
|
|
151
151
|
/**
|
|
152
152
|
* Loads associated records for association-type fields.
|
|
153
153
|
* Populates `records` array in field config for widget rendering.
|
|
@@ -158,5 +158,5 @@ export declare abstract class AbstractHistoryAdapter {
|
|
|
158
158
|
* @returns Promise resolving to updated fields with loaded associations.
|
|
159
159
|
* @protected
|
|
160
160
|
*/
|
|
161
|
-
protected loadAssociations(fields: Fields, user:
|
|
161
|
+
protected loadAssociations(fields: Fields, user: User, action?: ActionType): Promise<Fields>;
|
|
162
162
|
}
|
|
@@ -8,15 +8,14 @@ import { isMediaManagerFieldConfig, normalizeMediaManagerWidgetData } from "../m
|
|
|
8
8
|
* These models are internal or administrative and should not appear in user-accessible history.
|
|
9
9
|
*/
|
|
10
10
|
const EXCLUDED_MODELS = new Set([
|
|
11
|
-
'
|
|
11
|
+
'HistoryActions',
|
|
12
12
|
'MediaManagerAP',
|
|
13
13
|
'MediaManagerAssociationsAP',
|
|
14
14
|
'MediaManagerMetaAP',
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'GroupAP'
|
|
15
|
+
'Notification',
|
|
16
|
+
'UserNotification',
|
|
17
|
+
'User',
|
|
18
|
+
'Group'
|
|
20
19
|
]);
|
|
21
20
|
/**
|
|
22
21
|
* Abstract base class for handling history operations in the AdminPanel.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HistoryActions } from "../../models/HistoryActions";
|
|
2
|
+
import { User } from "../../models/User";
|
|
3
3
|
import { Adminizer } from "../Adminizer";
|
|
4
4
|
import { AbstractHistoryAdapter } from "./AbstractHistoryAdapter";
|
|
5
5
|
export declare class DefaultHistoryAdapter extends AbstractHistoryAdapter {
|
|
@@ -8,12 +8,12 @@ export declare class DefaultHistoryAdapter extends AbstractHistoryAdapter {
|
|
|
8
8
|
constructor(adminizer: Adminizer);
|
|
9
9
|
private historyModel;
|
|
10
10
|
private userModel;
|
|
11
|
-
getAllHistory(user:
|
|
12
|
-
data:
|
|
11
|
+
getAllHistory(user: User, forUserName: string, modelName: string, limit?: number, skip?: number, from?: Date, to?: Date): Promise<{
|
|
12
|
+
data: HistoryActions[];
|
|
13
13
|
}>;
|
|
14
|
-
getAllModelHistory(modelId: string | number, modelName: string, user:
|
|
15
|
-
getModelFieldsHistory(historyId: number, user:
|
|
16
|
-
setHistory(data: Omit<
|
|
14
|
+
getAllModelHistory(modelId: string | number, modelName: string, user: User): Promise<HistoryActions[]>;
|
|
15
|
+
getModelFieldsHistory(historyId: number, user: User): Promise<Record<string, any>>;
|
|
16
|
+
setHistory(data: Omit<HistoryActions, "createdAt" | "updatedAt" | "user"> & {
|
|
17
17
|
user: string | number;
|
|
18
18
|
}): Promise<void>;
|
|
19
19
|
}
|
|
@@ -2,7 +2,7 @@ import { Adminizer } from "../Adminizer.js";
|
|
|
2
2
|
import { AbstractHistoryAdapter } from "./AbstractHistoryAdapter.js";
|
|
3
3
|
export class DefaultHistoryAdapter extends AbstractHistoryAdapter {
|
|
4
4
|
id = 'default';
|
|
5
|
-
model = '
|
|
5
|
+
model = 'HistoryActions';
|
|
6
6
|
constructor(adminizer) {
|
|
7
7
|
super(adminizer);
|
|
8
8
|
}
|
|
@@ -10,7 +10,7 @@ export class DefaultHistoryAdapter extends AbstractHistoryAdapter {
|
|
|
10
10
|
return this.adminizer.modelHandler.internal("history").get(this.model);
|
|
11
11
|
}
|
|
12
12
|
userModel() {
|
|
13
|
-
return this.adminizer.modelHandler.internal("history").get("
|
|
13
|
+
return this.adminizer.modelHandler.internal("history").get("User");
|
|
14
14
|
}
|
|
15
15
|
async getAllHistory(user, forUserName, modelName, limit = 15, skip = 0, from, to) {
|
|
16
16
|
let userId = null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fields } from '../../helpers/fieldsHelper';
|
|
2
2
|
import { AbstractModel } from '../model/AbstractModel';
|
|
3
3
|
import { DataAccessor } from '../DataAccessor';
|
|
4
|
-
import { FilterOperator } from '../../models/
|
|
4
|
+
import { FilterOperator } from '../../models/Filter';
|
|
5
5
|
import { CustomFilterHandler } from '../filters/CustomFilterHandler';
|
|
6
6
|
import { ListQueryBuilderParams, ListQueryBuilderResult } from '../../interfaces/listQueryBuilder';
|
|
7
7
|
import { CriteriaWhere } from '../../interfaces/queryCriteria';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { MediaManagerMetaAP } from "../../models/MediaManagerMetaAP";
|
|
1
2
|
import { Adminizer } from "../Adminizer";
|
|
2
|
-
import { MediaManagerMetaAP } from "../../models/MediaManagerMetaAP";
|
|
3
3
|
export interface MediaManagerItem {
|
|
4
4
|
id?: string;
|
|
5
5
|
parent: string | null;
|
|
@@ -156,10 +156,21 @@ export declare abstract class AbstractMediaManager {
|
|
|
156
156
|
abstract id: string;
|
|
157
157
|
readonly itemTypes: File<MediaManagerItem>[];
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
159
|
+
* Registers the media manager access right through the legacy Adminizer API.
|
|
160
|
+
*
|
|
161
|
+
* @deprecated Starting with Adminizer v6, register access rights through
|
|
162
|
+
* `ctx.accessRight(...)` in the app's `setup` method.
|
|
163
|
+
* @param adminizer Adminizer instance used for legacy access-right registration.
|
|
160
164
|
*/
|
|
161
|
-
protected constructor(adminizer: Adminizer);
|
|
162
165
|
private _bindAccessRight;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated The `adminizer` parameter is deprecated and will be removed in
|
|
168
|
+
* Adminizer v6. Register the media manager through `AppManager` using
|
|
169
|
+
* `ctx.mediaManager(...)`, and register its access right using
|
|
170
|
+
* `ctx.accessRight(...)`.
|
|
171
|
+
* @param adminizer Adminizer instance used by the legacy registration flow.
|
|
172
|
+
*/
|
|
173
|
+
protected constructor(adminizer: Adminizer);
|
|
163
174
|
/**
|
|
164
175
|
* Upload an item.
|
|
165
176
|
* @param file
|
|
@@ -40,21 +40,32 @@ export class AbstractMediaManager {
|
|
|
40
40
|
allowSearch;
|
|
41
41
|
itemTypes = [];
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Registers the media manager access right through the legacy Adminizer API.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated Starting with Adminizer v6, register access rights through
|
|
46
|
+
* `ctx.accessRight(...)` in the app's `setup` method.
|
|
47
|
+
* @param adminizer Adminizer instance used for legacy access-right registration.
|
|
44
48
|
*/
|
|
45
|
-
constructor(adminizer) {
|
|
46
|
-
this._bindAccessRight(adminizer);
|
|
47
|
-
}
|
|
48
49
|
_bindAccessRight(adminizer) {
|
|
49
50
|
setTimeout(() => {
|
|
50
51
|
adminizer.accessRightsHelper.registerToken({
|
|
51
52
|
id: `mediaManager-${this.id}`,
|
|
52
53
|
name: this.id,
|
|
53
54
|
description: `Access to edit media-manager for ${this.id}`,
|
|
54
|
-
department:
|
|
55
|
+
department: "media-manager",
|
|
55
56
|
});
|
|
56
57
|
}, 100);
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated The `adminizer` parameter is deprecated and will be removed in
|
|
61
|
+
* Adminizer v6. Register the media manager through `AppManager` using
|
|
62
|
+
* `ctx.mediaManager(...)`, and register its access right using
|
|
63
|
+
* `ctx.accessRight(...)`.
|
|
64
|
+
* @param adminizer Adminizer instance used by the legacy registration flow.
|
|
65
|
+
*/
|
|
66
|
+
constructor(adminizer) {
|
|
67
|
+
this._bindAccessRight(adminizer);
|
|
68
|
+
}
|
|
58
69
|
/**
|
|
59
70
|
* Upload an item.
|
|
60
71
|
* @param file
|
|
@@ -2,5 +2,8 @@ import { AbstractMediaManager } from "./AbstractMediaManager";
|
|
|
2
2
|
export declare class MediaManagerHandler {
|
|
3
3
|
private managers;
|
|
4
4
|
add(manager: AbstractMediaManager): void;
|
|
5
|
+
register(appName: string | undefined, manager: AbstractMediaManager): string;
|
|
6
|
+
unregister(resourceId: string): void;
|
|
5
7
|
get(id: string): AbstractMediaManager;
|
|
8
|
+
getByApp(appName: string): AbstractMediaManager[];
|
|
6
9
|
}
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { Adminizer } from "../Adminizer.js";
|
|
2
2
|
export class MediaManagerHandler {
|
|
3
|
-
managers =
|
|
3
|
+
managers = new Map();
|
|
4
4
|
add(manager) {
|
|
5
|
-
this.
|
|
5
|
+
this.register(undefined, manager);
|
|
6
|
+
}
|
|
7
|
+
register(appName, manager) {
|
|
8
|
+
if (this.managers.has(manager.id)) {
|
|
9
|
+
throw new Error(`MediaManager with id "${manager.id}" is already registered`);
|
|
10
|
+
}
|
|
11
|
+
const resourceId = appName ? `${appName}:${manager.id}` : manager.id;
|
|
12
|
+
this.managers.set(manager.id, {
|
|
13
|
+
resourceId,
|
|
14
|
+
appName,
|
|
15
|
+
manager,
|
|
16
|
+
});
|
|
17
|
+
return resourceId;
|
|
18
|
+
}
|
|
19
|
+
unregister(resourceId) {
|
|
20
|
+
for (const [managerId, record] of this.managers) {
|
|
21
|
+
if (record.resourceId === resourceId) {
|
|
22
|
+
this.managers.delete(managerId);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
6
26
|
}
|
|
7
27
|
get(id) {
|
|
8
|
-
let instance = this.managers.
|
|
28
|
+
let instance = this.managers.get(id)?.manager;
|
|
9
29
|
/**
|
|
10
30
|
* ✨ We magically get one
|
|
11
31
|
*/
|
|
12
|
-
if (!instance && (id === 'default' || id === undefined) && this.managers.
|
|
13
|
-
instance = this.managers
|
|
32
|
+
if (!instance && (id === 'default' || id === undefined) && this.managers.size === 1) {
|
|
33
|
+
instance = this.managers.values().next().value?.manager;
|
|
14
34
|
}
|
|
15
35
|
if (!instance) {
|
|
16
36
|
Adminizer.log.debug(`MediaManager with id ${id} not found`);
|
|
@@ -18,4 +38,9 @@ export class MediaManagerHandler {
|
|
|
18
38
|
// Adminizer.log.debug(`ins`, instance) // DEBUG: removed to reduce console noise
|
|
19
39
|
return instance;
|
|
20
40
|
}
|
|
41
|
+
getByApp(appName) {
|
|
42
|
+
return Array.from(this.managers.values())
|
|
43
|
+
.filter((record) => record.appName === appName)
|
|
44
|
+
.map((record) => record.manager);
|
|
45
|
+
}
|
|
21
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sharp from "sharp";
|
|
2
|
-
import { promises as fs } from
|
|
3
|
-
import path from
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
4
|
export class MediaManagerThumb {
|
|
5
5
|
static async getThumb(id, managerId, adminizer) {
|
|
6
6
|
const fileExists = async (filePath) => {
|
|
@@ -14,28 +14,22 @@ export class MediaManagerThumb {
|
|
|
14
14
|
};
|
|
15
15
|
const manager = adminizer.mediaManagerHandler.get(managerId);
|
|
16
16
|
const filePath = await manager.getOrigin(id);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
path.normalize(filePath) : // If the path is already absolute, normalize it
|
|
22
|
-
path.join(process.cwd(), filePath); // If relative, add base
|
|
23
|
-
// Path for thumbnail
|
|
24
|
-
const baseThumbPath = path.join(process.cwd(), '.tmp', 'thumbs');
|
|
17
|
+
const sourcePath = path.isAbsolute(filePath)
|
|
18
|
+
? path.normalize(filePath)
|
|
19
|
+
: path.join(process.cwd(), filePath);
|
|
20
|
+
const baseThumbPath = path.join(process.cwd(), ".tmp", "thumbs");
|
|
25
21
|
await fs.mkdir(baseThumbPath, { recursive: true });
|
|
26
22
|
const thumbPath = path.join(baseThumbPath, `${id}_thumb.webp`);
|
|
27
23
|
if (await fileExists(thumbPath)) {
|
|
28
24
|
return await fs.readFile(thumbPath);
|
|
29
25
|
}
|
|
30
|
-
// Checking the existence of the file
|
|
31
26
|
if (!await fileExists(sourcePath)) {
|
|
32
27
|
throw new Error(`Source file not found: ${sourcePath}\n` +
|
|
33
28
|
`Check if file exists at: ${sourcePath}\n` +
|
|
34
29
|
`Original path from manager: ${filePath}`);
|
|
35
30
|
}
|
|
36
|
-
// Create a thumbnail
|
|
37
31
|
await sharp(sourcePath)
|
|
38
|
-
.resize({ width: 150, height: 150, fit:
|
|
32
|
+
.resize({ width: 150, height: 150, fit: "cover" })
|
|
39
33
|
.toFile(thumbPath);
|
|
40
34
|
return await fs.readFile(thumbPath);
|
|
41
35
|
}
|
|
@@ -2,6 +2,7 @@ import { Fields } from "../../../helpers/fieldsHelper";
|
|
|
2
2
|
import { MediaManagerWidgetData, MediaManagerItem, MediaManagerWidgetItem, MediaManagerWidgetJSON } from "../AbstractMediaManager";
|
|
3
3
|
import { BaseFieldConfig } from "../../../interfaces/adminpanelConfig";
|
|
4
4
|
import { Adminizer } from "../../Adminizer";
|
|
5
|
+
import type { AppRuntime } from "../../app-manager/AdminizerApp";
|
|
5
6
|
type PostParams = Record<string, string | number | boolean | object | string[] | number[] | null>;
|
|
6
7
|
export declare function isMediaManagerFieldConfig(fieldConfig: BaseFieldConfig): boolean;
|
|
7
8
|
export declare function normalizeMediaManagerWidgetData(value: PostParams[string] | undefined, prop: string): MediaManagerWidgetData[];
|
|
@@ -41,11 +42,12 @@ export declare function getRelationsMediaManager(adminizer: Adminizer, data: Med
|
|
|
41
42
|
export declare function deleteRelationsMediaManager(adminizer: Adminizer, model: string, record: {
|
|
42
43
|
[p: string]: string | MediaManagerWidgetItem[];
|
|
43
44
|
}[]): Promise<void>;
|
|
45
|
+
type MediaManagerModelHost = Adminizer | Pick<AppRuntime, "models">;
|
|
44
46
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
47
|
+
* Reload variants through the model adapter so their associations are populated.
|
|
48
|
+
*
|
|
49
|
+
* Supports both the legacy Adminizer path and app-scoped model access.
|
|
48
50
|
*/
|
|
49
|
-
export declare function populateVariants(
|
|
51
|
+
export declare function populateVariants(host: MediaManagerModelHost, variants: MediaManagerItem[], model: string): Promise<MediaManagerItem[]>;
|
|
50
52
|
export declare function getAssociationFieldName(model: any, associationName: string): string;
|
|
51
53
|
export {};
|
|
@@ -80,7 +80,7 @@ export async function updateCurrentHistoryMediaManagerData(adminizer, fields, re
|
|
|
80
80
|
const mediaData = collectMediaManagerHistoryData(fields, reqData);
|
|
81
81
|
if (!Object.keys(mediaData).length)
|
|
82
82
|
return;
|
|
83
|
-
const historyModel = adminizer.modelHandler.internal("history").get("
|
|
83
|
+
const historyModel = adminizer.modelHandler.internal("history").get("HistoryActions");
|
|
84
84
|
const currentHistory = await historyModel.findOne({
|
|
85
85
|
where: {
|
|
86
86
|
modelId: String(recordId),
|
|
@@ -122,33 +122,33 @@ export async function deleteRelationsMediaManager(adminizer, model, record) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
125
|
+
* Reload variants through the model adapter so their associations are populated.
|
|
126
|
+
*
|
|
127
|
+
* Supports both the legacy Adminizer path and app-scoped model access.
|
|
128
128
|
*/
|
|
129
|
-
export async function populateVariants(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
export async function populateVariants(host, variants, model) {
|
|
130
|
+
const mediaModel = "models" in host
|
|
131
|
+
? host.models.get(model)
|
|
132
|
+
: host.modelHandler.internal("media-manager").get(model);
|
|
133
|
+
const items = [];
|
|
134
|
+
for (const variant of variants ?? []) {
|
|
135
|
+
const populated = await mediaModel.findOne({ where: { id: variant.id } });
|
|
136
|
+
if (populated) {
|
|
137
|
+
items.push(populated);
|
|
138
|
+
}
|
|
135
139
|
}
|
|
136
140
|
return items;
|
|
137
141
|
}
|
|
138
142
|
export function getAssociationFieldName(model, associationName) {
|
|
139
143
|
const attributes = model.attributes || {};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (attributes.file?.type === 'association' && attributes.file.via) {
|
|
144
|
-
return attributes.file.via; // Returns 'fileId'
|
|
144
|
+
if (associationName === "file") {
|
|
145
|
+
if (attributes.file?.type === "association" && attributes.file.via) {
|
|
146
|
+
return attributes.file.via;
|
|
145
147
|
}
|
|
146
|
-
// Or just check for the presence of fileId
|
|
147
148
|
if (attributes.fileId) {
|
|
148
|
-
return
|
|
149
|
+
return "fileId";
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
|
-
// General case
|
|
152
152
|
const idField = `${associationName}Id`;
|
|
153
153
|
return attributes[idField] ? idField : associationName;
|
|
154
154
|
}
|
|
@@ -81,14 +81,18 @@ export declare abstract class AbstractAdapter {
|
|
|
81
81
|
abstract Model: any;
|
|
82
82
|
readonly orm: any;
|
|
83
83
|
readonly ormType: string;
|
|
84
|
-
|
|
84
|
+
readonly systemModels: SystemModelBindings;
|
|
85
|
+
protected constructor(type: string, orm: any, options?: AbstractAdapterOptions);
|
|
85
86
|
abstract get models(): Record<string, any>;
|
|
86
87
|
/** This function should return constant type from any adapter (for adminizer proper work) */
|
|
87
88
|
abstract getAttributes(modelName: string): ModelAttributes | undefined;
|
|
88
89
|
/** Return full model object */
|
|
89
90
|
abstract getModel(modelName: string): any;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
}
|
|
92
|
+
export type SystemModelBindingValue = string | {
|
|
93
|
+
model: string;
|
|
94
|
+
};
|
|
95
|
+
export type SystemModelBindings = Record<string, SystemModelBindingValue>;
|
|
96
|
+
export interface AbstractAdapterOptions {
|
|
97
|
+
systemModels?: SystemModelBindings;
|
|
94
98
|
}
|
|
@@ -128,12 +128,12 @@ export class AbstractModel {
|
|
|
128
128
|
async findOne(criteria, dataAccessor) {
|
|
129
129
|
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
130
130
|
let record = await this._findOne(criteria);
|
|
131
|
-
return record ? dataAccessor.process(record) : null;
|
|
131
|
+
return record ? dataAccessor.process(record, criteria) : null;
|
|
132
132
|
}
|
|
133
133
|
async find(criteria, dataAccessor) {
|
|
134
134
|
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
135
135
|
let records = await this._find(criteria);
|
|
136
|
-
return records.map(record => dataAccessor.process(record));
|
|
136
|
+
return records.map(record => dataAccessor.process(record, criteria));
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Find with raw SQL where clause (Sequelize.literal support)
|
|
@@ -165,7 +165,7 @@ export class AbstractModel {
|
|
|
165
165
|
}
|
|
166
166
|
// Log update event
|
|
167
167
|
await this.logSystemEvent(dataAccessor, 'Updated', dataAccessor.user.id, oldRecord, record);
|
|
168
|
-
return dataAccessor.process(record);
|
|
168
|
+
return dataAccessor.process(record, criteria);
|
|
169
169
|
}
|
|
170
170
|
async update(criteria, data, dataAccessor) {
|
|
171
171
|
let _data = dataAccessor.process(data);
|
|
@@ -181,7 +181,7 @@ export class AbstractModel {
|
|
|
181
181
|
await this.logSystemEvent(dataAccessor, 'Updated', dataAccessor.user.id, oldRecord, record);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
return records.map(record => dataAccessor.process(record));
|
|
184
|
+
return records.map(record => dataAccessor.process(record, criteria));
|
|
185
185
|
}
|
|
186
186
|
async destroyOne(criteria, dataAccessor) {
|
|
187
187
|
// Get the record first for diff
|
|
@@ -196,7 +196,7 @@ export class AbstractModel {
|
|
|
196
196
|
}
|
|
197
197
|
// Log delete event
|
|
198
198
|
await this.logSystemEvent(dataAccessor, 'Deleted', dataAccessor.user.id, oldRecord, {});
|
|
199
|
-
return dataAccessor.process(record);
|
|
199
|
+
return dataAccessor.process(record, criteria);
|
|
200
200
|
}
|
|
201
201
|
async destroy(criteria, dataAccessor) {
|
|
202
202
|
// Get records first for diff
|
|
@@ -211,7 +211,7 @@ export class AbstractModel {
|
|
|
211
211
|
await this.logSystemEvent(dataAccessor, 'Deleted', dataAccessor.user.id, oldRecord, {});
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
return records.map(record => dataAccessor.process(record));
|
|
214
|
+
return records.map(record => dataAccessor.process(record, criteria));
|
|
215
215
|
}
|
|
216
216
|
async count(criteria = {}, dataAccessor) {
|
|
217
217
|
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
@@ -221,14 +221,10 @@ export class AbstractModel {
|
|
|
221
221
|
export class AbstractAdapter {
|
|
222
222
|
orm;
|
|
223
223
|
ormType;
|
|
224
|
-
|
|
224
|
+
systemModels;
|
|
225
|
+
constructor(type, orm, options = {}) {
|
|
225
226
|
this.ormType = type;
|
|
226
227
|
this.orm = orm;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* This method must ensure system models registration and throw an error in case of errors. We force all adapters to realize it
|
|
230
|
-
*/
|
|
231
|
-
static registerSystemModels(orm) {
|
|
232
|
-
throw new Error("Function 'registerSystemModels' must be implemented by subclass");
|
|
228
|
+
this.systemModels = options.systemModels ?? {};
|
|
233
229
|
}
|
|
234
230
|
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { createInternalModelRepository } from "./internalModelRepository.js";
|
|
2
2
|
export const DEFAULT_INTERNAL_MODEL_ACCESS = {
|
|
3
|
-
auth: ["
|
|
4
|
-
"access-rights": ["
|
|
5
|
-
users: ["
|
|
6
|
-
filters: ["
|
|
3
|
+
auth: ["User", "Group"],
|
|
4
|
+
"access-rights": ["User", "Group"],
|
|
5
|
+
users: ["User", "Group"],
|
|
6
|
+
filters: ["Filter", "FilterColumn", "User", "Group"],
|
|
7
7
|
"media-manager": [
|
|
8
8
|
"MediaManagerAP",
|
|
9
9
|
"MediaManagerMetaAP",
|
|
10
10
|
"MediaManagerAssociationsAP",
|
|
11
|
-
"
|
|
11
|
+
"HistoryActions"
|
|
12
12
|
],
|
|
13
|
-
history: ["
|
|
13
|
+
history: ["HistoryActions", "User"],
|
|
14
14
|
"data-accessor": [],
|
|
15
|
-
notifications: ["
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
widgets: ["UserAP", "FilterAP"]
|
|
15
|
+
notifications: ["Notification", "UserNotification", "User"],
|
|
16
|
+
feed: ["Filter", "User"],
|
|
17
|
+
widgets: ["User", "Filter"]
|
|
19
18
|
};
|
|
20
19
|
function normalizeName(name) {
|
|
21
20
|
return name.toLowerCase();
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { AbstractModel } from "./AbstractModel";
|
|
2
|
-
import { InternalModelAccessMap } from "../../interfaces/internalModelAccess";
|
|
2
|
+
import { InternalModelAccessMap, InternalModelRepository } from "../../interfaces/internalModelAccess";
|
|
3
3
|
import { InternalModelScope } from "./InternalModelAccessFactory";
|
|
4
|
+
export interface AppModelAccessRecord {
|
|
5
|
+
id: string;
|
|
6
|
+
appName: string;
|
|
7
|
+
models: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface ModelRecord {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
model: AbstractModel<any>;
|
|
13
|
+
ownerApp?: string;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class AppModelAccess {
|
|
17
|
+
private readonly getModel;
|
|
18
|
+
private readonly appName;
|
|
19
|
+
private readonly allowedModels;
|
|
20
|
+
constructor(getModel: (modelName: string) => AbstractModel<any> | undefined, appName: string, allowedModels: () => Set<string>);
|
|
21
|
+
get<T = any>(modelName: string): InternalModelRepository<T>;
|
|
22
|
+
has(modelName: string): boolean;
|
|
23
|
+
}
|
|
4
24
|
/**
|
|
5
25
|
* Central registry (service locator) for all AbstractModel instances in the application.
|
|
6
26
|
* A single instance is created in Adminizer and shared across the entire app via `req.adminizer.modelHandler`.
|
|
@@ -8,20 +28,32 @@ import { InternalModelScope } from "./InternalModelAccessFactory";
|
|
|
8
28
|
* Models are registered at startup via `bindModels`, then looked up by name from controllers,
|
|
9
29
|
* services, helpers, and system utilities — without importing each model directly.
|
|
10
30
|
*
|
|
11
|
-
* Lookup is case-insensitive
|
|
31
|
+
* Lookup is case-insensitive and can resolve aliases registered at startup via system model bindings.
|
|
12
32
|
*/
|
|
13
33
|
export declare class ModelHandler {
|
|
14
34
|
private models;
|
|
35
|
+
private modelAliases;
|
|
15
36
|
private internalAccess?;
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
private appAccessRecords;
|
|
38
|
+
add<T>(modelName: string, modelInstance: AbstractModel<T>, aliases?: string[]): void;
|
|
39
|
+
register<T>(appName: string, modelName: string, modelInstance: AbstractModel<T>): string;
|
|
40
|
+
unregister(id: string): void;
|
|
41
|
+
disable(id: string): void;
|
|
42
|
+
enable(id: string): void;
|
|
43
|
+
getByApp(appName: string): ModelRecord[];
|
|
44
|
+
registerAppAccess(appName: string, id: string, models: string[]): string;
|
|
45
|
+
unregisterAppAccess(id: string): void;
|
|
46
|
+
getAppAccessRecords(appName: string): AppModelAccessRecord[];
|
|
47
|
+
createAppAccess(appName: string): AppModelAccess;
|
|
48
|
+
/** Improved model getter with case-insensitive lookup and configured alias support. */
|
|
18
49
|
get model(): {
|
|
19
50
|
get: (modelName: string) => AbstractModel<any>;
|
|
20
51
|
has: (modelName: string) => boolean;
|
|
21
|
-
entries: () =>
|
|
22
|
-
keys: () =>
|
|
23
|
-
values: () =>
|
|
52
|
+
entries: () => IterableIterator<[string, AbstractModel<any>]>;
|
|
53
|
+
keys: () => IterableIterator<string>;
|
|
54
|
+
values: () => IterableIterator<AbstractModel<any>>;
|
|
24
55
|
};
|
|
56
|
+
resolveModelName(modelName: string): string;
|
|
25
57
|
configureInternalAccess(accessMap?: InternalModelAccessMap): void;
|
|
26
58
|
internal(scopeName: string): InternalModelScope;
|
|
27
59
|
private getInternalAccess;
|
|
@@ -29,4 +61,10 @@ export declare class ModelHandler {
|
|
|
29
61
|
* Get all models
|
|
30
62
|
*/
|
|
31
63
|
get all(): AbstractModel<any>[];
|
|
64
|
+
private getAllowedAppModels;
|
|
65
|
+
private registerAliases;
|
|
66
|
+
private resolveName;
|
|
67
|
+
private enabledModelEntries;
|
|
68
|
+
private enabledModelKeys;
|
|
69
|
+
private enabledModelValues;
|
|
32
70
|
}
|