style: trim narration comments from recent changes

This commit is contained in:
2026-08-23 20:06:05 -07:00
parent c342b91029
commit 58702da156
16 changed files with 21 additions and 75 deletions
-3
View File
@@ -41,7 +41,6 @@ export async function ensureMessages(locale: AppLocale): Promise<Messages> {
const loader = catalogLoaders[`/src/locales/${locale}/messages.po`];
if (!loader) return messageCache[DEFAULT_LOCALE]!;
// Dedupe concurrent loads; a rejected load is dropped so a retry can succeed.
const pending = (inflightLoads[locale] ??= loader()
.then(({ messages }) => {
messageCache[locale] = messages;
@@ -57,8 +56,6 @@ export function primeMessages(locale: AppLocale, messages: Messages) {
messageCache[locale] ??= messages;
}
// Seeded into the SSR-dehydrated query cache so hydration renders the active
// locale without depending on a client-side catalog chunk load.
export const i18nMessagesQueryKey = (locale: AppLocale) =>
["i18n-messages", locale] as const;
-7
View File
@@ -36,11 +36,6 @@ export const LinguiProvider = ({ children }: { children: React.ReactNode }) => {
const locale = resolveLocale(data?.metadata?.locale);
const [catalogVersion, setCatalogVersion] = useState(0);
// Fresh instance per locale (and per SSR request tree). __root beforeLoad
// dehydrates the active locale's catalog with the page, so hydration primes
// it from the query cache and never regresses to en for the SSR'd locale.
// Public routes (login) may still lack it — createI18n falls back to en
// until the effect below loads it and bumps catalogVersion.
const i18n = useMemo(
() => {
if (!hasCachedMessages(locale)) {
@@ -59,8 +54,6 @@ export const LinguiProvider = ({ children }: { children: React.ReactNode }) => {
if (hasCachedMessages(locale)) return;
let cancelled = false;
let retryTimer: ReturnType<typeof setTimeout> | undefined;
// A failed chunk load must not strand the UI in en — retry until the
// catalog arrives or the locale changes.
const load = () => {
ensureMessages(locale).then(
() => {
+2 -10
View File
@@ -19,17 +19,13 @@ class PocketBaseAdminClient {
this.pb = new PocketBase(process.env.POCKETBASE_URL);
this.pb.beforeSend = async (url, options) => {
// The auth requests themselves must skip the gate below: gating them on
// authPromise would make them await their own completion (deadlock).
// Auth requests skip the gate: awaiting authPromise here would deadlock them.
if (!url.includes("/collections/_superusers/auth-")) {
try {
await this.authPromise;
} catch {
// Swallow: fall through to self-heal so a rejected authPromise can't strand every request.
}
} catch {}
if (!this.pb.authStore.isValid) {
// Self-heal: re-auth once PocketBase is reachable again, no restart.
this.authPromise = this.authenticate();
await this.authPromise;
this.startTokenRefresh();
@@ -43,8 +39,6 @@ class PocketBaseAdminClient {
}
}
// The SDK stamps Authorization before this hook runs, so a request
// built while auth was still in flight carries no (or a stale) token.
options.headers = {
...options.headers,
Authorization: this.pb.authStore.token,
@@ -75,8 +69,6 @@ class PocketBaseAdminClient {
Object.assign(this, createPushService(this.pb));
this.authPromise = this.authenticate();
// Fail soft at boot: an unreachable PocketBase must not crash the process;
// beforeSend self-heals on the next request.
this.authPromise
.then(() => {
this.startTokenRefresh();
+1 -9
View File
@@ -2,17 +2,9 @@ import type PocketBase from "pocketbase";
export type FilterParam = string | number | boolean | Date | null;
// Any key the SDK's own `replaceAll("{:" + key + "}", …)` loop would substitute,
// so which keys resolve does not depend on the characters they are spelled with.
const PLACEHOLDER = /\{:([^}]+)\}/g;
// `pb.filter` substitutes with String.replaceAll and a *string* replacement, so
// `$&`, `` $` ``, `$'` and `$$` inside a value are expanded as replacement
// patterns: the value's own text, or a slice of the surrounding expression,
// gets spliced into the quoted literal. Doubling every `$` first collapses back
// to the exact literal inside that same replaceAll. The FilterParam union is
// load-bearing — it keeps objects and arrays out of the SDK's JSON.stringify
// branch, which would reintroduce an undoubled `$`.
// pb.filter $-expands string replacements; doubling `$` keeps the value literal.
const quote = (pb: PocketBase, value: FilterParam) =>
pb.filter("{:v}", {
v: typeof value === "string" ? value.replaceAll("$", () => "$$") : value,
+1 -8
View File
@@ -1,10 +1,3 @@
// `pb.filter()` escapes single quotes and nothing else, so a term ending in a
// backslash escapes the closing quote of the literal it is substituted into and
// PocketBase rejects the whole expression with 400 validation_invalid_filter.
// Escaping `\ % _` and appending the wildcards here keeps the operand's last
// character a literal `%`, and makes `~` an unconditional substring match:
// PocketBase only auto-wraps (and only auto-escapes) operands that contain no
// `%` of their own, so a term carrying one would otherwise silently become a
// prefix match, and a bare `_` would match every row.
// Escapes LIKE metacharacters and wraps in `%` for a literal substring match.
export const likePattern = (term: string) =>
`%${term.replace(/[\\%_]/g, (char) => `\\${char}`)}%`;
-3
View File
@@ -1,13 +1,10 @@
// Shared redaction for logs + audit rows so the two never drift.
export const SENSITIVE_KEY = /token|secret|password|phone|otp|code|auth|key/i;
const REDACTED = "[redacted]";
// Deep-redact: keys matching SENSITIVE_KEY become "[redacted]"; primitives pass through.
export const redactValue = (value: unknown): unknown => {
if (Array.isArray(value)) return value.map(redactValue);
if (value && typeof value === "object") {
// Keep Error serializable.
if (value instanceof Error) {
return { name: value.name, message: value.message, stack: value.stack };
}
@@ -16,8 +16,6 @@ export const createServerError = (
context,
});
// Audit rows are written by serverFnLoggingMiddleware, which reads the
// returned envelope's success flag — never write them here.
export const toServerResult = async <T>(
serverFn: () => Promise<T>
): Promise<ServerResult<T>> => {