From 3d6e0503c31d4b24c2fdb6b5edba79dfc41c13fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Tue, 1 Aug 2023 12:57:25 +0200 Subject: [PATCH] feat: return all node data from query --- .../Reveal3DResources/queryMappedData.ts | 11 ++++----- .../src/components/Reveal3DResources/types.ts | 4 ++-- react-components/src/utilities/FdmSDK.ts | 23 +++++++++++-------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/react-components/src/components/Reveal3DResources/queryMappedData.ts b/react-components/src/components/Reveal3DResources/queryMappedData.ts index 8d5b23d73bf..d49be855ee5 100644 --- a/react-components/src/components/Reveal3DResources/queryMappedData.ts +++ b/react-components/src/components/Reveal3DResources/queryMappedData.ts @@ -9,7 +9,8 @@ import { type InspectResultList, type FdmSDK, type DmsUniqueIdentifier, - type Source + type Source, + FdmNode } from '../../utilities/FdmSDK'; import { type FdmAssetMappingsConfig } from '../../hooks/types'; import { type FdmPropertyType, type NodeDataResult } from './types'; @@ -69,7 +70,7 @@ export async function queryMappedData( } return { - data: nodeData as FdmPropertyType, + data: nodeData, view: dataView, cadNode: selectedNode, model: cadIntersection.model @@ -157,7 +158,7 @@ async function filterNodeData( fdmClient: FdmSDK, dataNode: DmsUniqueIdentifier, dataView: Source -): Promise { +): Promise | undefined> { if (dataView === undefined) { return undefined; } @@ -167,7 +168,5 @@ async function filterNodeData( dataView ); - return dataQueryResult.items[0]?.properties[dataView.space]?.[ - `${dataView.externalId}/${dataView.version}` - ]; + return dataQueryResult.items[0]; } diff --git a/react-components/src/components/Reveal3DResources/types.ts b/react-components/src/components/Reveal3DResources/types.ts index 2445488069f..dc0d0add83c 100644 --- a/react-components/src/components/Reveal3DResources/types.ts +++ b/react-components/src/components/Reveal3DResources/types.ts @@ -8,7 +8,7 @@ import { type SupportedModelTypes } from '@cognite/reveal'; import { type Matrix4 } from 'three'; -import { type Source } from '../../utilities/FdmSDK'; +import { FdmNode, type Source } from '../../utilities/FdmSDK'; import { type Node3D } from '@cognite/sdk/dist/src'; export type AddImageCollection360Options = { @@ -23,7 +23,7 @@ export type AddReveal3DModelOptions = AddModelOptions & { transform?: Matrix4 }; export type TypedReveal3DModel = AddReveal3DModelOptions & { type: SupportedModelTypes | '' }; export type NodeDataResult = { - data: FdmPropertyType; + data: FdmNode; view: Source; cadNode: Node3D; model: CogniteCadModel; diff --git a/react-components/src/utilities/FdmSDK.ts b/react-components/src/utilities/FdmSDK.ts index ea92e8b4fe4..4d4ff899c74 100644 --- a/react-components/src/utilities/FdmSDK.ts +++ b/react-components/src/utilities/FdmSDK.ts @@ -3,6 +3,7 @@ */ import { type CogniteClient } from '@cognite/sdk'; +import { FdmPropertyType } from '../components/Reveal3DResources/types'; type InstanceType = 'node' | 'edge'; @@ -51,17 +52,19 @@ export type InspectResultList = { }>; }; +export type FdmNode = { + instanceType: InstanceType; + version: number; + space: string; + externalId: string; + createdTime: number; + lastUpdatedTime: number; + deletedTime: number; + properties: FdmPropertyType; +}; + export type ExternalIdsResultList = { - items: Array<{ - instanceType: InstanceType; - version: number; - space: string; - externalId: string; - createdTime: number; - lastUpdatedTime: number; - deletedTime: number; - properties: Record>; - }>; + items: Array>; typing?: Record< string, Record<