kysely 0.23.1 → 0.23.2

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 (56) hide show
  1. package/README.md +5 -0
  2. package/dist/cjs/operation-node/on-conflict-node.d.ts +2 -0
  3. package/dist/cjs/operation-node/on-conflict-node.js +12 -0
  4. package/dist/cjs/operation-node/query-node.d.ts +1 -0
  5. package/dist/cjs/operation-node/query-node.js +6 -0
  6. package/dist/cjs/operation-node/select-query-node.d.ts +4 -0
  7. package/dist/cjs/operation-node/select-query-node.js +24 -0
  8. package/dist/cjs/query-builder/delete-query-builder.d.ts +63 -1
  9. package/dist/cjs/query-builder/delete-query-builder.js +51 -1
  10. package/dist/cjs/query-builder/insert-query-builder.d.ts +44 -1
  11. package/dist/cjs/query-builder/insert-query-builder.js +45 -1
  12. package/dist/cjs/query-builder/on-conflict-builder.d.ts +38 -0
  13. package/dist/cjs/query-builder/on-conflict-builder.js +12 -0
  14. package/dist/cjs/query-builder/select-query-builder.d.ts +138 -1
  15. package/dist/cjs/query-builder/select-query-builder.js +146 -1
  16. package/dist/cjs/query-builder/update-query-builder.d.ts +65 -1
  17. package/dist/cjs/query-builder/update-query-builder.js +53 -1
  18. package/dist/cjs/query-builder/where-interface.d.ts +19 -0
  19. package/dist/cjs/schema/alter-table-add-foreign-key-constraint-builder.d.ts +23 -0
  20. package/dist/cjs/schema/alter-table-add-foreign-key-constraint-builder.js +38 -0
  21. package/dist/cjs/schema/alter-table-builder.d.ts +3 -35
  22. package/dist/cjs/schema/alter-table-builder.js +10 -102
  23. package/dist/cjs/schema/alter-table-drop-constraint-builder.d.ts +21 -0
  24. package/dist/cjs/schema/alter-table-drop-constraint-builder.js +54 -0
  25. package/dist/cjs/schema/alter-table-executor.d.ts +18 -0
  26. package/dist/cjs/schema/alter-table-executor.js +22 -0
  27. package/dist/cjs/util/type-error.d.ts +3 -0
  28. package/dist/cjs/util/type-error.js +2 -0
  29. package/dist/esm/operation-node/on-conflict-node.d.ts +2 -0
  30. package/dist/esm/operation-node/on-conflict-node.js +12 -0
  31. package/dist/esm/operation-node/query-node.d.ts +1 -0
  32. package/dist/esm/operation-node/query-node.js +6 -0
  33. package/dist/esm/operation-node/select-query-node.d.ts +4 -0
  34. package/dist/esm/operation-node/select-query-node.js +24 -0
  35. package/dist/esm/query-builder/delete-query-builder.d.ts +63 -1
  36. package/dist/esm/query-builder/delete-query-builder.js +51 -1
  37. package/dist/esm/query-builder/insert-query-builder.d.ts +44 -1
  38. package/dist/esm/query-builder/insert-query-builder.js +45 -1
  39. package/dist/esm/query-builder/on-conflict-builder.d.ts +38 -0
  40. package/dist/esm/query-builder/on-conflict-builder.js +12 -0
  41. package/dist/esm/query-builder/select-query-builder.d.ts +138 -1
  42. package/dist/esm/query-builder/select-query-builder.js +146 -1
  43. package/dist/esm/query-builder/update-query-builder.d.ts +65 -1
  44. package/dist/esm/query-builder/update-query-builder.js +53 -1
  45. package/dist/esm/query-builder/where-interface.d.ts +19 -0
  46. package/dist/esm/schema/alter-table-add-foreign-key-constraint-builder.d.ts +23 -0
  47. package/dist/esm/schema/alter-table-add-foreign-key-constraint-builder.js +35 -0
  48. package/dist/esm/schema/alter-table-builder.d.ts +3 -35
  49. package/dist/esm/schema/alter-table-builder.js +4 -93
  50. package/dist/esm/schema/alter-table-drop-constraint-builder.d.ts +21 -0
  51. package/dist/esm/schema/alter-table-drop-constraint-builder.js +51 -0
  52. package/dist/esm/schema/alter-table-executor.d.ts +18 -0
  53. package/dist/esm/schema/alter-table-executor.js +19 -0
  54. package/dist/esm/util/type-error.d.ts +3 -0
  55. package/dist/esm/util/type-error.js +2 -0
  56. package/package.json +2 -2
