@frigear-nu/shifts 0.0.0-stage → 0.0.0

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 (341) hide show
  1. package/README.md +53 -2
  2. package/dist/module.d.mts +709 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +253 -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 +169 -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 +192 -0
  96. package/dist/runtime/app/pages/swaps.vue.d.ts +3 -0
  97. package/dist/runtime/app/tabs/Shifts.d.vue.ts +9 -0
  98. package/dist/runtime/app/tabs/Shifts.vue +487 -0
  99. package/dist/runtime/app/tabs/Shifts.vue.d.ts +9 -0
  100. package/dist/runtime/app/utils/admin-shifts.d.ts +42 -0
  101. package/dist/runtime/app/utils/admin-shifts.js +36 -0
  102. package/dist/runtime/dashboard.d.ts +8 -0
  103. package/dist/runtime/dashboard.js +30 -0
  104. package/dist/runtime/emails/shifts-broadcast.d.vue.ts +8 -0
  105. package/dist/runtime/emails/shifts-broadcast.vue +24 -0
  106. package/dist/runtime/emails/shifts-broadcast.vue.d.ts +8 -0
  107. package/dist/runtime/emails/shifts-reminder.d.vue.ts +12 -0
  108. package/dist/runtime/emails/shifts-reminder.vue +34 -0
  109. package/dist/runtime/emails/shifts-reminder.vue.d.ts +12 -0
  110. package/dist/runtime/emails/shifts-swap-accepted.d.vue.ts +11 -0
  111. package/dist/runtime/emails/shifts-swap-accepted.vue +32 -0
  112. package/dist/runtime/emails/shifts-swap-accepted.vue.d.ts +11 -0
  113. package/dist/runtime/emails/shifts-swap-completed.d.vue.ts +11 -0
  114. package/dist/runtime/emails/shifts-swap-completed.vue +32 -0
  115. package/dist/runtime/emails/shifts-swap-completed.vue.d.ts +11 -0
  116. package/dist/runtime/emails/shifts-swap-offered.d.vue.ts +11 -0
  117. package/dist/runtime/emails/shifts-swap-offered.vue +32 -0
  118. package/dist/runtime/emails/shifts-swap-offered.vue.d.ts +11 -0
  119. package/dist/runtime/emails/shifts-swap-pending.d.vue.ts +11 -0
  120. package/dist/runtime/emails/shifts-swap-pending.vue +32 -0
  121. package/dist/runtime/emails/shifts-swap-pending.vue.d.ts +11 -0
  122. package/dist/runtime/emails/shifts-swap-proposed.d.vue.ts +11 -0
  123. package/dist/runtime/emails/shifts-swap-proposed.vue +32 -0
  124. package/dist/runtime/emails/shifts-swap-proposed.vue.d.ts +11 -0
  125. package/dist/runtime/emails/shifts-swap-rejected.d.vue.ts +11 -0
  126. package/dist/runtime/emails/shifts-swap-rejected.vue +32 -0
  127. package/dist/runtime/emails/shifts-swap-rejected.vue.d.ts +11 -0
  128. package/dist/runtime/i18n/lang/da.json +626 -0
  129. package/dist/runtime/i18n/lang/en.json +626 -0
  130. package/dist/runtime/menus.d.ts +2 -0
  131. package/dist/runtime/menus.js +17 -0
  132. package/dist/runtime/notifications.d.ts +9 -0
  133. package/dist/runtime/notifications.js +36 -0
  134. package/dist/runtime/server/db/schema.postgresql.d.ts +2151 -0
  135. package/dist/runtime/server/db/schema.postgresql.js +228 -0
  136. package/dist/runtime/server/db/schema.sqlite.d.ts +2263 -0
  137. package/dist/runtime/server/db/schema.sqlite.js +228 -0
  138. package/dist/runtime/server/digest-email.d.ts +17 -0
  139. package/dist/runtime/server/digest-email.js +42 -0
  140. package/dist/runtime/server/plugins/station-key.d.ts +2 -0
  141. package/dist/runtime/server/plugins/station-key.js +5 -0
  142. package/dist/runtime/server/plugins/teams.d.ts +2 -0
  143. package/dist/runtime/server/plugins/teams.js +19 -0
  144. package/dist/runtime/server/policies.d.ts +2 -0
  145. package/dist/runtime/server/policies.js +41 -0
  146. package/dist/runtime/server/reminder-email.d.ts +67 -0
  147. package/dist/runtime/server/reminder-email.js +109 -0
  148. package/dist/runtime/server/routes/admin/assignment.delete.d.ts +2 -0
  149. package/dist/runtime/server/routes/admin/assignment.delete.js +10 -0
  150. package/dist/runtime/server/routes/admin/assignments.post.d.ts +2 -0
  151. package/dist/runtime/server/routes/admin/assignments.post.js +11 -0
  152. package/dist/runtime/server/routes/admin/broadcasts.get.d.ts +2 -0
  153. package/dist/runtime/server/routes/admin/broadcasts.get.js +8 -0
  154. package/dist/runtime/server/routes/admin/broadcasts.post.d.ts +2 -0
  155. package/dist/runtime/server/routes/admin/broadcasts.post.js +9 -0
  156. package/dist/runtime/server/routes/admin/candidates.get.d.ts +2 -0
  157. package/dist/runtime/server/routes/admin/candidates.get.js +10 -0
  158. package/dist/runtime/server/routes/admin/operation-teams.get.d.ts +2 -0
  159. package/dist/runtime/server/routes/admin/operation-teams.get.js +9 -0
  160. package/dist/runtime/server/routes/admin/perk.delete.d.ts +2 -0
  161. package/dist/runtime/server/routes/admin/perk.delete.js +10 -0
  162. package/dist/runtime/server/routes/admin/perk.patch.d.ts +2 -0
  163. package/dist/runtime/server/routes/admin/perk.patch.js +10 -0
  164. package/dist/runtime/server/routes/admin/perks.get.d.ts +2 -0
  165. package/dist/runtime/server/routes/admin/perks.get.js +9 -0
  166. package/dist/runtime/server/routes/admin/perks.post.d.ts +2 -0
  167. package/dist/runtime/server/routes/admin/perks.post.js +10 -0
  168. package/dist/runtime/server/routes/admin/role.delete.d.ts +2 -0
  169. package/dist/runtime/server/routes/admin/role.delete.js +11 -0
  170. package/dist/runtime/server/routes/admin/role.patch.d.ts +2 -0
  171. package/dist/runtime/server/routes/admin/role.patch.js +11 -0
  172. package/dist/runtime/server/routes/admin/roles.get.d.ts +2 -0
  173. package/dist/runtime/server/routes/admin/roles.get.js +9 -0
  174. package/dist/runtime/server/routes/admin/roles.post.d.ts +2 -0
  175. package/dist/runtime/server/routes/admin/roles.post.js +10 -0
  176. package/dist/runtime/server/routes/admin/schedule-copy.post.d.ts +2 -0
  177. package/dist/runtime/server/routes/admin/schedule-copy.post.js +12 -0
  178. package/dist/runtime/server/routes/admin/schedule-publish.post.d.ts +2 -0
  179. package/dist/runtime/server/routes/admin/schedule-publish.post.js +9 -0
  180. package/dist/runtime/server/routes/admin/schedule.delete.d.ts +2 -0
  181. package/dist/runtime/server/routes/admin/schedule.delete.js +10 -0
  182. package/dist/runtime/server/routes/admin/schedule.get.d.ts +2 -0
  183. package/dist/runtime/server/routes/admin/schedule.get.js +9 -0
  184. package/dist/runtime/server/routes/admin/schedule.patch.d.ts +2 -0
  185. package/dist/runtime/server/routes/admin/schedule.patch.js +10 -0
  186. package/dist/runtime/server/routes/admin/schedules.get.d.ts +2 -0
  187. package/dist/runtime/server/routes/admin/schedules.get.js +10 -0
  188. package/dist/runtime/server/routes/admin/schedules.post.d.ts +2 -0
  189. package/dist/runtime/server/routes/admin/schedules.post.js +9 -0
  190. package/dist/runtime/server/routes/admin/shift.delete.d.ts +2 -0
  191. package/dist/runtime/server/routes/admin/shift.delete.js +10 -0
  192. package/dist/runtime/server/routes/admin/shift.patch.d.ts +2 -0
  193. package/dist/runtime/server/routes/admin/shift.patch.js +10 -0
  194. package/dist/runtime/server/routes/admin/shifts-bulk.post.d.ts +2 -0
  195. package/dist/runtime/server/routes/admin/shifts-bulk.post.js +10 -0
  196. package/dist/runtime/server/routes/admin/shifts.get.d.ts +2 -0
  197. package/dist/runtime/server/routes/admin/shifts.get.js +10 -0
  198. package/dist/runtime/server/routes/admin/station.delete.d.ts +2 -0
  199. package/dist/runtime/server/routes/admin/station.delete.js +11 -0
  200. package/dist/runtime/server/routes/admin/station.patch.d.ts +2 -0
  201. package/dist/runtime/server/routes/admin/station.patch.js +11 -0
  202. package/dist/runtime/server/routes/admin/stations.get.d.ts +2 -0
  203. package/dist/runtime/server/routes/admin/stations.get.js +9 -0
  204. package/dist/runtime/server/routes/admin/stations.post.d.ts +2 -0
  205. package/dist/runtime/server/routes/admin/stations.post.js +10 -0
  206. package/dist/runtime/server/routes/admin/swap-cancel.post.d.ts +2 -0
  207. package/dist/runtime/server/routes/admin/swap-cancel.post.js +10 -0
  208. package/dist/runtime/server/routes/admin/swaps.get.d.ts +2 -0
  209. package/dist/runtime/server/routes/admin/swaps.get.js +10 -0
  210. package/dist/runtime/server/routes/feed/feed.get.d.ts +2 -0
  211. package/dist/runtime/server/routes/feed/feed.get.js +9 -0
  212. package/dist/runtime/server/routes/lead/attended.post.d.ts +2 -0
  213. package/dist/runtime/server/routes/lead/attended.post.js +11 -0
  214. package/dist/runtime/server/routes/lead/broadcast.post.d.ts +2 -0
  215. package/dist/runtime/server/routes/lead/broadcast.post.js +12 -0
  216. package/dist/runtime/server/routes/lead/check-in.post.d.ts +2 -0
  217. package/dist/runtime/server/routes/lead/check-in.post.js +9 -0
  218. package/dist/runtime/server/routes/lead/exceptions.get.d.ts +2 -0
  219. package/dist/runtime/server/routes/lead/exceptions.get.js +8 -0
  220. package/dist/runtime/server/routes/lead/no-show.post.d.ts +2 -0
  221. package/dist/runtime/server/routes/lead/no-show.post.js +11 -0
  222. package/dist/runtime/server/routes/lead/now.get.d.ts +2 -0
  223. package/dist/runtime/server/routes/lead/now.get.js +9 -0
  224. package/dist/runtime/server/routes/lead/on-duty.get.d.ts +2 -0
  225. package/dist/runtime/server/routes/lead/on-duty.get.js +10 -0
  226. package/dist/runtime/server/routes/lead/stations.get.d.ts +2 -0
  227. package/dist/runtime/server/routes/lead/stations.get.js +8 -0
  228. package/dist/runtime/server/routes/lead/team-shifts.get.d.ts +2 -0
  229. package/dist/runtime/server/routes/lead/team-shifts.get.js +9 -0
  230. package/dist/runtime/server/routes/lead/team-swaps.get.d.ts +2 -0
  231. package/dist/runtime/server/routes/lead/team-swaps.get.js +9 -0
  232. package/dist/runtime/server/routes/me/check-in.post.d.ts +2 -0
  233. package/dist/runtime/server/routes/me/check-in.post.js +11 -0
  234. package/dist/runtime/server/routes/me/earned-perk-claim.post.d.ts +2 -0
  235. package/dist/runtime/server/routes/me/earned-perk-claim.post.js +10 -0
  236. package/dist/runtime/server/routes/me/earned-perks.get.d.ts +2 -0
  237. package/dist/runtime/server/routes/me/earned-perks.get.js +9 -0
  238. package/dist/runtime/server/routes/me/feed-token.delete.d.ts +2 -0
  239. package/dist/runtime/server/routes/me/feed-token.delete.js +7 -0
  240. package/dist/runtime/server/routes/me/feed-token.get.d.ts +2 -0
  241. package/dist/runtime/server/routes/me/feed-token.get.js +6 -0
  242. package/dist/runtime/server/routes/me/feed-token.post.d.ts +2 -0
  243. package/dist/runtime/server/routes/me/feed-token.post.js +7 -0
  244. package/dist/runtime/server/routes/me/leads.get.d.ts +2 -0
  245. package/dist/runtime/server/routes/me/leads.get.js +5 -0
  246. package/dist/runtime/server/routes/me/now.get.d.ts +2 -0
  247. package/dist/runtime/server/routes/me/now.get.js +5 -0
  248. package/dist/runtime/server/routes/me/pass.get.d.ts +2 -0
  249. package/dist/runtime/server/routes/me/pass.get.js +11 -0
  250. package/dist/runtime/server/routes/me/settle.post.d.ts +2 -0
  251. package/dist/runtime/server/routes/me/settle.post.js +14 -0
  252. package/dist/runtime/server/routes/me/shift.get.d.ts +2 -0
  253. package/dist/runtime/server/routes/me/shift.get.js +10 -0
  254. package/dist/runtime/server/routes/me/shifts.get.d.ts +2 -0
  255. package/dist/runtime/server/routes/me/shifts.get.js +6 -0
  256. package/dist/runtime/server/routes/me/swap.delete.d.ts +2 -0
  257. package/dist/runtime/server/routes/me/swap.delete.js +11 -0
  258. package/dist/runtime/server/routes/me/swap.post.d.ts +2 -0
  259. package/dist/runtime/server/routes/me/swap.post.js +11 -0
  260. package/dist/runtime/server/routes/stations/token.get.d.ts +2 -0
  261. package/dist/runtime/server/routes/stations/token.get.js +12 -0
  262. package/dist/runtime/server/routes/swaps/approve.post.d.ts +2 -0
  263. package/dist/runtime/server/routes/swaps/approve.post.js +9 -0
  264. package/dist/runtime/server/routes/swaps/list.get.d.ts +2 -0
  265. package/dist/runtime/server/routes/swaps/list.get.js +5 -0
  266. package/dist/runtime/server/routes/swaps/offer-accept.post.d.ts +2 -0
  267. package/dist/runtime/server/routes/swaps/offer-accept.post.js +9 -0
  268. package/dist/runtime/server/routes/swaps/offer-reject.post.d.ts +2 -0
  269. package/dist/runtime/server/routes/swaps/offer-reject.post.js +9 -0
  270. package/dist/runtime/server/routes/swaps/offer.delete.d.ts +2 -0
  271. package/dist/runtime/server/routes/swaps/offer.delete.js +11 -0
  272. package/dist/runtime/server/routes/swaps/offer.post.d.ts +2 -0
  273. package/dist/runtime/server/routes/swaps/offer.post.js +11 -0
  274. package/dist/runtime/server/routes/swaps/reject.post.d.ts +2 -0
  275. package/dist/runtime/server/routes/swaps/reject.post.js +9 -0
  276. package/dist/runtime/server/swap-email.d.ts +28 -0
  277. package/dist/runtime/server/swap-email.js +49 -0
  278. package/dist/runtime/server/tasks/close-shifts.d.ts +2 -0
  279. package/dist/runtime/server/tasks/close-shifts.js +9 -0
  280. package/dist/runtime/server/tasks/send-reminders.d.ts +2 -0
  281. package/dist/runtime/server/tasks/send-reminders.js +9 -0
  282. package/dist/runtime/server/utils/shifts-admin.d.ts +67 -0
  283. package/dist/runtime/server/utils/shifts-admin.js +312 -0
  284. package/dist/runtime/server/utils/shifts-assign.d.ts +89 -0
  285. package/dist/runtime/server/utils/shifts-assign.js +264 -0
  286. package/dist/runtime/server/utils/shifts-automation.d.ts +37 -0
  287. package/dist/runtime/server/utils/shifts-automation.js +171 -0
  288. package/dist/runtime/server/utils/shifts-broadcasts.d.ts +38 -0
  289. package/dist/runtime/server/utils/shifts-broadcasts.js +113 -0
  290. package/dist/runtime/server/utils/shifts-core.d.ts +78 -0
  291. package/dist/runtime/server/utils/shifts-core.js +142 -0
  292. package/dist/runtime/server/utils/shifts-dto.d.ts +32 -0
  293. package/dist/runtime/server/utils/shifts-dto.js +127 -0
  294. package/dist/runtime/server/utils/shifts-emails.d.ts +16 -0
  295. package/dist/runtime/server/utils/shifts-emails.js +44 -0
  296. package/dist/runtime/server/utils/shifts-exceptions.d.ts +7 -0
  297. package/dist/runtime/server/utils/shifts-exceptions.js +32 -0
  298. package/dist/runtime/server/utils/shifts-feed.d.ts +16 -0
  299. package/dist/runtime/server/utils/shifts-feed.js +73 -0
  300. package/dist/runtime/server/utils/shifts-notify.d.ts +40 -0
  301. package/dist/runtime/server/utils/shifts-notify.js +22 -0
  302. package/dist/runtime/server/utils/shifts-on-duty.d.ts +12 -0
  303. package/dist/runtime/server/utils/shifts-on-duty.js +37 -0
  304. package/dist/runtime/server/utils/shifts-perks.d.ts +46 -0
  305. package/dist/runtime/server/utils/shifts-perks.js +183 -0
  306. package/dist/runtime/server/utils/shifts-reminders.d.ts +30 -0
  307. package/dist/runtime/server/utils/shifts-reminders.js +102 -0
  308. package/dist/runtime/server/utils/shifts-schemas.d.ts +318 -0
  309. package/dist/runtime/server/utils/shifts-schemas.js +177 -0
  310. package/dist/runtime/server/utils/shifts-station-key.d.ts +7 -0
  311. package/dist/runtime/server/utils/shifts-station-key.js +22 -0
  312. package/dist/runtime/server/utils/shifts-stations.d.ts +28 -0
  313. package/dist/runtime/server/utils/shifts-stations.js +109 -0
  314. package/dist/runtime/server/utils/shifts-swaps.d.ts +114 -0
  315. package/dist/runtime/server/utils/shifts-swaps.js +559 -0
  316. package/dist/runtime/server/utils/shifts-views.d.ts +62 -0
  317. package/dist/runtime/server/utils/shifts-views.js +212 -0
  318. package/dist/runtime/utils/api.d.ts +108 -0
  319. package/dist/runtime/utils/api.js +111 -0
  320. package/dist/runtime/utils/checkin.d.ts +59 -0
  321. package/dist/runtime/utils/checkin.js +57 -0
  322. package/dist/runtime/utils/guards.d.ts +21 -0
  323. package/dist/runtime/utils/guards.js +36 -0
  324. package/dist/runtime/utils/ics.d.ts +32 -0
  325. package/dist/runtime/utils/ics.js +56 -0
  326. package/dist/runtime/utils/index.d.ts +16 -0
  327. package/dist/runtime/utils/index.js +15 -0
  328. package/dist/runtime/utils/links.d.ts +30 -0
  329. package/dist/runtime/utils/links.js +18 -0
  330. package/dist/runtime/utils/reminders.d.ts +27 -0
  331. package/dist/runtime/utils/reminders.js +28 -0
  332. package/dist/runtime/utils/settings.d.ts +28 -0
  333. package/dist/runtime/utils/settings.js +18 -0
  334. package/dist/runtime/utils/station-key.d.ts +9 -0
  335. package/dist/runtime/utils/station-key.js +12 -0
  336. package/dist/runtime/utils/status.d.ts +23 -0
  337. package/dist/runtime/utils/status.js +46 -0
  338. package/dist/runtime/utils/time.d.ts +22 -0
  339. package/dist/runtime/utils/time.js +14 -0
  340. package/dist/types.d.mts +5 -0
  341. package/package.json +131 -3
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@frigear-nu/shifts",
3
+ "configKey": "shifts",
4
+ "version": "0.0.0",
5
+ "builder": {
6
+ "@nuxt/module-builder": "1.0.4",
7
+ "unbuild": "unknown"
8
+ }
9
+ }
@@ -0,0 +1,253 @@
1
+ import { defineNuxtModule, createResolver, addServerImportsDir, addServerPlugin, addImports, addComponentsDir, hasNuxtModule } from '@nuxt/kit';
2
+ import { registerModule, registerTailwindSource, registerLocales, resolvePagePath, registerDatabaseTable, addModuleRoutes, inlineModuleRuntime, addModulePages, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
3
+ import { extendMaps, defineMapLayer } from '@frigear-nu/maps/utils';
4
+ import { OPERATIONS_VENUE_SURFACE } from '@frigear-nu/operations/utils';
5
+ import { registerAccess, addPolicies } from '@frigear-nu/auth/utils';
6
+ import { shiftsAccess, perksAccess } from '../dist/runtime/access.js';
7
+ import { SHIFTS_DEFAULT_PAGES } from '../dist/runtime/utils/links.js';
8
+ import { isValidTimeZone } from '@frigear-nu/module-kit/time';
9
+ import { normalizeReminderBatch, normalizeReminderOffsets } from '../dist/runtime/utils/reminders.js';
10
+ import { SHIFTS_DASHBOARD, shiftsDashboardItems } from '../dist/runtime/dashboard.js';
11
+ import { extendNotificationTopics } from '@frigear-nu/notify/utils';
12
+ import { shiftsNotificationTopics } from '../dist/runtime/notifications.js';
13
+ import { normalizeAutomationBatch } from '../dist/runtime/utils/checkin.js';
14
+ import { assertShiftsStationKey } from '../dist/runtime/utils/station-key.js';
15
+
16
+ const MODULE_NAME = "@frigear-nu/shifts";
17
+ const module$1 = defineNuxtModule({
18
+ meta: { name: MODULE_NAME, configKey: "shifts" },
19
+ defaults: {
20
+ settings: { pages: {} },
21
+ checkInOpensMinutes: 60
22
+ },
23
+ moduleDependencies: {
24
+ "@nuxthub/core": { version: ">=0.10" },
25
+ "@frigear-nu/module-kit": { version: ">=0.0.1" },
26
+ "@frigear-nu/auth": { version: ">=0.0.1" },
27
+ // People on shifts are users: names, emails and phone numbers come from the `users` table.
28
+ "@frigear-nu/users": { version: ">=0.0.1" },
29
+ "@frigear-nu/ui": { version: ">=0.0.1" },
30
+ // Schedules hang off operations; shifts belong to an operation's teams; approved crew are the people on them.
31
+ "@frigear-nu/operations": { version: ">=0.0.0" },
32
+ "@frigear-nu/teams": { version: ">=0.0.0" },
33
+ "@frigear-nu/crew": { version: ">=0.0.0" },
34
+ // Reminders, swaps, broadcasts and the digest go through notify's `notifyUser` (email, push, SMS by the person's choice).
35
+ "@frigear-nu/notify": { version: ">=0.0.1" },
36
+ "@frigear-nu/menu": { version: ">=0.0.1", optional: true },
37
+ "@frigear-nu/widget": { version: ">=0.0.0", optional: true },
38
+ // Items on the `crew.home` dashboard.
39
+ "@frigear-nu/dashboard": { version: ">=0.0.0", optional: true },
40
+ // Provides the admin route and shell the operation page lives in.
41
+ "@frigear-nu/admin": { version: ">=0.0.0", optional: true },
42
+ "@frigear-nu/mobile": { version: ">=0.0.0", optional: true },
43
+ // Renders the `shifts-swap-*`, `shifts-reminder` and `shifts-broadcast` emails from the templates this module ships.
44
+ "@frigear-nu/email-templates": { version: ">=0.0.1", optional: true },
45
+ // The `shifts.on-duty` live layer on the venue layouts of operations (installed with operations already).
46
+ "@frigear-nu/maps": { version: ">=0.0.0" }
47
+ },
48
+ async setup(options, nuxt) {
49
+ registerModule(MODULE_NAME, nuxt);
50
+ const resolver = createResolver(import.meta.url);
51
+ registerAccess(nuxt, shiftsAccess, { from: MODULE_NAME });
52
+ registerAccess(nuxt, perksAccess, { from: MODULE_NAME });
53
+ addPolicies(nuxt, { path: resolver.resolve("./runtime/server/policies") });
54
+ registerTailwindSource(nuxt, resolver.resolve("./runtime/app"));
55
+ registerLocales(nuxt, resolver.resolve("./runtime/i18n/lang"));
56
+ const settings = options.settings ?? {};
57
+ const timeZone = options.timeZone || "";
58
+ if (timeZone && !isValidTimeZone(timeZone)) throw new Error(`[shifts] \`timeZone\` "${timeZone}" is not a time zone this runtime knows.`);
59
+ const checkInOpensMinutes = Math.max(0, Math.round(options.checkInOpensMinutes ?? 60));
60
+ const shiftsPath = resolvePagePath(settings.pages?.shifts ?? true, SHIFTS_DEFAULT_PAGES.shifts);
61
+ const shiftPath = resolvePagePath(settings.pages?.shift ?? true, SHIFTS_DEFAULT_PAGES.shift);
62
+ const swapsPath = resolvePagePath(settings.pages?.swaps ?? true, SHIFTS_DEFAULT_PAGES.swaps);
63
+ const checkInPath = resolvePagePath(settings.pages?.checkIn ?? true, SHIFTS_DEFAULT_PAGES.checkIn);
64
+ const leadPath = resolvePagePath(settings.pages?.lead ?? true, SHIFTS_DEFAULT_PAGES.lead);
65
+ const stationPath = resolvePagePath(settings.pages?.station ?? true, SHIFTS_DEFAULT_PAGES.station);
66
+ nuxt.options.runtimeConfig.public.shifts = {
67
+ pages: { shifts: shiftsPath, shift: shiftPath, swaps: swapsPath, checkIn: checkInPath, lead: leadPath, station: stationPath },
68
+ timeZone,
69
+ checkInOpensMinutes
70
+ };
71
+ const runtime = nuxt.options.runtimeConfig;
72
+ const reminders = { offsets: normalizeReminderOffsets(options.reminders?.offsets), sms: options.reminders?.sms === true, batchSize: normalizeReminderBatch(options.reminders?.batchSize) };
73
+ const automation = { batchSize: normalizeAutomationBatch(options.automation?.batchSize) };
74
+ runtime.shifts = { stationKey: "", ...runtime.shifts, timeZone, checkInOpensMinutes, reminders, automation };
75
+ assertShiftsStationKey(runtime.shifts.stationKey);
76
+ registerDatabaseTable(nuxt, {
77
+ resolver,
78
+ schema: (dialect) => `./runtime/server/db/schema.${dialect}`
79
+ });
80
+ addModuleRoutes(resolver, [
81
+ { method: "get", path: "me", file: "me/shifts.get" },
82
+ // Static, so it wins over `me/:assignmentId`.
83
+ { method: "get", path: "me/leads", file: "me/leads.get" },
84
+ { method: "get", path: "me/now", file: "me/now.get" },
85
+ { method: "get", path: "me/earned-perks", file: "me/earned-perks.get" },
86
+ { method: "post", path: "me/earned-perks/:earnedPerkId/claim", file: "me/earned-perk-claim.post" },
87
+ { method: "get", path: "me/feed-token", file: "me/feed-token.get" },
88
+ { method: "post", path: "me/feed-token", file: "me/feed-token.post" },
89
+ { method: "delete", path: "me/feed-token", file: "me/feed-token.delete" },
90
+ { method: "get", path: "me/:assignmentId", file: "me/shift.get" },
91
+ { method: "get", path: "me/:assignmentId/pass", file: "me/pass.get" },
92
+ { method: "post", path: "me/:assignmentId/settle", file: "me/settle.post" },
93
+ { method: "post", path: "me/:assignmentId/check-in", file: "me/check-in.post" },
94
+ { method: "post", path: "me/:assignmentId/swap", file: "me/swap.post" },
95
+ { method: "delete", path: "me/:assignmentId/swap", file: "me/swap.delete" },
96
+ // The calendar feed: public, the secret in the path is the credential (`feed/<token>`, `.ics` suffix stripped by the handler).
97
+ { method: "get", path: "feed/:token", file: "feed/feed.get" },
98
+ { method: "get", path: "swaps", file: "swaps/list.get" },
99
+ { method: "post", path: "swaps/:swapId/offers", file: "swaps/offer.post" },
100
+ { method: "delete", path: "swaps/:swapId/offers/:offerId", file: "swaps/offer.delete" },
101
+ { method: "post", path: "swaps/:swapId/offers/:offerId/accept", file: "swaps/offer-accept.post" },
102
+ { method: "post", path: "swaps/:swapId/offers/:offerId/reject", file: "swaps/offer-reject.post" },
103
+ { method: "post", path: "swaps/:swapId/approve", file: "swaps/approve.post" },
104
+ { method: "post", path: "swaps/:swapId/reject", file: "swaps/reject.post" },
105
+ { method: "post", path: "teams/:teamId/check-in", file: "lead/check-in.post" },
106
+ { method: "get", path: "teams/:teamId/shifts", file: "lead/team-shifts.get" },
107
+ { method: "get", path: "teams/:teamId/swaps", file: "lead/team-swaps.get" },
108
+ { method: "post", path: "teams/:teamId/broadcasts", file: "lead/broadcast.post" },
109
+ { method: "get", path: "teams/:teamId/exceptions", file: "lead/exceptions.get" },
110
+ { method: "get", path: "teams/:teamId/stations", file: "lead/stations.get" },
111
+ { method: "get", path: "stations/:stationId/token", file: "stations/token.get" },
112
+ { method: "post", path: "assignments/:assignmentId/attended", file: "lead/attended.post" },
113
+ { method: "post", path: "assignments/:assignmentId/no-show", file: "lead/no-show.post" },
114
+ { method: "get", path: "operations/:operationId/now", file: "lead/now.get" },
115
+ { method: "get", path: "operations/:operationId/on-duty", file: "lead/on-duty.get" }
116
+ ], { base: "/api/shifts" });
117
+ addModuleRoutes(resolver, [
118
+ { method: "get", path: "schedules", file: "admin/schedules.get" },
119
+ { method: "post", path: "schedules", file: "admin/schedules.post" },
120
+ { method: "get", path: "schedules/:scheduleId", file: "admin/schedule.get" },
121
+ { method: "patch", path: "schedules/:scheduleId", file: "admin/schedule.patch" },
122
+ { method: "delete", path: "schedules/:scheduleId", file: "admin/schedule.delete" },
123
+ { method: "post", path: "schedules/:scheduleId/publish", file: "admin/schedule-publish.post" },
124
+ { method: "post", path: "schedules/:scheduleId/copy-from", file: "admin/schedule-copy.post" },
125
+ { method: "get", path: "schedules/:scheduleId/roles", file: "admin/roles.get" },
126
+ { method: "post", path: "schedules/:scheduleId/roles", file: "admin/roles.post" },
127
+ { method: "get", path: "schedules/:scheduleId/stations", file: "admin/stations.get" },
128
+ { method: "post", path: "schedules/:scheduleId/stations", file: "admin/stations.post" },
129
+ { method: "patch", path: "stations/:stationId", file: "admin/station.patch" },
130
+ { method: "delete", path: "stations/:stationId", file: "admin/station.delete" },
131
+ { method: "get", path: "schedules/:scheduleId/shifts", file: "admin/shifts.get" },
132
+ { method: "post", path: "schedules/:scheduleId/shifts/bulk", file: "admin/shifts-bulk.post" },
133
+ { method: "patch", path: "roles/:roleId", file: "admin/role.patch" },
134
+ { method: "delete", path: "roles/:roleId", file: "admin/role.delete" },
135
+ { method: "delete", path: "assignments/:assignmentId", file: "admin/assignment.delete" },
136
+ { method: "get", path: "swaps", file: "admin/swaps.get" },
137
+ { method: "post", path: "swaps/:swapId/cancel", file: "admin/swap-cancel.post" },
138
+ { method: "get", path: "operations/:operationId/teams", file: "admin/operation-teams.get" },
139
+ { method: "get", path: "broadcasts", file: "admin/broadcasts.get" },
140
+ { method: "post", path: "broadcasts", file: "admin/broadcasts.post" },
141
+ { method: "get", path: "operations/:operationId/perks", file: "admin/perks.get" },
142
+ { method: "post", path: "operations/:operationId/perks", file: "admin/perks.post" },
143
+ { method: "patch", path: "perks/:perkId", file: "admin/perk.patch" },
144
+ { method: "delete", path: "perks/:perkId", file: "admin/perk.delete" },
145
+ // A shift is the module's main resource: `/api/admin/shifts/:shiftId`. The static segments above win over it.
146
+ { method: "patch", path: ":shiftId", file: "admin/shift.patch" },
147
+ { method: "delete", path: ":shiftId", file: "admin/shift.delete" },
148
+ { method: "post", path: ":shiftId/assignments", file: "admin/assignments.post" },
149
+ { method: "get", path: ":shiftId/candidates", file: "admin/candidates.get" }
150
+ ], { base: "/api/admin/shifts" });
151
+ addServerImportsDir(resolver.resolve("./runtime/server/utils"));
152
+ inlineModuleRuntime(nuxt, resolver);
153
+ addServerPlugin(resolver.resolve("./runtime/server/plugins/teams"));
154
+ addServerPlugin(resolver.resolve("./runtime/server/plugins/station-key"));
155
+ nuxt.hook("notify:email:templates", (sources) => sources.push({ dir: resolver.resolve("./runtime/emails") }));
156
+ const tasks = [
157
+ {
158
+ name: "shifts:send-reminders",
159
+ handler: "./runtime/server/tasks/send-reminders",
160
+ description: "Email (and optionally text) people before their shifts start.",
161
+ cron: options.reminders?.cron === void 0 ? "*/10 * * * *" : options.reminders.cron
162
+ },
163
+ {
164
+ name: "shifts:close-shifts",
165
+ handler: "./runtime/server/tasks/close-shifts",
166
+ description: "Give out the perks of ended shifts, mark auto no-shows and send the leads their digest.",
167
+ cron: options.automation?.cron === void 0 ? "*/5 * * * *" : options.automation.cron
168
+ }
169
+ ];
170
+ nuxt.hook("nitro:config", (nitroConfig) => {
171
+ nitroConfig.experimental ||= {};
172
+ nitroConfig.experimental.tasks = true;
173
+ nitroConfig.tasks ||= {};
174
+ nitroConfig.scheduledTasks ||= {};
175
+ for (const task of tasks) {
176
+ nitroConfig.tasks[task.name] = { handler: resolver.resolve(task.handler), description: task.description };
177
+ if (!task.cron) continue;
178
+ const existing = nitroConfig.scheduledTasks[task.cron];
179
+ nitroConfig.scheduledTasks[task.cron] = [...Array.isArray(existing) ? existing : existing ? [existing] : [], task.name];
180
+ }
181
+ });
182
+ const crons = tasks.map((task) => task.cron).filter((cron) => !!cron);
183
+ if (crons.length) {
184
+ nuxt.hook("nitro:init", (nitro) => {
185
+ if (!nitro.options.preset.startsWith("cloudflare")) return;
186
+ const wrangler = (nitro.options.cloudflare ||= {}).wrangler ||= {};
187
+ wrangler.triggers = { ...wrangler.triggers, crons: [.../* @__PURE__ */ new Set([...wrangler.triggers?.crons ?? [], ...crons])] };
188
+ });
189
+ }
190
+ addImports([
191
+ { name: "useShiftsLinks", from: resolver.resolve("./runtime/app/composables/useShiftsLinks") },
192
+ { name: "useShiftsTranslate", from: resolver.resolve("./runtime/app/composables/useShiftsTranslate") },
193
+ { name: "useShiftsFormat", from: resolver.resolve("./runtime/app/composables/useShiftsFormat") },
194
+ { name: "useShiftsActions", from: resolver.resolve("./runtime/app/composables/useShiftsActions") },
195
+ { name: "useShiftsVenueFeatures", from: resolver.resolve("./runtime/app/composables/useShiftsVenueFeatures") },
196
+ { name: "SHIFTS_NO_FEATURE", from: resolver.resolve("./runtime/app/composables/useShiftsVenueFeatures") }
197
+ ]);
198
+ addComponentsDir({ path: resolver.resolve("./runtime/app/components") });
199
+ addModulePages(MODULE_NAME, resolver, [
200
+ { name: "shifts-mine", path: shiftsPath, file: "./runtime/app/pages/shifts.vue" },
201
+ // The swaps page before the detail page: `/shifts/swaps` is not an assignment id.
202
+ { name: "shifts-swaps", path: swapsPath, file: "./runtime/app/pages/swaps.vue" },
203
+ { name: "shifts-check-in", path: checkInPath, file: "./runtime/app/pages/check-in.vue" },
204
+ { name: "shifts-lead", path: leadPath, file: "./runtime/app/pages/lead.vue" },
205
+ // Before the detail page: `/shifts/station/:stationId` has two segments after `/shifts`.
206
+ { name: "shifts-station", path: stationPath, file: "./runtime/app/pages/station.vue" },
207
+ { name: "shifts-shift", path: shiftPath, file: "./runtime/app/pages/shift.vue" }
208
+ ]);
209
+ extendMaps(nuxt, {
210
+ layers: [defineMapLayer({
211
+ id: "shifts.on-duty",
212
+ label: { da: "P\xE5 vagt nu", en: "On duty now" },
213
+ appliesTo: OPERATIONS_VENUE_SURFACE,
214
+ endpoint: "/api/shifts/operations/:operationId/on-duty",
215
+ permission: shiftsAccess.permissions.read,
216
+ refreshInterval: 120
217
+ })]
218
+ });
219
+ if (settings.operationsTab !== false && hasNuxtModule("@frigear-nu/widget") && hasNuxtModule("@frigear-nu/admin")) {
220
+ const { extendTabs } = await import('@frigear-nu/widget/utils');
221
+ extendTabs(nuxt, "admin.operations", {
222
+ id: "shifts",
223
+ component: resolver.resolve("./runtime/app/tabs/Shifts.vue"),
224
+ order: 30,
225
+ label: "Shifts",
226
+ labelKey: "shifts.admin.tabs.shifts",
227
+ icon: "i-lucide-calendar-clock",
228
+ permission: shiftsAccess.permissions.manage
229
+ });
230
+ }
231
+ if (shiftsPath && hasNuxtModule("@frigear-nu/mobile")) {
232
+ const { extendMobileTabs } = await import('@frigear-nu/mobile/utils');
233
+ extendMobileTabs(nuxt, {
234
+ id: "shifts",
235
+ to: shiftsPath,
236
+ label: "Shifts",
237
+ labelKey: "shifts.mobile.tab",
238
+ icon: "i-lucide-calendar-clock",
239
+ sfSymbol: "calendar",
240
+ sfSymbolActive: "calendar.circle.fill",
241
+ requiresAuth: true
242
+ });
243
+ }
244
+ extendNotificationTopics(nuxt, shiftsNotificationTopics);
245
+ if (hasNuxtModule("@frigear-nu/dashboard")) {
246
+ const { extendDashboard } = await import('@frigear-nu/dashboard/utils');
247
+ extendDashboard(nuxt, SHIFTS_DASHBOARD, shiftsDashboardItems((path) => resolver.resolve(path)));
248
+ }
249
+ addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "account" });
250
+ }
251
+ });
252
+
253
+ export { module$1 as default };
@@ -0,0 +1,2 @@
1
+ export declare const shiftsAccess: import("@frigear-nu/auth/access").Access<"shifts", "read" | "swap" | "lead" | "attend" | "feed" | "broadcast" | "manage" | "pii", "shifts", never>;
2
+ export declare const perksAccess: import("@frigear-nu/auth/access").Access<"perks", "perks:read" | "perks:claim", "perks", never>;
@@ -0,0 +1,84 @@
1
+ import { defineAccess } from "@frigear-nu/auth/access";
2
+ export const shiftsAccess = defineAccess("shifts", {
3
+ permissions: {
4
+ // Held by everyone, narrowed by the policy: your own shifts, the operations you take part in, the teams you lead, staff.
5
+ read: {
6
+ label: "Read shifts",
7
+ description: "See your own shifts, and who is on shift now in the operations you work at.",
8
+ implicit: true
9
+ },
10
+ // Held by everyone, narrowed by the policy to the person's own assignments.
11
+ swap: {
12
+ label: "Swap shifts",
13
+ description: "Offer your own shifts for a swap, and offer to take other people's.",
14
+ implicit: true
15
+ },
16
+ // Held by everyone, narrowed by the policy to the leads of the record's team (lead role and up) and staff.
17
+ lead: {
18
+ label: "Lead shifts",
19
+ description: "Check people in, mark attendance and approve swaps on the teams you lead.",
20
+ implicit: true
21
+ },
22
+ // Held by everyone, narrowed by the policy to the person's own assignments: checking in at a station or by location.
23
+ attend: {
24
+ label: "Check in on your shifts",
25
+ description: "Check in on your own shifts by scanning a station's code or by your location.",
26
+ implicit: true
27
+ },
28
+ // Held by everyone, but only through a signed-in session: the calendar feed URL is a secret that shows your shifts to
29
+ // whoever holds it, so a token (or an OAuth client) cannot mint or revoke one.
30
+ feed: {
31
+ label: "Subscribe to your shifts in a calendar",
32
+ description: "Create and revoke the secret calendar feed (iCal) of your own shifts.",
33
+ implicit: true,
34
+ sessionOnly: true
35
+ },
36
+ // Messages people by email and SMS; leads send to their own team through `shifts:lead` instead.
37
+ broadcast: {
38
+ label: "Message shift teams",
39
+ description: "Send an email (and an SMS, on purpose) to the members of an operation's teams or the people on a shift.",
40
+ grantTo: ["admin"]
41
+ },
42
+ manage: {
43
+ label: "Manage shifts",
44
+ description: "Create and publish schedules, create shifts in bulk, assign people and handle every swap.",
45
+ grantTo: ["admin"]
46
+ },
47
+ // Sensitive (`:pii`): never covered by `shifts:*` or `*`, only granted by name.
48
+ pii: {
49
+ label: "See the contact details of people on shift",
50
+ description: "See the email address and phone number of the people on a shift.",
51
+ grantTo: ["admin"]
52
+ }
53
+ },
54
+ scopes: {
55
+ shifts: {
56
+ label: "Shifts",
57
+ description: "See your own shifts.",
58
+ icon: "i-lucide-calendar-clock",
59
+ permissions: ["shifts:read"]
60
+ }
61
+ }
62
+ });
63
+ export const perksAccess = defineAccess("perks", {
64
+ permissions: {
65
+ "perks:read": {
66
+ label: "Read your perks",
67
+ description: "See the perks you earned on your shifts.",
68
+ implicit: true
69
+ },
70
+ "perks:claim": {
71
+ label: "Claim your perks",
72
+ description: "Mark the perks you earned as claimed, so an app can hand them out.",
73
+ implicit: true
74
+ }
75
+ },
76
+ scopes: {
77
+ perks: {
78
+ label: "Perks",
79
+ description: "See and claim the perks you earned on your shifts.",
80
+ icon: "i-lucide-ticket",
81
+ permissions: ["perks:read", "perks:claim"]
82
+ }
83
+ }
84
+ });
@@ -0,0 +1,19 @@
1
+ import type { ShiftsLadder, ShiftsTeamOption } from '../utils/admin-shifts.js';
2
+ import type { ShiftBroadcastResultDto } from '../../../types.js';
3
+ type __VLS_Props = {
4
+ /** Staff: the operation to message. */
5
+ operationId?: string;
6
+ /** A lead: the team to message. */
7
+ teamId?: string;
8
+ /** The name of the team a lead messages. */
9
+ teamName?: string;
10
+ teams?: ShiftsTeamOption[];
11
+ ladders?: ShiftsLadder[];
12
+ };
13
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
+ close: (sent: false | ShiftBroadcastResultDto) => any;
15
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
16
+ onClose?: ((sent: false | ShiftBroadcastResultDto) => any) | undefined;
17
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -0,0 +1,142 @@
1
+ <script setup>
2
+ import { z } from "zod";
3
+ import { shiftsRoleOptions } from "../utils/admin-shifts";
4
+ import { shiftsApi } from "../../utils/api";
5
+ import { $fetch, computed, reactive, useAction, useModuleT, useShiftsTranslate, useToast } from "#imports";
6
+ defineOptions({ name: "ShiftBroadcastSlideover" });
7
+ const props = defineProps({
8
+ operationId: { type: String, required: false },
9
+ teamId: { type: String, required: false },
10
+ teamName: { type: String, required: false },
11
+ teams: { type: Array, required: false },
12
+ ladders: { type: Array, required: false }
13
+ });
14
+ const emit = defineEmits(["close"]);
15
+ const t = useModuleT("shifts");
16
+ const tr = useShiftsTranslate();
17
+ const { busy, run } = useAction();
18
+ const ALL = "__all__";
19
+ const ANY = "__any__";
20
+ const filled = (value) => !!value && (typeof value === "string" ? !!value.trim() : Object.values(value).some((text) => text?.trim()));
21
+ const schema = z.object({
22
+ teamId: z.string(),
23
+ teamRole: z.string(),
24
+ subject: z.custom(filled, t("broadcast.subjectRequired", "Give the message a subject.")),
25
+ message: z.custom(filled, t("broadcast.messageRequired", "Write the message.")),
26
+ sms: z.boolean()
27
+ });
28
+ const state = reactive({ teamId: ALL, teamRole: ANY, subject: "", message: "", sms: false });
29
+ const teamOptions = computed(() => [{ label: t("admin.allTeams", "All teams"), value: ALL }, ...(props.teams ?? []).map((team) => ({ label: tr(team.name), value: team.id }))]);
30
+ const kind = computed(() => props.teams?.find((team) => team.id === state.teamId)?.kind);
31
+ const roleOptions = computed(() => [{ label: t("broadcast.anyRole", "Everyone on the team"), value: ANY }, ...shiftsRoleOptions(props.ladders, kind.value, tr)]);
32
+ const audienceHelp = computed(() => props.teamId ? t("broadcast.leadAudience", "Everyone on {team}.", { team: props.teamName ?? "" }) : t("broadcast.audienceHelp", "The active members of the operation's teams. At most 500 people at once."));
33
+ async function send(event) {
34
+ const { data } = event;
35
+ const channels = data.sms ? ["email", "sms"] : ["email"];
36
+ const body = props.teamId ? { audience: {}, channels, subject: data.subject, message: data.message } : {
37
+ operationId: props.operationId,
38
+ audience: { ...data.teamId === ALL ? {} : { teamId: data.teamId }, ...data.teamId !== ALL && data.teamRole !== ANY ? { teamRole: data.teamRole } : {} },
39
+ channels,
40
+ subject: data.subject,
41
+ message: data.message
42
+ };
43
+ const sent = await run(
44
+ () => $fetch(props.teamId ? shiftsApi.teams.broadcasts(props.teamId) : shiftsApi.admin.broadcasts, { method: "POST", body }),
45
+ { error: t("broadcast.failed", "Could not send the message") }
46
+ );
47
+ if (sent) {
48
+ notifySent(sent);
49
+ emit("close", sent);
50
+ }
51
+ }
52
+ const toast = useToast();
53
+ function notifySent(sent) {
54
+ toast.add({
55
+ title: sent.delivery === "queued" ? t("broadcast.queued", "Sending to {count} people", { count: sent.recipientCount }) : t("broadcast.sent", "Sent to {count} people", { count: sent.recipientCount }),
56
+ description: sent.delivery === "queued" ? t("broadcast.queuedDetail", "The messages go out in the background.") : sent.sent.sms ? t("broadcast.sentDetail", "{email} emails and {sms} texts.", { email: sent.sent.email, sms: sent.sent.sms }) : t("broadcast.sentEmails", "{email} emails.", { email: sent.sent.email }),
57
+ color: "success"
58
+ });
59
+ }
60
+ </script>
61
+
62
+ <template>
63
+ <FormSlideover
64
+ form-id="shift-broadcast-form"
65
+ :title="teamId ? t('broadcast.leadTitle', 'Message {team}', { team: teamName ?? '' }) : t('broadcast.title', 'Message teams')"
66
+ :description="audienceHelp"
67
+ :submit-label="t('broadcast.submit', 'Send message')"
68
+ :loading="busy"
69
+ @close="emit('close', false)"
70
+ >
71
+ <UForm
72
+ id="shift-broadcast-form"
73
+ :schema="schema"
74
+ :state="state"
75
+ class="flex flex-col gap-4"
76
+ @submit="send"
77
+ >
78
+ <template v-if="!teamId">
79
+ <UFormField
80
+ name="teamId"
81
+ :label="t('admin.team', 'Team')"
82
+ >
83
+ <USelect
84
+ v-model="state.teamId"
85
+ :items="teamOptions"
86
+ class="w-full"
87
+ />
88
+ </UFormField>
89
+ <UFormField
90
+ v-if="state.teamId !== ALL"
91
+ name="teamRole"
92
+ :label="t('broadcast.role', 'Role')"
93
+ :description="t('broadcast.roleHelp', 'This role and everyone above it on the team\'s ladder.')"
94
+ >
95
+ <USelect
96
+ v-model="state.teamRole"
97
+ :items="roleOptions"
98
+ class="w-full"
99
+ />
100
+ </UFormField>
101
+ </template>
102
+ <UFormField
103
+ name="subject"
104
+ :label="t('broadcast.subject', 'Subject')"
105
+ required
106
+ >
107
+ <TranslatedInput
108
+ v-model="state.subject"
109
+ class="w-full"
110
+ />
111
+ </UFormField>
112
+ <UFormField
113
+ name="message"
114
+ :label="t('broadcast.message', 'Message')"
115
+ :description="t('broadcast.messageHelp', 'Each person gets the text in their own language when you write it in several.')"
116
+ required
117
+ >
118
+ <TranslatedInput
119
+ v-model="state.message"
120
+ multiline
121
+ :preview="false"
122
+ :rows="5"
123
+ class="w-full"
124
+ />
125
+ </UFormField>
126
+ <UFormField
127
+ name="sms"
128
+ :label="t('broadcast.sms', 'Also send a text message')"
129
+ >
130
+ <USwitch v-model="state.sms" />
131
+ </UFormField>
132
+ <UAlert
133
+ v-if="state.sms"
134
+ color="warning"
135
+ variant="subtle"
136
+ icon="i-lucide-coins"
137
+ :title="t('broadcast.smsCost', 'Texts cost money')"
138
+ :description="t('broadcast.smsWarning', 'Everyone with a phone number gets a text as well as the email. Use it when people need to know right now.')"
139
+ />
140
+ </UForm>
141
+ </FormSlideover>
142
+ </template>
@@ -0,0 +1,19 @@
1
+ import type { ShiftsLadder, ShiftsTeamOption } from '../utils/admin-shifts.js';
2
+ import type { ShiftBroadcastResultDto } from '../../../types.js';
3
+ type __VLS_Props = {
4
+ /** Staff: the operation to message. */
5
+ operationId?: string;
6
+ /** A lead: the team to message. */
7
+ teamId?: string;
8
+ /** The name of the team a lead messages. */
9
+ teamName?: string;
10
+ teams?: ShiftsTeamOption[];
11
+ ladders?: ShiftsLadder[];
12
+ };
13
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
+ close: (sent: false | ShiftBroadcastResultDto) => any;
15
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
16
+ onClose?: ((sent: false | ShiftBroadcastResultDto) => any) | undefined;
17
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import type { ShiftsLadder, ShiftsTeamOption } from '../utils/admin-shifts.js';
2
+ type __VLS_Props = {
3
+ operationId: string;
4
+ teams: ShiftsTeamOption[];
5
+ ladders: ShiftsLadder[];
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,74 @@
1
+ <script setup>
2
+ import { shiftsRoleLabel } from "../utils/admin-shifts";
3
+ import { shiftsApi } from "../../utils/api";
4
+ import { computed, h, resolveComponent, tableUi, useFetch, useModuleT, useShiftsActions, useShiftsFormat, useShiftsTranslate } from "#imports";
5
+ defineOptions({ name: "ShiftBroadcastsCard" });
6
+ const props = defineProps({
7
+ operationId: { type: String, required: true },
8
+ teams: { type: Array, required: true },
9
+ ladders: { type: Array, required: true }
10
+ });
11
+ const t = useModuleT("shifts");
12
+ const tr = useShiftsTranslate();
13
+ const format = useShiftsFormat();
14
+ const actions = useShiftsActions();
15
+ const { data: broadcasts, status, error, refresh } = await useFetch(shiftsApi.admin.broadcasts, {
16
+ query: computed(() => ({ operationId: props.operationId })),
17
+ key: computed(() => `shifts:broadcasts:${props.operationId}`),
18
+ default: () => []
19
+ });
20
+ const allowed = computed(() => error.value?.statusCode !== 403);
21
+ async function send() {
22
+ if (await actions.broadcast(props.operationId, { teams: props.teams, ladders: props.ladders })) await refresh();
23
+ }
24
+ const StatusBadge = resolveComponent("StatusBadge");
25
+ const audience = (item) => {
26
+ if (item.shiftId) return t("broadcast.audienceShift", "People on a shift");
27
+ const team = item.teamId ? props.teams.find((candidate) => candidate.id === item.teamId) : void 0;
28
+ const base = team ? tr(team.name) : t("admin.allTeams", "All teams");
29
+ return item.teamRole ? `${base} \xB7 ${shiftsRoleLabel(props.ladders, team?.kind, item.teamRole, tr)}+` : base;
30
+ };
31
+ const columns = computed(() => [
32
+ { accessorKey: "createdAt", header: t("broadcast.when", "Sent"), cell: ({ row }) => h("span", { class: "tabular-nums" }, format.dateTime(row.original.createdAt)) },
33
+ { accessorKey: "subject", header: t("broadcast.subject", "Subject"), cell: ({ row }) => h("span", { class: "text-highlighted font-medium" }, tr(row.original.subject)) },
34
+ { id: "audience", header: t("broadcast.audience", "To"), cell: ({ row }) => audience(row.original) },
35
+ { accessorKey: "recipientCount", header: t("broadcast.recipients", "People"), cell: ({ row }) => String(row.original.recipientCount) },
36
+ {
37
+ id: "channels",
38
+ header: t("broadcast.channels", "Sent by"),
39
+ cell: ({ row }) => h("div", { class: "flex gap-1" }, row.original.channels.map((channel) => h(StatusBadge, { key: channel, status: channel, label: channel === "sms" ? t("broadcast.channelSms", "Text") : t("broadcast.channelEmail", "Email"), colors: { email: "neutral", sms: "warning" } })))
40
+ }
41
+ ]);
42
+ </script>
43
+
44
+ <template>
45
+ <TableCard
46
+ v-if="allowed"
47
+ :title="t('broadcast.cardTitle', 'Messages')"
48
+ :description="t('broadcast.cardDescription', 'Emails to the people on the operation\'s teams. A text message is sent only when you ask for it.')"
49
+ :loading="status === 'pending' && !broadcasts.length"
50
+ >
51
+ <template #actions>
52
+ <UButton
53
+ icon="i-lucide-send"
54
+ :label="t('broadcast.title', 'Message teams')"
55
+ :disabled="!teams.length"
56
+ @click="send"
57
+ />
58
+ </template>
59
+ <UTable
60
+ :data="broadcasts"
61
+ :columns="columns"
62
+ :ui="tableUi()"
63
+ >
64
+ <template #empty>
65
+ <UEmpty
66
+ icon="i-lucide-megaphone"
67
+ :title="t('broadcast.empty', 'No messages sent yet')"
68
+ :description="t('broadcast.emptyDescription', 'Message a team, or the people with a role and up on it.')"
69
+ :actions="[{ label: t('broadcast.title', 'Message teams'), icon: 'i-lucide-send', onClick: send }]"
70
+ />
71
+ </template>
72
+ </UTable>
73
+ </TableCard>
74
+ </template>
@@ -0,0 +1,9 @@
1
+ import type { ShiftsLadder, ShiftsTeamOption } from '../utils/admin-shifts.js';
2
+ type __VLS_Props = {
3
+ operationId: string;
4
+ teams: ShiftsTeamOption[];
5
+ ladders: ShiftsLadder[];
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;