@lyxa.ai/core 1.3.60 → 1.3.62
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/event/index.js +6 -1
- package/dist/libraries/event/index.js.map +1 -1
- package/dist/libraries/mongo/models/support-reason.model.d.ts +2 -1
- package/dist/libraries/mongo/models/support-reason.model.js +5 -0
- package/dist/libraries/mongo/models/support-reason.model.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/package.json +1 -1
|
@@ -47,11 +47,16 @@ async function publishEvent(event) {
|
|
|
47
47
|
}
|
|
48
48
|
async function subscribeToEvent(eventId, onMessage) {
|
|
49
49
|
const ch = getChannel().subChannel;
|
|
50
|
-
const queueName = `${eventId}
|
|
50
|
+
const queueName = `${eventId}`;
|
|
51
51
|
await ch.assertQueue(queueName, {
|
|
52
52
|
durable: true,
|
|
53
53
|
exclusive: false,
|
|
54
54
|
autoDelete: false,
|
|
55
|
+
arguments: {
|
|
56
|
+
'x-max-length': 50000,
|
|
57
|
+
'x-message-ttl': 24 * 60 * 60 * 1000,
|
|
58
|
+
'x-overflow': 'drop-head',
|
|
59
|
+
},
|
|
55
60
|
});
|
|
56
61
|
await ch.bindQueue(queueName, exports.EXCHANGE_NAME, eventId);
|
|
57
62
|
await ch.consume(queueName, async (msg) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;;AAWA,oCAUC;AAED,gCAOC;AAED,oCAYC;AAED,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;;AAWA,oCAUC;AAED,gCAOC;AAED,oCAYC;AAED,4CAuCC;AAED,sCAKC;AA5FD,sDAA2B;AAE3B,mEAA+D;AAE/D,IAAI,UAA6B,CAAC;AAClC,IAAI,UAA+B,CAAC;AACpC,IAAI,UAAwB,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G,CAAC,wBAAwB,OAAO,GAAG,CAAC,CAAC;AACjD,CAAC;AAEM,KAAK,UAAU,aAAa;IAClC,IAAI,UAAU;QAAE,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,IAAI,UAAU;QAAE,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,IAAI,UAAU;QAAE,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAA,8BAAa,GAAE,GAAG,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,YAAY,CAAC,EAAsC,EAAE,IAAmB;IAChF,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,gCAAgC,CAAC,CAAC;QACvD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACpB,UAAU,GAAG,MAAM,UAAU,CAAC,oBAAoB,EAAE,CAAC;YACrD,MAAM,UAAU,CAAC,cAAc,CAAC,qBAAa,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3E,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACP,UAAU,GAAG,MAAM,UAAU,CAAC,aAAa,EAAE,CAAC;YAC9C,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import amqp from 'amqplib';\nimport { BaseEvent } from './BaseEvent';\nimport { getInstanceId } from '../../utilities/instance.utils';\n\nlet connection: amqp.ChannelModel;\nlet pubChannel: amqp.ConfirmChannel;\nlet subChannel: amqp.Channel;\n\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\tpubChannel = await connection.createConfirmChannel();\n\tattachGuards(pubChannel, 'pub');\n\n\tsubChannel = await connection.createChannel();\n\tattachGuards(subChannel, 'sub');\n\n\tawait pubChannel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\tconsole.log(`EventBus initialized with instance ID: ${getInstanceId()}`);\n}\n\nexport function getChannel(): { pubChannel: amqp.ConfirmChannel; subChannel: amqp.Channel } {\n\tif (!pubChannel) throw new Error('Channel not initialized. Call initEventBus first.');\n\tif (!subChannel) throw new Error('Channel not initialized. Call initEventBus first.');\n\treturn {\n\t\tpubChannel,\n\t\tsubChannel,\n\t};\n}\n\nexport async function publishEvent<TPayload extends Record<string, unknown>>(\n\tevent: BaseEvent<TPayload>\n): Promise<void> {\n\tconsole.log('taking event', event);\n\n\tconst ch = getChannel().pubChannel;\n\tconst messageBuffer = Buffer.from(JSON.stringify(event.payload));\n\tch.publish(EXCHANGE_NAME, event.eventId, messageBuffer, {\n\t\tcontentType: 'application/json',\n\t\tpersistent: true,\n\t});\n\tawait ch.waitForConfirms();\n}\n\nexport async function subscribeToEvent(\n\teventId: string,\n\tonMessage: (payload: any) => Promise<void>\n): Promise<void> {\n\tconst ch = getChannel().subChannel;\n\tconst queueName = `${eventId}`;\n\t// const queueName = `${eventId}.${getInstanceId()}`;\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\targuments: {\n\t\t\t// Optional safety: limit queue size and TTL to prevent disk issues\n\t\t\t'x-max-length': 50000, // max 50k messages\n\t\t\t'x-message-ttl': 24 * 60 * 60 * 1000, // 24h TTL\n\t\t\t'x-overflow': 'drop-head', // drop oldest messages if full\n\t\t},\n\t});\n\n\tawait ch.bindQueue(queueName, EXCHANGE_NAME, eventId);\n\n\tawait ch.consume(queueName, async msg => {\n\t\tif (!msg) return;\n\t\tlet processed = false;\n\t\ttry {\n\t\t\tconst payload = JSON.parse(msg.content.toString());\n\t\t\tawait onMessage(payload);\n\t\t\tprocessed = true;\n\t\t} catch (err) {\n\t\t\tconsole.error(`Error handling event [${eventId}]`, err);\n\t\t} finally {\n\t\t\tif (processed) ch.ack(msg);\n\t\t\telse ch.nack(msg, false, true); // retry\n\t\t}\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 (pubChannel) await pubChannel.close();\n\tif (subChannel) await subChannel.close();\n\tif (connection) await connection.close();\n\tconsole.log(`EventBus closed for instance [${getInstanceId()}]`);\n}\n\nfunction attachGuards(ch: amqp.Channel | amqp.ConfirmChannel, type: 'pub' | 'sub') {\n\tch.on('close', async () => {\n\t\tconsole.error(`${type} channel closed, recreating...`);\n\t\tif (type === 'pub') {\n\t\t\tpubChannel = await connection.createConfirmChannel();\n\t\t\tawait pubChannel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\t\t\tattachGuards(pubChannel, 'pub');\n\t\t} else {\n\t\t\tsubChannel = await connection.createChannel();\n\t\t\tattachGuards(subChannel, 'sub');\n\t\t}\n\t});\n\n\tch.on('error', err => {\n\t\tconsole.error(`${type} channel error`, err);\n\t});\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
2
|
-
import { Status, SupportReasonTypeEnum } from '../../../utilities/enum';
|
|
2
|
+
import { FaqAccountType, Status, SupportReasonTypeEnum } from '../../../utilities/enum';
|
|
3
3
|
import { SupportReasonInfo } from './embedded/support-reason-info.model';
|
|
4
4
|
export declare class SupportReason extends TimeStamps {
|
|
5
5
|
reason: SupportReasonInfo;
|
|
6
6
|
reasonType: SupportReasonTypeEnum;
|
|
7
|
+
accountType?: FaqAccountType;
|
|
7
8
|
status: Status;
|
|
8
9
|
sortingOrder?: number;
|
|
9
10
|
}
|
|
@@ -19,6 +19,7 @@ const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
|
19
19
|
let SupportReason = class SupportReason extends defaultClasses_1.TimeStamps {
|
|
20
20
|
reason;
|
|
21
21
|
reasonType;
|
|
22
|
+
accountType;
|
|
22
23
|
status;
|
|
23
24
|
sortingOrder;
|
|
24
25
|
};
|
|
@@ -31,6 +32,10 @@ __decorate([
|
|
|
31
32
|
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.SupportReasonTypeEnum }),
|
|
32
33
|
__metadata("design:type", String)
|
|
33
34
|
], SupportReason.prototype, "reasonType", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typegoose_1.prop)({ required: true, enum: enum_1.FaqAccountType }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], SupportReason.prototype, "accountType", void 0);
|
|
34
39
|
__decorate([
|
|
35
40
|
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.Status }),
|
|
36
41
|
__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"support-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/support-reason.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"support-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/support-reason.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAAwF;AACxF,oFAAyE;AAEzE,wBAAuC;AACvC,0EAG0C;AAiBnC,IAAM,aAAa,GAAnB,MAAM,aAAc,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BAAK,EAAC,EAAE,UAAU,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACpD,aAAa,CAezB","sourcesContent":["import { index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { FaqAccountType, Status, SupportReasonTypeEnum } from '../../../utilities/enum';\nimport { SupportReasonInfo } from './embedded/support-reason-info.model';\nimport { Query } from 'mongoose';\nimport { SupportReasonModel } from '.';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sorting-order.hooks';\n\n@modelOptions({ schemaOptions: { collection: 'supportReasons' } })\n@pre<SupportReason>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, SupportReasonModel, {\n\t\treasonType: this.reasonType,\n\t});\n\n\tnext();\n})\n@pre<SupportReason>('findOneAndUpdate', async function (this: Query<any, SupportReason>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, SupportReasonModel, ['reasonType']);\n\n\tnext();\n})\n\n@index({ reasonType: 1, \"reason.question\": 1 }, { unique: true })\nexport class SupportReason extends TimeStamps {\n\t@prop({ required: true, type: () => SupportReasonInfo })\n\tpublic reason: SupportReasonInfo;\n\n\t@prop({ required: true, type: String, enum: SupportReasonTypeEnum })\n\tpublic reasonType: SupportReasonTypeEnum;\n\n\t@prop({ required: true, enum: FaqAccountType })\n\tpublic accountType?: FaqAccountType;\n\n\t@prop({ required: true, type: String, enum: Status })\n\tpublic status: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED