managarten/services/mana-auth/src
Till JS 3df7391905 feat(auth): bootstrap per-Space kontextDoc on Space-creation (F4 follow-up)
Symmetrically extends the F4 server-side singleton bootstrap to the
per-Space `kontextDoc`. Every Space-creation — Personal at signup and
brand/club/family/team/practice via the org plugin — now writes an empty
kontextDoc row straight into mana_sync.sync_changes with origin='system',
client_id='system:bootstrap'. Fresh clients pull the row instead of
racing on a local insert that the next pull would clobber.

- New `bootstrapSpaceSingletons(spaceId, ownerUserId, syncSql)` in
  services/mana-auth/src/services/bootstrap-singletons.ts; shared
  `buildFieldMeta` helper extracted.
- `createBetterAuth(databaseUrl, syncDatabaseUrl, webauthn)` now takes
  the sync-DB URL and lazy-creates a module-scoped postgres pool for
  the bootstrap inserts.
- Hook into `databaseHooks.user.create.after` (only on `created: true`
  from createPersonalSpaceFor) and `organizationHooks.afterCreateOrganization`.
- Webapp `kontextStore.ensureDoc()` made private as `getOrCreateLocalDoc()` —
  same fallback role as userContextStore's after F5. Public API is now just
  setContent + appendContent.

Plan: docs/plans/sync-field-meta-overhaul.md (F4-fu row in Shipping Log).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 01:21:31 +02:00
..
auth feat(auth): bootstrap per-Space kontextDoc on Space-creation (F4 follow-up) 2026-04-27 01:21:31 +02:00
db feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
email feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
lib feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
middleware refactor(shared-tailwind): rewrite themes.css to single-layer shadcn convention 2026-04-09 01:13:06 +02:00
routes feat(sync): F4 — server-side singleton bootstrap 2026-04-26 23:18:54 +02:00
services feat(auth): bootstrap per-Space kontextDoc on Space-creation (F4 follow-up) 2026-04-27 01:21:31 +02:00
spaces feat(spaces): move access tier from user to space 2026-04-20 20:10:06 +02:00
config.ts feat(auth): error-classification layer + passkey end-to-end 2026-04-24 01:52:51 +02:00
index.ts feat(auth): bootstrap per-Space kontextDoc on Space-creation (F4 follow-up) 2026-04-27 01:21:31 +02:00