@strapi/content-manager 5.59.0 → 5.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/dist/admin/constants/customOrder.js +14 -0
  2. package/dist/admin/constants/customOrder.js.map +1 -0
  3. package/dist/admin/constants/customOrder.mjs +10 -0
  4. package/dist/admin/constants/customOrder.mjs.map +1 -0
  5. package/dist/admin/history/components/VersionInputRenderer.js +2 -1
  6. package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
  7. package/dist/admin/history/components/VersionInputRenderer.mjs +2 -1
  8. package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
  9. package/dist/admin/hooks/useDocument.js +22 -11
  10. package/dist/admin/hooks/useDocument.js.map +1 -1
  11. package/dist/admin/hooks/useDocument.mjs +22 -11
  12. package/dist/admin/hooks/useDocument.mjs.map +1 -1
  13. package/dist/admin/hooks/useDocumentLayout.js.map +1 -1
  14. package/dist/admin/hooks/useDocumentLayout.mjs.map +1 -1
  15. package/dist/admin/hooks/useHasBeenNearViewport.js +70 -0
  16. package/dist/admin/hooks/useHasBeenNearViewport.js.map +1 -0
  17. package/dist/admin/hooks/useHasBeenNearViewport.mjs +46 -0
  18. package/dist/admin/hooks/useHasBeenNearViewport.mjs.map +1 -0
  19. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js +102 -32
  20. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs +104 -35
  22. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +20 -17
  24. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +20 -17
  26. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +15 -1
  28. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +17 -3
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js +21 -0
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs +22 -1
  34. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +1 -0
  36. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +1 -0
  38. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +1 -0
  40. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +1 -0
  42. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +2 -0
  44. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +2 -0
  46. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +4 -7
  48. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +4 -7
  50. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  51. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +46 -10
  52. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  53. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +47 -11
  54. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  55. package/dist/admin/pages/EditView/components/FormLayout.js +201 -50
  56. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  57. package/dist/admin/pages/EditView/components/FormLayout.mjs +202 -52
  58. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  59. package/dist/admin/pages/EditView/components/InputRenderer.js +3 -1
  60. package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
  61. package/dist/admin/pages/EditView/components/InputRenderer.mjs +3 -1
  62. package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
  63. package/dist/admin/pages/ListConfiguration/components/Settings.js +31 -2
  64. package/dist/admin/pages/ListConfiguration/components/Settings.js.map +1 -1
  65. package/dist/admin/pages/ListConfiguration/components/Settings.mjs +31 -2
  66. package/dist/admin/pages/ListConfiguration/components/Settings.mjs.map +1 -1
  67. package/dist/admin/pages/ListView/ListViewPage.js +196 -132
  68. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  69. package/dist/admin/pages/ListView/ListViewPage.mjs +196 -132
  70. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  71. package/dist/admin/pages/ListView/components/CustomOrder.js +571 -0
  72. package/dist/admin/pages/ListView/components/CustomOrder.js.map +1 -0
  73. package/dist/admin/pages/ListView/components/CustomOrder.mjs +546 -0
  74. package/dist/admin/pages/ListView/components/CustomOrder.mjs.map +1 -0
  75. package/dist/admin/pages/ListView/components/TableActions.js +4 -1
  76. package/dist/admin/pages/ListView/components/TableActions.js.map +1 -1
  77. package/dist/admin/pages/ListView/components/TableActions.mjs +4 -1
  78. package/dist/admin/pages/ListView/components/TableActions.mjs.map +1 -1
  79. package/dist/admin/preview/components/PreviewSidePanel.js +2 -1
  80. package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
  81. package/dist/admin/preview/components/PreviewSidePanel.mjs +2 -1
  82. package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
  83. package/dist/admin/preview/utils/getPreviewUrlStatus.js +17 -0
  84. package/dist/admin/preview/utils/getPreviewUrlStatus.js.map +1 -0
  85. package/dist/admin/preview/utils/getPreviewUrlStatus.mjs +15 -0
  86. package/dist/admin/preview/utils/getPreviewUrlStatus.mjs.map +1 -0
  87. package/dist/admin/services/documents.js +22 -1
  88. package/dist/admin/services/documents.js.map +1 -1
  89. package/dist/admin/services/documents.mjs +21 -2
  90. package/dist/admin/services/documents.mjs.map +1 -1
  91. package/dist/admin/src/constants/customOrder.d.ts +8 -0
  92. package/dist/admin/src/exports.d.ts +1 -1
  93. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +3 -1
  94. package/dist/admin/src/hooks/useDocument.d.ts +4 -0
  95. package/dist/admin/src/hooks/useDocumentLayout.d.ts +6 -2
  96. package/dist/admin/src/hooks/useHasBeenNearViewport.d.ts +13 -0
  97. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.d.ts +13 -1
  98. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +11 -1
  99. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -0
  100. package/dist/admin/src/pages/ListView/components/CustomOrder.d.ts +72 -0
  101. package/dist/admin/src/preview/utils/getPreviewUrlStatus.d.ts +6 -0
  102. package/dist/admin/src/services/documents.d.ts +10 -2
  103. package/dist/admin/translations/en.json.js +9 -0
  104. package/dist/admin/translations/en.json.js.map +1 -1
  105. package/dist/admin/translations/en.json.mjs +9 -0
  106. package/dist/admin/translations/en.json.mjs.map +1 -1
  107. package/dist/server/audit-logs.js +36 -0
  108. package/dist/server/audit-logs.js.map +1 -0
  109. package/dist/server/audit-logs.mjs +33 -0
  110. package/dist/server/audit-logs.mjs.map +1 -0
  111. package/dist/server/bootstrap.js +8 -0
  112. package/dist/server/bootstrap.js.map +1 -1
  113. package/dist/server/bootstrap.mjs +8 -0
  114. package/dist/server/bootstrap.mjs.map +1 -1
  115. package/dist/server/controllers/collection-types.js +8 -0
  116. package/dist/server/controllers/collection-types.js.map +1 -1
  117. package/dist/server/controllers/collection-types.mjs +8 -0
  118. package/dist/server/controllers/collection-types.mjs.map +1 -1
  119. package/dist/server/controllers/content-types.js +15 -0
  120. package/dist/server/controllers/content-types.js.map +1 -1
  121. package/dist/server/controllers/content-types.mjs +16 -1
  122. package/dist/server/controllers/content-types.mjs.map +1 -1
  123. package/dist/server/controllers/index.js +3 -1
  124. package/dist/server/controllers/index.js.map +1 -1
  125. package/dist/server/controllers/index.mjs +2 -0
  126. package/dist/server/controllers/index.mjs.map +1 -1
  127. package/dist/server/controllers/relations.js +53 -17
  128. package/dist/server/controllers/relations.js.map +1 -1
  129. package/dist/server/controllers/relations.mjs +54 -18
  130. package/dist/server/controllers/relations.mjs.map +1 -1
  131. package/dist/server/controllers/single-types.js +10 -1
  132. package/dist/server/controllers/single-types.js.map +1 -1
  133. package/dist/server/controllers/single-types.mjs +10 -1
  134. package/dist/server/controllers/single-types.mjs.map +1 -1
  135. package/dist/server/controllers/validation/model-configuration.js +2 -1
  136. package/dist/server/controllers/validation/model-configuration.js.map +1 -1
  137. package/dist/server/controllers/validation/model-configuration.mjs +2 -1
  138. package/dist/server/controllers/validation/model-configuration.mjs.map +1 -1
  139. package/dist/server/custom-order/constants.js +21 -0
  140. package/dist/server/custom-order/constants.js.map +1 -0
  141. package/dist/server/custom-order/constants.mjs +17 -0
  142. package/dist/server/custom-order/constants.mjs.map +1 -0
  143. package/dist/server/custom-order/controllers/custom-order.js +77 -0
  144. package/dist/server/custom-order/controllers/custom-order.js.map +1 -0
  145. package/dist/server/custom-order/controllers/custom-order.mjs +75 -0
  146. package/dist/server/custom-order/controllers/custom-order.mjs.map +1 -0
  147. package/dist/server/custom-order/controllers/index.js +10 -0
  148. package/dist/server/custom-order/controllers/index.js.map +1 -0
  149. package/dist/server/custom-order/controllers/index.mjs +8 -0
  150. package/dist/server/custom-order/controllers/index.mjs.map +1 -0
  151. package/dist/server/custom-order/index.js +71 -0
  152. package/dist/server/custom-order/index.js.map +1 -0
  153. package/dist/server/custom-order/index.mjs +69 -0
  154. package/dist/server/custom-order/index.mjs.map +1 -0
  155. package/dist/server/custom-order/routes/custom-order.js +38 -0
  156. package/dist/server/custom-order/routes/custom-order.js.map +1 -0
  157. package/dist/server/custom-order/routes/custom-order.mjs +36 -0
  158. package/dist/server/custom-order/routes/custom-order.mjs.map +1 -0
  159. package/dist/server/custom-order/routes/index.js +13 -0
  160. package/dist/server/custom-order/routes/index.js.map +1 -0
  161. package/dist/server/custom-order/routes/index.mjs +11 -0
  162. package/dist/server/custom-order/routes/index.mjs.map +1 -0
  163. package/dist/server/custom-order/services/custom-order.js +286 -0
  164. package/dist/server/custom-order/services/custom-order.js.map +1 -0
  165. package/dist/server/custom-order/services/custom-order.mjs +284 -0
  166. package/dist/server/custom-order/services/custom-order.mjs.map +1 -0
  167. package/dist/server/custom-order/services/document-middleware.js +83 -0
  168. package/dist/server/custom-order/services/document-middleware.js.map +1 -0
  169. package/dist/server/custom-order/services/document-middleware.mjs +81 -0
  170. package/dist/server/custom-order/services/document-middleware.mjs.map +1 -0
  171. package/dist/server/custom-order/services/index.js +10 -0
  172. package/dist/server/custom-order/services/index.js.map +1 -0
  173. package/dist/server/custom-order/services/index.mjs +8 -0
  174. package/dist/server/custom-order/services/index.mjs.map +1 -0
  175. package/dist/server/custom-order/services/utils.js +152 -0
  176. package/dist/server/custom-order/services/utils.js.map +1 -0
  177. package/dist/server/custom-order/services/utils.mjs +148 -0
  178. package/dist/server/custom-order/services/utils.mjs.map +1 -0
  179. package/dist/server/custom-order/utils.js +13 -0
  180. package/dist/server/custom-order/utils.js.map +1 -0
  181. package/dist/server/custom-order/utils.mjs +10 -0
  182. package/dist/server/custom-order/utils.mjs.map +1 -0
  183. package/dist/server/history/constants.js +2 -1
  184. package/dist/server/history/constants.js.map +1 -1
  185. package/dist/server/history/constants.mjs +2 -1
  186. package/dist/server/history/constants.mjs.map +1 -1
  187. package/dist/server/history/controllers/history-version.js +6 -2
  188. package/dist/server/history/controllers/history-version.js.map +1 -1
  189. package/dist/server/history/controllers/history-version.mjs +6 -2
  190. package/dist/server/history/controllers/history-version.mjs.map +1 -1
  191. package/dist/server/history/services/history.js +24 -7
  192. package/dist/server/history/services/history.js.map +1 -1
  193. package/dist/server/history/services/history.mjs +25 -8
  194. package/dist/server/history/services/history.mjs.map +1 -1
  195. package/dist/server/history/services/lifecycles.js +2 -16
  196. package/dist/server/history/services/lifecycles.js.map +1 -1
  197. package/dist/server/history/services/lifecycles.mjs +2 -16
  198. package/dist/server/history/services/lifecycles.mjs.map +1 -1
  199. package/dist/server/mcp/schemas/filters-schema.js +10 -2
  200. package/dist/server/mcp/schemas/filters-schema.js.map +1 -1
  201. package/dist/server/mcp/schemas/filters-schema.mjs +10 -2
  202. package/dist/server/mcp/schemas/filters-schema.mjs.map +1 -1
  203. package/dist/server/preview/controllers/validation/preview.js +1 -1
  204. package/dist/server/preview/controllers/validation/preview.js.map +1 -1
  205. package/dist/server/preview/controllers/validation/preview.mjs +2 -2
  206. package/dist/server/preview/controllers/validation/preview.mjs.map +1 -1
  207. package/dist/server/register.js +4 -0
  208. package/dist/server/register.js.map +1 -1
  209. package/dist/server/register.mjs +4 -0
  210. package/dist/server/register.mjs.map +1 -1
  211. package/dist/server/routes/index.js +3 -1
  212. package/dist/server/routes/index.js.map +1 -1
  213. package/dist/server/routes/index.mjs +2 -0
  214. package/dist/server/routes/index.mjs.map +1 -1
  215. package/dist/server/services/content-types.js +2 -2
  216. package/dist/server/services/content-types.js.map +1 -1
  217. package/dist/server/services/content-types.mjs +2 -2
  218. package/dist/server/services/content-types.mjs.map +1 -1
  219. package/dist/server/services/document-manager.js +13 -0
  220. package/dist/server/services/document-manager.js.map +1 -1
  221. package/dist/server/services/document-manager.mjs +14 -1
  222. package/dist/server/services/document-manager.mjs.map +1 -1
  223. package/dist/server/services/document-metadata.js +1 -1
  224. package/dist/server/services/document-metadata.js.map +1 -1
  225. package/dist/server/services/document-metadata.mjs +1 -1
  226. package/dist/server/services/document-metadata.mjs.map +1 -1
  227. package/dist/server/services/index.js +3 -1
  228. package/dist/server/services/index.js.map +1 -1
  229. package/dist/server/services/index.mjs +2 -0
  230. package/dist/server/services/index.mjs.map +1 -1
  231. package/dist/server/services/utils/configuration/settings.js +2 -1
  232. package/dist/server/services/utils/configuration/settings.js.map +1 -1
  233. package/dist/server/services/utils/configuration/settings.mjs +2 -1
  234. package/dist/server/services/utils/configuration/settings.mjs.map +1 -1
  235. package/dist/server/src/audit-logs.d.ts +40 -0
  236. package/dist/server/src/audit-logs.d.ts.map +1 -0
  237. package/dist/server/src/bootstrap.d.ts.map +1 -1
  238. package/dist/server/src/controllers/collection-types.d.ts +1 -1
  239. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  240. package/dist/server/src/controllers/content-types.d.ts.map +1 -1
  241. package/dist/server/src/controllers/index.d.ts +21 -3
  242. package/dist/server/src/controllers/index.d.ts.map +1 -1
  243. package/dist/server/src/controllers/relations.d.ts +19 -1
  244. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  245. package/dist/server/src/controllers/single-types.d.ts +1 -1
  246. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  247. package/dist/server/src/custom-order/constants.d.ts +18 -0
  248. package/dist/server/src/custom-order/constants.d.ts.map +1 -0
  249. package/dist/server/src/custom-order/controllers/custom-order.d.ts +8 -0
  250. package/dist/server/src/custom-order/controllers/custom-order.d.ts.map +1 -0
  251. package/dist/server/src/custom-order/controllers/index.d.ts +3 -0
  252. package/dist/server/src/custom-order/controllers/index.d.ts.map +1 -0
  253. package/dist/server/src/custom-order/index.d.ts +8 -0
  254. package/dist/server/src/custom-order/index.d.ts.map +1 -0
  255. package/dist/server/src/custom-order/routes/custom-order.d.ts +4 -0
  256. package/dist/server/src/custom-order/routes/custom-order.d.ts.map +1 -0
  257. package/dist/server/src/custom-order/routes/index.d.ts +10 -0
  258. package/dist/server/src/custom-order/routes/index.d.ts.map +1 -0
  259. package/dist/server/src/custom-order/services/custom-order.d.ts +43 -0
  260. package/dist/server/src/custom-order/services/custom-order.d.ts.map +1 -0
  261. package/dist/server/src/custom-order/services/document-middleware.d.ts +16 -0
  262. package/dist/server/src/custom-order/services/document-middleware.d.ts.map +1 -0
  263. package/dist/server/src/custom-order/services/index.d.ts +24 -0
  264. package/dist/server/src/custom-order/services/index.d.ts.map +1 -0
  265. package/dist/server/src/custom-order/services/utils.d.ts +34 -0
  266. package/dist/server/src/custom-order/services/utils.d.ts.map +1 -0
  267. package/dist/server/src/custom-order/utils.d.ts +6 -0
  268. package/dist/server/src/custom-order/utils.d.ts.map +1 -0
  269. package/dist/server/src/history/constants.d.ts.map +1 -1
  270. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  271. package/dist/server/src/history/services/history.d.ts.map +1 -1
  272. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  273. package/dist/server/src/index.d.ts +22 -6
  274. package/dist/server/src/index.d.ts.map +1 -1
  275. package/dist/server/src/mcp/schemas/filters-schema.d.ts.map +1 -1
  276. package/dist/server/src/register.d.ts.map +1 -1
  277. package/dist/server/src/routes/index.d.ts.map +1 -1
  278. package/dist/server/src/services/content-types.d.ts +1 -3
  279. package/dist/server/src/services/content-types.d.ts.map +1 -1
  280. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  281. package/dist/server/src/services/index.d.ts +1 -3
  282. package/dist/server/src/services/index.d.ts.map +1 -1
  283. package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -1
  284. package/dist/shared/contracts/content-types.d.ts +5 -0
  285. package/dist/shared/contracts/content-types.d.ts.map +1 -1
  286. package/dist/shared/contracts/custom-order.d.ts +33 -0
  287. package/dist/shared/contracts/custom-order.d.ts.map +1 -0
  288. package/dist/shared/contracts/custom-order.js +3 -0
  289. package/dist/shared/contracts/custom-order.js.map +1 -0
  290. package/dist/shared/contracts/custom-order.mjs +2 -0
  291. package/dist/shared/contracts/custom-order.mjs.map +1 -0
  292. package/dist/shared/contracts/history-versions.d.ts +0 -1
  293. package/dist/shared/contracts/history-versions.d.ts.map +1 -1
  294. package/dist/shared/contracts/index.d.ts +1 -0
  295. package/dist/shared/contracts/index.d.ts.map +1 -1
  296. package/dist/shared/contracts/index.js +2 -0
  297. package/dist/shared/contracts/index.js.map +1 -1
  298. package/dist/shared/contracts/index.mjs +2 -0
  299. package/dist/shared/contracts/index.mjs.map +1 -1
  300. package/package.json +10 -10
