Skip to content

Commit

Permalink
Merge pull request #20244 from abpframework/sumeyye/ts-toolbeltVersio…
Browse files Browse the repository at this point in the history
…nConfig

Angular - Typescript Tool Version Compatibility Fixes (ts-toolbelt)
  • Loading branch information
masum-ulu authored Aug 6, 2024
2 parents b9df01a + 635aeb4 commit c7d05de
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 64 deletions.
4 changes: 2 additions & 2 deletions npm/ng-packs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@
"should-quote": "^1.0.0",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"ts-toolbelt": "6.15.4",
"ts-toolbelt": "^9.0.0",
"tslib": "^2.0.0",
"tslint": "~6.1.0",
"typescript": "~5.3.0",
"typescript": "~5.4.0",
"zone.js": "~0.14.0"
},
"lint-staged": {
Expand Down
3 changes: 0 additions & 3 deletions npm/ng-packs/packages/components/extensible/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LinkedList } from '@abp/utils';
import { InjectFlags, InjectionToken, InjectOptions, Type } from '@angular/core';
import { O } from 'ts-toolbelt';

export abstract class ActionList<R = any, A = Action<R>> extends LinkedList<A> {}

Expand All @@ -22,7 +21,7 @@ export abstract class ActionData<R = any> {
}
}

export type ReadonlyActionData<R = any> = O.Readonly<Omit<ActionData<R>, 'data'>>;
export type ReadonlyActionData<R = any> = Readonly<Omit<ActionData<R>, 'data'>>;

export abstract class Action<R = any> {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Type } from '@angular/core';
import { O } from 'ts-toolbelt';
import {
Action,
ActionContributorCallback,
Expand All @@ -9,6 +8,7 @@ import {
ActionsFactory,
} from './actions';
import { FormPropTooltip } from './form-props';
import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils';

export class EntityActionList<R = any> extends ActionList<R, EntityAction<R>> {}

Expand Down Expand Up @@ -47,10 +47,9 @@ export class EntityAction<R = any> extends Action<R> {
}
}

export type EntityActionOptions<R = any> = O.Optional<
O.Writable<EntityAction<R>>,
'permission' | 'visible' | 'icon'
>;
type OptionalKeys = 'permission' | 'visible' | 'icon';
export type EntityActionOptions<R = any> = PartialWithOptions<EntityAction<R>, OptionalKeys> &
FilteredWithOptions<EntityAction<R>, OptionalKeys>;

export type EntityActionDefaults<R = any> = Record<string, EntityAction<R>[]>;
export type EntityActionContributorCallback<R = any> = ActionContributorCallback<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ABP, escapeHtmlChars } from '@abp/ng.core';
import { InjectFlags, InjectOptions, InjectionToken, Type } from '@angular/core';
import { Observable, of } from 'rxjs';
import { O } from 'ts-toolbelt';
import { ActionCallback } from './actions';
import {
Prop,
Expand All @@ -13,6 +12,7 @@ import {
PropsFactory,
} from './props';
import { FormPropTooltip } from './form-props';
import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils';

export class EntityPropList<R = any> extends PropList<R, EntityProp<R>> {}

Expand Down Expand Up @@ -71,8 +71,7 @@ export class EntityProp<R = any> extends Prop<R> {
}
}

export type EntityPropOptions<R = any> = O.Optional<
O.Writable<EntityProp<R>>,
type OptionalKeys =
| 'permission'
| 'visible'
| 'columnVisible'
Expand All @@ -83,8 +82,9 @@ export type EntityPropOptions<R = any> = O.Optional<
| 'valueResolver'
| 'action'
| 'component'
| 'enumList'
>;
| 'enumList';
export type EntityPropOptions<R = any> = PartialWithOptions<EntityProp<R>, OptionalKeys> &
FilteredWithOptions<EntityProp<R>, OptionalKeys>;

