@lyxa.ai/core 1.4.333 → 1.4.334-alpha-12

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.
Files changed (27) hide show
  1. package/dist/libraries/mongo/models/embedded/live-activity-token-info.model.d.ts +4 -0
  2. package/dist/libraries/mongo/models/embedded/live-activity-token-info.model.js +27 -0
  3. package/dist/libraries/mongo/models/embedded/live-activity-token-info.model.js.map +1 -0
  4. package/dist/libraries/mongo/models/order.model.d.ts +2 -1
  5. package/dist/libraries/mongo/models/order.model.js +5 -4
  6. package/dist/libraries/mongo/models/order.model.js.map +1 -1
  7. package/dist/libraries/mongo/models/payment-intent.model.d.ts +1 -2
  8. package/dist/libraries/mongo/models/payment-intent.model.js +0 -5
  9. package/dist/libraries/mongo/models/payment-intent.model.js.map +1 -1
  10. package/dist/libraries/notification/firebase-message.builder.d.ts +5 -1
  11. package/dist/libraries/notification/firebase-message.builder.js +34 -1
  12. package/dist/libraries/notification/firebase-message.builder.js.map +1 -1
  13. package/dist/libraries/notification/index.d.ts +2 -0
  14. package/dist/libraries/notification/index.js.map +1 -1
  15. package/dist/libraries/notification/lyxa-fcm-sender.js +9 -0
  16. package/dist/libraries/notification/lyxa-fcm-sender.js.map +1 -1
  17. package/dist/libraries/notification/lyxa-fcm.service.d.ts +1 -0
  18. package/dist/libraries/notification/lyxa-fcm.service.js +21 -0
  19. package/dist/libraries/notification/lyxa-fcm.service.js.map +1 -1
  20. package/dist/libraries/socket/events/chatroom-message-send.socket.event.d.ts +21 -21
  21. package/dist/libraries/socket/events/order-actions.socket.event.d.ts +36 -36
  22. package/dist/libraries/socket/events/rider-location-update.socket.event.d.ts +4 -4
  23. package/dist/libraries/socket/events/ticket-actions.socket.event.d.ts +13 -13
  24. package/dist/libraries/socket/events/ticket-assign.socket.event.d.ts +4 -4
  25. package/dist/types/README.md +1 -1
  26. package/dist/types/package.json +1 -1
  27. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ export declare class LiveActivityTokenInfo {
2
+ deviceId?: string;
3
+ liveActivityToken?: string;
4
+ }
@@ -0,0 +1,27 @@
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
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LiveActivityTokenInfo = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ class LiveActivityTokenInfo {
15
+ deviceId;
16
+ liveActivityToken;
17
+ }
18
+ exports.LiveActivityTokenInfo = LiveActivityTokenInfo;
19
+ __decorate([
20
+ (0, typegoose_1.prop)({ type: String, default: '' }),
21
+ __metadata("design:type", String)
22
+ ], LiveActivityTokenInfo.prototype, "deviceId", void 0);
23
+ __decorate([
24
+ (0, typegoose_1.prop)({ type: String, default: '' }),
25
+ __metadata("design:type", String)
26
+ ], LiveActivityTokenInfo.prototype, "liveActivityToken", void 0);
27
+ //# sourceMappingURL=live-activity-token-info.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-activity-token-info.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/live-activity-token-info.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AAEjD,MAAa,qBAAqB;IAE1B,QAAQ,CAAU;IAGlB,iBAAiB,CAAU;CAClC;AAND,sDAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;uDACX;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;gEACF","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\n\nexport class LiveActivityTokenInfo {\n\t@prop({ type: String, default: '' })\n\tpublic deviceId?: string;\n\n\t@prop({ type: String, default: '' })\n\tpublic liveActivityToken?: string;\n}\n"]}
@@ -9,6 +9,7 @@ import { Flag } from './flag.model';
9
9
  import { Review } from './review.model';
10
10
  import { TripLeg } from './embedded/trip-leg.mode';
11
11
  import { Chatroom } from './chat-room.model';
12
+ import { LiveActivityTokenInfo } from './embedded/live-activity-token-info.model';
12
13
  export declare class Order extends TimeStamps {
13
14
  orderId: string;
14
15
  orderType?: OrderType;
@@ -64,5 +65,5 @@ export declare class Order extends TimeStamps {
64
65
  appliedAt: Date;
65
66
  }>;
66
67
  translations?: Record<string, any>;
67
- liveActivityToken?: string | null;
68
+ liveActivityTokenInfo?: LiveActivityTokenInfo[];
68
69
  }
@@ -28,6 +28,7 @@ const time_1 = require("../../../utilities/time");
28
28
  const dayjs_1 = __importDefault(require("dayjs"));
29
29
  const utc_1 = __importDefault(require("dayjs/plugin/utc"));
30
30
  const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
31
+ const live_activity_token_info_model_1 = require("./embedded/live-activity-token-info.model");
31
32
  dayjs_1.default.extend(utc_1.default);
32
33
  dayjs_1.default.extend(timezone_1.default);
