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