@lyxa.ai/core 1.3.144 → 1.3.145
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 +2 -2
- package/dist/index.js.map +1 -1
- package/dist/libraries/event/decorators/subscribe.d.ts +2 -1
- package/dist/libraries/event/decorators/subscribe.js +2 -2
- package/dist/libraries/event/decorators/subscribe.js.map +1 -1
- package/dist/libraries/event/index.d.ts +5 -1
- package/dist/libraries/event/index.js +46 -15
- package/dist/libraries/event/index.js.map +1 -1
- package/dist/libraries/event/registry/SubscriptionRegistry.d.ts +3 -1
- package/dist/libraries/event/registry/SubscriptionRegistry.js +2 -1
- package/dist/libraries/event/registry/SubscriptionRegistry.js.map +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/index.js
CHANGED
|
@@ -155,7 +155,7 @@ async function registerLibraries(options) {
|
|
|
155
155
|
await (0, event_1.initEventBus)(rabbitmq_environments_1.RabbitMQUrlMap[options?.environment ?? EnvironmentConfigurationType_1.EnvironmentConfigurationType.DEV]);
|
|
156
156
|
const allSubscriptions = SubscriptionRegistry_1.SubscriptionRegistry.getAllSubscriptions();
|
|
157
157
|
const instantiatedServices = new Map();
|
|
158
|
-
for (const { eventId, targetConstructor, methodName } of allSubscriptions) {
|
|
158
|
+
for (const { eventId, targetConstructor, methodName, opts } of allSubscriptions) {
|
|
159
159
|
let instance = instantiatedServices.get(targetConstructor);
|
|
160
160
|
if (!instance) {
|
|
161
161
|
instance = typedi_1.Container.get(targetConstructor);
|
|
@@ -163,7 +163,7 @@ async function registerLibraries(options) {
|
|
|
163
163
|
}
|
|
164
164
|
await (0, event_1.subscribeToEvent)(eventId, async (payload) => {
|
|
165
165
|
return instance[methodName](payload);
|
|
166
|
-
});
|
|
166
|
+
}, opts);
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
function getLibraries() {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AAwB,CAAC,CAAC;YACnD,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,IAAA,wBAAgB,EAAC,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;YAC/C,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED,SAAgB,YAAY;IAC3B,OAAO,kBAAS,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Apply the soft delete plugin globally before any connections or models\nimport { applySoftDeletePlugin } from './libraries/mongo/plugins/soft-delete-plugin';\napplySoftDeletePlugin();\n\nimport { LibraryManager } from './libraries';\nimport { Container } from 'typedi';\nimport { 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 { GoogleMapsService, MapService } 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 { 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\n\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\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\t\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\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(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 => {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,sCA2BC;AAED,8CA6GC;AAED,oCAEC;AAlLD,qFAAqF;AACrF,IAAA,0CAAqB,GAAE,CAAC;AACxB,2CAA6C;AAC7C,mCAAmC;AACnC,6DAAuF;AACvF,+C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C;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 { initEventBus, 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\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\n\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\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\t\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\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(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, opts } 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(\n\t\t\teventId,\n\t\t\tasync payload => {\n\t\t\t\treturn instance[methodName](payload);\n\t\t\t},\n\t\t\topts\n\t\t);\n\t}\n}\n\nexport function getLibraries(): LibraryManager {\n\treturn Container.get(LibraryManager);\n}\n"]}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { RabbitMQEventOptions } from '../index';
|
|
2
|
+
export declare function Subscribe(eventId: string, opts?: RabbitMQEventOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Subscribe = Subscribe;
|
|
4
4
|
const SubscriptionRegistry_1 = require("../registry/SubscriptionRegistry");
|
|
5
|
-
function Subscribe(eventId) {
|
|
5
|
+
function Subscribe(eventId, opts) {
|
|
6
6
|
return function (target, propertyKey, descriptor) {
|
|
7
|
-
SubscriptionRegistry_1.SubscriptionRegistry.register(eventId, target.constructor, propertyKey);
|
|
7
|
+
SubscriptionRegistry_1.SubscriptionRegistry.register(eventId, target.constructor, propertyKey, opts);
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=subscribe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.js","sourceRoot":"/","sources":["libraries/event/decorators/subscribe.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"/","sources":["libraries/event/decorators/subscribe.ts"],"names":[],"mappings":";;AAGA,8BAIC;AAPD,2EAAwE;AAGxE,SAAgB,SAAS,CAAC,OAAe,EAAE,IAA2B;IACrE,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAChF,2CAAoB,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAC/E,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { SubscriptionRegistry } from '../registry/SubscriptionRegistry';\nimport { RabbitMQEventOptions } from '../index';\n\nexport function Subscribe(eventId: string, opts?: RabbitMQEventOptions) {\n\treturn function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {\n\t\tSubscriptionRegistry.register(eventId, target.constructor, propertyKey, opts);\n\t};\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import amqp from 'amqplib';
|
|
2
2
|
import { BaseEvent } from './BaseEvent';
|
|
3
|
+
export interface RabbitMQEventOptions {
|
|
4
|
+
consumeImmediately?: boolean;
|
|
5
|
+
}
|
|
3
6
|
export declare const EXCHANGE_NAME = "lyxa.events";
|
|
4
7
|
export declare const INSTANCE_ROUTE_PREFIX = "instance";
|
|
5
8
|
export declare function initEventBus(rabbitUrl: string): Promise<void>;
|
|
@@ -8,5 +11,6 @@ export declare function getChannel(): {
|
|
|
8
11
|
subChannel: amqp.Channel;
|
|
9
12
|
};
|
|
10
13
|
export declare function publishEvent<TPayload extends Record<string, unknown>>(event: BaseEvent<TPayload>): Promise<void>;
|
|
11
|
-
export declare function subscribeToEvent(eventId: string, onMessage: (payload: any) => Promise<void
|
|
14
|
+
export declare function subscribeToEvent(eventId: string, onMessage: (payload: any) => Promise<void>, opts?: RabbitMQEventOptions): Promise<void>;
|
|
15
|
+
export declare function consumeAllMessages<T>(queueName: string): Promise<T[]>;
|
|
12
16
|
export declare function closeEventBus(): Promise<void>;
|
|
@@ -8,9 +8,12 @@ exports.initEventBus = initEventBus;
|
|
|
8
8
|
exports.getChannel = getChannel;
|
|
9
9
|
exports.publishEvent = publishEvent;
|
|
10
10
|
exports.subscribeToEvent = subscribeToEvent;
|
|
11
|
+
exports.consumeAllMessages = consumeAllMessages;
|
|
11
12
|
exports.closeEventBus = closeEventBus;
|
|
12
13
|
const amqplib_1 = __importDefault(require("amqplib"));
|
|
13
14
|
const instance_utils_1 = require("../../utilities/instance.utils");
|
|
15
|
+
const index_1 = require("../../index");
|
|
16
|
+
const enum_1 = require("../../utilities/enum");
|
|
14
17
|
let connection;
|
|
15
18
|
let pubChannel;
|
|
16
19
|
let subChannel;
|
|
@@ -45,7 +48,7 @@ async function publishEvent(event) {
|
|
|
45
48
|
});
|
|
46
49
|
await ch.waitForConfirms();
|
|
47
50
|
}
|
|
48
|
-
async function subscribeToEvent(eventId, onMessage) {
|
|
51
|
+
async function subscribeToEvent(eventId, onMessage, opts) {
|
|
49
52
|
const ch = getChannel().subChannel;
|
|
50
53
|
const queueName = `${eventId}`;
|
|
51
54
|
await ch.assertQueue(queueName, {
|
|
@@ -54,26 +57,54 @@ async function subscribeToEvent(eventId, onMessage) {
|
|
|
54
57
|
autoDelete: false,
|
|
55
58
|
});
|
|
56
59
|
await ch.bindQueue(queueName, exports.EXCHANGE_NAME, eventId);
|
|
57
|
-
|
|
60
|
+
if (opts?.consumeImmediately !== false) {
|
|
61
|
+
await ch.consume(queueName, async (msg) => {
|
|
62
|
+
if (!msg)
|
|
63
|
+
return;
|
|
64
|
+
let processed = false;
|
|
65
|
+
try {
|
|
66
|
+
const payload = JSON.parse(msg.content.toString());
|
|
67
|
+
await onMessage(payload);
|
|
68
|
+
processed = true;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
console.error(`Error handling event [${eventId}]`, err);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
if (processed)
|
|
75
|
+
ch.ack(msg);
|
|
76
|
+
else
|
|
77
|
+
ch.nack(msg, false, true);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
console.log(`Subscribed to event [${eventId}]`);
|
|
82
|
+
}
|
|
83
|
+
async function consumeAllMessages(queueName) {
|
|
84
|
+
const logger = (0, index_1.getLibraries)().getLoggerKit();
|
|
85
|
+
const ch = getChannel().subChannel;
|
|
86
|
+
const messages = [];
|
|
87
|
+
while (true) {
|
|
88
|
+
const msg = await ch.get(queueName, { noAck: false });
|
|
58
89
|
if (!msg)
|
|
59
|
-
|
|
60
|
-
let processed = false;
|
|
90
|
+
break;
|
|
61
91
|
try {
|
|
62
92
|
const payload = JSON.parse(msg.content.toString());
|
|
63
|
-
|
|
64
|
-
|
|
93
|
+
messages.push(payload);
|
|
94
|
+
ch.ack(msg);
|
|
95
|
+
logger.debug(`Message consumed successfully for event ${queueName}`, {
|
|
96
|
+
tag: enum_1.LogTag.INFRA_QUEUE,
|
|
97
|
+
});
|
|
65
98
|
}
|
|
66
99
|
catch (err) {
|
|
67
|
-
|
|
100
|
+
logger.error(`Error processing message for event ${queueName}:`, err, {
|
|
101
|
+
tag: enum_1.LogTag.INFRA_QUEUE,
|
|
102
|
+
});
|
|
103
|
+
ch.nack(msg, false, true);
|
|
68
104
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
else
|
|
73
|
-
ch.nack(msg, false, true);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
console.log(`Subscribed to event [${eventId}]`);
|
|
105
|
+
}
|
|
106
|
+
logger.debug(`Fetched ${messages.length} messages for event ${queueName}`, { tag: enum_1.LogTag.INFRA_QUEUE });
|
|
107
|
+
return messages;
|
|
77
108
|
}
|
|
78
109
|
async function closeEventBus() {
|
|
79
110
|
if (pubChannel)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;;AAiBA,oCAUC;AAED,gCAOC;AAED,oCAYC;AAED,4CAyCC;AAED,gDAyBC;AAED,sCAKC;AA/HD,sDAA2B;AAE3B,mEAA+D;AAC/D,uCAA2C;AAC3C,+CAA8C;AAE9C,IAAI,UAA6B,CAAC;AAClC,IAAI,UAA+B,CAAC;AACpC,IAAI,UAAwB,CAAC;AAMhB,QAAA,aAAa,GAAG,aAAa,CAAC;AAC9B,QAAA,qBAAqB,GAAG,UAAU,CAAC;AAEzC,KAAK,UAAU,YAAY,CAAC,SAAiB;IACnD,UAAU,GAAG,MAAM,iBAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3C,UAAU,GAAG,MAAM,UAAU,CAAC,oBAAoB,EAAE,CAAC;IACrD,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAEhC,UAAU,GAAG,MAAM,UAAU,CAAC,aAAa,EAAE,CAAC;IAC9C,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAEhC,MAAM,UAAU,CAAC,cAAc,CAAC,qBAAa,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAC,0CAA0C,IAAA,8BAAa,GAAE,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,SAAgB,UAAU;IACzB,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACtF,IAAI,CAAC,UAAU;QAAE,MA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,UAAU,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import amqp from 'amqplib';\nimport { BaseEvent } from './BaseEvent';\nimport { getInstanceId } from '../../utilities/instance.utils';\nimport { getLibraries } from '../../index';\nimport { LogTag } from '../../utilities/enum';\n\nlet connection: amqp.ChannelModel;\nlet pubChannel: amqp.ConfirmChannel;\nlet subChannel: amqp.Channel;\n\nexport interface RabbitMQEventOptions {\n\tconsumeImmediately?: boolean;\n}\n\nexport const EXCHANGE_NAME = 'lyxa.events';\nexport const INSTANCE_ROUTE_PREFIX = 'instance'; // routing key: instance.{instanceName}.{eventType}\n\nexport async function initEventBus(rabbitUrl: string) {\n\tconnection = await amqp.connect(rabbitUrl);\n\tpubChannel = await connection.createConfirmChannel();\n\tattachGuards(pubChannel, 'pub');\n\n\tsubChannel = await connection.createChannel();\n\tattachGuards(subChannel, 'sub');\n\n\tawait pubChannel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\tconsole.log(`EventBus initialized with instance ID: ${getInstanceId()}`);\n}\n\nexport function getChannel(): { pubChannel: amqp.ConfirmChannel; subChannel: amqp.Channel } {\n\tif (!pubChannel) throw new Error('Channel not initialized. Call initEventBus first.');\n\tif (!subChannel) throw new Error('Channel not initialized. Call initEventBus first.');\n\treturn {\n\t\tpubChannel,\n\t\tsubChannel,\n\t};\n}\n\nexport async function publishEvent<TPayload extends Record<string, unknown>>(\n\tevent: BaseEvent<TPayload>\n): Promise<void> {\n\tconsole.log('taking event', event);\n\n\tconst ch = getChannel().pubChannel;\n\tconst messageBuffer = Buffer.from(JSON.stringify(event.payload));\n\tch.publish(EXCHANGE_NAME, event.eventId, messageBuffer, {\n\t\tcontentType: 'application/json',\n\t\tpersistent: true,\n\t});\n\tawait ch.waitForConfirms();\n}\n\nexport async function subscribeToEvent(\n\teventId: string,\n\tonMessage: (payload: any) => Promise<void>,\n\topts?: RabbitMQEventOptions\n): Promise<void> {\n\tconst ch = getChannel().subChannel;\n\tconst queueName = `${eventId}`;\n\t// const queueName = `${eventId}.${getInstanceId()}`;\n\n\tawait ch.assertQueue(queueName, {\n\t\tdurable: true, // survive broker restart\n\t\texclusive: false, // Allow multiple consumers to attach. Only one connection can use it (each pod has own queue). Set to TRUE if each pod needs it's own queue\n\t\tautoDelete: false, // Queue removed when pod disconnects when set to TRUE\n\t\t// arguments: {\n\t\t// \t// Optional safety: limit queue size and TTL to prevent disk issues\n\t\t// \t'x-max-length': 50000, // max 50k messages\n\t\t// \t'x-message-ttl': 24 * 60 * 60 * 1000, // 24h TTL\n\t\t// \t'x-overflow': 'drop-head', // drop oldest messages if full\n\t\t// },\n\t});\n\n\tawait ch.bindQueue(queueName, EXCHANGE_NAME, eventId);\n\tif (opts?.consumeImmediately !== false) {\n\t\tawait ch.consume(queueName, async msg => {\n\t\t\tif (!msg) return;\n\t\t\tlet processed = false;\n\t\t\ttry {\n\t\t\t\tconst payload = JSON.parse(msg.content.toString());\n\t\t\t\tawait onMessage(payload);\n\t\t\t\tprocessed = true;\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(`Error handling event [${eventId}]`, err);\n\t\t\t} finally {\n\t\t\t\tif (processed) ch.ack(msg);\n\t\t\t\telse ch.nack(msg, false, true); // retry\n\t\t\t}\n\t\t});\n\t}\n\n\t// console.log(`Subscribed to event [${eventId}] on queue [${queueName}]`);\n\tconsole.log(`Subscribed to event [${eventId}]`);\n}\n\nexport async function consumeAllMessages<T>(queueName: string): Promise<T[]> {\n\tconst logger = getLibraries().getLoggerKit();\n\tconst ch = getChannel().subChannel;\n\tconst messages: T[] = [];\n\n\twhile (true) {\n\t\tconst msg = await ch.get(queueName, { noAck: false });\n\t\tif (!msg) break;\n\n\t\ttry {\n\t\t\tconst payload = JSON.parse(msg.content.toString()) as T;\n\t\t\tmessages.push(payload);\n\t\t\tch.ack(msg);\n\t\t\tlogger.debug(`Message consumed successfully for event ${queueName}`, {\n\t\t\t\ttag: LogTag.INFRA_QUEUE,\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tlogger.error(`Error processing message for event ${queueName}:`, err, {\n\t\t\t\ttag: LogTag.INFRA_QUEUE,\n\t\t\t});\n\t\t\tch.nack(msg, false, true);\n\t\t}\n\t}\n\tlogger.debug(`Fetched ${messages.length} messages for event ${queueName}`, { tag: LogTag.INFRA_QUEUE });\n\treturn messages;\n}\n\nexport async function closeEventBus(): Promise<void> {\n\tif (pubChannel) await pubChannel.close();\n\tif (subChannel) await subChannel.close();\n\tif (connection) await connection.close();\n\tconsole.log(`EventBus closed for instance [${getInstanceId()}]`);\n}\n\nfunction attachGuards(ch: amqp.Channel | amqp.ConfirmChannel, type: 'pub' | 'sub') {\n\tch.on('close', async () => {\n\t\tconsole.error(`${type} channel closed, recreating...`);\n\t\tif (type === 'pub') {\n\t\t\tpubChannel = await connection.createConfirmChannel();\n\t\t\tawait pubChannel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\t\t\tattachGuards(pubChannel, 'pub');\n\t\t} else {\n\t\t\tsubChannel = await connection.createChannel();\n\t\t\tattachGuards(subChannel, 'sub');\n\t\t}\n\t});\n\n\tch.on('error', err => {\n\t\tconsole.error(`${type} channel error`, err);\n\t});\n}\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { RabbitMQEventOptions } from '../index';
|
|
1
2
|
interface SubscriptionMetadata {
|
|
2
3
|
eventId: string;
|
|
3
4
|
targetConstructor: Function;
|
|
4
5
|
methodName: string;
|
|
6
|
+
opts?: RabbitMQEventOptions;
|
|
5
7
|
}
|
|
6
8
|
export declare class SubscriptionRegistry {
|
|
7
9
|
private static subscriptions;
|
|
8
|
-
static register(eventId: string, targetConstructor: Function, methodName: string): void;
|
|
10
|
+
static register(eventId: string, targetConstructor: Function, methodName: string, opts?: RabbitMQEventOptions): void;
|
|
9
11
|
static getAllSubscriptions(): SubscriptionMetadata[];
|
|
10
12
|
}
|
|
11
13
|
export {};
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SubscriptionRegistry = void 0;
|
|
4
4
|
class SubscriptionRegistry {
|
|
5
5
|
static subscriptions = [];
|
|
6
|
-
static register(eventId, targetConstructor, methodName) {
|
|
6
|
+
static register(eventId, targetConstructor, methodName, opts) {
|
|
7
7
|
this.subscriptions.push({
|
|
8
8
|
eventId,
|
|
9
9
|
targetConstructor,
|
|
10
10
|
methodName,
|
|
11
|
+
opts: opts,
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
14
|
static getAllSubscriptions() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionRegistry.js","sourceRoot":"/","sources":["libraries/event/registry/SubscriptionRegistry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SubscriptionRegistry.js","sourceRoot":"/","sources":["libraries/event/registry/SubscriptionRegistry.ts"],"names":[],"mappings":";;;AASA,MAAa,oBAAoB;IACxB,MAAM,CAAC,aAAa,GAA2B,EAAE,CAAC;IAMnD,MAAM,CAAC,QAAQ,CACrB,OAAe,EACf,iBAA2B,EAC3B,UAAkB,EAClB,IAA2B;QAE3B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACvB,OAAO;YACP,iBAAiB;YACjB,UAAU;YACV,IAAI,EAAE,IAAI;SACV,CAAC,CAAC;IACJ,CAAC;IAMM,MAAM,CAAC,mBAAmB;QAChC,OAAO,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC;;AA3BF,oDA4BC","sourcesContent":["import { RabbitMQEventOptions } from '../index';\n\ninterface SubscriptionMetadata {\n\teventId: string;\n\ttargetConstructor: Function;\n\tmethodName: string;\n\topts?: RabbitMQEventOptions;\n}\n\nexport class SubscriptionRegistry {\n\tprivate static subscriptions: SubscriptionMetadata[] = [];\n\n\t/**\n\t * Called by the decorator to record which class method\n\t * is subscribed to which eventId.\n\t */\n\tpublic static register(\n\t\teventId: string,\n\t\ttargetConstructor: Function,\n\t\tmethodName: string,\n\t\topts?: RabbitMQEventOptions\n\t) {\n\t\tthis.subscriptions.push({\n\t\t\teventId,\n\t\t\ttargetConstructor,\n\t\t\tmethodName,\n\t\t\topts: opts,\n\t\t});\n\t}\n\n\t/**\n\t * Called at bootstrap to retrieve all known subscriptions\n\t * so we can actually wire them up.\n\t */\n\tpublic static getAllSubscriptions(): SubscriptionMetadata[] {\n\t\treturn [...this.subscriptions];\n\t}\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -26,8 +26,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
|
|
|
26
26
|
searchFields?: string[] | undefined;
|
|
27
27
|
} | undefined;
|
|
28
28
|
sort?: Record<string, 1 | -1> | undefined;
|
|
29
|
-
populate?: any;
|
|
30
29
|
select?: Record<string, 0 | 1> | undefined;
|
|
30
|
+
populate?: any;
|
|
31
31
|
query?: Record<string, any> | undefined;
|
|
32
32
|
}, {
|
|
33
33
|
search?: {
|
|
@@ -36,8 +36,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
|
|
|
36
36
|
} | undefined;
|
|
37
37
|
sort?: Record<string, 1 | -1> | undefined;
|
|
38
38
|
size?: number | undefined;
|
|
39
|
-
populate?: any;
|
|
40
39
|
select?: Record<string, 0 | 1> | undefined;
|
|
40
|
+
populate?: any;
|
|
41
41
|
query?: Record<string, any> | undefined;
|
|
42
42
|
page?: number | undefined;
|
|
43
43
|
}>>;
|
|
@@ -733,12 +733,12 @@ export declare const GetByIdInputSchema: z.ZodObject<{
|
|
|
733
733
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
734
734
|
}, "strip", z.ZodTypeAny, {
|
|
735
735
|
_id: import("mongoose").Types.ObjectId;
|
|
736
|
-
populate?: any;
|
|
737
736
|
select?: Record<string, 0 | 1> | undefined;
|
|
737
|
+
populate?: any;
|
|
738
738
|
}, {
|
|
739
739
|
_id: string | import("mongoose").Types.ObjectId;
|
|
740
|
-
populate?: any;
|
|
741
740
|
select?: Record<string, 0 | 1> | undefined;
|
|
741
|
+
populate?: any;
|
|
742
742
|
}>;
|
|
743
743
|
export type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;
|
|
744
744
|
export declare const GetProductByIdInputSchema: z.ZodObject<{
|
|
@@ -751,12 +751,12 @@ export declare const GetProductByIdInputSchema: z.ZodObject<{
|
|
|
751
751
|
_id: import("mongoose").Types.ObjectId;
|
|
752
752
|
withAttributeHiddenItems: boolean;
|
|
753
753
|
withAddonsHiddenItems: boolean;
|
|
754
|
-
populate?: any;
|
|
755
754
|
select?: Record<string, 0 | 1> | undefined;
|
|
755
|
+
populate?: any;
|
|
756
756
|
}, {
|
|
757
757
|
_id: string | import("mongoose").Types.ObjectId;
|
|
758
|
-
populate?: any;
|
|
759
758
|
select?: Record<string, 0 | 1> | undefined;
|
|
759
|
+
populate?: any;
|
|
760
760
|
withAttributeHiddenItems?: boolean | undefined;
|
|
761
761
|
withAddonsHiddenItems?: boolean | undefined;
|
|
762
762
|
}>;
|
|
@@ -768,13 +768,13 @@ export declare const GetOrderByIdInputSchema: z.ZodObject<{
|
|
|
768
768
|
userOrderCompletionScope: z.ZodOptional<z.ZodNativeEnum<typeof UserOrderCompletionScope>>;
|
|
769
769
|
}, "strip", z.ZodTypeAny, {
|
|
770
770
|
_id: import("mongoose").Types.ObjectId;
|
|
771
|
-
populate?: any;
|
|
772
771
|
select?: Record<string, 0 | 1> | undefined;
|
|
772
|
+
populate?: any;
|
|
773
773
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
774
774
|
}, {
|
|
775
775
|
_id: string | import("mongoose").Types.ObjectId;
|
|
776
|
-
populate?: any;
|
|
777
776
|
select?: Record<string, 0 | 1> | undefined;
|
|
777
|
+
populate?: any;
|
|
778
778
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
779
779
|
}>;
|
|
780
780
|
export type GetOrderByIdInputDTO = DTO<typeof GetOrderByIdInputSchema>;
|
|
@@ -782,11 +782,11 @@ export declare const GetByTokenInputSchema: z.ZodOptional<z.ZodObject<{
|
|
|
782
782
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
783
783
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
784
784
|
}, "strip", z.ZodTypeAny, {
|
|
785
|
-
populate?: any;
|
|
786
785
|
select?: Record<string, 0 | 1> | undefined;
|
|
787
|
-
}, {
|
|
788
786
|
populate?: any;
|
|
787
|
+
}, {
|
|
789
788
|
select?: Record<string, 0 | 1> | undefined;
|
|
789
|
+
populate?: any;
|
|
790
790
|
}>>;
|
|
791
791
|
export type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;
|
|
792
792
|
export declare const GetOneQuerySchema: z.ZodObject<{
|
|
@@ -794,12 +794,12 @@ export declare const GetOneQuerySchema: z.ZodObject<{
|
|
|
794
794
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
795
795
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
796
796
|
}, "strip", z.ZodTypeAny, {
|
|
797
|
-
populate?: any;
|
|
798
797
|
select?: Record<string, 0 | 1> | undefined;
|
|
798
|
+
populate?: any;
|
|
799
799
|
query?: Record<string, any> | undefined;
|
|
800
800
|
}, {
|
|
801
|
-
populate?: any;
|
|
802
801
|
select?: Record<string, 0 | 1> | undefined;
|
|
802
|
+
populate?: any;
|
|
803
803
|
query?: Record<string, any> | undefined;
|
|
804
804
|
}>;
|
|
805
805
|
export type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;
|