kysely 0.15.3 → 0.16.3

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 (239) hide show
  1. package/README.md +1 -9
  2. package/dist/cjs/dialect/database-introspector.d.ts +1 -1
  3. package/dist/cjs/dialect/dialect-adapter-base.d.ts +1 -1
  4. package/dist/cjs/dialect/dialect-adapter.d.ts +1 -1
  5. package/dist/cjs/dialect/dialect.d.ts +2 -2
  6. package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +1 -1
  7. package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +2 -2
  8. package/dist/cjs/dialect/mysql/mysql-introspector.d.ts +1 -1
  9. package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +1 -1
  10. package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +2 -2
  11. package/dist/cjs/dialect/postgres/postgres-introspector.d.ts +1 -1
  12. package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +1 -1
  13. package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +2 -2
  14. package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +1 -1
  15. package/dist/cjs/kysely.js +9 -5
  16. package/dist/cjs/migration/file-migration-provider.d.ts +2 -25
  17. package/dist/cjs/migration/file-migration-provider.js +8 -17
  18. package/dist/cjs/migration/migrator.d.ts +2 -15
  19. package/dist/cjs/migration/migrator.js +2 -15
  20. package/dist/cjs/operation-node/constraint-node.d.ts +4 -4
  21. package/dist/cjs/parser/join-parser.d.ts +4 -4
  22. package/dist/cjs/plugin/camel-case/camel-case-plugin.js +1 -1
  23. package/dist/cjs/query-builder/delete-query-builder.d.ts +3 -3
  24. package/dist/cjs/query-builder/expression-builder.d.ts +42 -0
  25. package/dist/cjs/query-builder/expression-builder.js +48 -0
  26. package/dist/cjs/query-builder/insert-query-builder.d.ts +16 -0
  27. package/dist/cjs/query-builder/insert-query-builder.js +16 -0
  28. package/dist/cjs/query-builder/join-interface.d.ts +3 -3
  29. package/dist/cjs/query-builder/on-conflict-builder.d.ts +5 -3
  30. package/dist/cjs/query-builder/select-query-builder.d.ts +3 -3
  31. package/dist/cjs/query-builder/update-query-builder.d.ts +3 -3
  32. package/dist/cjs/query-creator.d.ts +1 -1
  33. package/dist/cjs/util/object-utils.d.ts +1 -1
  34. package/dist/cjs/util/object-utils.js +8 -8
  35. package/dist/esm/dialect/database-introspector.d.ts +1 -1
  36. package/dist/esm/dialect/database-introspector.js +1 -0
  37. package/dist/esm/dialect/dialect-adapter-base.d.ts +1 -1
  38. package/dist/esm/dialect/dialect-adapter-base.js +1 -0
  39. package/dist/esm/dialect/dialect-adapter.d.ts +1 -1
  40. package/dist/esm/dialect/dialect-adapter.js +1 -0
  41. package/dist/esm/dialect/dialect.d.ts +2 -2
  42. package/dist/esm/dialect/dialect.js +1 -0
  43. package/dist/esm/dialect/mysql/mysql-adapter.d.ts +1 -1
  44. package/dist/esm/dialect/mysql/mysql-adapter.js +1 -0
  45. package/dist/esm/dialect/mysql/mysql-dialect.d.ts +2 -2
  46. package/dist/esm/dialect/mysql/mysql-dialect.js +1 -0
  47. package/dist/esm/dialect/mysql/mysql-driver.js +1 -0
  48. package/dist/esm/dialect/mysql/mysql-introspector.d.ts +1 -1
  49. package/dist/esm/dialect/mysql/mysql-introspector.js +1 -0
  50. package/dist/esm/dialect/mysql/mysql-query-compiler.js +1 -0
  51. package/dist/esm/dialect/postgres/postgres-adapter.d.ts +1 -1
  52. package/dist/esm/dialect/postgres/postgres-adapter.js +1 -0
  53. package/dist/esm/dialect/postgres/postgres-dialect.d.ts +2 -2
  54. package/dist/esm/dialect/postgres/postgres-dialect.js +1 -0
  55. package/dist/esm/dialect/postgres/postgres-driver.js +1 -0
  56. package/dist/esm/dialect/postgres/postgres-introspector.d.ts +1 -1
  57. package/dist/esm/dialect/postgres/postgres-introspector.js +1 -0
  58. package/dist/esm/dialect/postgres/postgres-query-compiler.js +1 -0
  59. package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +1 -1
  60. package/dist/esm/dialect/sqlite/sqlite-adapter.js +1 -0
  61. package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +2 -2
  62. package/dist/esm/dialect/sqlite/sqlite-dialect.js +1 -0
  63. package/dist/esm/dialect/sqlite/sqlite-driver.js +1 -0
  64. package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +1 -1
  65. package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -0
  66. package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +1 -0
  67. package/dist/esm/driver/connection-provider.js +1 -0
  68. package/dist/esm/driver/database-connection.js +1 -0
  69. package/dist/esm/driver/default-connection-provider.js +1 -0
  70. package/dist/esm/driver/driver.js +1 -0
  71. package/dist/esm/driver/runtime-driver.js +1 -0
  72. package/dist/esm/driver/single-connection-provider.js +1 -0
  73. package/dist/esm/dynamic/dynamic-reference-builder.js +1 -0
  74. package/dist/esm/dynamic/dynamic.js +1 -0
  75. package/dist/esm/index-nodeless.js +1 -0
  76. package/dist/esm/index.js +1 -0
  77. package/dist/esm/kysely.js +10 -5
  78. package/dist/esm/migration/file-migration-provider.d.ts +2 -25
  79. package/dist/esm/migration/file-migration-provider.js +9 -17
  80. package/dist/esm/migration/migrator.d.ts +2 -15
  81. package/dist/esm/migration/migrator.js +3 -15
  82. package/dist/esm/operation-node/add-column-node.js +1 -0
  83. package/dist/esm/operation-node/add-constraint-node.js +1 -0
  84. package/dist/esm/operation-node/alias-node.js +1 -0
  85. package/dist/esm/operation-node/alter-column-node.js +1 -0
  86. package/dist/esm/operation-node/alter-table-node.js +1 -0
  87. package/dist/esm/operation-node/and-node.js +1 -0
  88. package/dist/esm/operation-node/check-constraint-node.js +1 -0
  89. package/dist/esm/operation-node/column-definition-node.js +1 -0
  90. package/dist/esm/operation-node/column-node.js +1 -0
  91. package/dist/esm/operation-node/column-update-node.js +1 -0
  92. package/dist/esm/operation-node/common-table-expression-name-node.js +1 -0
  93. package/dist/esm/operation-node/common-table-expression-node.js +1 -0
  94. package/dist/esm/operation-node/constraint-node.d.ts +4 -4
  95. package/dist/esm/operation-node/constraint-node.js +1 -0
  96. package/dist/esm/operation-node/create-index-node.js +1 -0
  97. package/dist/esm/operation-node/create-schema-node.js +1 -0
  98. package/dist/esm/operation-node/create-table-node.js +1 -0
  99. package/dist/esm/operation-node/create-view-node.js +1 -0
  100. package/dist/esm/operation-node/data-type-node.js +1 -0
  101. package/dist/esm/operation-node/default-value-node.js +1 -0
  102. package/dist/esm/operation-node/delete-query-node.js +1 -0
  103. package/dist/esm/operation-node/drop-column-node.js +1 -0
  104. package/dist/esm/operation-node/drop-constraint-node.js +1 -0
  105. package/dist/esm/operation-node/drop-index-node.js +1 -0
  106. package/dist/esm/operation-node/drop-schema-node.js +1 -0
  107. package/dist/esm/operation-node/drop-table-node.js +1 -0
  108. package/dist/esm/operation-node/drop-view-node.js +1 -0
  109. package/dist/esm/operation-node/filter-node.js +1 -0
  110. package/dist/esm/operation-node/foreign-key-constraint-node.js +1 -0
  111. package/dist/esm/operation-node/from-node.js +1 -0
  112. package/dist/esm/operation-node/generated-node.js +1 -0
  113. package/dist/esm/operation-node/group-by-item-node.js +1 -0
  114. package/dist/esm/operation-node/group-by-node.js +1 -0
  115. package/dist/esm/operation-node/having-node.js +1 -0
  116. package/dist/esm/operation-node/identifier-node.js +1 -0
  117. package/dist/esm/operation-node/insert-query-node.js +1 -0
  118. package/dist/esm/operation-node/join-node.js +1 -0
  119. package/dist/esm/operation-node/limit-node.js +1 -0
  120. package/dist/esm/operation-node/list-node.js +1 -0
  121. package/dist/esm/operation-node/modify-column-node.js +1 -0
  122. package/dist/esm/operation-node/offset-node.js +1 -0
  123. package/dist/esm/operation-node/on-conflict-node.js +1 -0
  124. package/dist/esm/operation-node/on-duplicate-key-node.js +1 -0
  125. package/dist/esm/operation-node/on-node.js +1 -0
  126. package/dist/esm/operation-node/operation-node-source.js +1 -0
  127. package/dist/esm/operation-node/operation-node-transformer.js +1 -0
  128. package/dist/esm/operation-node/operation-node-utils.js +1 -0
  129. package/dist/esm/operation-node/operation-node-visitor.js +1 -0
  130. package/dist/esm/operation-node/operation-node.js +1 -0
  131. package/dist/esm/operation-node/operator-node.js +1 -0
  132. package/dist/esm/operation-node/or-node.js +1 -0
  133. package/dist/esm/operation-node/order-by-item-node.js +1 -0
  134. package/dist/esm/operation-node/order-by-node.js +1 -0
  135. package/dist/esm/operation-node/parens-node.js +1 -0
  136. package/dist/esm/operation-node/primary-constraint-node.js +1 -0
  137. package/dist/esm/operation-node/primitive-value-list-node.js +1 -0
  138. package/dist/esm/operation-node/query-node.js +1 -0
  139. package/dist/esm/operation-node/raw-node.js +1 -0
  140. package/dist/esm/operation-node/reference-node.js +1 -0
  141. package/dist/esm/operation-node/references-node.js +1 -0
  142. package/dist/esm/operation-node/rename-column-node.js +1 -0
  143. package/dist/esm/operation-node/returning-node.js +1 -0
  144. package/dist/esm/operation-node/select-all-node.js +1 -0
  145. package/dist/esm/operation-node/select-query-node.js +1 -0
  146. package/dist/esm/operation-node/selection-node.js +1 -0
  147. package/dist/esm/operation-node/table-node.js +1 -0
  148. package/dist/esm/operation-node/union-node.js +1 -0
  149. package/dist/esm/operation-node/unique-constraint-node.js +1 -0
  150. package/dist/esm/operation-node/update-query-node.js +1 -0
  151. package/dist/esm/operation-node/value-list-node.js +1 -0
  152. package/dist/esm/operation-node/value-node.js +1 -0
  153. package/dist/esm/operation-node/values-node.js +1 -0
  154. package/dist/esm/operation-node/where-node.js +1 -0
  155. package/dist/esm/operation-node/with-node.js +1 -0
  156. package/dist/esm/parser/complex-expression-parser.js +1 -0
  157. package/dist/esm/parser/data-type-parser.js +1 -0
  158. package/dist/esm/parser/default-value-parser.js +1 -0
  159. package/dist/esm/parser/filter-parser.js +1 -0
  160. package/dist/esm/parser/group-by-parser.js +1 -0
  161. package/dist/esm/parser/insert-values-parser.js +1 -0
  162. package/dist/esm/parser/join-parser.d.ts +4 -4
  163. package/dist/esm/parser/join-parser.js +1 -0
  164. package/dist/esm/parser/order-by-parser.js +1 -0
  165. package/dist/esm/parser/parse-context.js +1 -0
  166. package/dist/esm/parser/reference-parser.js +1 -0
  167. package/dist/esm/parser/returning-parser.js +1 -0
  168. package/dist/esm/parser/select-parser.js +1 -0
  169. package/dist/esm/parser/table-parser.js +1 -0
  170. package/dist/esm/parser/union-parser.js +1 -0
  171. package/dist/esm/parser/update-set-parser.js +1 -0
  172. package/dist/esm/parser/value-parser.js +1 -0
  173. package/dist/esm/parser/with-parser.js +1 -0
  174. package/dist/esm/plugin/camel-case/camel-case-plugin.js +3 -2
  175. package/dist/esm/plugin/camel-case/camel-case-transformer.js +1 -0
  176. package/dist/esm/plugin/camel-case/camel-case.js +1 -0
  177. package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +1 -0
  178. package/dist/esm/plugin/immediate-value.ts/immediate-value-transformer.js +1 -0
  179. package/dist/esm/plugin/kysely-plugin.js +1 -0
  180. package/dist/esm/plugin/with-schema/with-schema-plugin.js +1 -0
  181. package/dist/esm/plugin/with-schema/with-schema-transformer.js +1 -0
  182. package/dist/esm/query-builder/delete-query-builder.d.ts +3 -3
  183. package/dist/esm/query-builder/delete-query-builder.js +1 -0
  184. package/dist/esm/query-builder/delete-result.js +1 -0
  185. package/dist/esm/query-builder/expression-builder.d.ts +42 -0
  186. package/dist/esm/query-builder/expression-builder.js +49 -0
  187. package/dist/esm/query-builder/function-builder.js +1 -0
  188. package/dist/esm/query-builder/having-interface.js +1 -0
  189. package/dist/esm/query-builder/insert-query-builder.d.ts +16 -0
  190. package/dist/esm/query-builder/insert-query-builder.js +17 -0
  191. package/dist/esm/query-builder/insert-result.js +1 -0
  192. package/dist/esm/query-builder/join-builder.js +1 -0
  193. package/dist/esm/query-builder/join-interface.d.ts +3 -3
  194. package/dist/esm/query-builder/join-interface.js +1 -0
  195. package/dist/esm/query-builder/no-result-error.js +1 -0
  196. package/dist/esm/query-builder/on-conflict-builder.d.ts +5 -3
  197. package/dist/esm/query-builder/on-conflict-builder.js +1 -0
  198. package/dist/esm/query-builder/returning-interface.js +1 -0
  199. package/dist/esm/query-builder/select-query-builder.d.ts +3 -3
  200. package/dist/esm/query-builder/select-query-builder.js +1 -0
  201. package/dist/esm/query-builder/update-query-builder.d.ts +3 -3
  202. package/dist/esm/query-builder/update-query-builder.js +1 -0
  203. package/dist/esm/query-builder/update-result.js +1 -0
  204. package/dist/esm/query-builder/where-interface.js +1 -0
  205. package/dist/esm/query-compiler/compiled-query.js +1 -0
  206. package/dist/esm/query-compiler/default-query-compiler.js +1 -0
  207. package/dist/esm/query-compiler/query-compiler.js +1 -0
  208. package/dist/esm/query-creator.d.ts +1 -1
  209. package/dist/esm/query-creator.js +1 -0
  210. package/dist/esm/query-executor/default-query-executor.js +1 -0
  211. package/dist/esm/query-executor/noop-query-executor.js +1 -0
  212. package/dist/esm/query-executor/query-executor.js +1 -0
  213. package/dist/esm/raw-builder/raw-builder.js +1 -0
  214. package/dist/esm/schema/alter-table-builder.js +1 -0
  215. package/dist/esm/schema/column-definition-builder.js +1 -0
  216. package/dist/esm/schema/create-index-builder.js +1 -0
  217. package/dist/esm/schema/create-schema-builder.js +1 -0
  218. package/dist/esm/schema/create-table-builder.js +1 -0
  219. package/dist/esm/schema/create-view-builder.js +1 -0
  220. package/dist/esm/schema/drop-index-builder.js +1 -0
  221. package/dist/esm/schema/drop-schema-builder.js +1 -0
  222. package/dist/esm/schema/drop-table-builder.js +1 -0
  223. package/dist/esm/schema/drop-view-builder.js +1 -0
  224. package/dist/esm/schema/foreign-key-constraint-builder.js +1 -0
  225. package/dist/esm/schema/schema.js +1 -0
  226. package/dist/esm/util/assert.js +1 -0
  227. package/dist/esm/util/column-type.js +1 -0
  228. package/dist/esm/util/compilable.js +1 -0
  229. package/dist/esm/util/dynamic-import.js +1 -0
  230. package/dist/esm/util/log.js +1 -0
  231. package/dist/esm/util/object-utils.d.ts +1 -1
  232. package/dist/esm/util/object-utils.js +7 -6
  233. package/dist/esm/util/performance-now.js +1 -0
  234. package/dist/esm/util/prevent-await.js +1 -0
  235. package/dist/esm/util/private-symbols.js +1 -0
  236. package/dist/esm/util/query-id.js +1 -0
  237. package/dist/esm/util/random-string.js +1 -0
  238. package/dist/esm/util/type-utils.js +1 -0
  239. package/package.json +3 -2
