adminizer 4.1.0-build.3 → 4.1.0-build.30

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 (249) hide show
  1. package/Readme.md +11 -1
  2. package/assets/{VanillaJSONEditor-FUe77pIA.js → VanillaJSONEditor-DKF_Ft1S.js} +96 -96
  3. package/assets/add-BA0ZgbVP.js +1 -0
  4. package/assets/add-form-D5PNdz6X.js +1 -0
  5. package/assets/add-group-BqvmQRDY.js +1 -0
  6. package/assets/{add-group-form-dzadPSfL.js → add-group-form-D1P6v9Fm.js} +1 -1
  7. package/assets/add-user-C31g3pXW.js +1 -0
  8. package/assets/add-user-form-DyczuE4l.js +1 -0
  9. package/assets/{app-DMmad2-f.css → app-ClS67l37.css} +1 -1
  10. package/assets/app-layout-CQTlWDgg.js +1 -0
  11. package/assets/{app-shell-BWMRMkHM.js → app-shell-B4pzTbiN.js} +1 -1
  12. package/assets/app-sidebar-DX9Shcd3.js +1 -0
  13. package/assets/{app-sidebar-header-DLAFi13E.js → app-sidebar-header-BcZ0JSSJ.js} +1 -1
  14. package/assets/app.js +9 -9
  15. package/assets/{breadcrumbs-CQNon4Vl.js → breadcrumbs-DIhfOCvh.js} +1 -1
  16. package/assets/{button-CQ9t1kLz.js → button-DleSKY4-.js} +1 -1
  17. package/assets/catalog-BHbLV-zr.js +12 -0
  18. package/assets/catalog-CZUI8zho.css +1 -0
  19. package/assets/{checkbox-W0nGAXIj.js → checkbox-DgmLwxEt.js} +1 -1
  20. package/assets/{compiler-runtime-tM4jBQ-T.js → compiler-runtime-CMDe02AS.js} +1 -1
  21. package/assets/dashboard-BOltB2Hq.css +1 -0
  22. package/assets/dashboard-BiycZ-vC.js +3 -0
  23. package/assets/{date-picker-B__dVVqj.js → date-picker-Cb6A4Zx_.js} +1 -1
  24. package/assets/dialog-stack-DU4Ow4Oa.js +1 -0
  25. package/assets/{dropdown-menu-SEBnEIiL.js → dropdown-menu-D3vlxbLx.js} +1 -1
  26. package/assets/{field-renderer-CapylJU9.js → field-renderer-CW8TLtlI.js} +3 -3
  27. package/assets/form-CLP53RtV.js +1 -0
  28. package/assets/form-CwSId-Cu.js +1 -0
  29. package/assets/{geo-json-CwteYDGB.js → geo-json-BNgLxoVs.js} +1 -1
  30. package/assets/group-add-Brshb-tH.js +1 -0
  31. package/assets/{handsontable-BCnjOpBr.js → handsontable-BI4C0OBe.js} +1 -1
  32. package/assets/home-BRJ6eKVn.js +2 -0
  33. package/assets/{icon-Bz9BMaD0.js → icon-DLHMhF_-.js} +1 -1
  34. package/assets/{index-BcE9FUM6.js → index-BRQOFOzQ.js} +1 -1
  35. package/assets/{index-C0SL3SHw.js → index-BZZx7KCI.js} +1 -1
  36. package/assets/{index-DTRTjOmh.js → index-BpVWRzP4.js} +2 -2
  37. package/assets/{index-BbXEMx9n.js → index-Bz0y23v2.js} +1 -1
  38. package/assets/index-C148XJoK.js +1 -0
  39. package/assets/index-C8anOJBB.js +1 -0
  40. package/assets/{index-DEk3sC8d.js → index-CS5ssiKu.js} +1 -1
  41. package/assets/index-CsMwA9pu.js +1 -0
  42. package/assets/{index-DrWfGwtf.js → index-HZzILD42.js} +1 -1
  43. package/assets/{index-BC0yfOHo.js → index-kzaPFHKt.js} +1 -1
  44. package/assets/{init-user-D9mW-g14.js → init-user-VMPNdivw.js} +1 -1
  45. package/assets/{input-DF7Ue23C.js → input-CZTX-THl.js} +1 -1
  46. package/assets/{input-error-BBygona6.js → input-error-DpUrcJaR.js} +1 -1
  47. package/assets/item-add-1duKvWXz.js +1 -0
  48. package/assets/{label-Z506NKsW.js → label-B1wVTLjK.js} +1 -1
  49. package/assets/list-C07llS61.js +1 -0
  50. package/assets/{list-table-DB1sEQLF.js → list-table-Bh8E-zkN.js} +11 -16
  51. package/assets/{login-DrGaTWhY.js → login-Dl59_ycU.js} +1 -1
  52. package/assets/manifest.json +735 -564
  53. package/assets/{material-icon-CItZiB53.js → material-icon-C9IuCi5R.js} +1 -1
  54. package/assets/module-DwX7rlQ2.js +1 -0
  55. package/assets/{monaco-editor-DqAqwxw4.js → monaco-editor-DjLNSn-O.js} +1 -1
  56. package/assets/{multi-select-oabtVhUP.js → multi-select-CvcWwfki.js} +2 -2
  57. package/assets/{nav-footer-CM-yHiRs.js → nav-footer-C7_pEHmX.js} +1 -1
  58. package/assets/{nav-main-Q3xofGRT.js → nav-main-CwwCPIYf.js} +1 -1
  59. package/assets/{nav-user-Ds8i0Pa2.js → nav-user-K0xXPEmb.js} +1 -1
  60. package/assets/{pagination-render-B57pOpFy.js → pagination-render-BYBw11L4.js} +1 -1
  61. package/assets/pencil-CewBKDRo.js +6 -0
  62. package/assets/{popover-I249Gg2O.js → popover-vHKm7zkm.js} +1 -1
  63. package/assets/{register-C9FQIDtS.js → register-CRsK6KgL.js} +1 -1
  64. package/assets/{select-D1N8zRPY.js → select-Bs9mijkr.js} +2 -2
  65. package/assets/{sidebar-4D-sX2l4.js → sidebar-DflSp1X1.js} +2 -2
  66. package/assets/skeleton-C6UluiCK.js +1 -0
  67. package/assets/{sonner-Dzckw3U3.js → sonner-Cn7ueXZc.js} +1 -1
  68. package/assets/{toast-editor-FbrFd1ft.js → toast-editor-FNxkBiFw.js} +1 -1
  69. package/assets/{tooltip-D2ehgLlB.js → tooltip-BlR1mf2V.js} +1 -1
  70. package/assets/{use-appearance-Co6mO0dV.js → use-appearance-CL1-5ZfQ.js} +1 -1
  71. package/assets/{use-window-size-B8l6Bpkf.js → use-window-size-ciZdUHrJ.js} +1 -1
  72. package/assets/{user-info-DBYoAJYJ.js → user-info-qduQAMOl.js} +2 -2
  73. package/assets/{user-menu-content-qkvdkUVd.js → user-menu-content-Cjq658jE.js} +2 -2
  74. package/assets/welcome-CbHEVD33.js +1 -0
  75. package/controllers/add.js +9 -10
  76. package/controllers/addGroup.js +2 -4
  77. package/controllers/addUser.js +4 -6
  78. package/controllers/catalog/Catalog.d.ts +1 -1
  79. package/controllers/catalog/Catalog.js +42 -34
  80. package/controllers/catalog/FrontentCatalogAdapter.d.ts +43 -21
  81. package/controllers/catalog/FrontentCatalogAdapter.js +49 -30
  82. package/controllers/ckeditorUpload.js +2 -3
  83. package/controllers/dashboard.js +16 -2
  84. package/controllers/edit.js +4 -5
  85. package/controllers/editGroup.js +2 -4
  86. package/controllers/editUser.js +3 -5
  87. package/controllers/form.js +2 -3
  88. package/controllers/getAllWidgets.js +3 -3
  89. package/controllers/initUser.js +1 -2
  90. package/controllers/list.js +6 -6
  91. package/controllers/login.js +31 -15
  92. package/controllers/media-manager/mediaManagerAdapter.js +1 -2
  93. package/controllers/media-manager/mediaManagerApi.js +2 -2
  94. package/controllers/navigation/edit.js +2 -2
  95. package/controllers/register.js +1 -4
  96. package/controllers/remove.js +3 -3
  97. package/controllers/timezones.js +1 -1
  98. package/controllers/view.js +3 -3
  99. package/controllers/welcome.js +1 -1
  100. package/controllers/widgets/Action.js +2 -2
  101. package/controllers/widgets/Custom.js +2 -2
  102. package/controllers/widgets/Info.js +2 -2
  103. package/controllers/widgets/switch.js +2 -2
  104. package/controllers/widgetsDB.js +5 -5
  105. package/helpers/JsUtils.d.ts +1 -0
  106. package/helpers/JsUtils.js +3 -0
  107. package/helpers/accessRightsHelper.d.ts +6 -2
  108. package/helpers/accessRightsHelper.js +26 -3
  109. package/helpers/configHelper.js +2 -1
  110. package/helpers/controllerHelper.js +1 -1
  111. package/helpers/fieldsHelper.d.ts +4 -3
  112. package/helpers/fieldsHelper.js +5 -1
  113. package/helpers/inertiaActionsHelper.js +1 -1
  114. package/helpers/inertiaAddHelper.d.ts +3 -4
  115. package/helpers/inertiaAddHelper.js +27 -7
  116. package/helpers/inertiaFromHelper.js +2 -0
  117. package/helpers/inertiaGroupHelper.d.ts +4 -2
  118. package/helpers/inertiaGroupHelper.js +1 -1
  119. package/helpers/inertiaListHelper.js +5 -5
  120. package/helpers/inertiaMenuHelper.d.ts +1 -1
  121. package/helpers/inertiaMenuHelper.js +2 -2
  122. package/helpers/inertiaUserHelper.d.ts +7 -1
  123. package/helpers/inertiaUserHelper.js +5 -1
  124. package/helpers/menuHelper.d.ts +4 -3
  125. package/helpers/menuHelper.js +22 -15
  126. package/index.d.ts +5 -3
  127. package/index.js +8 -3
  128. package/interfaces/adminpanelConfig.d.ts +28 -31
  129. package/interfaces/global.d.ts +10 -28
  130. package/interfaces/types.d.ts +1 -1
  131. package/lib/Adminizer.d.ts +4 -2
  132. package/lib/Adminizer.js +32 -10
  133. package/lib/media-manager/AbstractMediaManager.d.ts +2 -2
  134. package/lib/media-manager/AbstractMediaManager.js +1 -1
  135. package/lib/media-manager/Items.js +0 -3
  136. package/lib/requestProcessor.js +10 -3
  137. package/lib/v4/DataAccessor.d.ts +5 -2
  138. package/lib/v4/DataAccessor.js +44 -19
  139. package/lib/v4/I18n.js +2 -0
  140. package/lib/v4/POWCaptcha.js +0 -1
  141. package/lib/v4/PolicyManager.js +0 -1
  142. package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +87 -31
  143. package/lib/{catalog → v4/catalog}/AbstractCatalog.js +38 -34
  144. package/lib/v4/catalog/Navigation.d.ts +43 -0
  145. package/lib/v4/catalog/Navigation.js +462 -0
  146. package/lib/{controls → v4/controls}/AbstractControls.d.ts +1 -1
  147. package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.d.ts +1 -1
  148. package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.d.ts +1 -1
  149. package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.d.ts +1 -1
  150. package/lib/{controls → v4/controls}/markdown/ToastUiEditor.d.ts +1 -1
  151. package/lib/{controls → v4/controls}/table/Handsontable.d.ts +1 -1
  152. package/lib/{controls → v4/controls}/wysiwyg/CKeditor.d.ts +1 -1
  153. package/lib/{datatable → v4/datatable}/NodeTable.d.ts +3 -3
  154. package/lib/{datatable → v4/datatable}/NodeTable.js +8 -8
  155. package/lib/v4/helper/jwt.d.ts +10 -0
  156. package/lib/v4/helper/jwt.js +18 -0
  157. package/lib/{inertia → v4/inertia}/inertiaAdapter.js +0 -1
  158. package/lib/v4/model/AbstractModel.d.ts +5 -1
  159. package/lib/v4/model/AbstractModel.js +2 -3
  160. package/lib/v4/model/ModelHandler.js +1 -1
  161. package/lib/v4/model/adapter/sequelize.d.ts +11 -2
  162. package/lib/v4/model/adapter/sequelize.js +451 -118
  163. package/lib/v4/model/adapter/waterline.js +5 -3
  164. package/lib/{widgets → v4/widgets}/abstractAction.d.ts +1 -1
  165. package/lib/v4/widgets/abstractCustom.d.ts +28 -0
  166. package/lib/v4/widgets/abstractCustom.js +9 -0
  167. package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +1 -1
  168. package/lib/{widgets → v4/widgets}/abstractInfo.js +1 -1
  169. package/lib/{widgets → v4/widgets}/abstractLink.d.ts +2 -1
  170. package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +1 -1
  171. package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +2 -2
  172. package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +29 -5
  173. package/lib/{widgets → v4/widgets}/widgetHandler.js +25 -25
  174. package/models/GroupAP.d.ts +8 -0
  175. package/models/NavigationAP.d.ts +7 -3
  176. package/models/NavigationAP.js +5 -6
  177. package/models/UserAP.d.ts +24 -2
  178. package/models/UserAP.js +2 -2
  179. package/package.json +25 -13
  180. package/policies/checkAuth.js +4 -3
  181. package/policies/setLocale.js +2 -2
  182. package/system/Router.js +8 -16
  183. package/system/bindAccessRights.js +0 -4
  184. package/system/bindAuthorization.js +4 -5
  185. package/system/bindControls.js +6 -6
  186. package/system/bindDev.js +1 -0
  187. package/system/bindInertia.js +12 -11
  188. package/system/bindMediaManager.js +0 -1
  189. package/system/bindModels.js +7 -2
  190. package/system/bindNavigation.d.ts +2 -0
  191. package/system/bindNavigation.js +42 -42
  192. package/system/bindReqFunctions.js +15 -0
  193. package/translations/ru.json +17 -8
  194. package/assets/add-ZITr43GJ.js +0 -1
  195. package/assets/add-form-CYOfr0Ef.js +0 -1
  196. package/assets/add-group-B332wN8K.js +0 -1
  197. package/assets/add-user-TC-mYdsB.js +0 -1
  198. package/assets/add-user-form-y2f_1_lM.js +0 -1
  199. package/assets/app-layout-D1m9Kvxq.js +0 -1
  200. package/assets/app-sidebar-BCtaEFGb.js +0 -1
  201. package/assets/dashboard-BR602KhL.js +0 -1
  202. package/assets/form-DOUNk3o2.js +0 -1
  203. package/assets/form-lOKv4Qbw.js +0 -1
  204. package/assets/home-Ch6QfTIt.js +0 -2
  205. package/assets/index-Cdb9ACvz.js +0 -1
  206. package/assets/index-K81GbF6O.js +0 -1
  207. package/assets/list-Qyd7ecQH.js +0 -1
  208. package/assets/module-DBaykv8l.js +0 -1
  209. package/assets/welcome-D2adQ8EU.js +0 -1
  210. package/controllers/processInstallFinalize.d.ts +0 -1
  211. package/controllers/processInstallFinalize.js +0 -16
  212. package/controllers/processInstallStep.d.ts +0 -1
  213. package/controllers/processInstallStep.js +0 -132
  214. package/lib/catalog/Navigation.d.ts +0 -0
  215. package/lib/catalog/Navigation.js +0 -532
  216. package/lib/installStepper/InstallStepAbstract.d.ts +0 -52
  217. package/lib/installStepper/InstallStepAbstract.js +0 -69
  218. package/lib/installStepper/finalizeStep.d.ts +0 -21
  219. package/lib/installStepper/finalizeStep.js +0 -48
  220. package/lib/installStepper/installStepper.d.ts +0 -40
  221. package/lib/installStepper/installStepper.js +0 -195
  222. package/lib/widgets/abstractCustom.d.ts +0 -13
  223. package/lib/widgets/abstractCustom.js +0 -3
  224. package/models/MediaManagerAP.d.ts +0 -46
  225. package/models/MediaManagerAP.js +0 -45
  226. package/models/MediaManagerAssociationsAP.d.ts +0 -28
  227. package/models/MediaManagerAssociationsAP.js +0 -27
  228. package/models/MediaManagerMetaAP.d.ts +0 -22
  229. package/models/MediaManagerMetaAP.js +0 -21
  230. package/system/bindInstallStepper.d.ts +0 -2
  231. package/system/bindInstallStepper.js +0 -23
  232. /package/lib/{catalog → v4/catalog}/CatalogHandler.d.ts +0 -0
  233. /package/lib/{catalog → v4/catalog}/CatalogHandler.js +0 -0
  234. /package/lib/{controls → v4/controls}/AbstractControls.js +0 -0
  235. /package/lib/{controls → v4/controls}/ControlsHandler.d.ts +0 -0
  236. /package/lib/{controls → v4/controls}/ControlsHandler.js +0 -0
  237. /package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.js +0 -0
  238. /package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.js +0 -0
  239. /package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.js +0 -0
  240. /package/lib/{controls → v4/controls}/markdown/ToastUiEditor.js +0 -0
  241. /package/lib/{controls → v4/controls}/table/Handsontable.js +0 -0
  242. /package/lib/{controls → v4/controls}/wysiwyg/CKeditor.js +0 -0
  243. /package/lib/{inertia → v4/inertia}/flash.d.ts +0 -0
  244. /package/lib/{inertia → v4/inertia}/flash.js +0 -0
  245. /package/lib/{inertia → v4/inertia}/inertiaAdapter.d.ts +0 -0
  246. /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
  247. /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
  248. /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
  249. /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { AbstractModel } from "../lib/v4/model/AbstractModel";
