@retrivora-ai/rag-engine 2.3.6 → 2.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{BatchProcessor-Dfn23VAd.d.mts → BatchProcessor-BhLczWj5.d.mts} +100 -2
  2. package/dist/{BatchProcessor-ByBl-1MA.d.ts → BatchProcessor-C42_RVWO.d.ts} +100 -2
  3. package/dist/handlers/index.d.mts +1 -1
  4. package/dist/handlers/index.d.ts +1 -1
  5. package/dist/handlers/index.js +340 -172
  6. package/dist/handlers/index.mjs +342 -174
  7. package/dist/{index-ejOWsaqb.d.ts → index-BQd6Bax0.d.ts} +1 -1
  8. package/dist/{index-xxQOFx-u.d.mts → index-C7aHK7_g.d.mts} +1 -1
  9. package/dist/index.d.mts +2 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +114 -87
  12. package/dist/index.mjs +114 -87
  13. package/dist/server.d.mts +263 -37
  14. package/dist/server.d.ts +263 -37
  15. package/dist/server.js +957 -178
  16. package/dist/server.mjs +949 -180
  17. package/package.json +1 -1
  18. package/src/LicensedRetrivora.ts +273 -0
  19. package/src/components/ChatWidget.tsx +0 -1
  20. package/src/components/ConfigProvider.tsx +2 -1
  21. package/src/config/LicenseConfigResolver.ts +296 -0
  22. package/src/config/serverConfig.ts +75 -16
  23. package/src/core/ConfigFetcher.ts +36 -3
  24. package/src/core/DatabaseStorage.ts +13 -13
  25. package/src/core/LicenseValidator.ts +5 -3
  26. package/src/core/LicenseVerifier.ts +85 -120
  27. package/src/core/Retrivora.ts +1 -1
  28. package/src/core/VectorPlugin.ts +1 -1
  29. package/src/handlers/index.ts +25 -11
  30. package/src/index.ts +9 -0
  31. package/src/llm/providers/UniversalLLMAdapter.ts +67 -12
  32. package/src/providers/vectordb/PineconeProvider.ts +69 -2
  33. package/src/server.ts +23 -1
  34. package/src/telemetry/TelemetryService.ts +330 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retrivora-ai/rag-engine",
3
- "version": "2.3.6",
3
+ "version": "2.3.8",
4
4
  "description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
5
5
  "author": "Abhinav Alkuchi",
6
6
  "license": "UNLICENSED",
