@h3ravel/arquebus 0.3.0 → 0.3.2

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