adminizer 4.6.0 → 4.7.0-build.221

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 (335) hide show
  1. package/Readme.md +12 -0
  2. package/assets/RelationDialogStack-CnHFOYyR.css +1 -0
  3. package/assets/RelationDialogStack-DI2bZxQX.js +20 -0
  4. package/assets/add-4213XScp.js +1 -0
  5. package/assets/add-group--F1XxfJ1.js +1 -0
  6. package/assets/add-group-form-DKRXC2n-.js +1 -0
  7. package/assets/add-user-b9HfMq7z.js +1 -0
  8. package/assets/add-user-form-UXAToWQd.js +1 -0
  9. package/assets/app-Clx8f5hd.css +1 -0
  10. package/assets/app-layout-C02ja4OI.js +1 -0
  11. package/assets/app-shell-D8wtkECO.js +1 -0
  12. package/assets/app-sidebar-BR5_zwxj.js +1 -0
  13. package/assets/app-sidebar-header-BZbIBQjq.js +1 -0
  14. package/assets/app.js +59 -7990
  15. package/assets/breadcrumbs-CODaqVkB.js +1 -0
  16. package/assets/catalog-6ZZjWdFs.js +6 -0
  17. package/assets/dashboard-CftAdKiH.js +3 -0
  18. package/assets/date-picker-DSOkNiNo.js +1 -0
  19. package/assets/del-modal-Cd4M7af8.js +1 -0
  20. package/assets/dynamic-controls-BsrJhPDY.js +1 -0
  21. package/assets/geo-json-CzR5JBXL.js +1 -0
  22. package/assets/handsontable-BI98OF5R.js +336 -0
  23. package/assets/history-DLHSU7Ak.js +1 -0
  24. package/assets/home-NcQ7nnU0.js +2 -0
  25. package/assets/icon-C2JNaLxH.js +1 -0
  26. package/assets/init-user-D2HSyXup.js +1 -0
  27. package/assets/input-error-CH2caTtO.js +1 -0
  28. package/assets/jsoneditor-DVNQmA6G.js +3869 -0
  29. package/assets/list-CFU0-TgN.js +4 -0
  30. package/assets/login-DFSLEO17.js +1 -0
  31. package/assets/manifest.json +246 -273
  32. package/assets/material-icon-Bx9pGQiQ.js +1 -0
  33. package/assets/media-manager-WcKe1EvD.js +6 -0
  34. package/assets/module-CT7PC6pc.js +1 -0
  35. package/assets/monaco-Bl4zdWCn.js +11 -0
  36. package/assets/nav-footer-BiSQkPt4.js +1 -0
  37. package/assets/nav-main-rTH0PfDw.js +1 -0
  38. package/assets/nav-user-Bj6cWs0a.js +1 -0
  39. package/assets/notification-Bi-PX87D.js +20 -0
  40. package/assets/pagination-render-AKJvTIRA.js +1 -0
  41. package/assets/register-BTP4uxsK.js +1 -0
  42. package/assets/ru-eW0WKkga.js +1 -0
  43. package/assets/theme-switcher-Dm8EOGzx.js +1 -0
  44. package/assets/toast-editor-DOg_gvSp.js +668 -0
  45. package/assets/user-filters-list-YUfR4XMI.js +1 -0
  46. package/assets/user-info-BgSbT02v.js +1 -0
  47. package/assets/user-menu-content-TQTXHIv6.js +1 -0
  48. package/assets/{vanilla-picker-l5rcX3cq.js → vanilla-picker-B3LgXoKV.js} +1 -7
  49. package/assets/welcome-vLwTu1R6.js +1 -0
  50. package/controllers/add.d.ts +1 -1
  51. package/controllers/add.js +20 -26
  52. package/controllers/addGroup.d.ts +1 -1
  53. package/controllers/addGroup.js +7 -15
  54. package/controllers/addUser.d.ts +1 -1
  55. package/controllers/addUser.js +10 -16
  56. package/controllers/catalog/Catalog.d.ts +1 -1
  57. package/controllers/catalog/Catalog.js +1 -10
  58. package/controllers/catalog/FrontendCatalogAdapter.d.ts +3 -3
  59. package/controllers/catalog/FrontendCatalogAdapter.js +0 -6
  60. package/controllers/catalog/FrontentCatalogAdapter.d.ts +3 -3
  61. package/controllers/catalog/FrontentCatalogAdapter.js +0 -4
  62. package/controllers/ckeditorUpload.js +2 -18
  63. package/controllers/dashboard.d.ts +1 -1
  64. package/controllers/dashboard.js +2 -5
  65. package/controllers/edit.js +24 -37
  66. package/controllers/editGroup.d.ts +1 -1
  67. package/controllers/editGroup.js +10 -21
  68. package/controllers/editUser.d.ts +1 -1
  69. package/controllers/editUser.js +11 -23
  70. package/controllers/exportData.d.ts +6 -0
  71. package/controllers/exportData.js +315 -0
  72. package/controllers/feed.d.ts +6 -0
  73. package/controllers/feed.js +73 -0
  74. package/controllers/feedback/feedbackController.d.ts +1 -1
  75. package/controllers/feedback/feedbackController.js +5 -7
  76. package/controllers/filter-fields/columns.d.ts +11 -0
  77. package/controllers/filter-fields/columns.js +106 -0
  78. package/controllers/filter-fields/filterFields.d.ts +10 -0
  79. package/controllers/filter-fields/filterFields.js +141 -0
  80. package/controllers/filter-fields/getAllUserFilters.d.ts +6 -0
  81. package/controllers/filter-fields/getAllUserFilters.js +115 -0
  82. package/controllers/filter-fields/groups.d.ts +5 -0
  83. package/controllers/filter-fields/groups.js +26 -0
  84. package/controllers/filter-fields/savedFilters.d.ts +25 -0
  85. package/controllers/filter-fields/savedFilters.js +317 -0
  86. package/controllers/getAllWidgets.d.ts +1 -1
  87. package/controllers/getAllWidgets.js +1 -9
  88. package/controllers/history-actions/HistoryController.js +6 -31
  89. package/controllers/initUser.js +6 -5
  90. package/controllers/inlineUpdate.d.ts +7 -0
  91. package/controllers/inlineUpdate.js +148 -0
  92. package/controllers/list.d.ts +1 -1
  93. package/controllers/list.js +383 -70
  94. package/controllers/listUserFilters.d.ts +5 -0
  95. package/controllers/listUserFilters.js +26 -0
  96. package/controllers/login.js +2 -2
  97. package/controllers/media-manager/mediaManagerApi.js +0 -9
  98. package/controllers/navigation/edit.js +3 -9
  99. package/controllers/notifications/NotificationController.d.ts +1 -1
  100. package/controllers/notifications/NotificationController.js +12 -36
  101. package/controllers/register.js +10 -9
  102. package/controllers/remove.js +10 -19
  103. package/controllers/timezones.d.ts +1 -1
  104. package/controllers/timezones.js +0 -6
  105. package/controllers/userApiKey.d.ts +7 -0
  106. package/controllers/userApiKey.js +36 -0
  107. package/controllers/view.js +14 -26
  108. package/controllers/welcome.d.ts +1 -1
  109. package/controllers/welcome.js +0 -4
  110. package/controllers/widgets/Action.d.ts +1 -1
  111. package/controllers/widgets/Action.js +1 -9
  112. package/controllers/widgets/Custom.d.ts +1 -1
  113. package/controllers/widgets/Custom.js +1 -9
  114. package/controllers/widgets/Info.d.ts +1 -1
  115. package/controllers/widgets/Info.js +1 -9
  116. package/controllers/widgets/filterInfo.d.ts +1 -0
  117. package/controllers/widgets/filterInfo.js +44 -0
  118. package/controllers/widgets/switch.d.ts +1 -1
  119. package/controllers/widgets/switch.js +1 -9
  120. package/controllers/widgetsDB.d.ts +1 -1
  121. package/controllers/widgetsDB.js +2 -8
  122. package/helpers/accessRightsHelper.d.ts +1 -1
  123. package/helpers/accessRightsHelper.js +5 -4
  124. package/helpers/apiKeyHelper.d.ts +5 -0
  125. package/helpers/apiKeyHelper.js +8 -0
  126. package/helpers/configHelper.js +12 -15
  127. package/helpers/controllerHelper.d.ts +14 -21
  128. package/helpers/controllerHelper.js +50 -83
  129. package/helpers/fieldsHelper.js +3 -3
  130. package/helpers/filterDatetimeHelper.d.ts +5 -0
  131. package/helpers/filterDatetimeHelper.js +84 -0
  132. package/helpers/inertiaActionsHelper.d.ts +2 -2
  133. package/helpers/inertiaActionsHelper.js +5 -4
  134. package/helpers/inertiaAddHelper.d.ts +3 -414
  135. package/helpers/inertiaAddHelper.js +39 -15
  136. package/helpers/inertiaGroupHelper.d.ts +2 -2
  137. package/helpers/inertiaGroupHelper.js +3 -3
  138. package/helpers/inertiaListHelper.d.ts +7 -3
  139. package/helpers/inertiaListHelper.js +26 -12
  140. package/helpers/inertiaMenuHelper.d.ts +1 -0
  141. package/helpers/inertiaMenuHelper.js +15 -3
  142. package/helpers/inertiaUserHelper.d.ts +3 -2
  143. package/helpers/inertiaUserHelper.js +7 -3
  144. package/helpers/menuHelper.d.ts +5 -2
  145. package/helpers/menuHelper.js +64 -12
  146. package/helpers/viteHelper.js +1 -2
  147. package/index.d.ts +6 -2
  148. package/index.js +6 -2
  149. package/interfaces/adminpanelConfig.d.ts +126 -39
  150. package/interfaces/internalModelAccess.d.ts +37 -0
  151. package/interfaces/internalModelAccess.js +1 -0
  152. package/interfaces/listQueryBuilder.d.ts +22 -0
  153. package/interfaces/listQueryBuilder.js +1 -0
  154. package/interfaces/queryCriteria.d.ts +54 -0
  155. package/interfaces/queryCriteria.js +1 -0
  156. package/interfaces/types.d.ts +1 -13
  157. package/lib/Adminizer.d.ts +4 -2
  158. package/lib/Adminizer.js +29 -10
  159. package/lib/DataAccessor.d.ts +8 -5
  160. package/lib/DataAccessor.js +89 -42
  161. package/lib/I18n.d.ts +5 -1
  162. package/lib/I18n.js +45 -19
  163. package/lib/MiddlewareManager.d.ts +8 -0
  164. package/lib/MiddlewareManager.js +53 -0
  165. package/lib/ai-assistant/OpenAiModelService.d.ts +3 -3
  166. package/lib/ai-assistant/OpenAiModelService.js +23 -24
  167. package/lib/catalog/Navigation.d.ts +1 -0
  168. package/lib/catalog/Navigation.js +12 -11
  169. package/lib/controls/jsoneditor/JsonEditor.d.ts +1 -2
  170. package/lib/controls/markdown/ToastUiEditor.d.ts +1 -2
  171. package/lib/feedback/FeedbackHandler.js +2 -2
  172. package/lib/filters/ConditionValidator.d.ts +107 -0
  173. package/lib/filters/ConditionValidator.js +483 -0
  174. package/lib/filters/CustomFilterHandler.d.ts +122 -0
  175. package/lib/filters/CustomFilterHandler.js +131 -0
  176. package/lib/filters/FilterCustomFieldHandler.d.ts +2 -0
  177. package/lib/filters/FilterCustomFieldHandler.js +2 -0
  178. package/lib/filters/FilterService.d.ts +82 -0
  179. package/lib/filters/FilterService.js +323 -0
  180. package/lib/filters/index.d.ts +6 -0
  181. package/lib/filters/index.js +4 -0
  182. package/lib/history-actions/AbstractHistoryAdapter.d.ts +5 -4
  183. package/lib/history-actions/AbstractHistoryAdapter.js +45 -30
  184. package/lib/history-actions/DefaultHistoryAdapter.d.ts +2 -0
  185. package/lib/history-actions/DefaultHistoryAdapter.js +12 -6
  186. package/lib/history-actions/HistoryHandler.js +1 -1
  187. package/lib/list-query-builder/ListQueryBuilder.d.ts +117 -0
  188. package/lib/list-query-builder/ListQueryBuilder.js +707 -0
  189. package/lib/media-manager/AbstractMediaManager.d.ts +9 -8
  190. package/lib/media-manager/DefaultMediaManager.d.ts +2 -0
  191. package/lib/media-manager/DefaultMediaManager.js +27 -15
  192. package/lib/media-manager/Items.d.ts +4 -1
  193. package/lib/media-manager/Items.js +62 -59
  194. package/lib/media-manager/MediaManagerHandler.js +1 -1
  195. package/lib/media-manager/helpers/MediaManagerHelper.d.ts +5 -1
  196. package/lib/media-manager/helpers/MediaManagerHelper.js +38 -4
  197. package/lib/model/AbstractModel.d.ts +33 -25
  198. package/lib/model/AbstractModel.js +54 -2
  199. package/lib/model/InternalModelAccessFactory.d.ts +18 -0
  200. package/lib/model/InternalModelAccessFactory.js +82 -0
  201. package/lib/model/ModelHandler.d.ts +6 -0
  202. package/lib/model/ModelHandler.js +14 -0
  203. package/lib/model/adapter/sequelize.d.ts +32 -10
  204. package/lib/model/adapter/sequelize.js +409 -62
  205. package/lib/model/adapter/typeorm.d.ts +62 -0
  206. package/lib/model/adapter/typeorm.js +777 -0
  207. package/lib/model/internalModelAccessToken.d.ts +1 -0
  208. package/lib/model/internalModelAccessToken.js +1 -0
  209. package/lib/model/internalModelRepository.d.ts +3 -0
  210. package/lib/model/internalModelRepository.js +4 -0
  211. package/lib/notifications/AbstractNotificationService.d.ts +3 -0
  212. package/lib/notifications/AbstractNotificationService.js +42 -36
  213. package/lib/notifications/GeneralNotificationService.js +37 -40
  214. package/lib/notifications/SystemNotificationService.js +33 -36
  215. package/lib/requestProcessor.js +0 -3
  216. package/lib/ui-i18n/getUiTranslations.d.ts +1 -0
  217. package/lib/ui-i18n/getUiTranslations.js +3 -0
  218. package/lib/ui-i18n/uiTranslationKeys.d.ts +6 -0
  219. package/lib/ui-i18n/uiTranslationKeys.js +268 -0
  220. package/lib/widgets/widgetHandler.d.ts +7 -2
  221. package/lib/widgets/widgetHandler.js +98 -18
  222. package/models/FilterAP.d.ts +116 -0
  223. package/models/FilterAP.js +68 -0
  224. package/models/FilterColumnAP.d.ts +32 -0
  225. package/models/FilterColumnAP.js +21 -0
  226. package/models/GroupAP.d.ts +1 -1
  227. package/models/HistoryActionsAP.d.ts +3 -3
  228. package/models/MediaManagerMetaAP.d.ts +1 -1
  229. package/models/NavigationAP.d.ts +1 -1
  230. package/models/UserAP.d.ts +6 -1
  231. package/models/UserAP.js +4 -0
  232. package/package.json +39 -32
  233. package/policies/authPolicies.d.ts +12 -0
  234. package/policies/authPolicies.js +104 -0
  235. package/policies/permissionResolvers.d.ts +12 -0
  236. package/policies/permissionResolvers.js +52 -0
  237. package/services/FeedService.d.ts +70 -0
  238. package/services/FeedService.js +334 -0
  239. package/system/Router.d.ts +1 -0
  240. package/system/Router.js +136 -59
  241. package/system/bindAccessRights.js +11 -30
  242. package/system/bindAuthorization.js +18 -18
  243. package/system/bindCors.js +16 -1
  244. package/system/bindCustomFilterHandlers.d.ts +2 -0
  245. package/system/bindCustomFilterHandlers.js +4 -0
  246. package/system/bindInertia.js +18 -61
  247. package/system/bindReqFunctions.js +10 -2
  248. package/system/bindTranslations.js +7 -3
  249. package/system/buildInternalModelAccess.d.ts +4 -0
  250. package/system/buildInternalModelAccess.js +59 -0
  251. package/system/defaults.js +18 -14
  252. package/system/routePolicies.d.ts +2 -0
  253. package/system/routePolicies.js +29 -0
  254. package/translations/en.json +151 -39
  255. package/translations/ru.json +211 -64
  256. package/ui/components/handsontable.js +13 -27
  257. package/ui/components/ui/dialog-stack.js +1 -3
  258. package/ui/components/ui/popover.js +1 -1
  259. package/ui/components/ui/sidebar.js +1 -1
  260. package/assets/RelationDialogStack-D9UVEF9s.js +0 -407
  261. package/assets/RelationDialogStack-DV8OITPR.css +0 -4
  262. package/assets/add-BlvzWQKF.js +0 -1
  263. package/assets/add-group-1Uoq9NWe.js +0 -1
  264. package/assets/add-group-form-B01gwDGu.js +0 -1
  265. package/assets/add-user-BQCAsaRy.js +0 -1
  266. package/assets/add-user-form-Cgwc9JkI.js +0 -1
  267. package/assets/app-DaOMy1nl.css +0 -72
  268. package/assets/app-layout-CAm60qoE.js +0 -1
  269. package/assets/app-shell-QWCtn9ye.js +0 -1
  270. package/assets/app-sidebar-CfaYbnSy.js +0 -1
  271. package/assets/app-sidebar-header-BsPFDhZ8.js +0 -1
  272. package/assets/breadcrumbs-CZZirDj8.js +0 -1
  273. package/assets/catalog-k5myk7fk.js +0 -6
  274. package/assets/dashboard-BkL9ybBw.js +0 -3
  275. package/assets/date-picker-B5AZ_7Q9.js +0 -1
  276. package/assets/del-modal-BoyXZloG.js +0 -1
  277. package/assets/dynamic-controls-k61T9W2P.js +0 -1
  278. package/assets/form-1WGY0YgG.js +0 -1
  279. package/assets/form-DJapG3qF.js +0 -1
  280. package/assets/geo-json-DsMUHo0l.js +0 -4
  281. package/assets/handsontable-PxYdjN8c.js +0 -298
  282. package/assets/history-CluyR-yJ.js +0 -1
  283. package/assets/home-Dug9zBzM.js +0 -2
  284. package/assets/icon-DfDLMG5f.js +0 -1
  285. package/assets/init-user-CF80MEnT.js +0 -1
  286. package/assets/input-error-DuuqFgZa.js +0 -1
  287. package/assets/jsoneditor-De1FvcYu.js +0 -3882
  288. package/assets/list-CuexshNt.js +0 -1
  289. package/assets/list-table-BsEWjTKY.js +0 -22
  290. package/assets/login-eDemYzN-.js +0 -1
  291. package/assets/material-icon-DMT8KdmE.js +0 -1
  292. package/assets/media-manager-DfYa_mT_.js +0 -14
  293. package/assets/module-Cd4Tm6uq.js +0 -1
  294. package/assets/monaco-BhBYtg3d.js +0 -11
  295. package/assets/nav-footer-D3olYxtz.js +0 -1
  296. package/assets/nav-main-BctqyzeV.js +0 -1
  297. package/assets/nav-user-Bn1Lt-BZ.js +0 -1
  298. package/assets/notification-D64qvni-.js +0 -27
  299. package/assets/pagination-render-DxD78ahJ.js +0 -1
  300. package/assets/register-349PwYbe.js +0 -1
  301. package/assets/theme-switcher-DfExsHW2.js +0 -1
  302. package/assets/toast-editor-ESK5iWPx.js +0 -845
  303. package/assets/user-info-DtBK5Kh8.js +0 -1
  304. package/assets/user-menu-content-0XYOCMaA.js +0 -1
  305. package/assets/welcome-PDp-gUei.js +0 -1
  306. package/controllers/form.d.ts +0 -1
  307. package/controllers/form.js +0 -86
  308. package/helpers/formHelper.d.ts +0 -6
  309. package/helpers/formHelper.js +0 -38
  310. package/helpers/inertiaFromHelper.d.ts +0 -11
  311. package/helpers/inertiaFromHelper.js +0 -98
  312. package/helpers/runtimeMode.d.ts +0 -1
  313. package/helpers/runtimeMode.js +0 -3
  314. package/lib/PolicyManager.d.ts +0 -8
  315. package/lib/PolicyManager.js +0 -53
  316. package/lib/datatable/NodeTable.d.ts +0 -49
  317. package/lib/datatable/NodeTable.js +0 -207
  318. package/lib/model/adapter/waterline.d.ts +0 -32
  319. package/lib/model/adapter/waterline.js +0 -180
  320. package/migrations/index.d.ts +0 -3
  321. package/migrations/index.js +0 -4
  322. package/migrations/knex/20250106000001_adminizer_init.d.ts +0 -8
  323. package/migrations/knex/20250106000001_adminizer_init.js +0 -164
  324. package/migrations/umzug/0001.d.ts +0 -7
  325. package/migrations/umzug/0001.js +0 -121
  326. package/migrations/umzugExports.d.ts +0 -2
  327. package/migrations/umzugExports.js +0 -9
  328. package/system/bindForms.d.ts +0 -2
  329. package/system/bindForms.js +0 -20
  330. /package/{policies → middlewares}/addMessages.d.ts +0 -0
  331. /package/{policies → middlewares}/addMessages.js +0 -0
  332. /package/{policies → middlewares}/checkAuth.d.ts +0 -0
  333. /package/{policies → middlewares}/checkAuth.js +0 -0
  334. /package/{policies → middlewares}/setLocale.d.ts +0 -0
  335. /package/{policies → middlewares}/setLocale.js +0 -0
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generates a unique API key for user authentication.
3
+ * @returns A UUID string representing the user's API key.
4
+ */
5
+ export declare function generateUserApiKey(): string;
@@ -0,0 +1,8 @@
1
+ import { randomUUID } from "crypto";
2
+ /**
3
+ * Generates a unique API key for user authentication.
4
+ * @returns A UUID string representing the user's API key.
5
+ */
6
+ export function generateUserApiKey() {
7
+ return randomUUID();
8
+ }
@@ -36,12 +36,12 @@ export class ConfigHelper {
36
36
  }
