kysely 0.27.3 → 0.27.5

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 (301) hide show
  1. package/.renovaterc.json +3 -0
  2. package/CONTRIBUTING.md +2 -2
  3. package/README.md +7 -7
  4. package/deno.check.d.ts +86 -0
  5. package/deno.check.json +21 -0
  6. package/dist/cjs/dialect/dialect-adapter-base.d.ts +13 -3
  7. package/dist/cjs/dialect/dialect-adapter-base.js +4 -1
  8. package/dist/cjs/dialect/dialect-adapter.d.ts +16 -2
  9. package/dist/cjs/dialect/mssql/mssql-adapter.d.ts +12 -7
  10. package/dist/cjs/dialect/mssql/mssql-adapter.js +2 -4
  11. package/dist/cjs/dialect/mssql/mssql-dialect-config.d.ts +83 -55
  12. package/dist/cjs/dialect/mssql/mssql-driver.d.ts +1 -0
  13. package/dist/cjs/dialect/mssql/mssql-driver.js +114 -48
  14. package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +11 -2
  15. package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +4 -0
  16. package/dist/cjs/dialect/mysql/mysql-driver.js +3 -0
  17. package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +11 -2
  18. package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +10 -3
  19. package/dist/cjs/dialect/postgres/postgres-driver.js +3 -0
  20. package/dist/cjs/dialect/postgres/postgres-introspector.js +5 -1
  21. package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +11 -2
  22. package/dist/cjs/driver/database-connection.d.ts +3 -1
  23. package/dist/cjs/driver/dummy-driver.d.ts +13 -12
  24. package/dist/cjs/driver/dummy-driver.js +13 -12
  25. package/dist/cjs/dynamic/dynamic-reference-builder.js +2 -2
  26. package/dist/cjs/dynamic/dynamic.d.ts +7 -7
  27. package/dist/cjs/dynamic/dynamic.js +7 -7
  28. package/dist/cjs/expression/expression-builder.d.ts +153 -62
  29. package/dist/cjs/expression/expression-builder.js +2 -3
  30. package/dist/cjs/expression/expression-wrapper.d.ts +92 -23
  31. package/dist/cjs/expression/expression.d.ts +40 -5
  32. package/dist/cjs/expression/expression.js +2 -3
  33. package/dist/cjs/helpers/mssql.d.ts +74 -14
  34. package/dist/cjs/helpers/mssql.js +77 -18
  35. package/dist/cjs/helpers/mysql.d.ts +17 -13
  36. package/dist/cjs/helpers/mysql.js +20 -17
  37. package/dist/cjs/helpers/postgres.d.ts +11 -8
  38. package/dist/cjs/helpers/postgres.js +14 -12
  39. package/dist/cjs/helpers/sqlite.d.ts +41 -16
  40. package/dist/cjs/helpers/sqlite.js +44 -20
  41. package/dist/cjs/index.d.ts +28 -21
  42. package/dist/cjs/index.js +28 -21
  43. package/dist/cjs/kysely.d.ts +100 -42
  44. package/dist/cjs/kysely.js +63 -39
  45. package/dist/cjs/migration/file-migration-provider.d.ts +2 -2
  46. package/dist/cjs/migration/file-migration-provider.js +2 -2
  47. package/dist/cjs/migration/migrator.d.ts +82 -14
  48. package/dist/cjs/migration/migrator.js +82 -14
  49. package/dist/cjs/operation-node/aggregate-function-node.d.ts +4 -0
  50. package/dist/cjs/operation-node/aggregate-function-node.js +9 -0
  51. package/dist/cjs/operation-node/alter-column-node.d.ts +1 -1
  52. package/dist/cjs/operation-node/case-node.d.ts +1 -1
  53. package/dist/cjs/operation-node/column-definition-node.d.ts +1 -0
  54. package/dist/cjs/operation-node/data-type-node.d.ts +2 -2
  55. package/dist/cjs/operation-node/data-type-node.js +17 -3
  56. package/dist/cjs/operation-node/delete-query-node.d.ts +3 -0
  57. package/dist/cjs/operation-node/foreign-key-constraint-node.d.ts +4 -4
  58. package/dist/cjs/operation-node/having-node.d.ts +1 -1
  59. package/dist/cjs/operation-node/insert-query-node.d.ts +3 -0
  60. package/dist/cjs/operation-node/merge-query-node.d.ts +3 -0
  61. package/dist/cjs/operation-node/on-node.d.ts +1 -1
  62. package/dist/cjs/operation-node/operation-node-source.js +1 -2
  63. package/dist/cjs/operation-node/operation-node-transformer.d.ts +11 -3
  64. package/dist/cjs/operation-node/operation-node-transformer.js +26 -3
  65. package/dist/cjs/operation-node/operation-node-visitor.d.ts +2 -0
  66. package/dist/cjs/operation-node/operation-node-visitor.js +1 -0
  67. package/dist/cjs/operation-node/operation-node.d.ts +1 -1
  68. package/dist/cjs/operation-node/operator-node.d.ts +3 -3
  69. package/dist/cjs/operation-node/operator-node.js +8 -6
  70. package/dist/cjs/operation-node/output-node.d.ts +13 -0
  71. package/dist/cjs/operation-node/output-node.js +26 -0
  72. package/dist/cjs/operation-node/query-node.d.ts +15 -6
  73. package/dist/cjs/operation-node/query-node.js +17 -0
  74. package/dist/cjs/operation-node/select-query-node.d.ts +1 -1
  75. package/dist/cjs/operation-node/select-query-node.js +6 -8
  76. package/dist/cjs/operation-node/update-query-node.d.ts +3 -0
  77. package/dist/cjs/operation-node/where-node.d.ts +1 -1
  78. package/dist/cjs/parser/binary-operation-parser.js +5 -6
  79. package/dist/cjs/parser/data-type-parser.js +1 -2
  80. package/dist/cjs/parser/default-value-parser.js +1 -2
  81. package/dist/cjs/parser/expression-parser.js +3 -4
  82. package/dist/cjs/parser/fetch-parser.js +1 -2
  83. package/dist/cjs/parser/group-by-parser.js +1 -2
  84. package/dist/cjs/parser/identifier-parser.js +1 -2
  85. package/dist/cjs/parser/insert-values-parser.js +1 -2
  86. package/dist/cjs/parser/join-parser.js +1 -2
  87. package/dist/cjs/parser/merge-parser.js +2 -3
  88. package/dist/cjs/parser/on-commit-action-parse.js +1 -2
  89. package/dist/cjs/parser/on-modify-action-parser.js +1 -2
  90. package/dist/cjs/parser/order-by-parser.js +3 -4
  91. package/dist/cjs/parser/parse-utils.js +4 -5
  92. package/dist/cjs/parser/partition-by-parser.js +1 -2
  93. package/dist/cjs/parser/reference-parser.js +8 -9
  94. package/dist/cjs/parser/returning-parser.d.ts +4 -3
  95. package/dist/cjs/parser/select-parser.js +2 -3
  96. package/dist/cjs/parser/set-operation-parser.js +1 -2
  97. package/dist/cjs/parser/table-parser.js +4 -5
  98. package/dist/cjs/parser/top-parser.js +1 -2
  99. package/dist/cjs/parser/unary-operation-parser.js +3 -4
  100. package/dist/cjs/parser/update-set-parser.js +2 -3
  101. package/dist/cjs/parser/value-parser.js +4 -5
  102. package/dist/cjs/parser/with-parser.js +1 -2
  103. package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +54 -27
  104. package/dist/cjs/plugin/camel-case/camel-case-plugin.js +26 -21
  105. package/dist/cjs/plugin/camel-case/camel-case.js +2 -3
  106. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
  107. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
  108. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
  109. package/dist/cjs/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
  110. package/dist/cjs/plugin/kysely-plugin.d.ts +28 -6
  111. package/dist/cjs/plugin/noop-plugin.d.ts +28 -6
  112. package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
  113. package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
  114. package/dist/cjs/plugin/with-schema/with-schema-plugin.d.ts +28 -6
  115. package/dist/cjs/query-builder/aggregate-function-builder.d.ts +43 -1
  116. package/dist/cjs/query-builder/aggregate-function-builder.js +30 -0
  117. package/dist/cjs/query-builder/delete-query-builder.d.ts +219 -43
  118. package/dist/cjs/query-builder/delete-query-builder.js +95 -31
  119. package/dist/cjs/query-builder/function-module.d.ts +40 -93
  120. package/dist/cjs/query-builder/function-module.js +1 -2
  121. package/dist/cjs/query-builder/insert-query-builder.d.ts +326 -67
  122. package/dist/cjs/query-builder/insert-query-builder.js +212 -61
  123. package/dist/cjs/query-builder/insert-result.d.ts +10 -5
  124. package/dist/cjs/query-builder/insert-result.js +10 -5
  125. package/dist/cjs/query-builder/json-path-builder.d.ts +33 -9
  126. package/dist/cjs/query-builder/json-path-builder.js +8 -5
  127. package/dist/cjs/query-builder/merge-query-builder.d.ts +312 -10
  128. package/dist/cjs/query-builder/merge-query-builder.js +98 -7
  129. package/dist/cjs/query-builder/no-result-error.js +2 -2
  130. package/dist/cjs/query-builder/on-conflict-builder.d.ts +53 -20
  131. package/dist/cjs/query-builder/on-conflict-builder.js +41 -16
  132. package/dist/cjs/query-builder/output-interface.d.ts +138 -0
  133. package/dist/cjs/query-builder/output-interface.js +2 -0
  134. package/dist/cjs/query-builder/returning-interface.d.ts +7 -5
  135. package/dist/cjs/query-builder/select-query-builder-expression.d.ts +8 -0
  136. package/dist/cjs/query-builder/select-query-builder.d.ts +370 -73
  137. package/dist/cjs/query-builder/select-query-builder.js +14 -9
  138. package/dist/cjs/query-builder/update-query-builder.d.ts +225 -31
  139. package/dist/cjs/query-builder/update-query-builder.js +96 -17
  140. package/dist/cjs/query-builder/update-result.d.ts +9 -0
  141. package/dist/cjs/query-builder/update-result.js +9 -0
  142. package/dist/cjs/query-builder/where-interface.d.ts +6 -2
  143. package/dist/cjs/query-compiler/default-query-compiler.d.ts +2 -0
  144. package/dist/cjs/query-compiler/default-query-compiler.js +45 -1
  145. package/dist/cjs/query-creator.d.ts +122 -21
  146. package/dist/cjs/query-creator.js +56 -3
  147. package/dist/cjs/raw-builder/raw-builder.d.ts +29 -7
  148. package/dist/cjs/raw-builder/raw-builder.js +1 -2
  149. package/dist/cjs/raw-builder/sql.d.ts +31 -12
  150. package/dist/cjs/schema/alter-column-builder.d.ts +17 -3
  151. package/dist/cjs/schema/alter-column-builder.js +20 -3
  152. package/dist/cjs/schema/alter-table-add-index-builder.d.ts +44 -10
  153. package/dist/cjs/schema/alter-table-add-index-builder.js +27 -10
  154. package/dist/cjs/schema/alter-table-builder.js +1 -2
  155. package/dist/cjs/schema/column-definition-builder.d.ts +286 -24
  156. package/dist/cjs/schema/column-definition-builder.js +288 -24
  157. package/dist/cjs/schema/create-table-builder.d.ts +86 -33
  158. package/dist/cjs/schema/create-table-builder.js +86 -33
  159. package/dist/cjs/util/assert.js +2 -3
  160. package/dist/cjs/util/column-type.d.ts +5 -9
  161. package/dist/cjs/util/compilable.js +1 -2
  162. package/dist/cjs/util/json-object-args.js +1 -2
  163. package/dist/cjs/util/log-once.js +1 -2
  164. package/dist/cjs/util/object-utils.js +38 -26
  165. package/dist/cjs/util/performance-now.js +1 -2
  166. package/dist/cjs/util/prevent-await.js +1 -2
  167. package/dist/cjs/util/query-id.js +1 -2
  168. package/dist/cjs/util/random-string.js +1 -2
  169. package/dist/cjs/util/require-all-props.d.ts +4 -2
  170. package/dist/cjs/util/require-all-props.js +5 -4
  171. package/dist/cjs/util/stack-trace-utils.js +1 -2
  172. package/dist/cjs/util/streamable.d.ts +1 -1
  173. package/dist/cjs/util/type-utils.d.ts +4 -2
  174. package/dist/esm/dialect/dialect-adapter-base.d.ts +13 -3
  175. package/dist/esm/dialect/dialect-adapter-base.js +4 -1
  176. package/dist/esm/dialect/dialect-adapter.d.ts +16 -2
  177. package/dist/esm/dialect/mssql/mssql-adapter.d.ts +12 -7
  178. package/dist/esm/dialect/mssql/mssql-adapter.js +2 -4
  179. package/dist/esm/dialect/mssql/mssql-dialect-config.d.ts +83 -55
  180. package/dist/esm/dialect/mssql/mssql-driver.d.ts +1 -0
  181. package/dist/esm/dialect/mssql/mssql-driver.js +114 -48
  182. package/dist/esm/dialect/mysql/mysql-adapter.d.ts +11 -2
  183. package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +4 -0
  184. package/dist/esm/dialect/mysql/mysql-driver.js +3 -0
  185. package/dist/esm/dialect/postgres/postgres-adapter.d.ts +11 -2
  186. package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +10 -3
  187. package/dist/esm/dialect/postgres/postgres-driver.js +3 -0
  188. package/dist/esm/dialect/postgres/postgres-introspector.js +5 -1
  189. package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +11 -2
  190. package/dist/esm/driver/database-connection.d.ts +3 -1
  191. package/dist/esm/driver/dummy-driver.d.ts +13 -12
  192. package/dist/esm/driver/dummy-driver.js +13 -12
  193. package/dist/esm/dynamic/dynamic.d.ts +7 -7
  194. package/dist/esm/dynamic/dynamic.js +7 -7
  195. package/dist/esm/expression/expression-builder.d.ts +153 -62
  196. package/dist/esm/expression/expression-wrapper.d.ts +92 -23
  197. package/dist/esm/expression/expression.d.ts +40 -5
  198. package/dist/esm/helpers/mssql.d.ts +74 -14
  199. package/dist/esm/helpers/mssql.js +74 -14
  200. package/dist/esm/helpers/mysql.d.ts +17 -13
  201. package/dist/esm/helpers/mysql.js +17 -13
  202. package/dist/esm/helpers/postgres.d.ts +11 -8
  203. package/dist/esm/helpers/postgres.js +11 -8
  204. package/dist/esm/helpers/sqlite.d.ts +41 -16
  205. package/dist/esm/helpers/sqlite.js +41 -16
  206. package/dist/esm/index.d.ts +28 -21
  207. package/dist/esm/index.js +28 -21
  208. package/dist/esm/kysely.d.ts +100 -42
  209. package/dist/esm/kysely.js +61 -37
  210. package/dist/esm/migration/file-migration-provider.d.ts +2 -2
  211. package/dist/esm/migration/file-migration-provider.js +2 -2
  212. package/dist/esm/migration/migrator.d.ts +82 -14
  213. package/dist/esm/migration/migrator.js +82 -14
  214. package/dist/esm/operation-node/aggregate-function-node.d.ts +4 -0
  215. package/dist/esm/operation-node/aggregate-function-node.js +9 -0
  216. package/dist/esm/operation-node/alter-column-node.d.ts +1 -1
  217. package/dist/esm/operation-node/case-node.d.ts +1 -1
  218. package/dist/esm/operation-node/column-definition-node.d.ts +1 -0
  219. package/dist/esm/operation-node/data-type-node.d.ts +2 -2
  220. package/dist/esm/operation-node/data-type-node.js +15 -1
  221. package/dist/esm/operation-node/delete-query-node.d.ts +3 -0
  222. package/dist/esm/operation-node/foreign-key-constraint-node.d.ts +4 -4
  223. package/dist/esm/operation-node/having-node.d.ts +1 -1
  224. package/dist/esm/operation-node/insert-query-node.d.ts +3 -0
  225. package/dist/esm/operation-node/merge-query-node.d.ts +3 -0
  226. package/dist/esm/operation-node/on-node.d.ts +1 -1
  227. package/dist/esm/operation-node/operation-node-transformer.d.ts +11 -3
  228. package/dist/esm/operation-node/operation-node-transformer.js +26 -3
  229. package/dist/esm/operation-node/operation-node-visitor.d.ts +2 -0
  230. package/dist/esm/operation-node/operation-node-visitor.js +1 -0
  231. package/dist/esm/operation-node/operation-node.d.ts +1 -1
  232. package/dist/esm/operation-node/operator-node.d.ts +3 -3
  233. package/dist/esm/operation-node/operator-node.js +2 -0
  234. package/dist/esm/operation-node/output-node.d.ts +13 -0
  235. package/dist/esm/operation-node/output-node.js +24 -0
  236. package/dist/esm/operation-node/query-node.d.ts +15 -6
  237. package/dist/esm/operation-node/query-node.js +17 -0
  238. package/dist/esm/operation-node/select-query-node.d.ts +1 -1
  239. package/dist/esm/operation-node/select-query-node.js +6 -8
  240. package/dist/esm/operation-node/update-query-node.d.ts +3 -0
  241. package/dist/esm/operation-node/where-node.d.ts +1 -1
  242. package/dist/esm/parser/returning-parser.d.ts +4 -3
  243. package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +54 -27
  244. package/dist/esm/plugin/camel-case/camel-case-plugin.js +26 -21
  245. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
  246. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
  247. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
  248. package/dist/esm/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
  249. package/dist/esm/plugin/kysely-plugin.d.ts +28 -6
  250. package/dist/esm/plugin/noop-plugin.d.ts +28 -6
  251. package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
  252. package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
  253. package/dist/esm/plugin/with-schema/with-schema-plugin.d.ts +28 -6
  254. package/dist/esm/query-builder/aggregate-function-builder.d.ts +43 -1
  255. package/dist/esm/query-builder/aggregate-function-builder.js +30 -0
  256. package/dist/esm/query-builder/delete-query-builder.d.ts +219 -43
  257. package/dist/esm/query-builder/delete-query-builder.js +95 -31
  258. package/dist/esm/query-builder/function-module.d.ts +40 -93
  259. package/dist/esm/query-builder/insert-query-builder.d.ts +326 -67
  260. package/dist/esm/query-builder/insert-query-builder.js +212 -61
  261. package/dist/esm/query-builder/insert-result.d.ts +10 -5
  262. package/dist/esm/query-builder/insert-result.js +10 -5
  263. package/dist/esm/query-builder/json-path-builder.d.ts +33 -9
  264. package/dist/esm/query-builder/json-path-builder.js +8 -5
  265. package/dist/esm/query-builder/merge-query-builder.d.ts +312 -10
  266. package/dist/esm/query-builder/merge-query-builder.js +98 -7
  267. package/dist/esm/query-builder/on-conflict-builder.d.ts +53 -20
  268. package/dist/esm/query-builder/on-conflict-builder.js +41 -16
  269. package/dist/esm/query-builder/output-interface.d.ts +138 -0
  270. package/dist/esm/query-builder/output-interface.js +2 -0
  271. package/dist/esm/query-builder/returning-interface.d.ts +7 -5
  272. package/dist/esm/query-builder/select-query-builder-expression.d.ts +8 -0
  273. package/dist/esm/query-builder/select-query-builder.d.ts +370 -73
  274. package/dist/esm/query-builder/select-query-builder.js +13 -7
  275. package/dist/esm/query-builder/update-query-builder.d.ts +225 -31
  276. package/dist/esm/query-builder/update-query-builder.js +96 -17
  277. package/dist/esm/query-builder/update-result.d.ts +9 -0
  278. package/dist/esm/query-builder/update-result.js +9 -0
  279. package/dist/esm/query-builder/where-interface.d.ts +6 -2
  280. package/dist/esm/query-compiler/default-query-compiler.d.ts +2 -0
  281. package/dist/esm/query-compiler/default-query-compiler.js +45 -1
  282. package/dist/esm/query-creator.d.ts +122 -21
  283. package/dist/esm/query-creator.js +56 -3
  284. package/dist/esm/raw-builder/raw-builder.d.ts +29 -7
  285. package/dist/esm/raw-builder/sql.d.ts +31 -12
  286. package/dist/esm/schema/alter-column-builder.d.ts +17 -3
  287. package/dist/esm/schema/alter-column-builder.js +20 -3
  288. package/dist/esm/schema/alter-table-add-index-builder.d.ts +44 -10
  289. package/dist/esm/schema/alter-table-add-index-builder.js +27 -10
  290. package/dist/esm/schema/alter-table-builder.js +1 -2
  291. package/dist/esm/schema/column-definition-builder.d.ts +286 -24
  292. package/dist/esm/schema/column-definition-builder.js +288 -24
  293. package/dist/esm/schema/create-table-builder.d.ts +86 -33
  294. package/dist/esm/schema/create-table-builder.js +86 -33
  295. package/dist/esm/util/column-type.d.ts +5 -9
  296. package/dist/esm/util/object-utils.js +18 -5
  297. package/dist/esm/util/require-all-props.d.ts +4 -2
  298. package/dist/esm/util/require-all-props.js +4 -2
  299. package/dist/esm/util/streamable.d.ts +1 -1
  300. package/dist/esm/util/type-utils.d.ts +4 -2
  301. package/package.json +30 -24
