drizzle-orm 0.40.0-bbf78ae → 0.40.0-f8a2f3c

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.
Files changed (216) hide show
  1. package/aws-data-api/pg/driver.cjs +1 -5
  2. package/aws-data-api/pg/driver.cjs.map +1 -1
  3. package/aws-data-api/pg/driver.d.cts +0 -1
  4. package/aws-data-api/pg/driver.d.ts +0 -1
  5. package/aws-data-api/pg/driver.js +1 -5
  6. package/aws-data-api/pg/driver.js.map +1 -1
  7. package/aws-data-api/pg/session.cjs +4 -15
  8. package/aws-data-api/pg/session.cjs.map +1 -1
  9. package/aws-data-api/pg/session.d.cts +3 -13
  10. package/aws-data-api/pg/session.d.ts +3 -13
  11. package/aws-data-api/pg/session.js +4 -15
  12. package/aws-data-api/pg/session.js.map +1 -1
  13. package/bun-sql/driver.cjs +1 -5
  14. package/bun-sql/driver.cjs.map +1 -1
  15. package/bun-sql/driver.js +1 -5
  16. package/bun-sql/driver.js.map +1 -1
  17. package/bun-sql/session.cjs +9 -21
  18. package/bun-sql/session.cjs.map +1 -1
  19. package/bun-sql/session.d.cts +3 -12
  20. package/bun-sql/session.d.ts +3 -12
  21. package/bun-sql/session.js +9 -21
  22. package/bun-sql/session.js.map +1 -1
  23. package/neon-http/driver.cjs +2 -9
  24. package/neon-http/driver.cjs.map +1 -1
  25. package/neon-http/driver.d.cts +0 -2
  26. package/neon-http/driver.d.ts +0 -2
  27. package/neon-http/driver.js +2 -9
  28. package/neon-http/driver.js.map +1 -1
  29. package/neon-http/session.cjs +15 -25
  30. package/neon-http/session.cjs.map +1 -1
  31. package/neon-http/session.d.cts +3 -12
  32. package/neon-http/session.d.ts +3 -12
  33. package/neon-http/session.js +15 -25
  34. package/neon-http/session.js.map +1 -1
  35. package/neon-serverless/driver.cjs +2 -9
  36. package/neon-serverless/driver.cjs.map +1 -1
  37. package/neon-serverless/driver.d.cts +0 -2
  38. package/neon-serverless/driver.d.ts +0 -2
  39. package/neon-serverless/driver.js +2 -9
  40. package/neon-serverless/driver.js.map +1 -1
  41. package/neon-serverless/session.cjs +7 -21
  42. package/neon-serverless/session.cjs.map +1 -1
  43. package/neon-serverless/session.d.cts +3 -12
  44. package/neon-serverless/session.d.ts +3 -12
  45. package/neon-serverless/session.js +7 -21
  46. package/neon-serverless/session.js.map +1 -1
  47. package/node-postgres/driver.cjs +2 -9
  48. package/node-postgres/driver.cjs.map +1 -1
  49. package/node-postgres/driver.d.cts +0 -2
  50. package/node-postgres/driver.d.ts +0 -2
  51. package/node-postgres/driver.js +2 -9
  52. package/node-postgres/driver.js.map +1 -1
  53. package/node-postgres/session.cjs +6 -19
  54. package/node-postgres/session.cjs.map +1 -1
  55. package/node-postgres/session.d.cts +3 -13
  56. package/node-postgres/session.d.ts +3 -13
  57. package/node-postgres/session.js +6 -19
  58. package/node-postgres/session.js.map +1 -1
  59. package/package.json +135 -196
  60. package/pg-core/db.cjs +0 -1
  61. package/pg-core/db.cjs.map +1 -1
  62. package/pg-core/db.d.cts +0 -4
  63. package/pg-core/db.d.ts +0 -4
  64. package/pg-core/db.js +0 -1
  65. package/pg-core/db.js.map +1 -1
  66. package/pg-core/query-builders/delete.cjs +1 -6
  67. package/pg-core/query-builders/delete.cjs.map +1 -1
  68. package/pg-core/query-builders/delete.d.cts +1 -2
  69. package/pg-core/query-builders/delete.d.ts +1 -2
  70. package/pg-core/query-builders/delete.js +1 -6
  71. package/pg-core/query-builders/delete.js.map +1 -1
  72. package/pg-core/query-builders/insert.cjs +1 -6
  73. package/pg-core/query-builders/insert.cjs.map +1 -1
  74. package/pg-core/query-builders/insert.d.cts +1 -2
  75. package/pg-core/query-builders/insert.d.ts +1 -2
  76. package/pg-core/query-builders/insert.js +1 -6
  77. package/pg-core/query-builders/insert.js.map +1 -1
  78. package/pg-core/query-builders/select.cjs +5 -31
  79. package/pg-core/query-builders/select.cjs.map +1 -1
  80. package/pg-core/query-builders/select.d.cts +2 -11
  81. package/pg-core/query-builders/select.d.ts +2 -11
  82. package/pg-core/query-builders/select.js +5 -31
  83. package/pg-core/query-builders/select.js.map +1 -1
  84. package/pg-core/query-builders/select.types.cjs.map +1 -1
  85. package/pg-core/query-builders/select.types.d.cts +0 -7
  86. package/pg-core/query-builders/select.types.d.ts +0 -7
  87. package/pg-core/query-builders/update.cjs +1 -6
  88. package/pg-core/query-builders/update.cjs.map +1 -1
  89. package/pg-core/query-builders/update.d.cts +3 -4
  90. package/pg-core/query-builders/update.d.ts +3 -4
  91. package/pg-core/query-builders/update.js +1 -6
  92. package/pg-core/query-builders/update.js.map +1 -1
  93. package/pg-core/session.cjs +1 -58
  94. package/pg-core/session.cjs.map +1 -1
  95. package/pg-core/session.d.cts +3 -14
  96. package/pg-core/session.d.ts +3 -14
  97. package/pg-core/session.js +2 -59
  98. package/pg-core/session.js.map +1 -1
  99. package/pg-core/utils.cjs +0 -16
  100. package/pg-core/utils.cjs.map +1 -1
  101. package/pg-core/utils.d.cts +4 -8
  102. package/pg-core/utils.d.ts +4 -8
  103. package/pg-core/utils.js +1 -16
  104. package/pg-core/utils.js.map +1 -1
  105. package/pg-proxy/driver.cjs +2 -7
  106. package/pg-proxy/driver.cjs.map +1 -1
  107. package/pg-proxy/driver.js +2 -7
  108. package/pg-proxy/driver.js.map +1 -1
  109. package/pg-proxy/session.cjs +5 -15
  110. package/pg-proxy/session.cjs.map +1 -1
  111. package/pg-proxy/session.d.cts +3 -12
  112. package/pg-proxy/session.d.ts +3 -12
  113. package/pg-proxy/session.js +5 -15
  114. package/pg-proxy/session.js.map +1 -1
  115. package/pglite/driver.cjs +2 -9
  116. package/pglite/driver.cjs.map +1 -1
  117. package/pglite/driver.d.cts +0 -2
  118. package/pglite/driver.d.ts +0 -2
  119. package/pglite/driver.js +2 -9
  120. package/pglite/driver.js.map +1 -1
  121. package/pglite/session.cjs +7 -19
  122. package/pglite/session.cjs.map +1 -1
  123. package/pglite/session.d.cts +3 -12
  124. package/pglite/session.d.ts +3 -12
  125. package/pglite/session.js +7 -19
  126. package/pglite/session.js.map +1 -1
  127. package/postgres-js/driver.cjs +1 -5
  128. package/postgres-js/driver.cjs.map +1 -1
  129. package/postgres-js/driver.js +1 -5
  130. package/postgres-js/driver.js.map +1 -1
  131. package/postgres-js/session.cjs +6 -18
  132. package/postgres-js/session.cjs.map +1 -1
  133. package/postgres-js/session.d.cts +3 -12
  134. package/postgres-js/session.d.ts +3 -12
  135. package/postgres-js/session.js +6 -18
  136. package/postgres-js/session.js.map +1 -1
  137. package/prisma/pg/session.cjs +1 -1
  138. package/prisma/pg/session.cjs.map +1 -1
  139. package/prisma/pg/session.js +1 -1
  140. package/prisma/pg/session.js.map +1 -1
  141. package/query-builders/query-builder.cjs.map +1 -1
  142. package/query-builders/query-builder.d.cts +1 -2
  143. package/query-builders/query-builder.d.ts +1 -2
  144. package/query-builders/query-builder.js.map +1 -1
  145. package/sql/sql.cjs +0 -7
  146. package/sql/sql.cjs.map +1 -1
  147. package/sql/sql.js +0 -7
  148. package/sql/sql.js.map +1 -1
  149. package/subquery.cjs +3 -4
  150. package/subquery.cjs.map +1 -1
  151. package/subquery.d.cts +1 -2
  152. package/subquery.d.ts +1 -2
  153. package/subquery.js +3 -4
  154. package/subquery.js.map +1 -1
  155. package/utils.cjs.map +1 -1
  156. package/utils.d.cts +0 -2
  157. package/utils.d.ts +0 -2
  158. package/utils.js.map +1 -1
  159. package/vercel-postgres/driver.cjs +2 -9
  160. package/vercel-postgres/driver.cjs.map +1 -1
  161. package/vercel-postgres/driver.d.cts +0 -2
  162. package/vercel-postgres/driver.d.ts +0 -2
  163. package/vercel-postgres/driver.js +2 -9
  164. package/vercel-postgres/driver.js.map +1 -1
  165. package/vercel-postgres/session.cjs +7 -21
  166. package/vercel-postgres/session.cjs.map +1 -1
  167. package/vercel-postgres/session.d.cts +3 -12
  168. package/vercel-postgres/session.d.ts +3 -12
  169. package/vercel-postgres/session.js +7 -21
  170. package/vercel-postgres/session.js.map +1 -1
  171. package/version.cjs +1 -1
  172. package/version.d.cts +1 -1
  173. package/version.d.ts +1 -1
  174. package/version.js +1 -1
  175. package/xata-http/driver.cjs +2 -7
  176. package/xata-http/driver.cjs.map +1 -1
  177. package/xata-http/driver.d.cts +0 -2
  178. package/xata-http/driver.d.ts +0 -2
  179. package/xata-http/driver.js +2 -7
  180. package/xata-http/driver.js.map +1 -1
  181. package/xata-http/session.cjs +7 -21
  182. package/xata-http/session.cjs.map +1 -1
  183. package/xata-http/session.d.cts +3 -12
  184. package/xata-http/session.d.ts +3 -12
  185. package/xata-http/session.js +7 -21
  186. package/xata-http/session.js.map +1 -1
  187. package/cache/core/cache.cjs +0 -47
  188. package/cache/core/cache.cjs.map +0 -1
  189. package/cache/core/cache.d.cts +0 -35
  190. package/cache/core/cache.d.ts +0 -35
  191. package/cache/core/cache.js +0 -22
  192. package/cache/core/cache.js.map +0 -1
  193. package/cache/core/index.cjs +0 -23
  194. package/cache/core/index.cjs.map +0 -1
  195. package/cache/core/index.d.cts +0 -1
  196. package/cache/core/index.d.ts +0 -1
  197. package/cache/core/index.js +0 -2
  198. package/cache/core/index.js.map +0 -1
  199. package/cache/core/types.cjs +0 -17
  200. package/cache/core/types.cjs.map +0 -1
  201. package/cache/core/types.d.cts +0 -22
  202. package/cache/core/types.d.ts +0 -22
  203. package/cache/core/types.js +0 -1
  204. package/cache/core/types.js.map +0 -1
  205. package/cache/upstash/cache.cjs +0 -98
  206. package/cache/upstash/cache.cjs.map +0 -1
  207. package/cache/upstash/cache.d.cts +0 -23
  208. package/cache/upstash/cache.d.ts +0 -23
  209. package/cache/upstash/cache.js +0 -73
  210. package/cache/upstash/cache.js.map +0 -1
  211. package/cache/upstash/index.cjs +0 -23
  212. package/cache/upstash/index.cjs.map +0 -1
  213. package/cache/upstash/index.d.cts +0 -1
  214. package/cache/upstash/index.d.ts +0 -1
  215. package/cache/upstash/index.js +0 -2
  216. package/cache/upstash/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cache/upstash/cache.ts"],"sourcesContent":["import type { SetCommandOptions } from '@upstash/redis';\nimport { Redis } from '@upstash/redis';\nimport type { MutationOption } from '~/cache/core/index.ts';\nimport { Cache } from '~/cache/core/index.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { OriginalName, Table } from '~/index.ts';\nimport type { CacheConfig } from '../core/types.ts';\n\nexport class UpstashCache extends Cache {\n\tstatic override readonly [entityKind]: string = 'UpstashCache';\n\n\tprivate internalConfig?: SetCommandOptions;\n\n\tconstructor(public redis: Redis, config?: CacheConfig, protected useGlobally?: boolean) {\n\t\tsuper();\n\t\tthis.internalConfig = this.toInternalConfig(config);\n\t}\n\n\tpublic strategy() {\n\t\treturn this.useGlobally ? 'all' : 'explicit';\n\t}\n\n\tprivate toInternalConfig(config?: CacheConfig) {\n\t\treturn config\n\t\t\t? {\n\t\t\t\tex: config.ex,\n\t\t\t\texat: config.exat,\n\t\t\t\tpx: config.px,\n\t\t\t\tpxat: config.pxat,\n\t\t\t\tkeepTtl: config.keepTtl,\n\t\t\t} as SetCommandOptions\n\t\t\t: undefined;\n\t}\n\n\toverride async get(key: string, _tables: string[], _isTag: boolean) {\n\t\tconst res = await this.redis.get<any[]>(key) ?? undefined;\n\t\treturn res;\n\t}\n\n\toverride async put(key: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig) {\n\t\tawait this.redis.set(key, response, config ? this.toInternalConfig(config) : this.internalConfig);\n\t\tfor (const table of tables) {\n\t\t\tawait this.redis.sadd(table, key);\n\t\t}\n\t}\n\n\toverride async onMutate(params: MutationOption) {\n\t\tconst tagsArray = params.tags ? Array.isArray(params.tags) ? params.tags : [params.tags] : [];\n\t\tconst tablesArray = params.tables ? Array.isArray(params.tables) ? params.tables : [params.tables] : [];\n\n\t\tconst keysToDelete = new Set<string>();\n\n\t\tfor (const table of tablesArray) {\n\t\t\tconst tableName = is(table, Table) ? table[OriginalName] : table as string;\n\t\t\tconst keys = await this.redis.smembers(tableName);\n\t\t\tfor (const key of keys) keysToDelete.add(key); // Add to the set\n\t\t}\n\n\t\tif (keysToDelete.size > 0 || tagsArray.length > 0) {\n\t\t\tconst pipeline = this.redis.pipeline();\n\n\t\t\tfor (const tag of tagsArray) {\n\t\t\t\tpipeline.del(tag);\n\t\t\t}\n\n\t\t\tfor (const key of keysToDelete) {\n\t\t\t\tpipeline.del(key);\n\t\t\t\tfor (const table of tablesArray) {\n\t\t\t\t\tconst tableName = is(table, Table) ? table[OriginalName] : table as string;\n\t\t\t\t\tpipeline.srem(tableName, key);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait pipeline.exec();\n\t\t}\n\t}\n}\n\nexport function upstashCache(\n\t{ url, token, config, global = false }: { url: string; token: string; config?: CacheConfig; global?: boolean },\n): UpstashCache {\n\tconst redis = new Redis({\n\t\turl,\n\t\ttoken,\n\t});\n\n\treturn new UpstashCache(redis, config, global);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAsB;AAEtB,kBAAsB;AACtB,oBAA+B;AAC/B,eAAoC;AAG7B,MAAM,qBAAqB,kBAAM;AAAA,EAKvC,YAAmB,OAAc,QAAgC,aAAuB;AACvF,UAAM;AADY;AAA8C;AAEhE,SAAK,iBAAiB,KAAK,iBAAiB,MAAM;AAAA,EACnD;AAAA,EAPA,QAA0B,wBAAU,IAAY;AAAA,EAExC;AAAA,EAOD,WAAW;AACjB,WAAO,KAAK,cAAc,QAAQ;AAAA,EACnC;AAAA,EAEQ,iBAAiB,QAAsB;AAC9C,WAAO,SACJ;AAAA,MACD,IAAI,OAAO;AAAA,MACX,MAAM,OAAO;AAAA,MACb,IAAI,OAAO;AAAA,MACX,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,IACjB,IACE;AAAA,EACJ;AAAA,EAEA,MAAe,IAAI,KAAa,SAAmB,QAAiB;AACnE,UAAM,MAAM,MAAM,KAAK,MAAM,IAAW,GAAG,KAAK;AAChD,WAAO;A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EACD,CAAC;AAED,SAAO,IAAI,aAAa,OAAO,QAAQ,MAAM;AAC9C;","names":[]}
