Commit Graph

319 Commits

Author SHA1 Message Date
saravanakumardb1
7ca2139418 refactor(storage): migrate to storage abstraction 2026-03-02 09:07:33 -08:00
saravanakumardb1
5401fad419 refactor(platform-service): migrate webhooks/routes and migrations/runner from cosmos.js to datastore 2026-03-02 02:02:47 -08:00
saravanakumardb1
b69abf44c7 refactor(platform-service): migrate remaining 14 repositories to @bytelyst/datastore
Migrated modules: audit, auth, invitations, items, jobs, licenses,
maintenance, notifications, subscriptions, telemetry, tokens, usage,
waitlist, webhooks.

Updated 4 test files (notifications, subscriptions, tokens, usage) from
Cosmos SDK mocks to MemoryDatastoreProvider.

Zero cosmos.js imports remain in modules/. All 66 test files pass (746 tests).
2026-03-02 01:06:24 -08:00
saravanakumardb1
e355cb0c1b feat(platform-service): migrate 7 more repositories to @bytelyst/datastore (exports, plans, status, sessions, referrals, ip-rules, delivery) — 753/753 tests pass 2026-03-02 00:54:55 -08:00
saravanakumardb1
4d126cb051 feat(platform-service): migrate 6 repositories to @bytelyst/datastore (flags, settings, comments, votes, products, themes) — 756/756 tests pass 2026-03-02 00:51:03 -08:00
saravanakumardb1
b33d3cf2b3 feat(platform): add webhook subscriptions module, DB migration runner, Swagger UI — complete 23/25 roadmap items 2026-03-01 23:38:48 -08:00
saravanakumardb1
24d7896599 refactor(platform-service): migrate product-specific modules to product repo backends
Remove 23 product-specific module directories from platform-service:
- ChronoMind: timers, routines, households, shared-timers, webhooks
- JarvisJr: jarvis-agents, jarvis-sessions, jarvis-memory, jarvis-teams, marketplace
- NomGap: fasting-sessions, fasting-protocols, body-stages, social-fasting, meal-log, push-triggers
- PeakPulse: peak-sessions, peak-routes
- MindLyst: brains, memory, reflections, daily-briefs, streaks

Update server.ts: remove product module imports and registrations
Update cosmos-init.ts: remove product-specific container definitions
Clean up server.test.ts: remove 5 stale vi.mock() calls
Update AGENTS.md: add section 13 (product backends), update test counts

Platform-service tests: 759 passing (platform-common only)
Product backends: PeakPulse 32, ChronoMind 171, JarvisJr 198, NomGap 152, MindLyst 59
2026-03-01 20:38:32 -08:00
saravanakumardb1
92a6929238 fix(delivery): replace hardcoded product URL/name maps with dynamic product cache lookup 2026-03-01 17:44:54 -08:00
saravanakumardb1
2f199cb67a fix(auth): replace hardcoded product ID lists with dynamic getAllProducts() in reset-password and verify-email 2026-03-01 17:43:32 -08:00
saravanakumardb1
bd7e78641e fix(platform): replace Math.random() IDs with crypto.randomUUID() in 5 P2 modules 2026-03-01 17:42:28 -08:00
saravanakumardb1
a2461fc26a fix(platform): replace 3 console.* calls with process.stdout/stderr in cosmos-init + server startup 2026-03-01 17:41:02 -08:00
saravanakumardb1
f97f7a0adb fix(marketplace): validate agentListingIds/individualPrices length match in buildAgentPack (18 tests) 2026-03-01 17:04:28 -08:00
saravanakumardb1
573f54888c fix(jarvis-teams): enforce maxMembers capacity in addMember, return null on full/missing team (25 tests) 2026-03-01 17:03:49 -08:00
saravanakumardb1
5088507400 feat(marketplace): verified creator program — applications, badges, agent pack bundles with discount validation (17 tests) 2026-03-01 16:50:38 -08:00
saravanakumardb1
66d6aa7b5b feat(jarvis-teams): enterprise teams module — team CRUD, member management, shared agents, analytics (23 tests) 2026-03-01 16:48:26 -08:00
saravanakumardb1
d0cb3a2238 feat(marketplace): purchase repository — build/complete/refund docs, 70/30 revenue share, author earnings aggregation (15 tests) 2026-03-01 16:39:38 -08:00
saravanakumardb1
063efa8e41 feat(marketplace): automated certification — prompt-safety, content-policy, payload-validator, engine (25 tests) 2026-03-01 14:26:23 -08:00
saravanakumardb1
59552712a8 feat(platform): wire marketplace routes into server.ts + add server test mock 2026-03-01 08:06:12 -08:00
saravanakumardb1
7aed0ebec3 feat(platform): marketplace routes — 30 Fastify endpoints (catalog, consumer, author, admin) 2026-03-01 08:04:39 -08:00
saravanakumardb1
761a0c17f4 feat(platform): marketplace module — types, repository, 52 tests passing 2026-03-01 08:01:45 -08:00
saravanakumardb1
383a8dad32 feat(peak-sessions): add clientId for idempotent sync, findByClientId repo method, explicit 204 returns 2026-03-01 07:55:02 -08:00
saravanakumardb1
d10b898ba5 feat(peak-routes): add PeakPulse track point storage module — types, repository, routes, 10 tests 2026-03-01 07:40:19 -08:00
saravanakumardb1
b20e1c6165 feat(peak-sessions): add PeakPulse session sync module — types, repository, routes, 20 tests 2026-03-01 07:12:28 -08:00
saravanakumardb1
dcabe46de2 feat(jarvis): add jarvis-agents, jarvis-sessions, jarvis-memory modules (63 tests) 2026-03-01 07:09:12 -08:00
saravanakumardb1
33160a5daa feat(platform-service): add brains, daily-briefs, reflections, streaks modules 2026-02-28 20:24:06 -08:00
saravanakumardb1
a97b730a89 feat(flags): seed default feature flags for all products on startup 2026-02-28 19:33:22 -08:00
saravanakumardb1
711621e3d9 fix(telemetry): add 'native' to ChannelEnum for mobile app clients 2026-02-28 19:26:52 -08:00
saravanakumardb1
1b2a5d5483 fix(platform-service): register 13 missing MindLyst Cosmos containers
Add containers used by MindLyst web API routes to platform-service
cosmos-init so the shared database has a single authoritative registry:

  share_cards, notification_log, analytics_events, brain_packs,
  chat_sessions, ab_experiments, waitlist_entries, email_captures,
  engagement_campaigns, context_triggers, monitoring_reports,
  nudge_state, triage_retries

