@open-mercato/core 0.6.5-develop.4516.1.88e6ab71a9 → 0.6.5-develop.4544.1.71c003c861

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 (726) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/AGENTS.md +5 -0
  3. package/dist/generated/entities/role/index.js +3 -1
  4. package/dist/generated/entities/role/index.js.map +2 -2
  5. package/dist/generated/entities/step_instance/index.js +2 -0
  6. package/dist/generated/entities/step_instance/index.js.map +2 -2
  7. package/dist/generated/entities/user/index.js +3 -1
  8. package/dist/generated/entities/user/index.js.map +2 -2
  9. package/dist/generated/entities/user_task/index.js +2 -0
  10. package/dist/generated/entities/user_task/index.js.map +2 -2
  11. package/dist/generated/entities/workflow_branch_instance/index.js +39 -0
  12. package/dist/generated/entities/workflow_branch_instance/index.js.map +7 -0
  13. package/dist/generated/entities/workflow_event/index.js +2 -0
  14. package/dist/generated/entities/workflow_event/index.js.map +2 -2
  15. package/dist/generated/entities/workflow_instance/index.js +2 -0
  16. package/dist/generated/entities/workflow_instance/index.js.map +2 -2
  17. package/dist/generated/entities.ids.generated.js +1 -0
  18. package/dist/generated/entities.ids.generated.js.map +2 -2
  19. package/dist/generated/entity-fields-registry.js +26 -0
  20. package/dist/generated/entity-fields-registry.js.map +2 -2
  21. package/dist/helpers/integration/optimisticLockUi.js +104 -0
  22. package/dist/helpers/integration/optimisticLockUi.js.map +7 -0
  23. package/dist/helpers/integration/salesFixtures.js +17 -0
  24. package/dist/helpers/integration/salesFixtures.js.map +2 -2
  25. package/dist/modules/api_keys/backend/api-keys/page.js +9 -5
  26. package/dist/modules/api_keys/backend/api-keys/page.js.map +2 -2
  27. package/dist/modules/attachments/components/AttachmentPartitionSettings.js +17 -9
  28. package/dist/modules/attachments/components/AttachmentPartitionSettings.js.map +2 -2
  29. package/dist/modules/auth/api/roles/acl/route.js +32 -13
  30. package/dist/modules/auth/api/roles/acl/route.js.map +2 -2
  31. package/dist/modules/auth/api/roles/route.js +3 -1
  32. package/dist/modules/auth/api/roles/route.js.map +2 -2
  33. package/dist/modules/auth/api/sidebar/preferences/route.js +71 -3
  34. package/dist/modules/auth/api/sidebar/preferences/route.js.map +2 -2
  35. package/dist/modules/auth/api/users/acl/route.js +42 -19
  36. package/dist/modules/auth/api/users/acl/route.js.map +2 -2
  37. package/dist/modules/auth/api/users/route.js +3 -1
  38. package/dist/modules/auth/api/users/route.js.map +2 -2
  39. package/dist/modules/auth/backend/roles/[id]/edit/page.js +24 -4
  40. package/dist/modules/auth/backend/roles/[id]/edit/page.js.map +2 -2
  41. package/dist/modules/auth/backend/roles/page.js +8 -4
  42. package/dist/modules/auth/backend/roles/page.js.map +2 -2
  43. package/dist/modules/auth/backend/users/[id]/edit/page.js +27 -5
  44. package/dist/modules/auth/backend/users/[id]/edit/page.js.map +2 -2
  45. package/dist/modules/auth/backend/users/page.js +6 -2
  46. package/dist/modules/auth/backend/users/page.js.map +2 -2
  47. package/dist/modules/auth/components/AclEditor.js +3 -1
  48. package/dist/modules/auth/components/AclEditor.js.map +2 -2
  49. package/dist/modules/auth/data/entities.js +6 -0
  50. package/dist/modules/auth/data/entities.js.map +2 -2
  51. package/dist/modules/auth/services/sidebarPreferencesService.js +32 -4
  52. package/dist/modules/auth/services/sidebarPreferencesService.js.map +2 -2
  53. package/dist/modules/business_rules/api/rules/route.js +28 -0
  54. package/dist/modules/business_rules/api/rules/route.js.map +2 -2
  55. package/dist/modules/business_rules/api/sets/route.js +28 -0
  56. package/dist/modules/business_rules/api/sets/route.js.map +2 -2
  57. package/dist/modules/business_rules/backend/rules/[id]/page.js +11 -4
  58. package/dist/modules/business_rules/backend/rules/[id]/page.js.map +3 -3
  59. package/dist/modules/business_rules/backend/rules/page.js +20 -11
  60. package/dist/modules/business_rules/backend/rules/page.js.map +2 -2
  61. package/dist/modules/business_rules/backend/sets/[id]/page.js +11 -4
  62. package/dist/modules/business_rules/backend/sets/[id]/page.js.map +2 -2
  63. package/dist/modules/business_rules/backend/sets/page.js +20 -11
  64. package/dist/modules/business_rules/backend/sets/page.js.map +2 -2
  65. package/dist/modules/catalog/api/categories/route.js +2 -0
  66. package/dist/modules/catalog/api/categories/route.js.map +2 -2
  67. package/dist/modules/catalog/api/products/route.js +2 -1
  68. package/dist/modules/catalog/api/products/route.js.map +2 -2
  69. package/dist/modules/catalog/backend/catalog/categories/[id]/edit/page.js +2 -0
  70. package/dist/modules/catalog/backend/catalog/categories/[id]/edit/page.js.map +2 -2
  71. package/dist/modules/catalog/backend/catalog/products/[id]/page.js +94 -40
  72. package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
  73. package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js +37 -8
  74. package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js.map +2 -2
  75. package/dist/modules/catalog/backend/catalog/products/optionSchemaClient.js.map +2 -2
  76. package/dist/modules/catalog/commands/variants.js +32 -31
  77. package/dist/modules/catalog/commands/variants.js.map +2 -2
  78. package/dist/modules/catalog/components/PriceKindSettings.js +12 -5
  79. package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
  80. package/dist/modules/catalog/components/categories/CategoriesDataTable.js.map +2 -2
  81. package/dist/modules/catalog/components/products/ProductMediaManager.js.map +2 -2
  82. package/dist/modules/catalog/components/products/ProductsDataTable.js +5 -3
  83. package/dist/modules/catalog/components/products/ProductsDataTable.js.map +2 -2
  84. package/dist/modules/catalog/components/products/productForm.js.map +2 -2
  85. package/dist/modules/catalog/components/products/variantForm.js +2 -1
  86. package/dist/modules/catalog/components/products/variantForm.js.map +2 -2
  87. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js +5 -0
  88. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js.map +2 -2
  89. package/dist/modules/currencies/backend/currencies/[id]/page.js +6 -3
  90. package/dist/modules/currencies/backend/currencies/[id]/page.js.map +2 -2
  91. package/dist/modules/currencies/backend/currencies/page.js +18 -11
  92. package/dist/modules/currencies/backend/currencies/page.js.map +2 -2
  93. package/dist/modules/currencies/backend/exchange-rates/[id]/page.js +1 -0
  94. package/dist/modules/currencies/backend/exchange-rates/[id]/page.js.map +2 -2
  95. package/dist/modules/currencies/backend/exchange-rates/page.js +10 -6
  96. package/dist/modules/currencies/backend/exchange-rates/page.js.map +2 -2
  97. package/dist/modules/currencies/commands/currencies.js +7 -5
  98. package/dist/modules/currencies/commands/currencies.js.map +2 -2
  99. package/dist/modules/currencies/components/CurrencyFetchingConfig.js +26 -19
  100. package/dist/modules/currencies/components/CurrencyFetchingConfig.js.map +2 -2
  101. package/dist/modules/customer_accounts/api/admin/roles/[id].js +28 -5
  102. package/dist/modules/customer_accounts/api/admin/roles/[id].js.map +2 -2
  103. package/dist/modules/customer_accounts/api/admin/roles.js +4 -2
  104. package/dist/modules/customer_accounts/api/admin/roles.js.map +2 -2
  105. package/dist/modules/customer_accounts/api/admin/users/[id].js +28 -5
  106. package/dist/modules/customer_accounts/api/admin/users/[id].js.map +2 -2
  107. package/dist/modules/customer_accounts/api/admin/users.js +2 -0
  108. package/dist/modules/customer_accounts/api/admin/users.js.map +2 -2
  109. package/dist/modules/customer_accounts/backend/customer_accounts/roles/[id]/page.js +16 -8
  110. package/dist/modules/customer_accounts/backend/customer_accounts/roles/[id]/page.js.map +2 -2
  111. package/dist/modules/customer_accounts/backend/customer_accounts/roles/page.js +8 -4
  112. package/dist/modules/customer_accounts/backend/customer_accounts/roles/page.js.map +2 -2
  113. package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/page.js +8 -4
  114. package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/page.js.map +2 -2
  115. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js +29 -18
  116. package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js.map +2 -2
  117. package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js +18 -11
  118. package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js.map +2 -2
  119. package/dist/modules/customers/api/companies/route.js +13 -2
  120. package/dist/modules/customers/api/companies/route.js.map +2 -2
  121. package/dist/modules/customers/api/deals/route.js +2 -0
  122. package/dist/modules/customers/api/deals/route.js.map +2 -2
  123. package/dist/modules/customers/api/people/route.js +11 -2
  124. package/dist/modules/customers/api/people/route.js.map +2 -2
  125. package/dist/modules/customers/api/todos/route.js +1 -0
  126. package/dist/modules/customers/api/todos/route.js.map +2 -2
  127. package/dist/modules/customers/backend/config/customers/deals/page.js.map +2 -2
  128. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js +34 -21
  129. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js.map +2 -2
  130. package/dist/modules/customers/backend/customers/companies/[id]/page.js +45 -27
  131. package/dist/modules/customers/backend/customers/companies/[id]/page.js.map +2 -2
  132. package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
  133. package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +22 -5
  134. package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +2 -2
  135. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.js +30 -8
  136. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.js.map +2 -2
  137. package/dist/modules/customers/backend/customers/deals/[id]/page.js +1 -0
  138. package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
  139. package/dist/modules/customers/backend/customers/deals/page.js +16 -6
  140. package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
  141. package/dist/modules/customers/backend/customers/deals/pipeline/page.js +62 -39
  142. package/dist/modules/customers/backend/customers/deals/pipeline/page.js.map +2 -2
  143. package/dist/modules/customers/backend/customers/people/[id]/page.js +41 -26
  144. package/dist/modules/customers/backend/customers/people/[id]/page.js.map +2 -2
  145. package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
  146. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +50 -23
  147. package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +2 -2
  148. package/dist/modules/customers/commands/addresses.js +16 -14
  149. package/dist/modules/customers/commands/addresses.js.map +2 -2
  150. package/dist/modules/customers/commands/companies.js +1 -1
  151. package/dist/modules/customers/commands/companies.js.map +2 -2
  152. package/dist/modules/customers/commands/interactions.js +41 -4
  153. package/dist/modules/customers/commands/interactions.js.map +2 -2
  154. package/dist/modules/customers/commands/people.js +1 -1
  155. package/dist/modules/customers/commands/people.js.map +2 -2
  156. package/dist/modules/customers/commands/personCompanyLinks.js +8 -5
  157. package/dist/modules/customers/commands/personCompanyLinks.js.map +2 -2
  158. package/dist/modules/customers/commands/pipeline-stages.js +13 -11
  159. package/dist/modules/customers/commands/pipeline-stages.js.map +3 -3
  160. package/dist/modules/customers/components/AddressFormatSettings.js.map +2 -2
  161. package/dist/modules/customers/components/DictionarySettings.js +20 -13
  162. package/dist/modules/customers/components/DictionarySettings.js.map +2 -2
  163. package/dist/modules/customers/components/DictionarySortSettings.js +4 -0
  164. package/dist/modules/customers/components/DictionarySortSettings.js.map +2 -2
  165. package/dist/modules/customers/components/PipelineSettings.js +38 -23
  166. package/dist/modules/customers/components/PipelineSettings.js.map +2 -2
  167. package/dist/modules/customers/components/detail/ActivityTimeline.js +1 -1
  168. package/dist/modules/customers/components/detail/ActivityTimeline.js.map +2 -2
  169. package/dist/modules/customers/components/detail/AddressesSection.js +4 -0
  170. package/dist/modules/customers/components/detail/AddressesSection.js.map +2 -2
  171. package/dist/modules/customers/components/detail/CompanyPeopleSection.js +28 -22
  172. package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
  173. package/dist/modules/customers/components/detail/DealsSection.js +36 -24
  174. package/dist/modules/customers/components/detail/DealsSection.js.map +2 -2
  175. package/dist/modules/customers/components/detail/EmailCardActions.js +5 -0
  176. package/dist/modules/customers/components/detail/EmailCardActions.js.map +2 -2
  177. package/dist/modules/customers/components/detail/EntityTagsDialog.js +7 -0
  178. package/dist/modules/customers/components/detail/EntityTagsDialog.js.map +2 -2
  179. package/dist/modules/customers/components/detail/ManageTagsDialog.js +34 -22
  180. package/dist/modules/customers/components/detail/ManageTagsDialog.js.map +2 -2
  181. package/dist/modules/customers/components/detail/PersonCompaniesSection.js +41 -29
  182. package/dist/modules/customers/components/detail/PersonCompaniesSection.js.map +2 -2
  183. package/dist/modules/customers/components/detail/RoleAssignmentRow.js +14 -8
  184. package/dist/modules/customers/components/detail/RoleAssignmentRow.js.map +2 -2
  185. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js +14 -6
  186. package/dist/modules/customers/components/detail/ScheduleActivityDialog.js.map +2 -2
  187. package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js +29 -13
  188. package/dist/modules/customers/components/detail/hooks/useInteractionMutations.js.map +2 -2
  189. package/dist/modules/customers/components/detail/hooks/useInteractions.js +77 -35
  190. package/dist/modules/customers/components/detail/hooks/useInteractions.js.map +2 -2
  191. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js +25 -17
  192. package/dist/modules/customers/components/detail/hooks/usePersonTasks.js.map +2 -2
  193. package/dist/modules/customers/components/detail/schedule/useScheduleFormState.js.map +2 -2
  194. package/dist/modules/customers/components/formConfig.js.map +2 -2
  195. package/dist/modules/customers/data/guards.js +66 -0
  196. package/dist/modules/customers/data/guards.js.map +7 -0
  197. package/dist/modules/customers/di.js +37 -0
  198. package/dist/modules/customers/di.js.map +2 -2
  199. package/dist/modules/customers/lib/todoCompatibility.js +11 -0
  200. package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
  201. package/dist/modules/dashboards/components/WidgetVisibilityEditor.js.map +2 -2
  202. package/dist/modules/data_sync/api/options.js +4 -4
  203. package/dist/modules/data_sync/api/options.js.map +2 -2
  204. package/dist/modules/data_sync/api/schedules/route.js +9 -1
  205. package/dist/modules/data_sync/api/schedules/route.js.map +2 -2
  206. package/dist/modules/data_sync/backend/data-sync/page.js +17 -8
  207. package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
  208. package/dist/modules/data_sync/components/IntegrationScheduleTab.js +43 -22
  209. package/dist/modules/data_sync/components/IntegrationScheduleTab.js.map +2 -2
  210. package/dist/modules/data_sync/lib/sync-schedule-service.js +9 -0
  211. package/dist/modules/data_sync/lib/sync-schedule-service.js.map +2 -2
  212. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +8 -1
  213. package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
  214. package/dist/modules/dictionaries/api/[dictionaryId]/route.js +17 -1
  215. package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
  216. package/dist/modules/dictionaries/components/DictionariesManager.js +31 -10
  217. package/dist/modules/dictionaries/components/DictionariesManager.js.map +2 -2
  218. package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js +28 -15
  219. package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js.map +2 -2
  220. package/dist/modules/directory/api/organizations/route.js +3 -0
  221. package/dist/modules/directory/api/organizations/route.js.map +2 -2
  222. package/dist/modules/directory/backend/directory/organizations/[id]/edit/page.js +2 -0
  223. package/dist/modules/directory/backend/directory/organizations/[id]/edit/page.js.map +2 -2
  224. package/dist/modules/directory/backend/directory/organizations/page.js +9 -5
  225. package/dist/modules/directory/backend/directory/organizations/page.js.map +2 -2
  226. package/dist/modules/directory/backend/directory/tenants/[id]/edit/page.js +7 -3
  227. package/dist/modules/directory/backend/directory/tenants/[id]/edit/page.js.map +2 -2
  228. package/dist/modules/directory/backend/directory/tenants/page.js +8 -4
  229. package/dist/modules/directory/backend/directory/tenants/page.js.map +2 -2
  230. package/dist/modules/directory/commands/organizations.js +7 -2
  231. package/dist/modules/directory/commands/organizations.js.map +2 -2
  232. package/dist/modules/entities/api/records.js +66 -0
  233. package/dist/modules/entities/api/records.js.map +2 -2
  234. package/dist/modules/entities/backend/entities/user/[entityId]/records/[recordId]/page.js +1 -0
  235. package/dist/modules/entities/backend/entities/user/[entityId]/records/[recordId]/page.js.map +2 -2
  236. package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js +8 -4
  237. package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js.map +2 -2
  238. package/dist/modules/entities/lib/helpers.js +17 -0
  239. package/dist/modules/entities/lib/helpers.js.map +2 -2
  240. package/dist/modules/feature_toggles/api/global/[id]/override/route.js +2 -1
  241. package/dist/modules/feature_toggles/api/global/[id]/override/route.js.map +2 -2
  242. package/dist/modules/feature_toggles/api/overrides/route.js +15 -0
  243. package/dist/modules/feature_toggles/api/overrides/route.js.map +2 -2
  244. package/dist/modules/feature_toggles/backend/feature-toggles/global/[id]/edit/page.js +15 -14
  245. package/dist/modules/feature_toggles/backend/feature-toggles/global/[id]/edit/page.js.map +2 -2
  246. package/dist/modules/feature_toggles/components/FeatureToggleOverrideCard.js +20 -12
  247. package/dist/modules/feature_toggles/components/FeatureToggleOverrideCard.js.map +2 -2
  248. package/dist/modules/feature_toggles/components/FeatureTogglesTable.js +6 -2
  249. package/dist/modules/feature_toggles/components/FeatureTogglesTable.js.map +2 -2
  250. package/dist/modules/feature_toggles/components/formConfig.js +2 -1
  251. package/dist/modules/feature_toggles/components/formConfig.js.map +2 -2
  252. package/dist/modules/feature_toggles/components/overrideFormConfig.js +5 -1
  253. package/dist/modules/feature_toggles/components/overrideFormConfig.js.map +2 -2
  254. package/dist/modules/feature_toggles/data/validators.js +7 -4
  255. package/dist/modules/feature_toggles/data/validators.js.map +2 -2
  256. package/dist/modules/inbox_ops/api/settings/route.js +17 -2
  257. package/dist/modules/inbox_ops/api/settings/route.js.map +2 -2
  258. package/dist/modules/inbox_ops/backend/inbox-ops/settings/page.js +13 -8
  259. package/dist/modules/inbox_ops/backend/inbox-ops/settings/page.js.map +2 -2
  260. package/dist/modules/inbox_ops/components/proposals/EditActionDialog.js +9 -4
  261. package/dist/modules/inbox_ops/components/proposals/EditActionDialog.js.map +2 -2
  262. package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js +18 -11
  263. package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js.map +2 -2
  264. package/dist/modules/integrations/backend/integrations/page.js +12 -8
  265. package/dist/modules/integrations/backend/integrations/page.js.map +2 -2
  266. package/dist/modules/messages/commands/messages.js +13 -10
  267. package/dist/modules/messages/commands/messages.js.map +2 -2
  268. package/dist/modules/perspectives/api/[tableId]/route.js +39 -30
  269. package/dist/modules/perspectives/api/[tableId]/route.js.map +2 -2
  270. package/dist/modules/perspectives/services/perspectiveService.js +7 -0
  271. package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
  272. package/dist/modules/planner/backend/planner/availability-rulesets/[id]/page.js +6 -14
  273. package/dist/modules/planner/backend/planner/availability-rulesets/[id]/page.js.map +3 -3
  274. package/dist/modules/planner/backend/planner/availability-rulesets/page.js +4 -2
  275. package/dist/modules/planner/backend/planner/availability-rulesets/page.js.map +2 -2
  276. package/dist/modules/planner/components/AvailabilityRuleSetForm.js +2 -0
  277. package/dist/modules/planner/components/AvailabilityRuleSetForm.js.map +2 -2
  278. package/dist/modules/planner/components/AvailabilityRulesEditor.js +36 -11
  279. package/dist/modules/planner/components/AvailabilityRulesEditor.js.map +2 -2
  280. package/dist/modules/planner/components/AvailabilitySchedule.js +9 -5
  281. package/dist/modules/planner/components/AvailabilitySchedule.js.map +2 -2
  282. package/dist/modules/progress/api/jobs/[id]/route.js +7 -1
  283. package/dist/modules/progress/api/jobs/[id]/route.js.map +2 -2
  284. package/dist/modules/query_index/lib/engine.js +19 -0
  285. package/dist/modules/query_index/lib/engine.js.map +2 -2
  286. package/dist/modules/resources/backend/resources/resource-types/[id]/edit/page.js +1 -0
  287. package/dist/modules/resources/backend/resources/resource-types/[id]/edit/page.js.map +2 -2
  288. package/dist/modules/resources/backend/resources/resource-types/page.js +4 -2
  289. package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
  290. package/dist/modules/resources/backend/resources/resources/[id]/page.js +14 -3
  291. package/dist/modules/resources/backend/resources/resources/[id]/page.js.map +2 -2
  292. package/dist/modules/resources/backend/resources/resources/page.js +8 -4
  293. package/dist/modules/resources/backend/resources/resources/page.js.map +2 -2
  294. package/dist/modules/resources/components/ResourceCrudForm.js +2 -0
  295. package/dist/modules/resources/components/ResourceCrudForm.js.map +2 -2
  296. package/dist/modules/resources/components/ResourceTypeCrudForm.js +1 -0
  297. package/dist/modules/resources/components/ResourceTypeCrudForm.js.map +2 -2
  298. package/dist/modules/sales/api/documents/factory.js +7 -2
  299. package/dist/modules/sales/api/documents/factory.js.map +2 -2
  300. package/dist/modules/sales/backend/sales/channels/[channelId]/edit/page.js +3 -1
  301. package/dist/modules/sales/backend/sales/channels/[channelId]/edit/page.js.map +2 -2
  302. package/dist/modules/sales/backend/sales/channels/offers/page.js +13 -4
  303. package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
  304. package/dist/modules/sales/backend/sales/channels/page.js +16 -4
  305. package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
  306. package/dist/modules/sales/backend/sales/documents/[id]/page.js +68 -22
  307. package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
  308. package/dist/modules/sales/backend/sales/documents/create/page.js.map +2 -2
  309. package/dist/modules/sales/commands/documentAddresses.js +181 -2
  310. package/dist/modules/sales/commands/documentAddresses.js.map +2 -2
  311. package/dist/modules/sales/commands/documents.js +29 -1
  312. package/dist/modules/sales/commands/documents.js.map +2 -2
  313. package/dist/modules/sales/commands/returns.js +12 -2
  314. package/dist/modules/sales/commands/returns.js.map +2 -2
  315. package/dist/modules/sales/commands/shared.js +15 -0
  316. package/dist/modules/sales/commands/shared.js.map +2 -2
  317. package/dist/modules/sales/commands/shipments.js +4 -1
  318. package/dist/modules/sales/commands/shipments.js.map +2 -2
  319. package/dist/modules/sales/components/AdjustmentKindSettings.js +19 -11
  320. package/dist/modules/sales/components/AdjustmentKindSettings.js.map +2 -2
  321. package/dist/modules/sales/components/DocumentNumberSettings.js.map +2 -2
  322. package/dist/modules/sales/components/OrderEditingSettings.js.map +2 -2
  323. package/dist/modules/sales/components/PaymentMethodsSettings.js +12 -4
  324. package/dist/modules/sales/components/PaymentMethodsSettings.js.map +2 -2
  325. package/dist/modules/sales/components/ShippingMethodsSettings.js +12 -4
  326. package/dist/modules/sales/components/ShippingMethodsSettings.js.map +2 -2
  327. package/dist/modules/sales/components/StatusSettings.js +18 -11
  328. package/dist/modules/sales/components/StatusSettings.js.map +2 -2
  329. package/dist/modules/sales/components/TaxRatesSettings.js +12 -4
  330. package/dist/modules/sales/components/TaxRatesSettings.js.map +2 -2
  331. package/dist/modules/sales/components/channels/ChannelOfferForm.js +47 -16
  332. package/dist/modules/sales/components/channels/ChannelOfferForm.js.map +2 -2
  333. package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js +8 -4
  334. package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js.map +2 -2
  335. package/dist/modules/sales/components/documents/AddressesSection.js +44 -25
  336. package/dist/modules/sales/components/documents/AddressesSection.js.map +2 -2
  337. package/dist/modules/sales/components/documents/AdjustmentsSection.js +43 -23
  338. package/dist/modules/sales/components/documents/AdjustmentsSection.js.map +2 -2
  339. package/dist/modules/sales/components/documents/ItemsSection.js +22 -13
  340. package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
  341. package/dist/modules/sales/components/documents/LineItemDialog.js +23 -10
  342. package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
  343. package/dist/modules/sales/components/documents/PaymentDialog.js +29 -14
  344. package/dist/modules/sales/components/documents/PaymentDialog.js.map +2 -2
  345. package/dist/modules/sales/components/documents/PaymentsSection.js +20 -10
  346. package/dist/modules/sales/components/documents/PaymentsSection.js.map +2 -2
  347. package/dist/modules/sales/components/documents/ReturnDialog.js +26 -17
  348. package/dist/modules/sales/components/documents/ReturnDialog.js.map +2 -2
  349. package/dist/modules/sales/components/documents/ReturnsSection.js +3 -1
  350. package/dist/modules/sales/components/documents/ReturnsSection.js.map +2 -2
  351. package/dist/modules/sales/components/documents/SalesDocumentsTable.js +10 -5
  352. package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
  353. package/dist/modules/sales/components/documents/ShipmentDialog.js +21 -7
  354. package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
  355. package/dist/modules/sales/components/documents/ShipmentsSection.js +19 -10
  356. package/dist/modules/sales/components/documents/ShipmentsSection.js.map +2 -2
  357. package/dist/modules/sales/components/documents/optimisticLock.js +27 -0
  358. package/dist/modules/sales/components/documents/optimisticLock.js.map +7 -0
  359. package/dist/modules/sales/di.js +18 -0
  360. package/dist/modules/sales/di.js.map +2 -2
  361. package/dist/modules/shipping_carriers/api/cancel/route.js +2 -2
  362. package/dist/modules/shipping_carriers/api/cancel/route.js.map +2 -2
  363. package/dist/modules/shipping_carriers/lib/status-sync.js +8 -1
  364. package/dist/modules/shipping_carriers/lib/status-sync.js.map +2 -2
  365. package/dist/modules/staff/api/job-histories.js +11 -2
  366. package/dist/modules/staff/api/job-histories.js.map +2 -2
  367. package/dist/modules/staff/api/timesheets/time-entries/route.js +11 -4
  368. package/dist/modules/staff/api/timesheets/time-entries/route.js.map +2 -2
  369. package/dist/modules/staff/backend/staff/leave-requests/[id]/page.js +13 -8
  370. package/dist/modules/staff/backend/staff/leave-requests/[id]/page.js.map +2 -2
  371. package/dist/modules/staff/backend/staff/my-leave-requests/[id]/page.js +2 -1
  372. package/dist/modules/staff/backend/staff/my-leave-requests/[id]/page.js.map +2 -2
  373. package/dist/modules/staff/backend/staff/team-members/[id]/page.js +7 -4
  374. package/dist/modules/staff/backend/staff/team-members/[id]/page.js.map +2 -2
  375. package/dist/modules/staff/backend/staff/team-members/page.js +4 -2
  376. package/dist/modules/staff/backend/staff/team-members/page.js.map +2 -2
  377. package/dist/modules/staff/backend/staff/team-roles/[id]/edit/page.js +1 -0
  378. package/dist/modules/staff/backend/staff/team-roles/[id]/edit/page.js.map +2 -2
  379. package/dist/modules/staff/backend/staff/team-roles/page.js +4 -2
  380. package/dist/modules/staff/backend/staff/team-roles/page.js.map +2 -2
  381. package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +5 -2
  382. package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
  383. package/dist/modules/staff/backend/staff/teams/page.js +12 -3
  384. package/dist/modules/staff/backend/staff/teams/page.js.map +2 -2
  385. package/dist/modules/staff/backend/staff/timesheets/page.js +4 -1
  386. package/dist/modules/staff/backend/staff/timesheets/page.js.map +2 -2
  387. package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js.map +2 -2
  388. package/dist/modules/staff/backend/staff/timesheets/projects/page.js +12 -3
  389. package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +2 -2
  390. package/dist/modules/staff/commands/job-histories.js +40 -3
  391. package/dist/modules/staff/commands/job-histories.js.map +2 -2
  392. package/dist/modules/staff/components/LeaveRequestForm.js +1 -0
  393. package/dist/modules/staff/components/LeaveRequestForm.js.map +2 -2
  394. package/dist/modules/staff/components/TeamForm.js +1 -0
  395. package/dist/modules/staff/components/TeamForm.js.map +2 -2
  396. package/dist/modules/staff/components/TeamMemberForm.js +1 -0
  397. package/dist/modules/staff/components/TeamMemberForm.js.map +2 -2
  398. package/dist/modules/staff/components/TeamRoleForm.js +1 -0
  399. package/dist/modules/staff/components/TeamRoleForm.js.map +2 -2
  400. package/dist/modules/staff/components/detail/JobHistorySection.js +20 -7
  401. package/dist/modules/staff/components/detail/JobHistorySection.js.map +2 -2
  402. package/dist/modules/staff/data/validators.js +7 -1
  403. package/dist/modules/staff/data/validators.js.map +2 -2
  404. package/dist/modules/staff/lib/leaveRequestHelpers.js +2 -1
  405. package/dist/modules/staff/lib/leaveRequestHelpers.js.map +2 -2
  406. package/dist/modules/translations/components/TranslationManager.js +12 -8
  407. package/dist/modules/translations/components/TranslationManager.js.map +2 -2
  408. package/dist/modules/workflows/api/definitions/[id]/route.js +106 -0
  409. package/dist/modules/workflows/api/definitions/[id]/route.js.map +2 -2
  410. package/dist/modules/workflows/backend/definitions/[id]/page.js +11 -3
  411. package/dist/modules/workflows/backend/definitions/[id]/page.js.map +2 -2
  412. package/dist/modules/workflows/backend/definitions/page.js +19 -8
  413. package/dist/modules/workflows/backend/definitions/page.js.map +2 -2
  414. package/dist/modules/workflows/backend/definitions/visual-editor/page.js +29 -16
  415. package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
  416. package/dist/modules/workflows/components/NodeEditDialog.js +3 -1
  417. package/dist/modules/workflows/components/NodeEditDialog.js.map +2 -2
  418. package/dist/modules/workflows/components/WorkflowGraphImpl.js +4 -2
  419. package/dist/modules/workflows/components/WorkflowGraphImpl.js.map +2 -2
  420. package/dist/modules/workflows/components/formConfig.js +4 -1
  421. package/dist/modules/workflows/components/formConfig.js.map +2 -2
  422. package/dist/modules/workflows/components/nodes/ParallelForkNode.js +49 -0
  423. package/dist/modules/workflows/components/nodes/ParallelForkNode.js.map +7 -0
  424. package/dist/modules/workflows/components/nodes/ParallelJoinNode.js +49 -0
  425. package/dist/modules/workflows/components/nodes/ParallelJoinNode.js.map +7 -0
  426. package/dist/modules/workflows/components/nodes/index.js +4 -0
  427. package/dist/modules/workflows/components/nodes/index.js.map +2 -2
  428. package/dist/modules/workflows/data/entities.js +81 -0
  429. package/dist/modules/workflows/data/entities.js.map +2 -2
  430. package/dist/modules/workflows/data/validators.js +146 -1
  431. package/dist/modules/workflows/data/validators.js.map +2 -2
  432. package/dist/modules/workflows/di.js +12 -0
  433. package/dist/modules/workflows/di.js.map +2 -2
  434. package/dist/modules/workflows/events.js +7 -1
  435. package/dist/modules/workflows/events.js.map +2 -2
  436. package/dist/modules/workflows/lib/activity-executor.js +4 -2
  437. package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
  438. package/dist/modules/workflows/lib/activity-queue-types.js.map +2 -2
  439. package/dist/modules/workflows/lib/event-logger.js +2 -0
  440. package/dist/modules/workflows/lib/event-logger.js.map +2 -2
  441. package/dist/modules/workflows/lib/execution-token.js +98 -0
  442. package/dist/modules/workflows/lib/execution-token.js.map +7 -0
  443. package/dist/modules/workflows/lib/node-type-icons.js +14 -5
  444. package/dist/modules/workflows/lib/node-type-icons.js.map +2 -2
  445. package/dist/modules/workflows/lib/parallel-handler.js +364 -0
  446. package/dist/modules/workflows/lib/parallel-handler.js.map +7 -0
  447. package/dist/modules/workflows/lib/signal-handler.js +63 -1
  448. package/dist/modules/workflows/lib/signal-handler.js.map +2 -2
  449. package/dist/modules/workflows/lib/step-handler.js +74 -30
  450. package/dist/modules/workflows/lib/step-handler.js.map +2 -2
  451. package/dist/modules/workflows/lib/task-handler.js +26 -0
  452. package/dist/modules/workflows/lib/task-handler.js.map +2 -2
  453. package/dist/modules/workflows/lib/timer-handler.js +26 -1
  454. package/dist/modules/workflows/lib/timer-handler.js.map +2 -2
  455. package/dist/modules/workflows/lib/transition-handler.js +33 -21
  456. package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
  457. package/dist/modules/workflows/lib/workflow-executor.js +39 -1
  458. package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
  459. package/dist/modules/workflows/migrations/Migration20260602120000.js +24 -0
  460. package/dist/modules/workflows/migrations/Migration20260602120000.js.map +7 -0
  461. package/dist/modules/workflows/workers/workflow-activities.worker.js +8 -4
  462. package/dist/modules/workflows/workers/workflow-activities.worker.js.map +2 -2
  463. package/generated/entities/role/index.ts +1 -0
  464. package/generated/entities/step_instance/index.ts +1 -0
  465. package/generated/entities/user/index.ts +1 -0
  466. package/generated/entities/user_task/index.ts +1 -0
  467. package/generated/entities/workflow_branch_instance/index.ts +18 -0
  468. package/generated/entities/workflow_event/index.ts +1 -0
  469. package/generated/entities/workflow_instance/index.ts +1 -0
  470. package/generated/entities.ids.generated.ts +1 -0
  471. package/generated/entity-fields-registry.ts +26 -0
  472. package/jest.setup.ts +17 -0
  473. package/package.json +8 -7
  474. package/src/helpers/integration/optimisticLockUi.ts +172 -0
  475. package/src/helpers/integration/salesFixtures.ts +29 -0
  476. package/src/modules/api_keys/backend/api-keys/page.tsx +10 -5
  477. package/src/modules/attachments/components/AttachmentPartitionSettings.tsx +19 -9
  478. package/src/modules/auth/api/roles/acl/route.ts +37 -11
  479. package/src/modules/auth/api/roles/route.ts +2 -0
  480. package/src/modules/auth/api/sidebar/preferences/route.ts +73 -0
  481. package/src/modules/auth/api/users/acl/route.ts +46 -18
  482. package/src/modules/auth/api/users/route.ts +2 -0
  483. package/src/modules/auth/backend/roles/[id]/edit/page.tsx +29 -4
  484. package/src/modules/auth/backend/roles/page.tsx +9 -4
  485. package/src/modules/auth/backend/users/[id]/edit/page.tsx +37 -4
  486. package/src/modules/auth/backend/users/page.tsx +7 -2
  487. package/src/modules/auth/components/AclEditor.tsx +10 -1
  488. package/src/modules/auth/data/entities.ts +7 -1
  489. package/src/modules/auth/services/sidebarPreferencesService.ts +38 -4
  490. package/src/modules/business_rules/api/rules/route.ts +30 -0
  491. package/src/modules/business_rules/api/sets/route.ts +30 -0
  492. package/src/modules/business_rules/backend/rules/[id]/page.tsx +16 -4
  493. package/src/modules/business_rules/backend/rules/page.tsx +20 -11
  494. package/src/modules/business_rules/backend/sets/[id]/page.tsx +16 -4
  495. package/src/modules/business_rules/backend/sets/page.tsx +20 -11
  496. package/src/modules/catalog/api/categories/route.ts +3 -0
  497. package/src/modules/catalog/api/products/route.ts +4 -0
  498. package/src/modules/catalog/backend/catalog/categories/[id]/edit/page.tsx +5 -0
  499. package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +112 -35
  500. package/src/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.tsx +56 -7
  501. package/src/modules/catalog/backend/catalog/products/optionSchemaClient.ts +2 -0
  502. package/src/modules/catalog/commands/variants.ts +32 -32
  503. package/src/modules/catalog/components/PriceKindSettings.tsx +20 -7
  504. package/src/modules/catalog/components/categories/CategoriesDataTable.tsx +1 -0
  505. package/src/modules/catalog/components/products/ProductMediaManager.tsx +2 -0
  506. package/src/modules/catalog/components/products/ProductsDataTable.tsx +8 -4
  507. package/src/modules/catalog/components/products/productForm.ts +3 -0
  508. package/src/modules/catalog/components/products/variantForm.ts +9 -0
  509. package/src/modules/communication_channels/backend/profile/communication-channels/page.tsx +5 -0
  510. package/src/modules/currencies/backend/currencies/[id]/page.tsx +13 -6
  511. package/src/modules/currencies/backend/currencies/page.tsx +18 -11
  512. package/src/modules/currencies/backend/exchange-rates/[id]/page.tsx +3 -0
  513. package/src/modules/currencies/backend/exchange-rates/page.tsx +10 -6
  514. package/src/modules/currencies/commands/currencies.ts +10 -5
  515. package/src/modules/currencies/components/CurrencyFetchingConfig.tsx +31 -21
  516. package/src/modules/customer_accounts/api/admin/roles/[id].ts +35 -5
  517. package/src/modules/customer_accounts/api/admin/roles.ts +2 -0
  518. package/src/modules/customer_accounts/api/admin/users/[id].ts +38 -5
  519. package/src/modules/customer_accounts/api/admin/users.ts +2 -0
  520. package/src/modules/customer_accounts/backend/customer_accounts/roles/[id]/page.tsx +34 -20
  521. package/src/modules/customer_accounts/backend/customer_accounts/roles/page.tsx +9 -4
  522. package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/page.tsx +11 -4
  523. package/src/modules/customer_accounts/backend/customer_accounts/users/[id]/page.tsx +28 -17
  524. package/src/modules/customer_accounts/backend/customer_accounts/users/page.tsx +19 -11
  525. package/src/modules/customers/AGENTS.md +2 -2
  526. package/src/modules/customers/api/companies/route.ts +14 -1
  527. package/src/modules/customers/api/deals/route.ts +3 -0
  528. package/src/modules/customers/api/people/route.ts +12 -1
  529. package/src/modules/customers/api/todos/route.ts +1 -0
  530. package/src/modules/customers/backend/config/customers/deals/page.tsx +1 -0
  531. package/src/modules/customers/backend/config/customers/pipeline-stages/page.tsx +36 -21
  532. package/src/modules/customers/backend/customers/companies/[id]/page.tsx +52 -27
  533. package/src/modules/customers/backend/customers/companies/page.tsx +2 -0
  534. package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +27 -5
  535. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealFormHandlers.ts +39 -7
  536. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +1 -0
  537. package/src/modules/customers/backend/customers/deals/page.tsx +18 -6
  538. package/src/modules/customers/backend/customers/deals/pipeline/page.tsx +64 -39
  539. package/src/modules/customers/backend/customers/people/[id]/page.tsx +46 -26
  540. package/src/modules/customers/backend/customers/people/page.tsx +2 -0
  541. package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +84 -24
  542. package/src/modules/customers/commands/addresses.ts +16 -14
  543. package/src/modules/customers/commands/companies.ts +3 -1
  544. package/src/modules/customers/commands/interactions.ts +50 -4
  545. package/src/modules/customers/commands/people.ts +2 -1
  546. package/src/modules/customers/commands/personCompanyLinks.ts +8 -5
  547. package/src/modules/customers/commands/pipeline-stages.ts +16 -16
  548. package/src/modules/customers/components/AddressFormatSettings.tsx +1 -0
  549. package/src/modules/customers/components/DictionarySettings.tsx +18 -13
  550. package/src/modules/customers/components/DictionarySortSettings.tsx +4 -0
  551. package/src/modules/customers/components/PipelineSettings.tsx +42 -21
  552. package/src/modules/customers/components/detail/ActivityTimeline.tsx +3 -3
  553. package/src/modules/customers/components/detail/AddressesSection.tsx +4 -0
  554. package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +2 -0
  555. package/src/modules/customers/components/detail/DealsSection.tsx +4 -0
  556. package/src/modules/customers/components/detail/EmailCardActions.tsx +5 -0
  557. package/src/modules/customers/components/detail/EntityTagsDialog.tsx +7 -0
  558. package/src/modules/customers/components/detail/ManageTagsDialog.tsx +4 -0
  559. package/src/modules/customers/components/detail/PersonCompaniesSection.tsx +4 -0
  560. package/src/modules/customers/components/detail/RoleAssignmentRow.tsx +2 -0
  561. package/src/modules/customers/components/detail/ScheduleActivityDialog.tsx +23 -7
  562. package/src/modules/customers/components/detail/hooks/useInteractionMutations.ts +25 -15
  563. package/src/modules/customers/components/detail/hooks/useInteractions.ts +76 -35
  564. package/src/modules/customers/components/detail/hooks/usePersonTasks.ts +30 -17
  565. package/src/modules/customers/components/detail/schedule/useScheduleFormState.ts +2 -0
  566. package/src/modules/customers/components/detail/types.ts +1 -0
  567. package/src/modules/customers/components/formConfig.tsx +2 -0
  568. package/src/modules/customers/data/guards.ts +67 -0
  569. package/src/modules/customers/di.ts +66 -0
  570. package/src/modules/customers/i18n/de.json +2 -0
  571. package/src/modules/customers/i18n/en.json +2 -0
  572. package/src/modules/customers/i18n/es.json +2 -0
  573. package/src/modules/customers/i18n/pl.json +2 -0
  574. package/src/modules/customers/lib/todoCompatibility.ts +14 -0
  575. package/src/modules/dashboards/components/WidgetVisibilityEditor.tsx +2 -0
  576. package/src/modules/data_sync/api/options.ts +7 -4
  577. package/src/modules/data_sync/api/schedules/route.ts +9 -1
  578. package/src/modules/data_sync/backend/data-sync/page.tsx +18 -5
  579. package/src/modules/data_sync/components/IntegrationScheduleTab.tsx +46 -19
  580. package/src/modules/data_sync/lib/sync-schedule-service.ts +11 -0
  581. package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +8 -1
  582. package/src/modules/dictionaries/api/[dictionaryId]/route.ts +23 -0
  583. package/src/modules/dictionaries/components/DictionariesManager.tsx +32 -9
  584. package/src/modules/dictionaries/components/DictionaryEntriesEditor.tsx +30 -14
  585. package/src/modules/dictionaries/i18n/de.json +1 -0
  586. package/src/modules/dictionaries/i18n/en.json +1 -0
  587. package/src/modules/dictionaries/i18n/es.json +1 -0
  588. package/src/modules/dictionaries/i18n/pl.json +1 -0
  589. package/src/modules/directory/api/organizations/route.ts +3 -0
  590. package/src/modules/directory/backend/directory/organizations/[id]/edit/page.tsx +8 -0
  591. package/src/modules/directory/backend/directory/organizations/page.tsx +10 -5
  592. package/src/modules/directory/backend/directory/tenants/[id]/edit/page.tsx +16 -5
  593. package/src/modules/directory/backend/directory/tenants/page.tsx +8 -4
  594. package/src/modules/directory/commands/organizations.ts +7 -4
  595. package/src/modules/entities/api/records.ts +99 -0
  596. package/src/modules/entities/backend/entities/user/[entityId]/records/[recordId]/page.tsx +7 -0
  597. package/src/modules/entities/backend/entities/user/[entityId]/records/page.tsx +8 -4
  598. package/src/modules/entities/lib/helpers.ts +17 -0
  599. package/src/modules/feature_toggles/api/global/[id]/override/route.ts +1 -0
  600. package/src/modules/feature_toggles/api/overrides/route.ts +19 -0
  601. package/src/modules/feature_toggles/backend/feature-toggles/global/[id]/edit/page.tsx +19 -13
  602. package/src/modules/feature_toggles/components/FeatureToggleOverrideCard.tsx +22 -12
  603. package/src/modules/feature_toggles/components/FeatureTogglesTable.tsx +7 -2
  604. package/src/modules/feature_toggles/components/formConfig.tsx +2 -1
  605. package/src/modules/feature_toggles/components/overrideFormConfig.tsx +10 -1
  606. package/src/modules/feature_toggles/data/validators.ts +11 -3
  607. package/src/modules/inbox_ops/api/settings/route.ts +18 -0
  608. package/src/modules/inbox_ops/backend/inbox-ops/settings/page.tsx +15 -10
  609. package/src/modules/inbox_ops/components/proposals/EditActionDialog.tsx +9 -4
  610. package/src/modules/integrations/backend/integrations/bundle/[id]/page.tsx +20 -11
  611. package/src/modules/integrations/backend/integrations/page.tsx +13 -8
  612. package/src/modules/messages/commands/messages.ts +27 -15
  613. package/src/modules/perspectives/api/[tableId]/route.ts +11 -2
  614. package/src/modules/perspectives/services/perspectiveService.ts +13 -1
  615. package/src/modules/planner/backend/planner/availability-rulesets/[id]/page.tsx +16 -14
  616. package/src/modules/planner/backend/planner/availability-rulesets/page.tsx +6 -3
  617. package/src/modules/planner/components/AvailabilityRuleSetForm.tsx +3 -0
  618. package/src/modules/planner/components/AvailabilityRulesEditor.tsx +58 -15
  619. package/src/modules/planner/components/AvailabilitySchedule.tsx +22 -7
  620. package/src/modules/progress/api/jobs/[id]/route.ts +7 -0
  621. package/src/modules/query_index/lib/engine.ts +34 -0
  622. package/src/modules/resources/backend/resources/resource-types/[id]/edit/page.tsx +7 -1
  623. package/src/modules/resources/backend/resources/resource-types/page.tsx +6 -3
  624. package/src/modules/resources/backend/resources/resources/[id]/page.tsx +23 -3
  625. package/src/modules/resources/backend/resources/resources/page.tsx +15 -4
  626. package/src/modules/resources/components/ResourceCrudForm.tsx +3 -0
  627. package/src/modules/resources/components/ResourceTypeCrudForm.tsx +2 -0
  628. package/src/modules/sales/api/documents/factory.ts +13 -1
  629. package/src/modules/sales/backend/sales/channels/[channelId]/edit/page.tsx +6 -0
  630. package/src/modules/sales/backend/sales/channels/offers/page.tsx +10 -4
  631. package/src/modules/sales/backend/sales/channels/page.tsx +19 -4
  632. package/src/modules/sales/backend/sales/documents/[id]/page.tsx +73 -20
  633. package/src/modules/sales/backend/sales/documents/create/page.tsx +2 -0
  634. package/src/modules/sales/commands/documentAddresses.ts +226 -4
  635. package/src/modules/sales/commands/documents.ts +28 -0
  636. package/src/modules/sales/commands/returns.ts +12 -3
  637. package/src/modules/sales/commands/shared.ts +36 -0
  638. package/src/modules/sales/commands/shipments.ts +17 -1
  639. package/src/modules/sales/components/AdjustmentKindSettings.tsx +20 -11
  640. package/src/modules/sales/components/DocumentNumberSettings.tsx +1 -0
  641. package/src/modules/sales/components/OrderEditingSettings.tsx +1 -0
  642. package/src/modules/sales/components/PaymentMethodsSettings.tsx +12 -4
  643. package/src/modules/sales/components/ShippingMethodsSettings.tsx +12 -4
  644. package/src/modules/sales/components/StatusSettings.tsx +20 -11
  645. package/src/modules/sales/components/TaxRatesSettings.tsx +12 -5
  646. package/src/modules/sales/components/channels/ChannelOfferForm.tsx +67 -14
  647. package/src/modules/sales/components/channels/SalesChannelOffersPanel.tsx +7 -4
  648. package/src/modules/sales/components/documents/AddressesSection.tsx +35 -25
  649. package/src/modules/sales/components/documents/AdjustmentsSection.tsx +50 -25
  650. package/src/modules/sales/components/documents/ItemsSection.tsx +24 -13
  651. package/src/modules/sales/components/documents/LineItemDialog.tsx +26 -9
  652. package/src/modules/sales/components/documents/PaymentDialog.tsx +33 -14
  653. package/src/modules/sales/components/documents/PaymentsSection.tsx +22 -10
  654. package/src/modules/sales/components/documents/ReturnDialog.tsx +28 -17
  655. package/src/modules/sales/components/documents/ReturnsSection.tsx +4 -1
  656. package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +11 -4
  657. package/src/modules/sales/components/documents/ShipmentDialog.tsx +23 -8
  658. package/src/modules/sales/components/documents/ShipmentsSection.tsx +20 -10
  659. package/src/modules/sales/components/documents/optimisticLock.ts +34 -0
  660. package/src/modules/sales/components/documents/shipmentTypes.ts +1 -0
  661. package/src/modules/sales/di.ts +35 -0
  662. package/src/modules/sales/i18n/de.json +3 -0
  663. package/src/modules/sales/i18n/en.json +3 -0
  664. package/src/modules/sales/i18n/es.json +3 -0
  665. package/src/modules/sales/i18n/pl.json +3 -0
  666. package/src/modules/shipping_carriers/api/cancel/route.ts +2 -2
  667. package/src/modules/shipping_carriers/lib/status-sync.ts +19 -0
  668. package/src/modules/staff/api/job-histories.ts +12 -2
  669. package/src/modules/staff/api/timesheets/time-entries/route.ts +16 -4
  670. package/src/modules/staff/backend/staff/leave-requests/[id]/page.tsx +12 -7
  671. package/src/modules/staff/backend/staff/my-leave-requests/[id]/page.tsx +2 -0
  672. package/src/modules/staff/backend/staff/team-members/[id]/page.tsx +16 -5
  673. package/src/modules/staff/backend/staff/team-members/page.tsx +6 -2
  674. package/src/modules/staff/backend/staff/team-roles/[id]/edit/page.tsx +8 -0
  675. package/src/modules/staff/backend/staff/team-roles/page.tsx +6 -2
  676. package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +13 -3
  677. package/src/modules/staff/backend/staff/teams/page.tsx +9 -3
  678. package/src/modules/staff/backend/staff/timesheets/page.tsx +10 -1
  679. package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.tsx +4 -0
  680. package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +9 -3
  681. package/src/modules/staff/commands/job-histories.ts +42 -3
  682. package/src/modules/staff/components/LeaveRequestForm.tsx +2 -0
  683. package/src/modules/staff/components/TeamForm.tsx +2 -0
  684. package/src/modules/staff/components/TeamMemberForm.tsx +2 -0
  685. package/src/modules/staff/components/TeamRoleForm.tsx +2 -0
  686. package/src/modules/staff/components/detail/JobHistorySection.tsx +28 -6
  687. package/src/modules/staff/data/validators.ts +6 -0
  688. package/src/modules/staff/i18n/de.json +1 -0
  689. package/src/modules/staff/i18n/en.json +1 -0
  690. package/src/modules/staff/i18n/es.json +1 -0
  691. package/src/modules/staff/i18n/pl.json +1 -0
  692. package/src/modules/staff/lib/leaveRequestHelpers.ts +4 -0
  693. package/src/modules/translations/components/TranslationManager.tsx +13 -8
  694. package/src/modules/workflows/api/definitions/[id]/route.ts +112 -0
  695. package/src/modules/workflows/backend/definitions/[id]/page.tsx +20 -4
  696. package/src/modules/workflows/backend/definitions/page.tsx +20 -9
  697. package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +29 -16
  698. package/src/modules/workflows/components/NodeEditDialog.tsx +2 -0
  699. package/src/modules/workflows/components/WorkflowGraphImpl.tsx +3 -1
  700. package/src/modules/workflows/components/formConfig.tsx +5 -0
  701. package/src/modules/workflows/components/nodes/ParallelForkNode.tsx +66 -0
  702. package/src/modules/workflows/components/nodes/ParallelJoinNode.tsx +66 -0
  703. package/src/modules/workflows/components/nodes/index.ts +6 -0
  704. package/src/modules/workflows/data/entities.ts +109 -0
  705. package/src/modules/workflows/data/validators.ts +223 -0
  706. package/src/modules/workflows/di.ts +20 -0
  707. package/src/modules/workflows/events.ts +7 -0
  708. package/src/modules/workflows/i18n/de.json +13 -0
  709. package/src/modules/workflows/i18n/en.json +13 -0
  710. package/src/modules/workflows/i18n/es.json +13 -0
  711. package/src/modules/workflows/i18n/pl.json +13 -0
  712. package/src/modules/workflows/lib/activity-executor.ts +8 -2
  713. package/src/modules/workflows/lib/activity-queue-types.ts +3 -0
  714. package/src/modules/workflows/lib/event-logger.ts +3 -0
  715. package/src/modules/workflows/lib/execution-token.ts +166 -0
  716. package/src/modules/workflows/lib/node-type-icons.ts +11 -2
  717. package/src/modules/workflows/lib/parallel-handler.ts +575 -0
  718. package/src/modules/workflows/lib/signal-handler.ts +72 -1
  719. package/src/modules/workflows/lib/step-handler.ts +94 -34
  720. package/src/modules/workflows/lib/task-handler.ts +32 -0
  721. package/src/modules/workflows/lib/timer-handler.ts +30 -1
  722. package/src/modules/workflows/lib/transition-handler.ts +56 -24
  723. package/src/modules/workflows/lib/workflow-executor.ts +53 -1
  724. package/src/modules/workflows/migrations/.snapshot-open-mercato.json +263 -0
  725. package/src/modules/workflows/migrations/Migration20260602120000.ts +25 -0
  726. package/src/modules/workflows/workers/workflow-activities.worker.ts +9 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/staff/lib/leaveRequestHelpers.ts"],
