diff --git a/react-components/src/components/RuleBasedOutputs/types.ts b/react-components/src/components/RuleBasedOutputs/types.ts index 4bdd4311c03..d73d64ad922 100644 --- a/react-components/src/components/RuleBasedOutputs/types.ts +++ b/react-components/src/components/RuleBasedOutputs/types.ts @@ -4,12 +4,20 @@ import { type TreeIndexNodeCollection, type NumericRange } from '@cognite/reveal'; import { type FdmNode, type EdgeItem, type DmsUniqueIdentifier } from '../../data-providers/FdmSDK'; -import { type AssetStylingGroup, type FdmPropertyType } from '../Reveal3DResources/types'; +import { + type FdmAssetStylingGroup, + type AssetStylingGroup, + type FdmPropertyType +} from '../Reveal3DResources/types'; import { type Datapoints, type Asset, type Timeseries } from '@cognite/sdk'; +import { + type FdmTyping, + type FdmInstanceNodeWithConnectionAndProperties +} from '../../data-providers/types'; // =========== RULE BASED OUTPUT DATA MODEL -export type TriggerType = 'timeseries' | 'metadata'; +export type TriggerType = 'timeseries' | 'metadata' | 'fdm'; export type TimeseriesRuleTrigger = { type: 'timeseries'; @@ -21,13 +29,50 @@ export type MetadataRuleTrigger = { key: string; }; +export type FdmRuleTrigger = { + type: 'fdm'; + key: FdmInstanceNodeDataKey; +}; + +export type FdmInstanceNodeDataKey = { + space: string; + externalId: string; + view: Source; + typing: FdmTyping; + property: string; +}; + export type StringTrigger = MetadataRuleTrigger; +export type BooleanCondition = { + type: 'true' | 'false'; + parameter: boolean; +}; + export type StringCondition = { type: 'equals' | 'notEquals' | 'contains' | 'startsWith' | 'endsWith'; parameter: string; }; +export type DatetimeCondition = + | { + type: + | 'before' + | 'notBefore' + | 'onOrBefore' + | 'after' + | 'notAfter' + | 'onOrAfter' + | 'on' + | 'notOn'; + parameter: string; + } + | { + type: 'between' | 'notBetween'; + lowerBound: number; + upperBound: number; + }; + export type NumericCondition = | { type: @@ -52,16 +97,28 @@ export type NumericCondition = export type StringExpression = { type: 'stringExpression'; - trigger: StringTrigger; + trigger: StringTrigger | FdmRuleTrigger; condition: StringCondition; }; export type NumericExpression = { type: 'numericExpression'; - trigger: MetadataRuleTrigger | TimeseriesRuleTrigger; + trigger: MetadataRuleTrigger | TimeseriesRuleTrigger | FdmRuleTrigger; condition: NumericCondition; }; +export type DatetimeExpression = { + type: 'datetimeExpression'; + trigger: FdmRuleTrigger; + condition: DatetimeCondition; +}; + +export type BooleanExpression = { + type: 'booleanExpression'; + trigger: FdmRuleTrigger; + condition: BooleanCondition; +}; + export type ExpressionOperator = | { type: 'or'; @@ -76,7 +133,11 @@ export type ExpressionOperator = expression: Expression; }; -export type ConcreteExpression = StringExpression | NumericExpression; +export type ConcreteExpression = + | StringExpression + | NumericExpression + | DatetimeExpression + | BooleanExpression; export type Expression = ConcreteExpression | ExpressionOperator; @@ -156,6 +217,8 @@ export type FdmRuleOutputSet = { export type ExpressionOperatorsTypes = 'and' | 'or' | 'not'; +export type BooleanConditionTypes = 'true' | 'false'; + export type StringConditionTypes = 'equals' | 'notEquals' | 'contains' | 'startsWith' | 'endsWith'; export type NumericConditionTypes = @@ -180,11 +243,38 @@ export type NumericOutsideConditionType = { upperBoundExclusive: number; }; +export type DatetimeConditionTypes = + | 'before' + | 'notBefore' + | 'onOrBefore' + | 'between' + | 'notBetween' + | 'after' + | 'notAfter' + | 'onOrAfter' + | 'on' + | 'notOn'; + +export type DatetimeBetweenConditionType = { + type: 'between'; + lowerBoundInclusive: number; + upperBoundInclusive: number; +}; + +export type DatetimeNotBetweenConditionType = { + type: 'notBetween'; + lowerBoundExclusive: number; + upperBoundExclusive: number; +}; + export type CriteriaTypes = + | BooleanConditionTypes | string | number | NumericWithinConditionType - | NumericOutsideConditionType; + | NumericOutsideConditionType + | DatetimeBetweenConditionType + | DatetimeNotBetweenConditionType; export type RuleAndStyleIndex = { styleIndex: TreeIndexNodeCollection; @@ -196,6 +286,21 @@ export type AssetStylingGroupAndStyleIndex = { assetStylingGroup: AssetStylingGroup; }; +export type FdmStylingGroupAndStyleIndex = { + styleIndex: TreeIndexNodeCollection; + fdmStylingGroup: FdmAssetStylingGroup; +}; + +export type AllRuleBasedStylingGroups = { + assetStylingGroup: AssetStylingGroup[]; + fdmStylingGroup: FdmAssetStylingGroup[]; +}; + +export type AllMappingStylingGroupAndStyleIndex = { + assetMappingsStylingGroupAndIndex: AssetStylingGroupAndStyleIndex; + fdmStylingGroupAndStyleIndex: FdmStylingGroupAndStyleIndex; +}; + export type NodeAndRange = { treeIndex: number; nodeId: number; @@ -271,7 +376,7 @@ export type EmptyRuleForSelectionProps = { isNoSelection: boolean; }; -export type TriggerTypeData = TriggerMetadataType | TriggerTimeseriesType; +export type TriggerTypeData = TriggerMetadataType | TriggerTimeseriesType | TriggerFdmType; export type TriggerMetadataType = { type: 'metadata'; @@ -286,4 +391,9 @@ export type TriggerTimeseriesType = { }; }; +export type TriggerFdmType = { + type: 'fdm'; + instanceNode: FdmInstanceNodeWithConnectionAndProperties; +}; + export type TimeseriesAndDatapoints = Timeseries & Datapoints; diff --git a/react-components/src/data-providers/types.ts b/react-components/src/data-providers/types.ts index 7101cb245d4..e12c1095179 100644 --- a/react-components/src/data-providers/types.ts +++ b/react-components/src/data-providers/types.ts @@ -7,12 +7,56 @@ import { type ExternalId, type InternalId, type Metadata, - type Relationship + type Relationship, + type Node3D } from '@cognite/sdk/'; -import { type DmsUniqueIdentifier, type Source } from './FdmSDK'; +import { type NodeItem, type DmsUniqueIdentifier, type Source, type EdgeItem } from './FdmSDK'; +import { type FdmCadConnection } from '../components/CacheProvider/types'; +import { type FdmPropertyType } from '../components/Reveal3DResources/types'; export type FdmInstanceWithView = DmsUniqueIdentifier & { view: Source }; +export type FdmInstanceWithProperties = NodeItem | EdgeItem; + +export type FdmInstanceWithPropertiesAndTyping = { + items: FdmInstanceWithProperties[]; + typing: FdmTyping; +}; + +export type FdmTyping = Record< + string, + Record< + string, + Record< + string, + { + nullable?: boolean; + autoIncrement?: boolean; + defaultValue?: any; + description?: string; + name?: string; + immutable?: boolean; + type: { collation?: string; list?: boolean; type: string }; + } + > + > +>; + +export type FdmInstanceNodeWithConnectionAndProperties = { + instanceType: 'node'; + version: number; + space: string; + externalId: string; + createdTime: number; + lastUpdatedTime: number; + deletedTime: number; + properties: FdmPropertyType; + connection?: FdmCadConnection | undefined; + cadNode?: Node3D | undefined; + view?: Source | undefined; + typing: FdmTyping; +}; + export type AssetInstanceReference = { assetId: number }; export type InstanceReference = AssetInstanceReference | DmsUniqueIdentifier;