@h3ravel/arquebus 0.3.0 → 0.3.2
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 -1
- package/bin/index.cjs +4419 -1
- package/bin/index.d.cts +1 -1
- package/bin/index.d.ts +1 -1
- package/bin/index.js +4384 -1
- package/dist/browser/index.cjs +1269 -1
- package/dist/browser/index.d.cts +1222 -1202
- package/dist/browser/index.d.ts +1222 -1202
- package/dist/browser/index.js +1217 -1
- package/dist/index.cjs +4181 -1
- package/dist/index.d.cts +1306 -1280
- package/dist/index.d.ts +1306 -1280
- package/dist/index.js +4116 -1
- package/dist/migrations/chunk-PECeCxCb.js +15 -0
- package/dist/migrations/index.cjs +4064 -1
- package/dist/migrations/index.d.cts +1250 -1243
- package/dist/migrations/index.d.ts +1247 -1243
- package/dist/migrations/index.js +3994 -1
- package/package.json +3 -3
- package/bin/cli.cjs +0 -4942
- package/bin/cli.d.cts +0 -18
- package/bin/cli.d.ts +0 -18
- package/bin/cli.js +0 -4907
- package/bin/utils.js +0 -141
- /package/{bin → dist}/migrations/stubs/migration-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration-ts.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.create-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.create-ts.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.update-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.update-ts.stub +0 -0
- /package/{bin → dist}/stubs/arquebus.config-js.stub +0 -0
- /package/{bin → dist}/stubs/arquebus.config-ts.stub +0 -0
- /package/{bin → dist}/stubs/model-js.stub +0 -0
- /package/{bin → dist}/stubs/model-ts.stub +0 -0
|
@@ -1,870 +1,883 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
declare class Collection$1<I extends Model$1 | Model> extends Collection$2<I> implements ICollection<I> {
|
|
5
|
-
private newConstructor;
|
|
6
|
-
getConstructor<T extends typeof Collection$1<I>>(this: InstanceType<T>): T;
|
|
7
|
-
load(...relations: I[]): Promise<Collection$1<I>>;
|
|
8
|
-
loadAggregate<I>(relations: I, column: string, action?: string | null | TFunction): Promise<this>;
|
|
9
|
-
loadCount(relations: I): Promise<this>;
|
|
10
|
-
loadMax(relation: I, column: string): Promise<this>;
|
|
11
|
-
loadMin(relation: I, column: string): Promise<this>;
|
|
12
|
-
loadSum(relation: I, column: string): Promise<this>;
|
|
13
|
-
loadAvg(relation: I, column: string): Promise<this>;
|
|
14
|
-
mapThen(callback: () => void): Promise<void[]>;
|
|
15
|
-
modelKeys(): any[];
|
|
16
|
-
contains<K, V>(key: keyof I | K | TFunction, value?: V): boolean;
|
|
17
|
-
diff(items: ICollection<any> | any[]): any;
|
|
18
|
-
except(keys: any[]): any;
|
|
19
|
-
intersect(items: I[]): any;
|
|
20
|
-
unique(key?: TFunction | keyof I, _strict?: boolean): any;
|
|
21
|
-
find(key: any, defaultValue?: null): any;
|
|
22
|
-
fresh(...args: any[]): Promise<any>;
|
|
23
|
-
makeVisible(attributes: any): this;
|
|
24
|
-
makeHidden(attributes: any): this;
|
|
25
|
-
append(attributes: any): this;
|
|
26
|
-
only(keys: any[]): any;
|
|
27
|
-
getDictionary(items?: ICollection<any> | any[]): TGeneric;
|
|
28
|
-
toQuery(): any;
|
|
29
|
-
toData(): (I | {
|
|
30
|
-
[x: string]: any;
|
|
31
|
-
[x: number]: any;
|
|
32
|
-
[x: symbol]: any;
|
|
33
|
-
})[];
|
|
34
|
-
toJSON(): (I | {
|
|
35
|
-
[x: string]: any;
|
|
36
|
-
[x: number]: any;
|
|
37
|
-
[x: symbol]: any;
|
|
38
|
-
})[];
|
|
39
|
-
toJson(...args: any[]): string;
|
|
40
|
-
[Symbol.iterator]: () => Iterator<I>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
declare class Paginator<T extends Model$1, K extends IPaginatorParams = IPaginatorParams> implements IPaginator<T, K> {
|
|
44
|
-
static formatter: (paginator: IPaginator<any>) => any | null;
|
|
45
|
-
_items: Collection$1<T>;
|
|
46
|
-
_total: number;
|
|
47
|
-
_perPage: number;
|
|
48
|
-
_lastPage: number;
|
|
49
|
-
_currentPage: number;
|
|
50
|
-
hasMore: boolean;
|
|
51
|
-
options: TGeneric;
|
|
52
|
-
static setFormatter(formatter: (paginator: IPaginator<any>) => any | null): void;
|
|
53
|
-
constructor(items: T[], total: number, perPage: number, currentPage?: number, options?: TGeneric);
|
|
54
|
-
setItems(items: T[]): void;
|
|
55
|
-
firstItem(): number | null;
|
|
56
|
-
lastItem(): number | null;
|
|
57
|
-
hasMorePages(): boolean;
|
|
58
|
-
get(index: number): T | null;
|
|
59
|
-
count(): number;
|
|
60
|
-
items(): Collection$1<T>;
|
|
61
|
-
map(callback: (value: T, index: number) => T): Collection$1<T>;
|
|
62
|
-
currentPage(): number;
|
|
63
|
-
onFirstPage(): boolean;
|
|
64
|
-
perPage(): number;
|
|
65
|
-
lastPage(): number;
|
|
66
|
-
total(): number;
|
|
67
|
-
toData(): any;
|
|
68
|
-
toJSON(): any;
|
|
69
|
-
toJson(...args: any[]): string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
declare class Scope<M extends Model$1 = Model$1> implements IScope {
|
|
73
|
-
constructor();
|
|
74
|
-
apply(_builder: Builder<M>, _model: M): void;
|
|
75
|
-
}
|
|
1
|
+
import Knex$1, { Knex } from "knex";
|
|
2
|
+
import { Collection } from "collect.js";
|
|
76
3
|
|
|
4
|
+
//#region src/collection.d.ts
|
|
5
|
+
declare class Collection$1<I extends Model | Model$1> extends Collection<I> implements ICollection<I> {
|
|
6
|
+
private newConstructor;
|
|
7
|
+
getConstructor<T extends typeof Collection$1<I>>(this: InstanceType<T>): T;
|
|
8
|
+
load(...relations: I[]): Promise<Collection$1<I>>;
|
|
9
|
+
loadAggregate<I>(relations: I, column: string, action?: string | null | TFunction): Promise<this>;
|
|
10
|
+
loadCount(relations: I): Promise<this>;
|
|
11
|
+
loadMax(relation: I, column: string): Promise<this>;
|
|
12
|
+
loadMin(relation: I, column: string): Promise<this>;
|
|
13
|
+
loadSum(relation: I, column: string): Promise<this>;
|
|
14
|
+
loadAvg(relation: I, column: string): Promise<this>;
|
|
15
|
+
mapThen(callback: () => void): Promise<void[]>;
|
|
16
|
+
modelKeys(): any[];
|
|
17
|
+
contains<K, V>(key: keyof I | K | TFunction, value?: V): boolean;
|
|
18
|
+
diff(items: ICollection<any> | any[]): any;
|
|
19
|
+
except(keys: any[]): any;
|
|
20
|
+
intersect(items: I[]): any;
|
|
21
|
+
unique(key?: TFunction | keyof I, _strict?: boolean): any;
|
|
22
|
+
find(key: any, defaultValue?: null): any;
|
|
23
|
+
fresh(...args: any[]): Promise<any>;
|
|
24
|
+
makeVisible(attributes: any): this;
|
|
25
|
+
makeHidden(attributes: any): this;
|
|
26
|
+
append(attributes: any): this;
|
|
27
|
+
only(keys: any[]): any;
|
|
28
|
+
getDictionary(items?: ICollection<any> | any[]): TGeneric;
|
|
29
|
+
toQuery(): any;
|
|
30
|
+
toData(): (I | {
|
|
31
|
+
[x: string]: any;
|
|
32
|
+
[x: number]: any;
|
|
33
|
+
[x: symbol]: any;
|
|
34
|
+
})[];
|
|
35
|
+
toJSON(): (I | {
|
|
36
|
+
[x: string]: any;
|
|
37
|
+
[x: number]: any;
|
|
38
|
+
[x: symbol]: any;
|
|
39
|
+
})[];
|
|
40
|
+
toJson(...args: any[]): string;
|
|
41
|
+
[Symbol.iterator]: () => Iterator<I>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/paginator.d.ts
|
|
45
|
+
declare class Paginator<T extends Model, K extends IPaginatorParams = IPaginatorParams> implements IPaginator<T, K> {
|
|
46
|
+
static formatter: (paginator: IPaginator<any>) => any | null;
|
|
47
|
+
_items: Collection$1<T>;
|
|
48
|
+
_total: number;
|
|
49
|
+
_perPage: number;
|
|
50
|
+
_lastPage: number;
|
|
51
|
+
_currentPage: number;
|
|
52
|
+
hasMore: boolean;
|
|
53
|
+
options: TGeneric;
|
|
54
|
+
static setFormatter(formatter: (paginator: IPaginator<any>) => any | null): void;
|
|
55
|
+
constructor(items: T[], total: number, perPage: number, currentPage?: number, options?: TGeneric);
|
|
56
|
+
setItems(items: T[]): void;
|
|
57
|
+
firstItem(): number | null;
|
|
58
|
+
lastItem(): number | null;
|
|
59
|
+
hasMorePages(): boolean;
|
|
60
|
+
get(index: number): T | null;
|
|
61
|
+
count(): number;
|
|
62
|
+
items(): Collection$1<T>;
|
|
63
|
+
map(callback: (value: T, index: number) => T): Collection$1<T>;
|
|
64
|
+
currentPage(): number;
|
|
65
|
+
onFirstPage(): boolean;
|
|
66
|
+
perPage(): number;
|
|
67
|
+
lastPage(): number;
|
|
68
|
+
total(): number;
|
|
69
|
+
toData(): any;
|
|
70
|
+
toJSON(): any;
|
|
71
|
+
toJson(...args: any[]): string;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/scope.d.ts
|
|
75
|
+
declare class Scope<M extends Model = Model> implements IScope {
|
|
76
|
+
constructor();
|
|
77
|
+
apply(_builder: Builder<M>, _model: M): void;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/builder.d.ts
|
|
77
81
|
declare const Inference$2: {
|
|
78
|
-
|
|
82
|
+
new <M extends Model = Model, R = IModel | ICollection<M>>(): IBuilder<M, R>;
|
|
79
83
|
};
|
|
80
|
-
declare class Builder<M extends Model
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
84
|
+
declare class Builder<M extends Model = Model, R = IModel | ICollection<M>> extends Inference$2 {
|
|
85
|
+
query: IBuilder<M, R>;
|
|
86
|
+
connection: any;
|
|
87
|
+
model: M;
|
|
88
|
+
actions: any[];
|
|
89
|
+
localMacros: TGeneric<(...args: any[]) => any, keyof Omit<IBuilder<M, R>, number>>;
|
|
90
|
+
eagerLoad: TGeneric<(...args: any[]) => any>;
|
|
91
|
+
globalScopes: TGeneric<Scope<M> | ((arg: Builder<M, R>) => Builder<M, R>)>;
|
|
92
|
+
onDeleteCallback?: (builder: Builder<M, R>) => Promise<boolean | number>;
|
|
93
|
+
constructor(query: IBuilder<M, R>);
|
|
94
|
+
asProxy(): Builder<M, R>;
|
|
95
|
+
orWhere(...args: any[]): this;
|
|
96
|
+
chunk<C extends TFunction>(count: number, callback: C): Promise<boolean>;
|
|
97
|
+
enforceOrderBy(this: any): void;
|
|
98
|
+
clone(this: any): any;
|
|
99
|
+
forPage(this: any, page: number, perPage?: number): any;
|
|
100
|
+
insert(...args: Parameters<typeof (void 0).query.insert>): Promise<any>;
|
|
101
|
+
update<T extends TGeneric>(values: T): Promise<any>;
|
|
102
|
+
increment(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
103
|
+
decrement(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
104
|
+
addUpdatedAtColumn(values: TGeneric<string>): TGeneric<string>;
|
|
105
|
+
delete(): Promise<number | boolean>;
|
|
106
|
+
onDelete<C extends TFunction<any, Promise<number | boolean>>>(callback: C): void;
|
|
107
|
+
forceDelete(): Promise<number | boolean>;
|
|
108
|
+
create(attributes?: {}): Promise<any>;
|
|
109
|
+
newModelInstance(attributes?: {}): any;
|
|
110
|
+
getQuery(): IBuilder<M, R>;
|
|
111
|
+
getModel(): M;
|
|
112
|
+
setModel<MO extends Model>(model: MO): this;
|
|
113
|
+
qualifyColumn(column: string): string;
|
|
114
|
+
setTable(table: string): this;
|
|
115
|
+
applyScopes(): this;
|
|
116
|
+
hasNamedScope(name: string): boolean;
|
|
117
|
+
callNamedScope(scope: string, parameters: any[]): any;
|
|
118
|
+
callScope(scope: (builder: this, ...args: any[]) => this, parameters?: never[]): this;
|
|
119
|
+
scopes(scopes: string[]): this;
|
|
120
|
+
withGlobalScope(identifier: string, scope: any): this;
|
|
121
|
+
withoutGlobalScope(scope: Scope | string): this;
|
|
122
|
+
macro<N extends string>(name: N, callback: (builder: TGeneric & IBuilder<M>, attrs: any, vals: any) => any): this;
|
|
123
|
+
hasMacro(name: string): boolean;
|
|
124
|
+
getMacro(name: string): (...args: any[]) => any;
|
|
125
|
+
with(...args: any[]): this;
|
|
126
|
+
has(relation: any, operator?: string, count?: number, boolean?: string, callback?: TFunction | null): any;
|
|
127
|
+
orHas(relation: any, operator?: string, count?: number): any;
|
|
128
|
+
doesntHave(relation: any, boolean?: string, callback?: TFunction | null): any;
|
|
129
|
+
orDoesntHave(relation: any): any;
|
|
130
|
+
whereHas(relation: any, callback?: TFunction | null, operator?: string, count?: number): any;
|
|
131
|
+
orWhereHas(relation: any, callback?: TFunction | null, operator?: string, count?: number): any;
|
|
132
|
+
whereRelation(relation: any, ...args: any[]): any;
|
|
133
|
+
orWhereRelation(relation: any, ...args: any[]): any;
|
|
134
|
+
hasNested(relations: any, operator?: string, count?: number, boolean?: string, callback?: TFunction | null): any;
|
|
135
|
+
canUseExistsForExistenceCheck(operator: string, count: number): boolean;
|
|
136
|
+
addHasWhere(hasQuery: any, relation: any, operator: string, count: number, boolean: string): any;
|
|
137
|
+
addWhereExistsQuery(this: any, query: any, boolean?: string, not?: boolean): any;
|
|
138
|
+
addWhereCountQuery(this: any, query: any, operator?: string, count?: number, boolean?: string): any;
|
|
139
|
+
withAggregate(relations: any, column: string, action?: string | null): this;
|
|
140
|
+
toSql(): any;
|
|
141
|
+
mergeConstraintsFrom(_from: any): this;
|
|
142
|
+
selectSub(query: Builder<M>, as: string): any;
|
|
143
|
+
createSub(query: any): any[];
|
|
144
|
+
parseSub(query: any): any[];
|
|
145
|
+
prependDatabaseNameIfCrossDatabaseQuery(query: any): any;
|
|
146
|
+
getRelationWithoutConstraints(relation: string): any;
|
|
147
|
+
withCount(...args: any[]): this;
|
|
148
|
+
withMax(relation: any, column: string): this;
|
|
149
|
+
withMin(relation: any, column: string): this;
|
|
150
|
+
withAvg(relation: any, column: string): this;
|
|
151
|
+
withSum(relation: any, column: string): this;
|
|
152
|
+
withExists(relation: any): this;
|
|
153
|
+
parseWithRelations(relations: TGeneric): TGeneric | never[];
|
|
154
|
+
addNestedWiths(name: string, results: TGeneric): TGeneric;
|
|
155
|
+
prepareNestedWithRelationships(relations: TGeneric, prefix?: string): TGeneric;
|
|
156
|
+
combineConstraints(constraints: TFunction[]): (builder: Builder<M>) => Builder<M, IModel | ICollection<M>>;
|
|
157
|
+
parseNameAndAttributeSelectionConstraint(name: string, value: string): (string | ((query: any) => void))[];
|
|
158
|
+
createSelectWithConstraint(name: string): (string | ((query: any) => void))[];
|
|
159
|
+
related(relation: string): any;
|
|
160
|
+
take(this: any, ...args: any[]): any;
|
|
161
|
+
skip(this: any, ...args: any[]): any;
|
|
162
|
+
first(this: any, ...columns: any[]): Promise<M | null>;
|
|
163
|
+
firstOrFail(...columns: any[]): Promise<M>;
|
|
164
|
+
findOrFail(this: any, ...args: any[]): Promise<M>;
|
|
165
|
+
findOrNew(id: string, columns?: string[]): Promise<any>;
|
|
166
|
+
firstOrNew(this: any, attributes?: {}, values?: {}): Promise<any>;
|
|
167
|
+
firstOrCreate(this: any, attributes?: TGeneric, values?: {}): Promise<any>;
|
|
168
|
+
updateOrCreate(attributes: TGeneric, values?: {}): Promise<any>;
|
|
169
|
+
latest(column?: string): this;
|
|
170
|
+
oldest(column?: string): this;
|
|
171
|
+
find(this: any, id: string | number | Collection$1<M>, columns?: string[]): Promise<any>;
|
|
172
|
+
findMany(this: any, ids: string[] | number[] | ICollection<any>, columns?: string[]): Promise<any>;
|
|
173
|
+
pluck(column: string): Promise<any>;
|
|
174
|
+
destroy(this: any, ids?: (string | number)[] | TFunction | Collection$1<M>): Promise<number>;
|
|
175
|
+
get<M extends Model>(columns?: string | string[]): Promise<Collection$1<M>>;
|
|
176
|
+
all(columns?: string[]): Promise<any>;
|
|
177
|
+
paginate(this: any, page?: number, perPage?: number): Promise<Paginator<any, IPaginatorParams>>;
|
|
178
|
+
getModels(...columns: any[]): Promise<any[]>;
|
|
179
|
+
getRelation(name: string): any;
|
|
180
|
+
relationsNestedUnder(relation: string): TGeneric;
|
|
181
|
+
isNestedUnder(relation: string, name: string): boolean;
|
|
182
|
+
eagerLoadRelation<M extends Model>(models: M[], name: string, constraints: any): Promise<any>;
|
|
183
|
+
eagerLoadRelations<M extends Model>(models: M[]): Promise<M[]>;
|
|
184
|
+
hydrate(items: any[]): Collection$1<any>;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/relations/relation.d.ts
|
|
183
188
|
declare class Relation$1 {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
189
|
+
query: QueryBuilder;
|
|
190
|
+
parent: any;
|
|
191
|
+
related: any;
|
|
192
|
+
eagerKeysWereEmpty: boolean;
|
|
193
|
+
static constraints: boolean;
|
|
194
|
+
static selfJoinCount: number;
|
|
195
|
+
constructor(query: any, parent: any);
|
|
196
|
+
static extend(trait: Record<string, any>): void;
|
|
197
|
+
static noConstraints(callback: () => any): any;
|
|
198
|
+
asProxy(): any;
|
|
199
|
+
getRelated(): any;
|
|
200
|
+
getKeys(models: any[], key?: string | null): any[];
|
|
201
|
+
getRelationQuery(): any;
|
|
202
|
+
whereInEager(whereIn: string, key: string, modelKeys: any[], query?: any): void;
|
|
203
|
+
whereInMethod(model: any, key: string): string;
|
|
204
|
+
getEager(): any;
|
|
205
|
+
get(columns?: string | string[]): Promise<any>;
|
|
206
|
+
first(columns?: string[]): Promise<any>;
|
|
207
|
+
paginate(...args: any[]): Promise<any>;
|
|
208
|
+
count(...args: any[]): Promise<any>;
|
|
209
|
+
toSql(): string;
|
|
210
|
+
addConstraints(): void;
|
|
211
|
+
getRelationCountHash(incrementJoinCount?: boolean): string;
|
|
212
|
+
getRelationExistenceQuery(query: any, parentQuery: any, columns?: string[]): any;
|
|
213
|
+
getRelationExistenceCountQuery(query: any, parentQuery: any): any;
|
|
214
|
+
getQualifiedParentKeyName(): string;
|
|
215
|
+
getExistenceCompareKey(this: any): string;
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/arquebus.d.ts
|
|
219
|
+
declare class arquebus<M extends Model = Model> {
|
|
220
|
+
static connectorFactory: typeof Knex$1 | null;
|
|
221
|
+
static instance: arquebus | null;
|
|
222
|
+
manager: Record<string, QueryBuilder<M>>;
|
|
223
|
+
connections: Record<string, TConfig>;
|
|
224
|
+
models: Record<string, typeof Model>;
|
|
225
|
+
constructor();
|
|
226
|
+
getConstructor<T extends typeof arquebus>(this: InstanceType<T>): T;
|
|
227
|
+
static getInstance(): arquebus<Model>;
|
|
228
|
+
/**
|
|
229
|
+
* Initialize a new database connection
|
|
230
|
+
*
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
233
|
+
static fire<C extends TBaseConfig['client']>(connection?: C | null): QueryBuilder<Model>;
|
|
234
|
+
/**
|
|
235
|
+
* Initialize a new database connection
|
|
236
|
+
*
|
|
237
|
+
* This is an alias of `arquebus.fire()` and will be removed in the future
|
|
238
|
+
*
|
|
239
|
+
* @deprecated since version 0.3.0
|
|
240
|
+
* @alias fire
|
|
241
|
+
*
|
|
242
|
+
* @returns
|
|
243
|
+
*/
|
|
244
|
+
static connection<C extends TBaseConfig['client']>(connection?: C | null): QueryBuilder<Model, Model | Model[]>;
|
|
245
|
+
static setConnectorFactory(connectorFactory: typeof Knex$1): void;
|
|
246
|
+
static getConnectorFactory(): typeof Knex$1;
|
|
247
|
+
static addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
248
|
+
static beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]> | undefined>;
|
|
249
|
+
static transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
250
|
+
static table(name: string, connection?: null): IQueryBuilder<Model, Model | Model[]>;
|
|
251
|
+
static schema(connection?: null): SchemaBuilder;
|
|
252
|
+
static destroyAll(): Promise<void>;
|
|
253
|
+
static createModel<X extends TGeneric>(name: string, options: X): typeof Model;
|
|
254
|
+
connection(connection?: string | null): QueryBuilder<M, M | M[]>;
|
|
255
|
+
getConnection(name?: string | null): QueryBuilder<M, M | M[]>;
|
|
256
|
+
addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
257
|
+
/**
|
|
258
|
+
* Autoload the config file
|
|
259
|
+
*
|
|
260
|
+
* @param addConnection
|
|
261
|
+
* @default true
|
|
262
|
+
* If set to `false` we will no attempt add the connection, we
|
|
263
|
+
* will just go ahead and return the config
|
|
264
|
+
*
|
|
265
|
+
* @returns
|
|
266
|
+
*/
|
|
267
|
+
static autoLoad(addConnection?: boolean): Promise<TBaseConfig>;
|
|
268
|
+
beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]> | undefined>;
|
|
269
|
+
transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
270
|
+
table(name: string, connection?: null): IQueryBuilder<M, M | M[]>;
|
|
271
|
+
schema(connection?: null): SchemaBuilder;
|
|
272
|
+
destroyAll(): Promise<void>;
|
|
273
|
+
createModel(name: string, options?: ModelOptions): typeof Model;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region types/container.d.ts
|
|
270
277
|
interface TBaseConfig {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
278
|
+
client: 'mysql' | 'mysql2' | 'sqlite3' | 'oracle' | 'mariadb' | 'pg';
|
|
279
|
+
connection: {
|
|
280
|
+
typeCast?(field: TField, next: TFunction): any;
|
|
281
|
+
dateStrings?: boolean;
|
|
282
|
+
};
|
|
283
|
+
pool?: {
|
|
284
|
+
afterCreate: (connection: TConfig, callback: (val: any, con: any) => void) => Promise<any>;
|
|
285
|
+
} | undefined;
|
|
286
|
+
connections?: arquebus['connections'];
|
|
287
|
+
migrations?: {
|
|
288
|
+
table: string;
|
|
289
|
+
path: string;
|
|
290
|
+
};
|
|
291
|
+
factories?: {
|
|
292
|
+
path: string;
|
|
293
|
+
};
|
|
294
|
+
seeders?: {
|
|
295
|
+
path: string;
|
|
296
|
+
};
|
|
297
|
+
models?: {
|
|
298
|
+
path: string;
|
|
299
|
+
};
|
|
293
300
|
}
|
|
294
301
|
type TConfig = TBaseConfig & ({
|
|
295
|
-
|
|
296
|
-
|
|
302
|
+
client: 'pg';
|
|
303
|
+
connection: Knex.PgConnectionConfig;
|
|
297
304
|
} | {
|
|
298
|
-
|
|
299
|
-
|
|
305
|
+
client: 'oracle';
|
|
306
|
+
connection: Knex.OracleDbConnectionConfig;
|
|
300
307
|
} | {
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
client: 'mysql2';
|
|
309
|
+
connection: Knex.MySql2ConnectionConfig;
|
|
303
310
|
} | {
|
|
304
|
-
|
|
305
|
-
|
|
311
|
+
client: 'mysql';
|
|
312
|
+
connection: Knex.MySqlConnectionConfig;
|
|
306
313
|
} | {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
314
|
+
client: 'sqlite3';
|
|
315
|
+
connection: Knex.Sqlite3ConnectionConfig;
|
|
316
|
+
useNullAsDefault?: boolean;
|
|
310
317
|
} | {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
318
|
+
client: 'mariadb';
|
|
319
|
+
connection: Knex.MariaSqlConnectionConfig;
|
|
320
|
+
useNullAsDefault?: boolean;
|
|
314
321
|
});
|
|
315
|
-
interface ModelOptions<M extends Model
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
322
|
+
interface ModelOptions<M extends Model = Model> {
|
|
323
|
+
table?: string;
|
|
324
|
+
scopes?: TGeneric<(...args: any[]) => Builder<M>>;
|
|
325
|
+
plugins?: (<X extends MixinConstructor<M>>(Model: X) => MixinConstructor<M>)[];
|
|
326
|
+
relations?: TGeneric<(...args: any[]) => Relation$1>;
|
|
327
|
+
attributes?: TGeneric<Attribute>;
|
|
328
|
+
CREATED_AT?: string;
|
|
329
|
+
UPDATED_AT?: string;
|
|
330
|
+
DELETED_AT?: string;
|
|
331
|
+
connection?: TBaseConfig['client'];
|
|
332
|
+
timestamps?: boolean;
|
|
333
|
+
primaryKey?: string;
|
|
334
|
+
incrementing?: boolean;
|
|
335
|
+
keyType?: 'int' | 'string';
|
|
336
|
+
with?: Model['with'];
|
|
337
|
+
casts?: Model['casts'];
|
|
331
338
|
}
|
|
332
339
|
interface TField {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
|
|
340
|
+
type: 'VAR_STRING' | 'BLOB' | 'DATETIME' | 'TIMESTAMP' | 'LONG' | 'JSON';
|
|
341
|
+
length: number;
|
|
342
|
+
db: string;
|
|
343
|
+
table: string;
|
|
344
|
+
name: string;
|
|
345
|
+
string: TFunction;
|
|
346
|
+
buffer: TFunction;
|
|
347
|
+
geometry: TFunction;
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region types/modeling.d.ts
|
|
343
351
|
interface Attribute {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
type Relation<M extends Model
|
|
354
|
-
interface HasOneOrMany<M extends Model
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
interface HasOne<M extends Model
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
interface HasMany<M extends Model
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
interface BelongsTo<M extends Model
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
interface BelongsToMany<M extends Model
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
352
|
+
make(config: {
|
|
353
|
+
get?: TFunction | null;
|
|
354
|
+
set?: TFunction | null;
|
|
355
|
+
}): Attribute;
|
|
356
|
+
get: TFunction | null;
|
|
357
|
+
set: TFunction | null;
|
|
358
|
+
withCaching?: boolean;
|
|
359
|
+
withObjectCaching?: boolean;
|
|
360
|
+
}
|
|
361
|
+
type Relation<M extends Model> = IBuilder<M, any> & {};
|
|
362
|
+
interface HasOneOrMany<M extends Model> extends Relation<M> {
|
|
363
|
+
save(model: M): Promise<M>;
|
|
364
|
+
saveMany(models: M[] | ICollection<M>): Promise<ICollection<M>>;
|
|
365
|
+
create(attributes?: any): Promise<M>;
|
|
366
|
+
createMany(records: any[]): Promise<ICollection<M>>;
|
|
367
|
+
}
|
|
368
|
+
interface HasOne<M extends Model> extends HasOneOrMany<M> {
|
|
369
|
+
getResults(): Promise<M | null>;
|
|
370
|
+
withDefault(callback?: TFunction | object): this;
|
|
371
|
+
}
|
|
372
|
+
interface HasMany<M extends Model> extends HasOneOrMany<M> {
|
|
373
|
+
getResults(): Promise<ICollection<M>>;
|
|
374
|
+
}
|
|
375
|
+
interface BelongsTo<M extends Model> extends Relation<M> {
|
|
376
|
+
getResults(): Promise<M | null>;
|
|
377
|
+
withDefault(callback?: TFunction | object): this;
|
|
378
|
+
}
|
|
379
|
+
interface BelongsToMany<M extends Model> extends Relation<M> {
|
|
380
|
+
getResults(): Promise<ICollection<M>>;
|
|
381
|
+
withTimestamps(): this;
|
|
382
|
+
wherePivot(column: any, operator?: any, value?: any, boolean?: string, ...args: any[]): this;
|
|
383
|
+
wherePivotBetween(column: any, values: any, boolean?: string, not?: boolean): this;
|
|
384
|
+
orWherePivotBetween(column: any, values: any): this;
|
|
385
|
+
wherePivotNotBetween(column: any, values: any, boolean?: string): this;
|
|
386
|
+
orWherePivotNotBetween(column: any, values: any): this;
|
|
387
|
+
wherePivotIn(column: any, values: any, boolean?: string, not?: boolean): this;
|
|
388
|
+
orWherePivot(column: any, operator?: any, value?: any): this;
|
|
389
|
+
orWherePivotIn(column: any, values: any): this;
|
|
390
|
+
wherePivotNotIn(column: any, values: any, boolean?: string): this;
|
|
391
|
+
orWherePivotNotIn(column: any, values: any): this;
|
|
392
|
+
wherePivotNull(column: any, boolean?: string, not?: boolean): this;
|
|
393
|
+
wherePivotNotNull(column: any, boolean?: string): this;
|
|
394
|
+
orWherePivotNull(column: any, not?: boolean): this;
|
|
395
|
+
orWherePivotNotNull(column: any): this;
|
|
396
|
+
orderByPivot(column: any, direction?: string): this;
|
|
389
397
|
}
|
|
390
398
|
interface IModel {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
399
|
+
[value: string]: any;
|
|
400
|
+
attributes: any;
|
|
401
|
+
relations: any;
|
|
402
|
+
exists: boolean;
|
|
403
|
+
primaryKey: string;
|
|
404
|
+
builder?: IBuilder<any, any> | null;
|
|
405
|
+
table: string | null;
|
|
406
|
+
connection?: TBaseConfig['client'] | null;
|
|
407
|
+
keyType: string;
|
|
408
|
+
incrementing: boolean;
|
|
409
|
+
perPage: number;
|
|
410
|
+
with: string | string[] | TGeneric<(...args: any[]) => IBuilder<Model>>;
|
|
411
|
+
withCount: string[];
|
|
412
|
+
trx: AnyQueryBuilder | null;
|
|
413
|
+
timestamps: boolean;
|
|
414
|
+
dateFormat: string;
|
|
415
|
+
visible: string[];
|
|
416
|
+
hidden: string[];
|
|
417
|
+
query<T extends {
|
|
418
|
+
prototype: unknown;
|
|
419
|
+
}>(this: T, client?: AnyQueryBuilder | null): IBuilder<Model>;
|
|
420
|
+
on<T extends {
|
|
421
|
+
prototype: unknown;
|
|
422
|
+
}>(this: T, connection: string | null): IBuilder<Model>;
|
|
423
|
+
boot(): void;
|
|
424
|
+
make<T extends IModel>(this: new () => T, attributes?: TGeneric): T;
|
|
425
|
+
addHook(hook: Hook, callback: TFunction): void;
|
|
426
|
+
creating(callback: TFunction): void;
|
|
427
|
+
created(callback: TFunction): void;
|
|
428
|
+
updating(callback: TFunction): void;
|
|
429
|
+
updated(callback: TFunction): void;
|
|
430
|
+
deleting(callback: TFunction): void;
|
|
431
|
+
deleted(callback: TFunction): void;
|
|
432
|
+
saving(callback: TFunction): void;
|
|
433
|
+
saved(callback: TFunction): void;
|
|
434
|
+
restoring(callback: TFunction): void;
|
|
435
|
+
restored(callback: TFunction): void;
|
|
436
|
+
trashed(callback: TFunction): void;
|
|
437
|
+
forceDeleted(callback: TFunction): void;
|
|
438
|
+
bootIfNotBooted(): void;
|
|
439
|
+
initialize(): void;
|
|
440
|
+
initializePlugins(): void;
|
|
441
|
+
addPluginInitializer(method: any): void;
|
|
442
|
+
newInstance(attributes?: TGeneric, exists?: boolean): any;
|
|
443
|
+
getKey(): string | number | null | undefined;
|
|
444
|
+
getKeyName(): string;
|
|
445
|
+
getConnectionName(): string;
|
|
446
|
+
getConnection(): any;
|
|
447
|
+
setConnection(connection: TBaseConfig['client'] | null): this;
|
|
448
|
+
usesUniqueIds(): boolean;
|
|
449
|
+
uniqueIds(): string[];
|
|
450
|
+
newUniqueId(): string;
|
|
451
|
+
setUniqueIds(): void;
|
|
452
|
+
getKeyType(): string;
|
|
453
|
+
getIncrementing(): boolean;
|
|
454
|
+
setIncrementing(value: boolean): this;
|
|
455
|
+
getTable(): string;
|
|
456
|
+
setTable(table: string): this;
|
|
457
|
+
getDates(): string[];
|
|
458
|
+
getDateFormat(): string;
|
|
459
|
+
getAttributes(): object;
|
|
460
|
+
getAttribute(key: string): any;
|
|
461
|
+
setAttribute(key: string, value: any): this;
|
|
462
|
+
fill(attributes: any): this;
|
|
463
|
+
setAppends(appends: string[]): this;
|
|
464
|
+
append(key: string | string[]): this;
|
|
465
|
+
getRelation<T extends Model>(relation: string): T | ICollection<T> | null | undefined;
|
|
466
|
+
setRelation<T extends Model>(relation: string, value: T | ICollection<T> | null): this;
|
|
467
|
+
unsetRelation(relation: string): this;
|
|
468
|
+
relationLoaded(relation: string): boolean;
|
|
469
|
+
makeVisible(attributes: string | string[]): this;
|
|
470
|
+
makeHidden(attributes: string | string[]): this;
|
|
471
|
+
newCollection(models?: any[]): ICollection<Model>;
|
|
472
|
+
load(relations: WithRelationType): Promise<this>;
|
|
473
|
+
load(...relations: WithRelationType[]): Promise<this>;
|
|
474
|
+
loadAggregate(relations: WithRelationType, column: any, callback?: any): Promise<this>;
|
|
475
|
+
loadCount(...relations: WithRelationType[]): Promise<this>;
|
|
476
|
+
loadMax(relations: WithRelationType, column: string): Promise<this>;
|
|
477
|
+
loadMin(relations: WithRelationType, column: string): Promise<this>;
|
|
478
|
+
loadSum(relations: WithRelationType, column: string): Promise<this>;
|
|
479
|
+
usesTimestamps(): boolean;
|
|
480
|
+
updateTimestamps(): this;
|
|
481
|
+
getCreatedAtColumn(): string;
|
|
482
|
+
getUpdatedAtColumn(): string;
|
|
483
|
+
getDeletedAtColumn(): string;
|
|
484
|
+
setCreatedAt(value: string): this;
|
|
485
|
+
setUpdatedAt(value: string): this;
|
|
486
|
+
freshTimestamp(): Date;
|
|
487
|
+
freshTimestampString(): string;
|
|
488
|
+
fromDateTime(value: Date | number | null): string;
|
|
489
|
+
useSoftDeletes(): boolean;
|
|
490
|
+
toData(): any;
|
|
491
|
+
attributesToData(): any;
|
|
492
|
+
relationsToData(): any;
|
|
493
|
+
toJSON(): any;
|
|
494
|
+
toJson(): string;
|
|
495
|
+
toString(): string;
|
|
496
|
+
isDirty(attributes?: string | string[]): boolean;
|
|
497
|
+
getDirty(): string[];
|
|
498
|
+
save(options?: any): Promise<boolean>;
|
|
499
|
+
update(attributes?: any, options?: any): Promise<boolean>;
|
|
500
|
+
increment(column: string, amount?: number, extra?: any): Promise<boolean>;
|
|
501
|
+
decrement(column: string, amount?: number, extra?: any): Promise<boolean>;
|
|
502
|
+
serializeDate(date: any): string;
|
|
503
|
+
delete(options?: any): Promise<boolean>;
|
|
504
|
+
softDelete(options?: any): Promise<boolean>;
|
|
505
|
+
forceDelete(options?: any): Promise<boolean>;
|
|
506
|
+
restore(options?: any): Promise<boolean>;
|
|
507
|
+
trashed(): boolean;
|
|
508
|
+
fresh(): Promise<this>;
|
|
509
|
+
refresh(): Promise<this | undefined>;
|
|
510
|
+
push(): Promise<boolean>;
|
|
511
|
+
is(model: this): boolean;
|
|
512
|
+
isNot(model: this): boolean;
|
|
513
|
+
related<T extends RelationNames<this>>(relation: T): ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>;
|
|
514
|
+
getRelated<T extends RelationNames<this>>(relation: T): ReturnTypeOfMethod<ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>, any>;
|
|
515
|
+
hasOne<T extends Model>(model: new () => T, foreignKey?: string, localKey?: string): HasOne<T>;
|
|
516
|
+
hasMany<T extends Model>(model: new () => T, foreignKey?: string, localKey?: string): HasMany<T>;
|
|
517
|
+
belongsTo<T extends Model>(model: new () => T, foreignKey?: string, ownerKey?: string, relation?: string): BelongsTo<T>;
|
|
518
|
+
belongsToMany<T extends Model>(model: new () => T, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string): BelongsToMany<T>;
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/model.d.ts
|
|
513
522
|
declare const BaseModel$1: (new (...args: any[]) => any) & {
|
|
514
|
-
|
|
523
|
+
[x: string]: any;
|
|
515
524
|
};
|
|
516
|
-
declare class Model
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
declare class Pivot$1 extends Model
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
|
|
525
|
+
declare class Model extends BaseModel$1 {
|
|
526
|
+
protected primaryKey: string;
|
|
527
|
+
protected builder: IBuilder<any, any> | null;
|
|
528
|
+
protected table: string | null;
|
|
529
|
+
protected keyType: string;
|
|
530
|
+
protected incrementing: boolean;
|
|
531
|
+
protected withCount: never[];
|
|
532
|
+
perPage: number;
|
|
533
|
+
static globalScopes: {};
|
|
534
|
+
static pluginInitializers: {};
|
|
535
|
+
static _booted: {};
|
|
536
|
+
static resolver: arquebus;
|
|
537
|
+
connection: TBaseConfig['client'] | null;
|
|
538
|
+
eagerLoad: {};
|
|
539
|
+
exists: boolean;
|
|
540
|
+
with: string | string[] | TGeneric<(...args: any[]) => IBuilder<Model>>;
|
|
541
|
+
trx: null;
|
|
542
|
+
constructor(attributes?: {});
|
|
543
|
+
static query(trx?: null): Builder<Model, IModel | ICollection<Model>>;
|
|
544
|
+
static on(connection?: TBaseConfig['client'] | null): Builder<Model, IModel | ICollection<Model>>;
|
|
545
|
+
static init(attributes?: {}): Model;
|
|
546
|
+
static extend(plugin: TFunction, options: TGeneric): void;
|
|
547
|
+
static make(attributes?: TGeneric): Model;
|
|
548
|
+
getConstructor<T extends typeof Model>(this: InstanceType<T>): T;
|
|
549
|
+
bootIfNotBooted(this: any): void;
|
|
550
|
+
static booting(): void;
|
|
551
|
+
static boot(): void;
|
|
552
|
+
static booted(): void;
|
|
553
|
+
static setConnectionResolver(resolver: arquebus): void;
|
|
554
|
+
initialize(): void;
|
|
555
|
+
initializePlugins(this: any): void;
|
|
556
|
+
addPluginInitializer(this: any, method: any): void;
|
|
557
|
+
newInstance(this: any, attributes?: TGeneric, exists?: boolean): any;
|
|
558
|
+
newFromBuilder(attributes?: TGeneric, connection?: null): any;
|
|
559
|
+
asProxy(): this;
|
|
560
|
+
getKey(): any;
|
|
561
|
+
getKeyName(): string;
|
|
562
|
+
getForeignKey(): string;
|
|
563
|
+
getConnectionName(): "mysql" | "mysql2" | "sqlite3" | "oracle" | "mariadb" | "pg";
|
|
564
|
+
getTable(): string;
|
|
565
|
+
getConnection(this: any): any;
|
|
566
|
+
setConnection(connection: TBaseConfig['client'] | null): this;
|
|
567
|
+
getKeyType(): string;
|
|
568
|
+
newQuery(trx?: null): Builder<Model, IModel | ICollection<Model>>;
|
|
569
|
+
newQueryWithoutScopes(trx?: null): Builder<Model, IModel | ICollection<Model>>;
|
|
570
|
+
newModelQuery(trx?: null): Builder<Model, IModel | ICollection<Model>>;
|
|
571
|
+
addGlobalScopes(this: any, builder: Builder<Model>): Builder<Model, IModel | ICollection<Model>>;
|
|
572
|
+
hasNamedScope(name: string): boolean;
|
|
573
|
+
callNamedScope(scope: string, parameters: any[]): any;
|
|
574
|
+
setTable(table: string): this;
|
|
575
|
+
newCollection(this: any, models?: never[]): Collection$1<Model>;
|
|
576
|
+
load<R extends WithRelationType>(this: any, ...relations: R[]): Promise<any>;
|
|
577
|
+
loadAggregate<R extends WithRelationType>(relations: R[], column: string, callback?: TFunction | string | null): Promise<this>;
|
|
578
|
+
loadCount<R extends WithRelationType>(...relations: R[]): Promise<this>;
|
|
579
|
+
loadMax<R extends WithRelationType>(relations: R[], column: string): Promise<this>;
|
|
580
|
+
loadMin<R extends WithRelationType>(relations: R[], column: string): Promise<this>;
|
|
581
|
+
loadSum<R extends WithRelationType>(relations: R[], column: string): Promise<this>;
|
|
582
|
+
increment(column: string, amount?: number, extra?: TGeneric, options?: TGeneric): Promise<any>;
|
|
583
|
+
decrement(column: string, amount?: number, extra?: TGeneric, options?: TGeneric): Promise<any>;
|
|
584
|
+
incrementOrDecrement(column: string, amount: number, extra: TGeneric, method: string, options: TGeneric): Promise<any>;
|
|
585
|
+
toData(): {
|
|
586
|
+
[x: string]: any;
|
|
587
|
+
[x: number]: any;
|
|
588
|
+
[x: symbol]: any;
|
|
589
|
+
};
|
|
590
|
+
toJSON(): {
|
|
591
|
+
[x: string]: any;
|
|
592
|
+
[x: number]: any;
|
|
593
|
+
[x: symbol]: any;
|
|
594
|
+
};
|
|
595
|
+
toJson(...args: any[]): string;
|
|
596
|
+
toString(): string;
|
|
597
|
+
fill(attributes: TGeneric): this;
|
|
598
|
+
transacting(trx: any): this;
|
|
599
|
+
trashed(): boolean;
|
|
600
|
+
getIncrementing(): boolean;
|
|
601
|
+
setIncrementing(value: boolean): this;
|
|
602
|
+
save(options?: TGeneric): Promise<boolean>;
|
|
603
|
+
update(attributes?: TGeneric, options?: TGeneric): Promise<boolean>;
|
|
604
|
+
delete(options?: {}): Promise<boolean>;
|
|
605
|
+
performDeleteOnModel(options?: TGeneric): Promise<void>;
|
|
606
|
+
setKeysForSaveQuery(query: any): any;
|
|
607
|
+
forceDelete(options?: {}): Promise<boolean>;
|
|
608
|
+
fresh(this: any): any;
|
|
609
|
+
refresh(this: any): Promise<any>;
|
|
610
|
+
newPivot<E extends Model>(parent: E, attributes: TGeneric, table: string, exists: boolean, using?: typeof Pivot$1 | null): Pivot$1;
|
|
611
|
+
qualifyColumn(column: string): string;
|
|
612
|
+
getQualifiedKeyName(): string;
|
|
613
|
+
push(options?: {}): Promise<boolean>;
|
|
614
|
+
is(model: any): any;
|
|
615
|
+
isNot(model: any): boolean;
|
|
616
|
+
}
|
|
617
|
+
declare class Pivot$1 extends Model {
|
|
618
|
+
incrementing: boolean;
|
|
619
|
+
guarded: never[];
|
|
620
|
+
pivotParent: Model | null;
|
|
621
|
+
foreignKey: string | null;
|
|
622
|
+
relatedKey: string | null;
|
|
623
|
+
setPivotKeys(foreignKey: string, relatedKey: string): this;
|
|
624
|
+
static fromRawAttributes<E extends Model>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot$1;
|
|
625
|
+
static fromAttributes<E extends Model>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot$1;
|
|
626
|
+
hasTimestampAttributes(this: any, attributes?: TGeneric | null): boolean;
|
|
627
|
+
}
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region types/generics.d.ts
|
|
620
630
|
type TGeneric<V = any, K extends string = string> = Record<K, V>;
|
|
621
631
|
type Hook = 'creating' | 'created' | 'updating' | 'updated' | 'saving' | 'saved' | 'deleting' | 'deleted' | 'restoring' | 'restored' | 'trashed' | 'forceDeleted';
|
|
622
632
|
type TFunction<TArgs extends any[] = any[], TReturn = any> = (...args: TArgs) => TReturn;
|
|
623
633
|
type PrimitiveValue = string | number | boolean | Date | string[] | number[] | boolean[] | Date[] | null | Buffer;
|
|
624
|
-
type ReturnTypeOfMethod<T, K extends keyof T> = T[K] extends (...args: any[]) => infer R ? R : never;
|
|
634
|
+
type ReturnTypeOfMethod<T, K extends keyof T> = T[K] extends ((...args: any[]) => infer R) ? R : never;
|
|
625
635
|
type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
|
|
626
636
|
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToSnakeCase<U>}` : `${Uncapitalize<T>}_${CamelToSnakeCase<U>}` : S;
|
|
627
|
-
type FunctionPropertyNames<T> = {
|
|
628
|
-
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
629
|
-
}[keyof T];
|
|
637
|
+
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
|
|
630
638
|
type RelationNames<T> = FunctionPropertyNames<T> extends infer R ? R extends `relation${infer P}` ? P extends ('sToData' | 'loaded') ? never : CamelToSnakeCase<P> : never : never;
|
|
631
639
|
type MixinConstructor<T = TGeneric> = new (...args: any[]) => T;
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
[x: number]: any;
|
|
655
|
-
[x: symbol]: any;
|
|
656
|
-
} | I)[];
|
|
657
|
-
toJson(...args: any[]): string;
|
|
658
|
-
[Symbol.iterator]: () => Iterator<I>;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
declare const BaseModel: (new (...args: any[]) => any) & {
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/browser/collection.d.ts
|
|
642
|
+
declare class Collection$2<I extends Model$1> extends Collection<I> {
|
|
643
|
+
mapThen(callback: TFunction): Promise<any[]>;
|
|
644
|
+
modelKeys(): any[];
|
|
645
|
+
contains<K, V>(key: keyof I | K | TFunction, value?: V): boolean;
|
|
646
|
+
diff(items: ICollection<any> | any[]): any;
|
|
647
|
+
except(keys: any[]): any;
|
|
648
|
+
intersect(items: I[]): any;
|
|
649
|
+
unique(key?: TFunction | keyof I, _strict?: boolean): any;
|
|
650
|
+
find(key: any, defaultValue?: null): any;
|
|
651
|
+
makeVisible(attributes: any): this;
|
|
652
|
+
makeHidden(attributes: any): this;
|
|
653
|
+
append(attributes: any): this;
|
|
654
|
+
only(keys: any[]): any;
|
|
655
|
+
getDictionary(items?: ICollection<any> | any[]): TGeneric;
|
|
656
|
+
toData(): ({
|
|
657
|
+
[x: string]: any;
|
|
658
|
+
[x: number]: any;
|
|
659
|
+
[x: symbol]: any;
|
|
660
|
+
} | I)[];
|
|
661
|
+
toJSON(): ({
|
|
662
662
|
[x: string]: any;
|
|
663
|
+
[x: number]: any;
|
|
664
|
+
[x: symbol]: any;
|
|
665
|
+
} | I)[];
|
|
666
|
+
toJson(...args: any[]): string;
|
|
667
|
+
[Symbol.iterator]: () => Iterator<I>;
|
|
668
|
+
}
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region src/browser/model.d.ts
|
|
671
|
+
declare const BaseModel: (new (...args: any[]) => any) & {
|
|
672
|
+
[x: string]: any;
|
|
663
673
|
};
|
|
664
|
-
declare class Model extends BaseModel {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
declare class Pivot extends Model {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
674
|
+
declare class Model$1 extends BaseModel {
|
|
675
|
+
protected primaryKey: string;
|
|
676
|
+
protected perPage: number;
|
|
677
|
+
static globalScopes: {};
|
|
678
|
+
static pluginInitializers: {};
|
|
679
|
+
static _booted: {};
|
|
680
|
+
static resolver: arquebus;
|
|
681
|
+
static browser: boolean;
|
|
682
|
+
connection: TBaseConfig['client'] | null;
|
|
683
|
+
constructor(attributes?: {});
|
|
684
|
+
static init(attributes?: {}): Model$1;
|
|
685
|
+
static extend(plugin: TFunction, options: TGeneric): void;
|
|
686
|
+
static make(attributes?: TGeneric): Model$1;
|
|
687
|
+
bootIfNotBooted(this: any): void;
|
|
688
|
+
static booting(): void;
|
|
689
|
+
static boot(): void;
|
|
690
|
+
static booted(): void;
|
|
691
|
+
static setConnectionResolver(resolver: arquebus): void;
|
|
692
|
+
initialize(): void;
|
|
693
|
+
initializePlugins(this: any): void;
|
|
694
|
+
addPluginInitializer(this: any, method: any): void;
|
|
695
|
+
newInstance(this: any, attributes?: TGeneric, exists?: boolean): any;
|
|
696
|
+
asProxy(): this;
|
|
697
|
+
getKey(): any;
|
|
698
|
+
getKeyName(): string;
|
|
699
|
+
getForeignKey(): string;
|
|
700
|
+
getConnectionName(): "mysql" | "mysql2" | "sqlite3" | "oracle" | "mariadb" | "pg" | null;
|
|
701
|
+
getTable(): any;
|
|
702
|
+
setConnection(connection: TBaseConfig['client']): this;
|
|
703
|
+
getKeyType(): any;
|
|
704
|
+
hasNamedScope(name: string): boolean;
|
|
705
|
+
callNamedScope(scope: string, parameters: any): any;
|
|
706
|
+
setTable(table: string): this;
|
|
707
|
+
newCollection(models?: never[]): Collection$2<never>;
|
|
708
|
+
getIncrementing(): any;
|
|
709
|
+
setIncrementing(value: boolean): this;
|
|
710
|
+
toData(): {
|
|
711
|
+
[x: string]: any;
|
|
712
|
+
[x: number]: any;
|
|
713
|
+
[x: symbol]: any;
|
|
714
|
+
};
|
|
715
|
+
toJSON(): {
|
|
716
|
+
[x: string]: any;
|
|
717
|
+
[x: number]: any;
|
|
718
|
+
[x: symbol]: any;
|
|
719
|
+
};
|
|
720
|
+
toJson(...args: any[]): string;
|
|
721
|
+
toString(): string;
|
|
722
|
+
fill(attributes: TGeneric): this;
|
|
723
|
+
transacting(trx: any): this;
|
|
724
|
+
trashed(): boolean;
|
|
725
|
+
newPivot<E extends Model$1>(parent: E, attributes: TGeneric, table: string, exists: boolean, using?: typeof Pivot | null): Pivot;
|
|
726
|
+
qualifyColumn(column: string): string;
|
|
727
|
+
getQualifiedKeyName(): string;
|
|
728
|
+
is(model: any): any;
|
|
729
|
+
isNot(model: any): boolean;
|
|
730
|
+
}
|
|
731
|
+
declare class Pivot extends Model$1 {
|
|
732
|
+
incrementing: boolean;
|
|
733
|
+
guarded: never[];
|
|
734
|
+
pivotParent: Model$1 | null;
|
|
735
|
+
foreignKey: string | null;
|
|
736
|
+
relatedKey: string | null;
|
|
737
|
+
setPivotKeys(foreignKey: string, relatedKey: string): this;
|
|
738
|
+
static fromRawAttributes<E extends Model$1>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot;
|
|
739
|
+
static fromAttributes<E extends Model$1>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot;
|
|
740
|
+
hasTimestampAttributes(this: any, attributes?: TGeneric | null): boolean;
|
|
741
|
+
}
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region types/utils.d.ts
|
|
744
|
+
interface ICollection<T extends Model | Model$1> extends Collection<T> {
|
|
745
|
+
items?: T[];
|
|
746
|
+
load(...relations: T[]): Promise<ICollection<T>>;
|
|
747
|
+
loadAggregate(relations: T | T[], column: string, action?: string | null): Promise<this>;
|
|
748
|
+
loadCount(relation: T, column: string): Promise<this>;
|
|
749
|
+
loadMax(relation: T, column: string): Promise<this>;
|
|
750
|
+
loadMin(relation: T, column: string): Promise<this>;
|
|
751
|
+
loadSum(relation: T, column: string): Promise<this>;
|
|
752
|
+
loadAvg(relation: T, column: string): Promise<this>;
|
|
753
|
+
mapThen(callback: () => void): Promise<any>;
|
|
754
|
+
modelKeys(): string[] | number[];
|
|
755
|
+
contains(key: IModel | any, operator?: any, value?: any): boolean;
|
|
756
|
+
diff(items: ICollection<T> | any[]): ICollection<T>;
|
|
757
|
+
except(keys: any[]): ICollection<T>;
|
|
758
|
+
intersect(items: T[]): ICollection<T>;
|
|
759
|
+
unique(key?: any, strict?: boolean): ICollection<T>;
|
|
760
|
+
find(key: any, defaultValue?: any): any;
|
|
761
|
+
fresh(withs?: any[]): Promise<ICollection<T>>;
|
|
762
|
+
makeVisible(attributes: string | string[]): this;
|
|
763
|
+
makeHidden(attributes: string | string[]): this;
|
|
764
|
+
append(attributes: string[]): this;
|
|
765
|
+
only(keys: null | any[]): this;
|
|
766
|
+
getDictionary(items?: any[]): TGeneric;
|
|
767
|
+
toQuery(): IBuilder<T, any>;
|
|
768
|
+
toData(): any;
|
|
769
|
+
toJSON(): any;
|
|
770
|
+
toJson(): string;
|
|
771
|
+
toString(): string;
|
|
772
|
+
[key: string]: any;
|
|
773
|
+
[Symbol.iterator]: () => Iterator<T>;
|
|
763
774
|
}
|
|
764
775
|
interface IPaginatorParams {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
interface IPaginator<T extends Model
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
};
|
|
776
|
+
current_page: number;
|
|
777
|
+
data: any[];
|
|
778
|
+
per_page: number;
|
|
779
|
+
total: number;
|
|
780
|
+
last_page: number;
|
|
781
|
+
count: number;
|
|
782
|
+
}
|
|
783
|
+
interface IPaginator<T extends Model | Model$1, K extends IPaginatorParams = IPaginatorParams> {
|
|
784
|
+
formatter?(paginator: IPaginator<any>): any | null;
|
|
785
|
+
setFormatter?(formatter: (paginator: IPaginator<any>) => any | null): void;
|
|
786
|
+
setItems(items: T[] | Collection$1<T>): void;
|
|
787
|
+
hasMorePages(): boolean;
|
|
788
|
+
get(index: number): T | null;
|
|
789
|
+
count(): number;
|
|
790
|
+
items(): Collection$1<T>;
|
|
791
|
+
map(callback: (value: T, index: number) => T): Collection$1<T>;
|
|
792
|
+
currentPage(): number;
|
|
793
|
+
perPage(): number;
|
|
794
|
+
lastPage(): number;
|
|
795
|
+
firstItem(): number | null;
|
|
796
|
+
lastItem(): number | null;
|
|
797
|
+
total(): number;
|
|
798
|
+
toData<U = K>(): U;
|
|
799
|
+
toJSON<U = K>(): U;
|
|
800
|
+
toJson(): string;
|
|
801
|
+
[Symbol.iterator]?(): {
|
|
802
|
+
next: () => {
|
|
803
|
+
value: T;
|
|
804
|
+
done: boolean;
|
|
795
805
|
};
|
|
806
|
+
};
|
|
796
807
|
}
|
|
797
|
-
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region types/builder.d.ts
|
|
798
810
|
interface IScope {
|
|
799
|
-
|
|
800
|
-
}
|
|
801
|
-
interface IBuilder<M extends Model
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
|
|
811
|
+
apply(builder: Builder<any>, model: Model): void;
|
|
812
|
+
}
|
|
813
|
+
interface IBuilder<M extends Model | Model$1, R = ICollection<M> | IModel> extends IQueryBuilder<M, R> {
|
|
814
|
+
asProxy(): IQueryBuilder<M, R>;
|
|
815
|
+
enforceOrderBy(): void;
|
|
816
|
+
insert(attributes: any): Promise<any>;
|
|
817
|
+
update(attributes: any): Promise<any>;
|
|
818
|
+
increment(column: string, amount?: number, extra?: any): Promise<any>;
|
|
819
|
+
decrement(column: string, amount?: number, extra?: any): Promise<any>;
|
|
820
|
+
addUpdatedAtColumn(values: any): any;
|
|
821
|
+
delete(): Promise<boolean | number>;
|
|
822
|
+
softDelete(): boolean | Promise<any>;
|
|
823
|
+
forceDelete(): boolean | Promise<any>;
|
|
824
|
+
restore(): boolean | Promise<any>;
|
|
825
|
+
withTrashed(): this;
|
|
826
|
+
withoutTrashed(): this;
|
|
827
|
+
onlyTrashed(): this;
|
|
828
|
+
getDeletedAtColumn(): string;
|
|
829
|
+
create(attributes?: any): Promise<M>;
|
|
830
|
+
newModelInstance(attributes?: any): M;
|
|
831
|
+
count(columns?: string): Promise<number>;
|
|
832
|
+
getQuery(): AnyQueryBuilder;
|
|
833
|
+
getModel(): M;
|
|
834
|
+
setModel(model: M): this;
|
|
835
|
+
setTable(table: string): this;
|
|
836
|
+
applyScopes(): this;
|
|
837
|
+
scopes(scopes: string[]): this;
|
|
838
|
+
withGlobalScope(identifier: string | number, scope: string | (() => void)): this;
|
|
839
|
+
withoutGlobalScope(scope: IScope | string): this;
|
|
840
|
+
with(relation: WithRelationType): this;
|
|
841
|
+
with(...relations: WithRelationType[]): this;
|
|
842
|
+
has(relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
|
|
843
|
+
orHas(relation: string, operator?: any, count?: number): this;
|
|
844
|
+
doesntHave(relation: string, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
|
|
845
|
+
orDoesntHave(relation: string): this;
|
|
846
|
+
whereHas(relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
|
|
847
|
+
orWhereHas(relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
|
|
848
|
+
whereRelation(relation: string, column: string, operator?: any, value?: any): this;
|
|
849
|
+
hasNested(relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
|
|
850
|
+
canUseExistsForExistenceCheck(operator: string, count: number): boolean;
|
|
851
|
+
addHasWhere(hasQuery: IBuilder<any>, relation: string, operator?: string, count?: number, boolean?: string): this;
|
|
852
|
+
withAggregate(relations: string | string[] | object, column: string, action?: string | null): this;
|
|
853
|
+
toSql(): object;
|
|
854
|
+
withCount(...relations: WithRelationType[]): this;
|
|
855
|
+
withMax(relation: WithRelationType, column: string): this;
|
|
856
|
+
withMin(relation: WithRelationType, column: string): this;
|
|
857
|
+
withAvg(relation: WithRelationType, column: string): this;
|
|
858
|
+
withSum(relation: WithRelationType, column: string): this;
|
|
859
|
+
withExists(relation: WithRelationType): this;
|
|
860
|
+
related(relation: string): this;
|
|
861
|
+
first(column?: string | string[]): Promise<M | null | undefined>;
|
|
862
|
+
firstOrFail(column?: string | string[]): Promise<M>;
|
|
863
|
+
findOrFail(key: string | number, columns?: string[]): Promise<M>;
|
|
864
|
+
findOrFail(key: string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
|
|
865
|
+
findOrFail(key: string | number | string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
|
|
866
|
+
findOrNew(id: string | number, columns?: string[]): Promise<M>;
|
|
867
|
+
firstOrNew(attributes?: object, values?: object): Promise<M>;
|
|
868
|
+
firstOrCreate(attributes?: object, values?: object): Promise<M>;
|
|
869
|
+
updateOrCreate(attributes: object, values?: object): Promise<M>;
|
|
870
|
+
latest(column?: string): this;
|
|
871
|
+
oldest(column?: string): this;
|
|
872
|
+
find(key: string | number, columns?: string[]): Promise<M | null | undefined>;
|
|
873
|
+
findMany(keys: string[] | number[] | ICollection<any>, columns?: string[]): Promise<ICollection<M>>;
|
|
874
|
+
pluck<X extends Model = any | M>(column: string): Promise<ICollection<X>>;
|
|
875
|
+
all(columns?: string[]): Promise<ICollection<M>>;
|
|
876
|
+
paginate<F extends IPaginatorParams>(page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
877
|
+
[value: string]: any;
|
|
878
|
+
}
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region types/query-methods.d.ts
|
|
868
881
|
type Operator = string;
|
|
869
882
|
type ColumnRef = string | Raw;
|
|
870
883
|
type FieldExpression = string;
|
|
@@ -872,489 +885,480 @@ type TableRef<QB extends AnyQueryBuilder> = ColumnRef | AnyQueryBuilder | Callba
|
|
|
872
885
|
type Selection<QB extends AnyQueryBuilder> = ColumnRef | AnyQueryBuilder | CallbackVoid<QB>;
|
|
873
886
|
type QBOrCallback<QB extends AnyQueryBuilder> = AnyQueryBuilder | CallbackVoid<QB>;
|
|
874
887
|
interface CallbackVoid<T> {
|
|
875
|
-
|
|
888
|
+
(this: T, arg: T): void;
|
|
876
889
|
}
|
|
877
|
-
type Raw = Knex
|
|
890
|
+
type Raw = Knex.Raw;
|
|
878
891
|
type OrderByDirection = 'asc' | 'desc' | 'ASC' | 'DESC';
|
|
879
892
|
interface OrderByDescriptor {
|
|
880
|
-
|
|
881
|
-
|
|
893
|
+
column: ColumnRef;
|
|
894
|
+
order?: OrderByDirection;
|
|
882
895
|
}
|
|
883
|
-
type AnyQueryBuilder<M extends Model
|
|
896
|
+
type AnyQueryBuilder<M extends Model = any, R = any> = IQueryBuilder<M, R> | IBuilder<M, R>;
|
|
884
897
|
type Expression<T> = T | Raw | AnyQueryBuilder;
|
|
885
898
|
type ColumnRefOrOrderByDescriptor = ColumnRef | OrderByDescriptor;
|
|
886
899
|
interface RawInterface<R> {
|
|
887
|
-
|
|
900
|
+
(sql: string, ...bindings: any[]): R;
|
|
888
901
|
}
|
|
889
902
|
interface BaseSetOperations<QB extends AnyQueryBuilder> {
|
|
890
|
-
|
|
891
|
-
|
|
903
|
+
(callbackOrBuilder: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
904
|
+
(callbacksOrBuilders: QBOrCallback<QB>[], wrap?: boolean): QB;
|
|
892
905
|
}
|
|
893
906
|
type JoinRawMethod<QB extends AnyQueryBuilder> = RawInterface<QB> & {};
|
|
894
907
|
type OrderByRawMethod<QB extends AnyQueryBuilder> = RawInterface<QB> & {};
|
|
895
908
|
type WhereRawMethod<QB extends AnyQueryBuilder> = RawInterface<QB> & {};
|
|
896
909
|
interface GroupByMethod<QB extends AnyQueryBuilder> {
|
|
897
|
-
|
|
898
|
-
|
|
910
|
+
(...columns: ColumnRef[]): QB;
|
|
911
|
+
(columns: ColumnRef[]): QB;
|
|
899
912
|
}
|
|
900
913
|
type WithRelationType = {
|
|
901
|
-
|
|
914
|
+
[key: string]: <T extends IBuilder<any>>(builder: T) => T | void;
|
|
902
915
|
} | string | string[];
|
|
903
916
|
interface SetOperationsMethod<QB extends AnyQueryBuilder> extends BaseSetOperations<QB> {
|
|
904
|
-
|
|
917
|
+
(...callbacksOrBuilders: QBOrCallback<QB>[]): QB;
|
|
905
918
|
}
|
|
906
919
|
interface SelectMethod<QB extends AnyQueryBuilder> {
|
|
907
|
-
|
|
908
|
-
|
|
920
|
+
<QBP extends QB>(...columns: Selection<QBP>[]): QB;
|
|
921
|
+
<QBP extends QB>(columns: Selection<QBP>[]): QB;
|
|
909
922
|
}
|
|
910
923
|
interface WhereMethod<QB extends AnyQueryBuilder> {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
924
|
+
(col: ColumnRef, op: Operator, expr: Expression<PrimitiveValue>): QB;
|
|
925
|
+
(col: ColumnRef, expr: Expression<PrimitiveValue>): QB;
|
|
926
|
+
(condition: boolean): QB;
|
|
927
|
+
(cb: CallbackVoid<QB>): QB;
|
|
928
|
+
(raw: Raw): QB;
|
|
929
|
+
<QBA extends AnyQueryBuilder>(qb: QBA): QB;
|
|
930
|
+
(obj: object): QB;
|
|
918
931
|
}
|
|
919
932
|
interface WhereWrappedMethod<QB extends AnyQueryBuilder> {
|
|
920
|
-
|
|
933
|
+
(cb: CallbackVoid<QB>): QB;
|
|
921
934
|
}
|
|
922
935
|
interface WhereFieldExpressionMethod<QB extends AnyQueryBuilder> {
|
|
923
|
-
|
|
936
|
+
(fieldExpression: FieldExpression): QB;
|
|
924
937
|
}
|
|
925
938
|
interface WhereExistsMethod<QB extends AnyQueryBuilder> {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
939
|
+
(cb: CallbackVoid<QB>): QB;
|
|
940
|
+
(raw: Raw): QB;
|
|
941
|
+
<QBA extends AnyQueryBuilder>(qb: QBA): QB;
|
|
929
942
|
}
|
|
930
943
|
interface WhereInMethod<QB extends AnyQueryBuilder> {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
944
|
+
(col: ColumnRef | ColumnRef[], expr: Expression<PrimitiveValue>[]): QB;
|
|
945
|
+
(col: ColumnRef | ColumnRef[], cb: CallbackVoid<QB>): QB;
|
|
946
|
+
(col: ColumnRef | ColumnRef[], qb: AnyQueryBuilder): QB;
|
|
934
947
|
}
|
|
935
948
|
interface WhereBetweenMethod<QB extends AnyQueryBuilder> {
|
|
936
|
-
|
|
949
|
+
(column: ColumnRef, range: [Expression<PrimitiveValue>, Expression<PrimitiveValue>]): QB;
|
|
937
950
|
}
|
|
938
951
|
interface WhereNullMethod<QB extends AnyQueryBuilder> {
|
|
939
|
-
|
|
952
|
+
(column: ColumnRef): QB;
|
|
940
953
|
}
|
|
941
954
|
interface OrderByMethod<QB extends AnyQueryBuilder> {
|
|
942
|
-
|
|
943
|
-
|
|
955
|
+
(column: ColumnRef, order?: OrderByDirection): QB;
|
|
956
|
+
(columns: ColumnRefOrOrderByDescriptor[]): QB;
|
|
944
957
|
}
|
|
945
958
|
interface WhereJsonExpressionMethod<QB extends AnyQueryBuilder> {
|
|
946
|
-
|
|
959
|
+
(fieldExpression: FieldExpression, keys: string | string[]): QB;
|
|
947
960
|
}
|
|
948
961
|
interface WhereColumnMethod<QB extends AnyQueryBuilder> {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
}
|
|
952
|
-
interface UnionMethod<QB extends AnyQueryBuilder> extends BaseSetOperations<QB> {
|
|
953
|
-
(arg1: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
954
|
-
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
955
|
-
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
956
|
-
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
957
|
-
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
958
|
-
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, arg6: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
959
|
-
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, arg6: QBOrCallback<QB>, arg7: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
962
|
+
(col1: ColumnRef, op: Operator, col2: ColumnRef): QB;
|
|
963
|
+
(col1: ColumnRef, col2: ColumnRef): QB;
|
|
960
964
|
}
|
|
961
965
|
interface JoinMethod<QB extends AnyQueryBuilder> {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
966
|
+
(table: TableRef<QB>, leftCol: ColumnRef, op: Operator, rightCol: ColumnRef): QB;
|
|
967
|
+
(table: TableRef<QB>, leftCol: ColumnRef, rightCol: ColumnRef): QB;
|
|
968
|
+
(table: TableRef<QB>, cb: CallbackVoid<Knex.JoinClause>): QB;
|
|
969
|
+
(table: TableRef<QB>, raw: Raw): QB;
|
|
970
|
+
(raw: Raw): QB;
|
|
971
|
+
}
|
|
972
|
+
interface UnionMethod<QB extends AnyQueryBuilder> extends BaseSetOperations<QB> {
|
|
973
|
+
(arg1: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
974
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
975
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
976
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
977
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
978
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, arg6: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
979
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, arg6: QBOrCallback<QB>, arg7: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
967
980
|
}
|
|
968
981
|
interface JoinMethod<QB extends AnyQueryBuilder> {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
982
|
+
(table: TableRef<QB>, leftCol: ColumnRef, op: Operator, rightCol: ColumnRef): QB;
|
|
983
|
+
(table: TableRef<QB>, leftCol: ColumnRef, rightCol: ColumnRef): QB;
|
|
984
|
+
(table: TableRef<QB>, cb: CallbackVoid<Knex.JoinClause>): QB;
|
|
985
|
+
(table: TableRef<QB>, raw: Raw): QB;
|
|
986
|
+
(raw: Raw): QB;
|
|
974
987
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region types/query-builder.d.ts
|
|
990
|
+
interface SchemaBuilder extends Knex.SchemaBuilder {
|
|
991
|
+
[k: string]: any;
|
|
978
992
|
}
|
|
979
993
|
interface AsMethod<QB extends AnyQueryBuilder> {
|
|
980
|
-
|
|
994
|
+
(alias: string): QB;
|
|
981
995
|
}
|
|
982
996
|
interface IStatement {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
interface IQueryBuilder<M extends Model
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
}
|
|
1113
|
-
|
|
997
|
+
grouping: string;
|
|
998
|
+
direction: string;
|
|
999
|
+
type: string;
|
|
1000
|
+
value: () => any;
|
|
1001
|
+
not: boolean;
|
|
1002
|
+
nulls: boolean;
|
|
1003
|
+
bool: 'and' | 'or' | 'not';
|
|
1004
|
+
}
|
|
1005
|
+
interface IQueryBuilder<M extends Model | Model$1 = Model, R = M[] | M> {
|
|
1006
|
+
schema: SchemaBuilder;
|
|
1007
|
+
_statements: IStatement[];
|
|
1008
|
+
table(name: string): IQueryBuilder<M, R>;
|
|
1009
|
+
select: SelectMethod<this>;
|
|
1010
|
+
columns: SelectMethod<this>;
|
|
1011
|
+
column: SelectMethod<this>;
|
|
1012
|
+
distinct: SelectMethod<this>;
|
|
1013
|
+
distinctOn: SelectMethod<this>;
|
|
1014
|
+
as: AsMethod<this>;
|
|
1015
|
+
asProxy(): IQueryBuilder<M, R>;
|
|
1016
|
+
where: WhereMethod<this>;
|
|
1017
|
+
andWhere: WhereMethod<this>;
|
|
1018
|
+
orWhere(...args: any[]): this;
|
|
1019
|
+
whereNot: WhereMethod<this>;
|
|
1020
|
+
andWhereNot: WhereMethod<this>;
|
|
1021
|
+
orWhereNot: WhereMethod<this>;
|
|
1022
|
+
whereRaw: WhereRawMethod<this>;
|
|
1023
|
+
orWhereRaw: WhereRawMethod<this>;
|
|
1024
|
+
andWhereRaw: WhereRawMethod<this>;
|
|
1025
|
+
whereWrapped: WhereWrappedMethod<this>;
|
|
1026
|
+
havingWrapped: WhereWrappedMethod<this>;
|
|
1027
|
+
whereExists: WhereExistsMethod<this>;
|
|
1028
|
+
orWhereExists: WhereExistsMethod<this>;
|
|
1029
|
+
whereNotExists: WhereExistsMethod<this>;
|
|
1030
|
+
orWhereNotExists: WhereExistsMethod<this>;
|
|
1031
|
+
whereIn: WhereInMethod<this>;
|
|
1032
|
+
orWhereIn: WhereInMethod<this>;
|
|
1033
|
+
whereNotIn: WhereInMethod<this>;
|
|
1034
|
+
orWhereNotIn: WhereInMethod<this>;
|
|
1035
|
+
whereBetween: WhereBetweenMethod<this>;
|
|
1036
|
+
orWhereBetween: WhereBetweenMethod<this>;
|
|
1037
|
+
andWhereBetween: WhereBetweenMethod<this>;
|
|
1038
|
+
whereNotBetween: WhereBetweenMethod<this>;
|
|
1039
|
+
orWhereNotBetween: WhereBetweenMethod<this>;
|
|
1040
|
+
andWhereNotBetween: WhereBetweenMethod<this>;
|
|
1041
|
+
whereNull: WhereNullMethod<this>;
|
|
1042
|
+
orWhereNull: WhereNullMethod<this>;
|
|
1043
|
+
whereNotNull: WhereNullMethod<this>;
|
|
1044
|
+
orWhereNotNull: WhereNullMethod<this>;
|
|
1045
|
+
whereColumn: WhereColumnMethod<this>;
|
|
1046
|
+
orWhereColumn: WhereColumnMethod<this>;
|
|
1047
|
+
andWhereColumn: WhereColumnMethod<this>;
|
|
1048
|
+
whereNotColumn: WhereColumnMethod<this>;
|
|
1049
|
+
orWhereNotColumn: WhereColumnMethod<this>;
|
|
1050
|
+
andWhereNotColumn: WhereColumnMethod<this>;
|
|
1051
|
+
whereJsonIsArray: WhereFieldExpressionMethod<this>;
|
|
1052
|
+
orWhereJsonIsArray: WhereFieldExpressionMethod<this>;
|
|
1053
|
+
whereJsonNotArray: WhereFieldExpressionMethod<this>;
|
|
1054
|
+
orWhereJsonNotArray: WhereFieldExpressionMethod<this>;
|
|
1055
|
+
whereJsonIsObject: WhereFieldExpressionMethod<this>;
|
|
1056
|
+
orWhereJsonIsObject: WhereFieldExpressionMethod<this>;
|
|
1057
|
+
whereJsonNotObject: WhereFieldExpressionMethod<this>;
|
|
1058
|
+
orWhereJsonNotObject: WhereFieldExpressionMethod<this>;
|
|
1059
|
+
whereJsonHasAny: WhereJsonExpressionMethod<this>;
|
|
1060
|
+
orWhereJsonHasAny: WhereJsonExpressionMethod<this>;
|
|
1061
|
+
whereJsonHasAll: WhereJsonExpressionMethod<this>;
|
|
1062
|
+
orWhereJsonHasAll: WhereJsonExpressionMethod<this>;
|
|
1063
|
+
having: WhereMethod<this>;
|
|
1064
|
+
andHaving: WhereMethod<this>;
|
|
1065
|
+
orHaving: WhereMethod<this>;
|
|
1066
|
+
havingRaw: WhereRawMethod<this>;
|
|
1067
|
+
orHavingRaw: WhereRawMethod<this>;
|
|
1068
|
+
havingIn: WhereInMethod<this>;
|
|
1069
|
+
orHavingIn: WhereInMethod<this>;
|
|
1070
|
+
havingNotIn: WhereInMethod<this>;
|
|
1071
|
+
orHavingNotIn: WhereInMethod<this>;
|
|
1072
|
+
havingNull: WhereNullMethod<this>;
|
|
1073
|
+
orHavingNull: WhereNullMethod<this>;
|
|
1074
|
+
havingNotNull: WhereNullMethod<this>;
|
|
1075
|
+
orHavingNotNull: WhereNullMethod<this>;
|
|
1076
|
+
havingExists: WhereExistsMethod<this>;
|
|
1077
|
+
orHavingExists: WhereExistsMethod<this>;
|
|
1078
|
+
havingNotExists: WhereExistsMethod<this>;
|
|
1079
|
+
orHavingNotExists: WhereExistsMethod<this>;
|
|
1080
|
+
havingBetween: WhereBetweenMethod<this>;
|
|
1081
|
+
orHavingBetween: WhereBetweenMethod<this>;
|
|
1082
|
+
havingNotBetween: WhereBetweenMethod<this>;
|
|
1083
|
+
orHavingNotBetween: WhereBetweenMethod<this>;
|
|
1084
|
+
union: UnionMethod<this>;
|
|
1085
|
+
unionAll: UnionMethod<this>;
|
|
1086
|
+
intersect: SetOperationsMethod<this>;
|
|
1087
|
+
join: JoinMethod<this>;
|
|
1088
|
+
joinRaw: JoinRawMethod<this>;
|
|
1089
|
+
innerJoin: JoinMethod<this>;
|
|
1090
|
+
leftJoin: JoinMethod<this>;
|
|
1091
|
+
leftOuterJoin: JoinMethod<this>;
|
|
1092
|
+
rightJoin: JoinMethod<this>;
|
|
1093
|
+
rightOuterJoin: JoinMethod<this>;
|
|
1094
|
+
outerJoin: JoinMethod<this>;
|
|
1095
|
+
fullOuterJoin: JoinMethod<this>;
|
|
1096
|
+
crossJoin: JoinMethod<this>;
|
|
1097
|
+
orderBy: OrderByMethod<this>;
|
|
1098
|
+
orderByRaw: OrderByRawMethod<this>;
|
|
1099
|
+
groupBy: GroupByMethod<this>;
|
|
1100
|
+
groupByRaw: RawInterface<this>;
|
|
1101
|
+
transaction(callback?: TFunction): Promise<Knex.Transaction> | undefined;
|
|
1102
|
+
destroy(callback: TFunction): Promise<number>;
|
|
1103
|
+
destroy(): Promise<number>;
|
|
1104
|
+
clone(): IQueryBuilder<M, R>;
|
|
1105
|
+
raw: Knex.RawQueryBuilder<TGeneric, M>;
|
|
1106
|
+
get(columns?: string[]): Promise<any>;
|
|
1107
|
+
first(columns?: string[]): Promise<M | null | undefined>;
|
|
1108
|
+
find(key: string | number, columns?: string[]): Promise<M | null | undefined>;
|
|
1109
|
+
insert(attributes: any): Promise<unknown>;
|
|
1110
|
+
update(...attributes: any[]): Promise<number>;
|
|
1111
|
+
delete(): Promise<boolean | number>;
|
|
1112
|
+
exists(): Promise<boolean>;
|
|
1113
|
+
count(column?: string): Promise<number>;
|
|
1114
|
+
min(column: string): Promise<number>;
|
|
1115
|
+
max(column: string): Promise<number>;
|
|
1116
|
+
sum(column: string): Promise<number>;
|
|
1117
|
+
avg(column: string): Promise<number>;
|
|
1118
|
+
skip(count: number): this;
|
|
1119
|
+
take(count: number): this;
|
|
1120
|
+
limit(count: number): this;
|
|
1121
|
+
offset(count: number): this;
|
|
1122
|
+
pluck<X extends Model = any>(column: string): Promise<ICollection<X>>;
|
|
1123
|
+
chunk(count: number, callback: (rows: M[]) => any): Promise<boolean>;
|
|
1124
|
+
forPage(page: number, perPage?: number): this;
|
|
1125
|
+
paginate<F extends IPaginatorParams>(page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
1126
|
+
}
|
|
1127
|
+
//#endregion
|
|
1128
|
+
//#region src/query-builder.d.ts
|
|
1114
1129
|
declare const Inference$1: {
|
|
1115
|
-
|
|
1130
|
+
new <M extends Model = Model, R = M[] | M>(): IQueryBuilder<M, R>;
|
|
1116
1131
|
};
|
|
1117
|
-
declare class QueryBuilder<M extends Model
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1132
|
+
declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inference$1<M, R> {
|
|
1133
|
+
model: M;
|
|
1134
|
+
schema: SchemaBuilder;
|
|
1135
|
+
private connector;
|
|
1136
|
+
constructor(config: TConfig | null, connector: TFunction);
|
|
1137
|
+
asProxy(): any;
|
|
1138
|
+
beginTransaction(): Promise<Knex.Transaction<any, any[]> | undefined>;
|
|
1139
|
+
table<X extends M>(table: string): IQueryBuilder<X, R>;
|
|
1140
|
+
transaction(callback?: TFunction): Promise<Knex.Transaction> | undefined;
|
|
1141
|
+
find(id: string | number, columns?: string[]): Promise<any>;
|
|
1142
|
+
get(_columns?: string[]): Promise<any>;
|
|
1143
|
+
exists(): Promise<boolean>;
|
|
1144
|
+
skip(this: any, ...args: any[]): any;
|
|
1145
|
+
take(this: any, ...args: any[]): any;
|
|
1146
|
+
chunk(count: number, callback: TFunction): Promise<boolean>;
|
|
1147
|
+
paginate<F extends IPaginatorParams>(this: any, page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
1148
|
+
forPage(this: any, page?: number, perPage?: number): any;
|
|
1149
|
+
toSQL(...args: Parameters<typeof (void 0).connector.toSQL>): Knex.Sql;
|
|
1150
|
+
count(column: string): Promise<number>;
|
|
1151
|
+
min(column: string): Promise<number>;
|
|
1152
|
+
max(column: string): Promise<number>;
|
|
1153
|
+
sum(column: string): Promise<number>;
|
|
1154
|
+
avg(column: string): Promise<number>;
|
|
1155
|
+
clone(): IQueryBuilder<M, R>;
|
|
1156
|
+
delete(): Promise<number | boolean>;
|
|
1157
|
+
insert(...args: Parameters<typeof (void 0).connector.insert>): Promise<unknown>;
|
|
1158
|
+
update(...args: Parameters<typeof (void 0).connector.update>): Promise<number>;
|
|
1159
|
+
destroy(...args: Parameters<typeof (void 0).connector.destroy>): Promise<number>;
|
|
1160
|
+
get _statements(): IStatement[] & any[];
|
|
1161
|
+
get _single(): any;
|
|
1162
|
+
get from(): Knex.Table<any, any>;
|
|
1163
|
+
}
|
|
1164
|
+
declare namespace migration_d_exports {
|
|
1165
|
+
export { IMigration, Migration, Migration as default };
|
|
1148
1166
|
}
|
|
1149
|
-
|
|
1150
1167
|
interface IMigration {
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1168
|
+
withinTransaction?: boolean;
|
|
1169
|
+
up(schema: SchemaBuilder, connection?: QueryBuilder): Promise<any>;
|
|
1170
|
+
down(schema: SchemaBuilder, connection?: QueryBuilder): Promise<any>;
|
|
1171
|
+
getConnection(): TBaseConfig['client'];
|
|
1155
1172
|
}
|
|
1156
1173
|
declare const Inference: {
|
|
1157
|
-
|
|
1174
|
+
new (): IMigration;
|
|
1158
1175
|
};
|
|
1159
1176
|
declare class Migration extends Inference {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1177
|
+
protected connection: TBaseConfig['client'];
|
|
1178
|
+
withinTransaction: boolean;
|
|
1179
|
+
getConnection(): TBaseConfig['client'];
|
|
1163
1180
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
type migration_Migration = Migration;
|
|
1167
|
-
declare const migration_Migration: typeof Migration;
|
|
1168
|
-
declare namespace migration {
|
|
1169
|
-
export { type migration_IMigration as IMigration, migration_Migration as Migration, Migration as default };
|
|
1181
|
+
declare namespace migration_repository_d_exports {
|
|
1182
|
+
export { MigrationRepository as default };
|
|
1170
1183
|
}
|
|
1171
|
-
|
|
1172
1184
|
declare class MigrationRepository {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1185
|
+
resolver: typeof arquebus;
|
|
1186
|
+
table: string;
|
|
1187
|
+
connection: TBaseConfig['client'] | null;
|
|
1188
|
+
constructor(resolver: typeof arquebus, table: string);
|
|
1189
|
+
getRan(): Promise<ICollection<any>>;
|
|
1190
|
+
getMigrations(steps: number): Promise<any>;
|
|
1191
|
+
getMigrationsByBatch(batch: number): Promise<any>;
|
|
1192
|
+
getLast(): Promise<any>;
|
|
1193
|
+
getMigrationBatches(): Promise<TGeneric>;
|
|
1194
|
+
log(file: string, batch: number): Promise<void>;
|
|
1195
|
+
delete(migration: TGeneric): Promise<void>;
|
|
1196
|
+
getNextBatchNumber(): Promise<number>;
|
|
1197
|
+
getLastBatchNumber(): Promise<number>;
|
|
1198
|
+
createRepository(): Promise<void>;
|
|
1199
|
+
repositoryExists(): Promise<boolean>;
|
|
1200
|
+
deleteRepository(): Promise<void>;
|
|
1201
|
+
getTable(): IQueryBuilder<Model, Model | Model[]>;
|
|
1202
|
+
getConnection(): QueryBuilder<Model, Model | Model[]>;
|
|
1203
|
+
setSource(name: TBaseConfig['client']): void;
|
|
1204
|
+
}
|
|
1205
|
+
declare namespace migrator_d_exports {
|
|
1206
|
+
export { MigrationOptions, Migrator as default };
|
|
1192
1207
|
}
|
|
1193
|
-
|
|
1194
|
-
declare namespace migrationRepository {
|
|
1195
|
-
export { MigrationRepository as default };
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
1208
|
interface MigrationOptions {
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1209
|
+
pretend?: boolean;
|
|
1210
|
+
step?: number;
|
|
1211
|
+
batch?: number;
|
|
1202
1212
|
}
|
|
1203
1213
|
declare class Migrator {
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
declare namespace migrator {
|
|
1252
|
-
export { type migrator_MigrationOptions as MigrationOptions, Migrator as default };
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1214
|
+
events: any;
|
|
1215
|
+
repository: MigrationRepository;
|
|
1216
|
+
files: any;
|
|
1217
|
+
resolver: typeof arquebus;
|
|
1218
|
+
connection: TBaseConfig['client'];
|
|
1219
|
+
paths: string[];
|
|
1220
|
+
output: boolean | null;
|
|
1221
|
+
constructor(repository: MigrationRepository, resolver?: typeof arquebus | null, files?: any, dispatcher?: any);
|
|
1222
|
+
run(paths?: string[], options?: MigrationOptions): Promise<string[]>;
|
|
1223
|
+
pendingMigrations(files: Record<string, string>, ran: string[]): string[];
|
|
1224
|
+
runPending(migrations: string[], options?: MigrationOptions): Promise<void>;
|
|
1225
|
+
runUp(file: string, batch: number, _pretend: boolean): Promise<void>;
|
|
1226
|
+
runDown(file: string, migration: {
|
|
1227
|
+
migration: string;
|
|
1228
|
+
}, _pretend: boolean): Promise<void>;
|
|
1229
|
+
rollback(paths?: string[], options?: MigrationOptions): Promise<string[]>;
|
|
1230
|
+
getMigrationsForRollback(options: MigrationOptions): Promise<{
|
|
1231
|
+
migration: string;
|
|
1232
|
+
}[]>;
|
|
1233
|
+
rollbackMigrations(migrations: {
|
|
1234
|
+
migration: string;
|
|
1235
|
+
}[], paths: string[], options: MigrationOptions): Promise<string[]>;
|
|
1236
|
+
reset(_paths?: string[], _pretend?: boolean): Promise<string[]> | string[];
|
|
1237
|
+
resetMigrations(migrations: {
|
|
1238
|
+
migration: string;
|
|
1239
|
+
}[], paths: string[], pretend?: boolean): Promise<string[]>;
|
|
1240
|
+
runMigration(migration: IMigration, method: 'up' | 'down'): Promise<void>;
|
|
1241
|
+
runMethod(connection: QueryBuilder, migration: IMigration, method: 'up' | 'down'): Promise<void>;
|
|
1242
|
+
resolvePath(filePath: string): Promise<IMigration>;
|
|
1243
|
+
getMigrationClass(migrationName: string): string;
|
|
1244
|
+
getMigrationFiles(paths: string[]): Promise<Record<string, string>>;
|
|
1245
|
+
getMigrationName(filePath: string): string;
|
|
1246
|
+
path(p: string): void;
|
|
1247
|
+
getPaths(): string[];
|
|
1248
|
+
getConnection(): TBaseConfig['client'];
|
|
1249
|
+
resolveConnection(connection?: TBaseConfig['client']): any;
|
|
1250
|
+
getRepository(): MigrationRepository;
|
|
1251
|
+
repositoryExists(): Promise<boolean>;
|
|
1252
|
+
hasRunAnyMigrations(): Promise<boolean>;
|
|
1253
|
+
deleteRepository(): void;
|
|
1254
|
+
setOutput(output: boolean): this;
|
|
1255
|
+
write(...args: any[]): void;
|
|
1256
|
+
writeTwoColumns(name: string, ...args: string[]): void;
|
|
1257
|
+
writeTask(description: string, task: () => Promise<any> | any): Promise<void>;
|
|
1258
|
+
}
|
|
1259
|
+
//#endregion
|
|
1260
|
+
//#region src/migrate.d.ts
|
|
1255
1261
|
interface MigrationStatus {
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1262
|
+
name: string;
|
|
1263
|
+
ran: boolean;
|
|
1264
|
+
batch: number | null;
|
|
1259
1265
|
}
|
|
1260
1266
|
interface MigrateOptions {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1267
|
+
path?: string;
|
|
1268
|
+
step?: number;
|
|
1269
|
+
pretend?: boolean;
|
|
1270
|
+
batch?: number;
|
|
1265
1271
|
}
|
|
1266
1272
|
type TXBaseConfig<S = boolean> = (S extends true ? Partial<TBaseConfig> : TBaseConfig) & {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1273
|
+
/**
|
|
1274
|
+
* Set this to true if you already have an active connection and dont want to create a new one
|
|
1275
|
+
*/
|
|
1276
|
+
skipConnection?: S;
|
|
1271
1277
|
};
|
|
1272
1278
|
interface TCallback {
|
|
1273
|
-
|
|
1279
|
+
(message: string, status?: 'success' | 'error' | 'info' | 'quiet'): void;
|
|
1274
1280
|
}
|
|
1275
1281
|
declare class Migrate {
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
declare class MigrationCreator {
|
|
1324
|
-
private customStubPath?;
|
|
1325
|
-
private type;
|
|
1326
|
-
private postCreate;
|
|
1327
|
-
constructor(customStubPath?: string | undefined, type?: 'ts' | 'js');
|
|
1328
|
-
/**
|
|
1329
|
-
* Create a new migration file
|
|
1330
|
-
*
|
|
1331
|
-
* @param name
|
|
1332
|
-
* @param dir
|
|
1333
|
-
* @param table
|
|
1334
|
-
* @param create
|
|
1335
|
-
* @returns
|
|
1336
|
-
*/
|
|
1337
|
-
create(name: string, dir: string, table: string, create?: boolean): Promise<string>;
|
|
1338
|
-
/**
|
|
1339
|
-
* Publish migrations from third party vendors
|
|
1340
|
-
*
|
|
1341
|
-
* @param dir
|
|
1342
|
-
* @param callback
|
|
1343
|
-
*/
|
|
1344
|
-
publish(dir: string, callback?: (name: string, source: string, dest: string) => void): Promise<void>;
|
|
1345
|
-
getStub(table?: string, create?: boolean): string;
|
|
1346
|
-
populateStub(stub: string, table: string): string;
|
|
1347
|
-
getClassName(name: string): string;
|
|
1348
|
-
getPath(name: string, dir: string): string;
|
|
1349
|
-
firePostCreateHooks(table: string, filePath: string): Promise<void>;
|
|
1350
|
-
afterCreate(callback: TFunction): void;
|
|
1351
|
-
ensureDirectoryExists(dir: string): Promise<void>;
|
|
1352
|
-
stubPath(stub?: string): string;
|
|
1353
|
-
getDirname(meta: ImportMeta | null): string;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
declare namespace migrationCreator {
|
|
1282
|
+
private basePath?;
|
|
1283
|
+
private customStubPath?;
|
|
1284
|
+
private callback;
|
|
1285
|
+
constructor(basePath?: string | undefined, customStubPath?: string | undefined, callback?: TCallback);
|
|
1286
|
+
/**
|
|
1287
|
+
* Runs all pending migrations
|
|
1288
|
+
*
|
|
1289
|
+
* @param config
|
|
1290
|
+
* @param options
|
|
1291
|
+
* @param destroyAll
|
|
1292
|
+
*/
|
|
1293
|
+
run(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Rollback the last migration
|
|
1296
|
+
*
|
|
1297
|
+
* @param config
|
|
1298
|
+
* @param options
|
|
1299
|
+
* @param destroyAll
|
|
1300
|
+
*/
|
|
1301
|
+
rollback(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1302
|
+
/**
|
|
1303
|
+
* Prepares the database for migration
|
|
1304
|
+
*
|
|
1305
|
+
* @param migrator
|
|
1306
|
+
*/
|
|
1307
|
+
prepareDatabase(migrator: Migrator): Promise<void>;
|
|
1308
|
+
/**
|
|
1309
|
+
* Check the status of available migrations
|
|
1310
|
+
*
|
|
1311
|
+
* @param config
|
|
1312
|
+
* @param options
|
|
1313
|
+
* @param destroyAll
|
|
1314
|
+
* @returns
|
|
1315
|
+
*/
|
|
1316
|
+
status(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<MigrationStatus[]>;
|
|
1317
|
+
/**
|
|
1318
|
+
* Setup the database connection
|
|
1319
|
+
*
|
|
1320
|
+
* @param config
|
|
1321
|
+
* @returns
|
|
1322
|
+
*/
|
|
1323
|
+
setupConnection(config: TXBaseConfig): Promise<{
|
|
1324
|
+
arquebus: typeof arquebus;
|
|
1325
|
+
migrator: Migrator;
|
|
1326
|
+
}>;
|
|
1327
|
+
}
|
|
1328
|
+
declare namespace migration_creator_d_exports {
|
|
1357
1329
|
export { MigrationCreator as default };
|
|
1358
1330
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1331
|
+
declare class MigrationCreator {
|
|
1332
|
+
private customStubPath?;
|
|
1333
|
+
private type;
|
|
1334
|
+
private postCreate;
|
|
1335
|
+
constructor(customStubPath?: string | undefined, type?: 'ts' | 'js');
|
|
1336
|
+
/**
|
|
1337
|
+
* Create a new migration file
|
|
1338
|
+
*
|
|
1339
|
+
* @param name
|
|
1340
|
+
* @param dir
|
|
1341
|
+
* @param table
|
|
1342
|
+
* @param create
|
|
1343
|
+
* @returns
|
|
1344
|
+
*/
|
|
1345
|
+
create(name: string, dir: string, table: string, create?: boolean): Promise<string>;
|
|
1346
|
+
/**
|
|
1347
|
+
* Publish migrations from third party vendors
|
|
1348
|
+
*
|
|
1349
|
+
* @param dir
|
|
1350
|
+
* @param callback
|
|
1351
|
+
*/
|
|
1352
|
+
publish(dir: string, callback?: (name: string, source: string, dest: string) => void): Promise<void>;
|
|
1353
|
+
getStub(table?: string, create?: boolean): string;
|
|
1354
|
+
populateStub(stub: string, table: string): string;
|
|
1355
|
+
getClassName(name: string): string;
|
|
1356
|
+
getPath(name: string, dir: string): string;
|
|
1357
|
+
firePostCreateHooks(table: string, filePath: string): Promise<void>;
|
|
1358
|
+
afterCreate(callback: TFunction): void;
|
|
1359
|
+
ensureDirectoryExists(dir: string): Promise<void>;
|
|
1360
|
+
stubPath(stub?: string): string;
|
|
1361
|
+
getDirname(meta: ImportMeta | null): string;
|
|
1362
|
+
}
|
|
1363
|
+
//#endregion
|
|
1364
|
+
export { Migrate, migration_d_exports as Migration, migration_creator_d_exports as MigrationCreator, migration_repository_d_exports as MigrationRepository, migrator_d_exports as Migrator };
|