@lyxa.ai/core 1.4.39 → 1.4.40

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.
@@ -16,5 +16,5 @@ export declare class RedisService {
16
16
  getSetMembers(group: string): Promise<string[]>;
17
17
  acquireLock(key: string, ttl?: number): Promise<string | null>;
18
18
  releaseLock(key: string, lockValue: string): Promise<boolean>;
19
- executeWithLock<T>(key: string, ttl: number, callback: () => Promise<T>): Promise<T>;
19
+ executeWithLock<T>(key: string, ttl: number, callback: () => Promise<T>, errorMessage?: string): Promise<T>;
20
20
  }
@@ -104,10 +104,10 @@ let RedisService = class RedisService {
104
104
  const result = await this._redisClient.eval(luaScript, 1, lockKey, lockValue);
105
105
  return result === 1;
106
106
  }
107
- async executeWithLock(key, ttl, callback) {
107
+ async executeWithLock(key, ttl, callback, errorMessage) {
108
108
  const lockValue = await this.acquireLock(key, ttl);
109
109
  if (!lockValue) {
110
- throw new Error('Resource is locked');
110
+ throw new Error(errorMessage || 'Resource is locked');
111
111
  }
112
112
  try {
113
113
  return await callback();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA4B;AAC5B,mCAAiC;AACjC,mCAAoC;AAG7B,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;IACJ,CAAC;IAED,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,eAAe,CAAI,GAAW;QAC1C,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEvD,IAAI,aAAa,IAAI,SAAS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,IAAI,EAAE,CAAC;YACrB,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,GAAW,EAAE,SAAiB;QACtD,MAAM,OAAO,GAAG,QAAQ,GAAG,EAAE,CAAC;QAE9B,MAAM,SAAS,GAAG;;;;;;EAMlB,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAE9E,OAAO,MAAM,KAAK,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAI,GAAW,EAAE,GAAW,EAAE,QAA0B;QACnF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAEnD,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC;YACJ,OAAO,MAAM,QAAQ,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACV,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD,CAAA;AArIY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAqIxB","sourcesContent":["import Redis from 'ioredis';\nimport { Service } from 'typedi';\nimport { randomUUID } from 'crypto';\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>(key: string, ttl: number, callback: () => Promise<T>): Promise<T> {\n\t\tconst lockValue = await this.acquireLock(key, ttl);\n\n\t\tif (!lockValue) {\n\t\t\tthrow new Error('Resource is locked');\n\t\t}\n\n\t\ttry {\n\t\t\treturn await callback();\n\t\t} finally {\n\t\t\tawait this.releaseLock(key, lockValue);\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;AAG7B,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;IACJ,CAAC;IAED,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,eAAe,CAAI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I,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAGhF,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,GAAW,EAAE,SAAiB;QACtD,MAAM,OAAO,GAAG,QAAQ,GAAG,EAAE,CAAC;QAE9B,MAAM,SAAS,GAAG;;;;;;EAMlB,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAE9E,OAAO,MAAM,KAAK,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAI,GAAW,EAAE,GAAW,EAAE,QAA0B,EAAE,YAAqB;QAC1G,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAEnD,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,oBAAoB,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC;YACJ,OAAO,MAAM,QAAQ,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACV,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;CACD,CAAA;AArIY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAqIxB","sourcesContent":["import Redis from 'ioredis';\nimport { Service } from 'typedi';\nimport { randomUUID } from 'crypto';\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>(key: string, ttl: number, callback: () => Promise<T>, errorMessage?: string): Promise<T> {\n\t\tconst lockValue = await this.acquireLock(key, ttl);\n\n\t\tif (!lockValue) {\n\t\t\tthrow new Error(errorMessage || 'Resource is locked');\n\t\t}\n\n\t\ttry {\n\t\t\treturn await callback();\n\t\t} finally {\n\t\t\tawait this.releaseLock(key, lockValue);\n\t\t}\n\t}\n}\n"]}
@@ -5,10 +5,10 @@ interface AuthOptions {
5
5
  autoRefresh?: boolean;
6
6
  }
7
7
  export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
8
+ req: import("http").IncomingMessage;
8
9
  res: import("http").ServerResponse<import("http").IncomingMessage>;
9
10
  tokenType: TokenType | undefined;
10
11
  entity: import("../context").EntityContext | undefined;
11
- req: import("http").IncomingMessage;
12
12
  requestId: string | undefined;
13
13
  usedRefreshToken: boolean | undefined;
14
14
  tokenRenewed: boolean | undefined;
@@ -4,10 +4,10 @@ interface RoleProtectedOptions {
4
4
  allowedRoles: string[];
5
5
  }
6
6
  export declare function createRoleProtectedProcedure(options: RoleProtectedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
7
+ req: import("http").IncomingMessage;
7
8
  res: import("http").ServerResponse<import("http").IncomingMessage>;
8
9
  tokenType: import("../../auth").TokenType | undefined;
9
10
  entity: import("../context").EntityContext | undefined;
10
- req: import("http").IncomingMessage;
11
11
  requestId: string | undefined;
12
12
  usedRefreshToken: boolean | undefined;
13
13
  tokenRenewed: boolean | undefined;
@@ -3,10 +3,10 @@ interface PhoneVerifiedOptions {
3
3
  entityTypes: AuthEntityType[];
4
4
  }
5
5
  export declare function createPhoneVerifiedProcedure(options: PhoneVerifiedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
6
+ req: import("http").IncomingMessage;
6
7
  res: import("http").ServerResponse<import("http").IncomingMessage>;
7
8
  tokenType: import("../../auth").TokenType | undefined;
8
9
  entity: import("../context").EntityContext | undefined;
9
- req: import("http").IncomingMessage;
10
10
  requestId: string | undefined;
11
11
  usedRefreshToken: boolean | undefined;
12
12
  tokenRenewed: boolean | undefined;
@@ -5,10 +5,10 @@ interface AuthOptions {
5
5
  autoRefresh?: boolean;
6
6
  }
7
7
  export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
8
+ req: import("http").IncomingMessage;
8
9
  res: import("http").ServerResponse<import("http").IncomingMessage>;
9
10
  tokenType: TokenType | undefined;
10
11
  entity: import("../context").EntityContext | undefined;
11
- req: import("http").IncomingMessage;
12
12
  requestId: string | undefined;
13
13
  usedRefreshToken: boolean | undefined;
14
14
  tokenRenewed: boolean | undefined;
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.39
25
+ Version: 1.4.40
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.39",
3
+ "version": "1.4.40",
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",
@@ -26,8 +26,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
26
26
  searchFields?: string[] | undefined;
27
27
  } | undefined;
28
28
  sort?: Record<string, 1 | -1> | undefined;
29
- select?: Record<string, 0 | 1> | undefined;
30
29
  populate?: any;
30
+ select?: Record<string, 0 | 1> | undefined;
31
31
  query?: Record<string, any> | undefined;
32
32
  }, {
33
33
  search?: {
@@ -36,8 +36,8 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
36
36
  } | undefined;
37
37
  sort?: Record<string, 1 | -1> | undefined;
38
38
  size?: number | undefined;
39
- select?: Record<string, 0 | 1> | undefined;
40
39
  populate?: any;
40
+ select?: Record<string, 0 | 1> | undefined;
41
41
  query?: Record<string, any> | undefined;
42
42
  page?: number | undefined;
43
43
  }>>;
@@ -736,12 +736,12 @@ export declare const GetByIdInputSchema: z.ZodObject<{
736
736
  populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
737
737
  }, "strip", z.ZodTypeAny, {
738
738
  _id: import("mongoose").Types.ObjectId;
739
- select?: Record<string, 0 | 1> | undefined;
740
739
  populate?: any;
740
+ select?: Record<string, 0 | 1> | undefined;
741
741
  }, {
742
742
  _id: string | import("mongoose").Types.ObjectId;
743
- select?: Record<string, 0 | 1> | undefined;
744
743
  populate?: any;
744
+ select?: Record<string, 0 | 1> | undefined;
745
745
  }>;
746
746
  export type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;
747
747
  export declare const GetProductByIdInputSchema: z.ZodObject<{
@@ -754,12 +754,12 @@ export declare const GetProductByIdInputSchema: z.ZodObject<{
754
754
  _id: import("mongoose").Types.ObjectId;
755
755
  withAttributeHiddenItems: boolean;
756
756
  withAddonsHiddenItems: boolean;
757
- select?: Record<string, 0 | 1> | undefined;
758
757
  populate?: any;
758
+ select?: Record<string, 0 | 1> | undefined;
759
759
  }, {
760
760
  _id: string | import("mongoose").Types.ObjectId;
761
- select?: Record<string, 0 | 1> | undefined;
762
761
  populate?: any;
762
+ select?: Record<string, 0 | 1> | undefined;
763
763
  withAttributeHiddenItems?: boolean | undefined;
764
764
  withAddonsHiddenItems?: boolean | undefined;
765
765
  }>;
@@ -772,14 +772,14 @@ export declare const GetOrderByIdInputSchema: z.ZodObject<{
772
772
  userOrderCompletionScope: z.ZodOptional<z.ZodNativeEnum<typeof UserOrderCompletionScope>>;
773
773
  }, "strip", z.ZodTypeAny, {
774
774
  _id: import("mongoose").Types.ObjectId;
775
- select?: Record<string, 0 | 1> | undefined;
776
775
  populate?: any;
776
+ select?: Record<string, 0 | 1> | undefined;
777
777
  groupByCategories?: boolean | undefined;
778
778
  userOrderCompletionScope?: UserOrderCompletionScope | undefined;
779
779
  }, {
780
780
  _id: string | import("mongoose").Types.ObjectId;
781
- select?: Record<string, 0 | 1> | undefined;
782
781
  populate?: any;
782
+ select?: Record<string, 0 | 1> | undefined;
783
783
  groupByCategories?: boolean | undefined;
784
784
  userOrderCompletionScope?: UserOrderCompletionScope | undefined;
785
785
  }>;
@@ -788,11 +788,11 @@ export declare const GetByTokenInputSchema: z.ZodOptional<z.ZodObject<{
788
788
  select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
789
789
  populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
790
790
  }, "strip", z.ZodTypeAny, {
791
- select?: Record<string, 0 | 1> | undefined;
792
791
  populate?: any;
793
- }, {
794
792
  select?: Record<string, 0 | 1> | undefined;
793
+ }, {
795
794
  populate?: any;
795
+ select?: Record<string, 0 | 1> | undefined;
796
796
  }>>;
797
797
  export type GetByTokenInputDTO = DTO<typeof GetByTokenInputSchema>;
798
798
  export declare const GetOneQuerySchema: z.ZodObject<{
@@ -800,12 +800,12 @@ export declare const GetOneQuerySchema: z.ZodObject<{
800
800
  select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
801
801
  populate: z.ZodOptional<z.ZodUnion<[z.ZodType<any, z.ZodTypeDef, any>, z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">]>>;
802
802
  }, "strip", z.ZodTypeAny, {
803
- select?: Record<string, 0 | 1> | undefined;
804
803
  populate?: any;
804
+ select?: Record<string, 0 | 1> | undefined;
805
805
  query?: Record<string, any> | undefined;
806
806
  }, {
807
- select?: Record<string, 0 | 1> | undefined;
808
807
  populate?: any;
808
+ select?: Record<string, 0 | 1> | undefined;
809
809
  query?: Record<string, any> | undefined;
810
810
  }>;
811
811
  export type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.4.39",
3
+ "version": "1.4.40",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",