@remit/web-client 0.0.327 → 0.0.329

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 (148) hide show
  1. package/dist/src/components/calendar/CalendarEventEditor.d.ts +6 -0
  2. package/dist/src/components/calendar/CalendarEventEditor.js +321 -0
  3. package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
  4. package/dist/src/components/calendar/CalendarEventPopup.js +133 -0
  5. package/dist/src/components/calendar/CalendarLoadFailed.d.ts +8 -0
  6. package/dist/src/components/calendar/CalendarLoadFailed.js +11 -0
  7. package/dist/src/components/calendar/CalendarNavPane.d.ts +11 -0
  8. package/dist/src/components/calendar/CalendarNavPane.js +50 -0
  9. package/dist/src/components/calendar/CalendarQuickCreate.d.ts +22 -0
  10. package/dist/src/components/calendar/CalendarQuickCreate.js +131 -0
  11. package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
  12. package/dist/src/components/calendar/CalendarScreen.js +145 -0
  13. package/dist/src/components/calendar/CalendarSession.d.ts +21 -0
  14. package/dist/src/components/calendar/CalendarSession.js +12 -0
  15. package/dist/src/components/calendar/ChangeCalendarSuggestion.js +39 -5
  16. package/dist/src/components/calendar/EventMoves.d.ts +17 -0
  17. package/dist/src/components/calendar/EventMoves.js +103 -0
  18. package/dist/src/components/calendar/calendar-story-fixtures.js +8 -2
  19. package/dist/src/components/calendar/calendar-story-server.d.ts +2 -5
  20. package/dist/src/components/calendar/calendar-story-server.js +5 -6
  21. package/dist/src/components/layout/AppFrame.d.ts +11 -0
  22. package/dist/src/components/layout/AppFrame.js +16 -0
  23. package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
  24. package/dist/src/components/settings/AccountFormPanel.js +1 -1
  25. package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
  26. package/dist/src/components/ui/SignedOutOverlay.js +29 -0
  27. package/dist/src/hooks/calendar/draft-session.d.ts +77 -0
  28. package/dist/src/hooks/calendar/draft-session.js +109 -0
  29. package/dist/src/hooks/calendar/index.d.ts +2 -1
  30. package/dist/src/hooks/calendar/index.js +1 -0
  31. package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
  32. package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
  33. package/dist/src/hooks/calendar/useCalendarWrites.d.ts +11 -1
  34. package/dist/src/hooks/calendar/useCalendarWrites.js +7 -2
  35. package/dist/src/hooks/calendar/useCalendars.d.ts +1 -0
  36. package/dist/src/hooks/calendar/useCalendars.js +5 -2
  37. package/dist/src/hooks/calendar/useDraftSession.d.ts +32 -0
  38. package/dist/src/hooks/calendar/useDraftSession.js +106 -0
  39. package/dist/src/hooks/calendar/useMoveEvent.d.ts +4 -0
  40. package/dist/src/hooks/calendar/useMoveEvent.js +61 -0
  41. package/dist/src/hooks/use-system-update.js +3 -5
  42. package/dist/src/hooks/useCalendarData.d.ts +2 -0
  43. package/dist/src/hooks/useCalendarData.js +6 -1
  44. package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
  45. package/dist/src/hooks/useCalendarSidePane.js +30 -0
  46. package/dist/src/hooks/useRefreshControl.js +4 -8
  47. package/dist/src/hooks/useStaleAccountSync.js +4 -4
  48. package/dist/src/hooks/useWarningsAttention.js +1 -3
  49. package/dist/src/lib/calendar-route.d.ts +8 -6
  50. package/dist/src/lib/calendar-route.js +18 -2
  51. package/dist/src/lib/calendar-side-pane-pref.d.ts +14 -0
  52. package/dist/src/lib/calendar-side-pane-pref.js +27 -0
  53. package/dist/src/lib/error-classifier.d.ts +5 -30
  54. package/dist/src/lib/error-classifier.js +7 -10
  55. package/dist/src/lib/escalate.d.ts +6 -0
  56. package/dist/src/lib/escalate.js +16 -0
  57. package/dist/src/lib/intelligence-pref.js +3 -2
  58. package/dist/src/lib/mail-search.d.ts +32 -74
  59. package/dist/src/lib/mail-search.js +11 -0
  60. package/dist/src/lib/new-event-range.d.ts +26 -0
  61. package/dist/src/lib/new-event-range.js +69 -0
  62. package/dist/src/lib/query-error-handler.d.ts +2 -6
  63. package/dist/src/lib/query-error-handler.js +5 -14
  64. package/dist/src/lib/signed-out.d.ts +13 -0
  65. package/dist/src/lib/signed-out.js +28 -0
  66. package/dist/src/routeTree.gen.d.ts +620 -821
  67. package/dist/src/routeTree.gen.js +25 -1
  68. package/dist/src/routes/__root.js +8 -2
  69. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.d.ts +5 -0
  70. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.js +11 -0
  71. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.d.ts +5 -0
  72. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.js +12 -0
  73. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.d.ts +4 -12
  74. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.js +4 -13
  75. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.d.ts +5 -0
  76. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.js +14 -0
  77. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.d.ts +4 -12
  78. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.js +4 -4
  79. package/dist/src/routes/calendar/$view.$date/$calendarObjectId.d.ts +4 -12
  80. package/dist/src/routes/calendar/$view.$date/index.d.ts +4 -17
  81. package/dist/src/routes/calendar/$view.$date/index.js +3 -10
  82. package/dist/src/routes/calendar/$view.$date/new.d.ts +8 -12
  83. package/dist/src/routes/calendar/$view.$date/new.js +8 -13
  84. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.d.ts +4 -12
  85. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.js +2 -2
  86. package/dist/src/routes/calendar/$view.$date.d.ts +4 -12
  87. package/dist/src/routes/calendar/$view.$date.js +14 -50
  88. package/dist/src/routes/calendar/index.d.ts +4 -12
  89. package/dist/src/routes/calendar/index.js +2 -1
  90. package/dist/src/routes/calendar.d.ts +4 -9
  91. package/dist/src/routes/calendar.js +10 -35
  92. package/dist/src/routes/mail/$mailboxId/$threadId/$messageId/$mode.{-$outboxMessageId}.d.ts +13 -24
  93. package/dist/src/routes/mail/$mailboxId/$threadId/$messageId.d.ts +12 -16
  94. package/dist/src/routes/mail/$mailboxId/$threadId/index.d.ts +12 -16
  95. package/dist/src/routes/mail/$mailboxId/$threadId.d.ts +12 -16
  96. package/dist/src/routes/mail/$mailboxId/compose.{-$outboxMessageId}.d.ts +12 -16
  97. package/dist/src/routes/mail/$mailboxId/index.d.ts +12 -16
  98. package/dist/src/routes/mail/$mailboxId.d.ts +12 -16
  99. package/dist/src/routes/mail/brief/$threadId/$messageId/$mode.{-$outboxMessageId}.d.ts +13 -24
  100. package/dist/src/routes/mail/brief/$threadId/$messageId.d.ts +12 -16
  101. package/dist/src/routes/mail/brief/$threadId/index.d.ts +12 -16
  102. package/dist/src/routes/mail/brief/$threadId.d.ts +12 -16
  103. package/dist/src/routes/mail/brief/compose.{-$outboxMessageId}.d.ts +12 -16
  104. package/dist/src/routes/mail/brief/index.d.ts +12 -16
  105. package/dist/src/routes/mail/brief.d.ts +12 -16
  106. package/dist/src/routes/mail/flagged/$threadId/$messageId/$mode.{-$outboxMessageId}.d.ts +13 -24
  107. package/dist/src/routes/mail/flagged/$threadId/$messageId.d.ts +12 -16
  108. package/dist/src/routes/mail/flagged/$threadId/index.d.ts +12 -16
  109. package/dist/src/routes/mail/flagged/$threadId.d.ts +12 -16
  110. package/dist/src/routes/mail/flagged/compose.{-$outboxMessageId}.d.ts +12 -16
  111. package/dist/src/routes/mail/flagged/index.d.ts +12 -16
  112. package/dist/src/routes/mail/flagged.d.ts +12 -16
  113. package/dist/src/routes/mail/index.d.ts +24 -32
  114. package/dist/src/routes/mail/index.js +7 -2
  115. package/dist/src/routes/mail/outbox/compose.{-$outboxMessageId}.d.ts +12 -16
  116. package/dist/src/routes/mail/outbox/draft/$outboxMessageId.d.ts +12 -16
  117. package/dist/src/routes/mail/outbox/index.d.ts +12 -16
  118. package/dist/src/routes/mail/outbox.d.ts +12 -16
  119. package/dist/src/routes/mail.d.ts +13 -14
  120. package/dist/src/routes/mail.js +8 -15
  121. package/dist/src/routes/settings/accounts.d.ts +1 -17
  122. package/dist/src/routing/app-switch.d.ts +11 -0
  123. package/dist/src/routing/app-switch.js +35 -0
  124. package/dist/src/routing/calendar.d.ts +41 -4
  125. package/dist/src/routing/calendar.js +121 -13
  126. package/dist/src/routing/fragment.d.ts +1 -1
  127. package/dist/src/routing/fragment.js +6 -1
  128. package/dist/src/routing/index.d.ts +3 -2
  129. package/dist/src/routing/index.js +3 -2
  130. package/dist/src/routing/wizard-history.d.ts +10 -4
  131. package/dist/src/routing/wizard-history.js +2 -10
  132. package/package.json +3 -3
  133. package/dist/src/components/calendar/CalendarComposePane.d.ts +0 -49
  134. package/dist/src/components/calendar/CalendarComposePane.js +0 -8
  135. package/dist/src/components/calendar/CalendarComposeSeed.d.ts +0 -7
  136. package/dist/src/components/calendar/CalendarComposeSeed.js +0 -19
  137. package/dist/src/components/calendar/CalendarEventPane.d.ts +0 -48
  138. package/dist/src/components/calendar/CalendarEventPane.js +0 -48
  139. package/dist/src/components/calendar/CalendarShell.d.ts +0 -43
  140. package/dist/src/components/calendar/CalendarShell.js +0 -35
  141. package/dist/src/components/calendar/CalendarViewPlaceholder.d.ts +0 -1
  142. package/dist/src/components/calendar/CalendarViewPlaceholder.js +0 -5
  143. package/dist/src/components/calendar/CalendarWorkspace.d.ts +0 -49
  144. package/dist/src/components/calendar/CalendarWorkspace.js +0 -65
  145. package/dist/src/components/calendar/OpenCalendarEvent.d.ts +0 -20
  146. package/dist/src/components/calendar/OpenCalendarEvent.js +0 -169
  147. package/dist/src/components/calendar/WriteCalendarEvent.d.ts +0 -13
  148. package/dist/src/components/calendar/WriteCalendarEvent.js +0 -59
