saravanakumardb1
7ffc60c490
feat(testing): create @bytelyst/testing shared package with 10 tests
...
Exports:
- createCosmosMocks(): full Cosmos DB mock factory for vitest
- TEST_USERS, TEST_JWT_SECRET, createTestTokenPayload(): auth fixtures
- injectGet/Post/Patch/Delete(): Fastify inject wrappers
- expectHealthOk(): health endpoint assertion helper
2026-02-12 22:59:28 -08:00
saravanakumardb1
428e973548
test(react-auth): add 10 tests with jsdom + React Testing Library
...
Tests: createAuthProvider factory, AuthProvider rendering, login/logout
flows, localStorage persistence, onLoginFallback, useAuth outside provider,
custom storage prefix.
2026-02-12 22:55:44 -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
11e79aa4f9
feat(react-auth): add onLoginFallback to createAuthProvider config
...
Allows dashboards to provide fallback login logic (e.g. mock credentials)
when the API is unavailable. Used by admin-dashboard-web.
2026-02-12 22:21:25 -08:00
saravanakumardb1
832eccafed
feat: add package tests (58 new) + @bytelyst/fastify-core package
...
Package tests added:
- @bytelyst/cosmos: 12 tests (client singleton, env vars, container registry)
- @bytelyst/config: 15 tests (base schema, loadConfig, product identity)
- @bytelyst/auth: 10 tests (JWT round-trip, password hash/verify)
- @bytelyst/api-client: 10 tests (fetch, safeFetch, auth injection)
- @bytelyst/design-tokens: 11 tests (loadTokens, generated file checks)
New package:
- @bytelyst/fastify-core: 8 tests (createServiceApp factory with CORS,
x-request-id, health endpoint, ServiceError handler)
Total: 246 tests passing (was 180)
2026-02-12 22:17:17 -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
fbcb39d52c
feat(logger): add @bytelyst/logger shared package
...
createLogger(config) factory for structured logging across dashboards and services.
- Dev: pretty-prints to stderr/stdout
- Prod: JSON structured output for log ingestion (Loki, Datadog, etc.)
- Exports: createLogger, Logger, LoggerConfig, LogLevel, LogPayload
2026-02-12 15:35:27 -08:00
saravanakumardb1
09c767295a
feat(design-tokens): generate platform token files (CSS, TS, Kotlin, Swift)
...
Updated generator to match existing MindLyst conventions:
- Kotlin: SCREAMING_SNAKE_CASE, Palette/Dark/Light/BrainGradient/Typography/Motion/Layout
- Swift: Color(hex: UInt), dark/light prefixes, Gradient(colors:), MindLystMotion, Color ext
- CSS: [data-theme] selectors, --ml-fs-*, --ml-elevation-*, --ml-motion-*, light theme
Generated 4 files:
- generated/tokens.css — CSS custom properties (dark + light themes)
- generated/tokens.ts — Full token tree as const
- generated/MindLystTokens.kt — KMP shared module (drop-in for existing)
- generated/MindLystTheme.swift — SwiftUI structs (drop-in for existing)
2026-02-12 12:15:07 -08:00
saravanakumardb1
b80d249c78
feat(design-tokens): add @bytelyst/design-tokens package
...
- Canonical bytelyst.tokens.json with colors, typography, spacing, radius, elevation, motion, breakpoints
- loadTokens() for programmatic access
- generate.ts script outputs 4 platform formats:
- tokens.css (CSS custom properties with --ml-* prefix)
- tokens.ts (TypeScript constants)
- MindLystTokens.kt (Kotlin object for KMP shared module)
- MindLystTheme.swift (Swift structs for SwiftUI)
- Shared across LysnrAI dashboards and MindLyst native apps
2026-02-12 11:22:52 -08:00
saravanakumardb1
cf8781cc11
feat(react-auth): add @bytelyst/react-auth package
...
- createAuthProvider<TUser>() factory returns typed AuthProvider + useAuth hook
- Configurable storagePrefix, loginEndpoint, mapLoginResponse, onLogout
- localStorage persistence for user, access token, refresh token
- Uses @bytelyst/api-client for login requests
- Replaces 3 duplicated auth-context.tsx files across LysnrAI dashboards
- Peer dep: react >=18.0.0, workspace dep: @bytelyst/api-client
2026-02-12 11:22:41 -08:00
saravanakumardb1
01624a2231
feat(api-client): add @bytelyst/api-client package
...
- createApiClient() factory with baseUrl, getToken, defaultHeaders
- fetch() method that throws on error
- safeFetch() method that returns { data, error } tuple (never throws)
- Auto-injects Authorization header from getToken callback
- Replaces duplicated apiFetch patterns in 3 dashboards
2026-02-12 11:20:04 -08:00
saravanakumardb1
602fa50216
feat(auth): add @bytelyst/auth package
...
- createJwtUtils() factory with configurable issuer and expiry (jose)
- extractAuth() middleware for Fastify request auth extraction
- requireRole() guard with multi-role support
- hashPassword() / verifyPassword() via bcryptjs
- getCurrentUser() helper for Next.js API routes (generic TUser)
- AuthPayload, TokenPayload, JwtUtils types
- NO dependency on @bytelyst/config (reads JWT_SECRET from process.env directly)
- Peer deps: jose >=5.0.0, bcryptjs >=2.4.0
2026-02-12 11:19:58 -08:00
saravanakumardb1
65bf79203b
feat(config): add @bytelyst/config package
...
- Zod-based baseEnvSchema (PORT, HOST, NODE_ENV, CORS_ORIGIN, SERVICE_NAME, COSMOS_*)
- loadConfig() with extension support for service-specific fields
- loadProductIdentity() reads product.json or falls back to env vars
- getProductId() convenience function
- Replaces 5 duplicated product-config.ts files across LysnrAI
- Peer dep: zod >=3.20.0
2026-02-12 11:19:49 -08:00
saravanakumardb1
2e9dcf49a8
feat(cosmos): add @bytelyst/cosmos package
...
- Singleton CosmosClient with env var config (COSMOS_ENDPOINT, COSMOS_KEY, COSMOS_DATABASE)
- Simple getContainer() for services
- Container registry with registerContainers(), getRegisteredContainer(), initializeAllContainers() for dashboards
- ContainerConfig type with partitionKeyPath and optional defaultTtl
- _resetClient() and _resetRegistry() for test isolation
- Peer dep: @azure/cosmos >=4.0.0
2026-02-12 11:19:42 -08:00
saravanakumardb1
9c0ab36171
feat(errors): add @bytelyst/errors package
...
- ServiceError base class with statusCode, message, details
- HTTP errors: BadRequest, Unauthorized, Forbidden, NotFound, Conflict, TooManyRequests
- 10 tests passing (vitest)
- Superset of all 4 service error files in LysnrAI
2026-02-12 11:19:35 -08:00