@lyxa.ai/core 1.3.280 → 1.3.281
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/libraries/firebase/fcmService.js +4 -1
- package/dist/libraries/firebase/fcmService.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/app-force-update.d.ts +1 -0
- package/dist/libraries/mongo/models/embedded/app-force-update.js +5 -0
- package/dist/libraries/mongo/models/embedded/app-force-update.js.map +1 -1
- package/dist/libraries/mongo/models/setting.model.d.ts +0 -1
- package/dist/libraries/mongo/models/setting.model.js +0 -5
- package/dist/libraries/mongo/models/setting.model.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 +12 -12
- package/package.json +1 -1
|
@@ -166,7 +166,10 @@ let FCMService = class FCMService {
|
|
|
166
166
|
message,
|
|
167
167
|
response,
|
|
168
168
|
};
|
|
169
|
-
logger.
|
|
169
|
+
logger.info('Called Firebase function sendEachForMulticast', {
|
|
170
|
+
tag: enum_1.LogTag.NOTIFICATION_ATTEMPTED,
|
|
171
|
+
data: logEntry,
|
|
172
|
+
});
|
|
170
173
|
const batchSuccess = [];
|
|
171
174
|
const batchFailed = [];
|
|
172
175
|
response.responses.forEach((resp, idx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fcmService.js","sourceRoot":"/","sources":["libraries/firebase/fcmService.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;AACrC,mCAAiC;AAEjC,+CAAoF;AAuBpF,MAAM,wBAAwB,GAAuE;IACpG,CAAC,8BAAuB,CAAC,KAAK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W,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CAoPtB","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { getLibraries } from '../..';\nimport { Service } from 'typedi';\nimport { App } from 'firebase-admin/app';\nimport { AppPlatform, LogTag, NotificationAccountType } from '../../utilities/enum';\n\nexport interface FCMNotificationPayload {\n\ttitle?: string;\n\tbody?: string;\n\tdata?: Record<string, string>;\n\tsound?: string;\n\tinvisible?: boolean;\n}\n\nexport interface NotificationTokenTarget {\n\ttoken: string;\n\tentityType: NotificationAccountType;\n\tentityId: string;\n\tplatform?: AppPlatform;\n\tappVersion?: string;\n}\n\ntype NotifiableEntityType =\n\t| NotificationAccountType.USER\n\t| NotificationAccountType.SHOP\n\t| NotificationAccountType.RIDER;\n\nconst NotificationVersionRules: Record<NotifiableEntityType, Partial<Record<AppPlatform, string>>> = {\n\t[NotificationAccountType.RIDER]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.4',\n\t},\n\n\t[NotificationAccountType.USER]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.3',\n\t},\n\n\t[NotificationAccountType.SHOP]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.3',\n\t},\n};\n\nexport const FCMServiceForUser = 'fcm.service.user';\nexport const FCMServiceForRider = 'fcm.service.rider';\nexport const FCMServiceForShop = 'fcm.service.shop';\n\n@Service()\nexport class FCMService {\n\tprivate messaging!: messaging.Messaging;\n\tprivate static readonly MAX_BATCH = 500;\n\n\tconstructor(app?: App) {\n\t\tconst firebaseApp = app ?? getLibraries().getFirebaseService().superApp;\n\t\tthis.messaging = messaging(firebaseApp);\n\t}\n\n\t/**\n\t * Split array into chunks of fixed size\n\t */\n\tprivate chunkArray<T>(arr: T[], size: number): T[][] {\n\t\tconst chunks: T[][] = [];\n\t\tfor (let i = 0; i < arr.length; i += size) {\n\t\t\tchunks.push(arr.slice(i, i + size));\n\t\t}\n\t\treturn chunks;\n\t}\n\n\tprivate compareVersions(v1: string, v2: string): number {\n\t\tconst a = v1.split('.').map(Number);\n\t\tconst b = v2.split('.').map(Number);\n\n\t\tfor (let i = 0; i < Math.max(a.length, b.length); i++) {\n\t\t\tconst diff = (a[i] || 0) - (b[i] || 0);\n\t\t\tif (diff !== 0) return diff;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprivate isNotifiableEntityType(type: NotificationAccountType): type is NotifiableEntityType {\n\t\treturn (\n\t\t\ttype === NotificationAccountType.USER ||\n\t\t\ttype === NotificationAccountType.RIDER ||\n\t\t\ttype === NotificationAccountType.SHOP\n\t\t);\n\t}\n\n\tprivate shouldUseNewStructure(\n\t\tentityType: NotificationAccountType,\n\t\tplatform?: AppPlatform,\n\t\tversion?: string\n\t): boolean {\n\t\tif (!this.isNotifiableEntityType(entityType)) return false;\n\n\t\tif (!platform || !version) return false;\n\n\t\tconst minVersion = NotificationVersionRules?.[entityType]?.[platform];\n\n\t\tif (!minVersion) return false;\n\n\t\treturn this.compareVersions(version, minVersion) > 0;\n\t}\n\n\t/**\n\t * Build multicast message safely\n\t */\n\tprivate buildMessage(payload: FCMNotificationPayload, batchTokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: { ...payload.data, channelId: isInvisible ? 'silent' : channelId },\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\ttokens: batchTokens,\n\t\t\tandroid: {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: 'silent',\n\t\t\t\t},\n\t\t\t},\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\theaders: {\n\t\t\t\t\t'apns-push-type': 'background',\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\treturn message;\n\t}\n\n\t/**\n\t * Build multicast message safely for old apps\n\t */\n\tprivate buildOldMessage(\n\t\tpayload: FCMNotificationPayload,\n\t\tbatchTokens: string[]\n\t): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: payload.data || {},\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\ttokens: batchTokens,\n\t\t\tandroid: { priority: 'high' },\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tif (!isInvisible) {\n\t\t\tmessage.notification = {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t};\n\n\t\t\tmessage.android = {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn message;\n\t}\n\n\t/**\n\t * Sends a push notification (visible or invisible) to multiple device tokens\n\t * @param payload - Notification title, body, and optional data\n\t * @param tokens - FCM device tokens\n\t * @returns Object containing success and invalid tokens\n\t */\n\tasync sendNotification(\n\t\tpayload: FCMNotificationPayload,\n\t\ttargets: NotificationTokenTarget[]\n\t): Promise<{ successTokens: string[]; failedTokens: string[] }> {\n\t\tif (!targets.length) {\n\t\t\treturn { successTokens: [], failedTokens: [] };\n\t\t}\n\n\t\tconst logger = getLibraries().getLoggerKit();\n\n\t\tconst oldTokens: string[] = [];\n\t\tconst newTokens: string[] = [];\n\n\t\tfor (const t of targets) {\n\t\t\tconst useNew = this.shouldUseNewStructure(t.entityType, t.platform, t.appVersion);\n\n\t\t\tif (useNew) newTokens.push(t.token);\n\t\t\telse oldTokens.push(t.token);\n\t\t}\n\n\t\tconst sendGroup = async (\n\t\t\tgroupTokens: string[],\n\t\t\tgroupPayload: FCMNotificationPayload,\n\t\t\toldNotificationStructure: boolean = false\n\t\t) => {\n\t\t\tconst tokenChunks = this.chunkArray(groupTokens, FCMService.MAX_BATCH);\n\n\t\t\tconst success: string[] = [];\n\t\t\tconst failed: string[] = [];\n\n\t\t\tconst results = await Promise.all(\n\t\t\t\ttokenChunks.map(async chunk => {\n\t\t\t\t\tconst message = oldNotificationStructure\n\t\t\t\t\t\t? this.buildOldMessage(groupPayload, chunk)\n\t\t\t\t\t\t: this.buildMessage(groupPayload, chunk);\n\n\t\t\t\t\tconst response = await this.messaging.sendEachForMulticast(message);\n\n\t\t\t\t\tconst logEntry = {\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\tgroupTokens,\n\t\t\t\t\t\tgroupPayload,\n\t\t\t\t\t\toldNotificationStructure,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t};\n\n\t\t\t\t\tlogger.debug('Called Firebase function sendEachForMulticast', { tag: LogTag.NOTIFICATION_ATTEMPTED, data: logEntry });\n\n\t\t\t\t\tconst batchSuccess: string[] = [];\n\t\t\t\t\tconst batchFailed: string[] = [];\n\n\t\t\t\t\tresponse.responses.forEach((resp, idx) => {\n\t\t\t\t\t\tif (resp.success) {\n\t\t\t\t\t\t\tbatchSuccess.push(chunk[idx]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst errorCode = resp.error?.code;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\terrorCode === 'messaging/invalid-argument' ||\n\t\t\t\t\t\t\t\terrorCode === 'messaging/registration-token-not-registered'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tbatchFailed.push(chunk[idx]);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.warn(`FCM Error for token ${chunk[idx]}:`, resp.error?.message);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treturn { batchSuccess, batchFailed };\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tfor (const r of results) {\n\t\t\t\tsuccess.push(...r.batchSuccess);\n\t\t\t\tfailed.push(...r.batchFailed);\n\t\t\t}\n\n\t\t\treturn { success, failed };\n\t\t};\n\n\t\tlet successTokens: string[] = [];\n\t\tlet failedTokens: string[] = [];\n\n\t\t// send old payload\n\t\tif (oldTokens.length) {\n\t\t\tconst r = await sendGroup(oldTokens, payload, true);\n\n\t\t\tsuccessTokens.push(...r.success);\n\t\t\tfailedTokens.push(...r.failed);\n\t\t}\n\n\t\t// send new payload\n\t\tif (newTokens.length) {\n\t\t\tconst r = await sendGroup(newTokens, payload, false);\n\n\t\t\tsuccessTokens.push(...r.success);\n\t\t\tfailedTokens.push(...r.failed);\n\t\t}\n\n\t\treturn { successTokens, failedTokens };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fcmService.js","sourceRoot":"/","sources":["libraries/firebase/fcmService.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;AACrC,mCAAiC;AAEjC,+CAAoF;AAuBpF,MAAM,wBAAwB,GAAuE;IACpG,CAAC,8BAAuB,CAAC,KAAK,CAAC,EAAE;QAChC,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,OAAO;QAC1B,CAAC,kBAAW,CAAC,OAAO,CAAC,EAAE,OAAO;KAC9B;IAED,CAAC,8BAAuB,CAAC,IAAI,CAAC,EAAE;QAC/B,CAAC,kBAAW,CAAC,GAAG,CAAC,EAAE,OAAO;QAC1B,CAAC,kBAAW,CAAC,OAAO,CAAC,EAAE,OAAO;KAC9B;IA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CAAC,CACF,CAAC;YAEF,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;gBACzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;YAC/B,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAC5B,CAAC,CAAC;QAEF,IAAI,aAAa,GAAa,EAAE,CAAC;QACjC,IAAI,YAAY,GAAa,EAAE,CAAC;QAGhC,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAEpD,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;YACjC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QAGD,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YAErD,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;YACjC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;IACxC,CAAC;;AAtPW,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CAuPtB","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { getLibraries } from '../..';\nimport { Service } from 'typedi';\nimport { App } from 'firebase-admin/app';\nimport { AppPlatform, LogTag, NotificationAccountType } from '../../utilities/enum';\n\nexport interface FCMNotificationPayload {\n\ttitle?: string;\n\tbody?: string;\n\tdata?: Record<string, string>;\n\tsound?: string;\n\tinvisible?: boolean;\n}\n\nexport interface NotificationTokenTarget {\n\ttoken: string;\n\tentityType: NotificationAccountType;\n\tentityId: string;\n\tplatform?: AppPlatform;\n\tappVersion?: string;\n}\n\ntype NotifiableEntityType =\n\t| NotificationAccountType.USER\n\t| NotificationAccountType.SHOP\n\t| NotificationAccountType.RIDER;\n\nconst NotificationVersionRules: Record<NotifiableEntityType, Partial<Record<AppPlatform, string>>> = {\n\t[NotificationAccountType.RIDER]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.4',\n\t},\n\n\t[NotificationAccountType.USER]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.3',\n\t},\n\n\t[NotificationAccountType.SHOP]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.3',\n\t},\n};\n\nexport const FCMServiceForUser = 'fcm.service.user';\nexport const FCMServiceForRider = 'fcm.service.rider';\nexport const FCMServiceForShop = 'fcm.service.shop';\n\n@Service()\nexport class FCMService {\n\tprivate messaging!: messaging.Messaging;\n\tprivate static readonly MAX_BATCH = 500;\n\n\tconstructor(app?: App) {\n\t\tconst firebaseApp = app ?? getLibraries().getFirebaseService().superApp;\n\t\tthis.messaging = messaging(firebaseApp);\n\t}\n\n\t/**\n\t * Split array into chunks of fixed size\n\t */\n\tprivate chunkArray<T>(arr: T[], size: number): T[][] {\n\t\tconst chunks: T[][] = [];\n\t\tfor (let i = 0; i < arr.length; i += size) {\n\t\t\tchunks.push(arr.slice(i, i + size));\n\t\t}\n\t\treturn chunks;\n\t}\n\n\tprivate compareVersions(v1: string, v2: string): number {\n\t\tconst a = v1.split('.').map(Number);\n\t\tconst b = v2.split('.').map(Number);\n\n\t\tfor (let i = 0; i < Math.max(a.length, b.length); i++) {\n\t\t\tconst diff = (a[i] || 0) - (b[i] || 0);\n\t\t\tif (diff !== 0) return diff;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprivate isNotifiableEntityType(type: NotificationAccountType): type is NotifiableEntityType {\n\t\treturn (\n\t\t\ttype === NotificationAccountType.USER ||\n\t\t\ttype === NotificationAccountType.RIDER ||\n\t\t\ttype === NotificationAccountType.SHOP\n\t\t);\n\t}\n\n\tprivate shouldUseNewStructure(\n\t\tentityType: NotificationAccountType,\n\t\tplatform?: AppPlatform,\n\t\tversion?: string\n\t): boolean {\n\t\tif (!this.isNotifiableEntityType(entityType)) return false;\n\n\t\tif (!platform || !version) return false;\n\n\t\tconst minVersion = NotificationVersionRules?.[entityType]?.[platform];\n\n\t\tif (!minVersion) return false;\n\n\t\treturn this.compareVersions(version, minVersion) > 0;\n\t}\n\n\t/**\n\t * Build multicast message safely\n\t */\n\tprivate buildMessage(payload: FCMNotificationPayload, batchTokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: { ...payload.data, channelId: isInvisible ? 'silent' : channelId },\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\ttokens: batchTokens,\n\t\t\tandroid: {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: 'silent',\n\t\t\t\t},\n\t\t\t},\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\theaders: {\n\t\t\t\t\t'apns-push-type': 'background',\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\treturn message;\n\t}\n\n\t/**\n\t * Build multicast message safely for old apps\n\t */\n\tprivate buildOldMessage(\n\t\tpayload: FCMNotificationPayload,\n\t\tbatchTokens: string[]\n\t): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: payload.data || {},\n\t\t\tnotification: {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t},\n\t\t\ttokens: batchTokens,\n\t\t\tandroid: { priority: 'high' },\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tif (!isInvisible) {\n\t\t\tmessage.notification = {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t};\n\n\t\t\tmessage.android = {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn message;\n\t}\n\n\t/**\n\t * Sends a push notification (visible or invisible) to multiple device tokens\n\t * @param payload - Notification title, body, and optional data\n\t * @param tokens - FCM device tokens\n\t * @returns Object containing success and invalid tokens\n\t */\n\tasync sendNotification(\n\t\tpayload: FCMNotificationPayload,\n\t\ttargets: NotificationTokenTarget[]\n\t): Promise<{ successTokens: string[]; failedTokens: string[] }> {\n\t\tif (!targets.length) {\n\t\t\treturn { successTokens: [], failedTokens: [] };\n\t\t}\n\n\t\tconst logger = getLibraries().getLoggerKit();\n\n\t\tconst oldTokens: string[] = [];\n\t\tconst newTokens: string[] = [];\n\n\t\tfor (const t of targets) {\n\t\t\tconst useNew = this.shouldUseNewStructure(t.entityType, t.platform, t.appVersion);\n\n\t\t\tif (useNew) newTokens.push(t.token);\n\t\t\telse oldTokens.push(t.token);\n\t\t}\n\n\t\tconst sendGroup = async (\n\t\t\tgroupTokens: string[],\n\t\t\tgroupPayload: FCMNotificationPayload,\n\t\t\toldNotificationStructure: boolean = false\n\t\t) => {\n\t\t\tconst tokenChunks = this.chunkArray(groupTokens, FCMService.MAX_BATCH);\n\n\t\t\tconst success: string[] = [];\n\t\t\tconst failed: string[] = [];\n\n\t\t\tconst results = await Promise.all(\n\t\t\t\ttokenChunks.map(async chunk => {\n\t\t\t\t\tconst message = oldNotificationStructure\n\t\t\t\t\t\t? this.buildOldMessage(groupPayload, chunk)\n\t\t\t\t\t\t: this.buildMessage(groupPayload, chunk);\n\n\t\t\t\t\tconst response = await this.messaging.sendEachForMulticast(message);\n\n\t\t\t\t\tconst logEntry = {\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\tgroupTokens,\n\t\t\t\t\t\tgroupPayload,\n\t\t\t\t\t\toldNotificationStructure,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tresponse,\n\t\t\t\t\t};\n\n\t\t\t\t\tlogger.info('Called Firebase function sendEachForMulticast', {\n\t\t\t\t\t\ttag: LogTag.NOTIFICATION_ATTEMPTED,\n\t\t\t\t\t\tdata: logEntry,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst batchSuccess: string[] = [];\n\t\t\t\t\tconst batchFailed: string[] = [];\n\n\t\t\t\t\tresponse.responses.forEach((resp, idx) => {\n\t\t\t\t\t\tif (resp.success) {\n\t\t\t\t\t\t\tbatchSuccess.push(chunk[idx]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst errorCode = resp.error?.code;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\terrorCode === 'messaging/invalid-argument' ||\n\t\t\t\t\t\t\t\terrorCode === 'messaging/registration-token-not-registered'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tbatchFailed.push(chunk[idx]);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.warn(`FCM Error for token ${chunk[idx]}:`, resp.error?.message);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treturn { batchSuccess, batchFailed };\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tfor (const r of results) {\n\t\t\t\tsuccess.push(...r.batchSuccess);\n\t\t\t\tfailed.push(...r.batchFailed);\n\t\t\t}\n\n\t\t\treturn { success, failed };\n\t\t};\n\n\t\tlet successTokens: string[] = [];\n\t\tlet failedTokens: string[] = [];\n\n\t\t// send old payload\n\t\tif (oldTokens.length) {\n\t\t\tconst r = await sendGroup(oldTokens, payload, true);\n\n\t\t\tsuccessTokens.push(...r.success);\n\t\t\tfailedTokens.push(...r.failed);\n\t\t}\n\n\t\t// send new payload\n\t\tif (newTokens.length) {\n\t\t\tconst r = await sendGroup(newTokens, payload, false);\n\n\t\t\tsuccessTokens.push(...r.success);\n\t\t\tfailedTokens.push(...r.failed);\n\t\t}\n\n\t\treturn { successTokens, failedTokens };\n\t}\n}\n"]}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AppForceUpdate = void 0;
|
|
13
13
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
14
|
class AppForceUpdate {
|
|
15
|
+
isEnabled;
|
|
15
16
|
minVersionIOS;
|
|
16
17
|
minVersionAndroid;
|
|
17
18
|
storeUrlIOS;
|
|
@@ -20,6 +21,10 @@ class AppForceUpdate {
|
|
|
20
21
|
title;
|
|
21
22
|
}
|
|
22
23
|
exports.AppForceUpdate = AppForceUpdate;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
26
|
+
__metadata("design:type", Boolean)
|
|
27
|
+
], AppForceUpdate.prototype, "isEnabled", void 0);
|
|
23
28
|
__decorate([
|
|
24
29
|
(0, typegoose_1.prop)({ type: String }),
|
|
25
30
|
__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-force-update.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/app-force-update.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,cAAc;IAEnB,aAAa,CAAU;IAGvB,iBAAiB,CAAU;IAG3B,WAAW,CAAU;IAGrB,eAAe,CAAU;IAGzB,OAAO,CAAU;IAGjB,KAAK,CAAU;CACtB;
|
|
1
|
+
{"version":3,"file":"app-force-update.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/app-force-update.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,cAAc;IAEnB,SAAS,CAAW;IAGpB,aAAa,CAAU;IAGvB,iBAAiB,CAAU;IAG3B,WAAW,CAAU;IAGrB,eAAe,CAAU;IAGzB,OAAO,CAAU;IAGjB,KAAK,CAAU;CACtB;AArBD,wCAqBC;AAnBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;iDACb;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDACO;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDACW;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uDACS;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CACC;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CACD","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class AppForceUpdate {\n\t@prop({ type: Boolean, default: false })\n\tpublic isEnabled?: boolean;\n\n\t@prop({ type: String })\n\tpublic minVersionIOS?: string;\n\n\t@prop({ type: String })\n\tpublic minVersionAndroid?: string;\n\n\t@prop({ type: String })\n\tpublic storeUrlIOS?: string;\n\n\t@prop({ type: String })\n\tpublic storeUrlAndroid?: string;\n\n\t@prop({ type: String })\n\tpublic message?: string;\n\n\t@prop({ type: String })\n\tpublic title?: string;\n}\n"]}
|
|
@@ -52,7 +52,6 @@ let Setting = class Setting extends defaultClasses_1.TimeStamps {
|
|
|
52
52
|
cashbackAmount;
|
|
53
53
|
timezone;
|
|
54
54
|
bufferTimeInSeconds;
|
|
55
|
-
isAppForceUpdateEnabled;
|
|
56
55
|
appForceUpdate;
|
|
57
56
|
};
|
|
58
57
|
exports.Setting = Setting;
|
|
@@ -152,10 +151,6 @@ __decorate([
|
|
|
152
151
|
(0, typegoose_1.prop)({ type: Number, min: 0, default: 600 }),
|
|
153
152
|
__metadata("design:type", Number)
|
|
154
153
|
], Setting.prototype, "bufferTimeInSeconds", void 0);
|
|
155
|
-
__decorate([
|
|
156
|
-
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
157
|
-
__metadata("design:type", Boolean)
|
|
158
|
-
], Setting.prototype, "isAppForceUpdateEnabled", void 0);
|
|
159
154
|
__decorate([
|
|
160
155
|
(0, typegoose_1.prop)({ type: app_force_update_1.AppForceUpdate }),
|
|
161
156
|
__metadata("design:type", app_force_update_1.AppForceUpdate)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,8DAA2D;AAC3D,kEAA6D;AAC7D,wEAA8D;AAC9D,wEAA8D;AAC9D,0EAAgE;AAChE,4EAAkE;AAClE,8EAAoE;AACpE,4EAAqE;AACrE,wEAAsE;AACtE,oFAAyE;AACzE,4FAA0E;AAC1E,kDAA0E;AAC1E,8FAA4E;AAC5E,kGAAuF;AACvF,sGAA2F;AAC3F,8FAA2F;AAGpF,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,2BAAU;IAE/B,eAAe,CAAmB;IAGlC,iBAAiB,CAAqB;IAGtC,aAAa,CAAiB;IAG9B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EAAE,CAAC;;+CACJ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAgB,EAAE,CAAC;;yCACZ;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;;oDACT;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,iCAAc,EAAE,CAAC;8BACP,iCAAc;+CAAC;kBA1E3B,OAAO;IADnB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC;GAC/C,OAAO,CA2EnB","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\nimport { WorkHourSetting } from './shared/work-hour.model';\nimport { AppForceUpdate } from './embedded/app-force-update';\nimport { PlusSettings } from './embedded/plus-settings.model';\nimport { RiderSetting } from './embedded/rider-setting.model';\nimport { PayoutSetting } from './embedded/payout-setting.model';\nimport { CourierSetting } from './embedded/courier-setting.model';\nimport { CurrencySetting } from './embedded/currency-setting.model';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { RiderBatchesSettings } from './embedded/rider-batches.model';\nimport { ServiceFeeSetting } from './embedded/service-fee-setting.model';\nimport { DeliveryCharge } from './embedded/delivery-charge-setting.model';\nimport { LyxaTimeZoneEnum, PaymentMethod } from '../../../utilities/enum';\nimport { CustomerSupport } from './embedded/customer-support-numbers.model';\nimport { AgentNotificationSetting } from './embedded/agent-notification-setting.model';\nimport { BusinessDevelopmentSetting } from './embedded/business-development-setting.model';\nimport { CustomerSupportBatchesSettings } from './embedded/customer-support-batches.model';\n\n@modelOptions({ schemaOptions: { collection: 'settings' } })\nexport class Setting extends TimeStamps {\n\t@prop({ type: () => [DeliveryCharge] })\n\tpublic deliveryCharges: DeliveryCharge[];\n\n\t@prop({ type: ServiceFeeSetting })\n\tpublic serviceFeeSetting?: ServiceFeeSetting;\n\n\t@prop({ type: PayoutSetting })\n\tpublic payoutSetting?: PayoutSetting;\n\n\t@prop({ type: WorkHourSetting })\n\tpublic workHourSetting?: WorkHourSetting;\n\n\t@prop({ type: CourierSetting })\n\tpublic courierSetting?: CourierSetting;\n\n\t@prop({ type: RiderSetting })\n\tpublic riderSetting?: RiderSetting;\n\n\t@prop({ type: BusinessDevelopmentSetting })\n\tpublic businessDevelopmentSetting?: BusinessDevelopmentSetting;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic payLimitForUser?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic vatPercentage?: number;\n\n\t@prop({ type: () => [Number], default: [] })\n\tpublic riderSearchRanges?: number[];\n\n\t@prop({ type: () => [RiderBatchesSettings], default: [] })\n\tpublic riderBatches?: RiderBatchesSettings[];\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic nearByShopDistance?: number;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic nearByShopDistanceInHomeScreen?: number;\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic units?: string[];\n\n\t@prop({ type: CurrencySetting })\n\tpublic currencySetting?: CurrencySetting;\n\n\t@prop({ type: () => [String], enum: PaymentMethod, default: [] })\n\tpublic paymentMethods?: PaymentMethod[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isGroupOrderEnabled?: boolean;\n\n\t@prop({ type: CustomerSupport })\n\tpublic customerSupport?: CustomerSupport;\n\n\t@prop({ type: () => [CustomerSupportBatchesSettings], default: [] })\n\tpublic customerSupportBatches?: CustomerSupportBatchesSettings[];\n\n\t@prop({ type: () => [PlusSettings], default: [] })\n\tpublic plusSettings?: PlusSettings[];\n\n\t@prop({ type: AgentNotificationSetting })\n\tpublic agentNotificationSetting?: AgentNotificationSetting;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic cashbackAmount?: number;\n\n\t@prop({ type: String, enum: LyxaTimeZoneEnum })\n\tpublic timezone?: LyxaTimeZoneEnum;\n\n\t@prop({ type: Number, min: 0, default: 600 })\n\tpublic bufferTimeInSeconds!: number;\n\n\t@prop({ type: AppForceUpdate })\n\tpublic appForceUpdate?: AppForceUpdate;\n}\n"]}
|
|
@@ -5,10 +5,10 @@ interface AuthOptions {
|
|
|
5
5
|
autoRefresh?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
8
|
-
req: import("http").IncomingMessage;
|
|
9
8
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
10
9
|
tokenType: TokenType | undefined;
|
|
11
10
|
entity: import("../context").EntityContext | undefined;
|
|
11
|
+
req: import("http").IncomingMessage;
|
|
12
12
|
requestId: string | undefined;
|
|
13
13
|
usedRefreshToken: boolean | undefined;
|
|
14
14
|
tokenRenewed: boolean | undefined;
|
|
@@ -4,10 +4,10 @@ interface RoleProtectedOptions {
|
|
|
4
4
|
allowedRoles: string[];
|
|
5
5
|
}
|
|
6
6
|
export declare function createRoleProtectedProcedure(options: RoleProtectedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
7
|
-
req: import("http").IncomingMessage;
|
|
8
7
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
9
8
|
tokenType: import("../../auth").TokenType | undefined;
|
|
10
9
|
entity: import("../context").EntityContext | undefined;
|
|
10
|
+
req: import("http").IncomingMessage;
|
|
11
11
|
requestId: string | undefined;
|
|
12
12
|
usedRefreshToken: boolean | undefined;
|
|
13
13
|
tokenRenewed: boolean | undefined;
|
|
@@ -3,10 +3,10 @@ interface PhoneVerifiedOptions {
|
|
|
3
3
|
entityTypes: AuthEntityType[];
|
|
4
4
|
}
|
|
5
5
|
export declare function createPhoneVerifiedProcedure(options: PhoneVerifiedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
6
|
-
req: import("http").IncomingMessage;
|
|
7
6
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
8
7
|
tokenType: import("../../auth").TokenType | undefined;
|
|
9
8
|
entity: import("../context").EntityContext | undefined;
|
|
9
|
+
req: import("http").IncomingMessage;
|
|
10
10
|
requestId: string | undefined;
|
|
11
11
|
usedRefreshToken: boolean | undefined;
|
|
12
12
|
tokenRenewed: boolean | undefined;
|
|
@@ -5,10 +5,10 @@ interface AuthOptions {
|
|
|
5
5
|
autoRefresh?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
8
|
-
req: import("http").IncomingMessage;
|
|
9
8
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
10
9
|
tokenType: TokenType | undefined;
|
|
11
10
|
entity: import("../context").EntityContext | undefined;
|
|
11
|
+
req: import("http").IncomingMessage;
|
|
12
12
|
requestId: string | undefined;
|
|
13
13
|
usedRefreshToken: boolean | undefined;
|
|
14
14
|
tokenRenewed: boolean | undefined;
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -26,8 +26,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
|
|
|
26
26
|
searchFields?: string[] | undefined;
|
|
27
27
|
} | undefined;
|
|
28
28
|
sort?: Record<string, 1 | -1> | undefined;
|
|
29
|
-
populate?: any;
|
|
30
29
|
select?: Record<string, 0 | 1> | undefined;
|
|
30
|
+
populate?: any;
|
|
31
31
|
query?: Record<string, any> | undefined;
|
|
32
32
|
}, {
|
|
33
33
|
search?: {
|
|
@@ -36,8 +36,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
|
|
|
36
36
|
} | undefined;
|
|
37
37
|
sort?: Record<string, 1 | -1> | undefined;
|
|
38
38
|
size?: number | undefined;
|
|
39
|
-
populate?: any;
|
|
40
39
|
select?: Record<string, 0 | 1> | undefined;
|
|
40
|
+
populate?: any;
|
|
41
41
|
query?: Record<string, any> | undefined;
|
|
42
42
|
page?: number | undefined;
|
|
43
43
|
}>>;
|
|
@@ -733,12 +733,12 @@ export declare const GetByIdInputSchema: z.ZodObject<{
|
|
|
733
733
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
734
734
|
}, "strip", z.ZodTypeAny, {
|
|
735
735
|
_id: import("mongoose").Types.ObjectId;
|
|
736
|
-
populate?: any;
|
|
737
736
|
select?: Record<string, 0 | 1> | undefined;
|
|
737
|
+
populate?: any;
|
|
738
738
|
}, {
|
|
739
739
|
_id: string | import("mongoose").Types.ObjectId;
|
|
740
|
-
populate?: any;
|
|
741
740
|
select?: Record<string, 0 | 1> | undefined;
|
|
741
|
+
populate?: any;
|
|
742
742
|
}>;
|
|
743
743
|
export type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;
|
|
744
744
|
export declare const GetProductByIdInputSchema: z.ZodObject<{
|
|
@@ -751,12 +751,12 @@ export declare const GetProductByIdInputSchema: z.ZodObject<{
|
|
|
751
751
|
_id: import("mongoose").Types.ObjectId;
|
|
752
752
|
withAttributeHiddenItems: boolean;
|
|
753
753
|
withAddonsHiddenItems: boolean;
|
|
754
|
-
populate?: any;
|
|
755
754
|
select?: Record<string, 0 | 1> | undefined;
|
|
755
|
+
populate?: any;
|
|
756
756
|
}, {
|
|
757
757
|
_id: string | import("mongoose").Types.ObjectId;
|
|
758
|
-
populate?: any;
|
|
759
758
|
select?: Record<string, 0 | 1> | undefined;
|
|
759
|
+
populate?: any;
|
|
760
760
|
withAttributeHiddenItems?: boolean | undefined;
|
|
761
761
|
withAddonsHiddenItems?: boolean | undefined;
|
|
762
762
|
}>;
|
|
@@ -768,13 +768,13 @@ export declare const GetOrderByIdInputSchema: z.ZodObject<{
|
|
|
768
768
|
userOrderCompletionScope: z.ZodOptional<z.ZodNativeEnum<typeof UserOrderCompletionScope>>;
|
|
769
769
|
}, "strip", z.ZodTypeAny, {
|
|
770
770
|
_id: import("mongoose").Types.ObjectId;
|
|
771
|
-
populate?: any;
|
|
772
771
|
select?: Record<string, 0 | 1> | undefined;
|
|
772
|
+
populate?: any;
|
|
773
773
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
774
774
|
}, {
|
|
775
775
|
_id: string | import("mongoose").Types.ObjectId;
|
|
776
|
-
populate?: any;
|
|
777
776
|
select?: Record<string, 0 | 1> | undefined;
|
|
777
|
+
populate?: any;
|
|
778
778
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
779
779
|
}>;
|
|
780
780
|
export type GetOrderByIdInputDTO = DTO<typeof GetOrderByIdInputSchema>;
|
|
@@ -782,11 +782,11 @@ export declare const GetByTokenInputSchema: z.ZodOptional<z.ZodObject<{
|
|
|
782
782
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
783
783
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
784
784
|
}, "strip", z.ZodTypeAny, {
|
|
785
|
-
populate?: any;
|
|
786
785
|
select?: Record<string, 0 | 1> | undefined;
|
|
787
|
-
}, {
|
|
788
786
|
populate?: any;
|
|
787
|
+
}, {
|
|
789
788
|
select?: Record<string, 0 | 1> | undefined;
|
|
789
|
+
populate?: any;
|
|
790
790
|
}>>;
|
|
791
791
|
export type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;
|
|
792
792
|
export declare const GetOneQuerySchema: z.ZodObject<{
|
|
@@ -794,12 +794,12 @@ export declare const GetOneQuerySchema: z.ZodObject<{
|
|
|
794
794
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
795
795
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
796
796
|
}, "strip", z.ZodTypeAny, {
|
|
797
|
-
populate?: any;
|
|
798
797
|
select?: Record<string, 0 | 1> | undefined;
|
|
798
|
+
populate?: any;
|
|
799
799
|
query?: Record<string, any> | undefined;
|
|
800
800
|
}, {
|
|
801
|
-
populate?: any;
|
|
802
801
|
select?: Record<string, 0 | 1> | undefined;
|
|
802
|
+
populate?: any;
|
|
803
803
|
query?: Record<string, any> | undefined;
|
|
804
804
|
}>;
|
|
805
805
|
export type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;
|