@open-mercato/core 0.6.6-develop.6089.1.a7ed560528 → 0.6.6-develop.6121.1.5797a901b3

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 (320) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/generated/entities/catalog_product/index.js +52 -0
  3. package/dist/generated/entities/catalog_product/index.js.map +2 -2
  4. package/dist/generated/entities/catalog_product_variant/index.js +4 -0
  5. package/dist/generated/entities/catalog_product_variant/index.js.map +2 -2
  6. package/dist/generated/entity-fields-registry.js +28 -0
  7. package/dist/generated/entity-fields-registry.js.map +2 -2
  8. package/dist/modules/catalog/api/products/route.js +103 -33
  9. package/dist/modules/catalog/api/products/route.js.map +2 -2
  10. package/dist/modules/catalog/api/variants/route.js +4 -0
  11. package/dist/modules/catalog/api/variants/route.js.map +2 -2
  12. package/dist/modules/catalog/backend/catalog/products/[id]/page.js +46 -2
  13. package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
  14. package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js +4 -0
  15. package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js.map +2 -2
  16. package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js +2 -0
  17. package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js.map +2 -2
  18. package/dist/modules/catalog/backend/catalog/products/create/page.js +42 -2
  19. package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
  20. package/dist/modules/catalog/commands/products.js +251 -14
  21. package/dist/modules/catalog/commands/products.js.map +2 -2
  22. package/dist/modules/catalog/commands/variants.js +72 -1
  23. package/dist/modules/catalog/commands/variants.js.map +2 -2
  24. package/dist/modules/catalog/components/products/ProductComplianceSection.js +500 -0
  25. package/dist/modules/catalog/components/products/ProductComplianceSection.js.map +7 -0
  26. package/dist/modules/catalog/components/products/VariantBuilder.js +39 -1
  27. package/dist/modules/catalog/components/products/VariantBuilder.js.map +2 -2
  28. package/dist/modules/catalog/components/products/productForm.js +164 -2
  29. package/dist/modules/catalog/components/products/productForm.js.map +2 -2
  30. package/dist/modules/catalog/components/products/variantForm.js +2 -0
  31. package/dist/modules/catalog/components/products/variantForm.js.map +2 -2
  32. package/dist/modules/catalog/data/entities.js +93 -0
  33. package/dist/modules/catalog/data/entities.js.map +2 -2
  34. package/dist/modules/catalog/data/types.js +28 -0
  35. package/dist/modules/catalog/data/types.js.map +2 -2
  36. package/dist/modules/catalog/data/validators.js +100 -5
  37. package/dist/modules/catalog/data/validators.js.map +2 -2
  38. package/dist/modules/catalog/lib/gtin.js +61 -0
  39. package/dist/modules/catalog/lib/gtin.js.map +7 -0
  40. package/dist/modules/catalog/migrations/Migration20260611090000.js +17 -0
  41. package/dist/modules/catalog/migrations/Migration20260611090000.js.map +7 -0
  42. package/dist/modules/catalog/translations.js +1 -1
  43. package/dist/modules/catalog/translations.js.map +2 -2
  44. package/dist/modules/configs/api/cache/route.js +60 -10
  45. package/dist/modules/configs/api/cache/route.js.map +3 -3
  46. package/dist/modules/configs/components/CachePanel.js +52 -29
  47. package/dist/modules/configs/components/CachePanel.js.map +2 -2
  48. package/dist/modules/currencies/api/currencies/options/route.js +18 -4
  49. package/dist/modules/currencies/api/currencies/options/route.js.map +2 -2
  50. package/dist/modules/currencies/services/rateFetchingService.js +35 -18
  51. package/dist/modules/currencies/services/rateFetchingService.js.map +2 -2
  52. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js +16 -16
  53. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js.map +2 -2
  54. package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js +1 -1
  55. package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js.map +2 -2
  56. package/dist/modules/customers/backend/calendar/page.js +10 -0
  57. package/dist/modules/customers/backend/calendar/page.js.map +7 -0
  58. package/dist/modules/customers/backend/calendar/page.meta.js +25 -0
  59. package/dist/modules/customers/backend/calendar/page.meta.js.map +7 -0
  60. package/dist/modules/customers/cli.js +1 -0
  61. package/dist/modules/customers/cli.js.map +2 -2
  62. package/dist/modules/customers/components/calendar/AgendaList.js +182 -0
  63. package/dist/modules/customers/components/calendar/AgendaList.js.map +7 -0
  64. package/dist/modules/customers/components/calendar/CalendarEventEditor.js +331 -0
  65. package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +7 -0
  66. package/dist/modules/customers/components/calendar/CalendarFooter.js +48 -0
  67. package/dist/modules/customers/components/calendar/CalendarFooter.js.map +7 -0
  68. package/dist/modules/customers/components/calendar/CalendarHeader.js +36 -0
  69. package/dist/modules/customers/components/calendar/CalendarHeader.js.map +7 -0
  70. package/dist/modules/customers/components/calendar/CalendarScreen.js +516 -0
  71. package/dist/modules/customers/components/calendar/CalendarScreen.js.map +7 -0
  72. package/dist/modules/customers/components/calendar/CalendarSettingsModal.js +163 -0
  73. package/dist/modules/customers/components/calendar/CalendarSettingsModal.js.map +7 -0
  74. package/dist/modules/customers/components/calendar/CalendarTabs.js +60 -0
  75. package/dist/modules/customers/components/calendar/CalendarTabs.js.map +7 -0
  76. package/dist/modules/customers/components/calendar/CalendarToolbar.js +262 -0
  77. package/dist/modules/customers/components/calendar/CalendarToolbar.js.map +7 -0
  78. package/dist/modules/customers/components/calendar/EventBlock.js +149 -0
  79. package/dist/modules/customers/components/calendar/EventBlock.js.map +7 -0
  80. package/dist/modules/customers/components/calendar/EventPeekPopover.js +72 -0
  81. package/dist/modules/customers/components/calendar/EventPeekPopover.js.map +7 -0
  82. package/dist/modules/customers/components/calendar/MonthGrid.js +214 -0
  83. package/dist/modules/customers/components/calendar/MonthGrid.js.map +7 -0
  84. package/dist/modules/customers/components/calendar/ShortcutsDialog.js +44 -0
  85. package/dist/modules/customers/components/calendar/ShortcutsDialog.js.map +7 -0
  86. package/dist/modules/customers/components/calendar/TimeGrid.js +410 -0
  87. package/dist/modules/customers/components/calendar/TimeGrid.js.map +7 -0
  88. package/dist/modules/customers/components/calendar/UpcomingCards.js +175 -0
  89. package/dist/modules/customers/components/calendar/UpcomingCards.js.map +7 -0
  90. package/dist/modules/customers/components/calendar/editor/CategoryField.js +75 -0
  91. package/dist/modules/customers/components/calendar/editor/CategoryField.js.map +7 -0
  92. package/dist/modules/customers/components/calendar/editor/LocationField.js +30 -0
  93. package/dist/modules/customers/components/calendar/editor/LocationField.js.map +7 -0
  94. package/dist/modules/customers/components/calendar/editor/PeopleField.js +135 -0
  95. package/dist/modules/customers/components/calendar/editor/PeopleField.js.map +7 -0
  96. package/dist/modules/customers/components/calendar/editor/RelatedToField.js +218 -0
  97. package/dist/modules/customers/components/calendar/editor/RelatedToField.js.map +7 -0
  98. package/dist/modules/customers/components/calendar/editor/RepeatField.js +119 -0
  99. package/dist/modules/customers/components/calendar/editor/RepeatField.js.map +7 -0
  100. package/dist/modules/customers/components/calendar/editor/ScheduleSection.js +83 -0
  101. package/dist/modules/customers/components/calendar/editor/ScheduleSection.js.map +7 -0
  102. package/dist/modules/customers/components/calendar/editor/SegmentGroup.js +44 -0
  103. package/dist/modules/customers/components/calendar/editor/SegmentGroup.js.map +7 -0
  104. package/dist/modules/customers/components/calendar/editor/hooks.js +132 -0
  105. package/dist/modules/customers/components/calendar/editor/hooks.js.map +7 -0
  106. package/dist/modules/customers/components/calendar/editor/inputs.js +160 -0
  107. package/dist/modules/customers/components/calendar/editor/inputs.js.map +7 -0
  108. package/dist/modules/customers/components/calendar/editor/lookups.js +107 -0
  109. package/dist/modules/customers/components/calendar/editor/lookups.js.map +7 -0
  110. package/dist/modules/customers/components/calendar/types.js +30 -0
  111. package/dist/modules/customers/components/calendar/types.js.map +7 -0
  112. package/dist/modules/customers/components/calendar/useCalendarItems.js +131 -0
  113. package/dist/modules/customers/components/calendar/useCalendarItems.js.map +7 -0
  114. package/dist/modules/customers/components/calendar/useCalendarPreferences.js +41 -0
  115. package/dist/modules/customers/components/calendar/useCalendarPreferences.js.map +7 -0
  116. package/dist/modules/customers/lib/calendar/categories.js +28 -0
  117. package/dist/modules/customers/lib/calendar/categories.js.map +7 -0
  118. package/dist/modules/customers/lib/calendar/conflicts.js +72 -0
  119. package/dist/modules/customers/lib/calendar/conflicts.js.map +7 -0
  120. package/dist/modules/customers/lib/calendar/editorPayload.js +271 -0
  121. package/dist/modules/customers/lib/calendar/editorPayload.js.map +7 -0
  122. package/dist/modules/customers/lib/calendar/grid.js +48 -0
  123. package/dist/modules/customers/lib/calendar/grid.js.map +7 -0
  124. package/dist/modules/customers/lib/calendar/layout.js +39 -0
  125. package/dist/modules/customers/lib/calendar/layout.js.map +7 -0
  126. package/dist/modules/customers/lib/calendar/mapItem.js +79 -0
  127. package/dist/modules/customers/lib/calendar/mapItem.js.map +7 -0
  128. package/dist/modules/customers/lib/calendar/preferences.js +71 -0
  129. package/dist/modules/customers/lib/calendar/preferences.js.map +7 -0
  130. package/dist/modules/customers/lib/calendar/range.js +46 -0
  131. package/dist/modules/customers/lib/calendar/range.js.map +7 -0
  132. package/dist/modules/customers/lib/calendar/recurrence.js +113 -0
  133. package/dist/modules/customers/lib/calendar/recurrence.js.map +7 -0
  134. package/dist/modules/dashboards/services/widgetDataService.js +5 -5
  135. package/dist/modules/dashboards/services/widgetDataService.js.map +2 -2
  136. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +61 -1
  137. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
  138. package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +33 -1
  139. package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
  140. package/dist/modules/dictionaries/api/[dictionaryId]/route.js +61 -1
  141. package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
  142. package/dist/modules/dictionaries/api/route.js +33 -1
  143. package/dist/modules/dictionaries/api/route.js.map +2 -2
  144. package/dist/modules/feature_toggles/lib/queries.js +36 -52
  145. package/dist/modules/feature_toggles/lib/queries.js.map +2 -2
  146. package/dist/modules/messages/commands/actions.js +81 -9
  147. package/dist/modules/messages/commands/actions.js.map +2 -2
  148. package/dist/modules/perspectives/api/[tableId]/[perspectiveId]/route.js +32 -1
  149. package/dist/modules/perspectives/api/[tableId]/[perspectiveId]/route.js.map +2 -2
  150. package/dist/modules/perspectives/api/[tableId]/roles/[roleId]/route.js +32 -1
  151. package/dist/modules/perspectives/api/[tableId]/roles/[roleId]/route.js.map +2 -2
  152. package/dist/modules/perspectives/api/[tableId]/route.js +73 -2
  153. package/dist/modules/perspectives/api/[tableId]/route.js.map +2 -2
  154. package/dist/modules/perspectives/services/perspectiveService.js +5 -3
  155. package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
  156. package/dist/modules/planner/api/access.js +9 -0
  157. package/dist/modules/planner/api/access.js.map +2 -2
  158. package/dist/modules/planner/api/availability-date-specific.js +22 -1
  159. package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
  160. package/dist/modules/planner/api/availability-weekly.js +22 -1
  161. package/dist/modules/planner/api/availability-weekly.js.map +2 -2
  162. package/dist/modules/resources/api/resources/tags/assign/route.js +39 -0
  163. package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
  164. package/dist/modules/resources/api/resources/tags/unassign/route.js +39 -0
  165. package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
  166. package/dist/modules/sales/api/settings/document-numbers/route.js +33 -1
  167. package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
  168. package/dist/modules/sales/api/settings/order-editing/route.js +35 -3
  169. package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
  170. package/dist/modules/staff/api/leave-requests/accept/route.js +41 -0
  171. package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
  172. package/dist/modules/staff/api/leave-requests/reject/route.js +41 -0
  173. package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
  174. package/dist/modules/staff/api/team-members/self/route.js +40 -0
  175. package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
  176. package/dist/modules/staff/api/team-members/tags/assign/route.js +41 -0
  177. package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
  178. package/dist/modules/staff/api/team-members/tags/unassign/route.js +41 -0
  179. package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
  180. package/dist/modules/translations/api/[entityType]/[entityId]/route.js +61 -1
  181. package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
  182. package/dist/modules/translations/api/context.js +7 -0
  183. package/dist/modules/translations/api/context.js.map +2 -2
  184. package/dist/modules/translations/api/put/locales.js +33 -1
  185. package/dist/modules/translations/api/put/locales.js.map +2 -2
  186. package/dist/modules/workflows/backend/definitions/visual-editor/page.js +6 -7
  187. package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
  188. package/dist/modules/workflows/backend/instances/[id]/page.js.map +1 -1
  189. package/dist/modules/workflows/components/EdgeEditDialog.js.map +1 -1
  190. package/dist/modules/workflows/components/EdgeEditDialogCrudForm.js.map +1 -1
  191. package/dist/modules/workflows/components/NodeEditDialog.js.map +1 -1
  192. package/dist/modules/workflows/components/NodeEditDialogCrudForm.js.map +1 -1
  193. package/dist/modules/workflows/components/WorkflowGraph.js.map +1 -1
  194. package/dist/modules/workflows/components/WorkflowGraphImpl.js +17 -9
  195. package/dist/modules/workflows/components/WorkflowGraphImpl.js.map +2 -2
  196. package/dist/modules/workflows/components/mobile/MobileVisualEditor.js.map +1 -1
  197. package/dist/modules/workflows/frontend/checkout-demo/deriveCurrentStep.js +8 -0
  198. package/dist/modules/workflows/frontend/checkout-demo/deriveCurrentStep.js.map +7 -0
  199. package/dist/modules/workflows/frontend/checkout-demo/page.js +2 -20
  200. package/dist/modules/workflows/frontend/checkout-demo/page.js.map +2 -2
  201. package/dist/modules/workflows/lib/graph-utils.js +8 -0
  202. package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
  203. package/generated/entities/catalog_product/index.ts +26 -0
  204. package/generated/entities/catalog_product_variant/index.ts +2 -0
  205. package/generated/entity-fields-registry.ts +28 -0
  206. package/package.json +7 -7
  207. package/src/modules/catalog/api/products/route.ts +123 -39
  208. package/src/modules/catalog/api/variants/route.ts +4 -0
  209. package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +43 -0
  210. package/src/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.tsx +14 -0
  211. package/src/modules/catalog/backend/catalog/products/[productId]/variants/create/page.tsx +2 -0
  212. package/src/modules/catalog/backend/catalog/products/create/page.tsx +41 -0
  213. package/src/modules/catalog/commands/products.ts +307 -2
  214. package/src/modules/catalog/commands/variants.ts +90 -1
  215. package/src/modules/catalog/components/products/ProductComplianceSection.tsx +497 -0
  216. package/src/modules/catalog/components/products/VariantBuilder.tsx +43 -0
  217. package/src/modules/catalog/components/products/productForm.ts +262 -0
  218. package/src/modules/catalog/components/products/variantForm.ts +4 -0
  219. package/src/modules/catalog/data/entities.ts +97 -0
  220. package/src/modules/catalog/data/types.ts +36 -0
  221. package/src/modules/catalog/data/validators.ts +159 -3
  222. package/src/modules/catalog/i18n/de.json +64 -0
  223. package/src/modules/catalog/i18n/en.json +64 -0
  224. package/src/modules/catalog/i18n/es.json +64 -0
  225. package/src/modules/catalog/i18n/pl.json +64 -0
  226. package/src/modules/catalog/lib/gtin.ts +66 -0
  227. package/src/modules/catalog/migrations/.snapshot-open-mercato.json +457 -0
  228. package/src/modules/catalog/migrations/Migration20260611090000.ts +17 -0
  229. package/src/modules/catalog/translations.ts +1 -1
  230. package/src/modules/configs/api/cache/route.ts +72 -10
  231. package/src/modules/configs/components/CachePanel.tsx +59 -29
  232. package/src/modules/currencies/api/currencies/options/route.ts +22 -4
  233. package/src/modules/currencies/services/rateFetchingService.ts +63 -26
  234. package/src/modules/customer_accounts/backend/customer_accounts/users/[id]/page.tsx +18 -18
  235. package/src/modules/customer_accounts/backend/customer_accounts/users/page.tsx +1 -1
  236. package/src/modules/customer_accounts/i18n/de.json +1 -1
  237. package/src/modules/customer_accounts/i18n/en.json +1 -1
  238. package/src/modules/customer_accounts/i18n/es.json +1 -1
  239. package/src/modules/customer_accounts/i18n/pl.json +1 -1
  240. package/src/modules/customers/backend/calendar/page.meta.ts +23 -0
  241. package/src/modules/customers/backend/calendar/page.tsx +12 -0
  242. package/src/modules/customers/cli.ts +1 -0
  243. package/src/modules/customers/components/calendar/AgendaList.tsx +219 -0
  244. package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +386 -0
  245. package/src/modules/customers/components/calendar/CalendarFooter.tsx +61 -0
  246. package/src/modules/customers/components/calendar/CalendarHeader.tsx +40 -0
  247. package/src/modules/customers/components/calendar/CalendarScreen.tsx +590 -0
  248. package/src/modules/customers/components/calendar/CalendarSettingsModal.tsx +207 -0
  249. package/src/modules/customers/components/calendar/CalendarTabs.tsx +63 -0
  250. package/src/modules/customers/components/calendar/CalendarToolbar.tsx +295 -0
  251. package/src/modules/customers/components/calendar/EventBlock.tsx +205 -0
  252. package/src/modules/customers/components/calendar/EventPeekPopover.tsx +100 -0
  253. package/src/modules/customers/components/calendar/MonthGrid.tsx +236 -0
  254. package/src/modules/customers/components/calendar/ShortcutsDialog.tsx +57 -0
  255. package/src/modules/customers/components/calendar/TimeGrid.tsx +510 -0
  256. package/src/modules/customers/components/calendar/UpcomingCards.tsx +220 -0
  257. package/src/modules/customers/components/calendar/editor/CategoryField.tsx +79 -0
  258. package/src/modules/customers/components/calendar/editor/LocationField.tsx +37 -0
  259. package/src/modules/customers/components/calendar/editor/PeopleField.tsx +148 -0
  260. package/src/modules/customers/components/calendar/editor/RelatedToField.tsx +242 -0
  261. package/src/modules/customers/components/calendar/editor/RepeatField.tsx +132 -0
  262. package/src/modules/customers/components/calendar/editor/ScheduleSection.tsx +110 -0
  263. package/src/modules/customers/components/calendar/editor/SegmentGroup.tsx +50 -0
  264. package/src/modules/customers/components/calendar/editor/hooks.ts +162 -0
  265. package/src/modules/customers/components/calendar/editor/inputs.tsx +158 -0
  266. package/src/modules/customers/components/calendar/editor/lookups.ts +160 -0
  267. package/src/modules/customers/components/calendar/types.ts +163 -0
  268. package/src/modules/customers/components/calendar/useCalendarItems.ts +162 -0
  269. package/src/modules/customers/components/calendar/useCalendarPreferences.ts +52 -0
  270. package/src/modules/customers/i18n/de.json +195 -0
  271. package/src/modules/customers/i18n/en.json +195 -0
  272. package/src/modules/customers/i18n/es.json +195 -0
  273. package/src/modules/customers/i18n/pl.json +195 -0
  274. package/src/modules/customers/lib/calendar/categories.ts +26 -0
  275. package/src/modules/customers/lib/calendar/conflicts.ts +117 -0
  276. package/src/modules/customers/lib/calendar/editorPayload.ts +388 -0
  277. package/src/modules/customers/lib/calendar/grid.ts +50 -0
  278. package/src/modules/customers/lib/calendar/layout.ts +47 -0
  279. package/src/modules/customers/lib/calendar/mapItem.ts +94 -0
  280. package/src/modules/customers/lib/calendar/preferences.ts +95 -0
  281. package/src/modules/customers/lib/calendar/range.ts +45 -0
  282. package/src/modules/customers/lib/calendar/recurrence.ts +137 -0
  283. package/src/modules/dashboards/services/widgetDataService.ts +8 -6
  284. package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +61 -1
  285. package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +33 -1
  286. package/src/modules/dictionaries/api/[dictionaryId]/route.ts +65 -1
  287. package/src/modules/dictionaries/api/route.ts +36 -1
  288. package/src/modules/feature_toggles/lib/queries.ts +41 -60
  289. package/src/modules/messages/commands/actions.ts +100 -7
  290. package/src/modules/perspectives/api/[tableId]/[perspectiveId]/route.ts +34 -1
  291. package/src/modules/perspectives/api/[tableId]/roles/[roleId]/route.ts +34 -1
  292. package/src/modules/perspectives/api/[tableId]/route.ts +107 -32
  293. package/src/modules/perspectives/services/perspectiveService.ts +9 -5
  294. package/src/modules/planner/api/access.ts +9 -0
  295. package/src/modules/planner/api/availability-date-specific.ts +22 -1
  296. package/src/modules/planner/api/availability-weekly.ts +22 -1
  297. package/src/modules/resources/api/resources/tags/assign/route.ts +42 -0
  298. package/src/modules/resources/api/resources/tags/unassign/route.ts +42 -0
  299. package/src/modules/sales/api/settings/document-numbers/route.ts +35 -1
  300. package/src/modules/sales/api/settings/order-editing/route.ts +37 -3
  301. package/src/modules/staff/api/leave-requests/accept/route.ts +45 -0
  302. package/src/modules/staff/api/leave-requests/reject/route.ts +45 -0
  303. package/src/modules/staff/api/team-members/self/route.ts +43 -0
  304. package/src/modules/staff/api/team-members/tags/assign/route.ts +45 -0
  305. package/src/modules/staff/api/team-members/tags/unassign/route.ts +45 -0
  306. package/src/modules/translations/api/[entityType]/[entityId]/route.ts +65 -1
  307. package/src/modules/translations/api/context.ts +7 -0
  308. package/src/modules/translations/api/put/locales.ts +35 -1
  309. package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +11 -9
  310. package/src/modules/workflows/backend/instances/[id]/page.tsx +1 -1
  311. package/src/modules/workflows/components/EdgeEditDialog.tsx +1 -1
  312. package/src/modules/workflows/components/EdgeEditDialogCrudForm.tsx +1 -1
  313. package/src/modules/workflows/components/NodeEditDialog.tsx +1 -1
  314. package/src/modules/workflows/components/NodeEditDialogCrudForm.tsx +1 -1
  315. package/src/modules/workflows/components/WorkflowGraph.tsx +2 -2
  316. package/src/modules/workflows/components/WorkflowGraphImpl.tsx +27 -13
  317. package/src/modules/workflows/components/mobile/MobileVisualEditor.tsx +3 -3
  318. package/src/modules/workflows/frontend/checkout-demo/deriveCurrentStep.ts +12 -0
  319. package/src/modules/workflows/frontend/checkout-demo/page.tsx +3 -23
  320. package/src/modules/workflows/lib/graph-utils.ts +21 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/catalog/data/validators.ts"],
