@lyxa.ai/core 1.4.162 → 1.4.164
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 +11 -13
- package/dist/index.js.map +1 -1
- package/dist/libraries/index.d.ts +4 -6
- package/dist/libraries/index.js +6 -14
- package/dist/libraries/index.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/delivery-charge-setting.model.d.ts +0 -3
- package/dist/libraries/mongo/models/embedded/delivery-charge-setting.model.js +0 -6
- package/dist/libraries/mongo/models/embedded/delivery-charge-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/zone.model.d.ts +2 -0
- package/dist/libraries/mongo/models/zone.model.js +6 -0
- package/dist/libraries/mongo/models/zone.model.js.map +1 -1
- package/dist/libraries/notification/firebase-fcm.service.d.ts +7 -0
- package/dist/libraries/notification/firebase-fcm.service.js +40 -0
- package/dist/libraries/notification/firebase-fcm.service.js.map +1 -0
- package/dist/libraries/notification/firebase-message.builder.d.ts +22 -0
- package/dist/libraries/notification/firebase-message.builder.js +107 -0
- package/dist/libraries/notification/firebase-message.builder.js.map +1 -0
- package/dist/libraries/notification/index.d.ts +1 -1
- package/dist/libraries/notification/index.js.map +1 -1
- package/dist/libraries/notification/lyxa-fcm-sender.d.ts +13 -0
- package/dist/libraries/notification/lyxa-fcm-sender.js +104 -0
- package/dist/libraries/notification/lyxa-fcm-sender.js.map +1 -0
- package/dist/libraries/notification/lyxa-fcm.service.d.ts +42 -0
- package/dist/libraries/notification/lyxa-fcm.service.js +174 -0
- package/dist/libraries/notification/lyxa-fcm.service.js.map +1 -0
- package/dist/libraries/trpc/middlewares/auth.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/createRoleProtectedProcedure.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/phone-verified.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/publicUserDecoder.d.ts +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/validation/common-validation.d.ts +12 -12
- package/package.json +1 -1
- package/dist/libraries/firebase/fcmService.d.ts +0 -38
- package/dist/libraries/firebase/fcmService.js +0 -267
- package/dist/libraries/firebase/fcmService.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -38,7 +38,6 @@ exports.bootstrapCore = bootstrapCore;
|
|
|
38
38
|
exports.registerLibraries = registerLibraries;
|
|
39
39
|
exports.getLibraries = getLibraries;
|
|
40
40
|
const soft_delete_plugin_1 = require("./libraries/mongo/plugins/soft-delete-plugin");
|
|
41
|
-
(0, soft_delete_plugin_1.applySoftDeletePlugin)();
|
|
42
41
|
const libraries_1 = require("./libraries");
|
|
43
42
|
const typedi_1 = require("typedi");
|
|
44
43
|
const configuration_1 = require("./libraries/configuration");
|
|
@@ -53,7 +52,7 @@ const event_1 = require("./libraries/event");
|
|
|
53
52
|
const SubscriptionRegistry_1 = require("./libraries/event/registry/SubscriptionRegistry");
|
|
54
53
|
const map_1 = require("./libraries/map");
|
|
55
54
|
const settings_1 = require("./libraries/cache/settings");
|
|
56
|
-
const
|
|
55
|
+
const firebase_fcm_service_1 = require("./libraries/notification/firebase-fcm.service");
|
|
57
56
|
const bull_mq_service_1 = require("./libraries/bullmq/bull-mq-service");
|
|
58
57
|
const cash_settlement_1 = require("./libraries/cash-settlement");
|
|
59
58
|
const EnvironmentConfigurationType_1 = require("./libraries/configuration/types/EnvironmentConfigurationType");
|
|
@@ -61,6 +60,10 @@ const osrm_1 = require("./libraries/map/providers/osrm");
|
|
|
61
60
|
const rabbitmq_environments_1 = require("./utilities/environment/rabbitmq-environments");
|
|
62
61
|
const instance_disconnect_1 = require("./libraries/socket/connections/instance-disconnect");
|
|
63
62
|
const logger_kit_1 = require("./libraries/logger-kit");
|
|
63
|
+
const lyxa_fcm_service_1 = require("./libraries/notification/lyxa-fcm.service");
|
|
64
|
+
const lyxa_fcm_sender_1 = require("./libraries/notification/lyxa-fcm-sender");
|
|
65
|
+
const firebase_message_builder_1 = require("./libraries/notification/firebase-message.builder");
|
|
66
|
+
(0, soft_delete_plugin_1.applySoftDeletePlugin)();
|
|
64
67
|
var EnvironmentConfigurationType_2 = require("./libraries/configuration/types/EnvironmentConfigurationType");
|
|
65
68
|
Object.defineProperty(exports, "EnvironmentConfigurationType", { enumerable: true, get: function () { return EnvironmentConfigurationType_2.EnvironmentConfigurationType; } });
|
|
66
69
|
var mongo_2 = require("./libraries/mongo");
|
|
@@ -142,17 +145,12 @@ async function registerLibraries(options) {
|
|
|
142
145
|
catch (error) {
|
|
143
146
|
console.error('Failed to initialize timezone:', error);
|
|
144
147
|
}
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
typedi_1.Container.set(fcmService_1.FCMService, fcmServiceInstance);
|
|
152
|
-
typedi_1.Container.set(fcmService_1.FCMServiceForUser, fcmServiceInstanceForUser);
|
|
153
|
-
typedi_1.Container.set(fcmService_1.FCMServiceForRider, fcmServiceInstanceForRider);
|
|
154
|
-
typedi_1.Container.set(fcmService_1.FCMServiceForShop, fcmServiceInstanceForShop);
|
|
155
|
-
typedi_1.Container.set(fcmService_1.FCMServiceForCpanel, fcmServiceInstanceForCpanel);
|
|
148
|
+
const fcmService = new firebase_fcm_service_1.FirebaseFcmService();
|
|
149
|
+
const builder = new firebase_message_builder_1.FirebaseMessageBuilderFactory();
|
|
150
|
+
const lyxaFcmSender = new lyxa_fcm_sender_1.LyxaFcmSender(fcmService, builder);
|
|
151
|
+
const lyxaFcmService = new lyxa_fcm_service_1.LyxaFcmService(lyxaFcmSender);
|
|
152
|
+
typedi_1.Container.set(firebase_fcm_service_1.FirebaseFcmService, fcmService);
|
|
153
|
+
typedi_1.Container.set(lyxa_fcm_service_1.LyxaFcmService, lyxaFcmService);
|
|
156
154
|
console.log('Initialized everything');
|
|
157
155
|
await (0, event_1.initRabbitMQConnection)(rabbitmq_environments_1.RabbitMQUrlMap[options?.environment ?? EnvironmentConfigurationType_1.EnvironmentConfigurationType.DEV]);
|
|
158
156
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,sCA0BC;AAED,8CAyGC;AAED,oCAEC;AA5KD,qFAAqF;AACrF,IAAA,0CAAqB,GAAE,CAAC;AACxB,2CAA6C;AAC7C,mCAAmC;AACnC,6DAAuF;AACvF,+CAAgD;AAChD,6CAAiD;AACjD,6CAAoF;AACpF,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;AACvD,6CAA6E;AAC7E,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,gEAMyC;AACzC,wEAAmE;AACnE,iEAA4F;AAC5F,+GAA4G;AAC5G,yDAAgE;AAChE,yFAA+E;AAC/E,4FAAuG;AACvG,uDAAuD;AAGvD,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;QACjC,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,IAAI,OAAO,EAAE,YAAY,IAAI,QAAQ;gBAAE,MAAM,IAAA,uDAAiC,GAAE,CAAC;YACjF,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,C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,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';\napplySoftDeletePlugin();\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 {\n\tFCMService,\n\tFCMServiceForCpanel,\n\tFCMServiceForRider,\n\tFCMServiceForShop,\n\tFCMServiceForUser,\n} from './libraries/firebase/fcmService';\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';\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\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 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(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 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\tconst fcmServiceInstanceForCpanel = new FCMService(firebaseService.cpanelApp);\n\tContainer.set(FCMService, fcmServiceInstance);\n\tContainer.set(FCMServiceForUser, fcmServiceInstanceForUser);\n\tContainer.set(FCMServiceForRider, fcmServiceInstanceForRider);\n\tContainer.set(FCMServiceForShop, fcmServiceInstanceForShop);\n\tContainer.set(FCMServiceForCpanel, fcmServiceInstanceForCpanel);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,sCA0BC;AAED,8CAqGC;AAED,oCAEC;AAtKD,qFAAqF;AACrF,2CAA6C;AAC7C,mCAAmC;AACnC,6DAAuF;AACvF,+CAAgD;AAChD,6CAAiD;AACjD,6CAAoF;AACpF,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;AACvD,6CAA6E;AAC7E,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,wFAAmF;AACnF,wEAAmE;AACnE,iEAA4F;AAC5F,+GAA4G;AAC5G,yDAAgE;AAChE,yFAA+E;AAC/E,4FAAuG;AACvG,uDAAuD;AACvD,gFAA2E;AAC3E,8EAAyE;AACzE,gGAAkG;AAElG,IAAA,0CAAqB,GAAE,CAAC;AAGxB,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;QACjC,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,IAAI,OAAO,EAAE,YAAY,IAAI,QAAQ;gBAAE,MAAM,IAAA,uDAAiC,GAAE,CAAC;YACjF,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC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,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';\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';\n\napplySoftDeletePlugin();\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\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 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(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"]}
|
|
@@ -9,11 +9,12 @@ import { FirebaseService } from './firebase';
|
|
|
9
9
|
import { TokenRepository } from './auth/repository';
|
|
10
10
|
import { MapService } from './map';
|
|
11
11
|
import { CachedSettingsService } from './cache/settings';
|
|
12
|
-
import {
|
|
12
|
+
import { FirebaseFcmService } from './notification/firebase-fcm.service';
|
|
13
13
|
import { BullMQService } from './bullmq/bull-mq-service';
|
|
14
14
|
import { BOBService, CashSettlementService } from './cash-settlement';
|
|
15
15
|
import { LyxaLoggerKit } from './logger-kit';
|
|
16
16
|
import { ICloudStorage, StorageProvider } from './cloud-storage';
|
|
17
|
+
import { LyxaFcmService } from './notification/lyxa-fcm.service';
|
|
17
18
|
export declare class LibraryManager {
|
|
18
19
|
getLogger(): LyxaLogger;
|
|
19
20
|
getLoggerKit(): LyxaLoggerKit;
|
|
@@ -30,11 +31,8 @@ export declare class LibraryManager {
|
|
|
30
31
|
getTenetStorageService(provider?: StorageProvider): ICloudStorage;
|
|
31
32
|
getMapService(): MapService;
|
|
32
33
|
getCachedSettingsService(): CachedSettingsService;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
getFCMServiceForRider(): FCMService;
|
|
36
|
-
getFCMServiceForShop(): FCMService;
|
|
37
|
-
FCMServiceForCpanel(): FCMService;
|
|
34
|
+
getLyxaFcmService(): LyxaFcmService;
|
|
35
|
+
getFCMService(): FirebaseFcmService;
|
|
38
36
|
getBullMQService(): BullMQService;
|
|
39
37
|
getCashSettlementService(): CashSettlementService;
|
|
40
38
|
getBOBService(): BOBService;
|
package/dist/libraries/index.js
CHANGED
|
@@ -19,11 +19,12 @@ const firebase_1 = require("./firebase");
|
|
|
19
19
|
const repository_1 = require("./auth/repository");
|
|
20
20
|
const map_1 = require("./map");
|
|
21
21
|
const settings_1 = require("./cache/settings");
|
|
22
|
-
const
|
|
22
|
+
const firebase_fcm_service_1 = require("./notification/firebase-fcm.service");
|
|
23
23
|
const bull_mq_service_1 = require("./bullmq/bull-mq-service");
|
|
24
24
|
const cash_settlement_1 = require("./cash-settlement");
|
|
25
25
|
const logger_kit_1 = require("./logger-kit");
|
|
26
26
|
const cloud_storage_1 = require("./cloud-storage");
|
|
27
|
+
const lyxa_fcm_service_1 = require("./notification/lyxa-fcm.service");
|
|
27
28
|
let LibraryManager = class LibraryManager {
|
|
28
29
|
getLogger() {
|
|
29
30
|
return typedi_1.Container.get(logger_1.LyxaLogger);
|
|
@@ -70,20 +71,11 @@ let LibraryManager = class LibraryManager {
|
|
|
70
71
|
getCachedSettingsService() {
|
|
71
72
|
return typedi_1.Container.get(settings_1.CachedSettingsService);
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
return typedi_1.Container.get(
|
|
75
|
-
}
|
|
76
|
-
getFCMServiceForUser() {
|
|
77
|
-
return typedi_1.Container.get(fcmService_1.FCMServiceForUser);
|
|
78
|
-
}
|
|
79
|
-
getFCMServiceForRider() {
|
|
80
|
-
return typedi_1.Container.get(fcmService_1.FCMServiceForRider);
|
|
74
|
+
getLyxaFcmService() {
|
|
75
|
+
return typedi_1.Container.get(lyxa_fcm_service_1.LyxaFcmService);
|
|
81
76
|
}
|
|
82
|
-
|
|
83
|
-
return typedi_1.Container.get(
|
|
84
|
-
}
|
|
85
|
-
FCMServiceForCpanel() {
|
|
86
|
-
return typedi_1.Container.get(fcmService_1.FCMServiceForCpanel);
|
|
77
|
+
getFCMService() {
|
|
78
|
+
return typedi_1.Container.get(firebase_fcm_service_1.FirebaseFcmService);
|
|
87
79
|
}
|
|
88
80
|
getBullMQService() {
|
|
89
81
|
return typedi_1.Container.get(bull_mq_service_1.BullMQService);
|
|
@@ -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,8EAAyE;AACzE,8DAAyD;AACzD,uDAAsE;AACtE,6CAA6C;AAC7C,mDAAsF;AACtF,sEAAiE;AAG1D,IAAM,cAAc,GAApB,MAAM,cAAc;IACnB,SAAS;QACf,OAAO,kBAAS,CAAC,GAAG,CAAC,mBAAU,CAAC,CAAC;IAClC,CAAC;IACM,YAAY;QAClB,OAAO,kBAAS,CAAC,GAAG,CAAC,0BAAa,CAAC,CAAC;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AEM,iBAAiB;QACvB,OAAO,kBAAS,CAAC,GAAG,CAAC,iCAAc,CAAC,CAAC;IACtC,CAAC;IAEM,aAAa;QACnB,OAAO,kBAAS,CAAC,GAAG,CAAC,yCAAkB,CAAC,CAAC;IAC1C,CAAC;IACM,gBAAgB;QACtB,OAAO,kBAAS,CAAC,GAAG,CAAC,+BAAa,CAAC,CAAC;IACrC,CAAC;IACM,wBAAwB;QAC9B,OAAO,kBAAS,CAAC,GAAG,CAAC,uCAAqB,CAAC,CAAC;IAC7C,CAAC;IACM,aAAa;QACnB,OAAO,kBAAS,CAAC,GAAG,CAAC,4BAAU,CAAC,CAAC;IAClC,CAAC;CACD,CAAA;AAjEY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,gBAAO,GAAE;GACG,cAAc,CAiE1B","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 { FirebaseFcmService } from './notification/firebase-fcm.service';\nimport { BullMQService } from './bullmq/bull-mq-service';\nimport { BOBService, CashSettlementService } from './cash-settlement';\nimport { LyxaLoggerKit } from './logger-kit';\nimport { CloudStorageFactory, ICloudStorage, StorageProvider } from './cloud-storage';\nimport { LyxaFcmService } from './notification/lyxa-fcm.service';\n\n@Service()\nexport class LibraryManager {\n\tpublic getLogger(): LyxaLogger {\n\t\treturn Container.get(LyxaLogger);\n\t}\n\tpublic getLoggerKit(): LyxaLoggerKit {\n\t\treturn Container.get(LyxaLoggerKit);\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\n\tpublic getGlobalStorageService(provider?: StorageProvider): ICloudStorage {\n\t\treturn CloudStorageFactory.create(undefined, provider);\n\t}\n\n\tpublic getTenetStorageService(provider?: StorageProvider): ICloudStorage {\n\t\treturn CloudStorageFactory.create('lyxa-' + this.getConfigurationService().options.tenet, provider);\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\n\tpublic getLyxaFcmService(): LyxaFcmService {\n\t\treturn Container.get(LyxaFcmService);\n\t}\n\n\tpublic getFCMService(): FirebaseFcmService {\n\t\treturn Container.get(FirebaseFcmService);\n\t}\n\tpublic getBullMQService(): BullMQService {\n\t\treturn Container.get(BullMQService);\n\t}\n\tpublic getCashSettlementService(): CashSettlementService {\n\t\treturn Container.get(CashSettlementService);\n\t}\n\tpublic getBOBService(): BOBService {\n\t\treturn Container.get(BOBService);\n\t}\n}\n"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Ref } from '@typegoose/typegoose';
|
|
2
|
-
import { Zone } from '../zone.model';
|
|
3
1
|
export declare class Charge {
|
|
4
2
|
from: number;
|
|
5
3
|
to: number;
|
|
@@ -9,5 +7,4 @@ export declare class Charge {
|
|
|
9
7
|
export declare class DeliveryCharge {
|
|
10
8
|
type: string;
|
|
11
9
|
charges: Charge[];
|
|
12
|
-
zone?: Ref<Zone>;
|
|
13
10
|
}
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.DeliveryCharge = exports.Charge = void 0;
|
|
13
13
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
14
|
const enum_1 = require("../../../../utilities/enum");
|
|
15
|
-
const zone_model_1 = require("../zone.model");
|
|
16
15
|
class Charge {
|
|
17
16
|
from;
|
|
18
17
|
to;
|
|
@@ -39,7 +38,6 @@ __decorate([
|
|
|
39
38
|
class DeliveryCharge {
|
|
40
39
|
type;
|
|
41
40
|
charges;
|
|
42
|
-
zone;
|
|
43
41
|
}
|
|
44
42
|
exports.DeliveryCharge = DeliveryCharge;
|
|
45
43
|
__decorate([
|
|
@@ -50,8 +48,4 @@ __decorate([
|
|
|
50
48
|
(0, typegoose_1.prop)({ type: () => [Charge], default: [] }),
|
|
51
49
|
__metadata("design:type", Array)
|
|
52
50
|
], DeliveryCharge.prototype, "charges", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
(0, typegoose_1.prop)({ ref: () => zone_model_1.Zone }),
|
|
55
|
-
__metadata("design:type", Object)
|
|
56
|
-
], DeliveryCharge.prototype, "zone", void 0);
|
|
57
51
|
//# sourceMappingURL=delivery-charge-setting.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-charge-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/delivery-charge-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAuD;
|
|
1
|
+
{"version":3,"file":"delivery-charge-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/delivery-charge-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAuD;AAGvD,MAAa,MAAM;IAEX,IAAI,CAAU;IAGd,EAAE,CAAU;IAGZ,MAAM,CAAU;IAGhB,QAAQ,CAAU;CACzB;AAZD,wBAYC;AAVO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;oCAC1B;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;kCAC5B;AAGZ;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;sCACxB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;wCACtB;AAG1B,MAAa,cAAc;IAEnB,IAAI,CAAS;IAGb,OAAO,CAAW;CACzB;AAND,wCAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,OAAO,EAAE,gBAAS,CAAC,OAAO,EAAE,CAAC;;4CAChD;AAGb;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;+CACnB","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { OrderType } from '../../../../utilities/enum';\nimport { Zone } from '../zone.model';\n\nexport class Charge {\n\t@prop({ required: true, type: Number, min: 0 })\n\tpublic from!: number;\n\n\t@prop({ required: true, type: Number, min: 0 })\n\tpublic to!: number;\n\n\t@prop({ required: true, type: Number, min: 0 })\n\tpublic charge!: number;\n\n\t@prop({ required: true, type: Number, min: 0 })\n\tpublic riderCut!: number;\n}\n\nexport class DeliveryCharge {\n\t@prop({ type: String, enum: OrderType, default: OrderType.REGULAR })\n\tpublic type: string;\n\n\t@prop({ type: () => [Charge], default: [] })\n\tpublic charges: Charge[];\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
2
2
|
import { ZoneStatus } from '../../../utilities/enum';
|
|
3
3
|
import { ZoneGeometry } from './embedded/zone-geometry.mode';
|
|
4
|
+
import { DeliveryCharge } from './embedded/delivery-charge-setting.model';
|
|
4
5
|
export declare class Zone extends TimeStamps {
|
|
5
6
|
name: string;
|
|
6
7
|
area?: string;
|
|
@@ -12,4 +13,5 @@ export declare class Zone extends TimeStamps {
|
|
|
12
13
|
riderWeeklyReward?: number;
|
|
13
14
|
areaSqKm: number;
|
|
14
15
|
isIncludedReward?: boolean;
|
|
16
|
+
deliveryCharges: DeliveryCharge[];
|
|
15
17
|
}
|
|
@@ -14,6 +14,7 @@ const typegoose_1 = require("@typegoose/typegoose");
|
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const zone_geometry_mode_1 = require("./embedded/zone-geometry.mode");
|
|
17
|
+
const delivery_charge_setting_model_1 = require("./embedded/delivery-charge-setting.model");
|
|
17
18
|
let Zone = class Zone extends defaultClasses_1.TimeStamps {
|
|
18
19
|
name;
|
|
19
20
|
area;
|
|
@@ -25,6 +26,7 @@ let Zone = class Zone extends defaultClasses_1.TimeStamps {
|
|
|
25
26
|
riderWeeklyReward;
|
|
26
27
|
areaSqKm;
|
|
27
28
|
isIncludedReward;
|
|
29
|
+
deliveryCharges;
|
|
28
30
|
};
|
|
29
31
|
exports.Zone = Zone;
|
|
30
32
|
__decorate([
|
|
@@ -67,6 +69,10 @@ __decorate([
|
|
|
67
69
|
(0, typegoose_1.prop)({ type: Boolean, default: true }),
|
|
68
70
|
__metadata("design:type", Boolean)
|
|
69
71
|
], Zone.prototype, "isIncludedReward", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typegoose_1.prop)({ type: () => [delivery_charge_setting_model_1.DeliveryCharge] }),
|
|
74
|
+
__metadata("design:type", Array)
|
|
75
|
+
], Zone.prototype, "deliveryCharges", void 0);
|
|
70
76
|
exports.Zone = Zone = __decorate([
|
|
71
77
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'zones' } }),
|
|
72
78
|
(0, typegoose_1.Index)({ geometry: '2dsphere' })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zone.model.js","sourceRoot":"/","sources":["libraries/mongo/models/zone.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiE;AACjE,4EAAqE;AACrE,kDAAqD;AACrD,sEAA6D;
|
|
1
|
+
{"version":3,"file":"zone.model.js","sourceRoot":"/","sources":["libraries/mongo/models/zone.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiE;AACjE,4EAAqE;AACrE,kDAAqD;AACrD,sEAA6D;AAC7D,4FAA0E;AAInE,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,IAAI,CAAU;IAGd,IAAI,CAAU;IAGd,QAAQ,CAAgB;IAGxB,MAAM,CAAc;IAGpB,SAAS,CAAU;IAGnB,eAAe,CAAU;IAIzB,iBAAiB,CAAU;IAG3B,iBAAiB,CAAU;IAG3B,QAAQ,CAAU;IAIlB,gBAAgB,CAAW;IAG3B,eAAe,CAAmB;CACzC,CAAA;AAnCY,oBAAI;AAET;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCAChC;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCACF;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,iCAAY,EAAE,CAAC;8BAC3B,iCAAY;sCAAC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,OAAO,EAAE,iBAAU,CAAC,MAAM,EAAE,CAAC;;oCAC1C;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uCACG;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CACS;AAIzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;+CACR;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+CACD;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCACd;AAIlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;8CACL;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,8CAAc,CAAC,EAAE,CAAC;;6CACE;eAlC7B,IAAI;IAFhB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;IACxD,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;GACnB,IAAI,CAmChB","sourcesContent":["import { Index, modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ZoneStatus } from '../../../utilities/enum';\nimport { ZoneGeometry } from './embedded/zone-geometry.mode';\nimport { DeliveryCharge } from './embedded/delivery-charge-setting.model';\n\n@modelOptions({ schemaOptions: { collection: 'zones' } })\n@Index({ geometry: '2dsphere' })\nexport class Zone extends TimeStamps {\n\t@prop({ required: true, unique: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic area?: string;\n\n\t@prop({ required: true, type: ZoneGeometry })\n\tpublic geometry!: ZoneGeometry;\n\n\t@prop({ type: String, enum: ZoneStatus, default: ZoneStatus.ACTIVE })\n\tpublic status?: ZoneStatus;\n\n\t@prop({ type: String })\n\tpublic busyTitle?: string;\n\n\t@prop({ type: String })\n\tpublic busyDescription?: string;\n\n\t// Rider reward feature when he reached the target\n\t@prop({ type: Number, default: Infinity })\n\tpublic riderWeeklyTarget?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic riderWeeklyReward?: number;\n\n\t@prop({ type: Number, required: true })\n\tpublic areaSqKm!: number;\n\n\t// Rider reward are not be applied when isIncludedRewared false\n\t@prop({ type: Boolean, default: true })\n\tpublic isIncludedReward?: boolean;\n\n\t@prop({ type: () => [DeliveryCharge] })\n\tpublic deliveryCharges: DeliveryCharge[];\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { messaging } from 'firebase-admin';
|
|
2
|
+
import { FcmProject } from './lyxa-fcm.service';
|
|
3
|
+
export declare class FirebaseFcmService {
|
|
4
|
+
private readonly messagingMap;
|
|
5
|
+
constructor();
|
|
6
|
+
sendMessage(project: FcmProject, message: messaging.MulticastMessage): Promise<import("firebase-admin/lib/messaging/messaging-api").BatchResponse>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FirebaseFcmService = void 0;
|
|
13
|
+
const firebase_admin_1 = require("firebase-admin");
|
|
14
|
+
const __1 = require("../..");
|
|
15
|
+
const typedi_1 = require("typedi");
|
|
16
|
+
const lyxa_fcm_service_1 = require("./lyxa-fcm.service");
|
|
17
|
+
let FirebaseFcmService = class FirebaseFcmService {
|
|
18
|
+
messagingMap;
|
|
19
|
+
constructor() {
|
|
20
|
+
const firebase = (0, __1.getLibraries)().getFirebaseService();
|
|
21
|
+
this.messagingMap = new Map([
|
|
22
|
+
[lyxa_fcm_service_1.FcmProject.USER, (0, firebase_admin_1.messaging)(firebase.userApp)],
|
|
23
|
+
[lyxa_fcm_service_1.FcmProject.RIDER, (0, firebase_admin_1.messaging)(firebase.riderApp)],
|
|
24
|
+
[lyxa_fcm_service_1.FcmProject.SHOP, (0, firebase_admin_1.messaging)(firebase.shopApp)],
|
|
25
|
+
[lyxa_fcm_service_1.FcmProject.CPANEL, (0, firebase_admin_1.messaging)(firebase.cpanelApp)],
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
async sendMessage(project, message) {
|
|
29
|
+
const m = this.messagingMap.get(project);
|
|
30
|
+
if (!m)
|
|
31
|
+
throw new Error(`No messaging instance for project: ${project}`);
|
|
32
|
+
return await m.sendEachForMulticast(message);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.FirebaseFcmService = FirebaseFcmService;
|
|
36
|
+
exports.FirebaseFcmService = FirebaseFcmService = __decorate([
|
|
37
|
+
(0, typedi_1.Service)(),
|
|
38
|
+
__metadata("design:paramtypes", [])
|
|
39
|
+
], FirebaseFcmService);
|
|
40
|
+
//# sourceMappingURL=firebase-fcm.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-fcm.service.js","sourceRoot":"/","sources":["libraries/notification/firebase-fcm.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;AACrC,mCAAiC;AACjC,yDAAgD;AAGzC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACb,YAAY,CAAuC;IAEpE;QACC,MAAM,QAAQ,GAAG,IAAA,gBAAY,GAAE,CAAC,kBAAkB,EAAE,CAAC;QACrD,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC;YAC3B,CAAC,6BAAU,CAAC,IAAI,EAAE,IAAA,0BAAS,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC9C,CAAC,6BAAU,CAAC,KAAK,EAAE,IAAA,0BAAS,EAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChD,CAAC,6BAAU,CAAC,IAAI,EAAE,IAAA,0BAAS,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC9C,CAAC,6BAAU,CAAC,MAAM,EAAE,IAAA,0BAAS,EAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;SAClD,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAAmB,EAAE,OAAmC;QAChF,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;CACD,CAAA;AAlBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,GAAE;;GACG,kBAAkB,CAkB9B","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { getLibraries } from '../..';\nimport { Service } from 'typedi';\nimport { FcmProject } from './lyxa-fcm.service';\n\n@Service()\nexport class FirebaseFcmService {\n\tprivate readonly messagingMap: Map<FcmProject, messaging.Messaging>;\n\n\tconstructor() {\n\t\tconst firebase = getLibraries().getFirebaseService();\n\t\tthis.messagingMap = new Map([\n\t\t\t[FcmProject.USER, messaging(firebase.userApp)],\n\t\t\t[FcmProject.RIDER, messaging(firebase.riderApp)],\n\t\t\t[FcmProject.SHOP, messaging(firebase.shopApp)],\n\t\t\t[FcmProject.CPANEL, messaging(firebase.cpanelApp)],\n\t\t]);\n\t}\n\n\tpublic async sendMessage(project: FcmProject, message: messaging.MulticastMessage) {\n\t\tconst m = this.messagingMap.get(project);\n\t\tif (!m) throw new Error(`No messaging instance for project: ${project}`);\n\t\treturn await m.sendEachForMulticast(message);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { messaging } from 'firebase-admin';
|
|
2
|
+
import { FCMNotificationPayload } from './lyxa-fcm.service';
|
|
3
|
+
export declare enum MultiMessageType {
|
|
4
|
+
OLD = "old",
|
|
5
|
+
CONSOLE = "console",
|
|
6
|
+
DEFAULT = "default"
|
|
7
|
+
}
|
|
8
|
+
export interface IFirebaseMessageBuilder {
|
|
9
|
+
buildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
|
|
10
|
+
}
|
|
11
|
+
export declare class FirebaseMessageBuilderFactory {
|
|
12
|
+
buildMessage(type: MultiMessageType, payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
|
|
13
|
+
}
|
|
14
|
+
export declare class DefaultMessageBuilder implements IFirebaseMessageBuilder {
|
|
15
|
+
buildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
|
|
16
|
+
}
|
|
17
|
+
export declare class OldMessageBuilder implements IFirebaseMessageBuilder {
|
|
18
|
+
buildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
|
|
19
|
+
}
|
|
20
|
+
export declare class ConsoleMessageBuilder implements IFirebaseMessageBuilder {
|
|
21
|
+
buildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
|
|
22
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleMessageBuilder = exports.OldMessageBuilder = exports.DefaultMessageBuilder = exports.FirebaseMessageBuilderFactory = exports.MultiMessageType = void 0;
|
|
4
|
+
var MultiMessageType;
|
|
5
|
+
(function (MultiMessageType) {
|
|
6
|
+
MultiMessageType["OLD"] = "old";
|
|
7
|
+
MultiMessageType["CONSOLE"] = "console";
|
|
8
|
+
MultiMessageType["DEFAULT"] = "default";
|
|
9
|
+
})(MultiMessageType || (exports.MultiMessageType = MultiMessageType = {}));
|
|
10
|
+
class FirebaseMessageBuilderFactory {
|
|
11
|
+
buildMessage(type, payload, tokens) {
|
|
12
|
+
switch (type) {
|
|
13
|
+
case MultiMessageType.CONSOLE:
|
|
14
|
+
return new ConsoleMessageBuilder().buildMessage(payload, tokens);
|
|
15
|
+
case MultiMessageType.OLD:
|
|
16
|
+
return new OldMessageBuilder().buildMessage(payload, tokens);
|
|
17
|
+
default:
|
|
18
|
+
return new DefaultMessageBuilder().buildMessage(payload, tokens);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.FirebaseMessageBuilderFactory = FirebaseMessageBuilderFactory;
|
|
23
|
+
class DefaultMessageBuilder {
|
|
24
|
+
buildMessage(payload, tokens) {
|
|
25
|
+
const isInvisible = payload.invisible === true;
|
|
26
|
+
const channelId = payload.sound ? 'order_alert' : 'default';
|
|
27
|
+
return {
|
|
28
|
+
data: { ...payload.data, channelId: isInvisible ? 'silent' : channelId },
|
|
29
|
+
notification: {
|
|
30
|
+
title: payload.title,
|
|
31
|
+
body: payload.body,
|
|
32
|
+
},
|
|
33
|
+
tokens: tokens,
|
|
34
|
+
android: {
|
|
35
|
+
priority: 'high',
|
|
36
|
+
notification: {
|
|
37
|
+
channelId: 'silent',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
apns: {
|
|
41
|
+
payload: {
|
|
42
|
+
aps: {
|
|
43
|
+
sound: payload.sound || 'default',
|
|
44
|
+
contentAvailable: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
headers: {
|
|
48
|
+
'apns-push-type': 'background',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.DefaultMessageBuilder = DefaultMessageBuilder;
|
|
55
|
+
class OldMessageBuilder {
|
|
56
|
+
buildMessage(payload, tokens) {
|
|
57
|
+
const isInvisible = payload.invisible === true;
|
|
58
|
+
const message = {
|
|
59
|
+
data: payload.data || {},
|
|
60
|
+
notification: {
|
|
61
|
+
title: payload.title,
|
|
62
|
+
body: payload.body,
|
|
63
|
+
},
|
|
64
|
+
tokens: tokens,
|
|
65
|
+
android: { priority: 'high' },
|
|
66
|
+
apns: {
|
|
67
|
+
payload: {
|
|
68
|
+
aps: {
|
|
69
|
+
sound: payload.sound || 'default',
|
|
70
|
+
contentAvailable: true,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
if (!isInvisible) {
|
|
76
|
+
message.notification = {
|
|
77
|
+
title: payload.title,
|
|
78
|
+
body: payload.body,
|
|
79
|
+
};
|
|
80
|
+
message.android = {
|
|
81
|
+
priority: 'high',
|
|
82
|
+
notification: {
|
|
83
|
+
channelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return message;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.OldMessageBuilder = OldMessageBuilder;
|
|
91
|
+
class ConsoleMessageBuilder {
|
|
92
|
+
buildMessage(payload, tokens) {
|
|
93
|
+
const isInvisible = payload.invisible === true;
|
|
94
|
+
const channelId = payload.sound ? 'order_alert' : 'default';
|
|
95
|
+
return {
|
|
96
|
+
data: {
|
|
97
|
+
...payload.data,
|
|
98
|
+
channelId: isInvisible ? 'silent' : channelId,
|
|
99
|
+
notificationTitle: payload.title ?? '',
|
|
100
|
+
notificationBody: payload.body ?? '',
|
|
101
|
+
},
|
|
102
|
+
tokens: tokens,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.ConsoleMessageBuilder = ConsoleMessageBuilder;
|
|
107
|
+
//# sourceMappingURL=firebase-message.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase-message.builder.js","sourceRoot":"/","sources":["libraries/notification/firebase-message.builder.ts"],"names":[],"mappings":";;;AAGA,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC3B,+BAAW,CAAA;IACX,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;AACpB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AAMD,MAAa,6BAA6B;IAClC,YAAY,CAClB,IAAsB,EACtB,OAA+B,EAC/B,MAAgB;QAEhB,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,gBAAgB,CAAC,OAAO;gBAC5B,OAAO,IAAI,qBAAqB,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAClE,KAAK,gBAAgB,CAAC,GAAG;gBACxB,OAAO,IAAI,iBAAiB,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAG9D;gBACC,OAAO,IAAI,qBAAqB,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;IACF,CAAC;CACD;AAjBD,sEAiBC;AAED,MAAa,qBAAqB;IACjC,Y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AAO,CAAC,KAAK,IAAI,SAAS;wBACjC,gBAAgB,EAAE,IAAI;qBACtB;iBACD;aACD;SACD,CAAC;QAEF,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,OAAO,CAAC,YAAY,GAAG;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;aAClB,CAAC;YAEF,OAAO,CAAC,OAAO,GAAG;gBACjB,QAAQ,EAAE,MAAM;gBAChB,YAAY,EAAE;oBACb,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,SAAS;iBAC5E;aACD,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAtCD,8CAsCC;AAED,MAAa,qBAAqB;IACjC,YAAY,CAAC,OAA+B,EAAE,MAAgB;QAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;QAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5D,OAAO;YACN,IAAI,EAAE;gBACL,GAAG,OAAO,CAAC,IAAI;gBACf,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBAC7C,iBAAiB,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;gBACtC,gBAAgB,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;aACpC;YACD,MAAM,EAAE,MAAM;SACd,CAAC;IACH,CAAC;CACD;AAdD,sDAcC","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { FCMNotificationPayload } from './lyxa-fcm.service';\n\nexport enum MultiMessageType {\n\tOLD = 'old',\n\tCONSOLE = 'console',\n\tDEFAULT = 'default',\n}\n\nexport interface IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;\n}\n\nexport class FirebaseMessageBuilderFactory {\n\tpublic buildMessage(\n\t\ttype: MultiMessageType,\n\t\tpayload: FCMNotificationPayload,\n\t\ttokens: string[]\n\t): messaging.MulticastMessage {\n\t\tswitch (type) {\n\t\t\tcase MultiMessageType.CONSOLE:\n\t\t\t\treturn new ConsoleMessageBuilder().buildMessage(payload, tokens);\n\t\t\tcase MultiMessageType.OLD:\n\t\t\t\treturn new OldMessageBuilder().buildMessage(payload, tokens);\n\t\t\t// case MultiMessageType.DEFAULT:\n\t\t\t// \treturn new DefaultMessageBuilder().buildMessage(payload, tokens);\n\t\t\tdefault:\n\t\t\t\treturn new DefaultMessageBuilder().buildMessage(payload, tokens);\n\t\t}\n\t}\n}\n\nexport class DefaultMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\treturn {\n\t\t\tdata: { ...payload.data, channelId: isInvisible ? 'silent' : channelId },\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\ttokens: tokens,\n\t\t\tandroid: {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: 'silent',\n\t\t\t\t},\n\t\t\t},\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\theaders: {\n\t\t\t\t\t'apns-push-type': 'background',\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n}\n\nexport class OldMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: payload.data || {},\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\ttokens: tokens,\n\t\t\tandroid: { priority: 'high' },\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tif (!isInvisible) {\n\t\t\tmessage.notification = {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t};\n\n\t\t\tmessage.android = {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn message;\n\t}\n}\n\nexport class ConsoleMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\t\treturn {\n\t\t\tdata: {\n\t\t\t\t...payload.data,\n\t\t\t\tchannelId: isInvisible ? 'silent' : channelId,\n\t\t\t\tnotificationTitle: payload.title ?? '',\n\t\t\t\tnotificationBody: payload.body ?? '',\n\t\t\t},\n\t\t\ttokens: tokens,\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClickType, NotificationAccountType, PushNotificationEventType } from '../../utilities/enum';
|
|
2
2
|
import { BaseEvent } from '../event/BaseEvent';
|
|
3
3
|
import mongoose from 'mongoose';
|
|
4
|
-
import { FCMNotificationPayload } from '
|
|
4
|
+
import { FCMNotificationPayload } from './lyxa-fcm.service';
|
|
5
5
|
export interface NotificationEventData {
|
|
6
6
|
accountType: NotificationAccountType;
|
|
7
7
|
recipientId: mongoose.Types.ObjectId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/notification/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqG;AACrG,kDAA+C;AAyB/C,MAAa,iBAAkB,SAAQ,qBAAgC;IACtE,YACC,OAEC;QAED,MAAM,YAAY,GAA0B;YAC3C,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrC,CAAC;CACD;AAjBD,8CAiBC;AAED,MAAa,uBAAwB,SAAQ,qBAAsC;IAClF,YACC,OAEC;QAED,MAAM,YAAY,GAAgC;YACjD,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;CACD;AAjBD,0DAiBC","sourcesContent":["import { ClickType, NotificationAccountType, PushNotificationEventType } from '../../utilities/enum';\nimport { BaseEvent } from '../event/BaseEvent';\nimport mongoose from 'mongoose';\nimport { FCMNotificationPayload } from '
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/notification/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqG;AACrG,kDAA+C;AAyB/C,MAAa,iBAAkB,SAAQ,qBAAgC;IACtE,YACC,OAEC;QAED,MAAM,YAAY,GAA0B;YAC3C,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrC,CAAC;CACD;AAjBD,8CAiBC;AAED,MAAa,uBAAwB,SAAQ,qBAAsC;IAClF,YACC,OAEC;QAED,MAAM,YAAY,GAAgC;YACjD,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;CACD;AAjBD,0DAiBC","sourcesContent":["import { ClickType, NotificationAccountType, PushNotificationEventType } from '../../utilities/enum';\nimport { BaseEvent } from '../event/BaseEvent';\nimport mongoose from 'mongoose';\nimport { FCMNotificationPayload } from './lyxa-fcm.service';\n\nexport interface NotificationEventData {\n\taccountType: NotificationAccountType;\n\trecipientId: mongoose.Types.ObjectId;\n\tisClickable: boolean;\n\tclickType?: ClickType | null;\n\tclickableUrl?: string | null;\n\tnotificationType?: PushNotificationEventType;\n\tsaveNotification?: boolean;\n\t[key: string]: any;\n}\n\nexport type NotificationGlobalEventData = Omit<NotificationEventData, 'recipientId'>;\n\nexport interface NotificationEventType extends Omit<FCMNotificationPayload, 'data'> {\n\tdata: NotificationEventData;\n}\n\nexport interface NotificationGlobalEventType extends Omit<FCMNotificationPayload, 'data'> {\n\tdata: NotificationGlobalEventData;\n}\n\nexport class NotificationEvent extends BaseEvent<NotificationEventType> {\n\tconstructor(\n\t\tpayload: Partial<Omit<NotificationEventType, 'data'>> & {\n\t\t\tdata: Partial<NotificationEventData> & { recipientId: mongoose.Types.ObjectId };\n\t\t}\n\t) {\n\t\tconst finalPayload: NotificationEventType = {\n\t\t\t...payload,\n\t\t\tdata: {\n\t\t\t\tisClickable: false,\n\t\t\t\taccountType: NotificationAccountType.USER,\n\t\t\t\t...payload.data,\n\t\t\t},\n\t\t};\n\n\t\tsuper('notification', finalPayload);\n\t}\n}\n\nexport class NotificationGlobalEvent extends BaseEvent<NotificationGlobalEventType> {\n\tconstructor(\n\t\tpayload: Partial<Omit<NotificationGlobalEventType, 'data'>> & {\n\t\t\tdata?: Partial<NotificationGlobalEventData>;\n\t\t}\n\t) {\n\t\tconst finalPayload: NotificationGlobalEventType = {\n\t\t\t...payload,\n\t\t\tdata: {\n\t\t\t\tisClickable: false,\n\t\t\t\taccountType: NotificationAccountType.USER,\n\t\t\t\t...payload.data,\n\t\t\t},\n\t\t};\n\n\t\tsuper('notification-global', finalPayload);\n\t}\n}"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FirebaseFcmService } from './firebase-fcm.service';
|
|
2
|
+
import { FirebaseMessageBuilderFactory, MultiMessageType } from './firebase-message.builder';
|
|
3
|
+
import { FCMNotificationPayload, FcmProject } from './lyxa-fcm.service';
|
|
4
|
+
export declare class LyxaFcmSender {
|
|
5
|
+
private readonly fcmService;
|
|
6
|
+
private readonly builder;
|
|
7
|
+
static readonly MAX_BATCH = 500;
|
|
8
|
+
constructor(fcmService: FirebaseFcmService, builder: FirebaseMessageBuilderFactory);
|
|
9
|
+
sendMessages(project: FcmProject, type: MultiMessageType, tokens: string[], payload: FCMNotificationPayload): Promise<string[]>;
|
|
10
|
+
private buildMultiCastMessages;
|
|
11
|
+
private chunkArray;
|
|
12
|
+
private sendToAllTokens;
|
|
13
|
+
}
|