@h3ravel/arquebus 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.cjs +4382 -1
- package/bin/index.d.cts +1 -1
- package/bin/index.d.ts +1 -1
- package/bin/index.js +4346 -1
- package/dist/browser/index.cjs +1269 -1
- package/dist/browser/index.d.cts +1222 -1202
- package/dist/browser/index.d.ts +1222 -1202
- package/dist/browser/index.js +1217 -1
- package/dist/index.cjs +4141 -1
- package/dist/index.d.cts +1305 -1280
- package/dist/index.d.ts +1305 -1280
- package/dist/index.js +4076 -1
- package/dist/migrations/chunk-PECeCxCb.js +15 -0
- package/dist/migrations/index.cjs +4024 -1
- package/dist/migrations/index.d.cts +1249 -1243
- package/dist/migrations/index.d.ts +1246 -1243
- package/dist/migrations/index.js +3954 -1
- package/package.json +4 -3
- package/bin/cli.cjs +0 -4942
- package/bin/cli.d.cts +0 -18
- package/bin/cli.d.ts +0 -18
- package/bin/cli.js +0 -4907
- package/bin/utils.js +0 -141
- /package/{bin → dist}/migrations/stubs/migration-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration-ts.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.create-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.create-ts.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.update-js.stub +0 -0
- /package/{bin → dist}/migrations/stubs/migration.update-ts.stub +0 -0
- /package/{bin → dist}/stubs/arquebus.config-js.stub +0 -0
- /package/{bin → dist}/stubs/arquebus.config-ts.stub +0 -0
- /package/{bin → dist}/stubs/model-js.stub +0 -0
- /package/{bin → dist}/stubs/model-ts.stub +0 -0
|
@@ -1,870 +1,886 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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
|
-
|
|
85
|
+
new <M extends Model = Model, R = IModel | ICollection<M>>(): IBuilder<M, R>;
|
|
79
86
|
};
|
|
80
|
-
declare class Builder<M extends Model
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
296
|
-
|
|
305
|
+
client: 'pg';
|
|
306
|
+
connection: Knex.PgConnectionConfig;
|
|
297
307
|
} | {
|
|
298
|
-
|
|
299
|
-
|
|
308
|
+
client: 'oracle';
|
|
309
|
+
connection: Knex.OracleDbConnectionConfig;
|
|
300
310
|
} | {
|
|
301
|
-
|
|
302
|
-
|
|
311
|
+
client: 'mysql2';
|
|
312
|
+
connection: Knex.MySql2ConnectionConfig;
|
|
303
313
|
} | {
|
|
304
|
-
|
|
305
|
-
|
|
314
|
+
client: 'mysql';
|
|
315
|
+
connection: Knex.MySqlConnectionConfig;
|
|
306
316
|
} | {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
317
|
+
client: 'sqlite3';
|
|
318
|
+
connection: Knex.Sqlite3ConnectionConfig;
|
|
319
|
+
useNullAsDefault?: boolean;
|
|
310
320
|
} | {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
321
|
+
client: 'mariadb';
|
|
322
|
+
connection: Knex.MariaSqlConnectionConfig;
|
|
323
|
+
useNullAsDefault?: boolean;
|
|
314
324
|
});
|
|
315
|
-
interface ModelOptions<M extends Model
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
type Relation<M extends Model
|
|
354
|
-
interface HasOneOrMany<M extends Model
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
interface HasOne<M extends Model
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
interface HasMany<M extends Model
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
interface BelongsTo<M extends Model
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
interface BelongsToMany<M extends Model
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
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
|
-
|
|
526
|
+
[x: string]: any;
|
|
515
527
|
};
|
|
516
|
-
declare class Model
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
declare class Pivot$1 extends Model
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
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
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
declare class Pivot extends Model {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
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
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
interface IPaginator<T extends Model
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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
|
-
|
|
800
|
-
}
|
|
801
|
-
interface IBuilder<M extends Model
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
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,479 @@ 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
|
-
|
|
891
|
+
(this: T, arg: T): void;
|
|
876
892
|
}
|
|
877
|
-
type Raw = Knex
|
|
893
|
+
type Raw = Knex.Raw;
|
|
878
894
|
type OrderByDirection = 'asc' | 'desc' | 'ASC' | 'DESC';
|
|
879
895
|
interface OrderByDescriptor {
|
|
880
|
-
|
|
881
|
-
|
|
896
|
+
column: ColumnRef;
|
|
897
|
+
order?: OrderByDirection;
|
|
882
898
|
}
|
|
883
|
-
type AnyQueryBuilder<M extends Model
|
|
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
|
-
|
|
903
|
+
(sql: string, ...bindings: any[]): R;
|
|
888
904
|
}
|
|
889
905
|
interface BaseSetOperations<QB extends AnyQueryBuilder> {
|
|
890
|
-
|
|
891
|
-
|
|
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
|
-
|
|
898
|
-
|
|
913
|
+
(...columns: ColumnRef[]): QB;
|
|
914
|
+
(columns: ColumnRef[]): QB;
|
|
899
915
|
}
|
|
900
916
|
type WithRelationType = {
|
|
901
|
-
|
|
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
|
-
|
|
920
|
+
(...callbacksOrBuilders: QBOrCallback<QB>[]): QB;
|
|
905
921
|
}
|
|
906
922
|
interface SelectMethod<QB extends AnyQueryBuilder> {
|
|
907
|
-
|
|
908
|
-
|
|
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
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
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
|
-
|
|
936
|
+
(cb: CallbackVoid<QB>): QB;
|
|
921
937
|
}
|
|
922
938
|
interface WhereFieldExpressionMethod<QB extends AnyQueryBuilder> {
|
|
923
|
-
|
|
939
|
+
(fieldExpression: FieldExpression): QB;
|
|
924
940
|
}
|
|
925
941
|
interface WhereExistsMethod<QB extends AnyQueryBuilder> {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
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
|
-
|
|
932
|
-
|
|
933
|
-
|
|
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
|
-
|
|
952
|
+
(column: ColumnRef, range: [Expression<PrimitiveValue>, Expression<PrimitiveValue>]): QB;
|
|
937
953
|
}
|
|
938
954
|
interface WhereNullMethod<QB extends AnyQueryBuilder> {
|
|
939
|
-
|
|
955
|
+
(column: ColumnRef): QB;
|
|
940
956
|
}
|
|
941
957
|
interface OrderByMethod<QB extends AnyQueryBuilder> {
|
|
942
|
-
|
|
943
|
-
|
|
958
|
+
(column: ColumnRef, order?: OrderByDirection): QB;
|
|
959
|
+
(columns: ColumnRefOrOrderByDescriptor[]): QB;
|
|
944
960
|
}
|
|
945
961
|
interface WhereJsonExpressionMethod<QB extends AnyQueryBuilder> {
|
|
946
|
-
|
|
962
|
+
(fieldExpression: FieldExpression, keys: string | string[]): QB;
|
|
947
963
|
}
|
|
948
964
|
interface WhereColumnMethod<QB extends AnyQueryBuilder> {
|
|
949
|
-
|
|
950
|
-
|
|
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
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
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
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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
|
-
|
|
977
|
-
|
|
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
|
-
|
|
997
|
+
(alias: string): QB;
|
|
981
998
|
}
|
|
982
999
|
interface IStatement {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
interface IQueryBuilder<M extends Model
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
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
|
-
|
|
1133
|
+
new <M extends Model = Model, R = M[] | M>(): IQueryBuilder<M, R>;
|
|
1116
1134
|
};
|
|
1117
|
-
declare class QueryBuilder<M extends Model
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
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
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
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
|
-
|
|
1177
|
+
new (): IMigration;
|
|
1158
1178
|
};
|
|
1159
1179
|
declare class Migration extends Inference {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1180
|
+
protected connection: TBaseConfig['client'];
|
|
1181
|
+
withinTransaction: boolean;
|
|
1182
|
+
getConnection(): TBaseConfig['client'];
|
|
1163
1183
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
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
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
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
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1212
|
+
pretend?: boolean;
|
|
1213
|
+
step?: number;
|
|
1214
|
+
batch?: number;
|
|
1202
1215
|
}
|
|
1203
1216
|
declare class Migrator {
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
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
|
+
writeTask(description: string, task: () => Promise<any> | any): Promise<void>;
|
|
1260
|
+
}
|
|
1261
|
+
//#endregion
|
|
1262
|
+
//#region src/migrate.d.ts
|
|
1255
1263
|
interface MigrationStatus {
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1264
|
+
name: string;
|
|
1265
|
+
ran: boolean;
|
|
1266
|
+
batch: number | null;
|
|
1259
1267
|
}
|
|
1260
1268
|
interface MigrateOptions {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1269
|
+
path?: string;
|
|
1270
|
+
step?: number;
|
|
1271
|
+
pretend?: boolean;
|
|
1272
|
+
batch?: number;
|
|
1265
1273
|
}
|
|
1266
1274
|
type TXBaseConfig<S = boolean> = (S extends true ? Partial<TBaseConfig> : TBaseConfig) & {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* Set this to true if you already have an active connection and dont want to create a new one
|
|
1277
|
+
*/
|
|
1278
|
+
skipConnection?: S;
|
|
1271
1279
|
};
|
|
1272
1280
|
interface TCallback {
|
|
1273
|
-
|
|
1281
|
+
(message: string, status?: 'success' | 'error' | 'info' | 'quiet'): void;
|
|
1274
1282
|
}
|
|
1275
1283
|
declare class Migrate {
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
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 {
|
|
1284
|
+
private basePath?;
|
|
1285
|
+
private customStubPath?;
|
|
1286
|
+
private callback;
|
|
1287
|
+
constructor(basePath?: string | undefined, customStubPath?: string | undefined, callback?: TCallback);
|
|
1288
|
+
/**
|
|
1289
|
+
* Runs all pending migrations
|
|
1290
|
+
*
|
|
1291
|
+
* @param config
|
|
1292
|
+
* @param options
|
|
1293
|
+
* @param destroyAll
|
|
1294
|
+
*/
|
|
1295
|
+
run(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Rollback the last migration
|
|
1298
|
+
*
|
|
1299
|
+
* @param config
|
|
1300
|
+
* @param options
|
|
1301
|
+
* @param destroyAll
|
|
1302
|
+
*/
|
|
1303
|
+
rollback(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1304
|
+
/**
|
|
1305
|
+
* Prepares the database for migration
|
|
1306
|
+
*
|
|
1307
|
+
* @param migrator
|
|
1308
|
+
*/
|
|
1309
|
+
prepareDatabase(migrator: Migrator): Promise<void>;
|
|
1310
|
+
/**
|
|
1311
|
+
* Check the status of available migrations
|
|
1312
|
+
*
|
|
1313
|
+
* @param config
|
|
1314
|
+
* @param options
|
|
1315
|
+
* @param destroyAll
|
|
1316
|
+
* @returns
|
|
1317
|
+
*/
|
|
1318
|
+
status(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<MigrationStatus[]>;
|
|
1319
|
+
/**
|
|
1320
|
+
* Setup the database connection
|
|
1321
|
+
*
|
|
1322
|
+
* @param config
|
|
1323
|
+
* @returns
|
|
1324
|
+
*/
|
|
1325
|
+
setupConnection(config: TXBaseConfig): Promise<{
|
|
1326
|
+
arquebus: typeof arquebus;
|
|
1327
|
+
migrator: Migrator;
|
|
1328
|
+
}>;
|
|
1329
|
+
}
|
|
1330
|
+
declare namespace migration_creator_d_exports {
|
|
1357
1331
|
export { MigrationCreator as default };
|
|
1358
1332
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1333
|
+
declare class MigrationCreator {
|
|
1334
|
+
private customStubPath?;
|
|
1335
|
+
private type;
|
|
1336
|
+
private postCreate;
|
|
1337
|
+
constructor(customStubPath?: string | undefined, type?: 'ts' | 'js');
|
|
1338
|
+
/**
|
|
1339
|
+
* Create a new migration file
|
|
1340
|
+
*
|
|
1341
|
+
* @param name
|
|
1342
|
+
* @param dir
|
|
1343
|
+
* @param table
|
|
1344
|
+
* @param create
|
|
1345
|
+
* @returns
|
|
1346
|
+
*/
|
|
1347
|
+
create(name: string, dir: string, table: string, create?: boolean): Promise<string>;
|
|
1348
|
+
/**
|
|
1349
|
+
* Publish migrations from third party vendors
|
|
1350
|
+
*
|
|
1351
|
+
* @param dir
|
|
1352
|
+
* @param callback
|
|
1353
|
+
*/
|
|
1354
|
+
publish(dir: string, callback?: (name: string, source: string, dest: string) => void): Promise<void>;
|
|
1355
|
+
getStub(table?: string, create?: boolean): string;
|
|
1356
|
+
populateStub(stub: string, table: string): string;
|
|
1357
|
+
getClassName(name: string): string;
|
|
1358
|
+
getPath(name: string, dir: string): string;
|
|
1359
|
+
firePostCreateHooks(table: string, filePath: string): Promise<void>;
|
|
1360
|
+
afterCreate(callback: TFunction): void;
|
|
1361
|
+
ensureDirectoryExists(dir: string): Promise<void>;
|
|
1362
|
+
stubPath(stub?: string): string;
|
|
1363
|
+
getDirname(meta: ImportMeta | null): string;
|
|
1364
|
+
}
|
|
1365
|
+
//#endregion
|
|
1366
|
+
export { Migrate, migration_d_exports as Migration, migration_creator_d_exports as MigrationCreator, migration_repository_d_exports as MigrationRepository, migrator_d_exports as Migrator };
|