TD-355: Update s-libs, keycloak and others for Angular 14 (#111)

This commit is contained in:
Rinat Arsaev 2022-07-20 17:17:02 +03:00 committed by GitHub
parent afb9894e92
commit 79fd09b81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 641 additions and 911 deletions

View File

@ -22,25 +22,22 @@
"options": {
"allowedCommonJsDependencies": [
"moment",
"keycloak-js",
"uuid",
"short-uuid",
"js-sha256",
"jwt-decode",
"rxjs",
"thrift-ts",
"buffer",
"humanize-duration",
"node-int64",
"element-resize-detector",
"base64-js",
"@vality/deanonimus-proto",
"@vality/domain-proto",
"@vality/dominant-cache-proto",
"@vality/file-storage-proto",
"@vality/fistful-proto",
"@vality/machinegun-proto",
"@vality/magista-proto",
"@vality/messages-proto",
"@vality/payout-manager-proto"
"@vality/payout-manager-proto",
"@vality/repairer-proto",
"@vality/fistful-proto",
"@vality/file-storage-proto"
],
"outputPath": "dist",
"index": "src/index.html",

1387
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
"start": "ng serve --proxy-config proxy.conf.js --port 4200",
"build": "ng build --extra-webpack-config webpack.extra.js",
"test": "ng test",
"lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1273",
"lint-cmd": "eslint \"src/**/*.{ts,js,html}\" --max-warnings 1216",
"lint": "npm run lint-cmd -- --cache",
"lint-fix": "npm run lint -- --fix",
"lint-errors": "npm run lint -- --quiet",
@ -32,10 +32,10 @@
"@angular/router": "14.0.4",
"@ngneat/reactive-forms": "5.0.0",
"@ngneat/until-destroy": "9.0.0",
"@s-libs/js-core": "13.1.0",
"@s-libs/micro-dash": "13.1.0",
"@s-libs/ng-core": "13.1.0",
"@s-libs/rxjs-core": "13.1.0",
"@s-libs/js-core": "14.0.0",
"@s-libs/micro-dash": "14.0.0",
"@s-libs/ng-core": "14.0.0",
"@s-libs/rxjs-core": "14.0.0",
"@vality/deanonimus-proto": "1.0.1-c9a6cae.0",
"@vality/domain-proto": "1.0.1-3efe7df.0",
"@vality/dominant-cache-proto": "1.0.1-5b29d81.0",
@ -46,7 +46,7 @@
"@vality/messages-proto": "1.0.1-8c5435c.0",
"@vality/payout-manager-proto": "1.0.1-dbed280.0",
"@vality/repairer-proto": "1.0.1-675b6f4.0",
"@vality/thrift-ts": "2.2.2-e8bc2ab.0",
"@vality/thrift-ts": "2.4.1-8ad5123.0",
"@vality/woody": "0.1.1",
"angular-file": "3.6.0",
"angular2-prettyjson": "3.0.1",
@ -54,10 +54,10 @@
"element-resize-detector": "1.2.4",
"humanize-duration": "3.21.0",
"jsonc-parser": "2.0.2",
"keycloak-angular": "9.0.0",
"keycloak-js": "14.0.0",
"lodash-es": "4.17.15",
"moment": "2.22.2",
"keycloak-angular": "12.0.0",
"keycloak-js": "18.0.1",
"lodash-es": "4.17.21",
"moment": "2.29.4",
"monaco-editor": "0.21.2",
"ngx-mat-select-search": "4.2.0",
"rxjs": "7.5.4",
@ -77,34 +77,32 @@
"@angular-eslint/template-parser": "14.0.0",
"@angular/cli": "14.0.5",
"@angular/compiler-cli": "14.0.4",
"@types/del": "4.0.0",
"@types/element-resize-detector": "1.1.3",
"@types/humanize-duration": "3.18.0",
"@types/jasmine": "3.6.2",
"@types/jasmine": "4.0.3",
"@types/jwt-decode": "2.2.1",
"@types/lodash-es": "4.17.3",
"@types/lodash-es": "4.17.6",
"@types/node": "16.4.12",
"@types/uuid": "3.4.3",
"@typescript-eslint/eslint-plugin": "^5.29.0",
"@typescript-eslint/parser": "^5.29.0",
"del": "5.1.0",
"dotenv": "16.0.0",
"eslint": "^8.18.0",
"eslint": "8.20.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jasmine": "4.1.3",
"eslint-plugin-jsdoc": "37.6.1",
"eslint-plugin-jsdoc": "39.3.3",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-unused-imports": "2.0.0",
"eslint-plugin-you-dont-need-lodash-underscore": "6.12.0",
"jasmine-core": "3.6.0",
"jasmine-spec-reporter": "5.0.2",
"jasmine-core": "4.2.0",
"jasmine-spec-reporter": "7.0.0",
"jwt-decode": "2.2.0",
"karma": "6.3.4",
"karma-chrome-launcher": "3.1.0",
"karma": "6.4.0",
"karma-chrome-launcher": "3.1.1",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jasmine": "4.0.1",
"karma-jasmine-html-reporter": "1.5.3",
"karma-jasmine": "5.1.0",
"karma-jasmine-html-reporter": "2.0.0",
"ngx-build-plus": "14.0.0",
"prettier": "2.6.1",
"ts-mockito": "2.6.1",

View File

@ -1,6 +1,5 @@
import { Component, Injector, Input, OnChanges } from '@angular/core';
import { ValidationErrors, Validator } from '@angular/forms';
import { WrappedFormControlSuperclass } from '@s-libs/ng-core';
import { Validator } from '@angular/forms';
import { Claim } from '@vality/domain-proto/lib/claim_management';
import { Party } from '@vality/domain-proto/lib/domain';
import { from, Observable } from 'rxjs';
@ -8,7 +7,7 @@ import { map } from 'rxjs/operators';
import { ComponentChanges, MetadataFormExtension } from '@cc/app/shared';
import { DomainMetadataFormExtensionsService } from '@cc/app/shared/services/domain-metadata-form-extensions';
import { createControlProviders } from '@cc/utils';
import { createControlProviders, ValidatedFormControlSuperclass } from '@cc/utils';
import { createPartyClaimMetadataFormExtensions } from './utils/create-party-claim-metadata-form-extensions';
@ -18,7 +17,7 @@ import { createPartyClaimMetadataFormExtensions } from './utils/create-party-cla
providers: createControlProviders(ModificationFormComponent),
})
export class ModificationFormComponent
extends WrappedFormControlSuperclass<unknown>
extends ValidatedFormControlSuperclass<unknown>
implements Validator, OnChanges
{
@Input() party: Party;
@ -46,8 +45,4 @@ export class ModificationFormComponent
);
}
}
validate(): ValidationErrors | null {
return this.control.errors;
}
}

