@lyxa.ai/core 1.2.84 → 1.2.85

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 (35) hide show
  1. package/dist/libraries/event/EventEnums.d.ts +2 -1
  2. package/dist/libraries/event/EventEnums.js +1 -0
  3. package/dist/libraries/event/EventEnums.js.map +1 -1
  4. package/dist/libraries/event/index.d.ts +6 -1
  5. package/dist/libraries/event/index.js +6 -4
  6. package/dist/libraries/event/index.js.map +1 -1
  7. package/dist/libraries/socket/BaseSocketEvent.d.ts +9 -4
  8. package/dist/libraries/socket/BaseSocketEvent.js +13 -1
  9. package/dist/libraries/socket/BaseSocketEvent.js.map +1 -1
  10. package/dist/libraries/socket/PushNotificationEvent.d.ts +27 -10
  11. package/dist/libraries/socket/PushNotificationEvent.js +30 -5
  12. package/dist/libraries/socket/PushNotificationEvent.js.map +1 -1
  13. package/dist/libraries/socket/core/socket-event-publisher.js +4 -7
  14. package/dist/libraries/socket/core/socket-event-publisher.js.map +1 -1
  15. package/dist/libraries/socket/core/socket-event-registry.map.d.ts +55 -0
  16. package/dist/libraries/socket/core/socket-event-registry.map.js +5 -0
  17. package/dist/libraries/socket/core/socket-event-registry.map.js.map +1 -1
  18. package/dist/libraries/socket/events/chatlist-message-send.socket.event.d.ts +66 -2
  19. package/dist/libraries/socket/events/chatlist-message-send.socket.event.js +10 -3
  20. package/dist/libraries/socket/events/chatlist-message-send.socket.event.js.map +1 -1
  21. package/dist/libraries/socket/events/chatroom-message-send.socket.event.d.ts +0 -2
  22. package/dist/libraries/socket/events/chatroom-message-send.socket.event.js +4 -6
  23. package/dist/libraries/socket/events/chatroom-message-send.socket.event.js.map +1 -1
  24. package/dist/libraries/socket/events/ticket-actions.socket.event.d.ts +59 -0
  25. package/dist/libraries/socket/events/ticket-actions.socket.event.js +33 -0
  26. package/dist/libraries/socket/events/ticket-actions.socket.event.js.map +1 -0
  27. package/dist/types/README.md +1 -1
  28. package/dist/types/package.json +1 -1
  29. package/dist/types/utilities/enum.d.ts +5 -1
  30. package/dist/types/utilities/enum.js +4 -0
  31. package/dist/types/utilities/enum.js.map +1 -1
  32. package/dist/utilities/enum.d.ts +5 -1
  33. package/dist/utilities/enum.js +4 -0
  34. package/dist/utilities/enum.js.map +1 -1
  35. package/package.json +1 -1
@@ -5,5 +5,6 @@ export declare enum PublishEventEnums {
5
5
  CART_ITEM_UPSERT_EVENT = "cart_item_upsert_event",
6
6
  SHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT = "shop_active_timings_batch_process_event",
7
7
  MONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT = "mongo_stream_changes_batch_process_shops_event",
8
- BULK_UPDATE_SHOPS_SEARCH_FIELDS_EVENT = "bulk_update_shops_search_fields_event"
8
+ BULK_UPDATE_SHOPS_SEARCH_FIELDS_EVENT = "bulk_update_shops_search_fields_event",
9
+ SOCKET_PUSH_NOTIFICATION_EVENT = "socket_push_notification_event"
9
10
  }
@@ -10,5 +10,6 @@ var PublishEventEnums;
10
10
  PublishEventEnums["SHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT"] = "shop_active_timings_batch_process_event";
11
11
  PublishEventEnums["MONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT"] = "mongo_stream_changes_batch_process_shops_event";
12
12
  PublishEventEnums["BULK_UPDATE_SHOPS_SEARCH_FIELDS_EVENT"] = "bulk_update_shops_search_fields_event";
13
+ PublishEventEnums["SOCKET_PUSH_NOTIFICATION_EVENT"] = "socket_push_notification_event";
13
14
  })(PublishEventEnums || (exports.PublishEventEnums = PublishEventEnums = {}));
14
15
  //# sourceMappingURL=EventEnums.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EventEnums.js","sourceRoot":"/","sources":["libraries/event/EventEnums.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC5B,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,wGAAmF,CAAA;IACnF,sHAAiG,CAAA;IACjG,oGAA+E,CAAA;AAChF,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B","sourcesContent":["export enum PublishEventEnums {\n\tADMIN_ACTIVITY_LOGS_EVENT = 'admin_activity_logs_event',\n\tMESSAGE_RECEIVED_EVENT = 'message_received_event',\n\tTICKET_NOTIFICATION_EVENT = 'ticket_notification_event',\n\tCART_ITEM_UPSERT_EVENT = 'cart_item_upsert_event',\n\tSHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT = 'shop_active_timings_batch_process_event',\n\tMONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT = 'mongo_stream_changes_batch_process_shops_event',\n\tBULK_UPDATE_SHOPS_SEARCH_FIELDS_EVENT = 'bulk_update_shops_search_fields_event',\n}\n"]}
1
+ {"version":3,"file":"EventEnums.js","sourceRoot":"/","sources":["libraries/event/EventEnums.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC5B,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,wGAAmF,CAAA;IACnF,sHAAiG,CAAA;IACjG,oGAA+E,CAAA;IAC/E,sFAAiE,CAAA;AAClE,CAAC,EATW,iBAAiB,iCAAjB,iBAAiB,QAS5B","sourcesContent":["export enum PublishEventEnums {\n\tADMIN_ACTIVITY_LOGS_EVENT = 'admin_activity_logs_event',\n\tMESSAGE_RECEIVED_EVENT = 'message_received_event',\n\tTICKET_NOTIFICATION_EVENT = 'ticket_notification_event',\n\tCART_ITEM_UPSERT_EVENT = 'cart_item_upsert_event',\n\tSHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT = 'shop_active_timings_batch_process_event',\n\tMONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT = 'mongo_stream_changes_batch_process_shops_event',\n\tBULK_UPDATE_SHOPS_SEARCH_FIELDS_EVENT = 'bulk_update_shops_search_fields_event',\n\tSOCKET_PUSH_NOTIFICATION_EVENT = 'socket_push_notification_event',\n}\n"]}
@@ -5,5 +5,10 @@ export declare const INSTANCE_ROUTE_PREFIX = "instance";
5
5
  export declare function initEventBus(rabbitUrl: string): Promise<void>;
6
6
  export declare function getChannel(): amqp.Channel;
7
7
  export declare function publishEvent<TPayload extends Record<string, unknown>>(event: BaseEvent<TPayload>): Promise<void>;
8
- export declare function subscribeToEvent(eventId: string, onMessage: (payload: any) => Promise<void>): Promise<void>;
8
+ export type RabbitMqOptions = {
9
+ exclusive?: boolean;
10
+ durable?: boolean;
11
+ autoDelete?: boolean;
12
+ };
13
+ export declare function subscribeToEvent(eventId: string, onMessage: (payload: any) => Promise<void>, options?: RabbitMqOptions): Promise<void>;
9
14
  export declare function closeEventBus(): Promise<void>;
@@ -33,14 +33,16 @@ async function publishEvent(event) {
33
33
  contentType: 'application/json',
34
34
  });
35
35
  }