@@ -11,7 +11,7 @@ import { preventAwait } from '../util/prevent-await.js';
11
11
  import { ColumnDefinitionBuilder, } from './column-definition-builder.js';
12
12
  import { ModifyColumnNode } from '../operation-node/modify-column-node.js';
13
13
  import { parseDataTypeExpression, } from '../parser/data-type-parser.js';
14
- import { ForeignKeyConstraintBuilder, } from './foreign-key-constraint-builder.js';
14
+ import { ForeignKeyConstraintBuilder } from './foreign-key-constraint-builder.js';
15
15
  import { AddConstraintNode } from '../operation-node/add-constraint-node.js';
16
16
  import { UniqueConstraintNode } from '../operation-node/unique-constraint-node.js';
17
17
  import { CheckConstraintNode } from '../operation-node/check-constraint-node.js';
@@ -20,6 +20,9 @@ import { ColumnNode } from '../operation-node/column-node.js';
20
20
  import { parseTable } from '../parser/table-parser.js';
21
21
  import { DropConstraintNode } from '../operation-node/drop-constraint-node.js';
22
22
  import { AlterColumnBuilder, } from './alter-column-builder.js';
23
+ import { AlterTableExecutor } from './alter-table-executor.js';
24
+ import { AlterTableAddForeignKeyConstraintBuilder } from './alter-table-add-foreign-key-constraint-builder.js';
25
+ import { AlterTableDropConstraintBuilder } from './alter-table-drop-constraint-builder.js';
23
26
  /**
24
27
  * This builder can be used to create a `alter table` query.
25
28
  */
@@ -129,21 +132,6 @@ export class AlterTableBuilder {
129
132
  return func(this);
130
133
  }
131
134
  }
132
- export class AlterTableExecutor {
133
- #props;
134
- constructor(props) {
135
- this.#props = freeze(props);
136
- }
137
- toOperationNode() {
138
- return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
139
- }
140
- compile() {
141
- return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
142
- }
143
- async execute() {
144
- await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
145
- }
146
- }
147
135
  export class AlterTableColumnAlteringBuilder {
148
136
  #props;
149
137
  constructor(props) {
@@ -192,83 +180,6 @@ export class AlterTableColumnAlteringBuilder {
192
180
  await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
193
181
  }
194
182
  }
195
- export class AlterTableAddForeignKeyConstraintBuilder {
196
- #props;
197
- constructor(props) {
198
- this.#props = freeze(props);
199
- }
200
- onDelete(onDelete) {
201
- return new AlterTableAddForeignKeyConstraintBuilder({
202
- ...this.#props,
203
- constraintBuilder: this.#props.constraintBuilder.onDelete(onDelete),
204
- });
205
- }
206
- onUpdate(onUpdate) {
207
- return new AlterTableAddForeignKeyConstraintBuilder({
208
- ...this.#props,
209
- constraintBuilder: this.#props.constraintBuilder.onUpdate(onUpdate),
210
- });
211
- }
212
- toOperationNode() {
213
- return this.#props.executor.transformQuery(AlterTableNode.cloneWithTableProps(this.#props.node, {
214
- addConstraint: AddConstraintNode.create(this.#props.constraintBuilder.toOperationNode()),
215
- }), this.#props.queryId);
216
- }
217
- compile() {
218
- return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
219
- }
220
- async execute() {
221
- await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
222
- }
223
- }
224
- export class AlterTableDropConstraintBuilder {
225
- #props;
226
- constructor(props) {
227
- this.#props = freeze(props);
228
- }
229
- ifExists() {
230
- return new AlterTableDropConstraintBuilder({
231
- ...this.#props,
232
- node: AlterTableNode.cloneWithTableProps(this.#props.node, {
233
- dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
234
- ifExists: true,
235
- }),
236
- }),
237
- });
238
- }
239
- cascade() {
240
- return new AlterTableDropConstraintBuilder({
241
- ...this.#props,
242
- node: AlterTableNode.cloneWithTableProps(this.#props.node, {
243
- dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
244
- modifier: 'cascade',
245
- }),
246
- }),
247
- });
248
- }
249
- restrict() {
250
- return new AlterTableDropConstraintBuilder({
251
- ...this.#props,
252
- node: AlterTableNode.cloneWithTableProps(this.#props.node, {
253
- dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
254
- modifier: 'restrict',
255
- }),
256
- }),
257
- });
258
- }
259
- toOperationNode() {
260
- return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
261
- }
262
- compile() {
263
- return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
264
- }
265
- async execute() {
266
- await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
267
- }
268
- }
269
183
  preventAwait(AlterTableBuilder, "don't await AlterTableBuilder instances");
