@open-mercato/core 0.4.2-canary-07dbc98202 → 0.4.2-canary-11e19dfb84

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 (235) hide show
  1. package/dist/generated/entities.ids.generated.js +59 -63
  2. package/dist/generated/entities.ids.generated.js.map +2 -2
  3. package/dist/generated/entity-fields-registry.js +0 -2
  4. package/dist/generated/entity-fields-registry.js.map +2 -2
  5. package/dist/modules/api_docs/frontend/docs/api/page.js +2 -3
  6. package/dist/modules/api_docs/frontend/docs/api/page.js.map +2 -2
  7. package/dist/modules/auth/api/admin/nav.js +3 -4
  8. package/dist/modules/auth/api/admin/nav.js.map +2 -2
  9. package/dist/modules/auth/api/reset/confirm.js +2 -25
  10. package/dist/modules/auth/api/reset/confirm.js.map +2 -2
  11. package/dist/modules/auth/api/reset.js +0 -23
  12. package/dist/modules/auth/api/reset.js.map +2 -2
  13. package/dist/modules/auth/api/sidebar/preferences/route.js +9 -14
  14. package/dist/modules/auth/api/sidebar/preferences/route.js.map +2 -2
  15. package/dist/modules/auth/commands/users.js +0 -55
  16. package/dist/modules/auth/commands/users.js.map +2 -2
  17. package/dist/modules/auth/lib/setup-app.js +0 -1
  18. package/dist/modules/auth/lib/setup-app.js.map +2 -2
  19. package/dist/modules/auth/services/authService.js +3 -3
  20. package/dist/modules/auth/services/authService.js.map +2 -2
  21. package/dist/modules/configs/cli.js +0 -6
  22. package/dist/modules/configs/cli.js.map +2 -2
  23. package/dist/modules/customers/commands/deals.js +0 -31
  24. package/dist/modules/customers/commands/deals.js.map +2 -2
  25. package/dist/modules/sales/commands/documents.js +0 -53
  26. package/dist/modules/sales/commands/documents.js.map +2 -2
  27. package/dist/modules/sales/commands/payments.js +0 -26
  28. package/dist/modules/sales/commands/payments.js.map +2 -2
  29. package/dist/modules/staff/commands/leave-requests.js +0 -79
  30. package/dist/modules/staff/commands/leave-requests.js.map +2 -2
  31. package/generated/entities.ids.generated.ts +59 -63
  32. package/generated/entity-fields-registry.ts +0 -2
  33. package/package.json +2 -2
  34. package/src/modules/api_docs/frontend/docs/api/page.tsx +2 -3
  35. package/src/modules/auth/api/admin/nav.ts +6 -10
  36. package/src/modules/auth/api/reset/confirm.ts +2 -25
  37. package/src/modules/auth/api/reset.ts +0 -23
  38. package/src/modules/auth/api/sidebar/preferences/route.ts +12 -21
  39. package/src/modules/auth/commands/users.ts +0 -68
  40. package/src/modules/auth/i18n/de.json +1 -29
  41. package/src/modules/auth/i18n/en.json +1 -29
  42. package/src/modules/auth/i18n/es.json +1 -29
  43. package/src/modules/auth/i18n/pl.json +1 -29
  44. package/src/modules/auth/lib/setup-app.ts +0 -1
  45. package/src/modules/auth/services/authService.ts +4 -4
  46. package/src/modules/business_rules/i18n/en.json +1 -3
  47. package/src/modules/catalog/i18n/en.json +1 -3
  48. package/src/modules/configs/cli.ts +0 -6
  49. package/src/modules/customers/commands/deals.ts +0 -39
  50. package/src/modules/customers/i18n/en.json +1 -5
  51. package/src/modules/sales/commands/documents.ts +0 -65
  52. package/src/modules/sales/commands/payments.ts +0 -33
  53. package/src/modules/sales/i18n/de.json +0 -20
  54. package/src/modules/sales/i18n/en.json +1 -25
  55. package/src/modules/sales/i18n/es.json +0 -20
  56. package/src/modules/sales/i18n/pl.json +0 -20
  57. package/src/modules/staff/commands/leave-requests.ts +0 -94
  58. package/src/modules/staff/i18n/de.json +0 -4
  59. package/src/modules/staff/i18n/en.json +1 -9
  60. package/src/modules/staff/i18n/es.json +0 -4
  61. package/src/modules/staff/i18n/pl.json +0 -4
  62. package/src/modules/workflows/i18n/en.json +1 -3
  63. package/dist/generated/entities/notification/index.js +0 -57
  64. package/dist/generated/entities/notification/index.js.map +0 -7
  65. package/dist/modules/auth/api/profile/route.js +0 -155
  66. package/dist/modules/auth/api/profile/route.js.map +0 -7
  67. package/dist/modules/auth/backend/auth/profile/page.js +0 -99
  68. package/dist/modules/auth/backend/auth/profile/page.js.map +0 -7
  69. package/dist/modules/auth/backend/auth/profile/page.meta.js +0 -12
  70. package/dist/modules/auth/backend/auth/profile/page.meta.js.map +0 -7
  71. package/dist/modules/auth/notifications.js +0 -112
  72. package/dist/modules/auth/notifications.js.map +0 -7
  73. package/dist/modules/business_rules/notifications.js +0 -28
  74. package/dist/modules/business_rules/notifications.js.map +0 -7
  75. package/dist/modules/business_rules/subscribers/rule-execution-failed-notification.js +0 -37
  76. package/dist/modules/business_rules/subscribers/rule-execution-failed-notification.js.map +0 -7
  77. package/dist/modules/catalog/notifications.js +0 -28
  78. package/dist/modules/catalog/notifications.js.map +0 -7
  79. package/dist/modules/catalog/subscribers/low-stock-notification.js +0 -38
  80. package/dist/modules/catalog/subscribers/low-stock-notification.js.map +0 -7
  81. package/dist/modules/customers/notifications.js +0 -48
  82. package/dist/modules/customers/notifications.js.map +0 -7
  83. package/dist/modules/notifications/acl.js +0 -11
  84. package/dist/modules/notifications/acl.js.map +0 -7
  85. package/dist/modules/notifications/api/[id]/action/route.js +0 -74
  86. package/dist/modules/notifications/api/[id]/action/route.js.map +0 -7
  87. package/dist/modules/notifications/api/[id]/dismiss/route.js +0 -15
  88. package/dist/modules/notifications/api/[id]/dismiss/route.js.map +0 -7
  89. package/dist/modules/notifications/api/[id]/read/route.js +0 -15
  90. package/dist/modules/notifications/api/[id]/read/route.js.map +0 -7
  91. package/dist/modules/notifications/api/[id]/restore/route.js +0 -53
  92. package/dist/modules/notifications/api/[id]/restore/route.js.map +0 -7
  93. package/dist/modules/notifications/api/batch/route.js +0 -17
  94. package/dist/modules/notifications/api/batch/route.js.map +0 -7
  95. package/dist/modules/notifications/api/feature/route.js +0 -17
  96. package/dist/modules/notifications/api/feature/route.js.map +0 -7
  97. package/dist/modules/notifications/api/mark-all-read/route.js +0 -35
  98. package/dist/modules/notifications/api/mark-all-read/route.js.map +0 -7
  99. package/dist/modules/notifications/api/openapi.js +0 -76
  100. package/dist/modules/notifications/api/openapi.js.map +0 -7
  101. package/dist/modules/notifications/api/role/route.js +0 -17
  102. package/dist/modules/notifications/api/role/route.js.map +0 -7
  103. package/dist/modules/notifications/api/route.js +0 -85
  104. package/dist/modules/notifications/api/route.js.map +0 -7
  105. package/dist/modules/notifications/api/settings/route.js +0 -155
  106. package/dist/modules/notifications/api/settings/route.js.map +0 -7
  107. package/dist/modules/notifications/api/unread-count/route.js +0 -38
  108. package/dist/modules/notifications/api/unread-count/route.js.map +0 -7
  109. package/dist/modules/notifications/backend/config/notifications/page.js +0 -10
  110. package/dist/modules/notifications/backend/config/notifications/page.js.map +0 -7
  111. package/dist/modules/notifications/backend/config/notifications/page.meta.js +0 -24
  112. package/dist/modules/notifications/backend/config/notifications/page.meta.js.map +0 -7
  113. package/dist/modules/notifications/cli.js +0 -16
  114. package/dist/modules/notifications/cli.js.map +0 -7
  115. package/dist/modules/notifications/data/entities.js +0 -112
  116. package/dist/modules/notifications/data/entities.js.map +0 -7
  117. package/dist/modules/notifications/data/validators.js +0 -94
  118. package/dist/modules/notifications/data/validators.js.map +0 -7
  119. package/dist/modules/notifications/di.js +0 -13
  120. package/dist/modules/notifications/di.js.map +0 -7
  121. package/dist/modules/notifications/emails/NotificationEmail.js +0 -58
  122. package/dist/modules/notifications/emails/NotificationEmail.js.map +0 -7
  123. package/dist/modules/notifications/frontend/NotificationInboxPageClient.js +0 -44
  124. package/dist/modules/notifications/frontend/NotificationInboxPageClient.js.map +0 -7
  125. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js +0 -219
  126. package/dist/modules/notifications/frontend/NotificationSettingsPageClient.js.map +0 -7
  127. package/dist/modules/notifications/index.js +0 -14
  128. package/dist/modules/notifications/index.js.map +0 -7
  129. package/dist/modules/notifications/lib/deliveryConfig.js +0 -105
  130. package/dist/modules/notifications/lib/deliveryConfig.js.map +0 -7
  131. package/dist/modules/notifications/lib/events.js +0 -12
  132. package/dist/modules/notifications/lib/events.js.map +0 -7
  133. package/dist/modules/notifications/lib/notificationBuilder.js +0 -66
  134. package/dist/modules/notifications/lib/notificationBuilder.js.map +0 -7
  135. package/dist/modules/notifications/lib/notificationFactory.js +0 -54
  136. package/dist/modules/notifications/lib/notificationFactory.js.map +0 -7
  137. package/dist/modules/notifications/lib/notificationMapper.js +0 -34
  138. package/dist/modules/notifications/lib/notificationMapper.js.map +0 -7
  139. package/dist/modules/notifications/lib/notificationRecipients.js +0 -35
  140. package/dist/modules/notifications/lib/notificationRecipients.js.map +0 -7
  141. package/dist/modules/notifications/lib/notificationService.js +0 -279
  142. package/dist/modules/notifications/lib/notificationService.js.map +0 -7
  143. package/dist/modules/notifications/lib/routeHelpers.js +0 -101
  144. package/dist/modules/notifications/lib/routeHelpers.js.map +0 -7
  145. package/dist/modules/notifications/lib/safeHref.js +0 -24
  146. package/dist/modules/notifications/lib/safeHref.js.map +0 -7
  147. package/dist/modules/notifications/migrations/Migration20260123000001.js +0 -70
  148. package/dist/modules/notifications/migrations/Migration20260123000001.js.map +0 -7
  149. package/dist/modules/notifications/migrations/Migration20260126150000.js +0 -37
  150. package/dist/modules/notifications/migrations/Migration20260126150000.js.map +0 -7
  151. package/dist/modules/notifications/subscribers/deliver-notification.js +0 -139
  152. package/dist/modules/notifications/subscribers/deliver-notification.js.map +0 -7
  153. package/dist/modules/notifications/workers/create-notification.worker.js +0 -70
  154. package/dist/modules/notifications/workers/create-notification.worker.js.map +0 -7
  155. package/dist/modules/sales/notifications.client.js +0 -51
  156. package/dist/modules/sales/notifications.client.js.map +0 -7
  157. package/dist/modules/sales/notifications.js +0 -88
  158. package/dist/modules/sales/notifications.js.map +0 -7
  159. package/dist/modules/sales/subscribers/quote-expiring-notification.js +0 -38
  160. package/dist/modules/sales/subscribers/quote-expiring-notification.js.map +0 -7
  161. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js +0 -137
  162. package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js.map +0 -7
  163. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js +0 -137
  164. package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js.map +0 -7
  165. package/dist/modules/sales/widgets/notifications/index.js +0 -7
  166. package/dist/modules/sales/widgets/notifications/index.js.map +0 -7
  167. package/dist/modules/sales/widgets/notifications/useSalesDocumentTotals.js +0 -60
  168. package/dist/modules/sales/widgets/notifications/useSalesDocumentTotals.js.map +0 -7
  169. package/dist/modules/staff/notifications.js +0 -75
  170. package/dist/modules/staff/notifications.js.map +0 -7
  171. package/dist/modules/workflows/notifications.js +0 -28
  172. package/dist/modules/workflows/notifications.js.map +0 -7
  173. package/dist/modules/workflows/subscribers/task-assigned-notification.js +0 -38
  174. package/dist/modules/workflows/subscribers/task-assigned-notification.js.map +0 -7
  175. package/generated/entities/notification/index.ts +0 -27
  176. package/src/modules/auth/api/profile/route.ts +0 -160
  177. package/src/modules/auth/backend/auth/profile/page.meta.ts +0 -8
  178. package/src/modules/auth/backend/auth/profile/page.tsx +0 -127
  179. package/src/modules/auth/notifications.ts +0 -109
  180. package/src/modules/business_rules/notifications.ts +0 -25
  181. package/src/modules/business_rules/subscribers/rule-execution-failed-notification.ts +0 -50
  182. package/src/modules/catalog/notifications.ts +0 -25
  183. package/src/modules/catalog/subscribers/low-stock-notification.ts +0 -52
  184. package/src/modules/customers/notifications.ts +0 -44
  185. package/src/modules/notifications/acl.ts +0 -7
  186. package/src/modules/notifications/api/[id]/action/route.ts +0 -75
  187. package/src/modules/notifications/api/[id]/dismiss/route.ts +0 -12
  188. package/src/modules/notifications/api/[id]/read/route.ts +0 -12
  189. package/src/modules/notifications/api/[id]/restore/route.ts +0 -53
  190. package/src/modules/notifications/api/batch/route.ts +0 -14
  191. package/src/modules/notifications/api/feature/route.ts +0 -14
  192. package/src/modules/notifications/api/mark-all-read/route.ts +0 -34
  193. package/src/modules/notifications/api/openapi.ts +0 -76
  194. package/src/modules/notifications/api/role/route.ts +0 -14
  195. package/src/modules/notifications/api/route.ts +0 -92
  196. package/src/modules/notifications/api/settings/route.ts +0 -157
  197. package/src/modules/notifications/api/unread-count/route.ts +0 -38
  198. package/src/modules/notifications/backend/config/notifications/page.meta.ts +0 -22
  199. package/src/modules/notifications/backend/config/notifications/page.tsx +0 -12
  200. package/src/modules/notifications/cli.ts +0 -18
  201. package/src/modules/notifications/data/entities.ts +0 -99
  202. package/src/modules/notifications/data/validators.ts +0 -110
  203. package/src/modules/notifications/di.ts +0 -11
  204. package/src/modules/notifications/emails/NotificationEmail.tsx +0 -98
  205. package/src/modules/notifications/frontend/NotificationInboxPageClient.tsx +0 -42
  206. package/src/modules/notifications/frontend/NotificationSettingsPageClient.tsx +0 -231
  207. package/src/modules/notifications/i18n/de.json +0 -50
  208. package/src/modules/notifications/i18n/en.json +0 -50
  209. package/src/modules/notifications/i18n/es.json +0 -50
  210. package/src/modules/notifications/i18n/pl.json +0 -50
  211. package/src/modules/notifications/index.ts +0 -12
  212. package/src/modules/notifications/lib/deliveryConfig.ts +0 -145
  213. package/src/modules/notifications/lib/events.ts +0 -48
  214. package/src/modules/notifications/lib/notificationBuilder.ts +0 -121
  215. package/src/modules/notifications/lib/notificationFactory.ts +0 -76
  216. package/src/modules/notifications/lib/notificationMapper.ts +0 -33
  217. package/src/modules/notifications/lib/notificationRecipients.ts +0 -83
  218. package/src/modules/notifications/lib/notificationService.ts +0 -414
  219. package/src/modules/notifications/lib/routeHelpers.ts +0 -151
  220. package/src/modules/notifications/lib/safeHref.ts +0 -29
  221. package/src/modules/notifications/migrations/.snapshot-open-mercato.json +0 -300
  222. package/src/modules/notifications/migrations/Migration20260123000001.ts +0 -73
  223. package/src/modules/notifications/migrations/Migration20260126150000.ts +0 -39
  224. package/src/modules/notifications/subscribers/deliver-notification.ts +0 -175
  225. package/src/modules/notifications/workers/create-notification.worker.ts +0 -122
  226. package/src/modules/sales/notifications.client.ts +0 -65
  227. package/src/modules/sales/notifications.ts +0 -82
  228. package/src/modules/sales/subscribers/quote-expiring-notification.ts +0 -53
  229. package/src/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.tsx +0 -156
  230. package/src/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.tsx +0 -156
  231. package/src/modules/sales/widgets/notifications/index.ts +0 -2
  232. package/src/modules/sales/widgets/notifications/useSalesDocumentTotals.ts +0 -81
  233. package/src/modules/staff/notifications.ts +0 -71
  234. package/src/modules/workflows/notifications.ts +0 -25
  235. package/src/modules/workflows/subscribers/task-assigned-notification.ts +0 -53
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/staff/commands/leave-requests.ts"],
4
- "sourcesContent": ["import { randomUUID } from 'crypto'\nimport type { CommandHandler, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { registerCommand } from '@open-mercato/shared/lib/commands'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { emitCrudSideEffects, emitCrudUndoSideEffects, buildChanges } from '@open-mercato/shared/lib/commands/helpers'\nimport type { CrudIndexerConfig } from '@open-mercato/shared/lib/crud/types'\nimport type { DataEngine } from '@open-mercato/shared/lib/data/engine'\nimport { invalidateCrudCache } from '@open-mercato/shared/lib/crud/cache'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { PlannerAvailabilityRule } from '@open-mercato/core/modules/planner/data/entities'\nimport { StaffLeaveRequest, type StaffLeaveRequestStatus } from '../data/entities'\nimport {\n staffLeaveRequestCreateSchema,\n staffLeaveRequestDecisionSchema,\n staffLeaveRequestUpdateSchema,\n type StaffLeaveRequestCreateInput,\n type StaffLeaveRequestDecisionInput,\n type StaffLeaveRequestUpdateInput,\n} from '../data/validators'\nimport { ensureOrganizationScope, ensureTenantScope, extractUndoPayload, requireTeamMember } from './shared'\nimport { E } from '#generated/entities.ids.generated'\nimport { resolveNotificationService } from '../../notifications/lib/notificationService'\nimport { buildFeatureNotificationFromType, buildNotificationFromType } from '../../notifications/lib/notificationBuilder'\nimport { notificationTypes } from '../notifications'\n\nconst leaveRequestCrudIndexer: CrudIndexerConfig<StaffLeaveRequest> = {\n entityType: E.staff.staff_leave_request,\n}\n\nconst availabilityRuleCrudIndexer: CrudIndexerConfig<PlannerAvailabilityRule> = {\n entityType: E.planner.planner_availability_rule,\n cacheAliases: ['planner.availability'],\n}\n\ntype LeaveRequestSnapshot = {\n id: string\n tenantId: string\n organizationId: string\n memberId: string\n startDate: string\n endDate: string\n timezone: string\n status: StaffLeaveRequestStatus\n unavailabilityReasonEntryId: string | null\n unavailabilityReasonValue: string | null\n note: string | null\n decisionComment: string | null\n submittedByUserId: string | null\n decidedByUserId: string | null\n decidedAt: string | null\n deletedAt: string | null\n createdAt: string | null\n updatedAt: string | null\n}\n\ntype LeaveRequestUndoPayload = {\n before?: LeaveRequestSnapshot | null\n after?: LeaveRequestSnapshot | null\n availabilityRuleIds?: string[]\n}\n\nfunction parseUuidCandidate(value: string | null | undefined): string | null {\n if (!value) return null\n const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/\n return uuidRegex.test(value) ? value : null\n}\n\nfunction resolveAuthUserId(ctx: { auth?: { sub?: string | null; isApiKey?: boolean } | null }): string | null {\n if (!ctx.auth || ctx.auth.isApiKey) return null\n return parseUuidCandidate(ctx.auth.sub ?? null)\n}\n\nfunction formatDateKey(value: Date): string {\n const year = value.getUTCFullYear()\n const month = String(value.getUTCMonth() + 1).padStart(2, '0')\n const day = String(value.getUTCDate()).padStart(2, '0')\n return `${year}-${month}-${day}`\n}\n\nfunction listDateKeysInRange(start: Date, end: Date): string[] {\n const dates: string[] = []\n const current = new Date(Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), start.getUTCDate()))\n const last = new Date(Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate()))\n while (current <= last) {\n dates.push(formatDateKey(current))\n current.setUTCDate(current.getUTCDate() + 1)\n }\n return dates\n}\n\nfunction formatDuration(minutes: number): string {\n const clamped = Math.max(1, minutes)\n const hours = Math.floor(clamped / 60)\n const mins = clamped % 60\n if (hours > 0 && mins > 0) return `PT${hours}H${mins}M`\n if (hours > 0) return `PT${hours}H`\n return `PT${mins}M`\n}\n\nfunction buildAvailabilityRrule(start: Date, end: Date): string {\n const dtStart = start.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z'\n const durationMinutes = Math.max(1, Math.round((end.getTime() - start.getTime()) / 60000))\n const duration = formatDuration(durationMinutes)\n return `DTSTART:${dtStart}\\nDURATION:${duration}\\nRRULE:FREQ=DAILY;COUNT=1`\n}\n\nfunction buildFullDayRrule(date: string): string | null {\n const [year, month, day] = date.split('-').map((part) => Number(part))\n if (!Number.isFinite(year) || !Number.isFinite(month) || !Number.isFinite(day)) return null\n const start = new Date(Date.UTC(year, month - 1, day, 0, 0, 0))\n const end = new Date(start.getTime() + 24 * 60 * 60 * 1000)\n return buildAvailabilityRrule(start, end)\n}\n\nasync function loadLeaveRequestSnapshot(em: EntityManager, id: string): Promise<LeaveRequestSnapshot | null> {\n const request = await findOneWithDecryption(em, StaffLeaveRequest, { id }, undefined, { tenantId: null, organizationId: null })\n if (!request) return null\n const memberId = typeof request.member === 'string' ? request.member : request.member.id\n return {\n id: request.id,\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n memberId,\n startDate: request.startDate.toISOString(),\n endDate: request.endDate.toISOString(),\n timezone: request.timezone,\n status: request.status,\n unavailabilityReasonEntryId: request.unavailabilityReasonEntryId ?? null,\n unavailabilityReasonValue: request.unavailabilityReasonValue ?? null,\n note: request.note ?? null,\n decisionComment: request.decisionComment ?? null,\n submittedByUserId: request.submittedByUserId ?? null,\n decidedByUserId: request.decidedByUserId ?? null,\n decidedAt: request.decidedAt ? request.decidedAt.toISOString() : null,\n deletedAt: request.deletedAt ? request.deletedAt.toISOString() : null,\n createdAt: request.createdAt ? request.createdAt.toISOString() : null,\n updatedAt: request.updatedAt ? request.updatedAt.toISOString() : null,\n }\n}\n\nasync function requireLeaveRequest(em: EntityManager, id: string): Promise<StaffLeaveRequest> {\n const request = await findOneWithDecryption(em, StaffLeaveRequest, { id, deletedAt: null }, undefined, { tenantId: null, organizationId: null })\n if (!request) throw new CrudHttpError(404, { error: 'Leave request not found.' })\n return request\n}\n\nfunction ensurePendingStatus(request: StaffLeaveRequest): void {\n if (request.status !== 'pending') {\n throw new CrudHttpError(400, { error: 'Leave request is already finalized.' })\n }\n}\n\nasync function createUnavailabilityRules(params: {\n em: EntityManager\n tenantId: string\n organizationId: string\n memberId: string\n timezone: string\n dates: string[]\n note: string | null\n reasonEntryId: string | null\n reasonValue: string | null\n}): Promise<string[]> {\n const now = new Date()\n const createdIds: string[] = []\n params.dates.forEach((date) => {\n const rrule = buildFullDayRrule(date)\n if (!rrule) return\n const ruleId = randomUUID()\n const rule = params.em.create(PlannerAvailabilityRule, {\n id: ruleId,\n tenantId: params.tenantId,\n organizationId: params.organizationId,\n subjectType: 'member',\n subjectId: params.memberId,\n timezone: params.timezone,\n rrule,\n exdates: [],\n kind: 'unavailability',\n note: params.note,\n unavailabilityReasonEntryId: params.reasonEntryId,\n unavailabilityReasonValue: params.reasonValue,\n createdAt: now,\n updatedAt: now,\n deletedAt: null,\n })\n params.em.persist(rule)\n createdIds.push(ruleId)\n })\n return createdIds\n}\n\nasync function invalidateAvailabilityCache(params: {\n container: CommandRuntimeContext['container']\n tenantId: string | null\n organizationId: string | null\n ruleIds: string[]\n}) {\n if (!params.ruleIds.length) return\n const resource = 'planner.availability'\n const fallbackTenant = params.tenantId ?? null\n for (const ruleId of params.ruleIds) {\n await invalidateCrudCache(\n params.container,\n resource,\n { id: ruleId, organizationId: params.organizationId, tenantId: params.tenantId },\n fallbackTenant,\n 'updated',\n )\n }\n}\n\nconst createLeaveRequestCommand: CommandHandler<StaffLeaveRequestCreateInput, { requestId: string }> = {\n id: 'staff.leave-requests.create',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestCreateSchema.parse(rawInput)\n ensureTenantScope(ctx, parsed.tenantId)\n ensureOrganizationScope(ctx, parsed.organizationId)\n\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const member = await requireTeamMember(em, parsed.memberId, 'Team member not found')\n ensureTenantScope(ctx, member.tenantId)\n ensureOrganizationScope(ctx, member.organizationId)\n\n const submittedByUserId = parsed.submittedByUserId ?? resolveAuthUserId(ctx)\n const now = new Date()\n const request = em.create(StaffLeaveRequest, {\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n member,\n startDate: parsed.startDate,\n endDate: parsed.endDate,\n timezone: parsed.timezone,\n status: 'pending',\n unavailabilityReasonEntryId: parsed.unavailabilityReasonEntryId ?? null,\n unavailabilityReasonValue: parsed.unavailabilityReasonValue ?? null,\n note: parsed.note ?? null,\n decisionComment: null,\n submittedByUserId,\n decidedByUserId: null,\n decidedAt: null,\n createdAt: now,\n updatedAt: now,\n deletedAt: null,\n })\n em.persist(request)\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'created',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n // Create notification for users who can approve/reject leave requests\n try {\n const notificationService = resolveNotificationService(ctx.container)\n const typeDef = notificationTypes.find((type) => type.type === 'staff.leave_request.pending')\n if (typeDef) {\n const memberName = member.displayName || 'Team member'\n const startDateStr = request.startDate.toLocaleDateString()\n const endDateStr = request.endDate.toLocaleDateString()\n\n const notificationInput = buildFeatureNotificationFromType(typeDef, {\n requiredFeature: 'staff.leave_requests.manage',\n bodyVariables: {\n memberName,\n startDate: startDateStr,\n endDate: endDateStr,\n },\n sourceEntityType: 'staff:leave_request',\n sourceEntityId: request.id,\n linkHref: `/backend/staff/leave-requests/${request.id}`,\n })\n\n await notificationService.createForFeature(notificationInput, {\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n })\n }\n } catch {\n // Notification creation is non-critical, don't fail the command\n }\n\n return { requestId: request.id }\n },\n captureAfter: async (_input, result, ctx) => {\n const em = (ctx.container.resolve('em') as EntityManager)\n return await loadLeaveRequestSnapshot(em, result.requestId)\n },\n buildLog: async ({ result, ctx }) => {\n const { translate } = await resolveTranslations()\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.create', 'Create leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: snapshot?.tenantId ?? null,\n organizationId: snapshot?.organizationId ?? null,\n snapshotAfter: snapshot ?? null,\n payload: {\n undo: {\n after: snapshot ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const after = payload?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: after.id })\n if (request) {\n request.deletedAt = new Date()\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'deleted',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n }\n },\n}\n\nconst updateLeaveRequestCommand: CommandHandler<StaffLeaveRequestUpdateInput, { requestId: string }> = {\n id: 'staff.leave-requests.update',\n async prepare(rawInput, ctx) {\n const parsed = staffLeaveRequestUpdateSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, parsed.id)\n return snapshot ? { before: snapshot } : {}\n },\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestUpdateSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n if (parsed.memberId !== undefined) {\n const member = await requireTeamMember(em, parsed.memberId, 'Team member not found')\n ensureTenantScope(ctx, member.tenantId)\n ensureOrganizationScope(ctx, member.organizationId)\n request.member = member\n }\n if (parsed.startDate !== undefined) request.startDate = parsed.startDate\n if (parsed.endDate !== undefined) request.endDate = parsed.endDate\n if (parsed.timezone !== undefined) request.timezone = parsed.timezone\n if (parsed.unavailabilityReasonEntryId !== undefined) request.unavailabilityReasonEntryId = parsed.unavailabilityReasonEntryId ?? null\n if (parsed.unavailabilityReasonValue !== undefined) request.unavailabilityReasonValue = parsed.unavailabilityReasonValue ?? null\n if (parsed.note !== undefined) request.note = parsed.note ?? null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n return { requestId: request.id }\n },\n buildLog: async ({ snapshots, ctx }) => {\n const { translate } = await resolveTranslations()\n const before = snapshots.before as LeaveRequestSnapshot | undefined\n if (!before) return null\n const em = (ctx.container.resolve('em') as EntityManager)\n const after = await loadLeaveRequestSnapshot(em, before.id)\n const changes = after\n ? buildChanges(before as unknown as Record<string, unknown>, after as unknown as Record<string, unknown>, [\n 'memberId',\n 'startDate',\n 'endDate',\n 'timezone',\n 'unavailabilityReasonEntryId',\n 'unavailabilityReasonValue',\n 'note',\n ])\n : {}\n return {\n actionLabel: translate('staff.audit.leaveRequests.update', 'Update leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n snapshotBefore: before,\n snapshotAfter: after ?? null,\n changes,\n payload: {\n undo: {\n before,\n after: after ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const before = payload?.before\n const after = payload?.after\n if (!before || !after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: after.id })\n if (!request) return\n request.startDate = new Date(before.startDate)\n request.endDate = new Date(before.endDate)\n request.timezone = before.timezone\n request.status = before.status\n request.unavailabilityReasonEntryId = before.unavailabilityReasonEntryId\n request.unavailabilityReasonValue = before.unavailabilityReasonValue\n request.note = before.note\n request.decisionComment = before.decisionComment\n request.decidedByUserId = before.decidedByUserId\n request.decidedAt = before.decidedAt ? new Date(before.decidedAt) : null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n },\n}\n\nconst deleteLeaveRequestCommand: CommandHandler<{ id: string }, { requestId: string }> = {\n id: 'staff.leave-requests.delete',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.pick({ id: true }).parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n request.deletedAt = new Date()\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'deleted',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n return { requestId: request.id }\n },\n captureAfter: async (_input, result, ctx) => {\n const em = (ctx.container.resolve('em') as EntityManager)\n return await loadLeaveRequestSnapshot(em, result.requestId)\n },\n buildLog: async ({ result, ctx }) => {\n const { translate } = await resolveTranslations()\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.delete', 'Delete leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: snapshot?.tenantId ?? null,\n organizationId: snapshot?.organizationId ?? null,\n snapshotAfter: snapshot ?? null,\n payload: {\n undo: {\n after: snapshot ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const after = payload?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: after.id })\n if (!request) return\n request.deletedAt = null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'created',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n },\n}\n\nconst acceptLeaveRequestCommand: CommandHandler<StaffLeaveRequestDecisionInput, { requestId: string; ruleIds: string[] }> = {\n id: 'staff.leave-requests.accept',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n const memberId = typeof request.member === 'string' ? request.member : request.member.id\n const decidedByUserId = parsed.decidedByUserId ?? resolveAuthUserId(ctx)\n const now = new Date()\n const dates = listDateKeysInRange(request.startDate, request.endDate)\n let createdRuleIds: string[] = []\n\n await em.transactional(async (trx) => {\n request.status = 'approved'\n request.decisionComment = parsed.decisionComment ?? null\n request.decidedByUserId = decidedByUserId\n request.decidedAt = now\n request.updatedAt = now\n trx.persist(request)\n\n createdRuleIds = await createUnavailabilityRules({\n em: trx,\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n memberId,\n timezone: request.timezone,\n dates,\n note: request.note ?? null,\n reasonEntryId: request.unavailabilityReasonEntryId ?? null,\n reasonValue: request.unavailabilityReasonValue ?? null,\n })\n await trx.flush()\n })\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n if (createdRuleIds.length) {\n const rules = await em.find(PlannerAvailabilityRule, { id: { $in: createdRuleIds } })\n for (const rule of rules) {\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'created',\n entity: rule,\n identifiers: {\n id: rule.id,\n organizationId: rule.organizationId,\n tenantId: rule.tenantId,\n },\n indexer: availabilityRuleCrudIndexer,\n })\n }\n }\n await invalidateAvailabilityCache({\n container: ctx.container,\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n ruleIds: createdRuleIds,\n })\n\n // Send notification to the requester\n if (request.submittedByUserId) {\n try {\n const notificationService = resolveNotificationService(ctx.container)\n const typeDef = notificationTypes.find((type) => type.type === 'staff.leave_request.approved')\n if (typeDef) {\n const startDateStr = request.startDate.toLocaleDateString()\n const endDateStr = request.endDate.toLocaleDateString()\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: request.submittedByUserId,\n bodyVariables: {\n startDate: startDateStr,\n endDate: endDateStr,\n },\n sourceEntityType: 'staff:leave_request',\n sourceEntityId: request.id,\n linkHref: `/backend/staff/leave-requests/${request.id}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n })\n }\n } catch {\n // Notification creation is non-critical, don't fail the command\n }\n }\n\n return { requestId: request.id, ruleIds: createdRuleIds }\n },\n buildLog: async ({ result, ctx, snapshots }) => {\n const { translate } = await resolveTranslations()\n const before = snapshots.before as LeaveRequestSnapshot | undefined\n const em = (ctx.container.resolve('em') as EntityManager)\n const after = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.accept', 'Approve leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: after?.tenantId ?? before?.tenantId ?? null,\n organizationId: after?.organizationId ?? before?.organizationId ?? null,\n snapshotBefore: before ?? null,\n snapshotAfter: after ?? null,\n payload: {\n undo: {\n before: before ?? null,\n after: after ?? null,\n availabilityRuleIds: result.ruleIds,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n async prepare(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, parsed.id)\n return snapshot ? { before: snapshot } : {}\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const before = payload?.before\n const availabilityRuleIds = payload?.availabilityRuleIds ?? []\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: before.id })\n if (!request) return\n request.status = before.status\n request.decisionComment = before.decisionComment\n request.decidedByUserId = before.decidedByUserId\n request.decidedAt = before.decidedAt ? new Date(before.decidedAt) : null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n if (availabilityRuleIds.length) {\n const rules = await em.find(PlannerAvailabilityRule, { id: { $in: availabilityRuleIds } })\n const now = new Date()\n rules.forEach((rule) => {\n rule.deletedAt = now\n rule.updatedAt = now\n })\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n for (const rule of rules) {\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'deleted',\n entity: rule,\n identifiers: {\n id: rule.id,\n organizationId: rule.organizationId,\n tenantId: rule.tenantId,\n },\n indexer: availabilityRuleCrudIndexer,\n })\n }\n }\n await invalidateAvailabilityCache({\n container: ctx.container,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n ruleIds: availabilityRuleIds,\n })\n },\n}\n\nconst rejectLeaveRequestCommand: CommandHandler<StaffLeaveRequestDecisionInput, { requestId: string }> = {\n id: 'staff.leave-requests.reject',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n request.status = 'rejected'\n request.decisionComment = parsed.decisionComment ?? null\n request.decidedByUserId = parsed.decidedByUserId ?? resolveAuthUserId(ctx)\n request.decidedAt = new Date()\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n // Send notification to the requester\n if (request.submittedByUserId) {\n try {\n const notificationService = resolveNotificationService(ctx.container)\n const typeDef = notificationTypes.find((type) => type.type === 'staff.leave_request.rejected')\n if (typeDef) {\n const startDateStr = request.startDate.toLocaleDateString()\n const endDateStr = request.endDate.toLocaleDateString()\n\n const notificationInput = buildNotificationFromType(typeDef, {\n recipientUserId: request.submittedByUserId,\n bodyVariables: {\n startDate: startDateStr,\n endDate: endDateStr,\n reason: request.decisionComment ?? '',\n },\n sourceEntityType: 'staff:leave_request',\n sourceEntityId: request.id,\n linkHref: `/backend/staff/leave-requests/${request.id}`,\n })\n\n await notificationService.create(notificationInput, {\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n })\n }\n } catch {\n // Notification creation is non-critical, don't fail the command\n }\n }\n\n return { requestId: request.id }\n },\n async prepare(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, parsed.id)\n return snapshot ? { before: snapshot } : {}\n },\n buildLog: async ({ result, ctx, snapshots }) => {\n const { translate } = await resolveTranslations()\n const before = snapshots.before as LeaveRequestSnapshot | undefined\n const em = (ctx.container.resolve('em') as EntityManager)\n const after = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.reject', 'Reject leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: after?.tenantId ?? before?.tenantId ?? null,\n organizationId: after?.organizationId ?? before?.organizationId ?? null,\n snapshotBefore: before ?? null,\n snapshotAfter: after ?? null,\n payload: {\n undo: {\n before: before ?? null,\n after: after ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const before = payload?.before\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: before.id })\n if (!request) return\n request.status = before.status\n request.decisionComment = before.decisionComment\n request.decidedByUserId = before.decidedByUserId\n request.decidedAt = before.decidedAt ? new Date(before.decidedAt) : null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n },\n}\n\nregisterCommand(createLeaveRequestCommand)\nregisterCommand(updateLeaveRequestCommand)\nregisterCommand(deleteLeaveRequestCommand)\nregisterCommand(acceptLeaveRequestCommand)\nregisterCommand(rejectLeaveRequestCommand)\n"],
5
- "mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,uBAAuB;AAEhC,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,qBAAqB,yBAAyB,oBAAoB;AAG3E,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AACxC,SAAS,yBAAuD;AAChE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,yBAAyB,mBAAmB,oBAAoB,yBAAyB;AAClG,SAAS,SAAS;AAClB,SAAS,kCAAkC;AAC3C,SAAS,kCAAkC,iCAAiC;AAC5E,SAAS,yBAAyB;AAElC,MAAM,0BAAgE;AAAA,EACpE,YAAY,EAAE,MAAM;AACtB;AAEA,MAAM,8BAA0E;AAAA,EAC9E,YAAY,EAAE,QAAQ;AAAA,EACtB,cAAc,CAAC,sBAAsB;AACvC;AA6BA,SAAS,mBAAmB,OAAiD;AAC3E,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,YAAY;AAClB,SAAO,UAAU,KAAK,KAAK,IAAI,QAAQ;AACzC;AAEA,SAAS,kBAAkB,KAAmF;AAC5G,MAAI,CAAC,IAAI,QAAQ,IAAI,KAAK,SAAU,QAAO;AAC3C,SAAO,mBAAmB,IAAI,KAAK,OAAO,IAAI;AAChD;AAEA,SAAS,cAAc,OAAqB;AAC1C,QAAM,OAAO,MAAM,eAAe;AAClC,QAAM,QAAQ,OAAO,MAAM,YAAY,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AAC7D,QAAM,MAAM,OAAO,MAAM,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG;AACtD,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI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UAAU,QAAQ,YAAY;AAC9C,UAAM,wBAAwB;AAAA,MAC5B,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,QACX,IAAI,QAAQ;AAAA,QACZ,gBAAgB,QAAQ;AAAA,QACxB,UAAU,QAAQ;AAAA,MACpB;AAAA,MACA,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAEA,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;",
4
+ "sourcesContent": ["import { randomUUID } from 'crypto'\nimport type { CommandHandler, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { registerCommand } from '@open-mercato/shared/lib/commands'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { emitCrudSideEffects, emitCrudUndoSideEffects, buildChanges } from '@open-mercato/shared/lib/commands/helpers'\nimport type { CrudIndexerConfig } from '@open-mercato/shared/lib/crud/types'\nimport type { DataEngine } from '@open-mercato/shared/lib/data/engine'\nimport { invalidateCrudCache } from '@open-mercato/shared/lib/crud/cache'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { PlannerAvailabilityRule } from '@open-mercato/core/modules/planner/data/entities'\nimport { StaffLeaveRequest, type StaffLeaveRequestStatus } from '../data/entities'\nimport {\n staffLeaveRequestCreateSchema,\n staffLeaveRequestDecisionSchema,\n staffLeaveRequestUpdateSchema,\n type StaffLeaveRequestCreateInput,\n type StaffLeaveRequestDecisionInput,\n type StaffLeaveRequestUpdateInput,\n} from '../data/validators'\nimport { ensureOrganizationScope, ensureTenantScope, extractUndoPayload, requireTeamMember } from './shared'\nimport { E } from '#generated/entities.ids.generated'\n\nconst leaveRequestCrudIndexer: CrudIndexerConfig<StaffLeaveRequest> = {\n entityType: E.staff.staff_leave_request,\n}\n\nconst availabilityRuleCrudIndexer: CrudIndexerConfig<PlannerAvailabilityRule> = {\n entityType: E.planner.planner_availability_rule,\n cacheAliases: ['planner.availability'],\n}\n\ntype LeaveRequestSnapshot = {\n id: string\n tenantId: string\n organizationId: string\n memberId: string\n startDate: string\n endDate: string\n timezone: string\n status: StaffLeaveRequestStatus\n unavailabilityReasonEntryId: string | null\n unavailabilityReasonValue: string | null\n note: string | null\n decisionComment: string | null\n submittedByUserId: string | null\n decidedByUserId: string | null\n decidedAt: string | null\n deletedAt: string | null\n createdAt: string | null\n updatedAt: string | null\n}\n\ntype LeaveRequestUndoPayload = {\n before?: LeaveRequestSnapshot | null\n after?: LeaveRequestSnapshot | null\n availabilityRuleIds?: string[]\n}\n\nfunction parseUuidCandidate(value: string | null | undefined): string | null {\n if (!value) return null\n const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/\n return uuidRegex.test(value) ? value : null\n}\n\nfunction resolveAuthUserId(ctx: { auth?: { sub?: string | null; isApiKey?: boolean } | null }): string | null {\n if (!ctx.auth || ctx.auth.isApiKey) return null\n return parseUuidCandidate(ctx.auth.sub ?? null)\n}\n\nfunction formatDateKey(value: Date): string {\n const year = value.getUTCFullYear()\n const month = String(value.getUTCMonth() + 1).padStart(2, '0')\n const day = String(value.getUTCDate()).padStart(2, '0')\n return `${year}-${month}-${day}`\n}\n\nfunction listDateKeysInRange(start: Date, end: Date): string[] {\n const dates: string[] = []\n const current = new Date(Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), start.getUTCDate()))\n const last = new Date(Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate()))\n while (current <= last) {\n dates.push(formatDateKey(current))\n current.setUTCDate(current.getUTCDate() + 1)\n }\n return dates\n}\n\nfunction formatDuration(minutes: number): string {\n const clamped = Math.max(1, minutes)\n const hours = Math.floor(clamped / 60)\n const mins = clamped % 60\n if (hours > 0 && mins > 0) return `PT${hours}H${mins}M`\n if (hours > 0) return `PT${hours}H`\n return `PT${mins}M`\n}\n\nfunction buildAvailabilityRrule(start: Date, end: Date): string {\n const dtStart = start.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z'\n const durationMinutes = Math.max(1, Math.round((end.getTime() - start.getTime()) / 60000))\n const duration = formatDuration(durationMinutes)\n return `DTSTART:${dtStart}\\nDURATION:${duration}\\nRRULE:FREQ=DAILY;COUNT=1`\n}\n\nfunction buildFullDayRrule(date: string): string | null {\n const [year, month, day] = date.split('-').map((part) => Number(part))\n if (!Number.isFinite(year) || !Number.isFinite(month) || !Number.isFinite(day)) return null\n const start = new Date(Date.UTC(year, month - 1, day, 0, 0, 0))\n const end = new Date(start.getTime() + 24 * 60 * 60 * 1000)\n return buildAvailabilityRrule(start, end)\n}\n\nasync function loadLeaveRequestSnapshot(em: EntityManager, id: string): Promise<LeaveRequestSnapshot | null> {\n const request = await findOneWithDecryption(em, StaffLeaveRequest, { id }, undefined, { tenantId: null, organizationId: null })\n if (!request) return null\n const memberId = typeof request.member === 'string' ? request.member : request.member.id\n return {\n id: request.id,\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n memberId,\n startDate: request.startDate.toISOString(),\n endDate: request.endDate.toISOString(),\n timezone: request.timezone,\n status: request.status,\n unavailabilityReasonEntryId: request.unavailabilityReasonEntryId ?? null,\n unavailabilityReasonValue: request.unavailabilityReasonValue ?? null,\n note: request.note ?? null,\n decisionComment: request.decisionComment ?? null,\n submittedByUserId: request.submittedByUserId ?? null,\n decidedByUserId: request.decidedByUserId ?? null,\n decidedAt: request.decidedAt ? request.decidedAt.toISOString() : null,\n deletedAt: request.deletedAt ? request.deletedAt.toISOString() : null,\n createdAt: request.createdAt ? request.createdAt.toISOString() : null,\n updatedAt: request.updatedAt ? request.updatedAt.toISOString() : null,\n }\n}\n\nasync function requireLeaveRequest(em: EntityManager, id: string): Promise<StaffLeaveRequest> {\n const request = await findOneWithDecryption(em, StaffLeaveRequest, { id, deletedAt: null }, undefined, { tenantId: null, organizationId: null })\n if (!request) throw new CrudHttpError(404, { error: 'Leave request not found.' })\n return request\n}\n\nfunction ensurePendingStatus(request: StaffLeaveRequest): void {\n if (request.status !== 'pending') {\n throw new CrudHttpError(400, { error: 'Leave request is already finalized.' })\n }\n}\n\nasync function createUnavailabilityRules(params: {\n em: EntityManager\n tenantId: string\n organizationId: string\n memberId: string\n timezone: string\n dates: string[]\n note: string | null\n reasonEntryId: string | null\n reasonValue: string | null\n}): Promise<string[]> {\n const now = new Date()\n const createdIds: string[] = []\n params.dates.forEach((date) => {\n const rrule = buildFullDayRrule(date)\n if (!rrule) return\n const ruleId = randomUUID()\n const rule = params.em.create(PlannerAvailabilityRule, {\n id: ruleId,\n tenantId: params.tenantId,\n organizationId: params.organizationId,\n subjectType: 'member',\n subjectId: params.memberId,\n timezone: params.timezone,\n rrule,\n exdates: [],\n kind: 'unavailability',\n note: params.note,\n unavailabilityReasonEntryId: params.reasonEntryId,\n unavailabilityReasonValue: params.reasonValue,\n createdAt: now,\n updatedAt: now,\n deletedAt: null,\n })\n params.em.persist(rule)\n createdIds.push(ruleId)\n })\n return createdIds\n}\n\nasync function invalidateAvailabilityCache(params: {\n container: CommandRuntimeContext['container']\n tenantId: string | null\n organizationId: string | null\n ruleIds: string[]\n}) {\n if (!params.ruleIds.length) return\n const resource = 'planner.availability'\n const fallbackTenant = params.tenantId ?? null\n for (const ruleId of params.ruleIds) {\n await invalidateCrudCache(\n params.container,\n resource,\n { id: ruleId, organizationId: params.organizationId, tenantId: params.tenantId },\n fallbackTenant,\n 'updated',\n )\n }\n}\n\nconst createLeaveRequestCommand: CommandHandler<StaffLeaveRequestCreateInput, { requestId: string }> = {\n id: 'staff.leave-requests.create',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestCreateSchema.parse(rawInput)\n ensureTenantScope(ctx, parsed.tenantId)\n ensureOrganizationScope(ctx, parsed.organizationId)\n\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const member = await requireTeamMember(em, parsed.memberId, 'Team member not found')\n ensureTenantScope(ctx, member.tenantId)\n ensureOrganizationScope(ctx, member.organizationId)\n\n const submittedByUserId = parsed.submittedByUserId ?? resolveAuthUserId(ctx)\n const now = new Date()\n const request = em.create(StaffLeaveRequest, {\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n member,\n startDate: parsed.startDate,\n endDate: parsed.endDate,\n timezone: parsed.timezone,\n status: 'pending',\n unavailabilityReasonEntryId: parsed.unavailabilityReasonEntryId ?? null,\n unavailabilityReasonValue: parsed.unavailabilityReasonValue ?? null,\n note: parsed.note ?? null,\n decisionComment: null,\n submittedByUserId,\n decidedByUserId: null,\n decidedAt: null,\n createdAt: now,\n updatedAt: now,\n deletedAt: null,\n })\n em.persist(request)\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'created',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n return { requestId: request.id }\n },\n captureAfter: async (_input, result, ctx) => {\n const em = (ctx.container.resolve('em') as EntityManager)\n return await loadLeaveRequestSnapshot(em, result.requestId)\n },\n buildLog: async ({ result, ctx }) => {\n const { translate } = await resolveTranslations()\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.create', 'Create leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: snapshot?.tenantId ?? null,\n organizationId: snapshot?.organizationId ?? null,\n snapshotAfter: snapshot ?? null,\n payload: {\n undo: {\n after: snapshot ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const after = payload?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: after.id })\n if (request) {\n request.deletedAt = new Date()\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'deleted',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n }\n },\n}\n\nconst updateLeaveRequestCommand: CommandHandler<StaffLeaveRequestUpdateInput, { requestId: string }> = {\n id: 'staff.leave-requests.update',\n async prepare(rawInput, ctx) {\n const parsed = staffLeaveRequestUpdateSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, parsed.id)\n return snapshot ? { before: snapshot } : {}\n },\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestUpdateSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n if (parsed.memberId !== undefined) {\n const member = await requireTeamMember(em, parsed.memberId, 'Team member not found')\n ensureTenantScope(ctx, member.tenantId)\n ensureOrganizationScope(ctx, member.organizationId)\n request.member = member\n }\n if (parsed.startDate !== undefined) request.startDate = parsed.startDate\n if (parsed.endDate !== undefined) request.endDate = parsed.endDate\n if (parsed.timezone !== undefined) request.timezone = parsed.timezone\n if (parsed.unavailabilityReasonEntryId !== undefined) request.unavailabilityReasonEntryId = parsed.unavailabilityReasonEntryId ?? null\n if (parsed.unavailabilityReasonValue !== undefined) request.unavailabilityReasonValue = parsed.unavailabilityReasonValue ?? null\n if (parsed.note !== undefined) request.note = parsed.note ?? null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n return { requestId: request.id }\n },\n buildLog: async ({ snapshots, ctx }) => {\n const { translate } = await resolveTranslations()\n const before = snapshots.before as LeaveRequestSnapshot | undefined\n if (!before) return null\n const em = (ctx.container.resolve('em') as EntityManager)\n const after = await loadLeaveRequestSnapshot(em, before.id)\n const changes = after\n ? buildChanges(before as unknown as Record<string, unknown>, after as unknown as Record<string, unknown>, [\n 'memberId',\n 'startDate',\n 'endDate',\n 'timezone',\n 'unavailabilityReasonEntryId',\n 'unavailabilityReasonValue',\n 'note',\n ])\n : {}\n return {\n actionLabel: translate('staff.audit.leaveRequests.update', 'Update leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n snapshotBefore: before,\n snapshotAfter: after ?? null,\n changes,\n payload: {\n undo: {\n before,\n after: after ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const before = payload?.before\n const after = payload?.after\n if (!before || !after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: after.id })\n if (!request) return\n request.startDate = new Date(before.startDate)\n request.endDate = new Date(before.endDate)\n request.timezone = before.timezone\n request.status = before.status\n request.unavailabilityReasonEntryId = before.unavailabilityReasonEntryId\n request.unavailabilityReasonValue = before.unavailabilityReasonValue\n request.note = before.note\n request.decisionComment = before.decisionComment\n request.decidedByUserId = before.decidedByUserId\n request.decidedAt = before.decidedAt ? new Date(before.decidedAt) : null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n },\n}\n\nconst deleteLeaveRequestCommand: CommandHandler<{ id: string }, { requestId: string }> = {\n id: 'staff.leave-requests.delete',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.pick({ id: true }).parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n request.deletedAt = new Date()\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'deleted',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n return { requestId: request.id }\n },\n captureAfter: async (_input, result, ctx) => {\n const em = (ctx.container.resolve('em') as EntityManager)\n return await loadLeaveRequestSnapshot(em, result.requestId)\n },\n buildLog: async ({ result, ctx }) => {\n const { translate } = await resolveTranslations()\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.delete', 'Delete leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: snapshot?.tenantId ?? null,\n organizationId: snapshot?.organizationId ?? null,\n snapshotAfter: snapshot ?? null,\n payload: {\n undo: {\n after: snapshot ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const after = payload?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: after.id })\n if (!request) return\n request.deletedAt = null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'created',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n },\n}\n\nconst acceptLeaveRequestCommand: CommandHandler<StaffLeaveRequestDecisionInput, { requestId: string; ruleIds: string[] }> = {\n id: 'staff.leave-requests.accept',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n const memberId = typeof request.member === 'string' ? request.member : request.member.id\n const decidedByUserId = parsed.decidedByUserId ?? resolveAuthUserId(ctx)\n const now = new Date()\n const dates = listDateKeysInRange(request.startDate, request.endDate)\n let createdRuleIds: string[] = []\n\n await em.transactional(async (trx) => {\n request.status = 'approved'\n request.decisionComment = parsed.decisionComment ?? null\n request.decidedByUserId = decidedByUserId\n request.decidedAt = now\n request.updatedAt = now\n trx.persist(request)\n\n createdRuleIds = await createUnavailabilityRules({\n em: trx,\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n memberId,\n timezone: request.timezone,\n dates,\n note: request.note ?? null,\n reasonEntryId: request.unavailabilityReasonEntryId ?? null,\n reasonValue: request.unavailabilityReasonValue ?? null,\n })\n await trx.flush()\n })\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n if (createdRuleIds.length) {\n const rules = await em.find(PlannerAvailabilityRule, { id: { $in: createdRuleIds } })\n for (const rule of rules) {\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'created',\n entity: rule,\n identifiers: {\n id: rule.id,\n organizationId: rule.organizationId,\n tenantId: rule.tenantId,\n },\n indexer: availabilityRuleCrudIndexer,\n })\n }\n }\n await invalidateAvailabilityCache({\n container: ctx.container,\n tenantId: request.tenantId,\n organizationId: request.organizationId,\n ruleIds: createdRuleIds,\n })\n\n return { requestId: request.id, ruleIds: createdRuleIds }\n },\n buildLog: async ({ result, ctx, snapshots }) => {\n const { translate } = await resolveTranslations()\n const before = snapshots.before as LeaveRequestSnapshot | undefined\n const em = (ctx.container.resolve('em') as EntityManager)\n const after = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.accept', 'Approve leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: after?.tenantId ?? before?.tenantId ?? null,\n organizationId: after?.organizationId ?? before?.organizationId ?? null,\n snapshotBefore: before ?? null,\n snapshotAfter: after ?? null,\n payload: {\n undo: {\n before: before ?? null,\n after: after ?? null,\n availabilityRuleIds: result.ruleIds,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n async prepare(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, parsed.id)\n return snapshot ? { before: snapshot } : {}\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const before = payload?.before\n const availabilityRuleIds = payload?.availabilityRuleIds ?? []\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: before.id })\n if (!request) return\n request.status = before.status\n request.decisionComment = before.decisionComment\n request.decidedByUserId = before.decidedByUserId\n request.decidedAt = before.decidedAt ? new Date(before.decidedAt) : null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n if (availabilityRuleIds.length) {\n const rules = await em.find(PlannerAvailabilityRule, { id: { $in: availabilityRuleIds } })\n const now = new Date()\n rules.forEach((rule) => {\n rule.deletedAt = now\n rule.updatedAt = now\n })\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n for (const rule of rules) {\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'deleted',\n entity: rule,\n identifiers: {\n id: rule.id,\n organizationId: rule.organizationId,\n tenantId: rule.tenantId,\n },\n indexer: availabilityRuleCrudIndexer,\n })\n }\n }\n await invalidateAvailabilityCache({\n container: ctx.container,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n ruleIds: availabilityRuleIds,\n })\n },\n}\n\nconst rejectLeaveRequestCommand: CommandHandler<StaffLeaveRequestDecisionInput, { requestId: string }> = {\n id: 'staff.leave-requests.reject',\n async execute(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await requireLeaveRequest(em, parsed.id)\n ensureTenantScope(ctx, request.tenantId)\n ensureOrganizationScope(ctx, request.organizationId)\n ensurePendingStatus(request)\n\n request.status = 'rejected'\n request.decisionComment = parsed.decisionComment ?? null\n request.decidedByUserId = parsed.decidedByUserId ?? resolveAuthUserId(ctx)\n request.decidedAt = new Date()\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n\n return { requestId: request.id }\n },\n async prepare(rawInput, ctx) {\n const parsed = staffLeaveRequestDecisionSchema.parse(rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadLeaveRequestSnapshot(em, parsed.id)\n return snapshot ? { before: snapshot } : {}\n },\n buildLog: async ({ result, ctx, snapshots }) => {\n const { translate } = await resolveTranslations()\n const before = snapshots.before as LeaveRequestSnapshot | undefined\n const em = (ctx.container.resolve('em') as EntityManager)\n const after = await loadLeaveRequestSnapshot(em, result.requestId)\n return {\n actionLabel: translate('staff.audit.leaveRequests.reject', 'Reject leave request'),\n resourceKind: 'staff.leave_request',\n resourceId: result.requestId,\n tenantId: after?.tenantId ?? before?.tenantId ?? null,\n organizationId: after?.organizationId ?? before?.organizationId ?? null,\n snapshotBefore: before ?? null,\n snapshotAfter: after ?? null,\n payload: {\n undo: {\n before: before ?? null,\n after: after ?? null,\n } satisfies LeaveRequestUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<LeaveRequestUndoPayload>(logEntry)\n const before = payload?.before\n if (!before) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const request = await em.findOne(StaffLeaveRequest, { id: before.id })\n if (!request) return\n request.status = before.status\n request.decisionComment = before.decisionComment\n request.decidedByUserId = before.decidedByUserId\n request.decidedAt = before.decidedAt ? new Date(before.decidedAt) : null\n request.updatedAt = new Date()\n await em.flush()\n\n const de = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine: de,\n action: 'updated',\n entity: request,\n identifiers: {\n id: request.id,\n organizationId: request.organizationId,\n tenantId: request.tenantId,\n },\n indexer: leaveRequestCrudIndexer,\n })\n },\n}\n\nregisterCommand(createLeaveRequestCommand)\nregisterCommand(updateLeaveRequestCommand)\nregisterCommand(deleteLeaveRequestCommand)\nregisterCommand(acceptLeaveRequestCommand)\nregisterCommand(rejectLeaveRequestCommand)\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,uBAAuB;AAEhC,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACp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YAAQ,kBAAkB,OAAO;AACjC,YAAQ,YAAY,OAAO,YAAY,IAAI,KAAK,OAAO,SAAS,IAAI;AACpE,YAAQ,YAAY,oBAAI,KAAK;AAC7B,UAAM,GAAG,MAAM;AAEf,UAAM,KAAM,IAAI,UAAU,QAAQ,YAAY;AAC9C,UAAM,wBAAwB;AAAA,MAC5B,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,QACX,IAAI,QAAQ;AAAA,QACZ,gBAAgB,QAAQ;AAAA,QACxB,UAAU,QAAQ;AAAA,MACpB;AAAA,MACA,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAEA,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;AACzC,gBAAgB,yBAAyB;",
6
6
  "names": ["de"]
7
7
  }
