diff --git a/.prettierignore b/.prettierignore index c995ccf6..efda5d86 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,10 +1,24 @@ +LICENSE + +.idea +.vscode + package.json package-lock.json node_modules -dist -src/assets/icons/ +.npmrc + .angular -LICENSE +.run +dist + Dockerfile *.conf + +.*ignore *.env + +*.ico +*.ttf + +src/assets/icons/ diff --git a/.prettierrc.js b/.prettierrc.js index 3cee9524..9f81c84c 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1 +1 @@ -module.exports = require("@vality/prettier-config"); +module.exports = require('@vality/prettier-config'); diff --git a/package-lock.json b/package-lock.json index fa164eb4..382932c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "@vality/dominant-cache-proto": "2.0.0", "@vality/fistful-proto": "2.0.1-ed97a0e.0", "@vality/magista-proto": "2.0.2-37b81e6.0", - "@vality/ng-core": "16.2.1-pr-40-bdc62db.0", + "@vality/ng-core": "16.2.1-pr-40-c4e5174.0", "@vality/payout-manager-proto": "2.0.0", "@vality/repairer-proto": "2.0.2-f5e3b7a.0", "@vality/thrift-ts": "2.4.1-8ad5123.0", @@ -37,6 +37,7 @@ "coerce-property": "15.0.1", "css-element-queries": "1.2.3", "date-fns": "2.30.0", + "fuse.js": "6.6.2", "humanize-duration": "3.21.0", "inputmask": "5.0.7", "keycloak-angular": "14.0.0", @@ -66,8 +67,8 @@ "@types/lodash-es": "4.17.6", "@types/papaparse": "5.3.7", "@vality/cspell-config": "7.0.1-pr-33-8e9a771.0", - "@vality/eslint-config": "8.0.1-pr-33-541079b.0", - "@vality/prettier-config": "3.0.1-pr-33-1086ab7.0", + "@vality/eslint-config": "8.1.1-pr-40-c4e5174.0", + "@vality/prettier-config": "3.0.1-pr-40-c4e5174.0", "cross-env": "7.0.3", "cspell": "^7.0.0", "eslint": "^8.39.0", @@ -79,7 +80,7 @@ "karma-coverage-istanbul-reporter": "3.0.3", "karma-jasmine": "5.1.0", "karma-jasmine-html-reporter": "2.0.0", - "prettier": "3.0.1", + "prettier": "3.0.3", "typescript": "~5.0.4", "typescript-memoize": "1.1.1" } @@ -5783,9 +5784,9 @@ "integrity": "sha512-Jxo7n8/2xo8D/y7g0v1iFjr5MijOYmJ0hiHNTqoj/D0elzRhHAeRBur9F8h4RDf6sd2/+FmtVlprc7+q0/AGig==" }, "node_modules/@vality/eslint-config": { - "version": "8.0.1-pr-33-541079b.0", - "resolved": "https://registry.npmjs.org/@vality/eslint-config/-/eslint-config-8.0.1-pr-33-541079b.0.tgz", - "integrity": "sha512-FvkI4bhsfWjJYmpw0lFPqajxlA4cNNDvoIRaelkJcr70iEq1xIol+vYHqvqV8jEc8z0W3xrApseSFOxjTMzMnw==", + "version": "8.1.1-pr-40-c4e5174.0", + "resolved": "https://registry.npmjs.org/@vality/eslint-config/-/eslint-config-8.1.1-pr-40-c4e5174.0.tgz", + "integrity": "sha512-nKOHesoVfatRqdmZUk7S6qm3zs41BxDQam768QAiS81k6rQ52sQwdOZgJYFGm36r2fvokb1KxEnSrIRfqY8U+g==", "dev": true, "dependencies": { "@angular-eslint/eslint-plugin": "^16.1.0", @@ -6000,9 +6001,9 @@ "integrity": "sha512-gJizpTWuB74L+XuJ+dUaxAwJDkycdnuVwrXWIl/NKcS7++/zgrgTpw+tM5/Te3rWqkkCnSxC1SK0C4aPbbtifg==" }, "node_modules/@vality/ng-core": { - "version": "16.2.1-pr-40-bdc62db.0", - "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-40-bdc62db.0.tgz", - "integrity": "sha512-hw7ljBUP1X1WYt6ZEQZ2E+y0Udy7G5pUNWL1wUIMmexaXr5H21NTuRZRgy9u3zfxrYfNnLmmI1XZgLfZry/gkA==", + "version": "16.2.1-pr-40-c4e5174.0", + "resolved": "https://registry.npmjs.org/@vality/ng-core/-/ng-core-16.2.1-pr-40-c4e5174.0.tgz", + "integrity": "sha512-gIJrzmrS+vxSdo+0F66imWNZdf7hC5tA74Le3glQSsbr9ZhmldYaBE5559a3VWCwF4VITrADCGBV3tt2nxjM/Q==", "dependencies": { "@ng-matero/extensions": "^16.0.0", "@s-libs/js-core": "^16.0.0", @@ -6032,9 +6033,9 @@ "integrity": "sha512-eBR/QJQObjfRQPOSR29vafvvfYVaAvrKJGYVxGo7j4ZWWf9KWDlR4cipixNnZyZ/esLNX2fdqebWbfogrOBdSA==" }, "node_modules/@vality/prettier-config": { - "version": "3.0.1-pr-33-1086ab7.0", - "resolved": "https://registry.npmjs.org/@vality/prettier-config/-/prettier-config-3.0.1-pr-33-1086ab7.0.tgz", - "integrity": "sha512-TurfC2o3w8owbXTC9KTTZef0dlr4EX7l3pfcA8Ubht9lf4YmPiTs86sicMcwQaeyfTKWQExfnsSw99JG90DAAQ==", + "version": "3.0.1-pr-40-c4e5174.0", + "resolved": "https://registry.npmjs.org/@vality/prettier-config/-/prettier-config-3.0.1-pr-40-c4e5174.0.tgz", + "integrity": "sha512-1w5LgPbZxc4j3tam7RIA6NKLNabCI/BWsrx3gSiWVTZfEWSOl43e7UBLv+Mq+Bc/8gdvl1eNNRRjvGkJU82Brw==", "dev": true, "dependencies": { "prettier-plugin-organize-attributes": "^1.0.0" @@ -13360,6 +13361,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/fuse.js": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz", + "integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==", + "engines": { + "node": ">=10" + } + }, "node_modules/gauge": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", @@ -18549,9 +18558,9 @@ } }, "node_modules/prettier": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.1.tgz", - "integrity": "sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", + "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" diff --git a/package.json b/package.json index 5fec82bb..d6dd923d 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "test": "ng test", "lint": "ng lint --max-warnings=0", "lint:fix": "ng lint --fix", - "format": "prettier * --list-different", - "format:fix": "prettier * --write --loglevel warn", + "format": "prettier ** --list-different", + "format:fix": "prettier ** --write --log-level=warn", "spell": "cspell --no-progress **", "spell:fix": "cspell --no-progress --show-suggestions --show-context **", "fix": "npm run lint:fix && npm run format:fix" @@ -37,7 +37,7 @@ "@vality/dominant-cache-proto": "2.0.0", "@vality/fistful-proto": "2.0.1-ed97a0e.0", "@vality/magista-proto": "2.0.2-37b81e6.0", - "@vality/ng-core": "16.2.1-pr-40-bdc62db.0", + "@vality/ng-core": "16.2.1-pr-40-c4e5174.0", "@vality/payout-manager-proto": "2.0.0", "@vality/repairer-proto": "2.0.2-f5e3b7a.0", "@vality/thrift-ts": "2.4.1-8ad5123.0", @@ -45,6 +45,7 @@ "coerce-property": "15.0.1", "css-element-queries": "1.2.3", "date-fns": "2.30.0", + "fuse.js": "6.6.2", "humanize-duration": "3.21.0", "inputmask": "5.0.7", "keycloak-angular": "14.0.0", @@ -74,8 +75,8 @@ "@types/lodash-es": "4.17.6", "@types/papaparse": "5.3.7", "@vality/cspell-config": "7.0.1-pr-33-8e9a771.0", - "@vality/eslint-config": "8.0.1-pr-33-541079b.0", - "@vality/prettier-config": "3.0.1-pr-33-1086ab7.0", + "@vality/eslint-config": "8.1.1-pr-40-c4e5174.0", + "@vality/prettier-config": "3.0.1-pr-40-c4e5174.0", "cross-env": "7.0.3", "cspell": "^7.0.0", "eslint": "^8.39.0", @@ -87,7 +88,7 @@ "karma-coverage-istanbul-reporter": "3.0.3", "karma-jasmine": "5.1.0", "karma-jasmine-html-reporter": "2.0.0", - "prettier": "3.0.1", + "prettier": "3.0.3", "typescript": "~5.0.4", "typescript-memoize": "1.1.1" } diff --git a/src/app/api/deprecated-damsel/index.ts b/src/app/api/deprecated-damsel/index.ts deleted file mode 100644 index 1f35a68a..00000000 --- a/src/app/api/deprecated-damsel/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './domain-store.service'; diff --git a/src/app/api/domain-config/index.ts b/src/app/api/domain-config/index.ts index 0cadf132..d7e13642 100644 --- a/src/app/api/domain-config/index.ts +++ b/src/app/api/domain-config/index.ts @@ -1 +1,2 @@ export * from './repository.service'; +export * from './stores/domain-store.service'; diff --git a/src/app/api/deprecated-damsel/domain-store.service.ts b/src/app/api/domain-config/stores/domain-store.service.ts similarity index 83% rename from src/app/api/deprecated-damsel/domain-store.service.ts rename to src/app/api/domain-config/stores/domain-store.service.ts index 91f62f44..012ef835 100644 --- a/src/app/api/deprecated-damsel/domain-store.service.ts +++ b/src/app/api/domain-config/stores/domain-store.service.ts @@ -5,12 +5,11 @@ import { Commit, Snapshot, Version } from '@vality/domain-proto/domain_config'; import { BehaviorSubject, defer, Observable, of, ReplaySubject } from 'rxjs'; import { map, pluck, shareReplay, startWith, switchMap, take, tap } from 'rxjs/operators'; -import { RepositoryService } from '@cc/app/api/domain-config'; -import { DomainSecretService } from '@cc/app/shared/services/domain-secret-service'; -import { inProgressFrom, progressTo } from '@cc/utils'; -import { getUnionKey } from '@cc/utils/get-union-key'; - -import { handleError, NotificationErrorService } from '../../shared/services/notification-error'; +import { inProgressFrom, progressTo } from '../../../../utils'; +import { getUnionKey } from '../../../../utils/get-union-key'; +import { DomainSecretService } from '../../../shared/services/domain-secret-service'; +import { handleError, NotificationErrorService } from '../../../shared/services/notification-error'; +import { RepositoryService } from '../index'; @UntilDestroy() @Injectable({ @@ -68,7 +67,9 @@ export class DomainStoreService { return version$.pipe( switchMap((v) => this.repositoryService.Commit(v, commit)), tap(() => { - if (reload) this.forceReload(); + if (reload) { + this.forceReload(); + } }), ); } diff --git a/src/app/app.component.html b/src/app/app.component.html index 0ffb8d82..73740d31 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,4 @@ - Control Center {{ username }} @@ -7,14 +6,7 @@ - + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 03d94c23..169331bb 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -12,11 +12,10 @@ import { ROUTING_CONFIG as PAYOUTS_ROUTING_CONFIG } from './sections/payouts/pay import { ROUTING_CONFIG as REPAIRING_ROUTING_CONFIG } from './sections/repairing/routing-config'; import { ROUTING_CONFIG as PARTIES_ROUTING_CONFIG } from './sections/search-parties/routing-config'; import { ROUTING_CONFIG as SOURCES_ROUTING_CONFIG } from './sections/sources/routing-config'; +import { ROUTING_CONFIG as TERMINALS_ROUTING_CONFIG } from './sections/terminals'; import { ROUTING_CONFIG as WALLETS_ROUTING_CONFIG } from './sections/wallets/routing-config'; import { ROUTING_CONFIG as WITHDRAWALS_ROUTING_CONFIG } from './sections/withdrawals/routing-config'; -import { SidenavInfoService } from './shared/components/sidenav-info/sidenav-info.service'; - -const SIDENAV_OPENED_KEY = 'sidenav-opened'; +import { SidenavInfoService } from './shared/components/sidenav-info'; @Component({ selector: 'cc-root', @@ -27,13 +26,6 @@ export class AppComponent implements OnInit { username: string; menuItems: { name: string; route: string }[][] = []; - get opened(): boolean { - return localStorage.getItem(SIDENAV_OPENED_KEY) === String(true); - } - set opened(opened: boolean) { - localStorage.setItem(SIDENAV_OPENED_KEY, String(opened)); - } - constructor( private keycloakService: KeycloakService, private appAuthGuardService: AppAuthGuardService, @@ -59,6 +51,11 @@ export class AppComponent implements OnInit { route: '/domain', services: DOMAIN_ROUTING_CONFIG.services, }, + { + name: 'Terminals', + route: '/terminals', + services: TERMINALS_ROUTING_CONFIG.services, + }, { name: 'Repairing', route: '/repairing', diff --git a/src/app/sections/chargebacks/components/create-chargebacks-by-file-dialog/create-chargebacks-by-file-dialog.component.ts b/src/app/sections/chargebacks/components/create-chargebacks-by-file-dialog/create-chargebacks-by-file-dialog.component.ts index dd39783e..2d35ff0e 100644 --- a/src/app/sections/chargebacks/components/create-chargebacks-by-file-dialog/create-chargebacks-by-file-dialog.component.ts +++ b/src/app/sections/chargebacks/components/create-chargebacks-by-file-dialog/create-chargebacks-by-file-dialog.component.ts @@ -108,13 +108,19 @@ export class CreateChargebacksByFileDialogComponent parseCsv(content, { header: this.hasHeaderControl.value || false, delimiter: ';' }), ), tap((d) => { - if (!d.errors.length) return; - if (d.errors.length === 1) this.log.error(d.errors[0]); + if (!d.errors.length) { + return; + } + if (d.errors.length === 1) { + this.log.error(d.errors[0]); + } this.log.error(new Error(d.errors.map((e) => e.message).join('. '))); }), map((d) => { const chargebacks = unifyCsvItems(d?.data, CSV_CHARGEBACK_PROPS); - if (chargebacks[0].invoice_id) return chargebacks; + if (chargebacks[0].invoice_id) { + return chargebacks; + } this.log.error( 'Perhaps you incorrectly checked the checkbox to have or not a header (the first element does not have at least an invoice ID)', ); diff --git a/src/app/sections/claim/claim.component.ts b/src/app/sections/claim/claim.component.ts index cffef07e..805e811b 100644 --- a/src/app/sections/claim/claim.component.ts +++ b/src/app/sections/claim/claim.component.ts @@ -84,7 +84,9 @@ export class ClaimComponent { untilDestroyed(this), ) .subscribe((result) => { - if (result.status === DialogResponseStatus.Success) this.reloadClaim(); + if (result.status === DialogResponseStatus.Success) { + this.reloadClaim(); + } }); } @@ -100,7 +102,9 @@ export class ClaimComponent { untilDestroyed(this), ) .subscribe((result) => { - if (result.status === DialogResponseStatus.Success) this.reloadClaim(); + if (result.status === DialogResponseStatus.Success) { + this.reloadClaim(); + } }); } } diff --git a/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts b/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts index 30a825cf..1627047a 100644 --- a/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts +++ b/src/app/sections/claim/components/modification-unit-timeline-item/modification-unit-timeline-item.component.ts @@ -76,7 +76,9 @@ export class ModificationUnitTimelineItemComponent { untilDestroyed(this), ) .subscribe((result) => { - if (result.status === DialogResponseStatus.Success) this.claimChanged.emit(); + if (result.status === DialogResponseStatus.Success) { + this.claimChanged.emit(); + } }); } diff --git a/src/app/sections/claim/services/allowed-claim-statuses.service.ts b/src/app/sections/claim/services/allowed-claim-statuses.service.ts index 3797a97d..2f3969d6 100644 --- a/src/app/sections/claim/services/allowed-claim-statuses.service.ts +++ b/src/app/sections/claim/services/allowed-claim-statuses.service.ts @@ -28,8 +28,9 @@ export class AllowedClaimStatusesService { if ( excludedStatuses.includes(status) || !includedCurrentStatuses.includes(currentClaimStatus) - ) + ) { return false; + } return this.appAuthGuardService.userHasRoles(CLAIM_STATUS_ROLES[status]); } } diff --git a/src/app/sections/domain/domain-info/domain-group/domain-group.component.ts b/src/app/sections/domain/domain-info/domain-group/domain-group.component.ts index 3982a4bb..17110909 100644 --- a/src/app/sections/domain/domain-info/domain-group/domain-group.component.ts +++ b/src/app/sections/domain/domain-info/domain-group/domain-group.component.ts @@ -12,7 +12,7 @@ import startCase from 'lodash-es/startCase'; import { combineLatest, Observable, ReplaySubject, defer } from 'rxjs'; import { map, switchMap, startWith, shareReplay, withLatestFrom, filter } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { objectToJSON } from '@cc/utils/thrift-instance'; import { Columns } from '../../../../../components/table'; diff --git a/src/app/sections/domain/domain-info/domain-group/utils/sort-table-data.ts b/src/app/sections/domain/domain-info/domain-group/utils/sort-table-data.ts index 9c4f7461..113ee02a 100644 --- a/src/app/sections/domain/domain-info/domain-group/utils/sort-table-data.ts +++ b/src/app/sections/domain/domain-info/domain-group/utils/sort-table-data.ts @@ -26,6 +26,8 @@ export function sortData(data: DataSourceItem[], sort: MatSort): DataSourceItem[ break; } } - if (sort.direction === 'desc') return data.reverse(); + if (sort.direction === 'desc') { + return data.reverse(); + } return data; } diff --git a/src/app/sections/domain/domain-info/domain-info.component.ts b/src/app/sections/domain/domain-info/domain-info.component.ts index 0b97d1d0..1cf8dc59 100644 --- a/src/app/sections/domain/domain-info/domain-info.component.ts +++ b/src/app/sections/domain/domain-info/domain-info.component.ts @@ -12,7 +12,7 @@ import { import { from } from 'rxjs'; import { filter, switchMap } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { DomainMetadataViewExtensionsService } from '@cc/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions'; import { enumHasValue } from '../../../../utils'; diff --git a/src/app/sections/domain/domain-obj-creation/domain-obj-creation.component.ts b/src/app/sections/domain/domain-obj-creation/domain-obj-creation.component.ts index dcb248ae..29199710 100644 --- a/src/app/sections/domain/domain-obj-creation/domain-obj-creation.component.ts +++ b/src/app/sections/domain/domain-obj-creation/domain-obj-creation.component.ts @@ -5,7 +5,7 @@ import { DomainObject } from '@vality/domain-proto/domain'; import { BehaviorSubject } from 'rxjs'; import { withLatestFrom } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { DomainMetadataViewExtensionsService } from '@cc/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions'; import { progressTo, getUnionKey, enumHasValue } from '../../../../utils'; diff --git a/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts b/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts index e48edb12..0f17c0c6 100644 --- a/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts +++ b/src/app/sections/domain/domain-obj-modification/domain-obj-modification.component.ts @@ -62,9 +62,11 @@ export class DomainObjModificationComponent implements OnInit { if ( this.modifiedDomainObjectService.domainObject && this.route.snapshot.params.ref === this.modifiedDomainObjectService.ref - ) + ) { this.control.setValue(this.modifiedDomainObjectService.domainObject); - else this.control.setValue(object); + } else { + this.control.setValue(object); + } }); } diff --git a/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts b/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts index 47ff74c8..1db0ce83 100644 --- a/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts +++ b/src/app/sections/domain/domain-obj-review/domain-obj-review.component.ts @@ -4,7 +4,7 @@ import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy'; import { switchMap } from 'rxjs'; import { first, withLatestFrom } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { DomainSecretService } from '@cc/app/shared/services/domain-secret-service'; import { NotificationErrorService } from '@cc/app/shared/services/notification-error'; diff --git a/src/app/sections/domain/services/domain-obj-modification.service.ts b/src/app/sections/domain/services/domain-obj-modification.service.ts index 68dca77f..a9382da1 100644 --- a/src/app/sections/domain/services/domain-obj-modification.service.ts +++ b/src/app/sections/domain/services/domain-obj-modification.service.ts @@ -4,10 +4,11 @@ import { DomainObject, Reference } from '@vality/domain-proto/domain'; import { Observable, switchMap, BehaviorSubject, defer } from 'rxjs'; import { map, shareReplay, first } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel/domain-store.service'; import { NotificationErrorService } from '@cc/app/shared/services/notification-error'; import { toJson, getUnionValue, progressTo } from '@cc/utils'; +import { DomainStoreService } from '../../../api/domain-config/stores/domain-store.service'; + import { MetadataService } from './metadata.service'; @Injectable() diff --git a/src/app/sections/party-shops/party-shops.component.html b/src/app/sections/party-shops/party-shops.component.html index 93df1d2e..82e8a72b 100644 --- a/src/app/sections/party-shops/party-shops.component.html +++ b/src/app/sections/party-shops/party-shops.component.html @@ -10,7 +10,15 @@ > - + diff --git a/src/app/sections/party-shops/party-shops.component.ts b/src/app/sections/party-shops/party-shops.component.ts index f53902fe..3656e2de 100644 --- a/src/app/sections/party-shops/party-shops.component.ts +++ b/src/app/sections/party-shops/party-shops.component.ts @@ -40,7 +40,11 @@ export class PartyShopsComponent { ), ]).pipe( map(([shops, searchStr]) => - shops.filter((s) => JSON.stringify(s).toLowerCase().includes(searchStr.toLowerCase())), + searchStr + ? shops.filter((s) => + JSON.stringify(s).toLowerCase().includes(searchStr.toLowerCase()), + ) + : shops, ), shareReplay({ refCount: true, bufferSize: 1 }), ); @@ -54,6 +58,7 @@ export class PartyShopsComponent { this.selectedShop = d; this.sidenavInfoService.toggle(this.shopTpl, d.details.name || `Shop #${d.id}`, d); }, + sortable: true, }, { field: 'contract_id', @@ -114,6 +119,7 @@ export class PartyShopsComponent { ]), ]; progress$ = new BehaviorSubject(0); + shopsProgress$ = this.partyShopsService.progress$; constructor( private partyShopsService: PartyShopsService, diff --git a/src/app/sections/party-shops/party-shops.service.ts b/src/app/sections/party-shops/party-shops.service.ts index d41ac330..6a007733 100644 --- a/src/app/sections/party-shops/party-shops.service.ts +++ b/src/app/sections/party-shops/party-shops.service.ts @@ -1,7 +1,8 @@ import { Injectable } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Party } from '@vality/domain-proto/domain'; -import { defer, merge, Observable, Subject } from 'rxjs'; +import { progressTo } from '@vality/ng-core'; +import { defer, merge, Observable, Subject, BehaviorSubject } from 'rxjs'; import { map, shareReplay, switchMap } from 'rxjs/operators'; import { PartyManagementService } from '@cc/app/api/payment-processing'; @@ -12,6 +13,7 @@ export class PartyShopsService { map((p) => p.shops), map((shops) => Array.from(shops.values())), ); + progress$ = new BehaviorSubject(0); private reload$ = new Subject(); @@ -20,7 +22,9 @@ export class PartyShopsService { this.reload$.pipe(map(() => this.route.snapshot.params)), ).pipe( map((p) => p.partyID), - switchMap((partyID) => this.partyManagementService.Get(partyID)), + switchMap((partyID) => + this.partyManagementService.Get(partyID).pipe(progressTo(this.progress$)), + ), shareReplay(1), ); diff --git a/src/app/sections/payment-details/payment-details.component.ts b/src/app/sections/payment-details/payment-details.component.ts index 22839f60..bca16633 100644 --- a/src/app/sections/payment-details/payment-details.component.ts +++ b/src/app/sections/payment-details/payment-details.component.ts @@ -56,7 +56,9 @@ export class PaymentDetailsComponent { .afterClosed() .pipe(untilDestroyed(this)) .subscribe(({ status }) => { - if (status === DialogResponseStatus.Success) this.updateChargebacks$.next(); + if (status === DialogResponseStatus.Success) { + this.updateChargebacks$.next(); + } }); } } diff --git a/src/app/sections/payment-details/payment-main-info/payment-provider/fetch-provider.service.ts b/src/app/sections/payment-details/payment-main-info/payment-provider/fetch-provider.service.ts index 5aa1562b..bb34c690 100644 --- a/src/app/sections/payment-details/payment-main-info/payment-provider/fetch-provider.service.ts +++ b/src/app/sections/payment-details/payment-main-info/payment-provider/fetch-provider.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { merge, of, Subject } from 'rxjs'; import { catchError, filter, map, shareReplay, startWith, switchMap } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { progress } from '@cc/app/shared/custom-operators'; @Injectable() diff --git a/src/app/sections/payment-details/payment-main-info/payment-terminal/fetch-terminal.service.ts b/src/app/sections/payment-details/payment-main-info/payment-terminal/fetch-terminal.service.ts index fa23c06d..ad1dedec 100644 --- a/src/app/sections/payment-details/payment-main-info/payment-terminal/fetch-terminal.service.ts +++ b/src/app/sections/payment-details/payment-main-info/payment-terminal/fetch-terminal.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { merge, of, Subject } from 'rxjs'; import { catchError, filter, map, shareReplay, startWith, switchMap } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { progress } from '@cc/app/shared/custom-operators'; @Injectable() diff --git a/src/app/sections/payments/components/create-payment-adjustment/create-payment-adjustment.component.ts b/src/app/sections/payments/components/create-payment-adjustment/create-payment-adjustment.component.ts index 260939c9..ac696598 100644 --- a/src/app/sections/payments/components/create-payment-adjustment/create-payment-adjustment.component.ts +++ b/src/app/sections/payments/components/create-payment-adjustment/create-payment-adjustment.component.ts @@ -75,7 +75,9 @@ export class CreatePaymentAdjustmentComponent extends DialogSuperclass< .map((w) => { const error: string = w.error?.['name'] || w.error?.['message'] || ''; - if (error) return `${w.payment.id}: ${error}`; + if (error) { + return `${w.payment.id}: ${error}`; + } return null; }) .filter(Boolean) diff --git a/src/app/sections/repairing/repairing.component.ts b/src/app/sections/repairing/repairing.component.ts index d3266afa..48e5ab50 100644 --- a/src/app/sections/repairing/repairing.component.ts +++ b/src/app/sections/repairing/repairing.component.ts @@ -18,7 +18,7 @@ import { Moment } from 'moment'; import { BehaviorSubject } from 'rxjs'; import { filter, map, switchMap, shareReplay } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { NotificationErrorService } from '@cc/app/shared/services/notification-error'; import { getEnumKey } from '@cc/utils'; diff --git a/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.component.ts b/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.component.ts index 52729424..0cead57c 100644 --- a/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.component.ts +++ b/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.component.ts @@ -4,7 +4,7 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { DialogService } from '@vality/ng-core'; import { first, map } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { RoutingRulesType } from '@cc/app/sections/routing-rules/types/routing-rules-type'; import { NotificationErrorService } from '@cc/app/shared/services/notification-error'; diff --git a/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.service.ts b/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.service.ts index 00b28cc5..88006b47 100644 --- a/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.service.ts +++ b/src/app/sections/routing-rules/party-delegate-rulesets/party-delegate-rulesets.service.ts @@ -9,7 +9,7 @@ import { import { combineLatest, Observable } from 'rxjs'; import { map, pluck, startWith, switchMap } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { RoutingRulesService } from '../services/routing-rules'; import { RoutingRulesType } from '../types/routing-rules-type'; diff --git a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts index 7fd6feb9..e2b6368d 100644 --- a/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts +++ b/src/app/sections/routing-rules/party-routing-ruleset/party-routing-ruleset.component.ts @@ -5,7 +5,7 @@ import { DialogService, DialogResponseStatus } from '@vality/ng-core'; import { combineLatest, Observable } from 'rxjs'; import { filter, map, pluck, shareReplay, startWith, switchMap, take } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { RoutingRulesType } from '../types/routing-rules-type'; diff --git a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html index 417da434..f4c0c4fe 100644 --- a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html +++ b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.html @@ -19,11 +19,9 @@ [columns]="columns" [data]="(candidates$ | async) || []" [progress]="isLoading$ | async" - [sortActive]="sort.active" - [sortDirection]="sort.direction" + [sort]="{ active: 'priority', direction: 'desc' }" noActions sortOnFront - (sortChange)="sort = $event" > diff --git a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.ts b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.ts index e05220a7..a5698a3e 100644 --- a/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.ts +++ b/src/app/sections/routing-rules/routing-ruleset/routing-ruleset.component.ts @@ -1,5 +1,4 @@ import { Component, ViewChild, TemplateRef } from '@angular/core'; -import { Sort } from '@angular/material/sort'; import { ActivatedRoute } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TerminalObject, RoutingCandidate, Predicate } from '@vality/domain-proto/domain'; @@ -13,7 +12,7 @@ import { import { Observable, combineLatest } from 'rxjs'; import { first, map, switchMap, withLatestFrom } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { RoutingRulesType } from '@cc/app/sections/routing-rules/types/routing-rules-type'; import { DomainThriftFormDialogComponent } from '@cc/app/shared/components/thrift-api-crud'; @@ -152,10 +151,6 @@ export class RoutingRulesetComponent { ]), ]; openedCandidate?: RoutingCandidate; - sort: Sort = { - active: 'priority', - direction: 'desc', - }; constructor( private dialog: DialogService, @@ -271,7 +266,9 @@ export class RoutingRulesetComponent { } private formatPredicate(predicate: Predicate) { - if (!predicate) return ''; + if (!predicate) { + return ''; + } if (getUnionKey(predicate) === 'constant') { return JSON.stringify(predicate.constant); } diff --git a/src/app/sections/routing-rules/services/routing-rules/routing-rules.service.ts b/src/app/sections/routing-rules/services/routing-rules/routing-rules.service.ts index ff5f04db..c30d36f0 100644 --- a/src/app/sections/routing-rules/services/routing-rules/routing-rules.service.ts +++ b/src/app/sections/routing-rules/services/routing-rules/routing-rules.service.ts @@ -5,7 +5,7 @@ import cloneDeep from 'lodash-es/cloneDeep'; import { combineLatest, concat, Observable } from 'rxjs'; import { map, pluck, shareReplay, switchMap, take } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { createNextId } from '@cc/utils/create-next-id'; import { getDelegate } from './utils/get-delegate'; diff --git a/src/app/sections/routing-rules/target-ruleset-form/target-ruleset-form.component.ts b/src/app/sections/routing-rules/target-ruleset-form/target-ruleset-form.component.ts index d5231e34..7b513240 100644 --- a/src/app/sections/routing-rules/target-ruleset-form/target-ruleset-form.component.ts +++ b/src/app/sections/routing-rules/target-ruleset-form/target-ruleset-form.component.ts @@ -13,7 +13,7 @@ import { ComponentChanges } from '@vality/ng-core'; import sortBy from 'lodash-es/sortBy'; import { map, startWith } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { RoutingRulesService } from '../services/routing-rules'; import { RoutingRulesType } from '../types/routing-rules-type'; diff --git a/src/app/sections/sections-routing.module.ts b/src/app/sections/sections-routing.module.ts index f0643def..59bb47db 100644 --- a/src/app/sections/sections-routing.module.ts +++ b/src/app/sections/sections-routing.module.ts @@ -56,6 +56,10 @@ const ROUTES: Routes = [ path: 'chargebacks', loadChildren: () => import('./chargebacks').then((m) => m.ChargebacksModule), }, + { + path: 'terminals', + loadChildren: () => import('./terminals').then((m) => m.TerminalsModule), + }, { path: '404', loadChildren: () => import('./not-found').then((m) => m.NotFoundModule), diff --git a/src/app/sections/terminals/index.ts b/src/app/sections/terminals/index.ts new file mode 100644 index 00000000..844928e2 --- /dev/null +++ b/src/app/sections/terminals/index.ts @@ -0,0 +1,2 @@ +export * from './terminals.module'; +export * from './routing-config'; diff --git a/src/app/sections/terminals/routing-config.ts b/src/app/sections/terminals/routing-config.ts new file mode 100644 index 00000000..562aad51 --- /dev/null +++ b/src/app/sections/terminals/routing-config.ts @@ -0,0 +1,5 @@ +import { Services, RoutingConfig } from '@cc/app/shared/services'; + +export const ROUTING_CONFIG: RoutingConfig = { + services: [Services.Domain], +}; diff --git a/src/app/sections/terminals/terminals-routing.module.ts b/src/app/sections/terminals/terminals-routing.module.ts new file mode 100644 index 00000000..c92617cc --- /dev/null +++ b/src/app/sections/terminals/terminals-routing.module.ts @@ -0,0 +1,22 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { AppAuthGuardService } from '@cc/app/shared/services'; + +import { ROUTING_CONFIG } from './routing-config'; +import { TerminalsComponent } from './terminals.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { + path: '', + component: TerminalsComponent, + canActivate: [AppAuthGuardService], + data: ROUTING_CONFIG, + }, + ]), + ], + exports: [RouterModule], +}) +export class TerminalsRoutingModule {} diff --git a/src/app/sections/terminals/terminals.component.html b/src/app/sections/terminals/terminals.component.html new file mode 100644 index 00000000..0d01a1a7 --- /dev/null +++ b/src/app/sections/terminals/terminals.component.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/app/sections/terminals/terminals.component.ts b/src/app/sections/terminals/terminals.component.ts new file mode 100644 index 00000000..02cbde0d --- /dev/null +++ b/src/app/sections/terminals/terminals.component.ts @@ -0,0 +1,240 @@ +import { Component, ViewChild, TemplateRef } from '@angular/core'; +import { FormControl } from '@angular/forms'; +import { Sort } from '@angular/material/sort'; +import { Router } from '@angular/router'; +import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy'; +import { + TerminalObject, + ProviderObject, + RoutingRulesObject, + RoutingDelegate, +} from '@vality/domain-proto/domain'; +import { Column } from '@vality/ng-core'; +import startCase from 'lodash-es/startCase'; +import { combineLatest } from 'rxjs'; +import { startWith, map, debounceTime, tap, take } from 'rxjs/operators'; + +import { objectToJSON, createFullTextSearch, getUnionValue, getUnionKey } from '../../../utils'; +import { DomainStoreService } from '../../api/domain-config'; +import { PartiesStoreService } from '../../api/payment-processing'; +import { SidenavInfoService } from '../../shared/components/sidenav-info'; + +@UntilDestroy() +@Component({ + selector: 'cc-terminals', + templateUrl: './terminals.component.html', +}) +export class TerminalsComponent { + searchControl = new FormControl(''); + columns: Column[] = [ + { field: 'ref.id', sortable: true }, + { + field: 'data.name', + description: 'data.description', + sortable: true, + click: (d) => { + this.openedTerminal = d; + this.sidenavInfoService.toggle( + this.terminalTpl, + d.data.name || d.data.description || `Terminal #${d.ref.id}`, + d, + ); + }, + }, + { + field: 'data.provider_ref.id', + description: 'data.provider_ref.id', + header: 'Provider', + formatter: (d) => this.getProvider(d).pipe(map((p) => p?.data?.name || '')), + sortable: true, + click: (d) => { + this.getProvider(d) + .pipe(take(1), untilDestroyed(this)) + .subscribe((provider) => { + if (!provider) { + return; + } + this.openedProvider = provider; + this.sidenavInfoService.toggle( + this.providerTpl, + provider.data.name || + provider.data.description || + `Provider #${provider.ref.id}`, + provider, + ); + }); + }, + }, + { + field: 'delegates', + formatter: (d) => + this.getTerminalShopWalletDelegates(d).pipe(map((r) => r.length || '')), + click: (d) => { + this.getTerminalShopWalletDelegates(d) + .pipe(take(1), untilDestroyed(this)) + .subscribe((rules) => { + this.openedRoutingRules = rules; + this.sidenavInfoService.toggle( + this.routingRulesTpl, + `Terminal #${d.ref.id} delegates`, + d, + ); + }); + }, + }, + ]; + data$ = combineLatest([ + this.domainStoreService.getObjects('terminal').pipe( + map((objects) => + createFullTextSearch( + objects, + objects.map((o) => ({ + ref: o.ref.id, + data: JSON.stringify(objectToJSON(o.data)), + name: o.data.name, + description: o.data.description, + })), + ), + ), + ), + this.searchControl.valueChanges.pipe( + startWith(this.searchControl.value), + debounceTime(100), + ), + ]).pipe( + tap(([, search]) => { + if (search) { + this.sort = { active: '', direction: '' }; + } + }), + map(([fts, search]) => fts.search(search)), + ); + progress$ = this.domainStoreService.isLoading$; + sort: Sort = { active: 'data.name', direction: 'asc' }; + openedTerminal?: TerminalObject; + @ViewChild('terminalTpl') terminalTpl: TemplateRef; + openedProvider?: ProviderObject; + @ViewChild('providerTpl') providerTpl: TemplateRef; + openedRoutingRules?: { + delegate: RoutingDelegate; + rule: RoutingRulesObject; + terminalRule: RoutingRulesObject; + }[]; + @ViewChild('routingRulesTpl') routingRulesTpl: TemplateRef; + + routingRulesColumns: Column<{ + delegate: RoutingDelegate; + rule: RoutingRulesObject; + terminalRule: RoutingRulesObject; + }>[] = [ + { + header: 'Routing Rule', + field: 'terminalRule.data.name', + description: 'terminalRule.ref.id', + }, + { + header: 'Ruleset', + field: 'rule.data.name', + description: 'rule.ref.id', + }, + { + field: 'party', + formatter: (d) => + this.partiesStoreService + .get(d.delegate.allowed.condition?.party?.id) + .pipe(map((p) => p.contact_info.email)), + description: (d) => d.delegate.allowed.condition?.party?.id, + link: (d) => `/party/${d.delegate.allowed.condition.party.id}`, + }, + { + field: 'type', + formatter: (d) => + startCase( + getUnionKey(d.delegate.allowed.condition?.party?.definition).slice(0, -3), + ), + }, + { + field: 'definition', + formatter: (d) => + this.partiesStoreService + .get(d.delegate.allowed.condition?.party?.id) + .pipe( + map((p) => + getUnionKey(d.delegate.allowed.condition?.party?.definition) === + 'shop_is' + ? p.shops.get( + getUnionValue( + d.delegate.allowed.condition?.party?.definition, + ), + ).details.name + : p.wallets.get( + getUnionValue( + d.delegate.allowed.condition?.party?.definition, + ), + ).name, + ), + ), + description: (d) => getUnionValue(d.delegate.allowed.condition?.party?.definition), + link: (d) => + `/party/${d.delegate.allowed.condition.party.id}/routing-rules/${ + getUnionKey(d.delegate.allowed.condition?.party?.definition) === 'shop_is' + ? 'payment' + : 'withdrawal' + }/${d.rule.ref.id}/delegate/${d.delegate.ruleset.id}`, + }, + ]; + + constructor( + private domainStoreService: DomainStoreService, + private router: Router, + private sidenavInfoService: SidenavInfoService, + private partiesStoreService: PartiesStoreService, + ) {} + + update() { + this.domainStoreService.forceReload(); + } + + create() { + void this.router.navigate(['/domain/create']); + } + + private getProvider(terminalObj: TerminalObject) { + return this.domainStoreService + .getObjects('provider') + .pipe( + map((providers) => + providers.find((p) => p.ref.id === terminalObj.data.provider_ref.id), + ), + ); + } + + private getTerminalShopWalletDelegates(terminalObj: TerminalObject) { + return this.domainStoreService.getObjects('routing_rules').pipe( + map((rules) => { + const terminalRules = rules.filter( + (r) => + r.data?.decisions?.candidates?.some?.( + (c) => c.terminal.id === terminalObj.ref.id, + ), + ); + return terminalRules + .map((terminalRule) => + rules.map((rule) => + ( + rule?.data?.decisions?.delegates?.filter?.( + (d) => + d?.ruleset?.id === terminalRule.ref.id && + d?.allowed?.condition?.party && + ['wallet_is', 'shop_is'].includes( + getUnionKey(d?.allowed?.condition?.party?.definition), + ), + ) || [] + ).map((delegate) => ({ delegate, rule, terminalRule })), + ), + ) + .flat(2); + }), + ); + } +} diff --git a/src/app/sections/terminals/terminals.module.ts b/src/app/sections/terminals/terminals.module.ts new file mode 100644 index 00000000..57bb6a71 --- /dev/null +++ b/src/app/sections/terminals/terminals.module.ts @@ -0,0 +1,28 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { ReactiveFormsModule } from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; +import { MatExpansionModule } from '@angular/material/expansion'; +import { TableModule, InputFieldModule } from '@vality/ng-core'; + +import { PageLayoutModule } from '../../shared'; +import { DomainThriftViewerComponent } from '../../shared/components/thrift-api-crud'; + +import { TerminalsRoutingModule } from './terminals-routing.module'; +import { TerminalsComponent } from './terminals.component'; + +@NgModule({ + declarations: [TerminalsComponent], + imports: [ + CommonModule, + TerminalsRoutingModule, + TableModule, + MatButtonModule, + PageLayoutModule, + InputFieldModule, + ReactiveFormsModule, + DomainThriftViewerComponent, + MatExpansionModule, + ], +}) +export class TerminalsModule {} diff --git a/src/app/shared/components/datetime/datetime.component.ts b/src/app/shared/components/datetime/datetime.component.ts index 00a88a8d..10eb065f 100644 --- a/src/app/shared/components/datetime/datetime.component.ts +++ b/src/app/shared/components/datetime/datetime.component.ts @@ -41,8 +41,11 @@ export class DatetimeComponent extends FormComponentSuperclass { dateChanged(date: MatDatepickerInputEvent) { const v = date.target.value; - if (!this.datetime) this.datetime = date.target.value; - else this.datetime.set({ date: v.date(), month: v.month(), year: v.year() }); + if (!this.datetime) { + this.datetime = date.target.value; + } else { + this.datetime.set({ date: v.date(), month: v.month(), year: v.year() }); + } this.emitOutgoingValue(this.datetime.toISOString()); } diff --git a/src/app/shared/components/json-viewer/components/key/key.component.ts b/src/app/shared/components/json-viewer/components/key/key.component.ts index f48134e2..c9ee3922 100644 --- a/src/app/shared/components/json-viewer/components/key/key.component.ts +++ b/src/app/shared/components/json-viewer/components/key/key.component.ts @@ -15,11 +15,15 @@ export class KeyComponent implements OnChanges { keys$ = new ReplaySubject(1); numberKey$ = this.keys$.pipe( switchMap((keys) => { - if (keys.length !== 1) return of(null); + if (keys.length !== 1) { + return of(null); + } return this.keys[0].key$.pipe( switchMap((key) => key.renderValue$), map((value) => { - if (typeof value === 'number') return `${value + 1}`; + if (typeof value === 'number') { + return `${value + 1}`; + } return null; }), ); @@ -27,16 +31,22 @@ export class KeyComponent implements OnChanges { ); ngOnChanges(changes: ComponentChanges) { - if (changes.keys) this.keys$.next(this.keys); + if (changes.keys) { + this.keys$.next(this.keys); + } } parentIsUnion(pathItem: MetadataViewItem) { - if (!pathItem?.data$) return of(false); + if (!pathItem?.data$) { + return of(false); + } return pathItem.data$.pipe(map((data) => data?.trueParent?.objectType === 'union')); } isUnion(pathItem: MetadataViewItem) { - if (!pathItem?.data$) return of(false); + if (!pathItem?.data$) { + return of(false); + } return pathItem.data$.pipe(map((data) => data?.trueTypeNode?.data?.objectType === 'union')); } } diff --git a/src/app/shared/components/json-viewer/utils/get-entries.ts b/src/app/shared/components/json-viewer/utils/get-entries.ts index e8e6e1a2..530fa4d6 100644 --- a/src/app/shared/components/json-viewer/utils/get-entries.ts +++ b/src/app/shared/components/json-viewer/utils/get-entries.ts @@ -1,5 +1,7 @@ export function getEntries(obj: unknown): [number | string, unknown][] { - if (!obj) return []; + if (!obj) { + return []; + } return Array.isArray(obj) || obj instanceof Set ? Array.from(obj).map((v, idx) => [idx, v]) : obj instanceof Map diff --git a/src/app/shared/components/json-viewer/utils/metadata-view.ts b/src/app/shared/components/json-viewer/utils/metadata-view.ts index 554cb400..82df886d 100644 --- a/src/app/shared/components/json-viewer/utils/metadata-view.ts +++ b/src/app/shared/components/json-viewer/utils/metadata-view.ts @@ -31,17 +31,21 @@ export class MetadataViewItem { ); renderValue$ = combineLatest([this.value$, this.data$]).pipe( map(([value, data]) => { - if (data?.trueTypeNode?.data?.objectType === 'enum') + if (data?.trueTypeNode?.data?.objectType === 'enum') { return ( (data.trueTypeNode.data as MetadataFormData).ast.items.find( (i, idx) => { - if ('value' in i) return i.value === value; + if ('value' in i) { + return i.value === value; + } return idx === value; }, ).name ?? value ); - if (data?.objectType === 'union' && isEmpty(getEntries(value)?.[0]?.[1])) + } + if (data?.objectType === 'union' && isEmpty(getEntries(value)?.[0]?.[1])) { return getEntries(value)?.[0]?.[0]; + } return value; }), ); @@ -64,8 +68,9 @@ export class MetadataViewItem { key?.data || (data?.trueTypeNode?.data as MetadataFormData)?.type ?.name - ) + ) { return of([]); + } const [item] = items; return combineLatest([ item.key$.pipe(switchMap((key) => key.value$)), @@ -75,12 +80,14 @@ export class MetadataViewItem { if ( typeof childKey === 'number' || (data?.objectType === 'union' && isEmpty(childValue)) - ) + ) { return of([]); + } return item.data$.pipe( switchMap((itemData) => { - if (data?.objectType === 'union' && itemData?.objectType !== 'union') + if (data?.objectType === 'union' && itemData?.objectType !== 'union') { return of([item]); + } return item.inline$.pipe(map((childInline) => [item, ...childInline])); }), ); diff --git a/src/app/shared/components/merchant-field/merchant-field.component.ts b/src/app/shared/components/merchant-field/merchant-field.component.ts index bc626092..d60e1e80 100644 --- a/src/app/shared/components/merchant-field/merchant-field.component.ts +++ b/src/app/shared/components/merchant-field/merchant-field.component.ts @@ -56,7 +56,9 @@ export class MerchantFieldComponent } private searchOptions(str: string): Observable[]> { - if (!str) return of([]); + if (!str) { + return of([]); + } return this.deanonimusService.searchParty(str).pipe( map((parties) => parties.map((p) => ({ diff --git a/src/app/shared/components/metadata-form/components/complex-form/complex-form.component.ts b/src/app/shared/components/metadata-form/components/complex-form/complex-form.component.ts index d6fef330..148390c7 100644 --- a/src/app/shared/components/metadata-form/components/complex-form/complex-form.component.ts +++ b/src/app/shared/components/metadata-form/components/complex-form/complex-form.component.ts @@ -52,7 +52,9 @@ export class ComplexFormComponent } get keyType() { - if ('keyType' in this.data.type) return this.data.type.keyType; + if ('keyType' in this.data.type) { + return this.data.type.keyType; + } } ngOnInit() { @@ -93,11 +95,15 @@ export class ComplexFormComponent add() { this.valueControls.push(new FormControl()); - if (this.isKeyValue) this.keyControls.push(new FormControl()); + if (this.isKeyValue) { + this.keyControls.push(new FormControl()); + } } delete(idx: number) { this.valueControls.removeAt(idx); - if (this.isKeyValue) this.keyControls.removeAt(idx); + if (this.isKeyValue) { + this.keyControls.removeAt(idx); + } } } diff --git a/src/app/shared/components/metadata-form/components/extension-field/extension-field.component.ts b/src/app/shared/components/metadata-form/components/extension-field/extension-field.component.ts index 34065809..f18d7eb9 100644 --- a/src/app/shared/components/metadata-form/components/extension-field/extension-field.component.ts +++ b/src/app/shared/components/metadata-form/components/extension-field/extension-field.component.ts @@ -89,7 +89,9 @@ export class ExtensionFieldComponent this.data$.next(this.data); this.control.setValidators(this.data.isRequired ? Validators.required : []); } - if (changes.extensions) this.extensions$.next(this.extensions); + if (changes.extensions) { + this.extensions$.next(this.extensions); + } } generate(event: MouseEvent) { diff --git a/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts b/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts index f2aee8fe..a01ca22f 100644 --- a/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts +++ b/src/app/shared/components/metadata-form/components/primitive-field/primitive-field.component.ts @@ -82,8 +82,12 @@ export class PrimitiveFieldComponent ngOnChanges(changes: ComponentChanges>) { super.ngOnChanges(changes); - if (changes.data) this.data$.next(this.data); - if (changes.extensions) this.extensions$.next(this.extensions); + if (changes.data) { + this.data$.next(this.data); + } + if (changes.extensions) { + this.extensions$.next(this.extensions); + } } generate(event: MouseEvent) { diff --git a/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.ts b/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.ts index 60048586..ce9d2ae3 100644 --- a/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.ts +++ b/src/app/shared/components/metadata-form/components/struct-form/struct-form.component.ts @@ -55,8 +55,11 @@ export class StructFormComponent ngOnChanges(changes: SimpleChanges) { const newControlsNames = new Set(this.data.ast.map(({ name }) => name)); Object.keys(this.control.controls).forEach((name) => { - if (newControlsNames.has(name)) newControlsNames.delete(name); - else this.control.removeControl(name as never); + if (newControlsNames.has(name)) { + newControlsNames.delete(name); + } else { + this.control.removeControl(name as never); + } }); newControlsNames.forEach((name) => this.control.addControl( @@ -84,11 +87,19 @@ export class StructFormComponent private setLabelControl(value: boolean = false) { if (!this.hasLabel || this.data.isRequired) { - if (!this.labelControl.value) this.labelControl.setValue(true); - if (this.labelControl.enabled) this.labelControl.disable(); + if (!this.labelControl.value) { + this.labelControl.setValue(true); + } + if (this.labelControl.enabled) { + this.labelControl.disable(); + } } else { - if (this.labelControl.value !== value) this.labelControl.setValue(value); - if (this.labelControl.disabled) this.labelControl.enable(); + if (this.labelControl.value !== value) { + this.labelControl.setValue(value); + } + if (this.labelControl.disabled) { + this.labelControl.enable(); + } } } } diff --git a/src/app/shared/components/metadata-form/types/metadata-form-data.ts b/src/app/shared/components/metadata-form/types/metadata-form-data.ts index 416b67cd..c3f34152 100644 --- a/src/app/shared/components/metadata-form/types/metadata-form-data.ts +++ b/src/app/shared/components/metadata-form/types/metadata-form-data.ts @@ -98,7 +98,9 @@ export class MetadataFormData< ) { this.setNamespaceType(namespace, type); this.setTypeGroup(); - if (this.typeGroup === TypeGroup.Object) this.setNamespaceObjectType(); + if (this.typeGroup === TypeGroup.Object) { + this.setNamespaceObjectType(); + } } create(params: { type?: ValueType; field?: Field }): MetadataFormData { diff --git a/src/app/shared/components/thrift-api-crud/domain/domain-object-field/domain-object-field.component.ts b/src/app/shared/components/thrift-api-crud/domain/domain-object-field/domain-object-field.component.ts index 617b43bd..15f951e3 100644 --- a/src/app/shared/components/thrift-api-crud/domain/domain-object-field/domain-object-field.component.ts +++ b/src/app/shared/components/thrift-api-crud/domain/domain-object-field/domain-object-field.component.ts @@ -12,7 +12,7 @@ import { import { defer, switchMap, ReplaySubject } from 'rxjs'; import { shareReplay, map } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { DOMAIN_OBJECTS_TO_OPTIONS, diff --git a/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts b/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts index 4b79b6d1..6df63241 100644 --- a/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts +++ b/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/domain-metadata-view-extensions.service.ts @@ -8,7 +8,7 @@ import isEqual from 'lodash-es/isEqual'; import { of, Observable } from 'rxjs'; import { map, shareReplay } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +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'; diff --git a/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/utils/get-object-label.ts b/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/utils/get-object-label.ts index 68188d23..4bcdb070 100644 --- a/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/utils/get-object-label.ts +++ b/src/app/shared/components/thrift-api-crud/domain/domain-thrift-viewer/services/domain-metadata-view-extensions/utils/get-object-label.ts @@ -12,8 +12,12 @@ const LABEL_SELECTORS: { }; export function getObjectLabel(o: DomainObject[keyof DomainObject], objectKey: keyof DomainObject) { - if (LABEL_SELECTORS[objectKey]) return LABEL_SELECTORS[objectKey](o as never); - if ('name' in o.data && o.data.name) return o.data.name; + if (LABEL_SELECTORS[objectKey]) { + return LABEL_SELECTORS[objectKey](o as never); + } + if ('name' in o.data && o.data.name) { + return o.data.name; + } const id = 'id' in o.ref && typeof o.ref.id !== 'object' ? o.ref.id : ''; return startCase([...objectKey.split('_'), 'ref', id && `#${id}`].filter(Boolean).join(' ')); } diff --git a/src/app/shared/components/thrift-viewer/thrift-viewer.component.scss b/src/app/shared/components/thrift-viewer/thrift-viewer.component.scss index 171e173e..763c818e 100644 --- a/src/app/shared/components/thrift-viewer/thrift-viewer.component.scss +++ b/src/app/shared/components/thrift-viewer/thrift-viewer.component.scss @@ -15,5 +15,6 @@ .monaco-editor { height: 100%; display: block; + min-height: 300px; } } diff --git a/src/app/shared/pipes/amount-currency.pipe.ts b/src/app/shared/pipes/amount-currency.pipe.ts index 67b854c4..ddd801ba 100644 --- a/src/app/shared/pipes/amount-currency.pipe.ts +++ b/src/app/shared/pipes/amount-currency.pipe.ts @@ -6,7 +6,7 @@ import isNil from 'lodash-es/isNil'; import { ReplaySubject, combineLatest } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { toMajor } from '../../../utils'; @@ -39,10 +39,12 @@ export class AmountCurrencyPipe implements PipeTransform { ]) .pipe( map(([currencies, { amount, currencyCode, format }]) => { - if (isNil(amount)) return '?'; + if (isNil(amount)) { + return '?'; + } const exponent = currencies.find((c) => c.data.symbolic_code === currencyCode) ?.data?.exponent; - if (!currencyCode || !exponent) + if (!currencyCode || !exponent) { return formatCurrency( toMajor(amount, exponent), this._locale, @@ -50,6 +52,7 @@ export class AmountCurrencyPipe implements PipeTransform { '', format === 'short' ? '0.0-2' : undefined, ); + } return formatCurrency( toMajor(amount, exponent), this._locale, @@ -71,7 +74,9 @@ export class AmountCurrencyPipe implements PipeTransform { format: 'short' | 'long' = 'long', ) { this.params$.next({ amount, currencyCode, format }); - if (!this.isInit) this.init(); + if (!this.isInit) { + this.init(); + } return this.latestValue; } } diff --git a/src/app/shared/services/amount-currency.service.ts b/src/app/shared/services/amount-currency.service.ts index 2dd75287..b89eee57 100644 --- a/src/app/shared/services/amount-currency.service.ts +++ b/src/app/shared/services/amount-currency.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { toMajorByExponent } from '@vality/ng-core'; import { map, first } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; @Injectable({ providedIn: 'root', diff --git a/src/app/shared/services/app-auth-guard/app-auth-guard.service.ts b/src/app/shared/services/app-auth-guard/app-auth-guard.service.ts index 12954719..250cbe6d 100644 --- a/src/app/shared/services/app-auth-guard/app-auth-guard.service.ts +++ b/src/app/shared/services/app-auth-guard/app-auth-guard.service.ts @@ -25,8 +25,9 @@ export class AppAuthGuardService extends KeycloakAuthGuard { } userHasSomeServiceMethods(serviceMethods: string[]): boolean { - if ((!environment.production && environment.ignoreRoles) || !serviceMethods?.length) + if ((!environment.production && environment.ignoreRoles) || !serviceMethods?.length) { return true; + } const allowedServiceMethods = this.keycloakAngular .getUserRoles(true) .map((r) => r.split(':')); diff --git a/src/app/shared/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts b/src/app/shared/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts index 69a4da76..ee7c1215 100644 --- a/src/app/shared/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts +++ b/src/app/shared/services/domain-metadata-form-extensions/domain-metadata-form-extensions.service.ts @@ -6,7 +6,7 @@ import { from, Observable, of } from 'rxjs'; import { map, shareReplay } from 'rxjs/operators'; import * as short from 'short-uuid'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { Cash as CashField } from '../../../../components/cash-field'; import { diff --git a/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts b/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts index 9c7ca0af..b09aa011 100644 --- a/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts +++ b/src/app/shared/services/domain-metadata-form-extensions/utils/domains-objects-to-options.ts @@ -26,7 +26,11 @@ export const DOMAIN_OBJECTS_TO_OPTIONS: { export function defaultDomainObjectToOption(o: DomainRefDataObjects[keyof DomainRefDataObjects]) { let label: string; - if ('name' in o.data) label = o.data.name; - if ('id' in o.data && !label) label = (o.data as unknown as { id: string }).id; + if ('name' in o.data) { + label = o.data.name; + } + if ('id' in o.data && !label) { + label = (o.data as unknown as { id: string }).id; + } return { value: o.ref.id, label, details: o }; } diff --git a/src/app/shared/utils/clean-thrift.ts b/src/app/shared/utils/clean-thrift.ts index f9807347..c5fd0998 100644 --- a/src/app/shared/utils/clean-thrift.ts +++ b/src/app/shared/utils/clean-thrift.ts @@ -2,7 +2,9 @@ import { clean, isEmpty } from '@vality/ng-core'; import isObject from 'lodash-es/isObject'; function isEmptyThrift(value: unknown): boolean { - if (isObject(value) && value.constructor === Object) return false; + if (isObject(value) && value.constructor === Object) { + return false; + } return isEmpty(value); } diff --git a/src/app/tokens.ts b/src/app/tokens.ts index ee7e1b47..f4b22026 100644 --- a/src/app/tokens.ts +++ b/src/app/tokens.ts @@ -27,9 +27,13 @@ export const DEFAULT_QUERY_PARAMS_SERIALIZERS: Serializer[] = [ return { start, end }; }, recognize: (value) => { - if (typeof value !== 'object') return false; + if (typeof value !== 'object') { + return false; + } const { start, end, ...other } = value as DateRange; - if (Object.keys(other).length) return false; + if (Object.keys(other).length) { + return false; + } return (!start || moment.isMoment(start)) && (!end || moment.isMoment(end)); }, }, diff --git a/src/components/cash-field/cash-field.component.ts b/src/components/cash-field/cash-field.component.ts index 1b42e3ce..a3c32983 100644 --- a/src/components/cash-field/cash-field.component.ts +++ b/src/components/cash-field/cash-field.component.ts @@ -9,7 +9,7 @@ import sortBy from 'lodash-es/sortBy'; import { combineLatest } from 'rxjs'; import { map, switchMap, first, distinctUntilChanged } from 'rxjs/operators'; -import { DomainStoreService } from '@cc/app/api/deprecated-damsel'; +import { DomainStoreService } from '@cc/app/api/domain-config'; import { createControlProviders, getFormValueChanges } from '../../utils'; @@ -87,10 +87,11 @@ export class CashFieldComponent extends FormComponentSuperclass implements const amountStr = this.amountControl.value; if (amountStr && currency && !this.validate()) { const [whole, fractional] = amountStr.split('.'); - if (fractional?.length > currency.data.exponent) + if (fractional?.length > currency.data.exponent) { this.amountControl.setValue( `${whole}.${fractional.slice(0, currency.data.exponent)}`, ); + } const amount = Number(this.amountControl.value.replaceAll(GROUP_SEPARATOR, '')); this.emitOutgoingValue({ amount, currencyCode: currency.data.symbolic_code }); } else { diff --git a/src/components/monaco-editor/abstract-monaco.service.ts b/src/components/monaco-editor/abstract-monaco.service.ts index adc7ba0f..f84d0397 100644 --- a/src/components/monaco-editor/abstract-monaco.service.ts +++ b/src/components/monaco-editor/abstract-monaco.service.ts @@ -61,7 +61,9 @@ export abstract class AbstractMonacoService { } destroy() { - if (this.resizeDetector) this.resizeDetector.detach(); + if (this.resizeDetector) { + this.resizeDetector.detach(); + } this.destroy$.next(); } @@ -153,7 +155,9 @@ export abstract class AbstractMonacoService { } private registerResizeListener() { - if (this.resizeDetector) this.resizeDetector.detach(); + if (this.resizeDetector) { + this.resizeDetector.detach(); + } this.resizeDetector = new ResizeSensor(this.nativeElement, () => { this.updateLayoutSize(); }); diff --git a/src/utils/csv/utils/unify-csv-items.ts b/src/utils/csv/utils/unify-csv-items.ts index 8aa0c9c1..8c3b21f0 100644 --- a/src/utils/csv/utils/unify-csv-items.ts +++ b/src/utils/csv/utils/unify-csv-items.ts @@ -2,7 +2,9 @@ export function unifyCsvItems( csv: T[] | string[][], defaultProps: readonly (keyof T)[] | (keyof T)[], ): T[] { - if (!Array.isArray(csv)) return []; + if (!Array.isArray(csv)) { + return []; + } if (Array.isArray(csv?.[0])) { return csv.map((d) => Object.fromEntries(d.map((prop, idx) => [defaultProps[idx], prop])), diff --git a/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts b/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts index f3660044..768f2281 100644 --- a/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts +++ b/src/utils/forms/validated-control-superclass/validated-control-superclass.directive.ts @@ -40,11 +40,14 @@ export abstract class ValidatedControlSuperclass( + source: T[], + objects: O[], + options: Fuse.IFuseOptions = { keys: Object.keys(objects[0]) }, +) { + const fuse = new Fuse(objects, options); + return { + search: (str: string) => (str ? fuse.search(str).map((r) => source[r.refIndex]) : source), + }; +} diff --git a/src/utils/full-text-search/index.ts b/src/utils/full-text-search/index.ts new file mode 100644 index 00000000..9db48bbe --- /dev/null +++ b/src/utils/full-text-search/index.ts @@ -0,0 +1 @@ +export * from './create-full-text-search'; diff --git a/src/utils/get-enum-keys.ts b/src/utils/get-enum-keys.ts index cfbfb565..af173fb9 100644 --- a/src/utils/get-enum-keys.ts +++ b/src/utils/get-enum-keys.ts @@ -4,9 +4,13 @@ export function getEnumEntries>( srcEnum: E, ): [key: keyof E, value: ValuesType][] { const entries = Object.entries(srcEnum); - if (!entries.length) return []; + if (!entries.length) { + return []; + } const isValueNumberEnum = entries.some(([, v]) => typeof v === 'number'); - if (isValueNumberEnum) return entries.filter(([, v]) => typeof v === 'number') as never; + if (isValueNumberEnum) { + return entries.filter(([, v]) => typeof v === 'number') as never; + } return entries as never; } diff --git a/src/utils/index.ts b/src/utils/index.ts index 34a2c48f..72d83ebe 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -16,3 +16,4 @@ export * from './enumerate'; export * from './thrift-instance'; export * from './csv'; export * from './thrift'; +export * from './full-text-search'; diff --git a/src/utils/thrift-instance/namespace-type.ts b/src/utils/thrift-instance/namespace-type.ts index a8de1213..c42a58dd 100644 --- a/src/utils/thrift-instance/namespace-type.ts +++ b/src/utils/thrift-instance/namespace-type.ts @@ -44,10 +44,12 @@ export function parseNamespaceObjectType( ): NamespaceObjectType { // metadata reverse find - search for the last matching protocol if the names match (files are overwritten in the same order) let namespaceMetadata: ThriftAstMetadata; - if (include) + if (include) { namespaceMetadata = metadata.reverse().find((m) => m.path === include[namespace].path); - if (!namespaceMetadata) + } + if (!namespaceMetadata) { namespaceMetadata = metadata.reverse().find((m) => m.name === namespace); + } const objectType = Object.keys(namespaceMetadata.ast).find( (t) => namespaceMetadata.ast[t][type], ) as StructureType; diff --git a/src/utils/to-major.ts b/src/utils/to-major.ts index eda190ae..fea973e0 100644 --- a/src/utils/to-major.ts +++ b/src/utils/to-major.ts @@ -2,6 +2,8 @@ import isNil from 'lodash-es/isNil'; import round from 'lodash-es/round'; export const toMajor = (amount: number, exponent = 2): number | null => { - if (isNil(amount)) return null; + if (isNil(amount)) { + return null; + } return round(amount / 10 ** exponent, exponent); };