@@ -0,0 +1,3 @@
1
+ {
2
+ "rangeStrategy": "bump"
3
+ }
package/CONTRIBUTING.md CHANGED
@@ -15,7 +15,7 @@ There are quite a few guidelines to keep in mind:
15
15
 
16
16
  * Kysely should have zero dependencies.
17
17
 
18
- * Kysely should work in all javascript environments (node.js, deno & modern browsers),
18
+ * Kysely should work in all JavaScript environments (node.js, deno & modern browsers),
19
19
  even though the main focus is node.js.
20
20
 
21
21
  * Everything is immutable.
@@ -52,7 +52,7 @@ for all cases, are best left for consumers to implement.
52
52
 
53
53
  5. create a branch.
54
54
 
55
- 6. create a draft pull request. link the relevant issue by refering to it in the
55
+ 6. create a draft pull request. link the relevant issue by referring to it in the
56
56
  PR's description. E.g. `closes #123` will link the PR to issue/pull request #123.
57
57
 
58
58
  7. implement your changes.
package/README.md CHANGED
@@ -5,16 +5,16 @@
5
5
  [![License](https://img.shields.io/github/license/kysely-org/kysely?style=flat)](https://github.com/kysely-org/kysely/blob/master/LICENSE)
6
6
  [![Issues](https://img.shields.io/github/issues-closed/kysely-org/kysely?logo=github)](https://github.com/kysely-org/kysely/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
7
7
  [![Pull Requests](https://img.shields.io/github/issues-pr-closed/kysely-org/kysely?label=PRs&logo=github&style=flat)](https://github.com/kysely-org/kysely/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc)
8
- [![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/kysely-org/kysely?style=flat&logo=snyk)](https://snyk.io/advisor/npm-package/kysely)
9
8
  [![Downloads](https://img.shields.io/npm/dw/kysely?logo=npm)](https://www.npmjs.com/package/kysely)
10
9
  [![Bundle Size](https://img.shields.io/bundlephobia/minzip/kysely?label=size&logo=npm)](https://bundlephobia.com/package/kysely)
11
10
  [![Social](https://img.shields.io/twitter/follow/kysely_?style=social)](https://twitter.com/kysely_)
12
11
 
13
12
  # [Kysely](https://kysely.dev)
14
13
 
15
- Kysely (pronounce “Key-Seh-Lee”) is a type-safe and autocompletion-friendly typescript SQL query builder.
16
- Inspired by [knex](http://knexjs.org/). Mainly developed for [node.js](https://nodejs.org/en/) but also
17
- runs on all other javascript environments like [deno](https://deno.land/).
14
+ Kysely (pronounce “Key-Seh-Lee”) is a type-safe and autocompletion-friendly [TypeScript](https://www.typescriptlang.org/) [SQL](https://en.wikipedia.org/wiki/SQL) query builder.
15
+ Inspired by [Knex.js](http://knexjs.org/). Mainly developed for [Node.js](https://nodejs.org/en/) but also
16
+ runs on all other [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) environments like [Deno](https://deno.com/), [Bun](https://bun.sh/), [Cloudflare Workers](https://workers.cloudflare.com/)
17
+ and web browsers.
18
18
 
19
19
  ![](https://github.com/kysely-org/kysely/blob/master/assets/demo.gif)
20
20
 
@@ -22,7 +22,7 @@ Kysely makes sure you only refer to tables and columns that are visible to the p
22
22
  you're writing. The result type only has the selected columns with correct types and aliases. As an
23
23
  added bonus you get autocompletion for all that stuff.
24
24
 
25
- As shown in the gif above, through the pure magic of modern typescript, Kysely is even able to parse
25
+ As shown in the gif above, through the pure magic of modern TypeScript, Kysely is even able to parse
26
26
  the alias given to `pet.name` and add the `pet_name` column to the result row type. Kysely is able to infer
27
27
  column names, aliases and types from selected subqueries, joined subqueries, `with` statements and pretty
28
28
  much anything you can think of.
@@ -35,12 +35,12 @@ All API documentation is written in the typing files and you can simply hover ov
35
35
  or method you're using to see it in your IDE. The same documentation is also hosted [here](https://kysely-org.github.io/kysely-apidoc/).
36
36
 
37
37
  If you start using Kysely and can't find something you'd want to use, please open an issue or join our
38
- [discord server](https://discord.gg/xyBJ3GwvAm).
38
+ [Discord server](https://discord.gg/xyBJ3GwvAm).
39
39
 
40
40
  # Getting started
41
41
 
42
42
  Please visit our documentation site [kysely.dev](https://kysely.dev) to get started. We also have a comprehensive
43
- API documentation hosted [here](https://kysely-org.github.io/kysely-apidoc/) but you can access the same
43
+ API documentation hosted [here](https://kysely-org.github.io/kysely-apidoc/), but you can access the same
44
44
  documentation in your IDE by hovering over a class/method/property/whatever.
45
45
 
46
46
  # Contributors
@@ -0,0 +1,86 @@
1
+ import type {
2
+ ColumnType,
3
+ Generated,
4
+ GeneratedAlways,
5
+ Insertable,
6
+ Kysely,
7
+ Selectable,
8
+ SqlBool,
9
+ Updateable,
10
+ } from './dist/esm'
11
+
12
+ export interface Database {
13
+ person: PersonTable
14
+ pet: PetTable
15
+ toy: ToyTable
16
+ wine: WineTable
17
+ wine_stock_change: WineStockChangeTable
18
+ }
19
+
20
+ interface PersonTable {
21
+ id: Generated<number>
22
+ address: { city: string } | null
23
+ age: number | null
24
+ birthdate: ColumnType<Date | null, string | null | undefined, string | null>
25
+ created_at: GeneratedAlways<Date>
26
+ deleted_at: ColumnType<Date | null, string | null | undefined, string | null>
27
+ experience: { role: string }[] | null
28
+ first_name: string
29
+ gender: 'male' | 'female' | 'other' | null
30
+ has_pets: Generated<'Y' | 'N'>
31
+ last_name: string | null
32
+ middle_name: string | null
33
+ nicknames: string[] | null
34
+ nullable_column: string | null
35
+ profile: {
36
+ addresses: { city: string }[]
37
+ website: { url: string }
38
+ } | null
39
+ updated_at: ColumnType<Date | null, string | null | undefined, string | null>
40
+ marital_status: 'single' | 'married' | 'divorced' | 'widowed' | null
41
+ }
42
+
43
+ interface PetTable {
44
+ id: Generated<number>
45
+ created_at: GeneratedAlways<Date>
46
+ is_favorite: Generated<SqlBool>
47
+ name: string
48
+ owner_id: number
49
+ species: Species
50
+ }
51
+
52
+ interface ToyTable {
53
+ id: Generated<number>
54
+ pet_id: number
55
+ price: number
56
+ }
57
+
58
+ interface WineTable {
59
+ name: string
60
+ stock: number
61
+ }
62
+
63
+ interface WineStockChangeTable {
64
+ stock_delta: number
65
+ wine_name: string
66
+ }
67
+
68
+ export type Person = Selectable<PersonTable>
69
+ export type NewPerson = Insertable<PersonTable>
70
+ export type PersonUpdate = Updateable<PersonTable>
71
+ export type Pet = Selectable<PetTable>
72
+ export type NewPet = Insertable<PetTable>
73
+ export type PetUpdate = Updateable<PetTable>
74
+ export type Species = 'dog' | 'cat' | 'hamster'
75
+
76
+ declare global {
77
+ // @ts-ignore
78
+ export class Buffer {
79
+ static isBuffer(obj: unknown): obj is { length: number }
80
+ static compare(a: Buffer, b: Buffer): number
81
+ }
82
+ export const db: Kysely<Database>
83
+ export function functionThatExpectsPersonWithNonNullValue(
84
+ person: Person & { nullable_column: string },
85
+ ): void
86
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json",
3
+ "compilerOptions": {
4
+ "types": ["./deno.check.d.ts"]
5
+ },
6
+ "imports": {
7
+ "better-sqlite3": "npm:better-sqlite3",
8
+ "kysely": "./dist/esm",
9
+ "kysely/helpers/mssql": "./dist/esm/helpers/mssql.js",
10
+ "kysely/helpers/mysql": "./dist/esm/helpers/mysql.js",
11
+ "kysely/helpers/postgres": "./dist/esm/helpers/postgres.js",
12
+ "kysely/helpers/sqlite": "./dist/esm/helpers/sqlite.js",
13
+ "lodash/snakeCase": "npm:lodash/snakeCase",
14
+ "mysql2": "npm:mysql2",
15
+ "pg": "npm:pg",
16
+ "pg-cursor": "npm:pg-cursor",
17
+ "tarn": "npm:tarn",
18
+ "tedious": "npm:tedious",
19
+ "type-editor": "./deno.check.d.ts"
20
+ }
21
+ }
@@ -2,7 +2,7 @@ import { Kysely } from '../kysely.js';
2
2
  import { DialectAdapter, MigrationLockOptions } from './dialect-adapter.js';
3
3
  /**
4
4
  * A basic implementation of `DialectAdapter` with sensible default values.
5
- * 3rd party dialects can extend this instead of implementing the `DialectAdapter`
5
+ * Third-party dialects can extend this instead of implementing the `DialectAdapter`
6
6
  * interface from scratch. That way all new settings will get default values when
7
7
  * they are added and there will be less breaking changes.
8
8
  */
@@ -26,6 +26,7 @@ export declare abstract class DialectAdapterBase implements DialectAdapter {
26
26
  * updates and deletes.
27
27
  */
28
28
  get supportsReturning(): boolean;
29
+ get supportsOutput(): boolean;
29
30
  /**
30
31
  * This method is used to acquire a lock for the migrations so that
31
32
  * it's not possible for two migration operations to run in parallel.
@@ -46,8 +47,13 @@ export declare abstract class DialectAdapterBase implements DialectAdapter {
46
47
  * have explicit locks but supports `FOR UPDATE` row locks and transactional DDL:
47
48
  *
48
49
  * ```ts
49
- * {
50
- * async acquireMigrationLock(db, options): Promise<void> {
50
+ * import { DialectAdapterBase, type MigrationLockOptions, Kysely } from 'kysely'
51
+ *
52
+ * export class MyAdapter extends DialectAdapterBase {
53
+ * override async acquireMigrationLock(
54
+ * db: Kysely<any>,
55
+ * options: MigrationLockOptions
56
+ * ): Promise<void> {
51
57
  * const queryDb = options.lockTableSchema
52
58
  * ? db.withSchema(options.lockTableSchema)
53
59
  * : db
@@ -63,6 +69,10 @@ export declare abstract class DialectAdapterBase implements DialectAdapter {
63
69
  * .forUpdate()
64
70
  * .execute()
65
71
  * }
72
+ *
73
+ * override async releaseMigrationLock() {
74
+ * // noop
75
+ * }
66
76
  * }
67
77
  * ```
68
78
  *
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DialectAdapterBase = void 0;
4
4
  /**
5
5
  * A basic implementation of `DialectAdapter` with sensible default values.
6
- * 3rd party dialects can extend this instead of implementing the `DialectAdapter`
6
+ * Third-party dialects can extend this instead of implementing the `DialectAdapter`
7
7
  * interface from scratch. That way all new settings will get default values when
8
8
  * they are added and there will be less breaking changes.
9
9
  */
@@ -17,5 +17,8 @@ class DialectAdapterBase {
17
17
  get supportsReturning() {
18
18
  return false;
19
19
  }
20
+ get supportsOutput() {
21
+ return false;
22
+ }
20
23
  }
21
24
  exports.DialectAdapterBase = DialectAdapterBase;
@@ -27,6 +27,11 @@ export interface DialectAdapter {
27
27
  * updates and deletes.
28
28
  */
29
29
  readonly supportsReturning: boolean;
30
+ /**
31
+ * Whether or not this dialect supports the `output` clause in inserts
32
+ * updates and deletes.
33
+ */
34
+ readonly supportsOutput?: boolean;
30
35
  /**
31
36
  * This method is used to acquire a lock for the migrations so that
32
37
  * it's not possible for two migration operations to run in parallel.
@@ -47,8 +52,13 @@ export interface DialectAdapter {
47
52
  * have explicit locks but supports `FOR UPDATE` row locks and transactional DDL:
48
53
  *
49
54
  * ```ts
50
- * {
51
- * async acquireMigrationLock(db, options): Promise<void> {
55
+ * import { DialectAdapterBase, type MigrationLockOptions, Kysely } from 'kysely'
56
+ *
57
+ * export class MyAdapter extends DialectAdapterBase {
58
+ * override async acquireMigrationLock(
59
+ * db: Kysely<any>,
60
+ * options: MigrationLockOptions
61
+ * ): Promise<void> {
52
62
  * const queryDb = options.lockTableSchema
53
63
  * ? db.withSchema(options.lockTableSchema)
54
64
  * : db
@@ -64,6 +74,10 @@ export interface DialectAdapter {
64
74
  * .forUpdate()
65
75
  * .execute()
66
76
  * }
77
+ *
78
+ * override async releaseMigrationLock() {
79
+ * // noop
80
+ * }
67
81
  * }
68
82
  * ```
69
83
  *
@@ -15,11 +15,7 @@ export declare class MssqlAdapter extends DialectAdapterBase {
15
15
  * If this is true, migrations are executed inside a transaction.
16
16
  */
17
17
  get supportsTransactionalDdl(): boolean;
18
- /**
19
- * Whether or not this dialect supports the `returning` in inserts
20
- * updates and deletes.
21
- */
22
- get supportsReturning(): boolean;
18
+ get supportsOutput(): boolean;
23
19
  /**
24
20
  * This method is used to acquire a lock for the migrations so that
25
21
  * it's not possible for two migration operations to run in parallel.
@@ -40,8 +36,13 @@ export declare class MssqlAdapter extends DialectAdapterBase {
40
36
  * have explicit locks but supports `FOR UPDATE` row locks and transactional DDL:
41
37
  *
42
38
  * ```ts
43
- * {
44
- * async acquireMigrationLock(db, options): Promise<void> {
39
+ * import { DialectAdapterBase, type MigrationLockOptions, Kysely } from 'kysely'
40
+ *
41
+ * export class MyAdapter extends DialectAdapterBase {
42
+ * override async acquireMigrationLock(
43
+ * db: Kysely<any>,
44
+ * options: MigrationLockOptions
45
+ * ): Promise<void> {
45
46
  * const queryDb = options.lockTableSchema
46
47
  * ? db.withSchema(options.lockTableSchema)
47
48
  * : db
@@ -57,6 +58,10 @@ export declare class MssqlAdapter extends DialectAdapterBase {
57
58
  * .forUpdate()
58
59
  * .execute()
59
60
  * }
61
+ *
62
+ * override async releaseMigrationLock() {
63
+ * // noop
64
+ * }
60
65
  * }
61
66
  * ```
62
67
  *
@@ -11,10 +11,8 @@ class MssqlAdapter extends dialect_adapter_base_js_1.DialectAdapterBase {
11
11
  get supportsTransactionalDdl() {
12
12
  return true;
13
13
  }
14
- get supportsReturning() {
15
- // mssql should support returning with the `output` clause.
16
- // we need to figure this out when we'll introduce support for it.
17
- return false;
14
+ get supportsOutput() {
15
+ return true;
18
16
  }
19
17
  async acquireMigrationLock(db) {
20
18
  // Acquire a transaction-level exclusive lock on the migrations table.
@@ -6,21 +6,23 @@ export interface MssqlDialectConfig {
6
6
  * (excluding `create`, `destroy` and `validate` functions which are controlled by this dialect),
7
7
  * `min` & `max` connections at the very least.
8
8
  *
9
- * Example:
9
+ * ### Examples
10
10
  *
11
11
  * ```ts
12
+ * import { MssqlDialect } from 'kysely'
12
13
  * import * as Tarn from 'tarn'
14
+ * import * as Tedious from 'tedious'
13
15
  *
14
16
  * const dialect = new MssqlDialect({
15
- * // ...
16
- * tarn: {
17
- * ...Tarn,
18
- * options: {
17
+ * tarn: { ...Tarn, options: { max: 10, min: 0 } },
18
+ * tedious: {
19
+ * ...Tedious,
20
+ * connectionFactory: () => new Tedious.Connection({
19
21
  * // ...
20
- * min: 0,
21
- * max: 10,
22
- * },
23
- * },
22
+ * server: 'localhost',
23
+ * // ...
24
+ * }),
25
+ * }
24
26
  * })
25
27
  * ```
26
28
  */
@@ -31,17 +33,23 @@ export interface MssqlDialectConfig {
31
33
  * you need to pass the `tedious` package itself. You also need to pass a factory
32
34
  * function that creates new `tedious` `Connection` instances on demand.
33
35
  *
34
- * Example:
36
+ * ### Examples
35
37
  *
36
38
  * ```ts
39
+ * import { MssqlDialect } from 'kysely'
40
+ * import * as Tarn from 'tarn'
37
41
  * import * as Tedious from 'tedious'
38
42
  *
39
43
  * const dialect = new MssqlDialect({
40
- * // ...
44
+ * tarn: { ...Tarn, options: { max: 10, min: 0 } },
41
45
  * tedious: {
42
46
  * ...Tedious,
43
- * connectionFactory: () => new Tedious.Connection({ ... }),
44
- * },
47
+ * connectionFactory: () => new Tedious.Connection({
48
+ * // ...
49
+ * server: 'localhost',
50
+ * // ...
51
+ * }),
52
+ * }
45
53
  * })
46
54
  * ```
47
55
  */
@@ -50,39 +58,66 @@ export interface MssqlDialectConfig {
50
58
  export interface Tedious {
51
59
  connectionFactory: () => TediousConnection | Promise<TediousConnection>;
52
60
  ISOLATION_LEVEL: TediousIsolationLevel;
53
- Request: typeof TediousRequest;
61
+ Request: TediousRequestClass;
54
62
  TYPES: TediousTypes;
55
- }
56
- export type TediousIsolationLevel = Record<'NO_CHANGE' | 'READ_UNCOMMITTED' | 'READ_COMMITTED' | 'REPEATABLE_READ' | 'SERIALIZABLE' | 'SNAPSHOT', number>;
57
- export type TediousTypes = Record<'BigInt' | 'Binary' | 'Bit' | 'Char' | 'Date' | 'DateTime' | 'DateTime2' | 'DateTimeOffset' | 'Decimal' | 'Float' | 'Image' | 'Int' | 'Money' | 'NChar' | 'NText' | 'Null' | 'Numeric' | 'NVarChar' | 'Real' | 'SmallDateTime' | 'SmallInt' | 'SmallMoney' | 'Text' | 'Time' | 'TinyInt' | 'TVP' | 'UDT' | 'UniqueIdentifier' | 'VarBinary' | 'VarChar' | 'Xml', {
58
- name: string;
59
- type: string;
60
- }>;
61
- export interface TediousType {
62
- name: string;
63
- type: string;
63
+ /**
64
+ * Controls whether connections are reset to their initial states when released back to the pool. Resetting a connection performs additional requests to the database.
65
+ * See {@link https://tediousjs.github.io/tedious/api-connection.html#function_reset | connection.reset}.
66
+ *
67
+ * Defaults to `true`.
68
+ */
69
+ resetConnectionOnRelease?: boolean;
64
70
  }
65
71
  export interface TediousConnection {
66
- beginTransaction(callback: (error?: Error) => void, transactionId?: string | undefined, isolationLevel?: number | undefined): void;
67
- cancel(): void;
72
+ beginTransaction(callback: (error?: Error | null, transactionDescriptor?: any) => void, name?: string, isolationLevel?: number): void;
73
+ cancel(): boolean;
68
74
  close(): void;
69
- commitTransaction(callback: (error?: Error) => void): void;
70
- connect(callback: (error?: Error) => void): void;
75
+ commitTransaction(callback: (error?: Error | null) => void, name?: string): void;
76
+ connect(callback?: (error?: Error) => void): void;
71
77
  execSql(request: TediousRequest): void;
72
- reset(callback: (error?: Error) => void): void;
73
- rollbackTransaction(callback: (error?: Error) => void): void;
74
- once(event: 'end', listener: () => void): void;
78
+ off(event: 'error', listener: (error: unknown) => void): this;
79
+ off(event: string, listener: (...args: any[]) => void): this;
80
+ on(event: 'error', listener: (error: unknown) => void): this;
81
+ on(event: string, listener: (...args: any[]) => void): this;
82
+ once(event: 'end', listener: () => void): this;
83
+ once(event: string, listener: (...args: any[]) => void): this;
84
+ reset(callback: (error?: Error | null) => void): void;
85
+ rollbackTransaction(callback: (error?: Error | null) => void, name?: string): void;
86
+ saveTransaction(callback: (error?: Error | null) => void, name: string): void;
87
+ }
88
+ export type TediousIsolationLevel = Record<string, number>;
89
+ export interface TediousRequestClass {
90
+ new (sqlTextOrProcedure: string | undefined, callback: (error?: Error | null, rowCount?: number, rows?: any) => void, options?: {
91
+ statementColumnEncryptionSetting?: any;
92
+ }): TediousRequest;
75
93
  }
76
94
  export declare class TediousRequest {
77
- constructor(sql: string, callback: (error: Error, rowCount: number, rows: any[]) => void);
78
- addParameter(name: string, type: TediousType, value: any, options?: {
79
- length?: number | 'max' | undefined;
80
- precision?: number | undefined;
81
- scale?: number | undefined;
82
- }): void;
83
- off(event: 'row', listener: (...args: any[]) => void): void;
84
- on(event: 'row', listener: (columns: TediousColumnValue[]) => void): void;
85
- once(event: 'requestCompleted', listener: (...args: any[]) => void): void;
95
+ addParameter(name: string, dataType: TediousDataType, value?: unknown, options?: Readonly<{
96
+ output?: boolean;
97
+ length?: number;
98
+ precision?: number;
99
+ scale?: number;
100
+ }> | null): void;
101
+ off(event: 'row', listener: (columns: any) => void): this;
102
+ off(event: string, listener: (...args: any[]) => void): this;
103
+ on(event: 'row', listener: (columns: any) => void): this;
104
+ on(event: string, listener: (...args: any[]) => void): this;
105
+ once(event: 'requestCompleted', listener: () => void): this;
106
+ once(event: string, listener: (...args: any[]) => void): this;
107
+ pause(): void;
108
+ resume(): void;
109
+ }
110
+ export interface TediousTypes {
111
+ NVarChar: TediousDataType;
112
+ BigInt: TediousDataType;
113
+ Int: TediousDataType;
114
+ Float: TediousDataType;
115
+ Bit: TediousDataType;
116
+ DateTime: TediousDataType;
117
+ VarBinary: TediousDataType;
118
+ [x: string]: TediousDataType;
119
+ }
120
+ export interface TediousDataType {
86
121
  }
87
122
  export interface TediousColumnValue {
88
123
  metadata: {
@@ -95,23 +130,16 @@ export interface Tarn {
95
130
  * Tarn.js' pool options, excluding `create`, `destroy` and `validate` functions,
96
131
  * which must be implemented by this dialect.
97
132
  */
98
- options: Omit<TarnPoolOptions<any>, 'create' | 'destroy' | 'validate'>;
133
+ options: Omit<TarnPoolOptions<any>, 'create' | 'destroy' | 'validate'> & {
134
+ /**
135
+ * Controls whether connections are validated before being acquired from the pool. Connection validation performs additional requests to the database.
136
+ *
137
+ * Defaults to `true`.
138
+ */
139
+ validateConnections?: boolean;
140
+ };
99
141
  /**
100
142
  * Tarn.js' Pool class.
101
- *
102
- * Example:
103
- *
104
- * ```ts
105
- * import { Pool } from 'tarn'
106
- *
107
- * const dialect = new MssqlDialect({
108
- * // ...
109
- * tarn: {
110
- * // ...
111
- * Pool,
112
- * },
113
- * })
114
- * ```
115
143
  */
116
144
  Pool: typeof TarnPool;
117
145
  }
@@ -134,7 +162,7 @@ export interface TarnPoolOptions<R> {
134
162
  min: number;
135
163
  propagateCreateError?: boolean;
136
164
  reapIntervalMillis?: number;
137
- validate(resource: R): boolean;
165
+ validate?(resource: R): boolean;
138
166
  }
139
167
  export interface TarnPendingRequest<R> {
140
168
  promise: Promise<R>;
@@ -44,6 +44,7 @@ declare class MssqlConnection implements DatabaseConnection {
44
44
  constructor(connection: TediousConnection, tedious: Tedious);
45
45
  beginTransaction(settings: TransactionSettings): Promise<void>;
46
46
  commitTransaction(): Promise<void>;
47
+ connect(): Promise<this>;
47
48
  executeQuery<O>(compiledQuery: CompiledQuery): Promise<QueryResult<O>>;
48
49
  rollbackTransaction(): Promise<void>;
49
50
  streamQuery<O>(compiledQuery: CompiledQuery, chunkSize: number): AsyncIterableIterator<QueryResult<O>>;