export type EntityPropDefaults<R = any> = Record<string, EntityProp<R>[]>;
export type EntityPropContributorCallback<R = any> = PropContributorCallback<EntityPropList<R>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ABP } from '@abp/ng.core';
import { Injector, Type } from '@angular/core';
import { AsyncValidatorFn, ValidatorFn } from '@angular/forms';
import { Observable } from 'rxjs';
import { O } from 'ts-toolbelt';
import {
Prop,
PropCallback,
Expand All @@ -15,6 +14,7 @@ import {
Props,
PropsFactory,
} from './props';
import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils';

export class FormPropList<R = any> extends PropList<R, FormProp<R>> {}

Expand Down Expand Up @@ -131,8 +131,7 @@ export class FormPropData<R = any> extends PropData<R> {
}
}

export type FormPropOptions<R = any> = O.Optional<
O.Writable<FormProp<R>>,
type OptionalKeys =
| 'permission'
| 'visible'
| 'displayName'
Expand All @@ -147,8 +146,9 @@ export type FormPropOptions<R = any> = O.Optional<
| 'id'
| 'displayTextResolver'
| 'formText'
| 'tooltip'
>;
| 'tooltip';
export type FormPropOptions<R = any> = PartialWithOptions<FormProp<R>, OptionalKeys> &
FilteredWithOptions<FormProp<R>, OptionalKeys>;

export type CreateFormPropDefaults<R = any> = Record<string, FormProp<R>[]>;
export type CreateFormPropContributorCallback<R = any> = PropContributorCallback<FormPropList<R>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LinkedList } from '@abp/utils';
import { InjectFlags, InjectionToken, InjectOptions, Type } from '@angular/core';
import { O } from 'ts-toolbelt';
import { ePropType } from '../enums/props.enum';
import { FormPropTooltip } from './form-props';

Expand All @@ -24,7 +23,7 @@ export abstract class PropData<R = any> {
}
}

export type ReadonlyPropData<R = any> = O.Readonly<Omit<PropData<R>, 'data'>>;
export type ReadonlyPropData<R = any> = Readonly<Omit<PropData<R>, 'data'>>;

export abstract class Prop<R = any> {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injector, Type } from '@angular/core';
import { O } from 'ts-toolbelt';
import {
Action,
ActionContributorCallback,
Expand All @@ -10,6 +9,7 @@ import {
ActionsFactory,
ReadonlyActionData,
} from './actions';
import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils';

export class ToolbarActionList<R = any> extends ActionList<R, ToolbarActionDefault<R>> {}

Expand Down Expand Up @@ -61,15 +61,19 @@ export class ToolbarComponent<R = any> extends Action<R> {
}
}

export type ToolbarActionOptions<R = any> = O.Optional<
O.Writable<ToolbarAction<R>>,
'permission' | 'visible' | 'icon' | 'btnClass'
>;

export type ToolbarComponentOptions<R = any> = O.Optional<
O.Writable<ToolbarComponent<R>>,
'permission' | 'visible' | 'action'
>;
type OptionalActionKeys = 'permission' | 'visible' | 'icon' | 'btnClass';
export type ToolbarActionOptions<R = any> = PartialWithOptions<
ToolbarAction<R>,
OptionalActionKeys
> &
FilteredWithOptions<ToolbarAction<R>, OptionalActionKeys>;

type OptionalComponentKeys = 'permission' | 'visible' | 'action';
export type ToolbarComponentOptions<R = any> = PartialWithOptions<
ToolbarComponent<R>,
OptionalComponentKeys
> &
FilteredWithOptions<ToolbarComponent<R>, OptionalComponentKeys>;

export type ToolbarActionDefault<R = any> = ToolbarAction<R> | ToolbarComponent<R>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { DateTimeAdapter,DateAdapter,TimeAdapter } from '@abp/ng.theme.shared';
import { DateTimeAdapter, DateAdapter, TimeAdapter } from '@abp/ng.theme.shared';

