@remit/web-client 0.0.328 → 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.
- package/dist/src/components/calendar/CalendarEventEditor.d.ts +6 -0
- package/dist/src/components/calendar/CalendarEventEditor.js +321 -0
- package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
- package/dist/src/components/calendar/CalendarEventPopup.js +133 -0
- package/dist/src/components/calendar/CalendarLoadFailed.d.ts +8 -0
- package/dist/src/components/calendar/CalendarLoadFailed.js +11 -0
- package/dist/src/components/calendar/CalendarNavPane.d.ts +11 -0
- package/dist/src/components/calendar/CalendarNavPane.js +50 -0
- package/dist/src/components/calendar/CalendarQuickCreate.d.ts +22 -0
- package/dist/src/components/calendar/CalendarQuickCreate.js +131 -0
- package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
- package/dist/src/components/calendar/CalendarScreen.js +145 -0
- package/dist/src/components/calendar/CalendarSession.d.ts +21 -0
- package/dist/src/components/calendar/CalendarSession.js +12 -0
- package/dist/src/components/calendar/ChangeCalendarSuggestion.js +39 -5
- package/dist/src/components/calendar/EventMoves.d.ts +17 -0
- package/dist/src/components/calendar/EventMoves.js +103 -0
- package/dist/src/components/calendar/calendar-story-fixtures.js +8 -2
- package/dist/src/components/calendar/calendar-story-server.d.ts +2 -5
- package/dist/src/components/calendar/calendar-story-server.js +5 -6
- package/dist/src/components/layout/AppFrame.d.ts +11 -0
- package/dist/src/components/layout/AppFrame.js +16 -0
- package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
- package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
- package/dist/src/components/ui/SignedOutOverlay.js +29 -0
- package/dist/src/hooks/calendar/draft-session.d.ts +77 -0
- package/dist/src/hooks/calendar/draft-session.js +109 -0
- package/dist/src/hooks/calendar/index.d.ts +2 -1
- package/dist/src/hooks/calendar/index.js +1 -0
- package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
- package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
- package/dist/src/hooks/calendar/useCalendarWrites.d.ts +11 -1
- package/dist/src/hooks/calendar/useCalendarWrites.js +7 -2
- package/dist/src/hooks/calendar/useCalendars.d.ts +1 -0
- package/dist/src/hooks/calendar/useCalendars.js +5 -2
- package/dist/src/hooks/calendar/useDraftSession.d.ts +32 -0
- package/dist/src/hooks/calendar/useDraftSession.js +106 -0
- package/dist/src/hooks/calendar/useMoveEvent.d.ts +4 -0
- package/dist/src/hooks/calendar/useMoveEvent.js +61 -0
- package/dist/src/hooks/use-system-update.js +3 -5
- package/dist/src/hooks/useCalendarData.d.ts +2 -0
- package/dist/src/hooks/useCalendarData.js +6 -1
- package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
- package/dist/src/hooks/useCalendarSidePane.js +30 -0
- package/dist/src/hooks/useRefreshControl.js +4 -8
- package/dist/src/hooks/useStaleAccountSync.js +4 -4
- package/dist/src/hooks/useWarningsAttention.js +1 -3
- package/dist/src/lib/calendar-route.d.ts +6 -0
- package/dist/src/lib/calendar-route.js +14 -0
- package/dist/src/lib/calendar-side-pane-pref.d.ts +14 -0
- package/dist/src/lib/calendar-side-pane-pref.js +27 -0
- package/dist/src/lib/error-classifier.d.ts +5 -30
- package/dist/src/lib/error-classifier.js +7 -10
- package/dist/src/lib/escalate.d.ts +6 -0
- package/dist/src/lib/escalate.js +16 -0
- package/dist/src/lib/intelligence-pref.js +3 -2
- package/dist/src/lib/new-event-range.d.ts +26 -0
- package/dist/src/lib/new-event-range.js +69 -0
- package/dist/src/lib/query-error-handler.d.ts +2 -6
- package/dist/src/lib/query-error-handler.js +5 -14
- package/dist/src/lib/signed-out.d.ts +13 -0
- package/dist/src/lib/signed-out.js +28 -0
- package/dist/src/routeTree.gen.d.ts +81 -19
- package/dist/src/routeTree.gen.js +25 -1
- package/dist/src/routes/__root.js +8 -2
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.js +11 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.js +12 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.js +4 -13
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.js +14 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.js +4 -4
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/index.d.ts +1 -6
- package/dist/src/routes/calendar/$view.$date/index.js +3 -10
- package/dist/src/routes/calendar/$view.$date/new.d.ts +6 -2
- package/dist/src/routes/calendar/$view.$date/new.js +8 -13
- package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.js +2 -2
- package/dist/src/routes/calendar/$view.$date.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date.js +14 -50
- package/dist/src/routes/calendar/index.d.ts +1 -1
- package/dist/src/routes/calendar/index.js +2 -1
- package/dist/src/routes/calendar.d.ts +4 -9
- package/dist/src/routes/calendar.js +10 -35
- package/dist/src/routes/mail/index.d.ts +1 -1
- package/dist/src/routes/mail/index.js +7 -2
- package/dist/src/routes/mail.js +6 -5
- package/dist/src/routing/app-switch.d.ts +11 -0
- package/dist/src/routing/app-switch.js +35 -0
- package/dist/src/routing/calendar.d.ts +41 -4
- package/dist/src/routing/calendar.js +121 -13
- package/dist/src/routing/fragment.d.ts +1 -1
- package/dist/src/routing/fragment.js +6 -1
- package/dist/src/routing/index.d.ts +2 -1
- package/dist/src/routing/index.js +2 -1
- package/package.json +2 -2
- package/dist/src/components/calendar/CalendarComposePane.d.ts +0 -49
- package/dist/src/components/calendar/CalendarComposePane.js +0 -8
- package/dist/src/components/calendar/CalendarComposeSeed.d.ts +0 -7
- package/dist/src/components/calendar/CalendarComposeSeed.js +0 -19
- package/dist/src/components/calendar/CalendarEventPane.d.ts +0 -48
- package/dist/src/components/calendar/CalendarEventPane.js +0 -48
- package/dist/src/components/calendar/CalendarShell.d.ts +0 -43
- package/dist/src/components/calendar/CalendarShell.js +0 -35
- package/dist/src/components/calendar/CalendarViewPlaceholder.d.ts +0 -1
- package/dist/src/components/calendar/CalendarViewPlaceholder.js +0 -5
- package/dist/src/components/calendar/CalendarWorkspace.d.ts +0 -49
- package/dist/src/components/calendar/CalendarWorkspace.js +0 -65
- package/dist/src/components/calendar/OpenCalendarEvent.d.ts +0 -20
- package/dist/src/components/calendar/OpenCalendarEvent.js +0 -169
- package/dist/src/components/calendar/WriteCalendarEvent.d.ts +0 -13
- 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 {
|
|
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
|
|
23
|
-
//
|
|
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
|
-
|
|
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 {
|
|
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 }
|
|
120
|
-
|
|
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
|
|
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 = {
|
|
@@ -87,3 +87,9 @@ export declare const calendarSearchSchema: z.ZodObject<{
|
|
|
87
87
|
calendarId: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string[], unknown>>, z.ZodTransform<string[] | undefined, string[]>>>;
|
|
88
88
|
}, z.core.$strip>;
|
|
89
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;
|
|
@@ -145,3 +145,17 @@ export const calendarSearchSchema = z.object({
|
|
|
145
145
|
.transform((ids) => (ids.length === 0 ? undefined : ids))
|
|
146
146
|
.optional(),
|
|
147
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
|
|
98
|
-
*
|
|
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
|
|
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
|
|
116
|
-
* exception, and a 401
|
|
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
|
|
146
|
-
*
|
|
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
|
|
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 (
|
|
167
|
-
return
|
|
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
|
|
178
|
-
* exception, and a 401
|
|
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
|
-
|
|
39
|
-
|
|
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
|
}
|
|
@@ -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
|
-
*
|
|
11
|
-
*
|
|
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 {
|
|
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
|
-
*
|
|
12
|
-
*
|
|
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
|
-
|
|
23
|
-
reportFatalError(error);
|
|
24
|
-
}
|
|
17
|
+
escalate(error, query.meta);
|
|
25
18
|
};
|
|
26
19
|
export const handleMutationCacheError = (error, _variables, _onMutateResult, mutation) => {
|
|
27
|
-
|
|
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 {};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
const listeners = new Set();
|
|
8
|
+
let signedOut = false;
|
|
9
|
+
export const reportSignedOut = () => {
|
|
10
|
+
if (signedOut)
|
|
11
|
+
return;
|
|
12
|
+
signedOut = true;
|
|
13
|
+
for (const listener of listeners)
|
|
14
|
+
listener(true);
|
|
15
|
+
};
|
|
16
|
+
export const isSignedOut = () => signedOut;
|
|
17
|
+
export const subscribeSignedOut = (listener) => {
|
|
18
|
+
listeners.add(listener);
|
|
19
|
+
return () => {
|
|
20
|
+
listeners.delete(listener);
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** Forgets a reported sign-out, once the reader is signing back in. */
|
|
24
|
+
export const resetSignedOut = () => {
|
|
25
|
+
signedOut = false;
|
|
26
|
+
for (const listener of listeners)
|
|
27
|
+
listener(false);
|
|
28
|
+
};
|