drizzle-orm 0.44.2-512acc4 → 0.44.2-6baabce

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 (775) hide show
  1. package/aws-data-api/pg/driver.cjs +6 -14
  2. package/aws-data-api/pg/driver.cjs.map +1 -1
  3. package/aws-data-api/pg/driver.d.cts +3 -4
  4. package/aws-data-api/pg/driver.d.ts +3 -4
  5. package/aws-data-api/pg/driver.js +6 -14
  6. package/aws-data-api/pg/driver.js.map +1 -1
  7. package/aws-data-api/pg/session.cjs +9 -26
  8. package/aws-data-api/pg/session.cjs.map +1 -1
  9. package/aws-data-api/pg/session.d.cts +4 -5
  10. package/aws-data-api/pg/session.d.ts +4 -5
  11. package/aws-data-api/pg/session.js +9 -26
  12. package/aws-data-api/pg/session.js.map +1 -1
  13. package/better-sqlite3/driver.cjs.map +1 -1
  14. package/better-sqlite3/driver.d.cts +3 -4
  15. package/better-sqlite3/driver.d.ts +3 -4
  16. package/better-sqlite3/driver.js.map +1 -1
  17. package/better-sqlite3/session.cjs +4 -4
  18. package/better-sqlite3/session.cjs.map +1 -1
  19. package/better-sqlite3/session.d.cts +4 -4
  20. package/better-sqlite3/session.d.ts +4 -4
  21. package/better-sqlite3/session.js +4 -4
  22. package/better-sqlite3/session.js.map +1 -1
  23. package/bun-sql/driver.cjs +2 -3
  24. package/bun-sql/driver.cjs.map +1 -1
  25. package/bun-sql/driver.d.cts +3 -4
  26. package/bun-sql/driver.d.ts +3 -4
  27. package/bun-sql/driver.js +2 -3
  28. package/bun-sql/driver.js.map +1 -1
  29. package/bun-sql/session.cjs +11 -20
  30. package/bun-sql/session.cjs.map +1 -1
  31. package/bun-sql/session.d.cts +5 -6
  32. package/bun-sql/session.d.ts +5 -6
  33. package/bun-sql/session.js +11 -20
  34. package/bun-sql/session.js.map +1 -1
  35. package/bun-sqlite/driver.cjs.map +1 -1
  36. package/bun-sqlite/driver.d.cts +3 -4
  37. package/bun-sqlite/driver.d.ts +3 -4
  38. package/bun-sqlite/driver.js.map +1 -1
  39. package/bun-sqlite/session.cjs +4 -4
  40. package/bun-sqlite/session.cjs.map +1 -1
  41. package/bun-sqlite/session.d.cts +4 -4
  42. package/bun-sqlite/session.d.ts +4 -4
  43. package/bun-sqlite/session.js +4 -4
  44. package/bun-sqlite/session.js.map +1 -1
  45. package/column-builder.cjs.map +1 -1
  46. package/column-builder.d.cts +2 -7
  47. package/column-builder.d.ts +2 -7
  48. package/column-builder.js.map +1 -1
  49. package/column.cjs +0 -2
  50. package/column.cjs.map +1 -1
  51. package/column.d.cts +0 -6
  52. package/column.d.ts +0 -6
  53. package/column.js +0 -2
  54. package/column.js.map +1 -1
  55. package/d1/driver.cjs +2 -9
  56. package/d1/driver.cjs.map +1 -1
  57. package/d1/driver.d.cts +1 -2
  58. package/d1/driver.d.ts +1 -2
  59. package/d1/driver.js +2 -9
  60. package/d1/driver.js.map +1 -1
  61. package/d1/session.cjs +11 -20
  62. package/d1/session.cjs.map +1 -1
  63. package/d1/session.d.cts +7 -8
  64. package/d1/session.d.ts +7 -8
  65. package/d1/session.js +11 -20
  66. package/d1/session.js.map +1 -1
  67. package/durable-sqlite/driver.cjs.map +1 -1
  68. package/durable-sqlite/driver.d.cts +1 -2
  69. package/durable-sqlite/driver.d.ts +1 -2
  70. package/durable-sqlite/driver.js.map +1 -1
  71. package/durable-sqlite/session.cjs +4 -4
  72. package/durable-sqlite/session.cjs.map +1 -1
  73. package/durable-sqlite/session.d.cts +4 -4
  74. package/durable-sqlite/session.d.ts +4 -4
  75. package/durable-sqlite/session.js +4 -4
  76. package/durable-sqlite/session.js.map +1 -1
  77. package/expo-sqlite/driver.cjs.map +1 -1
  78. package/expo-sqlite/driver.d.cts +1 -2
  79. package/expo-sqlite/driver.d.ts +1 -2
  80. package/expo-sqlite/driver.js.map +1 -1
  81. package/expo-sqlite/session.cjs +4 -4
  82. package/expo-sqlite/session.cjs.map +1 -1
  83. package/expo-sqlite/session.d.cts +4 -4
  84. package/expo-sqlite/session.d.ts +4 -4
  85. package/expo-sqlite/session.js +4 -4
  86. package/expo-sqlite/session.js.map +1 -1
  87. package/gel/driver.cjs +4 -6
  88. package/gel/driver.cjs.map +1 -1
  89. package/gel/driver.d.cts +4 -6
  90. package/gel/driver.d.ts +4 -6
  91. package/gel/driver.js +4 -6
  92. package/gel/driver.js.map +1 -1
  93. package/gel/session.cjs +9 -12
  94. package/gel/session.cjs.map +1 -1
  95. package/gel/session.d.cts +4 -5
  96. package/gel/session.d.ts +4 -5
  97. package/gel/session.js +9 -12
  98. package/gel/session.js.map +1 -1
  99. package/gel-core/columns/common.cjs +0 -8
  100. package/gel-core/columns/common.cjs.map +1 -1
  101. package/gel-core/columns/common.d.cts +0 -2
  102. package/gel-core/columns/common.d.ts +0 -2
  103. package/gel-core/columns/common.js +0 -8
  104. package/gel-core/columns/common.js.map +1 -1
  105. package/gel-core/db.cjs +3 -5
  106. package/gel-core/db.cjs.map +1 -1
  107. package/gel-core/db.d.cts +1 -3
  108. package/gel-core/db.d.ts +1 -3
  109. package/gel-core/db.js +3 -5
  110. package/gel-core/db.js.map +1 -1
  111. package/gel-core/dialect.cjs +19 -24
  112. package/gel-core/dialect.cjs.map +1 -1
  113. package/gel-core/dialect.d.cts +6 -7
  114. package/gel-core/dialect.d.ts +6 -7
  115. package/gel-core/dialect.js +20 -25
  116. package/gel-core/dialect.js.map +1 -1
  117. package/gel-core/query-builders/delete.cjs +5 -19
  118. package/gel-core/query-builders/delete.cjs.map +1 -1
  119. package/gel-core/query-builders/delete.js +5 -19
  120. package/gel-core/query-builders/delete.js.map +1 -1
  121. package/gel-core/query-builders/insert.cjs +9 -44
  122. package/gel-core/query-builders/insert.cjs.map +1 -1
  123. package/gel-core/query-builders/insert.js +11 -46
  124. package/gel-core/query-builders/insert.js.map +1 -1
  125. package/gel-core/query-builders/query.cjs +2 -15
  126. package/gel-core/query-builders/query.cjs.map +1 -1
  127. package/gel-core/query-builders/query.js +2 -15
  128. package/gel-core/query-builders/query.js.map +1 -1
  129. package/gel-core/query-builders/select.cjs +5 -21
  130. package/gel-core/query-builders/select.cjs.map +1 -1
  131. package/gel-core/query-builders/select.js +5 -21
  132. package/gel-core/query-builders/select.js.map +1 -1
  133. package/gel-core/query-builders/update.cjs +6 -20
  134. package/gel-core/query-builders/update.cjs.map +1 -1
  135. package/gel-core/query-builders/update.js +6 -20
  136. package/gel-core/query-builders/update.js.map +1 -1
  137. package/gel-core/session.cjs +4 -47
  138. package/gel-core/session.cjs.map +1 -1
  139. package/gel-core/session.d.cts +5 -11
  140. package/gel-core/session.d.ts +5 -11
  141. package/gel-core/session.js +4 -47
  142. package/gel-core/session.js.map +1 -1
  143. package/libsql/driver-core.cjs +2 -3
  144. package/libsql/driver-core.cjs.map +1 -1
  145. package/libsql/driver-core.js +2 -3
  146. package/libsql/driver-core.js.map +1 -1
  147. package/libsql/driver.cjs +1 -4
  148. package/libsql/driver.cjs.map +1 -1
  149. package/libsql/driver.d.cts +3 -4
  150. package/libsql/driver.d.ts +3 -4
  151. package/libsql/driver.js +1 -4
  152. package/libsql/driver.js.map +1 -1
  153. package/libsql/http/index.cjs +1 -4
  154. package/libsql/http/index.cjs.map +1 -1
  155. package/libsql/http/index.d.cts +3 -4
  156. package/libsql/http/index.d.ts +3 -4
  157. package/libsql/http/index.js +1 -4
  158. package/libsql/http/index.js.map +1 -1
  159. package/libsql/node/index.cjs +1 -4
  160. package/libsql/node/index.cjs.map +1 -1
  161. package/libsql/node/index.d.cts +3 -4
  162. package/libsql/node/index.d.ts +3 -4
  163. package/libsql/node/index.js +1 -4
  164. package/libsql/node/index.js.map +1 -1
  165. package/libsql/session.cjs +12 -29
  166. package/libsql/session.cjs.map +1 -1
  167. package/libsql/session.d.cts +7 -8
  168. package/libsql/session.d.ts +7 -8
  169. package/libsql/session.js +12 -29
  170. package/libsql/session.js.map +1 -1
  171. package/libsql/sqlite3/index.cjs +1 -4
  172. package/libsql/sqlite3/index.cjs.map +1 -1
  173. package/libsql/sqlite3/index.d.cts +3 -4
  174. package/libsql/sqlite3/index.d.ts +3 -4
  175. package/libsql/sqlite3/index.js +1 -4
  176. package/libsql/sqlite3/index.js.map +1 -1
  177. package/libsql/wasm/index.cjs +1 -4
  178. package/libsql/wasm/index.cjs.map +1 -1
  179. package/libsql/wasm/index.d.cts +3 -4
  180. package/libsql/wasm/index.d.ts +3 -4
  181. package/libsql/wasm/index.js +1 -4
  182. package/libsql/wasm/index.js.map +1 -1
  183. package/libsql/web/index.cjs +1 -4
  184. package/libsql/web/index.cjs.map +1 -1
  185. package/libsql/web/index.d.cts +3 -4
  186. package/libsql/web/index.d.ts +3 -4
  187. package/libsql/web/index.js +1 -4
  188. package/libsql/web/index.js.map +1 -1
  189. package/libsql/ws/index.cjs +1 -4
  190. package/libsql/ws/index.cjs.map +1 -1
  191. package/libsql/ws/index.d.cts +3 -4
  192. package/libsql/ws/index.d.ts +3 -4
  193. package/libsql/ws/index.js +1 -4
  194. package/libsql/ws/index.js.map +1 -1
  195. package/mysql-core/db.cjs +3 -5
  196. package/mysql-core/db.cjs.map +1 -1
  197. package/mysql-core/db.d.cts +1 -3
  198. package/mysql-core/db.d.ts +1 -3
  199. package/mysql-core/db.js +3 -5
  200. package/mysql-core/db.js.map +1 -1
  201. package/mysql-core/dialect.cjs +23 -29
  202. package/mysql-core/dialect.cjs.map +1 -1
  203. package/mysql-core/dialect.d.cts +7 -8
  204. package/mysql-core/dialect.d.ts +7 -8
  205. package/mysql-core/dialect.js +24 -30
  206. package/mysql-core/dialect.js.map +1 -1
  207. package/mysql-core/query-builders/delete.cjs +1 -8
  208. package/mysql-core/query-builders/delete.cjs.map +1 -1
  209. package/mysql-core/query-builders/delete.js +1 -8
  210. package/mysql-core/query-builders/delete.js.map +1 -1
  211. package/mysql-core/query-builders/insert.cjs +6 -30
  212. package/mysql-core/query-builders/insert.cjs.map +1 -1
  213. package/mysql-core/query-builders/insert.js +8 -32
  214. package/mysql-core/query-builders/insert.js.map +1 -1
  215. package/mysql-core/query-builders/query.cjs +3 -19
  216. package/mysql-core/query-builders/query.cjs.map +1 -1
  217. package/mysql-core/query-builders/query.js +3 -19
  218. package/mysql-core/query-builders/query.js.map +1 -1
  219. package/mysql-core/query-builders/select.cjs +6 -23
  220. package/mysql-core/query-builders/select.cjs.map +1 -1
  221. package/mysql-core/query-builders/select.js +6 -23
  222. package/mysql-core/query-builders/select.js.map +1 -1
  223. package/mysql-core/query-builders/update.cjs +3 -15
  224. package/mysql-core/query-builders/update.cjs.map +1 -1
  225. package/mysql-core/query-builders/update.js +3 -15
  226. package/mysql-core/query-builders/update.js.map +1 -1
  227. package/mysql-core/session.cjs +4 -43
  228. package/mysql-core/session.cjs.map +1 -1
  229. package/mysql-core/session.d.cts +7 -14
  230. package/mysql-core/session.d.ts +7 -14
  231. package/mysql-core/session.js +4 -43
  232. package/mysql-core/session.js.map +1 -1
  233. package/mysql-proxy/driver.cjs +2 -3
  234. package/mysql-proxy/driver.cjs.map +1 -1
  235. package/mysql-proxy/driver.d.cts +1 -2
  236. package/mysql-proxy/driver.d.ts +1 -2
  237. package/mysql-proxy/driver.js +2 -3
  238. package/mysql-proxy/driver.js.map +1 -1
  239. package/mysql-proxy/session.cjs +8 -8
  240. package/mysql-proxy/session.cjs.map +1 -1
  241. package/mysql-proxy/session.d.cts +6 -5
  242. package/mysql-proxy/session.d.ts +6 -5
  243. package/mysql-proxy/session.js +8 -8
  244. package/mysql-proxy/session.js.map +1 -1
  245. package/mysql2/driver.cjs +4 -11
  246. package/mysql2/driver.cjs.map +1 -1
  247. package/mysql2/driver.d.cts +2 -4
  248. package/mysql2/driver.d.ts +2 -4
  249. package/mysql2/driver.js +4 -11
  250. package/mysql2/driver.js.map +1 -1
  251. package/mysql2/session.cjs +10 -14
  252. package/mysql2/session.cjs.map +1 -1
  253. package/mysql2/session.d.cts +5 -5
  254. package/mysql2/session.d.ts +5 -5
  255. package/mysql2/session.js +10 -14
  256. package/mysql2/session.js.map +1 -1
  257. package/neon-http/driver.cjs +3 -5
  258. package/neon-http/driver.cjs.map +1 -1
  259. package/neon-http/driver.d.cts +4 -6
  260. package/neon-http/driver.d.ts +4 -6
  261. package/neon-http/driver.js +3 -5
  262. package/neon-http/driver.js.map +1 -1
  263. package/neon-http/session.cjs +6 -8
  264. package/neon-http/session.cjs.map +1 -1
  265. package/neon-http/session.d.cts +4 -5
  266. package/neon-http/session.d.ts +4 -5
  267. package/neon-http/session.js +6 -8
  268. package/neon-http/session.js.map +1 -1
  269. package/neon-serverless/driver.cjs +4 -6
  270. package/neon-serverless/driver.cjs.map +1 -1
  271. package/neon-serverless/driver.d.cts +4 -6
  272. package/neon-serverless/driver.d.ts +4 -6
  273. package/neon-serverless/driver.js +4 -6
  274. package/neon-serverless/driver.js.map +1 -1
  275. package/neon-serverless/session.cjs +9 -23
  276. package/neon-serverless/session.cjs.map +1 -1
  277. package/neon-serverless/session.d.cts +4 -5
  278. package/neon-serverless/session.d.ts +4 -5
  279. package/neon-serverless/session.js +9 -23
  280. package/neon-serverless/session.js.map +1 -1
  281. package/node-postgres/driver.cjs +4 -6
  282. package/node-postgres/driver.cjs.map +1 -1
  283. package/node-postgres/driver.d.cts +4 -6
  284. package/node-postgres/driver.d.ts +4 -6
  285. package/node-postgres/driver.js +4 -6
  286. package/node-postgres/driver.js.map +1 -1
  287. package/node-postgres/session.cjs +9 -18
  288. package/node-postgres/session.cjs.map +1 -1
  289. package/node-postgres/session.d.cts +4 -5
  290. package/node-postgres/session.d.ts +4 -5
  291. package/node-postgres/session.js +9 -18
  292. package/node-postgres/session.js.map +1 -1
  293. package/op-sqlite/driver.cjs +2 -3
  294. package/op-sqlite/driver.cjs.map +1 -1
  295. package/op-sqlite/driver.d.cts +1 -2
  296. package/op-sqlite/driver.d.ts +1 -2
  297. package/op-sqlite/driver.js +2 -3
  298. package/op-sqlite/driver.js.map +1 -1
  299. package/op-sqlite/session.cjs +11 -20
  300. package/op-sqlite/session.cjs.map +1 -1
  301. package/op-sqlite/session.d.cts +7 -8
  302. package/op-sqlite/session.d.ts +7 -8
  303. package/op-sqlite/session.js +11 -20
  304. package/op-sqlite/session.js.map +1 -1
  305. package/package.json +5 -351
  306. package/pg-core/columns/common.cjs +0 -2
  307. package/pg-core/columns/common.cjs.map +1 -1
  308. package/pg-core/columns/common.js +0 -2
  309. package/pg-core/columns/common.js.map +1 -1
  310. package/pg-core/db.cjs +3 -5
  311. package/pg-core/db.cjs.map +1 -1
  312. package/pg-core/db.d.cts +1 -3
  313. package/pg-core/db.d.ts +1 -3
  314. package/pg-core/db.js +3 -5
  315. package/pg-core/db.js.map +1 -1
  316. package/pg-core/dialect.cjs +19 -25
  317. package/pg-core/dialect.cjs.map +1 -1
  318. package/pg-core/dialect.d.cts +6 -7
  319. package/pg-core/dialect.d.ts +6 -7
  320. package/pg-core/dialect.js +20 -26
  321. package/pg-core/dialect.js.map +1 -1
  322. package/pg-core/query-builders/delete.cjs +5 -19
  323. package/pg-core/query-builders/delete.cjs.map +1 -1
  324. package/pg-core/query-builders/delete.js +5 -19
  325. package/pg-core/query-builders/delete.js.map +1 -1
  326. package/pg-core/query-builders/insert.cjs +9 -49
  327. package/pg-core/query-builders/insert.cjs.map +1 -1
  328. package/pg-core/query-builders/insert.js +11 -51
  329. package/pg-core/query-builders/insert.js.map +1 -1
  330. package/pg-core/query-builders/query.cjs +2 -15
  331. package/pg-core/query-builders/query.cjs.map +1 -1
  332. package/pg-core/query-builders/query.js +2 -15
  333. package/pg-core/query-builders/query.js.map +1 -1
  334. package/pg-core/query-builders/select.cjs +7 -23
  335. package/pg-core/query-builders/select.cjs.map +1 -1
  336. package/pg-core/query-builders/select.js +7 -23
  337. package/pg-core/query-builders/select.js.map +1 -1
  338. package/pg-core/query-builders/update.cjs +6 -20
  339. package/pg-core/query-builders/update.cjs.map +1 -1
  340. package/pg-core/query-builders/update.js +6 -20
  341. package/pg-core/query-builders/update.js.map +1 -1
  342. package/pg-core/session.cjs +4 -48
  343. package/pg-core/session.cjs.map +1 -1
  344. package/pg-core/session.d.cts +5 -11
  345. package/pg-core/session.d.ts +5 -11
  346. package/pg-core/session.js +4 -48
  347. package/pg-core/session.js.map +1 -1
  348. package/pg-proxy/driver.cjs +2 -3
  349. package/pg-proxy/driver.cjs.map +1 -1
  350. package/pg-proxy/driver.d.cts +1 -2
  351. package/pg-proxy/driver.d.ts +1 -2
  352. package/pg-proxy/driver.js +2 -3
  353. package/pg-proxy/driver.js.map +1 -1
  354. package/pg-proxy/session.cjs +6 -8
  355. package/pg-proxy/session.cjs.map +1 -1
  356. package/pg-proxy/session.d.cts +4 -5
  357. package/pg-proxy/session.d.ts +4 -5
  358. package/pg-proxy/session.js +6 -8
  359. package/pg-proxy/session.js.map +1 -1
  360. package/pglite/driver.cjs +4 -6
  361. package/pglite/driver.cjs.map +1 -1
  362. package/pglite/driver.d.cts +4 -6
  363. package/pglite/driver.d.ts +4 -6
  364. package/pglite/driver.js +4 -6
  365. package/pglite/driver.js.map +1 -1
  366. package/pglite/session.cjs +9 -19
  367. package/pglite/session.cjs.map +1 -1
  368. package/pglite/session.d.cts +4 -5
  369. package/pglite/session.d.ts +4 -5
  370. package/pglite/session.js +9 -19
  371. package/pglite/session.js.map +1 -1
  372. package/planetscale-serverless/driver.cjs +2 -10
  373. package/planetscale-serverless/driver.cjs.map +1 -1
  374. package/planetscale-serverless/driver.d.cts +3 -4
  375. package/planetscale-serverless/driver.d.ts +3 -4
  376. package/planetscale-serverless/driver.js +2 -10
  377. package/planetscale-serverless/driver.js.map +1 -1
  378. package/planetscale-serverless/session.cjs +13 -23
  379. package/planetscale-serverless/session.cjs.map +1 -1
  380. package/planetscale-serverless/session.d.cts +7 -6
  381. package/planetscale-serverless/session.d.ts +7 -6
  382. package/planetscale-serverless/session.js +13 -23
  383. package/planetscale-serverless/session.js.map +1 -1
  384. package/postgres-js/driver.cjs +2 -3
  385. package/postgres-js/driver.cjs.map +1 -1
  386. package/postgres-js/driver.d.cts +3 -4
  387. package/postgres-js/driver.d.ts +3 -4
  388. package/postgres-js/driver.js +2 -3
  389. package/postgres-js/driver.js.map +1 -1
  390. package/postgres-js/session.cjs +16 -27
  391. package/postgres-js/session.cjs.map +1 -1
  392. package/postgres-js/session.d.cts +5 -6
  393. package/postgres-js/session.d.ts +5 -6
  394. package/postgres-js/session.js +16 -27
  395. package/postgres-js/session.js.map +1 -1
  396. package/prisma/mysql/driver.cjs +3 -3
  397. package/prisma/mysql/driver.cjs.map +1 -1
  398. package/prisma/mysql/driver.d.cts +2 -3
  399. package/prisma/mysql/driver.d.ts +2 -3
  400. package/prisma/mysql/driver.js +3 -3
  401. package/prisma/mysql/driver.js.map +1 -1
  402. package/prisma/mysql/session.cjs +11 -10
  403. package/prisma/mysql/session.cjs.map +1 -1
  404. package/prisma/mysql/session.d.cts +5 -10
  405. package/prisma/mysql/session.d.ts +5 -10
  406. package/prisma/mysql/session.js +11 -10
  407. package/prisma/mysql/session.js.map +1 -1
  408. package/prisma/pg/driver.cjs +3 -3
  409. package/prisma/pg/driver.cjs.map +1 -1
  410. package/prisma/pg/driver.d.cts +1 -2
  411. package/prisma/pg/driver.d.ts +1 -2
  412. package/prisma/pg/driver.js +3 -3
  413. package/prisma/pg/driver.js.map +1 -1
  414. package/prisma/pg/session.cjs +7 -7
  415. package/prisma/pg/session.cjs.map +1 -1
  416. package/prisma/pg/session.d.cts +5 -10
  417. package/prisma/pg/session.d.ts +5 -10
  418. package/prisma/pg/session.js +7 -7
  419. package/prisma/pg/session.js.map +1 -1
  420. package/prisma/sqlite/driver.cjs +1 -7
  421. package/prisma/sqlite/driver.cjs.map +1 -1
  422. package/prisma/sqlite/driver.d.cts +1 -2
  423. package/prisma/sqlite/driver.d.ts +1 -2
  424. package/prisma/sqlite/driver.js +1 -7
  425. package/prisma/sqlite/driver.js.map +1 -1
  426. package/prisma/sqlite/session.cjs +10 -10
  427. package/prisma/sqlite/session.cjs.map +1 -1
  428. package/prisma/sqlite/session.d.cts +7 -12
  429. package/prisma/sqlite/session.d.ts +7 -12
  430. package/prisma/sqlite/session.js +10 -10
  431. package/prisma/sqlite/session.js.map +1 -1
  432. package/singlestore/driver.cjs +25 -34
  433. package/singlestore/driver.cjs.map +1 -1
  434. package/singlestore/driver.d.cts +2 -4
  435. package/singlestore/driver.d.ts +2 -4
  436. package/singlestore/driver.js +25 -34
  437. package/singlestore/driver.js.map +1 -1
  438. package/singlestore/session.cjs +10 -14
  439. package/singlestore/session.cjs.map +1 -1
  440. package/singlestore/session.d.cts +5 -5
  441. package/singlestore/session.d.ts +5 -5
  442. package/singlestore/session.js +10 -14
  443. package/singlestore/session.js.map +1 -1
  444. package/singlestore-core/db.cjs +3 -5
  445. package/singlestore-core/db.cjs.map +1 -1
  446. package/singlestore-core/db.d.cts +1 -3
  447. package/singlestore-core/db.d.ts +1 -3
  448. package/singlestore-core/db.js +3 -5
  449. package/singlestore-core/db.js.map +1 -1
  450. package/singlestore-core/dialect.cjs +18 -24
  451. package/singlestore-core/dialect.cjs.map +1 -1
  452. package/singlestore-core/dialect.d.cts +6 -7
  453. package/singlestore-core/dialect.d.ts +6 -7
  454. package/singlestore-core/dialect.js +19 -25
  455. package/singlestore-core/dialect.js.map +1 -1
  456. package/singlestore-core/query-builders/delete.cjs +1 -8
  457. package/singlestore-core/query-builders/delete.cjs.map +1 -1
  458. package/singlestore-core/query-builders/delete.js +1 -8
  459. package/singlestore-core/query-builders/delete.js.map +1 -1
  460. package/singlestore-core/query-builders/insert.cjs +5 -30
  461. package/singlestore-core/query-builders/insert.cjs.map +1 -1
  462. package/singlestore-core/query-builders/insert.js +7 -32
  463. package/singlestore-core/query-builders/insert.js.map +1 -1
  464. package/singlestore-core/query-builders/query.cjs +2 -17
  465. package/singlestore-core/query-builders/query.cjs.map +1 -1
  466. package/singlestore-core/query-builders/query.js +2 -17
  467. package/singlestore-core/query-builders/query.js.map +1 -1
  468. package/singlestore-core/query-builders/select.cjs +7 -24
  469. package/singlestore-core/query-builders/select.cjs.map +1 -1
  470. package/singlestore-core/query-builders/select.js +7 -24
  471. package/singlestore-core/query-builders/select.js.map +1 -1
  472. package/singlestore-core/query-builders/update.cjs +2 -9
  473. package/singlestore-core/query-builders/update.cjs.map +1 -1
  474. package/singlestore-core/query-builders/update.js +2 -9
  475. package/singlestore-core/query-builders/update.js.map +1 -1
  476. package/singlestore-core/session.cjs +4 -43
  477. package/singlestore-core/session.cjs.map +1 -1
  478. package/singlestore-core/session.d.cts +6 -14
  479. package/singlestore-core/session.d.ts +6 -14
  480. package/singlestore-core/session.js +4 -43
  481. package/singlestore-core/session.js.map +1 -1
  482. package/singlestore-proxy/driver.cjs +2 -3
  483. package/singlestore-proxy/driver.cjs.map +1 -1
  484. package/singlestore-proxy/driver.d.cts +1 -2
  485. package/singlestore-proxy/driver.d.ts +1 -2
  486. package/singlestore-proxy/driver.js +2 -3
  487. package/singlestore-proxy/driver.js.map +1 -1
  488. package/singlestore-proxy/session.cjs +8 -8
  489. package/singlestore-proxy/session.cjs.map +1 -1
  490. package/singlestore-proxy/session.d.cts +6 -9
  491. package/singlestore-proxy/session.d.ts +6 -9
  492. package/singlestore-proxy/session.js +8 -8
  493. package/singlestore-proxy/session.js.map +1 -1
  494. package/sql/sql.cjs +2 -24
  495. package/sql/sql.cjs.map +1 -1
  496. package/sql/sql.d.cts +0 -12
  497. package/sql/sql.d.ts +0 -12
  498. package/sql/sql.js +2 -23
  499. package/sql/sql.js.map +1 -1
  500. package/sql-js/driver.cjs.map +1 -1
  501. package/sql-js/driver.d.cts +1 -2
  502. package/sql-js/driver.d.ts +1 -2
  503. package/sql-js/driver.js.map +1 -1
  504. package/sql-js/session.cjs +4 -4
  505. package/sql-js/session.cjs.map +1 -1
  506. package/sql-js/session.d.cts +4 -4
  507. package/sql-js/session.d.ts +4 -4
  508. package/sql-js/session.js +4 -4
  509. package/sql-js/session.js.map +1 -1
  510. package/sqlite-core/db.cjs +3 -5
  511. package/sqlite-core/db.cjs.map +1 -1
  512. package/sqlite-core/db.d.cts +1 -3
  513. package/sqlite-core/db.d.ts +1 -3
  514. package/sqlite-core/db.js +3 -5
  515. package/sqlite-core/db.js.map +1 -1
  516. package/sqlite-core/dialect.cjs +19 -29
  517. package/sqlite-core/dialect.cjs.map +1 -1
  518. package/sqlite-core/dialect.d.cts +6 -7
  519. package/sqlite-core/dialect.d.ts +6 -7
  520. package/sqlite-core/dialect.js +20 -30
  521. package/sqlite-core/dialect.js.map +1 -1
  522. package/sqlite-core/query-builders/delete.cjs +1 -8
  523. package/sqlite-core/query-builders/delete.cjs.map +1 -1
  524. package/sqlite-core/query-builders/delete.js +1 -8
  525. package/sqlite-core/query-builders/delete.js.map +1 -1
  526. package/sqlite-core/query-builders/insert.cjs +4 -28
  527. package/sqlite-core/query-builders/insert.cjs.map +1 -1
  528. package/sqlite-core/query-builders/insert.js +6 -35
  529. package/sqlite-core/query-builders/insert.js.map +1 -1
  530. package/sqlite-core/query-builders/query.cjs +2 -15
  531. package/sqlite-core/query-builders/query.cjs.map +1 -1
  532. package/sqlite-core/query-builders/query.js +2 -15
  533. package/sqlite-core/query-builders/query.js.map +1 -1
  534. package/sqlite-core/query-builders/select.cjs +6 -15
  535. package/sqlite-core/query-builders/select.cjs.map +1 -1
  536. package/sqlite-core/query-builders/select.js +6 -15
  537. package/sqlite-core/query-builders/select.js.map +1 -1
  538. package/sqlite-core/query-builders/update.cjs +2 -9
  539. package/sqlite-core/query-builders/update.cjs.map +1 -1
  540. package/sqlite-core/query-builders/update.js +2 -9
  541. package/sqlite-core/query-builders/update.js.map +1 -1
  542. package/sqlite-core/session.cjs +6 -81
  543. package/sqlite-core/session.cjs.map +1 -1
  544. package/sqlite-core/session.d.cts +9 -19
  545. package/sqlite-core/session.d.ts +9 -19
  546. package/sqlite-core/session.js +6 -81
  547. package/sqlite-core/session.js.map +1 -1
  548. package/sqlite-proxy/driver.cjs +3 -4
  549. package/sqlite-proxy/driver.cjs.map +1 -1
  550. package/sqlite-proxy/driver.d.cts +2 -3
  551. package/sqlite-proxy/driver.d.ts +2 -3
  552. package/sqlite-proxy/driver.js +3 -4
  553. package/sqlite-proxy/driver.js.map +1 -1
  554. package/sqlite-proxy/session.cjs +11 -20
  555. package/sqlite-proxy/session.cjs.map +1 -1
  556. package/sqlite-proxy/session.d.cts +7 -8
  557. package/sqlite-proxy/session.d.ts +7 -8
  558. package/sqlite-proxy/session.js +11 -20
  559. package/sqlite-proxy/session.js.map +1 -1
  560. package/tidb-serverless/driver.cjs +2 -16
  561. package/tidb-serverless/driver.cjs.map +1 -1
  562. package/tidb-serverless/driver.d.cts +3 -4
  563. package/tidb-serverless/driver.d.ts +3 -4
  564. package/tidb-serverless/driver.js +2 -16
  565. package/tidb-serverless/driver.js.map +1 -1
  566. package/tidb-serverless/session.cjs +13 -23
  567. package/tidb-serverless/session.cjs.map +1 -1
  568. package/tidb-serverless/session.d.cts +7 -6
  569. package/tidb-serverless/session.d.ts +7 -6
  570. package/tidb-serverless/session.js +13 -23
  571. package/tidb-serverless/session.js.map +1 -1
  572. package/tracing.cjs.map +1 -1
  573. package/tracing.js.map +1 -1
  574. package/utils.cjs +2 -38
  575. package/utils.cjs.map +1 -1
  576. package/utils.d.cts +2 -6
  577. package/utils.d.ts +2 -6
  578. package/utils.js +4 -39
  579. package/utils.js.map +1 -1
  580. package/vercel-postgres/driver.cjs +5 -10
  581. package/vercel-postgres/driver.cjs.map +1 -1
  582. package/vercel-postgres/driver.d.cts +4 -6
  583. package/vercel-postgres/driver.d.ts +4 -6
  584. package/vercel-postgres/driver.js +5 -10
  585. package/vercel-postgres/driver.js.map +1 -1
  586. package/vercel-postgres/session.cjs +9 -18
  587. package/vercel-postgres/session.cjs.map +1 -1
  588. package/vercel-postgres/session.d.cts +4 -5
  589. package/vercel-postgres/session.d.ts +4 -5
  590. package/vercel-postgres/session.js +9 -18
  591. package/vercel-postgres/session.js.map +1 -1
  592. package/version.cjs +1 -1
  593. package/version.d.cts +1 -1
  594. package/version.d.ts +1 -1
  595. package/version.js +1 -1
  596. package/xata-http/driver.cjs +4 -7
  597. package/xata-http/driver.cjs.map +1 -1
  598. package/xata-http/driver.d.cts +2 -4
  599. package/xata-http/driver.d.ts +2 -4
  600. package/xata-http/driver.js +4 -7
  601. package/xata-http/driver.js.map +1 -1
  602. package/xata-http/session.cjs +6 -8
  603. package/xata-http/session.cjs.map +1 -1
  604. package/xata-http/session.d.cts +4 -5
  605. package/xata-http/session.d.ts +4 -5
  606. package/xata-http/session.js +6 -8
  607. package/xata-http/session.js.map +1 -1
  608. package/extension-core/gel/index.cjs +0 -33
  609. package/extension-core/gel/index.cjs.map +0 -1
  610. package/extension-core/gel/index.d.cts +0 -67
  611. package/extension-core/gel/index.d.ts +0 -67
  612. package/extension-core/gel/index.js +0 -9
  613. package/extension-core/gel/index.js.map +0 -1
  614. package/extension-core/index.cjs +0 -42
  615. package/extension-core/index.cjs.map +0 -1
  616. package/extension-core/index.d.cts +0 -9
  617. package/extension-core/index.d.ts +0 -9
  618. package/extension-core/index.js +0 -15
  619. package/extension-core/index.js.map +0 -1
  620. package/extension-core/mysql/index.cjs +0 -33
  621. package/extension-core/mysql/index.cjs.map +0 -1
  622. package/extension-core/mysql/index.d.cts +0 -69
  623. package/extension-core/mysql/index.d.ts +0 -69
  624. package/extension-core/mysql/index.js +0 -9
  625. package/extension-core/mysql/index.js.map +0 -1
  626. package/extension-core/pg/index.cjs +0 -33
  627. package/extension-core/pg/index.cjs.map +0 -1
  628. package/extension-core/pg/index.d.cts +0 -67
  629. package/extension-core/pg/index.d.ts +0 -67
  630. package/extension-core/pg/index.js +0 -9
  631. package/extension-core/pg/index.js.map +0 -1
  632. package/extension-core/singlestore/index.cjs +0 -33
  633. package/extension-core/singlestore/index.cjs.map +0 -1
  634. package/extension-core/singlestore/index.d.cts +0 -67
  635. package/extension-core/singlestore/index.d.ts +0 -67
  636. package/extension-core/singlestore/index.js +0 -9
  637. package/extension-core/singlestore/index.js.map +0 -1
  638. package/extension-core/sqlite/index.cjs +0 -33
  639. package/extension-core/sqlite/index.cjs.map +0 -1
  640. package/extension-core/sqlite/index.d.cts +0 -68
  641. package/extension-core/sqlite/index.d.ts +0 -68
  642. package/extension-core/sqlite/index.js +0 -9
  643. package/extension-core/sqlite/index.js.map +0 -1
  644. package/extensions/hook/gel/index.cjs +0 -47
  645. package/extensions/hook/gel/index.cjs.map +0 -1
  646. package/extensions/hook/gel/index.d.cts +0 -11
  647. package/extensions/hook/gel/index.d.ts +0 -11
  648. package/extensions/hook/gel/index.js +0 -22
  649. package/extensions/hook/gel/index.js.map +0 -1
  650. package/extensions/hook/mysql/index.cjs +0 -47
  651. package/extensions/hook/mysql/index.cjs.map +0 -1
  652. package/extensions/hook/mysql/index.d.cts +0 -11
  653. package/extensions/hook/mysql/index.d.ts +0 -11
  654. package/extensions/hook/mysql/index.js +0 -22
  655. package/extensions/hook/mysql/index.js.map +0 -1
  656. package/extensions/hook/pg/index.cjs +0 -47
  657. package/extensions/hook/pg/index.cjs.map +0 -1
  658. package/extensions/hook/pg/index.d.cts +0 -11
  659. package/extensions/hook/pg/index.d.ts +0 -11
  660. package/extensions/hook/pg/index.js +0 -22
  661. package/extensions/hook/pg/index.js.map +0 -1
  662. package/extensions/hook/singlestore/index.cjs +0 -47
  663. package/extensions/hook/singlestore/index.cjs.map +0 -1
  664. package/extensions/hook/singlestore/index.d.cts +0 -11
  665. package/extensions/hook/singlestore/index.d.ts +0 -11
  666. package/extensions/hook/singlestore/index.js +0 -22
  667. package/extensions/hook/singlestore/index.js.map +0 -1
  668. package/extensions/hook/sqlite/index.cjs +0 -47
  669. package/extensions/hook/sqlite/index.cjs.map +0 -1
  670. package/extensions/hook/sqlite/index.d.cts +0 -11
  671. package/extensions/hook/sqlite/index.d.ts +0 -11
  672. package/extensions/hook/sqlite/index.js +0 -22
  673. package/extensions/hook/sqlite/index.js.map +0 -1
  674. package/extensions/s3-file/common.cjs +0 -313
  675. package/extensions/s3-file/common.cjs.map +0 -1
  676. package/extensions/s3-file/common.d.cts +0 -88
  677. package/extensions/s3-file/common.d.ts +0 -88
  678. package/extensions/s3-file/common.js +0 -280
  679. package/extensions/s3-file/common.js.map +0 -1
  680. package/extensions/s3-file/gel/column.cjs +0 -113
  681. package/extensions/s3-file/gel/column.cjs.map +0 -1
  682. package/extensions/s3-file/gel/column.d.cts +0 -105
  683. package/extensions/s3-file/gel/column.d.ts +0 -105
  684. package/extensions/s3-file/gel/column.js +0 -92
  685. package/extensions/s3-file/gel/column.js.map +0 -1
  686. package/extensions/s3-file/gel/extension.cjs +0 -262
  687. package/extensions/s3-file/gel/extension.cjs.map +0 -1
  688. package/extensions/s3-file/gel/extension.d.cts +0 -18
  689. package/extensions/s3-file/gel/extension.d.ts +0 -18
  690. package/extensions/s3-file/gel/extension.js +0 -248
  691. package/extensions/s3-file/gel/extension.js.map +0 -1
  692. package/extensions/s3-file/gel/index.cjs +0 -25
  693. package/extensions/s3-file/gel/index.cjs.map +0 -1
  694. package/extensions/s3-file/gel/index.d.cts +0 -2
  695. package/extensions/s3-file/gel/index.d.ts +0 -2
  696. package/extensions/s3-file/gel/index.js +0 -3
  697. package/extensions/s3-file/gel/index.js.map +0 -1
  698. package/extensions/s3-file/index.cjs +0 -23
  699. package/extensions/s3-file/index.cjs.map +0 -1
  700. package/extensions/s3-file/index.d.cts +0 -1
  701. package/extensions/s3-file/index.d.ts +0 -1
  702. package/extensions/s3-file/index.js +0 -2
  703. package/extensions/s3-file/index.js.map +0 -1
  704. package/extensions/s3-file/mysql/column.cjs +0 -110
  705. package/extensions/s3-file/mysql/column.cjs.map +0 -1
  706. package/extensions/s3-file/mysql/column.d.cts +0 -63
  707. package/extensions/s3-file/mysql/column.d.ts +0 -63
  708. package/extensions/s3-file/mysql/column.js +0 -86
  709. package/extensions/s3-file/mysql/column.js.map +0 -1
  710. package/extensions/s3-file/mysql/extension.cjs +0 -242
  711. package/extensions/s3-file/mysql/extension.cjs.map +0 -1
  712. package/extensions/s3-file/mysql/extension.d.cts +0 -18
  713. package/extensions/s3-file/mysql/extension.d.ts +0 -18
  714. package/extensions/s3-file/mysql/extension.js +0 -228
  715. package/extensions/s3-file/mysql/extension.js.map +0 -1
  716. package/extensions/s3-file/mysql/index.cjs +0 -25
  717. package/extensions/s3-file/mysql/index.cjs.map +0 -1
  718. package/extensions/s3-file/mysql/index.d.cts +0 -2
  719. package/extensions/s3-file/mysql/index.d.ts +0 -2
  720. package/extensions/s3-file/mysql/index.js +0 -3
  721. package/extensions/s3-file/mysql/index.js.map +0 -1
  722. package/extensions/s3-file/pg/column.cjs +0 -113
  723. package/extensions/s3-file/pg/column.cjs.map +0 -1
  724. package/extensions/s3-file/pg/column.d.cts +0 -105
  725. package/extensions/s3-file/pg/column.d.ts +0 -105
  726. package/extensions/s3-file/pg/column.js +0 -92
  727. package/extensions/s3-file/pg/column.js.map +0 -1
  728. package/extensions/s3-file/pg/extension.cjs +0 -264
  729. package/extensions/s3-file/pg/extension.cjs.map +0 -1
  730. package/extensions/s3-file/pg/extension.d.cts +0 -18
  731. package/extensions/s3-file/pg/extension.d.ts +0 -18
  732. package/extensions/s3-file/pg/extension.js +0 -250
  733. package/extensions/s3-file/pg/extension.js.map +0 -1
  734. package/extensions/s3-file/pg/index.cjs +0 -25
  735. package/extensions/s3-file/pg/index.cjs.map +0 -1
  736. package/extensions/s3-file/pg/index.d.cts +0 -2
  737. package/extensions/s3-file/pg/index.d.ts +0 -2
  738. package/extensions/s3-file/pg/index.js +0 -3
  739. package/extensions/s3-file/pg/index.js.map +0 -1
  740. package/extensions/s3-file/singlestore/column.cjs +0 -110
  741. package/extensions/s3-file/singlestore/column.cjs.map +0 -1
  742. package/extensions/s3-file/singlestore/column.d.cts +0 -63
  743. package/extensions/s3-file/singlestore/column.d.ts +0 -63
  744. package/extensions/s3-file/singlestore/column.js +0 -86
  745. package/extensions/s3-file/singlestore/column.js.map +0 -1
  746. package/extensions/s3-file/singlestore/extension.cjs +0 -239
  747. package/extensions/s3-file/singlestore/extension.cjs.map +0 -1
  748. package/extensions/s3-file/singlestore/extension.d.cts +0 -18
  749. package/extensions/s3-file/singlestore/extension.d.ts +0 -18
  750. package/extensions/s3-file/singlestore/extension.js +0 -225
  751. package/extensions/s3-file/singlestore/extension.js.map +0 -1
  752. package/extensions/s3-file/singlestore/index.cjs +0 -25
  753. package/extensions/s3-file/singlestore/index.cjs.map +0 -1
  754. package/extensions/s3-file/singlestore/index.d.cts +0 -2
  755. package/extensions/s3-file/singlestore/index.d.ts +0 -2
  756. package/extensions/s3-file/singlestore/index.js +0 -3
  757. package/extensions/s3-file/singlestore/index.js.map +0 -1
  758. package/extensions/s3-file/sqlite/column.cjs +0 -110
  759. package/extensions/s3-file/sqlite/column.cjs.map +0 -1
  760. package/extensions/s3-file/sqlite/column.d.cts +0 -63
  761. package/extensions/s3-file/sqlite/column.d.ts +0 -63
  762. package/extensions/s3-file/sqlite/column.js +0 -86
  763. package/extensions/s3-file/sqlite/column.js.map +0 -1
  764. package/extensions/s3-file/sqlite/extension.cjs +0 -242
  765. package/extensions/s3-file/sqlite/extension.cjs.map +0 -1
  766. package/extensions/s3-file/sqlite/extension.d.cts +0 -18
  767. package/extensions/s3-file/sqlite/extension.d.ts +0 -18
  768. package/extensions/s3-file/sqlite/extension.js +0 -228
  769. package/extensions/s3-file/sqlite/extension.js.map +0 -1
  770. package/extensions/s3-file/sqlite/index.cjs +0 -25
  771. package/extensions/s3-file/sqlite/index.cjs.map +0 -1
  772. package/extensions/s3-file/sqlite/index.d.cts +0 -2
  773. package/extensions/s3-file/sqlite/index.d.ts +0 -2
  774. package/extensions/s3-file/sqlite/index.js +0 -3
  775. package/extensions/s3-file/sqlite/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/extensions/s3-file/common.ts"],"sourcesContent":["import { GetObjectCommand, PutObjectCommand, type S3Client } from '@aws-sdk/client-s3';\nimport type { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport { DrizzleError } from '~/errors.ts';\nimport type { ExtensionParam } from '~/sql/sql.ts';\nimport type { Simplify } from '~/utils.ts';\n\n// Local class, won't be used with `is` nor `instanceof`\n// eslint-disable-next-line drizzle-internal/require-entity-kind\nclass PresignerImporter {\n\tprivate static presignerImportSource: string = ['@aws', 'sdk/s3', 'request', 'presigner'].join('-');\n\tprivate static presigner: typeof getSignedUrl | undefined = undefined;\n\tconstructor() {}\n\n\tstatic async importPresigner(): Promise<typeof getSignedUrl> {\n\t\tif (this.presigner) return this.presigner;\n\n\t\tthis.presigner = await import(this.presignerImportSource).then((e) => e.getSignedUrl);\n\n\t\treturn this.presigner!;\n\t}\n}\n\nconst AsyncFunction = (async function() {}.constructor) as {\n\tnew(...args: string[]): (...args: any[]) => Promise<any>;\n\t(...args: string[]): (...args: any[]) => Promise<any>;\n};\n\nexport interface DecoderFunction {\n\t(\n\t\ts3: S3Client,\n\t\tdata: Record<string, unknown>[] | Record<string, unknown>,\n\t\terrors: unknown[],\n\t\tdownloader: typeof downloadFile,\n\t\tpresigner: typeof presignDownload,\n\t\tidGetter: typeof textToObjectId,\n\t): Promise<void>;\n}\n\nexport interface EncoderFunction {\n\t(\n\t\ts3: S3Client,\n\t\tplaceholders: Record<string, unknown> | undefined,\n\t\terrors: unknown[],\n\t\tuploader: typeof uploadFile,\n\t\tidBuilder: typeof objectIdToText,\n\t): Promise<void>;\n}\n\nconst buildFunctionArrayRecursion = (dimensions: number, body: string): string => {\n\tif (dimensions) {\n\t\treturn buildFunctionArrayRecursion(dimensions - 1, `arr?.forEach((arr, i${dimensions}) => ${body})`);\n\t}\n\n\treturn body;\n};\n\nconst buildArrayRecursionIndexAccess = (dimensions: number) => {\n\tlet idxs = '';\n\tfor (let idx = 1; idx <= dimensions; ++idx) {\n\t\tidxs = `${idxs}[i${idx}]`;\n\t}\n\treturn idxs;\n};\n\nconst formPresignerOptions = (options?: RequestPresigningArguments) => {\n\tif (!options) return 'undefined';\n\n\tconst fields = Object.entries(options).map(([k, v]) =>\n\t\t// eslint-disable-next-line no-instanceof/no-instanceof\n\t\t`${JSON.stringify(k)}: ${v instanceof Set ? `new Set(${JSON.stringify([...v])})` : JSON.stringify(v)}`\n\t).join(',\\n');\n\n\treturn `{${fields}}`;\n};\n\nexport const buildDecoderInner = (mappingInstructions: DrizzleS3FileOutputMappingInstruction[]): string => {\n\treturn mappingInstructions.map((i) => {\n\t\tconst path = i.path.join('');\n\t\tconst optPath = i.path.join('?.');\n\n\t\treturn `if(row${optPath}) {\\n` + (\n\t\t\t'subinstructions' in i\n\t\t\t\t? `row${path}.forEach(row => {\n\t\t\t${buildDecoderInner(i.subinstructions)} \n\t\t\t});`\n\t\t\t\t: i.arrayDimensions\n\t\t\t\t? `const arr = row${path};\n\t\t\t\t` + buildFunctionArrayRecursion(\n\t\t\t\t\ti.arrayDimensions,\n\t\t\t\t\t`p.push((async () => {\n\t\t\t\t\t\t\t\tif(!arr || typeof arr !== 'string') return;\n\n\t\t\t\t\t\t\t\tconst { key, bucket } = idGetter(arr);\n\t\t\t\t\t\t\t\trow${path}${buildArrayRecursionIndexAccess(i.arrayDimensions)} = await ${\n\t\t\t\t\t\ti.fetchMode === 'file' || i.fetchMode === 'data'\n\t\t\t\t\t\t\t? 'downloader'\n\t\t\t\t\t\t\t: 'presigner'\n\t\t\t\t\t}({ key, bucket, s3, mode: ${JSON.stringify(i.fileMode)}, fileOnly: ${\n\t\t\t\t\t\ti.fetchMode === 'data' ? 'true' : 'false'\n\t\t\t\t\t}, options: ${formPresignerOptions(i.options)}});\n\t\t\t\t\t\t})().catch((e) => errors.push(e)))`,\n\t\t\t\t)\n\t\t\t\t: `p.push((async () => {\n\t\t\t\t\t\tconst str = row${path};\n\t\t\t\t\t\tif(typeof str !== 'string') return;\n\n\t\t\t\t\t\tconst { key, bucket } = idGetter(str);\n\t\t\t\t\t\trow${path} = await ${\n\t\t\t\t\ti.fetchMode === 'file' || i.fetchMode === 'data'\n\t\t\t\t\t\t? 'downloader'\n\t\t\t\t\t\t: 'presigner'\n\t\t\t\t}({ key, bucket, s3, mode: ${JSON.stringify(i.fileMode)}, fileOnly: ${\n\t\t\t\t\ti.fetchMode === 'data' ? 'true' : 'false'\n\t\t\t\t}, options: ${formPresignerOptions(i.options)}});\n\t\t\t\t\t\t})().catch((e) => errors.push(e)));`\n\t\t) + `\n\t\t}`;\n\t}).join('\\n');\n};\n\nexport const buildDecoder = (\n\tmappingInstructions: DrizzleS3FileOutputMappingInstruction[],\n\tmode: 'first' | 'many' = 'many',\n): DecoderFunction => {\n\tif (!mappingInstructions.length) return () => undefined as any;\n\n\treturn new AsyncFunction(\n\t\t's3',\n\t\t'data',\n\t\t'errors',\n\t\t'downloader',\n\t\t'presigner',\n\t\t'idGetter',\n\t\tmode === 'many'\n\t\t\t? `\n\t\t\tawait Promise.all(data.reduce((p, row) => {\n\t\t\t${buildDecoderInner(mappingInstructions)}\n\t\t\treturn p;\n\t\t}, []));`\n\t\t\t: `\n\t\t\tconst p = [];\n\t\t\tconst row = data;\n\t\t\t${buildDecoderInner(mappingInstructions)}\n\t\t\tawait Promise.all(p);\n\t\t`,\n\t);\n};\n\nexport const buildEncoder = (mappingInstructions: DrizzleS3FilePlaceholderMappingInstruction[]): EncoderFunction => {\n\tif (!mappingInstructions.length) return () => undefined as any;\n\n\treturn new AsyncFunction(\n\t\t's3',\n\t\t'placeholders',\n\t\t'errors',\n\t\t'uploader',\n\t\t'idBuilder',\n\t\t`\n\t\t\tif(!placeholders) return;\n\t\t\tawait Promise.all([\n\t\t\t\t${\n\t\t\tmappingInstructions.map((i) => {\n\t\t\t\tconst path = `[${JSON.stringify(i.key)}]`;\n\n\t\t\t\treturn i.arrayDimensions\n\t\t\t\t\t? `...(() => {\n\t\t\t\t\t\tconst arr = placeholders${path};\n\t\t\t\t\t\tconst p = [];\n\t\t\t\t\t\t${\n\t\t\t\t\t\tbuildFunctionArrayRecursion(\n\t\t\t\t\t\t\ti.arrayDimensions,\n\t\t\t\t\t\t\t`p.push((async () => {\n\t\t\t\t\t\t\tif(!arr || typeof arr !== 'object') return;\n\n\t\t\t\t\t\t\tconst { key, bucket, data } = arr;\n\t\t\t\t\t\t\tawait uploader({ key, bucket, data, s3, mode: ${JSON.stringify(i.mode)} });\n\t\t\t\t\t\t\tplaceholders${path}${buildArrayRecursionIndexAccess(i.arrayDimensions)} = idBuilder(arr);\n\t\t\t\t\t\t})().catch((e) => errors.push(e)))`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\t\treturn p;\n\t\t\t\t\t})()`\n\t\t\t\t\t: `(async () => {\n\t\t\t\t\t\t\tconst params = placeholders${path};\n\t\t\t\t\t\t\tif(!params || typeof params !== 'object') return;\n\n\t\t\t\t\t\t\tconst { key, bucket, data } = params;\n\t\t\t\t\t\t\tawait uploader({ key, bucket, data, s3, mode: ${JSON.stringify(i.mode)} });\n\t\t\t\t\t\t\tplaceholders${path} = idBuilder(params);\n\t\t\t\t\t\t})().catch((e) => errors.push(e))`;\n\t\t\t}).join(',\\n')\n\t\t}\n\t\t\t]);\n\t\t`,\n\t);\n};\n\nexport type DrizzleS3FileMode = 'buffer' | 'hex' | 'base64' | 'uint8array';\n\nexport type DrizzleS3FileModeToData = {\n\tbuffer: Buffer;\n\thex: string;\n\tbase64: string;\n\tuint8array: Uint8Array;\n};\n\nexport type DrizzleS3FetchMode = 'file' | 'data' | 'presigned';\n\nexport type DrizzleS3FileOutputMappingInstructionNodeCommon = {\n\tpath: string[];\n};\nexport type DrizzleS3FileOutputMappingInstruction =\n\t| DrizzleS3FileOutputMappingInstructionIterableNode\n\t| DrizzleS3FileOutputMappingInstructionTerminalNode;\n\nexport type DrizzleS3FileOutputMappingInstructionTerminalNode =\n\t& DrizzleS3FileOutputMappingInstructionNodeCommon\n\t& {\n\t\tfileMode: DrizzleS3FileMode;\n\t\tfetchMode: DrizzleS3FetchMode;\n\t\toptions?: RequestPresigningArguments;\n\t\tarrayDimensions?: number;\n\t};\n\nexport type DrizzleS3FileOutputMappingInstructionIterableNode =\n\t& DrizzleS3FileOutputMappingInstructionNodeCommon\n\t& {\n\t\tsubinstructions: DrizzleS3FileOutputMappingInstruction[];\n\t};\n\nexport interface DrizzleS3FileInputMappingInstruction {\n\tmode: DrizzleS3FileMode;\n\tindex: number;\n\tarrayDimensions?: number;\n}\n\nexport interface DrizzleS3FilePlaceholderMappingInstruction {\n\tmode: DrizzleS3FileMode;\n\tkey: string;\n\tarrayDimensions?: number;\n}\n\nexport type RequestPresigningArguments = typeof getSignedUrl extends\n\t((client: any, command: any, options?: infer R) => any) ? R\n\t: Record<string, unknown>;\n\nexport interface DrizzleS3ObjectIdentification {\n\tkey: string;\n\tbucket: string;\n}\n\nexport interface S3ExtMeta {\n\tdecoder?: DecoderFunction;\n\tencoder?: EncoderFunction;\n}\n\nexport type DrizzleS3Object<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<\n\t& DrizzleS3ObjectIdentification\n\t& {\n\t\tdata: TData;\n\t}\n>;\n\nexport type DrizzleS3ObjectFile<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<\n\t& DrizzleS3ObjectIdentification\n\t& {\n\t\tdata: TData;\n\t}\n>;\n\n// export type DrizzleS3ObjectMeta = Simplify<\n// \t& DrizzleS3ObjectIdentification\n// \t& {\n// \t\tmeta?: Record<string, unknown>;\n// \t}\n// >;\n\nconst separator = ':';\n\nexport function objectIdToText({ key, bucket }: DrizzleS3ObjectIdentification): string {\n\treturn `${bucket}${separator}${key}`;\n}\n\nexport function textToObjectId(text: string): DrizzleS3ObjectIdentification {\n\tconst split = text.split(separator);\n\n\tif (split.length < 2) throw new Error(`Invalid S3 object identifier: \"${text}\". Expected: \"bucket${separator}key\"`);\n\n\tconst bucket = split.shift()!;\n\tconst key = split.join(separator);\n\n\treturn { key, bucket };\n}\n\nexport async function downloadFile(\n\t{ key, bucket, s3, mode, fileOnly }: {\n\t\tkey: string;\n\t\tbucket: string;\n\t\ts3: S3Client;\n\t\tmode: DrizzleS3FileMode;\n\t\tfileOnly?: boolean;\n\t},\n) {\n\tconst res = await s3.send(\n\t\tnew GetObjectCommand({\n\t\t\tBucket: bucket,\n\t\t\tKey: key,\n\t\t}),\n\t);\n\n\tif (!res.Body) {\n\t\tthrow new DrizzleError({\n\t\t\tmessage: `No data found in bucket \"${bucket}\" for key \"${key}\"`,\n\t\t});\n\t}\n\n\tlet data;\n\tswitch (mode) {\n\t\tcase 'uint8array': {\n\t\t\tdata = await res.Body.transformToByteArray();\n\t\t\tbreak;\n\t\t}\n\t\tcase 'buffer': {\n\t\t\tdata = Buffer.from(await res.Body.transformToByteArray());\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tdata = await res.Body.transformToString(mode);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn fileOnly ? data : {\n\t\tkey,\n\t\tbucket,\n\t\tdata,\n\t};\n}\n\n// export async function downloadFileMeta({ key, bucket, s3 }: { key: string; bucket: string; s3: S3Client }) {\n// \tconst { Metadata: meta } = await s3.send(\n// \t\tnew HeadObjectCommand({\n// \t\t\tBucket: bucket,\n// \t\t\tKey: key,\n// \t\t}),\n// \t);\n\n// \treturn {\n// \t\tkey,\n// \t\tbucket,\n// \t\tmeta,\n// \t};\n// }\n\nexport async function presignDownload(\n\t{ key, bucket, options, s3 }: { key: string; bucket: string; options?: RequestPresigningArguments; s3: S3Client },\n) {\n\tconst command = new GetObjectCommand({\n\t\tBucket: bucket,\n\t\tKey: key,\n\t});\n\n\tconst presigner = await PresignerImporter.importPresigner();\n\t// Types are compatible, errors seem to be caused by internal package or package resolution issues\n\tconst url = await presigner(s3 as any, command as any, options);\n\n\treturn url;\n}\n\nexport async function uploadFile(\n\t{ key, bucket, data, s3, mode }: {\n\t\tkey: string;\n\t\tbucket: string;\n\t\tdata: DrizzleS3Object['data'];\n\t\ts3: S3Client;\n\t\tmode: DrizzleS3FileMode;\n\t},\n) {\n\tlet body: Buffer | Uint8Array;\n\tswitch (mode) {\n\t\tcase 'uint8array':\n\t\tcase 'buffer': {\n\t\t\tbody = data as Buffer | Uint8Array;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'hex': {\n\t\t\tbody = Uint8Array.fromHex ? Uint8Array.fromHex(data as string) : Buffer.from(data as string, 'hex');\n\t\t\tbreak;\n\t\t}\n\t\tcase 'base64': {\n\t\t\tbody = Uint8Array.fromBase64 ? Uint8Array.fromBase64(data as string) : Buffer.from(data as string, 'base64');\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst res = await s3.send(\n\t\tnew PutObjectCommand({\n\t\t\tBucket: bucket,\n\t\t\tKey: key,\n\t\t\tBody: body,\n\t\t}),\n\t);\n\n\treturn res;\n}\n\ntype RecursiveArrayItem = DrizzleS3Object | RecursiveArrayItem[];\n\nexport function mapArrayParam(\n\ts3: S3Client,\n\titem: RecursiveArrayItem,\n\tdimensions: number,\n\tmode: DrizzleS3FileMode,\n\terrors: unknown[],\n\tpromises: Promise<unknown>[],\n) {\n\tif (dimensions > 1) {\n\t\tfor (const sub of item as Exclude<RecursiveArrayItem, DrizzleS3Object>) {\n\t\t\tmapArrayParam(s3, sub, dimensions - 1, mode, errors, promises);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tlet i = 0;\n\tfor (const param of item as (DrizzleS3Object | unknown)[]) {\n\t\tif (!param || typeof param !== 'object') {\n\t\t\t++i;\n\t\t\tcontinue;\n\t\t}\n\t\tconst obj = param as DrizzleS3Object;\n\n\t\tpromises.push(\n\t\t\t(async (i: number) => {\n\t\t\t\tawait uploadFile({\n\t\t\t\t\ts3: s3,\n\t\t\t\t\tkey: obj.key,\n\t\t\t\t\tbucket: obj.bucket,\n\t\t\t\t\tdata: obj.data,\n\t\t\t\t\tmode: mode,\n\t\t\t\t});\n\n\t\t\t\tconst value = objectIdToText(obj);\n\t\t\t\t(item as unknown[])[i] = value;\n\t\t\t})(i++).catch((e) => errors.push(e)),\n\t\t);\n\t}\n}\n\nexport async function mapParams(\n\ts3: S3Client,\n\tparams: unknown[],\n\tindexes: DrizzleS3FileInputMappingInstruction[],\n\terrors: unknown[],\n) {\n\tif (!indexes.length) return;\n\n\tconst arrayIdxs: number[] = [];\n\tawait Promise.all(\n\t\tindexes.reduce((p, { index, mode, arrayDimensions }) => {\n\t\t\tconst { value: param } = params![index]! as ExtensionParam<DrizzleS3Object, string>;\n\n\t\t\tif (arrayDimensions) {\n\t\t\t\tmapArrayParam(s3, param, arrayDimensions, mode, errors, p);\n\t\t\t\tarrayIdxs.push(index);\n\n\t\t\t\treturn p;\n\t\t\t}\n\n\t\t\tif (!param || typeof param !== 'object') return p;\n\n\t\t\tp.push(\n\t\t\t\t(async (i: number) => {\n\t\t\t\t\tawait uploadFile({\n\t\t\t\t\t\ts3: s3,\n\t\t\t\t\t\tkey: param.key,\n\t\t\t\t\t\tbucket: param.bucket,\n\t\t\t\t\t\tdata: param.data,\n\t\t\t\t\t\tmode: mode,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst value = objectIdToText(param);\n\t\t\t\t\tparams![i] = value;\n\t\t\t\t})(index).catch((e) => errors.push(e)),\n\t\t\t);\n\n\t\t\treturn p;\n\t\t}, [] as Promise<unknown>[]),\n\t);\n\n\tfor (const idx of arrayIdxs) {\n\t\tparams[idx] = (<ExtensionParam<any[]>> params[idx]).value\n\t\t\t? (<ExtensionParam> params[idx]).encoder.mapToDriverValue(\n\t\t\t\t(<ExtensionParam<any[]>> params[idx]).value,\n\t\t\t)\n\t\t\t: params[idx];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAkE;AAElE,oBAA6B;AAM7B,MAAM,kBAAkB;AAAA,EACvB,OAAe,wBAAgC,CAAC,QAAQ,UAAU,WAAW,WAAW,EAAE,KAAK,GAAG;AAAA,EAClG,OAAe,YAA6C;AAAA,EAC5D,cAAc;AAAA,EAAC;AAAA,EAEf,aAAa,kBAAgD;AAC5D,QAAI,KAAK,UAAW,QAAO,KAAK;AA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D;","names":["i"]}
@@ -1,88 +0,0 @@
1
- import { type S3Client } from '@aws-sdk/client-s3';
2
- import type { getSignedUrl } from '@aws-sdk/s3-request-presigner';
3
- import type { Simplify } from "../../utils.cjs";
4
- export interface DecoderFunction {
5
- (s3: S3Client, data: Record<string, unknown>[] | Record<string, unknown>, errors: unknown[], downloader: typeof downloadFile, presigner: typeof presignDownload, idGetter: typeof textToObjectId): Promise<void>;
6
- }
7
- export interface EncoderFunction {
8
- (s3: S3Client, placeholders: Record<string, unknown> | undefined, errors: unknown[], uploader: typeof uploadFile, idBuilder: typeof objectIdToText): Promise<void>;
9
- }
10
- export declare const buildDecoderInner: (mappingInstructions: DrizzleS3FileOutputMappingInstruction[]) => string;
11
- export declare const buildDecoder: (mappingInstructions: DrizzleS3FileOutputMappingInstruction[], mode?: "first" | "many") => DecoderFunction;
12
- export declare const buildEncoder: (mappingInstructions: DrizzleS3FilePlaceholderMappingInstruction[]) => EncoderFunction;
13
- export type DrizzleS3FileMode = 'buffer' | 'hex' | 'base64' | 'uint8array';
14
- export type DrizzleS3FileModeToData = {
15
- buffer: Buffer;
16
- hex: string;
17
- base64: string;
18
- uint8array: Uint8Array;
19
- };
20
- export type DrizzleS3FetchMode = 'file' | 'data' | 'presigned';
21
- export type DrizzleS3FileOutputMappingInstructionNodeCommon = {
22
- path: string[];
23
- };
24
- export type DrizzleS3FileOutputMappingInstruction = DrizzleS3FileOutputMappingInstructionIterableNode | DrizzleS3FileOutputMappingInstructionTerminalNode;
25
- export type DrizzleS3FileOutputMappingInstructionTerminalNode = DrizzleS3FileOutputMappingInstructionNodeCommon & {
26
- fileMode: DrizzleS3FileMode;
27
- fetchMode: DrizzleS3FetchMode;
28
- options?: RequestPresigningArguments;
29
- arrayDimensions?: number;
30
- };
31
- export type DrizzleS3FileOutputMappingInstructionIterableNode = DrizzleS3FileOutputMappingInstructionNodeCommon & {
32
- subinstructions: DrizzleS3FileOutputMappingInstruction[];
33
- };
34
- export interface DrizzleS3FileInputMappingInstruction {
35
- mode: DrizzleS3FileMode;
36
- index: number;
37
- arrayDimensions?: number;
38
- }
39
- export interface DrizzleS3FilePlaceholderMappingInstruction {
40
- mode: DrizzleS3FileMode;
41
- key: string;
42
- arrayDimensions?: number;
43
- }
44
- export type RequestPresigningArguments = typeof getSignedUrl extends ((client: any, command: any, options?: infer R) => any) ? R : Record<string, unknown>;
45
- export interface DrizzleS3ObjectIdentification {
46
- key: string;
47
- bucket: string;
48
- }
49
- export interface S3ExtMeta {
50
- decoder?: DecoderFunction;
51
- encoder?: EncoderFunction;
52
- }
53
- export type DrizzleS3Object<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<DrizzleS3ObjectIdentification & {
54
- data: TData;
55
- }>;
56
- export type DrizzleS3ObjectFile<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<DrizzleS3ObjectIdentification & {
57
- data: TData;
58
- }>;
59
- export declare function objectIdToText({ key, bucket }: DrizzleS3ObjectIdentification): string;
60
- export declare function textToObjectId(text: string): DrizzleS3ObjectIdentification;
61
- export declare function downloadFile({ key, bucket, s3, mode, fileOnly }: {
62
- key: string;
63
- bucket: string;
64
- s3: S3Client;
65
- mode: DrizzleS3FileMode;
66
- fileOnly?: boolean;
67
- }): Promise<string | Uint8Array | Buffer | {
68
- key: string;
69
- bucket: string;
70
- data: string | Uint8Array | Buffer;
71
- }>;
72
- export declare function presignDownload({ key, bucket, options, s3 }: {
73
- key: string;
74
- bucket: string;
75
- options?: RequestPresigningArguments;
76
- s3: S3Client;
77
- }): Promise<string>;
78
- export declare function uploadFile({ key, bucket, data, s3, mode }: {
79
- key: string;
80
- bucket: string;
81
- data: DrizzleS3Object['data'];
82
- s3: S3Client;
83
- mode: DrizzleS3FileMode;
84
- }): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput>;
85
- type RecursiveArrayItem = DrizzleS3Object | RecursiveArrayItem[];
86
- export declare function mapArrayParam(s3: S3Client, item: RecursiveArrayItem, dimensions: number, mode: DrizzleS3FileMode, errors: unknown[], promises: Promise<unknown>[]): void;
87
- export declare function mapParams(s3: S3Client, params: unknown[], indexes: DrizzleS3FileInputMappingInstruction[], errors: unknown[]): Promise<void>;
88
- export {};
@@ -1,88 +0,0 @@
1
- import { type S3Client } from '@aws-sdk/client-s3';
2
- import type { getSignedUrl } from '@aws-sdk/s3-request-presigner';
3
- import type { Simplify } from "../../utils.js";
4
- export interface DecoderFunction {
5
- (s3: S3Client, data: Record<string, unknown>[] | Record<string, unknown>, errors: unknown[], downloader: typeof downloadFile, presigner: typeof presignDownload, idGetter: typeof textToObjectId): Promise<void>;
6
- }
7
- export interface EncoderFunction {
8
- (s3: S3Client, placeholders: Record<string, unknown> | undefined, errors: unknown[], uploader: typeof uploadFile, idBuilder: typeof objectIdToText): Promise<void>;
9
- }
10
- export declare const buildDecoderInner: (mappingInstructions: DrizzleS3FileOutputMappingInstruction[]) => string;
11
- export declare const buildDecoder: (mappingInstructions: DrizzleS3FileOutputMappingInstruction[], mode?: "first" | "many") => DecoderFunction;
12
- export declare const buildEncoder: (mappingInstructions: DrizzleS3FilePlaceholderMappingInstruction[]) => EncoderFunction;
13
- export type DrizzleS3FileMode = 'buffer' | 'hex' | 'base64' | 'uint8array';
14
- export type DrizzleS3FileModeToData = {
15
- buffer: Buffer;
16
- hex: string;
17
- base64: string;
18
- uint8array: Uint8Array;
19
- };
20
- export type DrizzleS3FetchMode = 'file' | 'data' | 'presigned';
21
- export type DrizzleS3FileOutputMappingInstructionNodeCommon = {
22
- path: string[];
23
- };
24
- export type DrizzleS3FileOutputMappingInstruction = DrizzleS3FileOutputMappingInstructionIterableNode | DrizzleS3FileOutputMappingInstructionTerminalNode;
25
- export type DrizzleS3FileOutputMappingInstructionTerminalNode = DrizzleS3FileOutputMappingInstructionNodeCommon & {
26
- fileMode: DrizzleS3FileMode;
27
- fetchMode: DrizzleS3FetchMode;
28
- options?: RequestPresigningArguments;
29
- arrayDimensions?: number;
30
- };
31
- export type DrizzleS3FileOutputMappingInstructionIterableNode = DrizzleS3FileOutputMappingInstructionNodeCommon & {
32
- subinstructions: DrizzleS3FileOutputMappingInstruction[];
33
- };
34
- export interface DrizzleS3FileInputMappingInstruction {
35
- mode: DrizzleS3FileMode;
36
- index: number;
37
- arrayDimensions?: number;
38
- }
39
- export interface DrizzleS3FilePlaceholderMappingInstruction {
40
- mode: DrizzleS3FileMode;
41
- key: string;
42
- arrayDimensions?: number;
43
- }
44
- export type RequestPresigningArguments = typeof getSignedUrl extends ((client: any, command: any, options?: infer R) => any) ? R : Record<string, unknown>;
45
- export interface DrizzleS3ObjectIdentification {
46
- key: string;
47
- bucket: string;
48
- }
49
- export interface S3ExtMeta {
50
- decoder?: DecoderFunction;
51
- encoder?: EncoderFunction;
52
- }
53
- export type DrizzleS3Object<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<DrizzleS3ObjectIdentification & {
54
- data: TData;
55
- }>;
56
- export type DrizzleS3ObjectFile<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<DrizzleS3ObjectIdentification & {
57
- data: TData;
58
- }>;
59
- export declare function objectIdToText({ key, bucket }: DrizzleS3ObjectIdentification): string;
60
- export declare function textToObjectId(text: string): DrizzleS3ObjectIdentification;
61
- export declare function downloadFile({ key, bucket, s3, mode, fileOnly }: {
62
- key: string;
63
- bucket: string;
64
- s3: S3Client;
65
- mode: DrizzleS3FileMode;
66
- fileOnly?: boolean;
67
- }): Promise<string | Uint8Array | Buffer | {
68
- key: string;
69
- bucket: string;
70
- data: string | Uint8Array | Buffer;
71
- }>;
72
- export declare function presignDownload({ key, bucket, options, s3 }: {
73
- key: string;
74
- bucket: string;
75
- options?: RequestPresigningArguments;
76
- s3: S3Client;
77
- }): Promise<string>;
78
- export declare function uploadFile({ key, bucket, data, s3, mode }: {
79
- key: string;
80
- bucket: string;
81
- data: DrizzleS3Object['data'];
82
- s3: S3Client;
83
- mode: DrizzleS3FileMode;
84
- }): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput>;
85
- type RecursiveArrayItem = DrizzleS3Object | RecursiveArrayItem[];
86
- export declare function mapArrayParam(s3: S3Client, item: RecursiveArrayItem, dimensions: number, mode: DrizzleS3FileMode, errors: unknown[], promises: Promise<unknown>[]): void;
87
- export declare function mapParams(s3: S3Client, params: unknown[], indexes: DrizzleS3FileInputMappingInstruction[], errors: unknown[]): Promise<void>;
88
- export {};
@@ -1,280 +0,0 @@
1
- import { GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
2
- import { DrizzleError } from "../../errors.js";
3
- class PresignerImporter {
4
- static presignerImportSource = ["@aws", "sdk/s3", "request", "presigner"].join("-");
5
- static presigner = void 0;
6
- constructor() {
7
- }
8
- static async importPresigner() {
9
- if (this.presigner) return this.presigner;
10
- this.presigner = await import(this.presignerImportSource).then((e) => e.getSignedUrl);
11
- return this.presigner;
12
- }
13
- }
14
- const AsyncFunction = async function() {
15
- }.constructor;
16
- const buildFunctionArrayRecursion = (dimensions, body) => {
17
- if (dimensions) {
18
- return buildFunctionArrayRecursion(dimensions - 1, `arr?.forEach((arr, i${dimensions}) => ${body})`);
19
- }
20
- return body;
21
- };
22
- const buildArrayRecursionIndexAccess = (dimensions) => {
23
- let idxs = "";
24
- for (let idx = 1; idx <= dimensions; ++idx) {
25
- idxs = `${idxs}[i${idx}]`;
26
- }
27
- return idxs;
28
- };
29
- const formPresignerOptions = (options) => {
30
- if (!options) return "undefined";
31
- const fields = Object.entries(options).map(
32
- ([k, v]) => (
33
- // eslint-disable-next-line no-instanceof/no-instanceof
34
- (`${JSON.stringify(k)}: ${v instanceof Set ? `new Set(${JSON.stringify([...v])})` : JSON.stringify(v)}`)
35
- )
36
- ).join(",\n");
37
- return `{${fields}}`;
38
- };
39
- const buildDecoderInner = (mappingInstructions) => {
40
- return mappingInstructions.map((i) => {
41
- const path = i.path.join("");
42
- const optPath = i.path.join("?.");
43
- return `if(row${optPath}) {
44
- ` + ("subinstructions" in i ? `row${path}.forEach(row => {
45
- ${buildDecoderInner(i.subinstructions)}
46
- });` : i.arrayDimensions ? `const arr = row${path};
47
- ` + buildFunctionArrayRecursion(
48
- i.arrayDimensions,
49
- `p.push((async () => {
50
- if(!arr || typeof arr !== 'string') return;
51
-
52
- const { key, bucket } = idGetter(arr);
53
- row${path}${buildArrayRecursionIndexAccess(i.arrayDimensions)} = await ${i.fetchMode === "file" || i.fetchMode === "data" ? "downloader" : "presigner"}({ key, bucket, s3, mode: ${JSON.stringify(i.fileMode)}, fileOnly: ${i.fetchMode === "data" ? "true" : "false"}, options: ${formPresignerOptions(i.options)}});
54
- })().catch((e) => errors.push(e)))`
55
- ) : `p.push((async () => {
56
- const str = row${path};
57
- if(typeof str !== 'string') return;
58
-
59
- const { key, bucket } = idGetter(str);
60
- row${path} = await ${i.fetchMode === "file" || i.fetchMode === "data" ? "downloader" : "presigner"}({ key, bucket, s3, mode: ${JSON.stringify(i.fileMode)}, fileOnly: ${i.fetchMode === "data" ? "true" : "false"}, options: ${formPresignerOptions(i.options)}});
61
- })().catch((e) => errors.push(e)));`) + `
62
- }`;
63
- }).join("\n");
64
- };
65
- const buildDecoder = (mappingInstructions, mode = "many") => {
66
- if (!mappingInstructions.length) return () => void 0;
67
- return new AsyncFunction(
68
- "s3",
69
- "data",
70
- "errors",
71
- "downloader",
72
- "presigner",
73
- "idGetter",
74
- mode === "many" ? `
75
- await Promise.all(data.reduce((p, row) => {
76
- ${buildDecoderInner(mappingInstructions)}
77
- return p;
78
- }, []));` : `
79
- const p = [];
80
- const row = data;
81
- ${buildDecoderInner(mappingInstructions)}
82
- await Promise.all(p);
83
- `
84
- );
85
- };
86
- const buildEncoder = (mappingInstructions) => {
87
- if (!mappingInstructions.length) return () => void 0;
88
- return new AsyncFunction(
89
- "s3",
90
- "placeholders",
91
- "errors",
92
- "uploader",
93
- "idBuilder",
94
- `
95
- if(!placeholders) return;
96
- await Promise.all([
97
- ${mappingInstructions.map((i) => {
98
- const path = `[${JSON.stringify(i.key)}]`;
99
- return i.arrayDimensions ? `...(() => {
100
- const arr = placeholders${path};
101
- const p = [];
102
- ${buildFunctionArrayRecursion(
103
- i.arrayDimensions,
104
- `p.push((async () => {
105
- if(!arr || typeof arr !== 'object') return;
106
-
107
- const { key, bucket, data } = arr;
108
- await uploader({ key, bucket, data, s3, mode: ${JSON.stringify(i.mode)} });
109
- placeholders${path}${buildArrayRecursionIndexAccess(i.arrayDimensions)} = idBuilder(arr);
110
- })().catch((e) => errors.push(e)))`
111
- )}
112
- return p;
113
- })()` : `(async () => {
114
- const params = placeholders${path};
115
- if(!params || typeof params !== 'object') return;
116
-
117
- const { key, bucket, data } = params;
118
- await uploader({ key, bucket, data, s3, mode: ${JSON.stringify(i.mode)} });
119
- placeholders${path} = idBuilder(params);
120
- })().catch((e) => errors.push(e))`;
121
- }).join(",\n")}
122
- ]);
123
- `
124
- );
125
- };
126
- const separator = ":";
127
- function objectIdToText({ key, bucket }) {
128
- return `${bucket}${separator}${key}`;
129
- }
130
- function textToObjectId(text) {
131
- const split = text.split(separator);
132
- if (split.length < 2) throw new Error(`Invalid S3 object identifier: "${text}". Expected: "bucket${separator}key"`);
133
- const bucket = split.shift();
134
- const key = split.join(separator);
135
- return { key, bucket };
136
- }
137
- async function downloadFile({ key, bucket, s3, mode, fileOnly }) {
138
- const res = await s3.send(
139
- new GetObjectCommand({
140
- Bucket: bucket,
141
- Key: key
142
- })
143
- );
144
- if (!res.Body) {
145
- throw new DrizzleError({
146
- message: `No data found in bucket "${bucket}" for key "${key}"`
147
- });
148
- }
149
- let data;
150
- switch (mode) {
151
- case "uint8array": {
152
- data = await res.Body.transformToByteArray();
153
- break;
154
- }
155
- case "buffer": {
156
- data = Buffer.from(await res.Body.transformToByteArray());
157
- break;
158
- }
159
- default: {
160
- data = await res.Body.transformToString(mode);
161
- break;
162
- }
163
- }
164
- return fileOnly ? data : {
165
- key,
166
- bucket,
167
- data
168
- };
169
- }
170
- async function presignDownload({ key, bucket, options, s3 }) {
171
- const command = new GetObjectCommand({
172
- Bucket: bucket,
173
- Key: key
174
- });
175
- const presigner = await PresignerImporter.importPresigner();
176
- const url = await presigner(s3, command, options);
177
- return url;
178
- }
179
- async function uploadFile({ key, bucket, data, s3, mode }) {
180
- let body;
181
- switch (mode) {
182
- case "uint8array":
183
- case "buffer": {
184
- body = data;
185
- break;
186
- }
187
- case "hex": {
188
- body = Uint8Array.fromHex ? Uint8Array.fromHex(data) : Buffer.from(data, "hex");
189
- break;
190
- }
191
- case "base64": {
192
- body = Uint8Array.fromBase64 ? Uint8Array.fromBase64(data) : Buffer.from(data, "base64");
193
- break;
194
- }
195
- }
196
- const res = await s3.send(
197
- new PutObjectCommand({
198
- Bucket: bucket,
199
- Key: key,
200
- Body: body
201
- })
202
- );
203
- return res;
204
- }
205
- function mapArrayParam(s3, item, dimensions, mode, errors, promises) {
206
- if (dimensions > 1) {
207
- for (const sub of item) {
208
- mapArrayParam(s3, sub, dimensions - 1, mode, errors, promises);
209
- }
210
- return;
211
- }
212
- let i = 0;
213
- for (const param of item) {
214
- if (!param || typeof param !== "object") {
215
- ++i;
216
- continue;
217
- }
218
- const obj = param;
219
- promises.push(
220
- (async (i2) => {
221
- await uploadFile({
222
- s3,
223
- key: obj.key,
224
- bucket: obj.bucket,
225
- data: obj.data,
226
- mode
227
- });
228
- const value = objectIdToText(obj);
229
- item[i2] = value;
230
- })(i++).catch((e) => errors.push(e))
231
- );
232
- }
233
- }
234
- async function mapParams(s3, params, indexes, errors) {
235
- if (!indexes.length) return;
236
- const arrayIdxs = [];
237
- await Promise.all(
238
- indexes.reduce((p, { index, mode, arrayDimensions }) => {
239
- const { value: param } = params[index];
240
- if (arrayDimensions) {
241
- mapArrayParam(s3, param, arrayDimensions, mode, errors, p);
242
- arrayIdxs.push(index);
243
- return p;
244
- }
245
- if (!param || typeof param !== "object") return p;
246
- p.push(
247
- (async (i) => {
248
- await uploadFile({
249
- s3,
250
- key: param.key,
251
- bucket: param.bucket,
252
- data: param.data,
253
- mode
254
- });
255
- const value = objectIdToText(param);
256
- params[i] = value;
257
- })(index).catch((e) => errors.push(e))
258
- );
259
- return p;
260
- }, [])
261
- );
262
- for (const idx of arrayIdxs) {
263
- params[idx] = params[idx].value ? params[idx].encoder.mapToDriverValue(
264
- params[idx].value
265
- ) : params[idx];
266
- }
267
- }
268
- export {
269
- buildDecoder,
270
- buildDecoderInner,
271
- buildEncoder,
272
- downloadFile,
273
- mapArrayParam,
274
- mapParams,
275
- objectIdToText,
276
- presignDownload,
277
- textToObjectId,
278
- uploadFile
279
- };
280
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/extensions/s3-file/common.ts"],"sourcesContent":["import { GetObjectCommand, PutObjectCommand, type S3Client } from '@aws-sdk/client-s3';\nimport type { getSignedUrl } from '@aws-sdk/s3-request-presigner';\nimport { DrizzleError } from '~/errors.ts';\nimport type { ExtensionParam } from '~/sql/sql.ts';\nimport type { Simplify } from '~/utils.ts';\n\n// Local class, won't be used with `is` nor `instanceof`\n// eslint-disable-next-line drizzle-internal/require-entity-kind\nclass PresignerImporter {\n\tprivate static presignerImportSource: string = ['@aws', 'sdk/s3', 'request', 'presigner'].join('-');\n\tprivate static presigner: typeof getSignedUrl | undefined = undefined;\n\tconstructor() {}\n\n\tstatic async importPresigner(): Promise<typeof getSignedUrl> {\n\t\tif (this.presigner) return this.presigner;\n\n\t\tthis.presigner = await import(this.presignerImportSource).then((e) => e.getSignedUrl);\n\n\t\treturn this.presigner!;\n\t}\n}\n\nconst AsyncFunction = (async function() {}.constructor) as {\n\tnew(...args: string[]): (...args: any[]) => Promise<any>;\n\t(...args: string[]): (...args: any[]) => Promise<any>;\n};\n\nexport interface DecoderFunction {\n\t(\n\t\ts3: S3Client,\n\t\tdata: Record<string, unknown>[] | Record<string, unknown>,\n\t\terrors: unknown[],\n\t\tdownloader: typeof downloadFile,\n\t\tpresigner: typeof presignDownload,\n\t\tidGetter: typeof textToObjectId,\n\t): Promise<void>;\n}\n\nexport interface EncoderFunction {\n\t(\n\t\ts3: S3Client,\n\t\tplaceholders: Record<string, unknown> | undefined,\n\t\terrors: unknown[],\n\t\tuploader: typeof uploadFile,\n\t\tidBuilder: typeof objectIdToText,\n\t): Promise<void>;\n}\n\nconst buildFunctionArrayRecursion = (dimensions: number, body: string): string => {\n\tif (dimensions) {\n\t\treturn buildFunctionArrayRecursion(dimensions - 1, `arr?.forEach((arr, i${dimensions}) => ${body})`);\n\t}\n\n\treturn body;\n};\n\nconst buildArrayRecursionIndexAccess = (dimensions: number) => {\n\tlet idxs = '';\n\tfor (let idx = 1; idx <= dimensions; ++idx) {\n\t\tidxs = `${idxs}[i${idx}]`;\n\t}\n\treturn idxs;\n};\n\nconst formPresignerOptions = (options?: RequestPresigningArguments) => {\n\tif (!options) return 'undefined';\n\n\tconst fields = Object.entries(options).map(([k, v]) =>\n\t\t// eslint-disable-next-line no-instanceof/no-instanceof\n\t\t`${JSON.stringify(k)}: ${v instanceof Set ? `new Set(${JSON.stringify([...v])})` : JSON.stringify(v)}`\n\t).join(',\\n');\n\n\treturn `{${fields}}`;\n};\n\nexport const buildDecoderInner = (mappingInstructions: DrizzleS3FileOutputMappingInstruction[]): string => {\n\treturn mappingInstructions.map((i) => {\n\t\tconst path = i.path.join('');\n\t\tconst optPath = i.path.join('?.');\n\n\t\treturn `if(row${optPath}) {\\n` + (\n\t\t\t'subinstructions' in i\n\t\t\t\t? `row${path}.forEach(row => {\n\t\t\t${buildDecoderInner(i.subinstructions)} \n\t\t\t});`\n\t\t\t\t: i.arrayDimensions\n\t\t\t\t? `const arr = row${path};\n\t\t\t\t` + buildFunctionArrayRecursion(\n\t\t\t\t\ti.arrayDimensions,\n\t\t\t\t\t`p.push((async () => {\n\t\t\t\t\t\t\t\tif(!arr || typeof arr !== 'string') return;\n\n\t\t\t\t\t\t\t\tconst { key, bucket } = idGetter(arr);\n\t\t\t\t\t\t\t\trow${path}${buildArrayRecursionIndexAccess(i.arrayDimensions)} = await ${\n\t\t\t\t\t\ti.fetchMode === 'file' || i.fetchMode === 'data'\n\t\t\t\t\t\t\t? 'downloader'\n\t\t\t\t\t\t\t: 'presigner'\n\t\t\t\t\t}({ key, bucket, s3, mode: ${JSON.stringify(i.fileMode)}, fileOnly: ${\n\t\t\t\t\t\ti.fetchMode === 'data' ? 'true' : 'false'\n\t\t\t\t\t}, options: ${formPresignerOptions(i.options)}});\n\t\t\t\t\t\t})().catch((e) => errors.push(e)))`,\n\t\t\t\t)\n\t\t\t\t: `p.push((async () => {\n\t\t\t\t\t\tconst str = row${path};\n\t\t\t\t\t\tif(typeof str !== 'string') return;\n\n\t\t\t\t\t\tconst { key, bucket } = idGetter(str);\n\t\t\t\t\t\trow${path} = await ${\n\t\t\t\t\ti.fetchMode === 'file' || i.fetchMode === 'data'\n\t\t\t\t\t\t? 'downloader'\n\t\t\t\t\t\t: 'presigner'\n\t\t\t\t}({ key, bucket, s3, mode: ${JSON.stringify(i.fileMode)}, fileOnly: ${\n\t\t\t\t\ti.fetchMode === 'data' ? 'true' : 'false'\n\t\t\t\t}, options: ${formPresignerOptions(i.options)}});\n\t\t\t\t\t\t})().catch((e) => errors.push(e)));`\n\t\t) + `\n\t\t}`;\n\t}).join('\\n');\n};\n\nexport const buildDecoder = (\n\tmappingInstructions: DrizzleS3FileOutputMappingInstruction[],\n\tmode: 'first' | 'many' = 'many',\n): DecoderFunction => {\n\tif (!mappingInstructions.length) return () => undefined as any;\n\n\treturn new AsyncFunction(\n\t\t's3',\n\t\t'data',\n\t\t'errors',\n\t\t'downloader',\n\t\t'presigner',\n\t\t'idGetter',\n\t\tmode === 'many'\n\t\t\t? `\n\t\t\tawait Promise.all(data.reduce((p, row) => {\n\t\t\t${buildDecoderInner(mappingInstructions)}\n\t\t\treturn p;\n\t\t}, []));`\n\t\t\t: `\n\t\t\tconst p = [];\n\t\t\tconst row = data;\n\t\t\t${buildDecoderInner(mappingInstructions)}\n\t\t\tawait Promise.all(p);\n\t\t`,\n\t);\n};\n\nexport const buildEncoder = (mappingInstructions: DrizzleS3FilePlaceholderMappingInstruction[]): EncoderFunction => {\n\tif (!mappingInstructions.length) return () => undefined as any;\n\n\treturn new AsyncFunction(\n\t\t's3',\n\t\t'placeholders',\n\t\t'errors',\n\t\t'uploader',\n\t\t'idBuilder',\n\t\t`\n\t\t\tif(!placeholders) return;\n\t\t\tawait Promise.all([\n\t\t\t\t${\n\t\t\tmappingInstructions.map((i) => {\n\t\t\t\tconst path = `[${JSON.stringify(i.key)}]`;\n\n\t\t\t\treturn i.arrayDimensions\n\t\t\t\t\t? `...(() => {\n\t\t\t\t\t\tconst arr = placeholders${path};\n\t\t\t\t\t\tconst p = [];\n\t\t\t\t\t\t${\n\t\t\t\t\t\tbuildFunctionArrayRecursion(\n\t\t\t\t\t\t\ti.arrayDimensions,\n\t\t\t\t\t\t\t`p.push((async () => {\n\t\t\t\t\t\t\tif(!arr || typeof arr !== 'object') return;\n\n\t\t\t\t\t\t\tconst { key, bucket, data } = arr;\n\t\t\t\t\t\t\tawait uploader({ key, bucket, data, s3, mode: ${JSON.stringify(i.mode)} });\n\t\t\t\t\t\t\tplaceholders${path}${buildArrayRecursionIndexAccess(i.arrayDimensions)} = idBuilder(arr);\n\t\t\t\t\t\t})().catch((e) => errors.push(e)))`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\t\treturn p;\n\t\t\t\t\t})()`\n\t\t\t\t\t: `(async () => {\n\t\t\t\t\t\t\tconst params = placeholders${path};\n\t\t\t\t\t\t\tif(!params || typeof params !== 'object') return;\n\n\t\t\t\t\t\t\tconst { key, bucket, data } = params;\n\t\t\t\t\t\t\tawait uploader({ key, bucket, data, s3, mode: ${JSON.stringify(i.mode)} });\n\t\t\t\t\t\t\tplaceholders${path} = idBuilder(params);\n\t\t\t\t\t\t})().catch((e) => errors.push(e))`;\n\t\t\t}).join(',\\n')\n\t\t}\n\t\t\t]);\n\t\t`,\n\t);\n};\n\nexport type DrizzleS3FileMode = 'buffer' | 'hex' | 'base64' | 'uint8array';\n\nexport type DrizzleS3FileModeToData = {\n\tbuffer: Buffer;\n\thex: string;\n\tbase64: string;\n\tuint8array: Uint8Array;\n};\n\nexport type DrizzleS3FetchMode = 'file' | 'data' | 'presigned';\n\nexport type DrizzleS3FileOutputMappingInstructionNodeCommon = {\n\tpath: string[];\n};\nexport type DrizzleS3FileOutputMappingInstruction =\n\t| DrizzleS3FileOutputMappingInstructionIterableNode\n\t| DrizzleS3FileOutputMappingInstructionTerminalNode;\n\nexport type DrizzleS3FileOutputMappingInstructionTerminalNode =\n\t& DrizzleS3FileOutputMappingInstructionNodeCommon\n\t& {\n\t\tfileMode: DrizzleS3FileMode;\n\t\tfetchMode: DrizzleS3FetchMode;\n\t\toptions?: RequestPresigningArguments;\n\t\tarrayDimensions?: number;\n\t};\n\nexport type DrizzleS3FileOutputMappingInstructionIterableNode =\n\t& DrizzleS3FileOutputMappingInstructionNodeCommon\n\t& {\n\t\tsubinstructions: DrizzleS3FileOutputMappingInstruction[];\n\t};\n\nexport interface DrizzleS3FileInputMappingInstruction {\n\tmode: DrizzleS3FileMode;\n\tindex: number;\n\tarrayDimensions?: number;\n}\n\nexport interface DrizzleS3FilePlaceholderMappingInstruction {\n\tmode: DrizzleS3FileMode;\n\tkey: string;\n\tarrayDimensions?: number;\n}\n\nexport type RequestPresigningArguments = typeof getSignedUrl extends\n\t((client: any, command: any, options?: infer R) => any) ? R\n\t: Record<string, unknown>;\n\nexport interface DrizzleS3ObjectIdentification {\n\tkey: string;\n\tbucket: string;\n}\n\nexport interface S3ExtMeta {\n\tdecoder?: DecoderFunction;\n\tencoder?: EncoderFunction;\n}\n\nexport type DrizzleS3Object<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<\n\t& DrizzleS3ObjectIdentification\n\t& {\n\t\tdata: TData;\n\t}\n>;\n\nexport type DrizzleS3ObjectFile<TData extends string | Buffer | Uint8Array = string | Buffer | Uint8Array> = Simplify<\n\t& DrizzleS3ObjectIdentification\n\t& {\n\t\tdata: TData;\n\t}\n>;\n\n// export type DrizzleS3ObjectMeta = Simplify<\n// \t& DrizzleS3ObjectIdentification\n// \t& {\n// \t\tmeta?: Record<string, unknown>;\n// \t}\n// >;\n\nconst separator = ':';\n\nexport function objectIdToText({ key, bucket }: DrizzleS3ObjectIdentification): string {\n\treturn `${bucket}${separator}${key}`;\n}\n\nexport function textToObjectId(text: string): DrizzleS3ObjectIdentification {\n\tconst split = text.split(separator);\n\n\tif (split.length < 2) throw new Error(`Invalid S3 object identifier: \"${text}\". Expected: \"bucket${separator}key\"`);\n\n\tconst bucket = split.shift()!;\n\tconst key = split.join(separator);\n\n\treturn { key, bucket };\n}\n\nexport async function downloadFile(\n\t{ key, bucket, s3, mode, fileOnly }: {\n\t\tkey: string;\n\t\tbucket: string;\n\t\ts3: S3Client;\n\t\tmode: DrizzleS3FileMode;\n\t\tfileOnly?: boolean;\n\t},\n) {\n\tconst res = await s3.send(\n\t\tnew GetObjectCommand({\n\t\t\tBucket: bucket,\n\t\t\tKey: key,\n\t\t}),\n\t);\n\n\tif (!res.Body) {\n\t\tthrow new DrizzleError({\n\t\t\tmessage: `No data found in bucket \"${bucket}\" for key \"${key}\"`,\n\t\t});\n\t}\n\n\tlet data;\n\tswitch (mode) {\n\t\tcase 'uint8array': {\n\t\t\tdata = await res.Body.transformToByteArray();\n\t\t\tbreak;\n\t\t}\n\t\tcase 'buffer': {\n\t\t\tdata = Buffer.from(await res.Body.transformToByteArray());\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tdata = await res.Body.transformToString(mode);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn fileOnly ? data : {\n\t\tkey,\n\t\tbucket,\n\t\tdata,\n\t};\n}\n\n// export async function downloadFileMeta({ key, bucket, s3 }: { key: string; bucket: string; s3: S3Client }) {\n// \tconst { Metadata: meta } = await s3.send(\n// \t\tnew HeadObjectCommand({\n// \t\t\tBucket: bucket,\n// \t\t\tKey: key,\n// \t\t}),\n// \t);\n\n// \treturn {\n// \t\tkey,\n// \t\tbucket,\n// \t\tmeta,\n// \t};\n// }\n\nexport async function presignDownload(\n\t{ key, bucket, options, s3 }: { key: string; bucket: string; options?: RequestPresigningArguments; s3: S3Client },\n) {\n\tconst command = new GetObjectCommand({\n\t\tBucket: bucket,\n\t\tKey: key,\n\t});\n\n\tconst presigner = await PresignerImporter.importPresigner();\n\t// Types are compatible, errors seem to be caused by internal package or package resolution issues\n\tconst url = await presigner(s3 as any, command as any, options);\n\n\treturn url;\n}\n\nexport async function uploadFile(\n\t{ key, bucket, data, s3, mode }: {\n\t\tkey: string;\n\t\tbucket: string;\n\t\tdata: DrizzleS3Object['data'];\n\t\ts3: S3Client;\n\t\tmode: DrizzleS3FileMode;\n\t},\n) {\n\tlet body: Buffer | Uint8Array;\n\tswitch (mode) {\n\t\tcase 'uint8array':\n\t\tcase 'buffer': {\n\t\t\tbody = data as Buffer | Uint8Array;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'hex': {\n\t\t\tbody = Uint8Array.fromHex ? Uint8Array.fromHex(data as string) : Buffer.from(data as string, 'hex');\n\t\t\tbreak;\n\t\t}\n\t\tcase 'base64': {\n\t\t\tbody = Uint8Array.fromBase64 ? Uint8Array.fromBase64(data as string) : Buffer.from(data as string, 'base64');\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst res = await s3.send(\n\t\tnew PutObjectCommand({\n\t\t\tBucket: bucket,\n\t\t\tKey: key,\n\t\t\tBody: body,\n\t\t}),\n\t);\n\n\treturn res;\n}\n\ntype RecursiveArrayItem = DrizzleS3Object | RecursiveArrayItem[];\n\nexport function mapArrayParam(\n\ts3: S3Client,\n\titem: RecursiveArrayItem,\n\tdimensions: number,\n\tmode: DrizzleS3FileMode,\n\terrors: unknown[],\n\tpromises: Promise<unknown>[],\n) {\n\tif (dimensions > 1) {\n\t\tfor (const sub of item as Exclude<RecursiveArrayItem, DrizzleS3Object>) {\n\t\t\tmapArrayParam(s3, sub, dimensions - 1, mode, errors, promises);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tlet i = 0;\n\tfor (const param of item as (DrizzleS3Object | unknown)[]) {\n\t\tif (!param || typeof param !== 'object') {\n\t\t\t++i;\n\t\t\tcontinue;\n\t\t}\n\t\tconst obj = param as DrizzleS3Object;\n\n\t\tpromises.push(\n\t\t\t(async (i: number) => {\n\t\t\t\tawait uploadFile({\n\t\t\t\t\ts3: s3,\n\t\t\t\t\tkey: obj.key,\n\t\t\t\t\tbucket: obj.bucket,\n\t\t\t\t\tdata: obj.data,\n\t\t\t\t\tmode: mode,\n\t\t\t\t});\n\n\t\t\t\tconst value = objectIdToText(obj);\n\t\t\t\t(item as unknown[])[i] = value;\n\t\t\t})(i++).catch((e) => errors.push(e)),\n\t\t);\n\t}\n}\n\nexport async function mapParams(\n\ts3: S3Client,\n\tparams: unknown[],\n\tindexes: DrizzleS3FileInputMappingInstruction[],\n\terrors: unknown[],\n) {\n\tif (!indexes.length) return;\n\n\tconst arrayIdxs: number[] = [];\n\tawait Promise.all(\n\t\tindexes.reduce((p, { index, mode, arrayDimensions }) => {\n\t\t\tconst { value: param } = params![index]! as ExtensionParam<DrizzleS3Object, string>;\n\n\t\t\tif (arrayDimensions) {\n\t\t\t\tmapArrayParam(s3, param, arrayDimensions, mode, errors, p);\n\t\t\t\tarrayIdxs.push(index);\n\n\t\t\t\treturn p;\n\t\t\t}\n\n\t\t\tif (!param || typeof param !== 'object') return p;\n\n\t\t\tp.push(\n\t\t\t\t(async (i: number) => {\n\t\t\t\t\tawait uploadFile({\n\t\t\t\t\t\ts3: s3,\n\t\t\t\t\t\tkey: param.key,\n\t\t\t\t\t\tbucket: param.bucket,\n\t\t\t\t\t\tdata: param.data,\n\t\t\t\t\t\tmode: mode,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst value = objectIdToText(param);\n\t\t\t\t\tparams![i] = value;\n\t\t\t\t})(index).catch((e) => errors.push(e)),\n\t\t\t);\n\n\t\t\treturn p;\n\t\t}, [] as Promise<unknown>[]),\n\t);\n\n\tfor (const idx of arrayIdxs) {\n\t\tparams[idx] = (<ExtensionParam<any[]>> params[idx]).value\n\t\t\t? (<ExtensionParam> params[idx]).encoder.mapToDriverValue(\n\t\t\t\t(<ExtensionParam<any[]>> params[idx]).value,\n\t\t\t)\n\t\t\t: params[idx];\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB,wBAAuC;AAElE,SAAS,oBAAoB;AAM7B,MAAM,kBAAkB;AAAA,EACvB,OAAe,wBAAgC,CAAC,QAAQ,UAAU,WAAW,WAAW,EAAE,KAAK,GAAG;AAAA,EAClG,OAAe,YAA6C;AAAA,EAC5D,cAAc;AAAA,EAAC;AAAA,EAEf,aAAa,kBAAgD;AAC5D,QAAI,KAAK,UAAW,QAAO,KAAK;AAEhC,SAAK,YAAY,MAAM,OAAO,KAAK,uBAAuB,KAAK,CAAC,MAAM,EAAE,YAAY;AAEpF,WAAO,KAAK;AAAA,EACb;AACD;AAEA,MAAM,gBAAiB,iBAAiB;AAAC,EAAE;AA0B3C,MAAM,8BAA8B,CAAC,YAAoB,SAAyB;AACjF,MAAI,YAAY;AACf,WAAO,4BAA4B,aAAa,GAAG,uBAAuB,UAAU,QAAQ,IAAI,GAAG;AAAA,EACpG;AAEA,SAAO;AACR;AAEA,MAAM,iCAAiC,CAAC,eAAuB;AAC9D,MAAI,OAAO;AACX,WAAS,MAAM,GAAG,OAAO,YAAY,EAAE,KAAK;AAC3C,WAAO,GAAG,IAAI,KAAK,GAAG;AAAA,EACvB;AACA,SAAO;AACR;AAEA,MAAM,uBAAuB,CAAC,YAAyC;AACtE,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,SAAS,OAAO,QAAQ,OAAO,EAAE;AAAA,IAAI,CAAC,CAAC,GAAG,CAAC;AAAA;AAAA,MAEhD,GAAG,KAAK,UAAU,CAAC,CAAC,KAAK,aAAa,MAAM,WAAW,KAAK,UAAU,CAAC,GAAG,CAAC,CAA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,OAAO,MAAc;AACrB,gBAAM,WAAW;AAAA,YAChB;AAAA,YACA,KAAK,MAAM;AAAA,YACX,QAAQ,MAAM;AAAA,YACd,MAAM,MAAM;AAAA,YACZ;AAAA,UACD,CAAC;AAED,gBAAM,QAAQ,eAAe,KAAK;AAClC,iBAAQ,CAAC,IAAI;AAAA,QACd,GAAG,KAAK,EAAE,MAAM,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAAA,MACtC;AAEA,aAAO;AAAA,IACR,GAAG,CAAC,CAAuB;AAAA,EAC5B;AAEA,aAAW,OAAO,WAAW;AAC5B,WAAO,GAAG,IAA6B,OAAO,GAAG,EAAG,QAC/B,OAAO,GAAG,EAAG,QAAQ;AAAA,MACf,OAAO,GAAG,EAAG;AAAA,IACvC,IACE,OAAO,GAAG;AAAA,EACd;AACD;","names":["i"]}
@@ -1,113 +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 column_exports = {};
20
- __export(column_exports, {
21
- GelS3File: () => GelS3File,
22
- GelS3FileBuilder: () => GelS3FileBuilder,
23
- s3File: () => s3File
24
- });
25
- module.exports = __toCommonJS(column_exports);
26
- var import_entity = require("../../../entity.cjs");
27
- var import_extension_core = require("../../../extension-core/index.cjs");
28
- var import_gel_core = require("../../../gel-core/index.cjs");
29
- var import_utils = require("../../../utils.cjs");
30
- var import_common = require("../common.cjs");
31
- var import_extension = require("./extension.cjs");
32
- class GelS3FileBuilder extends import_gel_core.GelColumnBuilder {
33
- static [import_entity.entityKind] = "GelS3FileBuilder";
34
- [import_extension_core.extensionColumnConfig];
35
- constructor(name, config) {
36
- super(name, "custom", "GelS3File");
37
- this[import_extension_core.extensionColumnConfig] = {
38
- fileMode: config.mode,
39
- fetchMode: "file"
40
- };
41
- }
42
- array(size) {
43
- return super.array(size);
44
- }
45
- /**
46
- * Allows to set default to an existing file
47
- *
48
- * @example
49
- * ```
50
- * fileColumn: s3File().default(sql`${bucket}:${key}`)
51
- * ```
52
- *
53
- * @returns
54
- */
55
- default(value) {
56
- return super.default(value);
57
- }
58
- generatedAlwaysAs(as) {
59
- return super.generatedAlwaysAs(as);
60
- }
61
- /** @internal */
62
- build(table) {
63
- return new GelS3File(
64
- table,
65
- this.config,
66
- this[import_extension_core.extensionColumnConfig]
67
- );
68
- }
69
- }
70
- class GelS3File extends import_gel_core.GelColumn {
71
- static [import_entity.entityKind] = "GelS3File";
72
- [import_extension_core.requiredExtension] = import_extension.DrizzleGelS3Extension;
73
- [import_extension_core.extensionColumnConfig];
74
- constructor(table, config, extensionConfig) {
75
- super(table, config);
76
- this[import_extension_core.extensionColumnConfig] = extensionConfig ?? {
77
- fileMode: "buffer",
78
- fetchMode: "file"
79
- };
80
- }
81
- mapToDriverValue(value) {
82
- if (typeof value === "string") return value;
83
- return (0, import_common.objectIdToText)(value);
84
- }
85
- data() {
86
- return new GelS3File(
87
- this.table,
88
- this.config,
89
- { fileMode: this[import_extension_core.extensionColumnConfig].fileMode, fetchMode: "data" }
90
- );
91
- }
92
- presigned(options) {
93
- return new GelS3File(
94
- this.table,
95
- this.config,
96
- { fileMode: this[import_extension_core.extensionColumnConfig].fileMode, fetchMode: "presigned", options }
97
- );
98
- }
99
- getSQLType() {
100
- return "text";
101
- }
102
- }
103
- function s3File(a, b) {
104
- const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
105
- return new GelS3FileBuilder(name, config);
106
- }
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
109
- GelS3File,
110
- GelS3FileBuilder,
111
- s3File
112
- });
113
- //# sourceMappingURL=column.cjs.map