@open-mercato/core 0.9.0 → 0.9.1-develop.7459.1.99e3accd30

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 (243) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/generated/entities/customer_dictionary_entry/index.js +2 -0
  3. package/dist/generated/entities/customer_dictionary_entry/index.js.map +2 -2
  4. package/dist/generated/entities/customer_interaction/index.js +2 -0
  5. package/dist/generated/entities/customer_interaction/index.js.map +2 -2
  6. package/dist/generated/entity-fields-registry.js +2 -0
  7. package/dist/generated/entity-fields-registry.js.map +2 -2
  8. package/dist/modules/catalog/commands/categories.js +1 -1
  9. package/dist/modules/catalog/commands/categories.js.map +2 -2
  10. package/dist/modules/catalog/commands/productDeleteChildren.js +389 -0
  11. package/dist/modules/catalog/commands/productDeleteChildren.js.map +7 -0
  12. package/dist/modules/catalog/commands/products.js +52 -17
  13. package/dist/modules/catalog/commands/products.js.map +2 -2
  14. package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js +4 -6
  15. package/dist/modules/communication_channels/api/post/channels/connect/credentials/route.js.map +2 -2
  16. package/dist/modules/communication_channels/api/post/channels/connect/tenant-credentials/route.js +4 -6
  17. package/dist/modules/communication_channels/api/post/channels/connect/tenant-credentials/route.js.map +2 -2
  18. package/dist/modules/communication_channels/api/post/oauth/[provider]/initiate/route.js +47 -11
  19. package/dist/modules/communication_channels/api/post/oauth/[provider]/initiate/route.js.map +3 -3
  20. package/dist/modules/communication_channels/commands/deliver-outbound-message.js +5 -1
  21. package/dist/modules/communication_channels/commands/deliver-outbound-message.js.map +2 -2
  22. package/dist/modules/communication_channels/lib/inbound-message-origin.js +1 -1
  23. package/dist/modules/communication_channels/lib/inbound-message-origin.js.map +2 -2
  24. package/dist/modules/communication_channels/lib/oauth-state.js +4 -1
  25. package/dist/modules/communication_channels/lib/oauth-state.js.map +2 -2
  26. package/dist/modules/communication_channels/lib/use-connect-channel.js +10 -0
  27. package/dist/modules/communication_channels/lib/use-connect-channel.js.map +2 -2
  28. package/dist/modules/customers/api/activity-types/route.js +151 -0
  29. package/dist/modules/customers/api/activity-types/route.js.map +7 -0
  30. package/dist/modules/customers/api/deals/[id]/people/route.js +58 -5
  31. package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
  32. package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js +13 -5
  33. package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js.map +2 -2
  34. package/dist/modules/customers/api/dictionaries/[kind]/route.js +20 -5
  35. package/dist/modules/customers/api/dictionaries/[kind]/route.js.map +2 -2
  36. package/dist/modules/customers/api/interactions/route.js +3 -0
  37. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  38. package/dist/modules/customers/api/interactions/tasks/route.js +1 -0
  39. package/dist/modules/customers/api/interactions/tasks/route.js.map +2 -2
  40. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.meta.js +18 -0
  41. package/dist/modules/customers/backend/config/customers/pipeline-stages/page.meta.js.map +2 -2
  42. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js +0 -23
  43. package/dist/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.js.map +2 -2
  44. package/dist/modules/customers/backend/customers/deals/[id]/page.js +15 -17
  45. package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
  46. package/dist/modules/customers/calendar-event-types.js +548 -0
  47. package/dist/modules/customers/calendar-event-types.js.map +7 -0
  48. package/dist/modules/customers/commands/dictionaries.js +70 -10
  49. package/dist/modules/customers/commands/dictionaries.js.map +2 -2
  50. package/dist/modules/customers/commands/interactions.js +187 -22
  51. package/dist/modules/customers/commands/interactions.js.map +3 -3
  52. package/dist/modules/customers/components/ActivityTypeEditor.js +288 -0
  53. package/dist/modules/customers/components/ActivityTypeEditor.js.map +7 -0
  54. package/dist/modules/customers/components/DictionarySettings.js +3 -1
  55. package/dist/modules/customers/components/DictionarySettings.js.map +2 -2
  56. package/dist/modules/customers/components/calendar/CalendarEventEditor.js +391 -297
  57. package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +3 -3
  58. package/dist/modules/customers/components/calendar/CalendarSettingsModal.js +9 -74
  59. package/dist/modules/customers/components/calendar/CalendarSettingsModal.js.map +2 -2
  60. package/dist/modules/customers/components/calendar/TimeGrid.js +20 -16
  61. package/dist/modules/customers/components/calendar/TimeGrid.js.map +2 -2
  62. package/dist/modules/customers/components/calendar/editor/EventTypePanel.js +218 -0
  63. package/dist/modules/customers/components/calendar/editor/EventTypePanel.js.map +7 -0
  64. package/dist/modules/customers/components/calendar/editor/LocationField.js +7 -3
  65. package/dist/modules/customers/components/calendar/editor/LocationField.js.map +2 -2
  66. package/dist/modules/customers/components/calendar/editor/PeopleField.js +5 -2
  67. package/dist/modules/customers/components/calendar/editor/PeopleField.js.map +2 -2
  68. package/dist/modules/customers/components/calendar/editor/PriorityField.js +3 -1
  69. package/dist/modules/customers/components/calendar/editor/PriorityField.js.map +2 -2
  70. package/dist/modules/customers/components/calendar/editor/RepeatField.js +9 -1
  71. package/dist/modules/customers/components/calendar/editor/RepeatField.js.map +2 -2
  72. package/dist/modules/customers/components/calendar/editor/ResourcesField.js +4 -1
  73. package/dist/modules/customers/components/calendar/editor/ResourcesField.js.map +2 -2
  74. package/dist/modules/customers/components/calendar/editor/ScheduleSection.js +15 -7
  75. package/dist/modules/customers/components/calendar/editor/ScheduleSection.js.map +2 -2
  76. package/dist/modules/customers/components/calendar/editor/SegmentGroup.js +3 -1
  77. package/dist/modules/customers/components/calendar/editor/SegmentGroup.js.map +2 -2
  78. package/dist/modules/customers/components/calendar/editor/hooks.js +28 -13
  79. package/dist/modules/customers/components/calendar/editor/hooks.js.map +3 -3
  80. package/dist/modules/customers/components/calendar/editor/inputs.js +14 -6
  81. package/dist/modules/customers/components/calendar/editor/inputs.js.map +2 -2
  82. package/dist/modules/customers/components/calendar/editor/useCalendarCustomFields.js +54 -0
  83. package/dist/modules/customers/components/calendar/editor/useCalendarCustomFields.js.map +7 -0
  84. package/dist/modules/customers/components/calendar/editor/useEventTypeCatalog.js +82 -0
  85. package/dist/modules/customers/components/calendar/editor/useEventTypeCatalog.js.map +7 -0
  86. package/dist/modules/customers/components/calendar/types.js +1 -0
  87. package/dist/modules/customers/components/calendar/types.js.map +2 -2
  88. package/dist/modules/customers/components/detail/CompanyPeopleSection.js +78 -343
  89. package/dist/modules/customers/components/detail/CompanyPeopleSection.js.map +2 -2
  90. package/dist/modules/customers/components/detail/CreatePersonDialog.js +12 -11
  91. package/dist/modules/customers/components/detail/CreatePersonDialog.js.map +2 -2
  92. package/dist/modules/customers/components/detail/DealForm.js +7 -3
  93. package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
  94. package/dist/modules/customers/components/detail/DealPeopleSection.js +206 -0
  95. package/dist/modules/customers/components/detail/DealPeopleSection.js.map +7 -0
  96. package/dist/modules/customers/components/detail/LinkedPeopleSection.js +342 -0
  97. package/dist/modules/customers/components/detail/LinkedPeopleSection.js.map +7 -0
  98. package/dist/modules/customers/components/detail/PersonCard.js +5 -2
  99. package/dist/modules/customers/components/detail/PersonCard.js.map +2 -2
  100. package/dist/modules/customers/components/linking/adapters/personAdapter.js +3 -0
  101. package/dist/modules/customers/components/linking/adapters/personAdapter.js.map +2 -2
  102. package/dist/modules/customers/data/entities.js +6 -0
  103. package/dist/modules/customers/data/entities.js.map +2 -2
  104. package/dist/modules/customers/data/validators.js +39 -10
  105. package/dist/modules/customers/data/validators.js.map +2 -2
  106. package/dist/modules/customers/di.js +20 -1
  107. package/dist/modules/customers/di.js.map +2 -2
  108. package/dist/modules/customers/extension-points.js +13 -0
  109. package/dist/modules/customers/extension-points.js.map +2 -2
  110. package/dist/modules/customers/lib/calendar/conflicts.js +59 -16
  111. package/dist/modules/customers/lib/calendar/conflicts.js.map +2 -2
  112. package/dist/modules/customers/lib/calendar/editorPayload.js +34 -16
  113. package/dist/modules/customers/lib/calendar/editorPayload.js.map +2 -2
  114. package/dist/modules/customers/lib/calendar/eventTypeResolver.js +197 -0
  115. package/dist/modules/customers/lib/calendar/eventTypeResolver.js.map +7 -0
  116. package/dist/modules/customers/lib/calendar/interactionApplicability.js +67 -0
  117. package/dist/modules/customers/lib/calendar/interactionApplicability.js.map +7 -0
  118. package/dist/modules/customers/lib/calendar/mapItem.js +5 -2
  119. package/dist/modules/customers/lib/calendar/mapItem.js.map +2 -2
  120. package/dist/modules/customers/lib/calendar/recurrence.js +62 -1
  121. package/dist/modules/customers/lib/calendar/recurrence.js.map +2 -2
  122. package/dist/modules/customers/lib/calendar/timezone.js +111 -0
  123. package/dist/modules/customers/lib/calendar/timezone.js.map +7 -0
  124. package/dist/modules/customers/lib/interactionReadModel.js +1 -0
  125. package/dist/modules/customers/lib/interactionReadModel.js.map +2 -2
  126. package/dist/modules/customers/lib/todoCompatibility.js +1 -0
  127. package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
  128. package/dist/modules/customers/migrations/Migration20260928175058_customers.js +17 -0
  129. package/dist/modules/customers/migrations/Migration20260928175058_customers.js.map +7 -0
  130. package/dist/modules/customers/migrations/Migration20260930110235_customers.js +17 -0
  131. package/dist/modules/customers/migrations/Migration20260930110235_customers.js.map +7 -0
  132. package/dist/modules/dictionaries/components/DictionaryTable.js +60 -51
  133. package/dist/modules/dictionaries/components/DictionaryTable.js.map +2 -2
  134. package/dist/modules/messages/subscribers/message-notification.js +13 -1
  135. package/dist/modules/messages/subscribers/message-notification.js.map +2 -2
  136. package/dist/modules/payment_gateways/api/webhook/[provider]/route.js +201 -53
  137. package/dist/modules/payment_gateways/api/webhook/[provider]/route.js.map +2 -2
  138. package/dist/modules/payment_gateways/lib/gateway-service.js +37 -11
  139. package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
  140. package/dist/modules/planner/lib/availabilityMerge.js +101 -38
  141. package/dist/modules/planner/lib/availabilityMerge.js.map +3 -3
  142. package/dist/modules/planner/services/plannerAvailabilityService.js.map +2 -2
  143. package/dist/modules/sales/components/documents/LineItemDialog.js +159 -81
  144. package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
  145. package/dist/modules/sales/components/documents/lineItemUtils.js +7 -0
  146. package/dist/modules/sales/components/documents/lineItemUtils.js.map +2 -2
  147. package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.js +12 -7
  148. package/dist/modules/staff/backend/staff/time-tracking/projects/[id]/page.js.map +2 -2
  149. package/dist/modules/sync_excel/lib/adapters/customers.js +28 -25
  150. package/dist/modules/sync_excel/lib/adapters/customers.js.map +2 -2
  151. package/generated/entities/customer_dictionary_entry/index.ts +1 -0
  152. package/generated/entities/customer_interaction/index.ts +1 -0
  153. package/generated/entity-fields-registry.ts +2 -0
  154. package/package.json +9 -8
  155. package/src/modules/auth/i18n/de.json +3 -0
  156. package/src/modules/auth/i18n/en.json +3 -0
  157. package/src/modules/auth/i18n/es.json +3 -0
  158. package/src/modules/auth/i18n/ko.json +3 -0
  159. package/src/modules/auth/i18n/pl.json +3 -0
  160. package/src/modules/catalog/commands/categories.ts +1 -1
  161. package/src/modules/catalog/commands/productDeleteChildren.ts +557 -0
  162. package/src/modules/catalog/commands/products.ts +58 -17
  163. package/src/modules/communication_channels/api/post/channels/connect/credentials/route.ts +4 -6
  164. package/src/modules/communication_channels/api/post/channels/connect/tenant-credentials/route.ts +4 -6
  165. package/src/modules/communication_channels/api/post/oauth/[provider]/initiate/route.ts +46 -10
  166. package/src/modules/communication_channels/commands/deliver-outbound-message.ts +6 -1
  167. package/src/modules/communication_channels/i18n/de.json +4 -0
  168. package/src/modules/communication_channels/i18n/en.json +4 -0
  169. package/src/modules/communication_channels/i18n/es.json +4 -0
  170. package/src/modules/communication_channels/i18n/ko.json +4 -0
  171. package/src/modules/communication_channels/i18n/pl.json +4 -0
  172. package/src/modules/communication_channels/lib/inbound-message-origin.ts +2 -6
  173. package/src/modules/communication_channels/lib/oauth-state.ts +4 -1
  174. package/src/modules/communication_channels/lib/use-connect-channel.ts +10 -0
  175. package/src/modules/customers/api/activity-types/route.ts +154 -0
  176. package/src/modules/customers/api/deals/[id]/people/route.ts +82 -3
  177. package/src/modules/customers/api/dictionaries/[kind]/[id]/route.ts +9 -1
  178. package/src/modules/customers/api/dictionaries/[kind]/route.ts +18 -2
  179. package/src/modules/customers/api/interactions/route.ts +4 -0
  180. package/src/modules/customers/api/interactions/tasks/route.ts +1 -0
  181. package/src/modules/customers/backend/config/customers/pipeline-stages/page.meta.ts +20 -0
  182. package/src/modules/customers/backend/customers/deals/[id]/hooks/useDealAssociations.ts +0 -29
  183. package/src/modules/customers/backend/customers/deals/[id]/page.tsx +15 -17
  184. package/src/modules/customers/calendar-event-types.ts +674 -0
  185. package/src/modules/customers/commands/dictionaries.ts +84 -8
  186. package/src/modules/customers/commands/interactions.ts +244 -21
  187. package/src/modules/customers/components/ActivityTypeEditor.tsx +239 -0
  188. package/src/modules/customers/components/DictionarySettings.tsx +5 -3
  189. package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +347 -218
  190. package/src/modules/customers/components/calendar/CalendarSettingsModal.tsx +18 -96
  191. package/src/modules/customers/components/calendar/TimeGrid.tsx +20 -18
  192. package/src/modules/customers/components/calendar/editor/EventTypePanel.tsx +230 -0
  193. package/src/modules/customers/components/calendar/editor/LocationField.tsx +7 -1
  194. package/src/modules/customers/components/calendar/editor/PeopleField.tsx +4 -0
  195. package/src/modules/customers/components/calendar/editor/PriorityField.tsx +3 -0
  196. package/src/modules/customers/components/calendar/editor/RepeatField.tsx +10 -0
  197. package/src/modules/customers/components/calendar/editor/ResourcesField.tsx +4 -0
  198. package/src/modules/customers/components/calendar/editor/ScheduleSection.tsx +16 -4
  199. package/src/modules/customers/components/calendar/editor/SegmentGroup.tsx +3 -0
  200. package/src/modules/customers/components/calendar/editor/hooks.ts +29 -13
  201. package/src/modules/customers/components/calendar/editor/inputs.tsx +17 -5
  202. package/src/modules/customers/components/calendar/editor/useCalendarCustomFields.ts +49 -0
  203. package/src/modules/customers/components/calendar/editor/useEventTypeCatalog.ts +100 -0
  204. package/src/modules/customers/components/calendar/types.ts +1 -0
  205. package/src/modules/customers/components/detail/CompanyPeopleSection.tsx +94 -388
  206. package/src/modules/customers/components/detail/CreatePersonDialog.tsx +39 -19
  207. package/src/modules/customers/components/detail/DealForm.tsx +7 -3
  208. package/src/modules/customers/components/detail/DealPeopleSection.tsx +256 -0
  209. package/src/modules/customers/components/detail/LinkedPeopleSection.tsx +474 -0
  210. package/src/modules/customers/components/detail/PersonCard.tsx +12 -4
  211. package/src/modules/customers/components/detail/types.ts +1 -0
  212. package/src/modules/customers/components/linking/adapters/personAdapter.tsx +4 -0
  213. package/src/modules/customers/data/entities.ts +8 -1
  214. package/src/modules/customers/data/validators.ts +42 -7
  215. package/src/modules/customers/di.ts +21 -0
  216. package/src/modules/customers/extension-points.ts +13 -0
  217. package/src/modules/customers/i18n/de.json +104 -8
  218. package/src/modules/customers/i18n/en.json +104 -8
  219. package/src/modules/customers/i18n/es.json +104 -8
  220. package/src/modules/customers/i18n/ko.json +104 -8
  221. package/src/modules/customers/i18n/pl.json +104 -8
  222. package/src/modules/customers/lib/calendar/conflicts.ts +106 -27
  223. package/src/modules/customers/lib/calendar/editorPayload.ts +39 -19
  224. package/src/modules/customers/lib/calendar/eventTypeResolver.ts +258 -0
  225. package/src/modules/customers/lib/calendar/interactionApplicability.ts +99 -0
  226. package/src/modules/customers/lib/calendar/mapItem.ts +6 -2
  227. package/src/modules/customers/lib/calendar/recurrence.ts +65 -1
  228. package/src/modules/customers/lib/calendar/timezone.ts +117 -0
  229. package/src/modules/customers/lib/interactionReadModel.ts +1 -0
  230. package/src/modules/customers/lib/todoCompatibility.ts +2 -0
  231. package/src/modules/customers/migrations/.snapshot-open-mercato.json +34 -0
  232. package/src/modules/customers/migrations/Migration20260928175058_customers.ts +15 -0
  233. package/src/modules/customers/migrations/Migration20260930110235_customers.ts +15 -0
  234. package/src/modules/dictionaries/components/DictionaryTable.tsx +63 -56
  235. package/src/modules/messages/subscribers/message-notification.ts +13 -3
  236. package/src/modules/payment_gateways/api/webhook/[provider]/route.ts +243 -62
  237. package/src/modules/payment_gateways/lib/gateway-service.ts +39 -12
  238. package/src/modules/planner/lib/availabilityMerge.ts +106 -41
  239. package/src/modules/planner/services/plannerAvailabilityService.ts +4 -0
  240. package/src/modules/sales/components/documents/LineItemDialog.tsx +194 -111
  241. package/src/modules/sales/components/documents/lineItemUtils.ts +18 -0
  242. package/src/modules/staff/backend/staff/time-tracking/projects/[id]/page.tsx +25 -13
  243. package/src/modules/sync_excel/lib/adapters/customers.ts +33 -27
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/catalog/commands/productDeleteChildren.ts"],
4
+ "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { loadCustomFieldSnapshot } from '@open-mercato/shared/lib/commands/customFieldSnapshots'\nimport { setCustomFieldsIfAny } from '@open-mercato/shared/lib/commands/helpers'\nimport type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport type { DataEngine } from '@open-mercato/shared/lib/data/engine'\nimport { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { E } from '#generated/entities.ids.generated'\nimport {\n CatalogOffer,\n CatalogOptionSchemaTemplate,\n CatalogPriceKind,\n CatalogProduct,\n CatalogProductPrice,\n CatalogProductUnitConversion,\n CatalogProductVariant,\n} from '../data/entities'\nimport type { CatalogGtinType, CatalogProductOptionSchema } from '../data/types'\nimport { cloneJson, emitCatalogQueryIndexEvent } from './shared'\n\ntype VariantDimensions = NonNullable<CatalogProductVariant['dimensions']>\n\nexport type ProductDeleteVariantSnapshot = {\n id: string\n productId: string\n name: string | null\n sku: string | null\n barcode: string | null\n gtinType: CatalogGtinType | null\n hsCode: string | null\n statusEntryId: string | null\n isDefault: boolean\n isActive: boolean\n weightValue: string | null\n weightUnit: string | null\n dimensions: VariantDimensions | null\n metadata: Record<string, unknown> | null\n taxRateId: string | null\n taxRate: string | null\n optionValues: Record<string, string> | null\n defaultMediaId: string | null\n defaultMediaUrl: string | null\n customFieldsetCode: string | null\n createdAt: string\n updatedAt: string\n deletedAt: string | null\n custom: Record<string, unknown> | null\n}\n\nexport type ProductDeletePriceSnapshot = {\n id: string\n variantId: string | null\n productId: string | null\n offerId: string | null\n priceKindId: string\n currencyCode: string\n kind: string\n minQuantity: number\n maxQuantity: number | null\n unitPriceNet: string | null\n unitPriceGross: string | null\n taxRate: string | null\n taxAmount: string | null\n channelId: string | null\n userId: string | null\n userGroupId: string | null\n customerId: string | null\n customerGroupId: string | null\n metadata: Record<string, unknown> | null\n startsAt: string | null\n endsAt: string | null\n createdAt: string\n updatedAt: string\n}\n\nexport type ProductDeleteUnitConversionSnapshot = {\n id: string\n productId: string\n unitCode: string\n toBaseFactor: string\n sortOrder: number\n isActive: boolean\n metadata: Record<string, unknown> | null\n createdAt: string\n updatedAt: string\n deletedAt: string | null\n}\n\nexport type ProductDeleteOptionSchemaSnapshot = {\n id: string\n name: string\n code: string\n description: string | null\n schema: CatalogProductOptionSchema\n metadata: Record<string, unknown> | null\n isActive: boolean\n createdAt: string\n updatedAt: string\n deletedAt: string | null\n}\n\nexport type ProductDeleteChildrenSnapshot = {\n variants: ProductDeleteVariantSnapshot[]\n prices: ProductDeletePriceSnapshot[]\n unitConversions: ProductDeleteUnitConversionSnapshot[]\n optionSchemaTemplate: ProductDeleteOptionSchemaSnapshot | null\n}\n\nexport type ProductDeleteOwner = {\n id: string\n organizationId: string\n tenantId: string\n optionSchemaId: string | null\n offerIds: string[]\n}\n\nexport type ProductDeleteChildrenRestorePlan = ProductDeleteChildrenSnapshot\n\ntype EntityRef = { id: string } | string | null | undefined\n\nfunction refId(ref: EntityRef): string | null {\n if (!ref) return null\n return typeof ref === 'string' ? ref : ref.id\n}\n\nfunction toIso(value: Date | null | undefined): string | null {\n return value ? value.toISOString() : null\n}\n\nfunction toDate(value: string | null | undefined): Date | null {\n return value ? new Date(value) : null\n}\n\nexport function isProductOwnedOptionSchemaTemplate(\n template: CatalogOptionSchemaTemplate | string | null | undefined,\n): template is CatalogOptionSchemaTemplate {\n if (!template || typeof template === 'string') return false\n const metadata = template.metadata\n if (!metadata || typeof metadata !== 'object') return false\n const source = (metadata as Record<string, unknown>).source\n return source === 'product'\n}\n\nexport async function captureProductDeleteChildren(\n em: EntityManager,\n owner: Pick<ProductDeleteOwner, 'id' | 'organizationId' | 'tenantId' | 'optionSchemaId'>,\n): Promise<ProductDeleteChildrenSnapshot> {\n const scope = { tenantId: owner.tenantId, organizationId: owner.organizationId }\n const variantRecords = await findWithDecryption(em, CatalogProductVariant, { product: owner.id }, {}, scope)\n const variantIds = variantRecords.map((variant) => variant.id)\n const priceRecords = await findWithDecryption(\n em,\n CatalogProductPrice,\n variantIds.length ? { $or: [{ variant: { $in: variantIds } }, { product: owner.id }] } : { product: owner.id },\n {},\n scope,\n )\n const conversionRecords = await findWithDecryption(em, CatalogProductUnitConversion, { product: owner.id }, {}, scope)\n const template = owner.optionSchemaId\n ? await findOneWithDecryption(em, CatalogOptionSchemaTemplate, { id: owner.optionSchemaId }, {}, scope)\n : null\n const variants: ProductDeleteVariantSnapshot[] = []\n for (const variant of variantRecords) {\n const custom = await loadCustomFieldSnapshot(em, {\n entityId: E.catalog.catalog_product_variant,\n recordId: variant.id,\n tenantId: variant.tenantId,\n organizationId: variant.organizationId,\n })\n variants.push({\n id: variant.id,\n productId: refId(variant.product) ?? owner.id,\n name: variant.name ?? null,\n sku: variant.sku ?? null,\n barcode: variant.barcode ?? null,\n gtinType: variant.gtinType ?? null,\n hsCode: variant.hsCode ?? null,\n statusEntryId: variant.statusEntryId ?? null,\n isDefault: variant.isDefault,\n isActive: variant.isActive,\n weightValue: variant.weightValue ?? null,\n weightUnit: variant.weightUnit ?? null,\n dimensions: variant.dimensions ? cloneJson(variant.dimensions) : null,\n metadata: variant.metadata ? cloneJson(variant.metadata) : null,\n taxRateId: variant.taxRateId ?? null,\n taxRate: variant.taxRate ?? null,\n optionValues: variant.optionValues ? cloneJson(variant.optionValues) : null,\n defaultMediaId: variant.defaultMediaId ?? null,\n defaultMediaUrl: variant.defaultMediaUrl ?? null,\n customFieldsetCode: variant.customFieldsetCode ?? null,\n createdAt: variant.createdAt.toISOString(),\n updatedAt: variant.updatedAt.toISOString(),\n deletedAt: toIso(variant.deletedAt),\n custom: Object.keys(custom).length ? custom : null,\n })\n }\n const prices: ProductDeletePriceSnapshot[] = []\n for (const price of priceRecords) {\n const priceKindId = refId(price.priceKind)\n if (!priceKindId) throw new Error(`[internal] Catalog price ${price.id} has no price kind`)\n prices.push({\n id: price.id,\n variantId: refId(price.variant),\n productId: refId(price.product),\n offerId: refId(price.offer),\n priceKindId,\n currencyCode: price.currencyCode,\n kind: price.kind,\n minQuantity: price.minQuantity,\n maxQuantity: price.maxQuantity ?? null,\n unitPriceNet: price.unitPriceNet ?? null,\n unitPriceGross: price.unitPriceGross ?? null,\n taxRate: price.taxRate ?? null,\n taxAmount: price.taxAmount ?? null,\n channelId: price.channelId ?? null,\n userId: price.userId ?? null,\n userGroupId: price.userGroupId ?? null,\n customerId: price.customerId ?? null,\n customerGroupId: price.customerGroupId ?? null,\n metadata: price.metadata ? cloneJson(price.metadata) : null,\n startsAt: toIso(price.startsAt),\n endsAt: toIso(price.endsAt),\n createdAt: price.createdAt.toISOString(),\n updatedAt: price.updatedAt.toISOString(),\n })\n }\n const unitConversions: ProductDeleteUnitConversionSnapshot[] = conversionRecords.map((conversion) => ({\n id: conversion.id,\n productId: refId(conversion.product) ?? owner.id,\n unitCode: conversion.unitCode,\n toBaseFactor: conversion.toBaseFactor,\n sortOrder: conversion.sortOrder,\n isActive: conversion.isActive,\n metadata: conversion.metadata ? cloneJson(conversion.metadata) : null,\n createdAt: conversion.createdAt.toISOString(),\n updatedAt: conversion.updatedAt.toISOString(),\n deletedAt: toIso(conversion.deletedAt),\n }))\n return {\n variants,\n prices,\n unitConversions,\n optionSchemaTemplate: isProductOwnedOptionSchemaTemplate(template)\n ? {\n id: template.id,\n name: template.name,\n code: template.code,\n description: template.description ?? null,\n schema: cloneJson(template.schema),\n metadata: template.metadata ? cloneJson(template.metadata) : null,\n isActive: template.isActive,\n createdAt: template.createdAt.toISOString(),\n updatedAt: template.updatedAt.toISOString(),\n deletedAt: toIso(template.deletedAt),\n }\n : null,\n }\n}\n\nfunction restoreConflict(kind: string, id: string): Error {\n return new Error(`[internal] Cannot restore catalog product ${kind} ${id}: it does not belong to the restored product`)\n}\n\nfunction sameScope(row: { tenantId: string; organizationId: string }, owner: ProductDeleteOwner): boolean {\n return row.tenantId === owner.tenantId && row.organizationId === owner.organizationId\n}\n\nfunction asList<T>(value: T[] | null | undefined): T[] {\n return Array.isArray(value) ? value : []\n}\n\nexport async function planProductDeleteChildrenRestore(\n em: EntityManager,\n owner: ProductDeleteOwner,\n children: ProductDeleteChildrenSnapshot | null | undefined,\n): Promise<ProductDeleteChildrenRestorePlan | null> {\n if (!children) return null\n const scope = { tenantId: owner.tenantId, organizationId: owner.organizationId }\n const variantSnapshots = asList(children.variants)\n const priceSnapshots = asList(children.prices)\n const conversionSnapshots = asList(children.unitConversions)\n const templateSnapshot =\n children.optionSchemaTemplate && children.optionSchemaTemplate.id === owner.optionSchemaId\n ? children.optionSchemaTemplate\n : null\n const ownVariantIds = new Set(variantSnapshots.map((variant) => variant.id))\n const offerIds = new Set(owner.offerIds)\n\n const priceOwned = (price: { variantId: string | null; productId: string | null }) =>\n (price.variantId !== null && ownVariantIds.has(price.variantId)) || price.productId === owner.id\n\n for (const variant of variantSnapshots) {\n if (variant.productId !== owner.id) throw restoreConflict('variant', variant.id)\n }\n for (const conversion of conversionSnapshots) {\n if (conversion.productId !== owner.id) throw restoreConflict('unit conversion', conversion.id)\n }\n for (const price of priceSnapshots) {\n if (!priceOwned(price)) throw restoreConflict('price', price.id)\n }\n\n const foreignVariantIds = new Set<string>()\n const foreignProductIds = new Set<string>()\n const trackVariant = (id: string | null) => {\n if (id && !ownVariantIds.has(id)) foreignVariantIds.add(id)\n }\n const trackProduct = (id: string | null) => {\n if (id && id !== owner.id) foreignProductIds.add(id)\n }\n for (const price of priceSnapshots) {\n trackVariant(price.variantId)\n trackProduct(price.productId)\n }\n\n const existingVariants = variantSnapshots.length\n ? await findWithDecryption(em, CatalogProductVariant, { id: { $in: variantSnapshots.map((entry) => entry.id) } }, {}, scope)\n : []\n const existingPrices = priceSnapshots.length\n ? await findWithDecryption(em, CatalogProductPrice, { id: { $in: priceSnapshots.map((entry) => entry.id) } }, {}, scope)\n : []\n const existingConversions = conversionSnapshots.length\n ? await findWithDecryption(\n em,\n CatalogProductUnitConversion,\n { id: { $in: conversionSnapshots.map((entry) => entry.id) } },\n {},\n scope,\n )\n : []\n const existingTemplate = templateSnapshot\n ? await findOneWithDecryption(em, CatalogOptionSchemaTemplate, { id: templateSnapshot.id }, {}, scope)\n : null\n const foreignVariants = foreignVariantIds.size\n ? await findWithDecryption(\n em,\n CatalogProductVariant,\n { id: { $in: Array.from(foreignVariantIds) }, tenantId: owner.tenantId, organizationId: owner.organizationId },\n {},\n scope,\n )\n : []\n const foreignProducts = foreignProductIds.size\n ? await findWithDecryption(\n em,\n CatalogProduct,\n { id: { $in: Array.from(foreignProductIds) }, tenantId: owner.tenantId, organizationId: owner.organizationId },\n {},\n scope,\n )\n : []\n\n for (const variant of existingVariants) {\n if (!sameScope(variant, owner) || refId(variant.product) !== owner.id) throw restoreConflict('variant', variant.id)\n }\n for (const conversion of existingConversions) {\n if (!sameScope(conversion, owner) || refId(conversion.product) !== owner.id) {\n throw restoreConflict('unit conversion', conversion.id)\n }\n }\n for (const price of existingPrices) {\n if (!sameScope(price, owner) || !priceOwned({ variantId: refId(price.variant), productId: refId(price.product) })) {\n throw restoreConflict('price', price.id)\n }\n }\n if (existingTemplate && !sameScope(existingTemplate, owner)) {\n throw restoreConflict('option schema', existingTemplate.id)\n }\n\n const existingVariantIds = new Set(existingVariants.map((entry) => entry.id))\n const existingPriceIds = new Set(existingPrices.map((entry) => entry.id))\n const existingConversionIds = new Set(existingConversions.map((entry) => entry.id))\n const availableForeignVariantIds = new Set(foreignVariants.map((entry) => entry.id))\n const availableForeignProductIds = new Set(foreignProducts.map((entry) => entry.id))\n const variantAvailable = (id: string | null) =>\n id === null || ownVariantIds.has(id) || availableForeignVariantIds.has(id)\n const productAvailable = (id: string | null) =>\n id === null || id === owner.id || availableForeignProductIds.has(id)\n\n return {\n optionSchemaTemplate: templateSnapshot && !existingTemplate ? templateSnapshot : null,\n unitConversions: conversionSnapshots.filter((entry) => !existingConversionIds.has(entry.id)),\n variants: variantSnapshots.filter((entry) => !existingVariantIds.has(entry.id)),\n prices: priceSnapshots\n .filter(\n (entry) =>\n !existingPriceIds.has(entry.id) && variantAvailable(entry.variantId) && productAvailable(entry.productId),\n )\n .map((entry) => ({ ...entry, offerId: entry.offerId && offerIds.has(entry.offerId) ? entry.offerId : null })),\n }\n}\n\nexport function restoreProductOptionSchemaTemplate(\n em: EntityManager,\n owner: ProductDeleteOwner,\n plan: ProductDeleteChildrenRestorePlan | null,\n): void {\n const snapshot = plan?.optionSchemaTemplate\n if (!snapshot) return\n const template = em.create(CatalogOptionSchemaTemplate, {\n id: snapshot.id,\n organizationId: owner.organizationId,\n tenantId: owner.tenantId,\n name: snapshot.name,\n code: snapshot.code,\n description: snapshot.description ?? null,\n schema: cloneJson(snapshot.schema),\n metadata: snapshot.metadata ? cloneJson(snapshot.metadata) : null,\n isActive: snapshot.isActive,\n createdAt: new Date(snapshot.createdAt),\n updatedAt: new Date(snapshot.updatedAt),\n deletedAt: toDate(snapshot.deletedAt),\n })\n em.persist(template)\n}\n\n/**\n * Child rows are created on a fork that shares the undo transaction instead of on the\n * EntityManager holding the restored product: the tenant encryption subscriber walks the\n * loaded graph of every created entity, which is quadratic once a product has hundreds of\n * prices attached to already-managed variants.\n */\nexport function buildProductDeleteChildrenRestorePhases(\n em: EntityManager,\n owner: ProductDeleteOwner,\n plan: ProductDeleteChildrenRestorePlan | null,\n): Array<() => Promise<void>> {\n if (!plan) return []\n const scope = { organizationId: owner.organizationId, tenantId: owner.tenantId }\n let childEm: EntityManager | null = null\n const resolveChildEm = (): EntityManager => {\n childEm ??= em.fork({ keepTransactionContext: true })\n return childEm\n }\n return [\n async () => {\n const target = resolveChildEm()\n for (const snapshot of plan.unitConversions) {\n target.persist(\n target.create(CatalogProductUnitConversion, {\n id: snapshot.id,\n ...scope,\n product: target.getReference(CatalogProduct, snapshot.productId),\n unitCode: snapshot.unitCode,\n toBaseFactor: snapshot.toBaseFactor,\n sortOrder: snapshot.sortOrder,\n isActive: snapshot.isActive,\n metadata: snapshot.metadata ? cloneJson(snapshot.metadata) : null,\n createdAt: new Date(snapshot.createdAt),\n updatedAt: new Date(snapshot.updatedAt),\n deletedAt: toDate(snapshot.deletedAt),\n }),\n )\n }\n await target.flush()\n },\n async () => {\n const target = resolveChildEm()\n for (const snapshot of plan.variants) {\n target.persist(\n target.create(CatalogProductVariant, {\n id: snapshot.id,\n ...scope,\n product: target.getReference(CatalogProduct, snapshot.productId),\n name: snapshot.name ?? null,\n sku: snapshot.sku ?? null,\n barcode: snapshot.barcode ?? null,\n gtinType: snapshot.gtinType ?? null,\n hsCode: snapshot.hsCode ?? null,\n statusEntryId: snapshot.statusEntryId ?? null,\n isDefault: snapshot.isDefault,\n isActive: snapshot.isActive,\n weightValue: snapshot.weightValue ?? null,\n weightUnit: snapshot.weightUnit ?? null,\n dimensions: snapshot.dimensions ? cloneJson(snapshot.dimensions) : null,\n metadata: snapshot.metadata ? cloneJson(snapshot.metadata) : null,\n taxRateId: snapshot.taxRateId ?? null,\n taxRate: snapshot.taxRate ?? null,\n optionValues: snapshot.optionValues ? cloneJson(snapshot.optionValues) : null,\n defaultMediaId: snapshot.defaultMediaId ?? null,\n defaultMediaUrl: snapshot.defaultMediaUrl ?? null,\n customFieldsetCode: snapshot.customFieldsetCode ?? null,\n createdAt: new Date(snapshot.createdAt),\n updatedAt: new Date(snapshot.updatedAt),\n deletedAt: toDate(snapshot.deletedAt),\n }),\n )\n }\n await target.flush()\n },\n async () => {\n const target = resolveChildEm()\n for (const snapshot of plan.prices) {\n target.persist(\n target.create(CatalogProductPrice, {\n id: snapshot.id,\n ...scope,\n variant: snapshot.variantId ? target.getReference(CatalogProductVariant, snapshot.variantId) : null,\n product: snapshot.productId ? target.getReference(CatalogProduct, snapshot.productId) : null,\n offer: snapshot.offerId ? target.getReference(CatalogOffer, snapshot.offerId) : null,\n priceKind: target.getReference(CatalogPriceKind, snapshot.priceKindId),\n currencyCode: snapshot.currencyCode,\n kind: snapshot.kind,\n minQuantity: snapshot.minQuantity,\n maxQuantity: snapshot.maxQuantity ?? null,\n unitPriceNet: snapshot.unitPriceNet ?? null,\n unitPriceGross: snapshot.unitPriceGross ?? null,\n taxRate: snapshot.taxRate ?? null,\n taxAmount: snapshot.taxAmount ?? null,\n channelId: snapshot.channelId ?? null,\n userId: snapshot.userId ?? null,\n userGroupId: snapshot.userGroupId ?? null,\n customerId: snapshot.customerId ?? null,\n customerGroupId: snapshot.customerGroupId ?? null,\n metadata: snapshot.metadata ? cloneJson(snapshot.metadata) : null,\n startsAt: toDate(snapshot.startsAt),\n endsAt: toDate(snapshot.endsAt),\n createdAt: new Date(snapshot.createdAt),\n updatedAt: new Date(snapshot.updatedAt),\n }),\n )\n }\n await target.flush()\n },\n ]\n}\n\nexport async function emitProductDeleteChildrenRestoreSideEffects(opts: {\n ctx: CommandRuntimeContext\n dataEngine: DataEngine\n owner: ProductDeleteOwner\n children: ProductDeleteChildrenSnapshot | null | undefined\n plan: ProductDeleteChildrenRestorePlan | null\n}): Promise<void> {\n const { ctx, dataEngine, owner, children, plan } = opts\n const variants = asList(children?.variants)\n const createdVariantIds = new Set(asList(plan?.variants).map((variant) => variant.id))\n for (const variant of variants) {\n if (!variant.custom || !Object.keys(variant.custom).length) continue\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.catalog.catalog_product_variant,\n recordId: variant.id,\n organizationId: owner.organizationId,\n tenantId: owner.tenantId,\n values: variant.custom,\n })\n }\n for (const variant of variants) {\n await emitCatalogQueryIndexEvent(ctx, {\n entityType: E.catalog.catalog_product_variant,\n recordId: variant.id,\n organizationId: owner.organizationId,\n tenantId: owner.tenantId,\n action: 'created',\n ...(createdVariantIds.has(variant.id) ? {} : { coverageBaseDelta: 0 }),\n })\n }\n}\n"],
5
+ "mappings": "AACA,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AAGrC,SAAS,uBAAuB,0BAA0B;AAC1D,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,WAAW,kCAAkC;AAsGtD,SAAS,MAAM,KAA+B;AAC5C,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,OAAO,QAAQ,WAAW,MAAM,IAAI;AAC7C;AAEA,SAAS,MAAM,OAA+C;AAC5D,SAAO,QAAQ,MAAM,YAAY,IAAI;AACvC;AAEA,SAAS,OAAO,OAA+C;AAC7D,SAAO,QAAQ,IAAI,KAAK,KAAK,IAAI;AACnC;AAEO,SAAS,mCACd,UACyC;AACzC,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU,QAAO;AACtD,QAAM,WAAW,SAAS;AAC1B,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU,QAAO;AACtD,QAAM,SAAU,SAAqC;AACrD,SAAO,WAAW;AACpB;AAEA,eAAsB,6BACpB,IACA,OACwC;AACxC,QAAM,QAAQ,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe;AAC/E,QAAM,iBAAiB,MAAM,mBAAmB,IAAI,uBAAuB,EAAE,SAAS,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK;AAC3G,QAAM,aAAa,eAAe,IAAI,CAAC,YAAY,QAAQ,EAAE;AAC7D,QAAM,eAAe,MAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA,WAAW,SAAS,EAAE,K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,SAAS,SAAS;AAAA,UACxC,CAAC;AAAA,QACH;AAAA,MACF;AACA,YAAM,OAAO,MAAM;AAAA,IACrB;AAAA,EACF;AACF;AAEA,eAAsB,4CAA4C,MAMhD;AAChB,QAAM,EAAE,KAAK,YAAY,OAAO,UAAU,KAAK,IAAI;AACnD,QAAM,WAAW,OAAO,UAAU,QAAQ;AAC1C,QAAM,oBAAoB,IAAI,IAAI,OAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,YAAY,QAAQ,EAAE,CAAC;AACrF,aAAW,WAAW,UAAU;AAC9B,QAAI,CAAC,QAAQ,UAAU,CAAC,OAAO,KAAK,QAAQ,MAAM,EAAE,OAAQ;AAC5D,UAAM,qBAAqB;AAAA,MACzB;AAAA,MACA,UAAU,EAAE,QAAQ;AAAA,MACpB,UAAU,QAAQ;AAAA,MAClB,gBAAgB,MAAM;AAAA,MACtB,UAAU,MAAM;AAAA,MAChB,QAAQ,QAAQ;AAAA,IAClB,CAAC;AAAA,EACH;AACA,aAAW,WAAW,UAAU;AAC9B,UAAM,2BAA2B,KAAK;AAAA,MACpC,YAAY,EAAE,QAAQ;AAAA,MACtB,UAAU,QAAQ;AAAA,MAClB,gBAAgB,MAAM;AAAA,MACtB,UAAU,MAAM;AAAA,MAChB,QAAQ;AAAA,MACR,GAAI,kBAAkB,IAAI,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,EAAE;AAAA,IACtE,CAAC;AAAA,EACH;AACF;",
6
+ "names": []
7
+ }
@@ -56,6 +56,14 @@ import {
56
56
  findWithDecryption,
57
57
  findOneWithDecryption
58
58
  } from "@open-mercato/shared/lib/encryption/find";
