From 53fab30b88cf204756b8b5d49e52905c7335e428 Mon Sep 17 00:00:00 2001 From: Miroir Framework Date: Wed, 10 Apr 2024 20:24:44 +0200 Subject: [PATCH] refactor #23: enable use of DomainSelector functions on LocalCache state (current DeploymentEntityState). Generalize types for useDeploymentEntityStateQuerySelector, by making the StateType (DeploymentEntityState) a parameter, so that selectors that do not depend on the state type can be used on different state types STEP 2, remove old type uses. --- ...oymentEntityStateQuerySelectorInterface.ts | 51 ++++------ .../DeploymentEntityStateQuerySelectors.ts | 97 +++++++++---------- packages/miroir-core/src/index.ts | 10 +- .../DomainStateMemoizedSelectors.ts | 4 +- .../localCache/LocalCacheSliceSelectors.ts | 24 ++--- .../src/miroir-fwk/4_view/ReduxHooks.ts | 14 ++- .../4_view/ReportSectionListDisplay.tsx | 4 - .../miroir-fwk/4_view/ReportSectionView.tsx | 6 +- .../4_view/RootReportSectionView.tsx | 12 +-- .../src/miroir-fwk/4_view/Sidebar.tsx | 11 ++- 10 files changed, 99 insertions(+), 134 deletions(-) diff --git a/packages/miroir-core/src/0_interfaces/2_domain/DeploymentEntityStateQuerySelectorInterface.ts b/packages/miroir-core/src/0_interfaces/2_domain/DeploymentEntityStateQuerySelectorInterface.ts index 9c0a21c5..e7a3613e 100644 --- a/packages/miroir-core/src/0_interfaces/2_domain/DeploymentEntityStateQuerySelectorInterface.ts +++ b/packages/miroir-core/src/0_interfaces/2_domain/DeploymentEntityStateQuerySelectorInterface.ts @@ -1,13 +1,14 @@ import { DomainElement, DomainElementObject, + DomainModelGetEntityDefinitionQueryParams, + DomainModelGetFetchParamJzodSchemaQueryParams, + DomainModelGetSingleSelectQueryJzodSchemaQueryParams, DomainModelQueryJzodSchemaParams, JzodElement, JzodObject, MiroirSelectorQueryParams } from "../1_core/preprocessor-generated/miroirFundamentalType"; -import { DeploymentEntityState } from "./DeploymentStateInterface"; -import { DomainState } from "./DomainControllerInterface"; // ################################################################################################ export type RecordOfJzodElement = Record; @@ -21,51 +22,35 @@ export type QuerySelectorMap }; +// ################################################################################################ export interface QuerySelectorParams { selectorMap?: QuerySelectorMap query: QueryType } +// ################################################################################################ export type QuerySelector = ( domainState: StateType, params: QuerySelectorParams ) => ResultType; - - - // ################################################################################################ -export type DeploymentEntityStateQuerySelectorMap = { - [k: string]: DeploymentEntityStateQuerySelector; +export type JzodSchemaQuerySelectorMap = { + selectJzodSchemaByDomainModelQuery: JzodSchemaQuerySelector, + selectEntityJzodSchema: JzodSchemaQuerySelector, + selectFetchQueryJzodSchema: JzodSchemaQuerySelector, + selectJzodSchemaBySingleSelectQuery: JzodSchemaQuerySelector, }; -export interface DeploymentEntityStateQuerySelectorParams { - selectorMap?: DeploymentEntityStateQuerySelectorMap - query: Q +// ################################################################################################ +export interface JzodSchemaQuerySelectorParams { + selectorMap: JzodSchemaQuerySelectorMap + query: QueryType } -export type DeploymentEntityStateQuerySelector = ( - domainState: DeploymentEntityState, - params: DeploymentEntityStateQuerySelectorParams -) => T; - - -// // ################################################################################################ -export type DeploymentEntityStateJzodSchemaSelector = ( - domainState: DeploymentEntityState, - params: DeploymentEntityStateJzodSchemaSelectorParams +// ################################################################################################ +export type JzodSchemaQuerySelector = ( + domainState: StateType, + params: JzodSchemaQuerySelectorParams ) => RecordOfJzodElement | JzodElement | undefined; -export type DeploymentEntityStateJzodSchemaSelectorMap = {[k:string]: DeploymentEntityStateJzodSchemaSelector}; - -export interface DeploymentEntityStateJzodSchemaSelectorParams { - selectorMap: DeploymentEntityStateJzodSchemaSelectorMap - query: Q -} - -// // ################################################################################################ -// export type DomainStateSelector

