@lyxa.ai/core 1.0.348 → 1.0.350
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/socket/index.d.ts +1 -1
- package/dist/libraries/socket/index.js +1 -1
- package/dist/libraries/socket/index.js.map +1 -1
- package/dist/libraries/socket/socket-utils.d.ts +18 -0
- package/dist/libraries/socket/{socket-publisher.js → socket-utils.js} +16 -4
- package/dist/libraries/socket/socket-utils.js.map +1 -0
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/validation/common-validation.d.ts +78 -2
- package/dist/types/utilities/validation/global-validation.d.ts +38 -14
- package/dist/utilities/validation/common-validation.d.ts +78 -2
- package/dist/utilities/validation/global-validation.d.ts +38 -14
- package/package.json +1 -1
- package/dist/libraries/socket/socket-publisher.d.ts +0 -19
- package/dist/libraries/socket/socket-publisher.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './SocketEmitEvent';
|
|
2
|
-
export * from './socket-
|
|
2
|
+
export * from './socket-utils';
|
|
@@ -15,5 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./SocketEmitEvent"), exports);
|
|
18
|
-
__exportStar(require("./socket-
|
|
18
|
+
__exportStar(require("./socket-utils"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/socket/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/socket/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,iDAA+B","sourcesContent":["export * from './SocketEmitEvent';\nexport * from './socket-utils';\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SocketServiceQueue } from '../../utilities/enum';
|
|
2
|
+
export interface InstanceRecipients {
|
|
3
|
+
instanceId: string;
|
|
4
|
+
usersId: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function getInstanceSocketsMap(cacheKeys: string[]): Promise<{
|
|
7
|
+
instanceId: string;
|
|
8
|
+
socketIds: string[];
|
|
9
|
+
}[]>;
|
|
10
|
+
type PublishToSocketsParams<TData> = {
|
|
11
|
+
cacheKeys: string[];
|
|
12
|
+
data: TData;
|
|
13
|
+
socketEmitType: string;
|
|
14
|
+
socketQueue: SocketServiceQueue;
|
|
15
|
+
};
|
|
16
|
+
export declare function publishToSockets<TData>({ cacheKeys, data, socketEmitType, socketQueue: eventId, }: PublishToSocketsParams<TData>): Promise<void>;
|
|
17
|
+
export declare function generateCacheKey(userId: string | number, subscriptionType: string, identifiers: Record<string, any>): string;
|
|
18
|
+
export {};
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstanceSocketsMap = getInstanceSocketsMap;
|
|
4
4
|
exports.publishToSockets = publishToSockets;
|
|
5
|
+
exports.generateCacheKey = generateCacheKey;
|
|
5
6
|
const event_1 = require("../event");
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
6
8
|
const SocketEmitEvent_1 = require("./SocketEmitEvent");
|
|
7
|
-
|
|
9
|
+
const index_1 = require("../../index");
|
|
10
|
+
async function getInstanceSocketsMap(cacheKeys) {
|
|
8
11
|
const instanceMap = {};
|
|
12
|
+
const redis = (0, index_1.getLibraries)().getRedisService();
|
|
9
13
|
for (const cacheKey of cacheKeys) {
|
|
10
14
|
const instanceIds = await redis.redisClient.smembers(`cacheKey:${cacheKey}:instances`);
|
|
11
15
|
for (const instanceId of instanceIds) {
|
|
@@ -20,8 +24,8 @@ async function getInstanceSocketsMap(redis, cacheKeys) {
|
|
|
20
24
|
socketIds: [...socketSet],
|
|
21
25
|
}));
|
|
22
26
|
}
|
|
23
|
-
async function publishToSockets({
|
|
24
|
-
const recipients = await getInstanceSocketsMap(
|
|
27
|
+
async function publishToSockets({ cacheKeys, data, socketEmitType, socketQueue: eventId, }) {
|
|
28
|
+
const recipients = await getInstanceSocketsMap(cacheKeys);
|
|
25
29
|
await Promise.all(recipients.map(({ instanceId, socketIds }) => {
|
|
26
30
|
const payload = {
|
|
27
31
|
data,
|
|
@@ -32,4 +36,12 @@ async function publishToSockets({ redis, cacheKeys, data, socketEmitType, socket
|
|
|
32
36
|
return (0, event_1.publishEvent)(event);
|
|
33
37
|
}));
|
|
34
38
|
}
|
|
35
|
-
|
|
39
|
+
function generateCacheKey(userId, subscriptionType, identifiers) {
|
|
40
|
+
const serializedIdentifiers = Object.entries(identifiers)
|
|
41
|
+
.sort(([keyA], [keyB]) => keyA.localeCompare(keyB))
|
|
42
|
+
.map(([key, value]) => `${key}:${JSON.stringify(value)}`)
|
|
43
|
+
.join('|');
|
|
44
|
+
const serialized = `userId:${userId}|subscriptionType:${subscriptionType}|${serializedIdentifiers}`;
|
|
45
|
+
return (0, crypto_1.createHash)('sha256').update(serialized).digest('hex');
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=socket-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-utils.js","sourceRoot":"/","sources":["libraries/socket/socket-utils.ts"],"names":[],"mappings":";;AAWA,sDAyBC;AAqBD,4CAoBC;AAED,4CAaC;AA5FD,oCAAwC;AACxC,mCAAoC;AACpC,uDAAuE;AAEvE,uCAA2C;AAOpC,KAAK,UAAU,qBAAqB,CAC1C,SAAmB;IAEnB,MAAM,WAAW,GAAgC,EAAE,CAAC;IAEpD,MAAM,KAAK,GAAG,IAAA,oBAAY,GAAE,CAAC,eAAe,EAAE,CAAC;IAE/C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,YAAY,QAAQ,YAAY,CAAC,CAAC;QAEvF,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;gBAAE,WAAW,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;YAElE,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,QAAQ,CACjD,YAAY,QAAQ,aAAa,UAAU,UAAU,CACrD,CAAC;YAEF,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,UAAU;QACV,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC;KACzB,CAAC,CAAC,CAAC;AACL,CAAC;AAqBM,KAAK,UAAU,gBAAgB,CAAQ,EAC7C,SAAS,EACT,IAAI,EACJ,cAAc,EACd,WAAW,EAAE,OAAO,GACW;IAC/B,MAAM,UAAU,GAAG,MAAM,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAE1D,MAAM,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE;QAC5C,MAAM,OAAO,GAA6B;YACzC,IAAI;YACJ,OAAO,EAAE,SAAS;YAClB,cAAc;SACd,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,iCAAe,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAChE,OAAO,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,CAAC,CACF,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAC/B,MAAuB,EACvB,gBAAwB,EACxB,WAAgC;IAEhC,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;SACvD,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;SAClD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;SACxD,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,MAAM,UAAU,GAAG,UAAU,MAAM,qBAAqB,gBAAgB,IAAI,qBAAqB,EAAE,CAAC;IAEpG,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import { publishEvent } from '../event';\nimport { createHash } from 'crypto';\nimport { SocketEmitEvent, SocketEventParams } from './SocketEmitEvent';\nimport { SocketServiceQueue } from '../../utilities/enum';\nimport { getLibraries } from '../../index';\n\nexport interface InstanceRecipients {\n\tinstanceId: string;\n\tusersId: string[];\n}\n\nexport async function getInstanceSocketsMap(\n\tcacheKeys: string[]\n): Promise<{ instanceId: string; socketIds: string[] }[]> {\n\tconst instanceMap: Record<string, Set<string>> = {};\n\n\tconst redis = getLibraries().getRedisService();\n\n\tfor (const cacheKey of cacheKeys) {\n\t\tconst instanceIds = await redis.redisClient.smembers(`cacheKey:${cacheKey}:instances`);\n\n\t\tfor (const instanceId of instanceIds) {\n\t\t\tif (!instanceMap[instanceId]) instanceMap[instanceId] = new Set();\n\n\t\t\tconst socketIds = await redis.redisClient.smembers(\n\t\t\t\t`cacheKey:${cacheKey}:instance:${instanceId}:sockets`\n\t\t\t);\n\n\t\t\tsocketIds.forEach(id => instanceMap[instanceId].add(id));\n\t\t}\n\t}\n\n\treturn Object.entries(instanceMap).map(([instanceId, socketSet]) => ({\n\t\tinstanceId,\n\t\tsocketIds: [...socketSet],\n\t}));\n}\n\ntype PublishToSocketsParams<TData> = {\n\tcacheKeys: string[];\n\tdata: TData;\n\tsocketEmitType: string;\n\tsocketQueue: SocketServiceQueue;\n};\n\n/**\n * Example usage:\n *\n * await publishToSockets({\n * redis,\n * cacheKeys: ['user:123', 'user:456'], // target users\n * data: { message: 'Hello, this is a test!' }, // payload to send\n * socketEmitType: 'notification', // event type frontend listens for\n * socketQueue: SocketServiceQueue.SOCKET, // target socket service queue\n * });\n */\n\nexport async function publishToSockets<TData>({\n\tcacheKeys,\n\tdata,\n\tsocketEmitType,\n\tsocketQueue: eventId,\n}: PublishToSocketsParams<TData>) {\n\tconst recipients = await getInstanceSocketsMap(cacheKeys);\n\n\tawait Promise.all(\n\t\trecipients.map(({ instanceId, socketIds }) => {\n\t\t\tconst payload: SocketEventParams<TData> = {\n\t\t\t\tdata,\n\t\t\t\tsockets: socketIds,\n\t\t\t\tsocketEmitType,\n\t\t\t};\n\n\t\t\tconst event = new SocketEmitEvent(eventId, instanceId, payload);\n\t\t\treturn publishEvent(event);\n\t\t})\n\t);\n}\n\nexport function generateCacheKey(\n\tuserId: string | number,\n\tsubscriptionType: string,\n\tidentifiers: Record<string, any>\n): string {\n\tconst serializedIdentifiers = Object.entries(identifiers)\n\t\t.sort(([keyA], [keyB]) => keyA.localeCompare(keyB))\n\t\t.map(([key, value]) => `${key}:${JSON.stringify(value)}`)\n\t\t.join('|');\n\n\tconst serialized = `userId:${userId}|subscriptionType:${subscriptionType}|${serializedIdentifiers}`;\n\n\treturn createHash('sha256').update(serialized).digest('hex');\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -587,7 +587,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
587
587
|
totalPages: number;
|
|
588
588
|
} | undefined;
|
|
589
589
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
590
|
-
}>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
590
|
+
}>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
591
591
|
success: z.ZodBoolean;
|
|
592
592
|
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
593
593
|
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
@@ -625,7 +625,83 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
625
625
|
totalPages: number;
|
|
626
626
|
} | undefined;
|
|
627
627
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
628
|
-
}>
|
|
628
|
+
}>, any>[k]; } : never, z.baseObjectInputType<{
|
|
629
|
+
success: z.ZodBoolean;
|
|
630
|
+
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
631
|
+
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
632
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
633
|
+
page: z.ZodNumber;
|
|
634
|
+
size: z.ZodNumber;
|
|
635
|
+
totalElements: z.ZodNumber;
|
|
636
|
+
totalPages: z.ZodNumber;
|
|
637
|
+
}, "strip", z.ZodTypeAny, {
|
|
638
|
+
size: number;
|
|
639
|
+
page: number;
|
|
640
|
+
totalElements: number;
|
|
641
|
+
totalPages: number;
|
|
642
|
+
}, {
|
|
643
|
+
size: number;
|
|
644
|
+
page: number;
|
|
645
|
+
totalElements: number;
|
|
646
|
+
totalPages: number;
|
|
647
|
+
}>>;
|
|
648
|
+
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
649
|
+
}, "strip", z.ZodTypeAny, {
|
|
650
|
+
documents: T[];
|
|
651
|
+
metadata?: {
|
|
652
|
+
size: number;
|
|
653
|
+
page: number;
|
|
654
|
+
totalElements: number;
|
|
655
|
+
totalPages: number;
|
|
656
|
+
} | undefined;
|
|
657
|
+
}, {
|
|
658
|
+
documents: T[];
|
|
659
|
+
metadata?: {
|
|
660
|
+
size: number;
|
|
661
|
+
page: number;
|
|
662
|
+
totalElements: number;
|
|
663
|
+
totalPages: number;
|
|
664
|
+
} | undefined;
|
|
665
|
+
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
666
|
+
}> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
|
|
667
|
+
success: z.ZodBoolean;
|
|
668
|
+
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
669
|
+
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
670
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
671
|
+
page: z.ZodNumber;
|
|
672
|
+
size: z.ZodNumber;
|
|
673
|
+
totalElements: z.ZodNumber;
|
|
674
|
+
totalPages: z.ZodNumber;
|
|
675
|
+
}, "strip", z.ZodTypeAny, {
|
|
676
|
+
size: number;
|
|
677
|
+
page: number;
|
|
678
|
+
totalElements: number;
|
|
679
|
+
totalPages: number;
|
|
680
|
+
}, {
|
|
681
|
+
size: number;
|
|
682
|
+
page: number;
|
|
683
|
+
totalElements: number;
|
|
684
|
+
totalPages: number;
|
|
685
|
+
}>>;
|
|
686
|
+
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
687
|
+
}, "strip", z.ZodTypeAny, {
|
|
688
|
+
documents: T[];
|
|
689
|
+
metadata?: {
|
|
690
|
+
size: number;
|
|
691
|
+
page: number;
|
|
692
|
+
totalElements: number;
|
|
693
|
+
totalPages: number;
|
|
694
|
+
} | undefined;
|
|
695
|
+
}, {
|
|
696
|
+
documents: T[];
|
|
697
|
+
metadata?: {
|
|
698
|
+
size: number;
|
|
699
|
+
page: number;
|
|
700
|
+
totalElements: number;
|
|
701
|
+
totalPages: number;
|
|
702
|
+
} | undefined;
|
|
703
|
+
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
704
|
+
}>[k_1]; } : never>;
|
|
629
705
|
export type PaginatedDTO<T> = {
|
|
630
706
|
metadata: DTO<typeof metadataSchema>;
|
|
631
707
|
documents: T[];
|
|
@@ -62,22 +62,34 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
62
62
|
private baseSchema;
|
|
63
63
|
constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
|
|
64
64
|
private createBaseSchema;
|
|
65
|
-
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
65
|
+
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
|
|
66
66
|
getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
67
67
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
68
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<
|
|
68
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
69
69
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
70
|
-
}>
|
|
70
|
+
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
71
71
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
72
|
-
}> extends infer
|
|
72
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
73
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
74
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
75
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
76
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
77
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
78
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
73
79
|
getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
74
80
|
getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
75
81
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
76
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<
|
|
82
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
83
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
84
|
+
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
85
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
86
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
87
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
88
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
77
89
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
78
|
-
}> extends infer
|
|
90
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
79
91
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
80
|
-
}>
|
|
92
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
81
93
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
82
94
|
}, "strict", z.ZodTypeAny, {
|
|
83
95
|
[x: string]: any;
|
|
@@ -100,22 +112,34 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
100
112
|
[x: string]: any;
|
|
101
113
|
}>;
|
|
102
114
|
getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
|
|
103
|
-
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
115
|
+
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
|
|
104
116
|
EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
105
117
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
106
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<
|
|
118
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
107
119
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
108
|
-
}>
|
|
120
|
+
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
109
121
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
110
|
-
}> extends infer
|
|
122
|
+
}> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
123
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
124
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
125
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
126
|
+
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
127
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
128
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
111
129
|
IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
112
130
|
UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
113
131
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
114
|
-
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<
|
|
132
|
+
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
133
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
134
|
+
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
135
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
136
|
+
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
137
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
138
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
115
139
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
116
|
-
}> extends infer
|
|
140
|
+
}> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
117
141
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
118
|
-
}>
|
|
142
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
119
143
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
120
144
|
}, "strict", z.ZodTypeAny, {
|
|
121
145
|
[x: string]: any;
|
|
@@ -587,7 +587,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
587
587
|
totalPages: number;
|
|
588
588
|
} | undefined;
|
|
589
589
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
590
|
-
}>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
590
|
+
}>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
591
591
|
success: z.ZodBoolean;
|
|
592
592
|
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
593
593
|
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
@@ -625,7 +625,83 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
|
|
|
625
625
|
totalPages: number;
|
|
626
626
|
} | undefined;
|
|
627
627
|
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
628
|
-
}>
|
|
628
|
+
}>, any>[k]; } : never, z.baseObjectInputType<{
|
|
629
|
+
success: z.ZodBoolean;
|
|
630
|
+
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
631
|
+
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
632
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
633
|
+
page: z.ZodNumber;
|
|
634
|
+
size: z.ZodNumber;
|
|
635
|
+
totalElements: z.ZodNumber;
|
|
636
|
+
totalPages: z.ZodNumber;
|
|
637
|
+
}, "strip", z.ZodTypeAny, {
|
|
638
|
+
page: number;
|
|
639
|
+
size: number;
|
|
640
|
+
totalElements: number;
|
|
641
|
+
totalPages: number;
|
|
642
|
+
}, {
|
|
643
|
+
page: number;
|
|
644
|
+
size: number;
|
|
645
|
+
totalElements: number;
|
|
646
|
+
totalPages: number;
|
|
647
|
+
}>>;
|
|
648
|
+
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
649
|
+
}, "strip", z.ZodTypeAny, {
|
|
650
|
+
documents: T[];
|
|
651
|
+
metadata?: {
|
|
652
|
+
page: number;
|
|
653
|
+
size: number;
|
|
654
|
+
totalElements: number;
|
|
655
|
+
totalPages: number;
|
|
656
|
+
} | undefined;
|
|
657
|
+
}, {
|
|
658
|
+
documents: T[];
|
|
659
|
+
metadata?: {
|
|
660
|
+
page: number;
|
|
661
|
+
size: number;
|
|
662
|
+
totalElements: number;
|
|
663
|
+
totalPages: number;
|
|
664
|
+
} | undefined;
|
|
665
|
+
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
666
|
+
}> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
|
|
667
|
+
success: z.ZodBoolean;
|
|
668
|
+
message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
669
|
+
data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
670
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
671
|
+
page: z.ZodNumber;
|
|
672
|
+
size: z.ZodNumber;
|
|
673
|
+
totalElements: z.ZodNumber;
|
|
674
|
+
totalPages: z.ZodNumber;
|
|
675
|
+
}, "strip", z.ZodTypeAny, {
|
|
676
|
+
page: number;
|
|
677
|
+
size: number;
|
|
678
|
+
totalElements: number;
|
|
679
|
+
totalPages: number;
|
|
680
|
+
}, {
|
|
681
|
+
page: number;
|
|
682
|
+
size: number;
|
|
683
|
+
totalElements: number;
|
|
684
|
+
totalPages: number;
|
|
685
|
+
}>>;
|
|
686
|
+
documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
|
|
687
|
+
}, "strip", z.ZodTypeAny, {
|
|
688
|
+
documents: T[];
|
|
689
|
+
metadata?: {
|
|
690
|
+
page: number;
|
|
691
|
+
size: number;
|
|
692
|
+
totalElements: number;
|
|
693
|
+
totalPages: number;
|
|
694
|
+
} | undefined;
|
|
695
|
+
}, {
|
|
696
|
+
documents: T[];
|
|
697
|
+
metadata?: {
|
|
698
|
+
page: number;
|
|
699
|
+
size: number;
|
|
700
|
+
totalElements: number;
|
|
701
|
+
totalPages: number;
|
|
702
|
+
} | undefined;
|
|
703
|
+
}>, z.ZodType<T, z.ZodTypeDef, T>]>>;
|
|
704
|
+
}>[k_1]; } : never>;
|
|
629
705
|
export type PaginatedDTO<T> = {
|
|
630
706
|
metadata: DTO<typeof metadataSchema>;
|
|
631
707
|
documents: T[];
|
|
@@ -62,22 +62,34 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
62
62
|
private baseSchema;
|
|
63
63
|
constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
|
|
64
64
|
private createBaseSchema;
|
|
65
|
-
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
65
|
+
getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
|
|
66
66
|
getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
67
67
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
68
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<
|
|
68
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
69
69
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
70
|
-
}>
|
|
70
|
+
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
71
71
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
72
|
-
}> extends infer
|
|
72
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
73
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
74
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
75
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
76
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
77
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
78
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
73
79
|
getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
74
80
|
getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
75
81
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
76
|
-
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<
|
|
82
|
+
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
83
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
84
|
+
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
85
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
86
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
87
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
88
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
77
89
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
78
|
-
}> extends infer
|
|
90
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
79
91
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
80
|
-
}>
|
|
92
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
81
93
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
82
94
|
}, "strict", z.ZodTypeAny, {
|
|
83
95
|
[x: string]: any;
|
|
@@ -100,22 +112,34 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
100
112
|
[x: string]: any;
|
|
101
113
|
}>;
|
|
102
114
|
getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
|
|
103
|
-
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]:
|
|
115
|
+
BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
|
|
104
116
|
EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
105
117
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
106
|
-
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<
|
|
118
|
+
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
107
119
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
108
|
-
}>
|
|
120
|
+
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
109
121
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
110
|
-
}> extends infer
|
|
122
|
+
}> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
123
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
124
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
125
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
126
|
+
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
127
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
128
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
111
129
|
IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
112
130
|
UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
113
131
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
114
|
-
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<
|
|
132
|
+
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
133
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
134
|
+
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
135
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
136
|
+
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
137
|
+
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
138
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
115
139
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
116
|
-
}> extends infer
|
|
140
|
+
}> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
117
141
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
|
|
118
|
-
}>
|
|
142
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
119
143
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
120
144
|
}, "strict", z.ZodTypeAny, {
|
|
121
145
|
[x: string]: any;
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { RedisService } from '../redis';
|
|
2
|
-
import { SocketServiceQueue } from '../../utilities/enum';
|
|
3
|
-
export interface InstanceRecipients {
|
|
4
|
-
instanceId: string;
|
|
5
|
-
usersId: string[];
|
|
6
|
-
}
|
|
7
|
-
export declare function getInstanceSocketsMap(redis: RedisService, cacheKeys: string[]): Promise<{
|
|
8
|
-
instanceId: string;
|
|
9
|
-
socketIds: string[];
|
|
10
|
-
}[]>;
|
|
11
|
-
type PublishToSocketsParams<TData> = {
|
|
12
|
-
redis: RedisService;
|
|
13
|
-
cacheKeys: string[];
|
|
14
|
-
data: TData;
|
|
15
|
-
socketEmitType: string;
|
|
16
|
-
socketQueue: SocketServiceQueue;
|
|
17
|
-
};
|
|
18
|
-
export declare function publishToSockets<TData>({ redis, cacheKeys, data, socketEmitType, socketQueue: eventId, }: PublishToSocketsParams<TData>): Promise<void>;
|
|
19
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"socket-publisher.js","sourceRoot":"/","sources":["libraries/socket/socket-publisher.ts"],"names":[],"mappings":";;AAUA,sDAwBC;AAsBD,4CAqBC;AA7ED,oCAAwC;AACxC,uDAAuE;AAShE,KAAK,UAAU,qBAAqB,CAC1C,KAAmB,EACnB,SAAmB;IAEnB,MAAM,WAAW,GAAgC,EAAE,CAAC;IAEpD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,YAAY,QAAQ,YAAY,CAAC,CAAC;QAEvF,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;gBAAE,WAAW,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;YAElE,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,QAAQ,CACjD,YAAY,QAAQ,aAAa,UAAU,UAAU,CACrD,CAAC;YAEF,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE,UAAU;QACV,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC;KACzB,CAAC,CAAC,CAAC;AACL,CAAC;AAsBM,KAAK,UAAU,gBAAgB,CAAQ,EAC7C,KAAK,EACL,SAAS,EACT,IAAI,EACJ,cAAc,EACd,WAAW,EAAE,OAAO,GACW;IAC/B,MAAM,UAAU,GAAG,MAAM,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAEjE,MAAM,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE;QAC5C,MAAM,OAAO,GAA6B;YACzC,IAAI;YACJ,OAAO,EAAE,SAAS;YAClB,cAAc;SACd,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,iCAAe,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAChE,OAAO,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,CAAC,CACF,CAAC;AACH,CAAC","sourcesContent":["import { publishEvent } from '../event';\nimport { SocketEmitEvent, SocketEventParams } from './SocketEmitEvent';\nimport { RedisService } from '../redis';\nimport { SocketServiceQueue } from '../../utilities/enum';\n\nexport interface InstanceRecipients {\n\tinstanceId: string;\n\tusersId: string[];\n}\n\nexport async function getInstanceSocketsMap(\n\tredis: RedisService,\n\tcacheKeys: string[]\n): Promise<{ instanceId: string; socketIds: string[] }[]> {\n\tconst instanceMap: Record<string, Set<string>> = {};\n\n\tfor (const cacheKey of cacheKeys) {\n\t\tconst instanceIds = await redis.redisClient.smembers(`cacheKey:${cacheKey}:instances`);\n\n\t\tfor (const instanceId of instanceIds) {\n\t\t\tif (!instanceMap[instanceId]) instanceMap[instanceId] = new Set();\n\n\t\t\tconst socketIds = await redis.redisClient.smembers(\n\t\t\t\t`cacheKey:${cacheKey}:instance:${instanceId}:sockets`\n\t\t\t);\n\n\t\t\tsocketIds.forEach(id => instanceMap[instanceId].add(id));\n\t\t}\n\t}\n\n\treturn Object.entries(instanceMap).map(([instanceId, socketSet]) => ({\n\t\tinstanceId,\n\t\tsocketIds: [...socketSet],\n\t}));\n}\n\ntype PublishToSocketsParams<TData> = {\n\tredis: RedisService;\n\tcacheKeys: string[];\n\tdata: TData;\n\tsocketEmitType: string;\n\tsocketQueue: SocketServiceQueue;\n};\n\n/**\n * Example usage:\n *\n * await publishToSockets({\n * redis,\n * cacheKeys: ['user:123', 'user:456'], // target users\n * data: { message: 'Hello, this is a test!' }, // payload to send\n * socketEmitType: 'notification', // event type frontend listens for\n * socketQueue: SocketServiceQueue.SOCKET, // target socket service queue\n * });\n */\n\nexport async function publishToSockets<TData>({\n\tredis,\n\tcacheKeys,\n\tdata,\n\tsocketEmitType,\n\tsocketQueue: eventId,\n}: PublishToSocketsParams<TData>) {\n\tconst recipients = await getInstanceSocketsMap(redis, cacheKeys);\n\n\tawait Promise.all(\n\t\trecipients.map(({ instanceId, socketIds }) => {\n\t\t\tconst payload: SocketEventParams<TData> = {\n\t\t\t\tdata,\n\t\t\t\tsockets: socketIds,\n\t\t\t\tsocketEmitType,\n\t\t\t};\n\n\t\t\tconst event = new SocketEmitEvent(eventId, instanceId, payload);\n\t\t\treturn publishEvent(event);\n\t\t})\n\t);\n}\n"]}
|