knex 2.5.1 → 3.0.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 (30) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/LICENSE +22 -22
  3. package/lib/dialects/oracledb/index.js +1 -1
  4. package/lib/migrations/migrate/Migrator.js +1 -0
  5. package/lib/migrations/migrate/stub/cjs.stub +15 -15
  6. package/lib/migrations/migrate/stub/coffee.stub +13 -13
  7. package/lib/migrations/migrate/stub/eg.stub +14 -14
  8. package/lib/migrations/migrate/stub/js-schema.stub +22 -22
  9. package/lib/migrations/migrate/stub/js.stub +22 -22
  10. package/lib/migrations/migrate/stub/knexfile-coffee.stub +34 -34
  11. package/lib/migrations/migrate/stub/knexfile-eg.stub +43 -43
  12. package/lib/migrations/migrate/stub/knexfile-js.stub +47 -47
  13. package/lib/migrations/migrate/stub/knexfile-ls.stub +35 -35
  14. package/lib/migrations/migrate/stub/knexfile-ts.stub +47 -47
  15. package/lib/migrations/migrate/stub/ls.stub +14 -14
  16. package/lib/migrations/migrate/stub/mjs.stub +23 -23
  17. package/lib/migrations/migrate/stub/ts-schema.stub +21 -21
  18. package/lib/migrations/migrate/stub/ts.stub +21 -21
  19. package/lib/migrations/seed/stub/coffee.stub +9 -9
  20. package/lib/migrations/seed/stub/eg.stub +11 -11
  21. package/lib/migrations/seed/stub/js.stub +13 -13
  22. package/lib/migrations/seed/stub/ls.stub +11 -11
  23. package/lib/migrations/seed/stub/mjs.stub +12 -12
  24. package/lib/migrations/seed/stub/ts.stub +13 -13
  25. package/package.json +5 -5
  26. package/scripts/oracledb-install-driver-libs.sh +82 -82
  27. package/scripts/release.sh +36 -36
  28. package/scripts/stress-test/README.txt +18 -18
  29. package/types/index.d.ts +13 -15
  30. package/lib/dialects/index.js +0 -34
@@ -1,36 +1,36 @@
1
- #!/bin/bash -e
2
-
3
- changelog=node_modules/.bin/changelog
4
-
5
- update_version() {
6
- echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1
7
- echo "Updated ${1} version to ${2}"
8
- }
9
-
10
- current_version=$(node -p "require('./package').version")
11
-
12
- printf "Next version (current is $current_version)? "
13
- read next_version
14
-
15
- if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then
16
- echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1"
17
- exit 1
18
- fi
19
-
20
- next_ref="v$next_version"
21
-
22
- git add -u
23
-
24
- npm run build
25
- npm run format:check
26
- npm run lint:everything
27
- npm test
28
-
29
- update_version 'package.json' $next_version
30
-
31
- git commit -am "release $next_version"
32
- git tag $next_version
33
-
34
- git push --tags
35
-
36
- npm publish
1
+ #!/bin/bash -e
2
+
3
+ changelog=node_modules/.bin/changelog
4
+
5
+ update_version() {
6
+ echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1
7
+ echo "Updated ${1} version to ${2}"
8
+ }
9
+
10
+ current_version=$(node -p "require('./package').version")
11
+
12
+ printf "Next version (current is $current_version)? "
13
+ read next_version
14
+
15
+ if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then
16
+ echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1"
17
+ exit 1
18
+ fi
19
+
20
+ next_ref="v$next_version"
21
+
22
+ git add -u
23
+
24
+ npm run build
25
+ npm run format:check
26
+ npm run lint:everything
27
+ npm test
28
+
29
+ update_version 'package.json' $next_version
30
+
31
+ git commit -am "release $next_version"
32
+ git tag $next_version
33
+
34
+ git push --tags
35
+
36
+ npm publish
@@ -1,18 +1,18 @@
1
- # Test scripts to evaluate stability of drivers / pool etc.
2
-
3
- # To run this test you need to be in this directory + have node >= 8
4
- # and startup docker containers with proxy and sql servers
5
-
6
- docker-compose up --no-start
7
- docker-compose start
8
-
9
- # Select different test script to run:
10
-
11
- node mysql2-random-hanging-every-now-and-then.js 2> /dev/null | grep -B500 -A2 -- "- STATS"
12
- node mysql2-sudden-exit-without-error
13
- node knex-stress-test.js | grep -A 3 -- "- STATS "
14
- node reconnect-test-mysql-based-drivers.js 2> /dev/null | grep -A 3 -- "- STATS "
15
-
16
- # Shut down docker instances when done:
17
-
18
- docker-compose down
1
+ # Test scripts to evaluate stability of drivers / pool etc.
2
+
3
+ # To run this test you need to be in this directory + have node >= 8
4
+ # and startup docker containers with proxy and sql servers
5
+
6
+ docker-compose up --no-start
7
+ docker-compose start
8
+
9
+ # Select different test script to run:
10
+
11
+ node mysql2-random-hanging-every-now-and-then.js 2> /dev/null | grep -B500 -A2 -- "- STATS"
12
+ node mysql2-sudden-exit-without-error
13
+ node knex-stress-test.js | grep -A 3 -- "- STATS "
14
+ node reconnect-test-mysql-based-drivers.js 2> /dev/null | grep -A 3 -- "- STATS "
15
+
16
+ # Shut down docker instances when done:
17
+
18
+ docker-compose down
package/types/index.d.ts CHANGED
@@ -13,8 +13,8 @@ import ResultTypes = require('./result');
13
13
 