@@ -1,23 +0,0 @@
1
- import { Redis } from '@upstash/redis';
2
- import type { MutationOption } from "../core/index.cjs";
3
- import { Cache } from "../core/index.cjs";
4
- import { entityKind } from "../../entity.cjs";
5
- import type { CacheConfig } from "../core/types.cjs";
6
- export declare class UpstashCache extends Cache {
7
- redis: Redis;
8
- protected useGlobally?: boolean | undefined;
9
- static readonly [entityKind]: string;
10
- private internalConfig?;
11
- constructor(redis: Redis, config?: CacheConfig, useGlobally?: boolean | undefined);
12
- strategy(): "all" | "explicit";
13
- private toInternalConfig;
14
- get(key: string, _tables: string[], _isTag: boolean): Promise<any[] | undefined>;
15
- put(key: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig): Promise<void>;
16
- onMutate(params: MutationOption): Promise<void>;
17
- }
18
- export declare function upstashCache({ url, token, config, global }: {
19
- url: string;
20
- token: string;
21
- config?: CacheConfig;
22
- global?: boolean;
23
- }): UpstashCache;
@@ -1,23 +0,0 @@
1
- import { Redis } from '@upstash/redis';
2
- import type { MutationOption } from "../core/index.js";
3
- import { Cache } from "../core/index.js";
4
- import { entityKind } from "../../entity.js";
5
- import type { CacheConfig } from "../core/types.js";
6
- export declare class UpstashCache extends Cache {
7
- redis: Redis;
8
- protected useGlobally?: boolean | undefined;
9
- static readonly [entityKind]: string;
10
- private internalConfig?;
11
- constructor(redis: Redis, config?: CacheConfig, useGlobally?: boolean | undefined);
12
- strategy(): "all" | "explicit";
13
- private toInternalConfig;
14
- get(key: string, _tables: string[], _isTag: boolean): Promise<any[] | undefined>;
15
- put(key: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig): Promise<void>;
16
- onMutate(params: MutationOption): Promise<void>;
17
- }
18
- export declare function upstashCache({ url, token, config, global }: {
19
- url: string;
20
- token: string;
21
- config?: CacheConfig;
22
- global?: boolean;
23
- }): UpstashCache;
@@ -1,73 +0,0 @@
1
- import { Redis } from "@upstash/redis";
2
- import { Cache } from "../core/index.js";
3
- import { entityKind, is } from "../../entity.js";
4
- import { OriginalName, Table } from "../../index.js";
5
- class UpstashCache extends Cache {
6
- constructor(redis, config, useGlobally) {
7
- super();
8
- this.redis = redis;
9
- this.useGlobally = useGlobally;
10
- this.internalConfig = this.toInternalConfig(config);
11
- }
12
- static [entityKind] = "UpstashCache";
13
- internalConfig;
14
- strategy() {
15
- return this.useGlobally ? "all" : "explicit";
16
- }
17
- toInternalConfig(config) {
18
- return config ? {
19
- ex: config.ex,
20
- exat: config.exat,
21
- px: config.px,
22
- pxat: config.pxat,
23
- keepTtl: config.keepTtl
24
- } : void 0;
25
- }
26
- async get(key, _tables, _isTag) {
27
- const res = (await this.redis.get(key)) ?? void 0;
28
- return res;
29
- }
30
- async put(key, response, tables, isTag, config) {
31
- await this.redis.set(key, response, config ? this.toInternalConfig(config) : this.internalConfig);
32
- for (const table of tables) {
33
- await this.redis.sadd(table, key);
34
- }
35
- }
36
- async onMutate(params) {
37
- const tagsArray = params.tags ? Array.isArray(params.tags) ? params.tags : [params.tags] : [];
38
- const tablesArray = params.tables ? Array.isArray(params.tables) ? params.tables : [params.tables] : [];
39
- const keysToDelete = /* @__PURE__ */ new Set();
40
- for (const table of tablesArray) {
41
- const tableName = is(table, Table) ? table[OriginalName] : table;
42
- const keys = await this.redis.smembers(tableName);
43
- for (const key of keys)
44
- keysToDelete.add(key);
45
- }
46
- if (keysToDelete.size > 0 || tagsArray.length > 0) {
47
- const pipeline = this.redis.pipeline();
48
- for (const tag of tagsArray) {
49
- pipeline.del(tag);
50
- }
51
- for (const key of keysToDelete) {
52
- pipeline.del(key);
53
- for (const table of tablesArray) {
54
- const tableName = is(table, Table) ? table[OriginalName] : table;
55
- pipeline.srem(tableName, key);
56
- }
57
- }
58
- await pipeline.exec();
59
- }
60
- }
61
- }
62
- function upstashCache({ url, token, config, global = false }) {
63
- const redis = new Redis({
64
- url,
65
- token
66
- });
67
- return new UpstashCache(redis, config, global);
68
- }
69
- export {
70
- UpstashCache,
71
- upstashCache
72
- };
73
- //# sourceMappingURL=cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cache/upstash/cache.ts"],"sourcesContent":["import type { SetCommandOptions } from '@upstash/redis';\nimport { Redis } from '@upstash/redis';\nimport type { MutationOption } from '~/cache/core/index.ts';\nimport { Cache } from '~/cache/core/index.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport { OriginalName, Table } from '~/index.ts';\nimport type { CacheConfig } from '../core/types.ts';\n\nexport class UpstashCache extends Cache {\n\tstatic override readonly [entityKind]: string = 'UpstashCache';\n\n\tprivate internalConfig?: SetCommandOptions;\n\n\tconstructor(public redis: Redis, config?: CacheConfig, protected useGlobally?: boolean) {\n\t\tsuper();\n\t\tthis.internalConfig = this.toInternalConfig(config);\n\t}\n\n\tpublic strategy() {\n\t\treturn this.useGlobally ? 'all' : 'explicit';\n\t}\n\n\tprivate toInternalConfig(config?: CacheConfig) {\n\t\treturn config\n\t\t\t? {\n\t\t\t\tex: config.ex,\n\t\t\t\texat: config.exat,\n\t\t\t\tpx: config.px,\n\t\t\t\tpxat: config.pxat,\n\t\t\t\tkeepTtl: config.keepTtl,\n\t\t\t} as SetCommandOptions\n\t\t\t: undefined;\n\t}\n\n\toverride async get(key: string, _tables: string[], _isTag: boolean) {\n\t\tconst res = await this.redis.get<any[]>(key) ?? undefined;\n\t\treturn res;\n\t}\n\n\toverride async put(key: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig) {\n\t\tawait this.redis.set(key, response, config ? this.toInternalConfig(config) : this.internalConfig);\n\t\tfor (const table of tables) {\n\t\t\tawait this.redis.sadd(table, key);\n\t\t}\n\t}\n\n\toverride async onMutate(params: MutationOption) {\n\t\tconst tagsArray = params.tags ? Array.isArray(params.tags) ? params.tags : [params.tags] : [];\n\t\tconst tablesArray = params.tables ? Array.isArray(params.tables) ? params.tables : [params.tables] : [];\n\n\t\tconst keysToDelete = new Set<string>();\n\n\t\tfor (const table of tablesArray) {\n\t\t\tconst tableName = is(table, Table) ? table[OriginalName] : table as string;\n\t\t\tconst keys = await this.redis.smembers(tableName);\n\t\t\tfor (const key of keys) keysToDelete.add(key); // Add to the set\n\t\t}\n\n\t\tif (keysToDelete.size > 0 || tagsArray.length > 0) {\n\t\t\tconst pipeline = this.redis.pipeline();\n\n\t\t\tfor (const tag of tagsArray) {\n\t\t\t\tpipeline.del(tag);\n\t\t\t}\n\n\t\t\tfor (const key of keysToDelete) {\n\t\t\t\tpipeline.del(key);\n\t\t\t\tfor (const table of tablesArray) {\n\t\t\t\t\tconst tableName = is(table, Table) ? table[OriginalName] : table as string;\n\t\t\t\t\tpipeline.srem(tableName, key);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait pipeline.exec();\n\t\t}\n\t}\n}\n\nexport function upstashCache(\n\t{ url, token, config, global = false }: { url: string; token: string; config?: CacheConfig; global?: boolean },\n): UpstashCache {\n\tconst redis = new Redis({\n\t\turl,\n\t\ttoken,\n\t});\n\n\treturn new UpstashCache(redis, config, global);\n}\n"],"mappings":"AACA,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,YAAY,UAAU;AAC/B,SAAS,cAAc,aAAa;AAG7B,MAAM,qBAAqB,MAAM;AAAA,EAKvC,YAAmB,OAAc,QAAgC,aAAuB;AACvF,UAAM;AADY;AAA8C;AAEhE,SAAK,iBAAiB,KAAK,iBAAiB,MAAM;AAAA,EACnD;AAAA,EAPA,QAA0B,UAAU,IAAY;AAAA,EAExC;AAAA,EAOD,WAAW;AACjB,WAAO,KAAK,cAAc,QAAQ;AAAA,EACnC;AAAA,EAEQ,iBAAiB,QAAsB;AAC9C,WAAO,SACJ;AAAA,MACD,IAAI,OAAO;AAAA,MACX,MAAM,OAAO;AAAA,MACb,IAAI,OAAO;AAAA,MACX,MAAM,OAAO;AAAA,MACb,SAAS,OAAO;AAAA,IACjB,IACE;AAAA,EACJ;AAAA,EAEA,MAAe,IAAI,KAAa,SAAmB,QA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ACtB;AACf,QAAM,QAAQ,IAAI,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,EACD,CAAC;AAED,SAAO,IAAI,aAAa,OAAO,QAAQ,MAAM;AAC9C;","names":[]}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var upstash_exports = {};
17
- module.exports = __toCommonJS(upstash_exports);
18
- __reExport(upstash_exports, require("./cache.cjs"), module.exports);
19
- // Annotate the CommonJS export names for ESM import in node:
20
- 0 && (module.exports = {
21
- ...require("./cache.cjs")
22
- });
23
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cache/upstash/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,uBAAd;","names":[]}
@@ -1 +0,0 @@
1
- export * from "./cache.cjs";
@@ -1 +0,0 @@
1
- export * from "./cache.js";
@@ -1,2 +0,0 @@
1
- export * from "./cache.js";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cache/upstash/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":"AAAA,cAAc;","names":[]}