@lyxa.ai/core 1.2.85 → 1.2.87

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.
@@ -5,10 +5,5 @@ 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 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>;
8
+ export declare function subscribeToEvent(eventId: string, onMessage: (payload: any) => Promise<void>): Promise<void>;
14
9
  export declare function closeEventBus(): Promise<void>;
@@ -33,16 +33,14 @@ async function publishEvent(event) {
33
33
  contentType: 'application/json',
34
34
  });
35
35
  }
36
- async function subscribeToEvent(eventId, onMessage, options) {
36
+ async function subscribeToEvent(eventId, onMessage) {
37
37
  const ch = getChannel();
38
- const queueName = options?.exclusive ? `${eventId}-${(0, instance_utils_1.getInstanceId)()}` : eventId;
39
- const queueOptions = {
38
+ const queueName = `${eventId}`;
39
+ await ch.assertQueue(queueName, {
40
40
  durable: true,
41
41
  exclusive: false,
42
42
  autoDelete: false,
43
- ...options,
44
- };
45
- await ch.assertQueue(queueName, queueOptions);
43
+ });
46
44
  await ch.bindQueue(queueName, exports.EXCHANGE_NAME, eventId);
47
45
  await ch.consume(queueName, async (msg) => {
48
46
  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;AAQD,4CAoCC;AAED,sCAIC;AAhFD,sDAA2B;AAE3B,mEAA+D;AAE/D,IAAI,UAA6B,CAAC;AAClC,IAAI,OAAqB,C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B,GAAG,OAAO;KACV,CAAC;IAEF,MAAM,EAAE,CAAC,WAAW,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC9C,MAAM,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,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 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
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;;AASA,oCAKC;AAED,gCAGC;AAED,oCASC;AAED,4CAiCC;AAED,sCAIC;AAvED,sDAA2B;AAE3B,mEAA+D;AAE/D,IAAI,UAA6B,CAAC;AAClC,IAAI,OAAqB,CAAC;AACb,QAAA,aAAa,GAAG,aAAa,CAAC;AAC9B,QAAA,qBAAqB,GAAG,UAAU,CAAC;AAEzC,KAAK,UAAU,YAAY,CAAC,SAAiB;IACnD,UAAU,GAAG,MAAM,iBAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3C,OAAO,GAAG,MAAM,UAAU,CAAC,aAAa,EAAE,CAAC;IAC3C,MAAM,OAAO,CAAC,cAAc,CAAC,qBAAa,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,0CAA0C,IAAA,8BAAa,GAAE,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,SAAgB,UAAU;IACzB,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACnF,OAAO,OAAO,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,YAAY,CACjC,KAA0B;IAE1B,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,EAAE,CAAC,OAAO,CAAC,qBAAa,EAAE,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE;QACvD,WAAW,EAAE,kBAAkB;KAC/B,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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\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}"]}
@@ -54,10 +54,15 @@ exports.CoreEmailAuthIdentity = CoreEmailAuthIdentity = __decorate([
54
54
  }),
55
55
  (0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
56
56
  const update = this.getUpdate();
57
+ if (!update)
58
+ return next();
57
59
  if (update?.password) {
58
60
  update.password = await hashPassword(update.password);
59
- this.setUpdate(update);
60
61
  }
62
+ if (update.$set?.password) {
63
+ update.$set.password = await hashPassword(update.$set.password);
64
+ }
65
+ this.setUpdate(update);
61
66
  next();
62
67
  })
63
68
  ], CoreEmailAuthIdentity);
