adminizer 4.2.0 → 4.3.0-build.100
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/assets/add-1E1UsMVZ.js +1 -0
- package/assets/add-form-CGa9QbwE.js +1 -0
- package/assets/add-group-7yAK6uFY.js +1 -0
- package/assets/add-group-form-BNmpvW8K.js +1 -0
- package/assets/add-user-NoYkTfZi.js +1 -0
- package/assets/add-user-form-DrclnTOd.js +1 -0
- package/assets/{app-CVnUv8s_.css → app-D8oqdt8J.css} +1 -1
- package/assets/app-layout-i2zN9Rn-.js +1 -0
- package/assets/app-shell-CHEYhVco.js +1 -0
- package/assets/app-sidebar-DeF8WNmW.js +1 -0
- package/assets/app-sidebar-header-DdM1EOrb.js +1 -0
- package/assets/app.js +1699 -1657
- package/assets/breadcrumbs-C439DWrC.js +1 -0
- package/assets/catalog-B9hdop59.js +6 -0
- package/assets/dashboard-Bi5KeZu2.js +3 -0
- package/assets/date-picker-DbJ8nHp5.js +1 -0
- package/assets/del-modal-_b3CSNHb.js +1 -0
- package/assets/dynamic-controls-BOYmRX_z.js +1 -0
- package/assets/field-renderer-4obZ_jUo.js +407 -0
- package/assets/{field-renderer-CsBa_tMB.css → field-renderer-CRNLShJD.css} +1 -1
- package/assets/form-Bte5kzjB.js +1 -0
- package/assets/form-oUlsuu7h.js +1 -0
- package/assets/geo-json-CadjdhwW.js +4 -0
- package/assets/handsontable-PVakPtJV.js +281 -0
- package/assets/home-CsUXA-O6.js +2 -0
- package/assets/icon-DM49pZW3.js +1 -0
- package/assets/init-user-DNrB8Xt5.js +1 -0
- package/assets/input-error--IOnWghB.js +1 -0
- package/assets/jsoneditor-D95dIAP2.js +3878 -0
- package/assets/list-CdfSnSN1.js +1 -0
- package/assets/list-table-Byzv346I.js +22 -0
- package/assets/login-6Xb8bcPq.js +1 -0
- package/assets/manifest.json +331 -221
- package/assets/material-icon-BedgD2NE.js +1 -0
- package/assets/media-manager-UQT6RhI8.js +14 -0
- package/assets/module-B4-7WkY5.js +1 -0
- package/assets/monaco-ICtx6xoc.js +11 -0
- package/assets/nav-footer-BwkQkwow.js +1 -0
- package/assets/nav-main-9Eb_A0rf.js +1 -0
- package/assets/nav-user-CRAfyE-x.js +1 -0
- package/assets/notification-ma2x7vka.js +27 -0
- package/assets/pagination-render-xsEktzA8.js +1 -0
- package/assets/register-BIyjCy8M.js +1 -0
- package/assets/tabs-BK_5wdPA.js +1 -0
- package/assets/theme-switcher-CKiJbMkh.js +1 -0
- package/assets/toast-editor-BZM5RHph.js +845 -0
- package/assets/user-info-CcYdmjMZ.js +1 -0
- package/assets/user-menu-content-DbUk8ZeY.js +1 -0
- package/assets/vanilla-picker-l5rcX3cq.js +8 -0
- package/assets/vendor-wzZzN_Jv.js +17 -0
- package/assets/welcome-cWh1qnl_.js +1 -0
- package/controllers/add.js +1 -1
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +4 -4
- package/controllers/ckeditorUpload.d.ts +1 -1
- package/controllers/ckeditorUpload.js +50 -26
- package/controllers/edit.js +2 -2
- package/controllers/form.js +28 -13
- package/controllers/list.js +2 -2
- package/controllers/login.js +2 -2
- package/controllers/media-manager/mediaManagerAdapter.js +13 -2
- package/controllers/media-manager/mediaManagerApi.js +4 -3
- package/controllers/navigation/edit.js +1 -1
- package/controllers/notifications/NotificationController.d.ts +11 -0
- package/controllers/notifications/NotificationController.js +219 -0
- package/controllers/remove.js +2 -1
- package/controllers/view.js +1 -1
- package/files/favicon.png +0 -0
- package/helpers/configHelper.d.ts +1 -1
- package/helpers/controllerHelper.js +1 -1
- package/helpers/diffHelpers.d.ts +2 -0
- package/helpers/diffHelpers.js +69 -0
- package/helpers/fieldsHelper.d.ts +1 -1
- package/helpers/fieldsHelper.js +1 -1
- package/helpers/formHelper.js +3 -1
- package/helpers/inertiaAddHelper.d.ts +1 -1
- package/helpers/inertiaAutHelper.js +19 -0
- package/helpers/inertiaFromHelper.js +12 -0
- package/helpers/translationHelper.d.ts +1 -1
- package/helpers/translationHelper.js +1 -1
- package/index.d.ts +16 -14
- package/index.js +16 -14
- package/interfaces/adminpanelConfig.d.ts +18 -0
- package/interfaces/global.d.ts +3 -3
- package/interfaces/types.d.ts +44 -2
- package/lib/Adminizer.d.ts +16 -8
- package/lib/Adminizer.js +95 -12
- package/lib/{v4/DataAccessor.d.ts → DataAccessor.d.ts} +5 -5
- package/lib/{v4/DataAccessor.js → DataAccessor.js} +3 -3
- package/lib/{v4/I18n.js → I18n.js} +2 -2
- package/lib/{v4/PolicyManager.d.ts → PolicyManager.d.ts} +1 -1
- package/lib/{v4/PolicyManager.js → PolicyManager.js} +2 -2
- package/lib/{v4/catalog → catalog}/AbstractCatalog.d.ts +1 -1
- package/lib/{v4/catalog → catalog}/Navigation.d.ts +2 -2
- package/lib/{v4/catalog → catalog}/Navigation.js +1 -1
- package/lib/{v4/controls → controls}/AbstractControls.d.ts +1 -1
- package/lib/{v4/controls → controls}/codeEditor/MonacoEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/geojsoneditor/GeoEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/jsoneditor/JsonEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/markdown/ToastUiEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/table/Handsontable.d.ts +1 -1
- package/lib/{v4/controls → controls}/wysiwyg/CKeditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/wysiwyg/CKeditor.js +1 -1
- package/lib/{v4/datatable → datatable}/NodeTable.d.ts +1 -1
- package/lib/media-manager/AbstractMediaManager.d.ts +3 -3
- package/lib/media-manager/AbstractMediaManager.js +2 -2
- package/lib/media-manager/DefaultMediaManager.d.ts +1 -1
- package/lib/media-manager/DefaultMediaManager.js +6 -8
- package/lib/media-manager/Items.d.ts +2 -1
- package/lib/media-manager/Items.js +7 -0
- package/lib/media-manager/helpers/MediaManagerHelper.d.ts +10 -0
- package/lib/media-manager/helpers/MediaManagerHelper.js +27 -10
- package/lib/{v4/model → model}/AbstractModel.d.ts +12 -0
- package/lib/model/AbstractModel.js +178 -0
- package/lib/{v4/model → model}/ModelHandler.js +1 -1
- package/lib/{v4/model → model}/adapter/sequelize.d.ts +3 -4
- package/lib/{v4/model → model}/adapter/sequelize.js +41 -14
- package/lib/notifications/AbstractNotificationService.d.ts +163 -0
- package/lib/notifications/AbstractNotificationService.js +353 -0
- package/lib/notifications/GeneralNotificationService.d.ts +8 -0
- package/lib/notifications/GeneralNotificationService.js +61 -0
- package/lib/notifications/NotificationHandler.d.ts +27 -0
- package/lib/notifications/NotificationHandler.js +41 -0
- package/lib/notifications/SystemNotificationService.d.ts +19 -0
- package/lib/notifications/SystemNotificationService.js +173 -0
- package/lib/{v4/widgets → widgets}/abstractCustom.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/abstractLink.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/abstractWidgetBase.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/widgetHandler.d.ts +2 -2
- package/migrations/index.d.ts +3 -0
- package/migrations/index.js +4 -0
- package/migrations/umzug/0001.d.ts +7 -0
- package/migrations/umzug/0001.js +121 -0
- package/migrations/umzugExports.d.ts +2 -0
- package/migrations/umzugExports.js +9 -0
- package/models/MediaManagerAP.d.ts +9 -3
- package/models/MediaManagerAP.js +11 -5
- package/models/MediaManagerAssociationsAP.d.ts +9 -3
- package/models/MediaManagerAssociationsAP.js +11 -5
- package/models/MediaManagerMetaAP.d.ts +9 -3
- package/models/MediaManagerMetaAP.js +11 -5
- package/models/NotificationAP.d.ts +44 -0
- package/models/NotificationAP.js +30 -0
- package/models/UserAP.d.ts +1 -1
- package/models/UserNotificationAP.d.ts +26 -0
- package/models/UserNotificationAP.js +18 -0
- package/package.json +17 -8
- package/system/Router.js +21 -7
- package/system/bindAssets.js +1 -0
- package/system/bindControls.js +6 -6
- package/system/bindInertia.js +9 -3
- package/system/bindMediaManager.js +2 -1
- package/system/bindNavigation.js +3 -4
- package/system/bindNotifications.d.ts +2 -0
- package/system/bindNotifications.js +14 -0
- package/system/bindReqFunctions.js +8 -25
- package/system/defaults.js +6 -0
- package/translations/ar.json +5 -4
- package/translations/cn.json +5 -4
- package/translations/de.json +72 -71
- package/translations/en.json +5 -4
- package/translations/es.json +5 -4
- package/translations/fr.json +5 -4
- package/translations/hi.json +5 -4
- package/translations/jp.json +5 -4
- package/translations/ko.json +5 -4
- package/translations/pt.json +5 -4
- package/translations/ru.json +2 -1
- package/translations/ua.json +5 -4
- package/translations/uz.json +73 -72
- package/translations/vi.json +5 -4
- package/ui/components/VanillaJSONEditor.d.ts +2 -0
- package/ui/components/VanillaJSONEditor.js +101 -0
- package/ui/components/handsontable.d.ts +10 -0
- package/ui/components/handsontable.js +51 -0
- package/ui/components/monaco-editor.d.ts +11 -0
- package/ui/components/monaco-editor.js +57 -0
- package/ui/components/ui/table.d.ts +1 -1
- package/ui/components/ui/table.js +2 -2
- package/ui/hooks/form-state.d.ts +4 -0
- package/ui/hooks/form-state.js +45 -0
- package/ui/hooks/use-appearance.d.ts +7 -0
- package/ui/hooks/use-appearance.js +76 -0
- package/ui/hooks/use-window-size.d.ts +5 -0
- package/ui/hooks/use-window-size.js +21 -0
- package/assets/VanillaJSONEditor-x8tDbio1.js +0 -3833
- package/assets/add-DOaZgoTz.js +0 -1
- package/assets/add-form-BjackXJe.js +0 -1
- package/assets/add-group-Br44s2D6.js +0 -1
- package/assets/add-group-form-YI6KS37x.js +0 -1
- package/assets/add-user-DWcH0s9-.js +0 -1
- package/assets/add-user-form-bv5BNX5A.js +0 -1
- package/assets/app-layout-DecN527i.js +0 -1
- package/assets/app-shell-DHzMWA1L.js +0 -1
- package/assets/app-sidebar-4JFP8UdU.js +0 -1
- package/assets/app-sidebar-header-CIKLfLsF.js +0 -1
- package/assets/breadcrumbs-Bo2z-LNC.js +0 -1
- package/assets/catalog-DVyrGTNR.js +0 -6
- package/assets/dashboard-Dy3pk9t7.js +0 -3
- package/assets/date-picker-B2z-aeuv.js +0 -1
- package/assets/debounce-D6eaSoDg.js +0 -1
- package/assets/del-modal-l3LxJWCN.js +0 -1
- package/assets/dynamic-controls-CSVVCONh.js +0 -1
- package/assets/field-renderer-BHo944Cn.js +0 -407
- package/assets/form-BXfnz6h5.js +0 -1
- package/assets/form-hP8sjbND.js +0 -1
- package/assets/form-state-702tb_BV.js +0 -1
- package/assets/geo-json-CVaNUZbb.js +0 -4
- package/assets/handsontable-CZQ5Ietj.js +0 -347
- package/assets/home-BD4MWmm9.js +0 -2
- package/assets/icon-C_X2cQ6W.js +0 -1
- package/assets/index-C148XJoK.js +0 -1
- package/assets/index-Vcq4gwWv.js +0 -1
- package/assets/init-user-DgCD4ZN1.js +0 -1
- package/assets/input-error-Bab-HPbn.js +0 -1
- package/assets/list-C-27EH39.js +0 -1
- package/assets/list-table-_OiQmr2A.js +0 -22
- package/assets/login-jzvVXgAV.js +0 -1
- package/assets/material-icon-DsiW0iQG.js +0 -1
- package/assets/media-manager-CSB_XRcE.js +0 -14
- package/assets/module-Ceq6vuwa.js +0 -1
- package/assets/monaco-editor-XX8Hz76f.js +0 -11
- package/assets/multi-select-BbKSrMw2.js +0 -1
- package/assets/nav-footer-B8gMV6Wp.js +0 -1
- package/assets/nav-main-BUp9qA8R.js +0 -1
- package/assets/nav-user-DeF3SDRj.js +0 -1
- package/assets/pagination-render-B9U_hVbB.js +0 -1
- package/assets/register-C6acWsLe.js +0 -1
- package/assets/theme-switcher-D8T9NgWG.js +0 -1
- package/assets/toast-editor-C0550yms.js +0 -845
- package/assets/use-appearance-CXP5cHaQ.js +0 -1
- package/assets/use-window-size-DLSEoR6e.js +0 -1
- package/assets/user-info-CAgkqARx.js +0 -1
- package/assets/user-menu-content-BxL0QMC9.js +0 -1
- package/assets/vanilla-picker-B6E6ObS_.js +0 -8
- package/assets/welcome-Dk7GoS5R.js +0 -1
- package/lib/v4/model/AbstractModel.js +0 -67
- package/lib/v4/model/adapter/typeorm.d.ts +0 -23
- package/lib/v4/model/adapter/typeorm.js +0 -68
- package/migrations/20230303171134-adminpanel-init.js +0 -122
- package/migrations/20231223215835-add-widgets.js +0 -32
- package/migrations/20240804191001-added-navigationap.js +0 -53
- package/migrations/20241121184236-v4-init.js +0 -134
- /package/lib/{v4/I18n.d.ts → I18n.d.ts} +0 -0
- /package/lib/{v4/POWCaptcha.d.ts → POWCaptcha.d.ts} +0 -0
- /package/lib/{v4/POWCaptcha.js → POWCaptcha.js} +0 -0
- /package/lib/{v4/catalog → catalog}/AbstractCatalog.js +0 -0
- /package/lib/{v4/catalog → catalog}/CatalogHandler.d.ts +0 -0
- /package/lib/{v4/catalog → catalog}/CatalogHandler.js +0 -0
- /package/lib/{v4/controls → controls}/AbstractControls.js +0 -0
- /package/lib/{v4/controls → controls}/ControlsHandler.d.ts +0 -0
- /package/lib/{v4/controls → controls}/ControlsHandler.js +0 -0
- /package/lib/{v4/controls → controls}/codeEditor/MonacoEditor.js +0 -0
- /package/lib/{v4/controls → controls}/geojsoneditor/GeoEditor.js +0 -0
- /package/lib/{v4/controls → controls}/jsoneditor/JsonEditor.js +0 -0
- /package/lib/{v4/controls → controls}/markdown/ToastUiEditor.js +0 -0
- /package/lib/{v4/controls → controls}/table/Handsontable.js +0 -0
- /package/lib/{v4/datatable → datatable}/NodeTable.js +0 -0
- /package/lib/{v4/helper → helper}/jwt.d.ts +0 -0
- /package/lib/{v4/helper → helper}/jwt.js +0 -0
- /package/lib/{v4/inertia → inertia}/flash.d.ts +0 -0
- /package/lib/{v4/inertia → inertia}/flash.js +0 -0
- /package/lib/{v4/inertia → inertia}/inertiaAdapter.d.ts +0 -0
- /package/lib/{v4/inertia → inertia}/inertiaAdapter.js +0 -0
- /package/lib/{v4/model → model}/ModelHandler.d.ts +0 -0
- /package/lib/{v4/model → model}/adapter/waterline.d.ts +0 -0
- /package/lib/{v4/model → model}/adapter/waterline.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractAction.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractAction.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractCustom.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractInfo.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractInfo.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractLink.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractSwitch.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractSwitch.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractWidgetBase.js +0 -0
- /package/lib/{v4/widgets → widgets}/widgetHandler.js +0 -0
package/lib/Adminizer.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { Express } from "express";
|
|
1
|
+
import express, { Express } from "express";
|
|
2
2
|
import winston from "winston";
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
4
|
import { AdminpanelConfig } from "../interfaces/adminpanelConfig";
|
|
5
|
-
import PolicyManager from "./
|
|
6
|
-
import { ModelHandler } from "./
|
|
7
|
-
import { WidgetHandler } from "./
|
|
5
|
+
import PolicyManager from "./PolicyManager";
|
|
6
|
+
import { ModelHandler } from "./model/ModelHandler";
|
|
7
|
+
import { WidgetHandler } from "./widgets/widgetHandler";
|
|
8
8
|
import { AccessRightsHelper } from "../helpers/accessRightsHelper";
|
|
9
9
|
import { ConfigHelper } from "../helpers/configHelper";
|
|
10
|
-
import { AbstractAdapter } from "./
|
|
10
|
+
import { AbstractAdapter } from "./model/AbstractModel";
|
|
11
11
|
import type { ViteDevServer } from 'vite';
|
|
12
12
|
import { MenuHelper } from "../helpers/menuHelper";
|
|
13
|
-
import { ControlsHandler } from "./
|
|
14
|
-
import { CatalogHandler } from "./
|
|
13
|
+
import { ControlsHandler } from "./controls/ControlsHandler";
|
|
14
|
+
import { CatalogHandler } from "./catalog/CatalogHandler";
|
|
15
|
+
import { NotificationHandler } from './notifications/NotificationHandler';
|
|
16
|
+
import { INotification } from "../interfaces/types";
|
|
15
17
|
export declare class Adminizer {
|
|
16
18
|
/**
|
|
17
19
|
* If you convey this default Middleware, it will add it to the very top of the router,
|
|
@@ -26,6 +28,7 @@ export declare class Adminizer {
|
|
|
26
28
|
accessRightsHelper: AccessRightsHelper;
|
|
27
29
|
configHelper: ConfigHelper;
|
|
28
30
|
menuHelper: MenuHelper;
|
|
31
|
+
notificationHandler: NotificationHandler;
|
|
29
32
|
modelHandler: ModelHandler;
|
|
30
33
|
widgetHandler: WidgetHandler;
|
|
31
34
|
vite: ViteDevServer;
|
|
@@ -34,13 +37,18 @@ export declare class Adminizer {
|
|
|
34
37
|
jwtSecret: string;
|
|
35
38
|
static logger: winston.Logger;
|
|
36
39
|
constructor(ormAdapters: AbstractAdapter[]);
|
|
37
|
-
getMiddleware(): (req:
|
|
40
|
+
getMiddleware(): (req: express.Request, res: express.Response, next: () => void) => void;
|
|
38
41
|
/**
|
|
39
42
|
* Vite middleware
|
|
40
43
|
* @protected
|
|
41
44
|
*/
|
|
42
45
|
protected viteMiddleware(): Promise<void>;
|
|
43
46
|
init(config: AdminpanelConfig): Promise<void>;
|
|
47
|
+
sendNotification(notification: Omit<INotification, 'id' | 'createdAt' | 'icon'>): Promise<boolean>;
|
|
48
|
+
logSystemEvent(title: string, message: string, metadata?: any): Promise<boolean>;
|
|
49
|
+
logSystemCreatedEvent(title: string, message: string, metadata?: any): Promise<boolean>;
|
|
50
|
+
logSystemUpdatedEvent(title: string, message: string, metadata?: any): Promise<boolean>;
|
|
51
|
+
logSystemDeletedEvent(title: string, message: string, metadata?: any): Promise<boolean>;
|
|
44
52
|
get emitter(): EventEmitter;
|
|
45
53
|
getOrmAdapter(ormType: string): AbstractAdapter;
|
|
46
54
|
static get log(): {
|
package/lib/Adminizer.js
CHANGED
|
@@ -3,7 +3,7 @@ import cookieParser from 'cookie-parser';
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import winston from "winston";
|
|
5
5
|
import EventEmitter from 'events';
|
|
6
|
-
import PolicyManager from "./
|
|
6
|
+
import PolicyManager from "./PolicyManager";
|
|
7
7
|
import Router from "./../system/Router";
|
|
8
8
|
import bindAssets from "../system/bindAssets";
|
|
9
9
|
import bindDev from "../system/bindDev";
|
|
@@ -15,20 +15,21 @@ import bindAuthorization from "../system/bindAuthorization";
|
|
|
15
15
|
import bindModels from "../system/bindModels";
|
|
16
16
|
import bindForms from "../system/bindForms";
|
|
17
17
|
import bindTranslations from "../system/bindTranslations";
|
|
18
|
-
import { ModelHandler } from "./
|
|
19
|
-
import { WidgetHandler } from "./
|
|
18
|
+
import { ModelHandler } from "./model/ModelHandler";
|
|
19
|
+
import { WidgetHandler } from "./widgets/widgetHandler";
|
|
20
20
|
import { AccessRightsHelper } from "../helpers/accessRightsHelper";
|
|
21
21
|
import bindReqFunctions from "../system/bindReqFunctions";
|
|
22
22
|
import { ConfigHelper } from "../helpers/configHelper";
|
|
23
|
-
import { I18n } from "./
|
|
23
|
+
import { I18n } from "./I18n";
|
|
24
24
|
import { getDefaultConfig } from "../system/defaults";
|
|
25
25
|
import bindExpressUtils from "../system/bindExpressUtils";
|
|
26
26
|
import { bindInertia } from "../system/bindInertia";
|
|
27
27
|
import { MenuHelper } from "../helpers/menuHelper";
|
|
28
28
|
import { bindControls } from "../system/bindControls";
|
|
29
|
-
import { ControlsHandler } from "./
|
|
30
|
-
import { CatalogHandler } from "./
|
|
29
|
+
import { ControlsHandler } from "./controls/ControlsHandler";
|
|
30
|
+
import { CatalogHandler } from "./catalog/CatalogHandler";
|
|
31
31
|
import { v4 as uuid } from "uuid";
|
|
32
|
+
import { bindNotifications } from "../system/bindNotifications";
|
|
32
33
|
export class Adminizer {
|
|
33
34
|
// Preconfigures
|
|
34
35
|
/**
|
|
@@ -45,6 +46,7 @@ export class Adminizer {
|
|
|
45
46
|
accessRightsHelper;
|
|
46
47
|
configHelper;
|
|
47
48
|
menuHelper;
|
|
49
|
+
notificationHandler;
|
|
48
50
|
modelHandler;
|
|
49
51
|
widgetHandler;
|
|
50
52
|
vite;
|
|
@@ -69,16 +71,61 @@ export class Adminizer {
|
|
|
69
71
|
this.ormAdapters = ormAdapters;
|
|
70
72
|
}
|
|
71
73
|
getMiddleware() {
|
|
72
|
-
return (req, res) => {
|
|
74
|
+
return (req, res, next) => {
|
|
75
|
+
try {
|
|
76
|
+
const prefix = (this.config && this.config.routePrefix) ? String(this.config.routePrefix) : '';
|
|
77
|
+
if (prefix === '/') {
|
|
78
|
+
throw new Error('Using "/" as routePrefix is temporarily prohibited');
|
|
79
|
+
}
|
|
80
|
+
const normalizedPrefix = prefix.replace(/\/+/g, '/').replace(/\/+$/g, '');
|
|
81
|
+
// Check if this middleware is already mounted under a prefix
|
|
82
|
+
const isMountedUnderPrefix = req.baseUrl && req.baseUrl === normalizedPrefix;
|
|
83
|
+
if (normalizedPrefix && !isMountedUnderPrefix) {
|
|
84
|
+
// Legacy behavior: middleware not mounted under prefix, check URL manually
|
|
85
|
+
const url = req.originalUrl || req.url || '';
|
|
86
|
+
const condition1 = url === normalizedPrefix;
|
|
87
|
+
const condition2 = url.startsWith(normalizedPrefix + '/');
|
|
88
|
+
const condition3 = url.startsWith('/public');
|
|
89
|
+
const conditions = [
|
|
90
|
+
condition1,
|
|
91
|
+
condition2
|
|
92
|
+
];
|
|
93
|
+
if (process.env.IS_SAILS === undefined) {
|
|
94
|
+
conditions.push(condition3);
|
|
95
|
+
}
|
|
96
|
+
if (!conditions.some(condition => condition)) {
|
|
97
|
+
return typeof next === 'function' ? next() : undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (isMountedUnderPrefix) {
|
|
101
|
+
// When mounted under prefix, we need to restore the full path for internal routing
|
|
102
|
+
// because Router expects routes with full prefix
|
|
103
|
+
const originalUrl = req.url;
|
|
104
|
+
req.url = normalizedPrefix + req.url;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
// No prefix configured, handling all requests
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
// fall back to handling the request
|
|
112
|
+
}
|
|
73
113
|
this.app(req, res, (err) => {
|
|
74
114
|
if (err) {
|
|
75
|
-
console.error("Error in Adminizer", err);
|
|
76
|
-
res.
|
|
77
|
-
|
|
115
|
+
console.error("❌ Error in Adminizer:", err);
|
|
116
|
+
if (!res.headersSent) {
|
|
117
|
+
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
118
|
+
res.end('Internal Server Error');
|
|
119
|
+
}
|
|
78
120
|
}
|
|
79
121
|
else {
|
|
80
|
-
|
|
81
|
-
|
|
122
|
+
if (typeof next === 'function') {
|
|
123
|
+
return next();
|
|
124
|
+
}
|
|
125
|
+
if (!res.headersSent) {
|
|
126
|
+
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
127
|
+
res.end('Route Not Found in Adminizer');
|
|
128
|
+
}
|
|
82
129
|
}
|
|
83
130
|
});
|
|
84
131
|
};
|
|
@@ -173,6 +220,9 @@ export class Adminizer {
|
|
|
173
220
|
// bind Inertia
|
|
174
221
|
bindInertia(this);
|
|
175
222
|
await bindAuthorization(this);
|
|
223
|
+
// Bind notifications
|
|
224
|
+
if (this.config.notifications.enabled)
|
|
225
|
+
await bindNotifications(this);
|
|
176
226
|
await Router.bind(this); // must be after binding policies and req/res functions
|
|
177
227
|
/**
|
|
178
228
|
* Adminizer loaded
|
|
@@ -180,6 +230,39 @@ export class Adminizer {
|
|
|
180
230
|
*/
|
|
181
231
|
this._emitter.emit('adminizer:loaded');
|
|
182
232
|
}
|
|
233
|
+
// Хелпер для отправки уведомлений
|
|
234
|
+
async sendNotification(notification) {
|
|
235
|
+
if (this.config.notifications.enabled) {
|
|
236
|
+
const notificationClass = notification.notificationClass || 'general';
|
|
237
|
+
return this.notificationHandler.dispatchNotification(notificationClass, notification);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return Promise.resolve(false);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Хелпер для системных событий
|
|
244
|
+
async logSystemEvent(title, message, metadata) {
|
|
245
|
+
if (this.config.notifications.enabled) {
|
|
246
|
+
const systemNotificationService = this.notificationHandler.getService('system');
|
|
247
|
+
return systemNotificationService.logSystemEvent(title, message, 'system', metadata);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
return Promise.resolve(false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// Хелпер для CRUD системных событий
|
|
254
|
+
async logSystemCreatedEvent(title, message, metadata) {
|
|
255
|
+
const systemNotificationService = this.notificationHandler.getService('system');
|
|
256
|
+
return systemNotificationService.logCreatedEvent(title, message, metadata);
|
|
257
|
+
}
|
|
258
|
+
async logSystemUpdatedEvent(title, message, metadata) {
|
|
259
|
+
const systemNotificationService = this.notificationHandler.getService('system');
|
|
260
|
+
return systemNotificationService.logUpdatedEvent(title, message, metadata);
|
|
261
|
+
}
|
|
262
|
+
async logSystemDeletedEvent(title, message, metadata) {
|
|
263
|
+
const systemNotificationService = this.notificationHandler.getService('system');
|
|
264
|
+
return systemNotificationService.logDeletedEvent(title, message, metadata);
|
|
265
|
+
}
|
|
183
266
|
get emitter() {
|
|
184
267
|
return this._emitter;
|
|
185
268
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The class manages the interaction between the user and the database entry, taking into account user permissions and the main config file settings.
|
|
3
3
|
*/
|
|
4
|
-
import { Entity } from "
|
|
5
|
-
import { ActionType } from "
|
|
6
|
-
import { Fields } from "
|
|
7
|
-
import { Adminizer } from "
|
|
4
|
+
import { Entity } from "../interfaces/types";
|
|
5
|
+
import { ActionType } from "../interfaces/adminpanelConfig";
|
|
6
|
+
import { Fields } from "../helpers/fieldsHelper";
|
|
7
|
+
import { Adminizer } from "./Adminizer";
|
|
8
8
|
import { UserAP } from "models/UserAP";
|
|
9
9
|
export declare class DataAccessor {
|
|
10
|
-
|
|
10
|
+
readonly adminizer: Adminizer;
|
|
11
11
|
user: UserAP;
|
|
12
12
|
entity: Entity;
|
|
13
13
|
action: ActionType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ControllerHelper } from "
|
|
2
|
-
import { Adminizer } from "
|
|
3
|
-
import { isObject } from "
|
|
1
|
+
import { ControllerHelper } from "../helpers/controllerHelper";
|
|
2
|
+
import { Adminizer } from "./Adminizer";
|
|
3
|
+
import { isObject } from "../helpers/JsUtils";
|
|
4
4
|
export class DataAccessor {
|
|
5
5
|
adminizer;
|
|
6
6
|
user;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { vsprintf } from "sprintf-js";
|
|
4
|
-
import { Adminizer } from "
|
|
4
|
+
import { Adminizer } from "./Adminizer";
|
|
5
5
|
export class I18n {
|
|
6
6
|
devMode;
|
|
7
7
|
static locales = {};
|
|
@@ -18,7 +18,7 @@ export class I18n {
|
|
|
18
18
|
constructor(options = {}) {
|
|
19
19
|
this.devMode = process.env.NODE_ENV !== "production";
|
|
20
20
|
this.defaultLocale = options.defaultLocale || "en";
|
|
21
|
-
this.directory = options.directory || path.join(import.meta.filename, '
|
|
21
|
+
this.directory = options.directory || path.join(import.meta.filename, '../../translations');
|
|
22
22
|
this.extension = options.extension || ".json";
|
|
23
23
|
this.cookieName = options.cookieName || "lang";
|
|
24
24
|
this.sessionVarName = options.sessionVarName || "locale";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "./Adminizer";
|
|
4
4
|
import { pathToFileURL } from "url";
|
|
5
5
|
class PolicyManager {
|
|
6
6
|
_adminizer;
|
|
@@ -9,7 +9,7 @@ class PolicyManager {
|
|
|
9
9
|
}
|
|
10
10
|
async loadPolicies() {
|
|
11
11
|
try {
|
|
12
|
-
const policiesDirPath = path.join(import.meta.dirname, "
|
|
12
|
+
const policiesDirPath = path.join(import.meta.dirname, "../policies");
|
|
13
13
|
const policiesDir = fs.readdirSync(policiesDirPath);
|
|
14
14
|
for (const policyFile of policiesDir) {
|
|
15
15
|
if (path.extname(policyFile).toLowerCase() === ".js") {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractCatalog, ActionHandler, Item } from "./AbstractCatalog";
|
|
2
|
-
import { NavigationConfig } from "
|
|
3
|
-
import { Adminizer } from "
|
|
2
|
+
import { NavigationConfig } from "../../interfaces/adminpanelConfig";
|
|
3
|
+
import { Adminizer } from "../Adminizer";
|
|
4
4
|
export interface NavItem extends Item {
|
|
5
5
|
urlPath?: string;
|
|
6
6
|
modelId?: string | number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../Adminizer";
|
|
3
3
|
export declare class MonacoEditor extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../Adminizer";
|
|
3
3
|
export declare class GeoEditor extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Path, Config } from "../AbstractControls";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "../../Adminizer";
|
|
4
4
|
export declare class JsonEditor extends AbstractControls {
|
|
5
5
|
readonly config: Partial<EditorOptions>;
|
|
6
6
|
readonly name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Path, Config } from "../AbstractControls";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "../../Adminizer";
|
|
4
4
|
export declare class ToastUiEditor extends AbstractControls {
|
|
5
5
|
readonly config: Partial<EditorOptions>;
|
|
6
6
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../Adminizer";
|
|
3
3
|
export declare class Handsontable extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../Adminizer";
|
|
3
3
|
export declare class CKeditor extends AbstractControls {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
readonly type: ControlType;
|
|
@@ -104,7 +104,7 @@ export declare abstract class File<T extends MediaManagerItem> {
|
|
|
104
104
|
* Delete an item.
|
|
105
105
|
* @param id
|
|
106
106
|
*/
|
|
107
|
-
abstract delete(id: string): Promise<
|
|
107
|
+
abstract delete(id: string): Promise<boolean>;
|
|
108
108
|
/**
|
|
109
109
|
* Get all items of a type.
|
|
110
110
|
* @param limit
|
|
@@ -208,7 +208,7 @@ export declare abstract class AbstractMediaManager {
|
|
|
208
208
|
* widget Id in the model in which the mediafile was added
|
|
209
209
|
*/
|
|
210
210
|
modelId: string, widgetName: string): Promise<void>;
|
|
211
|
-
abstract
|
|
211
|
+
abstract getItemsList(items: MediaManagerWidgetItem[]): Promise<MediaManagerWidgetClientItem[]>;
|
|
212
212
|
/**
|
|
213
213
|
* Search all items.
|
|
214
214
|
* If not this.allowSearch = true then it will not come here
|
|
@@ -258,6 +258,6 @@ export declare abstract class AbstractMediaManager {
|
|
|
258
258
|
* Delete an item.
|
|
259
259
|
* @param item
|
|
260
260
|
*/
|
|
261
|
-
delete(item: MediaManagerItem): Promise<
|
|
261
|
+
delete(item: MediaManagerItem): Promise<boolean>;
|
|
262
262
|
}
|
|
263
263
|
export {};
|
|
@@ -50,8 +50,8 @@ export class AbstractMediaManager {
|
|
|
50
50
|
adminizer.accessRightsHelper.registerToken({
|
|
51
51
|
id: `mediaManager-${this.id}`,
|
|
52
52
|
name: this.id,
|
|
53
|
-
description: `Access to edit
|
|
54
|
-
department: '
|
|
53
|
+
description: `Access to edit media-manager for ${this.id}`,
|
|
54
|
+
department: 'media-manager',
|
|
55
55
|
});
|
|
56
56
|
}, 100);
|
|
57
57
|
}
|
|
@@ -13,5 +13,5 @@ export declare class DefaultMediaManager extends AbstractMediaManager {
|
|
|
13
13
|
}>;
|
|
14
14
|
searchAll(s: string, group: string): Promise<MediaManagerItem[]>;
|
|
15
15
|
setRelations(data: MediaManagerWidgetData[], model: string, modelId: string, widgetName: string): Promise<void>;
|
|
16
|
-
|
|
16
|
+
getItemsList(items: MediaManagerWidgetItem[]): Promise<MediaManagerWidgetClientItem[]>;
|
|
17
17
|
}
|
|
@@ -19,7 +19,7 @@ export class DefaultMediaManager extends AbstractMediaManager {
|
|
|
19
19
|
this.adminizer = adminizer;
|
|
20
20
|
}
|
|
21
21
|
async getAll(limit, skip, sort, group) {
|
|
22
|
-
//
|
|
22
|
+
//TODO refactor CRUD functions for DataAccessor usage
|
|
23
23
|
let data = await this.adminizer.modelHandler.model.get(this.model)["_find"]({
|
|
24
24
|
where: { parent: null, group: group },
|
|
25
25
|
limit: limit,
|
|
@@ -41,7 +41,7 @@ export class DefaultMediaManager extends AbstractMediaManager {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async searchAll(s, group) {
|
|
44
|
-
//
|
|
44
|
+
//TODO refactor CRUD functions for DataAccessor usage
|
|
45
45
|
let data = await this.adminizer.modelHandler.model.get(this.model)["_find"]({
|
|
46
46
|
where: { filename: { contains: s }, parent: null, group: group },
|
|
47
47
|
sort: "createdAt DESC",
|
|
@@ -56,7 +56,6 @@ export class DefaultMediaManager extends AbstractMediaManager {
|
|
|
56
56
|
return data;
|
|
57
57
|
}
|
|
58
58
|
async setRelations(data, model, modelId, widgetName) {
|
|
59
|
-
// TODO refactor CRUD functions for DataAccessor usage
|
|
60
59
|
let modelAssociations = await this.adminizer.modelHandler.model.get(this.modelAssoc)["_find"]({
|
|
61
60
|
where: { modelId: modelId, model: model, widgetName: widgetName },
|
|
62
61
|
});
|
|
@@ -64,25 +63,24 @@ export class DefaultMediaManager extends AbstractMediaManager {
|
|
|
64
63
|
const q = {};
|
|
65
64
|
const pk = this.adminizer.modelHandler.model.get(this.modelAssoc).primaryKey;
|
|
66
65
|
q[pk] = modelAssociation.id;
|
|
67
|
-
// TODO refactor CRUD functions for DataAccessor usage
|
|
68
66
|
await this.adminizer.modelHandler.model.get(this.modelAssoc)["_destroy"](q);
|
|
69
67
|
}
|
|
68
|
+
const fieldName = this.adminizer.ormAdapters[0].ormType === 'sequelize' ? 'fileId' : 'file';
|
|
70
69
|
for (const [key, widgetItem] of data.entries()) {
|
|
71
|
-
// TODO refactor CRUD functions for DataAccessor usage
|
|
72
70
|
await this.adminizer.modelHandler.model.get(this.modelAssoc)["_create"]({
|
|
73
71
|
mediaManagerId: this.id,
|
|
74
72
|
model: model,
|
|
75
73
|
modelId: modelId,
|
|
76
|
-
|
|
74
|
+
[fieldName]: widgetItem.id,
|
|
77
75
|
widgetName: widgetName,
|
|
78
76
|
sortOrder: key + 1,
|
|
79
77
|
});
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
async
|
|
80
|
+
async getItemsList(items) {
|
|
83
81
|
let widgetItems = [];
|
|
84
82
|
for (const item of items) {
|
|
85
|
-
//
|
|
83
|
+
//TODO refactor CRUD functions for DataAccessor usage
|
|
86
84
|
let file = (await this.adminizer.modelHandler.model.get(this.model)["_find"]({
|
|
87
85
|
where: { id: item.id }
|
|
88
86
|
}, { populate: [["variants", { sort: "createdAt DESC" }]] }))[0];
|
|
@@ -5,6 +5,7 @@ export declare class ImageItem extends File<MediaManagerItem> {
|
|
|
5
5
|
type: MediaFileType;
|
|
6
6
|
model: string;
|
|
7
7
|
metaModel: string;
|
|
8
|
+
modelAssoc: string;
|
|
8
9
|
imageSizes: any;
|
|
9
10
|
protected readonly adminizer: Adminizer;
|
|
10
11
|
constructor(adminizer: Adminizer, urlPathPrefix: string, fileStoragePath: string);
|
|
@@ -28,7 +29,7 @@ export declare class ImageItem extends File<MediaManagerItem> {
|
|
|
28
29
|
}): Promise<void>;
|
|
29
30
|
protected resizeImage(input: string, output: string, width: number, height: number): Promise<sharp.OutputInfo>;
|
|
30
31
|
uploadVariant(parent: MediaManagerItem, file: UploaderFile, filename: string, group: string, localeId: string): Promise<MediaManagerItem>;
|
|
31
|
-
delete(id: string): Promise<
|
|
32
|
+
delete(id: string): Promise<boolean>;
|
|
32
33
|
}
|
|
33
34
|
export declare class TextItem extends ImageItem {
|
|
34
35
|
type: MediaFileType;
|
|
@@ -8,6 +8,7 @@ export class ImageItem extends File {
|
|
|
8
8
|
type = "image";
|
|
9
9
|
model = "mediamanagerap";
|
|
10
10
|
metaModel = "mediamanagermetaap";
|
|
11
|
+
modelAssoc = "mediamanagerassociationsap";
|
|
11
12
|
imageSizes;
|
|
12
13
|
adminizer;
|
|
13
14
|
constructor(adminizer, urlPathPrefix, fileStoragePath) {
|
|
@@ -176,6 +177,11 @@ export class ImageItem extends File {
|
|
|
176
177
|
return (await this.adminizer.modelHandler.model.get(this.model)["_findOne"]({ where: { id: item.id } }));
|
|
177
178
|
}
|
|
178
179
|
async delete(id) {
|
|
180
|
+
const fieldName = this.adminizer.ormAdapters[0].ormType === 'sequelize' ? 'fileId' : 'file';
|
|
181
|
+
const assoc = await this.adminizer.modelHandler.model.get(this.modelAssoc)["_find"]({ where: { [fieldName]: id } });
|
|
182
|
+
if (assoc.length) {
|
|
183
|
+
return Promise.resolve(false);
|
|
184
|
+
}
|
|
179
185
|
const criteria = { where: { id: id } };
|
|
180
186
|
// TODO refactor CRUD functions for DataAccessor usage
|
|
181
187
|
let record = await this.adminizer.modelHandler.model.get(this.model)["_findOne"](criteria);
|
|
@@ -189,6 +195,7 @@ export class ImageItem extends File {
|
|
|
189
195
|
await deleteFile(variant.path);
|
|
190
196
|
}
|
|
191
197
|
}
|
|
198
|
+
return Promise.resolve(true);
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
/*
|
|
@@ -17,7 +17,16 @@ export declare function randomFileName(filenameOrig: string, type: string, prefi
|
|
|
17
17
|
* @param recordId
|
|
18
18
|
*/
|
|
19
19
|
export declare function saveRelationsMediaManager(fields: Fields, reqData: PostParams, model: string, recordId: string): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Get realtions
|
|
22
|
+
* @param data
|
|
23
|
+
*/
|
|
20
24
|
export declare function getRelationsMediaManager(data: MediaManagerWidgetJSON): Promise<import("../AbstractMediaManager").MediaManagerWidgetClientItem[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Delate Ralations
|
|
27
|
+
* @param model
|
|
28
|
+
* @param record
|
|
29
|
+
*/
|
|
21
30
|
export declare function deleteRelationsMediaManager(adminizer: Adminizer, model: string, record: {
|
|
22
31
|
[p: string]: string | MediaManagerWidgetItem[];
|
|
23
32
|
}[]): Promise<void>;
|
|
@@ -27,4 +36,5 @@ export declare function deleteRelationsMediaManager(adminizer: Adminizer, model:
|
|
|
27
36
|
* @param model
|
|
28
37
|
*/
|
|
29
38
|
export declare function populateVariants(adminizer: Adminizer, variants: MediaManagerItem[], model: string): Promise<MediaManagerItem[]>;
|
|
39
|
+
export declare function getAssociationFieldName(model: any, associationName: string): string;
|
|
30
40
|
export {};
|
|
@@ -29,19 +29,19 @@ export async function saveRelationsMediaManager(fields, reqData, model, recordId
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
* Get realtions
|
|
34
|
-
* @param data
|
|
35
|
-
*/
|
|
32
|
+
/**
|
|
33
|
+
* Get realtions
|
|
34
|
+
* @param data
|
|
35
|
+
*/
|
|
36
36
|
export async function getRelationsMediaManager(data) {
|
|
37
37
|
let mediaManager = MediaManagerHandler.get(data.mediaManagerId);
|
|
38
|
-
return await mediaManager.
|
|
38
|
+
return await mediaManager.getItemsList(data.list ?? []);
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
* Delate Ralations
|
|
42
|
-
* @param model
|
|
43
|
-
* @param record
|
|
44
|
-
*/
|
|
40
|
+
/**
|
|
41
|
+
* Delate Ralations
|
|
42
|
+
* @param model
|
|
43
|
+
* @param record
|
|
44
|
+
*/
|
|
45
45
|
export async function deleteRelationsMediaManager(adminizer, model, record) {
|
|
46
46
|
let config = adminizer.config.models[model];
|
|
47
47
|
for (const key of Object.keys(record[0])) {
|
|
@@ -68,3 +68,20 @@ export async function populateVariants(adminizer, variants, model) {
|
|
|
68
68
|
}
|
|
69
69
|
return items;
|
|
70
70
|
}
|
|
71
|
+
export function getAssociationFieldName(model, associationName) {
|
|
72
|
+
const attributes = model.attributes || {};
|
|
73
|
+
// Для вашего случая: file связь использует fileId
|
|
74
|
+
if (associationName === 'file') {
|
|
75
|
+
// Проверяем есть ли связь file и какое у нее via
|
|
76
|
+
if (attributes.file?.type === 'association' && attributes.file.via) {
|
|
77
|
+
return attributes.file.via; // Вернет 'fileId'
|
|
78
|
+
}
|
|
79
|
+
// Или просто проверяем наличие fileId
|
|
80
|
+
if (attributes.fileId) {
|
|
81
|
+
return 'fileId';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Общий случай
|
|
85
|
+
const idField = `${associationName}Id`;
|
|
86
|
+
return attributes[idField] ? idField : associationName;
|
|
87
|
+
}
|
|
@@ -46,6 +46,18 @@ export declare abstract class AbstractModel<T> {
|
|
|
46
46
|
protected abstract _destroyOne(criteria: Partial<T>): Promise<T | null>;
|
|
47
47
|
protected abstract _destroy(criteria: Partial<T>): Promise<T[]>;
|
|
48
48
|
protected abstract _count(criteria: Partial<T> | undefined): Promise<number>;
|
|
49
|
+
/**
|
|
50
|
+
* Generate diff between old and new records
|
|
51
|
+
*/
|
|
52
|
+
private generateDiff;
|
|
53
|
+
/**
|
|
54
|
+
* Generate delete diff (record vs empty object)
|
|
55
|
+
*/
|
|
56
|
+
private generateDeleteDiff;
|
|
57
|
+
/**
|
|
58
|
+
* Log system event with diff
|
|
59
|
+
*/
|
|
60
|
+
private logSystemEvent;
|
|
49
61
|
create(data: T, dataAccessor: DataAccessor): Promise<Partial<T>>;
|
|
50
62
|
findOne(criteria: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T> | null>;
|
|
51
63
|
find(criteria: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T>[]>;
|