From 572231bf49cdc8101e9907cceec3f54eaa972bf4 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 13 Jan 2026 08:47:07 +0000 Subject: [PATCH] AAE-41225 update typescript target to es2022 and fix FormService propagation (#11508) * update targets * update targets * fixed FormService propagation [ci:force] * fixed FormService propagation [ci:force] --- lib/cli/tsconfig.json | 4 +- lib/content-services/tsconfig.json | 2 +- .../widgets/amount/amount.widget.ts | 4 +- .../widgets/base-viewer/base-viewer.widget.ts | 5 -- .../widgets/button/button.widget.ts | 5 -- .../widgets/checkbox/checkbox.widget.ts | 9 +-- .../widgets/decimal/decimal.component.ts | 7 +-- .../display-text/display-text.widget.ts | 7 +-- .../widgets/error/error.component.ts | 6 -- .../widgets/hyperlink/hyperlink.widget.ts | 5 -- .../components/widgets/json/json.widget.ts | 7 +-- .../multiline-text/multiline-text.widget.ts | 7 +-- .../widgets/number/number.widget.ts | 7 +-- .../components/widgets/text/text.widget.ts | 5 -- .../widgets/unknown/unknown.widget.ts | 7 +-- .../widgets/widget.component.spec.ts | 9 ++- .../components/widgets/widget.component.ts | 4 +- lib/core/tsconfig.json | 2 +- lib/core/tsconfig.nx.migrations.json | 56 +++++++++---------- lib/core/tsconfig.schematics.json | 50 ++++++++--------- lib/eslint-angular/tsconfig.json | 37 +++++------- lib/extensions/tsconfig.json | 2 +- lib/insights/tsconfig.json | 2 +- lib/js-api/tsconfig.json | 4 +- lib/js-api/tsconfig/tsconfig.types.json | 18 +++--- .../attach-file-cloud-widget.component.ts | 5 -- .../widgets/data-table/data-table.widget.ts | 8 +-- .../display-external-property.widget.ts | 8 +-- .../display-rich-text.widget.ts | 6 +- .../widgets/file-viewer/file-viewer.widget.ts | 8 +-- .../widgets/group/group-cloud.widget.ts | 6 +- .../widgets/people/people-cloud.widget.ts | 6 +- .../properties-viewer.widget.ts | 6 +- .../radio-buttons-cloud.widget.spec.ts | 6 +- .../radio-buttons-cloud.widget.ts | 6 +- .../widgets/upload/upload-cloud.widget.ts | 6 +- lib/process-services-cloud/tsconfig.json | 2 +- lib/process-services-cloud/tsconfig.spec.json | 2 +- .../attach-file-widget.component.spec.ts | 16 +++--- .../attach-file-widget.component.ts | 8 +-- .../form/widgets/document/document.widget.ts | 6 +- .../dynamic-table/dynamic-table.widget.ts | 15 ++--- .../widgets/file-viewer/file-viewer.widget.ts | 8 +-- .../functional-group.widget.ts | 9 ++- .../lib/form/widgets/people/people.widget.ts | 12 +--- .../radio-buttons.widget.spec.ts | 5 +- .../radio-buttons/radio-buttons.widget.ts | 13 ++--- .../typeahead/typeahead.widget.spec.ts | 8 +-- .../widgets/typeahead/typeahead.widget.ts | 13 ++--- .../lib/form/widgets/upload/upload.widget.ts | 9 ++- lib/process-services/tsconfig.json | 2 +- tsconfig.json | 4 +- 52 files changed, 159 insertions(+), 315 deletions(-) diff --git a/lib/cli/tsconfig.json b/lib/cli/tsconfig.json index 0bb5bfa9e3..6cdc8354de 100644 --- a/lib/cli/tsconfig.json +++ b/lib/cli/tsconfig.json @@ -16,8 +16,8 @@ "rootDir": ".", "skipLibCheck": true, "strictNullChecks": false, - "target": "es2018", - "lib": ["es2018", "dom"], + "target": "es2022", + "lib": ["es2022", "dom"], "baseUrl": ".", "typeRoots": ["node_modules/@types", "../../node_modules/@types"], "types": ["node"], diff --git a/lib/content-services/tsconfig.json b/lib/content-services/tsconfig.json index 93cbd20d23..40a6ff9fae 100644 --- a/lib/content-services/tsconfig.json +++ b/lib/content-services/tsconfig.json @@ -18,7 +18,7 @@ ], "compilerOptions": { "baseUrl": "src", - "target": "es2020" + "target": "es2022" }, "angularCompilerOptions": { "skipTemplateCodegen": true, diff --git a/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts b/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts index 6ebb0f5901..861e5e352d 100644 --- a/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts +++ b/lib/core/src/lib/form/components/widgets/amount/amount.widget.ts @@ -23,7 +23,6 @@ import { FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { ErrorWidgetComponent } from '../error/error.component'; import { WidgetComponent } from '../widget.component'; import { filter, isObservable, Observable } from 'rxjs'; @@ -87,12 +86,11 @@ export class AmountWidgetComponent extends WidgetComponent implements OnInit { } constructor( - public formService: FormService, @Optional() @Inject(ADF_AMOUNT_SETTINGS) settings: Observable | AmountWidgetSettings, private currencyPipe: CurrencyPipe, private translationService: TranslationService ) { - super(formService); + super(); if (isObservable(settings)) { settings.pipe(takeUntilDestroyed()).subscribe((data: AmountWidgetSettings) => { this.updateSettingsBasedProperties(data); diff --git a/lib/core/src/lib/form/components/widgets/base-viewer/base-viewer.widget.ts b/lib/core/src/lib/form/components/widgets/base-viewer/base-viewer.widget.ts index 26999a4864..978709bcc3 100644 --- a/lib/core/src/lib/form/components/widgets/base-viewer/base-viewer.widget.ts +++ b/lib/core/src/lib/form/components/widgets/base-viewer/base-viewer.widget.ts @@ -18,7 +18,6 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { TranslatePipe } from '@ngx-translate/core'; import { ViewerComponent } from '../../../../viewer'; -import { FormService } from '../../../services/form.service'; import { ErrorWidgetComponent } from '../error/error.component'; import { WidgetComponent } from '../widget.component'; @@ -35,10 +34,6 @@ import { WidgetComponent } from '../widget.component'; encapsulation: ViewEncapsulation.None }) export class BaseViewerWidgetComponent extends WidgetComponent implements OnInit { - constructor(formService: FormService) { - super(formService); - } - ngOnInit(): void { if (this.field?.value) { if (Array.isArray(this.field.value) && this.field.value.length > 0) { diff --git a/lib/core/src/lib/form/components/widgets/button/button.widget.ts b/lib/core/src/lib/form/components/widgets/button/button.widget.ts index 4add67d219..a93d94a788 100644 --- a/lib/core/src/lib/form/components/widgets/button/button.widget.ts +++ b/lib/core/src/lib/form/components/widgets/button/button.widget.ts @@ -19,7 +19,6 @@ import { Component, ViewEncapsulation } from '@angular/core'; import { WidgetComponent } from '../widget.component'; -import { FormService } from '../../../services/form.service'; import { TranslatePipe } from '@ngx-translate/core'; import { MatButtonModule } from '@angular/material/button'; import { MatTooltipModule } from '@angular/material/tooltip'; @@ -37,10 +36,6 @@ import { MatTooltipModule } from '@angular/material/tooltip'; export class ButtonWidgetComponent extends WidgetComponent { readonly tooltipShowDelay: number = 500; - constructor(public formService: FormService) { - super(formService); - } - get hostClasses(): string { return `adf-button-widget ${this.field?.className || ''}`; } diff --git a/lib/core/src/lib/form/components/widgets/checkbox/checkbox.widget.ts b/lib/core/src/lib/form/components/widgets/checkbox/checkbox.widget.ts index 066974e24e..50914648ca 100644 --- a/lib/core/src/lib/form/components/widgets/checkbox/checkbox.widget.ts +++ b/lib/core/src/lib/form/components/widgets/checkbox/checkbox.widget.ts @@ -22,7 +22,6 @@ import { Component, ViewEncapsulation } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { ErrorWidgetComponent } from '../error/error.component'; import { WidgetComponent } from '../widget.component'; @@ -51,10 +50,4 @@ import { WidgetComponent } from '../widget.component'; imports: [NgClass, MatCheckboxModule, FormsModule, TranslatePipe, ErrorWidgetComponent, NgIf], encapsulation: ViewEncapsulation.None }) -export class CheckboxWidgetComponent extends WidgetComponent { - checkboxValue: boolean; - - constructor(public formService: FormService) { - super(formService); - } -} +export class CheckboxWidgetComponent extends WidgetComponent {} diff --git a/lib/core/src/lib/form/components/widgets/decimal/decimal.component.ts b/lib/core/src/lib/form/components/widgets/decimal/decimal.component.ts index 1bdbd00fa2..8a2c1cd51e 100644 --- a/lib/core/src/lib/form/components/widgets/decimal/decimal.component.ts +++ b/lib/core/src/lib/form/components/widgets/decimal/decimal.component.ts @@ -21,7 +21,6 @@ import { FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { ErrorWidgetComponent } from '../error/error.component'; import { WidgetComponent } from '../widget.component'; @@ -43,8 +42,4 @@ import { WidgetComponent } from '../widget.component'; imports: [NgIf, TranslatePipe, MatFormFieldModule, MatInputModule, FormsModule, ErrorWidgetComponent], encapsulation: ViewEncapsulation.None }) -export class DecimalWidgetComponent extends WidgetComponent { - constructor(public formService: FormService) { - super(formService); - } -} +export class DecimalWidgetComponent extends WidgetComponent {} diff --git a/lib/core/src/lib/form/components/widgets/display-text/display-text.widget.ts b/lib/core/src/lib/form/components/widgets/display-text/display-text.widget.ts index a421719a26..5735f10767 100644 --- a/lib/core/src/lib/form/components/widgets/display-text/display-text.widget.ts +++ b/lib/core/src/lib/form/components/widgets/display-text/display-text.widget.ts @@ -19,7 +19,6 @@ import { Component, ViewEncapsulation } from '@angular/core'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { WidgetComponent } from '../widget.component'; @Component({ @@ -40,8 +39,4 @@ import { WidgetComponent } from '../widget.component'; imports: [TranslatePipe], encapsulation: ViewEncapsulation.None }) -export class DisplayTextWidgetComponent extends WidgetComponent { - constructor(public formService: FormService) { - super(formService); - } -} +export class DisplayTextWidgetComponent extends WidgetComponent {} diff --git a/lib/core/src/lib/form/components/widgets/error/error.component.ts b/lib/core/src/lib/form/components/widgets/error/error.component.ts index 561cde3e1d..56b4b86343 100644 --- a/lib/core/src/lib/form/components/widgets/error/error.component.ts +++ b/lib/core/src/lib/form/components/widgets/error/error.component.ts @@ -21,7 +21,6 @@ import { animate, state, style, transition, trigger } from '@angular/animations' import { NgIf } from '@angular/common'; import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { ErrorMessageModel } from '../core'; import { WidgetComponent } from '../widget.component'; import { IconModule } from '../../../../icon/icon.module'; @@ -64,13 +63,8 @@ export class ErrorWidgetComponent extends WidgetComponent implements OnChanges { required: string; translateParameters: any = null; - subscriptAnimationState: string = ''; - constructor(public formService: FormService) { - super(formService); - } - ngOnChanges(changes: SimpleChanges) { if (changes['required']) { this.required = changes.required.currentValue; diff --git a/lib/core/src/lib/form/components/widgets/hyperlink/hyperlink.widget.ts b/lib/core/src/lib/form/components/widgets/hyperlink/hyperlink.widget.ts index 2048248042..3e25fd424e 100644 --- a/lib/core/src/lib/form/components/widgets/hyperlink/hyperlink.widget.ts +++ b/lib/core/src/lib/form/components/widgets/hyperlink/hyperlink.widget.ts @@ -19,7 +19,6 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { FormFieldModel } from '../core'; import { WidgetComponent } from '../widget.component'; @@ -48,10 +47,6 @@ export class HyperlinkWidgetComponent extends WidgetComponent implements OnInit linkUrl: string = '#'; linkText: string = null; - constructor(public formService: FormService) { - super(formService); - } - ngOnInit() { if (this.field) { this.linkUrl = this.getHyperlinkUrl(this.field); diff --git a/lib/core/src/lib/form/components/widgets/json/json.widget.ts b/lib/core/src/lib/form/components/widgets/json/json.widget.ts index 98c761b32f..add918be27 100644 --- a/lib/core/src/lib/form/components/widgets/json/json.widget.ts +++ b/lib/core/src/lib/form/components/widgets/json/json.widget.ts @@ -15,11 +15,10 @@ * limitations under the License. */ -import { Component, ViewEncapsulation } from '@angular/core'; +import { Component, inject, ViewEncapsulation } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatDialog } from '@angular/material/dialog'; import { EditJsonDialogSettings, EditJsonDialogComponent } from '../../../../dialogs/edit-json/edit-json.dialog'; -import { FormService } from '../../../services/form.service'; import { WidgetComponent } from '../widget.component'; import { MatFormFieldModule } from '@angular/material/form-field'; import { TranslatePipe } from '@ngx-translate/core'; @@ -42,9 +41,7 @@ import { TranslatePipe } from '@ngx-translate/core'; encapsulation: ViewEncapsulation.None }) export class JsonWidgetComponent extends WidgetComponent { - constructor(public formService: FormService, private dialog: MatDialog) { - super(formService); - } + private dialog = inject(MatDialog); view() { const rawValue = this.field.value; diff --git a/lib/core/src/lib/form/components/widgets/multiline-text/multiline-text.widget.ts b/lib/core/src/lib/form/components/widgets/multiline-text/multiline-text.widget.ts index 6a28b421aa..11334b1af1 100644 --- a/lib/core/src/lib/form/components/widgets/multiline-text/multiline-text.widget.ts +++ b/lib/core/src/lib/form/components/widgets/multiline-text/multiline-text.widget.ts @@ -23,7 +23,6 @@ import { FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { ErrorWidgetComponent } from '../error/error.component'; import { WidgetComponent } from '../widget.component'; @@ -45,8 +44,4 @@ import { WidgetComponent } from '../widget.component'; imports: [MatFormFieldModule, NgIf, TranslatePipe, MatInputModule, FormsModule, ErrorWidgetComponent], encapsulation: ViewEncapsulation.None }) -export class MultilineTextWidgetComponentComponent extends WidgetComponent { - constructor(public formService: FormService) { - super(formService); - } -} +export class MultilineTextWidgetComponentComponent extends WidgetComponent {} diff --git a/lib/core/src/lib/form/components/widgets/number/number.widget.ts b/lib/core/src/lib/form/components/widgets/number/number.widget.ts index 88cdb62601..0a6e818dcc 100644 --- a/lib/core/src/lib/form/components/widgets/number/number.widget.ts +++ b/lib/core/src/lib/form/components/widgets/number/number.widget.ts @@ -18,13 +18,12 @@ /* eslint-disable @angular-eslint/component-selector, @angular-eslint/no-input-rename */ import { NgIf } from '@angular/common'; -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { TranslatePipe } from '@ngx-translate/core'; import { DecimalNumberPipe } from '../../../../pipes'; -import { FormService } from '../../../services/form.service'; import { ErrorWidgetComponent } from '../error/error.component'; import { WidgetComponent } from '../widget.component'; @@ -50,9 +49,7 @@ import { WidgetComponent } from '../widget.component'; export class NumberWidgetComponent extends WidgetComponent implements OnInit { displayValue: number; - constructor(public formService: FormService, private decimalNumberPipe: DecimalNumberPipe) { - super(formService); - } + private decimalNumberPipe = inject(DecimalNumberPipe); ngOnInit() { if (this.field.readOnly) { diff --git a/lib/core/src/lib/form/components/widgets/text/text.widget.ts b/lib/core/src/lib/form/components/widgets/text/text.widget.ts index 55f4c822e1..11f5d99c8d 100644 --- a/lib/core/src/lib/form/components/widgets/text/text.widget.ts +++ b/lib/core/src/lib/form/components/widgets/text/text.widget.ts @@ -23,7 +23,6 @@ import { FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { TranslatePipe } from '@ngx-translate/core'; -import { FormService } from '../../../services/form.service'; import { ErrorWidgetComponent } from '../error/error.component'; import { WidgetComponent } from '../widget.component'; import { InputMaskDirective } from './text-mask.component'; @@ -51,10 +50,6 @@ export class TextWidgetComponent extends WidgetComponent implements OnInit { placeholder: string; isMaskReversed: boolean; - constructor(public formService: FormService) { - super(formService); - } - ngOnInit() { if (this.field.params) { this.mask = this.field.params['inputMask']; diff --git a/lib/core/src/lib/form/components/widgets/unknown/unknown.widget.ts b/lib/core/src/lib/form/components/widgets/unknown/unknown.widget.ts index 03d70e1729..afdec731a9 100644 --- a/lib/core/src/lib/form/components/widgets/unknown/unknown.widget.ts +++ b/lib/core/src/lib/form/components/widgets/unknown/unknown.widget.ts @@ -19,7 +19,6 @@ import { Component, ViewEncapsulation } from '@angular/core'; import { MatListModule } from '@angular/material/list'; -import { FormService } from '../../../services/form.service'; import { WidgetComponent } from '../widget.component'; import { IconModule } from '../../../../icon/icon.module'; @@ -48,8 +47,4 @@ import { IconModule } from '../../../../icon/icon.module'; imports: [MatListModule, IconModule], encapsulation: ViewEncapsulation.None }) -export class UnknownWidgetComponent extends WidgetComponent { - constructor(public formService: FormService) { - super(formService); - } -} +export class UnknownWidgetComponent extends WidgetComponent {} diff --git a/lib/core/src/lib/form/components/widgets/widget.component.spec.ts b/lib/core/src/lib/form/components/widgets/widget.component.spec.ts index 184c370638..c6b331e0d5 100644 --- a/lib/core/src/lib/form/components/widgets/widget.component.spec.ts +++ b/lib/core/src/lib/form/components/widgets/widget.component.spec.ts @@ -20,17 +20,20 @@ import { filter } from 'rxjs/operators'; import { FormRulesEvent } from '../../events'; import { FormFieldModel, FormModel } from './core'; import { WidgetComponent } from './widget.component'; +import { FormService } from '@alfresco/adf-core'; describe('WidgetComponent', () => { let widget: WidgetComponent; let fixture: ComponentFixture; let element: HTMLElement; + let formService: FormService; beforeEach(() => { TestBed.configureTestingModule({ imports: [WidgetComponent] }); fixture = TestBed.createComponent(WidgetComponent); + formService = fixture.debugElement.injector.get(FormService); element = fixture.nativeElement; widget = fixture.componentInstance; @@ -40,7 +43,7 @@ describe('WidgetComponent', () => { describe('Events', () => { it('should click event be redirect on the form event service', fakeAsync(() => { - widget.formService.formEvents.subscribe((event) => { + formService.formEvents.subscribe((event) => { expect(event).toBeTruthy(); }); @@ -48,7 +51,7 @@ describe('WidgetComponent', () => { })); it('should click event be redirect on the form rules event service', fakeAsync(() => { - widget.formService.formRulesEvent.pipe(filter((event) => event.type === 'click')).subscribe((event) => { + formService.formRulesEvent.pipe(filter((event) => event.type === 'click')).subscribe((event) => { expect(event).toBeTruthy(); }); @@ -95,7 +98,7 @@ describe('WidgetComponent', () => { const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' }); let lastValue: FormRulesEvent; - widget.formService.formRulesEvent.subscribe((event) => (lastValue = event)); + formService.formRulesEvent.subscribe((event) => (lastValue = event)); widget.onFieldChanged(fakeField); expect(lastValue.type).toEqual('fieldValueChanged'); diff --git a/lib/core/src/lib/form/components/widgets/widget.component.ts b/lib/core/src/lib/form/components/widgets/widget.component.ts index 9f5ba71278..a328774bae 100644 --- a/lib/core/src/lib/form/components/widgets/widget.component.ts +++ b/lib/core/src/lib/form/components/widgets/widget.component.ts @@ -17,7 +17,7 @@ /* eslint-disable @angular-eslint/component-selector */ -import { AfterViewInit, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'; +import { AfterViewInit, Component, EventEmitter, Input, Output, ViewEncapsulation, inject } from '@angular/core'; import { FormFieldEvent, FormRulesEvent } from '../../events'; import { FormService } from '../../services/form.service'; import { FormFieldModel } from './core'; @@ -60,7 +60,7 @@ export class WidgetComponent implements AfterViewInit { touched: boolean = false; - constructor(public formService?: FormService) {} + protected formService = inject(FormService); hasField(): boolean { return !!this.field; diff --git a/lib/core/tsconfig.json b/lib/core/tsconfig.json index a93df7905c..8474bf7f56 100644 --- a/lib/core/tsconfig.json +++ b/lib/core/tsconfig.json @@ -15,7 +15,7 @@ ], "compilerOptions": { "baseUrl": "src", - "target": "es2020" + "target": "es2022" }, "angularCompilerOptions": { "skipTemplateCodegen": true, diff --git a/lib/core/tsconfig.nx.migrations.json b/lib/core/tsconfig.nx.migrations.json index 39388c6bfe..5a1cdafd19 100644 --- a/lib/core/tsconfig.nx.migrations.json +++ b/lib/core/tsconfig.nx.migrations.json @@ -1,32 +1,26 @@ { - "compilerOptions": { - "baseUrl": ".", - "lib": [ - "es2018", - "dom" - ], - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitThis": true, - "noUnusedParameters": true, - "noUnusedLocals": true, - "rootDir": "./migrations", - "outDir": "../../dist/libs/core/migrations", - "skipDefaultLibCheck": true, - "skipLibCheck": true, - "sourceMap": true, - "strictNullChecks": true, - "target": "es2015", - "typeRoots": ["node_modules/@types"], - "types": ["node"] - }, - "include": [ - "migrations/**/*" - ], - "files": ["schematics/migrations/7_0_0/index.ts"] - } - + "compilerOptions": { + "baseUrl": ".", + "lib": ["es2022", "dom"], + "declaration": true, + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedParameters": true, + "noUnusedLocals": true, + "rootDir": "./migrations", + "outDir": "../../dist/libs/core/migrations", + "skipDefaultLibCheck": true, + "skipLibCheck": true, + "sourceMap": true, + "strictNullChecks": true, + "target": "es2022", + "typeRoots": ["node_modules/@types"], + "types": ["node"] + }, + "include": ["migrations/**/*"], + "files": ["schematics/migrations/7_0_0/index.ts"] +} diff --git a/lib/core/tsconfig.schematics.json b/lib/core/tsconfig.schematics.json index cf80a81325..a2cf96fc8e 100644 --- a/lib/core/tsconfig.schematics.json +++ b/lib/core/tsconfig.schematics.json @@ -1,29 +1,23 @@ { - "compilerOptions": { - "baseUrl": ".", - "lib": [ - "es2018", - "dom" - ], - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noImplicitThis": true, - "noUnusedParameters": true, - "noUnusedLocals": true, - "rootDir": "./schematics", - "outDir": "../../dist/libs/core/schematics", - "skipDefaultLibCheck": true, - "skipLibCheck": true, - "sourceMap": true, - "strictNullChecks": true, - "target": "es2015", - "types": ["node"] - }, - "include": [ - "schematics/**/*" - ] - } - + "compilerOptions": { + "baseUrl": ".", + "lib": ["es2022", "dom"], + "declaration": true, + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitThis": true, + "noUnusedParameters": true, + "noUnusedLocals": true, + "rootDir": "./schematics", + "outDir": "../../dist/libs/core/schematics", + "skipDefaultLibCheck": true, + "skipLibCheck": true, + "sourceMap": true, + "strictNullChecks": true, + "target": "es2022", + "types": ["node"] + }, + "include": ["schematics/**/*"] +} diff --git a/lib/eslint-angular/tsconfig.json b/lib/eslint-angular/tsconfig.json index f5b70d9c2d..bba64192fe 100644 --- a/lib/eslint-angular/tsconfig.json +++ b/lib/eslint-angular/tsconfig.json @@ -1,24 +1,17 @@ { - "compilerOptions": { - "target": "ES2019", - "module": "commonjs", - "sourceMap": false, - "outDir": "dist", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "noUnusedLocals": true, - "skipLibCheck": true, - "baseUrl": "src", - "types": [ - "node", "@typescript-eslint/utils" - ] - }, - "include": [ - "**/*" - ], - "exclude": [ - "node_modules", - "tests" - ] + "compilerOptions": { + "target": "ES2022", + "module": "commonjs", + "sourceMap": false, + "outDir": "dist", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noUnusedLocals": true, + "skipLibCheck": true, + "baseUrl": "src", + "types": ["node", "@typescript-eslint/utils"] + }, + "include": ["**/*"], + "exclude": ["node_modules", "tests"] } diff --git a/lib/extensions/tsconfig.json b/lib/extensions/tsconfig.json index 204cc68ba2..446c749a6c 100644 --- a/lib/extensions/tsconfig.json +++ b/lib/extensions/tsconfig.json @@ -15,7 +15,7 @@ ], "compilerOptions": { "baseUrl": "src", - "target": "es2020" + "target": "es2022" }, "angularCompilerOptions": { "skipTemplateCodegen": true, diff --git a/lib/insights/tsconfig.json b/lib/insights/tsconfig.json index 204cc68ba2..446c749a6c 100644 --- a/lib/insights/tsconfig.json +++ b/lib/insights/tsconfig.json @@ -15,7 +15,7 @@ ], "compilerOptions": { "baseUrl": "src", - "target": "es2020" + "target": "es2022" }, "angularCompilerOptions": { "skipTemplateCodegen": true, diff --git a/lib/js-api/tsconfig.json b/lib/js-api/tsconfig.json index c4d1b98a8f..b1e7c0104d 100644 --- a/lib/js-api/tsconfig.json +++ b/lib/js-api/tsconfig.json @@ -14,9 +14,9 @@ "allowSyntheticDefaultImports": true, "moduleResolution": "node", "stripInternal": false, - "target": "es2015", + "target": "es2022", "outDir": "./.out", - "lib": ["es2018", "dom"], + "lib": ["es2022", "dom"], "typeRoots": ["node_modules/@types"], "types": [] }, diff --git a/lib/js-api/tsconfig/tsconfig.types.json b/lib/js-api/tsconfig/tsconfig.types.json index 41eb505222..6c2854787c 100644 --- a/lib/js-api/tsconfig/tsconfig.types.json +++ b/lib/js-api/tsconfig/tsconfig.types.json @@ -1,11 +1,11 @@ { - "extends": "./tsconfig.base.json", - "compilerOptions": { - "module": "es2015", - "target": "esnext", - "removeComments": false, - "declaration": true, - "declarationDir": "../../../dist/libs/js-api/typings", - "emitDeclarationOnly": true - } + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "es2022", + "target": "esnext", + "removeComments": false, + "declaration": true, + "declarationDir": "../../../dist/libs/js-api/typings", + "emitDeclarationOnly": true + } } diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts index 8d89d0157b..c321546b2a 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/attach-file/attach-file-cloud-widget.component.ts @@ -19,7 +19,6 @@ import { Component, EventEmitter, inject, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { - FormService, FormValues, ContentLinkModel, AppConfigService, @@ -80,10 +79,6 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i } displayedColumns = ['icon', 'fileName', 'title', 'action']; - constructor(formService: FormService) { - super(formService); - } - ngOnInit() { super.ngOnInit(); if (this.hasFile && this.field.value.length > 0) { diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table.widget.ts index a5efc574b1..42f60a457d 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/data-table/data-table.widget.ts @@ -17,10 +17,9 @@ /* eslint-disable @angular-eslint/component-selector */ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core'; import { WidgetComponent, - FormService, FormBaseModule, DataRow, DataColumn, @@ -64,10 +63,7 @@ export class DataTableWidgetComponent extends WidgetComponent implements OnInit private variableName: string; private defaultResponseProperty = 'data'; private pathParserHelper = new DataTablePathParserHelper(); - - constructor(public formService: FormService, private formCloudService: FormCloudService) { - super(formService); - } + private formCloudService = inject(FormCloudService); ngOnInit(): void { this.init(); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/display-external-property/display-external-property.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/display-external-property/display-external-property.widget.ts index 09a061c2c5..b159394bb8 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/display-external-property/display-external-property.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/display-external-property/display-external-property.widget.ts @@ -15,8 +15,8 @@ * limitations under the License. */ -import { ChangeDetectionStrategy, Component, OnInit, ViewEncapsulation } from '@angular/core'; -import { WidgetComponent, FormService, FormBaseModule } from '@alfresco/adf-core'; +import { ChangeDetectionStrategy, Component, inject, OnInit, ViewEncapsulation } from '@angular/core'; +import { WidgetComponent, FormBaseModule } from '@alfresco/adf-core'; import { CommonModule } from '@angular/common'; import { TranslatePipe } from '@ngx-translate/core'; import { FormCloudService } from '../../../services/form-cloud.service'; @@ -49,9 +49,7 @@ export class DisplayExternalPropertyWidgetComponent extends WidgetComponent impl previewState = false; propertyControl: FormControl; - constructor(public readonly formService: FormService, private readonly formCloudService: FormCloudService) { - super(formService); - } + private readonly formCloudService = inject(FormCloudService); ngOnInit(): void { this.initFormControl(); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts index d462c01aae..b937def050 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/display-rich-text/display-rich-text.widget.ts @@ -18,7 +18,7 @@ /* eslint-disable @angular-eslint/component-selector */ import { Component, inject, InjectionToken, OnInit, SecurityContext, ViewEncapsulation } from '@angular/core'; -import { WidgetComponent, FormService } from '@alfresco/adf-core'; +import { WidgetComponent } from '@alfresco/adf-core'; import { DomSanitizer } from '@angular/platform-browser'; import { RichTextParserService } from '../../../services/rich-text-parser.service'; @@ -49,10 +49,6 @@ export class DisplayRichTextWidgetComponent extends WidgetComponent implements O private readonly richTextParserService = inject(RICH_TEXT_PARSER_TOKEN); private readonly sanitizer = inject(DomSanitizer); - constructor(formService: FormService) { - super(formService); - } - ngOnInit(): void { this.parsedHTML = this.richTextParserService.parse(this.field.value); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts index 99570f21f6..19a025f84f 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/file-viewer/file-viewer.widget.ts @@ -16,7 +16,7 @@ */ import { Component, ViewEncapsulation } from '@angular/core'; -import { FormService, BaseViewerWidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; +import { BaseViewerWidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; import { AlfrescoViewerComponent } from '@alfresco/adf-content-services'; import { TranslatePipe } from '@ngx-translate/core'; @@ -29,8 +29,4 @@ import { TranslatePipe } from '@ngx-translate/core'; styleUrls: ['./file-viewer.widget.scss'], encapsulation: ViewEncapsulation.None }) -export class FileViewerWidgetComponent extends BaseViewerWidgetComponent { - constructor(formService: FormService) { - super(formService); - } -} +export class FileViewerWidgetComponent extends BaseViewerWidgetComponent {} diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts index ebfc6e6cc4..9b9e3dbe2a 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/group/group-cloud.widget.ts @@ -16,7 +16,7 @@ */ import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core'; -import { ErrorWidgetComponent, FormService, WidgetComponent } from '@alfresco/adf-core'; +import { ErrorWidgetComponent, WidgetComponent } from '@alfresco/adf-core'; import { UntypedFormControl } from '@angular/forms'; import { filter } from 'rxjs/operators'; import { ComponentSelectionMode } from '../../../../types'; @@ -56,10 +56,6 @@ export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit private readonly destroyRef = inject(DestroyRef); - constructor(formService: FormService) { - super(formService); - } - ngOnInit() { if (this.field) { this.roles = this.field.roles; diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts index 0d847e1cdd..a8bb73ff8a 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/people/people-cloud.widget.ts @@ -16,7 +16,7 @@ */ import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core'; -import { ErrorWidgetComponent, FormService, WidgetComponent } from '@alfresco/adf-core'; +import { ErrorWidgetComponent, WidgetComponent } from '@alfresco/adf-core'; import { UntypedFormControl } from '@angular/forms'; import { filter } from 'rxjs/operators'; import { ComponentSelectionMode } from '../../../../types'; @@ -62,10 +62,6 @@ export class PeopleCloudWidgetComponent extends WidgetComponent implements OnIni private readonly destroyRef = inject(DestroyRef); - constructor(formService: FormService) { - super(formService); - } - ngOnInit() { if (this.field) { this.roles = this.field.roles; diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts index fed3102342..207bbf6ead 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/properties-viewer/properties-viewer.widget.ts @@ -16,7 +16,7 @@ */ import { Component, EventEmitter, Output, ViewEncapsulation } from '@angular/core'; -import { BaseViewerWidgetComponent, ErrorWidgetComponent, FormService } from '@alfresco/adf-core'; +import { BaseViewerWidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; import { Node } from '@alfresco/js-api'; import { PropertiesViewerWrapperComponent } from './properties-viewer-wrapper/properties-viewer-wrapper.component'; import { TranslatePipe } from '@ngx-translate/core'; @@ -35,10 +35,6 @@ export class PropertiesViewerWidgetComponent extends BaseViewerWidgetComponent { @Output() nodeContentLoaded: EventEmitter = new EventEmitter(); - constructor(formService: FormService) { - super(formService); - } - onNodeContentLoaded(node: Node) { this.nodeContentLoaded.emit(node); } diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts index 2754f53eb7..2bf2276da5 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.spec.ts @@ -16,7 +16,7 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormFieldModel, FormFieldOption, FormFieldTypes, FormModel } from '@alfresco/adf-core'; +import { FormFieldModel, FormFieldOption, FormFieldTypes, FormModel, FormService } from '@alfresco/adf-core'; import { FormCloudService } from '../../../services/form-cloud.service'; import { RadioButtonsCloudWidgetComponent } from './radio-buttons-cloud.widget'; import { of, throwError } from 'rxjs'; @@ -29,6 +29,7 @@ describe('RadioButtonsCloudWidgetComponent', () => { let fixture: ComponentFixture; let widget: RadioButtonsCloudWidgetComponent; let formCloudService: FormCloudService; + let formService: FormService; let formUtilsService: FormUtilsService; let element: HTMLElement; let loader: HarnessLoader; @@ -50,6 +51,7 @@ describe('RadioButtonsCloudWidgetComponent', () => { formCloudService = TestBed.inject(FormCloudService); formUtilsService = TestBed.inject(FormUtilsService); fixture = TestBed.createComponent(RadioButtonsCloudWidgetComponent); + formService = fixture.debugElement.injector.get(FormService); widget = fixture.componentInstance; element = fixture.nativeElement; loader = TestbedHarnessEnvironment.loader(fixture); @@ -291,7 +293,7 @@ describe('RadioButtonsCloudWidgetComponent', () => { options: restOption }); fixture.detectChanges(); - const formValueSpy = spyOn(widget.formService.formRulesEvent, 'next'); + const formValueSpy = spyOn(formService.formRulesEvent, 'next'); const radioButton = await loader.getHarness(MatRadioButtonHarness.with({ label: 'opt-name-1' })); await radioButton.check(); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts index f41a8943a0..301cbedfc8 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/radio-buttons/radio-buttons-cloud.widget.ts @@ -18,7 +18,7 @@ /* eslint-disable @angular-eslint/component-selector */ import { Component, DestroyRef, inject, OnInit, ViewEncapsulation } from '@angular/core'; -import { ErrorMessageModel, ErrorWidgetComponent, FormFieldOption, FormService, WidgetComponent } from '@alfresco/adf-core'; +import { ErrorMessageModel, ErrorWidgetComponent, FormFieldOption, WidgetComponent } from '@alfresco/adf-core'; import { FormCloudService } from '../../../services/form-cloud.service'; import { TranslatePipe, TranslateService } from '@ngx-translate/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; @@ -55,10 +55,6 @@ export class RadioButtonsCloudWidgetComponent extends WidgetComponent implements private readonly destroyRef = inject(DestroyRef); - constructor(formService: FormService) { - super(formService); - } - ngOnInit() { if (this.isValidRestConfig() && !this.isReadOnlyForm()) { this.getValuesFromRestApi(); diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/upload/upload-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/upload/upload-cloud.widget.ts index 0742d6f5aa..da6c45b184 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/upload/upload-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/upload/upload-cloud.widget.ts @@ -21,7 +21,7 @@ import { Component, ElementRef, EventEmitter, inject, OnInit, Output, ViewChild, import { Node } from '@alfresco/js-api'; import { Observable, from } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; -import { WidgetComponent, FormService, ThumbnailService, NotificationService, ErrorWidgetComponent, IconModule } from '@alfresco/adf-core'; +import { WidgetComponent, ThumbnailService, NotificationService, ErrorWidgetComponent, IconModule } from '@alfresco/adf-core'; import { ProcessCloudContentService } from '../../../services/process-cloud-content.service'; import { FileSourceTypes, DestinationFolderPathType } from '../../../models/form-cloud-representation.model'; import { VersionManagerUploadData } from '@alfresco/adf-content-services'; @@ -65,10 +65,6 @@ export class UploadCloudWidgetComponent extends WidgetComponent implements OnIni @ViewChild('uploadFiles') fileInput: ElementRef; - constructor(formService: FormService) { - super(formService); - } - ngOnInit() { if (this.field?.value?.length > 0) { this.hasFile = true; diff --git a/lib/process-services-cloud/tsconfig.json b/lib/process-services-cloud/tsconfig.json index 93cbd20d23..40a6ff9fae 100644 --- a/lib/process-services-cloud/tsconfig.json +++ b/lib/process-services-cloud/tsconfig.json @@ -18,7 +18,7 @@ ], "compilerOptions": { "baseUrl": "src", - "target": "es2020" + "target": "es2022" }, "angularCompilerOptions": { "skipTemplateCodegen": true, diff --git a/lib/process-services-cloud/tsconfig.spec.json b/lib/process-services-cloud/tsconfig.spec.json index 6af39a9353..a4222287d3 100644 --- a/lib/process-services-cloud/tsconfig.spec.json +++ b/lib/process-services-cloud/tsconfig.spec.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../dist/out-tsc", - "target": "ES2021", + "target": "ES2022", "useDefineForClassFields": false }, "files": ["src/test.ts"], diff --git a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts index a41078764f..094aa4cca6 100644 --- a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts +++ b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.spec.ts @@ -189,7 +189,7 @@ describe('AttachFileWidgetComponent', () => { processContentService = TestBed.inject(ProcessContentService); downloadService = TestBed.inject(DownloadService); appConfigService = TestBed.inject(AppConfigService); - formService = TestBed.inject(FormService); + formService = fixture.debugElement.injector.get(FormService); attachFileWidgetDialogService = TestBed.inject(AttachFileWidgetDialogService); }); @@ -845,7 +845,7 @@ describe('AttachFileWidgetComponent', () => { value: [] }); - spyOn(widget.formService.formContentClicked, 'next'); + spyOn(formService.formContentClicked, 'next'); }); it('should call formContentClicked when file clicked and it has sourceId', () => { @@ -853,7 +853,7 @@ describe('AttachFileWidgetComponent', () => { widget.onAttachFileClicked(fileWithSourceId); - expect(widget.formService.formContentClicked.next).toHaveBeenCalledWith(fileWithSourceId); + expect(formService.formContentClicked.next).toHaveBeenCalledWith(fileWithSourceId); }); it('should call formContentClicked when file is temporary', () => { @@ -864,7 +864,7 @@ describe('AttachFileWidgetComponent', () => { widget.onAttachFileClicked(regularFile); - expect(widget.formService.formContentClicked.next).toHaveBeenCalledWith(regularFile); + expect(formService.formContentClicked.next).toHaveBeenCalledWith(regularFile); }); it('should fetch getContentPreview when file is neither temporary nor has sourceId', () => { @@ -874,7 +874,7 @@ describe('AttachFileWidgetComponent', () => { widget.onAttachFileClicked(regularFile); expect(processContentService.getContentPreview).toHaveBeenCalledWith(123); - expect(widget.formService.formContentClicked.next).toHaveBeenCalled(); + expect(formService.formContentClicked.next).toHaveBeenCalled(); }); it('should not emit formContentClicked when file has no sourceId and contentAvailable is false', () => { @@ -882,7 +882,7 @@ describe('AttachFileWidgetComponent', () => { widget.onAttachFileClicked(fileWithoutContent); - expect(widget.formService.formContentClicked.next).not.toHaveBeenCalled(); + expect(formService.formContentClicked.next).not.toHaveBeenCalled(); }); it('should not emit formContentClicked when file is external', () => { @@ -890,7 +890,7 @@ describe('AttachFileWidgetComponent', () => { widget.onAttachFileClicked(externalFile); - expect(widget.formService.formContentClicked.next).not.toHaveBeenCalled(); + expect(formService.formContentClicked.next).not.toHaveBeenCalled(); }); it('should not emit formContentClicked when file has no sourceId and isStartProcessPage is true', () => { @@ -899,7 +899,7 @@ describe('AttachFileWidgetComponent', () => { widget.onAttachFileClicked(fileWithoutContent); - expect(widget.formService.formContentClicked.next).not.toHaveBeenCalled(); + expect(formService.formContentClicked.next).not.toHaveBeenCalled(); }); }); }); diff --git a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts index 1a688074ed..6b71a2ca73 100644 --- a/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts +++ b/lib/process-services/src/lib/form/widgets/content-widget/attach-file-widget.component.ts @@ -18,14 +18,13 @@ /* eslint-disable @angular-eslint/component-selector */ import { Component, DestroyRef, inject, isDevMode, OnInit, ViewEncapsulation } from '@angular/core'; -import { AppConfigService, AppConfigValues, DownloadService, ErrorWidgetComponent, FormService, ThumbnailService } from '@alfresco/adf-core'; +import { AppConfigService, AppConfigValues, DownloadService, ErrorWidgetComponent } from '@alfresco/adf-core'; import { AlfrescoIconComponent, ContentNodeDialogService, ContentService } from '@alfresco/adf-content-services'; import { AlfrescoEndpointRepresentation, Node, NodeChildAssociation, RelatedContentRepresentation } from '@alfresco/js-api'; import { from, of, zip } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; import { AttachFileWidgetDialogService } from './attach-file-widget-dialog.service'; import { UploadWidgetComponent } from '../upload/upload.widget'; -import { ProcessContentService } from '../../services/process-content.service'; import { ActivitiContentService } from '../../services/activiti-alfresco.service'; import { CommonModule } from '@angular/common'; import { TranslatePipe } from '@ngx-translate/core'; @@ -53,9 +52,6 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements private readonly destroyRef = inject(DestroyRef); constructor( - public formService: FormService, - public thumbnails: ThumbnailService, - public processContentService: ProcessContentService, private activitiContentService: ActivitiContentService, private contentService: ContentService, private contentDialog: ContentNodeDialogService, @@ -65,7 +61,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements private activatedRoute: ActivatedRoute, private attachDialogService: AttachFileWidgetDialogService ) { - super(formService, thumbnails, processContentService); + super(); } ngOnInit() { diff --git a/lib/process-services/src/lib/form/widgets/document/document.widget.ts b/lib/process-services/src/lib/form/widgets/document/document.widget.ts index e331b5de65..f70bafe26d 100644 --- a/lib/process-services/src/lib/form/widgets/document/document.widget.ts +++ b/lib/process-services/src/lib/form/widgets/document/document.widget.ts @@ -16,7 +16,7 @@ */ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; -import { FormService, WidgetComponent } from '@alfresco/adf-core'; +import { WidgetComponent } from '@alfresco/adf-core'; import { CommonModule } from '@angular/common'; import { ContentWidgetComponent } from './content.widget'; @@ -41,10 +41,6 @@ export class DocumentWidgetComponent extends WidgetComponent implements OnInit { fileId: string = null; hasFile: boolean = false; - constructor(public formService: FormService) { - super(formService); - } - ngOnInit() { if (this.field) { const file = this.field.value; diff --git a/lib/process-services/src/lib/form/widgets/dynamic-table/dynamic-table.widget.ts b/lib/process-services/src/lib/form/widgets/dynamic-table/dynamic-table.widget.ts index cf6485157c..47e784e7cc 100644 --- a/lib/process-services/src/lib/form/widgets/dynamic-table/dynamic-table.widget.ts +++ b/lib/process-services/src/lib/form/widgets/dynamic-table/dynamic-table.widget.ts @@ -17,8 +17,8 @@ /* eslint-disable @angular-eslint/component-selector */ -import { WidgetVisibilityService, WidgetComponent, FormService, ErrorWidgetComponent } from '@alfresco/adf-core'; -import { ChangeDetectorRef, Component, ElementRef, OnInit, ViewEncapsulation } from '@angular/core'; +import { WidgetVisibilityService, WidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; +import { ChangeDetectorRef, Component, ElementRef, inject, OnInit, ViewEncapsulation } from '@angular/core'; import { DynamicTableColumn } from './editors/models/dynamic-table-column.model'; import { DynamicTableRow } from './editors/models/dynamic-table-row.model'; import { DynamicTableModel } from './editors/models/dynamic-table.widget.model'; @@ -55,14 +55,9 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn private selectArrayCode = [32, 0, 13]; - constructor( - public formService: FormService, - public elementRef: ElementRef, - private visibilityService: WidgetVisibilityService, - private cd: ChangeDetectorRef - ) { - super(formService); - } + public elementRef = inject(ElementRef); + private visibilityService = inject(WidgetVisibilityService); + private cd = inject(ChangeDetectorRef); ngOnInit() { if (this.field) { diff --git a/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.ts b/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.ts index 6c1acfdc43..3b5af6062a 100644 --- a/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.ts +++ b/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { BaseViewerWidgetComponent, ErrorWidgetComponent, FormService } from '@alfresco/adf-core'; +import { BaseViewerWidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; import { Component, ViewEncapsulation } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TranslatePipe } from '@ngx-translate/core'; @@ -30,8 +30,4 @@ import { AlfrescoViewerComponent } from '@alfresco/adf-content-services'; styleUrls: ['./file-viewer.widget.scss'], encapsulation: ViewEncapsulation.None }) -export class FileViewerWidgetComponent extends BaseViewerWidgetComponent { - constructor(formService: FormService) { - super(formService); - } -} +export class FileViewerWidgetComponent extends BaseViewerWidgetComponent {} diff --git a/lib/process-services/src/lib/form/widgets/functional-group/functional-group.widget.ts b/lib/process-services/src/lib/form/widgets/functional-group/functional-group.widget.ts index 3d91cd0d39..6a3202c9fb 100644 --- a/lib/process-services/src/lib/form/widgets/functional-group/functional-group.widget.ts +++ b/lib/process-services/src/lib/form/widgets/functional-group/functional-group.widget.ts @@ -17,8 +17,8 @@ /* eslint-disable @angular-eslint/component-selector */ -import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; -import { ErrorWidgetComponent, FormService, GroupModel, WidgetComponent } from '@alfresco/adf-core'; +import { Component, ElementRef, inject, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; +import { ErrorWidgetComponent, GroupModel, WidgetComponent } from '@alfresco/adf-core'; import { catchError, debounceTime, distinctUntilChanged, switchMap, tap } from 'rxjs/operators'; import { merge, of } from 'rxjs'; import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms'; @@ -84,9 +84,8 @@ export class FunctionalGroupWidgetComponent extends WidgetComponent implements O @ViewChild('inputValue', { static: true }) input: ElementRef; - constructor(public peopleProcessService: PeopleProcessService, public formService: FormService, public elementRef: ElementRef) { - super(formService); - } + public peopleProcessService = inject(PeopleProcessService); + public elementRef = inject(ElementRef); ngOnInit() { if (this.field) { diff --git a/lib/process-services/src/lib/form/widgets/people/people.widget.ts b/lib/process-services/src/lib/form/widgets/people/people.widget.ts index e8e6cf9498..79ad583911 100644 --- a/lib/process-services/src/lib/form/widgets/people/people.widget.ts +++ b/lib/process-services/src/lib/form/widgets/people/people.widget.ts @@ -17,8 +17,8 @@ /* eslint-disable @angular-eslint/component-selector */ -import { ErrorWidgetComponent, FormService, InitialUsernamePipe, WidgetComponent } from '@alfresco/adf-core'; -import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core'; +import { ErrorWidgetComponent, InitialUsernamePipe, WidgetComponent } from '@alfresco/adf-core'; +import { Component, ElementRef, EventEmitter, inject, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core'; import { ReactiveFormsModule, UntypedFormControl } from '@angular/forms'; import { MatChipsModule } from '@angular/material/chips'; import { MatIconModule } from '@angular/material/icon'; @@ -91,13 +91,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { return list; }) ); - - constructor( - public formService: FormService, - public peopleProcessService: PeopleProcessService - ) { - super(formService); - } + public peopleProcessService = inject(PeopleProcessService); ngOnInit() { if (this.field) { diff --git a/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts b/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts index dc8bb69b9f..e22b48edba 100644 --- a/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts +++ b/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts @@ -18,7 +18,6 @@ import { ComponentFixture, fakeAsync, getTestBed } from '@angular/core/testing'; import { Observable, of } from 'rxjs'; import { - FormService, ContainerModel, FormFieldTypes, FormFieldOption, @@ -36,7 +35,6 @@ import { MatRadioButtonHarness, MatRadioGroupHarness } from '@angular/material/r import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services'; describe('RadioButtonsWidgetComponent', () => { - let formService: FormService; let widget: RadioButtonsWidgetComponent; let taskFormService: TaskFormService; let processDefinitionService: ProcessDefinitionService; @@ -52,8 +50,7 @@ describe('RadioButtonsWidgetComponent', () => { taskFormService = getTestBed().inject(TaskFormService); processDefinitionService = getTestBed().inject(ProcessDefinitionService); - formService = new FormService(); - widget = new RadioButtonsWidgetComponent(formService, taskFormService, processDefinitionService); + widget = getTestBed().createComponent(RadioButtonsWidgetComponent).componentInstance; widget.field = new FormFieldModel(new FormModel(), { restUrl: '', optionType: 'rest' }); }); diff --git a/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.ts b/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.ts index f48572c86b..400ce8bd81 100644 --- a/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.ts +++ b/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.ts @@ -17,8 +17,8 @@ /* eslint-disable @angular-eslint/component-selector */ -import { ErrorWidgetComponent, FormService, WidgetComponent } from '@alfresco/adf-core'; -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { ErrorWidgetComponent, WidgetComponent } from '@alfresco/adf-core'; +import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core'; import { TaskFormService } from '../../services/task-form.service'; import { ProcessDefinitionService } from '../../services/process-definition.service'; import { CommonModule } from '@angular/common'; @@ -45,13 +45,8 @@ import { FormsModule } from '@angular/forms'; encapsulation: ViewEncapsulation.None }) export class RadioButtonsWidgetComponent extends WidgetComponent implements OnInit { - constructor( - public formService: FormService, - private taskFormService: TaskFormService, - private processDefinitionService: ProcessDefinitionService - ) { - super(formService); - } + private taskFormService = inject(TaskFormService); + private processDefinitionService = inject(ProcessDefinitionService); ngOnInit() { if (this.isValidRestConfig() && !this.isReadOnlyForm()) { diff --git a/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.spec.ts b/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.spec.ts index 2c9e3807b8..17a9ef79f3 100644 --- a/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.spec.ts +++ b/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.spec.ts @@ -18,18 +18,16 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { Observable, of } from 'rxjs'; import { By } from '@angular/platform-browser'; -import { FormService, FormFieldOption, FormFieldTypes, FormFieldModel, FormModel } from '@alfresco/adf-core'; +import { FormFieldOption, FormFieldTypes, FormFieldModel, FormModel } from '@alfresco/adf-core'; import { TypeaheadWidgetComponent } from './typeahead.widget'; import { TranslateService } from '@ngx-translate/core'; import { TaskFormService } from '../../services/task-form.service'; import { ProcessDefinitionService } from '../../services/process-definition.service'; describe('TypeaheadWidgetComponent', () => { - let formService: FormService; let widget: TypeaheadWidgetComponent; let translationService: TranslateService; let taskFormService: TaskFormService; - let processDefinitionService: ProcessDefinitionService; beforeEach(() => { TestBed.configureTestingModule({ @@ -37,12 +35,10 @@ describe('TypeaheadWidgetComponent', () => { }); translationService = TestBed.inject(TranslateService); taskFormService = TestBed.inject(TaskFormService); - processDefinitionService = TestBed.inject(ProcessDefinitionService); spyOn(translationService, 'instant').and.callFake((key) => key); spyOn(translationService, 'get').and.callFake((key) => of(key)); - formService = new FormService(); - widget = new TypeaheadWidgetComponent(formService, taskFormService, processDefinitionService); + widget = TestBed.createComponent(TypeaheadWidgetComponent).componentInstance; widget.field = new FormFieldModel(new FormModel({ taskId: 'task-id' })); widget.field.restUrl = 'whateverURL'; }); diff --git a/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.ts b/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.ts index e23cc07803..67fda419f7 100644 --- a/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.ts +++ b/lib/process-services/src/lib/form/widgets/typeahead/typeahead.widget.ts @@ -17,9 +17,9 @@ /* eslint-disable @angular-eslint/component-selector */ -import { FormService, FormFieldOption, WidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; +import { FormFieldOption, WidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; import { ENTER, ESCAPE } from '@angular/cdk/keycodes'; -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core'; import { TaskFormService } from '../../services/task-form.service'; import { ProcessDefinitionService } from '../../services/process-definition.service'; import { CommonModule } from '@angular/common'; @@ -53,13 +53,8 @@ export class TypeaheadWidgetComponent extends WidgetComponent implements OnInit oldValue: string; options: FormFieldOption[] = []; - constructor( - public formService: FormService, - private taskFormService: TaskFormService, - private processDefinitionService: ProcessDefinitionService - ) { - super(formService); - } + private taskFormService = inject(TaskFormService); + private processDefinitionService = inject(ProcessDefinitionService); ngOnInit() { if (this.field.form.taskId && this.field.restUrl) { diff --git a/lib/process-services/src/lib/form/widgets/upload/upload.widget.ts b/lib/process-services/src/lib/form/widgets/upload/upload.widget.ts index 6f02116ca7..8c4b164596 100644 --- a/lib/process-services/src/lib/form/widgets/upload/upload.widget.ts +++ b/lib/process-services/src/lib/form/widgets/upload/upload.widget.ts @@ -17,8 +17,8 @@ /* eslint-disable @angular-eslint/component-selector */ -import { ThumbnailService, FormService, ContentLinkModel, WidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; -import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; +import { ThumbnailService, ContentLinkModel, WidgetComponent, ErrorWidgetComponent } from '@alfresco/adf-core'; +import { Component, ElementRef, inject, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { Observable, from } from 'rxjs'; import { ProcessContentService } from '../../services/process-content.service'; import { mergeMap, map } from 'rxjs/operators'; @@ -55,9 +55,8 @@ export class UploadWidgetComponent extends WidgetComponent implements OnInit { @ViewChild('uploadFiles') fileInput: ElementRef; - constructor(public formService: FormService, private thumbnailService: ThumbnailService, public processContentService: ProcessContentService) { - super(formService); - } + protected thumbnailService = inject(ThumbnailService); + protected processContentService = inject(ProcessContentService); ngOnInit() { if (this.field?.value?.length > 0) { diff --git a/lib/process-services/tsconfig.json b/lib/process-services/tsconfig.json index 204cc68ba2..446c749a6c 100644 --- a/lib/process-services/tsconfig.json +++ b/lib/process-services/tsconfig.json @@ -15,7 +15,7 @@ ], "compilerOptions": { "baseUrl": "src", - "target": "es2020" + "target": "es2022" }, "angularCompilerOptions": { "skipTemplateCodegen": true, diff --git a/tsconfig.json b/tsconfig.json index 91ce4ee74e..4ea511f3bd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,12 +15,12 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, - "target": "es2015", + "target": "ES2022", "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "typeRoots": ["node_modules/@types"], "types": ["jasmine", "node", "jasminewd2"], - "lib": ["es2018", "esnext.array", "esnext.asynciterable", "dom"], + "lib": ["es2022", "dom"], "paths": { "@alfresco/adf-content-services": ["lib/content-services/src/public-api.ts"], "@alfresco/adf-core": ["lib/core/src/public-api.ts"],