mirror of
https://github.com/valitydev/control-center.git
synced 2024-11-06 02:25:17 +00:00
TD-237: New @vality/dominant-cache-proto API codegen (#53)
This commit is contained in:
parent
a9c269bac4
commit
4fcc1cbde0
15
.github/actions/init/action.yaml
vendored
15
.github/actions/init/action.yaml
vendored
@ -3,19 +3,10 @@ description: Init
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Init Thrift
|
||||
uses: valitydev/action-setup-thrift@v0.0.1
|
||||
|
||||
- name: Init NodeJS
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16.13.2'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install Packages
|
||||
run: npm ci
|
||||
- uses: valitydev/action-frontend/setup@v0.1
|
||||
- uses: valitydev/action-setup-thrift@v1.0.0
|
||||
- run: npm ci
|
||||
shell: bash
|
||||
|
||||
- name: Compile Thrift
|
||||
run: npm run compile
|
||||
shell: bash
|
||||
|
31
.github/workflows/build-push.yaml
vendored
31
.github/workflows/build-push.yaml
vendored
@ -1,31 +0,0 @@
|
||||
name: Build & Push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Init
|
||||
uses: ./.github/actions/init
|
||||
|
||||
- name: Check & Build
|
||||
run: npm run ci:build
|
||||
|
||||
- name: Deploy image
|
||||
uses: valitydev/action-deploy-docker@v1.0.16
|
||||
with:
|
||||
registry-username: ${{ github.actor }}
|
||||
registry-access-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
dockerfile-path: .
|
||||
env:
|
||||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
18
.github/workflows/main.yaml
vendored
Normal file
18
.github/workflows/main.yaml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: Main
|
||||
on:
|
||||
push:
|
||||
branches: ['master', 'main']
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/init
|
||||
- name: Build
|
||||
run: npm run build
|
||||
- name: Deploy image
|
||||
uses: valitydev/action-deploy-docker@v2
|
||||
with:
|
||||
registry-username: ${{ github.actor }}
|
||||
registry-access-token: ${{ secrets.GITHUB_TOKEN }}
|
20
.github/workflows/pr-build-check.yaml
vendored
20
.github/workflows/pr-build-check.yaml
vendored
@ -1,20 +0,0 @@
|
||||
name: 'PR: Build & Check'
|
||||
on:
|
||||
pull_request:
|
||||
branches: ['*']
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Init
|
||||
uses: ./.github/actions/init
|
||||
|
||||
- name: Check & Build
|
||||
run: npm run ci:build
|
15
.github/workflows/pr.yaml
vendored
15
.github/workflows/pr.yaml
vendored
@ -1,12 +1,13 @@
|
||||
name: 'PR Title Checker'
|
||||
name: PR
|
||||
on:
|
||||
pull_request:
|
||||
types: [edited, opened, synchronize, reopened]
|
||||
branches: [disabled]
|
||||
branches: ['*']
|
||||
jobs:
|
||||
title-check:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: naveenk1223/action-pr-title@master
|
||||
with:
|
||||
regex: '([A-Z]+-[0-9]+,?)+: [A-Z0-9].*'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/init
|
||||
- name: Check & Build
|
||||
run: npm run ci:build
|
||||
|
23
package-lock.json
generated
23
package-lock.json
generated
@ -28,6 +28,7 @@
|
||||
"@s-libs/micro-dash": "^13.1.0",
|
||||
"@s-libs/ng-core": "^13.1.0",
|
||||
"@s-libs/rxjs-core": "^13.1.0",
|
||||
"@vality/dominant-cache-proto": "1.0.1-5b29d81.0",
|
||||
"@vality/magista-proto": "1.0.1-f1a4bc0.0",
|
||||
"@vality/payout-manager-proto": "^1.0.1-cc9875f.0",
|
||||
"@vality/thrift-ts": "2.2.0-alpha",
|
||||
@ -75,7 +76,6 @@
|
||||
"damsel": "github:valitydev/damsel#318a7a6588c4813bd7d5c170af58fa9b6a80e401",
|
||||
"deanonimus-proto": "github:valitydev/deanonimus-proto#b9fab4fd1c7690186efdc5974d113c82bd5765e9",
|
||||
"del": "^5.1.0",
|
||||
"dominant-cache-proto": "github:valitydev/dominant-cache-proto#ebd35c3096cb5e3222aa29317277b59a01c41fbe",
|
||||
"eslint": "^8.5.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
@ -5268,6 +5268,11 @@
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vality/dominant-cache-proto": {
|
||||
"version": "1.0.1-5b29d81.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/dominant-cache-proto/-/dominant-cache-proto-1.0.1-5b29d81.0.tgz",
|
||||
"integrity": "sha512-mk7H5/WeaXoHPSvube14pQEzYbCxnfrdaaA0DVgAHRxQ8CvX/KEtWT4lG78H/Xrg/6WQhP79T/BvujueO5pq8w=="
|
||||
},
|
||||
"node_modules/@vality/magista-proto": {
|
||||
"version": "1.0.1-f1a4bc0.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-f1a4bc0.0.tgz",
|
||||
@ -10126,12 +10131,6 @@
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/dominant-cache-proto": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "git+ssh://git@github.com/valitydev/dominant-cache-proto.git#ebd35c3096cb5e3222aa29317277b59a01c41fbe",
|
||||
"dev": true,
|
||||
"license": "UNLICENSED"
|
||||
},
|
||||
"node_modules/domino": {
|
||||
"version": "2.1.6",
|
||||
"resolved": "https://registry.npmjs.org/domino/-/domino-2.1.6.tgz",
|
||||
@ -26554,6 +26553,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@vality/dominant-cache-proto": {
|
||||
"version": "1.0.1-5b29d81.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/dominant-cache-proto/-/dominant-cache-proto-1.0.1-5b29d81.0.tgz",
|
||||
"integrity": "sha512-mk7H5/WeaXoHPSvube14pQEzYbCxnfrdaaA0DVgAHRxQ8CvX/KEtWT4lG78H/Xrg/6WQhP79T/BvujueO5pq8w=="
|
||||
},
|
||||
"@vality/magista-proto": {
|
||||
"version": "1.0.1-f1a4bc0.0",
|
||||
"resolved": "https://registry.npmjs.org/@vality/magista-proto/-/magista-proto-1.0.1-f1a4bc0.0.tgz",
|
||||
@ -30544,11 +30548,6 @@
|
||||
"domelementtype": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"dominant-cache-proto": {
|
||||
"version": "git+ssh://git@github.com/valitydev/dominant-cache-proto.git#ebd35c3096cb5e3222aa29317277b59a01c41fbe",
|
||||
"dev": true,
|
||||
"from": "dominant-cache-proto@github:valitydev/dominant-cache-proto#ebd35c3096cb5e3222aa29317277b59a01c41fbe"
|
||||
},
|
||||
"domino": {
|
||||
"version": "2.1.6",
|
||||
"resolved": "https://registry.npmjs.org/domino/-/domino-2.1.6.tgz",
|
||||
|
@ -7,7 +7,7 @@
|
||||
"start": "ng serve --proxy-config proxy.conf.js --port 4200",
|
||||
"build": "ng build --extra-webpack-config webpack.extra.js",
|
||||
"test": "ng test",
|
||||
"lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1307",
|
||||
"lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1328",
|
||||
"lint-cache-cmd": "npm run lint-cmd -- --cache",
|
||||
"lint": "npm run lint-cache-cmd",
|
||||
"lint-fix": "npm run lint-cache-cmd -- --fix",
|
||||
@ -42,6 +42,7 @@
|
||||
"@s-libs/micro-dash": "^13.1.0",
|
||||
"@s-libs/ng-core": "^13.1.0",
|
||||
"@s-libs/rxjs-core": "^13.1.0",
|
||||
"@vality/dominant-cache-proto": "1.0.1-5b29d81.0",
|
||||
"@vality/magista-proto": "1.0.1-f1a4bc0.0",
|
||||
"@vality/payout-manager-proto": "^1.0.1-cc9875f.0",
|
||||
"@vality/thrift-ts": "2.2.0-alpha",
|
||||
@ -89,7 +90,6 @@
|
||||
"damsel": "github:valitydev/damsel#318a7a6588c4813bd7d5c170af58fa9b6a80e401",
|
||||
"deanonimus-proto": "github:valitydev/deanonimus-proto#b9fab4fd1c7690186efdc5974d113c82bd5765e9",
|
||||
"del": "^5.1.0",
|
||||
"dominant-cache-proto": "github:valitydev/dominant-cache-proto#ebd35c3096cb5e3222aa29317277b59a01c41fbe",
|
||||
"eslint": "^8.5.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
@ -117,4 +117,4 @@
|
||||
"ts-node": "~8.8.2",
|
||||
"typescript": "~4.5.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
src/app/api/dominant-cache/dominant-cache.service.ts
Normal file
23
src/app/api/dominant-cache/dominant-cache.service.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Injectable, Injector } 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';
|
||||
|
||||
import { createThriftApi } from '@cc/app/api/utils';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class DominantCacheService extends createThriftApi<CodegenClient>() {
|
||||
constructor(injector: Injector) {
|
||||
super(injector, {
|
||||
service: DominantCache,
|
||||
endpoint: '/v1/dominant/cache',
|
||||
metadata: () =>
|
||||
import('@vality/dominant-cache-proto/lib/metadata.json').then((m) => m.default),
|
||||
context,
|
||||
...codegenClientConfig,
|
||||
});
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ProviderSettings, ThriftInstanceProvider } from '../../thrift-instance-provider';
|
||||
import * as dominant_cache from './gen-nodejs/dominant_cache_types';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class DominantCacheInstanceProvider extends ThriftInstanceProvider {
|
||||
protected getProviderSettings(): ProviderSettings {
|
||||
return {
|
||||
context: {
|
||||
dominant_cache,
|
||||
},
|
||||
metadataName: 'dominant-cache',
|
||||
defaultNamespace: 'dominant_cache',
|
||||
};
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { KeycloakTokenInfoService } from '@cc/app/shared/services';
|
||||
|
||||
import { toListValueType } from '../../../thrift-services';
|
||||
import { ThriftConnector } from '../../thrift-connector';
|
||||
import {
|
||||
CashRegisterProvider,
|
||||
Category,
|
||||
ContractTemplate,
|
||||
Country,
|
||||
TradeBloc,
|
||||
} from '../gen-model/dominant_cache';
|
||||
import { DominantCacheInstanceProvider } from './dominant-cache-instance-provider.service';
|
||||
import * as DominantCache from './gen-nodejs/DominantCache';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class DominantCacheService extends ThriftConnector {
|
||||
constructor(
|
||||
protected keycloakTokenInfoService: KeycloakTokenInfoService,
|
||||
private instanceProvider: DominantCacheInstanceProvider
|
||||
) {
|
||||
super(keycloakTokenInfoService, DominantCache, '/v1/dominant/cache');
|
||||
}
|
||||
|
||||
getCategories(): Observable<Category[]> {
|
||||
return this.instanceProvider.methods$.pipe(
|
||||
switchMap(({ toPlainObject }) =>
|
||||
this.callThriftServiceMethod<Category[]>('GetCategories').pipe(
|
||||
map((v) => toPlainObject(toListValueType('Category'), v))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getDocumentTypes(): Observable<DocumentType[]> {
|
||||
return this.instanceProvider.methods$.pipe(
|
||||
switchMap(({ toPlainObject }) =>
|
||||
this.callThriftServiceMethod<DocumentType[]>('GetDocumentTypes').pipe(
|
||||
map((v) => toPlainObject(toListValueType('DocumentType'), v))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getCashRegisterProviders(): Observable<CashRegisterProvider[]> {
|
||||
return this.instanceProvider.methods$.pipe(
|
||||
switchMap(({ toPlainObject }) =>
|
||||
this.callThriftServiceMethod<CashRegisterProvider[]>(
|
||||
'GetCashRegisterProviders'
|
||||
).pipe(map((v) => toPlainObject(toListValueType('CashRegisterProvider'), v)))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getContractTemplates(): Observable<ContractTemplate[]> {
|
||||
return this.instanceProvider.methods$.pipe(
|
||||
switchMap(({ toPlainObject }) =>
|
||||
this.callThriftServiceMethod<ContractTemplate[]>('GetContractTemplates').pipe(
|
||||
map((v) => toPlainObject(toListValueType('ContractTemplate'), v))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getTradeBlocs(): Observable<TradeBloc[]> {
|
||||
return this.instanceProvider.methods$.pipe(
|
||||
switchMap(({ toPlainObject }) =>
|
||||
this.callThriftServiceMethod<TradeBloc[]>('GetTradeBlocs').pipe(
|
||||
map((v) => toPlainObject(toListValueType('TradeBloc'), v))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getCountries(): Observable<Country[]> {
|
||||
return this.instanceProvider.methods$.pipe(
|
||||
switchMap(({ toPlainObject }) =>
|
||||
this.callThriftServiceMethod<Country[]>('GetCountries').pipe(
|
||||
map((v) => toPlainObject(toListValueType('Country'), v))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './dominant-cache.service';
|
@ -1 +1 @@
|
||||
export * from './dominant-cache';
|
||||
export * from './dominant-cache.service';
|
||||
|
@ -4,7 +4,7 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { KeycloakTokenInfoService } from '@cc/app/shared/services';
|
||||
|
||||
import { ThriftConnector } from '../../thrift-connector';
|
||||
import { ThriftConnector } from '../../utils/thrift-connector';
|
||||
import { RevertParams, RevertState } from '../gen-model/deposit_revert';
|
||||
import { DepositInstanceProvider } from './deposit-instance-provider.service';
|
||||
import * as Management from './gen-nodejs/Management';
|
||||
|
@ -4,7 +4,7 @@ import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { KeycloakTokenInfoService } from '@cc/app/shared/services';
|
||||
|
||||
import { ThriftConnector } from '../../thrift-connector';
|
||||
import { ThriftConnector } from '../../utils/thrift-connector';
|
||||
import { WalletState, EventRange } from '../gen-model/wallet';
|
||||
import * as Management from './gen-nodejs/Management';
|
||||
import { WalletInstanceProvider } from './wallet-instance-provider.service';
|
||||
|
@ -4,7 +4,7 @@ import * as ThriftMerchantStatisticsService from '@vality/magista-proto/lib/magi
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { ThriftConnector } from '@cc/app/api/thrift-connector';
|
||||
import { ThriftConnector } from '@cc/app/api/utils/thrift-connector';
|
||||
import { KeycloakTokenInfoService } from '@cc/app/shared/services';
|
||||
|
||||
import { MagistaInstanceProviderService } from './magista-instance-provider.service';
|
||||
|
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { forkJoin, Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { ThriftConnector } from '@cc/app/api/thrift-connector';
|
||||
import { ThriftConnector } from '@cc/app/api/utils/thrift-connector';
|
||||
import { KeycloakTokenInfoService } from '@cc/app/shared/services';
|
||||
|
||||
import {
|
||||
|
@ -4,7 +4,7 @@ import { Payout, PayoutID, PayoutParams } from '@vality/payout-manager-proto';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { ThriftConnector } from '@cc/app/api/thrift-connector';
|
||||
import { ThriftConnector } from '@cc/app/api/utils/thrift-connector';
|
||||
import { KeycloakTokenInfoService } from '@cc/app/shared/services';
|
||||
|
||||
import { PayoutManagerInstanceProviderService } from './payout-manager-instance-provider.service';
|
||||
|
@ -3,7 +3,7 @@ import partial from 'lodash-es/partial';
|
||||
import { Observable } from 'rxjs';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
|
||||
import { createThriftInstance, thriftInstanceToObject } from '../../thrift-services';
|
||||
import { createThriftInstance, thriftInstanceToObject } from '../utils/thrift-instance';
|
||||
import { ThriftMetaLoader } from './thrift-meta-loader.service';
|
||||
import { ProviderMethods, ProviderSettings } from './types';
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
|
||||
import { from, Observable, ObservableInput } from 'rxjs';
|
||||
import { shareReplay } from 'rxjs/operators';
|
||||
|
||||
import { ThriftAstMetadata } from '../../thrift-services';
|
||||
import { ThriftAstMetadata } from '@cc/app/api/utils';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ThriftMetaLoader {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ThriftAstMetadata } from '../../../thrift-services';
|
||||
import { ThriftAstMetadata } from '@cc/app/api/utils';
|
||||
|
||||
export interface ApiMetadata {
|
||||
[name: string]: ThriftAstMetadata[];
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ObservableInput } from 'rxjs';
|
||||
|
||||
import { ThriftInstanceContext } from '../../../thrift-services';
|
||||
import { ThriftInstanceContext } from '@cc/app/api/utils';
|
||||
|
||||
export interface ProviderSettings {
|
||||
context: ThriftInstanceContext;
|
||||
|
12
src/app/api/utils/create-thrift-api/create-thrift-api.ts
Normal file
12
src/app/api/utils/create-thrift-api/create-thrift-api.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { ThriftApi } from './thrift-api';
|
||||
import { ThriftApiArgs } from './types/thrift-api-args';
|
||||
|
||||
export function createThriftApi<T extends { [N in PropertyKey]: any }>() {
|
||||
return (ThriftApi as unknown) as new (...args: ThriftApiArgs) => {
|
||||
[N in keyof T]: (
|
||||
...args: Parameters<T[N]>
|
||||
) => ReturnType<T[N]> extends Promise<infer R> ? Observable<R> : never;
|
||||
};
|
||||
}
|
1
src/app/api/utils/create-thrift-api/index.ts
Normal file
1
src/app/api/utils/create-thrift-api/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './create-thrift-api';
|
59
src/app/api/utils/create-thrift-api/thrift-api.ts
Normal file
59
src/app/api/utils/create-thrift-api/thrift-api.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import { from } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
import { KeycloakTokenInfoService } from '@cc/app/shared/services';
|
||||
|
||||
import { ThriftConnector } from '../thrift-connector';
|
||||
import { createThriftInstance, thriftInstanceToObject } from '../thrift-instance';
|
||||
import { ThriftApiArgs } from './types/thrift-api-args';
|
||||
|
||||
export class ThriftApi extends ThriftConnector {
|
||||
constructor(...[injector, options]: ThriftApiArgs) {
|
||||
super(
|
||||
injector.get(KeycloakTokenInfoService),
|
||||
options.service,
|
||||
options.endpoint,
|
||||
options.deprecatedHeaders
|
||||
);
|
||||
Object.assign(
|
||||
this,
|
||||
Object.fromEntries(
|
||||
options.functions.map((methodName) => [
|
||||
methodName,
|
||||
(...methodArgs) =>
|
||||
from(options.metadata()).pipe(
|
||||
switchMap((metadata) =>
|
||||
this.callThriftServiceMethodWithConvert(
|
||||
options.name,
|
||||
options.serviceName,
|
||||
methodName,
|
||||
methodArgs,
|
||||
metadata,
|
||||
options.context
|
||||
)
|
||||
)
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private callThriftServiceMethodWithConvert(
|
||||
namespaceName: string,
|
||||
serviceName: string,
|
||||
methodName: string,
|
||||
methodArgs: any[],
|
||||
metadata: any,
|
||||
context: any
|
||||
) {
|
||||
const methodMetadata = metadata.find((m) => m.name === namespaceName).ast.service[
|
||||
serviceName
|
||||
].functions[methodName];
|
||||
const methodThriftArgs = methodArgs.map((arg, idx) =>
|
||||
createThriftInstance(metadata, context, namespaceName, methodMetadata.args[idx], arg)
|
||||
);
|
||||
return this.callThriftServiceMethod(methodName, ...methodThriftArgs).pipe(
|
||||
map((v) => thriftInstanceToObject(metadata, namespaceName, methodMetadata.type, v))
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import { Injector } from '@angular/core';
|
||||
|
||||
import { ThriftApiOptions } from './thrift-api-options';
|
||||
|
||||
export type ThriftApiArgs = [Injector, ThriftApiOptions];
|
@ -0,0 +1,12 @@
|
||||
import { ThriftService } from '@cc/app/api/utils/thrift-connector/utils';
|
||||
|
||||
export interface ThriftApiOptions {
|
||||
name: string;
|
||||
service: ThriftService;
|
||||
serviceName: string;
|
||||
endpoint: string;
|
||||
metadata: () => Promise<any>;
|
||||
context: any;
|
||||
functions: string[];
|
||||
deprecatedHeaders?: boolean;
|
||||
}
|
3
src/app/api/utils/index.ts
Normal file
3
src/app/api/utils/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './create-thrift-api';
|
||||
export * from './thrift-connector';
|
||||
export * from './thrift-instance';
|
@ -4,9 +4,11 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
||||
import { combineLatest } from 'rxjs';
|
||||
import { map, shareReplay, switchMap, take } from 'rxjs/operators';
|
||||
|
||||
import { objectToJSON } from '@cc/app/api/utils';
|
||||
|
||||
import { handleError } from '../../../../utils/operators/handle-error';
|
||||
import { ErrorService } from '../../../shared/services/error';
|
||||
import { damselInstanceToObject, objectToJSON } from '../../../thrift-services';
|
||||
import { damselInstanceToObject } from '../../../thrift-services';
|
||||
import { DomainCacheService } from '../../../thrift-services/damsel/domain-cache.service';
|
||||
import { Predicate, TerminalObject } from '../../../thrift-services/damsel/gen-model/domain';
|
||||
import { AddShopPaymentRoutingRuleDialogComponent } from './add-shop-payment-routing-rule-dialog';
|
||||
|
@ -15,7 +15,7 @@ export class CategoryComponent {
|
||||
@Input() set category(categoryID: number) {
|
||||
this.categoryID = categoryID;
|
||||
this.category$ = this.dominantCacheService
|
||||
.getCategories()
|
||||
.GetCategories()
|
||||
.pipe(
|
||||
map((categories) =>
|
||||
categories.find((category) => category.ref === String(categoryID))
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ContractTemplate } from '@vality/dominant-cache-proto';
|
||||
import isNil from 'lodash-es/isNil';
|
||||
import sortBy from 'lodash-es/sortBy';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
|
||||
import { DominantCacheService } from '@cc/app/api/dominant-cache';
|
||||
import { ContractTemplate } from '@cc/app/api/dominant-cache/gen-model/dominant_cache';
|
||||
|
||||
import { ContractTemplateRef } from '../../../../../thrift-services/damsel/gen-model/domain';
|
||||
|
||||
@ -42,7 +42,7 @@ export class ContractTemplateRefComponent implements OnInit {
|
||||
)
|
||||
);
|
||||
this.form.updateValueAndValidity();
|
||||
this.contracts$ = this.dominantCacheService.getContractTemplates().pipe(
|
||||
this.contracts$ = this.dominantCacheService.GetContractTemplates().pipe(
|
||||
map((templates) => sortBy(templates, (o) => Number(o.ref))),
|
||||
tap(
|
||||
() => {
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { Category } from '@vality/dominant-cache-proto';
|
||||
import isNil from 'lodash-es/isNil';
|
||||
import sortBy from 'lodash-es/sortBy';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
|
||||
import { DominantCacheService } from '@cc/app/api/dominant-cache';
|
||||
import { Category } from '@cc/app/api/dominant-cache/gen-model/dominant_cache';
|
||||
|
||||
import { CategoryRef } from '../../../../../thrift-services/damsel/gen-model/domain';
|
||||
|
||||
@ -41,7 +41,7 @@ export class CategoryRefComponent implements OnInit {
|
||||
this.required ? Validators.required : null
|
||||
)
|
||||
);
|
||||
this.categories$ = this.dominantCacheService.getCategories().pipe(
|
||||
this.categories$ = this.dominantCacheService.GetCategories().pipe(
|
||||
map((categories) => sortBy(categories, (o) => Number(o.ref))),
|
||||
tap(
|
||||
() => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { createThriftInstanceUtils } from '@cc/app/api/utils';
|
||||
|
||||
import metadata from '../../../../assets/meta-damsel.json';
|
||||
import { createThriftInstanceUtils } from '../../utils/thrift-instance';
|
||||
import * as base from '../gen-nodejs/base_types';
|
||||
import * as claim_management from '../gen-nodejs/claim_management_types';
|
||||
import * as domain_config from '../gen-nodejs/domain_config_types';
|
||||
|
@ -1,5 +1,4 @@
|
||||
export * from './filters';
|
||||
export * from './utils/thrift-instance';
|
||||
export * from './utils/get-thrift-instance';
|
||||
export * from './file-storage';
|
||||
export * from './messages';
|
||||
|
@ -35,16 +35,6 @@
|
||||
"definitionFile": "domain_config.thrift"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"namespace": "dominant-cache",
|
||||
"baseUrl": "./node_modules/dominant-cache-proto/proto",
|
||||
"services": [
|
||||
{
|
||||
"outputFolder": "dominant-cache",
|
||||
"definitionFile": "dominant_cache.thrift"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user