4
- "sourcesContent": ["import { z } from 'zod'\nimport { CATALOG_PRICE_DISPLAY_MODES, CATALOG_PRODUCT_TYPES } from './types'\nimport { REFERENCE_UNIT_CODES } from '../lib/unitCodes'\nimport {\n getCatalogPriceAmountValidationMessage,\n validateCatalogPriceAmountInput,\n} from '../lib/priceValidation'\n\nconst uuid = () => z.string().uuid()\n\nconst scoped = z.object({\n organizationId: uuid(),\n tenantId: uuid(),\n})\n\nconst tenantScoped = z.object({\n tenantId: uuid(),\n})\n\nconst currencyCodeSchema = z\n .string()\n .trim()\n .regex(/^[A-Z]{3}$/, 'currency code must be a three-letter ISO code')\n\nconst metadataSchema = z.record(z.string(), z.unknown()).optional()\n\nconst slugSchema = z\n .string()\n .trim()\n .toLowerCase()\n .regex(/^[a-z0-9\\-_]+$/, 'code must contain lowercase letters, digits, hyphen, or underscore')\n .max(150)\n\nconst handleSchema = z\n .string()\n .trim()\n .toLowerCase()\n .regex(/^[a-z0-9\\-_]+$/, 'handle must contain lowercase letters, digits, hyphen, or underscore')\n .max(150)\n\nconst skuSchema = z\n .string()\n .trim()\n .regex(/^[A-Za-z0-9\\-_\\.]+$/, 'SKU may include letters, numbers, hyphen, underscore, or period')\n .max(191)\n\nconst variantOptionValuesSchema = z\n .record(\n z\n .string()\n .trim()\n .min(1)\n .max(191),\n z.string().trim().max(255)\n )\n .optional()\n\nconst optionChoiceSchema = z.object({\n code: slugSchema,\n label: z.string().trim().max(255).optional(),\n})\n\nconst optionDefinitionSchema = z.object({\n code: slugSchema,\n label: z.string().trim().min(1).max(255),\n description: z.string().trim().max(2000).optional(),\n inputType: z.enum(['select', 'text', 'textarea', 'number']),\n isRequired: z.boolean().optional(),\n isMultiple: z.boolean().optional(),\n choices: z.array(optionChoiceSchema).max(200).optional(),\n})\n\nconst optionSchema = z.object({\n version: z.number().int().min(1).optional(),\n name: z.string().trim().max(255).optional(),\n description: z.string().trim().max(4000).optional(),\n options: z.array(optionDefinitionSchema).max(64),\n})\n\nconst tagLabelSchema = z.string().trim().min(1).max(100)\n\nconst offerBaseSchema = z.object({\n channelId: uuid(),\n title: z.string().trim().min(1).max(255),\n description: z.string().trim().max(4000).optional(),\n defaultMediaId: uuid().optional().nullable(),\n defaultMediaUrl: z.string().trim().max(500).optional().nullable(),\n metadata: metadataSchema,\n isActive: z.boolean().optional(),\n})\n\nconst offerInputSchema = offerBaseSchema.extend({\n id: uuid().optional(),\n})\n\nexport const offerCreateSchema = scoped.merge(\n offerBaseSchema.extend({\n productId: uuid(),\n })\n)\n\nexport const offerUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(\n offerBaseSchema\n .extend({\n productId: uuid().optional(),\n })\n .partial()\n )\n\nconst productTypeSchema = z.enum(CATALOG_PRODUCT_TYPES)\nconst uomRoundingModeSchema = z.enum(['half_up', 'down', 'up'])\nconst unitPriceReferenceUnitSchema = z.enum(REFERENCE_UNIT_CODES)\nconst unitPriceConfigSchema = z.object({\n enabled: z.boolean().optional(),\n referenceUnit: unitPriceReferenceUnitSchema.nullable().optional(),\n baseQuantity: z.coerce.number().positive().optional(),\n})\n\nconst catalogPriceAmountSchema = z\n .custom<number>((value) => validateCatalogPriceAmountInput(value).ok, {\n message: getCatalogPriceAmountValidationMessage(),\n })\n .transform((value) => {\n const result = validateCatalogPriceAmountInput(value)\n if (!result.ok) {\n throw new Error('catalogPriceAmountSchema transform reached invalid state')\n }\n return result.numeric\n })\n\nfunction productUomCrossFieldRefinement(\n input: {\n defaultUnit?: string | null\n defaultSalesUnit?: string | null\n unitPriceEnabled?: boolean\n unitPriceReferenceUnit?: string | null\n unitPriceBaseQuantity?: number\n unitPrice?: { enabled?: boolean; referenceUnit?: string | null; baseQuantity?: number }\n },\n ctx: z.RefinementCtx,\n) {\n const defaultUnit = typeof input.defaultUnit === 'string' ? input.defaultUnit.trim() : ''\n const defaultSalesUnit =\n typeof input.defaultSalesUnit === 'string' ? input.defaultSalesUnit.trim() : ''\n if (defaultSalesUnit && !defaultUnit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['defaultSalesUnit'],\n message: 'catalog.products.validation.baseUnitRequired',\n })\n }\n const unitPriceEnabled = input.unitPrice?.enabled ?? input.unitPriceEnabled ?? false\n if (!unitPriceEnabled) return\n const referenceUnit =\n input.unitPrice?.referenceUnit ?? input.unitPriceReferenceUnit ?? null\n const baseQuantity =\n input.unitPrice?.baseQuantity ?? input.unitPriceBaseQuantity ?? null\n if (!referenceUnit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['unitPrice'],\n message: 'catalog.products.validation.referenceUnitRequired',\n })\n }\n if (baseQuantity === null || baseQuantity === undefined || Number(baseQuantity) <= 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['unitPrice'],\n message: 'catalog.products.unitPrice.errors.baseQuantity',\n })\n }\n}\n\n// Base schema without refinements (used for .partial() in update schema)\nconst productBaseSchema = scoped.extend({\n title: z.string().trim().min(1).max(255),\n subtitle: z.string().trim().max(255).optional(),\n description: z.string().trim().max(4000).optional(),\n sku: skuSchema.nullable().optional(),\n handle: handleSchema.optional(),\n taxRateId: uuid().nullable().optional(),\n taxRate: z.coerce.number().min(0).max(100).optional().nullable(),\n productType: productTypeSchema.default('simple'),\n statusEntryId: uuid().optional(),\n primaryCurrencyCode: currencyCodeSchema.optional(),\n defaultUnit: z.string().trim().max(50).optional().nullable(),\n defaultSalesUnit: z.string().trim().max(50).optional().nullable(),\n defaultSalesUnitQuantity: z.coerce.number().positive().optional(),\n uomRoundingScale: z.coerce.number().int().min(0).max(6).optional(),\n uomRoundingMode: uomRoundingModeSchema.optional(),\n unitPriceEnabled: z.boolean().optional(),\n unitPriceReferenceUnit: unitPriceReferenceUnitSchema.nullable().optional(),\n unitPriceBaseQuantity: z.coerce.number().positive().optional(),\n unitPrice: unitPriceConfigSchema.optional(),\n defaultMediaId: uuid().optional().nullable(),\n defaultMediaUrl: z.string().trim().max(500).optional().nullable(),\n weightValue: z.coerce.number().min(0).optional().nullable(),\n weightUnit: z.string().trim().max(25).optional().nullable(),\n dimensions: z\n .object({\n width: z.coerce.number().min(0).optional(),\n height: z.coerce.number().min(0).optional(),\n depth: z.coerce.number().min(0).optional(),\n unit: z.string().trim().max(25).optional(),\n })\n .optional()\n .nullable(),\n optionSchemaId: uuid().nullable().optional(),\n optionSchema: optionSchema.optional(),\n customFieldsetCode: slugSchema.nullable().optional(),\n isConfigurable: z.boolean().optional(),\n isActive: z.boolean().optional(),\n metadata: metadataSchema,\n offers: z.array(offerInputSchema.omit({ id: true })).optional(),\n categoryIds: z.array(uuid()).max(100).optional(),\n tags: z.array(tagLabelSchema).max(100).optional(),\n})\n\nexport const productCreateSchema = productBaseSchema\n .superRefine(productUomCrossFieldRefinement)\n\nexport const productUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(productBaseSchema.partial())\n .extend({\n productType: productTypeSchema.optional(),\n })\n .superRefine(productUomCrossFieldRefinement)\n\nexport const variantCreateSchema = scoped.extend({\n productId: uuid(),\n name: z.string().trim().max(255).optional(),\n sku: z\n .string()\n .trim()\n .regex(/^[A-Za-z0-9\\-_\\.]+$/)\n .max(191)\n .optional(),\n barcode: z.string().trim().max(191).optional(),\n statusEntryId: uuid().optional(),\n isDefault: z.boolean().optional(),\n isActive: z.boolean().optional(),\n defaultMediaId: uuid().optional().nullable(),\n defaultMediaUrl: z.string().trim().max(500).optional().nullable(),\n weightValue: z.coerce.number().min(0).optional(),\n weightUnit: z.string().trim().max(25).optional(),\n taxRateId: uuid().nullable().optional(),\n taxRate: z.coerce.number().min(0).max(100).optional().nullable(),\n dimensions: z\n .object({\n width: z.coerce.number().min(0).optional(),\n height: z.coerce.number().min(0).optional(),\n depth: z.coerce.number().min(0).optional(),\n unit: z.string().trim().max(25).optional(),\n })\n .optional(),\n metadata: metadataSchema,\n optionValues: variantOptionValuesSchema,\n customFieldsetCode: slugSchema.nullable().optional(),\n})\n\nexport const variantUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(variantCreateSchema.partial())\n\nexport const optionSchemaTemplateCreateSchema = scoped.extend({\n name: z.string().trim().min(1).max(255),\n code: slugSchema.optional(),\n description: z.string().trim().max(4000).optional(),\n schema: optionSchema,\n metadata: metadataSchema,\n isActive: z.boolean().optional(),\n})\n\nexport const optionSchemaTemplateUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(optionSchemaTemplateCreateSchema.partial())\n\nconst priceDisplayModeSchema = z.enum(CATALOG_PRICE_DISPLAY_MODES)\n\nexport const priceKindCreateSchema = tenantScoped.extend({\n code: slugSchema,\n title: z.string().trim().min(1).max(255),\n displayMode: priceDisplayModeSchema.default('excluding-tax'),\n currencyCode: currencyCodeSchema.optional(),\n isPromotion: z.boolean().optional(),\n isActive: z.boolean().optional(),\n})\n\nexport const priceKindUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(priceKindCreateSchema.partial())\n\nexport const priceCreateSchema = scoped.extend({\n variantId: uuid().optional(),\n productId: uuid().optional(),\n offerId: uuid().optional(),\n currencyCode: currencyCodeSchema,\n priceKindId: uuid(),\n minQuantity: z.coerce.number().int().min(1).optional(),\n maxQuantity: z.coerce.number().int().min(1).optional(),\n unitPriceNet: catalogPriceAmountSchema.optional(),\n unitPriceGross: catalogPriceAmountSchema.optional(),\n taxRate: z.coerce.number().min(0).max(100).optional(),\n taxRateId: uuid().nullable().optional(),\n channelId: uuid().optional(),\n userId: uuid().optional(),\n userGroupId: uuid().optional(),\n customerId: uuid().optional(),\n customerGroupId: uuid().optional(),\n metadata: metadataSchema,\n startsAt: z.coerce.date().optional(),\n endsAt: z.coerce.date().optional(),\n})\n\nexport const priceUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(priceCreateSchema.partial())\n\nexport const categoryCreateSchema = scoped.extend({\n name: z.string().trim().min(1).max(255),\n slug: slugSchema.optional().nullable(),\n description: z.string().trim().max(2000).optional(),\n parentId: uuid().optional().nullable(),\n isActive: z.boolean().optional(),\n})\n\nexport const categoryUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(categoryCreateSchema.partial())\n\nexport const productUnitConversionCreateSchema = scoped.extend({\n productId: uuid(),\n unitCode: z.string().trim().min(1).max(50),\n toBaseFactor: z.coerce.number().positive().max(1_000_000),\n sortOrder: z.coerce.number().int().optional(),\n isActive: z.boolean().optional(),\n metadata: metadataSchema,\n})\n\nexport const productUnitConversionUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(productUnitConversionCreateSchema.omit({ productId: true }).partial())\n\nexport const productUnitConversionDeleteSchema = scoped.extend({\n id: uuid(),\n})\n\nexport type ProductCreateInput = z.infer<typeof productCreateSchema>\nexport type ProductUpdateInput = z.infer<typeof productUpdateSchema>\nexport type VariantCreateInput = z.infer<typeof variantCreateSchema>\nexport type VariantUpdateInput = z.infer<typeof variantUpdateSchema>\nexport type OptionSchemaTemplateCreateInput = z.infer<typeof optionSchemaTemplateCreateSchema>\nexport type OptionSchemaTemplateUpdateInput = z.infer<typeof optionSchemaTemplateUpdateSchema>\nexport type PriceKindCreateInput = z.infer<typeof priceKindCreateSchema>\nexport type PriceKindUpdateInput = z.infer<typeof priceKindUpdateSchema>\nexport type PriceCreateInput = z.infer<typeof priceCreateSchema>\nexport type PriceUpdateInput = z.infer<typeof priceUpdateSchema>\nexport type CategoryCreateInput = z.infer<typeof categoryCreateSchema>\nexport type CategoryUpdateInput = z.infer<typeof categoryUpdateSchema>\nexport type OfferInput = z.infer<typeof offerInputSchema>\nexport type OfferCreateInput = z.infer<typeof offerCreateSchema>\nexport type OfferUpdateInput = z.infer<typeof offerUpdateSchema>\nexport type ProductUnitConversionCreateInput = z.infer<typeof productUnitConversionCreateSchema>\nexport type ProductUnitConversionUpdateInput = z.infer<typeof productUnitConversionUpdateSchema>\nexport type ProductUnitConversionDeleteInput = z.infer<typeof productUnitConversionDeleteSchema>\n"],
5
- "mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,6BAA6B,6BAA6B;AACnE,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,MAAM,OAAO,MAAM,EAAE,OAAO,EAAE,KAAK;AAEnC,MAAM,SAAS,EAAE,OAAO;AAAA,EACtB,gBAAgB,KAAK;AAAA,EACrB,UAAU,KAAK;AACjB,CAAC;AAED,MAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,UAAU,KAAK;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X,CAAC,EACA,MAAM,qBAAqB,QAAQ,CAAC;AAEhC,MAAM,oCAAoC,OAAO,OAAO;AAAA,EAC7D,WAAW,KAAK;AAAA,EAChB,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;AAAA,EACzC,cAAc,EAAE,OAAO,OAAO,EAAE,SAAS,EAAE,IAAI,GAAS;AAAA,EACxD,WAAW,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC5C,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,UAAU;AACZ,CAAC;AAEM,MAAM,oCAAoC,EAC9C,OAAO;AAAA,EACN,IAAI,KAAK;AACX,CAAC,EACA,MAAM,kCAAkC,KAAK,EAAE,WAAW,KAAK,CAAC,EAAE,QAAQ,CAAC;AAEvE,MAAM,oCAAoC,OAAO,OAAO;AAAA,EAC7D,IAAI,KAAK;AACX,CAAC;",
4
+ "sourcesContent": ["import { z } from 'zod'\nimport {\n CATALOG_EXCISE_CATEGORIES,\n CATALOG_GTIN_TYPES,\n CATALOG_GTU_CODES,\n CATALOG_HAZMAT_PACKING_GROUPS,\n CATALOG_PRICE_DISPLAY_MODES,\n CATALOG_PRODUCT_TYPES,\n} from './types'\nimport { isValidGtin, normalizeGtinValue } from '../lib/gtin'\nimport { REFERENCE_UNIT_CODES } from '../lib/unitCodes'\nimport {\n getCatalogPriceAmountValidationMessage,\n validateCatalogPriceAmountInput,\n} from '../lib/priceValidation'\n\nconst uuid = () => z.string().uuid()\n\nconst scoped = z.object({\n organizationId: uuid(),\n tenantId: uuid(),\n})\n\nconst tenantScoped = z.object({\n tenantId: uuid(),\n})\n\nconst currencyCodeSchema = z\n .string()\n .trim()\n .regex(/^[A-Z]{3}$/, 'currency code must be a three-letter ISO code')\n\nconst metadataSchema = z.record(z.string(), z.unknown()).optional()\n\nconst slugSchema = z\n .string()\n .trim()\n .toLowerCase()\n .regex(/^[a-z0-9\\-_]+$/, 'code must contain lowercase letters, digits, hyphen, or underscore')\n .max(150)\n\nconst handleSchema = z\n .string()\n .trim()\n .toLowerCase()\n .regex(/^[a-z0-9\\-_]+$/, 'handle must contain lowercase letters, digits, hyphen, or underscore')\n .max(150)\n\nconst skuSchema = z\n .string()\n .trim()\n .regex(/^[A-Za-z0-9\\-_\\.]+$/, 'SKU may include letters, numbers, hyphen, underscore, or period')\n .max(191)\n\nconst variantOptionValuesSchema = z\n .record(\n z\n .string()\n .trim()\n .min(1)\n .max(191),\n z.string().trim().max(255)\n )\n .optional()\n\nconst optionChoiceSchema = z.object({\n code: slugSchema,\n label: z.string().trim().max(255).optional(),\n})\n\nconst optionDefinitionSchema = z.object({\n code: slugSchema,\n label: z.string().trim().min(1).max(255),\n description: z.string().trim().max(2000).optional(),\n inputType: z.enum(['select', 'text', 'textarea', 'number']),\n isRequired: z.boolean().optional(),\n isMultiple: z.boolean().optional(),\n choices: z.array(optionChoiceSchema).max(200).optional(),\n})\n\nconst optionSchema = z.object({\n version: z.number().int().min(1).optional(),\n name: z.string().trim().max(255).optional(),\n description: z.string().trim().max(4000).optional(),\n options: z.array(optionDefinitionSchema).max(64),\n})\n\nconst tagLabelSchema = z.string().trim().min(1).max(100)\n\nconst offerBaseSchema = z.object({\n channelId: uuid(),\n title: z.string().trim().min(1).max(255),\n description: z.string().trim().max(4000).optional(),\n defaultMediaId: uuid().optional().nullable(),\n defaultMediaUrl: z.string().trim().max(500).optional().nullable(),\n metadata: metadataSchema,\n isActive: z.boolean().optional(),\n})\n\nconst offerInputSchema = offerBaseSchema.extend({\n id: uuid().optional(),\n})\n\nexport const offerCreateSchema = scoped.merge(\n offerBaseSchema.extend({\n productId: uuid(),\n })\n)\n\nexport const offerUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(\n offerBaseSchema\n .extend({\n productId: uuid().optional(),\n })\n .partial()\n )\n\nconst productTypeSchema = z.enum(CATALOG_PRODUCT_TYPES)\nconst uomRoundingModeSchema = z.enum(['half_up', 'down', 'up'])\nconst unitPriceReferenceUnitSchema = z.enum(REFERENCE_UNIT_CODES)\nconst unitPriceConfigSchema = z.object({\n enabled: z.boolean().optional(),\n referenceUnit: unitPriceReferenceUnitSchema.nullable().optional(),\n baseQuantity: z.coerce.number().positive().optional(),\n})\n\nconst catalogPriceAmountSchema = z\n .custom<number>((value) => validateCatalogPriceAmountInput(value).ok, {\n message: getCatalogPriceAmountValidationMessage(),\n })\n .transform((value) => {\n const result = validateCatalogPriceAmountInput(value)\n if (!result.ok) {\n throw new Error('catalogPriceAmountSchema transform reached invalid state')\n }\n return result.numeric\n })\n\nfunction productUomCrossFieldRefinement(\n input: {\n defaultUnit?: string | null\n defaultSalesUnit?: string | null\n unitPriceEnabled?: boolean\n unitPriceReferenceUnit?: string | null\n unitPriceBaseQuantity?: number\n unitPrice?: { enabled?: boolean; referenceUnit?: string | null; baseQuantity?: number }\n },\n ctx: z.RefinementCtx,\n) {\n const defaultUnit = typeof input.defaultUnit === 'string' ? input.defaultUnit.trim() : ''\n const defaultSalesUnit =\n typeof input.defaultSalesUnit === 'string' ? input.defaultSalesUnit.trim() : ''\n if (defaultSalesUnit && !defaultUnit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['defaultSalesUnit'],\n message: 'catalog.products.validation.baseUnitRequired',\n })\n }\n const unitPriceEnabled = input.unitPrice?.enabled ?? input.unitPriceEnabled ?? false\n if (!unitPriceEnabled) return\n const referenceUnit =\n input.unitPrice?.referenceUnit ?? input.unitPriceReferenceUnit ?? null\n const baseQuantity =\n input.unitPrice?.baseQuantity ?? input.unitPriceBaseQuantity ?? null\n if (!referenceUnit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['unitPrice'],\n message: 'catalog.products.validation.referenceUnitRequired',\n })\n }\n if (baseQuantity === null || baseQuantity === undefined || Number(baseQuantity) <= 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['unitPrice'],\n message: 'catalog.products.unitPrice.errors.baseQuantity',\n })\n }\n}\n\n// Base schema without refinements (used for .partial() in update schema)\nconst productBaseSchema = scoped.extend({\n title: z.string().trim().min(1).max(255),\n subtitle: z.string().trim().max(255).optional(),\n description: z.string().trim().max(4000).optional(),\n sku: skuSchema.nullable().optional(),\n handle: handleSchema.optional(),\n taxRateId: uuid().nullable().optional(),\n taxRate: z.coerce.number().min(0).max(100).optional().nullable(),\n productType: productTypeSchema.default('simple'),\n statusEntryId: uuid().optional(),\n primaryCurrencyCode: currencyCodeSchema.optional(),\n defaultUnit: z.string().trim().max(50).optional().nullable(),\n defaultSalesUnit: z.string().trim().max(50).optional().nullable(),\n defaultSalesUnitQuantity: z.coerce.number().positive().optional(),\n uomRoundingScale: z.coerce.number().int().min(0).max(6).optional(),\n uomRoundingMode: uomRoundingModeSchema.optional(),\n unitPriceEnabled: z.boolean().optional(),\n unitPriceReferenceUnit: unitPriceReferenceUnitSchema.nullable().optional(),\n unitPriceBaseQuantity: z.coerce.number().positive().optional(),\n unitPrice: unitPriceConfigSchema.optional(),\n defaultMediaId: uuid().optional().nullable(),\n defaultMediaUrl: z.string().trim().max(500).optional().nullable(),\n weightValue: z.coerce.number().min(0).optional().nullable(),\n weightUnit: z.string().trim().max(25).optional().nullable(),\n dimensions: z\n .object({\n width: z.coerce.number().min(0).optional(),\n height: z.coerce.number().min(0).optional(),\n depth: z.coerce.number().min(0).optional(),\n unit: z.string().trim().max(25).optional(),\n })\n .optional()\n .nullable(),\n optionSchemaId: uuid().nullable().optional(),\n optionSchema: optionSchema.optional(),\n customFieldsetCode: slugSchema.nullable().optional(),\n isConfigurable: z.boolean().optional(),\n isActive: z.boolean().optional(),\n countryOfOriginCode: z\n .string()\n .trim()\n .toUpperCase()\n .regex(/^[A-Z]{2}$/, 'catalog.products.validation.countryCodeInvalid')\n .nullable()\n .optional(),\n pkwiuCode: z.string().trim().min(1).max(32).nullable().optional(),\n cnCode: z.string().trim().min(1).max(32).nullable().optional(),\n hsCode: z.string().trim().min(1).max(32).nullable().optional(),\n taxClassificationCode: z.string().trim().min(1).max(64).nullable().optional(),\n gtuCodes: z\n .array(z.enum(CATALOG_GTU_CODES))\n .max(13)\n .transform((codes) => Array.from(new Set(codes)).sort())\n .nullable()\n .optional(),\n ageMin: z.coerce.number().int().min(0).max(120).nullable().optional(),\n isExciseGood: z.boolean().optional(),\n exciseCategory: z.enum(CATALOG_EXCISE_CATEGORIES).nullable().optional(),\n requiresPrescription: z.boolean().optional(),\n hazmatClass: z.string().trim().min(1).max(32).nullable().optional(),\n unNumber: z\n .string()\n .trim()\n .regex(/^(?:UN)?[0-9]{4}$/i, 'catalog.products.validation.unNumberInvalid')\n .transform((value) => {\n const upper = value.toUpperCase()\n return upper.startsWith('UN') ? upper : `UN${upper}`\n })\n .nullable()\n .optional(),\n hazmatPackingGroup: z.enum(CATALOG_HAZMAT_PACKING_GROUPS).nullable().optional(),\n containsLithiumBattery: z.boolean().optional(),\n launchAt: z.coerce.date().nullable().optional(),\n endOfLifeAt: z.coerce.date().nullable().optional(),\n availableFrom: z.coerce.date().nullable().optional(),\n availableUntil: z.coerce.date().nullable().optional(),\n minOrderQty: z.coerce.number().int().min(1).nullable().optional(),\n maxOrderQty: z.coerce.number().int().min(1).nullable().optional(),\n orderQtyIncrement: z.coerce.number().int().min(1).nullable().optional(),\n requiresShipping: z.boolean().optional(),\n isQuoteOnly: z.boolean().optional(),\n seoTitle: z.string().trim().min(1).max(255).nullable().optional(),\n seoDescription: z.string().trim().min(1).max(1000).nullable().optional(),\n canonicalUrl: z\n .string()\n .trim()\n .max(500)\n .regex(/^https?:\\/\\/\\S+$/, 'catalog.products.validation.canonicalUrlInvalid')\n .nullable()\n .optional(),\n metadata: metadataSchema,\n offers: z.array(offerInputSchema.omit({ id: true })).optional(),\n categoryIds: z.array(uuid()).max(100).optional(),\n tags: z.array(tagLabelSchema).max(100).optional(),\n})\n\n// Cross-field checks chained on the exported schemas only \u2014 refining the base\n// schema itself would break `.partial()` in the update schema.\nconst productComplianceCrossFieldRefinement = (\n input: {\n minOrderQty?: number | null\n maxOrderQty?: number | null\n launchAt?: Date | null\n endOfLifeAt?: Date | null\n availableFrom?: Date | null\n availableUntil?: Date | null\n },\n ctx: z.RefinementCtx,\n) => {\n if (\n input.minOrderQty != null &&\n input.maxOrderQty != null &&\n input.maxOrderQty < input.minOrderQty\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['maxOrderQty'],\n message: 'catalog.products.validation.orderQtyRange',\n })\n }\n if (input.launchAt && input.endOfLifeAt && input.endOfLifeAt < input.launchAt) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['endOfLifeAt'],\n message: 'catalog.products.validation.lifecycleDateRange',\n })\n }\n if (\n input.availableFrom &&\n input.availableUntil &&\n input.availableUntil < input.availableFrom\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['availableUntil'],\n message: 'catalog.products.validation.availabilityDateRange',\n })\n }\n}\n\nexport const productCreateSchema = productBaseSchema\n .superRefine(productUomCrossFieldRefinement)\n .superRefine(productComplianceCrossFieldRefinement)\n\nexport const productUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(productBaseSchema.partial())\n .extend({\n productType: productTypeSchema.optional(),\n })\n .superRefine(productUomCrossFieldRefinement)\n .superRefine(productComplianceCrossFieldRefinement)\n\n// Base schema without refinements (used for .partial() in update schema)\nconst variantBaseSchema = scoped.extend({\n productId: uuid(),\n name: z.string().trim().max(255).optional(),\n sku: z\n .string()\n .trim()\n .regex(/^[A-Za-z0-9\\-_\\.]+$/)\n .max(191)\n .optional(),\n barcode: z.string().trim().max(191).optional(),\n gtinType: z.enum(CATALOG_GTIN_TYPES).nullable().optional(),\n hsCode: z.string().trim().min(1).max(32).nullable().optional(),\n statusEntryId: uuid().optional(),\n isDefault: z.boolean().optional(),\n isActive: z.boolean().optional(),\n defaultMediaId: uuid().optional().nullable(),\n defaultMediaUrl: z.string().trim().max(500).optional().nullable(),\n weightValue: z.coerce.number().min(0).optional(),\n weightUnit: z.string().trim().max(25).optional(),\n taxRateId: uuid().nullable().optional(),\n taxRate: z.coerce.number().min(0).max(100).optional().nullable(),\n dimensions: z\n .object({\n width: z.coerce.number().min(0).optional(),\n height: z.coerce.number().min(0).optional(),\n depth: z.coerce.number().min(0).optional(),\n unit: z.string().trim().max(25).optional(),\n })\n .optional(),\n metadata: metadataSchema,\n optionValues: variantOptionValuesSchema,\n customFieldsetCode: slugSchema.nullable().optional(),\n})\n\n// Payload-level GTIN check. Partial updates carrying only one of\n// (gtinType, barcode) are re-validated against the merged record state in the\n// catalog.variants.update command \u2014 zod cannot see the stored half here.\nconst variantGtinRefinement =\n (mode: 'create' | 'update') =>\n (\n input: {\n gtinType?: (typeof CATALOG_GTIN_TYPES)[number] | null\n barcode?: string\n },\n ctx: z.RefinementCtx,\n ) => {\n const gtinType = input.gtinType\n if (!gtinType) return\n const barcode = input.barcode\n if (barcode === undefined) {\n if (mode === 'create') {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['barcode'],\n message: 'catalog.variants.validation.gtinBarcodeRequired',\n })\n }\n return\n }\n if (!barcode.trim().length) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['barcode'],\n message: 'catalog.variants.validation.gtinBarcodeRequired',\n })\n return\n }\n if (!isValidGtin(gtinType, normalizeGtinValue(gtinType, barcode))) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['barcode'],\n message: 'catalog.variants.validation.gtinChecksum',\n })\n }\n }\n\nexport const variantCreateSchema = variantBaseSchema.superRefine(\n variantGtinRefinement('create'),\n)\n\nexport const variantUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(variantBaseSchema.partial())\n .superRefine(variantGtinRefinement('update'))\n\nexport const optionSchemaTemplateCreateSchema = scoped.extend({\n name: z.string().trim().min(1).max(255),\n code: slugSchema.optional(),\n description: z.string().trim().max(4000).optional(),\n schema: optionSchema,\n metadata: metadataSchema,\n isActive: z.boolean().optional(),\n})\n\nexport const optionSchemaTemplateUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(optionSchemaTemplateCreateSchema.partial())\n\nconst priceDisplayModeSchema = z.enum(CATALOG_PRICE_DISPLAY_MODES)\n\nexport const priceKindCreateSchema = tenantScoped.extend({\n code: slugSchema,\n title: z.string().trim().min(1).max(255),\n displayMode: priceDisplayModeSchema.default('excluding-tax'),\n currencyCode: currencyCodeSchema.optional(),\n isPromotion: z.boolean().optional(),\n isActive: z.boolean().optional(),\n})\n\nexport const priceKindUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(priceKindCreateSchema.partial())\n\nexport const priceCreateSchema = scoped.extend({\n variantId: uuid().optional(),\n productId: uuid().optional(),\n offerId: uuid().optional(),\n currencyCode: currencyCodeSchema,\n priceKindId: uuid(),\n minQuantity: z.coerce.number().int().min(1).optional(),\n maxQuantity: z.coerce.number().int().min(1).optional(),\n unitPriceNet: catalogPriceAmountSchema.optional(),\n unitPriceGross: catalogPriceAmountSchema.optional(),\n taxRate: z.coerce.number().min(0).max(100).optional(),\n taxRateId: uuid().nullable().optional(),\n channelId: uuid().optional(),\n userId: uuid().optional(),\n userGroupId: uuid().optional(),\n customerId: uuid().optional(),\n customerGroupId: uuid().optional(),\n metadata: metadataSchema,\n startsAt: z.coerce.date().optional(),\n endsAt: z.coerce.date().optional(),\n})\n\nexport const priceUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(priceCreateSchema.partial())\n\nexport const categoryCreateSchema = scoped.extend({\n name: z.string().trim().min(1).max(255),\n slug: slugSchema.optional().nullable(),\n description: z.string().trim().max(2000).optional(),\n parentId: uuid().optional().nullable(),\n isActive: z.boolean().optional(),\n})\n\nexport const categoryUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(categoryCreateSchema.partial())\n\nexport const productUnitConversionCreateSchema = scoped.extend({\n productId: uuid(),\n unitCode: z.string().trim().min(1).max(50),\n toBaseFactor: z.coerce.number().positive().max(1_000_000),\n sortOrder: z.coerce.number().int().optional(),\n isActive: z.boolean().optional(),\n metadata: metadataSchema,\n})\n\nexport const productUnitConversionUpdateSchema = z\n .object({\n id: uuid(),\n })\n .merge(productUnitConversionCreateSchema.omit({ productId: true }).partial())\n\nexport const productUnitConversionDeleteSchema = scoped.extend({\n id: uuid(),\n})\n\nexport type ProductCreateInput = z.infer<typeof productCreateSchema>\nexport type ProductUpdateInput = z.infer<typeof productUpdateSchema>\nexport type VariantCreateInput = z.infer<typeof variantCreateSchema>\nexport type VariantUpdateInput = z.infer<typeof variantUpdateSchema>\nexport type OptionSchemaTemplateCreateInput = z.infer<typeof optionSchemaTemplateCreateSchema>\nexport type OptionSchemaTemplateUpdateInput = z.infer<typeof optionSchemaTemplateUpdateSchema>\nexport type PriceKindCreateInput = z.infer<typeof priceKindCreateSchema>\nexport type PriceKindUpdateInput = z.infer<typeof priceKindUpdateSchema>\nexport type PriceCreateInput = z.infer<typeof priceCreateSchema>\nexport type PriceUpdateInput = z.infer<typeof priceUpdateSchema>\nexport type CategoryCreateInput = z.infer<typeof categoryCreateSchema>\nexport type CategoryUpdateInput = z.infer<typeof categoryUpdateSchema>\nexport type OfferInput = z.infer<typeof offerInputSchema>\nexport type OfferCreateInput = z.infer<typeof offerCreateSchema>\nexport type OfferUpdateInput = z.infer<typeof offerUpdateSchema>\nexport type ProductUnitConversionCreateInput = z.infer<typeof productUnitConversionCreateSchema>\nexport type ProductUnitConversionUpdateInput = z.infer<typeof productUnitConversionUpdateSchema>\nexport type ProductUnitConversionDeleteInput = z.infer<typeof productUnitConversionDeleteSchema>\n"],
5
+ "mappings": "AAAA,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,0BAA0B;AAChD,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,MAAM,OAAO,MAAM,EAAE,OAAO,EAAE,KAAK;AAEnC,MAAM,SAAS,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,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,EACtC,MAAM,WAAW,SAAS,EAAE,SAAS;AAAA,EACrC,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAI,EAAE,SAAS;AAAA,EAClD,UAAU,KAAK,EAAE,SAAS,EAAE,SAAS;AAAA,EACrC,UAAU,EAAE,QAAQ,EAAE,SAAS;AACjC,CAAC;AAEM,MAAM,uBAAuB,EACjC,OAAO;AAAA,EACN,IAAI,KAAK;AACX,CAAC,EACA,MAAM,qBAAqB,QAAQ,CAAC;AAEhC,MAAM,oCAAoC,OAAO,OAAO;AAAA,EAC7D,WAAW,KAAK;AAAA,EAChB,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;AAAA,EACzC,cAAc,EAAE,OAAO,OAAO,EAAE,SAAS,EAAE,IAAI,GAAS;AAAA,EACxD,WAAW,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC5C,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,UAAU;AACZ,CAAC;AAEM,MAAM,oCAAoC,EAC9C,OAAO;AAAA,EACN,IAAI,KAAK;AACX,CAAC,EACA,MAAM,kCAAkC,KAAK,EAAE,WAAW,KAAK,CAAC,EAAE,QAAQ,CAAC;AAEvE,MAAM,oCAAoC,OAAO,OAAO;AAAA,EAC7D,IAAI,KAAK;AACX,CAAC;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,61 @@
1
+ const DIGITS_ONLY = /^[0-9]+$/;
2
+ const ASIN_PATTERN = /^[A-Z0-9]{10}$/;
3
+ const ISBN10_PATTERN = /^[0-9]{9}[0-9X]$/;
4
+ const GTIN_DIGIT_LENGTHS = {
5
+ ean13: 13,
6
+ ean8: 8,
7
+ upc: 12
8
+ };
9
+ const GTIN_MAX_LENGTH = 70;
10
+ function computeGs1CheckDigit(digitsWithoutCheck) {
11
+ let sum = 0;
12
+ let weight = 3;
13
+ for (let index = digitsWithoutCheck.length - 1; index >= 0; index -= 1) {
14
+ sum += (digitsWithoutCheck.charCodeAt(index) - 48) * weight;
15
+ weight = weight === 3 ? 1 : 3;
16
+ }
17
+ return (10 - sum % 10) % 10;
18
+ }
19
+ function hasValidGs1CheckDigit(digits) {
20
+ const body = digits.slice(0, -1);
21
+ const checkDigit = digits.charCodeAt(digits.length - 1) - 48;
22
+ return computeGs1CheckDigit(body) === checkDigit;
23
+ }
24
+ function normalizeGtinValue(type, raw) {
25
+ const trimmed = raw.trim();
26
+ switch (type) {
27
+ case "ean13":
28
+ case "ean8":
29
+ case "upc":
30
+ return trimmed.replace(/\s+/g, "");
31
+ case "isbn":
32
+ return trimmed.replace(/[\s-]+/g, "").toUpperCase();
33
+ case "asin":
34
+ return trimmed.toUpperCase();
35
+ case "mpn":
36
+ return trimmed;
37
+ }
38
+ }
39
+ function isValidGtin(type, normalizedValue) {
40
+ if (!normalizedValue.length || normalizedValue.length > GTIN_MAX_LENGTH) return false;
41
+ const gs1Length = GTIN_DIGIT_LENGTHS[type];
42
+ if (gs1Length !== void 0) {
43
+ return normalizedValue.length === gs1Length && DIGITS_ONLY.test(normalizedValue) && hasValidGs1CheckDigit(normalizedValue);
44
+ }
45
+ if (type === "isbn") {
46
+ if (normalizedValue.length === 10) return ISBN10_PATTERN.test(normalizedValue);
47
+ if (normalizedValue.length === 13) return DIGITS_ONLY.test(normalizedValue);
48
+ return false;
49
+ }
50
+ if (type === "asin") {
51
+ return ASIN_PATTERN.test(normalizedValue);
52
+ }
53
+ return true;
54
+ }
55
+ export {
56
+ GTIN_MAX_LENGTH,
57
+ computeGs1CheckDigit,
58
+ isValidGtin,
59
+ normalizeGtinValue
60
+ };
61
+ //# sourceMappingURL=gtin.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/catalog/lib/gtin.ts"],
4
+ "sourcesContent": ["import type { CatalogGtinType } from '../data/types'\n\nconst DIGITS_ONLY = /^[0-9]+$/\nconst ASIN_PATTERN = /^[A-Z0-9]{10}$/\nconst ISBN10_PATTERN = /^[0-9]{9}[0-9X]$/\n\nconst GTIN_DIGIT_LENGTHS: Partial<Record<CatalogGtinType, number>> = {\n ean13: 13,\n ean8: 8,\n upc: 12,\n}\n\nexport const GTIN_MAX_LENGTH = 70\n\nexport function computeGs1CheckDigit(digitsWithoutCheck: string): number {\n let sum = 0\n let weight = 3\n for (let index = digitsWithoutCheck.length - 1; index >= 0; index -= 1) {\n sum += (digitsWithoutCheck.charCodeAt(index) - 48) * weight\n weight = weight === 3 ? 1 : 3\n }\n return (10 - (sum % 10)) % 10\n}\n\nfunction hasValidGs1CheckDigit(digits: string): boolean {\n const body = digits.slice(0, -1)\n const checkDigit = digits.charCodeAt(digits.length - 1) - 48\n return computeGs1CheckDigit(body) === checkDigit\n}\n\nexport function normalizeGtinValue(type: CatalogGtinType, raw: string): string {\n const trimmed = raw.trim()\n switch (type) {\n case 'ean13':\n case 'ean8':\n case 'upc':\n return trimmed.replace(/\\s+/g, '')\n case 'isbn':\n return trimmed.replace(/[\\s-]+/g, '').toUpperCase()\n case 'asin':\n return trimmed.toUpperCase()\n case 'mpn':\n return trimmed\n }\n}\n\nexport function isValidGtin(type: CatalogGtinType, normalizedValue: string): boolean {\n if (!normalizedValue.length || normalizedValue.length > GTIN_MAX_LENGTH) return false\n const gs1Length = GTIN_DIGIT_LENGTHS[type]\n if (gs1Length !== undefined) {\n return (\n normalizedValue.length === gs1Length &&\n DIGITS_ONLY.test(normalizedValue) &&\n hasValidGs1CheckDigit(normalizedValue)\n )\n }\n if (type === 'isbn') {\n if (normalizedValue.length === 10) return ISBN10_PATTERN.test(normalizedValue)\n if (normalizedValue.length === 13) return DIGITS_ONLY.test(normalizedValue)\n return false\n }\n if (type === 'asin') {\n return ASIN_PATTERN.test(normalizedValue)\n }\n return true\n}\n"],
5
+ "mappings": "AAEA,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAA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;AAC1E,WAAO;AAAA,EACT;AACA,MAAI,SAAS,QAAQ;AACnB,WAAO,aAAa,KAAK,eAAe;AAAA,EAC1C;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,17 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ class Migration20260611090000 extends Migration {
3
+ async up() {
4
+ this.addSql(`alter table "catalog_products" add column if not exists "country_of_origin_code" text null, add column if not exists "pkwiu_code" text null, add column if not exists "cn_code" text null, add column if not exists "hs_code" text null, add column if not exists "tax_classification_code" text null, add column if not exists "gtu_codes" text[] null, add column if not exists "age_min" smallint null, add column if not exists "is_excise_good" boolean not null default false, add column if not exists "excise_category" text null, add column if not exists "requires_prescription" boolean not null default false, add column if not exists "hazmat_class" text null, add column if not exists "un_number" text null, add column if not exists "hazmat_packing_group" text null, add column if not exists "contains_lithium_battery" boolean not null default false, add column if not exists "launch_at" timestamptz null, add column if not exists "end_of_life_at" timestamptz null, add column if not exists "available_from" timestamptz null, add column if not exists "available_until" timestamptz null, add column if not exists "min_order_qty" int null, add column if not exists "max_order_qty" int null, add column if not exists "order_qty_increment" int null, add column if not exists "requires_shipping" boolean not null default true, add column if not exists "is_quote_only" boolean not null default false, add column if not exists "seo_title" text null, add column if not exists "seo_description" text null, add column if not exists "canonical_url" text null;`);
5
+ this.addSql(`alter table "catalog_product_variants" add column if not exists "gtin_type" text null, add column if not exists "hs_code" text null;`);
6
+ this.addSql(`create unique index "catalog_product_variants_gtin_scope_unique" on "catalog_product_variants" ("tenant_id", "organization_id", "gtin_type", "barcode") where deleted_at is null and gtin_type is not null and barcode is not null;`);
7
+ }
8
+ async down() {
9
+ this.addSql(`drop index if exists "catalog_product_variants_gtin_scope_unique";`);
10
+ this.addSql(`alter table "catalog_product_variants" drop column if exists "gtin_type", drop column if exists "hs_code";`);
11
+ this.addSql(`alter table "catalog_products" drop column if exists "country_of_origin_code", drop column if exists "pkwiu_code", drop column if exists "cn_code", drop column if exists "hs_code", drop column if exists "tax_classification_code", drop column if exists "gtu_codes", drop column if exists "age_min", drop column if exists "is_excise_good", drop column if exists "excise_category", drop column if exists "requires_prescription", drop column if exists "hazmat_class", drop column if exists "un_number", drop column if exists "hazmat_packing_group", drop column if exists "contains_lithium_battery", drop column if exists "launch_at", drop column if exists "end_of_life_at", drop column if exists "available_from", drop column if exists "available_until", drop column if exists "min_order_qty", drop column if exists "max_order_qty", drop column if exists "order_qty_increment", drop column if exists "requires_shipping", drop column if exists "is_quote_only", drop column if exists "seo_title", drop column if exists "seo_description", drop column if exists "canonical_url";`);
12
+ }
13
+ }
14
+ export {
15
+ Migration20260611090000
16
+ };
17
+ //# sourceMappingURL=Migration20260611090000.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/catalog/migrations/Migration20260611090000.ts"],
4
+ "sourcesContent": ["import { Migration } from '@mikro-orm/migrations';\n\nexport class Migration20260611090000 extends Migration {\n\n override async up(): Promise<void> {\n this.addSql(`alter table \"catalog_products\" add column if not exists \"country_of_origin_code\" text null, add column if not exists \"pkwiu_code\" text null, add column if not exists \"cn_code\" text null, add column if not exists \"hs_code\" text null, add column if not exists \"tax_classification_code\" text null, add column if not exists \"gtu_codes\" text[] null, add column if not exists \"age_min\" smallint null, add column if not exists \"is_excise_good\" boolean not null default false, add column if not exists \"excise_category\" text null, add column if not exists \"requires_prescription\" boolean not null default false, add column if not exists \"hazmat_class\" text null, add column if not exists \"un_number\" text null, add column if not exists \"hazmat_packing_group\" text null, add column if not exists \"contains_lithium_battery\" boolean not null default false, add column if not exists \"launch_at\" timestamptz null, add column if not exists \"end_of_life_at\" timestamptz null, add column if not exists \"available_from\" timestamptz null, add column if not exists \"available_until\" timestamptz null, add column if not exists \"min_order_qty\" int null, add column if not exists \"max_order_qty\" int null, add column if not exists \"order_qty_increment\" int null, add column if not exists \"requires_shipping\" boolean not null default true, add column if not exists \"is_quote_only\" boolean not null default false, add column if not exists \"seo_title\" text null, add column if not exists \"seo_description\" text null, add column if not exists \"canonical_url\" text null;`);\n this.addSql(`alter table \"catalog_product_variants\" add column if not exists \"gtin_type\" text null, add column if not exists \"hs_code\" text null;`);\n this.addSql(`create unique index \"catalog_product_variants_gtin_scope_unique\" on \"catalog_product_variants\" (\"tenant_id\", \"organization_id\", \"gtin_type\", \"barcode\") where deleted_at is null and gtin_type is not null and barcode is not null;`);\n }\n\n override async down(): Promise<void> {\n this.addSql(`drop index if exists \"catalog_product_variants_gtin_scope_unique\";`);\n this.addSql(`alter table \"catalog_product_variants\" drop column if exists \"gtin_type\", drop column if exists \"hs_code\";`);\n this.addSql(`alter table \"catalog_products\" drop column if exists \"country_of_origin_code\", drop column if exists \"pkwiu_code\", drop column if exists \"cn_code\", drop column if exists \"hs_code\", drop column if exists \"tax_classification_code\", drop column if exists \"gtu_codes\", drop column if exists \"age_min\", drop column if exists \"is_excise_good\", drop column if exists \"excise_category\", drop column if exists \"requires_prescription\", drop column if exists \"hazmat_class\", drop column if exists \"un_number\", drop column if exists \"hazmat_packing_group\", drop column if exists \"contains_lithium_battery\", drop column if exists \"launch_at\", drop column if exists \"end_of_life_at\", drop column if exists \"available_from\", drop column if exists \"available_until\", drop column if exists \"min_order_qty\", drop column if exists \"max_order_qty\", drop column if exists \"order_qty_increment\", drop column if exists \"requires_shipping\", drop column if exists \"is_quote_only\", drop column if exists \"seo_title\", drop column if exists \"seo_description\", drop column if exists \"canonical_url\";`);\n }\n\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAEnB,MAAM,gCAAgC,UAAU;AAAA,EAErD,MAAe,KAAoB;AACjC,SAAK,OAAO,ygDAAygD;AACrhD,SAAK,OAAO,sIAAsI;AAClJ,SAAK,OAAO,qOAAqO;AAAA,EACnP;AAAA,EAEA,MAAe,OAAsB;AACnC,SAAK,OAAO,oEAAoE;AAChF,SAAK,OAAO,4GAA4G;AACxH,SAAK,OAAO,gjCAAgjC;AAAA,EAC9jC;AAEF;",
6
+ "names": []
7
+ }
@@ -1,5 +1,5 @@
1
1
  const translatableFields = {
2
- "catalog:catalog_product": ["title", "subtitle", "description"],
2
+ "catalog:catalog_product": ["title", "subtitle", "description", "seoTitle", "seoDescription"],
3
3
  "catalog:catalog_product_variant": ["name"],
4
4
  "catalog:catalog_offer": ["title", "subtitle", "description"],
5
5
  "catalog:catalog_option_schema_template": ["name", "description"],
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/modules/catalog/translations.ts"],
4
- "sourcesContent": ["export const translatableFields: Record<string, string[]> = {\n 'catalog:catalog_product': ['title', 'subtitle', 'description'],\n 'catalog:catalog_product_variant': ['name'],\n 'catalog:catalog_offer': ['title', 'subtitle', 'description'],\n 'catalog:catalog_option_schema_template': ['name', 'description'],\n 'catalog:catalog_product_category': ['name', 'description'],\n 'catalog:catalog_product_tag': ['label'],\n}\n\nexport default translatableFields\n"],
5
- "mappings": "AAAO,MAAM,qBAA+C;AAAA,EAC1D,2BAA2B,CAAC,SAAS,YAAY,aAAa;AAAA,EAC9D,mCAAmC,CAAC,MAAM;AAAA,EAC1C,yBAAyB,CAAC,SAAS,YAAY,aAAa;AAAA,EAC5D,0CAA0C,CAAC,QAAQ,aAAa;AAAA,EAChE,oCAAoC,CAAC,QAAQ,aAAa;AAAA,EAC1D,+BAA+B,CAAC,OAAO;AACzC;AAEA,IAAO,uBAAQ;",
4
+ "sourcesContent": ["export const translatableFields: Record<string, string[]> = {\n 'catalog:catalog_product': ['title', 'subtitle', 'description', 'seoTitle', 'seoDescription'],\n 'catalog:catalog_product_variant': ['name'],\n 'catalog:catalog_offer': ['title', 'subtitle', 'description'],\n 'catalog:catalog_option_schema_template': ['name', 'description'],\n 'catalog:catalog_product_category': ['name', 'description'],\n 'catalog:catalog_product_tag': ['label'],\n}\n\nexport default translatableFields\n"],
5
+ "mappings": "AAAO,MAAM,qBAA+C;AAAA,EAC1D,2BAA2B,CAAC,SAAS,YAAY,eAAe,YAAY,gBAAgB;AAAA,EAC5F,mCAAmC,CAAC,MAAM;AAAA,EAC1C,yBAAyB,CAAC,SAAS,YAAY,aAAa;AAAA,EAC5D,0CAA0C,CAAC,QAAQ,aAAa;AAAA,EAChE,oCAAoC,CAAC,QAAQ,aAAa;AAAA,EAC1D,+BAA+B,CAAC,OAAO;AACzC;AAEA,IAAO,uBAAQ;",
6
6
  "names": []
7
7
  }
