Skip to content

Commit

Permalink
feat: move some types to utils lib
Browse files Browse the repository at this point in the history
  • Loading branch information
BenElferink committed Feb 9, 2025
1 parent 5653a34 commit 6e9fbe7
Show file tree
Hide file tree
Showing 32 changed files with 124 additions and 226 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@odigos/ui-components": "^0.0.57",
"@odigos/ui-icons": "^0.0.10",
"@odigos/ui-theme": "^0.0.12",
"@odigos/ui-utils": "^0.0.14",
"@odigos/ui-utils": "^0.0.16",
"@xyflow/react": "^12.4.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand All @@ -36,7 +36,7 @@
"@odigos/ui-components": "^0.0.57",
"@odigos/ui-icons": "^0.0.10",
"@odigos/ui-theme": "^0.0.12",
"@odigos/ui-utils": "^0.0.15",
"@odigos/ui-utils": "^0.0.16",
"@xyflow/react": "^12.4.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
60 changes: 12 additions & 48 deletions src/@types/actions.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,17 @@
import { ACTION_TYPE, SIGNAL_TYPE, type Condition, type FetchedCondition } from '@odigos/ui-utils'

interface Spec {
actionName?: string
notes?: string
signals: SIGNAL_TYPE[]
disabled?: boolean

clusterAttributes?:
| {
attributeName: string
attributeStringValue: string
}[]
| null
renames?: {
[oldKey: string]: string
} | null
attributeNamesToDelete?: string[] | null
piiCategories?: string[] | null
fallbackSamplingRatio?: number | null
samplingPercentage?: string | null
endpointsFilters?:
| {
serviceName: string
httpRoute: string
minimumLatencyThreshold: number
fallbackSamplingRatio: number
}[]
| null
}

export interface Action {
id: string
type: ACTION_TYPE
conditions: FetchedCondition[] | Condition[] | null
spec: Spec
}
import type { Action } from '@odigos/ui-utils'

export interface ActionFormData {
type: Action['type']
name: Spec['actionName']
notes: Spec['notes']
signals: Spec['signals']
disabled: Spec['disabled']
name: Action['spec']['actionName']
notes: Action['spec']['notes']
signals: Action['spec']['signals']
disabled: Action['spec']['disabled']

clusterAttributes: Spec['clusterAttributes']
renames: Spec['renames']
attributeNamesToDelete: Spec['attributeNamesToDelete']
piiCategories: Spec['piiCategories']
fallbackSamplingRatio: Spec['fallbackSamplingRatio']
samplingPercentage: Spec['samplingPercentage']
endpointsFilters: Spec['endpointsFilters']
clusterAttributes: Action['spec']['clusterAttributes']
attributeNamesToDelete: Action['spec']['attributeNamesToDelete']
renames: Action['spec']['renames']
piiCategories: Action['spec']['piiCategories']
fallbackSamplingRatio: Action['spec']['fallbackSamplingRatio']
samplingPercentage: Action['spec']['samplingPercentage']
endpointsFilters: Action['spec']['endpointsFilters']
}
6 changes: 1 addition & 5 deletions src/@types/common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { type Source } from './sources'
import { type Action } from './actions'
import { type Destination } from './destinations'
import { NOTIFICATION_TYPE } from '@odigos/ui-utils'
import { type InstrumentationRule } from './instrumentation-rules'
import { type Action, type Destination, type InstrumentationRule, NOTIFICATION_TYPE, type Source } from '@odigos/ui-utils'