@@ -2,8 +2,7 @@ import { mailboxOperationsListMailboxesQueryKey, syncOperationsGetSyncStatusOpti
2
2
  import { syncOperationsTriggerSync } from "@remit/api-http-client/sdk.gen.ts";
3
3
  import { useQueryClient } from "@tanstack/react-query";
4
4
  import { useCallback, useEffect, useRef, useState } from "react";
5
- import { shouldEscalate } from "../lib/error-classifier";
6
- import { reportFatalError } from "../lib/fatal-error";
5
+ import { escalate } from "../lib/escalate";
7
6
  import { startHotSyncWindow } from "../lib/hot-sync-window";
8
7
  import { useMailFreshness } from "../lib/mail-freshness";
9
8
  import { useTelemetry } from "../lib/telemetry-context";
@@ -19,13 +18,10 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
19
18
  const messageFor = (error) => error instanceof Error && error.message
20
19
  ? error.message
21
20
  : "Something went wrong";
22
- // The user pulled to refresh and is watching the spinner, so this is theirs to
23
- // be answered: a 401 here escalates over the soft meta rather than resolving
24
- // into a spinner that stops for no stated reason.
21
+ // The user pulled to refresh and is watching the spinner: a 401 raises the
22
+ // signed-out notice rather than a spinner that stops for no stated reason.
25
23
  const escalateIfFatal = (error) => {
26
- if (shouldEscalate(error, { softError: true }, "user")) {
27
- reportFatalError(error);
28
- }
24
+ escalate(error, { softError: true });
29
25
  };
30
26
  /**
31
27
  * `getSyncStatus` for one account, always as a real network read: `staleTime:
@@ -3,8 +3,8 @@ import { syncOperationsTriggerSync } from "@remit/api-http-client/sdk.gen.ts";
3
3
  import { useQueryClient } from "@tanstack/react-query";
4
4
  import pMap from "p-map";
5
5
  import { useEffect, useRef } from "react";
6
- import { shouldEscalate } from "../lib/error-classifier";
7
- import { reportFatalError } from "../lib/fatal-error";
6
+ import { isUnauthenticated, shouldEscalate } from "../lib/error-classifier";
7
+ import { escalate } from "../lib/escalate";
8
8
  import { HOT_POLL_INTERVAL_MS, isHotSyncWindowActive, subscribeHotSyncWindow, } from "../lib/hot-sync-window";
9
9
  import { getRuntimeConfig } from "../runtime-config";
10
10
  /**
@@ -116,8 +116,8 @@ export const __peekStaleAccountSyncGuard = () => triggeredAccountIds;
116
116
  */
117
117
  export const handleBackgroundSyncFailure = (accountId, error) => {
118
118
  triggeredAccountIds.delete(accountId);
119
- if (shouldEscalate(error, { softError: true }, "nobody")) {
120
- reportFatalError(error);
119
+ if (isUnauthenticated(error) || shouldEscalate(error, { softError: true })) {
120
+ escalate(error, { softError: true });
121
121
  return;
122
122
  }
123
123
  console.warn("[remit] background mailbox sync failed", {
@@ -1,11 +1,9 @@
1
1
  import { meOperationsListQuarantineOptions } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
2
2
  import { useQuery } from "@tanstack/react-query";
3
- import { isUnauthenticated, softErrorStatuses } from "../lib/error-classifier";
4
- const WARNINGS_LIST_META = softErrorStatuses(401);
3
+ import { isUnauthenticated } from "../lib/error-classifier";
5
4
  export function useWarningsList() {
6
5
  return useQuery({
7
6
  ...meOperationsListQuarantineOptions(),
8
- meta: WARNINGS_LIST_META,
9
7
  });
10
8
  }
11
9
  export const WARNINGS_ATTENTION = {
@@ -84,10 +84,12 @@ export declare function readCalendarIds(value: unknown): string[];
84
84
  * rather than a fact about the view, so it belongs to no tier of the address.
85
85
  */
86
86
  export declare const calendarSearchSchema: z.ZodObject<{
87
- calendarId: z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], unknown>, string[] | undefined, unknown>;
88
- }, "strip", z.ZodTypeAny, {
89
- calendarId?: string[] | undefined;
90
- }, {
91
- calendarId?: unknown;
92
- }>;
87
+ calendarId: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string[], unknown>>, z.ZodTransform<string[] | undefined, string[]>>>;
88
+ }, z.core.$strip>;
93
89
  export type CalendarSearch = z.infer<typeof calendarSearchSchema>;
90
+ /**
91
+ * The view a screen draws for the view the address names. A phone has room
92
+ * for one day and one month, so a week draws its day and a year its month;
93
+ * the address keeps what it said.
94
+ */
95
+ export declare function shownCalendarView(view: CalendarViewId, isPhone: boolean): CalendarViewId;
@@ -140,6 +140,22 @@ export function readCalendarIds(value) {
140
140
  */
141
141
  export const calendarSearchSchema = z.object({
142
142
  calendarId: z
143
- .preprocess(readCalendarIds, z.array(calendarIdSchema))
144
- .transform((ids) => (ids.length === 0 ? undefined : ids)),
143
+ .unknown()
144
+ .transform(readCalendarIds)
145
+ .transform((ids) => (ids.length === 0 ? undefined : ids))
146
+ .optional(),
145
147
  });
148
+ /**
149
+ * The view a screen draws for the view the address names. A phone has room
150
+ * for one day and one month, so a week draws its day and a year its month;
151
+ * the address keeps what it said.
152
+ */
153
+ export function shownCalendarView(view, isPhone) {
154
+ if (!isPhone)
155
+ return view;
156
+ if (view === "week")
157
+ return "day";
158
+ if (view === "year")
159
+ return "month";
160
+ return view;
161
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Whether the calendar's side pane is up: the address decides, and this
3
+ * device's last choice speaks where the address is silent about it, the way
4
+ * `resolveRailOpen` seeds the intelligence rail.
5
+ */
6
+ import type { PanelFragment } from "../routing";
7
+ export declare const SIDE_PANE_PREF_KEY = "remit:calendar-side-pane";
8
+ export declare function readSidePanePref(): boolean;
9
+ export declare function writeSidePanePref(open: boolean): void;
10
+ /**
11
+ * The rail is mail's pane and says nothing about this one, so an address
12
+ * naming only the rail is silent here.
13
+ */
14
+ export declare function resolveSidePaneOpen(panels: readonly PanelFragment[], prefersOpen: boolean): boolean;
@@ -0,0 +1,27 @@
1
+ export const SIDE_PANE_PREF_KEY = "remit:calendar-side-pane";
2
+ export function readSidePanePref() {
3
+ try {
4
+ return localStorage.getItem(SIDE_PANE_PREF_KEY) !== "closed";
5
+ }
6
+ catch {
7
+ return true;
8
+ }
9
+ }
10
+ export function writeSidePanePref(open) {
11
+ try {
12
+ localStorage.setItem(SIDE_PANE_PREF_KEY, open ? "open" : "closed");
13
+ }
14
+ catch {
15
+ // Storage unavailable — the address still holds the choice.
16
+ }
17
+ }
18
+ /**
19
+ * The rail is mail's pane and says nothing about this one, so an address
20
+ * naming only the rail is silent here.
21
+ */
22
+ export function resolveSidePaneOpen(panels, prefersOpen) {
23
+ if (panels.includes("sidebar"))
24
+ return true;
25
+ const speaks = panels.some((panel) => panel !== "intelligence");
26
+ return !speaks && prefersOpen;
27
+ }
@@ -58,28 +58,6 @@ export declare const isAlwaysFatal: (error: unknown) => boolean;
58
58
  * stands. A 401 is the user signed out from under whatever they were doing.
59
59
  */
60
60
  export declare const isUnauthenticated: (error: unknown) => boolean;
61
- /**
62
- * Who is waiting on this request's answer. One decision turns on it, and only
63
- * one: whether a 401 overrides the call site's own `meta.softError`.
64
- *
65
- * "user" — the user did something and the app owes them the outcome. Every
66
- * mutation is this, the debounced autosave included: it carries text that is on
67
- * screen, and if it is refused for want of a session then so is the send behind
68
- * it. No banner a call site can render signs anyone back in, so this is the one
69
- * 4xx a call site may not keep to itself.
70
- *
71
- * "nobody" — a poll, a prefetch, a best-effort background trigger, an inline
72
- * sub-resource with an error surface of its own. A 401 there is not news the
73
- * app may take the whole screen for, and `meta.softError` decides as usual.
74
- *
75
- * Reads are "nobody" as a class, which is not the same as saying no read
76
- * matters: a read the screen is actually waiting on has no `meta.softError` on
77
- * it, so rule 1 escalates it anyway. The only reads this spares are the ones
78
- * that already declared they own their failures — the update poll mounted at
79
- * the app root, the message body with its own inline banner. Escalating those
80
- * put the full-screen page over every screen in the app.
81
- */
82
- export type Awaiting = "user" | "nobody";
83
61
  /**
84
62
  * The single fail-fast decision: should this error escalate to the full-screen
85
63
  * fatal overlay? Default is YES — a non-2xx must never silently vanish.
@@ -94,11 +72,8 @@ export type Awaiting = "user" | "nobody";
94
72
  * the operation working, and that call site renders the wait itself.
95
73
  * 3. A client-side exception ALWAYS escalates, on the same terms. It is our
96
74
  * bug; there is nothing for the user to retry and nothing to dismiss.
97
- * 4. A 401 on a request the user is waiting on ALWAYS escalates, on the same
98
- * terms. Dismissing it leaves them signed out with no way back in, and a
99
- * send that keeps failing becomes a loop with no exit — `BetterAuthShell`
100
- * re-gates only when `useSession()` revalidates, which a banner never makes
101
- * happen. See `Awaiting` for what nobody waiting on it means.
75
+ * 4. A 401 NEVER escalates here: the session is gone, and the signed-out
76
+ * notice (`lib/escalate.ts`) owns it on every screen.
102
77
  * 5. The ONLY soft (do-NOT-escalate) exemptions:
103
78
  * a. aborts / cancellations — never a failure;
104
79
  * b. network/offline errors — environmental, recovered by React Query's
@@ -108,12 +83,12 @@ export type Awaiting = "user" | "nobody";
108
83
  * (e.g. a 404 empty state, a 4xx "Reconnect" banner) — or, where it owns
109
84
  * one status and not the rest, `meta.softErrorStatuses`.
110
85
  */
111
- export declare const shouldEscalate: (error: unknown, meta?: Record<string, unknown>, awaiting?: Awaiting) => boolean;
86
+ export declare const shouldEscalate: (error: unknown, meta?: Record<string, unknown>) => boolean;
112
87
  /**
113
88
  * The meta a call site sets to keep its own non-5xx failures off the
114
89
  * full-screen fatal page, because it renders them itself — a banner, a retry,
115
- * an empty state. Rules 2, 3 and 4 above still win: a 5xx, a client-side
116
- * exception, and a 401 on something the user is waiting on, escalate regardless.
90
+ * an empty state. Rules 2 and 3 above still win: a 5xx and a client-side
91
+ * exception escalate regardless, and a 401 goes to the signed-out notice.
117
92
  *
118
93
  * Two classes of call site must always carry it. One is a request the user
119
94
  * never asked for and is not waiting on — a debounced autosave, a
@@ -142,11 +142,8 @@ const isDesignedRestartGap = (error, meta) => {
142
142
  * the operation working, and that call site renders the wait itself.
143
143
  * 3. A client-side exception ALWAYS escalates, on the same terms. It is our
144
144
  * bug; there is nothing for the user to retry and nothing to dismiss.
145
- * 4. A 401 on a request the user is waiting on ALWAYS escalates, on the same
146
- * terms. Dismissing it leaves them signed out with no way back in, and a
147
- * send that keeps failing becomes a loop with no exit — `BetterAuthShell`
148
- * re-gates only when `useSession()` revalidates, which a banner never makes
149
- * happen. See `Awaiting` for what nobody waiting on it means.
145
+ * 4. A 401 NEVER escalates here: the session is gone, and the signed-out
146
+ * notice (`lib/escalate.ts`) owns it on every screen.
150
147
  * 5. The ONLY soft (do-NOT-escalate) exemptions:
151
148
  * a. aborts / cancellations — never a failure;
152
149
  * b. network/offline errors — environmental, recovered by React Query's
@@ -156,15 +153,15 @@ const isDesignedRestartGap = (error, meta) => {
156
153
  * (e.g. a 404 empty state, a 4xx "Reconnect" banner) — or, where it owns
157
154
  * one status and not the rest, `meta.softErrorStatuses`.
158
155
  */
159
- export const shouldEscalate = (error, meta, awaiting = "nobody") => {
156
+ export const shouldEscalate = (error, meta) => {
160
157
  if (isServerError(error))
161
158
  return !isDesignedRestartGap(error, meta);
162
159
  if (isAbortError(error))
163
160
  return false;
164
161
  if (isNetworkError(error))
165
162
  return false;
166
- if (awaiting === "user" && isUnauthenticated(error))
167
- return true;
163
+ if (isUnauthenticated(error))
164
+ return false;
168
165
  if (isAlwaysFatal(error))
169
166
  return true;
170
167
  if (isSoftErrorMeta(error, meta))
@@ -174,8 +171,8 @@ export const shouldEscalate = (error, meta, awaiting = "nobody") => {
174
171
  /**
175
172
  * The meta a call site sets to keep its own non-5xx failures off the
176
173
  * full-screen fatal page, because it renders them itself — a banner, a retry,
177
- * an empty state. Rules 2, 3 and 4 above still win: a 5xx, a client-side
178
- * exception, and a 401 on something the user is waiting on, escalate regardless.
174
+ * an empty state. Rules 2 and 3 above still win: a 5xx and a client-side
175
+ * exception escalate regardless, and a 401 goes to the signed-out notice.
179
176
  *
180
177
  * Two classes of call site must always carry it. One is a request the user
181
178
  * never asked for and is not waiting on — a debounced autosave, a
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Where a failed request goes when its call site does not answer it: a 401 to
3
+ * the signed-out notice, whatever the call site declared, and anything else
4
+ * the fail-fast contract escalates to the fatal page.
5
+ */
6
+ export declare const escalate: (error: unknown, meta?: Record<string, unknown>) => void;
@@ -0,0 +1,16 @@
1
+ import { isUnauthenticated, shouldEscalate } from "./error-classifier";
2
+ import { reportFatalError } from "./fatal-error";
3
+ import { reportSignedOut } from "./signed-out";
4
+ /**
5
+ * Where a failed request goes when its call site does not answer it: a 401 to
6
+ * the signed-out notice, whatever the call site declared, and anything else
7
+ * the fail-fast contract escalates to the fatal page.
8
+ */
9
+ export const escalate = (error, meta) => {
10
+ if (isUnauthenticated(error)) {
11
+ reportSignedOut();
12
+ return;
13
+ }
14
+ if (shouldEscalate(error, meta))
15
+ reportFatalError(error);
16
+ };
@@ -35,7 +35,8 @@ export function writeIntelligencePref(open) {
35
35
  export function resolveRailOpen({ panels, prefersOpen, isDesktop, hasThread, raisedFor, openMessage, }) {
36
36
  if (raisedFor !== null && raisedFor === openMessage)
37
37
  return true;
38
- if (panels.length > 0)
39
- return panels.includes("intelligence");
38
+ const named = panels.filter((panel) => panel !== "sidebar");
39
+ if (named.length > 0)
40
+ return named.includes("intelligence");
40
41
  return isDesktop && hasThread && prefersOpen;
41
42
  }
@@ -16,19 +16,11 @@ import { z } from "zod";
16
16
  */
17
17
  export declare const briefSearchSchema: z.ZodObject<{
18
18
  q: z.ZodOptional<z.ZodString>;
19
- }, "strip", z.ZodTypeAny, {
20
- q?: string | undefined;
21
- }, {
22
- q?: string | undefined;
23
- }>;
19
+ }, z.core.$strip>;
24
20
  /** The same, for `/mail/flagged/<thread>/<message>`. */
25
21
  export declare const flaggedSearchSchema: z.ZodObject<{
26
22
  q: z.ZodOptional<z.ZodString>;
27
- }, "strip", z.ZodTypeAny, {
28
- q?: string | undefined;
29
- }, {
30
- q?: string | undefined;
31
- }>;
23
+ }, z.core.$strip>;
32
24
  /**
33
25
  * The outbox's open message is a path segment
34
26
  * (`/mail/outbox/draft/<outboxMessageId>`), so the query carries nothing but
@@ -36,11 +28,7 @@ export declare const flaggedSearchSchema: z.ZodObject<{
36
28
  */
37
29
  export declare const outboxSearchSchema: z.ZodObject<{
38
30
  q: z.ZodOptional<z.ZodString>;
39
- }, "strip", z.ZodTypeAny, {
40
- q?: string | undefined;
41
- }, {
42
- q?: string | undefined;
43
- }>;
31
+ }, z.core.$strip>;
44
32
  /**
45
33
  * A folder's open thread and the message inside it are path segments
46
34
  * (`/mail/<mailbox>/<thread>/<message>`), so the query carries nothing but the
@@ -48,94 +36,64 @@ export declare const outboxSearchSchema: z.ZodObject<{
48
36
  */
49
37
  export declare const mailboxSearchSchema: z.ZodObject<{
50
38
  q: z.ZodOptional<z.ZodString>;
51
- }, "strip", z.ZodTypeAny, {
52
- q?: string | undefined;
53
- }, {
54
- q?: string | undefined;
55
- }>;
39
+ }, z.core.$strip>;
56
40
  /**
57
41
  * `/mail` itself only redirects to the brief, so it accepts what the brief
58
42
  * accepts and hands it straight on.
59
43
  */
60
44
  export declare const mailIndexSearchSchema: z.ZodObject<{
61
45
  q: z.ZodOptional<z.ZodString>;
62
- }, "strip", z.ZodTypeAny, {
63
- q?: string | undefined;
64
- }, {
65
- q?: string | undefined;
66
- }>;
46
+ }, z.core.$strip>;
47
+ /**
48
+ * The `/mail` layout's own search: the query, plus the selection wizard's step
49
+ * (#477 clause 1.6) and the affordance that opened it, so a reload lands back on
50
+ * the walk it was in. The router owns history, so the step is a validated
51
+ * search param rather than a raw pushState entry.
52
+ */
53
+ export declare const mailSearchSchema: z.ZodObject<{
54
+ q: z.ZodOptional<z.ZodString>;
55
+ wizard: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
56
+ name: "name";
57
+ match: "match";
58
+ run: "run";
59
+ folder: "folder";
60
+ rule: "rule";
61
+ review: "review";
62
+ properties: "properties";
63
+ }>>>;
64
+ wizardFrom: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"search">>>;
65
+ }, z.core.$strip>;
67
66
  /** Every list's schema, by the path it validates. */
68
67
  export declare const mailListSearchSchemas: {
69
68
  readonly "/mail/brief": z.ZodObject<{
70
69
  q: z.ZodOptional<z.ZodString>;
71
- }, "strip", z.ZodTypeAny, {
72
- q?: string | undefined;
73
- }, {
74
- q?: string | undefined;
75
- }>;
70
+ }, z.core.$strip>;
76
71
  readonly "/mail/flagged": z.ZodObject<{
77
72
  q: z.ZodOptional<z.ZodString>;
78
- }, "strip", z.ZodTypeAny, {
79
- q?: string | undefined;
80
- }, {
81
- q?: string | undefined;
82
- }>;
73
+ }, z.core.$strip>;
83
74
  readonly "/mail/outbox": z.ZodObject<{
84
75
  q: z.ZodOptional<z.ZodString>;
85
- }, "strip", z.ZodTypeAny, {
86
- q?: string | undefined;
87
- }, {
88
- q?: string | undefined;
89
- }>;
76
+ }, z.core.$strip>;
90
77
  readonly "/mail/$mailboxId": z.ZodObject<{
91
78
  q: z.ZodOptional<z.ZodString>;
92
- }, "strip", z.ZodTypeAny, {
93
- q?: string | undefined;
94
- }, {
95
- q?: string | undefined;
96
- }>;
79
+ }, z.core.$strip>;
97
80
  };
