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.
- package/README.md +1 -9
- package/dist/cjs/dialect/database-introspector.d.ts +1 -1
- package/dist/cjs/dialect/dialect-adapter-base.d.ts +1 -1
- package/dist/cjs/dialect/dialect-adapter.d.ts +1 -1
- package/dist/cjs/dialect/dialect.d.ts +2 -2
- package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +1 -1
- package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +2 -2
- package/dist/cjs/dialect/mysql/mysql-introspector.d.ts +1 -1
- package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +1 -1
- package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +2 -2
- package/dist/cjs/dialect/postgres/postgres-introspector.d.ts +1 -1
- package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +1 -1
- package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +1 -1
- package/dist/cjs/kysely.js +9 -5
- package/dist/cjs/migration/file-migration-provider.d.ts +2 -25
- package/dist/cjs/migration/file-migration-provider.js +8 -17
- package/dist/cjs/migration/migrator.d.ts +2 -15
- package/dist/cjs/migration/migrator.js +2 -15
- package/dist/cjs/operation-node/constraint-node.d.ts +4 -4
- package/dist/cjs/parser/join-parser.d.ts +4 -4
- package/dist/cjs/plugin/camel-case/camel-case-plugin.js +1 -1
- package/dist/cjs/query-builder/delete-query-builder.d.ts +3 -3
- package/dist/cjs/query-builder/expression-builder.d.ts +42 -0
- package/dist/cjs/query-builder/expression-builder.js +48 -0
- package/dist/cjs/query-builder/insert-query-builder.d.ts +16 -0
- package/dist/cjs/query-builder/insert-query-builder.js +16 -0
- package/dist/cjs/query-builder/join-interface.d.ts +3 -3
- package/dist/cjs/query-builder/on-conflict-builder.d.ts +5 -3
- package/dist/cjs/query-builder/select-query-builder.d.ts +3 -3
- package/dist/cjs/query-builder/update-query-builder.d.ts +3 -3
- package/dist/cjs/query-creator.d.ts +1 -1
- package/dist/cjs/util/object-utils.d.ts +1 -1
- package/dist/cjs/util/object-utils.js +8 -8
- package/dist/esm/dialect/database-introspector.d.ts +1 -1
- package/dist/esm/dialect/database-introspector.js +1 -0
- package/dist/esm/dialect/dialect-adapter-base.d.ts +1 -1
- package/dist/esm/dialect/dialect-adapter-base.js +1 -0
- package/dist/esm/dialect/dialect-adapter.d.ts +1 -1
- package/dist/esm/dialect/dialect-adapter.js +1 -0
- package/dist/esm/dialect/dialect.d.ts +2 -2
- package/dist/esm/dialect/dialect.js +1 -0
- package/dist/esm/dialect/mysql/mysql-adapter.d.ts +1 -1
- package/dist/esm/dialect/mysql/mysql-adapter.js +1 -0
- package/dist/esm/dialect/mysql/mysql-dialect.d.ts +2 -2
- package/dist/esm/dialect/mysql/mysql-dialect.js +1 -0
- package/dist/esm/dialect/mysql/mysql-driver.js +1 -0
- package/dist/esm/dialect/mysql/mysql-introspector.d.ts +1 -1
- package/dist/esm/dialect/mysql/mysql-introspector.js +1 -0
- package/dist/esm/dialect/mysql/mysql-query-compiler.js +1 -0
- package/dist/esm/dialect/postgres/postgres-adapter.d.ts +1 -1
- package/dist/esm/dialect/postgres/postgres-adapter.js +1 -0
- package/dist/esm/dialect/postgres/postgres-dialect.d.ts +2 -2
- package/dist/esm/dialect/postgres/postgres-dialect.js +1 -0
- package/dist/esm/dialect/postgres/postgres-driver.js +1 -0
- package/dist/esm/dialect/postgres/postgres-introspector.d.ts +1 -1
- package/dist/esm/dialect/postgres/postgres-introspector.js +1 -0
- package/dist/esm/dialect/postgres/postgres-query-compiler.js +1 -0
- package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +1 -1
- package/dist/esm/dialect/sqlite/sqlite-adapter.js +1 -0
- package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +2 -2
- package/dist/esm/dialect/sqlite/sqlite-dialect.js +1 -0
- package/dist/esm/dialect/sqlite/sqlite-driver.js +1 -0
- package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +1 -1
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -0
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +1 -0
- package/dist/esm/driver/connection-provider.js +1 -0
- package/dist/esm/driver/database-connection.js +1 -0
- package/dist/esm/driver/default-connection-provider.js +1 -0
- package/dist/esm/driver/driver.js +1 -0
- package/dist/esm/driver/runtime-driver.js +1 -0
- package/dist/esm/driver/single-connection-provider.js +1 -0
- package/dist/esm/dynamic/dynamic-reference-builder.js +1 -0
- package/dist/esm/dynamic/dynamic.js +1 -0
- package/dist/esm/index-nodeless.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/kysely.js +10 -5
- package/dist/esm/migration/file-migration-provider.d.ts +2 -25
- package/dist/esm/migration/file-migration-provider.js +9 -17
- package/dist/esm/migration/migrator.d.ts +2 -15
- package/dist/esm/migration/migrator.js +3 -15
- package/dist/esm/operation-node/add-column-node.js +1 -0
- package/dist/esm/operation-node/add-constraint-node.js +1 -0
- package/dist/esm/operation-node/alias-node.js +1 -0
- package/dist/esm/operation-node/alter-column-node.js +1 -0
- package/dist/esm/operation-node/alter-table-node.js +1 -0
- package/dist/esm/operation-node/and-node.js +1 -0
- package/dist/esm/operation-node/check-constraint-node.js +1 -0
- package/dist/esm/operation-node/column-definition-node.js +1 -0
- package/dist/esm/operation-node/column-node.js +1 -0
- package/dist/esm/operation-node/column-update-node.js +1 -0
- package/dist/esm/operation-node/common-table-expression-name-node.js +1 -0
- package/dist/esm/operation-node/common-table-expression-node.js +1 -0
- package/dist/esm/operation-node/constraint-node.d.ts +4 -4
- package/dist/esm/operation-node/constraint-node.js +1 -0
- package/dist/esm/operation-node/create-index-node.js +1 -0
- package/dist/esm/operation-node/create-schema-node.js +1 -0
- package/dist/esm/operation-node/create-table-node.js +1 -0
- package/dist/esm/operation-node/create-view-node.js +1 -0
- package/dist/esm/operation-node/data-type-node.js +1 -0
- package/dist/esm/operation-node/default-value-node.js +1 -0
- package/dist/esm/operation-node/delete-query-node.js +1 -0
- package/dist/esm/operation-node/drop-column-node.js +1 -0
- package/dist/esm/operation-node/drop-constraint-node.js +1 -0
- package/dist/esm/operation-node/drop-index-node.js +1 -0
- package/dist/esm/operation-node/drop-schema-node.js +1 -0
- package/dist/esm/operation-node/drop-table-node.js +1 -0
- package/dist/esm/operation-node/drop-view-node.js +1 -0
- package/dist/esm/operation-node/filter-node.js +1 -0
- package/dist/esm/operation-node/foreign-key-constraint-node.js +1 -0
- package/dist/esm/operation-node/from-node.js +1 -0
- package/dist/esm/operation-node/generated-node.js +1 -0
- package/dist/esm/operation-node/group-by-item-node.js +1 -0
- package/dist/esm/operation-node/group-by-node.js +1 -0
- package/dist/esm/operation-node/having-node.js +1 -0
- package/dist/esm/operation-node/identifier-node.js +1 -0
- package/dist/esm/operation-node/insert-query-node.js +1 -0
- package/dist/esm/operation-node/join-node.js +1 -0
- package/dist/esm/operation-node/limit-node.js +1 -0
- package/dist/esm/operation-node/list-node.js +1 -0
- package/dist/esm/operation-node/modify-column-node.js +1 -0
- package/dist/esm/operation-node/offset-node.js +1 -0
- package/dist/esm/operation-node/on-conflict-node.js +1 -0
- package/dist/esm/operation-node/on-duplicate-key-node.js +1 -0
- package/dist/esm/operation-node/on-node.js +1 -0
- package/dist/esm/operation-node/operation-node-source.js +1 -0
- package/dist/esm/operation-node/operation-node-transformer.js +1 -0
- package/dist/esm/operation-node/operation-node-utils.js +1 -0
- package/dist/esm/operation-node/operation-node-visitor.js +1 -0
- package/dist/esm/operation-node/operation-node.js +1 -0
- package/dist/esm/operation-node/operator-node.js +1 -0
- package/dist/esm/operation-node/or-node.js +1 -0
- package/dist/esm/operation-node/order-by-item-node.js +1 -0
- package/dist/esm/operation-node/order-by-node.js +1 -0
- package/dist/esm/operation-node/parens-node.js +1 -0
- package/dist/esm/operation-node/primary-constraint-node.js +1 -0
- package/dist/esm/operation-node/primitive-value-list-node.js +1 -0
- package/dist/esm/operation-node/query-node.js +1 -0
- package/dist/esm/operation-node/raw-node.js +1 -0
- package/dist/esm/operation-node/reference-node.js +1 -0
- package/dist/esm/operation-node/references-node.js +1 -0
- package/dist/esm/operation-node/rename-column-node.js +1 -0
- package/dist/esm/operation-node/returning-node.js +1 -0
- package/dist/esm/operation-node/select-all-node.js +1 -0
- package/dist/esm/operation-node/select-query-node.js +1 -0
- package/dist/esm/operation-node/selection-node.js +1 -0
- package/dist/esm/operation-node/table-node.js +1 -0
- package/dist/esm/operation-node/union-node.js +1 -0
- package/dist/esm/operation-node/unique-constraint-node.js +1 -0
- package/dist/esm/operation-node/update-query-node.js +1 -0
- package/dist/esm/operation-node/value-list-node.js +1 -0
- package/dist/esm/operation-node/value-node.js +1 -0
- package/dist/esm/operation-node/values-node.js +1 -0
- package/dist/esm/operation-node/where-node.js +1 -0
- package/dist/esm/operation-node/with-node.js +1 -0
- package/dist/esm/parser/complex-expression-parser.js +1 -0
- package/dist/esm/parser/data-type-parser.js +1 -0
- package/dist/esm/parser/default-value-parser.js +1 -0
- package/dist/esm/parser/filter-parser.js +1 -0
- package/dist/esm/parser/group-by-parser.js +1 -0
- package/dist/esm/parser/insert-values-parser.js +1 -0
- package/dist/esm/parser/join-parser.d.ts +4 -4
- package/dist/esm/parser/join-parser.js +1 -0
- package/dist/esm/parser/order-by-parser.js +1 -0
- package/dist/esm/parser/parse-context.js +1 -0
- package/dist/esm/parser/reference-parser.js +1 -0
- package/dist/esm/parser/returning-parser.js +1 -0
- package/dist/esm/parser/select-parser.js +1 -0
- package/dist/esm/parser/table-parser.js +1 -0
- package/dist/esm/parser/union-parser.js +1 -0
- package/dist/esm/parser/update-set-parser.js +1 -0
- package/dist/esm/parser/value-parser.js +1 -0
- package/dist/esm/parser/with-parser.js +1 -0
- package/dist/esm/plugin/camel-case/camel-case-plugin.js +3 -2
- package/dist/esm/plugin/camel-case/camel-case-transformer.js +1 -0
- package/dist/esm/plugin/camel-case/camel-case.js +1 -0
- package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +1 -0
- package/dist/esm/plugin/immediate-value.ts/immediate-value-transformer.js +1 -0
- package/dist/esm/plugin/kysely-plugin.js +1 -0
- package/dist/esm/plugin/with-schema/with-schema-plugin.js +1 -0
- package/dist/esm/plugin/with-schema/with-schema-transformer.js +1 -0
- package/dist/esm/query-builder/delete-query-builder.d.ts +3 -3
- package/dist/esm/query-builder/delete-query-builder.js +1 -0
- package/dist/esm/query-builder/delete-result.js +1 -0
- package/dist/esm/query-builder/expression-builder.d.ts +42 -0
- package/dist/esm/query-builder/expression-builder.js +49 -0
- package/dist/esm/query-builder/function-builder.js +1 -0
- package/dist/esm/query-builder/having-interface.js +1 -0
- package/dist/esm/query-builder/insert-query-builder.d.ts +16 -0
- package/dist/esm/query-builder/insert-query-builder.js +17 -0
- package/dist/esm/query-builder/insert-result.js +1 -0
- package/dist/esm/query-builder/join-builder.js +1 -0
- package/dist/esm/query-builder/join-interface.d.ts +3 -3
- package/dist/esm/query-builder/join-interface.js +1 -0
- package/dist/esm/query-builder/no-result-error.js +1 -0
- package/dist/esm/query-builder/on-conflict-builder.d.ts +5 -3
- package/dist/esm/query-builder/on-conflict-builder.js +1 -0
- package/dist/esm/query-builder/returning-interface.js +1 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +3 -3
- package/dist/esm/query-builder/select-query-builder.js +1 -0
- package/dist/esm/query-builder/update-query-builder.d.ts +3 -3
- package/dist/esm/query-builder/update-query-builder.js +1 -0
- package/dist/esm/query-builder/update-result.js +1 -0
- package/dist/esm/query-builder/where-interface.js +1 -0
- package/dist/esm/query-compiler/compiled-query.js +1 -0
- package/dist/esm/query-compiler/default-query-compiler.js +1 -0
- package/dist/esm/query-compiler/query-compiler.js +1 -0
- package/dist/esm/query-creator.d.ts +1 -1
- package/dist/esm/query-creator.js +1 -0
- package/dist/esm/query-executor/default-query-executor.js +1 -0
- package/dist/esm/query-executor/noop-query-executor.js +1 -0
- package/dist/esm/query-executor/query-executor.js +1 -0
- package/dist/esm/raw-builder/raw-builder.js +1 -0
- package/dist/esm/schema/alter-table-builder.js +1 -0
- package/dist/esm/schema/column-definition-builder.js +1 -0
- package/dist/esm/schema/create-index-builder.js +1 -0
- package/dist/esm/schema/create-schema-builder.js +1 -0
- package/dist/esm/schema/create-table-builder.js +1 -0
- package/dist/esm/schema/create-view-builder.js +1 -0
- package/dist/esm/schema/drop-index-builder.js +1 -0
- package/dist/esm/schema/drop-schema-builder.js +1 -0
- package/dist/esm/schema/drop-table-builder.js +1 -0
- package/dist/esm/schema/drop-view-builder.js +1 -0
- package/dist/esm/schema/foreign-key-constraint-builder.js +1 -0
- package/dist/esm/schema/schema.js +1 -0
- package/dist/esm/util/assert.js +1 -0
- package/dist/esm/util/column-type.js +1 -0
- package/dist/esm/util/compilable.js +1 -0
- package/dist/esm/util/dynamic-import.js +1 -0
- package/dist/esm/util/log.js +1 -0
- package/dist/esm/util/object-utils.d.ts +1 -1
- package/dist/esm/util/object-utils.js +7 -6
- package/dist/esm/util/performance-now.js +1 -0
- package/dist/esm/util/prevent-await.js +1 -0
- package/dist/esm/util/private-symbols.js +1 -0
- package/dist/esm/util/query-id.js +1 -0
- package/dist/esm/util/random-string.js +1 -0
- package/dist/esm/util/type-utils.js +1 -0
- 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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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?:
|
|
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.
|
|
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) ||
|
|
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
|
-
|
|
49
|
-
|
|
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
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -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
|
|
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.
|
|
@@ -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
|
|
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.
|
|
@@ -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
|
|
28
|
-
* such as the
|
|
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}.
|
|
@@ -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
|
|
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.
|
|
@@ -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
|
|
32
|
-
* such as the
|
|
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}.
|
|
@@ -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
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -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
|
|
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.
|
|
@@ -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
|
|
38
|
-
* such as the
|
|
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}.
|
|
@@ -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
|
|
7
|
+
* Get the database metadata such as table and column names.
|
|
8
8
|
*/
|
|
9
9
|
getMetadata(options?: DatabaseMetadataOptions): Promise<DatabaseMetadata>;
|
|
10
10
|
}
|
|
@@ -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
|
|
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.
|
|
@@ -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
|
|
32
|
-
* such as the
|
|
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}.
|
|
@@ -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
|
|
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="./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';
|
package/dist/esm/index.js
CHANGED
package/dist/esm/kysely.js
CHANGED
|
@@ -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
|
-
|
|
61
|
-
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
*
|
|
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(
|
|
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
|
-
*
|
|
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(
|
|
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
|
|
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(
|
|
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
|
*
|