diff --git a/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts b/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts index 6819e1297f..a0eae51b11 100644 --- a/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts +++ b/src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts @@ -3,17 +3,17 @@ import * as moment from 'moment'; import { combineLatest, Observable, of } from 'rxjs'; import { first, map } from 'rxjs/operators'; -import { EndpointHealthCheck } from '../../core/endpoints-health-checks'; import { urlValidationExpression } from '../../core/src/core/utils.service'; -import { BaseEndpointAuth } from '../../core/src/features/endpoints/endpoint-auth'; import { AppState, GeneralEntityAppState } from '../../store/src/app-state'; import { metricEntityType } from '../../store/src/base-entity-schemas'; +import { BaseEndpointAuth } from '../../store/src/endpoint-auth'; import { StratosBaseCatalogEntity, StratosCatalogEndpointEntity, StratosCatalogEntity, } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; import { + EndpointHealthCheck, IStratosEntityDefinition, StratosEndpointExtensionDefinition, } from '../../store/src/entity-catalog/entity-catalog.types'; diff --git a/src/frontend/packages/cloud-foundry/src/cf-favorites-helpers.ts b/src/frontend/packages/cloud-foundry/src/cf-favorites-helpers.ts index ec23f4125f..8f19d39a21 100644 --- a/src/frontend/packages/cloud-foundry/src/cf-favorites-helpers.ts +++ b/src/frontend/packages/cloud-foundry/src/cf-favorites-helpers.ts @@ -1,5 +1,5 @@ -import { FavoritesConfigMapper } from '../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { IEntityMetadata } from '../../store/src/entity-catalog/entity-catalog.types'; +import { FavoritesConfigMapper } from '../../store/src/favorite-config-mapper'; import { UserFavorite } from '../../store/src/types/user-favorites.types'; import { CfAPIResource } from './store/types/cf-api.types'; diff --git a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts index d6e3c44434..7974416cac 100644 --- a/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/applications/application/application-tabs-base/application-tabs-base.component.ts @@ -17,14 +17,12 @@ import { import { CurrentUserPermissionsService } from '../../../../../../core/src/core/permissions/current-user-permissions.service'; import { safeUnsubscribe } from '../../../../../../core/src/core/utils.service'; import { IPageSideNavTab } from '../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component'; -import { - FavoritesConfigMapper, -} from '../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { IHeaderBreadcrumb } from '../../../../../../core/src/shared/components/page-header/page-header.types'; import { ENTITY_SERVICE } from '../../../../../../core/src/shared/entity.tokens'; import { RouterNav } from '../../../../../../store/src/actions/router.actions'; import { entityCatalog } from '../../../../../../store/src/entity-catalog/entity-catalog'; import { EntityService } from '../../../../../../store/src/entity-service'; +import { FavoritesConfigMapper } from '../../../../../../store/src/favorite-config-mapper'; import { EntitySchema } from '../../../../../../store/src/helpers/entity-schema'; import { ActionState } from '../../../../../../store/src/reducers/api-request-reducer/types'; import { endpointEntitiesSelector } from '../../../../../../store/src/selectors/endpoint.selectors'; diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/cloud-foundry-tabs-base/cloud-foundry-tabs-base.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/cloud-foundry-tabs-base/cloud-foundry-tabs-base.component.ts index 57ddd512a7..c086f9cd86 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/cloud-foundry-tabs-base/cloud-foundry-tabs-base.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/cloud-foundry-tabs-base/cloud-foundry-tabs-base.component.ts @@ -13,7 +13,7 @@ import { import { CurrentUserPermissionsService } from '../../../../../core/src/core/permissions/current-user-permissions.service'; import { environment } from '../../../../../core/src/environments/environment.prod'; import { IPageSideNavTab } from '../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component'; -import { FavoritesConfigMapper } from '../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; +import { FavoritesConfigMapper } from '../../../../../store/src/favorite-config-mapper'; import { UserFavoriteEndpoint } from '../../../../../store/src/types/user-favorites.types'; import { CfCurrentUserPermissions } from '../../../user-permissions/cf-user-permissions-checkers'; import { CloudFoundryEndpointService } from '../services/cloud-foundry-endpoint.service'; diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-base/cloud-foundry-organization-base.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-base/cloud-foundry-organization-base.component.ts index 91c27c3f31..f9a24ac961 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-base/cloud-foundry-organization-base.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-base/cloud-foundry-organization-base.component.ts @@ -13,10 +13,8 @@ import { } from '../../../../../../../core/src/core/extension/extension-service'; import { environment } from '../../../../../../../core/src/environments/environment.prod'; import { IPageSideNavTab } from '../../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component'; -import { - FavoritesConfigMapper, -} from '../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { IHeaderBreadcrumb } from '../../../../../../../core/src/shared/components/page-header/page-header.types'; +import { FavoritesConfigMapper } from '../../../../../../../store/src/favorite-config-mapper'; import { EntitySchema } from '../../../../../../../store/src/helpers/entity-schema'; import { UserFavorite } from '../../../../../../../store/src/types/user-favorites.types'; import { getFavoriteFromEntity } from '../../../../../../../store/src/user-favorite-helpers'; diff --git a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/cloud-foundry-space-base/cloud-foundry-space-base.component.ts b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/cloud-foundry-space-base/cloud-foundry-space-base.component.ts index 7f5e455ecc..5ae190a43b 100644 --- a/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/cloud-foundry-space-base/cloud-foundry-space-base.component.ts +++ b/src/frontend/packages/cloud-foundry/src/features/cloud-foundry/tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/cloud-foundry-space-base/cloud-foundry-space-base.component.ts @@ -16,11 +16,9 @@ import { import { environment } from '../../../../../../../../core/src/environments/environment.prod'; import { IPageSideNavTab } from '../../../../../../../../core/src/features/dashboard/page-side-nav/page-side-nav.component'; import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service'; -import { - FavoritesConfigMapper, -} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { IHeaderBreadcrumb } from '../../../../../../../../core/src/shared/components/page-header/page-header.types'; import { RouterNav } from '../../../../../../../../store/src/actions/router.actions'; +import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper'; import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types'; import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers'; import { cfEntityFactory } from '../../../../../../cf-entity-factory'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app/card/card-app.component.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app/card/card-app.component.ts index 3a450bdde4..4fdef71b47 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app/card/card-app.component.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/app/card/card-app.component.ts @@ -6,11 +6,9 @@ import { map, startWith } from 'rxjs/operators'; import { CFAppState } from '../../../../../../../../cloud-foundry/src/cf-app-state'; import { applicationEntityType } from '../../../../../../../../cloud-foundry/src/cf-entity-types'; import { IAppFavMetadata } from '../../../../../../../../cloud-foundry/src/cf-metadata-types'; -import { - FavoritesConfigMapper, -} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { CardCell } from '../../../../../../../../core/src/shared/components/list/list.types'; import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../core/src/shared/shared.types'; +import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper'; import { APIResource } from '../../../../../../../../store/src/types/api.types'; import { UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types'; import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-orgs/cf-org-card/cf-org-card.component.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-orgs/cf-org-card/cf-org-card.component.ts index f146e81e1c..2e7f605c23 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-orgs/cf-org-card/cf-org-card.component.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-orgs/cf-org-card/cf-org-card.component.ts @@ -11,15 +11,13 @@ import { import { truthyIncludingZeroString } from '../../../../../../../../core/src/core/utils.service'; import { ConfirmationDialogConfig } from '../../../../../../../../core/src/shared/components/confirmation-dialog.config'; import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service'; -import { - FavoritesConfigMapper, -} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { MetaCardMenuItem, } from '../../../../../../../../core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component'; import { CardCell } from '../../../../../../../../core/src/shared/components/list/list.types'; import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../core/src/shared/shared.types'; import { RouterNav } from '../../../../../../../../store/src/actions/router.actions'; +import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper'; import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { PaginationMonitorFactory } from '../../../../../../../../store/src/monitors/pagination-monitor.factory'; import { APIResource } from '../../../../../../../../store/src/types/api.types'; diff --git a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts index 890fdf2f98..189604d778 100644 --- a/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts +++ b/src/frontend/packages/cloud-foundry/src/shared/components/list/list-types/cf-spaces/cf-space-card/cf-space-card.component.ts @@ -12,15 +12,13 @@ import { import { truthyIncludingZeroString } from '../../../../../../../../core/src/core/utils.service'; import { ConfirmationDialogConfig } from '../../../../../../../../core/src/shared/components/confirmation-dialog.config'; import { ConfirmationDialogService } from '../../../../../../../../core/src/shared/components/confirmation-dialog.service'; -import { - FavoritesConfigMapper, -} from '../../../../../../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { MetaCardMenuItem, } from '../../../../../../../../core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component'; import { CardCell } from '../../../../../../../../core/src/shared/components/list/list.types'; import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../../../../core/src/shared/shared.types'; import { RouterNav } from '../../../../../../../../store/src/actions/router.actions'; +import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper'; import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { PaginationMonitorFactory } from '../../../../../../../../store/src/monitors/pagination-monitor.factory'; import { APIResource } from '../../../../../../../../store/src/types/api.types'; diff --git a/src/frontend/packages/core/endpoints-health-checks.ts b/src/frontend/packages/core/endpoints-health-checks.ts index 2c7624fd76..11e46ae3fc 100644 --- a/src/frontend/packages/core/endpoints-health-checks.ts +++ b/src/frontend/packages/core/endpoints-health-checks.ts @@ -1,20 +1,9 @@ import { Injectable } from '@angular/core'; import { entityCatalog } from '../store/src/entity-catalog/entity-catalog'; +import { EndpointHealthCheck } from '../store/src/entity-catalog/entity-catalog.types'; import { EndpointModel } from '../store/src/types/endpoint.types'; - -export class EndpointHealthCheck { - /** - * @param check To show an error, the check should either call a WrapperRequestActionFailed - * or kick off a chain that eventually calls a WrapperRequestActionFailed - */ - constructor( - public endpointType: string, - public check: (endpoint: EndpointModel) => void - ) { } -} - @Injectable({ providedIn: 'root' }) diff --git a/src/frontend/packages/core/src/app.module.ts b/src/frontend/packages/core/src/app.module.ts index ca4a5daacb..5143286c99 100644 --- a/src/frontend/packages/core/src/app.module.ts +++ b/src/frontend/packages/core/src/app.module.ts @@ -4,6 +4,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { Params, RouteReuseStrategy, RouterStateSnapshot } from '@angular/router'; import { DefaultRouterStateSerializer, RouterStateSerializer, StoreRouterConnectingModule } from '@ngrx/router-store'; import { Store } from '@ngrx/store'; +import { StoreDevtoolsModule } from '@ngrx/store-devtools'; import { debounceTime, filter, withLatestFrom } from 'rxjs/operators'; import { CfAutoscalerModule } from '../../cf-autoscaler/src/cf-autoscaler.module'; @@ -19,6 +20,7 @@ import { EntityCatalogModule } from '../../store/src/entity-catalog.module'; import { entityCatalog } from '../../store/src/entity-catalog/entity-catalog'; import { EntityCatalogHelper } from '../../store/src/entity-catalog/entity-catalog-entity/entity-catalog.service'; import { EntityCatalogHelpers } from '../../store/src/entity-catalog/entity-catalog.helper'; +import { FavoritesConfigMapper } from '../../store/src/favorite-config-mapper'; import { endpointSchemaKey } from '../../store/src/helpers/entity-factory'; import { getAPIRequestDataState, selectEntity } from '../../store/src/selectors/api.selectors'; import { internalEventStateSelector } from '../../store/src/selectors/internal-events.selectors'; @@ -38,6 +40,7 @@ import { ExtensionService } from './core/extension/extension-service'; import { getGitHubAPIURL, GITHUB_API_URL } from './core/github.helpers'; import { CurrentUserPermissionsService } from './core/permissions/current-user-permissions.service'; import { CustomImportModule } from './custom-import.module'; +import { environment } from './environments/environment'; import { AboutModule } from './features/about/about.module'; import { DashboardModule } from './features/dashboard/dashboard.module'; import { HomeModule } from './features/home/home.module'; @@ -46,7 +49,6 @@ import { NoEndpointsNonAdminComponent } from './features/no-endpoints-non-admin/ import { SetupModule } from './features/setup/setup.module'; import { LoggedInService } from './logged-in.service'; import { CustomReuseStrategy } from './route-reuse-stragegy'; -import { FavoritesConfigMapper } from './shared/components/favorites-meta-card/favorite-config-mapper'; import { endpointEventKey, GlobalEventData, GlobalEventService } from './shared/global-events.service'; import { SidePanelService } from './shared/services/side-panel.service'; import { SharedModule } from './shared/shared.module'; @@ -80,6 +82,18 @@ export class CustomRouterStateSerializer } } +const storeDebugImports = environment.production ? [] : [ + StoreDevtoolsModule.instrument({ + maxAge: 100, + logOnly: !environment.production + }) +]; + +@NgModule({ + imports: storeDebugImports +}) +class AppStoreDebugModule {} + /** * `HttpXsrfTokenExtractor` which retrieves the token from a cookie. */ @@ -94,6 +108,7 @@ export class CustomRouterStateSerializer RouteModule, CloudFoundryPackageModule, AppStoreModule, + AppStoreDebugModule, BrowserModule, SharedModule, BrowserAnimationsModule, diff --git a/src/frontend/packages/core/src/core/endpoints.service.ts b/src/frontend/packages/core/src/core/endpoints.service.ts index 842330f087..1d82326027 100644 --- a/src/frontend/packages/core/src/core/endpoints.service.ts +++ b/src/frontend/packages/core/src/core/endpoints.service.ts @@ -7,10 +7,11 @@ import { first, map, skipWhile, withLatestFrom } from 'rxjs/operators'; import { RouterNav } from '../../../store/src/actions/router.actions'; import { EndpointOnlyAppState, IRequestEntityTypeState } from '../../../store/src/app-state'; import { entityCatalog } from '../../../store/src/entity-catalog/entity-catalog'; +import { EndpointHealthCheck } from '../../../store/src/entity-catalog/entity-catalog.types'; import { AuthState } from '../../../store/src/reducers/auth.reducer'; import { endpointEntitiesSelector, endpointStatusSelector } from '../../../store/src/selectors/endpoint.selectors'; import { EndpointModel, EndpointState } from '../../../store/src/types/endpoint.types'; -import { EndpointHealthCheck, EndpointHealthChecks } from '../../endpoints-health-checks'; +import { EndpointHealthChecks } from '../../endpoints-health-checks'; import { endpointHasMetricsByAvailable } from '../features/endpoints/endpoint-helpers'; import { UserService } from './user.service'; diff --git a/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.spec.ts b/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.spec.ts index 900bd8ade9..067a4e1f69 100644 --- a/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.spec.ts +++ b/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.spec.ts @@ -2,13 +2,13 @@ import { OverlayContainer } from '@angular/cdk/overlay'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { BehaviorSubject, of } from 'rxjs'; +import { FavoritesConfigMapper } from '../../../../store/src/favorite-config-mapper'; import { PaginationMonitorFactory } from '../../../../store/src/monitors/pagination-monitor.factory'; import { IFavoriteMetadata, UserFavorite } from '../../../../store/src/types/user-favorites.types'; import { UserFavoriteManager } from '../../../../store/src/user-favorite-manager'; import { BaseTestModulesNoShared } from '../../../test-framework/core-test.helper'; import { ConfirmationDialogService } from '../../shared/components/confirmation-dialog.service'; import { DialogConfirmComponent } from '../../shared/components/dialog-confirm/dialog-confirm.component'; -import { FavoritesConfigMapper } from '../../shared/components/favorites-meta-card/favorite-config-mapper'; import { EntityFavoriteStarComponent } from './entity-favorite-star.component'; describe('EntityFavoriteStarComponent', () => { diff --git a/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.ts b/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.ts index 1aed1b41b0..c345e7d523 100644 --- a/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.ts +++ b/src/frontend/packages/core/src/core/entity-favorite-star/entity-favorite-star.component.ts @@ -2,11 +2,11 @@ import { Component, Input } from '@angular/core'; import { Observable } from 'rxjs'; import { first, tap } from 'rxjs/operators'; +import { FavoritesConfigMapper } from '../../../../store/src/favorite-config-mapper'; import { IFavoriteMetadata, UserFavorite } from '../../../../store/src/types/user-favorites.types'; import { UserFavoriteManager } from '../../../../store/src/user-favorite-manager'; import { ConfirmationDialogConfig } from '../../shared/components/confirmation-dialog.config'; import { ConfirmationDialogService } from '../../shared/components/confirmation-dialog.service'; -import { FavoritesConfigMapper } from '../../shared/components/favorites-meta-card/favorite-config-mapper'; import { EndpointsService } from '../endpoints.service'; @Component({ diff --git a/src/frontend/packages/core/src/core/utils.service.ts b/src/frontend/packages/core/src/core/utils.service.ts index 415a8f89c6..a99ddf6708 100644 --- a/src/frontend/packages/core/src/core/utils.service.ts +++ b/src/frontend/packages/core/src/core/utils.service.ts @@ -11,56 +11,6 @@ export function getIdFromRoute(activatedRoute: ActivatedRoute, id: string) { return null; } -export type OptionalKeys = Exclude<{ - [K in keyof T]: T extends Record - ? K - : never -}[keyof T], undefined> - - -export type NonOptionalKeys = Exclude<{ - [K in keyof T]: T extends Record - ? K - : never -}[keyof T], undefined> - -export type NeverKeys = Exclude<{ - [K in keyof T]: T[K] extends never - ? K - : never -}[keyof T], undefined> - - -/** - * Remove keys such as typed indexes (i.e. [key: string]) - * For magic see - * - https://github.com/Microsoft/TypeScript/issues/25987#issuecomment-441224690 - * - https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-414808995 - */ -export type KnownKeys = { - [K in keyof T]: string extends K ? never : number extends K ? never : K -} extends { [_ in keyof T]: infer U } ? ({} extends U ? never : U) : never; - -/** - * Pick all properties who's function has the specified return type U - */ -export type FilteredByReturnType any }, U> = { - [P in keyof T]: ReturnType extends U ? T[P] : never -}; - -/** - * Pick all properties who's function do not have the specified return type U - */ -export type FilteredByNotReturnType any }, U> = { - [P in keyof T]: ReturnType extends U ? never : T[P] -}; - -// Note - Adding }[keyof T] to [P in keyof T] types should filter out properties of type `never`, however this fails with generics! -export type FilteredByValueType any }, U> = { - [P in keyof T]: T[P] extends U ? never : T[P] -}; - - export const urlValidationExpression = '^' + // protocol identifier @@ -319,13 +269,6 @@ export const safeUnsubscribe = (...subs: Subscription[]) => { export const truthyIncludingZero = (obj: any): boolean => !!obj || obj === 0; export const truthyIncludingZeroString = (obj: any): string => truthyIncludingZero(obj) ? obj.toString() : null; -export const sortStringify = (obj: { [key: string]: string | string[] | number }): string => { - const keys = Object.keys(obj).sort(); - return keys.reduce((res, key) => { - return res += `${key}-${obj[key]},`; - }, ''); -}; - /** * Real basic, shallow check */ diff --git a/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints.service.ts b/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints.service.ts index 5251a66479..2aee2629c1 100644 --- a/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints.service.ts +++ b/src/frontend/packages/core/src/features/endpoints/backup-restore/backup-endpoints.service.ts @@ -5,9 +5,9 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { first, map } from 'rxjs/operators'; import { GeneralEntityAppState } from '../../../../../store/src/app-state'; +import { BrowserStandardEncoder } from '../../../../../store/src/browser-encoder'; import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog'; import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; -import { BrowserStandardEncoder } from '../../../helper'; import { BackupEndpointConfigUI, BackupEndpointConnectionTypes, diff --git a/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints.service.ts b/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints.service.ts index 8fa35048c1..38dee43257 100644 --- a/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints.service.ts +++ b/src/frontend/packages/core/src/features/endpoints/backup-restore/restore-endpoints.service.ts @@ -5,10 +5,10 @@ import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; import { filter, map, switchMap } from 'rxjs/operators'; import { GeneralEntityAppState } from '../../../../../store/src/app-state'; +import { BrowserStandardEncoder } from '../../../../../store/src/browser-encoder'; import { selectSessionData } from '../../../../../store/src/reducers/auth.reducer'; import { SessionData } from '../../../../../store/src/types/auth.types'; import { LoggerService } from '../../../core/logger.service'; -import { BrowserStandardEncoder } from '../../../helper'; interface BackupContent { payload: string; diff --git a/src/frontend/packages/core/src/features/endpoints/connect-endpoint/connect-endpoint.component.ts b/src/frontend/packages/core/src/features/endpoints/connect-endpoint/connect-endpoint.component.ts index 4bc13f56bb..78c10d099a 100644 --- a/src/frontend/packages/core/src/features/endpoints/connect-endpoint/connect-endpoint.component.ts +++ b/src/frontend/packages/core/src/features/endpoints/connect-endpoint/connect-endpoint.component.ts @@ -14,11 +14,11 @@ import { import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Subscription } from 'rxjs'; +import { BaseEndpointAuth } from '../../../../../store/src/endpoint-auth'; import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog'; import { EndpointAuthTypeConfig, IAuthForm, IEndpointAuthComponent } from '../../../../../store/src/extension-types'; import { safeUnsubscribe } from '../../../core/utils.service'; import { ConnectEndpointConfig, ConnectEndpointData, ConnectEndpointService } from '../connect.service'; -import { BaseEndpointAuth } from '../endpoint-auth'; @Component({ selector: 'app-connect-endpoint', diff --git a/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts b/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts index 31171980d5..aeeca51973 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-entity-list/favorites-entity-list.component.ts @@ -2,8 +2,8 @@ import { Component, Input, OnInit } from '@angular/core'; import { combineLatest, Observable, ReplaySubject, Subject } from 'rxjs'; import { distinctUntilChanged, map, scan, startWith } from 'rxjs/operators'; +import { FavoritesConfigMapper, IFavoriteTypes } from '../../../../../store/src/favorite-config-mapper'; import { IFavoriteEntity } from '../../../../../store/src/user-favorite-manager'; -import { FavoritesConfigMapper, IFavoriteTypes } from '../favorites-meta-card/favorite-config-mapper'; @Component({ diff --git a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts index a559cedad0..db9713e8aa 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorites-meta-card.component.ts @@ -9,6 +9,7 @@ import { import { AppState } from '../../../../../store/src/app-state'; import { userFavoritesEntitySchema } from '../../../../../store/src/base-entity-schemas'; import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog'; +import { IFavoritesMetaCardConfig } from '../../../../../store/src/favorite-config-mapper'; import { endpointEntitiesSelector } from '../../../../../store/src/selectors/endpoint.selectors'; import { IFavoriteMetadata, UserFavorite } from '../../../../../store/src/types/user-favorites.types'; import { IFavoriteEntity } from '../../../../../store/src/user-favorite-manager'; @@ -17,7 +18,6 @@ import { ComponentEntityMonitorConfig, StratosStatus } from '../../shared.types' import { ConfirmationDialogConfig } from '../confirmation-dialog.config'; import { ConfirmationDialogService } from '../confirmation-dialog.service'; import { MetaCardMenuItem } from '../list/list-cards/meta-card/meta-card-base/meta-card.component'; -import { IFavoritesMetaCardConfig } from './favorite-config-mapper'; @Component({ diff --git a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.spec.ts b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.spec.ts index 8800a8a802..4a35630e03 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.spec.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.spec.ts @@ -5,6 +5,7 @@ import { StoreModule } from '@ngrx/store'; import { createBasicStoreModule } from '@stratosui/store/testing'; import { Observable, of } from 'rxjs'; +import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper'; import { EntitySchema } from '../../../../../../../../store/src/helpers/entity-schema'; import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types'; @@ -13,7 +14,6 @@ import { UserFavoriteManager } from '../../../../../../../../store/src/user-favo import { CoreTestingModule } from '../../../../../../../test-framework/core-test.modules'; import { SharedModule } from '../../../../../shared.module'; import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../shared.types'; -import { FavoritesConfigMapper } from '../../../../favorites-meta-card/favorite-config-mapper'; import { MetaCardComponent } from './meta-card.component'; @Component({ diff --git a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts index ced89b65c0..2a180f646f 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component.ts @@ -2,12 +2,12 @@ import { Component, ContentChild, ContentChildren, Input, OnDestroy, QueryList } import { combineLatest, Observable, of as observableOf, Subscription } from 'rxjs'; import { first, map, tap } from 'rxjs/operators'; +import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper'; import { EntityMonitorFactory } from '../../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { IFavoriteMetadata, UserFavorite } from '../../../../../../../../store/src/types/user-favorites.types'; import { getFavoriteFromEntity } from '../../../../../../../../store/src/user-favorite-helpers'; import { safeUnsubscribe } from '../../../../../../core/utils.service'; import { ComponentEntityMonitorConfig, StratosStatus } from '../../../../../shared.types'; -import { FavoritesConfigMapper } from '../../../../favorites-meta-card/favorite-config-mapper'; import { MetaCardItemComponent } from '../meta-card-item/meta-card-item.component'; import { MetaCardTitleComponent } from '../meta-card-title/meta-card-title.component'; diff --git a/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-favorite/table-cell-favorite.component.ts b/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-favorite/table-cell-favorite.component.ts index 93f89e58de..cb239478f9 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-favorite/table-cell-favorite.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-table/table-cell-favorite/table-cell-favorite.component.ts @@ -1,9 +1,9 @@ import { Component, Input } from '@angular/core'; +import { FavoritesConfigMapper } from '../../../../../../../store/src/favorite-config-mapper'; import { IFavoriteMetadata, UserFavorite } from '../../../../../../../store/src/types/user-favorites.types'; import { TableCellCustom } from '../../list.types'; import { ITableColumn } from '../table.types'; -import { FavoritesConfigMapper } from '../../../favorites-meta-card/favorite-config-mapper'; export interface TableCellFavoriteComponentConfig { createUserFavorite: (entity: T) => UserFavorite; diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts index 581680cd4f..e975236944 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoint-card/endpoint-card.component.ts @@ -18,6 +18,7 @@ import { entityCatalog } from '../../../../../../../../store/src/entity-catalog/ import { StratosCatalogEndpointEntity, } from '../../../../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; +import { FavoritesConfigMapper } from '../../../../../../../../store/src/favorite-config-mapper'; import { EndpointModel } from '../../../../../../../../store/src/types/endpoint.types'; import { UserFavoriteEndpoint } from '../../../../../../../../store/src/types/user-favorites.types'; import { safeUnsubscribe } from '../../../../../../core/utils.service'; @@ -26,7 +27,6 @@ import { getFullEndpointApiUrl, } from '../../../../../../features/endpoints/endpoint-helpers'; import { StratosStatus } from '../../../../../shared.types'; -import { FavoritesConfigMapper } from '../../../../favorites-meta-card/favorite-config-mapper'; import { createMetaCardMenuItemSeparator, MetaCardMenuItem, diff --git a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-list-config.service.ts b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-list-config.service.ts index 1848861dae..0f091dbd85 100644 --- a/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-list-config.service.ts +++ b/src/frontend/packages/core/src/shared/components/list/list-types/endpoint/endpoints-list-config.service.ts @@ -5,11 +5,11 @@ import { filter } from 'rxjs/operators'; import { ListView } from '../../../../../../../store/src/actions/list.actions'; import { AppState } from '../../../../../../../store/src/app-state'; import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog'; +import { FavoritesConfigMapper } from '../../../../../../../store/src/favorite-config-mapper'; import { EntityMonitorFactory } from '../../../../../../../store/src/monitors/entity-monitor.factory.service'; import { InternalEventMonitorFactory } from '../../../../../../../store/src/monitors/internal-event-monitor.factory'; import { PaginationMonitorFactory } from '../../../../../../../store/src/monitors/pagination-monitor.factory'; import { EndpointModel } from '../../../../../../../store/src/types/endpoint.types'; -import { FavoritesConfigMapper } from '../../../favorites-meta-card/favorite-config-mapper'; import { createTableColumnFavorite } from '../../list-table/table-cell-favorite/table-cell-favorite.component'; import { ITableColumn } from '../../list-table/table.types'; import { IListAction, IListConfig, ListViewTypes } from '../../list.component.types'; diff --git a/src/frontend/packages/core/src/shared/components/page-header/page-header.component.ts b/src/frontend/packages/core/src/shared/components/page-header/page-header.component.ts index ce65f784ba..a032a1d887 100644 --- a/src/frontend/packages/core/src/shared/components/page-header/page-header.component.ts +++ b/src/frontend/packages/core/src/shared/components/page-header/page-header.component.ts @@ -10,6 +10,7 @@ import { ToggleSideNav } from '../../../../../store/src/actions/dashboard-action import { AddRecentlyVisitedEntityAction } from '../../../../../store/src/actions/recently-visited.actions'; import { AppState } from '../../../../../store/src/app-state'; import { EntityCatalogHelpers } from '../../../../../store/src/entity-catalog/entity-catalog.helper'; +import { FavoritesConfigMapper } from '../../../../../store/src/favorite-config-mapper'; import { selectIsMobile } from '../../../../../store/src/selectors/dashboard.selectors'; import { InternalEventSeverity } from '../../../../../store/src/types/internal-events.types'; import { IFavoriteMetadata, UserFavorite } from '../../../../../store/src/types/user-favorites.types'; @@ -18,7 +19,6 @@ import { UserProfileService } from '../../../core/user-profile.service'; import { IPageSideNavTab } from '../../../features/dashboard/page-side-nav/page-side-nav.component'; import { GlobalEventService, IGlobalEvent } from '../../global-events.service'; import { StratosStatus } from '../../shared.types'; -import { FavoritesConfigMapper } from '../favorites-meta-card/favorite-config-mapper'; import { selectDashboardState } from './../../../../../store/src/selectors/dashboard.selectors'; import { UserProfileInfo } from './../../../../../store/src/types/user-profile.types'; import { BREADCRUMB_URL_PARAM, IHeaderBreadcrumb, IHeaderBreadcrumbLink } from './page-header.types'; diff --git a/src/frontend/packages/store/src/base-entity-types.ts b/src/frontend/packages/store/src/base-entity-types.ts index ed2a579cb7..e9cf682103 100644 --- a/src/frontend/packages/store/src/base-entity-types.ts +++ b/src/frontend/packages/store/src/base-entity-types.ts @@ -1,4 +1,3 @@ -import { BaseEndpointAuth } from '../../core/src/features/endpoints/endpoint-auth'; import { MetricsEndpointDetailsComponent, } from '../../core/src/features/metrics/metrics-endpoint-details/metrics-endpoint-details.component'; @@ -9,6 +8,7 @@ import { userFavoritesEntitySchema, userProfileEntitySchema, } from './base-entity-schemas'; +import { BaseEndpointAuth } from './endpoint-auth'; import { StratosCatalogEndpointEntity, StratosCatalogEntity, diff --git a/src/frontend/packages/core/src/helper.ts b/src/frontend/packages/store/src/browser-encoder.ts similarity index 72% rename from src/frontend/packages/core/src/helper.ts rename to src/frontend/packages/store/src/browser-encoder.ts index 88cbff36f5..ffdc0584ed 100644 --- a/src/frontend/packages/core/src/helper.ts +++ b/src/frontend/packages/store/src/browser-encoder.ts @@ -1,14 +1,5 @@ import { HttpParameterCodec } from '@angular/common/http'; -export function getPath(object: { [key: string]: any }, path: string[]) { - try { - return path.reduce((o, i) => o[i], object); - } catch (err) { - return null; - } -} - - export class BrowserStandardEncoder implements HttpParameterCodec { encodeKey(key: string): string { return encodeURIComponent(key); diff --git a/src/frontend/packages/store/src/effects/auth.effects.ts b/src/frontend/packages/store/src/effects/auth.effects.ts index 8cd9810cc3..086c791cea 100644 --- a/src/frontend/packages/store/src/effects/auth.effects.ts +++ b/src/frontend/packages/store/src/effects/auth.effects.ts @@ -4,7 +4,6 @@ import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { catchError, map, mergeMap, switchMap, tap } from 'rxjs/operators'; -import { BrowserStandardEncoder } from '../../../core/src/helper'; import { InvalidSession, LOGIN, @@ -28,6 +27,7 @@ import { HydrateDashboardStateAction } from '../actions/dashboard-actions'; import { GET_ENDPOINTS_SUCCESS, GetAllEndpointsSuccess } from '../actions/endpoint.actions'; import { GetSystemInfo } from '../actions/system.actions'; import { DispatchOnlyAppState } from '../app-state'; +import { BrowserStandardEncoder } from '../browser-encoder'; import { getDashboardStateSessionId } from '../helpers/store-helpers'; import { SessionData } from '../types/auth.types'; diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index 35ac3594a3..0a7f25fcae 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -4,7 +4,6 @@ import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { catchError, mergeMap } from 'rxjs/operators'; -import { BrowserStandardEncoder } from '../../../core/src/helper'; import { CONNECT_ENDPOINTS, CONNECT_ENDPOINTS_FAILED, @@ -33,6 +32,7 @@ import { GET_SYSTEM_INFO_SUCCESS, GetSystemInfo, GetSystemSuccess } from '../act import { GetUserFavoritesAction } from '../actions/user-favourites-actions/get-user-favorites-action'; import { DispatchOnlyAppState } from '../app-state'; import { STRATOS_ENDPOINT_TYPE } from '../base-entity-schemas'; +import { BrowserStandardEncoder } from '../browser-encoder'; import { entityCatalog } from '../entity-catalog/entity-catalog'; import { EndpointType } from '../extension-types'; import { endpointSchemaKey } from '../helpers/entity-factory'; diff --git a/src/frontend/packages/core/src/features/endpoints/endpoint-auth.ts b/src/frontend/packages/store/src/endpoint-auth.ts similarity index 59% rename from src/frontend/packages/core/src/features/endpoints/endpoint-auth.ts rename to src/frontend/packages/store/src/endpoint-auth.ts index 9c771119f0..5cad621ff1 100644 --- a/src/frontend/packages/core/src/features/endpoints/endpoint-auth.ts +++ b/src/frontend/packages/store/src/endpoint-auth.ts @@ -1,10 +1,16 @@ import { Validators } from '@angular/forms'; -import { EndpointAuthTypeConfig, EndpointType } from '../../../../store/src/extension-types'; -import { CredentialsAuthFormComponent } from './connect-endpoint-dialog/auth-forms/credentials-auth-form.component'; -import { NoneAuthFormComponent } from './connect-endpoint-dialog/auth-forms/none-auth-form.component'; -import { SSOAuthFormComponent } from './connect-endpoint-dialog/auth-forms/sso-auth-form.component'; -import { EndpointAuthTypeNames } from './endpoint-helpers'; +import { + CredentialsAuthFormComponent, +} from '../../core/src/features/endpoints/connect-endpoint-dialog/auth-forms/credentials-auth-form.component'; +import { + NoneAuthFormComponent, +} from '../../core/src/features/endpoints/connect-endpoint-dialog/auth-forms/none-auth-form.component'; +import { + SSOAuthFormComponent, +} from '../../core/src/features/endpoints/connect-endpoint-dialog/auth-forms/sso-auth-form.component'; +import { EndpointAuthTypeNames } from '../../core/src/features/endpoints/endpoint-helpers'; +import { EndpointAuthTypeConfig, EndpointType } from './extension-types'; export abstract class BaseEndpointAuth { static readonly UsernamePassword = { diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts index b754067761..5ad125609d 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.ts @@ -1,6 +1,5 @@ import { ActionReducer } from '@ngrx/store'; -import { KnownKeys, NonOptionalKeys } from '../../../../core/src/core/utils.service'; import { getFullEndpointApiUrl } from '../../../../core/src/features/endpoints/endpoint-helpers'; import { IRequestEntityTypeState } from '../../app-state'; import { endpointEntitySchema, STRATOS_ENDPOINT_TYPE } from '../../base-entity-schemas'; @@ -37,6 +36,7 @@ import { import { ActionBuilderConfigMapper } from './action-builder-config.mapper'; import { ActionDispatchers, EntityCatalogEntityStoreHelpers } from './entity-catalog-entity-store-helpers'; import { EntityCatalogEntityStore } from './entity-catalog-entity.types'; +import { KnownKeys, NonOptionalKeys } from './type.helpers'; export type KnownActionBuilders = Pick>>>; diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.types.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.types.ts index 0280477e6f..84c0592670 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.types.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity.types.ts @@ -1,15 +1,10 @@ -import { - FilteredByNotReturnType, - FilteredByReturnType, - KnownKeys, - NeverKeys, -} from '../../../../core/src/core/utils.service'; import { EntityService } from '../../entity-service'; import { EntityMonitor } from '../../monitors/entity-monitor'; import { PaginationMonitor } from '../../monitors/pagination-monitor'; import { PaginationObservables } from '../../reducers/pagination-reducer/pagination-reducer.types'; import { PaginatedAction } from '../../types/pagination.types'; import { OrchestratedActionBuilders, OrchestratedActionCoreBuilders } from '../action-orchestrator/action-orchestrator'; +import { FilteredByNotReturnType, FilteredByReturnType, KnownKeys, NeverKeys } from './type.helpers'; /** * Core entity and entities access (entity/entities monitors and services) @@ -105,7 +100,7 @@ export type CustomEntityCatalogEntityStore = { + [K in keyof T]: string extends K ? never : number extends K ? never : K +} extends { [_ in keyof T]: infer U } ? ({} extends U ? never : U) : never; + +export type NonOptionalKeys = Exclude<{ + [K in keyof T]: T extends Record + ? K + : never +}[keyof T], undefined> + +export type OptionalKeys = Exclude<{ + [K in keyof T]: T extends Record + ? K + : never +}[keyof T], undefined> + +export type NeverKeys = Exclude<{ + [K in keyof T]: T[K] extends never + ? K + : never +}[keyof T], undefined> + +/** + * Pick all properties who's function has the specified return type U + */ +export type FilteredByReturnType any }, U> = { + [P in keyof T]: ReturnType extends U ? T[P] : never +}; + +/** + * Pick all properties who's function do not have the specified return type U + */ +export type FilteredByNotReturnType any }, U> = { + [P in keyof T]: ReturnType extends U ? never : T[P] +}; + +// Note - Adding }[keyof T] to [P in keyof T] types should filter out properties of type `never`, however this fails with generics! +export type FilteredByValueType any }, U> = { + [P in keyof T]: T[P] extends U ? never : T[P] +}; diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts index ce4979a9fc..38bd2aec54 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog.spec.ts @@ -1,8 +1,8 @@ -import { BaseEndpointAuth } from '../../../core/src/features/endpoints/endpoint-auth'; import { EndpointListDetailsComponent, } from '../../../core/src/shared/components/list/list-types/endpoint/endpoint-list.helpers'; import { endpointEntitySchema } from '../base-entity-schemas'; +import { BaseEndpointAuth } from '../endpoint-auth'; import { EntitySchema } from '../helpers/entity-schema'; import { TestEntityCatalog } from './entity-catalog'; import { StratosCatalogEndpointEntity, StratosCatalogEntity } from './entity-catalog-entity/entity-catalog-entity'; diff --git a/src/frontend/packages/store/src/entity-catalog/entity-catalog.types.ts b/src/frontend/packages/store/src/entity-catalog/entity-catalog.types.ts index a0bba1cf85..33b6fea18f 100644 --- a/src/frontend/packages/store/src/entity-catalog/entity-catalog.types.ts +++ b/src/frontend/packages/store/src/entity-catalog/entity-catalog.types.ts @@ -1,8 +1,6 @@ import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; -import { EndpointHealthCheck } from '../../../core/endpoints-health-checks'; -import { FavoritesConfigMapper } from '../../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { StratosStatus } from '../../../core/src/shared/shared.types'; import { GeneralEntityAppState } from '../app-state'; import { @@ -21,7 +19,9 @@ import { PaginationPageIteratorConfig, } from '../entity-request-pipeline/pagination-request-base-handlers/pagination-iterator.pipe'; import { EndpointAuthTypeConfig } from '../extension-types'; +import { FavoritesConfigMapper } from '../favorite-config-mapper'; import { EntitySchema } from '../helpers/entity-schema'; +import { EndpointModel } from '../types/endpoint.types'; import { UserFavorite } from '../types/user-favorites.types'; export interface EntityCatalogEntityConfig { @@ -95,6 +95,17 @@ export interface IStratosBaseEntityDefinition void + ) { } +} + /** * Static information describing a stratos endpoint. * diff --git a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts b/src/frontend/packages/store/src/favorite-config-mapper.ts similarity index 86% rename from src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts rename to src/frontend/packages/store/src/favorite-config-mapper.ts index 94e4d2bbd6..7a5faf9b60 100644 --- a/src/frontend/packages/core/src/shared/components/favorites-meta-card/favorite-config-mapper.ts +++ b/src/frontend/packages/store/src/favorite-config-mapper.ts @@ -1,21 +1,16 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { entityCatalog } from '../../../../../store/src/entity-catalog/entity-catalog'; import { - StratosBaseCatalogEntity, -} from '../../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; -import { EntityCatalogHelpers } from '../../../../../store/src/entity-catalog/entity-catalog.helper'; -import { IEntityMetadata, IStratosEntityDefinition } from '../../../../../store/src/entity-catalog/entity-catalog.types'; -import { EndpointModel } from '../../../../../store/src/types/endpoint.types'; -import { EntityRequestAction } from '../../../../../store/src/types/request.types'; -import { - IFavoriteMetadata, - IFavoriteTypeInfo, - UserFavorite, - UserFavoriteEndpoint, -} from '../../../../../store/src/types/user-favorites.types'; -import { MetaCardMenuItem } from '../list/list-cards/meta-card/meta-card-base/meta-card.component'; + MetaCardMenuItem, +} from '../../core/src/shared/components/list/list-cards/meta-card/meta-card-base/meta-card.component'; +import { entityCatalog } from './entity-catalog/entity-catalog'; +import { StratosBaseCatalogEntity } from './entity-catalog/entity-catalog-entity/entity-catalog-entity'; +import { EntityCatalogHelpers } from './entity-catalog/entity-catalog.helper'; +import { IEntityMetadata, IStratosEntityDefinition } from './entity-catalog/entity-catalog.types'; +import { EndpointModel } from './types/endpoint.types'; +import { EntityRequestAction } from './types/request.types'; +import { IFavoriteMetadata, IFavoriteTypeInfo, UserFavorite, UserFavoriteEndpoint } from './types/user-favorites.types'; export interface IFavoriteTypes { diff --git a/src/frontend/packages/store/src/reducers.module.ts b/src/frontend/packages/store/src/reducers.module.ts index 23054fd7fb..d5268b68bf 100644 --- a/src/frontend/packages/store/src/reducers.module.ts +++ b/src/frontend/packages/store/src/reducers.module.ts @@ -1,10 +1,7 @@ import { NgModule } from '@angular/core'; import { ActionReducer, ActionReducerMap, StoreModule } from '@ngrx/store'; -import { StoreDevtoolsModule } from '@ngrx/store-devtools'; - import { localStorageSync } from 'ngrx-store-localstorage'; -import { environment } from '../../core/src/environments/environment'; import { getDashboardStateSessionId } from './helpers/store-helpers'; import { actionHistoryReducer } from './reducers/action-history-reducer'; import { requestReducer } from './reducers/api-request-reducers.generator'; @@ -71,29 +68,21 @@ export function localStorageSyncReducer(reducer: ActionReducer): ActionRedu })(reducer); } -const metaReducers = [localStorageSyncReducer]; -const storeModule = StoreModule.forRoot( - appReducers, - { - metaReducers, - runtimeChecks: { - strictStateImmutability: true, - strictActionImmutability: false - } - } -); -const imports = environment.production ? [ - storeModule -] : [ - storeModule, - StoreDevtoolsModule.instrument({ - maxAge: 100, - logOnly: !environment.production - }) - ]; +const metaReducers = [localStorageSyncReducer]; @NgModule({ - imports + imports: [ + StoreModule.forRoot( + appReducers, + { + metaReducers, + runtimeChecks: { + strictStateImmutability: true, + strictActionImmutability: false + } + } + ) + ] }) export class AppReducersModule { } diff --git a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer.helper.ts b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer.helper.ts index 56a5e0bef4..427a184b21 100644 --- a/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer.helper.ts +++ b/src/frontend/packages/store/src/reducers/pagination-reducer/pagination-reducer.helper.ts @@ -12,7 +12,6 @@ import { tap, } from 'rxjs/operators'; -import { sortStringify } from '../../../../core/src/core/utils.service'; import { SetInitialParams } from '../../actions/pagination.actions'; import { AppState, GeneralEntityAppState } from '../../app-state'; import { entityCatalog } from '../../entity-catalog/entity-catalog'; @@ -152,6 +151,14 @@ function paginationParamsString(params: PaginationParam): string { return sortStringify(clone); } + +function sortStringify(obj: { [key: string]: string | string[] | number }): string { + const keys = Object.keys(obj).sort(); + return keys.reduce((res, key) => { + return res += `${key}-${obj[key]},`; + }, ''); +} + function shouldFetchNonLocalList(pagination: PaginationEntityState): boolean { return !hasError(pagination) && !hasValidOrGettingPage(pagination); } diff --git a/src/frontend/packages/store/src/selectors/current-user-role.selectors.ts b/src/frontend/packages/store/src/selectors/current-user-role.selectors.ts index 166767e168..6e274d7fa8 100644 --- a/src/frontend/packages/store/src/selectors/current-user-role.selectors.ts +++ b/src/frontend/packages/store/src/selectors/current-user-role.selectors.ts @@ -1,7 +1,6 @@ import { compose } from '@ngrx/store'; import { PermissionValues } from '../../../core/src/core/permissions/current-user-permissions.config'; -import { StratosScopeStrings } from '../../../core/src/core/permissions/stratos-user-permissions.checker'; import { CurrentUserRolesAppState } from '../app-state'; import { ICurrentUserRolesState, IStratosRolesState } from '../types/current-user-roles.types'; import { UserScopeStrings } from '../types/endpoint.types'; @@ -38,7 +37,7 @@ export const getCurrentUserStratosRole = (role: PermissionValues) => compose( // Top level stratos endpoint scopes // ============================ -export const getCurrentUserStratosHasScope = (scope: StratosScopeStrings) => compose( +export const getCurrentUserStratosHasScope = (scope: UserScopeStrings) => compose( selectCurrentUserGlobalHasScopes(scope), selectCurrentUserStratosScopesState, getCurrentUserStratosRolesState diff --git a/src/frontend/packages/store/src/types/auth.types.ts b/src/frontend/packages/store/src/types/auth.types.ts index 5cf7e40f42..cef354d888 100644 --- a/src/frontend/packages/store/src/types/auth.types.ts +++ b/src/frontend/packages/store/src/types/auth.types.ts @@ -1,5 +1,3 @@ -import { StratosScopeStrings } from '../../../core/src/core/permissions/stratos-user-permissions.checker'; - export interface SessionDataEndpoint { guid: string; name: string; @@ -11,7 +9,7 @@ export interface SessionUser { admin: boolean; guid: string; name: string; - scopes: StratosScopeStrings[]; + scopes: string[]; } export interface PluginConfig { userInvitationsEnabled: 'true' | 'false'; diff --git a/src/frontend/packages/store/src/types/endpoint.types.ts b/src/frontend/packages/store/src/types/endpoint.types.ts index 25ccfe3689..779b7cabbd 100644 --- a/src/frontend/packages/store/src/types/endpoint.types.ts +++ b/src/frontend/packages/store/src/types/endpoint.types.ts @@ -1,4 +1,3 @@ -import { StratosScopeStrings } from '../../../core/src/core/permissions/stratos-user-permissions.checker'; import { MetricsAPITargets, MetricsStratosInfo } from '../actions/metrics-api.actions'; import { EndpointType } from '../extension-types'; import { endpointSchemaKey } from '../helpers/entity-factory'; @@ -63,7 +62,7 @@ export interface EndpointModel { export const SystemSharedUserGuid = '00000000-1111-2222-3333-444444444444'; -export type UserScopeStrings = string | StratosScopeStrings; +export type UserScopeStrings = string; // Metadata for the user connected to an endpoint export interface EndpointUser { diff --git a/src/frontend/packages/store/src/user-favorite-helpers.ts b/src/frontend/packages/store/src/user-favorite-helpers.ts index 2033859a4f..84f81be582 100644 --- a/src/frontend/packages/store/src/user-favorite-helpers.ts +++ b/src/frontend/packages/store/src/user-favorite-helpers.ts @@ -1,6 +1,6 @@ -import { FavoritesConfigMapper } from '../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { entityCatalog } from './entity-catalog/entity-catalog'; import { IEntityMetadata } from './entity-catalog/entity-catalog.types'; +import { FavoritesConfigMapper } from './favorite-config-mapper'; import { IFavoriteMetadata, UserFavorite } from './types/user-favorites.types'; export function isEndpointTypeFavorite(favorite: UserFavorite) { diff --git a/src/frontend/packages/store/src/user-favorite-manager.ts b/src/frontend/packages/store/src/user-favorite-manager.ts index b67f56c0e3..d6420bf804 100644 --- a/src/frontend/packages/store/src/user-favorite-manager.ts +++ b/src/frontend/packages/store/src/user-favorite-manager.ts @@ -3,13 +3,10 @@ import { Store } from '@ngrx/store'; import { combineLatest, Observable, of } from 'rxjs'; import { filter, map, switchMap, tap } from 'rxjs/operators'; -import { - FavoritesConfigMapper, - TFavoriteMapperFunction, -} from '../../core/src/shared/components/favorites-meta-card/favorite-config-mapper'; import { ToggleUserFavoriteAction } from './actions/user-favourites-actions/toggle-user-favorite-action'; import { GeneralEntityAppState, IRequestEntityTypeState } from './app-state'; import { entityCatalog } from './entity-catalog/entity-catalog'; +import { FavoritesConfigMapper, TFavoriteMapperFunction } from './favorite-config-mapper'; import { endpointEntitiesSelector } from './selectors/endpoint.selectors'; import { errorFetchingFavoritesSelector,