@@ -4,6 +4,10 @@ import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
4
4
  import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
5
5
  import { runWithCacheTenant } from "@open-mercato/cache";
6
6
  import { collectCrudCacheStats, purgeCrudCacheSegment } from "@open-mercato/shared/lib/crud/cache-stats";
7
+ import {
8
+ bridgeLegacyGuard,
9
+ runMutationGuards
10
+ } from "@open-mercato/shared/lib/crud/mutation-guard-registry";
7
11
  import {
8
12
  configsTag,
9
13
  cacheStatsResponseSchema,
@@ -16,6 +20,10 @@ const metadata = {
16
20
  GET: { requireAuth: true, requireFeatures: ["configs.cache.view"] },
17
21
  POST: { requireAuth: true, requireFeatures: ["configs.cache.manage"] }
18
22
  };
23
+ function resolveUserFeatures(auth) {
24
+ const features = auth?.features;
25
+ return Array.isArray(features) ? features.filter((value) => typeof value === "string") : [];
26
+ }
19
27
  async function GET(req) {
20
28
  const auth = await getAuthFromRequest(req);
21
29
  if (!auth?.sub) {
@@ -68,21 +76,63 @@ async function POST(req) {
68
76
  );
69
77
  }
70
78
  const tenantScope = auth.tenantId ?? null;
71
- if (action === "purgeSegment") {
72
- const segment = typeof body?.segment === "string" ? body.segment.trim() : "";
73
- if (!segment) {
79
+ const segment = action === "purgeSegment" ? typeof body?.segment === "string" ? body.segment.trim() : "" : null;
80
+ if (action === "purgeSegment" && !segment) {
81
+ return NextResponse.json(
82
+ { error: translate("configs.cache.purgeError", "Failed to purge cache segment.") },
83
+ { status: 400 }
84
+ );
85
+ }
86
+ const guardInput = {
87
+ tenantId: tenantScope ?? "",
88
+ organizationId: auth.orgId ?? null,
89
+ userId: auth.sub,
90
+ resourceKind: "configs.cache",
91
+ resourceId: segment ?? tenantScope ?? "all",
92
+ operation: "delete",
93
+ requestMethod: req.method,
94
+ requestHeaders: req.headers,
95
+ mutationPayload: { action, ...segment ? { segment } : {} }
96
+ };
97
+ const guard = bridgeLegacyGuard(container);
98
+ let afterSuccessCallbacks = [];
99
+ if (guard) {
100
+ const guardResult = await runMutationGuards([guard], guardInput, {
101
+ userFeatures: resolveUserFeatures(auth)
102
+ });
103
+ if (!guardResult.ok) {
74
104
  return NextResponse.json(
75
- { error: translate("configs.cache.purgeError", "Failed to purge cache segment.") },
76
- { status: 400 }
105
+ guardResult.errorBody ?? { error: translate("configs.cache.purgeError", "Failed to purge cache segment.") },
106
+ { status: guardResult.errorStatus ?? 422 }
77
107
  );
78
108
  }
109
+ afterSuccessCallbacks = guardResult.afterSuccessCallbacks;
110
+ }
111
+ let responseBody;
112
+ if (action === "purgeSegment") {
79
113
  const result = await runWithCacheTenant(tenantScope, () => purgeCrudCacheSegment(cache, segment));
80
- const stats2 = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache));
81
- return NextResponse.json({ action: "purgeSegment", segment, deleted: result.deleted, stats: stats2 });
114
+ const stats = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache));
115
+ responseBody = { action: "purgeSegment", segment, deleted: result.deleted, stats };
116
+ } else {
117
+ await runWithCacheTenant(tenantScope, () => cache.clear());
118
+ const stats = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache));
119
+ responseBody = { action: "purgeAll", stats };
120
+ }
121
+ for (const callback of afterSuccessCallbacks) {
122
+ if (!callback.guard.afterSuccess) continue;
123
+ await callback.guard.afterSuccess({
124
+ tenantId: tenantScope ?? "",
125
+ organizationId: auth.orgId ?? null,
126
+ userId: auth.sub,
127
+ resourceKind: "configs.cache",
128
+ resourceId: segment ?? tenantScope ?? "all",
129
+ operation: "delete",
130
+ requestMethod: req.method,
131
+ requestHeaders: req.headers,
132
+ metadata: callback.metadata ?? null
133
+ });
82
134
  }
