@h3ravel/arquebus 0.7.1 → 0.7.2
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 +1 -1
- package/bin/index.js +1 -1
- package/dist/concerns/index.cjs +35 -72
- package/dist/concerns/index.d.ts +209 -235
- package/dist/concerns/index.js +41 -26
- package/dist/relations/index.cjs +46 -93
- package/dist/relations/index.d.ts +93 -103
- package/dist/relations/index.js +50 -35
- package/package.json +1 -1
- 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;
|
|
@@ -192,10 +189,10 @@ interface IModel {
|
|
|
192
189
|
isNot(model: this): boolean;
|
|
193
190
|
related<T$1 extends RelationNames<this>>(relation: T$1): ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T$1>>}`>;
|
|
194
191
|
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$
|
|
192
|
+
hasOne<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string): HasOne$2<T$1>;
|
|
193
|
+
hasMany<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string): HasMany$2<T$1>;
|
|
194
|
+
belongsTo<T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, ownerKey?: string, relation?: string): BelongsTo$2<T$1>;
|
|
195
|
+
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
196
|
}
|
|
200
197
|
//#endregion
|
|
201
198
|
//#region src/collection.d.ts
|
|
@@ -648,10 +645,9 @@ declare class QueryBuilder<M extends Model$1 = Model$1, R$1 = M[] | M> extends I
|
|
|
648
645
|
get _single(): any;
|
|
649
646
|
get from(): Knex.Table<any, any> & Knex.Table<any, any[]>;
|
|
650
647
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
declare class Relation {
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/relations/relation.d.ts
|
|
650
|
+
declare class Relation$1 {
|
|
655
651
|
query: QueryBuilder;
|
|
656
652
|
parent: any;
|
|
657
653
|
related: any;
|
|
@@ -800,7 +796,7 @@ interface ModelOptions<M extends Model$1 = Model$1> {
|
|
|
800
796
|
table?: string;
|
|
801
797
|
scopes?: TGeneric<(...args: any[]) => Builder<M>>;
|
|
802
798
|
plugins?: (<X extends MixinConstructor<M>>(Model: X) => MixinConstructor<M>)[];
|
|
803
|
-
relations?: TGeneric<(...args: any[]) => Relation>;
|
|
799
|
+
relations?: TGeneric<(...args: any[]) => Relation$1>;
|
|
804
800
|
attributes?: TGeneric<Attribute>;
|
|
805
801
|
CREATED_AT?: string;
|
|
806
802
|
UPDATED_AT?: string;
|
|
@@ -4098,10 +4094,10 @@ declare const BaseModel: (new (...args: any[]) => any) & {
|
|
|
4098
4094
|
uniqueIds(): never[];
|
|
4099
4095
|
setUniqueIds(): void;
|
|
4100
4096
|
}, `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$
|
|
4097
|
+
hasOne: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string) => HasOne$2<T$1>;
|
|
4098
|
+
hasMany: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, localKey?: string) => HasMany$2<T$1>;
|
|
4099
|
+
belongsTo: <T$1 extends Model$1>(model: new () => T$1, foreignKey?: string, ownerKey?: string, relation?: string) => BelongsTo$2<T$1>;
|
|
4100
|
+
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
4101
|
original: TGeneric;
|
|
4106
4102
|
casts: TGeneric<typeof CastsAttributes | "int" | "json" | "string" | "date" | "boolean" | "datetime" | "collection">;
|
|
4107
4103
|
changes: TGeneric;
|
|
@@ -4734,10 +4730,9 @@ type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? U e
|
|
|
4734
4730
|
type FunctionPropertyNames<T$1> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? K : never }[keyof T$1];
|
|
4735
4731
|
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
4732
|
type MixinConstructor<T$1 = TGeneric> = new (...args: any[]) => T$1;
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
declare const BelongsTo_base: (new (...args: any[]) => Relation & typeof Relation & {
|
|
4733
|
+
//#endregion
|
|
4734
|
+
//#region src/relations/belongs-to.d.ts
|
|
4735
|
+
declare const BelongsTo_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & {
|
|
4741
4736
|
[x: string]: any;
|
|
4742
4737
|
_withDefault?: boolean | TFunction | TGeneric;
|
|
4743
4738
|
withDefault(callback?: boolean): /*elided*/any;
|
|
@@ -4750,13 +4745,13 @@ declare const BelongsTo_base: (new (...args: any[]) => Relation & typeof Relatio
|
|
|
4750
4745
|
getDefaultFor<P$1>(parent: P$1): any;
|
|
4751
4746
|
};
|
|
4752
4747
|
} & {
|
|
4753
|
-
prototype: Relation;
|
|
4748
|
+
prototype: Relation$1;
|
|
4754
4749
|
constraints: boolean;
|
|
4755
4750
|
selfJoinCount: number;
|
|
4756
|
-
extend: typeof Relation.extend;
|
|
4757
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4751
|
+
extend: typeof Relation$1.extend;
|
|
4752
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
4758
4753
|
};
|
|
4759
|
-
declare class BelongsTo extends BelongsTo_base {
|
|
4754
|
+
declare class BelongsTo$1 extends BelongsTo_base {
|
|
4760
4755
|
foreignKey?: string;
|
|
4761
4756
|
ownerKey?: string;
|
|
4762
4757
|
child: Model$1;
|
|
@@ -4775,17 +4770,16 @@ declare class BelongsTo extends BelongsTo_base {
|
|
|
4775
4770
|
addConstraints(this: any): void;
|
|
4776
4771
|
newRelatedInstanceFor(_parent: any): Model$1;
|
|
4777
4772
|
}
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
}
|
|
4781
|
-
|
|
4782
|
-
prototype: Relation;
|
|
4773
|
+
//#endregion
|
|
4774
|
+
//#region src/relations/belongs-to-many.d.ts
|
|
4775
|
+
declare const BelongsToMany_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & TGeneric<any, string>) & {} & {
|
|
4776
|
+
prototype: Relation$1;
|
|
4783
4777
|
constraints: boolean;
|
|
4784
4778
|
selfJoinCount: number;
|
|
4785
|
-
extend: typeof Relation.extend;
|
|
4786
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4779
|
+
extend: typeof Relation$1.extend;
|
|
4780
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
4787
4781
|
};
|
|
4788
|
-
declare class BelongsToMany extends BelongsToMany_base {
|
|
4782
|
+
declare class BelongsToMany$1 extends BelongsToMany_base {
|
|
4789
4783
|
table?: string;
|
|
4790
4784
|
foreignPivotKey?: string;
|
|
4791
4785
|
relatedPivotKey?: string;
|
|
@@ -4848,25 +4842,9 @@ declare class BelongsToMany extends BelongsToMany_base {
|
|
|
4848
4842
|
getRelationExistenceQuery(query: any, parentQuery: any, columns?: string[]): any;
|
|
4849
4843
|
getRelationExistenceQueryForSelfJoin(query: any, parentQuery: any, columns?: string[]): any;
|
|
4850
4844
|
}
|
|
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 & {
|
|
4845
|
+
//#endregion
|
|
4846
|
+
//#region src/relations/has-many.d.ts
|
|
4847
|
+
declare const HasMany_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & {
|
|
4870
4848
|
[x: string]: any;
|
|
4871
4849
|
getRelationValue(dictionary: TGeneric, key: string, type: string): any;
|
|
4872
4850
|
matchOneOrMany(models: Model$1[], results: any, relation: string, type: string): Model$1[];
|
|
@@ -4899,13 +4877,13 @@ declare const HasMany_base: (new (...args: any[]) => Relation & typeof Relation
|
|
|
4899
4877
|
addConstraints(): void;
|
|
4900
4878
|
};
|
|
4901
4879
|
} & {
|
|
4902
|
-
prototype: Relation;
|
|
4880
|
+
prototype: Relation$1;
|
|
4903
4881
|
constraints: boolean;
|
|
4904
4882
|
selfJoinCount: number;
|
|
4905
|
-
extend: typeof Relation.extend;
|
|
4906
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4883
|
+
extend: typeof Relation$1.extend;
|
|
4884
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
4907
4885
|
};
|
|
4908
|
-
declare class HasMany extends HasMany_base {
|
|
4886
|
+
declare class HasMany$1 extends HasMany_base {
|
|
4909
4887
|
foreignKey?: string | null;
|
|
4910
4888
|
localKey?: string | null;
|
|
4911
4889
|
constructor(query: any, parent: any, foreignKey?: string | null, localKey?: string | null);
|
|
@@ -4916,10 +4894,9 @@ declare class HasMany extends HasMany_base {
|
|
|
4916
4894
|
match(models: Model$1[], results: any, relation: string): Model$1[];
|
|
4917
4895
|
addEagerConstraints(models: Model$1[]): void;
|
|
4918
4896
|
}
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
declare class HasManyThrough extends Relation {
|
|
4897
|
+
//#endregion
|
|
4898
|
+
//#region src/relations/has-many-through.d.ts
|
|
4899
|
+
declare class HasManyThrough$1 extends Relation$1 {
|
|
4923
4900
|
throughParent: any;
|
|
4924
4901
|
farParent: any;
|
|
4925
4902
|
firstKey?: string;
|
|
@@ -4963,10 +4940,9 @@ declare class HasManyThrough extends Relation {
|
|
|
4963
4940
|
getQualifiedLocalKeyName(): any;
|
|
4964
4941
|
getSecondLocalKeyName(): string | undefined;
|
|
4965
4942
|
}
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
declare const HasOne_base: (new (...args: any[]) => Relation & typeof Relation & {
|
|
4943
|
+
//#endregion
|
|
4944
|
+
//#region src/relations/has-one.d.ts
|
|
4945
|
+
declare const HasOne_base: (new (...args: any[]) => Relation$1 & typeof Relation$1 & {
|
|
4970
4946
|
[x: string]: any;
|
|
4971
4947
|
_withDefault?: boolean | TFunction | TGeneric;
|
|
4972
4948
|
withDefault(callback?: boolean): /*elided*/any;
|
|
@@ -5011,13 +4987,13 @@ declare const HasOne_base: (new (...args: any[]) => Relation & typeof Relation &
|
|
|
5011
4987
|
addConstraints(): void;
|
|
5012
4988
|
};
|
|
5013
4989
|
} & {
|
|
5014
|
-
prototype: Relation;
|
|
4990
|
+
prototype: Relation$1;
|
|
5015
4991
|
constraints: boolean;
|
|
5016
4992
|
selfJoinCount: number;
|
|
5017
|
-
extend: typeof Relation.extend;
|
|
5018
|
-
noConstraints: typeof Relation.noConstraints;
|
|
4993
|
+
extend: typeof Relation$1.extend;
|
|
4994
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
5019
4995
|
};
|
|
5020
|
-
declare class HasOne extends HasOne_base {
|
|
4996
|
+
declare class HasOne$1 extends HasOne_base {
|
|
5021
4997
|
foreignKey?: string | null;
|
|
5022
4998
|
localKey?: string | null;
|
|
5023
4999
|
constructor(query: Builder, parent: Builder, foreignKey?: string | null, localKey?: string | null);
|
|
@@ -5029,31 +5005,9 @@ declare class HasOne extends HasOne_base {
|
|
|
5029
5005
|
addEagerConstraints(models: Model$1[]): void;
|
|
5030
5006
|
newRelatedInstanceFor(parent: Model$1): any;
|
|
5031
5007
|
}
|
|
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 & {
|
|
5008
|
+
//#endregion
|
|
5009
|
+
//#region src/relations/has-one-through.d.ts
|
|
5010
|
+
declare const HasOneThrough_base: (new (...args: any[]) => HasManyThrough$1 & typeof HasManyThrough$1 & {
|
|
5057
5011
|
[x: string]: any;
|
|
5058
5012
|
_withDefault?: boolean | TFunction | TGeneric;
|
|
5059
5013
|
withDefault(callback?: boolean): /*elided*/any;
|
|
@@ -5066,17 +5020,53 @@ declare const HasOneThrough_base: (new (...args: any[]) => HasManyThrough & type
|
|
|
5066
5020
|
getDefaultFor<P$1>(parent: P$1): any;
|
|
5067
5021
|
};
|
|
5068
5022
|
} & {
|
|
5069
|
-
prototype: HasManyThrough;
|
|
5023
|
+
prototype: HasManyThrough$1;
|
|
5070
5024
|
constraints: boolean;
|
|
5071
5025
|
selfJoinCount: number;
|
|
5072
|
-
extend: typeof Relation.extend;
|
|
5073
|
-
noConstraints: typeof Relation.noConstraints;
|
|
5026
|
+
extend: typeof Relation$1.extend;
|
|
5027
|
+
noConstraints: typeof Relation$1.noConstraints;
|
|
5074
5028
|
};
|
|
5075
|
-
declare class HasOneThrough extends HasOneThrough_base {
|
|
5029
|
+
declare class HasOneThrough$1 extends HasOneThrough_base {
|
|
5076
5030
|
getResults(): Promise<any>;
|
|
5077
5031
|
initRelation(models: Model$1[], relation: string): Model$1[];
|
|
5078
5032
|
match(models: Model$1[], results: any, relation: string): Model$1[];
|
|
5079
5033
|
newRelatedInstanceFor(_parent: Model$1): any;
|
|
5080
5034
|
}
|
|
5081
5035
|
//#endregion
|
|
5082
|
-
|
|
5036
|
+
//#region src/relations/index.d.ts
|
|
5037
|
+
declare const BelongsTo: typeof BelongsTo$1;
|
|
5038
|
+
declare const BelongsToMany: typeof BelongsToMany$1;
|
|
5039
|
+
declare const InteractsWithPivotTable: <TBase extends MixinConstructor>(Relation: TBase) => MixinConstructor;
|
|
5040
|
+
declare const SupportsDefaultModels: <TBase extends MixinConstructor>(Relation: TBase) => {
|
|
5041
|
+
new (...args: any[]): {
|
|
5042
|
+
[x: string]: any;
|
|
5043
|
+
_withDefault?: boolean | TFunction | TGeneric;
|
|
5044
|
+
withDefault(callback?: boolean): /*elided*/any;
|
|
5045
|
+
getDefaultFor<P$1>(parent: P$1): any;
|
|
5046
|
+
};
|
|
5047
|
+
} & TBase;
|
|
5048
|
+
declare const HasMany: typeof HasMany$1;
|
|
5049
|
+
declare const HasManyThrough: typeof HasManyThrough$1;
|
|
5050
|
+
declare const HasOne: typeof HasOne$1;
|
|
5051
|
+
declare const HasOneOrMany: <TBase extends MixinConstructor>(Relation: TBase) => {
|
|
5052
|
+
new (...args: any[]): {
|
|
5053
|
+
[x: string]: any;
|
|
5054
|
+
getRelationValue(dictionary: TGeneric, key: string, type: string): any;
|
|
5055
|
+
matchOneOrMany(models: Model$1[], results: any, relation: string, type: string): Model$1[];
|
|
5056
|
+
buildDictionary(results: any): any;
|
|
5057
|
+
save(model: Model$1): Promise<false | Model$1>;
|
|
5058
|
+
saveMany(models: Model$1[]): Promise<(Model$1[] & Collection$1<any>) | Collection$1<Model$1>>;
|
|
5059
|
+
create(attributes?: {}): Promise<any>;
|
|
5060
|
+
createMany(records: any[]): Promise<Collection$1<any>>;
|
|
5061
|
+
setForeignAttributesForCreate(model: Model$1): void;
|
|
5062
|
+
getForeignKeyName(): any;
|
|
5063
|
+
getParentKey(): any;
|
|
5064
|
+
getQualifiedForeignKeyName(): any;
|
|
5065
|
+
getExistenceCompareKey(): any;
|
|
5066
|
+
addConstraints(): void;
|
|
5067
|
+
};
|
|
5068
|
+
} & TBase;
|
|
5069
|
+
declare const HasOneThrough: typeof HasOneThrough$1;
|
|
5070
|
+
declare const Relation: typeof Relation$1;
|
|
5071
|
+
//#endregion
|
|
5072
|
+
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/arquebus",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
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": {
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __export = (all) => {
|
|
6
|
-
let target = {};
|
|
7
|
-
for (var name in all) __defProp(target, name, {
|
|
8
|
-
get: all[name],
|
|
9
|
-
enumerable: true
|
|
10
|
-
});
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { __export as t };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __export = (all) => {
|
|
6
|
-
let target = {};
|
|
7
|
-
for (var name in all) __defProp(target, name, {
|
|
8
|
-
get: all[name],
|
|
9
|
-
enumerable: true
|
|
10
|
-
});
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { __export as t };
|