kysely 0.15.0 → 0.16.0

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 (60) hide show
  1. package/README.md +12 -24
  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/index-nodeless.d.ts +148 -0
  16. package/dist/cjs/index-nodeless.js +149 -0
  17. package/dist/cjs/index.d.ts +6 -153
  18. package/dist/cjs/index.js +6 -142
  19. package/dist/cjs/kysely.js +9 -5
  20. package/dist/cjs/migration/file-migration-provider.d.ts +2 -25
  21. package/dist/cjs/migration/file-migration-provider.js +8 -17
  22. package/dist/cjs/migration/migrator.d.ts +2 -15
  23. package/dist/cjs/migration/migrator.js +2 -15
  24. package/dist/cjs/parser/join-parser.d.ts +4 -4
  25. package/dist/cjs/query-builder/delete-query-builder.d.ts +5 -4
  26. package/dist/cjs/query-builder/insert-query-builder.d.ts +2 -1
  27. package/dist/cjs/query-builder/join-interface.d.ts +3 -3
  28. package/dist/cjs/query-builder/returning-interface.d.ts +2 -1
  29. package/dist/cjs/query-builder/select-query-builder.d.ts +4 -4
  30. package/dist/cjs/query-builder/update-query-builder.d.ts +5 -4
  31. package/dist/esm/dialect/database-introspector.d.ts +1 -1
  32. package/dist/esm/dialect/dialect-adapter-base.d.ts +1 -1
  33. package/dist/esm/dialect/dialect-adapter.d.ts +1 -1
  34. package/dist/esm/dialect/dialect.d.ts +2 -2
  35. package/dist/esm/dialect/mysql/mysql-adapter.d.ts +1 -1
  36. package/dist/esm/dialect/mysql/mysql-dialect.d.ts +2 -2
  37. package/dist/esm/dialect/mysql/mysql-introspector.d.ts +1 -1
  38. package/dist/esm/dialect/postgres/postgres-adapter.d.ts +1 -1
  39. package/dist/esm/dialect/postgres/postgres-dialect.d.ts +2 -2
  40. package/dist/esm/dialect/postgres/postgres-introspector.d.ts +1 -1
  41. package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +1 -1
  42. package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +2 -2
  43. package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +1 -1
  44. package/dist/esm/index-nodeless.d.ts +148 -0
  45. package/dist/esm/index-nodeless.js +137 -0
  46. package/dist/esm/index.d.ts +6 -153
  47. package/dist/esm/index.js +6 -142
  48. package/dist/esm/kysely.js +9 -5
  49. package/dist/esm/migration/file-migration-provider.d.ts +2 -25
  50. package/dist/esm/migration/file-migration-provider.js +8 -17
  51. package/dist/esm/migration/migrator.d.ts +2 -15
  52. package/dist/esm/migration/migrator.js +2 -15
  53. package/dist/esm/parser/join-parser.d.ts +4 -4
  54. package/dist/esm/query-builder/delete-query-builder.d.ts +5 -4
  55. package/dist/esm/query-builder/insert-query-builder.d.ts +2 -1
  56. package/dist/esm/query-builder/join-interface.d.ts +3 -3
  57. package/dist/esm/query-builder/returning-interface.d.ts +2 -1
  58. package/dist/esm/query-builder/select-query-builder.d.ts +4 -4
  59. package/dist/esm/query-builder/update-query-builder.d.ts +5 -4
  60. package/package.json +4 -2
