mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
Remove trailing spaces
Trailing spaces make it hard to contribute
This commit is contained in:
@@ -97,4 +97,3 @@ class Photo extends bookshelf.Model<Photo> {
|
||||
return this.morphTo('imageable', Site, Post);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+33
-33
@@ -11,7 +11,7 @@ declare module 'bookshelf' {
|
||||
import knex = require('knex');
|
||||
import Promise = require('bluebird');
|
||||
import Lodash = require('lodash');
|
||||
|
||||
|
||||
interface Bookshelf extends Bookshelf.Events<any> {
|
||||
VERSION : string;
|
||||
knex : knex;
|
||||
@@ -20,9 +20,9 @@ declare module 'bookshelf' {
|
||||
|
||||
transaction<T>(callback : (transaction : knex.Transaction) => T) : Promise<T>;
|
||||
}
|
||||
|
||||
|
||||
function Bookshelf(knex : knex) : Bookshelf;
|
||||
|
||||
|
||||
namespace Bookshelf {
|
||||
abstract class Events<T> {
|
||||
on(event? : string, callback? : EventFunction<T>, context? : any) : void;
|
||||
@@ -31,20 +31,20 @@ declare module 'bookshelf' {
|
||||
triggerThen(name : string, ...args : any[]) : Promise<any>;
|
||||
once(event : string, callback : EventFunction<T>, context? : any) : void;
|
||||
}
|
||||
|
||||
|
||||
interface IModelBase {
|
||||
/** Should be declared as a getter instead of a plain property. */
|
||||
hasTimestamps? : boolean|string[];
|
||||
/** Should be declared as a getter instead of a plain property. Should be required, but cannot have abstract properties yet. */
|
||||
tableName? : string;
|
||||
}
|
||||
|
||||
|
||||
abstract class ModelBase<T extends Model<any>> extends Events<T|Collection<T>> implements IModelBase {
|
||||
/** If overriding, must use a getter instead of a plain property. */
|
||||
idAttribute : string;
|
||||
|
||||
|
||||
constructor(attributes? : any, options? : ModelOptions);
|
||||
|
||||
|
||||
clear() : T;
|
||||
clone() : T;
|
||||
escape(attribute : string) : string;
|
||||
@@ -63,7 +63,7 @@ declare module 'bookshelf' {
|
||||
timestamp(options? : TimestampOptions) : any;
|
||||
toJSON(options? : SerializeOptions) : any;
|
||||
unset(attribute : string) : T;
|
||||
|
||||
|
||||
// lodash methods
|
||||
invert<R extends {}>() : R;
|
||||
keys() : string[];
|
||||
@@ -74,7 +74,7 @@ declare module 'bookshelf' {
|
||||
pick<R extends {}>(...attributes : string[]) : R;
|
||||
values() : any[];
|
||||
}
|
||||
|
||||
|
||||
class Model<T extends Model<any>> extends ModelBase<T> {
|
||||
static collection<T extends Model<any>>(models? : T[], options? : CollectionOptions<T>) : Collection<T>;
|
||||
static count(column? : string, options? : SyncOptions) : Promise<number>;
|
||||
@@ -83,7 +83,7 @@ declare module 'bookshelf' {
|
||||
static fetchAll<T extends Model<any>>() : Promise<Collection<T>>;
|
||||
/** @deprecated should use `new` objects instead. */
|
||||
static forge<T>(attributes? : any, options? : ModelOptions) : T;
|
||||
|
||||
|
||||
belongsTo<R extends Model<any>>(target : {new(...args : any[]) : R}, foreignKey? : string) : R;
|
||||
belongsToMany<R extends Model<any>>(target : {new(...args : any[]) : R}, table? : string, foreignKey? : string, otherKey? : string) : Collection<R>;
|
||||
count(column? : string, options? : SyncOptions) : Promise<number>;
|
||||
@@ -109,7 +109,7 @@ declare module 'bookshelf' {
|
||||
where(properties : {[key : string] : any}) : T;
|
||||
where(key : string, operatorOrValue : string|number|boolean, valueIfOperator? : string|number|boolean) : T;
|
||||
}
|
||||
|
||||
|
||||
abstract class CollectionBase<T extends Model<any>> extends Events<T> {
|
||||
add(models : T[]|{[key : string] : any}[], options? : CollectionAddOptions) : Collection<T>;
|
||||
at(index : number) : T;
|
||||
@@ -133,7 +133,7 @@ declare module 'bookshelf' {
|
||||
toJSON(options? : SerializeOptions) : any;
|
||||
unshift(model : any, options? : CollectionAddOptions) : void;
|
||||
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;
|
||||
@@ -200,13 +200,13 @@ declare module 'bookshelf' {
|
||||
toArray() : T[];
|
||||
without(...values : any[]) : T[];
|
||||
}
|
||||
|
||||
|
||||
class Collection<T extends Model<any>> extends CollectionBase<T> {
|
||||
/** @deprecated use Typescript classes */
|
||||
static extend<T>(prototypeProperties? : any, classProperties? : any) : Function;
|
||||
/** @deprecated should use `new` objects instead. */
|
||||
static forge<T>(attributes? : any, options? : ModelOptions) : T;
|
||||
|
||||
|
||||
attach(ids : any[], options? : SyncOptions) : Promise<Collection<T>>;
|
||||
count(column? : string, options? : SyncOptions) : Promise<number>;
|
||||
create(model : {[key : string] : any}, options? : CollectionCreateOptions) : Promise<T>;
|
||||
@@ -222,92 +222,92 @@ declare module 'bookshelf' {
|
||||
updatePivot(attributes : any, options? : PivotOptions) : Promise<number>;
|
||||
withPivot(columns : string[]) : Collection<T>;
|
||||
}
|
||||
|
||||
|
||||
interface ModelOptions {
|
||||
tableName? : string;
|
||||
hasTimestamps? : boolean;
|
||||
parse? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface LoadOptions extends SyncOptions {
|
||||
withRelated: string|any|any[];
|
||||
}
|
||||
|
||||
|
||||
interface FetchOptions extends SyncOptions {
|
||||
require? : boolean;
|
||||
columns? : string|string[];
|
||||
withRelated? : string|any|any[];
|
||||
}
|
||||
|
||||
|
||||
interface FetchAllOptions extends SyncOptions {
|
||||
require? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface SaveOptions extends SyncOptions {
|
||||
method? : string;
|
||||
defaults? : string;
|
||||
patch? : boolean;
|
||||
require? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface SerializeOptions {
|
||||
shallow? : boolean;
|
||||
omitPivot? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface SetOptions {
|
||||
unset? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface TimestampOptions {
|
||||
method? : string;
|
||||
}
|
||||
|
||||
|
||||
interface SyncOptions {
|
||||
transacting? : knex.Transaction;
|
||||
debug? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface CollectionOptions<T> {
|
||||
comparator? : boolean|string|((a : T, b : T) => number);
|
||||
}
|
||||
|
||||
|
||||
interface CollectionAddOptions extends EventOptions {
|
||||
at? : number;
|
||||
merge? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface CollectionFetchOptions {
|
||||
require? : boolean;
|
||||
withRelated? : string|string[];
|
||||
}
|
||||
|
||||
|
||||
interface CollectionFetchOneOptions {
|
||||
require? : boolean;
|
||||
columns? : string|string[];
|
||||
}
|
||||
|
||||
|
||||
interface CollectionSetOptions extends EventOptions {
|
||||
add? : boolean;
|
||||
remove? : boolean;
|
||||
merge?: boolean;
|
||||
}
|
||||
|
||||
|
||||
interface PivotOptions {
|
||||
query? : Function|any;
|
||||
require? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface EventOptions {
|
||||
silent? : boolean;
|
||||
}
|
||||
|
||||
|
||||
interface EventFunction<T> {
|
||||
(model: T, attrs: any, options: any) : Promise<any>|void;
|
||||
}
|
||||
|
||||
|
||||
interface CollectionCreateOptions extends ModelOptions, SyncOptions, CollectionAddOptions, SaveOptions {}
|
||||
}
|
||||
|
||||
|
||||
export = Bookshelf;
|
||||
}
|
||||
|
||||
Vendored
+70
-70
@@ -39,7 +39,7 @@ declare module "knex" {
|
||||
//
|
||||
// QueryInterface
|
||||
//
|
||||
|
||||
|
||||
interface QueryInterface {
|
||||
select: Select;
|
||||
as: As;
|
||||
@@ -49,7 +49,7 @@ declare module "knex" {
|
||||
into: Table;
|
||||
table: Table;
|
||||
distinct: Distinct;
|
||||
|
||||
|
||||
// Joins
|
||||
join: Join;
|
||||
joinRaw: JoinRaw;
|
||||
@@ -61,7 +61,7 @@ declare module "knex" {
|
||||
outerJoin: Join;
|
||||
fullOuterJoin: Join;
|
||||
crossJoin: Join;
|
||||
|
||||
|
||||
// Wheres
|
||||
where: Where;
|
||||
andWhere: Where;
|
||||
@@ -86,29 +86,29 @@ declare module "knex" {
|
||||
whereNotBetween: WhereBetween;
|
||||
orWhereBetween: WhereBetween;
|
||||
orWhereNotBetween: WhereBetween;
|
||||
|
||||
|
||||
// Group by
|
||||
groupBy: GroupBy;
|
||||
groupByRaw: RawQueryBuilder;
|
||||
|
||||
|
||||
// Order by
|
||||
orderBy: OrderBy;
|
||||
orderByRaw: RawQueryBuilder;
|
||||
|
||||
|
||||
// Union
|
||||
union: Union;
|
||||
unionAll(callback: Function): QueryBuilder;
|
||||
|
||||
|
||||
// Having
|
||||
having: Having;
|
||||
havingRaw: RawQueryBuilder;
|
||||
orHaving: Having;
|
||||
orHavingRaw: RawQueryBuilder;
|
||||
|
||||
|
||||
// Paging
|
||||
offset(offset: number): QueryBuilder;
|
||||
limit(limit: number): QueryBuilder;
|
||||
|
||||
|
||||
// Aggregation
|
||||
count(columnName?: string): QueryBuilder;
|
||||
min(columnName: string): QueryBuilder;
|
||||
@@ -117,43 +117,43 @@ declare module "knex" {
|
||||
avg(columnName: string): QueryBuilder;
|
||||
increment(columnName: string, amount?: number): QueryBuilder;
|
||||
decrement(columnName: string, amount?: number): QueryBuilder;
|
||||
|
||||
|
||||
// Others
|
||||
first(...columns: string[]): QueryBuilder;
|
||||
|
||||
|
||||
debug(enabled?: boolean): QueryBuilder;
|
||||
pluck(column: string): QueryBuilder;
|
||||
|
||||
|
||||
insert(data: any, returning?: string | string[]): QueryBuilder;
|
||||
update(data: any, returning?: string | string[]): QueryBuilder;
|
||||
update(columnName: string, value: Value, returning?: string | string[]): QueryBuilder;
|
||||
returning(column: string): QueryBuilder;
|
||||
|
||||
|
||||
del(returning?: string | string[]): QueryBuilder;
|
||||
delete(returning?: string | string[]): QueryBuilder;
|
||||
truncate(): QueryBuilder;
|
||||
|
||||
|
||||
transacting(trx: Transaction): QueryBuilder;
|
||||
connection(connection: any): QueryBuilder;
|
||||
|
||||
clone(): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface As {
|
||||
(columnName: string): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface Select extends ColumnNameQueryBuilder {
|
||||
}
|
||||
|
||||
|
||||
interface Table {
|
||||
(tableName: string): QueryBuilder;
|
||||
(callback: Function): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface Distinct extends ColumnNameQueryBuilder {
|
||||
}
|
||||
|
||||
|
||||
interface Join {
|
||||
(raw: Raw): QueryBuilder;
|
||||
(tableName: string, callback: Function): QueryBuilder;
|
||||
@@ -161,126 +161,126 @@ declare module "knex" {
|
||||
(tableName: string, column1: string, raw: Raw): QueryBuilder;
|
||||
(tableName: string, column1: string, operator: string, column2: string): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface JoinRaw {
|
||||
(tableName: string, binding?: Value): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface Where extends WhereRaw, WhereWrapped, WhereNull {
|
||||
(object: Object): QueryBuilder;
|
||||
(columnName: string, value: Value): QueryBuilder;
|
||||
(columnName: string, operator: string, value: Value): QueryBuilder;
|
||||
(columnName: string, operator: string, query: QueryBuilder): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereRaw extends RawQueryBuilder {
|
||||
(condition: boolean): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereWrapped {
|
||||
(callback: Function): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereNull {
|
||||
(columnName: string): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereIn {
|
||||
(columnName: string, values: Value[]): QueryBuilder;
|
||||
(columnName: string, callback: Function): QueryBuilder;
|
||||
(columnName: string, query: QueryBuilder): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereBetween {
|
||||
(columnName: string, range: [Value, Value]): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereExists {
|
||||
(callback: Function): QueryBuilder;
|
||||
(query: QueryBuilder): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereNull {
|
||||
(columnName: string): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface WhereIn {
|
||||
(columnName: string, values: Value[]): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface GroupBy extends RawQueryBuilder, ColumnNameQueryBuilder {
|
||||
}
|
||||
|
||||
|
||||
interface OrderBy {
|
||||
(columnName: string, direction?: string): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface Union {
|
||||
(callback: Function, wrap?: boolean): QueryBuilder;
|
||||
(callbacks: Function[], wrap?: boolean): QueryBuilder;
|
||||
(...callbacks: Function[]): QueryBuilder;
|
||||
// (...callbacks: Function[], wrap?: boolean): QueryInterface;
|
||||
}
|
||||
|
||||
|
||||
interface Having extends RawQueryBuilder, WhereWrapped {
|
||||
(tableName: string, column1: string, operator: string, column2: string): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
// commons
|
||||
|
||||
|
||||
interface ColumnNameQueryBuilder {
|
||||
(...columnNames: ColumnName[]): QueryBuilder;
|
||||
(columnNames: ColumnName[]): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface RawQueryBuilder {
|
||||
(sql: string, ...bindings: Value[]): QueryBuilder;
|
||||
(sql: string, bindings: Value[]): QueryBuilder;
|
||||
(raw: Raw): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
// Raw
|
||||
|
||||
|
||||
interface Raw extends events.EventEmitter, ChainableInterface {
|
||||
wrap(before: string, after: string): Raw;
|
||||
}
|
||||
|
||||
|
||||
interface RawBuilder {
|
||||
(value: Value): Raw;
|
||||
(sql: string, ...bindings: Value[]): Raw;
|
||||
(sql: string, bindings: Value[]): Raw;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// QueryBuilder
|
||||
//
|
||||
|
||||
|
||||
interface QueryBuilder extends QueryInterface, ChainableInterface {
|
||||
or: QueryBuilder;
|
||||
and: QueryBuilder;
|
||||
|
||||
|
||||
//TODO: Promise?
|
||||
columnInfo(column?: string): Promise<ColumnInfo>;
|
||||
|
||||
|
||||
forUpdate(): QueryBuilder;
|
||||
forShare(): QueryBuilder;
|
||||
|
||||
|
||||
toSQL(): Sql;
|
||||
|
||||
|
||||
on(event: string, callback: Function): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface Sql {
|
||||
method: string;
|
||||
options: any;
|
||||
bindings: Value[];
|
||||
sql: string;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Chainable interface
|
||||
//
|
||||
|
||||
|
||||
interface ChainableInterface extends Promise<any> {
|
||||
toQuery(): string;
|
||||
options(options: any): QueryBuilder;
|
||||
@@ -289,16 +289,16 @@ declare module "knex" {
|
||||
pipe(writable: any): QueryBuilder;
|
||||
exec(callback: Function): QueryBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface Transaction extends QueryBuilder {
|
||||
commit: any;
|
||||
rollback: any;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Schema builder
|
||||
//
|
||||
|
||||
|
||||
interface SchemaBuilder {
|
||||
createTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): Promise<void>;
|
||||
renameTable(oldTableName: string, newTableName: string): Promise<void>;
|
||||
@@ -309,7 +309,7 @@ declare module "knex" {
|
||||
dropTableIfExists(tableName: string): Promise<void>;
|
||||
raw(statement: string): SchemaBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface TableBuilder {
|
||||
increments(columnName?: string): ColumnBuilder;
|
||||
dropColumn(columnName: string): TableBuilder;
|
||||
@@ -336,24 +336,24 @@ declare module "knex" {
|
||||
specificType(columnName: string, type: string): ColumnBuilder;
|
||||
primary(columnNames: string[]) : TableBuilder;
|
||||
index(columnNames: string[], indexName?: string, indexType?: string) : TableBuilder;
|
||||
unique(columnNames: string[], indexName?: string) : TableBuilder;
|
||||
unique(columnNames: string[], indexName?: string) : TableBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface CreateTableBuilder extends TableBuilder {
|
||||
}
|
||||
|
||||
|
||||
interface MySqlTableBuilder extends CreateTableBuilder {
|
||||
engine(val: string): CreateTableBuilder;
|
||||
charset(val: string): CreateTableBuilder;
|
||||
collate(val: string): CreateTableBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface AlterTableBuilder extends TableBuilder {
|
||||
}
|
||||
|
||||
|
||||
interface MySqlAlterTableBuilder extends AlterTableBuilder {
|
||||
}
|
||||
|
||||
|
||||
interface ColumnBuilder {
|
||||
index(indexName?: string): ColumnBuilder;
|
||||
primary(): ColumnBuilder;
|
||||
@@ -367,34 +367,34 @@ declare module "knex" {
|
||||
nullable(): ColumnBuilder;
|
||||
comment(value: string): ColumnBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface PostgreSqlColumnBuilder extends ColumnBuilder {
|
||||
index(indexName?: string, indexType?: string): ColumnBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface ReferencingColumnBuilder {
|
||||
inTable(tableName: string): ColumnBuilder;
|
||||
}
|
||||
|
||||
|
||||
interface AlterColumnBuilder extends ColumnBuilder {
|
||||
}
|
||||
|
||||
|
||||
interface MySqlAlterColumnBuilder extends AlterColumnBuilder {
|
||||
first(): AlterColumnBuilder;
|
||||
after(columnName: string): AlterColumnBuilder;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Configurations
|
||||
//
|
||||
|
||||
|
||||
interface ColumnInfo {
|
||||
defaultValue: Value;
|
||||
type: string;
|
||||
maxLength: number;
|
||||
nullable: boolean;
|
||||
}
|
||||
|
||||
|
||||
interface Config {
|
||||
debug?: boolean;
|
||||
client?: string;
|
||||
@@ -404,7 +404,7 @@ declare module "knex" {
|
||||
pool?: PoolConfig;
|
||||
migrations?: MigrationConfig;
|
||||
}
|
||||
|
||||
|
||||
interface ConnectionConfig {
|
||||
host: string;
|
||||
user: string;
|
||||
@@ -412,13 +412,13 @@ declare module "knex" {
|
||||
database: string;
|
||||
debug?: boolean;
|
||||
}
|
||||
|
||||
|
||||
/** Used with SQLite3 adapter */
|
||||
interface Sqlite3ConnectionConfig {
|
||||
filename: string;
|
||||
debug?: boolean;
|
||||
}
|
||||
|
||||
|
||||
interface SocketConnectionConfig {
|
||||
socketPath: string;
|
||||
user: string;
|
||||
@@ -426,7 +426,7 @@ declare module "knex" {
|
||||
database: string;
|
||||
debug?: boolean;
|
||||
}
|
||||
|
||||
|
||||
interface PoolConfig {
|
||||
name?: string;
|
||||
create?: Function;
|
||||
@@ -443,7 +443,7 @@ declare module "knex" {
|
||||
validate?: Function;
|
||||
log?: boolean;
|
||||
}
|
||||
|
||||
|
||||
interface MigrationConfig {
|
||||
database?: string;
|
||||
directory?: string;
|
||||
|
||||
Reference in New Issue
Block a user