@microsoft/paris
Advanced tools
Comparing version 1.3.6 to 1.3.7
@@ -15,2 +15,3 @@ import { ApiCallBackendConfigInterface } from "../../config/api-call-backend-config.interface"; | ||
method?: RequestMethod; | ||
responseType?: 'json' | 'blob' | 'text'; | ||
timeout?: number; | ||
@@ -17,0 +18,0 @@ type?: { |
@@ -117,3 +117,3 @@ import { Observable } from "rxjs"; | ||
*/ | ||
allItems<TEntity extends EntityModelBase>(entityConstructor: DataEntityType<TEntity>): Observable<Array<TEntity>>; | ||
allItems<TEntity extends EntityModelBase<TId>, TId extends EntityId>(entityConstructor: DataEntityType<TEntity, any, TId>): Observable<Array<TEntity>>; | ||
/** | ||
@@ -120,0 +120,0 @@ * Query items in a relationship - fetches multiple items that relate to a specified item. |
@@ -118,3 +118,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
} | ||
var httpOptions = input | ||
var httpOptions = ((input !== undefined) && (input !== null)) | ||
? apiCallType.config.parseQuery | ||
@@ -124,3 +124,4 @@ ? apiCallType.config.parseQuery(input) | ||
: null; | ||
var apiCall$ = this.makeApiCall(apiCallType.config, apiCallType.config.method || "GET", httpOptions) | ||
var requestOptions = apiCallType.config.responseType ? { responseType: apiCallType.config.responseType } : null; | ||
var apiCall$ = this.makeApiCall(apiCallType.config, apiCallType.config.method || "GET", httpOptions, undefined, requestOptions) | ||
.pipe(catchError(function (err) { | ||
@@ -193,3 +194,3 @@ _this._errorSubject$.next(err); | ||
}; | ||
Paris.prototype.makeApiCall = function (backendConfig, method, httpOptions, query) { | ||
Paris.prototype.makeApiCall = function (backendConfig, method, httpOptions, query, requestOptions) { | ||
var _this = this; | ||
@@ -214,4 +215,5 @@ var dataQuery = query || { where: httpOptions && httpOptions.params }; | ||
} | ||
if (backendConfig.parseData) { | ||
return this.dataStore.request(method || "GET", endpoint, apiCallHttpOptions, baseUrl).pipe(catchError(function (err) { | ||
var self = this; | ||
function makeRequest$() { | ||
return self.dataStore.request(method || "GET", endpoint, apiCallHttpOptions, baseUrl, requestOptions).pipe(catchError(function (err) { | ||
return throwError({ | ||
@@ -222,3 +224,6 @@ originalError: err, | ||
}); | ||
}), map(function (rawData) { | ||
})); | ||
} | ||
if (backendConfig.parseData) { | ||
return makeRequest$().pipe(map(function (rawData) { | ||
try { | ||
@@ -236,9 +241,3 @@ return backendConfig.parseData(rawData, _this.config, dataQuery); | ||
} | ||
return this.dataStore.request(method || "GET", endpoint, apiCallHttpOptions, baseUrl).pipe(catchError(function (err) { | ||
return throwError({ | ||
originalError: err, | ||
type: EntityErrorTypes.HttpError, | ||
entity: null | ||
}); | ||
})); | ||
return makeRequest$(); | ||
}; | ||
@@ -245,0 +244,0 @@ /** |
{ | ||
"name": "@microsoft/paris", | ||
"version": "1.3.6", | ||
"version": "1.3.7", | ||
"description": "Library for the implementation of Domain Driven Design with TypeScript + RxJS", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -279,2 +279,5 @@ import {Observable, of} from 'rxjs'; | ||
@EntityField() name:string; | ||
@EntityField() | ||
someArray:Array<Record<string, any>>; | ||
} | ||
@@ -300,3 +303,3 @@ | ||
it("calls the entity's `serializeItem` method with the proper params", () => { | ||
const newSerializedItem = new serializedEntity({ id: undefined, name: 'test' }); | ||
const newSerializedItem = new serializedEntity({ id: undefined, name: 'test', someArray: null }); | ||
const serializationData = { test: 1 }; | ||
@@ -313,3 +316,15 @@ | ||
}); | ||
it("models an item with a non-entity array field", (done) => { | ||
const data = { | ||
name: "test", | ||
someArray: [ { hello: "Ben" }, { Hello: "Yossi" }] | ||
}; | ||
paris.modeler.modelEntity(data, serializedItemRepo.modelConfig).subscribe((entity) => { | ||
expect(entity.someArray).toBeInstanceOf(Array); | ||
done(); | ||
}); | ||
}) | ||
}); | ||
}); |
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
243837
4987