This commit is contained in:
Ildar Galeev 2022-12-20 20:55:03 +03:00 committed by GitHub
parent 39ecc08edf
commit 327ea29e7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 24 deletions

11
package-lock.json generated
View File

@ -30,7 +30,7 @@
"@s-libs/rxjs-core": "15.0.0",
"@vality/deanonimus-proto": "2.0.1-03a2143.0",
"@vality/domain-proto": "2.0.1-b8cfba3.0",
"@vality/dominant-cache-proto": "1.0.1-5b29d81.0",
"@vality/dominant-cache-proto": "2.0.1-9001474.0",
"@vality/file-storage-proto": "1.0.1-447212b.0",
"@vality/fistful-proto": "1.0.1-9c78e89.0",
"@vality/machinegun-proto": "1.0.1-277f06e.0",
@ -5163,8 +5163,9 @@
"integrity": "sha512-6Wu/SnDo5UEWGmY4U0c7hyDg/mN1+x/J2gcdzMY4q+dZb5TWXxsExJ16vqkLChbHKt6HzbsyCIeewYimv0gPOg=="
},
"node_modules/@vality/dominant-cache-proto": {
"version": "1.0.1-5b29d81.0",
"license": "Apache-2.0"
"version": "2.0.1-9001474.0",
"resolved": "https://registry.npmjs.org/@vality/dominant-cache-proto/-/dominant-cache-proto-2.0.1-9001474.0.tgz",
"integrity": "sha512-QBRGI45jciKII9sEefzoULyAWXmTnLIetdaLu1s1B5UK2DVd3ju5TSqYCwTVxInt+jZ7Q8ACTb3pYHDuDI5uig=="
},
"node_modules/@vality/file-storage-proto": {
"version": "1.0.1-447212b.0",
@ -22876,7 +22877,9 @@
"integrity": "sha512-6Wu/SnDo5UEWGmY4U0c7hyDg/mN1+x/J2gcdzMY4q+dZb5TWXxsExJ16vqkLChbHKt6HzbsyCIeewYimv0gPOg=="
},
"@vality/dominant-cache-proto": {
"version": "1.0.1-5b29d81.0"
"version": "2.0.1-9001474.0",
"resolved": "https://registry.npmjs.org/@vality/dominant-cache-proto/-/dominant-cache-proto-2.0.1-9001474.0.tgz",
"integrity": "sha512-QBRGI45jciKII9sEefzoULyAWXmTnLIetdaLu1s1B5UK2DVd3ju5TSqYCwTVxInt+jZ7Q8ACTb3pYHDuDI5uig=="
},
"@vality/file-storage-proto": {
"version": "1.0.1-447212b.0"

View File

@ -44,7 +44,7 @@
"@s-libs/rxjs-core": "15.0.0",
"@vality/deanonimus-proto": "2.0.1-03a2143.0",
"@vality/domain-proto": "2.0.1-b8cfba3.0",
"@vality/dominant-cache-proto": "1.0.1-5b29d81.0",
"@vality/dominant-cache-proto": "2.0.1-9001474.0",
"@vality/file-storage-proto": "1.0.1-447212b.0",
"@vality/fistful-proto": "1.0.1-9c78e89.0",
"@vality/machinegun-proto": "1.0.1-277f06e.0",

View File

@ -1,23 +1,47 @@
import { Injectable, Injector } from '@angular/core';
import { Injectable } from '@angular/core';
import {
codegenClientConfig,
CodegenClient,
} from '@vality/dominant-cache-proto/lib/dominant_cache-DominantCache';
import context from '@vality/dominant-cache-proto/lib/dominant_cache/context';
import * as DominantCache from '@vality/dominant-cache-proto/lib/dominant_cache/gen-nodejs/DominantCache';
ThriftAstMetadata,
DominantCacheCodegenClient,
DominantCache,
} from '@vality/dominant-cache-proto';
import { Category, ContractTemplate } from '@vality/dominant-cache-proto/dominant_cache';
import { combineLatest, from, map, Observable, switchMap } from 'rxjs';
import { createThriftApi } from '@cc/app/api/utils';
import { KeycloakTokenInfoService, toWachterHeaders } from '@cc/app/shared/services';
import { environment } from '@cc/environments/environment';
@Injectable({ providedIn: 'root' })
export class DominantCacheService extends createThriftApi<CodegenClient>() {
constructor(injector: Injector) {
super(injector, {
service: DominantCache,
wachterServiceName: 'DominantCache',
metadata: () =>
import('@vality/dominant-cache-proto/lib/metadata.json').then((m) => m.default),
context,
...codegenClientConfig,
});
export class DominantCacheService {
private client$: Observable<DominantCacheCodegenClient>;
constructor(private keycloakTokenInfoService: KeycloakTokenInfoService) {
const headers$ = this.keycloakTokenInfoService.decoded$.pipe(
map(toWachterHeaders('DominantCache'))
);
const metadata$ = from(
import('@vality/dominant-cache-proto/metadata.json').then(
(m) => m.default as ThriftAstMetadata[]
)
);
this.client$ = combineLatest([metadata$, headers$]).pipe(
switchMap(([metadata, headers]) =>
DominantCache({
metadata,
headers,
logging: environment.logging.requests,
path: '/wachter',
})
)
);
}
// eslint-disable-next-line @typescript-eslint/naming-convention
GetCategories(): Observable<Category[]> {
return this.client$.pipe(switchMap((c) => c.GetCategories()));
}
// eslint-disable-next-line @typescript-eslint/naming-convention
GetContractTemplates(): Observable<ContractTemplate[]> {
return this.client$.pipe(switchMap((c) => c.GetContractTemplates()));
}
}

View File

@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { MatLegacySnackBar as MatSnackBar } from '@angular/material/legacy-snack-bar';
import { ContractTemplateRef } from '@vality/domain-proto/domain';
import { ContractTemplate } from '@vality/dominant-cache-proto';
import { ContractTemplate } from '@vality/dominant-cache-proto/dominant_cache';
import isNil from 'lodash-es/isNil';
import sortBy from 'lodash-es/sortBy';
import { Observable } from 'rxjs';

View File

@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { MatLegacySnackBar as MatSnackBar } from '@angular/material/legacy-snack-bar';
import { CategoryRef } from '@vality/domain-proto/domain';
import { Category } from '@vality/dominant-cache-proto';
import { Category } from '@vality/dominant-cache-proto/dominant_cache';
import isNil from 'lodash-es/isNil';
import sortBy from 'lodash-es/sortBy';
import { Observable } from 'rxjs';