Note: 'referrals' is intentionally skipped — the growth module already
registers it with /id partition key, but MindLyst uses /userId. This
partition key mismatch requires a separate data migration to reconcile.

All 1141 platform-service tests pass.
2026-02-28 19:23:04 -08:00
saravanakumardb1
ba2641c552 feat(platform-service): add push notification triggers module (6 endpoints, 22 tests)
- 7 trigger types: streak_risk, fast_milestone, stage_transition, social_invite, weekly_digest, achievement_unlocked, refeeding_reminder
- Built-in templates with variable interpolation
- CRUD + batch create + pending trigger query + status updates + stats
- push_triggers container (TTL 30d)
- 1,112 total platform-service tests passing
2026-02-28 14:10:11 -08:00
saravanakumardb1
20e0ef2201 feat(platform-service): add P2 Product Intelligence modules (5 modules, 61 tests)
- experiments: A/B testing with FNV-1a deterministic variant assignment (7 endpoints, 15 tests)
- analytics: metric ingest + daily/weekly/monthly rollup queries (3 endpoints, 14 tests)
- feedback: in-app bug/feature/praise submission + admin triage (6 endpoints, 14 tests)
- impersonation: admin user impersonation with audit trail (4 endpoints, 6 tests)
- changelog: public product changelog with admin CRUD (6 endpoints, 12 tests)
- 6 new Cosmos containers added to cosmos-init.ts
- All 5 route modules registered in server.ts
- 1,090 total platform-service tests passing
2026-02-28 14:04:07 -08:00
saravanakumardb1
7d5ed86724 feat: add universal prep-consumer.sh for portable Docker/CI builds + fix tsc errors 2026-02-28 12:32:11 -08:00
saravanakumardb1
4e94ecd721 feat(auth): add forgot-password/change-password API routes to admin dashboard + wire email delivery
Admin dashboard:
- platform-client.ts: Added forgotPasswordViaService, changePasswordViaService, deleteAccountViaService
- app/api/auth/forgot-password/route.ts: New API route proxying to platform-service
- app/api/auth/change-password/route.ts: New API route for authenticated password change

