@lyxa.ai/core 1.4.331 → 1.4.332-alpha.0

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.
@@ -1,4 +1,5 @@
1
1
  import Redis from 'ioredis';
2
+ import { AuthEntityType } from '../auth';
2
3
  interface LockOptions {
3
4
  maxRetries?: number;
4
5
  retryDelayMs?: number;
@@ -21,5 +22,8 @@ export declare class RedisService {
21
22
  acquireLock(key: string, ttl?: number): Promise<string | null>;
22
23
  releaseLock(key: string, lockValue: string): Promise<boolean>;
23
24
  executeWithLock<T>(key: string, ttl: number, callback: () => Promise<T>, errorMessage?: string, options?: LockOptions): Promise<T>;
25
+ private buildLastOnlineKey;
26
+ setLastOnline(entityType: AuthEntityType, entityId: string, timestamp?: number): Promise<void>;
27
+ getOnlineEntities(entityType: AuthEntityType, cutoffTime: Date): Promise<string[]>;
24
28
  }
25
29
  export {};
@@ -128,6 +128,18 @@ let RedisService = class RedisService {
128
128
  cause: { retryable: true },
129
129
  });
130
130
  }
131
+ buildLastOnlineKey(entityType) {
132
+ return `lastOnline:${entityType}`;
133
+ }
134
+ async setLastOnline(entityType, entityId, timestamp = Date.now()) {
135
+ const key = this.buildLastOnlineKey(entityType);
136
+ await this._redisClient.zadd(key, timestamp, entityId);
137
+ }
138
+ async getOnlineEntities(entityType, cutoffTime) {
139
+ const key = this.buildLastOnlineKey(entityType);
140
+ const cutoffMs = cutoffTime.getTime();
141
+ return await this._redisClient.zrangebyscore(key, cutoffMs, '+inf');
142
+ }
131
143
  };
132
144
  exports.RedisService = RedisService;
