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