2
2
  import { ModelConfig } from "./adminpanelConfig";
3
- export type EntityType = "form" | "model" | "wizard";
3
+ export type EntityType = "form" | "model";
4
4
  export interface Entity {
5
5
  name: string;
6
6
  config?: ModelConfig;
@@ -4,13 +4,13 @@ import EventEmitter from 'events';
4
4
  import { AdminpanelConfig } from "../interfaces/adminpanelConfig";
5
5
  import PolicyManager from "./v4/PolicyManager";
6
6
  import { ModelHandler } from "./v4/model/ModelHandler";
7
- import { WidgetHandler } from "./widgets/widgetHandler";
7
+ import { WidgetHandler } from "./v4/widgets/widgetHandler";
8
8
  import { AccessRightsHelper } from "../helpers/accessRightsHelper";
9
9
  import { ConfigHelper } from "../helpers/configHelper";
10
10
  import { AbstractAdapter } from "./v4/model/AbstractModel";
11
11
  import { ViteDevServer } from 'vite';
12
12
  import { MenuHelper } from "../helpers/menuHelper";
13
- import { ControlsHandler } from "./controls/ControlsHandler";
13
+ import { ControlsHandler } from "./v4/controls/ControlsHandler";
14
14
  export declare class Adminizer {
15
15
  app: Express;
16
16
  config: AdminpanelConfig;
@@ -24,8 +24,10 @@ export declare class Adminizer {
24
24
  widgetHandler: WidgetHandler;
25
25
  vite: ViteDevServer;
26
26
  controlsHandler: ControlsHandler;
27
+ jwtSecret: string;
27
28
  static logger: winston.Logger;
28
29
  constructor(ormAdapters: AbstractAdapter[]);
30
+ getMiddleware(): (req: any, res: any) => void;
29
31
  /**
30
32
  * Vite middleware
31
33
  * @protected
package/lib/Adminizer.js CHANGED
@@ -9,7 +9,7 @@ import Router from "./../system/Router";
9
9
  import bindAssets from "../system/bindAssets";
10
10
  import bindDev from "../system/bindDev";
11
11
  import bindDashboardWidgets from "../system/bindDashboardWidgets";
12
- // import bindNavigation from "../system/bindNavigation";
12
+ import bindNavigation from "../system/bindNavigation";
13
13
  // import bindMediaManager from "../system/bindMediaManager";
14
14
  import bindAccessRights from "../system/bindAccessRights";
15
15
  import bindAuthorization from "../system/bindAuthorization";
@@ -17,7 +17,7 @@ import bindModels from "../system/bindModels";
17
17
  import bindForms from "../system/bindForms";
18
18
  import bindTranslations from "../system/bindTranslations";
19
19
  import { ModelHandler } from "./v4/model/ModelHandler";
20
- import { WidgetHandler } from "./widgets/widgetHandler";
20
+ import { WidgetHandler } from "./v4/widgets/widgetHandler";
21
21
  import { AccessRightsHelper } from "../helpers/accessRightsHelper";
22
22
  import bindReqFunctions from "../system/bindReqFunctions";
23
23
  import { ConfigHelper } from "../helpers/configHelper";
@@ -28,7 +28,8 @@ import { createServer as createViteServer } from 'vite';
28
28
  import { bindInertia } from "../system/bindInertia";
29
29
  import { MenuHelper } from "../helpers/menuHelper";
30
30
  import { bindControls } from "../system/bindControls";
31
- import { ControlsHandler } from "./controls/ControlsHandler";
31
+ import { ControlsHandler } from "./v4/controls/ControlsHandler";
32
+ import { v4 as uuid } from "uuid";
32
33
  export class Adminizer {
33
34
  app;
34
35
  config;
@@ -42,8 +43,9 @@ export class Adminizer {
42
43
  widgetHandler;
43
44
  vite;
44
45
  controlsHandler;
46
+ jwtSecret = process.env.JWT_SECRET ?? uuid();
45
47
  static logger = winston.createLogger({
46
- level: "info",
48
+ level: process.env.LOG_LEVEL ?? "debug",
47
49
  format: winston.format.combine(winston.format.timestamp(), winston.format.printf(({ timestamp, level, message, ...meta }) => {
48
50
  const metaString = Object.keys(meta).length ? JSON.stringify(meta) : "";
49
51
  return `[${timestamp}] ${level.toUpperCase()}: ${message} ${metaString}`;
@@ -58,6 +60,21 @@ export class Adminizer {
58
60
  this._emitter = new EventEmitter();
59
61
  this.ormAdapters = ormAdapters;
60
62
  }
63
+ getMiddleware() {
64
+ return (req, res) => {
65
+ this.app(req, res, (err) => {
66
+ if (err) {
67
+ console.error("Error in Adminizer", err);
68
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
69
+ res.end('Internal Server Error');
70
+ }
71
+ else {
72
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
73
+ res.end('Route Not Found in Adminizer');
74
+ }
75
+ });
76
+ };
77
+ }
61
78
  /**
62
79
  * Vite middleware
63
80
  * @protected
@@ -76,6 +93,9 @@ export class Adminizer {
76
93
  async init(config) {
77
94
  // set cookie parser
78
95
  this.app.use(cookieParser());
96
+ if (!config || Object.keys(config).length === 0) {
97
+ Adminizer.log.warn(`Adminizer init > Adminizer config is emtpy`);
98
+ }
79
99
  // Set vite middleware
80
100
  const isViteDev = process.env.VITE_ENV === "dev";
81
101
  if (isViteDev)
@@ -105,28 +125,30 @@ export class Adminizer {
105
125
  set: configForms.set ?? defaultForms.set
106
126
  }
107
127
  };
108
- // console.log("CONFIG", this.config)
109
128
  this.modelHandler = new ModelHandler();
129
+ // TODO: 'hot reload' unbind models & unbind forms
110
130
  await bindModels(this);
111
131
  await bindForms(this);
112
132
  this.config.rootPath = path.resolve(import.meta.dirname + "/..");
113
133
  this.policyManager = new PolicyManager(this);
114
134
  await this.policyManager.loadPolicies();
135
+ // TODO: 'hot reload' problem with deleting access right tokens
115
136
  this.accessRightsHelper = new AccessRightsHelper(this);
137
+ // Helpers go to construtor
116
138
  this.configHelper = new ConfigHelper(this);
117
139
  this.menuHelper = new MenuHelper(this.config);
118
140
  this.widgetHandler = new WidgetHandler(this);
119
141
  bindExpressUtils(this.app);
120
142
  bindReqFunctions(this);
121
- // add install stepper policy to check unfilled settings
122
- // bindInstallStepper(this); // TODO It is necessary to provide an opportunity to be inserted by an intermediary after authorization, but before the admin panel, in order to block the user from managing the Installstepper's admin panel.
123
143
  // Bind assets
124
144
  bindAssets(this.app, this.config.routePrefix);
125
- if ((process.env.DEV && process.env.NODE_ENV !== 'production') || process.env.ADMINPANEL_FORCE_BIND_DEV === "TRUE") {
126
- bindDev(this);
145
+ if (!process.env.VITEST) {
146
+ if ((process.env.DEV && process.env.NODE_ENV !== 'production') || process.env.ADMINPANEL_FORCE_BIND_DEV === "TRUE") {
147
+ bindDev(this);
148
+ }
127
149
  }
128
150
  await bindDashboardWidgets(this);
129
- // bindNavigation(this);
151
+ bindNavigation(this);
130
152
  // bindMediaManager(this);
131
153
  await bindAccessRights(this);
132
154
  if (I18n.appendLocale) {
@@ -143,10 +143,10 @@ export declare abstract class AbstractMediaManager {
143
143
  uloadAllowedTypes: string[];
144
144
  dir: string;
145
145
  /**
146
- * Разрешает или нет поиск по названию
146
+
147
147
  */
148
148
  allowSearch: boolean;
149
- /** ⚠️ ВЫШЕ НАСТРОЙКИ КОТОРЫЕ НАДО РЕАЛИЗОВАТЬ */
149
+ /**⚠️ above the settings that need to be implemented*/
150
150
  /**
151
151
  * id for mediamanager instance
152
152
  */
@@ -34,7 +34,7 @@ export class AbstractMediaManager {
34
34
  uloadAllowedTypes;
35
35
  dir;
36
36
  /**
37
- * Разрешает или нет поиск по названию
37
+
38
38
  */
39
39
  allowSearch;
40
40
  itemTypes = [];
@@ -324,12 +324,9 @@
324
324
  // try {
325
325
  // await fs.promises.access(file);
326
326
  // await fs.promises.unlink(file);
327
- // console.log('The file was successfully deleted');
328
327
  // } catch (err) {
329
328
  // if (err.code === 'ENOENT') {
330
- // console.log('The file does not exist');
331
329
  // } else if (err.code === 'EPERM') {
332
- // console.log('You do not have permission to delete this file');
333
330
  // } else {
334
331
  // console.error(`An error occurred: ${err}`);
335
332
  // }
@@ -1,3 +1,4 @@
1
+ import { isObject } from "../helpers/JsUtils";
1
2
  import { Adminizer } from "./Adminizer";
2
3
  /**
3
4
  * Default helper that will contain all methods
@@ -29,11 +30,17 @@ export class RequestProcessor {
29
30
  }
30
31
  for (let key in postParams) {
31
32
  let field = fields[key];
32
- if (field.model.type === 'boolean') {
33
- postParams[key] = ['true', '1', 'yes', "TRUE", "on"].includes(postParams[key].toString().toLowerCase());
34
- continue;
33
+ if (key === 'sort') {
34
+ console.log(fields[key], key, postParams[key]);
35
35
  }
36
+ // if (field.model.type === 'boolean') {
37
+ // postParams[key] = ['true', '1', 'yes', "TRUE", "on"].includes(postParams[key].toString().toLowerCase());
38
+ // continue;
39
+ // }
36
40
  if (field.model.type === 'number') {
41
+ if (isObject(field.config) && field.config.type === "boolean" && typeof postParams[key] === "boolean") {
42
+ postParams[key] = postParams[key] ? 1 : 0;
43
+ }
37
44
  postParams[key] = parseFloat(postParams[key]);
38
45
  }
39
46
  if (field.model.type === 'json') {
@@ -4,13 +4,16 @@
4
4
  import { Entity } from "../../interfaces/types";
5
5
  import { ActionType } from "../../interfaces/adminpanelConfig";
6
6
  import { Fields } from "../../helpers/fieldsHelper";
7
+ import { Adminizer } from "../Adminizer";
8
+ import { UserAP } from "models/UserAP";
7
9
  export declare class DataAccessor {
8
10
  private readonly adminizer;
9
- user: ModelsAP["UserAP"];
11
+ user: UserAP;
10
12
  entity: Entity;
11
13
  action: ActionType;
12
14
  private fields;
13
- constructor(req: ReqType, entity: Entity, action: ActionType);
15
+ private actionVerb;
16
+ constructor(adminizer: Adminizer, user: UserAP, entity: Entity, action: ActionType);
14
17
  /**
15
18
  * Retrieves the fields for the given entity based on action type,
16
19
  * taking into account access rights and configuration settings.
@@ -1,16 +1,19 @@
1
1
  import { ControllerHelper } from "../../helpers/controllerHelper";
2
2
  import { Adminizer } from "../Adminizer";
3
+ import { isObject } from "../../helpers/JsUtils";
3
4
  export class DataAccessor {
4
5
  adminizer;
5
6
  user;
6
7
  entity;
7
8
  action;
8
9
  fields = null;
9
- constructor(req, entity, action) {
10
- this.adminizer = req.adminizer;
11
- this.user = req.session.UserAP;
10
+ actionVerb;
11
+ constructor(adminizer, user, entity, action) {
12
+ this.adminizer = adminizer;
13
+ this.user = user;
12
14
  this.entity = entity;
13
15
  this.action = action;
16
+ this.actionVerb = getTokenAction(this.action);
14
17
  }
15
18
  /**
16
19
  * Retrieves the fields for the given entity based on action type,
@@ -26,10 +29,19 @@ export class DataAccessor {
26
29
  }
27
30
  // get action and field configs
28
31
  const actionConfig = ControllerHelper.findActionConfig(this.entity, this.action);
29
- const fieldsConfig = this.entity.config.fields || {};
32
+ const fieldsConfig = this.entity.config?.fields || {};
30
33
  const modelAttributes = this.entity.model.attributes;
34
+ const tokenId = `${this.actionVerb}-${this.entity.model.modelname}-${this.entity.type}`;
35
+ if (!this.adminizer.accessRightsHelper.hasPermission(tokenId, this.user)) {
36
+ Adminizer.log.debug(`getFieldsConfig > No access rights to ${this.actionVerb} ${this.entity.type}: ${this.entity.model.modelname}`);
37
+ return undefined;
38
+ }
31
39
  const result = {};
32
40
  Object.entries(modelAttributes).forEach(([key, modelField]) => {
41
+ // The fields that are recorded separately from the connection in some ORMs, because they are processed at the level above them.
42
+ if (modelAttributes[key].primaryKeyForAssociation === true) {
43
+ return undefined;
44
+ }
33
45
  // Checks for short type in Waterline: fieldName: 'string'
34
46
  if (typeof modelField === "string") {
35
47
  modelField = { type: modelField };
@@ -45,6 +57,7 @@ export class DataAccessor {
45
57
  }
46
58
  // Getting base field config
47
59
  let fldConfig = { key: key, title: key };
60
+ let associatedModelConfig = undefined;
48
61
  /** Combine the field configuration from global and action-specific configs
49
62
  * (now combine it before check, earlier was opposite).
50
63
  * Action-specific config should overwrite the global one */
@@ -66,42 +79,52 @@ export class DataAccessor {
66
79
  let populatedModelFieldsConfig = {};
67
80
  if (modelField.type === "association" || modelField.type === "association-many") {
68
81
  const modelName = modelField.model || modelField.collection;
82
+ const tokenId = `read-${modelName}-${this.entity.type}`;
83
+ if (!this.adminizer.accessRightsHelper.hasPermission(tokenId, this.user)) {
84
+ Adminizer.log.silly(`No access rights to ${this.entity.type}: ${this.entity.model.modelname}`);
85
+ return undefined;
86
+ }
69
87
  if (modelName) {
70
- const Model = this.adminizer.modelHandler.model.get(modelName);
71
- if (Model) {
88
+ const model = this.adminizer.modelHandler.model.get(modelName);
89
+ if (model) {
72
90
  populatedModelFieldsConfig = this.getAssociatedFieldsConfig(modelName);
91
+ let _modelConfig = this.adminizer.config.models[modelName];
92
+ if (!isObject(_modelConfig))
93
+ throw `type error: model config of ${modelName} is ${typeof (this.adminizer.config.models[modelName])} expected object`;
94
+ associatedModelConfig = _modelConfig;
73
95
  }
74
96
  else {
75
- Adminizer.log.error(`Model not found: ${modelName}`);
97
+ Adminizer.log.error(`DataAccessor > getFieldsConfig > Model not found: ${modelName} when ${key}`);
76
98
  }
77
99
  }
78
100
  }
79
101
  // Set required and type attributes
80
- fldConfig.required = Boolean(fldConfig.required || modelField.required);
102
+ fldConfig.required = Boolean(fldConfig.required ?? modelField.required);
81
103
  // Default type for field. Could be fetched form config file or file model if not defined in config file.
82
104
  fldConfig.type = (fldConfig.type || modelField.type).toLowerCase();
83
105
  // Normalize final configuration
84
106
  fldConfig = this.adminizer.configHelper.normalizeFieldConfig(this.adminizer, fldConfig, key, modelField);
85
107
  // Add new field to result set
86
- result[key] = { config: fldConfig, model: modelField, populated: populatedModelFieldsConfig };
108
+ result[key] = { config: fldConfig, model: modelField, populated: populatedModelFieldsConfig, modelConfig: associatedModelConfig };
87
109
  });
88
110
  this.fields = result;
89
111
  return result;
90
112
  }
91
113
  getAssociatedFieldsConfig(modelName) {
92
- const Model = this.adminizer.modelHandler.model.get(modelName);
93
- if (!Model || !this.adminizer.config.models[modelName] || typeof this.adminizer.config.models[modelName] === "boolean") {
114
+ const model = this.adminizer.modelHandler.model.get(modelName);
115
+ if (!model || !this.adminizer.config.models[modelName] || typeof this.adminizer.config.models[modelName] === "boolean") {
94
116
  return undefined;
95
117
  }
96
118
  // Check if user has access to the associated model
97
- const actionVerb = getTokenAction(this.action);
98
- const tokenId = `${actionVerb}-${modelName}-${this.entity.type}`;
119
+ const tokenId = `read-${modelName}-${this.entity.type}`;
99
120
  if (!this.adminizer.accessRightsHelper.hasPermission(tokenId, this.user)) {
100
- Adminizer.log.warn(`No access rights to ${this.entity.type}: ${modelName}`);
121
+ Adminizer.log.debug(`getAssociatedFieldsConfig > No access rights to ${this.actionVerb} ${this.entity.type}: ${modelName}`);
101
122
  return undefined;
102
123
  }
103
124
  const associatedFields = {};
104
125
  const modelConfig = this.adminizer.config.models[modelName];
126
+ if (!isObject(modelConfig))
127
+ throw `Type error ModelConfig should is object`;
105
128
  // Get the main fields configuration
106
129
  const fieldsConfig = modelConfig.fields || {};
107
130
  // Merge action-specific fields configuration if it exists
@@ -129,7 +152,7 @@ export class DataAccessor {
129
152
  }
130
153
  const mergedFieldsConfig = { ...fieldsConfig, ...actionSpecificConfig };
131
154
  // Loop through model attributes and apply access checks
132
- Object.entries(Model.attributes).forEach(([key, modelField]) => {
155
+ Object.entries(model.attributes).forEach(([key, modelField]) => {
133
156
  const fieldConfig = mergedFieldsConfig[key];
134
157
  // Creating a basic config
135
158
  let fldConfig = { key: key, title: key };
@@ -146,6 +169,7 @@ export class DataAccessor {
146
169
  config: fldConfig,
147
170
  model: modelField,
148
171
  populated: undefined, // set undefined for already populated fields
172
+ modelConfig: undefined
149
173
  };
150
174
  });
151
175
  return associatedFields;
@@ -327,7 +351,7 @@ export class DataAccessor {
327
351
  throw new Error(`No intermediate record found in model "${intermediateRelation.model}" associated with user ID "${this.user.id}"`);
328
352
  }
329
353
  // Ensure there is only one associated intermediate record
330
- const intermediateRecordCount = await intermediateModel.count({ [via]: this.user.id });
354
+ const intermediateRecordCount = await intermediateModel.count({ [via]: this.user.id }, this);
331
355
  if (intermediateRecordCount > 1) {
332
356
  throw new Error(`Multiple intermediate records found in model "${intermediateRelation.model}" associated with user ID "${this.user.id}". ` +
333
357
  `Expected only one`);
@@ -363,10 +387,11 @@ export class DataAccessor {
363
387
  const relation = modelAttributes[accessField];
364
388
  if (relation && ['userap', 'groupap'].includes(relation.model.toLowerCase())) {
365
389
  if (relation.model.toLowerCase() === 'userap') {
366
- updatedRecord[accessField] = this.user.id;
390
+ if (!this.user.isAdministrator) {
391
+ updatedRecord[accessField] = this.user.id;
392
+ }
367
393
  }
368
394
  else if (relation.model.toLowerCase() === 'groupap') {
369
- // Works only for users with only one group, later it can be resolved with group weight
370
395
  const userGroups = this.user.groups || [];
371
396
  if (userGroups.length === 1) {
372
397
  updatedRecord[accessField] = userGroups[0].id;
@@ -409,7 +434,7 @@ export class DataAccessor {
409
434
  throw new Error(`No intermediate record found in model "${intermediateRelation.model}" linking user "${this.user.id}" to the main record`);
410
435
  }
411
436
  // Ensure there is only one associated intermediate record
412
- const intermediateRecordCount = await intermediateModel.count({ [via]: this.user.id });
437
+ const intermediateRecordCount = await intermediateModel.count({ [via]: this.user.id }, this);
413
438
  if (intermediateRecordCount > 1) {
414
439
  throw new Error(`Multiple intermediate records found in model "${intermediateRelation.model}" associated with user ID "${this.user.id}". ` +
415
440
  `Expected only one`);
package/lib/v4/I18n.js CHANGED
@@ -104,7 +104,9 @@ export class I18n {
104
104
  return;
105
105
  const file = this.locateFile(locale);
106
106
  const tmpFile = `${file}.tmp`;
107
+ const dir = path.dirname(file);
107
108
  try {
109
+ fs.mkdirSync(dir, { recursive: true });
108
110
  fs.writeFileSync(tmpFile, JSON.stringify(I18n.locales[locale], null, this.indent), "utf8");
109
111
  fs.renameSync(tmpFile, file);
110
112
  }
@@ -54,7 +54,6 @@ export class POWCaptcha {
54
54
  if (!task || task.label !== label)
55
55
  return false;
56
56
  // Verify the solution (should be equal to puzzleOptions.message)
57
- // console.log("QUESTION", `${taskId}:${label}`)
58
57
  if (`${taskId}:${label}` === captchaSolution) {
59
58
  this.deleteTask(taskId);
60
59
  return true;
@@ -27,7 +27,6 @@ class PolicyManager {
27
27
  Adminizer.log.info("Adminizer policies loaded");
28
28
  }
29
29
  catch (e) {
30
- console.log(e);
31
30
  Adminizer.log.error("Adminizer > Could not load policies", e);
32
31
  }
33
32
  }