@@ -1,155 +1,8 @@
1
- export * from './kysely.js';
2
- export * from './query-creator.js';
3
- export * from './query-builder/where-interface.js';
4
- export * from './query-builder/join-interface.js';
5
- export * from './query-builder/returning-interface.js';
6
- export * from './query-builder/having-interface.js';
7
- export * from './query-builder/select-query-builder.js';
8
- export * from './query-builder/insert-query-builder.js';
9
- export * from './query-builder/update-query-builder.js';
10
- export * from './query-builder/delete-query-builder.js';
11
- export * from './query-builder/no-result-error.js';
12
- export * from './query-builder/join-builder.js';
13
- export * from './query-builder/expression-builder.js';
14
- export * from './query-builder/function-builder.js';
15
- export * from './query-builder/insert-result.js';
16
- export * from './query-builder/delete-result.js';
17
- export * from './query-builder/update-result.js';
18
- export * from './query-builder/on-conflict-builder.js';
19
- export * from './raw-builder/raw-builder.js';
20
- export * from './query-executor/query-executor.js';
21
- export * from './query-executor/default-query-executor.js';
22
- export * from './query-executor/noop-query-executor.js';
23
- export * from './query-compiler/default-query-compiler.js';
24
- export * from './query-compiler/compiled-query.js';
25
- export * from './schema/schema.js';
26
- export * from './schema/create-table-builder.js';
27
- export * from './schema/drop-table-builder.js';
28
- export * from './schema/create-index-builder.js';
29
- export * from './schema/drop-index-builder.js';
30
- export * from './schema/create-schema-builder.js';
31
- export * from './schema/drop-schema-builder.js';
32
- export * from './schema/column-definition-builder.js';
33
- export * from './schema/foreign-key-constraint-builder.js';
34
- export * from './schema/alter-table-builder.js';
35
- export * from './schema/create-view-builder.js';
36
- export * from './schema/drop-view-builder.js';
37
- export * from './dynamic/dynamic.js';
38
- export * from './driver/driver.js';
39
- export * from './driver/database-connection.js';
40
- export * from './driver/connection-provider.js';
41
- export * from './driver/default-connection-provider.js';
42
- export * from './driver/single-connection-provider.js';
43
- export * from './dialect/postgres/postgres-dialect.js';
44
- export * from './dialect/postgres/postgres-query-compiler.js';
45
- export * from './dialect/postgres/postgres-driver.js';
46
- export * from './dialect/postgres/postgres-introspector.js';
47
- export * from './dialect/postgres/postgres-adapter.js';
48
- export * from './dialect/mysql/mysql-dialect.js';
49
- export * from './dialect/mysql/mysql-query-compiler.js';
50
- export * from './dialect/mysql/mysql-driver.js';
51
- export * from './dialect/mysql/mysql-introspector.js';
52
- export * from './dialect/mysql/mysql-adapter.js';
1
+ export * from './index-nodeless.js';
2
+ export * from './migration/file-migration-provider.js';
53
3
  export * from './dialect/sqlite/sqlite-dialect.js';
54
- export * from './dialect/sqlite/sqlite-query-compiler.js';
55
4
  export * from './dialect/sqlite/sqlite-driver.js';
