From 8f449a5ee5b7fa25c99b17df21a0a7ff21b343fd Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 May 2026 21:07:26 +0000 Subject: [PATCH] fix(platform): add temporary invttrdg product fallback --- .../src/modules/products/cache.ts | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/services/platform-service/src/modules/products/cache.ts b/services/platform-service/src/modules/products/cache.ts index 85e9f547..1f80ccce 100644 --- a/services/platform-service/src/modules/products/cache.ts +++ b/services/platform-service/src/modules/products/cache.ts @@ -7,6 +7,28 @@ import * as repository from './repository.js'; import type { ProductDoc } from './types.js'; const productCache = new Map(); +const TEMPORARY_FALLBACK_PRODUCTS: Record = { + // TODO(platform): remove this hardcoded invttrdg fallback after creating the + // real product in the platform-service /products registry. + invttrdg: { + id: 'invttrdg', + productId: 'invttrdg', + displayName: 'Investment Trading', + licensePrefix: 'INVTTRDG', + packageName: 'com.bytelyst.invttrdg', + defaultPlan: 'free', + trialDays: 14, + deviceLimits: { + free: 1, + pro: 3, + enterprise: 10, + }, + websiteUrl: 'https://invttrdg.bytelyst.com', + status: 'active', + createdAt: '2026-05-05T00:00:00.000Z', + updatedAt: '2026-05-05T00:00:00.000Z', + }, +}; /** * Load all products from Cosmos into memory. @@ -20,17 +42,20 @@ export async function loadProductCache(): Promise { /** Get a product by ID from cache. */ export function getProduct(productId: string): ProductDoc | undefined { - return productCache.get(productId); + return productCache.get(productId) ?? TEMPORARY_FALLBACK_PRODUCTS[productId]; } /** Check if a productId exists in cache. */ export function isValidProduct(productId: string): boolean { - return productCache.has(productId); + return productCache.has(productId) || Boolean(TEMPORARY_FALLBACK_PRODUCTS[productId]); } /** Get all cached products. */ export function getAllProducts(): ProductDoc[] { - return Array.from(productCache.values()); + return [ + ...Array.from(productCache.values()), + ...Object.values(TEMPORARY_FALLBACK_PRODUCTS).filter(product => !productCache.has(product.id)), + ]; } /** Current cache size (for tests/health). */