TD-887: Move thrift utils to ng-thrift libs package (#356)

This commit is contained in:
Rinat Arsaev 2024-05-13 13:34:44 +05:00 committed by GitHub
parent 31460f99d4
commit ba159b62df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
133 changed files with 247 additions and 866 deletions

33
package-lock.json generated
View File

@ -26,6 +26,7 @@
"@vality/machinegun-proto": "1.0.0",
"@vality/magista-proto": "2.0.2-28d11b9.0",
"@vality/ng-core": "17.2.1-pr-61-d842667.0",
"@vality/ng-thrift": "17.0.1-pr-5-2ce0f11.0",
"@vality/payout-manager-proto": "2.0.1-eb4091a.0",
"@vality/repairer-proto": "2.0.2-07b73e9.0",
"@vality/scrooge-proto": "0.1.1-9ce7fc6.0",
@ -6481,6 +6482,38 @@
"utility-types": "^3.0.0"
}
},
"node_modules/@vality/ng-thrift": {
"version": "17.0.1-pr-5-2ce0f11.0",
"resolved": "https://registry.npmjs.org/@vality/ng-thrift/-/ng-thrift-17.0.1-pr-5-2ce0f11.0.tgz",
"integrity": "sha512-LC/6uzTKu2sgbus2KwGqdzt9r/6JPkRJbkvAByq2fh5cu/RUMJTTQPnrhDDCp0Mc5IuOzUScX+Cl9qFwBXoJcQ==",
"dependencies": {
"tslib": "^2.3.0",
"yaml": "^2.4.2"
},
"peerDependencies": {
"@angular/cdk": "^17.2.0",
"@angular/common": "^17.2.0",
"@angular/core": "^17.2.0",
"@angular/material": "^17.2.0",
"@types/lodash-es": "^4.0.0",
"@vality/ng-core": "^17.2.1-a6a2910.0",
"@vality/thrift-ts": "^2.4.1-8ad5123.0",
"lodash-es": "^4.0.0",
"rxjs": "^7.0.0",
"utility-types": "^3.0.0"
}
},
"node_modules/@vality/ng-thrift/node_modules/yaml": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz",
"integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==",
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14"
}
},
"node_modules/@vality/payout-manager-proto": {
"version": "2.0.1-eb4091a.0",
"resolved": "https://registry.npmjs.org/@vality/payout-manager-proto/-/payout-manager-proto-2.0.1-eb4091a.0.tgz",

View File

@ -34,6 +34,7 @@
"@vality/machinegun-proto": "1.0.0",
"@vality/magista-proto": "2.0.2-28d11b9.0",
"@vality/ng-core": "17.2.1-pr-61-d842667.0",
"@vality/ng-thrift": "17.0.1-pr-5-2ce0f11.0",
"@vality/payout-manager-proto": "2.0.1-eb4091a.0",
"@vality/repairer-proto": "2.0.2-07b73e9.0",
"@vality/scrooge-proto": "0.1.1-9ce7fc6.0",

View File

@ -3,11 +3,11 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Domain, DomainObject, Reference } from '@vality/domain-proto/domain';
import { Commit, Snapshot, Version } from '@vality/domain-proto/domain_config';
import { NotifyLogService, handleError, inProgressFrom, progressTo } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import isEqual from 'lodash-es/isEqual';
import { BehaviorSubject, defer, Observable, of, ReplaySubject, filter, combineLatest } from 'rxjs';
import { map, shareReplay, startWith, switchMap, take, tap } from 'rxjs/operators';
import { getUnionKey } from '../../../../utils';
import { DomainSecretService } from '../../../shared/services';
import { RepositoryService } from '../repository.service';

View File

@ -17,7 +17,7 @@
<mat-label>Statuses</mat-label>
<mat-select formControlName="chargeback_statuses" multiple>
<mat-option *ngFor="let status of statuses" [value]="status">
{{ status | keyTitle | titlecase }}
{{ status | ngtKeyTitle | titlecase }}
</mat-option>
</mat-select>
</mat-form-field>
@ -25,7 +25,7 @@
<mat-label>Stages</mat-label>
<mat-select formControlName="chargeback_stages" multiple>
<mat-option *ngFor="let stage of stages" [value]="stage">
{{ stage | keyTitle | titlecase }}
{{ stage | ngtKeyTitle | titlecase }}
</mat-option>
</mat-select>
</mat-form-field>
@ -33,7 +33,7 @@
<mat-label>Categories</mat-label>
<mat-select formControlName="chargeback_categories" multiple>
<mat-option *ngFor="let category of categories" [value]="category">
{{ category | keyTitle | titlecase }}
{{ category | ngtKeyTitle | titlecase }}
</mat-option>
</mat-select>
</mat-form-field>

View File

@ -17,6 +17,7 @@ import {
debounceTimeWithFirst,
countChanged,
} from '@vality/ng-core';
import { createUnion } from '@vality/ng-thrift';
import { endOfDay } from 'date-fns';
import { filter } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';
@ -28,7 +29,6 @@ import {
CHARGEBACK_CATEGORIES,
} from '@cc/app/api/fistful-stat';
import { createUnion } from '../../../utils';
import { ChangeChargebacksStatusDialogComponent } from '../../shared/components/change-chargebacks-status-dialog';
import { DATE_RANGE_DAYS, DEBOUNCE_TIME_MS } from '../../tokens';

View File

@ -18,12 +18,13 @@ import {
DialogModule,
FileUploadModule,
} from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { MagistaThriftFormComponent } from '@cc/app/shared/components/thrift-api-crud';
import { PageLayoutModule, ShopFieldModule, ThriftPipesModule } from '../../shared';
import { PageLayoutModule, ShopFieldModule } from '../../shared';
import { MerchantFieldModule } from '../../shared/components/merchant-field';
import { MetadataFormModule } from '../../shared/components/metadata-form';
import { ThriftFormModule } from '../../shared/components/metadata-form';
import { DomainThriftFormComponent } from '../../shared/components/thrift-api-crud/domain/domain-thrift-form';
import { ChargebacksRoutingModule } from './chargebacks-routing.module';
@ -49,7 +50,7 @@ import { CreateChargebacksByFileDialogComponent } from './components/create-char
MerchantFieldModule,
ShopFieldModule,
InputFieldModule,
MetadataFormModule,
ThriftFormModule,
MagistaThriftFormComponent,
SelectFieldModule,
MatFormFieldModule,

View File

