kysely 0.16.1 → 0.16.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 (253) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +205 -0
  3. package/dist/cjs/dialect/mysql/mysql-dialect-config.js +2 -0
  4. package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +1 -205
  5. package/dist/cjs/dialect/mysql/mysql-driver.d.ts +1 -1
  6. package/dist/cjs/dialect/mysql/mysql-driver.js +10 -2
  7. package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +103 -0
  8. package/dist/cjs/dialect/postgres/postgres-dialect-config.js +2 -0
  9. package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +1 -103
  10. package/dist/cjs/dialect/postgres/postgres-driver.d.ts +1 -1
  11. package/dist/cjs/dialect/postgres/postgres-driver.js +11 -2
  12. package/dist/cjs/dialect/sqlite/sqlite-dialect-config.d.ts +43 -0
  13. package/dist/cjs/dialect/sqlite/sqlite-dialect-config.js +2 -0
  14. package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +1 -43
  15. package/dist/cjs/dialect/sqlite/sqlite-driver.d.ts +1 -1
  16. package/dist/cjs/dialect/sqlite/sqlite-driver.js +10 -2
  17. package/dist/cjs/index.d.ts +3 -0
  18. package/dist/cjs/index.js +3 -0
  19. package/dist/cjs/migration/migrator.d.ts +2 -2
  20. package/dist/cjs/operation-node/primitive-value-list-node.d.ts +2 -3
  21. package/dist/cjs/operation-node/value-node.d.ts +3 -4
  22. package/dist/cjs/parser/complex-expression-parser.d.ts +1 -0
  23. package/dist/cjs/parser/complex-expression-parser.js +5 -1
  24. package/dist/cjs/parser/default-value-parser.d.ts +2 -3
  25. package/dist/cjs/parser/default-value-parser.js +2 -2
  26. package/dist/cjs/parser/insert-values-parser.js +4 -3
  27. package/dist/cjs/parser/reference-parser.d.ts +2 -3
  28. package/dist/cjs/parser/value-parser.d.ts +2 -3
  29. package/dist/cjs/parser/value-parser.js +6 -7
  30. package/dist/cjs/plugin/camel-case/camel-case-plugin.js +1 -1
  31. package/dist/cjs/query-builder/expression-builder.d.ts +42 -0
  32. package/dist/cjs/query-builder/expression-builder.js +48 -0
  33. package/dist/cjs/query-builder/insert-query-builder.d.ts +16 -0
  34. package/dist/cjs/query-builder/insert-query-builder.js +16 -0
  35. package/dist/cjs/query-builder/on-conflict-builder.d.ts +5 -3
  36. package/dist/cjs/query-compiler/default-query-compiler.d.ts +1 -2
  37. package/dist/cjs/query-creator.d.ts +1 -1
  38. package/dist/cjs/schema/alter-table-builder.d.ts +30 -4
  39. package/dist/cjs/schema/alter-table-builder.js +2 -5
  40. package/dist/cjs/schema/column-definition-builder.d.ts +27 -2
  41. package/dist/cjs/util/object-utils.d.ts +4 -5
  42. package/dist/cjs/util/object-utils.js +8 -16
  43. package/dist/esm/dialect/database-introspector.js +1 -0
  44. package/dist/esm/dialect/dialect-adapter-base.js +1 -0
  45. package/dist/esm/dialect/dialect-adapter.js +1 -0
  46. package/dist/esm/dialect/dialect.js +1 -0
  47. package/dist/esm/dialect/mysql/mysql-adapter.js +1 -0
  48. package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +205 -0
  49. package/dist/esm/dialect/mysql/mysql-dialect-config.js +2 -0
  50. package/dist/esm/dialect/mysql/mysql-dialect.d.ts +1 -205
  51. package/dist/esm/dialect/mysql/mysql-dialect.js +1 -0
  52. package/dist/esm/dialect/mysql/mysql-driver.d.ts +1 -1
  53. package/dist/esm/dialect/mysql/mysql-driver.js +12 -3
  54. package/dist/esm/dialect/mysql/mysql-introspector.js +1 -0
  55. package/dist/esm/dialect/mysql/mysql-query-compiler.js +1 -0
  56. package/dist/esm/dialect/postgres/postgres-adapter.js +1 -0
  57. package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +103 -0
  58. package/dist/esm/dialect/postgres/postgres-dialect-config.js +2 -0
  59. package/dist/esm/dialect/postgres/postgres-dialect.d.ts +1 -103
  60. package/dist/esm/dialect/postgres/postgres-dialect.js +1 -0
  61. package/dist/esm/dialect/postgres/postgres-driver.d.ts +1 -1
  62. package/dist/esm/dialect/postgres/postgres-driver.js +12 -2
  63. package/dist/esm/dialect/postgres/postgres-introspector.js +1 -0
  64. package/dist/esm/dialect/postgres/postgres-query-compiler.js +1 -0
  65. package/dist/esm/dialect/sqlite/sqlite-adapter.js +1 -0
  66. package/dist/esm/dialect/sqlite/sqlite-dialect-config.d.ts +43 -0
  67. package/dist/esm/dialect/sqlite/sqlite-dialect-config.js +2 -0
  68. package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +1 -43
  69. package/dist/esm/dialect/sqlite/sqlite-dialect.js +1 -0
  70. package/dist/esm/dialect/sqlite/sqlite-driver.d.ts +1 -1
  71. package/dist/esm/dialect/sqlite/sqlite-driver.js +11 -2
  72. package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -0
  73. package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +1 -0
  74. package/dist/esm/driver/connection-provider.js +1 -0
  75. package/dist/esm/driver/database-connection.js +1 -0
  76. package/dist/esm/driver/default-connection-provider.js +1 -0
  77. package/dist/esm/driver/driver.js +1 -0
  78. package/dist/esm/driver/runtime-driver.js +1 -0
  79. package/dist/esm/driver/single-connection-provider.js +1 -0
  80. package/dist/esm/dynamic/dynamic-reference-builder.js +1 -0
  81. package/dist/esm/dynamic/dynamic.js +1 -0
  82. package/dist/esm/index-nodeless.js +1 -0
  83. package/dist/esm/index.d.ts +3 -0
  84. package/dist/esm/index.js +4 -0
  85. package/dist/esm/kysely.js +1 -0
  86. package/dist/esm/migration/file-migration-provider.js +1 -0
  87. package/dist/esm/migration/migrator.d.ts +2 -2
  88. package/dist/esm/migration/migrator.js +1 -0
  89. package/dist/esm/operation-node/add-column-node.js +1 -0
  90. package/dist/esm/operation-node/add-constraint-node.js +1 -0
  91. package/dist/esm/operation-node/alias-node.js +1 -0
  92. package/dist/esm/operation-node/alter-column-node.js +1 -0
  93. package/dist/esm/operation-node/alter-table-node.js +1 -0
  94. package/dist/esm/operation-node/and-node.js +1 -0
  95. package/dist/esm/operation-node/check-constraint-node.js +1 -0
  96. package/dist/esm/operation-node/column-definition-node.js +1 -0
  97. package/dist/esm/operation-node/column-node.js +1 -0
  98. package/dist/esm/operation-node/column-update-node.js +1 -0
  99. package/dist/esm/operation-node/common-table-expression-name-node.js +1 -0
  100. package/dist/esm/operation-node/common-table-expression-node.js +1 -0
  101. package/dist/esm/operation-node/constraint-node.js +1 -0
  102. package/dist/esm/operation-node/create-index-node.js +1 -0
  103. package/dist/esm/operation-node/create-schema-node.js +1 -0
  104. package/dist/esm/operation-node/create-table-node.js +1 -0
  105. package/dist/esm/operation-node/create-view-node.js +1 -0
  106. package/dist/esm/operation-node/data-type-node.js +1 -0
  107. package/dist/esm/operation-node/default-value-node.js +1 -0
  108. package/dist/esm/operation-node/delete-query-node.js +1 -0
  109. package/dist/esm/operation-node/drop-column-node.js +1 -0
  110. package/dist/esm/operation-node/drop-constraint-node.js +1 -0
  111. package/dist/esm/operation-node/drop-index-node.js +1 -0
  112. package/dist/esm/operation-node/drop-schema-node.js +1 -0
  113. package/dist/esm/operation-node/drop-table-node.js +1 -0
  114. package/dist/esm/operation-node/drop-view-node.js +1 -0
  115. package/dist/esm/operation-node/filter-node.js +1 -0
  116. package/dist/esm/operation-node/foreign-key-constraint-node.js +1 -0
  117. package/dist/esm/operation-node/from-node.js +1 -0
  118. package/dist/esm/operation-node/generated-node.js +1 -0
  119. package/dist/esm/operation-node/group-by-item-node.js +1 -0
  120. package/dist/esm/operation-node/group-by-node.js +1 -0
  121. package/dist/esm/operation-node/having-node.js +1 -0
  122. package/dist/esm/operation-node/identifier-node.js +1 -0
  123. package/dist/esm/operation-node/insert-query-node.js +1 -0
  124. package/dist/esm/operation-node/join-node.js +1 -0
  125. package/dist/esm/operation-node/limit-node.js +1 -0
  126. package/dist/esm/operation-node/list-node.js +1 -0
  127. package/dist/esm/operation-node/modify-column-node.js +1 -0
  128. package/dist/esm/operation-node/offset-node.js +1 -0
  129. package/dist/esm/operation-node/on-conflict-node.js +1 -0
  130. package/dist/esm/operation-node/on-duplicate-key-node.js +1 -0
  131. package/dist/esm/operation-node/on-node.js +1 -0
  132. package/dist/esm/operation-node/operation-node-source.js +1 -0
  133. package/dist/esm/operation-node/operation-node-transformer.js +1 -0
  134. package/dist/esm/operation-node/operation-node-utils.js +1 -0
  135. package/dist/esm/operation-node/operation-node-visitor.js +1 -0
  136. package/dist/esm/operation-node/operation-node.js +1 -0
  137. package/dist/esm/operation-node/operator-node.js +1 -0
  138. package/dist/esm/operation-node/or-node.js +1 -0
  139. package/dist/esm/operation-node/order-by-item-node.js +1 -0
  140. package/dist/esm/operation-node/order-by-node.js +1 -0
  141. package/dist/esm/operation-node/parens-node.js +1 -0
  142. package/dist/esm/operation-node/primary-constraint-node.js +1 -0
  143. package/dist/esm/operation-node/primitive-value-list-node.d.ts +2 -3
  144. package/dist/esm/operation-node/primitive-value-list-node.js +1 -0
  145. package/dist/esm/operation-node/query-node.js +1 -0
  146. package/dist/esm/operation-node/raw-node.js +1 -0
  147. package/dist/esm/operation-node/reference-node.js +1 -0
  148. package/dist/esm/operation-node/references-node.js +1 -0
  149. package/dist/esm/operation-node/rename-column-node.js +1 -0
  150. package/dist/esm/operation-node/returning-node.js +1 -0
  151. package/dist/esm/operation-node/select-all-node.js +1 -0
  152. package/dist/esm/operation-node/select-query-node.js +1 -0
  153. package/dist/esm/operation-node/selection-node.js +1 -0
  154. package/dist/esm/operation-node/table-node.js +1 -0
  155. package/dist/esm/operation-node/union-node.js +1 -0
  156. package/dist/esm/operation-node/unique-constraint-node.js +1 -0
  157. package/dist/esm/operation-node/update-query-node.js +1 -0
  158. package/dist/esm/operation-node/value-list-node.js +1 -0
  159. package/dist/esm/operation-node/value-node.d.ts +3 -4
  160. package/dist/esm/operation-node/value-node.js +1 -0
  161. package/dist/esm/operation-node/values-node.js +1 -0
  162. package/dist/esm/operation-node/where-node.js +1 -0
  163. package/dist/esm/operation-node/with-node.js +1 -0
  164. package/dist/esm/parser/complex-expression-parser.d.ts +1 -0
  165. package/dist/esm/parser/complex-expression-parser.js +4 -0
  166. package/dist/esm/parser/data-type-parser.js +1 -0
  167. package/dist/esm/parser/default-value-parser.d.ts +2 -3
  168. package/dist/esm/parser/default-value-parser.js +3 -2
  169. package/dist/esm/parser/filter-parser.js +1 -0
  170. package/dist/esm/parser/group-by-parser.js +1 -0
  171. package/dist/esm/parser/insert-values-parser.js +6 -4
  172. package/dist/esm/parser/join-parser.js +1 -0
  173. package/dist/esm/parser/order-by-parser.js +1 -0
  174. package/dist/esm/parser/parse-context.js +1 -0
  175. package/dist/esm/parser/reference-parser.d.ts +2 -3
  176. package/dist/esm/parser/reference-parser.js +2 -1
  177. package/dist/esm/parser/returning-parser.js +1 -0
  178. package/dist/esm/parser/select-parser.js +1 -0
  179. package/dist/esm/parser/table-parser.js +1 -0
  180. package/dist/esm/parser/union-parser.js +1 -0
  181. package/dist/esm/parser/update-set-parser.js +1 -0
  182. package/dist/esm/parser/value-parser.d.ts +2 -3
  183. package/dist/esm/parser/value-parser.js +9 -9
  184. package/dist/esm/parser/with-parser.js +1 -0
  185. package/dist/esm/plugin/camel-case/camel-case-plugin.js +3 -2
  186. package/dist/esm/plugin/camel-case/camel-case-transformer.js +1 -0
  187. package/dist/esm/plugin/camel-case/camel-case.js +1 -0
  188. package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +1 -0
  189. package/dist/esm/plugin/immediate-value.ts/immediate-value-transformer.js +1 -0
  190. package/dist/esm/plugin/kysely-plugin.js +1 -0
  191. package/dist/esm/plugin/with-schema/with-schema-plugin.js +1 -0
  192. package/dist/esm/plugin/with-schema/with-schema-transformer.js +1 -0
  193. package/dist/esm/query-builder/delete-query-builder.js +1 -0
  194. package/dist/esm/query-builder/delete-result.js +1 -0
  195. package/dist/esm/query-builder/expression-builder.d.ts +42 -0
  196. package/dist/esm/query-builder/expression-builder.js +49 -0
  197. package/dist/esm/query-builder/function-builder.js +1 -0
  198. package/dist/esm/query-builder/having-interface.js +1 -0
  199. package/dist/esm/query-builder/insert-query-builder.d.ts +16 -0
  200. package/dist/esm/query-builder/insert-query-builder.js +17 -0
  201. package/dist/esm/query-builder/insert-result.js +1 -0
  202. package/dist/esm/query-builder/join-builder.js +1 -0
  203. package/dist/esm/query-builder/join-interface.js +1 -0
  204. package/dist/esm/query-builder/no-result-error.js +1 -0
  205. package/dist/esm/query-builder/on-conflict-builder.d.ts +5 -3
  206. package/dist/esm/query-builder/on-conflict-builder.js +1 -0
  207. package/dist/esm/query-builder/returning-interface.js +1 -0
  208. package/dist/esm/query-builder/select-query-builder.js +1 -0
  209. package/dist/esm/query-builder/update-query-builder.js +1 -0
  210. package/dist/esm/query-builder/update-result.js +1 -0
  211. package/dist/esm/query-builder/where-interface.js +1 -0
  212. package/dist/esm/query-compiler/compiled-query.js +1 -0
  213. package/dist/esm/query-compiler/default-query-compiler.d.ts +1 -2
  214. package/dist/esm/query-compiler/default-query-compiler.js +1 -0
  215. package/dist/esm/query-compiler/query-compiler.js +1 -0
  216. package/dist/esm/query-creator.d.ts +1 -1
  217. package/dist/esm/query-creator.js +1 -0
  218. package/dist/esm/query-executor/default-query-executor.js +1 -0
  219. package/dist/esm/query-executor/noop-query-executor.js +1 -0
  220. package/dist/esm/query-executor/query-executor.js +1 -0
  221. package/dist/esm/raw-builder/raw-builder.js +1 -0
  222. package/dist/esm/schema/alter-table-builder.d.ts +30 -4
  223. package/dist/esm/schema/alter-table-builder.js +3 -5
  224. package/dist/esm/schema/column-definition-builder.d.ts +27 -2
  225. package/dist/esm/schema/column-definition-builder.js +1 -0
  226. package/dist/esm/schema/create-index-builder.js +1 -0
  227. package/dist/esm/schema/create-schema-builder.js +1 -0
  228. package/dist/esm/schema/create-table-builder.js +1 -0
  229. package/dist/esm/schema/create-view-builder.js +1 -0
  230. package/dist/esm/schema/drop-index-builder.js +1 -0
  231. package/dist/esm/schema/drop-schema-builder.js +1 -0
  232. package/dist/esm/schema/drop-table-builder.js +1 -0
  233. package/dist/esm/schema/drop-view-builder.js +1 -0
  234. package/dist/esm/schema/foreign-key-constraint-builder.js +1 -0
  235. package/dist/esm/schema/schema.js +1 -0
  236. package/dist/esm/util/assert.js +1 -0
  237. package/dist/esm/util/column-type.js +1 -0
  238. package/dist/esm/util/compilable.js +1 -0
  239. package/dist/esm/util/log.js +1 -0
  240. package/dist/esm/util/object-utils.d.ts +4 -5
  241. package/dist/esm/util/object-utils.js +6 -12
  242. package/dist/esm/util/performance-now.js +1 -0
  243. package/dist/esm/util/prevent-await.js +1 -0
  244. package/dist/esm/util/private-symbols.js +1 -0
  245. package/dist/esm/util/query-id.js +1 -0
  246. package/dist/esm/util/random-string.js +1 -0
  247. package/dist/esm/util/type-utils.js +1 -0
  248. package/package.json +3 -2
  249. package/.prettierignore +0 -1
  250. package/dist/cjs/util/dynamic-import.d.ts +0 -2
  251. package/dist/cjs/util/dynamic-import.js +0 -32
  252. package/dist/esm/util/dynamic-import.d.ts +0 -2
  253. package/dist/esm/util/dynamic-import.js +0 -27
