Commit Graph

32 Commits

Author SHA1 Message Date
RevIQ
a4d1f28f3d Add typed context and middleware for oRPC procedures
Use implement(contract).$context<APIContext>() for proper type safety
in all procedure handlers. Create authMiddleware and loginRequestMiddleware
using os.middleware() and apply with .use() on routes requiring auth.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:36:26 +08:00
RevIQ
829d365e80 Implement auth procedures with code review fixes
Add complete auth backend (Workstream D):
- Auth middleware for session/API key authentication
- Signup with password or passkey (WebAuthn)
- Login flow with device trust and email confirmation
- Password reset and email verification
- Session management and logout

Utilities created:
- cookies.ts: Cookie helpers and configuration
- crypto.ts: Token generation and hashing
- password.ts: zxcvbn validation, argon2id hashing
- geo.ts: IP/location extraction from headers
- email.ts: Stubbed email sending
- session.ts: Session creation and device trust

Code review improvements applied:
- Use ORPCError instead of Error in procedures
- Add ast-grep rule to enforce ORPCError usage
- Remove error info leakage (generic messages)
- Optimize N+1 query with JOIN in login-password
- Extract signupWithPassword/signupWithPasskey for testability
- Add 15-minute WebAuthn challenge expiry check
- Strengthen CookieOptions type definitions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:19:15 +08:00
RevIQ
8de88472b1 claude settings 2026-01-09 12:37:17 +08:00
RevIQ
b46146faa5 Implement WebAuthn passkey authentication
Add complete WebAuthn support for passkey registration and authentication:
- Install @simplewebauthn/server for WebAuthn utilities
- Create passkey-helpers.ts with base64url/Uint8Array conversion utilities
- Create webauthn.ts with registration/authentication option generation and verification
- Create context.ts with API context types
- Implement all WebAuthn router handlers (createRegistrationOptions, verifyRegistration, createAuthenticationOptions, verifyAuthentication)
- Implement passkey management handlers (listPasskeys, createPasskey, renamePasskey, deletePasskey)
- Add WebAuthn configuration constants and environment variables

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:34:26 +08:00
RevIQ
a4dff188eb Replace z.any() with z.custom<T>() for WebAuthn types
Use proper TypeScript types from @simplewebauthn/types instead of
z.any() for WebAuthn-related schemas:
- PublicKeyCredentialCreationOptionsJSON
- PublicKeyCredentialRequestOptionsJSON
- RegistrationResponseJSON
- AuthenticationResponseJSON

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:17:29 +08:00
RevIQ
b6bce41092 Fix zod imports with ast-grep namespace import rule
Applied ast-grep rule to convert named zod imports to namespace imports
across the api-contract package for consistency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:14:19 +08:00
RevIQ
2e9ea74bc9 Connect frontend to oRPC server
- Add Vite proxy to forward /api/v1/rpc to API server (port 9861)
- Create oRPC client in src/lib/api/client.ts
- Add @orpc/client and @orpc/contract dependencies
- Add @reviq/api-contract workspace dependency
- Extract DEFAULT_PORT constant to api-server/src/constants.ts
- Change API server default port from 3001 to 9861

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:09:03 +08:00
RevIQ
bd3997ffe9 Ignore noExplicitAny in publisher-dashboard utils
Add biome override to allow `any` in conditional types used for
Svelte component utility types (WithoutChild, WithoutChildren).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:03:53 +08:00
RevIQ
8f3f711af0 Add ESLint to all packages and reorganize CLI
ESLint:
- Add @macalinao/eslint-config and eslint to all packages/apps
- Add lint scripts to all package.json files
- Create eslint.config.js for all apps
- Add lint task to turbo.json
- Add @macalinao/eslint-config and @types/bun to catalog

Biome:
- Exclude docs/ from biome checks

CLI Reorganization:
- Restructure CLI to use route maps with one command per file
- Move commands to routes/ directory structure
- Use func property instead of async loaders
- Route maps in _command.ts files for each directory

Environment:
- Use Bun.env instead of process.env for env vars
- Add DATABASE_URL and PORT to turbo.json globalEnv

Lint Fixes:
- Fix nullish coalescing operator usage
- Update deprecated Zod API (z.email() instead of .string().email())
- Fix import sorting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 12:01:41 +08:00
RevIQ
b687d9cd1d Add turbo lint to root lint scripts
Run ESLint on all packages in addition to Biome check.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:48:18 +08:00
RevIQ
5eeef44850 Fix TypeScript compilation issues in packages
- Add explicit type annotations for isolatedDeclarations
- Export Database type alias from db-schema
- Fix import paths and add proper type exports
- Update common schemas with better exports

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:46:11 +08:00
RevIQ
aee22ae454 Update devenv and cleanup packages
- Add api-server process to devenv.nix
- Add dbmate and kysely-codegen scripts
- Configure PostgreSQL with localhost listener
- Update publisher-dashboard package to @apps/publisher-dashboard
- Fix deprecated asChild prop in mobile-nav component
- Remove unused publisher-utils package
- Update bun.lock with new dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:45:13 +08:00
RevIQ
93132d76c0 Add api-server and CLI applications
- Create api-server with Bun.serve:
  - oRPC router with stub handlers for all procedures
  - Auth middleware placeholder
  - CORS configuration
- Create CLI tool with stricli:
  - bootstrap command for initial superuser creation
  - Placeholder commands for auth, user, org management

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:45:03 +08:00
RevIQ
cc5fba0fc7 Add oRPC API contract with Zod schemas
- Create @reviq/api-contract package
- Define Zod schemas for all input/output types:
  - Auth schemas (signup, login, password reset, WebAuthn)
  - User/profile schemas
  - Organization schemas (CRUD, members, invites)
  - Admin procedure schemas
