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