133
145
  exports.RedisService = RedisService = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA4B;AAC5B,mCAAiC;AACjC,mCAAoC;AACpC,kCAAoC;AAQ7B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAChB,YAAY,CAAS;IAE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BAAS,CAAC;oBACV,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;gBACxC,CAAC;YACF,CAAC;YAED,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YAE1E,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,IAAI,gBAAS,CAAC;YACnB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,YAAY,IAAI,oBAAoB;YAC7C,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;SAC1B,CAAC,CAAC;IACJ,CAAC;CACD,CAAA;AA1JY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CA0JxB","sourcesContent":["import Redis from 'ioredis';\nimport { Service } from 'typedi';\nimport { randomUUID } from 'crypto';\nimport { TRPCError } from '../trpc';\n\ninterface LockOptions {\n\tmaxRetries?: number;\n\tretryDelayMs?: number;\n}\n\n@Service()\nexport class RedisService {\n\tprivate _redisClient!: Redis;\n\n\tconstructor(redisURL: string) {\n\t\tthis._redisClient = new Redis(redisURL, {\n\t\t\tmaxRetriesPerRequest: null,\n\t\t});\n\t}\n\n\tget redisClient(): Redis {\n\t\treturn this._redisClient;\n\t}\n\n\tpublic async getCachedObject<T>(key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.get(key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async cacheObject<T>(key: string, object: T, expiry?: number): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\n\t\tif (expiry) {\n\t\t\tawait this._redisClient.setex(key, expiry, stringifiedObject);\n\t\t} else {\n\t\t\tawait this._redisClient.set(key, stringifiedObject);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObject(key: string): Promise<boolean> {\n\t\tawait this._redisClient.del(key);\n\t\treturn true;\n\t}\n\n\tpublic async getCachedObjectByGroup<T>(group: string, key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.hget(group, key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async setCachedObjectByGroup<T>(group: string, key: string, object: T): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\t\tawait this._redisClient.hset(group, key, stringifiedObject);\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObjectByGroup<T>(group: string, key: string): Promise<boolean> {\n\t\tawait this._redisClient.hdel(group, key);\n\t\treturn true;\n\t}\n\n\tpublic sanitizeKey(key: string) {\n\t\treturn key\n\t\t\t.replace(/[^\\w\\s]/gi, '')\n\t\t\t.replace(/\\s+/g, '-')\n\t\t\t.toLowerCase();\n\t}\n\n\tpublic async addToSet(group: string, member: string): Promise<boolean> {\n\t\tawait this._redisClient.sadd(group, member);\n\t\treturn true;\n\t}\n\n\tpublic async removeFromSet(group: string, member: string): Promise<boolean> {\n\t\tawait this._redisClient.srem(group, member);\n\t\treturn true;\n\t}\n\n\tpublic async isMemberOfSet(group: string, member: string): Promise<boolean> {\n\t\treturn (await this._redisClient.sismember(group, member)) === 1;\n\t}\n\n\tpublic async getSetMembers(group: string): Promise<string[]> {\n\t\treturn await this._redisClient.smembers(group);\n\t}\n\n\tpublic async acquireLock(\n\t\tkey: string,\n\t\tttl: number = 10000 // default 10s\n\t): Promise<string | null> {\n\t\tconst lockKey = `lock:${key}`;\n\t\tconst lockValue = randomUUID(); // unique value per process\n\n\t\tconst result = await this._redisClient.set(lockKey, lockValue, 'PX', ttl, 'NX');\n\n\t\t// If result === 'OK' → lock acquired\n\t\tif (result === 'OK') {\n\t\t\treturn lockValue;\n\t\t}\n\n\t\treturn null; // lock not acquired\n\t}\n\n\tpublic async releaseLock(key: string, lockValue: string): Promise<boolean> {\n\t\tconst lockKey = `lock:${key}`;\n\n\t\tconst luaScript = `\n\t\tif redis.call(\"get\", KEYS[1]) == ARGV[1] then\n\t\t\treturn redis.call(\"del\", KEYS[1])\n\t\telse\n\t\t\treturn 0\n\t\tend\n\t`;\n\n\t\tconst result = await this._redisClient.eval(luaScript, 1, lockKey, lockValue);\n\n\t\treturn result === 1;\n\t}\n\n\tpublic async executeWithLock<T>(\n\t\tkey: string,\n\t\tttl: number,\n\t\tcallback: () => Promise<T>,\n\t\terrorMessage?: string,\n\t\toptions?: LockOptions\n\t): Promise<T> {\n\t\tconst maxRetries = options?.maxRetries ?? 10;\n\t\tconst retryDelayMs = options?.retryDelayMs ?? 500;\n\n\t\tlet attempt = 0;\n\n\t\twhile (attempt <= maxRetries) {\n\t\t\tconst lockValue = await this.acquireLock(key, ttl);\n\n\t\t\tif (lockValue) {\n\t\t\t\ttry {\n\t\t\t\t\treturn await callback();\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.releaseLock(key, lockValue);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait new Promise(r => setTimeout(r, retryDelayMs + Math.random() * 100));\n\n\t\t\tattempt++;\n\t\t}\n\n\t\tthrow new TRPCError({\n\t\t\tcode: 'CONFLICT',\n\t\t\tmessage: errorMessage || 'Resource is locked',\n\t\t\tcause: { retryable: true },\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA4B;AAC5B,mCAAiC;AACjC,mCAAoC;AACpC,kCAAoC;AAS7B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAChB,YAAY,CAAS;IAE7B,YAAY,QAAgB;QAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,iBAAK,CAAC,QAAQ,EAAE;YACvC,oBAAoB,EAAE,IAAI;SAC1B,CAAC,CAAC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CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YAE1E,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,IAAI,gBAAS,CAAC;YACnB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,YAAY,IAAI,oBAAoB;YAC7C,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;SAC1B,CAAC,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,UAA0B;QACpD,OAAO,cAAc,UAAU,EAAE,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,UAA0B,EAAE,QAAgB,EAAE,YAAoB,IAAI,CAAC,GAAG,EAAE;QACtG,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAChD,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,UAA0B,EAAE,UAAgB;QAC1E,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;QAEtC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;CACD,CAAA;AA1KY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CA0KxB","sourcesContent":["import Redis from 'ioredis';\nimport { Service } from 'typedi';\nimport { randomUUID } from 'crypto';\nimport { TRPCError } from '../trpc';\nimport { AuthEntityType } from '../auth';\n\ninterface LockOptions {\n\tmaxRetries?: number;\n\tretryDelayMs?: number;\n}\n\n@Service()\nexport class RedisService {\n\tprivate _redisClient!: Redis;\n\n\tconstructor(redisURL: string) {\n\t\tthis._redisClient = new Redis(redisURL, {\n\t\t\tmaxRetriesPerRequest: null,\n\t\t});\n\t}\n\n\tget redisClient(): Redis {\n\t\treturn this._redisClient;\n\t}\n\n\tpublic async getCachedObject<T>(key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.get(key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async cacheObject<T>(key: string, object: T, expiry?: number): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\n\t\tif (expiry) {\n\t\t\tawait this._redisClient.setex(key, expiry, stringifiedObject);\n\t\t} else {\n\t\t\tawait this._redisClient.set(key, stringifiedObject);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObject(key: string): Promise<boolean> {\n\t\tawait this._redisClient.del(key);\n\t\treturn true;\n\t}\n\n\tpublic async getCachedObjectByGroup<T>(group: string, key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.hget(group, key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async setCachedObjectByGroup<T>(group: string, key: string, object: T): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\t\tawait this._redisClient.hset(group, key, stringifiedObject);\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObjectByGroup<T>(group: string, key: string): Promise<boolean> {\n\t\tawait this._redisClient.hdel(group, key);\n\t\treturn true;\n\t}\n\n\tpublic sanitizeKey(key: string) {\n\t\treturn key\n\t\t\t.replace(/[^\\w\\s]/gi, '')\n\t\t\t.replace(/\\s+/g, '-')\n\t\t\t.toLowerCase();\n\t}\n\n\tpublic async addToSet(group: string, member: string): Promise<boolean> {\n\t\tawait this._redisClient.sadd(group, member);\n\t\treturn true;\n\t}\n\n\tpublic async removeFromSet(group: string, member: string): Promise<boolean> {\n\t\tawait this._redisClient.srem(group, member);\n\t\treturn true;\n\t}\n\n\tpublic async isMemberOfSet(group: string, member: string): Promise<boolean> {\n\t\treturn (await this._redisClient.sismember(group, member)) === 1;\n\t}\n\n\tpublic async getSetMembers(group: string): Promise<string[]> {\n\t\treturn await this._redisClient.smembers(group);\n\t}\n\n\tpublic async acquireLock(\n\t\tkey: string,\n\t\tttl: number = 10000 // default 10s\n\t): Promise<string | null> {\n\t\tconst lockKey = `lock:${key}`;\n\t\tconst lockValue = randomUUID(); // unique value per process\n\n\t\tconst result = await this._redisClient.set(lockKey, lockValue, 'PX', ttl, 'NX');\n\n\t\t// If result === 'OK' → lock acquired\n\t\tif (result === 'OK') {\n\t\t\treturn lockValue;\n\t\t}\n\n\t\treturn null; // lock not acquired\n\t}\n\n\tpublic async releaseLock(key: string, lockValue: string): Promise<boolean> {\n\t\tconst lockKey = `lock:${key}`;\n\n\t\tconst luaScript = `\n\t\tif redis.call(\"get\", KEYS[1]) == ARGV[1] then\n\t\t\treturn redis.call(\"del\", KEYS[1])\n\t\telse\n\t\t\treturn 0\n\t\tend\n\t`;\n\n\t\tconst result = await this._redisClient.eval(luaScript, 1, lockKey, lockValue);\n\n\t\treturn result === 1;\n\t}\n\n\tpublic async executeWithLock<T>(\n\t\tkey: string,\n\t\tttl: number,\n\t\tcallback: () => Promise<T>,\n\t\terrorMessage?: string,\n\t\toptions?: LockOptions\n\t): Promise<T> {\n\t\tconst maxRetries = options?.maxRetries ?? 10;\n\t\tconst retryDelayMs = options?.retryDelayMs ?? 500;\n\n\t\tlet attempt = 0;\n\n\t\twhile (attempt <= maxRetries) {\n\t\t\tconst lockValue = await this.acquireLock(key, ttl);\n\n\t\t\tif (lockValue) {\n\t\t\t\ttry {\n\t\t\t\t\treturn await callback();\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.releaseLock(key, lockValue);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait new Promise(r => setTimeout(r, retryDelayMs + Math.random() * 100));\n\n\t\t\tattempt++;\n\t\t}\n\n\t\tthrow new TRPCError({\n\t\t\tcode: 'CONFLICT',\n\t\t\tmessage: errorMessage || 'Resource is locked',\n\t\t\tcause: { retryable: true },\n\t\t});\n\t}\n\n\tprivate buildLastOnlineKey(entityType: AuthEntityType) {\n\t\treturn `lastOnline:${entityType}`;\n\t}\n\n\tpublic async setLastOnline(entityType: AuthEntityType, entityId: string, timestamp: number = Date.now()) {\n\t\tconst key = this.buildLastOnlineKey(entityType);\n\t\tawait this._redisClient.zadd(key, timestamp, entityId);\n\t}\n\n\tpublic async getOnlineEntities(entityType: AuthEntityType, cutoffTime: Date) {\n\t\tconst key = this.buildLastOnlineKey(entityType);\n\t\tconst cutoffMs = cutoffTime.getTime();\n\n\t\treturn await this._redisClient.zrangebyscore(key, cutoffMs, '+inf');\n\t}\n}\n"]}
@@ -36,14 +36,14 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
36
36
  thumbnailUrl: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
37
37
  name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
38
38
  }, "strip", z.ZodTypeAny, {
39
- mediaType: MediaType;
40
39
  mediaUrl: string;
40
+ mediaType: MediaType;
41
41
  mimeType: string;
42
42
  name?: string | undefined;
43
43
  thumbnailUrl?: string | undefined;
44
44
  }, {
45
- mediaType: MediaType;
46
45
  mediaUrl: string;
46
+ mediaType: MediaType;
47
47
  mimeType: string;
48
48
  name?: string | undefined;
49
49
  thumbnailUrl?: string | undefined;
@@ -63,8 +63,8 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
63
63
  orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
64
64
  createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
65
65
  }, "strip", z.ZodTypeAny, {
66
- _id: import("mongoose").Types.ObjectId;
67
66
  createdAt: Date;
67
+ _id: import("mongoose").Types.ObjectId;
68
68
  sender: {
69
69
  type: UserRef;
70
70
  name: string;
@@ -72,8 +72,8 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
72
72
  };
73
73
  senderType: UserRef;
74
74
  media: {
75
- mediaType: MediaType;
76
75
  mediaUrl: string;
76
+ mediaType: MediaType;
77
77
  mimeType: string;
78
78
  name?: string | undefined;
79
79
  thumbnailUrl?: string | undefined;
@@ -85,12 +85,12 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
85
85
  longitude?: number | undefined;
86
86
  } | undefined;
87
87
  orderId?: import("mongoose").Types.ObjectId | undefined;
88
- ticketId?: import("mongoose").Types.ObjectId | undefined;
89
88
  content?: string | undefined;
89
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
90
90
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
91
91
  }, {
92
- _id: import("mongoose").Types.ObjectId;
93
92
  createdAt: Date;
93
+ _id: import("mongoose").Types.ObjectId;
94
94
  sender: {
95
95
  type: UserRef;
96
96
  name: string;
@@ -98,8 +98,8 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
98
98
  };
99
99
  senderType: UserRef;
100
100
  media: {
101
- mediaType: MediaType;
102
101
  mediaUrl: string;
102
+ mediaType: MediaType;
103
103
  mimeType: string;
104
104
  name?: string | undefined;
105
105
  thumbnailUrl?: string | undefined;
@@ -111,8 +111,8 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
111
111
  longitude?: number | undefined;
112
112
  } | undefined;
113
113
  orderId?: import("mongoose").Types.ObjectId | undefined;
114
- ticketId?: import("mongoose").Types.ObjectId | undefined;
115
114
  content?: string | undefined;
115
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
116
116
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
117
117
  }>;
118
118
  export declare const ChatroomMessageSendPushOutputSchema: z.ZodObject<{
@@ -172,14 +172,14 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
172
172
  thumbnailUrl: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
173
173
  name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
174
174
  }, "strip", z.ZodTypeAny, {
175
- mediaType: MediaType;
176
175
  mediaUrl: string;
176
+ mediaType: MediaType;
177
177
  mimeType: string;
178
178
  name?: string | undefined;
179
179
  thumbnailUrl?: string | undefined;
180
180
  }, {
181
- mediaType: MediaType;
182
181
  mediaUrl: string;
182
+ mediaType: MediaType;
183
183
  mimeType: string;
184
184
  name?: string | undefined;
185
185
  thumbnailUrl?: string | undefined;
@@ -199,8 +199,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
199
199
  orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
200
200
  createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
201
201
  }, "strip", z.ZodTypeAny, {
202
- _id: import("mongoose").Types.ObjectId;
203
202
  createdAt: Date;
203
+ _id: import("mongoose").Types.ObjectId;
204
204
  sender: {
205
205
  type: UserRef;
206
206
  name: string;
@@ -208,8 +208,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
208
208
  };
209
209
  senderType: UserRef;
210
210
  media: {
211
- mediaType: MediaType;
212
211
  mediaUrl: string;
212
+ mediaType: MediaType;
213
213
  mimeType: string;
214
214
  name?: string | undefined;
215
215
  thumbnailUrl?: string | undefined;
@@ -221,12 +221,12 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
221
221
  longitude?: number | undefined;
222
222
  } | undefined;
223
223
  orderId?: import("mongoose").Types.ObjectId | undefined;
224
- ticketId?: import("mongoose").Types.ObjectId | undefined;
225
224
  content?: string | undefined;
225
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
226
226
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
227
227
  }, {
228
- _id: import("mongoose").Types.ObjectId;
229
228
  createdAt: Date;
229
+ _id: import("mongoose").Types.ObjectId;
230
230
  sender: {
231
231
  type: UserRef;
232
232
  name: string;
@@ -234,8 +234,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
234
234
  };
235
235
  senderType: UserRef;
236
236
  media: {
237
- mediaType: MediaType;
238
237
  mediaUrl: string;
238
+ mediaType: MediaType;
239
239
  mimeType: string;
240
240
  name?: string | undefined;
241
241
  thumbnailUrl?: string | undefined;
@@ -247,8 +247,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
247
247
  longitude?: number | undefined;
248
248
  } | undefined;
249
249
  orderId?: import("mongoose").Types.ObjectId | undefined;
250
- ticketId?: import("mongoose").Types.ObjectId | undefined;
251
250
  content?: string | undefined;
251
+ ticketId?: import("mongoose").Types.ObjectId | undefined;
252
252
  chatroomId?: import("mongoose").Types.ObjectId | undefined;
253
253
  }>;
254
254
  pushNotificationOutput: z.ZodObject<{
@@ -16,11 +16,11 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
16
16
  _id: 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
17
  name: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
18
18
  }, "strip", z.ZodTypeAny, {
19
- _id: import("mongoose").Types.ObjectId;
20
19
  name: string;
20
+ _id: import("mongoose").Types.ObjectId;
21
21
  }, {
22
- _id: string | import("mongoose").Types.ObjectId;
23
22
  name: string;
23
+ _id: string | import("mongoose").Types.ObjectId;
24
24
  }>;
25
25
  orderStatus: z.ZodNativeEnum<typeof RegularOrderStatus>;
26
26
  orderAction: z.ZodNativeEnum<typeof OrderAction>;
@@ -40,107 +40,107 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
40
40
  secondaryRiderTips: z.ZodNumber;
41
41
  }, "strip", z.ZodTypeAny, {
42
42
  deliveryFee: number;
43
- secondaryDeliveryFee: number;
44
43
  riderTips: number;
45
- secondaryRiderTips: number;
46
44
  total: number;
45
+ secondaryDeliveryFee: number;
46
+ secondaryRiderTips: number;
47
47
  secondaryTotal: number;
48
48
  paidAmount: number;
49
49
  secondaryPaidAmount: number;
50
50
  }, {
51
51
  deliveryFee: number;
52
- secondaryDeliveryFee: number;
53
52
  riderTips: number;
54
- secondaryRiderTips: number;
55
53
  total: number;
54
+ secondaryDeliveryFee: number;
55
+ secondaryRiderTips: number;
56
56
  secondaryTotal: number;
57
57
  paidAmount: number;
58
58
  secondaryPaidAmount: number;
59
59
  }>;
60
60
  }, "strip", z.ZodTypeAny, {
61
+ paymentMethod: PaymentMethod;
61
62
  pricing: {
62
63
  deliveryFee: number;
63
- secondaryDeliveryFee: number;
64
64
  riderTips: number;
65
- secondaryRiderTips: number;
66
65
  total: number;
66
+ secondaryDeliveryFee: number;
67
+ secondaryRiderTips: number;
67
68
  secondaryTotal: number;
68
69
  paidAmount: number;
69
70
  secondaryPaidAmount: number;
70
71
  };
71
72
  shopProfit: number;
72
- paymentMethod: PaymentMethod;
73
73
  }, {
74
+ paymentMethod: PaymentMethod;
74
75
  pricing: {
75
76
  deliveryFee: number;
76
- secondaryDeliveryFee: number;
77
77
  riderTips: number;
78
- secondaryRiderTips: number;
79
78
  total: number;
79
+ secondaryDeliveryFee: number;
80
+ secondaryRiderTips: number;
80
81
  secondaryTotal: number;
81
82
  paidAmount: number;
82
83
  secondaryPaidAmount: number;
83
84
  };
84
85
  shopProfit: number;
85
- paymentMethod: PaymentMethod;
86
86
  }>;
87
87
  createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
88
88
  triggerAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
89
89
  orderActionType: z.ZodNativeEnum<typeof OrderAction>;
90
90
  }, "strip", z.ZodTypeAny, {
91
+ createdAt: Date;
91
92
  _id: import("mongoose").Types.ObjectId;
92
- orderId: string;
93
+ shopId: import("mongoose").Types.ObjectId;
93
94
  user: {
94
- _id: import("mongoose").Types.ObjectId;
95
95
  name: string;
96
+ _id: import("mongoose").Types.ObjectId;
96
97
  };
97
- createdAt: Date;
98
- shopId: import("mongoose").Types.ObjectId;
98
+ paymentMethod: PaymentMethod;
99
+ orderId: string;
99
100
  triggerAt: Date;
100
101
  adjustedFinance: {
102
+ paymentMethod: PaymentMethod;
101
103
  pricing: {
102
104
  deliveryFee: number;
103
- secondaryDeliveryFee: number;
104
105
  riderTips: number;
105
- secondaryRiderTips: number;
106
106
  total: number;
107
+ secondaryDeliveryFee: number;
108
+ secondaryRiderTips: number;
107
109
  secondaryTotal: number;
108
110
  paidAmount: number;
109
111
  secondaryPaidAmount: number;
110
112
  };
111
113
  shopProfit: number;
112
- paymentMethod: PaymentMethod;
113
114
  };
114
- paymentMethod: PaymentMethod;
115
115
  orderActionType: OrderAction;
116
116
  orderStatus: RegularOrderStatus;
117
117
  orderAction: OrderAction;
118
118
  preparationTimeMinutes: number;
119
119
  }, {
120
+ createdAt: Date;
120
121
  _id: string | import("mongoose").Types.ObjectId;
121
- orderId: string;
122
+ shopId: string | import("mongoose").Types.ObjectId;
122
123
  user: {
123
- _id: string | import("mongoose").Types.ObjectId;
124
124
  name: string;
125
+ _id: string | import("mongoose").Types.ObjectId;
125
126
  };
126
- createdAt: Date;
127
- shopId: string | import("mongoose").Types.ObjectId;
127
+ paymentMethod: PaymentMethod;
128
+ orderId: string;
128
129
  triggerAt: Date;
129
130
  adjustedFinance: {
131
+ paymentMethod: PaymentMethod;
130
132
  pricing: {
131
133
  deliveryFee: number;
132
- secondaryDeliveryFee: number;
133
134
  riderTips: number;
134
- secondaryRiderTips: number;
135
135
  total: number;
136
+ secondaryDeliveryFee: number;
137
+ secondaryRiderTips: number;
136
138
  secondaryTotal: number;
137
139
  paidAmount: number;
138
140
  secondaryPaidAmount: number;
139
141
  };
140
142
  shopProfit: number;
141
- paymentMethod: PaymentMethod;
142
143
  };
143
- paymentMethod: PaymentMethod;
144
144
  orderActionType: OrderAction;
145
145
  orderStatus: RegularOrderStatus;
146
146
  orderAction: OrderAction;
@@ -160,11 +160,11 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
160
160
  _id: 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>]>;
161
161
  name: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
162
162
  }, "strip", z.ZodTypeAny, {
163
- _id: import("mongoose").Types.ObjectId;
164
163
  name: string;
164
+ _id: import("mongoose").Types.ObjectId;
165
165
  }, {
166
- _id: string | import("mongoose").Types.ObjectId;
167
166
  name: string;
167
+ _id: string | import("mongoose").Types.ObjectId;
168
168
  }>;
169
169
  orderStatus: z.ZodNativeEnum<typeof RegularOrderStatus>;
170
170
  orderAction: z.ZodNativeEnum<typeof OrderAction>;
@@ -184,107 +184,107 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
184
184
  secondaryRiderTips: z.ZodNumber;
185
185
  }, "strip", z.ZodTypeAny, {
186
186
  deliveryFee: number;
187
- secondaryDeliveryFee: number;
188
187
  riderTips: number;
189
- secondaryRiderTips: number;
190
188
  total: number;
189
+ secondaryDeliveryFee: number;
190
+ secondaryRiderTips: number;
191
191
  secondaryTotal: number;
192
192
  paidAmount: number;
193
193
  secondaryPaidAmount: number;
194
194
  }, {
195
195
  deliveryFee: number;
196
- secondaryDeliveryFee: number;
197
196
  riderTips: number;
198
- secondaryRiderTips: number;
199
197
  total: number;
198
+ secondaryDeliveryFee: number;
199
+ secondaryRiderTips: number;
200
200
  secondaryTotal: number;
201
201
  paidAmount: number;
202
202
  secondaryPaidAmount: number;
203
203
  }>;
204
204
  }, "strip", z.ZodTypeAny, {
205
+ paymentMethod: PaymentMethod;
205
206
  pricing: {
206
207
  deliveryFee: number;
207
- secondaryDeliveryFee: number;
208
208
  riderTips: number;
209
- secondaryRiderTips: number;
210
209
  total: number;
210
+ secondaryDeliveryFee: number;
211
+ secondaryRiderTips: number;
211
212
  secondaryTotal: number;
212
213
  paidAmount: number;
213
214
  secondaryPaidAmount: number;
214
215
  };
215
216
  shopProfit: number;
216
- paymentMethod: PaymentMethod;
217
217
  }, {
218
+ paymentMethod: PaymentMethod;
218
219
  pricing: {
219
220
  deliveryFee: number;
220
- secondaryDeliveryFee: number;
221
221
  riderTips: number;
222
- secondaryRiderTips: number;
223
222
  total: number;
223
+ secondaryDeliveryFee: number;
224
+ secondaryRiderTips: number;
224
225
  secondaryTotal: number;
225
226
  paidAmount: number;
226
227
  secondaryPaidAmount: number;
227
228
  };
228
229
  shopProfit: number;
229
- paymentMethod: PaymentMethod;
230
230
  }>;