@ -2,9 +2,9 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
import { InvoicePaymentChargebackStatus } from '@vality/magista-proto/internal/proto/domain';
import { StatChargeback } from '@vality/magista-proto/magista';
import { LoadOptions, Column, TagColumn } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { getUnionKey } from '../../../../../utils';
import { AmountCurrencyService } from '../../../../shared/services';
@Component({

View File

@ -11,12 +11,13 @@ import {
forkJoinToResult,
Column,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { BehaviorSubject, combineLatest } from 'rxjs';
import { switchMap, map, shareReplay, tap, startWith } from 'rxjs/operators';
import { InvoicingService } from '@cc/app/api/payment-processing';
import { parseCsv, unifyCsvItems, getUnionKey } from '@cc/utils';
import { parseCsv, unifyCsvItems } from '@cc/utils';
import { AmountCurrencyService } from '../../../../shared/services';

View File

@ -1,7 +1,7 @@
<cc-page-layout description="#{{ (claim$ | async)?.id }}" title="Claim">
<cc-page-layout-actions *ngIf="claim$ | async as claim">
<cc-status [color]="statusColor[claim.status | ccUnionKey]">{{
claim.status | ccUnionKey | keyTitle | titlecase
<cc-status [color]="statusColor[claim.status | ngtUnionKey]">{{
claim.status | ngtUnionKey | ngtKeyTitle | titlecase
}}</cc-status>
</cc-page-layout-actions>
@ -32,11 +32,11 @@
</cc-timeline-item>
<ng-container
*ngFor="let modificationUnit of claim.changeset"
[ngSwitch]="modificationUnit.modification | ccUnionKey"
[ngSwitch]="modificationUnit.modification | ngtUnionKey"
>
<ng-container
*ngSwitchCase="'party_modification'"
[ngSwitch]="modificationUnit.modification | ccUnionValue | ccUnionKey"
[ngSwitch]="modificationUnit.modification | ccUnionValue | ngtUnionKey"
>
<cc-shop-modification-timeline-item
*ngSwitchCase="'shop_modification'"
@ -55,7 +55,7 @@
</ng-container>
<ng-container
*ngSwitchCase="'claim_modification'"
[ngSwitch]="modificationUnit.modification | ccUnionValue | ccUnionKey"
[ngSwitch]="modificationUnit.modification | ccUnionValue | ngtUnionKey"
>
<cc-status-modification-timeline-item
*ngSwitchCase="'status_modification'"

View File

@ -9,12 +9,12 @@ import {
inProgressFrom,
progressTo,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import { BehaviorSubject, combineLatest, defer, merge, Observable, Subject, switchMap } from 'rxjs';
import { first, map, shareReplay } from 'rxjs/operators';
import { ClaimManagementService } from '@cc/app/api/claim-management';
import { PartyManagementService } from '@cc/app/api/payment-processing';
import { getUnionKey } from '@cc/utils';
import { DomainMetadataFormExtensionsService } from '../../shared/services';

View File

@ -15,14 +15,14 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSelectModule } from '@angular/material/select';
import { RouterModule } from '@angular/router';
import { ActionsModule, DialogModule, PipesModule } from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { JsonViewerModule } from '@cc/app/shared/components/json-viewer/json-viewer.module';
import { StatusModule } from '@cc/app/shared/components/status';
import { ThriftPipesModule } from '@cc/app/shared/pipes';
import { TimelineModule } from '@cc/components/timeline';
import { PageLayoutModule } from '../../shared';
import { MetadataFormModule } from '../../shared/components/metadata-form';
import { ThriftFormModule } from '../../shared/components/metadata-form';
import { DomainThriftFormComponent } from '../../shared/components/thrift-api-crud';
import { ClaimRoutingModule } from './claim-routing.module';
@ -64,7 +64,7 @@ import { TimelineItemLoadingComponent } from './components/timeline-item-loading
MatFormFieldModule,
MatSelectModule,
MatInputModule,
MetadataFormModule,
ThriftFormModule,
MatMenuModule,
MatDialogModule,
MatProgressBarModule,

View File

@ -7,7 +7,7 @@
placeholder="Status"
>
<mat-option *ngFor="let status of statuses" [value]="status">{{
status | keyTitle | titlecase
status | ngtKeyTitle | titlecase
}}</mat-option>
</mat-select>
</mat-form-field>

View File

@ -9,11 +9,11 @@ import {
inProgressFrom,
progressTo,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import { BehaviorSubject, Observable } from 'rxjs';
import { ClaimManagementService } from '@cc/app/api/claim-management';
import { AllowedClaimStatusesService } from '@cc/app/sections/claim/services/allowed-claim-statuses.service';
import { getUnionKey } from '@cc/utils';
@Component({
selector: 'cc-change-status-dialog',

View File

@ -22,11 +22,12 @@ import {
NotifyLogService,
progressTo,
} from '@vality/ng-core';
import { isTypeWithAliases } from '@vality/ng-thrift';
import { of, BehaviorSubject } from 'rxjs';
import { first } from 'rxjs/operators';
import short from 'short-uuid';
import { MetadataFormExtension, isTypeWithAliases } from '@cc/app/shared/components/metadata-form';
import { MetadataFormExtension } from '@cc/app/shared/components/metadata-form';
import { ClaimManagementService } from '../../../../api/claim-management';
import { DomainStoreService } from '../../../../api/domain-config';

View File

@ -6,7 +6,7 @@
<cc-timeline-item-header
[createdAt]="modificationUnit.created_at"
[removed]="!!modificationUnit.removed_at"
[text]="title ?? 'added ' + (modificationUnit.modification | ccUnionKey | keyTitle)"
[text]="title ?? 'added ' + (modificationUnit.modification | ngtUnionKey | ngtKeyTitle)"
[username]="modificationUnit.user_info.username"
></cc-timeline-item-header>
<div>
@ -34,7 +34,7 @@
<div #content><ng-content></ng-content></div>
<mat-expansion-panel *ngIf="!content.innerHTML.trim().length">
<mat-expansion-panel-header>
{{ name | keyTitle | titlecase }}
{{ name | ngtKeyTitle | titlecase }}
</mat-expansion-panel-header>
<cc-json-viewer
[extensions]="extensions$ | async"

View File

@ -16,6 +16,7 @@ import {
inProgressFrom,
progressTo,
} from '@vality/ng-core';
import { getUnionValue } from '@vality/ng-thrift';
import isEmpty from 'lodash-es/isEmpty';
import { BehaviorSubject, switchMap, from } from 'rxjs';
import { filter, first } from 'rxjs/operators';
@ -25,7 +26,6 @@ import { PartyManagementService } from '@cc/app/api/payment-processing';
import { getModificationName } from '@cc/app/sections/claim/utils/get-modification-name';
import { DomainMetadataViewExtensionsService } from '@cc/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions';
import { Color, StatusColor } from '@cc/app/styles';
import { getUnionValue } from '@cc/utils/get-union-key';
import { AddModificationDialogComponent } from '../add-modification-dialog/add-modification-dialog.component';

View File

@ -1,7 +1,6 @@
import { getUnionKey } from '@vality/ng-thrift';
import isObject from 'lodash-es/isObject';
import { getUnionKey } from '@cc/utils';
export function getModificationNameParts(modification: unknown): string[] {
const parts: string[] = [];
for (let modKey = '', mod = modification; isObject(mod); ) {

View File

@ -3,7 +3,7 @@
[color]="claimStatusColor[status]"
[icon]="claimStatusIconName[status]"
[modificationUnit]="modificationUnit"
[title]="'changed claim status to ' + (status | keyTitle)"
[title]="'changed claim status to ' + (status | ngtKeyTitle)"
(claimChanged)="claimChanged.emit()"
>
<mat-card *ngIf="reason">

View File

@ -1,7 +1,6 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Claim, ClaimStatus, ModificationUnit } from '@vality/domain-proto/claim_management';
import { getUnionKey, getUnionValue } from '@cc/utils';
import { getUnionKey, getUnionValue } from '@vality/ng-thrift';
import { CLAIM_STATUS_COLOR } from '../../types/claim-status-color';

View File

@ -1,8 +1,7 @@
import { Modification } from '@vality/domain-proto/claim_management';
import { getUnionKey } from '@vality/ng-thrift';
import isObject from 'lodash-es/isObject';
import { getUnionKey } from '../../../../utils';
import { MODIFICATIONS_NAME_TREE } from './types/modifications-name-tree';
export function getModificationName(modification: Modification) {

View File

@ -10,10 +10,10 @@ import {
import { Router } from '@angular/router';
import { Claim, ClaimStatus } from '@vality/domain-proto/claim_management';
import { Column, LoadOptions, TagColumn, createOperationColumn } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import isObject from 'lodash-es/isObject';
import startCase from 'lodash-es/startCase';
import { getUnionKey } from '../../../../utils';
import { createPartyColumn } from '../../../shared';
@Component({

View File

@ -20,7 +20,7 @@
<mat-form-field>
<mat-select formControlName="statuses" multiple placeholder="Claim statuses">
<mat-option *ngFor="let status of claimStatuses" [value]="status">{{
status | keyTitle | titlecase
status | ngtKeyTitle | titlecase
}}</mat-option>
</mat-select>
</mat-form-field>

View File

@ -13,10 +13,10 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatSelectModule } from '@angular/material/select';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { ActionsModule, DialogModule, TableModule, FiltersModule } from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { PageLayoutModule } from '@cc/app/shared/components';
import { MerchantFieldModule } from '@cc/app/shared/components/merchant-field';
import { ThriftPipesModule } from '@cc/app/shared/pipes';
import { ClaimsComponentRouting } from './claims-routing.module';
import { ClaimsTableComponent } from './claims-table/claims-table.component';

View File

@ -4,17 +4,16 @@ import { ActivatedRoute } from '@angular/router';
import { DepositStatus, RevertStatus } from '@vality/fistful-proto/fistful_stat';
import { Timestamp } from '@vality/fistful-proto/internal/base';
import { formatCurrency, getImportValue } from '@vality/ng-core';
import { getUnionKey, getUnionValue, isTypeWithAliases } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { of, Observable } from 'rxjs';
import { take, map } from 'rxjs/operators';
import { getUnionKey, getUnionValue } from '../../../utils';
import { ManagementService } from '../../api/wallet';
import {
MetadataViewExtension,
MetadataViewExtensionResult,
} from '../../shared/components/json-viewer';
import { isTypeWithAliases } from '../../shared/components/metadata-form';
import { AmountCurrencyService } from '../../shared/services';
import { FetchSourcesService } from '../sources';

View File

@ -10,16 +10,14 @@ import { FormControl } from '@angular/forms';
import { DepositParams } from '@vality/fistful-proto/deposit';
import { Revert } from '@vality/fistful-proto/internal/deposit_revert';
import { DialogSuperclass, NotifyLogService, clean } from '@vality/ng-core';
import { isTypeWithAliases } from '@vality/ng-thrift';
import { BehaviorSubject, of } from 'rxjs';
import { Overwrite } from 'utility-types';
import { DepositManagementService } from '@cc/app/api/deposit';
import { Cash } from '../../../../../components/cash-field';
import {
MetadataFormExtension,
isTypeWithAliases,
} from '../../../../shared/components/metadata-form';
import { MetadataFormExtension } from '../../../../shared/components/metadata-form';
import { UserInfoBasedIdGeneratorService } from '../../../../shared/services';
import { CreateRevertDialogConfig } from './types/create-revert-dialog-config';

View File

@ -1,13 +1,12 @@
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { DepositStatus, StatDeposit, StatDepositRevert } from '@vality/fistful-proto/fistful_stat';
import { DialogService, Column, UpdateOptions } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { filter } from 'rxjs/operators';
import { createCurrencyColumn } from '@cc/app/shared/utils';
import { getUnionKey } from '../../../../utils';
import { CreateRevertDialogComponent } from './create-revert-dialog/create-revert-dialog.component';
import { FetchRevertsService } from './services/fetch-reverts/fetch-reverts.service';

View File

@ -1,18 +1,13 @@
import { Injectable } from '@angular/core';
import { NotifyLogService } from '@vality/ng-core';
import { merge, ReplaySubject, Subject, EMPTY } from 'rxjs';
import { NotifyLogService, inProgressFrom, progressTo } from '@vality/ng-core';
import { ReplaySubject, Subject, EMPTY, defer, BehaviorSubject } from 'rxjs';
import { catchError, switchMap, shareReplay, map } from 'rxjs/operators';
import { FistfulStatisticsService, createDsl } from '@cc/app/api/fistful-stat';
import { progress } from '@cc/app/shared/custom-operators';
@Injectable()
export class ReceiveDepositService {
private receiveDeposit$ = new ReplaySubject<string>();
private error$ = new Subject<boolean>();
// eslint-disable-next-line @typescript-eslint/member-ordering
deposit$ = this.receiveDeposit$.pipe(
deposit$ = defer(() => this.receiveDeposit$).pipe(
switchMap((depositId) =>
this.fistfulStatisticsService
.GetDeposits({ dsl: createDsl({ deposits: { deposit_id: depositId, size: 1 } }) })
@ -22,14 +17,17 @@ export class ReceiveDepositService {
this.log.error(err);
return EMPTY;
}),
),
)
.pipe(progressTo(this.progress$)),
),
map(({ data }) => data?.deposits[0]),
shareReplay(1),
);
isLoading$ = inProgressFrom(() => this.progress$, this.deposit$);
// eslint-disable-next-line @typescript-eslint/member-ordering
isLoading$ = progress(this.receiveDeposit$, merge(this.deposit$, this.error$));
private receiveDeposit$ = new ReplaySubject<string>();
private error$ = new Subject<boolean>();
private progress$ = new BehaviorSubject(0);
constructor(
private fistfulStatisticsService: FistfulStatisticsService,

View File

@ -3,13 +3,14 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl, Validators } from '@angular/forms';
import { DepositParams } from '@vality/fistful-proto/deposit';
import { DialogSuperclass, NotifyLogService, progressTo } from '@vality/ng-core';
import { isTypeWithAliases } from '@vality/ng-thrift';
import { BehaviorSubject, of } from 'rxjs';
import { first, map, switchMap } from 'rxjs/operators';
import { Overwrite } from 'utility-types';
import { SourceCash } from '../../../../components/source-cash-field';
import { DepositManagementService } from '../../../api/deposit';
import { MetadataFormExtension, isTypeWithAliases } from '../../../shared/components/metadata-form';
import { MetadataFormExtension } from '../../../shared/components/metadata-form';
import { UserInfoBasedIdGeneratorService } from '../../../shared/services';
import { FetchSourcesService } from '../../sources';

View File

@ -18,11 +18,11 @@ import {
getValueChanges,
countChanged,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import { endOfDay } from 'date-fns';
import startCase from 'lodash-es/startCase';
import { filter, map, shareReplay } from 'rxjs/operators';
import { getUnionKey } from '../../../utils';
import { QueryDsl } from '../../api/fistful-stat';
import { createCurrencyColumn } from '../../shared';
import { DATE_RANGE_DAYS, DEBOUNCE_TIME_MS } from '../../tokens';

View File

@ -9,8 +9,9 @@ import { MatSidenavModule } from '@angular/material/sidenav';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { RouterModule } from '@angular/router';
import { PipesModule, ActionsModule } from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { ThriftPipesModule, PageLayoutModule } from '../../../shared';
import { PageLayoutModule } from '../../../shared';
import { DomainThriftViewerComponent } from '../../../shared/components/thrift-api-crud';
import { ThriftViewerModule } from '../../../shared/components/thrift-viewer';

View File

@ -3,10 +3,9 @@ import { NgModule } from '@angular/core';
import { DomainInfoModule } from './domain-info';
import { DomainRoutingModule } from './domain-routing.module';
import { MetadataService } from './services/metadata.service';
import { ModifiedDomainObjectService } from './services/modified-domain-object.service';
@NgModule({
imports: [DomainRoutingModule, DomainInfoModule],
providers: [MetadataService, ModifiedDomainObjectService],
providers: [MetadataService],
})
export class DomainModule {}

View File

@ -1,57 +0,0 @@
import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { DomainObject, Reference } from '@vality/domain-proto/domain';
import { NotifyLogService } from '@vality/ng-core';
import { Observable, switchMap, BehaviorSubject, defer } from 'rxjs';
import { map, shareReplay, first } from 'rxjs/operators';
import { toJson, getUnionValue, progressTo } from '@cc/utils';
import { DomainStoreService } from '../../../api/domain-config';
import { MetadataService } from './metadata.service';
@Injectable()
export class DomainObjModificationService {
progress$ = new BehaviorSubject(0);
fullObject$ = defer(() => this.ref$).pipe(switchMap((ref) => this.getDomainObject(ref, true)));
object$ = defer(() => this.ref$).pipe(
switchMap((ref) => this.getDomainObject(ref, false).pipe(progressTo(this.progress$))),
map((obj) => getUnionValue(obj)),
shareReplay({ refCount: true, bufferSize: 1 }),
);
type$ = defer(() => this.ref$).pipe(
switchMap((ref) => this.metadataService.getDomainObjectType(ref)),
shareReplay({ refCount: true, bufferSize: 1 }),
);
private ref$ = this.route.queryParams.pipe(
map(({ ref }) => {
try {
return JSON.parse(ref as string) as Reference;
} catch (err) {
this.log.error(err, 'Malformed domain object ref');
return null;
}
}),
);
constructor(
private route: ActivatedRoute,
private domainStoreService: DomainStoreService,
private metadataService: MetadataService,
private log: NotifyLogService,
) {}
private getDomainObject(ref: Reference, rawDomain: boolean): Observable<DomainObject> {
return this.domainStoreService.getDomain(rawDomain).pipe(
first(),
map((domain) => {
const searchRef = JSON.stringify(ref);
return domain.get(
Array.from(domain.keys()).find((k) => JSON.stringify(toJson(k)) === searchRef),
);
}),
);
}
}

View File

@ -1,13 +0,0 @@
import { Injectable } from '@angular/core';
import { DomainObject } from '@vality/domain-proto/domain';
@Injectable()
export class ModifiedDomainObjectService {
domainObject: DomainObject;
ref: string;
update(domainObject: DomainObject, ref: string) {
this.domainObject = domainObject;
this.ref = ref;
}
}

View File

@ -5,15 +5,15 @@
<!-- </div>-->
<v-tag
*ngIf="party?.blocking"
[color]="(party?.blocking | ccUnionKey) === 'blocked' ? 'warn' : 'success'"
[color]="(party?.blocking | ngtUnionKey) === 'blocked' ? 'warn' : 'success'"
style="margin-top: 8px"
>{{ party?.blocking | ccUnionKey | titlecase }}</v-tag
>{{ party?.blocking | ngtUnionKey | titlecase }}</v-tag
>
<v-tag
*ngIf="party?.suspension"
[color]="(party?.suspension | ccUnionKey) === 'suspended' ? 'warn' : 'success'"
[color]="(party?.suspension | ngtUnionKey) === 'suspended' ? 'warn' : 'success'"
style="margin-top: 8px"
>{{ party?.suspension | ccUnionKey | titlecase }}</v-tag
>{{ party?.suspension | ngtUnionKey | titlecase }}</v-tag
>
</div>
</mat-toolbar>

View File

@ -5,8 +5,9 @@ import { MatSidenavModule } from '@angular/material/sidenav';
import { MatTabsModule } from '@angular/material/tabs';
import { MatToolbar } from '@angular/material/toolbar';
import { NavComponent, TagModule } from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { PageLayoutModule, ThriftPipesModule } from '../../shared';
import { PageLayoutModule } from '../../shared';
import { PartyRouting } from './party-routing.module';
import { PartyComponent } from './party.component';

View File

@ -10,15 +10,14 @@ import {
formatCurrency,
Color,
} from '@vality/ng-core';
import { getUnionKey, getUnionValue, isTypeWithAliases } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { Subject, merge, defer, Observable, of } from 'rxjs';
import { shareReplay, switchMap, map } from 'rxjs/operators';
import { InvoicingService } from '@cc/app/api/payment-processing';
import { getUnionKey, getUnionValue } from '../../../utils';
import { MetadataViewExtension } from '../../shared/components/json-viewer';
import { isTypeWithAliases } from '../../shared/components/metadata-form';
import { DomainMetadataViewExtensionsService } from '../../shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions';
import { AmountCurrencyService } from '../../shared/services';

View File

@ -13,7 +13,7 @@ import { HeadlineModule } from '@cc/components/headline';
import { ChargebacksComponent } from '../../shared/components/chargebacks/chargebacks.component';
import { JsonViewerModule } from '../../shared/components/json-viewer';
import { MetadataFormModule } from '../../shared/components/metadata-form';
import { ThriftFormModule } from '../../shared/components/metadata-form';
import { MagistaThriftViewerComponent } from '../../shared/components/thrift-api-crud';
import { ThriftViewerModule } from '../../shared/components/thrift-viewer';
@ -36,7 +36,7 @@ import { RefundsTableModule } from './refunds-table';
ChargebacksComponent,
ActionsModule,
DialogModule,
MetadataFormModule,
ThriftFormModule,
ReactiveFormsModule,
PageLayoutModule,
ThriftViewerModule,

View File

@ -1,9 +1,9 @@
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { InvoicePaymentID, InvoiceID, PartyID } from '@vality/domain-proto/domain';
import { Column, UpdateOptions } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { getUnionKey } from '../../../../utils';
import { Refund } from '../../../api/fistful-stat';
import { createCurrencyColumn } from '../../../shared';

View File

@ -2,8 +2,9 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { TableModule } from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { StatusModule, CommonPipesModule, ThriftPipesModule } from '../../../shared';
import { StatusModule, CommonPipesModule } from '../../../shared';
import { RefundsTableComponent } from './refunds-table.component';

View File

@ -3,10 +3,10 @@ import { Router } from '@angular/router';
import { InvoicePaymentStatus } from '@vality/domain-proto/domain';
import { StatPayment } from '@vality/magista-proto/magista';
import { Column, TagColumn, LoadOptions, createOperationColumn } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { AmountCurrencyService } from '@cc/app/shared/services';
import { getUnionKey } from '@cc/utils';
import { createFailureColumn, createPartyColumn, createShopColumn } from '../../../../shared';
import { createProviderColumn } from '../../../../shared/utils/table/create-provider-column';

View File

@ -16,6 +16,7 @@ import {
getValueChanges,
countChanged,
} from '@vality/ng-core';
import { isTypeWithAliases } from '@vality/ng-thrift';
import { endOfDay } from 'date-fns';
import { uniq } from 'lodash-es';
import isEqual from 'lodash-es/isEqual';
@ -23,7 +24,7 @@ import { BehaviorSubject, of, merge } from 'rxjs';
import { startWith, map, distinctUntilChanged, shareReplay } from 'rxjs/operators';
import { FailMachinesDialogComponent, Type } from '../../shared/components/fail-machines-dialog';
import { MetadataFormExtension, isTypeWithAliases } from '../../shared/components/metadata-form';
import { MetadataFormExtension } from '../../shared/components/metadata-form';
import { DATE_RANGE_DAYS, DEBOUNCE_TIME_MS } from '../../tokens';
import { CreatePaymentAdjustmentComponent } from './components/create-payment-adjustment/create-payment-adjustment.component';

View File

@ -13,7 +13,7 @@ import {
import { PageLayoutModule, ShopFieldModule } from '@cc/app/shared';
import { MerchantFieldModule } from '@cc/app/shared/components/merchant-field';
import { MetadataFormModule } from '@cc/app/shared/components/metadata-form';
import { ThriftFormModule } from '@cc/app/shared/components/metadata-form';
import { MagistaThriftFormComponent } from '../../shared/components/thrift-api-crud';
@ -34,7 +34,7 @@ import { PaymentsComponent } from './payments.component';
ReactiveFormsModule,
TableModule,
DialogModule,
MetadataFormModule,
ThriftFormModule,
MatButtonModule,
ShopFieldModule,
InputFieldModule,

View File

@ -1,7 +1,7 @@
<cc-page-layout [description]="(payout$ | async)?.id" [progress]="progress$ | async" title="Payout">
<cc-page-layout-actions *ngIf="payout$ | async as payout">
<button
[disabled]="canBeCancelled(payout.status | ccUnionKey)"
[disabled]="canBeCancelled(payout.status | ngtUnionKey)"
color="warn"
mat-raised-button
(click)="cancel(payout.id)"
@ -9,7 +9,7 @@
Cancel
</button>
<button
[disabled]="canBeConfirmed(payout.status | ccUnionKey)"
[disabled]="canBeConfirmed(payout.status | ngtUnionKey)"
color="primary"
mat-raised-button
(click)="confirm(payout.id)"
@ -31,7 +31,7 @@
{{ payout.currency.symbolic_code | ccCurrency }}
</cc-details-item>
<cc-details-item title="Status">{{
payout.status | ccUnionKey
payout.status | ngtUnionKey
}}</cc-details-item>
<cc-details-item *ngIf="payout.status.cancelled" title="Status Details">{{
payout.status.cancelled.details

View File

@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PayoutID, PayoutStatus } from '@vality/magista-proto/magista';
import { Column, progressTo } from '@vality/ng-core';
import { getUnionKey, getUnionValue } from '@vality/ng-thrift';
import { FinalCashFlowPosting } from '@vality/payout-manager-proto/internal/proto/domain';
import startCase from 'lodash-es/startCase';
import { combineLatest, BehaviorSubject } from 'rxjs';
@ -10,7 +11,6 @@ import { map, shareReplay, startWith, switchMap } from 'rxjs/operators';
import { PartyManagementService } from '@cc/app/api/payment-processing';
import { PayoutManagementService } from '@cc/app/api/payout-manager';
import { getUnionKey, getUnionValue } from '../../../../utils';
import { createCurrencyColumn } from '../../../shared';
import { PayoutActionsService } from '../services/payout-actions.service';

View File

@ -5,10 +5,11 @@ import { MatCardModule } from '@angular/material/card';
import { MatDividerModule } from '@angular/material/divider';
import { MatPaginatorModule } from '@angular/material/paginator';
import { ActionsModule, TableModule } from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { ShopDetailsModule, PageLayoutModule } from '@cc/app/shared/components';
import { PayoutToolDetailsModule } from '@cc/app/shared/components/payout-tool-details/payout-tool-details.module';
import { CommonPipesModule, ThriftPipesModule } from '@cc/app/shared/pipes';
import { CommonPipesModule } from '@cc/app/shared/pipes';
import { DetailsItemModule } from '@cc/components/details-item';
import { HeadlineModule } from '@cc/components/headline';

View File

@ -18,11 +18,11 @@ import {
debounceTimeWithFirst,
countChanged,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import { endOfDay } from 'date-fns';
import startCase from 'lodash-es/startCase';
import { map, shareReplay } from 'rxjs/operators';
import { getUnionKey } from '../../../../utils';
import { createCurrencyColumn, createPartyColumn, createShopColumn } from '../../../shared';
import { DATE_RANGE_DAYS, DEBOUNCE_TIME_MS } from '../../../tokens';
import { PayoutActionsService } from '../services/payout-actions.service';

View File

@ -19,6 +19,7 @@ import {
FiltersModule,
EnumKeysPipe,
} from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import {
PayoutToolFieldModule,
@ -27,7 +28,7 @@ import {
PageLayoutModule,
} from '@cc/app/shared/components';
import { MerchantFieldModule } from '@cc/app/shared/components/merchant-field';
import { CommonPipesModule, ThriftPipesModule } from '@cc/app/shared/pipes';
import { CommonPipesModule } from '@cc/app/shared/pipes';
import { CancelPayoutDialogComponent } from './components/cancel-payout-dialog/cancel-payout-dialog.component';
import { CreatePayoutDialogComponent } from './components/create-payout-dialog/create-payout-dialog.component';

View File

@ -22,7 +22,7 @@
*ngFor="let statusName of status | enumKeys"
[value]="status[statusName]"
>
{{ statusName | keyTitle | titlecase }}
{{ statusName | ngtKeyTitle | titlecase }}
</mat-option>
</mat-select>
</mat-form-field>

View File

@ -21,9 +21,10 @@ import {
EnumKeysPipe,
FiltersModule,
} from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { PageLayoutModule, ThriftPipesModule } from '@cc/app/shared';
import { MetadataFormModule } from '@cc/app/shared/components/metadata-form';
import { PageLayoutModule } from '@cc/app/shared';
import { ThriftFormModule } from '@cc/app/shared/components/metadata-form';
import { DomainObjectFieldComponent } from '@cc/app/shared/components/thrift-api-crud';
import { RepairByScenarioDialogComponent } from './components/repair-by-scenario-dialog/repair-by-scenario-dialog.component';
@ -47,7 +48,7 @@ import { RepairingComponent } from './repairing.component';
MatSelectModule,
ActionsModule,
DialogModule,
MetadataFormModule,
ThriftFormModule,
MatRadioModule,
MatChipsModule,
EnumKeyPipe,

View File

@ -12,6 +12,7 @@ import {
DragDrop,
correctPriorities,
} from '@vality/ng-core';
import { toJson, getUnionKey } from '@vality/ng-thrift';
import cloneDeep from 'lodash-es/cloneDeep';
import { Observable, combineLatest, filter } from 'rxjs';
import { first, map, switchMap, withLatestFrom, take } from 'rxjs/operators';
@ -24,7 +25,6 @@ import {
UpdateThriftDialogComponent,
} from '@cc/app/shared/components/thrift-api-crud';
import { objectToJSON, getUnionKey } from '../../../../utils';
import { createPredicateColumn } from '../../../shared';
import { CandidateCardComponent } from '../../../shared/components/candidate-card/candidate-card.component';
import { SidenavInfoService } from '../../../shared/components/sidenav-info';
@ -103,7 +103,7 @@ export class RoutingRulesetComponent {
{ field: 'weight', sortable: true },
{
field: 'pin',
formatter: (d) => JSON.stringify(objectToJSON(d.pin?.features)),
formatter: (d) => JSON.stringify(toJson(d.pin?.features)),
hide: true,
},
createOperationColumn<RoutingCandidate>([

View File

@ -2,13 +2,12 @@ import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { Party } from '@vality/deanonimus-proto/deanonimus';
import { Column, createOperationColumn, QueryParamsService, UpdateOptions } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { map } from 'rxjs/operators';
import { FetchPartiesService } from '@cc/app/shared/services/fetch-parties.service';
import { getUnionKey } from '../../../utils';
@Component({
templateUrl: 'search-parties.component.html',
styleUrls: ['search-parties.component.scss'],

View File

@ -9,7 +9,7 @@ import { ActionsModule, DialogModule, TableModule } from '@vality/ng-core';
import { PageLayoutModule } from '../../shared';
import { FistfulThriftFormComponent } from '../../shared/components/fistful-thrift-form';
import { MetadataFormModule } from '../../shared/components/metadata-form';
import { ThriftFormModule } from '../../shared/components/metadata-form';
import { CreateSourceComponent } from './create-source/create-source.component';
import { SourcesRoutingModule } from './sources-routing.module';
@ -26,7 +26,7 @@ import { SourcesComponent } from './sources.component';
TableModule,
MatTableModule,
DialogModule,
MetadataFormModule,
ThriftFormModule,
ReactiveFormsModule,
PageLayoutModule,
FistfulThriftFormComponent,

View File

@ -4,8 +4,7 @@ import {
RoutingDelegate,
RoutingCandidate,
} from '@vality/domain-proto/domain';
import { getUnionKey } from '../../../../utils';
import { getUnionKey } from '@vality/ng-thrift';
export interface TerminalShopWalletDelegate {
delegate: RoutingDelegate;

View File

@ -10,7 +10,7 @@ import { TableModule, ListFieldModule, FiltersModule, SwitchButtonModule } from
import { PageLayoutModule } from '@cc/app/shared';
import { MerchantFieldModule } from '@cc/app/shared/components/merchant-field';
import { MetadataFormModule } from '@cc/app/shared/components/metadata-form';
import { ThriftFormModule } from '@cc/app/shared/components/metadata-form';
import { CurrencyFieldComponent } from '../../shared/components/currency-field';
@ -24,7 +24,7 @@ import { WalletsComponent } from './wallets.component';
MatCardModule,
TableModule,
MatProgressSpinnerModule,
MetadataFormModule,
ThriftFormModule,
ReactiveFormsModule,
MatInputModule,
MerchantFieldModule,

View File

@ -4,15 +4,13 @@ import { Validators, FormControl } from '@angular/forms';
import { StatWithdrawal } from '@vality/fistful-proto/fistful_stat';
import { AdjustmentParams } from '@vality/fistful-proto/withdrawal_adjustment';
import { DialogSuperclass, forkJoinToResult, NotifyLogService } from '@vality/ng-core';
import { isTypeWithAliases } from '@vality/ng-thrift';
import { BehaviorSubject, of } from 'rxjs';
import * as short from 'short-uuid';
import { ManagementService } from '@cc/app/api/withdrawal';
import {
MetadataFormExtension,
isTypeWithAliases,
} from '../../../../shared/components/metadata-form';
import { MetadataFormExtension } from '../../../../shared/components/metadata-form';
@Component({
templateUrl: './create-adjustment-dialog.component.html',

View File

@ -19,13 +19,13 @@ import {
countChanged,
debounceTimeWithFirst,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import { endOfDay } from 'date-fns';
import startCase from 'lodash-es/startCase';
import { map, shareReplay } from 'rxjs/operators';
import { WithdrawalParams } from '@cc/app/api/fistful-stat';
import { getUnionKey } from '../../../utils';
import { createFailureColumn } from '../../shared';
import { FailMachinesDialogComponent, Type } from '../../shared/components/fail-machines-dialog';
import { AmountCurrencyService } from '../../shared/services';

View File

@ -20,11 +20,12 @@ import {
InputFieldModule,
AutocompleteFieldModule,
} from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { PageLayoutModule, WalletFieldModule, ThriftPipesModule } from '../../shared';
import { PageLayoutModule, WalletFieldModule } from '../../shared';
import { FistfulThriftFormComponent } from '../../shared/components/fistful-thrift-form';
import { MerchantFieldModule } from '../../shared/components/merchant-field';
import { MetadataFormModule } from '../../shared/components/metadata-form';
import { ThriftFormModule } from '../../shared/components/metadata-form';
import { CreateAdjustmentDialogComponent } from './components/create-adjustment-dialog/create-adjustment-dialog.component';
import { WithdrawalsRoutingModule } from './withdrawals-routing.module';
@ -43,7 +44,7 @@ import { WithdrawalsComponent } from './withdrawals.component';
MatCheckboxModule,
TableModule,
MatSortModule,
MetadataFormModule,
ThriftFormModule,
DialogModule,
MatFormFieldModule,
MatSelectModule,

View File

@ -19,7 +19,7 @@ import { from, BehaviorSubject } from 'rxjs';
import { InvoicingService } from '@cc/app/api/payment-processing';
import { DomainMetadataFormExtensionsService } from '@cc/app/shared/services';
import { MetadataFormModule } from '../metadata-form';
import { ThriftFormModule } from '../metadata-form';
enum Action {
Accept,
@ -42,7 +42,7 @@ const CHANGE_STATUS_METHODS = {
CommonModule,
DialogModule,
MatButtonModule,
MetadataFormModule,
ThriftFormModule,
ReactiveFormsModule,
MatFormFieldModule,
MatSelectModule,

View File

@ -2,12 +2,12 @@ import { CommonModule } from '@angular/common';
import { Component, Input } from '@angular/core';
import { InvoicePaymentChargeback } from '@vality/domain-proto/payment_processing';
import { DialogService, Column, TableModule, createOperationColumn } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { createCurrencyColumn } from '@cc/app/shared';
import { DetailsDialogComponent } from '@cc/app/shared/components/details-dialog/details-dialog.component';
import { getUnionKey } from '../../../../utils';
import { ChangeChargebacksStatusDialogComponent } from '../change-chargebacks-status-dialog';
@Component({

View File

@ -3,10 +3,11 @@ import { Component } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { ThriftAstMetadata } from '@vality/fistful-proto';
import { createControlProviders, getImportValue } from '@vality/ng-core';
import { isTypeWithAliases } from '@vality/ng-thrift';
import { of } from 'rxjs';
import short from 'short-uuid';
import { isTypeWithAliases, MetadataFormExtension } from '../metadata-form';
import { MetadataFormExtension } from '../metadata-form';
import { BaseThriftFormSuperclass } from '../thrift-api-crud/thrift-forms/utils/thrift-form-superclass';
import { ThriftEditorModule } from '../thrift-editor';

View File

@ -5,7 +5,7 @@
<ng-template #defKey>
<ng-container *ngFor="let pathItem of keys; let idx = index">
<span [class]="(parentIsUnion(pathItem) | async) ? 'bold' : 'mat-secondary-text'"
>{{ (pathItem.key$ | async)?.renderValue$ | async | keyTitle | titlecase
>{{ (pathItem.key$ | async)?.renderValue$ | async | ngtKeyTitle | titlecase
}}{{
idx !== keys.length - 1 ? ((isUnion(pathItem) | async) ? ': ' : ' / ') : ''
}}</span

View File

@ -1,12 +1,11 @@
import { Component, Input, OnChanges } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ThriftAstMetadata } from '@vality/domain-proto';
import { ThriftData } from '@vality/ng-thrift';
import { ValueType, Field } from '@vality/thrift-ts';
import { map } from 'rxjs';
import yaml from 'yaml';
import { MetadataFormData } from '../metadata-form';
import { MetadataViewItem } from './utils/metadata-view';
import {
MetadataViewExtension,
@ -27,9 +26,9 @@ export class JsonViewerComponent implements OnChanges {
@Input() namespace: string;
@Input() type: ValueType;
@Input() field?: Field;
@Input() parent?: MetadataFormData;
@Input() parent?: ThriftData;
@Input() data: MetadataFormData;
@Input() data: ThriftData;
@Input() extensions: MetadataViewExtension[];
view: MetadataViewItem;
@ -43,7 +42,7 @@ export class JsonViewerComponent implements OnChanges {
ngOnChanges() {
if (this.metadata && this.namespace && this.type) {
try {
this.data = new MetadataFormData(
this.data = new ThriftData(
this.metadata,
this.namespace,
this.type,

View File

@ -8,8 +8,8 @@ import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { RouterModule } from '@angular/router';
import { TagModule } from '@vality/ng-core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { ThriftPipesModule } from '@cc/app/shared';
import { DetailsItemModule } from '@cc/components/details-item';
import { KeyComponent } from './components/key/key.component';

View File

@ -1,8 +1,7 @@
import { ThriftData, TypeGroup } from '@vality/ng-thrift';
import { ValueType, Field, SetType, MapType, ListType } from '@vality/thrift-ts';
import { MetadataFormData, TypeGroup } from '../../metadata-form';
export function getChildrenTypes(sourceData: MetadataFormData): {
export function getChildrenTypes(sourceData: ThriftData): {
keyType?: ValueType;
valueType?: ValueType;
fields?: Field[];
@ -12,21 +11,21 @@ export function getChildrenTypes(sourceData: MetadataFormData): {
case TypeGroup.Object: {
switch (data.objectType) {
case 'struct':
return { fields: (data as MetadataFormData<ValueType, 'struct'>).ast };
return { fields: (data as ThriftData<ValueType, 'struct'>).ast };
case 'union':
return { fields: (data as MetadataFormData<ValueType, 'union'>).ast };
return { fields: (data as ThriftData<ValueType, 'union'>).ast };
}
return;
}
case TypeGroup.Complex: {
if ((data as MetadataFormData<SetType | MapType | ListType>).type.name === 'map') {
if ((data as ThriftData<SetType | MapType | ListType>).type.name === 'map') {
return {
keyType: (data as MetadataFormData<MapType>).type.keyType,
valueType: (data as MetadataFormData<MapType>).type.valueType,
keyType: (data as ThriftData<MapType>).type.keyType,
valueType: (data as ThriftData<MapType>).type.valueType,
};
}
return {
valueType: (data as MetadataFormData<SetType | ListType>).type.valueType,
valueType: (data as ThriftData<SetType | ListType>).type.valueType,
};
}
}

View File

@ -1,10 +1,9 @@
import { Router } from '@angular/router';
import { Color } from '@vality/ng-core';
import { ThriftData } from '@vality/ng-thrift';
import { Observable, combineLatest, switchMap, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { MetadataFormData } from '../../metadata-form';
export interface MetadataViewExtensionResult {
key?: string;
value?: unknown;
@ -17,9 +16,9 @@ export interface MetadataViewExtensionResult {
}
export type MetadataViewExtension = {
determinant: (data: MetadataFormData, value: unknown) => Observable<boolean>;
determinant: (data: ThriftData, value: unknown) => Observable<boolean>;
extension: (
data: MetadataFormData,
data: ThriftData,
value: unknown,
viewValue: unknown,
) => Observable<MetadataViewExtensionResult>;
@ -27,7 +26,7 @@ export type MetadataViewExtension = {
export function getFirstDeterminedExtensionsResult(
sourceExtensions: MetadataViewExtension[],
data: MetadataFormData,
data: ThriftData,
value: unknown,
viewValue: unknown,
): Observable<MetadataViewExtensionResult> {

View File

@ -1,12 +1,11 @@
import { isEmpty } from '@vality/ng-core';
import { ThriftData } from '@vality/ng-thrift';
import { SetType, ListType, MapType, ValueType } from '@vality/thrift-ts';
import isNil from 'lodash-es/isNil';
import isObject from 'lodash-es/isObject';
import { Observable, of, switchMap, combineLatest, defer } from 'rxjs';
import { map, shareReplay, distinctUntilChanged, startWith } from 'rxjs/operators';
import { MetadataFormData } from '../../metadata-form';
import { getChildrenTypes } from './get-children-types';
import { getEntries } from './get-entries';
import {
@ -58,8 +57,7 @@ export class MetadataViewItem {
items.length > 1 ||
isObject(keyValue) ||
key?.data ||
(data?.trueTypeNode?.data as MetadataFormData<SetType | ListType | MapType>)?.type
?.name
(data?.trueTypeNode?.data as ThriftData<SetType | ListType | MapType>)?.type?.name
) {
return of([]);
}
@ -148,7 +146,7 @@ export class MetadataViewItem {
constructor(
private value: unknown,
private key?: MetadataViewItem,
private data?: MetadataFormData,
private data?: ThriftData,
private extensions?: MetadataViewExtension[],
) {}
@ -160,7 +158,7 @@ export class MetadataViewItem {
if (
trueData.objectType === 'struct' ||
trueData.objectType === 'union' ||
(trueData as MetadataFormData<SetType | ListType | MapType>).type?.name
(trueData as ThriftData<SetType | ListType | MapType>).type?.name
) {
const types = getChildrenTypes(trueData);
return getEntries(value).map(([itemKey, itemValue]) => {
@ -197,10 +195,10 @@ export class MetadataViewItem {
return isEmpty(value) || ext?.hidden ? null : value;
}
private getRenderValue(value: unknown, data: MetadataFormData) {
private getRenderValue(value: unknown, data: ThriftData) {
if (data?.trueTypeNode?.data?.objectType === 'enum') {
return (
(data.trueTypeNode.data as MetadataFormData<ValueType, 'enum'>).ast.items.find(
(data.trueTypeNode.data as ThriftData<ValueType, 'enum'>).ast.items.find(
(i, idx) => {
if ('value' in i) {
return i.value === value;

View File

@ -3,8 +3,8 @@
{{ data.type | fieldLabel: data.field }}
<span class="mat-secondary-text">
({{ data.type.name | titlecase }}:
{{ isKeyValue ? (keyType | valueTypeTitle | titlecase) + ' - ' : '' }}
{{ data.type.valueType | valueTypeTitle | titlecase }})
{{ isKeyValue ? (keyType | ngtValueTypeTitle | titlecase) + ' - ' : '' }}
{{ data.type.valueType | ngtValueTypeTitle | titlecase }})
</span>
</span>
<mat-accordion [ngStyle]="{ 'padding-left': hasLabel && '16px', overflow: 'hidden' }">
@ -29,7 +29,7 @@
</ng-template>
</ng-container>
<ng-template #edited>
{{ data.type.valueType | valueTypeTitle }}
{{ data.type.valueType | ngtValueTypeTitle }}
</ng-template>
</div>
<div *ngIf="isKeyValue && !panel.expanded">
@ -68,5 +68,5 @@
</ng-template>
</mat-expansion-panel>
</mat-accordion>
<button mat-button (click)="add()">Add {{ data.type.valueType | valueTypeTitle }}</button>
<button mat-button (click)="add()">Add {{ data.type.valueType | ngtValueTypeTitle }}</button>
</div>

View File

@ -8,13 +8,12 @@ import {
AbstractControl,
} from '@angular/forms';
import { FormComponentSuperclass, createControlProviders, getErrorsTree } from '@vality/ng-core';
import { ThriftData } from '@vality/ng-thrift';
import { MapType, SetType, ListType } from '@vality/thrift-ts';
import { merge } from 'rxjs';
import { MetadataFormExtension } from '@cc/app/shared/components/metadata-form';
import { MetadataFormData } from '../../types/metadata-form-data';
function updateFormArray<V>(formArray: FormArray<AbstractControl<V>>, values: V[]) {
formArray.clear({ emitEvent: false });
values.forEach((v) => {
@ -35,7 +34,7 @@ export class ComplexFormComponent<V, K = never>
extends FormComponentSuperclass<ComplexType<V, K>>
implements OnInit, Validator
{
@Input() data: MetadataFormData<SetType | MapType | ListType>;
@Input() data: ThriftData<SetType | MapType | ListType>;
@Input() extensions: MetadataFormExtension[];
valueControls = new FormArray<AbstractControl<V>>([]);

View File

@ -1,7 +1,6 @@
import { Component, Input } from '@angular/core';
import { createControlProviders, FormControlSuperclass } from '@vality/ng-core';
import { MetadataFormData } from '../../types/metadata-form-data';
import { ThriftData } from '@vality/ng-thrift';
@Component({
selector: 'cc-enum-field',
@ -9,5 +8,5 @@ import { MetadataFormData } from '../../types/metadata-form-data';
providers: createControlProviders(() => EnumFieldComponent),
})
export class EnumFieldComponent<T> extends FormControlSuperclass<T> {
@Input() data: MetadataFormData<string, 'enum'>;
@Input() data: ThriftData<string, 'enum'>;
}

View File

@ -2,13 +2,11 @@ import { Component, Input, OnChanges, OnInit, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validator, ValidationErrors, FormControl, Validators } from '@angular/forms';
import { FormComponentSuperclass, ComponentChanges, createControlProviders } from '@vality/ng-core';
import { getValueTypeTitle, getAliases, ThriftData } from '@vality/ng-thrift';
import { ThriftType } from '@vality/thrift-ts';
import { defer, switchMap, ReplaySubject, Observable, combineLatest } from 'rxjs';
import { shareReplay, first, map, pluck } from 'rxjs/operators';
import { getValueTypeTitle } from '@cc/app/shared/pipes';
import { getAliases, MetadataFormData } from '../../types/metadata-form-data';
import {
Converter,
MetadataFormExtension,
@ -25,7 +23,7 @@ export class ExtensionFieldComponent<T>
extends FormComponentSuperclass<T>
implements Validator, OnChanges, OnInit
{
@Input() data: MetadataFormData<ThriftType>;
@Input() data: ThriftData<ThriftType>;
@Input() extensions: MetadataFormExtension[];
control = new FormControl<T>(null);
@ -47,7 +45,7 @@ export class ExtensionFieldComponent<T>
.join(', ');
}
private data$ = new ReplaySubject<MetadataFormData>(1);
private data$ = new ReplaySubject<ThriftData>(1);
private extensions$ = new ReplaySubject<MetadataFormExtension[]>(1);
private converter$: Observable<Converter> = this.extensionResult$.pipe(
map(

View File

@ -7,6 +7,7 @@ import {
createControlProviders,
getValueChanges,
} from '@vality/ng-core';
import { getValueTypeTitle, ThriftData, getAliases } from '@vality/ng-thrift';
import { ThriftType } from '@vality/thrift-ts';
import { combineLatest, defer, ReplaySubject, switchMap, Observable } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';
@ -14,11 +15,8 @@ import { map, shareReplay } from 'rxjs/operators';
import {
MetadataFormExtensionResult,
MetadataFormExtension,
getAliases,
} from '@cc/app/shared/components/metadata-form';
import { getValueTypeTitle } from '../../../../pipes';
import { MetadataFormData } from '../../types/metadata-form-data';
import { getExtensionsResult } from '../../types/metadata-form-extension';
@Component({
@ -31,7 +29,7 @@ export class PrimitiveFieldComponent<T>
extends FormControlSuperclass<T>
implements OnChanges, OnInit
{
@Input() data: MetadataFormData<ThriftType>;
@Input() data: ThriftData<ThriftType>;
@Input() extensions: MetadataFormExtension[];
extensionResult$: Observable<MetadataFormExtensionResult> = combineLatest([
@ -95,7 +93,7 @@ export class PrimitiveFieldComponent<T>
}
}
private data$ = new ReplaySubject<MetadataFormData<ThriftType>>(1);
private data$ = new ReplaySubject<ThriftData<ThriftType>>(1);
private extensions$ = new ReplaySubject<MetadataFormExtension[]>(1);
constructor(private destroyRef: DestroyRef) {

View File

@ -14,12 +14,12 @@ import {
getValueChanges,
getErrorsTree,
} from '@vality/ng-core';
import { ThriftData, isRequiredField } from '@vality/ng-thrift';
import isNil from 'lodash-es/isNil';
import omitBy from 'lodash-es/omitBy';
import { combineLatest } from 'rxjs';
import { map, distinctUntilChanged } from 'rxjs/operators';
import { MetadataFormData, isRequiredField } from '../../types/metadata-form-data';
import { MetadataFormExtension } from '../../types/metadata-form-extension';
@Component({
@ -31,7 +31,7 @@ export class StructFormComponent<T extends { [N in string]: unknown }>
extends FormComponentSuperclass<T>
implements OnChanges, OnInit
{
@Input() data: MetadataFormData<string, 'struct'>;
@Input() data: ThriftData<string, 'struct'>;
@Input() extensions: MetadataFormExtension[];
control: FormGroup = this.fb.group<T>({} as T);

View File

@ -1,15 +1,14 @@
import { Component, Input } from '@angular/core';
import { createControlProviders, FormControlSuperclass } from '@vality/ng-core';
import { ThriftData } from '@vality/ng-thrift';
import { MetadataFormData } from '../../types/metadata-form-data';
import { MetadataFormExtension } from '../../types/metadata-form-extension';
@Component({
selector: 'cc-typedef-form',
templateUrl: './typedef-form.component.html',
providers: createControlProviders(() => TypedefFormComponent),
})
export class TypedefFormComponent<T> extends FormControlSuperclass<T> {
@Input() data: MetadataFormData<string, 'typedef'>;
@Input() data: ThriftData<string, 'typedef'>;
@Input() extensions: MetadataFormExtension[];
}

View File

@ -7,13 +7,13 @@ import {
getErrorsTree,
ComponentChanges,
} from '@vality/ng-core';
import { getFieldLabel, ThriftData } from '@vality/ng-thrift';
import { Field } from '@vality/thrift-ts';
import { merge, ReplaySubject, defer } from 'rxjs';
import { delay, distinctUntilChanged, map, shareReplay } from 'rxjs/operators';
import { MetadataFormData } from '../../types/metadata-form-data';
import { MetadataFormExtension } from '../../types/metadata-form-extension';
import { getFieldLabel, getDefaultValue } from '../../utils';
import { getDefaultValue } from '../../utils';
@Component({
selector: 'cc-union-field',
@ -24,7 +24,7 @@ export class UnionFieldComponent<T extends { [N in string]: unknown }>
extends FormComponentSuperclass<T>
implements OnInit, Validator, OnChanges
{
@Input() data: MetadataFormData<string, 'union'>;
@Input() data: ThriftData<string, 'union'>;
@Input() extensions: MetadataFormExtension[];
fieldControl = new FormControl() as FormControl<Field>;
@ -39,7 +39,7 @@ export class UnionFieldComponent<T extends { [N in string]: unknown }>
shareReplay({ refCount: true, bufferSize: 1 }),
);
private data$ = new ReplaySubject<MetadataFormData<string, 'union'>>(1);
private data$ = new ReplaySubject<ThriftData<string, 'union'>>(1);
constructor(private destroyRef: DestroyRef) {
super();

View File

@ -1,5 +1,4 @@
export * from './metadata-form.module';
export * from './types/metadata-form-data';
export * from './thrift-form.module';
export { MetadataFormExtension } from './types/metadata-form-extension';
export { MetadataFormExtensionResult } from './types/metadata-form-extension';
export { MetadataFormExtensionOption } from './types/metadata-form-extension';

View File

@ -1,8 +1,7 @@
import { Pipe, PipeTransform } from '@angular/core';
import { getFieldLabel } from '@vality/ng-thrift';
import { ValueType, Field } from '@vality/thrift-ts';
import { getFieldLabel } from '../utils';
@Pipe({
name: 'fieldLabel',
})

View File

@ -3,11 +3,11 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Validator } from '@angular/forms';
import { ThriftAstMetadata } from '@vality/domain-proto';
import { createControlProviders, FormControlSuperclass } from '@vality/ng-core';
import { ThriftData } from '@vality/ng-thrift';
import { Field, ValueType } from '@vality/thrift-ts';
import { Observable, BehaviorSubject, defer, switchMap } from 'rxjs';
import { map, distinctUntilChanged, shareReplay } from 'rxjs/operators';
import { MetadataFormData } from './types/metadata-form-data';
import {
MetadataFormExtension,
MetadataFormExtensionResult,
@ -16,11 +16,11 @@ import {
@Component({
selector: 'cc-metadata-form',
templateUrl: './metadata-form.component.html',
styleUrl: `./metadata-form.component.scss`,
providers: createControlProviders(() => MetadataFormComponent),
templateUrl: './thrift-form.component.html',
styleUrl: `./thrift-form.component.scss`,
providers: createControlProviders(() => ThriftFormComponent),
})
export class MetadataFormComponent<T>
export class ThriftFormComponent<T>
extends FormControlSuperclass<T>
implements OnInit, OnChanges, Validator
{
@ -28,12 +28,12 @@ export class MetadataFormComponent<T>
@Input() namespace: string;
@Input() type: ValueType;
@Input() field?: Field;
@Input() parent?: MetadataFormData;
@Input() parent?: ThriftData;
@Input() extensions?: MetadataFormExtension[];
@HostBinding('class.cc-metadata-form-hidden') hidden = false;
data: MetadataFormData;
data: ThriftData;
extensionResult$: Observable<MetadataFormExtensionResult> = defer(() => this.updated$).pipe(
switchMap(() => getExtensionsResult(this.extensions, this.data)),
shareReplay({ refCount: true, bufferSize: 1 }),
@ -61,7 +61,7 @@ export class MetadataFormComponent<T>
ngOnChanges() {
if (this.metadata && this.namespace && this.type) {
try {
this.data = new MetadataFormData(
this.data = new ThriftData(
this.metadata,
this.namespace,
this.type,

View File

@ -20,10 +20,9 @@ import {
AutocompleteFieldModule,
TagModule,
} from '@vality/ng-core';
import { ThriftPipesModule, ValueTypeTitlePipe } from '@vality/ng-thrift';
import { JsonViewerModule } from '@cc/app/shared/components/json-viewer';
import { ThriftPipesModule } from '@cc/app/shared/pipes/thrift';
import { ValueTypeTitleModule } from '@cc/app/shared/pipes/value-type-title';
import { ComplexFormComponent } from './components/complex-form/complex-form.component';
import { EnumFieldComponent } from './components/enum-field/enum-field.component';
@ -32,8 +31,8 @@ import { PrimitiveFieldComponent } from './components/primitive-field/primitive-
import { StructFormComponent } from './components/struct-form/struct-form.component';
import { TypedefFormComponent } from './components/typedef-form/typedef-form.component';
import { UnionFieldComponent } from './components/union-field/union-field.component';
import { MetadataFormComponent } from './metadata-form.component';
import { FieldLabelPipe } from './pipes/field-label.pipe';
import { ThriftFormComponent } from './thrift-form.component';
@NgModule({
imports: [
@ -50,7 +49,7 @@ import { FieldLabelPipe } from './pipes/field-label.pipe';
OverlayModule,
MatCardModule,
MatExpansionModule,
ValueTypeTitleModule,
ValueTypeTitlePipe,
MatCheckboxModule,
MatChipsModule,
MatRadioModule,
@ -61,7 +60,7 @@ import { FieldLabelPipe } from './pipes/field-label.pipe';
TagModule,
],
declarations: [
MetadataFormComponent,
ThriftFormComponent,
PrimitiveFieldComponent,
ComplexFormComponent,
StructFormComponent,
@ -71,6 +70,6 @@ import { FieldLabelPipe } from './pipes/field-label.pipe';
FieldLabelPipe,
ExtensionFieldComponent,
],
exports: [MetadataFormComponent],
exports: [ThriftFormComponent],
})
export class MetadataFormModule {}
export class ThriftFormModule {}

View File

@ -1,145 +0,0 @@
import { ThriftAstMetadata } from '@vality/domain-proto';
import { Field, ValueType } from '@vality/thrift-ts';
import { JsonAST } from '@vality/thrift-ts/src/thrift-parser';
import { ValuesType } from 'utility-types';
import {
isComplexType,
isPrimitiveType,
parseNamespaceObjectType,
parseNamespaceType,
StructureType,
} from '@cc/utils/thrift-instance';
export enum TypeGroup {
Complex = 'complex',
Primitive = 'primitive',
Object = 'object',
}
export function getAliases(data: MetadataFormData): MetadataFormData[] {
let alias: MetadataFormData = data?.parent;
const path: MetadataFormData[] = [];
while (alias && alias.objectType === 'typedef' && alias.parent) {
path.push(alias);
alias = alias?.parent;
}
return path;
}
export function getByType(
data: MetadataFormData,
type: string,
namespace: string,
): MetadataFormData {
return data
? [data, ...getAliases(data)].find((d) => d.type === type && d.namespace === namespace)
: null;
}
export function isTypeWithAliases(
data: MetadataFormData,
type: string,
namespace: string,
): boolean {
return Boolean(getByType(data, type, namespace));
}
export function isRequiredField(field: Field): boolean {
return field?.option === 'required'; // optional even if not explicitly stated
}
export class MetadataFormData<
T extends ValueType = ValueType,
S extends StructureType = StructureType,
> {
typeGroup: TypeGroup;
namespace: string;
type: T;
objectType?: S;
ast?: ValuesType<JsonAST[S]>;
include?: JsonAST['include'];
/**
* Parent who is not typedef
*/
get trueParent() {
let data: MetadataFormData = this.parent;
while (data?.objectType === 'typedef') {
data = data.parent;
}
return data;
}
/**
* Path to the object without aliases
*/
get trueTypeNode() {
const typedefs: MetadataFormData<ValueType, 'typedef'>[] = [];
let currentData: MetadataFormData = this as never;
while (currentData.objectType === 'typedef') {
typedefs.push(currentData as never);
currentData = currentData.create({
type: (currentData as MetadataFormData<ValueType, 'typedef'>).ast.type,
});
}
return { data: currentData, typedefs };
}
get isRequired() {
return isRequiredField(this.field) || this.trueParent?.objectType === 'union';
}
constructor(
public metadata: ThriftAstMetadata[],
namespace: string,
type: T,
public field?: Field,
public parent?: MetadataFormData,
) {
this.setNamespaceType(namespace, type);
this.setTypeGroup();
if (this.typeGroup === TypeGroup.Object) {
this.setNamespaceObjectType();
}
}
create(params: { type?: ValueType; field?: Field }): MetadataFormData {
return new MetadataFormData(
this.metadata,
this.namespace,
params.type ?? params.field?.type,
params.field,
this as never,
);
}
private setNamespaceType(namespace: string, type: T) {
const namespaceType = parseNamespaceType(type, namespace);
this.namespace = namespaceType.namespace;
this.type = namespaceType.type;
}
private setTypeGroup(type: ValueType = this.type) {
this.typeGroup = isComplexType(type)
? TypeGroup.Complex
: isPrimitiveType(this.type)
? TypeGroup.Primitive
: TypeGroup.Object;
}
private setNamespaceObjectType() {
const { namespaceMetadata, objectType, include } = parseNamespaceObjectType(
this.metadata,
this.namespace,
this.type as string,
this.parent?.include,
);
this.objectType = objectType as never;
this.ast = (namespaceMetadata.ast[this.objectType] as unknown)[this.type] as never;
this.include = include;
}
}

View File

@ -1,13 +1,12 @@
import { TemplateRef } from '@angular/core';
import { ThemePalette } from '@angular/material/core';
import { ThriftData } from '@vality/ng-thrift';
import { Observable, combineLatest, switchMap, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { MetadataFormData } from './metadata-form-data';
export type MetadataFormExtension = {
determinant: (data: MetadataFormData) => Observable<boolean>;
extension: (data: MetadataFormData) => Observable<MetadataFormExtensionResult>;
determinant: (data: ThriftData) => Observable<boolean>;
extension: (data: ThriftData) => Observable<MetadataFormExtensionResult>;
};
export interface Converter<O = unknown, I = O> {
@ -35,7 +34,7 @@ export interface MetadataFormExtensionOption {
export function getExtensionsResult(
sourceExtensions: MetadataFormExtension[],
data: MetadataFormData,
data: ThriftData,
): Observable<MetadataFormExtensionResult> {
return sourceExtensions?.length
? combineLatest(sourceExtensions.map(({ determinant }) => determinant(data))).pipe(

View File

@ -1,16 +1,15 @@
import { ThriftAstMetadata } from '@vality/domain-proto';
import { ThriftData, TypeGroup } from '@vality/ng-thrift';
import { ValueType } from '@vality/thrift-ts';
import { TypeDefs } from '@vality/thrift-ts/src/thrift-parser';
import { MetadataFormData, TypeGroup } from '../types/metadata-form-data';
export function getDefaultValue(metadata: ThriftAstMetadata[], namespace: string, type: ValueType) {
if (!type) {
return null;
}
let data: MetadataFormData;
let data: ThriftData;
do {
data = new MetadataFormData(metadata, namespace, type);
data = new ThriftData(metadata, namespace, type);
type = (data.ast as TypeDefs[string])?.type;
} while (data.objectType === 'typedef');
switch (data.typeGroup) {

View File

@ -1,8 +0,0 @@
import { Field, ValueType } from '@vality/thrift-ts';
import startCase from 'lodash-es/startCase';
import { getValueTypeTitle } from '../../../pipes';
export function getFieldLabel(type: ValueType, field?: Field) {
return type ? startCase((field ? field.name : getValueTypeTitle(type)).toLowerCase()) : '';
}

View File

@ -1,2 +1 @@
export * from './get-field-label';
export * from './get-default-value';

View File

@ -7,8 +7,7 @@ import { MatToolbar } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { RouterLink } from '@angular/router';
import { ActionsModule, TagModule } from '@vality/ng-core';
import { ThriftPipesModule } from '../../pipes';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { PageLayoutActionsComponent } from './components/page-layout-actions/page-layout-actions.component';
import { PageLayoutComponent } from './page-layout.component';

View File

@ -6,7 +6,7 @@
</div>
<ng-container
*ngIf="(payoutTool.payout_tool_info | ccUnionKey) === 'international_bank_account'"
*ngIf="(payoutTool.payout_tool_info | ngtUnionKey) === 'international_bank_account'"
>
<h2 class="mat-h3">International bank account</h2>
<cc-international-bank-account-details
@ -26,14 +26,14 @@
</ng-container>
</ng-container>
<ng-container *ngIf="(payoutTool.payout_tool_info | ccUnionKey) === 'russian_bank_account'">
<ng-container *ngIf="(payoutTool.payout_tool_info | ngtUnionKey) === 'russian_bank_account'">
<h2 class="mat-h3">Russian bank account</h2>
<cc-russian-bank-account-details
[russianBankAccount]="payoutTool.payout_tool_info.russian_bank_account"
></cc-russian-bank-account-details>
</ng-container>
<ng-container *ngIf="(payoutTool.payout_tool_info | ccUnionKey) === 'wallet_info'">
<ng-container *ngIf="(payoutTool.payout_tool_info | ngtUnionKey) === 'wallet_info'">
<h2 class="mat-h3">Wallet</h2>
<cc-details-item title="Wallet ID">{{
payoutTool.payout_tool_info.wallet_info.wallet_id
@ -41,7 +41,7 @@
</ng-container>
<ng-container
*ngIf="(payoutTool.payout_tool_info | ccUnionKey) === 'payment_institution_account'"
*ngIf="(payoutTool.payout_tool_info | ngtUnionKey) === 'payment_institution_account'"
>
<h2 class="mat-h3">Payment institution account</h2>
</ng-container>

View File

@ -1,7 +1,7 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ThriftPipesModule } from '@vality/ng-thrift';
import { ThriftPipesModule } from '@cc/app/shared/pipes';
import { DetailsItemModule } from '@cc/components/details-item';
import { InternationalBankAccountDetailsComponent } from './components/international-bank-account-details/international-bank-account-details.component';

View File

@ -15,12 +15,12 @@ import {
DialogResponseStatus,
ComponentChanges,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { map, switchMap, Subject, defer, combineLatest } from 'rxjs';
import { filter, shareReplay, startWith, take, first } from 'rxjs/operators';
import { MemoizeExpiring } from 'typescript-memoize';
import { getUnionKey } from '../../../../utils';
import { DomainStoreService } from '../../../api/domain-config';
import { PartyManagementService } from '../../../api/payment-processing';
import { PartyDelegateRulesetsService } from '../../../sections/routing-rules/party-delegate-rulesets';

View File

@ -1,8 +1,7 @@
import { Pipe, PipeTransform } from '@angular/core';
import { getUnionKey } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { getUnionKey } from '@cc/utils/get-union-key';
@Pipe({
name: 'toStatus',
})

View File

@ -2,11 +2,11 @@ import { CommonModule } from '@angular/common';
import { Component, Input, OnChanges } from '@angular/core';
import { TerminalRef } from '@vality/domain-proto/domain';
import { ComponentChanges, TableModule, Column } from '@vality/ng-core';
import { getUnionKey, getUnionValue } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { ReplaySubject, defer, switchMap } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';
import { getUnionKey, getUnionValue } from '../../../../utils';
import { DomainStoreService } from '../../../api/domain-config';
import { PartiesStoreService } from '../../../api/payment-processing';
import {

View File

@ -13,11 +13,11 @@ import {
progressTo,
NotifyLogService,
} from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift';
import { BehaviorSubject, switchMap, EMPTY } from 'rxjs';
import { first, map, catchError } from 'rxjs/operators';
import { ValuesType } from 'utility-types';
import { getUnionKey } from '../../../../../../utils';
import { DomainStoreService } from '../../../../../api/domain-config';
import { DomainNavigateService } from '../../../../../sections/domain/services/domain-navigate.service';
import { MetadataService } from '../../../../../sections/domain/services/metadata.service';

View File

@ -5,11 +5,11 @@ import { MatButtonModule } from '@angular/material/button';
import { Router } from '@angular/router';
import { Reference } from '@vality/domain-proto/internal/domain';
import { ComponentChanges, DialogService } from '@vality/ng-core';
import { isEqualThrift } from '@vality/ng-thrift';
import { combineLatest, ReplaySubject, switchMap } from 'rxjs';
import { map, shareReplay, first } from 'rxjs/operators';
import { DomainStoreService } from '@cc/app/api/domain-config';
import { isEqualThrift } from '@cc/utils';
import { SidenavInfoModule } from '../../../sidenav-info';
import { CardComponent } from '../../../sidenav-info/components/card/card.component';

View File

@ -10,7 +10,7 @@ import { combineLatest, filter } from 'rxjs';
import { shareReplay, startWith, map } from 'rxjs/operators';
import { DomainMetadataFormExtensionsService } from '../../../../services';
import { MetadataFormModule } from '../../../metadata-form';
import { ThriftFormModule } from '../../../metadata-form';
import { ThriftEditorModule } from '../../../thrift-editor';
import { BaseThriftFormSuperclass } from '../../thrift-forms/utils/thrift-form-superclass';
@ -19,7 +19,7 @@ import { BaseThriftFormSuperclass } from '../../thrift-forms/utils/thrift-form-s
selector: 'cc-domain-thrift-form',
templateUrl: './domain-thrift-form.component.html',
providers: createControlProviders(() => DomainThriftFormComponent),
imports: [CommonModule, ReactiveFormsModule, MetadataFormModule, ThriftEditorModule],
imports: [CommonModule, ReactiveFormsModule, ThriftFormModule, ThriftEditorModule],
})
export class DomainThriftFormComponent extends BaseThriftFormSuperclass {
party = input<Party>();

View File

@ -6,6 +6,7 @@ import { DomainObject } from '@vality/domain-proto/domain';
import { Rational, Timestamp } from '@vality/domain-proto/internal/base';
import { PartyID, ShopID } from '@vality/domain-proto/internal/domain';
import { getImportValue } from '@vality/ng-core';
import { getUnionValue, isTypeWithAliases, ThriftData } from '@vality/ng-thrift';
import isEqual from 'lodash-es/isEqual';
import round from 'lodash-es/round';
import { of, Observable } from 'rxjs';
@ -13,9 +14,7 @@ import { map, shareReplay } from 'rxjs/operators';
import { DomainStoreService } from '@cc/app/api/domain-config';
import { MetadataViewExtension } from '@cc/app/shared/components/json-viewer';
import { isTypeWithAliases, MetadataFormData } from '@cc/app/shared/components/metadata-form';
import { getUnionValue } from '../../../../../../../../utils';
import { PartiesStoreService } from '../../../../../../../api/payment-processing';
import { SidenavInfoService } from '../../../../../sidenav-info';
import { getDomainObjectDetails } from '../../../utils';
@ -94,14 +93,11 @@ export class DomainMetadataViewExtensionsService {
}
createDomainObjectExtensions(metadata: ThriftAstMetadata[]): MetadataViewExtension[] {
const domainFields = new MetadataFormData<string, 'struct'>(
metadata,
'domain',
'DomainObject',
).ast;
const domainFields = new ThriftData<string, 'struct'>(metadata, 'domain', 'DomainObject')
.ast;
return domainFields.map((f) => {
const objectKey = f.name as keyof DomainObject;
const objectFields = new MetadataFormData<string, 'struct'>(
const objectFields = new ThriftData<string, 'struct'>(
metadata,
'domain',
f.type as string,

View File

@ -15,15 +15,14 @@ import {
progressTo,
inProgressFrom,
} from '@vality/ng-core';
import { isEqualThrift, getUnionKey, getUnionValue, ThriftPipesModule } from '@vality/ng-thrift';
import { BehaviorSubject, switchMap, EMPTY, combineLatest, Observable } from 'rxjs';
import { first, map, shareReplay, catchError, distinctUntilChanged } from 'rxjs/operators';
import { ValuesType } from 'utility-types';
import { getUnionKey, getUnionValue, isEqualThrift } from '../../../../../../utils';
import { DomainStoreService } from '../../../../../api/domain-config';
import { DomainNavigateService } from '../../../../../sections/domain/services/domain-navigate.service';
import { MetadataService } from '../../../../../sections/domain/services/metadata.service';
import { ThriftPipesModule } from '../../../../pipes';
import { DomainSecretService } from '../../../../services';
import { DomainThriftFormComponent } from '../domain-thrift-form';
import { DomainThriftViewerComponent } from '../domain-thrift-viewer';

View File

@ -1,10 +1,9 @@
import { DomainObject } from '@vality/domain-proto/domain';
import { inlineJson } from '@vality/ng-core';
import { getUnionKey, getUnionValue } from '@vality/ng-thrift';
import startCase from 'lodash-es/startCase';
import { PickByValue, ValuesType } from 'utility-types';
import { getUnionKey, getUnionValue } from '../../../../../../utils';
export interface DomainObjectDetails {
id: number | string;
label: string;

View File

@ -4,7 +4,7 @@ import { ReactiveFormsModule } from '@angular/forms';
import { ThriftAstMetadata } from '@vality/fistful-proto';
import { createControlProviders, getImportValue } from '@vality/ng-core';
import { MetadataFormModule } from '../../../metadata-form';
import { ThriftFormModule } from '../../../metadata-form';
import { ThriftEditorModule } from '../../../thrift-editor';
import { BaseThriftFormSuperclass } from '../../thrift-forms/utils/thrift-form-superclass';
@ -13,7 +13,7 @@ import { BaseThriftFormSuperclass } from '../../thrift-forms/utils/thrift-form-s
selector: 'cc-magista-thrift-form',
templateUrl: './magista-thrift-form.component.html',
providers: createControlProviders(() => MagistaThriftFormComponent),
imports: [CommonModule, ReactiveFormsModule, MetadataFormModule, ThriftEditorModule],
imports: [CommonModule, ReactiveFormsModule, ThriftFormModule, ThriftEditorModule],
})
export class MagistaThriftFormComponent extends BaseThriftFormSuperclass {
metadata$ = getImportValue<ThriftAstMetadata[]>(import('@vality/magista-proto/metadata.json'));

View File

@ -8,11 +8,10 @@ import {
createControlProviders,
FormControlSuperclass,
} from '@vality/ng-core';
import { toJson } from '@vality/ng-thrift';
import { merge, defer, of, Subject } from 'rxjs';
import { map, filter, shareReplay } from 'rxjs/operators';
import { objectToJSON } from '@cc/utils/thrift-instance';
import { MetadataFormExtension } from '../metadata-form';
export enum EditorKind {
@ -102,6 +101,6 @@ export class ThriftEditorComponent<T> extends FormControlSuperclass<T> {
}
private createMonacoContent(value: unknown): string {
return JSON.stringify(objectToJSON(value), null, 2);
return JSON.stringify(toJson(value), null, 2);
}
}

View File

@ -8,7 +8,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
import { PipesModule } from '@vality/ng-core';
import { MonacoEditorModule } from 'ngx-monaco-editor-v2';
import { MetadataFormModule } from '@cc/app/shared/components/metadata-form';
import { ThriftFormModule } from '@cc/app/shared/components/metadata-form';
import { ThriftEditorComponent } from './thrift-editor.component';
@ -17,7 +17,7 @@ import { ThriftEditorComponent } from './thrift-editor.component';
exports: [ThriftEditorComponent],
imports: [
CommonModule,
MetadataFormModule,
ThriftFormModule,
ReactiveFormsModule,
MonacoEditorModule,
MatButtonToggleModule,

Some files were not shown because too many files have changed in this diff Show More