@h3ravel/arquebus 0.7.5 → 0.7.6
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/index.cjs +55 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +55 -1
- package/package.json +1 -1
package/bin/index.cjs
CHANGED
package/bin/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -5640,6 +5640,60 @@ const HasOneOrMany = has_one_or_many_default;
|
|
|
5640
5640
|
const HasOneThrough = has_one_through_default;
|
|
5641
5641
|
const Relation = relation_default;
|
|
5642
5642
|
|
|
5643
|
+
//#endregion
|
|
5644
|
+
//#region src/decorators.ts
|
|
5645
|
+
/**
|
|
5646
|
+
* Relationship Decorator
|
|
5647
|
+
* Supports: _user() -> user and relationUser() -> user
|
|
5648
|
+
*
|
|
5649
|
+
* @param value
|
|
5650
|
+
* @param context
|
|
5651
|
+
*/
|
|
5652
|
+
function Relationship(target, context, descriptor) {
|
|
5653
|
+
const isModern = context && typeof context === "object" && "kind" in context;
|
|
5654
|
+
const propertyKey = isModern ? context.name : context;
|
|
5655
|
+
const originalMethod = isModern ? target : descriptor.value;
|
|
5656
|
+
let internalMethodName;
|
|
5657
|
+
let rootName = propertyKey.replace(/^(_|relation)/, "");
|
|
5658
|
+
if (propertyKey.startsWith("_")) {
|
|
5659
|
+
rootName = propertyKey.slice(1);
|
|
5660
|
+
internalMethodName = `relation${rootName.charAt(0).toUpperCase()}${rootName.slice(1)}`;
|
|
5661
|
+
} else if (propertyKey.startsWith("relation")) {
|
|
5662
|
+
rootName = propertyKey.replace(/^relation/, "").replace(/^\w/, (c) => c.toLowerCase());
|
|
5663
|
+
internalMethodName = `_${rootName}`;
|
|
5664
|
+
}
|
|
5665
|
+
const setupProperty = (proto, logicFn) => {
|
|
5666
|
+
if (!Object.prototype.hasOwnProperty.call(proto, internalMethodName)) Object.defineProperty(proto, internalMethodName, {
|
|
5667
|
+
value: logicFn,
|
|
5668
|
+
writable: true,
|
|
5669
|
+
configurable: true,
|
|
5670
|
+
enumerable: false
|
|
5671
|
+
});
|
|
5672
|
+
if (!Object.getOwnPropertyDescriptor(proto, rootName)) Object.defineProperty(proto, rootName, {
|
|
5673
|
+
async get() {
|
|
5674
|
+
if (this.$relations && this.$relations[rootName] != null) return this.$relations[rootName];
|
|
5675
|
+
const result = await this.getRelated(rootName);
|
|
5676
|
+
if (!this.$relations) this.$relations = {};
|
|
5677
|
+
this.$relations[rootName] = result;
|
|
5678
|
+
return result;
|
|
5679
|
+
},
|
|
5680
|
+
set(val) {
|
|
5681
|
+
if (!this.$relations) this.$relations = {};
|
|
5682
|
+
this.$relations[rootName] = val;
|
|
5683
|
+
},
|
|
5684
|
+
enumerable: true,
|
|
5685
|
+
configurable: true
|
|
5686
|
+
});
|
|
5687
|
+
};
|
|
5688
|
+
if (isModern) context.addInitializer(function() {
|
|
5689
|
+
setupProperty(Object.getPrototypeOf(this), originalMethod);
|
|
5690
|
+
});
|
|
5691
|
+
else {
|
|
5692
|
+
setupProperty(target, originalMethod);
|
|
5693
|
+
return descriptor;
|
|
5694
|
+
}
|
|
5695
|
+
}
|
|
5696
|
+
|
|
5643
5697
|
//#endregion
|
|
5644
5698
|
//#region src/make.ts
|
|
5645
5699
|
const make = (model, data, options = {}) => {
|
|
@@ -5675,6 +5729,7 @@ exports.Pivot = pivot_default;
|
|
|
5675
5729
|
exports.QueryBuilder = query_builder_default;
|
|
5676
5730
|
exports.Relation = Relation;
|
|
5677
5731
|
exports.RelationNotFoundError = RelationNotFoundError;
|
|
5732
|
+
exports.Relationship = Relationship;
|
|
5678
5733
|
exports.Scope = scope_default;
|
|
5679
5734
|
exports.Seeder = seeder_default;
|
|
5680
5735
|
exports.SeederCreator = seeder_creator_default;
|
package/dist/index.d.ts
CHANGED
|
@@ -5463,6 +5463,16 @@ declare const HasOneOrMany: <TBase extends MixinConstructor>(Relation: TBase) =>
|
|
|
5463
5463
|
declare const HasOneThrough: typeof HasOneThrough$1;
|
|
5464
5464
|
declare const Relation: typeof Relation$1;
|
|
5465
5465
|
//#endregion
|
|
5466
|
+
//#region src/decorators.d.ts
|
|
5467
|
+
/**
|
|
5468
|
+
* Relationship Decorator
|
|
5469
|
+
* Supports: _user() -> user and relationUser() -> user
|
|
5470
|
+
*
|
|
5471
|
+
* @param value
|
|
5472
|
+
* @param context
|
|
5473
|
+
*/
|
|
5474
|
+
declare function Relationship(target: any, context?: any, descriptor?: any): any;
|
|
5475
|
+
//#endregion
|
|
5466
5476
|
//#region src/contracts/utilities.d.ts
|
|
5467
5477
|
type DeepWrappedData<D> = { [K in keyof D]: D[K] extends Array<infer V> ? Collection<DeepWrappedData<V>> : D[K] extends object ? DeepWrappedData<D[K]> : D[K] };
|
|
5468
5478
|
interface IMake {
|
|
@@ -5476,4 +5486,4 @@ declare const make: IMake;
|
|
|
5476
5486
|
declare const makeCollection: <T$1 extends typeof Model$1>(model: T$1, data: TGeneric) => Collection<Model$1 | Model$2>;
|
|
5477
5487
|
declare const makePaginator: <T$1 extends typeof Model$1>(model: T$1, data: TGeneric) => Paginator<T$1, IPaginatorParams>;
|
|
5478
5488
|
//#endregion
|
|
5479
|
-
export { Attribute, BelongsTo, BelongsToMany, Builder, CastsAttributes, Collection, HasMany, HasManyThrough, HasOne, HasOneOrMany, HasOneThrough, HasUniqueIds, InteractsWithPivotTable, InvalidArgumentError, Migrate, Migration, Model$1 as Model, ModelNotFoundError, Paginator, Pivot, QueryBuilder, Relation, RelationNotFoundError, Scope, Seeder, SeederCreator, SeederRunner, softDeletes as SoftDeletes, SupportsDefaultModels, arquebus, compose, defineConfig, flatten, flattenDeep, getAttrMethod, getAttrName, getGetterMethod, getRelationMethod, getRelationName, getScopeMethod, getScopeName, getSetterMethod, kebabCase, make, makeCollection, makePaginator, now, snakeCase, tap };
|
|
5489
|
+
export { Attribute, BelongsTo, BelongsToMany, Builder, CastsAttributes, Collection, HasMany, HasManyThrough, HasOne, HasOneOrMany, HasOneThrough, HasUniqueIds, InteractsWithPivotTable, InvalidArgumentError, Migrate, Migration, Model$1 as Model, ModelNotFoundError, Paginator, Pivot, QueryBuilder, Relation, RelationNotFoundError, Relationship, Scope, Seeder, SeederCreator, SeederRunner, softDeletes as SoftDeletes, SupportsDefaultModels, arquebus, compose, defineConfig, flatten, flattenDeep, getAttrMethod, getAttrName, getGetterMethod, getRelationMethod, getRelationName, getScopeMethod, getScopeName, getSetterMethod, kebabCase, make, makeCollection, makePaginator, now, snakeCase, tap };
|
package/dist/index.js
CHANGED
|
@@ -5614,6 +5614,60 @@ const HasOneOrMany = has_one_or_many_default;
|
|
|
5614
5614
|
const HasOneThrough = has_one_through_default;
|
|
5615
5615
|
const Relation = relation_default;
|
|
5616
5616
|
|
|
5617
|
+
//#endregion
|
|
5618
|
+
//#region src/decorators.ts
|
|
5619
|
+
/**
|
|
5620
|
+
* Relationship Decorator
|
|
5621
|
+
* Supports: _user() -> user and relationUser() -> user
|
|
5622
|
+
*
|
|
5623
|
+
* @param value
|
|
5624
|
+
* @param context
|
|
5625
|
+
*/
|
|
5626
|
+
function Relationship(target, context, descriptor) {
|
|
5627
|
+
const isModern = context && typeof context === "object" && "kind" in context;
|
|
5628
|
+
const propertyKey = isModern ? context.name : context;
|
|
5629
|
+
const originalMethod = isModern ? target : descriptor.value;
|
|
5630
|
+
let internalMethodName;
|
|
5631
|
+
let rootName = propertyKey.replace(/^(_|relation)/, "");
|
|
5632
|
+
if (propertyKey.startsWith("_")) {
|
|
5633
|
+
rootName = propertyKey.slice(1);
|
|
5634
|
+
internalMethodName = `relation${rootName.charAt(0).toUpperCase()}${rootName.slice(1)}`;
|
|
5635
|
+
} else if (propertyKey.startsWith("relation")) {
|
|
5636
|
+
rootName = propertyKey.replace(/^relation/, "").replace(/^\w/, (c) => c.toLowerCase());
|
|
5637
|
+
internalMethodName = `_${rootName}`;
|
|
5638
|
+
}
|
|
5639
|
+
const setupProperty = (proto, logicFn) => {
|
|
5640
|
+
if (!Object.prototype.hasOwnProperty.call(proto, internalMethodName)) Object.defineProperty(proto, internalMethodName, {
|
|
5641
|
+
value: logicFn,
|
|
5642
|
+
writable: true,
|
|
5643
|
+
configurable: true,
|
|
5644
|
+
enumerable: false
|
|
5645
|
+
});
|
|
5646
|
+
if (!Object.getOwnPropertyDescriptor(proto, rootName)) Object.defineProperty(proto, rootName, {
|
|
5647
|
+
async get() {
|
|
5648
|
+
if (this.$relations && this.$relations[rootName] != null) return this.$relations[rootName];
|
|
5649
|
+
const result = await this.getRelated(rootName);
|
|
5650
|
+
if (!this.$relations) this.$relations = {};
|
|
5651
|
+
this.$relations[rootName] = result;
|
|
5652
|
+
return result;
|
|
5653
|
+
},
|
|
5654
|
+
set(val) {
|
|
5655
|
+
if (!this.$relations) this.$relations = {};
|
|
5656
|
+
this.$relations[rootName] = val;
|
|
5657
|
+
},
|
|
5658
|
+
enumerable: true,
|
|
5659
|
+
configurable: true
|
|
5660
|
+
});
|
|
5661
|
+
};
|
|
5662
|
+
if (isModern) context.addInitializer(function() {
|
|
5663
|
+
setupProperty(Object.getPrototypeOf(this), originalMethod);
|
|
5664
|
+
});
|
|
5665
|
+
else {
|
|
5666
|
+
setupProperty(target, originalMethod);
|
|
5667
|
+
return descriptor;
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5670
|
+
|
|
5617
5671
|
//#endregion
|
|
5618
5672
|
//#region src/make.ts
|
|
5619
5673
|
const make = (model, data, options = {}) => {
|
|
@@ -5626,4 +5680,4 @@ const makeCollection = (model, data) => new collection_default(data.map((item) =
|
|
|
5626
5680
|
const makePaginator = (model, data) => new paginator_default(data.data.map((item) => model.make(item)), data.total, data.per_page, data.current_page);
|
|
5627
5681
|
|
|
5628
5682
|
//#endregion
|
|
5629
|
-
export { attribute_default as Attribute, BelongsTo, BelongsToMany, builder_default as Builder, casts_attributes_default as CastsAttributes, collection_default as Collection, HasMany, HasManyThrough, HasOne, HasOneOrMany, HasOneThrough, has_unique_ids_default as HasUniqueIds, InteractsWithPivotTable, InvalidArgumentError, Migrate, migration_default as Migration, model_default as Model, ModelNotFoundError, paginator_default as Paginator, pivot_default as Pivot, query_builder_default as QueryBuilder, Relation, RelationNotFoundError, scope_default as Scope, seeder_default as Seeder, seeder_creator_default as SeederCreator, runner_default as SeederRunner, soft_deletes_default as SoftDeletes, SupportsDefaultModels, arquebus_default as arquebus, compose, defineConfig, flatten, flattenDeep, getAttrMethod, getAttrName, getGetterMethod, getRelationMethod, getRelationName, getScopeMethod, getScopeName, getSetterMethod, kebabCase, make, makeCollection, makePaginator, now, snakeCase, tap };
|
|
5683
|
+
export { attribute_default as Attribute, BelongsTo, BelongsToMany, builder_default as Builder, casts_attributes_default as CastsAttributes, collection_default as Collection, HasMany, HasManyThrough, HasOne, HasOneOrMany, HasOneThrough, has_unique_ids_default as HasUniqueIds, InteractsWithPivotTable, InvalidArgumentError, Migrate, migration_default as Migration, model_default as Model, ModelNotFoundError, paginator_default as Paginator, pivot_default as Pivot, query_builder_default as QueryBuilder, Relation, RelationNotFoundError, Relationship, scope_default as Scope, seeder_default as Seeder, seeder_creator_default as SeederCreator, runner_default as SeederRunner, soft_deletes_default as SoftDeletes, SupportsDefaultModels, arquebus_default as arquebus, compose, defineConfig, flatten, flattenDeep, getAttrMethod, getAttrName, getGetterMethod, getRelationMethod, getRelationName, getScopeMethod, getScopeName, getSetterMethod, kebabCase, make, makeCollection, makePaginator, now, snakeCase, tap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/arquebus",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
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": {
|