feat(WP-0011): IHF Phase 10 — Hub Registry and Widget Marketplace
Delivers the hub registry discovery UI, widget pattern library,
governance template library, and marketplace dashboard.
Key changes:
- Schema: widget_patterns (widget_type FK to registry), widget_pattern_versions,
pattern_adoptions, governance_templates (categories JSONB, validated at
controller), governance_template_clones — all GAAF-compliant, no bare TEXT
type discriminators
- Migration: 1743897600-ihf-phase10-hub-registry.sql
- HubRegistry controller + views: browsable view over hub_capability_manifests,
hub_health_snapshots, hubs with per-hub GAAF compliance indicator
- WidgetPatterns controller + views: publish, version, adopt; adoption
triggers manifest amendment draft when new types are introduced
- GovernanceTemplates controller + views: CRUD, clone with category
validation against annotation_category_registry
- MarketplaceDashboard controller + view: full-text search, widget-type
filter, sort, trending panel, autoRefresh
- API v2: /api/v2/hub-registry, /api/v2/widget-patterns (+ adopt endpoint)
- OpenAPI spec updated with Phase 10 paths
- GAAF scorecard: Customization 2.5 → 3.2; overall 3.41 → 3.56 (Strong)
- CLAUDE.md: Phase 10 complete; active workplan → Phase 11
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 20:14:43 +00:00
|
|
|
module Web.Controller.MarketplaceDashboard where
|
|
|
|
|
|
|
|
|
|
import Web.Types
|
|
|
|
|
import Web.View.MarketplaceDashboard.Show
|
|
|
|
|
import Generated.Types
|
|
|
|
|
import IHP.Prelude
|
|
|
|
|
import IHP.ControllerPrelude
|
|
|
|
|
instance Controller MarketplaceDashboardController where
|
|
|
|
|
beforeAction = ensureIsUser
|
|
|
|
|
|
|
|
|
|
action MarketplaceDashboardAction = autoRefresh do
|
|
|
|
|
let mSearch = paramOrNothing @Text "q"
|
|
|
|
|
let mWType = paramOrNothing @Text "widgetType"
|
|
|
|
|
let sortBy = paramOrDefault @Text "adopted" "sort"
|
|
|
|
|
|
2026-04-12 13:11:32 +00:00
|
|
|
-- Widget patterns: fetch then count adoptions
|
|
|
|
|
basePatterns <- query @WidgetPattern
|
|
|
|
|
|> filterWhere (#isPublished, True)
|
|
|
|
|
|> orderByAsc #name
|
|
|
|
|
|> limit 50
|
|
|
|
|
|> fetch
|
|
|
|
|
patterns <- mapM (\p -> do
|
|
|
|
|
cnt <- sqlQueryScalar
|
|
|
|
|
"SELECT COUNT(*) FROM pattern_adoptions WHERE widget_pattern_id = ?"
|
|
|
|
|
(Only p.id)
|
|
|
|
|
pure (p, fromMaybe 0 cnt)) basePatterns
|
|
|
|
|
|
|
|
|
|
-- Governance templates: fetch then count clones
|
|
|
|
|
baseTemplates <- query @GovernanceTemplate
|
|
|
|
|
|> filterWhere (#isPublished, True)
|
|
|
|
|
|> limit 50
|
|
|
|
|
|> fetch
|
|
|
|
|
templates <- mapM (\t -> do
|
|
|
|
|
cnt <- sqlQueryScalar
|
|
|
|
|
"SELECT COUNT(*) FROM governance_template_clones WHERE governance_template_id = ?"
|
|
|
|
|
(Only t.id)
|
|
|
|
|
pure (t, fromMaybe 0 cnt)) baseTemplates
|
feat(WP-0011): IHF Phase 10 — Hub Registry and Widget Marketplace
Delivers the hub registry discovery UI, widget pattern library,
governance template library, and marketplace dashboard.
Key changes:
- Schema: widget_patterns (widget_type FK to registry), widget_pattern_versions,
pattern_adoptions, governance_templates (categories JSONB, validated at
controller), governance_template_clones — all GAAF-compliant, no bare TEXT
type discriminators
- Migration: 1743897600-ihf-phase10-hub-registry.sql
- HubRegistry controller + views: browsable view over hub_capability_manifests,
hub_health_snapshots, hubs with per-hub GAAF compliance indicator
- WidgetPatterns controller + views: publish, version, adopt; adoption
triggers manifest amendment draft when new types are introduced
- GovernanceTemplates controller + views: CRUD, clone with category
validation against annotation_category_registry
- MarketplaceDashboard controller + view: full-text search, widget-type
filter, sort, trending panel, autoRefresh
- API v2: /api/v2/hub-registry, /api/v2/widget-patterns (+ adopt endpoint)
- OpenAPI spec updated with Phase 10 paths
- GAAF scorecard: Customization 2.5 → 3.2; overall 3.41 → 3.56 (Strong)
- CLAUDE.md: Phase 10 complete; active workplan → Phase 11
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 20:14:43 +00:00
|
|
|
|
|
|
|
|
-- Trending patterns (most adoptions in last 30 days)
|
2026-04-12 13:11:32 +00:00
|
|
|
trendingRaw :: [(Id WidgetPattern, Text, Text, Int)] <- sqlQuery
|
|
|
|
|
"SELECT wp.id, wp.name, wp.widget_type, CAST(COUNT(pa.id) AS integer) AS recent_adoptions \
|
feat(WP-0011): IHF Phase 10 — Hub Registry and Widget Marketplace
Delivers the hub registry discovery UI, widget pattern library,
governance template library, and marketplace dashboard.
Key changes:
- Schema: widget_patterns (widget_type FK to registry), widget_pattern_versions,
pattern_adoptions, governance_templates (categories JSONB, validated at
controller), governance_template_clones — all GAAF-compliant, no bare TEXT
type discriminators
- Migration: 1743897600-ihf-phase10-hub-registry.sql
- HubRegistry controller + views: browsable view over hub_capability_manifests,
hub_health_snapshots, hubs with per-hub GAAF compliance indicator
- WidgetPatterns controller + views: publish, version, adopt; adoption
triggers manifest amendment draft when new types are introduced
- GovernanceTemplates controller + views: CRUD, clone with category
validation against annotation_category_registry
- MarketplaceDashboard controller + view: full-text search, widget-type
filter, sort, trending panel, autoRefresh
- API v2: /api/v2/hub-registry, /api/v2/widget-patterns (+ adopt endpoint)
- OpenAPI spec updated with Phase 10 paths
- GAAF scorecard: Customization 2.5 → 3.2; overall 3.41 → 3.56 (Strong)
- CLAUDE.md: Phase 10 complete; active workplan → Phase 11
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 20:14:43 +00:00
|
|
|
\ FROM widget_patterns wp \
|
|
|
|
|
\ JOIN pattern_adoptions pa ON pa.widget_pattern_id = wp.id \
|
|
|
|
|
\ WHERE wp.is_published = TRUE \
|
|
|
|
|
\ AND pa.adopted_at >= NOW() - INTERVAL '30 days' \
|
|
|
|
|
\ GROUP BY wp.id, wp.name, wp.widget_type \
|
|
|
|
|
\ ORDER BY recent_adoptions DESC \
|
|
|
|
|
\ LIMIT 5"
|
|
|
|
|
()
|
2026-04-12 13:11:32 +00:00
|
|
|
let trending = trendingRaw
|
feat(WP-0011): IHF Phase 10 — Hub Registry and Widget Marketplace
Delivers the hub registry discovery UI, widget pattern library,
governance template library, and marketplace dashboard.
Key changes:
- Schema: widget_patterns (widget_type FK to registry), widget_pattern_versions,
pattern_adoptions, governance_templates (categories JSONB, validated at
controller), governance_template_clones — all GAAF-compliant, no bare TEXT
type discriminators
- Migration: 1743897600-ihf-phase10-hub-registry.sql
- HubRegistry controller + views: browsable view over hub_capability_manifests,
hub_health_snapshots, hubs with per-hub GAAF compliance indicator
- WidgetPatterns controller + views: publish, version, adopt; adoption
triggers manifest amendment draft when new types are introduced
- GovernanceTemplates controller + views: CRUD, clone with category
validation against annotation_category_registry
- MarketplaceDashboard controller + view: full-text search, widget-type
filter, sort, trending panel, autoRefresh
- API v2: /api/v2/hub-registry, /api/v2/widget-patterns (+ adopt endpoint)
- OpenAPI spec updated with Phase 10 paths
- GAAF scorecard: Customization 2.5 → 3.2; overall 3.41 → 3.56 (Strong)
- CLAUDE.md: Phase 10 complete; active workplan → Phase 11
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 20:14:43 +00:00
|
|
|
|
|
|
|
|
widgetTypeOptions <- sqlQuery
|
|
|
|
|
"SELECT name, label FROM widget_type_registry WHERE status = 'active' ORDER BY label"
|
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
render ShowView
|
|
|
|
|
{ patterns, templates, trending
|
|
|
|
|
, widgetTypeOptions
|
|
|
|
|
, searchQuery = mSearch
|
|
|
|
|
, selectedType = mWType
|
|
|
|
|
, sortOrder = sortBy
|
|
|
|
|
}
|
|
|
|
|
|