@lyxa.ai/core 1.3.63 → 1.3.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libraries/socket/PushNotificationEvent.d.ts +1 -1
- package/dist/libraries/socket/PushNotificationEvent.js.map +1 -1
- package/dist/libraries/socket/core/socket-event-publisher.js +13 -10
- package/dist/libraries/socket/core/socket-event-publisher.js.map +1 -1
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.js +7 -1
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.js.map +1 -1
- package/dist/libraries/socket/events/order-actions.socket.event.d.ts +0 -2
- package/dist/libraries/socket/events/order-actions.socket.event.js +7 -3
- package/dist/libraries/socket/events/order-actions.socket.event.js.map +1 -1
- package/dist/libraries/socket/events/socketNotificationEvent.d.ts +13 -0
- package/dist/libraries/socket/events/socketNotificationEvent.js +2 -0
- package/dist/libraries/socket/events/socketNotificationEvent.js.map +1 -1
- package/dist/libraries/socket/events/ticket-assign.socket.event.js +7 -1
- package/dist/libraries/socket/events/ticket-assign.socket.event.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/validation/common-validation.d.ts +12 -12
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseEvent } from '../event/BaseEvent';
|
|
2
|
-
import {
|
|
2
|
+
import { ClickType, SocketEventType } from '../../utilities/enum';
|
|
3
3
|
import { EntitySubscription } from './core/socket-redis-connections';
|
|
4
4
|
import { REGISTRY } from './core/socket-event-registry.map';
|
|
5
5
|
type SocketEventPayloads = {
|
|
@@ -1 +1 @@
|
|
|
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 {
|
|
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 { ClickType, SocketEventType } 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"]}
|
|
@@ -63,23 +63,26 @@ async function getActiveSubscribedRecipients(recipients, localKey) {
|
|
|
63
63
|
return { subscribed, unsubscribed };
|
|
64
64
|
}
|
|
65
65
|
async function publishSocketEvent(event, recipients) {
|
|
66
|
+
const logger = (0, __1.getLibraries)().getLogger().logger;
|
|
66
67
|
if (recipients.length === 0)
|
|
67
68
|
return;
|
|
68
69
|
const localKey = event.getSubscriptionKey();
|
|
69
70
|
const payload = event.payload();
|
|
70
71
|
const { subscribed, unsubscribed } = await getActiveSubscribedRecipients(recipients, localKey);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (subscribed.length > 0) {
|
|
72
|
+
logger.debug({ subscribed }, '[Socket] Subscribed recipients:');
|
|
73
|
+
logger.debug({ unsubscribed }, '[Socket] Unsubscribed recipients:');
|
|
74
|
+
if (subscribed.length > 0)
|
|
75
75
|
publishToInstances(subscribed, localKey, payload);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
if (unsubscribed.length > 0) {
|
|
77
|
+
logger.debug({ unsubscribed }, '[Socket] Processing unsubscribed recipients');
|
|
78
|
+
if (event.notificationSettings?.isPushNotification) {
|
|
79
|
+
const pushNotificationPayload = event.getPushNotificationPayload();
|
|
80
|
+
const settings = event.notificationSettings;
|
|
81
|
+
await (0, event_1.publishEvent)(new PushNotificationEvent_1.PushNotificationEvent(event.eventType(), pushNotificationPayload, unsubscribed, settings)).catch(err => console.error('[Socket] Push notification failed:', err));
|
|
82
|
+
}
|
|
79
83
|
const socketNotificationPayload = event.getSocketNotificationEvent();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (socketNotificationPayload) {
|
|
84
|
+
logger.debug({ socketNotificationPayload }, '[Socket] Socket notification payload');
|
|
85
|
+
if (event.getSocketNotificationEvent()) {
|
|
83
86
|
await publishNotificationSocketEvent(socketNotificationPayload, unsubscribed);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-event-publisher.js","sourceRoot":"/","sources":["libraries/socket/core/socket-event-publisher.ts"],"names":[],"mappings":";;AA6FA,gDAiCC;AAED,wEAmCC;AAnKD,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,OAAgB;IAEhB,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEjD,MAAM,OAAO,GAAG,IAAA,kBAAU,GAAE,CAAC,UAAU,CAAC;IAGxC,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,IAAW,EAAE,CAAC;IAG9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,uBAAuB,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AAG,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 { SocketNotificationEvent } from '../events';\nimport { EXCHANGE_NAME, getChannel, INSTANCE_ROUTE_PREFIX, publishEvent } from '../../event';\nimport { PushNotificationEvent } from '../PushNotificationEvent';\nimport type { ZodTypeAny } from 'zod';\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: unknown\n): void {\n\tif (recipientsWithInstances.length === 0) return;\n\n\tconst channel = getChannel().pubChannel;\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<ZodTypeAny, ZodTypeAny, ZodTypeAny | undefined>,\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\tconsole.log('payloadaa', payload);\n\n\tconsole.log('subscribed', subscribed);\n\tconsole.log('unsubscribed', unsubscribed);\n\n\tif (subscribed.length > 0) {\n\t\tpublishToInstances(subscribed, localKey, payload);\n\t}\n\n\tif (unsubscribed.length > 0 && event.notificationSettings?.isPushNotification) {\n\t\tconst pushNotificationPayload = event.getPushNotificationPayload();\n\t\tconst socketNotificationPayload = event.getSocketNotificationEvent();\n\n\t\tconst settings = event.notificationSettings;\n\t\tawait publishEvent(\n\t\t\tnew PushNotificationEvent(event.eventType(), pushNotificationPayload, unsubscribed, settings)\n\t\t).catch(err => console.error('[Socket] Push notification failed:', err));\n\n\t\tif (socketNotificationPayload) {\n\t\t\tawait publishNotificationSocketEvent(socketNotificationPayload, unsubscribed);\n\t\t}\n\t}\n}\n\nexport async function publishNotificationSocketEvent(\n\tevent: SocketNotificationEvent,\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,gDAmCC;AAED,wEAmCC;AArKD,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,OAAgB;IAEhB,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEjD,MAAM,OAAO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,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 { SocketNotificationEvent } from '../events';\nimport { EXCHANGE_NAME, getChannel, INSTANCE_ROUTE_PREFIX, publishEvent } from '../../event';\nimport { PushNotificationEvent } from '../PushNotificationEvent';\nimport type { ZodTypeAny } from 'zod';\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: unknown\n): void {\n\tif (recipientsWithInstances.length === 0) return;\n\n\tconst channel = getChannel().pubChannel;\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<ZodTypeAny, ZodTypeAny, ZodTypeAny | undefined>,\n\trecipients: EntitySubscription[]\n): Promise<void> {\n\tconst logger = getLibraries().getLogger().logger;\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\tlogger.debug({ subscribed }, '[Socket] Subscribed recipients:');\n\tlogger.debug({ unsubscribed }, '[Socket] Unsubscribed recipients:');\n\n\tif (subscribed.length > 0) publishToInstances(subscribed, localKey, payload);\n\n\tif (unsubscribed.length > 0) {\n\t\tlogger.debug({ unsubscribed }, '[Socket] Processing unsubscribed recipients');\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 notification failed:', err));\n\t\t}\n\n\t\tconst socketNotificationPayload = event.getSocketNotificationEvent();\n\n\t\tlogger.debug({ socketNotificationPayload }, '[Socket] Socket notification payload');\n\n\t\tif (event.getSocketNotificationEvent()) {\n\t\t\tawait publishNotificationSocketEvent(socketNotificationPayload!, unsubscribed);\n\t\t}\n\t}\n}\n\nexport async function publishNotificationSocketEvent(\n\tevent: SocketNotificationEvent,\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"]}
|
|
@@ -8,6 +8,7 @@ const zod_1 = __importDefault(require("zod"));
|
|
|
8
8
|
const enum_1 = require("../../../utilities/enum");
|
|
9
9
|
const validation_1 = require("../../../utilities/validation");
|
|
10
10
|
const BaseSocketEvent_1 = require("../BaseSocketEvent");
|
|
11
|
+
const core_1 = require("../core");
|
|
11
12
|
exports.ChatroomMessageSendSocketInputSchema = zod_1.default.object({
|
|
12
13
|
chatroomId: validation_1.IdSchema,
|
|
13
14
|
});
|
|
@@ -61,7 +62,12 @@ class ChatroomMessageSendSocketEvent extends BaseSocketEvent_1.BaseSocketEvent {
|
|
|
61
62
|
chatroomId: payload.chatroomId,
|
|
62
63
|
type: payload.chatroomType,
|
|
63
64
|
};
|
|
64
|
-
|
|
65
|
+
const socketNotificationEvent = core_1.EventFactory.createEvent(enum_1.SocketEventType.NOTIFICATION, {
|
|
66
|
+
message: 'New message!',
|
|
67
|
+
notificationType: enum_1.SocketEventType.CHATROOM_MESSAGE_SEND,
|
|
68
|
+
_id: payload._id,
|
|
69
|
+
});
|
|
70
|
+
super(enum_1.SocketEventType.CHATROOM_MESSAGE_SEND, ChatroomMessageSendSocketEvent.schemas, payload, pushPayload, socketNotificationEvent);
|
|
65
71
|
}
|
|
66
72
|
static identifier(input) {
|
|
67
73
|
return input.chatroomId.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatroom-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/chatroom-message-send.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAuG;AACvG,8DAA6E;AAC7E,wDAAqD;
|
|
1
|
+
{"version":3,"file":"chatroom-message-send.socket.event.js","sourceRoot":"/","sources":["libraries/socket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AAe,CAAC,YAAY,EAAE;YACtF,OAAO,EAAE,cAAc;YACvB,gBAAgB,EAAE,sBAAe,CAAC,qBAAqB;YACvD,GAAG,EAAE,OAAO,CAAC,GAAG;SAChB,CAAC,CAAC;QAEH,KAAK,CACJ,sBAAe,CAAC,qBAAqB,EACrC,8BAA8B,CAAC,OAAO,EACtC,OAAO,EACP,WAAW,EACX,uBAAuB,CACvB,CAAC;IACH,CAAC;IAER,MAAM,CAAC,UAAU,CAAC,KAA2D;QAC5E,OAAO,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAEM,0BAA0B;QAChC,OAAO,IAAI,CAAC,oBAAoB,CAAC;IAClC,CAAC;IAES,aAAa;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,SAAS,CAAC;IACtD,CAAC;;AAnDF,wEAoDC","sourcesContent":["import z from 'zod';\nimport { ChatroomType, ClickType, MediaType, SocketEventType, UserRef } from '../../../utilities/enum';\nimport { DTO, IdSchema, ZodValidation } from '../../../utilities/validation';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { NotificationSettings } from '../PushNotificationEvent';\nimport { EventFactory } from '../core';\n\nexport const ChatroomMessageSendSocketInputSchema = z.object({\n\tchatroomId: IdSchema,\n});\n\nexport const ChatroomMessageSendOutputSchema = z.object({\n\t_id: ZodValidation.coerce.objectId('_id'),\n\tchatroomType: ZodValidation.enumType(ChatroomType, 'chatroomType'),\n\tsenderId: ZodValidation.coerce.objectId('senderId'), // DEPRECATED\n\tsenderType: ZodValidation.enumType(UserRef, 'senderType'), // DEPRECATED\n\tsender: z.object({\n\t\tid: ZodValidation.coerce.objectId('sender.id'),\n\t\ttype: ZodValidation.enumType(UserRef, 'sender.type'),\n\t}),\n\tcontent: ZodValidation.string('content').optional(),\n\tmedia: z.array(\n\t\tz.object({\n\t\t\tmimeType: ZodValidation.string('mimeType'),\n\t\t\tmediaType: ZodValidation.enumType(MediaType, 'mediaType'),\n\t\t\tmediaUrl: ZodValidation.string('url'),\n\t\t\tthumbnailUrl: ZodValidation.string('thumbnailUrl').optional(),\n\t\t\tname: ZodValidation.string('name').optional(),\n\t\t})\n\t),\n\tlocation: z\n\t\t.object({\n\t\t\tlongitude: ZodValidation.coerce.number('longitude').optional(),\n\t\t\tlatitude: ZodValidation.coerce.number('latitude').optional(),\n\t\t})\n\t\t.optional(),\n\tchatroomId: ZodValidation.coerce.objectId('chatroomId').optional(),\n\tcreatedAt: ZodValidation.coerce.date(),\n});\n\nexport const ChatroomMessageSendPushOutputSchema = z.object({\n\tlastMessage: ZodValidation.string('lastMessage').optional(),\n\tchatroomId: ZodValidation.coerce.objectId('chatroomId').optional(),\n\ttype: ZodValidation.enumType(ChatroomType, 'type'),\n});\n\nexport type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatroomMessageSendPushOutputSchema>;\n\nexport type ChatroomMessageSendSocketOutputDTO = DTO<typeof ChatroomMessageSendOutputSchema>;\nexport type ChatroomMessageSendSocketInputDTO = DTO<typeof ChatroomMessageSendSocketInputSchema>;\n\nexport class ChatroomMessageSendSocketEvent extends BaseSocketEvent<\n\ttypeof ChatroomMessageSendSocketInputSchema,\n\ttypeof ChatroomMessageSendOutputSchema,\n\ttypeof ChatroomMessageSendPushOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: ChatroomMessageSendSocketInputSchema,\n\t\toutput: ChatroomMessageSendOutputSchema,\n\t\tpushNotificationOutput: ChatroomMessageSendPushOutputSchema,\n\t};\n\n\tpublic get notificationSettings(): NotificationSettings | undefined {\n\t\treturn {\n\t\t\tisPushNotification: true,\n\t\t\tisClickable: true,\n\t\t\tclickType: ClickType.CLICKABLE_MESSAGE,\n\t\t};\n\t}\n\n\t constructor(payload: ChatroomMessageSendSocketOutputDTO) {\n\t\t const pushPayload: ChatlistMessageSendPushOutputDTO = {\n\t\t\t lastMessage: payload.content,\n\t\t\t chatroomId: payload.chatroomId,\n\t\t\t type: payload.chatroomType,\n\t\t };\n\n\t\t const socketNotificationEvent = EventFactory.createEvent(SocketEventType.NOTIFICATION, {\n\t\t\t message: 'New message!',\n\t\t\t notificationType: SocketEventType.CHATROOM_MESSAGE_SEND,\n\t\t\t _id: payload._id,\n\t\t });\n\n\t\t super(\n\t\t\t SocketEventType.CHATROOM_MESSAGE_SEND,\n\t\t\t ChatroomMessageSendSocketEvent.schemas,\n\t\t\t payload,\n\t\t\t pushPayload,\n\t\t\t socketNotificationEvent\n\t\t );\n\t }\n\n\tstatic identifier(input: z.infer<typeof ChatroomMessageSendSocketInputSchema>): string {\n\t\treturn input.chatroomId.toString();\n\t}\n\n\tpublic getPushNotificationPayload() {\n\t\treturn this.pushNotificationData;\n\t}\n\n\tprotected getIdentifier(): string {\n\t\treturn this.data.chatroomId?.toString() ?? 'default';\n\t}\n}\n"]}
|
|
@@ -2,7 +2,6 @@ import { z } from 'zod';
|
|
|
2
2
|
import { DTO } from '../../../utilities/validation/';
|
|
3
3
|
import { PaymentMethod, RegularOrderStatus } from '../../../utilities/enum';
|
|
4
4
|
import { BaseSocketEvent } from '../BaseSocketEvent';
|
|
5
|
-
import { SocketNotificationEvent } from './socketNotificationEvent';
|
|
6
5
|
export declare enum OrderAction {
|
|
7
6
|
PLACED = "placed",
|
|
8
7
|
ADJUSTMENT = "adjustment",
|
|
@@ -296,7 +295,6 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
|
|
|
296
295
|
orderAction: OrderAction;
|
|
297
296
|
preparationTimeMinutes: number;
|
|
298
297
|
}>;
|
|
299
|
-
socketNotificationEvent: SocketNotificationEvent;
|
|
300
298
|
};
|
|
301
299
|
constructor(payload: OrderActionSocketOutputDTO);
|
|
302
300
|
static identifier(input: z.infer<typeof OrderActionsInputSchema>): string;
|
|
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const validation_1 = require("../../../utilities/validation/");
|
|
6
6
|
const enum_1 = require("../../../utilities/enum");
|
|
7
7
|
const BaseSocketEvent_1 = require("../BaseSocketEvent");
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("../core");
|
|
9
9
|
var OrderAction;
|
|
10
10
|
(function (OrderAction) {
|
|
11
11
|
OrderAction["PLACED"] = "placed";
|
|
@@ -51,10 +51,14 @@ class OrderActionsSocketEvent extends BaseSocketEvent_1.BaseSocketEvent {
|
|
|
51
51
|
static schemas = {
|
|
52
52
|
input: exports.OrderActionsInputSchema,
|
|
53
53
|
output: exports.OrderActionsOutputSchema,
|
|
54
|
-
socketNotificationEvent: new socketNotificationEvent_1.SocketNotificationEvent({ message: 'New Order!' }),
|
|
55
54
|
};
|
|
56
55
|
constructor(payload) {
|
|
57
|
-
|
|
56
|
+
const socketNotificationEvent = core_1.EventFactory.createEvent(enum_1.SocketEventType.NOTIFICATION, {
|
|
57
|
+
message: 'New Order!',
|
|
58
|
+
notificationType: enum_1.SocketEventType.ORDER_ACTIONS,
|
|
59
|
+
_id: payload._id,
|
|
60
|
+
});
|
|
61
|
+
super(enum_1.SocketEventType.ORDER_ACTIONS, OrderActionsSocketEvent.schemas, payload, undefined, socketNotificationEvent);
|
|
58
62
|
}
|
|
59
63
|
static identifier(input) {
|
|
60
64
|
return input.shopId.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-actions.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/order-actions.socket.event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,+DAAoE;AACpE,kDAA6F;AAC7F,wDAAqD;
|
|
1
|
+
{"version":3,"file":"order-actions.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/order-actions.socket.event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,+DAAoE;AACpE,kDAA6F;AAC7F,wDAAqD;AAErD,kCAAuC;AAEvC,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,gCAAiB,CAAA;IACjB,wCAAyB,CAAA;IACzB,0CAA2B,CAAA;AAC5B,CAAC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C,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;;AAhCF,0DAiCC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from '../../../utilities/validation/';\nimport { PaymentMethod, RegularOrderStatus, SocketEventType } from '../../../utilities/enum';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { SocketNotificationEvent } from './socketNotificationEvent';\nimport { EventFactory } from '../core';\n\nexport enum OrderAction {\n\tPLACED = 'placed',\n\tADJUSTMENT = 'adjustment',\n\tREPLACEMENT = 'replacement',\n}\n\nconst OrderUserSchema = z.object({\n\t_id: ZodValidation.objectId('User ID'),\n\tname: ZodValidation.string('User Name'),\n});\n\nexport const OrderActionsOutputSchema = z.object({\n\t_id: ZodValidation.objectId('Order ID'),\n\tshopId: ZodValidation.objectId('shopId'),\n\torderId: ZodValidation.string('Readable Order ID'),\n\tuser: OrderUserSchema,\n\torderStatus: ZodValidation.enumType(RegularOrderStatus, 'status'),\n\torderAction: ZodValidation.enumType(OrderAction, 'orderAction'),\n\tpaymentMethod: ZodValidation.enumType(PaymentMethod, 'paymentMethod'),\n\tpreparationTimeMinutes: ZodValidation.number('Preparation Time (minutes)', {\n\t\tisNonnegative: true,\n\t}),\n\tadjustedFinance: z.object({\n\t\tpaymentMethod: ZodValidation.enumType(PaymentMethod, 'paymentMethod'),\n\t\tshopProfit: ZodValidation.number('shopProfit'),\n\t\tpricing: z.object({\n\t\t\ttotal: ZodValidation.number('total'),\n\t\t\tsecondaryTotal: ZodValidation.number('secondaryTotal'),\n\t\t\tpaidAmount: ZodValidation.number('paidAmount'),\n\t\t\tsecondaryPaidAmount: ZodValidation.number('secondaryPaidAmount'),\n\t\t\tdeliveryFee: ZodValidation.number('deliveryFee'),\n\t\t\tsecondaryDeliveryFee: ZodValidation.number('secondaryDeliveryFee'),\n\t\t\triderTips: ZodValidation.number('riderTip'),\n\t\t\tsecondaryRiderTips: ZodValidation.number('secondaryRiderTips'),\n\t\t}),\n\t}),\n\tcreatedAt: ZodValidation.coerce.date('Order Creation Date'),\n\ttriggerAt: ZodValidation.coerce.date('Order Trigger Date'),\n});\n\nexport const OrderActionsInputSchema = z.object({\n\tshopId: ZodValidation.objectId('shopId'),\n});\n\nexport type OrderActionSocketInputDTO = DTO<typeof OrderActionsInputSchema>;\nexport type OrderActionSocketOutputDTO = DTO<typeof OrderActionsOutputSchema>;\n\nexport class OrderActionsSocketEvent extends BaseSocketEvent<\n\ttypeof OrderActionsInputSchema,\n\ttypeof OrderActionsOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: OrderActionsInputSchema,\n\t\toutput: OrderActionsOutputSchema,\n\t};\n\n\tconstructor(payload: OrderActionSocketOutputDTO) {\n\t\tconst socketNotificationEvent = EventFactory.createEvent(SocketEventType.NOTIFICATION, {\n\t\t\tmessage: 'New Order!',\n\t\t\tnotificationType: SocketEventType.ORDER_ACTIONS,\n\t\t\t_id: payload._id,\n\t\t});\n\n\t\tsuper(\n\t\t\tSocketEventType.ORDER_ACTIONS,\n\t\t\tOrderActionsSocketEvent.schemas,\n\t\t\tpayload,\n\t\t\tundefined,\n\t\t\tsocketNotificationEvent\n\t\t);\n\t}\n\n\tstatic identifier(input: z.infer<typeof OrderActionsInputSchema>): string {\n\t\treturn input.shopId.toString();\n\t}\n\n\tprotected getIdentifier(): string {\n\t\tconsole.log('this.data.shopId.toString(): ', this.data.shopId.toString());\n\t\treturn this.data.shopId.toString();\n\t}\n}\n"]}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import { BaseSocketEvent } from '../BaseSocketEvent';
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
import { DTO } from '../../../utilities/validation';
|
|
4
|
+
import { SocketEventType } from '../../../utilities/enum';
|
|
4
5
|
export declare const NotificationSocketInputSchema: z.ZodUndefined;
|
|
5
6
|
export declare const NotificationSocketOutputSchema: z.ZodObject<{
|
|
7
|
+
_id: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
|
|
6
8
|
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
9
|
+
notificationType: z.ZodNativeEnum<typeof SocketEventType>;
|
|
7
10
|
}, "strip", z.ZodTypeAny, {
|
|
8
11
|
message: string;
|
|
12
|
+
notificationType: SocketEventType;
|
|
13
|
+
_id?: import("mongoose").Types.ObjectId | undefined;
|
|
9
14
|
}, {
|
|
10
15
|
message: string;
|
|
16
|
+
notificationType: SocketEventType;
|
|
17
|
+
_id?: string | import("mongoose").Types.ObjectId | undefined;
|
|
11
18
|
}>;
|
|
12
19
|
export type NotificationSocketOutputDTO = DTO<typeof NotificationSocketOutputSchema>;
|
|
13
20
|
export declare class SocketNotificationEvent extends BaseSocketEvent<typeof NotificationSocketInputSchema, typeof NotificationSocketOutputSchema> {
|
|
14
21
|
static readonly schemas: {
|
|
15
22
|
input: z.ZodUndefined;
|
|
16
23
|
output: z.ZodObject<{
|
|
24
|
+
_id: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
|
|
17
25
|
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
26
|
+
notificationType: z.ZodNativeEnum<typeof SocketEventType>;
|
|
18
27
|
}, "strip", z.ZodTypeAny, {
|
|
19
28
|
message: string;
|
|
29
|
+
notificationType: SocketEventType;
|
|
30
|
+
_id?: import("mongoose").Types.ObjectId | undefined;
|
|
20
31
|
}, {
|
|
21
32
|
message: string;
|
|
33
|
+
notificationType: SocketEventType;
|
|
34
|
+
_id?: string | import("mongoose").Types.ObjectId | undefined;
|
|
22
35
|
}>;
|
|
23
36
|
};
|
|
24
37
|
constructor(payload: DTO<typeof NotificationSocketOutputSchema>);
|
|
@@ -10,7 +10,9 @@ const validation_1 = require("../../../utilities/validation");
|
|
|
10
10
|
const enum_1 = require("../../../utilities/enum");
|
|
11
11
|
exports.NotificationSocketInputSchema = zod_1.default.undefined();
|
|
12
12
|
exports.NotificationSocketOutputSchema = zod_1.default.object({
|
|
13
|
+
_id: validation_1.ZodValidation.objectId().optional(),
|
|
13
14
|
message: validation_1.ZodValidation.string(),
|
|
15
|
+
notificationType: validation_1.ZodValidation.enumType(enum_1.SocketEventType, 'type'),
|
|
14
16
|
});
|
|
15
17
|
class SocketNotificationEvent extends BaseSocketEvent_1.BaseSocketEvent {
|
|
16
18
|
static schemas = { input: exports.NotificationSocketInputSchema, output: exports.NotificationSocketOutputSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketNotificationEvent.js","sourceRoot":"/","sources":["libraries/socket/events/socketNotificationEvent.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAqD;AACrD,8CAAoB;AACpB,8DAAmE;AACnE,
|
|
1
|
+
{"version":3,"file":"socketNotificationEvent.js","sourceRoot":"/","sources":["libraries/socket/events/socketNotificationEvent.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAqD;AACrD,8CAAoB;AACpB,8DAAmE;AACnE,kDAA0D;AAE7C,QAAA,6BAA6B,GAAG,aAAC,CAAC,SAAS,EAAE,CAAC;AAC9C,QAAA,8BAA8B,GAAG,aAAC,CAAC,MAAM,CAAC;IACtD,GAAG,EAAE,0BAAa,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACxC,OAAO,EAAE,0BAAa,CAAC,MAAM,EAAE;IAC/B,gBAAgB,EAAE,0BAAa,CAAC,QAAQ,CAAC,sBAAe,EAAE,MAAM,CAAC;CACjE,CAAC,CAAC;AAIH,MAAa,uBAAwB,SAAQ,iCAG5C;IACA,MAAM,CAAU,OAAO,GAAG,EAAE,KAAK,EAAE,qCAA6B,EAAE,MAAM,EAAE,sCAA8B,EAAE,CAAC;IAE3G,YAAY,OAAmD;QAC9D,KAAK,CAAC,sBAAe,CAAC,YAAY,EAAE,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAES,aAAa;QACtB,OAAO,SAAS,CAAC;IAClB,CAAC;;AAZF,0DAaC","sourcesContent":["import { BaseSocketEvent } from '../BaseSocketEvent';\nimport z from 'zod';\nimport { DTO, ZodValidation } from '../../../utilities/validation';\nimport { SocketEventType } from '../../../utilities/enum';\n\nexport const NotificationSocketInputSchema = z.undefined();\nexport const NotificationSocketOutputSchema = z.object({\n\t_id: ZodValidation.objectId().optional(),\n\tmessage: ZodValidation.string(),\n\tnotificationType: ZodValidation.enumType(SocketEventType, 'type'),\n});\n\nexport type NotificationSocketOutputDTO = DTO<typeof NotificationSocketOutputSchema>;\n\nexport class SocketNotificationEvent extends BaseSocketEvent<\n\ttypeof NotificationSocketInputSchema,\n\ttypeof NotificationSocketOutputSchema\n> {\n\tstatic readonly schemas = { input: NotificationSocketInputSchema, output: NotificationSocketOutputSchema };\n\n\tconstructor(payload: DTO<typeof NotificationSocketOutputSchema>) {\n\t\tsuper(SocketEventType.NOTIFICATION, SocketNotificationEvent.schemas, payload);\n\t}\n\n\tprotected getIdentifier(): string {\n\t\treturn 'default';\n\t}\n}\n"]}
|
|
@@ -8,6 +8,7 @@ const zod_1 = __importDefault(require("zod"));
|
|
|
8
8
|
const enum_1 = require("../../../utilities/enum");
|
|
9
9
|
const validation_1 = require("../../../utilities/validation");
|
|
10
10
|
const BaseSocketEvent_1 = require("../BaseSocketEvent");
|
|
11
|
+
const core_1 = require("../core");
|
|
11
12
|
exports.TicketAssignSocketInputSchema = zod_1.default.undefined({});
|
|
12
13
|
exports.TicketAssignSocketOutputSchema = zod_1.default.object({
|
|
13
14
|
_id: validation_1.IdSchema,
|
|
@@ -32,7 +33,12 @@ exports.TicketAssignSocketOutputSchema = zod_1.default.object({
|
|
|
32
33
|
class TicketAssignEvent extends BaseSocketEvent_1.BaseSocketEvent {
|
|
33
34
|
static schemas = { input: exports.TicketAssignSocketInputSchema, output: exports.TicketAssignSocketOutputSchema };
|
|
34
35
|
constructor(payload) {
|
|
35
|
-
|
|
36
|
+
const socketNotificationEvent = core_1.EventFactory.createEvent(enum_1.SocketEventType.NOTIFICATION, {
|
|
37
|
+
message: 'Ticket assigned!',
|
|
38
|
+
notificationType: enum_1.SocketEventType.TICKET_ASSIGN,
|
|
39
|
+
_id: payload._id,
|
|
40
|
+
});
|
|
41
|
+
super(enum_1.SocketEventType.TICKET_ASSIGN, TicketAssignEvent.schemas, payload, undefined, socketNotificationEvent);
|
|
36
42
|
}
|
|
37
43
|
getIdentifier() {
|
|
38
44
|
return 'default';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticket-assign.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/ticket-assign.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAwH;AACxH,8DAA6E;AAC7E,wDAAqD;
|
|
1
|
+
{"version":3,"file":"ticket-assign.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/ticket-assign.socket.event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAwH;AACxH,8DAA6E;AAC7E,wDAAqD;AACrD,kCAAuC;AAE1B,QAAA,6BAA6B,GAAG,aAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AAEhD,QAAA,8BAA8B,GAAG,aAAC,CAAC,MAAM,CAAC;IACtD,GAAG,EAAE,qBAAQ;IACb,IAAI,EAAE,0BAAa,CAAC,QAAQ,CAAC,iBAAU,EAAE,MAAM,CAAC;IAChD,MAAM,EAAE,0BAAa,CAAC,QAAQ,CAAC,mBAAY,EAAE,QAAQ,CAAC;IACtD,MAAM,EAAE,aAAC,CAAC,MAAM,CAAC;QAChB,GAAG,EAAE,0BAAa,CAAC,QAAQ,CAAC,KAAK,CAAC;QAClC,IAAI,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C;;AAvBF,8CAwBC","sourcesContent":["import z from 'zod';\nimport { PushNotificationEventType, SocketEventType, TicketStatus, TicketType, UserRef } from '../../../utilities/enum';\nimport { DTO, IdSchema, ZodValidation } from '../../../utilities/validation';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { EventFactory } from '../core';\n\nexport const TicketAssignSocketInputSchema = z.undefined({});\n\nexport const TicketAssignSocketOutputSchema = z.object({\n\t_id: IdSchema,\n\ttype: ZodValidation.enumType(TicketType, 'type'),\n\tstatus: ZodValidation.enumType(TicketStatus, 'status'),\n\tclient: z.object({\n\t\t_id: ZodValidation.objectId('_id'),\n\t\ttype: ZodValidation.enumType(UserRef, 'clientType'),\n\t\tname: ZodValidation.string('name'),\n\t\tprofilePhoto: ZodValidation.string('profilePhoto').nullable(),\n\t}),\n\tcreatedAt: ZodValidation.date('createdAt'),\n\tupdatedAt: ZodValidation.date('updatedAt'),\n\torderId: ZodValidation.objectId('orderId').optional(),\n\tchatroomId: ZodValidation.objectId('chatroomId'),\n\tlastMessage: z.object({\n\t\tcontent: ZodValidation.string('content'),\n\t\tcreatedAt: ZodValidation.date('createdAt'),\n\t}),\n\tunreadCount: ZodValidation.number('unreadCount').min(0),\n});\n\nexport type TicketAssignSocketOutputDTO = DTO<typeof TicketAssignSocketOutputSchema>;\n\nexport class TicketAssignEvent extends BaseSocketEvent<\n\ttypeof TicketAssignSocketInputSchema,\n\ttypeof TicketAssignSocketOutputSchema\n> {\n\tstatic readonly schemas = { input: TicketAssignSocketInputSchema, output: TicketAssignSocketOutputSchema };\n\n\t constructor(payload: DTO<typeof TicketAssignSocketOutputSchema>) {\n\t\t const socketNotificationEvent = EventFactory.createEvent(SocketEventType.NOTIFICATION, {\n\t\t\t message: 'Ticket assigned!',\n\t\t\t notificationType: SocketEventType.TICKET_ASSIGN,\n\t\t\t _id: payload._id,\n\t\t });\n\t\t super(\n\t\t\t SocketEventType.TICKET_ASSIGN,\n\t\t\t TicketAssignEvent.schemas,\n\t\t\t payload,\n\t\t\t undefined,\n\t\t\t socketNotificationEvent\n\t\t );\n\t }\n\n\tprotected getIdentifier(): string {\n\t\treturn 'default';\n\t}\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -26,8 +26,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
|
|
|
26
26
|
searchFields?: string[] | undefined;
|
|
27
27
|
} | undefined;
|
|
28
28
|
sort?: Record<string, 1 | -1> | undefined;
|
|
29
|
-
populate?: any;
|
|
30
29
|
select?: Record<string, 0 | 1> | undefined;
|
|
30
|
+
populate?: any;
|
|
31
31
|
query?: Record<string, any> | undefined;
|
|
32
32
|
}, {
|
|
33
33
|
search?: {
|
|
@@ -36,8 +36,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
|
|
|
36
36
|
} | undefined;
|
|
37
37
|
sort?: Record<string, 1 | -1> | undefined;
|
|
38
38
|
size?: number | undefined;
|
|
39
|
-
populate?: any;
|
|
40
39
|
select?: Record<string, 0 | 1> | undefined;
|
|
40
|
+
populate?: any;
|
|
41
41
|
query?: Record<string, any> | undefined;
|
|
42
42
|
page?: number | undefined;
|
|
43
43
|
}>>;
|
|
@@ -733,12 +733,12 @@ export declare const GetByIdInputSchema: z.ZodObject<{
|
|
|
733
733
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
734
734
|
}, "strip", z.ZodTypeAny, {
|
|
735
735
|
_id: import("mongoose").Types.ObjectId;
|
|
736
|
-
populate?: any;
|
|
737
736
|
select?: Record<string, 0 | 1> | undefined;
|
|
737
|
+
populate?: any;
|
|
738
738
|
}, {
|
|
739
739
|
_id: string | import("mongoose").Types.ObjectId;
|
|
740
|
-
populate?: any;
|
|
741
740
|
select?: Record<string, 0 | 1> | undefined;
|
|
741
|
+
populate?: any;
|
|
742
742
|
}>;
|
|
743
743
|
export type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;
|
|
744
744
|
export declare const GetProductByIdInputSchema: z.ZodObject<{
|
|
@@ -751,12 +751,12 @@ export declare const GetProductByIdInputSchema: z.ZodObject<{
|
|
|
751
751
|
_id: import("mongoose").Types.ObjectId;
|
|
752
752
|
withAttributeHiddenItems: boolean;
|
|
753
753
|
withAddonsHiddenItems: boolean;
|
|
754
|
-
populate?: any;
|
|
755
754
|
select?: Record<string, 0 | 1> | undefined;
|
|
755
|
+
populate?: any;
|
|
756
756
|
}, {
|
|
757
757
|
_id: string | import("mongoose").Types.ObjectId;
|
|
758
|
-
populate?: any;
|
|
759
758
|
select?: Record<string, 0 | 1> | undefined;
|
|
759
|
+
populate?: any;
|
|
760
760
|
withAttributeHiddenItems?: boolean | undefined;
|
|
761
761
|
withAddonsHiddenItems?: boolean | undefined;
|
|
762
762
|
}>;
|
|
@@ -768,13 +768,13 @@ export declare const GetOrderByIdInputSchema: z.ZodObject<{
|
|
|
768
768
|
userOrderCompletionScope: z.ZodOptional<z.ZodNativeEnum<typeof UserOrderCompletionScope>>;
|
|
769
769
|
}, "strip", z.ZodTypeAny, {
|
|
770
770
|
_id: import("mongoose").Types.ObjectId;
|
|
771
|
-
populate?: any;
|
|
772
771
|
select?: Record<string, 0 | 1> | undefined;
|
|
772
|
+
populate?: any;
|
|
773
773
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
774
774
|
}, {
|
|
775
775
|
_id: string | import("mongoose").Types.ObjectId;
|
|
776
|
-
populate?: any;
|
|
777
776
|
select?: Record<string, 0 | 1> | undefined;
|
|
777
|
+
populate?: any;
|
|
778
778
|
userOrderCompletionScope?: UserOrderCompletionScope | undefined;
|
|
779
779
|
}>;
|
|
780
780
|
export type GetOrderByIdInputDTO = DTO<typeof GetOrderByIdInputSchema>;
|
|
@@ -782,11 +782,11 @@ export declare const GetByTokenInputSchema: z.ZodOptional<z.ZodObject<{
|
|
|
782
782
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
783
783
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
784
784
|
}, "strip", z.ZodTypeAny, {
|
|
785
|
-
populate?: any;
|
|
786
785
|
select?: Record<string, 0 | 1> | undefined;
|
|
787
|
-
}, {
|
|
788
786
|
populate?: any;
|
|
787
|
+
}, {
|
|
789
788
|
select?: Record<string, 0 | 1> | undefined;
|
|
789
|
+
populate?: any;
|
|
790
790
|
}>>;
|
|
791
791
|
export type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;
|
|
792
792
|
export declare const GetOneQuerySchema: z.ZodObject<{
|
|
@@ -794,12 +794,12 @@ export declare const GetOneQuerySchema: z.ZodObject<{
|
|
|
794
794
|
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
|
|
795
795
|
populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
|
|
796
796
|
}, "strip", z.ZodTypeAny, {
|
|
797
|
-
populate?: any;
|
|
798
797
|
select?: Record<string, 0 | 1> | undefined;
|
|
798
|
+
populate?: any;
|
|
799
799
|
query?: Record<string, any> | undefined;
|
|
800
800
|
}, {
|
|
801
|
-
populate?: any;
|
|
802
801
|
select?: Record<string, 0 | 1> | undefined;
|
|
802
|
+
populate?: any;
|
|
803
803
|
query?: Record<string, any> | undefined;
|
|
804
804
|
}>;
|
|
805
805
|
export type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;
|