33
34
  let Order = class Order extends defaultClasses_1.TimeStamps {
@@ -82,7 +83,7 @@ let Order = class Order extends defaultClasses_1.TimeStamps {
82
83
  paymentAuthRequired;
83
84
  etaExtensionReasons;
84
85
  translations;
85
- liveActivityToken;
86
+ liveActivityTokenInfo;
86
87
  };
87
88
  exports.Order = Order;
88
89
  __decorate([
@@ -315,9 +316,9 @@ __decorate([
315
316
  __metadata("design:type", Object)
316
317
  ], Order.prototype, "translations", void 0);
317
318
  __decorate([
318
- (0, typegoose_1.prop)({ type: String, default: null }),
319
- __metadata("design:type", Object)
320
- ], Order.prototype, "liveActivityToken", void 0);
319
+ (0, typegoose_1.prop)({ type: () => [live_activity_token_info_model_1.LiveActivityTokenInfo], default: [] }),
320
+ __metadata("design:type", Array)
321
+ ], Order.prototype, "liveActivityTokenInfo", void 0);
321
322
  exports.Order = Order = __decorate([
322
323
  (0, typegoose_1.modelOptions)({
323
324
  schemaOptions: {
@@ -1 +1 @@
1
- {"version":3,"file":"order.model.js","sourceRoot":"/","sources":["libraries/mongo/models/order.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAqF;AACrF,4EAAqE;AACrE,kDAMiC;AACjC,sEAA4D;AAC5D,+CAAsC;AACtC,kGAAqF;AACrF,8EAAoE;AACpE,6CAAoC;AACpC,iDAAwC;AACxC,4DAAmD;AACnD,wBAAiC;AAEjC,kDAAuD;AACvD,kDAA0B;AAC1B,2DAAmC;AACnC,qEAA6C;AAG7C,eAAK,CAAC,MAAM,CAAC,aAAG,CAAC,CAAC;AAClB,eAAK,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAC;AA6ChB,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,2BAAU;IAE7B,OAAO,CAAS;IAGhB,SAAS,CAAa;IAGtB,iBAAiB,CAAU;IAG3B,KAAK,CAAc;IAGnB,sBAAsB,CAA0B;IAGhD,6BAA6B,CAAQ;IAGrC,sCAAsC,CAAU;IAGhD,sBAAsB,CAAQ;IAG9B,+BAA+B,CAAU;IAGzC,WAAW,CAAQ;IAGnB,sBAAsB,CAAU;IAGhC,WAAW,CAAU;IAGrB,IAAI,CAAU;IAGd,YAAY,CAAQ;IAGpB,SAAS,CAAQ;IAGjB,QAAQ,CAAQ;IAGhB,WAAW,CAAe;IAG1B,qBAAqB,CAAU;IAG/B,WAAW,CAAW;IAGtB,aAAa,CAAW;IAGxB,iBAAiB,CAAwB;IAGzC,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prop, Ref, Severity } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tCounterType,\n\tFlagReasonType,\n\tFlagType,\n\tOrderType,\n\tUrgentOrderReasons,\n} from '../../../utilities/enum';\nimport { OrderCancel } from './embedded/order-cancel.model';\nimport { Rider } from './rider.model';\nimport { DeliveryFeeInformation } from './embedded/order-delivery-information.model';\nimport { RiderAssignment } from './embedded/rider-assignment-model';\nimport { Flag } from './flag.model';\nimport { Review } from './review.model';\nimport { TripLeg } from './embedded/trip-leg.mode';\nimport { CounterModel } from '.';\nimport { Chatroom } from './chat-room.model';\nimport { LyxaTimezone } from '../../../utilities/time';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\nimport { User } from './user.model';\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'orders',\n\t\tdiscriminatorKey: 'orderType',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: { allowMixed: Severity.ALLOW },\n})\n@index({ 'deliveryAddress.location': '2dsphere' })\n@index({ user: 1, status: 1, processedAt: -1 })\n@index({ shop: 1, status: 1, processedAt: -1 })\n@index({ parent: 1, status: 1, processedAt: -1 })\n@index({ orderType: 1, status: 1, processedAt: -1 })\n@index({ orderType: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ itemType: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ shop: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ parent: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ rider: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ 'riderAssignments.rider': 1, 'riderAssignments.status': 1 })\n@pre<Order>('validate', async function (next) {\n\tif (this.isNew) {\n\t\tconst today = dayjs().tz(LyxaTimezone).format('DDMMYY');\n\n\t\tconst counter = await CounterModel.findOneAndUpdate(\n\t\t\t{ counterType: CounterType.ORDER },\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t$cond: [{ $eq: ['$today', today] }, { $add: ['$value', 1] }, 1],\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoday: today,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ new: true, upsert: true }\n\t\t);\n\n\t\tthis.orderId = `${today}${counter.value.toString().padStart(6, '0')}`;\n\t}\n\tnext();\n})\nexport class Order extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic orderId: string;\n\n\t@prop({ type: String, enum: OrderType, default: OrderType.REGULAR })\n\tpublic orderType?: OrderType;\n\n\t@prop({ type: Number })\n\tpublic bringChangeAmount?: number;\n\n\t@prop({ ref: () => Rider, index: true })\n\tpublic rider?: Ref<Rider>;\n\n\t@prop({ type: () => DeliveryFeeInformation })\n\tpublic deliveryFeeInformation?: DeliveryFeeInformation;\n\n\t@prop({ type: Date })\n\tpublic initialEstimatedDeliveredTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic initialEstimatedDeliveredTimeInMinutes?: number;\n\n\t@prop({ type: Date })\n\tpublic estimatedDeliveredTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic estimatedDeliveredTimeInMinutes?: number;\n\n\t@prop({ type: Date })\n\tpublic deliveredAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic deliveredTimeInMinutes?: number;\n\n\t@prop({ type: String })\n\tpublic instruction?: string;\n\n\t@prop({ type: String })\n\tpublic note?: string;\n\n\t@prop({ type: Date })\n\tpublic scheduledFor?: Date;\n\n\t@prop({ type: Date })\n\tpublic triggerAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic placedAt?: Date;\n\n\t@prop({ type: () => OrderCancel })\n\tpublic orderCancel?: OrderCancel;\n\n\t@prop({ type: String })\n\tpublic cancellationMsgToUser?: string;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLateOrder?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isUrgentOrder?: boolean;\n\n\t@prop({ type: () => [String], enum: UrgentOrderReasons, default: [] })\n\tpublic urgentOrderReason?: UrgentOrderReasons[];\n\n\t@prop({ type: Date, default: new Date() })\n\tpublic processedAt?: Date;\n\n\t@prop({\n\t\ttype: Number,\n\t\trequired: true,\n\t\tmin: 1000,\n\t\tmax: 9999,\n\t\tvalidate: {\n\t\t\tvalidator: (v: number) => Number.isInteger(v),\n\t\t\tmessage: 'Pin code must be an integer',\n\t\t},\n\t})\n\tpublic pinCode!: number;\n\n\t// Review feature\n\t@prop({ type: Boolean, default: false })\n\tpublic isOrderReviewed?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isReviewNotificationSent?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLowRated?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isResolved?: boolean;\n\n\t@prop({\n\t\tref: () => Review,\n\t\tforeignField: 'order',\n\t\tlocalField: '_id',\n\t})\n\tpublic reviews?: Ref<Review>[];\n\n\t// Flag feature\n\t@prop({ type: Boolean, default: false })\n\tpublic isFlagged?: boolean;\n\n\t@prop({ type: [String], enum: FlagType, default: [] })\n\tpublic flagTypes?: FlagType[];\n\n\t@prop({ type: () => [String], enum: FlagReasonType, default: [] })\n\tpublic flagOrderReason?: FlagReasonType[];\n\n\t@prop({ type: Date })\n\tpublic flaggedAt?: Date;\n\n\t@prop({\n\t\tref: () => Flag,\n\t\tforeignField: 'order',\n\t\tlocalField: '_id',\n\t})\n\tpublic flags?: Ref<Flag>[];\n\n\t@prop({ type: () => [RiderAssignment], default: [] })\n\tpublic riderAssignments?: RiderAssignment[];\n\n\t@prop({ type: Date })\n\tpublic estimatedPickupTime?: Date;\n\n\t@prop({ type: Date })\n\tpublic actualPickupTime?: Date;\n\n\t@prop({ type: Date })\n\tpublic estimatedPickupArrivalTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic estimatedPickupArrivalTimeInMinutes?: Number;\n\n\t@prop({ type: Date })\n\tpublic actualPickupArrivalTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic actualPickupArrivalTimeInMinutes?: Number;\n\n\t@prop({ type: Date })\n\tpublic riderSearchingStartTime?: Date;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic totalSearchAttempts?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic lastSearchRadiusInKm?: number;\n\n\t@prop({ type: () => [TripLeg], default: [] })\n\tpublic tripSummary?: TripLeg[];\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({\n\t\tref: 'Chatroom', // ✅ Use string instead of () => Chatroom\n\t\tforeignField: 'order',\n\t\tlocalField: '_id',\n\t\tjustOne: false,\n\t})\n\tpublic chatrooms?: Ref<Chatroom>[];\n\n\t@prop({ type: Date })\n\tpublic riderNearbyNotifiedAt?: Date;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic hasChatroom?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic paymentAuthRequired?: boolean;\n\n\t@prop({ type: () => Array, default: [] })\n\tetaExtensionReasons?: Array<{\n\t\treason: UrgentOrderReasons | FlagReasonType;\n\t\tappliedAt: Date;\n\t}>;\n\t@prop({\n\t\ttype: Object,\n\t\tdefault: {},\n\t})\n\tpublic translations?: Record<string, any>;\n\n\t@prop({ type: String, default: null })\n\tpublic liveActivityToken?: string | null;\n}\n"]}
1
+ {"version":3,"file":"order.model.js","sourceRoot":"/","sources":["libraries/mongo/models/order.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAqF;AACrF,4EAAqE;AACrE,kDAMiC;AACjC,sEAA4D;AAC5D,+CAAsC;AACtC,kGAAqF;AACrF,8EAAoE;AACpE,6CAAoC;AACpC,iDAAwC;AACxC,4DAAmD;AACnD,wBAAiC;AAEjC,kDAAuD;AACvD,kDAA0B;AAC1B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;YAExD,MAAM,OAAO,GAAG,MAAM,eAAY,CAAC,gBAAgB,CAClD,EAAE,WAAW,EAAE,kBAAW,CAAC,KAAK,EAAE,EAClC;gBACC;oBACC,IAAI,EAAE;wBACL,KAAK,EAAE;4BACN,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;yBAC/D;wBACD,KAAK,EAAE,KAAK;qBACZ;iBACD;aACD,EACD,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAC3B,CAAC;YAEF,IAAI,CAAC,OAAO,GAAG,GAAG,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;QACvE,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,KAAK,CAyLjB","sourcesContent":["import { index, modelOptions, pre, prop, Ref, Severity } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tCounterType,\n\tFlagReasonType,\n\tFlagType,\n\tOrderType,\n\tUrgentOrderReasons,\n} from '../../../utilities/enum';\nimport { OrderCancel } from './embedded/order-cancel.model';\nimport { Rider } from './rider.model';\nimport { DeliveryFeeInformation } from './embedded/order-delivery-information.model';\nimport { RiderAssignment } from './embedded/rider-assignment-model';\nimport { Flag } from './flag.model';\nimport { Review } from './review.model';\nimport { TripLeg } from './embedded/trip-leg.mode';\nimport { CounterModel } from '.';\nimport { Chatroom } from './chat-room.model';\nimport { LyxaTimezone } from '../../../utilities/time';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\nimport { LiveActivityTokenInfo } from './embedded/live-activity-token-info.model';\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'orders',\n\t\tdiscriminatorKey: 'orderType',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: { allowMixed: Severity.ALLOW },\n})\n@index({ 'deliveryAddress.location': '2dsphere' })\n@index({ user: 1, status: 1, processedAt: -1 })\n@index({ shop: 1, status: 1, processedAt: -1 })\n@index({ parent: 1, status: 1, processedAt: -1 })\n@index({ orderType: 1, status: 1, processedAt: -1 })\n@index({ orderType: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ itemType: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ shop: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ parent: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ rider: 1, status: 1, isEndorseLossApplied: 1, processedAt: -1 })\n@index({ 'riderAssignments.rider': 1, 'riderAssignments.status': 1 })\n@pre<Order>('validate', async function (next) {\n\tif (this.isNew) {\n\t\tconst today = dayjs().tz(LyxaTimezone).format('DDMMYY');\n\n\t\tconst counter = await CounterModel.findOneAndUpdate(\n\t\t\t{ counterType: CounterType.ORDER },\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t$cond: [{ $eq: ['$today', today] }, { $add: ['$value', 1] }, 1],\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoday: today,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ new: true, upsert: true }\n\t\t);\n\n\t\tthis.orderId = `${today}${counter.value.toString().padStart(6, '0')}`;\n\t}\n\tnext();\n})\nexport class Order extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic orderId: string;\n\n\t@prop({ type: String, enum: OrderType, default: OrderType.REGULAR })\n\tpublic orderType?: OrderType;\n\n\t@prop({ type: Number })\n\tpublic bringChangeAmount?: number;\n\n\t@prop({ ref: () => Rider, index: true })\n\tpublic rider?: Ref<Rider>;\n\n\t@prop({ type: () => DeliveryFeeInformation })\n\tpublic deliveryFeeInformation?: DeliveryFeeInformation;\n\n\t@prop({ type: Date })\n\tpublic initialEstimatedDeliveredTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic initialEstimatedDeliveredTimeInMinutes?: number;\n\n\t@prop({ type: Date })\n\tpublic estimatedDeliveredTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic estimatedDeliveredTimeInMinutes?: number;\n\n\t@prop({ type: Date })\n\tpublic deliveredAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic deliveredTimeInMinutes?: number;\n\n\t@prop({ type: String })\n\tpublic instruction?: string;\n\n\t@prop({ type: String })\n\tpublic note?: string;\n\n\t@prop({ type: Date })\n\tpublic scheduledFor?: Date;\n\n\t@prop({ type: Date })\n\tpublic triggerAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic placedAt?: Date;\n\n\t@prop({ type: () => OrderCancel })\n\tpublic orderCancel?: OrderCancel;\n\n\t@prop({ type: String })\n\tpublic cancellationMsgToUser?: string;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLateOrder?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isUrgentOrder?: boolean;\n\n\t@prop({ type: () => [String], enum: UrgentOrderReasons, default: [] })\n\tpublic urgentOrderReason?: UrgentOrderReasons[];\n\n\t@prop({ type: Date, default: new Date() })\n\tpublic processedAt?: Date;\n\n\t@prop({\n\t\ttype: Number,\n\t\trequired: true,\n\t\tmin: 1000,\n\t\tmax: 9999,\n\t\tvalidate: {\n\t\t\tvalidator: (v: number) => Number.isInteger(v),\n\t\t\tmessage: 'Pin code must be an integer',\n\t\t},\n\t})\n\tpublic pinCode!: number;\n\n\t// Review feature\n\t@prop({ type: Boolean, default: false })\n\tpublic isOrderReviewed?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isReviewNotificationSent?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLowRated?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isResolved?: boolean;\n\n\t@prop({\n\t\tref: () => Review,\n\t\tforeignField: 'order',\n\t\tlocalField: '_id',\n\t})\n\tpublic reviews?: Ref<Review>[];\n\n\t// Flag feature\n\t@prop({ type: Boolean, default: false })\n\tpublic isFlagged?: boolean;\n\n\t@prop({ type: [String], enum: FlagType, default: [] })\n\tpublic flagTypes?: FlagType[];\n\n\t@prop({ type: () => [String], enum: FlagReasonType, default: [] })\n\tpublic flagOrderReason?: FlagReasonType[];\n\n\t@prop({ type: Date })\n\tpublic flaggedAt?: Date;\n\n\t@prop({\n\t\tref: () => Flag,\n\t\tforeignField: 'order',\n\t\tlocalField: '_id',\n\t})\n\tpublic flags?: Ref<Flag>[];\n\n\t@prop({ type: () => [RiderAssignment], default: [] })\n\tpublic riderAssignments?: RiderAssignment[];\n\n\t@prop({ type: Date })\n\tpublic estimatedPickupTime?: Date;\n\n\t@prop({ type: Date })\n\tpublic actualPickupTime?: Date;\n\n\t@prop({ type: Date })\n\tpublic estimatedPickupArrivalTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic estimatedPickupArrivalTimeInMinutes?: Number;\n\n\t@prop({ type: Date })\n\tpublic actualPickupArrivalTime?: Date;\n\n\t@prop({ type: Number })\n\tpublic actualPickupArrivalTimeInMinutes?: Number;\n\n\t@prop({ type: Date })\n\tpublic riderSearchingStartTime?: Date;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic totalSearchAttempts?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic lastSearchRadiusInKm?: number;\n\n\t@prop({ type: () => [TripLeg], default: [] })\n\tpublic tripSummary?: TripLeg[];\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({\n\t\tref: 'Chatroom', // ✅ Use string instead of () => Chatroom\n\t\tforeignField: 'order',\n\t\tlocalField: '_id',\n\t\tjustOne: false,\n\t})\n\tpublic chatrooms?: Ref<Chatroom>[];\n\n\t@prop({ type: Date })\n\tpublic riderNearbyNotifiedAt?: Date;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic hasChatroom?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic paymentAuthRequired?: boolean;\n\n\t@prop({ type: () => Array, default: [] })\n\tetaExtensionReasons?: Array<{\n\t\treason: UrgentOrderReasons | FlagReasonType;\n\t\tappliedAt: Date;\n\t}>;\n\t@prop({\n\t\ttype: Object,\n\t\tdefault: {},\n\t})\n\tpublic translations?: Record<string, any>;\n\n\t@prop({ type: () => [LiveActivityTokenInfo], default: [] })\n\tpublic liveActivityTokenInfo?: LiveActivityTokenInfo[];\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { Ref } from '@typegoose/typegoose';
2
2
  import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
3
3
  import { CoreUser } from './core-user.model';
4
- import { PaymentIntentStatus, PaymentProvider } from '../../../utilities/enum';
4
+ import { PaymentIntentStatus } from '../../../utilities/enum';
5
5
  import { User } from './user.model';
6
6
  export declare class PaymentIntent extends TimeStamps {
7
7
  coreUser: Ref<CoreUser>;
@@ -14,5 +14,4 @@ export declare class PaymentIntent extends TimeStamps {
14
14
  authorization?: string;
15
15
  paymentContext?: any;
16
16
  status?: PaymentIntentStatus;
17
- provider?: PaymentProvider;
18
17
  }
@@ -26,7 +26,6 @@ let PaymentIntent = class PaymentIntent extends defaultClasses_1.TimeStamps {
26
26
  authorization;
27
27
  paymentContext;
28
28
  status;
29
- provider;
30
29
  };
31
30
  exports.PaymentIntent = PaymentIntent;
32
31
  __decorate([
@@ -69,10 +68,6 @@ __decorate([
69
68
  (0, typegoose_1.prop)({ type: String, enum: enum_1.PaymentIntentStatus, default: enum_1.PaymentIntentStatus.PENDING }),
70
69
  __metadata("design:type", String)
71
70
  ], PaymentIntent.prototype, "status", void 0);
72
- __decorate([
73
- (0, typegoose_1.prop)({ type: String, enum: enum_1.PaymentProvider }),
74
- __metadata("design:type", String)
75
- ], PaymentIntent.prototype, "provider", void 0);
76
71
  exports.PaymentIntent = PaymentIntent = __decorate([
77
72
  (0, typegoose_1.modelOptions)({
78
73
  schemaOptions: { collection: 'paymentIntents' },
@@ -1 +1 @@
1
- {"version":3,"file":"payment-intent.model.js","sourceRoot":"/","sources":["libraries/mongo/models/payment-intent.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmF;AACnF,4EAAqE;AACrE,uDAA6C;AAC7C,kDAA+E;AAC/E,6CAAoC;AAQ7B,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,2BAAU;IAErC,QAAQ,CAAiB;IAGzB,IAAI,CAAa;IAGjB,OAAO,CAAU;IAGjB,KAAK,CAAU;IAGf,UAAU,CAAU;IAGpB,MAAM,CAAU;IAGhB,eAAe,CAAU;IAGzB,aAAa,CAAU;IAGvB,cAAc,CAAO;IAGrB,MAAM,CAAuB;IAG7B,QAAQ,CAAmB;CAClC,CAAA;AAjCY,sCAAa;AAElB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC;;+CACd;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;2CAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDACI;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDACS;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACO;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,oBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;;qDAChB;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAAmB,EAAE,OAAO,EAAE,0BAAmB,CAAC,OAAO,EAAE,CAAC;;6CACpD;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAe,EAAE,CAAC;;+CACZ;wBAhCtB,aAAa;IANzB,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE;QAC/C,OAAO,EAAE;YACR,UAAU,EAAE,oBAAQ,CAAC,KAAK;SAC1B;KACD,CAAC;GACW,aAAa,CAiCzB","sourcesContent":["import { modelOptions, mongoose, prop, Ref, Severity } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CoreUser } from './core-user.model';\nimport { PaymentIntentStatus, PaymentProvider } from '../../../utilities/enum';\nimport { User } from './user.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'paymentIntents' },\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\nexport class PaymentIntent extends TimeStamps {\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic coreUser!: Ref<CoreUser>;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, type: String })\n\tpublic orderId!: string;\n\n\t@prop({ type: String })\n\tpublic token?: string; // only for areeba\n\n\t@prop({ type: String })\n\tpublic externalId?: string; // only for whish\n\n\t@prop({ required: true, type: Number })\n\tpublic amount!: number;\n\n\t@prop({ type: Number })\n\tpublic secondaryAmount?: number;\n\n\t@prop({ type: String })\n\tpublic authorization?: string;\n\n\t@prop({ type: mongoose.Schema.Types.Mixed })\n\tpublic paymentContext?: any;\n\n\t@prop({ type: String, enum: PaymentIntentStatus, default: PaymentIntentStatus.PENDING })\n\tpublic status?: PaymentIntentStatus;\n\n\t@prop({ type: String, enum: PaymentProvider })\n\tpublic provider?: PaymentProvider;\n}\n"]}
1
+ {"version":3,"file":"payment-intent.model.js","sourceRoot":"/","sources":["libraries/mongo/models/payment-intent.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmF;AACnF,4EAAqE;AACrE,uDAA6C;AAC7C,kDAA8D;AAC9D,6CAAoC;AAQ7B,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,2BAAU;IAErC,QAAQ,CAAiB;IAGzB,IAAI,CAAa;IAGjB,OAAO,CAAU;IAGjB,KAAK,CAAU;IAGf,UAAU,CAAU;IAGpB,MAAM,CAAU;IAGhB,eAAe,CAAU;IAGzB,aAAa,CAAU;IAGvB,cAAc,CAAO;IAGrB,MAAM,CAAuB;CACpC,CAAA;AA9BY,sCAAa;AAElB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC;;+CACd;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;2CAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDACI;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDACS;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACO;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,oBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;;qDAChB;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAAmB,EAAE,OAAO,EAAE,0BAAmB,CAAC,OAAO,EAAE,CAAC;;6CACpD;wBA7BxB,aAAa;IANzB,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE;QAC/C,OAAO,EAAE;YACR,UAAU,EAAE,oBAAQ,CAAC,KAAK;SAC1B;KACD,CAAC;GACW,aAAa,CA8BzB","sourcesContent":["import { modelOptions, mongoose, prop, Ref, Severity } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CoreUser } from './core-user.model';\nimport { PaymentIntentStatus } from '../../../utilities/enum';\nimport { User } from './user.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'paymentIntents' },\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\nexport class PaymentIntent extends TimeStamps {\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic coreUser!: Ref<CoreUser>;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, type: String })\n\tpublic orderId!: string;\n\n\t@prop({ type: String })\n\tpublic token?: string; // only for areeba\n\n\t@prop({ type: String })\n\tpublic externalId?: string; // only for whish\n\n\t@prop({ required: true, type: Number })\n\tpublic amount!: number;\n\n\t@prop({ type: Number })\n\tpublic secondaryAmount?: number;\n\n\t@prop({ type: String })\n\tpublic authorization?: string;\n\n\t@prop({ type: mongoose.Schema.Types.Mixed })\n\tpublic paymentContext?: any;\n\n\t@prop({ type: String, enum: PaymentIntentStatus, default: PaymentIntentStatus.PENDING })\n\tpublic status?: PaymentIntentStatus;\n}\n"]}
@@ -3,7 +3,8 @@ import { FCMNotificationPayload } from './lyxa-fcm.service';
3
3
  export declare enum MultiMessageType {
4
4
  OLD = "old",
5
5
  CONSOLE = "console",
6
- DEFAULT = "default"
6
+ DEFAULT = "default",
7
+ LIVE_ACTIVITY = "live_activity"
7
8
  }
8
9
  export interface IFirebaseMessageBuilder {
9
10
  buildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
@@ -20,3 +21,6 @@ export declare class OldMessageBuilder implements IFirebaseMessageBuilder {
20
21
  export declare class ConsoleMessageBuilder implements IFirebaseMessageBuilder {
21
22
  buildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
22
23
  }
24
+ export declare class LiveActivityMessageBuilder implements IFirebaseMessageBuilder {
25
+ buildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;
26
+ }
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConsoleMessageBuilder = exports.OldMessageBuilder = exports.DefaultMessageBuilder = exports.FirebaseMessageBuilderFactory = exports.MultiMessageType = void 0;
6
+ exports.LiveActivityMessageBuilder = exports.ConsoleMessageBuilder = exports.OldMessageBuilder = exports.DefaultMessageBuilder = exports.FirebaseMessageBuilderFactory = exports.MultiMessageType = void 0;
7
+ const dayjs_1 = __importDefault(require("dayjs"));
4
8
  var MultiMessageType;
5
9
  (function (MultiMessageType) {
6
10
  MultiMessageType["OLD"] = "old";
7
11
  MultiMessageType["CONSOLE"] = "console";
8
12
  MultiMessageType["DEFAULT"] = "default";
13
+ MultiMessageType["LIVE_ACTIVITY"] = "live_activity";
9
14
  })(MultiMessageType || (exports.MultiMessageType = MultiMessageType = {}));
10
15
  class FirebaseMessageBuilderFactory {
11
16
  buildMessage(type, payload, tokens) {
@@ -14,6 +19,8 @@ class FirebaseMessageBuilderFactory {
14
19
  return new ConsoleMessageBuilder().buildMessage(payload, tokens);
15
20
  case MultiMessageType.OLD:
16
21
  return new OldMessageBuilder().buildMessage(payload, tokens);
22
+ case MultiMessageType.LIVE_ACTIVITY:
23
+ return new LiveActivityMessageBuilder().buildMessage(payload, tokens);
17
24
  default:
18
25
  return new DefaultMessageBuilder().buildMessage(payload, tokens);
19
26
  }
@@ -104,4 +111,30 @@ class ConsoleMessageBuilder {
104
111
  }
105
112
  }
106
113
  exports.ConsoleMessageBuilder = ConsoleMessageBuilder;
114
+ class LiveActivityMessageBuilder {
115
+ buildMessage(payload, tokens) {
116
+ return {
117
+ notification: {
118
+ title: payload.title,
119
+ body: payload.body,
120
+ },
121
+ tokens: tokens,
122
+ apns: {
123
+ payload: {
124
+ aps: {
125
+ timestamp: (0, dayjs_1.default)().unix(),
126
+ event: payload.data.event,
127
+ 'content-state': { status: payload.data.status, etaMinutes: payload.data.deliveryETAInMinutes },
128
+ },
129
+ },
130
+ headers: {
131
+ 'apns-push-type': 'liveactivity',
132
+ 'apns-priority': '10',
133
+ 'apns-topic': 'com.lyxa.app.push-type.liveactivity',
134
+ },
135
+ },
136
+ };
137
+ }
138
+ }
139
+ exports.LiveActivityMessageBuilder = LiveActivityMessageBuilder;
107
140
  //# sourceMappingURL=firebase-message.builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"firebase-message.builder.js","sourceRoot":"/","sources":["libraries/notification/firebase-message.builder.ts"],"names":[],"mappings":";;;AAGA,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC3B,+BAAW,CAAA;IACX,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;AAC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AAS,CAAC;QAC5D,OAAO;YACN,IAAI,EAAE;gBACL,GAAG,OAAO,CAAC,IAAI;gBACf,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBAC7C,iBAAiB,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;gBACtC,gBAAgB,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;aACpC;YACD,MAAM,EAAE,MAAM;SACd,CAAC;IACH,CAAC;CACD;AAdD,sDAcC","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { FCMNotificationPayload } from './lyxa-fcm.service';\n\nexport enum MultiMessageType {\n\tOLD = 'old',\n\tCONSOLE = 'console',\n\tDEFAULT = 'default',\n}\n\nexport interface IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;\n}\n\nexport class FirebaseMessageBuilderFactory {\n\tpublic buildMessage(\n\t\ttype: MultiMessageType,\n\t\tpayload: FCMNotificationPayload,\n\t\ttokens: string[]\n\t): messaging.MulticastMessage {\n\t\tswitch (type) {\n\t\t\tcase MultiMessageType.CONSOLE:\n\t\t\t\treturn new ConsoleMessageBuilder().buildMessage(payload, tokens);\n\t\t\tcase MultiMessageType.OLD:\n\t\t\t\treturn new OldMessageBuilder().buildMessage(payload, tokens);\n\t\t\t// case MultiMessageType.DEFAULT:\n\t\t\t// \treturn new DefaultMessageBuilder().buildMessage(payload, tokens);\n\t\t\tdefault:\n\t\t\t\treturn new DefaultMessageBuilder().buildMessage(payload, tokens);\n\t\t}\n\t}\n}\n\nexport class DefaultMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\treturn {\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: tokens,\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\t}\n}\n\nexport class OldMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): 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: tokens,\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\nexport class ConsoleMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\t\treturn {\n\t\t\tdata: {\n\t\t\t\t...payload.data,\n\t\t\t\tchannelId: isInvisible ? 'silent' : channelId,\n\t\t\t\tnotificationTitle: payload.title ?? '',\n\t\t\t\tnotificationBody: payload.body ?? '',\n\t\t\t},\n\t\t\ttokens: tokens,\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"firebase-message.builder.js","sourceRoot":"/","sources":["libraries/notification/firebase-message.builder.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA0B;AAE1B,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,+BAAW,CAAA;IACX,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,mDAA+B,CAAA;AAChC,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAMD,MAAa,6BAA6B;IAClC,YAAY,CAClB,IAAsB,EACtB,OAA+B,EAC/B,MAAgB;QAEhB,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,gBAAgB,CAAC,OAAO;gBAC5B,OAAO,IAAI,qBAAqB,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAClE,KAAK,gBAAgB,CAAC,GAAG;gBACxB,OAAO,IAAI,iBAAiB,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC9D,KAAK,gBAAgB,CAAC,aAAa;gBAClC,OAAO,IAAI,0BAA0B,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAGvE;gBACC,OAAO,IAAI,qBAAqB,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;IACF,CAAC;CACD;AAnBD,sEAmBC;AAED,MAAa,qBAAqB;IACjC,YAAY,CAAC,OAA+B,EAAE,MAAgB;QAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;QAC/C,MAAM,S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C,IAAK,CAAC,KAAK;wBAC3B,eAAe,EAAE,EAAE,MAAM,EAAE,OAAQ,CAAC,IAAK,CAAC,MAAM,EAAE,UAAU,EAAE,OAAQ,CAAC,IAAK,CAAC,oBAAoB,EAAE;qBACnG;iBACD;gBACD,OAAO,EAAE;oBACR,gBAAgB,EAAE,cAAc;oBAChC,eAAe,EAAE,IAAI;oBACrB,YAAY,EAAE,qCAAqC;iBACnD;aACD;SACD,CAAC;IACH,CAAC;CACD;AA5BD,gEA4BC","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { FCMNotificationPayload } from './lyxa-fcm.service';\nimport dayjs from 'dayjs';\n\nexport enum MultiMessageType {\n\tOLD = 'old',\n\tCONSOLE = 'console',\n\tDEFAULT = 'default',\n\tLIVE_ACTIVITY = 'live_activity'\n}\n\nexport interface IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage;\n}\n\nexport class FirebaseMessageBuilderFactory {\n\tpublic buildMessage(\n\t\ttype: MultiMessageType,\n\t\tpayload: FCMNotificationPayload,\n\t\ttokens: string[]\n\t): messaging.MulticastMessage {\n\t\tswitch (type) {\n\t\t\tcase MultiMessageType.CONSOLE:\n\t\t\t\treturn new ConsoleMessageBuilder().buildMessage(payload, tokens);\n\t\t\tcase MultiMessageType.OLD:\n\t\t\t\treturn new OldMessageBuilder().buildMessage(payload, tokens);\n\t\t\tcase MultiMessageType.LIVE_ACTIVITY:\n\t\t\t\treturn new LiveActivityMessageBuilder().buildMessage(payload, tokens);\n\t\t\t// case MultiMessageType.DEFAULT:\n\t\t\t// \treturn new DefaultMessageBuilder().buildMessage(payload, tokens);\n\t\t\tdefault:\n\t\t\t\treturn new DefaultMessageBuilder().buildMessage(payload, tokens);\n\t\t}\n\t}\n}\n\nexport class DefaultMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\treturn {\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: tokens,\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\t}\n}\n\nexport class OldMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): 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: tokens,\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\nexport class ConsoleMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\tconst isInvisible = payload.invisible === true;\n\t\tconst channelId = payload.sound ? 'order_alert' : 'default';\n\t\treturn {\n\t\t\tdata: {\n\t\t\t\t...payload.data,\n\t\t\t\tchannelId: isInvisible ? 'silent' : channelId,\n\t\t\t\tnotificationTitle: payload.title ?? '',\n\t\t\t\tnotificationBody: payload.body ?? '',\n\t\t\t},\n\t\t\ttokens: tokens,\n\t\t};\n\t}\n}\n\nexport class LiveActivityMessageBuilder implements IFirebaseMessageBuilder {\n\tbuildMessage(payload: FCMNotificationPayload, tokens: string[]): messaging.MulticastMessage {\n\t\t// const isInvisible = payload.invisible === true;\n\t\t// const channelId = payload.sound ? 'order_alert' : 'default';\n\n\t\treturn {\n\t\t\t// data: { ...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: tokens,\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\ttimestamp: dayjs().unix(),\n\t\t\t\t\t\tevent: payload!.data!.event,\n\t\t\t\t\t\t'content-state': { status: payload!.data!.status, etaMinutes: payload!.data!.deliveryETAInMinutes },\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': 'liveactivity',\n\t\t\t\t\t'apns-priority': '10',\n\t\t\t\t\t'apns-topic': 'com.lyxa.app.push-type.liveactivity',\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n}\n"]}
@@ -10,6 +10,8 @@ export interface NotificationEventData {
10
10
  clickableUrl?: string | null;
11
11
  notificationType?: PushNotificationEventType;
12
12
  saveNotification?: boolean;
13
+ isLiveActivity?: boolean;
14
+ tokens?: string[];
13
15
  [key: string]: any;
14
16
  }
15
17
  export type NotificationGlobalEventData = Omit<NotificationEventData, 'recipientId'>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/notification/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqG;AACrG,kDAA+C;AAyB/C,MAAa,iBAAkB,SAAQ,qBAAgC;IACtE,YACC,OAEC;QAED,MAAM,YAAY,GAA0B;YAC3C,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrC,CAAC;CACD;AAjBD,8CAiBC;AAED,MAAa,uBAAwB,SAAQ,qBAAsC;IAClF,YACC,OAEC;QAED,MAAM,YAAY,GAAgC;YACjD,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;CACD;AAjBD,0DAiBC","sourcesContent":["import { ClickType, NotificationAccountType, PushNotificationEventType } from '../../utilities/enum';\nimport { BaseEvent } from '../event/BaseEvent';\nimport mongoose from 'mongoose';\nimport { FCMNotificationPayload } from './lyxa-fcm.service';\n\nexport interface NotificationEventData {\n\taccountType: NotificationAccountType;\n\trecipientId: mongoose.Types.ObjectId;\n\tisClickable: boolean;\n\tclickType?: ClickType | null;\n\tclickableUrl?: string | null;\n\tnotificationType?: PushNotificationEventType;\n\tsaveNotification?: boolean;\n\t[key: string]: any;\n}\n\nexport type NotificationGlobalEventData = Omit<NotificationEventData, 'recipientId'>;\n\nexport interface NotificationEventType extends Omit<FCMNotificationPayload, 'data'> {\n\tdata: NotificationEventData;\n}\n\nexport interface NotificationGlobalEventType extends Omit<FCMNotificationPayload, 'data'> {\n\tdata: NotificationGlobalEventData;\n}\n\nexport class NotificationEvent extends BaseEvent<NotificationEventType> {\n\tconstructor(\n\t\tpayload: Partial<Omit<NotificationEventType, 'data'>> & {\n\t\t\tdata: Partial<NotificationEventData> & { recipientId: mongoose.Types.ObjectId };\n\t\t}\n\t) {\n\t\tconst finalPayload: NotificationEventType = {\n\t\t\t...payload,\n\t\t\tdata: {\n\t\t\t\tisClickable: false,\n\t\t\t\taccountType: NotificationAccountType.USER,\n\t\t\t\t...payload.data,\n\t\t\t},\n\t\t};\n\n\t\tsuper('notification', finalPayload);\n\t}\n}\n\nexport class NotificationGlobalEvent extends BaseEvent<NotificationGlobalEventType> {\n\tconstructor(\n\t\tpayload: Partial<Omit<NotificationGlobalEventType, 'data'>> & {\n\t\t\tdata?: Partial<NotificationGlobalEventData>;\n\t\t}\n\t) {\n\t\tconst finalPayload: NotificationGlobalEventType = {\n\t\t\t...payload,\n\t\t\tdata: {\n\t\t\t\tisClickable: false,\n\t\t\t\taccountType: NotificationAccountType.USER,\n\t\t\t\t...payload.data,\n\t\t\t},\n\t\t};\n\n\t\tsuper('notification-global', finalPayload);\n\t}\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/notification/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqG;AACrG,kDAA+C;AA2B/C,MAAa,iBAAkB,SAAQ,qBAAgC;IACtE,YACC,OAEC;QAED,MAAM,YAAY,GAA0B;YAC3C,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrC,CAAC;CACD;AAjBD,8CAiBC;AAED,MAAa,uBAAwB,SAAQ,qBAAsC;IAClF,YACC,OAEC;QAED,MAAM,YAAY,GAAgC;YACjD,GAAG,OAAO;YACV,IAAI,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,GAAG,OAAO,CAAC,IAAI;aACf;SACD,CAAC;QAEF,KAAK,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC;CACD;AAjBD,0DAiBC","sourcesContent":["import { ClickType, NotificationAccountType, PushNotificationEventType } from '../../utilities/enum';\nimport { BaseEvent } from '../event/BaseEvent';\nimport mongoose from 'mongoose';\nimport { FCMNotificationPayload } from './lyxa-fcm.service';\n\nexport interface NotificationEventData {\n\taccountType: NotificationAccountType;\n\trecipientId: mongoose.Types.ObjectId;\n\tisClickable: boolean;\n\tclickType?: ClickType | null;\n\tclickableUrl?: string | null;\n\tnotificationType?: PushNotificationEventType;\n\tsaveNotification?: boolean;\n\tisLiveActivity?: boolean\n\ttokens?: string[]\n\t[key: string]: any;\n}\n\nexport type NotificationGlobalEventData = Omit<NotificationEventData, 'recipientId'>;\n\nexport interface NotificationEventType extends Omit<FCMNotificationPayload, 'data'> {\n\tdata: NotificationEventData;\n}\n\nexport interface NotificationGlobalEventType extends Omit<FCMNotificationPayload, 'data'> {\n\tdata: NotificationGlobalEventData;\n}\n\nexport class NotificationEvent extends BaseEvent<NotificationEventType> {\n\tconstructor(\n\t\tpayload: Partial<Omit<NotificationEventType, 'data'>> & {\n\t\t\tdata: Partial<NotificationEventData> & { recipientId: mongoose.Types.ObjectId };\n\t\t}\n\t) {\n\t\tconst finalPayload: NotificationEventType = {\n\t\t\t...payload,\n\t\t\tdata: {\n\t\t\t\tisClickable: false,\n\t\t\t\taccountType: NotificationAccountType.USER,\n\t\t\t\t...payload.data,\n\t\t\t},\n\t\t};\n\n\t\tsuper('notification', finalPayload);\n\t}\n}\n\nexport class NotificationGlobalEvent extends BaseEvent<NotificationGlobalEventType> {\n\tconstructor(\n\t\tpayload: Partial<Omit<NotificationGlobalEventType, 'data'>> & {\n\t\t\tdata?: Partial<NotificationGlobalEventData>;\n\t\t}\n\t) {\n\t\tconst finalPayload: NotificationGlobalEventType = {\n\t\t\t...payload,\n\t\t\tdata: {\n\t\t\t\tisClickable: false,\n\t\t\t\taccountType: NotificationAccountType.USER,\n\t\t\t\t...payload.data,\n\t\t\t},\n\t\t};\n\n\t\tsuper('notification-global', finalPayload);\n\t}\n}"]}
@@ -32,6 +32,10 @@ let LyxaFcmSender = class LyxaFcmSender {
32
32
  if (!tokens.length)
33
33
  return { failedTokens: [], tokensToDelete: [] };
34
34
  const messages = this.buildMultiCastMessages(type, tokens, payload);
35
+ console.log({ project, type, payload, messages });
36
+ console.log("notification: ", messages[0].notification);
37
+ console.log("notification: ", messages[0].tokens);
38
+ console.log("notification: ", messages[0].apns);
35
39
  return await this.sendToAllTokens(project, type, payload, messages);
36
40
  }
37
41
  buildMultiCastMessages(type, tokens, payload) {
@@ -52,6 +56,11 @@ let LyxaFcmSender = class LyxaFcmSender {
52
56
  await Promise.all(messages.map(async (message) => {
53
57
  let logData;
54
58
  try {
59
+ console.log("fcm service send message: ", { project, message });
60
+ console.log("sendToAllTokens: ", messages[0].apns?.payload);
61
+ console.log("sendToAllTokens: ", messages[0].apns?.headers);
62
+ console.log("sendToAllTokens: ", messages[0].apns?.liveActivityToken);
63
+ console.log("sendToAllTokens: ", messages[0].apns?.fcmOptions);
55
64
  const result = await this.fcmService.sendMessage(project, message);
56
65
  const payloadKnownValid = result.successCount > 0;
57
66
  result.responses.forEach((r, i) => {
@@ -1 +1 @@
1
- {"version":3,"file":"lyxa-fcm-sender.js","sourceRoot":"/","sources":["libraries/notification/lyxa-fcm-sender.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mCAAiC;AACjC,iEAA4D;AAC5D,yEAA6F;AAG7F,6BAAqC;AAU9B,IAAM,aAAa,GAAnB,MAAM,aAAa;;IAsBP;IACA;IAtBX,MAAM,CAAU,SAAS,GAAG,GAAG,CAAC;IAa/B,MAAM,CAAU,2BAA2B,GAAwB,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AAI,CAAC,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7B,IAAI,eAAa,CAAC,2BAA2B,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC;QAC1E,IAAI,SAAS,KAAK,4BAA4B;YAAE,OAAO,iBAAiB,CAAC;QACzE,OAAO,KAAK,CAAC;IACd,CAAC;;AA/JW,sCAAa;wBAAb,aAAa;IADzB,IAAA,gBAAO,GAAE;qCAuBqB,yCAAkB;QACrB,wDAA6B;GAvB5C,aAAa,CAgKzB","sourcesContent":["import { Service } from 'typedi';\nimport { FirebaseFcmService } from './firebase-fcm.service';\nimport { FirebaseMessageBuilderFactory, MultiMessageType } from './firebase-message.builder';\nimport { messaging } from 'firebase-admin';\nimport { FCMNotificationPayload, FcmProject } from './lyxa-fcm.service';\nimport { getLibraries } from '../..';\n\nexport interface FcmSendResult {\n\t/** Every token that failed to receive the message, for any reason. */\n\tfailedTokens: string[];\n\t/** Subset of failedTokens that are confirmed invalid and must be deleted. */\n\ttokensToDelete: string[];\n}\n\n@Service()\nexport class LyxaFcmSender {\n\tpublic static readonly MAX_BATCH = 500;\n\n\t/**\n\t * FCM error codes that unambiguously mean the registration token itself is\n\t * malformed or no longer registered, so it will never be valid again and is\n\t * safe to delete from our records.\n\t *\n\t * Everything else (server/internal errors, rate limits, auth/credential\n\t * issues, transport failures) is transient and must NOT cause deletion.\n\t *\n\t * @see https://firebase.google.com/docs/cloud-messaging/manage-tokens#ensuring-registration-token-freshness\n\t * @see https://firebase.google.com/docs/cloud-messaging/manage-tokens\n\t */\n\tprivate static readonly REMOVABLE_TOKEN_ERROR_CODES: ReadonlySet<string> = new Set([\n\t\t// UNREGISTERED (404): token was unregistered (app uninstalled / token refreshed).\n\t\t'messaging/registration-token-not-registered',\n\t\t// Token is not a valid FCM registration token (wrong format).\n\t\t'messaging/invalid-registration-token',\n\t]);\n\n\tconstructor(\n\t\tprivate readonly fcmService: FirebaseFcmService,\n\t\tprivate readonly builder: FirebaseMessageBuilderFactory\n\t) {}\n\n\t/**\n\t * Sends notifications and reports the outcome. `failedTokens` contains every\n\t * failure; `tokensToDelete` is the subset that is confirmed invalid and must\n\t * be removed from our records. Transient failures stay out of\n\t * `tokensToDelete` so they never trigger token deletion.\n\t */\n\tpublic async sendMessages(\n\t\tproject: FcmProject,\n\t\ttype: MultiMessageType,\n\t\ttokens: string[],\n\t\tpayload: FCMNotificationPayload\n\t): Promise<FcmSendResult> {\n\t\tif (!tokens.length) return { failedTokens: [], tokensToDelete: [] };\n\t\tconst messages = this.buildMultiCastMessages(type, tokens, payload);\n\t\treturn await this.sendToAllTokens(project, type, payload, messages);\n\t}\n\n\tprivate buildMultiCastMessages(\n\t\ttype: MultiMessageType,\n\t\ttokens: string[],\n\t\tpayload: FCMNotificationPayload\n\t): messaging.MulticastMessage[] {\n\t\tconst tokenChunks = this.chunkArray(tokens, LyxaFcmSender.MAX_BATCH);\n\t\treturn tokenChunks.map(chunk => this.builder.buildMessage(type, payload, chunk));\n\t}\n\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 async sendToAllTokens(\n\t\tproject: FcmProject,\n\t\ttype: MultiMessageType,\n\t\tpayload: FCMNotificationPayload,\n\t\tmessages: messaging.MulticastMessage[]\n\t): Promise<FcmSendResult> {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst failedTokens: string[] = [];\n\t\tconst tokensToDelete: string[] = [];\n\n\t\tawait Promise.all(\n\t\t\tmessages.map(async message => {\n\t\t\t\tlet logData: Record<string, unknown>;\n\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.fcmService.sendMessage(project, message);\n\n\t\t\t\t\t// A sibling token succeeding with the identical payload proves the\n\t\t\t\t\t// payload is valid, which is required before treating an\n\t\t\t\t\t// INVALID_ARGUMENT error as a bad token (see shouldRemoveToken).\n\t\t\t\t\tconst payloadKnownValid = result.successCount > 0;\n\n\t\t\t\t\tresult.responses.forEach((r, i) => {\n\t\t\t\t\t\tif (r.success) return;\n\t\t\t\t\t\tfailedTokens.push(message.tokens[i]);\n\t\t\t\t\t\tif (this.shouldRemoveToken(r.error?.code, payloadKnownValid)) {\n\t\t\t\t\t\t\ttokensToDelete.push(message.tokens[i]);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tlogData = {\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tconsoleNotification: type === MultiMessageType.CONSOLE,\n\t\t\t\t\t\tgroupTokens: message.tokens,\n\t\t\t\t\t\tgroupPayload: payload,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tsuccessCount: result.successCount,\n\t\t\t\t\t\t\tfailureCount: result.failureCount,\n\t\t\t\t\t\t\tresponses: result.responses.map((r, i) => ({\n\t\t\t\t\t\t\t\ttoken: message.tokens[i],\n\t\t\t\t\t\t\t\tsuccess: r.success,\n\t\t\t\t\t\t\t\t...(r.error && {\n\t\t\t\t\t\t\t\t\terrorCode: r.error.code,\n\t\t\t\t\t\t\t\t\terrorMessage: r.error.message,\n\t\t\t\t\t\t\t\t\twillDelete: this.shouldRemoveToken(r.error.code, payloadKnownValid),\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tlogger.info('Called Firebase function sendEachForMulticast', {\n\t\t\t\t\t\ttag: 'notification.attempted.new',\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t});\n\t\t\t\t} catch (err) {\n\t\t\t\t\t// The whole batch send threw (transport/auth/infra failure), not a\n\t\t\t\t\t// per-token rejection. They count as failed, but are not proven\n\t\t\t\t\t// invalid, so they must not be deleted.\n\t\t\t\t\tfailedTokens.push(...message.tokens);\n\n\t\t\t\t\tlogData = {\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tconsoleNotification: type === MultiMessageType.CONSOLE,\n\t\t\t\t\t\tgroupTokens: message.tokens,\n\t\t\t\t\t\tgroupPayload: payload,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t};\n\t\t\t\t\tlogger.error('Called Firebase function sendEachForMulticast', err, {\n\t\t\t\t\t\ttag: 'notification.attempted.new',\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\n\t\treturn { failedTokens, tokensToDelete };\n\t}\n\n\t/**\n\t * Decides whether a per-token FCM failure means the token should be removed.\n\t *\n\t * Only the codes in {@link LyxaFcmSender.REMOVABLE_TOKEN_ERROR_CODES} are\n\t * unconditionally removable. `messaging/invalid-argument` (INVALID_ARGUMENT)\n\t * is special: Firebase notes it \"can also be returned in cases of issues in\n\t * the message payload, so it signals an invalid token only if the payload is\n\t * completely valid.\" We therefore only remove on it when we know the payload\n\t * was valid (a sibling token in the same batch succeeded).\n\t *\n\t * @see https://firebase.google.com/docs/cloud-messaging/manage-tokens\n\t */\n\tprivate shouldRemoveToken(errorCode: string | undefined, payloadKnownValid: boolean): boolean {\n\t\tif (!errorCode) return false;\n\t\tif (LyxaFcmSender.REMOVABLE_TOKEN_ERROR_CODES.has(errorCode)) return true;\n\t\tif (errorCode === 'messaging/invalid-argument') return payloadKnownValid;\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"file":"lyxa-fcm-sender.js","sourceRoot":"/","sources":["libraries/notification/lyxa-fcm-sender.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mCAAiC;AACjC,iEAA4D;AAC5D,yEAA6F;AAG7F,6BAAqC;AAU9B,IAAM,aAAa,GAAnB,MAAM,aAAa;;IAsBP;IACA;IAtBX,MAAM,CAAU,S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,GAAE;qCAuBqB,yCAAkB;QACrB,wDAA6B;GAvB5C,aAAa,CAyKzB","sourcesContent":["import { Service } from 'typedi';\nimport { FirebaseFcmService } from './firebase-fcm.service';\nimport { FirebaseMessageBuilderFactory, MultiMessageType } from './firebase-message.builder';\nimport { messaging } from 'firebase-admin';\nimport { FCMNotificationPayload, FcmProject } from './lyxa-fcm.service';\nimport { getLibraries } from '../..';\n\nexport interface FcmSendResult {\n\t/** Every token that failed to receive the message, for any reason. */\n\tfailedTokens: string[];\n\t/** Subset of failedTokens that are confirmed invalid and must be deleted. */\n\ttokensToDelete: string[];\n}\n\n@Service()\nexport class LyxaFcmSender {\n\tpublic static readonly MAX_BATCH = 500;\n\n\t/**\n\t * FCM error codes that unambiguously mean the registration token itself is\n\t * malformed or no longer registered, so it will never be valid again and is\n\t * safe to delete from our records.\n\t *\n\t * Everything else (server/internal errors, rate limits, auth/credential\n\t * issues, transport failures) is transient and must NOT cause deletion.\n\t *\n\t * @see https://firebase.google.com/docs/cloud-messaging/manage-tokens#ensuring-registration-token-freshness\n\t * @see https://firebase.google.com/docs/cloud-messaging/manage-tokens\n\t */\n\tprivate static readonly REMOVABLE_TOKEN_ERROR_CODES: ReadonlySet<string> = new Set([\n\t\t// UNREGISTERED (404): token was unregistered (app uninstalled / token refreshed).\n\t\t'messaging/registration-token-not-registered',\n\t\t// Token is not a valid FCM registration token (wrong format).\n\t\t'messaging/invalid-registration-token',\n\t]);\n\n\tconstructor(\n\t\tprivate readonly fcmService: FirebaseFcmService,\n\t\tprivate readonly builder: FirebaseMessageBuilderFactory\n\t) {}\n\n\t/**\n\t * Sends notifications and reports the outcome. `failedTokens` contains every\n\t * failure; `tokensToDelete` is the subset that is confirmed invalid and must\n\t * be removed from our records. Transient failures stay out of\n\t * `tokensToDelete` so they never trigger token deletion.\n\t */\n\tpublic async sendMessages(\n\t\tproject: FcmProject,\n\t\ttype: MultiMessageType,\n\t\ttokens: string[],\n\t\tpayload: FCMNotificationPayload\n\t): Promise<FcmSendResult> {\n\t\tif (!tokens.length) return { failedTokens: [], tokensToDelete: [] };\n\t\tconst messages = this.buildMultiCastMessages(type, tokens, payload);\t\t\n\t\tconsole.log({ project, type, payload, messages })\n\t\tconsole.log(\"notification: \", messages[0].notification)\n\t\tconsole.log(\"notification: \", messages[0].tokens)\n\t\tconsole.log(\"notification: \", messages[0].apns)\n\t\treturn await this.sendToAllTokens(project, type, payload, messages);\n\t}\n\n\tprivate buildMultiCastMessages(\n\t\ttype: MultiMessageType,\n\t\ttokens: string[],\n\t\tpayload: FCMNotificationPayload\n\t): messaging.MulticastMessage[] {\n\t\tconst tokenChunks = this.chunkArray(tokens, LyxaFcmSender.MAX_BATCH);\n\t\treturn tokenChunks.map(chunk => this.builder.buildMessage(type, payload, chunk));\n\t}\n\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 async sendToAllTokens(\n\t\tproject: FcmProject,\n\t\ttype: MultiMessageType,\n\t\tpayload: FCMNotificationPayload,\n\t\tmessages: messaging.MulticastMessage[]\n\t): Promise<FcmSendResult> {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst failedTokens: string[] = [];\n\t\tconst tokensToDelete: string[] = [];\n\n\t\tawait Promise.all(\n\t\t\tmessages.map(async message => {\n\t\t\t\tlet logData: Record<string, unknown>;\n\n\t\t\t\ttry {\n\t\t\t\t\tconsole.log(\"fcm service send message: \",{ project, message })\n\t\t\t\t\tconsole.log(\"sendToAllTokens: \", messages[0].apns?.payload)\n\t\t\t\t\tconsole.log(\"sendToAllTokens: \", messages[0].apns?.headers)\n\t\t\t\t\tconsole.log(\"sendToAllTokens: \", messages[0].apns?.liveActivityToken)\n\t\t\t\t\tconsole.log(\"sendToAllTokens: \", messages[0].apns?.fcmOptions)\n\t\t\t\t\tconst result = await this.fcmService.sendMessage(project, message);\n\n\t\t\t\t\t// A sibling token succeeding with the identical payload proves the\n\t\t\t\t\t// payload is valid, which is required before treating an\n\t\t\t\t\t// INVALID_ARGUMENT error as a bad token (see shouldRemoveToken).\n\t\t\t\t\tconst payloadKnownValid = result.successCount > 0;\n\n\t\t\t\t\tresult.responses.forEach((r, i) => {\n\t\t\t\t\t\tif (r.success) return;\n\t\t\t\t\t\tfailedTokens.push(message.tokens[i]);\n\t\t\t\t\t\tif (this.shouldRemoveToken(r.error?.code, payloadKnownValid)) {\n\t\t\t\t\t\t\ttokensToDelete.push(message.tokens[i]);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tlogData = {\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tconsoleNotification: type === MultiMessageType.CONSOLE,\n\t\t\t\t\t\tgroupTokens: message.tokens,\n\t\t\t\t\t\tgroupPayload: payload,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tsuccessCount: result.successCount,\n\t\t\t\t\t\t\tfailureCount: result.failureCount,\n\t\t\t\t\t\t\tresponses: result.responses.map((r, i) => ({\n\t\t\t\t\t\t\t\ttoken: message.tokens[i],\n\t\t\t\t\t\t\t\tsuccess: r.success,\n\t\t\t\t\t\t\t\t...(r.error && {\n\t\t\t\t\t\t\t\t\terrorCode: r.error.code,\n\t\t\t\t\t\t\t\t\terrorMessage: r.error.message,\n\t\t\t\t\t\t\t\t\twillDelete: this.shouldRemoveToken(r.error.code, payloadKnownValid),\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tlogger.info('Called Firebase function sendEachForMulticast', {\n\t\t\t\t\t\ttag: 'notification.attempted.new',\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t});\n\t\t\t\t} catch (err) {\n\t\t\t\t\t// The whole batch send threw (transport/auth/infra failure), not a\n\t\t\t\t\t// per-token rejection. They count as failed, but are not proven\n\t\t\t\t\t// invalid, so they must not be deleted.\n\t\t\t\t\tfailedTokens.push(...message.tokens);\n\n\t\t\t\t\tlogData = {\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tconsoleNotification: type === MultiMessageType.CONSOLE,\n\t\t\t\t\t\tgroupTokens: message.tokens,\n\t\t\t\t\t\tgroupPayload: payload,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t};\n\t\t\t\t\tlogger.error('Called Firebase function sendEachForMulticast', err, {\n\t\t\t\t\t\ttag: 'notification.attempted.new',\n\t\t\t\t\t\tdata: logData,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\n\t\treturn { failedTokens, tokensToDelete };\n\t}\n\n\t/**\n\t * Decides whether a per-token FCM failure means the token should be removed.\n\t *\n\t * Only the codes in {@link LyxaFcmSender.REMOVABLE_TOKEN_ERROR_CODES} are\n\t * unconditionally removable. `messaging/invalid-argument` (INVALID_ARGUMENT)\n\t * is special: Firebase notes it \"can also be returned in cases of issues in\n\t * the message payload, so it signals an invalid token only if the payload is\n\t * completely valid.\" We therefore only remove on it when we know the payload\n\t * was valid (a sibling token in the same batch succeeded).\n\t *\n\t * @see https://firebase.google.com/docs/cloud-messaging/manage-tokens\n\t */\n\tprivate shouldRemoveToken(errorCode: string | undefined, payloadKnownValid: boolean): boolean {\n\t\tif (!errorCode) return false;\n\t\tif (LyxaFcmSender.REMOVABLE_TOKEN_ERROR_CODES.has(errorCode)) return true;\n\t\tif (errorCode === 'messaging/invalid-argument') return payloadKnownValid;\n\t\treturn false;\n\t}\n}\n"]}
@@ -33,6 +33,7 @@ export declare class LyxaFcmService {
33
33
  private separateTokens;
34
34
  static getProjectForAccountType(accountType: NotificationAccountType): FcmProject;
35
35
  sendToTokens(project: FcmProject, payload: FCMNotificationPayload, targets: NotificationTokenTarget[]): Promise<FcmSendResult>;
36
+ sendToTokensToSpecificMultiMessageType(project: FcmProject, payload: FCMNotificationPayload, targets: NotificationTokenTarget[]): Promise<FcmSendResult>;
36
37
  private isNotifiableEntityType;
37
38
  private isConsoleEntityType;
38
39
  private compareVersions;
@@ -136,6 +136,27 @@ let LyxaFcmService = class LyxaFcmService {
136
136
  tokensToDelete: results.flatMap(r => r.tokensToDelete),
137
137
  };
138
138
  }
139
+ async sendToTokensToSpecificMultiMessageType(project, payload, targets) {
140
+ if (!targets.length)
141
+ return { failedTokens: [], tokensToDelete: [] };
142
+ console.log('targets', targets);
143
+ const cleanedTargets = this.deduplicateTargets(targets);
144
+ const tokens = [];
145
+ for (let target of cleanedTargets) {
146
+ tokens.push(target.token);
147
+ }
148
+ console.log('sendToTokensToSpecificMultiMessageType ', { project });
149
+ console.log('sendToTokensToSpecificMultiMessageType ', { tokens });
150
+ console.log('sendToTokensToSpecificMultiMessageType ', { payload });
151
+ const results = await Promise.all([
152
+ this.lyxaFcmSender.sendMessages(project, firebase_message_builder_1.MultiMessageType.LIVE_ACTIVITY, tokens, payload),
153
+ ]);
154
+ console.log({ results });
155
+ return {
156
+ failedTokens: results.flatMap(r => r.failedTokens),
157
+ tokensToDelete: results.flatMap(r => r.tokensToDelete),
158
+ };
159
+ }
139
160
  isNotifiableEntityType(type) {
140
161
  return (type === enum_1.NotificationAccountType.USER ||
141
162
  type === enum_1.NotificationAccountType.RIDER ||
@@ -1 +1 @@
1
- {"version":3,"file":"lyxa-fcm.service.js","sourceRoot":"/","sources":["libraries/notification/lyxa-fcm.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAiC;AACjC,yEAA8D;AAC9D,+CAA4E;AAC5E,uDAAiE;AACjE,6BAAqC;AAErC,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,uCAAyB,CAAA;IACzB,yCAA2B,CAAA;IAC3B,uCAAyB,CAAA;IACzB,2CAA6B,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D,CAAC;CACD,CAAA;AAxJY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,gBAAO,GAAE;qCAEmC,+BAAa;GAD7C,cAAc,CAwJ1B","sourcesContent":["import { Service } from 'typedi';\nimport { MultiMessageType } from './firebase-message.builder';\nimport { AppPlatform, NotificationAccountType } from '../../utilities/enum';\nimport { FcmSendResult, LyxaFcmSender } from './lyxa-fcm-sender';\nimport { getLibraries } from '../..';\n\nexport enum FcmProject {\n\tUSER = 'fcm.service.user',\n\tRIDER = 'fcm.service.rider',\n\tSHOP = 'fcm.service.shop',\n\tCPANEL = 'fcm.service.cpanel',\n}\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\t| NotificationAccountType.PROFESSIONAL;\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\t[NotificationAccountType.PROFESSIONAL]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.3',\n\t},\n};\n\nexport type LyxaTokens = {\n\toldTokens: string[];\n\tnewTokens: string[];\n\tconsoleTokens: string[];\n};\n\n@Service()\nexport class LyxaFcmService {\n\tconstructor(private readonly lyxaFcmSender: LyxaFcmSender) {}\n\n\tprivate deduplicateTargets(targets: NotificationTokenTarget[]): NotificationTokenTarget[] {\n\t\tconst sorted = targets.slice().sort((a, b) => {\n\t\t\tif (a.token !== b.token) return a.token < b.token ? -1 : 1;\n\t\t\tif (!a.appVersion && !b.appVersion) return 0;\n\t\t\tif (!a.appVersion) return 1;\n\t\t\tif (!b.appVersion) return -1;\n\t\t\treturn this.compareVersions(b.appVersion, a.appVersion);\n\t\t});\n\t\treturn sorted.filter((t, i) => i === 0 || t.token !== sorted[i - 1].token);\n\t}\n\n\tprivate separateTokens(targets: NotificationTokenTarget[]): LyxaTokens {\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\tif (true) {\n\t\t\tgetLibraries()\n\t\t\t\t.getLoggerKit()\n\t\t\t\t.debug('FCM token separation', {\n\t\t\t\t\ttag: 'notification.token.separated',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\ttotalTargets: targets.length,\n\t\t\t\t\t\tbuckets: {\n\t\t\t\t\t\t\told: oldTokens.length,\n\t\t\t\t\t\t\tnew: newTokens.length,\n\t\t\t\t\t\t\tconsole: consoleTokens.length,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttargets: targets.map(t => ({\n\t\t\t\t\t\t\tentityId: t.entityId,\n\t\t\t\t\t\t\tentityType: t.entityType,\n\t\t\t\t\t\t\tplatform: t.platform,\n\t\t\t\t\t\t\tappVersion: t.appVersion,\n\t\t\t\t\t\t\tbucket: this.isConsoleEntityType(t.entityType)\n\t\t\t\t\t\t\t\t? 'console'\n\t\t\t\t\t\t\t\t: this.shouldUseNewStructure(t.entityType, t.platform, t.appVersion)\n\t\t\t\t\t\t\t\t\t? 'new'\n\t\t\t\t\t\t\t\t\t: 'old',\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\toldTokens,\n\t\t\tnewTokens,\n\t\t\tconsoleTokens,\n\t\t};\n\t}\n\n\tpublic static getProjectForAccountType(accountType: NotificationAccountType): FcmProject {\n\t\tswitch (accountType) {\n\t\t\tcase NotificationAccountType.USER:\n\t\t\t\treturn FcmProject.USER;\n\t\t\tcase NotificationAccountType.SHOP:\n\t\t\tcase NotificationAccountType.PROFESSIONAL:\n\t\t\t\treturn FcmProject.SHOP;\n\t\t\tcase NotificationAccountType.RIDER:\n\t\t\t\treturn FcmProject.RIDER;\n\t\t\tdefault:\n\t\t\t\treturn FcmProject.USER;\n\t\t}\n\t}\n\n\tpublic async sendToTokens(\n\t\tproject: FcmProject,\n\t\tpayload: FCMNotificationPayload,\n\t\ttargets: NotificationTokenTarget[]\n\t): Promise<FcmSendResult> {\n\t\tif (!targets.length) return { failedTokens: [], tokensToDelete: [] };\n\t\tconsole.log('targets', targets);\n\t\tconst cleanedTargets = this.deduplicateTargets(targets);\n\t\tconsole.log('cleanedTargets', cleanedTargets);\n\t\tconst tokens = this.separateTokens(cleanedTargets);\n\n\t\tconst results = await Promise.all([\n\t\t\tthis.lyxaFcmSender.sendMessages(project, MultiMessageType.OLD, tokens.oldTokens, payload),\n\t\t\tthis.lyxaFcmSender.sendMessages(project, MultiMessageType.DEFAULT, tokens.newTokens, payload),\n\t\t\tthis.lyxaFcmSender.sendMessages(\n\t\t\t\tFcmProject.CPANEL,\n\t\t\t\tMultiMessageType.CONSOLE,\n\t\t\t\ttokens.consoleTokens,\n\t\t\t\tpayload\n\t\t\t),\n\t\t]);\n\n\t\treturn {\n\t\t\tfailedTokens: results.flatMap(r => r.failedTokens),\n\t\t\ttokensToDelete: results.flatMap(r => r.tokensToDelete),\n\t\t};\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\ttype === NotificationAccountType.PROFESSIONAL\n\t\t);\n\t}\n\n\tprivate isConsoleEntityType(type: NotificationAccountType): type is NotifiableEntityType {\n\t\treturn (\n\t\t\ttype === NotificationAccountType.SHOP_CONSOLE ||\n\t\t\ttype === NotificationAccountType.PARENT ||\n\t\t\ttype === NotificationAccountType.VENDOR ||\n\t\t\ttype === NotificationAccountType.VENDOR_PARENT\n\t\t);\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 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"]}
1
+ {"version":3,"file":"lyxa-fcm.service.js","sourceRoot":"/","sources":["libraries/notification/lyxa-fcm.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAiC;AACjC,yEAA8D;AAC9D,+CAA4E;AAC5E,uDAAiE;AACjE,6BAAqC;AAErC,IAAY,UAKX;AALD,WAAY,UAAU;IAC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lLY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,gBAAO,GAAE;qCAEmC,+BAAa;GAD7C,cAAc,CAkL1B","sourcesContent":["import { Service } from 'typedi';\nimport { MultiMessageType } from './firebase-message.builder';\nimport { AppPlatform, NotificationAccountType } from '../../utilities/enum';\nimport { FcmSendResult, LyxaFcmSender } from './lyxa-fcm-sender';\nimport { getLibraries } from '../..';\n\nexport enum FcmProject {\n\tUSER = 'fcm.service.user',\n\tRIDER = 'fcm.service.rider',\n\tSHOP = 'fcm.service.shop',\n\tCPANEL = 'fcm.service.cpanel',\n}\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\t| NotificationAccountType.PROFESSIONAL;\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\t[NotificationAccountType.PROFESSIONAL]: {\n\t\t[AppPlatform.IOS]: '2.0.3',\n\t\t[AppPlatform.ANDROID]: '2.0.3',\n\t},\n};\n\nexport type LyxaTokens = {\n\toldTokens: string[];\n\tnewTokens: string[];\n\tconsoleTokens: string[];\n};\n\n@Service()\nexport class LyxaFcmService {\n\tconstructor(private readonly lyxaFcmSender: LyxaFcmSender) {}\n\n\tprivate deduplicateTargets(targets: NotificationTokenTarget[]): NotificationTokenTarget[] {\n\t\tconst sorted = targets.slice().sort((a, b) => {\n\t\t\tif (a.token !== b.token) return a.token < b.token ? -1 : 1;\n\t\t\tif (!a.appVersion && !b.appVersion) return 0;\n\t\t\tif (!a.appVersion) return 1;\n\t\t\tif (!b.appVersion) return -1;\n\t\t\treturn this.compareVersions(b.appVersion, a.appVersion);\n\t\t});\n\t\treturn sorted.filter((t, i) => i === 0 || t.token !== sorted[i - 1].token);\n\t}\n\n\tprivate separateTokens(targets: NotificationTokenTarget[]): LyxaTokens {\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\tif (true) {\n\t\t\tgetLibraries()\n\t\t\t\t.getLoggerKit()\n\t\t\t\t.debug('FCM token separation', {\n\t\t\t\t\ttag: 'notification.token.separated',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\ttotalTargets: targets.length,\n\t\t\t\t\t\tbuckets: {\n\t\t\t\t\t\t\told: oldTokens.length,\n\t\t\t\t\t\t\tnew: newTokens.length,\n\t\t\t\t\t\t\tconsole: consoleTokens.length,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttargets: targets.map(t => ({\n\t\t\t\t\t\t\tentityId: t.entityId,\n\t\t\t\t\t\t\tentityType: t.entityType,\n\t\t\t\t\t\t\tplatform: t.platform,\n\t\t\t\t\t\t\tappVersion: t.appVersion,\n\t\t\t\t\t\t\tbucket: this.isConsoleEntityType(t.entityType)\n\t\t\t\t\t\t\t\t? 'console'\n\t\t\t\t\t\t\t\t: this.shouldUseNewStructure(t.entityType, t.platform, t.appVersion)\n\t\t\t\t\t\t\t\t\t? 'new'\n\t\t\t\t\t\t\t\t\t: 'old',\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\toldTokens,\n\t\t\tnewTokens,\n\t\t\tconsoleTokens,\n\t\t};\n\t}\n\n\tpublic static getProjectForAccountType(accountType: NotificationAccountType): FcmProject {\n\t\tswitch (accountType) {\n\t\t\tcase NotificationAccountType.USER:\n\t\t\t\treturn FcmProject.USER;\n\t\t\tcase NotificationAccountType.SHOP:\n\t\t\tcase NotificationAccountType.PROFESSIONAL:\n\t\t\t\treturn FcmProject.SHOP;\n\t\t\tcase NotificationAccountType.RIDER:\n\t\t\t\treturn FcmProject.RIDER;\n\t\t\tdefault:\n\t\t\t\treturn FcmProject.USER;\n\t\t}\n\t}\n\n\tpublic async sendToTokens(\n\t\tproject: FcmProject,\n\t\tpayload: FCMNotificationPayload,\n\t\ttargets: NotificationTokenTarget[]\n\t): Promise<FcmSendResult> {\n\t\tif (!targets.length) return { failedTokens: [], tokensToDelete: [] };\n\t\tconsole.log('targets', targets);\n\t\tconst cleanedTargets = this.deduplicateTargets(targets);\n\t\tconsole.log('cleanedTargets', cleanedTargets);\n\t\tconst tokens = this.separateTokens(cleanedTargets);\n\n\t\tconst results = await Promise.all([\n\t\t\tthis.lyxaFcmSender.sendMessages(project, MultiMessageType.OLD, tokens.oldTokens, payload),\n\t\t\tthis.lyxaFcmSender.sendMessages(project, MultiMessageType.DEFAULT, tokens.newTokens, payload),\n\t\t\tthis.lyxaFcmSender.sendMessages(\n\t\t\t\tFcmProject.CPANEL,\n\t\t\t\tMultiMessageType.CONSOLE,\n\t\t\t\ttokens.consoleTokens,\n\t\t\t\tpayload\n\t\t\t),\n\t\t]);\n\n\t\treturn {\n\t\t\tfailedTokens: results.flatMap(r => r.failedTokens),\n\t\t\ttokensToDelete: results.flatMap(r => r.tokensToDelete),\n\t\t};\n\t}\n\n\tpublic async sendToTokensToSpecificMultiMessageType(\n\t\tproject: FcmProject,\n\t\tpayload: FCMNotificationPayload,\n\t\ttargets: NotificationTokenTarget[]\n\t): Promise<FcmSendResult> {\n\t\tif (!targets.length) return { failedTokens: [], tokensToDelete: [] };\n\t\tconsole.log('targets', targets);\n\t\tconst cleanedTargets = this.deduplicateTargets(targets);\n\n\t\tconst tokens: string[] = [];\n\t\tfor (let target of cleanedTargets) {\n\t\t\ttokens.push(target.token);\n\t\t}\n\t\tconsole.log('sendToTokensToSpecificMultiMessageType ', { project })\n\t\tconsole.log('sendToTokensToSpecificMultiMessageType ',{ tokens });\n\t\tconsole.log('sendToTokensToSpecificMultiMessageType ', { payload });\n\t\tconst results = await Promise.all([\n\t\t\tthis.lyxaFcmSender.sendMessages(project, MultiMessageType.LIVE_ACTIVITY, tokens, payload),\n\t\t]);\n\t\tconsole.log({ results });\n\t\treturn {\n\t\t\tfailedTokens: results.flatMap(r => r.failedTokens),\n\t\t\ttokensToDelete: results.flatMap(r => r.tokensToDelete),\n\t\t};\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\ttype === NotificationAccountType.PROFESSIONAL\n\t\t);\n\t}\n\n\tprivate isConsoleEntityType(type: NotificationAccountType): type is NotifiableEntityType {\n\t\treturn (\n\t\t\ttype === NotificationAccountType.SHOP_CONSOLE ||\n\t\t\ttype === NotificationAccountType.PARENT ||\n\t\t\ttype === NotificationAccountType.VENDOR ||\n\t\t\ttype === NotificationAccountType.VENDOR_PARENT\n\t\t);\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 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"]}
@@ -21,12 +21,12 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
21
21
  type: z.ZodNativeEnum<typeof UserRef>;
22
22
  }, "strip", z.ZodTypeAny, {
23
23
  type: UserRef;
24
- name: string;
25
24
  id: import("mongoose").Types.ObjectId;
25
+ name: string;
26
26
  }, {
27
27
  type: UserRef;
28
- name: string;
29
28
  id: import("mongoose").Types.ObjectId;
29
+ name: string;
30
30
  }>;
31
31
  content: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
32
32
  media: z.ZodArray<z.ZodObject<{
@@ -67,8 +67,8 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
67
67
  createdAt: Date;
68
68
  sender: {
69
69
  type: UserRef;
70
- name: string;
71
70
  id: import("mongoose").Types.ObjectId;
71
+ name: string;
72
72
  };
73
73
  senderType: UserRef;
74
74
  media: {
@@ -80,21 +80,21 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
80
80
  }[];
81
81
  chatroomType: ChatroomType;
82
82
  senderId: import("mongoose").Types.ObjectId;
83
+ orderId?: import("mongoose").Types.ObjectId | undefined;
83
84
  location?: {
84
85
  latitude?: number | undefined;
85
86
  longitude?: number | undefined;
86
87
  } | undefined;
87
- orderId?: import("mongoose").Types.ObjectId | undefined;
88
- ticketId?: import("mongoose").Types.ObjectId | undefined;
89
88
  content?: string | undefined;
89
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
90
90
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
91
91
  }, {
92
92
  _id: import("mongoose").Types.ObjectId;
93
93
  createdAt: Date;
94
94
  sender: {
95
95
  type: UserRef;
96
- name: string;
97
96
  id: import("mongoose").Types.ObjectId;
97
+ name: string;
98
98
  };
99
99
  senderType: UserRef;
100
100
  media: {
@@ -106,13 +106,13 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
106
106
  }[];
107
107
  chatroomType: ChatroomType;
108
108
  senderId: import("mongoose").Types.ObjectId;
109
+ orderId?: import("mongoose").Types.ObjectId | undefined;
109
110
  location?: {
110
111
  latitude?: number | undefined;
111
112
  longitude?: number | undefined;
112
113
  } | undefined;
113
- orderId?: import("mongoose").Types.ObjectId | undefined;
114
- ticketId?: import("mongoose").Types.ObjectId | undefined;
115
114
  content?: string | undefined;
115
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
116
116
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
117
117
  }>;
118
118
  export declare const ChatroomMessageSendPushOutputSchema: z.ZodObject<{
@@ -124,14 +124,14 @@ export declare const ChatroomMessageSendPushOutputSchema: z.ZodObject<{
124
124
  }, "strip", z.ZodTypeAny, {
125
125
  type: ChatroomType;
126
126
  orderId?: import("mongoose").Types.ObjectId | undefined;
127
- ticketId?: import("mongoose").Types.ObjectId | undefined;
128
127
  lastMessage?: string | undefined;
128
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
129
129
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
130
130
  }, {
131
131
  type: ChatroomType;
132
132
  orderId?: import("mongoose").Types.ObjectId | undefined;
133
- ticketId?: import("mongoose").Types.ObjectId | undefined;
134
133
  lastMessage?: string | undefined;
134
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
135
135
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
136
136
  }>;
137
137
  export type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatroomMessageSendPushOutputSchema>;
@@ -157,12 +157,12 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
157
157
  type: z.ZodNativeEnum<typeof UserRef>;
158
158
  }, "strip", z.ZodTypeAny, {
159
159
  type: UserRef;
160
- name: string;
161
160
  id: import("mongoose").Types.ObjectId;
161
+ name: string;
162
162
  }, {
163
163
  type: UserRef;
164
- name: string;
165
164
  id: import("mongoose").Types.ObjectId;
165
+ name: string;
166
166
  }>;
167
167
  content: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
168
168
  media: z.ZodArray<z.ZodObject<{
@@ -203,8 +203,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
203
203
  createdAt: Date;
204
204
  sender: {
205
205
  type: UserRef;
206
- name: string;
207
206
  id: import("mongoose").Types.ObjectId;
207
+ name: string;
208
208
  };
209
209
  senderType: UserRef;
210
210
  media: {
@@ -216,21 +216,21 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
216
216
  }[];
217
217
  chatroomType: ChatroomType;
218
218
  senderId: import("mongoose").Types.ObjectId;
219
+ orderId?: import("mongoose").Types.ObjectId | undefined;
219
220
  location?: {
220
221
  latitude?: number | undefined;
221
222
  longitude?: number | undefined;
222
223
  } | undefined;
223
- orderId?: import("mongoose").Types.ObjectId | undefined;
224
- ticketId?: import("mongoose").Types.ObjectId | undefined;
225
224
  content?: string | undefined;
225
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
226
226
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
227
227
  }, {
228
228
  _id: import("mongoose").Types.ObjectId;
229
229
  createdAt: Date;
230
230
  sender: {
231
231
  type: UserRef;
232
- name: string;
233
232
  id: import("mongoose").Types.ObjectId;
233
+ name: string;
234
234
  };
235
235
  senderType: UserRef;
236
236
  media: {
@@ -242,13 +242,13 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
242
242
  }[];
243
243
  chatroomType: ChatroomType;
244
244
  senderId: import("mongoose").Types.ObjectId;
245
+ orderId?: import("mongoose").Types.ObjectId | undefined;
245
246
  location?: {
246
247
  latitude?: number | undefined;
247
248
  longitude?: number | undefined;
248
249
  } | undefined;
249
- orderId?: import("mongoose").Types.ObjectId | undefined;
250
- ticketId?: import("mongoose").Types.ObjectId | undefined;
251
250
  content?: string | undefined;
251
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
252
252
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
253
253
  }>;
254
254
  pushNotificationOutput: z.ZodObject<{
@@ -260,14 +260,14 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
260
260
  }, "strip", z.ZodTypeAny, {
261
261
  type: ChatroomType;
262
262
  orderId?: import("mongoose").Types.ObjectId | undefined;
263
- ticketId?: import("mongoose").Types.ObjectId | undefined;
264
263
  lastMessage?: string | undefined;
264
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
265
265
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
266
266
  }, {
267
267
  type: ChatroomType;
268
268
  orderId?: import("mongoose").Types.ObjectId | undefined;
269
- ticketId?: import("mongoose").Types.ObjectId | undefined;
270
269
  lastMessage?: string | undefined;
270
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
271
271
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
272
272
  }>;
273
273
  };
@@ -278,8 +278,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
278
278
  getPushNotificationPayload(): {
279
279
  type: ChatroomType;
280
280
  orderId?: import("mongoose").Types.ObjectId | undefined;
281
- ticketId?: import("mongoose").Types.ObjectId | undefined;
282
281
  lastMessage?: string | undefined;
282
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
283
283
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
284
284
  } | undefined;
285
285
  protected getIdentifier(): string;
@@ -39,19 +39,19 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
39
39
  riderTips: z.ZodNumber;
40
40
  secondaryRiderTips: z.ZodNumber;
41
41
  }, "strip", z.ZodTypeAny, {
42
- total: number;
43
42
  deliveryFee: number;
44
- secondaryDeliveryFee: number;
45
43
  riderTips: number;
44
+ total: number;
45
+ secondaryDeliveryFee: number;
46
46
  secondaryRiderTips: number;
47
47
  secondaryTotal: number;
48
48
  paidAmount: number;
49
49
  secondaryPaidAmount: number;
50
50
  }, {
51
- total: number;
52
51
  deliveryFee: number;
53
- secondaryDeliveryFee: number;
54
52
  riderTips: number;
53
+ total: number;
54
+ secondaryDeliveryFee: number;
55
55
  secondaryRiderTips: number;
56
56
  secondaryTotal: number;
57
57
  paidAmount: number;
@@ -60,10 +60,10 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
60
60
  }, "strip", z.ZodTypeAny, {
61
61
  paymentMethod: PaymentMethod;
62
62
  pricing: {
63
- total: number;
64
63
  deliveryFee: number;
65
- secondaryDeliveryFee: number;
66
64
  riderTips: number;
65
+ total: number;
66
+ secondaryDeliveryFee: number;
67
67
  secondaryRiderTips: number;
68
68
  secondaryTotal: number;
69
69
  paidAmount: number;
@@ -73,10 +73,10 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
73
73
  }, {
74
74
  paymentMethod: PaymentMethod;
75
75
  pricing: {
76
- total: number;
77
76
  deliveryFee: number;
78
- secondaryDeliveryFee: number;
79
77
  riderTips: number;
78
+ total: number;
79
+ secondaryDeliveryFee: number;
80
80
  secondaryRiderTips: number;
81
81
  secondaryTotal: number;
82
82
  paidAmount: number;
@@ -88,23 +88,23 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
88
88
  triggerAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
89
89
  orderActionType: z.ZodNativeEnum<typeof OrderAction>;
90
90
  }, "strip", z.ZodTypeAny, {
91
- _id: import("mongoose").Types.ObjectId;
92
- createdAt: Date;
93
91
  user: {
94
92
  _id: import("mongoose").Types.ObjectId;
95
93
  name: string;
96
94
  };
95
+ _id: import("mongoose").Types.ObjectId;
97
96
  orderId: string;
97
+ triggerAt: Date;
98
+ createdAt: Date;
98
99
  shopId: import("mongoose").Types.ObjectId;
99
100
  paymentMethod: PaymentMethod;
100
- triggerAt: Date;
101
101
  adjustedFinance: {
102
102
  paymentMethod: PaymentMethod;
103
103
  pricing: {
104
- total: number;
105
104
  deliveryFee: number;
106
- secondaryDeliveryFee: number;
107
105
  riderTips: number;
106
+ total: number;
107
+ secondaryDeliveryFee: number;
108
108
  secondaryRiderTips: number;
109
109
  secondaryTotal: number;
110
110
  paidAmount: number;
@@ -117,23 +117,23 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
117
117
  orderAction: OrderAction;
118
118
  preparationTimeMinutes: number;
119
119
  }, {
120
- _id: string | import("mongoose").Types.ObjectId;
121
- createdAt: Date;
122
120
  user: {
123
121
  _id: string | import("mongoose").Types.ObjectId;
124
122
  name: string;
125
123
  };
124
+ _id: string | import("mongoose").Types.ObjectId;
126
125
  orderId: string;
126
+ triggerAt: Date;
127
+ createdAt: Date;
127
128
  shopId: string | import("mongoose").Types.ObjectId;
128
129
  paymentMethod: PaymentMethod;
129
- triggerAt: Date;
130
130
  adjustedFinance: {
131
131
  paymentMethod: PaymentMethod;
132
132
  pricing: {
133
- total: number;
134
133
  deliveryFee: number;
135
- secondaryDeliveryFee: number;
136
134
  riderTips: number;
135
+ total: number;
136
+ secondaryDeliveryFee: number;
137
137
  secondaryRiderTips: number;
138
138
  secondaryTotal: number;
139
139
  paidAmount: number;
@@ -183,19 +183,19 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
183
183
  riderTips: z.ZodNumber;
184
184
  secondaryRiderTips: z.ZodNumber;
185
185
  }, "strip", z.ZodTypeAny, {
186
- total: number;
187
186
  deliveryFee: number;
188
- secondaryDeliveryFee: number;
189
187
  riderTips: number;
188
+ total: number;
189
+ secondaryDeliveryFee: number;
190
190
  secondaryRiderTips: number;
191
191
  secondaryTotal: number;
192
192
  paidAmount: number;
193
193
  secondaryPaidAmount: number;
194
194
  }, {
195
- total: number;
196
195
  deliveryFee: number;
197
- secondaryDeliveryFee: number;
198
196
  riderTips: number;
197
+ total: number;
198
+ secondaryDeliveryFee: number;
199
199
  secondaryRiderTips: number;
200
200
  secondaryTotal: number;
201
201
  paidAmount: number;
@@ -204,10 +204,10 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
204
204
  }, "strip", z.ZodTypeAny, {
205
205
  paymentMethod: PaymentMethod;
206
206
  pricing: {
207
- total: number;
208
207
  deliveryFee: number;
209
- secondaryDeliveryFee: number;
210
208
  riderTips: number;
209
+ total: number;
210
+ secondaryDeliveryFee: number;
211
211
  secondaryRiderTips: number;
212
212
  secondaryTotal: number;
213
213
  paidAmount: number;
@@ -217,10 +217,10 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
217
217
  }, {
218
218
  paymentMethod: PaymentMethod;
219
219
  pricing: {
220
- total: number;
221
220
  deliveryFee: number;
222
- secondaryDeliveryFee: number;
223
221
  riderTips: number;
222
+ total: number;
223
+ secondaryDeliveryFee: number;
224
224
  secondaryRiderTips: number;
225
225
  secondaryTotal: number;
226
226
  paidAmount: number;
@@ -232,23 +232,23 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
232
232
  triggerAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
233
233
  orderActionType: z.ZodNativeEnum<typeof OrderAction>;
234
234
  }, "strip", z.ZodTypeAny, {
235
- _id: import("mongoose").Types.ObjectId;
236
- createdAt: Date;
237
235
  user: {
238
236
  _id: import("mongoose").Types.ObjectId;
239
237
  name: string;
240
238
  };
239
+ _id: import("mongoose").Types.ObjectId;
241
240
  orderId: string;
241
+ triggerAt: Date;
242
+ createdAt: Date;
242
243
  shopId: import("mongoose").Types.ObjectId;
243
244
  paymentMethod: PaymentMethod;
244
- triggerAt: Date;
245
245
  adjustedFinance: {
246
246
  paymentMethod: PaymentMethod;
247
247
  pricing: {
248
- total: number;
249
248
  deliveryFee: number;
250
- secondaryDeliveryFee: number;
251
249
  riderTips: number;
250
+ total: number;
251
+ secondaryDeliveryFee: number;
252
252
  secondaryRiderTips: number;
253
253
  secondaryTotal: number;
254
254
  paidAmount: number;
@@ -261,23 +261,23 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
261
261
  orderAction: OrderAction;
262
262
  preparationTimeMinutes: number;
263
263
  }, {
264
- _id: string | import("mongoose").Types.ObjectId;
265
- createdAt: Date;
266
264
  user: {
267
265
  _id: string | import("mongoose").Types.ObjectId;
268
266
  name: string;
269
267
  };
268
+ _id: string | import("mongoose").Types.ObjectId;
270
269
  orderId: string;
270
+ triggerAt: Date;
271
+ createdAt: Date;
271
272
  shopId: string | import("mongoose").Types.ObjectId;
272
273
  paymentMethod: PaymentMethod;
273
- triggerAt: Date;
274
274
  adjustedFinance: {
275
275
  paymentMethod: PaymentMethod;
276
276
  pricing: {
277
- total: number;
278
277
  deliveryFee: number;
279
- secondaryDeliveryFee: number;
280
278
  riderTips: number;
279
+ total: number;
280
+ secondaryDeliveryFee: number;
281
281
  secondaryRiderTips: number;
282
282
  secondaryTotal: number;
283
283
  paidAmount: number;
@@ -21,16 +21,16 @@ export declare const RiderLocationUpdateSocketOutputSchema: z.ZodObject<{
21
21
  }, "strip", z.ZodTypeAny, {
22
22
  _id: import("mongoose").Types.ObjectId;
23
23
  updatedAt: Date;
24
+ riderId: import("mongoose").Types.ObjectId;
24
25
  latitude: number;
25
26
  longitude: number;
26
- riderId: import("mongoose").Types.ObjectId;
27
27
  bearing?: number | undefined;
28
28
  }, {
29
29
  _id: string | import("mongoose").Types.ObjectId;
30
30
  updatedAt: string | Date;
31
+ riderId: string | import("mongoose").Types.ObjectId;
31
32
  latitude: number;
32
33
  longitude: number;
33
- riderId: string | import("mongoose").Types.ObjectId;
34
34
  bearing?: number | undefined;
35
35
  }>;
36
36
  export type RiderLocationUpdateSocketInputDTO = DTO<typeof RiderLocationUpdateSocketInputSchema>;
@@ -57,16 +57,16 @@ export declare class RiderLocationUpdateSocketEvent extends BaseSocketEvent<type
57
57
  }, "strip", z.ZodTypeAny, {
58
58
  _id: import("mongoose").Types.ObjectId;
59
59
  updatedAt: Date;
60
+ riderId: import("mongoose").Types.ObjectId;
60
61
  latitude: number;
61
62
  longitude: number;
62
- riderId: import("mongoose").Types.ObjectId;
63
63
  bearing?: number | undefined;
64
64
  }, {
65
65
  _id: string | import("mongoose").Types.ObjectId;
66
66
  updatedAt: string | Date;
67
+ riderId: string | import("mongoose").Types.ObjectId;
67
68
  latitude: number;
68
69
  longitude: number;
69
- riderId: string | import("mongoose").Types.ObjectId;
70
70
  bearing?: number | undefined;
71
71
  }>;
72
72
  };
@@ -12,19 +12,19 @@ export declare const TicketActionsSocketOutputSchema: z.ZodObject<{
12
12
  title: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
13
13
  silent: z.ZodOptional<z.ZodBoolean>;
14
14
  }, "strip", z.ZodTypeAny, {
15
- status: TicketStatus;
16
15
  type: TicketType;
16
+ status: TicketStatus;
17
17
  _id: import("mongoose").Types.ObjectId;
18
- silent?: boolean | undefined;
19
18
  title?: string | undefined;
20
19
  content?: string | undefined;
20
+ silent?: boolean | undefined;
21
21
  }, {
22
- status: TicketStatus;
23
22
  type: TicketType;
23
+ status: TicketStatus;
24
24
  _id: import("mongoose").Types.ObjectId;
25
- silent?: boolean | undefined;
26
25
  title?: string | undefined;
27
26
  content?: string | undefined;
27
+ silent?: boolean | undefined;
28
28
  }>;
29
29
  export declare const TicketActionsPushOutputSchema: z.ZodObject<{
30
30
  ticketId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
@@ -33,14 +33,14 @@ export declare const TicketActionsPushOutputSchema: z.ZodObject<{
33
33
  content: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
34
34
  title: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
35
35
  }, "strip", z.ZodTypeAny, {
36
- status: TicketStatus;
37
36
  type: TicketType;
37
+ status: TicketStatus;
38
38
  ticketId: import("mongoose").Types.ObjectId;
39
39
  title?: string | undefined;
40
40
  content?: string | undefined;
41
41
  }, {
42
- status: TicketStatus;
43
42
  type: TicketType;
43
+ status: TicketStatus;
44
44
  ticketId: import("mongoose").Types.ObjectId;
45
45
  title?: string | undefined;
46
46
  content?: string | undefined;
@@ -59,19 +59,19 @@ export declare class TicketActionsSocketEvent extends BaseSocketEvent<typeof Tic
59
59
  title: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
60
60
  silent: z.ZodOptional<z.ZodBoolean>;
61
61
  }, "strip", z.ZodTypeAny, {
62
- status: TicketStatus;
63
62
  type: TicketType;
63
+ status: TicketStatus;
64
64
  _id: import("mongoose").Types.ObjectId;
65
- silent?: boolean | undefined;
66
65
  title?: string | undefined;
67
66
  content?: string | undefined;
67
+ silent?: boolean | undefined;
68
68
  }, {
69
- status: TicketStatus;
70
69
  type: TicketType;
70
+ status: TicketStatus;
71
71
  _id: import("mongoose").Types.ObjectId;
72
- silent?: boolean | undefined;
73
72
  title?: string | undefined;
74
73
  content?: string | undefined;
74
+ silent?: boolean | undefined;
75
75
  }>;
76
76
  pushNotificationOutput: z.ZodObject<{
77
77
  ticketId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
@@ -80,14 +80,14 @@ export declare class TicketActionsSocketEvent extends BaseSocketEvent<typeof Tic
80
80
  content: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
81
81
  title: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
82
82
  }, "strip", z.ZodTypeAny, {
83
- status: TicketStatus;
84
83
  type: TicketType;
84
+ status: TicketStatus;
85
85
  ticketId: import("mongoose").Types.ObjectId;
86
86
  title?: string | undefined;
87
87
  content?: string | undefined;
88
88
  }, {
89
- status: TicketStatus;
90
89
  type: TicketType;
90
+ status: TicketStatus;
91
91
  ticketId: import("mongoose").Types.ObjectId;
92
92
  title?: string | undefined;
93
93
  content?: string | undefined;
@@ -96,8 +96,8 @@ export declare class TicketActionsSocketEvent extends BaseSocketEvent<typeof Tic
96
96
  get notificationSettings(): NotificationSettings | undefined;
97
97
  constructor(payload: TicketActionsSocketOutputDTO);
98
98
  getPushNotificationPayload(): {
99
- status: TicketStatus;
100
99
  type: TicketType;
100
+ status: TicketStatus;
101
101
  ticketId: import("mongoose").Types.ObjectId;
102
102
  title?: string | undefined;
103
103
  content?: string | undefined;
@@ -39,8 +39,8 @@ export declare const TicketAssignSocketOutputSchema: z.ZodObject<{
39
39
  }>;
40
40
  unreadCount: z.ZodNumber;
41
41
  }, "strip", z.ZodTypeAny, {
42
- status: TicketStatus;
43
42
  type: TicketType;
43
+ status: TicketStatus;
44
44
  _id: import("mongoose").Types.ObjectId;
45
45
  createdAt: Date;
46
46
  updatedAt: Date;
@@ -58,8 +58,8 @@ export declare const TicketAssignSocketOutputSchema: z.ZodObject<{
58
58
  chatroomId: import("mongoose").Types.ObjectId;
59
59
  orderId?: import("mongoose").Types.ObjectId | undefined;
60
60
  }, {
61
- status: TicketStatus;
62
61
  type: TicketType;
62
+ status: TicketStatus;
63
63
  _id: string | import("mongoose").Types.ObjectId;
64
64
  createdAt: string | Date;
65
65
  updatedAt: string | Date;
@@ -117,8 +117,8 @@ export declare class TicketAssignEvent extends BaseSocketEvent<typeof TicketAssi
117
117
  }>;
118
118
  unreadCount: z.ZodNumber;
119
119
  }, "strip", z.ZodTypeAny, {
120
- status: TicketStatus;
121
120
  type: TicketType;
121
+ status: TicketStatus;
122
122
  _id: import("mongoose").Types.ObjectId;
123
123
  createdAt: Date;
124
124
  updatedAt: Date;
@@ -136,8 +136,8 @@ export declare class TicketAssignEvent extends BaseSocketEvent<typeof TicketAssi
136
136
  chatroomId: import("mongoose").Types.ObjectId;
137
137
  orderId?: import("mongoose").Types.ObjectId | undefined;
138
138
  }, {
139
- status: TicketStatus;
140
139
  type: TicketType;
140
+ status: TicketStatus;
141
141
  _id: string | import("mongoose").Types.ObjectId;
142
142
  createdAt: string | Date;
143
143
  updatedAt: string | Date;
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.333
25
+ Version: 1.4.334-alpha-12
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.333",
3
+ "version": "1.4.334-alpha-12",
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.333",
3
+ "version": "1.4.334-alpha-12",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",