View File

@ -16,7 +16,6 @@ import { filter, map, share, switchMap } from 'rxjs/operators';
import { PartyManagementWithUserService } from '@cc/app/api/payment-processing';
import { ComponentChanges } from '@cc/app/shared/utils';
import { createControlProviders, ValidatedControlSuperclass } from '@cc/utils/forms';
import { RequiredSuper } from '@cc/utils/required-super';
@UntilDestroy()
@Component({
@ -65,7 +64,7 @@ export class ShopFieldComponent<M extends boolean = boolean>
}
}
ngOnInit(): RequiredSuper {
ngOnInit() {
this.shops$
.pipe(
filter(
@ -76,6 +75,6 @@ export class ShopFieldComponent<M extends boolean = boolean>
.subscribe(() => {
this.control.setValue(null);
});
return super.ngOnInit();
super.ngOnInit();
}
}

View File

@ -11,13 +11,13 @@ import {
} from '@angular/core';
import { FormControl } from '@ngneat/reactive-forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { FormComponentSuperclass, provideValueAccessor } from '@s-libs/ng-core';
import { FormComponentSuperclass } from '@s-libs/ng-core';
import { coerceBoolean } from 'coerce-property';
import { BehaviorSubject, combineLatest, defer, Observable } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { ComponentChanges } from '@cc/app/shared/utils';
import { getFormValueChanges } from '@cc/utils/forms';
import { createControlProviders, getFormValueChanges } from '@cc/utils/forms';
import { SelectSearchFieldOptions, SELECT_SEARCH_FIELD_OPTIONS } from './tokens';
import { Option } from './types';
@ -28,7 +28,7 @@ import { filterOptions } from './utils';
selector: 'cc-select-search-field',
templateUrl: 'select-search-field.component.html',
styleUrls: ['select-search-field.component.scss'],
providers: [provideValueAccessor(SelectSearchFieldComponent)],
providers: createControlProviders(SelectSearchFieldComponent),
})
export class SelectSearchFieldComponent<Value>
extends FormComponentSuperclass<Value>

View File

