drizzle-orm 0.39.2-1177ad8 → 0.39.2-aaa57ff

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 (702) hide show
  1. package/_relations.cjs +328 -0
  2. package/_relations.cjs.map +1 -0
  3. package/_relations.d.cts +215 -0
  4. package/_relations.d.ts +215 -0
  5. package/_relations.js +316 -0
  6. package/_relations.js.map +1 -0
  7. package/alias.cjs.map +1 -1
  8. package/alias.d.cts +3 -3
  9. package/alias.d.ts +3 -3
  10. package/alias.js.map +1 -1
  11. package/aws-data-api/pg/driver.cjs +19 -9
  12. package/aws-data-api/pg/driver.cjs.map +1 -1
  13. package/aws-data-api/pg/driver.d.cts +9 -9
  14. package/aws-data-api/pg/driver.d.ts +9 -9
  15. package/aws-data-api/pg/driver.js +9 -12
  16. package/aws-data-api/pg/driver.js.map +1 -1
  17. package/aws-data-api/pg/migrator.cjs.map +1 -1
  18. package/aws-data-api/pg/migrator.d.cts +2 -1
  19. package/aws-data-api/pg/migrator.d.ts +2 -1
  20. package/aws-data-api/pg/migrator.js.map +1 -1
  21. package/aws-data-api/pg/session.cjs +70 -18
  22. package/aws-data-api/pg/session.cjs.map +1 -1
  23. package/aws-data-api/pg/session.d.cts +16 -21
  24. package/aws-data-api/pg/session.d.ts +16 -21
  25. package/aws-data-api/pg/session.js +70 -18
  26. package/aws-data-api/pg/session.js.map +1 -1
  27. package/better-sqlite3/driver.cjs +12 -5
  28. package/better-sqlite3/driver.cjs.map +1 -1
  29. package/better-sqlite3/driver.d.cts +7 -6
  30. package/better-sqlite3/driver.d.ts +7 -6
  31. package/better-sqlite3/driver.js +12 -8
  32. package/better-sqlite3/driver.js.map +1 -1
  33. package/better-sqlite3/migrator.cjs.map +1 -1
  34. package/better-sqlite3/migrator.d.cts +2 -1
  35. package/better-sqlite3/migrator.d.ts +2 -1
  36. package/better-sqlite3/migrator.js.map +1 -1
  37. package/better-sqlite3/session.cjs +49 -4
  38. package/better-sqlite3/session.cjs.map +1 -1
  39. package/better-sqlite3/session.d.cts +14 -8
  40. package/better-sqlite3/session.d.ts +14 -8
  41. package/better-sqlite3/session.js +49 -4
  42. package/better-sqlite3/session.js.map +1 -1
  43. package/bun-sql/driver.cjs +16 -9
  44. package/bun-sql/driver.cjs.map +1 -1
  45. package/bun-sql/driver.d.cts +7 -6
  46. package/bun-sql/driver.d.ts +7 -6
  47. package/bun-sql/driver.js +6 -12
  48. package/bun-sql/driver.js.map +1 -1
  49. package/bun-sql/migrator.cjs.map +1 -1
  50. package/bun-sql/migrator.d.cts +2 -1
  51. package/bun-sql/migrator.d.ts +2 -1
  52. package/bun-sql/migrator.js.map +1 -1
  53. package/bun-sql/session.cjs +58 -26
  54. package/bun-sql/session.cjs.map +1 -1
  55. package/bun-sql/session.d.cts +16 -20
  56. package/bun-sql/session.d.ts +16 -20
  57. package/bun-sql/session.js +58 -26
  58. package/bun-sql/session.js.map +1 -1
  59. package/bun-sqlite/driver.cjs +22 -5
  60. package/bun-sqlite/driver.cjs.map +1 -1
  61. package/bun-sqlite/driver.d.cts +7 -6
  62. package/bun-sqlite/driver.d.ts +7 -6
  63. package/bun-sqlite/driver.js +12 -8
  64. package/bun-sqlite/driver.js.map +1 -1
  65. package/bun-sqlite/migrator.cjs.map +1 -1
  66. package/bun-sqlite/migrator.d.cts +2 -1
  67. package/bun-sqlite/migrator.d.ts +2 -1
  68. package/bun-sqlite/migrator.js.map +1 -1
  69. package/bun-sqlite/session.cjs +49 -4
  70. package/bun-sqlite/session.cjs.map +1 -1
  71. package/bun-sqlite/session.d.cts +14 -8
  72. package/bun-sqlite/session.d.ts +14 -8
  73. package/bun-sqlite/session.js +49 -4
  74. package/bun-sqlite/session.js.map +1 -1
  75. package/d1/driver.cjs +22 -5
  76. package/d1/driver.cjs.map +1 -1
  77. package/d1/driver.d.cts +3 -2
  78. package/d1/driver.d.ts +3 -2
  79. package/d1/driver.js +12 -8
  80. package/d1/driver.js.map +1 -1
  81. package/d1/migrator.cjs.map +1 -1
  82. package/d1/migrator.d.cts +2 -1
  83. package/d1/migrator.d.ts +2 -1
  84. package/d1/migrator.js.map +1 -1
  85. package/d1/session.cjs +50 -8
  86. package/d1/session.cjs.map +1 -1
  87. package/d1/session.d.cts +15 -8
  88. package/d1/session.d.ts +15 -8
  89. package/d1/session.js +50 -8
  90. package/d1/session.js.map +1 -1
  91. package/durable-sqlite/driver.cjs +16 -5
  92. package/durable-sqlite/driver.cjs.map +1 -1
  93. package/durable-sqlite/driver.d.cts +3 -2
  94. package/durable-sqlite/driver.d.ts +3 -2
  95. package/durable-sqlite/driver.js +6 -8
  96. package/durable-sqlite/driver.js.map +1 -1
  97. package/durable-sqlite/migrator.cjs.map +1 -1
  98. package/durable-sqlite/migrator.d.cts +2 -1
  99. package/durable-sqlite/migrator.d.ts +2 -1
  100. package/durable-sqlite/migrator.js.map +1 -1
  101. package/durable-sqlite/session.cjs +46 -4
  102. package/durable-sqlite/session.cjs.map +1 -1
  103. package/durable-sqlite/session.d.cts +14 -8
  104. package/durable-sqlite/session.d.ts +14 -8
  105. package/durable-sqlite/session.js +46 -4
  106. package/durable-sqlite/session.js.map +1 -1
  107. package/expo-sqlite/driver.cjs +22 -5
  108. package/expo-sqlite/driver.cjs.map +1 -1
  109. package/expo-sqlite/driver.d.cts +3 -2
  110. package/expo-sqlite/driver.d.ts +3 -2
  111. package/expo-sqlite/driver.js +12 -8
  112. package/expo-sqlite/driver.js.map +1 -1
  113. package/expo-sqlite/migrator.cjs.map +1 -1
  114. package/expo-sqlite/migrator.d.cts +3 -2
  115. package/expo-sqlite/migrator.d.ts +3 -2
  116. package/expo-sqlite/migrator.js.map +1 -1
  117. package/expo-sqlite/query.cjs +13 -2
  118. package/expo-sqlite/query.cjs.map +1 -1
  119. package/expo-sqlite/query.d.cts +2 -1
  120. package/expo-sqlite/query.d.ts +2 -1
  121. package/expo-sqlite/query.js +3 -2
  122. package/expo-sqlite/query.js.map +1 -1
  123. package/expo-sqlite/session.cjs +47 -4
  124. package/expo-sqlite/session.cjs.map +1 -1
  125. package/expo-sqlite/session.d.cts +14 -8
  126. package/expo-sqlite/session.d.ts +14 -8
  127. package/expo-sqlite/session.js +47 -4
  128. package/expo-sqlite/session.js.map +1 -1
  129. package/libsql/driver-core.cjs +22 -5
  130. package/libsql/driver-core.cjs.map +1 -1
  131. package/libsql/driver-core.d.cts +2 -1
  132. package/libsql/driver-core.d.ts +2 -1
  133. package/libsql/driver-core.js +12 -8
  134. package/libsql/driver-core.js.map +1 -1
  135. package/libsql/driver.cjs.map +1 -1
  136. package/libsql/driver.d.cts +6 -5
  137. package/libsql/driver.d.ts +6 -5
  138. package/libsql/driver.js.map +1 -1
  139. package/libsql/http/index.cjs.map +1 -1
  140. package/libsql/http/index.d.cts +6 -5
  141. package/libsql/http/index.d.ts +6 -5
  142. package/libsql/http/index.js.map +1 -1
  143. package/libsql/migrator.cjs.map +1 -1
  144. package/libsql/migrator.d.cts +2 -1
  145. package/libsql/migrator.d.ts +2 -1
  146. package/libsql/migrator.js.map +1 -1
  147. package/libsql/node/index.cjs.map +1 -1
  148. package/libsql/node/index.d.cts +6 -5
  149. package/libsql/node/index.d.ts +6 -5
  150. package/libsql/node/index.js.map +1 -1
  151. package/libsql/session.cjs +56 -4
  152. package/libsql/session.cjs.map +1 -1
  153. package/libsql/session.d.cts +15 -9
  154. package/libsql/session.d.ts +15 -9
  155. package/libsql/session.js +56 -4
  156. package/libsql/session.js.map +1 -1
  157. package/libsql/sqlite3/index.cjs.map +1 -1
  158. package/libsql/sqlite3/index.d.cts +6 -5
  159. package/libsql/sqlite3/index.d.ts +6 -5
  160. package/libsql/sqlite3/index.js.map +1 -1
  161. package/libsql/wasm/index.cjs.map +1 -1
  162. package/libsql/wasm/index.d.cts +6 -5
  163. package/libsql/wasm/index.d.ts +6 -5
  164. package/libsql/wasm/index.js.map +1 -1
  165. package/libsql/web/index.cjs.map +1 -1
  166. package/libsql/web/index.d.cts +6 -5
  167. package/libsql/web/index.d.ts +6 -5
  168. package/libsql/web/index.js.map +1 -1
  169. package/libsql/ws/index.cjs.map +1 -1
  170. package/libsql/ws/index.d.cts +6 -5
  171. package/libsql/ws/index.d.ts +6 -5
  172. package/libsql/ws/index.js.map +1 -1
  173. package/mysql-core/db.cjs +30 -6
  174. package/mysql-core/db.cjs.map +1 -1
  175. package/mysql-core/db.d.cts +15 -8
  176. package/mysql-core/db.d.ts +15 -8
  177. package/mysql-core/db.js +29 -5
  178. package/mysql-core/db.js.map +1 -1
  179. package/mysql-core/dialect.cjs +197 -15
  180. package/mysql-core/dialect.cjs.map +1 -1
  181. package/mysql-core/dialect.d.cts +36 -13
  182. package/mysql-core/dialect.d.ts +36 -13
  183. package/mysql-core/dialect.js +196 -22
  184. package/mysql-core/dialect.js.map +1 -1
  185. package/mysql-core/query-builders/_query.cjs +149 -0
  186. package/mysql-core/query-builders/_query.cjs.map +1 -0
  187. package/mysql-core/query-builders/_query.d.cts +44 -0
  188. package/mysql-core/query-builders/_query.d.ts +44 -0
  189. package/mysql-core/query-builders/_query.js +114 -0
  190. package/mysql-core/query-builders/_query.js.map +1 -0
  191. package/mysql-core/query-builders/count.cjs.map +1 -1
  192. package/mysql-core/query-builders/count.d.cts +1 -1
  193. package/mysql-core/query-builders/count.d.ts +1 -1
  194. package/mysql-core/query-builders/count.js.map +1 -1
  195. package/mysql-core/query-builders/query.cjs +18 -31
  196. package/mysql-core/query-builders/query.cjs.map +1 -1
  197. package/mysql-core/query-builders/query.d.cts +8 -10
  198. package/mysql-core/query-builders/query.d.ts +8 -10
  199. package/mysql-core/query-builders/query.js +18 -31
  200. package/mysql-core/query-builders/query.js.map +1 -1
  201. package/mysql-core/session.cjs +3 -2
  202. package/mysql-core/session.cjs.map +1 -1
  203. package/mysql-core/session.d.cts +10 -7
  204. package/mysql-core/session.d.ts +10 -7
  205. package/mysql-core/session.js +3 -2
  206. package/mysql-core/session.js.map +1 -1
  207. package/mysql-proxy/driver.cjs +22 -5
  208. package/mysql-proxy/driver.cjs.map +1 -1
  209. package/mysql-proxy/driver.d.cts +3 -2
  210. package/mysql-proxy/driver.d.ts +3 -2
  211. package/mysql-proxy/driver.js +12 -8
  212. package/mysql-proxy/driver.js.map +1 -1
  213. package/mysql-proxy/migrator.cjs.map +1 -1
  214. package/mysql-proxy/migrator.d.cts +2 -1
  215. package/mysql-proxy/migrator.d.ts +2 -1
  216. package/mysql-proxy/migrator.js.map +1 -1
  217. package/mysql-proxy/session.cjs +27 -2
  218. package/mysql-proxy/session.cjs.map +1 -1
  219. package/mysql-proxy/session.d.cts +13 -8
  220. package/mysql-proxy/session.d.ts +13 -8
  221. package/mysql-proxy/session.js +27 -2
  222. package/mysql-proxy/session.js.map +1 -1
  223. package/mysql2/driver.cjs +24 -7
  224. package/mysql2/driver.cjs.map +1 -1
  225. package/mysql2/driver.d.cts +10 -9
  226. package/mysql2/driver.d.ts +10 -9
  227. package/mysql2/driver.js +14 -10
  228. package/mysql2/driver.js.map +1 -1
  229. package/mysql2/migrator.cjs.map +1 -1
  230. package/mysql2/migrator.d.cts +2 -1
  231. package/mysql2/migrator.d.ts +2 -1
  232. package/mysql2/migrator.js.map +1 -1
  233. package/mysql2/session.cjs +30 -2
  234. package/mysql2/session.cjs.map +1 -1
  235. package/mysql2/session.d.cts +13 -8
  236. package/mysql2/session.d.ts +13 -8
  237. package/mysql2/session.js +30 -2
  238. package/mysql2/session.js.map +1 -1
  239. package/neon-http/driver.cjs +21 -14
  240. package/neon-http/driver.cjs.map +1 -1
  241. package/neon-http/driver.d.cts +10 -11
  242. package/neon-http/driver.d.ts +10 -11
  243. package/neon-http/driver.js +11 -14
  244. package/neon-http/driver.js.map +1 -1
  245. package/neon-http/migrator.cjs.map +1 -1
  246. package/neon-http/migrator.d.cts +2 -1
  247. package/neon-http/migrator.d.ts +2 -1
  248. package/neon-http/migrator.js.map +1 -1
  249. package/neon-http/session.cjs +46 -26
  250. package/neon-http/session.cjs.map +1 -1
  251. package/neon-http/session.d.cts +15 -19
  252. package/neon-http/session.d.ts +15 -19
  253. package/neon-http/session.js +46 -26
  254. package/neon-http/session.js.map +1 -1
  255. package/neon-serverless/driver.cjs +19 -15
  256. package/neon-serverless/driver.cjs.map +1 -1
  257. package/neon-serverless/driver.d.cts +9 -10
  258. package/neon-serverless/driver.d.ts +9 -10
  259. package/neon-serverless/driver.js +9 -18
  260. package/neon-serverless/driver.js.map +1 -1
  261. package/neon-serverless/migrator.cjs.map +1 -1
  262. package/neon-serverless/migrator.d.cts +2 -1
  263. package/neon-serverless/migrator.d.ts +2 -1
  264. package/neon-serverless/migrator.js.map +1 -1
  265. package/neon-serverless/session.cjs +46 -25
  266. package/neon-serverless/session.cjs.map +1 -1
  267. package/neon-serverless/session.d.cts +15 -19
  268. package/neon-serverless/session.d.ts +15 -19
  269. package/neon-serverless/session.js +46 -25
  270. package/neon-serverless/session.js.map +1 -1
  271. package/node-postgres/driver.cjs +14 -15
  272. package/node-postgres/driver.cjs.map +1 -1
  273. package/node-postgres/driver.d.cts +9 -10
  274. package/node-postgres/driver.d.ts +9 -10
  275. package/node-postgres/driver.js +14 -18
  276. package/node-postgres/driver.js.map +1 -1
  277. package/node-postgres/migrator.cjs.map +1 -1
  278. package/node-postgres/migrator.d.cts +2 -1
  279. package/node-postgres/migrator.d.ts +2 -1
  280. package/node-postgres/migrator.js.map +1 -1
  281. package/node-postgres/session.cjs +50 -22
  282. package/node-postgres/session.cjs.map +1 -1
  283. package/node-postgres/session.d.cts +15 -20
  284. package/node-postgres/session.d.ts +15 -20
  285. package/node-postgres/session.js +50 -22
  286. package/node-postgres/session.js.map +1 -1
  287. package/op-sqlite/driver.cjs +22 -5
  288. package/op-sqlite/driver.cjs.map +1 -1
  289. package/op-sqlite/driver.d.cts +3 -2
  290. package/op-sqlite/driver.d.ts +3 -2
  291. package/op-sqlite/driver.js +12 -8
  292. package/op-sqlite/driver.js.map +1 -1
  293. package/op-sqlite/migrator.cjs.map +1 -1
  294. package/op-sqlite/migrator.d.cts +3 -2
  295. package/op-sqlite/migrator.d.ts +3 -2
  296. package/op-sqlite/migrator.js.map +1 -1
  297. package/op-sqlite/session.cjs +47 -4
  298. package/op-sqlite/session.cjs.map +1 -1
  299. package/op-sqlite/session.d.cts +14 -8
  300. package/op-sqlite/session.d.ts +14 -8
  301. package/op-sqlite/session.js +47 -4
  302. package/op-sqlite/session.js.map +1 -1
  303. package/package.json +100 -113
  304. package/pg-core/db.cjs +32 -6
  305. package/pg-core/db.cjs.map +1 -1
  306. package/pg-core/db.d.cts +16 -13
  307. package/pg-core/db.d.ts +16 -13
  308. package/pg-core/db.js +31 -5
  309. package/pg-core/db.js.map +1 -1
  310. package/pg-core/dialect.cjs +173 -488
  311. package/pg-core/dialect.cjs.map +1 -1
  312. package/pg-core/dialect.d.cts +27 -8
  313. package/pg-core/dialect.d.ts +27 -8
  314. package/pg-core/dialect.js +172 -495
  315. package/pg-core/dialect.js.map +1 -1
  316. package/pg-core/query-builders/_query.cjs +155 -0
  317. package/pg-core/query-builders/_query.cjs.map +1 -0
  318. package/pg-core/query-builders/_query.d.cts +47 -0
  319. package/pg-core/query-builders/_query.d.ts +47 -0
  320. package/pg-core/query-builders/_query.js +120 -0
  321. package/pg-core/query-builders/_query.js.map +1 -0
  322. package/pg-core/query-builders/count.cjs.map +1 -1
  323. package/pg-core/query-builders/count.d.cts +1 -1
  324. package/pg-core/query-builders/count.d.ts +1 -1
  325. package/pg-core/query-builders/count.js.map +1 -1
  326. package/pg-core/query-builders/delete.cjs +1 -6
  327. package/pg-core/query-builders/delete.cjs.map +1 -1
  328. package/pg-core/query-builders/delete.d.cts +1 -2
  329. package/pg-core/query-builders/delete.d.ts +1 -2
  330. package/pg-core/query-builders/delete.js +1 -6
  331. package/pg-core/query-builders/delete.js.map +1 -1
  332. package/pg-core/query-builders/insert.cjs +1 -6
  333. package/pg-core/query-builders/insert.cjs.map +1 -1
  334. package/pg-core/query-builders/insert.d.cts +1 -2
  335. package/pg-core/query-builders/insert.d.ts +1 -2
  336. package/pg-core/query-builders/insert.js +1 -6
  337. package/pg-core/query-builders/insert.js.map +1 -1
  338. package/pg-core/query-builders/query.cjs +15 -18
  339. package/pg-core/query-builders/query.cjs.map +1 -1
  340. package/pg-core/query-builders/query.d.cts +6 -6
  341. package/pg-core/query-builders/query.d.ts +6 -6
  342. package/pg-core/query-builders/query.js +15 -18
  343. package/pg-core/query-builders/query.js.map +1 -1
  344. package/pg-core/query-builders/select.cjs +5 -31
  345. package/pg-core/query-builders/select.cjs.map +1 -1
  346. package/pg-core/query-builders/select.d.cts +2 -11
  347. package/pg-core/query-builders/select.d.ts +2 -11
  348. package/pg-core/query-builders/select.js +5 -31
  349. package/pg-core/query-builders/select.js.map +1 -1
  350. package/pg-core/query-builders/select.types.cjs.map +1 -1
  351. package/pg-core/query-builders/select.types.d.cts +0 -7
  352. package/pg-core/query-builders/select.types.d.ts +0 -7
  353. package/pg-core/query-builders/update.cjs +1 -6
  354. package/pg-core/query-builders/update.cjs.map +1 -1
  355. package/pg-core/query-builders/update.d.cts +3 -4
  356. package/pg-core/query-builders/update.d.ts +3 -4
  357. package/pg-core/query-builders/update.js +1 -6
  358. package/pg-core/query-builders/update.js.map +1 -1
  359. package/pg-core/session.cjs +4 -55
  360. package/pg-core/session.cjs.map +1 -1
  361. package/pg-core/session.d.cts +12 -20
  362. package/pg-core/session.d.ts +12 -20
  363. package/pg-core/session.js +5 -56
  364. package/pg-core/session.js.map +1 -1
  365. package/pg-core/utils.cjs +0 -16
  366. package/pg-core/utils.cjs.map +1 -1
  367. package/pg-core/utils.d.cts +4 -8
  368. package/pg-core/utils.d.ts +4 -8
  369. package/pg-core/utils.js +1 -16
  370. package/pg-core/utils.js.map +1 -1
  371. package/pg-proxy/driver.cjs +21 -10
  372. package/pg-proxy/driver.cjs.map +1 -1
  373. package/pg-proxy/driver.d.cts +3 -2
  374. package/pg-proxy/driver.d.ts +3 -2
  375. package/pg-proxy/driver.js +11 -13
  376. package/pg-proxy/driver.js.map +1 -1
  377. package/pg-proxy/migrator.cjs.map +1 -1
  378. package/pg-proxy/migrator.d.cts +2 -1
  379. package/pg-proxy/migrator.d.ts +2 -1
  380. package/pg-proxy/migrator.js.map +1 -1
  381. package/pg-proxy/session.cjs +41 -16
  382. package/pg-proxy/session.cjs.map +1 -1
  383. package/pg-proxy/session.d.cts +15 -19
  384. package/pg-proxy/session.d.ts +15 -19
  385. package/pg-proxy/session.js +41 -16
  386. package/pg-proxy/session.js.map +1 -1
  387. package/pglite/driver.cjs +24 -15
  388. package/pglite/driver.cjs.map +1 -1
  389. package/pglite/driver.d.cts +9 -10
  390. package/pglite/driver.d.ts +9 -10
  391. package/pglite/driver.js +14 -18
  392. package/pglite/driver.js.map +1 -1
  393. package/pglite/migrator.cjs.map +1 -1
  394. package/pglite/migrator.d.cts +2 -1
  395. package/pglite/migrator.d.ts +2 -1
  396. package/pglite/migrator.js.map +1 -1
  397. package/pglite/session.cjs +40 -21
  398. package/pglite/session.cjs.map +1 -1
  399. package/pglite/session.d.cts +15 -19
  400. package/pglite/session.d.ts +15 -19
  401. package/pglite/session.js +40 -21
  402. package/pglite/session.js.map +1 -1
  403. package/planetscale-serverless/driver.cjs +22 -5
  404. package/planetscale-serverless/driver.cjs.map +1 -1
  405. package/planetscale-serverless/driver.d.cts +7 -6
  406. package/planetscale-serverless/driver.d.ts +7 -6
  407. package/planetscale-serverless/driver.js +12 -8
  408. package/planetscale-serverless/driver.js.map +1 -1
  409. package/planetscale-serverless/migrator.cjs.map +1 -1
  410. package/planetscale-serverless/migrator.d.cts +2 -1
  411. package/planetscale-serverless/migrator.d.ts +2 -1
  412. package/planetscale-serverless/migrator.js.map +1 -1
  413. package/planetscale-serverless/session.cjs +45 -5
  414. package/planetscale-serverless/session.cjs.map +1 -1
  415. package/planetscale-serverless/session.d.cts +14 -9
  416. package/planetscale-serverless/session.d.ts +14 -9
  417. package/planetscale-serverless/session.js +45 -5
  418. package/planetscale-serverless/session.js.map +1 -1
  419. package/postgres-js/driver.cjs +6 -9
  420. package/postgres-js/driver.cjs.map +1 -1
  421. package/postgres-js/driver.d.cts +7 -6
  422. package/postgres-js/driver.d.ts +7 -6
  423. package/postgres-js/driver.js +6 -12
  424. package/postgres-js/driver.js.map +1 -1
  425. package/postgres-js/migrator.cjs.map +1 -1
  426. package/postgres-js/migrator.d.cts +2 -1
  427. package/postgres-js/migrator.d.ts +2 -1
  428. package/postgres-js/migrator.js.map +1 -1
  429. package/postgres-js/session.cjs +56 -23
  430. package/postgres-js/session.cjs.map +1 -1
  431. package/postgres-js/session.d.cts +17 -20
  432. package/postgres-js/session.d.ts +17 -20
  433. package/postgres-js/session.js +56 -23
  434. package/postgres-js/session.js.map +1 -1
  435. package/prisma/mysql/driver.cjs +1 -1
  436. package/prisma/mysql/driver.cjs.map +1 -1
  437. package/prisma/mysql/driver.js +1 -1
  438. package/prisma/mysql/driver.js.map +1 -1
  439. package/prisma/mysql/session.cjs +3 -0
  440. package/prisma/mysql/session.cjs.map +1 -1
  441. package/prisma/mysql/session.d.cts +3 -1
  442. package/prisma/mysql/session.d.ts +3 -1
  443. package/prisma/mysql/session.js +3 -0
  444. package/prisma/mysql/session.js.map +1 -1
  445. package/prisma/pg/driver.cjs +1 -1
  446. package/prisma/pg/driver.cjs.map +1 -1
  447. package/prisma/pg/driver.js +1 -1
  448. package/prisma/pg/driver.js.map +1 -1
  449. package/prisma/pg/session.cjs +4 -1
  450. package/prisma/pg/session.cjs.map +1 -1
  451. package/prisma/pg/session.d.cts +3 -1
  452. package/prisma/pg/session.d.ts +3 -1
  453. package/prisma/pg/session.js +4 -1
  454. package/prisma/pg/session.js.map +1 -1
  455. package/prisma/sqlite/driver.cjs +1 -1
  456. package/prisma/sqlite/driver.cjs.map +1 -1
  457. package/prisma/sqlite/driver.js +1 -1
  458. package/prisma/sqlite/driver.js.map +1 -1
  459. package/prisma/sqlite/session.cjs +3 -0
  460. package/prisma/sqlite/session.cjs.map +1 -1
  461. package/prisma/sqlite/session.d.cts +4 -2
  462. package/prisma/sqlite/session.d.ts +4 -2
  463. package/prisma/sqlite/session.js +3 -0
  464. package/prisma/sqlite/session.js.map +1 -1
  465. package/query-builders/query-builder.cjs.map +1 -1
  466. package/query-builders/query-builder.d.cts +1 -2
  467. package/query-builders/query-builder.d.ts +1 -2
  468. package/query-builders/query-builder.js.map +1 -1
  469. package/relations.cjs +596 -245
  470. package/relations.cjs.map +1 -1
  471. package/relations.d.cts +292 -140
  472. package/relations.d.ts +292 -140
  473. package/relations.js +589 -240
  474. package/relations.js.map +1 -1
  475. package/singlestore/driver.cjs +1 -1
  476. package/singlestore/driver.cjs.map +1 -1
  477. package/singlestore/driver.d.cts +1 -1
  478. package/singlestore/driver.d.ts +1 -1
  479. package/singlestore/driver.js +3 -3
  480. package/singlestore/driver.js.map +1 -1
  481. package/singlestore/session.cjs.map +1 -1
  482. package/singlestore/session.d.cts +4 -4
  483. package/singlestore/session.d.ts +4 -4
  484. package/singlestore/session.js.map +1 -1
  485. package/singlestore-core/db.cjs.map +1 -1
  486. package/singlestore-core/db.d.cts +3 -3
  487. package/singlestore-core/db.d.ts +3 -3
  488. package/singlestore-core/db.js.map +1 -1
  489. package/singlestore-core/dialect.cjs +16 -6
  490. package/singlestore-core/dialect.cjs.map +1 -1
  491. package/singlestore-core/dialect.d.cts +6 -6
  492. package/singlestore-core/dialect.d.ts +6 -6
  493. package/singlestore-core/dialect.js +6 -12
  494. package/singlestore-core/dialect.js.map +1 -1
  495. package/singlestore-core/query-builders/query.cjs +12 -2
  496. package/singlestore-core/query-builders/query.cjs.map +1 -1
  497. package/singlestore-core/query-builders/query.d.cts +6 -6
  498. package/singlestore-core/query-builders/query.d.ts +6 -6
  499. package/singlestore-core/query-builders/query.js +2 -4
  500. package/singlestore-core/query-builders/query.js.map +1 -1
  501. package/singlestore-core/session.cjs.map +1 -1
  502. package/singlestore-core/session.d.cts +5 -5
  503. package/singlestore-core/session.d.ts +5 -5
  504. package/singlestore-core/session.js.map +1 -1
  505. package/singlestore-proxy/driver.cjs +1 -1
  506. package/singlestore-proxy/driver.cjs.map +1 -1
  507. package/singlestore-proxy/driver.js +3 -3
  508. package/singlestore-proxy/driver.js.map +1 -1
  509. package/singlestore-proxy/session.cjs.map +1 -1
  510. package/singlestore-proxy/session.d.cts +4 -4
  511. package/singlestore-proxy/session.d.ts +4 -4
  512. package/singlestore-proxy/session.js.map +1 -1
  513. package/sql/expressions/conditions.cjs.map +1 -1
  514. package/sql/expressions/conditions.d.cts +4 -4
  515. package/sql/expressions/conditions.d.ts +4 -4
  516. package/sql/expressions/conditions.js.map +1 -1
  517. package/sql/sql.cjs +21 -7
  518. package/sql/sql.cjs.map +1 -1
  519. package/sql/sql.d.cts +8 -8
  520. package/sql/sql.d.ts +8 -8
  521. package/sql/sql.js +22 -8
  522. package/sql/sql.js.map +1 -1
  523. package/sql-js/driver.cjs +16 -5
  524. package/sql-js/driver.cjs.map +1 -1
  525. package/sql-js/driver.d.cts +3 -2
  526. package/sql-js/driver.d.ts +3 -2
  527. package/sql-js/driver.js +6 -8
  528. package/sql-js/driver.js.map +1 -1
  529. package/sql-js/migrator.cjs.map +1 -1
  530. package/sql-js/migrator.d.cts +2 -1
  531. package/sql-js/migrator.d.ts +2 -1
  532. package/sql-js/migrator.js.map +1 -1
  533. package/sql-js/session.cjs +71 -36
  534. package/sql-js/session.cjs.map +1 -1
  535. package/sql-js/session.d.cts +16 -13
  536. package/sql-js/session.d.ts +16 -13
  537. package/sql-js/session.js +71 -36
  538. package/sql-js/session.js.map +1 -1
  539. package/sqlite-core/db.cjs +39 -12
  540. package/sqlite-core/db.cjs.map +1 -1
  541. package/sqlite-core/db.d.cts +16 -8
  542. package/sqlite-core/db.d.ts +16 -8
  543. package/sqlite-core/db.js +38 -11
  544. package/sqlite-core/db.js.map +1 -1
  545. package/sqlite-core/dialect.cjs +186 -7
  546. package/sqlite-core/dialect.cjs.map +1 -1
  547. package/sqlite-core/dialect.d.cts +31 -9
  548. package/sqlite-core/dialect.d.ts +31 -9
  549. package/sqlite-core/dialect.js +185 -14
  550. package/sqlite-core/dialect.js.map +1 -1
  551. package/sqlite-core/query-builders/_query.cjs +187 -0
  552. package/sqlite-core/query-builders/_query.cjs.map +1 -0
  553. package/sqlite-core/query-builders/_query.d.cts +55 -0
  554. package/sqlite-core/query-builders/_query.d.ts +55 -0
  555. package/sqlite-core/query-builders/_query.js +151 -0
  556. package/sqlite-core/query-builders/_query.js.map +1 -0
  557. package/sqlite-core/query-builders/count.cjs.map +1 -1
  558. package/sqlite-core/query-builders/count.d.cts +1 -1
  559. package/sqlite-core/query-builders/count.d.ts +1 -1
  560. package/sqlite-core/query-builders/count.js.map +1 -1
  561. package/sqlite-core/query-builders/delete.cjs.map +1 -1
  562. package/sqlite-core/query-builders/delete.d.cts +1 -1
  563. package/sqlite-core/query-builders/delete.d.ts +1 -1
  564. package/sqlite-core/query-builders/delete.js.map +1 -1
  565. package/sqlite-core/query-builders/insert.cjs.map +1 -1
  566. package/sqlite-core/query-builders/insert.d.cts +3 -3
  567. package/sqlite-core/query-builders/insert.d.ts +3 -3
  568. package/sqlite-core/query-builders/insert.js.map +1 -1
  569. package/sqlite-core/query-builders/query.cjs +56 -35
  570. package/sqlite-core/query-builders/query.cjs.map +1 -1
  571. package/sqlite-core/query-builders/query.d.cts +18 -17
  572. package/sqlite-core/query-builders/query.d.ts +18 -17
  573. package/sqlite-core/query-builders/query.js +56 -35
  574. package/sqlite-core/query-builders/query.js.map +1 -1
  575. package/sqlite-core/query-builders/select.cjs.map +1 -1
  576. package/sqlite-core/query-builders/select.d.cts +3 -3
  577. package/sqlite-core/query-builders/select.d.ts +3 -3
  578. package/sqlite-core/query-builders/select.js.map +1 -1
  579. package/sqlite-core/query-builders/update.cjs.map +1 -1
  580. package/sqlite-core/query-builders/update.d.cts +3 -3
  581. package/sqlite-core/query-builders/update.d.ts +3 -3
  582. package/sqlite-core/query-builders/update.js.map +1 -1
  583. package/sqlite-core/session.cjs +6 -2
  584. package/sqlite-core/session.cjs.map +1 -1
  585. package/sqlite-core/session.d.cts +15 -7
  586. package/sqlite-core/session.d.ts +15 -7
  587. package/sqlite-core/session.js +6 -2
  588. package/sqlite-core/session.js.map +1 -1
  589. package/sqlite-proxy/driver.cjs +23 -5
  590. package/sqlite-proxy/driver.cjs.map +1 -1
  591. package/sqlite-proxy/driver.d.cts +4 -3
  592. package/sqlite-proxy/driver.d.ts +4 -3
  593. package/sqlite-proxy/driver.js +13 -5
  594. package/sqlite-proxy/driver.js.map +1 -1
  595. package/sqlite-proxy/migrator.cjs.map +1 -1
  596. package/sqlite-proxy/migrator.d.cts +2 -1
  597. package/sqlite-proxy/migrator.d.ts +2 -1
  598. package/sqlite-proxy/migrator.js.map +1 -1
  599. package/sqlite-proxy/session.cjs +50 -6
  600. package/sqlite-proxy/session.cjs.map +1 -1
  601. package/sqlite-proxy/session.d.cts +14 -8
  602. package/sqlite-proxy/session.d.ts +14 -8
  603. package/sqlite-proxy/session.js +50 -6
  604. package/sqlite-proxy/session.js.map +1 -1
  605. package/subquery.cjs +3 -4
  606. package/subquery.cjs.map +1 -1
  607. package/subquery.d.cts +1 -2
  608. package/subquery.d.ts +1 -2
  609. package/subquery.js +3 -4
  610. package/subquery.js.map +1 -1
  611. package/table.cjs.map +1 -1
  612. package/table.d.cts +2 -2
  613. package/table.d.ts +2 -2
  614. package/table.js.map +1 -1
  615. package/tidb-serverless/driver.cjs +22 -5
  616. package/tidb-serverless/driver.cjs.map +1 -1
  617. package/tidb-serverless/driver.d.cts +7 -6
  618. package/tidb-serverless/driver.d.ts +7 -6
  619. package/tidb-serverless/driver.js +12 -8
  620. package/tidb-serverless/driver.js.map +1 -1
  621. package/tidb-serverless/migrator.cjs.map +1 -1
  622. package/tidb-serverless/migrator.d.cts +2 -1
  623. package/tidb-serverless/migrator.d.ts +2 -1
  624. package/tidb-serverless/migrator.js.map +1 -1
  625. package/tidb-serverless/session.cjs +62 -5
  626. package/tidb-serverless/session.cjs.map +1 -1
  627. package/tidb-serverless/session.d.cts +14 -9
  628. package/tidb-serverless/session.d.ts +14 -9
  629. package/tidb-serverless/session.js +62 -5
  630. package/tidb-serverless/session.js.map +1 -1
  631. package/utils.cjs +2 -2
  632. package/utils.cjs.map +1 -1
  633. package/utils.d.cts +3 -3
  634. package/utils.d.ts +3 -3
  635. package/utils.js +2 -2
  636. package/utils.js.map +1 -1
  637. package/vercel-postgres/driver.cjs +24 -15
  638. package/vercel-postgres/driver.cjs.map +1 -1
  639. package/vercel-postgres/driver.d.cts +9 -10
  640. package/vercel-postgres/driver.d.ts +9 -10
  641. package/vercel-postgres/driver.js +14 -18
  642. package/vercel-postgres/driver.js.map +1 -1
  643. package/vercel-postgres/migrator.cjs.map +1 -1
  644. package/vercel-postgres/migrator.d.cts +2 -1
  645. package/vercel-postgres/migrator.d.ts +2 -1
  646. package/vercel-postgres/migrator.js.map +1 -1
  647. package/vercel-postgres/session.cjs +40 -24
  648. package/vercel-postgres/session.cjs.map +1 -1
  649. package/vercel-postgres/session.d.cts +15 -19
  650. package/vercel-postgres/session.d.ts +15 -19
  651. package/vercel-postgres/session.js +40 -24
  652. package/vercel-postgres/session.js.map +1 -1
  653. package/version.cjs +1 -1
  654. package/version.d.cts +1 -1
  655. package/version.d.ts +1 -1
  656. package/version.js +1 -1
  657. package/xata-http/driver.cjs +19 -12
  658. package/xata-http/driver.cjs.map +1 -1
  659. package/xata-http/driver.d.cts +5 -6
  660. package/xata-http/driver.d.ts +5 -6
  661. package/xata-http/driver.js +9 -12
  662. package/xata-http/driver.js.map +1 -1
  663. package/xata-http/migrator.cjs.map +1 -1
  664. package/xata-http/migrator.d.cts +2 -1
  665. package/xata-http/migrator.d.ts +2 -1
  666. package/xata-http/migrator.js.map +1 -1
  667. package/xata-http/session.cjs +36 -22
  668. package/xata-http/session.cjs.map +1 -1
  669. package/xata-http/session.d.cts +15 -19
  670. package/xata-http/session.d.ts +15 -19
  671. package/xata-http/session.js +36 -22
  672. package/xata-http/session.js.map +1 -1
  673. package/cache/core/cache.cjs +0 -47
  674. package/cache/core/cache.cjs.map +0 -1
  675. package/cache/core/cache.d.cts +0 -35
  676. package/cache/core/cache.d.ts +0 -35
  677. package/cache/core/cache.js +0 -22
  678. package/cache/core/cache.js.map +0 -1
  679. package/cache/core/index.cjs +0 -23
  680. package/cache/core/index.cjs.map +0 -1
  681. package/cache/core/index.d.cts +0 -1
  682. package/cache/core/index.d.ts +0 -1
  683. package/cache/core/index.js +0 -2
  684. package/cache/core/index.js.map +0 -1
  685. package/cache/core/types.cjs +0 -17
  686. package/cache/core/types.cjs.map +0 -1
  687. package/cache/core/types.d.cts +0 -22
  688. package/cache/core/types.d.ts +0 -22
  689. package/cache/core/types.js +0 -1
  690. package/cache/core/types.js.map +0 -1
  691. package/cache/upstash/cache.cjs +0 -98
  692. package/cache/upstash/cache.cjs.map +0 -1
  693. package/cache/upstash/cache.d.cts +0 -23
  694. package/cache/upstash/cache.d.ts +0 -23
  695. package/cache/upstash/cache.js +0 -73
  696. package/cache/upstash/cache.js.map +0 -1
  697. package/cache/upstash/index.cjs +0 -23
  698. package/cache/upstash/index.cjs.map +0 -1
  699. package/cache/upstash/index.d.cts +0 -1
  700. package/cache/upstash/index.d.ts +0 -1
  701. package/cache/upstash/index.js +0 -2
  702. package/cache/upstash/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/xata-http/session.ts"],"sourcesContent":["import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';\nimport type { Cache } from '~/cache/core/index.ts';\nimport { NoopCache } from '~/cache/core/index.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { PgDialect } from '~/pg-core/dialect.ts';\nimport { PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered, WithCacheConfig } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport type XataHttpClient = {\n\tsql: SQLPluginResult;\n};\n\nexport interface QueryResults<ArrayMode extends 'json' | 'array'> {\n\trowCount: number;\n\trows: ArrayMode extends 'array' ? any[][] : Record<string, any>[];\n\trowAsArray: ArrayMode extends 'array' ? true : false;\n}\n\nexport class XataHttpPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'XataHttpPreparedQuery';\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tcache: Cache,\n\t\tqueryMetadata: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t} | undefined,\n\t\tcacheConfig: WithCacheConfig | undefined,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper(query, cache, queryMetadata, cacheConfig);\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { fields, client, query, customResultMapper, joinsNotNullableMap } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn this.queryWithCache(query.sql, params, async () => {\n\t\t\t\treturn await client.sql<Record<string, any>>({ statement: query.sql, params });\n\t\t\t});\n\t\t}\n\n\t\tconst { rows, warning } = await this.queryWithCache(query.sql, params, async () => {\n\t\t\treturn await client.sql({ statement: query.sql, params, responseType: 'array' });\n\t\t});\n\n\t\tif (warning) console.warn(warning);\n\n\t\treturn customResultMapper\n\t\t\t? customResultMapper(rows as unknown[][])\n\t\t\t: rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.queryWithCache(this.query.sql, params, async () => {\n\t\t\treturn this.client.sql({ statement: this.query.sql, params, responseType: 'array' });\n\t\t}).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.queryWithCache(this.query.sql, params, async () => {\n\t\t\treturn this.client.sql({ statement: this.query.sql, params });\n\t\t}).then((result) => result.records);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode() {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface XataHttpSessionOptions {\n\tlogger?: Logger;\n\tcache?: Cache;\n}\n\nexport class XataHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends PgSession<\n\t\tXataHttpQueryResultHKT,\n\t\tTFullSchema,\n\t\tTSchema\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'XataHttpSession';\n\n\tprivate logger: Logger;\n\tprivate cache: Cache;\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: XataHttpSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t\tthis.cache = options.cache ?? new NoopCache();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tqueryMetadata?: {\n\t\t\ttype: 'select' | 'update' | 'delete' | 'insert';\n\t\t\ttables: string[];\n\t\t},\n\t\tcacheConfig?: WithCacheConfig,\n\t): PgPreparedQuery<T> {\n\t\treturn new XataHttpPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tthis.cache,\n\t\t\tqueryMetadata,\n\t\t\tcacheConfig,\n\t\t\tfields,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResults<'array'>> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.sql({ statement: query, params, responseType: 'array' });\n\n\t\treturn {\n\t\t\trowCount: result.rows.length,\n\t\t\trows: result.rows,\n\t\t\trowAsArray: true,\n\t\t};\n\t}\n\n\tasync queryObjects(query: string, params: unknown[]): Promise<QueryResults<'json'>> {\n\t\tconst result = await this.client.sql<Record<string, any>>({ statement: query, params });\n\n\t\treturn {\n\t\t\trowCount: result.records.length,\n\t\t\trows: result.records,\n\t\t\trowAsArray: false,\n\t\t};\n\t}\n\n\toverride async transaction<T>(\n\t\t_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_config: PgTransactionConfig = {},\n\t): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport class XataTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends PgTransaction<\n\t\tXataHttpQueryResultHKT,\n\t\tTFullSchema,\n\t\tTSchema\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'XataHttpTransaction';\n\n\toverride async transaction<T>(_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport interface XataH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MAAM;AAClC,UAAM,SAAS,MAAM,KAAK,OAAO,IAAI,EAAE,WAAW,OAAO,QAAQ,cAAc,QAAQ,CAAC;AAExF,WAAO;AAAA,MACN,UAAU,OAAO,KAAK;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EAEA,MAAM,aAAa,OAAe,QAAkD;AACnF,UAAM,SAAS,MAAM,KAAK,OAAO,IAAyB,EAAE,WAAW,OAAO,OAAO,CAAC;AAEtF,WAAO;AAAA,MACN,UAAU,OAAO,QAAQ;AAAA,MACzB,MAAM,OAAO;AAAA,MACb,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EAEA,MAAe,YACd,cAEA,UAA+B,CAAC,GACnB;AACb,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC9D;AACD;AAEO,MAAM,wBACJ,cAKT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,YAAe,cAAqF;AAClH,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC9D;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/xata-http/session.ts"],"sourcesContent":["import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { PgDialect } from '~/pg-core/dialect.ts';\nimport { PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport type XataHttpClient = {\n\tsql: SQLPluginResult;\n};\n\nexport interface QueryResults<ArrayMode extends 'json' | 'array'> {\n\trowCount: number;\n\trows: ArrayMode extends 'array' ? any[][] : Record<string, any>[];\n\trowAsArray: ArrayMode extends 'array' ? true : false;\n}\n\nexport class XataHttpPreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PgPreparedQuery<T>\n{\n\tstatic override readonly [entityKind]: string = 'XataHttpPreparedQuery';\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => T['execute'],\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper(query);\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tif (this.isRqbV2Query) return this.executeRqbV2(placeholderValues);\n\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { fields, client, query, customResultMapper, joinsNotNullableMap } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn await client.sql<Record<string, any>>({ statement: query.sql, params });\n\t\t\t// return { rowCount: result.records.length, rows: result.records, rowAsArray: false };\n\t\t}\n\n\t\tconst { rows, warning } = await client.sql({ statement: query.sql, params, responseType: 'array' });\n\t\tif (warning) console.warn(warning);\n\n\t\treturn customResultMapper\n\t\t\t? (customResultMapper as (rows: unknown[][]) => T['execute'])(rows as unknown[][])\n\t\t\t: rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\tprivate async executeRqbV2(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { client, query, customResultMapper } = this;\n\n\t\tconst { warning, records } = await client.sql<Record<string, any>>({\n\t\t\tstatement: query.sql,\n\t\t\tparams,\n\t\t\tresponseType: 'json',\n\t\t});\n\t\tif (warning) console.warn(warning);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(records);\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.client.sql({ statement: this.query.sql, params, responseType: 'array' }).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.client.sql({ statement: this.query.sql, params }).then((result) => result.records);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode() {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface XataHttpSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class XataHttpSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgSession<\n\tXataHttpQueryResultHKT,\n\tTFullSchema,\n\tTRelations,\n\tTTablesConfig,\n\tTSchema\n> {\n\tstatic override readonly [entityKind]: string = 'XataHttpSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tdialect: PgDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: XataHttpSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new XataHttpPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new XataHttpPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResults<'array'>> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.sql({ statement: query, params, responseType: 'array' });\n\n\t\treturn {\n\t\t\trowCount: result.rows.length,\n\t\t\trows: result.rows,\n\t\t\trowAsArray: true,\n\t\t};\n\t}\n\n\tasync queryObjects(query: string, params: unknown[]): Promise<QueryResults<'json'>> {\n\t\tconst result = await this.client.sql<Record<string, any>>({ statement: query, params });\n\n\t\treturn {\n\t\t\trowCount: result.records.length,\n\t\t\trows: result.records,\n\t\t\trowAsArray: false,\n\t\t};\n\t}\n\n\toverride async transaction<T>(\n\t\t_transaction: (tx: XataTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_config: PgTransactionConfig = {},\n\t): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport class XataTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgTransaction<\n\tXataHttpQueryResultHKT,\n\tTFullSchema,\n\tTRelations,\n\tTTablesConfig,\n\tTSchema\n> {\n\tstatic override readonly [entityKind]: string = 'XataHttpTransaction';\n\n\toverride async transaction<T>(\n\t\t_transaction: (tx: XataTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport interface XataHttpQueryResultHKT extends PgQueryResultHKT {\n\ttype: SQLQueryResult<this['row']>;\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAG9B,SAAS,iBAAiB,iBAAiB;AAE3C,SAAS,wBAAoC;AAC7C,SAAS,oBAAoB;AAYtB,MAAM,8BACJ,gBACT;AAAA,EAGC,YACS,QACR,OACQ,QACA,QACA,wBACA,oBAGA,cACP;AACD,UAAM,KAAK;AAVH;AAEA;AACA;AACA;AACA;AAGA;AAAA,EAGT;AAAA,EAdA,QAA0B,UAAU,IAAY;AAAA,EAgBhD,MAAM,QAAQ,oBAAyD,CAAC,GAA0B;AACjG,QAAI,KAAK;AAAc,aAAO,KAAK,aAAa,iBAAiB;AAEjE,UAAM,SAAS,iBAAiB,KAAK,MAAM,QAAQ,iBAAiB;AAEpE,SAAK,OAAO,SAAS,KAAK,MAAM,KAAK,MAAM;AAE3C,UAAM,EAAE,QAAQ,QAAQ,OAAO,oBAAoB,oBAAoB,IAAI;AAE3E,QAAI,CAAC,UAAU,CAAC,oBAAoB;AACnC,aAAO,MAAM,OAAO,IAAyB,EAAE,WAAW,MAAM,KAAK,OAAO,CAAC;AAAA,IAE9E;AAEA,UAAM,EAAE,MAAM,QAAQ,IAAI,MAAM,OAAO,IAAI,EAAE,WAAW,MAAM,KAAK,QAAQ,cAAc,QAAQ,CAAC;AAClG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defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var cache_exports = {};
20
- __export(cache_exports, {
21
- Cache: () => Cache,
22
- NoopCache: () => NoopCache
23
- });
24
- module.exports = __toCommonJS(cache_exports);
25
- var import_entity = require("../../entity.cjs");
26
- class Cache {
27
- static [import_entity.entityKind] = "Cache";
28
- }
29
- class NoopCache extends Cache {
30
- strategy() {
31
- return "all";
32
- }
33
- static [import_entity.entityKind] = "NoopCache";
34
- async get(_key) {
35
- return void 0;
36
- }
37
- async put(_hashedQuery, _response, _tables, _config) {
38
- }
39
- async onMutate(_params) {
40
- }
41
- }
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- Cache,
45
- NoopCache
46
- });
47
- //# sourceMappingURL=cache.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cache/core/cache.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { Table } from '~/index.ts';\nimport type { CacheConfig } from './types.ts';\n\nexport abstract class Cache {\n\tstatic readonly [entityKind]: string = 'Cache';\n\n\tabstract strategy(): 'explicit' | 'all';\n\n\t/**\n\t * Invoked if we should check cache for cached response\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract get(\n\t\tkey: string,\n\t): Promise<any[] | undefined>;\n\n\t/**\n\t * Invoked if new query should be inserted to cache\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract put(\n\t\thashedQuery: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tconfig?: CacheConfig,\n\t): Promise<void>;\n\n\t/**\n\t * Invoked if insert, update, delete was invoked\n\t * @param tables\n\t */\n\tabstract onMutate(\n\t\tparams: MutationOption,\n\t): Promise<void>;\n}\n\nexport class NoopCache extends Cache {\n\toverride strategy() {\n\t\treturn 'all' as const;\n\t}\n\n\tstatic override readonly [entityKind]: string = 'NoopCache';\n\n\toverride async get(_key: string): Promise<any[] | undefined> {\n\t\treturn undefined;\n\t}\n\toverride async put(\n\t\t_hashedQuery: string,\n\t\t_response: any,\n\t\t_tables: string[],\n\t\t_config?: any,\n\t): Promise<void> {\n\t\t// noop\n\t}\n\toverride async onMutate(_params: MutationOption): Promise<void> {\n\t\t// noop\n\t}\n}\n\nexport type MutationOption = { tags?: string | string[]; tables?: Table<any> | Table<any>[] | string | string[] };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,wBAAU,IAAY;AAgCxC;AAEO,MAAM,kBAAkB,MAAM;AAAA,EAC3B,WAAW;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,QAA0B,wBAAU,IAAY;AAAA,EAEhD,MAAe,IAAI,MAA0C;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,MAAe,IACd,cACA,WACA,SACA,SACgB;AAAA,EAEjB;AAAA,EACA,MAAe,SAAS,SAAwC;AAAA,EAEhE;AACD;","names":[]}
@@ -1,35 +0,0 @@
1
- import { entityKind } from "../../entity.cjs";
2
- import type { Table } from "../../index.cjs";
3
- import type { CacheConfig } from "./types.cjs";
4
- export declare abstract class Cache {
5
- static readonly [entityKind]: string;
6
- abstract strategy(): 'explicit' | 'all';
7
- /**
8
- * Invoked if we should check cache for cached response
9
- * @param sql
10
- * @param tables
11
- */
12
- abstract get(key: string): Promise<any[] | undefined>;
13
- /**
14
- * Invoked if new query should be inserted to cache
15
- * @param sql
16
- * @param tables
17
- */
18
- abstract put(hashedQuery: string, response: any, tables: string[], config?: CacheConfig): Promise<void>;
19
- /**
20
- * Invoked if insert, update, delete was invoked
21
- * @param tables
22
- */
23
- abstract onMutate(params: MutationOption): Promise<void>;
24
- }
25
- export declare class NoopCache extends Cache {
26
- strategy(): "all";
27
- static readonly [entityKind]: string;
28
- get(_key: string): Promise<any[] | undefined>;
29
- put(_hashedQuery: string, _response: any, _tables: string[], _config?: any): Promise<void>;
30
- onMutate(_params: MutationOption): Promise<void>;
31
- }
32
- export type MutationOption = {
33
- tags?: string | string[];
34
- tables?: Table<any> | Table<any>[] | string | string[];
35
- };
@@ -1,35 +0,0 @@
1
- import { entityKind } from "../../entity.js";
2
- import type { Table } from "../../index.js";
3
- import type { CacheConfig } from "./types.js";
4
- export declare abstract class Cache {
5
- static readonly [entityKind]: string;
6
- abstract strategy(): 'explicit' | 'all';
7
- /**
8
- * Invoked if we should check cache for cached response
9
- * @param sql
10
- * @param tables
11
- */
12
- abstract get(key: string): Promise<any[] | undefined>;
13
- /**
14
- * Invoked if new query should be inserted to cache
15
- * @param sql
16
- * @param tables
17
- */
18
- abstract put(hashedQuery: string, response: any, tables: string[], config?: CacheConfig): Promise<void>;
19
- /**
20
- * Invoked if insert, update, delete was invoked
21
- * @param tables
22
- */
23
- abstract onMutate(params: MutationOption): Promise<void>;
24
- }
25
- export declare class NoopCache extends Cache {
26
- strategy(): "all";
27
- static readonly [entityKind]: string;
28
- get(_key: string): Promise<any[] | undefined>;
29
- put(_hashedQuery: string, _response: any, _tables: string[], _config?: any): Promise<void>;
30
- onMutate(_params: MutationOption): Promise<void>;
31
- }
32
- export type MutationOption = {
33
- tags?: string | string[];
34
- tables?: Table<any> | Table<any>[] | string | string[];
35
- };
@@ -1,22 +0,0 @@
1
- import { entityKind } from "../../entity.js";
2
- class Cache {
3
- static [entityKind] = "Cache";
4
- }
5
- class NoopCache extends Cache {
6
- strategy() {
7
- return "all";
8
- }
9
- static [entityKind] = "NoopCache";
10
- async get(_key) {
11
- return void 0;
12
- }
13
- async put(_hashedQuery, _response, _tables, _config) {
14
- }
15
- async onMutate(_params) {
16
- }
17
- }
18
- export {
19
- Cache,
20
- NoopCache
21
- };
22
- //# sourceMappingURL=cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cache/core/cache.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { Table } from '~/index.ts';\nimport type { CacheConfig } from './types.ts';\n\nexport abstract class Cache {\n\tstatic readonly [entityKind]: string = 'Cache';\n\n\tabstract strategy(): 'explicit' | 'all';\n\n\t/**\n\t * Invoked if we should check cache for cached response\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract get(\n\t\tkey: string,\n\t): Promise<any[] | undefined>;\n\n\t/**\n\t * Invoked if new query should be inserted to cache\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract put(\n\t\thashedQuery: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tconfig?: CacheConfig,\n\t): Promise<void>;\n\n\t/**\n\t * Invoked if insert, update, delete was invoked\n\t * @param tables\n\t */\n\tabstract onMutate(\n\t\tparams: MutationOption,\n\t): Promise<void>;\n}\n\nexport class NoopCache extends Cache {\n\toverride strategy() {\n\t\treturn 'all' as const;\n\t}\n\n\tstatic override readonly [entityKind]: string = 'NoopCache';\n\n\toverride async get(_key: string): Promise<any[] | undefined> {\n\t\treturn undefined;\n\t}\n\toverride async put(\n\t\t_hashedQuery: string,\n\t\t_response: any,\n\t\t_tables: string[],\n\t\t_config?: any,\n\t): Promise<void> {\n\t\t// noop\n\t}\n\toverride async onMutate(_params: MutationOption): Promise<void> {\n\t\t// noop\n\t}\n}\n\nexport type MutationOption = { tags?: string | string[]; tables?: Table<any> | Table<any>[] | string | string[] };\n"],"mappings":"AAAA,SAAS,kBAAkB;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,UAAU,IAAY;AAgCxC;AAEO,MAAM,kBAAkB,MAAM;AAAA,EAC3B,WAAW;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,IAAI,MAA0C;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,MAAe,IACd,cACA,WACA,SACA,SACgB;AAAA,EAEjB;AAAA,EACA,MAAe,SAAS,SAAwC;AAAA,EAEhE;AACD;","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 core_exports = {};
17
- module.exports = __toCommonJS(core_exports);
18
- __reExport(core_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/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,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/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -1,17 +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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var types_exports = {};
16
- module.exports = __toCommonJS(types_exports);
17
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/cache/core/types.ts"],"sourcesContent":["export type CacheConfig = {\n\t/**\n\t * expire time, in seconds (a positive integer)\n\t */\n\tex?: number;\n\t/**\n\t * expire time, in milliseconds (a positive integer).\n\t */\n\tpx?: number;\n\t/**\n\t * Unix time at which the key will expire, in seconds (a positive integer).\n\t */\n\texat?: number;\n\t/**\n\t * Unix time at which the key will expire, in milliseconds (a positive integer)\n\t */\n\tpxat?: number;\n\t/**\n\t * Retain the time to live associated with the key.\n\t */\n\tkeepTtl?: boolean;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,22 +0,0 @@
1
- export type CacheConfig = {
2
- /**
3
- * expire time, in seconds (a positive integer)
4
- */
5
- ex?: number;
6
- /**
7
- * expire time, in milliseconds (a positive integer).
8
- */
9
- px?: number;
10
- /**
11
- * Unix time at which the key will expire, in seconds (a positive integer).
12
- */
13
- exat?: number;
14
- /**
15
- * Unix time at which the key will expire, in milliseconds (a positive integer)
16
- */
17
- pxat?: number;
18
- /**
19
- * Retain the time to live associated with the key.
20
- */
21
- keepTtl?: boolean;
22
- };
@@ -1,22 +0,0 @@
1
- export type CacheConfig = {
2
- /**
3
- * expire time, in seconds (a positive integer)
4
- */
5
- ex?: number;
6
- /**
7
- * expire time, in milliseconds (a positive integer).
8
- */
9
- px?: number;
10
- /**
11
- * Unix time at which the key will expire, in seconds (a positive integer).
12
- */
13
- exat?: number;
14
- /**
15
- * Unix time at which the key will expire, in milliseconds (a positive integer)
16
- */
17
- pxat?: number;
18
- /**
19
- * Retain the time to live associated with the key.
20
- */
21
- keepTtl?: boolean;
22
- };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,98 +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 __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var cache_exports = {};
20
- __export(cache_exports, {
21
- UpstashCache: () => UpstashCache,
22
- upstashCache: () => upstashCache
23
- });
24
- module.exports = __toCommonJS(cache_exports);
25
- var import_redis = require("@upstash/redis");
26
- var import_core = require("../core/index.cjs");
27
- var import_entity = require("../../entity.cjs");
28
- var import__ = require("../../index.cjs");
29
- class UpstashCache extends import_core.Cache {
30
- constructor(redis, config, useGlobally) {
31
- super();
32
- this.redis = redis;
33
- this.useGlobally = useGlobally;
34
- this.internalConfig = this.toInternalConfig(config);
35
- }
36
- static [import_entity.entityKind] = "UpstashCache";
37
- internalConfig;
38
- strategy() {
39
- return this.useGlobally ? "all" : "explicit";
40
- }
41
- toInternalConfig(config) {
42
- return config ? {
43
- ex: config.ex,
44
- exat: config.exat,
45
- px: config.px,
46
- pxat: config.pxat,
47
- keepTtl: config.keepTtl
48
- } : void 0;
49
- }
50
- async get(key) {
51
- const res = (await this.redis.get(key)) ?? void 0;
52
- return res;
53
- }
54
- async put(key, response, tables, config) {
55
- await this.redis.set(key, response, config ? this.toInternalConfig(config) : this.internalConfig);
56
- for (const table of tables) {
57
- await this.redis.sadd(table, key);
58
- }
59
- }
60
- async onMutate(params) {
61
- const tagsArray = params.tags ? Array.isArray(params.tags) ? params.tags : [params.tags] : [];
62
- const tablesArray = params.tables ? Array.isArray(params.tables) ? params.tables : [params.tables] : [];
63
- const keysToDelete = /* @__PURE__ */ new Set();
64
- for (const table of tablesArray) {
65
- const tableName = (0, import_entity.is)(table, import__.Table) ? table[import__.OriginalName] : table;
66
- const keys = await this.redis.smembers(tableName);
67
- for (const key of keys)
68
- keysToDelete.add(key);
69
- }
70
- if (keysToDelete.size > 0 || tagsArray.length > 0) {
71
- const pipeline = this.redis.pipeline();
72
- for (const tag of tagsArray) {
73
- pipeline.del(tag);
74
- }
75
- for (const key of keysToDelete) {
76
- pipeline.del(key);
77
- for (const table of tablesArray) {
78
- const tableName = (0, import_entity.is)(table, import__.Table) ? table[import__.OriginalName] : table;
79
- pipeline.srem(tableName, key);
80
- }
81
- }
82
- await pipeline.exec();
83
- }
84
- }
85
- }
86
- function upstashCache({ url, token, config, global = false }) {
87
- const redis = new import_redis.Redis({
88
- url,
89
- token
90
- });
91
- return new UpstashCache(redis, config, global);
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- UpstashCache,
96
- upstashCache
97
- });
98
- //# sourceMappingURL=cache.cjs.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) {\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[], 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;AA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ACf,QAAM,QAAQ,IAAI,mBAAM;AAAA,IACvB;AAAA,IACA;AAAA,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): Promise<any[] | undefined>;
15
- put(key: string, response: any, tables: string[], 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): Promise<any[] | undefined>;
15
- put(key: string, response: any, tables: string[], 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) {
27
- const res = (await this.redis.get(key)) ?? void 0;
28
- return res;
29
- }
30
- async put(key, response, tables, 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) {\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[], 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;AAC/B,UAAM,MAAM,MAAM,KAAK,MAAM,IAAW,GAAG,KAA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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":[]}