Skip to content

Commit

Permalink
chore: lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonflatval-cognite committed Aug 1, 2023
1 parent 9ec8db5 commit 13c845a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { type Cognite3DViewer, type PointerEventData, type CogniteCadModel } from '@cognite/reveal';
import { type CogniteInternalId, type CogniteClient, Node3D } from '@cognite/sdk';
import { type CogniteInternalId, type CogniteClient, type Node3D } from '@cognite/sdk';
import {
type EdgeItem,
type InspectResultList,
Expand All @@ -12,7 +12,8 @@ import {
type Source
} from '../../utilities/FdmSDK';
import { type FdmAssetMappingsConfig } from '../../hooks/types';
import { FdmPropertyType, type NodeDataResult } from './types';
import { type FdmPropertyType, type NodeDataResult } from './types';
import assert from 'assert';

export async function queryMappedData<NodeType>(
viewer: Cognite3DViewer,
Expand Down Expand Up @@ -52,6 +53,8 @@ export async function queryMappedData<NodeType>(
`${fdmConfig.source.externalId}/${fdmConfig.source.version}`
].revisionNodeId;
const selectedNode = ancestors.find((n) => n.id === selectedNodeId);
assert(selectedNode !== undefined);

const dataNode = selectedEdge.startNode;

const inspectionResult = await inspectNode(fdmClient, dataNode);
Expand All @@ -68,7 +71,7 @@ export async function queryMappedData<NodeType>(
return {
data: nodeData as FdmPropertyType<NodeType>,
view: dataView,
cadNode: selectedNode!,
cadNode: selectedNode,
model: cadIntersection.model
};
}
Expand Down
8 changes: 6 additions & 2 deletions react-components/src/components/Reveal3DResources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
* Copyright 2023 Cognite AS
*/

import { CogniteCadModel, type AddModelOptions, type SupportedModelTypes } from '@cognite/reveal';
import {
type CogniteCadModel,
type AddModelOptions,
type SupportedModelTypes
} from '@cognite/reveal';
import { type Matrix4 } from 'three';
import { type Source } from '../../utilities/FdmSDK';
import { Node3D } from '@cognite/sdk/dist/src';
import { type Node3D } from '@cognite/sdk/dist/src';

export type AddImageCollection360Options = {
siteId: string;
Expand Down
2 changes: 1 addition & 1 deletion react-components/src/utilities/FdmSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class FdmSDK {
}

public async getByExternalIds<PropertyType>(
queries: { instanceType: InstanceType; externalId: string; space: string }[],
queries: Array<{ instanceType: InstanceType; externalId: string; space: string }>,
source?: Source
): Promise<ExternalIdsResultList<PropertyType>> {
const data: any = { items: queries, includeTyping: true };
Expand Down
24 changes: 6 additions & 18 deletions react-components/stories/HighlightNode.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,16 @@

import type { Meta, StoryObj } from '@storybook/react';
import {
CadModelContainer,
type FdmAssetMappingsConfig,
RevealContainer,
RevealToolbar,
useReveal,
Reveal3DResources,
NodeDataResult,
Reveal3DResourcesProps,
AddResourceOptions
type NodeDataResult,
type AddResourceOptions
} from '../src';
import { CogniteClient } from '@cognite/sdk';
import { Color, Matrix4 } from 'three';
import { type ReactElement, useEffect, useState } from 'react';
import {
CogniteCadModel,
DefaultNodeAppearance,
NodeIdNodeCollection,
TreeIndexNodeCollection,
type PointerEventData
} from '@cognite/reveal';
import { queryMappedData } from '../src/components/Reveal3DResources/queryMappedData';
import { useFdmSdk, useSDK } from '../src/components/RevealContainer/SDKProvider';
import { type ReactElement, useState } from 'react';
import { DefaultNodeAppearance, TreeIndexNodeCollection } from '@cognite/reveal';
import { createSdkByUrlToken } from './utilities/createSdkByUrlToken';

const DefaultFdmConfig: FdmAssetMappingsConfig = {
Expand Down Expand Up @@ -77,10 +65,10 @@ const StoryContent = ({
}: {
resources: AddResourceOptions[];
fdmAssetMappingConfig: FdmAssetMappingsConfig;
}) => {
}): ReactElement => {
const [nodeData, setNodeData] = useState<any>();

const callback = (nodeData: NodeDataResult<any>) => {
const callback = (nodeData: NodeDataResult<any>): void => {
setNodeData(nodeData.data);

nodeData.model.assignStyledNodeCollection(
Expand Down

0 comments on commit 13c845a

Please sign in to comment.