This commit is contained in:
Aleksandra Usacheva 2021-02-10 05:03:28 +03:00
parent 0c31a27b7a
commit 11bbc1b810
53 changed files with 21860 additions and 281 deletions

5
.gitignore vendored
View File

@ -38,6 +38,9 @@ testem.log
.DS_Store
Thumbs.db
# Sonar
.scannerwork
# Swagger Codegen
src/app/api/**/swagger-codegen

View File

@ -41,6 +41,7 @@ submodules: $(SUBTARGETS)
init:
echo -e "//npm.pkg.github.com/:_authToken=$(NPM_TOKEN)" >> .npmrc
npm ci
npm run codegen
build: check lint
npm run build

3950
fb-management.json Normal file

File diff suppressed because it is too large Load Diff

17792
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,9 @@
"prettier:fix": "npm run prettier-preset -- --write",
"fix": "npm run lint:fix; npm run prettier:fix",
"e2e": "ng e2e",
"postinstall": "ngcc"
"postinstall": "ngcc",
"swagger-codegen": "ts-node --project tools/tsconfig.json tools/swagger-codegen.ts",
"codegen": "run-p swagger-codegen"
},
"private": true,
"dependencies": {
@ -56,8 +58,10 @@
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"lint-staged": "^10.4.0",
"npm-run-all": "^4.1.5",
"prettier": "2.1.2",
"protractor": "~7.0.0",
"shelljs": "^0.8.4",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"tslint-config-prettier": "^1.18.0",

View File

@ -1 +1,2 @@
export * from './payment-templates';
export * from './p2p-templates';

View File

@ -3,13 +3,13 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ConfigService } from '../../config';
import { Template } from '../../sections/template/model/template';
import { ValidateResponse } from '../../sections/template/model/validate-response';
import { ValidateTemplate } from '../../sections/template/model/validate-template';
import { HttpRequestModel } from '../../shared/model/http-request-model';
import { HttpSearchResponse } from '../../shared/model/http-search-response';
import { SearchParams } from '../../shared/model/search-params';
import { filterParameters } from '../../shared/utils/filter-params';
import { CreateTemplateResponse } from '../fb-management/swagger-codegen/model/createTemplateResponse';
import { TemplateModel } from '../fb-management/swagger-codegen/model/templateModel';
import { ValidationResponse } from '../fb-management/swagger-codegen/model/validationResponse';
@Injectable()
export class P2pTemplatesService {
@ -17,8 +17,8 @@ export class P2pTemplatesService {
constructor(private http: HttpClient, private configService: ConfigService) {}
findTemplates(params?: SearchParams): Observable<HttpSearchResponse<Template>> {
return this.http.get<HttpSearchResponse<Template>>(`${this.fbP2pTemplatesEndpoint}/template/filter/`, {
findTemplates(params?: SearchParams): Observable<HttpSearchResponse<TemplateModel>> {
return this.http.get<HttpSearchResponse<TemplateModel>>(`${this.fbP2pTemplatesEndpoint}/template/filter/`, {
params: filterParameters(params),
});
}
@ -27,8 +27,8 @@ export class P2pTemplatesService {
return this.http.delete<string>(`${this.fbP2pTemplatesEndpoint}/template/${id}`);
}
saveTemplate(template: Template): Observable<ValidateTemplate> {
return this.http.post<ValidateTemplate>(
saveTemplate(template: TemplateModel): Observable<CreateTemplateResponse> {
return this.http.post<CreateTemplateResponse>(
`${this.fbP2pTemplatesEndpoint}/template`,
template,
new HttpRequestModel()
@ -41,8 +41,8 @@ export class P2pTemplatesService {
});
}
validateTemplate(template: Template): Observable<ValidateResponse> {
return this.http.post<ValidateResponse>(
validateTemplate(template: TemplateModel): Observable<ValidationResponse> {
return this.http.post<ValidationResponse>(
`${this.fbP2pTemplatesEndpoint}/template/validate`,
template,
new HttpRequestModel()

View File

@ -3,13 +3,13 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ConfigService } from '../../config';
import { Template } from '../../sections/template/model/template';
import { ValidateResponse } from '../../sections/template/model/validate-response';
import { ValidateTemplate } from '../../sections/template/model/validate-template';
import { HttpRequestModel } from '../../shared/model/http-request-model';
import { HttpSearchResponse } from '../../shared/model/http-search-response';
import { SearchParams } from '../../shared/model/search-params';
import { filterParameters } from '../../shared/utils/filter-params';
import { CreateTemplateResponse } from '../fb-management/swagger-codegen/model/createTemplateResponse';
import { TemplateModel } from '../fb-management/swagger-codegen/model/templateModel';
import { ValidationResponse } from '../fb-management/swagger-codegen/model/validationResponse';
@Injectable()
export class PaymentTemplatesService {
@ -17,8 +17,8 @@ export class PaymentTemplatesService {
constructor(private http: HttpClient, private configService: ConfigService) {}
findTemplates(params?: SearchParams): Observable<HttpSearchResponse<Template>> {
return this.http.get<HttpSearchResponse<Template>>(`${this.fbPaymentTemplatesEndpoint}/filter/`, {
findTemplates(params?: SearchParams): Observable<HttpSearchResponse<TemplateModel>> {
return this.http.get<HttpSearchResponse<TemplateModel>>(`${this.fbPaymentTemplatesEndpoint}/filter/`, {
params: filterParameters(params),
});
}
@ -33,12 +33,16 @@ export class PaymentTemplatesService {
});
}
saveTemplate(template: Template): Observable<ValidateTemplate> {
return this.http.post<ValidateTemplate>(`${this.fbPaymentTemplatesEndpoint}`, template, new HttpRequestModel());
saveTemplate(template: TemplateModel): Observable<CreateTemplateResponse> {
return this.http.post<CreateTemplateResponse>(
`${this.fbPaymentTemplatesEndpoint}`,
template,
new HttpRequestModel()
);
}
validateTemplate(template: Template): Observable<ValidateResponse> {
return this.http.post<ValidateResponse>(
validateTemplate(template: TemplateModel): Observable<ValidationResponse> {
return this.http.post<ValidationResponse>(
`${this.fbPaymentTemplatesEndpoint}/validate`,
template,
new HttpRequestModel()

View File

@ -15,8 +15,7 @@ import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pTemplatesModule } from '../../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../../api';
import { SharedPipesModule } from '../../../shared/pipes';
import { PaymentEmulationTemplateService } from '../../../shared/services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../../shared/services/groups-reference/p2p-groups-reference.service';

View File

@ -3,10 +3,10 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { BehaviorSubject, combineLatest, Observable, of, Subject } from 'rxjs';
import { catchError, switchMap } from 'rxjs/operators';
import { TemplateModel } from '../../../api/fb-management/swagger-codegen/model/templateModel';
import { OperationType } from '../../../shared/constants/operation-type';
import { OperationTypeManagementService } from '../../../shared/services/operation-type-management.service';
import { ErrorHandlerService } from '../../../shared/services/utils/error-handler.service';
import { Template } from '../../template/model/template';
import { P2pEmulateFilter } from './model/p2p-emulate-filter';
import { PaymentEmulateFilter } from './model/payment-emulate-filter';
@ -14,7 +14,7 @@ import { PaymentEmulateFilter } from './model/payment-emulate-filter';
export class EmulationTemplateService {
queries$ = new Subject<PaymentEmulateFilter | P2pEmulateFilter>();
operationType$ = new BehaviorSubject<string>(OperationType.Payment);
templates$: Observable<Template[]>;
templates$: Observable<TemplateModel[]>;
constructor(
private operationReferenceService: OperationTypeManagementService,
@ -41,7 +41,7 @@ export class EmulationTemplateService {
this.operationType$.next(next);
}
emulate(type: OperationType, filter: PaymentEmulateFilter | P2pEmulateFilter): Observable<Template[]> {
emulate(type: OperationType, filter: PaymentEmulateFilter | P2pEmulateFilter): Observable<TemplateModel[]> {
return this.operationReferenceService.findEmulationService(type).emulate(filter);
}
}

View File

@ -10,8 +10,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pTemplatesModule } from '../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../api';
import { PaymentEmulationTemplateService } from '../../shared/services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../shared/services/groups-reference/p2p-groups-reference.service';
import { PaymentGroupsReferenceService } from '../../shared/services/groups-reference/payment-groups-reference.service';

View File

@ -12,8 +12,7 @@ import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pTemplatesModule } from '../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../api';
import { PaymentEmulationTemplateService } from '../../shared/services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../shared/services/groups-reference/p2p-groups-reference.service';
import { PaymentGroupsReferenceService } from '../../shared/services/groups-reference/payment-groups-reference.service';

View File

@ -16,8 +16,7 @@ import { MatTableModule } from '@angular/material/table';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pReferencesService } from 'src/app/shared/services/reference/p2p-references.service';
import { P2pTemplatesModule } from '../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../api';
import { PaymentEmulationTemplateService } from '../../shared/services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../shared/services/groups-reference/p2p-groups-reference.service';
import { PaymentGroupsReferenceService } from '../../shared/services/groups-reference/payment-groups-reference.service';

View File

@ -17,8 +17,7 @@ import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pTemplatesModule } from '../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../api';
import { PaymentEmulationTemplateService } from '../../shared/services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../shared/services/groups-reference/p2p-groups-reference.service';
import { PaymentGroupsReferenceService } from '../../shared/services/groups-reference/payment-groups-reference.service';

View File

@ -1,5 +0,0 @@
import { Reference } from './reference';
export interface P2pReference extends Reference {
identityId: string;
}

View File

@ -1,6 +0,0 @@
import { Reference } from './reference';
export interface PaymentReference extends Reference {
partyId: string;
shopId: string;
}

View File

@ -1,7 +0,0 @@
export interface Reference {
id?: string;
templateId: string;
isDefault: boolean;
isGlobal: boolean;
lastUpdateDate?: string;
}

View File

@ -1,5 +0,0 @@
export interface Template {
id: string;
template: string;
lastUpdateDate?: string;
}

View File

@ -1,4 +0,0 @@
export interface ValidateError {
errors: string[];
id: string;
}

View File

@ -1,5 +0,0 @@
import { ValidateError } from './validate-error';
export interface ValidateResponse {
validateResults: ValidateError[];
}

View File

@ -1,5 +0,0 @@
import { Template } from './template';
export interface ValidateTemplate extends Template {
errors: string[];
}

View File

@ -3,22 +3,21 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
import { catchError, map, scan, switchMap } from 'rxjs/operators';
import { P2pReferenceModel } from '../../api/fb-management/swagger-codegen/model/p2pReferenceModel';
import { PaymentReferenceModel } from '../../api/fb-management/swagger-codegen/model/paymentReferenceModel';
import { OperationType } from '../../shared/constants/operation-type';
import { SortOrder } from '../../shared/constants/sort-order';
import { HttpSearchResponse } from '../../shared/model/http-search-response';
import { OperationTypeManagementService } from '../../shared/services/operation-type-management.service';
import { ErrorHandlerService } from '../../shared/services/utils/error-handler.service';
import { FilterReference } from './model/filter-reference';
import { P2pReference } from './model/p2p-reference';
import { PaymentReference } from './model/payment-reference';
import { Reference } from './model/reference';
@Injectable()
export class ReferencesService {
filterReference$ = new BehaviorSubject<FilterReference>({ type: OperationType.Payment });
isLoadMoreSubject$ = new BehaviorSubject<boolean>(false);
lastRefSubject$ = new Subject<PaymentReference>();
references$ = new Observable<PaymentReference[] | P2pReference[]>();
lastRefSubject$ = new Subject<PaymentReferenceModel>();
references$ = new Observable<PaymentReferenceModel[] | P2pReferenceModel[]>();
isLoadMore$ = new Observable<boolean>();
constructor(
@ -62,7 +61,7 @@ export class ReferencesService {
this.filterReference$.next(filter);
}
getReferences(filter: FilterReference): Observable<HttpSearchResponse<PaymentReference | P2pReference>> {
getReferences(filter: FilterReference): Observable<HttpSearchResponse<PaymentReferenceModel | P2pReferenceModel>> {
return this.operationReferenceService.findReferenceService(filter.type).findReferences({
searchValue: filter.search,
lastId: filter.lastInListName,
@ -74,11 +73,14 @@ export class ReferencesService {
});
}
deleteReference(type: OperationType, reference: Reference): Observable<string> {
deleteReference(type: OperationType, reference: P2pReferenceModel | PaymentReferenceModel): Observable<string> {
return this.operationReferenceService.findReferenceService(type).deleteReference(reference);
}
saveReferences(type: OperationType, references: Reference[]): Observable<string[]> {
saveReferences(
type: OperationType,
references: P2pReferenceModel[] | PaymentReferenceModel[]
): Observable<string[]> {
return this.operationReferenceService.findReferenceService(type).saveReferences(references);
}
}

View File

@ -1,5 +1,6 @@
import { P2pReferenceModel } from '../../api/fb-management/swagger-codegen/model/p2pReferenceModel';
import { PaymentReferenceModel } from '../../api/fb-management/swagger-codegen/model/paymentReferenceModel';
import { SortOrder } from '../../shared/constants/sort-order';
import { Reference } from '../reference/model/reference';
export enum ActionType {
createReference = 'createReference',
@ -11,6 +12,6 @@ export enum ActionType {
export interface Action {
type: ActionType;
reference?: Reference;
reference?: P2pReferenceModel | PaymentReferenceModel;
sortDirection?: SortOrder;
}

View File

@ -1,8 +1,9 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { Sort } from '@angular/material/sort';
import { P2pReferenceModel } from '../../../../api/fb-management/swagger-codegen/model/p2pReferenceModel';
import { PaymentReferenceModel } from '../../../../api/fb-management/swagger-codegen/model/paymentReferenceModel';
import { SortOrder } from '../../../../shared/constants/sort-order';
import { Reference } from '../../../reference/model/reference';
import { Action, ActionType } from '../../action';
@Component({
@ -16,7 +17,7 @@ export class ReferencesTableComponent {
action: EventEmitter<Action> = new EventEmitter();
@Input()
references: Reference[];
references: P2pReferenceModel[] | PaymentReferenceModel[];
displayedColumns: string[] = ['id', 'templateID', 'isGlobal', 'isDefault', 'updatedAt', 'actions'];
@ -31,15 +32,15 @@ export class ReferencesTableComponent {
}
}
removeReference(reference: Reference): void {
removeReference(reference: P2pReferenceModel | PaymentReferenceModel): void {
this.action.emit({ type: ActionType.removeReference, reference });
}
editReference(reference: Reference) {
editReference(reference: P2pReferenceModel | PaymentReferenceModel) {
this.action.emit({ type: ActionType.editReference, reference });
}
goToTempalte(reference: Reference) {
goToTempalte(reference: P2pReferenceModel | PaymentReferenceModel) {
this.action.emit({ type: ActionType.goToTemplate, reference });
}
}

View File

@ -16,8 +16,7 @@ import { MatTableModule } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pTemplatesModule } from '../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../api';
import { ConfirmActionDialogModule } from '../../shared/components/confirm-action-dialog';
import { EmptySearchResultModule } from '../../shared/components/empty-search-result';
import { PaymentEmulationTemplateService } from '../../shared/services/emulation/payment-emulation-template-service';

View File

@ -2,13 +2,14 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
import { P2pReferenceModel } from '../../../api/fb-management/swagger-codegen/model/p2pReferenceModel';
import { PaymentReferenceModel } from '../../../api/fb-management/swagger-codegen/model/paymentReferenceModel';
import { ConfigService } from '../../../config';
import { OperationType } from '../../../shared/constants/operation-type';
import { SortOrder } from '../../../shared/constants/sort-order';
import { booleanDelay } from '../../../shared/operators';
import { OperationTypeManagementService } from '../../../shared/services/operation-type-management.service';
import { FetchResult, PartialFetcher } from '../../../shared/utils/partial-fetcher';
import { Reference } from '../../reference/model/reference';
export interface FetchReferencesParams {
type: OperationType;
@ -24,7 +25,10 @@ export interface FetchReferencesParams {
}
@Injectable()
export class FetchReferencesService extends PartialFetcher<Reference, FetchReferencesParams> {
export class FetchReferencesService extends PartialFetcher<
PaymentReferenceModel | P2pReferenceModel,
FetchReferencesParams
> {
inProgress$ = this.doAction$.pipe(booleanDelay(), shareReplay(1));
private SIZE = this.configService.pageSize;
@ -35,7 +39,10 @@ export class FetchReferencesService extends PartialFetcher<Reference, FetchRefer
super();
}
protected fetch(params: FetchReferencesParams, lastId?: string): Observable<FetchResult<Reference>> {
protected fetch(
params: FetchReferencesParams,
lastId?: string
): Observable<FetchResult<PaymentReferenceModel | P2pReferenceModel>> {
const { type, searchValue, sortOrder, sortFieldValue, sortBy, id, isDefault, isGlobal, name, size } = params;
return this.operationTypeManagementService.findReferenceService(type).findReferences({
isDefault: isDefault || false,

View File

@ -5,15 +5,16 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { combineLatest, EMPTY, merge, of, Subject } from 'rxjs';
import { catchError, filter, switchMap } from 'rxjs/operators';
import { P2pReferenceModel } from '../../../api/fb-management/swagger-codegen/model/p2pReferenceModel';
import { PaymentReferenceModel } from '../../../api/fb-management/swagger-codegen/model/paymentReferenceModel';
import { ConfirmActionDialogComponent } from '../../../shared/components/confirm-action-dialog';
import { OperationType } from '../../../shared/constants/operation-type';
import { progress } from '../../../shared/operators';
import { OperationTypeManagementService } from '../../../shared/services/operation-type-management.service';
import { Reference } from '../../reference/model/reference';
export interface RemoveReferenceParams {
type: OperationType;
reference: Reference;
reference: PaymentReferenceModel | P2pReferenceModel;
}
@Injectable()

View File

@ -3,10 +3,10 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute, Router } from '@angular/router';
import { TemplateModel } from '../../../api/fb-management/swagger-codegen/model/templateModel';
import { OperationType } from '../../../shared/constants/operation-type';
import { ErrorHandlerService } from '../../../shared/services/utils/error-handler.service';
import { ValidateResponseHandler } from '../../../shared/services/utils/validate-response-handler.service';
import { Template } from '../model/template';
import { TemplatesService } from '../templates.service';
@Component({
@ -16,7 +16,7 @@ import { TemplatesService } from '../templates.service';
})
export class CreateTemplateComponent implements OnInit {
private operationType: OperationType;
template: Template = { id: '', template: '' };
template: TemplateModel = { id: '', template: '' };
constructor(
private router: Router,

View File

@ -3,10 +3,10 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute } from '@angular/router';
import { TemplateModel } from '../../../api/fb-management/swagger-codegen/model/templateModel';
import { OperationType } from '../../../shared/constants/operation-type';
import { ErrorHandlerService } from '../../../shared/services/utils/error-handler.service';
import { ValidateResponseHandler } from '../../../shared/services/utils/validate-response-handler.service';
import { Template } from '../model/template';
import { TemplatesService } from '../templates.service';
@Component({
@ -16,7 +16,7 @@ import { TemplatesService } from '../templates.service';
})
export class EditTemplateComponent implements OnInit {
private operationType: OperationType;
template: Template = { id: '', template: '' };
template: TemplateModel = { id: '', template: '' };
constructor(
private route: ActivatedRoute,

View File

@ -1,5 +0,0 @@
export interface Template {
id: string;
template: string;
lastUpdateDate?: string;
}

View File

@ -1,4 +0,0 @@
export interface ValidateError {
errors: string[];
id: string;
}

View File

@ -1,5 +0,0 @@
import { ValidateError } from './validate-error';
export interface ValidateResponse {
validateResults: ValidateError[];
}

View File

@ -1,5 +0,0 @@
import { Template } from './template';
export interface ValidateTemplate extends Template {
errors: string[];
}

View File

@ -7,8 +7,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pTemplatesModule } from '../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../api';
import { PaymentEmulationTemplateService } from '../../shared/services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../shared/services/groups-reference/p2p-groups-reference.service';
import { PaymentGroupsReferenceService } from '../../shared/services/groups-reference/payment-groups-reference.service';

View File

@ -1,13 +1,13 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CreateTemplateResponse } from '../../api/fb-management/swagger-codegen/model/createTemplateResponse';
import { TemplateModel } from '../../api/fb-management/swagger-codegen/model/templateModel';
import { ValidationResponse } from '../../api/fb-management/swagger-codegen/model/validationResponse';
import { OperationType } from '../../shared/constants/operation-type';
import { SortOrder } from '../../shared/constants/sort-order';
import { HttpSearchResponse } from '../../shared/model/http-search-response';
import { OperationTypeManagementService } from '../../shared/services/operation-type-management.service';
import { Template } from './model/template';
import { ValidateResponse } from './model/validate-response';
import { ValidateTemplate } from './model/validate-template';
@Injectable()
export class TemplatesService {
@ -19,7 +19,7 @@ export class TemplatesService {
nameRegexp?: string,
lastInListName?: string,
sortOrder?: SortOrder
): Observable<HttpSearchResponse<Template>> {
): Observable<HttpSearchResponse<TemplateModel>> {
return this.operationTemplateService.findTemplateService(type).findTemplates({
searchValue: nameRegexp,
lastId: lastInListName,
@ -36,11 +36,11 @@ export class TemplatesService {
return this.operationTemplateService.findTemplateService(type).getTemplatesName(regexp);
}
saveTemplate(type: OperationType, template: Template): Observable<ValidateTemplate> {
saveTemplate(type: OperationType, template: TemplateModel): Observable<CreateTemplateResponse> {
return this.operationTemplateService.findTemplateService(type).saveTemplate(template);
}
validateTemplate(type: OperationType, template: Template): Observable<ValidateResponse> {
validateTemplate(type: OperationType, template: TemplateModel): Observable<ValidationResponse> {
return this.operationTemplateService.findTemplateService(type).validateTemplate(template);
}
}

View File

@ -1,8 +1,8 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { Sort } from '@angular/material/sort';
import { TemplateModel } from '../../../../api/fb-management/swagger-codegen/model/templateModel';
import { SortOrder } from '../../../../shared/constants/sort-order';
import { Template } from '../../../template/model/template';
import { Action, ActionType } from '../../action';
@Component({
@ -16,7 +16,7 @@ export class TemplatesTableComponent {
action: EventEmitter<Action> = new EventEmitter();
@Input()
templates: Template[];
templates: TemplateModel[];
displayedColumns: string[] = ['id', 'template', 'updatedAt', 'actions'];

View File

@ -2,12 +2,12 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
import { TemplateModel } from '../../../api/fb-management/swagger-codegen/model/templateModel';
import { P2pTemplatesService } from '../../../api/p2p-templates';
import { ConfigService } from '../../../config';
import { SortOrder } from '../../../shared/constants/sort-order';
import { booleanDelay } from '../../../shared/operators';
import { FetchResult, PartialFetcher } from '../../../shared/utils/partial-fetcher';
import { Template } from '../../template/model/template';
export interface FetchTemplatesParams {
searchValue?: string;
@ -16,7 +16,7 @@ export interface FetchTemplatesParams {
}
@Injectable()
export class FetchP2pTemplatesService extends PartialFetcher<Template, FetchTemplatesParams> {
export class FetchP2pTemplatesService extends PartialFetcher<TemplateModel, FetchTemplatesParams> {
inProgress$ = this.doAction$.pipe(booleanDelay(), shareReplay(1));
private SIZE = this.configService.pageSize;
@ -24,7 +24,7 @@ export class FetchP2pTemplatesService extends PartialFetcher<Template, FetchTemp
super();
}
protected fetch(params: FetchTemplatesParams, lastId?: string): Observable<FetchResult<Template>> {
protected fetch(params: FetchTemplatesParams, lastId?: string): Observable<FetchResult<TemplateModel>> {
const { searchValue, sortOrder, pageSize } = params;
return this.p2pTemplatesService.findTemplates({
size: pageSize ? pageSize : this.SIZE,

View File

@ -2,12 +2,12 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
import { TemplateModel } from '../../../api/fb-management/swagger-codegen/model/templateModel';
import { PaymentTemplatesService } from '../../../api/payment-templates';
import { ConfigService } from '../../../config';
import { SortOrder } from '../../../shared/constants/sort-order';
import { booleanDelay } from '../../../shared/operators';
import { FetchResult, PartialFetcher } from '../../../shared/utils/partial-fetcher';
import { Template } from '../../template/model/template';
export interface FetchTemplatesParams {
searchValue?: string;
@ -16,7 +16,7 @@ export interface FetchTemplatesParams {
}
@Injectable()
export class FetchPaymentTemplatesService extends PartialFetcher<Template, FetchTemplatesParams> {
export class FetchPaymentTemplatesService extends PartialFetcher<TemplateModel, FetchTemplatesParams> {
inProgress$ = this.doAction$.pipe(booleanDelay(), shareReplay(1));
private SIZE = this.configService.pageSize;
@ -24,7 +24,7 @@ export class FetchPaymentTemplatesService extends PartialFetcher<Template, Fetch
super();
}
protected fetch(params: FetchTemplatesParams, lastId?: string): Observable<FetchResult<Template>> {
protected fetch(params: FetchTemplatesParams, lastId?: string): Observable<FetchResult<TemplateModel>> {
const { searchValue, sortOrder, pageSize } = params;
return this.paymentTemplatesService.findTemplates({
size: pageSize ? pageSize : this.SIZE,

View File

@ -16,8 +16,7 @@ import { MatTableModule } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs';
import { MatToolbarModule } from '@angular/material/toolbar';
import { P2pTemplatesModule } from '../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../api';
import { ConfirmActionDialogModule } from '../../shared/components/confirm-action-dialog';
import { EmptySearchResultModule } from '../../shared/components/empty-search-result';
import { SharedPipesModule } from '../../shared/pipes';

View File

@ -5,8 +5,7 @@ import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { P2pTemplatesModule } from '../../../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../../../api';
import { PaymentEmulationTemplateService } from '../../../services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../../services/groups-reference/p2p-groups-reference.service';
import { PaymentGroupsReferenceService } from '../../../services/groups-reference/payment-groups-reference.service';

View File

@ -24,8 +24,7 @@ import { MatTableModule } from '@angular/material/table';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { P2pTemplatesModule } from '../../../api/p2p-templates';
import { PaymentTemplatesModule } from '../../../api/payment-templates';
import { P2pTemplatesModule, PaymentTemplatesModule } from '../../../api';
import { PaymentEmulationTemplateService } from '../../services/emulation/payment-emulation-template-service';
import { P2pGroupsReferenceService } from '../../services/groups-reference/p2p-groups-reference.service';
import { PaymentGroupsReferenceService } from '../../services/groups-reference/payment-groups-reference.service';

View File

@ -1,9 +1,9 @@
import { Observable } from 'rxjs';
import { TemplateModel } from '../../../api/fb-management/swagger-codegen/model/templateModel';
import { P2pEmulateFilter } from '../../../sections/emulation/template/model/p2p-emulate-filter';
import { PaymentEmulateFilter } from '../../../sections/emulation/template/model/payment-emulate-filter';
import { Template } from '../../../sections/template/model/template';
export interface IEmulationTemplateService {
emulate(filter: PaymentEmulateFilter | P2pEmulateFilter): Observable<Template[]>;
emulate(filter: PaymentEmulateFilter | P2pEmulateFilter): Observable<TemplateModel[]>;
}

View File

@ -2,9 +2,9 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { TemplateModel } from '../../../api/fb-management/swagger-codegen/model/templateModel';
import { ConfigService } from '../../../config';
import { PaymentEmulateFilter } from '../../../sections/emulation/template/model/payment-emulate-filter';
import { Template } from '../../../sections/template/model/template';
import { IEmulationTemplateService } from './iemulation-template.service';
@Injectable()
@ -13,8 +13,8 @@ export class PaymentEmulationTemplateService implements IEmulationTemplateServic
constructor(private http: HttpClient, private configService: ConfigService) {}
emulate(filter: PaymentEmulateFilter): Observable<Template[]> {
return this.http.get<Template[]>(`${this.fbManagementEndpoint}/rules/`, {
emulate(filter: PaymentEmulateFilter): Observable<TemplateModel[]> {
return this.http.get<TemplateModel[]>(`${this.fbManagementEndpoint}/rules/`, {
params: { shopId: filter.shopId, partyId: filter.partyId },
headers: {
'Content-Type': 'application/json',

View File

@ -1,15 +1,16 @@
import { Observable } from 'rxjs';
import { P2pReference } from '../../../sections/reference/model/p2p-reference';
import { PaymentReference } from '../../../sections/reference/model/payment-reference';
import { Reference } from '../../../sections/reference/model/reference';
import { P2pReferenceModel } from '../../../api/fb-management/swagger-codegen/model/p2pReferenceModel';
import { PaymentReferenceModel } from '../../../api/fb-management/swagger-codegen/model/paymentReferenceModel';
import { HttpSearchResponse } from '../../model/http-search-response';
import { SearchReferenceParams } from './model/search-reference-params';
export interface IReferencesService {
findReferences(params?: SearchReferenceParams): Observable<HttpSearchResponse<PaymentReference | P2pReference>>;
findReferences(
params?: SearchReferenceParams
): Observable<HttpSearchResponse<PaymentReferenceModel | P2pReferenceModel>>;
deleteReference(reference: Reference): Observable<string>;
deleteReference(reference: PaymentReferenceModel | P2pReferenceModel): Observable<string>;
saveReferences(reference: Reference[]): Observable<string[]>;
saveReferences(reference: PaymentReferenceModel[] | P2pReferenceModel[]): Observable<string[]>;
}

View File

@ -2,10 +2,9 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { P2pReferenceModel } from '../../../api/fb-management/swagger-codegen/model/p2pReferenceModel';
import { ConfigService } from '../../../config';
import { P2pReference } from '../../../sections/reference/model/p2p-reference';
import { PaymentReference } from '../../../sections/reference/model/payment-reference';
import { Reference } from '../../../sections/reference/model/reference';
import { ReferenceModule } from '../../../sections/reference';
import { HttpRequestModel } from '../../model/http-request-model';
import { HttpSearchResponse } from '../../model/http-search-response';
import { filterParameters } from '../../utils/filter-params';
@ -18,8 +17,8 @@ export class P2pReferencesService implements IReferencesService {
constructor(private http: HttpClient, private configService: ConfigService) {}
findReferences(params?: SearchReferenceParams): Observable<HttpSearchResponse<PaymentReference | P2pReference>> {
return this.http.get<HttpSearchResponse<PaymentReference | P2pReference>>(
findReferences(params?: SearchReferenceParams): Observable<HttpSearchResponse<P2pReferenceModel>> {
return this.http.get<HttpSearchResponse<P2pReferenceModel>>(
`${this.fbManagementEndpoint}/p2p/reference/filter/`,
{
params: filterParameters(params),
@ -27,14 +26,14 @@ export class P2pReferencesService implements IReferencesService {
);
}
deleteReference(reference: P2pReference): Observable<string> {
deleteReference(reference: P2pReferenceModel): Observable<string> {
return this.http.delete(`${this.fbManagementEndpoint}/p2p/template/${reference.templateId}/reference`, {
params: { identityId: reference.identityId },
responseType: 'text',
});
}
saveReferences(references: Reference[]): Observable<string[]> {
saveReferences(references: ReferenceModule[]): Observable<string[]> {
return this.http.post<string[]>(
`${this.fbManagementEndpoint}/p2p/template/references`,
references,

View File

@ -2,10 +2,8 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { PaymentReferenceModel } from '../../../api/fb-management/swagger-codegen/model/paymentReferenceModel';
import { ConfigService } from '../../../config';
import { P2pReference } from '../../../sections/reference/model/p2p-reference';
import { PaymentReference } from '../../../sections/reference/model/payment-reference';
import { Reference } from '../../../sections/reference/model/reference';
import { HttpRequestModel } from '../../model/http-request-model';
import { HttpSearchResponse } from '../../model/http-search-response';
import { filterParameters } from '../../utils/filter-params';
@ -18,8 +16,8 @@ export class PaymentReferencesService implements IReferencesService {
constructor(private http: HttpClient, private configService: ConfigService) {}
findReferences(params?: SearchReferenceParams): Observable<HttpSearchResponse<PaymentReference | P2pReference>> {
return this.http.get<HttpSearchResponse<PaymentReference | P2pReference>>(
findReferences(params?: SearchReferenceParams): Observable<HttpSearchResponse<PaymentReferenceModel>> {
return this.http.get<HttpSearchResponse<PaymentReferenceModel>>(
`${this.fbManagementEndpoint}/reference/filter/`,
{
params: filterParameters(params),
@ -27,14 +25,14 @@ export class PaymentReferencesService implements IReferencesService {
);
}
deleteReference(reference: PaymentReference): Observable<string> {
deleteReference(reference: PaymentReferenceModel): Observable<string> {
return this.http.delete(`${this.fbManagementEndpoint}/template/${reference.templateId}/reference`, {
params: { shopId: reference.shopId, partyId: reference.partyId },
responseType: 'text',
});
}
saveReferences(references: Reference[]): Observable<string[]> {
saveReferences(references: PaymentReferenceModel[]): Observable<string[]> {
return this.http.post<string[]>(
`${this.fbManagementEndpoint}/template/references`,
references,

View File

@ -1,14 +1,16 @@
import { Injectable } from '@angular/core';
import { ValidateResponse } from '../../../sections/template/model/validate-response';
import { ValidationResponse } from '../../../api/fb-management/swagger-codegen/model/validationResponse';
@Injectable()
export class ValidateResponseHandler {
constructor() {}
checkValidateResponse(response: ValidateResponse): string {
return response.validateResults.length > 0
? `${response.validateResults[0].id}: ${response.validateResults[0].errors}`
: 'All rule success';
checkValidateResponse(response: ValidationResponse): string {
// TODO what i need to return here?
return '';
// return response.result.length > 0
// ? `${response.result[0].id}: ${response.errors[0]}`
// : 'All rule success';
}
}

View File

@ -0,0 +1,8 @@
{
"cliPath": "tools/codegens/swagger-codegen-cli-2.4.18.jar",
"outputRootDir": "src/app/api",
"outputDir": "swagger-codegen",
"schemes": {
"fb-management": "fb-management.json"
}
}

Binary file not shown.

61
tools/swagger-codegen.ts Normal file
View File

@ -0,0 +1,61 @@
import * as del from 'del';
import * as path from 'path';
import * as shell from 'shelljs';
import * as config from '../swagger-codegen-config.json';
import { createLog } from './utils/create-log';
import { execWithLog } from './utils/exec-with-log';
type Schemes = { [name: string]: string };
async function replaceModuleWithProvidersNg10(outputDirPath: string) {
const modulePath = `${outputDirPath}/api.module.ts`;
return new Promise((resolve, reject) => {
try {
const result = shell.sed('-i', /ModuleWithProviders\s/, `ModuleWithProviders<ApiModule> `, modulePath);
// tslint:disable-next-line:no-console
console.log(`Replaced "ModuleWithProviders" in "${modulePath}"`);
resolve(result);
} catch (err) {
// tslint:disable-next-line:no-console
console.error(err);
console.error(`Error on path "${modulePath}"`);
reject(err);
}
});
}
async function swaggerCodegenAngularCli({
schemes,
outputDir,
outputRootDir,
cliPath,
}: {
schemes: Schemes;
outputDir: string;
outputRootDir: string;
cliPath: string;
}) {
const swaggerLog = createLog('Swagger 2 Codegen');
swaggerLog('Generate...');
await Promise.all(
Object.entries(schemes).map(async ([specName, specPath]) => {
const inputPath = specPath;
const outputDirPath = path.join(outputRootDir, specName, outputDir);
await del([outputDirPath]);
swaggerLog(`${outputDirPath} deleted`);
const cmd = `java -jar ${cliPath} generate -Dmodels -l typescript-angular --additional-properties ngVersion=7 -i ${inputPath} -o ${outputDirPath}`;
// angular 10 requires change "ModuleWithProviders" with "ModuleWithProviders<ApiModule>"
// swagger-codegen has a fix in v2.4.17 but it breaks our backward compatibility
swaggerLog(`> ${cmd}`);
return execWithLog(cmd).then(() => replaceModuleWithProvidersNg10(outputDirPath));
})
);
swaggerLog('Successfully generated 😀');
}
(async () => {
await swaggerCodegenAngularCli(config);
})();

10
tools/tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2015",
"moduleResolution": "node",
"lib": ["es2018"],
"module": "commonjs",
"resolveJsonModule": true,
"allowJs": true
}
}

View File

@ -0,0 +1,4 @@
export function createLog(prefix: string) {
// tslint:disable-next-line:no-console
return (message: string) => console.log(`[${prefix}]: ${message}`);
}

View File

@ -0,0 +1,23 @@
import { exec } from 'child_process';
export function execWithLog(cmd: string) {
return new Promise((res, rej) =>
exec(
cmd,
{
cwd: process.cwd(),
},
(error, stdout, stderr) => {
if (error === null) {
// tslint:disable-next-line:no-console
console.log(stderr);
res(stdout);
} else {
console.error(error);
console.error(stderr);
rej(error);
}
}
)
);
}