231
231
  createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
232
232
  triggerAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
233
233
  orderActionType: z.ZodNativeEnum<typeof OrderAction>;
234
234
  }, "strip", z.ZodTypeAny, {
235
+ createdAt: Date;
235
236
  _id: import("mongoose").Types.ObjectId;
236
- orderId: string;
237
+ shopId: import("mongoose").Types.ObjectId;
237
238
  user: {
238
- _id: import("mongoose").Types.ObjectId;
239
239
  name: string;
240
+ _id: import("mongoose").Types.ObjectId;
240
241
  };
241
- createdAt: Date;
242
- shopId: import("mongoose").Types.ObjectId;
242
+ paymentMethod: PaymentMethod;
243
+ orderId: string;
243
244
  triggerAt: Date;
244
245
  adjustedFinance: {
246
+ paymentMethod: PaymentMethod;
245
247
  pricing: {
246
248
  deliveryFee: number;
247
- secondaryDeliveryFee: number;
248
249
  riderTips: number;
249
- secondaryRiderTips: number;
250
250
  total: number;
251
+ secondaryDeliveryFee: number;
252
+ secondaryRiderTips: number;
251
253
  secondaryTotal: number;
252
254
  paidAmount: number;
253
255
  secondaryPaidAmount: number;
254
256
  };
255
257
  shopProfit: number;
256
- paymentMethod: PaymentMethod;
257
258
  };
258
- paymentMethod: PaymentMethod;
259
259
  orderActionType: OrderAction;
260
260
  orderStatus: RegularOrderStatus;
261
261
  orderAction: OrderAction;
262
262
  preparationTimeMinutes: number;
263
263
  }, {
264
+ createdAt: Date;
264
265
  _id: string | import("mongoose").Types.ObjectId;
265
- orderId: string;
266
+ shopId: string | import("mongoose").Types.ObjectId;
266
267
  user: {
267
- _id: string | import("mongoose").Types.ObjectId;
268
268
  name: string;
269
+ _id: string | import("mongoose").Types.ObjectId;
269
270
  };
270
- createdAt: Date;
271
- shopId: string | import("mongoose").Types.ObjectId;
271
+ paymentMethod: PaymentMethod;
272
+ orderId: string;
272
273
  triggerAt: Date;
273
274
  adjustedFinance: {
275
+ paymentMethod: PaymentMethod;
274
276
  pricing: {
275
277
  deliveryFee: number;
276
- secondaryDeliveryFee: number;
277
278
  riderTips: number;
278
- secondaryRiderTips: number;
279
279
  total: number;
280
+ secondaryDeliveryFee: number;
281
+ secondaryRiderTips: number;
280
282
  secondaryTotal: number;
281
283
  paidAmount: number;
282
284
  secondaryPaidAmount: number;
283
285
  };
284
286
  shopProfit: number;
285
- paymentMethod: PaymentMethod;
286
287
  };
287
- paymentMethod: PaymentMethod;
288
288
  orderActionType: OrderAction;
289
289
  orderStatus: RegularOrderStatus;
290
290
  orderAction: OrderAction;
@@ -21,15 +21,15 @@ export declare const RiderLocationUpdateSocketOutputSchema: z.ZodObject<{
21
21
  }, "strip", z.ZodTypeAny, {
22
22
  latitude: number;
23
23
  longitude: number;
24
- _id: import("mongoose").Types.ObjectId;
25
24
  updatedAt: Date;
25
+ _id: import("mongoose").Types.ObjectId;
26
26
  riderId: import("mongoose").Types.ObjectId;
27
27
  bearing?: number | undefined;
28
28
  }, {
29
29
  latitude: number;
30
30
  longitude: number;
31
- _id: string | import("mongoose").Types.ObjectId;
32
31
  updatedAt: string | Date;
32
+ _id: string | import("mongoose").Types.ObjectId;
33
33
  riderId: string | import("mongoose").Types.ObjectId;
34
34
  bearing?: number | undefined;
35
35
  }>;
@@ -57,15 +57,15 @@ export declare class RiderLocationUpdateSocketEvent extends BaseSocketEvent<type
57
57
  }, "strip", z.ZodTypeAny, {
58
58
  latitude: number;
59
59
  longitude: number;
60
- _id: import("mongoose").Types.ObjectId;
61
60
  updatedAt: Date;
61
+ _id: import("mongoose").Types.ObjectId;
62
62
  riderId: import("mongoose").Types.ObjectId;
63
63
  bearing?: number | undefined;
64
64
  }, {
65
65
  latitude: number;
66
66
  longitude: number;
67
- _id: string | import("mongoose").Types.ObjectId;
68
67
  updatedAt: string | Date;
68
+ _id: string | import("mongoose").Types.ObjectId;
69
69
  riderId: string | import("mongoose").Types.ObjectId;
70
70
  bearing?: number | undefined;
71
71
  }>;
