@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.
- package/README.md +53 -2
- package/dist/module.d.mts +709 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +253 -0
- package/dist/runtime/access.d.ts +2 -0
- package/dist/runtime/access.js +84 -0
- package/dist/runtime/app/components/ShiftBroadcastSlideover.d.vue.ts +19 -0
- package/dist/runtime/app/components/ShiftBroadcastSlideover.vue +142 -0
- package/dist/runtime/app/components/ShiftBroadcastSlideover.vue.d.ts +19 -0
- package/dist/runtime/app/components/ShiftBroadcastsCard.d.vue.ts +9 -0
- package/dist/runtime/app/components/ShiftBroadcastsCard.vue +74 -0
- package/dist/runtime/app/components/ShiftBroadcastsCard.vue.d.ts +9 -0
- package/dist/runtime/app/components/ShiftBulkSlideover.d.vue.ts +15 -0
- package/dist/runtime/app/components/ShiftBulkSlideover.vue +185 -0
- package/dist/runtime/app/components/ShiftBulkSlideover.vue.d.ts +15 -0
- package/dist/runtime/app/components/ShiftCheckInCard.d.vue.ts +13 -0
- package/dist/runtime/app/components/ShiftCheckInCard.vue +238 -0
- package/dist/runtime/app/components/ShiftCheckInCard.vue.d.ts +13 -0
- package/dist/runtime/app/components/ShiftCopySlideover.d.vue.ts +11 -0
- package/dist/runtime/app/components/ShiftCopySlideover.vue +71 -0
- package/dist/runtime/app/components/ShiftCopySlideover.vue.d.ts +11 -0
- package/dist/runtime/app/components/ShiftDayView.d.vue.ts +16 -0
- package/dist/runtime/app/components/ShiftDayView.vue +124 -0
- package/dist/runtime/app/components/ShiftDayView.vue.d.ts +16 -0
- package/dist/runtime/app/components/ShiftFeedSlideover.d.vue.ts +7 -0
- package/dist/runtime/app/components/ShiftFeedSlideover.vue +172 -0
- package/dist/runtime/app/components/ShiftFeedSlideover.vue.d.ts +7 -0
- package/dist/runtime/app/components/ShiftNowCard.d.vue.ts +6 -0
- package/dist/runtime/app/components/ShiftNowCard.vue +83 -0
- package/dist/runtime/app/components/ShiftNowCard.vue.d.ts +6 -0
- package/dist/runtime/app/components/ShiftPassFullscreen.d.vue.ts +13 -0
- package/dist/runtime/app/components/ShiftPassFullscreen.vue +79 -0
- package/dist/runtime/app/components/ShiftPassFullscreen.vue.d.ts +13 -0
- package/dist/runtime/app/components/ShiftPerkSlideover.d.vue.ts +14 -0
- package/dist/runtime/app/components/ShiftPerkSlideover.vue +103 -0
- package/dist/runtime/app/components/ShiftPerkSlideover.vue.d.ts +14 -0
- package/dist/runtime/app/components/ShiftPerksCard.d.vue.ts +8 -0
- package/dist/runtime/app/components/ShiftPerksCard.vue +66 -0
- package/dist/runtime/app/components/ShiftPerksCard.vue.d.ts +8 -0
- package/dist/runtime/app/components/ShiftQrScanner.d.vue.ts +10 -0
- package/dist/runtime/app/components/ShiftQrScanner.vue +44 -0
- package/dist/runtime/app/components/ShiftQrScanner.vue.d.ts +10 -0
- package/dist/runtime/app/components/ShiftRoleSlideover.d.vue.ts +15 -0
- package/dist/runtime/app/components/ShiftRoleSlideover.vue +88 -0
- package/dist/runtime/app/components/ShiftRoleSlideover.vue.d.ts +15 -0
- package/dist/runtime/app/components/ShiftScheduleSettingsFields.d.vue.ts +11 -0
- package/dist/runtime/app/components/ShiftScheduleSettingsFields.vue +61 -0
- package/dist/runtime/app/components/ShiftScheduleSettingsFields.vue.d.ts +11 -0
- package/dist/runtime/app/components/ShiftScheduleSlideover.d.vue.ts +12 -0
- package/dist/runtime/app/components/ShiftScheduleSlideover.vue +129 -0
- package/dist/runtime/app/components/ShiftScheduleSlideover.vue.d.ts +12 -0
- package/dist/runtime/app/components/ShiftSlideover.d.vue.ts +13 -0
- package/dist/runtime/app/components/ShiftSlideover.vue +353 -0
- package/dist/runtime/app/components/ShiftSlideover.vue.d.ts +13 -0
- package/dist/runtime/app/components/ShiftStationSlideover.d.vue.ts +15 -0
- package/dist/runtime/app/components/ShiftStationSlideover.vue +92 -0
- package/dist/runtime/app/components/ShiftStationSlideover.vue.d.ts +15 -0
- package/dist/runtime/app/composables/index.d.ts +6 -0
- package/dist/runtime/app/composables/index.js +5 -0
- package/dist/runtime/app/composables/useShiftsActions.d.ts +61 -0
- package/dist/runtime/app/composables/useShiftsActions.js +224 -0
- package/dist/runtime/app/composables/useShiftsFormat.d.ts +12 -0
- package/dist/runtime/app/composables/useShiftsFormat.js +14 -0
- package/dist/runtime/app/composables/useShiftsLinks.d.ts +12 -0
- package/dist/runtime/app/composables/useShiftsLinks.js +6 -0
- package/dist/runtime/app/composables/useShiftsTranslate.d.ts +5 -0
- package/dist/runtime/app/composables/useShiftsTranslate.js +12 -0
- package/dist/runtime/app/composables/useShiftsVenueFeatures.d.ts +17 -0
- package/dist/runtime/app/composables/useShiftsVenueFeatures.js +18 -0
- package/dist/runtime/app/dashboard/NextShift.d.vue.ts +3 -0
- package/dist/runtime/app/dashboard/NextShift.vue +69 -0
- package/dist/runtime/app/dashboard/NextShift.vue.d.ts +3 -0
- package/dist/runtime/app/dashboard/OpenSwaps.d.vue.ts +3 -0
- package/dist/runtime/app/dashboard/OpenSwaps.vue +69 -0
- package/dist/runtime/app/dashboard/OpenSwaps.vue.d.ts +3 -0
- package/dist/runtime/app/dashboard/TeamOnNow.d.vue.ts +3 -0
- package/dist/runtime/app/dashboard/TeamOnNow.vue +72 -0
- package/dist/runtime/app/dashboard/TeamOnNow.vue.d.ts +3 -0
- package/dist/runtime/app/pages/check-in.d.vue.ts +3 -0
- package/dist/runtime/app/pages/check-in.vue +93 -0
- package/dist/runtime/app/pages/check-in.vue.d.ts +3 -0
- package/dist/runtime/app/pages/lead.d.vue.ts +3 -0
- package/dist/runtime/app/pages/lead.vue +300 -0
- package/dist/runtime/app/pages/lead.vue.d.ts +3 -0
- package/dist/runtime/app/pages/shift.d.vue.ts +3 -0
- package/dist/runtime/app/pages/shift.vue +482 -0
- package/dist/runtime/app/pages/shift.vue.d.ts +3 -0
- package/dist/runtime/app/pages/shifts.d.vue.ts +3 -0
- package/dist/runtime/app/pages/shifts.vue +169 -0
- package/dist/runtime/app/pages/shifts.vue.d.ts +3 -0
- package/dist/runtime/app/pages/station.d.vue.ts +3 -0
- package/dist/runtime/app/pages/station.vue +104 -0
- package/dist/runtime/app/pages/station.vue.d.ts +3 -0
- package/dist/runtime/app/pages/swaps.d.vue.ts +3 -0
- package/dist/runtime/app/pages/swaps.vue +192 -0
- package/dist/runtime/app/pages/swaps.vue.d.ts +3 -0
- package/dist/runtime/app/tabs/Shifts.d.vue.ts +9 -0
- package/dist/runtime/app/tabs/Shifts.vue +487 -0
- package/dist/runtime/app/tabs/Shifts.vue.d.ts +9 -0
- package/dist/runtime/app/utils/admin-shifts.d.ts +42 -0
- package/dist/runtime/app/utils/admin-shifts.js +36 -0
- package/dist/runtime/dashboard.d.ts +8 -0
- package/dist/runtime/dashboard.js +30 -0
- package/dist/runtime/emails/shifts-broadcast.d.vue.ts +8 -0
- package/dist/runtime/emails/shifts-broadcast.vue +24 -0
- package/dist/runtime/emails/shifts-broadcast.vue.d.ts +8 -0
- package/dist/runtime/emails/shifts-reminder.d.vue.ts +12 -0
- package/dist/runtime/emails/shifts-reminder.vue +34 -0
- package/dist/runtime/emails/shifts-reminder.vue.d.ts +12 -0
- package/dist/runtime/emails/shifts-swap-accepted.d.vue.ts +11 -0
- package/dist/runtime/emails/shifts-swap-accepted.vue +32 -0
- package/dist/runtime/emails/shifts-swap-accepted.vue.d.ts +11 -0
- package/dist/runtime/emails/shifts-swap-completed.d.vue.ts +11 -0
- package/dist/runtime/emails/shifts-swap-completed.vue +32 -0
- package/dist/runtime/emails/shifts-swap-completed.vue.d.ts +11 -0
- package/dist/runtime/emails/shifts-swap-offered.d.vue.ts +11 -0
- package/dist/runtime/emails/shifts-swap-offered.vue +32 -0
- package/dist/runtime/emails/shifts-swap-offered.vue.d.ts +11 -0
- package/dist/runtime/emails/shifts-swap-pending.d.vue.ts +11 -0
- package/dist/runtime/emails/shifts-swap-pending.vue +32 -0
- package/dist/runtime/emails/shifts-swap-pending.vue.d.ts +11 -0
- package/dist/runtime/emails/shifts-swap-proposed.d.vue.ts +11 -0
- package/dist/runtime/emails/shifts-swap-proposed.vue +32 -0
- package/dist/runtime/emails/shifts-swap-proposed.vue.d.ts +11 -0
- package/dist/runtime/emails/shifts-swap-rejected.d.vue.ts +11 -0
- package/dist/runtime/emails/shifts-swap-rejected.vue +32 -0
- package/dist/runtime/emails/shifts-swap-rejected.vue.d.ts +11 -0
- package/dist/runtime/i18n/lang/da.json +626 -0
- package/dist/runtime/i18n/lang/en.json +626 -0
- package/dist/runtime/menus.d.ts +2 -0
- package/dist/runtime/menus.js +17 -0
- package/dist/runtime/notifications.d.ts +9 -0
- package/dist/runtime/notifications.js +36 -0
- package/dist/runtime/server/db/schema.postgresql.d.ts +2151 -0
- package/dist/runtime/server/db/schema.postgresql.js +228 -0
- package/dist/runtime/server/db/schema.sqlite.d.ts +2263 -0
- package/dist/runtime/server/db/schema.sqlite.js +228 -0
- package/dist/runtime/server/digest-email.d.ts +17 -0
- package/dist/runtime/server/digest-email.js +42 -0
- package/dist/runtime/server/plugins/station-key.d.ts +2 -0
- package/dist/runtime/server/plugins/station-key.js +5 -0
- package/dist/runtime/server/plugins/teams.d.ts +2 -0
- package/dist/runtime/server/plugins/teams.js +19 -0
- package/dist/runtime/server/policies.d.ts +2 -0
- package/dist/runtime/server/policies.js +41 -0
- package/dist/runtime/server/reminder-email.d.ts +67 -0
- package/dist/runtime/server/reminder-email.js +109 -0
- package/dist/runtime/server/routes/admin/assignment.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/assignment.delete.js +10 -0
- package/dist/runtime/server/routes/admin/assignments.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/assignments.post.js +11 -0
- package/dist/runtime/server/routes/admin/broadcasts.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/broadcasts.get.js +8 -0
- package/dist/runtime/server/routes/admin/broadcasts.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/broadcasts.post.js +9 -0
- package/dist/runtime/server/routes/admin/candidates.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/candidates.get.js +10 -0
- package/dist/runtime/server/routes/admin/operation-teams.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/operation-teams.get.js +9 -0
- package/dist/runtime/server/routes/admin/perk.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/perk.delete.js +10 -0
- package/dist/runtime/server/routes/admin/perk.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/perk.patch.js +10 -0
- package/dist/runtime/server/routes/admin/perks.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/perks.get.js +9 -0
- package/dist/runtime/server/routes/admin/perks.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/perks.post.js +10 -0
- package/dist/runtime/server/routes/admin/role.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/role.delete.js +11 -0
- package/dist/runtime/server/routes/admin/role.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/role.patch.js +11 -0
- package/dist/runtime/server/routes/admin/roles.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/roles.get.js +9 -0
- package/dist/runtime/server/routes/admin/roles.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/roles.post.js +10 -0
- package/dist/runtime/server/routes/admin/schedule-copy.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/schedule-copy.post.js +12 -0
- package/dist/runtime/server/routes/admin/schedule-publish.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/schedule-publish.post.js +9 -0
- package/dist/runtime/server/routes/admin/schedule.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/schedule.delete.js +10 -0
- package/dist/runtime/server/routes/admin/schedule.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/schedule.get.js +9 -0
- package/dist/runtime/server/routes/admin/schedule.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/schedule.patch.js +10 -0
- package/dist/runtime/server/routes/admin/schedules.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/schedules.get.js +10 -0
- package/dist/runtime/server/routes/admin/schedules.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/schedules.post.js +9 -0
- package/dist/runtime/server/routes/admin/shift.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/shift.delete.js +10 -0
- package/dist/runtime/server/routes/admin/shift.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/shift.patch.js +10 -0
- package/dist/runtime/server/routes/admin/shifts-bulk.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/shifts-bulk.post.js +10 -0
- package/dist/runtime/server/routes/admin/shifts.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/shifts.get.js +10 -0
- package/dist/runtime/server/routes/admin/station.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/station.delete.js +11 -0
- package/dist/runtime/server/routes/admin/station.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/station.patch.js +11 -0
- package/dist/runtime/server/routes/admin/stations.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/stations.get.js +9 -0
- package/dist/runtime/server/routes/admin/stations.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/stations.post.js +10 -0
- package/dist/runtime/server/routes/admin/swap-cancel.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/swap-cancel.post.js +10 -0
- package/dist/runtime/server/routes/admin/swaps.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/swaps.get.js +10 -0
- package/dist/runtime/server/routes/feed/feed.get.d.ts +2 -0
- package/dist/runtime/server/routes/feed/feed.get.js +9 -0
- package/dist/runtime/server/routes/lead/attended.post.d.ts +2 -0
- package/dist/runtime/server/routes/lead/attended.post.js +11 -0
- package/dist/runtime/server/routes/lead/broadcast.post.d.ts +2 -0
- package/dist/runtime/server/routes/lead/broadcast.post.js +12 -0
- package/dist/runtime/server/routes/lead/check-in.post.d.ts +2 -0
- package/dist/runtime/server/routes/lead/check-in.post.js +9 -0
- package/dist/runtime/server/routes/lead/exceptions.get.d.ts +2 -0
- package/dist/runtime/server/routes/lead/exceptions.get.js +8 -0
- package/dist/runtime/server/routes/lead/no-show.post.d.ts +2 -0
- package/dist/runtime/server/routes/lead/no-show.post.js +11 -0
- package/dist/runtime/server/routes/lead/now.get.d.ts +2 -0
- package/dist/runtime/server/routes/lead/now.get.js +9 -0
- package/dist/runtime/server/routes/lead/on-duty.get.d.ts +2 -0
- package/dist/runtime/server/routes/lead/on-duty.get.js +10 -0
- package/dist/runtime/server/routes/lead/stations.get.d.ts +2 -0
- package/dist/runtime/server/routes/lead/stations.get.js +8 -0
- package/dist/runtime/server/routes/lead/team-shifts.get.d.ts +2 -0
- package/dist/runtime/server/routes/lead/team-shifts.get.js +9 -0
- package/dist/runtime/server/routes/lead/team-swaps.get.d.ts +2 -0
- package/dist/runtime/server/routes/lead/team-swaps.get.js +9 -0
- package/dist/runtime/server/routes/me/check-in.post.d.ts +2 -0
- package/dist/runtime/server/routes/me/check-in.post.js +11 -0
- package/dist/runtime/server/routes/me/earned-perk-claim.post.d.ts +2 -0
- package/dist/runtime/server/routes/me/earned-perk-claim.post.js +10 -0
- package/dist/runtime/server/routes/me/earned-perks.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/earned-perks.get.js +9 -0
- package/dist/runtime/server/routes/me/feed-token.delete.d.ts +2 -0
- package/dist/runtime/server/routes/me/feed-token.delete.js +7 -0
- package/dist/runtime/server/routes/me/feed-token.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/feed-token.get.js +6 -0
- package/dist/runtime/server/routes/me/feed-token.post.d.ts +2 -0
- package/dist/runtime/server/routes/me/feed-token.post.js +7 -0
- package/dist/runtime/server/routes/me/leads.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/leads.get.js +5 -0
- package/dist/runtime/server/routes/me/now.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/now.get.js +5 -0
- package/dist/runtime/server/routes/me/pass.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/pass.get.js +11 -0
- package/dist/runtime/server/routes/me/settle.post.d.ts +2 -0
- package/dist/runtime/server/routes/me/settle.post.js +14 -0
- package/dist/runtime/server/routes/me/shift.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/shift.get.js +10 -0
- package/dist/runtime/server/routes/me/shifts.get.d.ts +2 -0
- package/dist/runtime/server/routes/me/shifts.get.js +6 -0
- package/dist/runtime/server/routes/me/swap.delete.d.ts +2 -0
- package/dist/runtime/server/routes/me/swap.delete.js +11 -0
- package/dist/runtime/server/routes/me/swap.post.d.ts +2 -0
- package/dist/runtime/server/routes/me/swap.post.js +11 -0
- package/dist/runtime/server/routes/stations/token.get.d.ts +2 -0
- package/dist/runtime/server/routes/stations/token.get.js +12 -0
- package/dist/runtime/server/routes/swaps/approve.post.d.ts +2 -0
- package/dist/runtime/server/routes/swaps/approve.post.js +9 -0
- package/dist/runtime/server/routes/swaps/list.get.d.ts +2 -0
- package/dist/runtime/server/routes/swaps/list.get.js +5 -0
- package/dist/runtime/server/routes/swaps/offer-accept.post.d.ts +2 -0
- package/dist/runtime/server/routes/swaps/offer-accept.post.js +9 -0
- package/dist/runtime/server/routes/swaps/offer-reject.post.d.ts +2 -0
- package/dist/runtime/server/routes/swaps/offer-reject.post.js +9 -0
- package/dist/runtime/server/routes/swaps/offer.delete.d.ts +2 -0
- package/dist/runtime/server/routes/swaps/offer.delete.js +11 -0
- package/dist/runtime/server/routes/swaps/offer.post.d.ts +2 -0
- package/dist/runtime/server/routes/swaps/offer.post.js +11 -0
- package/dist/runtime/server/routes/swaps/reject.post.d.ts +2 -0
- package/dist/runtime/server/routes/swaps/reject.post.js +9 -0
- package/dist/runtime/server/swap-email.d.ts +28 -0
- package/dist/runtime/server/swap-email.js +49 -0
- package/dist/runtime/server/tasks/close-shifts.d.ts +2 -0
- package/dist/runtime/server/tasks/close-shifts.js +9 -0
- package/dist/runtime/server/tasks/send-reminders.d.ts +2 -0
- package/dist/runtime/server/tasks/send-reminders.js +9 -0
- package/dist/runtime/server/utils/shifts-admin.d.ts +67 -0
- package/dist/runtime/server/utils/shifts-admin.js +312 -0
- package/dist/runtime/server/utils/shifts-assign.d.ts +89 -0
- package/dist/runtime/server/utils/shifts-assign.js +264 -0
- package/dist/runtime/server/utils/shifts-automation.d.ts +37 -0
- package/dist/runtime/server/utils/shifts-automation.js +171 -0
- package/dist/runtime/server/utils/shifts-broadcasts.d.ts +38 -0
- package/dist/runtime/server/utils/shifts-broadcasts.js +113 -0
- package/dist/runtime/server/utils/shifts-core.d.ts +78 -0
- package/dist/runtime/server/utils/shifts-core.js +142 -0
- package/dist/runtime/server/utils/shifts-dto.d.ts +32 -0
- package/dist/runtime/server/utils/shifts-dto.js +127 -0
- package/dist/runtime/server/utils/shifts-emails.d.ts +16 -0
- package/dist/runtime/server/utils/shifts-emails.js +44 -0
- package/dist/runtime/server/utils/shifts-exceptions.d.ts +7 -0
- package/dist/runtime/server/utils/shifts-exceptions.js +32 -0
- package/dist/runtime/server/utils/shifts-feed.d.ts +16 -0
- package/dist/runtime/server/utils/shifts-feed.js +73 -0
- package/dist/runtime/server/utils/shifts-notify.d.ts +40 -0
- package/dist/runtime/server/utils/shifts-notify.js +22 -0
- package/dist/runtime/server/utils/shifts-on-duty.d.ts +12 -0
- package/dist/runtime/server/utils/shifts-on-duty.js +37 -0
- package/dist/runtime/server/utils/shifts-perks.d.ts +46 -0
- package/dist/runtime/server/utils/shifts-perks.js +183 -0
- package/dist/runtime/server/utils/shifts-reminders.d.ts +30 -0
- package/dist/runtime/server/utils/shifts-reminders.js +102 -0
- package/dist/runtime/server/utils/shifts-schemas.d.ts +318 -0
- package/dist/runtime/server/utils/shifts-schemas.js +177 -0
- package/dist/runtime/server/utils/shifts-station-key.d.ts +7 -0
- package/dist/runtime/server/utils/shifts-station-key.js +22 -0
- package/dist/runtime/server/utils/shifts-stations.d.ts +28 -0
- package/dist/runtime/server/utils/shifts-stations.js +109 -0
- package/dist/runtime/server/utils/shifts-swaps.d.ts +114 -0
- package/dist/runtime/server/utils/shifts-swaps.js +559 -0
- package/dist/runtime/server/utils/shifts-views.d.ts +62 -0
- package/dist/runtime/server/utils/shifts-views.js +212 -0
- package/dist/runtime/utils/api.d.ts +108 -0
- package/dist/runtime/utils/api.js +111 -0
- package/dist/runtime/utils/checkin.d.ts +59 -0
- package/dist/runtime/utils/checkin.js +57 -0
- package/dist/runtime/utils/guards.d.ts +21 -0
- package/dist/runtime/utils/guards.js +36 -0
- package/dist/runtime/utils/ics.d.ts +32 -0
- package/dist/runtime/utils/ics.js +56 -0
- package/dist/runtime/utils/index.d.ts +16 -0
- package/dist/runtime/utils/index.js +15 -0
- package/dist/runtime/utils/links.d.ts +30 -0
- package/dist/runtime/utils/links.js +18 -0
- package/dist/runtime/utils/reminders.d.ts +27 -0
- package/dist/runtime/utils/reminders.js +28 -0
- package/dist/runtime/utils/settings.d.ts +28 -0
- package/dist/runtime/utils/settings.js +18 -0
- package/dist/runtime/utils/station-key.d.ts +9 -0
- package/dist/runtime/utils/station-key.js +12 -0
- package/dist/runtime/utils/status.d.ts +23 -0
- package/dist/runtime/utils/status.js +46 -0
- package/dist/runtime/utils/time.d.ts +22 -0
- package/dist/runtime/utils/time.js +14 -0
- package/dist/types.d.mts +5 -0
- package/package.json +131 -3
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The body of `POST /api/admin/shifts/schedules`. `coverage: 'all'` with a `handover` other than `trade` is refused
|
|
4
|
+
* with 400 `invalid_schedule_settings` (checked by `shiftsCreateSchedule`, so the code is stable).
|
|
5
|
+
*/
|
|
6
|
+
export declare const shiftsScheduleInput: z.ZodObject<{
|
|
7
|
+
operationId: z.ZodString;
|
|
8
|
+
name: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
9
|
+
[k: string]: string;
|
|
10
|
+
}, Record<string, string>>>]>;
|
|
11
|
+
coverage: z.ZodDefault<z.ZodEnum<{
|
|
12
|
+
all: "all";
|
|
13
|
+
flexible: "flexible";
|
|
14
|
+
}>>;
|
|
15
|
+
handover: z.ZodDefault<z.ZodEnum<{
|
|
16
|
+
trade: "trade";
|
|
17
|
+
release: "release";
|
|
18
|
+
both: "both";
|
|
19
|
+
}>>;
|
|
20
|
+
approval: z.ZodDefault<z.ZodEnum<{
|
|
21
|
+
lead: "lead";
|
|
22
|
+
peer: "peer";
|
|
23
|
+
}>>;
|
|
24
|
+
minPerShift: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
25
|
+
maxPerShift: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
26
|
+
guards: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
27
|
+
maxShiftsPerDay: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
|
+
minRestHours: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
29
|
+
}, z.core.$strict>>>;
|
|
30
|
+
checkIn: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
31
|
+
modes: z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
32
|
+
lead: "lead";
|
|
33
|
+
location: "location";
|
|
34
|
+
station: "station";
|
|
35
|
+
daily: "daily";
|
|
36
|
+
}>>, z.ZodTransform<("lead" | "location" | "station" | "daily")[], ("lead" | "location" | "station" | "daily")[]>>;
|
|
37
|
+
location: z.ZodOptional<z.ZodNullable<z.ZodType<import("@frigear-nu/maps/utils").MapLocation, unknown, z.core.$ZodTypeInternals<import("@frigear-nu/maps/utils").MapLocation, unknown>>>>;
|
|
38
|
+
teams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
39
|
+
modes: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
40
|
+
lead: "lead";
|
|
41
|
+
location: "location";
|
|
42
|
+
station: "station";
|
|
43
|
+
daily: "daily";
|
|
44
|
+
}>>, z.ZodTransform<("lead" | "location" | "station" | "daily")[], ("lead" | "location" | "station" | "daily")[]>>>;
|
|
45
|
+
location: z.ZodOptional<z.ZodNullable<z.ZodType<import("@frigear-nu/maps/utils").MapLocation, unknown, z.core.$ZodTypeInternals<import("@frigear-nu/maps/utils").MapLocation, unknown>>>>;
|
|
46
|
+
}, z.core.$strict>>>;
|
|
47
|
+
}, z.core.$strict>>>;
|
|
48
|
+
autoNoShow: z.ZodDefault<z.ZodBoolean>;
|
|
49
|
+
autoNoShowMinutes: z.ZodDefault<z.ZodNumber>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/** The body of `PATCH /api/admin/shifts/schedules/:scheduleId`. The settings are checked merged with the stored ones. */
|
|
52
|
+
export declare const shiftsSchedulePatch: z.ZodObject<{
|
|
53
|
+
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
54
|
+
[k: string]: string;
|
|
55
|
+
}, Record<string, string>>>]>>;
|
|
56
|
+
coverage: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
all: "all";
|
|
58
|
+
flexible: "flexible";
|
|
59
|
+
}>>;
|
|
60
|
+
handover: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
trade: "trade";
|
|
62
|
+
release: "release";
|
|
63
|
+
both: "both";
|
|
64
|
+
}>>;
|
|
65
|
+
approval: z.ZodOptional<z.ZodEnum<{
|
|
66
|
+
lead: "lead";
|
|
67
|
+
peer: "peer";
|
|
68
|
+
}>>;
|
|
69
|
+
minPerShift: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
70
|
+
maxPerShift: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
71
|
+
guards: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
72
|
+
maxShiftsPerDay: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
73
|
+
minRestHours: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
74
|
+
}, z.core.$strict>>>;
|
|
75
|
+
checkIn: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
76
|
+
modes: z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
77
|
+
lead: "lead";
|
|
78
|
+
location: "location";
|
|
79
|
+
station: "station";
|
|
80
|
+
daily: "daily";
|
|
81
|
+
}>>, z.ZodTransform<("lead" | "location" | "station" | "daily")[], ("lead" | "location" | "station" | "daily")[]>>;
|
|
82
|
+
location: z.ZodOptional<z.ZodNullable<z.ZodType<import("@frigear-nu/maps/utils").MapLocation, unknown, z.core.$ZodTypeInternals<import("@frigear-nu/maps/utils").MapLocation, unknown>>>>;
|
|
83
|
+
teams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
84
|
+
modes: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
85
|
+
lead: "lead";
|
|
86
|
+
location: "location";
|
|
87
|
+
station: "station";
|
|
88
|
+
daily: "daily";
|
|
89
|
+
}>>, z.ZodTransform<("lead" | "location" | "station" | "daily")[], ("lead" | "location" | "station" | "daily")[]>>>;
|
|
90
|
+
location: z.ZodOptional<z.ZodNullable<z.ZodType<import("@frigear-nu/maps/utils").MapLocation, unknown, z.core.$ZodTypeInternals<import("@frigear-nu/maps/utils").MapLocation, unknown>>>>;
|
|
91
|
+
}, z.core.$strict>>>;
|
|
92
|
+
}, z.core.$strict>>>;
|
|
93
|
+
autoNoShow: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
autoNoShowMinutes: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
/** The query of `GET /api/admin/shifts/schedules`. */
|
|
97
|
+
export declare const shiftsScheduleQuery: z.ZodObject<{
|
|
98
|
+
operationId: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
/** The body of `POST /api/admin/shifts/schedules/:scheduleId/copy-from`. */
|
|
101
|
+
export declare const shiftsCopyInput: z.ZodObject<{
|
|
102
|
+
scheduleId: z.ZodString;
|
|
103
|
+
offsetDays: z.ZodDefault<z.ZodNumber>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
/** The body of `POST /api/admin/shifts/schedules/:scheduleId/roles`. */
|
|
106
|
+
export declare const shiftsRoleInput: z.ZodObject<{
|
|
107
|
+
teamId: z.ZodString;
|
|
108
|
+
teamRole: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
109
|
+
name: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
110
|
+
[k: string]: string;
|
|
111
|
+
}, Record<string, string>>>]>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
/** The body of `PATCH /api/admin/shifts/roles/:roleId`. */
|
|
114
|
+
export declare const shiftsRolePatch: z.ZodObject<{
|
|
115
|
+
teamRole: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
117
|
+
[k: string]: string;
|
|
118
|
+
}, Record<string, string>>>]>>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
/** The body of `POST /api/admin/shifts/schedules/:scheduleId/shifts/bulk`: every slot on every day, in the module's time zone. */
|
|
121
|
+
export declare const shiftsBulkInput: z.ZodObject<{
|
|
122
|
+
teamId: z.ZodString;
|
|
123
|
+
days: z.ZodArray<z.ZodString>;
|
|
124
|
+
slots: z.ZodArray<z.ZodObject<{
|
|
125
|
+
start: z.ZodString;
|
|
126
|
+
end: z.ZodString;
|
|
127
|
+
}, z.core.$strip>>;
|
|
128
|
+
capacity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
129
|
+
shiftRoleId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
location: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
131
|
+
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
132
|
+
[k: string]: string;
|
|
133
|
+
}, Record<string, string>>>]>>;
|
|
134
|
+
featureId: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, z.core.$strict>>>;
|
|
136
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
137
|
+
[k: string]: string;
|
|
138
|
+
}, Record<string, string>>>]>>>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
/** The body of `PATCH /api/admin/shifts/:shiftId`. */
|
|
141
|
+
export declare const shiftsShiftPatch: z.ZodObject<{
|
|
142
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
143
|
+
shiftRoleId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
144
|
+
startsAt: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
145
|
+
endsAt: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
146
|
+
capacity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
147
|
+
location: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
148
|
+
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
149
|
+
[k: string]: string;
|
|
150
|
+
}, Record<string, string>>>]>>;
|
|
151
|
+
featureId: z.ZodOptional<z.ZodString>;
|
|
152
|
+
}, z.core.$strict>>>;
|
|
153
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
154
|
+
[k: string]: string;
|
|
155
|
+
}, Record<string, string>>>]>>>;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
/** The query of the shift lists (`?teamId&from&to`). */
|
|
158
|
+
export declare const shiftsRangeQuery: z.ZodObject<{
|
|
159
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
160
|
+
from: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
161
|
+
to: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
/** The body of `POST /api/admin/shifts/:shiftId/assignments`. */
|
|
164
|
+
export declare const shiftsAssignInput: z.ZodObject<{
|
|
165
|
+
userId: z.ZodNumber;
|
|
166
|
+
shiftRoleId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
167
|
+
force: z.ZodDefault<z.ZodBoolean>;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
/** The query of `GET /api/admin/shifts/:shiftId/candidates`. */
|
|
170
|
+
export declare const shiftsCandidatesQuery: z.ZodObject<{
|
|
171
|
+
q: z.ZodOptional<z.ZodString>;
|
|
172
|
+
shiftRoleId: z.ZodOptional<z.ZodString>;
|
|
173
|
+
}, z.core.$strip>;
|
|
174
|
+
/** The body of `POST /api/shifts/teams/:teamId/check-in`. */
|
|
175
|
+
export declare const shiftsCheckInInput: z.ZodObject<{
|
|
176
|
+
code: z.ZodString;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
/**
|
|
179
|
+
* The body of `POST /api/shifts/me/:assignmentId/swap`: the kind (the schedule's only allowed kind, else `release`, when
|
|
180
|
+
* left out) and, for a trade, the one assignment wanted in return.
|
|
181
|
+
*/
|
|
182
|
+
export declare const shiftsOpenSwapInput: z.ZodPrefault<z.ZodObject<{
|
|
183
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
184
|
+
trade: "trade";
|
|
185
|
+
release: "release";
|
|
186
|
+
}>>;
|
|
187
|
+
wantedAssignmentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
188
|
+
}, z.core.$strip>>;
|
|
189
|
+
/** The body of `POST /api/shifts/swaps/:swapId/offers`: one of my own assignments in return (a trade), or none (a release). */
|
|
190
|
+
export declare const shiftsOfferInput: z.ZodPrefault<z.ZodObject<{
|
|
191
|
+
assignmentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
/** The router params of `/api/shifts/swaps/:swapId/offers/:offerId`. */
|
|
194
|
+
export declare const shiftsOfferParams: z.ZodObject<{
|
|
195
|
+
swapId: z.ZodString;
|
|
196
|
+
offerId: z.ZodString;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
/** The query of `GET /api/admin/shifts/swaps`. */
|
|
199
|
+
export declare const shiftsSwapsQuery: z.ZodObject<{
|
|
200
|
+
operationId: z.ZodOptional<z.ZodString>;
|
|
201
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
202
|
+
open: "open";
|
|
203
|
+
completed: "completed";
|
|
204
|
+
cancelled: "cancelled";
|
|
205
|
+
offered: "offered";
|
|
206
|
+
accepted: "accepted";
|
|
207
|
+
pending_approval: "pending_approval";
|
|
208
|
+
rejected: "rejected";
|
|
209
|
+
}>>;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
/** The body of `POST /api/admin/shifts/broadcasts`. */
|
|
212
|
+
export declare const shiftsBroadcastInput: z.ZodObject<{
|
|
213
|
+
audience: z.ZodPrefault<z.ZodObject<{
|
|
214
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
215
|
+
teamRole: z.ZodOptional<z.ZodString>;
|
|
216
|
+
shiftId: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, z.core.$strict>>;
|
|
218
|
+
channels: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
219
|
+
email: "email";
|
|
220
|
+
sms: "sms";
|
|
221
|
+
}>>>, z.ZodTransform<("email" | "sms")[], ("email" | "sms")[]>>;
|
|
222
|
+
subject: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
223
|
+
[k: string]: string;
|
|
224
|
+
}, Record<string, string>>>]>;
|
|
225
|
+
message: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
226
|
+
[k: string]: string;
|
|
227
|
+
}, Record<string, string>>>]>;
|
|
228
|
+
operationId: z.ZodString;
|
|
229
|
+
}, z.core.$strip>;
|
|
230
|
+
/** The body of `POST /api/shifts/teams/:teamId/broadcasts`: the operation is the team's. */
|
|
231
|
+
export declare const shiftsLeadBroadcastInput: z.ZodObject<{
|
|
232
|
+
audience: z.ZodPrefault<z.ZodObject<{
|
|
233
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
234
|
+
teamRole: z.ZodOptional<z.ZodString>;
|
|
235
|
+
shiftId: z.ZodOptional<z.ZodString>;
|
|
236
|
+
}, z.core.$strict>>;
|
|
237
|
+
channels: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
238
|
+
email: "email";
|
|
239
|
+
sms: "sms";
|
|
240
|
+
}>>>, z.ZodTransform<("email" | "sms")[], ("email" | "sms")[]>>;
|
|
241
|
+
subject: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
242
|
+
[k: string]: string;
|
|
243
|
+
}, Record<string, string>>>]>;
|
|
244
|
+
message: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
245
|
+
[k: string]: string;
|
|
246
|
+
}, Record<string, string>>>]>;
|
|
247
|
+
}, z.core.$strip>;
|
|
248
|
+
/** The query of `GET /api/admin/shifts/broadcasts`. */
|
|
249
|
+
export declare const shiftsBroadcastsQuery: z.ZodObject<{
|
|
250
|
+
operationId: z.ZodString;
|
|
251
|
+
}, z.core.$strip>;
|
|
252
|
+
/** The body of `POST /api/admin/shifts/operations/:operationId/perks`. */
|
|
253
|
+
export declare const shiftsPerkInput: z.ZodObject<{
|
|
254
|
+
teamId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
255
|
+
name: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
256
|
+
[k: string]: string;
|
|
257
|
+
}, Record<string, string>>>]>;
|
|
258
|
+
voucherType: z.ZodString;
|
|
259
|
+
quantity: z.ZodDefault<z.ZodNumber>;
|
|
260
|
+
}, z.core.$strip>;
|
|
261
|
+
/** The body of `PATCH /api/admin/shifts/perks/:perkId`. Changes apply to perks earned from now on. */
|
|
262
|
+
export declare const shiftsPerkPatch: z.ZodObject<{
|
|
263
|
+
teamId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
264
|
+
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
265
|
+
[k: string]: string;
|
|
266
|
+
}, Record<string, string>>>]>>;
|
|
267
|
+
voucherType: z.ZodOptional<z.ZodString>;
|
|
268
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
/** The query of `GET /api/shifts/me/earned-perks`. */
|
|
271
|
+
export declare const shiftsEarnedPerksQuery: z.ZodObject<{
|
|
272
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
273
|
+
all: "all";
|
|
274
|
+
claimed: "claimed";
|
|
275
|
+
unclaimed: "unclaimed";
|
|
276
|
+
}>>;
|
|
277
|
+
}, z.core.$strip>;
|
|
278
|
+
/** The optional body of `POST /api/shifts/me/earned-perks/:id/claim`. */
|
|
279
|
+
export declare const shiftsPerkClaimInput: z.ZodPrefault<z.ZodObject<{
|
|
280
|
+
client: z.ZodOptional<z.ZodString>;
|
|
281
|
+
}, z.core.$strip>>;
|
|
282
|
+
/** The body of `POST /api/admin/shifts/schedules/:scheduleId/stations`. */
|
|
283
|
+
export declare const shiftsStationInput: z.ZodObject<{
|
|
284
|
+
teamId: z.ZodString;
|
|
285
|
+
name: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
286
|
+
[k: string]: string;
|
|
287
|
+
}, Record<string, string>>>]>;
|
|
288
|
+
featureId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
289
|
+
}, z.core.$strip>;
|
|
290
|
+
/** The body of `PATCH /api/admin/shifts/stations/:stationId`. */
|
|
291
|
+
export declare const shiftsStationPatch: z.ZodObject<{
|
|
292
|
+
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodString>, z.ZodTransform<{
|
|
293
|
+
[k: string]: string;
|
|
294
|
+
}, Record<string, string>>>]>>;
|
|
295
|
+
featureId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
296
|
+
}, z.core.$strip>;
|
|
297
|
+
/** The body of `POST /api/shifts/me/:assignmentId/check-in`: a station's QR token, or the device's position. */
|
|
298
|
+
export declare const shiftsSelfCheckInInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
299
|
+
mode: z.ZodLiteral<"station">;
|
|
300
|
+
token: z.ZodString;
|
|
301
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
302
|
+
mode: z.ZodLiteral<"location">;
|
|
303
|
+
latitude: z.ZodNumber;
|
|
304
|
+
longitude: z.ZodNumber;
|
|
305
|
+
accuracy: z.ZodNumber;
|
|
306
|
+
}, z.core.$strip>], "mode">;
|
|
307
|
+
/** The query of `GET /api/shifts/teams/:teamId/swaps`. */
|
|
308
|
+
export declare const shiftsTeamSwapsQuery: z.ZodObject<{
|
|
309
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
310
|
+
open: "open";
|
|
311
|
+
completed: "completed";
|
|
312
|
+
cancelled: "cancelled";
|
|
313
|
+
offered: "offered";
|
|
314
|
+
accepted: "accepted";
|
|
315
|
+
pending_approval: "pending_approval";
|
|
316
|
+
rejected: "rejected";
|
|
317
|
+
}>>;
|
|
318
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { mapLocationSchema } from "@frigear-nu/maps/schemas";
|
|
3
|
+
import { SHIFT_CHECK_IN_MODES } from "../../utils/checkin.js";
|
|
4
|
+
import { SHIFT_APPROVALS, SHIFT_COVERAGES, SHIFT_HANDOVERS, SHIFT_SWAP_KINDS } from "../../utils/settings.js";
|
|
5
|
+
import { SHIFT_SWAP_STATUSES } from "../../utils/status.js";
|
|
6
|
+
import { isClock, isDay } from "@frigear-nu/module-kit/time";
|
|
7
|
+
const key = z.string().trim().min(1).max(64);
|
|
8
|
+
const shiftsTranslated = z.union([
|
|
9
|
+
z.string().trim().min(1).max(500),
|
|
10
|
+
z.record(z.string(), z.string().max(500)).transform((value) => Object.fromEntries(Object.entries(value).filter(([, text]) => text.trim()))).refine((value) => Object.keys(value).length > 0, "Add a text in at least one language.")
|
|
11
|
+
]);
|
|
12
|
+
const longTranslated = z.union([
|
|
13
|
+
z.string().trim().max(4e3),
|
|
14
|
+
z.record(z.string(), z.string().max(4e3)).transform((value) => Object.fromEntries(Object.entries(value).filter(([, text]) => text.trim())))
|
|
15
|
+
]);
|
|
16
|
+
const date = z.iso.datetime({ offset: true }).transform((value) => new Date(value));
|
|
17
|
+
const count = z.number().int().min(0).max(1e4);
|
|
18
|
+
const guards = z.strictObject({
|
|
19
|
+
maxShiftsPerDay: z.number().int().min(1).max(24).nullish(),
|
|
20
|
+
minRestHours: z.number().min(0).max(72).nullish()
|
|
21
|
+
});
|
|
22
|
+
const checkInModes = z.array(z.enum(SHIFT_CHECK_IN_MODES)).max(SHIFT_CHECK_IN_MODES.length).transform((value) => [...new Set(value)]);
|
|
23
|
+
const checkIn = z.strictObject({
|
|
24
|
+
modes: checkInModes,
|
|
25
|
+
location: mapLocationSchema.nullish(),
|
|
26
|
+
teams: z.record(key, z.strictObject({ modes: checkInModes.optional(), location: mapLocationSchema.nullish() })).refine((value) => Object.keys(value).length <= 200, "At most 200 team overrides.").optional()
|
|
27
|
+
});
|
|
28
|
+
const autoNoShowMinutes = z.number().int().min(0).max(24 * 60);
|
|
29
|
+
const location = z.strictObject({
|
|
30
|
+
name: shiftsTranslated.optional(),
|
|
31
|
+
featureId: key.optional()
|
|
32
|
+
});
|
|
33
|
+
export const shiftsScheduleInput = z.object({
|
|
34
|
+
operationId: key,
|
|
35
|
+
name: shiftsTranslated,
|
|
36
|
+
coverage: z.enum(SHIFT_COVERAGES).default("flexible"),
|
|
37
|
+
handover: z.enum(SHIFT_HANDOVERS).default("both"),
|
|
38
|
+
approval: z.enum(SHIFT_APPROVALS).default("peer"),
|
|
39
|
+
minPerShift: count.nullish(),
|
|
40
|
+
maxPerShift: count.nullish(),
|
|
41
|
+
guards: guards.nullish(),
|
|
42
|
+
checkIn: checkIn.nullish(),
|
|
43
|
+
autoNoShow: z.boolean().default(false),
|
|
44
|
+
autoNoShowMinutes: autoNoShowMinutes.default(30)
|
|
45
|
+
}).refine((value) => value.minPerShift == null || value.maxPerShift == null || value.maxPerShift >= value.minPerShift, {
|
|
46
|
+
message: "The maximum must be at least the minimum.",
|
|
47
|
+
path: ["maxPerShift"]
|
|
48
|
+
});
|
|
49
|
+
export const shiftsSchedulePatch = z.object({
|
|
50
|
+
name: shiftsTranslated.optional(),
|
|
51
|
+
coverage: z.enum(SHIFT_COVERAGES).optional(),
|
|
52
|
+
handover: z.enum(SHIFT_HANDOVERS).optional(),
|
|
53
|
+
approval: z.enum(SHIFT_APPROVALS).optional(),
|
|
54
|
+
minPerShift: count.nullish(),
|
|
55
|
+
maxPerShift: count.nullish(),
|
|
56
|
+
guards: guards.nullish(),
|
|
57
|
+
checkIn: checkIn.nullish(),
|
|
58
|
+
autoNoShow: z.boolean().optional(),
|
|
59
|
+
autoNoShowMinutes: autoNoShowMinutes.optional()
|
|
60
|
+
});
|
|
61
|
+
export const shiftsScheduleQuery = z.object({ operationId: key.optional() });
|
|
62
|
+
export const shiftsCopyInput = z.object({
|
|
63
|
+
scheduleId: key,
|
|
64
|
+
/** Whole days the copied shifts move by, at the same wall-clock time (365 for a year on). */
|
|
65
|
+
offsetDays: z.number().int().min(-3660).max(3660).default(0)
|
|
66
|
+
});
|
|
67
|
+
export const shiftsRoleInput = z.object({
|
|
68
|
+
teamId: key,
|
|
69
|
+
teamRole: key.nullish(),
|
|
70
|
+
name: shiftsTranslated
|
|
71
|
+
});
|
|
72
|
+
export const shiftsRolePatch = z.object({
|
|
73
|
+
teamRole: key.nullish(),
|
|
74
|
+
name: shiftsTranslated.optional()
|
|
75
|
+
});
|
|
76
|
+
const day = z.string().refine(isDay, "Use a YYYY-MM-DD day.");
|
|
77
|
+
const clock = z.string().refine(isClock, "Use an HH:mm time.");
|
|
78
|
+
export const shiftsBulkInput = z.object({
|
|
79
|
+
teamId: key,
|
|
80
|
+
days: z.array(day).min(1).max(62),
|
|
81
|
+
slots: z.array(z.object({ start: clock, end: clock })).min(1).max(24),
|
|
82
|
+
capacity: count.nullish(),
|
|
83
|
+
shiftRoleId: key.nullish(),
|
|
84
|
+
location: location.nullish(),
|
|
85
|
+
notes: longTranslated.nullish()
|
|
86
|
+
}).refine((value) => value.days.length * value.slots.length <= 500, { message: "At most 500 shifts at once.", path: ["days"] });
|
|
87
|
+
export const shiftsShiftPatch = z.object({
|
|
88
|
+
teamId: key.optional(),
|
|
89
|
+
shiftRoleId: key.nullish(),
|
|
90
|
+
startsAt: date.optional(),
|
|
91
|
+
endsAt: date.optional(),
|
|
92
|
+
capacity: count.nullish(),
|
|
93
|
+
location: location.nullish(),
|
|
94
|
+
notes: longTranslated.nullish()
|
|
95
|
+
});
|
|
96
|
+
export const shiftsRangeQuery = z.object({
|
|
97
|
+
teamId: key.optional(),
|
|
98
|
+
from: date.optional(),
|
|
99
|
+
to: date.optional()
|
|
100
|
+
});
|
|
101
|
+
export const shiftsAssignInput = z.object({
|
|
102
|
+
userId: z.number().int().positive(),
|
|
103
|
+
shiftRoleId: key.nullish(),
|
|
104
|
+
/** Assign over the capacity (`shifts:manage` only). */
|
|
105
|
+
force: z.boolean().default(false)
|
|
106
|
+
});
|
|
107
|
+
export const shiftsCandidatesQuery = z.object({
|
|
108
|
+
q: z.string().trim().max(200).optional(),
|
|
109
|
+
// The shift role the person would hold; the shift's own role when left out.
|
|
110
|
+
shiftRoleId: key.optional()
|
|
111
|
+
});
|
|
112
|
+
export const shiftsCheckInInput = z.object({ code: z.string().trim().min(1).max(200) });
|
|
113
|
+
export const shiftsOpenSwapInput = z.object({
|
|
114
|
+
kind: z.enum(SHIFT_SWAP_KINDS).optional(),
|
|
115
|
+
wantedAssignmentId: key.nullish()
|
|
116
|
+
}).prefault({});
|
|
117
|
+
export const shiftsOfferInput = z.object({ assignmentId: key.nullish() }).prefault({});
|
|
118
|
+
export const shiftsOfferParams = z.object({ swapId: z.string().trim().min(1), offerId: z.string().trim().min(1) });
|
|
119
|
+
export const shiftsSwapsQuery = z.object({
|
|
120
|
+
operationId: key.optional(),
|
|
121
|
+
status: z.enum(SHIFT_SWAP_STATUSES).optional()
|
|
122
|
+
});
|
|
123
|
+
const messageText = (max) => z.union([
|
|
124
|
+
z.string().trim().min(1).max(max),
|
|
125
|
+
z.record(z.string(), z.string().max(max)).transform((value) => Object.fromEntries(Object.entries(value).filter(([, text]) => text.trim()))).refine((value) => Object.keys(value).length > 0, "Add a text in at least one language.")
|
|
126
|
+
]);
|
|
127
|
+
const broadcastFields = {
|
|
128
|
+
audience: z.strictObject({
|
|
129
|
+
teamId: key.optional(),
|
|
130
|
+
/** The lowest team role (on each team kind's ladder) that gets it; every member when left out. */
|
|
131
|
+
teamRole: key.optional(),
|
|
132
|
+
shiftId: key.optional()
|
|
133
|
+
}).prefault({}),
|
|
134
|
+
// Email is the default; SMS costs money, so it is only sent when asked for.
|
|
135
|
+
channels: z.array(z.enum(["email", "sms"])).min(1).max(2).default(["email"]).transform((value) => [...new Set(value)]),
|
|
136
|
+
subject: messageText(200),
|
|
137
|
+
message: messageText(1500)
|
|
138
|
+
};
|
|
139
|
+
export const shiftsBroadcastInput = z.object({ operationId: key, ...broadcastFields });
|
|
140
|
+
export const shiftsLeadBroadcastInput = z.object(broadcastFields);
|
|
141
|
+
export const shiftsBroadcastsQuery = z.object({ operationId: key });
|
|
142
|
+
const perkQuantity = z.number().int().min(1).max(1e3);
|
|
143
|
+
const voucherType = z.string().trim().min(1).max(64);
|
|
144
|
+
export const shiftsPerkInput = z.object({
|
|
145
|
+
teamId: key.nullish(),
|
|
146
|
+
name: shiftsTranslated,
|
|
147
|
+
voucherType,
|
|
148
|
+
quantity: perkQuantity.default(1)
|
|
149
|
+
});
|
|
150
|
+
export const shiftsPerkPatch = z.object({
|
|
151
|
+
teamId: key.nullish(),
|
|
152
|
+
name: shiftsTranslated.optional(),
|
|
153
|
+
voucherType: voucherType.optional(),
|
|
154
|
+
quantity: perkQuantity.optional()
|
|
155
|
+
});
|
|
156
|
+
export const shiftsEarnedPerksQuery = z.object({ status: z.enum(["unclaimed", "claimed", "all"]).default("unclaimed") });
|
|
157
|
+
export const shiftsPerkClaimInput = z.object({ client: z.string().trim().min(1).max(100).optional() }).prefault({});
|
|
158
|
+
export const shiftsStationInput = z.object({
|
|
159
|
+
teamId: key,
|
|
160
|
+
name: shiftsTranslated,
|
|
161
|
+
featureId: key.nullish()
|
|
162
|
+
});
|
|
163
|
+
export const shiftsStationPatch = z.object({
|
|
164
|
+
name: shiftsTranslated.optional(),
|
|
165
|
+
featureId: key.nullish()
|
|
166
|
+
});
|
|
167
|
+
export const shiftsSelfCheckInInput = z.discriminatedUnion("mode", [
|
|
168
|
+
z.object({ mode: z.literal("station"), token: z.string().trim().min(1).max(300) }),
|
|
169
|
+
z.object({
|
|
170
|
+
mode: z.literal("location"),
|
|
171
|
+
latitude: z.number().min(-90).max(90),
|
|
172
|
+
longitude: z.number().min(-180).max(180),
|
|
173
|
+
/** The accuracy the device reports, in metres. */
|
|
174
|
+
accuracy: z.number().min(0).max(1e5)
|
|
175
|
+
})
|
|
176
|
+
]);
|
|
177
|
+
export const shiftsTeamSwapsQuery = z.object({ status: z.enum(SHIFT_SWAP_STATUSES).optional() });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
/** `shifts.stationKey` (`NUXT_SHIFTS_STATION_KEY`), trimmed; empty when unset or too short. Station check-in has no other secret. */
|
|
3
|
+
export declare function shiftsStationSecret(event?: H3Event): string;
|
|
4
|
+
/** Whether `shifts.stationKey` (`NUXT_SHIFTS_STATION_KEY`) is set (and long enough), so station check-in and station screens work. */
|
|
5
|
+
export declare function shiftsStationKeyConfigured(event?: H3Event): boolean;
|
|
6
|
+
/** 501 `not_configured` unless `shifts.stationKey` (`NUXT_SHIFTS_STATION_KEY`) is set and at least 32 characters. */
|
|
7
|
+
export declare function shiftsRequireStationKey(event?: H3Event): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { notConfigured } from "@frigear-nu/module-kit/server";
|
|
2
|
+
import { shiftsStationKeyIssue } from "../../utils/station-key.js";
|
|
3
|
+
let reported;
|
|
4
|
+
export function shiftsStationSecret(event) {
|
|
5
|
+
const config = useRuntimeConfig(event);
|
|
6
|
+
const secret = config.shifts?.stationKey;
|
|
7
|
+
const issue = shiftsStationKeyIssue(secret);
|
|
8
|
+
if (issue) {
|
|
9
|
+
if (reported !== issue) console.error(issue);
|
|
10
|
+
reported = issue;
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
return typeof secret === "string" ? secret.trim() : "";
|
|
14
|
+
}
|
|
15
|
+
export function shiftsStationKeyConfigured(event) {
|
|
16
|
+
return shiftsStationSecret(event) !== "";
|
|
17
|
+
}
|
|
18
|
+
export function shiftsRequireStationKey(event) {
|
|
19
|
+
if (!shiftsStationKeyConfigured(event)) {
|
|
20
|
+
throw notConfigured("Station check-in is not set up: the server has no station key of at least 32 characters (NUXT_SHIFTS_STATION_KEY).");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { ShiftStationTokenDto, Translated } from '../../../types.js';
|
|
4
|
+
import type { ShiftScheduleRow, ShiftStationRow } from './shifts-dto.js';
|
|
5
|
+
import type { shiftsStationInput, shiftsStationPatch } from './shifts-schemas.js';
|
|
6
|
+
type StationInput = z.output<typeof shiftsStationInput>;
|
|
7
|
+
type StationPatch = z.output<typeof shiftsStationPatch>;
|
|
8
|
+
/** The token of a station for a window (the current one by default). */
|
|
9
|
+
export declare function shiftsStationToken(event: H3Event | undefined, stationId: string, window?: number): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Checks a scanned station token: 501 `not_configured` without a station key, 400 `invalid_token` when it is not one
|
|
12
|
+
* or its signature does not verify (forged or altered), 409 `token_expired` when it is from a window before the
|
|
13
|
+
* previous one (or from the future). Returns the station id; the caller loads the station.
|
|
14
|
+
*/
|
|
15
|
+
export declare function shiftsVerifyStationToken(event: H3Event | undefined, token: string, now?: number): Promise<string>;
|
|
16
|
+
export declare function findShiftStation(id: string): Promise<ShiftStationRow | undefined>;
|
|
17
|
+
export declare function getShiftStationOr404(id: string): Promise<ShiftStationRow>;
|
|
18
|
+
/** A schedule's stations, oldest first. */
|
|
19
|
+
export declare function shiftsListStations(scheduleId: string): Promise<any>;
|
|
20
|
+
/** Adds a station for a team of the schedule's operation, optionally on a station feature of the venue layout. */
|
|
21
|
+
export declare function shiftsCreateStation(schedule: ShiftScheduleRow, input: StationInput): Promise<ShiftStationRow>;
|
|
22
|
+
export declare function shiftsPatchStation(station: ShiftStationRow, schedule: ShiftScheduleRow, patch: StationPatch): Promise<ShiftStationRow>;
|
|
23
|
+
export declare function shiftsDeleteStation(station: ShiftStationRow): Promise<void>;
|
|
24
|
+
/** The stations of a team on published schedules, for its leads' page. */
|
|
25
|
+
export declare function shiftsTeamStations(teamId: string): Promise<any>;
|
|
26
|
+
/** The current token of a station with its QR code, for the display page (501 `not_configured` without a station key). */
|
|
27
|
+
export declare function shiftsStationTokenDto(event: H3Event, station: ShiftStationRow, teamName: Translated): Promise<ShiftStationTokenDto>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { db, schema } from "@nuxthub/db";
|
|
2
|
+
import { and, asc, eq } from "drizzle-orm";
|
|
3
|
+
import { renderSVG } from "uqr";
|
|
4
|
+
import { apiError, base64UrlToBytes, bytesToBase64Url, deriveHkdfKey, notFound, validationError } from "@frigear-nu/module-kit/server";
|
|
5
|
+
import { OPERATIONS_STATION_KIND } from "@frigear-nu/operations/utils";
|
|
6
|
+
import { newId } from "../../utils/index.js";
|
|
7
|
+
import { STATION_ROTATE_SECONDS, parseStationToken, stationTokenPayload, stationWindow, stationWindowAccepted } from "../../utils/checkin.js";
|
|
8
|
+
import { toShiftStationDto } from "./shifts-dto.js";
|
|
9
|
+
import { shiftsOperationTeamOr400 } from "./shifts-core.js";
|
|
10
|
+
import { shiftsRequireStationKey, shiftsStationSecret } from "./shifts-station-key.js";
|
|
11
|
+
const encoder = new TextEncoder();
|
|
12
|
+
const stationKeys = /* @__PURE__ */ new Map();
|
|
13
|
+
function shiftsStationKey(event) {
|
|
14
|
+
shiftsRequireStationKey(event);
|
|
15
|
+
const secret = shiftsStationSecret(event);
|
|
16
|
+
let key = stationKeys.get(secret);
|
|
17
|
+
if (!key) {
|
|
18
|
+
key = deriveHkdfKey(secret, { salt: "@frigear-nu/shifts", info: "shift_station_tokens" }, { name: "HMAC", hash: "SHA-256", length: 256 }, ["sign", "verify"]);
|
|
19
|
+
stationKeys.set(secret, key);
|
|
20
|
+
}
|
|
21
|
+
return key;
|
|
22
|
+
}
|
|
23
|
+
function fromBase64Url(value) {
|
|
24
|
+
try {
|
|
25
|
+
return base64UrlToBytes(value);
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function shiftsStationToken(event, stationId, window = stationWindow(Date.now())) {
|
|
31
|
+
const signature = await crypto.subtle.sign("HMAC", await shiftsStationKey(event), encoder.encode(stationTokenPayload(stationId, window)));
|
|
32
|
+
return `${stationId}.${window}.${bytesToBase64Url(signature)}`;
|
|
33
|
+
}
|
|
34
|
+
export async function shiftsVerifyStationToken(event, token, now = Date.now()) {
|
|
35
|
+
shiftsRequireStationKey(event);
|
|
36
|
+
const parsed = parseStationToken(token);
|
|
37
|
+
const signature = parsed ? fromBase64Url(parsed.signature) : null;
|
|
38
|
+
const invalid = () => apiError(400, "invalid_token", "This is not a check-in code of a station.");
|
|
39
|
+
if (!parsed || !signature) throw invalid();
|
|
40
|
+
const valid = await crypto.subtle.verify("HMAC", await shiftsStationKey(event), signature, encoder.encode(stationTokenPayload(parsed.stationId, parsed.window)));
|
|
41
|
+
if (!valid) throw invalid();
|
|
42
|
+
if (!stationWindowAccepted(parsed.window, now)) throw apiError(409, "token_expired", "This code has expired. Scan the station again.");
|
|
43
|
+
return parsed.stationId;
|
|
44
|
+
}
|
|
45
|
+
export async function findShiftStation(id) {
|
|
46
|
+
const [row] = await db.select().from(schema.shiftStations).where(eq(schema.shiftStations.id, id)).limit(1);
|
|
47
|
+
return row;
|
|
48
|
+
}
|
|
49
|
+
export async function getShiftStationOr404(id) {
|
|
50
|
+
const row = await findShiftStation(id);
|
|
51
|
+
if (!row) throw notFound("Station not found.");
|
|
52
|
+
return row;
|
|
53
|
+
}
|
|
54
|
+
export async function shiftsListStations(scheduleId) {
|
|
55
|
+
const rows = await db.select().from(schema.shiftStations).where(eq(schema.shiftStations.scheduleId, scheduleId)).orderBy(asc(schema.shiftStations.createdAt), asc(schema.shiftStations.id)).limit(500);
|
|
56
|
+
return rows.map(toShiftStationDto);
|
|
57
|
+
}
|
|
58
|
+
function stationFeatureIds(layout) {
|
|
59
|
+
const features = layout?.features ?? [];
|
|
60
|
+
return new Set(features.filter((feature) => feature.kind === OPERATIONS_STATION_KIND && typeof feature.id === "string").map((feature) => feature.id));
|
|
61
|
+
}
|
|
62
|
+
async function assertStationFeature(operationId, featureId) {
|
|
63
|
+
const [operation] = await db.select({ venueLayout: schema.operations.venueLayout }).from(schema.operations).where(eq(schema.operations.id, operationId)).limit(1);
|
|
64
|
+
if (!stationFeatureIds(operation?.venueLayout).has(featureId)) {
|
|
65
|
+
throw validationError([{ path: ["featureId"], message: "Pick a station of the operation's venue layout." }], "Unknown station feature");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export async function shiftsCreateStation(schedule, input) {
|
|
69
|
+
await shiftsOperationTeamOr400(schedule.operationId, input.teamId);
|
|
70
|
+
if (input.featureId) await assertStationFeature(schedule.operationId, input.featureId);
|
|
71
|
+
const [row] = await db.insert(schema.shiftStations).values({
|
|
72
|
+
id: newId("sst"),
|
|
73
|
+
scheduleId: schedule.id,
|
|
74
|
+
teamId: input.teamId,
|
|
75
|
+
name: input.name,
|
|
76
|
+
featureId: input.featureId ?? null
|
|
77
|
+
}).returning();
|
|
78
|
+
return row;
|
|
79
|
+
}
|
|
80
|
+
export async function shiftsPatchStation(station, schedule, patch) {
|
|
81
|
+
const values = {};
|
|
82
|
+
if (patch.name !== void 0) values.name = patch.name;
|
|
83
|
+
if (patch.featureId !== void 0) {
|
|
84
|
+
if (patch.featureId) await assertStationFeature(schedule.operationId, patch.featureId);
|
|
85
|
+
values.featureId = patch.featureId ?? null;
|
|
86
|
+
}
|
|
87
|
+
if (!Object.keys(values).length) return station;
|
|
88
|
+
const [row] = await db.update(schema.shiftStations).set(values).where(eq(schema.shiftStations.id, station.id)).returning();
|
|
89
|
+
return row;
|
|
90
|
+
}
|
|
91
|
+
export async function shiftsDeleteStation(station) {
|
|
92
|
+
await db.delete(schema.shiftStations).where(eq(schema.shiftStations.id, station.id));
|
|
93
|
+
}
|
|
94
|
+
export async function shiftsTeamStations(teamId) {
|
|
95
|
+
const rows = await db.select({ station: schema.shiftStations }).from(schema.shiftStations).innerJoin(schema.shiftSchedules, eq(schema.shiftSchedules.id, schema.shiftStations.scheduleId)).where(and(eq(schema.shiftStations.teamId, teamId), eq(schema.shiftSchedules.status, "published"))).orderBy(asc(schema.shiftStations.createdAt), asc(schema.shiftStations.id)).limit(200);
|
|
96
|
+
return rows.map((row) => toShiftStationDto(row.station));
|
|
97
|
+
}
|
|
98
|
+
export async function shiftsStationTokenDto(event, station, teamName) {
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
const window = stationWindow(now);
|
|
101
|
+
const token = await shiftsStationToken(event, station.id, window);
|
|
102
|
+
return {
|
|
103
|
+
station: { ...toShiftStationDto(station), teamName },
|
|
104
|
+
token,
|
|
105
|
+
svg: renderSVG(token, { border: 1 }),
|
|
106
|
+
refreshAt: new Date((window + 1) * STATION_ROTATE_SECONDS * 1e3).toISOString(),
|
|
107
|
+
rotateSeconds: STATION_ROTATE_SECONDS
|
|
108
|
+
};
|
|
109
|
+
}
|