@h3ravel/arquebus 0.7.1 → 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.cjs +35 -72
- package/dist/concerns/index.d.ts +214 -236
- package/dist/concerns/index.js +41 -26
- 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.cjs +46 -93
- package/dist/relations/index.d.ts +98 -104
- package/dist/relations/index.js +50 -35
- package/dist/seeders/index.d.ts +5 -1
- package/package.json +1 -1
- package/types/modeling.ts +129 -126
- package/dist/concerns/chunk-Bop6jNiL.js +0 -15
- package/dist/relations/chunk-Bop6jNiL.js +0 -15
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import "node:module";
|
|
2
1
|
import { Collection } from "collect.js";
|
|
3
2
|
import Knex$1, { Knex } from "knex";
|
|
4
3
|
import * as dayjs0 from "dayjs";
|
|
5
4
|
|
|
6
|
-
//#region rolldown:runtime
|
|
7
|
-
//#endregion
|
|
8
5
|
//#region src/browser/collection.d.ts
|
|
9
6
|
declare class Collection$2<I$1 extends Model$2> extends Collection<I$1> {
|
|
10
7
|
mapThen(callback: TFunction): Promise<any[]>;
|
|
@@ -45,25 +42,25 @@ interface Attribute {
|
|
|
45
42
|
withCaching?: boolean;
|
|
46
43
|
withObjectCaching?: boolean;
|
|
47
44
|
}
|
|
48
|
-
type Relation$
|
|
49
|
-
interface HasOneOrMany$1<M extends Model$1> extends Relation$
|
|
45
|
+
type Relation$2<M extends Model$1> = IBuilder<M, any> & {};
|
|
46
|
+
interface HasOneOrMany$1<M extends Model$1> extends Relation$2<M> {
|
|
50
47
|
save(model: M): Promise<M>;
|
|
51
48
|
saveMany(models: M[] | ICollection<M>): Promise<ICollection<M>>;
|
|
52
49
|
create(attributes?: any): Promise<M>;
|
|
53
50
|
createMany(records: any[]): Promise<ICollection<M>>;
|
|
54
51
|
}
|
|
55
|
-
interface HasOne$
|
|
52
|
+
interface HasOne$2<M extends Model$1> extends HasOneOrMany$1<M> {
|
|
56
53
|
getResults(): Promise<M | null>;
|
|
57
54
|
withDefault(callback?: TFunction | object): this;
|
|
58
55
|
}
|
|
59
|
-
interface HasMany$
|
|
56
|
+
interface HasMany$2<M extends Model$1> extends HasOneOrMany$1<M> {
|
|
60
57
|
getResults(): Promise<ICollection<M>>;
|
|
61
58
|
}
|
|
62
|
-
interface BelongsTo$
|
|
59
|
+
interface BelongsTo$2<M extends Model$1> extends Relation$2<M> {
|
|
63
60
|
getResults(): Promise<M | null>;
|
|
64
61
|
withDefault(callback?: TFunction | object): this;
|
|
65
62
|
}
|
|
66
|
-
interface BelongsToMany$
|
|
63
|
+
interface BelongsToMany$2<M extends Model$1> extends Relation$2<M> {
|
|
67
64
|
getResults(): Promise<ICollection<M>>;
|
|
68
65
|
withTimestamps(): this;
|
|
69
66
|
wherePivot(column: any, operator?: any, value?: any, boolean?: string, ...args: any[]): this;
|
|
@@ -143,6 +140,7 @@ interface IModel {
|
|
|
143
140
|
setAppends(appends: string[]): this;
|
|
144
141
|
append(key: string | string[]): this;
|
|
145
142
|
getRelation<T$1 extends Model$1>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
143
|
+
getRelation<T$1 extends Model$1, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
146
144
|
setRelation<T$1 extends Model$1>(relation: string, value: T$1 | ICollection<T$1> | null): this;
|
|
147
145
|
unsetRelation(relation: string): this;
|
|
148
146
|
relationLoaded(relation: string): boolean;
|
|
@@ -192,10 +190,10 @@ interface IModel {
|
|
|
192
190
|
isNot(model: this): boolean;
|
|
193
191
|
related<T$1 extends RelationNames<this>>(relation: T$1): ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T$1>>}`>;
|
|
194
192
|
getRelated<T$1 extends RelationNames<this>>(relation: T$1): ReturnTypeOfMethod<ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T$1>>}`>, any>;
|
|
195
|
-
hasOne<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string): HasOne$
|
|
196
|
-
hasMany<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string): HasMany$
|
|
197
|
-
belongsTo<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, ownerKey?: string, relation?: string): BelongsTo$
|
|
198
|
-
belongsToMany<T$1 extends Model$1>(model: new () => T$1, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string): BelongsToMany$
|
|
193
|
+
hasOne<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string): HasOne$2<T$1>;
|
|
194
|
+
hasMany<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string): HasMany$2<T$1>;
|
|
195
|
+
belongsTo<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, ownerKey?: string, relation?: string): BelongsTo$2<T$1>;
|
|
196
|
+
belongsToMany<T$1 extends Model$1>(model: new () => T$1, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string): BelongsToMany$2<T$1>;
|
|
199
197
|
}
|
|
200
198
|
//#endregion
|
|
201
199
|
//#region src/collection.d.ts
|
|
@@ -648,10 +646,9 @@ declare class QueryBuilder<M extends Model$1 = Model$1, R$1 = M[] | M> extends I
|
|
|
648
646
|
get _single(): any;
|
|
649
647
|
get from(): Knex.Table<any, any> & Knex.Table<any, any[]>;
|
|
650
648
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
declare class Relation {
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/relations/relation.d.ts
|
|
651
|
+
declare class Relation$1 {
|
|
655
652
|
query: QueryBuilder;
|
|
656
653
|
parent: any;
|
|
657
654
|
related: any;
|
|
@@ -800,7 +797,7 @@ interface ModelOptions<M extends Model$1 = Model$1> {
|
|
|
800
797
|
table?: string;
|
|
801
798
|
scopes?: TGeneric<(...args: any[]) => Builder<M>>;
|
|
802
799
|
plugins?: (<X extends MixinConstructor<M>>(Model: X) => MixinConstructor<M>)[];
|
|
803
|
-
relations?: TGeneric<(...args: any[]) => Relation>;
|
|
800
|
+
relations?: TGeneric<(...args: any[]) => Relation$1>;
|
|
804
801
|
attributes?: TGeneric<Attribute>;
|
|
805
802
|
CREATED_AT?: string;
|
|
806
803
|
UPDATED_AT?: string;
|
|
@@ -2045,7 +2042,10 @@ declare const BaseModel: (new (...args: any[]) => any) & {
|
|
|
2045
2042
|
uniqueIds(): never[];
|
|
2046
2043
|
setUniqueIds(): void;
|
|
2047
2044
|
});
|
|
2048
|
-
getRelation:
|
|
2045
|
+
getRelation: {
|
|
2046
|
+
<T$1 extends Model$1>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
2047
|
+
<T$1 extends Model$1, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
2048
|
+
};
|
|
2049
2049
|
setRelation: <T$1 extends Model$1>(relation: string, value: T$1 | ICollection<T$1> | null) => (new () => IModel) & IModel & {
|
|
2050
2050
|
[x: string]: any;
|
|
2051
2051
|
timestamps: boolean;
|
|
@@ -4098,10 +4098,10 @@ declare const BaseModel: (new (...args: any[]) => any) & {
|
|
|
4098
4098
|
uniqueIds(): never[];
|
|
4099
4099
|
setUniqueIds(): void;
|
|
4100
4100
|
}, `relation${Capitalize<SnakeToCamelCase<T$1>>}`>, any>;
|
|
4101
|
-
hasOne: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string) => HasOne$
|
|
4102
|
-
hasMany: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string) => HasMany$
|
|
4103
|
-
belongsTo: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, ownerKey?: string, relation?: string) => BelongsTo$
|
|
4104
|
-
belongsToMany: <T$1 extends Model$1>(model: new () => T$1, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string) => BelongsToMany$
|
|
4101
|
+
hasOne: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string) => HasOne$2<T$1>;
|
|
4102
|
+
hasMany: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string) => HasMany$2<T$1>;
|
|
4103
|
+
belongsTo: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, ownerKey?: string, relation?: string) => BelongsTo$2<T$1>;
|
|
4104
|
+
belongsToMany: <T$1 extends Model$1>(model: new () => T$1, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string) => BelongsToMany$2<T$1>;
|
|
4105
4105
|
original: TGeneric;
|
|
4106
4106
|
casts: TGeneric<typeof CastsAttributes | "int" | "json" | "string" | "date" | "boolean" | "datetime" | "collection">;
|
|
4107
4107
|
changes: TGeneric;
|
|
@@ -4734,10 +4734,9 @@ type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? U e
|
|
|
4734
4734
|
type FunctionPropertyNames<T$1> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? K : never }[keyof T$1];
|
|
4735
4735
|
type RelationNames<T$1> = FunctionPropertyNames<T$1> extends infer R ? R extends `relation${infer P}` ? P extends 'sToData' | 'loaded' ? never : CamelToSnakeCase<P> : never : never;
|
|
4736
4736
|
type MixinConstructor<T$1 = TGeneric> = new (...args: any[]) => T$1;
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
declare const BelongsTo_base: (new (...args: any[]) => Relation & typeof Relation & {
|
|
4737
|
+
//#endregion
|
|
4738
|
+
//#region src/relations/belongs-to.d.ts
|
|
4739
|
+
declare const BelongsTo_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & {
|
|
4741
4740
|
[x: string]: any;
|
|
4742
4741
|
_withDefault?: boolean | TFunction | TGeneric;
|
|
4743
4742
|
withDefault(callback?: boolean): /*elided*/any;
|
|
@@ -4750,13 +4749,13 @@ declare const BelongsTo_base: (new (...args: any[]) => Relation & typeof Relatio
|
|
|
4750
4749
|
getDefaultFor<P$1>(parent: P$1): any;
|
|
4751
4750
|
};
|
|
4752
4751
|
} & {
|
|
4753
|
-
prototype: Relation;
|
|
4752
|
+
prototype: Relation$1;
|
|
4754
4753
|
constraints: boolean;
|
|
4755
4754
|
selfJoinCount: number;
|
|
4756
|
-
extend: typeof Relation.extend;
|
|
4757
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4755
|
+
extend: typeof Relation$1.extend;
|
|
4756
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
4758
4757
|
};
|
|
4759
|
-
declare class BelongsTo extends BelongsTo_base {
|
|
4758
|
+
declare class BelongsTo$1 extends BelongsTo_base {
|
|
4760
4759
|
foreignKey?: string;
|
|
4761
4760
|
ownerKey?: string;
|
|
4762
4761
|
child: Model$1;
|
|
@@ -4775,17 +4774,16 @@ declare class BelongsTo extends BelongsTo_base {
|
|
|
4775
4774
|
addConstraints(this: any): void;
|
|
4776
4775
|
newRelatedInstanceFor(_parent: any): Model$1;
|
|
4777
4776
|
}
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
}
|
|
4781
|
-
|
|
4782
|
-
prototype: Relation;
|
|
4777
|
+
//#endregion
|
|
4778
|
+
//#region src/relations/belongs-to-many.d.ts
|
|
4779
|
+
declare const BelongsToMany_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & TGeneric<any, string>) & {} & {
|
|
4780
|
+
prototype: Relation$1;
|
|
4783
4781
|
constraints: boolean;
|
|
4784
4782
|
selfJoinCount: number;
|
|
4785
|
-
extend: typeof Relation.extend;
|
|
4786
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4783
|
+
extend: typeof Relation$1.extend;
|
|
4784
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
4787
4785
|
};
|
|
4788
|
-
declare class BelongsToMany extends BelongsToMany_base {
|
|
4786
|
+
declare class BelongsToMany$1 extends BelongsToMany_base {
|
|
4789
4787
|
table?: string;
|
|
4790
4788
|
foreignPivotKey?: string;
|
|
4791
4789
|
relatedPivotKey?: string;
|
|
@@ -4848,25 +4846,9 @@ declare class BelongsToMany extends BelongsToMany_base {
|
|
|
4848
4846
|
getRelationExistenceQuery(query: any, parentQuery: any, columns?: string[]): any;
|
|
4849
4847
|
getRelationExistenceQueryForSelfJoin(query: any, parentQuery: any, columns?: string[]): any;
|
|
4850
4848
|
}
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
declare const InteractsWithPivotTable: <TBase extends MixinConstructor>(Relation: TBase) => MixinConstructor;
|
|
4855
|
-
declare namespace supports_default_models_d_exports {
|
|
4856
|
-
export { SupportsDefaultModels as default };
|
|
4857
|
-
}
|
|
4858
|
-
declare const SupportsDefaultModels: <TBase extends MixinConstructor>(Relation: TBase) => {
|
|
4859
|
-
new (...args: any[]): {
|
|
4860
|
-
[x: string]: any;
|
|
4861
|
-
_withDefault?: boolean | TFunction | TGeneric;
|
|
4862
|
-
withDefault(callback?: boolean): /*elided*/any;
|
|
4863
|
-
getDefaultFor<P$1>(parent: P$1): any;
|
|
4864
|
-
};
|
|
4865
|
-
} & TBase;
|
|
4866
|
-
declare namespace has_many_d_exports {
|
|
4867
|
-
export { HasMany as default };
|
|
4868
|
-
}
|
|
4869
|
-
declare const HasMany_base: (new (...args: any[]) => Relation & typeof Relation & {
|
|
4849
|
+
//#endregion
|
|
4850
|
+
//#region src/relations/has-many.d.ts
|
|
4851
|
+
declare const HasMany_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & {
|
|
4870
4852
|
[x: string]: any;
|
|
4871
4853
|
getRelationValue(dictionary: TGeneric, key: string, type: string): any;
|
|
4872
4854
|
matchOneOrMany(models: Model$1[], results: any, relation: string, type: string): Model$1[];
|
|
@@ -4899,13 +4881,13 @@ declare const HasMany_base: (new (...args: any[]) => Relation & typeof Relation
|
|
|
4899
4881
|
addConstraints(): void;
|
|
4900
4882
|
};
|
|
4901
4883
|
} & {
|
|
4902
|
-
prototype: Relation;
|
|
4884
|
+
prototype: Relation$1;
|
|
4903
4885
|
constraints: boolean;
|
|
4904
4886
|
selfJoinCount: number;
|
|
4905
|
-
extend: typeof Relation.extend;
|
|
4906
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4887
|
+
extend: typeof Relation$1.extend;
|
|
4888
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
4907
4889
|
};
|
|
4908
|
-
declare class HasMany extends HasMany_base {
|
|
4890
|
+
declare class HasMany$1 extends HasMany_base {
|
|
4909
4891
|
foreignKey?: string | null;
|
|
4910
4892
|
localKey?: string | null;
|
|
4911
4893
|
constructor(query: any, parent: any, foreignKey?: string | null, localKey?: string | null);
|
|
@@ -4916,10 +4898,9 @@ declare class HasMany extends HasMany_base {
|
|
|
4916
4898
|
match(models: Model$1[], results: any, relation: string): Model$1[];
|
|
4917
4899
|
addEagerConstraints(models: Model$1[]): void;
|
|
4918
4900
|
}
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
declare class HasManyThrough extends Relation {
|
|
4901
|
+
//#endregion
|
|
4902
|
+
//#region src/relations/has-many-through.d.ts
|
|
4903
|
+
declare class HasManyThrough$1 extends Relation$1 {
|
|
4923
4904
|
throughParent: any;
|
|
4924
4905
|
farParent: any;
|
|
4925
4906
|
firstKey?: string;
|
|
@@ -4963,10 +4944,9 @@ declare class HasManyThrough extends Relation {
|
|
|
4963
4944
|
getQualifiedLocalKeyName(): any;
|
|
4964
4945
|
getSecondLocalKeyName(): string | undefined;
|
|
4965
4946
|
}
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
declare const HasOne_base: (new (...args: any[]) => Relation & typeof Relation & {
|
|
4947
|
+
//#endregion
|
|
4948
|
+
//#region src/relations/has-one.d.ts
|
|
4949
|
+
declare const HasOne_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & {
|
|
4970
4950
|
[x: string]: any;
|
|
4971
4951
|
_withDefault?: boolean | TFunction | TGeneric;
|
|
4972
4952
|
withDefault(callback?: boolean): /*elided*/any;
|
|
@@ -5011,13 +4991,13 @@ declare const HasOne_base: (new (...args: any[]) => Relation & typeof Relation &
|
|
|
5011
4991
|
addConstraints(): void;
|
|
5012
4992
|
};
|
|
5013
4993
|
} & {
|
|
5014
|
-
prototype: Relation;
|
|
4994
|
+
prototype: Relation$1;
|
|
5015
4995
|
constraints: boolean;
|
|
5016
4996
|
selfJoinCount: number;
|
|
5017
|
-
extend: typeof Relation.extend;
|
|
5018
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4997
|
+
extend: typeof Relation$1.extend;
|
|
4998
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
5019
4999
|
};
|
|
5020
|
-
declare class HasOne extends HasOne_base {
|
|
5000
|
+
declare class HasOne$1 extends HasOne_base {
|
|
5021
5001
|
foreignKey?: string | null;
|
|
5022
5002
|
localKey?: string | null;
|
|
5023
5003
|
constructor(query: Builder, parent: Builder, foreignKey?: string | null, localKey?: string | null);
|
|
@@ -5029,31 +5009,9 @@ declare class HasOne extends HasOne_base {
|
|
|
5029
5009
|
addEagerConstraints(models: Model$1[]): void;
|
|
5030
5010
|
newRelatedInstanceFor(parent: Model$1): any;
|
|
5031
5011
|
}
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
declare const HasOneOrMany: <TBase extends MixinConstructor>(Relation: TBase) => {
|
|
5036
|
-
new (...args: any[]): {
|
|
5037
|
-
[x: string]: any;
|
|
5038
|
-
getRelationValue(dictionary: TGeneric, key: string, type: string): any;
|
|
5039
|
-
matchOneOrMany(models: Model$1[], results: any, relation: string, type: string): Model$1[];
|
|
5040
|
-
buildDictionary(results: any): any;
|
|
5041
|
-
save(model: Model$1): Promise<false | Model$1>;
|
|
5042
|
-
saveMany(models: Model$1[]): Promise<(Model$1[] & Collection$1<any>) | Collection$1<Model$1>>;
|
|
5043
|
-
create(attributes?: {}): Promise<any>;
|
|
5044
|
-
createMany(records: any[]): Promise<Collection$1<any>>;
|
|
5045
|
-
setForeignAttributesForCreate(model: Model$1): void;
|
|
5046
|
-
getForeignKeyName(): any;
|
|
5047
|
-
getParentKey(): any;
|
|
5048
|
-
getQualifiedForeignKeyName(): any;
|
|
5049
|
-
getExistenceCompareKey(): any;
|
|
5050
|
-
addConstraints(): void;
|
|
5051
|
-
};
|
|
5052
|
-
} & TBase;
|
|
5053
|
-
declare namespace has_one_through_d_exports {
|
|
5054
|
-
export { HasOneThrough as default };
|
|
5055
|
-
}
|
|
5056
|
-
declare const HasOneThrough_base: (new (...args: any[]) => HasManyThrough & typeof HasManyThrough & {
|
|
5012
|
+
//#endregion
|
|
5013
|
+
//#region src/relations/has-one-through.d.ts
|
|
5014
|
+
declare const HasOneThrough_base: (new (...args: any[]) => HasManyThrough$1 & typeof HasManyThrough$1 & {
|
|
5057
5015
|
[x: string]: any;
|
|
5058
5016
|
_withDefault?: boolean | TFunction | TGeneric;
|
|
5059
5017
|
withDefault(callback?: boolean): /*elided*/any;
|
|
@@ -5066,17 +5024,53 @@ declare const HasOneThrough_base: (new (...args: any[]) => HasManyThrough & type
|
|
|
5066
5024
|
getDefaultFor<P$1>(parent: P$1): any;
|
|
5067
5025
|
};
|
|
5068
5026
|
} & {
|
|
5069
|
-
prototype: HasManyThrough;
|
|
5027
|
+
prototype: HasManyThrough$1;
|
|
5070
5028
|
constraints: boolean;
|
|
5071
5029
|
selfJoinCount: number;
|
|
5072
|
-
extend: typeof Relation.extend;
|
|
5073
|
-
noConstraints: typeof Relation.noConstraints;
|
|
5030
|
+
extend: typeof Relation$1.extend;
|
|
5031
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
5074
5032
|
};
|
|
5075
|
-
declare class HasOneThrough extends HasOneThrough_base {
|
|
5033
|
+
declare class HasOneThrough$1 extends HasOneThrough_base {
|
|
5076
5034
|
getResults(): Promise<any>;
|
|
5077
5035
|
initRelation(models: Model$1[], relation: string): Model$1[];
|
|
5078
5036
|
match(models: Model$1[], results: any, relation: string): Model$1[];
|
|
5079
5037
|
newRelatedInstanceFor(_parent: Model$1): any;
|
|
5080
5038
|
}
|
|
5081
5039
|
//#endregion
|
|
5082
|
-
|
|
5040
|
+
//#region src/relations/index.d.ts
|
|
5041
|
+
declare const BelongsTo: typeof BelongsTo$1;
|
|
5042
|
+
declare const BelongsToMany: typeof BelongsToMany$1;
|
|
5043
|
+
declare const InteractsWithPivotTable: <TBase extends MixinConstructor>(Relation: TBase) => MixinConstructor;
|
|
5044
|
+
declare const SupportsDefaultModels: <TBase extends MixinConstructor>(Relation: TBase) => {
|
|
5045
|
+
new (...args: any[]): {
|
|
5046
|
+
[x: string]: any;
|
|
5047
|
+
_withDefault?: boolean | TFunction | TGeneric;
|
|
5048
|
+
withDefault(callback?: boolean): /*elided*/any;
|
|
5049
|
+
getDefaultFor<P$1>(parent: P$1): any;
|
|
5050
|
+
};
|
|
5051
|
+
} & TBase;
|
|
5052
|
+
declare const HasMany: typeof HasMany$1;
|
|
5053
|
+
declare const HasManyThrough: typeof HasManyThrough$1;
|
|
5054
|
+
declare const HasOne: typeof HasOne$1;
|
|
5055
|
+
declare const HasOneOrMany: <TBase extends MixinConstructor>(Relation: TBase) => {
|
|
5056
|
+
new (...args: any[]): {
|
|
5057
|
+
[x: string]: any;
|
|
5058
|
+
getRelationValue(dictionary: TGeneric, key: string, type: string): any;
|
|
5059
|
+
matchOneOrMany(models: Model$1[], results: any, relation: string, type: string): Model$1[];
|
|
5060
|
+
buildDictionary(results: any): any;
|
|
5061
|
+
save(model: Model$1): Promise<false | Model$1>;
|
|
5062
|
+
saveMany(models: Model$1[]): Promise<(Model$1[] & Collection$1<any>) | Collection$1<Model$1>>;
|
|
5063
|
+
create(attributes?: {}): Promise<any>;
|
|
5064
|
+
createMany(records: any[]): Promise<Collection$1<any>>;
|
|
5065
|
+
setForeignAttributesForCreate(model: Model$1): void;
|
|
5066
|
+
getForeignKeyName(): any;
|
|
5067
|
+
getParentKey(): any;
|
|
5068
|
+
getQualifiedForeignKeyName(): any;
|
|
5069
|
+
getExistenceCompareKey(): any;
|
|
5070
|
+
addConstraints(): void;
|
|
5071
|
+
};
|
|
5072
|
+
} & TBase;
|
|
5073
|
+
declare const HasOneThrough: typeof HasOneThrough$1;
|
|
5074
|
+
declare const Relation: typeof Relation$1;
|
|
5075
|
+
//#endregion
|
|
5076
|
+
export { BelongsTo, BelongsToMany, HasMany, HasManyThrough, HasOne, HasOneOrMany, HasOneThrough, InteractsWithPivotTable, Relation, SupportsDefaultModels };
|
package/dist/relations/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "node:module";
|
|
2
2
|
import { assign, camel, diff, flat, get, isArray, isEmpty, isEqual, isString, omit, pick, set, snake, trim } from "radashi";
|
|
3
3
|
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
4
4
|
import dayjs from "dayjs";
|
|
@@ -9,6 +9,18 @@ import { existsSync } from "fs";
|
|
|
9
9
|
import { FileSystem } from "@h3ravel/shared";
|
|
10
10
|
import pluralize from "pluralize";
|
|
11
11
|
|
|
12
|
+
//#region rolldown:runtime
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __export = (all) => {
|
|
15
|
+
let target = {};
|
|
16
|
+
for (var name in all) __defProp(target, name, {
|
|
17
|
+
get: all[name],
|
|
18
|
+
enumerable: true
|
|
19
|
+
});
|
|
20
|
+
return target;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
12
24
|
//#region src/mixin.ts
|
|
13
25
|
var mixin_exports = /* @__PURE__ */ __export({ compose: () => compose$1 });
|
|
14
26
|
/**
|
|
@@ -284,9 +296,8 @@ var collection_default = Collection$1;
|
|
|
284
296
|
|
|
285
297
|
//#endregion
|
|
286
298
|
//#region src/relations/concerns/interacts-with-pivot-table.ts
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return class extends Relation$1 {
|
|
299
|
+
const InteractsWithPivotTable$1 = (Relation$2) => {
|
|
300
|
+
return class extends Relation$2 {
|
|
290
301
|
newExistingPivot(attributes = []) {
|
|
291
302
|
return this.newPivot(attributes, true);
|
|
292
303
|
}
|
|
@@ -473,7 +484,7 @@ const InteractsWithPivotTable = (Relation$1) => {
|
|
|
473
484
|
}
|
|
474
485
|
};
|
|
475
486
|
};
|
|
476
|
-
var interacts_with_pivot_table_default = InteractsWithPivotTable;
|
|
487
|
+
var interacts_with_pivot_table_default = InteractsWithPivotTable$1;
|
|
477
488
|
|
|
478
489
|
//#endregion
|
|
479
490
|
//#region src/errors.ts
|
|
@@ -511,8 +522,7 @@ var InvalidArgumentError = class extends BaseError {};
|
|
|
511
522
|
|
|
512
523
|
//#endregion
|
|
513
524
|
//#region src/relations/relation.ts
|
|
514
|
-
var
|
|
515
|
-
var Relation = class {
|
|
525
|
+
var Relation$1 = class {
|
|
516
526
|
query;
|
|
517
527
|
parent;
|
|
518
528
|
related;
|
|
@@ -600,12 +610,11 @@ var Relation = class {
|
|
|
600
610
|
return (_this$getQualifiedFor = this.getQualifiedForeignKeyName) === null || _this$getQualifiedFor === void 0 ? void 0 : _this$getQualifiedFor.call(this);
|
|
601
611
|
}
|
|
602
612
|
};
|
|
603
|
-
var relation_default = Relation;
|
|
613
|
+
var relation_default = Relation$1;
|
|
604
614
|
|
|
605
615
|
//#endregion
|
|
606
616
|
//#region src/relations/belongs-to-many.ts
|
|
607
|
-
var
|
|
608
|
-
var BelongsToMany = class extends compose(relation_default, interacts_with_pivot_table_default) {
|
|
617
|
+
var BelongsToMany$1 = class extends compose(relation_default, interacts_with_pivot_table_default) {
|
|
609
618
|
table;
|
|
610
619
|
foreignPivotKey;
|
|
611
620
|
relatedPivotKey;
|
|
@@ -826,7 +835,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
826
835
|
return super.getRelationExistenceQuery(query, parentQuery, columns);
|
|
827
836
|
}
|
|
828
837
|
};
|
|
829
|
-
var belongs_to_many_default = BelongsToMany;
|
|
838
|
+
var belongs_to_many_default = BelongsToMany$1;
|
|
830
839
|
|
|
831
840
|
//#endregion
|
|
832
841
|
//#region src/paginator.ts
|
|
@@ -1969,9 +1978,8 @@ var has_hooks_default = HasHooks;
|
|
|
1969
1978
|
|
|
1970
1979
|
//#endregion
|
|
1971
1980
|
//#region src/relations/has-one-or-many.ts
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
return class extends Relation$1 {
|
|
1981
|
+
const HasOneOrMany$1 = (Relation$2) => {
|
|
1982
|
+
return class extends Relation$2 {
|
|
1975
1983
|
getRelationValue(dictionary, key, type) {
|
|
1976
1984
|
const value = dictionary[key];
|
|
1977
1985
|
return type === "one" ? value[0] : new collection_default(value);
|
|
@@ -2035,12 +2043,11 @@ const HasOneOrMany = (Relation$1) => {
|
|
|
2035
2043
|
}
|
|
2036
2044
|
};
|
|
2037
2045
|
};
|
|
2038
|
-
var has_one_or_many_default = HasOneOrMany;
|
|
2046
|
+
var has_one_or_many_default = HasOneOrMany$1;
|
|
2039
2047
|
|
|
2040
2048
|
//#endregion
|
|
2041
2049
|
//#region src/relations/has-many.ts
|
|
2042
|
-
var
|
|
2043
|
-
var HasMany = class extends compose(relation_default, has_one_or_many_default) {
|
|
2050
|
+
var HasMany$1 = class extends compose(relation_default, has_one_or_many_default) {
|
|
2044
2051
|
foreignKey;
|
|
2045
2052
|
localKey;
|
|
2046
2053
|
constructor(query, parent, foreignKey, localKey) {
|
|
@@ -2075,13 +2082,12 @@ var HasMany = class extends compose(relation_default, has_one_or_many_default) {
|
|
|
2075
2082
|
this.query.whereIn(this.foreignKey, this.getKeys(models, this.localKey));
|
|
2076
2083
|
}
|
|
2077
2084
|
};
|
|
2078
|
-
var has_many_default = HasMany;
|
|
2085
|
+
var has_many_default = HasMany$1;
|
|
2079
2086
|
|
|
2080
2087
|
//#endregion
|
|
2081
2088
|
//#region src/relations/concerns/supports-default-models.ts
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
return class extends Relation$1 {
|
|
2089
|
+
const SupportsDefaultModels$1 = (Relation$2) => {
|
|
2090
|
+
return class extends Relation$2 {
|
|
2085
2091
|
_withDefault;
|
|
2086
2092
|
withDefault(callback = true) {
|
|
2087
2093
|
this._withDefault = callback;
|
|
@@ -2096,12 +2102,11 @@ const SupportsDefaultModels = (Relation$1) => {
|
|
|
2096
2102
|
}
|
|
2097
2103
|
};
|
|
2098
2104
|
};
|
|
2099
|
-
var supports_default_models_default = SupportsDefaultModels;
|
|
2105
|
+
var supports_default_models_default = SupportsDefaultModels$1;
|
|
2100
2106
|
|
|
2101
2107
|
//#endregion
|
|
2102
2108
|
//#region src/relations/has-one.ts
|
|
2103
|
-
var
|
|
2104
|
-
var HasOne = class extends compose(relation_default, has_one_or_many_default, supports_default_models_default) {
|
|
2109
|
+
var HasOne$1 = class extends compose(relation_default, has_one_or_many_default, supports_default_models_default) {
|
|
2105
2110
|
foreignKey;
|
|
2106
2111
|
localKey;
|
|
2107
2112
|
constructor(query, parent, foreignKey, localKey) {
|
|
@@ -2139,12 +2144,11 @@ var HasOne = class extends compose(relation_default, has_one_or_many_default, su
|
|
|
2139
2144
|
return this.related.newInstance().setAttribute(this.getForeignKeyName(), parent[this.localKey]);
|
|
2140
2145
|
}
|
|
2141
2146
|
};
|
|
2142
|
-
var has_one_default = HasOne;
|
|
2147
|
+
var has_one_default = HasOne$1;
|
|
2143
2148
|
|
|
2144
2149
|
//#endregion
|
|
2145
2150
|
//#region src/relations/has-many-through.ts
|
|
2146
|
-
var
|
|
2147
|
-
var HasManyThrough = class extends relation_default {
|
|
2151
|
+
var HasManyThrough$1 = class extends relation_default {
|
|
2148
2152
|
throughParent;
|
|
2149
2153
|
farParent;
|
|
2150
2154
|
firstKey;
|
|
@@ -2322,12 +2326,11 @@ var HasManyThrough = class extends relation_default {
|
|
|
2322
2326
|
return this.secondLocalKey;
|
|
2323
2327
|
}
|
|
2324
2328
|
};
|
|
2325
|
-
var has_many_through_default = HasManyThrough;
|
|
2329
|
+
var has_many_through_default = HasManyThrough$1;
|
|
2326
2330
|
|
|
2327
2331
|
//#endregion
|
|
2328
2332
|
//#region src/relations/has-one-through.ts
|
|
2329
|
-
var
|
|
2330
|
-
var HasOneThrough = class extends compose(has_many_through_default, supports_default_models_default) {
|
|
2333
|
+
var HasOneThrough$1 = class extends compose(has_many_through_default, supports_default_models_default) {
|
|
2331
2334
|
async getResults() {
|
|
2332
2335
|
return await this.first() || this.getDefaultFor(this.farParent);
|
|
2333
2336
|
}
|
|
@@ -2350,7 +2353,7 @@ var HasOneThrough = class extends compose(has_many_through_default, supports_def
|
|
|
2350
2353
|
return this.related.newInstance();
|
|
2351
2354
|
}
|
|
2352
2355
|
};
|
|
2353
|
-
var has_one_through_default = HasOneThrough;
|
|
2356
|
+
var has_one_through_default = HasOneThrough$1;
|
|
2354
2357
|
|
|
2355
2358
|
//#endregion
|
|
2356
2359
|
//#region src/concerns/has-relations.ts
|
|
@@ -3347,8 +3350,7 @@ var model_default = Model;
|
|
|
3347
3350
|
|
|
3348
3351
|
//#endregion
|
|
3349
3352
|
//#region src/relations/belongs-to.ts
|
|
3350
|
-
var
|
|
3351
|
-
var BelongsTo = class extends compose(relation_default, supports_default_models_default) {
|
|
3353
|
+
var BelongsTo$1 = class extends compose(relation_default, supports_default_models_default) {
|
|
3352
3354
|
foreignKey;
|
|
3353
3355
|
ownerKey;
|
|
3354
3356
|
child;
|
|
@@ -3433,7 +3435,20 @@ var BelongsTo = class extends compose(relation_default, supports_default_models_
|
|
|
3433
3435
|
return this.related.newInstance();
|
|
3434
3436
|
}
|
|
3435
3437
|
};
|
|
3436
|
-
var belongs_to_default = BelongsTo;
|
|
3438
|
+
var belongs_to_default = BelongsTo$1;
|
|
3439
|
+
|
|
3440
|
+
//#endregion
|
|
3441
|
+
//#region src/relations/index.ts
|
|
3442
|
+
const BelongsTo = belongs_to_default;
|
|
3443
|
+
const BelongsToMany = belongs_to_many_default;
|
|
3444
|
+
const InteractsWithPivotTable = interacts_with_pivot_table_default;
|
|
3445
|
+
const SupportsDefaultModels = supports_default_models_default;
|
|
3446
|
+
const HasMany = has_many_default;
|
|
3447
|
+
const HasManyThrough = has_many_through_default;
|
|
3448
|
+
const HasOne = has_one_default;
|
|
3449
|
+
const HasOneOrMany = has_one_or_many_default;
|
|
3450
|
+
const HasOneThrough = has_one_through_default;
|
|
3451
|
+
const Relation = relation_default;
|
|
3437
3452
|
|
|
3438
3453
|
//#endregion
|
|
3439
|
-
export {
|
|
3454
|
+
export { BelongsTo, BelongsToMany, HasMany, HasManyThrough, HasOne, HasOneOrMany, HasOneThrough, InteractsWithPivotTable, Relation, SupportsDefaultModels };
|
package/dist/seeders/index.d.ts
CHANGED
|
@@ -468,6 +468,7 @@ interface IModel {
|
|
|
468
468
|
setAppends(appends: string[]): this;
|
|
469
469
|
append(key: string | string[]): this;
|
|
470
470
|
getRelation<T$1 extends Model$1>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
471
|
+
getRelation<T$1 extends Model$1, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
471
472
|
setRelation<T$1 extends Model$1>(relation: string, value: T$1 | ICollection<T$1> | null): this;
|
|
472
473
|
unsetRelation(relation: string): this;
|
|
473
474
|
relationLoaded(relation: string): boolean;
|
|
@@ -1391,7 +1392,10 @@ declare const BaseModel$1: (new (...args: any[]) => any) & {
|
|
|
1391
1392
|
uniqueIds(): never[];
|
|
1392
1393
|
setUniqueIds(): void;
|
|
1393
1394
|
});
|
|
1394
|
-
getRelation:
|
|
1395
|
+
getRelation: {
|
|
1396
|
+
<T$1 extends Model$1>(relation: string): T$1 | ICollection<T$1> | null | undefined;
|
|
1397
|
+
<T$1 extends Model$1, IsCollection extends boolean = false>(relation: string): IsCollection extends true ? ICollection<T$1> | undefined : T$1 | null | undefined;
|
|
1398
|
+
};
|
|
1395
1399
|
setRelation: <T$1 extends Model$1>(relation: string, value: T$1 | ICollection<T$1> | null) => (new () => IModel) & IModel & {
|
|
1396
1400
|
[x: string]: any;
|
|
1397
1401
|
timestamps: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/arquebus",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Arquebus ORM is a Beautiful, expressive ORM inspired by Laravel's Eloquent, designed for TypeScript applications and for the H3ravel Framework.",
|
|
5
5
|
"homepage": "https://h3ravel.toneflix.net/arquebus",
|
|
6
6
|
"bin": {
|