@@ -0,0 +1,75 @@
1
+ import { z, errors } from '@strapi/utils';
2
+ import { getService as getService$1 } from '../../utils/index.mjs';
3
+ import { getDocumentLocaleAndStatus } from '../../controllers/validation/dimensions.mjs';
4
+ import { validateZodAsync } from '../../validation/zod.mjs';
5
+ import { isFeatureEnabled, getService } from '../utils.mjs';
6
+
7
+ // Not strict: like for the other document actions, i18n adds the locale of the request to the body
8
+ const moveInputSchema = z.looseObject({
9
+ before: z.string().min(1).optional(),
10
+ after: z.string().min(1).optional()
11
+ }).refine(({ before, after })=>before === undefined !== (after === undefined), {
12
+ error: 'Expected either "before" or "after" to be the documentId of another entry'
13
+ });
14
+ const validateMoveInput = validateZodAsync(moveInputSchema);
15
+ const createCustomOrderController = ({ strapi })=>{
16
+ return {
17
+ async move (ctx) {
18
+ if (!isFeatureEnabled(strapi)) {
19
+ return ctx.notFound();
20
+ }
21
+ const { userAbility } = ctx.state;
22
+ const { id } = ctx.params;
23
+ const model = ctx.params.model;
24
+ const { body } = ctx.request;
25
+ const { before, after } = await validateMoveInput(body);
26
+ const placement = before !== undefined ? 'before' : 'after';
27
+ const anchorId = before ?? after;
28
+ if (anchorId === undefined || anchorId === id) {
29
+ throw new errors.ValidationError('An entry cannot be moved next to itself');
30
+ }
31
+ const customOrder = getService(strapi, 'custom-order');
32
+ // The setting may have just been turned on from another instance
33
+ if (!customOrder.isEnabled(model)) {
34
+ await customOrder.refresh();
35
+ }
36
+ if (!customOrder.isEnabled(model)) {
37
+ throw new errors.ValidationError('Custom order is not enabled for this content type');
38
+ }
39
+ const permissionChecker = getService$1('permission-checker').create({
40
+ userAbility,
41
+ model
42
+ });
43
+ if (permissionChecker.cannot.update()) {
44
+ return ctx.forbidden();
45
+ }
46
+ const permissionQuery = await permissionChecker.sanitizedQuery.update(ctx.query);
47
+ const populate = await getService$1('populate-builder')(model).populateFromQuery(permissionQuery).build();
48
+ const { locale } = await getDocumentLocaleAndStatus(body, model);
49
+ const document = await getService$1('document-manager').findOne(id, model, {
50
+ populate,
51
+ locale
52
+ });
53
+ if (!document) {
54
+ return ctx.notFound();
55
+ }
56
+ if (permissionChecker.cannot.update(document)) {
57
+ return ctx.forbidden();
58
+ }
59
+ await customOrder.move({
60
+ uid: model,
61
+ documentId: id,
62
+ anchorId,
63
+ placement
64
+ });
65
+ return {
66
+ data: {
67
+ documentId: id
68
+ }
69
+ };
70
+ }
71
+ };
72
+ };
73
+
74
+ export { createCustomOrderController };
75
+ //# sourceMappingURL=custom-order.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-order.mjs","sources":["../../../../server/src/custom-order/controllers/custom-order.ts"],"sourcesContent":["import { errors, z } from '@strapi/utils';\nimport type { Core, UID } from '@strapi/types';\n\nimport { getService as getContentManagerService } from '../../utils';\nimport { getDocumentLocaleAndStatus } from '../../controllers/validation/dimensions';\nimport { validateZodAsync } from '../../validation/zod';\nimport { getService, isFeatureEnabled } from '../utils';\nimport type { CustomOrder } from '../../../../shared/contracts';\n\n// Not strict: like for the other document actions, i18n adds the locale of the request to the body\nconst moveInputSchema = z\n .looseObject({\n before: z.string().min(1).optional(),\n after: z.string().min(1).optional(),\n })\n .refine(({ before, after }) => (before === undefined) !== (after === undefined), {\n error: 'Expected either \"before\" or \"after\" to be the documentId of another entry',\n });\n\nconst validateMoveInput = validateZodAsync(moveInputSchema);\n\nconst createCustomOrderController = ({ strapi }: { strapi: Core.Strapi }) => {\n return {\n async move(ctx) {\n if (!isFeatureEnabled(strapi)) {\n return ctx.notFound();\n }\n\n const { userAbility } = ctx.state;\n const { id } = ctx.params as CustomOrder.MoveDocument.Params;\n const model = ctx.params.model as UID.CollectionType;\n const { body } = ctx.request;\n\n const { before, after } = await validateMoveInput(body);\n\n const placement = before !== undefined ? 'before' : 'after';\n const anchorId = before ?? after;\n\n if (anchorId === undefined || anchorId === id) {\n throw new errors.ValidationError('An entry cannot be moved next to itself');\n }\n\n const customOrder = getService(strapi, 'custom-order');\n\n // The setting may have just been turned on from another instance\n if (!customOrder.isEnabled(model)) {\n await customOrder.refresh();\n }\n\n if (!customOrder.isEnabled(model)) {\n throw new errors.ValidationError('Custom order is not enabled for this content type');\n }\n\n const permissionChecker = getContentManagerService('permission-checker').create({\n userAbility,\n model,\n });\n\n if (permissionChecker.cannot.update()) {\n return ctx.forbidden();\n }\n\n const permissionQuery = await permissionChecker.sanitizedQuery.update(ctx.query);\n const populate = await getContentManagerService('populate-builder')(model)\n .populateFromQuery(permissionQuery)\n .build();\n\n const { locale } = await getDocumentLocaleAndStatus(body, model);\n const document = await getContentManagerService('document-manager').findOne(id, model, {\n populate,\n locale,\n });\n\n if (!document) {\n return ctx.notFound();\n }\n\n if (permissionChecker.cannot.update(document)) {\n return ctx.forbidden();\n }\n\n await customOrder.move({ uid: model, documentId: id, anchorId, placement });\n\n return {\n data: { documentId: id },\n } satisfies CustomOrder.MoveDocument.Response;\n },\n } satisfies Core.Controller;\n};\n\nexport { createCustomOrderController };\n"],"names":["moveInputSchema","z","looseObject","before","string","min","optional","after","refine","undefined","error","validateMoveInput","validateZodAsync","createCustomOrderController","strapi","move","ctx","isFeatureEnabled","notFound","userAbility","state","id","params","model","body","request","placement","anchorId","errors","ValidationError","customOrder","getService","isEnabled","refresh","permissionChecker","getContentManagerService","create","cannot","update","forbidden","permissionQuery","sanitizedQuery","query","populate","populateFromQuery","build","locale","getDocumentLocaleAndStatus","document","findOne","uid","documentId","data"],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var customOrder = require('./custom-order.js');
4
+
5
+ const controllers = {
6
+ 'custom-order': customOrder.createCustomOrderController
7
+ };
8
+
9
+ exports.controllers = controllers;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../server/src/custom-order/controllers/index.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\nimport { createCustomOrderController } from './custom-order';\n\nexport const controllers = {\n 'custom-order': createCustomOrderController,\n /**\n * Casting is needed because the types aren't aware that Strapi supports\n * passing a controller factory as the value, instead of a controller object directly\n */\n} as unknown as Plugin.LoadedPlugin['controllers'];\n"],"names":["controllers","createCustomOrderController"],"mappings":";;;;MAGaA,WAAAA,GAAc;IACzB,cAAA,EAAgBC;AAKlB;;;;"}
@@ -0,0 +1,8 @@
1
+ import { createCustomOrderController } from './custom-order.mjs';
2
+
3
+ const controllers = {
4
+ 'custom-order': createCustomOrderController
5
+ };
6
+
7
+ export { controllers };
8
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../server/src/custom-order/controllers/index.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\nimport { createCustomOrderController } from './custom-order';\n\nexport const controllers = {\n 'custom-order': createCustomOrderController,\n /**\n * Casting is needed because the types aren't aware that Strapi supports\n * passing a controller factory as the value, instead of a controller object directly\n */\n} as unknown as Plugin.LoadedPlugin['controllers'];\n"],"names":["controllers","createCustomOrderController"],"mappings":";;MAGaA,WAAAA,GAAc;IACzB,cAAA,EAAgBC;AAKlB;;;;"}
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ var strapiUtils = require('@strapi/utils');
4
+ var _ = require('lodash');
5
+ var index$2 = require('./controllers/index.js');
6
+ var index = require('./services/index.js');
7
+ var index$1 = require('./routes/index.js');
8
+ var constants = require('./constants.js');
9
+ var utils = require('./utils.js');
10
+
11
+ /**
12
+ * Custom order can be turned on for any collection type listed in the Content Manager.
13
+ */ const isOrderable = (contentType)=>strapiUtils.contentTypes.isCollectionType(contentType) && _.get(contentType, 'pluginOptions.content-manager.visible', true) === true;
14
+ /**
15
+ * The future flag is read when the server starts rather than when this module is loaded,
16
+ * so the controllers, services and routes are always there and do nothing while it is off.
17
+ */ const feature = {
18
+ register ({ strapi }) {
19
+ if (!utils.isFeatureEnabled(strapi)) {
20
+ return;
21
+ }
22
+ /**
23
+ * The setting is changed at runtime, while columns are only created when the server
24
+ * starts, so every content type that could be ordered needs the attribute up front.
25
+ */ for (const contentType of Object.values(strapi.contentTypes)){
26
+ if (!isOrderable(contentType)) {
27
+ continue;
28
+ }
29
+ strapi.get('content-types').extend(contentType.uid, (schema)=>{
30
+ Object.assign(schema.attributes, {
31
+ [constants.POSITION_ATTRIBUTE]: {
32
+ type: 'integer',
33
+ configurable: false,
34
+ visible: false,
35
+ // Needed for the Content Manager to sort on it, the value itself is only ever
36
+ // written by moving a document
37
+ writable: true,
38
+ private: true
39
+ }
40
+ });
41
+ // Every default list sorts on the position, and moves look for rows without one
42
+ const { identifiers } = strapi.db.metadata;
43
+ const collectionName = schema.collectionName ?? schema.uid;
44
+ schema.indexes = [
45
+ ...schema.indexes ?? [],
46
+ {
47
+ name: identifiers.getIndexName([
48
+ collectionName,
49
+ constants.POSITION_ATTRIBUTE
50
+ ]),
51
+ columns: [
52
+ identifiers.getColumnName(constants.POSITION_ATTRIBUTE)
53
+ ]
54
+ }
55
+ ];
56
+ });
57
+ }
58
+ },
59
+ async bootstrap ({ strapi }) {
60
+ if (!utils.isFeatureEnabled(strapi)) {
61
+ return;
62
+ }
63
+ await utils.getService(strapi, 'custom-order').bootstrap();
64
+ },
65
+ controllers: index$2.controllers,
66
+ services: index.services,
67
+ routes: index$1.routes
68
+ };
69
+
70
+ module.exports = feature;
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../server/src/custom-order/index.ts"],"sourcesContent":["import type { Plugin, Struct } from '@strapi/types';\nimport { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport { get } from 'lodash';\n\nimport { controllers } from './controllers';\nimport { services } from './services';\nimport { routes } from './routes';\nimport { POSITION_ATTRIBUTE } from './constants';\nimport { getService, isFeatureEnabled } from './utils';\n\n/**\n * Custom order can be turned on for any collection type listed in the Content Manager.\n */\nconst isOrderable = (contentType: Struct.ContentTypeSchema) =>\n contentTypesUtils.isCollectionType(contentType) &&\n get(contentType, 'pluginOptions.content-manager.visible', true) === true;\n\n/**\n * The future flag is read when the server starts rather than when this module is loaded,\n * so the controllers, services and routes are always there and do nothing while it is off.\n */\nconst feature: Partial<Plugin.LoadedPlugin> = {\n register({ strapi }) {\n if (!isFeatureEnabled(strapi)) {\n return;\n }\n\n /**\n * The setting is changed at runtime, while columns are only created when the server\n * starts, so every content type that could be ordered needs the attribute up front.\n */\n for (const contentType of Object.values(strapi.contentTypes)) {\n if (!isOrderable(contentType)) {\n continue;\n }\n\n strapi.get('content-types').extend(contentType.uid, (schema: Struct.ContentTypeSchema) => {\n Object.assign(schema.attributes, {\n [POSITION_ATTRIBUTE]: {\n type: 'integer',\n configurable: false,\n visible: false,\n // Needed for the Content Manager to sort on it, the value itself is only ever\n // written by moving a document\n writable: true,\n private: true,\n },\n });\n\n // Every default list sorts on the position, and moves look for rows without one\n const { identifiers } = strapi.db.metadata;\n const collectionName = schema.collectionName ?? schema.uid;\n\n schema.indexes = [\n ...(schema.indexes ?? []),\n {\n name: identifiers.getIndexName([collectionName, POSITION_ATTRIBUTE]),\n columns: [identifiers.getColumnName(POSITION_ATTRIBUTE)],\n },\n ];\n });\n }\n },\n async bootstrap({ strapi }) {\n if (!isFeatureEnabled(strapi)) {\n return;\n }\n\n await getService(strapi, 'custom-order').bootstrap();\n },\n controllers,\n services,\n routes,\n};\n\nexport default feature;\n"],"names":["isOrderable","contentType","contentTypesUtils","isCollectionType","get","feature","register","strapi","isFeatureEnabled","Object","values","contentTypes","extend","uid","schema","assign","attributes","POSITION_ATTRIBUTE","type","configurable","visible","writable","private","identifiers","db","metadata","collectionName","indexes","name","getIndexName","columns","getColumnName","bootstrap","getService","controllers","services","routes"],"mappings":";;;;;;;;;;AAUA;;IAGA,MAAMA,WAAAA,GAAc,CAACC,WAAAA,GACnBC,wBAAAA,CAAkBC,gBAAgB,CAACF,WAAAA,CAAAA,IACnCG,KAAAA,CAAIH,WAAAA,EAAa,uCAAA,EAAyC,IAAA,CAAA,KAAU,IAAA;AAEtE;;;AAGC,UACKI,OAAAA,GAAwC;IAC5CC,QAAAA,CAAAA,CAAS,EAAEC,MAAM,EAAE,EAAA;QACjB,IAAI,CAACC,uBAAiBD,MAAAA,CAAAA,EAAS;AAC7B,YAAA;AACF,QAAA;AAEA;;;QAIA,KAAK,MAAMN,WAAAA,IAAeQ,MAAAA,CAAOC,MAAM,CAACH,MAAAA,CAAOI,YAAY,CAAA,CAAG;YAC5D,IAAI,CAACX,YAAYC,WAAAA,CAAAA,EAAc;AAC7B,gBAAA;AACF,YAAA;YAEAM,MAAAA,CAAOH,GAAG,CAAC,eAAA,CAAA,CAAiBQ,MAAM,CAACX,WAAAA,CAAYY,GAAG,EAAE,CAACC,MAAAA,GAAAA;AACnDL,gBAAAA,MAAAA,CAAOM,MAAM,CAACD,MAAAA,CAAOE,UAAU,EAAE;AAC/B,oBAAA,CAACC,+BAAqB;wBACpBC,IAAAA,EAAM,SAAA;wBACNC,YAAAA,EAAc,KAAA;wBACdC,OAAAA,EAAS,KAAA;;;wBAGTC,QAAAA,EAAU,IAAA;wBACVC,OAAAA,EAAS;AACX;AACF,iBAAA,CAAA;;AAGA,gBAAA,MAAM,EAAEC,WAAW,EAAE,GAAGhB,MAAAA,CAAOiB,EAAE,CAACC,QAAQ;AAC1C,gBAAA,MAAMC,cAAAA,GAAiBZ,MAAAA,CAAOY,cAAc,IAAIZ,OAAOD,GAAG;AAE1DC,gBAAAA,MAAAA,CAAOa,OAAO,GAAG;uBACXb,MAAAA,CAAOa,OAAO,IAAI,EAAE;AACxB,oBAAA;wBACEC,IAAAA,EAAML,WAAAA,CAAYM,YAAY,CAAC;AAACH,4BAAAA,cAAAA;AAAgBT,4BAAAA;AAAmB,yBAAA,CAAA;wBACnEa,OAAAA,EAAS;AAACP,4BAAAA,WAAAA,CAAYQ,aAAa,CAACd,4BAAAA;AAAoB;AAC1D;AACD,iBAAA;AACH,YAAA,CAAA,CAAA;AACF,QAAA;AACF,IAAA,CAAA;IACA,MAAMe,SAAAA,CAAAA,CAAU,EAAEzB,MAAM,EAAE,EAAA;QACxB,IAAI,CAACC,uBAAiBD,MAAAA,CAAAA,EAAS;AAC7B,YAAA;AACF,QAAA;QAEA,MAAM0B,gBAAAA,CAAW1B,MAAAA,EAAQ,cAAA,CAAA,CAAgByB,SAAS,EAAA;AACpD,IAAA,CAAA;AACAE,iBAAAA,mBAAAA;AACAC,cAAAA,cAAAA;AACAC,YAAAA;AACF;;;;"}
@@ -0,0 +1,69 @@
1
+ import { contentTypes } from '@strapi/utils';
2
+ import { get } from 'lodash';
3
+ import { controllers } from './controllers/index.mjs';
4
+ import { services } from './services/index.mjs';
5
+ import { routes } from './routes/index.mjs';
6
+ import { POSITION_ATTRIBUTE } from './constants.mjs';
7
+ import { isFeatureEnabled, getService } from './utils.mjs';
8
+
9
+ /**
10
+ * Custom order can be turned on for any collection type listed in the Content Manager.
11
+ */ const isOrderable = (contentType)=>contentTypes.isCollectionType(contentType) && get(contentType, 'pluginOptions.content-manager.visible', true) === true;
12
+ /**
13
+ * The future flag is read when the server starts rather than when this module is loaded,
14
+ * so the controllers, services and routes are always there and do nothing while it is off.
15
+ */ const feature = {
16
+ register ({ strapi }) {
17
+ if (!isFeatureEnabled(strapi)) {
18
+ return;
19
+ }
20
+ /**
21
+ * The setting is changed at runtime, while columns are only created when the server
22
+ * starts, so every content type that could be ordered needs the attribute up front.
23
+ */ for (const contentType of Object.values(strapi.contentTypes)){
24
+ if (!isOrderable(contentType)) {
25
+ continue;
26
+ }
27
+ strapi.get('content-types').extend(contentType.uid, (schema)=>{
28
+ Object.assign(schema.attributes, {
29
+ [POSITION_ATTRIBUTE]: {
30
+ type: 'integer',
31
+ configurable: false,
32
+ visible: false,
33
+ // Needed for the Content Manager to sort on it, the value itself is only ever
34
+ // written by moving a document
35
+ writable: true,
36
+ private: true
37
+ }
38
+ });
39
+ // Every default list sorts on the position, and moves look for rows without one
40
+ const { identifiers } = strapi.db.metadata;
41
+ const collectionName = schema.collectionName ?? schema.uid;
42
+ schema.indexes = [
43
+ ...schema.indexes ?? [],
44
+ {
45
+ name: identifiers.getIndexName([
46
+ collectionName,
47
+ POSITION_ATTRIBUTE
48
+ ]),
49
+ columns: [
50
+ identifiers.getColumnName(POSITION_ATTRIBUTE)
51
+ ]
52
+ }
53
+ ];
54
+ });
55
+ }
56
+ },
57
+ async bootstrap ({ strapi }) {
58
+ if (!isFeatureEnabled(strapi)) {
59
+ return;
60
+ }
61
+ await getService(strapi, 'custom-order').bootstrap();
62
+ },
63
+ controllers,
64
+ services,
65
+ routes
66
+ };
67
+
68
+ export { feature as default };
69
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../server/src/custom-order/index.ts"],"sourcesContent":["import type { Plugin, Struct } from '@strapi/types';\nimport { contentTypes as contentTypesUtils } from '@strapi/utils';\nimport { get } from 'lodash';\n\nimport { controllers } from './controllers';\nimport { services } from './services';\nimport { routes } from './routes';\nimport { POSITION_ATTRIBUTE } from './constants';\nimport { getService, isFeatureEnabled } from './utils';\n\n/**\n * Custom order can be turned on for any collection type listed in the Content Manager.\n */\nconst isOrderable = (contentType: Struct.ContentTypeSchema) =>\n contentTypesUtils.isCollectionType(contentType) &&\n get(contentType, 'pluginOptions.content-manager.visible', true) === true;\n\n/**\n * The future flag is read when the server starts rather than when this module is loaded,\n * so the controllers, services and routes are always there and do nothing while it is off.\n */\nconst feature: Partial<Plugin.LoadedPlugin> = {\n register({ strapi }) {\n if (!isFeatureEnabled(strapi)) {\n return;\n }\n\n /**\n * The setting is changed at runtime, while columns are only created when the server\n * starts, so every content type that could be ordered needs the attribute up front.\n */\n for (const contentType of Object.values(strapi.contentTypes)) {\n if (!isOrderable(contentType)) {\n continue;\n }\n\n strapi.get('content-types').extend(contentType.uid, (schema: Struct.ContentTypeSchema) => {\n Object.assign(schema.attributes, {\n [POSITION_ATTRIBUTE]: {\n type: 'integer',\n configurable: false,\n visible: false,\n // Needed for the Content Manager to sort on it, the value itself is only ever\n // written by moving a document\n writable: true,\n private: true,\n },\n });\n\n // Every default list sorts on the position, and moves look for rows without one\n const { identifiers } = strapi.db.metadata;\n const collectionName = schema.collectionName ?? schema.uid;\n\n schema.indexes = [\n ...(schema.indexes ?? []),\n {\n name: identifiers.getIndexName([collectionName, POSITION_ATTRIBUTE]),\n columns: [identifiers.getColumnName(POSITION_ATTRIBUTE)],\n },\n ];\n });\n }\n },\n async bootstrap({ strapi }) {\n if (!isFeatureEnabled(strapi)) {\n return;\n }\n\n await getService(strapi, 'custom-order').bootstrap();\n },\n controllers,\n services,\n routes,\n};\n\nexport default feature;\n"],"names":["isOrderable","contentType","contentTypesUtils","isCollectionType","get","feature","register","strapi","isFeatureEnabled","Object","values","contentTypes","extend","uid","schema","assign","attributes","POSITION_ATTRIBUTE","type","configurable","visible","writable","private","identifiers","db","metadata","collectionName","indexes","name","getIndexName","columns","getColumnName","bootstrap","getService","controllers","services","routes"],"mappings":";;;;;;;;AAUA;;IAGA,MAAMA,WAAAA,GAAc,CAACC,WAAAA,GACnBC,YAAAA,CAAkBC,gBAAgB,CAACF,WAAAA,CAAAA,IACnCG,GAAAA,CAAIH,WAAAA,EAAa,uCAAA,EAAyC,IAAA,CAAA,KAAU,IAAA;AAEtE;;;AAGC,UACKI,OAAAA,GAAwC;IAC5CC,QAAAA,CAAAA,CAAS,EAAEC,MAAM,EAAE,EAAA;QACjB,IAAI,CAACC,iBAAiBD,MAAAA,CAAAA,EAAS;AAC7B,YAAA;AACF,QAAA;AAEA;;;QAIA,KAAK,MAAMN,WAAAA,IAAeQ,MAAAA,CAAOC,MAAM,CAACH,MAAAA,CAAOI,YAAY,CAAA,CAAG;YAC5D,IAAI,CAACX,YAAYC,WAAAA,CAAAA,EAAc;AAC7B,gBAAA;AACF,YAAA;YAEAM,MAAAA,CAAOH,GAAG,CAAC,eAAA,CAAA,CAAiBQ,MAAM,CAACX,WAAAA,CAAYY,GAAG,EAAE,CAACC,MAAAA,GAAAA;AACnDL,gBAAAA,MAAAA,CAAOM,MAAM,CAACD,MAAAA,CAAOE,UAAU,EAAE;AAC/B,oBAAA,CAACC,qBAAqB;wBACpBC,IAAAA,EAAM,SAAA;wBACNC,YAAAA,EAAc,KAAA;wBACdC,OAAAA,EAAS,KAAA;;;wBAGTC,QAAAA,EAAU,IAAA;wBACVC,OAAAA,EAAS;AACX;AACF,iBAAA,CAAA;;AAGA,gBAAA,MAAM,EAAEC,WAAW,EAAE,GAAGhB,MAAAA,CAAOiB,EAAE,CAACC,QAAQ;AAC1C,gBAAA,MAAMC,cAAAA,GAAiBZ,MAAAA,CAAOY,cAAc,IAAIZ,OAAOD,GAAG;AAE1DC,gBAAAA,MAAAA,CAAOa,OAAO,GAAG;uBACXb,MAAAA,CAAOa,OAAO,IAAI,EAAE;AACxB,oBAAA;wBACEC,IAAAA,EAAML,WAAAA,CAAYM,YAAY,CAAC;AAACH,4BAAAA,cAAAA;AAAgBT,4BAAAA;AAAmB,yBAAA,CAAA;wBACnEa,OAAAA,EAAS;AAACP,4BAAAA,WAAAA,CAAYQ,aAAa,CAACd,kBAAAA;AAAoB;AAC1D;AACD,iBAAA;AACH,YAAA,CAAA,CAAA;AACF,QAAA;AACF,IAAA,CAAA;IACA,MAAMe,SAAAA,CAAAA,CAAU,EAAEzB,MAAM,EAAE,EAAA;QACxB,IAAI,CAACC,iBAAiBD,MAAAA,CAAAA,EAAS;AAC7B,YAAA;AACF,QAAA;QAEA,MAAM0B,UAAAA,CAAW1B,MAAAA,EAAQ,cAAA,CAAA,CAAgByB,SAAS,EAAA;AACpD,IAAA,CAAA;AACAE,IAAAA,WAAAA;AACAC,IAAAA,QAAAA;AACAC,IAAAA;AACF;;;;"}
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var routing = require('../../middlewares/routing.js');
4
+
5
+ const info = {
6
+ pluginName: 'content-manager',
7
+ type: 'admin'
8
+ };
9
+ const customOrderRouter = {
10
+ type: 'admin',
11
+ routes: [
12
+ {
13
+ method: 'POST',
14
+ info,
15
+ path: '/collection-types/:model/:id/actions/move',
16
+ handler: 'custom-order.move',
17
+ config: {
18
+ middlewares: [
19
+ routing
20
+ ],
21
+ policies: [
22
+ 'admin::isAuthenticatedAdmin',
23
+ {
24
+ name: 'plugin::content-manager.hasPermissions',
25
+ config: {
26
+ actions: [
27
+ 'plugin::content-manager.explorer.update'
28
+ ]
29
+ }
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ ]
35
+ };
36
+
37
+ exports.customOrderRouter = customOrderRouter;
38
+ //# sourceMappingURL=custom-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-order.js","sources":["../../../../server/src/custom-order/routes/custom-order.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nimport { routing } from '../../middlewares';\n\nconst info = { pluginName: 'content-manager', type: 'admin' };\n\nconst customOrderRouter: Plugin.LoadedPlugin['routes'][string] = {\n type: 'admin',\n routes: [\n {\n method: 'POST',\n info,\n path: '/collection-types/:model/:id/actions/move',\n handler: 'custom-order.move',\n config: {\n middlewares: [routing],\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::content-manager.explorer.update'] },\n },\n ],\n },\n },\n ],\n};\n\nexport { customOrderRouter };\n"],"names":["info","pluginName","type","customOrderRouter","routes","method","path","handler","config","middlewares","routing","policies","name","actions"],"mappings":";;;;AAIA,MAAMA,IAAAA,GAAO;IAAEC,UAAAA,EAAY,iBAAA;IAAmBC,IAAAA,EAAM;AAAQ,CAAA;AAE5D,MAAMC,iBAAAA,GAA2D;IAC/DD,IAAAA,EAAM,OAAA;IACNE,MAAAA,EAAQ;AACN,QAAA;YACEC,MAAAA,EAAQ,MAAA;AACRL,YAAAA,IAAAA;YACAM,IAAAA,EAAM,2CAAA;YACNC,OAAAA,EAAS,mBAAA;YACTC,MAAAA,EAAQ;gBACNC,WAAAA,EAAa;AAACC,oBAAAA;AAAQ,iBAAA;gBACtBC,QAAAA,EAAU;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAAA,EAAM,wCAAA;wBACNJ,MAAAA,EAAQ;4BAAEK,OAAAA,EAAS;AAAC,gCAAA;AAA0C;AAAC;AACjE;AACD;AACH;AACF;AACD;AACH;;;;"}
@@ -0,0 +1,36 @@
1
+ import routing from '../../middlewares/routing.mjs';
2
+
3
+ const info = {
4
+ pluginName: 'content-manager',
5
+ type: 'admin'
6
+ };
7
+ const customOrderRouter = {
8
+ type: 'admin',
9
+ routes: [
10
+ {
11
+ method: 'POST',
12
+ info,
13
+ path: '/collection-types/:model/:id/actions/move',
14
+ handler: 'custom-order.move',
15
+ config: {
16
+ middlewares: [
17
+ routing
18
+ ],
19
+ policies: [
20
+ 'admin::isAuthenticatedAdmin',
21
+ {
22
+ name: 'plugin::content-manager.hasPermissions',
23
+ config: {
24
+ actions: [
25
+ 'plugin::content-manager.explorer.update'
26
+ ]
27
+ }
28
+ }
29
+ ]
30
+ }
31
+ }
32
+ ]
33
+ };
34
+
35
+ export { customOrderRouter };
36
+ //# sourceMappingURL=custom-order.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-order.mjs","sources":["../../../../server/src/custom-order/routes/custom-order.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nimport { routing } from '../../middlewares';\n\nconst info = { pluginName: 'content-manager', type: 'admin' };\n\nconst customOrderRouter: Plugin.LoadedPlugin['routes'][string] = {\n type: 'admin',\n routes: [\n {\n method: 'POST',\n info,\n path: '/collection-types/:model/:id/actions/move',\n handler: 'custom-order.move',\n config: {\n middlewares: [routing],\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::content-manager.explorer.update'] },\n },\n ],\n },\n },\n ],\n};\n\nexport { customOrderRouter };\n"],"names":["info","pluginName","type","customOrderRouter","routes","method","path","handler","config","middlewares","routing","policies","name","actions"],"mappings":";;AAIA,MAAMA,IAAAA,GAAO;IAAEC,UAAAA,EAAY,iBAAA;IAAmBC,IAAAA,EAAM;AAAQ,CAAA;AAE5D,MAAMC,iBAAAA,GAA2D;IAC/DD,IAAAA,EAAM,OAAA;IACNE,MAAAA,EAAQ;AACN,QAAA;YACEC,MAAAA,EAAQ,MAAA;AACRL,YAAAA,IAAAA;YACAM,IAAAA,EAAM,2CAAA;YACNC,OAAAA,EAAS,mBAAA;YACTC,MAAAA,EAAQ;gBACNC,WAAAA,EAAa;AAACC,oBAAAA;AAAQ,iBAAA;gBACtBC,QAAAA,EAAU;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAAA,EAAM,wCAAA;wBACNJ,MAAAA,EAAQ;4BAAEK,OAAAA,EAAS;AAAC,gCAAA;AAA0C;AAAC;AACjE;AACD;AACH;AACF;AACD;AACH;;;;"}
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var customOrder = require('./custom-order.js');
4
+
5
+ /**
6
+ * The routes will be merged with the other Content Manager routers,
7
+ * so we need to avoid conflicts in the router name.
8
+ */ const routes = {
9
+ 'custom-order': customOrder.customOrderRouter
10
+ };
11
+
12
+ exports.routes = routes;
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../server/src/custom-order/routes/index.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\nimport { customOrderRouter } from './custom-order';\n\n/**\n * The routes will be merged with the other Content Manager routers,\n * so we need to avoid conflicts in the router name.\n */\nexport const routes = {\n 'custom-order': customOrderRouter,\n} satisfies Plugin.LoadedPlugin['routes'];\n"],"names":["routes","customOrderRouter"],"mappings":";;;;AAGA;;;UAIaA,MAAAA,GAAS;IACpB,cAAA,EAAgBC;AAClB;;;;"}
@@ -0,0 +1,11 @@
1
+ import { customOrderRouter } from './custom-order.mjs';
2
+
3
+ /**
4
+ * The routes will be merged with the other Content Manager routers,
5
+ * so we need to avoid conflicts in the router name.
6
+ */ const routes = {
7
+ 'custom-order': customOrderRouter
8
+ };
9
+
10
+ export { routes };
11
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../server/src/custom-order/routes/index.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\nimport { customOrderRouter } from './custom-order';\n\n/**\n * The routes will be merged with the other Content Manager routers,\n * so we need to avoid conflicts in the router name.\n */\nexport const routes = {\n 'custom-order': customOrderRouter,\n} satisfies Plugin.LoadedPlugin['routes'];\n"],"names":["routes","customOrderRouter"],"mappings":";;AAGA;;;UAIaA,MAAAA,GAAS;IACpB,cAAA,EAAgBC;AAClB;;;;"}