Plant registry, grow event calendar, and gardening knowledge base populated via cf-harvest ingest endpoint. All 23 tests passing. Stack: - FastAPI + SQLite (cf-core migrations) on port 8522 - Vue 3 + Vite + Pinia SPA on port 8521 - 5 SQL migrations: locations → plants → grow_events, knowledge_sources → knowledge_facts - Earthy green theme (--color-primary: #4a7c59) matching CF theme system Knowledge ingest contract: - POST /api/v1/knowledge/ingest — idempotent on fact_hash (sha256 of type+payload+video_path) - 8 fact types: companion_planting, soil_amendment, propagation, pest_diagnosis, harvest_timing, instruction, medicinal, history_context - Partial batch failure: malformed facts collected in rejected[], valid facts inserted - Re-ingesting same video batch: facts_skipped_duplicate > 0, no duplicates Wired views: RegistryView (plant CRUD), KnowledgeView (facts + type filter chips) Stub views: CalendarView, SettingsView
57 lines
1.3 KiB
TypeScript
57 lines
1.3 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
import { api } from '@/services/api'
|
|
|
|
export type FactType =
|
|
| 'companion_planting'
|
|
| 'soil_amendment'
|
|
| 'propagation'
|
|
| 'pest_diagnosis'
|
|
| 'harvest_timing'
|
|
| 'instruction'
|
|
| 'medicinal'
|
|
| 'history_context'
|
|
|
|
export interface KnowledgeFact {
|
|
id: number
|
|
source_id: number
|
|
fact_type: FactType
|
|
subject: string | null
|
|
payload: Record<string, unknown>
|
|
presenter: string | null
|
|
confidence: number
|
|
fact_hash: string
|
|
created_at: string
|
|
video_path: string | null
|
|
location: string | null
|
|
}
|
|
|
|
export interface KnowledgeFilters {
|
|
fact_type?: FactType
|
|
subject?: string
|
|
presenter?: string
|
|
min_confidence?: number
|
|
limit?: number
|
|
offset?: number
|
|
}
|
|
|
|
export const useKnowledgeStore = defineStore('knowledge', () => {
|
|
const facts = ref<KnowledgeFact[]>([])
|
|
const loading = ref(false)
|
|
const error = ref<string | null>(null)
|
|
|
|
async function fetchFacts(filters: KnowledgeFilters = {}) {
|
|
loading.value = true
|
|
error.value = null
|
|
try {
|
|
const resp = await api.get('/knowledge', { params: filters })
|
|
facts.value = resp.data
|
|
} catch (e: any) {
|
|
error.value = e?.response?.data?.detail ?? 'Failed to load knowledge'
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
return { facts, loading, error, fetchFacts }
|
|
})
|