83
- await runWithCacheTenant(tenantScope, () => cache.clear());
84
- const stats = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache));
85
- return NextResponse.json({ action: "purgeAll", stats });
135
+ return NextResponse.json(responseBody);
86
136
  } catch (error) {
87
137
  console.error("[configs.cache] failed to purge cache", error);
88
138
  return NextResponse.json(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/configs/api/cache/route.ts"],
4
- "sourcesContent": ["import { NextResponse } from 'next/server'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { runWithCacheTenant, type CacheStrategy } from '@open-mercato/cache'\nimport { collectCrudCacheStats, purgeCrudCacheSegment } from '@open-mercato/shared/lib/crud/cache-stats'\nimport {\n configsTag,\n cacheStatsResponseSchema,\n cachePurgeRequestSchema,\n cachePurgeAllResponseSchema,\n cachePurgeSegmentResponseSchema,\n configErrorSchema,\n} from '../openapi'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['configs.cache.view'] },\n POST: { requireAuth: true, requireFeatures: ['configs.cache.manage'] },\n} as const\n\nexport async function GET(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth?.sub) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const { translate } = await resolveTranslations()\n\n try {\n const container = await createRequestContainer()\n let cache: CacheStrategy\n try {\n cache = (container.resolve('cache') as CacheStrategy)\n } catch {\n return NextResponse.json(\n { error: translate('configs.cache.unavailable', 'Cache service is unavailable.') },\n { status: 503 },\n )\n }\n const stats = await runWithCacheTenant(auth.tenantId ?? null, () => collectCrudCacheStats(cache))\n return NextResponse.json(stats)\n } catch (error) {\n console.error('[configs.cache] failed to resolve cache stats', error)\n return NextResponse.json(\n { error: translate('configs.cache.unavailable', 'Cache service is unavailable.') },\n { status: 500 },\n )\n }\n}\n\nexport async function POST(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth?.sub) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const { translate } = await resolveTranslations()\n\n let body: any = null\n try {\n body = await req.json()\n } catch {\n body = null\n }\n\n const action = typeof body?.action === 'string' ? body.action : 'purgeAll'\n\n try {\n const container = await createRequestContainer()\n let cache: CacheStrategy\n try {\n cache = (container.resolve('cache') as CacheStrategy)\n } catch {\n return NextResponse.json(\n { error: translate('configs.cache.unavailable', 'Cache service is unavailable.') },\n { status: 503 },\n )\n }\n const tenantScope = auth.tenantId ?? null\n\n if (action === 'purgeSegment') {\n const segment = typeof body?.segment === 'string' ? body.segment.trim() : ''\n if (!segment) {\n return NextResponse.json(\n { error: translate('configs.cache.purgeError', 'Failed to purge cache segment.') },\n { status: 400 },\n )\n }\n const result = await runWithCacheTenant(tenantScope, () => purgeCrudCacheSegment(cache, segment))\n const stats = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache))\n return NextResponse.json({ action: 'purgeSegment', segment, deleted: result.deleted, stats })\n }\n\n await runWithCacheTenant(tenantScope, () => cache.clear())\n const stats = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache))\n return NextResponse.json({ action: 'purgeAll', stats })\n } catch (error) {\n console.error('[configs.cache] failed to purge cache', error)\n return NextResponse.json(\n { error: translate('configs.cache.purgeError', 'Failed to purge cache segment.') },\n { status: 500 },\n )\n }\n}\n\nexport const openApi: OpenApiRouteDoc = {\n tag: configsTag,\n summary: 'Cache management',\n methods: {\n GET: {\n summary: 'Get cache statistics',\n description: 'Returns detailed cache statistics including total entries and breakdown by cache segments. Requires cache service to be available.',\n responses: [\n { status: 200, description: 'Cache statistics', schema: cacheStatsResponseSchema },\n ],\n errors: [\n { status: 401, description: 'Unauthorized', schema: configErrorSchema },\n { status: 500, description: 'Failed to resolve cache stats', schema: configErrorSchema },\n { status: 503, description: 'Cache service unavailable', schema: configErrorSchema },\n ],\n },\n POST: {\n summary: 'Purge cache',\n description: 'Purges cache entries. Supports two actions: purgeAll (clears entire cache) or purgeSegment (clears specific segment). Returns updated cache statistics after purge.',\n requestBody: {\n contentType: 'application/json',\n schema: cachePurgeRequestSchema,\n },\n responses: [\n { status: 200, description: 'All cache cleared successfully', schema: cachePurgeAllResponseSchema },\n { status: 200, description: 'Cache segment cleared successfully', schema: cachePurgeSegmentResponseSchema },\n ],\n errors: [\n { status: 400, description: 'Invalid request - missing segment identifier for purgeSegment action', schema: configErrorSchema },\n { status: 401, description: 'Unauthorized', schema: configErrorSchema },\n { status: 500, description: 'Failed to purge cache', schema: configErrorSchema },\n { status: 503, description: 'Cache service unavailable', schema: configErrorSchema },\n ],\n },\n },\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAE7B,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,0BAA8C;AACvD,SAAS,uBAAuB,6BAA6B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,oBAAoB,EAAE;AAAA,EAClE,MAAM,EAAE,aAAa,MAAM,iBAAiB,CAAC,sBAAsB,EAAE;AACvE;AAEA,eAAsB,IAAI,KAAc;AACtC,QAAM,OAAO,MAAM,mBAAmB,GAAG;AACzC,MAAI,CAAC,MAAM,KAAK;AACd,WAAO,aAAa,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrE;AAEA,QAAM,EAAE,UAAU,IAAI,MAAM,oBAAoB;AAEhD,MAAI;AACF,UAAM,YAAY,MAAM,uBAAuB;AAC/C,QAAI;AACJ,QAAI;AACF,cAAS,UAAU,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AAAA,QACb,QAAQ;AAAA,MACV;AAAA,MACA,WAAW;AAAA,QACT,EAAE,QAAQ,KAAK,aAAa,kCAAkC,QAAQ,4BAA4B;AAAA,QAClG,EAAE,QAAQ,KAAK,aAAa,sCAAsC,QAAQ,gCAAgC;AAAA,MAC5G;AAAA,MACA,QAAQ;AAAA,QACN,EAAE,QAAQ,KAAK,aAAa,wEAAwE,QAAQ,kBAAkB;AAAA,QAC9H,EAAE,QAAQ,KAAK,aAAa,gBAAgB,QAAQ,kBAAkB;AAAA,QACtE,EAAE,QAAQ,KAAK,aAAa,yBAAyB,QAAQ,kBAAkB;AAAA,QAC/E,EAAE,QAAQ,KAAK,aAAa,6BAA6B,QAAQ,kBAAkB;AAAA,MACrF;AAAA,IACF;AAAA,EACF;AACF;",
6
- "names": ["stats"]
4
+ "sourcesContent": ["import { NextResponse } from 'next/server'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { runWithCacheTenant, type CacheStrategy } from '@open-mercato/cache'\nimport { collectCrudCacheStats, purgeCrudCacheSegment } from '@open-mercato/shared/lib/crud/cache-stats'\nimport {\n bridgeLegacyGuard,\n runMutationGuards,\n type MutationGuardInput,\n} from '@open-mercato/shared/lib/crud/mutation-guard-registry'\nimport {\n configsTag,\n cacheStatsResponseSchema,\n cachePurgeRequestSchema,\n cachePurgeAllResponseSchema,\n cachePurgeSegmentResponseSchema,\n configErrorSchema,\n} from '../openapi'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['configs.cache.view'] },\n POST: { requireAuth: true, requireFeatures: ['configs.cache.manage'] },\n} as const\n\nfunction resolveUserFeatures(auth: unknown): string[] {\n const features = (auth as { features?: unknown } | null)?.features\n return Array.isArray(features) ? features.filter((value): value is string => typeof value === 'string') : []\n}\n\nexport async function GET(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth?.sub) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const { translate } = await resolveTranslations()\n\n try {\n const container = await createRequestContainer()\n let cache: CacheStrategy\n try {\n cache = (container.resolve('cache') as CacheStrategy)\n } catch {\n return NextResponse.json(\n { error: translate('configs.cache.unavailable', 'Cache service is unavailable.') },\n { status: 503 },\n )\n }\n const stats = await runWithCacheTenant(auth.tenantId ?? null, () => collectCrudCacheStats(cache))\n return NextResponse.json(stats)\n } catch (error) {\n console.error('[configs.cache] failed to resolve cache stats', error)\n return NextResponse.json(\n { error: translate('configs.cache.unavailable', 'Cache service is unavailable.') },\n { status: 500 },\n )\n }\n}\n\nexport async function POST(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth?.sub) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const { translate } = await resolveTranslations()\n\n let body: any = null\n try {\n body = await req.json()\n } catch {\n body = null\n }\n\n const action = typeof body?.action === 'string' ? body.action : 'purgeAll'\n\n try {\n const container = await createRequestContainer()\n let cache: CacheStrategy\n try {\n cache = (container.resolve('cache') as CacheStrategy)\n } catch {\n return NextResponse.json(\n { error: translate('configs.cache.unavailable', 'Cache service is unavailable.') },\n { status: 503 },\n )\n }\n const tenantScope = auth.tenantId ?? null\n\n const segment =\n action === 'purgeSegment'\n ? (typeof body?.segment === 'string' ? body.segment.trim() : '')\n : null\n if (action === 'purgeSegment' && !segment) {\n return NextResponse.json(\n { error: translate('configs.cache.purgeError', 'Failed to purge cache segment.') },\n { status: 400 },\n )\n }\n\n // Mutation-guard contract for this custom write route (packages/core/AGENTS.md\n // \u2192 API Routes). A cache purge carries no per-record optimistic-lock version, so\n // the default OSS guard short-circuits; wiring it keeps the route on the shared\n // write-guard interception path for any tenant-registered guard.\n const guardInput: MutationGuardInput = {\n tenantId: tenantScope ?? '',\n organizationId: auth.orgId ?? null,\n userId: auth.sub,\n resourceKind: 'configs.cache',\n resourceId: segment ?? tenantScope ?? 'all',\n operation: 'delete',\n requestMethod: req.method,\n requestHeaders: req.headers,\n mutationPayload: { action, ...(segment ? { segment } : {}) },\n }\n const guard = bridgeLegacyGuard(container)\n let afterSuccessCallbacks: Awaited<ReturnType<typeof runMutationGuards>>['afterSuccessCallbacks'] = []\n if (guard) {\n const guardResult = await runMutationGuards([guard], guardInput, {\n userFeatures: resolveUserFeatures(auth),\n })\n if (!guardResult.ok) {\n return NextResponse.json(\n guardResult.errorBody ?? { error: translate('configs.cache.purgeError', 'Failed to purge cache segment.') },\n { status: guardResult.errorStatus ?? 422 },\n )\n }\n afterSuccessCallbacks = guardResult.afterSuccessCallbacks\n }\n\n let responseBody: Record<string, unknown>\n if (action === 'purgeSegment') {\n const result = await runWithCacheTenant(tenantScope, () => purgeCrudCacheSegment(cache, segment!))\n const stats = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache))\n responseBody = { action: 'purgeSegment', segment, deleted: result.deleted, stats }\n } else {\n await runWithCacheTenant(tenantScope, () => cache.clear())\n const stats = await runWithCacheTenant(tenantScope, () => collectCrudCacheStats(cache))\n responseBody = { action: 'purgeAll', stats }\n }\n\n for (const callback of afterSuccessCallbacks) {\n if (!callback.guard.afterSuccess) continue\n await callback.guard.afterSuccess({\n tenantId: tenantScope ?? '',\n organizationId: auth.orgId ?? null,\n userId: auth.sub,\n resourceKind: 'configs.cache',\n resourceId: segment ?? tenantScope ?? 'all',\n operation: 'delete',\n requestMethod: req.method,\n requestHeaders: req.headers,\n metadata: callback.metadata ?? null,\n })\n }\n\n return NextResponse.json(responseBody)\n } catch (error) {\n console.error('[configs.cache] failed to purge cache', error)\n return NextResponse.json(\n { error: translate('configs.cache.purgeError', 'Failed to purge cache segment.') },\n { status: 500 },\n )\n }\n}\n\nexport const openApi: OpenApiRouteDoc = {\n tag: configsTag,\n summary: 'Cache management',\n methods: {\n GET: {\n summary: 'Get cache statistics',\n description: 'Returns detailed cache statistics including total entries and breakdown by cache segments. Requires cache service to be available.',\n responses: [\n { status: 200, description: 'Cache statistics', schema: cacheStatsResponseSchema },\n ],\n errors: [\n { status: 401, description: 'Unauthorized', schema: configErrorSchema },\n { status: 500, description: 'Failed to resolve cache stats', schema: configErrorSchema },\n { status: 503, description: 'Cache service unavailable', schema: configErrorSchema },\n ],\n },\n POST: {\n summary: 'Purge cache',\n description: 'Purges cache entries. Supports two actions: purgeAll (clears entire cache) or purgeSegment (clears specific segment). Returns updated cache statistics after purge.',\n requestBody: {\n contentType: 'application/json',\n schema: cachePurgeRequestSchema,\n },\n responses: [\n { status: 200, description: 'All cache cleared successfully', schema: cachePurgeAllResponseSchema },\n { status: 200, description: 'Cache segment cleared successfully', schema: cachePurgeSegmentResponseSchema },\n ],\n errors: [\n { status: 400, description: 'Invalid request - missing segment identifier for purgeSegment action', schema: configErrorSchema },\n { status: 401, description: 'Unauthorized', schema: configErrorSchema },\n { status: 500, description: 'Failed to purge cache', schema: configErrorSchema },\n { status: 503, description: 'Cache service unavailable', schema: configErrorSchema },\n ],\n },\n },\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAE7B,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,0BAA8C;AACvD,SAAS,uBAAuB,6BAA6B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,oBAAoB,EAAE;AAAA,EAClE,MAAM,EAAE,aAAa,MAAM,iBAAiB,CAAC,sBAAsB,EAAE;AACvE;AAEA,SAAS,oBAAoB,MAAyB;AACpD,QAAM,WAAY,MAAwC;AAC1D,SAAO,MAAM,QAAQ,QAAQ,IAAI,SAAS,OAAO,CAAC,UAA2B,OAAO,UAAU,QAAQ,IAAI,C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AiC,QAAQ,kBAAkB;AAAA,QACvF,EAAE,QAAQ,KAAK,aAAa,6BAA6B,QAAQ,kBAAkB;AAAA,MACrF;AAAA,IACF;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aAAa;AAAA,QACX,aAAa;AAAA,QACb,QAAQ;AAAA,MACV;AAAA,MACA,WAAW;AAAA,QACT,EAAE,QAAQ,KAAK,aAAa,kCAAkC,QAAQ,4BAA4B;AAAA,QAClG,EAAE,QAAQ,KAAK,aAAa,sCAAsC,QAAQ,gCAAgC;AAAA,MAC5G;AAAA,MACA,QAAQ;AAAA,QACN,EAAE,QAAQ,KAAK,aAAa,wEAAwE,QAAQ,kBAAkB;AAAA,QAC9H,EAAE,QAAQ,KAAK,aAAa,gBAAgB,QAAQ,kBAAkB;AAAA,QACtE,EAAE,QAAQ,KAAK,aAAa,yBAAyB,QAAQ,kBAAkB;AAAA,QAC/E,EAAE,QAAQ,KAAK,aAAa,6BAA6B,QAAQ,kBAAkB;AAAA,MACrF;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
7
  }
@@ -4,10 +4,12 @@ import * as React from "react";
4
4
  import { Spinner } from "@open-mercato/ui/primitives/spinner";
5
5
  import { Button } from "@open-mercato/ui/primitives/button";
6
6
  import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
7
+ import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
7
8
  import { flash } from "@open-mercato/ui/backend/FlashMessages";
8
9
  import { useT } from "@open-mercato/shared/lib/i18n/context";
9
10
  import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
10
11
  const API_PATH = "/api/configs/cache";
12
+ const CACHE_MUTATION_CONTEXT_ID = "configs-cache-panel";
11
13
  function CachePanel() {
12
14
  const t = useT();
13
15
  const { confirm, ConfirmDialogElement } = useConfirmDialog();
@@ -16,6 +18,18 @@ function CachePanel() {
16
18
  const [checkingFeature, setCheckingFeature] = React.useState(true);
17
19
  const [purgingAll, setPurgingAll] = React.useState(false);
18
20
  const [segmentPurges, setSegmentPurges] = React.useState({});
21
+ const { runMutation, retryLastMutation } = useGuardedMutation({
22
+ contextId: CACHE_MUTATION_CONTEXT_ID,
23
+ blockedMessage: t("ui.forms.flash.saveBlocked", "Save blocked by validation")
24
+ });
25
+ const cacheMutationContext = React.useMemo(
26
+ () => ({
27
+ formId: CACHE_MUTATION_CONTEXT_ID,
28
+ resourceKind: "configs.cache",
29
+ retryLastMutation
30
+ }),
31
+ [retryLastMutation]
32
+ );
19
33
  const loadStats = React.useCallback(async () => {
20
34
  setState((current) => ({ ...current, loading: true, error: null }));
21
35
  try {
@@ -77,18 +91,22 @@ function CachePanel() {
77
91
  if (!confirmed) return;
78
92
  setPurgingAll(true);
79
93
  try {
80
- const payload = await readApiResultOrThrow(
81
- API_PATH,
82
- {
83
- method: "POST",
84
- headers: { "content-type": "application/json" },
85
- body: JSON.stringify({ action: "purgeAll" })
86
- },
87
- {
88
- errorMessage: t("configs.cache.purgeError", "Failed to purge cache segment."),
89
- allowNullResult: true
90
- }
91
- );
94
+ const payload = await runMutation({
95
+ operation: () => readApiResultOrThrow(
96
+ API_PATH,
97
+ {
98
+ method: "POST",
99
+ headers: { "content-type": "application/json" },
100
+ body: JSON.stringify({ action: "purgeAll" })
101
+ },
102
+ {
103
+ errorMessage: t("configs.cache.purgeError", "Failed to purge cache segment."),
104
+ allowNullResult: true
105
+ }
106
+ ),
107
+ context: cacheMutationContext,
108
+ mutationPayload: { action: "purgeAll" }
109
+ });
92
110
  const stats2 = payload?.stats;
93
111
  if (stats2) {
94
112
  setState({ loading: false, error: null, stats: stats2 });
@@ -103,7 +121,7 @@ function CachePanel() {
103
121
  } finally {
104
122
  setPurgingAll(false);
105
123
  }
106
- }, [canManage, confirm, purgingAll, t, handleRefresh]);
124
+ }, [canManage, confirm, purgingAll, t, handleRefresh, runMutation, cacheMutationContext]);
107
125
  const handlePurgeSegment = React.useCallback(async (segment) => {
108
126
  if (!canManage || segmentPurges[segment]) return;
109
127
  const confirmed = await confirm({
@@ -113,18 +131,22 @@ function CachePanel() {
113
131
  if (!confirmed) return;
114
132
  setSegmentPurges((prev) => ({ ...prev, [segment]: true }));
115
133
  try {
116
- const payload = await readApiResultOrThrow(
117
- API_PATH,
118
- {
119
- method: "POST",
120
- headers: { "content-type": "application/json" },
121
- body: JSON.stringify({ action: "purgeSegment", segment })
122
- },
123
- {
124
- errorMessage: t("configs.cache.purgeError", "Failed to purge cache segment."),
125
- allowNullResult: true
126
- }
127
- );
134
+ const payload = await runMutation({
135
+ operation: () => readApiResultOrThrow(
136
+ API_PATH,
137
+ {
138
+ method: "POST",
139
+ headers: { "content-type": "application/json" },
140
+ body: JSON.stringify({ action: "purgeSegment", segment })
141
+ },
142
+ {
143
+ errorMessage: t("configs.cache.purgeError", "Failed to purge cache segment."),
144
+ allowNullResult: true
145
+ }
146
+ ),
147
+ context: cacheMutationContext,
148
+ mutationPayload: { action: "purgeSegment", segment }
149
+ });
128
150
  const stats2 = payload?.stats;
129
151
  if (stats2) {
130
152
  setState({ loading: false, error: null, stats: stats2 });
@@ -149,7 +171,7 @@ function CachePanel() {
149
171
  return next;
150
172
  });
151
173
  }
152
- }, [canManage, confirm, segmentPurges, t, handleRefresh]);
174
+ }, [canManage, confirm, segmentPurges, t, handleRefresh, runMutation, cacheMutationContext]);
153
175
  if (state.loading) {
154
176
  return /* @__PURE__ */ jsxs("section", { className: "space-y-3 rounded-lg border bg-background p-6", children: [
155
177
  ConfirmDialogElement,
@@ -171,7 +193,7 @@ function CachePanel() {
171
193
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("configs.cache.description", "Inspect cached responses and clear segments when necessary.") })
172
194
  ] }),
173
195
  /* @__PURE__ */ jsx("div", { className: "rounded border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: state.error }),
174
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: handleRefresh, children: t("configs.cache.retry", "Retry") }) })
196
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: /* @__PURE__ */ jsx(Button, { variant: "outline", type: "button", onClick: handleRefresh, children: t("configs.cache.retry", "Retry") }) })
175
197
  ] });
176
198
  }
177
199
  const stats = state.stats;
@@ -195,8 +217,8 @@ function CachePanel() {
195
217
  ] }) : null
196
218
  ] }),
197
219
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
198
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: handleRefresh, children: t("configs.cache.refresh", "Refresh") }),
199
- canShowActions ? /* @__PURE__ */ jsx(Button, { variant: "destructive", disabled: purgingAll, onClick: () => {
220
+ /* @__PURE__ */ jsx(Button, { variant: "outline", type: "button", onClick: handleRefresh, children: t("configs.cache.refresh", "Refresh") }),
221
+ canShowActions ? /* @__PURE__ */ jsx(Button, { variant: "destructive", type: "button", disabled: purgingAll, onClick: () => {
200
222
  void handlePurgeAll();
201
223
  }, children: purgingAll ? t("configs.cache.purgeAllLoading", "Purging\u2026") : t("configs.cache.purgeAll", "Purge all cache") }) : null
202
224
  ] })
@@ -224,6 +246,7 @@ function CachePanel() {
224
246
  {
225
247
  variant: "outline",
226
248
  size: "sm",
249
+ type: "button",
227
250
  disabled: isPurging,
228
251
  onClick: () => {
229
252
  void handlePurgeSegment(segment.segment);