98
81
  export declare const composeSeedSearch: z.ZodObject<{
99
82
  body: z.ZodOptional<z.ZodString>;
100
- }, "strip", z.ZodTypeAny, {
101
- body?: string | undefined;
102
- }, {
103
- body?: string | undefined;
104
- }>;
83
+ }, z.core.$strip>;
105
84
  export type ComposeSeed = Required<z.infer<typeof composeSeedSearch>>;
106
85
  export declare const withoutComposeSeed: (prev: Record<string, unknown>) => Record<string, unknown>;
107
86
  export declare const replySearchSchemas: {
108
87
  readonly brief: z.ZodObject<{
109
88
  q: z.ZodOptional<z.ZodString>;
110
- } & {
111
89
  body: z.ZodOptional<z.ZodString>;
112
- }, "strip", z.ZodTypeAny, {
113
- body?: string | undefined;
114
- q?: string | undefined;
115
- }, {
116
- body?: string | undefined;
117
- q?: string | undefined;
118
- }>;
90
+ }, z.core.$strip>;
119
91
  readonly flagged: z.ZodObject<{
120
92
  q: z.ZodOptional<z.ZodString>;
121
- } & {
122
93
  body: z.ZodOptional<z.ZodString>;
123
- }, "strip", z.ZodTypeAny, {
124
- body?: string | undefined;
125
- q?: string | undefined;
126
- }, {
127
- body?: string | undefined;
128
- q?: string | undefined;
129
- }>;
94
+ }, z.core.$strip>;
130
95
  readonly mailbox: z.ZodObject<{
131
96
  q: z.ZodOptional<z.ZodString>;
132
- } & {
133
97
  body: z.ZodOptional<z.ZodString>;
134
- }, "strip", z.ZodTypeAny, {
135
- body?: string | undefined;
136
- q?: string | undefined;
137
- }, {
138
- body?: string | undefined;
139
- q?: string | undefined;
140
- }>;
98
+ }, z.core.$strip>;
141
99
  };
