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
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
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
saravanakumardb1
8cc70db676
refactor(platform-service): auth/jwt.ts — productId from caller, issuer → 'bytelyst-platform'
...
- createAccessToken() and createRefreshToken() now require productId parameter
- Issuer changed from PRODUCT_ID env var to generic 'bytelyst-platform'
- verifyToken() validates against 'bytelyst-platform' issuer
- auth/routes.ts callers updated to pass productId (still from PRODUCT_ID env var for now)
- Refresh endpoint reads productId from user doc
2026-02-15 14:16:49 -08:00
saravanakumardb1
465d429e09
feat(platform-service): add Fastify onRequest hook to parse JWT → req.jwtPayload
...
- Best-effort JWT parsing on every request (non-blocking for unauthenticated routes)
- Attaches parsed payload to req.jwtPayload for downstream use by getRequestProductId()
- Invalid/expired tokens silently ignored — auth-required routes handle their own validation
2026-02-15 14:15:17 -08:00
saravanakumardb1
365061566a
feat(platform-service): add getRequestProductId() + getRequestProductConfig() helpers
...
- New lib/request-context.ts with product validation against cache
- Priority: JWT payload > X-Product-Id header > env var fallback
- Rejects unknown or disabled products with 400 Bad Request
- Augments FastifyRequest with jwtPayload type declaration
- getRequestProductConfig() for modules needing product-specific values
2026-02-15 14:14:17 -08:00
saravanakumardb1
755c16dbfb
feat(platform-service): add products module (types, repository, cache, routes)
...
- New products container in Cosmos DB (partition key: /id)
- ProductDoc: displayName, licensePrefix, deviceLimits, trialDays, status
- In-memory cache loaded on startup via loadProductCache()
- CRUD routes: GET/POST /products, GET/PUT /products/:id
- Cache refreshed after admin writes (create/update)
- Registered before all other modules in server.ts
2026-02-15 14:13:03 -08:00
e64bba258f
feat(platform-service): allow memory-items to store blob media refs
2026-02-15 03:50:51 -08:00
1011fd85f8
feat(platform-service): restrict blob SAS/list/info to user scope
2026-02-15 03:31:27 -08:00
17c41e8441
feat(platform-service): add memory-items API backed by Cosmos
2026-02-15 03:20:09 -08:00
saravanakumardb1
81999dcbb3
feat(services): wire AKV secret resolution in platform-service and extraction-service startup
2026-02-14 22:18:01 -08:00
saravanakumardb1
fb3bc750eb
fix: update .env.example comments, Grafana dashboard, and debug-service.md for consolidated services
2026-02-14 22:01:55 -08:00
saravanakumardb1
11ca4e95e3
docs: Phase 5 update AGENTS.md, package.json, monitoring for consolidated services
2026-02-14 21:54:09 -08:00
saravanakumardb1
81609e9358
fix: remove stale port references from monitoring, docs, and AI.dev skills
2026-02-14 21:48:21 -08:00
saravanakumardb1
29fc8124e4
refactor: merge tracker-service into platform-service
...
Phase 3 of service consolidation (5→2 services).
Moved modules:
- items (16 tests)
- comments (6 tests)
- votes (5 tests)
- public (16 tests) — rate-limited, no auth required
Changes:
- Copied 4 modules from tracker-service
- Added DEFAULT_PRODUCT_ID alias in product-config.ts (Gap 1)
- Created src/lib/auth.ts re-exporting extractAuth from @bytelyst/auth (Gap 2)
- Added @bytelyst/auth and @fastify/rate-limit to package.json (Gap 2)
- Registered itemRoutes, commentRoutes, voteRoutes, publicRoutes in server.ts
- Public routes at top level (no auth scope)
- Removed tracker-service directory
Tests: 158 passing (115 + 43 from tracker = 158) ✅
Build: clean ✅
Service consolidation Phases 1-3 complete:
- growth-service: merged ✅
- billing-service: merged ✅
- tracker-service: merged ✅
Remaining: 2 services (platform-service + extraction-service)
2026-02-14 21:34:21 -08:00
saravanakumardb1
f13c676139
refactor: merge billing-service into platform-service
...
Phase 2 of service consolidation (5→2 services).
Moved modules:
- subscriptions (9 tests)
- usage (7 tests)
- plans (9 tests)
- licenses (7 tests)
- stripe (0 tests — webhook signature verified at runtime)
Changes:
- Copied 5 modules + stripe.ts lib from billing-service
- Added billing env vars to config schema (Stripe, internal key, etc.)
- Scoped billing routes with internal key auth guard (Gap 3)
- When BILLING_INTERNAL_KEY is set, billing routes require x-internal-key header
- When unset, billing routes are open (dev mode)
- Stripe routes always outside scope (own webhook signature check)
- Removed billing-service directory
Tests: 115 passing (83 + 32 from billing = 115) ✅
Build: clean ✅
2026-02-14 21:31:04 -08:00
saravanakumardb1
05008ee04f
refactor: merge growth-service into platform-service
...
Phase 1 of service consolidation (5→2 services).
Moved modules:
- invitations (12 tests)
- referrals (9 tests)
- promos (7 tests)
Changes:
- Copied 3 modules + webhooks.ts lib from growth-service
- Added stripe dep to platform-service package.json
- Added webhook env vars to config schema
- Registered invitationRoutes, referralRoutes, promoRoutes in server.ts
- Removed growth-service directory
Tests: 83 passing (was 55 + 28 from growth = 83) ✅
Build: clean ✅
2026-02-14 21:27:44 -08:00
95b45a9fd3
fix(cosmos): init containers on startup for local compose
2026-02-14 20:57:17 -08:00
16bc06d84a
Add local health-check script; mark health verification
2026-02-14 18:59:01 -08:00
607fcbf3d7
fix(docker): make pnpm deploy work under pnpm v10
2026-02-14 18:30:00 -08:00
32f8f7ccf5
chore(docker): include new workspace packages in builds
2026-02-14 16:48:09 -08:00
e9b33fb518
feat(monitoring): add @bytelyst/monitoring package
2026-02-14 15:57:41 -08:00
125eb03745
feat(blob): add @bytelyst/blob shared package
2026-02-14 15:53:33 -08:00
saravanakumardb1
5c1744d3a4
feat(extraction): Phase 6 advanced features (6.1-6.8)
...
- 6.1-6.2: Entity visualization components (bar chart, pie chart, timeline) [in LysnrAI repo]
- 6.3-6.4: Async job queue — POST /extract/jobs, GET /extract/jobs/:id, GET /extract/jobs
- 6.5-6.6: Model registry with tier (standard/premium/free/mock) + GET /extract/models
- 6.7-6.8: Multi-language detection (es/fr/de/pt/ja/zh/ko/ar) + prompt enrichment
- ExtractMetadata.language field added to Python models
- 46 TS tests passing, build clean
2026-02-14 14:08:02 -08:00
saravanakumardb1
b8c0a73e89
feat(extraction): Phase 5 observability + error handling (5.7-5.12)
...
- 5.7: Enhanced structured logging with userId, productId, cacheHit, tokenCount
- 5.8: Metrics module (counters + histograms) + /extract/metrics endpoint
- 5.9: Grafana dashboard config for extraction-service (Loki queries)
- 5.10: Error mapping — sidecar errors → proper HTTP status codes (408, 429, 502, 503)
- 5.11: Circuit breaker for Python sidecar (5 failures → 30s OPEN)
- 5.12: Graceful degradation — circuit open returns 503, cached results still served
- 46 TS tests passing
2026-02-14 14:04:59 -08:00
saravanakumardb1
9c8a3169dc
feat(extraction): Phase 5 caching + cost controls (5.1-5.6)
...
- 5.1: Python sidecar LRU cache (cache.py) with configurable TTL + max size
- 5.2: Fastify-level cache with X-Extraction-Cache HIT/MISS header + /extract/cache-stats
- 5.3-5.5: Per-user daily quota (free=10, pro=100, enterprise=unlimited) with 429 response
- 5.6: GET /extract/usage endpoint for admin usage reporting
- Both Python + TS caches use sha256(taskId:modelId:text) keys
- 46 TS tests + 29 Python tests still passing
2026-02-14 14:02:21 -08:00
saravanakumardb1
37343ae57b
feat(extraction): add Dockerfile + supervisord for extraction-service
...
- Multi-stage: Node.js build + Python sidecar + supervisord runtime
- Stage 1: pnpm workspace build for Fastify TS service
- Stage 2: pip install langextract + FastAPI deps
- Stage 3: node:22-alpine + python3 + supervisord
- supervisord manages both Fastify (4005) and uvicorn (4006)
2026-02-14 13:57:41 -08:00
saravanakumardb1
c2d626c7b5
chore(extraction): add Python .gitignore, remove cached .pyc files
2026-02-14 13:49:39 -08:00
saravanakumardb1
c9d5c0caed
feat(extraction): integration tests + Python tests + fix langextract API
...
- 6 route integration tests (mock sidecar via vitest vi.mock)
- 12 task CRUD route tests (mock repository)
- 29 Python tests: 10 extractor, 12 models, 7 app endpoints
- Fix extractor.py: correct lx.extract() API (text_or_documents positional, prompt_description)
- Mock fallback when no GEMINI_API_KEY or USE_MOCK_EXTRACTOR=true
- 46 TS tests + 29 Python tests = 75 total
2026-02-14 13:49:18 -08:00
saravanakumardb1
6a49823e1d
feat(extraction): add task seed module + 7 seed tests
...
- seed.ts: 5 built-in task definitions with idempotent upsert
- seed.test.ts: 7 tests validating task schema compliance
- 28 total tests passing
2026-02-14 13:36:46 -08:00