@@ -811,13 +811,13 @@ export declare class SelectQueryBuilder<DB, TB extends keyof DB, O> implements W
811
811
  * and "pet"."name" = $1
812
812
  * ```
813
813
  *
814
- * You can join a subquery by providing a function as the first
815
- * argument:
814
+ * You can join a subquery by providing a select query (or a callback)
815
+ * as the first argument:
816
816
  *
817
817
  * ```ts
818
818
  * await db.selectFrom('person')
819
819
  * .innerJoin(
820
- * (qb) => qb.selectFrom('pet')
820
+ * qb.selectFrom('pet')
821
821
  * .select(['owner_id', 'name'])
822
822
  * .where('name', '=', 'Doggo')
823
823
  * .as('doggos'),
@@ -474,13 +474,13 @@ export declare class UpdateQueryBuilder<DB, TB extends keyof DB, O> implements W
474
474
  * and "pet"."name" = $1
475
475
  * ```
476
476
  *
477
- * You can join a subquery by providing a function as the first
478
- * argument:
477
+ * You can join a subquery by providing a select query (or a callback)
478
+ * as the first argument:
479
479
  *
480
480
  * ```ts
481
481
  * await db.selectFrom('person')
482
482
  * .innerJoin(
483
- * (qb) => qb.selectFrom('pet')
483
+ * qb.selectFrom('pet')
484
484
  * .select(['owner_id', 'name'])
485
485
  * .where('name', '=', 'Doggo')
486
486
  * .as('doggos'),
@@ -412,7 +412,7 @@ export declare class QueryCreator<DB> {
412
412
  * @param params - The parameters that will be bound to the `?` and `??` placeholders in
413
413
  * the sql string.
414
414
  */
415
- raw<T = unknown>(sql: string, parameters?: any[]): RawBuilder<T>;
415
+ raw<T = unknown>(sql: string, parameters?: unknown[]): RawBuilder<T>;
416
416
  }
417
417
  export interface QueryCreatorProps {
418
418
  readonly executor: QueryExecutor;
@@ -6,8 +6,8 @@ export declare function isNumber(obj: unknown): obj is number;
6
6
  export declare function isBoolean(obj: unknown): obj is boolean;
7
7
  export declare function isNull(obj: unknown): obj is null;
8
8
  export declare function isDate(obj: unknown): obj is Date;
9
- export declare function isBuffer(obj: unknown): obj is Buffer;
10
9
  export declare function isBigInt(obj: unknown): obj is BigInt;
10
+ export declare function isBuffer(obj: unknown): obj is Buffer;
11
11
  export declare function isPrimitive(obj: unknown): obj is PrimitiveValue;
12
12
  export declare function isFunction(obj: unknown): obj is Function;
13
13
  export declare function isObject(obj: unknown): obj is Record<string, unknown>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noop = exports.isReadonlyArray = exports.asReadonlyArray = exports.asArray = exports.freeze = exports.getLast = exports.isObject = exports.isFunction = exports.isPrimitive = exports.isBigInt = exports.isBuffer = exports.isDate = exports.isNull = exports.isBoolean = exports.isNumber = exports.isString = exports.isEmpty = void 0;
3
+ exports.noop = exports.isReadonlyArray = exports.asReadonlyArray = exports.asArray = exports.freeze = exports.getLast = exports.isObject = exports.isFunction = exports.isPrimitive = exports.isBuffer = exports.isBigInt = exports.isDate = exports.isNull = exports.isBoolean = exports.isNumber = exports.isString = exports.isEmpty = void 0;
4
4
  function isEmpty(obj) {
5
- if (Array.isArray(obj) || isString(obj) || Buffer.isBuffer(obj)) {
5
+ if (Array.isArray(obj) || isString(obj) || isBuffer(obj)) {
6
6
  return obj.length === 0;
7
7
  }
8
8
  else if (obj) {
@@ -31,22 +31,22 @@ function isDate(obj) {
31
31
  return obj instanceof Date;
32
32
  }
33
33
  exports.isDate = isDate;
34
- function isBuffer(obj) {
35
- return Buffer.isBuffer(obj);
36
- }
37
- exports.isBuffer = isBuffer;
38
34
  function isBigInt(obj) {
39
35
  return typeof obj === 'bigint';
40
36
  }
41
37
  exports.isBigInt = isBigInt;
38
+ function isBuffer(obj) {
39
+ return typeof Buffer !== 'undefined' && Buffer.isBuffer(obj);
40
+ }
41
+ exports.isBuffer = isBuffer;
42
42
  function isPrimitive(obj) {
43
43
  return (isString(obj) ||
44
44
  isNumber(obj) ||
45
45
  isBoolean(obj) ||
46
46
  isNull(obj) ||
47
47
  isDate(obj) ||
48
- isBuffer(obj) ||
49
- isBigInt(obj));
48
+ isBigInt(obj) ||
49
+ isBuffer(obj));
50
50
  }
51
51
  exports.isPrimitive = isPrimitive;
52
52
  function isFunction(obj) {
@@ -4,7 +4,7 @@ import { ColumnDataType } from '../operation-node/data-type-node.js';
4
4
  */
5
5
  export interface DatabaseIntrospector {
6
6
  /**
7
- * Get the database metadata such as the names of the tables and columns.
7
+ * Get the database metadata such as table and column names.
8
8
  */
9
9
  getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
10
10
  }
@@ -1 +1,2 @@
1
+ /// <reference types="./database-introspector.d.ts" />
1
2
  export {};
@@ -20,7 +20,7 @@ export declare abstract class DialectAdapterBase implements DialectAdapter {
20
20
  get supportsReturning(): boolean;
21
21
  /**
22
22
  * This method is used to acquire a lock for the migrations so that
23
- * it's not possible for two migration processes to run in parallel.
23
+ * it's not possible for two migration operations to run in parallel.
24
24
  *
25
25
  * Most dialects have explicit locks that can be used, like advisory locks
26
26
  * in PostgreSQL and the get_lock function in MySQL.
@@ -1,3 +1,4 @@
1
+ /// <reference types="./dialect-adapter-base.d.ts" />
1
2
  /**
2
3
  * A basic implementation of `DialectAdapter` with sensible default values.
3
4
  * 3rd party dialects can extend this instead of implementing the `DialectAdapter`
@@ -21,7 +21,7 @@ export interface DialectAdapter {
21
21
  readonly supportsReturning: boolean;
22
22
  /**
23
23
  * This method is used to acquire a lock for the migrations so that
24
- * it's not possible for two migration processes to run in parallel.
24
+ * it's not possible for two migration operations to run in parallel.
25
25
  *
26
26
  * Most dialects have explicit locks that can be used, like advisory locks
27
27
  * in PostgreSQL and the get_lock function in MySQL.
@@ -1 +1,2 @@
1
+ /// <reference types="./dialect-adapter.d.ts" />
1
2
  export {};
@@ -24,8 +24,8 @@ export interface Dialect {
24
24
  */
25
25
  createAdapter(): DialectAdapter;
26
26
  /**
27
- * Creates a database introspector that can be used to get the database metadata
28
- * such as the tables and columns that exist in the database.
27
+ * Creates a database introspector that can be used to get database metadata
28
+ * such as the table names and column names of those tables.
29
29
  *
30
30
  * `db` never has any plugins installed. It's created using
31
31
  * {@link Kysely.withoutPlugins}.
@@ -1 +1,2 @@
1
+ /// <reference types="./dialect.d.ts" />
1
2
  export {};
@@ -14,7 +14,7 @@ export declare class MysqlAdapter extends DialectAdapterBase {
14
14
  get supportsReturning(): boolean;
15
15
  /**
16
16
  * This method is used to acquire a lock for the migrations so that
17
- * it's not possible for two migration processes to run in parallel.
17
+ * it's not possible for two migration operations to run in parallel.
18
18
  *
19
19
  * Most dialects have explicit locks that can be used, like advisory locks
20
20
  * in PostgreSQL and the get_lock function in MySQL.
@@ -1,3 +1,4 @@
1
+ /// <reference types="./mysql-adapter.d.ts" />
1
2
  import { DialectAdapterBase } from '../dialect-adapter-base.js';
2
3
  const LOCK_ID = 'ea586330-2c93-47c8-908d-981d9d270f9d';
3
4
  const LOCK_TIMEOUT_SECONDS = 60 * 60;
@@ -28,8 +28,8 @@ export declare class MysqlDialect implements Dialect {
28
28
  */
29
29
  createAdapter(): DialectAdapter;
30
30
  /**
31
- * Creates a database introspector that can be used to get the database metadata
32
- * such as the tables and columns that exist in the database.
31
+ * Creates a database introspector that can be used to get database metadata
32
+ * such as the table names and column names of those tables.
33
33
  *
34
34
  * `db` never has any plugins installed. It's created using
35
35
  * {@link Kysely.withoutPlugins}.
@@ -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,3 +1,4 @@
1
+ /// <reference types="./mysql-driver.d.ts" />
1
2
  import { CompiledQuery } from '../../query-compiler/compiled-query.js';
2
3
  import { importNamedFunction } from '../../util/dynamic-import.js';
3
4
  import { isObject } from '../../util/object-utils.js';
@@ -4,7 +4,7 @@ export declare class MysqlIntrospector implements DatabaseIntrospector {
4
4
  #private;
5
5
  constructor(db: Kysely<any>);
6
6
  /**
7
- * Get the database metadata such as the names of the tables and columns.
7
+ * Get the database metadata such as table and column names.
8
8
  */
9
9
  getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
10
10
  }
@@ -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() {
@@ -14,7 +14,7 @@ export declare class PostgresAdapter extends DialectAdapterBase {
14
14
  get supportsReturning(): boolean;
15
15
  /**
16
16
  * This method is used to acquire a lock for the migrations so that
17
- * it's not possible for two migration processes to run in parallel.
17
+ * it's not possible for two migration operations to run in parallel.
18
18
  *
19
19
  * Most dialects have explicit locks that can be used, like advisory locks
20
20
  * in PostgreSQL and the get_lock function in MySQL.
@@ -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';
@@ -34,8 +34,8 @@ export declare class PostgresDialect implements Dialect {
34
34
  */
35
35
  createAdapter(): DialectAdapter;
36
36
  /**
37
- * Creates a database introspector that can be used to get the database metadata
38
- * such as the tables and columns that exist in the database.
37
+ * Creates a database introspector that can be used to get database metadata
38
+ * such as the table names and column names of those tables.
39
39
  *
40
40
  * `db` never has any plugins installed. It's created using
41
41
  * {@link Kysely.withoutPlugins}.
@@ -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,3 +1,4 @@
1
+ /// <reference types="./postgres-driver.d.ts" />
1
2
  import { CompiledQuery } from '../../query-compiler/compiled-query.js';
2
3
  import { importNamedFunction } from '../../util/dynamic-import.js';
3
4
  const PRIVATE_RELEASE_METHOD = Symbol();
@@ -4,7 +4,7 @@ export declare class PostgresIntrospector implements DatabaseIntrospector {
4
4
  #private;
5
5
  constructor(db: Kysely<any>);
6
6
  /**
7
- * Get the database metadata such as the names of the tables and columns.
7
+ * Get the database metadata such as table and column names.
8
8
  */
9
9
  getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
10
10
  }
@@ -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() {
@@ -13,7 +13,7 @@ export declare class SqliteAdapter implements DialectAdapterBase {
13
13
  get supportsReturning(): boolean;
14
14
  /**
15
15
  * This method is used to acquire a lock for the migrations so that
16
- * it's not possible for two migration processes to run in parallel.
16
+ * it's not possible for two migration operations to run in parallel.
17
17
  *
18
18
  * Most dialects have explicit locks that can be used, like advisory locks
19
19
  * in PostgreSQL and the get_lock function in MySQL.
@@ -1,3 +1,4 @@
1
+ /// <reference types="./sqlite-adapter.d.ts" />
1
2
  export class SqliteAdapter {
2
3
  get supportsTransactionalDdl() {
3
4
  return false;
@@ -28,8 +28,8 @@ export declare class SqliteDialect implements Dialect {
28
28
  */
29
29
  createAdapter(): DialectAdapter;
30
30
  /**
31
- * Creates a database introspector that can be used to get the database metadata
32
- * such as the tables and columns that exist in the database.
31
+ * Creates a database introspector that can be used to get database metadata
32
+ * such as the table names and column names of those tables.
33
33
  *
34
34
  * `db` never has any plugins installed. It's created using
35
35
  * {@link Kysely.withoutPlugins}.
@@ -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';
@@ -1,3 +1,4 @@
1
+ /// <reference types="./sqlite-driver.d.ts" />
1
2
  import { CompiledQuery } from '../../query-compiler/compiled-query.js';
2
3
  import { importFunction } from '../../util/dynamic-import.js';
3
4
  import { isBoolean, isFunction, isNumber } from '../../util/object-utils.js';
@@ -4,7 +4,7 @@ export declare class SqliteIntrospector implements DatabaseIntrospector {
4
4
  #private;
5
5
  constructor(db: Kysely<any>);
6
6
  /**
7
- * Get the database metadata such as the names of the tables and columns.
7
+ * Get the database metadata such as table and column names.
8
8
  */
9
9
  getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
10
10
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="./sqlite-introspector.d.ts" />
1
2
  import { MIGRATION_LOCK_TABLE, MIGRATION_TABLE, } from '../../migration/migrator.js';
2
3
  export class SqliteIntrospector {
3
4
  #db;
@@ -1,3 +1,4 @@
1
+ /// <reference types="./sqlite-query-compiler.d.ts" />
1
2
  import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js';
2
3
  export class SqliteQueryCompiler extends DefaultQueryCompiler {
3
4
  getCurrentParameterPlaceholder() {
@@ -1 +1,2 @@
1
+ /// <reference types="./connection-provider.d.ts" />
1
2
  export {};
@@ -1 +1,2 @@
1
+ /// <reference types="./database-connection.d.ts" />
1
2
  export {};
@@ -1,3 +1,4 @@
1
+ /// <reference types="./default-connection-provider.d.ts" />
1
2
  export class DefaultConnectionProvider {
2
3
  #driver;
3
4
  constructor(driver) {
@@ -1,3 +1,4 @@
1
+ /// <reference types="./driver.d.ts" />
1
2
  export const TRANSACTION_ISOLATION_LEVELS = [
2
3
  'read uncommitted',
3
4
  'read committed',
@@ -1,3 +1,4 @@
1
+ /// <reference types="./runtime-driver.d.ts" />
1
2
  import { performanceNow } from '../util/performance-now.js';
2
3
  /**
3
4
  * A small wrapper around {@link Driver} that makes sure the driver is
@@ -1,3 +1,4 @@
1
+ /// <reference types="./single-connection-provider.d.ts" />
1
2
  export class SingleConnectionProvider {
2
3
  #connection;
3
4
  #runningPromise;
@@ -1,3 +1,4 @@
1
+ /// <reference types="./dynamic-reference-builder.d.ts" />
1
2
  import { isOperationNodeSource, } from '../operation-node/operation-node-source.js';
2
3
  import { parseStringReference } from '../parser/reference-parser.js';
3
4
  import { isObject, isString } from '../util/object-utils.js';
@@ -1,3 +1,4 @@
1
+ /// <reference types="./dynamic.d.ts" />
1
2
  import { DynamicReferenceBuilder } from './dynamic-reference-builder.js';
2
3
  export class DynamicModule {
3
4
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="./index-nodeless.d.ts" />
1
2
  export * from './kysely.js';
2
3
  export * from './query-creator.js';
3
4
  export * from './query-builder/where-interface.js';
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="./index.d.ts" />
1
2
  export * from './index-nodeless.js';
2
3
  export * from './migration/file-migration-provider.js';
3
4
  export * from './dialect/sqlite/sqlite-dialect.js';
@@ -1,3 +1,4 @@
1
+ /// <reference types="./kysely.d.ts" />
1
2
  import { SchemaModule } from './schema/schema.js';
2
3
  import { DynamicModule } from './dynamic/dynamic.js';
3
4
  import { DefaultConnectionProvider } from './driver/default-connection-provider.js';
@@ -56,9 +57,11 @@ import { PRIVATE_ADAPTER } from './util/private-symbols.js';
56
57
  export class Kysely extends QueryCreator {
57
58
  #props;
58
59
  constructor(args) {
60
+ let superProps;
61
+ let props;
59
62
  if (isKyselyProps(args)) {
60
- super({ executor: args.executor, parseContext: args.parseContext });
61
- this.#props = freeze({ ...args });
63
+ superProps = { executor: args.executor, parseContext: args.parseContext };
64
+ props = { ...args };
62
65
  }
63
66
  else {
64
67
  const dialect = args.dialect;
@@ -70,15 +73,17 @@ export class Kysely extends QueryCreator {
70
73
  const runtimeDriver = new RuntimeDriver(driver, log);
71
74
  const connectionProvider = new DefaultConnectionProvider(runtimeDriver);
72
75
  const executor = new DefaultQueryExecutor(compiler, connectionProvider, args.plugins ?? []);
73
- super({ executor, parseContext });
74
- this.#props = freeze({
76
+ superProps = { executor, parseContext };
77
+ props = {
75
78
  config: args,
76
79
  executor,
77
80
  dialect,
78
81
  driver: runtimeDriver,
79
82
  parseContext,
80
- });
83
+ };
81
84
  }
85
+ super(superProps);
86
+ this.#props = freeze(props);
82
87
  }
83
88
  /**
84
89
  * Returns the {@link SchemaModule} module for building database schema.
@@ -1,41 +1,18 @@
1
1
  import { Migration, MigrationProvider } from './migrator.js';
2
- /**
3
- * A function that takes a folder path and returns names of the
4
- * files insider that folder.
5
- */
6
- export declare type ReadDir = (migrationFolderPath: string) => Promise<string[]>;
7
- /**
8
- * A function that combines two file path parts into a single file path.
9
- *
10
- * ```ts
11
- * joinPath('/some/path', 'file.ts')
12
- * // ==> '/some/path/file.ts'
13
- * ```
14
- */
15
- export declare type JoinPath = (part1: string, part2: string) => string;
16
2
  /**
17
3
  * Reads all migrations from a folder.
18
4
  *
19
- * You need to provide a function for reading files in a folder and a function for
20
- * joining file paths together. The API is like this to make Kysely independent of
21
- * node.js or any other environment. See the example usage on node.js below.
22
- *
23
5
  * ### Examples
24
6
  *
25
7
  * ```ts
26
- * import * as path from 'path'
27
- * import * as fs from 'fs/promises'
28
- *
29
8
  * new FileMigrationProvider(
30
- * fs.readdir,
31
- * path.join,
32
- * path.join(__dirname, 'migrations')
9
+ * 'path/to/migrations/folder'
33
10
  * )
34
11
  * ```
35
12
  */
36
13
  export declare class FileMigrationProvider implements MigrationProvider {
37
14
  #private;
38
- constructor(readDir: ReadDir, joinPath: JoinPath, migrationFolderPath: string);
15
+ constructor(migrationFolderPath: string);
39
16
  /**
40
17
  * Returns all migrations, old and new.
41
18
  *
@@ -1,40 +1,32 @@
1
+ /// <reference types="./file-migration-provider.d.ts" />
1
2
  import { isFunction, isObject } from '../util/object-utils.js';
2
3
  /**
3
4
  * Reads all migrations from a folder.
4
5
  *
5
- * You need to provide a function for reading files in a folder and a function for
6
- * joining file paths together. The API is like this to make Kysely independent of
7
- * node.js or any other environment. See the example usage on node.js below.
8
- *
9
6
  * ### Examples
10
7
  *
11
8
  * ```ts
12
- * import * as path from 'path'
13
- * import * as fs from 'fs/promises'
14
- *
15
9
  * new FileMigrationProvider(
16
- * fs.readdir,
17
- * path.join,
18
- * path.join(__dirname, 'migrations')
10
+ * 'path/to/migrations/folder'
19
11
  * )
20
12
  * ```
21
13
  */
22
14
  export class FileMigrationProvider {
23
- #readDir;
24
- #joinPath;
25
15
  #migrationFolderPath;
26
- constructor(readDir, joinPath, migrationFolderPath) {
27
- this.#readDir = readDir;
28
- this.#joinPath = joinPath;
16
+ constructor(migrationFolderPath) {
29
17
  this.#migrationFolderPath = migrationFolderPath;
30
18
  }
31
19
  async getMigrations() {
20
+ // Import these dynamically so that we don't have any top level
21
+ // node dependencies.
22
+ const fs = await import('fs/promises');
23
+ const path = await import('path');
32
24
  const migrations = {};
33
- const files = await this.#readDir(this.#migrationFolderPath);
25
+ const files = await fs.readdir(this.#migrationFolderPath);
34
26
  for (const fileName of files) {
35
27
  if ((fileName.endsWith('.js') || fileName.endsWith('.ts')) &&
36
28
  !fileName.endsWith('.d.ts')) {
37
- const migration = await import(this.#joinPath(this.#migrationFolderPath, fileName));
29
+ const migration = await import(path.join(this.#migrationFolderPath, fileName));
38
30
  if (isMigration(migration)) {
39
31
  migrations[fileName.substring(0, fileName.length - 3)] = migration;
40
32
  }
@@ -26,14 +26,9 @@ export interface Migration {
26
26
  * ```ts
27
27
  * const migrator = new Migrator({
28
28
  * db,
29
- * // The constructor signature of FileMigrationProvider is a
30
- * // bit weird to keep Kysely independent of node.js or any
31
- * // other environment.
32
29
  * provider: new FileMigrationProvider(
33
- * fs.readdir,
34
- * path.join,
35
30
  * // Path to the folder that contains all your migrations.
36
- * 'migrations'
31
+ * 'some/path/to/migrations'
37
32
  * )
38
33
  * })
39
34
  * ```
@@ -57,9 +52,6 @@ export declare class Migrator {
57
52
  * ### Examples
58
53
  *
59
54
  * ```ts
60
- * import * as path from 'path'
61
- * import * as fs from 'fs/promises'
62
- *
63
55
  * const db = new Kysely<Database>({
64
56
  * dialect: new PostgresDialect({
65
57
  * host: 'localhost',
@@ -69,14 +61,9 @@ export declare class Migrator {
69
61
  *
70
62
  * const migrator = new Migrator({
71
63
  * db,
72
- * // The constructor signature of FileMigrationProvider is a
73
- * // bit weird to keep Kysely independent of node.js or any
74
- * // other environment.
75
64
  * provider: new FileMigrationProvider(
76
- * fs.readdir,
77
- * path.join,
78
65
  * // Path to the folder that contains all your migrations.
79
- * 'migrations'
66
+ * 'some/path/to/migrations'
80
67
  * )
81
68
  * })
82
69
  *