Commit Graph

212 Commits

Author SHA1 Message Date
saravanakumardb1
18a5b342d9 fix(request-context): block sunset products in public productId resolver 2026-02-16 23:45:17 -08:00
saravanakumardb1
b0e8304d59 test(server): update @bytelyst/config mock for loadProductIdentity 2026-02-16 23:28:52 -08:00
saravanakumardb1
c7480661eb fix(waitlist): harden public endpoints and unsubscribe validation
- Block sunset products on public waitlist join/count/config endpoints
- Verify unsubscribe email matches unsubscribeToken before status change
- Keep idempotent join behavior explicit for existing entries (200 path)
- Escape CSV newline/carriage-return values to prevent malformed exports
- Refactor request productId extraction to shared helper in request-context
- Guard prelaunchConfig merge with safe default object in products update route
2026-02-16 23:28:32 -08:00
saravanakumardb1
b9b4822cad docs(waitlist): add implementation TODOs summary + commit links to roadmap 2026-02-16 22:50:56 -08:00
saravanakumardb1
6a996cc11d test(waitlist): add 45 unit tests + update doc checkboxes with commit links
- 45 tests: schema validation, email normalization, status transitions, route exports
- Update Phase 1, 2, 3, 4 checkboxes in PRE_LAUNCH_SIGNUP_SYSTEM.md with commit SHAs
- Add webhook env vars to .env.example
2026-02-16 22:49:42 -08:00
saravanakumardb1
2692c918ce feat(waitlist): add pre-launch waitlist module (types, repo, routes)
- Create waitlist/types.ts: WaitlistEntryDoc, Zod schemas for join/status/unsubscribe/admin
- Create waitlist/repository.ts: full CRUD, dedup by emailNormalized, position assignment, stats
- Create waitlist/routes.ts: 5 public endpoints + 7 admin endpoints with role guard
- Add waitlist container to cosmos-init.ts (+ 13 previously missing containers)
- Add dispatchWaitlistJoined webhook to webhooks.ts
- Register waitlistRoutes in server.ts
- Public: join, check status, count, config, unsubscribe
- Admin: list, stats, get, update, delete, batch invite, CSV export
2026-02-16 22:45:14 -08:00
saravanakumardb1
66e657a646 feat(products): extend product status lifecycle + prelaunch config
- Add 6 product statuses: draft, pre_launch, beta, active, sunset, disabled
- Add PrelaunchConfig with customFields, CAPTCHA, tagline, maxSignups
- Add isValidStatusTransition() helper for safe status changes
- Update getRequestProductId() to block draft/sunset/disabled
- Add getRequestProductIdForPublic() for pre_launch waitlist routes
- Add status transition validation to product update route
- Add PRE_LAUNCH_SIGNUP_SYSTEM.md design doc with full roadmap
2026-02-16 22:36:53 -08:00
saravanakumardb1
209213b50d test(server): cover platform bootstrap wiring and hooks 2026-02-16 15:25:27 -08:00
saravanakumardb1
1df94103ea test(cosmos): add init path coverage for platform-service 2026-02-16 15:22:38 -08:00
saravanakumardb1
e3f173c164 test(config): add env schema coverage for platform-service 2026-02-16 15:20:04 -08:00
saravanakumardb1
9fbaf60ba8 test(platform-service): add route coverage for items invitations audit 2026-02-16 15:00:13 -08:00
saravanakumardb1
7179f1e7c4 test(platform-service): add promos route-level tests 2026-02-16 12:46:40 -08:00
saravanakumardb1
e4ee23aab4 test(platform-service): add comments route-level tests 2026-02-16 12:43:56 -08:00
saravanakumardb1
3e1647ae96 test(platform-service): add tokens route-level tests 2026-02-16 12:41:34 -08:00
saravanakumardb1
dc0cf6d8b4 test(platform-service): add referrals route-level tests 2026-02-16 12:38:42 -08:00
saravanakumardb1
783b9792df test(platform-service): add memory route-level tests 2026-02-16 12:36:27 -08:00
saravanakumardb1
8576fe2e91 test(platform-service): add route tests for settings, votes, and public modules 2026-02-16 12:33:17 -08:00
saravanakumardb1
c7934af227 test(platform-service): add subscriptions route-level tests — 395 tests, 39.6% stmts 2026-02-16 12:17:00 -08:00
saravanakumardb1
1cb9af3ae4 test(platform-service): add usage route-level tests — 386 tests, 37.9% stmts 2026-02-16 12:15:40 -08:00
saravanakumardb1
149d97dd9f test(platform-service): add route-level tests for plans + notifications — 379 tests, 35.4% stmts 2026-02-16 12:14:42 -08:00
saravanakumardb1
87f7d76915 test(platform-service): add products, cache, votes repository tests — 362 tests, 32.6% stmts 2026-02-16 12:08:40 -08:00
saravanakumardb1
747d89fe4d test(platform-service): add repository tests for settings, referrals — 336 tests, 30.64% coverage 2026-02-16 12:05:03 -08:00
saravanakumardb1
fbb2197f7c test(platform-service): add repository tests for notifications, plans, subscriptions, usage, tokens, memory + fix extraction-service flaky test 2026-02-16 11:59:06 -08:00
saravanakumardb1
7524c4d29e feat(platform-service): add GET /settings/kill-switch public endpoint
- No auth required — mobile apps call this at launch before login
- Reads kill_switch feature flag from Cosmos DB
- If flag enabled=true → returns disabled:true with maintenance message
- Fail-open: DB errors allow app to run normally
- Response: { enabled: bool, disabled: bool, message: string }