56
- export * from './dialect/sqlite/sqlite-introspector.js';
57
- export * from './dialect/sqlite/sqlite-adapter.js';
58
- export * from './query-compiler/default-query-compiler.js';
59
- export * from './query-compiler/query-compiler.js';
60
- export * from './migration/migrator.js';
61
- export * from './migration/file-migration-provider.js';
62
- export * from './dialect/dialect.js';
63
- export * from './dialect/dialect-adapter.js';
64
- export * from './dialect/dialect-adapter-base.js';
65
- export * from './plugin/kysely-plugin.js';
66
- export * from './plugin/camel-case/camel-case-plugin.js';
67
- export * from './operation-node/add-column-node.js';
68
- export * from './operation-node/add-constraint-node.js';
69
- export * from './operation-node/alias-node.js';
70
- export * from './operation-node/alter-column-node.js';
71
- export * from './operation-node/alter-table-node.js';
72
- export * from './operation-node/and-node.js';
73
- export * from './operation-node/check-constraint-node.js';
74
- export * from './operation-node/column-definition-node.js';
75
- export * from './operation-node/column-node.js';
76
- export * from './operation-node/column-update-node.js';
77
- export * from './operation-node/common-table-expression-node.js';
78
- export * from './operation-node/common-table-expression-name-node.js';
79
- export * from './operation-node/constraint-node.js';
80
- export * from './operation-node/create-index-node.js';
81
- export * from './operation-node/create-schema-node.js';
82
- export * from './operation-node/create-table-node.js';
83
- export * from './operation-node/create-view-node.js';
84
- export * from './operation-node/data-type-node.js';
85
- export * from './operation-node/default-value-node.js';
86
- export * from './operation-node/delete-query-node.js';
87
- export * from './operation-node/drop-column-node.js';
88
- export * from './operation-node/drop-constraint-node.js';
89
- export * from './operation-node/drop-index-node.js';
90
- export * from './operation-node/drop-schema-node.js';
91
- export * from './operation-node/drop-table-node.js';
92
- export * from './operation-node/drop-view-node.js';
93
- export * from './operation-node/filter-node.js';
94
- export * from './operation-node/foreign-key-constraint-node.js';
95
- export * from './operation-node/from-node.js';
96
- export * from './operation-node/generated-node.js';
97
- export * from './operation-node/group-by-item-node.js';
98
- export * from './operation-node/group-by-node.js';
99
- export * from './operation-node/having-node.js';
100
- export * from './operation-node/identifier-node.js';
101
- export * from './operation-node/insert-query-node.js';
102
- export * from './operation-node/join-node.js';
103
- export * from './operation-node/limit-node.js';
104
- export * from './operation-node/list-node.js';
105
- export * from './operation-node/modify-column-node.js';
106
- export * from './operation-node/offset-node.js';
107
- export * from './operation-node/on-conflict-node.js';
108
- export * from './operation-node/on-duplicate-key-node.js';
109
- export * from './operation-node/on-node.js';
110
- export * from './operation-node/operation-node-source.js';
111
- export * from './operation-node/operation-node-transformer.js';
112
- export * from './operation-node/operation-node-utils.js';
113
- export * from './operation-node/operation-node-visitor.js';
114
- export * from './operation-node/operation-node.js';
115
- export * from './operation-node/operator-node.js';
116
- export * from './operation-node/or-node.js';
117
- export * from './operation-node/order-by-item-node.js';
118
- export * from './operation-node/order-by-node.js';
119
- export * from './operation-node/parens-node.js';
120
- export * from './operation-node/primary-constraint-node.js';
121
- export * from './operation-node/primitive-value-list-node.js';
122
- export * from './operation-node/query-node.js';
123
- export * from './operation-node/raw-node.js';
124
- export * from './operation-node/reference-node.js';
125
- export * from './operation-node/references-node.js';
126
- export * from './operation-node/rename-column-node.js';
127
- export * from './operation-node/returning-node.js';
128
- export * from './operation-node/select-all-node.js';
129
- export * from './operation-node/select-query-node.js';
130
- export * from './operation-node/select-query-node.js';
131
- export * from './operation-node/selection-node.js';
132
- export * from './operation-node/table-node.js';
133
- export * from './operation-node/union-node.js';
134
- export * from './operation-node/unique-constraint-node.js';
135
- export * from './operation-node/update-query-node.js';
136
- export * from './operation-node/value-list-node.js';
137
- export * from './operation-node/value-node.js';
138
- export * from './operation-node/values-node.js';
139
- export * from './operation-node/where-node.js';
140
- export * from './operation-node/with-node.js';
141
- export * from './dialect/database-introspector.js';
142
- export * from './util/column-type.js';
143
- export * from './util/compilable.js';
144
- export * from './util/log.js';
145
- export { AnyColumn, UnknownRow, AnySelectQueryBuilder, } from './util/type-utils.js';
146
- export { SelectExpression, SelectExpressionOrList, Selection, } from './parser/select-parser.js';
147
- export { ReferenceExpression, ReferenceExpressionOrList, } from './parser/reference-parser.js';
148
- export { ValueExpression, ValueExpressionOrList, } from './parser/value-parser.js';
149
- export { FilterValueExpression, FilterValueExpressionOrList, ExistsExpression, FilterOperator, } from './parser/filter-parser.js';
150
- export { TableExpression, TableExpressionOrList, } from './parser/table-parser.js';
151
- export { JoinReferenceExpression, JoinCallbackExpression, } from './parser/join-parser.js';
152
- export { InsertObject } from './parser/insert-values-parser.js';
153
- export { MutationObject } from './parser/update-set-parser.js';
154
- export { OrderByExpression, OrderByDirectionExpression, } from './parser/order-by-parser.js';
155
- export { UnionExpression } from './parser/union-parser.js';
5
+ export * from './dialect/mysql/mysql-dialect.js';
6
+ export * from './dialect/mysql/mysql-driver.js';
7
+ export * from './dialect/postgres/postgres-driver.js';
8
+ export * from './dialect/postgres/postgres-dialect.js';
package/dist/esm/index.js CHANGED
@@ -1,144 +1,8 @@
1
- export * from './kysely.js';
2
- export * from './query-creator.js';
3
- export * from './query-builder/where-interface.js';
4
- export * from './query-builder/join-interface.js';
5
- export * from './query-builder/returning-interface.js';
6
- export * from './query-builder/having-interface.js';
7
- export * from './query-builder/select-query-builder.js';
8
- export * from './query-builder/insert-query-builder.js';
9
- export * from './query-builder/update-query-builder.js';
10
- export * from './query-builder/delete-query-builder.js';
11
- export * from './query-builder/no-result-error.js';
12
- export * from './query-builder/join-builder.js';
13
- export * from './query-builder/expression-builder.js';
14
- export * from './query-builder/function-builder.js';
15
- export * from './query-builder/insert-result.js';
16
- export * from './query-builder/delete-result.js';
17
- export * from './query-builder/update-result.js';
18
- export * from './query-builder/on-conflict-builder.js';
19
- export * from './raw-builder/raw-builder.js';
20
- export * from './query-executor/query-executor.js';
21
- export * from './query-executor/default-query-executor.js';
22
- export * from './query-executor/noop-query-executor.js';
23
- export * from './query-compiler/default-query-compiler.js';
24
- export * from './query-compiler/compiled-query.js';
25
- export * from './schema/schema.js';
26
- export * from './schema/create-table-builder.js';
27
- export * from './schema/drop-table-builder.js';
28
- export * from './schema/create-index-builder.js';
29
- export * from './schema/drop-index-builder.js';
30
- export * from './schema/create-schema-builder.js';
31
- export * from './schema/drop-schema-builder.js';
32
- export * from './schema/column-definition-builder.js';
33
- export * from './schema/foreign-key-constraint-builder.js';
34
- export * from './schema/alter-table-builder.js';
35
- export * from './schema/create-view-builder.js';
36
- export * from './schema/drop-view-builder.js';
37
- export * from './dynamic/dynamic.js';
38
- export * from './driver/driver.js';
39
- export * from './driver/database-connection.js';
40
- export * from './driver/connection-provider.js';
41
- export * from './driver/default-connection-provider.js';
42
- export * from './driver/single-connection-provider.js';
43
- export * from './dialect/postgres/postgres-dialect.js';
44
- export * from './dialect/postgres/postgres-query-compiler.js';
45
- export * from './dialect/postgres/postgres-driver.js';
46
- export * from './dialect/postgres/postgres-introspector.js';
47
- export * from './dialect/postgres/postgres-adapter.js';
48
- export * from './dialect/mysql/mysql-dialect.js';
49
- export * from './dialect/mysql/mysql-query-compiler.js';
50
- export * from './dialect/mysql/mysql-driver.js';
51
- export * from './dialect/mysql/mysql-introspector.js';
52
- export * from './dialect/mysql/mysql-adapter.js';
1
+ export * from './index-nodeless.js';
2
+ export * from './migration/file-migration-provider.js';
53
3
  export * from './dialect/sqlite/sqlite-dialect.js';
