@lyxa.ai/core 1.4.276 → 1.4.278
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 +1 -5
- package/dist/index.js.map +1 -1
- package/dist/libraries/google-translate/google-translate.client.d.ts +5 -0
- package/dist/libraries/google-translate/google-translate.client.js +44 -0
- package/dist/libraries/google-translate/google-translate.client.js.map +1 -0
- package/dist/libraries/google-translate/google-translate.dto.d.ts +13 -0
- package/dist/libraries/google-translate/google-translate.dto.js +3 -0
- package/dist/libraries/google-translate/google-translate.dto.js.map +1 -0
- package/dist/libraries/google-translate/google-translate.service.d.ts +5 -5
- package/dist/libraries/google-translate/google-translate.service.js +56 -39
- package/dist/libraries/google-translate/google-translate.service.js.map +1 -1
- package/dist/libraries/trpc/middlewares/auth.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/createRoleProtectedProcedure.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/phone-verified.d.ts +1 -1
- package/dist/libraries/trpc/middlewares/publicUserDecoder.d.ts +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/validation/common-validation.d.ts +15 -15
- package/dist/types/utilities/validation/common-validation.js +1 -1
- package/dist/types/utilities/validation/common-validation.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +3 -3
- package/dist/utilities/validation/common-validation.js +1 -1
- package/dist/utilities/validation/common-validation.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -120,11 +120,7 @@ async function registerLibraries(options) {
|
|
|
120
120
|
typedi_1.Container.set(logger_kit_1.LyxaLoggerKit, loggerKit);
|
|
121
121
|
const firebaseInstance = new firebase_1.FirebaseService(configurationInstance);
|
|
122
122
|
typedi_1.Container.set(firebase_1.FirebaseService, firebaseInstance);
|
|
123
|
-
|
|
124
|
-
if (!googleTranslateApiKey) {
|
|
125
|
-
throw new Error('GOOGLE_TRANSLATE_API_KEY not found');
|
|
126
|
-
}
|
|
127
|
-
typedi_1.Container.set(google_translate_1.GoogleTranslateService, new google_translate_1.GoogleTranslateService(googleTranslateApiKey));
|
|
123
|
+
typedi_1.Container.set(google_translate_1.GoogleTranslateService, typedi_1.Container.get(google_translate_1.GoogleTranslateService));
|
|
128
124
|
const microserviceDispatcherInstance = new dispatcher_1.MicroServiceDispatcher(secretInstance);
|
|
129
125
|
typedi_1.Container.set(dispatcher_1.MicroServiceDispatcher, microserviceDispatcherInstance);
|
|
130
126
|
const twilioServiceInstance = new twilio_1.TwilioService();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,sCA0BC;AAED,8CAkHC;AAED,oCAEC;AAvLD,qFAAqF;AAErF,IAAA,0CAAqB,GAAE,CAAC;AAExB,2CAA6C;AAC7C,mCAAmC;AACnC,6DAAuF;AACvF,+CAAgD;AAChD,6CAAiD;AACjD,6CAAoF;AACpF,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;AACvD,6CAA6E;AAC7E,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,wFAAmF;AACnF,wEAAmE;AACnE,iEAA4F;AAC5F,+GAA4G;AAC5G,yDAAgE;AAChE,yFAA+E;AAC/E,4FAAuG;AACvG,uDAAuD;AACvD,gFAA2E;AAC3E,8EAAyE;AACzE,gGAAkG;AAClG,mEAAsE;AACtE,iGAAsH;AAGtH,6GAA4G;AAAnG,4IAAA,4BAA4B,OAAA;AACrC,2CAAyD;AAAhD,6GAAA,oBAAoB,OAAA;AAC7B,+DAA6C;AAEtC,KAAK,UAAU,aAAa,CAAC,OAA8B;IACjE,IAAI,CAAC;QACJ,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACjC,YAAY,EAAE,CAAC,SAAS,EAAE,CAAC,MA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E,UAAU,CAAC,CAAC;IAC9C,kBAAS,CAAC,GAAG,CAAC,iCAAc,EAAE,cAAc,CAAC,CAAC;IAE9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAEtC,MAAM,IAAA,8BAAsB,EAAC,sCAAc,CAAC,OAAO,EAAE,WAAW,IAAI,2DAA4B,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvG,MAAM,gBAAgB,GAAG,2CAAoB,CAAC,mBAAmB,EAAE,CAAC;IAEpE,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAiB,CAAC;IAEtD,KAAK,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,gBAAgB,EAAE,CAAC;QAC3E,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,QAAQ,GAAG,kBAAS,CAAC,GAAG,CAAC,iBAAwB,CAAC,CAAC;YACnD,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,IAAA,wBAAgB,EAAC,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACjF,CAAC;AACF,CAAC;AAED,SAAgB,YAAY;IAC3B,OAAO,kBAAS,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Apply the soft delete plugin globally before any connections or models\nimport { applySoftDeletePlugin } from './libraries/mongo/plugins/soft-delete-plugin';\n\napplySoftDeletePlugin();\n\nimport { LibraryManager } from './libraries';\nimport { Container } from 'typedi';\nimport { ConfigurationOptions, ConfigurationService } from './libraries/configuration';\nimport { LyxaLogger } from './libraries/logger';\nimport { RedisService } from './libraries/redis';\nimport { initGlobalConnection, initLyxaMongoDbConnection } from './libraries/mongo';\nimport { SecretManagerService } from './libraries/secrets';\nimport { MicroServiceDispatcher } from './libraries/dispatcher';\nimport { TwilioService } from './libraries/twilio';\nimport { FirebaseService } from './libraries/firebase';\nimport { initRabbitMQConnection, subscribeToEvent } from './libraries/event';\nimport { SubscriptionRegistry } from './libraries/event/registry/SubscriptionRegistry';\nimport { GoogleMapsService, MapService } from './libraries/map';\nimport { CachedSettingsService } from './libraries/cache/settings';\nimport { FirebaseFcmService } from './libraries/notification/firebase-fcm.service';\nimport { BullMQService } from './libraries/bullmq/bull-mq-service';\nimport { BOBSecrets, BOBService, CashSettlementService } from './libraries/cash-settlement';\nimport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nimport { OsrmMapService } from './libraries/map/providers/osrm';\nimport { RabbitMQUrlMap } from './utilities/environment/rabbitmq-environments';\nimport { disconnectAllEntitiesFromInstance } from './libraries/socket/connections/instance-disconnect';\nimport { LyxaLoggerKit } from './libraries/logger-kit';\nimport { LyxaFcmService } from './libraries/notification/lyxa-fcm.service';\nimport { LyxaFcmSender } from './libraries/notification/lyxa-fcm-sender';\nimport { FirebaseMessageBuilderFactory } from './libraries/notification/firebase-message.builder';\nimport { GoogleTranslateService } from './libraries/google-translate';\nimport { TransliterationProvider, TransliterationService } from './libraries/transliteration/transliteration-service';\n\nexport { ConfigurationOptions } from './libraries/configuration';\nexport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nexport { initGlobalConnection } from './libraries/mongo';\nexport * from './libraries/google-translate';\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 google translate\n\tconst googleTranslateApiKey = await getLibraries().getSecretsService().getKey('GOOGLE_TRANSLATE_API_KEY');\n\n\tif (!googleTranslateApiKey) {\n\t\tthrow new Error('GOOGLE_TRANSLATE_API_KEY not found');\n\t}\n\n\tContainer.set(GoogleTranslateService, new GoogleTranslateService(googleTranslateApiKey));\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 Transliteration service\n\tconst transliterationService = new TransliterationService(TransliterationProvider.OPENAI);\n\tContainer.set(TransliterationService, transliterationService);\n\n\t// Setup map service\n\tconst googleMapsKey = await getLibraries().getSecretsService().getKey('GOOGLE_MAPS_API_KEY');\n\tconst googleMapService = new GoogleMapsService(redisInstance, googleMapsKey as string);\n\tconst osrmMapService = new OsrmMapService();\n\tconst mapServiceInstance = new MapService(googleMapService, osrmMapService);\n\tContainer.set(MapService, mapServiceInstance);\n\n\t// Setup cash settlement service\n\tconst bobUsername = await getLibraries().getSecretsService().getKey('BOB_USER_NAME');\n\tconst bobPassword = await getLibraries().getSecretsService().getKey('BOB_PASSWORD');\n\tconst bobURL = await getLibraries().getSecretsService().getKey('BOB_URL');\n\n\tconst bobService = new BOBService({\n\t\tBOB_USER_NAME: bobUsername,\n\t\tBOB_PASSWORD: bobPassword,\n\t\tBOB_URL: bobURL,\n\t} as BOBSecrets);\n\tconst cashSettlementServiceInstance = new CashSettlementService(bobService);\n\tContainer.set(CashSettlementService, cashSettlementServiceInstance);\n\tContainer.set(BOBService, bobService);\n\n\tconst settingsServiceInstance = new CachedSettingsService(redisInstance);\n\tContainer.set(CachedSettingsService, settingsServiceInstance);\n\n\ttry {\n\t\tconst settings = await settingsServiceInstance.getSettings();\n\t\tconst { _setTimezone } = await import('./utilities/dayjs/dayjs');\n\t\t_setTimezone(settings?.timezone || 'Asia/Beirut');\n\t\tconsole.log('Timezone initialized:', settings?.timezone || 'Asia/Beirut');\n\t} catch (error) {\n\t\tconsole.error('Failed to initialize timezone:', error);\n\t}\n\n\t// Setup fcm service\n\tconst fcmService = new FirebaseFcmService();\n\tconst builder = new FirebaseMessageBuilderFactory();\n\tconst lyxaFcmSender = new LyxaFcmSender(fcmService, builder);\n\tconst lyxaFcmService = new LyxaFcmService(lyxaFcmSender);\n\n\tContainer.set(FirebaseFcmService, fcmService);\n\tContainer.set(LyxaFcmService, lyxaFcmService);\n\n\tconsole.log('Initialized everything');\n\n\tawait initRabbitMQConnection(RabbitMQUrlMap[options?.environment ?? EnvironmentConfigurationType.DEV]);\n\n\tconst allSubscriptions = SubscriptionRegistry.getAllSubscriptions();\n\n\tconst instantiatedServices = new Map<Function, any>();\n\n\tfor (const { eventId, targetConstructor, methodName } of allSubscriptions) {\n\t\tlet instance = instantiatedServices.get(targetConstructor);\n\t\tif (!instance) {\n\t\t\tinstance = Container.get(targetConstructor as any);\n\t\t\tinstantiatedServices.set(targetConstructor, instance);\n\t\t}\n\n\t\tawait subscribeToEvent(eventId, async payload => instance[methodName](payload));\n\t}\n}\n\nexport function getLibraries(): LibraryManager {\n\treturn Container.get(LibraryManager);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,sCA0BC;AAED,8CA4GC;AAED,oCAEC;AAjLD,qFAAqF;AAErF,IAAA,0CAAqB,GAAE,CAAC;AAExB,2CAA6C;AAC7C,mCAAmC;AACnC,6DAAuF;AACvF,+CAAgD;AAChD,6CAAiD;AACjD,6CAAoF;AACpF,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;AACvD,6CAA6E;AAC7E,0FAAuF;AACvF,yCAAgE;AAChE,yDAAmE;AACnE,wFAAmF;AACnF,wEAAmE;AACnE,iEAA4F;AAC5F,+GAA4G;AAC5G,yDAAgE;AAChE,yFAA+E;AAC/E,4FAAuG;AACvG,uDAAuD;AACvD,gFAA2E;AAC3E,8EAAyE;AACzE,gGAAkG;AAClG,mEAAs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C,aAAa,CAAC,CAAC;IAEzD,kBAAS,CAAC,GAAG,CAAC,yCAAkB,EAAE,UAAU,CAAC,CAAC;IAC9C,kBAAS,CAAC,GAAG,CAAC,iCAAc,EAAE,cAAc,CAAC,CAAC;IAE9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAEtC,MAAM,IAAA,8BAAsB,EAAC,sCAAc,CAAC,OAAO,EAAE,WAAW,IAAI,2DAA4B,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvG,MAAM,gBAAgB,GAAG,2CAAoB,CAAC,mBAAmB,EAAE,CAAC;IAEpE,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAiB,CAAC;IAEtD,KAAK,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,gBAAgB,EAAE,CAAC;QAC3E,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,QAAQ,GAAG,kBAAS,CAAC,GAAG,CAAC,iBAAwB,CAAC,CAAC;YACnD,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,IAAA,wBAAgB,EAAC,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACjF,CAAC;AACF,CAAC;AAED,SAAgB,YAAY;IAC3B,OAAO,kBAAS,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Apply the soft delete plugin globally before any connections or models\nimport { applySoftDeletePlugin } from './libraries/mongo/plugins/soft-delete-plugin';\n\napplySoftDeletePlugin();\n\nimport { LibraryManager } from './libraries';\nimport { Container } from 'typedi';\nimport { ConfigurationOptions, ConfigurationService } from './libraries/configuration';\nimport { LyxaLogger } from './libraries/logger';\nimport { RedisService } from './libraries/redis';\nimport { initGlobalConnection, initLyxaMongoDbConnection } from './libraries/mongo';\nimport { SecretManagerService } from './libraries/secrets';\nimport { MicroServiceDispatcher } from './libraries/dispatcher';\nimport { TwilioService } from './libraries/twilio';\nimport { FirebaseService } from './libraries/firebase';\nimport { initRabbitMQConnection, subscribeToEvent } from './libraries/event';\nimport { SubscriptionRegistry } from './libraries/event/registry/SubscriptionRegistry';\nimport { GoogleMapsService, MapService } from './libraries/map';\nimport { CachedSettingsService } from './libraries/cache/settings';\nimport { FirebaseFcmService } from './libraries/notification/firebase-fcm.service';\nimport { BullMQService } from './libraries/bullmq/bull-mq-service';\nimport { BOBSecrets, BOBService, CashSettlementService } from './libraries/cash-settlement';\nimport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nimport { OsrmMapService } from './libraries/map/providers/osrm';\nimport { RabbitMQUrlMap } from './utilities/environment/rabbitmq-environments';\nimport { disconnectAllEntitiesFromInstance } from './libraries/socket/connections/instance-disconnect';\nimport { LyxaLoggerKit } from './libraries/logger-kit';\nimport { LyxaFcmService } from './libraries/notification/lyxa-fcm.service';\nimport { LyxaFcmSender } from './libraries/notification/lyxa-fcm-sender';\nimport { FirebaseMessageBuilderFactory } from './libraries/notification/firebase-message.builder';\nimport { GoogleTranslateService } from './libraries/google-translate';\nimport { TransliterationProvider, TransliterationService } from './libraries/transliteration/transliteration-service';\n\nexport { ConfigurationOptions } from './libraries/configuration';\nexport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\nexport { initGlobalConnection } from './libraries/mongo';\nexport * from './libraries/google-translate';\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 google translate\n\tContainer.set(GoogleTranslateService, Container.get(GoogleTranslateService));\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 Transliteration service\n\tconst transliterationService = new TransliterationService(TransliterationProvider.OPENAI);\n\tContainer.set(TransliterationService, transliterationService);\n\n\t// Setup map service\n\tconst googleMapsKey = await getLibraries().getSecretsService().getKey('GOOGLE_MAPS_API_KEY');\n\tconst googleMapService = new GoogleMapsService(redisInstance, googleMapsKey as string);\n\tconst osrmMapService = new OsrmMapService();\n\tconst mapServiceInstance = new MapService(googleMapService, osrmMapService);\n\tContainer.set(MapService, mapServiceInstance);\n\n\t// Setup cash settlement service\n\tconst bobUsername = await getLibraries().getSecretsService().getKey('BOB_USER_NAME');\n\tconst bobPassword = await getLibraries().getSecretsService().getKey('BOB_PASSWORD');\n\tconst bobURL = await getLibraries().getSecretsService().getKey('BOB_URL');\n\n\tconst bobService = new BOBService({\n\t\tBOB_USER_NAME: bobUsername,\n\t\tBOB_PASSWORD: bobPassword,\n\t\tBOB_URL: bobURL,\n\t} as BOBSecrets);\n\tconst cashSettlementServiceInstance = new CashSettlementService(bobService);\n\tContainer.set(CashSettlementService, cashSettlementServiceInstance);\n\tContainer.set(BOBService, bobService);\n\n\tconst settingsServiceInstance = new CachedSettingsService(redisInstance);\n\tContainer.set(CachedSettingsService, settingsServiceInstance);\n\n\ttry {\n\t\tconst settings = await settingsServiceInstance.getSettings();\n\t\tconst { _setTimezone } = await import('./utilities/dayjs/dayjs');\n\t\t_setTimezone(settings?.timezone || 'Asia/Beirut');\n\t\tconsole.log('Timezone initialized:', settings?.timezone || 'Asia/Beirut');\n\t} catch (error) {\n\t\tconsole.error('Failed to initialize timezone:', error);\n\t}\n\n\t// Setup fcm service\n\tconst fcmService = new FirebaseFcmService();\n\tconst builder = new FirebaseMessageBuilderFactory();\n\tconst lyxaFcmSender = new LyxaFcmSender(fcmService, builder);\n\tconst lyxaFcmService = new LyxaFcmService(lyxaFcmSender);\n\n\tContainer.set(FirebaseFcmService, fcmService);\n\tContainer.set(LyxaFcmService, lyxaFcmService);\n\n\tconsole.log('Initialized everything');\n\n\tawait initRabbitMQConnection(RabbitMQUrlMap[options?.environment ?? EnvironmentConfigurationType.DEV]);\n\n\tconst allSubscriptions = SubscriptionRegistry.getAllSubscriptions();\n\n\tconst instantiatedServices = new Map<Function, any>();\n\n\tfor (const { eventId, targetConstructor, methodName } of allSubscriptions) {\n\t\tlet instance = instantiatedServices.get(targetConstructor);\n\t\tif (!instance) {\n\t\t\tinstance = Container.get(targetConstructor as any);\n\t\t\tinstantiatedServices.set(targetConstructor, instance);\n\t\t}\n\n\t\tawait subscribeToEvent(eventId, async payload => instance[methodName](payload));\n\t}\n}\n\nexport function getLibraries(): LibraryManager {\n\treturn Container.get(LibraryManager);\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GoogleTranslateClient = void 0;
|
|
10
|
+
const typedi_1 = require("typedi");
|
|
11
|
+
const logSettings_1 = require("@typegoose/typegoose/lib/logSettings");
|
|
12
|
+
let GoogleTranslateClient = class GoogleTranslateClient {
|
|
13
|
+
getUrl(apiKey) {
|
|
14
|
+
return `https://translation.googleapis.com/language/translate/v2?key=${apiKey}`;
|
|
15
|
+
}
|
|
16
|
+
async translate(apiKey, input) {
|
|
17
|
+
const response = await fetch(this.getUrl(apiKey), {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers: {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify(input),
|
|
23
|
+
});
|
|
24
|
+
const responseBody = await response.text();
|
|
25
|
+
logSettings_1.logger.info(`Google Translate Response: ${JSON.stringify({
|
|
26
|
+
status: response.status,
|
|
27
|
+
body: responseBody,
|
|
28
|
+
})}`);
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
logSettings_1.logger.error(`Google Translate API request failed: ${JSON.stringify({
|
|
31
|
+
status: response.status,
|
|
32
|
+
input,
|
|
33
|
+
body: responseBody,
|
|
34
|
+
})}`);
|
|
35
|
+
throw new Error(responseBody);
|
|
36
|
+
}
|
|
37
|
+
return JSON.parse(responseBody);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.GoogleTranslateClient = GoogleTranslateClient;
|
|
41
|
+
exports.GoogleTranslateClient = GoogleTranslateClient = __decorate([
|
|
42
|
+
(0, typedi_1.Service)()
|
|
43
|
+
], GoogleTranslateClient);
|
|
44
|
+
//# sourceMappingURL=google-translate.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-translate.client.js","sourceRoot":"/","sources":["libraries/google-translate/google-translate.client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAiC;AAEjC,sEAA8D;AAGvD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACzB,MAAM,CAAC,MAAc;QAC5B,OAAO,gEAAgE,MAAM,EAAE,CAAC;IACjF,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,KAA8B;QACpE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YACjD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,cAAc,EAAE,kBAAkB;aAClC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SAC3B,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAE3C,oBAAM,CAAC,IAAI,CACV,8BAA8B,IAAI,CAAC,SAAS,CAAC;YAC5C,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,IAAI,EAAE,YAAY;SAClB,CAAC,EAAE,CACJ,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YAClB,oBAAM,CAAC,KAAK,CACX,wCAAwC,IAAI,CAAC,SAAS,CAAC;gBACtD,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,KAAK;gBACL,IAAI,EAAE,YAAY;aAClB,CAAC,EAAE,CACJ,CAAC;YAEF,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAsB,CAAC;IACtD,CAAC;CACD,CAAA;AApCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,gBAAO,GAAE;GACG,qBAAqB,CAoCjC","sourcesContent":["import { Service } from 'typedi';\nimport { GoogleTranslateInputDTO, TranslateResponse } from './google-translate.dto';\nimport { logger } from '@typegoose/typegoose/lib/logSettings';\n\n@Service()\nexport class GoogleTranslateClient {\n\tprivate getUrl(apiKey: string): string {\n\t\treturn `https://translation.googleapis.com/language/translate/v2?key=${apiKey}`;\n\t}\n\n\tpublic async translate(apiKey: string, input: GoogleTranslateInputDTO): Promise<TranslateResponse> {\n\t\tconst response = await fetch(this.getUrl(apiKey), {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify(input),\n\t\t});\n\n\t\tconst responseBody = await response.text();\n\n\t\tlogger.info(\n\t\t\t`Google Translate Response: ${JSON.stringify({\n\t\t\t\tstatus: response.status,\n\t\t\t\tbody: responseBody,\n\t\t\t})}`\n\t\t);\n\t\tif (!response.ok) {\n\t\t\tlogger.error(\n\t\t\t\t`Google Translate API request failed: ${JSON.stringify({\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tinput,\n\t\t\t\t\tbody: responseBody,\n\t\t\t\t})}`\n\t\t\t);\n\n\t\t\tthrow new Error(responseBody);\n\t\t}\n\n\t\treturn JSON.parse(responseBody) as TranslateResponse;\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-translate.dto.js","sourceRoot":"/","sources":["libraries/google-translate/google-translate.dto.ts"],"names":[],"mappings":"","sourcesContent":["export interface GoogleTranslateInputDTO {\n\tq: string | string[];\n\ttarget: string;\n\tsource?: string;\n\tformat: 'text';\n}\n\nexport interface TranslateResponse {\n\tdata: {\n\t\ttranslations: {\n\t\t\ttranslatedText: string;\n\t\t}[];\n\t};\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { GoogleTranslateClient } from './google-translate.client';
|
|
1
2
|
export declare class GoogleTranslateService {
|
|
2
|
-
private readonly
|
|
3
|
-
constructor(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
translateBatch(texts: string[], targetLanguage: string, sourceLanguage?: string): Promise<string[]>;
|
|
3
|
+
private readonly googleTranslateClient;
|
|
4
|
+
constructor(googleTranslateClient: GoogleTranslateClient);
|
|
5
|
+
translate(apiKey: string, text: string, targetLanguage: string, sourceLanguage?: string): Promise<string>;
|
|
6
|
+
translateBatch(apiKey: string, texts: string[], targetLanguage: string, sourceLanguage?: string): Promise<string[]>;
|
|
7
7
|
}
|
|
@@ -8,65 +8,82 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.GoogleTranslateService = void 0;
|
|
13
16
|
const typedi_1 = require("typedi");
|
|
17
|
+
const google_translate_client_1 = require("./google-translate.client");
|
|
18
|
+
const logSettings_1 = require("@typegoose/typegoose/lib/logSettings");
|
|
14
19
|
let GoogleTranslateService = class GoogleTranslateService {
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
this.
|
|
18
|
-
}
|
|
19
|
-
get url() {
|
|
20
|
-
return `https://translation.googleapis.com/language/translate/v2?key=${this.apiKey}`;
|
|
20
|
+
googleTranslateClient;
|
|
21
|
+
constructor(googleTranslateClient) {
|
|
22
|
+
this.googleTranslateClient = googleTranslateClient;
|
|
21
23
|
}
|
|
22
|
-
async translate(text, targetLanguage, sourceLanguage) {
|
|
24
|
+
async translate(apiKey, text, targetLanguage, sourceLanguage) {
|
|
23
25
|
if (!text?.trim()) {
|
|
24
26
|
return text;
|
|
25
27
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
source: sourceLanguage,
|
|
35
|
-
format: 'text',
|
|
36
|
-
}),
|
|
28
|
+
const input = {
|
|
29
|
+
q: text,
|
|
30
|
+
target: targetLanguage,
|
|
31
|
+
source: sourceLanguage,
|
|
32
|
+
format: 'text',
|
|
33
|
+
};
|
|
34
|
+
logSettings_1.logger.info('Google Translate request', {
|
|
35
|
+
input,
|
|
37
36
|
});
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
try {
|
|
38
|
+
const result = await this.googleTranslateClient.translate(apiKey, input);
|
|
39
|
+
logSettings_1.logger.info('Google Translate response', {
|
|
40
|
+
input,
|
|
41
|
+
result: result.data,
|
|
42
|
+
});
|
|
43
|
+
return result.data.translations[0]?.translatedText ?? text;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logSettings_1.logger.error('Google Translate failed', {
|
|
47
|
+
input,
|
|
48
|
+
error,
|
|
49
|
+
});
|
|
50
|
+
throw error;
|
|
40
51
|
}
|
|
41
|
-
const result = (await response.json());
|
|
42
|
-
return result.data.translations[0]?.translatedText ?? text;
|
|
43
52
|
}
|
|
44
|
-
async translateBatch(texts, targetLanguage, sourceLanguage) {
|
|
53
|
+
async translateBatch(apiKey, texts, targetLanguage, sourceLanguage) {
|
|
45
54
|
if (!texts.length) {
|
|
46
55
|
return [];
|
|
47
56
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
source: sourceLanguage,
|
|
57
|
-
format: 'text',
|
|
58
|
-
}),
|
|
57
|
+
const input = {
|
|
58
|
+
q: texts,
|
|
59
|
+
target: targetLanguage,
|
|
60
|
+
source: sourceLanguage,
|
|
61
|
+
format: 'text',
|
|
62
|
+
};
|
|
63
|
+
logSettings_1.logger.info('Google Translate request', {
|
|
64
|
+
input,
|
|
59
65
|
});
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
try {
|
|
67
|
+
const result = await this.googleTranslateClient.translate(apiKey, input);
|
|
68
|
+
logSettings_1.logger.info('Google Translate batch response', {
|
|
69
|
+
input,
|
|
70
|
+
result: result.data,
|
|
71
|
+
});
|
|
72
|
+
return result.data.translations.map(x => x.translatedText);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
logSettings_1.logger.error('Google Translate batch failed', {
|
|
76
|
+
input,
|
|
77
|
+
error,
|
|
78
|
+
});
|
|
79
|
+
throw error;
|
|
62
80
|
}
|
|
63
|
-
const result = (await response.json());
|
|
64
|
-
return result.data.translations.map(x => x.translatedText);
|
|
65
81
|
}
|
|
66
82
|
};
|
|
67
83
|
exports.GoogleTranslateService = GoogleTranslateService;
|
|
68
84
|
exports.GoogleTranslateService = GoogleTranslateService = __decorate([
|
|
69
85
|
(0, typedi_1.Service)(),
|
|
70
|
-
|
|
86
|
+
__param(0, (0, typedi_1.Inject)()),
|
|
87
|
+
__metadata("design:paramtypes", [google_translate_client_1.GoogleTranslateClient])
|
|
71
88
|
], GoogleTranslateService);
|
|
72
89
|
//# sourceMappingURL=google-translate.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-translate.service.js","sourceRoot":"/","sources":["libraries/google-translate/google-translate.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"google-translate.service.js","sourceRoot":"/","sources":["libraries/google-translate/google-translate.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAyC;AACzC,uEAAkE;AAElE,sEAA8D;AAGvD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAGhB;IAFlB,YAEkB,qBAA4C;QAA5C,0BAAqB,GAArB,qBAAqB,CAAuB;IAC3D,CAAC;IAEG,KAAK,CAAC,SAAS,CACrB,MAAc,EACd,IAAY,EACZ,cAAsB,EACtB,cAAuB;QAEvB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,KAAK,GAA4B;YACtC,CAAC,EAAE,IAAI;YACP,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,MAAM;SACd,CAAC;QACF,oBAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;YACvC,KAAK;SACL,CAAC,CAAC;QACH,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzE,oBAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE;gBACxC,KAAK;gBACL,MAA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AAsB;IADlC,IAAA,gBAAO,GAAE;IAGP,WAAA,IAAA,eAAM,GAAE,CAAA;qCAC+B,+CAAqB;GAHlD,sBAAsB,CA+ElC","sourcesContent":["import { Inject, Service } from 'typedi';\nimport { GoogleTranslateClient } from './google-translate.client';\nimport { GoogleTranslateInputDTO } from './google-translate.dto';\nimport { logger } from '@typegoose/typegoose/lib/logSettings';\n\n@Service()\nexport class GoogleTranslateService {\n\tconstructor(\n\t\t@Inject()\n\t\tprivate readonly googleTranslateClient: GoogleTranslateClient\n\t) {}\n\n\tpublic async translate(\n\t\tapiKey: string,\n\t\ttext: string,\n\t\ttargetLanguage: string,\n\t\tsourceLanguage?: string\n\t): Promise<string> {\n\t\tif (!text?.trim()) {\n\t\t\treturn text;\n\t\t}\n\n\t\tconst input: GoogleTranslateInputDTO = {\n\t\t\tq: text,\n\t\t\ttarget: targetLanguage,\n\t\t\tsource: sourceLanguage,\n\t\t\tformat: 'text',\n\t\t};\n\t\tlogger.info('Google Translate request', {\n\t\t\tinput,\n\t\t});\n\t\ttry {\n\t\t\tconst result = await this.googleTranslateClient.translate(apiKey, input);\n\t\t\tlogger.info('Google Translate response', {\n\t\t\t\tinput,\n\t\t\t\tresult: result.data,\n\t\t\t});\n\n\t\t\treturn result.data.translations[0]?.translatedText ?? text;\n\t\t} catch (error) {\n\t\t\tlogger.error('Google Translate failed', {\n\t\t\t\tinput,\n\t\t\t\terror,\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async translateBatch(\n\t\tapiKey: string,\n\t\ttexts: string[],\n\t\ttargetLanguage: string,\n\t\tsourceLanguage?: string\n\t): Promise<string[]> {\n\t\tif (!texts.length) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst input: GoogleTranslateInputDTO = {\n\t\t\tq: texts,\n\t\t\ttarget: targetLanguage,\n\t\t\tsource: sourceLanguage,\n\t\t\tformat: 'text',\n\t\t};\n\t\tlogger.info('Google Translate request', {\n\t\t\tinput,\n\t\t});\n\n\t\ttry {\n\t\t\tconst result = await this.googleTranslateClient.translate(apiKey, input);\n\t\t\tlogger.info('Google Translate batch response', {\n\t\t\t\tinput,\n\t\t\t\tresult: result.data,\n\t\t\t});\n\n\t\t\treturn result.data.translations.map(x => x.translatedText);\n\t\t} catch (error) {\n\t\t\tlogger.error('Google Translate batch failed', {\n\t\t\t\tinput,\n\t\t\t\terror,\n\t\t\t});\n\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -5,9 +5,9 @@ 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
|
-
req: import("http").IncomingMessage;
|
|
11
11
|
requestId: string | undefined;
|
|
12
12
|
entity: import("../context").EntityContext | undefined;
|
|
13
13
|
usedRefreshToken: boolean | undefined;
|
|
@@ -4,9 +4,9 @@ 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
|
-
req: import("http").IncomingMessage;
|
|
10
10
|
requestId: string | undefined;
|
|
11
11
|
entity: import("../context").EntityContext | undefined;
|
|
12
12
|
usedRefreshToken: boolean | undefined;
|
|
@@ -3,9 +3,9 @@ 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
|
-
req: import("http").IncomingMessage;
|
|
9
9
|
requestId: string | undefined;
|
|
10
10
|
entity: import("../context").EntityContext | undefined;
|
|
11
11
|
usedRefreshToken: boolean | undefined;
|
|
@@ -5,9 +5,9 @@ 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
|
-
req: import("http").IncomingMessage;
|
|
11
11
|
requestId: string | undefined;
|
|
12
12
|
entity: import("../context").EntityContext | undefined;
|
|
13
13
|
usedRefreshToken: boolean | undefined;
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -26,8 +26,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
|
|
|
26
26
|
searchFields?: string[] | undefined;
|
|
27
27
|
} | undefined;
|
|
28
28
|
sort?: Record<string, 1 | -1> | undefined;
|
|
29
|
-
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
|
}>;
|
|
@@ -773,15 +773,15 @@ export declare const GetOrderByIdInputSchema: z.ZodObject<{
|
|
|
773
773
|
userOrderCompletionScope: z.ZodOptional<z.ZodNativeEnum<typeof UserOrderCompletionScope>>;
|
|
774
774
|
}, "strip", z.ZodTypeAny, {
|
|
775
775
|
_id: import("mongoose").Types.ObjectId;
|
|
776
|
-
select?: Record<string, 0 | 1> | undefined;
|
|
777
776
|
populate?: any;
|
|
777
|
+
select?: Record<string, 0 | 1> | undefined;
|
|
778
778
|
groupByCategories?: boolean | undefined;
|
|
779
779
|
getParentCategory?: boolean | undefined;
|
|
780
780
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
781
781
|
}, {
|
|
782
782
|
_id: string | import("mongoose").Types.ObjectId;
|
|
783
|
-
select?: Record<string, 0 | 1> | undefined;
|
|
784
783
|
populate?: any;
|
|
784
|
+
select?: Record<string, 0 | 1> | undefined;
|
|
785
785
|
groupByCategories?: boolean | undefined;
|
|
786
786
|
getParentCategory?: boolean | undefined;
|
|
787
787
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
@@ -791,11 +791,11 @@ export declare const GetByTokenInputSchema: z.ZodOptional<z.ZodObject<{
|
|
|
791
791
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
792
792
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
793
793
|
}, "strip", z.ZodTypeAny, {
|
|
794
|
-
select?: Record<string, 0 | 1> | undefined;
|
|
795
794
|
populate?: any;
|
|
796
|
-
}, {
|
|
797
795
|
select?: Record<string, 0 | 1> | undefined;
|
|
796
|
+
}, {
|
|
798
797
|
populate?: any;
|
|
798
|
+
select?: Record<string, 0 | 1> | undefined;
|
|
799
799
|
}>>;
|
|
800
800
|
export type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;
|
|
801
801
|
export declare const GetOneQuerySchema: z.ZodObject<{
|
|
@@ -803,12 +803,12 @@ export declare const GetOneQuerySchema: z.ZodObject<{
|
|
|
803
803
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
804
804
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
805
805
|
}, "strip", z.ZodTypeAny, {
|
|
806
|
-
select?: Record<string, 0 | 1> | undefined;
|
|
807
806
|
populate?: any;
|
|
807
|
+
select?: Record<string, 0 | 1> | undefined;
|
|
808
808
|
query?: Record<string, any> | undefined;
|
|
809
809
|
}, {
|
|
810
|
-
select?: Record<string, 0 | 1> | undefined;
|
|
811
810
|
populate?: any;
|
|
811
|
+
select?: Record<string, 0 | 1> | undefined;
|
|
812
812
|
query?: Record<string, any> | undefined;
|
|
813
813
|
}>;
|
|
814
814
|
export type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;
|
|
@@ -999,7 +999,7 @@ export declare const PaymentRecordSchema: z.ZodObject<{
|
|
|
999
999
|
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
|
|
1000
1000
|
amount: z.ZodNumber;
|
|
1001
1001
|
authorizedAmount: z.ZodNumber;
|
|
1002
|
-
externalId: z.ZodOptional<z.ZodNumber
|
|
1002
|
+
externalId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1003
1003
|
}, "strip", z.ZodTypeAny, {
|
|
1004
1004
|
amount: number;
|
|
1005
1005
|
provider: PaymentProvider;
|
|
@@ -1007,7 +1007,7 @@ export declare const PaymentRecordSchema: z.ZodObject<{
|
|
|
1007
1007
|
paymentIntentId?: string | null | undefined;
|
|
1008
1008
|
orderId?: string | null | undefined;
|
|
1009
1009
|
transactionId?: string | null | undefined;
|
|
1010
|
-
externalId?: number | undefined;
|
|
1010
|
+
externalId?: number | null | undefined;
|
|
1011
1011
|
}, {
|
|
1012
1012
|
amount: number;
|
|
1013
1013
|
provider: PaymentProvider;
|
|
@@ -1015,7 +1015,7 @@ export declare const PaymentRecordSchema: z.ZodObject<{
|
|
|
1015
1015
|
paymentIntentId?: string | null | undefined;
|
|
1016
1016
|
orderId?: string | null | undefined;
|
|
1017
1017
|
transactionId?: string | null | undefined;
|
|
1018
|
-
externalId?: number | undefined;
|
|
1018
|
+
externalId?: number | null | undefined;
|
|
1019
1019
|
}>;
|
|
1020
1020
|
export type PaymentRecordDTO = DTO<typeof PaymentRecordSchema>;
|
|
1021
1021
|
export {};
|
|
@@ -258,6 +258,6 @@ exports.PaymentRecordSchema = zod_1.z.object({
|
|
|
258
258
|
transactionId: global_validation_1.ZodValidation.string('Transaction id').nullish(),
|
|
259
259
|
amount: global_validation_1.ZodValidation.number('Amount'),
|
|
260
260
|
authorizedAmount: global_validation_1.ZodValidation.number('Authorized amount'),
|
|
261
|
-
externalId: global_validation_1.ZodValidation.number('External id').
|
|
261
|
+
externalId: global_validation_1.ZodValidation.number('External id').nullish(),
|
|
262
262
|
});
|
|
263
263
|
//# sourceMappingURL=common-validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAWiB;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,GA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C,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;AAGU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,iCAAa,CAAC,QAAQ,CAAC,sBAAe,EAAE,kBAAkB,CAAC;IACrE,eAAe,EAAE,iCAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE;IACpE,OAAO,EAAE,iCAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnD,aAAa,EAAE,iCAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE;IAC/D,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC;IACtC,gBAAgB,EAAE,iCAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAC3D,UAAU,EAAE,iCAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE;CAC1D,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\tPaymentProvider,\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\tapartment: ZodValidation.string('Apartment').optional(),\n\tbuildingName: ZodValidation.string('Building Name').optional(),\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 for Ids\n */\nexport const IdsSchema = ZodValidation.array(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\tgetParentCategory: ZodValidation.boolean('Get Parent Category').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\t// Todo: Remove this after paymentRecords is fully implemented\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\nexport const PaymentRecordSchema = z.object({\n\tprovider: ZodValidation.enumType(PaymentProvider, 'Payment provider'),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').nullish(),\n\torderId: ZodValidation.string('Order id').nullish(),\n\ttransactionId: ZodValidation.string('Transaction id').nullish(),\n\tamount: ZodValidation.number('Amount'),\n\tauthorizedAmount: ZodValidation.number('Authorized amount'),\n\texternalId: ZodValidation.number('External id').optional(),\n});\nexport type PaymentRecordDTO = DTO<typeof PaymentRecordSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAWiB;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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Ae,EAAE,iCAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE;IACpE,OAAO,EAAE,iCAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnD,aAAa,EAAE,iCAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE;IAC/D,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC;IACtC,gBAAgB,EAAE,iCAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAC3D,UAAU,EAAE,iCAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;CACzD,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\tPaymentProvider,\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\tapartment: ZodValidation.string('Apartment').optional(),\n\tbuildingName: ZodValidation.string('Building Name').optional(),\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 for Ids\n */\nexport const IdsSchema = ZodValidation.array(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\tgetParentCategory: ZodValidation.boolean('Get Parent Category').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\t// Todo: Remove this after paymentRecords is fully implemented\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\nexport const PaymentRecordSchema = z.object({\n\tprovider: ZodValidation.enumType(PaymentProvider, 'Payment provider'),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').nullish(),\n\torderId: ZodValidation.string('Order id').nullish(),\n\ttransactionId: ZodValidation.string('Transaction id').nullish(),\n\tamount: ZodValidation.number('Amount'),\n\tauthorizedAmount: ZodValidation.number('Authorized amount'),\n\texternalId: ZodValidation.number('External id').nullish(),\n});\nexport type PaymentRecordDTO = DTO<typeof PaymentRecordSchema>;\n"]}
|
|
@@ -999,7 +999,7 @@ export declare const PaymentRecordSchema: z.ZodObject<{
|
|
|
999
999
|
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>>;
|
|
1000
1000
|
amount: z.ZodNumber;
|
|
1001
1001
|
authorizedAmount: z.ZodNumber;
|
|
1002
|
-
externalId: z.ZodOptional<z.ZodNumber
|
|
1002
|
+
externalId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1003
1003
|
}, "strip", z.ZodTypeAny, {
|
|
1004
1004
|
amount: number;
|
|
1005
1005
|
provider: PaymentProvider;
|
|
@@ -1007,7 +1007,7 @@ export declare const PaymentRecordSchema: z.ZodObject<{
|
|
|
1007
1007
|
paymentIntentId?: string | null | undefined;
|
|
1008
1008
|
orderId?: string | null | undefined;
|
|
1009
1009
|
transactionId?: string | null | undefined;
|
|
1010
|
-
externalId?: number | undefined;
|
|
1010
|
+
externalId?: number | null | undefined;
|
|
1011
1011
|
}, {
|
|
1012
1012
|
amount: number;
|
|
1013
1013
|
provider: PaymentProvider;
|
|
@@ -1015,7 +1015,7 @@ export declare const PaymentRecordSchema: z.ZodObject<{
|
|
|
1015
1015
|
paymentIntentId?: string | null | undefined;
|
|
1016
1016
|
orderId?: string | null | undefined;
|
|
1017
1017
|
transactionId?: string | null | undefined;
|
|
1018
|
-
externalId?: number | undefined;
|
|
1018
|
+
externalId?: number | null | undefined;
|
|
1019
1019
|
}>;
|
|
1020
1020
|
export type PaymentRecordDTO = DTO<typeof PaymentRecordSchema>;
|
|
1021
1021
|
export {};
|
|
@@ -258,6 +258,6 @@ exports.PaymentRecordSchema = zod_1.z.object({
|
|
|
258
258
|
transactionId: global_validation_1.ZodValidation.string('Transaction id').nullish(),
|
|
259
259
|
amount: global_validation_1.ZodValidation.number('Amount'),
|
|
260
260
|
authorizedAmount: global_validation_1.ZodValidation.number('Authorized amount'),
|
|
261
|
-
externalId: global_validation_1.ZodValidation.number('External id').
|
|
261
|
+
externalId: global_validation_1.ZodValidation.number('External id').nullish(),
|
|
262
262
|
});
|
|
263
263
|
//# sourceMappingURL=common-validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAWiB;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,CAAC,QAAQ,EAAE;IACjC,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,IAAI,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,CAAC;IACtC,gBAAgB,EAAE,iCAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAC3D,UAAU,EAAE,iCAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE;CAC1D,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\tPaymentProvider,\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\tapartment: ZodValidation.string('Apartment').optional(),\n\tbuildingName: ZodValidation.string('Building Name').optional(),\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 for Ids\n */\nexport const IdsSchema = ZodValidation.array(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\tgetParentCategory: ZodValidation.boolean('Get Parent Category').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\t// Todo: Remove this after paymentRecords is fully implemented\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\nexport const PaymentRecordSchema = z.object({\n\tprovider: ZodValidation.enumType(PaymentProvider, 'Payment provider'),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').nullish(),\n\torderId: ZodValidation.string('Order id').nullish(),\n\ttransactionId: ZodValidation.string('Transaction id').nullish(),\n\tamount: ZodValidation.number('Amount'),\n\tauthorizedAmount: ZodValidation.number('Authorized amount'),\n\texternalId: ZodValidation.number('External id').optional(),\n});\nexport type PaymentRecordDTO = DTO<typeof PaymentRecordSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAWiB;AAKjB,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,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AQ,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;AAGU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,iCAAa,CAAC,QAAQ,CAAC,sBAAe,EAAE,kBAAkB,CAAC;IACrE,eAAe,EAAE,iCAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE;IACpE,OAAO,EAAE,iCAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnD,aAAa,EAAE,iCAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE;IAC/D,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC;IACtC,gBAAgB,EAAE,iCAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAC3D,UAAU,EAAE,iCAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;CACzD,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\tPaymentProvider,\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\tapartment: ZodValidation.string('Apartment').optional(),\n\tbuildingName: ZodValidation.string('Building Name').optional(),\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 for Ids\n */\nexport const IdsSchema = ZodValidation.array(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\tgetParentCategory: ZodValidation.boolean('Get Parent Category').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\t// Todo: Remove this after paymentRecords is fully implemented\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\nexport const PaymentRecordSchema = z.object({\n\tprovider: ZodValidation.enumType(PaymentProvider, 'Payment provider'),\n\tpaymentIntentId: ZodValidation.string('Payment intent id').nullish(),\n\torderId: ZodValidation.string('Order id').nullish(),\n\ttransactionId: ZodValidation.string('Transaction id').nullish(),\n\tamount: ZodValidation.number('Amount'),\n\tauthorizedAmount: ZodValidation.number('Authorized amount'),\n\texternalId: ZodValidation.number('External id').nullish(),\n});\nexport type PaymentRecordDTO = DTO<typeof PaymentRecordSchema>;\n"]}
|