@@ -4,7 +4,7 @@ import { QueryCompiler } from '../../query-compiler/query-compiler.js';
4
4
  import { Dialect } from '../dialect.js';
5
5
  import { DatabaseIntrospector } from '../database-introspector.js';
6
6
  import { DialectAdapter } from '../dialect-adapter.js';
7
- import { DatabaseConnection } from '../../driver/database-connection.js';
7
+ import { MysqlDialectConfig } from './mysql-dialect-config.js';
8
8
  /**
9
9
  * MySQL dialect that uses the [mysql2](https://github.com/sidorares/node-mysql2#readme) library.
10
10
  *
@@ -36,207 +36,3 @@ export declare class MysqlDialect implements Dialect {
36
36
  */
37
37
  createIntrospector(db: Kysely<any>): DatabaseIntrospector;
38
38
  }
39
- /**
40
- * Config for the MySQL dialect.
41
- *
42
- * This interface is equal to `mysql2` library's pool config.
43
- *
44
- * https://github.com/sidorares/node-mysql2#using-connection-pools
45
- */
46
- export interface MysqlDialectConfig {
47
- /**
48
- * The MySQL user to authenticate as
49
- */
50
- user?: string;
51
- /**
52
- * The password of that MySQL user
53
- */
54
- password?: string;
55
- /**
56
- * Name of the database to use for this connection
57
- */
58
- database?: string;
59
- /**
60
- * The charset for the connection. This is called 'collation' in the SQL-level of MySQL (like utf8_general_ci).
61
- * If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used.
62
- * (Default: 'UTF8_GENERAL_CI')
63
- */
64
- charset?: string;
65
- /**
66
- * The hostname of the database you are connecting to. (Default: localhost)
67
- */
68
- host?: string;
69
- /**
70
- * The port number to connect to. (Default: 3306)
71
- */
72
- port?: number;
73
- /**
74
- * The source IP address to use for TCP connection
75
- */
76
- localAddress?: string;
77
- /**
78
- * The path to a unix domain socket to connect to. When used host and port are ignored
79
- */
80
- socketPath?: string;
81
- /**
82
- * The timezone used to store local dates. (Default: 'local')
83
- */
84
- timezone?: string | 'local';
85
- /**
86
- * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
87
- */
88
- connectTimeout?: number;
89
- /**
90
- * Stringify objects instead of converting to values. (Default: 'false')
91
- */
92
- stringifyObjects?: boolean;
93
- /**
94
- * Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
95
- */
96
- insecureAuth?: boolean;
97
- /**
98
- * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
99
- * to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
100
- *
101
- * You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
102
- *
103
- * WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
104
- *
105
- * field.string()
106
- * field.buffer()
107
- * field.geometry()
108
- *
109
- * are aliases for
110
- *
111
- * parser.parseLengthCodedString()
112
- * parser.parseLengthCodedBuffer()
113
- * parser.parseGeometryValue()
114
- *
115
- * You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
116
- */
117
- typeCast?: boolean | ((field: any, next: () => void) => any);
118
- /**
119
- * A custom query format function
120
- */
121
- queryFormat?: (query: string, values: any) => void;
122
- /**
123
- * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
124
- * (Default: false)
125
- */
126
- supportBigNumbers?: boolean;
127
- /**
128
- * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
129
- * always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
130
- * bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
131
- * represented with [JavaScript Number objects] (http://ecma262-5.com/ELS5_HTML.htm#Section_8.5)
132
- * (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects.
133
- * This option is ignored if supportBigNumbers is disabled.
134
- */
135
- bigNumberStrings?: boolean;
136
- /**
137
- * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
138
- * objects. Can be true/false or an array of type names to keep as strings.
139
- *
140
- * (Default: false)
141
- */
142
- dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
143
- /**
144
- * This will print all incoming and outgoing packets on stdout.
145
- * You can also restrict debugging to packet types by passing an array of types (strings) to debug;
146
- *
147
- * (Default: false)
148
- */
149
- debug?: any;
150
- /**
151
- * Generates stack traces on Error to include call site of library entrance ('long stack traces'). Slight
152
- * performance penalty for most calls. (Default: true)
153
- */
154
- trace?: boolean;
155
- /**
156
- * Allow multiple MySQL statements per query. Be careful with this, it exposes you to SQL injection attacks. (Default: false)
157
- */
158
- multipleStatements?: boolean;
159
- /**
160
- * List of connection flags to use other than the default ones. It is also possible to blacklist default ones
161
- */
162
- flags?: Array<string>;
163
- /**
164
- * object with ssl parameters or a string containing name of ssl profile
165
- */
166
- ssl?: string | MysqlSslOptions;
167
- /**
168
- * Return each row as an array, not as an object.
169
- * This is useful when you have duplicate column names.
170
- * This can also be set in the `QueryOption` object to be applied per-query.
171
- */
172
- rowsAsArray?: boolean;
173
- /**
174
- * The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout,
175
- * because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds)
176
- */
177
- acquireTimeout?: number;
178
- /**
179
- * Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue
180
- * the connection request and call it when one becomes available. If false, the pool will immediately call back with an error.
181
- * (Default: true)
182
- */
183
- waitForConnections?: boolean;
184
- /**
185
- * The maximum number of connections to create at once. (Default: 10)
186
- */
187
- connectionLimit?: number;
188
- /**
189
- * The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there
190
- * is no limit to the number of queued connection requests. (Default: 0)
191
- */
192
- queueLimit?: number;
193
- /**
194
- * Enable keep-alive on the socket. It's disabled by default, but the
195
- * user can enable it and supply an initial delay.
196
- */
197
- enableKeepAlive?: true;
198
- /**
199
- * If keep-alive is enabled users can supply an initial delay.
200
- */
201
- keepAliveInitialDelay?: number;
202
- /**
203
- * Called once for each created connection.
204
- *
205
- * This is a Kysely specific feature and does not come from the `mysql2` module.
206
- */
207
- onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
208
- }
209
- export interface MysqlSslOptions {
210
- /**
211
- * A string or buffer holding the PFX or PKCS12 encoded private key, certificate and CA certificates
212
- */
213
- pfx?: string;
214
- /**
215
- * A string holding the PEM encoded private key
216
- */
217
- key?: string;
218
- /**
219
- * A string of passphrase for the private key or pfx
220
- */
221
- passphrase?: string;
222
- /**
223
- * A string holding the PEM encoded certificate
224
- */
225
- cert?: string;
226
- /**
227
- * Either a string or list of strings of PEM encoded CA certificates to trust.
228
- */
229
- ca?: string | string[];
230
- /**
231
- * Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List)
232
- */
233
- crl?: string | string[];
234
- /**
235
- * A string describing the ciphers to use or exclude
236
- */
237
- ciphers?: string;
238
- /**
239
- * You can also connect to a MySQL server without properly providing the appropriate CA to trust. You should not do this.
240
- */
241
- rejectUnauthorized?: boolean;
242
- }
@@ -1,3 +1,4 @@
1
+ /// <reference types="./mysql-dialect.d.ts" />
1
2
  import { MysqlDriver } from './mysql-driver.js';