4
- "sourcesContent": ["export type LeaveRequestRecord = {\n id: string\n member?: { id?: string; displayName?: string }\n memberId?: string | null\n member_id?: string | null\n startDate?: string | null\n start_date?: string | null\n endDate?: string | null\n end_date?: string | null\n timezone?: string | null\n status?: 'pending' | 'approved' | 'rejected'\n unavailabilityReasonEntryId?: string | null\n unavailability_reason_entry_id?: string | null\n unavailabilityReasonValue?: string | null\n unavailability_reason_value?: string | null\n note?: string | null\n decisionComment?: string | null\n decision_comment?: string | null\n decidedAt?: string | null\n decided_at?: string | null\n} & Record<string, unknown>\n\nexport type NormalizedLeaveRequest = {\n id: string\n member?: { id?: string; displayName?: string }\n memberId: string | null\n startDate: string | null\n endDate: string | null\n timezone: string | null\n status: 'pending' | 'approved' | 'rejected'\n unavailabilityReasonEntryId: string | null\n unavailabilityReasonValue: string | null\n note: string | null\n decisionComment: string | null\n decidedAt: string | null\n} & Record<string, unknown>\n\nexport function normalizeLeaveRequest(record: LeaveRequestRecord): NormalizedLeaveRequest {\n return {\n ...record,\n id: record.id,\n member: record.member,\n memberId: record.memberId ?? record.member_id ?? null,\n startDate: record.startDate ?? record.start_date ?? null,\n endDate: record.endDate ?? record.end_date ?? null,\n timezone: record.timezone ?? null,\n status: record.status ?? 'pending',\n unavailabilityReasonEntryId: record.unavailabilityReasonEntryId ?? record.unavailability_reason_entry_id ?? null,\n unavailabilityReasonValue: record.unavailabilityReasonValue ?? record.unavailability_reason_value ?? null,\n note: record.note ?? null,\n decisionComment: record.decisionComment ?? record.decision_comment ?? null,\n decidedAt: record.decidedAt ?? record.decided_at ?? null,\n }\n}\n\nexport type LeaveRequestsResponse = {\n items?: LeaveRequestRecord[]\n}\n\nexport function resolveStatusVariant(status: 'pending' | 'approved' | 'rejected') {\n if (status === 'approved') return 'default'\n if (status === 'rejected') return 'destructive'\n return 'secondary'\n}\n\nexport function formatDateLabel(value?: string | null): string {\n if (!value) return ''\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return value\n return date.toLocaleDateString()\n}\n\nexport function formatDateRange(start?: string | null, end?: string | null): string {\n const startLabel = formatDateLabel(start)\n const endLabel = formatDateLabel(end)\n if (startLabel && endLabel) return `${startLabel} -> ${endLabel}`\n return startLabel || endLabel || '-'\n}\n"],
5
- "mappings": "AAqCO,SAAS,sBAAsB,QAAoD;AACxF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,IAAI,OAAO;AAAA,IACX,QAAQ,OAAO;AAAA,IACf,UAAU,OAAO,YAAY,OAAO,aAAa;AAAA,IACjD,WAAW,OAAO,aAAa,OAAO,cAAc;AAAA,IACpD,SAAS,OAAO,WAAW,OAAO,YAAY;AAAA,IAC9C,UAAU,OAAO,YAAY;AAAA,IAC7B,QAAQ,OAAO,UAAU;AAAA,IACzB,6BAA6B,OAAO,+BAA+B,OAAO,kCAAkC;AAAA,IAC5G,2BAA2B,OAAO,6BAA6B,OAAO,+BAA+B;AAAA,IACrG,MAAM,OAAO,QAAQ;AAAA,IACrB,iBAAiB,OAAO,mBAAmB,OAAO,oBAAoB;AAAA,IACtE,WAAW,OAAO,aAAa,OAAO,cAAc;AAAA,EACtD;AACF;AAMO,SAAS,qBAAqB,QAA6C;AAChF,MAAI,WAAW,WAAY,QAAO;AAClC,MAAI,WAAW,WAAY,QAAO;AAClC,SAAO;AACT;AAEO,SAAS,gBAAgB,OAA+B;AAC7D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,SAAO,KAAK,mBAAmB;AACjC;AAEO,SAAS,gBAAgB,OAAuB,KAA6B;AAClF,QAAM,aAAa,gBAAgB,KAAK;AACxC,QAAM,WAAW,gBAAgB,GAAG;AACpC,MAAI,cAAc,SAAU,QAAO,GAAG,UAAU,OAAO,QAAQ;AAC/D,SAAO,cAAc,YAAY;AACnC;",
4
+ "sourcesContent": ["export type LeaveRequestRecord = {\n id: string\n member?: { id?: string; displayName?: string }\n memberId?: string | null\n member_id?: string | null\n startDate?: string | null\n start_date?: string | null\n endDate?: string | null\n end_date?: string | null\n timezone?: string | null\n status?: 'pending' | 'approved' | 'rejected'\n unavailabilityReasonEntryId?: string | null\n unavailability_reason_entry_id?: string | null\n unavailabilityReasonValue?: string | null\n unavailability_reason_value?: string | null\n note?: string | null\n decisionComment?: string | null\n decision_comment?: string | null\n decidedAt?: string | null\n decided_at?: string | null\n updatedAt?: string | null\n updated_at?: string | null\n} & Record<string, unknown>\n\nexport type NormalizedLeaveRequest = {\n id: string\n member?: { id?: string; displayName?: string }\n memberId: string | null\n startDate: string | null\n endDate: string | null\n timezone: string | null\n status: 'pending' | 'approved' | 'rejected'\n unavailabilityReasonEntryId: string | null\n unavailabilityReasonValue: string | null\n note: string | null\n decisionComment: string | null\n decidedAt: string | null\n updatedAt: string | null\n} & Record<string, unknown>\n\nexport function normalizeLeaveRequest(record: LeaveRequestRecord): NormalizedLeaveRequest {\n return {\n ...record,\n id: record.id,\n member: record.member,\n memberId: record.memberId ?? record.member_id ?? null,\n startDate: record.startDate ?? record.start_date ?? null,\n endDate: record.endDate ?? record.end_date ?? null,\n timezone: record.timezone ?? null,\n status: record.status ?? 'pending',\n unavailabilityReasonEntryId: record.unavailabilityReasonEntryId ?? record.unavailability_reason_entry_id ?? null,\n unavailabilityReasonValue: record.unavailabilityReasonValue ?? record.unavailability_reason_value ?? null,\n note: record.note ?? null,\n decisionComment: record.decisionComment ?? record.decision_comment ?? null,\n decidedAt: record.decidedAt ?? record.decided_at ?? null,\n updatedAt: record.updatedAt ?? record.updated_at ?? null,\n }\n}\n\nexport type LeaveRequestsResponse = {\n items?: LeaveRequestRecord[]\n}\n\nexport function resolveStatusVariant(status: 'pending' | 'approved' | 'rejected') {\n if (status === 'approved') return 'default'\n if (status === 'rejected') return 'destructive'\n return 'secondary'\n}\n\nexport function formatDateLabel(value?: string | null): string {\n if (!value) return ''\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return value\n return date.toLocaleDateString()\n}\n\nexport function formatDateRange(start?: string | null, end?: string | null): string {\n const startLabel = formatDateLabel(start)\n const endLabel = formatDateLabel(end)\n if (startLabel && endLabel) return `${startLabel} -> ${endLabel}`\n return startLabel || endLabel || '-'\n}\n"],
5
+ "mappings": "AAwCO,SAAS,sBAAsB,QAAoD;AACxF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,IAAI,OAAO;AAAA,IACX,QAAQ,OAAO;AAAA,IACf,UAAU,OAAO,YAAY,OAAO,aAAa;AAAA,IACjD,WAAW,OAAO,aAAa,OAAO,cAAc;AAAA,IACpD,SAAS,OAAO,WAAW,OAAO,YAAY;AAAA,IAC9C,UAAU,OAAO,YAAY;AAAA,IAC7B,QAAQ,OAAO,UAAU;AAAA,IACzB,6BAA6B,OAAO,+BAA+B,OAAO,kCAAkC;AAAA,IAC5G,2BAA2B,OAAO,6BAA6B,OAAO,+BAA+B;AAAA,IACrG,MAAM,OAAO,QAAQ;AAAA,IACrB,iBAAiB,OAAO,mBAAmB,OAAO,oBAAoB;AAAA,IACtE,WAAW,OAAO,aAAa,OAAO,cAAc;AAAA,IACpD,WAAW,OAAO,aAAa,OAAO,cAAc;AAAA,EACtD;AACF;AAMO,SAAS,qBAAqB,QAA6C;AAChF,MAAI,WAAW,WAAY,QAAO;AAClC,MAAI,WAAW,WAAY,QAAO;AAClC,SAAO;AACT;AAEO,SAAS,gBAAgB,OAA+B;AAC7D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,SAAO,KAAK,mBAAmB;AACjC;AAEO,SAAS,gBAAgB,OAAuB,KAA6B;AAClF,QAAM,aAAa,gBAAgB,KAAK;AACxC,QAAM,WAAW,gBAAgB,GAAG;AACpC,MAAI,cAAc,SAAU,QAAO,GAAG,UAAU,OAAO,QAAQ;AAC/D,SAAO,cAAc,YAAY;AACnC;",
6
6
  "names": []