= ( -// domainState: DomainState, -// params: P -// ) => T; - diff --git a/packages/miroir-core/src/2_domain/DeploymentEntityStateQuerySelectors.ts b/packages/miroir-core/src/2_domain/DeploymentEntityStateQuerySelectors.ts index 1bf26685..360aa254 100644 --- a/packages/miroir-core/src/2_domain/DeploymentEntityStateQuerySelectors.ts +++ b/packages/miroir-core/src/2_domain/DeploymentEntityStateQuerySelectors.ts @@ -1,11 +1,4 @@ -import { DomainState } from "../0_interfaces/2_domain/DomainControllerInterface"; import { - DomainStateJzodSchemaSelectorMap, - DomainStateJzodSchemaSelectorParams, - DomainStateJzodSchemaSelector, - DomainStateQuerySelectorMap, - DomainStateQuerySelector, - DomainStateQuerySelectorParams, RecordOfJzodElement, RecordOfJzodObject } from "../0_interfaces/2_domain/DomainStateQuerySelectorInterface"; @@ -27,25 +20,30 @@ import { EntityInstance, JzodElement, JzodObject, - MiroirCustomQueryParams, MiroirSelectorQueryParams, MiroirSelectQuery, - QueryObjectReference, SelectObjectListByManyToManyRelationQuery, SelectObjectListByRelationQuery, SelectObjectQuery } from "../0_interfaces/1_core/preprocessor-generated/miroirFundamentalType"; +import { + JzodSchemaQuerySelector, + JzodSchemaQuerySelectorMap, + JzodSchemaQuerySelectorParams, + QuerySelector, + QuerySelectorMap, + QuerySelectorParams +} from "../0_interfaces/2_domain/DeploymentEntityStateQuerySelectorInterface"; +import { DeploymentEntityState } from "../0_interfaces/2_domain/DeploymentStateInterface"; import { LoggerInterface } from "../0_interfaces/4-services/LoggerInterface"; import { MiroirLoggerFactory } from "../4_services/Logger"; +import entityEntityDefinition from '../assets/miroir_model/16dbfe28-e1d7-4f20-9ba4-c1a9873202ad/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd.json'; import { packageName } from "../constants"; import { getLoggerName } from "../tools"; import { cleanLevel } from "./constants"; -import { applyTransformer } from "./Transformers"; -import entityEntityDefinition from '../assets/miroir_model/16dbfe28-e1d7-4f20-9ba4-c1a9873202ad/54b9c72f-d4f3-4db9-9e0e-0dc840b530bd.json'; -import { resolveContextReference } from "./DomainStateQuerySelectors"; -import { DeploymentEntityState } from "../0_interfaces/2_domain/DeploymentStateInterface"; import { getDeploymentEntityStateIndex } from "./DeploymentEntityState"; -import { DeploymentEntityStateJzodSchemaSelector, DeploymentEntityStateJzodSchemaSelectorMap, DeploymentEntityStateJzodSchemaSelectorParams, DeploymentEntityStateQuerySelector, DeploymentEntityStateQuerySelectorMap, DeploymentEntityStateQuerySelectorParams, QuerySelector, QuerySelectorMap, QuerySelectorParams } from "../0_interfaces/2_domain/DeploymentEntityStateQuerySelectorInterface"; +import { resolveContextReference } from "./DomainStateQuerySelectors"; +import { applyTransformer } from "./Transformers"; const loggerName: string = getLoggerName(packageName, cleanLevel,"DomainSelector"); let log:LoggerInterface = console as any as LoggerInterface; @@ -55,8 +53,12 @@ MiroirLoggerFactory.asyncCreateLogger(loggerName).then( } ); -let emptySelectorMap: DeploymentEntityStateQuerySelectorMap = {} -let emptyJzodSchemaSelectorMap: DeploymentEntityStateJzodSchemaSelectorMap = {} +let emptySelectorMap: QuerySelectorMap = { + selectByDomainManyQueries: {} as QuerySelector, + selectEntityInstanceFromObjectQuery: {} as QuerySelector, + selectEntityInstanceListFromListQuery: {} as QuerySelector, + selectEntityInstanceUuidIndex: {} as QuerySelector, +} // const domainStateSelectorParams = (domainState: DomainState, params: any) => params; @@ -95,11 +97,11 @@ let emptyJzodSchemaSelectorMap: DeploymentEntityStateJzodSchemaSelectorMap = {} * @param selectorParams * @returns */ -export const selectEntityInstanceFromObjectQueryAndDeploymentEntityState:DeploymentEntityStateQuerySelector< - DomainModelGetSingleSelectObjectQueryQueryParams, DomainElement +export const selectEntityInstanceFromObjectQueryAndDeploymentEntityState:QuerySelector< + DomainModelGetSingleSelectObjectQueryQueryParams, DeploymentEntityState, DomainElement > = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateQuerySelectorParams + selectorParams: QuerySelectorParams ): DomainElement => { const querySelectorParams: SelectObjectQuery = selectorParams.query.singleSelectQuery.select as SelectObjectQuery; const deploymentUuid = selectorParams.query.singleSelectQuery.deploymentUuid; @@ -259,11 +261,11 @@ export const selectEntityInstanceFromObjectQueryAndDeploymentEntityState:Deploym // ################################################################################################ // ACCESSES deploymentEntityState -export const selectEntityInstanceUuidIndexFromDeploymentEntityState: DeploymentEntityStateQuerySelector< - DomainModelGetSingleSelectObjectListQueryQueryParams, DomainElement +export const selectEntityInstanceUuidIndexFromDeploymentEntityState: QuerySelector< + DomainModelGetSingleSelectObjectListQueryQueryParams, DeploymentEntityState, DomainElement > = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateQuerySelectorParams + selectorParams: QuerySelectorParams ): DomainElement => { const deploymentUuid = selectorParams.query.singleSelectQuery.deploymentUuid; const applicationSection = selectorParams.query.singleSelectQuery.select.applicationSection??"data"; @@ -336,11 +338,11 @@ export const selectEntityInstanceUuidIndexFromDeploymentEntityState: DeploymentE * @param selectorParams * @returns */ -export const selectEntityInstanceListFromListQueryAndDeploymentEntityState: DeploymentEntityStateQuerySelector< - DomainModelGetSingleSelectObjectListQueryQueryParams, DomainElement +export const selectEntityInstanceListFromListQueryAndDeploymentEntityState: QuerySelector< + DomainModelGetSingleSelectObjectListQueryQueryParams, DeploymentEntityState, DomainElement > = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateQuerySelectorParams + selectorParams: QuerySelectorParams ): DomainElement => { log.info( "selectEntityInstanceListFromListQueryAndDeploymentEntityState called with queryType", @@ -348,7 +350,7 @@ export const selectEntityInstanceListFromListQueryAndDeploymentEntityState: Depl "selectorParams", selectorParams ); - const localSelectorMap: DeploymentEntityStateQuerySelectorMap = + const localSelectorMap: QuerySelectorMap = selectorParams?.selectorMap ?? emptySelectorMap; const selectedInstances: DomainElement = localSelectorMap.selectEntityInstanceUuidIndex( deploymentEntityState, @@ -521,15 +523,12 @@ export const selectEntityInstanceListFromListQueryAndDeploymentEntityState: Depl }; // ################################################################################################ -// export const innerSelectElementFromQuery = ( export const innerSelectElementFromQuery = ( deploymentEntityState: DeploymentEntityState, - // deploymentEntityState: StateTypeParam, newFetchedData: DomainElementObject, pageParams: DomainElementObject, queryParams: DomainElementObject, - selectorMap:DeploymentEntityStateQuerySelectorMap, - // selectorMap:StateQuerySelectorMapParam, + selectorMap:QuerySelectorMap, deploymentUuid: Uuid, query: MiroirSelectQuery ): DomainElement => { @@ -683,11 +682,11 @@ export const innerSelectElementFromQuery = ( } // ################################################################################################ -export const selectByDomainManyQueriesFromDeploymentEntityState:DeploymentEntityStateQuerySelector< - DomainManyQueriesWithDeploymentUuid, DomainElementObject +export const selectByDomainManyQueriesFromDeploymentEntityState:QuerySelector< + DomainManyQueriesWithDeploymentUuid, DeploymentEntityState, DomainElementObject > = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateQuerySelectorParams, + selectorParams: QuerySelectorParams, ): DomainElementObject => { log.info("########## selectByDomainManyQueriesFromDomainState begin, query", selectorParams); @@ -697,7 +696,7 @@ export const selectByDomainManyQueriesFromDeploymentEntityState:DeploymentEntity elementValue: { ...selectorParams.query.contextResults.elementValue }, }; // log.info("########## DomainSelector selectByDomainManyQueriesFromDomainState will use context", context); - const localSelectorMap: DeploymentEntityStateQuerySelectorMap = + const localSelectorMap: QuerySelectorMap = selectorParams?.selectorMap ?? emptySelectorMap; for (const entry of Object.entries(selectorParams.query.fetchQuery.select)) { @@ -766,7 +765,7 @@ export const selectByDomainManyQueriesFromDeploymentEntityState:DeploymentEntity // ################################################################################################ export const selectJzodSchemaBySingleSelectQueryFromDeploymentEntityState = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateJzodSchemaSelectorParams + selectorParams: JzodSchemaQuerySelectorParams ): JzodObject | undefined => { if ( selectorParams.query.singleSelectQuery.select.queryType=="literal" || @@ -806,7 +805,7 @@ export const selectJzodSchemaBySingleSelectQueryFromDeploymentEntityState = ( deploymentUuid: selectorParams.query.singleSelectQuery.deploymentUuid ?? "", entityUuid: entityUuidDomainElement.elementValue, }, - } as DeploymentEntityStateJzodSchemaSelectorParams) as JzodObject | undefined; + } as JzodSchemaQuerySelectorParams) as JzodObject | undefined; } } @@ -814,7 +813,7 @@ export const selectJzodSchemaBySingleSelectQueryFromDeploymentEntityState = ( // ACCESSES deploymentEntityState export const selectEntityJzodSchemaFromDeploymentEntityState = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateJzodSchemaSelectorParams + selectorParams: JzodSchemaQuerySelectorParams ): JzodObject | undefined => { const localQuery: DomainModelGetEntityDefinitionQueryParams = selectorParams.query; @@ -852,7 +851,7 @@ export const selectEntityJzodSchemaFromDeploymentEntityState = ( */ export const selectFetchQueryJzodSchemaFromDeploymentEntityState = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateJzodSchemaSelectorParams + selectorParams: JzodSchemaQuerySelectorParams ): RecordOfJzodObject | undefined => { const localFetchParams: DomainManyQueriesWithDeploymentUuid = selectorParams.query.fetchParams // log.info("selectFetchQueryJzodSchemaFromDomainState called", selectorParams.query); @@ -873,7 +872,7 @@ export const selectFetchQueryJzodSchemaFromDeploymentEntityState = ( select: entry[1], }, }, - } as DeploymentEntityStateJzodSchemaSelectorParams), + } as JzodSchemaQuerySelectorParams), ]) ) as RecordOfJzodObject; @@ -900,27 +899,27 @@ export const selectFetchQueryJzodSchemaFromDeploymentEntityState = ( // ################################################################################################ export const selectJzodSchemaByDomainModelQueryFromDeploymentEntityState = ( deploymentEntityState: DeploymentEntityState, - selectorParams: DeploymentEntityStateJzodSchemaSelectorParams + selectorParams: JzodSchemaQuerySelectorParams ): RecordOfJzodElement | JzodElement | undefined => { switch (selectorParams.query.queryType) { case "getEntityDefinition":{ return selectorParams.selectorMap.selectEntityJzodSchema( deploymentEntityState, - selectorParams as DeploymentEntityStateJzodSchemaSelectorParams + selectorParams as JzodSchemaQuerySelectorParams ); break; } case "getFetchParamsJzodSchema": { return selectorParams.selectorMap.selectFetchQueryJzodSchema( deploymentEntityState, - selectorParams as DeploymentEntityStateJzodSchemaSelectorParams + selectorParams as JzodSchemaQuerySelectorParams ); break; } case "getSingleSelectQueryJzodSchema": { - return selectorParams.selectorMap.selectJzodSchemaBySingleSelectQueryFromDeploymentEntityState( + return selectorParams.selectorMap.selectJzodSchemaBySingleSelectQuery( deploymentEntityState, - selectorParams as DeploymentEntityStateJzodSchemaSelectorParams + selectorParams as JzodSchemaQuerySelectorParams ); break; } @@ -973,16 +972,16 @@ export function getDeploymentEntityStateSelectorMap { // return jzodSchemaSelectorMap; return { - selectJzodSchemaByDomainModelQuery: selectJzodSchemaByDomainModelQueryFromDeploymentEntityState, + selectJzodSchemaByDomainModelQuery: selectJzodSchemaByDomainModelQueryFromDeploymentEntityState as JzodSchemaQuerySelector, selectEntityJzodSchema: - selectEntityJzodSchemaFromDeploymentEntityState as DeploymentEntityStateJzodSchemaSelector, + selectEntityJzodSchemaFromDeploymentEntityState as JzodSchemaQuerySelector, selectFetchQueryJzodSchema: - selectFetchQueryJzodSchemaFromDeploymentEntityState as DeploymentEntityStateJzodSchemaSelector, + selectFetchQueryJzodSchemaFromDeploymentEntityState as JzodSchemaQuerySelector, selectJzodSchemaBySingleSelectQuery: - selectJzodSchemaBySingleSelectQueryFromDeploymentEntityState as DeploymentEntityStateJzodSchemaSelector, + selectJzodSchemaBySingleSelectQueryFromDeploymentEntityState as JzodSchemaQuerySelector, }; } diff --git a/packages/miroir-core/src/index.ts b/packages/miroir-core/src/index.ts index cc353bba..65bb3bef 100644 --- a/packages/miroir-core/src/index.ts +++ b/packages/miroir-core/src/index.ts @@ -301,15 +301,13 @@ export { RecordOfJzodObject, } from './0_interfaces/2_domain/DomainStateQuerySelectorInterface.js'; export { + JzodSchemaQuerySelector, + JzodSchemaQuerySelectorMap, + JzodSchemaQuerySelectorParams, QuerySelector, QuerySelectorMap, QuerySelectorParams, - DeploymentEntityStateQuerySelector, - DeploymentEntityStateQuerySelectorMap, - DeploymentEntityStateQuerySelectorParams, - DeploymentEntityStateJzodSchemaSelector, - DeploymentEntityStateJzodSchemaSelectorMap, - DeploymentEntityStateJzodSchemaSelectorParams, + // RecordOfJzodElement, // RecordOfJzodObject, } from './0_interfaces/2_domain/DeploymentEntityStateQuerySelectorInterface.js'; diff --git a/packages/miroir-localcache-redux/src/4_services/localCache/DomainStateMemoizedSelectors.ts b/packages/miroir-localcache-redux/src/4_services/localCache/DomainStateMemoizedSelectors.ts index 8417f1c8..f33f2cd7 100644 --- a/packages/miroir-localcache-redux/src/4_services/localCache/DomainStateMemoizedSelectors.ts +++ b/packages/miroir-localcache-redux/src/4_services/localCache/DomainStateMemoizedSelectors.ts @@ -1,10 +1,10 @@ import { createSelector } from "@reduxjs/toolkit"; import { DeploymentEntityState, - DeploymentEntityStateJzodSchemaSelectorMap, DomainState, DomainStateJzodSchemaSelectorMap, DomainStateQuerySelectorMap, + JzodSchemaQuerySelectorMap, MiroirSelectorQueryParams, QuerySelectorMap, selectByDomainManyQueriesFromDeploymentEntityState, @@ -74,7 +74,7 @@ export function getMemoizedDeploymentEntityStateSelectorMap(): QuerySelectorMap< }; } -export function getMemoizedDeploymentEntityStateJzodSchemaSelectorMap(): DeploymentEntityStateJzodSchemaSelectorMap { +export function getMemoizedDeploymentEntityStateJzodSchemaSelectorMap(): JzodSchemaQuerySelectorMap { // return jzodSchemaSelectorMap; return { selectJzodSchemaByDomainModelQuery: createSelector( diff --git a/packages/miroir-localcache-redux/src/4_services/localCache/LocalCacheSliceSelectors.ts b/packages/miroir-localcache-redux/src/4_services/localCache/LocalCacheSliceSelectors.ts index 1d7a4f8a..b931d7b6 100644 --- a/packages/miroir-localcache-redux/src/4_services/localCache/LocalCacheSliceSelectors.ts +++ b/packages/miroir-localcache-redux/src/4_services/localCache/LocalCacheSliceSelectors.ts @@ -8,9 +8,6 @@ import { createSelector } from "@reduxjs/toolkit"; import { DeploymentEntityState, - DeploymentEntityStateJzodSchemaSelectorParams, - DeploymentEntityStateQuerySelector, - DeploymentEntityStateQuerySelectorParams, DomainElement, DomainModelQueryJzodSchemaParams, DomainState, @@ -60,15 +57,6 @@ declare type SelectorParamsSelector ) => QuerySelectorParams; -declare type DeploymentEntityStateSelectorParamsSelector = ( - reduxState: ReduxStateWithUndoRedo, - params: DeploymentEntityStateQuerySelectorParams -) => DeploymentEntityStateQuerySelectorParams; - -declare type DeploymentEntityStateJzodSchemaSelectorParamsSelector = ( - reduxState: ReduxStateWithUndoRedo, - params: DeploymentEntityStateJzodSchemaSelectorParams -) => DeploymentEntityStateJzodSchemaSelectorParams; // ################################################################################################ export const selectCurrentDeploymentEntityStateFromReduxState = ( @@ -78,10 +66,10 @@ export const selectCurrentDeploymentEntityStateFromReduxState = ( }; // ################################################################################################ -export const selectDeploymentEntityStateSelectorParams /*: DomainStateSelectorParamsSelector */ = ( +export const selectDeploymentEntityStateSelectorParams /*: DomainStateSelectorParamsSelector */ = ( reduxState: ReduxStateWithUndoRedo, - params: DeploymentEntityStateQuerySelectorParams -): DeploymentEntityStateQuerySelectorParams => { + params: QuerySelectorParams +): QuerySelectorParams => { return params; }; @@ -159,14 +147,14 @@ export const selectDomainStateJzodSchemaSelectorParams = ( // TODO: memoize? - deploymentEntityStateQuerySelector: DeploymentEntityStateQuerySelector + deploymentEntityStateQuerySelector: QuerySelector ): ( reduxState: ReduxStateWithUndoRedo, - params: DeploymentEntityStateQuerySelectorParams + params: QuerySelectorParams ) => ResultType { return createSelector( // [selectCurrentDeploymentEntityStateFromReduxState, selectDomainStateSelectorParams as DomainStateSelectorParamsSelector], - [selectCurrentDeploymentEntityStateFromReduxState, selectDeploymentEntityStateSelectorParams as DeploymentEntityStateSelectorParamsSelector], + [selectCurrentDeploymentEntityStateFromReduxState, selectDeploymentEntityStateSelectorParams as SelectorParamsSelector], deploymentEntityStateQuerySelector ) } diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReduxHooks.ts b/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReduxHooks.ts index e40111b8..2ea0e600 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReduxHooks.ts +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReduxHooks.ts @@ -6,8 +6,6 @@ import { useSelector } from "react-redux"; import { ApplicationSection, DeploymentEntityState, - DeploymentEntityStateQuerySelector, - DeploymentEntityStateQuerySelectorParams, DomainElement, DomainModelQueryJzodSchemaParams, DomainStateJzodSchemaSelector, @@ -55,16 +53,16 @@ MiroirLoggerFactory.asyncCreateLogger(loggerName).then((value: LoggerInterface) export type EntityInstanceUuidIndexSelectorParams = LocalCacheEntityInstancesSelectorParams; // ################################################################################################ -export function useDeploymentEntityStateQuerySelector( - deploymentEntityStateQuerySelector:DeploymentEntityStateQuerySelector, - selectorParams:DeploymentEntityStateQuerySelectorParams, - customQueryInterpreter?: { [k: string]: (query:MiroirSelectorQueryParams) => T } -): T { +export function useDeploymentEntityStateQuerySelector( + deploymentEntityStateQuerySelector:QuerySelector, + selectorParams:QuerySelectorParams, + customQueryInterpreter?: { [k: string]: (query:MiroirSelectorQueryParams) => ResultType } +): ResultType { const innerSelector = useMemo( () => { return applyDeploymentEntityStateQuerySelector(deploymentEntityStateQuerySelector); }, [deploymentEntityStateQuerySelector]); - const result: T = useSelector((state: ReduxStateWithUndoRedo) => + const result: ResultType = useSelector((state: ReduxStateWithUndoRedo) => innerSelector(state, selectorParams) ); return result diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionListDisplay.tsx b/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionListDisplay.tsx index 3a31dab1..d8050ecd 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionListDisplay.tsx +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionListDisplay.tsx @@ -11,9 +11,6 @@ import { ApplicationDeploymentConfiguration, ApplicationDeploymentSchema, DeploymentEntityState, - DeploymentEntityStateQuerySelector, - DeploymentEntityStateQuerySelectorMap, - DeploymentEntityStateQuerySelectorParams, DomainControllerInterface, DomainElement, DomainManyQueriesWithDeploymentUuid, @@ -320,7 +317,6 @@ export const ReportSectionListDisplay: React.FC = ( ] ); - // const foreignKeyObjectsFetchQueryParams: DeploymentEntityStateQuerySelectorParams = useMemo( const foreignKeyObjectsFetchQueryParams: QuerySelectorParams< DomainManyQueriesWithDeploymentUuid, DeploymentEntityState diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionView.tsx b/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionView.tsx index 4b984ddb..3030412f 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionView.tsx +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/ReportSectionView.tsx @@ -3,14 +3,14 @@ import { useMemo } from 'react'; import { ApplicationDeploymentConfiguration, ApplicationSection, - DeploymentEntityStateQuerySelectorMap, + DeploymentEntityState, DomainElementObject, - DomainStateQuerySelectorMap, Entity, EntityDefinition, LoggerInterface, MiroirLoggerFactory, MiroirSelectorQueryParams, + QuerySelectorMap, RecordOfJzodObject, ReportSection, RootReportSection, @@ -42,7 +42,7 @@ export interface ReportSectionEntityInstanceProps { paramsAsdomainElements: DomainElementObject, reportSection: ReportSection, rootReportSection: RootReportSection, - selectorMap: DeploymentEntityStateQuerySelectorMap + selectorMap: QuerySelectorMap } // ############################################################################################################### diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/RootReportSectionView.tsx b/packages/miroir-standalone-app/src/miroir-fwk/4_view/RootReportSectionView.tsx index e422e45d..481582ff 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/RootReportSectionView.tsx +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/RootReportSectionView.tsx @@ -3,8 +3,7 @@ import { Params } from 'react-router-dom'; import { ApplicationSection, - DeploymentEntityStateQuerySelectorMap, - DeploymentEntityStateQuerySelectorParams, + DeploymentEntityState, DomainElementObject, DomainManyQueriesWithDeploymentUuid, DomainModelGetFetchParamJzodSchemaQueryParams, @@ -13,12 +12,13 @@ import { LoggerInterface, MiroirLoggerFactory, MiroirSelectorQueryParams, + QuerySelectorMap, + QuerySelectorParams, RecordOfJzodObject, RootReportSection, Uuid, getDeploymentEntityStateSelectorParams, - getLoggerName, - selectFetchQueryJzodSchemaFromDomainStateNew + getLoggerName } from "miroir-core"; @@ -77,12 +77,12 @@ export const RootReportSectionView = (props: RootReportSectionEntityInstanceProp // props.reportSection.fetchQuery // ); - const deploymentEntityStateSelectorMap: DeploymentEntityStateQuerySelectorMap = useMemo( + const deploymentEntityStateSelectorMap: QuerySelectorMap = useMemo( () => getMemoizedDeploymentEntityStateSelectorMap(), [] ) - const deploymentEntityStateFetchQueryParams: DeploymentEntityStateQuerySelectorParams = useMemo( + const deploymentEntityStateFetchQueryParams: QuerySelectorParams = useMemo( () => props.pageParams.deploymentUuid && props.pageParams.applicationSection && props.pageParams.reportUuid ? getDeploymentEntityStateSelectorParams( diff --git a/packages/miroir-standalone-app/src/miroir-fwk/4_view/Sidebar.tsx b/packages/miroir-standalone-app/src/miroir-fwk/4_view/Sidebar.tsx index 6ec384e9..5b952e30 100644 --- a/packages/miroir-standalone-app/src/miroir-fwk/4_view/Sidebar.tsx +++ b/packages/miroir-standalone-app/src/miroir-fwk/4_view/Sidebar.tsx @@ -16,8 +16,7 @@ import { AutoStories } from '@mui/icons-material'; import { Icon } from '@mui/material'; import { applicationDeploymentMiroir, - DeploymentEntityStateQuerySelectorMap, - DeploymentEntityStateQuerySelectorParams, + DeploymentEntityState, DomainElementObject, DomainManyQueriesWithDeploymentUuid, getDeploymentEntityStateSelectorParams, @@ -25,7 +24,9 @@ import { LoggerInterface, menuDefaultMiroir, MiroirLoggerFactory, - MiroirSelectorQueryParams + MiroirSelectorQueryParams, + QuerySelectorMap, + QuerySelectorParams } from "miroir-core"; import { getMemoizedDeploymentEntityStateSelectorMap } from 'miroir-localcache-redux'; import { useMemo } from 'react'; @@ -162,12 +163,12 @@ export const Sidebar = (props: {open:boolean, setOpen: (v:boolean)=>void}) => { // const miroirConfig = context.getMiroirConfig(); // const context = useMiroirContext(); - const deploymentEntityStateSelectorMap: DeploymentEntityStateQuerySelectorMap = useMemo( + const deploymentEntityStateSelectorMap: QuerySelectorMap = useMemo( () => getMemoizedDeploymentEntityStateSelectorMap(), [] ) - const deploymentEntityStateFetchQueryParams: DeploymentEntityStateQuerySelectorParams = useMemo( + const deploymentEntityStateFetchQueryParams: QuerySelectorParams = useMemo( () => getDeploymentEntityStateSelectorParams({ queryType: "DomainManyQueries",