@lyxa.ai/core 1.4.284 → 1.4.285

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.
package/dist/index.js CHANGED
@@ -67,7 +67,6 @@ const logger_kit_1 = require("./libraries/logger-kit");
67
67
  const lyxa_fcm_service_1 = require("./libraries/notification/lyxa-fcm.service");
68
68
  const lyxa_fcm_sender_1 = require("./libraries/notification/lyxa-fcm-sender");
69
69
  const firebase_message_builder_1 = require("./libraries/notification/firebase-message.builder");
70
- const google_translate_1 = require("./libraries/google-translate");
71
70
  const llm_provider_service_1 = require("./libraries/llm/llm-provider-service");
72
71
  var EnvironmentConfigurationType_2 = require("./libraries/configuration/types/EnvironmentConfigurationType");
73
72
  Object.defineProperty(exports, "EnvironmentConfigurationType", { enumerable: true, get: function () { return EnvironmentConfigurationType_2.EnvironmentConfigurationType; } });
@@ -120,7 +119,6 @@ async function registerLibraries(options) {
120
119
  typedi_1.Container.set(logger_kit_1.LyxaLoggerKit, loggerKit);
121
120
  const firebaseInstance = new firebase_1.FirebaseService(configurationInstance);
122
121
  typedi_1.Container.set(firebase_1.FirebaseService, firebaseInstance);
123
- typedi_1.Container.set(google_translate_1.GoogleTranslateService, typedi_1.Container.get(google_translate_1.GoogleTranslateService));
124
122
  const microserviceDispatcherInstance = new dispatcher_1.MicroServiceDispatcher(secretInstance);
125
123
  typedi_1.Container.set(dispatcher_1.MicroServiceDispatcher, microserviceDispatcherInstance);
126
124
  const twilioServiceInstance = new twilio_1.TwilioService();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,sCA0BC;AAED,8CA4GC;AAED,oCAEC;AAjLD,qFAAqF;AAErF,IAAA,0CAAqB,GAAE,CAAC;AAExB,2CAA6C;AAC7C,mCAAmC;AACnC,6DAAuF;AACvF,+CAA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jF,CAAC;AACF,CAAC;AAED,SAAgB,YAAY;IAC3B,OAAO,kBAAS,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Apply the soft delete plugin globally before any connections or models\nimport { applySoftDeletePlugin } from './libraries/mongo/plugins/soft-delete-plugin';\n\napplySoftDeletePlugin();\n\nimport { LibraryManager } from './libraries';\nimport { Container } from 'typedi';\nimport { ConfigurationOptions, ConfigurationService } from './libraries/configuration';\nimport { LyxaLogger } from './libraries/logger';\nimport { RedisService } from './libraries/redis';\nimport { initGlobalConnection, initLyxaMongoDbConnection } from './libraries/mongo';\nimport { SecretManagerService } from './libraries/secrets';\nimport { MicroServiceDispatcher } from './libraries/dispatcher';\nimport { TwilioService } from './libraries/twilio';\nimport { FirebaseService } from './libraries/firebase';\nimport { initRabbitMQConnection, subscribeToEvent } from './libraries/event';\nimport { SubscriptionRegistry } from './libraries/event/registry/SubscriptionRegistry';\nimport { GoogleMapsService, MapService } from './libraries/map';\nimport { CachedSettingsService } from './libraries/cache/settings';\nimport { FirebaseFcmService } from './libraries/notification/firebase-fcm.service';\nimport { BullMQService } from './libraries/bullmq/bull-mq-service';\nimport { BOBSecrets, BOBService, CashSettlementService } from './libraries/cash-settlement';\nimport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nimport { OsrmMapService } from './libraries/map/providers/osrm';\nimport { RabbitMQUrlMap } from './utilities/environment/rabbitmq-environments';\nimport { disconnectAllEntitiesFromInstance } from './libraries/socket/connections/instance-disconnect';\nimport { LyxaLoggerKit } from './libraries/logger-kit';\nimport { LyxaFcmService } from './libraries/notification/lyxa-fcm.service';\nimport { LyxaFcmSender } from './libraries/notification/lyxa-fcm-sender';\nimport { FirebaseMessageBuilderFactory } from './libraries/notification/firebase-message.builder';\nimport { GoogleTranslateService } from './libraries/google-translate';\nimport { LLMCompletionService, LLMProvider } from './libraries/llm/llm-provider-service';\n\nexport { ConfigurationOptions } from './libraries/configuration';\nexport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nexport { initGlobalConnection } from './libraries/mongo';\nexport * from './libraries/google-translate';\n\nexport async function bootstrapCore(options?: ConfigurationOptions) {\n\ttry {\n\t\tawait registerLibraries(options);\n\t\tgetLibraries().getLogger().logger.info('Successfully bootstrapped lyxa-core.');\n\n\t\tconst gracefulShutdown = async () => {\n\t\t\tgetLibraries().getLogger().logger.info('Received shutdown signal, shutting down gracefully...');\n\t\t\tif (options?.instanceType == 'socket') await disconnectAllEntitiesFromInstance();\n\t\t\tprocess.exit();\n\t\t};\n\n\t\tprocess.on('SIGTERM', gracefulShutdown);\n\t\tprocess.on('SIGINT', gracefulShutdown);\n\t\tprocess.on('uncaughtException', err => {\n\t\t\tconsole.log('err', err);\n\t\t\tgetLibraries().getLogger().logger.error('Uncaught exception, shutting down...', err);\n\t\t\tgracefulShutdown();\n\t\t});\n\t\tprocess.on('exit', code => {\n\t\t\tgetLibraries().getLogger().logger.info(`Exiting with code: ${code}`);\n\t\t});\n\n\t\tconsole.log('Created hooks.');\n\t} catch (e) {\n\t\tconsole.error(e);\n\t}\n}\n\nexport async function registerLibraries(options?: ConfigurationOptions) {\n\t// Setup configuration.\n\tconst configurationInstance = new ConfigurationService(options);\n\tContainer.set(ConfigurationService, configurationInstance);\n\n\t// Setup redis.\n\tconst redisInstance = new RedisService(configurationInstance.redisURL);\n\tContainer.set(RedisService, redisInstance);\n\n\t// Setup secret\n\tconst secretInstance = new SecretManagerService(configurationInstance, redisInstance);\n\tContainer.set(SecretManagerService, secretInstance);\n\n\t// Setup BullMQ\n\tconst bullMQInstance = new BullMQService(redisInstance);\n\tContainer.set(BullMQService, bullMQInstance);\n\n\tconst mongoUrl = options?.mongoDbUrl\n\t\t? options.mongoDbUrl\n\t\t: await getLibraries().getSecretsService().getKey('MONGO_URL');\n\n\tawait initLyxaMongoDbConnection(mongoUrl!, options);\n\tawait initGlobalConnection(mongoUrl!, options!.environment);\n\n\tconst loggerInstance = new LyxaLogger(options!.instanceType!, mongoUrl!);\n\tContainer.set(LyxaLogger, loggerInstance);\n\n\tconst loggerKit = new LyxaLoggerKit({ instanceType: options!.instanceType! });\n\tContainer.set(LyxaLoggerKit, loggerKit);\n\n\t// Setup firebase\n\tconst firebaseInstance = new FirebaseService(configurationInstance!);\n\tContainer.set(FirebaseService, firebaseInstance);\n\n\t//Setup google translate\n\tContainer.set(GoogleTranslateService, Container.get(GoogleTranslateService));\n\n\t// Setup microservice dispatcher\n\tconst microserviceDispatcherInstance = new MicroServiceDispatcher(secretInstance);\n\tContainer.set(MicroServiceDispatcher, microserviceDispatcherInstance);\n\n\t// Setup twilio\n\tconst twilioServiceInstance = new TwilioService();\n\tContainer.set(TwilioService, twilioServiceInstance);\n\n\t// Setup LLM service\n\tconst llmCompletionService = new LLMCompletionService(LLMProvider.OPENAI);\n\tContainer.set(LLMCompletionService, llmCompletionService);\n\n\t// Setup map service\n\tconst googleMapsKey = await getLibraries().getSecretsService().getKey('GOOGLE_MAPS_API_KEY');\n\tconst googleMapService = new GoogleMapsService(redisInstance, googleMapsKey as string);\n\tconst osrmMapService = new OsrmMapService();\n\tconst mapServiceInstance = new MapService(googleMapService, osrmMapService);\n\tContainer.set(MapService, mapServiceInstance);\n\n\t// Setup cash settlement service\n\tconst bobUsername = await getLibraries().getSecretsService().getKey('BOB_USER_NAME');\n\tconst bobPassword = await getLibraries().getSecretsService().getKey('BOB_PASSWORD');\n\tconst bobURL = await getLibraries().getSecretsService().getKey('BOB_URL');\n\n\tconst bobService = new BOBService({\n\t\tBOB_USER_NAME: bobUsername,\n\t\tBOB_PASSWORD: bobPassword,\n\t\tBOB_URL: bobURL,\n\t} as BOBSecrets);\n\tconst cashSettlementServiceInstance = new CashSettlementService(bobService);\n\tContainer.set(CashSettlementService, cashSettlementServiceInstance);\n\tContainer.set(BOBService, bobService);\n\n\tconst settingsServiceInstance = new CachedSettingsService(redisInstance);\n\tContainer.set(CachedSettingsService, settingsServiceInstance);\n\n\ttry {\n\t\tconst settings = await settingsServiceInstance.getSettings();\n\t\tconst { _setTimezone } = await import('./utilities/dayjs/dayjs');\n\t\t_setTimezone(settings?.timezone || 'Asia/Beirut');\n\t\tconsole.log('Timezone initialized:', settings?.timezone || 'Asia/Beirut');\n\t} catch (error) {\n\t\tconsole.error('Failed to initialize timezone:', error);\n\t}\n\n\t// Setup fcm service\n\tconst fcmService = new FirebaseFcmService();\n\tconst builder = new FirebaseMessageBuilderFactory();\n\tconst lyxaFcmSender = new LyxaFcmSender(fcmService, builder);\n\tconst lyxaFcmService = new LyxaFcmService(lyxaFcmSender);\n\n\tContainer.set(FirebaseFcmService, fcmService);\n\tContainer.set(LyxaFcmService, lyxaFcmService);\n\n\tconsole.log('Initialized everything');\n\n\tawait initRabbitMQConnection(RabbitMQUrlMap[options?.environment ?? EnvironmentConfigurationType.DEV]);\n\n\tconst allSubscriptions = SubscriptionRegistry.getAllSubscriptions();\n\n\tconst instantiatedServices = new Map<Function, any>();\n\n\tfor (const { eventId, targetConstructor, methodName } of allSubscriptions) {\n\t\tlet instance = instantiatedServices.get(targetConstructor);\n\t\tif (!instance) {\n\t\t\tinstance = Container.get(targetConstructor as any);\n\t\t\tinstantiatedServices.set(targetConstructor, instance);\n\t\t}\n\n\t\tawait subscribeToEvent(eventId, async payload => instance[methodName](payload));\n\t}\n}\n\nexport function getLibraries(): LibraryManager {\n\treturn Container.get(LibraryManager);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,sCA0BC;AAED,8CA4GC;AAED,oCAEC;AAjLD,qFAAqF;AAErF,IAAA,0CAAqB,GAAE,CAAC;AAExB,2CAA6C;AAC7C,mCAAmC;AACnC,6DAAuF;AACvF,+CAAgD;AAChD,6CAAiD;AACjD,6CAAoF;AACpF,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;A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AC;IACpD,MAAM,aAAa,GAAG,IAAI,+BAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7D,MAAM,cAAc,GAAG,IAAI,iCAAc,CAAC,aAAa,CAAC,CAAC;IAEzD,kBAAS,CAAC,GAAG,CAAC,yCAAkB,EAAE,UAAU,CAAC,CAAC;IAC9C,kBAAS,CAAC,GAAG,CAAC,iCAAc,EAAE,cAAc,CAAC,CAAC;IAE9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAEtC,MAAM,IAAA,8BAAsB,EAAC,sCAAc,CAAC,OAAO,EAAE,WAAW,IAAI,2DAA4B,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvG,MAAM,gBAAgB,GAAG,2CAAoB,CAAC,mBAAmB,EAAE,CAAC;IAEpE,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAiB,CAAC;IAEtD,KAAK,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,gBAAgB,EAAE,CAAC;QAC3E,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,QAAQ,GAAG,kBAAS,CAAC,GAAG,CAAC,iBAAwB,CAAC,CAAC;YACnD,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,IAAA,wBAAgB,EAAC,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACjF,CAAC;AACF,CAAC;AAED,SAAgB,YAAY;IAC3B,OAAO,kBAAS,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Apply the soft delete plugin globally before any connections or models\nimport { applySoftDeletePlugin } from './libraries/mongo/plugins/soft-delete-plugin';\n\napplySoftDeletePlugin();\n\nimport { LibraryManager } from './libraries';\nimport { Container } from 'typedi';\nimport { ConfigurationOptions, ConfigurationService } from './libraries/configuration';\nimport { LyxaLogger } from './libraries/logger';\nimport { RedisService } from './libraries/redis';\nimport { initGlobalConnection, initLyxaMongoDbConnection } from './libraries/mongo';\nimport { SecretManagerService } from './libraries/secrets';\nimport { MicroServiceDispatcher } from './libraries/dispatcher';\nimport { TwilioService } from './libraries/twilio';\nimport { FirebaseService } from './libraries/firebase';\nimport { initRabbitMQConnection, subscribeToEvent } from './libraries/event';\nimport { SubscriptionRegistry } from './libraries/event/registry/SubscriptionRegistry';\nimport { GoogleMapsService, MapService } from './libraries/map';\nimport { CachedSettingsService } from './libraries/cache/settings';\nimport { FirebaseFcmService } from './libraries/notification/firebase-fcm.service';\nimport { BullMQService } from './libraries/bullmq/bull-mq-service';\nimport { BOBSecrets, BOBService, CashSettlementService } from './libraries/cash-settlement';\nimport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nimport { OsrmMapService } from './libraries/map/providers/osrm';\nimport { RabbitMQUrlMap } from './utilities/environment/rabbitmq-environments';\nimport { disconnectAllEntitiesFromInstance } from './libraries/socket/connections/instance-disconnect';\nimport { LyxaLoggerKit } from './libraries/logger-kit';\nimport { LyxaFcmService } from './libraries/notification/lyxa-fcm.service';\nimport { LyxaFcmSender } from './libraries/notification/lyxa-fcm-sender';\nimport { FirebaseMessageBuilderFactory } from './libraries/notification/firebase-message.builder';\nimport { GoogleTranslateService } from './libraries/google-translate';\nimport { LLMCompletionService, LLMProvider } from './libraries/llm/llm-provider-service';\n\nexport { ConfigurationOptions } from './libraries/configuration';\nexport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nexport { initGlobalConnection } from './libraries/mongo';\nexport * from './libraries/google-translate';\n\nexport async function bootstrapCore(options?: ConfigurationOptions) {\n\ttry {\n\t\tawait registerLibraries(options);\n\t\tgetLibraries().getLogger().logger.info('Successfully bootstrapped lyxa-core.');\n\n\t\tconst gracefulShutdown = async () => {\n\t\t\tgetLibraries().getLogger().logger.info('Received shutdown signal, shutting down gracefully...');\n\t\t\tif (options?.instanceType == 'socket') await disconnectAllEntitiesFromInstance();\n\t\t\tprocess.exit();\n\t\t};\n\n\t\tprocess.on('SIGTERM', gracefulShutdown);\n\t\tprocess.on('SIGINT', gracefulShutdown);\n\t\tprocess.on('uncaughtException', err => {\n\t\t\tconsole.log('err', err);\n\t\t\tgetLibraries().getLogger().logger.error('Uncaught exception, shutting down...', err);\n\t\t\tgracefulShutdown();\n\t\t});\n\t\tprocess.on('exit', code => {\n\t\t\tgetLibraries().getLogger().logger.info(`Exiting with code: ${code}`);\n\t\t});\n\n\t\tconsole.log('Created hooks.');\n\t} catch (e) {\n\t\tconsole.error(e);\n\t}\n}\n\nexport async function registerLibraries(options?: ConfigurationOptions) {\n\t// Setup configuration.\n\tconst configurationInstance = new ConfigurationService(options);\n\tContainer.set(ConfigurationService, configurationInstance);\n\n\t// Setup redis.\n\tconst redisInstance = new RedisService(configurationInstance.redisURL);\n\tContainer.set(RedisService, redisInstance);\n\n\t// Setup secret\n\tconst secretInstance = new SecretManagerService(configurationInstance, redisInstance);\n\tContainer.set(SecretManagerService, secretInstance);\n\n\t// Setup BullMQ\n\tconst bullMQInstance = new BullMQService(redisInstance);\n\tContainer.set(BullMQService, bullMQInstance);\n\n\tconst mongoUrl = options?.mongoDbUrl\n\t\t? options.mongoDbUrl\n\t\t: await getLibraries().getSecretsService().getKey('MONGO_URL');\n\n\tawait initLyxaMongoDbConnection(mongoUrl!, options);\n\tawait initGlobalConnection(mongoUrl!, options!.environment);\n\n\tconst loggerInstance = new LyxaLogger(options!.instanceType!, mongoUrl!);\n\tContainer.set(LyxaLogger, loggerInstance);\n\n\tconst loggerKit = new LyxaLoggerKit({ instanceType: options!.instanceType! });\n\tContainer.set(LyxaLoggerKit, loggerKit);\n\n\t// Setup firebase\n\tconst firebaseInstance = new FirebaseService(configurationInstance!);\n\tContainer.set(FirebaseService, firebaseInstance);\n\n\t//Setup google translate\n\t// Container.set(GoogleTranslateService, Container.get(GoogleTranslateService));\n\n\t// Setup microservice dispatcher\n\tconst microserviceDispatcherInstance = new MicroServiceDispatcher(secretInstance);\n\tContainer.set(MicroServiceDispatcher, microserviceDispatcherInstance);\n\n\t// Setup twilio\n\tconst twilioServiceInstance = new TwilioService();\n\tContainer.set(TwilioService, twilioServiceInstance);\n\n\t// Setup LLM service\n\tconst llmCompletionService = new LLMCompletionService(LLMProvider.OPENAI);\n\tContainer.set(LLMCompletionService, llmCompletionService);\n\n\t// Setup map service\n\tconst googleMapsKey = await getLibraries().getSecretsService().getKey('GOOGLE_MAPS_API_KEY');\n\tconst googleMapService = new GoogleMapsService(redisInstance, googleMapsKey as string);\n\tconst osrmMapService = new OsrmMapService();\n\tconst mapServiceInstance = new MapService(googleMapService, osrmMapService);\n\tContainer.set(MapService, mapServiceInstance);\n\n\t// Setup cash settlement service\n\tconst bobUsername = await getLibraries().getSecretsService().getKey('BOB_USER_NAME');\n\tconst bobPassword = await getLibraries().getSecretsService().getKey('BOB_PASSWORD');\n\tconst bobURL = await getLibraries().getSecretsService().getKey('BOB_URL');\n\n\tconst bobService = new BOBService({\n\t\tBOB_USER_NAME: bobUsername,\n\t\tBOB_PASSWORD: bobPassword,\n\t\tBOB_URL: bobURL,\n\t} as BOBSecrets);\n\tconst cashSettlementServiceInstance = new CashSettlementService(bobService);\n\tContainer.set(CashSettlementService, cashSettlementServiceInstance);\n\tContainer.set(BOBService, bobService);\n\n\tconst settingsServiceInstance = new CachedSettingsService(redisInstance);\n\tContainer.set(CachedSettingsService, settingsServiceInstance);\n\n\ttry {\n\t\tconst settings = await settingsServiceInstance.getSettings();\n\t\tconst { _setTimezone } = await import('./utilities/dayjs/dayjs');\n\t\t_setTimezone(settings?.timezone || 'Asia/Beirut');\n\t\tconsole.log('Timezone initialized:', settings?.timezone || 'Asia/Beirut');\n\t} catch (error) {\n\t\tconsole.error('Failed to initialize timezone:', error);\n\t}\n\n\t// Setup fcm service\n\tconst fcmService = new FirebaseFcmService();\n\tconst builder = new FirebaseMessageBuilderFactory();\n\tconst lyxaFcmSender = new LyxaFcmSender(fcmService, builder);\n\tconst lyxaFcmService = new LyxaFcmService(lyxaFcmSender);\n\n\tContainer.set(FirebaseFcmService, fcmService);\n\tContainer.set(LyxaFcmService, lyxaFcmService);\n\n\tconsole.log('Initialized everything');\n\n\tawait initRabbitMQConnection(RabbitMQUrlMap[options?.environment ?? EnvironmentConfigurationType.DEV]);\n\n\tconst allSubscriptions = SubscriptionRegistry.getAllSubscriptions();\n\n\tconst instantiatedServices = new Map<Function, any>();\n\n\tfor (const { eventId, targetConstructor, methodName } of allSubscriptions) {\n\t\tlet instance = instantiatedServices.get(targetConstructor);\n\t\tif (!instance) {\n\t\t\tinstance = Container.get(targetConstructor as any);\n\t\t\tinstantiatedServices.set(targetConstructor, instance);\n\t\t}\n\n\t\tawait subscribeToEvent(eventId, async payload => instance[methodName](payload));\n\t}\n}\n\nexport function getLibraries(): LibraryManager {\n\treturn Container.get(LibraryManager);\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import { GoogleTranslateClient } from './google-translate.client';
2
+ import { SecretManagerService } from '../secrets';
2
3
  export declare class GoogleTranslateService {
3
4
  private readonly googleTranslateClient;
4
- constructor(googleTranslateClient: GoogleTranslateClient);
5
- translate(apiKey: string, text: string, targetLanguage: string, sourceLanguage?: string): Promise<string>;
6
- translateBatch(apiKey: string, texts: string[], targetLanguage: string, sourceLanguage?: string): Promise<string[]>;
5
+ private readonly secretManager;
6
+ constructor(googleTranslateClient: GoogleTranslateClient, secretManager: SecretManagerService);
7
+ translate(text: string, targetLanguage: string, sourceLanguage?: string): Promise<string>;
8
+ translateBatch(texts: string[], targetLanguage: string, sourceLanguage?: string): Promise<string[]>;
7
9
  }
@@ -16,12 +16,15 @@ exports.GoogleTranslateService = void 0;
16
16
  const typedi_1 = require("typedi");
17
17
  const google_translate_client_1 = require("./google-translate.client");
18
18
  const logSettings_1 = require("@typegoose/typegoose/lib/logSettings");
19
+ const secrets_1 = require("../secrets");
19
20
  let GoogleTranslateService = class GoogleTranslateService {
20
21
  googleTranslateClient;
21
- constructor(googleTranslateClient) {
22
+ secretManager;
23
+ constructor(googleTranslateClient, secretManager) {
22
24
  this.googleTranslateClient = googleTranslateClient;
25
+ this.secretManager = secretManager;
23
26
  }
24
- async translate(apiKey, text, targetLanguage, sourceLanguage) {
27
+ async translate(text, targetLanguage, sourceLanguage) {
25
28
  if (!text?.trim()) {
26
29
  return text;
27
30
  }
@@ -35,6 +38,10 @@ let GoogleTranslateService = class GoogleTranslateService {
35
38
  input,
36
39
  });
37
40
  try {
41
+ const apiKey = await this.secretManager.getKey('GOOGLE_TRANSLATE_API_KEY');
42
+ if (!apiKey) {
43
+ throw new Error('GOOGLE_TRANSLATE_API_KEY is not configured');
44
+ }
38
45
  const result = await this.googleTranslateClient.translate(apiKey, input);
39
46
  logSettings_1.logger.info('Google Translate response', {
40
47
  input,
@@ -50,7 +57,7 @@ let GoogleTranslateService = class GoogleTranslateService {
50
57
  throw error;
51
58
  }
52
59
  }
53
- async translateBatch(apiKey, texts, targetLanguage, sourceLanguage) {
60
+ async translateBatch(texts, targetLanguage, sourceLanguage) {
54
61
  if (!texts.length) {
55
62
  return [];
56
63
  }
@@ -64,6 +71,10 @@ let GoogleTranslateService = class GoogleTranslateService {
64
71
  input,
65
72
  });
66
73
  try {
74
+ const apiKey = await this.secretManager.getKey('GOOGLE_TRANSLATE_API_KEY');
75
+ if (!apiKey) {
76
+ throw new Error('GOOGLE_TRANSLATE_API_KEY is not configured');
77
+ }
67
78
  const result = await this.googleTranslateClient.translate(apiKey, input);
68
79
  logSettings_1.logger.info('Google Translate batch response', {
69
80
  input,
@@ -84,6 +95,8 @@ exports.GoogleTranslateService = GoogleTranslateService;
84
95
  exports.GoogleTranslateService = GoogleTranslateService = __decorate([
85
96
  (0, typedi_1.Service)(),
86
97
  __param(0, (0, typedi_1.Inject)()),
87
- __metadata("design:paramtypes", [google_translate_client_1.GoogleTranslateClient])
98
+ __param(1, (0, typedi_1.Inject)()),
99
+ __metadata("design:paramtypes", [google_translate_client_1.GoogleTranslateClient,
100
+ secrets_1.SecretManagerService])
88
101
  ], GoogleTranslateService);
89
102
  //# sourceMappingURL=google-translate.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"google-translate.service.js","sourceRoot":"/","sources":["libraries/google-translate/google-translate.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAyC;AACzC,uEAAkE;AAElE,sEAA8D;AAGvD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAGhB;IAFlB,YAEkB,qBAA4C;QAA5C,0BAAqB,GAArB,qBAAqB,CAAuB;IAC3D,CAAC;IAEG,KAAK,CAAC,SAAS,CACrB,MAAc,EACd,IAAY,EACZ,cAAsB,EACtB,cAAuB;QAEvB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,KAAK,GAA4B;YACtC,CAAC,EAAE,IAAI;YACP,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,MAAM;SACd,CAAC;QACF,oBAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;YACvC,KAAK;SACL,CAAC,CAAC;QACH,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzE,oBAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE;gBACxC,KAAK;gBACL,MAAM,EAAE,MAAM,CAAC,IAAI;aACnB,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,cAAc,IAAI,IAAI,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,oBAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;gBACvC,KAAK;gBACL,KAAK;aACL,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,cAAc,CAC1B,MAAc,EACd,KAAe,EACf,cAAsB,EACtB,cAAuB;QAEvB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,KAAK,GAA4B;YACtC,CAAC,EAAE,KAAK;YACR,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,MAAM;SACd,CAAC;QACF,oBAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;YACvC,KAAK;SACL,CAAC,CAAC;QAEH,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzE,oBAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE;gBAC9C,KAAK;gBACL,MAAM,EAAE,MAAM,CAAC,IAAI;aACnB,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,oBAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE;gBAC7C,KAAK;gBACL,KAAK;aACL,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;CACD,CAAA;AA/EY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,gBAAO,GAAE;IAGP,WAAA,IAAA,eAAM,GAAE,CAAA;qCAC+B,+CAAqB;GAHlD,sBAAsB,CA+ElC","sourcesContent":["import { Inject, Service } from 'typedi';\nimport { GoogleTranslateClient } from './google-translate.client';\nimport { GoogleTranslateInputDTO } from './google-translate.dto';\nimport { logger } from '@typegoose/typegoose/lib/logSettings';\n\n@Service()\nexport class GoogleTranslateService {\n\tconstructor(\n\t\t@Inject()\n\t\tprivate readonly googleTranslateClient: GoogleTranslateClient\n\t) {}\n\n\tpublic async translate(\n\t\tapiKey: string,\n\t\ttext: string,\n\t\ttargetLanguage: string,\n\t\tsourceLanguage?: string\n\t): Promise<string> {\n\t\tif (!text?.trim()) {\n\t\t\treturn text;\n\t\t}\n\n\t\tconst input: GoogleTranslateInputDTO = {\n\t\t\tq: text,\n\t\t\ttarget: targetLanguage,\n\t\t\tsource: sourceLanguage,\n\t\t\tformat: 'text',\n\t\t};\n\t\tlogger.info('Google Translate request', {\n\t\t\tinput,\n\t\t});\n\t\ttry {\n\t\t\tconst result = await this.googleTranslateClient.translate(apiKey, input);\n\t\t\tlogger.info('Google Translate response', {\n\t\t\t\tinput,\n\t\t\t\tresult: result.data,\n\t\t\t});\n\n\t\t\treturn result.data.translations[0]?.translatedText ?? text;\n\t\t} catch (error) {\n\t\t\tlogger.error('Google Translate failed', {\n\t\t\t\tinput,\n\t\t\t\terror,\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async translateBatch(\n\t\tapiKey: string,\n\t\ttexts: string[],\n\t\ttargetLanguage: string,\n\t\tsourceLanguage?: string\n\t): Promise<string[]> {\n\t\tif (!texts.length) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst input: GoogleTranslateInputDTO = {\n\t\t\tq: texts,\n\t\t\ttarget: targetLanguage,\n\t\t\tsource: sourceLanguage,\n\t\t\tformat: 'text',\n\t\t};\n\t\tlogger.info('Google Translate request', {\n\t\t\tinput,\n\t\t});\n\n\t\ttry {\n\t\t\tconst result = await this.googleTranslateClient.translate(apiKey, input);\n\t\t\tlogger.info('Google Translate batch response', {\n\t\t\t\tinput,\n\t\t\t\tresult: result.data,\n\t\t\t});\n\n\t\t\treturn result.data.translations.map(x => x.translatedText);\n\t\t} catch (error) {\n\t\t\tlogger.error('Google Translate batch failed', {\n\t\t\t\tinput,\n\t\t\t\terror,\n\t\t\t});\n\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"google-translate.service.js","sourceRoot":"/","sources":["libraries/google-translate/google-translate.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAyC;AACzC,uEAAkE;AAElE,sEAA8D;AAC9D,wCAAkD;AAG3C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAGhB;IAEA;IAJlB,YAEkB,qBAA4C,EAE5C,aAAmC;QAFnC,0BAAqB,GAArB,qBAAqB,CAAuB;QAE5C,kBAAa,GAAb,aAAa,CAAsB;IAClD,CAAC;IAEG,KAAK,CAAC,SAAS,CAAC,IAAY,EAAE,cAAsB,EAAE,cAAuB;QACnF,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,KAAK,GAA4B;YACtC,CAAC,EAAE,IAAI;YACP,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,MAAM;SACd,CAAC;QACF,oBAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;YACvC,KAAK;SACL,CAAC,CAAC;QACH,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;YAE3E,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAC/D,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzE,oBAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE;gBACxC,KAAK;gBACL,MAAM,EAAE,MAAM,CAAC,IAAI;aACnB,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,I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KAAK;aACL,CAAC,CAAC;YAEH,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;CACD,CAAA;AApFY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,gBAAO,GAAE;IAGP,WAAA,IAAA,eAAM,GAAE,CAAA;IAER,WAAA,IAAA,eAAM,GAAE,CAAA;qCAD+B,+CAAqB;QAE7B,8BAAoB;GALzC,sBAAsB,CAoFlC","sourcesContent":["import { Inject, Service } from 'typedi';\nimport { GoogleTranslateClient } from './google-translate.client';\nimport { GoogleTranslateInputDTO } from './google-translate.dto';\nimport { logger } from '@typegoose/typegoose/lib/logSettings';\nimport { SecretManagerService } from '../secrets';\n\n@Service()\nexport class GoogleTranslateService {\n\tconstructor(\n\t\t@Inject()\n\t\tprivate readonly googleTranslateClient: GoogleTranslateClient,\n\t\t@Inject()\n\t\tprivate readonly secretManager: SecretManagerService\n\t) {}\n\n\tpublic async translate(text: string, targetLanguage: string, sourceLanguage?: string): Promise<string> {\n\t\tif (!text?.trim()) {\n\t\t\treturn text;\n\t\t}\n\n\t\tconst input: GoogleTranslateInputDTO = {\n\t\t\tq: text,\n\t\t\ttarget: targetLanguage,\n\t\t\tsource: sourceLanguage,\n\t\t\tformat: 'text',\n\t\t};\n\t\tlogger.info('Google Translate request', {\n\t\t\tinput,\n\t\t});\n\t\ttry {\n\t\t\tconst apiKey = await this.secretManager.getKey('GOOGLE_TRANSLATE_API_KEY');\n\n\t\t\tif (!apiKey) {\n\t\t\t\tthrow new Error('GOOGLE_TRANSLATE_API_KEY is not configured');\n\t\t\t}\n\t\t\tconst result = await this.googleTranslateClient.translate(apiKey, input);\n\t\t\tlogger.info('Google Translate response', {\n\t\t\t\tinput,\n\t\t\t\tresult: result.data,\n\t\t\t});\n\n\t\t\treturn result.data.translations[0]?.translatedText ?? text;\n\t\t} catch (error) {\n\t\t\tlogger.error('Google Translate failed', {\n\t\t\t\tinput,\n\t\t\t\terror,\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async translateBatch(\n\t\ttexts: string[],\n\t\ttargetLanguage: string,\n\t\tsourceLanguage?: string\n\t): Promise<string[]> {\n\t\tif (!texts.length) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst input: GoogleTranslateInputDTO = {\n\t\t\tq: texts,\n\t\t\ttarget: targetLanguage,\n\t\t\tsource: sourceLanguage,\n\t\t\tformat: 'text',\n\t\t};\n\t\tlogger.info('Google Translate request', {\n\t\t\tinput,\n\t\t});\n\n\t\ttry {\n\t\t\tconst apiKey = await this.secretManager.getKey('GOOGLE_TRANSLATE_API_KEY');\n\t\t\tif (!apiKey) {\n\t\t\t\tthrow new Error('GOOGLE_TRANSLATE_API_KEY is not configured');\n\t\t\t}\n\t\t\tconst result = await this.googleTranslateClient.translate(apiKey, input);\n\t\t\tlogger.info('Google Translate batch response', {\n\t\t\t\tinput,\n\t\t\t\tresult: result.data,\n\t\t\t});\n\n\t\t\treturn result.data.translations.map(x => x.translatedText);\n\t\t} catch (error) {\n\t\t\tlogger.error('Google Translate batch failed', {\n\t\t\t\tinput,\n\t\t\t\terror,\n\t\t\t});\n\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.284
25
+ Version: 1.4.285
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.284",
3
+ "version": "1.4.285",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.4.284",
3
+ "version": "1.4.285",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",