diff --git a/bundle/lib/entity/entity.config.d.ts b/bundle/lib/entity/entity.config.d.ts index 5d744c5..abc5121 100644 --- a/bundle/lib/entity/entity.config.d.ts +++ b/bundle/lib/entity/entity.config.d.ts @@ -13,6 +13,7 @@ export declare class ModelEntity extends EntityConfigBase { parseDataQuery?: (dataQuery: DataQuery) => { [index: string]: any; }; + parseItemQuery?: (itemId: string | number, entity?: ModelEntity, config?: ParisConfig) => string; constructor(config: EntityConfig, entityConstructor: DataEntityConstructor); } export interface EntityConfig extends IEntityConfigBase { @@ -26,6 +27,7 @@ export interface EntityConfig extends IEntityConfigBase { parseDataQuery?: (dataQuery: DataQuery) => { [index: string]: any; }; + parseItemQuery?: (itemId: string | number, entity?: ModelEntity, config?: ParisConfig) => string; } export interface ModelEntityCacheConfig { time?: number; diff --git a/bundle/lib/repository/repository.d.ts b/bundle/lib/repository/repository.d.ts index dc71b61..bfbc4de 100644 --- a/bundle/lib/repository/repository.d.ts +++ b/bundle/lib/repository/repository.d.ts @@ -49,7 +49,9 @@ export declare class Repository implements IRepositor private static getEntityItem(repository, data, options?); private static getValueObjectItem(valueObjectType, data, options, paris, config?); query(query?: DataQuery, dataOptions?: DataOptions): Observable>; - getItemById(itemId: string | number, options?: DataOptions): Observable; + getItemById(itemId: string | number, options?: DataOptions, params?: { + [index: string]: any; + }): Observable; private setAllItems(); getItemSaveData(item: T): Index; } diff --git a/bundle/lib/repository/repository.js b/bundle/lib/repository/repository.js index 58d169a..3cf2555 100644 --- a/bundle/lib/repository/repository.js +++ b/bundle/lib/repository/repository.js @@ -267,7 +267,7 @@ var Repository = /** @class */ (function () { }); }); }; - Repository.prototype.getItemById = function (itemId, options) { + Repository.prototype.getItemById = function (itemId, options, params) { var _this = this; if (options === void 0) { options = data_options_1.defaultDataOptions; } if (this.entity.values) { @@ -285,7 +285,7 @@ var Repository = /** @class */ (function () { if (this.entity.loadAll) return this.setAllItems().map(function () { return _this._allValuesMap.get(String(itemId)); }); else { - return this.dataStore.get(this.endpointName + "/" + itemId) + return this.dataStore.get(this.entity.parseItemQuery ? this.entity.parseItemQuery(itemId, this.entity, this.config) : this.endpointName + "/" + itemId, params && { params: params }, this.baseUrl) .flatMap(function (data) { return _this.createItem(data, options); }); } }; diff --git a/bundle/paris.umd.js b/bundle/paris.umd.js index 341522f..060d43b 100644 --- a/bundle/paris.umd.js +++ b/bundle/paris.umd.js @@ -786,7 +786,7 @@ var Repository = /** @class */ (function () { }); }); }; - Repository.prototype.getItemById = function (itemId, options) { + Repository.prototype.getItemById = function (itemId, options, params) { var _this = this; if (options === void 0) { options = data_options.defaultDataOptions; } if (this.entity.values) { @@ -804,7 +804,7 @@ var Repository = /** @class */ (function () { if (this.entity.loadAll) return this.setAllItems().map(function () { return _this._allValuesMap.get(String(itemId)); }); else { - return this.dataStore.get(this.endpointName + "/" + itemId) + return this.dataStore.get(this.entity.parseItemQuery ? this.entity.parseItemQuery(itemId, this.entity, this.config) : this.endpointName + "/" + itemId, params && { params: params }, this.baseUrl) .flatMap(function (data) { return _this.createItem(data, options); }); } };