@@ -1 +1 @@
1
- {"version":3,"file":"core-email-auth-identity.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/core-email-auth-identity.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,0EAA+D;AAC/D,mEAAyD;AACzD,wDAA8B;AAE9B,yEAAsE;AAEtE,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,IAAI,GAAG,MAAM,kBAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,OAAO,kBAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;AAeM,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,2CAAgB;IAEnD,KAAK,CAAU;IAGf,QAAQ,CAAU;IAGlB,IAAI,CAAe;IAGnB,aAAa,CAAuB;CAC3C,CAAA;AAZY,sDAAqB;AAE1B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACjB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uDACd;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,4BAAS,EAAE,CAAC;;mDACA;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACE,yCAAmB;4DAAC;gCAX/B,qBAAqB;IAdjC,IAAA,eAAG,EAAwB,MAAM,EAAE,KAAK,WAAW,IAAI;QACvD,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAoC,kBAAkB,EAAE,KAAK,WAAW,IAAI;QAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAyB,CAAC;QACvD,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC;YACtB,MAAM,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACtD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,qBAAqB,CAYjC","sourcesContent":["import { modelOptions, prop, pre, Ref } from '@typegoose/typegoose';\nimport { CoreAuthIdentity } from '../core-auth-identity.model';\nimport { OTPFields } from '../embedded/otp-fields.model';\nimport bcrypt from 'bcryptjs';\nimport { Query } from 'mongoose';\nimport { ResetPasswordFields } from '../embedded/rest-password.model';\n\nasync function hashPassword(password: string): Promise<string> {\n\tconst salt = await bcrypt.genSalt(10);\n\treturn bcrypt.hash(password, salt);\n}\n@pre<CoreEmailAuthIdentity>('save', async function (next) {\n\tif (this.isModified('password')) {\n\t\tthis.password = await hashPassword(this.password);\n\t}\n\tnext();\n})\n@pre<Query<any, CoreEmailAuthIdentity>>('findOneAndUpdate', async function (next) {\n\tconst update = this.getUpdate() as Record<string, any>;\n\tif (update?.password) {\n\t\tupdate.password = await hashPassword(update.password);\n\t\tthis.setUpdate(update);\n\t}\n\tnext();\n})\nexport class CoreEmailAuthIdentity extends CoreAuthIdentity {\n\t@prop({ required: true, type: String })\n\tpublic email!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic password!: string;\n\n\t@prop({ type: OTPFields })\n\tpublic otps?: OTPFields[];\n\n\t@prop({ _id: false })\n\tpublic resetPassword?: ResetPasswordFields;\n}\n"]}
1
+ {"version":3,"file":"core-email-auth-identity.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/core-email-auth-identity.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,0EAA+D;AAC/D,mEAAyD;AACzD,wDAA8B;AAE9B,yEAAsE;AAEtE,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,IAAI,GAAG,MAAM,kBAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,OAAO,kBAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;AAsBM,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,2CAAgB;IAEnD,KAAK,CAAU;IAGf,QAAQ,CAAU;IAGlB,IAAI,CAAe;IAGnB,aAAa,CAAuB;CAC3C,CAAA;AAZY,sDAAqB;AAE1B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACjB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uDACd;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,4BAAS,EAAE,CAAC;;mDACA;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;8BACE,yCAAmB;4DAAC;gCAX/B,qBAAqB;IArBjC,IAAA,eAAG,EAAwB,MAAM,EAAE,KAAK,WAAW,IAAI;QACvD,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAoC,kBAAkB,EAAE,KAAK,WAAW,IAAI;QAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAyB,CAAC;QACvD,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,EAAE,CAAC;QAE3B,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC;YACtB,MAAM,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,qBAAqB,CAYjC","sourcesContent":["import { modelOptions, prop, pre, Ref } from '@typegoose/typegoose';\nimport { CoreAuthIdentity } from '../core-auth-identity.model';\nimport { OTPFields } from '../embedded/otp-fields.model';\nimport bcrypt from 'bcryptjs';\nimport { Query } from 'mongoose';\nimport { ResetPasswordFields } from '../embedded/rest-password.model';\n\nasync function hashPassword(password: string): Promise<string> {\n\tconst salt = await bcrypt.genSalt(10);\n\treturn bcrypt.hash(password, salt);\n}\n@pre<CoreEmailAuthIdentity>('save', async function (next) {\n\tif (this.isModified('password')) {\n\t\tthis.password = await hashPassword(this.password);\n\t}\n\tnext();\n})\n@pre<Query<any, CoreEmailAuthIdentity>>('findOneAndUpdate', async function (next) {\n\tconst update = this.getUpdate() as Record<string, any>;\n\tif (!update) return next();\n\n\tif (update?.password) {\n\t\tupdate.password = await hashPassword(update.password);\n\t}\n\n\tif (update.$set?.password) {\n\t\tupdate.$set.password = await hashPassword(update.$set.password);\n\t}\n\n\tthis.setUpdate(update);\n\tnext();\n})\nexport class CoreEmailAuthIdentity extends CoreAuthIdentity {\n\t@prop({ required: true, type: String })\n\tpublic email!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic password!: string;\n\n\t@prop({ type: OTPFields })\n\tpublic otps?: OTPFields[];\n\n\t@prop({ _id: false })\n\tpublic resetPassword?: ResetPasswordFields;\n}\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.2.85
25
+ Version: 1.2.87
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.2.85",
3
+ "version": "1.2.87",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.2.85",
3
+ "version": "1.2.87",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",