drizzle-orm 1.0.0-beta.1-199e5ec → 1.0.0-beta.1-388a474

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 (674) hide show
  1. package/aws-data-api/pg/driver.cjs +6 -1
  2. package/aws-data-api/pg/driver.cjs.map +1 -1
  3. package/aws-data-api/pg/driver.d.cts +1 -0
  4. package/aws-data-api/pg/driver.d.ts +1 -0
  5. package/aws-data-api/pg/driver.js +6 -1
  6. package/aws-data-api/pg/driver.js.map +1 -1
  7. package/aws-data-api/pg/session.cjs +19 -6
  8. package/aws-data-api/pg/session.cjs.map +1 -1
  9. package/aws-data-api/pg/session.d.cts +13 -2
  10. package/aws-data-api/pg/session.d.ts +13 -2
  11. package/aws-data-api/pg/session.js +19 -6
  12. package/aws-data-api/pg/session.js.map +1 -1
  13. package/better-sqlite3/driver.cjs +1 -2
  14. package/better-sqlite3/driver.cjs.map +1 -1
  15. package/better-sqlite3/driver.js +1 -2
  16. package/better-sqlite3/driver.js.map +1 -1
  17. package/better-sqlite3/session.cjs +15 -9
  18. package/better-sqlite3/session.cjs.map +1 -1
  19. package/better-sqlite3/session.d.cts +12 -2
  20. package/better-sqlite3/session.d.ts +12 -2
  21. package/better-sqlite3/session.js +15 -9
  22. package/better-sqlite3/session.js.map +1 -1
  23. package/bun-sql/driver.cjs +6 -3
  24. package/bun-sql/driver.cjs.map +1 -1
  25. package/bun-sql/driver.js +6 -3
  26. package/bun-sql/driver.js.map +1 -1
  27. package/bun-sql/session.cjs +25 -11
  28. package/bun-sql/session.cjs.map +1 -1
  29. package/bun-sql/session.d.cts +12 -2
  30. package/bun-sql/session.d.ts +12 -2
  31. package/bun-sql/session.js +25 -11
  32. package/bun-sql/session.js.map +1 -1
  33. package/bun-sqlite/driver.cjs +1 -2
  34. package/bun-sqlite/driver.cjs.map +1 -1
  35. package/bun-sqlite/driver.js +1 -2
  36. package/bun-sqlite/driver.js.map +1 -1
  37. package/bun-sqlite/session.cjs +3 -6
  38. package/bun-sqlite/session.cjs.map +1 -1
  39. package/bun-sqlite/session.js +3 -6
  40. package/bun-sqlite/session.js.map +1 -1
  41. package/cache/core/cache.cjs +58 -0
  42. package/cache/core/cache.cjs.map +1 -0
  43. package/cache/core/cache.d.cts +36 -0
  44. package/cache/core/cache.d.ts +36 -0
  45. package/cache/core/cache.js +32 -0
  46. package/cache/core/cache.js.map +1 -0
  47. package/cache/core/index.cjs +23 -0
  48. package/cache/core/index.cjs.map +1 -0
  49. package/cache/core/index.d.cts +1 -0
  50. package/cache/core/index.d.ts +1 -0
  51. package/cache/core/index.js +2 -0
  52. package/cache/core/index.js.map +1 -0
  53. package/cache/core/types.cjs +17 -0
  54. package/cache/core/types.cjs.map +1 -0
  55. package/cache/core/types.d.cts +33 -0
  56. package/cache/core/types.d.ts +33 -0
  57. package/cache/core/types.js +1 -0
  58. package/cache/core/types.js.map +1 -0
  59. package/cache/upstash/cache.cjs +195 -0
  60. package/cache/upstash/cache.cjs.map +1 -0
  61. package/cache/upstash/cache.d.cts +59 -0
  62. package/cache/upstash/cache.d.ts +59 -0
  63. package/cache/upstash/cache.js +170 -0
  64. package/cache/upstash/cache.js.map +1 -0
  65. package/cache/upstash/index.cjs +23 -0
  66. package/cache/upstash/index.cjs.map +1 -0
  67. package/cache/upstash/index.d.cts +1 -0
  68. package/cache/upstash/index.d.ts +1 -0
  69. package/cache/upstash/index.js +2 -0
  70. package/cache/upstash/index.js.map +1 -0
  71. package/casing.cjs +2 -4
  72. package/casing.cjs.map +1 -1
  73. package/casing.js +2 -4
  74. package/casing.js.map +1 -1
  75. package/column-builder.cjs +1 -2
  76. package/column-builder.cjs.map +1 -1
  77. package/column-builder.js +1 -2
  78. package/column-builder.js.map +1 -1
  79. package/d1/driver.cjs +8 -1
  80. package/d1/driver.cjs.map +1 -1
  81. package/d1/driver.js +8 -1
  82. package/d1/driver.js.map +1 -1
  83. package/d1/session.cjs +28 -13
  84. package/d1/session.cjs.map +1 -1
  85. package/d1/session.d.cts +12 -2
  86. package/d1/session.d.ts +12 -2
  87. package/d1/session.js +28 -13
  88. package/d1/session.js.map +1 -1
  89. package/durable-sqlite/session.cjs +3 -5
  90. package/durable-sqlite/session.cjs.map +1 -1
  91. package/durable-sqlite/session.js +3 -5
  92. package/durable-sqlite/session.js.map +1 -1
  93. package/errors.cjs +14 -0
  94. package/errors.cjs.map +1 -1
  95. package/errors.d.cts +7 -0
  96. package/errors.d.ts +7 -0
  97. package/errors.js +13 -0
  98. package/errors.js.map +1 -1
  99. package/expo-sqlite/session.cjs +2 -4
  100. package/expo-sqlite/session.cjs.map +1 -1
  101. package/expo-sqlite/session.js +2 -4
  102. package/expo-sqlite/session.js.map +1 -1
  103. package/gel/driver.cjs +10 -4
  104. package/gel/driver.cjs.map +1 -1
  105. package/gel/driver.d.cts +3 -1
  106. package/gel/driver.d.ts +3 -1
  107. package/gel/driver.js +10 -4
  108. package/gel/driver.js.map +1 -1
  109. package/gel/session.cjs +29 -12
  110. package/gel/session.cjs.map +1 -1
  111. package/gel/session.d.cts +12 -2
  112. package/gel/session.d.ts +12 -2
  113. package/gel/session.js +29 -12
  114. package/gel/session.js.map +1 -1
  115. package/gel-core/columns/custom.cjs +1 -2
  116. package/gel-core/columns/custom.cjs.map +1 -1
  117. package/gel-core/columns/custom.js +1 -2
  118. package/gel-core/columns/custom.js.map +1 -1
  119. package/gel-core/columns/timestamptz.cjs +1 -2
  120. package/gel-core/columns/timestamptz.cjs.map +1 -1
  121. package/gel-core/columns/timestamptz.js +1 -2
  122. package/gel-core/columns/timestamptz.js.map +1 -1
  123. package/gel-core/db.cjs +3 -0
  124. package/gel-core/db.cjs.map +1 -1
  125. package/gel-core/db.d.cts +4 -0
  126. package/gel-core/db.d.ts +4 -0
  127. package/gel-core/db.js +3 -0
  128. package/gel-core/db.js.map +1 -1
  129. package/gel-core/dialect.cjs +9 -16
  130. package/gel-core/dialect.cjs.map +1 -1
  131. package/gel-core/dialect.js +9 -16
  132. package/gel-core/dialect.js.map +1 -1
  133. package/gel-core/query-builders/delete.cjs +5 -1
  134. package/gel-core/query-builders/delete.cjs.map +1 -1
  135. package/gel-core/query-builders/delete.js +5 -1
  136. package/gel-core/query-builders/delete.js.map +1 -1
  137. package/gel-core/query-builders/insert.cjs +5 -1
  138. package/gel-core/query-builders/insert.cjs.map +1 -1
  139. package/gel-core/query-builders/insert.js +5 -1
  140. package/gel-core/query-builders/insert.js.map +1 -1
  141. package/gel-core/query-builders/select.cjs +26 -4
  142. package/gel-core/query-builders/select.cjs.map +1 -1
  143. package/gel-core/query-builders/select.d.cts +18 -9
  144. package/gel-core/query-builders/select.d.ts +18 -9
  145. package/gel-core/query-builders/select.js +26 -4
  146. package/gel-core/query-builders/select.js.map +1 -1
  147. package/gel-core/query-builders/select.types.cjs.map +1 -1
  148. package/gel-core/query-builders/select.types.d.cts +2 -1
  149. package/gel-core/query-builders/select.types.d.ts +2 -1
  150. package/gel-core/query-builders/update.cjs +5 -1
  151. package/gel-core/query-builders/update.cjs.map +1 -1
  152. package/gel-core/query-builders/update.js +5 -1
  153. package/gel-core/query-builders/update.js.map +1 -1
  154. package/gel-core/session.cjs +77 -1
  155. package/gel-core/session.cjs.map +1 -1
  156. package/gel-core/session.d.cts +13 -2
  157. package/gel-core/session.d.ts +13 -2
  158. package/gel-core/session.js +79 -3
  159. package/gel-core/session.js.map +1 -1
  160. package/gel-core/utils.cjs +16 -0
  161. package/gel-core/utils.cjs.map +1 -1
  162. package/gel-core/utils.d.cts +8 -4
  163. package/gel-core/utils.d.ts +8 -4
  164. package/gel-core/utils.js +15 -0
  165. package/gel-core/utils.js.map +1 -1
  166. package/index.cjs +16 -16
  167. package/index.cjs.map +1 -1
  168. package/libsql/driver-core.cjs +5 -1
  169. package/libsql/driver-core.cjs.map +1 -1
  170. package/libsql/driver-core.js +5 -1
  171. package/libsql/driver-core.js.map +1 -1
  172. package/libsql/driver.cjs +1 -2
  173. package/libsql/driver.cjs.map +1 -1
  174. package/libsql/driver.js +1 -2
  175. package/libsql/driver.js.map +1 -1
  176. package/libsql/http/index.cjs +1 -2
  177. package/libsql/http/index.cjs.map +1 -1
  178. package/libsql/http/index.js +1 -2
  179. package/libsql/http/index.js.map +1 -1
  180. package/libsql/node/index.cjs +1 -2
  181. package/libsql/node/index.cjs.map +1 -1
  182. package/libsql/node/index.js +1 -2
  183. package/libsql/node/index.js.map +1 -1
  184. package/libsql/session.cjs +33 -19
  185. package/libsql/session.cjs.map +1 -1
  186. package/libsql/session.d.cts +12 -2
  187. package/libsql/session.d.ts +12 -2
  188. package/libsql/session.js +33 -19
  189. package/libsql/session.js.map +1 -1
  190. package/libsql/sqlite3/index.cjs +1 -2
  191. package/libsql/sqlite3/index.cjs.map +1 -1
  192. package/libsql/sqlite3/index.js +1 -2
  193. package/libsql/sqlite3/index.js.map +1 -1
  194. package/libsql/wasm/index.cjs +1 -2
  195. package/libsql/wasm/index.cjs.map +1 -1
  196. package/libsql/wasm/index.js +1 -2
  197. package/libsql/wasm/index.js.map +1 -1
  198. package/libsql/web/index.cjs +1 -2
  199. package/libsql/web/index.cjs.map +1 -1
  200. package/libsql/web/index.js +1 -2
  201. package/libsql/web/index.js.map +1 -1
  202. package/libsql/ws/index.cjs +1 -2
  203. package/libsql/ws/index.cjs.map +1 -1
  204. package/libsql/ws/index.js +1 -2
  205. package/libsql/ws/index.js.map +1 -1
  206. package/mysql-core/columns/binary.cjs +2 -4
  207. package/mysql-core/columns/binary.cjs.map +1 -1
  208. package/mysql-core/columns/binary.js +2 -4
  209. package/mysql-core/columns/binary.js.map +1 -1
  210. package/mysql-core/columns/custom.cjs +1 -2
  211. package/mysql-core/columns/custom.cjs.map +1 -1
  212. package/mysql-core/columns/custom.js +1 -2
  213. package/mysql-core/columns/custom.js.map +1 -1
  214. package/mysql-core/columns/decimal.cjs +2 -4
  215. package/mysql-core/columns/decimal.cjs.map +1 -1
  216. package/mysql-core/columns/decimal.js +2 -4
  217. package/mysql-core/columns/decimal.js.map +1 -1
  218. package/mysql-core/columns/varbinary.cjs +2 -4
  219. package/mysql-core/columns/varbinary.cjs.map +1 -1
  220. package/mysql-core/columns/varbinary.js +2 -4
  221. package/mysql-core/columns/varbinary.js.map +1 -1
  222. package/mysql-core/db.cjs +17 -0
  223. package/mysql-core/db.cjs.map +1 -1
  224. package/mysql-core/db.d.cts +4 -0
  225. package/mysql-core/db.d.ts +4 -0
  226. package/mysql-core/db.js +17 -0
  227. package/mysql-core/db.js.map +1 -1
  228. package/mysql-core/dialect.cjs +8 -16
  229. package/mysql-core/dialect.cjs.map +1 -1
  230. package/mysql-core/dialect.js +8 -16
  231. package/mysql-core/dialect.js.map +1 -1
  232. package/mysql-core/query-builders/delete.cjs +9 -1
  233. package/mysql-core/query-builders/delete.cjs.map +1 -1
  234. package/mysql-core/query-builders/delete.js +9 -1
  235. package/mysql-core/query-builders/delete.js.map +1 -1
  236. package/mysql-core/query-builders/insert.cjs +8 -1
  237. package/mysql-core/query-builders/insert.cjs.map +1 -1
  238. package/mysql-core/query-builders/insert.d.cts +2 -0
  239. package/mysql-core/query-builders/insert.d.ts +2 -0
  240. package/mysql-core/query-builders/insert.js +8 -1
  241. package/mysql-core/query-builders/insert.js.map +1 -1
  242. package/mysql-core/query-builders/select.cjs +24 -3
  243. package/mysql-core/query-builders/select.cjs.map +1 -1
  244. package/mysql-core/query-builders/select.d.cts +17 -8
  245. package/mysql-core/query-builders/select.d.ts +17 -8
  246. package/mysql-core/query-builders/select.js +25 -4
  247. package/mysql-core/query-builders/select.js.map +1 -1
  248. package/mysql-core/query-builders/select.types.cjs.map +1 -1
  249. package/mysql-core/query-builders/select.types.d.cts +2 -1
  250. package/mysql-core/query-builders/select.types.d.ts +2 -1
  251. package/mysql-core/query-builders/update.cjs +11 -1
  252. package/mysql-core/query-builders/update.cjs.map +1 -1
  253. package/mysql-core/query-builders/update.d.cts +2 -0
  254. package/mysql-core/query-builders/update.d.ts +2 -0
  255. package/mysql-core/query-builders/update.js +11 -1
  256. package/mysql-core/query-builders/update.js.map +1 -1
  257. package/mysql-core/session.cjs +78 -0
  258. package/mysql-core/session.cjs.map +1 -1
  259. package/mysql-core/session.d.cts +14 -1
  260. package/mysql-core/session.d.ts +14 -1
  261. package/mysql-core/session.js +80 -2
  262. package/mysql-core/session.js.map +1 -1
  263. package/mysql-core/utils.cjs +16 -0
  264. package/mysql-core/utils.cjs.map +1 -1
  265. package/mysql-core/utils.d.cts +6 -2
  266. package/mysql-core/utils.d.ts +6 -2
  267. package/mysql-core/utils.js +15 -0
  268. package/mysql-core/utils.js.map +1 -1
  269. package/mysql-proxy/session.cjs +19 -7
  270. package/mysql-proxy/session.cjs.map +1 -1
  271. package/mysql-proxy/session.d.cts +12 -2
  272. package/mysql-proxy/session.d.ts +12 -2
  273. package/mysql-proxy/session.js +19 -7
  274. package/mysql-proxy/session.js.map +1 -1
  275. package/mysql2/driver.cjs +11 -4
  276. package/mysql2/driver.cjs.map +1 -1
  277. package/mysql2/driver.d.cts +3 -1
  278. package/mysql2/driver.d.ts +3 -1
  279. package/mysql2/driver.js +11 -4
  280. package/mysql2/driver.js.map +1 -1
  281. package/mysql2/session.cjs +19 -7
  282. package/mysql2/session.cjs.map +1 -1
  283. package/mysql2/session.d.cts +12 -2
  284. package/mysql2/session.d.ts +12 -2
  285. package/mysql2/session.js +19 -7
  286. package/mysql2/session.js.map +1 -1
  287. package/neon/index.cjs +2 -2
  288. package/neon/index.cjs.map +1 -1
  289. package/neon/index.d.cts +1 -1
  290. package/neon/index.d.ts +1 -1
  291. package/neon/index.js +1 -1
  292. package/neon/index.js.map +1 -1
  293. package/neon/{neon-identity.cjs → neon-auth.cjs} +6 -5
  294. package/neon/neon-auth.cjs.map +1 -0
  295. package/neon/{neon-identity.d.cts → neon-auth.d.cts} +17 -0
  296. package/neon/{neon-identity.d.ts → neon-auth.d.ts} +17 -0
  297. package/neon/{neon-identity.js → neon-auth.js} +3 -2
  298. package/neon/neon-auth.js.map +1 -0
  299. package/neon-http/driver.cjs +11 -10
  300. package/neon-http/driver.cjs.map +1 -1
  301. package/neon-http/driver.d.cts +2 -0
  302. package/neon-http/driver.d.ts +2 -0
  303. package/neon-http/driver.js +11 -10
  304. package/neon-http/driver.js.map +1 -1
  305. package/neon-http/session.cjs +31 -19
  306. package/neon-http/session.cjs.map +1 -1
  307. package/neon-http/session.d.cts +12 -2
  308. package/neon-http/session.d.ts +12 -2
  309. package/neon-http/session.js +31 -19
  310. package/neon-http/session.js.map +1 -1
  311. package/neon-serverless/driver.cjs +10 -4
  312. package/neon-serverless/driver.cjs.map +1 -1
  313. package/neon-serverless/driver.d.cts +3 -1
  314. package/neon-serverless/driver.d.ts +3 -1
  315. package/neon-serverless/driver.js +10 -4
  316. package/neon-serverless/driver.js.map +1 -1
  317. package/neon-serverless/session.cjs +25 -9
  318. package/neon-serverless/session.cjs.map +1 -1
  319. package/neon-serverless/session.d.cts +12 -2
  320. package/neon-serverless/session.d.ts +12 -2
  321. package/neon-serverless/session.js +25 -9
  322. package/neon-serverless/session.js.map +1 -1
  323. package/node-postgres/driver.cjs +10 -4
  324. package/node-postgres/driver.cjs.map +1 -1
  325. package/node-postgres/driver.d.cts +7 -5
  326. package/node-postgres/driver.d.ts +7 -5
  327. package/node-postgres/driver.js +10 -4
  328. package/node-postgres/driver.js.map +1 -1
  329. package/node-postgres/session.cjs +23 -8
  330. package/node-postgres/session.cjs.map +1 -1
  331. package/node-postgres/session.d.cts +13 -2
  332. package/node-postgres/session.d.ts +13 -2
  333. package/node-postgres/session.js +23 -8
  334. package/node-postgres/session.js.map +1 -1
  335. package/op-sqlite/driver.cjs +5 -1
  336. package/op-sqlite/driver.cjs.map +1 -1
  337. package/op-sqlite/driver.js +5 -1
  338. package/op-sqlite/driver.js.map +1 -1
  339. package/op-sqlite/session.cjs +28 -13
  340. package/op-sqlite/session.cjs.map +1 -1
  341. package/op-sqlite/session.d.cts +12 -2
  342. package/op-sqlite/session.d.ts +12 -2
  343. package/op-sqlite/session.js +28 -13
  344. package/op-sqlite/session.js.map +1 -1
  345. package/package.json +78 -13
  346. package/pg-core/columns/bytea.cjs +1 -2
  347. package/pg-core/columns/bytea.cjs.map +1 -1
  348. package/pg-core/columns/bytea.js +1 -2
  349. package/pg-core/columns/bytea.js.map +1 -1
  350. package/pg-core/columns/common.cjs +1 -2
  351. package/pg-core/columns/common.cjs.map +1 -1
  352. package/pg-core/columns/common.js +1 -2
  353. package/pg-core/columns/common.js.map +1 -1
  354. package/pg-core/columns/custom.cjs +1 -2
  355. package/pg-core/columns/custom.cjs.map +1 -1
  356. package/pg-core/columns/custom.js +1 -2
  357. package/pg-core/columns/custom.js.map +1 -1
  358. package/pg-core/columns/numeric.cjs +2 -4
  359. package/pg-core/columns/numeric.cjs.map +1 -1
  360. package/pg-core/columns/numeric.js +2 -4
  361. package/pg-core/columns/numeric.js.map +1 -1
  362. package/pg-core/columns/postgis_extension/geometry.cjs +1 -2
  363. package/pg-core/columns/postgis_extension/geometry.cjs.map +1 -1
  364. package/pg-core/columns/postgis_extension/geometry.js +1 -2
  365. package/pg-core/columns/postgis_extension/geometry.js.map +1 -1
  366. package/pg-core/db.cjs +3 -0
  367. package/pg-core/db.cjs.map +1 -1
  368. package/pg-core/db.d.cts +4 -0
  369. package/pg-core/db.d.ts +4 -0
  370. package/pg-core/db.js +3 -0
  371. package/pg-core/db.js.map +1 -1
  372. package/pg-core/dialect.cjs +8 -16
  373. package/pg-core/dialect.cjs.map +1 -1
  374. package/pg-core/dialect.js +8 -16
  375. package/pg-core/dialect.js.map +1 -1
  376. package/pg-core/query-builders/delete.cjs +6 -1
  377. package/pg-core/query-builders/delete.cjs.map +1 -1
  378. package/pg-core/query-builders/delete.d.cts +3 -1
  379. package/pg-core/query-builders/delete.d.ts +3 -1
  380. package/pg-core/query-builders/delete.js +6 -1
  381. package/pg-core/query-builders/delete.js.map +1 -1
  382. package/pg-core/query-builders/insert.cjs +6 -1
  383. package/pg-core/query-builders/insert.cjs.map +1 -1
  384. package/pg-core/query-builders/insert.d.cts +2 -0
  385. package/pg-core/query-builders/insert.d.ts +2 -0
  386. package/pg-core/query-builders/insert.js +6 -1
  387. package/pg-core/query-builders/insert.js.map +1 -1
  388. package/pg-core/query-builders/select.cjs +28 -5
  389. package/pg-core/query-builders/select.cjs.map +1 -1
  390. package/pg-core/query-builders/select.d.cts +19 -10
  391. package/pg-core/query-builders/select.d.ts +19 -10
  392. package/pg-core/query-builders/select.js +28 -5
  393. package/pg-core/query-builders/select.js.map +1 -1
  394. package/pg-core/query-builders/select.types.cjs.map +1 -1
  395. package/pg-core/query-builders/select.types.d.cts +2 -1
  396. package/pg-core/query-builders/select.types.d.ts +2 -1
  397. package/pg-core/query-builders/update.cjs +6 -1
  398. package/pg-core/query-builders/update.cjs.map +1 -1
  399. package/pg-core/query-builders/update.d.cts +4 -2
  400. package/pg-core/query-builders/update.d.ts +4 -2
  401. package/pg-core/query-builders/update.js +6 -1
  402. package/pg-core/query-builders/update.js.map +1 -1
  403. package/pg-core/session.cjs +77 -1
  404. package/pg-core/session.cjs.map +1 -1
  405. package/pg-core/session.d.cts +13 -2
  406. package/pg-core/session.d.ts +13 -2
  407. package/pg-core/session.js +79 -3
  408. package/pg-core/session.js.map +1 -1
  409. package/pg-core/utils.cjs +16 -0
  410. package/pg-core/utils.cjs.map +1 -1
  411. package/pg-core/utils.d.cts +8 -4
  412. package/pg-core/utils.d.ts +8 -4
  413. package/pg-core/utils.js +16 -1
  414. package/pg-core/utils.js.map +1 -1
  415. package/pg-proxy/driver.cjs +7 -2
  416. package/pg-proxy/driver.cjs.map +1 -1
  417. package/pg-proxy/driver.js +7 -2
  418. package/pg-proxy/driver.js.map +1 -1
  419. package/pg-proxy/session.cjs +19 -7
  420. package/pg-proxy/session.cjs.map +1 -1
  421. package/pg-proxy/session.d.cts +12 -2
  422. package/pg-proxy/session.d.ts +12 -2
  423. package/pg-proxy/session.js +19 -7
  424. package/pg-proxy/session.js.map +1 -1
  425. package/pglite/driver.cjs +10 -4
  426. package/pglite/driver.cjs.map +1 -1
  427. package/pglite/driver.d.cts +2 -0
  428. package/pglite/driver.d.ts +2 -0
  429. package/pglite/driver.js +10 -4
  430. package/pglite/driver.js.map +1 -1
  431. package/pglite/session.cjs +23 -9
  432. package/pglite/session.cjs.map +1 -1
  433. package/pglite/session.d.cts +12 -2
  434. package/pglite/session.d.ts +12 -2
  435. package/pglite/session.js +23 -9
  436. package/pglite/session.js.map +1 -1
  437. package/planetscale-serverless/driver.cjs +9 -3
  438. package/planetscale-serverless/driver.cjs.map +1 -1
  439. package/planetscale-serverless/driver.d.cts +1 -0
  440. package/planetscale-serverless/driver.d.ts +1 -0
  441. package/planetscale-serverless/driver.js +9 -3
  442. package/planetscale-serverless/driver.js.map +1 -1
  443. package/planetscale-serverless/session.cjs +19 -7
  444. package/planetscale-serverless/session.cjs.map +1 -1
  445. package/planetscale-serverless/session.d.cts +12 -2
  446. package/planetscale-serverless/session.d.ts +12 -2
  447. package/planetscale-serverless/session.js +19 -7
  448. package/planetscale-serverless/session.js.map +1 -1
  449. package/postgres-js/driver.cjs +6 -3
  450. package/postgres-js/driver.cjs.map +1 -1
  451. package/postgres-js/driver.js +6 -3
  452. package/postgres-js/driver.js.map +1 -1
  453. package/postgres-js/session.cjs +22 -8
  454. package/postgres-js/session.cjs.map +1 -1
  455. package/postgres-js/session.d.cts +12 -2
  456. package/postgres-js/session.d.ts +12 -2
  457. package/postgres-js/session.js +22 -8
  458. package/postgres-js/session.js.map +1 -1
  459. package/prisma/mysql/session.cjs +1 -1
  460. package/prisma/mysql/session.cjs.map +1 -1
  461. package/prisma/mysql/session.js +1 -1
  462. package/prisma/mysql/session.js.map +1 -1
  463. package/prisma/pg/session.cjs +1 -1
  464. package/prisma/pg/session.cjs.map +1 -1
  465. package/prisma/pg/session.js +1 -1
  466. package/prisma/pg/session.js.map +1 -1
  467. package/query-builders/query-builder.cjs.map +1 -1
  468. package/query-builders/query-builder.d.cts +2 -1
  469. package/query-builders/query-builder.d.ts +2 -1
  470. package/query-builders/query-builder.js.map +1 -1
  471. package/relations.cjs +23 -46
  472. package/relations.cjs.map +1 -1
  473. package/relations.js +23 -46
  474. package/relations.js.map +1 -1
  475. package/singlestore/driver.cjs +24 -19
  476. package/singlestore/driver.cjs.map +1 -1
  477. package/singlestore/driver.d.cts +3 -1
  478. package/singlestore/driver.d.ts +3 -1
  479. package/singlestore/driver.js +24 -19
  480. package/singlestore/driver.js.map +1 -1
  481. package/singlestore/session.cjs +15 -5
  482. package/singlestore/session.cjs.map +1 -1
  483. package/singlestore/session.d.cts +12 -2
  484. package/singlestore/session.d.ts +12 -2
  485. package/singlestore/session.js +15 -5
  486. package/singlestore/session.js.map +1 -1
  487. package/singlestore-core/columns/binary.cjs +2 -4
  488. package/singlestore-core/columns/binary.cjs.map +1 -1
  489. package/singlestore-core/columns/binary.js +2 -4
  490. package/singlestore-core/columns/binary.js.map +1 -1
  491. package/singlestore-core/columns/custom.cjs +1 -2
  492. package/singlestore-core/columns/custom.cjs.map +1 -1
  493. package/singlestore-core/columns/custom.js +1 -2
  494. package/singlestore-core/columns/custom.js.map +1 -1
  495. package/singlestore-core/columns/decimal.cjs +2 -4
  496. package/singlestore-core/columns/decimal.cjs.map +1 -1
  497. package/singlestore-core/columns/decimal.js +2 -4
  498. package/singlestore-core/columns/decimal.js.map +1 -1
  499. package/singlestore-core/columns/enum.cjs +0 -1
  500. package/singlestore-core/columns/enum.cjs.map +1 -1
  501. package/singlestore-core/columns/enum.js +0 -1
  502. package/singlestore-core/columns/enum.js.map +1 -1
  503. package/singlestore-core/columns/varbinary.cjs +2 -4
  504. package/singlestore-core/columns/varbinary.cjs.map +1 -1
  505. package/singlestore-core/columns/varbinary.js +2 -4
  506. package/singlestore-core/columns/varbinary.js.map +1 -1
  507. package/singlestore-core/columns/vector.cjs.map +1 -1
  508. package/singlestore-core/columns/vector.js.map +1 -1
  509. package/singlestore-core/db.cjs +3 -0
  510. package/singlestore-core/db.cjs.map +1 -1
  511. package/singlestore-core/db.d.cts +4 -0
  512. package/singlestore-core/db.d.ts +4 -0
  513. package/singlestore-core/db.js +3 -0
  514. package/singlestore-core/db.js.map +1 -1
  515. package/singlestore-core/dialect.cjs +1 -2
  516. package/singlestore-core/dialect.cjs.map +1 -1
  517. package/singlestore-core/dialect.js +1 -2
  518. package/singlestore-core/dialect.js.map +1 -1
  519. package/singlestore-core/query-builders/delete.cjs +9 -1
  520. package/singlestore-core/query-builders/delete.cjs.map +1 -1
  521. package/singlestore-core/query-builders/delete.js +9 -1
  522. package/singlestore-core/query-builders/delete.js.map +1 -1
  523. package/singlestore-core/query-builders/insert.cjs +6 -1
  524. package/singlestore-core/query-builders/insert.cjs.map +1 -1
  525. package/singlestore-core/query-builders/insert.js +6 -1
  526. package/singlestore-core/query-builders/insert.js.map +1 -1
  527. package/singlestore-core/query-builders/select.cjs +25 -3
  528. package/singlestore-core/query-builders/select.cjs.map +1 -1
  529. package/singlestore-core/query-builders/select.d.cts +18 -9
  530. package/singlestore-core/query-builders/select.d.ts +18 -9
  531. package/singlestore-core/query-builders/select.js +25 -3
  532. package/singlestore-core/query-builders/select.js.map +1 -1
  533. package/singlestore-core/query-builders/select.types.cjs.map +1 -1
  534. package/singlestore-core/query-builders/select.types.d.cts +2 -1
  535. package/singlestore-core/query-builders/select.types.d.ts +2 -1
  536. package/singlestore-core/query-builders/update.cjs +9 -1
  537. package/singlestore-core/query-builders/update.cjs.map +1 -1
  538. package/singlestore-core/query-builders/update.js +9 -1
  539. package/singlestore-core/query-builders/update.js.map +1 -1
  540. package/singlestore-core/session.cjs +78 -0
  541. package/singlestore-core/session.cjs.map +1 -1
  542. package/singlestore-core/session.d.cts +13 -1
  543. package/singlestore-core/session.d.ts +13 -1
  544. package/singlestore-core/session.js +80 -2
  545. package/singlestore-core/session.js.map +1 -1
  546. package/singlestore-core/utils.cjs +16 -0
  547. package/singlestore-core/utils.cjs.map +1 -1
  548. package/singlestore-core/utils.d.cts +3 -0
  549. package/singlestore-core/utils.d.ts +3 -0
  550. package/singlestore-core/utils.js +15 -0
  551. package/singlestore-core/utils.js.map +1 -1
  552. package/sql/sql.cjs +10 -0
  553. package/sql/sql.cjs.map +1 -1
  554. package/sql/sql.js +10 -0
  555. package/sql/sql.js.map +1 -1
  556. package/sql-js/session.cjs +3 -6
  557. package/sql-js/session.cjs.map +1 -1
  558. package/sql-js/session.js +3 -6
  559. package/sql-js/session.js.map +1 -1
  560. package/sqlite-core/columns/custom.cjs +1 -2
  561. package/sqlite-core/columns/custom.cjs.map +1 -1
  562. package/sqlite-core/columns/custom.js +1 -2
  563. package/sqlite-core/columns/custom.js.map +1 -1
  564. package/sqlite-core/columns/numeric.cjs +2 -4
  565. package/sqlite-core/columns/numeric.cjs.map +1 -1
  566. package/sqlite-core/columns/numeric.js +2 -4
  567. package/sqlite-core/columns/numeric.js.map +1 -1
  568. package/sqlite-core/db.cjs +3 -0
  569. package/sqlite-core/db.cjs.map +1 -1
  570. package/sqlite-core/db.d.cts +4 -0
  571. package/sqlite-core/db.d.ts +4 -0
  572. package/sqlite-core/db.js +3 -0
  573. package/sqlite-core/db.js.map +1 -1
  574. package/sqlite-core/dialect.cjs +7 -14
  575. package/sqlite-core/dialect.cjs.map +1 -1
  576. package/sqlite-core/dialect.js +7 -14
  577. package/sqlite-core/dialect.js.map +1 -1
  578. package/sqlite-core/query-builders/delete.cjs +7 -1
  579. package/sqlite-core/query-builders/delete.cjs.map +1 -1
  580. package/sqlite-core/query-builders/delete.js +7 -1
  581. package/sqlite-core/query-builders/delete.js.map +1 -1
  582. package/sqlite-core/query-builders/insert.cjs +9 -5
  583. package/sqlite-core/query-builders/insert.cjs.map +1 -1
  584. package/sqlite-core/query-builders/insert.js +9 -5
  585. package/sqlite-core/query-builders/insert.js.map +1 -1
  586. package/sqlite-core/query-builders/select.cjs +28 -3
  587. package/sqlite-core/query-builders/select.cjs.map +1 -1
  588. package/sqlite-core/query-builders/select.d.cts +15 -6
  589. package/sqlite-core/query-builders/select.d.ts +15 -6
  590. package/sqlite-core/query-builders/select.js +28 -3
  591. package/sqlite-core/query-builders/select.js.map +1 -1
  592. package/sqlite-core/query-builders/select.types.cjs.map +1 -1
  593. package/sqlite-core/query-builders/select.types.d.cts +2 -1
  594. package/sqlite-core/query-builders/select.types.d.ts +2 -1
  595. package/sqlite-core/query-builders/update.cjs +7 -1
  596. package/sqlite-core/query-builders/update.cjs.map +1 -1
  597. package/sqlite-core/query-builders/update.js +7 -1
  598. package/sqlite-core/query-builders/update.js.map +1 -1
  599. package/sqlite-core/session.cjs +87 -3
  600. package/sqlite-core/session.cjs.map +1 -1
  601. package/sqlite-core/session.d.cts +17 -3
  602. package/sqlite-core/session.d.ts +17 -3
  603. package/sqlite-core/session.js +89 -5
  604. package/sqlite-core/session.js.map +1 -1
  605. package/sqlite-core/utils.cjs +16 -0
  606. package/sqlite-core/utils.cjs.map +1 -1
  607. package/sqlite-core/utils.d.cts +6 -2
  608. package/sqlite-core/utils.d.ts +6 -2
  609. package/sqlite-core/utils.js +15 -0
  610. package/sqlite-core/utils.js.map +1 -1
  611. package/sqlite-proxy/driver.cjs +9 -2
  612. package/sqlite-proxy/driver.cjs.map +1 -1
  613. package/sqlite-proxy/driver.js +9 -2
  614. package/sqlite-proxy/driver.js.map +1 -1
  615. package/sqlite-proxy/session.cjs +27 -12
  616. package/sqlite-proxy/session.cjs.map +1 -1
  617. package/sqlite-proxy/session.d.cts +12 -2
  618. package/sqlite-proxy/session.d.ts +12 -2
  619. package/sqlite-proxy/session.js +27 -12
  620. package/sqlite-proxy/session.js.map +1 -1
  621. package/subquery.cjs +4 -3
  622. package/subquery.cjs.map +1 -1
  623. package/subquery.d.cts +2 -1
  624. package/subquery.d.ts +2 -1
  625. package/subquery.js +4 -3
  626. package/subquery.js.map +1 -1
  627. package/tidb-serverless/driver.cjs +9 -3
  628. package/tidb-serverless/driver.cjs.map +1 -1
  629. package/tidb-serverless/driver.d.cts +1 -0
  630. package/tidb-serverless/driver.d.ts +1 -0
  631. package/tidb-serverless/driver.js +9 -3
  632. package/tidb-serverless/driver.js.map +1 -1
  633. package/tidb-serverless/session.cjs +19 -7
  634. package/tidb-serverless/session.cjs.map +1 -1
  635. package/tidb-serverless/session.d.cts +12 -2
  636. package/tidb-serverless/session.d.ts +12 -2
  637. package/tidb-serverless/session.js +19 -7
  638. package/tidb-serverless/session.js.map +1 -1
  639. package/utils.cjs +10 -20
  640. package/utils.cjs.map +1 -1
  641. package/utils.d.cts +2 -0
  642. package/utils.d.ts +2 -0
  643. package/utils.js +10 -20
  644. package/utils.js.map +1 -1
  645. package/vercel-postgres/driver.cjs +9 -2
  646. package/vercel-postgres/driver.cjs.map +1 -1
  647. package/vercel-postgres/driver.d.cts +3 -1
  648. package/vercel-postgres/driver.d.ts +3 -1
  649. package/vercel-postgres/driver.js +9 -2
  650. package/vercel-postgres/driver.js.map +1 -1
  651. package/vercel-postgres/session.cjs +25 -9
  652. package/vercel-postgres/session.cjs.map +1 -1
  653. package/vercel-postgres/session.d.cts +12 -2
  654. package/vercel-postgres/session.d.ts +12 -2
  655. package/vercel-postgres/session.js +25 -9
  656. package/vercel-postgres/session.js.map +1 -1
  657. package/version.cjs +1 -1
  658. package/version.d.cts +1 -1
  659. package/version.d.ts +1 -1
  660. package/version.js +1 -1
  661. package/xata-http/driver.cjs +7 -2
  662. package/xata-http/driver.cjs.map +1 -1
  663. package/xata-http/driver.d.cts +2 -0
  664. package/xata-http/driver.d.ts +2 -0
  665. package/xata-http/driver.js +7 -2
  666. package/xata-http/driver.js.map +1 -1
  667. package/xata-http/session.cjs +27 -13
  668. package/xata-http/session.cjs.map +1 -1
  669. package/xata-http/session.d.cts +12 -2
  670. package/xata-http/session.d.ts +12 -2
  671. package/xata-http/session.js +27 -13
  672. package/xata-http/session.js.map +1 -1
  673. package/neon/neon-identity.cjs.map +0 -1
  674. package/neon/neon-identity.js.map +0 -1