7
7
  }
@@ -7,7 +7,8 @@ import { Input } from "@open-mercato/ui/primitives/input";
7
7
  import { ComboboxInput } from "@open-mercato/ui/backend/inputs";
8
8
  import { LoadingMessage, ErrorMessage } from "@open-mercato/ui/backend/detail";
9
9
  import { flash } from "@open-mercato/ui/backend/FlashMessages";
10
- import { apiCall, readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
10
+ import { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
11
+ import { buildOptimisticLockHeader } from "@open-mercato/ui/backend/utils/optimisticLock";
11
12
  import { useCustomFieldDefs } from "@open-mercato/ui/backend/utils/customFieldDefs";
12
13
  import { Save, Plus, X } from "lucide-react";
13
14
  import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
@@ -190,13 +191,16 @@ function TranslationManager({
190
191
  console.warn("[translations] Save skipped: payload is empty \u2014 no locale contains any non-empty field");
191
192
  throw new Error(t("translations.manager.errors.nothingToSave", "Nothing to save \u2014 enter a translation first"));
192
193
  }
193
- const res = await apiCall(
194
- `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,
195
- {
196
- method: "PUT",
197
- headers: { "content-type": "application/json" },
198
- body: JSON.stringify(body)
199
- }
194
+ const res = await withScopedApiRequestHeaders(
195
+ buildOptimisticLockHeader(translationData?.updatedAt),
196
+ () => apiCall(
197
+ `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,
198
+ {
199
+ method: "PUT",
200
+ headers: { "content-type": "application/json" },
201
+ body: JSON.stringify(body)
202
+ }
203
+ )
200
204
  );
201
205
  if (!res.ok) {
202
206
  throw new Error(t("translations.manager.errors.save", "Failed to save translations"));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/translations/components/TranslationManager.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { ComboboxInput } from '@open-mercato/ui/backend/inputs'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useCustomFieldDefs } from '@open-mercato/ui/backend/utils/customFieldDefs'\nimport { Save, Plus, X } from 'lucide-react'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { locales as defaultLocales } from '@open-mercato/shared/lib/i18n/config'\nimport { ISO_639_1, isValidIso639, getIso639Label } from '@open-mercato/shared/lib/i18n/iso639'\nimport { formatEntityLabel, buildEntityListUrl, getRecordLabel, resolveBaseValue } from '../lib/helpers'\nimport { resolveFieldList } from '../lib/resolve-field-list'\nimport type { ResolvedField } from '../lib/resolve-field-list'\n\ntype TranslationManagerProps = {\n entityType?: string\n recordId?: string\n baseValues?: Record<string, unknown>\n translatableFields?: string[]\n mode?: 'standalone' | 'embedded'\n compact?: boolean\n}\n\ntype EntityOption = { entityId: string; label?: string; source?: string }\n\ntype TranslationsResponse = {\n entityType: string\n entityId: string\n translations: Record<string, Record<string, unknown>>\n createdAt?: string\n updatedAt?: string\n}\n\nfunction useTranslationLocales() {\n return useQuery<string[]>({\n queryKey: ['translation-locales'],\n queryFn: async () => {\n const res = await apiCall<{ locales: string[] }>('/api/translations/locales')\n if (!res.ok) return [...defaultLocales]\n return Array.isArray(res.result?.locales) && res.result.locales.length > 0\n ? res.result.locales\n : [...defaultLocales]\n },\n staleTime: 60_000,\n })\n}\n\nexport function TranslationManager({\n entityType: propEntityType,\n recordId: propRecordId,\n baseValues: propBaseValues,\n translatableFields: propTranslatableFields,\n mode = 'standalone',\n compact = false,\n}: TranslationManagerProps) {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const isEmbedded = mode === 'embedded'\n\n const [selectedEntityType, setSelectedEntityType] = React.useState(propEntityType ?? '')\n const [selectedRecordId, setSelectedRecordId] = React.useState(propRecordId ?? '')\n const [activeLocale, setActiveLocale] = React.useState('')\n const [editedTranslations, setEditedTranslations] = React.useState<Record<string, Record<string, string>>>({})\n const editedTranslationsRef = React.useRef<Record<string, Record<string, string>>>({})\n const [hasUserEdited, setHasUserEdited] = React.useState(false)\n const hasUserEditedRef = React.useRef(false)\n\n const entityType = isEmbedded ? (propEntityType ?? '') : selectedEntityType\n const recordId = isEmbedded ? (propRecordId ?? '') : selectedRecordId\n\n const { data: locales = [...defaultLocales] } = useTranslationLocales()\n\n React.useEffect(() => {\n if (locales.length > 0 && (!activeLocale || !locales.includes(activeLocale))) {\n setActiveLocale(locales[0])\n }\n }, [locales, activeLocale])\n\n React.useEffect(() => {\n if (isEmbedded && propEntityType) setSelectedEntityType(propEntityType)\n }, [isEmbedded, propEntityType])\n\n React.useEffect(() => {\n if (isEmbedded && propRecordId) setSelectedRecordId(propRecordId)\n }, [isEmbedded, propRecordId])\n\n const { data: entities, isLoading: loadingEntities, error: entitiesError } = useQuery<{ items: EntityOption[] }>({\n queryKey: ['entities-list', scopeVersion],\n enabled: !isEmbedded,\n queryFn: async () =>\n readApiResultOrThrow('/api/entities/entities', undefined, {\n errorMessage: t('translations.manager.errors.loadEntities', 'Failed to load entities'),\n }),\n })\n\n const entitySuggestions = React.useMemo(\n () =>\n (entities?.items || []).map((item) => ({\n value: item.entityId,\n label: formatEntityLabel(item.entityId, item.label),\n description: item.entityId,\n })),\n [entities],\n )\n\n const resolveEntityLabel = React.useCallback(\n (value: string) => {\n const match = entities?.items?.find((e) => e.entityId === value)\n return match ? formatEntityLabel(match.entityId, match.label) : formatEntityLabel(value)\n },\n [entities],\n )\n\n const listUrl = React.useMemo(() => entityType ? buildEntityListUrl(entityType) : null, [entityType])\n\n const loadRecordSuggestions = React.useCallback(\n async (query?: string) => {\n if (!entityType || !listUrl) return []\n const url = `${listUrl}?pageSize=20${query ? `&search=${encodeURIComponent(query)}` : ''}`\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(url)\n if (!res.ok) return []\n const items = res.result?.items ?? []\n return items.map((item) => ({\n value: String(item.id ?? ''),\n label: getRecordLabel(item),\n }))\n },\n [entityType, listUrl],\n )\n\n const { data: recordData } = useQuery<Record<string, unknown> | null>({\n queryKey: ['translation-record-data', entityType, recordId, listUrl, scopeVersion],\n enabled: !isEmbedded && !!entityType && !!recordId && !!listUrl,\n queryFn: async () => {\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(\n // Some APIs filter by `id` (catalog), others by `ids` (resources) \u2014 send both so the one recognized by the target route's buildFilters is applied\n `${listUrl}?id=${encodeURIComponent(recordId)}&ids=${encodeURIComponent(recordId)}&pageSize=1`,\n )\n if (!res.ok) return null\n const items = res.result?.items\n return Array.isArray(items) && items.length > 0 ? items[0] : null\n },\n })\n\n const baseValues = isEmbedded ? (propBaseValues ?? {}) : (recordData ?? {})\n\n const resolveRecordLabel = React.useCallback(\n (value: string) => {\n if (recordData) return getRecordLabel(recordData)\n return value\n },\n [recordData],\n )\n\n const { data: fieldDefs = [], isLoading: loadingFieldDefs } = useCustomFieldDefs(entityType ? [entityType] : [], {\n enabled: !!entityType,\n })\n\n const fieldList = React.useMemo(\n () => resolveFieldList(entityType, propTranslatableFields, fieldDefs as Array<{ key: string; kind: string; label?: string }>),\n [entityType, propTranslatableFields, fieldDefs],\n )\n\n const {\n data: translationData,\n isLoading: loadingTranslation,\n isError: translationError,\n refetch: refetchTranslation,\n } = useQuery<TranslationsResponse | null>({\n queryKey: ['entity-translation', entityType, recordId, scopeVersion],\n enabled: !!entityType && !!recordId,\n queryFn: async () => {\n const res = await apiCall<TranslationsResponse>(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n )\n if (!res.ok) {\n if (res.response?.status === 404) return null\n return null\n }\n return res.result ?? null\n },\n })\n\n const translationSignature = React.useMemo(() => JSON.stringify(translationData ?? null), [translationData])\n const lastTranslationSignatureRef = React.useRef<string | null>(null)\n\n React.useEffect(() => {\n const sig = translationSignature\n if (sig === lastTranslationSignatureRef.current && hasUserEditedRef.current) return\n lastTranslationSignatureRef.current = sig\n\n if (!translationData?.translations) {\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = {}\n setEditedTranslations({})\n }\n return\n }\n\n const parsed: Record<string, Record<string, string>> = {}\n for (const [locale, fields] of Object.entries(translationData.translations)) {\n if (!fields || typeof fields !== 'object') continue\n parsed[locale] = {}\n for (const [key, val] of Object.entries(fields)) {\n parsed[locale][key] = typeof val === 'string' ? val : ''\n }\n }\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = parsed\n setEditedTranslations(parsed)\n }\n }, [translationSignature, translationData])\n\n const mutation = useMutation({\n mutationFn: async () => {\n if (!entityType || !recordId) {\n throw new Error(t('translations.manager.errors.selectRecord', 'Select an entity and record before saving'))\n }\n const body: Record<string, Record<string, string | null>> = {}\n for (const [locale, fields] of Object.entries(editedTranslationsRef.current)) {\n const localeFields: Record<string, string | null> = {}\n let hasValues = false\n for (const [key, val] of Object.entries(fields)) {\n if (val && val.trim().length > 0) {\n localeFields[key] = val.trim()\n hasValues = true\n }\n }\n if (hasValues) body[locale] = localeFields\n }\n if (Object.keys(body).length === 0) {\n console.warn('[translations] Save skipped: payload is empty \u2014 no locale contains any non-empty field')\n throw new Error(t('translations.manager.errors.nothingToSave', 'Nothing to save \u2014 enter a translation first'))\n }\n const res = await apiCall(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n },\n )\n if (!res.ok) {\n throw new Error(t('translations.manager.errors.save', 'Failed to save translations'))\n }\n return true\n },\n onSuccess: () => {\n flash(t('translations.manager.flash.saved', 'Translations saved'), 'success')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n void refetchTranslation()\n },\n onError: (err: unknown) => {\n const message = err instanceof Error ? err.message : t('translations.manager.errors.save', 'Failed to save translations')\n flash(message, 'error')\n },\n })\n\n const updateFieldValue = (locale: string, fieldKey: string, value: string) => {\n hasUserEditedRef.current = true\n setHasUserEdited(true)\n const next = {\n ...editedTranslationsRef.current,\n [locale]: {\n ...editedTranslationsRef.current[locale],\n [fieldKey]: value,\n },\n }\n editedTranslationsRef.current = next\n setEditedTranslations(next)\n }\n\n const getBaseValue = (fieldKey: string): string => resolveBaseValue(baseValues, fieldKey)\n\n const renderRecordPicker = () => {\n if (isEmbedded) return null\n\n return (\n <div className=\"space-y-2\">\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectRecord', 'Select record')}\n </label>\n <ComboboxInput\n value={selectedRecordId}\n onChange={(next) => {\n setSelectedRecordId(next)\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.searchRecords', 'Search records...')}\n loadSuggestions={loadRecordSuggestions}\n resolveLabel={resolveRecordLabel}\n allowCustomValues\n disabled={!entityType}\n />\n </div>\n )\n }\n\n const renderLocaleTabs = () => (\n <div className=\"flex gap-1 border-b\">\n {locales.map((locale) => {\n const isActive = activeLocale === locale\n return (\n <button\n key={locale}\n type=\"button\"\n data-state={isActive ? 'active' : 'inactive'}\n data-locale={locale}\n className={`px-3 py-1.5 text-sm font-medium transition-colors ${\n isActive\n ? 'border-b-2 border-accent-indigo text-foreground'\n : 'text-muted-foreground hover:text-foreground'\n }`}\n onClick={() => setActiveLocale(locale)}\n >\n {locale.toUpperCase()}\n </button>\n )\n })}\n </div>\n )\n\n const renderFieldTable = () => {\n if (!entityType || !recordId) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.selectFirst', 'Select an entity and record to manage translations.')}\n </div>\n )\n }\n if (loadingTranslation || loadingFieldDefs) {\n return (\n <LoadingMessage\n label={t('translations.manager.loadingTranslations', 'Loading translations...')}\n className=\"border-0 bg-transparent p-4\"\n />\n )\n }\n if (translationError) {\n return (\n <ErrorMessage\n label={t('translations.manager.errors.loadTranslation', 'Failed to load translations')}\n action={(\n <Button variant=\"outline\" size=\"sm\" onClick={() => void refetchTranslation()}>\n {t('translations.manager.actions.retry', 'Retry')}\n </Button>\n )}\n />\n )\n }\n if (!fieldList.length) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.noFields', 'No translatable fields found for this entity type.')}\n </div>\n )\n }\n\n const localeTranslations = editedTranslations[activeLocale] ?? {}\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[480px] text-sm\">\n <thead>\n <tr className=\"text-xs uppercase tracking-wide text-muted-foreground\">\n <th className=\"px-3 py-2 text-left w-[140px]\">\n {t('translations.manager.fields.field', 'Field')}\n </th>\n {!compact && (\n <th className=\"px-3 py-2 text-left\">\n {t('translations.manager.fields.baseValue', 'Base value')}\n </th>\n )}\n <th className=\"px-3 py-2 text-left\">\n {t('translations.manager.fields.translation', 'Translation')} ({activeLocale.toUpperCase()})\n </th>\n </tr>\n </thead>\n <tbody>\n {fieldList.map((field) => {\n const baseVal = getBaseValue(field.key)\n const translatedVal = localeTranslations[field.key] ?? ''\n\n return (\n <tr key={field.key} className=\"border-t\">\n <td className=\"px-3 py-2 align-top text-xs font-medium text-muted-foreground\">\n {field.label}\n </td>\n {!compact && (\n <td className=\"px-3 py-2 align-top text-xs text-muted-foreground max-w-[200px]\">\n {baseVal ? (\n <span className=\"line-clamp-3\">{baseVal}</span>\n ) : (\n <span className=\"text-muted-foreground/50\">-</span>\n )}\n </td>\n )}\n <td className=\"px-3 py-2 align-top\">\n {field.multiline ? (\n <textarea\n className=\"flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50\"\n rows={3}\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n ) : (\n <Input\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n )}\n </td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </div>\n )\n }\n\n React.useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {\n e.preventDefault()\n if (entityType && recordId && !mutation.isPending) mutation.mutate()\n }\n }\n document.addEventListener('keydown', handler)\n return () => document.removeEventListener('keydown', handler)\n }, [entityType, recordId, mutation])\n\n if (compact) {\n return (\n <div className=\"space-y-3\">\n {renderLocaleTabs()}\n {renderFieldTable()}\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => mutation.mutate()}\n disabled={mutation.isPending || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-3 w-3\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"space-y-6\">\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-2\">\n <h2 className=\"text-xl font-semibold\">{t('translations.manager.title', 'Translations')}</h2>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.manager.description', 'Manage translations for entity records across supported locales.')}\n </p>\n </div>\n\n {!isEmbedded && (\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-start\">\n <div className=\"flex-1 space-y-3\">\n <div>\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectEntity', 'Choose entity')}\n </label>\n <div className=\"mt-1\">\n <ComboboxInput\n value={selectedEntityType}\n onChange={(next) => {\n setSelectedEntityType(next)\n setSelectedRecordId('')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.placeholder', 'Select an entity')}\n suggestions={entitySuggestions}\n resolveLabel={resolveEntityLabel}\n disabled={loadingEntities || !!entitiesError}\n />\n </div>\n {entitiesError && (\n <p className=\"mt-1 text-xs text-destructive\">\n {t('translations.manager.errors.loadEntities', 'Failed to load entities')}\n </p>\n )}\n </div>\n {renderRecordPicker()}\n </div>\n </div>\n )}\n\n <div className=\"rounded-lg border bg-background/80 p-4\">\n {renderLocaleTabs()}\n <div className=\"mt-3\">\n {renderFieldTable()}\n </div>\n </div>\n\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n onClick={() => mutation.mutate()}\n disabled={mutation.isPending || loadingEntities || !!entitiesError || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-4 w-4\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n\nexport function LocaleManager() {\n const t = useT()\n const queryClient = useQueryClient()\n const { data: locales = [], isLoading } = useTranslationLocales()\n const [newLocale, setNewLocale] = React.useState('')\n\n const mutation = useMutation({\n mutationFn: async (updatedLocales: string[]) => {\n const res = await apiCall<{ locales: string[] }>('/api/translations/locales', {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ locales: updatedLocales }),\n })\n if (!res.ok) throw new Error('Failed to save locales')\n return res.result?.locales ?? updatedLocales\n },\n onSuccess: (result) => {\n queryClient.setQueryData(['translation-locales'], result)\n flash(t('translations.locales.flash.saved', 'Locales updated'), 'success')\n },\n onError: () => {\n flash(t('translations.locales.flash.error', 'Failed to update locales'), 'error')\n },\n })\n\n const availableLocales = React.useMemo(\n () => ISO_639_1.filter((entry) => !locales.includes(entry.code)).map((entry) => ({\n value: entry.code,\n label: `${entry.code.toUpperCase()} \u2014 ${entry.label}`,\n })),\n [locales],\n )\n\n const addLocale = () => {\n const code = newLocale.toLowerCase().trim()\n if (!code || !isValidIso639(code) || locales.includes(code)) return\n mutation.mutate([...locales, code])\n setNewLocale('')\n }\n\n const removeLocale = (locale: string) => {\n if (locales.length <= 1) return\n mutation.mutate(locales.filter((l) => l !== locale))\n }\n\n if (isLoading) {\n return <LoadingMessage label={t('translations.locales.loading', 'Loading locales...')} className=\"border-0 bg-transparent p-4\" />\n }\n\n return (\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-1\">\n <h3 className=\"text-lg font-semibold\">{t('translations.locales.title', 'Supported locales')}</h3>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.locales.description', 'Configure which locales are available for translations. Add ISO language codes (e.g. fr, it, ja, zh).')}\n </p>\n </div>\n\n <div className=\"flex flex-wrap gap-2\">\n {locales.map((locale) => (\n <span\n key={locale}\n className=\"inline-flex items-center gap-1.5 rounded-full border bg-muted/50 px-3 py-1 text-sm font-medium\"\n title={getIso639Label(locale) ?? locale}\n >\n {locale.toUpperCase()}{getIso639Label(locale) ? ` \u2014 ${getIso639Label(locale)}` : ''}\n {locales.length > 1 && (\n <button\n type=\"button\"\n className=\"rounded-full p-0.5 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={() => removeLocale(locale)}\n disabled={mutation.isPending}\n >\n <X className=\"h-3 w-3\" />\n </button>\n )}\n </span>\n ))}\n </div>\n\n <div className=\"flex gap-2 items-center\">\n <div className=\"max-w-[240px] flex-1\">\n <ComboboxInput\n value={newLocale}\n onChange={setNewLocale}\n placeholder={t('translations.locales.addPlaceholder', 'Search language...')}\n suggestions={availableLocales}\n resolveLabel={(value) => {\n const label = getIso639Label(value)\n return label ? `${value.toUpperCase()} \u2014 ${label}` : value.toUpperCase()\n }}\n />\n </div>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={addLocale}\n disabled={mutation.isPending || !newLocale.trim() || !isValidIso639(newLocale) || locales.includes(newLocale.toLowerCase().trim())}\n >\n <Plus className=\"mr-1 h-3 w-3\" />\n {t('translations.locales.add', 'Add')}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
- "mappings": ";AA6RM,SACE,KADF;AA3RN,YAAY,WAAW;AACvB,SAAS,UAAU,aAAa,sBAAsB;AACtD,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,aAAa;AACtB,SAAS,SAAS,4BAA4B;AAC9C,SAAS,0BAA0B;AACnC,SAAS,MAAM,MAAM,SAAS;AAC9B,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,WAAW,sBAAsB;AAC1C,SAAS,WAAW,eAAe,sBAAsB;AACzD,SAAS,mBAAmB,oBAAoB,gBAAgB,wBAAwB;AACxF,SAAS,wBAAwB;AAsBjC,SAAS,wBAAwB;AAC/B,SAAO,SAAmB;AAAA,IACxB,UAAU,CAAC,qBAAqB;AAAA,IAChC,SAAS,YAAY;AACnB,YAAM,MAAM,MAAM,QAA+B,2BAA2B;AAC5E,UAAI,CAAC,IAAI,GAAI,QAAO,CAAC,GAAG,cAAc;AACtC,aAAO,MAAM,QAAQ,IAAI,QAAQ,OAAO,KAAK,IAAI,OAAO,QAAQ,SAAS,IACrE,IAAI,OAAO,UACX,CAAC,GAAG,cAAc;AAAA,IACxB;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AACH;AAEO,SAAS,mBAAmB;AAAA,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,oBAAoB;AAAA,UAC1E,aAAa;AAAA,UACb,cAAc,CAAC,UAAU;AACvB,kBAAM,QAAQ,eAAe,KAAK;AAClC,mBAAO,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAM,KAAK,KAAK,MAAM,YAAY;AAAA,UACzE;AAAA;AAAA,MACF,GACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,SAAS;AAAA,UACT,UAAU,SAAS,aAAa,CAAC,UAAU,KAAK,KAAK,CAAC,cAAc,SAAS,KAAK,QAAQ,SAAS,UAAU,YAAY,EAAE,KAAK,CAAC;AAAA,UAEjI;AAAA,gCAAC,QAAK,WAAU,gBAAe;AAAA,YAC9B,EAAE,4BAA4B,KAAK;AAAA;AAAA;AAAA,MACtC;AAAA,OACF;AAAA,KACF;AAEJ;",
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { ComboboxInput } from '@open-mercato/ui/backend/inputs'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { useCustomFieldDefs } from '@open-mercato/ui/backend/utils/customFieldDefs'\nimport { Save, Plus, X } from 'lucide-react'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { locales as defaultLocales } from '@open-mercato/shared/lib/i18n/config'\nimport { ISO_639_1, isValidIso639, getIso639Label } from '@open-mercato/shared/lib/i18n/iso639'\nimport { formatEntityLabel, buildEntityListUrl, getRecordLabel, resolveBaseValue } from '../lib/helpers'\nimport { resolveFieldList } from '../lib/resolve-field-list'\nimport type { ResolvedField } from '../lib/resolve-field-list'\n\ntype TranslationManagerProps = {\n entityType?: string\n recordId?: string\n baseValues?: Record<string, unknown>\n translatableFields?: string[]\n mode?: 'standalone' | 'embedded'\n compact?: boolean\n}\n\ntype EntityOption = { entityId: string; label?: string; source?: string }\n\ntype TranslationsResponse = {\n entityType: string\n entityId: string\n translations: Record<string, Record<string, unknown>>\n createdAt?: string\n updatedAt?: string\n}\n\nfunction useTranslationLocales() {\n return useQuery<string[]>({\n queryKey: ['translation-locales'],\n queryFn: async () => {\n const res = await apiCall<{ locales: string[] }>('/api/translations/locales')\n if (!res.ok) return [...defaultLocales]\n return Array.isArray(res.result?.locales) && res.result.locales.length > 0\n ? res.result.locales\n : [...defaultLocales]\n },\n staleTime: 60_000,\n })\n}\n\nexport function TranslationManager({\n entityType: propEntityType,\n recordId: propRecordId,\n baseValues: propBaseValues,\n translatableFields: propTranslatableFields,\n mode = 'standalone',\n compact = false,\n}: TranslationManagerProps) {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const isEmbedded = mode === 'embedded'\n\n const [selectedEntityType, setSelectedEntityType] = React.useState(propEntityType ?? '')\n const [selectedRecordId, setSelectedRecordId] = React.useState(propRecordId ?? '')\n const [activeLocale, setActiveLocale] = React.useState('')\n const [editedTranslations, setEditedTranslations] = React.useState<Record<string, Record<string, string>>>({})\n const editedTranslationsRef = React.useRef<Record<string, Record<string, string>>>({})\n const [hasUserEdited, setHasUserEdited] = React.useState(false)\n const hasUserEditedRef = React.useRef(false)\n\n const entityType = isEmbedded ? (propEntityType ?? '') : selectedEntityType\n const recordId = isEmbedded ? (propRecordId ?? '') : selectedRecordId\n\n const { data: locales = [...defaultLocales] } = useTranslationLocales()\n\n React.useEffect(() => {\n if (locales.length > 0 && (!activeLocale || !locales.includes(activeLocale))) {\n setActiveLocale(locales[0])\n }\n }, [locales, activeLocale])\n\n React.useEffect(() => {\n if (isEmbedded && propEntityType) setSelectedEntityType(propEntityType)\n }, [isEmbedded, propEntityType])\n\n React.useEffect(() => {\n if (isEmbedded && propRecordId) setSelectedRecordId(propRecordId)\n }, [isEmbedded, propRecordId])\n\n const { data: entities, isLoading: loadingEntities, error: entitiesError } = useQuery<{ items: EntityOption[] }>({\n queryKey: ['entities-list', scopeVersion],\n enabled: !isEmbedded,\n queryFn: async () =>\n readApiResultOrThrow('/api/entities/entities', undefined, {\n errorMessage: t('translations.manager.errors.loadEntities', 'Failed to load entities'),\n }),\n })\n\n const entitySuggestions = React.useMemo(\n () =>\n (entities?.items || []).map((item) => ({\n value: item.entityId,\n label: formatEntityLabel(item.entityId, item.label),\n description: item.entityId,\n })),\n [entities],\n )\n\n const resolveEntityLabel = React.useCallback(\n (value: string) => {\n const match = entities?.items?.find((e) => e.entityId === value)\n return match ? formatEntityLabel(match.entityId, match.label) : formatEntityLabel(value)\n },\n [entities],\n )\n\n const listUrl = React.useMemo(() => entityType ? buildEntityListUrl(entityType) : null, [entityType])\n\n const loadRecordSuggestions = React.useCallback(\n async (query?: string) => {\n if (!entityType || !listUrl) return []\n const url = `${listUrl}?pageSize=20${query ? `&search=${encodeURIComponent(query)}` : ''}`\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(url)\n if (!res.ok) return []\n const items = res.result?.items ?? []\n return items.map((item) => ({\n value: String(item.id ?? ''),\n label: getRecordLabel(item),\n }))\n },\n [entityType, listUrl],\n )\n\n const { data: recordData } = useQuery<Record<string, unknown> | null>({\n queryKey: ['translation-record-data', entityType, recordId, listUrl, scopeVersion],\n enabled: !isEmbedded && !!entityType && !!recordId && !!listUrl,\n queryFn: async () => {\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(\n // Some APIs filter by `id` (catalog), others by `ids` (resources) \u2014 send both so the one recognized by the target route's buildFilters is applied\n `${listUrl}?id=${encodeURIComponent(recordId)}&ids=${encodeURIComponent(recordId)}&pageSize=1`,\n )\n if (!res.ok) return null\n const items = res.result?.items\n return Array.isArray(items) && items.length > 0 ? items[0] : null\n },\n })\n\n const baseValues = isEmbedded ? (propBaseValues ?? {}) : (recordData ?? {})\n\n const resolveRecordLabel = React.useCallback(\n (value: string) => {\n if (recordData) return getRecordLabel(recordData)\n return value\n },\n [recordData],\n )\n\n const { data: fieldDefs = [], isLoading: loadingFieldDefs } = useCustomFieldDefs(entityType ? [entityType] : [], {\n enabled: !!entityType,\n })\n\n const fieldList = React.useMemo(\n () => resolveFieldList(entityType, propTranslatableFields, fieldDefs as Array<{ key: string; kind: string; label?: string }>),\n [entityType, propTranslatableFields, fieldDefs],\n )\n\n const {\n data: translationData,\n isLoading: loadingTranslation,\n isError: translationError,\n refetch: refetchTranslation,\n } = useQuery<TranslationsResponse | null>({\n queryKey: ['entity-translation', entityType, recordId, scopeVersion],\n enabled: !!entityType && !!recordId,\n queryFn: async () => {\n const res = await apiCall<TranslationsResponse>(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n )\n if (!res.ok) {\n if (res.response?.status === 404) return null\n return null\n }\n return res.result ?? null\n },\n })\n\n const translationSignature = React.useMemo(() => JSON.stringify(translationData ?? null), [translationData])\n const lastTranslationSignatureRef = React.useRef<string | null>(null)\n\n React.useEffect(() => {\n const sig = translationSignature\n if (sig === lastTranslationSignatureRef.current && hasUserEditedRef.current) return\n lastTranslationSignatureRef.current = sig\n\n if (!translationData?.translations) {\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = {}\n setEditedTranslations({})\n }\n return\n }\n\n const parsed: Record<string, Record<string, string>> = {}\n for (const [locale, fields] of Object.entries(translationData.translations)) {\n if (!fields || typeof fields !== 'object') continue\n parsed[locale] = {}\n for (const [key, val] of Object.entries(fields)) {\n parsed[locale][key] = typeof val === 'string' ? val : ''\n }\n }\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = parsed\n setEditedTranslations(parsed)\n }\n }, [translationSignature, translationData])\n\n const mutation = useMutation({\n mutationFn: async () => {\n if (!entityType || !recordId) {\n throw new Error(t('translations.manager.errors.selectRecord', 'Select an entity and record before saving'))\n }\n const body: Record<string, Record<string, string | null>> = {}\n for (const [locale, fields] of Object.entries(editedTranslationsRef.current)) {\n const localeFields: Record<string, string | null> = {}\n let hasValues = false\n for (const [key, val] of Object.entries(fields)) {\n if (val && val.trim().length > 0) {\n localeFields[key] = val.trim()\n hasValues = true\n }\n }\n if (hasValues) body[locale] = localeFields\n }\n if (Object.keys(body).length === 0) {\n console.warn('[translations] Save skipped: payload is empty \u2014 no locale contains any non-empty field')\n throw new Error(t('translations.manager.errors.nothingToSave', 'Nothing to save \u2014 enter a translation first'))\n }\n const res = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(translationData?.updatedAt),\n () => apiCall(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n },\n ),\n )\n if (!res.ok) {\n throw new Error(t('translations.manager.errors.save', 'Failed to save translations'))\n }\n return true\n },\n onSuccess: () => {\n flash(t('translations.manager.flash.saved', 'Translations saved'), 'success')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n void refetchTranslation()\n },\n onError: (err: unknown) => {\n const message = err instanceof Error ? err.message : t('translations.manager.errors.save', 'Failed to save translations')\n flash(message, 'error')\n },\n })\n\n const updateFieldValue = (locale: string, fieldKey: string, value: string) => {\n hasUserEditedRef.current = true\n setHasUserEdited(true)\n const next = {\n ...editedTranslationsRef.current,\n [locale]: {\n ...editedTranslationsRef.current[locale],\n [fieldKey]: value,\n },\n }\n editedTranslationsRef.current = next\n setEditedTranslations(next)\n }\n\n const getBaseValue = (fieldKey: string): string => resolveBaseValue(baseValues, fieldKey)\n\n const renderRecordPicker = () => {\n if (isEmbedded) return null\n\n return (\n <div className=\"space-y-2\">\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectRecord', 'Select record')}\n </label>\n <ComboboxInput\n value={selectedRecordId}\n onChange={(next) => {\n setSelectedRecordId(next)\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.searchRecords', 'Search records...')}\n loadSuggestions={loadRecordSuggestions}\n resolveLabel={resolveRecordLabel}\n allowCustomValues\n disabled={!entityType}\n />\n </div>\n )\n }\n\n const renderLocaleTabs = () => (\n <div className=\"flex gap-1 border-b\">\n {locales.map((locale) => {\n const isActive = activeLocale === locale\n return (\n <button\n key={locale}\n type=\"button\"\n data-state={isActive ? 'active' : 'inactive'}\n data-locale={locale}\n className={`px-3 py-1.5 text-sm font-medium transition-colors ${\n isActive\n ? 'border-b-2 border-accent-indigo text-foreground'\n : 'text-muted-foreground hover:text-foreground'\n }`}\n onClick={() => setActiveLocale(locale)}\n >\n {locale.toUpperCase()}\n </button>\n )\n })}\n </div>\n )\n\n const renderFieldTable = () => {\n if (!entityType || !recordId) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.selectFirst', 'Select an entity and record to manage translations.')}\n </div>\n )\n }\n if (loadingTranslation || loadingFieldDefs) {\n return (\n <LoadingMessage\n label={t('translations.manager.loadingTranslations', 'Loading translations...')}\n className=\"border-0 bg-transparent p-4\"\n />\n )\n }\n if (translationError) {\n return (\n <ErrorMessage\n label={t('translations.manager.errors.loadTranslation', 'Failed to load translations')}\n action={(\n <Button variant=\"outline\" size=\"sm\" onClick={() => void refetchTranslation()}>\n {t('translations.manager.actions.retry', 'Retry')}\n </Button>\n )}\n />\n )\n }\n if (!fieldList.length) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.noFields', 'No translatable fields found for this entity type.')}\n </div>\n )\n }\n\n const localeTranslations = editedTranslations[activeLocale] ?? {}\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[480px] text-sm\">\n <thead>\n <tr className=\"text-xs uppercase tracking-wide text-muted-foreground\">\n <th className=\"px-3 py-2 text-left w-[140px]\">\n {t('translations.manager.fields.field', 'Field')}\n </th>\n {!compact && (\n <th className=\"px-3 py-2 text-left\">\n {t('translations.manager.fields.baseValue', 'Base value')}\n </th>\n )}\n <th className=\"px-3 py-2 text-left\">\n {t('translations.manager.fields.translation', 'Translation')} ({activeLocale.toUpperCase()})\n </th>\n </tr>\n </thead>\n <tbody>\n {fieldList.map((field) => {\n const baseVal = getBaseValue(field.key)\n const translatedVal = localeTranslations[field.key] ?? ''\n\n return (\n <tr key={field.key} className=\"border-t\">\n <td className=\"px-3 py-2 align-top text-xs font-medium text-muted-foreground\">\n {field.label}\n </td>\n {!compact && (\n <td className=\"px-3 py-2 align-top text-xs text-muted-foreground max-w-[200px]\">\n {baseVal ? (\n <span className=\"line-clamp-3\">{baseVal}</span>\n ) : (\n <span className=\"text-muted-foreground/50\">-</span>\n )}\n </td>\n )}\n <td className=\"px-3 py-2 align-top\">\n {field.multiline ? (\n <textarea\n className=\"flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50\"\n rows={3}\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n ) : (\n <Input\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n )}\n </td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </div>\n )\n }\n\n React.useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {\n e.preventDefault()\n if (entityType && recordId && !mutation.isPending) mutation.mutate()\n }\n }\n document.addEventListener('keydown', handler)\n return () => document.removeEventListener('keydown', handler)\n }, [entityType, recordId, mutation])\n\n if (compact) {\n return (\n <div className=\"space-y-3\">\n {renderLocaleTabs()}\n {renderFieldTable()}\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => mutation.mutate()}\n disabled={mutation.isPending || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-3 w-3\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"space-y-6\">\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-2\">\n <h2 className=\"text-xl font-semibold\">{t('translations.manager.title', 'Translations')}</h2>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.manager.description', 'Manage translations for entity records across supported locales.')}\n </p>\n </div>\n\n {!isEmbedded && (\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-start\">\n <div className=\"flex-1 space-y-3\">\n <div>\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectEntity', 'Choose entity')}\n </label>\n <div className=\"mt-1\">\n <ComboboxInput\n value={selectedEntityType}\n onChange={(next) => {\n setSelectedEntityType(next)\n setSelectedRecordId('')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.placeholder', 'Select an entity')}\n suggestions={entitySuggestions}\n resolveLabel={resolveEntityLabel}\n disabled={loadingEntities || !!entitiesError}\n />\n </div>\n {entitiesError && (\n <p className=\"mt-1 text-xs text-destructive\">\n {t('translations.manager.errors.loadEntities', 'Failed to load entities')}\n </p>\n )}\n </div>\n {renderRecordPicker()}\n </div>\n </div>\n )}\n\n <div className=\"rounded-lg border bg-background/80 p-4\">\n {renderLocaleTabs()}\n <div className=\"mt-3\">\n {renderFieldTable()}\n </div>\n </div>\n\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n onClick={() => mutation.mutate()}\n disabled={mutation.isPending || loadingEntities || !!entitiesError || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-4 w-4\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n\nexport function LocaleManager() {\n const t = useT()\n const queryClient = useQueryClient()\n const { data: locales = [], isLoading } = useTranslationLocales()\n const [newLocale, setNewLocale] = React.useState('')\n\n const mutation = useMutation({\n mutationFn: async (updatedLocales: string[]) => {\n // optimistic-lock-exempt: single-row tenant supported-locales settings list \u2014 no per-record version / concurrent record edit\n const res = await apiCall<{ locales: string[] }>('/api/translations/locales', {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ locales: updatedLocales }),\n })\n if (!res.ok) throw new Error('Failed to save locales')\n return res.result?.locales ?? updatedLocales\n },\n onSuccess: (result) => {\n queryClient.setQueryData(['translation-locales'], result)\n flash(t('translations.locales.flash.saved', 'Locales updated'), 'success')\n },\n onError: () => {\n flash(t('translations.locales.flash.error', 'Failed to update locales'), 'error')\n },\n })\n\n const availableLocales = React.useMemo(\n () => ISO_639_1.filter((entry) => !locales.includes(entry.code)).map((entry) => ({\n value: entry.code,\n label: `${entry.code.toUpperCase()} \u2014 ${entry.label}`,\n })),\n [locales],\n )\n\n const addLocale = () => {\n const code = newLocale.toLowerCase().trim()\n if (!code || !isValidIso639(code) || locales.includes(code)) return\n mutation.mutate([...locales, code])\n setNewLocale('')\n }\n\n const removeLocale = (locale: string) => {\n if (locales.length <= 1) return\n mutation.mutate(locales.filter((l) => l !== locale))\n }\n\n if (isLoading) {\n return <LoadingMessage label={t('translations.locales.loading', 'Loading locales...')} className=\"border-0 bg-transparent p-4\" />\n }\n\n return (\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-1\">\n <h3 className=\"text-lg font-semibold\">{t('translations.locales.title', 'Supported locales')}</h3>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.locales.description', 'Configure which locales are available for translations. Add ISO language codes (e.g. fr, it, ja, zh).')}\n </p>\n </div>\n\n <div className=\"flex flex-wrap gap-2\">\n {locales.map((locale) => (\n <span\n key={locale}\n className=\"inline-flex items-center gap-1.5 rounded-full border bg-muted/50 px-3 py-1 text-sm font-medium\"\n title={getIso639Label(locale) ?? locale}\n >\n {locale.toUpperCase()}{getIso639Label(locale) ? ` \u2014 ${getIso639Label(locale)}` : ''}\n {locales.length > 1 && (\n <button\n type=\"button\"\n className=\"rounded-full p-0.5 text-muted-foreground hover:text-foreground transition-colors\"\n onClick={() => removeLocale(locale)}\n disabled={mutation.isPending}\n >\n <X className=\"h-3 w-3\" />\n </button>\n )}\n </span>\n ))}\n </div>\n\n <div className=\"flex gap-2 items-center\">\n <div className=\"max-w-[240px] flex-1\">\n <ComboboxInput\n value={newLocale}\n onChange={setNewLocale}\n placeholder={t('translations.locales.addPlaceholder', 'Search language...')}\n suggestions={availableLocales}\n resolveLabel={(value) => {\n const label = getIso639Label(value)\n return label ? `${value.toUpperCase()} \u2014 ${label}` : value.toUpperCase()\n }}\n />\n </div>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={addLocale}\n disabled={mutation.isPending || !newLocale.trim() || !isValidIso639(newLocale) || locales.includes(newLocale.toLowerCase().trim())}\n >\n <Plus className=\"mr-1 h-3 w-3\" />\n {t('translations.locales.add', 'Add')}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": ";AAiSM,SACE,KADF;AA/RN,YAAY,WAAW;AACvB,SAAS,UAAU,aAAa,sBAAsB;AACtD,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,aAAa;AACtB,SAAS,SAAS,sBAAsB,mCAAmC;AAC3E,SAAS,iCAAiC;AAC1C,SAAS,0BAA0B;AACnC,SAAS,MAAM,MAAM,SAAS;AAC9B,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,WAAW,sBAAsB;AAC1C,SAAS,WAAW,eAAe,sBAAsB;A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,QACV,OAAO,eAAe,MAAM,KAAK;AAAA,QAEhC;AAAA,iBAAO,YAAY;AAAA,UAAG,eAAe,MAAM,IAAI,WAAM,eAAe,MAAM,CAAC,KAAK;AAAA,UAChF,QAAQ,SAAS,KAChB;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,SAAS,MAAM,aAAa,MAAM;AAAA,cAClC,UAAU,SAAS;AAAA,cAEnB,8BAAC,KAAE,WAAU,WAAU;AAAA;AAAA,UACzB;AAAA;AAAA;AAAA,MAbG;AAAA,IAeP,CACD,GACH;AAAA,IAEA,qBAAC,SAAI,WAAU,2BACb;AAAA,0BAAC,SAAI,WAAU,wBACb;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,UACP,UAAU;AAAA,UACV,aAAa,EAAE,uCAAuC,oBAAoB;AAAA,UAC1E,aAAa;AAAA,UACb,cAAc,CAAC,UAAU;AACvB,kBAAM,QAAQ,eAAe,KAAK;AAClC,mBAAO,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAM,KAAK,KAAK,MAAM,YAAY;AAAA,UACzE;AAAA;AAAA,MACF,GACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,SAAS;AAAA,UACT,UAAU,SAAS,aAAa,CAAC,UAAU,KAAK,KAAK,CAAC,cAAc,SAAS,KAAK,QAAQ,SAAS,UAAU,YAAY,EAAE,KAAK,CAAC;AAAA,UAEjI;AAAA,gCAAC,QAAK,WAAU,gBAAe;AAAA,YAC9B,EAAE,4BAA4B,KAAK;AAAA;AAAA;AAAA,MACtC;AAAA,OACF;AAAA,KACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -11,6 +11,20 @@ import {
11
11
  import { serializeWorkflowDefinition, serializeCodeWorkflowDefinition } from "../serialize.js";
12
12
  import { invalidateTriggerCache } from "../../../lib/event-trigger-service.js";
13
13
  import { getCodeWorkflow } from "../../../lib/code-registry.js";
14
+ import { createGenericOptimisticLockReader } from "@open-mercato/shared/lib/crud/optimistic-lock";
15
+ import { registerOptimisticLockReaderIfAbsent } from "@open-mercato/shared/lib/crud/optimistic-lock-store";
16
+ import { validateCrudMutationGuard, runCrudMutationGuardAfterSuccess } from "@open-mercato/shared/lib/crud/mutation-guard";
17
+ import { enforceCommandOptimisticLock } from "@open-mercato/shared/lib/crud/optimistic-lock-command";
18
+ import { isCrudHttpError } from "@open-mercato/shared/lib/crud/errors";
19
+ registerOptimisticLockReaderIfAbsent({
20
+ "workflows.definition": createGenericOptimisticLockReader({
21
+ entity: WorkflowDefinition,
22
+ idField: "id",
23
+ tenantField: "tenantId",
24
+ orgField: "organizationId",
25
+ softDeleteField: "deletedAt"
26
+ })
27
+ });
14
28
  const metadata = {
15
29
  requireAuth: true,
16
30
  requireFeatures: ["workflows.definitions.view"]
@@ -100,6 +114,20 @@ async function PUT(request, context) {
100
114
  );
101
115
  }
102
116
  const input = validation.data;
117
+ const guardResult = await validateCrudMutationGuard(container, {
118
+ tenantId: tenantId ?? "",
119
+ organizationId: organizationId ?? null,
120
+ userId: auth.sub ?? "",
121
+ resourceKind: "workflows.definition",
122
+ resourceId: params.id,
123
+ operation: "update",
124
+ requestMethod: "PUT",
125
+ requestHeaders: request.headers,
126
+ mutationPayload: input
127
+ });
128
+ if (guardResult && !guardResult.ok) {
129
+ return NextResponse.json(guardResult.body, { status: guardResult.status });
130
+ }
103
131
  if (params.id.startsWith("code:")) {
104
132
  const workflowId = params.id.slice(5);
105
133
  const codeDef = getCodeWorkflow(workflowId);
@@ -115,6 +143,19 @@ async function PUT(request, context) {
115
143
  });
116
144
  let savedOverride;
117
145
  if (existingOverride) {
146
+ try {
147
+ enforceCommandOptimisticLock({
148
+ resourceKind: "workflows.definition",
149
+ resourceId: existingOverride.id,
150
+ current: existingOverride.updatedAt ?? null,
151
+ request
152
+ });
153
+ } catch (lockError) {
154
+ if (isCrudHttpError(lockError)) {
155
+ return NextResponse.json(lockError.body, { status: lockError.status });
156
+ }
157
+ throw lockError;
158
+ }
118
159
  existingOverride.deletedAt = null;
119
160
  existingOverride.workflowName = codeDef.workflowName;
120
161
  existingOverride.description = codeDef.description;
@@ -167,6 +208,19 @@ async function PUT(request, context) {
167
208
  } catch (eventError) {
168
209
  console.error("Failed to emit workflows.definition.customized event:", eventError);
169
210
  }
211
+ if (guardResult?.shouldRunAfterSuccess) {
212
+ await runCrudMutationGuardAfterSuccess(container, {
213
+ tenantId: tenantId ?? "",
214
+ organizationId: organizationId ?? null,
215
+ userId: auth.sub ?? "",
216
+ resourceKind: "workflows.definition",
217
+ resourceId: String(savedOverride.id),
218
+ operation: "update",
219
+ requestMethod: "PUT",
220
+ requestHeaders: request.headers,
221
+ metadata: guardResult.metadata
222
+ });
223
+ }
170
224
  return NextResponse.json({
171
225
  data: serializeWorkflowDefinition(savedOverride),
172
226
  message: "Workflow definition customized successfully"
@@ -184,6 +238,19 @@ async function PUT(request, context) {
184
238
  { status: 404 }
185
239
  );
186
240
  }
241
+ try {
242
+ enforceCommandOptimisticLock({
243
+ resourceKind: "workflows.definition",
244
+ resourceId: definition.id,
245
+ current: definition.updatedAt ?? null,
246
+ request
247
+ });
248
+ } catch (lockError) {
249
+ if (isCrudHttpError(lockError)) {
250
+ return NextResponse.json(lockError.body, { status: lockError.status });
251
+ }
252
+ throw lockError;
253
+ }
187
254
  if (input.workflowName !== void 0) {
188
255
  definition.workflowName = input.workflowName;
189
256
  }
@@ -210,6 +277,19 @@ async function PUT(request, context) {
210
277
  }
211
278
  definition.updatedAt = /* @__PURE__ */ new Date();
212
279
  await em.flush();
280
+ if (guardResult?.shouldRunAfterSuccess) {
281
+ await runCrudMutationGuardAfterSuccess(container, {
282
+ tenantId: tenantId ?? "",
283
+ organizationId: organizationId ?? null,
284
+ userId: auth.sub ?? "",
285
+ resourceKind: "workflows.definition",
286
+ resourceId: String(definition.id),
287
+ operation: "update",
288
+ requestMethod: "PUT",
289
+ requestHeaders: request.headers,
290
+ metadata: guardResult.metadata
291
+ });
292
+ }
213
293
  if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? void 0);
214
294
  return NextResponse.json({
215
295
  data: serializeWorkflowDefinition(definition),
@@ -262,6 +342,19 @@ async function DELETE(request, context) {
262
342
  { status: 404 }
263
343
  );
264
344
  }
345
+ const guardResult = await validateCrudMutationGuard(container, {
346
+ tenantId: tenantId ?? "",
347
+ organizationId: organizationId ?? null,
348
+ userId: auth.sub ?? "",
349
+ resourceKind: "workflows.definition",
350
+ resourceId: params.id,
351
+ operation: "delete",
352
+ requestMethod: "DELETE",
353
+ requestHeaders: request.headers
354
+ });
355
+ if (guardResult && !guardResult.ok) {
356
+ return NextResponse.json(guardResult.body, { status: guardResult.status });
357
+ }
265
358
  const { WorkflowInstance } = await import("../../../data/entities.js");
266
359
  const activeInstances = await em.count(WorkflowInstance, {
267
360
  definitionId: definition.id,
@@ -278,6 +371,19 @@ async function DELETE(request, context) {
278
371
  definition.deletedAt = /* @__PURE__ */ new Date();
279
372
  definition.updatedAt = /* @__PURE__ */ new Date();
280
373
  await em.flush();
374
+ if (guardResult?.shouldRunAfterSuccess) {
375
+ await runCrudMutationGuardAfterSuccess(container, {
376
+ tenantId: tenantId ?? "",
377
+ organizationId: organizationId ?? null,
378
+ userId: auth.sub ?? "",
379
+ resourceKind: "workflows.definition",
380
+ resourceId: String(definition.id),
381
+ operation: "delete",
382
+ requestMethod: "DELETE",
383
+ requestHeaders: request.headers,
384
+ metadata: guardResult.metadata
385
+ });
386
+ }
281
387
  if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? void 0);
282
388
  return NextResponse.json({
283
389
  message: "Workflow definition deleted successfully"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/workflows/api/definitions/%5Bid%5D/route.ts"],
4
- "sourcesContent": ["/**\n * Workflow Definition Detail API\n *\n * Endpoints:\n * - GET /api/workflows/definitions/[id] - Get workflow definition\n * - PUT /api/workflows/definitions/[id] - Update workflow definition\n * - DELETE /api/workflows/definitions/[id] - Delete workflow definition (soft delete)\n */\n\nimport { NextRequest, NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveOrganizationScopeFilter } from '@open-mercato/core/modules/directory/utils/organizationScopeFilter'\nimport { WorkflowDefinition } from '../../../data/entities'\nimport {\n updateWorkflowDefinitionInputSchema,\n type UpdateWorkflowDefinitionApiInput,\n} from '../../../data/validators'\nimport { serializeWorkflowDefinition, serializeCodeWorkflowDefinition } from '../serialize'\nimport { invalidateTriggerCache } from '../../../lib/event-trigger-service'\nimport { getCodeWorkflow } from '../../../lib/code-registry'\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['workflows.definitions.view'],\n}\n\ninterface RouteContext {\n params: Promise<{\n id: string\n }>\n}\n\n/**\n * GET /api/workflows/definitions/[id]\n *\n * Get a single workflow definition by ID\n */\nexport async function GET(\n request: NextRequest,\n context: RouteContext\n) {\n try {\n const params = await context.params\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const orgFilter = resolveOrganizationScopeFilter(scope, auth)\n\n // Handle code-based workflow definitions (code:<workflowId>)\n if (params.id.startsWith('code:')) {\n const workflowId = params.id.slice(5)\n const codeDef = getCodeWorkflow(workflowId)\n if (!codeDef) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n return NextResponse.json({\n data: serializeCodeWorkflowDefinition(codeDef, params.id),\n })\n }\n\n const definition = await em.findOne(WorkflowDefinition, {\n id: params.id,\n tenantId,\n ...orgFilter.where,\n deletedAt: null,\n })\n\n if (!definition) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n return NextResponse.json({ data: serializeWorkflowDefinition(definition) })\n } catch (error) {\n console.error('Error getting workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to get workflow definition' },\n { status: 500 }\n )\n }\n}\n\n/**\n * PUT /api/workflows/definitions/[id]\n *\n * Update a workflow definition\n */\nexport async function PUT(\n request: NextRequest,\n context: RouteContext\n) {\n try {\n const params = await context.params\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const organizationId = scope?.selectedId ?? auth.orgId\n\n // Check edit permission\n const rbacService = container.resolve('rbacService')\n const hasPermission = await rbacService.userHasAllFeatures(\n auth.sub,\n ['workflows.definitions.edit'],\n {\n tenantId,\n organizationId,\n }\n )\n\n if (!hasPermission) {\n return NextResponse.json(\n { error: 'Insufficient permissions' },\n { status: 403 }\n )\n }\n\n const body = await request.json()\n\n // Validate input\n const validation = updateWorkflowDefinitionInputSchema.safeParse(body)\n if (!validation.success) {\n return NextResponse.json(\n {\n error: 'Validation failed',\n details: validation.error.issues,\n },\n { status: 400 }\n )\n }\n\n const input: UpdateWorkflowDefinitionApiInput = validation.data\n\n // Handle customizing a code-based workflow definition\n if (params.id.startsWith('code:')) {\n const workflowId = params.id.slice(5)\n const codeDef = getCodeWorkflow(workflowId)\n if (!codeDef) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n // Check if an override already exists (including soft-deleted, due to unique constraint on workflowId+tenantId)\n const existingOverride = await em.findOne(WorkflowDefinition, {\n workflowId: codeDef.workflowId,\n tenantId,\n })\n\n let savedOverride: WorkflowDefinition\n if (existingOverride) {\n // Revive if soft-deleted, then apply updates\n existingOverride.deletedAt = null\n existingOverride.workflowName = codeDef.workflowName\n existingOverride.description = codeDef.description\n existingOverride.version = codeDef.version\n existingOverride.definition = input.definition ?? codeDef.definition\n existingOverride.metadata = codeDef.metadata ?? null\n existingOverride.enabled = input.enabled ?? codeDef.enabled\n existingOverride.codeWorkflowId = codeDef.workflowId\n existingOverride.updatedBy = auth.sub\n existingOverride.updatedAt = new Date()\n await em.flush()\n savedOverride = existingOverride\n } else {\n // Create DB override row from code definition + user changes\n const override = em.create(WorkflowDefinition, {\n workflowId: codeDef.workflowId,\n workflowName: codeDef.workflowName,\n description: codeDef.description,\n version: codeDef.version,\n definition: input.definition ?? codeDef.definition,\n metadata: codeDef.metadata,\n enabled: input.enabled ?? codeDef.enabled,\n codeWorkflowId: codeDef.workflowId,\n tenantId,\n organizationId,\n createdBy: auth.sub,\n updatedBy: auth.sub,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n\n em.persist(override)\n await em.flush()\n savedOverride = override\n }\n\n try {\n const eventBus = container.resolve('eventBus') as\n | { emitEvent(event: string, payload: unknown, options?: unknown): Promise<void> }\n | undefined\n if (eventBus && typeof eventBus.emitEvent === 'function') {\n await eventBus.emitEvent(\n 'workflows.definition.customized',\n {\n id: savedOverride.id,\n workflowId: savedOverride.workflowId,\n codeWorkflowId: savedOverride.codeWorkflowId ?? null,\n tenantId: savedOverride.tenantId,\n organizationId: savedOverride.organizationId,\n userId: auth.sub ?? null,\n },\n { tenantId: savedOverride.tenantId, organizationId: savedOverride.organizationId, persistent: true },\n )\n }\n } catch (eventError) {\n console.error('Failed to emit workflows.definition.customized event:', eventError)\n }\n\n return NextResponse.json({\n data: serializeWorkflowDefinition(savedOverride),\n message: 'Workflow definition customized successfully',\n })\n }\n\n // Find existing definition\n const definition = await em.findOne(WorkflowDefinition, {\n id: params.id,\n tenantId,\n organizationId,\n deletedAt: null,\n })\n\n if (!definition) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n // Update fields. workflowId is intentionally ignored \u2014 it identifies the\n // row and renaming would break references. Version is user-managed and\n // applied when supplied so the edit form can bump it explicitly.\n if (input.workflowName !== undefined) {\n definition.workflowName = input.workflowName\n }\n if (input.description !== undefined) {\n definition.description = input.description\n }\n if (input.version !== undefined) {\n definition.version = input.version\n }\n if (input.definition !== undefined) {\n definition.definition = input.definition\n }\n if (input.metadata !== undefined) {\n definition.metadata = input.metadata\n }\n if (input.enabled !== undefined) {\n definition.enabled = input.enabled\n }\n if (input.effectiveFrom !== undefined) {\n definition.effectiveFrom = input.effectiveFrom\n }\n if (input.effectiveTo !== undefined) {\n definition.effectiveTo = input.effectiveTo\n }\n\n definition.updatedAt = new Date()\n\n await em.flush()\n\n // Embedded triggers may have changed; invalidate the in-memory cache so\n // the wildcard event subscriber reloads them on the next event.\n if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? undefined)\n\n return NextResponse.json({\n data: serializeWorkflowDefinition(definition),\n message: 'Workflow definition updated successfully',\n })\n } catch (error) {\n console.error('Error updating workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to update workflow definition' },\n { status: 500 }\n )\n }\n}\n\n/**\n * DELETE /api/workflows/definitions/[id]\n *\n * Soft delete a workflow definition\n */\nexport async function DELETE(\n request: NextRequest,\n context: RouteContext\n) {\n try {\n const params = await context.params\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const organizationId = scope?.selectedId ?? auth.orgId\n\n // Check delete permission\n const rbacService = container.resolve('rbacService')\n const hasPermission = await rbacService.userHasAllFeatures(\n auth.sub,\n ['workflows.definitions.delete'],\n {\n tenantId,\n organizationId,\n }\n )\n\n if (!hasPermission) {\n return NextResponse.json(\n { error: 'Insufficient permissions' },\n { status: 403 }\n )\n }\n\n // Find existing definition\n const definition = await em.findOne(WorkflowDefinition, {\n id: params.id,\n tenantId,\n organizationId,\n deletedAt: null,\n })\n\n if (!definition) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n // Check if there are active workflow instances using this definition\n const { WorkflowInstance } = await import('../../../data/entities')\n const activeInstances = await em.count(WorkflowInstance, {\n definitionId: definition.id,\n status: { $in: ['RUNNING', 'WAITING'] },\n })\n\n if (activeInstances > 0) {\n return NextResponse.json(\n {\n error: `Cannot delete workflow definition with ${activeInstances} active instance(s)`,\n },\n { status: 409 }\n )\n }\n\n // Soft delete\n definition.deletedAt = new Date()\n definition.updatedAt = new Date()\n\n await em.flush()\n\n if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? undefined)\n\n return NextResponse.json({\n message: 'Workflow definition deleted successfully',\n })\n } catch (error) {\n console.error('Error deleting workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to delete workflow definition' },\n { status: 500 }\n )\n }\n}\n\nexport const openApi = {\n methods: {\n GET: {\n summary: 'Get workflow definition',\n description: 'Get a single workflow definition by ID. Returns the complete workflow structure including steps and transitions (with embedded activities).',\n tags: ['Workflows'],\n pathParams: z.object({\n id: z.string().describe('UUID for DB definitions, or \"code:<workflowId>\" for code-based definitions'),\n }),\n responses: [\n {\n status: 200,\n description: 'Workflow definition found',\n example: {\n data: {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n description: 'Validate cart items and check inventory',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n description: 'Charge payment method',\n retryPolicy: {\n maxAttempts: 3,\n backoffMs: 1000,\n },\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-end',\n fromStepId: 'payment',\n toStepId: 'end',\n trigger: 'auto',\n activities: [\n {\n activityName: 'Send Order Confirmation',\n activityType: 'SEND_EMAIL',\n config: {\n to: '{{context.customerEmail}}',\n subject: 'Order Confirmation #{{context.orderId}}',\n template: 'order_confirmation',\n },\n },\n ],\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T10:00:00.000Z',\n },\n },\n },\n {\n status: 404,\n description: 'Workflow definition not found',\n example: {\n error: 'Workflow definition not found',\n },\n },\n ],\n },\n PUT: {\n summary: 'Update workflow definition',\n description: 'Update an existing workflow definition. Supports partial updates - only provided fields will be updated.',\n tags: ['Workflows'],\n pathParams: z.object({\n id: z.string().uuid(),\n }),\n requestBody: {\n schema: updateWorkflowDefinitionInputSchema,\n example: {\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'confirmation',\n stepName: 'Order Confirmation',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-confirmation',\n fromStepId: 'payment',\n toStepId: 'confirmation',\n trigger: 'auto',\n },\n {\n transitionId: 'confirmation-to-end',\n fromStepId: 'confirmation',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n },\n },\n responses: [\n {\n status: 200,\n description: 'Workflow definition updated successfully',\n example: {\n data: {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n { stepId: 'start', stepName: 'Start', stepType: 'START' },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'confirmation',\n stepName: 'Order Confirmation',\n stepType: 'AUTOMATED',\n },\n { stepId: 'end', stepName: 'End', stepType: 'END' },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-confirmation',\n fromStepId: 'payment',\n toStepId: 'confirmation',\n trigger: 'auto',\n },\n {\n transitionId: 'confirmation-to-end',\n fromStepId: 'confirmation',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T11:30:00.000Z',\n },\n message: 'Workflow definition updated successfully',\n },\n },\n {\n status: 400,\n description: 'Validation error',\n example: {\n error: 'Validation failed',\n details: [\n {\n code: 'invalid_type',\n message: 'Expected object, received string',\n path: ['definition'],\n },\n ],\n },\n },\n {\n status: 404,\n description: 'Workflow definition not found',\n example: {\n error: 'Workflow definition not found',\n },\n },\n ],\n },\n DELETE: {\n summary: 'Delete workflow definition',\n description: 'Soft delete a workflow definition. Cannot be deleted if there are active workflow instances (RUNNING or WAITING status) using this definition.',\n tags: ['Workflows'],\n pathParams: z.object({\n id: z.string().uuid(),\n }),\n responses: [\n {\n status: 200,\n description: 'Workflow definition deleted successfully',\n example: {\n message: 'Workflow definition deleted successfully',\n },\n },\n {\n status: 404,\n description: 'Workflow definition not found',\n example: {\n error: 'Workflow definition not found',\n },\n },\n {\n status: 409,\n description: 'Cannot delete - active workflow instances exist',\n example: {\n error: 'Cannot delete workflow definition with 3 active instance(s)',\n },\n },\n ],\n },\n },\n}\n"],
5
- "mappings": "AASA,SAAsB,oBAAoB;AAC1C,SAAS,SAAS;AAClB,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,0CAA0C;AACnD,SAAS,sCAAsC;AAC/C,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,OAEK;AACP,SAAS,6BAA6B,uCAAuC;AAC7E,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAEzB,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,4BAA4B;AAChD;AAaA,eAAsB,IACpB,SACA,SACA;AACA,MAAI;AACF,UAAM,SAAS,MAAM,QAAQ;AAC7B,UAAM,YAAY,MAAM,uBAAuB;AAC/C,UAAM,KAAK,UAAU,QAAQ,IAAI;AACjC,UAAM,OAAO,MAAM,mBAAmB,OAAO;AAE7C,QAAI,CAAC,MAAM;AACT,aAAO,aAAa,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,IACrE;AAEA,UAAM,QAAQ,MAAM,mCAAmC,EAAE,WAAW,MAAM,QAAQ,CAAC;AACnF,UAAM,WAAW,KAAK;AACtB,UAAM,YAAY,+BAA+B,OAAO,IAAI;AAG5D,QAAI,OAAO,GAAG,WAAW,OAAO,GAAG;AACjC,YAAM,aAAa,OAAO,GAAG,MAAM,CAAC;AACpC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AA,YACP,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * Workflow Definition Detail API\n *\n * Endpoints:\n * - GET /api/workflows/definitions/[id] - Get workflow definition\n * - PUT /api/workflows/definitions/[id] - Update workflow definition\n * - DELETE /api/workflows/definitions/[id] - Delete workflow definition (soft delete)\n */\n\nimport { NextRequest, NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport { resolveOrganizationScopeFilter } from '@open-mercato/core/modules/directory/utils/organizationScopeFilter'\nimport { WorkflowDefinition } from '../../../data/entities'\nimport {\n updateWorkflowDefinitionInputSchema,\n type UpdateWorkflowDefinitionApiInput,\n} from '../../../data/validators'\nimport { serializeWorkflowDefinition, serializeCodeWorkflowDefinition } from '../serialize'\nimport { invalidateTriggerCache } from '../../../lib/event-trigger-service'\nimport { getCodeWorkflow } from '../../../lib/code-registry'\nimport { createGenericOptimisticLockReader } from '@open-mercato/shared/lib/crud/optimistic-lock'\nimport { registerOptimisticLockReaderIfAbsent } from '@open-mercato/shared/lib/crud/optimistic-lock-store'\nimport { validateCrudMutationGuard, runCrudMutationGuardAfterSuccess } from '@open-mercato/shared/lib/crud/mutation-guard'\nimport { enforceCommandOptimisticLock } from '@open-mercato/shared/lib/crud/optimistic-lock-command'\nimport { isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'\n\nregisterOptimisticLockReaderIfAbsent({\n 'workflows.definition': createGenericOptimisticLockReader({\n entity: WorkflowDefinition,\n idField: 'id',\n tenantField: 'tenantId',\n orgField: 'organizationId',\n softDeleteField: 'deletedAt',\n }),\n})\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['workflows.definitions.view'],\n}\n\ninterface RouteContext {\n params: Promise<{\n id: string\n }>\n}\n\n/**\n * GET /api/workflows/definitions/[id]\n *\n * Get a single workflow definition by ID\n */\nexport async function GET(\n request: NextRequest,\n context: RouteContext\n) {\n try {\n const params = await context.params\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const orgFilter = resolveOrganizationScopeFilter(scope, auth)\n\n // Handle code-based workflow definitions (code:<workflowId>)\n if (params.id.startsWith('code:')) {\n const workflowId = params.id.slice(5)\n const codeDef = getCodeWorkflow(workflowId)\n if (!codeDef) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n return NextResponse.json({\n data: serializeCodeWorkflowDefinition(codeDef, params.id),\n })\n }\n\n const definition = await em.findOne(WorkflowDefinition, {\n id: params.id,\n tenantId,\n ...orgFilter.where,\n deletedAt: null,\n })\n\n if (!definition) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n return NextResponse.json({ data: serializeWorkflowDefinition(definition) })\n } catch (error) {\n console.error('Error getting workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to get workflow definition' },\n { status: 500 }\n )\n }\n}\n\n/**\n * PUT /api/workflows/definitions/[id]\n *\n * Update a workflow definition\n */\nexport async function PUT(\n request: NextRequest,\n context: RouteContext\n) {\n try {\n const params = await context.params\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const organizationId = scope?.selectedId ?? auth.orgId\n\n // Check edit permission\n const rbacService = container.resolve('rbacService')\n const hasPermission = await rbacService.userHasAllFeatures(\n auth.sub,\n ['workflows.definitions.edit'],\n {\n tenantId,\n organizationId,\n }\n )\n\n if (!hasPermission) {\n return NextResponse.json(\n { error: 'Insufficient permissions' },\n { status: 403 }\n )\n }\n\n const body = await request.json()\n\n // Validate input\n const validation = updateWorkflowDefinitionInputSchema.safeParse(body)\n if (!validation.success) {\n return NextResponse.json(\n {\n error: 'Validation failed',\n details: validation.error.issues,\n },\n { status: 400 }\n )\n }\n\n const input: UpdateWorkflowDefinitionApiInput = validation.data\n const guardResult = await validateCrudMutationGuard(container, {\n tenantId: tenantId ?? '',\n organizationId: organizationId ?? null,\n userId: auth.sub ?? '',\n resourceKind: 'workflows.definition',\n resourceId: params.id,\n operation: 'update',\n requestMethod: 'PUT',\n requestHeaders: request.headers,\n mutationPayload: input as Record<string, unknown>,\n })\n if (guardResult && !guardResult.ok) {\n return NextResponse.json(guardResult.body, { status: guardResult.status })\n }\n\n // Handle customizing a code-based workflow definition\n if (params.id.startsWith('code:')) {\n const workflowId = params.id.slice(5)\n const codeDef = getCodeWorkflow(workflowId)\n if (!codeDef) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n // Check if an override already exists (including soft-deleted, due to unique constraint on workflowId+tenantId)\n const existingOverride = await em.findOne(WorkflowDefinition, {\n workflowId: codeDef.workflowId,\n tenantId,\n })\n\n let savedOverride: WorkflowDefinition\n if (existingOverride) {\n try {\n enforceCommandOptimisticLock({\n resourceKind: 'workflows.definition',\n resourceId: existingOverride.id,\n current: existingOverride.updatedAt ?? null,\n request,\n })\n } catch (lockError) {\n if (isCrudHttpError(lockError)) {\n return NextResponse.json(lockError.body, { status: lockError.status })\n }\n throw lockError\n }\n // Revive if soft-deleted, then apply updates\n existingOverride.deletedAt = null\n existingOverride.workflowName = codeDef.workflowName\n existingOverride.description = codeDef.description\n existingOverride.version = codeDef.version\n existingOverride.definition = input.definition ?? codeDef.definition\n existingOverride.metadata = codeDef.metadata ?? null\n existingOverride.enabled = input.enabled ?? codeDef.enabled\n existingOverride.codeWorkflowId = codeDef.workflowId\n existingOverride.updatedBy = auth.sub\n existingOverride.updatedAt = new Date()\n await em.flush()\n savedOverride = existingOverride\n } else {\n // Create DB override row from code definition + user changes\n const override = em.create(WorkflowDefinition, {\n workflowId: codeDef.workflowId,\n workflowName: codeDef.workflowName,\n description: codeDef.description,\n version: codeDef.version,\n definition: input.definition ?? codeDef.definition,\n metadata: codeDef.metadata,\n enabled: input.enabled ?? codeDef.enabled,\n codeWorkflowId: codeDef.workflowId,\n tenantId,\n organizationId,\n createdBy: auth.sub,\n updatedBy: auth.sub,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n\n em.persist(override)\n await em.flush()\n savedOverride = override\n }\n\n try {\n const eventBus = container.resolve('eventBus') as\n | { emitEvent(event: string, payload: unknown, options?: unknown): Promise<void> }\n | undefined\n if (eventBus && typeof eventBus.emitEvent === 'function') {\n await eventBus.emitEvent(\n 'workflows.definition.customized',\n {\n id: savedOverride.id,\n workflowId: savedOverride.workflowId,\n codeWorkflowId: savedOverride.codeWorkflowId ?? null,\n tenantId: savedOverride.tenantId,\n organizationId: savedOverride.organizationId,\n userId: auth.sub ?? null,\n },\n { tenantId: savedOverride.tenantId, organizationId: savedOverride.organizationId, persistent: true },\n )\n }\n } catch (eventError) {\n console.error('Failed to emit workflows.definition.customized event:', eventError)\n }\n\n if (guardResult?.shouldRunAfterSuccess) {\n await runCrudMutationGuardAfterSuccess(container, {\n tenantId: tenantId ?? '',\n organizationId: organizationId ?? null,\n userId: auth.sub ?? '',\n resourceKind: 'workflows.definition',\n resourceId: String(savedOverride.id),\n operation: 'update',\n requestMethod: 'PUT',\n requestHeaders: request.headers,\n metadata: guardResult.metadata,\n })\n }\n\n return NextResponse.json({\n data: serializeWorkflowDefinition(savedOverride),\n message: 'Workflow definition customized successfully',\n })\n }\n\n // Find existing definition\n const definition = await em.findOne(WorkflowDefinition, {\n id: params.id,\n tenantId,\n organizationId,\n deletedAt: null,\n })\n\n if (!definition) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n try {\n enforceCommandOptimisticLock({\n resourceKind: 'workflows.definition',\n resourceId: definition.id,\n current: definition.updatedAt ?? null,\n request,\n })\n } catch (lockError) {\n if (isCrudHttpError(lockError)) {\n return NextResponse.json(lockError.body, { status: lockError.status })\n }\n throw lockError\n }\n\n // Update fields. workflowId is intentionally ignored \u2014 it identifies the\n // row and renaming would break references. Version is user-managed and\n // applied when supplied so the edit form can bump it explicitly.\n if (input.workflowName !== undefined) {\n definition.workflowName = input.workflowName\n }\n if (input.description !== undefined) {\n definition.description = input.description\n }\n if (input.version !== undefined) {\n definition.version = input.version\n }\n if (input.definition !== undefined) {\n definition.definition = input.definition\n }\n if (input.metadata !== undefined) {\n definition.metadata = input.metadata\n }\n if (input.enabled !== undefined) {\n definition.enabled = input.enabled\n }\n if (input.effectiveFrom !== undefined) {\n definition.effectiveFrom = input.effectiveFrom\n }\n if (input.effectiveTo !== undefined) {\n definition.effectiveTo = input.effectiveTo\n }\n\n definition.updatedAt = new Date()\n\n await em.flush()\n\n if (guardResult?.shouldRunAfterSuccess) {\n await runCrudMutationGuardAfterSuccess(container, {\n tenantId: tenantId ?? '',\n organizationId: organizationId ?? null,\n userId: auth.sub ?? '',\n resourceKind: 'workflows.definition',\n resourceId: String(definition.id),\n operation: 'update',\n requestMethod: 'PUT',\n requestHeaders: request.headers,\n metadata: guardResult.metadata,\n })\n }\n\n // Embedded triggers may have changed; invalidate the in-memory cache so\n // the wildcard event subscriber reloads them on the next event.\n if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? undefined)\n\n return NextResponse.json({\n data: serializeWorkflowDefinition(definition),\n message: 'Workflow definition updated successfully',\n })\n } catch (error) {\n console.error('Error updating workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to update workflow definition' },\n { status: 500 }\n )\n }\n}\n\n/**\n * DELETE /api/workflows/definitions/[id]\n *\n * Soft delete a workflow definition\n */\nexport async function DELETE(\n request: NextRequest,\n context: RouteContext\n) {\n try {\n const params = await context.params\n const container = await createRequestContainer()\n const em = container.resolve('em')\n const auth = await getAuthFromRequest(request)\n\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request })\n const tenantId = auth.tenantId\n const organizationId = scope?.selectedId ?? auth.orgId\n\n // Check delete permission\n const rbacService = container.resolve('rbacService')\n const hasPermission = await rbacService.userHasAllFeatures(\n auth.sub,\n ['workflows.definitions.delete'],\n {\n tenantId,\n organizationId,\n }\n )\n\n if (!hasPermission) {\n return NextResponse.json(\n { error: 'Insufficient permissions' },\n { status: 403 }\n )\n }\n\n // Find existing definition\n const definition = await em.findOne(WorkflowDefinition, {\n id: params.id,\n tenantId,\n organizationId,\n deletedAt: null,\n })\n\n if (!definition) {\n return NextResponse.json(\n { error: 'Workflow definition not found' },\n { status: 404 }\n )\n }\n\n const guardResult = await validateCrudMutationGuard(container, {\n tenantId: tenantId ?? '',\n organizationId: organizationId ?? null,\n userId: auth.sub ?? '',\n resourceKind: 'workflows.definition',\n resourceId: params.id,\n operation: 'delete',\n requestMethod: 'DELETE',\n requestHeaders: request.headers,\n })\n if (guardResult && !guardResult.ok) {\n return NextResponse.json(guardResult.body, { status: guardResult.status })\n }\n\n // Check if there are active workflow instances using this definition\n const { WorkflowInstance } = await import('../../../data/entities')\n const activeInstances = await em.count(WorkflowInstance, {\n definitionId: definition.id,\n status: { $in: ['RUNNING', 'WAITING'] },\n })\n\n if (activeInstances > 0) {\n return NextResponse.json(\n {\n error: `Cannot delete workflow definition with ${activeInstances} active instance(s)`,\n },\n { status: 409 }\n )\n }\n\n // Soft delete\n definition.deletedAt = new Date()\n definition.updatedAt = new Date()\n\n await em.flush()\n\n if (guardResult?.shouldRunAfterSuccess) {\n await runCrudMutationGuardAfterSuccess(container, {\n tenantId: tenantId ?? '',\n organizationId: organizationId ?? null,\n userId: auth.sub ?? '',\n resourceKind: 'workflows.definition',\n resourceId: String(definition.id),\n operation: 'delete',\n requestMethod: 'DELETE',\n requestHeaders: request.headers,\n metadata: guardResult.metadata,\n })\n }\n\n if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? undefined)\n\n return NextResponse.json({\n message: 'Workflow definition deleted successfully',\n })\n } catch (error) {\n console.error('Error deleting workflow definition:', error)\n return NextResponse.json(\n { error: 'Failed to delete workflow definition' },\n { status: 500 }\n )\n }\n}\n\nexport const openApi = {\n methods: {\n GET: {\n summary: 'Get workflow definition',\n description: 'Get a single workflow definition by ID. Returns the complete workflow structure including steps and transitions (with embedded activities).',\n tags: ['Workflows'],\n pathParams: z.object({\n id: z.string().describe('UUID for DB definitions, or \"code:<workflowId>\" for code-based definitions'),\n }),\n responses: [\n {\n status: 200,\n description: 'Workflow definition found',\n example: {\n data: {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n description: 'Validate cart items and check inventory',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n description: 'Charge payment method',\n retryPolicy: {\n maxAttempts: 3,\n backoffMs: 1000,\n },\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-end',\n fromStepId: 'payment',\n toStepId: 'end',\n trigger: 'auto',\n activities: [\n {\n activityName: 'Send Order Confirmation',\n activityType: 'SEND_EMAIL',\n config: {\n to: '{{context.customerEmail}}',\n subject: 'Order Confirmation #{{context.orderId}}',\n template: 'order_confirmation',\n },\n },\n ],\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T10:00:00.000Z',\n },\n },\n },\n {\n status: 404,\n description: 'Workflow definition not found',\n example: {\n error: 'Workflow definition not found',\n },\n },\n ],\n },\n PUT: {\n summary: 'Update workflow definition',\n description: 'Update an existing workflow definition. Supports partial updates - only provided fields will be updated.',\n tags: ['Workflows'],\n pathParams: z.object({\n id: z.string().uuid(),\n }),\n requestBody: {\n schema: updateWorkflowDefinitionInputSchema,\n example: {\n definition: {\n steps: [\n {\n stepId: 'start',\n stepName: 'Start',\n stepType: 'START',\n },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'confirmation',\n stepName: 'Order Confirmation',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'end',\n stepName: 'End',\n stepType: 'END',\n },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-confirmation',\n fromStepId: 'payment',\n toStepId: 'confirmation',\n trigger: 'auto',\n },\n {\n transitionId: 'confirmation-to-end',\n fromStepId: 'confirmation',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n },\n },\n responses: [\n {\n status: 200,\n description: 'Workflow definition updated successfully',\n example: {\n data: {\n id: '123e4567-e89b-12d3-a456-426614174000',\n workflowId: 'checkout-flow',\n workflowName: 'Checkout Flow',\n description: 'Complete checkout workflow for processing orders',\n version: 1,\n definition: {\n steps: [\n { stepId: 'start', stepName: 'Start', stepType: 'START' },\n {\n stepId: 'validate-cart',\n stepName: 'Validate Cart',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'payment',\n stepName: 'Process Payment',\n stepType: 'AUTOMATED',\n },\n {\n stepId: 'confirmation',\n stepName: 'Order Confirmation',\n stepType: 'AUTOMATED',\n },\n { stepId: 'end', stepName: 'End', stepType: 'END' },\n ],\n transitions: [\n {\n transitionId: 'start-to-validate',\n fromStepId: 'start',\n toStepId: 'validate-cart',\n trigger: 'auto',\n },\n {\n transitionId: 'validate-to-payment',\n fromStepId: 'validate-cart',\n toStepId: 'payment',\n trigger: 'auto',\n },\n {\n transitionId: 'payment-to-confirmation',\n fromStepId: 'payment',\n toStepId: 'confirmation',\n trigger: 'auto',\n },\n {\n transitionId: 'confirmation-to-end',\n fromStepId: 'confirmation',\n toStepId: 'end',\n trigger: 'auto',\n },\n ],\n },\n enabled: true,\n tenantId: '123e4567-e89b-12d3-a456-426614174001',\n organizationId: '123e4567-e89b-12d3-a456-426614174002',\n createdAt: '2025-12-08T10:00:00.000Z',\n updatedAt: '2025-12-08T11:30:00.000Z',\n },\n message: 'Workflow definition updated successfully',\n },\n },\n {\n status: 400,\n description: 'Validation error',\n example: {\n error: 'Validation failed',\n details: [\n {\n code: 'invalid_type',\n message: 'Expected object, received string',\n path: ['definition'],\n },\n ],\n },\n },\n {\n status: 404,\n description: 'Workflow definition not found',\n example: {\n error: 'Workflow definition not found',\n },\n },\n ],\n },\n DELETE: {\n summary: 'Delete workflow definition',\n description: 'Soft delete a workflow definition. Cannot be deleted if there are active workflow instances (RUNNING or WAITING status) using this definition.',\n tags: ['Workflows'],\n pathParams: z.object({\n id: z.string().uuid(),\n }),\n responses: [\n {\n status: 200,\n description: 'Workflow definition deleted successfully',\n example: {\n message: 'Workflow definition deleted successfully',\n },\n },\n {\n status: 404,\n description: 'Workflow definition not found',\n example: {\n error: 'Workflow definition not found',\n },\n },\n {\n status: 409,\n description: 'Cannot delete - active workflow instances exist',\n example: {\n error: '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