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