Used by iOS KillSwitchService.swift and Android KillSwitchService.kt
2026-02-15 21:30:03 -08:00
saravanakumardb1
5622499575 feat(licenses): add POST /licenses/revoke endpoint
Sets license status to 'revoked' and clears all device activations.
Returns the updated license doc. Idempotent — already-revoked licenses
return immediately.
2026-02-15 20:15:10 -08:00
saravanakumardb1
972a1a21d7 feat(usage): cross-product usage queries + product breakdown
- Make productId optional in repository list() — omitting it queries all products
- Add resolveProductFilter() helper: productId=_all skips filter, specific value overrides default
- Add ProductBreakdown interface for per-product aggregation
- Summary endpoint now returns productBreakdown[] alongside model/source breakdowns
- Enables admin to compare John's LysnrAI usage vs MindLyst usage
2026-02-15 19:47:23 -08:00
saravanakumardb1
1cf74d22fa feat(usage): add source/platform tracking + source breakdown in summary
- Add optional 'source' field to UsageDoc (desktop/web/ios/android)
- Add 'source' to UpsertUsageSchema validation
- Include source in upsert document ID to avoid cross-platform overwrites
- Add SourceBreakdown interface
- Aggregate sourceBreakdown in GET /usage/summary alongside modelBreakdown
- Clients can now pass source when reporting usage for per-app analytics
2026-02-15 18:57:16 -08:00
saravanakumardb1
b977e85bc2 feat(platform-service): add profile updates, tokens, and themes modules
Auth:
- PUT /auth/profile — self-service profile update (displayName, phone, bio, avatarUrl)
- ProfileUpdateSchema added to types.ts
- Repository update() expanded to accept profile fields

Tokens module (new):
- GET /tokens — list tokens (admin: all, user: own)
- POST /tokens — create API token (admin only)
- GET /tokens/count — count active tokens
- PATCH /tokens/:id — revoke token (admin only)
- DELETE /tokens/:id — delete token (super_admin only)

