@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.
- package/README.md +20 -1
- package/bin/index.cjs +225 -171
- package/bin/index.js +208 -122
- 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 +3655 -183
- package/dist/browser/index.d.ts +3655 -183
- package/dist/browser/index.js +9 -9
- package/dist/index.cjs +270 -135
- package/dist/index.d.cts +3797 -294
- package/dist/index.d.ts +3797 -294
- package/dist/index.js +263 -133
- package/dist/inspector/index.cjs +122 -46
- package/dist/inspector/index.js +119 -46
- package/dist/migrations/index.cjs +171 -151
- package/dist/migrations/index.d.cts +3510 -27
- package/dist/migrations/index.d.ts +3510 -27
- package/dist/migrations/index.js +177 -150
- 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 +15 -4
- package/types/builder.ts +158 -80
- package/types/container.ts +79 -66
- package/types/generics.ts +75 -36
- package/types/modeling.ts +213 -158
- package/types/query-builder.ts +223 -186
- package/types/query-methods.ts +160 -104
- package/types/utils.ts +64 -55
package/types/modeling.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { AnyQueryBuilder, WithRelationType } from './query-methods'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
Hook,
|
|
4
|
+
RelationNames,
|
|
5
|
+
ReturnTypeOfMethod,
|
|
6
|
+
SnakeToCamelCase,
|
|
7
|
+
TFunction,
|
|
8
|
+
TGeneric,
|
|
9
|
+
} from './generics'
|
|
3
10
|
|
|
4
11
|
import type { IBuilder } from './builder'
|
|
5
12
|
import type { ICollection } from './utils'
|
|
@@ -7,184 +14,232 @@ import type Model from 'src/model'
|
|
|
7
14
|
import type { TBaseConfig } from './container'
|
|
8
15
|
|
|
9
16
|
export interface Attribute {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
make(config: { get?: TFunction | null; set?: TFunction | null }): Attribute
|
|
18
|
+
get: TFunction | null
|
|
19
|
+
set: TFunction | null
|
|
20
|
+
withCaching?: boolean
|
|
21
|
+
withObjectCaching?: boolean
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
export interface CastsAttributes {
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
get(): any
|
|
26
|
+
set(): void
|
|
20
27
|
}
|
|
21
28
|
|
|
22
|
-
export type Relation<M extends Model> = IBuilder<M, any> & {
|
|
23
|
-
}
|
|
29
|
+
export type Relation<M extends Model> = IBuilder<M, any> & {}
|
|
24
30
|
|
|
25
31
|
export interface HasOneOrMany<M extends Model> extends Relation<M> {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
save(model: M): Promise<M>
|
|
33
|
+
saveMany(models: M[] | ICollection<M>): Promise<ICollection<M>>
|
|
34
|
+
create(attributes?: any): Promise<M>
|
|
35
|
+
createMany(records: any[]): Promise<ICollection<M>>
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
export interface HasOne<M extends Model> extends HasOneOrMany<M> {
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
getResults(): Promise<M | null>
|
|
40
|
+
withDefault(callback?: TFunction | object): this
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export interface HasMany<M extends Model> extends HasOneOrMany<M> {
|
|
38
|
-
|
|
44
|
+
getResults(): Promise<ICollection<M>>
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
export interface BelongsTo<M extends Model> extends Relation<M> {
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
getResults(): Promise<M | null>
|
|
49
|
+
withDefault(callback?: TFunction | object): this
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
export interface BelongsToMany<M extends Model> extends Relation<M> {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
getResults(): Promise<ICollection<M>>
|
|
54
|
+
withTimestamps(): this
|
|
55
|
+
wherePivot(
|
|
56
|
+
column: any,
|
|
57
|
+
operator?: any,
|
|
58
|
+
value?: any,
|
|
59
|
+
boolean?: string,
|
|
60
|
+
...args: any[]
|
|
61
|
+
): this
|
|
62
|
+
wherePivotBetween(
|
|
63
|
+
column: any,
|
|
64
|
+
values: any,
|
|
65
|
+
boolean?: string,
|
|
66
|
+
not?: boolean,
|
|
67
|
+
): this
|
|
68
|
+
orWherePivotBetween(column: any, values: any): this
|
|
69
|
+
wherePivotNotBetween(column: any, values: any, boolean?: string): this
|
|
70
|
+
orWherePivotNotBetween(column: any, values: any): this
|
|
71
|
+
wherePivotIn(column: any, values: any, boolean?: string, not?: boolean): this
|
|
72
|
+
orWherePivot(column: any, operator?: any, value?: any): this
|
|
73
|
+
orWherePivotIn(column: any, values: any): this
|
|
74
|
+
wherePivotNotIn(column: any, values: any, boolean?: string): this
|
|
75
|
+
orWherePivotNotIn(column: any, values: any): this
|
|
76
|
+
wherePivotNull(column: any, boolean?: string, not?: boolean): this
|
|
77
|
+
wherePivotNotNull(column: any, boolean?: string): this
|
|
78
|
+
orWherePivotNull(column: any, not?: boolean): this
|
|
79
|
+
orWherePivotNotNull(column: any): this
|
|
80
|
+
orderByPivot(column: any, direction?: string): this
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
export interface IModel {
|
|
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
|
-
|
|
84
|
+
[value: string]: any
|
|
85
|
+
attributes: any
|
|
86
|
+
relations: any
|
|
87
|
+
exists: boolean
|
|
88
|
+
// primaryKey: string
|
|
89
|
+
// builder?: IBuilder<any, any> | null
|
|
90
|
+
// table: string | null
|
|
91
|
+
connection?: TBaseConfig['client'] | null
|
|
92
|
+
// keyType: string
|
|
93
|
+
// incrementing: boolean
|
|
94
|
+
perPage: number
|
|
95
|
+
with: string | string[] | TGeneric<(...args: any[]) => IBuilder<Model>>
|
|
96
|
+
// withCount: string[]
|
|
97
|
+
trx: AnyQueryBuilder | null
|
|
98
|
+
timestamps: boolean
|
|
99
|
+
dateFormat: string
|
|
100
|
+
visible: string[]
|
|
101
|
+
hidden: string[]
|
|
102
|
+
query<T extends { prototype: unknown }>(
|
|
103
|
+
this: T,
|
|
104
|
+
client?: AnyQueryBuilder | null,
|
|
105
|
+
): IBuilder<Model>
|
|
106
|
+
on<T extends { prototype: unknown }>(
|
|
107
|
+
this: T,
|
|
108
|
+
connection: string | null,
|
|
109
|
+
): IBuilder<Model>
|
|
110
|
+
boot(): void
|
|
111
|
+
make<T extends IModel>(this: new () => T, attributes?: TGeneric): T
|
|
112
|
+
addHook(hook: Hook, callback: TFunction): void
|
|
113
|
+
creating(callback: TFunction): void
|
|
114
|
+
created(callback: TFunction): void
|
|
115
|
+
updating(callback: TFunction): void
|
|
116
|
+
updated(callback: TFunction): void
|
|
117
|
+
deleting(callback: TFunction): void
|
|
118
|
+
deleted(callback: TFunction): void
|
|
119
|
+
saving(callback: TFunction): void
|
|
120
|
+
saved(callback: TFunction): void
|
|
121
|
+
restoring(callback: TFunction): void
|
|
122
|
+
restored(callback: TFunction): void
|
|
123
|
+
trashed(callback: TFunction): void
|
|
124
|
+
forceDeleted(callback: TFunction): void
|
|
125
|
+
bootIfNotBooted(): void
|
|
126
|
+
initialize(): void
|
|
127
|
+
initializePlugins(): void
|
|
128
|
+
addPluginInitializer(method: any): void
|
|
129
|
+
newInstance(attributes?: TGeneric, exists?: boolean): any
|
|
130
|
+
getKey(): string | number | null | undefined
|
|
131
|
+
getKeyName(): string
|
|
132
|
+
getConnectionName(): string
|
|
133
|
+
getConnection(): any
|
|
134
|
+
setConnection(connection: TBaseConfig['client'] | null): this
|
|
135
|
+
usesUniqueIds(): boolean
|
|
136
|
+
uniqueIds(): string[]
|
|
137
|
+
// newUniqueId (): string;
|
|
138
|
+
setUniqueIds(): void
|
|
139
|
+
getKeyType(): string
|
|
140
|
+
getIncrementing(): boolean
|
|
141
|
+
setIncrementing(value: boolean): this
|
|
142
|
+
getTable(): string
|
|
143
|
+
setTable(table: string): this
|
|
144
|
+
getDates(): string[]
|
|
145
|
+
getDateFormat(): string
|
|
146
|
+
getAttributes(): object
|
|
147
|
+
getAttribute(key: string): any
|
|
148
|
+
setAttribute(key: string, value: any): this
|
|
149
|
+
fill(attributes: any): this
|
|
150
|
+
setAppends(appends: string[]): this
|
|
151
|
+
append(key: string | string[]): this
|
|
152
|
+
getRelation<T extends Model>(
|
|
153
|
+
relation: string,
|
|
154
|
+
): T | ICollection<T> | null | undefined
|
|
155
|
+
setRelation<T extends Model>(
|
|
156
|
+
relation: string,
|
|
157
|
+
value: T | ICollection<T> | null,
|
|
158
|
+
): this
|
|
159
|
+
unsetRelation(relation: string): this
|
|
160
|
+
relationLoaded(relation: string): boolean
|
|
161
|
+
makeVisible(attributes: string | string[]): this
|
|
162
|
+
makeHidden(attributes: string | string[]): this
|
|
163
|
+
newCollection(models?: any[]): ICollection<Model>
|
|
164
|
+
load(relations: WithRelationType): Promise<this>
|
|
165
|
+
load(...relations: WithRelationType[]): Promise<this>
|
|
166
|
+
loadAggregate(
|
|
167
|
+
relations: WithRelationType,
|
|
168
|
+
column: any,
|
|
169
|
+
callback?: any,
|
|
170
|
+
): Promise<this>
|
|
171
|
+
loadCount(...relations: WithRelationType[]): Promise<this>
|
|
172
|
+
loadMax(relations: WithRelationType, column: string): Promise<this>
|
|
173
|
+
loadMin(relations: WithRelationType, column: string): Promise<this>
|
|
174
|
+
loadSum(relations: WithRelationType, column: string): Promise<this>
|
|
175
|
+
usesTimestamps(): boolean
|
|
176
|
+
updateTimestamps(): this
|
|
177
|
+
getCreatedAtColumn(): string
|
|
178
|
+
getUpdatedAtColumn(): string
|
|
179
|
+
getDeletedAtColumn(): string
|
|
180
|
+
setCreatedAt(value: string): this
|
|
181
|
+
setUpdatedAt(value: string): this
|
|
182
|
+
freshTimestamp(): Date
|
|
183
|
+
freshTimestampString(): string
|
|
184
|
+
fromDateTime(value: Date | number | null): string
|
|
185
|
+
useSoftDeletes(): boolean
|
|
186
|
+
toData(): any
|
|
187
|
+
attributesToData(): any
|
|
188
|
+
relationsToData(): any
|
|
189
|
+
toJSON(): any
|
|
190
|
+
toJson(): string
|
|
191
|
+
toString(): string
|
|
192
|
+
isDirty(attributes?: string | string[]): boolean
|
|
193
|
+
getDirty(): string[]
|
|
194
|
+
save(options?: any): Promise<boolean>
|
|
195
|
+
update(attributes?: any, options?: any): Promise<boolean>
|
|
196
|
+
increment(column: string, amount?: number, extra?: any): Promise<boolean>
|
|
197
|
+
decrement(column: string, amount?: number, extra?: any): Promise<boolean>
|
|
198
|
+
serializeDate(date: any): string
|
|
199
|
+
delete(options?: any): Promise<boolean>
|
|
200
|
+
softDelete(options?: any): Promise<boolean>
|
|
201
|
+
forceDelete(options?: any): Promise<boolean>
|
|
202
|
+
restore(options?: any): Promise<boolean>
|
|
203
|
+
trashed(): boolean
|
|
204
|
+
fresh(): Promise<this>
|
|
205
|
+
refresh(): Promise<this | undefined>
|
|
206
|
+
push(): Promise<boolean>
|
|
207
|
+
is(model: this): boolean
|
|
208
|
+
isNot(model: this): boolean
|
|
209
|
+
// related(relation: string): Builder<any>;
|
|
210
|
+
// getRelated<T extends IModel>(relation: string): Promise<this | Collection<T> | null>;
|
|
211
|
+
related<T extends RelationNames<this>>(
|
|
212
|
+
relation: T,
|
|
213
|
+
): ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>
|
|
214
|
+
getRelated<T extends RelationNames<this>>(
|
|
215
|
+
relation: T,
|
|
216
|
+
): ReturnTypeOfMethod<
|
|
217
|
+
ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>,
|
|
218
|
+
any
|
|
219
|
+
> //'getResults'>;
|
|
220
|
+
hasOne<T extends Model>(
|
|
221
|
+
model: new () => T,
|
|
222
|
+
foreignKey?: string,
|
|
223
|
+
localKey?: string,
|
|
224
|
+
): HasOne<T>
|
|
225
|
+
hasMany<T extends Model>(
|
|
226
|
+
model: new () => T,
|
|
227
|
+
foreignKey?: string,
|
|
228
|
+
localKey?: string,
|
|
229
|
+
): HasMany<T>
|
|
230
|
+
belongsTo<T extends Model>(
|
|
231
|
+
model: new () => T,
|
|
232
|
+
foreignKey?: string,
|
|
233
|
+
ownerKey?: string,
|
|
234
|
+
relation?: string,
|
|
235
|
+
): BelongsTo<T>
|
|
236
|
+
belongsToMany<T extends Model>(
|
|
237
|
+
model: new () => T,
|
|
238
|
+
table?: string,
|
|
239
|
+
foreignPivotKey?: string,
|
|
240
|
+
relatedPivotKey?: string,
|
|
241
|
+
parentKey?: string,
|
|
242
|
+
relatedKey?: string,
|
|
243
|
+
): BelongsToMany<T>
|
|
189
244
|
}
|
|
190
245
|
export type IPivot = IModel & {}
|