@@ -92,8 +92,7 @@ class PreparedQuery extends PreparedQueryBase {
92
92
  return this.stmt.run(...params);
93
93
  }
94
94
  all(placeholderValues) {
95
- if (this.isRqbV2Query)
96
- return this.allRqbV2(placeholderValues);
95
+ if (this.isRqbV2Query) return this.allRqbV2(placeholderValues);
97
96
  const { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;
98
97
  if (!fields && !customResultMapper) {
99
98
  const params = fillPlaceholders(query.params, placeholderValues ?? {});
@@ -107,8 +106,7 @@ class PreparedQuery extends PreparedQueryBase {
107
106
  return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
108
107
  }
109
108
  get(placeholderValues) {
110
- if (this.isRqbV2Query)
111
- return this.getRqbV2(placeholderValues);
109
+ if (this.isRqbV2Query) return this.getRqbV2(placeholderValues);
112
110
  const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
113
111
  this.logger.logQuery(this.query.sql, params);
114
112
  const row = this.stmt.values(...params)[0];
@@ -137,8 +135,7 @@ class PreparedQuery extends PreparedQueryBase {
137
135
  this.logger.logQuery(this.query.sql, params);
138
136
  const { stmt, customResultMapper } = this;
139
137
  const row = stmt.get(...params);
140
- if (row === void 0)
141
- return row;
138
+ if (row === void 0) return row;
142
139
  return customResultMapper(
143
140
  [row]
144
141
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bun-sqlite/session.ts"],"sourcesContent":["/// <reference types=\"bun-types\" />\n\nimport type { Database, Statement as BunStatement } from 'bun:sqlite';\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 { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, sql } from '~/sql/sql.ts';\nimport type { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport { SQLiteTransaction } from '~/sqlite-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types.ts';\nimport type {\n\tPreparedQueryConfig as PreparedQueryConfigBase,\n\tSQLiteExecuteMethod,\n\tSQLiteTransactionConfig,\n} from '~/sqlite-core/session.ts';\nimport { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from '~/sqlite-core/session.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport interface SQLiteBunSessionOptions {\n\tlogger?: Logger;\n}\n\ntype PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;\ntype Statement = BunStatement<any>;\n\nexport class SQLiteBunSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteSession<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: Database,\n\t\tdialect: SQLiteSyncDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\toptions: SQLiteBunSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\texec(query: string): void {\n\t\tthis.client.exec(query);\n\t}\n\n\tprepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => unknown,\n\t): PreparedQuery<T> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => unknown,\n\t): PreparedQuery<T, true> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t\tconfig: SQLiteTransactionConfig = {},\n\t): T {\n\t\tconst tx = new SQLiteBunTransaction('sync', this.dialect, this, this.relations, this.schema);\n\t\tlet result: T | undefined;\n\t\tconst nativeTx = this.client.transaction(() => {\n\t\t\tresult = transaction(tx);\n\t\t});\n\t\tnativeTx[config.behavior ?? 'deferred']();\n\t\treturn result!;\n\t}\n}\n\nexport class SQLiteBunTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteTransaction<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunTransaction';\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t): T {\n\t\tconst savepointName = `sp${this.nestedIndex}`;\n\t\tconst tx = new SQLiteBunTransaction(\n\t\t\t'sync',\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tthis.session.run(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = transaction(tx);\n\t\t\tthis.session.run(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthis.session.run(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PreparedQueryBase<\n\t\t{ type: 'sync'; run: void; all: T['all']; get: T['get']; values: T['values']; execute: T['execute'] }\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteBunPreparedQuery';\n\n\tconstructor(\n\t\tprivate stmt: Statement,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => unknown,\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper('sync', executeMethod, query);\n\t}\n\n\trun(placeholderValues?: Record<string, unknown>) {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.run(...params);\n\t}\n\n\tall(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tif (this.isRqbV2Query) return this.allRqbV2(placeholderValues);\n\n\t\tconst { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\t\t\tlogger.logQuery(query.sql, params);\n\t\t\treturn stmt.all(...params);\n\t\t}\n\n\t\tconst rows = this.values(placeholderValues) as unknown[][];\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)(rows) as T['all'];\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tget(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tif (this.isRqbV2Query) return this.getRqbV2(placeholderValues);\n\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\tconst row = this.stmt.values(...params)[0];\n\n\t\tif (!row) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn row;\n\t\t}\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)([row]) as T['get'];\n\t\t}\n\n\t\treturn mapResultRow(fields!, row, joinsNotNullableMap);\n\t}\n\n\tprivate allRqbV2(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tconst { query, logger, stmt, customResultMapper } = this;\n\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\n\t\tlogger.logQuery(query.sql, params);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\tstmt.all(...params) as Record<string, unknown>[],\n\t\t);\n\t}\n\n\tprivate getRqbV2(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { stmt, customResultMapper } = this;\n\n\t\tconst row = stmt.get(...params) as Record<string, unknown>;\n\t\tif (row === undefined) return row;\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\t[row],\n\t\t);\n\t}\n\n\tvalues(placeholderValues?: Record<string, unknown>): T['values'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.values(...params);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n"],"mappings":"AAIA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAE3B,SAAS,kBAA8B,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,UAAM,SAAS,iBAAiB,KAAK,MAAM,QAAQ,qBAAqB,CAAC,CAAC;AAC1E,SAAK,OAAO,SAAS,KAAK,MAAM,KAAK,MAAM;AAC3C,WAAO,KAAK,KAAK,OAAO,GAAG,MAAM;AAAA,EAClC;AAAA;AAAA,EAGA,wBAAiC;AAChC,WAAO,KAAK;AAAA,EACb;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/bun-sqlite/session.ts"],"sourcesContent":["/// <reference types=\"bun-types\" />\n\nimport type { Database, Statement as BunStatement } from 'bun:sqlite';\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 { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, sql } from '~/sql/sql.ts';\nimport type { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport { SQLiteTransaction } from '~/sqlite-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/sqlite-core/query-builders/select.types.ts';\nimport type {\n\tPreparedQueryConfig as PreparedQueryConfigBase,\n\tSQLiteExecuteMethod,\n\tSQLiteTransactionConfig,\n} from '~/sqlite-core/session.ts';\nimport { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from '~/sqlite-core/session.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport interface SQLiteBunSessionOptions {\n\tlogger?: Logger;\n}\n\ntype PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;\ntype Statement = BunStatement<any>;\n\nexport class SQLiteBunSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteSession<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: Database,\n\t\tdialect: SQLiteSyncDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\toptions: SQLiteBunSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\texec(query: string): void {\n\t\tthis.client.exec(query);\n\t}\n\n\tprepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => unknown,\n\t): PreparedQuery<T> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends Omit<PreparedQueryConfig, 'run'>>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => unknown,\n\t): PreparedQuery<T, true> {\n\t\tconst stmt = this.client.prepare(query.sql);\n\t\treturn new PreparedQuery(\n\t\t\tstmt,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\texecuteMethod,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t\tconfig: SQLiteTransactionConfig = {},\n\t): T {\n\t\tconst tx = new SQLiteBunTransaction('sync', this.dialect, this, this.relations, this.schema);\n\t\tlet result: T | undefined;\n\t\tconst nativeTx = this.client.transaction(() => {\n\t\t\tresult = transaction(tx);\n\t\t});\n\t\tnativeTx[config.behavior ?? 'deferred']();\n\t\treturn result!;\n\t}\n}\n\nexport class SQLiteBunTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends SQLiteTransaction<'sync', void, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SQLiteBunTransaction';\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: SQLiteBunTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => T,\n\t): T {\n\t\tconst savepointName = `sp${this.nestedIndex}`;\n\t\tconst tx = new SQLiteBunTransaction(\n\t\t\t'sync',\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tthis.session.run(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = transaction(tx);\n\t\t\tthis.session.run(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tthis.session.run(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PreparedQueryBase<\n\t\t{ type: 'sync'; run: void; all: T['all']; get: T['get']; values: T['values']; execute: T['execute'] }\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteBunPreparedQuery';\n\n\tconstructor(\n\t\tprivate stmt: Statement,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\texecuteMethod: SQLiteExecuteMethod,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => unknown,\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper('sync', executeMethod, query);\n\t}\n\n\trun(placeholderValues?: Record<string, unknown>) {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.run(...params);\n\t}\n\n\tall(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tif (this.isRqbV2Query) return this.allRqbV2(placeholderValues);\n\n\t\tconst { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\t\t\tlogger.logQuery(query.sql, params);\n\t\t\treturn stmt.all(...params);\n\t\t}\n\n\t\tconst rows = this.values(placeholderValues) as unknown[][];\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)(rows) as T['all'];\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));\n\t}\n\n\tget(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tif (this.isRqbV2Query) return this.getRqbV2(placeholderValues);\n\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\tconst row = this.stmt.values(...params)[0];\n\n\t\tif (!row) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { fields, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn row;\n\t\t}\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => unknown)([row]) as T['get'];\n\t\t}\n\n\t\treturn mapResultRow(fields!, row, joinsNotNullableMap);\n\t}\n\n\tprivate allRqbV2(placeholderValues?: Record<string, unknown>): T['all'] {\n\t\tconst { query, logger, stmt, customResultMapper } = this;\n\t\tconst params = fillPlaceholders(query.params, placeholderValues ?? {});\n\n\t\tlogger.logQuery(query.sql, params);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\tstmt.all(...params) as Record<string, unknown>[],\n\t\t);\n\t}\n\n\tprivate getRqbV2(placeholderValues?: Record<string, unknown>): T['get'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { stmt, customResultMapper } = this;\n\n\t\tconst row = stmt.get(...params) as Record<string, unknown>;\n\t\tif (row === undefined) return row;\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => unknown)(\n\t\t\t[row],\n\t\t);\n\t}\n\n\tvalues(placeholderValues?: Record<string, unknown>): T['values'] {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues ?? {});\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.stmt.values(...params);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n"],"mappings":"AAIA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAE3B,SAAS,kBAA8B,WAAW;AAElD,SAAS,yBAAyB;AAOlC,SAAS,uBAAuB,mBAAmB,qBAAqB;AACxE,SAAS,oBAAoB;AAStB,MAAM,yBAKH,cAA6E;AAAA,EAKtF,YACS,QACR,SACQ,WACA,QACR,UAAmC,CAAC,GACnC;AACD,UAAM,OAAO;AANL;AAEA;AACA;AAIR,SAAK,SAAS,QAAQ,UAAU,IAAI,WAAW;AAAA,EAChD;AAAA,EAbA,QAA0B,UAAU,IAAY;AAAA,EAExC;AAAA,EAaR,KAAK,OAAqB;AACzB,SAAK,OAAO,KAAK,KAAK;AAAA,EACvB;AAAA,EAEA,aACC,OACA,QACA,eACA,uBACA,oBACmB;AACnB,UAAM,OAAO,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC1C,WAAO,IAAI;AAAA,MACV;AAAA,M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AO;AAAA,IACR;AAEA,QAAI,oBAAoB;AACvB,aAAQ,mBAAsD,CAAC,GAAG,CAAC;AAAA,IACpE;AAEA,WAAO,aAAa,QAAS,KAAK,mBAAmB;AAAA,EACtD;AAAA,EAEQ,SAAS,mBAAuD;AACvE,UAAM,EAAE,OAAO,QAAQ,MAAM,mBAAmB,IAAI;AACpD,UAAM,SAAS,iBAAiB,MAAM,QAAQ,qBAAqB,CAAC,CAAC;AAErE,WAAO,SAAS,MAAM,KAAK,MAAM;AAEjC,WAAQ;AAAA,MACP,KAAK,IAAI,GAAG,MAAM;AAAA,IACnB;AAAA,EACD;AAAA,EAEQ,SAAS,mBAAuD;AACvE,UAAM,SAAS,iBAAiB,KAAK,MAAM,QAAQ,qBAAqB,CAAC,CAAC;AAC1E,SAAK,OAAO,SAAS,KAAK,MAAM,KAAK,MAAM;AAE3C,UAAM,EAAE,MAAM,mBAAmB,IAAI;AAErC,UAAM,MAAM,KAAK,IAAI,GAAG,MAAM;AAC9B,QAAI,QAAQ,OAAW,QAAO;AAE9B,WAAQ;AAAA,MACP,CAAC,GAAG;AAAA,IACL;AAAA,EACD;AAAA,EAEA,OAAO,mBAA0D;AAChE,UAAM,SAAS,iBAAiB,KAAK,MAAM,QAAQ,qBAAqB,CAAC,CAAC;AAC1E,SAAK,OAAO,SAAS,KAAK,MAAM,KAAK,MAAM;AAC3C,WAAO,KAAK,KAAK,OAAO,GAAG,MAAM;AAAA,EAClC;AAAA;AAAA,EAGA,wBAAiC;AAChC,WAAO,KAAK;AAAA,EACb;AACD;","names":[]}
@@ -0,0 +1,58 @@
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
+ Cache: () => Cache,
22
+ NoopCache: () => NoopCache,
23
+ hashQuery: () => hashQuery
24
+ });
25
+ module.exports = __toCommonJS(cache_exports);
26
+ var import_entity = require("../../entity.cjs");
27
+ class Cache {
28
+ static [import_entity.entityKind] = "Cache";
29
+ }
30
+ class NoopCache extends Cache {
31
+ strategy() {
32
+ return "all";
33
+ }
34
+ static [import_entity.entityKind] = "NoopCache";
35
+ async get(_key) {
36
+ return void 0;
37
+ }
38
+ async put(_hashedQuery, _response, _tables, _config) {
39
+ }
40
+ async onMutate(_params) {
41
+ }
42
+ }
43
+ async function hashQuery(sql, params) {
44
+ const dataToHash = `${sql}-${JSON.stringify(params)}`;
45
+ const encoder = new TextEncoder();
46
+ const data = encoder.encode(dataToHash);
47
+ const hashBuffer = await crypto.subtle.digest("SHA-256", data);
48
+ const hashArray = [...new Uint8Array(hashBuffer)];
49
+ const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
50
+ return hashHex;
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ Cache,
55
+ NoopCache,
56
+ hashQuery
57
+ });
58
+ //# sourceMappingURL=cache.cjs.map
@@ -0,0 +1 @@
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\ttables: string[],\n\t\tisTag: boolean,\n\t\tisAutoInvalidate?: boolean,\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\tisTag: boolean,\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\nexport async function hashQuery(sql: string, params?: any[]) {\n\tconst dataToHash = `${sql}-${JSON.stringify(params)}`;\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(dataToHash);\n\tconst hashBuffer = await crypto.subtle.digest('SHA-256', data);\n\tconst hashArray = [...new Uint8Array(hashBuffer)];\n\tconst hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');\n\n\treturn hashHex;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,wBAAU,IAAY;AAoCxC;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;AAIA,eAAsB,UAAU,KAAa,QAAgB;AAC5D,QAAM,aAAa,GAAG,GAAG,IAAI,KAAK,UAAU,MAAM,CAAC;AACnD,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,OAAO,QAAQ,OAAO,UAAU;AACtC,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI;AAC7D,QAAM,YAAY,CAAC,GAAG,IAAI,WAAW,UAAU,CAAC;AAChD,QAAM,UAAU,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAE7E,SAAO;AACR;","names":[]}
@@ -0,0 +1,36 @@
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, tables: string[], isTag: boolean, isAutoInvalidate?: boolean): 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[], isTag: boolean, 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
+ };
36
+ export declare function hashQuery(sql: string, params?: any[]): Promise<string>;
@@ -0,0 +1,36 @@
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, tables: string[], isTag: boolean, isAutoInvalidate?: boolean): 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[], isTag: boolean, 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
+ };
36
+ export declare function hashQuery(sql: string, params?: any[]): Promise<string>;
@@ -0,0 +1,32 @@
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
+ async function hashQuery(sql, params) {
19
+ const dataToHash = `${sql}-${JSON.stringify(params)}`;
20
+ const encoder = new TextEncoder();
21
+ const data = encoder.encode(dataToHash);
22
+ const hashBuffer = await crypto.subtle.digest("SHA-256", data);
23
+ const hashArray = [...new Uint8Array(hashBuffer)];
24
+ const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
25
+ return hashHex;
26
+ }
27
+ export {
28
+ Cache,
29
+ NoopCache,
30
+ hashQuery
31
+ };
32
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
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\ttables: string[],\n\t\tisTag: boolean,\n\t\tisAutoInvalidate?: boolean,\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\tisTag: boolean,\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\nexport async function hashQuery(sql: string, params?: any[]) {\n\tconst dataToHash = `${sql}-${JSON.stringify(params)}`;\n\tconst encoder = new TextEncoder();\n\tconst data = encoder.encode(dataToHash);\n\tconst hashBuffer = await crypto.subtle.digest('SHA-256', data);\n\tconst hashArray = [...new Uint8Array(hashBuffer)];\n\tconst hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');\n\n\treturn hashHex;\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,UAAU,IAAY;AAoCxC;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;AAIA,eAAsB,UAAU,KAAa,QAAgB;AAC5D,QAAM,aAAa,GAAG,GAAG,IAAI,KAAK,UAAU,MAAM,CAAC;AACnD,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,OAAO,QAAQ,OAAO,UAAU;AACtC,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI;AAC7D,QAAM,YAAY,CAAC,GAAG,IAAI,WAAW,UAAU,CAAC;AAChD,QAAM,UAAU,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAE7E,SAAO;AACR;","names":[]}
@@ -0,0 +1,23 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/cache/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,uBAAd;","names":[]}
@@ -0,0 +1 @@
1
+ export * from "./cache.cjs";
@@ -0,0 +1 @@
1
+ export * from "./cache.js";
@@ -0,0 +1,2 @@
1
+ export * from "./cache.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/cache/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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\t/**\n\t * Set an expiration (TTL or time to live) on one or more fields of a given hash key.\n\t * Used for HEXPIRE command\n\t */\n\thexOptions?: 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';\n};\n\nexport type WithCacheConfig = { enable: boolean; config?: CacheConfig; tag?: string; autoInvalidate?: boolean };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,33 @@
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
+ /**
23
+ * Set an expiration (TTL or time to live) on one or more fields of a given hash key.
24
+ * Used for HEXPIRE command
25
+ */
26
+ hexOptions?: 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';
27
+ };
28
+ export type WithCacheConfig = {
29
+ enable: boolean;
30
+ config?: CacheConfig;
31
+ tag?: string;
32
+ autoInvalidate?: boolean;
33
+ };
@@ -0,0 +1,33 @@
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
+ /**
23
+ * Set an expiration (TTL or time to live) on one or more fields of a given hash key.
24
+ * Used for HEXPIRE command
25
+ */
26
+ hexOptions?: 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';
27
+ };
28
+ export type WithCacheConfig = {
29
+ enable: boolean;
30
+ config?: CacheConfig;
31
+ tag?: string;
32
+ autoInvalidate?: boolean;
33
+ };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,195 @@
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
+ const getByTagScript = `
30
+ local tagsMapKey = KEYS[1] -- tags map key
31
+ local tag = ARGV[1] -- tag
32
+
33
+ local compositeTableName = redis.call('HGET', tagsMapKey, tag)
34
+ if not compositeTableName then
35
+ return nil
36
+ end
37
+
38
+ local value = redis.call('HGET', compositeTableName, tag)
39
+ return value
40
+ `;
41
+ const onMutateScript = `
42
+ local tagsMapKey = KEYS[1] -- tags map key
43
+ local tables = {} -- initialize tables array
44
+ local tags = ARGV -- tags array
45
+
46
+ for i = 2, #KEYS do
47
+ tables[#tables + 1] = KEYS[i] -- add all keys except the first one to tables
48
+ end
49
+
50
+ if #tags > 0 then
51
+ for _, tag in ipairs(tags) do
52
+ if tag ~= nil and tag ~= '' then
53
+ local compositeTableName = redis.call('HGET', tagsMapKey, tag)
54
+ if compositeTableName then
55
+ redis.call('HDEL', compositeTableName, tag)
56
+ end
57
+ end
58
+ end
59
+ redis.call('HDEL', tagsMapKey, unpack(tags))
60
+ end
61
+
62
+ local keysToDelete = {}
63
+
64
+ if #tables > 0 then
65
+ local compositeTableNames = redis.call('SUNION', unpack(tables))
66
+ for _, compositeTableName in ipairs(compositeTableNames) do
67
+ keysToDelete[#keysToDelete + 1] = compositeTableName
68
+ end
69
+ for _, table in ipairs(tables) do
70
+ keysToDelete[#keysToDelete + 1] = table
71
+ end
72
+ redis.call('DEL', unpack(keysToDelete))
73
+ end
74
+ `;
75
+ class UpstashCache extends import_core.Cache {
76
+ constructor(redis, config, useGlobally) {
77
+ super();
78
+ this.redis = redis;
79
+ this.useGlobally = useGlobally;
80
+ this.internalConfig = this.toInternalConfig(config);
81
+ this.luaScripts = {
82
+ getByTagScript: this.redis.createScript(getByTagScript, { readonly: true }),
83
+ onMutateScript: this.redis.createScript(onMutateScript)
84
+ };
85
+ }
86
+ static [import_entity.entityKind] = "UpstashCache";
87
+ /**
88
+ * Prefix for sets which denote the composite table names for each unique table
89
+ *
90
+ * Example: In the composite table set of "table1", you may find
91
+ * `${compositeTablePrefix}table1,table2` and `${compositeTablePrefix}table1,table3`
92
+ */
93
+ static compositeTableSetPrefix = "__CTS__";
94
+ /**
95
+ * Prefix for hashes which map hash or tags to cache values
96
+ */
97
+ static compositeTablePrefix = "__CT__";
98
+ /**
99
+ * Key which holds the mapping of tags to composite table names
100
+ *
101
+ * Using this tagsMapKey, you can find the composite table name for a given tag
102
+ * and get the cache value for that tag:
103
+ *
104
+ * ```ts
105
+ * const compositeTable = redis.hget(tagsMapKey, 'tag1')
106
+ * console.log(compositeTable) // `${compositeTablePrefix}table1,table2`
107
+ *
108
+ * const cachevalue = redis.hget(compositeTable, 'tag1')
109
+ */
110
+ static tagsMapKey = "__tagsMap__";
111
+ /**
112
+ * Queries whose auto invalidation is false aren't stored in their respective
113
+ * composite table hashes because those hashes are deleted when a mutation
114
+ * occurs on related tables.
115
+ *
116
+ * Instead, they are stored in a separate hash with the prefix
117
+ * `__nonAutoInvalidate__` to prevent them from being deleted when a mutation
118
+ */
119
+ static nonAutoInvalidateTablePrefix = "__nonAutoInvalidate__";
120
+ luaScripts;
121
+ internalConfig;
122
+ strategy() {
123
+ return this.useGlobally ? "all" : "explicit";
124
+ }
125
+ toInternalConfig(config) {
126
+ return config ? {
127
+ seconds: config.ex,
128
+ hexOptions: config.hexOptions
129
+ } : {
130
+ seconds: 1
131
+ };
132
+ }
133
+ async get(key, tables, isTag = false, isAutoInvalidate) {
134
+ if (!isAutoInvalidate) {
135
+ const result2 = await this.redis.hget(UpstashCache.nonAutoInvalidateTablePrefix, key);
136
+ return result2 === null ? void 0 : result2;
137
+ }
138
+ if (isTag) {
139
+ const result2 = await this.luaScripts.getByTagScript.exec([UpstashCache.tagsMapKey], [key]);
140
+ return result2 === null ? void 0 : result2;
141
+ }
142
+ const compositeKey = this.getCompositeKey(tables);
143
+ const result = (await this.redis.hget(compositeKey, key)) ?? void 0;
144
+ return result === null ? void 0 : result;
145
+ }
146
+ async put(key, response, tables, isTag = false, config) {
147
+ const isAutoInvalidate = tables.length !== 0;
148
+ const pipeline = this.redis.pipeline();
149
+ const ttlSeconds = config && config.ex ? config.ex : this.internalConfig.seconds;
150
+ const hexOptions = config && config.hexOptions ? config.hexOptions : this.internalConfig?.hexOptions;
151
+ if (!isAutoInvalidate) {
152
+ if (isTag) {
153
+ pipeline.hset(UpstashCache.tagsMapKey, { [key]: UpstashCache.nonAutoInvalidateTablePrefix });
154
+ pipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions);
155
+ }
156
+ pipeline.hset(UpstashCache.nonAutoInvalidateTablePrefix, { [key]: response });
157
+ pipeline.hexpire(UpstashCache.nonAutoInvalidateTablePrefix, key, ttlSeconds, hexOptions);
158
+ await pipeline.exec();
159
+ return;
160
+ }
161
+ const compositeKey = this.getCompositeKey(tables);
162
+ pipeline.hset(compositeKey, { [key]: response });
163
+ pipeline.hexpire(compositeKey, key, ttlSeconds, hexOptions);
164
+ if (isTag) {
165
+ pipeline.hset(UpstashCache.tagsMapKey, { [key]: compositeKey });
166
+ pipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions);
167
+ }
168
+ for (const table of tables) {
169
+ pipeline.sadd(this.addTablePrefix(table), compositeKey);
170
+ }
171
+ await pipeline.exec();
172
+ }
173
+ async onMutate(params) {
174
+ const tags = Array.isArray(params.tags) ? params.tags : params.tags ? [params.tags] : [];
175
+ const tables = Array.isArray(params.tables) ? params.tables : params.tables ? [params.tables] : [];
176
+ const tableNames = tables.map((table) => (0, import_entity.is)(table, import__.Table) ? table[import__.OriginalName] : table);
177
+ const compositeTableSets = tableNames.map((table) => this.addTablePrefix(table));
178
+ await this.luaScripts.onMutateScript.exec([UpstashCache.tagsMapKey, ...compositeTableSets], tags);
179
+ }
180
+ addTablePrefix = (table) => `${UpstashCache.compositeTableSetPrefix}${table}`;
181
+ getCompositeKey = (tables) => `${UpstashCache.compositeTablePrefix}${tables.sort().join(",")}`;
182
+ }
183
+ function upstashCache({ url, token, config, global = false }) {
184
+ const redis = new import_redis.Redis({
185
+ url,
186
+ token
187
+ });
188
+ return new UpstashCache(redis, config, global);
189
+ }
190
+ // Annotate the CommonJS export names for ESM import in node:
191
+ 0 && (module.exports = {
192
+ UpstashCache,
193
+ upstashCache
194
+ });
195
+ //# sourceMappingURL=cache.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/cache/upstash/cache.ts"],"sourcesContent":["import { 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\nconst getByTagScript = `\nlocal tagsMapKey = KEYS[1] -- tags map key\nlocal tag = ARGV[1] -- tag\n\nlocal compositeTableName = redis.call('HGET', tagsMapKey, tag)\nif not compositeTableName then\n return nil\nend\n\nlocal value = redis.call('HGET', compositeTableName, tag)\nreturn value\n`;\n\nconst onMutateScript = `\nlocal tagsMapKey = KEYS[1] -- tags map key\nlocal tables = {} -- initialize tables array\nlocal tags = ARGV -- tags array\n\nfor i = 2, #KEYS do\n tables[#tables + 1] = KEYS[i] -- add all keys except the first one to tables\nend\n\nif #tags > 0 then\n for _, tag in ipairs(tags) do\n if tag ~= nil and tag ~= '' then\n local compositeTableName = redis.call('HGET', tagsMapKey, tag)\n if compositeTableName then\n redis.call('HDEL', compositeTableName, tag)\n end\n end\n end\n redis.call('HDEL', tagsMapKey, unpack(tags))\nend\n\nlocal keysToDelete = {}\n\nif #tables > 0 then\n local compositeTableNames = redis.call('SUNION', unpack(tables))\n for _, compositeTableName in ipairs(compositeTableNames) do\n keysToDelete[#keysToDelete + 1] = compositeTableName\n end\n for _, table in ipairs(tables) do\n keysToDelete[#keysToDelete + 1] = table\n end\n redis.call('DEL', unpack(keysToDelete))\nend\n`;\n\ntype Script = ReturnType<Redis['createScript']>;\n\ntype ExpireOptions = 'NX' | 'nx' | 'XX' | 'xx' | 'GT' | 'gt' | 'LT' | 'lt';\n\nexport class UpstashCache extends Cache {\n\tstatic override readonly [entityKind]: string = 'UpstashCache';\n\t/**\n\t * Prefix for sets which denote the composite table names for each unique table\n\t *\n\t * Example: In the composite table set of \"table1\", you may find\n\t * `${compositeTablePrefix}table1,table2` and `${compositeTablePrefix}table1,table3`\n\t */\n\tprivate static compositeTableSetPrefix = '__CTS__';\n\t/**\n\t * Prefix for hashes which map hash or tags to cache values\n\t */\n\tprivate static compositeTablePrefix = '__CT__';\n\t/**\n\t * Key which holds the mapping of tags to composite table names\n\t *\n\t * Using this tagsMapKey, you can find the composite table name for a given tag\n\t * and get the cache value for that tag:\n\t *\n\t * ```ts\n\t * const compositeTable = redis.hget(tagsMapKey, 'tag1')\n\t * console.log(compositeTable) // `${compositeTablePrefix}table1,table2`\n\t *\n\t * const cachevalue = redis.hget(compositeTable, 'tag1')\n\t */\n\tprivate static tagsMapKey = '__tagsMap__';\n\t/**\n\t * Queries whose auto invalidation is false aren't stored in their respective\n\t * composite table hashes because those hashes are deleted when a mutation\n\t * occurs on related tables.\n\t *\n\t * Instead, they are stored in a separate hash with the prefix\n\t * `__nonAutoInvalidate__` to prevent them from being deleted when a mutation\n\t */\n\tprivate static nonAutoInvalidateTablePrefix = '__nonAutoInvalidate__';\n\n\tprivate luaScripts: {\n\t\tgetByTagScript: Script;\n\t\tonMutateScript: Script;\n\t};\n\n\tprivate internalConfig: { seconds: number; hexOptions?: ExpireOptions };\n\n\tconstructor(public redis: Redis, config?: CacheConfig, protected useGlobally?: boolean) {\n\t\tsuper();\n\t\tthis.internalConfig = this.toInternalConfig(config);\n\t\tthis.luaScripts = {\n\t\t\tgetByTagScript: this.redis.createScript(getByTagScript, { readonly: true }),\n\t\t\tonMutateScript: this.redis.createScript(onMutateScript),\n\t\t};\n\t}\n\n\tpublic strategy() {\n\t\treturn this.useGlobally ? 'all' : 'explicit';\n\t}\n\n\tprivate toInternalConfig(config?: CacheConfig): { seconds: number; hexOptions?: ExpireOptions } {\n\t\treturn config\n\t\t\t? {\n\t\t\t\tseconds: config.ex!,\n\t\t\t\thexOptions: config.hexOptions,\n\t\t\t}\n\t\t\t: {\n\t\t\t\tseconds: 1,\n\t\t\t};\n\t}\n\n\toverride async get(\n\t\tkey: string,\n\t\ttables: string[],\n\t\tisTag: boolean = false,\n\t\tisAutoInvalidate?: boolean,\n\t): Promise<any[] | undefined> {\n\t\tif (!isAutoInvalidate) {\n\t\t\tconst result = await this.redis.hget(UpstashCache.nonAutoInvalidateTablePrefix, key);\n\t\t\treturn result === null ? undefined : result as any[];\n\t\t}\n\n\t\tif (isTag) {\n\t\t\tconst result = await this.luaScripts.getByTagScript.exec([UpstashCache.tagsMapKey], [key]);\n\t\t\treturn result === null ? undefined : result as any[];\n\t\t}\n\n\t\t// Normal cache lookup for the composite key\n\t\tconst compositeKey = this.getCompositeKey(tables);\n\t\tconst result = await this.redis.hget(compositeKey, key) ?? undefined; // Retrieve result for normal query\n\t\treturn result === null ? undefined : result as any[];\n\t}\n\n\toverride async put(\n\t\tkey: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tisTag: boolean = false,\n\t\tconfig?: CacheConfig,\n\t): Promise<void> {\n\t\tconst isAutoInvalidate = tables.length !== 0;\n\n\t\tconst pipeline = this.redis.pipeline();\n\t\tconst ttlSeconds = config && config.ex ? config.ex : this.internalConfig.seconds;\n\t\tconst hexOptions = config && config.hexOptions ? config.hexOptions : this.internalConfig?.hexOptions;\n\n\t\tif (!isAutoInvalidate) {\n\t\t\tif (isTag) {\n\t\t\t\tpipeline.hset(UpstashCache.tagsMapKey, { [key]: UpstashCache.nonAutoInvalidateTablePrefix });\n\t\t\t\tpipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions);\n\t\t\t}\n\n\t\t\tpipeline.hset(UpstashCache.nonAutoInvalidateTablePrefix, { [key]: response });\n\t\t\tpipeline.hexpire(UpstashCache.nonAutoInvalidateTablePrefix, key, ttlSeconds, hexOptions);\n\t\t\tawait pipeline.exec();\n\t\t\treturn;\n\t\t}\n\n\t\tconst compositeKey = this.getCompositeKey(tables);\n\n\t\tpipeline.hset(compositeKey, { [key]: response }); // Store the result with the tag under the composite key\n\t\tpipeline.hexpire(compositeKey, key, ttlSeconds, hexOptions); // Set expiration for the composite key\n\n\t\tif (isTag) {\n\t\t\tpipeline.hset(UpstashCache.tagsMapKey, { [key]: compositeKey }); // Store the tag and its composite key in the map\n\t\t\tpipeline.hexpire(UpstashCache.tagsMapKey, key, ttlSeconds, hexOptions); // Set expiration for the tag\n\t\t}\n\n\t\tfor (const table of tables) {\n\t\t\tpipeline.sadd(this.addTablePrefix(table), compositeKey);\n\t\t}\n\n\t\tawait pipeline.exec();\n\t}\n\n\toverride async onMutate(params: MutationOption) {\n\t\tconst tags = Array.isArray(params.tags) ? params.tags : params.tags ? [params.tags] : [];\n\t\tconst tables = Array.isArray(params.tables) ? params.tables : params.tables ? [params.tables] : [];\n\t\tconst tableNames: string[] = tables.map((table) => is(table, Table) ? table[OriginalName] : table as string);\n\n\t\tconst compositeTableSets = tableNames.map((table) => this.addTablePrefix(table));\n\t\tawait this.luaScripts.onMutateScript.exec([UpstashCache.tagsMapKey, ...compositeTableSets], tags);\n\t}\n\n\tprivate addTablePrefix = (table: string) => `${UpstashCache.compositeTableSetPrefix}${table}`;\n\tprivate getCompositeKey = (tables: string[]) => `${UpstashCache.compositeTablePrefix}${tables.sort().join(',')}`;\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;AAAA,mBAAsB;AAEtB,kBAAsB;AACtB,oBAA+B;AAC/B,eAAoC;AAGpC,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAavB,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuChB,MAAM,qBAAqB,kBAAM;AAAA,EA2CvC,YAAmB,OAAc,QAAgC,aAAuB;AACvF,UAAM;AADY;AAA8C;AAEhE,SAAK,iBAAiB,KAAK,iBAAiB,MAAM;AAClD,SAAK,aAAa;AAAA,MACjB,gBAAgB,KAAK,MAAM,aAAa,gBAAgB,EAAE,UAAU,KAAK,CAAC;AAAA,MAC1E,gBAAgB,KAAK,MAAM,aAAa,cAAc;AAAA,IACvD;AAAA,EACD;AAAA,EAjDA,QAA0B,wBAAU,IAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,OAAe,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAIzC,OAAe,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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