54
- export * from './dialect/sqlite/sqlite-query-compiler.js';
55
4
  export * from './dialect/sqlite/sqlite-driver.js';
56
- export * from './dialect/sqlite/sqlite-introspector.js';
57
- export * from './dialect/sqlite/sqlite-adapter.js';
58
- export * from './query-compiler/default-query-compiler.js';
59
- export * from './query-compiler/query-compiler.js';
60
- export * from './migration/migrator.js';
61
- export * from './migration/file-migration-provider.js';
62
- export * from './dialect/dialect.js';
63
- export * from './dialect/dialect-adapter.js';
64
- export * from './dialect/dialect-adapter-base.js';
65
- export * from './plugin/kysely-plugin.js';
66
- export * from './plugin/camel-case/camel-case-plugin.js';
67
- export * from './operation-node/add-column-node.js';
68
- export * from './operation-node/add-constraint-node.js';
69
- export * from './operation-node/alias-node.js';
70
- export * from './operation-node/alter-column-node.js';
71
- export * from './operation-node/alter-table-node.js';
72
- export * from './operation-node/and-node.js';
73
- export * from './operation-node/check-constraint-node.js';
74
- export * from './operation-node/column-definition-node.js';
75
- export * from './operation-node/column-node.js';
76
- export * from './operation-node/column-update-node.js';
77
- export * from './operation-node/common-table-expression-node.js';
78
- export * from './operation-node/common-table-expression-name-node.js';
79
- export * from './operation-node/constraint-node.js';
80
- export * from './operation-node/create-index-node.js';
81
- export * from './operation-node/create-schema-node.js';
82
- export * from './operation-node/create-table-node.js';
83
- export * from './operation-node/create-view-node.js';
84
- export * from './operation-node/data-type-node.js';
85
- export * from './operation-node/default-value-node.js';
86
- export * from './operation-node/delete-query-node.js';
87
- export * from './operation-node/drop-column-node.js';
88
- export * from './operation-node/drop-constraint-node.js';
89
- export * from './operation-node/drop-index-node.js';
90
- export * from './operation-node/drop-schema-node.js';
91
- export * from './operation-node/drop-table-node.js';
92
- export * from './operation-node/drop-view-node.js';
93
- export * from './operation-node/filter-node.js';
94
- export * from './operation-node/foreign-key-constraint-node.js';
95
- export * from './operation-node/from-node.js';
96
- export * from './operation-node/generated-node.js';
97
- export * from './operation-node/group-by-item-node.js';
98
- export * from './operation-node/group-by-node.js';
99
- export * from './operation-node/having-node.js';
100
- export * from './operation-node/identifier-node.js';
101
- export * from './operation-node/insert-query-node.js';
102
- export * from './operation-node/join-node.js';
103
- export * from './operation-node/limit-node.js';
104
- export * from './operation-node/list-node.js';
105
- export * from './operation-node/modify-column-node.js';
106
- export * from './operation-node/offset-node.js';
107
- export * from './operation-node/on-conflict-node.js';
108
- export * from './operation-node/on-duplicate-key-node.js';
109
- export * from './operation-node/on-node.js';
110
- export * from './operation-node/operation-node-source.js';
111
- export * from './operation-node/operation-node-transformer.js';
112
- export * from './operation-node/operation-node-utils.js';
113
- export * from './operation-node/operation-node-visitor.js';
114
- export * from './operation-node/operation-node.js';
115
- export * from './operation-node/operator-node.js';
116
- export * from './operation-node/or-node.js';
117
- export * from './operation-node/order-by-item-node.js';
118
- export * from './operation-node/order-by-node.js';
119
- export * from './operation-node/parens-node.js';
120
- export * from './operation-node/primary-constraint-node.js';
121
- export * from './operation-node/primitive-value-list-node.js';
122
- export * from './operation-node/query-node.js';
123
- export * from './operation-node/raw-node.js';
124
- export * from './operation-node/reference-node.js';
125
- export * from './operation-node/references-node.js';
126
- export * from './operation-node/rename-column-node.js';
127
- export * from './operation-node/returning-node.js';
128
- export * from './operation-node/select-all-node.js';
129
- export * from './operation-node/select-query-node.js';
130
- export * from './operation-node/select-query-node.js';
131
- export * from './operation-node/selection-node.js';
132
- export * from './operation-node/table-node.js';
133
- export * from './operation-node/union-node.js';
134
- export * from './operation-node/unique-constraint-node.js';
135
- export * from './operation-node/update-query-node.js';
136
- export * from './operation-node/value-list-node.js';
137
- export * from './operation-node/value-node.js';
138
- export * from './operation-node/values-node.js';
139
- export * from './operation-node/where-node.js';
140
- export * from './operation-node/with-node.js';
141
- export * from './dialect/database-introspector.js';
142
- export * from './util/column-type.js';
143
- export * from './util/compilable.js';
144
- export * from './util/log.js';
5
+ export * from './dialect/mysql/mysql-dialect.js';
6
+ export * from './dialect/mysql/mysql-driver.js';
7
+ export * from './dialect/postgres/postgres-driver.js';
8
+ export * from './dialect/postgres/postgres-dialect.js';
@@ -56,9 +56,11 @@ import { PRIVATE_ADAPTER } from './util/private-symbols.js';
56
56
  export class Kysely extends QueryCreator {
57
57
  #props;
58
58
  constructor(args) {
59
+ let superProps;
60
+ let props;
59
61
  if (isKyselyProps(args)) {
60
- super({ executor: args.executor, parseContext: args.parseContext });
61
- this.#props = freeze({ ...args });
62
+ superProps = { executor: args.executor, parseContext: args.parseContext };
63
+ props = { ...args };
62
64
  }
63
65
  else {
64
66
  const dialect = args.dialect;
@@ -70,15 +72,17 @@ export class Kysely extends QueryCreator {
70
72
  const runtimeDriver = new RuntimeDriver(driver, log);
71
73
  const connectionProvider = new DefaultConnectionProvider(runtimeDriver);
72
74
  const executor = new DefaultQueryExecutor(compiler, connectionProvider, args.plugins ?? []);
73
- super({ executor, parseContext });
74
- this.#props = freeze({
75
+ superProps = { executor, parseContext };
76
+ props = {
75
77
  config: args,
76
78
  executor,
77
79
  dialect,
78
80
  driver: runtimeDriver,
79
81
  parseContext,
80
- });
82
+ };
81
83
  }
84
+ super(superProps);
85
+ this.#props = freeze(props);
82
86
  }