37
37
  let config = this.adminizer.config;
38
38
  let modelConfig;
39
- Object.keys(config.models).forEach((entityName) => {
40
- const model = config.models[entityName];
39
+ Object.keys(config.models).forEach((modelResourceName) => {
40
+ const model = config.models[modelResourceName];
41
41
  if (typeof model !== "boolean") {
42
42
  if (model.model === modelName.toLowerCase()) {
43
- if (typeof config.models[entityName] !== "boolean") {
44
- modelConfig = config.models[entityName];
43
+ if (typeof config.models[modelResourceName] !== "boolean") {
44
+ modelConfig = config.models[modelResourceName];
45
45
  }
46
46
  }
47
47
  }
@@ -119,23 +119,20 @@ export class ConfigHelper {
119
119
  */
120
120
  static normalizeConfig(config) {
121
121
  const defaultConfig = getDefaultConfig();
122
- const { forms: configForms = {}, ...restConfig } = config;
123
- const { forms: defaultForms = {}, } = defaultConfig;
124
122
  const mergedConfig = {
125
123
  ...defaultConfig,
126
- ...restConfig,
124
+ ...config,
127
125
  models: {
128
126
  ...defaultConfig.models,
129
127
  ...config.models
130
128
  },
131
- forms: {
132
- path: configForms.path ?? defaultForms.path,
133
- data: {
134
- ...defaultForms.data,
135
- ...configForms.data
136
- },
137
- get: configForms.get ?? defaultForms.get,
138
- set: configForms.set ?? defaultForms.set
129
+ navbar: {
130
+ ...defaultConfig.navbar,
131
+ ...config.navbar,
132
+ additionalLinks: [
133
+ ...(defaultConfig.navbar?.additionalLinks || []),
134
+ ...(config.navbar?.additionalLinks || [])
135
+ ]
139
136
  }
140
137
  };
141
138
  // Normalize auth config if it's a boolean
@@ -1,4 +1,4 @@
1
- import { Entity, EntityType } from "../interfaces/types";
1
+ import { ModelResource } from "../interfaces/types";
2
2
  import { ActionType, CreateUpdateConfig, ModelConfig } from "../interfaces/adminpanelConfig";
3
3
  /**
4
4
  * @deprecated need refactor actions
@@ -6,7 +6,7 @@ import { ActionType, CreateUpdateConfig, ModelConfig } from "../interfaces/admin
6
6
  type ActionConfig = CreateUpdateConfig;
7
7
  export declare class ControllerHelper {
8
8
  /**
9
- * Default configuration for entity
9
+ * Default configuration for ModelResource
10
10
  *
11
11
  * @see ControllerHelper.findConfig
12
12
  */
@@ -18,7 +18,7 @@ export declare class ControllerHelper {
18
18
  */
19
19
  private static _defaultActionConfig;
20
20
  /**
21
- * Check if given entity config has all required properties
21
+ * Check if given ModelResource config has all required properties
22
22
  *
23
23
  * @param {Object} config
24
24
  * @returns {boolean}
@@ -26,11 +26,11 @@ export declare class ControllerHelper {
26
26
  */
27
27
  private static _isValidModelConfig;
28
28
  /**
29
- * Normalizing entity config.
29
+ * Normalizing ModelResource config.
30
30
  * Will return fulfilled configuration object.
31
31
  *
32
32
  * @see ControllerHelper._isValidModelConfig
33
- * @param entityName
33
+ * @param modelResourceName
34
34
  * @param {Object} config
35
35
  * @returns {Object}
36
36
  * @private
@@ -45,27 +45,20 @@ export declare class ControllerHelper {
45
45
  */
46
46
  private static _normalizeActionConfig;
47
47
  /**
48
- * Get entity type
48
+ * Get ModelResource name
49
49
  *
50
50
  * @param {Request} req
51
51
  * @returns {?string}
52
52
  */
53
- static findEntityType(req: ReqType): EntityType;
54
- /**
55
- * Get entity name
56
- *
57
- * @param {Request} req
58
- * @returns {?string}
59
- */
60
- static findEntityName(req: ReqType): string;
53
+ static findModelResourceName(req: ReqType): string;
61
54
  /**
62
55
  * Searches for config from admin panel
63
56
  *
64
57
  * @param {Request} req
65
- * @param {String} entityName
58
+ * @param {String} modelResourceName
66
59
  * @returns {?Object}
67
60
  */
68
- static findModelConfig(req: ReqType, entityName: string): ModelConfig;
61
+ static findModelConfig(req: ReqType, modelResourceName: string): ModelConfig;
69
62
  /**
70
63
  * Will get action config from configuration file depending to given action
71
64
  *
@@ -85,15 +78,15 @@ export declare class ControllerHelper {
85
78
  * }
86
79
  *
87
80
  * @throws {Error} if req or actionType not passed
88
- * @param {Object} entity Entity object with `name`, `config`, `model` {@link ControllerHelper.findEntityObject}
81
+ * @param {Object} ModelResource ModelResource object with `name`, `config`, `model` {@link ControllerHelper.findModelResource}
89
82
  * @param {string} actionType Type of action that config should be loaded for. Example: list, edit, add, remove, view.
90
83
  * @returns {Object} Will return object with configs or default configs.
91
84
  */
92
- static findActionConfig(entity: Entity, actionType: ActionType): ActionConfig;
85
+ static findActionConfig(modelResource: ModelResource, actionType: ActionType): ActionConfig;
93
86
  /**
94
- * Will create entity object from request.
87
+ * Will create ModelResource object from request.
95
88
  *
96
- * Entity Object will have this format:
89
+ * ModelResource Object will have this format:
97
90
  *
98
91
  * @example
99
92
  * ```javascript
@@ -108,6 +101,6 @@ export declare class ControllerHelper {
108
101
  * @param req
109
102
  * @returns {Object}
110
103
  */
111
- static findEntityObject(req: ReqType): Entity;
104
+ static findModelResource(req: ReqType): ModelResource;
112
105
  }
113
106
  export {};
@@ -1,7 +1,7 @@
1
1
  import { Adminizer } from "../lib/Adminizer.js";
2
2
  export class ControllerHelper {
3
3
  /**
4
- * Default configuration for entity
4
+ * Default configuration for ModelResource
5
5
  *
6
6
  * @see ControllerHelper.findConfig
7
7
  */
@@ -21,7 +21,7 @@ export class ControllerHelper {
21
21
  fields: {}
22
22
  };
23
23
  /**
24
- * Check if given entity config has all required properties
24
+ * Check if given ModelResource config has all required properties
25
25
  *
26
26
  * @param {Object} config
27
27
  * @returns {boolean}
@@ -40,29 +40,29 @@ export class ControllerHelper {
40
40
  }
41
41
  ;
42
42
  /**
43
- * Normalizing entity config.
43
+ * Normalizing ModelResource config.
44
44
  * Will return fulfilled configuration object.
45
45
  *
46
46
  * @see ControllerHelper._isValidModelConfig
47
- * @param entityName
47
+ * @param modelResourceName
48
48
  * @param {Object} config
49
49
  * @returns {Object}
50
50
  * @private
51
51
  */
52
- static _normalizeModelConfig(entityName, config) {
52
+ static _normalizeModelConfig(modelResourceName, config) {
53
53
  if (typeof config === "boolean") {
54
54
  config = {
55
- model: entityName,
55
+ model: modelResourceName,
56
56
  icon: 'description',
57
- title: entityName
57
+ title: modelResourceName
58
58
  };
59
59
  }
60
60
  if (!this._isValidModelConfig(config)) {
61
- Adminizer.log.error('Wrong entity configuration, using default');
61
+ Adminizer.log.error('Wrong ModelResource configuration, using default');
62
62
  config = {
63
- model: entityName,
63
+ model: modelResourceName,
64
64
  icon: 'description',
65
- title: entityName
65
+ title: modelResourceName
66
66
  };
67
67
  }
68
68
  config = { ...this._defaultModelConfig, ...config };
@@ -83,70 +83,42 @@ export class ControllerHelper {
83
83
  }
84
84
  ;
85
85
  /**
86
- * Get entity type
86
+ * Get ModelResource name
87
87
  *
88
88
  * @param {Request} req
89
89
  * @returns {?string}
90
90
  */
91
- static findEntityType(req) {
92
- const entityType = req.params.entityType;
93
- if (!entityType) {
94
- const extractedEntityType = req.originalUrl.split('/')[2];
95
- if (["form", "model"].includes(extractedEntityType)) {
96
- return extractedEntityType;
97
- }
98
- else {
99
- return null;
100
- }
91
+ static findModelResourceName(req) {
92
+ if (req.params.modelResourceName) {
93
+ return req.params.modelResourceName;
101
94
  }
102
- return entityType;
103
- }
104
- ;
105
- /**
106
- * Get entity name
107
- *
108
- * @param {Request} req
109
- * @returns {?string}
110
- */
111
- static findEntityName(req) {
112
- if (req.params.entityName) {
113
- return req.params.entityName;
95
+ if (req.params.model) {
96
+ return req.params.model;
114
97
  }
115
98
  const urlParts = req.originalUrl.split('/');
116
- const entityType = urlParts[2];
117
- const entityName = urlParts[3];
118
- if (entityType === 'form') {
119
- const forms = req.adminizer.config.forms?.data;
120
- if (!forms || !Object.keys(forms).some(key => key.toLowerCase() === entityName.toLowerCase())) {
121
- throw new Error(`Form "${entityName}" not found`);
122
- }
123
- return Object.keys(forms).find(key => key.toLowerCase() === entityName.toLowerCase());
124
- }
125
- if (entityType === 'model') {
126
- const models = req.adminizer.config.models;
127
- if (!models || !Object.keys(models).some(key => key.toLowerCase() === entityName.toLowerCase())) {
128
- throw new Error(`Model "${entityName}" not found`);
129
- }
130
- return Object.keys(models).find(key => key.toLowerCase() === entityName.toLowerCase());
99
+ const modelResourceName = urlParts[3];
100
+ const models = req.adminizer.config.models;
101
+ if (!models || !Object.keys(models).some(key => key.toLowerCase() === modelResourceName.toLowerCase())) {
102
+ throw new Error(`Model "${modelResourceName}" not found`);
131
103
  }
132
- throw new Error(`Unsupported entity type ${entityType} in URL`);
104
+ return Object.keys(models).find(key => key.toLowerCase() === modelResourceName.toLowerCase());
133
105
  }
134
106
  /**
135
107
  * Searches for config from admin panel
136
108
  *
137
109
  * @param {Request} req
138
- * @param {String} entityName
110
+ * @param {String} modelResourceName
139
111
  * @returns {?Object}
140
112
  */
141
- static findModelConfig(req, entityName) {
113
+ static findModelConfig(req, modelResourceName) {
142
114
  const models = req.adminizer.config.models;
143
115
  if (!models) {
144
116
  Adminizer.log.error('No models configuration found');
145
117
  return null;
146
118
  }
147
- const foundKey = Object.keys(models).find(key => key.toLowerCase() === entityName.toLowerCase());
119
+ const foundKey = Object.keys(models).find(key => key.toLowerCase() === modelResourceName.toLowerCase());
148
120
  if (!foundKey) {
149
- Adminizer.log.error(`No such route exists: ${entityName}`);
121
+ Adminizer.log.error(`No such route exists: ${modelResourceName}`);
150
122
  return null;
151
123
  }
152
124
  return this._normalizeModelConfig(foundKey, models[foundKey]);
@@ -170,31 +142,31 @@ export class ControllerHelper {
170
142
  * }
171
143
  *
172
144
  * @throws {Error} if req or actionType not passed
173
- * @param {Object} entity Entity object with `name`, `config`, `model` {@link ControllerHelper.findEntityObject}
145
+ * @param {Object} ModelResource ModelResource object with `name`, `config`, `model` {@link ControllerHelper.findModelResource}
174
146
  * @param {string} actionType Type of action that config should be loaded for. Example: list, edit, add, remove, view.
175
147
  * @returns {Object} Will return object with configs or default configs.
176
148
  */
177
- static findActionConfig(entity, actionType) {
178
- if (!entity || !actionType) {
179
- throw new Error('No `entity` or `actionType` passed !');
149
+ static findActionConfig(modelResource, actionType) {
150
+ if (!modelResource || !actionType) {
151
+ throw new Error('No `ModelResource` or `actionType` passed !');
180
152
  }
181
153
  let result = { ...this._defaultActionConfig };
182
- if (!entity.config || !entity.config[actionType]) {
154
+ if (!modelResource.config || !modelResource.config[actionType]) {
183
155
  return result;
184
156
  }
185
157
  /**
186
158
  * Here we could get true/false so need to update it to Object for later manipulations
187
159
  * In this function
188
160
  */
189
- if (typeof entity.config[actionType] === "boolean") {
161
+ if (typeof modelResource.config[actionType] === "boolean") {
190
162
  return result;
191
163
  }
192
- return this._normalizeActionConfig(entity.config[actionType]);
164
+ return this._normalizeActionConfig(modelResource.config[actionType]);
193
165
  }
194
166
  /**
195
- * Will create entity object from request.
167
+ * Will create ModelResource object from request.
196
168
  *
197
- * Entity Object will have this format:
169
+ * ModelResource Object will have this format:
198
170
  *
199
171
  * @example
200
172
  * ```javascript
@@ -209,30 +181,25 @@ export class ControllerHelper {
209
181
  * @param req
210
182
  * @returns {Object}
211
183
  */
212
- static findEntityObject(req) {
213
- // Retrieve entity name and type based on the request
214
- const entityName = this.findEntityName(req);
215
- const entityType = this.findEntityType(req);
216
- // Construct the entity URI
217
- const entityUri = `${req.adminizer.config.routePrefix}/${entityType}/${entityName}`;
218
- // Initialize the Entity object
219
- const entity = {
220
- name: entityName,
221
- uri: entityUri,
222
- type: entityType,
184
+ static findModelResource(req) {
185
+ // Retrieve model name based on the request
186
+ const modelResourceName = this.findModelResourceName(req);
187
+ // Construct the ModelResource URI
188
+ const modelResourceUri = `${req.adminizer.config.routePrefix}/model/${modelResourceName}`;
189
+ // Initialize the ModelResource object
190
+ const modelResource = {
191
+ name: modelResourceName,
192
+ uri: modelResourceUri,
223
193
  model: null,
224
194
  config: null
225
195
  };
226
- // If the entity type is "model", add additional properties
227
- if (entityType === "model") {
228
- // Find and add the model configuration to the entity
229
- entity.config = this.findModelConfig(req, entityName);
230
- // Find and add the model itself to the entity
231
- if (this._isValidModelConfig(entity.config)) {
232
- entity.model = req.adminizer.modelHandler.model.get(entity.config.model);
233
- }
196
+ // Find and add the model configuration to the ModelResource
197
+ modelResource.config = this.findModelConfig(req, modelResourceName);
198
+ // Find and add the model itself to the ModelResource
199
+ if (this._isValidModelConfig(modelResource.config)) {
200
+ modelResource.model = req.adminizer.modelHandler.model.get(modelResource.config.model);
234
201
  }
235
- // Return the completed entity object
236
- return entity;
202
+ // Return the completed ModelResource object
203
+ return modelResource;
237
204
  }
238
205
  }
@@ -38,11 +38,11 @@ export class FieldsHelper {
38
38
  // adding deprecated records array to config for association widget
39
39
  Adminizer.log.warn("Warning: executing malicious job trying to add a huge amount of records in field config," +
40
40
  " please rewrite this part of code in the nearest future");
41
- let entity = {
41
+ let modelResource = {
42
42
  name: modelName, config: req.adminizer.config.models[modelName],
43
- model: Model, uri: `${req.adminizer.config.routePrefix}/model/${modelName}`, type: "model"
43
+ model: Model, uri: `${req.adminizer.config.routePrefix}/model/${modelName}`
44
44
  };
45
- let dataAccessor = new DataAccessor(req.adminizer, req.user, entity, "view");
45
+ let dataAccessor = new DataAccessor(req.adminizer, req.user, modelResource, "view");
46
46
  list = await Model.find({}, dataAccessor);
47
47
  }
48
48
  catch (e) {
@@ -0,0 +1,5 @@
1
+ import { FilterCondition } from "../models/FilterAP";
2
+ export interface ConvertDatetimeConditionsOptions {
3
+ dropEmptyValues?: boolean;
4
+ }
5
+ export declare function convertDatetimeConditions(conditions: FilterCondition[] | undefined, options?: ConvertDatetimeConditionsOptions): FilterCondition[];
@@ -0,0 +1,84 @@
1
+ const DATETIME_LOCAL_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/;
2
+ const OPERATORS_WITHOUT_VALUE = ['isNull', 'isNotNull', 'today'];
3
+ function isOperatorWithoutValue(operator) {
4
+ return operator !== undefined && OPERATORS_WITHOUT_VALUE.includes(operator);
5
+ }
6
+ function parseDatetimeLocalToUtc(value) {
7
+ if (!DATETIME_LOCAL_REGEX.test(value)) {
8
+ return null;
9
+ }
10
+ const [datePart, timePart] = value.split('T');
11
+ const [year, month, day] = datePart.split('-').map(Number);
12
+ const [hours, minutes] = timePart.split(':').map(Number);
13
+ if ([year, month, day, hours, minutes].some(Number.isNaN)) {
14
+ return null;
15
+ }
16
+ return new Date(Date.UTC(year, month - 1, day, hours, minutes, 0, 0));
17
+ }
18
+ export function convertDatetimeConditions(conditions, options = {}) {
19
+ if (!conditions || !Array.isArray(conditions)) {
20
+ return [];
21
+ }
22
+ const { dropEmptyValues = false } = options;
23
+ return conditions
24
+ .filter(cond => {
25
+ if (!dropEmptyValues) {
26
+ return true;
27
+ }
28
+ if (isOperatorWithoutValue(cond.operator)) {
29
+ return true;
30
+ }
31
+ if (cond.value === undefined || cond.value === null || cond.value === '') {
32
+ return false;
33
+ }
34
+ if (Array.isArray(cond.value) && cond.value.length === 0) {
35
+ return false;
36
+ }
37
+ return true;
38
+ })
39
+ .map(cond => {
40
+ if (cond.children && cond.children.length > 0) {
41
+ return {
42
+ ...cond,
43
+ children: convertDatetimeConditions(cond.children, options)
44
+ };
45
+ }
46
+ if (!cond.field || cond.value === undefined || cond.value === null || cond.value === '') {
47
+ return cond;
48
+ }
49
+ if (isOperatorWithoutValue(cond.operator)) {
50
+ return cond;
51
+ }
52
+ if (typeof cond.value === 'string') {
53
+ const utcDate = parseDatetimeLocalToUtc(cond.value);
54
+ if (utcDate) {
55
+ if (cond.operator === 'eq') {
56
+ const endOfMinute = new Date(utcDate.getTime() + 59_999);
57
+ return {
58
+ ...cond,
59
+ operator: 'between',
60
+ value: [utcDate, endOfMinute]
61
+ };
62
+ }
63
+ return {
64
+ ...cond,
65
+ value: utcDate
66
+ };
67
+ }
68
+ }
69
+ if (Array.isArray(cond.value) && cond.value.length === 2) {
70
+ const [val1, val2] = cond.value;
71
+ if (typeof val1 === 'string' && typeof val2 === 'string') {
72
+ const utcDate1 = parseDatetimeLocalToUtc(val1);
73
+ const utcDate2 = parseDatetimeLocalToUtc(val2);
74
+ if (utcDate1 && utcDate2) {
75
+ return {
76
+ ...cond,
77
+ value: [utcDate1, utcDate2]
78
+ };
79
+ }
80
+ }
81
+ }
82
+ return cond;
83
+ });
84
+ }
@@ -1,4 +1,4 @@
1
- import { Entity } from "../interfaces/types";
1
+ import { ModelResource } from "../interfaces/types";
2
2
  import { ActionType } from "../interfaces/adminpanelConfig";
3
3
  export interface Actions {
4
4
  link: string;
@@ -7,4 +7,4 @@ export interface Actions {
7
7
  title: string;
8
8
  icon: string;
9
9
  }
10
- export default function inertiaActionsHelper(actionType: ActionType, entity: Entity, req: ReqType): Actions[];
10
+ export default function inertiaActionsHelper(actionType: ActionType, modelResource: ModelResource, req: ReqType): Actions[];
@@ -1,10 +1,11 @@
1
- export default function inertiaActionsHelper(actionType, entity, req) {
1
+ export default function inertiaActionsHelper(actionType, modelResource, req) {
2
2
  let resActions = [];
3
- if (req.adminizer.menuHelper.hasGlobalActions(entity.config, actionType)) {
4
- const actions = req.adminizer.menuHelper.getGlobalActions(entity.config, actionType);
3
+ if (req.adminizer.menuHelper.hasGlobalActions(modelResource.config, actionType)) {
4
+ const actions = req.adminizer.menuHelper.getGlobalActions(modelResource.config, actionType);
5
5
  if (actions && actions.length > 0) {
6
6
  actions.forEach(function (action) {
7
- if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.user)) {
7
+ const context = `global action "${action.title}" (${action.id}) on model "${modelResource.name}"`;
8
+ if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.user, context)) {
8
9
  resActions.push({
9
10
  link: action.link,
10
11
  id: action.id,