From edd14200e4fb90f55b4c48edd0b931b3109bcd3d Mon Sep 17 00:00:00 2001 From: Savelii Novikov Date: Wed, 12 Jul 2023 16:55:17 +0200 Subject: [PATCH] Added types for hooks --- .../Reveal3DResources/Reveal3DResources.tsx | 3 ++- react-components/src/hooks/types.ts | 18 ++++++++++++++++++ .../src/hooks/useFdmAssetMappings.tsx | 19 +------------------ react-components/src/index.ts | 3 ++- 4 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 react-components/src/hooks/types.ts diff --git a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx index 63eaaf0e25f..86124e11a5a 100644 --- a/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx +++ b/react-components/src/components/Reveal3DResources/Reveal3DResources.tsx @@ -26,7 +26,8 @@ import { type AddResourceOptions } from './types'; import { type CogniteExternalId } from '@cognite/sdk'; -import { type FdmAssetMappingsConfig, useFdmAssetMappings } from '../../hooks/useFdmAssetMappings'; +import { useFdmAssetMappings } from '../../hooks/useFdmAssetMappings'; +import { type FdmAssetMappingsConfig } from '../../hooks/types'; export type FdmAssetStylingGroup = { fdmAssetExternalIds: CogniteExternalId[]; diff --git a/react-components/src/hooks/types.ts b/react-components/src/hooks/types.ts new file mode 100644 index 00000000000..a416fc55eb5 --- /dev/null +++ b/react-components/src/hooks/types.ts @@ -0,0 +1,18 @@ +import { type Source } from '../utilities/FdmSDK'; + +export type FdmAssetMappingsConfig = { + /** + * 3D Data model source + */ + source: Source; + /* + * FDM space where model assets are located + */ + assetFdmSpace: string; + }; + + export type ThreeDModelMappings = { + modelId: number; + revisionId: number; + mappings: Array<{ nodeId: number; externalId: string }>; + }; \ No newline at end of file diff --git a/react-components/src/hooks/useFdmAssetMappings.tsx b/react-components/src/hooks/useFdmAssetMappings.tsx index b30df667192..c3d6dd3c53c 100644 --- a/react-components/src/hooks/useFdmAssetMappings.tsx +++ b/react-components/src/hooks/useFdmAssetMappings.tsx @@ -3,25 +3,8 @@ */ import { type CogniteExternalId } from '@cognite/sdk'; import { useFdmSdk } from '../components/RevealContainer/SDKProvider'; -import { type Source } from '../utilities/FdmSDK'; import { type UseQueryResult, useQuery } from '@tanstack/react-query'; - -export type FdmAssetMappingsConfig = { - /** - * 3D Data model source - */ - source: Source; - /* - * FDM space where model assets are located - */ - assetFdmSpace: string; -}; - -export type ThreeDModelMappings = { - modelId: number; - revisionId: number; - mappings: Array<{ nodeId: number; externalId: string }>; -}; +import { type FdmAssetMappingsConfig, type ThreeDModelMappings } from './types'; const DefaultFdmConfig: FdmAssetMappingsConfig = { source: { diff --git a/react-components/src/index.ts b/react-components/src/index.ts index 557d2895c62..855a901fa2a 100644 --- a/react-components/src/index.ts +++ b/react-components/src/index.ts @@ -29,4 +29,5 @@ export type { AddReveal3DModelOptions } from './components/Reveal3DResources/types'; export { RevealToolbar } from './components/RevealToolbar/RevealToolbar'; -export { useFdmAssetMappings, type FdmAssetMappingsConfig } from './hooks/useFdmAssetMappings'; +export { useFdmAssetMappings } from './hooks/useFdmAssetMappings'; +export { type FdmAssetMappingsConfig } from './hooks/types';