Files
zooqueen ad3c58d9a0 fix: confirm a saved profile, decide the upload store once, agree on ids
Three unrelated defects, one image.

The profile toast fired only after a session refresh. That refresh is a second
read: it can stall, and when it answers unauthenticated it clears the session,
which throws in useSession and takes down the subtree holding the toaster. A
save that had already persisted could therefore go unconfirmed. The save is
confirmed on the save now and the refresh follows it, so the confirmation
depends only on the thing it reports.

Document bytes are routed by NEXT_PUBLIC_UPLOAD_TRANSPORT. Three places read it
with three slightly different rules, and the two that chose a store fell through
to the database for any value they did not recognise -- so a transport named
under a variable nothing reads stored every PDF inline while the configuration
read as object storage, with nothing logged either way. One function resolves it
now: unset means the database, and an unrecognised value throws rather than
quietly picking a store. Reads still dispatch on each row's own type, so rows
written under either transport keep working.

entry.client and entry.server built different root trees -- StrictMode on the
client only, and a second child beside the router. useId numbers a component by
its position, and a parent's child count is part of that position, so every id
below the root diverged and hydration failed on the first component to ask for
one. Measured on the documents page: the header's menu trigger came back
radix-:R26j5: from the server and radix-:R8qcl: from the client. The trees are
identical now and all seven server-rendered ids survive hydration unchanged.

Also: .gitignore still named the license artifact by its pre-rebrand filename,
so the file the app actually writes was landing in git status untracked.
2026-08-14 09:24:44 -07:00

28 lines
1.0 KiB
TypeScript

import { match } from 'ts-pattern';
import { env } from '@hanzo/esign-lib/utils/env';
export type UploadTransport = 'database' | 's3';
/**
* Where document bytes live: `database` inlines them as base64 on the
* DocumentData row, `s3` stores an object key and streams from the bucket.
*
* Unset reads as `database`, the default every example config ships. Anything
* else throws, because the alternative is worse than a crash: an unrecognised
* value used to route to `database`, so a misspelled variable — or the right
* value under the wrong variable name — stored every PDF inline while the
* config claimed object storage, with nothing logged either way.
*/
export const uploadTransport = (): UploadTransport => {
const transport = env('NEXT_PUBLIC_UPLOAD_TRANSPORT') || 'database';
return match(transport)
.with('database', 's3', (value) => value)
.otherwise(() => {
throw new Error(
`NEXT_PUBLIC_UPLOAD_TRANSPORT is "${transport}", which is not a transport. Use "database" or "s3".`,
);
});
};