@lyxa.ai/core 1.3.80 → 1.3.81
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.
|
@@ -2,3 +2,4 @@ import { AuthEntityType } from '../../auth';
|
|
|
2
2
|
export declare function setUserOnline(userId: string, type: AuthEntityType, timestamp?: number): Promise<void>;
|
|
3
3
|
export declare function setUserOffline(userId: string, type: AuthEntityType): Promise<void>;
|
|
4
4
|
export declare function getOnlineUsers(type: AuthEntityType, page?: number, pageSize?: number): Promise<string[]>;
|
|
5
|
+
export declare function isUserOnline(userId: string, type: AuthEntityType): Promise<boolean>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setUserOnline = setUserOnline;
|
|
4
4
|
exports.setUserOffline = setUserOffline;
|
|
5
5
|
exports.getOnlineUsers = getOnlineUsers;
|
|
6
|
+
exports.isUserOnline = isUserOnline;
|
|
6
7
|
const __1 = require("../../..");
|
|
7
8
|
const keys_1 = require("./keys");
|
|
8
9
|
async function setUserOnline(userId, type, timestamp = Date.now()) {
|
|
@@ -20,4 +21,9 @@ async function getOnlineUsers(type, page = 1, pageSize = 100) {
|
|
|
20
21
|
const end = start + pageSize - 1;
|
|
21
22
|
return await redis.zrange(zsetKey, start, end);
|
|
22
23
|
}
|
|
24
|
+
async function isUserOnline(userId, type) {
|
|
25
|
+
const redis = (0, __1.getLibraries)().getRedisService().redisClient;
|
|
26
|
+
const score = await redis.zscore((0, keys_1.kOnlineEntities)(type), userId);
|
|
27
|
+
return score !== null;
|
|
28
|
+
}
|
|
23
29
|
//# sourceMappingURL=presence.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.js","sourceRoot":"/","sources":["libraries/socket/connections/presence.ts"],"names":[],"mappings":";;AAQA,sCAGC;AAKD,wCAGC;AAKD,wCAUC;
|
|
1
|
+
{"version":3,"file":"presence.js","sourceRoot":"/","sources":["libraries/socket/conn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M,KAAK,CAAC,MAAM,CAAC,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAChE,OAAO,KAAK,KAAK,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { getLibraries } from '../../..';\nimport { AuthEntityType } from '../../auth';\nimport { kOnlineEntities } from './keys';\nimport type { Redis } from 'ioredis';\n\n/**\n * Add or update a user as online in the type-based ZSET.\n */\nexport async function setUserOnline(userId: string, type: AuthEntityType, timestamp: number = Date.now()) {\n\tconst redis = getLibraries().getRedisService().redisClient as Redis;\n\tawait redis.zadd(kOnlineEntities(type), timestamp, userId);\n}\n\n/**\n * Remove a user from the type-based online ZSET (on disconnect).\n */\nexport async function setUserOffline(userId: string, type: AuthEntityType) {\n\tconst redis = getLibraries().getRedisService().redisClient as Redis;\n\tawait redis.zrem(kOnlineEntities(type), userId);\n}\n\n/**\n * Paginate online users for a given entity type (deep pagination, scalable).\n */\nexport async function getOnlineUsers(\n\ttype: AuthEntityType,\n\tpage: number = 1,\n\tpageSize: number = 100\n): Promise<string[]> {\n\tconst redis = getLibraries().getRedisService().redisClient as Redis;\n\tconst zsetKey = kOnlineEntities(type);\n\tconst start = (page - 1) * pageSize;\n\tconst end = start + pageSize - 1;\n\treturn await redis.zrange(zsetKey, start, end);\n}\n\nexport async function isUserOnline(userId: string, type: AuthEntityType): Promise<boolean> {\n\tconst redis = getLibraries().getRedisService().redisClient as Redis;\n\tconst score = await redis.zscore(kOnlineEntities(type), userId);\n\treturn score !== null;\n}\n\n/**\n * Example usage:\n *\n * import { getConnectedEntityByType } from './type-queries';\n *\n * // For entity type 'user', get page 2, 100 per page:\n * const users = await getConnectedEntityByType('user', 2, 100);\n */\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED