@microsoft/paris
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -189,3 +189,4 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
throw err; | ||
}), map(function (data) { return _this.entityBackendConfig.parseData ? _this.entityBackendConfig.parseData(data) : data; }), mergeMap(function (data) { return _this.createItem(data, dataOptions, query); })); | ||
}), map(function (data) { return _this.entityBackendConfig.parseData ? | ||
_this.entityBackendConfig.parseData(data, _this.paris.config, query) : data; }), mergeMap(function (data) { return _this.createItem(data, dataOptions, query); })); | ||
if (dataOptions.allowCache !== false && this.entityBackendConfig.cache) | ||
@@ -259,8 +260,12 @@ return this.cache.get(endpoint, httpOptions.params, function () { return getItem$; }); | ||
else { | ||
var endpoint = this.entityBackendConfig.parseItemQuery ? this.entityBackendConfig.parseItemQuery(itemId, this.entity, this.paris.config, params) : this.getEndpointName({ where: params }) + "/" + itemId; | ||
var query_1 = { where: params }; | ||
var endpoint = this.entityBackendConfig.parseItemQuery ? this.entityBackendConfig.parseItemQuery(itemId, this.entity, this.paris.config, params) : this.getEndpointName(query_1) + "/" + itemId; | ||
var currentOptions = this.addCustomHeaders(itemId); | ||
var getItem$_1 = this.paris.dataStore.get(endpoint, Object.assign({}, params && { params: params }, currentOptions), this.getBaseUrl({ where: params }), this.entityBackendConfig.timeout ? { timeout: this.entityBackendConfig.timeout } : null).pipe(catchError(function (err) { | ||
var getItem$_1 = this.paris.dataStore.get(endpoint, Object.assign({}, params && { params: params }, currentOptions), this.getBaseUrl(query_1), this.entityBackendConfig.timeout ? { timeout: this.entityBackendConfig.timeout } : null).pipe(catchError(function (err) { | ||
_this.emitEntityHttpErrorEvent(err); | ||
throw err; | ||
}), mergeMap(function (data) { return _this.createItem(data, options, { where: Object.assign({ itemId: itemId }, params) }); })); | ||
}), mergeMap(function (data) { | ||
return _this.createItem(_this.entityBackendConfig.parseData ? | ||
_this.entityBackendConfig.parseData(data, _this.paris.config, query_1) : data, options, { where: Object.assign({ itemId: itemId }, params) }); | ||
})); | ||
if (options.allowCache !== false && this.entityBackendConfig.cache) | ||
@@ -267,0 +272,0 @@ return this.cache.get(endpoint, params, function () { return getItem$_1; }); |
{ | ||
"name": "@microsoft/paris", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "Library for the implementation of Domain Driven Design with TypeScript + RxJS", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -121,2 +121,30 @@ import {Paris} from '../../lib/paris'; | ||
}); | ||
describe('parseData', () => { | ||
const text = "testParseData"; | ||
it('should set parse the raw data according to the original response', () => { | ||
setMockData({ | ||
isDataObject: true, | ||
dataObject: { | ||
id: 1, | ||
text: text | ||
} | ||
}); | ||
todoRepo.getItemById(1).subscribe(todoItem => { | ||
expect(todoItem.text).toEqual(text) | ||
}); | ||
}); | ||
it('should set parse the raw data according to the query', () => { | ||
setMockData({ | ||
dataObject: { | ||
id: 1, | ||
text: text | ||
} | ||
}); | ||
todoRepo.getItemById(1, undefined, {isDataObject: true}).subscribe(todoItem => { | ||
expect(todoItem.text).toEqual(text) | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -123,0 +151,0 @@ |
@@ -14,3 +14,12 @@ import {EntityModelBase} from "../../lib/config/entity-model.base"; | ||
separateArrayParams: true, | ||
customHeaders: (data, config) => data ? (data.text === "New todo item" ? {"keyForNewTodoItem": "valueForNewTodoItem"} : {"keyForRegularTodoItem": "valueForRegularTodoItem"}) : {} | ||
customHeaders: (data, config) => data ? (data.text === "New todo item" ? {"keyForNewTodoItem": "valueForNewTodoItem"} : {"keyForRegularTodoItem": "valueForRegularTodoItem"}) : {}, | ||
parseData: (data, config, query) => { | ||
if (data.isDataObject){ | ||
return data.dataObject; | ||
} | ||
if (query && query.where && (<{[index:string]:any }>query.where)['isDataObject']){ | ||
return data.dataObject; | ||
} | ||
return data; | ||
} | ||
}) | ||
@@ -17,0 +26,0 @@ export class Todo extends EntityModelBase<number>{ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
262466
5392