@burdenoff/microfe-calendar 2026.1123.3 → 2026.1124.2

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 (251) hide show
  1. package/dist/components/AgendaView.js.map +1 -1
  2. package/dist/generated/wspace-operations.d.ts +785 -0
  3. package/dist/generated/wspace-operations.js +250 -84
  4. package/dist/generated/wspace-operations.js.map +1 -1
  5. package/dist/generated/wspace-types.d.ts +1243 -10
  6. package/dist/hooks/useSafePermissions.js.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/providers/CalendarProvider.d.ts +3 -1
  9. package/dist/providers/CalendarProvider.js +12 -10
  10. package/dist/providers/CalendarProvider.js.map +1 -1
  11. package/dist/translations/en.d.ts +351 -0
  12. package/dist/types/index.d.ts +9 -0
  13. package/dist/v2/CalendarPageV2.js +92 -14
  14. package/dist/v2/CalendarPageV2.js.map +1 -1
  15. package/dist/v2/colors.d.ts +23 -0
  16. package/dist/v2/colors.js +92 -0
  17. package/dist/v2/colors.js.map +1 -0
  18. package/dist/v2/data/enums.d.ts +6 -0
  19. package/dist/v2/data/enums.js +10 -0
  20. package/dist/v2/data/enums.js.map +1 -0
  21. package/dist/v2/data/errors.d.ts +4 -0
  22. package/dist/v2/data/errors.js +17 -0
  23. package/dist/v2/data/errors.js.map +1 -0
  24. package/dist/v2/data/invalidation.js +19 -0
  25. package/dist/v2/data/invalidation.js.map +1 -0
  26. package/dist/v2/data/normalize.js +181 -16
  27. package/dist/v2/data/normalize.js.map +1 -1
  28. package/dist/v2/data/serialWrites.d.ts +17 -0
  29. package/dist/v2/data/serialWrites.js +21 -0
  30. package/dist/v2/data/serialWrites.js.map +1 -0
  31. package/dist/v2/data/useCalendarsV2.d.ts +10 -1
  32. package/dist/v2/data/useCalendarsV2.js +68 -16
  33. package/dist/v2/data/useCalendarsV2.js.map +1 -1
  34. package/dist/v2/data/useEventActions.d.ts +49 -0
  35. package/dist/v2/data/useEventActions.js +399 -0
  36. package/dist/v2/data/useEventActions.js.map +1 -0
  37. package/dist/v2/data/useEventForPeek.d.ts +17 -0
  38. package/dist/v2/data/useEventForPeek.js +29 -0
  39. package/dist/v2/data/useEventForPeek.js.map +1 -0
  40. package/dist/v2/data/useEventSearchV2.d.ts +15 -0
  41. package/dist/v2/data/useEventSearchV2.js +80 -0
  42. package/dist/v2/data/useEventSearchV2.js.map +1 -0
  43. package/dist/v2/data/useEventsInRangeV2.js +78 -0
  44. package/dist/v2/data/useEventsInRangeV2.js.map +1 -0
  45. package/dist/v2/data/useFreeBusy.d.ts +5 -0
  46. package/dist/v2/data/useFreeBusy.js +83 -0
  47. package/dist/v2/data/useFreeBusy.js.map +1 -0
  48. package/dist/v2/data/useKeyedLoad.js +47 -0
  49. package/dist/v2/data/useKeyedLoad.js.map +1 -0
  50. package/dist/v2/data/useRoomsV2.d.ts +28 -0
  51. package/dist/v2/data/useRoomsV2.js +45 -0
  52. package/dist/v2/data/useRoomsV2.js.map +1 -0
  53. package/dist/v2/day/DayPanel.d.ts +6 -0
  54. package/dist/v2/day/DayPanel.js +215 -0
  55. package/dist/v2/day/DayPanel.js.map +1 -0
  56. package/dist/v2/day/daySummary.d.ts +37 -0
  57. package/dist/v2/day/daySummary.js +37 -0
  58. package/dist/v2/day/daySummary.js.map +1 -0
  59. package/dist/v2/dialogs/CalendarDialogsV2.d.ts +1 -0
  60. package/dist/v2/dialogs/CalendarDialogsV2.js +17 -0
  61. package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -0
  62. package/dist/v2/dialogs/ShortcutsDialog.d.ts +4 -0
  63. package/dist/v2/dialogs/ShortcutsDialog.js +42 -0
  64. package/dist/v2/dialogs/ShortcutsDialog.js.map +1 -0
  65. package/dist/v2/events/eventLook.d.ts +46 -0
  66. package/dist/v2/events/eventLook.js +35 -0
  67. package/dist/v2/events/eventLook.js.map +1 -0
  68. package/dist/v2/events/eventModel.d.ts +92 -0
  69. package/dist/v2/events/eventModel.js +116 -0
  70. package/dist/v2/events/eventModel.js.map +1 -0
  71. package/dist/v2/events/localChanges.d.ts +4 -0
  72. package/dist/v2/events/localChanges.js +23 -0
  73. package/dist/v2/events/localChanges.js.map +1 -0
  74. package/dist/v2/format.d.ts +67 -0
  75. package/dist/v2/format.js +112 -0
  76. package/dist/v2/format.js.map +1 -0
  77. package/dist/v2/grid/AllDayRow.d.ts +20 -0
  78. package/dist/v2/grid/AllDayRow.js +94 -0
  79. package/dist/v2/grid/AllDayRow.js.map +1 -0
  80. package/dist/v2/grid/EventBlock.d.ts +21 -0
  81. package/dist/v2/grid/EventBlock.js +112 -0
  82. package/dist/v2/grid/EventBlock.js.map +1 -0
  83. package/dist/v2/grid/GridParts.d.ts +40 -0
  84. package/dist/v2/grid/GridParts.js +210 -0
  85. package/dist/v2/grid/GridParts.js.map +1 -0
  86. package/dist/v2/grid/QuickCreate.d.ts +1 -0
  87. package/dist/v2/grid/QuickCreate.js +175 -0
  88. package/dist/v2/grid/QuickCreate.js.map +1 -0
  89. package/dist/v2/grid/TimeGrid.d.ts +1 -0
  90. package/dist/v2/grid/TimeGrid.js +188 -0
  91. package/dist/v2/grid/TimeGrid.js.map +1 -0
  92. package/dist/v2/grid/geometry.d.ts +72 -0
  93. package/dist/v2/grid/geometry.js +85 -0
  94. package/dist/v2/grid/geometry.js.map +1 -0
  95. package/dist/v2/grid/layout.d.ts +24 -0
  96. package/dist/v2/grid/layout.js +77 -0
  97. package/dist/v2/grid/layout.js.map +1 -0
  98. package/dist/v2/grid/useGridDrag.d.ts +42 -0
  99. package/dist/v2/grid/useGridDrag.js +181 -0
  100. package/dist/v2/grid/useGridDrag.js.map +1 -0
  101. package/dist/v2/grid/useSlotCursor.d.ts +32 -0
  102. package/dist/v2/grid/useSlotCursor.js +57 -0
  103. package/dist/v2/grid/useSlotCursor.js.map +1 -0
  104. package/dist/v2/grid/workingHours.d.ts +21 -0
  105. package/dist/v2/grid/workingHours.js +101 -0
  106. package/dist/v2/grid/workingHours.js.map +1 -0
  107. package/dist/v2/hooks/useAvailableHeight.d.ts +2 -0
  108. package/dist/v2/hooks/useAvailableHeight.js +25 -0
  109. package/dist/v2/hooks/useAvailableHeight.js.map +1 -0
  110. package/dist/v2/hooks/useCalendarShortcuts.d.ts +9 -0
  111. package/dist/v2/hooks/useCalendarShortcuts.js +60 -0
  112. package/dist/v2/hooks/useCalendarShortcuts.js.map +1 -0
  113. package/dist/v2/hooks/useDebouncedValue.d.ts +1 -0
  114. package/dist/v2/hooks/useDebouncedValue.js +12 -0
  115. package/dist/v2/hooks/useDebouncedValue.js.map +1 -0
  116. package/dist/v2/hooks/useMediaQuery.d.ts +5 -0
  117. package/dist/v2/hooks/useMediaQuery.js +17 -0
  118. package/dist/v2/hooks/useMediaQuery.js.map +1 -0
  119. package/dist/v2/hooks/useNow.d.ts +2 -0
  120. package/dist/v2/hooks/useNow.js +31 -0
  121. package/dist/v2/hooks/useNow.js.map +1 -0
  122. package/dist/v2/limits.d.ts +6 -0
  123. package/dist/v2/limits.js +5 -0
  124. package/dist/v2/limits.js.map +1 -0
  125. package/dist/v2/list/EventListRow.d.ts +10 -0
  126. package/dist/v2/list/EventListRow.js +109 -0
  127. package/dist/v2/list/EventListRow.js.map +1 -0
  128. package/dist/v2/list/ListViewV2.d.ts +16 -0
  129. package/dist/v2/list/ListViewV2.js +96 -0
  130. package/dist/v2/list/ListViewV2.js.map +1 -0
  131. package/dist/v2/month/MonthView.d.ts +1 -0
  132. package/dist/v2/month/MonthView.js +328 -0
  133. package/dist/v2/month/MonthView.js.map +1 -0
  134. package/dist/v2/month/monthLayout.d.ts +39 -0
  135. package/dist/v2/month/monthLayout.js +29 -0
  136. package/dist/v2/month/monthLayout.js.map +1 -0
  137. package/dist/v2/page/CalendarChrome.d.ts +2 -0
  138. package/dist/v2/page/CalendarChrome.js +295 -0
  139. package/dist/v2/page/CalendarChrome.js.map +1 -0
  140. package/dist/v2/page/CalendarPageContext.d.ts +92 -0
  141. package/dist/v2/page/CalendarPageContext.js +11 -0
  142. package/dist/v2/page/CalendarPageContext.js.map +1 -0
  143. package/dist/v2/page/pageHelpers.d.ts +19 -0
  144. package/dist/v2/page/pageHelpers.js +39 -0
  145. package/dist/v2/page/pageHelpers.js.map +1 -0
  146. package/dist/v2/page/useCalendarPageModel.d.ts +2 -0
  147. package/dist/v2/page/useCalendarPageModel.js +198 -0
  148. package/dist/v2/page/useCalendarPageModel.js.map +1 -0
  149. package/dist/v2/page/viewState.d.ts +70 -0
  150. package/dist/v2/page/viewState.js +47 -0
  151. package/dist/v2/page/viewState.js.map +1 -0
  152. package/dist/v2/peek/EventPeek.d.ts +2 -0
  153. package/dist/v2/peek/EventPeek.js +92 -0
  154. package/dist/v2/peek/EventPeek.js.map +1 -0
  155. package/dist/v2/peek/PeekEvent.d.ts +4 -0
  156. package/dist/v2/peek/PeekEvent.js +443 -0
  157. package/dist/v2/peek/PeekEvent.js.map +1 -0
  158. package/dist/v2/peek/PeekParts.d.ts +14 -0
  159. package/dist/v2/peek/PeekParts.js +75 -0
  160. package/dist/v2/peek/PeekParts.js.map +1 -0
  161. package/dist/v2/prefs/calendarPrefs.d.ts +2 -2
  162. package/dist/v2/prefs/calendarPrefs.js +35 -34
  163. package/dist/v2/prefs/calendarPrefs.js.map +1 -1
  164. package/dist/v2/rail/CalendarRail.d.ts +3 -0
  165. package/dist/v2/rail/CalendarRail.js +258 -0
  166. package/dist/v2/rail/CalendarRail.js.map +1 -0
  167. package/dist/v2/rail/railStatus.d.ts +54 -0
  168. package/dist/v2/rail/railStatus.js +84 -0
  169. package/dist/v2/rail/railStatus.js.map +1 -0
  170. package/dist/v2/rail/syncWords.d.ts +10 -0
  171. package/dist/v2/rail/syncWords.js +75 -0
  172. package/dist/v2/rail/syncWords.js.map +1 -0
  173. package/dist/v2/rail/useMonthEventDates.d.ts +4 -0
  174. package/dist/v2/rail/useMonthEventDates.js +30 -0
  175. package/dist/v2/rail/useMonthEventDates.js.map +1 -0
  176. package/dist/v2/routes.js +4 -1
  177. package/dist/v2/routes.js.map +1 -1
  178. package/dist/v2/runs/RunPeek.d.ts +2 -0
  179. package/dist/v2/runs/RunPeek.js +382 -0
  180. package/dist/v2/runs/RunPeek.js.map +1 -0
  181. package/dist/v2/runs/RunPills.d.ts +28 -0
  182. package/dist/v2/runs/RunPills.js +179 -0
  183. package/dist/v2/runs/RunPills.js.map +1 -0
  184. package/dist/v2/runs/RunRows.d.ts +21 -0
  185. package/dist/v2/runs/RunRows.js +140 -0
  186. package/dist/v2/runs/RunRows.js.map +1 -0
  187. package/dist/v2/runs/RunsNotices.d.ts +1 -0
  188. package/dist/v2/runs/RunsNotices.js +37 -0
  189. package/dist/v2/runs/RunsNotices.js.map +1 -0
  190. package/dist/v2/runs/RunsSwitch.d.ts +1 -0
  191. package/dist/v2/runs/RunsSwitch.js +54 -0
  192. package/dist/v2/runs/RunsSwitch.js.map +1 -0
  193. package/dist/v2/runs/WorkflowRunsLayer.d.ts +4 -0
  194. package/dist/v2/runs/WorkflowRunsLayer.js +82 -0
  195. package/dist/v2/runs/WorkflowRunsLayer.js.map +1 -0
  196. package/dist/v2/runs/runAccess.d.ts +37 -0
  197. package/dist/v2/runs/runAccess.js +14 -0
  198. package/dist/v2/runs/runAccess.js.map +1 -0
  199. package/dist/v2/runs/runLayout.d.ts +76 -0
  200. package/dist/v2/runs/runLayout.js +129 -0
  201. package/dist/v2/runs/runLayout.js.map +1 -0
  202. package/dist/v2/runs/runLinks.d.ts +32 -0
  203. package/dist/v2/runs/runLinks.js +50 -0
  204. package/dist/v2/runs/runLinks.js.map +1 -0
  205. package/dist/v2/runs/runModel.d.ts +97 -0
  206. package/dist/v2/runs/runModel.js +132 -0
  207. package/dist/v2/runs/runModel.js.map +1 -0
  208. package/dist/v2/runs/runPeekState.d.ts +53 -0
  209. package/dist/v2/runs/runPeekState.js +62 -0
  210. package/dist/v2/runs/runPeekState.js.map +1 -0
  211. package/dist/v2/runs/runTypes.d.ts +60 -0
  212. package/dist/v2/runs/runWords.d.ts +23 -0
  213. package/dist/v2/runs/runWords.js +83 -0
  214. package/dist/v2/runs/runWords.js.map +1 -0
  215. package/dist/v2/runs/runsLayerContext.d.ts +26 -0
  216. package/dist/v2/runs/runsLayerContext.js +33 -0
  217. package/dist/v2/runs/runsLayerContext.js.map +1 -0
  218. package/dist/v2/runs/useRunHrefs.d.ts +10 -0
  219. package/dist/v2/runs/useRunHrefs.js +60 -0
  220. package/dist/v2/runs/useRunHrefs.js.map +1 -0
  221. package/dist/v2/runs/useRunLabels.d.ts +6 -0
  222. package/dist/v2/runs/useRunLabels.js +27 -0
  223. package/dist/v2/runs/useRunLabels.js.map +1 -0
  224. package/dist/v2/runs/useRunsAccess.d.ts +2 -0
  225. package/dist/v2/runs/useRunsAccess.js +14 -0
  226. package/dist/v2/runs/useRunsAccess.js.map +1 -0
  227. package/dist/v2/runs/useWorkflowRuns.d.ts +61 -0
  228. package/dist/v2/runs/useWorkflowRuns.js +119 -0
  229. package/dist/v2/runs/useWorkflowRuns.js.map +1 -0
  230. package/dist/v2/search/SearchResults.d.ts +1 -0
  231. package/dist/v2/search/SearchResults.js +88 -0
  232. package/dist/v2/search/SearchResults.js.map +1 -0
  233. package/dist/v2/search/searchModel.d.ts +20 -0
  234. package/dist/v2/search/searchModel.js +22 -0
  235. package/dist/v2/search/searchModel.js.map +1 -0
  236. package/dist/v2/state/calendarV2Store.d.ts +4 -1
  237. package/dist/v2/state/calendarV2Store.js +3 -1
  238. package/dist/v2/state/calendarV2Store.js.map +1 -1
  239. package/dist/v2/state/useCalendarV2Navigation.d.ts +1 -0
  240. package/dist/v2/state/useCalendarV2Navigation.js +4 -1
  241. package/dist/v2/state/useCalendarV2Navigation.js.map +1 -1
  242. package/dist/v2/states/CalendarStates.d.ts +18 -0
  243. package/dist/v2/states/CalendarStates.js +122 -0
  244. package/dist/v2/states/CalendarStates.js.map +1 -0
  245. package/dist/v2/styles.d.ts +32 -0
  246. package/dist/v2/styles.js +10 -0
  247. package/dist/v2/styles.js.map +1 -0
  248. package/dist/v2/time/calendarTime.js +121 -35
  249. package/dist/v2/time/calendarTime.js.map +1 -1
  250. package/dist/v2/types.d.ts +22 -2
  251. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RunsSwitch.js","names":["WorkflowRunsSwitch","useCalendarPage","layer","useWorkflowRunsLayer","usable","access","note","tr","Lock","GitBranch","Switch"],"sources":["../../../src/v2/runs/RunsSwitch.tsx"],"sourcesContent":["/**\n * The rail's Workflow runs switch (BOFF-15698 B5): off by default, remembered with the\n * person's calendar settings. Someone who can't read this workspace's schedules sees it\n * locked, with why, never a switch that would fail; while their access is being checked it\n * waits. Someone who can read schedules but not their runs sees what is to come, and is told.\n */\nimport { GitBranch, Lock } from 'lucide-react';\nimport { Switch } from '@burdenoff/fe-libs/ui';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { useWorkflowRunsLayer } from './runsLayerContext';\n\nexport function WorkflowRunsSwitch() {\n const { tr } = useCalendarPage();\n const layer = useWorkflowRunsLayer();\n const { access } = layer;\n const usable = access.kind === 'allowed';\n let note: string;\n switch (access.kind) {\n case 'denied':\n note = tr(\n 'calendar.v2.runsLocked',\n 'Locked: you can’t see this workspace’s schedules. A workspace admin can give you access.'\n );\n break;\n case 'checking':\n note = tr('calendar.v2.runsChecking', 'Checking your access to schedules…');\n break;\n case 'unknown':\n note = tr(\n 'calendar.v2.runsAccessUnknown',\n 'Couldn’t check your access to schedules. Reload the page to try again.'\n );\n break;\n default:\n note = access.past\n ? tr('calendar.v2.runsNote', 'Scheduled runs, read-only.')\n : tr(\n 'calendar.v2.runsNoteUpcoming',\n 'Upcoming runs only, read-only: you can’t see past runs.'\n );\n }\n return (\n <div className=\"flex items-start gap-2 px-1.5 py-1.5\" data-testid=\"workflow-runs-switch\">\n <span\n aria-hidden=\"true\"\n className=\"grid size-6 shrink-0 place-items-center rounded-md bg-bg-sunken text-text-secondary\"\n >\n {access.kind === 'denied' ? (\n <Lock className=\"size-3.5\" />\n ) : (\n <GitBranch className=\"size-3.5\" />\n )}\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <b id=\"calendar-runs-label\" className=\"text-sm font-medium text-text-primary\">\n {tr('calendar.v2.workflowRuns', 'Workflow runs')}\n </b>\n <small id=\"calendar-runs-note\" className=\"text-xs text-text-secondary\">\n {note}\n </small>\n </span>\n <Switch\n checked={usable && layer.switchOn}\n disabled={!usable}\n onCheckedChange={layer.setSwitchOn}\n aria-labelledby=\"calendar-runs-label\"\n aria-describedby=\"calendar-runs-note\"\n />\n </div>\n );\n}\n"],"mappings":";;;;;;AAWA,SAAgBA,IAAqB;CACnC,IAAM,EAAE,UAAOC,EAAgB,GACzBC,IAAQC,EAAqB,GAC7B,EAAE,cAAWD,GACbE,IAASC,EAAO,SAAS,WAC3BC;CACJ,QAAQD,EAAO,MAAf;EACE,KAAK;GACH,IAAOE,EACL,0BACA,0FACF;GACA;EACF,KAAK;GACH,IAAOA,EAAG,4BAA4B,oCAAoC;GAC1E;EACF,KAAK;GACH,IAAOA,EACL,iCACA,wEACF;GACA;EACF,SACE,IAAOF,EAAO,OACVE,EAAG,wBAAwB,4BAA4B,IACvDA,EACE,gCACA,yDACF;CACR;CACA,OACE,kBAAC,OAAD;EAAK,WAAU;EAAuC,eAAY;EAAlE,UAAA;GACE,kBAAC,QAAD;IACE,eAAY;IACZ,WAAU;IAET,UAAAF,EAAO,SAAS,WACf,kBAACG,GAAD,EAAM,WAAU,WAAY,CAAA,IAE5B,kBAACC,GAAD,EAAW,WAAU,WAAY,CAAA;GAE/B,CAAA;GACN,kBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,kBAAC,KAAD;KAAG,IAAG;KAAsB,WAAU;KACnC,UAAAF,EAAG,4BAA4B,eAAe;IAC9C,CAAA,GACH,kBAAC,SAAD;KAAO,IAAG;KAAqB,WAAU;KACtC,UAAAD;IACI,CAAA,CACH;;GACN,kBAACI,GAAD;IACE,SAASN,KAAUF,EAAM;IACzB,UAAU,CAACE;IACX,iBAAiBF,EAAM;IACvB,mBAAgB;IAChB,oBAAiB;GAClB,CAAA;EACE;;AAET"}
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from 'react';
2
+ export declare function WorkflowRunsLayer({ children }: {
3
+ children: ReactNode;
4
+ }): import('react').JSX.Element;
@@ -0,0 +1,82 @@
1
+ import { useCalendar as e } from "../../providers/CalendarProvider.js";
2
+ import { useCalendarPage as t } from "../page/CalendarPageContext.js";
3
+ import { useCalendarV2Store as n } from "../state/calendarV2Store.js";
4
+ import { daysToInstants as r } from "../time/calendarTime.js";
5
+ import { runsByDay as i } from "./runLayout.js";
6
+ import { useRunPeek as a } from "./runPeekState.js";
7
+ import { IDLE_RUNS_DATA as o, WorkflowRunsContext as s } from "./runsLayerContext.js";
8
+ import { useRunsAccess as c } from "./useRunsAccess.js";
9
+ import { useWorkflowRuns as l } from "./useWorkflowRuns.js";
10
+ import { useCallback as u, useMemo as d } from "react";
11
+ import { jsx as f } from "react/jsx-runtime";
12
+ import { useNotify as p } from "@burdenoff/fe-libs/ui";
13
+ // src/v2/runs/WorkflowRunsLayer.tsx
14
+ var m = /* @__PURE__ */ new Map();
15
+ function h({ children: h }) {
16
+ let g = t(), { tr: _, days: v, timeZone: y, now: b, nav: x } = g, { workspaceId: S, workflowRunLinks: C } = e(), w = p(), T = n((e) => e.runsLayer), E = n((e) => e.setRunsLayer), D = c(S), O = T && D.kind === "allowed", k = v[0] ?? g.today, A = v[v.length - 1] ?? k, j = d(() => r(k, A, y), [
17
+ k,
18
+ A,
19
+ y
20
+ ]), M = l({
21
+ workspaceId: S ?? null,
22
+ from: j.from,
23
+ to: j.to,
24
+ now: b,
25
+ timeZone: y,
26
+ upcoming: O,
27
+ past: O && D.kind === "allowed" && D.past
28
+ }), N = d(() => O ? i(M.runs, v, y) : m, [
29
+ M.runs,
30
+ v,
31
+ O,
32
+ y
33
+ ]), P = u((e) => N.get(e), [N]), F = d(() => [...N.values()].reduce((e, t) => e + t.total, 0), [N]), I = a({
34
+ daysKey: `${k}|${A}`,
35
+ eventOpen: x.eventId !== null,
36
+ dialog: x.dialog,
37
+ shown: O,
38
+ closeEventPeek: g.closePeek,
39
+ closeQuickCreate: g.quickDraft ? g.closeQuickCreate : null
40
+ }), { closePeek: L } = I, R = u(() => {
41
+ L(), E(!1), w({
42
+ title: _("calendar.v2.runsHidden", "Workflow runs are hidden."),
43
+ tone: "info",
44
+ undo: () => E(!0),
45
+ undoneTitle: _("calendar.v2.runsShownAgain", "Workflow runs show again.")
46
+ });
47
+ }, [
48
+ L,
49
+ w,
50
+ E,
51
+ _
52
+ ]), z = d(() => ({
53
+ ...I,
54
+ switchOn: T,
55
+ setSwitchOn: E,
56
+ access: D,
57
+ shown: O,
58
+ data: O ? M : o,
59
+ runsOn: P,
60
+ shownCount: F,
61
+ links: C ?? null,
62
+ hideRuns: R
63
+ }), [
64
+ D,
65
+ M,
66
+ R,
67
+ I,
68
+ P,
69
+ E,
70
+ O,
71
+ F,
72
+ T,
73
+ C
74
+ ]);
75
+ return /* @__PURE__ */ f(s, {
76
+ value: z,
77
+ children: h
78
+ });
79
+ }
80
+ export { h as WorkflowRunsLayer };
81
+
82
+ //# sourceMappingURL=WorkflowRunsLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowRunsLayer.js","names":["NO_DAYS","WorkflowRunsLayer","page","useCalendarPage","useCalendar","notify","useNotify","switchOn","useCalendarV2Store","state","setSwitchOn","access","useRunsAccess","workspaceId","shown","first","days","last","range","useMemo","daysToInstants","timeZone","data","useWorkflowRuns","byDay","runsByDay","runsOn","useCallback","day","shownCount","sum","peek","useRunPeek","nav","hideRuns","closePeek","tr","model","IDLE_RUNS_DATA","workflowRunLinks","WorkflowRunsContext"],"sources":["../../../src/v2/runs/WorkflowRunsLayer.tsx"],"sourcesContent":["/**\n * The workflow runs layer (BOFF-15698 B5): FluidGrids' scheduled workflow runs on the calendar,\n * read-only, behind the rail's switch (off by default; remembered with the person's calendar\n * settings, as hidden calendars are). Who may see it is `runsAccess`; what shows, the runs of\n * the shown days (`useWorkflowRuns`) by day (`runsByDay`); a run or a group of them opens in\n * the run peek, which this layer holds. Its parts read it with `useWorkflowRunsLayer`\n * (`runsLayerContext`).\n */\nimport { useCallback, useMemo, type ReactNode } from 'react';\nimport { useNotify, type DateValue } from '@burdenoff/fe-libs/ui';\nimport { useCalendar } from '../../providers/CalendarProvider';\nimport { useCalendarPage } from '../page/CalendarPageContext';\nimport { useCalendarV2Store } from '../state/calendarV2Store';\nimport { daysToInstants } from '../time/calendarTime';\nimport { runsByDay, type DayRuns } from './runLayout';\nimport { useRunPeek } from './runPeekState';\nimport {\n IDLE_RUNS_DATA,\n WorkflowRunsContext,\n type WorkflowRunsLayerModel,\n} from './runsLayerContext';\nimport { useRunsAccess } from './useRunsAccess';\nimport { useWorkflowRuns } from './useWorkflowRuns';\n\nconst NO_DAYS = new Map<DateValue, DayRuns>();\n\nexport function WorkflowRunsLayer({ children }: { children: ReactNode }) {\n const page = useCalendarPage();\n const { tr, days, timeZone, now, nav } = page;\n const { workspaceId, workflowRunLinks } = useCalendar();\n const notify = useNotify();\n const switchOn = useCalendarV2Store((state) => state.runsLayer);\n const setSwitchOn = useCalendarV2Store((state) => state.setRunsLayer);\n const access = useRunsAccess(workspaceId);\n const shown = switchOn && access.kind === 'allowed';\n\n const first = days[0] ?? page.today;\n const last = days[days.length - 1] ?? first;\n const range = useMemo(() => daysToInstants(first, last, timeZone), [first, last, timeZone]);\n const data = useWorkflowRuns({\n workspaceId: workspaceId ?? null,\n from: range.from,\n to: range.to,\n now,\n timeZone,\n upcoming: shown,\n past: shown && access.kind === 'allowed' && access.past,\n });\n const byDay = useMemo(\n () => (shown ? runsByDay(data.runs, days, timeZone) : NO_DAYS),\n [data.runs, days, shown, timeZone]\n );\n const runsOn = useCallback((day: DateValue) => byDay.get(day), [byDay]);\n const shownCount = useMemo(\n () => [...byDay.values()].reduce((sum, day) => sum + day.total, 0),\n [byDay]\n );\n\n const peek = useRunPeek({\n daysKey: `${first}|${last}`,\n eventOpen: nav.eventId !== null,\n dialog: nav.dialog,\n shown,\n closeEventPeek: page.closePeek,\n closeQuickCreate: page.quickDraft ? page.closeQuickCreate : null,\n });\n const { closePeek } = peek;\n const hideRuns = useCallback(() => {\n closePeek();\n setSwitchOn(false);\n notify({\n title: tr('calendar.v2.runsHidden', 'Workflow runs are hidden.'),\n tone: 'info',\n undo: () => setSwitchOn(true),\n undoneTitle: tr('calendar.v2.runsShownAgain', 'Workflow runs show again.'),\n });\n }, [closePeek, notify, setSwitchOn, tr]);\n\n const model = useMemo<WorkflowRunsLayerModel>(\n () => ({\n ...peek,\n switchOn,\n setSwitchOn,\n access,\n shown,\n data: shown ? data : IDLE_RUNS_DATA,\n runsOn,\n shownCount,\n links: workflowRunLinks ?? null,\n hideRuns,\n }),\n [\n access,\n data,\n hideRuns,\n peek,\n runsOn,\n setSwitchOn,\n shown,\n shownCount,\n switchOn,\n workflowRunLinks,\n ]\n );\n return <WorkflowRunsContext value={model}>{children}</WorkflowRunsContext>;\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAMA,oBAAU,IAAI,IAAwB;AAE5C,SAAgBC,EAAkB,EAAE,eAAqC;CACvE,IAAMC,IAAOC,EAAgB,GACvB,EAAE,OAAI,SAAM,aAAU,QAAK,WAAQD,GACnC,EAAE,gBAAa,wBAAqBE,EAAY,GAChDC,IAASC,EAAU,GACnBC,IAAWC,GAAoB,MAAUC,EAAM,SAAS,GACxDC,IAAcF,GAAoB,MAAUC,EAAM,YAAY,GAC9DE,IAASC,EAAcC,CAAW,GAClCC,IAAQP,KAAYI,EAAO,SAAS,WAEpCI,IAAQC,EAAK,MAAMd,EAAK,OACxBe,IAAOD,EAAKA,EAAK,SAAS,MAAMD,GAChCG,IAAQC,QAAcC,EAAeL,GAAOE,GAAMI,CAAQ,GAAG;EAACN;EAAOE;EAAMI;CAAQ,CAAC,GACpFC,IAAOC,EAAgB;EAC3B,aAAaV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er (BOFF-15698 B5). Upcoming runs need `schedule:read`
3
+ * (scheduleOccurrences' @rbac), past runs `schedule-execution:read` (workspaceJobExecutions').
4
+ * Someone without the first sees the switch locked, with a note, and nothing is asked for;
5
+ * someone with only the first sees what is to come. Pure.
6
+ */
7
+ /** The permissions as fe-libs' PermissionProvider gives them (null: the module stands alone). */
8
+ export interface PermissionCheck {
9
+ isLoading: boolean;
10
+ error: Error | null;
11
+ hasPermission: (permission: string) => boolean;
12
+ }
13
+ export declare const SCHEDULE_READ = "schedule:read";
14
+ export declare const SCHEDULE_EXECUTION_READ = "schedule-execution:read";
15
+ export type RunsAccess =
16
+ /** The permissions are still loading: the switch waits. */
17
+ {
18
+ kind: 'checking';
19
+ }
20
+ /** They couldn’t be loaded and don’t allow it: the switch waits, and says so. */
21
+ | {
22
+ kind: 'unknown';
23
+ }
24
+ /** No `schedule:read` (or no workspace): the switch is locked. */
25
+ | {
26
+ kind: 'denied';
27
+ }
28
+ /** `past`: past runs too (`schedule-execution:read`); else only what is to come. */
29
+ | {
30
+ kind: 'allowed';
31
+ past: boolean;
32
+ };
33
+ /**
34
+ * What the person may see. Outside a PermissionProvider (the module running on its own, where
35
+ * there is no shell to ask) the gateway alone decides, so the layer may ask.
36
+ */
37
+ export declare function runsAccess(permissions: PermissionCheck | null, workspaceId: string | null | undefined): RunsAccess;
@@ -0,0 +1,14 @@
1
+ // src/v2/runs/runAccess.ts
2
+ var e = "schedule:read", t = "schedule-execution:read";
3
+ function n(e, n) {
4
+ return n ? e ? e.isLoading ? { kind: "checking" } : e.hasPermission("schedule:read") ? {
5
+ kind: "allowed",
6
+ past: e.hasPermission(t)
7
+ } : e.error ? { kind: "unknown" } : { kind: "denied" } : {
8
+ kind: "allowed",
9
+ past: !0
10
+ } : { kind: "denied" };
11
+ }
12
+ export { t as SCHEDULE_EXECUTION_READ, e as SCHEDULE_READ, n as runsAccess };
13
+
14
+ //# sourceMappingURL=runAccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runAccess.js","names":["SCHEDULE_READ","SCHEDULE_EXECUTION_READ","runsAccess","workspaceId","permissions"],"sources":["../../../src/v2/runs/runAccess.ts"],"sourcesContent":["/**\n * Who may see the workflow runs layer (BOFF-15698 B5). Upcoming runs need `schedule:read`\n * (scheduleOccurrences' @rbac), past runs `schedule-execution:read` (workspaceJobExecutions').\n * Someone without the first sees the switch locked, with a note, and nothing is asked for;\n * someone with only the first sees what is to come. Pure.\n */\n\n/** The permissions as fe-libs' PermissionProvider gives them (null: the module stands alone). */\nexport interface PermissionCheck {\n isLoading: boolean;\n error: Error | null;\n hasPermission: (permission: string) => boolean;\n}\n\nexport const SCHEDULE_READ = 'schedule:read';\nexport const SCHEDULE_EXECUTION_READ = 'schedule-execution:read';\n\nexport type RunsAccess =\n /** The permissions are still loading: the switch waits. */\n | { kind: 'checking' }\n /** They couldn’t be loaded and don’t allow it: the switch waits, and says so. */\n | { kind: 'unknown' }\n /** No `schedule:read` (or no workspace): the switch is locked. */\n | { kind: 'denied' }\n /** `past`: past runs too (`schedule-execution:read`); else only what is to come. */\n | { kind: 'allowed'; past: boolean };\n\n/**\n * What the person may see. Outside a PermissionProvider (the module running on its own, where\n * there is no shell to ask) the gateway alone decides, so the layer may ask.\n */\nexport function runsAccess(\n permissions: PermissionCheck | null,\n workspaceId: string | null | undefined\n): RunsAccess {\n if (!workspaceId) return { kind: 'denied' };\n if (!permissions) return { kind: 'allowed', past: true };\n if (permissions.isLoading) return { kind: 'checking' };\n // A refresh that failed keeps the permissions it had: only a \"no\" may be the failure's.\n if (!permissions.hasPermission(SCHEDULE_READ)) {\n return permissions.error ? { kind: 'unknown' } : { kind: 'denied' };\n }\n return { kind: 'allowed', past: permissions.hasPermission(SCHEDULE_EXECUTION_READ) };\n}\n"],"mappings":";AAcA,IAAaA,IAAgB,iBAChBC,IAA0B;AAgBvC,SAAgBC,EACd,GACA,GACY;CAQZ,OAPKC,IACAC,IACDA,EAAY,YAAkB,EAAE,MAAM,WAAW,IAEhDA,EAAY,cAAA,eAA2B,IAGrC;EAAE,MAAM;EAAW,MAAMA,EAAY,cAAcH,CAAuB;CAAE,IAF1EG,EAAY,QAAQ,EAAE,MAAM,UAAU,IAAI,EAAE,MAAM,SAAS,IAJ3C;EAAE,MAAM;EAAW,MAAM;CAAK,IAD9B,EAAE,MAAM,SAAS;AAQ5C"}
@@ -0,0 +1,76 @@
1
+ import { DateValue } from '@burdenoff/fe-libs/ui';
2
+ import { RunStatus, WorkflowRun } from './runModel';
3
+ /** The most runs a schedule shows one by one on a day; more show as one item. */
4
+ export declare const FEW_RUNS_PER_DAY = 4;
5
+ /** A busy schedule's runs on one day. */
6
+ export interface RunGroup {
7
+ /** `<schedule>|<day>` */
8
+ key: string;
9
+ scheduledJobId: string;
10
+ day: DateValue;
11
+ name: string;
12
+ /** In time order. */
13
+ runs: WorkflowRun[];
14
+ /** The minutes between its runs when they are evenly apart (every 20 minutes); else null. */
15
+ everyMinutes: number | null;
16
+ /** Minutes after midnight of its first and last run. */
17
+ firstMinute: number;
18
+ lastMinute: number;
19
+ summary: RunSummary;
20
+ }
21
+ export interface RunSummary {
22
+ total: number;
23
+ counts: Readonly<Record<RunStatus, number>>;
24
+ /** The one status a group or a shared pill shows. */
25
+ status: RunStatus;
26
+ }
27
+ /** One day's runs: busy schedules as groups, the rest one by one. */
28
+ export interface DayRuns {
29
+ day: DateValue;
30
+ groups: RunGroup[];
31
+ /** In time order. */
32
+ single: WorkflowRun[];
33
+ /** Every run of the day, groups' included. */
34
+ total: number;
35
+ summary: RunSummary;
36
+ }
37
+ /** Runs that share a pill in the grid: one, or several close together. */
38
+ export interface RunCluster {
39
+ /** Minutes after midnight of its first run. */
40
+ minute: number;
41
+ runs: WorkflowRun[];
42
+ summary: RunSummary;
43
+ }
44
+ export declare function summarizeRuns(runs: readonly WorkflowRun[]): RunSummary;
45
+ /**
46
+ * The minutes between a schedule's runs when they are all the same apart (to the minute), for
47
+ * three runs or more; else null.
48
+ */
49
+ export declare function evenGapMinutes(runs: readonly WorkflowRun[]): number | null;
50
+ /**
51
+ * The shown days' runs, by day on the clock of `timeZone`. A schedule with more than
52
+ * `FEW_RUNS_PER_DAY` runs on a day is a group that day.
53
+ */
54
+ export declare function runsByDay(runs: readonly WorkflowRun[], days: readonly DateValue[], timeZone: string): Map<DateValue, DayRuns>;
55
+ /**
56
+ * A day's single runs as grid pills: a run within `pillMinutes` of the pill before it joins
57
+ * that pill, so no two pills overlap.
58
+ */
59
+ export declare function clusterRuns(runs: readonly WorkflowRun[], timeZone: string, pillMinutes: number): RunCluster[];
60
+ /** One line of a day's list: an event, a run, or a busy schedule's day. */
61
+ export type DayItem<E> = {
62
+ kind: 'event';
63
+ event: E;
64
+ } | {
65
+ kind: 'run';
66
+ run: WorkflowRun;
67
+ } | {
68
+ kind: 'group';
69
+ group: RunGroup;
70
+ };
71
+ /**
72
+ * A day's list with its runs (the List view, phones' Month): all-day events first, then
73
+ * timed events, runs and busy schedules by time (a busy schedule at its first run), an event
74
+ * before a run at the same time. `startOf` is an event's start, null for an all-day one.
75
+ */
76
+ export declare function dayItems<E>(events: readonly E[], runs: DayRuns | undefined, startOf: (event: E) => number | null): DayItem<E>[];
@@ -0,0 +1,129 @@
1
+ import { instantToZoned as e } from "../time/calendarTime.js";
2
+ var t = {
3
+ succeeded: 0,
4
+ failed: 0,
5
+ retrying: 0,
6
+ running: 0,
7
+ ended: 0,
8
+ overdue: 0,
9
+ scheduled: 0
10
+ }, n = [
11
+ "failed",
12
+ "retrying",
13
+ "overdue",
14
+ "running"
15
+ ];
16
+ function r(e) {
17
+ let r = { ...t };
18
+ for (let t of e) r[t.status] += 1;
19
+ let i = n.find((e) => r[e] > 0), a;
20
+ return a = i || (r.succeeded > 0 ? "succeeded" : r.ended > 0 ? "ended" : "scheduled"), {
21
+ total: e.length,
22
+ counts: r,
23
+ status: a
24
+ };
25
+ }
26
+ function i(e) {
27
+ if (e.length < 3) return null;
28
+ let t = e.map((e) => (e.fireAt ?? e.at).getTime()).sort((e, t) => e - t), n = null;
29
+ for (let e = 1; e < t.length; e += 1) {
30
+ let r = Math.round(((t[e] ?? 0) - (t[e - 1] ?? 0)) / 6e4);
31
+ if (r <= 0 || n !== null && r !== n) return null;
32
+ n = r;
33
+ }
34
+ return n;
35
+ }
36
+ function a(t, n, a) {
37
+ let o = new Set(n), s = /* @__PURE__ */ new Map();
38
+ for (let n of t) {
39
+ let { date: t } = e(n.at, a);
40
+ if (!o.has(t)) continue;
41
+ let r = s.get(t);
42
+ r || (r = /* @__PURE__ */ new Map(), s.set(t, r));
43
+ let i = r.get(n.scheduledJobId);
44
+ i ? i.push(n) : r.set(n.scheduledJobId, [n]);
45
+ }
46
+ let c = /* @__PURE__ */ new Map();
47
+ for (let t of n) {
48
+ let n = s.get(t);
49
+ if (!n) continue;
50
+ let o = [], l = [], u = [];
51
+ for (let [s, c] of n) {
52
+ if (u.push(...c), c.length <= 4) {
53
+ l.push(...c);
54
+ continue;
55
+ }
56
+ let n = [...c].sort((e, t) => e.at.getTime() - t.at.getTime()), d = n[0], f = n[n.length - 1];
57
+ d && f && o.push({
58
+ key: `${s}|${t}`,
59
+ scheduledJobId: s,
60
+ day: t,
61
+ name: d.name,
62
+ runs: n,
63
+ everyMinutes: i(n),
64
+ firstMinute: e(d.at, a).minutes,
65
+ lastMinute: e(f.at, a).minutes,
66
+ summary: r(n)
67
+ });
68
+ }
69
+ o.sort((e, t) => e.firstMinute - t.firstMinute || e.name.localeCompare(t.name)), l.sort((e, t) => e.at.getTime() - t.at.getTime() || e.name.localeCompare(t.name)), c.set(t, {
70
+ day: t,
71
+ groups: o,
72
+ single: l,
73
+ total: u.length,
74
+ summary: r(u)
75
+ });
76
+ }
77
+ return c;
78
+ }
79
+ function o(t, n, i) {
80
+ let a = [];
81
+ for (let r of t) {
82
+ let t = e(r.at, n).minutes, o = a[a.length - 1];
83
+ o && t < o.minute + i ? o.runs.push(r) : a.push({
84
+ minute: t,
85
+ runs: [r]
86
+ });
87
+ }
88
+ return a.map((e) => ({
89
+ ...e,
90
+ summary: r(e.runs)
91
+ }));
92
+ }
93
+ function s(e, t, n) {
94
+ let r = [], i = [];
95
+ for (let t of e) {
96
+ let e = n(t);
97
+ e === null ? r.push({
98
+ kind: "event",
99
+ event: t
100
+ }) : i.push({
101
+ at: e,
102
+ rank: 0,
103
+ item: {
104
+ kind: "event",
105
+ event: t
106
+ }
107
+ });
108
+ }
109
+ for (let e of t?.groups ?? []) i.push({
110
+ at: e.runs[0]?.at.getTime() ?? 0,
111
+ rank: 1,
112
+ item: {
113
+ kind: "group",
114
+ group: e
115
+ }
116
+ });
117
+ for (let e of t?.single ?? []) i.push({
118
+ at: e.at.getTime(),
119
+ rank: 1,
120
+ item: {
121
+ kind: "run",
122
+ run: e
123
+ }
124
+ });
125
+ return i.sort((e, t) => e.at - t.at || e.rank - t.rank), [...r, ...i.map((e) => e.item)];
126
+ }
127
+ export { o as clusterRuns, s as dayItems, i as evenGapMinutes, a as runsByDay, r as summarizeRuns };
128
+
129
+ //# sourceMappingURL=runLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runLayout.js","names":["NO_COUNTS","ATTENTION","summarizeRuns","counts","run","runs","first","status","evenGapMinutes","times","a","b","gap","index","minutes","runsByDay","shown","days","byDay","instantToZoned","timeZone","date","bySchedule","list","result","day","groups","single","all","scheduledJobId","sorted","last","clusterRuns","clusters","minute","current","pillMinutes","cluster","dayItems","allDay","timed","event","events","start","startOf","group","entry"],"sources":["../../../src/v2/runs/runLayout.ts"],"sourcesContent":["/**\n * Where the workflow runs layer's runs show (BOFF-15698 B5). Pure.\n *\n * - **A busy schedule is one item a day.** A schedule that runs more than `FEW_RUNS_PER_DAY`\n * times on a day (one every 20 minutes runs 72 times) shows as one item for that day: its\n * name, how often, how many, and how they went. It opens the day's runs. Others show run by\n * run.\n * - **Pills that would overlap in the grid share one**, \"3 runs\", which opens them.\n * - **One status stands for many:** a failure first, then a retry, an overdue run, a running\n * one; else succeeded when any has run, else scheduled.\n */\nimport type { DateValue } from '@burdenoff/fe-libs/ui';\nimport { instantToZoned } from '../time/calendarTime';\nimport type { RunStatus, WorkflowRun } from './runModel';\n\n/** The most runs a schedule shows one by one on a day; more show as one item. */\nexport const FEW_RUNS_PER_DAY = 4;\n\n/** A busy schedule's runs on one day. */\nexport interface RunGroup {\n /** `<schedule>|<day>` */\n key: string;\n scheduledJobId: string;\n day: DateValue;\n name: string;\n /** In time order. */\n runs: WorkflowRun[];\n /** The minutes between its runs when they are evenly apart (every 20 minutes); else null. */\n everyMinutes: number | null;\n /** Minutes after midnight of its first and last run. */\n firstMinute: number;\n lastMinute: number;\n summary: RunSummary;\n}\n\nexport interface RunSummary {\n total: number;\n counts: Readonly<Record<RunStatus, number>>;\n /** The one status a group or a shared pill shows. */\n status: RunStatus;\n}\n\n/** One day's runs: busy schedules as groups, the rest one by one. */\nexport interface DayRuns {\n day: DateValue;\n groups: RunGroup[];\n /** In time order. */\n single: WorkflowRun[];\n /** Every run of the day, groups' included. */\n total: number;\n summary: RunSummary;\n}\n\n/** Runs that share a pill in the grid: one, or several close together. */\nexport interface RunCluster {\n /** Minutes after midnight of its first run. */\n minute: number;\n runs: WorkflowRun[];\n summary: RunSummary;\n}\n\nconst NO_COUNTS: Readonly<Record<RunStatus, number>> = {\n succeeded: 0,\n failed: 0,\n retrying: 0,\n running: 0,\n ended: 0,\n overdue: 0,\n scheduled: 0,\n};\n\n/** The order a summary's status is picked in: what needs a look first. */\nconst ATTENTION: readonly RunStatus[] = ['failed', 'retrying', 'overdue', 'running'];\n\nexport function summarizeRuns(runs: readonly WorkflowRun[]): RunSummary {\n const counts: Record<RunStatus, number> = { ...NO_COUNTS };\n for (const run of runs) counts[run.status] += 1;\n const first = ATTENTION.find((status) => counts[status] > 0);\n let status: RunStatus;\n if (first) status = first;\n else if (counts.succeeded > 0) status = 'succeeded';\n else if (counts.ended > 0) status = 'ended';\n else status = 'scheduled';\n return { total: runs.length, counts, status };\n}\n\n/**\n * The minutes between a schedule's runs when they are all the same apart (to the minute), for\n * three runs or more; else null.\n */\nexport function evenGapMinutes(runs: readonly WorkflowRun[]): number | null {\n if (runs.length < 3) return null;\n const times = runs.map((run) => (run.fireAt ?? run.at).getTime()).sort((a, b) => a - b);\n let gap: number | null = null;\n for (let index = 1; index < times.length; index += 1) {\n const minutes = Math.round(((times[index] ?? 0) - (times[index - 1] ?? 0)) / 60_000);\n if (minutes <= 0 || (gap !== null && minutes !== gap)) return null;\n gap = minutes;\n }\n return gap;\n}\n\n/**\n * The shown days' runs, by day on the clock of `timeZone`. A schedule with more than\n * `FEW_RUNS_PER_DAY` runs on a day is a group that day.\n */\nexport function runsByDay(\n runs: readonly WorkflowRun[],\n days: readonly DateValue[],\n timeZone: string\n): Map<DateValue, DayRuns> {\n const shown = new Set(days);\n const byDay = new Map<DateValue, Map<string, WorkflowRun[]>>();\n for (const run of runs) {\n const { date } = instantToZoned(run.at, timeZone);\n if (!shown.has(date)) continue;\n let bySchedule = byDay.get(date);\n if (!bySchedule) {\n bySchedule = new Map();\n byDay.set(date, bySchedule);\n }\n const list = bySchedule.get(run.scheduledJobId);\n if (list) list.push(run);\n else bySchedule.set(run.scheduledJobId, [run]);\n }\n\n const result = new Map<DateValue, DayRuns>();\n for (const day of days) {\n const bySchedule = byDay.get(day);\n if (!bySchedule) continue;\n const groups: RunGroup[] = [];\n const single: WorkflowRun[] = [];\n const all: WorkflowRun[] = [];\n for (const [scheduledJobId, list] of bySchedule) {\n all.push(...list);\n if (list.length <= FEW_RUNS_PER_DAY) {\n single.push(...list);\n continue;\n }\n const sorted = [...list].sort((a, b) => a.at.getTime() - b.at.getTime());\n const first = sorted[0];\n const last = sorted[sorted.length - 1];\n if (!first || !last) continue;\n groups.push({\n key: `${scheduledJobId}|${day}`,\n scheduledJobId,\n day,\n name: first.name,\n runs: sorted,\n everyMinutes: evenGapMinutes(sorted),\n firstMinute: instantToZoned(first.at, timeZone).minutes,\n lastMinute: instantToZoned(last.at, timeZone).minutes,\n summary: summarizeRuns(sorted),\n });\n }\n groups.sort((a, b) => a.firstMinute - b.firstMinute || a.name.localeCompare(b.name));\n single.sort((a, b) => a.at.getTime() - b.at.getTime() || a.name.localeCompare(b.name));\n result.set(day, { day, groups, single, total: all.length, summary: summarizeRuns(all) });\n }\n return result;\n}\n\n/**\n * A day's single runs as grid pills: a run within `pillMinutes` of the pill before it joins\n * that pill, so no two pills overlap.\n */\nexport function clusterRuns(\n runs: readonly WorkflowRun[],\n timeZone: string,\n pillMinutes: number\n): RunCluster[] {\n const clusters: { minute: number; runs: WorkflowRun[] }[] = [];\n for (const run of runs) {\n const minute = instantToZoned(run.at, timeZone).minutes;\n const current = clusters[clusters.length - 1];\n if (current && minute < current.minute + pillMinutes) current.runs.push(run);\n else clusters.push({ minute, runs: [run] });\n }\n return clusters.map((cluster) => ({ ...cluster, summary: summarizeRuns(cluster.runs) }));\n}\n\n/** One line of a day's list: an event, a run, or a busy schedule's day. */\nexport type DayItem<E> =\n | { kind: 'event'; event: E }\n | { kind: 'run'; run: WorkflowRun }\n | { kind: 'group'; group: RunGroup };\n\n/**\n * A day's list with its runs (the List view, phones' Month): all-day events first, then\n * timed events, runs and busy schedules by time (a busy schedule at its first run), an event\n * before a run at the same time. `startOf` is an event's start, null for an all-day one.\n */\nexport function dayItems<E>(\n events: readonly E[],\n runs: DayRuns | undefined,\n startOf: (event: E) => number | null\n): DayItem<E>[] {\n const allDay: DayItem<E>[] = [];\n const timed: { at: number; rank: number; item: DayItem<E> }[] = [];\n for (const event of events) {\n const start = startOf(event);\n if (start === null) allDay.push({ kind: 'event', event });\n else timed.push({ at: start, rank: 0, item: { kind: 'event', event } });\n }\n for (const group of runs?.groups ?? []) {\n timed.push({ at: group.runs[0]?.at.getTime() ?? 0, rank: 1, item: { kind: 'group', group } });\n }\n for (const run of runs?.single ?? []) {\n timed.push({ at: run.at.getTime(), rank: 1, item: { kind: 'run', run } });\n }\n // Stable: items at the same time keep the order they came in.\n timed.sort((a, b) => a.at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,GAAG,QAAQ;EAAG,MAAM;EAAG,MAAM;GAAE,MAAM;GAAO;EAAI;CAAE,CAAC;CAI1E,OADAoC,EAAM,MAAM,GAAG,MAAM9B,EAAE,KAAKC,EAAE,MAAMD,EAAE,OAAOC,EAAE,IAAI,GAC5C,CAAC,GAAG4B,GAAQ,GAAGC,EAAM,KAAK,MAAUM,EAAM,IAAI,CAAC;AACxD"}
@@ -0,0 +1,32 @@
1
+ import { WorkflowRun } from './runModel';
2
+ import { CalendarRunExecutionRef, CalendarRunJobRef, CalendarRunLinks } from './runTypes';
3
+ export interface RunHrefs {
4
+ /** Where the run's workflow opens; null for no link. */
5
+ workflow: string | null;
6
+ /** Where the run itself opens; null for no link (a run still to come has none). */
7
+ run: string | null;
8
+ }
9
+ export declare const NO_HREFS: RunHrefs;
10
+ /** Whether the host gave any resolver: without one the layer asks for nothing and links nowhere. */
11
+ export declare function hasRunLinks(links: CalendarRunLinks | null | undefined): links is CalendarRunLinks;
12
+ /** A link a resolver returned, when it is one: an app path, or an http(s) address. */
13
+ export declare function safeRunHref(value: unknown): string | null;
14
+ /** Whether a link leaves the app (opens in a new tab). */
15
+ export declare function isExternalHref(href: string): boolean;
16
+ /** The schedule as the resolvers take it. */
17
+ export declare function runJobRef(job: {
18
+ id: string;
19
+ name: string | null;
20
+ timezone: string;
21
+ metadata: Record<string, unknown> | null;
22
+ }): CalendarRunJobRef;
23
+ /**
24
+ * Where a run's links go. `job`: its schedule (null when the schedule no longer exists: no
25
+ * links). `execution`: what a past run answered (null when it isn't known: no run link).
26
+ */
27
+ export declare function resolveRunHrefs(input: {
28
+ links: CalendarRunLinks;
29
+ run: WorkflowRun;
30
+ job: CalendarRunJobRef | null;
31
+ execution: CalendarRunExecutionRef | null;
32
+ }): RunHrefs;
@@ -0,0 +1,50 @@
1
+ import { parseRunSubject as e } from "./runModel.js";
2
+ // src/v2/runs/runLinks.ts
3
+ var t = {
4
+ workflow: null,
5
+ run: null
6
+ };
7
+ function n(e) {
8
+ return !!(e?.resolveSubjectHref || e?.resolveExecutionHref);
9
+ }
10
+ function r(e) {
11
+ if (typeof e != "string") return null;
12
+ let t = e.trim();
13
+ if (t.startsWith("/")) return t.startsWith("//") ? null : t;
14
+ try {
15
+ let e = new URL(t);
16
+ return e.protocol === "https:" || e.protocol === "http:" ? e.href : null;
17
+ } catch {
18
+ return null;
19
+ }
20
+ }
21
+ function i(e) {
22
+ return !e.startsWith("/");
23
+ }
24
+ function a(e) {
25
+ try {
26
+ return r(e());
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+ function o(e) {
32
+ return {
33
+ id: e.id,
34
+ name: e.name,
35
+ timezone: e.timezone,
36
+ metadata: e.metadata
37
+ };
38
+ }
39
+ function s(n) {
40
+ let { links: r, run: i, job: o, execution: s } = n;
41
+ if (!o) return t;
42
+ let c = e(o.metadata?.subject) ?? i.subject, l = r.resolveSubjectHref, u = r.resolveExecutionHref;
43
+ return {
44
+ workflow: c && l ? a(() => l(c, o)) : null,
45
+ run: s && i.execution && u ? a(() => u(s, c, o)) : null
46
+ };
47
+ }
48
+ export { t as NO_HREFS, n as hasRunLinks, i as isExternalHref, s as resolveRunHrefs, o as runJobRef, r as safeRunHref };
49
+
50
+ //# sourceMappingURL=runLinks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runLinks.js","names":["NO_HREFS","hasRunLinks","links","safeRunHref","value","href","url","isExternalHref","attempt","resolve","runJobRef","job","resolveRunHrefs","input","subject","parseRunSubject","run","resolveSubject","resolveExecution","execution"],"sources":["../../../src/v2/runs/runLinks.ts"],"sourcesContent":["/**\n * A run's links (BOFF-15698 B5): the host's resolvers (`CalendarRunLinks`) turned into where\n * \"Open workflow\" and \"Open run\" go. Pure.\n *\n * - The workflow's link needs the run's schedule and its subject (the schedule's\n * `metadata.subject`, or for an upcoming run the subject its fire carried).\n * - The run's link needs what the run answered (its execution's `output`).\n * - A link is a path in the host app (\"/workflows/runs/…\") or an http(s) address; anything\n * else is no link, and so is a resolver that throws: a link that can't work is never shown.\n */\nimport { parseRunSubject, type WorkflowRun } from './runModel';\nimport type {\n CalendarRunExecutionRef,\n CalendarRunJobRef,\n CalendarRunLinks,\n CalendarRunSubject,\n} from './runTypes';\n\nexport interface RunHrefs {\n /** Where the run's workflow opens; null for no link. */\n workflow: string | null;\n /** Where the run itself opens; null for no link (a run still to come has none). */\n run: string | null;\n}\n\nexport const NO_HREFS: RunHrefs = { workflow: null, run: null };\n\n/** Whether the host gave any resolver: without one the layer asks for nothing and links nowhere. */\nexport function hasRunLinks(links: CalendarRunLinks | null | undefined): links is CalendarRunLinks {\n return Boolean(links?.resolveSubjectHref || links?.resolveExecutionHref);\n}\n\n/** A link a resolver returned, when it is one: an app path, or an http(s) address. */\nexport function safeRunHref(value: unknown): string | null {\n if (typeof value !== 'string') return null;\n const href = value.trim();\n if (href.startsWith('/')) return href.startsWith('//') ? null : href;\n try {\n const url = new URL(href);\n return url.protocol === 'https:' || url.protocol === 'http:' ? url.href : null;\n } catch {\n return null;\n }\n}\n\n/** Whether a link leaves the app (opens in a new tab). */\nexport function isExternalHref(href: string): boolean {\n return !href.startsWith('/');\n}\n\nfunction attempt(resolve: () => string | null | undefined): string | null {\n try {\n return safeRunHref(resolve());\n } catch {\n // A host resolver that throws is a link that can't work: none is shown.\n return null;\n }\n}\n\n/** The schedule as the resolvers take it. */\nexport function runJobRef(job: {\n id: string;\n name: string | null;\n timezone: string;\n metadata: Record<string, unknown> | null;\n}): CalendarRunJobRef {\n return { id: job.id, name: job.name, timezone: job.timezone, metadata: job.metadata };\n}\n\n/**\n * Where a run's links go. `job`: its schedule (null when the schedule no longer exists: no\n * links). `execution`: what a past run answered (null when it isn't known: no run link).\n */\nexport function resolveRunHrefs(input: {\n links: CalendarRunLinks;\n run: WorkflowRun;\n job: CalendarRunJobRef | null;\n execution: CalendarRunExecutionRef | null;\n}): RunHrefs {\n const { links, run, job, execution } = input;\n if (!job) return NO_HREFS;\n const subject: CalendarRunSubject | null = parseRunSubject(job.metadata?.subject) ?? run.subject;\n const resolveSubject = links.resolveSubjectHref;\n const resolveExecution = links.resolveExecutionHref;\n return {\n workflow: subject && resolveSubject ? attempt(() => resolveSubject(subject, job)) : null,\n run:\n execution && run.execution && resolveExecution\n ? attempt(() => resolveExecution(execution, subject, job))\n : null,\n };\n}\n"],"mappings":";;AAyBA,IAAaA,IAAqB;CAAE,UAAU;CAAM,KAAK;AAAK;AAG9D,SAAgBC,EAAY,GAAuE;CACjG,OAAO,GAAQC,GAAO,sBAAsBA,GAAO;AACrD;AAGA,SAAgBC,EAAY,GAA+B;CACzD,IAAI,OAAOC,KAAU,UAAU,OAAO;CACtC,IAAMC,IAAOD,EAAM,KAAK;CACxB,IAAIC,EAAK,WAAW,GAAG,GAAG,OAAOA,EAAK,WAAW,IAAI,IAAI,OAAOA;CAChE,IAAI;EACF,IAAMC,IAAM,IAAI,IAAID,CAAI;EACxB,OAAOC,EAAI,aAAa,YAAYA,EAAI,aAAa,UAAUA,EAAI,OAAO;CAC5E,QAAQ;EACN,OAAO;CACT;AACF;AAGA,SAAgBC,EAAe,GAAuB;CACpD,OAAO,CAACF,EAAK,WAAW,GAAG;AAC7B;AAEA,SAASG,EAAQ,GAAyD;CACxE,IAAI;EACF,OAAOL,EAAYM,EAAQ,CAAC;CAC9B,QAAQ;EAEN,OAAO;CACT;AACF;AAGA,SAAgBC,EAAU,GAKJ;CACpB,OAAO;EAAE,IAAIC,EAAI;EAAI,MAAMA,EAAI;EAAM,UAAUA,EAAI;EAAU,UAAUA,EAAI;CAAS;AACtF;AAMA,SAAgBC,EAAgB,GAKnB;CACX,IAAM,EAAE,UAAO,QAAK,QAAK,iBAAcC;CACvC,IAAI,CAACF,GAAK,OAAOX;CACjB,IAAMc,IAAqCC,EAAgBJ,EAAI,UAAU,OAAO,KAAKK,EAAI,SACnFC,IAAiBf,EAAM,oBACvBgB,IAAmBhB,EAAM;CAC/B,OAAO;EACL,UAAUY,KAAWG,IAAiBT,QAAcS,EAAeH,GAASH,CAAG,CAAC,IAAI;EACpF,KACEQ,KAAaH,EAAI,aAAaE,IAC1BV,QAAcU,EAAiBC,GAAWL,GAASH,CAAG,CAAC,IACvD;CACR;AACF"}
@@ -0,0 +1,97 @@
1
+ import { DateValue } from '@burdenoff/fe-libs/ui';
2
+ import { CalendarV2JobExecutionsQuery, CalendarV2ScheduleOccurrencesQuery } from '../../generated/wspace-operations';
3
+ import { CalendarRunJobStatus, CalendarRunSubject } from './runTypes';
4
+ export type RawRunExecution = CalendarV2JobExecutionsQuery['workspaceJobExecutions']['executions'][number];
5
+ export type RawRunOccurrence = CalendarV2ScheduleOccurrencesQuery['scheduleOccurrences']['occurrences'][number];
6
+ /** The subject kind wspace-workflow-svc stamps on a workflow's schedule. */
7
+ export declare const WORKFLOW_SUBJECT_KIND = "workflow";
8
+ /**
9
+ * How a run went, in the Schedules screen's words, or that it is still to come:
10
+ * - `retrying`: it failed and the scheduler tries again;
11
+ * - `ended`: it stopped without succeeding or failing (cancelled before it ran);
12
+ * - `overdue`: planned before now and not run yet.
13
+ */
14
+ export type RunStatus = 'succeeded' | 'failed' | 'retrying' | 'running' | 'ended' | 'overdue' | 'scheduled';
15
+ /** What a past run did. */
16
+ export interface RunExecution {
17
+ id: string;
18
+ status: CalendarRunJobStatus;
19
+ success: boolean;
20
+ startedAt: Date;
21
+ completedAt: Date | null;
22
+ /** How long the run took, in milliseconds; null while it runs. */
23
+ durationMs: number | null;
24
+ errorMessage: string | null;
25
+ /** 0 for the first try, 1 for the first retry, … */
26
+ attempt: number;
27
+ /** Someone ran it by hand ("Run now"), outside its schedule. */
28
+ manual: boolean;
29
+ /** It made up for a fire the scheduler missed. */
30
+ catchUp: boolean;
31
+ }
32
+ export interface WorkflowRun {
33
+ /** One per fire: `<schedule>|<fire time>`, or `run:<execution>` for a run without one. */
34
+ key: string;
35
+ scheduledJobId: string;
36
+ /** The workflow's name. */
37
+ name: string;
38
+ workflowKey: string | null;
39
+ /** Where it sits on the calendar. */
40
+ at: Date;
41
+ status: RunStatus;
42
+ /** The fire it stands for; null for a run the scheduler didn't stamp with one. */
43
+ fireAt: Date | null;
44
+ /** What happened, for a run that has started; null for one still to come. */
45
+ execution: RunExecution | null;
46
+ /** An upcoming run's schedule subject (`metadata.subject`); null for past runs. */
47
+ subject: CalendarRunSubject | null;
48
+ /** An upcoming run's schedule time zone. */
49
+ timeZone: string | null;
50
+ }
51
+ /** The scheduler's job status, as the host's resolvers take it; null for a value it doesn't know. */
52
+ export declare function runJobStatus(value: unknown): CalendarRunJobStatus | null;
53
+ /**
54
+ * A job's `metadata.subject` as the host's resolvers take it: a kind and an id, its label (the
55
+ * id when it has none), and its product and details when it carries them. Null when it isn't
56
+ * one.
57
+ */
58
+ export declare function parseRunSubject(value: unknown): CalendarRunSubject | null;
59
+ /** How a past run went: the Schedules screen's rule (a failed run tried again is "retrying"). */
60
+ export declare function pastRunStatus(row: Pick<RawRunExecution, 'status' | 'success' | 'willRetry' | 'completedAt'>): RunStatus;
61
+ /**
62
+ * Past runs of workflow schedules, one per fire (the latest attempt of a retried one). Rows of
63
+ * other jobs, and rows whose start doesn't parse, are left out.
64
+ */
65
+ export declare function pastRuns(rows: readonly RawRunExecution[]): WorkflowRun[];
66
+ /**
67
+ * Upcoming runs of workflow schedules from their planned fires: overdue when planned before
68
+ * `now`. A fire listed twice (pages that meet at an instant) is kept once.
69
+ */
70
+ export declare function upcomingRuns(occurrences: readonly RawRunOccurrence[], now: Date): WorkflowRun[];
71
+ /**
72
+ * The runs in `[from, to)`, in time order: the past runs, and the upcoming ones whose fire
73
+ * hasn't run. A past run whose place falls outside the range but which started in it sits at
74
+ * its start.
75
+ */
76
+ export declare function mergeRuns(past: readonly WorkflowRun[], upcoming: readonly WorkflowRun[], range: {
77
+ from: Date;
78
+ to: Date;
79
+ }): WorkflowRun[];
80
+ /** The runs of whole days only, and from which days runs were left out. */
81
+ export interface WholeDays {
82
+ runs: WorkflowRun[];
83
+ /** Past runs before this day aren't shown; null when none were left out. */
84
+ pastFrom: DateValue | null;
85
+ /** Upcoming runs from this day on aren't shown; null when none were left out. */
86
+ upcomingUntil: DateValue | null;
87
+ }
88
+ /**
89
+ * Never a silently partial day: when the past runs stop at `pastCutoff` (the oldest start
90
+ * loaded), the past runs of its day and the days before are left out; when the upcoming ones
91
+ * stop at `upcomingCutoff` (the last fire loaded), the upcoming runs of its day and the days
92
+ * after are. Each day shown then has all of its runs, and the layer names the days without.
93
+ */
94
+ export declare function wholeDaysOnly(runs: readonly WorkflowRun[], cutoffs: {
95
+ pastCutoff: Date | null;
96
+ upcomingCutoff: Date | null;
97
+ }, timeZone: string): WholeDays;