83
87
  /**
84
88
  * 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
  *
@@ -2,39 +2,30 @@ import { isFunction, isObject } from '../util/object-utils.js';
2
2
  /**
3
3
  * Reads all migrations from a folder.
4
4
  *
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
5
  * ### Examples
10
6
  *
11
7
  * ```ts
12
- * import * as path from 'path'
13
- * import * as fs from 'fs/promises'
14
- *
15
8
  * new FileMigrationProvider(
16
- * fs.readdir,
17
- * path.join,
18
- * path.join(__dirname, 'migrations')
9
+ * 'path/to/migrations/folder'
19
10
  * )
20
11
  * ```
21
12
  */
22
13
  export class FileMigrationProvider {
23
- #readDir;
24
- #joinPath;
25
14
  #migrationFolderPath;
26
- constructor(readDir, joinPath, migrationFolderPath) {
27
- this.#readDir = readDir;
28
- this.#joinPath = joinPath;
15
+ constructor(migrationFolderPath) {
29
16
  this.#migrationFolderPath = migrationFolderPath;
30
17
  }
31
18
  async getMigrations() {
19
+ // Import these dynamically so that we don't have any top level
20
+ // node dependencies.
21
+ const fs = await import('fs/promises');
22
+ const path = await import('path');
32
23
  const migrations = {};
33
- const files = await this.#readDir(this.#migrationFolderPath);
24
+ const files = await fs.readdir(this.#migrationFolderPath);
34
25
  for (const fileName of files) {
35
26
  if ((fileName.endsWith('.js') || fileName.endsWith('.ts')) &&
36
27
  !fileName.endsWith('.d.ts')) {
37
- const migration = await import(this.#joinPath(this.#migrationFolderPath, fileName));
28
+ const migration = await import(path.join(this.#migrationFolderPath, fileName));
38
29
  if (isMigration(migration)) {
39
30
  migrations[fileName.substring(0, fileName.length - 3)] = migration;
40
31
  }
@@ -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
  *
@@ -17,14 +17,9 @@ export const NO_MIGRATIONS = freeze({ __noMigrations__: true });
17
17
  * ```ts
18
18
  * const migrator = new Migrator({
19
19
  * db,
20
- * // The constructor signature of FileMigrationProvider is a
21
- * // bit weird to keep Kysely independent of node.js or any
22
- * // other environment.
23
20
  * provider: new FileMigrationProvider(
24
- * fs.readdir,
25
- * path.join,
26
21
  * // Path to the folder that contains all your migrations.
27
- * 'migrations'
22
+ * 'some/path/to/migrations'
28
23
  * )
29
24
  * })
30
25
  * ```
@@ -50,9 +45,6 @@ export class Migrator {
50
45
  * ### Examples
51
46
  *
52
47
  * ```ts
53
- * import * as path from 'path'
54
- * import * as fs from 'fs/promises'
55
- *
56
48
  * const db = new Kysely<Database>({
57
49
  * dialect: new PostgresDialect({
58
50
  * host: 'localhost',
@@ -62,14 +54,9 @@ export class Migrator {
62
54
  *
63
55
  * const migrator = new Migrator({
64
56
  * db,
65
- * // The constructor signature of FileMigrationProvider is a
66
- * // bit weird to keep Kysely independent of node.js or any
67
- * // other environment.
68
57
  * provider: new FileMigrationProvider(
69
- * fs.readdir,
70
- * path.join,
71
58
  * // Path to the folder that contains all your migrations.
72
- * 'migrations'
59
+ * 'some/path/to/migrations'
73
60
  * )
74
61
  * })
75
62
  *
@@ -1,11 +1,11 @@
1
1
  import { JoinNode, JoinType } from '../operation-node/join-node.js';
2
2
  import { AnyColumn, AnyColumnWithTable } from '../util/type-utils.js';
3
- import { ExtractAliasFromTableExpression, TableExpressionDatabase } from './table-parser.js';
3
+ import { TableExpressionDatabase, TableExpressionTables } from './table-parser.js';
4
4
  import { JoinBuilder } from '../query-builder/join-builder.js';
5
5
  import { ParseContext } from './parse-context.js';
6
6
  export declare type JoinReferenceExpression<DB, TB extends keyof DB, TE> = AnyJoinColumn<DB, TB, TE> | AnyJoinColumnWithTable<DB, TB, TE>;
7
- export declare type JoinCallbackExpression<DB, TB extends keyof DB, TE> = (join: JoinBuilder<TableExpressionDatabase<DB, TE>, TB | ExtractAliasFromTableExpression<DB, TE>>) => JoinBuilder<any, any>;
8
- declare type AnyJoinColumn<DB, TB extends keyof DB, TE> = AnyColumn<TableExpressionDatabase<DB, TE>, TB | ExtractAliasFromTableExpression<DB, TE>>;
9
- declare type AnyJoinColumnWithTable<DB, TB extends keyof DB, TE> = AnyColumnWithTable<TableExpressionDatabase<DB, TE>, TB | ExtractAliasFromTableExpression<DB, TE>>;
7
+ export declare type JoinCallbackExpression<DB, TB extends keyof DB, TE> = (join: JoinBuilder<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>) => JoinBuilder<any, any>;
8
+ declare type AnyJoinColumn<DB, TB extends keyof DB, TE> = AnyColumn<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>;
9
+ declare type AnyJoinColumnWithTable<DB, TB extends keyof DB, TE> = AnyColumnWithTable<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, TB, TE>>;
10
10
  export declare function parseJoin(ctx: ParseContext, joinType: JoinType, args: any[]): JoinNode;
11
11
  export {};
@@ -17,6 +17,7 @@ import { JoinInterface } from './join-interface.js';
17
17
  import { ReturningInterface } from './returning-interface.js';
18
18
  import { NoResultErrorConstructor } from './no-result-error.js';
19
19
  import { DeleteQueryNode } from '../operation-node/delete-query-node.js';
20
+ import { Selectable } from '../util/column-type.js';
20
21
  export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements WhereInterface<DB, TB>, JoinInterface<DB, TB>, ReturningInterface<DB, TB, O>, OperationNodeSource, Compilable {
21
22
  #private;
22
23
  constructor(props: DeleteQueryBuilderProps);
@@ -472,13 +473,13 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
472
473
  * and "pet"."name" = $1
473
474
  * ```
474
475
  *
475
- * You can join a subquery by providing a function as the first
476
- * argument:
476
+ * You can join a subquery by providing a select query (or a callback)
477
+ * as the first argument:
477
478
  *
478
479
  * ```ts
479
480
  * await db.selectFrom('person')
480
481
  * .innerJoin(
481
- * (qb) => qb.selectFrom('pet')
482
+ * qb.selectFrom('pet')
482
483
  * .select(['owner_id', 'name'])
483
484
  * .where('name', '=', 'Doggo')
484
485
  * .as('doggos'),
@@ -584,7 +585,7 @@ export declare class DeleteQueryBuilder<DB, TB extends keyof DB, O> implements W
584
585
  * Adds a `returning *` to an insert/update/delete query on databases
585
586
  * that support `returning` such as PostgreSQL.
586
587
  */
587
- returningAll(): DeleteQueryBuilder<DB, TB, DB[TB]>;
588
+ returningAll(): DeleteQueryBuilder<DB, TB, Selectable<DB[TB]>>;
588
589
  /**
589
590
  * Simply calls the given function passing `this` as the only argument.
590
591
  *
@@ -15,6 +15,7 @@ import { NoResultErrorConstructor } from './no-result-error.js';
15
15
  import { ComplexExpression } from '../parser/complex-expression-parser.js';
16
16
  import { ReturningInterface } from './returning-interface.js';
17
17
  import { OnConflictBuilder, OnConflictDoNothingBuilder, OnConflictUpdateBuilder } from './on-conflict-builder.js';
18
+ import { Selectable } from '../util/column-type.js';
18
19
  export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements ReturningInterface<DB, TB, O>, OperationNodeSource, Compilable {
19
20
  #private;
20
21
  constructor(props: InsertQueryBuilderProps);
@@ -427,7 +428,7 @@ export declare class InsertQueryBuilder<DB, TB extends keyof DB, O> implements R
427
428
  * Adds a `returning *` to an insert/update/delete query on databases
428
429
  * that support `returning` such as PostgreSQL.
429
430
  */
430
- returningAll(): InsertQueryBuilder<DB, TB, DB[TB]>;
431
+ returningAll(): InsertQueryBuilder<DB, TB, Selectable<DB[TB]>>;
431
432
  /**
432
433
  * Simply calls the given function passing `this` as the only argument.
433
434
  *
@@ -80,13 +80,13 @@ export interface JoinInterface<DB, TB extends keyof DB> {
80
80
  * and "pet"."name" = $1
81
81
  * ```
82
82
  *
83
- * You can join a subquery by providing a function as the first
84
- * argument:
83
+ * You can join a subquery by providing a select query (or a callback)
84
+ * as the first argument:
85
85
  *
86
86
  * ```ts
87
87
  * await db.selectFrom('person')
88
88
  * .innerJoin(
89
- * (qb) => qb.selectFrom('pet')
89
+ * qb.selectFrom('pet')
90
90
  * .select(['owner_id', 'name'])
91
91
  * .where('name', '=', 'Doggo')
92
92
  * .as('doggos'),
@@ -1,5 +1,6 @@
1
1
  import { ReturningRow } from '../parser/returning-parser.js';
2
2
  import { SelectExpression } from '../parser/select-parser.js';
3
+ import { Selectable } from '../util/column-type.js';
3
4
  export interface ReturningInterface<DB, TB extends keyof DB, O> {
4
5
  /**
5
6
  * Allows you to return data from modified rows.
@@ -66,5 +67,5 @@ export interface ReturningInterface<DB, TB extends keyof DB, O> {
66
67
  * Adds a `returning *` to an insert/update/delete query on databases
67
68
  * that support `returning` such as PostgreSQL.
68
69
  */
69
- returningAll(): ReturningInterface<DB, TB, DB[TB]>;
70
+ returningAll(): ReturningInterface<DB, TB, Selectable<DB[TB]>>;
70
71
  }