@h3ravel/arquebus 0.3.1 → 0.3.3

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