@@ -14,13 +14,13 @@ export declare const TicketAssignSocketOutputSchema: z.ZodObject<{
14
14
  profilePhoto: z.ZodNullable<z.ZodString> | z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
15
15
  }, "strip", z.ZodTypeAny, {
16
16
  type: UserRef;
17
- _id: import("mongoose").Types.ObjectId;
18
17
  name: string;
18
+ _id: import("mongoose").Types.ObjectId;
19
19
  profilePhoto: string | null;
20
20
  }, {
21
21
  type: UserRef;
22
- _id: string | import("mongoose").Types.ObjectId;
23
22
  name: string;
23
+ _id: string | import("mongoose").Types.ObjectId;
24
24
  profilePhoto: string | null;
25
25
  }>;
26
26
  createdAt: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
@@ -41,39 +41,39 @@ export declare const TicketAssignSocketOutputSchema: z.ZodObject<{
41
41
  }, "strip", z.ZodTypeAny, {
42
42
  type: TicketType;
43
43
  status: TicketStatus;
44
- _id: import("mongoose").Types.ObjectId;
45
44
  createdAt: Date;
46
45
  updatedAt: Date;
46
+ _id: import("mongoose").Types.ObjectId;
47
47
  lastMessage: {
48
48
  createdAt: Date;
49
49
  content: string;
50
50
  };
51
+ unreadCount: number;
51
52
  client: {
52
53
  type: UserRef;
53
- _id: import("mongoose").Types.ObjectId;
54
54
  name: string;
55
+ _id: import("mongoose").Types.ObjectId;
55
56
  profilePhoto: string | null;
56
57
  };
57
- unreadCount: number;
58
58
  chatroomId: import("mongoose").Types.ObjectId;
59
59
  orderId?: import("mongoose").Types.ObjectId | undefined;
60
60
  }, {
61
61
  type: TicketType;
62
62
  status: TicketStatus;
63
- _id: string | import("mongoose").Types.ObjectId;
64
63
  createdAt: string | Date;
65
64
  updatedAt: string | Date;
65
+ _id: string | import("mongoose").Types.ObjectId;
66
66
  lastMessage: {
67
67
  createdAt: string | Date;
68
68
  content: string;
69
69
  };
70
+ unreadCount: number;
70
71
  client: {
71
72
  type: UserRef;
72
- _id: string | import("mongoose").Types.ObjectId;
73
73
  name: string;
74
+ _id: string | import("mongoose").Types.ObjectId;
74
75
  profilePhoto: string | null;
75
76
  };
76
- unreadCount: number;
77
77
  chatroomId: string | import("mongoose").Types.ObjectId;
78
78
  orderId?: string | import("mongoose").Types.ObjectId | undefined;
79
79
  }>;
