@h3ravel/arquebus 0.3.1 → 0.3.2

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