kysely 0.16.2 → 0.16.6
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 +4 -4
- package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +205 -0
- package/dist/cjs/dialect/mysql/mysql-dialect-config.js +2 -0
- package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +1 -205
- package/dist/cjs/dialect/mysql/mysql-driver.d.ts +1 -1
- package/dist/cjs/dialect/mysql/mysql-driver.js +10 -2
- package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +103 -0
- package/dist/cjs/dialect/postgres/postgres-dialect-config.js +2 -0
- package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +1 -103
- package/dist/cjs/dialect/postgres/postgres-driver.d.ts +1 -1
- package/dist/cjs/dialect/postgres/postgres-driver.js +11 -2
- package/dist/cjs/dialect/sqlite/sqlite-dialect-config.d.ts +43 -0
- package/dist/cjs/dialect/sqlite/sqlite-dialect-config.js +2 -0
- package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +1 -43
- package/dist/cjs/dialect/sqlite/sqlite-driver.d.ts +1 -1
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +10 -2
- package/dist/cjs/driver/dummy-driver.d.ts +40 -0
- package/dist/cjs/driver/dummy-driver.js +34 -0
- package/dist/cjs/driver/runtime-driver.d.ts +1 -1
- package/dist/cjs/driver/runtime-driver.js +30 -33
- package/dist/cjs/index-nodeless.d.ts +1 -0
- package/dist/cjs/index-nodeless.js +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/migration/migrator.d.ts +2 -2
- package/dist/cjs/operation-node/primitive-value-list-node.d.ts +2 -3
- package/dist/cjs/operation-node/value-node.d.ts +3 -4
- package/dist/cjs/parser/complex-expression-parser.d.ts +1 -0
- package/dist/cjs/parser/complex-expression-parser.js +5 -1
- package/dist/cjs/parser/default-value-parser.d.ts +2 -3
- package/dist/cjs/parser/default-value-parser.js +2 -2
- package/dist/cjs/parser/insert-values-parser.js +4 -3
- package/dist/cjs/parser/reference-parser.d.ts +2 -3
- package/dist/cjs/parser/value-parser.d.ts +2 -3
- package/dist/cjs/parser/value-parser.js +6 -7
- 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/on-conflict-builder.d.ts +5 -3
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +1 -2
- package/dist/cjs/query-creator.d.ts +1 -1
- package/dist/cjs/schema/alter-table-builder.d.ts +30 -4
- package/dist/cjs/schema/alter-table-builder.js +2 -5
- package/dist/cjs/schema/column-definition-builder.d.ts +27 -2
- package/dist/cjs/util/log.d.ts +1 -0
- package/dist/cjs/util/log.js +3 -0
- package/dist/cjs/util/object-utils.d.ts +4 -5
- package/dist/cjs/util/object-utils.js +3 -11
- package/dist/esm/dialect/database-introspector.js +1 -0
- package/dist/esm/dialect/dialect-adapter-base.js +1 -0
- package/dist/esm/dialect/dialect-adapter.js +1 -0
- package/dist/esm/dialect/dialect.js +1 -0
- package/dist/esm/dialect/mysql/mysql-adapter.js +1 -0
- package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +205 -0
- package/dist/esm/dialect/mysql/mysql-dialect-config.js +2 -0
- package/dist/esm/dialect/mysql/mysql-dialect.d.ts +1 -205
- package/dist/esm/dialect/mysql/mysql-dialect.js +1 -0
- package/dist/esm/dialect/mysql/mysql-driver.d.ts +1 -1
- package/dist/esm/dialect/mysql/mysql-driver.js +12 -3
- 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.js +1 -0
- package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +103 -0
- package/dist/esm/dialect/postgres/postgres-dialect-config.js +2 -0
- package/dist/esm/dialect/postgres/postgres-dialect.d.ts +1 -103
- package/dist/esm/dialect/postgres/postgres-dialect.js +1 -0
- package/dist/esm/dialect/postgres/postgres-driver.d.ts +1 -1
- package/dist/esm/dialect/postgres/postgres-driver.js +12 -2
- 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.js +1 -0
- package/dist/esm/dialect/sqlite/sqlite-dialect-config.d.ts +43 -0
- package/dist/esm/dialect/sqlite/sqlite-dialect-config.js +2 -0
- package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +1 -43
- package/dist/esm/dialect/sqlite/sqlite-dialect.js +1 -0
- package/dist/esm/dialect/sqlite/sqlite-driver.d.ts +1 -1
- package/dist/esm/dialect/sqlite/sqlite-driver.js +11 -2
- 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/dummy-driver.d.ts +40 -0
- package/dist/esm/driver/dummy-driver.js +31 -0
- package/dist/esm/driver/runtime-driver.d.ts +1 -1
- package/dist/esm/driver/runtime-driver.js +30 -32
- 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.d.ts +1 -0
- package/dist/esm/index-nodeless.js +2 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/kysely.js +1 -0
- package/dist/esm/migration/file-migration-provider.js +1 -0
- package/dist/esm/migration/migrator.d.ts +2 -2
- package/dist/esm/migration/migrator.js +1 -0
- 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.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.d.ts +2 -3
- 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.d.ts +3 -4
- 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.d.ts +1 -0
- package/dist/esm/parser/complex-expression-parser.js +4 -0
- package/dist/esm/parser/data-type-parser.js +1 -0
- package/dist/esm/parser/default-value-parser.d.ts +2 -3
- package/dist/esm/parser/default-value-parser.js +3 -2
- 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 +6 -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.d.ts +2 -3
- package/dist/esm/parser/reference-parser.js +2 -1
- 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.d.ts +2 -3
- package/dist/esm/parser/value-parser.js +9 -9
- package/dist/esm/parser/with-parser.js +1 -0
- package/dist/esm/plugin/camel-case/camel-case-plugin.js +1 -0
- 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.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.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.js +1 -0
- 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.d.ts +1 -2
- 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.d.ts +30 -4
- package/dist/esm/schema/alter-table-builder.js +3 -5
- package/dist/esm/schema/column-definition-builder.d.ts +27 -2
- 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/log.d.ts +1 -0
- package/dist/esm/util/log.js +4 -0
- package/dist/esm/util/object-utils.d.ts +4 -5
- package/dist/esm/util/object-utils.js +3 -9
- 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 +11 -6
- package/.prettierignore +0 -1
- package/dist/cjs/util/dynamic-import.d.ts +0 -2
- package/dist/cjs/util/dynamic-import.js +0 -32
- package/dist/esm/util/dynamic-import.d.ts +0 -2
- package/dist/esm/util/dynamic-import.js +0 -27
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OperationNodeSource } from '../operation-node/operation-node-source.js';
|
|
2
2
|
import { OnModifyForeignAction } from '../operation-node/references-node.js';
|
|
3
|
-
import { PrimitiveValue } from '../util/object-utils.js';
|
|
4
3
|
import { ColumnDefinitionNode } from '../operation-node/column-definition-node.js';
|
|
5
4
|
import { AnyRawBuilder } from '../util/type-utils.js';
|
|
6
5
|
import { DefaultValueExpression } from '../parser/default-value-parser.js';
|
|
@@ -83,8 +82,21 @@ export interface ColumnDefinitionBuilderInterface {
|
|
|
83
82
|
* .addColumn('number_of_legs', 'integer', (col) => col.defaultTo(4))
|
|
84
83
|
* .execute()
|
|
85
84
|
* ```
|
|
85
|
+
*
|
|
86
|
+
* Raw expressions are also supported:
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* db.schema
|
|
90
|
+
* .createTable('pet')
|
|
91
|
+
* .addColumn(
|
|
92
|
+
* 'number_of_legs',
|
|
93
|
+
* 'integer',
|
|
94
|
+
* (col) => col.defaultTo(db.raw('any SQL here'))
|
|
95
|
+
* )
|
|
96
|
+
* .execute()
|
|
97
|
+
* ```
|
|
86
98
|
*/
|
|
87
|
-
defaultTo(value:
|
|
99
|
+
defaultTo(value: DefaultValueExpression): ColumnDefinitionBuilderInterface;
|
|
88
100
|
/**
|
|
89
101
|
* Adds a check constraint for the column.
|
|
90
102
|
*
|
|
@@ -222,6 +234,19 @@ export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderI
|
|
|
222
234
|
* .addColumn('number_of_legs', 'integer', (col) => col.defaultTo(4))
|
|
223
235
|
* .execute()
|
|
224
236
|
* ```
|
|
237
|
+
*
|
|
238
|
+
* Raw expressions are also supported:
|
|
239
|
+
*
|
|
240
|
+
* ```ts
|
|
241
|
+
* db.schema
|
|
242
|
+
* .createTable('pet')
|
|
243
|
+
* .addColumn(
|
|
244
|
+
* 'number_of_legs',
|
|
245
|
+
* 'integer',
|
|
246
|
+
* (col) => col.defaultTo(db.raw('any SQL here'))
|
|
247
|
+
* )
|
|
248
|
+
* .execute()
|
|
249
|
+
* ```
|
|
225
250
|
*/
|
|
226
251
|
defaultTo(value: DefaultValueExpression): ColumnDefinitionBuilder;
|
|
227
252
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="./column-definition-builder.d.ts" />
|
|
1
2
|
import { CheckConstraintNode } from '../operation-node/check-constraint-node.js';
|
|
2
3
|
import { ReferenceNode } from '../operation-node/reference-node.js';
|
|
3
4
|
import { ReferencesNode, } from '../operation-node/references-node.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="./create-table-builder.d.ts" />
|
|
1
2
|
import { ColumnDefinitionNode } from '../operation-node/column-definition-node.js';
|
|
2
3
|
import { CreateTableNode, } from '../operation-node/create-table-node.js';
|
|
3
4
|
import { preventAwait } from '../util/prevent-await.js';
|
package/dist/esm/util/assert.js
CHANGED
package/dist/esm/util/log.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare type LogConfig = ReadonlyArray<LogLevel> | Logger;
|
|
|
17
17
|
export declare class Log {
|
|
18
18
|
#private;
|
|
19
19
|
constructor(config: LogConfig);
|
|
20
|
+
isLevelEnabled(level: LogLevel): boolean;
|
|
20
21
|
query(getEvent: () => QueryLogEvent): void;
|
|
21
22
|
error(getEvent: () => ErrorLogEvent): void;
|
|
22
23
|
}
|
package/dist/esm/util/log.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="./log.d.ts" />
|
|
1
2
|
import { freeze, isFunction } from './object-utils.js';
|
|
2
3
|
export const LOG_LEVELS = freeze(['query', 'error']);
|
|
3
4
|
export class Log {
|
|
@@ -19,6 +20,9 @@ export class Log {
|
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
}
|
|
23
|
+
isLevelEnabled(level) {
|
|
24
|
+
return this.#levels[level];
|
|
25
|
+
}
|
|
22
26
|
query(getEvent) {
|
|
23
27
|
if (this.#levels.query) {
|
|
24
28
|
this.#logger(getEvent());
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type PrimitiveValue = string | number | boolean | null | Date | Buffer | BigInt;
|
|
3
|
-
export declare function isEmpty(obj: ArrayLike<unknown> | string | object | Buffer): boolean;
|
|
1
|
+
export declare function isEmpty(obj: ArrayLike<unknown> | string | object): boolean;
|
|
4
2
|
export declare function isString(obj: unknown): obj is string;
|
|
5
3
|
export declare function isNumber(obj: unknown): obj is number;
|
|
6
4
|
export declare function isBoolean(obj: unknown): obj is boolean;
|
|
7
5
|
export declare function isNull(obj: unknown): obj is null;
|
|
8
6
|
export declare function isDate(obj: unknown): obj is Date;
|
|
9
7
|
export declare function isBigInt(obj: unknown): obj is BigInt;
|
|
10
|
-
export declare function isBuffer(obj: unknown): obj is
|
|
11
|
-
|
|
8
|
+
export declare function isBuffer(obj: unknown): obj is {
|
|
9
|
+
length: number;
|
|
10
|
+
};
|
|
12
11
|
export declare function isFunction(obj: unknown): obj is Function;
|
|
13
12
|
export declare function isObject(obj: unknown): obj is Record<string, unknown>;
|
|
14
13
|
export declare function getLast<T>(arr: ArrayLike<T>): T | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="./object-utils.d.ts" />
|
|
1
2
|
export function isEmpty(obj) {
|
|
2
3
|
if (Array.isArray(obj) || isString(obj) || isBuffer(obj)) {
|
|
3
4
|
return obj.length === 0;
|
|
@@ -25,18 +26,11 @@ export function isDate(obj) {
|
|
|
25
26
|
export function isBigInt(obj) {
|
|
26
27
|
return typeof obj === 'bigint';
|
|
27
28
|
}
|
|
29
|
+
// Don't change the returnd type to `obj is Buffer` to not create a
|
|
30
|
+
// hard dependency to node.
|
|
28
31
|
export function isBuffer(obj) {
|
|
29
32
|
return typeof Buffer !== 'undefined' && Buffer.isBuffer(obj);
|
|
30
33
|
}
|
|
31
|
-
export function isPrimitive(obj) {
|
|
32
|
-
return (isString(obj) ||
|
|
33
|
-
isNumber(obj) ||
|
|
34
|
-
isBoolean(obj) ||
|
|
35
|
-
isNull(obj) ||
|
|
36
|
-
isDate(obj) ||
|
|
37
|
-
isBigInt(obj) ||
|
|
38
|
-
isBuffer(obj));
|
|
39
|
-
}
|
|
40
34
|
export function isFunction(obj) {
|
|
41
35
|
return typeof obj === 'function';
|
|
42
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kysely",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.6",
|
|
4
4
|
"description": "Type safe SQL query builder",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,20 +20,23 @@
|
|
|
20
20
|
"./dist/esm/index-nodeless.js": "./dist/esm/index-nodeless.js"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"test": "
|
|
26
|
-
"test:
|
|
23
|
+
"clean": "rm -rf dist && rm -rf test/node/dist && rm -rf test/browser/bundle.js",
|
|
24
|
+
"test": "npm run clean && npm run build:cjs && npm run script:copy-interface-doc && npm run test:node:build && npm run test:node && npm run test:typings && npm run test:esmimports",
|
|
25
|
+
"test:node:build": "rm -rf test/node/dist && tsc -p test/node",
|
|
26
|
+
"test:node": "mocha --timeout 15000 test/node/dist/**/*.test.js",
|
|
27
|
+
"test:browser:build": "rm -rf test/browser/bundle.js && esbuild test/browser/main.ts --bundle --outfile=test/browser/bundle.js",
|
|
28
|
+
"test:browser": "npm run clean && npm run build:esm && npm run test:browser:build && node test/browser/test.js",
|
|
27
29
|
"test:typings": "tsd test/typings",
|
|
28
30
|
"test:esmimports": "node scripts/check-esm-imports.js",
|
|
29
31
|
"prettier": "prettier --write src/**/*.ts test/**/*.ts",
|
|
30
32
|
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run script:module-fixup && npm run script:copy-interface-doc",
|
|
31
|
-
"build:esm": "tsc -p tsconfig.json",
|
|
33
|
+
"build:esm": "tsc -p tsconfig.json && npm run script:add-deno-type-references",
|
|
32
34
|
"build:cjs": "tsc -p tsconfig-cjs.json",
|
|
33
35
|
"docs:build": "typedoc --excludePrivate --excludeInternal --customCss ./docs-theme.css src/index.ts && npm run docs:postprocess",
|
|
34
36
|
"docs:postprocess": "node scripts/post-process-docs.js",
|
|
35
37
|
"script:module-fixup": "node scripts/module-fixup.js",
|
|
36
38
|
"script:copy-interface-doc": "node scripts/copy-interface-documentation.js",
|
|
39
|
+
"script:add-deno-type-references": "node scripts/add-deno-type-references.js",
|
|
37
40
|
"prepublishOnly": "npm run build"
|
|
38
41
|
},
|
|
39
42
|
"author": "Sami Koskimäki <sami@jakso.me>",
|
|
@@ -50,9 +53,11 @@
|
|
|
50
53
|
"better-sqlite3": "^7.4.5",
|
|
51
54
|
"chai": "^4.3.4",
|
|
52
55
|
"chai-subset": "^1.6.0",
|
|
56
|
+
"esbuild": "^0.14.11",
|
|
53
57
|
"mocha": "^9.1.3",
|
|
54
58
|
"mysql2": "^2.3.3",
|
|
55
59
|
"pg": "^8.7.1",
|
|
60
|
+
"playwright": "^1.17.2",
|
|
56
61
|
"prettier": "^2.5.1",
|
|
57
62
|
"tsd": "^0.19.0",
|
|
58
63
|
"typedoc": "^0.22.10",
|
package/.prettierignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*.md
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.importNamedFunction = exports.importFunction = void 0;
|
|
4
|
-
const object_utils_js_1 = require("./object-utils.js");
|
|
5
|
-
async function importFunction(modulePath) {
|
|
6
|
-
const module = await Promise.resolve().then(() => require(modulePath));
|
|
7
|
-
const errorMessage = `module "${modulePath}" doesn't export a function`;
|
|
8
|
-
if ((0, object_utils_js_1.isFunction)(module)) {
|
|
9
|
-
return module;
|
|
10
|
-
}
|
|
11
|
-
else if ((0, object_utils_js_1.isObject)(module) && (0, object_utils_js_1.isFunction)(module.default)) {
|
|
12
|
-
return module.default;
|
|
13
|
-
}
|
|
14
|
-
throw new Error(errorMessage);
|
|
15
|
-
}
|
|
16
|
-
exports.importFunction = importFunction;
|
|
17
|
-
async function importNamedFunction(modulePath, exportName) {
|
|
18
|
-
const module = await Promise.resolve().then(() => require(modulePath));
|
|
19
|
-
const errorMessage = `no function export named "${exportName}" found in module "${modulePath}"`;
|
|
20
|
-
if (!(0, object_utils_js_1.isObject)(module)) {
|
|
21
|
-
throw new Error(errorMessage);
|
|
22
|
-
}
|
|
23
|
-
if ((0, object_utils_js_1.isFunction)(module[exportName])) {
|
|
24
|
-
return module[exportName];
|
|
25
|
-
}
|
|
26
|
-
else if ((0, object_utils_js_1.isObject)(module.default) &&
|
|
27
|
-
(0, object_utils_js_1.isFunction)(module.default[exportName])) {
|
|
28
|
-
return module.default[exportName];
|
|
29
|
-
}
|
|
30
|
-
throw new Error(errorMessage);
|
|
31
|
-
}
|
|
32
|
-
exports.importNamedFunction = importNamedFunction;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isFunction, isObject } from './object-utils.js';
|
|
2
|
-
export async function importFunction(modulePath) {
|
|
3
|
-
const module = await import(modulePath);
|
|
4
|
-
const errorMessage = `module "${modulePath}" doesn't export a function`;
|
|
5
|
-
if (isFunction(module)) {
|
|
6
|
-
return module;
|
|
7
|
-
}
|
|
8
|
-
else if (isObject(module) && isFunction(module.default)) {
|
|
9
|
-
return module.default;
|
|
10
|
-
}
|
|
11
|
-
throw new Error(errorMessage);
|
|
12
|
-
}
|
|
13
|
-
export async function importNamedFunction(modulePath, exportName) {
|
|
14
|
-
const module = await import(modulePath);
|
|
15
|
-
const errorMessage = `no function export named "${exportName}" found in module "${modulePath}"`;
|
|
16
|
-
if (!isObject(module)) {
|
|
17
|
-
throw new Error(errorMessage);
|
|
18
|
-
}
|
|
19
|
-
if (isFunction(module[exportName])) {
|
|
20
|
-
return module[exportName];
|
|
21
|
-
}
|
|
22
|
-
else if (isObject(module.default) &&
|
|
23
|
-
isFunction(module.default[exportName])) {
|
|
24
|
-
return module.default[exportName];
|
|
25
|
-
}
|
|
26
|
-
throw new Error(errorMessage);
|
|
27
|
-
}
|