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