14
14
  import { Tables } from './tables';
15
15
 
16
- import { ConnectionOptions } from 'tls';
17
16
  import { Stream } from 'stream';
17
+ import { ConnectionOptions } from 'tls';
18
18
 
19
19
  // # Generic type-level utilities
20
20
 
@@ -374,7 +374,7 @@ interface DMLOptions {
374
374
  includeTriggerModifications?: boolean;
375
375
  }
376
376
 
377
- export interface Knex<TRecord extends {} = any, TResult = any[]>
377
+ interface Knex<TRecord extends {} = any, TResult = any[]>
378
378
  extends Knex.QueryInterface<TRecord, TResult>,
379
379
  events.EventEmitter {
380
380
  <TTable extends Knex.TableNames>(
@@ -436,12 +436,13 @@ export interface Knex<TRecord extends {} = any, TResult = any[]>
436
436
  isTransaction?: boolean;
437
437
  }
438
438
 
439
- export declare function knex<TRecord extends {} = any, TResult = unknown[]>(
439
+ declare function knex<TRecord extends {} = any, TResult = unknown[]>(
440
440
  config: Knex.Config | string
441
441
  ): Knex<TRecord, TResult>;
442
442
 
443
- export declare namespace knex {
444
- class QueryBuilder {
443
+ declare namespace knex {
444
+ export { knex, knex as default, Knex };
445
+ export class QueryBuilder {
445
446
  static extend(
446
447
  methodName: string,
447
448
  fn: <TRecord extends {} = any, TResult extends {} = unknown[]>(
@@ -456,25 +457,25 @@ export declare namespace knex {
456
457
  ): void;
457
458
  }
458
459
 
459
- class TableBuilder {
460
+ export class TableBuilder {
460
461
  static extend<T = Knex.TableBuilder, B = Knex.TableBuilder>(
461
462
  methodName: string,
462
463
  fn: (this: T, ...args: any[]) => B
463
464
  ): void;
464
465
  }
465
- class ViewBuilder {
466
+ export class ViewBuilder {
466
467
  static extend<T = Knex.ViewBuilder, B = Knex.ViewBuilder>(
467
468
  methodName: string,
468
469
  fn: (this: T, ...args: any[]) => B
469
470
  ): void;
470
471
  }
471
- class SchemaBuilder {
472
+ export class SchemaBuilder {
472
473
  static extend<T = Knex.SchemaBuilder, B = Knex.SchemaBuilder>(
473
474
  methodName: string,
474
475
  fn: (this: T, ...args: any[]) => B
475
476
  ): void;
476
477
  }
477
- class ColumnBuilder {
478
+ export class ColumnBuilder {
478
479
  static extend<T = Knex.ColumnBuilder, B = Knex.ColumnBuilder>(
479
480
  methodName: string,
480
481
  fn: (this: T, ...args: any[]) => B
@@ -486,7 +487,7 @@ export declare namespace knex {
486
487
  export const Client: typeof Knex.Client;
487
488
  }
488
489
 
489
- export declare namespace Knex {
490
+ declare namespace Knex {
490
491
  //
491
492
  // Utility Types
492
493
  //
@@ -2116,10 +2117,7 @@ export declare namespace Knex {
2116
2117
 
2117
2118
  interface RawBuilder<TRecord extends {} = any, TResult = any> {
2118
2119
  <TResult2 = TResult>(value: Value): Raw<TResult2>;
2119
- <TResult2 = TResult>(
2120
- sql: string,
2121
- ...bindings: readonly RawBinding[]
2122
- ): Raw<TResult2>;
2120
+ <TResult2 = TResult>(sql: string, binding: RawBinding): Raw<TResult2>;
2123
2121
  <TResult2 = TResult>(
2124
2122
  sql: string,
2125
2123
  bindings: readonly RawBinding[] | ValueDict
@@ -3271,4 +3269,4 @@ export declare namespace Knex {
3271
3269
  }
3272
3270
  }
3273
3271
 
3274
- export default knex;
3272
+ export = knex;
@@ -1,34 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.getDialectByNameOrAlias = void 0;
4
- const { resolveClientNameWithAliases } = require('../util/helpers');
5
- const dbNameToDialectLoader = Object.freeze({
6
- 'better-sqlite3': () => require('./better-sqlite3'),
7
- cockroachdb: () => require('./cockroachdb'),
8
- mssql: () => require('./mssql'),
9
- mysql: () => require('./mysql'),
10
- mysql2: () => require('./mysql2'),
11
- oracle: () => require('./oracle'),
12
- oracledb: () => require('./oracledb'),
13
- pgnative: () => require('./pgnative'),
14
- postgres: () => require('./postgres'),
15
- redshift: () => require('./redshift'),
16
- sqlite3: () => require('./sqlite3'),
17
- });
18
- /**
19
- * Gets the Dialect object with the given client name or throw an
20
- * error if not found.
21
- *
22
- * NOTE: This is a replacement for prior practice of doing dynamic
23
- * string construction for imports of Dialect objects.
24
- */
25
- function getDialectByNameOrAlias(clientName) {
26
- const resolvedClientName = resolveClientNameWithAliases(clientName);
27
- const dialectLoader = dbNameToDialectLoader[resolvedClientName];
28
- if (!dialectLoader) {
29
- throw new Error(`Invalid clientName given: ${clientName}`);
30
- }
31
- return dialectLoader();
32
- }
33
- exports.getDialectByNameOrAlias = getDialectByNameOrAlias;
34
- //# sourceMappingURL=index.js.map