@@ -8,6 +8,7 @@
8
8
  * is one place for it to be right.
9
9
  */
10
10
  import { z } from "zod";
11
+ import { wizardEntryValue, wizardStepValue } from "../routing/wizard-history";
11
12
  /** What every list carries, whatever else it carries. */
12
13
  const listSearch = z.object({ q: z.string().optional() });
13
14
  /**
@@ -36,6 +37,16 @@ export const mailboxSearchSchema = listSearch.extend({});
36
37
  * accepts and hands it straight on.
37
38
  */
38
39
  export const mailIndexSearchSchema = briefSearchSchema;
40
+ /**
41
+ * The `/mail` layout's own search: the query, plus the selection wizard's step
42
+ * (#477 clause 1.6) and the affordance that opened it, so a reload lands back on
43
+ * the walk it was in. The router owns history, so the step is a validated
44
+ * search param rather than a raw pushState entry.
45
+ */
46
+ export const mailSearchSchema = listSearch.extend({
47
+ wizard: wizardStepValue,
48
+ wizardFrom: wizardEntryValue,
49
+ });
39
50
  /** Every list's schema, by the path it validates. */
40
51
  export const mailListSearchSchemas = {
41
52
  "/mail/brief": briefSearchSchema,
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The range a new event's sidebar holds, as the `/new` address spells it:
3
+ * `start` and `end` as ISO 8601 with an offset, or civil dates for an all-day
4
+ * range. The address is the only owner of the range (R2), so a reload of the
5
+ * sidebar comes back on it.
6
+ */
7
+ import type { CalendarSlotPick } from "@remit/ui";
8
+ import { z } from "zod";
9
+ export declare const newEventSearchSchema: z.ZodObject<{
10
+ calendarId: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string[], unknown>>, z.ZodTransform<string[] | undefined, string[]>>>;
11
+ start: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
12
+ end: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
13
+ }, z.core.$strip>;
14
+ export type NewEventSearch = z.infer<typeof newEventSearchSchema>;
15
+ /** The 09:00 to 10:00 a sidebar opens on when the address names no range it can read. */
16
+ export declare function defaultRange(date: string): CalendarSlotPick;
17
+ /**
18
+ * The range `start` and `end` name, read on the device's clock. Anything
19
+ * missing, unreadable or backwards falls back to the URL date's working hour.
20
+ */
21
+ export declare function rangeFromSearch(start: string | undefined, end: string | undefined, date: string, clock: string): CalendarSlotPick;
22
+ /** How a range is written back into `start` and `end`. */
23
+ export declare function searchFromRange(range: CalendarSlotPick, clock: string): {
24
+ start: string;
25
+ end: string;
26
+ };
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ import { addDays, isoAtInZone, isoOnClock } from "../hooks/calendar/window";
3
+ import { calendarSearchSchema } from "./calendar-route";
4
+ const instantWithOffset = z.iso.datetime({ offset: true, local: false });
5
+ const civilDate = z.iso.date();
6
+ const bound = z
7
+ .unknown()
8
+ .transform((value) => {
9
+ const read = z.union([instantWithOffset, civilDate]).safeParse(value);
10
+ return read.success ? read.data : undefined;
11
+ })
12
+ .optional();
13
+ export const newEventSearchSchema = calendarSearchSchema.extend({
14
+ start: bound,
15
+ end: bound,
16
+ });
17
+ const isCivil = (value) => civilDate.safeParse(value).success;
18
+ /** The 09:00 to 10:00 a sidebar opens on when the address names no range it can read. */
19
+ export function defaultRange(date) {
20
+ return {
21
+ date,
22
+ endDate: date,
23
+ startTime: "09:00",
24
+ endTime: "10:00",
25
+ allDay: false,
26
+ };
27
+ }
28
+ /**
29
+ * The range `start` and `end` name, read on the device's clock. Anything
30
+ * missing, unreadable or backwards falls back to the URL date's working hour.
31
+ */
32
+ export function rangeFromSearch(start, end, date, clock) {
33
+ if (start === undefined || end === undefined)
34
+ return defaultRange(date);
35
+ if (isCivil(start) && isCivil(end)) {
36
+ const last = addDays(end, -1);
37
+ if (last < start)
38
+ return defaultRange(date);
39
+ return {
40
+ date: start,
41
+ endDate: last,
42
+ startTime: "",
43
+ endTime: "",
44
+ allDay: true,
45
+ };
46
+ }
47
+ if (isCivil(start) || isCivil(end))
48
+ return defaultRange(date);
49
+ if (Date.parse(end) <= Date.parse(start))
50
+ return defaultRange(date);
51
+ const from = isoOnClock(start, clock);
52
+ const to = isoOnClock(end, clock);
53
+ return {
54
+ date: from.slice(0, 10),
55
+ endDate: to.slice(0, 10),
56
+ startTime: from.slice(11, 16),
57
+ endTime: to.slice(11, 16),
58
+ allDay: false,
59
+ };
60
+ }
61
+ /** How a range is written back into `start` and `end`. */
62
+ export function searchFromRange(range, clock) {
63
+ if (range.allDay)
64
+ return { start: range.date, end: addDays(range.endDate, 1) };
65
+ return {
66
+ start: isoAtInZone(range.date, range.startTime, clock),
67
+ end: isoAtInZone(range.endDate, range.endTime, clock),
68
+ };
69
+ }
@@ -7,12 +7,8 @@ import type { Mutation, Query } from "@tanstack/react-query";
7
7
  * statusless network blips, and non-5xx errors a call site opted out of via
8
8
  * `meta.softError` stay soft.
9
9
  *
10
- * The two caches differ on one thing, the `Awaiting` argument. A mutation is
11
- * something the user did and is owed the outcome of, so a 401 there escalates
12
- * over `meta.softError` — no banner signs anyone back in. A query is "nobody" as
13
- * a class: the reads the screen is actually waiting on carry no `meta.softError`
14
- * and escalate on the default anyway, so the only ones this spares are those
15
- * that already declared they own their failures.
10
+ * A 401 from either cache raises the signed-out notice instead, whatever the
11
+ * call site declared (`lib/escalate.ts`).
16
12
  *
17
13
  * This is the v5 equivalent of `defaultOptions.queries.onError` /
18
14
  * `.mutations.onError` — v5 moved the global error hook onto the caches.
@@ -1,5 +1,4 @@
1
- import { shouldEscalate } from "./error-classifier";
2
- import { reportFatalError } from "./fatal-error";
1
+ import { escalate } from "./escalate";
3
2
  /**
4
3
  * Global React Query error sink. Every query and mutation error flows through
5
4
  * here (wired on the `QueryCache`/`MutationCache` in main.tsx). The fail-fast
@@ -8,23 +7,15 @@ import { reportFatalError } from "./fatal-error";
8
7
  * statusless network blips, and non-5xx errors a call site opted out of via
9
8
  * `meta.softError` stay soft.
10
9
  *
11
- * The two caches differ on one thing, the `Awaiting` argument. A mutation is
12
- * something the user did and is owed the outcome of, so a 401 there escalates
13
- * over `meta.softError` — no banner signs anyone back in. A query is "nobody" as
14
- * a class: the reads the screen is actually waiting on carry no `meta.softError`
15
- * and escalate on the default anyway, so the only ones this spares are those
16
- * that already declared they own their failures.
10
+ * A 401 from either cache raises the signed-out notice instead, whatever the
11
+ * call site declared (`lib/escalate.ts`).
17
12
  *
18
13
  * This is the v5 equivalent of `defaultOptions.queries.onError` /
19
14
  * `.mutations.onError` — v5 moved the global error hook onto the caches.
20
15
  */
21
16
  export const handleQueryCacheError = (error, query) => {
22
- if (shouldEscalate(error, query.meta, "nobody")) {
23
- reportFatalError(error);
24
- }
17
+ escalate(error, query.meta);
25
18
  };
26
19
  export const handleMutationCacheError = (error, _variables, _onMutateResult, mutation) => {
27
- if (shouldEscalate(error, mutation.meta, "user")) {
28
- reportFatalError(error);
29
- }
20
+ escalate(error, mutation.meta);
30
21
  };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The one place a 401 goes: the session is no longer one the server accepts,
3
+ * so every screen shows the same signed-out notice instead of rendering empty
4
+ * data or the fatal page. A 403 is a refusal of one resource and stays with
5
+ * the call site that asked for it.
6
+ */
7
+ type SignedOutListener = (signedOut: boolean) => void;
8
+ export declare const reportSignedOut: () => void;
9
+ export declare const isSignedOut: () => boolean;
10
+ export declare const subscribeSignedOut: (listener: SignedOutListener) => (() => void);
11
+ /** Forgets a reported sign-out, once the reader is signing back in. */
12
+ export declare const resetSignedOut: () => void;
13
+ export {};