@lyxa.ai/core 1.0.146 → 1.0.148
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.d.ts +2 -1
- package/dist/libraries/event/index.js +19 -7
- package/dist/libraries/event/index.js.map +1 -1
- package/dist/libraries/mongo/models/user.model.js +0 -1
- package/dist/libraries/mongo/models/user.model.js.map +1 -1
- package/dist/libraries/mongo/models/zone.model.js +2 -1
- package/dist/libraries/mongo/models/zone.model.js.map +1 -1
- package/dist/libraries/trpc/context.d.ts +10 -0
- package/dist/libraries/trpc/context.js +12 -1
- package/dist/libraries/trpc/context.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/package.json +3 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseEvent } from './BaseEvent';
|
|
2
|
-
export declare function initEventBus(
|
|
2
|
+
export declare function initEventBus(rabbitUrl: string): Promise<void>;
|
|
3
3
|
export declare function publishEvent<TPayload extends Record<string, unknown>>(event: BaseEvent<TPayload>): Promise<void>;
|
|
4
4
|
export declare function subscribeToEvent(eventId: string, onMessage: (payload: any) => Promise<void>): Promise<void>;
|
|
5
|
+
export declare function closeEventBus(): Promise<void>;
|
|
@@ -6,16 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.initEventBus = initEventBus;
|
|
7
7
|
exports.publishEvent = publishEvent;
|
|
8
8
|
exports.subscribeToEvent = subscribeToEvent;
|
|
9
|
+
exports.closeEventBus = closeEventBus;
|
|
9
10
|
const amqplib_1 = __importDefault(require("amqplib"));
|
|
11
|
+
const crypto_1 = require("crypto");
|
|
10
12
|
let connection;
|
|
11
13
|
let channel;
|
|
14
|
+
let instanceId;
|
|
12
15
|
const EXCHANGE_NAME = 'lyxa.events';
|
|
13
|
-
async function initEventBus(
|
|
14
|
-
const rabbitUrl = rabbitMqUrl ?? 'amqps://adlvedna:oY_X4qH1AphtB83YNcf9DHMO3UVmX23s@dog.lmq.cloudamqp.com/adlvedna';
|
|
16
|
+
async function initEventBus(rabbitUrl) {
|
|
15
17
|
connection = await amqplib_1.default.connect(rabbitUrl);
|
|
16
18
|
channel = await connection.createChannel();
|
|
19
|
+
instanceId = (0, crypto_1.randomUUID)();
|
|
17
20
|
await channel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });
|
|
18
|
-
console.log(
|
|
21
|
+
console.log(`EventBus initialized with instance ID: ${instanceId}`);
|
|
19
22
|
}
|
|
20
23
|
async function publishEvent(event) {
|
|
21
24
|
if (!channel)
|
|
@@ -29,9 +32,11 @@ async function publishEvent(event) {
|
|
|
29
32
|
async function subscribeToEvent(eventId, onMessage) {
|
|
30
33
|
if (!channel)
|
|
31
34
|
throw new Error('Channel not initialized. Call initEventBus first.');
|
|
32
|
-
const queueName = `${eventId}
|
|
35
|
+
const queueName = `${eventId}-${instanceId}`;
|
|
33
36
|
await channel.assertQueue(queueName, {
|
|
34
|
-
durable:
|
|
37
|
+
durable: false,
|
|
38
|
+
exclusive: true,
|
|
39
|
+
autoDelete: true,
|
|
35
40
|
});
|
|
36
41
|
await channel.bindQueue(queueName, EXCHANGE_NAME, eventId);
|
|
37
42
|
await channel.consume(queueName, async (msg) => {
|
|
@@ -43,10 +48,17 @@ async function subscribeToEvent(eventId, onMessage) {
|
|
|
43
48
|
channel.ack(msg);
|
|
44
49
|
}
|
|
45
50
|
catch (err) {
|
|
46
|
-
console.error(`Error handling event [${eventId}]`, err);
|
|
51
|
+
console.error(`Error handling event [${eventId}] on instance [${instanceId}]`, err);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
}, { noAck: false });
|
|
50
|
-
console.log(`Subscribed to event [${eventId}] on queue [${queueName}]`);
|
|
55
|
+
console.log(`Subscribed to event [${eventId}] on queue [${queueName}] for instance [${instanceId}]`);
|
|
56
|
+
}
|
|
57
|
+
async function closeEventBus() {
|
|
58
|
+
if (channel)
|
|
59
|
+
await channel.close();
|
|
60
|
+
if (connection)
|
|
61
|
+
await connection.close();
|
|
62
|
+
console.log(`EventBus closed for instance [${instanceId}]`);
|
|
51
63
|
}
|
|
52
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;AAOA,oCAMC;AACD,oCASC;AACD,4CA6BC;AACD,sCAIC;AA1DD,sDAA2B;AAE3B,mCAAoC;AACpC,IAAI,UAA6B,CAAC;AAClC,IAAI,OAAqB,CAAC;AAC1B,IAAI,UAAkB,CAAC;AACvB,MAAM,aAAa,GAAG,aAAa,CAAC;AAC7B,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,UAAU,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC1B,MAAM,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,0CAA0C,UAAU,EAAE,CAAC,CAAC;AACrE,CAAC;AACM,KAAK,UAAU,YAAY,CACjC,KAA0B;IAE1B,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACnF,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE;QAC5D,WAAW,EAAE,kBAAkB;KAC/B,CAAC,CAAC;IAC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E,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACnC,IAAI,UAAU;QAAE,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,iCAAiC,UAAU,GAAG,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import amqp from 'amqplib';\nimport { BaseEvent } from './BaseEvent';\nimport { randomUUID } from 'crypto';\nlet connection: amqp.ChannelModel;\nlet channel: amqp.Channel;\nlet instanceId: string;\nconst EXCHANGE_NAME = 'lyxa.events';\nexport async function initEventBus(rabbitUrl: string) {\n\tconnection = await amqp.connect(rabbitUrl);\n\tchannel = await connection.createChannel();\n\tinstanceId = randomUUID(); // or use uuidv7\n\tawait channel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\tconsole.log(`EventBus initialized with instance ID: ${instanceId}`);\n}\nexport async function publishEvent<TPayload extends Record<string, unknown>>(\n\tevent: BaseEvent<TPayload>\n): Promise<void> {\n\tif (!channel) throw new Error('Channel not initialized. Call initEventBus first.');\n\tconst messageBuffer = Buffer.from(JSON.stringify(event.payload));\n\tchannel.publish(EXCHANGE_NAME, event.eventId, messageBuffer, {\n\t\tcontentType: 'application/json',\n\t});\n\tconsole.log(`Published event [${event.eventId}] with payload`, event.payload);\n}\nexport async function subscribeToEvent(\n\teventId: string,\n\tonMessage: (payload: any) => Promise<void>\n): Promise<void> {\n\tif (!channel) throw new Error('Channel not initialized. Call initEventBus first.');\n\tconst queueName = `${eventId}-${instanceId}`;\n\tawait channel.assertQueue(queueName, {\n\t\tdurable: false,\n\t\texclusive: true,\n\t\tautoDelete: true,\n\t});\n\tawait channel.bindQueue(queueName, EXCHANGE_NAME, eventId);\n\tawait channel.consume(\n\t\tqueueName,\n\t\tasync msg => {\n\t\t\tif (msg !== null) {\n\t\t\t\tconst payloadString = msg.content.toString();\n\t\t\t\tconst payload = JSON.parse(payloadString);\n\t\t\t\ttry {\n\t\t\t\t\tawait onMessage(payload);\n\t\t\t\t\tchannel.ack(msg);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`Error handling event [${eventId}] on instance [${instanceId}]`, err);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ noAck: false }\n\t);\n\tconsole.log(`Subscribed to event [${eventId}] on queue [${queueName}] for instance [${instanceId}]`);\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 [${instanceId}]`);\n}\n"]}
|
|
@@ -132,7 +132,6 @@ __decorate([
|
|
|
132
132
|
__metadata("design:type", String)
|
|
133
133
|
], User.prototype, "onlineStatus", void 0);
|
|
134
134
|
exports.User = User = User_1 = __decorate([
|
|
135
|
-
(0, typegoose_1.index)({ location: '2dsphere' }),
|
|
136
135
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'users' } })
|
|
137
136
|
], User);
|
|
138
137
|
//# sourceMappingURL=user.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.js","sourceRoot":"/","sources":["libraries/mongo/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAAiG;AACjG,4EAAqE;AACrE,uDAA6C;AAC7C,mDAA0C;AAC1C,6CAAoC;AACpC,0DAAqD;AACrD,iDAAwC;AACxC,6DAAoD;AACpD,kDAAiF;AACjF,kEAAwD;
|
|
1
|
+
{"version":3,"file":"user.model.js","sourceRoot":"/","sources":["libraries/mongo/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAAiG;AACjG,4EAAqE;AACrE,uDAA6C;AAC7C,mDAA0C;AAC1C,6CAAoC;AACpC,0DAAqD;AACrD,iDAAwC;AACxC,6DAAoD;AACpD,kDAAiF;AACjF,kEAAwD;AAGjD,IAAM,IAAI,YAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,QAAQ,CAAiB;IAGzB,gBAAgB,CAAkB;IAGlC,aAAa,CAAe;IAG5B,SAAS,CAA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V,4BAAS;0CAAC;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;6CACP;AAO1B;IALN,IAAA,gBAAI,EAAC;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,mBAAY;QAClB,OAAO,EAAE,mBAAY,CAAC,OAAO;KAC7B,CAAC;;0CACiC;eA/DvB,IAAI;IADhB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;GAC5C,IAAI,CAoEhB","sourcesContent":["import { index, modelOptions, mongoose, prop, Ref, ReturnModelType } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CoreUser } from './core-user.model';\nimport { Product } from './product.model';\nimport { Shop } from './shop.model';\nimport { UserAddress } from './shared/address.model';\nimport { Coupon } from './coupon.model';\nimport { Subscription } from './subscription.model';\nimport { OnlineStatus, ShopOnlineStatus, Status } from '../../../utilities/enum';\nimport { OTPFields } from './embedded/otp-fields.model';\n\n@modelOptions({ schemaOptions: { collection: 'users' } })\nexport class User extends TimeStamps {\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic coreUser!: Ref<CoreUser>;\n\n\t@prop({ type: () => [String], ref: () => Product })\n\tpublic favoriteProducts?: Ref<Product>[];\n\n\t@prop({ type: () => [String], ref: () => Shop })\n\tpublic favoriteShops?: Ref<Shop>[];\n\n\t@prop({ type: () => [UserAddress] })\n\tpublic addresses?: UserAddress[];\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic orderCompleted?: number;\n\n\t@prop({ type: Date })\n\tpublic repeatedOrderAt?: Date;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic walletBalance?: number;\n\n\t@prop({ ref: () => Coupon })\n\tpublic coupons?: Ref<Coupon>[];\n\n\t@prop({ type: String })\n\tpublic newUserCouponDiscountType?: string;\n\n\t@prop({ type: Number })\n\tpublic newUserCouponValue?: number;\n\n\t@prop({ type: Number })\n\tpublic newUserCouponMaximumDiscountLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isNewUserCouponShowed?: boolean;\n\n\t@prop({ ref: () => Coupon })\n\tpublic referralCode?: Ref<Coupon>;\n\n\t@prop({ type: String, ref: () => Subscription })\n\tpublic subscription?: Ref<Subscription>;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSubscribed?: boolean;\n\n\t@prop({ type: String, unique: true, sparse: true })\n\tpublic phoneNumber?: string;\n\n\t@prop({ type: () => OTPFields })\n\tpublic phoneOtpInfo?: OTPFields;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPhoneVerified?: boolean;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: OnlineStatus,\n\t\tdefault: OnlineStatus.OFFLINE,\n\t})\n\tpublic onlineStatus?: OnlineStatus;\n\n\tpublic static async updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number) {\n\t\treturn this.findByIdAndUpdate(userId, { $inc: { walletBalance: amount } }, { new: true });\n\t}\n}\n"]}
|
|
@@ -68,6 +68,7 @@ __decorate([
|
|
|
68
68
|
__metadata("design:type", Boolean)
|
|
69
69
|
], Zone.prototype, "isIncludedReward", void 0);
|
|
70
70
|
exports.Zone = Zone = __decorate([
|
|
71
|
-
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'zones' } })
|
|
71
|
+
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'zones' } }),
|
|
72
|
+
(0, typegoose_1.Index)({ geometry: '2dsphere' })
|
|
72
73
|
], Zone);
|
|
73
74
|
//# sourceMappingURL=zone.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zone.model.js","sourceRoot":"/","sources":["libraries/mongo/models/zone.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"zone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MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCACd;AAIlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;8CACL;eA/BtB,IAAI;IAFhB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;IACxD,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;GACnB,IAAI,CAgChB","sourcesContent":["import { Index, modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ZoneStatus } from '../../../utilities/enum';\nimport { ZoneGeometry } from './embedded/zone-geometry.mode';\n\n@modelOptions({ schemaOptions: { collection: 'zones' } })\n@Index({ geometry: '2dsphere' })\nexport class Zone extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic area?: string;\n\n\t@prop({ required: true, type: ZoneGeometry })\n\tpublic geometry!: ZoneGeometry;\n\n\t@prop({ type: String, enum: ZoneStatus, default: ZoneStatus.ACTIVE })\n\tpublic status?: ZoneStatus;\n\n\t@prop({ type: String })\n\tpublic busyTitle?: string;\n\n\t@prop({ type: String })\n\tpublic busyDescription?: string;\n\n\t// Rider reward feature when he reached the target\n\t@prop({ type: Number, default: Infinity })\n\tpublic riderWeeklyTarget?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic riderWeeklyReward?: number;\n\n\t@prop({ type: Number, required: true })\n\tpublic areaSqKm!: number;\n\n\t// Rider reward are not be applied when isIncludedRewared false\n\t@prop({ type: Boolean, default: true })\n\tpublic isIncludedReward?: boolean;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CreateHTTPContextOptions } from '@trpc/server/dist/adapters/standalone';
|
|
2
|
+
import type { CreateWSSContextFnOptions } from '@trpc/server/adapters/ws';
|
|
2
3
|
import { AuthEntityType } from '../auth';
|
|
3
4
|
import jwt from 'jsonwebtoken';
|
|
4
5
|
import { TokenType } from '../auth';
|
|
@@ -15,4 +16,13 @@ export interface LyxaContextParams {
|
|
|
15
16
|
tokenRenewed?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare const createLyxaContext: (opts: CreateHTTPContextOptions) => Promise<CreateHTTPContextOptions & LyxaContextParams>;
|
|
19
|
+
export declare const createLyxaWsContext: (opts: CreateWSSContextFnOptions) => Promise<{
|
|
20
|
+
entity: undefined;
|
|
21
|
+
requestId: undefined;
|
|
22
|
+
tokenType: undefined;
|
|
23
|
+
usedRefreshToken: boolean;
|
|
24
|
+
tokenRenewed: boolean;
|
|
25
|
+
req: import("http").IncomingMessage;
|
|
26
|
+
res: import("ws").WebSocket;
|
|
27
|
+
}>;
|
|
18
28
|
export type LyxaContext = Awaited<ReturnType<typeof createLyxaContext>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLyxaContext = void 0;
|
|
3
|
+
exports.createLyxaWsContext = exports.createLyxaContext = void 0;
|
|
4
4
|
const createLyxaContext = async (opts) => {
|
|
5
5
|
return {
|
|
6
6
|
...opts,
|
|
@@ -12,4 +12,15 @@ const createLyxaContext = async (opts) => {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
exports.createLyxaContext = createLyxaContext;
|
|
15
|
+
const createLyxaWsContext = async (opts) => {
|
|
16
|
+
return {
|
|
17
|
+
...opts,
|
|
18
|
+
entity: undefined,
|
|
19
|
+
requestId: undefined,
|
|
20
|
+
tokenType: undefined,
|
|
21
|
+
usedRefreshToken: false,
|
|
22
|
+
tokenRenewed: false,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.createLyxaWsContext = createLyxaWsContext;
|
|
15
26
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"/","sources":["libraries/trpc/context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"/","sources":["libraries/trpc/context.ts"],"names":[],"mappings":";;;AAqBO,MAAM,iBAAiB,GAAG,KAAK,EACrC,IAA8B,EAC0B,EAAE;IAC1D,OAAO;QACN,GAAG,IAAI;QACP,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,KAAK;KACnB,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B;AAEK,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA+B,EAAE,EAAE;IAC5E,OAAO;QACN,GAAG,IAAI;QACP,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,KAAK;KACnB,CAAC;AACH,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B","sourcesContent":["import { CreateHTTPContextOptions } from '@trpc/server/dist/adapters/standalone';\nimport type { CreateWSSContextFnOptions } from '@trpc/server/adapters/ws';\nimport { AuthEntityType } from '../auth';\nimport jwt from 'jsonwebtoken';\nimport { TokenType } from '../auth';\nimport { request } from 'http';\n\nexport interface EntityContext extends jwt.JwtPayload {\n\tid: string;\n\ttype: AuthEntityType;\n\tparameters: Record<string, unknown>;\n}\n\nexport interface LyxaContextParams {\n\tentity?: EntityContext;\n\trequestId?: string;\n\ttokenType?: TokenType;\n\tusedRefreshToken?: boolean;\n\ttokenRenewed?: boolean;\n}\n\nexport const createLyxaContext = async (\n\topts: CreateHTTPContextOptions\n): Promise<CreateHTTPContextOptions & LyxaContextParams> => {\n\treturn {\n\t\t...opts,\n\t\tentity: undefined,\n\t\trequestId: undefined,\n\t\ttokenType: undefined,\n\t\tusedRefreshToken: false,\n\t\ttokenRenewed: false,\n\t};\n};\n\nexport const createLyxaWsContext = async (opts: CreateWSSContextFnOptions) => {\n\treturn {\n\t\t...opts,\n\t\tentity: undefined,\n\t\trequestId: undefined,\n\t\ttokenType: undefined,\n\t\tusedRefreshToken: false,\n\t\ttokenRenewed: false,\n\t};\n};\n\nexport type LyxaContext = Awaited<ReturnType<typeof createLyxaContext>>;\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lyxa.ai/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.148",
|
|
4
4
|
"description": "The Core system of the Lyxa services.",
|
|
5
5
|
"author": "elie <42282499+Internalizable@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,11 +48,13 @@
|
|
|
48
48
|
"twilio": "^5.4.0",
|
|
49
49
|
"typedi": "^0.10.0",
|
|
50
50
|
"typescript": "^5.7.2",
|
|
51
|
+
"ws": "^8.18.3",
|
|
51
52
|
"zod": "^3.24.1"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@types/mapbox__polyline": "^1.0.5",
|
|
55
56
|
"@types/mime-types": "^2.1.4",
|
|
57
|
+
"@types/ws": "^8.18.1",
|
|
56
58
|
"prettier": "3.5.3"
|
|
57
59
|
}
|
|
58
60
|
}
|