@lyxa.ai/core 1.4.9 → 1.4.11

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.
@@ -26,7 +26,9 @@ export declare class FCMService {
26
26
  private chunkArray;
27
27
  private compareVersions;
28
28
  private isNotifiableEntityType;
29
+ private isConsoleEntityType;
29
30
  private shouldUseNewStructure;
31
+ private buildConsoleMessage;
30
32
  private buildMessage;
31
33
  private buildOldMessage;
32
34
  sendNotification(payload: FCMNotificationPayload, targets: NotificationTokenTarget[]): Promise<{
@@ -63,6 +63,9 @@ let FCMService = class FCMService {
63
63
  type === enum_1.NotificationAccountType.RIDER ||
64
64
  type === enum_1.NotificationAccountType.SHOP);
65
65
  }
66
+ isConsoleEntityType(type) {
67
+ return type === enum_1.NotificationAccountType.SHOP_CONSOLE;
68
+ }
66
69
  shouldUseNewStructure(entityType, platform, version) {
67
70
  if (!this.isNotifiableEntityType(entityType))
68
71
  return false;
@@ -73,6 +76,19 @@ let FCMService = class FCMService {
73
76
  return false;
74
77
  return this.compareVersions(version, minVersion) >= 0;
75
78
  }
79
+ buildConsoleMessage(payload, batchTokens) {
80
+ const isInvisible = payload.invisible === true;
81
+ const channelId = payload.sound ? 'order_alert' : 'default';
82
+ const message = {
83
+ data: { ...payload.data, channelId: isInvisible ? 'silent' : channelId },
84
+ notification: {
85
+ title: payload.title,
86
+ body: payload.body,
87
+ },
88
+ tokens: batchTokens,
89
+ };
90
+ return message;
91
+ }
76
92
  buildMessage(payload, batchTokens) {
77
93
  const isInvisible = payload.invisible === true;
78
94
  const channelId = payload.sound ? 'order_alert' : 'default';
@@ -143,31 +159,42 @@ let FCMService = class FCMService {
143
159
  const logger = (0, __1.getLibraries)().getLoggerKit();
144
160
  const oldTokens = [];
145
161
  const newTokens = [];
162
+ const consoleTokens = [];
146
163
  for (const t of targets) {
164
+ if (this.isConsoleEntityType(t.entityType)) {
165
+ consoleTokens.push(t.token);
166
+ continue;
167
+ }
147
168
  const useNew = this.shouldUseNewStructure(t.entityType, t.platform, t.appVersion);
148
169
  if (useNew)
149
170
  newTokens.push(t.token);
150
171
  else
151
172
  oldTokens.push(t.token);
152
173
  }
153
- const sendGroup = async (groupTokens, groupPayload, oldNotificationStructure = false) => {
154
- const tokenChunks = this.chunkArray(groupTokens, FCMService_1.MAX_BATCH);
174
+ const sendGroup = async (data) => {
175
+ const tokenChunks = this.chunkArray(data.groupTokens, FCMService_1.MAX_BATCH);
155
176
  const success = [];
156
177
  const failed = [];
157
178
  const results = await Promise.all(tokenChunks.map(async (chunk) => {
158
- const message = oldNotificationStructure
159
- ? this.buildOldMessage(groupPayload, chunk)
160
- : this.buildMessage(groupPayload, chunk);
179
+ const message = data.consoleNotification
180
+ ? this.buildConsoleMessage(data.groupPayload, chunk)
181
+ : data.oldNotificationStructure
182
+ ? this.buildOldMessage(data.groupPayload, chunk)
183
+ : this.buildMessage(data.groupPayload, chunk);
161
184
  const response = await this.messaging.sendEachForMulticast(message);
162
185
  const logEntry = {
163
186
  timestamp: new Date().toISOString(),
164
- groupTokens,
165
- groupPayload,
166
- oldNotificationStructure,
187
+ groupTokens: data.groupTokens,
188
+ groupPayload: data.groupPayload,
189
+ oldNotificationStructure: data.oldNotificationStructure,
190
+ consoleNotification: data.consoleNotification,
167
191
  message,
168
192
  response,
169
193
  };
170
- logger.debug('Called Firebase function sendEachForMulticast', { tag: enum_1.LogTag.NOTIFICATION_ATTEMPTED, data: logEntry });
194
+ logger.debug('Called Firebase function sendEachForMulticast', {
195
+ tag: enum_1.LogTag.NOTIFICATION_ATTEMPTED,
196
+ data: logEntry,
197
+ });
171
198
  const batchSuccess = [];
172
199
  const batchFailed = [];
173
200
  response.responses.forEach((resp, idx) => {
@@ -194,12 +221,29 @@ let FCMService = class FCMService {
194
221
  let successTokens = [];
195
222
  let failedTokens = [];
196
223
  if (oldTokens.length) {
197
- const r = await sendGroup(oldTokens, payload, true);
224
+ const r = await sendGroup({
225
+ groupTokens: oldTokens,
226
+ groupPayload: payload,
227
+ oldNotificationStructure: true,
228
+ });
198
229
  successTokens.push(...r.success);
199
230
  failedTokens.push(...r.failed);
200
231
  }
201
232
  if (newTokens.length) {
202
- const r = await sendGroup(newTokens, payload, false);
233
+ const r = await sendGroup({
234
+ groupTokens: newTokens,
235
+ groupPayload: payload,
236
+ oldNotificationStructure: false,
237
+ });
238
+ successTokens.push(...r.success);
239
+ failedTokens.push(...r.failed);
240
+ }
241
+ if (consoleTokens.length) {
242
+ const r = await sendGroup({
243
+ groupTokens: consoleTokens,
244
+ groupPayload: payload,
245
+ consoleNotification: true,
246
+ });
203
247
  successTokens.push(...r.success);
204
248
  failedTokens.push(...r.failed);
205
249
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fcmService.js","sourceRoot":"/","sources":["libraries/firebase/fcmService.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;AACrC,mCAAiC;AAEjC,+CAAoF;AAwBpF,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;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;CACD,CAAC;AAEW,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AACvC,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AACvC,QAAA,mBAAmB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5B,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;;AAnPW,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\tdeviceId?: string;\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';\nexport const FCMServiceForCpanel = 'fcm.service.cpanel';\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;AAwBpF,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;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;CACD,CAAC;AAEW,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AACvC,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AACvC,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAGjD,IAAM,UAAU,GAAhB,MAAM,UAAU;;IACd,SAAS,CAAuB;IAChC,MAAM,CAAU,SAAS,GAAG,GAAG,CAAC;IAExC,YAAY,GAAS;QACpB,MAAM,WAAW,GAAG,GAAG,IAAI,IAAA,gBAA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AAY,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;gBACzB,WAAW,EAAE,SAAS;gBACtB,YAAY,EAAE,OAAO;gBACrB,wBAAwB,EAAE,KAAK;aAC/B,CAAC,CAAC;YAEH,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,aAAa,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC;gBACzB,WAAW,EAAE,aAAa;gBAC1B,YAAY,EAAE,OAAO;gBACrB,mBAAmB,EAAE,IAAI;aACzB,CAAC,CAAC;YAEH,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;;AA9SW,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CA+StB","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\tdeviceId?: string;\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';\nexport const FCMServiceForCpanel = 'fcm.service.cpanel';\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 isConsoleEntityType(type: NotificationAccountType): type is NotifiableEntityType {\n\t\treturn type === NotificationAccountType.SHOP_CONSOLE;\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 buildConsoleMessage(\n\t\tpayload: FCMNotificationPayload,\n\t\tbatchTokens: string[]\n\t): 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};\n\n\t\treturn message;\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\t\tconst consoleTokens: string[] = [];\n\n\t\tfor (const t of targets) {\n\t\t\tif (this.isConsoleEntityType(t.entityType)) {\n\t\t\t\tconsoleTokens.push(t.token);\n\t\t\t\tcontinue;\n\t\t\t}\n\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 (data: {\n\t\t\tgroupTokens: string[];\n\t\t\tgroupPayload: FCMNotificationPayload;\n\t\t\toldNotificationStructure?: boolean;\n\t\t\tconsoleNotification?: boolean;\n\t\t}) => {\n\t\t\tconst tokenChunks = this.chunkArray(data.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 = data.consoleNotification\n\t\t\t\t\t\t? this.buildConsoleMessage(data.groupPayload, chunk)\n\t\t\t\t\t\t: data.oldNotificationStructure\n\t\t\t\t\t\t\t? this.buildOldMessage(data.groupPayload, chunk)\n\t\t\t\t\t\t\t: this.buildMessage(data.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: data.groupTokens,\n\t\t\t\t\t\tgroupPayload: data.groupPayload,\n\t\t\t\t\t\toldNotificationStructure: data.oldNotificationStructure,\n\t\t\t\t\t\tconsoleNotification: data.consoleNotification,\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', {\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({\n\t\t\t\tgroupTokens: oldTokens,\n\t\t\t\tgroupPayload: payload,\n\t\t\t\toldNotificationStructure: true,\n\t\t\t});\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({\n\t\t\t\tgroupTokens: newTokens,\n\t\t\t\tgroupPayload: payload,\n\t\t\t\toldNotificationStructure: false,\n\t\t\t});\n\n\t\t\tsuccessTokens.push(...r.success);\n\t\t\tfailedTokens.push(...r.failed);\n\t\t}\n\n\t\t// send console tokens\n\t\tif (consoleTokens.length) {\n\t\t\tconst r = await sendGroup({\n\t\t\t\tgroupTokens: consoleTokens,\n\t\t\t\tgroupPayload: payload,\n\t\t\t\tconsoleNotification: true,\n\t\t\t});\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"]}
@@ -13,6 +13,6 @@ export declare class RiderProfit extends CourierOrderProfit {
13
13
  secondaryProfitFromTips?: number;
14
14
  }
15
15
  export declare class ServiceBookingProfit {
16
- profit: number;
17
- secondaryProfit: number;
16
+ profit?: number;
17
+ secondaryProfit?: number;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"profit.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/profit.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,kBAAkB;IAEvB,kBAAkB,CAAU;IAG5B,2BAA2B,CAAU;IAGrC,WAAW,CAAU;IAGrB,oBAAoB,CAAU;CACrC;AAZD,gDAYC;AAVO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8DACA;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uEACS;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACP;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gEACE;AAGtC,MAAa,kBAAmB,SAAQ,kBAAkB;IAElD,cAAc,CAAU;IAGxB,uBAAuB,CAAU;CACxC;AAND,gDAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0DACJ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;mEACK;AAGzC,MAAa,WAAY,SAAQ,kBAAkB;IAE3C,cAAc,CAAU;IAGxB,uBAAuB,CAAU;CACxC;AAND,kCAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;mDACJ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;4DACK;AAGzC,MAAa,oBAAoB;IAEzB,MAAM,CAAS;IAGf,eAAe,CAAS;CAC/B;AAND,oDAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;oDACb;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6DACJ","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class CourierOrderProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profitFromDelivery?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfitFromDelivery?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic totalProfit?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryTotalProfit?: number;\n}\n\nexport class RegularOrderProfit extends CourierOrderProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profitFromItem?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfitFromItem?: number;\n}\n\nexport class RiderProfit extends CourierOrderProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profitFromTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfitFromTips?: number;\n}\n\nexport class ServiceBookingProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profit: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfit: number;\n}\n"]}
1
+ {"version":3,"file":"profit.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/profit.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,kBAAkB;IAEvB,kBAAkB,CAAU;IAG5B,2BAA2B,CAAU;IAGrC,WAAW,CAAU;IAGrB,oBAAoB,CAAU;CACrC;AAZD,gDAYC;AAVO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8DACA;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uEACS;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACP;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gEACE;AAGtC,MAAa,kBAAmB,SAAQ,kBAAkB;IAElD,cAAc,CAAU;IAGxB,uBAAuB,CAAU;CACxC;AAND,gDAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0DACJ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;mEACK;AAGzC,MAAa,WAAY,SAAQ,kBAAkB;IAE3C,cAAc,CAAU;IAGxB,uBAAuB,CAAU;CACxC;AAND,kCAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;mDACJ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;4DACK;AAGzC,MAAa,oBAAoB;IAEzB,MAAM,CAAU;IAGhB,eAAe,CAAU;CAChC;AAND,oDAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;oDACZ;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6DACH","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class CourierOrderProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profitFromDelivery?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfitFromDelivery?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic totalProfit?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryTotalProfit?: number;\n}\n\nexport class RegularOrderProfit extends CourierOrderProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profitFromItem?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfitFromItem?: number;\n}\n\nexport class RiderProfit extends CourierOrderProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profitFromTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfitFromTips?: number;\n}\n\nexport class ServiceBookingProfit {\n\t@prop({ type: Number, default: 0 })\n\tpublic profit?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryProfit?: number;\n}\n"]}
@@ -6,6 +6,7 @@ import { ServiceBookingProfit } from './profit.model';
6
6
  import { ServiceCouponDetails, ServicePromotionCut } from './marketing-cut.model';
7
7
  import { Cashback } from './cashback-amounts.model';
8
8
  export declare class ServiceBookingFinance {
9
+ adminCommission: number;
9
10
  exchangeRate?: number;
10
11
  paymentMethod: PaymentMethod;
11
12
  paymentInformation?: PaymentInformation;
@@ -19,6 +19,7 @@ const profit_model_1 = require("./profit.model");
19
19
  const marketing_cut_model_1 = require("./marketing-cut.model");
20
20
  const cashback_amounts_model_1 = require("./cashback-amounts.model");
21
21
  class ServiceBookingFinance {
22
+ adminCommission;
22
23
  exchangeRate;
23
24
  paymentMethod;
24
25
  paymentInformation;
@@ -31,6 +32,10 @@ class ServiceBookingFinance {
31
32
  cashBackAmounts;
32
33
  }
33
34
  exports.ServiceBookingFinance = ServiceBookingFinance;
35
+ __decorate([
36
+ (0, typegoose_1.prop)({ required: true, type: Number }),
37
+ __metadata("design:type", Number)
38
+ ], ServiceBookingFinance.prototype, "adminCommission", void 0);
34
39
  __decorate([
35
40
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
36
41
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"service-booking-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-booking-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,2CAAkC;AAClC,mFAAwE;AACxE,qDAA2D;AAC3D,2EAAiE;AACjE,iDAAsD;AACtD,+DAAkF;AAClF,qEAAoD;AAEpD,MAAa,qBAAqB;IAE1B,YAAY,CAAU;IAGtB,aAAa,CAAiB;IAG9B,kBAAkB,CAAsB;IAGxC,OAAO,CAAyB;IAGhC,aAAa,CAAwB;IAGrC,YAAY,CAAwB;IAGpC,QAAQ,CAAuB;IAG/B,MAAM,CAAwB;IAG9B,GAAG,CAAO;IAGV,eAAe,CAAY;CAClC;AA9BD,sDA8BC;AA5BO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;2DACN;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAa,EAAE,CAAC;;4DACvB;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,8CAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACzB,8CAAkB;iEAAC;AAGxC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,qDAAqB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACvD,qDAAqB;sDAAC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,mCAAoB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BAChC,mCAAoB;4DAAC;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,mCAAoB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACjC,mCAAoB;2DAAC;AAGpC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,yCAAmB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACpC,yCAAmB;uDAAC;AAG/B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,0CAAoB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACvC,0CAAoB;qDAAC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,eAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACzB,eAAG;kDAAC;AAGV;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BAClB,iCAAQ;8DAAC","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { Vat } from './vat.model';\nimport { ServiceBookingPricing } from './service-booking-pricing.model';\nimport { PaymentMethod } from '../../../../utilities/enum';\nimport { PaymentInformation } from './payment-infromation.model';\nimport { ServiceBookingProfit } from './profit.model';\nimport { ServiceCouponDetails, ServicePromotionCut } from './marketing-cut.model';\nimport { Cashback } from './cashback-amounts.model';\n\nexport class ServiceBookingFinance {\n\t@prop({ type: Number, default: 0 })\n\tpublic exchangeRate?: number;\n\n\t@prop({ required: true, type: String, enum: PaymentMethod })\n\tpublic paymentMethod!: PaymentMethod;\n\n\t@prop({ type: () => PaymentInformation, _id: false })\n\tpublic paymentInformation?: PaymentInformation;\n\n\t@prop({ required: true, type: () => ServiceBookingPricing, _id: false })\n\tpublic pricing!: ServiceBookingPricing;\n\n\t@prop({ type: () => ServiceBookingProfit, _id: false })\n\tpublic companyProfit?: ServiceBookingProfit;\n\n\t@prop({ type: () => ServiceBookingProfit, _id: false })\n\tpublic vendorProfit?: ServiceBookingProfit;\n\n\t@prop({ type: () => ServicePromotionCut, _id: false })\n\tpublic discount?: ServicePromotionCut;\n\n\t@prop({ type: () => ServiceCouponDetails, _id: false })\n\tpublic coupon?: ServiceCouponDetails;\n\n\t@prop({ type: () => Vat, _id: false })\n\tpublic vat?: Vat;\n\n\t@prop({ type: () => Cashback, _id: false })\n\tpublic cashBackAmounts?: Cashback;\n}\n"]}
1
+ {"version":3,"file":"service-booking-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-booking-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,2CAAkC;AAClC,mFAAwE;AACxE,qDAA2D;AAC3D,2EAAiE;AACjE,iDAAsD;AACtD,+DAAkF;AAClF,qEAAoD;AAEpD,MAAa,qBAAqB;IAE1B,eAAe,CAAU;IAGzB,YAAY,CAAU;IAGtB,aAAa,CAAiB;IAG9B,kBAAkB,CAAsB;IAGxC,OAAO,CAAyB;IAGhC,aAAa,CAAwB;IAGrC,YAAY,CAAwB;IAGpC,QAAQ,CAAuB;IAG/B,MAAM,CAAwB;IAG9B,GAAG,CAAO;IAG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IAAI,EAAE,GAAG,EAAE,CAAC,eAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACzB,eAAG;kDAAC;AAGV;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BAClB,iCAAQ;8DAAC","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { Vat } from './vat.model';\nimport { ServiceBookingPricing } from './service-booking-pricing.model';\nimport { PaymentMethod } from '../../../../utilities/enum';\nimport { PaymentInformation } from './payment-infromation.model';\nimport { ServiceBookingProfit } from './profit.model';\nimport { ServiceCouponDetails, ServicePromotionCut } from './marketing-cut.model';\nimport { Cashback } from './cashback-amounts.model';\n\nexport class ServiceBookingFinance {\n\t@prop({ required: true, type: Number })\n\tpublic adminCommission!: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic exchangeRate?: number;\n\n\t@prop({ required: true, type: String, enum: PaymentMethod })\n\tpublic paymentMethod!: PaymentMethod;\n\n\t@prop({ type: () => PaymentInformation, _id: false })\n\tpublic paymentInformation?: PaymentInformation;\n\n\t@prop({ required: true, type: () => ServiceBookingPricing, _id: false })\n\tpublic pricing!: ServiceBookingPricing;\n\n\t@prop({ type: () => ServiceBookingProfit, _id: false })\n\tpublic companyProfit?: ServiceBookingProfit;\n\n\t@prop({ type: () => ServiceBookingProfit, _id: false })\n\tpublic vendorProfit?: ServiceBookingProfit;\n\n\t@prop({ type: () => ServicePromotionCut, _id: false })\n\tpublic discount?: ServicePromotionCut;\n\n\t@prop({ type: () => ServiceCouponDetails, _id: false })\n\tpublic coupon?: ServiceCouponDetails;\n\n\t@prop({ type: () => Vat, _id: false })\n\tpublic vat?: Vat;\n\n\t@prop({ type: () => Cashback, _id: false })\n\tpublic cashBackAmounts?: Cashback;\n}\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.9
25
+ Version: 1.4.11
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",