[bookshelf] Update knex dependency (#43581)

* node_modules/knex/types/index.d.ts requires TypeScript 3.4

* Update knex dependency

* Switch to strict: true

* Fix error "Property 'model' has no initializer and is not definitely assigned in the constructor."

* Update Model-instance-related example

* Tests fail with TypeScript 3.5 :-/

* Rename/remove certain lodash functions from Bookshelf v0.10.0

See https://github.com/bookshelf/bookshelf/blob/1.1.1/CHANGELOG.md#breaking-changes-4
This commit is contained in:
Tanguy Krotoff 2020-04-11 01:49:21 +02:00 committed by GitHub
parent 4a4fbabbcb
commit 42101fa4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 104 deletions

View File

@ -701,17 +701,15 @@ qb.where({id: 1}).select().then(resp => {
/* model.refresh(), see http://bookshelfjs.org/#Model-instance-refresh */
/* model.related(), see http://bookshelfjs.org/#Model-instance-related */
/* model.related(), see https://bookshelfjs.org/api.html#Model-instance-related */
class Trip extends bookshelf.Model<Trip> {}
class Trips extends bookshelf.Collection<Trip> {}
new Photo({id: 1}).fetch({
withRelated: ['account']
}).then(photo => {
if (photo) {
var account = <Account> photo.related('account');
if (account.id) {
return (<Trips> account.related('trips')).fetch();
}
var account = photo.related('account') as Account;
if (account.id) {
return (account.related('trips') as Trips).fetch();
}
});
@ -974,10 +972,12 @@ let tabs = new TabSet([tab1, tab2, tab3]);
/* Collection.extend(), see http://bookshelfjs.org/#Collection-static-extend */
/* Collection.forge(), see http://bookshelfjs.org/#Collection-static-forge */
/* Collection.forge(), see https://bookshelfjs.org/api.html#Collection-static-forge */
class Accounts extends bookshelf.Collection<Account> {
model: Account
get model() {
return Account
}
}
var accounts = Accounts.forge<Accounts>([
@ -985,7 +985,7 @@ var accounts = Accounts.forge<Accounts>([
{name: 'Person2'}
]);
Promise.all(accounts.invoke('save')).then(() => {
Promise.all(accounts.invokeMap('save')).then(() => {
// collection models should now be saved...
});
@ -1219,63 +1219,26 @@ ships.trigger('fetched');
}
}
/* Lodash methods, see http://bookshelfjs.org/#Collection-subsection-lodash-methods */
/* Lodash methods, see https://bookshelfjs.org/api.html#Collection-subsection-lodash-methods */
/* all(), see http://lodash.com/docs/#all */
/* any(), see http://lodash.com/docs/#any */
/* chain(), see http://lodash.com/docs/#chain */
/* collect(), see http://lodash.com/docs/#collect */
/* contains(), see http://lodash.com/docs/#contains */
/* countBy(), see http://lodash.com/docs/#countBy */
/* detect(), see http://lodash.com/docs/#detect */
/* difference(), see http://lodash.com/docs/#difference */
/* drop(), see http://lodash.com/docs/#drop */
/* each(), see http://lodash.com/docs/#each */
/* every(), see http://lodash.com/docs/#every */
/* filter(), see http://lodash.com/docs/#filter */
/* find(), see http://lodash.com/docs/#find */
/* first(), see http://lodash.com/docs/#first */
/* foldl(), see http://lodash.com/docs/#foldl */
/* foldr(), see http://lodash.com/docs/#foldr */
/* forEach(), see http://lodash.com/docs/#forEach */
/* groupBy(), see http://lodash.com/docs/#groupBy */
/* head(), see http://lodash.com/docs/#head */
/* include(), see http://lodash.com/docs/#include */
/* indexOf(), see http://lodash.com/docs/#indexOf */
/* initial(), see http://lodash.com/docs/#initial */
/* inject(), see http://lodash.com/docs/#inject */
/* invoke(), see http://lodash.com/docs/#invoke */
/* isEmpty(), see http://lodash.com/docs/#isEmpty */
/* last(), see http://lodash.com/docs/#last */
/* lastIndexOf(), see http://lodash.com/docs/#lastIndexOf */
/* map(), see http://lodash.com/docs/#map */
/*
- countBy()
- every()
- filter()
- find()
- forEach()
- groupBy()
- includes()
- invokeMap()
- isEmpty()
- map()
- reduce()
- reduceRight()
- reject()
- some()
- sortBy()
- toArray()
*/
// TODO No example provided on Bookshelf website

View File

@ -1,10 +1,10 @@
// Type definitions for bookshelfjs v1.0.1
// Type definitions for bookshelfjs v1.1.1
// Project: http://bookshelfjs.org/
// Definitions by: Andrew Schurman <https://github.com/arcticwaters>
// Vesa Poikajärvi <https://github.com/vesse>
// Ian Serpa <http://github.com/ianldgs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.2
// Minimum TypeScript Version: 3.6
import Knex = require('knex');
import knex = require('knex');
@ -214,32 +214,12 @@ declare namespace Bookshelf {
where(match: { [key: string]: any }, firstOnly: boolean): T | Collection<T>;
// lodash methods
all(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,
): boolean;
all<R extends {}>(predicate?: R): boolean;
any(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,
): boolean;
any<R extends {}>(predicate?: R): boolean;
collect(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,
): T[];
collect<R extends {}>(predicate?: R): T[];
contains(value: any, fromIndex?: number): boolean;
includes(value: any, fromIndex?: number): boolean;
countBy(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,
): Lodash.Dictionary<number>;
countBy<R extends {}>(predicate?: R): Lodash.Dictionary<number>;
detect(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,
): T;
detect<R extends {}>(predicate?: R): T;
every(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,
@ -256,8 +236,6 @@ declare namespace Bookshelf {
): T;
find<R extends {}>(predicate?: R): T;
first(): T;
foldl<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
foldr<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
forEach(callback?: Lodash.ListIterator<T, void>, thisArg?: any): Lodash.List<T>;
forEach(callback?: Lodash.DictionaryIterator<T, void>, thisArg?: any): Lodash.Dictionary<T>;
forEach(callback?: Lodash.ObjectIterator<T, void>, thisArg?: any): T;
@ -266,9 +244,7 @@ declare namespace Bookshelf {
thisArg?: any,
): Lodash.Dictionary<T[]>;
groupBy<R extends {}>(predicate?: R): Lodash.Dictionary<T[]>;
include(value: any, fromIndex?: number): boolean;
inject<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
invoke(methodName: string | Function, ...args: any[]): any;
invokeMap(methodName: string | Function, ...args: any[]): any;
isEmpty(): boolean;
keys(): string[];
last(): T;
@ -286,12 +262,7 @@ declare namespace Bookshelf {
thisArg?: any,
): T[];
reject<R extends {}>(predicate?: R): T[];
rest(): T[];
select(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,
): T[];
select<R extends {}>(predicate?: R): T[];
tail(): T[];
some(
predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string,
thisArg?: any,

View File

@ -1,6 +1,6 @@
{
"private": true,
"dependencies": {
"knex": "^0.17.0"
"knex": "^0.20.13"
}
}

View File

@ -5,10 +5,7 @@
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"strict": true,
"baseUrl": "../",
"typeRoots": [
"../"