270
184
  preventAwait(AlterColumnBuilder, "don't await AlterColumnBuilder instances");
271
- preventAwait(AlterTableExecutor, "don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");
272
185
  preventAwait(AlterTableColumnAlteringBuilder, "don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");
273
- preventAwait(AlterTableAddForeignKeyConstraintBuilder, "don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");
274
- preventAwait(AlterTableDropConstraintBuilder, "don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");
@@ -0,0 +1,21 @@
1
+ import { AlterTableNode } from '../operation-node/alter-table-node.js';
2
+ import { OperationNodeSource } from '../operation-node/operation-node-source.js';
3
+ import { CompiledQuery } from '../query-compiler/compiled-query.js';
4
+ import { QueryExecutor } from '../query-executor/query-executor.js';
5
+ import { Compilable } from '../util/compilable.js';
6
+ import { QueryId } from '../util/query-id.js';
7
+ export declare class AlterTableDropConstraintBuilder implements OperationNodeSource, Compilable {
8
+ #private;
9
+ constructor(props: AlterTableDropConstraintBuilderProps);
10
+ ifExists(): AlterTableDropConstraintBuilder;
11
+ cascade(): AlterTableDropConstraintBuilder;
12
+ restrict(): AlterTableDropConstraintBuilder;
13
+ toOperationNode(): AlterTableNode;
14
+ compile(): CompiledQuery;
15
+ execute(): Promise<void>;
16
+ }
17
+ export interface AlterTableDropConstraintBuilderProps {
18
+ readonly queryId: QueryId;
19
+ readonly executor: QueryExecutor;
20
+ readonly node: AlterTableNode;
21
+ }
@@ -0,0 +1,51 @@
1
+ /// <reference types="./alter-table-drop-constraint-builder.d.ts" />
2
+ import { AlterTableNode } from '../operation-node/alter-table-node.js';
3
+ import { DropConstraintNode } from '../operation-node/drop-constraint-node.js';
4
+ import { freeze } from '../util/object-utils.js';
5
+ import { preventAwait } from '../util/prevent-await.js';
6
+ export class AlterTableDropConstraintBuilder {
7
+ #props;
8
+ constructor(props) {
9
+ this.#props = freeze(props);
10
+ }
11
+ ifExists() {
12
+ return new AlterTableDropConstraintBuilder({
13
+ ...this.#props,
14
+ node: AlterTableNode.cloneWithTableProps(this.#props.node, {
15
+ dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
16
+ ifExists: true,
17
+ }),
18
+ }),
19
+ });
20
+ }
21
+ cascade() {
22
+ return new AlterTableDropConstraintBuilder({
23
+ ...this.#props,
24
+ node: AlterTableNode.cloneWithTableProps(this.#props.node, {
25
+ dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
26
+ modifier: 'cascade',
27
+ }),
28
+ }),
29
+ });
30
+ }
31
+ restrict() {
32
+ return new AlterTableDropConstraintBuilder({
33
+ ...this.#props,
34
+ node: AlterTableNode.cloneWithTableProps(this.#props.node, {
35
+ dropConstraint: DropConstraintNode.cloneWith(this.#props.node.dropConstraint, {
36
+ modifier: 'restrict',
37
+ }),
38
+ }),
39
+ });
40
+ }
41
+ toOperationNode() {
42
+ return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
43
+ }
44
+ compile() {
45
+ return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
46
+ }
47
+ async execute() {
48
+ await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
49
+ }
50
+ }
51
+ preventAwait(AlterTableDropConstraintBuilder, "don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");
@@ -0,0 +1,18 @@
1
+ import { AlterTableNode } from '../operation-node/alter-table-node.js';
2
+ import { OperationNodeSource } from '../operation-node/operation-node-source.js';
3
+ import { CompiledQuery } from '../query-compiler/compiled-query.js';
4
+ import { QueryExecutor } from '../query-executor/query-executor.js';
5
+ import { Compilable } from '../util/compilable.js';
6
+ import { QueryId } from '../util/query-id.js';
7
+ export declare class AlterTableExecutor implements OperationNodeSource, Compilable {
8
+ #private;
9
+ constructor(props: AlterTableExecutorProps);
10
+ toOperationNode(): AlterTableNode;
11
+ compile(): CompiledQuery;
12
+ execute(): Promise<void>;
13
+ }
14
+ export interface AlterTableExecutorProps {
15
+ readonly queryId: QueryId;
16
+ readonly executor: QueryExecutor;
17
+ readonly node: AlterTableNode;
18
+ }
@@ -0,0 +1,19 @@
1
+ /// <reference types="./alter-table-executor.d.ts" />
2
+ import { freeze } from '../util/object-utils.js';
3
+ import { preventAwait } from '../util/prevent-await.js';
4
+ export class AlterTableExecutor {
5
+ #props;
6
+ constructor(props) {
7
+ this.#props = freeze(props);
8
+ }
9
+ toOperationNode() {
10
+ return this.#props.executor.transformQuery(this.#props.node, this.#props.queryId);
11
+ }
12
+ compile() {
13
+ return this.#props.executor.compileQuery(this.toOperationNode(), this.#props.queryId);
14
+ }
15
+ async execute() {
16
+ await this.#props.executor.executeQuery(this.compile(), this.#props.queryId);
17
+ }
18
+ }
19
+ preventAwait(AlterTableExecutor, "don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");
@@ -0,0 +1,3 @@
1
+ export interface KyselyTypeError<E extends string> {
2
+ readonly __kyselyTypeError__: E;
3
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="./type-error.d.ts" />
2
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kysely",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
4
4
  "description": "Type safe SQL query builder",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "test:typings": "tsd test/typings",
29
29
  "test:esmimports": "node scripts/check-esm-imports.js",
30
30
  "test:esbuild": "esbuild --bundle --platform=node --external:pg-native dist/esm/index.js --outfile=/dev/null",
31
- "prettier": "prettier --write src/**/*.ts test/**/*.ts",
31
+ "prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
32
32
  "build": "npm run clean && npm run build:esm && npm run build:cjs && npm run script:module-fixup && npm run script:copy-interface-doc",
33
33
  "build:esm": "tsc -p tsconfig.json && npm run script:add-deno-type-references",
34
34
  "build:cjs": "tsc -p tsconfig-cjs.json",