export interface Notification {
id: string
Expand Down
32 changes: 1 addition & 31 deletions src/@types/destinations.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
import { type Condition, type FetchedCondition } from '@odigos/ui-utils'

interface SupportedSignals {
logs: {
supported: boolean
}
metrics: {
supported: boolean
}
traces: {
supported: boolean
}
}

export interface Destination {
id: string
name: string
exportedSignals: {
traces: boolean
metrics: boolean
logs: boolean
}
fields: string
conditions: FetchedCondition[] | Condition[] | null
destinationType: {
type: string
displayName: string
imageUrl: string
supportedSignals: SupportedSignals
}
}
export interface DestinationFormData {}
66 changes: 1 addition & 65 deletions src/@types/instrumentation-rules.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,3 @@
import { INSTRUMENTATION_RULE_TYPE, type WorkloadId } from '@odigos/ui-utils'

interface InstrumentationLibraryGlobalId {
language: string
library: string
}
export interface InstrumentationRule {
ruleId: string
ruleName: string
type: INSTRUMENTATION_RULE_TYPE // does not come from backend, it's derived during GET
notes: string
disabled: boolean
mutable: boolean
profileName: string
workloads?: WorkloadId[] | null
instrumentationLibraries?: InstrumentationLibraryGlobalId[] | null
payloadCollection?: PayloadCollection | null
codeAttributes?: CodeAttributes | null
}

// Payload Collection for Instrumentation Rules
interface HttpPayloadCollection {
mimeTypes?: string[] | null
maxPayloadLength?: number | null
dropPartialPayloads?: boolean | null
}
interface DbQueryPayloadCollection {
maxPayloadLength?: number | null
dropPartialPayloads?: boolean | null
}
interface MessagingPayloadCollection {
maxPayloadLength?: number | null
dropPartialPayloads?: boolean | null
}

export enum PAYLOAD_COLLECTION_KEY_TYPES {
HTTP_REQUEST = 'httpRequest',
HTTP_RESPONSE = 'httpResponse',
DB_QUERY = 'dbQuery',
MESSAGING = 'messaging',
}
export interface PayloadCollection {
[PAYLOAD_COLLECTION_KEY_TYPES.HTTP_REQUEST]?: HttpPayloadCollection | null
[PAYLOAD_COLLECTION_KEY_TYPES.HTTP_RESPONSE]?: HttpPayloadCollection | null
[PAYLOAD_COLLECTION_KEY_TYPES.DB_QUERY]?: DbQueryPayloadCollection | null
[PAYLOAD_COLLECTION_KEY_TYPES.MESSAGING]?: MessagingPayloadCollection | null
}

// Code Attributes for Instrumentation Rules
export enum CODE_ATTRIBUTES_KEY_TYPES {
COLUMN = 'column',
FILE_PATH = 'filePath',
FUNCTION = 'function',
LINE_NUMBER = 'lineNumber',
NAMESPACE = 'namespace',
STACKTRACE = 'stacktrace',
}
export interface CodeAttributes {
[CODE_ATTRIBUTES_KEY_TYPES.COLUMN]?: boolean | null
[CODE_ATTRIBUTES_KEY_TYPES.FILE_PATH]?: boolean | null
[CODE_ATTRIBUTES_KEY_TYPES.FUNCTION]?: boolean | null
[CODE_ATTRIBUTES_KEY_TYPES.LINE_NUMBER]?: boolean | null
[CODE_ATTRIBUTES_KEY_TYPES.NAMESPACE]?: boolean | null
[CODE_ATTRIBUTES_KEY_TYPES.STACKTRACE]?: boolean | null
}
import type { InstrumentationRule } from '@odigos/ui-utils'

export type InstrumentationRuleFormData = Omit<InstrumentationRule, 'ruleId' | 'type' | 'mutable' | 'profileName'>
19 changes: 1 addition & 18 deletions src/@types/sources.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
import { type Condition, type FetchedCondition, PROGRAMMING_LANGUAGES, type WorkloadId } from '@odigos/ui-utils'

interface Container {
containerName: string
language: PROGRAMMING_LANGUAGES
runtimeVersion: string
instrumented: boolean
instrumentationMessage: string
otelDistroName: string | null
}

export interface Source extends WorkloadId {
selected: boolean
otelServiceName: string
numberOfInstances?: number
containers: Container[] | null
conditions: FetchedCondition[] | Condition[] | null
}
export interface SourceFormData {}
5 changes: 2 additions & 3 deletions src/containers/action-drawer/build-card.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Action } from '../../@types'
import { DISPLAY_TITLES } from '@odigos/ui-utils'
import { DATA_CARD_FIELD_TYPES, DataCardFieldsProps } from '@odigos/ui-components'
import { type Action, DISPLAY_TITLES } from '@odigos/ui-utils'
import { DATA_CARD_FIELD_TYPES, type DataCardFieldsProps } from '@odigos/ui-components'

