generated from coulomb/repo-seed
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
356 lines
15 KiB
Haskell
356 lines
15 KiB
Haskell
module Web.Routes where
|
|
|
|
import IHP.RouterPrelude
|
|
import Generated.Types
|
|
import Web.Types
|
|
|
|
-- Hubs
|
|
instance AutoRoute HubsController
|
|
|
|
-- Widgets
|
|
instance AutoRoute WidgetsController
|
|
|
|
-- Interaction Events (POST /widgets/:widgetId/events)
|
|
instance AutoRoute InteractionEventsController
|
|
|
|
-- Annotations (scoped to widget: /widgets/:widgetId/annotations/)
|
|
instance AutoRoute AnnotationsController
|
|
|
|
-- Annotation Threads (scoped to widget)
|
|
instance AutoRoute AnnotationThreadsController
|
|
|
|
-- Requirement Candidates
|
|
instance AutoRoute RequirementCandidatesController
|
|
|
|
-- Requirements (Phase 3)
|
|
instance AutoRoute RequirementsController
|
|
|
|
-- Decision Records (Phase 3)
|
|
instance AutoRoute DecisionRecordsController
|
|
|
|
-- Deployment Records (Phase 4)
|
|
instance AutoRoute DeploymentRecordsController
|
|
|
|
-- Agent Proposals (Phase 5)
|
|
instance AutoRoute AgentProposalsController
|
|
|
|
-- Phase 6 — Cross-Framework UI Adaptation
|
|
|
|
-- API endpoint: POST /api/v1/interaction-events
|
|
instance CanRoute ApiInteractionEventsController where
|
|
parseRoute' = do
|
|
_ <- string "/api"
|
|
_ <- string "/v1"
|
|
_ <- string "/interaction-events"
|
|
endOfInput
|
|
pure CreateApiInteractionEventAction
|
|
|
|
instance HasPath ApiInteractionEventsController where
|
|
pathTo CreateApiInteractionEventAction = "/api/v1/interaction-events"
|
|
|
|
instance AutoRoute EnvelopeEmissionContractsController
|
|
instance AutoRoute InteractionReportingContractsController
|
|
instance AutoRoute WidgetAdapterSpecsController
|
|
|
|
-- Phase 7 — Advanced Observability
|
|
instance AutoRoute CrossHubPropagationsController
|
|
|
|
-- Phase 8 — Federated Hub Maturity
|
|
instance AutoRoute WidgetOwnershipsController
|
|
instance AutoRoute HubRoutingRulesController
|
|
instance AutoRoute FederatedPolicyOverlaysController
|
|
instance AutoRoute StewardshipRolesController
|
|
instance AutoRoute ArchiveRecordsController
|
|
instance AutoRoute FederatedGovernanceController
|
|
|
|
-- GAAF Compliance Foundation (IHUB-WP-0009)
|
|
instance AutoRoute TypeRegistriesController
|
|
instance AutoRoute HubCapabilityManifestsController
|
|
|
|
-- Phase 9 — External API Surface (IHUB-WP-0010)
|
|
|
|
-- Admin: API consumers, keys, webhooks, dashboard
|
|
instance AutoRoute ApiConsumersController
|
|
instance AutoRoute ApiKeysController
|
|
instance AutoRoute WebhookSubscriptionsController
|
|
instance AutoRoute ApiDashboardController
|
|
|
|
-- /api/v2/ REST endpoints (manual routing for versioned prefix)
|
|
|
|
instance CanRoute ApiV2WidgetsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/widgets"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexWidgetsAction
|
|
, do _ <- string "/"; wId <- parseUUID; endOfInput
|
|
pure ApiV2ShowWidgetAction { widgetId = Id wId }
|
|
]
|
|
|
|
instance HasPath ApiV2WidgetsController where
|
|
pathTo ApiV2IndexWidgetsAction = "/api/v2/widgets"
|
|
pathTo ApiV2ShowWidgetAction { widgetId } = "/api/v2/widgets/" <> tshow widgetId
|
|
pathTo ApiV2CreateWidgetAction = "/api/v2/widgets"
|
|
|
|
instance CanRoute ApiV2InteractionEventsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/interaction-events"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexInteractionEventsAction
|
|
, do _ <- string "/"; eId <- parseUUID; endOfInput
|
|
pure ApiV2ShowInteractionEventAction { interactionEventId = Id eId }
|
|
]
|
|
|
|
instance HasPath ApiV2InteractionEventsController where
|
|
pathTo ApiV2IndexInteractionEventsAction = "/api/v2/interaction-events"
|
|
pathTo ApiV2ShowInteractionEventAction { interactionEventId } = "/api/v2/interaction-events/" <> tshow interactionEventId
|
|
pathTo ApiV2CreateInteractionEventAction = "/api/v2/interaction-events"
|
|
|
|
instance CanRoute ApiV2AnnotationsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/annotations"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexAnnotationsAction
|
|
, do _ <- string "/"; aId <- parseUUID; endOfInput
|
|
pure ApiV2ShowAnnotationAction { annotationId = Id aId }
|
|
]
|
|
|
|
instance HasPath ApiV2AnnotationsController where
|
|
pathTo ApiV2IndexAnnotationsAction = "/api/v2/annotations"
|
|
pathTo ApiV2ShowAnnotationAction { annotationId } = "/api/v2/annotations/" <> tshow annotationId
|
|
pathTo ApiV2CreateAnnotationAction = "/api/v2/annotations"
|
|
|
|
instance CanRoute ApiV2RequirementCandidatesController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/requirement-candidates"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexRequirementCandidatesAction
|
|
, do _ <- string "/"; rcId <- parseUUID; endOfInput
|
|
pure ApiV2ShowRequirementCandidateAction { requirementCandidateId = Id rcId }
|
|
]
|
|
|
|
instance HasPath ApiV2RequirementCandidatesController where
|
|
pathTo ApiV2IndexRequirementCandidatesAction = "/api/v2/requirement-candidates"
|
|
pathTo ApiV2ShowRequirementCandidateAction { requirementCandidateId } = "/api/v2/requirement-candidates/" <> tshow requirementCandidateId
|
|
|
|
instance CanRoute ApiV2DecisionRecordsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/decision-records"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexDecisionRecordsAction
|
|
, do _ <- string "/"; drId <- parseUUID; endOfInput
|
|
pure ApiV2ShowDecisionRecordAction { decisionRecordId = Id drId }
|
|
]
|
|
|
|
instance HasPath ApiV2DecisionRecordsController where
|
|
pathTo ApiV2IndexDecisionRecordsAction = "/api/v2/decision-records"
|
|
pathTo ApiV2ShowDecisionRecordAction { decisionRecordId } = "/api/v2/decision-records/" <> tshow decisionRecordId
|
|
|
|
instance CanRoute ApiV2DeploymentRecordsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/deployment-records"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexDeploymentRecordsAction
|
|
, do _ <- string "/"; drId <- parseUUID; endOfInput
|
|
pure ApiV2ShowDeploymentRecordAction { deploymentRecordId = Id drId }
|
|
]
|
|
|
|
instance HasPath ApiV2DeploymentRecordsController where
|
|
pathTo ApiV2IndexDeploymentRecordsAction = "/api/v2/deployment-records"
|
|
pathTo ApiV2ShowDeploymentRecordAction { deploymentRecordId } = "/api/v2/deployment-records/" <> tshow deploymentRecordId
|
|
|
|
instance CanRoute ApiV2OutcomeSignalsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/outcome-signals"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexOutcomeSignalsAction
|
|
, do _ <- string "/"; osId <- parseUUID; endOfInput
|
|
pure ApiV2ShowOutcomeSignalAction { outcomeSignalId = Id osId }
|
|
]
|
|
|
|
instance HasPath ApiV2OutcomeSignalsController where
|
|
pathTo ApiV2IndexOutcomeSignalsAction = "/api/v2/outcome-signals"
|
|
pathTo ApiV2ShowOutcomeSignalAction { outcomeSignalId } = "/api/v2/outcome-signals/" <> tshow outcomeSignalId
|
|
|
|
instance CanRoute ApiV2RegistriesController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/"
|
|
choice
|
|
[ do _ <- string "widget-types"; endOfInput; pure ApiV2ListWidgetTypesAction
|
|
, do _ <- string "event-types"; endOfInput; pure ApiV2ListEventTypesAction
|
|
, do _ <- string "annotation-categories"; endOfInput; pure ApiV2ListAnnotationCategoriesAction
|
|
, do _ <- string "policy-scopes"; endOfInput; pure ApiV2ListPolicyScopesAction
|
|
]
|
|
|
|
instance HasPath ApiV2RegistriesController where
|
|
pathTo ApiV2ListWidgetTypesAction = "/api/v2/widget-types"
|
|
pathTo ApiV2ListEventTypesAction = "/api/v2/event-types"
|
|
pathTo ApiV2ListAnnotationCategoriesAction = "/api/v2/annotation-categories"
|
|
pathTo ApiV2ListPolicyScopesAction = "/api/v2/policy-scopes"
|
|
|
|
instance CanRoute ApiV2OpenApiController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/"
|
|
choice
|
|
[ do _ <- string "openapi.json"; endOfInput; pure ApiV2OpenApiJsonAction
|
|
, do _ <- string "openapi.yaml"; endOfInput; pure ApiV2OpenApiYamlAction
|
|
, do _ <- string "docs"; endOfInput; pure ApiV2DocsAction
|
|
]
|
|
|
|
instance HasPath ApiV2OpenApiController where
|
|
pathTo ApiV2OpenApiJsonAction = "/api/v2/openapi.json"
|
|
pathTo ApiV2OpenApiYamlAction = "/api/v2/openapi.yaml"
|
|
pathTo ApiV2DocsAction = "/api/v2/docs"
|
|
|
|
instance CanRoute ApiV2TokenController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/token"
|
|
endOfInput
|
|
pure ApiV2CreateTokenAction
|
|
|
|
instance HasPath ApiV2TokenController where
|
|
pathTo ApiV2CreateTokenAction = "/api/v2/token"
|
|
|
|
instance CanRoute ApiV2SdkController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/sdk"
|
|
choice
|
|
[ do endOfInput; pure ApiV2SdkIndexAction
|
|
, do _ <- string "/ihf-client.ts"; endOfInput; pure ApiV2SdkTsAction
|
|
, do _ <- string "/ihf-client.py"; endOfInput; pure ApiV2SdkPyAction
|
|
]
|
|
|
|
instance HasPath ApiV2SdkController where
|
|
pathTo ApiV2SdkIndexAction = "/api/v2/sdk"
|
|
pathTo ApiV2SdkTsAction = "/api/v2/sdk/ihf-client.ts"
|
|
pathTo ApiV2SdkPyAction = "/api/v2/sdk/ihf-client.py"
|
|
|
|
-- Phase 10 — Hub Registry and Widget Marketplace (IHUB-WP-0011)
|
|
instance AutoRoute HubRegistryController
|
|
instance AutoRoute WidgetPatternsController
|
|
instance AutoRoute GovernanceTemplatesController
|
|
instance AutoRoute MarketplaceDashboardController
|
|
|
|
-- /api/v2/ Phase 10 endpoints
|
|
|
|
instance CanRoute ApiV2HubRegistryController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/hub-registry"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexHubRegistryAction
|
|
, do _ <- string "/"; hId <- parseUUID; endOfInput
|
|
pure ApiV2ShowHubRegistryAction { hubId = Id hId }
|
|
]
|
|
|
|
instance HasPath ApiV2HubRegistryController where
|
|
pathTo ApiV2IndexHubRegistryAction = "/api/v2/hub-registry"
|
|
pathTo ApiV2ShowHubRegistryAction { hubId } = "/api/v2/hub-registry/" <> tshow hubId
|
|
|
|
instance CanRoute ApiV2HubsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/hubs"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexHubsAction
|
|
, do _ <- string "/"; hId <- parseUUID; endOfInput
|
|
pure ApiV2ShowHubAction { hubId = Id hId }
|
|
]
|
|
|
|
instance HasPath ApiV2HubsController where
|
|
pathTo ApiV2IndexHubsAction = "/api/v2/hubs"
|
|
pathTo ApiV2ShowHubAction { hubId } = "/api/v2/hubs/" <> tshow hubId
|
|
pathTo ApiV2CreateHubAction = "/api/v2/hubs"
|
|
|
|
instance CanRoute ApiV2HubCapabilityManifestsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/hub-capability-manifests"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexHubCapabilityManifestsAction
|
|
, do _ <- string "/"; mId <- parseUUID
|
|
choice
|
|
[ do _ <- string "/activate"; endOfInput
|
|
pure ApiV2ActivateHubCapabilityManifestAction { hubCapabilityManifestId = Id mId }
|
|
, do endOfInput
|
|
pure ApiV2ShowHubCapabilityManifestAction { hubCapabilityManifestId = Id mId }
|
|
]
|
|
]
|
|
|
|
instance HasPath ApiV2HubCapabilityManifestsController where
|
|
pathTo ApiV2IndexHubCapabilityManifestsAction = "/api/v2/hub-capability-manifests"
|
|
pathTo ApiV2ShowHubCapabilityManifestAction { hubCapabilityManifestId } = "/api/v2/hub-capability-manifests/" <> tshow hubCapabilityManifestId
|
|
pathTo ApiV2CreateHubCapabilityManifestAction = "/api/v2/hub-capability-manifests"
|
|
pathTo ApiV2UpdateHubCapabilityManifestAction { hubCapabilityManifestId } = "/api/v2/hub-capability-manifests/" <> tshow hubCapabilityManifestId
|
|
pathTo ApiV2ActivateHubCapabilityManifestAction { hubCapabilityManifestId } = "/api/v2/hub-capability-manifests/" <> tshow hubCapabilityManifestId <> "/activate"
|
|
|
|
instance CanRoute ApiV2WidgetPatternsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/widget-patterns"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexWidgetPatternsAction
|
|
, do _ <- string "/"; pId <- parseUUID
|
|
choice
|
|
[ do _ <- string "/adopt"; endOfInput
|
|
pure ApiV2AdoptWidgetPatternAction { widgetPatternId = Id pId }
|
|
, do endOfInput
|
|
pure ApiV2ShowWidgetPatternAction { widgetPatternId = Id pId }
|
|
]
|
|
]
|
|
|
|
instance HasPath ApiV2WidgetPatternsController where
|
|
pathTo ApiV2IndexWidgetPatternsAction = "/api/v2/widget-patterns"
|
|
pathTo ApiV2ShowWidgetPatternAction { widgetPatternId } = "/api/v2/widget-patterns/" <> tshow widgetPatternId
|
|
pathTo ApiV2AdoptWidgetPatternAction { widgetPatternId } = "/api/v2/widget-patterns/" <> tshow widgetPatternId <> "/adopt"
|
|
|
|
-- Phase 11 — Advanced AI Federation (IHUB-WP-0012)
|
|
instance AutoRoute AgentRegistrationsController
|
|
instance AutoRoute ModelRoutingPoliciesController
|
|
instance AutoRoute AgentDelegationsController
|
|
instance AutoRoute CollectiveProposalsController
|
|
instance AutoRoute AiGovernancePoliciesController
|
|
|
|
-- Phase 12 — Platform Memory and Continuous Learning (IHUB-WP-0013)
|
|
instance AutoRoute OutcomeCorrelationsController
|
|
instance AutoRoute PatternPerformanceController
|
|
instance AutoRoute AdaptiveThresholdsController
|
|
instance AutoRoute InstitutionalKnowledgeController
|
|
instance AutoRoute LineageEnrichmentController
|
|
instance AutoRoute LearningDashboardController
|
|
|
|
instance CanRoute ApiV2LearningController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2"
|
|
choice
|
|
[ do _ <- string "/outcome-correlations"; endOfInput
|
|
pure ApiV2IndexOutcomeCorrelationsAction
|
|
, do _ <- string "/pattern-performance"; endOfInput
|
|
pure ApiV2IndexPatternPerformanceAction
|
|
, do _ <- string "/knowledge-base"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexKnowledgeBaseAction
|
|
, do _ <- string "/"; eid <- parseUUID; endOfInput
|
|
pure ApiV2ShowKnowledgeBaseAction { knowledgeEntryId = Id eid }
|
|
]
|
|
]
|
|
|
|
instance HasPath ApiV2LearningController where
|
|
pathTo ApiV2IndexOutcomeCorrelationsAction = "/api/v2/outcome-correlations"
|
|
pathTo ApiV2IndexPatternPerformanceAction = "/api/v2/pattern-performance"
|
|
pathTo ApiV2IndexKnowledgeBaseAction = "/api/v2/knowledge-base"
|
|
pathTo ApiV2ShowKnowledgeBaseAction { knowledgeEntryId } = "/api/v2/knowledge-base/" <> tshow knowledgeEntryId
|
|
|
|
-- Sessions
|
|
instance AutoRoute SessionsController
|
|
|
|
-- WP-0015 — Public intro / tutorial pages (manual routing so / is the root)
|
|
instance CanRoute StaticPagesController where
|
|
parseRoute' = choice
|
|
[ do _ <- string "/"; endOfInput; pure LandingAction
|
|
, do _ <- string "/capabilities"; endOfInput; pure CapabilitiesAction
|
|
, do _ <- string "/tutorial"; endOfInput; pure TutorialAction
|
|
, do _ <- string "/extension-guide"; endOfInput; pure ExtensionGuideAction
|
|
]
|
|
|
|
instance HasPath StaticPagesController where
|
|
pathTo LandingAction = "/"
|
|
pathTo CapabilitiesAction = "/capabilities"
|
|
pathTo TutorialAction = "/tutorial"
|
|
pathTo ExtensionGuideAction = "/extension-guide"
|