@lyxa.ai/core 1.1.2 → 1.1.4
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 +3 -25
- package/dist/index.js.map +1 -1
- package/dist/libraries/event/EventEnums.d.ts +2 -1
- package/dist/libraries/event/EventEnums.js +1 -0
- package/dist/libraries/event/EventEnums.js.map +1 -1
- package/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event.d.ts +36 -0
- package/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event.js +36 -0
- package/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event.js.map +1 -0
- package/dist/libraries/mongo/index.d.ts +3 -0
- package/dist/libraries/mongo/index.js +38 -2
- package/dist/libraries/mongo/index.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/validation/validation-for-frontend.js +3 -3
- package/dist/types/utilities/validation/validation-for-frontend.js.map +1 -1
- package/dist/utilities/events-common-methods.d.ts +2 -0
- package/dist/utilities/events-common-methods.js +6 -0
- package/dist/utilities/events-common-methods.js.map +1 -1
- package/dist/utilities/validation/validation-for-frontend.js +3 -3
- package/dist/utilities/validation/validation-for-frontend.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.initGlobalConnection = exports.EnvironmentConfigurationType = void 0;
|
|
7
4
|
exports.bootstrapCore = bootstrapCore;
|
|
@@ -11,9 +8,7 @@ const soft_delete_plugin_1 = require("./libraries/mongo/plugins/soft-delete-plug
|
|
|
11
8
|
(0, soft_delete_plugin_1.applySoftDeletePlugin)();
|
|
12
9
|
const libraries_1 = require("./libraries");
|
|
13
10
|
const typedi_1 = require("typedi");
|
|
14
|
-
const mongoose_1 = __importDefault(require("mongoose"));
|
|
15
11
|
const configuration_1 = require("./libraries/configuration");
|
|
16
|
-
const EnvironmentConfigurationType_1 = require("./libraries/configuration/types/EnvironmentConfigurationType");
|
|
17
12
|
const logger_1 = require("./libraries/logger");
|
|
18
13
|
const redis_1 = require("./libraries/redis");
|
|
19
14
|
const mongo_1 = require("./libraries/mongo");
|
|
@@ -29,8 +24,8 @@ const fcmService_1 = require("./libraries/firebase/fcmService");
|
|
|
29
24
|
const bull_mq_service_1 = require("./libraries/bullmq/bull-mq-service");
|
|
30
25
|
const cash_settlement_1 = require("./libraries/cash-settlement");
|
|
31
26
|
const socket_1 = require("./libraries/socket");
|
|
32
|
-
var
|
|
33
|
-
Object.defineProperty(exports, "EnvironmentConfigurationType", { enumerable: true, get: function () { return
|
|
27
|
+
var EnvironmentConfigurationType_1 = require("./libraries/configuration/types/EnvironmentConfigurationType");
|
|
28
|
+
Object.defineProperty(exports, "EnvironmentConfigurationType", { enumerable: true, get: function () { return EnvironmentConfigurationType_1.EnvironmentConfigurationType; } });
|
|
34
29
|
var mongo_2 = require("./libraries/mongo");
|
|
35
30
|
Object.defineProperty(exports, "initGlobalConnection", { enumerable: true, get: function () { return mongo_2.initGlobalConnection; } });
|
|
36
31
|
async function bootstrapCore(options) {
|
|
@@ -70,24 +65,7 @@ async function registerLibraries(options) {
|
|
|
70
65
|
const mongoUrl = options?.mongoDbUrl
|
|
71
66
|
? options.mongoDbUrl
|
|
72
67
|
: await getLibraries().getSecretsService().getKey('MONGO_URL');
|
|
73
|
-
await
|
|
74
|
-
dbName: `lyxa-${options.environment}-${options.tenet}`,
|
|
75
|
-
maxPoolSize: 20,
|
|
76
|
-
minPoolSize: 4,
|
|
77
|
-
maxIdleTimeMS: 30000,
|
|
78
|
-
waitQueueTimeoutMS: 10000,
|
|
79
|
-
retryWrites: true,
|
|
80
|
-
w: 1,
|
|
81
|
-
readPreference: 'primary',
|
|
82
|
-
readConcern: { level: 'local' },
|
|
83
|
-
serverSelectionTimeoutMS: 5000,
|
|
84
|
-
heartbeatFrequencyMS: 10000,
|
|
85
|
-
bufferCommands: false,
|
|
86
|
-
compressors: ['zlib'],
|
|
87
|
-
});
|
|
88
|
-
mongoose_1.default.set('debug', options?.mongooseDebug !== undefined
|
|
89
|
-
? options?.mongooseDebug
|
|
90
|
-
: getLibraries().getConfigurationService().options.environment == EnvironmentConfigurationType_1.EnvironmentConfigurationType.DEV);
|
|
68
|
+
await (0, mongo_1.initLyxaMongoDbConnection)(mongoUrl, options);
|
|
91
69
|
await (0, mongo_1.initGlobalConnection)(mongoUrl, options.environment);
|
|
92
70
|
const loggerInstance = new logger_1.LyxaLogger(options.instanceType, mongoUrl);
|
|
93
71
|
typedi_1.Container.set(logger_1.LyxaLogger, loggerInstance);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;AAmCA,sCA0BC;AAED,8CAiHC;AAED,oCAEC;AAnLD,qFAAqF;AAErF,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,gEAKyC;AACzC,wEAAmE;AACnE,iEAA4F;AAC5F,+CAAuE;AAGvE,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,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C,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';\n\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 {\n\tFCMService,\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 { disconnectAllEntitiesFromInstance } from './libraries/socket';\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\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\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 mongoose.connect(mongoUrl!, {\n\t\tdbName: `lyxa-${options!.environment}-${options!.tenet}`,\n\t\tmaxPoolSize: 20,\n\t\tminPoolSize: 4,\n\t\tmaxIdleTimeMS: 30000,\n\t\twaitQueueTimeoutMS: 10000,\n\t\tretryWrites: true,\n\t\tw: 1,\n\t\treadPreference: 'primary',\n\t\treadConcern: { level: 'local' },\n\t\tserverSelectionTimeoutMS: 5000,\n\t\theartbeatFrequencyMS: 10000,\n\t\tbufferCommands: false,\n\t\tcompressors: ['zlib'], // Reduces network traffic\n\t});\n\tmongoose.set(\n\t\t'debug',\n\t\toptions?.mongooseDebug !== undefined\n\t\t\t? options?.mongooseDebug\n\t\t\t: getLibraries().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\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\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"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;AAiCA,sCA0BC;AAED,8CA4FC;AAED,oCAEC;AA5JD,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;AACvD,6CAAmE;AACnE,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,gEAKyC;AACzC,wEAAmE;AACnE,iEAA4F;AAC5F,+CAAuE;AAGvE,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,IAAI,OAAO,EAAE,YAAY,IAAI,QAAQ;gBAAE,MAAM,IAAA,0CAAiC,GAAE,CAAC;YACjF,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,EAAE,GAAG,CAAC,EAAE;YACrC,YAAY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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';\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 { 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 {\n\tFCMService,\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 { disconnectAllEntitiesFromInstance } from './libraries/socket';\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\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\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\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\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\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}"]}
|
|
@@ -3,5 +3,6 @@ export declare enum PublishEventEnums {
|
|
|
3
3
|
MESSAGE_RECEIVED_EVENT = "message_received_event",
|
|
4
4
|
TICKET_NOTIFICATION_EVENT = "ticket_notification_event",
|
|
5
5
|
CART_ITEM_UPSERT_EVENT = "cart_item_upsert_event",
|
|
6
|
-
SHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT = "shop_active_timings_batch_process_event"
|
|
6
|
+
SHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT = "shop_active_timings_batch_process_event",
|
|
7
|
+
MONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT = "mongo_stream_changes_batch_process_shops_event"
|
|
7
8
|
}
|
|
@@ -8,5 +8,6 @@ var PublishEventEnums;
|
|
|
8
8
|
PublishEventEnums["TICKET_NOTIFICATION_EVENT"] = "ticket_notification_event";
|
|
9
9
|
PublishEventEnums["CART_ITEM_UPSERT_EVENT"] = "cart_item_upsert_event";
|
|
10
10
|
PublishEventEnums["SHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT"] = "shop_active_timings_batch_process_event";
|
|
11
|
+
PublishEventEnums["MONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT"] = "mongo_stream_changes_batch_process_shops_event";
|
|
11
12
|
})(PublishEventEnums || (exports.PublishEventEnums = PublishEventEnums = {}));
|
|
12
13
|
//# sourceMappingURL=EventEnums.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventEnums.js","sourceRoot":"/","sources":["libraries/event/EventEnums.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"EventEnums.js","sourceRoot":"/","sources":["libraries/event/EventEnums.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAOX;AAPD,WAAY,iBAAiB;IAC5B,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,wGAAmF,CAAA;IACnF,sHAAiG,CAAA;AAClG,CAAC,EAPW,iBAAiB,iCAAjB,iBAAiB,QAO5B","sourcesContent":["export enum PublishEventEnums {\n\tADMIN_ACTIVITY_LOGS_EVENT = 'admin_activity_logs_event',\n\tMESSAGE_RECEIVED_EVENT = 'message_received_event',\n\tTICKET_NOTIFICATION_EVENT = 'ticket_notification_event',\n\tCART_ITEM_UPSERT_EVENT = 'cart_item_upsert_event',\n\tSHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT = 'shop_active_timings_batch_process_event',\n\tMONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT = 'mongo_stream_changes_batch_process_shops_event',\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseEvent } from '../BaseEvent';
|
|
3
|
+
import { DTO } from '../../../utilities/validation/global-validation';
|
|
4
|
+
export declare enum ChangeStreamOperationTypes {
|
|
5
|
+
INSERT = "insert",
|
|
6
|
+
UPDATE = "update",
|
|
7
|
+
REPLACE = "replace",
|
|
8
|
+
DELETE = "delete"
|
|
9
|
+
}
|
|
10
|
+
export declare enum UpdateCollectionAtlasSearchEnum {
|
|
11
|
+
TAGS = "tags",
|
|
12
|
+
BRANDS = "brands",
|
|
13
|
+
PRODUCTS = "products",
|
|
14
|
+
CATEGORIES = "categories"
|
|
15
|
+
}
|
|
16
|
+
declare const MongoStreamsBatchProcessShopsSchema: z.ZodObject<{
|
|
17
|
+
operation: z.ZodNativeEnum<typeof ChangeStreamOperationTypes>;
|
|
18
|
+
updateCollection: z.ZodNativeEnum<typeof UpdateCollectionAtlasSearchEnum>;
|
|
19
|
+
updatedFields: z.ZodAny;
|
|
20
|
+
fullDocument: z.ZodAny;
|
|
21
|
+
}, "strict", z.ZodTypeAny, {
|
|
22
|
+
operation: ChangeStreamOperationTypes;
|
|
23
|
+
updateCollection: UpdateCollectionAtlasSearchEnum;
|
|
24
|
+
fullDocument?: any;
|
|
25
|
+
updatedFields?: any;
|
|
26
|
+
}, {
|
|
27
|
+
operation: ChangeStreamOperationTypes;
|
|
28
|
+
updateCollection: UpdateCollectionAtlasSearchEnum;
|
|
29
|
+
fullDocument?: any;
|
|
30
|
+
updatedFields?: any;
|
|
31
|
+
}>;
|
|
32
|
+
export type MongoStreamsBatchProcessShopsDTO = DTO<typeof MongoStreamsBatchProcessShopsSchema>;
|
|
33
|
+
export declare class MongoStreamsBatchProcessShopsEvent extends BaseEvent<Record<string, unknown>> {
|
|
34
|
+
constructor(payload: MongoStreamsBatchProcessShopsDTO);
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoStreamsBatchProcessShopsEvent = exports.UpdateCollectionAtlasSearchEnum = exports.ChangeStreamOperationTypes = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const BaseEvent_1 = require("../BaseEvent");
|
|
6
|
+
const EventEnums_1 = require("../EventEnums");
|
|
7
|
+
const global_validation_1 = require("../../../utilities/validation/global-validation");
|
|
8
|
+
var ChangeStreamOperationTypes;
|
|
9
|
+
(function (ChangeStreamOperationTypes) {
|
|
10
|
+
ChangeStreamOperationTypes["INSERT"] = "insert";
|
|
11
|
+
ChangeStreamOperationTypes["UPDATE"] = "update";
|
|
12
|
+
ChangeStreamOperationTypes["REPLACE"] = "replace";
|
|
13
|
+
ChangeStreamOperationTypes["DELETE"] = "delete";
|
|
14
|
+
})(ChangeStreamOperationTypes || (exports.ChangeStreamOperationTypes = ChangeStreamOperationTypes = {}));
|
|
15
|
+
var UpdateCollectionAtlasSearchEnum;
|
|
16
|
+
(function (UpdateCollectionAtlasSearchEnum) {
|
|
17
|
+
UpdateCollectionAtlasSearchEnum["TAGS"] = "tags";
|
|
18
|
+
UpdateCollectionAtlasSearchEnum["BRANDS"] = "brands";
|
|
19
|
+
UpdateCollectionAtlasSearchEnum["PRODUCTS"] = "products";
|
|
20
|
+
UpdateCollectionAtlasSearchEnum["CATEGORIES"] = "categories";
|
|
21
|
+
})(UpdateCollectionAtlasSearchEnum || (exports.UpdateCollectionAtlasSearchEnum = UpdateCollectionAtlasSearchEnum = {}));
|
|
22
|
+
const baseFields = {
|
|
23
|
+
operation: global_validation_1.ZodValidation.enumType(ChangeStreamOperationTypes, 'Mongo streams operation'),
|
|
24
|
+
updateCollection: global_validation_1.ZodValidation.enumType(UpdateCollectionAtlasSearchEnum, 'Updated collection'),
|
|
25
|
+
updatedFields: zod_1.z.any(),
|
|
26
|
+
fullDocument: zod_1.z.any()
|
|
27
|
+
};
|
|
28
|
+
const schemaBuilder = (0, global_validation_1.createSchemaBuilder)(baseFields);
|
|
29
|
+
const { BaseSchema: MongoStreamsBatchProcessShopsSchema, } = schemaBuilder.getAllSchemas({ createdAt: true });
|
|
30
|
+
class MongoStreamsBatchProcessShopsEvent extends BaseEvent_1.BaseEvent {
|
|
31
|
+
constructor(payload) {
|
|
32
|
+
super(EventEnums_1.PublishEventEnums.MONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT, payload);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.MongoStreamsBatchProcessShopsEvent = MongoStreamsBatchProcessShopsEvent;
|
|
36
|
+
//# sourceMappingURL=mongo-stream-changes-batch-process-shops-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo-stream-changes-batch-process-shops-event.js","sourceRoot":"/","sources":["libraries/event/events/mongo-stream-changes-batch-process-shops-event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,4CAAyC;AACzC,8CAAkD;AAClD,uFAA0G;AAE1G,IAAY,0BAKX;AALD,WAAY,0BAA0B;IACpC,+CAAiB,CAAA;IACjB,+CAAiB,CAAA;IACjB,iDAAmB,CAAA;IACnB,+CAAiB,CAAA;AACnB,CAAC,EALW,0BAA0B,0CAA1B,0BAA0B,QAKrC;AAED,IAAY,+BAMX;AAND,WAAY,+BAA+B;IACvC,gDAAa,CAAA;IACb,oDAAiB,CAAA;IACjB,wDAAqB,CAAA;IACrB,4DAAyB,CAAA;AAE7B,CAAC,EANW,+BAA+B,+CAA/B,+BAA+B,QAM1C;AAED,MAAM,UAAU,GAAG;IACf,SAAS,EAAE,iCAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,yBAAyB,CAAC;IACxF,gBAAgB,EAAE,iCAAa,CAAC,QAAQ,CAAC,+BAA+B,EAAE,oBAAoB,CAAC;IAC/F,aAAa,EAAE,OAAC,CAAC,GAAG,EAAE;IACtB,YAAY,EAAE,OAAC,CAAC,GAAG,EAAE;CACxB,CAAC;AACF,MAAM,aAAa,GAAG,IAAA,uCAAmB,EAAC,UAAU,CAAC,CAAC;AACtD,MAAM,EACF,UAAU,EAAE,mCAAmC,GAClD,GAAG,aAAa,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAIrD,MAAa,kCAAmC,SAAQ,qBAAkC;IACtF,YAAY,OAAyC;QACjD,KAAK,CAAC,8BAAiB,CAAC,8CAA8C,EAAE,OAAkC,CAAC,CAAC;IAChH,CAAC;CACJ;AAJD,gFAIC","sourcesContent":["import { z } from 'zod';\nimport { BaseEvent } from '../BaseEvent';\nimport { PublishEventEnums } from '../EventEnums';\nimport { createSchemaBuilder, DTO, ZodValidation } from '../../../utilities/validation/global-validation';\n\nexport enum ChangeStreamOperationTypes {\n INSERT = \"insert\",\n UPDATE = \"update\",\n REPLACE = \"replace\",\n DELETE = \"delete\"\n}\n\nexport enum UpdateCollectionAtlasSearchEnum {\n TAGS = 'tags',\n BRANDS = 'brands',\n PRODUCTS = 'products',\n CATEGORIES = 'categories'\n // shop category\n}\n\nconst baseFields = {\n operation: ZodValidation.enumType(ChangeStreamOperationTypes, 'Mongo streams operation'),\n updateCollection: ZodValidation.enumType(UpdateCollectionAtlasSearchEnum, 'Updated collection'),\n updatedFields: z.any(),\n fullDocument: z.any()\n};\nconst schemaBuilder = createSchemaBuilder(baseFields);\nconst {\n BaseSchema: MongoStreamsBatchProcessShopsSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\nexport type MongoStreamsBatchProcessShopsDTO = DTO<typeof MongoStreamsBatchProcessShopsSchema>;\n\nexport class MongoStreamsBatchProcessShopsEvent extends BaseEvent<Record<string, unknown>> {\n constructor(payload: MongoStreamsBatchProcessShopsDTO) {\n super(PublishEventEnums.MONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT, payload as Record<string, unknown>);\t\t\n }\n}"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
|
+
import { ConfigurationOptions } from '../configuration';
|
|
2
3
|
export declare function initGlobalConnection(uri: string, environment: string): Promise<Connection>;
|
|
4
|
+
export declare function initLyxaMongoDbConnection(mongoUrl: string, options?: ConfigurationOptions): Promise<void>;
|
|
3
5
|
export declare function isGlobalConnectionInitialized(): boolean;
|
|
4
6
|
export declare function getGlobalConnection(): Connection;
|
|
7
|
+
export declare function getLyxaMongoDbConnection(): Connection;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.initGlobalConnection = initGlobalConnection;
|
|
7
|
+
exports.initLyxaMongoDbConnection = initLyxaMongoDbConnection;
|
|
4
8
|
exports.isGlobalConnectionInitialized = isGlobalConnectionInitialized;
|
|
5
9
|
exports.getGlobalConnection = getGlobalConnection;
|
|
6
|
-
|
|
10
|
+
exports.getLyxaMongoDbConnection = getLyxaMongoDbConnection;
|
|
11
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
12
|
+
const mongoose_2 = require("mongoose");
|
|
7
13
|
const models_1 = require("./models");
|
|
14
|
+
const __1 = require("../..");
|
|
8
15
|
let globalConnection;
|
|
16
|
+
let lyxaDbConnection;
|
|
9
17
|
let connectionPromise = null;
|
|
10
18
|
async function initGlobalConnection(uri, environment) {
|
|
11
19
|
if (!connectionPromise) {
|
|
12
20
|
connectionPromise = new Promise(async (resolve, reject) => {
|
|
13
21
|
try {
|
|
14
22
|
console.log(`Initializing global connection for environment: ${environment}`);
|
|
15
|
-
const connection = (0,
|
|
23
|
+
const connection = (0, mongoose_2.createConnection)(uri, {
|
|
16
24
|
dbName: `lyxa-${environment}-global`,
|
|
17
25
|
maxPoolSize: 20,
|
|
18
26
|
minPoolSize: 4,
|
|
@@ -39,6 +47,28 @@ async function initGlobalConnection(uri, environment) {
|
|
|
39
47
|
}
|
|
40
48
|
return connectionPromise;
|
|
41
49
|
}
|
|
50
|
+
async function initLyxaMongoDbConnection(mongoUrl, options) {
|
|
51
|
+
console.log(`Initializing lyxa mongodb connection for environment: ${options?.environment}`);
|
|
52
|
+
await mongoose_1.default.connect(mongoUrl, {
|
|
53
|
+
dbName: `lyxa-${options.environment}-${options.tenet}`,
|
|
54
|
+
maxPoolSize: 20,
|
|
55
|
+
minPoolSize: 4,
|
|
56
|
+
maxIdleTimeMS: 30000,
|
|
57
|
+
waitQueueTimeoutMS: 10000,
|
|
58
|
+
retryWrites: true,
|
|
59
|
+
w: 1,
|
|
60
|
+
readPreference: 'primary',
|
|
61
|
+
readConcern: { level: 'local' },
|
|
62
|
+
serverSelectionTimeoutMS: 5000,
|
|
63
|
+
heartbeatFrequencyMS: 10000,
|
|
64
|
+
bufferCommands: false,
|
|
65
|
+
compressors: ['zlib']
|
|
66
|
+
});
|
|
67
|
+
mongoose_1.default.set('debug', options?.mongooseDebug !== undefined
|
|
68
|
+
? options?.mongooseDebug
|
|
69
|
+
: (0, __1.getLibraries)().getConfigurationService().options.environment == __1.EnvironmentConfigurationType.DEV);
|
|
70
|
+
lyxaDbConnection = mongoose_1.default.connection;
|
|
71
|
+
}
|
|
42
72
|
function isGlobalConnectionInitialized() {
|
|
43
73
|
return !!globalConnection;
|
|
44
74
|
}
|
|
@@ -48,4 +78,10 @@ function getGlobalConnection() {
|
|
|
48
78
|
}
|
|
49
79
|
return globalConnection;
|
|
50
80
|
}
|
|
81
|
+
function getLyxaMongoDbConnection() {
|
|
82
|
+
if (!lyxaDbConnection) {
|
|
83
|
+
throw new Error('Lyxa mongodb connection not initialized. Call initLyxaMongoDbConnection() first.');
|
|
84
|
+
}
|
|
85
|
+
return lyxaDbConnection;
|
|
86
|
+
}
|
|
51
87
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/mongo/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/mongo/index.ts"],"names":[],"mappings":";;;;;AAcA,oDAiCC;AAED,8DAyBC;AAKD,sEAEC;AAKD,kDAKC;AAED,4DAKC;AAlGD,wDAAgC;AAChC,uCAAwD;AACxD,qCAAkD;AAElD,6BAAmE;AAGnE,IAAI,gBAAwC,CAAC;AAC7C,IAAI,gBAAwC,CAAC;AAC7C,IAAI,iBAAiB,GAA+B,IAAI,CAAC;AAKlD,KAAK,UAAU,oBAAoB,CAAC,GAAW,EAAE,WAAmB;IAC1E,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACxB,iBAAiB,GAAG,IAAI,OAAO,CAAa,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YACrE,IAAI,CAAC;gBACJ,OAAO,CAAC,GAAG,CAAC,mDAAmD,WAAW,EAAE,CAAC,CAAC;gBAC9E,MAAM,UAAU,GAAG,IAAA,2BAAgB,EAAC,GAAG,EAAE;oBACxC,MAAM,EAAE,QAAQ,WAAW,SAAS;oBACpC,WAAW,EAAE,EAAE;oBACf,WAAW,EAAE,CAAC;oBACd,aAAa,EAAE,KAAK;oBACpB,kBAAkB,EAAE,KAAK;oBACzB,WAAW,EAAE,IAAI;oBACjB,CAAC,EAAE,UAAU;iBACb,CAAC,CAAC;gBAEH,MAAM,IAAI,OAAO,CAAO,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;oBACzD,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;wBACjC,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;wBAC1D,gBAAgB,GAAG,UAAU,CAAC;wBAC9B,cAAc,EAAE,CAAC;oBAClB,CAAC,CAAC,CAAC;oBACH,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,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C,gBAAgB,CAAC;AAC3B,CAAC;AAKD,SAAgB,mBAAmB;IAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED,SAAgB,wBAAwB;IACvC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,gBAAgB,CAAC;AACzB,CAAC","sourcesContent":["import mongoose from 'mongoose';\nimport { Connection, createConnection } from 'mongoose';\nimport { initializeGlobalModels } from './models';\nimport { ConfigurationOptions } from '../configuration';\nimport { EnvironmentConfigurationType, getLibraries } from '../..';\n\n// Track connection status\nlet globalConnection: Connection | undefined;\nlet lyxaDbConnection: Connection | undefined;\nlet connectionPromise: Promise<Connection> | null = null;\n\n/**\n * Initialize the global database connection and create all global models\n */\nexport async function initGlobalConnection(uri: string, environment: string): Promise<Connection> {\n\tif (!connectionPromise) {\n\t\tconnectionPromise = new Promise<Connection>(async (resolve, reject) => {\n\t\t\ttry {\n\t\t\t\tconsole.log(`Initializing global connection for environment: ${environment}`);\n\t\t\t\tconst connection = createConnection(uri, {\n\t\t\t\t\tdbName: `lyxa-${environment}-global`,\n\t\t\t\t\tmaxPoolSize: 20,\n\t\t\t\t\tminPoolSize: 4,\n\t\t\t\t\tmaxIdleTimeMS: 30000,\n\t\t\t\t\twaitQueueTimeoutMS: 10000,\n\t\t\t\t\tretryWrites: true,\n\t\t\t\t\tw: 'majority',\n\t\t\t\t});\n\n\t\t\t\tawait new Promise<void>((connectResolve, connectReject) => {\n\t\t\t\t\tconnection.once('connected', () => {\n\t\t\t\t\t\tconsole.log('Global connection successfully established');\n\t\t\t\t\t\tglobalConnection = connection;\n\t\t\t\t\t\tconnectResolve();\n\t\t\t\t\t});\n\t\t\t\t\tconnection.once('error', connectReject);\n\t\t\t\t});\n\n\t\t\t\tinitializeGlobalModels(globalConnection);\n\n\t\t\t\tresolve(connection);\n\t\t\t} catch (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\t\t});\n\t}\n\treturn connectionPromise;\n}\n\nexport async function initLyxaMongoDbConnection(mongoUrl: string, options?: ConfigurationOptions): Promise<void> {\n\tconsole.log(`Initializing lyxa mongodb connection for environment: ${options?.environment}`);\n\tawait mongoose.connect(mongoUrl!, {\n\t\tdbName: `lyxa-${options!.environment}-${options!.tenet}`,\n\t\tmaxPoolSize: 20,\n\t\tminPoolSize: 4,\n\t\tmaxIdleTimeMS: 30000,\n\t\twaitQueueTimeoutMS: 10000,\n\t\tretryWrites: true,\n\t\tw: 1,\n\t\treadPreference: 'primary',\n\t\treadConcern: { level: 'local' },\n\t\tserverSelectionTimeoutMS: 5000,\n\t\theartbeatFrequencyMS: 10000,\n\t\tbufferCommands: false,\n\t\tcompressors: ['zlib'] // Reduces network traffic \n\t});\n\tmongoose.set(\n\t\t'debug',\n\t\toptions?.mongooseDebug !== undefined\n\t\t\t? options?.mongooseDebug\n\t\t\t: getLibraries().getConfigurationService().options.environment == EnvironmentConfigurationType.DEV\n\t);\n\n\tlyxaDbConnection = mongoose.connection;\n}\n\n/**\n * Check if the global connection is initialized\n */\nexport function isGlobalConnectionInitialized(): boolean {\n\treturn !!globalConnection;\n}\n\n/**\n * Get the global and lyxa connections (throws if not initialized)\n */\nexport function getGlobalConnection(): Connection {\n\tif (!globalConnection) {\n\t\tthrow new Error('Global connection not initialized. Call initGlobalConnection() first.');\n\t}\n\treturn globalConnection;\n}\n\nexport function getLyxaMongoDbConnection(): Connection {\n\tif (!lyxaDbConnection) {\n\t\tthrow new Error('Lyxa mongodb connection not initialized. Call initLyxaMongoDbConnection() first.');\n\t}\n\treturn lyxaDbConnection;\n}\n\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -4,9 +4,9 @@ exports.UserAddressFrontendSchema = void 0;
|
|
|
4
4
|
const global_validation_1 = require("./global-validation");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
exports.UserAddressFrontendSchema = zod_1.z.object({
|
|
7
|
-
addressLabel: global_validation_1.ZodValidation.string('Address Label', { maxLength: 20 }),
|
|
8
|
-
apartment: global_validation_1.ZodValidation.string('Apt/Suite/Floor', { maxLength: 30 }),
|
|
9
|
-
buildingName: global_validation_1.ZodValidation.string('Building Name', { maxLength: 30 }),
|
|
7
|
+
addressLabel: global_validation_1.ZodValidation.string('Address Label', { maxLength: 20, isTrimmed: true }),
|
|
8
|
+
apartment: global_validation_1.ZodValidation.string('Apt/Suite/Floor', { maxLength: 30, isTrimmed: true }),
|
|
9
|
+
buildingName: global_validation_1.ZodValidation.string('Building Name', { maxLength: 30, isTrimmed: true }),
|
|
10
10
|
deliveryOption: global_validation_1.ZodValidation.string('Delivery Option').optional(),
|
|
11
11
|
instructions: global_validation_1.ZodValidation.string('Instructions', { maxLength: 250 }).optional(),
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-for-frontend.js","sourceRoot":"/","sources":["utilities/validation/validation-for-frontend.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AACzD,6BAAwB;AAEX,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,EAAE,EAAC,SAAS,EAAE,EAAE,EAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"validation-for-frontend.js","sourceRoot":"/","sources":["utilities/validation/validation-for-frontend.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AACzD,6BAAwB;AAEX,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,EAAE,EAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACrF,SAAS,EAAE,iCAAa,CAAC,MAAM,CAAC,iBAAiB,EAAE,EAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACpF,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,EAAE,EAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACrF,cAAc,EAAE,iCAAa,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;IAClE,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,cAAc,EAAE,EAAC,SAAS,EAAE,GAAG,EAAC,CAAC,CAAC,QAAQ,EAAE;CAC/E,CAAC,CAAC","sourcesContent":["import { DTO, ZodValidation } from './global-validation';\nimport { z } from 'zod';\n\nexport const UserAddressFrontendSchema = z.object({\n\taddressLabel: ZodValidation.string('Address Label', {maxLength: 20, isTrimmed: true}),\n\tapartment: ZodValidation.string('Apt/Suite/Floor', {maxLength: 30, isTrimmed: true}),\n\tbuildingName: ZodValidation.string('Building Name', {maxLength: 30, isTrimmed: true}),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions', {maxLength: 250}).optional(),\n});\nexport type UserAddressFrontendDTO = DTO<typeof UserAddressFrontendSchema>;"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mongoose } from "@typegoose/typegoose";
|
|
2
2
|
import { AdminLogsUpdatedFieldsType } from "./enum";
|
|
3
|
+
import { MongoStreamsBatchProcessShopsDTO } from "../libraries/event/events/mongo-stream-changes-batch-process-shops-event";
|
|
3
4
|
export declare function getChangedFields<T extends Record<string, any>>(oldDoc: T, newDoc: T, payload?: Partial<T>): Record<keyof T, {
|
|
4
5
|
old: any;
|
|
5
6
|
new: any;
|
|
@@ -22,3 +23,4 @@ export declare function publishAdminLogsEvent(payload: {
|
|
|
22
23
|
newDoc: any;
|
|
23
24
|
}): Promise<void>;
|
|
24
25
|
export declare function publishShopActiveBatchProcessEvent(): Promise<void>;
|
|
26
|
+
export declare function publishMongodbStreamsChangesBatchProcessShopsEvent(payload: MongoStreamsBatchProcessShopsDTO): Promise<void>;
|
|
@@ -5,9 +5,11 @@ exports.filterRelevantChanges = filterRelevantChanges;
|
|
|
5
5
|
exports.extractChangedDocument = extractChangedDocument;
|
|
6
6
|
exports.publishAdminLogsEvent = publishAdminLogsEvent;
|
|
7
7
|
exports.publishShopActiveBatchProcessEvent = publishShopActiveBatchProcessEvent;
|
|
8
|
+
exports.publishMongodbStreamsChangesBatchProcessShopsEvent = publishMongodbStreamsChangesBatchProcessShopsEvent;
|
|
8
9
|
const event_1 = require("../libraries/event");
|
|
9
10
|
const admin_logs_event_1 = require("../libraries/event/events/admin-logs-event");
|
|
10
11
|
const shop_active_timings_batch_process_event_1 = require("../libraries/event/events/shop-active-timings-batch-process-event");
|
|
12
|
+
const mongo_stream_changes_batch_process_shops_event_1 = require("../libraries/event/events/mongo-stream-changes-batch-process-shops-event");
|
|
11
13
|
function getChangedFields(oldDoc, newDoc, payload) {
|
|
12
14
|
const changes = {};
|
|
13
15
|
const oldObj = typeof oldDoc.toObject === 'function' ? oldDoc.toObject() : oldDoc;
|
|
@@ -49,4 +51,8 @@ async function publishShopActiveBatchProcessEvent() {
|
|
|
49
51
|
const shopActiveTimingsBatchProcessEvent = new shop_active_timings_batch_process_event_1.ShopActiveTimingsBatchProcessEvent({});
|
|
50
52
|
await (0, event_1.publishEvent)(shopActiveTimingsBatchProcessEvent);
|
|
51
53
|
}
|
|
54
|
+
async function publishMongodbStreamsChangesBatchProcessShopsEvent(payload) {
|
|
55
|
+
const mongodbStreamsBatchProcessEvent = new mongo_stream_changes_batch_process_shops_event_1.MongoStreamsBatchProcessShopsEvent(payload);
|
|
56
|
+
await (0, event_1.publishEvent)(mongodbStreamsBatchProcessEvent);
|
|
57
|
+
}
|
|
52
58
|
//# sourceMappingURL=events-common-methods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events-common-methods.js","sourceRoot":"/","sources":["utilities/events-common-methods.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"events-common-methods.js","sourceRoot":"/","sources":["utilities/events-common-methods.ts"],"names":[],"mappings":";;AAWA,4CAwBC;AAMD,sDAUC;AAKD,wDAOC;AAED,sDAcC;AAED,gFAGC;AAED,gHAGC;AAxFD,8CAAkD;AAElD,iFAAoF;AAEpF,+HAAuH;AACvH,6IAAgK;AAKhK,SAAgB,gBAAgB,CAC/B,MAAS,EACT,MAAS,EACT,OAAoB;IAEpB,MAAM,OAAO,GAAG,EAA6C,CAAC;IAE9D,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAClF,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAElF,MAAM,WAAW,GAAG,OAAO;QAC1B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAE7B,IAAI,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtE,OAAO,CAAC,GAAc,CAAC,GAAG,EAAE,GAAG,EAAE,Q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AC;AAEM,KAAK,UAAU,kDAAkD,CAAC,OAAyC;IACjH,MAAM,+BAA+B,GAAuC,IAAI,mFAAkC,CAAC,OAAO,CAAC,CAAC;IAC5H,MAAM,IAAA,oBAAY,EAAC,+BAA+B,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { mongoose } from \"@typegoose/typegoose\";\nimport { publishEvent } from \"../libraries/event\";\nimport { BaseEvent } from \"../libraries/event/BaseEvent\";\nimport { AdminActivityLogsEvent } from \"../libraries/event/events/admin-logs-event\";\nimport { AdminLogsUpdatedFieldsType } from \"./enum\";\nimport { ShopActiveTimingsBatchProcessEvent } from \"../libraries/event/events/shop-active-timings-batch-process-event\";\nimport { MongoStreamsBatchProcessShopsDTO, MongoStreamsBatchProcessShopsEvent } from \"../libraries/event/events/mongo-stream-changes-batch-process-shops-event\";\n\n/**\n\t * Returns changed fields between two objects (shallow comparison).\n\t */\nexport function getChangedFields<T extends Record<string, any>>(\n\toldDoc: T,\n\tnewDoc: T,\n\tpayload?: Partial<T>\n): Record<keyof T, { old: any; new: any }> {\n\tconst changes = {} as Record<keyof T, { old: any; new: any }>;\n\n\tconst oldObj = typeof oldDoc.toObject === 'function' ? oldDoc.toObject() : oldDoc;\n\tconst newObj = typeof newDoc.toObject === 'function' ? newDoc.toObject() : newDoc;\n\n\tconst keysToCheck = payload\n\t\t? Object.keys(payload)\n\t\t: Array.from(new Set([...Object.keys(oldObj), ...Object.keys(newObj)]));\n\n\tfor (const key of keysToCheck) {\n\t\tconst oldValue = oldObj[key];\n\t\tconst newValue = newObj[key];\n\n\t\tif (payload || JSON.stringify(oldValue) !== JSON.stringify(newValue)) {\n\t\t\tchanges[key as keyof T] = { old: oldValue, new: newValue };\n\t\t}\n\t}\n\n\treturn changes;\n}\n\n\n/**\n * Filters changed fields to only those that exist in the payload.\n */\nexport function filterRelevantChanges<T>(\n\tallChanges: Record<string, { old: any; new: any }>,\n\tpayload: Partial<T>\n): Record<string, { old: any; new: any }> {\n\treturn Object.keys(payload).reduce((acc, key) => {\n\t\tif (allChanges[key]) {\n\t\t\tacc[key] = allChanges[key];\n\t\t}\n\t\treturn acc;\n\t}, {} as Record<string, { old: any; new: any }>);\n}\n\n/**\n * Extracts either 'old' or 'new' values from the changes object.\n */\nexport function extractChangedDocument(\n\tchanges: Record<string, { old: any; new: any }>,\n\ttype: 'old' | 'new'\n): Record<string, any> {\n\treturn Object.fromEntries(\n\t\tObject.entries(changes).map(([key, value]) => [key, value[type]])\n\t);\n}\n\nexport async function publishAdminLogsEvent(payload: {\n\tadmin: mongoose.Types.ObjectId;\n\tupdatedField: AdminLogsUpdatedFieldsType;\n\toldDoc: any;\n\tnewDoc: any;\n}) {\n\tconst { admin, updatedField, oldDoc, newDoc } = payload;\n\tconst adminActivityLogsEvent: BaseEvent<Record<string, unknown>> = new AdminActivityLogsEvent({\n\t\tadmin: admin,\n\t\tupdatedField: updatedField,\n\t\toldDocument: oldDoc,\n\t\tnewDocument: newDoc,\n\t});\n\tawait publishEvent(adminActivityLogsEvent);\n}\n\nexport async function publishShopActiveBatchProcessEvent() {\n\tconst shopActiveTimingsBatchProcessEvent: BaseEvent<Record<string, unknown>> = new ShopActiveTimingsBatchProcessEvent({});\n\tawait publishEvent(shopActiveTimingsBatchProcessEvent);\n}\n\nexport async function publishMongodbStreamsChangesBatchProcessShopsEvent(payload: MongoStreamsBatchProcessShopsDTO) {\n\tconst mongodbStreamsBatchProcessEvent: BaseEvent<Record<string, unknown>> = new MongoStreamsBatchProcessShopsEvent(payload);\n\tawait publishEvent(mongodbStreamsBatchProcessEvent);\n}\n"]}
|
|
@@ -4,9 +4,9 @@ exports.UserAddressFrontendSchema = void 0;
|
|
|
4
4
|
const global_validation_1 = require("./global-validation");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
exports.UserAddressFrontendSchema = zod_1.z.object({
|
|
7
|
-
addressLabel: global_validation_1.ZodValidation.string('Address Label', { maxLength: 20 }),
|
|
8
|
-
apartment: global_validation_1.ZodValidation.string('Apt/Suite/Floor', { maxLength: 30 }),
|
|
9
|
-
buildingName: global_validation_1.ZodValidation.string('Building Name', { maxLength: 30 }),
|
|
7
|
+
addressLabel: global_validation_1.ZodValidation.string('Address Label', { maxLength: 20, isTrimmed: true }),
|
|
8
|
+
apartment: global_validation_1.ZodValidation.string('Apt/Suite/Floor', { maxLength: 30, isTrimmed: true }),
|
|
9
|
+
buildingName: global_validation_1.ZodValidation.string('Building Name', { maxLength: 30, isTrimmed: true }),
|
|
10
10
|
deliveryOption: global_validation_1.ZodValidation.string('Delivery Option').optional(),
|
|
11
11
|
instructions: global_validation_1.ZodValidation.string('Instructions', { maxLength: 250 }).optional(),
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-for-frontend.js","sourceRoot":"/","sources":["utilities/validation/validation-for-frontend.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AACzD,6BAAwB;AAEX,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,EAAE,EAAC,SAAS,EAAE,EAAE,EAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"validation-for-frontend.js","sourceRoot":"/","sources":["utilities/validation/validation-for-frontend.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AACzD,6BAAwB;AAEX,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,EAAE,EAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACrF,SAAS,EAAE,iCAAa,CAAC,MAAM,CAAC,iBAAiB,EAAE,EAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACpF,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,EAAE,EAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACrF,cAAc,EAAE,iCAAa,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;IAClE,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,cAAc,EAAE,EAAC,SAAS,EAAE,GAAG,EAAC,CAAC,CAAC,QAAQ,EAAE;CAC/E,CAAC,CAAC","sourcesContent":["import { DTO, ZodValidation } from './global-validation';\nimport { z } from 'zod';\n\nexport const UserAddressFrontendSchema = z.object({\n\taddressLabel: ZodValidation.string('Address Label', {maxLength: 20, isTrimmed: true}),\n\tapartment: ZodValidation.string('Apt/Suite/Floor', {maxLength: 30, isTrimmed: true}),\n\tbuildingName: ZodValidation.string('Building Name', {maxLength: 30, isTrimmed: true}),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions', {maxLength: 250}).optional(),\n});\nexport type UserAddressFrontendDTO = DTO<typeof UserAddressFrontendSchema>;"]}
|