Skip to content

feat(api): add API v1 columns (migration 0024) and principal via - #224

Merged
josue-commits merged 3 commits into
developfrom
feat/api-v1-base-migrations
Oct 13, 2026
Merged

josue-commits merged 3 commits into
developfrom
feat/api-v1-base-migrations

Conversation

@josue-commits

Copy link
Copy Markdown
Contributor

Summary

Lays the groundwork for the public API v1: the database columns it needs and a way for request handlers to tell how the caller authenticated. No user-facing behavior changes yet.

Changes

  • Migration 0024 (PostgreSQL and SQLite, both Drizzle schemas), additive and nullable:
    • api_key.member_id plus index api_key_account_member_idx
    • form.created_via, form.previous_config (JSONB in PG, TEXT in SQLite), form.previous_published_at_ms (BIGINT in PG, INTEGER in SQLite)
  • The resolved principal now carries via: 'session' | 'api_key' (and optional apiKeyId). Session requests get via: 'session' in both the home workspace and a workspace selected by header.
  • New isApiKeyPrincipal helper, exported from auth.provider.ts and re-exported from auth.service.ts.
  • Changeset: @quill/db minor.

How it was tested

  • migration-0024.spec.ts stages the upgrade at exactly 0023 then 0024 with realistic rows: no row lost, existing values unchanged, new columns NULL.
  • auth-principal.spec pins the exact principal keys for home and header-selected workspaces; unit tests for isApiKeyPrincipal.
  • pnpm typecheck, pnpm lint (no new warnings), full pnpm test on SQLite.
  • PostgreSQL parity: db:migrate applies 0024, db:seed works, @quill/db and @quill/api suites pass against Postgres 16.
  • Publish gate passes.

Review notes

An independent review found no bugs. Notes for follow-up work:

  • isApiKeyPrincipal returns false when via is missing, so test stubs built without via read as session. Give those stubs via: 'session' explicitly when they are next touched.
  • The principal type allows apiKeyId without via: 'api_key'; a discriminated union could tighten this once the API key principal is built.

🤖 Generated with Claude Code

josue-commits and others added 3 commits October 12, 2026 16:50
api_key.member_id with an (account_id, member_id) index, and
form.created_via, form.previous_config and form.previous_published_at_ms,
in SQLite and Postgres and in both Drizzle schemas. Purely additive: an
upgraded database keeps every row and the new columns read NULL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Josue Hernandez <josue@daptatech.com>
…ncipal

HostPrincipal gains via: 'session' | 'api_key' and an optional apiKeyId.
AuthService.resolveHost only resolves sessions today, so it always returns
via: 'session' and otherwise the same principal as before.
isApiKeyPrincipal is the one check the key, strict validation and
created-via metric code will use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Josue Hernandez <josue@daptatech.com>
… new specs

The upgrade test now migrates through 0024 only, so a later migration
cannot change what it asserts. Both new spec files follow the shared
Prettier preset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Josue Hernandez <josue@daptatech.com>
@josue-commits
josue-commits merged commit 2df580c into develop Oct 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant