Skip to content

Commit

Permalink
feat: return all node data from query
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed Aug 1, 2023
1 parent 13c845a commit 3d6e050
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -69,7 +70,7 @@ export async function queryMappedData<NodeType>(
}

return {
data: nodeData as FdmPropertyType<NodeType>,
data: nodeData,
view: dataView,
cadNode: selectedNode,
model: cadIntersection.model
Expand Down Expand Up @@ -157,7 +158,7 @@ async function filterNodeData<NodeType>(
fdmClient: FdmSDK,
dataNode: DmsUniqueIdentifier,
dataView: Source
): Promise<NodeType | undefined> {
): Promise<FdmNode<NodeType> | undefined> {
if (dataView === undefined) {
return undefined;
}
Expand All @@ -167,7 +168,5 @@ async function filterNodeData<NodeType>(
dataView
);

return dataQueryResult.items[0]?.properties[dataView.space]?.[
`${dataView.externalId}/${dataView.version}`
];
return dataQueryResult.items[0];
}
4 changes: 2 additions & 2 deletions react-components/src/components/Reveal3DResources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -23,7 +23,7 @@ export type AddReveal3DModelOptions = AddModelOptions & { transform?: Matrix4 };
export type TypedReveal3DModel = AddReveal3DModelOptions & { type: SupportedModelTypes | '' };

export type NodeDataResult<NodeType> = {
data: FdmPropertyType<NodeType>;
data: FdmNode<NodeType>;
view: Source;
cadNode: Node3D;
model: CogniteCadModel;
Expand Down
23 changes: 13 additions & 10 deletions react-components/src/utilities/FdmSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import { type CogniteClient } from '@cognite/sdk';
import { FdmPropertyType } from '../components/Reveal3DResources/types';

type InstanceType = 'node' | 'edge';

Expand Down Expand Up @@ -51,17 +52,19 @@ export type InspectResultList = {
}>;
};

export type FdmNode<PropertyType> = {
instanceType: InstanceType;
version: number;
space: string;
externalId: string;
createdTime: number;
lastUpdatedTime: number;
deletedTime: number;
properties: FdmPropertyType<PropertyType>;
};

export type ExternalIdsResultList<PropertyType> = {
items: Array<{
instanceType: InstanceType;
version: number;
space: string;
externalId: string;
createdTime: number;
lastUpdatedTime: number;
deletedTime: number;
properties: Record<string, Record<string, PropertyType>>;
}>;
items: Array<FdmNode<PropertyType>>;
typing?: Record<
string,
Record<
Expand Down

0 comments on commit 3d6e050

Please sign in to comment.