2
3
  import { MysqlQueryCompiler } from './mysql-query-compiler.js';
3
4
  import { MysqlIntrospector } from './mysql-introspector.js';
@@ -1,6 +1,6 @@
1
1
  import { DatabaseConnection } from '../../driver/database-connection.js';
2
2
  import { Driver, TransactionSettings } from '../../driver/driver.js';
3
- import { MysqlDialectConfig } from './mysql-dialect.js';
3
+ import { MysqlDialectConfig } from './mysql-dialect-config.js';
4
4
  export declare class MysqlDriver implements Driver {
5
5
  #private;
6
6
  constructor(config: MysqlDialectConfig);
@@ -1,6 +1,6 @@
1
+ /// <reference types="./mysql-driver.d.ts" />
1
2
  import { CompiledQuery } from '../../query-compiler/compiled-query.js';
2
- import { importNamedFunction } from '../../util/dynamic-import.js';
3
- import { isObject } from '../../util/object-utils.js';
3
+ import { isFunction, isObject } from '../../util/object-utils.js';
4
4
  const PRIVATE_RELEASE_METHOD = Symbol();
5
5
  export class MysqlDriver {
6
6
  #config;
@@ -79,7 +79,16 @@ export class MysqlDriver {
79
79
  }
80
80
  async function importMysqlPoolFactory() {
81
81
  try {
82
- return await importNamedFunction('mysql2', 'createPool');
82
+ // The imported module name must be a string literal to make
83
+ // some bundlers work. So don't move this code behind a helper
84
+ // for example.
85
+ const mysqlModule = await import('mysql2');
86
+ if (isFunction(mysqlModule.createPool)) {
87
+ return mysqlModule.createPool;
88
+ }
89
+ else {
90
+ return mysqlModule.default.createPool;
91
+ }
83
92
  }
84
93
  catch (error) {
85
94
  throw new Error('MySQL client not installed. Please run `npm install mysql2`');
@@ -1,3 +1,4 @@
1
+ /// <reference types="./mysql-introspector.d.ts" />
1
2
  import { MIGRATION_LOCK_TABLE, MIGRATION_TABLE, } from '../../migration/migrator.js';
2
3
  import { freeze } from '../../util/object-utils.js';
3
4
  export class MysqlIntrospector {
@@ -1,3 +1,4 @@
1
+ /// <reference types="./mysql-query-compiler.d.ts" />
1
2
  import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
2
3
  export class MysqlQueryCompiler extends DefaultQueryCompiler {
3
4
  getCurrentParameterPlaceholder() {
@@ -1,3 +1,4 @@
1
+ /// <reference types="./postgres-adapter.d.ts" />
1
2
  import { DialectAdapterBase } from '../dialect-adapter-base.js';
2
3
  // Random id for our transaction lock.
3
4
  const LOCK_ID = '3853314791062309107';
@@ -0,0 +1,103 @@
1
+ /// <reference types="node" />
2
+ import * as stream from 'stream';
3
+ import { ConnectionOptions } from 'tls';
4
+ import { DatabaseConnection } from '../../driver/database-connection.js';
5
+ /**
6
+ * Config for the PostgreSQL dialect.
7
+ *
8
+ * This interface is equal to `pg` library's `Pool` config:
9
+ *
10
+ * https://node-postgres.com/api/pool
11
+ * https://node-postgres.com/api/client
12
+ */
13
+ export interface PostgresDialectConfig {
14
+ /**
15
+ * defaults process.env.PGUSER || process.env.USER.
16
+ */
17
+ user?: string;
18
+ /**
19
+ * default process.env.PGDATABASE || process.env.USER
20
+ */
21
+ database?: string;
22
+ /**
23
+ * default process.env.PGPASSWORD
24
+ */
25
+ password?: string | (() => string | Promise<string>);
26
+ /**
27
+ * default process.env.PGPORT
28
+ */
29
+ port?: number;
30
+ /**
31
+ * default process.env.PGHOST
32
+ */
33
+ host?: string;
34
+ /**
35
+ * e.g. postgres:*user:password@host:5432/database
36
+ */
37
+ connectionString?: string;
38
+ /**
39
+ * passed directly to node.TLSSocket, supports all tls.connect options
40
+ */
41
+ ssl?: boolean | ConnectionOptions;
42
+ /**
43
+ * Number of milliseconds to wait before timing out when connecting a new client
44
+ * by default this is 0 which means no timeout.
45
+ */
46
+ connectionTimeoutMillis?: number;
47
+ /**
48
+ * Maximum number of clients the pool should contain. by default this is set to 10.
49
+ */
50
+ max?: number;
51
+ /**
52
+ * Minimum number of clients the pool should contain
53
+ */
54
+ min?: number;
55
+ /**
56
+ * Number of milliseconds a client must sit idle in the pool and not be checked out
57
+ * before it is disconnected from the backend and discarded.
58
+ *
59
+ * default is 10000 (10 seconds) - set to 0 to disable auto-disconnection of idle clients.
60
+ */
61
+ idleTimeoutMillis?: number;
62
+ /**
63
+ * Default behavior is the pool will keep clients open & connected to the backend
64
+ * until idleTimeoutMillis expire for each client and node will maintain a ref
65
+ * to the socket on the client, keeping the event loop alive until all clients are closed
66
+ * after being idle or the pool is manually shutdown with `pool.end()`.
67
+ *
68
+ * Setting `allowExitOnIdle: true` in the config will allow the node event loop to exit
69
+ * as soon as all clients in the pool are idle, even if their socket is still open
70
+ * to the PostgreSQL server. This can be handy in scripts & tests
71
+ * where you don't want to wait for your clients to go idle before your process exits.
72
+ */
73
+ allowExitOnIdle?: boolean;
74
+ log?: (...messages: any[]) => void;
75
+ /**
76
+ * Number of milliseconds before a statement in query will time out, default is no timeout.
77
+ */
78
+ statement_timeout?: false | number;
79
+ /**
80
+ * Number of milliseconds before terminating any session with an open idle transaction.
81
+ * Default is no timeout.
82
+ */
83
+ idle_in_transaction_session_timeout?: number;
84
+ /**
85
+ * Number of milliseconds before a query call will timeout, default is no timeout.
86
+ */
87
+ query_timeout?: number;
88
+ /**
89
+ * The name of the application that created this Client instance.
90
+ */
91
+ application_name?: string;
92
+ /**
93
+ * Called once for each created connection.
94
+ *
95
+ * This is a Kysely specific feature and does not come from the `pg` module.
96
+ */
97
+ onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
98
+ keepAlive?: boolean;
99
+ keepAliveInitialDelayMillis?: number;
100
+ types?: any;
101
+ stream?: stream.Duplex;
102
+ parseInputDatesAsUTC?: boolean;
103
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="./postgres-dialect-config.d.ts" />
2
+ export {};
@@ -1,13 +1,10 @@
1
- /// <reference types="node" />
2
- import * as stream from 'stream';
3
- import { ConnectionOptions } from 'tls';
4
1
  import { Driver } from '../../driver/driver.js';
5
2
  import { Kysely } from '../../kysely.js';
6
3
  import { QueryCompiler } from '../../query-compiler/query-compiler.js';
7
4
  import { Dialect } from '../dialect.js';
8
5
  import { DatabaseIntrospector } from '../database-introspector.js';
9
6
  import { DialectAdapter } from '../dialect-adapter.js';
10
- import { DatabaseConnection } from '../../driver/database-connection.js';
7
+ import { PostgresDialectConfig } from './postgres-dialect-config.js';
11
8
  /**
12
9
  * PostgreSQL dialect that uses the [pg](https://node-postgres.com/) library.
13
10
  *
@@ -42,102 +39,3 @@ export declare class PostgresDialect implements Dialect {
42
39
  */
43
40
  createIntrospector(db: Kysely<any>): DatabaseIntrospector;
44
41
  }
45
- /**
46
- * Config for the PostgreSQL dialect.
47
- *
48
- * This interface is equal to `pg` library's `Pool` config:
49
- *
50
- * https://node-postgres.com/api/pool
51
- * https://node-postgres.com/api/client
52
- */
53
- export interface PostgresDialectConfig {
54
- /**
55
- * defaults process.env.PGUSER || process.env.USER.
56
- */
57
- user?: string;
58
- /**
59
- * default process.env.PGDATABASE || process.env.USER
60
- */
61
- database?: string;
62
- /**
63
- * default process.env.PGPASSWORD
64
- */
65
- password?: string | (() => string | Promise<string>);
66
- /**
67
- * default process.env.PGPORT
68
- */
69
- port?: number;
70
- /**
71
- * default process.env.PGHOST
72
- */
73
- host?: string;
74
- /**
75
- * e.g. postgres:*user:password@host:5432/database
76
- */
77
- connectionString?: string;
78
- /**
79
- * passed directly to node.TLSSocket, supports all tls.connect options
80
- */
81
- ssl?: boolean | ConnectionOptions;
82
- /**
83
- * Number of milliseconds to wait before timing out when connecting a new client
84
- * by default this is 0 which means no timeout.
85
- */
86
- connectionTimeoutMillis?: number;
87
- /**
88
- * Maximum number of clients the pool should contain. by default this is set to 10.
89
- */
90
- max?: number;
91
- /**
92
- * Minimum number of clients the pool should contain
93
- */
94
- min?: number;
95
- /**
96
- * Number of milliseconds a client must sit idle in the pool and not be checked out
97
- * before it is disconnected from the backend and discarded.
98
- *
99
- * default is 10000 (10 seconds) - set to 0 to disable auto-disconnection of idle clients.
100
- */
101
- idleTimeoutMillis?: number;
102
- /**
103
- * Default behavior is the pool will keep clients open & connected to the backend
104
- * until idleTimeoutMillis expire for each client and node will maintain a ref
105
- * to the socket on the client, keeping the event loop alive until all clients are closed
106
- * after being idle or the pool is manually shutdown with `pool.end()`.
107
- *
108
- * Setting `allowExitOnIdle: true` in the config will allow the node event loop to exit
109
- * as soon as all clients in the pool are idle, even if their socket is still open
110
- * to the PostgreSQL server. This can be handy in scripts & tests
111
- * where you don't want to wait for your clients to go idle before your process exits.
112
- */
113
- allowExitOnIdle?: boolean;
114
- log?: (...messages: any[]) => void;
115
- /**
116
- * Number of milliseconds before a statement in query will time out, default is no timeout.
117
- */
118
- statement_timeout?: false | number;
119
- /**
120
- * Number of milliseconds before terminating any session with an open idle transaction.
121
- * Default is no timeout.
122
- */
123
- idle_in_transaction_session_timeout?: number;
124
- /**
125
- * Number of milliseconds before a query call will timeout, default is no timeout.
126
- */
127
- query_timeout?: number;
128
- /**
129
- * The name of the application that created this Client instance.
130
- */
131
- application_name?: string;
132
- /**
133
- * Called once for each created connection.
134
- *
135
- * This is a Kysely specific feature and does not come from the `pg` module.
136
- */
137
- onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
138
- keepAlive?: boolean;
139
- keepAliveInitialDelayMillis?: number;
140
- types?: any;
141
- stream?: stream.Duplex;
142
- parseInputDatesAsUTC?: boolean;
143
- }
@@ -1,3 +1,4 @@
1
+ /// <reference types="./postgres-dialect.d.ts" />
1
2
  import { PostgresDriver } from './postgres-driver.js';
2
3
  import { PostgresIntrospector } from './postgres-introspector.js';
3
4
  import { PostgresQueryCompiler } from './postgres-query-compiler.js';
@@ -1,6 +1,6 @@
1
1
  import { DatabaseConnection } from '../../driver/database-connection.js';
2
2
  import { Driver, TransactionSettings } from '../../driver/driver.js';
3
- import { PostgresDialectConfig } from './postgres-dialect.js';
3
+ import { PostgresDialectConfig } from './postgres-dialect-config.js';
4
4
  export declare class PostgresDriver implements Driver {
5
5
  #private;
6
6
  constructor(config: PostgresDialectConfig);
@@ -1,5 +1,6 @@
1
+ /// <reference types="./postgres-driver.d.ts" />
1
2
  import { CompiledQuery } from '../../query-compiler/compiled-query.js';
2
- import { importNamedFunction } from '../../util/dynamic-import.js';
3
+ import { isFunction } from '../../util/object-utils.js';
3
4
  const PRIVATE_RELEASE_METHOD = Symbol();
4
5
  export class PostgresDriver {
5
6
  #config;
@@ -62,7 +63,16 @@ export class PostgresDriver {
62
63
  }
63
64
  async function importPgPool() {
64
65
  try {
65
- return await importNamedFunction('pg', 'Pool');
66
+ // The imported module name must be a string literal to make
67
+ // some bundlers work. So don't move this code behind a helper
68
+ // for example.
69
+ const pgModule = await import('pg');
70
+ if (isFunction(pgModule.Pool)) {
71
+ return pgModule.Pool;
72
+ }
73
+ else {
74
+ return pgModule.default.Pool;
75
+ }
66
76
  }
67
77
  catch (error) {
68
78
  throw new Error('Postgres client not installed. Please run `npm install pg`');
@@ -1,3 +1,4 @@
1
+ /// <reference types="./postgres-introspector.d.ts" />
1
2
  import { MIGRATION_LOCK_TABLE, MIGRATION_TABLE, } from '../../migration/migrator.js';
2
3
  import { freeze } from '../../util/object-utils.js';
3
4
  export class PostgresIntrospector {
@@ -1,3 +1,4 @@
1
+ /// <reference types="./postgres-query-compiler.d.ts" />
1
2
  import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
2
3
  export class PostgresQueryCompiler extends DefaultQueryCompiler {
3
4
  getCurrentParameterPlaceholder() {
@@ -1,3 +1,4 @@
1
+ /// <reference types="./sqlite-adapter.d.ts" />
1
2
  export class SqliteAdapter {
2
3
  get supportsTransactionalDdl() {
3
4
  return false;
@@ -0,0 +1,43 @@
1
+ import { DatabaseConnection } from '../../driver/database-connection.js';
2
+ /**
3
+ * Config for the SQLite dialect.
4
+ *
5
+ * This interface is equal to `better-sqlite3` library's `Databse` class's constructor parameters.
6
+ *
7
+ * https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options
8
+ */
9
+ export interface SqliteDialectConfig {
10
+ /**
11
+ * The database file path.
12
+ *
13
+ * This is passed as the first argument for the [Database](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options)
14
+ * class constructor.
15
+ */
16
+ databasePath: string;
17
+ /**
18
+ * Open the database connection in readonly mode (default: false)
19
+ */
20
+ readonly?: boolean;
21
+ /**
22
+ * If the database does not exist, an Error will be thrown instead of creating a new file.
23
+ * This option is ignored for in-memory, temporary, or readonly database connections
24
+ * (default: false)
25
+ */
26
+ fileMustExist?: boolean;
27
+ /**
28
+ * The number of milliseconds to wait when executing queries on a locked database,
29
+ * before throwing a SQLITE_BUSY error (default: 5000)
30
+ */
31
+ timeout?: number;
32
+ /**
33
+ * Provide a function that gets called with every SQL string executed by the database connection
34
+ * (default: null)
35
+ */
36
+ verbose?: (sql: string) => void;
37
+ /**
38
+ * Called once when the first query is executed.
39
+ *
40
+ * This is a Kysely specific feature and does not come from the `better-sqlite3` module.
41
+ */
42
+ onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
43
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="./sqlite-dialect-config.d.ts" />
2
+ export {};
@@ -4,7 +4,7 @@ import { QueryCompiler } from '../../query-compiler/query-compiler.js';
4
4
  import { Dialect } from '../dialect.js';
5
5
  import { DatabaseIntrospector } from '../database-introspector.js';
6
6
  import { DialectAdapter } from '../dialect-adapter.js';
7
- import { DatabaseConnection } from '../../driver/database-connection.js';
7
+ import { SqliteDialectConfig } from './sqlite-dialect-config.js';
8
8
  /**
9
9
  * SQLite dialect that uses the [better-sqlite3](https://github.com/JoshuaWise/better-sqlite3) library.
10
10
  *
@@ -36,45 +36,3 @@ export declare class SqliteDialect implements Dialect {
36
36
  */
37
37
  createIntrospector(db: Kysely<any>): DatabaseIntrospector;
38
38
  }
39
- /**
40
- * Config for the SQLite dialect.
41
- *
42
- * This interface is equal to `better-sqlite3` library's `Databse` class's constructor parameters.
43
- *
44
- * https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options
45
- */
46
- export interface SqliteDialectConfig {
47
- /**
48
- * The database file path.
49
- *
50
- * This is passed as the first argument for the [Database](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/api.md#new-databasepath-options)
51
- * class constructor.
52
- */
53
- databasePath: string;
54
- /**
55
- * Open the database connection in readonly mode (default: false)
56
- */
57
- readonly?: boolean;
58
- /**
59
- * If the database does not exist, an Error will be thrown instead of creating a new file.
60
- * This option is ignored for in-memory, temporary, or readonly database connections
61
- * (default: false)
62
- */
63
- fileMustExist?: boolean;
64
- /**
65
- * The number of milliseconds to wait when executing queries on a locked database,
66
- * before throwing a SQLITE_BUSY error (default: 5000)
67
- */
68
- timeout?: number;
69
- /**
70
- * Provide a function that gets called with every SQL string executed by the database connection
71
- * (default: null)
72
- */
73
- verbose?: (sql: string) => void;
74
- /**
75
- * Called once when the first query is executed.
76
- *
77
- * This is a Kysely specific feature and does not come from the `better-sqlite3` module.
78
- */
79
- onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
80
- }
@@ -1,3 +1,4 @@
1
+ /// <reference types="./sqlite-dialect.d.ts" />
1
2
  import { SqliteDriver } from './sqlite-driver.js';
2
3
  import { SqliteQueryCompiler } from './sqlite-query-compiler.js';
3
4
  import { SqliteIntrospector } from './sqlite-introspector.js';