import type { CommandViewData } from '../../platform/registry/command-view'
import type { OrganizationModel } from '../types'
import type { RelationshipType } from '../../platform/registry/command-view'
import type { OrganizationModelIconToken } from '../icons'

export type OrganizationGraphNodeKind =
  | 'organization'
  | 'system'
  | 'client'
  | 'role'
  | 'action'
  | 'entity'
  | 'event'
  | 'policy'
  | 'stage'
  | 'resource'
  | 'knowledge'
  | 'customer-segment'
  | 'offering'
  | 'goal'
  | 'surface'
  | 'navigation-group'
  | 'ontology'

export type OrganizationGraphEdgeKind =
  | 'contains'
  | 'references'
  | 'maps_to'
  | 'uses'
  | 'governs'
  | 'links'
  | 'affects'
  | 'emits'
  | 'originates_from'
  | 'triggers'
  | 'approval'
  | 'applies_to'
  | 'effects'
  | 'actions'
  | 'reads'
  | 'writes'
  | 'uses_catalog'
export type { Link } from './link'

export interface OrganizationGraphNode {
  id: string
  kind: OrganizationGraphNodeKind
  label: string
  sourceId?: string
  description?: string
  icon?: OrganizationModelIconToken
  enabled?: boolean
  ontologyKind?: string
  resourceType?: 'workflow' | 'agent' | 'trigger' | 'integration' | 'external' | 'human_checkpoint' | 'script'
}

export interface OrganizationGraphEdge {
  id: string
  kind: OrganizationGraphEdgeKind
  sourceId: string
  targetId: string
  label?: string
  relationshipType?: RelationshipType
}

export interface OrganizationGraph {
  version: 1
  organizationModelVersion: OrganizationModel['version']
  nodes: OrganizationGraphNode[]
  edges: OrganizationGraphEdge[]
}

export interface BuildOrganizationGraphInput {
  organizationModel: OrganizationModel
  commandViewData?: CommandViewData
}
