@frigear-nu/shifts 0.0.0-stage → 0.0.1

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 (345) hide show
  1. package/README.md +53 -2
  2. package/dist/module.d.mts +716 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +272 -0
  5. package/dist/runtime/access.d.ts +2 -0
  6. package/dist/runtime/access.js +84 -0
  7. package/dist/runtime/app/components/ShiftBroadcastSlideover.d.vue.ts +19 -0
  8. package/dist/runtime/app/components/ShiftBroadcastSlideover.vue +142 -0
  9. package/dist/runtime/app/components/ShiftBroadcastSlideover.vue.d.ts +19 -0
  10. package/dist/runtime/app/components/ShiftBroadcastsCard.d.vue.ts +9 -0
  11. package/dist/runtime/app/components/ShiftBroadcastsCard.vue +74 -0
  12. package/dist/runtime/app/components/ShiftBroadcastsCard.vue.d.ts +9 -0
  13. package/dist/runtime/app/components/ShiftBulkSlideover.d.vue.ts +15 -0
  14. package/dist/runtime/app/components/ShiftBulkSlideover.vue +185 -0
  15. package/dist/runtime/app/components/ShiftBulkSlideover.vue.d.ts +15 -0
  16. package/dist/runtime/app/components/ShiftCheckInCard.d.vue.ts +13 -0
  17. package/dist/runtime/app/components/ShiftCheckInCard.vue +238 -0
  18. package/dist/runtime/app/components/ShiftCheckInCard.vue.d.ts +13 -0
  19. package/dist/runtime/app/components/ShiftCopySlideover.d.vue.ts +11 -0
  20. package/dist/runtime/app/components/ShiftCopySlideover.vue +71 -0
  21. package/dist/runtime/app/components/ShiftCopySlideover.vue.d.ts +11 -0
  22. package/dist/runtime/app/components/ShiftDayView.d.vue.ts +16 -0
  23. package/dist/runtime/app/components/ShiftDayView.vue +124 -0
  24. package/dist/runtime/app/components/ShiftDayView.vue.d.ts +16 -0
  25. package/dist/runtime/app/components/ShiftFeedSlideover.d.vue.ts +7 -0
  26. package/dist/runtime/app/components/ShiftFeedSlideover.vue +172 -0
  27. package/dist/runtime/app/components/ShiftFeedSlideover.vue.d.ts +7 -0
  28. package/dist/runtime/app/components/ShiftNowCard.d.vue.ts +6 -0
  29. package/dist/runtime/app/components/ShiftNowCard.vue +83 -0
  30. package/dist/runtime/app/components/ShiftNowCard.vue.d.ts +6 -0
  31. package/dist/runtime/app/components/ShiftPassFullscreen.d.vue.ts +13 -0
  32. package/dist/runtime/app/components/ShiftPassFullscreen.vue +79 -0
  33. package/dist/runtime/app/components/ShiftPassFullscreen.vue.d.ts +13 -0
  34. package/dist/runtime/app/components/ShiftPerkSlideover.d.vue.ts +14 -0
  35. package/dist/runtime/app/components/ShiftPerkSlideover.vue +103 -0
  36. package/dist/runtime/app/components/ShiftPerkSlideover.vue.d.ts +14 -0
  37. package/dist/runtime/app/components/ShiftPerksCard.d.vue.ts +8 -0
  38. package/dist/runtime/app/components/ShiftPerksCard.vue +66 -0
  39. package/dist/runtime/app/components/ShiftPerksCard.vue.d.ts +8 -0
  40. package/dist/runtime/app/components/ShiftQrScanner.d.vue.ts +10 -0
  41. package/dist/runtime/app/components/ShiftQrScanner.vue +44 -0
  42. package/dist/runtime/app/components/ShiftQrScanner.vue.d.ts +10 -0
  43. package/dist/runtime/app/components/ShiftRoleSlideover.d.vue.ts +15 -0
  44. package/dist/runtime/app/components/ShiftRoleSlideover.vue +88 -0
  45. package/dist/runtime/app/components/ShiftRoleSlideover.vue.d.ts +15 -0
  46. package/dist/runtime/app/components/ShiftScheduleSettingsFields.d.vue.ts +11 -0
  47. package/dist/runtime/app/components/ShiftScheduleSettingsFields.vue +61 -0
  48. package/dist/runtime/app/components/ShiftScheduleSettingsFields.vue.d.ts +11 -0
  49. package/dist/runtime/app/components/ShiftScheduleSlideover.d.vue.ts +12 -0
  50. package/dist/runtime/app/components/ShiftScheduleSlideover.vue +129 -0
  51. package/dist/runtime/app/components/ShiftScheduleSlideover.vue.d.ts +12 -0
  52. package/dist/runtime/app/components/ShiftSlideover.d.vue.ts +13 -0
  53. package/dist/runtime/app/components/ShiftSlideover.vue +353 -0
  54. package/dist/runtime/app/components/ShiftSlideover.vue.d.ts +13 -0
  55. package/dist/runtime/app/components/ShiftStationSlideover.d.vue.ts +15 -0
  56. package/dist/runtime/app/components/ShiftStationSlideover.vue +92 -0
  57. package/dist/runtime/app/components/ShiftStationSlideover.vue.d.ts +15 -0
  58. package/dist/runtime/app/composables/index.d.ts +6 -0
  59. package/dist/runtime/app/composables/index.js +5 -0
  60. package/dist/runtime/app/composables/useShiftsActions.d.ts +61 -0
  61. package/dist/runtime/app/composables/useShiftsActions.js +224 -0
  62. package/dist/runtime/app/composables/useShiftsFormat.d.ts +12 -0
  63. package/dist/runtime/app/composables/useShiftsFormat.js +14 -0
  64. package/dist/runtime/app/composables/useShiftsLinks.d.ts +12 -0
  65. package/dist/runtime/app/composables/useShiftsLinks.js +6 -0
  66. package/dist/runtime/app/composables/useShiftsTranslate.d.ts +5 -0
  67. package/dist/runtime/app/composables/useShiftsTranslate.js +12 -0
  68. package/dist/runtime/app/composables/useShiftsVenueFeatures.d.ts +17 -0
  69. package/dist/runtime/app/composables/useShiftsVenueFeatures.js +18 -0
  70. package/dist/runtime/app/dashboard/NextShift.d.vue.ts +3 -0
  71. package/dist/runtime/app/dashboard/NextShift.vue +69 -0
  72. package/dist/runtime/app/dashboard/NextShift.vue.d.ts +3 -0
  73. package/dist/runtime/app/dashboard/OpenSwaps.d.vue.ts +3 -0
  74. package/dist/runtime/app/dashboard/OpenSwaps.vue +69 -0
  75. package/dist/runtime/app/dashboard/OpenSwaps.vue.d.ts +3 -0
  76. package/dist/runtime/app/dashboard/TeamOnNow.d.vue.ts +3 -0
  77. package/dist/runtime/app/dashboard/TeamOnNow.vue +72 -0
  78. package/dist/runtime/app/dashboard/TeamOnNow.vue.d.ts +3 -0
  79. package/dist/runtime/app/pages/check-in.d.vue.ts +3 -0
  80. package/dist/runtime/app/pages/check-in.vue +93 -0
  81. package/dist/runtime/app/pages/check-in.vue.d.ts +3 -0
  82. package/dist/runtime/app/pages/lead.d.vue.ts +3 -0
  83. package/dist/runtime/app/pages/lead.vue +300 -0
  84. package/dist/runtime/app/pages/lead.vue.d.ts +3 -0
  85. package/dist/runtime/app/pages/shift.d.vue.ts +3 -0
  86. package/dist/runtime/app/pages/shift.vue +482 -0
  87. package/dist/runtime/app/pages/shift.vue.d.ts +3 -0
  88. package/dist/runtime/app/pages/shifts.d.vue.ts +3 -0
  89. package/dist/runtime/app/pages/shifts.vue +21 -0
  90. package/dist/runtime/app/pages/shifts.vue.d.ts +3 -0
  91. package/dist/runtime/app/pages/station.d.vue.ts +3 -0
  92. package/dist/runtime/app/pages/station.vue +104 -0
  93. package/dist/runtime/app/pages/station.vue.d.ts +3 -0
  94. package/dist/runtime/app/pages/swaps.d.vue.ts +3 -0
  95. package/dist/runtime/app/pages/swaps.vue +32 -0
  96. package/dist/runtime/app/pages/swaps.vue.d.ts +3 -0
  97. package/dist/runtime/app/tabs/HomeShifts.d.vue.ts +6 -0
  98. package/dist/runtime/app/tabs/HomeShifts.vue +194 -0
  99. package/dist/runtime/app/tabs/HomeShifts.vue.d.ts +6 -0
  100. package/dist/runtime/app/tabs/HomeSwaps.d.vue.ts +3 -0
  101. package/dist/runtime/app/tabs/HomeSwaps.vue +188 -0
  102. package/dist/runtime/app/tabs/HomeSwaps.vue.d.ts +3 -0
  103. package/dist/runtime/app/tabs/Shifts.d.vue.ts +9 -0
  104. package/dist/runtime/app/tabs/Shifts.vue +487 -0
  105. package/dist/runtime/app/tabs/Shifts.vue.d.ts +9 -0
  106. package/dist/runtime/app/utils/admin-shifts.d.ts +42 -0
  107. package/dist/runtime/app/utils/admin-shifts.js +36 -0
  108. package/dist/runtime/dashboard.d.ts +8 -0
  109. package/dist/runtime/dashboard.js +30 -0
  110. package/dist/runtime/emails/shifts-broadcast.d.vue.ts +8 -0
  111. package/dist/runtime/emails/shifts-broadcast.vue +24 -0
  112. package/dist/runtime/emails/shifts-broadcast.vue.d.ts +8 -0
  113. package/dist/runtime/emails/shifts-reminder.d.vue.ts +12 -0
  114. package/dist/runtime/emails/shifts-reminder.vue +34 -0
  115. package/dist/runtime/emails/shifts-reminder.vue.d.ts +12 -0
  116. package/dist/runtime/emails/shifts-swap-accepted.d.vue.ts +11 -0
  117. package/dist/runtime/emails/shifts-swap-accepted.vue +32 -0
  118. package/dist/runtime/emails/shifts-swap-accepted.vue.d.ts +11 -0
  119. package/dist/runtime/emails/shifts-swap-completed.d.vue.ts +11 -0
  120. package/dist/runtime/emails/shifts-swap-completed.vue +32 -0
  121. package/dist/runtime/emails/shifts-swap-completed.vue.d.ts +11 -0
  122. package/dist/runtime/emails/shifts-swap-offered.d.vue.ts +11 -0
  123. package/dist/runtime/emails/shifts-swap-offered.vue +32 -0
  124. package/dist/runtime/emails/shifts-swap-offered.vue.d.ts +11 -0
  125. package/dist/runtime/emails/shifts-swap-pending.d.vue.ts +11 -0
  126. package/dist/runtime/emails/shifts-swap-pending.vue +32 -0
  127. package/dist/runtime/emails/shifts-swap-pending.vue.d.ts +11 -0
  128. package/dist/runtime/emails/shifts-swap-proposed.d.vue.ts +11 -0
  129. package/dist/runtime/emails/shifts-swap-proposed.vue +32 -0
  130. package/dist/runtime/emails/shifts-swap-proposed.vue.d.ts +11 -0
  131. package/dist/runtime/emails/shifts-swap-rejected.d.vue.ts +11 -0
  132. package/dist/runtime/emails/shifts-swap-rejected.vue +32 -0
  133. package/dist/runtime/emails/shifts-swap-rejected.vue.d.ts +11 -0
  134. package/dist/runtime/i18n/lang/da.json +627 -0
  135. package/dist/runtime/i18n/lang/en.json +627 -0
  136. package/dist/runtime/notifications.d.ts +9 -0
  137. package/dist/runtime/notifications.js +36 -0
  138. package/dist/runtime/server/db/schema.postgresql.d.ts +2151 -0
  139. package/dist/runtime/server/db/schema.postgresql.js +228 -0
  140. package/dist/runtime/server/db/schema.sqlite.d.ts +2263 -0
  141. package/dist/runtime/server/db/schema.sqlite.js +228 -0
  142. package/dist/runtime/server/digest-email.d.ts +17 -0
  143. package/dist/runtime/server/digest-email.js +42 -0
  144. package/dist/runtime/server/plugins/station-key.d.ts +2 -0
  145. package/dist/runtime/server/plugins/station-key.js +5 -0
  146. package/dist/runtime/server/plugins/teams.d.ts +2 -0
  147. package/dist/runtime/server/plugins/teams.js +19 -0
  148. package/dist/runtime/server/policies.d.ts +2 -0
  149. package/dist/runtime/server/policies.js +41 -0
  150. package/dist/runtime/server/reminder-email.d.ts +67 -0
  151. package/dist/runtime/server/reminder-email.js +109 -0
  152. package/dist/runtime/server/routes/admin/assignment.delete.d.ts +2 -0
  153. package/dist/runtime/server/routes/admin/assignment.delete.js +10 -0
  154. package/dist/runtime/server/routes/admin/assignments.post.d.ts +2 -0
  155. package/dist/runtime/server/routes/admin/assignments.post.js +11 -0
  156. package/dist/runtime/server/routes/admin/broadcasts.get.d.ts +2 -0
  157. package/dist/runtime/server/routes/admin/broadcasts.get.js +8 -0
  158. package/dist/runtime/server/routes/admin/broadcasts.post.d.ts +2 -0
  159. package/dist/runtime/server/routes/admin/broadcasts.post.js +9 -0
  160. package/dist/runtime/server/routes/admin/candidates.get.d.ts +2 -0
  161. package/dist/runtime/server/routes/admin/candidates.get.js +10 -0
  162. package/dist/runtime/server/routes/admin/operation-teams.get.d.ts +2 -0
  163. package/dist/runtime/server/routes/admin/operation-teams.get.js +9 -0
  164. package/dist/runtime/server/routes/admin/perk.delete.d.ts +2 -0
  165. package/dist/runtime/server/routes/admin/perk.delete.js +10 -0
  166. package/dist/runtime/server/routes/admin/perk.patch.d.ts +2 -0
  167. package/dist/runtime/server/routes/admin/perk.patch.js +10 -0
  168. package/dist/runtime/server/routes/admin/perks.get.d.ts +2 -0
  169. package/dist/runtime/server/routes/admin/perks.get.js +9 -0
  170. package/dist/runtime/server/routes/admin/perks.post.d.ts +2 -0
  171. package/dist/runtime/server/routes/admin/perks.post.js +10 -0
  172. package/dist/runtime/server/routes/admin/role.delete.d.ts +2 -0
  173. package/dist/runtime/server/routes/admin/role.delete.js +11 -0
  174. package/dist/runtime/server/routes/admin/role.patch.d.ts +2 -0
  175. package/dist/runtime/server/routes/admin/role.patch.js +11 -0
  176. package/dist/runtime/server/routes/admin/roles.get.d.ts +2 -0
  177. package/dist/runtime/server/routes/admin/roles.get.js +9 -0
  178. package/dist/runtime/server/routes/admin/roles.post.d.ts +2 -0
  179. package/dist/runtime/server/routes/admin/roles.post.js +10 -0
  180. package/dist/runtime/server/routes/admin/schedule-copy.post.d.ts +2 -0
  181. package/dist/runtime/server/routes/admin/schedule-copy.post.js +12 -0
  182. package/dist/runtime/server/routes/admin/schedule-publish.post.d.ts +2 -0
  183. package/dist/runtime/server/routes/admin/schedule-publish.post.js +9 -0
  184. package/dist/runtime/server/routes/admin/schedule.delete.d.ts +2 -0
  185. package/dist/runtime/server/routes/admin/schedule.delete.js +10 -0
  186. package/dist/runtime/server/routes/admin/schedule.get.d.ts +2 -0
  187. package/dist/runtime/server/routes/admin/schedule.get.js +9 -0
  188. package/dist/runtime/server/routes/admin/schedule.patch.d.ts +2 -0
  189. package/dist/runtime/server/routes/admin/schedule.patch.js +10 -0
  190. package/dist/runtime/server/routes/admin/schedules.get.d.ts +2 -0
  191. package/dist/runtime/server/routes/admin/schedules.get.js +10 -0
  192. package/dist/runtime/server/routes/admin/schedules.post.d.ts +2 -0
  193. package/dist/runtime/server/routes/admin/schedules.post.js +9 -0
  194. package/dist/runtime/server/routes/admin/shift.delete.d.ts +2 -0
  195. package/dist/runtime/server/routes/admin/shift.delete.js +10 -0
  196. package/dist/runtime/server/routes/admin/shift.patch.d.ts +2 -0
  197. package/dist/runtime/server/routes/admin/shift.patch.js +10 -0
  198. package/dist/runtime/server/routes/admin/shifts-bulk.post.d.ts +2 -0
  199. package/dist/runtime/server/routes/admin/shifts-bulk.post.js +10 -0
  200. package/dist/runtime/server/routes/admin/shifts.get.d.ts +2 -0
  201. package/dist/runtime/server/routes/admin/shifts.get.js +10 -0
  202. package/dist/runtime/server/routes/admin/station.delete.d.ts +2 -0
  203. package/dist/runtime/server/routes/admin/station.delete.js +11 -0
  204. package/dist/runtime/server/routes/admin/station.patch.d.ts +2 -0
  205. package/dist/runtime/server/routes/admin/station.patch.js +11 -0
  206. package/dist/runtime/server/routes/admin/stations.get.d.ts +2 -0
  207. package/dist/runtime/server/routes/admin/stations.get.js +9 -0
  208. package/dist/runtime/server/routes/admin/stations.post.d.ts +2 -0
  209. package/dist/runtime/server/routes/admin/stations.post.js +10 -0
  210. package/dist/runtime/server/routes/admin/swap-cancel.post.d.ts +2 -0
  211. package/dist/runtime/server/routes/admin/swap-cancel.post.js +10 -0
  212. package/dist/runtime/server/routes/admin/swaps.get.d.ts +2 -0
  213. package/dist/runtime/server/routes/admin/swaps.get.js +10 -0
  214. package/dist/runtime/server/routes/feed/feed.get.d.ts +2 -0
  215. package/dist/runtime/server/routes/feed/feed.get.js +9 -0
  216. package/dist/runtime/server/routes/lead/attended.post.d.ts +2 -0
  217. package/dist/runtime/server/routes/lead/attended.post.js +11 -0
  218. package/dist/runtime/server/routes/lead/broadcast.post.d.ts +2 -0
  219. package/dist/runtime/server/routes/lead/broadcast.post.js +12 -0
  220. package/dist/runtime/server/routes/lead/check-in.post.d.ts +2 -0
  221. package/dist/runtime/server/routes/lead/check-in.post.js +9 -0
  222. package/dist/runtime/server/routes/lead/exceptions.get.d.ts +2 -0
  223. package/dist/runtime/server/routes/lead/exceptions.get.js +8 -0
  224. package/dist/runtime/server/routes/lead/no-show.post.d.ts +2 -0
  225. package/dist/runtime/server/routes/lead/no-show.post.js +11 -0
  226. package/dist/runtime/server/routes/lead/now.get.d.ts +2 -0
  227. package/dist/runtime/server/routes/lead/now.get.js +9 -0
  228. package/dist/runtime/server/routes/lead/on-duty.get.d.ts +2 -0
  229. package/dist/runtime/server/routes/lead/on-duty.get.js +10 -0
  230. package/dist/runtime/server/routes/lead/stations.get.d.ts +2 -0
  231. package/dist/runtime/server/routes/lead/stations.get.js +8 -0
  232. package/dist/runtime/server/routes/lead/team-shifts.get.d.ts +2 -0
  233. package/dist/runtime/server/routes/lead/team-shifts.get.js +9 -0
  234. package/dist/runtime/server/routes/lead/team-swaps.get.d.ts +2 -0
  235. package/dist/runtime/server/routes/lead/team-swaps.get.js +9 -0
  236. package/dist/runtime/server/routes/me/check-in.post.d.ts +2 -0
  237. package/dist/runtime/server/routes/me/check-in.post.js +11 -0
  238. package/dist/runtime/server/routes/me/earned-perk-claim.post.d.ts +2 -0
  239. package/dist/runtime/server/routes/me/earned-perk-claim.post.js +10 -0
  240. package/dist/runtime/server/routes/me/earned-perks.get.d.ts +2 -0
  241. package/dist/runtime/server/routes/me/earned-perks.get.js +9 -0
  242. package/dist/runtime/server/routes/me/feed-token.delete.d.ts +2 -0
  243. package/dist/runtime/server/routes/me/feed-token.delete.js +7 -0
  244. package/dist/runtime/server/routes/me/feed-token.get.d.ts +2 -0
  245. package/dist/runtime/server/routes/me/feed-token.get.js +6 -0
  246. package/dist/runtime/server/routes/me/feed-token.post.d.ts +2 -0
  247. package/dist/runtime/server/routes/me/feed-token.post.js +7 -0
  248. package/dist/runtime/server/routes/me/leads.get.d.ts +2 -0
  249. package/dist/runtime/server/routes/me/leads.get.js +5 -0
  250. package/dist/runtime/server/routes/me/now.get.d.ts +2 -0
  251. package/dist/runtime/server/routes/me/now.get.js +5 -0
  252. package/dist/runtime/server/routes/me/pass.get.d.ts +2 -0
  253. package/dist/runtime/server/routes/me/pass.get.js +11 -0
  254. package/dist/runtime/server/routes/me/settle.post.d.ts +2 -0
  255. package/dist/runtime/server/routes/me/settle.post.js +14 -0
  256. package/dist/runtime/server/routes/me/shift.get.d.ts +2 -0
  257. package/dist/runtime/server/routes/me/shift.get.js +10 -0
  258. package/dist/runtime/server/routes/me/shifts.get.d.ts +2 -0
  259. package/dist/runtime/server/routes/me/shifts.get.js +6 -0
  260. package/dist/runtime/server/routes/me/swap.delete.d.ts +2 -0
  261. package/dist/runtime/server/routes/me/swap.delete.js +11 -0
  262. package/dist/runtime/server/routes/me/swap.post.d.ts +2 -0
  263. package/dist/runtime/server/routes/me/swap.post.js +11 -0
  264. package/dist/runtime/server/routes/stations/token.get.d.ts +2 -0
  265. package/dist/runtime/server/routes/stations/token.get.js +12 -0
  266. package/dist/runtime/server/routes/swaps/approve.post.d.ts +2 -0
  267. package/dist/runtime/server/routes/swaps/approve.post.js +9 -0
  268. package/dist/runtime/server/routes/swaps/list.get.d.ts +2 -0
  269. package/dist/runtime/server/routes/swaps/list.get.js +5 -0
  270. package/dist/runtime/server/routes/swaps/offer-accept.post.d.ts +2 -0
  271. package/dist/runtime/server/routes/swaps/offer-accept.post.js +9 -0
  272. package/dist/runtime/server/routes/swaps/offer-reject.post.d.ts +2 -0
  273. package/dist/runtime/server/routes/swaps/offer-reject.post.js +9 -0
  274. package/dist/runtime/server/routes/swaps/offer.delete.d.ts +2 -0
  275. package/dist/runtime/server/routes/swaps/offer.delete.js +11 -0
  276. package/dist/runtime/server/routes/swaps/offer.post.d.ts +2 -0
  277. package/dist/runtime/server/routes/swaps/offer.post.js +11 -0
  278. package/dist/runtime/server/routes/swaps/reject.post.d.ts +2 -0
  279. package/dist/runtime/server/routes/swaps/reject.post.js +9 -0
  280. package/dist/runtime/server/swap-email.d.ts +28 -0
  281. package/dist/runtime/server/swap-email.js +49 -0
  282. package/dist/runtime/server/tasks/close-shifts.d.ts +2 -0
  283. package/dist/runtime/server/tasks/close-shifts.js +9 -0
  284. package/dist/runtime/server/tasks/send-reminders.d.ts +2 -0
  285. package/dist/runtime/server/tasks/send-reminders.js +9 -0
  286. package/dist/runtime/server/utils/shifts-admin.d.ts +67 -0
  287. package/dist/runtime/server/utils/shifts-admin.js +312 -0
  288. package/dist/runtime/server/utils/shifts-assign.d.ts +89 -0
  289. package/dist/runtime/server/utils/shifts-assign.js +264 -0
  290. package/dist/runtime/server/utils/shifts-automation.d.ts +37 -0
  291. package/dist/runtime/server/utils/shifts-automation.js +171 -0
  292. package/dist/runtime/server/utils/shifts-broadcasts.d.ts +38 -0
  293. package/dist/runtime/server/utils/shifts-broadcasts.js +113 -0
  294. package/dist/runtime/server/utils/shifts-core.d.ts +78 -0
  295. package/dist/runtime/server/utils/shifts-core.js +142 -0
  296. package/dist/runtime/server/utils/shifts-dto.d.ts +32 -0
  297. package/dist/runtime/server/utils/shifts-dto.js +127 -0
  298. package/dist/runtime/server/utils/shifts-emails.d.ts +16 -0
  299. package/dist/runtime/server/utils/shifts-emails.js +44 -0
  300. package/dist/runtime/server/utils/shifts-exceptions.d.ts +7 -0
  301. package/dist/runtime/server/utils/shifts-exceptions.js +32 -0
  302. package/dist/runtime/server/utils/shifts-feed.d.ts +16 -0
  303. package/dist/runtime/server/utils/shifts-feed.js +73 -0
  304. package/dist/runtime/server/utils/shifts-notify.d.ts +40 -0
  305. package/dist/runtime/server/utils/shifts-notify.js +22 -0
  306. package/dist/runtime/server/utils/shifts-on-duty.d.ts +12 -0
  307. package/dist/runtime/server/utils/shifts-on-duty.js +37 -0
  308. package/dist/runtime/server/utils/shifts-perks.d.ts +46 -0
  309. package/dist/runtime/server/utils/shifts-perks.js +183 -0
  310. package/dist/runtime/server/utils/shifts-reminders.d.ts +30 -0
  311. package/dist/runtime/server/utils/shifts-reminders.js +102 -0
  312. package/dist/runtime/server/utils/shifts-schemas.d.ts +318 -0
  313. package/dist/runtime/server/utils/shifts-schemas.js +177 -0
  314. package/dist/runtime/server/utils/shifts-station-key.d.ts +7 -0
  315. package/dist/runtime/server/utils/shifts-station-key.js +22 -0
  316. package/dist/runtime/server/utils/shifts-stations.d.ts +28 -0
  317. package/dist/runtime/server/utils/shifts-stations.js +109 -0
  318. package/dist/runtime/server/utils/shifts-swaps.d.ts +114 -0
  319. package/dist/runtime/server/utils/shifts-swaps.js +559 -0
  320. package/dist/runtime/server/utils/shifts-views.d.ts +62 -0
  321. package/dist/runtime/server/utils/shifts-views.js +212 -0
  322. package/dist/runtime/utils/api.d.ts +108 -0
  323. package/dist/runtime/utils/api.js +111 -0
  324. package/dist/runtime/utils/checkin.d.ts +59 -0
  325. package/dist/runtime/utils/checkin.js +57 -0
  326. package/dist/runtime/utils/guards.d.ts +21 -0
  327. package/dist/runtime/utils/guards.js +36 -0
  328. package/dist/runtime/utils/ics.d.ts +32 -0
  329. package/dist/runtime/utils/ics.js +56 -0
  330. package/dist/runtime/utils/index.d.ts +16 -0
  331. package/dist/runtime/utils/index.js +15 -0
  332. package/dist/runtime/utils/links.d.ts +44 -0
  333. package/dist/runtime/utils/links.js +21 -0
  334. package/dist/runtime/utils/reminders.d.ts +27 -0
  335. package/dist/runtime/utils/reminders.js +28 -0
  336. package/dist/runtime/utils/settings.d.ts +28 -0
  337. package/dist/runtime/utils/settings.js +18 -0
  338. package/dist/runtime/utils/station-key.d.ts +9 -0
  339. package/dist/runtime/utils/station-key.js +12 -0
  340. package/dist/runtime/utils/status.d.ts +23 -0
  341. package/dist/runtime/utils/status.js +46 -0
  342. package/dist/runtime/utils/time.d.ts +22 -0
  343. package/dist/runtime/utils/time.js +14 -0
  344. package/dist/types.d.mts +5 -0
  345. package/package.json +131 -3