Themes module (new):
- GET /themes — list all themes (admin only)
- POST /themes — create theme (admin only)
- GET /themes/active — get active theme (public, no auth)
- GET /themes/:id — get theme by id (admin only)
- PUT /themes/:id — update theme (admin only)
- DELETE /themes/:id — delete theme (admin only)
- POST /themes/:id/activate — set theme as active (admin only)
2026-02-15 17:29:43 -08:00
saravanakumardb1
be3f5459bd feat(platform-service): add SSO login endpoint (/auth/sso)
- POST /auth/sso — accepts verified email + provider + productId
- Creates user if not exists (with subscription + license provisioning)
- Issues platform JWT tokens for existing SSO users
- Supports Microsoft and Google OAuth providers
- Added SsoLoginSchema to types.ts
2026-02-15 16:38:10 -08:00
saravanakumardb1
c7fb2eb357 feat(platform-service): add admin user management routes
- GET /auth/users — list users (paginated, admin-only)
- GET /auth/users/count — total + by-plan counts
- GET /auth/users/:id — get user by id
- PUT /auth/users/:id — update user (displayName, role, plan, status)
- DELETE /auth/users/:id — delete user
- repository: added list, count, countByPlan, update, remove functions
- types: added UpdateUserSchema
2026-02-15 16:21:26 -08:00
saravanakumardb1
aaf7ec5b59 fix(licenses): add deviceName and platform to ActivateLicenseSchema
Desktop and mobile clients send deviceName and platform in the activate
payload. Without these fields in the schema, they were silently stripped
by Zod. Now accepted as optional fields for contract alignment.
2026-02-15 15:41:52 -08:00
saravanakumardb1
daccbaea6c fix(stripe): remove dead syncUserPlan call to deleted backend /api/users/:userId/plan route
The Python backend users.py route was deleted in the backend cleanup.
Plan updates are already handled by authRepo.updatePlan() inline in
each webhook handler — the syncUserPlan fetch was redundant dead code.
2026-02-15 15:40:42 -08:00
saravanakumardb1
d829c41fd4 docs: update migration checklist — Phases 1-4 complete 2026-02-15 15:38:11 -08:00
saravanakumardb1
c6937b74a6 docs(migration): mark Phase 2 Commit 17 complete
- Updated Phase 2 checklist with Android migration commit hash 63aa2ae
2026-02-15 15:19:12 -08:00
saravanakumardb1
855ebffcf6 docs(migration): mark Phase 2 Commit 16 complete
- Added Phase 2 progress checklist
- Marked Commit 16 complete with learning_voice_ai_agent hash 26d2a8b
2026-02-15 15:15:08 -08:00
saravanakumardb1
e7c8023aa8 docs(migration): mark Commit 15 complete with test commit hash 2026-02-15 15:09:54 -08:00
saravanakumardb1
8a7a0495b0 test(platform-service): add route-level tests for Phase 1 migration behaviors
- Added auth register route tests for default provisioning and best-effort fallback
- Added license activate route tests for token issuance, product device limits, and lockout
- Added Stripe webhook route tests for any-product fallback and plan normalization
- Verified: tsc --noEmit clean, 23 test files / 189 tests passing
2026-02-15 15:09:23 -08:00
saravanakumardb1
d236f19d42 docs(migration): track Phase 1 commit progress and review fixes
- Added checklist with commit hashes for commits 9-14
- Marked commit 15 pending
- Documented post-implementation bugfix commits from systematic review
2026-02-15 15:01:54 -08:00
saravanakumardb1
b987dec92c fix(platform-service): make Stripe webhook product routing resilient
- Added cross-product fallback lookup by stripeCustomerId when metadata lacks productId
- Ensure invoice payments are stored under the resolved subscription productId
- Normalize checkout metadata plan value before persistence/sync
- Keep auth plan sync aligned with resolved product context
- Verified: tsc --noEmit clean, 20 test files / 183 tests passing
2026-02-15 15:01:02 -08:00
saravanakumardb1
a699dd9073 fix(platform-service): harden register/stripe flows for multi-product correctness
- Make auth register provisioning truly best-effort (warn on failure, do not fail signup)
- Process Stripe webhook events for all products (remove non-default skip)
- Derive updated subscription plan from Stripe price IDs on subscription.updated
- Sync derived plan to auth users and backend plan sync endpoint
- Verified: tsc --noEmit clean, 20 test files / 183 tests passing
2026-02-15 14:59:27 -08:00
saravanakumardb1
0c3c109bf1 feat(platform-service): add settings module with device overrides
- Added settings module (types, repository, routes)
- Endpoints: GET/PUT /settings, GET/PUT/DELETE /settings/device/:deviceId
- Enforced userId from JWT and productId request scoping
- Added settings Cosmos container registration and route registration in server
- Added module tests for settings schemas and route export
- Verified: tsc --noEmit clean, 20 test files / 183 tests passing
2026-02-15 14:57:20 -08:00
saravanakumardb1
84681cbf75 feat(platform-service): add user plan update to auth module for Stripe webhooks
- Added auth repository updatePlan(userId, productId, plan) helper
- Stripe webhook handlers now sync plan changes into auth users container
- Handles checkout completion and cancellation downgrade paths
- Keeps existing backend sync behavior intact
- Verified: tsc --noEmit clean, 19 test files / 178 tests passing
2026-02-15 14:47:26 -08:00
saravanakumardb1
a264538c5e feat(platform-service): register hook provisions subscription + license from product config
- /auth/register now validates product from products cache
- Automatically provisions initial subscription using product defaultPlan + trialDays
- Automatically provisions initial license using product licensePrefix + deviceLimits
- Keeps auth user creation as primary flow while adding provisioning side-effects
- Verified: tsc --noEmit clean, 19 test files / 178 tests passing
2026-02-15 14:44:31 -08:00
saravanakumardb1
5e38342930 feat(platform-service): licenses/activate issues JWT tokens + IP lockout
- /licenses/activate now enforces in-memory IP lockout window for failed attempts
- Device limit enforcement now reads from product config by plan (deviceLimits)
- Successful activation returns { license, accessToken, refreshToken }
- Re-activation on existing device also returns tokens
- Keeps existing license validity checks (status, expiry)
- Verified: tsc --noEmit clean, 19 test files / 178 tests passing
2026-02-15 14:42:58 -08:00
saravanakumardb1
17772ed42a feat(platform-service): auth/refresh returns both accessToken + refreshToken
- Refresh endpoint now rotates refresh token and returns both tokens
- Keeps existing refresh token validation semantics
- Verified: tsc --noEmit clean, 19 test files / 178 tests passing
2026-02-15 14:40:34 -08:00
saravanakumardb1
a9ac953ed1 feat(platform-service): add plan field to auth UserDoc + auth responses
- Added plan to auth UserDoc model and token payload typing
- Register flow initializes user.plan from product default plan
- Login/Register/Me responses now include user.plan
- Access tokens now include optional plan claim
- Verified: tsc --noEmit clean, 19 test files / 178 tests passing
2026-02-15 14:39:42 -08:00
saravanakumardb1
0fee7e9ee7 test(platform-service): add products module tests and fix product schema defaults
- Added products.test.ts covering CreateProductSchema and UpdateProductSchema
- Added route export smoke test for productRoutes
- Fixed CreateProductSchema packageName default validation (allow empty default)
- Verified: tsc --noEmit clean, 19 test files / 178 tests passing
2026-02-15 14:36:33 -08:00
saravanakumardb1
c0830e3dec refactor(platform-service): remove BILLING_INTERNAL_KEY guard from server.ts
- Billing routes (subscriptions, usage, plans, licenses) now registered directly
- No more X-Internal-Key header check — JWT-based productId auth is sufficient
- BILLING_INTERNAL_KEY removed from config schema and AKV secret resolution
- 166 tests pass, tsc clean
2026-02-15 14:30:30 -08:00
saravanakumardb1
60617ab050 refactor(platform-service): replace PRODUCT_ID with getRequestProductId(req) in all modules
- 26 files updated: all repositories accept productId parameter instead of env var
- All route handlers extract productId via getRequestProductId(req) (JWT → header → env fallback)
- Repositories: auth, flags, audit, notifications, licenses, plans, referrals, usage, subscriptions, invitations
- Routes: all above + promos, items, memory, public, ratelimit, stripe
- lib/webhooks.ts: dispatchWebhook accepts optional productId parameter
- Stripe webhook handler uses metadata-based productId (no client JWT available)
- Ratelimit default config uses DEFAULT_PRODUCT_ID at startup
- 166 tests pass, tsc --noEmit clean
2026-02-15 14:29:11 -08:00
saravanakumardb1
8e5c6dc2d6 refactor(platform-service): auth routes + types — add productId to login/register schemas
- LoginSchema and RegisterSchema now require productId field
- Login/Register routes use productId from request body (not env var)
- PRODUCT_ID import removed from auth/routes.ts
- Test fixtures updated with productId: 'lysnrai'
2026-02-15 14:18:59 -08:00