@lyxa.ai/core 1.0.169 → 1.0.170
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 +8 -1
- package/dist/index.js.map +1 -1
- package/dist/libraries/firebase/fcmService.d.ts +3 -0
- package/dist/libraries/firebase/fcmService.js +4 -1
- package/dist/libraries/firebase/fcmService.js.map +1 -1
- package/dist/libraries/index.d.ts +3 -0
- package/dist/libraries/index.js +9 -0
- package/dist/libraries/index.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/utilities/projection.js +1 -1
- package/dist/utilities/projection.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -81,8 +81,15 @@ async function registerLibraries(options) {
|
|
|
81
81
|
typedi_1.Container.set(map_1.MapService, mapServiceInstance);
|
|
82
82
|
const settingsServiceInstance = new settings_1.CachedSettingsService(redisInstance);
|
|
83
83
|
typedi_1.Container.set(settings_1.CachedSettingsService, settingsServiceInstance);
|
|
84
|
-
const
|
|
84
|
+
const firebaseService = getLibraries().getFirebaseService();
|
|
85
|
+
const fcmServiceInstance = new fcmService_1.FCMService(firebaseService.superApp);
|
|
86
|
+
const fcmServiceInstanceForUser = new fcmService_1.FCMService(firebaseService.userApp);
|
|
87
|
+
const fcmServiceInstanceForRider = new fcmService_1.FCMService(firebaseService.riderApp);
|
|
88
|
+
const fcmServiceInstanceForShop = new fcmService_1.FCMService(firebaseService.shopApp);
|
|
85
89
|
typedi_1.Container.set(fcmService_1.FCMService, fcmServiceInstance);
|
|
90
|
+
typedi_1.Container.set(fcmService_1.FCMServiceForUser, fcmServiceInstanceForUser);
|
|
91
|
+
typedi_1.Container.set(fcmService_1.FCMServiceForRider, fcmServiceInstanceForRider);
|
|
92
|
+
typedi_1.Container.set(fcmService_1.FCMServiceForShop, fcmServiceInstanceForShop);
|
|
86
93
|
console.log('Initialized everything');
|
|
87
94
|
await (0, event_1.initEventBus)('amqps://adlvedna:oY_X4qH1AphtB83YNcf9DHMO3UVmX23s@dog.lmq.cloudamqp.com/adlvedna');
|
|
88
95
|
const allSubscriptions = SubscriptionRegistry_1.SubscriptionRegistry.getAllSubscriptions();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;AA2BA,sCAyBC;AAED,8CA2EC;AAED,oCAEC;AApID,qFAAqF;AACrF,IAAA,0CAAqB,GAAE,CAAC;AAExB,2CAA6C;AAC7C,mCAAmC;AACnC,wDAAgC;AAChC,6DAAuF;AACvF,+GAA4G;AAC5G,+CAAgD;AAChD,6CAAiD;AACjD,6CAAyD;AACzD,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;AACvD,6CAAmE;AACnE,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,gEAA6D;AAC7D,wEAAmE;AAGnE,6GAA4G;AAAnG,4IAAA,4BAA4B,OAAA;AACrC,2CAAyD;AAAhD,6GAAA,oBAAoB,OAAA;AAEtB,KAAK,UAAU,aAAa,CAAC,OAA8B;IACjE,IAAI,CAAC;QACJ,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEjC,YAAY,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QAE/E,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;YACnC,YAAY,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;YAChG,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACxC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QACvC,OAAO,CAAC,EAAE,CAAC,mBAAmB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,CAAC;IACzE,kBAAS,CAAC,GAAG,CAAC,gCAAqB,EAAE,uBAAuB,CAAC,CAAC;IAG9D,MAAM,kBAAkB,GAAG,IAAI,uBAAU,EAAE,CAAC;IAC5C,kBAAS,CAAC,GAAG,CAAC,uBAAU,EAAE,kBAAkB,CAAC,CAAC;IAE9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAEtC,MAAM,IAAA,oBAAY,EAAC,kFAAkF,CAAC,CAAC;IACvG,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;YAC/C,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,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';\napplySoftDeletePlugin();\n\nimport { LibraryManager } from './libraries';\nimport { Container } from 'typedi';\nimport mongoose from 'mongoose';\nimport { ConfigurationOptions, ConfigurationService } from './libraries/configuration';\nimport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nimport { LyxaLogger } from './libraries/logger';\nimport { RedisService } from './libraries/redis';\nimport { initGlobalConnection } from './libraries/mongo';\nimport { SecretManagerService } from './libraries/secrets';\nimport { MicroServiceDispatcher } from './libraries/dispatcher';\nimport { TwilioService } from './libraries/twilio';\nimport { FirebaseService } from './libraries/firebase';\nimport { initEventBus, subscribeToEvent } from './libraries/event';\nimport { SubscriptionRegistry } from './libraries/event/registry/SubscriptionRegistry';\nimport { MapService, GoogleMapsService } from './libraries/map';\nimport { CachedSettingsService } from './libraries/cache/settings';\nimport { FCMService } from './libraries/firebase/fcmService';\nimport { BullMQService } from './libraries/bullmq/bull-mq-service';\n\nexport { ConfigurationOptions } from './libraries/configuration';\nexport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nexport { initGlobalConnection } from './libraries/mongo';\n\nexport async function bootstrapCore(options?: ConfigurationOptions) {\n\ttry {\n\t\tawait registerLibraries(options);\n\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\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\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.options.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\n\tconst bullMQInstance = new BullMQService(redisInstance);\n\tContainer.set(BullMQService, bullMQInstance);\n\n\tconst mongoUrl = await getLibraries().getSecretsService().getKey('MONGO_URL');\n\n\tawait mongoose.connect(mongoUrl!, { dbName: `lyxa-${options!.environment}-${options!.tenet}` });\n\tmongoose.set(\n\t\t'debug',\n\t\tgetLibraries().getConfigurationService().options.environment == EnvironmentConfigurationType.DEV\n\t);\n\n\tawait initGlobalConnection(mongoUrl!, options!.environment);\n\n\t// Setup logger\n\tconst loggerInstance = new LyxaLogger(options!.instanceType!, mongoUrl!);\n\tContainer.set(LyxaLogger, loggerInstance);\n\n\t// Setup firebase\n\tconst firebaseInstance = new FirebaseService(configurationInstance!);\n\tContainer.set(FirebaseService, firebaseInstance);\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 map service\n\tconst googleMapsKey = await getLibraries().getSecretsService().getKey('GOOGLE_MAPS_API_KEY');\n\tconst googleMapService = new GoogleMapsService(googleMapsKey as string);\n\tconst mapServiceInstance = new MapService(googleMapService);\n\tContainer.set(MapService, mapServiceInstance);\n\n\tconst settingsServiceInstance = new CachedSettingsService(redisInstance);\n\tContainer.set(CachedSettingsService, settingsServiceInstance);\n\n\t// Setup fcm service\n\tconst fcmServiceInstance = new FCMService();\n\tContainer.set(FCMService, fcmServiceInstance);\n\n\tconsole.log('Initialized everything');\n\n\tawait initEventBus('amqps://adlvedna:oY_X4qH1AphtB83YNcf9DHMO3UVmX23s@dog.lmq.cloudamqp.com/adlvedna');\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 => {\n\t\t\treturn instance[methodName](payload);\n\t\t});\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":";;;;;;AA2BA,sCAyBC;AAED,8CAkFC;AAED,oCAEC;AA3ID,qFAAqF;AACrF,IAAA,0CAAqB,GAAE,CAAC;AAExB,2CAA6C;AAC7C,mCAAmC;AACnC,wDAAgC;AAChC,6DAAuF;AACvF,+GAA4G;AAC5G,+CAAgD;AAChD,6CAAiD;AACjD,6CAAyD;AACzD,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;AACvD,6CAAmE;AACnE,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,gEAAuH;AACvH,wEAAmE;AAGnE,6GAA4G;AAAnG,4IAAA,4BAA4B,OAAA;AACrC,2CAAyD;AAAhD,6GAAA,oBAAoB,OAAA;AAEtB,KAAK,UAAU,aAAa,CAAC,OAA8B;IACjE,IAAI,CAAC;QACJ,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEjC,YAAY,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QAE/E,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;YACnC,YAAY,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;YAChG,OA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;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;YAC/C,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,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';\napplySoftDeletePlugin();\n\nimport { LibraryManager } from './libraries';\nimport { Container } from 'typedi';\nimport mongoose from 'mongoose';\nimport { ConfigurationOptions, ConfigurationService } from './libraries/configuration';\nimport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nimport { LyxaLogger } from './libraries/logger';\nimport { RedisService } from './libraries/redis';\nimport { initGlobalConnection } from './libraries/mongo';\nimport { SecretManagerService } from './libraries/secrets';\nimport { MicroServiceDispatcher } from './libraries/dispatcher';\nimport { TwilioService } from './libraries/twilio';\nimport { FirebaseService } from './libraries/firebase';\nimport { initEventBus, subscribeToEvent } from './libraries/event';\nimport { SubscriptionRegistry } from './libraries/event/registry/SubscriptionRegistry';\nimport { MapService, GoogleMapsService } from './libraries/map';\nimport { CachedSettingsService } from './libraries/cache/settings';\nimport { FCMService, FCMServiceForRider, FCMServiceForShop, FCMServiceForUser } from './libraries/firebase/fcmService';\nimport { BullMQService } from './libraries/bullmq/bull-mq-service';\n\nexport { ConfigurationOptions } from './libraries/configuration';\nexport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nexport { initGlobalConnection } from './libraries/mongo';\n\nexport async function bootstrapCore(options?: ConfigurationOptions) {\n\ttry {\n\t\tawait registerLibraries(options);\n\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\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\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.options.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\n\tconst bullMQInstance = new BullMQService(redisInstance);\n\tContainer.set(BullMQService, bullMQInstance);\n\n\tconst mongoUrl = await getLibraries().getSecretsService().getKey('MONGO_URL');\n\n\tawait mongoose.connect(mongoUrl!, { dbName: `lyxa-${options!.environment}-${options!.tenet}` });\n\tmongoose.set(\n\t\t'debug',\n\t\tgetLibraries().getConfigurationService().options.environment == EnvironmentConfigurationType.DEV\n\t);\n\n\tawait initGlobalConnection(mongoUrl!, options!.environment);\n\n\t// Setup logger\n\tconst loggerInstance = new LyxaLogger(options!.instanceType!, mongoUrl!);\n\tContainer.set(LyxaLogger, loggerInstance);\n\n\t// Setup firebase\n\tconst firebaseInstance = new FirebaseService(configurationInstance!);\n\tContainer.set(FirebaseService, firebaseInstance);\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 map service\n\tconst googleMapsKey = await getLibraries().getSecretsService().getKey('GOOGLE_MAPS_API_KEY');\n\tconst googleMapService = new GoogleMapsService(googleMapsKey as string);\n\tconst mapServiceInstance = new MapService(googleMapService);\n\tContainer.set(MapService, mapServiceInstance);\n\n\tconst settingsServiceInstance = new CachedSettingsService(redisInstance);\n\tContainer.set(CachedSettingsService, settingsServiceInstance);\n\n\t// Setup fcm service\n\tconst firebaseService = getLibraries().getFirebaseService();\n\tconst fcmServiceInstance = new FCMService(firebaseService.superApp);\n\tconst fcmServiceInstanceForUser = new FCMService(firebaseService.userApp);\n\tconst fcmServiceInstanceForRider = new FCMService(firebaseService.riderApp);\n\tconst fcmServiceInstanceForShop = new FCMService(firebaseService.shopApp);\n\tContainer.set(FCMService, fcmServiceInstance);\n\tContainer.set(FCMServiceForUser, fcmServiceInstanceForUser);\n\tContainer.set(FCMServiceForRider, fcmServiceInstanceForRider);\n\tContainer.set(FCMServiceForShop, fcmServiceInstanceForShop);\n\n\tconsole.log('Initialized everything');\n\n\tawait initEventBus('amqps://adlvedna:oY_X4qH1AphtB83YNcf9DHMO3UVmX23s@dog.lmq.cloudamqp.com/adlvedna');\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 => {\n\t\t\treturn instance[methodName](payload);\n\t\t});\n\t}\n}\n\nexport function getLibraries(): LibraryManager {\n\treturn Container.get(LibraryManager);\n}\n"]}
|
|
@@ -4,6 +4,9 @@ export interface FCMNotificationPayload {
|
|
|
4
4
|
body: string;
|
|
5
5
|
data?: Record<string, string>;
|
|
6
6
|
}
|
|
7
|
+
export declare const FCMServiceForUser = "fcm.service.user";
|
|
8
|
+
export declare const FCMServiceForRider = "fcm.service.rider";
|
|
9
|
+
export declare const FCMServiceForShop = "fcm.service.shop";
|
|
7
10
|
export declare class FCMService {
|
|
8
11
|
private messaging;
|
|
9
12
|
constructor(app?: App);
|
|
@@ -9,10 +9,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FCMService = void 0;
|
|
12
|
+
exports.FCMService = exports.FCMServiceForShop = exports.FCMServiceForRider = exports.FCMServiceForUser = void 0;
|
|
13
13
|
const firebase_admin_1 = require("firebase-admin");
|
|
14
14
|
const __1 = require("../..");
|
|
15
15
|
const typedi_1 = require("typedi");
|
|
16
|
+
exports.FCMServiceForUser = 'fcm.service.user';
|
|
17
|
+
exports.FCMServiceForRider = 'fcm.service.rider';
|
|
18
|
+
exports.FCMServiceForShop = 'fcm.service.shop';
|
|
16
19
|
let FCMService = class FCMService {
|
|
17
20
|
messaging;
|
|
18
21
|
constructor(app) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fcmService.js","sourceRoot":"/","sources":["libraries/firebase/fcmService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;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G,CAAC,CAAC,CAAC;gBACjC,CAAC;qBAAM,CAAC;oBACP,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC;oBACnC,IACC,SAAS,KAAK,4BAA4B;wBAC1C,SAAS,KAAK,6CAA6C,EAC1D,CAAC;wBACF,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;oBAChC,CAAC;oBACD,OAAO,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAC1E,CAAC;YACF,CAAC,CAAC,CAAC;YAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;QACxC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;YAClD,MAAM,GAAG,CAAC;QACX,CAAC;IACF,CAAC;CACD,CAAA;AAxDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CAwDtB","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { getLibraries } from '../..';\nimport { Service } from 'typedi';\nimport { App } from 'firebase-admin/app';\n\nexport interface FCMNotificationPayload {\n\ttitle: string;\n\tbody: string;\n\tdata?: Record<string, string>;\n}\n\nexport const FCMServiceForUser = 'fcm.service.user';\nexport const FCMServiceForRider = 'fcm.service.rider';\nexport const FCMServiceForShop = 'fcm.service.shop';\n\n@Service()\nexport class FCMService {\n\tprivate messaging!: messaging.Messaging;\n\n\tconstructor(app?: App) {\n\t\tconst firebaseApp = app ?? getLibraries().getFirebaseService().superApp;\n\t\tthis.messaging = messaging(firebaseApp);\n\t}\n\n\t/**\n\t * Sends a push notification to multiple device tokens\n\t * @param payload - Notification title, body, and optional data\n\t * @param tokens - FCM device tokens\n\t * @returns Object containing success and invalid tokens\n\t */\n\tasync sendNotification(\n\t\tpayload: FCMNotificationPayload,\n\t\ttokens: string[]\n\t): Promise<{ successTokens: string[]; failedTokens: string[] }> {\n\t\tif (!tokens.length) return { successTokens: [], failedTokens: [] };\n\n\t\tconst message = {\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\tdata: payload.data || {},\n\t\t\ttokens,\n\t\t};\n\n\t\ttry {\n\t\t\tconst response = await this.messaging.sendEachForMulticast(message);\n\n\t\t\tconst successTokens: string[] = [];\n\t\t\tconst failedTokens: string[] = [];\n\n\t\t\tresponse.responses.forEach((resp, idx) => {\n\t\t\t\tif (resp.success) {\n\t\t\t\t\tsuccessTokens.push(tokens[idx]);\n\t\t\t\t} else {\n\t\t\t\t\tconst errorCode = resp.error?.code;\n\t\t\t\t\tif (\n\t\t\t\t\t\terrorCode === 'messaging/invalid-argument' ||\n\t\t\t\t\t\terrorCode === 'messaging/registration-token-not-registered'\n\t\t\t\t\t) {\n\t\t\t\t\t\tfailedTokens.push(tokens[idx]);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(`FCM Error for token ${tokens[idx]}:`, resp.error?.message);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn { successTokens, failedTokens };\n\t\t} catch (err) {\n\t\t\tconsole.error('FCM sendNotification error:', err);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -25,5 +25,8 @@ export declare class LibraryManager {
|
|
|
25
25
|
getMapService(): MapService;
|
|
26
26
|
getCachedSettingsService(): CachedSettingsService;
|
|
27
27
|
getFCMService(): FCMService;
|
|
28
|
+
getFCMServiceForUser(): FCMService;
|
|
29
|
+
getFCMServiceForRider(): FCMService;
|
|
30
|
+
getFCMServiceForShop(): FCMService;
|
|
28
31
|
getBullMQService(): BullMQService;
|
|
29
32
|
}
|
package/dist/libraries/index.js
CHANGED
|
@@ -61,6 +61,15 @@ let LibraryManager = class LibraryManager {
|
|
|
61
61
|
getFCMService() {
|
|
62
62
|
return typedi_1.Container.get(fcmService_1.FCMService);
|
|
63
63
|
}
|
|
64
|
+
getFCMServiceForUser() {
|
|
65
|
+
return typedi_1.Container.get(fcmService_1.FCMServiceForUser);
|
|
66
|
+
}
|
|
67
|
+
getFCMServiceForRider() {
|
|
68
|
+
return typedi_1.Container.get(fcmService_1.FCMServiceForRider);
|
|
69
|
+
}
|
|
70
|
+
getFCMServiceForShop() {
|
|
71
|
+
return typedi_1.Container.get(fcmService_1.FCMServiceForShop);
|
|
72
|
+
}
|
|
64
73
|
getBullMQService() {
|
|
65
74
|
return typedi_1.Container.get(bull_mq_service_1.BullMQService);
|
|
66
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAA4C;AAC5C,qCAAyC;AACzC,qCAAsC;AACtC,6CAAsD;AACtD,uCAAiD;AACjD,mCAAuC;AACvC,mDAAuD;AACvD,qCAAyC;AACzC,yCAA6C;AAC7C,kDAAoD;AACpD,+BAAmC;AACnC,+CAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAA4C;AAC5C,qCAAyC;AACzC,qCAAsC;AACtC,6CAAsD;AACtD,uCAAiD;AACjD,mCAAuC;AACvC,mDAAuD;AACvD,qCAAyC;AACzC,yCAA6C;AAC7C,kDAAoD;AACpD,+BAAmC;AACnC,+CAAyD;AACzD,sDAA6G;AAC7G,8DAAyD;AAGlD,IAAM,cAAc,GAApB,MAAM,cAAc;IACnB,SAAS;QACf,OAAO,kBAAS,CAAC,GAAG,CAAC,mBAAU,CAAC,CAAC;IAClC,CAAC;IACM,yBAAyB;QAC/B,OAAO,kBAAS,CAAC,GAAG,CAAC,mCAAsB,CAAC,CAAC;IAC9C,CAAC;IACM,gBAAgB;QACtB,OAAO,kBAAS,CAAC,GAAG,CAAC,sBAAa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,wCAAc;yBAAd,cAAc;IAD1B,IAAA,gBAAO,GAAE;GACG,cAAc,CAoD1B","sourcesContent":["import { Container, Service } from 'typedi';\nimport { TwilioService } from './twilio';\nimport { LyxaLogger } from './logger';\nimport { MicroServiceDispatcher } from './dispatcher';\nimport { SecretManagerService } from './secrets';\nimport { RedisService } from './redis';\nimport { ConfigurationService } from './configuration';\nimport { UploadService } from './upload';\nimport { FirebaseService } from './firebase';\nimport { TokenRepository } from './auth/repository';\nimport { MapService } from './map';\nimport { CachedSettingsService } from './cache/settings';\nimport { FCMService, FCMServiceForRider, FCMServiceForShop, FCMServiceForUser } from './firebase/fcmService';\nimport { BullMQService } from './bullmq/bull-mq-service';\n\n@Service()\nexport class LibraryManager {\n\tpublic getLogger(): LyxaLogger {\n\t\treturn Container.get(LyxaLogger);\n\t}\n\tpublic getMicroServiceDispatcher(): MicroServiceDispatcher {\n\t\treturn Container.get(MicroServiceDispatcher);\n\t}\n\tpublic getTwilioService(): TwilioService {\n\t\treturn Container.get(TwilioService);\n\t}\n\tpublic getSecretsService(): SecretManagerService {\n\t\treturn Container.get(SecretManagerService);\n\t}\n\tpublic getRedisService(): RedisService {\n\t\treturn Container.get(RedisService);\n\t}\n\tpublic getConfigurationService(): ConfigurationService {\n\t\treturn Container.get(ConfigurationService);\n\t}\n\tpublic getFirebaseService(): FirebaseService {\n\t\treturn Container.get(FirebaseService);\n\t}\n\tpublic getAuthTokenRepository(): TokenRepository {\n\t\treturn Container.get(TokenRepository);\n\t}\n\tpublic getGlobalUploadService(): UploadService {\n\t\treturn new UploadService();\n\t}\n\tpublic getTenetUploadService(): UploadService {\n\t\treturn new UploadService('lyxa-' + this.getConfigurationService().options.tenet);\n\t}\n\tpublic getMapService(): MapService {\n\t\treturn Container.get(MapService);\n\t}\n\tpublic getCachedSettingsService(): CachedSettingsService {\n\t\treturn Container.get(CachedSettingsService);\n\t}\n\tpublic getFCMService(): FCMService {\n\t\treturn Container.get(FCMService);\n\t}\n\tpublic getFCMServiceForUser(): FCMService {\n\t\treturn Container.get(FCMServiceForUser);\n\t}\n\tpublic getFCMServiceForRider(): FCMService {\n\t\treturn Container.get(FCMServiceForRider);\n\t}\n\tpublic getFCMServiceForShop(): FCMService {\n\t\treturn Container.get(FCMServiceForShop);\n\t}\n\tpublic getBullMQService(): BullMQService {\n\t\treturn Container.get(BullMQService);\n\t}\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -11,7 +11,7 @@ var ProjectionType;
|
|
|
11
11
|
ProjectionType["ADMIN"] = "admin";
|
|
12
12
|
})(ProjectionType || (exports.ProjectionType = ProjectionType = {}));
|
|
13
13
|
const excludedFieldsMap = {
|
|
14
|
-
[ProjectionType.USER]: ['phoneOtpInfo fcmTokens'],
|
|
14
|
+
[ProjectionType.USER]: ['phoneOtpInfo', 'fcmTokens'],
|
|
15
15
|
[ProjectionType.SHOP]: ['fcmTokens'],
|
|
16
16
|
[ProjectionType.PARENT]: [],
|
|
17
17
|
[ProjectionType.RIDER]: ['password', 'fcmToken', 'forgetToken', 'forgetExpired'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.js","sourceRoot":"/","sources":["utilities/projection.ts"],"names":[],"mappings":";;;AAoDA,sCAMC;AA1DD,IAAY,cAMX;AAND,WAAY,cAAc;IACzB,+BAAa,CAAA;IACb,+BAAa,CAAA;IACb,mCAAiB,CAAA;IACjB,iCAAe,CAAA;IACf,iCAAe,CAAA;AAChB,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB;AAED,MAAM,iBAAiB,GAAqC;IAC3D,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"/","sources":["utilities/projection.ts"],"names":[],"mappings":";;;AAoDA,sCAMC;AA1DD,IAAY,cAMX;AAND,WAAY,cAAc;IACzB,+BAAa,CAAA;IACb,+BAAa,CAAA;IACb,mCAAiB,CAAA;IACjB,iCAA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const excludedFieldsMap: Record<ProjectionType, string[]> = {\n\t[ProjectionType.USER]: ['phoneOtpInfo', 'fcmTokens'],\n\t[ProjectionType.SHOP]: ['fcmTokens'],\n\t[ProjectionType.PARENT]: [],\n\t[ProjectionType.RIDER]: ['password', 'fcmToken', 'forgetToken', 'forgetExpired'],\n\t[ProjectionType.ADMIN]: [],\n};\n\n/**\n * Utility to exclude specific fields from a MongoDB projection/select object.\n *\n * @param select - Existing projection object or undefined.\n * @param fieldsToExclude - Array of field names to exclude.\n * @returns A new projection object with specified fields excluded.\n */\nfunction excludeFieldsFromProjection(\n\tselect: Record<string, any> | null | undefined,\n\tfieldsToExclude: string[]\n): Record<string, 0 | 1> {\n\t// Case 1: If select object exists, clone and delete excluded fields\n\tif (select && typeof select === 'object') {\n\t\tconst newSelect: Record<string, 0 | 1> = { ...select };\n\n\t\tfor (const field of fieldsToExclude) {\n\t\t\tdelete newSelect[field];\n\t\t}\n\n\t\treturn newSelect;\n\t}\n\n\t// Case 2: No select provided, create one with excluded fields only\n\treturn fieldsToExclude.reduce<Record<string, 0>>((acc, field) => {\n\t\tacc[field] = 0;\n\t\treturn acc;\n\t}, {});\n}\n\n/**\n * Dynamically excludes fields from a projection based on model type.\n *\n * @param select - The existing MongoDB projection object.\n * @param model - The model type (e.g., 'user', 'shop').\n * @returns A new projection object with model-specific fields excluded.\n */\nexport function excludeFields(\n\tselect: Record<string, any> | null | undefined,\n\ttype: ProjectionType\n): Record<string, 0 | 1> {\n\tconst fieldsToExclude = excludedFieldsMap[type] || [];\n\treturn excludeFieldsFromProjection(select, fieldsToExclude);\n}\n"]}
|