@lyxa.ai/core 1.4.18 → 1.4.20

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.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,sCA0BC;AAED,8CA+GC;AAED,oCAEC;AApLD,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,6CAAmE;AACnE,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,gEAMyC;AACzC,wEAAmE;AACnE,iEAA4F;AAC5F,+GAA4G;AAC5G,yDAAgE;AAChE,yFAA+E;AAC/E,4FAAuG;AACvG,uDAAuD;AAKvD,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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K,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,gBAAgB,EAAE,CAAC;QACjF,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,EACrB,OAAO,EACP,KAAK,EAAC,OAAO,EAAC,EAAE;YACf,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,EACD,IAAI,CACJ,CAAC;IACH,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 { 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\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\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\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\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 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
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,sCA0BC;AAED,8CA+GC;AAED,oCAEC;AAlLD,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,6CAAmE;AACnE,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,C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AAC;IAEtD,KAAK,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,gBAAgB,EAAE,CAAC;QACjF,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,EACrB,OAAO,EACP,KAAK,EAAC,OAAO,EAAC,EAAE;YACf,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,EACD,IAAI,CACJ,CAAC;IACH,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 { 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\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 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"]}
@@ -30,5 +30,8 @@ export declare class BOBService implements ICashSettlementService {
30
30
  hasPendingRiderSettlements(riderId: mongoose.Types.ObjectId): Promise<boolean>;
31
31
  getLastSettlement(reference: string): Promise<ISettlementInfo | null>;
32
32
  getLastRiderSettlement(rider: mongoose.Types.ObjectId): Promise<ISettlementInfo | null>;
33
+ private getTransfers;
33
34
  private decompressResponse;
35
+ private hasUnpaidTransfer;
36
+ checkAllPendingTransfers(): Promise<void>;
34
37
  }
@@ -23,6 +23,7 @@ const enum_1 = require("../../../utilities/enum");
23
23
  const __1 = require("../../..");
24
24
  const error_common_1 = require("../../../utilities/error-common");
25
25
  const currency_1 = require("../../../utilities/shared/currency");
26
+ const dayjs_1 = __importDefault(require("dayjs"));
26
27
  var BOBTransferStatus;
27
28
  (function (BOBTransferStatus) {
28
29
  BOBTransferStatus["NOT_PAID"] = "NOT PAID";
@@ -108,7 +109,6 @@ let BOBService = class BOBService {
108
109
  bobModel: enum_1.BobModel.C2B,
109
110
  bobType: enum_1.BobType.INWARD,
110
111
  });
111
- await this.createBullMQJobForStatusCheck(crmNumber);
112
112
  return true;
113
113
  }
114
114
  async createBullMQJobForStatusCheck(crmNumber) {
@@ -130,38 +130,14 @@ let BOBService = class BOBService {
130
130
  console.log(`Removed job scheduler: ${schedulerId}`);
131
131
  return;
132
132
  }
133
- const bobData = {
134
- ChannelType: enum_1.BobChannelType.CO,
135
- Credentials: {
136
- User: this.BOB_USER_NAME,
137
- Password: this.BOB_PASSWORD,
138
- },
139
- Model: enum_1.BobModel.C2B,
140
- CRMNumber: job.data.crmNumber,
141
- };
142
- const { data } = await axios_1.default.post(`${this.BOB_URL}GetTransferStatus`, bobData, {
143
- httpsAgent: new https_1.default.Agent({ rejectUnauthorized: false }),
144
- });
145
- if (data.ErrorCode != 100) {
146
- console.error(`Error in BOB getTransferStatus: ${data.ErrorDescription}`);
147
- throw new server_1.TRPCError({
148
- code: 'INTERNAL_SERVER_ERROR',
149
- message: 'Failed to post data to BOB API.',
150
- });
151
- }
152
- const responseObject = await this.decompressResponse(data.Response);
153
- if (!responseObject) {
154
- console.error('Failed to get settlement status in BOB');
155
- throw new server_1.TRPCError({
156
- code: 'INTERNAL_SERVER_ERROR',
157
- message: 'Failed to get settlement status in BOB.',
158
- });
159
- }
160
- const hasUnpaidTransfer = responseObject.some((item) => item.CRMNumber == crmNumber && item.Status == BOBTransferStatus.NOT_PAID);
133
+ const hasUnpaidTransfer = await this.hasUnpaidTransfer(job.data.crmNumber);
161
134
  if (!hasUnpaidTransfer) {
162
135
  this.settlePayment(settlement);
163
136
  }
164
- console.log(`🔥 [${new Date().toISOString()}] Settlement status for ${job.data.crmNumber}:`, responseObject);
137
+ console.log(`🔥 [${new Date().toISOString()}] Checking settlement status for ${job.data.crmNumber}:`, {
138
+ settlement,
139
+ hasUnpaidTransfer,
140
+ });
165
141
  });
166
142
  worker.on('completed', (job) => {
167
143
  console.log(`✅ Job completed: ${job.id}`);
@@ -363,6 +339,39 @@ let BOBService = class BOBService {
363
339
  updatedAt: lastSettlement.updatedAt ?? new Date(),
364
340
  };
365
341
  }
342
+ async getTransfers(timeframe) {
343
+ const DateTimeFrom = new Date(timeframe.startDate).toISOString().split('.')[0] + 'Z';
344
+ const DateTimeTo = new Date(timeframe.endDate).toISOString().split('.')[0] + 'Z';
345
+ const bobData = {
346
+ ChannelType: enum_1.BobChannelType.CO,
347
+ Credentials: {
348
+ User: this.BOB_USER_NAME,
349
+ Password: this.BOB_PASSWORD,
350
+ },
351
+ Model: enum_1.BobModel.C2B,
352
+ DateTimeFrom,
353
+ DateTimeTo,
354
+ };
355
+ const { data } = await axios_1.default.post(`${this.BOB_URL}GetTransfers`, bobData, {
356
+ httpsAgent: new https_1.default.Agent({ rejectUnauthorized: false }),
357
+ });
358
+ if (data.ErrorCode != 100) {
359
+ console.error(`Error in BOB getTransfers: ${data.ErrorDescription}`);
360
+ throw new server_1.TRPCError({
361
+ code: 'INTERNAL_SERVER_ERROR',
362
+ message: 'Failed to post data to BOB API.',
363
+ });
364
+ }
365
+ const responseObject = await this.decompressResponse(data.Response);
366
+ if (!responseObject) {
367
+ console.error('Failed to get transfers in BOB');
368
+ throw new server_1.TRPCError({
369
+ code: 'INTERNAL_SERVER_ERROR',
370
+ message: 'Failed to get transfers in BOB.',
371
+ });
372
+ }
373
+ return responseObject;
374
+ }
366
375
  async decompressResponse(response) {
367
376
  return new Promise((resolve, reject) => {
368
377
  const decodedBuffer = Buffer.from(response, 'base64');
@@ -382,6 +391,79 @@ let BOBService = class BOBService {
382
391
  });
383
392
  });
384
393
  }
394
+ async hasUnpaidTransfer(crmNumber) {
395
+ const bobData = {
396
+ ChannelType: enum_1.BobChannelType.CO,
397
+ Credentials: {
398
+ User: this.BOB_USER_NAME,
399
+ Password: this.BOB_PASSWORD,
400
+ },
401
+ Model: enum_1.BobModel.C2B,
402
+ CRMNumber: crmNumber,
403
+ };
404
+ const { data } = await axios_1.default.post(`${this.BOB_URL}GetTransferStatus`, bobData, {
405
+ httpsAgent: new https_1.default.Agent({ rejectUnauthorized: false }),
406
+ });
407
+ if (data.ErrorCode != 100) {
408
+ console.error(`Error in BOB getTransferStatus: ${data.ErrorDescription}`);
409
+ throw new server_1.TRPCError({
410
+ code: 'INTERNAL_SERVER_ERROR',
411
+ message: 'Failed to post data to BOB API.',
412
+ });
413
+ }
414
+ const responseObject = await this.decompressResponse(data.Response);
415
+ if (!responseObject) {
416
+ console.error('Failed to get settlement status in BOB');
417
+ throw new server_1.TRPCError({
418
+ code: 'INTERNAL_SERVER_ERROR',
419
+ message: 'Failed to get settlement status in BOB.',
420
+ });
421
+ }
422
+ const hasUnpaidTransfer = responseObject.some((item) => item.CRMNumber == crmNumber && item.Status == BOBTransferStatus.NOT_PAID);
423
+ return hasUnpaidTransfer;
424
+ }
425
+ async checkAllPendingTransfers() {
426
+ console.log(`🔥 [${new Date().toISOString()}] Checking pending BOB transfers`);
427
+ const notPaidSettlements = await this.model.find({
428
+ status: enum_1.BobSettlementStatus.NOT_PAID,
429
+ });
430
+ if (!notPaidSettlements.length) {
431
+ return;
432
+ }
433
+ let maxDate = (0, dayjs_1.default)();
434
+ let minDate = (0, dayjs_1.default)();
435
+ const createdAtDates = notPaidSettlements.map(item => (0, dayjs_1.default)(item.createdAt));
436
+ if (createdAtDates.length > 0) {
437
+ maxDate = dayjs_1.default.max(...createdAtDates);
438
+ minDate = dayjs_1.default.min(...createdAtDates);
439
+ }
440
+ const maxDatePlusOneDay = maxDate.add(1, 'day').toDate();
441
+ const minDateMinusOneDay = minDate.add(1, 'day').toDate();
442
+ const transfers = await this.getTransfers({
443
+ startDate: minDateMinusOneDay,
444
+ endDate: maxDatePlusOneDay,
445
+ });
446
+ if (!transfers || transfers.length === 0) {
447
+ return;
448
+ }
449
+ const transferStatusMap = new Map();
450
+ for (const trx of transfers) {
451
+ transferStatusMap.set(trx.ReferenceNumber, trx.Status);
452
+ }
453
+ await Promise.all(notPaidSettlements.map(async (settlement) => {
454
+ try {
455
+ const status = transferStatusMap.get(settlement.crmNumber);
456
+ const isStillUnpaid = status === BOBTransferStatus.NOT_PAID;
457
+ if (!isStillUnpaid) {
458
+ await this.settlePayment(settlement);
459
+ }
460
+ console.log(`🔥 Settlement ${settlement.crmNumber}`, { status });
461
+ }
462
+ catch (err) {
463
+ console.error(`❌ Failed settlement ${settlement.crmNumber}`, err);
464
+ }
465
+ }));
466
+ }
385
467
  };
386
468
  exports.BOBService = BOBService;
