clean
This commit is contained in:
parent
52a0c188ac
commit
68a8bf1f06
@ -16,7 +16,7 @@ module.exports = function (config) {
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, '../../../coverage/poweredsoft/ngx-data'),
|
||||
dir: require('path').join(__dirname, '../../../coverage/openharbor/ngx-data'),
|
||||
reports: ['html', 'lcovonly', 'text-summary'],
|
||||
fixWebpackSourcePaths: true
|
||||
},
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
|
||||
"dest": "../../../dist/poweredsoft/ngx-data",
|
||||
"dest": "../../../dist/openharbor/ngx-data",
|
||||
"lib": {
|
||||
"entryFile": "src/public-api.ts"
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@poweredsoft/ngx-data",
|
||||
"version": "0.0.22",
|
||||
"name": "@openharbor/ngx-data",
|
||||
"version": "0.1.0",
|
||||
"peerDependencies": {
|
||||
"@angular/common": "^8.2.4",
|
||||
"@angular/core": "^8.2.4",
|
@ -1,12 +1,11 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { IQueryCriteria, IQueryExecutionGroupResult, IQueryExecutionResult, IQueryExecutionResultPaging } from "@poweredsoft/data";
|
||||
import { Observable, of } from "rxjs";
|
||||
import { map, switchMap } from "rxjs/operators";
|
||||
import { BaseHttpDataSourceOptionsBuilder } from "./BaseHttpDataSourceOptionsBuilder";
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { IQueryCriteria, IQueryExecutionGroupResult, IQueryExecutionResult, IQueryExecutionResultPaging } from '@poweredsoft/data';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { BaseHttpDataSourceOptionsBuilder } from './BaseHttpDataSourceOptionsBuilder';
|
||||
|
||||
export class SingleDataSourceOptionsBuilder<TQuery, TModel, TKey>
|
||||
extends BaseHttpDataSourceOptionsBuilder<TModel, TKey>
|
||||
{
|
||||
extends BaseHttpDataSourceOptionsBuilder<TModel, TKey> {
|
||||
private _beforeRead: (query: IQueryCriteria) => Observable<TQuery>;
|
||||
|
||||
constructor(http: HttpClient) {
|
||||
@ -22,7 +21,7 @@ export class SingleDataSourceOptionsBuilder<TQuery, TModel, TKey>
|
||||
this._query = {
|
||||
adapter: {
|
||||
handle: (query: IQueryCriteria) => {
|
||||
const finalBeforeRead = this._beforeRead || ((query: IQueryCriteria) => of(<TQuery>{}));
|
||||
const finalBeforeRead = this._beforeRead || ((query: IQueryCriteria) => of({} as TQuery));
|
||||
return finalBeforeRead(query)
|
||||
.pipe(
|
||||
switchMap(finalQuery => {
|
||||
@ -30,24 +29,22 @@ export class SingleDataSourceOptionsBuilder<TQuery, TModel, TKey>
|
||||
params: this.convertToParams(finalQuery)
|
||||
}).pipe(
|
||||
map(result => {
|
||||
return <IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>
|
||||
{
|
||||
return {
|
||||
totalRecords: result == null ? 0 : 1,
|
||||
data: [result]
|
||||
};
|
||||
} as IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>;
|
||||
})
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected convertToParams(finalQuery: TQuery)
|
||||
{
|
||||
protected convertToParams(finalQuery: TQuery) {
|
||||
return Object.keys(finalQuery).reduce((prev, key) => {
|
||||
prev[key] = finalQuery[key];
|
||||
return prev;
|
||||
@ -58,24 +55,23 @@ export class SingleDataSourceOptionsBuilder<TQuery, TModel, TKey>
|
||||
this._query = {
|
||||
adapter: {
|
||||
handle: (query: IQueryCriteria) => {
|
||||
const finalBeforeRead = this._beforeRead || ((_: IQueryCriteria) => of(<TQuery>{}));
|
||||
const finalBeforeRead = this._beforeRead || ((_: IQueryCriteria) => of({} as TQuery));
|
||||
return finalBeforeRead(query)
|
||||
.pipe(
|
||||
switchMap(finalQuery => {
|
||||
return this.http.post<TModel>(url, finalQuery).pipe(
|
||||
map(result => {
|
||||
return <IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>
|
||||
{
|
||||
return {
|
||||
totalRecords: result == null ? 0 : 1,
|
||||
data: [result]
|
||||
};
|
||||
} as IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>;
|
||||
})
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -90,17 +86,17 @@ export class SingleDataSourceOptionsBuilder<TQuery, TModel, TKey>
|
||||
switchMap(finalQuery => {
|
||||
return queryHandler(finalQuery).pipe(
|
||||
map(result => {
|
||||
return <IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>{
|
||||
return {
|
||||
totalRecords: result == null ? 0 : 1,
|
||||
data: [result]
|
||||
};
|
||||
} as IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>;
|
||||
})
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
||||
import { IDataSourceTransportOptions, IDataSourceCommandAdapterOptions, IDataSourceOptions, IResolveCommandModelEvent, IDataSourceError, IDataSourceErrorMessage, IDataSourceValidationError } from '@poweredsoft/data';
|
||||
import { IQueryExecutionResult, IQueryExecutionGroupResult, IQueryCriteria } from '@poweredsoft/data';
|
Loading…
Reference in New Issue
Block a user