import { EXTRA_PROPERTIES_KEY } from '../constants/extra-properties';
import { ePropType } from '../enums/props.enum';
import { FormPropList } from "../models/form-props";
import { PropData } from "../models/props";
import { FormPropList } from '../models/form-props';
import { PropData } from '../models/props';
import { ExtensionsService } from '../services/extensions.service';
import { EXTENSIONS_IDENTIFIER } from '../tokens/extensions.token';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type PartialWithOptions<T, OptionalKeys extends keyof T> = Partial<Pick<T, OptionalKeys>>;
export type FilteredWithOptions<T, OptionalKeys extends keyof T> = Omit<T, OptionalKeys>;
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,29 @@ export function mergeWithDefaultProps<F extends PropsFactory<any>>(
);
});
}
type InferredPropDefaults<F> = F extends EntityPropsFactory<infer RE>
? EntityPropDefaults<RE>
: F extends CreateFormPropsFactory<infer RCF>
? CreateFormPropDefaults<RCF>
: F extends EditFormPropsFactory<infer REF>
? EditFormPropDefaults<REF>
: never;
type InferredPropDefaults<F> =
F extends EntityPropsFactory<infer RE>
? EntityPropDefaults<RE>
: F extends CreateFormPropsFactory<infer RCF>
? CreateFormPropDefaults<RCF>
: F extends EditFormPropsFactory<infer REF>
? EditFormPropDefaults<REF>
: never;

type InferredPropContributorCallbacks<F> = F extends EntityPropsFactory<infer RE>
? EntityPropContributorCallbacks<RE>
: F extends CreateFormPropsFactory<infer RCF>
? CreateFormPropContributorCallbacks<RCF>
: F extends EditFormPropsFactory<infer REF>
? EditFormPropContributorCallbacks<REF>
: never;
type InferredPropContributorCallbacks<F> =
F extends EntityPropsFactory<infer RE>
? EntityPropContributorCallbacks<RE>
: F extends CreateFormPropsFactory<infer RCF>
? CreateFormPropContributorCallbacks<RCF>
: F extends EditFormPropsFactory<infer REF>
? EditFormPropContributorCallbacks<REF>
: never;

type InferredProps<F> = F extends EntityPropsFactory<infer RE>
? EntityProps<RE>
: F extends CreateFormPropsFactory<infer RCF>
? FormProps<RCF>
: F extends EditFormPropsFactory<infer REF>
? FormProps<REF>
: never;
type InferredProps<F> =
F extends EntityPropsFactory<infer RE>
? EntityProps<RE>
: F extends CreateFormPropsFactory<infer RCF>
? FormProps<RCF>
: F extends EditFormPropsFactory<infer REF>
? FormProps<REF>
: never;
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export function createTypeaheadOptions(
}

export function getTypeaheadType(lookup: ExtensionPropertyUiLookupDto, name: string) {
if (!!lookup.url) {
return ePropType.Typeahead;
} else {
if (!lookup.url) {
return name.endsWith(TYPEAHEAD_TEXT_SUFFIX) ? ePropType.Hidden : undefined;
} else {
return ePropType.Typeahead;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ export * from './lib/pipes/create-injector.pipe';
export * from './lib/services/extensions.service';
export * from './lib/tokens/extensions.token';
export * from './lib/tokens/extensible-form-view-provider.token';
export * from './lib/utils/actions.util';
export * from './lib/utils/actions.util';
export * from './lib/utils/form-props.util';
export * from './lib/utils/props.util';
export * from './lib/utils/state.util';
export * from './lib/utils/model.utils';
export * from './lib/extensible.module';
2 changes: 1 addition & 1 deletion npm/ng-packs/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@abp/utils": "~8.3.0-rc.1",
"just-clone": "^6.0.0",
"just-compare": "^2.0.0",
"ts-toolbelt": "6.15.4",
"ts-toolbelt": "^9.0.0",
"tslib": "^2.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion npm/ng-packs/packages/core/src/lib/models/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface ApplicationInfo {
export interface HasAdditional {
[key: string]: string;
}
export interface ApiConfig extends Partial<HasAdditional>{
export interface ApiConfig extends Partial<HasAdditional> {
url: string;
rootNamespace?: string;
}
Expand Down

0 comments on commit c7d05de

Please sign in to comment.