387
469
  exports.BOBService = BOBService = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"bob.js","sourceRoot":"/","sources":["libraries/cash-settlement/providers/bob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,+CAU4B;AAC5B,mCA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G,EAAE,kBAAkB,EAAE,EAAE;gBACtD,IAAI,GAAG,EAAE,CAAC;oBACT,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;oBAChD,MAAM,IAAI,kBAAS,CAAC;wBACnB,IAAI,EAAE,uBAAuB;wBAC7B,OAAO,EAAE,yCAAyC;qBAClD,CAAC,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBAEP,MAAM,aAAa,GAAG,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBAG3D,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;oBAEjD,OAAO,CAAC,cAAc,CAAC,CAAC;gBACzB,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAA;AArhBY,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CAqhBtB","sourcesContent":["import axios from 'axios';\nimport { ICashSettlementService, ISettlementInfo, ISettlementStatus } from '../interfaces/ICashSettlement';\nimport { SoftDeleteModel } from '../../mongo/plugins/soft-delete-plugin';\nimport {\n\tBOBFinance,\n\tBOBFinanceModel,\n\tCounter,\n\tCounterModel,\n\tFinanceSettlement,\n\tFinanceSettlementModel,\n\tRider,\n\tRiderModel,\n\tSetting,\n} from '../../mongo/models';\nimport { Service } from 'typedi';\nimport https from 'https';\nimport zlib from 'zlib';\nimport { TRPCError } from '@trpc/server';\nimport {\n\tAccountType,\n\tBobChannelType,\n\tBobModel,\n\tBobSettlementStatus,\n\tBobSettlementType,\n\tBobType,\n\tCounterType,\n\tSettlementType,\n} from '../../../utilities/enum';\nimport { DocumentType, mongoose } from '@typegoose/typegoose';\nimport { getLibraries } from '../../..';\nimport { badRequestError, notFoundError } from '../../../utilities/error-common';\nimport { roundBaseCurrency, roundSecondaryCurrency } from '../../../utilities/shared/currency';\n\nexport type BOBSecrets = {\n\tBOB_USER_NAME: string;\n\tBOB_PASSWORD: string;\n\tBOB_URL: string;\n};\n\nexport enum BOBTransferStatus {\n\tNOT_PAID = 'NOT PAID',\n\tPAID = 'PAID',\n}\n\n@Service()\nexport class BOBService implements ICashSettlementService {\n\tprivate model: typeof BOBFinanceModel & SoftDeleteModel<BOBFinance>;\n\tprivate riderModel: typeof RiderModel & SoftDeleteModel<Rider>;\n\tprivate financeSettlementModel: typeof FinanceSettlementModel & SoftDeleteModel<FinanceSettlement>;\n\n\tprivate BOB_USER_NAME: string;\n\tprivate BOB_PASSWORD: string;\n\tprivate BOB_URL: string;\n\n\tconstructor(secrets: BOBSecrets) {\n\t\tthis.BOB_USER_NAME = secrets.BOB_USER_NAME;\n\t\tthis.BOB_PASSWORD = secrets.BOB_PASSWORD;\n\t\tthis.BOB_URL = secrets.BOB_URL;\n\n\t\tthis.model = BOBFinanceModel as typeof BOBFinanceModel & SoftDeleteModel<BOBFinance>;\n\t\tthis.riderModel = RiderModel as typeof RiderModel & SoftDeleteModel<Rider>;\n\t\tthis.financeSettlementModel = FinanceSettlementModel as typeof FinanceSettlementModel &\n\t\t\tSoftDeleteModel<FinanceSettlement>;\n\t}\n\n\tprivate async autoIncrementCRMCounter(): Promise<DocumentType<Counter>> {\n\t\treturn await CounterModel.findOneAndUpdate(\n\t\t\t{ counterType: CounterType.CRM_NUMBER },\n\t\t\t{ $inc: { value: 1 } },\n\t\t\t{ new: true, upsert: true }\n\t\t);\n\t}\n\n\tprivate convertNumberToCode(num: number): string {\n\t\t// convert a number to a code (e.g. 0 -> aa00)\n\t\tconst letters = 'abcdefghijklmnopqrstuvwxyz';\n\t\tconst lettersLength = letters.length;\n\n\t\tconst firstCharIndex = Math.floor(num / lettersLength) % lettersLength;\n\t\tconst secondCharIndex = num % lettersLength;\n\n\t\tconst digits = num % 100; // Ensures two digits (00 to 99)\n\t\treturn digits.toString().padStart(2, '0') + letters[firstCharIndex] + letters[secondCharIndex];\n\t}\n\n\t/**\n\t * Initiates a cash settlement process\n\t *\n\t * @param amount - The amount to be settled\n\t * @param currency - The currency of the amount\n\t * @param reference - A unique reference for the settlement\n\t * @param firstName - The first name of the settler\n\t * @param lastName - The last name of the settler\n\t * @param riderId - The ID of the rider associated with the settlement\n\t * @param location - Optional location of the settler\n\t * @returns Confirmation of the settlement initiation\n\t */\n\tpublic async initiateSettlement(\n\t\tamount: number,\n\t\tcurrency: string,\n\t\treference: string,\n\t\tfirstName: string,\n\t\tlastName: string,\n\t\triderId: mongoose.Types.ObjectId,\n\t\tlocation?: string\n\t): Promise<boolean> {\n\t\t// BOB cannot handle amount > 20000000\n\t\tif (amount > 20000000) {\n\t\t\tbadRequestError('Please provide a value between 0 and 20000000');\n\t\t}\n\n\t\tconst crmCounter = await this.autoIncrementCRMCounter();\n\t\tconst crmNumber = this.convertNumberToCode(crmCounter.value);\n\t\tif (!crmNumber) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to generate CRM number for BOB settlement.',\n\t\t\t});\n\t\t}\n\n\t\tconst bobData = {\n\t\t\tChannelType: BobChannelType.CO,\n\t\t\tCredentials: {\n\t\t\t\tUser: this.BOB_USER_NAME,\n\t\t\t\tPassword: this.BOB_PASSWORD,\n\t\t\t},\n\t\t\tModel: BobModel.C2B,\n\t\t\tFirstName: firstName,\n\t\t\tLastName: lastName,\n\t\t\tCRMNumber: crmNumber,\n\t\t\tAmount: String(amount),\n\t\t\tCurrency: currency,\n\t\t};\n\n\t\tconst { data } = await axios.post(`${this.BOB_URL}InsertTransferData`, bobData, {\n\t\t\thttpsAgent: new https.Agent({ rejectUnauthorized: false }),\n\t\t});\n\n\t\tif (data.ErrorCode != 100) {\n\t\t\tconsole.error(`Error in BOB initiateSettlement: ${data.ErrorDescription}`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to post data to BOB API.',\n\t\t\t});\n\t\t}\n\n\t\tconst responseObject = await this.decompressResponse(data.Response);\n\n\t\tif (!responseObject || !responseObject.isSuccess) {\n\t\t\tconsole.error('Failed to initiate settlement in BOB');\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to initiate settlement in BOB.',\n\t\t\t});\n\t\t}\n\n\t\tconst bobSettlement = await this.model.create({\n\t\t\tamount: currency === 'USD' ? amount : 0,\n\t\t\tsecondaryAmount: currency === 'USD' ? 0 : amount,\n\t\t\tcrmNumber: crmNumber,\n\t\t\trider: riderId,\n\t\t\tbobLocation: location,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t\tsettlementType: BobSettlementType.SETTLE_CASH,\n\t\t\tbobModel: BobModel.C2B,\n\t\t\tbobType: BobType.INWARD,\n\t\t});\n\n\t\tawait this.createBullMQJobForStatusCheck(crmNumber);\n\n\t\treturn true;\n\t}\n\n\tprivate async createBullMQJobForStatusCheck(crmNumber: string) {\n\t\tconst bullmq = getLibraries().getBullMQService();\n\t\tconst queueId = `bob-settlement-status-check-queue-crm-${crmNumber}`;\n\t\tconst queue = bullmq.createQueue(queueId);\n\t\tconst jobName = `bob-settlement-status-check-job-crm-${crmNumber}`;\n\t\tconst schedulerId = `bob-settlement-status-check-scheduler-crm-${crmNumber}`;\n\n\t\tawait queue.upsertJobScheduler(\n\t\t\tschedulerId,\n\t\t\t{ pattern: '* * * * *' },\n\t\t\t{ name: jobName, data: { crmNumber } }\n\t\t);\n\n\t\tconst worker = bullmq.createWorker(queueId, async (job: any) => {\n\t\t\tconsole.log(`🔥 [${new Date().toISOString()}] Job triggered:`, job.name, job.data);\n\n\t\t\tconst settlement = await this.model.findOne({\n\t\t\t\tcrmNumber: job.data.crmNumber,\n\t\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t\t});\n\n\t\t\tif (!settlement) {\n\t\t\t\tconsole.log(`Settlement with CRM number ${job.data.crmNumber} not found.`);\n\t\t\t\tawait queue.removeJobScheduler(schedulerId);\n\t\t\t\tconsole.log(`Removed job scheduler: ${schedulerId}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst bobData = {\n\t\t\t\tChannelType: BobChannelType.CO,\n\t\t\t\tCredentials: {\n\t\t\t\t\tUser: this.BOB_USER_NAME,\n\t\t\t\t\tPassword: this.BOB_PASSWORD,\n\t\t\t\t},\n\t\t\t\tModel: BobModel.C2B,\n\t\t\t\tCRMNumber: job.data.crmNumber,\n\t\t\t};\n\t\t\tconst { data } = await axios.post(`${this.BOB_URL}GetTransferStatus`, bobData, {\n\t\t\t\thttpsAgent: new https.Agent({ rejectUnauthorized: false }),\n\t\t\t});\n\n\t\t\tif (data.ErrorCode != 100) {\n\t\t\t\tconsole.error(`Error in BOB getTransferStatus: ${data.ErrorDescription}`);\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\t\tmessage: 'Failed to post data to BOB API.',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst responseObject = await this.decompressResponse(data.Response);\n\n\t\t\tif (!responseObject) {\n\t\t\t\tconsole.error('Failed to get settlement status in BOB');\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\t\tmessage: 'Failed to get settlement status in BOB.',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst hasUnpaidTransfer = responseObject.some(\n\t\t\t\t(item: any) => item.CRMNumber == crmNumber && item.Status == BOBTransferStatus.NOT_PAID\n\t\t\t);\n\n\t\t\tif (!hasUnpaidTransfer) {\n\t\t\t\tthis.settlePayment(settlement);\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\t`🔥 [${new Date().toISOString()}] Settlement status for ${job.data.crmNumber}:`,\n\t\t\t\tresponseObject\n\t\t\t);\n\t\t});\n\n\t\tworker.on('completed', (job: any) => {\n\t\t\tconsole.log(`✅ Job completed: ${job.id}`);\n\t\t});\n\n\t\tworker.on('failed', (job: any, err: any) => {\n\t\t\tconsole.error(`❌ Job failed: ${job?.id} -`, err);\n\t\t});\n\t}\n\n\t/**\n\t * Mark a settlement as paid\n\t *\n\t * @param settlementId - The ID of the settlement to update\n\t * @returns Confirmation of the update\n\t */\n\tpublic async markSettlementAsPaid(settlementId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst settlement = await this.model.findById(settlementId);\n\n\t\tif (!settlement) {\n\t\t\tconsole.error(`Settlement with not found.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Settlement not found.',\n\t\t\t});\n\t\t}\n\n\t\tif (settlement.status === BobSettlementStatus.PAID) {\n\t\t\tconsole.error(`Settlement with ID ${settlementId} is already marked as paid.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'BAD_REQUEST',\n\t\t\t\tmessage: 'Settlement is already marked as paid.',\n\t\t\t});\n\t\t}\n\n\t\tawait this.settlePayment(settlement);\n\n\t\tif (settlement.status === BobSettlementStatus.NOT_PAID) {\n\t\t\tawait this.removeTransfer(settlement.crmNumber); // Remove the transfer from BOB so future settlements with the same reference do not fail\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate async settlePayment(settlement: DocumentType<BOBFinance>) {\n\t\tawait this.model.findByIdAndUpdate(\n\t\t\tsettlement._id,\n\t\t\t{ status: BobSettlementStatus.PAID },\n\t\t\t{ new: true, runValidators: true }\n\t\t);\n\n\t\tawait this.financeSettlementModel.create({\n\t\t\tamount: settlement.amount,\n\t\t\tsecondaryAmount: settlement.secondaryAmount,\n\t\t\trider: settlement.rider,\n\t\t\tsettlementType: SettlementType.RIDER_SETTLE_CASH,\n\t\t\taccountType: AccountType.RIDER,\n\t\t});\n\n\t\tconst rider = await this.riderModel.findById(settlement.rider);\n\t\tif (!rider) {\n\t\t\tconsole.error(`Rider with ID ${settlement.rider} not found.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Rider not found.',\n\t\t\t});\n\t\t}\n\n\t\tconst settings: Setting = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = settings?.currencySetting?.exchangeRate || 1;\n\n\t\tconst totalSettlement = settlement.amount || 0;\n\t\tconst totalSecondarySettlement = settlement.secondaryAmount || 0;\n\n\t\tlet primaryToDeduct = totalSettlement;\n\t\tlet secondaryToDeduct = totalSecondarySettlement;\n\n\t\tlet availablePrimary = rider.cashInHand?.amount || 0;\n\t\tlet availableSecondary = rider.cashInHand?.secondaryAmount || 0;\n\n\t\t// 1. Handle primary settlement\n\t\tlet deductedPrimary = Math.min(availablePrimary, primaryToDeduct);\n\t\tprimaryToDeduct -= deductedPrimary;\n\t\tavailablePrimary -= deductedPrimary;\n\n\t\t// fallback to secondary if needed\n\t\tif (primaryToDeduct > 0) {\n\t\t\tconst neededSecondary = roundSecondaryCurrency(primaryToDeduct * exchangeRate);\n\n\t\t\tconst deductedSecondary = Math.min(availableSecondary, neededSecondary);\n\n\t\t\tsecondaryToDeduct += deductedSecondary; // accumulate deduction\n\t\t\tavailableSecondary -= deductedSecondary;\n\n\t\t\tprimaryToDeduct = 0;\n\t\t}\n\n\t\t// 2. Handle secondary settlement\n\t\tlet deductedSecondaryDirect = Math.min(availableSecondary, totalSecondarySettlement);\n\t\tsecondaryToDeduct = deductedSecondaryDirect;\n\t\tavailableSecondary -= deductedSecondaryDirect;\n\n\t\tconst remainingSecondary = totalSecondarySettlement - deductedSecondaryDirect;\n\n\t\t// fallback to primary\n\t\tif (remainingSecondary > 0) {\n\t\t\tconst neededPrimary = roundBaseCurrency(remainingSecondary / exchangeRate);\n\n\t\t\tconst deductedPrimaryFallback = Math.min(availablePrimary, neededPrimary);\n\n\t\t\tdeductedPrimary += deductedPrimaryFallback;\n\t\t\tavailablePrimary -= deductedPrimaryFallback;\n\t\t}\n\n\t\tconst deltaPrimary = -deductedPrimary;\n\t\tconst deltaSecondary = -secondaryToDeduct;\n\n\t\tawait this.riderModel.findByIdAndUpdate(\n\t\t\trider._id,\n\t\t\t{\n\t\t\t\t$inc: {\n\t\t\t\t\t'cashInHand.secondaryAmount': deltaSecondary,\n\t\t\t\t\t'cashInHand.amount': deltaPrimary,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ new: true, runValidators: true }\n\t\t);\n\t}\n\n\t/**\n\t * Revokes a cash settlement\n\t *\n\t * @param reference - The reference ID of the settlement to revoke\n\t * @returns Confirmation of the revocation\n\t */\n\tpublic async revokeSettlement(reference: string): Promise<boolean> {\n\t\tconst settlement = await this.model.findOne({\n\t\t\tcrmNumber: reference,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\n\t\tif (!settlement) {\n\t\t\tconsole.error(`Settlement with reference ${reference} not found.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Settlement not found.',\n\t\t\t});\n\t\t}\n\n\t\tawait this.removeTransfer(reference);\n\n\t\tconst result = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\tcrmNumber: reference,\n\t\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t\t},\n\t\t\t{\n\t\t\t\tstatus: BobSettlementStatus.REVOKED,\n\t\t\t},\n\t\t\t{ new: true, runValidators: true }\n\t\t);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Revokes a cash settlement\n\t *\n\t * @param reference - The reference ID of the settlement to revoke\n\t * @returns Confirmation of the revocation\n\t */\n\tpublic async revokeRiderSettlements(rider: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst settlements = await this.model.find({\n\t\t\trider: rider,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\n\t\tif (!settlements.length) {\n\t\t\tnotFoundError('No unpaid settlements found.');\n\t\t}\n\n\t\tfor (const settlement of settlements) {\n\t\t\tawait this.removeTransfer(settlement.crmNumber);\n\t\t\tawait this.model.findByIdAndUpdate(settlement._id, {\n\t\t\t\tstatus: BobSettlementStatus.REVOKED,\n\t\t\t});\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate async removeTransfer(crmNumber: string) {\n\t\tconst bobData = {\n\t\t\tChannelType: BobChannelType.CO,\n\t\t\tCredentials: {\n\t\t\t\tUser: this.BOB_USER_NAME,\n\t\t\t\tPassword: this.BOB_PASSWORD,\n\t\t\t},\n\t\t\tModel: BobModel.C2B,\n\t\t\tCRMNumber: crmNumber,\n\t\t};\n\n\t\tconst { data } = await axios.post(`${this.BOB_URL}RemoveTransfer`, bobData, {\n\t\t\thttpsAgent: new https.Agent({ rejectUnauthorized: false }),\n\t\t});\n\n\t\tif (data.ErrorCode == 213) {\n\t\t\t// Record does not exist\n\t\t\treturn;\n\t\t}\n\n\t\tif (data.ErrorCode != 100) {\n\t\t\tconsole.error(`Error in BOB removeTransfer: ${data.ErrorDescription}`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to post data to BOB API.',\n\t\t\t});\n\t\t}\n\n\t\tconst responseObject = await this.decompressResponse(data.Response);\n\n\t\tif (!responseObject || !responseObject.isSuccess) {\n\t\t\tconsole.error('Failed to remove transfer in BOB');\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to remove transfer in BOB.',\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Check if there are pending settlements\n\t *\n\t * @param reference - The reference ID of the settlement to check\n\t * @returns true if there are pending settlements, false otherwise\n\t */\n\tpublic async hasPendingSettlements(reference: string): Promise<boolean> {\n\t\tconst pendingSettlements = await this.model.find({\n\t\t\tcrmNumber: reference,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\t\treturn pendingSettlements.length > 0;\n\t}\n\n\t/**\n\t * Check if there are pending settlements\n\t *\n\t * @param riderId - The ID of the rider to check\n\t * @returns true if there are pending settlements, false otherwise\n\t */\n\tpublic async hasPendingRiderSettlements(riderId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst pendingSettlements = await this.model.find({\n\t\t\trider: riderId,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\t\treturn pendingSettlements.length > 0;\n\t}\n\n\t/**\n\t * Get latest settlement info\n\t *\n\t * @param reference - The reference ID of the settlement to check\n\t * @returns the latest settlement if it exists, null otherwise\n\t */\n\tpublic async getLastSettlement(reference: string): Promise<ISettlementInfo | null> {\n\t\tconst pendingSettlements = await this.model\n\t\t\t.findOne({\n\t\t\t\tcrmNumber: reference,\n\t\t\t})\n\t\t\t.sort({ createdAt: -1 });\n\n\t\tif (!pendingSettlements) return null;\n\n\t\treturn {\n\t\t\tamount: pendingSettlements.amount || pendingSettlements.secondaryAmount || 0,\n\t\t\tcurrency: pendingSettlements.amount ? 'USD' : 'LBP',\n\t\t\treferenceNumber: pendingSettlements.crmNumber,\n\t\t\tstatus: (pendingSettlements.status ?? BobSettlementStatus.NOT_PAID) as unknown as ISettlementStatus,\n\t\t\tcreatedAt: pendingSettlements.createdAt ?? new Date(),\n\t\t\tupdatedAt: pendingSettlements.createdAt ?? new Date(),\n\t\t};\n\t}\n\n\t/**\n\t * Get latest settlement info\n\t *\n\t * @param riderId - The ID of the rider to check\n\t * @returns the latest settlement if it exists, null otherwise\n\t */\n\tpublic async getLastRiderSettlement(rider: mongoose.Types.ObjectId): Promise<ISettlementInfo | null> {\n\t\tconst lastSettlement = await this.model\n\t\t\t.findOne({\n\t\t\t\trider: rider,\n\t\t\t})\n\t\t\t.sort({ createdAt: -1 });\n\n\t\tif (!lastSettlement) return null;\n\n\t\treturn {\n\t\t\tamount: lastSettlement.amount || lastSettlement.secondaryAmount || 0,\n\t\t\tcurrency: lastSettlement.amount ? 'USD' : 'LBP',\n\t\t\treferenceNumber: lastSettlement.crmNumber,\n\t\t\tstatus: (lastSettlement.status ?? BobSettlementStatus.NOT_PAID) as unknown as ISettlementStatus,\n\t\t\tcreatedAt: lastSettlement.createdAt ?? new Date(),\n\t\t\tupdatedAt: lastSettlement.updatedAt ?? new Date(),\n\t\t};\n\t}\n\n\tprivate async decompressResponse(response: string): Promise<any> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\t// Step 1: Decode Base64\n\t\t\tconst decodedBuffer = Buffer.from(response, 'base64');\n\n\t\t\t// Step 2: Decompress GZIP\n\t\t\tzlib.gunzip(decodedBuffer, (err, decompressedBuffer) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tconsole.error('Error decompressing GZIP:', err);\n\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\t\t\tmessage: 'Failed to decompress data from BOB API.',\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// Step 3: Convert decompressed buffer to string\n\t\t\t\t\tconst decodedString = decompressedBuffer.toString('utf-8');\n\n\t\t\t\t\t// Step 4: Parse the JSON string to a JavaScript object\n\t\t\t\t\tconst responseObject = JSON.parse(decodedString);\n\n\t\t\t\t\tresolve(responseObject);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"bob.js","sourceRoot":"/","sources":["libraries/cash-settlement/providers/bob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,+CAU4B;AAC5B,mCAAiC;AACjC,kDAA0B;AAC1B,gDAAwB;AACxB,yCAAyC;AACzC,kDASiC;AAEjC,gCAAwC;AACxC,kEAAiF;AACjF,iEAA+F;AAC/F,kDAA0B;AAQ1B,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC5B,0CAAqB,CAAA;IACrB,kCAAa,CAAA;AACd,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAU;IACd,KAAK,CAAuD;IAC5D,UAAU,CAA6C;IACvD,s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BY,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CA0nBtB","sourcesContent":["import axios from 'axios';\nimport { ICashSettlementService, ISettlementInfo, ISettlementStatus } from '../interfaces/ICashSettlement';\nimport { SoftDeleteModel } from '../../mongo/plugins/soft-delete-plugin';\nimport {\n\tBOBFinance,\n\tBOBFinanceModel,\n\tCounter,\n\tCounterModel,\n\tFinanceSettlement,\n\tFinanceSettlementModel,\n\tRider,\n\tRiderModel,\n\tSetting,\n} from '../../mongo/models';\nimport { Service } from 'typedi';\nimport https from 'https';\nimport zlib from 'zlib';\nimport { TRPCError } from '@trpc/server';\nimport {\n\tAccountType,\n\tBobChannelType,\n\tBobModel,\n\tBobSettlementStatus,\n\tBobSettlementType,\n\tBobType,\n\tCounterType,\n\tSettlementType,\n} from '../../../utilities/enum';\nimport { DocumentType, mongoose } from '@typegoose/typegoose';\nimport { getLibraries } from '../../..';\nimport { badRequestError, notFoundError } from '../../../utilities/error-common';\nimport { roundBaseCurrency, roundSecondaryCurrency } from '../../../utilities/shared/currency';\nimport dayjs from 'dayjs';\n\nexport type BOBSecrets = {\n\tBOB_USER_NAME: string;\n\tBOB_PASSWORD: string;\n\tBOB_URL: string;\n};\n\nexport enum BOBTransferStatus {\n\tNOT_PAID = 'NOT PAID',\n\tPAID = 'PAID',\n}\n\n@Service()\nexport class BOBService implements ICashSettlementService {\n\tprivate model: typeof BOBFinanceModel & SoftDeleteModel<BOBFinance>;\n\tprivate riderModel: typeof RiderModel & SoftDeleteModel<Rider>;\n\tprivate financeSettlementModel: typeof FinanceSettlementModel & SoftDeleteModel<FinanceSettlement>;\n\n\tprivate BOB_USER_NAME: string;\n\tprivate BOB_PASSWORD: string;\n\tprivate BOB_URL: string;\n\n\tconstructor(secrets: BOBSecrets) {\n\t\tthis.BOB_USER_NAME = secrets.BOB_USER_NAME;\n\t\tthis.BOB_PASSWORD = secrets.BOB_PASSWORD;\n\t\tthis.BOB_URL = secrets.BOB_URL;\n\n\t\tthis.model = BOBFinanceModel as typeof BOBFinanceModel & SoftDeleteModel<BOBFinance>;\n\t\tthis.riderModel = RiderModel as typeof RiderModel & SoftDeleteModel<Rider>;\n\t\tthis.financeSettlementModel = FinanceSettlementModel as typeof FinanceSettlementModel &\n\t\t\tSoftDeleteModel<FinanceSettlement>;\n\t}\n\n\tprivate async autoIncrementCRMCounter(): Promise<DocumentType<Counter>> {\n\t\treturn await CounterModel.findOneAndUpdate(\n\t\t\t{ counterType: CounterType.CRM_NUMBER },\n\t\t\t{ $inc: { value: 1 } },\n\t\t\t{ new: true, upsert: true }\n\t\t);\n\t}\n\n\tprivate convertNumberToCode(num: number): string {\n\t\t// convert a number to a code (e.g. 0 -> aa00)\n\t\tconst letters = 'abcdefghijklmnopqrstuvwxyz';\n\t\tconst lettersLength = letters.length;\n\n\t\tconst firstCharIndex = Math.floor(num / lettersLength) % lettersLength;\n\t\tconst secondCharIndex = num % lettersLength;\n\n\t\tconst digits = num % 100; // Ensures two digits (00 to 99)\n\t\treturn digits.toString().padStart(2, '0') + letters[firstCharIndex] + letters[secondCharIndex];\n\t}\n\n\t/**\n\t * Initiates a cash settlement process\n\t *\n\t * @param amount - The amount to be settled\n\t * @param currency - The currency of the amount\n\t * @param reference - A unique reference for the settlement\n\t * @param firstName - The first name of the settler\n\t * @param lastName - The last name of the settler\n\t * @param riderId - The ID of the rider associated with the settlement\n\t * @param location - Optional location of the settler\n\t * @returns Confirmation of the settlement initiation\n\t */\n\tpublic async initiateSettlement(\n\t\tamount: number,\n\t\tcurrency: string,\n\t\treference: string,\n\t\tfirstName: string,\n\t\tlastName: string,\n\t\triderId: mongoose.Types.ObjectId,\n\t\tlocation?: string\n\t): Promise<boolean> {\n\t\t// BOB cannot handle amount > 20000000\n\t\tif (amount > 20000000) {\n\t\t\tbadRequestError('Please provide a value between 0 and 20000000');\n\t\t}\n\n\t\tconst crmCounter = await this.autoIncrementCRMCounter();\n\t\tconst crmNumber = this.convertNumberToCode(crmCounter.value);\n\t\tif (!crmNumber) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to generate CRM number for BOB settlement.',\n\t\t\t});\n\t\t}\n\n\t\tconst bobData = {\n\t\t\tChannelType: BobChannelType.CO,\n\t\t\tCredentials: {\n\t\t\t\tUser: this.BOB_USER_NAME,\n\t\t\t\tPassword: this.BOB_PASSWORD,\n\t\t\t},\n\t\t\tModel: BobModel.C2B,\n\t\t\tFirstName: firstName,\n\t\t\tLastName: lastName,\n\t\t\tCRMNumber: crmNumber,\n\t\t\tAmount: String(amount),\n\t\t\tCurrency: currency,\n\t\t};\n\n\t\tconst { data } = await axios.post(`${this.BOB_URL}InsertTransferData`, bobData, {\n\t\t\thttpsAgent: new https.Agent({ rejectUnauthorized: false }),\n\t\t});\n\n\t\tif (data.ErrorCode != 100) {\n\t\t\tconsole.error(`Error in BOB initiateSettlement: ${data.ErrorDescription}`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to post data to BOB API.',\n\t\t\t});\n\t\t}\n\n\t\tconst responseObject = await this.decompressResponse(data.Response);\n\n\t\tif (!responseObject || !responseObject.isSuccess) {\n\t\t\tconsole.error('Failed to initiate settlement in BOB');\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to initiate settlement in BOB.',\n\t\t\t});\n\t\t}\n\n\t\tconst bobSettlement = await this.model.create({\n\t\t\tamount: currency === 'USD' ? amount : 0,\n\t\t\tsecondaryAmount: currency === 'USD' ? 0 : amount,\n\t\t\tcrmNumber: crmNumber,\n\t\t\trider: riderId,\n\t\t\tbobLocation: location,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t\tsettlementType: BobSettlementType.SETTLE_CASH,\n\t\t\tbobModel: BobModel.C2B,\n\t\t\tbobType: BobType.INWARD,\n\t\t});\n\n\t\treturn true;\n\t}\n\n\tprivate async createBullMQJobForStatusCheck(crmNumber: string) {\n\t\tconst bullmq = getLibraries().getBullMQService();\n\t\tconst queueId = `bob-settlement-status-check-queue-crm-${crmNumber}`;\n\t\tconst queue = bullmq.createQueue(queueId);\n\t\tconst jobName = `bob-settlement-status-check-job-crm-${crmNumber}`;\n\t\tconst schedulerId = `bob-settlement-status-check-scheduler-crm-${crmNumber}`;\n\n\t\tawait queue.upsertJobScheduler(\n\t\t\tschedulerId,\n\t\t\t{ pattern: '* * * * *' },\n\t\t\t{ name: jobName, data: { crmNumber } }\n\t\t);\n\n\t\tconst worker = bullmq.createWorker(queueId, async (job: any) => {\n\t\t\tconsole.log(`🔥 [${new Date().toISOString()}] Job triggered:`, job.name, job.data);\n\n\t\t\tconst settlement = await this.model.findOne({\n\t\t\t\tcrmNumber: job.data.crmNumber,\n\t\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t\t});\n\n\t\t\tif (!settlement) {\n\t\t\t\tconsole.log(`Settlement with CRM number ${job.data.crmNumber} not found.`);\n\t\t\t\tawait queue.removeJobScheduler(schedulerId);\n\t\t\t\tconsole.log(`Removed job scheduler: ${schedulerId}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst hasUnpaidTransfer = await this.hasUnpaidTransfer(job.data.crmNumber);\n\n\t\t\tif (!hasUnpaidTransfer) {\n\t\t\t\tthis.settlePayment(settlement);\n\t\t\t}\n\n\t\t\tconsole.log(`🔥 [${new Date().toISOString()}] Checking settlement status for ${job.data.crmNumber}:`, {\n\t\t\t\tsettlement,\n\t\t\t\thasUnpaidTransfer,\n\t\t\t});\n\t\t});\n\n\t\tworker.on('completed', (job: any) => {\n\t\t\tconsole.log(`✅ Job completed: ${job.id}`);\n\t\t});\n\n\t\tworker.on('failed', (job: any, err: any) => {\n\t\t\tconsole.error(`❌ Job failed: ${job?.id} -`, err);\n\t\t});\n\t}\n\n\t/**\n\t * Mark a settlement as paid\n\t *\n\t * @param settlementId - The ID of the settlement to update\n\t * @returns Confirmation of the update\n\t */\n\tpublic async markSettlementAsPaid(settlementId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst settlement = await this.model.findById(settlementId);\n\n\t\tif (!settlement) {\n\t\t\tconsole.error(`Settlement with not found.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Settlement not found.',\n\t\t\t});\n\t\t}\n\n\t\tif (settlement.status === BobSettlementStatus.PAID) {\n\t\t\tconsole.error(`Settlement with ID ${settlementId} is already marked as paid.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'BAD_REQUEST',\n\t\t\t\tmessage: 'Settlement is already marked as paid.',\n\t\t\t});\n\t\t}\n\n\t\tawait this.settlePayment(settlement);\n\n\t\tif (settlement.status === BobSettlementStatus.NOT_PAID) {\n\t\t\tawait this.removeTransfer(settlement.crmNumber); // Remove the transfer from BOB so future settlements with the same reference do not fail\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate async settlePayment(settlement: DocumentType<BOBFinance>) {\n\t\tawait this.model.findByIdAndUpdate(\n\t\t\tsettlement._id,\n\t\t\t{ status: BobSettlementStatus.PAID },\n\t\t\t{ new: true, runValidators: true }\n\t\t);\n\n\t\tawait this.financeSettlementModel.create({\n\t\t\tamount: settlement.amount,\n\t\t\tsecondaryAmount: settlement.secondaryAmount,\n\t\t\trider: settlement.rider,\n\t\t\tsettlementType: SettlementType.RIDER_SETTLE_CASH,\n\t\t\taccountType: AccountType.RIDER,\n\t\t});\n\n\t\tconst rider = await this.riderModel.findById(settlement.rider);\n\t\tif (!rider) {\n\t\t\tconsole.error(`Rider with ID ${settlement.rider} not found.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Rider not found.',\n\t\t\t});\n\t\t}\n\n\t\tconst settings: Setting = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = settings?.currencySetting?.exchangeRate || 1;\n\n\t\tconst totalSettlement = settlement.amount || 0;\n\t\tconst totalSecondarySettlement = settlement.secondaryAmount || 0;\n\n\t\tlet primaryToDeduct = totalSettlement;\n\t\tlet secondaryToDeduct = totalSecondarySettlement;\n\n\t\tlet availablePrimary = rider.cashInHand?.amount || 0;\n\t\tlet availableSecondary = rider.cashInHand?.secondaryAmount || 0;\n\n\t\t// 1. Handle primary settlement\n\t\tlet deductedPrimary = Math.min(availablePrimary, primaryToDeduct);\n\t\tprimaryToDeduct -= deductedPrimary;\n\t\tavailablePrimary -= deductedPrimary;\n\n\t\t// fallback to secondary if needed\n\t\tif (primaryToDeduct > 0) {\n\t\t\tconst neededSecondary = roundSecondaryCurrency(primaryToDeduct * exchangeRate);\n\n\t\t\tconst deductedSecondary = Math.min(availableSecondary, neededSecondary);\n\n\t\t\tsecondaryToDeduct += deductedSecondary; // accumulate deduction\n\t\t\tavailableSecondary -= deductedSecondary;\n\n\t\t\tprimaryToDeduct = 0;\n\t\t}\n\n\t\t// 2. Handle secondary settlement\n\t\tlet deductedSecondaryDirect = Math.min(availableSecondary, totalSecondarySettlement);\n\t\tsecondaryToDeduct = deductedSecondaryDirect;\n\t\tavailableSecondary -= deductedSecondaryDirect;\n\n\t\tconst remainingSecondary = totalSecondarySettlement - deductedSecondaryDirect;\n\n\t\t// fallback to primary\n\t\tif (remainingSecondary > 0) {\n\t\t\tconst neededPrimary = roundBaseCurrency(remainingSecondary / exchangeRate);\n\n\t\t\tconst deductedPrimaryFallback = Math.min(availablePrimary, neededPrimary);\n\n\t\t\tdeductedPrimary += deductedPrimaryFallback;\n\t\t\tavailablePrimary -= deductedPrimaryFallback;\n\t\t}\n\n\t\tconst deltaPrimary = -deductedPrimary;\n\t\tconst deltaSecondary = -secondaryToDeduct;\n\n\t\tawait this.riderModel.findByIdAndUpdate(\n\t\t\trider._id,\n\t\t\t{\n\t\t\t\t$inc: {\n\t\t\t\t\t'cashInHand.secondaryAmount': deltaSecondary,\n\t\t\t\t\t'cashInHand.amount': deltaPrimary,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ new: true, runValidators: true }\n\t\t);\n\t}\n\n\t/**\n\t * Revokes a cash settlement\n\t *\n\t * @param reference - The reference ID of the settlement to revoke\n\t * @returns Confirmation of the revocation\n\t */\n\tpublic async revokeSettlement(reference: string): Promise<boolean> {\n\t\tconst settlement = await this.model.findOne({\n\t\t\tcrmNumber: reference,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\n\t\tif (!settlement) {\n\t\t\tconsole.error(`Settlement with reference ${reference} not found.`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Settlement not found.',\n\t\t\t});\n\t\t}\n\n\t\tawait this.removeTransfer(reference);\n\n\t\tconst result = await this.model.findOneAndUpdate(\n\t\t\t{\n\t\t\t\tcrmNumber: reference,\n\t\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t\t},\n\t\t\t{\n\t\t\t\tstatus: BobSettlementStatus.REVOKED,\n\t\t\t},\n\t\t\t{ new: true, runValidators: true }\n\t\t);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Revokes a cash settlement\n\t *\n\t * @param reference - The reference ID of the settlement to revoke\n\t * @returns Confirmation of the revocation\n\t */\n\tpublic async revokeRiderSettlements(rider: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst settlements = await this.model.find({\n\t\t\trider: rider,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\n\t\tif (!settlements.length) {\n\t\t\tnotFoundError('No unpaid settlements found.');\n\t\t}\n\n\t\tfor (const settlement of settlements) {\n\t\t\tawait this.removeTransfer(settlement.crmNumber);\n\t\t\tawait this.model.findByIdAndUpdate(settlement._id, {\n\t\t\t\tstatus: BobSettlementStatus.REVOKED,\n\t\t\t});\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tprivate async removeTransfer(crmNumber: string) {\n\t\tconst bobData = {\n\t\t\tChannelType: BobChannelType.CO,\n\t\t\tCredentials: {\n\t\t\t\tUser: this.BOB_USER_NAME,\n\t\t\t\tPassword: this.BOB_PASSWORD,\n\t\t\t},\n\t\t\tModel: BobModel.C2B,\n\t\t\tCRMNumber: crmNumber,\n\t\t};\n\n\t\tconst { data } = await axios.post(`${this.BOB_URL}RemoveTransfer`, bobData, {\n\t\t\thttpsAgent: new https.Agent({ rejectUnauthorized: false }),\n\t\t});\n\n\t\tif (data.ErrorCode == 213) {\n\t\t\t// Record does not exist\n\t\t\treturn;\n\t\t}\n\n\t\tif (data.ErrorCode != 100) {\n\t\t\tconsole.error(`Error in BOB removeTransfer: ${data.ErrorDescription}`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to post data to BOB API.',\n\t\t\t});\n\t\t}\n\n\t\tconst responseObject = await this.decompressResponse(data.Response);\n\n\t\tif (!responseObject || !responseObject.isSuccess) {\n\t\t\tconsole.error('Failed to remove transfer in BOB');\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to remove transfer in BOB.',\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Check if there are pending settlements\n\t *\n\t * @param reference - The reference ID of the settlement to check\n\t * @returns true if there are pending settlements, false otherwise\n\t */\n\tpublic async hasPendingSettlements(reference: string): Promise<boolean> {\n\t\tconst pendingSettlements = await this.model.find({\n\t\t\tcrmNumber: reference,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\t\treturn pendingSettlements.length > 0;\n\t}\n\n\t/**\n\t * Check if there are pending settlements\n\t *\n\t * @param riderId - The ID of the rider to check\n\t * @returns true if there are pending settlements, false otherwise\n\t */\n\tpublic async hasPendingRiderSettlements(riderId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst pendingSettlements = await this.model.find({\n\t\t\trider: riderId,\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\t\treturn pendingSettlements.length > 0;\n\t}\n\n\t/**\n\t * Get latest settlement info\n\t *\n\t * @param reference - The reference ID of the settlement to check\n\t * @returns the latest settlement if it exists, null otherwise\n\t */\n\tpublic async getLastSettlement(reference: string): Promise<ISettlementInfo | null> {\n\t\tconst pendingSettlements = await this.model\n\t\t\t.findOne({\n\t\t\t\tcrmNumber: reference,\n\t\t\t})\n\t\t\t.sort({ createdAt: -1 });\n\n\t\tif (!pendingSettlements) return null;\n\n\t\treturn {\n\t\t\tamount: pendingSettlements.amount || pendingSettlements.secondaryAmount || 0,\n\t\t\tcurrency: pendingSettlements.amount ? 'USD' : 'LBP',\n\t\t\treferenceNumber: pendingSettlements.crmNumber,\n\t\t\tstatus: (pendingSettlements.status ?? BobSettlementStatus.NOT_PAID) as unknown as ISettlementStatus,\n\t\t\tcreatedAt: pendingSettlements.createdAt ?? new Date(),\n\t\t\tupdatedAt: pendingSettlements.createdAt ?? new Date(),\n\t\t};\n\t}\n\n\t/**\n\t * Get latest settlement info\n\t *\n\t * @param riderId - The ID of the rider to check\n\t * @returns the latest settlement if it exists, null otherwise\n\t */\n\tpublic async getLastRiderSettlement(rider: mongoose.Types.ObjectId): Promise<ISettlementInfo | null> {\n\t\tconst lastSettlement = await this.model\n\t\t\t.findOne({\n\t\t\t\trider: rider,\n\t\t\t})\n\t\t\t.sort({ createdAt: -1 });\n\n\t\tif (!lastSettlement) return null;\n\n\t\treturn {\n\t\t\tamount: lastSettlement.amount || lastSettlement.secondaryAmount || 0,\n\t\t\tcurrency: lastSettlement.amount ? 'USD' : 'LBP',\n\t\t\treferenceNumber: lastSettlement.crmNumber,\n\t\t\tstatus: (lastSettlement.status ?? BobSettlementStatus.NOT_PAID) as unknown as ISettlementStatus,\n\t\t\tcreatedAt: lastSettlement.createdAt ?? new Date(),\n\t\t\tupdatedAt: lastSettlement.updatedAt ?? new Date(),\n\t\t};\n\t}\n\n\tprivate async getTransfers(timeframe: { startDate: Date; endDate: Date }) {\n\t\tconst DateTimeFrom = new Date(timeframe.startDate).toISOString().split('.')[0] + 'Z';\n\t\tconst DateTimeTo = new Date(timeframe.endDate).toISOString().split('.')[0] + 'Z';\n\n\t\tconst bobData = {\n\t\t\tChannelType: BobChannelType.CO,\n\t\t\tCredentials: {\n\t\t\t\tUser: this.BOB_USER_NAME,\n\t\t\t\tPassword: this.BOB_PASSWORD,\n\t\t\t},\n\t\t\tModel: BobModel.C2B,\n\t\t\tDateTimeFrom,\n\t\t\tDateTimeTo,\n\t\t};\n\t\tconst { data } = await axios.post(`${this.BOB_URL}GetTransfers`, bobData, {\n\t\t\thttpsAgent: new https.Agent({ rejectUnauthorized: false }),\n\t\t});\n\n\t\tif (data.ErrorCode != 100) {\n\t\t\tconsole.error(`Error in BOB getTransfers: ${data.ErrorDescription}`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to post data to BOB API.',\n\t\t\t});\n\t\t}\n\n\t\tconst responseObject = await this.decompressResponse(data.Response);\n\n\t\tif (!responseObject) {\n\t\t\tconsole.error('Failed to get transfers in BOB');\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to get transfers in BOB.',\n\t\t\t});\n\t\t}\n\n\t\treturn responseObject;\n\t}\n\n\tprivate async decompressResponse(response: string): Promise<any> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\t// Step 1: Decode Base64\n\t\t\tconst decodedBuffer = Buffer.from(response, 'base64');\n\n\t\t\t// Step 2: Decompress GZIP\n\t\t\tzlib.gunzip(decodedBuffer, (err, decompressedBuffer) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tconsole.error('Error decompressing GZIP:', err);\n\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\t\t\tmessage: 'Failed to decompress data from BOB API.',\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t// Step 3: Convert decompressed buffer to string\n\t\t\t\t\tconst decodedString = decompressedBuffer.toString('utf-8');\n\n\t\t\t\t\t// Step 4: Parse the JSON string to a JavaScript object\n\t\t\t\t\tconst responseObject = JSON.parse(decodedString);\n\n\t\t\t\t\tresolve(responseObject);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate async hasUnpaidTransfer(crmNumber: string): Promise<Boolean> {\n\t\tconst bobData = {\n\t\t\tChannelType: BobChannelType.CO,\n\t\t\tCredentials: {\n\t\t\t\tUser: this.BOB_USER_NAME,\n\t\t\t\tPassword: this.BOB_PASSWORD,\n\t\t\t},\n\t\t\tModel: BobModel.C2B,\n\t\t\tCRMNumber: crmNumber,\n\t\t};\n\t\tconst { data } = await axios.post(`${this.BOB_URL}GetTransferStatus`, bobData, {\n\t\t\thttpsAgent: new https.Agent({ rejectUnauthorized: false }),\n\t\t});\n\n\t\tif (data.ErrorCode != 100) {\n\t\t\tconsole.error(`Error in BOB getTransferStatus: ${data.ErrorDescription}`);\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to post data to BOB API.',\n\t\t\t});\n\t\t}\n\n\t\tconst responseObject = await this.decompressResponse(data.Response);\n\n\t\tif (!responseObject) {\n\t\t\tconsole.error('Failed to get settlement status in BOB');\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Failed to get settlement status in BOB.',\n\t\t\t});\n\t\t}\n\n\t\tconst hasUnpaidTransfer = responseObject.some(\n\t\t\t(item: any) => item.CRMNumber == crmNumber && item.Status == BOBTransferStatus.NOT_PAID\n\t\t);\n\n\t\treturn hasUnpaidTransfer;\n\t}\n\n\tpublic async checkAllPendingTransfers() {\n\t\tconsole.log(`🔥 [${new Date().toISOString()}] Checking pending BOB transfers`);\n\n\t\tconst notPaidSettlements = await this.model.find({\n\t\t\tstatus: BobSettlementStatus.NOT_PAID,\n\t\t});\n\n\t\tif (!notPaidSettlements.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet maxDate = dayjs();\n\t\tlet minDate = dayjs();\n\n\t\tconst createdAtDates = notPaidSettlements.map(item => dayjs(item.createdAt!));\n\n\t\tif (createdAtDates.length > 0) {\n\t\t\tmaxDate = dayjs.max(...createdAtDates)!;\n\t\t\tminDate = dayjs.min(...createdAtDates)!;\n\t\t}\n\n\t\tconst maxDatePlusOneDay = maxDate.add(1, 'day').toDate();\n\t\tconst minDateMinusOneDay = minDate.add(1, 'day').toDate();\n\n\t\tconst transfers = await this.getTransfers({\n\t\t\tstartDate: minDateMinusOneDay,\n\t\t\tendDate: maxDatePlusOneDay,\n\t\t});\n\n\t\tif (!transfers || transfers.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transferStatusMap = new Map<string, string>();\n\n\t\tfor (const trx of transfers) {\n\t\t\ttransferStatusMap.set(trx.ReferenceNumber, trx.Status);\n\t\t}\n\n\t\tawait Promise.all(\n\t\t\tnotPaidSettlements.map(async settlement => {\n\t\t\t\ttry {\n\t\t\t\t\tconst status = transferStatusMap.get(settlement.crmNumber);\n\n\t\t\t\t\tconst isStillUnpaid = status === BOBTransferStatus.NOT_PAID;\n\n\t\t\t\t\tif (!isStillUnpaid) {\n\t\t\t\t\t\tawait this.settlePayment(settlement);\n\t\t\t\t\t}\n\n\t\t\t\t\tconsole.log(`🔥 Settlement ${settlement.crmNumber}`, { status });\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`❌ Failed settlement ${settlement.crmNumber}`, err);\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t}\n}\n"]}
@@ -8,6 +8,7 @@ export declare class LineItemSnap {
8
8
  image?: string;
9
9
  description?: string;
10
10
  duration?: PreparingTime;
11
+ materialCost?: number;
11
12
  }
12
13
  export declare class ServiceLineItem {
13
14
  lineItemType: ServiceLineItemType;
@@ -20,6 +20,7 @@ class LineItemSnap {
20
20
  image;
21
21
  description;
22
22
  duration;
23
+ materialCost;
23
24
  }
24
25
  exports.LineItemSnap = LineItemSnap;
25
26
  __decorate([
@@ -38,6 +39,10 @@ __decorate([
38
39
  (0, typegoose_1.prop)({ type: preparing_time_model_1.PreparingTime }),
39
40
  __metadata("design:type", preparing_time_model_1.PreparingTime)
40
41
  ], LineItemSnap.prototype, "duration", void 0);
42
+ __decorate([
43
+ (0, typegoose_1.prop)({ type: Number }),
44
+ __metadata("design:type", Number)
45
+ ], LineItemSnap.prototype, "materialCost", void 0);
41
46
  class ServiceLineItem {
42
47
  lineItemType;
43
48
  servicePackage;
@@ -1 +1 @@
1
- {"version":3,"file":"service-line-item.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-line-item.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAiE;AACjE,oEAA0D;AAC1D,gEAAsD;AACtD,iEAAuD;AAEvD,MAAa,YAAY;IAEjB,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,WAAW,CAAU;IAGrB,QAAQ,CAAiB;CAChC;AAZD,oCAYC;AAVO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACF;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,oCAAa,EAAE,CAAC;8BACZ,oCAAa;8CAAC;AAejC,MAAa,eAAe;IAEpB,YAAY,CAAuB;IAGnC,cAAc,CAAuB;IAGrC,KAAK,CAAqB;IAG1B,KAAK,CAAU;IAGf,QAAQ,CAAU;IAIlB,YAAY,CAAgB;IAG5B,cAAc,CAAU;IAGxB,eAAe,CAAU;IAGzB,wBAAwB,CAAU;CACzC;AA5BD,0CA4BC;AA1BO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAAmB,EAAE,CAAC;;qDACxB;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,sCAAc,EAAE,CAAC;;uDACQ;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;;8CACD;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACjB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;iDACtB;AAIlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACnB,YAAY;qDAAC;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uDACQ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDACS;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iEACkB","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { ServiceLineItemType } from '../../../../utilities/enum';\nimport { ServicePackage } from '../service-package.model';\nimport { ServiceAddon } from '../service-addon.model';\nimport { PreparingTime } from './preparing-time.model';\n\nexport class LineItemSnap {\n\t@prop({ type: String })\n\tpublic name?: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ type: String })\n\tpublic description?: string;\n\n\t@prop({ type: PreparingTime })\n\tpublic duration?: PreparingTime;\n}\n\n/**\n * A single line item in the service cart.\n *\n * Each line item is either a PACKAGE or an ADDON — never both.\n * The `lineItemType` field is the discriminator:\n *\n * - lineItemType = PACKAGE → `servicePackage` + `lineItemSnap` are set; addon field is absent.\n * - lineItemType = ADDON → `addon` + `lineItemSnap` are set; servicePackage field is absent.\n *\n * `price` — unit price of the item (package price or addon price).\n * `quantity` — how many units of this item are being booked.\n */\nexport class ServiceLineItem {\n\t@prop({ required: true, type: String, enum: ServiceLineItemType })\n\tpublic lineItemType!: ServiceLineItemType;\n\n\t@prop({ ref: () => ServicePackage })\n\tpublic servicePackage?: Ref<ServicePackage>;\n\n\t@prop({ ref: () => ServiceAddon })\n\tpublic addon?: Ref<ServiceAddon>;\n\n\t@prop({ required: true, type: Number })\n\tpublic price!: number;\n\n\t@prop({ required: true, type: Number, min: 1 })\n\tpublic quantity!: number;\n\n\t// Add these fileds when cart will be submitted\n\t@prop({ type: LineItemSnap, _id: false })\n\tpublic lineItemSnap?: LineItemSnap;\n\n\t@prop({ type: Number })\n\tpublic secondaryPrice?: number;\n\n\t@prop({ type: Number })\n\tpublic discountedPrice?: number;\n\n\t@prop({ type: Number })\n\tpublic secondaryDiscountedPrice?: number;\n}\n"]}
1
+ {"version":3,"file":"service-line-item.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-line-item.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAiE;AACjE,oEAA0D;AAC1D,gEAAsD;AACtD,iEAAuD;AAEvD,MAAa,YAAY;IAEjB,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,WAAW,CAAU;IAGrB,QAAQ,CAAiB;IAGzB,YAAY,CAAU;CAC7B;AAfD,oCAeC;AAbO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACF;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CAC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I,EAAE,MAAM,EAAE,CAAC;;wDACS;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iEACkB","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { ServiceLineItemType } from '../../../../utilities/enum';\nimport { ServicePackage } from '../service-package.model';\nimport { ServiceAddon } from '../service-addon.model';\nimport { PreparingTime } from './preparing-time.model';\n\nexport class LineItemSnap {\n\t@prop({ type: String })\n\tpublic name?: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ type: String })\n\tpublic description?: string;\n\n\t@prop({ type: PreparingTime })\n\tpublic duration?: PreparingTime;\n\n\t@prop({ type: Number })\n\tpublic materialCost?: number;\n}\n\n/**\n * A single line item in the service cart.\n *\n * Each line item is either a PACKAGE or an ADDON — never both.\n * The `lineItemType` field is the discriminator:\n *\n * - lineItemType = PACKAGE → `servicePackage` + `lineItemSnap` are set; addon field is absent.\n * - lineItemType = ADDON → `addon` + `lineItemSnap` are set; servicePackage field is absent.\n *\n * `price` — unit price of the item (package price or addon price).\n * `quantity` — how many units of this item are being booked.\n */\nexport class ServiceLineItem {\n\t@prop({ required: true, type: String, enum: ServiceLineItemType })\n\tpublic lineItemType!: ServiceLineItemType;\n\n\t@prop({ ref: () => ServicePackage })\n\tpublic servicePackage?: Ref<ServicePackage>;\n\n\t@prop({ ref: () => ServiceAddon })\n\tpublic addon?: Ref<ServiceAddon>;\n\n\t@prop({ required: true, type: Number })\n\tpublic price!: number;\n\n\t@prop({ required: true, type: Number, min: 1 })\n\tpublic quantity!: number;\n\n\t// Add these fileds when cart will be submitted\n\t@prop({ type: LineItemSnap, _id: false })\n\tpublic lineItemSnap?: LineItemSnap;\n\n\t@prop({ type: Number })\n\tpublic secondaryPrice?: number;\n\n\t@prop({ type: Number })\n\tpublic discountedPrice?: number;\n\n\t@prop({ type: Number })\n\tpublic secondaryDiscountedPrice?: number;\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export declare class Vat {
2
+ vatPercentage?: number;
2
3
  companyVat?: number;
3
4
  secondaryCompanyVat?: number;
4
5
  }
@@ -12,10 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Vat = void 0;
13
13
  const typegoose_1 = require("@typegoose/typegoose");
14
14
  class Vat {
15
+ vatPercentage;
15
16
  companyVat;
16
17
  secondaryCompanyVat;
17
18
  }
18
19
  exports.Vat = Vat;
20
+ __decorate([
21
+ (0, typegoose_1.prop)({ type: Number, default: 0 }),
22
+ __metadata("design:type", Number)
23
+ ], Vat.prototype, "vatPercentage", void 0);
19
24
  __decorate([
20
25
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
21
26
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"vat.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/vat.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,GAAG;IAER,UAAU,CAAU;IAGpB,mBAAmB,CAAU;CACpC;AAND,kBAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uCACR;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACC","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class Vat {\n\t@prop({ type: Number, default: 0 })\n\tpublic companyVat?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryCompanyVat?: number;\n}\n"]}
1
+ {"version":3,"file":"vat.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/vat.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,GAAG;IAER,aAAa,CAAU;IAGvB,UAAU,CAAU;IAGpB,mBAAmB,CAAU;CACpC;AATD,kBASC;AAPO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0CACL;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uCACR;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACC","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class Vat {\n\t@prop({ type: Number, default: 0 })\n\tpublic vatPercentage?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic companyVat?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryCompanyVat?: number;\n}\n"]}
@@ -5,10 +5,10 @@ interface AuthOptions {
5
5
  autoRefresh?: boolean;
6
6
  }
7
7
  export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
8
+ req: import("http").IncomingMessage;
8
9
  res: import("http").ServerResponse<import("http").IncomingMessage>;
9
10
  tokenType: TokenType | undefined;
10
11
  entity: import("../context").EntityContext | undefined;
11
- req: import("http").IncomingMessage;
12
12
  requestId: string | undefined;
13
13
  usedRefreshToken: boolean | undefined;
14
14
  tokenRenewed: boolean | undefined;
@@ -4,10 +4,10 @@ interface RoleProtectedOptions {
4
4
  allowedRoles: string[];
5
5
  }
6
6
  export declare function createRoleProtectedProcedure(options: RoleProtectedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
7
+ req: import("http").IncomingMessage;
7
8
  res: import("http").ServerResponse<import("http").IncomingMessage>;
8
9
  tokenType: import("../../auth").TokenType | undefined;
9
10
  entity: import("../context").EntityContext | undefined;
10
- req: import("http").IncomingMessage;
11
11
  requestId: string | undefined;
12
12
  usedRefreshToken: boolean | undefined;
13
13
  tokenRenewed: boolean | undefined;
@@ -3,10 +3,10 @@ interface PhoneVerifiedOptions {
3
3
  entityTypes: AuthEntityType[];
4
4
  }
5
5
  export declare function createPhoneVerifiedProcedure(options: PhoneVerifiedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
6
+ req: import("http").IncomingMessage;
6
7
  res: import("http").ServerResponse<import("http").IncomingMessage>;
7
8
  tokenType: import("../../auth").TokenType | undefined;
8
9
  entity: import("../context").EntityContext | undefined;
9
- req: import("http").IncomingMessage;
10
10
  requestId: string | undefined;
11
11
  usedRefreshToken: boolean | undefined;
12
12
  tokenRenewed: boolean | undefined;
@@ -5,10 +5,10 @@ interface AuthOptions {
5
5
  autoRefresh?: boolean;
6
6
  }
7
7
  export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
8
+ req: import("http").IncomingMessage;
8
9
  res: import("http").ServerResponse<import("http").IncomingMessage>;
9
10
  tokenType: TokenType | undefined;
10
11
  entity: import("../context").EntityContext | undefined;
11
- req: import("http").IncomingMessage;
12
12
  requestId: string | undefined;
13
13
  usedRefreshToken: boolean | undefined;
14
14
  tokenRenewed: boolean | undefined;
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.18
25
+ Version: 1.4.20
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -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
- select?: Record<string, 0 | 1> | undefined;
30
29
  populate?: any;
30
+ select?: Record<string, 0 | 1> | undefined;
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
- select?: Record<string, 0 | 1> | undefined;
40
39
  populate?: any;
40
+ select?: Record<string, 0 | 1> | undefined;
41
41
  query?: Record<string, any> | undefined;
42
42
  page?: number | undefined;
43
43
  }>>;
@@ -736,12 +736,12 @@ export declare const GetByIdInputSchema: z.ZodObject<{
736
736
  populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
737
737
  }, "strip", z.ZodTypeAny, {
738
738
  _id: import("mongoose").Types.ObjectId;
739
- select?: Record<string, 0 | 1> | undefined;
740
739
  populate?: any;
740
+ select?: Record<string, 0 | 1> | undefined;
741
741
  }, {
742
742
  _id: string | import("mongoose").Types.ObjectId;
743
- select?: Record<string, 0 | 1> | undefined;
744
743
  populate?: any;
744
+ select?: Record<string, 0 | 1> | undefined;
745
745
  }>;
746
746
  export type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;
747
747
  export declare const GetProductByIdInputSchema: z.ZodObject<{
@@ -754,12 +754,12 @@ export declare const GetProductByIdInputSchema: z.ZodObject<{
754
754
  _id: import("mongoose").Types.ObjectId;
755
755
  withAttributeHiddenItems: boolean;
756
756
  withAddonsHiddenItems: boolean;
757
- select?: Record<string, 0 | 1> | undefined;
758
757
  populate?: any;
758
+ select?: Record<string, 0 | 1> | undefined;
759
759
  }, {
760
760
  _id: string | import("mongoose").Types.ObjectId;
761
- select?: Record<string, 0 | 1> | undefined;
762
761
  populate?: any;
762
+ select?: Record<string, 0 | 1> | undefined;
763
763
  withAttributeHiddenItems?: boolean | undefined;
764
764
  withAddonsHiddenItems?: boolean | undefined;
765
765
  }>;
@@ -772,14 +772,14 @@ export declare const GetOrderByIdInputSchema: z.ZodObject<{
772
772
  userOrderCompletionScope: z.ZodOptional<z.ZodNativeEnum<typeof UserOrderCompletionScope>>;
773
773
  }, "strip", z.ZodTypeAny, {
774
774
  _id: import("mongoose").Types.ObjectId;
775
- select?: Record<string, 0 | 1> | undefined;
776
775
  populate?: any;
776
+ select?: Record<string, 0 | 1> | undefined;
777
777
  groupByCategories?: boolean | undefined;
778
778
  userOrderCompletionScope?: UserOrderCompletionScope | undefined;
779
779
  }, {
780
780
  _id: string | import("mongoose").Types.ObjectId;
781
- select?: Record<string, 0 | 1> | undefined;
782
781
  populate?: any;
782
+ select?: Record<string, 0 | 1> | undefined;
783
783
  groupByCategories?: boolean | undefined;
784
784
  userOrderCompletionScope?: UserOrderCompletionScope | undefined;
785
785
  }>;
@@ -788,11 +788,11 @@ export declare const GetByTokenInputSchema: z.ZodOptional<z.ZodObject<{
788
788
  select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
789
789
  populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
790
790
  }, "strip", z.ZodTypeAny, {
791
- select?: Record<string, 0 | 1> | undefined;
792
791
  populate?: any;
793
- }, {
794
792
  select?: Record<string, 0 | 1> | undefined;
793
+ }, {
795
794
  populate?: any;
795
+ select?: Record<string, 0 | 1> | undefined;
796
796
  }>>;
797
797
  export type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;
798
798
  export declare const GetOneQuerySchema: z.ZodObject<{
@@ -800,12 +800,12 @@ export declare const GetOneQuerySchema: z.ZodObject<{
800
800
  select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
801
801
  populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
802
802
  }, "strip", z.ZodTypeAny, {
803
- select?: Record<string, 0 | 1> | undefined;
804
803
  populate?: any;
804
+ select?: Record<string, 0 | 1> | undefined;
805
805
  query?: Record<string, any> | undefined;
806
806
  }, {
807
- select?: Record<string, 0 | 1> | undefined;
808
807
  populate?: any;
808
+ select?: Record<string, 0 | 1> | undefined;
809
809
  query?: Record<string, any> | undefined;
810
810
  }>;
811
811
  export type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;
@@ -962,12 +962,15 @@ export declare const PaymentInformationSchema: z.ZodObject<{
962
962
  }>;
963
963
  export type PaymentInformationDTO = DTO<typeof PaymentInformationSchema>;
964
964
  export declare const VatSchema: z.ZodObject<{
965
+ vatPercentage: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
965
966
  companyVat: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
966
967
  secondaryCompanyVat: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
967
968
  }, "strip", z.ZodTypeAny, {
969
+ vatPercentage?: number | undefined;
968
970
  companyVat?: number | undefined;
969
971
  secondaryCompanyVat?: number | undefined;
970
972
  }, {
973
+ vatPercentage?: number | undefined;
971
974
  companyVat?: number | undefined;
972
975
  secondaryCompanyVat?: number | undefined;
973
976
  }>;
@@ -238,6 +238,7 @@ exports.PaymentInformationSchema = zod_1.z.object({
238
238
  transactionId: global_validation_1.ZodValidation.string('Transaction id').optional(),
239
239
  });
240
240
  exports.VatSchema = zod_1.z.object({
241
+ vatPercentage: global_validation_1.ZodValidation.number('Vat parcentage').default(0).optional(),
241
242
  companyVat: global_validation_1.ZodValidation.number('Company vat').default(0).optional(),
242
243
  secondaryCompanyVat: global_validation_1.ZodValidation.number('Secondary company vat').default(0).optional(),
243
244
  });
@@ -1 +1 @@
1
- {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAUiB;AAKjB,MAAM,gBAAgB,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AAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC/E,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport {\n\tActionType,\n\tAppPlatform,\n\tCardType,\n\tGeoLocationType,\n\tHolidayWorkStatus,\n\tLanguage,\n\tUserOrderCompletionScope,\n\tWeekDay,\n\tWorkStatus,\n} from '../enum';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City').optional(),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\n\nconst TimeStringSchema = z\n\t.string()\n\t// Allow 1 or 2 digits for hour\n\t.regex(/^([0-9]|[01]\\d|2[0-3]):([0-5]\\d)$/, 'Time must be in HH:mm format (e.g., 09:30 or 9:30)')\n\t// Normalize to HH:mm → always two digits for hour\n\t.transform(time => {\n\t\tlet [h, m] = time.split(':');\n\t\th = h.padStart(2, '0'); // convert \"9:30\" → \"09:30\"\n\t\treturn `${h}:${m}`;\n\t})\n\t// Validate logical range\n\t.refine(\n\t\ttime => {\n\t\t\tconst [h, m] = time.split(':').map(Number);\n\t\t\treturn h >= 0 && h <= 23 && m >= 0 && m <= 59;\n\t\t},\n\t\t{ message: 'Invalid time range, must be between 00:00 and 23:59' }\n\t);\n\nconst StartEndTimeSchema = z\n\t.object({\n\t\tstart: TimeStringSchema,\n\t\tend: TimeStringSchema,\n\t})\n\t.refine(\n\t\tdata => {\n\t\t\tconst start = parseInt(data.start.replace(':', ''));\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end > start;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time must be later than start time',\n\t\t\tpath: ['end'],\n\t\t}\n\t)\n\t.refine(\n\t\tdata => {\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end <= 2359;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time cannot exceed 23:59',\n\t\t\tpath: ['end'],\n\t\t}\n\t);\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema)\n\t\t.default([])\n\t\t.refine(\n\t\t\tarr => {\n\t\t\t\tif (arr.length === 0) return true;\n\t\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\t\tconst prevEnd = parseInt(arr[i - 1].end.replace(':', ''));\n\t\t\t\t\tconst currStart = parseInt(arr[i].start.replace(':', ''));\n\t\t\t\t\tif (currStart < prevEnd) return false; // Overlap or out of order\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage: 'Opening hours must be non-overlapping and in chronological order',\n\t\t\t}\n\t\t),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetProductByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\twithAttributeHiddenItems: z.boolean().optional().default(true),\n\twithAddonsHiddenItems: z.boolean().optional().default(true),\n});\nexport type GetProductByIdInputDTO = DTO<typeof GetProductByIdInputSchema>;\n\nexport const GetOrderByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\tgroupByCategories: ZodValidation.boolean('Group By Categories').optional(),\n\tuserOrderCompletionScope: ZodValidation.enumType(UserOrderCompletionScope).optional(),\n});\nexport type GetOrderByIdInputDTO = DTO<typeof GetOrderByIdInputSchema>;\n\n/**\n * Schema validation get by token\n */\nexport const GetByTokenInputSchema = z\n\t.object({\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n\t.optional();\nexport type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n\tplatform: ZodValidation.enumType(AppPlatform, 'App platform').optional(),\n\tappVersion: ZodValidation.string('App version').optional(),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n\nexport const AssignRiderSchema = z.object({\n\t_id: ZodValidation.objectId('Rider id'),\n\tlanguage: ZodValidation.enumType(Language, 'Rider language'),\n});\nexport type AssignRiderDTO = DTO<typeof AssignRiderSchema>;\n\nexport const PaymentInformationSchema = z.object({\n\tcardType: ZodValidation.enumType(CardType, 'Card type').default(CardType.AREEBA),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').optional(),\n\torderId: ZodValidation.string('Order id').optional(),\n\ttransactionId: ZodValidation.string('Transaction id').optional(),\n});\nexport type PaymentInformationDTO = DTO<typeof PaymentInformationSchema>;\n\nexport const VatSchema = z.object({\n\tcompanyVat: ZodValidation.number('Company vat').default(0).optional(),\n\tsecondaryCompanyVat: ZodValidation.number('Secondary company vat').default(0).optional(),\n});\nexport type VatDTO = DTO<typeof VatSchema>;\n\nexport const CashBackAmountSchema = z.object({\n\tcashbackRate: ZodValidation.number('Cashback rate').default(0).optional(),\n\tamount: ZodValidation.number('Amount').default(0).optional(),\n\tsecondaryAmount: ZodValidation.number('Secondary amount').default(0).optional(),\n});\nexport type CashBackAmountDTO = DTO<typeof CashBackAmountSchema>;\n"]}
1
+ {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAUiB;AAKjB,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAClD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC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,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3E,UAAU,EAAE,iCAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACrE,mBAAmB,EAAE,iCAAa,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxF,CAAC,CAAC;AAGU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACzE,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5D,eAAe,EAAE,iCAAa,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC/E,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport {\n\tActionType,\n\tAppPlatform,\n\tCardType,\n\tGeoLocationType,\n\tHolidayWorkStatus,\n\tLanguage,\n\tUserOrderCompletionScope,\n\tWeekDay,\n\tWorkStatus,\n} from '../enum';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City').optional(),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\n\nconst TimeStringSchema = z\n\t.string()\n\t// Allow 1 or 2 digits for hour\n\t.regex(/^([0-9]|[01]\\d|2[0-3]):([0-5]\\d)$/, 'Time must be in HH:mm format (e.g., 09:30 or 9:30)')\n\t// Normalize to HH:mm → always two digits for hour\n\t.transform(time => {\n\t\tlet [h, m] = time.split(':');\n\t\th = h.padStart(2, '0'); // convert \"9:30\" → \"09:30\"\n\t\treturn `${h}:${m}`;\n\t})\n\t// Validate logical range\n\t.refine(\n\t\ttime => {\n\t\t\tconst [h, m] = time.split(':').map(Number);\n\t\t\treturn h >= 0 && h <= 23 && m >= 0 && m <= 59;\n\t\t},\n\t\t{ message: 'Invalid time range, must be between 00:00 and 23:59' }\n\t);\n\nconst StartEndTimeSchema = z\n\t.object({\n\t\tstart: TimeStringSchema,\n\t\tend: TimeStringSchema,\n\t})\n\t.refine(\n\t\tdata => {\n\t\t\tconst start = parseInt(data.start.replace(':', ''));\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end > start;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time must be later than start time',\n\t\t\tpath: ['end'],\n\t\t}\n\t)\n\t.refine(\n\t\tdata => {\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end <= 2359;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time cannot exceed 23:59',\n\t\t\tpath: ['end'],\n\t\t}\n\t);\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema)\n\t\t.default([])\n\t\t.refine(\n\t\t\tarr => {\n\t\t\t\tif (arr.length === 0) return true;\n\t\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\t\tconst prevEnd = parseInt(arr[i - 1].end.replace(':', ''));\n\t\t\t\t\tconst currStart = parseInt(arr[i].start.replace(':', ''));\n\t\t\t\t\tif (currStart < prevEnd) return false; // Overlap or out of order\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage: 'Opening hours must be non-overlapping and in chronological order',\n\t\t\t}\n\t\t),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetProductByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\twithAttributeHiddenItems: z.boolean().optional().default(true),\n\twithAddonsHiddenItems: z.boolean().optional().default(true),\n});\nexport type GetProductByIdInputDTO = DTO<typeof GetProductByIdInputSchema>;\n\nexport const GetOrderByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\tgroupByCategories: ZodValidation.boolean('Group By Categories').optional(),\n\tuserOrderCompletionScope: ZodValidation.enumType(UserOrderCompletionScope).optional(),\n});\nexport type GetOrderByIdInputDTO = DTO<typeof GetOrderByIdInputSchema>;\n\n/**\n * Schema validation get by token\n */\nexport const GetByTokenInputSchema = z\n\t.object({\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n\t.optional();\nexport type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n\tplatform: ZodValidation.enumType(AppPlatform, 'App platform').optional(),\n\tappVersion: ZodValidation.string('App version').optional(),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n\nexport const AssignRiderSchema = z.object({\n\t_id: ZodValidation.objectId('Rider id'),\n\tlanguage: ZodValidation.enumType(Language, 'Rider language'),\n});\nexport type AssignRiderDTO = DTO<typeof AssignRiderSchema>;\n\nexport const PaymentInformationSchema = z.object({\n\tcardType: ZodValidation.enumType(CardType, 'Card type').default(CardType.AREEBA),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').optional(),\n\torderId: ZodValidation.string('Order id').optional(),\n\ttransactionId: ZodValidation.string('Transaction id').optional(),\n});\nexport type PaymentInformationDTO = DTO<typeof PaymentInformationSchema>;\n\nexport const VatSchema = z.object({\n\tvatPercentage: ZodValidation.number('Vat parcentage').default(0).optional(),\n\tcompanyVat: ZodValidation.number('Company vat').default(0).optional(),\n\tsecondaryCompanyVat: ZodValidation.number('Secondary company vat').default(0).optional(),\n});\nexport type VatDTO = DTO<typeof VatSchema>;\n\nexport const CashBackAmountSchema = z.object({\n\tcashbackRate: ZodValidation.number('Cashback rate').default(0).optional(),\n\tamount: ZodValidation.number('Amount').default(0).optional(),\n\tsecondaryAmount: ZodValidation.number('Secondary amount').default(0).optional(),\n});\nexport type CashBackAmountDTO = DTO<typeof CashBackAmountSchema>;\n"]}
@@ -962,12 +962,15 @@ export declare const PaymentInformationSchema: z.ZodObject<{
962
962
  }>;
963
963
  export type PaymentInformationDTO = DTO<typeof PaymentInformationSchema>;
964
964
  export declare const VatSchema: z.ZodObject<{
965
+ vatPercentage: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
965
966
  companyVat: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
966
967
  secondaryCompanyVat: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
967
968
  }, "strip", z.ZodTypeAny, {
969
+ vatPercentage?: number | undefined;
968
970
  companyVat?: number | undefined;
969
971
  secondaryCompanyVat?: number | undefined;
970
972
  }, {
973
+ vatPercentage?: number | undefined;
971
974
  companyVat?: number | undefined;
972
975
  secondaryCompanyVat?: number | undefined;
973
976
  }>;
@@ -238,6 +238,7 @@ exports.PaymentInformationSchema = zod_1.z.object({
238
238
  transactionId: global_validation_1.ZodValidation.string('Transaction id').optional(),
239
239
  });
240
240
  exports.VatSchema = zod_1.z.object({
241
+ vatPercentage: global_validation_1.ZodValidation.number('Vat parcentage').default(0).optional(),
241
242
  companyVat: global_validation_1.ZodValidation.number('Company vat').default(0).optional(),
242
243
  secondaryCompanyVat: global_validation_1.ZodValidation.number('Secondary company vat').default(0).optional(),
243
244
  });
@@ -1 +1 @@
1
- {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAUiB;AAKjB,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAClD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAA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a,EAAE,iCAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;CAChE,CAAC,CAAC;AAGU,QAAA,SAAS,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,UAAU,EAAE,iCAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACrE,mBAAmB,EAAE,iCAAa,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxF,CAAC,CAAC;AAGU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,YAAY,EAAE,iCAAa,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACzE,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC5D,eAAe,EAAE,iCAAa,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC/E,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport {\n\tActionType,\n\tAppPlatform,\n\tCardType,\n\tGeoLocationType,\n\tHolidayWorkStatus,\n\tLanguage,\n\tUserOrderCompletionScope,\n\tWeekDay,\n\tWorkStatus,\n} from '../enum';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City').optional(),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\n\nconst TimeStringSchema = z\n\t.string()\n\t// Allow 1 or 2 digits for hour\n\t.regex(/^([0-9]|[01]\\d|2[0-3]):([0-5]\\d)$/, 'Time must be in HH:mm format (e.g., 09:30 or 9:30)')\n\t// Normalize to HH:mm → always two digits for hour\n\t.transform(time => {\n\t\tlet [h, m] = time.split(':');\n\t\th = h.padStart(2, '0'); // convert \"9:30\" → \"09:30\"\n\t\treturn `${h}:${m}`;\n\t})\n\t// Validate logical range\n\t.refine(\n\t\ttime => {\n\t\t\tconst [h, m] = time.split(':').map(Number);\n\t\t\treturn h >= 0 && h <= 23 && m >= 0 && m <= 59;\n\t\t},\n\t\t{ message: 'Invalid time range, must be between 00:00 and 23:59' }\n\t);\n\nconst StartEndTimeSchema = z\n\t.object({\n\t\tstart: TimeStringSchema,\n\t\tend: TimeStringSchema,\n\t})\n\t.refine(\n\t\tdata => {\n\t\t\tconst start = parseInt(data.start.replace(':', ''));\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end > start;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time must be later than start time',\n\t\t\tpath: ['end'],\n\t\t}\n\t)\n\t.refine(\n\t\tdata => {\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end <= 2359;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time cannot exceed 23:59',\n\t\t\tpath: ['end'],\n\t\t}\n\t);\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema)\n\t\t.default([])\n\t\t.refine(\n\t\t\tarr => {\n\t\t\t\tif (arr.length === 0) return true;\n\t\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\t\tconst prevEnd = parseInt(arr[i - 1].end.replace(':', ''));\n\t\t\t\t\tconst currStart = parseInt(arr[i].start.replace(':', ''));\n\t\t\t\t\tif (currStart < prevEnd) return false; // Overlap or out of order\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage: 'Opening hours must be non-overlapping and in chronological order',\n\t\t\t}\n\t\t),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetProductByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\twithAttributeHiddenItems: z.boolean().optional().default(true),\n\twithAddonsHiddenItems: z.boolean().optional().default(true),\n});\nexport type GetProductByIdInputDTO = DTO<typeof GetProductByIdInputSchema>;\n\nexport const GetOrderByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\tgroupByCategories: ZodValidation.boolean('Group By Categories').optional(),\n\tuserOrderCompletionScope: ZodValidation.enumType(UserOrderCompletionScope).optional(),\n});\nexport type GetOrderByIdInputDTO = DTO<typeof GetOrderByIdInputSchema>;\n\n/**\n * Schema validation get by token\n */\nexport const GetByTokenInputSchema = z\n\t.object({\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n\t.optional();\nexport type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n\tplatform: ZodValidation.enumType(AppPlatform, 'App platform').optional(),\n\tappVersion: ZodValidation.string('App version').optional(),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n\nexport const AssignRiderSchema = z.object({\n\t_id: ZodValidation.objectId('Rider id'),\n\tlanguage: ZodValidation.enumType(Language, 'Rider language'),\n});\nexport type AssignRiderDTO = DTO<typeof AssignRiderSchema>;\n\nexport const PaymentInformationSchema = z.object({\n\tcardType: ZodValidation.enumType(CardType, 'Card type').default(CardType.AREEBA),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').optional(),\n\torderId: ZodValidation.string('Order id').optional(),\n\ttransactionId: ZodValidation.string('Transaction id').optional(),\n});\nexport type PaymentInformationDTO = DTO<typeof PaymentInformationSchema>;\n\nexport const VatSchema = z.object({\n\tcompanyVat: ZodValidation.number('Company vat').default(0).optional(),\n\tsecondaryCompanyVat: ZodValidation.number('Secondary company vat').default(0).optional(),\n});\nexport type VatDTO = DTO<typeof VatSchema>;\n\nexport const CashBackAmountSchema = z.object({\n\tcashbackRate: ZodValidation.number('Cashback rate').default(0).optional(),\n\tamount: ZodValidation.number('Amount').default(0).optional(),\n\tsecondaryAmount: ZodValidation.number('Secondary amount').default(0).optional(),\n});\nexport type CashBackAmountDTO = DTO<typeof CashBackAmountSchema>;\n"]}
1
+ {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAUiB;AAKjB,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC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E,iCAAa,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC/E,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport {\n\tActionType,\n\tAppPlatform,\n\tCardType,\n\tGeoLocationType,\n\tHolidayWorkStatus,\n\tLanguage,\n\tUserOrderCompletionScope,\n\tWeekDay,\n\tWorkStatus,\n} from '../enum';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City').optional(),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\n\nconst TimeStringSchema = z\n\t.string()\n\t// Allow 1 or 2 digits for hour\n\t.regex(/^([0-9]|[01]\\d|2[0-3]):([0-5]\\d)$/, 'Time must be in HH:mm format (e.g., 09:30 or 9:30)')\n\t// Normalize to HH:mm → always two digits for hour\n\t.transform(time => {\n\t\tlet [h, m] = time.split(':');\n\t\th = h.padStart(2, '0'); // convert \"9:30\" → \"09:30\"\n\t\treturn `${h}:${m}`;\n\t})\n\t// Validate logical range\n\t.refine(\n\t\ttime => {\n\t\t\tconst [h, m] = time.split(':').map(Number);\n\t\t\treturn h >= 0 && h <= 23 && m >= 0 && m <= 59;\n\t\t},\n\t\t{ message: 'Invalid time range, must be between 00:00 and 23:59' }\n\t);\n\nconst StartEndTimeSchema = z\n\t.object({\n\t\tstart: TimeStringSchema,\n\t\tend: TimeStringSchema,\n\t})\n\t.refine(\n\t\tdata => {\n\t\t\tconst start = parseInt(data.start.replace(':', ''));\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end > start;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time must be later than start time',\n\t\t\tpath: ['end'],\n\t\t}\n\t)\n\t.refine(\n\t\tdata => {\n\t\t\tconst end = parseInt(data.end.replace(':', ''));\n\t\t\treturn end <= 2359;\n\t\t},\n\t\t{\n\t\t\tmessage: 'End time cannot exceed 23:59',\n\t\t\tpath: ['end'],\n\t\t}\n\t);\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema)\n\t\t.default([])\n\t\t.refine(\n\t\t\tarr => {\n\t\t\t\tif (arr.length === 0) return true;\n\t\t\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\t\t\tconst prevEnd = parseInt(arr[i - 1].end.replace(':', ''));\n\t\t\t\t\tconst currStart = parseInt(arr[i].start.replace(':', ''));\n\t\t\t\t\tif (currStart < prevEnd) return false; // Overlap or out of order\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage: 'Opening hours must be non-overlapping and in chronological order',\n\t\t\t}\n\t\t),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetProductByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\twithAttributeHiddenItems: z.boolean().optional().default(true),\n\twithAddonsHiddenItems: z.boolean().optional().default(true),\n});\nexport type GetProductByIdInputDTO = DTO<typeof GetProductByIdInputSchema>;\n\nexport const GetOrderByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\tgroupByCategories: ZodValidation.boolean('Group By Categories').optional(),\n\tuserOrderCompletionScope: ZodValidation.enumType(UserOrderCompletionScope).optional(),\n});\nexport type GetOrderByIdInputDTO = DTO<typeof GetOrderByIdInputSchema>;\n\n/**\n * Schema validation get by token\n */\nexport const GetByTokenInputSchema = z\n\t.object({\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n\t.optional();\nexport type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n\tplatform: ZodValidation.enumType(AppPlatform, 'App platform').optional(),\n\tappVersion: ZodValidation.string('App version').optional(),\n\tdeviceId: ZodValidation.string('Device ID').optional(),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n\nexport const AssignRiderSchema = z.object({\n\t_id: ZodValidation.objectId('Rider id'),\n\tlanguage: ZodValidation.enumType(Language, 'Rider language'),\n});\nexport type AssignRiderDTO = DTO<typeof AssignRiderSchema>;\n\nexport const PaymentInformationSchema = z.object({\n\tcardType: ZodValidation.enumType(CardType, 'Card type').default(CardType.AREEBA),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').optional(),\n\torderId: ZodValidation.string('Order id').optional(),\n\ttransactionId: ZodValidation.string('Transaction id').optional(),\n});\nexport type PaymentInformationDTO = DTO<typeof PaymentInformationSchema>;\n\nexport const VatSchema = z.object({\n\tvatPercentage: ZodValidation.number('Vat parcentage').default(0).optional(),\n\tcompanyVat: ZodValidation.number('Company vat').default(0).optional(),\n\tsecondaryCompanyVat: ZodValidation.number('Secondary company vat').default(0).optional(),\n});\nexport type VatDTO = DTO<typeof VatSchema>;\n\nexport const CashBackAmountSchema = z.object({\n\tcashbackRate: ZodValidation.number('Cashback rate').default(0).optional(),\n\tamount: ZodValidation.number('Amount').default(0).optional(),\n\tsecondaryAmount: ZodValidation.number('Secondary amount').default(0).optional(),\n});\nexport type CashBackAmountDTO = DTO<typeof CashBackAmountSchema>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",