@ -1,4 +1,5 @@
export * from './validated-control-superclass.directive';
export * from './provide-validator';
export * from './create-control-providers';
export { getErrorsTree } from '@cc/utils/forms/validated-control-superclass/utils/get-errors-tree';
export * from './utils/get-errors-tree';
export * from './validated-form-control-superclass.directive';

View File

@ -13,14 +13,15 @@ export function getErrorsTree(control: AbstractControl): ValidationErrors | null
const errors: ValidationErrors = Object.assign({}, control.errors);
if (hasControls(control)) {
if (Array.isArray(control.controls)) {
errors.formArrayErrors = control.controls.map((c) => getErrorsTree(c));
errors.formArrayErrors = control.controls
.map((c: AbstractControl) => getErrorsTree(c))
.filter(Boolean);
} else {
errors.formGroupErrors = Object.fromEntries(
Array.from(Object.entries(control.controls)).map(([k, c]) => [
k,
getErrorsTree(c as AbstractControl),
])
);
Array.from(Object.entries(control.controls))
.map(([k, c]) => [k, getErrorsTree(c as AbstractControl)])
.filter(([, v]) => !!v)
) as ValidationErrors;
}
}
return errors;

View File

@ -1,9 +1,8 @@
import { Directive, OnInit } from '@angular/core';
import { ValidationErrors, Validator } from '@angular/forms';
import { FormControl } from '@ngneat/reactive-forms';
import { WrappedControlSuperclass } from '@s-libs/ng-core';
import { EMPTY, Observable } from 'rxjs';
import { REQUIRED_SUPER, RequiredSuper } from '../../required-super';
import { getValue } from '../get-value';
import { getErrorsTree } from './utils/get-errors-tree';
@ -14,16 +13,27 @@ export abstract class ValidatedControlSuperclass<OuterType, InnerType = OuterTyp
{
protected emptyValue: InnerType;
ngOnInit(): RequiredSuper {
ngOnInit() {
this.emptyValue = getValue(this.control) as InnerType;
super.ngOnInit();
return REQUIRED_SUPER;
}
validate(): ValidationErrors | null {
return getErrorsTree(this.control);
}
protected setUpOuterToInnerErrors$(
_outer$: Observable<ValidationErrors>
): Observable<ValidationErrors> {
return EMPTY;
}
protected setUpInnerToOuterErrors$(
_inner$: Observable<ValidationErrors>
): Observable<ValidationErrors> {
return EMPTY;
}
protected outerToInner(outer: OuterType): InnerType {
if (!outer && 'controls' in this.control) {
return this.emptyValue;
@ -31,11 +41,3 @@ export abstract class ValidatedControlSuperclass<OuterType, InnerType = OuterTyp
return outer as never;
}
}
@Directive()
export class ValidatedFormControlSuperclass<
OuterType,
InnerType = OuterType
> extends ValidatedControlSuperclass<OuterType, InnerType> {
control = new FormControl<InnerType>();
}

View File

@ -0,0 +1,30 @@
import { Directive } from '@angular/core';
import { ValidationErrors } from '@angular/forms';
import { FormControl } from '@ngneat/reactive-forms';
import { WrappedControlSuperclass } from '@s-libs/ng-core';
import { EMPTY, Observable } from 'rxjs';
@Directive()
export class ValidatedFormControlSuperclass<
OuterType,
InnerType = OuterType
> extends WrappedControlSuperclass<OuterType, InnerType> {
// TODO: Validation sometimes doesn't work (is not forwarded higher by nesting) with Angular FormControl
control = new FormControl<InnerType>();
validate(): ValidationErrors | null {
return this.control.errors;
}
protected setUpOuterToInnerErrors$(
_outer$: Observable<ValidationErrors>
): Observable<ValidationErrors> {
return EMPTY;
}
protected setUpInnerToOuterErrors$(
_inner$: Observable<ValidationErrors>
): Observable<ValidationErrors> {
return EMPTY;
}
}

View File

@ -17,7 +17,6 @@ export * from './has-active-fragments';
export * from './poll';
export * from './boolean-delay';
export * from './forms';
export * from './required-super';
export * from './operators';
export * from './get-enum-keys';
export * from './is-nil-or-empty-string';

View File

@ -1 +0,0 @@
export * from './required-super';

View File

@ -1,10 +0,0 @@
/**
* https://github.com/microsoft/TypeScript/issues/21388
*/
export const REQUIRED_SUPER = 'RequiredSuper' as const;
/**
* If you're here, you probably need to return the parent
* class's implementation, e.g. return super.ngOnInit();
*/
export type RequiredSuper = typeof REQUIRED_SUPER;