@h3ravel/arquebus 0.7.2 → 0.7.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 +76 -76
- package/bin/index.js +76 -76
- package/dist/browser/index.cjs +14 -3
- package/dist/browser/index.d.ts +17 -10
- package/dist/browser/index.js +14 -3
- package/dist/concerns/index.d.ts +5 -1
- package/dist/index.cjs +116 -116
- package/dist/index.d.ts +51 -42
- package/dist/index.js +114 -114
- package/dist/inspector/index.cjs +5 -5
- package/dist/inspector/index.js +4 -4
- package/dist/migrations/index.cjs +6 -6
- package/dist/migrations/index.d.ts +5 -1
- package/dist/migrations/index.js +10 -10
- package/dist/relations/index.d.ts +5 -1
- package/dist/seeders/index.d.ts +5 -1
- package/package.json +1 -1
- package/types/modeling.ts +129 -126
package/types/modeling.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type Model from 'src/model'
|
|
|
14
14
|
import type { TBaseConfig } from './container'
|
|
15
15
|
|
|
16
16
|
export interface Attribute {
|
|
17
|
-
make(config: { get?: TFunction | null; set?: TFunction | null }): Attribute
|
|
17
|
+
make (config: { get?: TFunction | null; set?: TFunction | null }): Attribute
|
|
18
18
|
get: TFunction | null
|
|
19
19
|
set: TFunction | null
|
|
20
20
|
withCaching?: boolean
|
|
@@ -22,62 +22,62 @@ export interface Attribute {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface CastsAttributes {
|
|
25
|
-
get(): any
|
|
26
|
-
set(): void
|
|
25
|
+
get (): any
|
|
26
|
+
set (): void
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export type Relation<M extends Model> = IBuilder<M, any> & {}
|
|
30
30
|
|
|
31
31
|
export interface HasOneOrMany<M extends Model> extends Relation<M> {
|
|
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>>
|
|
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>>
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface HasOne<M extends Model> extends HasOneOrMany<M> {
|
|
39
|
-
getResults(): Promise<M | null>
|
|
40
|
-
withDefault(callback?: TFunction | object): this
|
|
39
|
+
getResults (): Promise<M | null>
|
|
40
|
+
withDefault (callback?: TFunction | object): this
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export interface HasMany<M extends Model> extends HasOneOrMany<M> {
|
|
44
|
-
getResults(): Promise<ICollection<M>>
|
|
44
|
+
getResults (): Promise<ICollection<M>>
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface BelongsTo<M extends Model> extends Relation<M> {
|
|
48
|
-
getResults(): Promise<M | null>
|
|
49
|
-
withDefault(callback?: TFunction | object): this
|
|
48
|
+
getResults (): Promise<M | null>
|
|
49
|
+
withDefault (callback?: TFunction | object): this
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export interface BelongsToMany<M extends Model> extends Relation<M> {
|
|
53
|
-
getResults(): Promise<ICollection<M>>
|
|
54
|
-
withTimestamps(): this
|
|
55
|
-
wherePivot(
|
|
53
|
+
getResults (): Promise<ICollection<M>>
|
|
54
|
+
withTimestamps (): this
|
|
55
|
+
wherePivot (
|
|
56
56
|
column: any,
|
|
57
57
|
operator?: any,
|
|
58
58
|
value?: any,
|
|
59
59
|
boolean?: string,
|
|
60
60
|
...args: any[]
|
|
61
61
|
): this
|
|
62
|
-
wherePivotBetween(
|
|
62
|
+
wherePivotBetween (
|
|
63
63
|
column: any,
|
|
64
64
|
values: any,
|
|
65
65
|
boolean?: string,
|
|
66
66
|
not?: boolean,
|
|
67
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
|
|
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
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export interface IModel {
|
|
@@ -99,141 +99,144 @@ export interface IModel {
|
|
|
99
99
|
dateFormat: string
|
|
100
100
|
visible: string[]
|
|
101
101
|
hidden: string[]
|
|
102
|
-
query<T extends { prototype: unknown }>(
|
|
102
|
+
query<T extends { prototype: unknown }> (
|
|
103
103
|
this: T,
|
|
104
104
|
client?: AnyQueryBuilder | null,
|
|
105
105
|
): IBuilder<Model>
|
|
106
|
-
on<T extends { prototype: unknown }>(
|
|
106
|
+
on<T extends { prototype: unknown }> (
|
|
107
107
|
this: T,
|
|
108
108
|
connection: string | null,
|
|
109
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[]
|
|
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
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>(
|
|
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
153
|
relation: string,
|
|
154
154
|
): T | ICollection<T> | null | undefined
|
|
155
|
-
|
|
155
|
+
getRelation<T extends Model, IsCollection extends boolean = false> (
|
|
156
|
+
relation: string
|
|
157
|
+
): IsCollection extends true ? ICollection<T> | undefined : T | null | undefined;
|
|
158
|
+
setRelation<T extends Model> (
|
|
156
159
|
relation: string,
|
|
157
160
|
value: T | ICollection<T> | null,
|
|
158
161
|
): 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(
|
|
162
|
+
unsetRelation (relation: string): this
|
|
163
|
+
relationLoaded (relation: string): boolean
|
|
164
|
+
makeVisible (attributes: string | string[]): this
|
|
165
|
+
makeHidden (attributes: string | string[]): this
|
|
166
|
+
newCollection (models?: any[]): ICollection<Model>
|
|
167
|
+
load (relations: WithRelationType): Promise<this>
|
|
168
|
+
load (...relations: WithRelationType[]): Promise<this>
|
|
169
|
+
loadAggregate (
|
|
167
170
|
relations: WithRelationType,
|
|
168
171
|
column: any,
|
|
169
172
|
callback?: any,
|
|
170
173
|
): 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
|
|
174
|
+
loadCount (...relations: WithRelationType[]): Promise<this>
|
|
175
|
+
loadMax (relations: WithRelationType, column: string): Promise<this>
|
|
176
|
+
loadMin (relations: WithRelationType, column: string): Promise<this>
|
|
177
|
+
loadSum (relations: WithRelationType, column: string): Promise<this>
|
|
178
|
+
usesTimestamps (): boolean
|
|
179
|
+
updateTimestamps (): this
|
|
180
|
+
getCreatedAtColumn (): string
|
|
181
|
+
getUpdatedAtColumn (): string
|
|
182
|
+
getDeletedAtColumn (): string
|
|
183
|
+
setCreatedAt (value: string): this
|
|
184
|
+
setUpdatedAt (value: string): this
|
|
185
|
+
freshTimestamp (): Date
|
|
186
|
+
freshTimestampString (): string
|
|
187
|
+
fromDateTime (value: Date | number | null): string
|
|
188
|
+
useSoftDeletes (): boolean
|
|
189
|
+
toData (): any
|
|
190
|
+
attributesToData (): any
|
|
191
|
+
relationsToData (): any
|
|
192
|
+
toJSON (): any
|
|
193
|
+
toJson (): string
|
|
194
|
+
toString (): string
|
|
195
|
+
isDirty (attributes?: string | string[]): boolean
|
|
196
|
+
getDirty (): string[]
|
|
197
|
+
save (options?: any): Promise<boolean>
|
|
198
|
+
update (attributes?: any, options?: any): Promise<boolean>
|
|
199
|
+
increment (column: string, amount?: number, extra?: any): Promise<boolean>
|
|
200
|
+
decrement (column: string, amount?: number, extra?: any): Promise<boolean>
|
|
201
|
+
serializeDate (date: any): string
|
|
202
|
+
delete (options?: any): Promise<boolean>
|
|
203
|
+
softDelete (options?: any): Promise<boolean>
|
|
204
|
+
forceDelete (options?: any): Promise<boolean>
|
|
205
|
+
restore (options?: any): Promise<boolean>
|
|
206
|
+
trashed (): boolean
|
|
207
|
+
fresh (): Promise<this>
|
|
208
|
+
refresh (): Promise<this | undefined>
|
|
209
|
+
push (): Promise<boolean>
|
|
210
|
+
is (model: this): boolean
|
|
211
|
+
isNot (model: this): boolean
|
|
209
212
|
// related(relation: string): Builder<any>;
|
|
210
213
|
// getRelated<T extends IModel>(relation: string): Promise<this | Collection<T> | null>;
|
|
211
|
-
related<T extends RelationNames<this>>(
|
|
214
|
+
related<T extends RelationNames<this>> (
|
|
212
215
|
relation: T,
|
|
213
216
|
): ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>
|
|
214
|
-
getRelated<T extends RelationNames<this>>(
|
|
217
|
+
getRelated<T extends RelationNames<this>> (
|
|
215
218
|
relation: T,
|
|
216
219
|
): ReturnTypeOfMethod<
|
|
217
220
|
ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>,
|
|
218
221
|
any
|
|
219
222
|
> //'getResults'>;
|
|
220
|
-
hasOne<T extends Model>(
|
|
223
|
+
hasOne<T extends Model> (
|
|
221
224
|
model: new () => T,
|
|
222
225
|
foreignKey?: string,
|
|
223
226
|
localKey?: string,
|
|
224
227
|
): HasOne<T>
|
|
225
|
-
hasMany<T extends Model>(
|
|
228
|
+
hasMany<T extends Model> (
|
|
226
229
|
model: new () => T,
|
|
227
230
|
foreignKey?: string,
|
|
228
231
|
localKey?: string,
|
|
229
232
|
): HasMany<T>
|
|
230
|
-
belongsTo<T extends Model>(
|
|
233
|
+
belongsTo<T extends Model> (
|
|
231
234
|
model: new () => T,
|
|
232
235
|
foreignKey?: string,
|
|
233
236
|
ownerKey?: string,
|
|
234
237
|
relation?: string,
|
|
235
238
|
): BelongsTo<T>
|
|
236
|
-
belongsToMany<T extends Model>(
|
|
239
|
+
belongsToMany<T extends Model> (
|
|
237
240
|
model: new () => T,
|
|
238
241
|
table?: string,
|
|
239
242
|
foreignPivotKey?: string,
|