@@ -0,0 +1,228 @@
1
+ import { sqliteTable, text, integer, index, uniqueIndex } from "drizzle-orm/sqlite-core";
2
+ export const shiftSchedules = sqliteTable("shift_schedules", {
3
+ /** `shs_` + random id. */
4
+ id: text().primaryKey(),
5
+ operationId: text().notNull(),
6
+ name: text({ mode: "json" }).$type().notNull(),
7
+ /** `draft` (staff only) or `published` (volunteers see their shifts). */
8
+ status: text().notNull().default("draft"),
9
+ /** `all`: volunteers work every shift they hold, nothing they do lowers their count (trades only). `flexible`. */
10
+ coverage: text().notNull().default("flexible"),
11
+ /** How shifts change hands: `trade` (shift for shift), `release` (give away or take over) or `both`. */
12
+ handover: text().notNull().default("both"),
13
+ /** `peer`: a swap completes when the owner accepts an offer. `lead`: a lead of the team or staff approves it too. */
14
+ approval: text().notNull().default("peer"),
15
+ /** Fewer people than this on a shift shows it as short-staffed. */
16
+ minPerShift: integer(),
17
+ /** The capacity of a shift that sets none; `null` is unlimited. */
18
+ maxPerShift: integer(),
19
+ guards: text({ mode: "json" }).$type(),
20
+ /** How people check in: the modes, the place of `location` mode and per-team overrides (`ShiftCheckInSettings`). `null` is the lead's scanner only. */
21
+ checkIn: text({ mode: "json" }).$type(),
22
+ /** Mark assignments still `assigned` without a check-in `autoNoShowMinutes` after the start as `no_show` (the `shifts:close-shifts` task). */
23
+ autoNoShow: integer({ mode: "boolean" }).notNull().default(false),
24
+ autoNoShowMinutes: integer().notNull().default(30),
25
+ publishedAt: integer({ mode: "timestamp" }),
26
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
27
+ updatedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
28
+ }, (t) => [
29
+ index("shift_schedule_operation_idx").on(t.operationId)
30
+ ]);
31
+ export const shiftRoles = sqliteTable("shift_roles", {
32
+ /** `shr_` + random id. */
33
+ id: text().primaryKey(),
34
+ scheduleId: text().notNull(),
35
+ teamId: text().notNull(),
36
+ /** The lowest role of the team kind's ladder that may hold it; `null` is anybody on the team. */
37
+ teamRole: text(),
38
+ name: text({ mode: "json" }).$type().notNull(),
39
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
40
+ }, (t) => [
41
+ index("shift_role_schedule_idx").on(t.scheduleId)
42
+ ]);
43
+ export const shifts = sqliteTable("shifts", {
44
+ /** `shf_` + random id. */
45
+ id: text().primaryKey(),
46
+ scheduleId: text().notNull(),
47
+ teamId: text().notNull(),
48
+ /** The role a new assignment holds unless staff pick another; `null` is anybody on the team. */
49
+ shiftRoleId: text(),
50
+ startsAt: integer({ mode: "timestamp" }).notNull(),
51
+ endsAt: integer({ mode: "timestamp" }).notNull(),
52
+ location: text({ mode: "json" }).$type(),
53
+ /** How many people the shift takes; `null` is the schedule's `maxPerShift`. */
54
+ capacity: integer(),
55
+ notes: text({ mode: "json" }).$type(),
56
+ /** When the `shifts:close-shifts` task handled the shift's end (earned perks); `null` until then. */
57
+ closedAt: integer({ mode: "timestamp" }),
58
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
59
+ updatedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
60
+ }, (t) => [
61
+ index("shift_end_closed_idx").on(t.endsAt, t.closedAt),
62
+ index("shift_schedule_start_idx").on(t.scheduleId, t.startsAt),
63
+ index("shift_team_start_idx").on(t.teamId, t.startsAt)
64
+ ]);
65
+ export const shiftAssignments = sqliteTable("shift_assignments", {
66
+ /** `sha_` + random id. */
67
+ id: text().primaryKey(),
68
+ shiftId: text().notNull(),
69
+ userId: integer().notNull(),
70
+ shiftRoleId: text(),
71
+ /** `assigned`, `attended`, `no_show` or `cancelled`. */
72
+ status: text().notNull().default("assigned"),
73
+ /** The code of the QR pass: 64 hex characters, unguessable. A new one is issued when the assignment changes hands. */
74
+ checkInCode: text().notNull(),
75
+ checkedInAt: integer({ mode: "timestamp" }),
76
+ checkedInBy: integer(),
77
+ /** How the person checked in: `lead`, `station`, `location` or `daily`; `null` before a check-in. */
78
+ checkInMethod: text(),
79
+ assignedBy: integer(),
80
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
81
+ updatedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
82
+ }, (t) => [
83
+ uniqueIndex("shift_assignment_code_unique").on(t.checkInCode),
84
+ index("shift_assignment_shift_idx").on(t.shiftId),
85
+ index("shift_assignment_user_idx").on(t.userId)
86
+ ]);
87
+ export const shiftSwaps = sqliteTable("shift_swaps", {
88
+ /** `shw_` + random id. */
89
+ id: text().primaryKey(),
90
+ assignmentId: text().notNull(),
91
+ /** The person who opened it: the assignment's holder then. */
92
+ userId: integer().notNull(),
93
+ /** `trade` (shift for shift: every offer gives one back) or `release` (given away, taken over). */
94
+ kind: text().notNull().default("release"),
95
+ /** A trade aimed at one assignment: only its holder may offer, giving that shift. `null` is open to anybody. */
96
+ wantedAssignmentId: text(),
97
+ /** `open`, `offered`, `accepted`, `pending_approval`, `completed`, `rejected` or `cancelled`. */
98
+ status: text().notNull().default("open"),
99
+ openedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
100
+ decidedAt: integer({ mode: "timestamp" }),
101
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
102
+ updatedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
103
+ }, (t) => [
104
+ index("shift_swap_assignment_idx").on(t.assignmentId),
105
+ index("shift_swap_status_idx").on(t.status)
106
+ ]);
107
+ export const shiftSwapOffers = sqliteTable("shift_swap_offers", {
108
+ /** `sho_` + random id. */
109
+ id: text().primaryKey(),
110
+ swapId: text().notNull(),
111
+ userId: integer().notNull(),
112
+ /** The offerer's assignment the owner gets in return (a trade); `null` takes a released shift over. */
113
+ offeredAssignmentId: text(),
114
+ /** `offered`, `accepted`, `rejected`, `withdrawn` or `superseded`. */
115
+ status: text().notNull().default("offered"),
116
+ decidedAt: integer({ mode: "timestamp" }),
117
+ /** The lead or staff user who approved the swap (`approval: 'lead'`). */
118
+ approvedBy: integer(),
119
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
120
+ updatedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
121
+ }, (t) => [
122
+ index("shift_swap_offer_swap_idx").on(t.swapId),
123
+ index("shift_swap_offer_user_idx").on(t.userId)
124
+ ]);
125
+ export const shiftReminders = sqliteTable("shift_reminders", {
126
+ /** `srm_` + random id. */
127
+ id: text().primaryKey(),
128
+ assignmentId: text().notNull(),
129
+ /** How many minutes before the shift starts this reminder was for. */
130
+ offsetMinutes: integer().notNull(),
131
+ userId: integer().notNull(),
132
+ /** When it was claimed: a row stays when sending failed, so a broken address is not retried every run. */
133
+ sentAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
134
+ }, (t) => [
135
+ uniqueIndex("shift_reminder_unique").on(t.assignmentId, t.offsetMinutes)
136
+ ]);
137
+ export const shiftFeedTokens = sqliteTable("shift_feed_tokens", {
138
+ /** `sft_` + random id. */
139
+ id: text().primaryKey(),
140
+ userId: integer().notNull(),
141
+ tokenHash: text().notNull(),
142
+ /** The first characters of the token, to recognise it. */
143
+ prefix: text().notNull(),
144
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
145
+ lastUsedAt: integer({ mode: "timestamp" }),
146
+ revokedAt: integer({ mode: "timestamp" })
147
+ }, (t) => [
148
+ uniqueIndex("shift_feed_token_hash_unique").on(t.tokenHash),
149
+ index("shift_feed_token_user_idx").on(t.userId)
150
+ ]);
151
+ export const shiftBroadcasts = sqliteTable("shift_broadcasts", {
152
+ /** `shb_` + random id. */
153
+ id: text().primaryKey(),
154
+ operationId: text().notNull(),
155
+ teamId: text(),
156
+ shiftId: text(),
157
+ /** The lowest team role that got it (on each team kind's ladder); `null` is every member. */
158
+ teamRole: text(),
159
+ /** `['email']`, `['sms']` or both. */
160
+ channels: text({ mode: "json" }).$type().notNull(),
161
+ subject: text({ mode: "json" }).$type().notNull(),
162
+ message: text({ mode: "json" }).$type().notNull(),
163
+ recipientCount: integer().notNull(),
164
+ sentBy: integer().notNull(),
165
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
166
+ }, (t) => [
167
+ index("shift_broadcast_operation_idx").on(t.operationId, t.createdAt)
168
+ ]);
169
+ export const shiftPerks = sqliteTable("shift_perks", {
170
+ /** `spk_` + random id. */
171
+ id: text().primaryKey(),
172
+ operationId: text().notNull(),
173
+ /** The team it is for; `null` is every team of the operation. */
174
+ teamId: text(),
175
+ name: text({ mode: "json" }).$type().notNull(),
176
+ /** Free text the vouchers app spends it as (`beer`, `meal`). Always set by the API; the default only lets the column be added. */
177
+ voucherType: text().notNull().default(""),
178
+ /** How many of it one attended shift earns (at least 1). */
179
+ quantity: integer().notNull().default(1),
180
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
181
+ updatedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
182
+ }, (t) => [
183
+ index("shift_perk_operation_idx").on(t.operationId)
184
+ ]);
185
+ export const shiftEarnedPerks = sqliteTable("shift_earned_perks", {
186
+ /** `spg_` + random id. */
187
+ id: text().primaryKey(),
188
+ perkId: text().notNull(),
189
+ assignmentId: text().notNull(),
190
+ /** The person who attended (the assignment's holder when it was earned). */
191
+ userId: integer().notNull(),
192
+ /** Copied from the perk when earned. */
193
+ voucherType: text().notNull(),
194
+ quantity: integer().notNull(),
195
+ earnedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
196
+ claimedAt: integer({ mode: "timestamp" }),
197
+ /** The client that claimed it (such as `vouchers`). */
198
+ claimClient: text(),
199
+ revokedAt: integer({ mode: "timestamp" })
200
+ }, (t) => [
201
+ uniqueIndex("shift_earned_perk_unique").on(t.perkId, t.assignmentId),
202
+ index("shift_earned_perk_user_idx").on(t.userId, t.claimedAt),
203
+ index("shift_earned_perk_assignment_idx").on(t.assignmentId)
204
+ ]);
205
+ export const shiftStations = sqliteTable("shift_stations", {
206
+ /** `sst_` + random id. */
207
+ id: text().primaryKey(),
208
+ scheduleId: text().notNull(),
209
+ teamId: text().notNull(),
210
+ name: text({ mode: "json" }).$type().notNull(),
211
+ /** A feature of the operation's venue layout (an `operations.station`), or `null`. */
212
+ featureId: text(),
213
+ createdAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
214
+ updatedAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
215
+ }, (t) => [
216
+ index("shift_station_schedule_idx").on(t.scheduleId)
217
+ ]);
218
+ export const shiftDigestItems = sqliteTable("shift_digest_items", {
219
+ /** `sdi_` + random id. */
220
+ id: text().primaryKey(),
221
+ /** `no_show`, `not_checked_in` or `claimed_no_show`. */
222
+ kind: text().notNull(),
223
+ assignmentId: text().notNull(),
224
+ teamId: text().notNull(),
225
+ sentAt: integer({ mode: "timestamp" }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
226
+ }, (t) => [
227
+ uniqueIndex("shift_digest_item_unique").on(t.kind, t.assignmentId)
228
+ ]);
@@ -0,0 +1,17 @@
1
+ import type { EmailNotification } from '@frigear-nu/notify/types';
2
+ import type { ShiftExceptionKind } from '../../types.js';
3
+ /** One line of a digest: who, which shift (already formatted) and what happened. */
4
+ export type ShiftDigestLine = {
5
+ kind: ShiftExceptionKind;
6
+ name: string;
7
+ team: string;
8
+ when: string;
9
+ };
10
+ /** The digest email of one lead; `null` without an address or without lines. */
11
+ export declare function buildShiftDigestEmail(input: {
12
+ email: string | null;
13
+ name: string;
14
+ lines: ShiftDigestLine[];
15
+ url?: string;
16
+ locale?: string;
17
+ }): EmailNotification | null;
@@ -0,0 +1,42 @@
1
+ import { reminderLanguage } from "./reminder-email.js";
2
+ const escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3
+ const TEXTS = {
4
+ en: {
5
+ subject: (count) => count === 1 ? "Shifts: 1 thing to look at" : `Shifts: ${count} things to look at`,
6
+ intro: "These came up on the shifts of your team:",
7
+ kinds: { no_show: "no-show", not_checked_in: "not checked in", claimed_no_show: "no-show, perk already claimed", late: "late" },
8
+ greeting: (name) => `Hi ${name},`,
9
+ link: "Open the exceptions"
10
+ },
11
+ da: {
12
+ subject: (count) => count === 1 ? "Vagter: 1 ting at se p\xE5" : `Vagter: ${count} ting at se p\xE5`,
13
+ intro: "Det her er sket p\xE5 dit holds vagter:",
14
+ kinds: { no_show: "udeblevet", not_checked_in: "ikke tjekket ind", claimed_no_show: "udeblevet, fordel allerede hentet", late: "for sent" },
15
+ greeting: (name) => `Hej ${name},`,
16
+ link: "Se undtagelserne"
17
+ }
18
+ };
19
+ export function buildShiftDigestEmail(input) {
20
+ if (!input.email || !input.lines.length) return null;
21
+ const texts = TEXTS[reminderLanguage(input.locale)];
22
+ const items = input.lines.map((line) => `${line.name}, ${line.team} ${line.when}: ${texts.kinds[line.kind]}`);
23
+ const message = `${texts.intro}
24
+ ${items.map((item) => `- ${item}`).join("\n")}${input.url ? `
25
+
26
+ ${texts.link}: ${input.url}` : ""}`;
27
+ const subject = texts.subject(input.lines.length);
28
+ return {
29
+ to: input.email,
30
+ subject,
31
+ body: `<p>${escapeHtml(texts.greeting(input.name))}</p><p>${escapeHtml(texts.intro)}</p><ul>${items.map((item) => `<li>${escapeHtml(item)}</li>`).join("")}</ul>${input.url ? `<p><a href="${escapeHtml(input.url)}">${escapeHtml(texts.link)}</a></p>` : ""}`,
32
+ text: `${texts.greeting(input.name)}
33
+
34
+ ${message}`,
35
+ template: {
36
+ name: "shifts-broadcast",
37
+ props: { name: input.name, subject, message, ...input.url ? { url: input.url } : {} },
38
+ locale: input.locale ?? "en"
39
+ },
40
+ meta: { shiftDigest: true }
41
+ };
42
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { assertShiftsStationKey } from "../../utils/station-key.js";
2
+ export default defineNitroPlugin(() => {
3
+ const config = useRuntimeConfig();
4
+ assertShiftsStationKey(config.shifts?.stationKey);
5
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ export default defineNitroPlugin((nitro) => {
2
+ nitro.hooks.hook("teams:member:removed", async (ctx) => {
3
+ if (ctx.team.ownerType !== "operation") return;
4
+ try {
5
+ await shiftsCancelFutureAssignments(ctx.event, ctx.member.userId, ctx.team.id);
6
+ } catch (error) {
7
+ console.error("[shifts] the shifts of a person who left a team could not be cancelled", error);
8
+ }
9
+ });
10
+ nitro.hooks.hook("teams:member:role-changed", async (ctx) => {
11
+ if (ctx.team.ownerType !== "operation") return;
12
+ try {
13
+ forgetTeamRoles(ctx.event);
14
+ await shiftsCancelFutureAssignments(ctx.event, ctx.member.userId, ctx.team.id, (assignment) => shiftsStillEligible(ctx.event, assignment, ctx.team.id));
15
+ } catch (error) {
16
+ console.error("[shifts] the shifts of a person whose team role changed could not be checked", error);
17
+ }
18
+ });
19
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any[];
2
+ export default _default;
@@ -0,0 +1,41 @@
1
+ export default [
2
+ // Your own assignments; the published shifts of a team you hold an explicit role on; everything on a team you lead;
3
+ // who is on shift now in an operation you take part in (approved crew, or an explicit team role there); staff.
4
+ definePolicy("shifts:read", async ({ event, user, record }) => {
5
+ if (!record) return void 0;
6
+ if (await allows(event, "shifts:manage")) return true;
7
+ if (record.userId !== void 0 && Number(user.id) === record.userId) return true;
8
+ if (record.teamId) {
9
+ if (await isTeamLead(event, user.id, record.teamId)) return true;
10
+ if (record.published && (await teamGrantOf(event, user.id, record.teamId))?.source === "explicit") return true;
11
+ return false;
12
+ }
13
+ if (record.operationId) return operationsTakesPart(event, user.id, record.operationId);
14
+ return false;
15
+ }),
16
+ // Only your own assignments.
17
+ definePolicy("shifts:swap", ({ user, record }) => {
18
+ if (!record) return void 0;
19
+ return record.userId !== void 0 && Number(user.id) === record.userId;
20
+ }),
21
+ // Only your own assignments: a station or location check-in.
22
+ definePolicy("shifts:attend", ({ user, record }) => {
23
+ if (!record) return void 0;
24
+ return record.userId !== void 0 && Number(user.id) === record.userId;
25
+ }),
26
+ // Only your own earned perks (an earned perk is `{ userId }`).
27
+ definePolicy("perks:read", ({ user, record }) => {
28
+ if (!record) return void 0;
29
+ return record.userId !== void 0 && Number(user.id) === record.userId;
30
+ }),
31
+ definePolicy("perks:claim", ({ user, record }) => {
32
+ if (!record) return void 0;
33
+ return record.userId !== void 0 && Number(user.id) === record.userId;
34
+ }),
35
+ // The leads of the record's team (`isTeamLead` of teams: lead role and up), and staff.
36
+ definePolicy("shifts:lead", async ({ event, user, record }) => {
37
+ if (!record) return void 0;
38
+ if (await allows(event, "shifts:manage")) return true;
39
+ return !!record.teamId && isTeamLead(event, user.id, record.teamId);
40
+ })
41
+ ];
@@ -0,0 +1,67 @@
1
+ import type { EmailNotification, SMSNotification } from '@frigear-nu/notify/types';
2
+ /** What a reminder says about the shift: `when` is already formatted in the person's locale and the module's time zone. */
3
+ export type ShiftReminderVariables = {
4
+ name: string;
5
+ team: string;
6
+ role?: string;
7
+ when: string;
8
+ where?: string;
9
+ start: string;
10
+ };
11
+ /** How much time is left, bucketed (see `timeLeftBucket`). */
12
+ export type ShiftTimeLeft = {
13
+ unit: 'minutes' | 'hours' | 'days';
14
+ count: number;
15
+ };
16
+ /** The language of the texts for a locale (`da`, `da-DK` and `da_DK` are Danish); English for anything else, even garbage. */
17
+ export declare function reminderLanguage(locale: string | undefined | null): 'en' | 'da';
18
+ /** The wording of the time left in a locale: "in 3 hours", "om 3 timer". */
19
+ export declare function describeTimeLeft(left: ShiftTimeLeft, locale?: string | null): string;
20
+ /**
21
+ * A shift time as `Jun 28, 2027, 12:00` in the person's locale and the time zone. A locale `Intl` does not know (the
22
+ * value is free text on a crew row) falls back to English instead of throwing in the middle of a run.
23
+ */
24
+ export declare function formatShiftWhen(date: Date, locale: string | undefined | null, timeZone: string): string;
25
+ /** The reminder email. `null` without an address. `offset` is the configured offset that fell due; `left` the real time left. */
26
+ export declare function buildShiftReminderEmail(input: {
27
+ email: string | null;
28
+ variables: ShiftReminderVariables;
29
+ offset: number;
30
+ left: ShiftTimeLeft;
31
+ url?: string;
32
+ locale?: string;
33
+ }): EmailNotification | null;
34
+ /** The reminder push notification: the email's subject and the same one-line message. */
35
+ export declare function buildShiftReminderPush(input: {
36
+ variables: ShiftReminderVariables;
37
+ left: ShiftTimeLeft;
38
+ url?: string;
39
+ locale?: string;
40
+ }): {
41
+ title: string;
42
+ body: string;
43
+ url?: string;
44
+ };
45
+ /** The reminder SMS: one short line in the person's language, with the link when there is one. `null` without a phone number. */
46
+ export declare function buildShiftReminderSms(input: {
47
+ phone: string | null;
48
+ variables: ShiftReminderVariables;
49
+ offset: number;
50
+ left: ShiftTimeLeft;
51
+ url?: string;
52
+ locale?: string;
53
+ }): SMSNotification | null;
54
+ /** The broadcast email: the staff or lead's subject and message in the person's locale. `null` without an address. */
55
+ export declare function buildShiftBroadcastEmail(input: {
56
+ email: string | null;
57
+ name: string;
58
+ subject: string;
59
+ message: string;
60
+ locale?: string;
61
+ }): EmailNotification | null;
62
+ /** The broadcast SMS: the subject, then the message. `null` without a phone number. */
63
+ export declare function buildShiftBroadcastSms(input: {
64
+ phone: string | null;
65
+ subject: string;
66
+ message: string;
67
+ }): SMSNotification | null;
@@ -0,0 +1,109 @@
1
+ import { formatDateTime } from "@frigear-nu/ui/utils";
2
+ const escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3
+ const TEXTS = {
4
+ en: {
5
+ left: {
6
+ minutes: (count) => count === 1 ? "in a minute" : `in ${count} minutes`,
7
+ hours: (count) => count === 1 ? "in an hour" : `in ${count} hours`,
8
+ days: (count) => count === 1 ? "in a day" : `in ${count} days`
9
+ },
10
+ subject: (left) => `Reminder: your shift starts ${left}`,
11
+ message: (what, left, when, where) => `Your shift on ${what} starts ${left}: ${when}${where ? `, ${where}` : ""}.`,
12
+ greeting: (name) => `Hi ${name},`,
13
+ heading: "Your shift is coming up",
14
+ button: "See your shift"
15
+ },
16
+ da: {
17
+ left: {
18
+ minutes: (count) => count === 1 ? "om et minut" : `om ${count} minutter`,
19
+ hours: (count) => count === 1 ? "om en time" : `om ${count} timer`,
20
+ days: (count) => count === 1 ? "om en dag" : `om ${count} dage`
21
+ },
22
+ subject: (left) => `P\xE5mindelse: din vagt starter ${left}`,
23
+ message: (what, left, when, where) => `Din vagt p\xE5 ${what} starter ${left}: ${when}${where ? `, ${where}` : ""}.`,
24
+ greeting: (name) => `Hej ${name},`,
25
+ heading: "Din vagt n\xE6rmer sig",
26
+ button: "Se din vagt"
27
+ }
28
+ };
29
+ export function reminderLanguage(locale) {
30
+ return typeof locale === "string" && /^da(?:[-_]|$)/i.test(locale.trim()) ? "da" : "en";
31
+ }
32
+ export function describeTimeLeft(left, locale) {
33
+ return TEXTS[reminderLanguage(locale)].left[left.unit](left.count);
34
+ }
35
+ export function formatShiftWhen(date, locale, timeZone) {
36
+ try {
37
+ return formatDateTime(date, locale || "en", { timeZone });
38
+ } catch {
39
+ return formatDateTime(date, "en", { timeZone });
40
+ }
41
+ }
42
+ function reminderMessage(variables, left, locale) {
43
+ const texts = TEXTS[reminderLanguage(locale)];
44
+ const what = variables.role ? `${variables.team} (${variables.role})` : variables.team;
45
+ return texts.message(what, describeTimeLeft(left, locale), variables.when, variables.where);
46
+ }
47
+ export function buildShiftReminderEmail(input) {
48
+ const { email, variables, url, offset, left, locale } = input;
49
+ if (!email) return null;
50
+ const texts = TEXTS[reminderLanguage(locale)];
51
+ const subject = texts.subject(describeTimeLeft(left, locale));
52
+ const message = reminderMessage(variables, left, locale);
53
+ const greeting = texts.greeting(variables.name);
54
+ const link = url ? `<p><a href="${escapeHtml(url)}">${escapeHtml(url)}</a></p>` : "";
55
+ return {
56
+ to: email,
57
+ subject,
58
+ body: `<p>${escapeHtml(greeting)}</p><p>${escapeHtml(message)}</p>${link}`,
59
+ text: `${greeting}
60
+
61
+ ${message}${url ? `
62
+
63
+ ${url}` : ""}`,
64
+ template: {
65
+ name: "shifts-reminder",
66
+ props: { name: variables.name, subject, message, url: url ?? null, greeting, heading: texts.heading, button: texts.button },
67
+ locale: locale ?? "en"
68
+ },
69
+ meta: { shiftReminder: offset }
70
+ };
71
+ }
72
+ export function buildShiftReminderPush(input) {
73
+ return {
74
+ title: TEXTS[reminderLanguage(input.locale)].subject(describeTimeLeft(input.left, input.locale)),
75
+ body: reminderMessage(input.variables, input.left, input.locale),
76
+ ...input.url ? { url: input.url } : {}
77
+ };
78
+ }
79
+ export function buildShiftReminderSms(input) {
80
+ if (!input.phone) return null;
81
+ return {
82
+ to: input.phone,
83
+ body: `${reminderMessage(input.variables, input.left, input.locale)}${input.url ? ` ${input.url}` : ""}`,
84
+ meta: { shiftReminder: input.offset }
85
+ };
86
+ }
87
+ export function buildShiftBroadcastEmail(input) {
88
+ if (!input.email) return null;
89
+ const paragraphs = input.message.split(/\n{2,}/).map((part) => `<p>${escapeHtml(part).replace(/\n/g, "<br>")}</p>`).join("");
90
+ return {
91
+ to: input.email,
92
+ subject: input.subject,
93
+ body: `<p>Hi ${escapeHtml(input.name)},</p>${paragraphs}`,
94
+ text: `Hi ${input.name},
95
+
96
+ ${input.message}`,
97
+ template: {
98
+ name: "shifts-broadcast",
99
+ props: { name: input.name, subject: input.subject, message: input.message },
100
+ locale: input.locale ?? "en"
101
+ },
102
+ meta: { shiftBroadcast: true }
103
+ };
104
+ }
105
+ export function buildShiftBroadcastSms(input) {
106
+ if (!input.phone) return null;
107
+ return { to: input.phone, body: `${input.subject}
108
+ ${input.message}`, meta: { shiftBroadcast: true } };
109
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { idParams, noContent } from "@frigear-nu/module-kit/server";
2
+ import { shiftsAccess } from "../../../access.js";
3
+ export default defineEventHandler(async (event) => {
4
+ await authorize(event, shiftsAccess.permissions.manage);
5
+ const { assignmentId } = await getValidatedRouterParams(event, idParams("assignmentId").parse);
6
+ const entry = await getShiftAssignmentEntryOr404(assignmentId);
7
+ await authorize(event, shiftsAccess.permissions.manage, { operationId: entry.schedule.operationId });
8
+ await shiftsCancelAssignment(event, entry);
9
+ return noContent(event);
10
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { created, idParams } from "@frigear-nu/module-kit/server";
2
+ import { shiftsAccess } from "../../../access.js";
3
+ export default defineEventHandler(async (event) => {
4
+ const principal = await authorize(event, shiftsAccess.permissions.manage);
5
+ const { shiftId } = await getValidatedRouterParams(event, idParams("shiftId").parse);
6
+ const input = await readValidatedBody(event, shiftsAssignInput.parse);
7
+ const entry = await getShiftEntryOr404(shiftId);
8
+ await authorize(event, shiftsAccess.permissions.manage, { operationId: entry.schedule.operationId });
9
+ const pii = await allows(event, shiftsAccess.permissions.pii);
10
+ return created(event, await shiftsAssign(event, entry, input, Number(principal.user.id), pii));
11
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { shiftsAccess } from "../../../access.js";
2
+ export default defineEventHandler(async (event) => {
3
+ await authorize(event, shiftsAccess.permissions.broadcast);
4
+ const { operationId } = await getValidatedQuery(event, shiftsBroadcastsQuery.parse);
5
+ const operation = await getOperationOr404(operationId);
6
+ await authorize(event, shiftsAccess.permissions.broadcast, { operationId: operation.id });
7
+ return shiftsListBroadcasts(operation.id);
8
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { created } from "@frigear-nu/module-kit/server";
2
+ import { shiftsAccess } from "../../../access.js";
3
+ export default defineEventHandler(async (event) => {
4
+ const principal = await authorize(event, shiftsAccess.permissions.broadcast);
5
+ const input = await readValidatedBody(event, shiftsBroadcastInput.parse);
6
+ const operation = await getOperationOr404(input.operationId);
7
+ await authorize(event, shiftsAccess.permissions.broadcast, { operationId: operation.id });
8
+ return created(event, await shiftsSendBroadcast(event, { ...input, operationId: operation.id }, Number(principal.user.id)));
9
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { idParams } from "@frigear-nu/module-kit/server";
2
+ import { shiftsAccess } from "../../../access.js";
3
+ export default defineEventHandler(async (event) => {
4
+ await authorize(event, shiftsAccess.permissions.manage);
5
+ const { shiftId } = await getValidatedRouterParams(event, idParams("shiftId").parse);
6
+ const { q, shiftRoleId } = await getValidatedQuery(event, shiftsCandidatesQuery.parse);
7
+ const entry = await getShiftEntryOr404(shiftId);
8
+ await authorize(event, shiftsAccess.permissions.manage, { operationId: entry.schedule.operationId });
9
+ return shiftsCandidates(event, entry, q, await allows(event, shiftsAccess.permissions.pii), shiftRoleId);
10
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { idParams } from "@frigear-nu/module-kit/server";
2
+ import { shiftsAccess } from "../../../access.js";
3
+ export default defineEventHandler(async (event) => {
4
+ await authorize(event, shiftsAccess.permissions.manage);
5
+ const { operationId } = await getValidatedRouterParams(event, idParams("operationId").parse);
6
+ const operation = await getOperationOr404(operationId);
7
+ await authorize(event, shiftsAccess.permissions.manage, { operationId: operation.id });
8
+ return shiftsOperationTeams(event, operation.id);
9
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;