@@ -21,8 +21,7 @@ export const M = {
21
21
  "currencies": "currencies",
22
22
  "planner": "planner",
23
23
  "resources": "resources",
24
- "staff": "staff",
25
- "notifications": "notifications"
24
+ "staff": "staff"
26
25
  } as const
27
26
  export const E = {
28
27
  "dashboards": {
@@ -31,34 +30,34 @@ export const E = {
31
30
  "dashboard_user_widgets": "dashboards:dashboard_user_widgets"
32
31
  },
33
32
  "auth": {
34
- "password_reset": "auth:password_reset",
33
+ "user": "auth:user",
35
34
  "role": "auth:role",
36
- "role_acl": "auth:role_acl",
35
+ "user_sidebar_preference": "auth:user_sidebar_preference",
37
36
  "role_sidebar_preference": "auth:role_sidebar_preference",
38
- "session": "auth:session",
39
- "user": "auth:user",
40
- "user_acl": "auth:user_acl",
41
37
  "user_role": "auth:user_role",
42
- "user_sidebar_preference": "auth:user_sidebar_preference"
38
+ "session": "auth:session",
39
+ "password_reset": "auth:password_reset",
40
+ "role_acl": "auth:role_acl",
41
+ "user_acl": "auth:user_acl"
43
42
  },
44
43
  "directory": {
45
- "organization": "directory:organization",
46
- "tenant": "directory:tenant"
44
+ "tenant": "directory:tenant",
45
+ "organization": "directory:organization"
47
46
  },
48
47
  "customers": {
49
- "customer_activity": "customers:customer_activity",
50
- "customer_address": "customers:customer_address",
51
- "customer_comment": "customers:customer_comment",
48
+ "customer_entity": "customers:customer_entity",
49
+ "customer_person_profile": "customers:customer_person_profile",
52
50
  "customer_company_profile": "customers:customer_company_profile",
53
51
  "customer_deal": "customers:customer_deal",
54
- "customer_deal_company_link": "customers:customer_deal_company_link",
55
52
  "customer_deal_person_link": "customers:customer_deal_person_link",
56
- "customer_dictionary_entry": "customers:customer_dictionary_entry",
57
- "customer_entity": "customers:customer_entity",
58
- "customer_person_profile": "customers:customer_person_profile",
53
+ "customer_deal_company_link": "customers:customer_deal_company_link",
54
+ "customer_activity": "customers:customer_activity",
55
+ "customer_comment": "customers:customer_comment",
56
+ "customer_address": "customers:customer_address",
59
57
  "customer_settings": "customers:customer_settings",
60
58
  "customer_tag": "customers:customer_tag",
61
59
  "customer_tag_assignment": "customers:customer_tag_assignment",
60
+ "customer_dictionary_entry": "customers:customer_dictionary_entry",
62
61
  "customer_todo_link": "customers:customer_todo_link"
63
62
  },
64
63
  "perspectives": {
@@ -66,10 +65,10 @@ export const E = {
66
65
  "role_perspective": "perspectives:role_perspective"
67
66
  },
68
67
  "entities": {
69
- "custom_entity": "entities:custom_entity",
70
- "custom_entity_storage": "entities:custom_entity_storage",
71
68
  "custom_field_def": "entities:custom_field_def",
72
69
  "custom_field_entity_config": "entities:custom_field_entity_config",
70
+ "custom_entity": "entities:custom_entity",
71
+ "custom_entity_storage": "entities:custom_entity_storage",
73
72
  "custom_field_value": "entities:custom_field_value",
74
73
  "encryption_map": "entities:encryption_map"
75
74
  },
@@ -78,60 +77,60 @@ export const E = {
78
77
  "upgrade_action_run": "configs:upgrade_action_run"
79
78
  },
80
79
  "query_index": {
81
- "entity_index_coverage": "query_index:entity_index_coverage",
82
- "entity_index_job": "query_index:entity_index_job",
83
80
  "entity_index_row": "query_index:entity_index_row",
81
+ "entity_index_job": "query_index:entity_index_job",
82
+ "entity_index_coverage": "query_index:entity_index_coverage",
84
83
  "indexer_error_log": "query_index:indexer_error_log",
85
84
  "indexer_status_log": "query_index:indexer_status_log",
86
85
  "search_token": "query_index:search_token"
87
86
  },
88
87
  "audit_logs": {
89
- "access_log": "audit_logs:access_log",
90
- "action_log": "audit_logs:action_log"
88
+ "action_log": "audit_logs:action_log",
89
+ "access_log": "audit_logs:access_log"
91
90
  },
92
91
  "attachments": {
93
- "attachment": "attachments:attachment",
94
- "attachment_partition": "attachments:attachment_partition"
92
+ "attachment_partition": "attachments:attachment_partition",
93
+ "attachment": "attachments:attachment"
95
94
  },
96
95
  "catalog": {
97
- "catalog_offer": "catalog:catalog_offer",
98
96
  "catalog_option_schema_template": "catalog:catalog_option_schema_template",
99
- "catalog_price_kind": "catalog:catalog_price_kind",
100
97
  "catalog_product": "catalog:catalog_product",
101
98
  "catalog_product_category": "catalog:catalog_product_category",
102
99
  "catalog_product_category_assignment": "catalog:catalog_product_category_assignment",
103
- "catalog_product_price": "catalog:catalog_product_price",
104
100
  "catalog_product_tag": "catalog:catalog_product_tag",
105
101
  "catalog_product_tag_assignment": "catalog:catalog_product_tag_assignment",
102
+ "catalog_offer": "catalog:catalog_offer",
106
103
  "catalog_product_variant": "catalog:catalog_product_variant",
107
- "catalog_product_variant_relation": "catalog:catalog_product_variant_relation"
104
+ "catalog_product_variant_relation": "catalog:catalog_product_variant_relation",
105
+ "catalog_price_kind": "catalog:catalog_price_kind",
106
+ "catalog_product_price": "catalog:catalog_product_price"
108
107
  },
109
108
  "sales": {
110
109
  "sales_channel": "sales:sales_channel",
111
- "sales_credit_memo": "sales:sales_credit_memo",
112
- "sales_credit_memo_line": "sales:sales_credit_memo_line",
110
+ "sales_shipping_method": "sales:sales_shipping_method",
113
111
  "sales_delivery_window": "sales:sales_delivery_window",
114
- "sales_document_address": "sales:sales_document_address",
115
- "sales_document_sequence": "sales:sales_document_sequence",
116
- "sales_document_tag": "sales:sales_document_tag",
117
- "sales_document_tag_assignment": "sales:sales_document_tag_assignment",
118
- "sales_invoice": "sales:sales_invoice",
119
- "sales_invoice_line": "sales:sales_invoice_line",
120
- "sales_note": "sales:sales_note",
112
+ "sales_payment_method": "sales:sales_payment_method",
113
+ "sales_tax_rate": "sales:sales_tax_rate",
121
114
  "sales_order": "sales:sales_order",
122
- "sales_order_adjustment": "sales:sales_order_adjustment",
123
115
  "sales_order_line": "sales:sales_order_line",
124
- "sales_payment": "sales:sales_payment",
125
- "sales_payment_allocation": "sales:sales_payment_allocation",
126
- "sales_payment_method": "sales:sales_payment_method",
116
+ "sales_order_adjustment": "sales:sales_order_adjustment",
117
+ "sales_settings": "sales:sales_settings",
118
+ "sales_document_sequence": "sales:sales_document_sequence",
127
119
  "sales_quote": "sales:sales_quote",
128
- "sales_quote_adjustment": "sales:sales_quote_adjustment",
129
120
  "sales_quote_line": "sales:sales_quote_line",
130
- "sales_settings": "sales:sales_settings",
121
+ "sales_quote_adjustment": "sales:sales_quote_adjustment",
131
122
  "sales_shipment": "sales:sales_shipment",
132
123
  "sales_shipment_item": "sales:sales_shipment_item",
133
- "sales_shipping_method": "sales:sales_shipping_method",
134
- "sales_tax_rate": "sales:sales_tax_rate"
124
+ "sales_invoice": "sales:sales_invoice",
125
+ "sales_invoice_line": "sales:sales_invoice_line",
126
+ "sales_credit_memo": "sales:sales_credit_memo",
127
+ "sales_credit_memo_line": "sales:sales_credit_memo_line",
128
+ "sales_payment": "sales:sales_payment",
129
+ "sales_payment_allocation": "sales:sales_payment_allocation",
130
+ "sales_note": "sales:sales_note",
131
+ "sales_document_address": "sales:sales_document_address",
132
+ "sales_document_tag": "sales:sales_document_tag",
133
+ "sales_document_tag_assignment": "sales:sales_document_tag_assignment"
135
134
  },
136
135
  "api_keys": {
137
136
  "api_key": "api_keys:api_key"
@@ -151,41 +150,38 @@ export const E = {
151
150
  "feature_toggle_override": "feature_toggles:feature_toggle_override"
152
151
  },
153
152
  "workflows": {
153
+ "workflow_definition": "workflows:workflow_definition",
154
+ "workflow_instance": "workflows:workflow_instance",
154
155
  "step_instance": "workflows:step_instance",
155
156
  "user_task": "workflows:user_task",
156
- "workflow_definition": "workflows:workflow_definition",
157
- "workflow_event": "workflows:workflow_event",
158
- "workflow_instance": "workflows:workflow_instance"
157
+ "workflow_event": "workflows:workflow_event"
159
158
  },
160
159
  "currencies": {
161
160
  "currency": "currencies:currency",
162
- "currency_fetch_config": "currencies:currency_fetch_config",
163
- "exchange_rate": "currencies:exchange_rate"
161
+ "exchange_rate": "currencies:exchange_rate",
162
+ "currency_fetch_config": "currencies:currency_fetch_config"
164
163
  },
165
164
  "planner": {
166
- "planner_availability_rule": "planner:planner_availability_rule",
167
- "planner_availability_rule_set": "planner:planner_availability_rule_set"
165
+ "planner_availability_rule_set": "planner:planner_availability_rule_set",
166
+ "planner_availability_rule": "planner:planner_availability_rule"
168
167
  },
169
168
  "resources": {
169
+ "resources_resource_type": "resources:resources_resource_type",
170
170
  "resources_resource": "resources:resources_resource",
171
- "resources_resource_activity": "resources:resources_resource_activity",
172
171
  "resources_resource_comment": "resources:resources_resource_comment",
172
+ "resources_resource_activity": "resources:resources_resource_activity",
173
173
  "resources_resource_tag": "resources:resources_resource_tag",
174
- "resources_resource_tag_assignment": "resources:resources_resource_tag_assignment",
175
- "resources_resource_type": "resources:resources_resource_type"
174
+ "resources_resource_tag_assignment": "resources:resources_resource_tag_assignment"
176
175
  },
177
176
  "staff": {
178
- "staff_leave_request": "staff:staff_leave_request",
179
177
  "staff_team": "staff:staff_team",
178
+ "staff_team_role": "staff:staff_team_role",
180
179
  "staff_team_member": "staff:staff_team_member",
181
- "staff_team_member_activity": "staff:staff_team_member_activity",
182
- "staff_team_member_address": "staff:staff_team_member_address",
180
+ "staff_leave_request": "staff:staff_leave_request",
183
181
  "staff_team_member_comment": "staff:staff_team_member_comment",
182
+ "staff_team_member_activity": "staff:staff_team_member_activity",
184
183
  "staff_team_member_job_history": "staff:staff_team_member_job_history",
185
- "staff_team_role": "staff:staff_team_role"
186
- },
187
- "notifications": {
188
- "notification": "notifications:notification"
184
+ "staff_team_member_address": "staff:staff_team_member_address"
189
185
  }
190
186
  } as const
191
187
  export type KnownModuleId = keyof typeof M
@@ -53,7 +53,6 @@ import * as feature_toggle_override from './entities/feature_toggle_override/ind
53
53
  import * as indexer_error_log from './entities/indexer_error_log/index'
54
54
  import * as indexer_status_log from './entities/indexer_status_log/index'
55
55
  import * as module_config from './entities/module_config/index'
56
- import * as notification from './entities/notification/index'
57
56
  import * as organization from './entities/organization/index'
58
57
  import * as password_reset from './entities/password_reset/index'
59
58
  import * as perspective from './entities/perspective/index'
@@ -173,7 +172,6 @@ export const entityFieldsRegistry: Record<string, Record<string, string>> = {
173
172
  indexer_error_log,
174
173
  indexer_status_log,
175
174
  module_config,
176
- notification,
177
175
  organization,
178
176
  password_reset,
179
177
  perspective,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/core",
3
- "version": "0.4.2-canary-07dbc98202",
3
+ "version": "0.4.2-canary-11e19dfb84",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -207,7 +207,7 @@
207
207
  }
208
208
  },
209
209
  "dependencies": {
210
- "@open-mercato/shared": "0.4.2-canary-07dbc98202",
210
+ "@open-mercato/shared": "0.4.2-canary-11e19dfb84",
211
211
  "@xyflow/react": "^12.6.0",
212
212
  "date-fns": "^4.1.0",
213
213
  "date-fns-tz": "^3.2.0"
@@ -2,7 +2,6 @@ import ApiDocsExplorer from './Explorer'
2
2
  import { getModules } from '@open-mercato/shared/lib/i18n/server'
3
3
  import { buildOpenApiDocument } from '@open-mercato/shared/lib/openapi'
4
4
  import { resolveApiDocsBaseUrl } from '@open-mercato/core/modules/api_docs/lib/resources'
5
- import { APP_VERSION } from '@open-mercato/shared/lib/version'
6
5
 
7
6
  type ExplorerOperation = {
8
7
  id: string
@@ -55,7 +54,7 @@ export default async function ApiDocsViewerPage() {
55
54
  const modules = getModules()
56
55
  const doc = buildOpenApiDocument(modules, {
57
56
  title: 'Open Mercato API',
58
- version: APP_VERSION,
57
+ version: '1.0.0',
59
58
  description: 'Auto-generated OpenAPI definition for all enabled modules.',
60
59
  servers: [{ url: baseUrl, description: 'Default environment' }],
61
60
  baseUrlForExamples: baseUrl,
@@ -68,7 +67,7 @@ export default async function ApiDocsViewerPage() {
68
67
  return (
69
68
  <ApiDocsExplorer
70
69
  title={doc.info?.title ?? 'Open Mercato API'}
71
- version={doc.info?.version ?? APP_VERSION}
70
+ version={doc.info?.version ?? '1.0.0'}
72
71
  description={doc.info?.description}
73
72
  operations={operations}
74
73
  tagOrder={tagOrder}
@@ -297,16 +297,12 @@ export async function GET(req: Request) {
297
297
  const groupsWithRole = rolePreference ? applySidebarPreference(groups, rolePreference) : groups
298
298
  const baseForUser = adoptSidebarDefaults(groupsWithRole)
299
299
 
300
- // For API key auth, use userId (the actual user) if available; otherwise skip user preferences
301
- const effectiveUserId = auth.isApiKey ? auth.userId : auth.sub
302
- const preference = effectiveUserId
303
- ? await loadSidebarPreference(em, {
304
- userId: effectiveUserId,
305
- tenantId: auth.tenantId ?? null,
306
- organizationId: auth.orgId ?? null,
307
- locale,
308
- })
309
- : null
300
+ const preference = await loadSidebarPreference(em, {
301
+ userId: auth.sub,
302
+ tenantId: auth.tenantId ?? null,
303
+ organizationId: auth.orgId ?? null,
304
+ locale,
305
+ })
310
306
 
311
307
  const withPreference = applySidebarPreference(baseForUser, preference)
312
308
 
@@ -3,9 +3,6 @@ import { NextResponse } from 'next/server'
3
3
  import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
4
4
  import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
5
5
  import { AuthService } from '@open-mercato/core/modules/auth/services/authService'
6
- import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'
7
- import { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'
8
- import notificationTypes from '@open-mercato/core/modules/auth/notifications'
9
6
  import { z } from 'zod'
10
7
 
11
8
  // validation via confirmPasswordResetSchema
@@ -18,28 +15,8 @@ export async function POST(req: Request) {
18
15
  if (!parsed.success) return NextResponse.json({ ok: false, error: 'Invalid request' }, { status: 400 })
19
16
  const c = await createRequestContainer()
20
17
  const auth = c.resolve<AuthService>('authService')
21
- const user = await auth.confirmPasswordReset(parsed.data.token, parsed.data.password)
22
- if (!user) return NextResponse.json({ ok: false, error: 'Invalid or expired token' }, { status: 400 })
23
- try {
24
- const tenantId = user.tenantId ? String(user.tenantId) : null
25
- if (tenantId) {
26
- const notificationService = resolveNotificationService(c)
27
- const typeDef = notificationTypes.find((type) => type.type === 'auth.password_reset.completed')
28
- if (typeDef) {
29
- const notificationInput = buildNotificationFromType(typeDef, {
30
- recipientUserId: String(user.id),
31
- sourceEntityType: 'auth:user',
32
- sourceEntityId: String(user.id),
33
- })
34
- await notificationService.create(notificationInput, {
35
- tenantId,
36
- organizationId: user.organizationId ? String(user.organizationId) : null,
37
- })
38
- }
39
- }
40
- } catch (err) {
41
- console.error('[auth.reset.confirm] Failed to create notification:', err)
42
- }
18
+ const ok = await auth.confirmPasswordReset(parsed.data.token, parsed.data.password)
19
+ if (!ok) return NextResponse.json({ ok: false, error: 'Invalid or expired token' }, { status: 400 })
43
20
  return NextResponse.json({ ok: true, redirect: '/login' })
44
21
  }
45
22
 
@@ -6,9 +6,6 @@ import { AuthService } from '@open-mercato/core/modules/auth/services/authServic
6
6
  import { sendEmail } from '@open-mercato/shared/lib/email/send'
7
7
  import ResetPasswordEmail from '@open-mercato/core/modules/auth/emails/ResetPasswordEmail'
8
8
  import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
9
- import { buildNotificationFromType } from '@open-mercato/core/modules/notifications/lib/notificationBuilder'
10
- import { resolveNotificationService } from '@open-mercato/core/modules/notifications/lib/notificationService'
11
- import notificationTypes from '@open-mercato/core/modules/auth/notifications'
12
9
  import { z } from 'zod'
13
10
 
14
11
  // validation via requestPasswordResetSchema
@@ -38,26 +35,6 @@ export async function POST(req: Request) {
38
35
  }
39
36
 
40
37
  await sendEmail({ to: user.email, subject, react: ResetPasswordEmail({ resetUrl, copy }) })
41
- try {
42
- const tenantId = user.tenantId ? String(user.tenantId) : null
43
- if (tenantId) {
44
- const notificationService = resolveNotificationService(c)
45
- const typeDef = notificationTypes.find((type) => type.type === 'auth.password_reset.requested')
46
- if (typeDef) {
47
- const notificationInput = buildNotificationFromType(typeDef, {
48
- recipientUserId: String(user.id),
49
- sourceEntityType: 'auth:user',
50
- sourceEntityId: String(user.id),
51
- })
52
- await notificationService.create(notificationInput, {
53
- tenantId,
54
- organizationId: user.organizationId ? String(user.organizationId) : null,
55
- })
56
- }
57
- }
58
- } catch (err) {
59
- console.error('[auth.reset] Failed to create notification:', err)
60
- }
61
38
  return NextResponse.json({ ok: true })
62
39
  }
63
40