59
+ import {
60
+ buildProductDeleteChildrenRestorePhases,
61
+ captureProductDeleteChildren,
62
+ emitProductDeleteChildrenRestoreSideEffects,
63
+ isProductOwnedOptionSchemaTemplate,
64
+ planProductDeleteChildrenRestore,
65
+ restoreProductOptionSchemaTemplate
66
+ } from "./productDeleteChildren.js";
59
67
  import { canonicalizeUnitCode } from "../lib/unitCodes.js";
60
68
  import {
61
69
  resolveCanonicalUnitCode
@@ -119,6 +127,13 @@ function resolveUnitPriceInput(parsed) {
119
127
  baseProvided
120
128
  };
121
129
  }
130
+ const PRODUCT_DELETE_CACHE_ALIASES = [
131
+ "catalog.product",
132
+ "catalog.variant",
133
+ "catalog.price",
134
+ "catalog.product.unit.conversion",
135
+ "catalog.optionschema"
136
+ ];
122
137
  const productCrudEvents = {
123
138
  module: "catalog",
124
139
  entity: "product",
@@ -695,13 +710,6 @@ async function emitProductVariantCleanupSideEffects(opts) {
695
710
  });
696
711
  }
697
712
  }
698
- function isProductOwnedOptionSchemaTemplate(template) {
699
- if (!template || typeof template === "string") return false;
700
- const metadata = template.metadata;
701
- if (!metadata || typeof metadata !== "object") return false;
702
- const source = metadata.source;
703
- return source === "product";
704
- }
705
713
  async function resolveOptionSchemaTemplateForRemoval(em, product) {
706
714
  const template = product.optionSchemaTemplate;
707
715
  if (!isProductOwnedOptionSchemaTemplate(template)) {
@@ -1663,11 +1671,14 @@ const deleteProductCommand = {
1663
1671
  const id = requireId(input, "Product id is required");
1664
1672
  const em = ctx.container.resolve("em");
1665
1673
  const snapshot = await loadProductSnapshot(em, id);
1666
- if (snapshot) {
1667
- ensureTenantScope(ctx, snapshot.tenantId);
1668
- ensureOrganizationScope(ctx, snapshot.organizationId);
1669
- }
1670
- return snapshot ? { before: snapshot } : {};
1674
+ if (!snapshot) return {};
1675
+ ensureTenantScope(ctx, snapshot.tenantId);
1676
+ ensureOrganizationScope(ctx, snapshot.organizationId);
1677
+ const snapshots = {
1678
+ before: snapshot,
1679
+ children: await captureProductDeleteChildren(em.fork(), snapshot)
1680
+ };
1681
+ return snapshots;
1671
1682
  },
1672
1683
  async execute(input, ctx) {
1673
1684
  const id = requireId(input, "Product id is required");
@@ -1760,17 +1771,35 @@ const deleteProductCommand = {
1760
1771
  snapshotBefore: before,
1761
1772
  payload: {
1762
1773
  undo: {
1763
- before
1774
+ before,
1775
+ children: snapshots.children ?? null
1764
1776
  }
1765
- }
1777
+ },
1778
+ context: { cacheAliases: [...PRODUCT_DELETE_CACHE_ALIASES] }
1766
1779
  };
1767
1780
  },
1768
1781
  undo: async ({ logEntry, ctx }) => {
1769
1782
  const payload = extractUndoPayload(logEntry);
1770
1783
  const before = payload?.before;
1771
1784
  if (!before) return;
1785
+ ensureTenantScope(ctx, before.tenantId);
1786
+ ensureOrganizationScope(ctx, before.organizationId);
1772
1787
  const em = ctx.container.resolve("em").fork();
1788
+ const children = payload?.children ?? null;
1789
+ const owner = {
1790
+ id: before.id,
1791
+ organizationId: before.organizationId,
1792
+ tenantId: before.tenantId,
1793
+ optionSchemaId: before.optionSchemaId ?? null,
1794
+ offerIds: (before.offers ?? []).map((offer) => offer.id)
1795
+ };
1773
1796
  let record = await findOneWithDecryption(em, CatalogProduct, { id: before.id });
1797
+ const childrenPlan = await planProductDeleteChildrenRestore(
1798
+ em,
1799
+ owner,
1800
+ children
1801
+ );
1802
+ restoreProductOptionSchemaTemplate(em, owner, childrenPlan);
1774
1803
  if (!record) {
1775
1804
  record = em.create(CatalogProduct, {
1776
1805
  id: before.id,
@@ -1807,8 +1836,6 @@ const deleteProductCommand = {
1807
1836
  });
1808
1837
  em.persist(record);
1809
1838
  }
1810
- ensureTenantScope(ctx, before.tenantId);
1811
- ensureOrganizationScope(ctx, before.organizationId);
1812
1839
  applyProductSnapshot(em, record, before);
1813
1840
  await withAtomicFlush(
1814
1841
  em,
@@ -1816,7 +1843,8 @@ const deleteProductCommand = {
1816
1843
  () => em.flush(),
1817
1844
  () => restoreOffersFromSnapshot(em, record, before.offers),
1818
1845
  () => syncCategoryAssignments(em, record, before.categoryIds),
1819
- () => syncProductTags(em, record, before.tags)
1846
+ () => syncProductTags(em, record, before.tags),
1847
+ ...buildProductDeleteChildrenRestorePhases(em, owner, childrenPlan)
1820
1848
  ],
1821
1849
  { transaction: true }
1822
1850
  );
@@ -1831,6 +1859,13 @@ const deleteProductCommand = {
1831
1859
  values: before.custom
1832
1860
  });
1833
1861
  }
1862
+ await emitProductDeleteChildrenRestoreSideEffects({
1863
+ ctx,
1864
+ dataEngine,
1865
+ owner,
1866
+ children,
1867
+ plan: childrenPlan
1868
+ });
1834
1869
  await emitProductCrudUndoChange({
1835
1870
  dataEngine,
1836
1871
  action: "created",