Platform-service (from prior session):
- auth/routes.ts: Added /auth/change-password and DELETE /auth/account endpoints, wired email verification on register
- auth/types.ts: Added ChangePasswordSchema and DeleteAccountSchema
- delivery/subscribers.ts: Updated password reset subscriber, added email verification subscriber
- delivery/channels/email.ts: Added ByteLyst email API provider (sendViaBytelyst)
- delivery/types.ts: Added 'bytelyst' provider
- events/types.ts: Added resetToken/displayName to user.password_reset, added user.email_verification_requested event
2026-02-28 04:17:04 -08:00
saravanakumardb1
27f271d983 feat(platform): add P1 operational maturity modules — sessions, maintenance, exports, IP rules
- modules/sessions: device session tracking, revoke one/all, admin force-revoke (9 tests)
- modules/maintenance: 4 modes (off/read_only/maintenance/emergency), bypass roles/IPs, scheduled windows (14 tests)
- modules/exports: GDPR data export jobs for users/audit/telemetry/usage/subscriptions/licenses (10 tests)
- modules/ip-rules: IP allow/deny with CIDR matching, temporary blocks with expiry (10 tests)
- cosmos-init: 4 new containers (sessions, ip_rules, export_jobs, maintenance_windows)
- 1029 platform-service tests passing across 74 test files
2026-02-28 02:47:22 -08:00
saravanakumardb1
069d1ffda9 docs: add 19 reusable AI coding agent skills + sessions module scaffold 2026-02-28 02:41:22 -08:00
saravanakumardb1
662d417267 feat(platform): add email delivery module, wire event bus into auth, update roadmap
- modules/delivery: 8 email templates, renderer, SendGrid/Postmark/console adapters, dispatcher, delivery log, 21 tests
- modules/delivery/subscribers: event bus listeners for user.created, password_reset, email_verified
- auth/routes: emit bus events on register, forgot-password, verify-email (fire-and-forget)
- cosmos-init: delivery_log container (pk /pk, 90d TTL)
- roadmap: updated inventory (30 modules, 14 packages, 988 tests), marked P0 items complete
- 988 platform-service + 14 events = 1002 total tests passing
2026-02-28 02:36:58 -08:00
saravanakumardb1
772f428967 feat(platform): add P0 foundational modules — event bus, scheduled jobs, password reset, email verification, status page 2026-02-28 02:29:08 -08:00
saravanakumardb1
9a5e93bf05 feat(nomgap): add social-fasting + meal-log modules (47 tests, 2 Cosmos containers) 2026-02-28 00:37:46 -08:00
saravanakumardb1
5e8f133816 feat(webhooks): add webhook subscriptions module — 15 event types, HMAC signing, retry delivery 2026-02-28 00:27:32 -08:00
saravanakumardb1
b4237acaa2 feat(chronomind): add routines, households, shared-timers modules (88 new tests, 847 total) 2026-02-28 00:05:18 -08:00
saravanakumardb1
c1a1f86cd6 feat(timers): add timer CRUD endpoints for ChronoMind cloud sync (42 new tests, 759 total) 2026-02-27 23:48:31 -08:00
saravanakumardb1
1744bcf63f feat(api): NomGap fasting modules — sessions CRUD + stats, 14 built-in protocols + custom CRUD, body stages + autophagy confidence (47 new tests, 717 total) 2026-02-27 22:32:28 -08:00
saravanakumardb1
ca70a05e1d feat(flags): add region, osVersion targeting to feature flags
- Add OsVersionRange interface + Zod schema (platform, minVersion?, maxVersion?)
- Add regions[] and osVersions[] to FeatureFlagDoc, CreateFlagSchema, UpdateFlagSchema
- Add compareVersions() helper for dot-separated semver comparison
- Extend GET /flags/poll with ?region and ?osVersion query params
- Region targeting: flag only returned if client region is in flag's regions list
- OS version targeting: per-platform min/max version range filtering
- Add 10 new tests (schema validation, compareVersions edge cases)
- 634 tests passing, tsc clean
2026-02-17 20:53:48 -08:00
saravanakumardb1
51e2ecdec8 test(telemetry): Phase 3 regression tests — UpdateClusterSchema, ClusterStatusEnum, extractClientIp (614→624 tests) 2026-02-17 11:24:59 -08:00
saravanakumardb1
788ee57935 docs(telemetry): update routes doc comment with all 14 endpoints 2026-02-17 11:23:38 -08:00
saravanakumardb1
08b9642408 fix(telemetry): 3 bugs — Slack Block Kit text key, cluster reopen clears resolution, affectedInstallIds uses correct ID 2026-02-17 11:22:13 -08:00
saravanakumardb1
0bfd4bdf22 feat(telemetry): geo distribution endpoint (GET /telemetry/geo) with Cosmos GROUP BY aggregation 2026-02-17 11:13:55 -08:00
saravanakumardb1
61c919a916 feat(telemetry): Phase 3 — policy preview endpoint (count matching clients from recent events) 2026-02-17 10:59:13 -08:00
saravanakumardb1
2f61ea517c feat(telemetry): Phase 3 — geo enrichment, Prometheus metrics export endpoint 2026-02-17 10:56:19 -08:00
saravanakumardb1
80a4459f81 docs: update documentation 2026-02-17 10:49:14 -08:00
saravanakumardb1
2fb341048e feat(telemetry): Phase 3 — rate limiting, batch dedup, ETag config caching (614 tests) 2026-02-17 10:24:07 -08:00
saravanakumardb1
20f77d5a50 test(telemetry): add route-logic tests — containsPII, computePk, normalizeMessage, fingerprint, policyMatch, mergePolicies (34→77 tests) 2026-02-17 09:42:57 -08:00
saravanakumardb1
ce4c4ff53d feat(telemetry): add telemetry module — ingest, config, query, clusters, policies (34 tests) 2026-02-17 09:06:43 -08:00
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
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
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
11ca4e95e3 docs: Phase 5 update AGENTS.md, package.json, monitoring for consolidated services 2026-02-14 21:54:09 -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
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
125eb03745 feat(blob): add @bytelyst/blob shared package 2026-02-14 15:53:33 -08:00
saravanakumardb1
261181b182 feat(docker): rewrite service Dockerfiles for pnpm monorepo builds
- All 4 service Dockerfiles now use repo root as build context
- Multi-stage: pnpm install → build packages+service → pnpm deploy for production
- docker-compose.yml updated with context: . and dockerfile paths
- Added scripts/docker-prep.sh convenience wrapper
- Docker build blocked by corporate proxy SSL (not a code issue)
2026-02-12 23:48:18 -08:00
saravanakumardb1
446201b423 feat(platform-service): update Dockerfile for pnpm workspace support
- Add proper workspace dependency resolution
- Build packages before service
- Use pnpm deploy for production
- Add docker-prep.sh script for helper commands
2026-02-12 23:43:40 -08:00
saravanakumardb1
63c08dbb0a refactor(services): integrate @bytelyst/fastify-core into all 4 services
Replaced duplicated server setup code with createServiceApp() factory:
- platform-service: 91 → 39 lines
- billing-service: 105 → 51 lines (keeps service-specific internal key auth)
- growth-service: 83 → 33 lines
- tracker-service: 88 → 36 lines