36
- async function subscribeToEvent(eventId, onMessage) {
36
+ async function subscribeToEvent(eventId, onMessage, options) {
37
37
  const ch = getChannel();
38
- const queueName = `${eventId}`;
39
- await ch.assertQueue(queueName, {
38
+ const queueName = options?.exclusive ? `${eventId}-${(0, instance_utils_1.getInstanceId)()}` : eventId;
39
+ const queueOptions = {
40
40
  durable: true,
41
41
  exclusive: false,
42
42
  autoDelete: false,
43
- });
43
+ ...options,
44
+ };
45
+ await ch.assertQueue(queueName, queueOptions);
44
46
  await ch.bindQueue(queueName, exports.EXCHANGE_NAME, eventId);
45
47
  await ch.consume(queueName, async (msg) => {
46
48
  if (msg !== null) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;;AASA,oCAKC;AAED,gCAGC;AAED,oCASC;AAED,4CAkCC;AAED,sCAIC;AAxED,sDAA2B;AAE3B,mEAA+D;AAE/D,IAAI,UAA6B,CAAC;AAClC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AE,qBAAa,EAAE,OAAO,CAAC,CAAC;IAEtD,MAAM,EAAE,CAAC,OAAO,CACf,SAAS,EACT,KAAK,EAAC,GAAG,EAAC,EAAE;QACX,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YACnD,IAAI,CAAC;gBACJ,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;gBACzB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACb,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,KAAK,CAAC,yBAAyB,OAAO,kBAAkB,IAAA,8BAAa,GAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;IACF,CAAC,EACD,EAAE,KAAK,EAAE,KAAK,EAAE,CAChB,CAAC;IAGF,OAAO,CAAC,GAAG,CAAC,wBAAwB,OAAO,GAAG,CAAC,CAAC;AACjD,CAAC;AAEM,KAAK,UAAU,aAAa;IAClC,IAAI,OAAO;QAAE,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACnC,IAAI,UAAU;QAAE,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAA,8BAAa,GAAE,GAAG,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import amqp from 'amqplib';\nimport { BaseEvent } from './BaseEvent';\nimport { getInstanceId } from '../../utilities/instance.utils';\n\nlet connection: amqp.ChannelModel;\nlet channel: amqp.Channel;\nexport const EXCHANGE_NAME = 'lyxa.events';\nexport const INSTANCE_ROUTE_PREFIX = 'instance'; // routing key: instance.{instanceName}.{eventType}\n\nexport async function initEventBus(rabbitUrl: string) {\n\tconnection = await amqp.connect(rabbitUrl);\n\tchannel = await connection.createChannel();\n\tawait channel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\tconsole.log(`EventBus initialized with instance ID: ${getInstanceId()}`);\n}\n\nexport function getChannel(): amqp.Channel {\n\tif (!channel) throw new Error('Channel not initialized. Call initEventBus first.');\n\treturn channel;\n}\n\nexport async function publishEvent<TPayload extends Record<string, unknown>>(\n\tevent: BaseEvent<TPayload>\n): Promise<void> {\n\tconst ch = getChannel();\n\tconst messageBuffer = Buffer.from(JSON.stringify(event.payload));\n\tch.publish(EXCHANGE_NAME, event.eventId, messageBuffer, {\n\t\tcontentType: 'application/json',\n\t});\n\t// console.log(`Published event [${event.eventId}] with payload`, event.payload);\n}\n\nexport async function subscribeToEvent(\n\teventId: string,\n\tonMessage: (payload: any) => Promise<void>\n): Promise<void> {\n\tconst ch = getChannel();\n\t// const queueName = `${eventId}-${getInstanceId()}`;\n\tconst queueName = `${eventId}`;\n\n\tawait ch.assertQueue(queueName, {\n\t\tdurable: true, // survive broker restart\n\t\texclusive: false, // Allow multiple consumers to attach. Only one connection can use it (each pod has own queue). Set to TRUE if each pod needs it's own queue\n\t\tautoDelete: false, // Queue removed when pod disconnects when set to TRUE\n\t});\n\n\tawait ch.bindQueue(queueName, EXCHANGE_NAME, eventId);\n\n\tawait ch.consume(\n\t\tqueueName,\n\t\tasync msg => {\n\t\t\tif (msg !== null) {\n\t\t\t\tconst payload = JSON.parse(msg.content.toString());\n\t\t\t\ttry {\n\t\t\t\t\tawait onMessage(payload);\n\t\t\t\t\tch.ack(msg);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`Error handling event [${eventId}] on instance [${getInstanceId()}]`, err);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ noAck: false }\n\t);\n\n\t// console.log(`Subscribed to event [${eventId}] on queue [${queueName}]`);\n\tconsole.log(`Subscribed to event [${eventId}]`);\n}\n\nexport async function closeEventBus(): Promise<void> {\n\tif (channel) await channel.close();\n\tif (connection) await connection.close();\n\tconsole.log(`EventBus closed for instance [${getInstanceId()}]`);\n}"]}
1
+ {"version":3,"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esContent":["import amqp from 'amqplib';\nimport { BaseEvent } from './BaseEvent';\nimport { getInstanceId } from '../../utilities/instance.utils';\n\nlet connection: amqp.ChannelModel;\nlet channel: amqp.Channel;\nexport const EXCHANGE_NAME = 'lyxa.events';\nexport const INSTANCE_ROUTE_PREFIX = 'instance'; // routing key: instance.{instanceName}.{eventType}\n\nexport async function initEventBus(rabbitUrl: string) {\n\tconnection = await amqp.connect(rabbitUrl);\n\tchannel = await connection.createChannel();\n\tawait channel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\tconsole.log(`EventBus initialized with instance ID: ${getInstanceId()}`);\n}\n\nexport function getChannel(): amqp.Channel {\n\tif (!channel) throw new Error('Channel not initialized. Call initEventBus first.');\n\treturn channel;\n}\n\nexport async function publishEvent<TPayload extends Record<string, unknown>>(\n\tevent: BaseEvent<TPayload>\n): Promise<void> {\n\tconst ch = getChannel();\n\tconst messageBuffer = Buffer.from(JSON.stringify(event.payload));\n\tch.publish(EXCHANGE_NAME, event.eventId, messageBuffer, {\n\t\tcontentType: 'application/json',\n\t});\n\t// console.log(`Published event [${event.eventId}] with payload`, event.payload);\n}\n\nexport type RabbitMqOptions = {\n\texclusive?: boolean;\n\tdurable?: boolean;\n\tautoDelete?: boolean;\n};\n\nexport async function subscribeToEvent(\n\teventId: string,\n\tonMessage: (payload: any) => Promise<void>,\n\toptions?: RabbitMqOptions\n): Promise<void> {\n\tconst ch = getChannel();\n\tconst queueName = options?.exclusive ? `${eventId}-${getInstanceId()}` : eventId;\n\n\tconst queueOptions = {\n\t\tdurable: true,\n\t\texclusive: false,\n\t\tautoDelete: false,\n\t\t...options,\n\t};\n\n\tawait ch.assertQueue(queueName, queueOptions);\n\tawait ch.bindQueue(queueName, EXCHANGE_NAME, eventId);\n\n\tawait ch.consume(\n\t\tqueueName,\n\t\tasync msg => {\n\t\t\tif (msg !== null) {\n\t\t\t\tconst payload = JSON.parse(msg.content.toString());\n\t\t\t\ttry {\n\t\t\t\t\tawait onMessage(payload);\n\t\t\t\t\tch.ack(msg);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`Error handling event [${eventId}] on instance [${getInstanceId()}]`, err);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ noAck: false }\n\t);\n\n\t// console.log(`Subscribed to event [${eventId}] on queue [${queueName}]`);\n\tconsole.log(`Subscribed to event [${eventId}]`);\n}\n\nexport async function closeEventBus(): Promise<void> {\n\tif (channel) await channel.close();\n\tif (connection) await connection.close();\n\tconsole.log(`EventBus closed for instance [${getInstanceId()}]`);\n}\n"]}
@@ -1,19 +1,24 @@
1
1
  import z, { ZodTypeAny } from 'zod';
2
2
  import { SocketEventType } from '../../utilities/enum';
3
- import { NotificationSocketEvent } from './events/notification.socket.event';
4
- export declare abstract class BaseSocketEvent<SIn extends ZodTypeAny, SOut extends ZodTypeAny> {
3
+ import { PushNotificationEvent, NotificationSettings } from './PushNotificationEvent';
4
+ export declare abstract class BaseSocketEvent<SIn extends ZodTypeAny, SOut extends ZodTypeAny, SPush extends ZodTypeAny | undefined = undefined> {
5
5
  protected readonly _eventType: SocketEventType;
6
6
  readonly inputSchema: SIn;
7
7
  readonly outputSchema: SOut;
8
+ readonly pushNotificationOutputSchema?: SPush;
8
9
  protected readonly data: z.infer<SOut>;
10
+ protected readonly pushNotificationData?: SPush extends ZodTypeAny ? z.infer<SPush> : undefined;
9
11
  static identifier(input: any): string;
10
- notification?(): NotificationSocketEvent | null;
12
+ notification?(): PushNotificationEvent | null;
11
13
  pushNotification?: boolean;
12
14
  protected constructor(eventType: SocketEventType, schemas: {
13
15
  input: SIn;
14
16
  output: SOut;
15
- }, data: z.infer<SOut>);
17
+ pushNotificationOutput?: SPush;
18
+ }, data: z.infer<SOut>, pushNotificationData?: SPush extends ZodTypeAny ? z.infer<SPush> : undefined);
16
19
  payload(): z.infer<SOut>;
20
+ getPushNotificationPayload(): SPush extends ZodTypeAny ? z.infer<SPush> | undefined : undefined;
17
21
  eventType(): SocketEventType;
18
22
  getSubscriptionKey(): string;
23
+ get notificationSettings(): NotificationSettings | undefined;
19
24
  }
@@ -5,20 +5,29 @@ class BaseSocketEvent {
5
5
  _eventType;
6
6
  inputSchema;
7
7
  outputSchema;
8
+ pushNotificationOutputSchema;
8
9
  data;
10
+ pushNotificationData;
9
11
  static identifier(input) {
10
12
  return 'default';
11
13
  }
12
14
  pushNotification = false;
13
- constructor(eventType, schemas, data) {
15
+ constructor(eventType, schemas, data, pushNotificationData) {
14
16
  this._eventType = eventType;
15
17
  this.inputSchema = schemas.input;
16
18
  this.outputSchema = schemas.output;
17
19
  this.data = this.outputSchema.parse(data);
20
+ if (schemas.pushNotificationOutput && pushNotificationData) {
21
+ this.pushNotificationOutputSchema = schemas.pushNotificationOutput;
22
+ this.pushNotificationData = schemas.pushNotificationOutput.parse(pushNotificationData);
23
+ }
18
24
  }
19
25
  payload() {
20
26
  return this.data;
21
27
  }
28
+ getPushNotificationPayload() {
29
+ return this.pushNotificationData;
30
+ }
22
31
  eventType() {
23
32
  return this._eventType;
24
33
  }
@@ -26,6 +35,9 @@ class BaseSocketEvent {
26
35
  const identifier = this.constructor.identifier(this.data);
27
36
  return `${this._eventType}:${identifier}`;
28
37
  }
38
+ get notificationSettings() {
39
+ return this.constructor.notificationSettings;
40
+ }
29
41
  }
30
42
  exports.BaseSocketEvent = BaseSocketEvent;
31
43
  //# sourceMappingURL=BaseSocketEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseSocketEvent.js","sourceRoot":"/","sources":["libraries/socket/BaseSocketEvent.ts"],"names":[],"mappings":";;;AAIA,MAAsB,eAAe;IACjB,UAAU,CAAkB;IACtC,WAAW,CAAM;IACjB,YAAY,CAAO;IACT,IAAI,CAAgB;IAEvC,MAAM,CAAC,UAAU,CAAC,KAAU;QAC3B,OAAO,SAAS,CAAC;IAClB,CAAC;IAGM,gBAAgB,GAAa,KAAK,CAAC;IAE1C,YACC,SAA0B,EAC1B,OAAqC,EACrC,IAAmB;QAEnB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;QAEnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,SAAS;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAEM,kBAAkB;QACxB,MAAM,UAAU,GAAI,IAAI,CAAC,WAAsC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtF,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,UAAU,EAAE,CAAC;IAC3C,CAAC;CACD;AArCD,0CAqCC","sourcesContent":["import z, { ZodTypeAny } from 'zod';\nimport { SocketEventType } from '../../utilities/enum';\nimport { NotificationSocketEvent } from './events/notification.socket.event';\n\nexport abstract class BaseSocketEvent<SIn extends ZodTypeAny, SOut extends ZodTypeAny> {\n\tprotected readonly _eventType: SocketEventType;\n\treadonly inputSchema: SIn;\n\treadonly outputSchema: SOut;\n\tprotected readonly data: z.infer<SOut>;\n\n\tstatic identifier(input: any): string {\n\t\treturn 'default';\n\t}\n\n\tpublic notification?(): NotificationSocketEvent | null;\n\tpublic pushNotification?: boolean = false;\n\n\tprotected constructor(\n\t\teventType: SocketEventType,\n\t\tschemas: { input: SIn; output: SOut },\n\t\tdata: z.infer<SOut>\n\t) {\n\t\tthis._eventType = eventType;\n\t\tthis.inputSchema = schemas.input;\n\t\tthis.outputSchema = schemas.output;\n\n\t\tthis.data = this.outputSchema.parse(data);\n\t}\n\n\tpublic payload(): z.infer<SOut> {\n\t\treturn this.data;\n\t}\n\n\tpublic eventType(): SocketEventType {\n\t\treturn this._eventType;\n\t}\n\n\tpublic getSubscriptionKey(): string {\n\t\tconst identifier = (this.constructor as typeof BaseSocketEvent).identifier(this.data);\n\t\treturn `${this._eventType}:${identifier}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"BaseSocketEvent.js","sourceRoot":"/","sources":["libraries/socket/BaseSocketEvent.ts"],"names":[],"mappings":";;;AAMA,MAAsB,eAAe;IACjB,UAAU,CAAkB;IACtC,WAAW,CAAM;IACjB,YAAY,CAAO;IACnB,4BAA4B,CAAS;IAC3B,IAAI,CAAgB;IACpB,oBAAoB,CAAyD;IAEhG,MAAM,CAAC,UAAU,CAAC,KAAU;QAC3B,OAAO,SAAS,CAAC;IAClB,CAAC;IAGO,gBAAgB,GAAa,KAAK,CAAC;IAExC,YACC,SAA0B,EAC1B,OAAqE,EACrE,IAAmB,EACnB,oBAA4E;QAE5E,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,OAAO,CAAC,sBAAsB,IAAI,oBAAoB,EAAE,CAAC;YAC5D,IAAI,CAAC,4BAA4B,GAAG,OAAO,CAAC,sBAAsB,CAAC;YACnE,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxF,CAAC;IACF,CAAC;IAGM,OAAO;QACb,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,0BAA0B;QAEhC,OAAO,IAAI,CAAC,oBAAoB,CAAC;IAClC,CAAC;IAGM,SAAS;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAEM,kBAAkB;QACxB,MAAM,UAAU,GAAI,IAAI,CAAC,WAAsC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtF,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,UAAU,EAAE,CAAC;IAC3C,CAAC;IAED,IAAW,oBAAoB;QAC9B,OAAQ,IAAI,CAAC,WAAmB,CAAC,oBAAoB,CAAC;IACvD,CAAC;CACJ;AAtDD,0CAsDC","sourcesContent":["\nimport z, { ZodTypeAny } from 'zod';\nimport { SocketEventType, ClickType } from '../../utilities/enum';\nimport { PushNotificationEvent, NotificationSettings } from './PushNotificationEvent';\n\n\nexport abstract class BaseSocketEvent<SIn extends ZodTypeAny, SOut extends ZodTypeAny, SPush extends ZodTypeAny | undefined = undefined> {\n\tprotected readonly _eventType: SocketEventType;\n\treadonly inputSchema: SIn;\n\treadonly outputSchema: SOut;\n\treadonly pushNotificationOutputSchema?: SPush;\n\tprotected readonly data: z.infer<SOut>;\n\tprotected readonly pushNotificationData?: SPush extends ZodTypeAny ? z.infer<SPush> : undefined;\n\n\tstatic identifier(input: any): string {\n\t\treturn 'default';\n\t}\n\n\t\tpublic notification?(): PushNotificationEvent | null;\n\t\tpublic pushNotification?: boolean = false;\n\n\t protected constructor(\n\t\t eventType: SocketEventType,\n\t\t schemas: { input: SIn; output: SOut; pushNotificationOutput?: SPush },\n\t\t data: z.infer<SOut>,\n\t\t pushNotificationData?: SPush extends ZodTypeAny ? z.infer<SPush> : undefined\n\t ) {\n\t\t this._eventType = eventType;\n\t\t this.inputSchema = schemas.input;\n\t\t this.outputSchema = schemas.output;\n\t\t this.data = this.outputSchema.parse(data);\n\t\t if (schemas.pushNotificationOutput && pushNotificationData) {\n\t\t\t this.pushNotificationOutputSchema = schemas.pushNotificationOutput;\n\t\t\t this.pushNotificationData = schemas.pushNotificationOutput.parse(pushNotificationData);\n\t\t }\n\t }\n\n\n\t public payload(): z.infer<SOut> {\n\t\t return this.data;\n\t }\n\n\t public getPushNotificationPayload(): SPush extends ZodTypeAny ? z.infer<SPush> | undefined : undefined {\n\t\t // @ts-expect-error: TypeScript cannot infer conditional return here\n\t\t return this.pushNotificationData;\n\t }\n\n\n\t public eventType(): SocketEventType {\n\t\t return this._eventType;\n\t }\n\n\t public getSubscriptionKey(): string {\n\t\t const identifier = (this.constructor as typeof BaseSocketEvent).identifier(this.data);\n\t\t return `${this._eventType}:${identifier}`;\n\t }\n\n\t public get notificationSettings(): NotificationSettings | undefined {\n\t\t return (this.constructor as any).notificationSettings;\n\t }\n}\n"]}
@@ -1,18 +1,35 @@
1
1
  import { BaseEvent } from '../event/BaseEvent';
2
- import { BaseSocketEvent, EntitySubscription } from './core';
2
+ import { SocketEventType, ClickType } from '../../utilities/enum';
3
+ import { EntitySubscription } from './core/socket-redis-connections';
3
4
  import { REGISTRY } from './core/socket-event-registry.map';
4
- type EventCtorPayload<T> = T extends {
5
- ctor: new (...args: any) => BaseSocketEvent<any, infer P>;
6
- } ? P : never;
7
- export type PushNotificationEventData<T extends keyof typeof REGISTRY> = {
8
- type: T;
5
+ type SocketEventPayloads = {
6
+ [K in SocketEventType]: (typeof REGISTRY)[K] extends {
7
+ schemas: {
8
+ pushNotificationOutput: any;
9
+ };
10
+ } ? import('zod').infer<(typeof REGISTRY)[K]['schemas']['pushNotificationOutput']> : (typeof REGISTRY)[K] extends {
11
+ schemas: {
12
+ output: any;
13
+ };
14
+ } ? import('zod').infer<(typeof REGISTRY)[K]['schemas']['output']> : any;
15
+ };
16
+ export type NotificationSettings = {
17
+ isPushNotification: false;
18
+ } | {
19
+ isPushNotification: true;
20
+ isClickable: boolean;
21
+ clickType: ClickType;
22
+ };
23
+ export type PushNotificationEventData<T extends SocketEventType = SocketEventType> = {
24
+ eventName: T;
9
25
  recipients: EntitySubscription[];
10
- payload: EventCtorPayload<(typeof REGISTRY)[T]>;
26
+ payload: SocketEventPayloads[T];
27
+ notificationSettings: NotificationSettings;
11
28
  };
12
- export declare class PushNotificationEvent<T extends keyof typeof REGISTRY> extends BaseEvent<PushNotificationEventData<T>> {
13
- constructor(type: T, payload: EventCtorPayload<(typeof REGISTRY)[T]>, recipients: EntitySubscription[]);
29
+ export declare class PushNotificationEvent<T extends SocketEventType = SocketEventType> extends BaseEvent<PushNotificationEventData<T>> {
30
+ constructor(eventName: T, data: SocketEventPayloads[T], recipients: EntitySubscription[], settings: NotificationSettings);
14
31
  get type(): T;
15
32
  get recipients(): EntitySubscription[];
16
- getPayload(): EventCtorPayload<(typeof REGISTRY)[T]>;
33
+ getPayload(): SocketEventPayloads[T];
17
34
  }
18
35
  export {};
@@ -1,13 +1,30 @@
1
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
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.PushNotificationEvent = void 0;
4
13
  const BaseEvent_1 = require("../event/BaseEvent");
5
- class PushNotificationEvent extends BaseEvent_1.BaseEvent {
6
- constructor(type, payload, recipients) {
7
- super('notification.push', { type, recipients, payload });
14
+ const metadata_1 = require("../event/decorators/metadata");
15
+ const EventEnums_1 = require("../event/EventEnums");
16
+ let PushNotificationEvent = class PushNotificationEvent extends BaseEvent_1.BaseEvent {
17
+ constructor(eventName, data, recipients, settings) {
18
+ const payload = data;
19
+ super(EventEnums_1.PublishEventEnums.SOCKET_PUSH_NOTIFICATION_EVENT, {
20
+ eventName,
21
+ recipients,
22
+ payload,
23
+ notificationSettings: settings,
24
+ });
8
25
  }
9
26
  get type() {
10
- return this.payload.type;
27
+ return this.payload.eventName;
11
28
  }
12
29
  get recipients() {
13
30
  return this.payload.recipients;
@@ -15,6 +32,14 @@ class PushNotificationEvent extends BaseEvent_1.BaseEvent {
15
32
  getPayload() {
16
33
  return this.payload.payload;
17
34
  }
18
- }
35
+ };
19
36
  exports.PushNotificationEvent = PushNotificationEvent;
37
+ exports.PushNotificationEvent = PushNotificationEvent = __decorate([
38
+ (0, metadata_1.EventMetadata)('notification.push', [
39
+ { name: 'eventName', type: 'SocketEventType' },
40
+ { name: 'recipients', type: 'EntitySubscription[]' },
41
+ { name: 'payload', type: 'any' },
42
+ ]),
43
+ __metadata("design:paramtypes", [String, Object, Array, Object])
44
+ ], PushNotificationEvent);
20
45
  //# sourceMappingURL=PushNotificationEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PushNotificationEvent.js","sourceRoot":"/","sources":["libraries/socket/PushNotificationEvent.ts"],"names":[],"mappings":";;;AAAA,kDAA+C;AAc/C,MAAa,qBAAuD,SAAQ,qBAE3E;IACA,YAAY,IAAO,EAAE,OAA+C,EAAE,UAAgC;QACrG,KAAK,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,UAAU;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7B,CAAC;CACD;AAlBD,sDAkBC","sourcesContent":["import { BaseEvent } from '../event/BaseEvent';\nimport { BaseSocketEvent, EntitySubscription } from './core';\nimport { REGISTRY } from './core/socket-event-registry.map';\n\ntype EventCtorPayload<T> = T extends { ctor: new (...args: any) => BaseSocketEvent<any, infer P> }\n\t? P\n\t: never;\n\nexport type PushNotificationEventData<T extends keyof typeof REGISTRY> = {\n\ttype: T;\n\trecipients: EntitySubscription[];\n\tpayload: EventCtorPayload<(typeof REGISTRY)[T]>;\n};\n\nexport class PushNotificationEvent<T extends keyof typeof REGISTRY> extends BaseEvent<\n\tPushNotificationEventData<T>\n> {\n\tconstructor(type: T, payload: EventCtorPayload<(typeof REGISTRY)[T]>, recipients: EntitySubscription[]) {\n\t\tsuper('notification.push', { type, recipients, payload });\n\t}\n\n\tget type(): T {\n\t\treturn this.payload.type;\n\t}\n\n\tget recipients(): EntitySubscription[] {\n\t\treturn this.payload.recipients;\n\t}\n\n\tgetPayload(): EventCtorPayload<(typeof REGISTRY)[T]> {\n\t\treturn this.payload.payload;\n\t}\n}\n"]}
1
+ {"version":3,"file":"PushNotificationEvent.js","sourceRoot":"/","sources":["libraries/socket/PushNotificationEvent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+C;AAG/C,2DAA6D;AAC7D,oDAAwD;AAgCjD,IAAM,qBAAqB,GAA3B,MAAM,qBAAmE,SAAQ,qBAEvF;IACA,YACC,SAAY,EACZ,IAA4B,EAC5B,UAAgC,EAChC,QAA8B;QAE9B,MAAM,OAAO,GAAG,IAAI,CAAC;QACrB,KAAK,CAAC,8BAAiB,CAAC,8BAA8B,EAAE;YACvD,SAAS;YACT,UAAU;YACV,OAAO;YACP,oBAAoB,EAAE,QAAQ;SACE,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,UAAU;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7B,CAAC;CACD,CAAA;AA7BY,sDAAqB;gCAArB,qBAAqB;IALjC,IAAA,wBAAa,EAAC,mBAAmB,EAAE;QACnC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,iBAAiB,EAAE;QAC9C,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,sBAAsB,EAAE;QACpD,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE;KAChC,CAAC;;GACW,qBAAqB,CA6BjC","sourcesContent":["import { BaseEvent } from '../event/BaseEvent';\nimport { SocketEventType, ClickType } from '../../utilities/enum';\nimport { EntitySubscription } from './core/socket-redis-connections';\nimport { EventMetadata } from '../event/decorators/metadata';\nimport { PublishEventEnums } from '../event/EventEnums';\nimport { REGISTRY } from './core/socket-event-registry.map';\n\n// Extract payload types from the registry - use pushNotificationOutput when available, otherwise output\ntype SocketEventPayloads = {\n\t[K in SocketEventType]: (typeof REGISTRY)[K] extends { schemas: { pushNotificationOutput: any } }\n\t\t? import('zod').infer<(typeof REGISTRY)[K]['schemas']['pushNotificationOutput']>\n\t\t: (typeof REGISTRY)[K] extends { schemas: { output: any } }\n\t\t\t? import('zod').infer<(typeof REGISTRY)[K]['schemas']['output']>\n\t\t\t: any;\n};\n\nexport type NotificationSettings =\n\t| { isPushNotification: false }\n\t| {\n\t\t\tisPushNotification: true;\n\t\t\tisClickable: boolean;\n\t\t\tclickType: ClickType;\n\t };\n\nexport type PushNotificationEventData<T extends SocketEventType = SocketEventType> = {\n\teventName: T;\n\trecipients: EntitySubscription[];\n\tpayload: SocketEventPayloads[T];\n\tnotificationSettings: NotificationSettings;\n};\n\n@EventMetadata('notification.push', [\n\t{ name: 'eventName', type: 'SocketEventType' },\n\t{ name: 'recipients', type: 'EntitySubscription[]' },\n\t{ name: 'payload', type: 'any' },\n])\nexport class PushNotificationEvent<T extends SocketEventType = SocketEventType> extends BaseEvent<\n\tPushNotificationEventData<T>\n> {\n\tconstructor(\n\t\teventName: T,\n\t\tdata: SocketEventPayloads[T],\n\t\trecipients: EntitySubscription[],\n\t\tsettings: NotificationSettings\n\t) {\n\t\tconst payload = data;\n\t\tsuper(PublishEventEnums.SOCKET_PUSH_NOTIFICATION_EVENT, {\n\t\t\teventName,\n\t\t\trecipients,\n\t\t\tpayload,\n\t\t\tnotificationSettings: settings,\n\t\t} as PushNotificationEventData<T>);\n\t}\n\n\tget type(): T {\n\t\treturn this.payload.eventName;\n\t}\n\n\tget recipients(): EntitySubscription[] {\n\t\treturn this.payload.recipients;\n\t}\n\n\tgetPayload(): SocketEventPayloads[T] {\n\t\treturn this.payload.payload;\n\t}\n}\n"]}
@@ -72,13 +72,10 @@ async function publishSocketEvent(event, recipients) {
72
72
  publishToInstances(subscribed, localKey, payload);
73
73
  }
74
74
  if (unsubscribed.length > 0) {
75
- const notificationEvent = event.notification?.();
76
- const pushNotificationEvent = event.pushNotification;
77
- if (pushNotificationEvent) {
78
- (0, event_1.publishEvent)(new PushNotificationEvent_1.PushNotificationEvent(event.eventType(), event.payload(), unsubscribed)).catch(err => console.error('[Socket] Push failed:', err));
79
- }
80
- if (notificationEvent) {
81
- publishNotificationSocketEvent(notificationEvent, unsubscribed).catch(err => console.error('[Socket] Notification failed:', err));
75
+ if (event.notificationSettings?.isPushNotification) {
76
+ const pushNotificationPayload = event.getPushNotificationPayload();
77
+ const settings = event.notificationSettings;
78
+ await (0, event_1.publishEvent)(new PushNotificationEvent_1.PushNotificationEvent(event.eventType(), pushNotificationPayload, unsubscribed, settings)).catch(err => console.error('[Socket] Push failed:', err));
82
79
  }
83
80
  }
84
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"socket-event-publisher.js","sourceRoot":"/","sources":["libraries/socket/core/socket-event-publisher.ts"],"names":[],"mappings":";;AA6FA,gDA8BC;AAGD,wEAmCC;AAjKD,gCAAwC;AAExC,yEAA0F;AAE1F,uCAA6F;AAC7F,oEAAiE;AAIjE,MAAM,eAAe,GAAG;IACvB,WAAW,EAAE,kBAAkB;IAC/B,UAAU,EAAE,IAAI;CACP,CAAC;AAGX,SAAS,kBAAkB,CAC1B,uBAAsF,EACtF,QAAgB,EAChB,OAAY;IAEZ,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC;QAAE,OA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AM,cAAc,GAAkE,EAAE,CAAC;IAGzF,MAAM,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,SAAS,EAAC,EAAE;QAChC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,IAAA,mDAAwB,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;QAEzF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzC,IAAI,CAAC;oBACJ,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC1C,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;gBACxC,CAAC;gBAAC,MAAM,CAAC;gBAET,CAAC;YACF,CAAC;YACD,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC1B,cAAc,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACxE,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CACF,CAAC;IAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,kBAAkB,CAAC,cAAc,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;AACF,CAAC","sourcesContent":["import { getLibraries } from '../../..';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { EntitySubscription, getEntityEventSocketsKey } from './socket-redis-connections';\nimport { NotificationSocketEvent } from '../events';\nimport { EXCHANGE_NAME, getChannel, INSTANCE_ROUTE_PREFIX, publishEvent } from '../../event';\nimport { PushNotificationEvent } from '../PushNotificationEvent';\nimport { PushNotificationEventType } from '../../../utilities/enum';\n\n// Reusable publish options\nconst PUBLISH_OPTIONS = {\n\tcontentType: 'application/json',\n\tpersistent: true,\n} as const;\n\n// Zero-overhead publishing - minimal allocations\nfunction publishToInstances(\n\trecipientsWithInstances: Array<{ recipient: EntitySubscription; instances: string[] }>,\n\tlocalKey: string,\n\tpayload: any\n): void {\n\tif (recipientsWithInstances.length === 0) return;\n\n\tconst channel = getChannel();\n\n\t// Pre-serialize message once\n\tconst message = { localKey, payload, recipient: null as any };\n\n\t// Fire-and-forget with minimal overhead\n\tfor (let i = 0; i < recipientsWithInstances.length; i++) {\n\t\tconst { recipient, instances } = recipientsWithInstances[i];\n\t\tmessage.recipient = recipient;\n\t\tconst messageStr = JSON.stringify(message);\n\n\t\tfor (let j = 0; j < instances.length; j++) {\n\t\t\tconst routingKey = `${INSTANCE_ROUTE_PREFIX}.${instances[j]}`;\n\n\t\t\ttry {\n\t\t\t\t// Direct publish - Buffer.from creates minimal overhead\n\t\t\t\tchannel.publish(EXCHANGE_NAME, routingKey, Buffer.from(messageStr, 'utf8'), PUBLISH_OPTIONS);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`[Socket] Publish failed: ${routingKey}`, error);\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Ultra-simple: Direct Redis lookups, no batch/cache/parsing!\nasync function getActiveSubscribedRecipients(\n\trecipients: EntitySubscription[],\n\tlocalKey: string\n): Promise<{\n\tsubscribed: Array<{ recipient: EntitySubscription; instances: string[] }>;\n\tunsubscribed: EntitySubscription[];\n}> {\n\tif (recipients.length === 0) {\n\t\treturn { subscribed: [], unsubscribed: [] };\n\t}\n\n\tconst redis = getLibraries().getRedisService();\n\tconst subscribed: Array<{ recipient: EntitySubscription; instances: string[] }> = [];\n\tconst unsubscribed: EntitySubscription[] = [];\n\n\t// Parallel lookups - one key per recipient\n\tawait Promise.all(\n\t\trecipients.map(async recipient => {\n\t\t\tconst sockets = await redis.getSetMembers(getEntityEventSocketsKey(recipient, localKey));\n\n\t\t\tif (sockets.length > 0) {\n\t\t\t\t// Extract instances\n\t\t\t\tconst instanceSet = new Set<string>();\n\t\t\t\tfor (let i = 0; i < sockets.length; i++) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst socketInfo = JSON.parse(sockets[i]);\n\t\t\t\t\t\tinstanceSet.add(socketInfo.instanceId);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Skip malformed socket data\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (instanceSet.size > 0) {\n\t\t\t\t\tsubscribed.push({ recipient, instances: Array.from(instanceSet) });\n\t\t\t\t} else {\n\t\t\t\t\tunsubscribed.push(recipient);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tunsubscribed.push(recipient);\n\t\t\t}\n\t\t})\n\t);\n\n\treturn { subscribed, unsubscribed };\n}\n\n// Minimal overhead publish - early returns, lazy evaluation\nexport async function publishSocketEvent(\n\tevent: BaseSocketEvent<any, any>,\n\trecipients: EntitySubscription[]\n): Promise<void> {\n\tif (recipients.length === 0) return;\n\n\tconst localKey = event.getSubscriptionKey();\n\tconst payload = event.payload();\n\n\tconst { subscribed, unsubscribed } = await getActiveSubscribedRecipients(recipients, localKey);\n\n\tif (subscribed.length > 0) {\n\t\tpublishToInstances(subscribed, localKey, payload);\n\t}\n\n\tif (unsubscribed.length > 0) {\n\t\tconst notificationEvent = event.notification?.();\n\t\tconst pushNotificationEvent = event.pushNotification;\n\t\tif (pushNotificationEvent) {\n\t\t\tpublishEvent(new PushNotificationEvent(event.eventType(), event.payload(), unsubscribed)).catch(err =>\n\t\t\t\tconsole.error('[Socket] Push failed:', err)\n\t\t\t);\n\t\t}\n\n\t\tif (notificationEvent) {\n\t\t\tpublishNotificationSocketEvent(notificationEvent, unsubscribed).catch(err =>\n\t\t\t\tconsole.error('[Socket] Notification failed:', err)\n\t\t\t);\n\t\t}\n\t}\n}\n\n// Ultra-simple notification publish: Direct lookups!\nexport async function publishNotificationSocketEvent(\n\tevent: NotificationSocketEvent,\n\trecipients: EntitySubscription[]\n): Promise<void> {\n\tif (recipients.length === 0) return;\n\n\tconst eventKey = event.getSubscriptionKey();\n\tconst redis = getLibraries().getRedisService();\n\tconst validInstances: Array<{ recipient: EntitySubscription; instances: string[] }> = [];\n\n\t// Parallel direct lookups\n\tawait Promise.all(\n\t\trecipients.map(async recipient => {\n\t\t\tconst sockets = await redis.getSetMembers(getEntityEventSocketsKey(recipient, eventKey));\n\n\t\t\tif (sockets.length > 0) {\n\t\t\t\tconst instanceSet = new Set<string>();\n\t\t\t\tfor (let i = 0; i < sockets.length; i++) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst socketInfo = JSON.parse(sockets[i]);\n\t\t\t\t\t\tinstanceSet.add(socketInfo.instanceId);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Skip malformed socket data\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (instanceSet.size > 0) {\n\t\t\t\t\tvalidInstances.push({ recipient, instances: Array.from(instanceSet) });\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t);\n\n\tif (validInstances.length > 0) {\n\t\tpublishToInstances(validInstances, eventKey, event.payload());\n\t}\n}\n"]}
1
+ {"version":3,"file":"socket-event-publisher.js","sourceRoot":"/","sources":["libraries/socket/core/socket-event-publisher.ts"],"names":[],"mappings":";;AA6FA,gDAwBC;AAED,wEAmCC;AA1JD,gCAAwC;AAExC,yEAA0F;AAE1F,uCAA6F;AAC7F,oEAAuF;AAIvF,MAAM,eAAe,GAAG;IACvB,WAAW,EAAE,kBAAkB;IAC/B,UAAU,EAAE,IAAI;CACP,CAAC;AAGX,SAAS,kBAAkB,CAC1B,uBAAsF,EACtF,QAAgB,EAChB,OAAY;IAEZ,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEjD,MAAM,OAAO,GAAG,IAAA,kBAAU,GAAE,CAAC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CAAC,CAAC;QAEzF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzC,IAAI,CAAC;oBACJ,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC1C,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;gBACxC,CAAC;gBAAC,MAAM,CAAC;gBAET,CAAC;YACF,CAAC;YACD,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC1B,cAAc,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACxE,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CACF,CAAC;IAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,kBAAkB,CAAC,cAAc,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;AACF,CAAC","sourcesContent":["import { getLibraries } from '../../..';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { EntitySubscription, getEntityEventSocketsKey } from './socket-redis-connections';\nimport { NotificationSocketEvent } from '../events';\nimport { EXCHANGE_NAME, getChannel, INSTANCE_ROUTE_PREFIX, publishEvent } from '../../event';\nimport { PushNotificationEvent, NotificationSettings } from '../PushNotificationEvent';\nimport { PushNotificationEventType, ClickType } from '../../../utilities/enum';\n\n// Reusable publish options\nconst PUBLISH_OPTIONS = {\n\tcontentType: 'application/json',\n\tpersistent: true,\n} as const;\n\n// Zero-overhead publishing - minimal allocations\nfunction publishToInstances(\n\trecipientsWithInstances: Array<{ recipient: EntitySubscription; instances: string[] }>,\n\tlocalKey: string,\n\tpayload: any\n): void {\n\tif (recipientsWithInstances.length === 0) return;\n\n\tconst channel = getChannel();\n\n\t// Pre-serialize message once\n\tconst message = { localKey, payload, recipient: null as any };\n\n\t// Fire-and-forget with minimal overhead\n\tfor (let i = 0; i < recipientsWithInstances.length; i++) {\n\t\tconst { recipient, instances } = recipientsWithInstances[i];\n\t\tmessage.recipient = recipient;\n\t\tconst messageStr = JSON.stringify(message);\n\n\t\tfor (let j = 0; j < instances.length; j++) {\n\t\t\tconst routingKey = `${INSTANCE_ROUTE_PREFIX}.${instances[j]}`;\n\n\t\t\ttry {\n\t\t\t\t// Direct publish - Buffer.from creates minimal overhead\n\t\t\t\tchannel.publish(EXCHANGE_NAME, routingKey, Buffer.from(messageStr, 'utf8'), PUBLISH_OPTIONS);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(`[Socket] Publish failed: ${routingKey}`, error);\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Ultra-simple: Direct Redis lookups, no batch/cache/parsing!\nasync function getActiveSubscribedRecipients(\n\trecipients: EntitySubscription[],\n\tlocalKey: string\n): Promise<{\n\tsubscribed: Array<{ recipient: EntitySubscription; instances: string[] }>;\n\tunsubscribed: EntitySubscription[];\n}> {\n\tif (recipients.length === 0) {\n\t\treturn { subscribed: [], unsubscribed: [] };\n\t}\n\n\tconst redis = getLibraries().getRedisService();\n\tconst subscribed: Array<{ recipient: EntitySubscription; instances: string[] }> = [];\n\tconst unsubscribed: EntitySubscription[] = [];\n\n\t// Parallel lookups - one key per recipient\n\tawait Promise.all(\n\t\trecipients.map(async recipient => {\n\t\t\tconst sockets = await redis.getSetMembers(getEntityEventSocketsKey(recipient, localKey));\n\n\t\t\tif (sockets.length > 0) {\n\t\t\t\t// Extract instances\n\t\t\t\tconst instanceSet = new Set<string>();\n\t\t\t\tfor (let i = 0; i < sockets.length; i++) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst socketInfo = JSON.parse(sockets[i]);\n\t\t\t\t\t\tinstanceSet.add(socketInfo.instanceId);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Skip malformed socket data\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (instanceSet.size > 0) {\n\t\t\t\t\tsubscribed.push({ recipient, instances: Array.from(instanceSet) });\n\t\t\t\t} else {\n\t\t\t\t\tunsubscribed.push(recipient);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tunsubscribed.push(recipient);\n\t\t\t}\n\t\t})\n\t);\n\n\treturn { subscribed, unsubscribed };\n}\n\n// Minimal overhead publish - early returns, lazy evaluation\nexport async function publishSocketEvent(\n\tevent: BaseSocketEvent<any, any>,\n\trecipients: EntitySubscription[]\n): Promise<void> {\n\tif (recipients.length === 0) return;\n\n\tconst localKey = event.getSubscriptionKey();\n\tconst payload = event.payload();\n\n\tconst { subscribed, unsubscribed } = await getActiveSubscribedRecipients(recipients, localKey);\n\n\tif (subscribed.length > 0) {\n\t\tpublishToInstances(subscribed, localKey, payload);\n\t}\n\n\tif (unsubscribed.length > 0) {\n\t\tif (event.notificationSettings?.isPushNotification) {\n\t\t\tconst pushNotificationPayload = event.getPushNotificationPayload();\n\t\t\tconst settings = event.notificationSettings;\n\t\t\tawait publishEvent(\n\t\t\t\tnew PushNotificationEvent(event.eventType(), pushNotificationPayload, unsubscribed, settings)\n\t\t\t).catch(err => console.error('[Socket] Push failed:', err));\n\t\t}\n\t}\n}\n\nexport async function publishNotificationSocketEvent(\n\tevent: NotificationSocketEvent,\n\trecipients: EntitySubscription[]\n): Promise<void> {\n\tif (recipients.length === 0) return;\n\n\tconst eventKey = event.getSubscriptionKey();\n\tconst redis = getLibraries().getRedisService();\n\tconst validInstances: Array<{ recipient: EntitySubscription; instances: string[] }> = [];\n\n\t// Parallel direct lookups\n\tawait Promise.all(\n\t\trecipients.map(async recipient => {\n\t\t\tconst sockets = await redis.getSetMembers(getEntityEventSocketsKey(recipient, eventKey));\n\n\t\t\tif (sockets.length > 0) {\n\t\t\t\tconst instanceSet = new Set<string>();\n\t\t\t\tfor (let i = 0; i < sockets.length; i++) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst socketInfo = JSON.parse(sockets[i]);\n\t\t\t\t\t\tinstanceSet.add(socketInfo.instanceId);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Skip malformed socket data\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (instanceSet.size > 0) {\n\t\t\t\t\tvalidInstances.push({ recipient, instances: Array.from(instanceSet) });\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t);\n\n\tif (validInstances.length > 0) {\n\t\tpublishToInstances(validInstances, eventKey, event.payload());\n\t}\n}\n"]}
@@ -5,6 +5,7 @@ import { EventRegistration } from './index';
5
5
  import { NotificationSocketEvent } from '../events/notification.socket.event';
6
6
  import { RiderConnectSocketEvent } from '../events/rider-connect.socket.event';
7
7
  import { RiderLocationUpdateSocketEvent } from '../events/rider-location-update.socket.event';
8
+ import { TicketActionsSocketEvent } from '../events/ticket-actions.socket.event';
8
9
  export declare const REGISTRY: {
9
10
  readonly CHATROOM_MESSAGE_SEND: {
10
11
  readonly ctor: typeof ChatroomMessageSendSocketEvent;
@@ -142,6 +143,34 @@ export declare const REGISTRY: {
142
143
  createdAt: Date;
143
144
  } | undefined;
144
145
  }>;
146
+ pushNotificationOutput: import("zod").ZodObject<{
147
+ chatroomId: import("zod").ZodEffects<import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
148
+ lastMessage: import("zod").ZodOptional<import("zod").ZodObject<{
149
+ content: import("zod").ZodString | import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, string, string>;
150
+ createdAt: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodDate, Date, Date>, Date, Date>;
151
+ }, "strip", import("zod").ZodTypeAny, {
152
+ content: string;
153
+ createdAt: Date;
154
+ }, {
155
+ content: string;
156
+ createdAt: Date;
157
+ }>>;
158
+ unreadCount: import("zod").ZodNumber;
159
+ }, "strip", import("zod").ZodTypeAny, {
160
+ unreadCount: number;
161
+ chatroomId: import("mongoose").Types.ObjectId;
162
+ lastMessage?: {
163
+ content: string;
164
+ createdAt: Date;
165
+ } | undefined;
166
+ }, {
167
+ unreadCount: number;
168
+ chatroomId: import("mongoose").Types.ObjectId;
169
+ lastMessage?: {
170
+ content: string;
171
+ createdAt: Date;
172
+ } | undefined;
173
+ }>;
145
174
  };
146
175
  };
147
176
  readonly TICKET_ASSIGN: {
@@ -293,6 +322,32 @@ export declare const REGISTRY: {
293
322
  };
294
323
  readonly identifier: typeof RiderLocationUpdateSocketEvent.identifier;
295
324
  };
325
+ readonly TICKET_ACCEPT: {
326
+ readonly ctor: typeof TicketActionsSocketEvent;
327
+ readonly schemas: {
328
+ input: import("zod").ZodUndefined;
329
+ output: import("zod").ZodObject<{
330
+ _id: import("zod").ZodEffects<import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
331
+ status: import("zod").ZodNativeEnum<typeof import("../../../utilities/enum").TicketStatus>;
332
+ }, "strip", import("zod").ZodTypeAny, {
333
+ status: import("../../../utilities/enum").TicketStatus;
334
+ _id: import("mongoose").Types.ObjectId;
335
+ }, {
336
+ status: import("../../../utilities/enum").TicketStatus;
337
+ _id: import("mongoose").Types.ObjectId;
338
+ }>;
339
+ pushNotificationOutput: import("zod").ZodObject<{
340
+ _id: import("zod").ZodEffects<import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
341
+ status: import("zod").ZodNativeEnum<typeof import("../../../utilities/enum").TicketStatus>;
342
+ }, "strip", import("zod").ZodTypeAny, {
343
+ status: import("../../../utilities/enum").TicketStatus;
344
+ _id: import("mongoose").Types.ObjectId;
345
+ }, {
346
+ status: import("../../../utilities/enum").TicketStatus;
347
+ _id: import("mongoose").Types.ObjectId;
348
+ }>;
349
+ };
350
+ };
296
351
  };
297
352
  export type Registry = {
298
353
  [K in keyof typeof REGISTRY]: (typeof REGISTRY)[K] extends EventRegistration<any> ? (typeof REGISTRY)[K] : never;
@@ -8,6 +8,7 @@ const ticket_unassign_socket_event_1 = require("../events/ticket-unassign.socket
8
8
  const notification_socket_event_1 = require("../events/notification.socket.event");
9
9
  const rider_connect_socket_event_1 = require("../events/rider-connect.socket.event");
10
10
  const rider_location_update_socket_event_1 = require("../events/rider-location-update.socket.event");
11
+ const ticket_actions_socket_event_1 = require("../events/ticket-actions.socket.event");
11
12
  exports.REGISTRY = {
12
13
  [enum_1.SocketEventType.CHATROOM_MESSAGE_SEND]: {
13
14
  ctor: events_1.ChatroomMessageSendSocketEvent,
@@ -40,5 +41,9 @@ exports.REGISTRY = {
40
41
  schemas: rider_location_update_socket_event_1.RiderLocationUpdateSocketEvent.schemas,
41
42
  identifier: rider_location_update_socket_event_1.RiderLocationUpdateSocketEvent.identifier,
42
43
  },
44
+ [enum_1.SocketEventType.TICKET_ACTIONS]: {
45
+ ctor: ticket_actions_socket_event_1.TicketActionsSocketEvent,
46
+ schemas: ticket_actions_socket_event_1.TicketActionsSocketEvent.schemas,
47
+ },
43
48
  };
44
49
  //# sourceMappingURL=socket-event-registry.map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"socket-event-registry.map.js","sourceRoot":"/","sources":["libraries/socket/core/socket-event-registry.map.ts"],"names":[],"mappings":";;;AAAA,kDAA0D;AAC1D,sCAA2F;AAC3F,qFAAyE;AACzE,yFAA6E;AAE7E,mFAA8E;AAC9E,qFAA+E;AAC/E,qGAA8F;AAEjF,QAAA,QAAQ,GAAG;IACvB,CAAC,sBAAe,CAAC,qBAAqB,CAAC,EAAE;QACxC,IAAI,EAAE,uCAA8B;QACpC,OAAO,EAAE,uCAA8B,CAAC,OAAO;QAC/C,UAAU,EAAE,uCAA8B,CAAC,UAAU;KACrD;IACD,CAAC,sBAAe,CAAC,yBAAyB,CAAC,EAAE;QAC5C,IAAI,EAAE,uCAA8B;QACpC,OAAO,EAAE,uCAA8B,CAAC,OAAO;KAC/C;IACD,CAAC,sBAAe,CAAC,aAAa,CAAC,EAAE;QAChC,IAAI,EAAE,8CAAiB;QACvB,OAAO,EAAE,8CAAiB,CAAC,OAAO;KAClC;IACD,CAAC,sBAAe,CAAC,eAAe,CAAC,EAAE;QAClC,IAAI,EAAE,kDAAmB;QACzB,OAAO,EAAE,kDAAmB,CAAC,OAAO;QACpC,UAAU,EAAE,kDAAmB,CAAC,UAAU;KAC1C;IACD,CAAC,sBAAe,CAAC,YAAY,CAAC,EAAE;QAC/B,IAAI,EAAE,mDAAuB;QAC7B,OAAO,EAAE,mDAAuB,CAAC,OAAO;KACxC;IACD,CAAC,sBAAe,CAAC,aAAa,CAAC,EAAE;QAChC,IAAI,EAAE,oDAAuB;QAC7B,OAAO,EAAE,oDAAuB,CAAC,OAAO;KACxC;IACD,CAAC,sBAAe,CAAC,qBAAqB,CAAC,EAAE;QACxC,IAAI,EAAE,mEAA8B;QACpC,OAAO,EAAE,mEAA8B,CAAC,OAAO;QAC/C,UAAU,EAAE,mEAA8B,CAAC,UAAU;KACrD;CACQ,CAAC","sourcesContent":["import { SocketEventType } from '../../../utilities/enum';\nimport { ChatlistMessageSendSocketEvent, ChatroomMessageSendSocketEvent } from '../events';\nimport { TicketAssignEvent } from '../events/ticket-assign.socket.event';\nimport { TicketUnassignEvent } from '../events/ticket-unassign.socket.event';\nimport { EventRegistration } from './index';\nimport { NotificationSocketEvent } from '../events/notification.socket.event';\nimport { RiderConnectSocketEvent } from '../events/rider-connect.socket.event';\nimport { RiderLocationUpdateSocketEvent } from '../events/rider-location-update.socket.event';\n\nexport const REGISTRY = {\n\t[SocketEventType.CHATROOM_MESSAGE_SEND]: {\n\t\tctor: ChatroomMessageSendSocketEvent,\n\t\tschemas: ChatroomMessageSendSocketEvent.schemas,\n\t\tidentifier: ChatroomMessageSendSocketEvent.identifier,\n\t},\n\t[SocketEventType.CHATLIST_MESSAGE_RECEIVED]: {\n\t\tctor: ChatlistMessageSendSocketEvent,\n\t\tschemas: ChatlistMessageSendSocketEvent.schemas,\n\t},\n\t[SocketEventType.TICKET_ASSIGN]: {\n\t\tctor: TicketAssignEvent,\n\t\tschemas: TicketAssignEvent.schemas,\n\t},\n\t[SocketEventType.TICKET_UNASSIGN]: {\n\t\tctor: TicketUnassignEvent,\n\t\tschemas: TicketUnassignEvent.schemas,\n\t\tidentifier: TicketUnassignEvent.identifier,\n\t},\n\t[SocketEventType.NOTIFICATION]: {\n\t\tctor: NotificationSocketEvent,\n\t\tschemas: NotificationSocketEvent.schemas,\n\t},\n\t[SocketEventType.RIDER_CONNECT]: {\n\t\tctor: RiderConnectSocketEvent,\n\t\tschemas: RiderConnectSocketEvent.schemas,\n\t},\n\t[SocketEventType.RIDER_LOCATION_UPDATE]: {\n\t\tctor: RiderLocationUpdateSocketEvent,\n\t\tschemas: RiderLocationUpdateSocketEvent.schemas,\n\t\tidentifier: RiderLocationUpdateSocketEvent.identifier,\n\t},\n} as const;\n\nexport type Registry = {\n\t[K in keyof typeof REGISTRY]: (typeof REGISTRY)[K] extends EventRegistration<any>\n\t\t? (typeof REGISTRY)[K]\n\t\t: never;\n};\n"]}
1
+ {"version":3,"file":"socket-event-registry.map.js","sourceRoot":"/","sources":["libraries/socket/core/socket-event-registry.map.ts"],"names":[],"mappings":";;;AAAA,kDAA0D;AAC1D,sCAA2F;AAC3F,qFAAyE;AACzE,yFAA6E;AAE7E,mFAA8E;AAC9E,qFAA+E;AAC/E,qGAA8F;AAC9F,uFAAiF;AAEpE,QAAA,QAAQ,GAAG;IACvB,CAAC,sBAAe,CAAC,qBAAqB,CAAC,EAAE;QACxC,IAAI,EAAE,uCAA8B;QACpC,OAAO,EAAE,uCAA8B,CAAC,OAAO;QAC/C,UAAU,EAAE,uCAA8B,CAAC,UAAU;KACrD;IACD,CAAC,sBAAe,CAAC,yBAAyB,CAAC,EAAE;QAC5C,IAAI,EAAE,uCAA8B;QACpC,OAAO,EAAE,uCAA8B,CAAC,OAAO;KAC/C;IACD,CAAC,sBAAe,CAAC,aAAa,CAAC,EAAE;QAChC,IAAI,EAAE,8CAAiB;QACvB,OAAO,EAAE,8CAAiB,CAAC,OAAO;KAClC;IACD,CAAC,sBAAe,CAAC,eAAe,CAAC,EAAE;QAClC,IAAI,EAAE,kDAAmB;QACzB,OAAO,EAAE,kDAAmB,CAAC,OAAO;QACpC,UAAU,EAAE,kDAAmB,CAAC,UAAU;KAC1C;IACD,CAAC,sBAAe,CAAC,YAAY,CAAC,EAAE;QAC/B,IAAI,EAAE,mDAAuB;QAC7B,OAAO,EAAE,mDAAuB,CAAC,OAAO;KACxC;IACD,CAAC,sBAAe,CAAC,aAAa,CAAC,EAAE;QAChC,IAAI,EAAE,oDAAuB;QAC7B,OAAO,EAAE,oDAAuB,CAAC,OAAO;KACxC;IACD,CAAC,sBAAe,CAAC,qBAAqB,CAAC,EAAE;QACxC,IAAI,EAAE,mEAA8B;QACpC,OAAO,EAAE,mEAA8B,CAAC,OAAO;QAC/C,UAAU,EAAE,mEAA8B,CAAC,UAAU;KACrD;IACD,CAAC,sBAAe,CAAC,cAAc,CAAC,EAAE;QACjC,IAAI,EAAE,sDAAwB;QAC9B,OAAO,EAAE,sDAAwB,CAAC,OAAO;KACzC;CACQ,CAAC","sourcesContent":["import { SocketEventType } from '../../../utilities/enum';\nimport { ChatlistMessageSendSocketEvent, ChatroomMessageSendSocketEvent } from '../events';\nimport { TicketAssignEvent } from '../events/ticket-assign.socket.event';\nimport { TicketUnassignEvent } from '../events/ticket-unassign.socket.event';\nimport { EventRegistration } from './index';\nimport { NotificationSocketEvent } from '../events/notification.socket.event';\nimport { RiderConnectSocketEvent } from '../events/rider-connect.socket.event';\nimport { RiderLocationUpdateSocketEvent } from '../events/rider-location-update.socket.event';\nimport { TicketActionsSocketEvent } from '../events/ticket-actions.socket.event';\n\nexport const REGISTRY = {\n\t[SocketEventType.CHATROOM_MESSAGE_SEND]: {\n\t\tctor: ChatroomMessageSendSocketEvent,\n\t\tschemas: ChatroomMessageSendSocketEvent.schemas,\n\t\tidentifier: ChatroomMessageSendSocketEvent.identifier,\n\t},\n\t[SocketEventType.CHATLIST_MESSAGE_RECEIVED]: {\n\t\tctor: ChatlistMessageSendSocketEvent,\n\t\tschemas: ChatlistMessageSendSocketEvent.schemas,\n\t},\n\t[SocketEventType.TICKET_ASSIGN]: {\n\t\tctor: TicketAssignEvent,\n\t\tschemas: TicketAssignEvent.schemas,\n\t},\n\t[SocketEventType.TICKET_UNASSIGN]: {\n\t\tctor: TicketUnassignEvent,\n\t\tschemas: TicketUnassignEvent.schemas,\n\t\tidentifier: TicketUnassignEvent.identifier,\n\t},\n\t[SocketEventType.NOTIFICATION]: {\n\t\tctor: NotificationSocketEvent,\n\t\tschemas: NotificationSocketEvent.schemas,\n\t},\n\t[SocketEventType.RIDER_CONNECT]: {\n\t\tctor: RiderConnectSocketEvent,\n\t\tschemas: RiderConnectSocketEvent.schemas,\n\t},\n\t[SocketEventType.RIDER_LOCATION_UPDATE]: {\n\t\tctor: RiderLocationUpdateSocketEvent,\n\t\tschemas: RiderLocationUpdateSocketEvent.schemas,\n\t\tidentifier: RiderLocationUpdateSocketEvent.identifier,\n\t},\n\t[SocketEventType.TICKET_ACTIONS]: {\n\t\tctor: TicketActionsSocketEvent,\n\t\tschemas: TicketActionsSocketEvent.schemas,\n\t},\n} as const;\n\nexport type Registry = {\n\t[K in keyof typeof REGISTRY]: (typeof REGISTRY)[K] extends EventRegistration<any>\n\t\t? (typeof REGISTRY)[K]\n\t\t: never;\n};\n"]}
@@ -1,4 +1,5 @@
1
1
  import z from 'zod';
2
+ import { ClickType } from '../../../utilities/enum';
2
3
  import { DTO } from '../../../utilities/validation';
3
4
  import { BaseSocketEvent } from '../BaseSocketEvent';
4
5
  export declare const ChatlistMessageSendSocketInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
@@ -30,8 +31,38 @@ export declare const ChatlistMessageSendSocketOutputSchema: z.ZodObject<{
30
31
  createdAt: Date;
31
32
  } | undefined;
32
33
  }>;
34
+ export declare const ChatlistMessageSendPushOutputSchema: z.ZodObject<{
35
+ chatroomId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
36
+ lastMessage: z.ZodOptional<z.ZodObject<{
37
+ content: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
38
+ createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ content: string;
41
+ createdAt: Date;
42
+ }, {
43
+ content: string;
44
+ createdAt: Date;
45
+ }>>;
46
+ unreadCount: z.ZodNumber;
47
+ }, "strip", z.ZodTypeAny, {
48
+ unreadCount: number;
49
+ chatroomId: import("mongoose").Types.ObjectId;
50
+ lastMessage?: {
51
+ content: string;
52
+ createdAt: Date;
53
+ } | undefined;
54
+ }, {
55
+ unreadCount: number;
56
+ chatroomId: import("mongoose").Types.ObjectId;
57
+ lastMessage?: {
58
+ content: string;
59
+ createdAt: Date;
60
+ } | undefined;
61
+ }>;
62
+ export type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatlistMessageSendPushOutputSchema>;
33
63
  export type ChatlistMessageSendSocketOutputDTO = DTO<typeof ChatlistMessageSendSocketOutputSchema>;
34
- export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<typeof ChatlistMessageSendSocketInputSchema, typeof ChatlistMessageSendSocketOutputSchema> {
64
+ export type ChatlistMessageSendSocketInputDTO = DTO<typeof ChatlistMessageSendSocketInputSchema>;
65
+ export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<typeof ChatlistMessageSendSocketInputSchema, typeof ChatlistMessageSendSocketOutputSchema, typeof ChatlistMessageSendPushOutputSchema> {
35
66
  static readonly schemas: {
36
67
  input: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
37
68
  output: z.ZodObject<{
@@ -62,6 +93,39 @@ export declare class ChatlistMessageSendSocketEvent extends BaseSocketEvent<type
62
93
  createdAt: Date;
63
94
  } | undefined;
64
95
  }>;
96
+ pushNotificationOutput: z.ZodObject<{
97
+ chatroomId: z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>;
98
+ lastMessage: z.ZodOptional<z.ZodObject<{
99
+ content: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
100
+ createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ content: string;
103
+ createdAt: Date;
104
+ }, {
105
+ content: string;
106
+ createdAt: Date;
107
+ }>>;
108
+ unreadCount: z.ZodNumber;
109
+ }, "strip", z.ZodTypeAny, {
110
+ unreadCount: number;
111
+ chatroomId: import("mongoose").Types.ObjectId;
112
+ lastMessage?: {
113
+ content: string;
114
+ createdAt: Date;
115
+ } | undefined;
116
+ }, {
117
+ unreadCount: number;
118
+ chatroomId: import("mongoose").Types.ObjectId;
119
+ lastMessage?: {
120
+ content: string;
121
+ createdAt: Date;
122
+ } | undefined;
123
+ }>;
124
+ };
125
+ static readonly notificationSettings: {
126
+ isPushNotification: boolean;
127
+ isClickable: boolean;
128
+ clickType: ClickType;
65
129
  };
66
- constructor(payload: ChatlistMessageSendSocketOutputDTO);
130
+ constructor(payload: ChatlistMessageSendSocketOutputDTO, pushNotificationPayload?: ChatlistMessageSendPushOutputDTO);
67
131
  }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ChatlistMessageSendSocketEvent = exports.ChatlistMessageSendSocketOutputSchema = exports.ChatlistMessageSendSocketInputSchema = void 0;
6
+ exports.ChatlistMessageSendSocketEvent = exports.ChatlistMessageSendPushOutputSchema = exports.ChatlistMessageSendSocketOutputSchema = exports.ChatlistMessageSendSocketInputSchema = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
8
  const enum_1 = require("../../../utilities/enum");
9
9
  const validation_1 = require("../../../utilities/validation");
@@ -19,13 +19,20 @@ exports.ChatlistMessageSendSocketOutputSchema = zod_1.default.object({
19
19
  .optional(),
20
20
  unreadCount: validation_1.ZodValidation.number(),
21
21
  });
22
+ exports.ChatlistMessageSendPushOutputSchema = exports.ChatlistMessageSendSocketOutputSchema;
22
23
  class ChatlistMessageSendSocketEvent extends BaseSocketEvent_1.BaseSocketEvent {
23
24
  static schemas = {
24
25
  input: exports.ChatlistMessageSendSocketInputSchema,
25
26
  output: exports.ChatlistMessageSendSocketOutputSchema,
27
+ pushNotificationOutput: exports.ChatlistMessageSendPushOutputSchema,
26
28
  };
27
- constructor(payload) {
28
- super(enum_1.SocketEventType.CHATLIST_MESSAGE_RECEIVED, ChatlistMessageSendSocketEvent.schemas, payload);
29
+ static notificationSettings = {
30
+ isPushNotification: true,
31
+ isClickable: true,
32
+ clickType: enum_1.ClickType.CLICKABLE_MESSAGE,
33
+ };
34
+ constructor(payload, pushNotificationPayload) {
35
+ super(enum_1.SocketEventType.CHATLIST_MESSAGE_RECEIVED, ChatlistMessageSendSocketEvent.schemas, payload, pushNotificationPayload);
29
36
  }
30
37
  }
31
38
  exports.ChatlistMessageSendSocketEvent = ChatlistMessageSendSocketEvent;
@@ -1 +1 @@
1
- {"version":3,"file":"chatlist-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/chatlist-message-send.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAA0D;AAC1D,8DAAmE;AACnE,wDAAqD;AAExC,QAAA,oCAAoC,GAAG,aAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACpD,QAAA,qCAAqC,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7D,UAAU,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,EAAE;IAC3C,WAAW,EAAE,aAAC;SACZ,MAAM,CAAC;QACP,OAAO,EAAE,0BAAa,CAAC,MAAM,EAAE;QAC/B,SAAS,EAAE,0BAAa,CAAC,MAAM,CAAC,IAAI,EAAE;KACtC,CAAC;SACD,QAAQ,EAAE;IACZ,WAAW,EAAE,0BAAa,CAAC,MAAM,EAAE;CACnC,CAAC,CAAC;AAIH,MAAa,8BAA+B,SAAQ,iCAGnD;IACA,MAAM,CAAU,OAAO,GAAG;QACzB,KAAK,EAAE,4CAAoC;QAC3C,MAAM,EAAE,6CAAqC;KAC7C,CAAC;IAEF,YAAY,OAA2C;QACtD,KAAK,CAAC,sBAAe,CAAC,yBAAyB,EAAE,8BAA8B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnG,CAAC;;AAXF,wEAYC","sourcesContent":["import z from 'zod';\nimport { SocketEventType } from '../../../utilities/enum';\nimport { DTO, ZodValidation } from '../../../utilities/validation';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\n\nexport const ChatlistMessageSendSocketInputSchema = z.object({});\nexport const ChatlistMessageSendSocketOutputSchema = z.object({\n\tchatroomId: ZodValidation.coerce.objectId(),\n\tlastMessage: z\n\t\t.object({\n\t\t\tcontent: ZodValidation.string(),\n\t\t\tcreatedAt: ZodValidation.coerce.date(),\n\t\t})\n\t\t.optional(),\n\tunreadCount: ZodValidation.number(),\n});\n\nexport type ChatlistMessageSendSocketOutputDTO = DTO<typeof ChatlistMessageSendSocketOutputSchema>;\n\nexport class ChatlistMessageSendSocketEvent extends BaseSocketEvent<\n\ttypeof ChatlistMessageSendSocketInputSchema,\n\ttypeof ChatlistMessageSendSocketOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: ChatlistMessageSendSocketInputSchema,\n\t\toutput: ChatlistMessageSendSocketOutputSchema,\n\t};\n\n\tconstructor(payload: ChatlistMessageSendSocketOutputDTO) {\n\t\tsuper(SocketEventType.CHATLIST_MESSAGE_RECEIVED, ChatlistMessageSendSocketEvent.schemas, payload);\n\t}\n}\n"]}
1
+ {"version":3,"file":"chatlist-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/chatlist-message-send.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAqE;AACrE,8DAAmE;AACnE,wDAAqD;AAExC,QAAA,oCAAoC,GAAG,aAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACpD,QAAA,qCAAqC,GAAG,aAAC,CAAC,MAAM,CAAC;IAC7D,UAAU,EAAE,0BAAa,CAAC,MAAM,CAAC,QAAQ,EAAE;IAC3C,WAAW,EAAE,aAAC;SACZ,MAAM,CAAC;QACP,OAAO,EAAE,0BAAa,CAAC,MAAM,EAAE;QAC/B,SAAS,EAAE,0BAAa,CAAC,MAAM,CAAC,IAAI,EAAE;KACtC,CAAC;SACD,QAAQ,EAAE;IACZ,WAAW,EAAE,0BAAa,CAAC,MAAM,EAAE;CACnC,CAAC,CAAC;AAEU,QAAA,mCAAmC,GAAG,6CAAqC,CAAC;AAMzF,MAAa,8BAA+B,SAAQ,iCAInD;IACA,MAAM,CAAU,OAAO,GAAG;QACzB,KAAK,EAAE,4CAAoC;QAC3C,MAAM,EAAE,6CAAqC;QAC7C,sBAAsB,EAAE,2CAAmC;KAC3D,CAAC;IAEF,MAAM,CAAU,oBAAoB,GAAG;QACtC,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,gBAAS,CAAC,iBAAiB;KACtC,CAAC;IAEF,YACC,OAA2C,EAC3C,uBAA0D;QAE1D,KAAK,CACJ,sBAAe,CAAC,yBAAyB,EACzC,8BAA8B,CAAC,OAAO,EACtC,OAAO,EACP,uBAAuB,CACvB,CAAC;IACH,CAAC;;AA3BF,wEA4BC","sourcesContent":["import z from 'zod';\nimport { SocketEventType, ClickType } from '../../../utilities/enum';\nimport { DTO, ZodValidation } from '../../../utilities/validation';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\n\nexport const ChatlistMessageSendSocketInputSchema = z.object({});\nexport const ChatlistMessageSendSocketOutputSchema = z.object({\n\tchatroomId: ZodValidation.coerce.objectId(),\n\tlastMessage: z\n\t\t.object({\n\t\t\tcontent: ZodValidation.string(),\n\t\t\tcreatedAt: ZodValidation.coerce.date(),\n\t\t})\n\t\t.optional(),\n\tunreadCount: ZodValidation.number(),\n});\n\nexport const ChatlistMessageSendPushOutputSchema = ChatlistMessageSendSocketOutputSchema;\n\nexport type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatlistMessageSendPushOutputSchema>;\nexport type ChatlistMessageSendSocketOutputDTO = DTO<typeof ChatlistMessageSendSocketOutputSchema>;\nexport type ChatlistMessageSendSocketInputDTO = DTO<typeof ChatlistMessageSendSocketInputSchema>;\n\nexport class ChatlistMessageSendSocketEvent extends BaseSocketEvent<\n\ttypeof ChatlistMessageSendSocketInputSchema,\n\ttypeof ChatlistMessageSendSocketOutputSchema,\n\ttypeof ChatlistMessageSendPushOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: ChatlistMessageSendSocketInputSchema,\n\t\toutput: ChatlistMessageSendSocketOutputSchema,\n\t\tpushNotificationOutput: ChatlistMessageSendPushOutputSchema,\n\t};\n\n\tstatic readonly notificationSettings = {\n\t\tisPushNotification: true,\n\t\tisClickable: true,\n\t\tclickType: ClickType.CLICKABLE_MESSAGE,\n\t};\n\n\tconstructor(\n\t\tpayload: ChatlistMessageSendSocketOutputDTO,\n\t\tpushNotificationPayload?: ChatlistMessageSendPushOutputDTO\n\t) {\n\t\tsuper(\n\t\t\tSocketEventType.CHATLIST_MESSAGE_RECEIVED,\n\t\t\tChatlistMessageSendSocketEvent.schemas,\n\t\t\tpayload,\n\t\t\tpushNotificationPayload\n\t\t);\n\t}\n}\n"]}