- Define oRPC contract with full procedure signatures:
  - auth.* (signup, login, password reset, WebAuthn)
  - me.* (profile, sessions, devices, passkeys)
  - orgs.* (CRUD, members, invites, sites)
  - admin.* (orgs, users, auth management)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:44:52 +08:00
RevIQ
392d976812 Add database schema and Kysely packages
- Create initial database migration with full auth schema:
  - users, sessions, passkeys, devices tables
  - orgs, org_members, org_sites, org_invites tables
  - email_verifications, password_resets, login_requests tables
  - Indexes for common lookups and cleanup jobs
- Add @reviq/db-schema package with kysely-codegen
- Add @reviq/db package with Kysely client

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:44:36 +08:00
RevIQ
322155b4a1 set up ast-grep and dbmate and postgres 2026-01-09 10:51:47 +08:00
RevIQ
82f39e0335 Add TanStack Query and update dashboard card styling
- Set up @tanstack/svelte-query and devtools in root layout
- Configure QueryClient with 5-minute stale time
- Update dashboard card to match Figma: regular font weight, no border
- Add .playwright-mcp to gitignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 17:27:23 +08:00
RevIQ
e42201fea6 Fix peak traffic chart to match Figma design
Overlay bars instead of positioning side by side, with transparent
hatched "Last month" bars on top of solid "This month" bars. Update
legend icons to circular. Add CLAUDE.md with dev server notes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 09:47:02 +08:00
RevIQ
ad65469db6 Add DashboardCard component and redesign peak traffic chart
- Create reusable DashboardCard component with title and content slot
- Redesign PeakTrafficChart to match Figma design:
  - Vertical bar chart showing peak hours by day of week
  - Y-axis: hours (0:00 to 21:00)
  - X-axis: days (Mon-Sun)
  - Two data series: "This month" (solid) and "Last month" (hatched)
  - Diagonal stripe pattern for last month bars using SVG
  - Legend at bottom

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:15:57 +08:00
RevIQ
e387d8c123 Quote process names with hyphens in devenv.nix
Nix attribute names with hyphens need to be quoted.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:05:31 +08:00
RevIQ
bba08a4330 Fix turbo watch command syntax
Use `turbo watch build` instead of `turbo build --watch`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:04:23 +08:00
RevIQ
e4cbb9d565 Set publisher dashboard dev server to port 6827
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:03:51 +08:00
RevIQ
9670568fc1 Rename dev process to dev-publisher-dashboard
Runs dev server directly in apps/publisher-dashboard directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:03:31 +08:00
RevIQ
2835df69c0 Rename build:watch to build:watch:packages
Only watches and builds packages in ./packages/*, excluding apps.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:03:01 +08:00
RevIQ
c6380fff90 Add devenv processes for dev server and build:watch
- Add build:watch script to package.json (turbo build --watch)
- Configure devenv processes:
  - dev: runs turbo dev server
  - build-watch: runs turbo build in watch mode
- Run with `devenv up` to start all processes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:01:13 +08:00
RevIQ
b7e76434e2 Redesign sidebar with frosted glass effect
Based on Figma design, updated sidebar to feature:
- Frosted glass background with backdrop blur
- Dark gradient app icon (from-[#303035] to-[#26262c])
- Filled icons when active, stroked when inactive
- Smaller, more compact nav items (32x32px)
- Updated sidebar CSS variables for translucent colors
- Added glass utility classes for backdrop blur effects
- User avatar at bottom with gradient background

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 07:38:23 +08:00
RevIQ
d260821964 Add login page with two-column layout
- Two-column layout: dark branding panel (left) and login form (right)
- Responsive design with mobile logo visible on small screens
- Social login buttons (Google, GitHub)
- Loading state with spinner animation
- Uses shadcn-svelte Input and Label components
- Separate layout to bypass dashboard wrapper

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 16:00:33 +08:00
RevIQ
ed82503a44 Add max-width constraint to main content area
Keep sidebar full-height at left edge while constraining the main
content area to max-w-7xl centered.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 15:47:51 +08:00
RevIQ
9b7b1e8cd9 Remove max-width constraint from root layout
The root +layout.svelte had max-w-7xl and mx-auto which constrained
the entire app to 1280px centered. Removed to allow full-width layout
where sidebar extends to the left edge of the viewport.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 14:01:39 +08:00
RevIQ
f8d543565c Redesign dashboard UI with mobile responsive layout
- Add Geist font family and refined OKLCH color palette
- Redesign all dashboard components with polished styling
- Implement URL-synced tabs for performance table (domain, country, source, ad-unit, key-value)
- Add mobile hamburger menu using shadcn Sheet component
- Make sidebar responsive (hidden on mobile, visible on lg+)
- Add custom shadow utilities and improved visual hierarchy
- Add sparklines with gradients to metric cards
- Redesign peak traffic chart as heatmap grid
- Add icons and hover states to frequent filters

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 13:59:25 +08:00
RevIQ
ccd8f5c3db Add cursor-pointer to buttons globally
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 18:07:30 +08:00
RevIQ
a1db9ca3c5 Initial commit: Publisher dashboard monorepo
Turborepo + Bun monorepo with:
- apps/publisher-dashboard: Svelte 5 SPA with SvelteKit, Tailwind CSS v4, shadcn-svelte
- packages/publisher-utils: Shared TypeScript utilities

Features:
- Performance dashboard page with metrics, charts, and data tables
- shadcn-svelte UI components with OKLCH color system
- Biome for linting/formatting with Svelte-specific overrides

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 17:25:21 +08:00