@@ -0,0 +1,273 @@
1
+ /**
2
+ * LicensedRetrivora — End-user facing SDK that only requires:
3
+ * - License Key (JWT from Retrivora)
4
+ * - Project ID (workspace identifier)
5
+ *
6
+ * Everything else (models, vector DB, embeddings) is resolved from
7
+ * the Retrivora admin dashboard based on tier.
8
+ *
9
+ * NOTE: This is a SERVER-ONLY module. Import from '@retrivora-ai/rag-engine/server'
10
+ * Do NOT import in client components.
11
+ */
12
+
13
+ import { LicenseConfigResolver } from './config/LicenseConfigResolver';
14
+ import { Pipeline } from './core/Pipeline';
15
+ import { RagConfig, VectorDBConfig, LLMConfig, EmbeddingConfig } from './config/RagConfig';
16
+ import {
17
+ initializeTelemetryService,
18
+ getTelemetryService,
19
+ shutdownTelemetryService,
20
+ EventType,
21
+ } from './telemetry/TelemetryService';
22
+ import { IngestDocument, ChatResponse } from './types';
23
+
24
+ export interface LicensedRetrivoraOptions {
25
+ licenseKey: string;
26
+ projectId: string;
27
+ userTelemetryUrl?: string; // Optional: user's telemetry endpoint
28
+ enableTelemetry?: boolean; // Default: true
29
+ }
30
+
31
+ /**
32
+ * End-user facing SDK for Retrivora RAG engine
33
+ */
34
+ export class LicensedRetrivora {
35
+ private licenseKey: string;
36
+ private projectId: string;
37
+ private pipeline?: Pipeline;
38
+ private ragConfig?: RagConfig;
39
+ private initialized: boolean = false;
40
+
41
+ constructor(options: LicensedRetrivoraOptions) {
42
+ this.licenseKey = options.licenseKey;
43
+ this.projectId = options.projectId;
44
+
45
+ // Initialize telemetry if enabled
46
+ if (options.enableTelemetry !== false) {
47
+ initializeTelemetryService(this.projectId, this.licenseKey, options.userTelemetryUrl);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Initialize the SDK by validating license and fetching config
53
+ */
54
+ private generateId(): string {
55
+ return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
56
+ }
57
+
58
+ /**
59
+ * Initialize the SDK by validating license and fetching config
60
+ */
61
+ async initialize(): Promise<void> {
62
+ if (this.initialized) {
63
+ console.log('[LicensedRetrivora] Already initialized');
64
+ return;
65
+ }
66
+
67
+ console.log('[LicensedRetrivora] Initializing with license key...');
68
+ const operationId = this.generateId();
69
+
70
+ try {
71
+ // Resolve configuration from license tier
72
+ const { llmConfig, embeddingConfig, vectorDbConfig, tierConfig } =
73
+ await LicenseConfigResolver.resolveFromLicense(this.licenseKey, this.projectId);
74
+
75
+ // Log successful configuration load
76
+ const telemetry = getTelemetryService();
77
+ if (telemetry) {
78
+ telemetry.recordEvent({
79
+ eventType: EventType.CONFIGURATION_LOADED,
80
+ operationId,
81
+ metadata: {
82
+ tier: tierConfig.tier,
83
+ llmModel: tierConfig.llmModel,
84
+ embeddingModel: tierConfig.embeddingModel,
85
+ vectorDb: tierConfig.vectorDb.provider,
86
+ },
87
+ });
88
+ }
89
+
90
+ // Build RAG config
91
+ this.ragConfig = {
92
+ projectId: this.projectId,
93
+ licenseKey: this.licenseKey,
94
+ llm: llmConfig,
95
+ embedding: embeddingConfig,
96
+ vectorDb: vectorDbConfig,
97
+ rag: {
98
+ topK: tierConfig.topK,
99
+ chunkSize: tierConfig.chunkSize,
100
+ chunkOverlap: tierConfig.chunkOverlap,
101
+ scoreThreshold: 0,
102
+ },
103
+ telemetry: {
104
+ enabled: true,
105
+ url: 'https://www.retrivora.com/api/telemetry',
106
+ },
107
+ };
108
+
109
+ // Initialize pipeline
110
+ this.pipeline = new Pipeline(this.ragConfig);
111
+ await this.pipeline.initialize();
112
+
113
+ this.initialized = true;
114
+ console.log(`[LicensedRetrivora] Initialized successfully for tier: ${tierConfig.tier}`);
115
+ } catch (error) {
116
+ const telemetry = getTelemetryService();
117
+ if (telemetry && error instanceof Error) {
118
+ telemetry.recordError(error, { operationId });
119
+ await telemetry.flush();
120
+ }
121
+ throw error;
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Ingest documents (upload files to vector database)
127
+ * Returns success/failure status to end-user
128
+ */
129
+ async ingest(documents: IngestDocument[]): Promise<{ success: boolean; message: string; documentIds?: string[] }> {
130
+ if (!this.initialized || !this.pipeline) {
131
+ throw new Error('[LicensedRetrivora] SDK not initialized. Call initialize() first.');
132
+ }
133
+
134
+ const operationId = this.generateId();
135
+ const telemetry = getTelemetryService();
136
+ const startTime = Date.now();
137
+
138
+ try {
139
+ console.log(`[LicensedRetrivora] Starting ingestion of ${documents.length} document(s)`);
140
+
141
+ // Ingest documents
142
+ const results = await this.pipeline.ingest(documents);
143
+
144
+ const durationMs = Date.now() - startTime;
145
+
146
+ // Record successful ingestion
147
+ if (telemetry) {
148
+ for (const result of results) {
149
+ telemetry.recordDocumentIngested({
150
+ documentId: String(result.docId),
151
+ documentName: String(result.docId),
152
+ documentSize: 0, // TODO: track actual size
153
+ chunksGenerated: result.chunksIngested,
154
+ durationMs,
155
+ });
156
+ }
157
+ }
158
+
159
+ const successCount = results.length;
160
+ return {
161
+ success: successCount > 0,
162
+ message: `Successfully ingested ${successCount} document(s). Data is now available for search.`,
163
+ documentIds: results.map(r => String(r.docId)),
164
+ };
165
+ } catch (error) {
166
+ const durationMs = Date.now() - startTime;
167
+
168
+ if (telemetry && error instanceof Error) {
169
+ telemetry.recordError(error, { operationId, durationMs });
170
+ await telemetry.flush();
171
+ }
172
+
173
+ console.error('[LicensedRetrivora] Ingestion failed:', error);
174
+ throw error;
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Execute a user query and get response
180
+ * Returns only the response text and sources (abstracted from underlying models)
181
+ */
182
+ async query(queryText: string, options?: { topK?: number }): Promise<ChatResponse> {
183
+ if (!this.initialized || !this.pipeline) {
184
+ throw new Error('[LicensedRetrivora] SDK not initialized. Call initialize() first.');
185
+ }
186
+
187
+ const operationId = this.generateId();
188
+ const telemetry = getTelemetryService();
189
+ const startTime = Date.now();
190
+
191
+ try {
192
+ console.log(`[LicensedRetrivora] Executing query: "${queryText.substring(0, 100)}..."`);
193
+
194
+ // Execute query
195
+ const response = await this.pipeline.runNormalQuery(queryText);
196
+
197
+ const durationMs = Date.now() - startTime;
198
+
199
+ // Record query execution
200
+ if (telemetry) {
201
+ telemetry.recordQueryExecuted({
202
+ queryText,
203
+ resultCount: response.sources?.length || 0,
204
+ durationMs,
205
+ operationId,
206
+ });
207
+ }
208
+
209
+ // Return abstracted response (hide implementation details)
210
+ return {
211
+ reply: response.reply,
212
+ sources: response.sources,
213
+ };
214
+ } catch (error) {
215
+ const durationMs = Date.now() - startTime;
216
+
217
+ if (telemetry && error instanceof Error) {
218
+ telemetry.recordError(error, { operationId, durationMs });
219
+ await telemetry.flush();
220
+ }
221
+
222
+ console.error('[LicensedRetrivora] Query failed:', error);
223
+ throw error;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Get license tier information (for UI display if needed)
229
+ */
230
+ async getTierInfo(): Promise<{ tier: string; model: string; embeddingModel: string }> {
231
+ if (!this.ragConfig) {
232
+ throw new Error('[LicensedRetrivora] SDK not initialized.');
233
+ }
234
+
235
+ return {
236
+ tier: 'Standard', // TODO: fetch from tier config
237
+ model: this.ragConfig.llm.model,
238
+ embeddingModel: this.ragConfig.embedding.model,
239
+ };
240
+ }
241
+
242
+ /**
243
+ * Cleanup and shutdown
244
+ */
245
+ async shutdown(): Promise<void> {
246
+ await shutdownTelemetryService();
247
+ this.initialized = false;
248
+ console.log('[LicensedRetrivora] Shutdown complete');
249
+ }
250
+
251
+ /**
252
+ * Check if SDK is initialized
253
+ */
254
+ isInitialized(): boolean {
255
+ return this.initialized;
256
+ }
257
+
258
+ /**
259
+ * Get current RAG configuration (for debugging)
260
+ */
261
+ getConfig(): RagConfig | undefined {
262
+ return this.ragConfig;
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Convenience function to create and initialize SDK in one call
268
+ */
269
+ export async function createRetrivora(options: LicensedRetrivoraOptions): Promise<LicensedRetrivora> {
270
+ const retrivora = new LicensedRetrivora(options);
271
+ await retrivora.initialize();
272
+ return retrivora;
273
+ }
@@ -325,7 +325,6 @@ export function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, li
325
325
  {/* ── Floating Action Button ── */}
326
326
  <button
327
327
  onClick={isOpen ? () => setIsOpen(false) : handleOpen}
328
- disabled={isWidgetLocked && !isOpen}
329
328
  aria-label={isWidgetLocked ? 'Chat unavailable - invalid or missing license key' : (isOpen ? 'Close chat' : 'Open chat')}
330
329
  aria-disabled={isWidgetLocked && !isOpen}
331
330
  className={`group fixed z-[9999] w-14 h-14 drop-shadow-2xl flex items-center justify-center transition-all duration-300 ${positionClass} ${
@@ -30,7 +30,8 @@ export function ConfigProvider({
30
30
  config,
31
31
  children,
32
32
  }: ConfigProviderProps) {
33
- const projectId = config?.projectId || DEFAULT_CONFIG.projectId;
33
+ const envProjectId = typeof process !== 'undefined' ? (process.env.NEXT_PUBLIC_RETRIVORA_PROJECT_ID || process.env.RETRIVORA_PROJECT_ID) : '';
34
+ const projectId = config?.projectId || envProjectId || DEFAULT_CONFIG.projectId;
34
35
  const projectSettingsInput = config?.projectSettings;
35
36
  const autoLoadProjectSettings = config?.autoLoadProjectSettings;
36
37
  const licenseKeyInput = config?.licenseKey;
@@ -0,0 +1,296 @@
1
+ /**
2
+ * LicenseConfigResolver — Resolves LLM and embedding configuration
3
+ * based on the user's license tier from Retrivora admin dashboard.
4
+ *
5
+ * The end-user SDK only needs:
6
+ * - licenseKey (JWT token from Retrivora)
7
+ * - projectId (workspace identifier)
8
+ *
9
+ * Configuration includes:
10
+ * 1. Tier-based model selection (/api/v1/config)
11
+ * 2. Provider API credentials (/api/v1/credentials)
12
+ * 3. Vector DB and rate limit settings
13
+ *
14
+ * All provider API keys (Gemini, Groq, Pinecone) are stored on Retrivora backend
15
+ * and never exposed to end-users directly.
16
+ */
17
+
18
+ import axios, { AxiosInstance } from 'axios';
19
+ import { LLMConfig, EmbeddingConfig, VectorDBConfig } from './RagConfig';
20
+
21
+ export interface ProviderCredentials {
22
+ geminiApiKey?: string;
23
+ groqApiKey?: string;
24
+ pineconeApiKey?: string;
25
+ textEmbeddingProvider?: string;
26
+ }
27
+
28
+ export interface LicenseTierConfig {
29
+ tier: 'free_trial' | 'free' | 'hobby' | 'pro' | 'enterprise';
30
+ llmModel: string;
31
+ embeddingModel: string;
32
+ embeddingDimensions: number;
33
+ maxTokens: number;
34
+ chunkSize: number;
35
+ chunkOverlap: number;
36
+ topK: number;
37
+ vectorDb: {
38
+ provider: string;
39
+ indexName: string;
40
+ };
41
+ rateLimit?: {
42
+ requestsPerMinute: number;
43
+ tokensPerDay: number;
44
+ };
45
+ }
46
+
47
+ export interface ProviderCredentials {
48
+ geminiApiKey?: string;
49
+ groqApiKey?: string;
50
+ pineconeApiKey?: string;
51
+ textEmbeddingProvider?: string;
52
+ }
53
+
54
+ export interface ConfigAPIResponse {
55
+ success: boolean;
56
+ config?: LicenseTierConfig;
57
+ error?: string;
58
+ message?: string;
59
+ }
60
+
61
+ export interface CredentialsAPIResponse {
62
+ success: boolean;
63
+ credentials?: ProviderCredentials;
64
+ error?: string;
65
+ message?: string;
66
+ }
67
+
68
+ /**
69
+ * Resolver for license-based configuration.
70
+ * This is called by the end-user SDK after they instantiate with licenseKey + projectId.
71
+ */
72
+ export class LicenseConfigResolver {
73
+ private static readonly RETRIVORA_CONFIG_URL = 'https://www.retrivora.com/api/v1/config';
74
+ private static readonly RETRIVORA_CREDENTIALS_URL = 'https://www.retrivora.com/api/v1/credentials';
75
+ private static readonly CACHE_TTL_MS = 3600000; // 1 hour
76
+ private static configCache = new Map<string, { config: LicenseTierConfig; credentials: ProviderCredentials; timestamp: number }>();
77
+
78
+ /**
79
+ * Validate and resolve configuration from license key
80
+ * @param licenseKey JWT token from Retrivora (format: rtv_eyJ...)
81
+ * @param projectId Workspace identifier
82
+ * @returns Resolved LLM and embedding configs with provider credentials
83
+ */
84
+ static async resolveFromLicense(
85
+ licenseKey: string,
86
+ projectId: string
87
+ ): Promise<{
88
+ llmConfig: LLMConfig;
89
+ embeddingConfig: EmbeddingConfig;
90
+ vectorDbConfig: VectorDBConfig;
91
+ tierConfig: LicenseTierConfig;
92
+ credentials: ProviderCredentials;
93
+ }> {
94
+ // Check cache first
95
+ const cacheKey = `${licenseKey}:${projectId}`;
96
+ const cached = this.configCache.get(cacheKey);
97
+ if (cached && Date.now() - cached.timestamp < this.CACHE_TTL_MS) {
98
+ console.log('[LicenseConfigResolver] Using cached config for', projectId);
99
+ return this.buildConfigs(cached.config, cached.credentials, licenseKey, projectId);
100
+ }
101
+
102
+ // Fetch tier config from /api/v1/config
103
+ console.log('[LicenseConfigResolver] Fetching tier config from Retrivora...');
104
+ const tierConfig = await this.fetchTierConfig(licenseKey, projectId);
105
+
106
+ // Fetch provider credentials from /api/v1/credentials
107
+ console.log('[LicenseConfigResolver] Fetching provider credentials from Retrivora...');
108
+ const credentials = await this.fetchProviderCredentials(licenseKey, projectId);
109
+
110
+ // Cache both
111
+ this.configCache.set(cacheKey, { config: tierConfig, credentials, timestamp: Date.now() });
112
+
113
+ console.log('[LicenseConfigResolver] ✅ Successfully resolved config from Retrivora:', {
114
+ tier: tierConfig.tier,
115
+ llmModel: tierConfig.llmModel,
116
+ embeddingModel: tierConfig.embeddingModel,
117
+ });
118
+
119
+ return this.buildConfigs(tierConfig, credentials, licenseKey, projectId);
120
+ }
121
+
122
+ /**
123
+ * Fetch tier configuration from Retrivora config API
124
+ */
125
+ private static async fetchTierConfig(licenseKey: string, projectId: string): Promise<LicenseTierConfig> {
126
+ try {
127
+ const response = await axios.post<ConfigAPIResponse>(
128
+ this.RETRIVORA_CONFIG_URL,
129
+ { licenseKey, projectId },
130
+ {
131
+ headers: {
132
+ 'Content-Type': 'application/json',
133
+ Authorization: `Bearer ${licenseKey}`,
134
+ 'X-License-Key': licenseKey,
135
+ 'X-Project-ID': projectId,
136
+ },
137
+ timeout: 10000,
138
+ }
139
+ );
140
+
141
+ if (!response.data.success || !response.data.config) {
142
+ throw new Error(
143
+ `[LicenseConfigResolver] Config API returned error: ${response.data.error || response.data.message}`
144
+ );
145
+ }
146
+
147
+ console.log(`[LicenseConfigResolver] Resolved tier: ${response.data.config.tier}`);
148
+ return response.data.config;
149
+ } catch (err: any) {
150
+ console.error('[LicenseConfigResolver] Failed to fetch config:', err.message);
151
+ throw new Error(
152
+ `[LicenseConfigResolver] Could not validate license key or fetch tier configuration: ${err.message}`
153
+ );
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Fetch provider credentials from Retrivora credentials API
159
+ */
160
+ private static async fetchProviderCredentials(licenseKey: string, projectId: string): Promise<ProviderCredentials> {
161
+ try {
162
+ const response = await axios.post<CredentialsAPIResponse>(
163
+ this.RETRIVORA_CREDENTIALS_URL,
164
+ { licenseKey, projectId },
165
+ {
166
+ headers: {
167
+ 'Content-Type': 'application/json',
168
+ Authorization: `Bearer ${licenseKey}`,
169
+ 'X-License-Key': licenseKey,
170
+ 'X-Project-ID': projectId,
171
+ },
172
+ timeout: 10000,
173
+ }
174
+ );
175
+
176
+ if (!response.data.success || !response.data.credentials) {
177
+ throw new Error(
178
+ `[LicenseConfigResolver] Credentials API returned error: ${response.data.error || response.data.message}`
179
+ );
180
+ }
181
+
182
+ console.log(`[LicenseConfigResolver] Retrieved provider credentials for project: ${projectId}`);
183
+ return response.data.credentials;
184
+ } catch (err: any) {
185
+ console.error('[LicenseConfigResolver] Failed to fetch credentials:', err.message);
186
+ throw new Error(
187
+ `[LicenseConfigResolver] Could not fetch provider credentials: ${err.message}`
188
+ );
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Build LLM, embedding, and vector DB configs from tier and credentials
194
+ */
195
+ private static buildConfigs(
196
+ tierConfig: LicenseTierConfig,
197
+ credentials: ProviderCredentials,
198
+ licenseKey: string,
199
+ projectId: string
200
+ ): {
201
+ llmConfig: LLMConfig;
202
+ embeddingConfig: EmbeddingConfig;
203
+ vectorDbConfig: VectorDBConfig;
204
+ tierConfig: LicenseTierConfig;
205
+ credentials: ProviderCredentials;
206
+ } {
207
+ // Determine LLM provider and API key based on model
208
+ let llmProvider: 'gemini' | 'groq' | 'openai' = 'gemini';
209
+ let llmApiKey = credentials.geminiApiKey || licenseKey;
210
+
211
+ if (tierConfig.llmModel.includes('gpt')) {
212
+ llmProvider = 'openai';
213
+ } else if (tierConfig.llmModel.includes('groq') || tierConfig.llmModel.includes('llama')) {
214
+ llmProvider = 'groq';
215
+ llmApiKey = credentials.groqApiKey || licenseKey;
216
+ }
217
+
218
+ const llmConfig: LLMConfig = {
219
+ provider: llmProvider,
220
+ model: tierConfig.llmModel,
221
+ apiKey: llmApiKey,
222
+ maxTokens: tierConfig.maxTokens,
223
+ temperature: 0.7,
224
+ options: {},
225
+ };
226
+
227
+ // Embedding config - use Gemini's embeddings
228
+ const embeddingConfig: EmbeddingConfig = {
229
+ provider: 'gemini',
230
+ model: tierConfig.embeddingModel,
231
+ apiKey: credentials.geminiApiKey || licenseKey,
232
+ dimensions: tierConfig.embeddingDimensions,
233
+ options: {},
234
+ };
235
+
236
+ // Vector DB config - determined by tier from Retrivora
237
+ const vectorDbConfig: VectorDBConfig = {
238
+ provider: tierConfig.vectorDb.provider as any,
239
+ indexName: tierConfig.vectorDb.indexName,
240
+ options: this.getVectorDbOptions(tierConfig.vectorDb.provider, projectId, credentials),
241
+ };
242
+
243
+ return { llmConfig, embeddingConfig, vectorDbConfig, tierConfig, credentials };
244
+ }
245
+
246
+ /**
247
+ * Get provider-specific vector DB options
248
+ */
249
+ private static getVectorDbOptions(
250
+ provider: string,
251
+ projectId: string,
252
+ credentials: ProviderCredentials
253
+ ): Record<string, unknown> {
254
+ switch (provider) {
255
+ case 'pinecone':
256
+ return {
257
+ apiKey: credentials.pineconeApiKey,
258
+ indexName: `retrivora-${projectId}`,
259
+ };
260
+ case 'pgvector':
261
+ case 'postgresql':
262
+ return {
263
+ tables: [`documents_${projectId}`],
264
+ };
265
+ case 'mongodb':
266
+ return {
267
+ database: `retrivora_${projectId}`,
268
+ collection: `vectors_${projectId}`,
269
+ };
270
+ case 'qdrant':
271
+ return {
272
+ collection: `retrivora_${projectId}`,
273
+ };
274
+ default:
275
+ return {};
276
+ }
277
+ }
278
+
279
+ /**
280
+ * Clear configuration cache (useful for testing or manual refresh)
281
+ */
282
+ static clearCache(): void {
283
+ this.configCache.clear();
284
+ console.log('[LicenseConfigResolver] Configuration cache cleared');
285
+ }
286
+
287
+ /**
288
+ * Get cache stats for debugging
289
+ */
290
+ static getCacheStats(): { size: number; entries: string[] } {
291
+ return {
292
+ size: this.configCache.size,
293
+ entries: Array.from(this.configCache.keys()),
294
+ };
295
+ }
296
+ }