Enhanced fastify-core with optional Swagger + Prometheus metrics support.
Total reduction: ~208 lines of duplicated boilerplate eliminated.
All 246 tests pass.
2026-02-12 22:53:22 -08:00
saravanakumardb1
90b9cf93d8 fix(common): configure ESLint 9 and fix lint issues
- Added @eslint/js dependency
- Updated eslint.config.js for ESLint 9 compatibility
- Added required globals (crypto, localStorage, React, etc.)
- Fixed unused imports and variables
- Disabled sort-imports temporarily
- Formatted all files with Prettier
2026-02-12 16:37:30 -08:00
saravanakumardb1
86a56339ab fix: replace Math.random() IDs with crypto.randomUUID() across all services
- billing-service: licenses, subscriptions (pay_, lic_)
- growth-service: invitations, referrals (inv_, ref_)
- platform-service: auth, audit (usr_, aud_)
- tracker-service: items, comments, votes, public (trk_, cmt_, vote_)
- Add votes.test.ts — closes the only missing module test
2026-02-12 13:03:09 -08:00
saravanakumardb1
4ae7a9d023 refactor(services): rewire lib/ to @bytelyst/* packages + add docker-compose
Rewired all 4 services:
- lib/errors.ts → re-exports from @bytelyst/errors
- lib/cosmos.ts → re-exports from @bytelyst/cosmos
- lib/product-config.ts → uses loadProductIdentity()/getProductId() from @bytelyst/config
- lib/config.ts → kept self-contained (zod v3/v4 type mismatch with loadConfig)

Added workspace deps (@bytelyst/errors, @bytelyst/cosmos, @bytelyst/config) to all 4 services.
Added docker-compose.yml with Loki, Grafana, Traefik, and all 4 services.
Added .env.example with required env vars.
Added passWithNoTests to vitest.config.ts.
Pinned root zod to ^3.24.0 to match service zod versions.

All 12 projects build. 175 tests passing.
2026-02-12 11:49:42 -08:00
saravanakumardb1
e1ab956ac3 feat(services): add platform-service (auth, audit, flags, notifications, blob)
- Copied as-is from learning_voice_ai_agent/services/platform-service
- 55 tests passing (vitest)
- Fastify 5 + Cosmos DB + jose + bcryptjs + Zod
- Modules: auth, audit, flags, notifications, blob, ratelimit
- Port 4003
2026-02-12 11:39:00 -08:00