@h3ravel/arquebus 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/bin/index.cjs +196 -144
- package/bin/index.js +177 -94
- package/bin/seeders-8GJzfIIN.js +3 -0
- package/bin/seeders-ByeSoCAQ.cjs +131 -0
- package/bin/seeders-CltigymO.js +79 -0
- package/bin/seeders-_xJ6VGVS.cjs +3 -0
- package/dist/browser/index.cjs +9 -9
- package/dist/browser/index.d.cts +7 -7
- package/dist/browser/index.d.ts +7 -7
- package/dist/browser/index.js +9 -9
- package/dist/index.cjs +252 -121
- package/dist/index.d.cts +40 -8
- package/dist/index.d.ts +40 -8
- package/dist/index.js +245 -119
- package/dist/inspector/index.cjs +105 -33
- package/dist/inspector/index.js +102 -33
- package/dist/migrations/index.cjs +144 -126
- package/dist/migrations/index.d.cts +10 -10
- package/dist/migrations/index.d.ts +10 -10
- package/dist/migrations/index.js +148 -130
- package/dist/migrations/stubs/migration-js.stub +1 -1
- package/dist/migrations/stubs/migration-ts.stub +1 -1
- package/dist/migrations/stubs/migration.create-js.stub +5 -5
- package/dist/migrations/stubs/migration.create-ts.stub +5 -5
- package/dist/migrations/stubs/migration.update-js.stub +2 -2
- package/dist/migrations/stubs/migration.update-ts.stub +3 -3
- package/dist/seeders/index.cjs +141 -0
- package/dist/seeders/index.d.cts +4766 -0
- package/dist/seeders/index.d.ts +4766 -0
- package/dist/seeders/index.js +118 -0
- package/dist/seeders/index.ts +3 -0
- package/dist/seeders/runner.ts +102 -0
- package/dist/seeders/seeder-creator.ts +42 -0
- package/dist/seeders/seeder.ts +10 -0
- package/dist/stubs/seeder-js.stub +13 -0
- package/dist/stubs/seeder-ts.stub +9 -0
- package/package.json +14 -3
- package/types/builder.ts +153 -80
- package/types/container.ts +79 -66
- package/types/generics.ts +75 -37
- package/types/modeling.ts +213 -158
- package/types/query-builder.ts +221 -191
- package/types/query-methods.ts +145 -109
- package/types/utils.ts +64 -56
package/types/query-builder.ts
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AddSelectMethod,
|
|
3
|
+
AnyQueryBuilder,
|
|
4
|
+
FirstOrFailMethod,
|
|
5
|
+
ForceDeleteMethod,
|
|
6
|
+
GroupByMethod,
|
|
7
|
+
JoinMethod,
|
|
8
|
+
JoinRawMethod,
|
|
9
|
+
OrderByMethod,
|
|
10
|
+
OrderByRawMethod,
|
|
11
|
+
RawInterface,
|
|
12
|
+
RestoreMethod,
|
|
13
|
+
ReturningMethod,
|
|
14
|
+
SelectMethod,
|
|
15
|
+
SetOperationsMethod,
|
|
16
|
+
UnionMethod,
|
|
17
|
+
WhereBetweenMethod,
|
|
18
|
+
WhereColumnMethod,
|
|
19
|
+
WhereExistsMethod,
|
|
20
|
+
WhereFieldExpressionMethod,
|
|
21
|
+
WhereInMethod,
|
|
22
|
+
WhereJsonExpressionMethod,
|
|
23
|
+
WhereMethod,
|
|
24
|
+
WhereNullMethod,
|
|
25
|
+
WhereRawMethod,
|
|
26
|
+
WhereWrappedMethod,
|
|
27
|
+
} from './query-methods'
|
|
2
28
|
import type { IPaginator, IPaginatorParams } from './utils'
|
|
3
29
|
import type { TFunction, TGeneric } from './generics'
|
|
4
30
|
|
|
@@ -11,203 +37,207 @@ import type Model from 'src/model'
|
|
|
11
37
|
import type { Table } from 'src/inspector/types/table'
|
|
12
38
|
|
|
13
39
|
export interface SchemaBuilder extends Knex.SchemaBuilder {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
40
|
+
[k: string]: any
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve all tables in the current database.
|
|
43
|
+
*/
|
|
44
|
+
tables(): Promise<string[]>
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve the table info for the given table, or all tables if no table is specified.
|
|
47
|
+
*
|
|
48
|
+
* @param table
|
|
49
|
+
*/
|
|
50
|
+
tableInfo(table?: string): Promise<Table | Table[]>
|
|
51
|
+
/**
|
|
52
|
+
* Retrieve all columns in a given table, or all columns if no table is specified.
|
|
53
|
+
*
|
|
54
|
+
* @param table
|
|
55
|
+
*/
|
|
56
|
+
columns(table?: string): Promise<{ table: string; column: string }[]>
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve all columns from a given table. Returns all columns if table parameter is undefined.
|
|
59
|
+
*
|
|
60
|
+
* @param table
|
|
61
|
+
* @param column
|
|
62
|
+
*/
|
|
63
|
+
columnInfo(table?: string, column?: string): Promise<Column[] | Column>
|
|
64
|
+
/**
|
|
65
|
+
* Retrieve the primary key column for a given table.
|
|
66
|
+
*
|
|
67
|
+
* @param table
|
|
68
|
+
*/
|
|
69
|
+
primary(table: string): Promise<string>
|
|
70
|
+
/**
|
|
71
|
+
* Retrieve all configured foreign key constraints
|
|
72
|
+
*/
|
|
73
|
+
foreignKeys(): Promise<ForeignKey>
|
|
74
|
+
}
|
|
49
75
|
|
|
50
76
|
interface AsMethod<QB extends AnyQueryBuilder> {
|
|
51
|
-
|
|
77
|
+
(alias: string): QB
|
|
52
78
|
}
|
|
53
79
|
|
|
54
80
|
export interface IStatement {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
grouping: string
|
|
82
|
+
direction: string
|
|
83
|
+
type: string
|
|
84
|
+
value: () => any
|
|
85
|
+
not: boolean
|
|
86
|
+
nulls: boolean
|
|
87
|
+
bool: 'and' | 'or' | 'not'
|
|
62
88
|
}
|
|
63
89
|
|
|
64
|
-
export type IConnector<M extends TGeneric = any, R = any> = Knex &
|
|
90
|
+
export type IConnector<M extends TGeneric = any, R = any> = Knex &
|
|
91
|
+
Knex.QueryBuilder<M, R>
|
|
65
92
|
|
|
66
93
|
export interface IQueryBuilder<M extends Model | BModel = Model, R = M[] | M> {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
183
|
-
|
|
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
|
-
|
|
94
|
+
// connector: IQueryBuilder<M, R>
|
|
95
|
+
query: IBuilder<M, R>
|
|
96
|
+
schema: SchemaBuilder
|
|
97
|
+
_statements: IStatement[]
|
|
98
|
+
table(name: string): IQueryBuilder<M, R>
|
|
99
|
+
select: SelectMethod<this>
|
|
100
|
+
addSelect: AddSelectMethod<this>
|
|
101
|
+
columns: SelectMethod<this>
|
|
102
|
+
column: SelectMethod<this>
|
|
103
|
+
distinct: SelectMethod<this>
|
|
104
|
+
returning: ReturningMethod<this>
|
|
105
|
+
distinctOn: SelectMethod<this>
|
|
106
|
+
as: AsMethod<this>
|
|
107
|
+
asProxy(): IQueryBuilder<M, R>
|
|
108
|
+
where: WhereMethod<this>
|
|
109
|
+
firstOrFail: FirstOrFailMethod<this>
|
|
110
|
+
forceDelete: ForceDeleteMethod
|
|
111
|
+
andWhere: WhereMethod<this>
|
|
112
|
+
// orWhere: WhereMethod<this>
|
|
113
|
+
orWhere(...args: any[]): this
|
|
114
|
+
whereNot: WhereMethod<this>
|
|
115
|
+
andWhereNot: WhereMethod<this>
|
|
116
|
+
orWhereNot: WhereMethod<this>
|
|
117
|
+
|
|
118
|
+
whereRaw: WhereRawMethod<this>
|
|
119
|
+
orWhereRaw: WhereRawMethod<this>
|
|
120
|
+
andWhereRaw: WhereRawMethod<this>
|
|
121
|
+
|
|
122
|
+
whereWrapped: WhereWrappedMethod<this>
|
|
123
|
+
havingWrapped: WhereWrappedMethod<this>
|
|
124
|
+
|
|
125
|
+
whereExists: WhereExistsMethod<this>
|
|
126
|
+
orWhereExists: WhereExistsMethod<this>
|
|
127
|
+
whereNotExists: WhereExistsMethod<this>
|
|
128
|
+
orWhereNotExists: WhereExistsMethod<this>
|
|
129
|
+
|
|
130
|
+
restore: RestoreMethod
|
|
131
|
+
whereIn: WhereInMethod<this>
|
|
132
|
+
orWhereIn: WhereInMethod<this>
|
|
133
|
+
whereNotIn: WhereInMethod<this>
|
|
134
|
+
orWhereNotIn: WhereInMethod<this>
|
|
135
|
+
|
|
136
|
+
whereBetween: WhereBetweenMethod<this>
|
|
137
|
+
orWhereBetween: WhereBetweenMethod<this>
|
|
138
|
+
andWhereBetween: WhereBetweenMethod<this>
|
|
139
|
+
whereNotBetween: WhereBetweenMethod<this>
|
|
140
|
+
orWhereNotBetween: WhereBetweenMethod<this>
|
|
141
|
+
andWhereNotBetween: WhereBetweenMethod<this>
|
|
142
|
+
|
|
143
|
+
whereNull: WhereNullMethod<this>
|
|
144
|
+
orWhereNull: WhereNullMethod<this>
|
|
145
|
+
whereNotNull: WhereNullMethod<this>
|
|
146
|
+
orWhereNotNull: WhereNullMethod<this>
|
|
147
|
+
|
|
148
|
+
whereColumn: WhereColumnMethod<this>
|
|
149
|
+
orWhereColumn: WhereColumnMethod<this>
|
|
150
|
+
andWhereColumn: WhereColumnMethod<this>
|
|
151
|
+
whereNotColumn: WhereColumnMethod<this>
|
|
152
|
+
orWhereNotColumn: WhereColumnMethod<this>
|
|
153
|
+
andWhereNotColumn: WhereColumnMethod<this>
|
|
154
|
+
|
|
155
|
+
whereJsonIsArray: WhereFieldExpressionMethod<this>
|
|
156
|
+
orWhereJsonIsArray: WhereFieldExpressionMethod<this>
|
|
157
|
+
whereJsonNotArray: WhereFieldExpressionMethod<this>
|
|
158
|
+
orWhereJsonNotArray: WhereFieldExpressionMethod<this>
|
|
159
|
+
whereJsonIsObject: WhereFieldExpressionMethod<this>
|
|
160
|
+
orWhereJsonIsObject: WhereFieldExpressionMethod<this>
|
|
161
|
+
whereJsonNotObject: WhereFieldExpressionMethod<this>
|
|
162
|
+
orWhereJsonNotObject: WhereFieldExpressionMethod<this>
|
|
163
|
+
whereJsonHasAny: WhereJsonExpressionMethod<this>
|
|
164
|
+
orWhereJsonHasAny: WhereJsonExpressionMethod<this>
|
|
165
|
+
whereJsonHasAll: WhereJsonExpressionMethod<this>
|
|
166
|
+
orWhereJsonHasAll: WhereJsonExpressionMethod<this>
|
|
167
|
+
|
|
168
|
+
having: WhereMethod<this>
|
|
169
|
+
andHaving: WhereMethod<this>
|
|
170
|
+
orHaving: WhereMethod<this>
|
|
171
|
+
|
|
172
|
+
havingRaw: WhereRawMethod<this>
|
|
173
|
+
orHavingRaw: WhereRawMethod<this>
|
|
174
|
+
|
|
175
|
+
havingIn: WhereInMethod<this>
|
|
176
|
+
orHavingIn: WhereInMethod<this>
|
|
177
|
+
havingNotIn: WhereInMethod<this>
|
|
178
|
+
orHavingNotIn: WhereInMethod<this>
|
|
179
|
+
|
|
180
|
+
havingNull: WhereNullMethod<this>
|
|
181
|
+
orHavingNull: WhereNullMethod<this>
|
|
182
|
+
havingNotNull: WhereNullMethod<this>
|
|
183
|
+
orHavingNotNull: WhereNullMethod<this>
|
|
184
|
+
|
|
185
|
+
havingExists: WhereExistsMethod<this>
|
|
186
|
+
orHavingExists: WhereExistsMethod<this>
|
|
187
|
+
havingNotExists: WhereExistsMethod<this>
|
|
188
|
+
orHavingNotExists: WhereExistsMethod<this>
|
|
189
|
+
|
|
190
|
+
havingBetween: WhereBetweenMethod<this>
|
|
191
|
+
orHavingBetween: WhereBetweenMethod<this>
|
|
192
|
+
havingNotBetween: WhereBetweenMethod<this>
|
|
193
|
+
orHavingNotBetween: WhereBetweenMethod<this>
|
|
194
|
+
|
|
195
|
+
union: UnionMethod<this>
|
|
196
|
+
unionAll: UnionMethod<this>
|
|
197
|
+
intersect: SetOperationsMethod<this>
|
|
198
|
+
|
|
199
|
+
join: JoinMethod<this>
|
|
200
|
+
joinRaw: JoinRawMethod<this>
|
|
201
|
+
innerJoin: JoinMethod<this>
|
|
202
|
+
leftJoin: JoinMethod<this>
|
|
203
|
+
leftOuterJoin: JoinMethod<this>
|
|
204
|
+
rightJoin: JoinMethod<this>
|
|
205
|
+
rightOuterJoin: JoinMethod<this>
|
|
206
|
+
outerJoin: JoinMethod<this>
|
|
207
|
+
fullOuterJoin: JoinMethod<this>
|
|
208
|
+
crossJoin: JoinMethod<this>
|
|
209
|
+
|
|
210
|
+
orderBy: OrderByMethod<this>
|
|
211
|
+
orderByRaw: OrderByRawMethod<this>
|
|
212
|
+
|
|
213
|
+
groupBy: GroupByMethod<this>
|
|
214
|
+
groupByRaw: RawInterface<this>
|
|
215
|
+
transaction(callback?: TFunction): Promise<Knex.Transaction> | undefined
|
|
216
|
+
destroy(callback: TFunction): Promise<number>
|
|
217
|
+
destroy(): Promise<number>
|
|
218
|
+
clone(): IQueryBuilder<M, R>
|
|
219
|
+
raw: Knex.RawQueryBuilder<TGeneric, M>
|
|
220
|
+
get(columns?: string[]): Promise<any>
|
|
221
|
+
first(columns?: string[]): Promise<M | null | undefined>
|
|
222
|
+
find(key: string | number, columns?: string[]): Promise<M | null | undefined>
|
|
223
|
+
insert(attributes: any): Promise<unknown>
|
|
224
|
+
update(...attributes: any[]): Promise<number>
|
|
225
|
+
delete(): Promise<boolean | number>
|
|
226
|
+
exists(): Promise<boolean>
|
|
227
|
+
count(column?: string): Promise<number>
|
|
228
|
+
min(column: string): Promise<number>
|
|
229
|
+
max(column: string): Promise<number>
|
|
230
|
+
sum(column: string): Promise<number>
|
|
231
|
+
avg(column: string): Promise<number>
|
|
232
|
+
skip(count: number): this
|
|
233
|
+
take(count: number): this
|
|
234
|
+
limit(count: number): this
|
|
235
|
+
offset(count: number): this
|
|
236
|
+
pluck<X extends Model = any>(column: string): Promise<Array<X>>
|
|
237
|
+
chunk(count: number, callback: (rows: M[]) => any): Promise<boolean>
|
|
238
|
+
forPage(page: number, perPage?: number): this
|
|
239
|
+
paginate<F extends IPaginatorParams>(
|
|
240
|
+
page?: number,
|
|
241
|
+
perPage?: number,
|
|
242
|
+
): Promise<IPaginator<M, F>>
|
|
213
243
|
}
|