@@ -92,13 +92,13 @@ export declare class TicketAssignEvent extends BaseSocketEvent<typeof TicketAssi
92
92
  profilePhoto: z.ZodNullable<z.ZodString> | z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
93
93
  }, "strip", z.ZodTypeAny, {
94
94
  type: UserRef;
95
- _id: import("mongoose").Types.ObjectId;
96
95
  name: string;
96
+ _id: import("mongoose").Types.ObjectId;
97
97
  profilePhoto: string | null;
98
98
  }, {
99
99
  type: UserRef;
100
- _id: string | import("mongoose").Types.ObjectId;
101
100
  name: string;
101
+ _id: string | import("mongoose").Types.ObjectId;
102
102
  profilePhoto: string | null;
103
103
  }>;
104
104
  createdAt: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
@@ -119,39 +119,39 @@ export declare class TicketAssignEvent extends BaseSocketEvent<typeof TicketAssi
119
119
  }, "strip", z.ZodTypeAny, {
120
120
  type: TicketType;
121
121
  status: TicketStatus;
122
- _id: import("mongoose").Types.ObjectId;
123
122
  createdAt: Date;
124
123
  updatedAt: Date;
124
+ _id: import("mongoose").Types.ObjectId;
125
125
  lastMessage: {
126
126
  createdAt: Date;
127
127
  content: string;
128
128
  };
129
+ unreadCount: number;
129
130
  client: {
130
131
  type: UserRef;
131
- _id: import("mongoose").Types.ObjectId;
132
132
  name: string;
133
+ _id: import("mongoose").Types.ObjectId;
133
134
  profilePhoto: string | null;
134
135
  };
135
- unreadCount: number;
136
136
  chatroomId: import("mongoose").Types.ObjectId;
137
137
  orderId?: import("mongoose").Types.ObjectId | undefined;
138
138
  }, {
139
139
  type: TicketType;
140
140
  status: TicketStatus;
141
- _id: string | import("mongoose").Types.ObjectId;
142
141
  createdAt: string | Date;
143
142
  updatedAt: string | Date;
143
+ _id: string | import("mongoose").Types.ObjectId;
144
144
  lastMessage: {
145
145
  createdAt: string | Date;
146
146
  content: string;
147
147
  };
148
+ unreadCount: number;
148
149
  client: {
149
150
  type: UserRef;
150
- _id: string | import("mongoose").Types.ObjectId;
151
151
  name: string;
152
+ _id: string | import("mongoose").Types.ObjectId;
152
153
  profilePhoto: string | null;
153
154
  };
154
- unreadCount: number;
155
155
  chatroomId: string | import("mongoose").Types.ObjectId;
156
156
  orderId?: string | import("mongoose").Types.ObjectId | undefined;
157
157
  }>;
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.331
25
+ Version: 1.4.332-alpha.0
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.331",
3
+ "version": "1.4.332-alpha.0",
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.4.331",
3
+ "version": "1.4.332-alpha.0",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",