const buildCard = (action: Action) => {
const {
Expand Down
4 changes: 2 additions & 2 deletions src/containers/action-drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import styled from 'styled-components'
import { buildCard } from './build-card'
import { ActionForm } from '../action-form'
import { useDrawerStore } from '../../store'
import type { Action, ActionFormData } from '../../@types'
import type { ActionFormData } from '../../@types'
import { OverviewDrawer, useActionFormData } from '../../helpers'
import { ConditionDetails, DataCard } from '@odigos/ui-components'
import { ACTION_OPTIONS, ACTION_TYPE, CRUD, DISPLAY_TITLES, ENTITY_TYPES, getActionIcon } from '@odigos/ui-utils'
import { type Action, ACTION_OPTIONS, ACTION_TYPE, CRUD, DISPLAY_TITLES, ENTITY_TYPES, getActionIcon } from '@odigos/ui-utils'

interface ActionDrawerProps {
actions: Action[]
Expand Down
10 changes: 5 additions & 5 deletions src/containers/data-flow-actions-menu/add-entity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { PlusIcon } from '@odigos/ui-icons'
import { useModalStore } from '../../../store'
import styled, { css } from 'styled-components'
import { Button, type DropdownProps, Text } from '@odigos/ui-components'
import { ENTITY_TYPES, getEntityIcon, useOnClickOutside } from '@odigos/ui-utils'
import { DISPLAY_TITLES, ENTITY_TYPES, getEntityIcon, useOnClickOutside } from '@odigos/ui-utils'

interface Props {}

const DEFAULT_OPTIONS: DropdownProps['options'] = [
{ id: ENTITY_TYPES.INSTRUMENTATION_RULE, value: 'Instrumentation Rule' },
{ id: ENTITY_TYPES.SOURCE, value: 'Source' },
{ id: ENTITY_TYPES.ACTION, value: 'Action' },
{ id: ENTITY_TYPES.DESTINATION, value: 'Destination' },
{ id: ENTITY_TYPES.INSTRUMENTATION_RULE, value: DISPLAY_TITLES.INSTRUMENTATION_RULE },
{ id: ENTITY_TYPES.SOURCE, value: DISPLAY_TITLES.SOURCE },
{ id: ENTITY_TYPES.ACTION, value: DISPLAY_TITLES.ACTION },
{ id: ENTITY_TYPES.DESTINATION, value: DISPLAY_TITLES.DESTINATION },
]

const Container = styled.div`
Expand Down
13 changes: 11 additions & 2 deletions src/containers/data-flow-actions-menu/data-flow.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import React from 'react'
import { type StoryFn, type StoryObj } from '@storybook/react'
import { DataFlowActionsMenu, type DataFlowActionsMenuProps } from '.'
import { type Action, type Destination, type InstrumentationRule, type Source } from '../../@types'
import { ACTION_TYPE, CONDITION_STATUS, K8S_RESOURCE_KIND, PROGRAMMING_LANGUAGES, SIGNAL_TYPE } from '@odigos/ui-utils'
import {
type Action,
ACTION_TYPE,
CONDITION_STATUS,
type Destination,
type InstrumentationRule,
K8S_RESOURCE_KIND,
PROGRAMMING_LANGUAGES,
SIGNAL_TYPE,
type Source,
} from '@odigos/ui-utils'

export default {
title: 'Containers/DataFlowActionsMenu',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useMemo } from 'react'
import { type Source } from '../../../../../@types'
import { CONDITION_STATUS } from '@odigos/ui-utils'
import { CONDITION_STATUS, type Source } from '@odigos/ui-utils'
import { Dropdown, type DropdownProps } from '@odigos/ui-components'

interface Props {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react'
import { type Source } from '../../../../../@types'
import type { Source } from '@odigos/ui-utils'
import { Dropdown, type DropdownProps } from '@odigos/ui-components'

interface Props {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react'
import { type Source } from '../../../../../@types'
import type { Source } from '@odigos/ui-utils'
import { Dropdown, type DropdownProps } from '@odigos/ui-components'

interface Props {
Expand Down
3 changes: 1 addition & 2 deletions src/containers/data-flow-actions-menu/filters/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { useEffect, useRef, useState } from 'react'
import Theme from '@odigos/ui-theme'
import styled from 'styled-components'
import { type Source } from '../../../@types'
import { FilterIcon } from '@odigos/ui-icons'
import { SelectionButton } from '../selection-button'
import { Button, Toggle } from '@odigos/ui-components'
import { useKeyDown, useOnClickOutside } from '@odigos/ui-utils'
import { AbsoluteContainer, RelativeContainer } from '../styled'
import { useFilterStore, type FiltersState } from '../../../store'
import { type Source, useKeyDown, useOnClickOutside } from '@odigos/ui-utils'
import { ErrorDropdown, LanguageDropdown, MonitorDropdown, NamespaceDropdown, TypeDropdown } from './dropdowns'

interface Props {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ENTITY_TYPES } from '@odigos/ui-utils'
import type { Action, AllEntities, Destination, InstrumentationRule, Source } from '../../../../@types'
import type { AllEntities } from '../../../../@types'
import { type Action, type Destination, ENTITY_TYPES, type InstrumentationRule, type Source } from '@odigos/ui-utils'

export type Category = 'all' | ENTITY_TYPES

Expand Down
15 changes: 12 additions & 3 deletions src/containers/data-flow/data-flow.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import React from 'react'
import { DataFlow, type DataFlowProps } from '.'
import { type StoryFn, type StoryObj } from '@storybook/react'
import { type Action, type Destination, type InstrumentationRule, type Source } from '../../@types'
import { ACTION_TYPE, CONDITION_STATUS, K8S_RESOURCE_KIND, PROGRAMMING_LANGUAGES, SIGNAL_TYPE } from '@odigos/ui-utils'
import type { StoryFn, StoryObj } from '@storybook/react'
import {
type Action,
ACTION_TYPE,
CONDITION_STATUS,
type Destination,
type InstrumentationRule,
K8S_RESOURCE_KIND,
PROGRAMMING_LANGUAGES,
SIGNAL_TYPE,
type Source,
} from '@odigos/ui-utils'

export default {
title: 'Containers/DataFlow',
Expand Down
8 changes: 4 additions & 4 deletions src/containers/data-flow/helpers/build-action-nodes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type Node } from '@xyflow/react'
import nodeConfig from './node-config'
import { type NodePositions } from './get-node-positions'
import { type Action, NODE_TYPES, ADD_NODE_TYPES } from '../../../@types'
import { ENTITY_TYPES, getActionIcon, getEntityIcon, getEntityLabel, HEALTH_STATUS } from '@odigos/ui-utils'
import type { Node } from '@xyflow/react'
import type { NodePositions } from './get-node-positions'
import { NODE_TYPES, ADD_NODE_TYPES } from '../../../@types'
import { type Action, ENTITY_TYPES, getActionIcon, getEntityIcon, getEntityLabel, HEALTH_STATUS } from '@odigos/ui-utils'

interface Params {
loading: boolean
Expand Down
4 changes: 2 additions & 2 deletions src/containers/data-flow/helpers/build-destination-nodes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type Node } from '@xyflow/react'
import nodeConfig from './node-config'
import { type NodePositions } from './get-node-positions'
import { type Destination, NODE_TYPES, ADD_NODE_TYPES } from '../../../@types'
import { ENTITY_TYPES, getEntityIcon, getEntityLabel, getHealthStatus, HEALTH_STATUS, SIGNAL_TYPE } from '@odigos/ui-utils'
import { NODE_TYPES, ADD_NODE_TYPES } from '../../../@types'
import { type Destination, ENTITY_TYPES, getEntityIcon, getEntityLabel, getHealthStatus, HEALTH_STATUS, SIGNAL_TYPE } from '@odigos/ui-utils'

interface Params {
loading: boolean
Expand Down
4 changes: 2 additions & 2 deletions src/containers/data-flow/helpers/build-rule-nodes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type Node } from '@xyflow/react'
import nodeConfig from './node-config'
import { type NodePositions } from './get-node-positions'
import { type InstrumentationRule, NODE_TYPES, ADD_NODE_TYPES } from '../../../@types'
import { ENTITY_TYPES, getEntityIcon, getEntityLabel, getInstrumentationRuleIcon, HEALTH_STATUS } from '@odigos/ui-utils'
import { NODE_TYPES, ADD_NODE_TYPES } from '../../../@types'
import { ENTITY_TYPES, getEntityIcon, getEntityLabel, getInstrumentationRuleIcon, HEALTH_STATUS, type InstrumentationRule } from '@odigos/ui-utils'

interface Params {
loading: boolean
Expand Down
12 changes: 10 additions & 2 deletions src/containers/data-flow/helpers/build-source-nodes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { type Node } from '@xyflow/react'
import nodeConfig from './node-config'
import { type NodePositions } from './get-node-positions'
import { NODE_TYPES, ADD_NODE_TYPES } from '../../../@types'
import { getMainContainerLanguage } from './get-main-container-language'
import { NODE_TYPES, ADD_NODE_TYPES, type Source } from '../../../@types'
import { ENTITY_TYPES, getEntityIcon, getEntityLabel, getHealthStatus, getProgrammingLanguageIcon, HEALTH_STATUS } from '@odigos/ui-utils'
import {
ENTITY_TYPES,
getEntityIcon,
getEntityLabel,
getHealthStatus,
getProgrammingLanguageIcon,
HEALTH_STATUS,
type Source,
} from '@odigos/ui-utils'

interface Params {
loading: boolean
Expand Down
Loading

0 comments on commit 6e9fbe7

Please sign in to comment.