diff --git a/Makefile b/Makefile index e436bac..3966268 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ SERVER_BIN := $(BIN_DIR)/amcs-server CMD_SERVER := ./cmd/amcs-server BUILDINFO_PKG := git.warky.dev/wdevs/amcs/internal/buildinfo UI_DIR := $(CURDIR)/ui +AMCS_UI_BACKEND ?= http://127.0.0.1:8080 PATCH_INCREMENT ?= 1 RELEASE_VERSION ?= RELEASE_REMOTE ?= origin @@ -40,7 +41,7 @@ help: @echo " check-schema-drift Verify generated migration matches current schema" @echo " ui-install Install UI dependencies" @echo " ui-build Build UI assets" - @echo " ui-dev Start UI dev server" + @echo " ui-dev Start UI dev server with local API proxy" @echo " ui-check Run UI type checks" build: ui-build @@ -54,7 +55,7 @@ ui-build: ui-install cd $(UI_DIR) && $(PNPM) run build ui-dev: ui-install - cd $(UI_DIR) && $(PNPM) run dev + cd $(UI_DIR) && VITE_API_URL=/api AMCS_UI_BACKEND=$(AMCS_UI_BACKEND) $(PNPM) run dev ui-check: ui-install cd $(UI_DIR) && $(PNPM) run check diff --git a/internal/app/app.go b/internal/app/app.go index 9949eef..6eee341 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -214,10 +214,10 @@ func routes(logger *slog.Logger, cfg *config.Config, info buildinfo.Info, db *st Backfill: backfillTool, Reparse: tools.NewReparseMetadataTool(db, bgMetadata, cfg.Capture, activeProjects, logger), RetryMetadata: tools.NewRetryEnrichmentTool(enrichmentRetryer), - Maintenance: tools.NewMaintenanceTool(db), - Skills: tools.NewSkillsTool(db, activeProjects), - ChatHistory: tools.NewChatHistoryTool(db, activeProjects), - Describe: tools.NewDescribeTool(db, mcpserver.BuildToolCatalog()), + //Maintenance: tools.NewMaintenanceTool(db), + Skills: tools.NewSkillsTool(db, activeProjects), + ChatHistory: tools.NewChatHistoryTool(db, activeProjects), + Describe: tools.NewDescribeTool(db, mcpserver.BuildToolCatalog()), } mcpHandlers, err := mcpserver.NewHandlers(cfg.MCP, logger, toolSet, activeProjects.Clear) diff --git a/internal/app/resolvespec_admin.go b/internal/app/resolvespec_admin.go index 0ac7c50..6d420a0 100644 --- a/internal/app/resolvespec_admin.go +++ b/internal/app/resolvespec_admin.go @@ -4,6 +4,7 @@ import ( "fmt" "log/slog" "net/http" + "strings" "github.com/bitechdev/ResolveSpec/pkg/resolvespec" "github.com/uptrace/bunrouter" @@ -26,6 +27,21 @@ func registerResolveSpecAdminRoutes(mux *http.ServeMux, db *store.DB, middleware rsMount := http.StripPrefix("/api/rs", rsRouter) protectedRSMount := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" && strings.HasSuffix(r.URL.Path, "/") { + trimmed := strings.TrimRight(r.URL.Path, "/") + if trimmed == "" { + trimmed = "/" + } + clone := r.Clone(r.Context()) + clone.URL.Path = trimmed + if clone.URL.RawPath != "" { + clone.URL.RawPath = strings.TrimRight(clone.URL.RawPath, "/") + if clone.URL.RawPath == "" { + clone.URL.RawPath = "/" + } + } + r = clone + } if r.Method == http.MethodOptions { rsMount.ServeHTTP(w, r) return @@ -50,15 +66,36 @@ func registerResolveSpecGuards(rs *resolvespec.Handler) { mutableByEntity := map[string]map[string]struct{}{ "projects": { "create": {}, + "update": {}, + "delete": {}, }, "thoughts": { + "create": {}, + "update": {}, + "delete": {}, + }, + "plans": { + "create": {}, + "update": {}, + "delete": {}, + }, + "learnings": { + "create": {}, "update": {}, "delete": {}, }, "agent_skills": { + "create": {}, + "update": {}, "delete": {}, }, "agent_guardrails": { + "create": {}, + "update": {}, + "delete": {}, + }, + "stored_files": { + "update": {}, "delete": {}, }, } @@ -98,33 +135,35 @@ type resolveSpecModel struct { } func resolveSpecModels() []resolveSpecModel { + //This must be generated with relspec to include all models + //Use the relspec command with template generation. It supprot templ. return []resolveSpecModel{ - {schema: "public", entity: "activities", model: generatedmodels.ModelPublicActivities{}}, + // {schema: "public", entity: "activities", model: generatedmodels.ModelPublicActivities{}}, {schema: "public", entity: "agent_guardrails", model: generatedmodels.ModelPublicAgentGuardrails{}}, {schema: "public", entity: "agent_skills", model: generatedmodels.ModelPublicAgentSkills{}}, {schema: "public", entity: "chat_histories", model: generatedmodels.ModelPublicChatHistories{}}, - {schema: "public", entity: "contact_interactions", model: generatedmodels.ModelPublicContactInteractions{}}, + // {schema: "public", entity: "contact_interactions", model: generatedmodels.ModelPublicContactInteractions{}}, {schema: "public", entity: "embeddings", model: generatedmodels.ModelPublicEmbeddings{}}, - {schema: "public", entity: "family_members", model: generatedmodels.ModelPublicFamilyMembers{}}, - {schema: "public", entity: "household_items", model: generatedmodels.ModelPublicHouseholdItems{}}, - {schema: "public", entity: "household_vendors", model: generatedmodels.ModelPublicHouseholdVendors{}}, - {schema: "public", entity: "important_dates", model: generatedmodels.ModelPublicImportantDates{}}, + // {schema: "public", entity: "family_members", model: generatedmodels.ModelPublicFamilyMembers{}}, + // {schema: "public", entity: "household_items", model: generatedmodels.ModelPublicHouseholdItems{}}, + // {schema: "public", entity: "household_vendors", model: generatedmodels.ModelPublicHouseholdVendors{}}, + // {schema: "public", entity: "important_dates", model: generatedmodels.ModelPublicImportantDates{}}, {schema: "public", entity: "learnings", model: generatedmodels.ModelPublicLearnings{}}, - {schema: "public", entity: "maintenance_logs", model: generatedmodels.ModelPublicMaintenanceLogs{}}, - {schema: "public", entity: "maintenance_tasks", model: generatedmodels.ModelPublicMaintenanceTasks{}}, - {schema: "public", entity: "meal_plans", model: generatedmodels.ModelPublicMealPlans{}}, - {schema: "public", entity: "opportunities", model: generatedmodels.ModelPublicOpportunities{}}, + // {schema: "public", entity: "maintenance_logs", model: generatedmodels.ModelPublicMaintenanceLogs{}}, + // {schema: "public", entity: "maintenance_tasks", model: generatedmodels.ModelPublicMaintenanceTasks{}}, + // {schema: "public", entity: "meal_plans", model: generatedmodels.ModelPublicMealPlans{}}, + // {schema: "public", entity: "opportunities", model: generatedmodels.ModelPublicOpportunities{}}, {schema: "public", entity: "plan_dependencies", model: generatedmodels.ModelPublicPlanDependencies{}}, {schema: "public", entity: "plan_guardrails", model: generatedmodels.ModelPublicPlanGuardrails{}}, {schema: "public", entity: "plan_related_plans", model: generatedmodels.ModelPublicPlanRelatedPlans{}}, {schema: "public", entity: "plan_skills", model: generatedmodels.ModelPublicPlanSkills{}}, {schema: "public", entity: "plans", model: generatedmodels.ModelPublicPlans{}}, - {schema: "public", entity: "professional_contacts", model: generatedmodels.ModelPublicProfessionalContacts{}}, + // {schema: "public", entity: "professional_contacts", model: generatedmodels.ModelPublicProfessionalContacts{}}, {schema: "public", entity: "project_guardrails", model: generatedmodels.ModelPublicProjectGuardrails{}}, {schema: "public", entity: "project_skills", model: generatedmodels.ModelPublicProjectSkills{}}, {schema: "public", entity: "projects", model: generatedmodels.ModelPublicProjects{}}, - {schema: "public", entity: "recipes", model: generatedmodels.ModelPublicRecipes{}}, - {schema: "public", entity: "shopping_lists", model: generatedmodels.ModelPublicShoppingLists{}}, + // {schema: "public", entity: "recipes", model: generatedmodels.ModelPublicRecipes{}}, + // {schema: "public", entity: "shopping_lists", model: generatedmodels.ModelPublicShoppingLists{}}, {schema: "public", entity: "stored_files", model: generatedmodels.ModelPublicStoredFiles{}}, {schema: "public", entity: "thought_links", model: generatedmodels.ModelPublicThoughtLinks{}}, {schema: "public", entity: "thoughts", model: generatedmodels.ModelPublicThoughts{}}, diff --git a/internal/app/resolvespec_admin_test.go b/internal/app/resolvespec_admin_test.go index 9e1cb87..51ad17e 100644 --- a/internal/app/resolvespec_admin_test.go +++ b/internal/app/resolvespec_admin_test.go @@ -63,10 +63,25 @@ func TestResolveSpecGuardAllowsSupportedMutations(t *testing.T) { }{ {name: "learnings read", entity: "learnings", operation: "read"}, {name: "projects create", entity: "projects", operation: "create"}, + {name: "projects update", entity: "projects", operation: "update"}, + {name: "projects delete", entity: "projects", operation: "delete"}, + {name: "plans create", entity: "plans", operation: "create"}, + {name: "plans update", entity: "plans", operation: "update"}, + {name: "plans delete", entity: "plans", operation: "delete"}, + {name: "learnings create", entity: "learnings", operation: "create"}, + {name: "learnings update", entity: "learnings", operation: "update"}, + {name: "learnings delete", entity: "learnings", operation: "delete"}, + {name: "thoughts create", entity: "thoughts", operation: "create"}, {name: "thoughts update", entity: "thoughts", operation: "update"}, {name: "thoughts delete", entity: "thoughts", operation: "delete"}, + {name: "agent_skills create", entity: "agent_skills", operation: "create"}, + {name: "agent_skills update", entity: "agent_skills", operation: "update"}, {name: "agent_skills delete", entity: "agent_skills", operation: "delete"}, + {name: "agent_guardrails create", entity: "agent_guardrails", operation: "create"}, + {name: "agent_guardrails update", entity: "agent_guardrails", operation: "update"}, {name: "agent_guardrails delete", entity: "agent_guardrails", operation: "delete"}, + {name: "stored_files update", entity: "stored_files", operation: "update"}, + {name: "stored_files delete", entity: "stored_files", operation: "delete"}, } for _, tc := range cases { @@ -100,32 +115,18 @@ func TestResolveSpecGuardBlocksUnsupportedMutations(t *testing.T) { wantMessageIn string }{ { - name: "create not allowed on thoughts", - entity: "thoughts", + name: "mutations blocked for non-allowlisted operation", + entity: "stored_files", operation: "create", wantCode: http.StatusForbidden, - wantMessageIn: `operation "create" is not allowed for public.thoughts`, - }, - { - name: "delete not allowed on projects", - entity: "projects", - operation: "delete", - wantCode: http.StatusForbidden, - wantMessageIn: `operation "delete" is not allowed for public.projects`, + wantMessageIn: `operation "create" is not allowed for public.stored_files`, }, { name: "mutations blocked for non-allowlisted entity", - entity: "stored_files", + entity: "maintenance_logs", operation: "delete", wantCode: http.StatusForbidden, - wantMessageIn: `operation "delete" is not allowed for public.stored_files`, - }, - { - name: "mutations blocked for learnings", - entity: "learnings", - operation: "delete", - wantCode: http.StatusForbidden, - wantMessageIn: `operation "delete" is not allowed for public.learnings`, + wantMessageIn: `operation "delete" is not allowed for public.maintenance_logs`, }, { name: "unknown operation is rejected", diff --git a/internal/generatedmodels/sql_public_activities.go b/internal/generatedmodels/sql_public_activities.go deleted file mode 100644 index 2e6a2ef..0000000 --- a/internal/generatedmodels/sql_public_activities.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicActivities struct { - bun.BaseModel `bun:"table:public.activities,alias:activities"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - ActivityType resolvespec_common.SqlString `bun:"activity_type,type:text,nullzero," json:"activity_type"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - DayOfWeek resolvespec_common.SqlString `bun:"day_of_week,type:text,nullzero," json:"day_of_week"` - EndDate resolvespec_common.SqlDate `bun:"end_date,type:date,nullzero," json:"end_date"` - EndTime resolvespec_common.SqlTime `bun:"end_time,type:time,nullzero," json:"end_time"` - FamilyMemberID resolvespec_common.SqlUUID `bun:"family_member_id,type:uuid,nullzero," json:"family_member_id"` - Location resolvespec_common.SqlString `bun:"location,type:text,nullzero," json:"location"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - StartDate resolvespec_common.SqlDate `bun:"start_date,type:date,nullzero," json:"start_date"` - StartTime resolvespec_common.SqlTime `bun:"start_time,type:time,nullzero," json:"start_time"` - Title resolvespec_common.SqlString `bun:"title,type:text,notnull," json:"title"` - RelFamilyMemberID *ModelPublicFamilyMembers `bun:"rel:has-one,join:family_member_id=id" json:"relfamilymemberid,omitempty"` // Has one ModelPublicFamilyMembers -} - -// TableName returns the table name for ModelPublicActivities -func (m ModelPublicActivities) TableName() string { - return "public.activities" -} - -// TableNameOnly returns the table name without schema for ModelPublicActivities -func (m ModelPublicActivities) TableNameOnly() string { - return "activities" -} - -// SchemaName returns the schema name for ModelPublicActivities -func (m ModelPublicActivities) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicActivities) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicActivities) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicActivities) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicActivities) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicActivities) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicActivities) GetPrefix() string { - return "ACT" -} diff --git a/internal/generatedmodels/sql_public_agent_guardrails.go b/internal/generatedmodels/sql_public_agent_guardrails.go index 63fb3ce..6cce557 100644 --- a/internal/generatedmodels/sql_public_agent_guardrails.go +++ b/internal/generatedmodels/sql_public_agent_guardrails.go @@ -9,16 +9,16 @@ import ( type ModelPublicAgentGuardrails struct { bun.BaseModel `bun:"table:public.agent_guardrails,alias:agent_guardrails"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Description resolvespec_common.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Severity resolvespec_common.SqlString `bun:"severity,type:text,default:'medium',notnull," json:"severity"` - Tags resolvespec_common.SqlStringArray `bun:"tags,type:text,default:'{}',notnull," json:"tags"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelGuardrailIDPublicPlanGuardrails []*ModelPublicPlanGuardrails `bun:"rel:has-many,join:id=guardrail_id" json:"relguardrailidpublicplanguardrails,omitempty"` // Has many ModelPublicPlanGuardrails - RelGuardrailIDPublicProjectGuardrails []*ModelPublicProjectGuardrails `bun:"rel:has-many,join:id=guardrail_id" json:"relguardrailidpublicprojectguardrails,omitempty"` // Has many ModelPublicProjectGuardrails + ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` + Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description resolvespec_common.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` + Severity resolvespec_common.SqlString `bun:"severity,type:text,default:'medium',notnull," json:"severity"` + Tags resolvespec_common.SqlString `bun:"tags,type:text,nullzero," json:"tags"` + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelGuardrailIDPublicPlanGuardrails []*ModelPublicPlanGuardrails `bun:"rel:has-many,join:id=guardrail_id" json:"relguardrailidpublicplanguardrails,omitempty"` // Has many ModelPublicPlanGuardrails + RelGuardrailIDPublicProjectGuardrails []*ModelPublicProjectGuardrails `bun:"rel:has-many,join:id=guardrail_id" json:"relguardrailidpublicprojectguardrails,omitempty"` // Has many ModelPublicProjectGuardrails } // TableName returns the table name for ModelPublicAgentGuardrails diff --git a/internal/generatedmodels/sql_public_agent_skills.go b/internal/generatedmodels/sql_public_agent_skills.go index 87b15eb..d3ac912 100644 --- a/internal/generatedmodels/sql_public_agent_skills.go +++ b/internal/generatedmodels/sql_public_agent_skills.go @@ -9,16 +9,16 @@ import ( type ModelPublicAgentSkills struct { bun.BaseModel `bun:"table:public.agent_skills,alias:agent_skills"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Description resolvespec_common.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Tags resolvespec_common.SqlStringArray `bun:"tags,type:text,default:'{}',notnull," json:"tags"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelRelatedSkillIDPublicLearnings []*ModelPublicLearnings `bun:"rel:has-many,join:id=related_skill_id" json:"relrelatedskillidpubliclearnings,omitempty"` // Has many ModelPublicLearnings - RelSkillIDPublicPlanSkills []*ModelPublicPlanSkills `bun:"rel:has-many,join:id=skill_id" json:"relskillidpublicplanskills,omitempty"` // Has many ModelPublicPlanSkills - RelSkillIDPublicProjectSkills []*ModelPublicProjectSkills `bun:"rel:has-many,join:id=skill_id" json:"relskillidpublicprojectskills,omitempty"` // Has many ModelPublicProjectSkills + ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` + Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description resolvespec_common.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` + Tags resolvespec_common.SqlString `bun:"tags,type:text,nullzero," json:"tags"` + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelRelatedSkillIDPublicLearnings []*ModelPublicLearnings `bun:"rel:has-many,join:id=related_skill_id" json:"relrelatedskillidpubliclearnings,omitempty"` // Has many ModelPublicLearnings + RelSkillIDPublicPlanSkills []*ModelPublicPlanSkills `bun:"rel:has-many,join:id=skill_id" json:"relskillidpublicplanskills,omitempty"` // Has many ModelPublicPlanSkills + RelSkillIDPublicProjectSkills []*ModelPublicProjectSkills `bun:"rel:has-many,join:id=skill_id" json:"relskillidpublicprojectskills,omitempty"` // Has many ModelPublicProjectSkills } // TableName returns the table name for ModelPublicAgentSkills diff --git a/internal/generatedmodels/sql_public_chat_histories.go b/internal/generatedmodels/sql_public_chat_histories.go index ae5fd12..be126c1 100644 --- a/internal/generatedmodels/sql_public_chat_histories.go +++ b/internal/generatedmodels/sql_public_chat_histories.go @@ -13,7 +13,7 @@ type ModelPublicChatHistories struct { AgentID resolvespec_common.SqlString `bun:"agent_id,type:text,nullzero," json:"agent_id"` Channel resolvespec_common.SqlString `bun:"channel,type:text,nullzero," json:"channel"` CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Messages resolvespec_common.SqlJSONB `bun:"messages,type:jsonb,default:'',notnull," json:"messages"` + Messages resolvespec_common.SqlJSONB `bun:"messages,type:jsonb,default:'[',notnull," json:"messages"` Metadata resolvespec_common.SqlJSONB `bun:"metadata,type:jsonb,default:'{}',notnull," json:"metadata"` ProjectID resolvespec_common.SqlUUID `bun:"project_id,type:uuid,nullzero," json:"project_id"` SessionID resolvespec_common.SqlString `bun:"session_id,type:text,notnull," json:"session_id"` diff --git a/internal/generatedmodels/sql_public_contact_interactions.go b/internal/generatedmodels/sql_public_contact_interactions.go deleted file mode 100644 index d244e3a..0000000 --- a/internal/generatedmodels/sql_public_contact_interactions.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicContactInteractions struct { - bun.BaseModel `bun:"table:public.contact_interactions,alias:contact_interactions"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - ContactID resolvespec_common.SqlUUID `bun:"contact_id,type:uuid,notnull," json:"contact_id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - FollowUpNeeded bool `bun:"follow_up_needed,type:boolean,default:false,notnull," json:"follow_up_needed"` - FollowUpNotes resolvespec_common.SqlString `bun:"follow_up_notes,type:text,nullzero," json:"follow_up_notes"` - InteractionType resolvespec_common.SqlString `bun:"interaction_type,type:text,notnull," json:"interaction_type"` - OccurredAt resolvespec_common.SqlTimeStamp `bun:"occurred_at,type:timestamptz,default:now(),notnull," json:"occurred_at"` - Summary resolvespec_common.SqlString `bun:"summary,type:text,notnull," json:"summary"` - RelContactID *ModelPublicProfessionalContacts `bun:"rel:has-one,join:contact_id=id" json:"relcontactid,omitempty"` // Has one ModelPublicProfessionalContacts -} - -// TableName returns the table name for ModelPublicContactInteractions -func (m ModelPublicContactInteractions) TableName() string { - return "public.contact_interactions" -} - -// TableNameOnly returns the table name without schema for ModelPublicContactInteractions -func (m ModelPublicContactInteractions) TableNameOnly() string { - return "contact_interactions" -} - -// SchemaName returns the schema name for ModelPublicContactInteractions -func (m ModelPublicContactInteractions) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicContactInteractions) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicContactInteractions) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicContactInteractions) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicContactInteractions) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicContactInteractions) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicContactInteractions) GetPrefix() string { - return "CIO" -} diff --git a/internal/generatedmodels/sql_public_embeddings.go b/internal/generatedmodels/sql_public_embeddings.go index 16c26f7..276c0da 100644 --- a/internal/generatedmodels/sql_public_embeddings.go +++ b/internal/generatedmodels/sql_public_embeddings.go @@ -11,8 +11,8 @@ type ModelPublicEmbeddings struct { bun.BaseModel `bun:"table:public.embeddings,alias:embeddings"` ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),nullzero," json:"created_at"` - Dim int32 `bun:"dim,type:int,notnull," json:"dim"` - Embedding resolvespec_common.SqlVector `bun:"embedding,type:vector,notnull," json:"embedding"` + Dim resolvespec_common.SqlInt32 `bun:"dim,type:int,notnull," json:"dim"` + Embedding resolvespec_common.SqlString `bun:"embedding,type:vector,notnull," json:"embedding"` GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` Model resolvespec_common.SqlString `bun:"model,type:text,notnull,unique:uidx_embeddings_thought_id_model," json:"model"` ThoughtID resolvespec_common.SqlUUID `bun:"thought_id,type:uuid,notnull,unique:uidx_embeddings_thought_id_model," json:"thought_id"` diff --git a/internal/generatedmodels/sql_public_family_members.go b/internal/generatedmodels/sql_public_family_members.go deleted file mode 100644 index c59329b..0000000 --- a/internal/generatedmodels/sql_public_family_members.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicFamilyMembers struct { - bun.BaseModel `bun:"table:public.family_members,alias:family_members"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - BirthDate resolvespec_common.SqlDate `bun:"birth_date,type:date,nullzero," json:"birth_date"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - Relationship resolvespec_common.SqlString `bun:"relationship,type:text,nullzero," json:"relationship"` - RelFamilyMemberIDPublicActivities []*ModelPublicActivities `bun:"rel:has-many,join:id=family_member_id" json:"relfamilymemberidpublicactivities,omitempty"` // Has many ModelPublicActivities - RelFamilyMemberIDPublicImportantDates []*ModelPublicImportantDates `bun:"rel:has-many,join:id=family_member_id" json:"relfamilymemberidpublicimportantdates,omitempty"` // Has many ModelPublicImportantDates -} - -// TableName returns the table name for ModelPublicFamilyMembers -func (m ModelPublicFamilyMembers) TableName() string { - return "public.family_members" -} - -// TableNameOnly returns the table name without schema for ModelPublicFamilyMembers -func (m ModelPublicFamilyMembers) TableNameOnly() string { - return "family_members" -} - -// SchemaName returns the schema name for ModelPublicFamilyMembers -func (m ModelPublicFamilyMembers) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicFamilyMembers) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicFamilyMembers) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicFamilyMembers) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicFamilyMembers) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicFamilyMembers) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicFamilyMembers) GetPrefix() string { - return "FMA" -} diff --git a/internal/generatedmodels/sql_public_household_items.go b/internal/generatedmodels/sql_public_household_items.go deleted file mode 100644 index 71ea09a..0000000 --- a/internal/generatedmodels/sql_public_household_items.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicHouseholdItems struct { - bun.BaseModel `bun:"table:public.household_items,alias:household_items"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - Category resolvespec_common.SqlString `bun:"category,type:text,nullzero," json:"category"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Details resolvespec_common.SqlJSONB `bun:"details,type:jsonb,default:'{}',notnull," json:"details"` - Location resolvespec_common.SqlString `bun:"location,type:text,nullzero," json:"location"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` -} - -// TableName returns the table name for ModelPublicHouseholdItems -func (m ModelPublicHouseholdItems) TableName() string { - return "public.household_items" -} - -// TableNameOnly returns the table name without schema for ModelPublicHouseholdItems -func (m ModelPublicHouseholdItems) TableNameOnly() string { - return "household_items" -} - -// SchemaName returns the schema name for ModelPublicHouseholdItems -func (m ModelPublicHouseholdItems) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicHouseholdItems) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicHouseholdItems) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicHouseholdItems) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicHouseholdItems) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicHouseholdItems) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicHouseholdItems) GetPrefix() string { - return "HIO" -} diff --git a/internal/generatedmodels/sql_public_household_vendors.go b/internal/generatedmodels/sql_public_household_vendors.go deleted file mode 100644 index 6dcdcdd..0000000 --- a/internal/generatedmodels/sql_public_household_vendors.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicHouseholdVendors struct { - bun.BaseModel `bun:"table:public.household_vendors,alias:household_vendors"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Email resolvespec_common.SqlString `bun:"email,type:text,nullzero," json:"email"` - LastUsed resolvespec_common.SqlDate `bun:"last_used,type:date,nullzero," json:"last_used"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - Phone resolvespec_common.SqlString `bun:"phone,type:text,nullzero," json:"phone"` - Rating resolvespec_common.SqlInt32 `bun:"rating,type:int,nullzero," json:"rating"` - ServiceType resolvespec_common.SqlString `bun:"service_type,type:text,nullzero," json:"service_type"` - Website resolvespec_common.SqlString `bun:"website,type:text,nullzero," json:"website"` -} - -// TableName returns the table name for ModelPublicHouseholdVendors -func (m ModelPublicHouseholdVendors) TableName() string { - return "public.household_vendors" -} - -// TableNameOnly returns the table name without schema for ModelPublicHouseholdVendors -func (m ModelPublicHouseholdVendors) TableNameOnly() string { - return "household_vendors" -} - -// SchemaName returns the schema name for ModelPublicHouseholdVendors -func (m ModelPublicHouseholdVendors) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicHouseholdVendors) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicHouseholdVendors) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicHouseholdVendors) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicHouseholdVendors) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicHouseholdVendors) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicHouseholdVendors) GetPrefix() string { - return "HVO" -} diff --git a/internal/generatedmodels/sql_public_important_dates.go b/internal/generatedmodels/sql_public_important_dates.go deleted file mode 100644 index 24dcc46..0000000 --- a/internal/generatedmodels/sql_public_important_dates.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicImportantDates struct { - bun.BaseModel `bun:"table:public.important_dates,alias:important_dates"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - DateValue resolvespec_common.SqlDate `bun:"date_value,type:date,notnull," json:"date_value"` - FamilyMemberID resolvespec_common.SqlUUID `bun:"family_member_id,type:uuid,nullzero," json:"family_member_id"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - RecurringYearly bool `bun:"recurring_yearly,type:boolean,default:false,notnull," json:"recurring_yearly"` - ReminderDaysBefore int32 `bun:"reminder_days_before,type:int,default:7,notnull," json:"reminder_days_before"` - Title resolvespec_common.SqlString `bun:"title,type:text,notnull," json:"title"` - RelFamilyMemberID *ModelPublicFamilyMembers `bun:"rel:has-one,join:family_member_id=id" json:"relfamilymemberid,omitempty"` // Has one ModelPublicFamilyMembers -} - -// TableName returns the table name for ModelPublicImportantDates -func (m ModelPublicImportantDates) TableName() string { - return "public.important_dates" -} - -// TableNameOnly returns the table name without schema for ModelPublicImportantDates -func (m ModelPublicImportantDates) TableNameOnly() string { - return "important_dates" -} - -// SchemaName returns the schema name for ModelPublicImportantDates -func (m ModelPublicImportantDates) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicImportantDates) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicImportantDates) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicImportantDates) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicImportantDates) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicImportantDates) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicImportantDates) GetPrefix() string { - return "IDM" -} diff --git a/internal/generatedmodels/sql_public_learnings.go b/internal/generatedmodels/sql_public_learnings.go index 5bc176f..736f56f 100644 --- a/internal/generatedmodels/sql_public_learnings.go +++ b/internal/generatedmodels/sql_public_learnings.go @@ -9,32 +9,32 @@ import ( type ModelPublicLearnings struct { bun.BaseModel `bun:"table:public.learnings,alias:learnings"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - ActionRequired bool `bun:"action_required,type:boolean,default:false,notnull," json:"action_required"` - Area resolvespec_common.SqlString `bun:"area,type:text,default:'other',notnull," json:"area"` - Category resolvespec_common.SqlString `bun:"category,type:text,default:'insight',notnull," json:"category"` - Confidence resolvespec_common.SqlString `bun:"confidence,type:text,default:'hypothesis',notnull," json:"confidence"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Details resolvespec_common.SqlString `bun:"details,type:text,default:'',notnull," json:"details"` - DuplicateOfLearningID resolvespec_common.SqlUUID `bun:"duplicate_of_learning_id,type:uuid,nullzero," json:"duplicate_of_learning_id"` - Priority resolvespec_common.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` - ProjectID resolvespec_common.SqlUUID `bun:"project_id,type:uuid,nullzero," json:"project_id"` - RelatedSkillID resolvespec_common.SqlUUID `bun:"related_skill_id,type:uuid,nullzero," json:"related_skill_id"` - RelatedThoughtID resolvespec_common.SqlUUID `bun:"related_thought_id,type:uuid,nullzero," json:"related_thought_id"` - ReviewedAt resolvespec_common.SqlTimeStamp `bun:"reviewed_at,type:timestamptz,nullzero," json:"reviewed_at"` - ReviewedBy resolvespec_common.SqlString `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"` - SourceRef resolvespec_common.SqlString `bun:"source_ref,type:text,nullzero," json:"source_ref"` - SourceType resolvespec_common.SqlString `bun:"source_type,type:text,nullzero," json:"source_type"` - Status resolvespec_common.SqlString `bun:"status,type:text,default:'pending',notnull," json:"status"` - Summary resolvespec_common.SqlString `bun:"summary,type:text,notnull," json:"summary"` - SupersedesLearningID resolvespec_common.SqlUUID `bun:"supersedes_learning_id,type:uuid,nullzero," json:"supersedes_learning_id"` - Tags resolvespec_common.SqlStringArray `bun:"tags,type:text,default:'{}',notnull," json:"tags"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelDuplicateOfLearningID *ModelPublicLearnings `bun:"rel:has-one,join:duplicate_of_learning_id=id" json:"relduplicateoflearningid,omitempty"` // Has one ModelPublicLearnings - RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=guid" json:"relprojectid,omitempty"` // Has one ModelPublicProjects - RelRelatedSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:related_skill_id=id" json:"relrelatedskillid,omitempty"` // Has one ModelPublicAgentSkills - RelRelatedThoughtID *ModelPublicThoughts `bun:"rel:has-one,join:related_thought_id=guid" json:"relrelatedthoughtid,omitempty"` // Has one ModelPublicThoughts - RelSupersedesLearningID *ModelPublicLearnings `bun:"rel:has-one,join:supersedes_learning_id=id" json:"relsupersedeslearningid,omitempty"` // Has one ModelPublicLearnings + ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` + ActionRequired bool `bun:"action_required,type:boolean,default:false,notnull," json:"action_required"` + Area resolvespec_common.SqlString `bun:"area,type:text,default:'other',notnull," json:"area"` + Category resolvespec_common.SqlString `bun:"category,type:text,default:'insight',notnull," json:"category"` + Confidence resolvespec_common.SqlString `bun:"confidence,type:text,default:'hypothesis',notnull," json:"confidence"` + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Details resolvespec_common.SqlString `bun:"details,type:text,default:'',notnull," json:"details"` + DuplicateOfLearningID resolvespec_common.SqlUUID `bun:"duplicate_of_learning_id,type:uuid,nullzero," json:"duplicate_of_learning_id"` + Priority resolvespec_common.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` + ProjectID resolvespec_common.SqlUUID `bun:"project_id,type:uuid,nullzero," json:"project_id"` + RelatedSkillID resolvespec_common.SqlUUID `bun:"related_skill_id,type:uuid,nullzero," json:"related_skill_id"` + RelatedThoughtID resolvespec_common.SqlUUID `bun:"related_thought_id,type:uuid,nullzero," json:"related_thought_id"` + ReviewedAt resolvespec_common.SqlTimeStamp `bun:"reviewed_at,type:timestamptz,nullzero," json:"reviewed_at"` + ReviewedBy resolvespec_common.SqlString `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"` + SourceRef resolvespec_common.SqlString `bun:"source_ref,type:text,nullzero," json:"source_ref"` + SourceType resolvespec_common.SqlString `bun:"source_type,type:text,nullzero," json:"source_type"` + Status resolvespec_common.SqlString `bun:"status,type:text,default:'pending',notnull," json:"status"` + Summary resolvespec_common.SqlString `bun:"summary,type:text,notnull," json:"summary"` + SupersedesLearningID resolvespec_common.SqlUUID `bun:"supersedes_learning_id,type:uuid,nullzero," json:"supersedes_learning_id"` + Tags resolvespec_common.SqlString `bun:"tags,type:text,nullzero," json:"tags"` + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelDuplicateOfLearningID *ModelPublicLearnings `bun:"rel:has-one,join:duplicate_of_learning_id=id" json:"relduplicateoflearningid,omitempty"` // Has one ModelPublicLearnings + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=guid" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + RelRelatedSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:related_skill_id=id" json:"relrelatedskillid,omitempty"` // Has one ModelPublicAgentSkills + RelRelatedThoughtID *ModelPublicThoughts `bun:"rel:has-one,join:related_thought_id=guid" json:"relrelatedthoughtid,omitempty"` // Has one ModelPublicThoughts + RelSupersedesLearningID *ModelPublicLearnings `bun:"rel:has-one,join:supersedes_learning_id=id" json:"relsupersedeslearningid,omitempty"` // Has one ModelPublicLearnings } // TableName returns the table name for ModelPublicLearnings diff --git a/internal/generatedmodels/sql_public_maintenance_logs.go b/internal/generatedmodels/sql_public_maintenance_logs.go deleted file mode 100644 index 05de18d..0000000 --- a/internal/generatedmodels/sql_public_maintenance_logs.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicMaintenanceLogs struct { - bun.BaseModel `bun:"table:public.maintenance_logs,alias:maintenance_logs"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - CompletedAt resolvespec_common.SqlTimeStamp `bun:"completed_at,type:timestamptz,default:now(),notnull," json:"completed_at"` - Cost resolvespec_common.SqlFloat64 `bun:"cost,type:decimal(10,2),nullzero," json:"cost"` - NextAction resolvespec_common.SqlString `bun:"next_action,type:text,nullzero," json:"next_action"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - PerformedBy resolvespec_common.SqlString `bun:"performed_by,type:text,nullzero," json:"performed_by"` - TaskID resolvespec_common.SqlUUID `bun:"task_id,type:uuid,notnull," json:"task_id"` - RelTaskID *ModelPublicMaintenanceTasks `bun:"rel:has-one,join:task_id=id" json:"reltaskid,omitempty"` // Has one ModelPublicMaintenanceTasks -} - -// TableName returns the table name for ModelPublicMaintenanceLogs -func (m ModelPublicMaintenanceLogs) TableName() string { - return "public.maintenance_logs" -} - -// TableNameOnly returns the table name without schema for ModelPublicMaintenanceLogs -func (m ModelPublicMaintenanceLogs) TableNameOnly() string { - return "maintenance_logs" -} - -// SchemaName returns the schema name for ModelPublicMaintenanceLogs -func (m ModelPublicMaintenanceLogs) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicMaintenanceLogs) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicMaintenanceLogs) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicMaintenanceLogs) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicMaintenanceLogs) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicMaintenanceLogs) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicMaintenanceLogs) GetPrefix() string { - return "MLA" -} diff --git a/internal/generatedmodels/sql_public_maintenance_tasks.go b/internal/generatedmodels/sql_public_maintenance_tasks.go deleted file mode 100644 index d7717a1..0000000 --- a/internal/generatedmodels/sql_public_maintenance_tasks.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicMaintenanceTasks struct { - bun.BaseModel `bun:"table:public.maintenance_tasks,alias:maintenance_tasks"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - Category resolvespec_common.SqlString `bun:"category,type:text,nullzero," json:"category"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - FrequencyDays resolvespec_common.SqlInt32 `bun:"frequency_days,type:int,nullzero," json:"frequency_days"` - LastCompleted resolvespec_common.SqlTimeStamp `bun:"last_completed,type:timestamptz,nullzero," json:"last_completed"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - NextDue resolvespec_common.SqlTimeStamp `bun:"next_due,type:timestamptz,nullzero," json:"next_due"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - Priority resolvespec_common.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelTaskIDPublicMaintenanceLogs []*ModelPublicMaintenanceLogs `bun:"rel:has-many,join:id=task_id" json:"reltaskidpublicmaintenancelogs,omitempty"` // Has many ModelPublicMaintenanceLogs -} - -// TableName returns the table name for ModelPublicMaintenanceTasks -func (m ModelPublicMaintenanceTasks) TableName() string { - return "public.maintenance_tasks" -} - -// TableNameOnly returns the table name without schema for ModelPublicMaintenanceTasks -func (m ModelPublicMaintenanceTasks) TableNameOnly() string { - return "maintenance_tasks" -} - -// SchemaName returns the schema name for ModelPublicMaintenanceTasks -func (m ModelPublicMaintenanceTasks) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicMaintenanceTasks) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicMaintenanceTasks) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicMaintenanceTasks) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicMaintenanceTasks) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicMaintenanceTasks) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicMaintenanceTasks) GetPrefix() string { - return "MTA" -} diff --git a/internal/generatedmodels/sql_public_meal_plans.go b/internal/generatedmodels/sql_public_meal_plans.go deleted file mode 100644 index b55ee68..0000000 --- a/internal/generatedmodels/sql_public_meal_plans.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicMealPlans struct { - bun.BaseModel `bun:"table:public.meal_plans,alias:meal_plans"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - CustomMeal resolvespec_common.SqlString `bun:"custom_meal,type:text,nullzero," json:"custom_meal"` - DayOfWeek resolvespec_common.SqlString `bun:"day_of_week,type:text,notnull," json:"day_of_week"` - MealType resolvespec_common.SqlString `bun:"meal_type,type:text,notnull," json:"meal_type"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - RecipeID resolvespec_common.SqlUUID `bun:"recipe_id,type:uuid,nullzero," json:"recipe_id"` - Servings resolvespec_common.SqlInt32 `bun:"servings,type:int,nullzero," json:"servings"` - WeekStart resolvespec_common.SqlDate `bun:"week_start,type:date,notnull," json:"week_start"` - RelRecipeID *ModelPublicRecipes `bun:"rel:has-one,join:recipe_id=id" json:"relrecipeid,omitempty"` // Has one ModelPublicRecipes -} - -// TableName returns the table name for ModelPublicMealPlans -func (m ModelPublicMealPlans) TableName() string { - return "public.meal_plans" -} - -// TableNameOnly returns the table name without schema for ModelPublicMealPlans -func (m ModelPublicMealPlans) TableNameOnly() string { - return "meal_plans" -} - -// SchemaName returns the schema name for ModelPublicMealPlans -func (m ModelPublicMealPlans) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicMealPlans) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicMealPlans) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicMealPlans) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicMealPlans) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicMealPlans) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicMealPlans) GetPrefix() string { - return "MPE" -} diff --git a/internal/generatedmodels/sql_public_opportunities.go b/internal/generatedmodels/sql_public_opportunities.go deleted file mode 100644 index 16e0da7..0000000 --- a/internal/generatedmodels/sql_public_opportunities.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicOpportunities struct { - bun.BaseModel `bun:"table:public.opportunities,alias:opportunities"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - ContactID resolvespec_common.SqlUUID `bun:"contact_id,type:uuid,nullzero," json:"contact_id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Description resolvespec_common.SqlString `bun:"description,type:text,nullzero," json:"description"` - ExpectedCloseDate resolvespec_common.SqlDate `bun:"expected_close_date,type:date,nullzero," json:"expected_close_date"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - Stage resolvespec_common.SqlString `bun:"stage,type:text,default:'identified',notnull," json:"stage"` - Title resolvespec_common.SqlString `bun:"title,type:text,notnull," json:"title"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - Value resolvespec_common.SqlFloat64 `bun:"value,type:decimal(12,2),nullzero," json:"value"` - RelContactID *ModelPublicProfessionalContacts `bun:"rel:has-one,join:contact_id=id" json:"relcontactid,omitempty"` // Has one ModelPublicProfessionalContacts -} - -// TableName returns the table name for ModelPublicOpportunities -func (m ModelPublicOpportunities) TableName() string { - return "public.opportunities" -} - -// TableNameOnly returns the table name without schema for ModelPublicOpportunities -func (m ModelPublicOpportunities) TableNameOnly() string { - return "opportunities" -} - -// SchemaName returns the schema name for ModelPublicOpportunities -func (m ModelPublicOpportunities) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicOpportunities) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicOpportunities) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicOpportunities) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicOpportunities) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicOpportunities) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicOpportunities) GetPrefix() string { - return "OPP" -} diff --git a/internal/generatedmodels/sql_public_plans.go b/internal/generatedmodels/sql_public_plans.go index 08fe517..ecae26b 100644 --- a/internal/generatedmodels/sql_public_plans.go +++ b/internal/generatedmodels/sql_public_plans.go @@ -9,29 +9,29 @@ import ( type ModelPublicPlans struct { bun.BaseModel `bun:"table:public.plans,alias:plans"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - CompletedAt resolvespec_common.SqlTimeStamp `bun:"completed_at,type:timestamptz,nullzero," json:"completed_at"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Description resolvespec_common.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` - DueDate resolvespec_common.SqlTimeStamp `bun:"due_date,type:timestamptz,nullzero," json:"due_date"` - LastReviewedAt resolvespec_common.SqlTimeStamp `bun:"last_reviewed_at,type:timestamptz,nullzero," json:"last_reviewed_at"` - Owner resolvespec_common.SqlString `bun:"owner,type:text,nullzero," json:"owner"` - Priority resolvespec_common.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` // low, medium, high, critical - ProjectID resolvespec_common.SqlUUID `bun:"project_id,type:uuid,nullzero," json:"project_id"` - ReviewedBy resolvespec_common.SqlString `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"` - Status resolvespec_common.SqlString `bun:"status,type:text,default:'draft',notnull," json:"status"` // draft, active, blocked, completed, cancelled, superseded - SupersedesPlanID resolvespec_common.SqlUUID `bun:"supersedes_plan_id,type:uuid,nullzero," json:"supersedes_plan_id"` - Tags resolvespec_common.SqlStringArray `bun:"tags,type:text,default:'{}',notnull," json:"tags"` - Title resolvespec_common.SqlString `bun:"title,type:text,notnull," json:"title"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=guid" json:"relprojectid,omitempty"` // Has one ModelPublicProjects - RelSupersedesPlanID *ModelPublicPlans `bun:"rel:has-one,join:supersedes_plan_id=id" json:"relsupersedesplanid,omitempty"` // Has one ModelPublicPlans - RelDependsOnPlanIDPublicPlanDependencies []*ModelPublicPlanDependencies `bun:"rel:has-many,join:id=depends_on_plan_id" json:"reldependsonplanidpublicplandependencies,omitempty"` // Has many ModelPublicPlanDependencies - RelPlanIDPublicPlanDependencies []*ModelPublicPlanDependencies `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplandependencies,omitempty"` // Has many ModelPublicPlanDependencies - RelPlanAIDPublicPlanRelatedPlans []*ModelPublicPlanRelatedPlans `bun:"rel:has-many,join:id=plan_a_id" json:"relplanaidpublicplanrelatedplans,omitempty"` // Has many ModelPublicPlanRelatedPlans - RelPlanBIDPublicPlanRelatedPlans []*ModelPublicPlanRelatedPlans `bun:"rel:has-many,join:id=plan_b_id" json:"relplanbidpublicplanrelatedplans,omitempty"` // Has many ModelPublicPlanRelatedPlans - RelPlanIDPublicPlanSkills []*ModelPublicPlanSkills `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplanskills,omitempty"` // Has many ModelPublicPlanSkills - RelPlanIDPublicPlanGuardrails []*ModelPublicPlanGuardrails `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplanguardrails,omitempty"` // Has many ModelPublicPlanGuardrails + ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` + CompletedAt resolvespec_common.SqlTimeStamp `bun:"completed_at,type:timestamptz,nullzero," json:"completed_at"` + CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description resolvespec_common.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + DueDate resolvespec_common.SqlTimeStamp `bun:"due_date,type:timestamptz,nullzero," json:"due_date"` + LastReviewedAt resolvespec_common.SqlTimeStamp `bun:"last_reviewed_at,type:timestamptz,nullzero," json:"last_reviewed_at"` + Owner resolvespec_common.SqlString `bun:"owner,type:text,nullzero," json:"owner"` + Priority resolvespec_common.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` // low, medium, high, critical + ProjectID resolvespec_common.SqlUUID `bun:"project_id,type:uuid,nullzero," json:"project_id"` + ReviewedBy resolvespec_common.SqlString `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"` + Status resolvespec_common.SqlString `bun:"status,type:text,default:'draft',notnull," json:"status"` // draft, active, blocked, completed, cancelled, superseded + SupersedesPlanID resolvespec_common.SqlUUID `bun:"supersedes_plan_id,type:uuid,nullzero," json:"supersedes_plan_id"` + Tags resolvespec_common.SqlString `bun:"tags,type:text,nullzero," json:"tags"` + Title resolvespec_common.SqlString `bun:"title,type:text,notnull," json:"title"` + UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=guid" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + RelSupersedesPlanID *ModelPublicPlans `bun:"rel:has-one,join:supersedes_plan_id=id" json:"relsupersedesplanid,omitempty"` // Has one ModelPublicPlans + RelDependsOnPlanIDPublicPlanDependencies []*ModelPublicPlanDependencies `bun:"rel:has-many,join:id=depends_on_plan_id" json:"reldependsonplanidpublicplandependencies,omitempty"` // Has many ModelPublicPlanDependencies + RelPlanIDPublicPlanDependencies []*ModelPublicPlanDependencies `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplandependencies,omitempty"` // Has many ModelPublicPlanDependencies + RelPlanAIDPublicPlanRelatedPlans []*ModelPublicPlanRelatedPlans `bun:"rel:has-many,join:id=plan_a_id" json:"relplanaidpublicplanrelatedplans,omitempty"` // Has many ModelPublicPlanRelatedPlans + RelPlanBIDPublicPlanRelatedPlans []*ModelPublicPlanRelatedPlans `bun:"rel:has-many,join:id=plan_b_id" json:"relplanbidpublicplanrelatedplans,omitempty"` // Has many ModelPublicPlanRelatedPlans + RelPlanIDPublicPlanSkills []*ModelPublicPlanSkills `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplanskills,omitempty"` // Has many ModelPublicPlanSkills + RelPlanIDPublicPlanGuardrails []*ModelPublicPlanGuardrails `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplanguardrails,omitempty"` // Has many ModelPublicPlanGuardrails } // TableName returns the table name for ModelPublicPlans diff --git a/internal/generatedmodels/sql_public_professional_contacts.go b/internal/generatedmodels/sql_public_professional_contacts.go deleted file mode 100644 index 192ed40..0000000 --- a/internal/generatedmodels/sql_public_professional_contacts.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicProfessionalContacts struct { - bun.BaseModel `bun:"table:public.professional_contacts,alias:professional_contacts"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - Company resolvespec_common.SqlString `bun:"company,type:text,nullzero," json:"company"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Email resolvespec_common.SqlString `bun:"email,type:text,nullzero," json:"email"` - FollowUpDate resolvespec_common.SqlDate `bun:"follow_up_date,type:date,nullzero," json:"follow_up_date"` - HowWeMet resolvespec_common.SqlString `bun:"how_we_met,type:text,nullzero," json:"how_we_met"` - LastContacted resolvespec_common.SqlTimeStamp `bun:"last_contacted,type:timestamptz,nullzero," json:"last_contacted"` - LinkedinURL resolvespec_common.SqlString `bun:"linkedin_url,type:text,nullzero," json:"linkedin_url"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - Phone resolvespec_common.SqlString `bun:"phone,type:text,nullzero," json:"phone"` - Tags resolvespec_common.SqlStringArray `bun:"tags,type:text,default:'{}',notnull," json:"tags"` - Title resolvespec_common.SqlString `bun:"title,type:text,nullzero," json:"title"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelContactIDPublicContactInteractions []*ModelPublicContactInteractions `bun:"rel:has-many,join:id=contact_id" json:"relcontactidpubliccontactinteractions,omitempty"` // Has many ModelPublicContactInteractions - RelContactIDPublicOpportunities []*ModelPublicOpportunities `bun:"rel:has-many,join:id=contact_id" json:"relcontactidpublicopportunities,omitempty"` // Has many ModelPublicOpportunities -} - -// TableName returns the table name for ModelPublicProfessionalContacts -func (m ModelPublicProfessionalContacts) TableName() string { - return "public.professional_contacts" -} - -// TableNameOnly returns the table name without schema for ModelPublicProfessionalContacts -func (m ModelPublicProfessionalContacts) TableNameOnly() string { - return "professional_contacts" -} - -// SchemaName returns the schema name for ModelPublicProfessionalContacts -func (m ModelPublicProfessionalContacts) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicProfessionalContacts) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicProfessionalContacts) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicProfessionalContacts) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicProfessionalContacts) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicProfessionalContacts) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicProfessionalContacts) GetPrefix() string { - return "PCR" -} diff --git a/internal/generatedmodels/sql_public_recipes.go b/internal/generatedmodels/sql_public_recipes.go deleted file mode 100644 index b30f5ec..0000000 --- a/internal/generatedmodels/sql_public_recipes.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicRecipes struct { - bun.BaseModel `bun:"table:public.recipes,alias:recipes"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - CookTimeMinutes resolvespec_common.SqlInt32 `bun:"cook_time_minutes,type:int,nullzero," json:"cook_time_minutes"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Cuisine resolvespec_common.SqlString `bun:"cuisine,type:text,nullzero," json:"cuisine"` - Ingredients resolvespec_common.SqlJSONB `bun:"ingredients,type:jsonb,default:'',notnull," json:"ingredients"` - Instructions resolvespec_common.SqlJSONB `bun:"instructions,type:jsonb,default:'',notnull," json:"instructions"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - PrepTimeMinutes resolvespec_common.SqlInt32 `bun:"prep_time_minutes,type:int,nullzero," json:"prep_time_minutes"` - Rating resolvespec_common.SqlInt32 `bun:"rating,type:int,nullzero," json:"rating"` - Servings resolvespec_common.SqlInt32 `bun:"servings,type:int,nullzero," json:"servings"` - Tags resolvespec_common.SqlStringArray `bun:"tags,type:text,default:'{}',notnull," json:"tags"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelRecipeIDPublicMealPlans []*ModelPublicMealPlans `bun:"rel:has-many,join:id=recipe_id" json:"relrecipeidpublicmealplans,omitempty"` // Has many ModelPublicMealPlans -} - -// TableName returns the table name for ModelPublicRecipes -func (m ModelPublicRecipes) TableName() string { - return "public.recipes" -} - -// TableNameOnly returns the table name without schema for ModelPublicRecipes -func (m ModelPublicRecipes) TableNameOnly() string { - return "recipes" -} - -// SchemaName returns the schema name for ModelPublicRecipes -func (m ModelPublicRecipes) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicRecipes) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicRecipes) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicRecipes) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicRecipes) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicRecipes) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicRecipes) GetPrefix() string { - return "REC" -} diff --git a/internal/generatedmodels/sql_public_shopping_lists.go b/internal/generatedmodels/sql_public_shopping_lists.go deleted file mode 100644 index 43048b6..0000000 --- a/internal/generatedmodels/sql_public_shopping_lists.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by relspecgo. DO NOT EDIT. -package generatedmodels - -import ( - "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" - "github.com/uptrace/bun" -) - -type ModelPublicShoppingLists struct { - bun.BaseModel `bun:"table:public.shopping_lists,alias:shopping_lists"` - ID resolvespec_common.SqlUUID `bun:"id,type:uuid,pk,default:gen_random_uuid()," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Items resolvespec_common.SqlJSONB `bun:"items,type:jsonb,default:'',notnull," json:"items"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,nullzero," json:"notes"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - WeekStart resolvespec_common.SqlDate `bun:"week_start,type:date,notnull," json:"week_start"` -} - -// TableName returns the table name for ModelPublicShoppingLists -func (m ModelPublicShoppingLists) TableName() string { - return "public.shopping_lists" -} - -// TableNameOnly returns the table name without schema for ModelPublicShoppingLists -func (m ModelPublicShoppingLists) TableNameOnly() string { - return "shopping_lists" -} - -// SchemaName returns the schema name for ModelPublicShoppingLists -func (m ModelPublicShoppingLists) SchemaName() string { - return "public" -} - -// GetID returns the primary key value -func (m ModelPublicShoppingLists) GetID() int64 { - return m.ID.Int64() -} - -// GetIDStr returns the primary key as a string -func (m ModelPublicShoppingLists) GetIDStr() string { - return fmt.Sprintf("%v", m.ID) -} - -// SetID sets the primary key value -func (m ModelPublicShoppingLists) SetID(newid int64) { - m.UpdateID(newid) -} - -// UpdateID updates the primary key value -func (m *ModelPublicShoppingLists) UpdateID(newid int64) { - m.ID.FromString(fmt.Sprintf("%d", newid)) -} - -// GetIDName returns the name of the primary key column -func (m ModelPublicShoppingLists) GetIDName() string { - return "id" -} - -// GetPrefix returns the table prefix -func (m ModelPublicShoppingLists) GetPrefix() string { - return "SLH" -} diff --git a/internal/generatedmodels/sql_public_thoughts.go b/internal/generatedmodels/sql_public_thoughts.go index dfde207..3f1dec3 100644 --- a/internal/generatedmodels/sql_public_thoughts.go +++ b/internal/generatedmodels/sql_public_thoughts.go @@ -14,7 +14,7 @@ type ModelPublicThoughts struct { Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),nullzero," json:"created_at"` GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - Metadata resolvespec_common.SqlJSONB `bun:"metadata,type:jsonb,default:{}::jsonb,nullzero," json:"metadata"` + Metadata resolvespec_common.SqlJSONB `bun:"metadata,type:jsonb,default:'{}::jsonb',nullzero," json:"metadata"` ProjectID resolvespec_common.SqlUUID `bun:"project_id,type:uuid,nullzero," json:"project_id"` UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),nullzero," json:"updated_at"` RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=guid" json:"relprojectid,omitempty"` // Has one ModelPublicProjects diff --git a/internal/mcpserver/server.go b/internal/mcpserver/server.go index 0c81cd9..80cd551 100644 --- a/internal/mcpserver/server.go +++ b/internal/mcpserver/server.go @@ -36,12 +36,12 @@ type ToolSet struct { Backfill *tools.BackfillTool Reparse *tools.ReparseMetadataTool RetryMetadata *tools.RetryEnrichmentTool - Maintenance *tools.MaintenanceTool - Skills *tools.SkillsTool - ChatHistory *tools.ChatHistoryTool - Describe *tools.DescribeTool - Learnings *tools.LearningsTool - Plans *tools.PlansTool + //Maintenance *tools.MaintenanceTool + Skills *tools.SkillsTool + ChatHistory *tools.ChatHistoryTool + Describe *tools.DescribeTool + Learnings *tools.LearningsTool + Plans *tools.PlansTool } // Handlers groups the HTTP handlers produced for an MCP server instance. @@ -422,30 +422,30 @@ func registerMaintenanceTools(server *mcp.Server, logger *slog.Logger, toolSet T }, toolSet.RetryMetadata.Handle); err != nil { return err } - if err := addTool(server, logger, &mcp.Tool{ - Name: "add_maintenance_task", - Description: "Create a recurring or one-time home maintenance task.", - }, toolSet.Maintenance.AddTask); err != nil { - return err - } - if err := addTool(server, logger, &mcp.Tool{ - Name: "log_maintenance", - Description: "Log completed maintenance; updates next due date.", - }, toolSet.Maintenance.LogWork); err != nil { - return err - } - if err := addTool(server, logger, &mcp.Tool{ - Name: "get_upcoming_maintenance", - Description: "List maintenance tasks due within the next N days.", - }, toolSet.Maintenance.GetUpcoming); err != nil { - return err - } - if err := addTool(server, logger, &mcp.Tool{ - Name: "search_maintenance_history", - Description: "Search the maintenance log by task name, category, or date range.", - }, toolSet.Maintenance.SearchHistory); err != nil { - return err - } + // if err := addTool(server, logger, &mcp.Tool{ + // Name: "add_maintenance_task", + // Description: "Create a recurring or one-time home maintenance task.", + // }, toolSet.Maintenance.AddTask); err != nil { + // return err + // } + // if err := addTool(server, logger, &mcp.Tool{ + // Name: "log_maintenance", + // Description: "Log completed maintenance; updates next due date.", + // }, toolSet.Maintenance.LogWork); err != nil { + // return err + // } + // if err := addTool(server, logger, &mcp.Tool{ + // Name: "get_upcoming_maintenance", + // Description: "List maintenance tasks due within the next N days.", + // }, toolSet.Maintenance.GetUpcoming); err != nil { + // return err + // } + // if err := addTool(server, logger, &mcp.Tool{ + // Name: "search_maintenance_history", + // Description: "Search the maintenance log by task name, category, or date range.", + // }, toolSet.Maintenance.SearchHistory); err != nil { + // return err + // } return nil } diff --git a/internal/mcpserver/streamable_integration_test.go b/internal/mcpserver/streamable_integration_test.go index fc3fdca..629ed13 100644 --- a/internal/mcpserver/streamable_integration_test.go +++ b/internal/mcpserver/streamable_integration_test.go @@ -207,7 +207,7 @@ func streamableTestToolSet() ToolSet { Backfill: new(tools.BackfillTool), Reparse: new(tools.ReparseMetadataTool), RetryMetadata: new(tools.RetryEnrichmentTool), - Maintenance: new(tools.MaintenanceTool), - Skills: new(tools.SkillsTool), + //Maintenance: new(tools.MaintenanceTool), + Skills: new(tools.SkillsTool), } } diff --git a/internal/store/calendar.go b/internal/store/calendar.go index 3a5315f..972e77c 100644 --- a/internal/store/calendar.go +++ b/internal/store/calendar.go @@ -1,206 +1,206 @@ package store -import ( - "context" - "fmt" - "strings" - "time" +// import ( +// "context" +// "fmt" +// "strings" +// "time" - "github.com/google/uuid" +// "github.com/google/uuid" - "git.warky.dev/wdevs/amcs/internal/generatedmodels" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/generatedmodels" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -func (db *DB) AddFamilyMember(ctx context.Context, m ext.FamilyMember) (ext.FamilyMember, error) { - row := db.pool.QueryRow(ctx, ` - insert into family_members (name, relationship, birth_date, notes) - values ($1, $2, $3, $4) - returning id, created_at - `, m.Name, nullStr(m.Relationship), m.BirthDate, nullStr(m.Notes)) +// func (db *DB) AddFamilyMember(ctx context.Context, m ext.FamilyMember) (ext.FamilyMember, error) { +// row := db.pool.QueryRow(ctx, ` +// insert into family_members (name, relationship, birth_date, notes) +// values ($1, $2, $3, $4) +// returning id, created_at +// `, m.Name, nullStr(m.Relationship), m.BirthDate, nullStr(m.Notes)) - created := m - var model generatedmodels.ModelPublicFamilyMembers - if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { - return ext.FamilyMember{}, fmt.Errorf("insert family member: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - return created, nil -} +// created := m +// var model generatedmodels.ModelPublicFamilyMembers +// if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { +// return ext.FamilyMember{}, fmt.Errorf("insert family member: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// return created, nil +// } -func (db *DB) ListFamilyMembers(ctx context.Context) ([]ext.FamilyMember, error) { - rows, err := db.pool.Query(ctx, `select id, name, relationship, birth_date, notes, created_at from family_members order by name`) - if err != nil { - return nil, fmt.Errorf("list family members: %w", err) - } - defer rows.Close() +// func (db *DB) ListFamilyMembers(ctx context.Context) ([]ext.FamilyMember, error) { +// rows, err := db.pool.Query(ctx, `select id, name, relationship, birth_date, notes, created_at from family_members order by name`) +// if err != nil { +// return nil, fmt.Errorf("list family members: %w", err) +// } +// defer rows.Close() - var members []ext.FamilyMember - for rows.Next() { - var model generatedmodels.ModelPublicFamilyMembers - if err := rows.Scan(&model.ID, &model.Name, &model.Relationship, &model.BirthDate, &model.Notes, &model.CreatedAt); err != nil { - return nil, fmt.Errorf("scan family member: %w", err) - } - members = append(members, familyMemberFromModel(model)) - } - return members, rows.Err() -} +// var members []ext.FamilyMember +// for rows.Next() { +// var model generatedmodels.ModelPublicFamilyMembers +// if err := rows.Scan(&model.ID, &model.Name, &model.Relationship, &model.BirthDate, &model.Notes, &model.CreatedAt); err != nil { +// return nil, fmt.Errorf("scan family member: %w", err) +// } +// members = append(members, familyMemberFromModel(model)) +// } +// return members, rows.Err() +// } -func (db *DB) AddActivity(ctx context.Context, a ext.Activity) (ext.Activity, error) { - row := db.pool.QueryRow(ctx, ` - insert into activities (family_member_id, title, activity_type, day_of_week, start_time, end_time, start_date, end_date, location, notes) - values ($1, $2, $3, $4, $5::time, $6::time, $7, $8, $9, $10) - returning id, created_at - `, a.FamilyMemberID, a.Title, nullStr(a.ActivityType), nullStr(a.DayOfWeek), - nullStr(a.StartTime), nullStr(a.EndTime), a.StartDate, a.EndDate, - nullStr(a.Location), nullStr(a.Notes)) +// func (db *DB) AddActivity(ctx context.Context, a ext.Activity) (ext.Activity, error) { +// row := db.pool.QueryRow(ctx, ` +// insert into activities (family_member_id, title, activity_type, day_of_week, start_time, end_time, start_date, end_date, location, notes) +// values ($1, $2, $3, $4, $5::time, $6::time, $7, $8, $9, $10) +// returning id, created_at +// `, a.FamilyMemberID, a.Title, nullStr(a.ActivityType), nullStr(a.DayOfWeek), +// nullStr(a.StartTime), nullStr(a.EndTime), a.StartDate, a.EndDate, +// nullStr(a.Location), nullStr(a.Notes)) - created := a - var model generatedmodels.ModelPublicActivities - if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { - return ext.Activity{}, fmt.Errorf("insert activity: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - return created, nil -} +// created := a +// var model generatedmodels.ModelPublicActivities +// if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { +// return ext.Activity{}, fmt.Errorf("insert activity: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// return created, nil +// } -func (db *DB) GetWeekSchedule(ctx context.Context, weekStart time.Time) ([]ext.Activity, error) { - weekEnd := weekStart.AddDate(0, 0, 7) +// func (db *DB) GetWeekSchedule(ctx context.Context, weekStart time.Time) ([]ext.Activity, error) { +// weekEnd := weekStart.AddDate(0, 0, 7) - rows, err := db.pool.Query(ctx, ` - select a.id, a.family_member_id, fm.name, a.title, a.activity_type, - a.day_of_week, a.start_time::text, a.end_time::text, - a.start_date, a.end_date, a.location, a.notes, a.created_at - from activities a - left join family_members fm on fm.id = a.family_member_id - where (a.start_date >= $1 and a.start_date < $2) - or (a.day_of_week is not null and (a.end_date is null or a.end_date >= $1)) - order by a.start_date, a.start_time - `, weekStart, weekEnd) - if err != nil { - return nil, fmt.Errorf("get week schedule: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, ` +// select a.id, a.family_member_id, fm.name, a.title, a.activity_type, +// a.day_of_week, a.start_time::text, a.end_time::text, +// a.start_date, a.end_date, a.location, a.notes, a.created_at +// from activities a +// left join family_members fm on fm.id = a.family_member_id +// where (a.start_date >= $1 and a.start_date < $2) +// or (a.day_of_week is not null and (a.end_date is null or a.end_date >= $1)) +// order by a.start_date, a.start_time +// `, weekStart, weekEnd) +// if err != nil { +// return nil, fmt.Errorf("get week schedule: %w", err) +// } +// defer rows.Close() - return scanActivities(rows) -} +// return scanActivities(rows) +// } -func (db *DB) SearchActivities(ctx context.Context, query, activityType string, memberID *uuid.UUID) ([]ext.Activity, error) { - args := []any{} - conditions := []string{} +// func (db *DB) SearchActivities(ctx context.Context, query, activityType string, memberID *uuid.UUID) ([]ext.Activity, error) { +// args := []any{} +// conditions := []string{} - if q := strings.TrimSpace(query); q != "" { - args = append(args, "%"+q+"%") - conditions = append(conditions, fmt.Sprintf("(a.title ILIKE $%d OR a.notes ILIKE $%d)", len(args), len(args))) - } - if t := strings.TrimSpace(activityType); t != "" { - args = append(args, t) - conditions = append(conditions, fmt.Sprintf("a.activity_type = $%d", len(args))) - } - if memberID != nil { - args = append(args, *memberID) - conditions = append(conditions, fmt.Sprintf("a.family_member_id = $%d", len(args))) - } +// if q := strings.TrimSpace(query); q != "" { +// args = append(args, "%"+q+"%") +// conditions = append(conditions, fmt.Sprintf("(a.title ILIKE $%d OR a.notes ILIKE $%d)", len(args), len(args))) +// } +// if t := strings.TrimSpace(activityType); t != "" { +// args = append(args, t) +// conditions = append(conditions, fmt.Sprintf("a.activity_type = $%d", len(args))) +// } +// if memberID != nil { +// args = append(args, *memberID) +// conditions = append(conditions, fmt.Sprintf("a.family_member_id = $%d", len(args))) +// } - q := ` - select a.id, a.family_member_id, fm.name, a.title, a.activity_type, - a.day_of_week, a.start_time::text, a.end_time::text, - a.start_date, a.end_date, a.location, a.notes, a.created_at - from activities a - left join family_members fm on fm.id = a.family_member_id - ` - if len(conditions) > 0 { - q += " where " + strings.Join(conditions, " and ") - } - q += " order by a.start_date, a.start_time" +// q := ` +// select a.id, a.family_member_id, fm.name, a.title, a.activity_type, +// a.day_of_week, a.start_time::text, a.end_time::text, +// a.start_date, a.end_date, a.location, a.notes, a.created_at +// from activities a +// left join family_members fm on fm.id = a.family_member_id +// ` +// if len(conditions) > 0 { +// q += " where " + strings.Join(conditions, " and ") +// } +// q += " order by a.start_date, a.start_time" - rows, err := db.pool.Query(ctx, q, args...) - if err != nil { - return nil, fmt.Errorf("search activities: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, q, args...) +// if err != nil { +// return nil, fmt.Errorf("search activities: %w", err) +// } +// defer rows.Close() - return scanActivities(rows) -} +// return scanActivities(rows) +// } -func (db *DB) AddImportantDate(ctx context.Context, d ext.ImportantDate) (ext.ImportantDate, error) { - row := db.pool.QueryRow(ctx, ` - insert into important_dates (family_member_id, title, date_value, recurring_yearly, reminder_days_before, notes) - values ($1, $2, $3, $4, $5, $6) - returning id, created_at - `, d.FamilyMemberID, d.Title, d.DateValue, d.RecurringYearly, d.ReminderDaysBefore, nullStr(d.Notes)) +// func (db *DB) AddImportantDate(ctx context.Context, d ext.ImportantDate) (ext.ImportantDate, error) { +// row := db.pool.QueryRow(ctx, ` +// insert into important_dates (family_member_id, title, date_value, recurring_yearly, reminder_days_before, notes) +// values ($1, $2, $3, $4, $5, $6) +// returning id, created_at +// `, d.FamilyMemberID, d.Title, d.DateValue, d.RecurringYearly, d.ReminderDaysBefore, nullStr(d.Notes)) - created := d - var model generatedmodels.ModelPublicImportantDates - if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { - return ext.ImportantDate{}, fmt.Errorf("insert important date: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - return created, nil -} +// created := d +// var model generatedmodels.ModelPublicImportantDates +// if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { +// return ext.ImportantDate{}, fmt.Errorf("insert important date: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// return created, nil +// } -func (db *DB) GetUpcomingDates(ctx context.Context, daysAhead int) ([]ext.ImportantDate, error) { - if daysAhead <= 0 { - daysAhead = 30 - } - now := time.Now() - cutoff := now.AddDate(0, 0, daysAhead) +// func (db *DB) GetUpcomingDates(ctx context.Context, daysAhead int) ([]ext.ImportantDate, error) { +// if daysAhead <= 0 { +// daysAhead = 30 +// } +// now := time.Now() +// cutoff := now.AddDate(0, 0, daysAhead) - // For yearly recurring events, check if this year's occurrence falls in range - rows, err := db.pool.Query(ctx, ` - select d.id, d.family_member_id, fm.name, d.title, d.date_value, - d.recurring_yearly, d.reminder_days_before, d.notes, d.created_at - from important_dates d - left join family_members fm on fm.id = d.family_member_id - where ( - (d.recurring_yearly = false and d.date_value between $1 and $2) - or - (d.recurring_yearly = true and - make_date(extract(year from now())::int, extract(month from d.date_value)::int, extract(day from d.date_value)::int) - between $1 and $2) - ) - order by d.date_value - `, now, cutoff) - if err != nil { - return nil, fmt.Errorf("get upcoming dates: %w", err) - } - defer rows.Close() +// // For yearly recurring events, check if this year's occurrence falls in range +// rows, err := db.pool.Query(ctx, ` +// select d.id, d.family_member_id, fm.name, d.title, d.date_value, +// d.recurring_yearly, d.reminder_days_before, d.notes, d.created_at +// from important_dates d +// left join family_members fm on fm.id = d.family_member_id +// where ( +// (d.recurring_yearly = false and d.date_value between $1 and $2) +// or +// (d.recurring_yearly = true and +// make_date(extract(year from now())::int, extract(month from d.date_value)::int, extract(day from d.date_value)::int) +// between $1 and $2) +// ) +// order by d.date_value +// `, now, cutoff) +// if err != nil { +// return nil, fmt.Errorf("get upcoming dates: %w", err) +// } +// defer rows.Close() - var dates []ext.ImportantDate - for rows.Next() { - var model generatedmodels.ModelPublicImportantDates - var memberName *string - if err := rows.Scan(&model.ID, &model.FamilyMemberID, &memberName, &model.Title, &model.DateValue, - &model.RecurringYearly, &model.ReminderDaysBefore, &model.Notes, &model.CreatedAt); err != nil { - return nil, fmt.Errorf("scan important date: %w", err) - } - dates = append(dates, importantDateFromModel(model, strVal(memberName))) - } - return dates, rows.Err() -} +// var dates []ext.ImportantDate +// for rows.Next() { +// var model generatedmodels.ModelPublicImportantDates +// var memberName *string +// if err := rows.Scan(&model.ID, &model.FamilyMemberID, &memberName, &model.Title, &model.DateValue, +// &model.RecurringYearly, &model.ReminderDaysBefore, &model.Notes, &model.CreatedAt); err != nil { +// return nil, fmt.Errorf("scan important date: %w", err) +// } +// dates = append(dates, importantDateFromModel(model, strVal(memberName))) +// } +// return dates, rows.Err() +// } -func scanActivities(rows interface { - Next() bool - Scan(...any) error - Err() error - Close() -}) ([]ext.Activity, error) { - defer rows.Close() - var activities []ext.Activity - for rows.Next() { - var model generatedmodels.ModelPublicActivities - var memberName *string - if err := rows.Scan( - &model.ID, &model.FamilyMemberID, &memberName, &model.Title, &model.ActivityType, - &model.DayOfWeek, &model.StartTime, &model.EndTime, - &model.StartDate, &model.EndDate, &model.Location, &model.Notes, &model.CreatedAt, - ); err != nil { - return nil, fmt.Errorf("scan activity: %w", err) - } - activities = append(activities, activityFromModel(model, strVal(memberName))) - } - return activities, rows.Err() -} +// func scanActivities(rows interface { +// Next() bool +// Scan(...any) error +// Err() error +// Close() +// }) ([]ext.Activity, error) { +// defer rows.Close() +// var activities []ext.Activity +// for rows.Next() { +// var model generatedmodels.ModelPublicActivities +// var memberName *string +// if err := rows.Scan( +// &model.ID, &model.FamilyMemberID, &memberName, &model.Title, &model.ActivityType, +// &model.DayOfWeek, &model.StartTime, &model.EndTime, +// &model.StartDate, &model.EndDate, &model.Location, &model.Notes, &model.CreatedAt, +// ); err != nil { +// return nil, fmt.Errorf("scan activity: %w", err) +// } +// activities = append(activities, activityFromModel(model, strVal(memberName))) +// } +// return activities, rows.Err() +// } diff --git a/internal/store/crm.go b/internal/store/crm.go index a498ff1..4150777 100644 --- a/internal/store/crm.go +++ b/internal/store/crm.go @@ -1,235 +1,235 @@ package store -import ( - "context" - "fmt" - "strings" - "time" +// import ( +// "context" +// "fmt" +// "strings" +// "time" - "github.com/google/uuid" +// "github.com/google/uuid" - "git.warky.dev/wdevs/amcs/internal/generatedmodels" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/generatedmodels" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -func (db *DB) AddProfessionalContact(ctx context.Context, c ext.ProfessionalContact) (ext.ProfessionalContact, error) { - if c.Tags == nil { - c.Tags = []string{} - } +// func (db *DB) AddProfessionalContact(ctx context.Context, c ext.ProfessionalContact) (ext.ProfessionalContact, error) { +// if c.Tags == nil { +// c.Tags = []string{} +// } - row := db.pool.QueryRow(ctx, ` - insert into professional_contacts (name, company, title, email, phone, linkedin_url, how_we_met, tags, notes, follow_up_date) - values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) - returning id, created_at, updated_at - `, c.Name, nullStr(c.Company), nullStr(c.Title), nullStr(c.Email), nullStr(c.Phone), - nullStr(c.LinkedInURL), nullStr(c.HowWeMet), c.Tags, nullStr(c.Notes), c.FollowUpDate) +// row := db.pool.QueryRow(ctx, ` +// insert into professional_contacts (name, company, title, email, phone, linkedin_url, how_we_met, tags, notes, follow_up_date) +// values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) +// returning id, created_at, updated_at +// `, c.Name, nullStr(c.Company), nullStr(c.Title), nullStr(c.Email), nullStr(c.Phone), +// nullStr(c.LinkedInURL), nullStr(c.HowWeMet), c.Tags, nullStr(c.Notes), c.FollowUpDate) - created := c - var model generatedmodels.ModelPublicProfessionalContacts - if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.ProfessionalContact{}, fmt.Errorf("insert contact: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - created.UpdatedAt = model.UpdatedAt.Time() - return created, nil -} +// created := c +// var model generatedmodels.ModelPublicProfessionalContacts +// if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.ProfessionalContact{}, fmt.Errorf("insert contact: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// created.UpdatedAt = model.UpdatedAt.Time() +// return created, nil +// } -func (db *DB) SearchContacts(ctx context.Context, query string, tags []string) ([]ext.ProfessionalContact, error) { - args := []any{} - conditions := []string{} +// func (db *DB) SearchContacts(ctx context.Context, query string, tags []string) ([]ext.ProfessionalContact, error) { +// args := []any{} +// conditions := []string{} - if q := strings.TrimSpace(query); q != "" { - args = append(args, "%"+q+"%") - idx := len(args) - conditions = append(conditions, fmt.Sprintf( - "(name ILIKE $%[1]d OR company ILIKE $%[1]d OR title ILIKE $%[1]d OR notes ILIKE $%[1]d)", idx)) - } - if len(tags) > 0 { - args = append(args, tags) - conditions = append(conditions, fmt.Sprintf("tags @> $%d", len(args))) - } +// if q := strings.TrimSpace(query); q != "" { +// args = append(args, "%"+q+"%") +// idx := len(args) +// conditions = append(conditions, fmt.Sprintf( +// "(name ILIKE $%[1]d OR company ILIKE $%[1]d OR title ILIKE $%[1]d OR notes ILIKE $%[1]d)", idx)) +// } +// if len(tags) > 0 { +// args = append(args, tags) +// conditions = append(conditions, fmt.Sprintf("tags @> $%d", len(args))) +// } - q := `select id, name, company, title, email, phone, linkedin_url, how_we_met, tags::text[], notes, last_contacted, follow_up_date, created_at, updated_at from professional_contacts` - if len(conditions) > 0 { - q += " where " + strings.Join(conditions, " and ") - } - q += " order by name" +// q := `select id, name, company, title, email, phone, linkedin_url, how_we_met, tags::text[], notes, last_contacted, follow_up_date, created_at, updated_at from professional_contacts` +// if len(conditions) > 0 { +// q += " where " + strings.Join(conditions, " and ") +// } +// q += " order by name" - rows, err := db.pool.Query(ctx, q, args...) - if err != nil { - return nil, fmt.Errorf("search contacts: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, q, args...) +// if err != nil { +// return nil, fmt.Errorf("search contacts: %w", err) +// } +// defer rows.Close() - return scanContacts(rows) -} +// return scanContacts(rows) +// } -func (db *DB) GetContact(ctx context.Context, id uuid.UUID) (ext.ProfessionalContact, error) { - row := db.pool.QueryRow(ctx, ` - select id, name, company, title, email, phone, linkedin_url, how_we_met, tags::text[], notes, last_contacted, follow_up_date, created_at, updated_at - from professional_contacts where id = $1 - `, id) +// func (db *DB) GetContact(ctx context.Context, id uuid.UUID) (ext.ProfessionalContact, error) { +// row := db.pool.QueryRow(ctx, ` +// select id, name, company, title, email, phone, linkedin_url, how_we_met, tags::text[], notes, last_contacted, follow_up_date, created_at, updated_at +// from professional_contacts where id = $1 +// `, id) - var model generatedmodels.ModelPublicProfessionalContacts - var tags []string - if err := row.Scan(&model.ID, &model.Name, &model.Company, &model.Title, &model.Email, &model.Phone, - &model.LinkedinURL, &model.HowWeMet, &tags, &model.Notes, &model.LastContacted, &model.FollowUpDate, - &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.ProfessionalContact{}, fmt.Errorf("get contact: %w", err) - } - c := professionalContactFromModel(model, tags) - return c, nil -} +// var model generatedmodels.ModelPublicProfessionalContacts +// var tags []string +// if err := row.Scan(&model.ID, &model.Name, &model.Company, &model.Title, &model.Email, &model.Phone, +// &model.LinkedinURL, &model.HowWeMet, &tags, &model.Notes, &model.LastContacted, &model.FollowUpDate, +// &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.ProfessionalContact{}, fmt.Errorf("get contact: %w", err) +// } +// c := professionalContactFromModel(model, tags) +// return c, nil +// } -func (db *DB) LogInteraction(ctx context.Context, interaction ext.ContactInteraction) (ext.ContactInteraction, error) { - occurredAt := interaction.OccurredAt - if occurredAt.IsZero() { - occurredAt = time.Now() - } +// func (db *DB) LogInteraction(ctx context.Context, interaction ext.ContactInteraction) (ext.ContactInteraction, error) { +// occurredAt := interaction.OccurredAt +// if occurredAt.IsZero() { +// occurredAt = time.Now() +// } - row := db.pool.QueryRow(ctx, ` - insert into contact_interactions (contact_id, interaction_type, occurred_at, summary, follow_up_needed, follow_up_notes) - values ($1, $2, $3, $4, $5, $6) - returning id, created_at - `, interaction.ContactID, interaction.InteractionType, occurredAt, interaction.Summary, - interaction.FollowUpNeeded, nullStr(interaction.FollowUpNotes)) +// row := db.pool.QueryRow(ctx, ` +// insert into contact_interactions (contact_id, interaction_type, occurred_at, summary, follow_up_needed, follow_up_notes) +// values ($1, $2, $3, $4, $5, $6) +// returning id, created_at +// `, interaction.ContactID, interaction.InteractionType, occurredAt, interaction.Summary, +// interaction.FollowUpNeeded, nullStr(interaction.FollowUpNotes)) - created := interaction - created.OccurredAt = occurredAt - var model generatedmodels.ModelPublicContactInteractions - if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { - return ext.ContactInteraction{}, fmt.Errorf("insert interaction: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - return created, nil -} +// created := interaction +// created.OccurredAt = occurredAt +// var model generatedmodels.ModelPublicContactInteractions +// if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { +// return ext.ContactInteraction{}, fmt.Errorf("insert interaction: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// return created, nil +// } -func (db *DB) GetContactHistory(ctx context.Context, contactID uuid.UUID) (ext.ContactHistory, error) { - contact, err := db.GetContact(ctx, contactID) - if err != nil { - return ext.ContactHistory{}, err - } +// func (db *DB) GetContactHistory(ctx context.Context, contactID uuid.UUID) (ext.ContactHistory, error) { +// contact, err := db.GetContact(ctx, contactID) +// if err != nil { +// return ext.ContactHistory{}, err +// } - rows, err := db.pool.Query(ctx, ` - select id, contact_id, interaction_type, occurred_at, summary, follow_up_needed, follow_up_notes, created_at - from contact_interactions where contact_id = $1 order by occurred_at desc - `, contactID) - if err != nil { - return ext.ContactHistory{}, fmt.Errorf("get interactions: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, ` +// select id, contact_id, interaction_type, occurred_at, summary, follow_up_needed, follow_up_notes, created_at +// from contact_interactions where contact_id = $1 order by occurred_at desc +// `, contactID) +// if err != nil { +// return ext.ContactHistory{}, fmt.Errorf("get interactions: %w", err) +// } +// defer rows.Close() - var interactions []ext.ContactInteraction - for rows.Next() { - var model generatedmodels.ModelPublicContactInteractions - if err := rows.Scan(&model.ID, &model.ContactID, &model.InteractionType, &model.OccurredAt, &model.Summary, - &model.FollowUpNeeded, &model.FollowUpNotes, &model.CreatedAt); err != nil { - return ext.ContactHistory{}, fmt.Errorf("scan interaction: %w", err) - } - interactions = append(interactions, contactInteractionFromModel(model)) - } - if err := rows.Err(); err != nil { - return ext.ContactHistory{}, err - } +// var interactions []ext.ContactInteraction +// for rows.Next() { +// var model generatedmodels.ModelPublicContactInteractions +// if err := rows.Scan(&model.ID, &model.ContactID, &model.InteractionType, &model.OccurredAt, &model.Summary, +// &model.FollowUpNeeded, &model.FollowUpNotes, &model.CreatedAt); err != nil { +// return ext.ContactHistory{}, fmt.Errorf("scan interaction: %w", err) +// } +// interactions = append(interactions, contactInteractionFromModel(model)) +// } +// if err := rows.Err(); err != nil { +// return ext.ContactHistory{}, err +// } - oppRows, err := db.pool.Query(ctx, ` - select id, contact_id, title, description, stage, value, expected_close_date, notes, created_at, updated_at - from opportunities where contact_id = $1 order by created_at desc - `, contactID) - if err != nil { - return ext.ContactHistory{}, fmt.Errorf("get opportunities: %w", err) - } - defer oppRows.Close() +// oppRows, err := db.pool.Query(ctx, ` +// select id, contact_id, title, description, stage, value, expected_close_date, notes, created_at, updated_at +// from opportunities where contact_id = $1 order by created_at desc +// `, contactID) +// if err != nil { +// return ext.ContactHistory{}, fmt.Errorf("get opportunities: %w", err) +// } +// defer oppRows.Close() - var opportunities []ext.Opportunity - for oppRows.Next() { - var model generatedmodels.ModelPublicOpportunities - if err := oppRows.Scan(&model.ID, &model.ContactID, &model.Title, &model.Description, &model.Stage, &model.Value, - &model.ExpectedCloseDate, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.ContactHistory{}, fmt.Errorf("scan opportunity: %w", err) - } - opportunities = append(opportunities, opportunityFromModel(model)) - } - if err := oppRows.Err(); err != nil { - return ext.ContactHistory{}, err - } +// var opportunities []ext.Opportunity +// for oppRows.Next() { +// var model generatedmodels.ModelPublicOpportunities +// if err := oppRows.Scan(&model.ID, &model.ContactID, &model.Title, &model.Description, &model.Stage, &model.Value, +// &model.ExpectedCloseDate, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.ContactHistory{}, fmt.Errorf("scan opportunity: %w", err) +// } +// opportunities = append(opportunities, opportunityFromModel(model)) +// } +// if err := oppRows.Err(); err != nil { +// return ext.ContactHistory{}, err +// } - return ext.ContactHistory{ - Contact: contact, - Interactions: interactions, - Opportunities: opportunities, - }, nil -} +// return ext.ContactHistory{ +// Contact: contact, +// Interactions: interactions, +// Opportunities: opportunities, +// }, nil +// } -func (db *DB) CreateOpportunity(ctx context.Context, o ext.Opportunity) (ext.Opportunity, error) { - row := db.pool.QueryRow(ctx, ` - insert into opportunities (contact_id, title, description, stage, value, expected_close_date, notes) - values ($1, $2, $3, $4, $5, $6, $7) - returning id, created_at, updated_at - `, o.ContactID, o.Title, nullStr(o.Description), o.Stage, o.Value, o.ExpectedCloseDate, nullStr(o.Notes)) +// func (db *DB) CreateOpportunity(ctx context.Context, o ext.Opportunity) (ext.Opportunity, error) { +// row := db.pool.QueryRow(ctx, ` +// insert into opportunities (contact_id, title, description, stage, value, expected_close_date, notes) +// values ($1, $2, $3, $4, $5, $6, $7) +// returning id, created_at, updated_at +// `, o.ContactID, o.Title, nullStr(o.Description), o.Stage, o.Value, o.ExpectedCloseDate, nullStr(o.Notes)) - created := o - var model generatedmodels.ModelPublicOpportunities - if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.Opportunity{}, fmt.Errorf("insert opportunity: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - created.UpdatedAt = model.UpdatedAt.Time() - return created, nil -} +// created := o +// var model generatedmodels.ModelPublicOpportunities +// if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.Opportunity{}, fmt.Errorf("insert opportunity: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// created.UpdatedAt = model.UpdatedAt.Time() +// return created, nil +// } -func (db *DB) GetFollowUpsDue(ctx context.Context, daysAhead int) ([]ext.ProfessionalContact, error) { - if daysAhead <= 0 { - daysAhead = 7 - } - cutoff := time.Now().AddDate(0, 0, daysAhead) +// func (db *DB) GetFollowUpsDue(ctx context.Context, daysAhead int) ([]ext.ProfessionalContact, error) { +// if daysAhead <= 0 { +// daysAhead = 7 +// } +// cutoff := time.Now().AddDate(0, 0, daysAhead) - rows, err := db.pool.Query(ctx, ` - select id, name, company, title, email, phone, linkedin_url, how_we_met, tags::text[], notes, last_contacted, follow_up_date, created_at, updated_at - from professional_contacts - where follow_up_date <= $1 - order by follow_up_date asc - `, cutoff) - if err != nil { - return nil, fmt.Errorf("get follow-ups: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, ` +// select id, name, company, title, email, phone, linkedin_url, how_we_met, tags::text[], notes, last_contacted, follow_up_date, created_at, updated_at +// from professional_contacts +// where follow_up_date <= $1 +// order by follow_up_date asc +// `, cutoff) +// if err != nil { +// return nil, fmt.Errorf("get follow-ups: %w", err) +// } +// defer rows.Close() - return scanContacts(rows) -} +// return scanContacts(rows) +// } -func (db *DB) AppendThoughtToContactNotes(ctx context.Context, contactID uuid.UUID, thoughtContent string) error { - _, err := db.pool.Exec(ctx, ` - update professional_contacts - set notes = coalesce(notes, '') || $2 - where id = $1 - `, contactID, thoughtContent) - if err != nil { - return fmt.Errorf("append thought to contact: %w", err) - } - return nil -} +// func (db *DB) AppendThoughtToContactNotes(ctx context.Context, contactID uuid.UUID, thoughtContent string) error { +// _, err := db.pool.Exec(ctx, ` +// update professional_contacts +// set notes = coalesce(notes, '') || $2 +// where id = $1 +// `, contactID, thoughtContent) +// if err != nil { +// return fmt.Errorf("append thought to contact: %w", err) +// } +// return nil +// } -func scanContacts(rows interface { - Next() bool - Scan(...any) error - Err() error - Close() -}) ([]ext.ProfessionalContact, error) { - defer rows.Close() - var contacts []ext.ProfessionalContact - for rows.Next() { - var model generatedmodels.ModelPublicProfessionalContacts - var tags []string - if err := rows.Scan(&model.ID, &model.Name, &model.Company, &model.Title, &model.Email, &model.Phone, - &model.LinkedinURL, &model.HowWeMet, &tags, &model.Notes, &model.LastContacted, &model.FollowUpDate, - &model.CreatedAt, &model.UpdatedAt); err != nil { - return nil, fmt.Errorf("scan contact: %w", err) - } - contacts = append(contacts, professionalContactFromModel(model, tags)) - } - return contacts, rows.Err() -} +// func scanContacts(rows interface { +// Next() bool +// Scan(...any) error +// Err() error +// Close() +// }) ([]ext.ProfessionalContact, error) { +// defer rows.Close() +// var contacts []ext.ProfessionalContact +// for rows.Next() { +// var model generatedmodels.ModelPublicProfessionalContacts +// var tags []string +// if err := rows.Scan(&model.ID, &model.Name, &model.Company, &model.Title, &model.Email, &model.Phone, +// &model.LinkedinURL, &model.HowWeMet, &tags, &model.Notes, &model.LastContacted, &model.FollowUpDate, +// &model.CreatedAt, &model.UpdatedAt); err != nil { +// return nil, fmt.Errorf("scan contact: %w", err) +// } +// contacts = append(contacts, professionalContactFromModel(model, tags)) +// } +// return contacts, rows.Err() +// } diff --git a/internal/store/household.go b/internal/store/household.go index fcbb85a..24a57f8 100644 --- a/internal/store/household.go +++ b/internal/store/household.go @@ -1,133 +1,133 @@ package store -import ( - "context" - "encoding/json" - "fmt" - "strings" +// import ( +// "context" +// "encoding/json" +// "fmt" +// "strings" - "github.com/google/uuid" +// "github.com/google/uuid" - "git.warky.dev/wdevs/amcs/internal/generatedmodels" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/generatedmodels" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -func (db *DB) AddHouseholdItem(ctx context.Context, item ext.HouseholdItem) (ext.HouseholdItem, error) { - details, err := json.Marshal(item.Details) - if err != nil { - return ext.HouseholdItem{}, fmt.Errorf("marshal details: %w", err) - } +// func (db *DB) AddHouseholdItem(ctx context.Context, item ext.HouseholdItem) (ext.HouseholdItem, error) { +// details, err := json.Marshal(item.Details) +// if err != nil { +// return ext.HouseholdItem{}, fmt.Errorf("marshal details: %w", err) +// } - row := db.pool.QueryRow(ctx, ` - insert into household_items (name, category, location, details, notes) - values ($1, $2, $3, $4::jsonb, $5) - returning id, created_at, updated_at - `, item.Name, nullStr(item.Category), nullStr(item.Location), details, nullStr(item.Notes)) +// row := db.pool.QueryRow(ctx, ` +// insert into household_items (name, category, location, details, notes) +// values ($1, $2, $3, $4::jsonb, $5) +// returning id, created_at, updated_at +// `, item.Name, nullStr(item.Category), nullStr(item.Location), details, nullStr(item.Notes)) - created := item - var model generatedmodels.ModelPublicHouseholdItems - if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.HouseholdItem{}, fmt.Errorf("insert household item: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - created.UpdatedAt = model.UpdatedAt.Time() - return created, nil -} +// created := item +// var model generatedmodels.ModelPublicHouseholdItems +// if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.HouseholdItem{}, fmt.Errorf("insert household item: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// created.UpdatedAt = model.UpdatedAt.Time() +// return created, nil +// } -func (db *DB) SearchHouseholdItems(ctx context.Context, query, category, location string) ([]ext.HouseholdItem, error) { - args := []any{} - conditions := []string{} +// func (db *DB) SearchHouseholdItems(ctx context.Context, query, category, location string) ([]ext.HouseholdItem, error) { +// args := []any{} +// conditions := []string{} - if q := strings.TrimSpace(query); q != "" { - args = append(args, "%"+q+"%") - conditions = append(conditions, fmt.Sprintf("(name ILIKE $%d OR notes ILIKE $%d)", len(args), len(args))) - } - if c := strings.TrimSpace(category); c != "" { - args = append(args, c) - conditions = append(conditions, fmt.Sprintf("category = $%d", len(args))) - } - if l := strings.TrimSpace(location); l != "" { - args = append(args, "%"+l+"%") - conditions = append(conditions, fmt.Sprintf("location ILIKE $%d", len(args))) - } +// if q := strings.TrimSpace(query); q != "" { +// args = append(args, "%"+q+"%") +// conditions = append(conditions, fmt.Sprintf("(name ILIKE $%d OR notes ILIKE $%d)", len(args), len(args))) +// } +// if c := strings.TrimSpace(category); c != "" { +// args = append(args, c) +// conditions = append(conditions, fmt.Sprintf("category = $%d", len(args))) +// } +// if l := strings.TrimSpace(location); l != "" { +// args = append(args, "%"+l+"%") +// conditions = append(conditions, fmt.Sprintf("location ILIKE $%d", len(args))) +// } - q := `select id, name, category, location, details, notes, created_at, updated_at from household_items` - if len(conditions) > 0 { - q += " where " + strings.Join(conditions, " and ") - } - q += " order by name" +// q := `select id, name, category, location, details, notes, created_at, updated_at from household_items` +// if len(conditions) > 0 { +// q += " where " + strings.Join(conditions, " and ") +// } +// q += " order by name" - rows, err := db.pool.Query(ctx, q, args...) - if err != nil { - return nil, fmt.Errorf("search household items: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, q, args...) +// if err != nil { +// return nil, fmt.Errorf("search household items: %w", err) +// } +// defer rows.Close() - var items []ext.HouseholdItem - for rows.Next() { - var model generatedmodels.ModelPublicHouseholdItems - if err := rows.Scan(&model.ID, &model.Name, &model.Category, &model.Location, &model.Details, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { - return nil, fmt.Errorf("scan household item: %w", err) - } - items = append(items, householdItemFromModel(model)) - } - return items, rows.Err() -} +// var items []ext.HouseholdItem +// for rows.Next() { +// var model generatedmodels.ModelPublicHouseholdItems +// if err := rows.Scan(&model.ID, &model.Name, &model.Category, &model.Location, &model.Details, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return nil, fmt.Errorf("scan household item: %w", err) +// } +// items = append(items, householdItemFromModel(model)) +// } +// return items, rows.Err() +// } -func (db *DB) GetHouseholdItem(ctx context.Context, id uuid.UUID) (ext.HouseholdItem, error) { - row := db.pool.QueryRow(ctx, ` - select id, name, category, location, details, notes, created_at, updated_at - from household_items where id = $1 - `, id) +// func (db *DB) GetHouseholdItem(ctx context.Context, id uuid.UUID) (ext.HouseholdItem, error) { +// row := db.pool.QueryRow(ctx, ` +// select id, name, category, location, details, notes, created_at, updated_at +// from household_items where id = $1 +// `, id) - var model generatedmodels.ModelPublicHouseholdItems - if err := row.Scan(&model.ID, &model.Name, &model.Category, &model.Location, &model.Details, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.HouseholdItem{}, fmt.Errorf("get household item: %w", err) - } - return householdItemFromModel(model), nil -} +// var model generatedmodels.ModelPublicHouseholdItems +// if err := row.Scan(&model.ID, &model.Name, &model.Category, &model.Location, &model.Details, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.HouseholdItem{}, fmt.Errorf("get household item: %w", err) +// } +// return householdItemFromModel(model), nil +// } -func (db *DB) AddVendor(ctx context.Context, v ext.HouseholdVendor) (ext.HouseholdVendor, error) { - row := db.pool.QueryRow(ctx, ` - insert into household_vendors (name, service_type, phone, email, website, notes, rating, last_used) - values ($1, $2, $3, $4, $5, $6, $7, $8) - returning id, created_at - `, v.Name, nullStr(v.ServiceType), nullStr(v.Phone), nullStr(v.Email), - nullStr(v.Website), nullStr(v.Notes), v.Rating, v.LastUsed) +// func (db *DB) AddVendor(ctx context.Context, v ext.HouseholdVendor) (ext.HouseholdVendor, error) { +// row := db.pool.QueryRow(ctx, ` +// insert into household_vendors (name, service_type, phone, email, website, notes, rating, last_used) +// values ($1, $2, $3, $4, $5, $6, $7, $8) +// returning id, created_at +// `, v.Name, nullStr(v.ServiceType), nullStr(v.Phone), nullStr(v.Email), +// nullStr(v.Website), nullStr(v.Notes), v.Rating, v.LastUsed) - created := v - var model generatedmodels.ModelPublicHouseholdVendors - if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { - return ext.HouseholdVendor{}, fmt.Errorf("insert vendor: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - return created, nil -} +// created := v +// var model generatedmodels.ModelPublicHouseholdVendors +// if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { +// return ext.HouseholdVendor{}, fmt.Errorf("insert vendor: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// return created, nil +// } -func (db *DB) ListVendors(ctx context.Context, serviceType string) ([]ext.HouseholdVendor, error) { - args := []any{} - q := `select id, name, service_type, phone, email, website, notes, rating, last_used, created_at from household_vendors` - if st := strings.TrimSpace(serviceType); st != "" { - args = append(args, st) - q += " where service_type = $1" - } - q += " order by name" +// func (db *DB) ListVendors(ctx context.Context, serviceType string) ([]ext.HouseholdVendor, error) { +// args := []any{} +// q := `select id, name, service_type, phone, email, website, notes, rating, last_used, created_at from household_vendors` +// if st := strings.TrimSpace(serviceType); st != "" { +// args = append(args, st) +// q += " where service_type = $1" +// } +// q += " order by name" - rows, err := db.pool.Query(ctx, q, args...) - if err != nil { - return nil, fmt.Errorf("list vendors: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, q, args...) +// if err != nil { +// return nil, fmt.Errorf("list vendors: %w", err) +// } +// defer rows.Close() - var vendors []ext.HouseholdVendor - for rows.Next() { - var model generatedmodels.ModelPublicHouseholdVendors - if err := rows.Scan(&model.ID, &model.Name, &model.ServiceType, &model.Phone, &model.Email, &model.Website, &model.Notes, &model.Rating, &model.LastUsed, &model.CreatedAt); err != nil { - return nil, fmt.Errorf("scan vendor: %w", err) - } - vendors = append(vendors, householdVendorFromModel(model)) - } - return vendors, rows.Err() -} +// var vendors []ext.HouseholdVendor +// for rows.Next() { +// var model generatedmodels.ModelPublicHouseholdVendors +// if err := rows.Scan(&model.ID, &model.Name, &model.ServiceType, &model.Phone, &model.Email, &model.Website, &model.Notes, &model.Rating, &model.LastUsed, &model.CreatedAt); err != nil { +// return nil, fmt.Errorf("scan vendor: %w", err) +// } +// vendors = append(vendors, householdVendorFromModel(model)) +// } +// return vendors, rows.Err() +// } diff --git a/internal/store/maintenance.go b/internal/store/maintenance.go index 8776d42..f7a64ef 100644 --- a/internal/store/maintenance.go +++ b/internal/store/maintenance.go @@ -1,137 +1,137 @@ package store -import ( - "context" - "fmt" - "strings" - "time" +// import ( +// "context" +// "fmt" +// "strings" +// "time" - "git.warky.dev/wdevs/amcs/internal/generatedmodels" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/generatedmodels" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -func (db *DB) AddMaintenanceTask(ctx context.Context, t ext.MaintenanceTask) (ext.MaintenanceTask, error) { - row := db.pool.QueryRow(ctx, ` - insert into maintenance_tasks (name, category, frequency_days, next_due, priority, notes) - values ($1, $2, $3, $4, $5, $6) - returning id, created_at, updated_at - `, t.Name, nullStr(t.Category), t.FrequencyDays, t.NextDue, t.Priority, nullStr(t.Notes)) +// func (db *DB) AddMaintenanceTask(ctx context.Context, t ext.MaintenanceTask) (ext.MaintenanceTask, error) { +// row := db.pool.QueryRow(ctx, ` +// insert into maintenance_tasks (name, category, frequency_days, next_due, priority, notes) +// values ($1, $2, $3, $4, $5, $6) +// returning id, created_at, updated_at +// `, t.Name, nullStr(t.Category), t.FrequencyDays, t.NextDue, t.Priority, nullStr(t.Notes)) - created := t - var model generatedmodels.ModelPublicMaintenanceTasks - if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.MaintenanceTask{}, fmt.Errorf("insert maintenance task: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - created.UpdatedAt = model.UpdatedAt.Time() - return created, nil -} +// created := t +// var model generatedmodels.ModelPublicMaintenanceTasks +// if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.MaintenanceTask{}, fmt.Errorf("insert maintenance task: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// created.UpdatedAt = model.UpdatedAt.Time() +// return created, nil +// } -func (db *DB) LogMaintenance(ctx context.Context, log ext.MaintenanceLog) (ext.MaintenanceLog, error) { - completedAt := log.CompletedAt - if completedAt.IsZero() { - completedAt = time.Now() - } +// func (db *DB) LogMaintenance(ctx context.Context, log ext.MaintenanceLog) (ext.MaintenanceLog, error) { +// completedAt := log.CompletedAt +// if completedAt.IsZero() { +// completedAt = time.Now() +// } - row := db.pool.QueryRow(ctx, ` - insert into maintenance_logs (task_id, completed_at, performed_by, cost, notes, next_action) - values ($1, $2, $3, $4, $5, $6) - returning id - `, log.TaskID, completedAt, nullStr(log.PerformedBy), log.Cost, nullStr(log.Notes), nullStr(log.NextAction)) +// row := db.pool.QueryRow(ctx, ` +// insert into maintenance_logs (task_id, completed_at, performed_by, cost, notes, next_action) +// values ($1, $2, $3, $4, $5, $6) +// returning id +// `, log.TaskID, completedAt, nullStr(log.PerformedBy), log.Cost, nullStr(log.Notes), nullStr(log.NextAction)) - created := log - created.CompletedAt = completedAt - var model generatedmodels.ModelPublicMaintenanceLogs - if err := row.Scan(&model.ID); err != nil { - return ext.MaintenanceLog{}, fmt.Errorf("insert maintenance log: %w", err) - } - created.ID = model.ID.UUID() - return created, nil -} +// created := log +// created.CompletedAt = completedAt +// var model generatedmodels.ModelPublicMaintenanceLogs +// if err := row.Scan(&model.ID); err != nil { +// return ext.MaintenanceLog{}, fmt.Errorf("insert maintenance log: %w", err) +// } +// created.ID = model.ID.UUID() +// return created, nil +// } -func (db *DB) GetUpcomingMaintenance(ctx context.Context, daysAhead int) ([]ext.MaintenanceTask, error) { - if daysAhead <= 0 { - daysAhead = 30 - } - cutoff := time.Now().Add(time.Duration(daysAhead) * 24 * time.Hour) +// func (db *DB) GetUpcomingMaintenance(ctx context.Context, daysAhead int) ([]ext.MaintenanceTask, error) { +// if daysAhead <= 0 { +// daysAhead = 30 +// } +// cutoff := time.Now().Add(time.Duration(daysAhead) * 24 * time.Hour) - rows, err := db.pool.Query(ctx, ` - select id, name, category, frequency_days, last_completed, next_due, priority, notes, created_at, updated_at - from maintenance_tasks - where next_due <= $1 or next_due is null - order by next_due asc nulls last, priority desc - `, cutoff) - if err != nil { - return nil, fmt.Errorf("get upcoming maintenance: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, ` +// select id, name, category, frequency_days, last_completed, next_due, priority, notes, created_at, updated_at +// from maintenance_tasks +// where next_due <= $1 or next_due is null +// order by next_due asc nulls last, priority desc +// `, cutoff) +// if err != nil { +// return nil, fmt.Errorf("get upcoming maintenance: %w", err) +// } +// defer rows.Close() - tasks := make([]ext.MaintenanceTask, 0) - for rows.Next() { - var model generatedmodels.ModelPublicMaintenanceTasks - if err := rows.Scan(&model.ID, &model.Name, &model.Category, &model.FrequencyDays, &model.LastCompleted, &model.NextDue, &model.Priority, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { - return nil, fmt.Errorf("scan maintenance task: %w", err) - } - tasks = append(tasks, maintenanceTaskFromModel(model)) - } - return tasks, rows.Err() -} +// tasks := make([]ext.MaintenanceTask, 0) +// for rows.Next() { +// var model generatedmodels.ModelPublicMaintenanceTasks +// if err := rows.Scan(&model.ID, &model.Name, &model.Category, &model.FrequencyDays, &model.LastCompleted, &model.NextDue, &model.Priority, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return nil, fmt.Errorf("scan maintenance task: %w", err) +// } +// tasks = append(tasks, maintenanceTaskFromModel(model)) +// } +// return tasks, rows.Err() +// } -func (db *DB) SearchMaintenanceHistory(ctx context.Context, query, category string, start, end *time.Time) ([]ext.MaintenanceLogWithTask, error) { - args := []any{} - conditions := []string{} +// func (db *DB) SearchMaintenanceHistory(ctx context.Context, query, category string, start, end *time.Time) ([]ext.MaintenanceLogWithTask, error) { +// args := []any{} +// conditions := []string{} - if q := strings.TrimSpace(query); q != "" { - args = append(args, "%"+q+"%") - conditions = append(conditions, fmt.Sprintf("(mt.name ILIKE $%d OR ml.notes ILIKE $%d)", len(args), len(args))) - } - if c := strings.TrimSpace(category); c != "" { - args = append(args, c) - conditions = append(conditions, fmt.Sprintf("mt.category = $%d", len(args))) - } - if start != nil { - args = append(args, *start) - conditions = append(conditions, fmt.Sprintf("ml.completed_at >= $%d", len(args))) - } - if end != nil { - args = append(args, *end) - conditions = append(conditions, fmt.Sprintf("ml.completed_at <= $%d", len(args))) - } +// if q := strings.TrimSpace(query); q != "" { +// args = append(args, "%"+q+"%") +// conditions = append(conditions, fmt.Sprintf("(mt.name ILIKE $%d OR ml.notes ILIKE $%d)", len(args), len(args))) +// } +// if c := strings.TrimSpace(category); c != "" { +// args = append(args, c) +// conditions = append(conditions, fmt.Sprintf("mt.category = $%d", len(args))) +// } +// if start != nil { +// args = append(args, *start) +// conditions = append(conditions, fmt.Sprintf("ml.completed_at >= $%d", len(args))) +// } +// if end != nil { +// args = append(args, *end) +// conditions = append(conditions, fmt.Sprintf("ml.completed_at <= $%d", len(args))) +// } - q := ` - select ml.id, ml.task_id, ml.completed_at, ml.performed_by, ml.cost, ml.notes, ml.next_action, - mt.name, mt.category - from maintenance_logs ml - join maintenance_tasks mt on mt.id = ml.task_id - ` - if len(conditions) > 0 { - q += " where " + strings.Join(conditions, " and ") - } - q += " order by ml.completed_at desc" +// q := ` +// select ml.id, ml.task_id, ml.completed_at, ml.performed_by, ml.cost, ml.notes, ml.next_action, +// mt.name, mt.category +// from maintenance_logs ml +// join maintenance_tasks mt on mt.id = ml.task_id +// ` +// if len(conditions) > 0 { +// q += " where " + strings.Join(conditions, " and ") +// } +// q += " order by ml.completed_at desc" - rows, err := db.pool.Query(ctx, q, args...) - if err != nil { - return nil, fmt.Errorf("search maintenance history: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, q, args...) +// if err != nil { +// return nil, fmt.Errorf("search maintenance history: %w", err) +// } +// defer rows.Close() - var logs []ext.MaintenanceLogWithTask - for rows.Next() { - var model generatedmodels.ModelPublicMaintenanceLogs - var taskName, taskCategory string - if err := rows.Scan( - &model.ID, &model.TaskID, &model.CompletedAt, &model.PerformedBy, &model.Cost, &model.Notes, &model.NextAction, - &taskName, &taskCategory, - ); err != nil { - return nil, fmt.Errorf("scan maintenance log: %w", err) - } - l := ext.MaintenanceLogWithTask{ - MaintenanceLog: maintenanceLogFromModel(model), - TaskName: taskName, - TaskCategory: taskCategory, - } - logs = append(logs, l) - } - return logs, rows.Err() -} +// var logs []ext.MaintenanceLogWithTask +// for rows.Next() { +// var model generatedmodels.ModelPublicMaintenanceLogs +// var taskName, taskCategory string +// if err := rows.Scan( +// &model.ID, &model.TaskID, &model.CompletedAt, &model.PerformedBy, &model.Cost, &model.Notes, &model.NextAction, +// &taskName, &taskCategory, +// ); err != nil { +// return nil, fmt.Errorf("scan maintenance log: %w", err) +// } +// l := ext.MaintenanceLogWithTask{ +// MaintenanceLog: maintenanceLogFromModel(model), +// TaskName: taskName, +// TaskCategory: taskCategory, +// } +// logs = append(logs, l) +// } +// return logs, rows.Err() +// } diff --git a/internal/store/meals.go b/internal/store/meals.go index cfbf905..6395a57 100644 --- a/internal/store/meals.go +++ b/internal/store/meals.go @@ -1,280 +1,280 @@ package store -import ( - "context" - "encoding/json" - "fmt" - "strings" - "time" +// import ( +// "context" +// "encoding/json" +// "fmt" +// "strings" +// "time" - "github.com/google/uuid" +// "github.com/google/uuid" - "git.warky.dev/wdevs/amcs/internal/generatedmodels" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/generatedmodels" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -func (db *DB) AddRecipe(ctx context.Context, r ext.Recipe) (ext.Recipe, error) { - ingredients, err := json.Marshal(r.Ingredients) - if err != nil { - return ext.Recipe{}, fmt.Errorf("marshal ingredients: %w", err) - } - instructions, err := json.Marshal(r.Instructions) - if err != nil { - return ext.Recipe{}, fmt.Errorf("marshal instructions: %w", err) - } - if r.Tags == nil { - r.Tags = []string{} - } +// func (db *DB) AddRecipe(ctx context.Context, r ext.Recipe) (ext.Recipe, error) { +// ingredients, err := json.Marshal(r.Ingredients) +// if err != nil { +// return ext.Recipe{}, fmt.Errorf("marshal ingredients: %w", err) +// } +// instructions, err := json.Marshal(r.Instructions) +// if err != nil { +// return ext.Recipe{}, fmt.Errorf("marshal instructions: %w", err) +// } +// if r.Tags == nil { +// r.Tags = []string{} +// } - row := db.pool.QueryRow(ctx, ` - insert into recipes (name, cuisine, prep_time_minutes, cook_time_minutes, servings, ingredients, instructions, tags, rating, notes) - values ($1, $2, $3, $4, $5, $6::jsonb, $7::jsonb, $8, $9, $10) - returning id, created_at, updated_at - `, r.Name, nullStr(r.Cuisine), r.PrepTimeMinutes, r.CookTimeMinutes, r.Servings, - ingredients, instructions, r.Tags, r.Rating, nullStr(r.Notes)) +// row := db.pool.QueryRow(ctx, ` +// insert into recipes (name, cuisine, prep_time_minutes, cook_time_minutes, servings, ingredients, instructions, tags, rating, notes) +// values ($1, $2, $3, $4, $5, $6::jsonb, $7::jsonb, $8, $9, $10) +// returning id, created_at, updated_at +// `, r.Name, nullStr(r.Cuisine), r.PrepTimeMinutes, r.CookTimeMinutes, r.Servings, +// ingredients, instructions, r.Tags, r.Rating, nullStr(r.Notes)) - created := r - var model generatedmodels.ModelPublicRecipes - if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.Recipe{}, fmt.Errorf("insert recipe: %w", err) - } - created.ID = model.ID.UUID() - created.CreatedAt = model.CreatedAt.Time() - created.UpdatedAt = model.UpdatedAt.Time() - return created, nil -} +// created := r +// var model generatedmodels.ModelPublicRecipes +// if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.Recipe{}, fmt.Errorf("insert recipe: %w", err) +// } +// created.ID = model.ID.UUID() +// created.CreatedAt = model.CreatedAt.Time() +// created.UpdatedAt = model.UpdatedAt.Time() +// return created, nil +// } -func (db *DB) SearchRecipes(ctx context.Context, query, cuisine string, tags []string, ingredient string) ([]ext.Recipe, error) { - args := []any{} - conditions := []string{} +// func (db *DB) SearchRecipes(ctx context.Context, query, cuisine string, tags []string, ingredient string) ([]ext.Recipe, error) { +// args := []any{} +// conditions := []string{} - if q := strings.TrimSpace(query); q != "" { - args = append(args, "%"+q+"%") - conditions = append(conditions, fmt.Sprintf("name ILIKE $%d", len(args))) - } - if c := strings.TrimSpace(cuisine); c != "" { - args = append(args, c) - conditions = append(conditions, fmt.Sprintf("cuisine = $%d", len(args))) - } - if len(tags) > 0 { - args = append(args, tags) - conditions = append(conditions, fmt.Sprintf("tags @> $%d", len(args))) - } - if ing := strings.TrimSpace(ingredient); ing != "" { - args = append(args, "%"+ing+"%") - conditions = append(conditions, fmt.Sprintf("ingredients::text ILIKE $%d", len(args))) - } +// if q := strings.TrimSpace(query); q != "" { +// args = append(args, "%"+q+"%") +// conditions = append(conditions, fmt.Sprintf("name ILIKE $%d", len(args))) +// } +// if c := strings.TrimSpace(cuisine); c != "" { +// args = append(args, c) +// conditions = append(conditions, fmt.Sprintf("cuisine = $%d", len(args))) +// } +// if len(tags) > 0 { +// args = append(args, tags) +// conditions = append(conditions, fmt.Sprintf("tags @> $%d", len(args))) +// } +// if ing := strings.TrimSpace(ingredient); ing != "" { +// args = append(args, "%"+ing+"%") +// conditions = append(conditions, fmt.Sprintf("ingredients::text ILIKE $%d", len(args))) +// } - q := `select id, name, cuisine, prep_time_minutes, cook_time_minutes, servings, ingredients, instructions, tags::text[], rating, notes, created_at, updated_at from recipes` - if len(conditions) > 0 { - q += " where " + strings.Join(conditions, " and ") - } - q += " order by name" +// q := `select id, name, cuisine, prep_time_minutes, cook_time_minutes, servings, ingredients, instructions, tags::text[], rating, notes, created_at, updated_at from recipes` +// if len(conditions) > 0 { +// q += " where " + strings.Join(conditions, " and ") +// } +// q += " order by name" - rows, err := db.pool.Query(ctx, q, args...) - if err != nil { - return nil, fmt.Errorf("search recipes: %w", err) - } - defer rows.Close() +// rows, err := db.pool.Query(ctx, q, args...) +// if err != nil { +// return nil, fmt.Errorf("search recipes: %w", err) +// } +// defer rows.Close() - var recipes []ext.Recipe - for rows.Next() { - r, err := scanRecipeRow(rows) - if err != nil { - return nil, err - } - recipes = append(recipes, r) - } - return recipes, rows.Err() -} +// var recipes []ext.Recipe +// for rows.Next() { +// r, err := scanRecipeRow(rows) +// if err != nil { +// return nil, err +// } +// recipes = append(recipes, r) +// } +// return recipes, rows.Err() +// } -func (db *DB) GetRecipe(ctx context.Context, id uuid.UUID) (ext.Recipe, error) { - row := db.pool.QueryRow(ctx, ` - select id, name, cuisine, prep_time_minutes, cook_time_minutes, servings, ingredients, instructions, tags::text[], rating, notes, created_at, updated_at - from recipes where id = $1 - `, id) +// func (db *DB) GetRecipe(ctx context.Context, id uuid.UUID) (ext.Recipe, error) { +// row := db.pool.QueryRow(ctx, ` +// select id, name, cuisine, prep_time_minutes, cook_time_minutes, servings, ingredients, instructions, tags::text[], rating, notes, created_at, updated_at +// from recipes where id = $1 +// `, id) - var model generatedmodels.ModelPublicRecipes - var tags []string - if err := row.Scan(&model.ID, &model.Name, &model.Cuisine, &model.PrepTimeMinutes, &model.CookTimeMinutes, &model.Servings, - &model.Ingredients, &model.Instructions, &tags, &model.Rating, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.Recipe{}, fmt.Errorf("get recipe: %w", err) - } - if tags == nil { - tags = []string{} - } - return recipeFromModel(model, tags), nil -} +// var model generatedmodels.ModelPublicRecipes +// var tags []string +// if err := row.Scan(&model.ID, &model.Name, &model.Cuisine, &model.PrepTimeMinutes, &model.CookTimeMinutes, &model.Servings, +// &model.Ingredients, &model.Instructions, &tags, &model.Rating, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.Recipe{}, fmt.Errorf("get recipe: %w", err) +// } +// if tags == nil { +// tags = []string{} +// } +// return recipeFromModel(model, tags), nil +// } -func (db *DB) UpdateRecipe(ctx context.Context, id uuid.UUID, r ext.Recipe) (ext.Recipe, error) { - ingredients, err := json.Marshal(r.Ingredients) - if err != nil { - return ext.Recipe{}, fmt.Errorf("marshal ingredients: %w", err) - } - instructions, err := json.Marshal(r.Instructions) - if err != nil { - return ext.Recipe{}, fmt.Errorf("marshal instructions: %w", err) - } - if r.Tags == nil { - r.Tags = []string{} - } +// func (db *DB) UpdateRecipe(ctx context.Context, id uuid.UUID, r ext.Recipe) (ext.Recipe, error) { +// ingredients, err := json.Marshal(r.Ingredients) +// if err != nil { +// return ext.Recipe{}, fmt.Errorf("marshal ingredients: %w", err) +// } +// instructions, err := json.Marshal(r.Instructions) +// if err != nil { +// return ext.Recipe{}, fmt.Errorf("marshal instructions: %w", err) +// } +// if r.Tags == nil { +// r.Tags = []string{} +// } - _, err = db.pool.Exec(ctx, ` - update recipes set - name = $2, cuisine = $3, prep_time_minutes = $4, cook_time_minutes = $5, - servings = $6, ingredients = $7::jsonb, instructions = $8::jsonb, - tags = $9, rating = $10, notes = $11 - where id = $1 - `, id, r.Name, nullStr(r.Cuisine), r.PrepTimeMinutes, r.CookTimeMinutes, r.Servings, - ingredients, instructions, r.Tags, r.Rating, nullStr(r.Notes)) - if err != nil { - return ext.Recipe{}, fmt.Errorf("update recipe: %w", err) - } - return db.GetRecipe(ctx, id) -} +// _, err = db.pool.Exec(ctx, ` +// update recipes set +// name = $2, cuisine = $3, prep_time_minutes = $4, cook_time_minutes = $5, +// servings = $6, ingredients = $7::jsonb, instructions = $8::jsonb, +// tags = $9, rating = $10, notes = $11 +// where id = $1 +// `, id, r.Name, nullStr(r.Cuisine), r.PrepTimeMinutes, r.CookTimeMinutes, r.Servings, +// ingredients, instructions, r.Tags, r.Rating, nullStr(r.Notes)) +// if err != nil { +// return ext.Recipe{}, fmt.Errorf("update recipe: %w", err) +// } +// return db.GetRecipe(ctx, id) +// } -func (db *DB) CreateMealPlan(ctx context.Context, weekStart time.Time, entries []ext.MealPlanInput) ([]ext.MealPlanEntry, error) { - if _, err := db.pool.Exec(ctx, `delete from meal_plans where week_start = $1`, weekStart); err != nil { - return nil, fmt.Errorf("clear meal plan: %w", err) - } +// func (db *DB) CreateMealPlan(ctx context.Context, weekStart time.Time, entries []ext.MealPlanInput) ([]ext.MealPlanEntry, error) { +// if _, err := db.pool.Exec(ctx, `delete from meal_plans where week_start = $1`, weekStart); err != nil { +// return nil, fmt.Errorf("clear meal plan: %w", err) +// } - var results []ext.MealPlanEntry - for _, e := range entries { - row := db.pool.QueryRow(ctx, ` - insert into meal_plans (week_start, day_of_week, meal_type, recipe_id, custom_meal, servings, notes) - values ($1, $2, $3, $4, $5, $6, $7) - returning id, created_at - `, weekStart, e.DayOfWeek, e.MealType, e.RecipeID, nullStr(e.CustomMeal), e.Servings, nullStr(e.Notes)) +// var results []ext.MealPlanEntry +// for _, e := range entries { +// row := db.pool.QueryRow(ctx, ` +// insert into meal_plans (week_start, day_of_week, meal_type, recipe_id, custom_meal, servings, notes) +// values ($1, $2, $3, $4, $5, $6, $7) +// returning id, created_at +// `, weekStart, e.DayOfWeek, e.MealType, e.RecipeID, nullStr(e.CustomMeal), e.Servings, nullStr(e.Notes)) - entry := ext.MealPlanEntry{ - WeekStart: weekStart, - DayOfWeek: e.DayOfWeek, - MealType: e.MealType, - RecipeID: e.RecipeID, - CustomMeal: e.CustomMeal, - Servings: e.Servings, - Notes: e.Notes, - } - var model generatedmodels.ModelPublicMealPlans - if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { - return nil, fmt.Errorf("insert meal plan entry: %w", err) - } - entry.ID = model.ID.UUID() - entry.CreatedAt = model.CreatedAt.Time() - results = append(results, entry) - } - return results, nil -} +// entry := ext.MealPlanEntry{ +// WeekStart: weekStart, +// DayOfWeek: e.DayOfWeek, +// MealType: e.MealType, +// RecipeID: e.RecipeID, +// CustomMeal: e.CustomMeal, +// Servings: e.Servings, +// Notes: e.Notes, +// } +// var model generatedmodels.ModelPublicMealPlans +// if err := row.Scan(&model.ID, &model.CreatedAt); err != nil { +// return nil, fmt.Errorf("insert meal plan entry: %w", err) +// } +// entry.ID = model.ID.UUID() +// entry.CreatedAt = model.CreatedAt.Time() +// results = append(results, entry) +// } +// return results, nil +// } -func (db *DB) GetMealPlan(ctx context.Context, weekStart time.Time) ([]ext.MealPlanEntry, error) { - rows, err := db.pool.Query(ctx, ` - select mp.id, mp.week_start, mp.day_of_week, mp.meal_type, mp.recipe_id, r.name, mp.custom_meal, mp.servings, mp.notes, mp.created_at - from meal_plans mp - left join recipes r on r.id = mp.recipe_id - where mp.week_start = $1 - order by - case mp.day_of_week - when 'monday' then 1 when 'tuesday' then 2 when 'wednesday' then 3 - when 'thursday' then 4 when 'friday' then 5 when 'saturday' then 6 - when 'sunday' then 7 else 8 - end, - case mp.meal_type - when 'breakfast' then 1 when 'lunch' then 2 when 'dinner' then 3 - when 'snack' then 4 else 5 - end - `, weekStart) - if err != nil { - return nil, fmt.Errorf("get meal plan: %w", err) - } - defer rows.Close() +// func (db *DB) GetMealPlan(ctx context.Context, weekStart time.Time) ([]ext.MealPlanEntry, error) { +// rows, err := db.pool.Query(ctx, ` +// select mp.id, mp.week_start, mp.day_of_week, mp.meal_type, mp.recipe_id, r.name, mp.custom_meal, mp.servings, mp.notes, mp.created_at +// from meal_plans mp +// left join recipes r on r.id = mp.recipe_id +// where mp.week_start = $1 +// order by +// case mp.day_of_week +// when 'monday' then 1 when 'tuesday' then 2 when 'wednesday' then 3 +// when 'thursday' then 4 when 'friday' then 5 when 'saturday' then 6 +// when 'sunday' then 7 else 8 +// end, +// case mp.meal_type +// when 'breakfast' then 1 when 'lunch' then 2 when 'dinner' then 3 +// when 'snack' then 4 else 5 +// end +// `, weekStart) +// if err != nil { +// return nil, fmt.Errorf("get meal plan: %w", err) +// } +// defer rows.Close() - var entries []ext.MealPlanEntry - for rows.Next() { - var model generatedmodels.ModelPublicMealPlans - var recipeName *string - if err := rows.Scan(&model.ID, &model.WeekStart, &model.DayOfWeek, &model.MealType, &model.RecipeID, &recipeName, &model.CustomMeal, &model.Servings, &model.Notes, &model.CreatedAt); err != nil { - return nil, fmt.Errorf("scan meal plan entry: %w", err) - } - entries = append(entries, mealPlanEntryFromModel(model, strVal(recipeName))) - } - return entries, rows.Err() -} +// var entries []ext.MealPlanEntry +// for rows.Next() { +// var model generatedmodels.ModelPublicMealPlans +// var recipeName *string +// if err := rows.Scan(&model.ID, &model.WeekStart, &model.DayOfWeek, &model.MealType, &model.RecipeID, &recipeName, &model.CustomMeal, &model.Servings, &model.Notes, &model.CreatedAt); err != nil { +// return nil, fmt.Errorf("scan meal plan entry: %w", err) +// } +// entries = append(entries, mealPlanEntryFromModel(model, strVal(recipeName))) +// } +// return entries, rows.Err() +// } -func (db *DB) GenerateShoppingList(ctx context.Context, weekStart time.Time) (ext.ShoppingList, error) { - entries, err := db.GetMealPlan(ctx, weekStart) - if err != nil { - return ext.ShoppingList{}, err - } +// func (db *DB) GenerateShoppingList(ctx context.Context, weekStart time.Time) (ext.ShoppingList, error) { +// entries, err := db.GetMealPlan(ctx, weekStart) +// if err != nil { +// return ext.ShoppingList{}, err +// } - recipeIDs := map[uuid.UUID]bool{} - for _, e := range entries { - if e.RecipeID != nil { - recipeIDs[*e.RecipeID] = true - } - } +// recipeIDs := map[uuid.UUID]bool{} +// for _, e := range entries { +// if e.RecipeID != nil { +// recipeIDs[*e.RecipeID] = true +// } +// } - aggregated := map[string]*ext.ShoppingItem{} - for id := range recipeIDs { - recipe, err := db.GetRecipe(ctx, id) - if err != nil { - continue - } - for _, ing := range recipe.Ingredients { - key := strings.ToLower(ing.Name) - if existing, ok := aggregated[key]; ok { - if ing.Quantity != "" { - existing.Quantity += "+" + ing.Quantity - } - } else { - recipeIDCopy := id - aggregated[key] = &ext.ShoppingItem{ - Name: ing.Name, - Quantity: ing.Quantity, - Unit: ing.Unit, - Purchased: false, - RecipeID: &recipeIDCopy, - } - } - } - } +// aggregated := map[string]*ext.ShoppingItem{} +// for id := range recipeIDs { +// recipe, err := db.GetRecipe(ctx, id) +// if err != nil { +// continue +// } +// for _, ing := range recipe.Ingredients { +// key := strings.ToLower(ing.Name) +// if existing, ok := aggregated[key]; ok { +// if ing.Quantity != "" { +// existing.Quantity += "+" + ing.Quantity +// } +// } else { +// recipeIDCopy := id +// aggregated[key] = &ext.ShoppingItem{ +// Name: ing.Name, +// Quantity: ing.Quantity, +// Unit: ing.Unit, +// Purchased: false, +// RecipeID: &recipeIDCopy, +// } +// } +// } +// } - items := make([]ext.ShoppingItem, 0, len(aggregated)) - for _, item := range aggregated { - items = append(items, *item) - } +// items := make([]ext.ShoppingItem, 0, len(aggregated)) +// for _, item := range aggregated { +// items = append(items, *item) +// } - itemsJSON, err := json.Marshal(items) - if err != nil { - return ext.ShoppingList{}, fmt.Errorf("marshal shopping items: %w", err) - } +// itemsJSON, err := json.Marshal(items) +// if err != nil { +// return ext.ShoppingList{}, fmt.Errorf("marshal shopping items: %w", err) +// } - row := db.pool.QueryRow(ctx, ` - insert into shopping_lists (week_start, items) - values ($1, $2::jsonb) - on conflict (week_start) do update set items = excluded.items, updated_at = now() - returning id, created_at, updated_at - `, weekStart, itemsJSON) +// row := db.pool.QueryRow(ctx, ` +// insert into shopping_lists (week_start, items) +// values ($1, $2::jsonb) +// on conflict (week_start) do update set items = excluded.items, updated_at = now() +// returning id, created_at, updated_at +// `, weekStart, itemsJSON) - var model generatedmodels.ModelPublicShoppingLists - list := ext.ShoppingList{WeekStart: weekStart, Items: items} - if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.ShoppingList{}, fmt.Errorf("upsert shopping list: %w", err) - } - list.ID = model.ID.UUID() - list.CreatedAt = model.CreatedAt.Time() - list.UpdatedAt = model.UpdatedAt.Time() - return list, nil -} +// var model generatedmodels.ModelPublicShoppingLists +// list := ext.ShoppingList{WeekStart: weekStart, Items: items} +// if err := row.Scan(&model.ID, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.ShoppingList{}, fmt.Errorf("upsert shopping list: %w", err) +// } +// list.ID = model.ID.UUID() +// list.CreatedAt = model.CreatedAt.Time() +// list.UpdatedAt = model.UpdatedAt.Time() +// return list, nil +// } -func scanRecipeRow(rows interface{ Scan(...any) error }) (ext.Recipe, error) { - var model generatedmodels.ModelPublicRecipes - var tags []string - if err := rows.Scan(&model.ID, &model.Name, &model.Cuisine, &model.PrepTimeMinutes, &model.CookTimeMinutes, &model.Servings, - &model.Ingredients, &model.Instructions, &tags, &model.Rating, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { - return ext.Recipe{}, fmt.Errorf("scan recipe: %w", err) - } - if tags == nil { - tags = []string{} - } - return recipeFromModel(model, tags), nil -} +// func scanRecipeRow(rows interface{ Scan(...any) error }) (ext.Recipe, error) { +// var model generatedmodels.ModelPublicRecipes +// var tags []string +// if err := rows.Scan(&model.ID, &model.Name, &model.Cuisine, &model.PrepTimeMinutes, &model.CookTimeMinutes, &model.Servings, +// &model.Ingredients, &model.Instructions, &tags, &model.Rating, &model.Notes, &model.CreatedAt, &model.UpdatedAt); err != nil { +// return ext.Recipe{}, fmt.Errorf("scan recipe: %w", err) +// } +// if tags == nil { +// tags = []string{} +// } +// return recipeFromModel(model, tags), nil +// } diff --git a/internal/store/model_adapters.go b/internal/store/model_adapters.go index 7a3b540..b42534d 100644 --- a/internal/store/model_adapters.go +++ b/internal/store/model_adapters.go @@ -81,342 +81,342 @@ func storedFileFromModel(m generatedmodels.ModelPublicStoredFiles) ext.StoredFil } } -func maintenanceTaskFromModel(m generatedmodels.ModelPublicMaintenanceTasks) ext.MaintenanceTask { - var frequencyDays *int - if m.FrequencyDays.Valid { - n := int(m.FrequencyDays.Int64()) - frequencyDays = &n - } +// func maintenanceTaskFromModel(m generatedmodels.ModelPublicMaintenanceTasks) ext.MaintenanceTask { +// var frequencyDays *int +// if m.FrequencyDays.Valid { +// n := int(m.FrequencyDays.Int64()) +// frequencyDays = &n +// } - var lastCompleted *time.Time - if m.LastCompleted.Valid { - t := m.LastCompleted.Time() - lastCompleted = &t - } +// var lastCompleted *time.Time +// if m.LastCompleted.Valid { +// t := m.LastCompleted.Time() +// lastCompleted = &t +// } - var nextDue *time.Time - if m.NextDue.Valid { - t := m.NextDue.Time() - nextDue = &t - } +// var nextDue *time.Time +// if m.NextDue.Valid { +// t := m.NextDue.Time() +// nextDue = &t +// } - return ext.MaintenanceTask{ - ID: m.ID.UUID(), - Name: m.Name.String(), - Category: m.Category.String(), - FrequencyDays: frequencyDays, - LastCompleted: lastCompleted, - NextDue: nextDue, - Priority: m.Priority.String(), - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - UpdatedAt: m.UpdatedAt.Time(), - } -} +// return ext.MaintenanceTask{ +// ID: m.ID.UUID(), +// Name: m.Name.String(), +// Category: m.Category.String(), +// FrequencyDays: frequencyDays, +// LastCompleted: lastCompleted, +// NextDue: nextDue, +// Priority: m.Priority.String(), +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// UpdatedAt: m.UpdatedAt.Time(), +// } +// } -func maintenanceLogFromModel(m generatedmodels.ModelPublicMaintenanceLogs) ext.MaintenanceLog { - var cost *float64 - if m.Cost.Valid { - v := m.Cost.Float64() - cost = &v - } +// func maintenanceLogFromModel(m generatedmodels.ModelPublicMaintenanceLogs) ext.MaintenanceLog { +// var cost *float64 +// if m.Cost.Valid { +// v := m.Cost.Float64() +// cost = &v +// } - return ext.MaintenanceLog{ - ID: m.ID.UUID(), - TaskID: m.TaskID.UUID(), - CompletedAt: m.CompletedAt.Time(), - PerformedBy: m.PerformedBy.String(), - Cost: cost, - Notes: m.Notes.String(), - NextAction: m.NextAction.String(), - } -} +// return ext.MaintenanceLog{ +// ID: m.ID.UUID(), +// TaskID: m.TaskID.UUID(), +// CompletedAt: m.CompletedAt.Time(), +// PerformedBy: m.PerformedBy.String(), +// Cost: cost, +// Notes: m.Notes.String(), +// NextAction: m.NextAction.String(), +// } +// } -func householdItemFromModel(m generatedmodels.ModelPublicHouseholdItems) ext.HouseholdItem { - details := map[string]any{} - if len(m.Details) > 0 { - if err := json.Unmarshal(m.Details, &details); err != nil { - details = map[string]any{} - } - } +// func householdItemFromModel(m generatedmodels.ModelPublicHouseholdItems) ext.HouseholdItem { +// details := map[string]any{} +// if len(m.Details) > 0 { +// if err := json.Unmarshal(m.Details, &details); err != nil { +// details = map[string]any{} +// } +// } - return ext.HouseholdItem{ - ID: m.ID.UUID(), - Name: m.Name.String(), - Category: m.Category.String(), - Location: m.Location.String(), - Details: details, - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - UpdatedAt: m.UpdatedAt.Time(), - } -} +// return ext.HouseholdItem{ +// ID: m.ID.UUID(), +// Name: m.Name.String(), +// Category: m.Category.String(), +// Location: m.Location.String(), +// Details: details, +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// UpdatedAt: m.UpdatedAt.Time(), +// } +// } -func householdVendorFromModel(m generatedmodels.ModelPublicHouseholdVendors) ext.HouseholdVendor { - var rating *int - if m.Rating.Valid { - v := int(m.Rating.Int64()) - rating = &v - } +// func householdVendorFromModel(m generatedmodels.ModelPublicHouseholdVendors) ext.HouseholdVendor { +// var rating *int +// if m.Rating.Valid { +// v := int(m.Rating.Int64()) +// rating = &v +// } - var lastUsed *time.Time - if m.LastUsed.Valid { - t := m.LastUsed.Time() - lastUsed = &t - } +// var lastUsed *time.Time +// if m.LastUsed.Valid { +// t := m.LastUsed.Time() +// lastUsed = &t +// } - return ext.HouseholdVendor{ - ID: m.ID.UUID(), - Name: m.Name.String(), - ServiceType: m.ServiceType.String(), - Phone: m.Phone.String(), - Email: m.Email.String(), - Website: m.Website.String(), - Notes: m.Notes.String(), - Rating: rating, - LastUsed: lastUsed, - CreatedAt: m.CreatedAt.Time(), - } -} +// return ext.HouseholdVendor{ +// ID: m.ID.UUID(), +// Name: m.Name.String(), +// ServiceType: m.ServiceType.String(), +// Phone: m.Phone.String(), +// Email: m.Email.String(), +// Website: m.Website.String(), +// Notes: m.Notes.String(), +// Rating: rating, +// LastUsed: lastUsed, +// CreatedAt: m.CreatedAt.Time(), +// } +// } -func familyMemberFromModel(m generatedmodels.ModelPublicFamilyMembers) ext.FamilyMember { - var birthDate *time.Time - if m.BirthDate.Valid { - t := m.BirthDate.Time() - birthDate = &t - } +// func familyMemberFromModel(m generatedmodels.ModelPublicFamilyMembers) ext.FamilyMember { +// var birthDate *time.Time +// if m.BirthDate.Valid { +// t := m.BirthDate.Time() +// birthDate = &t +// } - return ext.FamilyMember{ - ID: m.ID.UUID(), - Name: m.Name.String(), - Relationship: m.Relationship.String(), - BirthDate: birthDate, - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - } -} +// return ext.FamilyMember{ +// ID: m.ID.UUID(), +// Name: m.Name.String(), +// Relationship: m.Relationship.String(), +// BirthDate: birthDate, +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// } +// } -func activityFromModel(m generatedmodels.ModelPublicActivities, memberName string) ext.Activity { - var familyMemberID *uuid.UUID - if m.FamilyMemberID.Valid { - id := m.FamilyMemberID.UUID() - familyMemberID = &id - } +// func activityFromModel(m generatedmodels.ModelPublicActivities, memberName string) ext.Activity { +// var familyMemberID *uuid.UUID +// if m.FamilyMemberID.Valid { +// id := m.FamilyMemberID.UUID() +// familyMemberID = &id +// } - var startDate *time.Time - if m.StartDate.Valid { - t := m.StartDate.Time() - startDate = &t - } +// var startDate *time.Time +// if m.StartDate.Valid { +// t := m.StartDate.Time() +// startDate = &t +// } - var endDate *time.Time - if m.EndDate.Valid { - t := m.EndDate.Time() - endDate = &t - } +// var endDate *time.Time +// if m.EndDate.Valid { +// t := m.EndDate.Time() +// endDate = &t +// } - return ext.Activity{ - ID: m.ID.UUID(), - FamilyMemberID: familyMemberID, - MemberName: memberName, - Title: m.Title.String(), - ActivityType: m.ActivityType.String(), - DayOfWeek: m.DayOfWeek.String(), - StartTime: m.StartTime.String(), - EndTime: m.EndTime.String(), - StartDate: startDate, - EndDate: endDate, - Location: m.Location.String(), - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - } -} +// return ext.Activity{ +// ID: m.ID.UUID(), +// FamilyMemberID: familyMemberID, +// MemberName: memberName, +// Title: m.Title.String(), +// ActivityType: m.ActivityType.String(), +// DayOfWeek: m.DayOfWeek.String(), +// StartTime: m.StartTime.String(), +// EndTime: m.EndTime.String(), +// StartDate: startDate, +// EndDate: endDate, +// Location: m.Location.String(), +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// } +// } -func importantDateFromModel(m generatedmodels.ModelPublicImportantDates, memberName string) ext.ImportantDate { - var familyMemberID *uuid.UUID - if m.FamilyMemberID.Valid { - id := m.FamilyMemberID.UUID() - familyMemberID = &id - } +// func importantDateFromModel(m generatedmodels.ModelPublicImportantDates, memberName string) ext.ImportantDate { +// var familyMemberID *uuid.UUID +// if m.FamilyMemberID.Valid { +// id := m.FamilyMemberID.UUID() +// familyMemberID = &id +// } - return ext.ImportantDate{ - ID: m.ID.UUID(), - FamilyMemberID: familyMemberID, - MemberName: memberName, - Title: m.Title.String(), - DateValue: m.DateValue.Time(), - RecurringYearly: m.RecurringYearly, - ReminderDaysBefore: int(m.ReminderDaysBefore), - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - } -} +// return ext.ImportantDate{ +// ID: m.ID.UUID(), +// FamilyMemberID: familyMemberID, +// MemberName: memberName, +// Title: m.Title.String(), +// DateValue: m.DateValue.Time(), +// RecurringYearly: m.RecurringYearly, +// ReminderDaysBefore: int(m.ReminderDaysBefore), +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// } +// } -func professionalContactFromModel(m generatedmodels.ModelPublicProfessionalContacts, tags []string) ext.ProfessionalContact { - var lastContacted *time.Time - if m.LastContacted.Valid { - t := m.LastContacted.Time() - lastContacted = &t - } +// func professionalContactFromModel(m generatedmodels.ModelPublicProfessionalContacts, tags []string) ext.ProfessionalContact { +// var lastContacted *time.Time +// if m.LastContacted.Valid { +// t := m.LastContacted.Time() +// lastContacted = &t +// } - var followUpDate *time.Time - if m.FollowUpDate.Valid { - t := m.FollowUpDate.Time() - followUpDate = &t - } +// var followUpDate *time.Time +// if m.FollowUpDate.Valid { +// t := m.FollowUpDate.Time() +// followUpDate = &t +// } - return ext.ProfessionalContact{ - ID: m.ID.UUID(), - Name: m.Name.String(), - Company: m.Company.String(), - Title: m.Title.String(), - Email: m.Email.String(), - Phone: m.Phone.String(), - LinkedInURL: m.LinkedinURL.String(), - HowWeMet: m.HowWeMet.String(), - Tags: tags, - Notes: m.Notes.String(), - LastContacted: lastContacted, - FollowUpDate: followUpDate, - CreatedAt: m.CreatedAt.Time(), - UpdatedAt: m.UpdatedAt.Time(), - } -} +// return ext.ProfessionalContact{ +// ID: m.ID.UUID(), +// Name: m.Name.String(), +// Company: m.Company.String(), +// Title: m.Title.String(), +// Email: m.Email.String(), +// Phone: m.Phone.String(), +// LinkedInURL: m.LinkedinURL.String(), +// HowWeMet: m.HowWeMet.String(), +// Tags: tags, +// Notes: m.Notes.String(), +// LastContacted: lastContacted, +// FollowUpDate: followUpDate, +// CreatedAt: m.CreatedAt.Time(), +// UpdatedAt: m.UpdatedAt.Time(), +// } +// } -func contactInteractionFromModel(m generatedmodels.ModelPublicContactInteractions) ext.ContactInteraction { - return ext.ContactInteraction{ - ID: m.ID.UUID(), - ContactID: m.ContactID.UUID(), - InteractionType: m.InteractionType.String(), - OccurredAt: m.OccurredAt.Time(), - Summary: m.Summary.String(), - FollowUpNeeded: m.FollowUpNeeded, - FollowUpNotes: m.FollowUpNotes.String(), - CreatedAt: m.CreatedAt.Time(), - } -} +// func contactInteractionFromModel(m generatedmodels.ModelPublicContactInteractions) ext.ContactInteraction { +// return ext.ContactInteraction{ +// ID: m.ID.UUID(), +// ContactID: m.ContactID.UUID(), +// InteractionType: m.InteractionType.String(), +// OccurredAt: m.OccurredAt.Time(), +// Summary: m.Summary.String(), +// FollowUpNeeded: m.FollowUpNeeded, +// FollowUpNotes: m.FollowUpNotes.String(), +// CreatedAt: m.CreatedAt.Time(), +// } +// } -func opportunityFromModel(m generatedmodels.ModelPublicOpportunities) ext.Opportunity { - var contactID *uuid.UUID - if m.ContactID.Valid { - id := m.ContactID.UUID() - contactID = &id - } +// func opportunityFromModel(m generatedmodels.ModelPublicOpportunities) ext.Opportunity { +// var contactID *uuid.UUID +// if m.ContactID.Valid { +// id := m.ContactID.UUID() +// contactID = &id +// } - var value *float64 - if m.Value.Valid { - v := m.Value.Float64() - value = &v - } +// var value *float64 +// if m.Value.Valid { +// v := m.Value.Float64() +// value = &v +// } - var expectedCloseDate *time.Time - if m.ExpectedCloseDate.Valid { - t := m.ExpectedCloseDate.Time() - expectedCloseDate = &t - } +// var expectedCloseDate *time.Time +// if m.ExpectedCloseDate.Valid { +// t := m.ExpectedCloseDate.Time() +// expectedCloseDate = &t +// } - return ext.Opportunity{ - ID: m.ID.UUID(), - ContactID: contactID, - Title: m.Title.String(), - Description: m.Description.String(), - Stage: m.Stage.String(), - Value: value, - ExpectedCloseDate: expectedCloseDate, - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - UpdatedAt: m.UpdatedAt.Time(), - } -} +// return ext.Opportunity{ +// ID: m.ID.UUID(), +// ContactID: contactID, +// Title: m.Title.String(), +// Description: m.Description.String(), +// Stage: m.Stage.String(), +// Value: value, +// ExpectedCloseDate: expectedCloseDate, +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// UpdatedAt: m.UpdatedAt.Time(), +// } +// } -func recipeFromModel(m generatedmodels.ModelPublicRecipes, tags []string) ext.Recipe { - var prepTimeMinutes *int - if m.PrepTimeMinutes.Valid { - v := int(m.PrepTimeMinutes.Int64()) - prepTimeMinutes = &v - } +// func recipeFromModel(m generatedmodels.ModelPublicRecipes, tags []string) ext.Recipe { +// var prepTimeMinutes *int +// if m.PrepTimeMinutes.Valid { +// v := int(m.PrepTimeMinutes.Int64()) +// prepTimeMinutes = &v +// } - var cookTimeMinutes *int - if m.CookTimeMinutes.Valid { - v := int(m.CookTimeMinutes.Int64()) - cookTimeMinutes = &v - } +// var cookTimeMinutes *int +// if m.CookTimeMinutes.Valid { +// v := int(m.CookTimeMinutes.Int64()) +// cookTimeMinutes = &v +// } - var servings *int - if m.Servings.Valid { - v := int(m.Servings.Int64()) - servings = &v - } +// var servings *int +// if m.Servings.Valid { +// v := int(m.Servings.Int64()) +// servings = &v +// } - var rating *int - if m.Rating.Valid { - v := int(m.Rating.Int64()) - rating = &v - } +// var rating *int +// if m.Rating.Valid { +// v := int(m.Rating.Int64()) +// rating = &v +// } - recipe := ext.Recipe{ - ID: m.ID.UUID(), - Name: m.Name.String(), - Cuisine: m.Cuisine.String(), - PrepTimeMinutes: prepTimeMinutes, - CookTimeMinutes: cookTimeMinutes, - Servings: servings, - Tags: tags, - Rating: rating, - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - UpdatedAt: m.UpdatedAt.Time(), - } +// recipe := ext.Recipe{ +// ID: m.ID.UUID(), +// Name: m.Name.String(), +// Cuisine: m.Cuisine.String(), +// PrepTimeMinutes: prepTimeMinutes, +// CookTimeMinutes: cookTimeMinutes, +// Servings: servings, +// Tags: tags, +// Rating: rating, +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// UpdatedAt: m.UpdatedAt.Time(), +// } - if err := json.Unmarshal(m.Ingredients, &recipe.Ingredients); err != nil { - recipe.Ingredients = []ext.Ingredient{} - } - if err := json.Unmarshal(m.Instructions, &recipe.Instructions); err != nil { - recipe.Instructions = []string{} - } - return recipe -} +// if err := json.Unmarshal(m.Ingredients, &recipe.Ingredients); err != nil { +// recipe.Ingredients = []ext.Ingredient{} +// } +// if err := json.Unmarshal(m.Instructions, &recipe.Instructions); err != nil { +// recipe.Instructions = []string{} +// } +// return recipe +// } -func mealPlanEntryFromModel(m generatedmodels.ModelPublicMealPlans, recipeName string) ext.MealPlanEntry { - var recipeID *uuid.UUID - if m.RecipeID.Valid { - id := m.RecipeID.UUID() - recipeID = &id - } +// func mealPlanEntryFromModel(m generatedmodels.ModelPublicMealPlans, recipeName string) ext.MealPlanEntry { +// var recipeID *uuid.UUID +// if m.RecipeID.Valid { +// id := m.RecipeID.UUID() +// recipeID = &id +// } - var servings *int - if m.Servings.Valid { - v := int(m.Servings.Int64()) - servings = &v - } +// var servings *int +// if m.Servings.Valid { +// v := int(m.Servings.Int64()) +// servings = &v +// } - return ext.MealPlanEntry{ - ID: m.ID.UUID(), - WeekStart: m.WeekStart.Time(), - DayOfWeek: m.DayOfWeek.String(), - MealType: m.MealType.String(), - RecipeID: recipeID, - RecipeName: recipeName, - CustomMeal: m.CustomMeal.String(), - Servings: servings, - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - } -} +// return ext.MealPlanEntry{ +// ID: m.ID.UUID(), +// WeekStart: m.WeekStart.Time(), +// DayOfWeek: m.DayOfWeek.String(), +// MealType: m.MealType.String(), +// RecipeID: recipeID, +// RecipeName: recipeName, +// CustomMeal: m.CustomMeal.String(), +// Servings: servings, +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// } +// } -func shoppingListFromModel(m generatedmodels.ModelPublicShoppingLists) ext.ShoppingList { - list := ext.ShoppingList{ - ID: m.ID.UUID(), - WeekStart: m.WeekStart.Time(), - Notes: m.Notes.String(), - CreatedAt: m.CreatedAt.Time(), - UpdatedAt: m.UpdatedAt.Time(), - } - if err := json.Unmarshal(m.Items, &list.Items); err != nil { - list.Items = []ext.ShoppingItem{} - } - return list -} +// func shoppingListFromModel(m generatedmodels.ModelPublicShoppingLists) ext.ShoppingList { +// list := ext.ShoppingList{ +// ID: m.ID.UUID(), +// WeekStart: m.WeekStart.Time(), +// Notes: m.Notes.String(), +// CreatedAt: m.CreatedAt.Time(), +// UpdatedAt: m.UpdatedAt.Time(), +// } +// if err := json.Unmarshal(m.Items, &list.Items); err != nil { +// list.Items = []ext.ShoppingItem{} +// } +// return list +// } func planFromModel(m generatedmodels.ModelPublicPlans, tags []string) ext.Plan { var projectID *uuid.UUID diff --git a/internal/tools/calendar.go b/internal/tools/calendar.go index 348cf54..9f17a60 100644 --- a/internal/tools/calendar.go +++ b/internal/tools/calendar.go @@ -1,212 +1,212 @@ package tools -import ( - "context" - "strings" - "time" +// import ( +// "context" +// "strings" +// "time" - "github.com/google/uuid" - "github.com/modelcontextprotocol/go-sdk/mcp" +// "github.com/google/uuid" +// "github.com/modelcontextprotocol/go-sdk/mcp" - "git.warky.dev/wdevs/amcs/internal/store" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/store" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -type CalendarTool struct { - store *store.DB -} +// type CalendarTool struct { +// store *store.DB +// } -func NewCalendarTool(db *store.DB) *CalendarTool { - return &CalendarTool{store: db} -} +// func NewCalendarTool(db *store.DB) *CalendarTool { +// return &CalendarTool{store: db} +// } -// add_family_member +// // add_family_member -type AddFamilyMemberInput struct { - Name string `json:"name" jsonschema:"person's name"` - Relationship string `json:"relationship,omitempty" jsonschema:"e.g. self, spouse, child, parent"` - BirthDate *time.Time `json:"birth_date,omitempty"` - Notes string `json:"notes,omitempty"` -} +// type AddFamilyMemberInput struct { +// Name string `json:"name" jsonschema:"person's name"` +// Relationship string `json:"relationship,omitempty" jsonschema:"e.g. self, spouse, child, parent"` +// BirthDate *time.Time `json:"birth_date,omitempty"` +// Notes string `json:"notes,omitempty"` +// } -type AddFamilyMemberOutput struct { - Member ext.FamilyMember `json:"member"` -} +// type AddFamilyMemberOutput struct { +// Member ext.FamilyMember `json:"member"` +// } -func (t *CalendarTool) AddMember(ctx context.Context, _ *mcp.CallToolRequest, in AddFamilyMemberInput) (*mcp.CallToolResult, AddFamilyMemberOutput, error) { - if strings.TrimSpace(in.Name) == "" { - return nil, AddFamilyMemberOutput{}, errRequiredField("name") - } - member, err := t.store.AddFamilyMember(ctx, ext.FamilyMember{ - Name: strings.TrimSpace(in.Name), - Relationship: strings.TrimSpace(in.Relationship), - BirthDate: in.BirthDate, - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, AddFamilyMemberOutput{}, err - } - return nil, AddFamilyMemberOutput{Member: member}, nil -} +// func (t *CalendarTool) AddMember(ctx context.Context, _ *mcp.CallToolRequest, in AddFamilyMemberInput) (*mcp.CallToolResult, AddFamilyMemberOutput, error) { +// if strings.TrimSpace(in.Name) == "" { +// return nil, AddFamilyMemberOutput{}, errRequiredField("name") +// } +// member, err := t.store.AddFamilyMember(ctx, ext.FamilyMember{ +// Name: strings.TrimSpace(in.Name), +// Relationship: strings.TrimSpace(in.Relationship), +// BirthDate: in.BirthDate, +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, AddFamilyMemberOutput{}, err +// } +// return nil, AddFamilyMemberOutput{Member: member}, nil +// } -// list_family_members +// // list_family_members -type ListFamilyMembersInput struct{} +// type ListFamilyMembersInput struct{} -type ListFamilyMembersOutput struct { - Members []ext.FamilyMember `json:"members"` -} +// type ListFamilyMembersOutput struct { +// Members []ext.FamilyMember `json:"members"` +// } -func (t *CalendarTool) ListMembers(ctx context.Context, _ *mcp.CallToolRequest, _ ListFamilyMembersInput) (*mcp.CallToolResult, ListFamilyMembersOutput, error) { - members, err := t.store.ListFamilyMembers(ctx) - if err != nil { - return nil, ListFamilyMembersOutput{}, err - } - if members == nil { - members = []ext.FamilyMember{} - } - return nil, ListFamilyMembersOutput{Members: members}, nil -} +// func (t *CalendarTool) ListMembers(ctx context.Context, _ *mcp.CallToolRequest, _ ListFamilyMembersInput) (*mcp.CallToolResult, ListFamilyMembersOutput, error) { +// members, err := t.store.ListFamilyMembers(ctx) +// if err != nil { +// return nil, ListFamilyMembersOutput{}, err +// } +// if members == nil { +// members = []ext.FamilyMember{} +// } +// return nil, ListFamilyMembersOutput{Members: members}, nil +// } -// add_activity +// // add_activity -type AddActivityInput struct { - Title string `json:"title" jsonschema:"activity title"` - ActivityType string `json:"activity_type,omitempty" jsonschema:"e.g. sports, medical, school, social"` - FamilyMemberID *uuid.UUID `json:"family_member_id,omitempty" jsonschema:"leave empty for whole-family activities"` - DayOfWeek string `json:"day_of_week,omitempty" jsonschema:"for recurring: monday, tuesday, etc."` - StartTime string `json:"start_time,omitempty" jsonschema:"HH:MM format"` - EndTime string `json:"end_time,omitempty" jsonschema:"HH:MM format"` - StartDate *time.Time `json:"start_date,omitempty"` - EndDate *time.Time `json:"end_date,omitempty" jsonschema:"for recurring activities, when they end"` - Location string `json:"location,omitempty"` - Notes string `json:"notes,omitempty"` -} +// type AddActivityInput struct { +// Title string `json:"title" jsonschema:"activity title"` +// ActivityType string `json:"activity_type,omitempty" jsonschema:"e.g. sports, medical, school, social"` +// FamilyMemberID *uuid.UUID `json:"family_member_id,omitempty" jsonschema:"leave empty for whole-family activities"` +// DayOfWeek string `json:"day_of_week,omitempty" jsonschema:"for recurring: monday, tuesday, etc."` +// StartTime string `json:"start_time,omitempty" jsonschema:"HH:MM format"` +// EndTime string `json:"end_time,omitempty" jsonschema:"HH:MM format"` +// StartDate *time.Time `json:"start_date,omitempty"` +// EndDate *time.Time `json:"end_date,omitempty" jsonschema:"for recurring activities, when they end"` +// Location string `json:"location,omitempty"` +// Notes string `json:"notes,omitempty"` +// } -type AddActivityOutput struct { - Activity ext.Activity `json:"activity"` -} +// type AddActivityOutput struct { +// Activity ext.Activity `json:"activity"` +// } -func (t *CalendarTool) AddActivity(ctx context.Context, _ *mcp.CallToolRequest, in AddActivityInput) (*mcp.CallToolResult, AddActivityOutput, error) { - if strings.TrimSpace(in.Title) == "" { - return nil, AddActivityOutput{}, errRequiredField("title") - } - activity, err := t.store.AddActivity(ctx, ext.Activity{ - FamilyMemberID: in.FamilyMemberID, - Title: strings.TrimSpace(in.Title), - ActivityType: strings.TrimSpace(in.ActivityType), - DayOfWeek: strings.ToLower(strings.TrimSpace(in.DayOfWeek)), - StartTime: strings.TrimSpace(in.StartTime), - EndTime: strings.TrimSpace(in.EndTime), - StartDate: in.StartDate, - EndDate: in.EndDate, - Location: strings.TrimSpace(in.Location), - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, AddActivityOutput{}, err - } - return nil, AddActivityOutput{Activity: activity}, nil -} +// func (t *CalendarTool) AddActivity(ctx context.Context, _ *mcp.CallToolRequest, in AddActivityInput) (*mcp.CallToolResult, AddActivityOutput, error) { +// if strings.TrimSpace(in.Title) == "" { +// return nil, AddActivityOutput{}, errRequiredField("title") +// } +// activity, err := t.store.AddActivity(ctx, ext.Activity{ +// FamilyMemberID: in.FamilyMemberID, +// Title: strings.TrimSpace(in.Title), +// ActivityType: strings.TrimSpace(in.ActivityType), +// DayOfWeek: strings.ToLower(strings.TrimSpace(in.DayOfWeek)), +// StartTime: strings.TrimSpace(in.StartTime), +// EndTime: strings.TrimSpace(in.EndTime), +// StartDate: in.StartDate, +// EndDate: in.EndDate, +// Location: strings.TrimSpace(in.Location), +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, AddActivityOutput{}, err +// } +// return nil, AddActivityOutput{Activity: activity}, nil +// } -// get_week_schedule +// // get_week_schedule -type GetWeekScheduleInput struct { - WeekStart time.Time `json:"week_start" jsonschema:"start of the week (Monday) to retrieve"` -} +// type GetWeekScheduleInput struct { +// WeekStart time.Time `json:"week_start" jsonschema:"start of the week (Monday) to retrieve"` +// } -type GetWeekScheduleOutput struct { - Activities []ext.Activity `json:"activities"` -} +// type GetWeekScheduleOutput struct { +// Activities []ext.Activity `json:"activities"` +// } -func (t *CalendarTool) GetWeekSchedule(ctx context.Context, _ *mcp.CallToolRequest, in GetWeekScheduleInput) (*mcp.CallToolResult, GetWeekScheduleOutput, error) { - activities, err := t.store.GetWeekSchedule(ctx, in.WeekStart) - if err != nil { - return nil, GetWeekScheduleOutput{}, err - } - if activities == nil { - activities = []ext.Activity{} - } - return nil, GetWeekScheduleOutput{Activities: activities}, nil -} +// func (t *CalendarTool) GetWeekSchedule(ctx context.Context, _ *mcp.CallToolRequest, in GetWeekScheduleInput) (*mcp.CallToolResult, GetWeekScheduleOutput, error) { +// activities, err := t.store.GetWeekSchedule(ctx, in.WeekStart) +// if err != nil { +// return nil, GetWeekScheduleOutput{}, err +// } +// if activities == nil { +// activities = []ext.Activity{} +// } +// return nil, GetWeekScheduleOutput{Activities: activities}, nil +// } -// search_activities +// // search_activities -type SearchActivitiesInput struct { - Query string `json:"query,omitempty" jsonschema:"search text matching title or notes"` - ActivityType string `json:"activity_type,omitempty" jsonschema:"filter by type"` - FamilyMemberID *uuid.UUID `json:"family_member_id,omitempty" jsonschema:"filter by family member"` -} +// type SearchActivitiesInput struct { +// Query string `json:"query,omitempty" jsonschema:"search text matching title or notes"` +// ActivityType string `json:"activity_type,omitempty" jsonschema:"filter by type"` +// FamilyMemberID *uuid.UUID `json:"family_member_id,omitempty" jsonschema:"filter by family member"` +// } -type SearchActivitiesOutput struct { - Activities []ext.Activity `json:"activities"` -} +// type SearchActivitiesOutput struct { +// Activities []ext.Activity `json:"activities"` +// } -func (t *CalendarTool) SearchActivities(ctx context.Context, _ *mcp.CallToolRequest, in SearchActivitiesInput) (*mcp.CallToolResult, SearchActivitiesOutput, error) { - activities, err := t.store.SearchActivities(ctx, in.Query, in.ActivityType, in.FamilyMemberID) - if err != nil { - return nil, SearchActivitiesOutput{}, err - } - if activities == nil { - activities = []ext.Activity{} - } - return nil, SearchActivitiesOutput{Activities: activities}, nil -} +// func (t *CalendarTool) SearchActivities(ctx context.Context, _ *mcp.CallToolRequest, in SearchActivitiesInput) (*mcp.CallToolResult, SearchActivitiesOutput, error) { +// activities, err := t.store.SearchActivities(ctx, in.Query, in.ActivityType, in.FamilyMemberID) +// if err != nil { +// return nil, SearchActivitiesOutput{}, err +// } +// if activities == nil { +// activities = []ext.Activity{} +// } +// return nil, SearchActivitiesOutput{Activities: activities}, nil +// } -// add_important_date +// // add_important_date -type AddImportantDateInput struct { - Title string `json:"title" jsonschema:"description of the date"` - DateValue time.Time `json:"date_value" jsonschema:"the date"` - FamilyMemberID *uuid.UUID `json:"family_member_id,omitempty"` - RecurringYearly bool `json:"recurring_yearly,omitempty" jsonschema:"if true, reminds every year"` - ReminderDaysBefore int `json:"reminder_days_before,omitempty" jsonschema:"how many days before to remind (default: 7)"` - Notes string `json:"notes,omitempty"` -} +// type AddImportantDateInput struct { +// Title string `json:"title" jsonschema:"description of the date"` +// DateValue time.Time `json:"date_value" jsonschema:"the date"` +// FamilyMemberID *uuid.UUID `json:"family_member_id,omitempty"` +// RecurringYearly bool `json:"recurring_yearly,omitempty" jsonschema:"if true, reminds every year"` +// ReminderDaysBefore int `json:"reminder_days_before,omitempty" jsonschema:"how many days before to remind (default: 7)"` +// Notes string `json:"notes,omitempty"` +// } -type AddImportantDateOutput struct { - Date ext.ImportantDate `json:"date"` -} +// type AddImportantDateOutput struct { +// Date ext.ImportantDate `json:"date"` +// } -func (t *CalendarTool) AddImportantDate(ctx context.Context, _ *mcp.CallToolRequest, in AddImportantDateInput) (*mcp.CallToolResult, AddImportantDateOutput, error) { - if strings.TrimSpace(in.Title) == "" { - return nil, AddImportantDateOutput{}, errRequiredField("title") - } - reminder := in.ReminderDaysBefore - if reminder <= 0 { - reminder = 7 - } - d, err := t.store.AddImportantDate(ctx, ext.ImportantDate{ - FamilyMemberID: in.FamilyMemberID, - Title: strings.TrimSpace(in.Title), - DateValue: in.DateValue, - RecurringYearly: in.RecurringYearly, - ReminderDaysBefore: reminder, - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, AddImportantDateOutput{}, err - } - return nil, AddImportantDateOutput{Date: d}, nil -} +// func (t *CalendarTool) AddImportantDate(ctx context.Context, _ *mcp.CallToolRequest, in AddImportantDateInput) (*mcp.CallToolResult, AddImportantDateOutput, error) { +// if strings.TrimSpace(in.Title) == "" { +// return nil, AddImportantDateOutput{}, errRequiredField("title") +// } +// reminder := in.ReminderDaysBefore +// if reminder <= 0 { +// reminder = 7 +// } +// d, err := t.store.AddImportantDate(ctx, ext.ImportantDate{ +// FamilyMemberID: in.FamilyMemberID, +// Title: strings.TrimSpace(in.Title), +// DateValue: in.DateValue, +// RecurringYearly: in.RecurringYearly, +// ReminderDaysBefore: reminder, +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, AddImportantDateOutput{}, err +// } +// return nil, AddImportantDateOutput{Date: d}, nil +// } -// get_upcoming_dates +// // get_upcoming_dates -type GetUpcomingDatesInput struct { - DaysAhead int `json:"days_ahead,omitempty" jsonschema:"how many days to look ahead (default: 30)"` -} +// type GetUpcomingDatesInput struct { +// DaysAhead int `json:"days_ahead,omitempty" jsonschema:"how many days to look ahead (default: 30)"` +// } -type GetUpcomingDatesOutput struct { - Dates []ext.ImportantDate `json:"dates"` -} +// type GetUpcomingDatesOutput struct { +// Dates []ext.ImportantDate `json:"dates"` +// } -func (t *CalendarTool) GetUpcomingDates(ctx context.Context, _ *mcp.CallToolRequest, in GetUpcomingDatesInput) (*mcp.CallToolResult, GetUpcomingDatesOutput, error) { - dates, err := t.store.GetUpcomingDates(ctx, in.DaysAhead) - if err != nil { - return nil, GetUpcomingDatesOutput{}, err - } - if dates == nil { - dates = []ext.ImportantDate{} - } - return nil, GetUpcomingDatesOutput{Dates: dates}, nil -} +// func (t *CalendarTool) GetUpcomingDates(ctx context.Context, _ *mcp.CallToolRequest, in GetUpcomingDatesInput) (*mcp.CallToolResult, GetUpcomingDatesOutput, error) { +// dates, err := t.store.GetUpcomingDates(ctx, in.DaysAhead) +// if err != nil { +// return nil, GetUpcomingDatesOutput{}, err +// } +// if dates == nil { +// dates = []ext.ImportantDate{} +// } +// return nil, GetUpcomingDatesOutput{Dates: dates}, nil +// } diff --git a/internal/tools/crm.go b/internal/tools/crm.go index 861feb7..605a78e 100644 --- a/internal/tools/crm.go +++ b/internal/tools/crm.go @@ -1,240 +1,240 @@ package tools -import ( - "context" - "errors" - "fmt" - "strings" - "time" +// import ( +// "context" +// "errors" +// "fmt" +// "strings" +// "time" - "github.com/google/uuid" - "github.com/jackc/pgx/v5" - "github.com/modelcontextprotocol/go-sdk/mcp" +// "github.com/google/uuid" +// "github.com/jackc/pgx/v5" +// "github.com/modelcontextprotocol/go-sdk/mcp" - "git.warky.dev/wdevs/amcs/internal/store" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/store" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -type CRMTool struct { - store *store.DB -} +// type CRMTool struct { +// store *store.DB +// } -func NewCRMTool(db *store.DB) *CRMTool { - return &CRMTool{store: db} -} +// func NewCRMTool(db *store.DB) *CRMTool { +// return &CRMTool{store: db} +// } -// add_professional_contact +// // add_professional_contact -type AddContactInput struct { - Name string `json:"name" jsonschema:"contact's full name"` - Company string `json:"company,omitempty"` - Title string `json:"title,omitempty" jsonschema:"job title"` - Email string `json:"email,omitempty"` - Phone string `json:"phone,omitempty"` - LinkedInURL string `json:"linkedin_url,omitempty"` - HowWeMet string `json:"how_we_met,omitempty"` - Tags []string `json:"tags,omitempty"` - Notes string `json:"notes,omitempty"` - FollowUpDate *time.Time `json:"follow_up_date,omitempty"` -} +// type AddContactInput struct { +// Name string `json:"name" jsonschema:"contact's full name"` +// Company string `json:"company,omitempty"` +// Title string `json:"title,omitempty" jsonschema:"job title"` +// Email string `json:"email,omitempty"` +// Phone string `json:"phone,omitempty"` +// LinkedInURL string `json:"linkedin_url,omitempty"` +// HowWeMet string `json:"how_we_met,omitempty"` +// Tags []string `json:"tags,omitempty"` +// Notes string `json:"notes,omitempty"` +// FollowUpDate *time.Time `json:"follow_up_date,omitempty"` +// } -type AddContactOutput struct { - Contact ext.ProfessionalContact `json:"contact"` -} +// type AddContactOutput struct { +// Contact ext.ProfessionalContact `json:"contact"` +// } -func (t *CRMTool) AddContact(ctx context.Context, _ *mcp.CallToolRequest, in AddContactInput) (*mcp.CallToolResult, AddContactOutput, error) { - if strings.TrimSpace(in.Name) == "" { - return nil, AddContactOutput{}, errRequiredField("name") - } - if in.Tags == nil { - in.Tags = []string{} - } - contact, err := t.store.AddProfessionalContact(ctx, ext.ProfessionalContact{ - Name: strings.TrimSpace(in.Name), - Company: strings.TrimSpace(in.Company), - Title: strings.TrimSpace(in.Title), - Email: strings.TrimSpace(in.Email), - Phone: strings.TrimSpace(in.Phone), - LinkedInURL: strings.TrimSpace(in.LinkedInURL), - HowWeMet: strings.TrimSpace(in.HowWeMet), - Tags: in.Tags, - Notes: strings.TrimSpace(in.Notes), - FollowUpDate: in.FollowUpDate, - }) - if err != nil { - return nil, AddContactOutput{}, err - } - return nil, AddContactOutput{Contact: contact}, nil -} +// func (t *CRMTool) AddContact(ctx context.Context, _ *mcp.CallToolRequest, in AddContactInput) (*mcp.CallToolResult, AddContactOutput, error) { +// if strings.TrimSpace(in.Name) == "" { +// return nil, AddContactOutput{}, errRequiredField("name") +// } +// if in.Tags == nil { +// in.Tags = []string{} +// } +// contact, err := t.store.AddProfessionalContact(ctx, ext.ProfessionalContact{ +// Name: strings.TrimSpace(in.Name), +// Company: strings.TrimSpace(in.Company), +// Title: strings.TrimSpace(in.Title), +// Email: strings.TrimSpace(in.Email), +// Phone: strings.TrimSpace(in.Phone), +// LinkedInURL: strings.TrimSpace(in.LinkedInURL), +// HowWeMet: strings.TrimSpace(in.HowWeMet), +// Tags: in.Tags, +// Notes: strings.TrimSpace(in.Notes), +// FollowUpDate: in.FollowUpDate, +// }) +// if err != nil { +// return nil, AddContactOutput{}, err +// } +// return nil, AddContactOutput{Contact: contact}, nil +// } -// search_contacts +// // search_contacts -type SearchContactsInput struct { - Query string `json:"query,omitempty" jsonschema:"search text matching name, company, title, or notes"` - Tags []string `json:"tags,omitempty" jsonschema:"filter by tags (all must match)"` -} +// type SearchContactsInput struct { +// Query string `json:"query,omitempty" jsonschema:"search text matching name, company, title, or notes"` +// Tags []string `json:"tags,omitempty" jsonschema:"filter by tags (all must match)"` +// } -type SearchContactsOutput struct { - Contacts []ext.ProfessionalContact `json:"contacts"` -} +// type SearchContactsOutput struct { +// Contacts []ext.ProfessionalContact `json:"contacts"` +// } -func (t *CRMTool) SearchContacts(ctx context.Context, _ *mcp.CallToolRequest, in SearchContactsInput) (*mcp.CallToolResult, SearchContactsOutput, error) { - contacts, err := t.store.SearchContacts(ctx, in.Query, in.Tags) - if err != nil { - return nil, SearchContactsOutput{}, err - } - if contacts == nil { - contacts = []ext.ProfessionalContact{} - } - return nil, SearchContactsOutput{Contacts: contacts}, nil -} +// func (t *CRMTool) SearchContacts(ctx context.Context, _ *mcp.CallToolRequest, in SearchContactsInput) (*mcp.CallToolResult, SearchContactsOutput, error) { +// contacts, err := t.store.SearchContacts(ctx, in.Query, in.Tags) +// if err != nil { +// return nil, SearchContactsOutput{}, err +// } +// if contacts == nil { +// contacts = []ext.ProfessionalContact{} +// } +// return nil, SearchContactsOutput{Contacts: contacts}, nil +// } -// log_interaction +// // log_interaction -type LogInteractionInput struct { - ContactID uuid.UUID `json:"contact_id" jsonschema:"id of the contact"` - InteractionType string `json:"interaction_type" jsonschema:"one of: meeting, email, call, coffee, event, linkedin, other"` - OccurredAt *time.Time `json:"occurred_at,omitempty" jsonschema:"when it happened (defaults to now)"` - Summary string `json:"summary" jsonschema:"summary of the interaction"` - FollowUpNeeded bool `json:"follow_up_needed,omitempty"` - FollowUpNotes string `json:"follow_up_notes,omitempty"` -} +// type LogInteractionInput struct { +// ContactID uuid.UUID `json:"contact_id" jsonschema:"id of the contact"` +// InteractionType string `json:"interaction_type" jsonschema:"one of: meeting, email, call, coffee, event, linkedin, other"` +// OccurredAt *time.Time `json:"occurred_at,omitempty" jsonschema:"when it happened (defaults to now)"` +// Summary string `json:"summary" jsonschema:"summary of the interaction"` +// FollowUpNeeded bool `json:"follow_up_needed,omitempty"` +// FollowUpNotes string `json:"follow_up_notes,omitempty"` +// } -type LogInteractionOutput struct { - Interaction ext.ContactInteraction `json:"interaction"` -} +// type LogInteractionOutput struct { +// Interaction ext.ContactInteraction `json:"interaction"` +// } -func (t *CRMTool) LogInteraction(ctx context.Context, _ *mcp.CallToolRequest, in LogInteractionInput) (*mcp.CallToolResult, LogInteractionOutput, error) { - if strings.TrimSpace(in.Summary) == "" { - return nil, LogInteractionOutput{}, errRequiredField("summary") - } - occurredAt := time.Now() - if in.OccurredAt != nil { - occurredAt = *in.OccurredAt - } - interaction, err := t.store.LogInteraction(ctx, ext.ContactInteraction{ - ContactID: in.ContactID, - InteractionType: in.InteractionType, - OccurredAt: occurredAt, - Summary: strings.TrimSpace(in.Summary), - FollowUpNeeded: in.FollowUpNeeded, - FollowUpNotes: strings.TrimSpace(in.FollowUpNotes), - }) - if err != nil { - return nil, LogInteractionOutput{}, err - } - return nil, LogInteractionOutput{Interaction: interaction}, nil -} +// func (t *CRMTool) LogInteraction(ctx context.Context, _ *mcp.CallToolRequest, in LogInteractionInput) (*mcp.CallToolResult, LogInteractionOutput, error) { +// if strings.TrimSpace(in.Summary) == "" { +// return nil, LogInteractionOutput{}, errRequiredField("summary") +// } +// occurredAt := time.Now() +// if in.OccurredAt != nil { +// occurredAt = *in.OccurredAt +// } +// interaction, err := t.store.LogInteraction(ctx, ext.ContactInteraction{ +// ContactID: in.ContactID, +// InteractionType: in.InteractionType, +// OccurredAt: occurredAt, +// Summary: strings.TrimSpace(in.Summary), +// FollowUpNeeded: in.FollowUpNeeded, +// FollowUpNotes: strings.TrimSpace(in.FollowUpNotes), +// }) +// if err != nil { +// return nil, LogInteractionOutput{}, err +// } +// return nil, LogInteractionOutput{Interaction: interaction}, nil +// } -// get_contact_history +// // get_contact_history -type GetContactHistoryInput struct { - ContactID uuid.UUID `json:"contact_id" jsonschema:"id of the contact"` -} +// type GetContactHistoryInput struct { +// ContactID uuid.UUID `json:"contact_id" jsonschema:"id of the contact"` +// } -type GetContactHistoryOutput struct { - History ext.ContactHistory `json:"history"` -} +// type GetContactHistoryOutput struct { +// History ext.ContactHistory `json:"history"` +// } -func (t *CRMTool) GetHistory(ctx context.Context, _ *mcp.CallToolRequest, in GetContactHistoryInput) (*mcp.CallToolResult, GetContactHistoryOutput, error) { - history, err := t.store.GetContactHistory(ctx, in.ContactID) - if err != nil { - return nil, GetContactHistoryOutput{}, err - } - return nil, GetContactHistoryOutput{History: history}, nil -} +// func (t *CRMTool) GetHistory(ctx context.Context, _ *mcp.CallToolRequest, in GetContactHistoryInput) (*mcp.CallToolResult, GetContactHistoryOutput, error) { +// history, err := t.store.GetContactHistory(ctx, in.ContactID) +// if err != nil { +// return nil, GetContactHistoryOutput{}, err +// } +// return nil, GetContactHistoryOutput{History: history}, nil +// } -// create_opportunity +// // create_opportunity -type CreateOpportunityInput struct { - ContactID *uuid.UUID `json:"contact_id,omitempty"` - Title string `json:"title" jsonschema:"opportunity title"` - Description string `json:"description,omitempty"` - Stage string `json:"stage,omitempty" jsonschema:"one of: identified, in_conversation, proposal, negotiation, won, lost (default: identified)"` - Value *float64 `json:"value,omitempty" jsonschema:"monetary value"` - ExpectedCloseDate *time.Time `json:"expected_close_date,omitempty"` - Notes string `json:"notes,omitempty"` -} +// type CreateOpportunityInput struct { +// ContactID *uuid.UUID `json:"contact_id,omitempty"` +// Title string `json:"title" jsonschema:"opportunity title"` +// Description string `json:"description,omitempty"` +// Stage string `json:"stage,omitempty" jsonschema:"one of: identified, in_conversation, proposal, negotiation, won, lost (default: identified)"` +// Value *float64 `json:"value,omitempty" jsonschema:"monetary value"` +// ExpectedCloseDate *time.Time `json:"expected_close_date,omitempty"` +// Notes string `json:"notes,omitempty"` +// } -type CreateOpportunityOutput struct { - Opportunity ext.Opportunity `json:"opportunity"` -} +// type CreateOpportunityOutput struct { +// Opportunity ext.Opportunity `json:"opportunity"` +// } -func (t *CRMTool) CreateOpportunity(ctx context.Context, _ *mcp.CallToolRequest, in CreateOpportunityInput) (*mcp.CallToolResult, CreateOpportunityOutput, error) { - if strings.TrimSpace(in.Title) == "" { - return nil, CreateOpportunityOutput{}, errRequiredField("title") - } - stage := strings.TrimSpace(in.Stage) - if stage == "" { - stage = "identified" - } - opp, err := t.store.CreateOpportunity(ctx, ext.Opportunity{ - ContactID: in.ContactID, - Title: strings.TrimSpace(in.Title), - Description: strings.TrimSpace(in.Description), - Stage: stage, - Value: in.Value, - ExpectedCloseDate: in.ExpectedCloseDate, - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, CreateOpportunityOutput{}, err - } - return nil, CreateOpportunityOutput{Opportunity: opp}, nil -} +// func (t *CRMTool) CreateOpportunity(ctx context.Context, _ *mcp.CallToolRequest, in CreateOpportunityInput) (*mcp.CallToolResult, CreateOpportunityOutput, error) { +// if strings.TrimSpace(in.Title) == "" { +// return nil, CreateOpportunityOutput{}, errRequiredField("title") +// } +// stage := strings.TrimSpace(in.Stage) +// if stage == "" { +// stage = "identified" +// } +// opp, err := t.store.CreateOpportunity(ctx, ext.Opportunity{ +// ContactID: in.ContactID, +// Title: strings.TrimSpace(in.Title), +// Description: strings.TrimSpace(in.Description), +// Stage: stage, +// Value: in.Value, +// ExpectedCloseDate: in.ExpectedCloseDate, +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, CreateOpportunityOutput{}, err +// } +// return nil, CreateOpportunityOutput{Opportunity: opp}, nil +// } -// get_follow_ups_due +// // get_follow_ups_due -type GetFollowUpsDueInput struct { - DaysAhead int `json:"days_ahead,omitempty" jsonschema:"look ahead window in days (default: 7)"` -} +// type GetFollowUpsDueInput struct { +// DaysAhead int `json:"days_ahead,omitempty" jsonschema:"look ahead window in days (default: 7)"` +// } -type GetFollowUpsDueOutput struct { - Contacts []ext.ProfessionalContact `json:"contacts"` -} +// type GetFollowUpsDueOutput struct { +// Contacts []ext.ProfessionalContact `json:"contacts"` +// } -func (t *CRMTool) GetFollowUpsDue(ctx context.Context, _ *mcp.CallToolRequest, in GetFollowUpsDueInput) (*mcp.CallToolResult, GetFollowUpsDueOutput, error) { - contacts, err := t.store.GetFollowUpsDue(ctx, in.DaysAhead) - if err != nil { - return nil, GetFollowUpsDueOutput{}, err - } - if contacts == nil { - contacts = []ext.ProfessionalContact{} - } - return nil, GetFollowUpsDueOutput{Contacts: contacts}, nil -} +// func (t *CRMTool) GetFollowUpsDue(ctx context.Context, _ *mcp.CallToolRequest, in GetFollowUpsDueInput) (*mcp.CallToolResult, GetFollowUpsDueOutput, error) { +// contacts, err := t.store.GetFollowUpsDue(ctx, in.DaysAhead) +// if err != nil { +// return nil, GetFollowUpsDueOutput{}, err +// } +// if contacts == nil { +// contacts = []ext.ProfessionalContact{} +// } +// return nil, GetFollowUpsDueOutput{Contacts: contacts}, nil +// } -// link_thought_to_contact +// // link_thought_to_contact -type LinkThoughtToContactInput struct { - ContactID uuid.UUID `json:"contact_id" jsonschema:"id of the contact"` - ThoughtID uuid.UUID `json:"thought_id" jsonschema:"id of the thought to link"` -} +// type LinkThoughtToContactInput struct { +// ContactID uuid.UUID `json:"contact_id" jsonschema:"id of the contact"` +// ThoughtID uuid.UUID `json:"thought_id" jsonschema:"id of the thought to link"` +// } -type LinkThoughtToContactOutput struct { - Contact ext.ProfessionalContact `json:"contact"` -} +// type LinkThoughtToContactOutput struct { +// Contact ext.ProfessionalContact `json:"contact"` +// } -func (t *CRMTool) LinkThought(ctx context.Context, _ *mcp.CallToolRequest, in LinkThoughtToContactInput) (*mcp.CallToolResult, LinkThoughtToContactOutput, error) { - thought, err := t.store.GetThought(ctx, in.ThoughtID) - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - return nil, LinkThoughtToContactOutput{}, errEntityNotFound("thought", "thought_id", in.ThoughtID.String()) - } - return nil, LinkThoughtToContactOutput{}, err - } +// func (t *CRMTool) LinkThought(ctx context.Context, _ *mcp.CallToolRequest, in LinkThoughtToContactInput) (*mcp.CallToolResult, LinkThoughtToContactOutput, error) { +// thought, err := t.store.GetThought(ctx, in.ThoughtID) +// if err != nil { +// if errors.Is(err, pgx.ErrNoRows) { +// return nil, LinkThoughtToContactOutput{}, errEntityNotFound("thought", "thought_id", in.ThoughtID.String()) +// } +// return nil, LinkThoughtToContactOutput{}, err +// } - appendText := fmt.Sprintf("\n\n[Linked thought %s]: %s", thought.ID, thought.Content) - if err := t.store.AppendThoughtToContactNotes(ctx, in.ContactID, appendText); err != nil { - return nil, LinkThoughtToContactOutput{}, err - } +// appendText := fmt.Sprintf("\n\n[Linked thought %s]: %s", thought.ID, thought.Content) +// if err := t.store.AppendThoughtToContactNotes(ctx, in.ContactID, appendText); err != nil { +// return nil, LinkThoughtToContactOutput{}, err +// } - contact, err := t.store.GetContact(ctx, in.ContactID) - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - return nil, LinkThoughtToContactOutput{}, errEntityNotFound("contact", "contact_id", in.ContactID.String()) - } - return nil, LinkThoughtToContactOutput{}, err - } - return nil, LinkThoughtToContactOutput{Contact: contact}, nil -} +// contact, err := t.store.GetContact(ctx, in.ContactID) +// if err != nil { +// if errors.Is(err, pgx.ErrNoRows) { +// return nil, LinkThoughtToContactOutput{}, errEntityNotFound("contact", "contact_id", in.ContactID.String()) +// } +// return nil, LinkThoughtToContactOutput{}, err +// } +// return nil, LinkThoughtToContactOutput{Contact: contact}, nil +// } diff --git a/internal/tools/household.go b/internal/tools/household.go index ff90dfc..a4634c2 100644 --- a/internal/tools/household.go +++ b/internal/tools/household.go @@ -1,151 +1,151 @@ package tools -import ( - "context" - "strings" +// import ( +// "context" +// "strings" - "github.com/google/uuid" - "github.com/modelcontextprotocol/go-sdk/mcp" +// "github.com/google/uuid" +// "github.com/modelcontextprotocol/go-sdk/mcp" - "git.warky.dev/wdevs/amcs/internal/store" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/store" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -type HouseholdTool struct { - store *store.DB -} +// type HouseholdTool struct { +// store *store.DB +// } -func NewHouseholdTool(db *store.DB) *HouseholdTool { - return &HouseholdTool{store: db} -} +// func NewHouseholdTool(db *store.DB) *HouseholdTool { +// return &HouseholdTool{store: db} +// } -// add_household_item +// // add_household_item -type AddHouseholdItemInput struct { - Name string `json:"name" jsonschema:"name of the item"` - Category string `json:"category,omitempty" jsonschema:"category (e.g. paint, appliance, measurement, document)"` - Location string `json:"location,omitempty" jsonschema:"where in the home this item is"` - Details map[string]any `json:"details,omitempty" jsonschema:"flexible metadata (model numbers, colors, specs, etc.)"` - Notes string `json:"notes,omitempty"` -} +// type AddHouseholdItemInput struct { +// Name string `json:"name" jsonschema:"name of the item"` +// Category string `json:"category,omitempty" jsonschema:"category (e.g. paint, appliance, measurement, document)"` +// Location string `json:"location,omitempty" jsonschema:"where in the home this item is"` +// Details map[string]any `json:"details,omitempty" jsonschema:"flexible metadata (model numbers, colors, specs, etc.)"` +// Notes string `json:"notes,omitempty"` +// } -type AddHouseholdItemOutput struct { - Item ext.HouseholdItem `json:"item"` -} +// type AddHouseholdItemOutput struct { +// Item ext.HouseholdItem `json:"item"` +// } -func (t *HouseholdTool) AddItem(ctx context.Context, _ *mcp.CallToolRequest, in AddHouseholdItemInput) (*mcp.CallToolResult, AddHouseholdItemOutput, error) { - if strings.TrimSpace(in.Name) == "" { - return nil, AddHouseholdItemOutput{}, errRequiredField("name") - } - if in.Details == nil { - in.Details = map[string]any{} - } - item, err := t.store.AddHouseholdItem(ctx, ext.HouseholdItem{ - Name: strings.TrimSpace(in.Name), - Category: strings.TrimSpace(in.Category), - Location: strings.TrimSpace(in.Location), - Details: in.Details, - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, AddHouseholdItemOutput{}, err - } - return nil, AddHouseholdItemOutput{Item: item}, nil -} +// func (t *HouseholdTool) AddItem(ctx context.Context, _ *mcp.CallToolRequest, in AddHouseholdItemInput) (*mcp.CallToolResult, AddHouseholdItemOutput, error) { +// if strings.TrimSpace(in.Name) == "" { +// return nil, AddHouseholdItemOutput{}, errRequiredField("name") +// } +// if in.Details == nil { +// in.Details = map[string]any{} +// } +// item, err := t.store.AddHouseholdItem(ctx, ext.HouseholdItem{ +// Name: strings.TrimSpace(in.Name), +// Category: strings.TrimSpace(in.Category), +// Location: strings.TrimSpace(in.Location), +// Details: in.Details, +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, AddHouseholdItemOutput{}, err +// } +// return nil, AddHouseholdItemOutput{Item: item}, nil +// } -// search_household_items +// // search_household_items -type SearchHouseholdItemsInput struct { - Query string `json:"query,omitempty" jsonschema:"search text matching name or notes"` - Category string `json:"category,omitempty" jsonschema:"filter by category"` - Location string `json:"location,omitempty" jsonschema:"filter by location"` -} +// type SearchHouseholdItemsInput struct { +// Query string `json:"query,omitempty" jsonschema:"search text matching name or notes"` +// Category string `json:"category,omitempty" jsonschema:"filter by category"` +// Location string `json:"location,omitempty" jsonschema:"filter by location"` +// } -type SearchHouseholdItemsOutput struct { - Items []ext.HouseholdItem `json:"items"` -} +// type SearchHouseholdItemsOutput struct { +// Items []ext.HouseholdItem `json:"items"` +// } -func (t *HouseholdTool) SearchItems(ctx context.Context, _ *mcp.CallToolRequest, in SearchHouseholdItemsInput) (*mcp.CallToolResult, SearchHouseholdItemsOutput, error) { - items, err := t.store.SearchHouseholdItems(ctx, in.Query, in.Category, in.Location) - if err != nil { - return nil, SearchHouseholdItemsOutput{}, err - } - if items == nil { - items = []ext.HouseholdItem{} - } - return nil, SearchHouseholdItemsOutput{Items: items}, nil -} +// func (t *HouseholdTool) SearchItems(ctx context.Context, _ *mcp.CallToolRequest, in SearchHouseholdItemsInput) (*mcp.CallToolResult, SearchHouseholdItemsOutput, error) { +// items, err := t.store.SearchHouseholdItems(ctx, in.Query, in.Category, in.Location) +// if err != nil { +// return nil, SearchHouseholdItemsOutput{}, err +// } +// if items == nil { +// items = []ext.HouseholdItem{} +// } +// return nil, SearchHouseholdItemsOutput{Items: items}, nil +// } -// get_household_item +// // get_household_item -type GetHouseholdItemInput struct { - ID uuid.UUID `json:"id" jsonschema:"item id"` -} +// type GetHouseholdItemInput struct { +// ID uuid.UUID `json:"id" jsonschema:"item id"` +// } -type GetHouseholdItemOutput struct { - Item ext.HouseholdItem `json:"item"` -} +// type GetHouseholdItemOutput struct { +// Item ext.HouseholdItem `json:"item"` +// } -func (t *HouseholdTool) GetItem(ctx context.Context, _ *mcp.CallToolRequest, in GetHouseholdItemInput) (*mcp.CallToolResult, GetHouseholdItemOutput, error) { - item, err := t.store.GetHouseholdItem(ctx, in.ID) - if err != nil { - return nil, GetHouseholdItemOutput{}, err - } - return nil, GetHouseholdItemOutput{Item: item}, nil -} +// func (t *HouseholdTool) GetItem(ctx context.Context, _ *mcp.CallToolRequest, in GetHouseholdItemInput) (*mcp.CallToolResult, GetHouseholdItemOutput, error) { +// item, err := t.store.GetHouseholdItem(ctx, in.ID) +// if err != nil { +// return nil, GetHouseholdItemOutput{}, err +// } +// return nil, GetHouseholdItemOutput{Item: item}, nil +// } -// add_vendor +// // add_vendor -type AddVendorInput struct { - Name string `json:"name" jsonschema:"vendor name"` - ServiceType string `json:"service_type,omitempty" jsonschema:"type of service (e.g. plumber, electrician, landscaper)"` - Phone string `json:"phone,omitempty"` - Email string `json:"email,omitempty"` - Website string `json:"website,omitempty"` - Notes string `json:"notes,omitempty"` - Rating *int `json:"rating,omitempty" jsonschema:"1-5 rating"` -} +// type AddVendorInput struct { +// Name string `json:"name" jsonschema:"vendor name"` +// ServiceType string `json:"service_type,omitempty" jsonschema:"type of service (e.g. plumber, electrician, landscaper)"` +// Phone string `json:"phone,omitempty"` +// Email string `json:"email,omitempty"` +// Website string `json:"website,omitempty"` +// Notes string `json:"notes,omitempty"` +// Rating *int `json:"rating,omitempty" jsonschema:"1-5 rating"` +// } -type AddVendorOutput struct { - Vendor ext.HouseholdVendor `json:"vendor"` -} +// type AddVendorOutput struct { +// Vendor ext.HouseholdVendor `json:"vendor"` +// } -func (t *HouseholdTool) AddVendor(ctx context.Context, _ *mcp.CallToolRequest, in AddVendorInput) (*mcp.CallToolResult, AddVendorOutput, error) { - if strings.TrimSpace(in.Name) == "" { - return nil, AddVendorOutput{}, errRequiredField("name") - } - vendor, err := t.store.AddVendor(ctx, ext.HouseholdVendor{ - Name: strings.TrimSpace(in.Name), - ServiceType: strings.TrimSpace(in.ServiceType), - Phone: strings.TrimSpace(in.Phone), - Email: strings.TrimSpace(in.Email), - Website: strings.TrimSpace(in.Website), - Notes: strings.TrimSpace(in.Notes), - Rating: in.Rating, - }) - if err != nil { - return nil, AddVendorOutput{}, err - } - return nil, AddVendorOutput{Vendor: vendor}, nil -} +// func (t *HouseholdTool) AddVendor(ctx context.Context, _ *mcp.CallToolRequest, in AddVendorInput) (*mcp.CallToolResult, AddVendorOutput, error) { +// if strings.TrimSpace(in.Name) == "" { +// return nil, AddVendorOutput{}, errRequiredField("name") +// } +// vendor, err := t.store.AddVendor(ctx, ext.HouseholdVendor{ +// Name: strings.TrimSpace(in.Name), +// ServiceType: strings.TrimSpace(in.ServiceType), +// Phone: strings.TrimSpace(in.Phone), +// Email: strings.TrimSpace(in.Email), +// Website: strings.TrimSpace(in.Website), +// Notes: strings.TrimSpace(in.Notes), +// Rating: in.Rating, +// }) +// if err != nil { +// return nil, AddVendorOutput{}, err +// } +// return nil, AddVendorOutput{Vendor: vendor}, nil +// } -// list_vendors +// // list_vendors -type ListVendorsInput struct { - ServiceType string `json:"service_type,omitempty" jsonschema:"filter by service type"` -} +// type ListVendorsInput struct { +// ServiceType string `json:"service_type,omitempty" jsonschema:"filter by service type"` +// } -type ListVendorsOutput struct { - Vendors []ext.HouseholdVendor `json:"vendors"` -} +// type ListVendorsOutput struct { +// Vendors []ext.HouseholdVendor `json:"vendors"` +// } -func (t *HouseholdTool) ListVendors(ctx context.Context, _ *mcp.CallToolRequest, in ListVendorsInput) (*mcp.CallToolResult, ListVendorsOutput, error) { - vendors, err := t.store.ListVendors(ctx, in.ServiceType) - if err != nil { - return nil, ListVendorsOutput{}, err - } - if vendors == nil { - vendors = []ext.HouseholdVendor{} - } - return nil, ListVendorsOutput{Vendors: vendors}, nil -} +// func (t *HouseholdTool) ListVendors(ctx context.Context, _ *mcp.CallToolRequest, in ListVendorsInput) (*mcp.CallToolResult, ListVendorsOutput, error) { +// vendors, err := t.store.ListVendors(ctx, in.ServiceType) +// if err != nil { +// return nil, ListVendorsOutput{}, err +// } +// if vendors == nil { +// vendors = []ext.HouseholdVendor{} +// } +// return nil, ListVendorsOutput{Vendors: vendors}, nil +// } diff --git a/internal/tools/maintenance.go b/internal/tools/maintenance.go index 301305a..19d9602 100644 --- a/internal/tools/maintenance.go +++ b/internal/tools/maintenance.go @@ -1,137 +1,137 @@ package tools -import ( - "context" - "strings" - "time" +// import ( +// "context" +// "strings" +// "time" - "github.com/google/uuid" - "github.com/modelcontextprotocol/go-sdk/mcp" +// "github.com/google/uuid" +// "github.com/modelcontextprotocol/go-sdk/mcp" - "git.warky.dev/wdevs/amcs/internal/store" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/store" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -type MaintenanceTool struct { - store *store.DB -} +// type MaintenanceTool struct { +// store *store.DB +// } -func NewMaintenanceTool(db *store.DB) *MaintenanceTool { - return &MaintenanceTool{store: db} -} +// func NewMaintenanceTool(db *store.DB) *MaintenanceTool { +// return &MaintenanceTool{store: db} +// } -// add_maintenance_task +// // add_maintenance_task -type AddMaintenanceTaskInput struct { - Name string `json:"name" jsonschema:"task name"` - Category string `json:"category,omitempty" jsonschema:"e.g. hvac, plumbing, exterior, appliance, landscaping"` - FrequencyDays *int `json:"frequency_days,omitempty" jsonschema:"recurrence interval in days; omit for one-time tasks"` - NextDue *time.Time `json:"next_due,omitempty" jsonschema:"when the task is next due"` - Priority string `json:"priority,omitempty" jsonschema:"low, medium, high, or urgent (default: medium)"` - Notes string `json:"notes,omitempty"` -} +// type AddMaintenanceTaskInput struct { +// Name string `json:"name" jsonschema:"task name"` +// Category string `json:"category,omitempty" jsonschema:"e.g. hvac, plumbing, exterior, appliance, landscaping"` +// FrequencyDays *int `json:"frequency_days,omitempty" jsonschema:"recurrence interval in days; omit for one-time tasks"` +// NextDue *time.Time `json:"next_due,omitempty" jsonschema:"when the task is next due"` +// Priority string `json:"priority,omitempty" jsonschema:"low, medium, high, or urgent (default: medium)"` +// Notes string `json:"notes,omitempty"` +// } -type AddMaintenanceTaskOutput struct { - Task ext.MaintenanceTask `json:"task"` -} +// type AddMaintenanceTaskOutput struct { +// Task ext.MaintenanceTask `json:"task"` +// } -func (t *MaintenanceTool) AddTask(ctx context.Context, _ *mcp.CallToolRequest, in AddMaintenanceTaskInput) (*mcp.CallToolResult, AddMaintenanceTaskOutput, error) { - if strings.TrimSpace(in.Name) == "" { - return nil, AddMaintenanceTaskOutput{}, errRequiredField("name") - } - priority := strings.TrimSpace(in.Priority) - if priority == "" { - priority = "medium" - } - task, err := t.store.AddMaintenanceTask(ctx, ext.MaintenanceTask{ - Name: strings.TrimSpace(in.Name), - Category: strings.TrimSpace(in.Category), - FrequencyDays: in.FrequencyDays, - NextDue: in.NextDue, - Priority: priority, - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, AddMaintenanceTaskOutput{}, err - } - return nil, AddMaintenanceTaskOutput{Task: task}, nil -} +// func (t *MaintenanceTool) AddTask(ctx context.Context, _ *mcp.CallToolRequest, in AddMaintenanceTaskInput) (*mcp.CallToolResult, AddMaintenanceTaskOutput, error) { +// if strings.TrimSpace(in.Name) == "" { +// return nil, AddMaintenanceTaskOutput{}, errRequiredField("name") +// } +// priority := strings.TrimSpace(in.Priority) +// if priority == "" { +// priority = "medium" +// } +// task, err := t.store.AddMaintenanceTask(ctx, ext.MaintenanceTask{ +// Name: strings.TrimSpace(in.Name), +// Category: strings.TrimSpace(in.Category), +// FrequencyDays: in.FrequencyDays, +// NextDue: in.NextDue, +// Priority: priority, +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, AddMaintenanceTaskOutput{}, err +// } +// return nil, AddMaintenanceTaskOutput{Task: task}, nil +// } -// log_maintenance +// // log_maintenance -type LogMaintenanceInput struct { - TaskID uuid.UUID `json:"task_id" jsonschema:"id of the maintenance task"` - CompletedAt *time.Time `json:"completed_at,omitempty" jsonschema:"when the work was done (defaults to now)"` - PerformedBy string `json:"performed_by,omitempty" jsonschema:"who did the work (self, vendor name, etc.)"` - Cost *float64 `json:"cost,omitempty" jsonschema:"cost of the work"` - Notes string `json:"notes,omitempty"` - NextAction string `json:"next_action,omitempty" jsonschema:"recommended follow-up"` -} +// type LogMaintenanceInput struct { +// TaskID uuid.UUID `json:"task_id" jsonschema:"id of the maintenance task"` +// CompletedAt *time.Time `json:"completed_at,omitempty" jsonschema:"when the work was done (defaults to now)"` +// PerformedBy string `json:"performed_by,omitempty" jsonschema:"who did the work (self, vendor name, etc.)"` +// Cost *float64 `json:"cost,omitempty" jsonschema:"cost of the work"` +// Notes string `json:"notes,omitempty"` +// NextAction string `json:"next_action,omitempty" jsonschema:"recommended follow-up"` +// } -type LogMaintenanceOutput struct { - Log ext.MaintenanceLog `json:"log"` -} +// type LogMaintenanceOutput struct { +// Log ext.MaintenanceLog `json:"log"` +// } -func (t *MaintenanceTool) LogWork(ctx context.Context, _ *mcp.CallToolRequest, in LogMaintenanceInput) (*mcp.CallToolResult, LogMaintenanceOutput, error) { - completedAt := time.Now() - if in.CompletedAt != nil { - completedAt = *in.CompletedAt - } - log, err := t.store.LogMaintenance(ctx, ext.MaintenanceLog{ - TaskID: in.TaskID, - CompletedAt: completedAt, - PerformedBy: strings.TrimSpace(in.PerformedBy), - Cost: in.Cost, - Notes: strings.TrimSpace(in.Notes), - NextAction: strings.TrimSpace(in.NextAction), - }) - if err != nil { - return nil, LogMaintenanceOutput{}, err - } - return nil, LogMaintenanceOutput{Log: log}, nil -} +// func (t *MaintenanceTool) LogWork(ctx context.Context, _ *mcp.CallToolRequest, in LogMaintenanceInput) (*mcp.CallToolResult, LogMaintenanceOutput, error) { +// completedAt := time.Now() +// if in.CompletedAt != nil { +// completedAt = *in.CompletedAt +// } +// log, err := t.store.LogMaintenance(ctx, ext.MaintenanceLog{ +// TaskID: in.TaskID, +// CompletedAt: completedAt, +// PerformedBy: strings.TrimSpace(in.PerformedBy), +// Cost: in.Cost, +// Notes: strings.TrimSpace(in.Notes), +// NextAction: strings.TrimSpace(in.NextAction), +// }) +// if err != nil { +// return nil, LogMaintenanceOutput{}, err +// } +// return nil, LogMaintenanceOutput{Log: log}, nil +// } -// get_upcoming_maintenance +// // get_upcoming_maintenance -type GetUpcomingMaintenanceInput struct { - DaysAhead int `json:"days_ahead,omitempty" jsonschema:"how many days to look ahead (default: 30)"` -} +// type GetUpcomingMaintenanceInput struct { +// DaysAhead int `json:"days_ahead,omitempty" jsonschema:"how many days to look ahead (default: 30)"` +// } -type GetUpcomingMaintenanceOutput struct { - Tasks []ext.MaintenanceTask `json:"tasks"` -} +// type GetUpcomingMaintenanceOutput struct { +// Tasks []ext.MaintenanceTask `json:"tasks"` +// } -func (t *MaintenanceTool) GetUpcoming(ctx context.Context, _ *mcp.CallToolRequest, in GetUpcomingMaintenanceInput) (*mcp.CallToolResult, GetUpcomingMaintenanceOutput, error) { - tasks, err := t.store.GetUpcomingMaintenance(ctx, in.DaysAhead) - if err != nil { - return nil, GetUpcomingMaintenanceOutput{}, err - } - if tasks == nil { - tasks = []ext.MaintenanceTask{} - } - return nil, GetUpcomingMaintenanceOutput{Tasks: tasks}, nil -} +// func (t *MaintenanceTool) GetUpcoming(ctx context.Context, _ *mcp.CallToolRequest, in GetUpcomingMaintenanceInput) (*mcp.CallToolResult, GetUpcomingMaintenanceOutput, error) { +// tasks, err := t.store.GetUpcomingMaintenance(ctx, in.DaysAhead) +// if err != nil { +// return nil, GetUpcomingMaintenanceOutput{}, err +// } +// if tasks == nil { +// tasks = []ext.MaintenanceTask{} +// } +// return nil, GetUpcomingMaintenanceOutput{Tasks: tasks}, nil +// } -// search_maintenance_history +// // search_maintenance_history -type SearchMaintenanceHistoryInput struct { - Query string `json:"query,omitempty" jsonschema:"search text matching task name or notes"` - Category string `json:"category,omitempty" jsonschema:"filter by task category"` - Start *time.Time `json:"start,omitempty" jsonschema:"filter logs completed on or after this date"` - End *time.Time `json:"end,omitempty" jsonschema:"filter logs completed on or before this date"` -} +// type SearchMaintenanceHistoryInput struct { +// Query string `json:"query,omitempty" jsonschema:"search text matching task name or notes"` +// Category string `json:"category,omitempty" jsonschema:"filter by task category"` +// Start *time.Time `json:"start,omitempty" jsonschema:"filter logs completed on or after this date"` +// End *time.Time `json:"end,omitempty" jsonschema:"filter logs completed on or before this date"` +// } -type SearchMaintenanceHistoryOutput struct { - Logs []ext.MaintenanceLogWithTask `json:"logs"` -} +// type SearchMaintenanceHistoryOutput struct { +// Logs []ext.MaintenanceLogWithTask `json:"logs"` +// } -func (t *MaintenanceTool) SearchHistory(ctx context.Context, _ *mcp.CallToolRequest, in SearchMaintenanceHistoryInput) (*mcp.CallToolResult, SearchMaintenanceHistoryOutput, error) { - logs, err := t.store.SearchMaintenanceHistory(ctx, in.Query, in.Category, in.Start, in.End) - if err != nil { - return nil, SearchMaintenanceHistoryOutput{}, err - } - if logs == nil { - logs = []ext.MaintenanceLogWithTask{} - } - return nil, SearchMaintenanceHistoryOutput{Logs: logs}, nil -} +// func (t *MaintenanceTool) SearchHistory(ctx context.Context, _ *mcp.CallToolRequest, in SearchMaintenanceHistoryInput) (*mcp.CallToolResult, SearchMaintenanceHistoryOutput, error) { +// logs, err := t.store.SearchMaintenanceHistory(ctx, in.Query, in.Category, in.Start, in.End) +// if err != nil { +// return nil, SearchMaintenanceHistoryOutput{}, err +// } +// if logs == nil { +// logs = []ext.MaintenanceLogWithTask{} +// } +// return nil, SearchMaintenanceHistoryOutput{Logs: logs}, nil +// } diff --git a/internal/tools/meals.go b/internal/tools/meals.go index 5a07a9c..4c063ae 100644 --- a/internal/tools/meals.go +++ b/internal/tools/meals.go @@ -1,210 +1,210 @@ package tools -import ( - "context" - "strings" - "time" +// import ( +// "context" +// "strings" +// "time" - "github.com/google/uuid" - "github.com/modelcontextprotocol/go-sdk/mcp" +// "github.com/google/uuid" +// "github.com/modelcontextprotocol/go-sdk/mcp" - "git.warky.dev/wdevs/amcs/internal/store" - ext "git.warky.dev/wdevs/amcs/internal/types" -) +// "git.warky.dev/wdevs/amcs/internal/store" +// ext "git.warky.dev/wdevs/amcs/internal/types" +// ) -type MealsTool struct { - store *store.DB -} +// type MealsTool struct { +// store *store.DB +// } -func NewMealsTool(db *store.DB) *MealsTool { - return &MealsTool{store: db} -} +// func NewMealsTool(db *store.DB) *MealsTool { +// return &MealsTool{store: db} +// } -// add_recipe +// // add_recipe -type AddRecipeInput struct { - Name string `json:"name" jsonschema:"recipe name"` - Cuisine string `json:"cuisine,omitempty"` - PrepTimeMinutes *int `json:"prep_time_minutes,omitempty"` - CookTimeMinutes *int `json:"cook_time_minutes,omitempty"` - Servings *int `json:"servings,omitempty"` - Ingredients []ext.Ingredient `json:"ingredients,omitempty" jsonschema:"list of ingredients with name, quantity, unit"` - Instructions []string `json:"instructions,omitempty" jsonschema:"ordered list of steps"` - Tags []string `json:"tags,omitempty"` - Rating *int `json:"rating,omitempty" jsonschema:"1-5 rating"` - Notes string `json:"notes,omitempty"` -} +// type AddRecipeInput struct { +// Name string `json:"name" jsonschema:"recipe name"` +// Cuisine string `json:"cuisine,omitempty"` +// PrepTimeMinutes *int `json:"prep_time_minutes,omitempty"` +// CookTimeMinutes *int `json:"cook_time_minutes,omitempty"` +// Servings *int `json:"servings,omitempty"` +// Ingredients []ext.Ingredient `json:"ingredients,omitempty" jsonschema:"list of ingredients with name, quantity, unit"` +// Instructions []string `json:"instructions,omitempty" jsonschema:"ordered list of steps"` +// Tags []string `json:"tags,omitempty"` +// Rating *int `json:"rating,omitempty" jsonschema:"1-5 rating"` +// Notes string `json:"notes,omitempty"` +// } -type AddRecipeOutput struct { - Recipe ext.Recipe `json:"recipe"` -} +// type AddRecipeOutput struct { +// Recipe ext.Recipe `json:"recipe"` +// } -func (t *MealsTool) AddRecipe(ctx context.Context, _ *mcp.CallToolRequest, in AddRecipeInput) (*mcp.CallToolResult, AddRecipeOutput, error) { - if strings.TrimSpace(in.Name) == "" { - return nil, AddRecipeOutput{}, errRequiredField("name") - } - if in.Ingredients == nil { - in.Ingredients = []ext.Ingredient{} - } - if in.Instructions == nil { - in.Instructions = []string{} - } - if in.Tags == nil { - in.Tags = []string{} - } - recipe, err := t.store.AddRecipe(ctx, ext.Recipe{ - Name: strings.TrimSpace(in.Name), - Cuisine: strings.TrimSpace(in.Cuisine), - PrepTimeMinutes: in.PrepTimeMinutes, - CookTimeMinutes: in.CookTimeMinutes, - Servings: in.Servings, - Ingredients: in.Ingredients, - Instructions: in.Instructions, - Tags: in.Tags, - Rating: in.Rating, - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, AddRecipeOutput{}, err - } - return nil, AddRecipeOutput{Recipe: recipe}, nil -} +// func (t *MealsTool) AddRecipe(ctx context.Context, _ *mcp.CallToolRequest, in AddRecipeInput) (*mcp.CallToolResult, AddRecipeOutput, error) { +// if strings.TrimSpace(in.Name) == "" { +// return nil, AddRecipeOutput{}, errRequiredField("name") +// } +// if in.Ingredients == nil { +// in.Ingredients = []ext.Ingredient{} +// } +// if in.Instructions == nil { +// in.Instructions = []string{} +// } +// if in.Tags == nil { +// in.Tags = []string{} +// } +// recipe, err := t.store.AddRecipe(ctx, ext.Recipe{ +// Name: strings.TrimSpace(in.Name), +// Cuisine: strings.TrimSpace(in.Cuisine), +// PrepTimeMinutes: in.PrepTimeMinutes, +// CookTimeMinutes: in.CookTimeMinutes, +// Servings: in.Servings, +// Ingredients: in.Ingredients, +// Instructions: in.Instructions, +// Tags: in.Tags, +// Rating: in.Rating, +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, AddRecipeOutput{}, err +// } +// return nil, AddRecipeOutput{Recipe: recipe}, nil +// } -// search_recipes +// // search_recipes -type SearchRecipesInput struct { - Query string `json:"query,omitempty" jsonschema:"search by recipe name"` - Cuisine string `json:"cuisine,omitempty"` - Tags []string `json:"tags,omitempty" jsonschema:"filter by tags (all must match)"` - Ingredient string `json:"ingredient,omitempty" jsonschema:"filter by ingredient name"` -} +// type SearchRecipesInput struct { +// Query string `json:"query,omitempty" jsonschema:"search by recipe name"` +// Cuisine string `json:"cuisine,omitempty"` +// Tags []string `json:"tags,omitempty" jsonschema:"filter by tags (all must match)"` +// Ingredient string `json:"ingredient,omitempty" jsonschema:"filter by ingredient name"` +// } -type SearchRecipesOutput struct { - Recipes []ext.Recipe `json:"recipes"` -} +// type SearchRecipesOutput struct { +// Recipes []ext.Recipe `json:"recipes"` +// } -func (t *MealsTool) SearchRecipes(ctx context.Context, _ *mcp.CallToolRequest, in SearchRecipesInput) (*mcp.CallToolResult, SearchRecipesOutput, error) { - recipes, err := t.store.SearchRecipes(ctx, in.Query, in.Cuisine, in.Tags, in.Ingredient) - if err != nil { - return nil, SearchRecipesOutput{}, err - } - if recipes == nil { - recipes = []ext.Recipe{} - } - return nil, SearchRecipesOutput{Recipes: recipes}, nil -} +// func (t *MealsTool) SearchRecipes(ctx context.Context, _ *mcp.CallToolRequest, in SearchRecipesInput) (*mcp.CallToolResult, SearchRecipesOutput, error) { +// recipes, err := t.store.SearchRecipes(ctx, in.Query, in.Cuisine, in.Tags, in.Ingredient) +// if err != nil { +// return nil, SearchRecipesOutput{}, err +// } +// if recipes == nil { +// recipes = []ext.Recipe{} +// } +// return nil, SearchRecipesOutput{Recipes: recipes}, nil +// } -// update_recipe +// // update_recipe -type UpdateRecipeInput struct { - ID uuid.UUID `json:"id" jsonschema:"recipe id to update"` - Name string `json:"name" jsonschema:"recipe name"` - Cuisine string `json:"cuisine,omitempty"` - PrepTimeMinutes *int `json:"prep_time_minutes,omitempty"` - CookTimeMinutes *int `json:"cook_time_minutes,omitempty"` - Servings *int `json:"servings,omitempty"` - Ingredients []ext.Ingredient `json:"ingredients,omitempty"` - Instructions []string `json:"instructions,omitempty"` - Tags []string `json:"tags,omitempty"` - Rating *int `json:"rating,omitempty"` - Notes string `json:"notes,omitempty"` -} +// type UpdateRecipeInput struct { +// ID uuid.UUID `json:"id" jsonschema:"recipe id to update"` +// Name string `json:"name" jsonschema:"recipe name"` +// Cuisine string `json:"cuisine,omitempty"` +// PrepTimeMinutes *int `json:"prep_time_minutes,omitempty"` +// CookTimeMinutes *int `json:"cook_time_minutes,omitempty"` +// Servings *int `json:"servings,omitempty"` +// Ingredients []ext.Ingredient `json:"ingredients,omitempty"` +// Instructions []string `json:"instructions,omitempty"` +// Tags []string `json:"tags,omitempty"` +// Rating *int `json:"rating,omitempty"` +// Notes string `json:"notes,omitempty"` +// } -type UpdateRecipeOutput struct { - Recipe ext.Recipe `json:"recipe"` -} +// type UpdateRecipeOutput struct { +// Recipe ext.Recipe `json:"recipe"` +// } -func (t *MealsTool) UpdateRecipe(ctx context.Context, _ *mcp.CallToolRequest, in UpdateRecipeInput) (*mcp.CallToolResult, UpdateRecipeOutput, error) { - if strings.TrimSpace(in.Name) == "" { - return nil, UpdateRecipeOutput{}, errRequiredField("name") - } - if in.Ingredients == nil { - in.Ingredients = []ext.Ingredient{} - } - if in.Instructions == nil { - in.Instructions = []string{} - } - if in.Tags == nil { - in.Tags = []string{} - } - recipe, err := t.store.UpdateRecipe(ctx, in.ID, ext.Recipe{ - Name: strings.TrimSpace(in.Name), - Cuisine: strings.TrimSpace(in.Cuisine), - PrepTimeMinutes: in.PrepTimeMinutes, - CookTimeMinutes: in.CookTimeMinutes, - Servings: in.Servings, - Ingredients: in.Ingredients, - Instructions: in.Instructions, - Tags: in.Tags, - Rating: in.Rating, - Notes: strings.TrimSpace(in.Notes), - }) - if err != nil { - return nil, UpdateRecipeOutput{}, err - } - return nil, UpdateRecipeOutput{Recipe: recipe}, nil -} +// func (t *MealsTool) UpdateRecipe(ctx context.Context, _ *mcp.CallToolRequest, in UpdateRecipeInput) (*mcp.CallToolResult, UpdateRecipeOutput, error) { +// if strings.TrimSpace(in.Name) == "" { +// return nil, UpdateRecipeOutput{}, errRequiredField("name") +// } +// if in.Ingredients == nil { +// in.Ingredients = []ext.Ingredient{} +// } +// if in.Instructions == nil { +// in.Instructions = []string{} +// } +// if in.Tags == nil { +// in.Tags = []string{} +// } +// recipe, err := t.store.UpdateRecipe(ctx, in.ID, ext.Recipe{ +// Name: strings.TrimSpace(in.Name), +// Cuisine: strings.TrimSpace(in.Cuisine), +// PrepTimeMinutes: in.PrepTimeMinutes, +// CookTimeMinutes: in.CookTimeMinutes, +// Servings: in.Servings, +// Ingredients: in.Ingredients, +// Instructions: in.Instructions, +// Tags: in.Tags, +// Rating: in.Rating, +// Notes: strings.TrimSpace(in.Notes), +// }) +// if err != nil { +// return nil, UpdateRecipeOutput{}, err +// } +// return nil, UpdateRecipeOutput{Recipe: recipe}, nil +// } -// create_meal_plan +// // create_meal_plan -type CreateMealPlanInput struct { - WeekStart time.Time `json:"week_start" jsonschema:"Monday of the week to plan"` - Meals []ext.MealPlanInput `json:"meals" jsonschema:"list of meal entries for the week"` -} +// type CreateMealPlanInput struct { +// WeekStart time.Time `json:"week_start" jsonschema:"Monday of the week to plan"` +// Meals []ext.MealPlanInput `json:"meals" jsonschema:"list of meal entries for the week"` +// } -type CreateMealPlanOutput struct { - Entries []ext.MealPlanEntry `json:"entries"` -} +// type CreateMealPlanOutput struct { +// Entries []ext.MealPlanEntry `json:"entries"` +// } -func (t *MealsTool) CreateMealPlan(ctx context.Context, _ *mcp.CallToolRequest, in CreateMealPlanInput) (*mcp.CallToolResult, CreateMealPlanOutput, error) { - if len(in.Meals) == 0 { - return nil, CreateMealPlanOutput{}, errInvalidInput("meals are required") - } - entries, err := t.store.CreateMealPlan(ctx, in.WeekStart, in.Meals) - if err != nil { - return nil, CreateMealPlanOutput{}, err - } - if entries == nil { - entries = []ext.MealPlanEntry{} - } - return nil, CreateMealPlanOutput{Entries: entries}, nil -} +// func (t *MealsTool) CreateMealPlan(ctx context.Context, _ *mcp.CallToolRequest, in CreateMealPlanInput) (*mcp.CallToolResult, CreateMealPlanOutput, error) { +// if len(in.Meals) == 0 { +// return nil, CreateMealPlanOutput{}, errInvalidInput("meals are required") +// } +// entries, err := t.store.CreateMealPlan(ctx, in.WeekStart, in.Meals) +// if err != nil { +// return nil, CreateMealPlanOutput{}, err +// } +// if entries == nil { +// entries = []ext.MealPlanEntry{} +// } +// return nil, CreateMealPlanOutput{Entries: entries}, nil +// } -// get_meal_plan +// // get_meal_plan -type GetMealPlanInput struct { - WeekStart time.Time `json:"week_start" jsonschema:"Monday of the week to retrieve"` -} +// type GetMealPlanInput struct { +// WeekStart time.Time `json:"week_start" jsonschema:"Monday of the week to retrieve"` +// } -type GetMealPlanOutput struct { - Entries []ext.MealPlanEntry `json:"entries"` -} +// type GetMealPlanOutput struct { +// Entries []ext.MealPlanEntry `json:"entries"` +// } -func (t *MealsTool) GetMealPlan(ctx context.Context, _ *mcp.CallToolRequest, in GetMealPlanInput) (*mcp.CallToolResult, GetMealPlanOutput, error) { - entries, err := t.store.GetMealPlan(ctx, in.WeekStart) - if err != nil { - return nil, GetMealPlanOutput{}, err - } - if entries == nil { - entries = []ext.MealPlanEntry{} - } - return nil, GetMealPlanOutput{Entries: entries}, nil -} +// func (t *MealsTool) GetMealPlan(ctx context.Context, _ *mcp.CallToolRequest, in GetMealPlanInput) (*mcp.CallToolResult, GetMealPlanOutput, error) { +// entries, err := t.store.GetMealPlan(ctx, in.WeekStart) +// if err != nil { +// return nil, GetMealPlanOutput{}, err +// } +// if entries == nil { +// entries = []ext.MealPlanEntry{} +// } +// return nil, GetMealPlanOutput{Entries: entries}, nil +// } -// generate_shopping_list +// // generate_shopping_list -type GenerateShoppingListInput struct { - WeekStart time.Time `json:"week_start" jsonschema:"Monday of the week to generate shopping list for"` -} +// type GenerateShoppingListInput struct { +// WeekStart time.Time `json:"week_start" jsonschema:"Monday of the week to generate shopping list for"` +// } -type GenerateShoppingListOutput struct { - ShoppingList ext.ShoppingList `json:"shopping_list"` -} +// type GenerateShoppingListOutput struct { +// ShoppingList ext.ShoppingList `json:"shopping_list"` +// } -func (t *MealsTool) GenerateShoppingList(ctx context.Context, _ *mcp.CallToolRequest, in GenerateShoppingListInput) (*mcp.CallToolResult, GenerateShoppingListOutput, error) { - list, err := t.store.GenerateShoppingList(ctx, in.WeekStart) - if err != nil { - return nil, GenerateShoppingListOutput{}, err - } - return nil, GenerateShoppingListOutput{ShoppingList: list}, nil -} +// func (t *MealsTool) GenerateShoppingList(ctx context.Context, _ *mcp.CallToolRequest, in GenerateShoppingListInput) (*mcp.CallToolResult, GenerateShoppingListOutput, error) { +// list, err := t.store.GenerateShoppingList(ctx, in.WeekStart) +// if err != nil { +// return nil, GenerateShoppingListOutput{}, err +// } +// return nil, GenerateShoppingListOutput{ShoppingList: list}, nil +// } diff --git a/schema/calendar.dbml b/schema/_dropped_old/calendar.dbml similarity index 100% rename from schema/calendar.dbml rename to schema/_dropped_old/calendar.dbml diff --git a/schema/crm.dbml b/schema/_dropped_old/crm.dbml similarity index 100% rename from schema/crm.dbml rename to schema/_dropped_old/crm.dbml diff --git a/schema/household.dbml b/schema/_dropped_old/household.dbml similarity index 100% rename from schema/household.dbml rename to schema/_dropped_old/household.dbml diff --git a/schema/maintenance.dbml b/schema/_dropped_old/maintenance.dbml similarity index 100% rename from schema/maintenance.dbml rename to schema/_dropped_old/maintenance.dbml diff --git a/schema/meals.dbml b/schema/_dropped_old/meals.dbml similarity index 100% rename from schema/meals.dbml rename to schema/_dropped_old/meals.dbml diff --git a/ui/index.html b/ui/index.html index d3e87c8..73e7e67 100644 --- a/ui/index.html +++ b/ui/index.html @@ -1,5 +1,5 @@ - +
@@ -9,7 +9,7 @@ content="AMCS is a memory server that captures, links, and retrieves structured project thoughts for AI assistants using semantic search, summaries, and MCP tools." /> - + diff --git a/ui/package.json b/ui/package.json index 9b62cfb..46218e1 100644 --- a/ui/package.json +++ b/ui/package.json @@ -21,12 +21,12 @@ "vite": "^8.0.10" }, "dependencies": { - "@sentry/svelte": "^10.50.0", + "@sentry/svelte": "^10.51.0", "@skeletonlabs/skeleton": "^4.15.2", "@skeletonlabs/skeleton-svelte": "^4.15.2", "@tanstack/svelte-virtual": "^3.13.24", "@warkypublic/artemis-kit": "^1.0.10", "@warkypublic/resolvespec-js": "^1.0.1", - "@warkypublic/svelix": "^0.1.39" + "@warkypublic/svelix": "^0.1.40" } -} +} \ No newline at end of file diff --git a/ui/pnpm-lock.yaml b/ui/pnpm-lock.yaml index bd08cfd..63fdebf 100644 --- a/ui/pnpm-lock.yaml +++ b/ui/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@sentry/svelte': - specifier: ^10.50.0 - version: 10.50.0(svelte@5.55.5) + specifier: ^10.51.0 + version: 10.51.0(svelte@5.55.5) '@skeletonlabs/skeleton': specifier: ^4.15.2 version: 4.15.2(tailwindcss@4.2.4) @@ -27,8 +27,8 @@ importers: specifier: ^1.0.1 version: 1.0.1 '@warkypublic/svelix': - specifier: ^0.1.39 - version: 0.1.39(highlight.js@11.8.0)(svelte@5.55.5)(unified@11.0.5) + specifier: ^0.1.40 + version: 0.1.40(highlight.js@11.8.0)(svelte@5.55.5)(unified@11.0.5) devDependencies: '@sveltejs/vite-plugin-svelte': specifier: ^7.0.0 @@ -315,32 +315,32 @@ packages: '@rolldown/pluginutils@1.0.0-rc.17': resolution: {integrity: sha512-n8iosDOt6Ig1UhJ2AYqoIhHWh/isz0xpicHTzpKBeotdVsTEcxsSA/i3EVM7gQAj0rU27OLAxCjzlj15IWY7bg==} - '@sentry-internal/browser-utils@10.50.0': - resolution: {integrity: sha512-42bxyRTxnCmYlWnvz4CxikuQNanw8UNma2WJrtxJ0f1MAJV2GhQGSHDLnA+lvFlmiz6qct3pfen/NXGyOTegTA==} + '@sentry-internal/browser-utils@10.51.0': + resolution: {integrity: sha512-lNKBS4P7RUvf1niojXQWe9bU3gnBUCbST4Dj0pSiyat1N96cXVyHkeE+uGxowD0RrVWhs+kGHiVX3FcmRWF6sA==} engines: {node: '>=18'} - '@sentry-internal/feedback@10.50.0': - resolution: {integrity: sha512-0k9XZF0wn86f77mIO2U3gNNyDZooy139CnEanRzHinrN106vVzvBZ6TUEQoHtoO1fqQxr+nWWVrqV/PXUqk47w==} + '@sentry-internal/feedback@10.51.0': + resolution: {integrity: sha512-bCM95bcpphx28e6aU0bwRLxOgwosYsdNzezM1sM0pVOkb0TB3hDFRamramVDK+/Hp1o8qmRxS4c5w/A7YBZGkA==} engines: {node: '>=18'} - '@sentry-internal/replay-canvas@10.50.0': - resolution: {integrity: sha512-jx6RKBmcJSWdI92qDGS/sBv1w+7Cww879Z/moX7bw7ipHa/Ts3iDcB3rgZwvhmi17U+mvYsbJeL2DXkPo3TjPw==} + '@sentry-internal/replay-canvas@10.51.0': + resolution: {integrity: sha512-8PW1Pp+Yl3lPwYqhBCr5SgkuhDanu9ZLzUqD2bPKL/ElqbM2eDVIWxq4z4ZzePrmZa6IcCjTv6sVQJ7Z4dLyLA==} engines: {node: '>=18'} - '@sentry-internal/replay@10.50.0': - resolution: {integrity: sha512-51FYNfnvVLAWw1rrEWPFfwHuMRb9mkVCFGA4J9/un7SpeGBsQDziGB0Di4fsCxI7+EdSBpfLHPF0csKtCCw0oQ==} + '@sentry-internal/replay@10.51.0': + resolution: {integrity: sha512-jCpI5HXSwK6ZT2HX70+mDRciAocHzSiDk4DTgvzV69Wvd+Ei5WLgE+d39eaEPsm8lUC0Ydntb5sJIB6uG9D4bw==} engines: {node: '>=18'} - '@sentry/browser@10.50.0': - resolution: {integrity: sha512-1f6rAvET6myiTaSeYqvaaBwvq1LfxqWjAPIoAW/NVC9bPMkeEcuvgDajHrnZMrBeWoJ81NMyoLkyX+iOc7MoFA==} + '@sentry/browser@10.51.0': + resolution: {integrity: sha512-Zdc0sKfenxUtW/OGhtJ7xHFN44bXR7YqxJ1zBDzlZfW0nTbeTTUZBq9z5NUw6qdS0Vs/i3V4qzAKTbRKWfqSEA==} engines: {node: '>=18'} - '@sentry/core@10.50.0': - resolution: {integrity: sha512-J4A+vzUO3adl0TkFCjaN1+4miamrjHiEIYuLHiuu1lmAjq5WIVw32ObvAh4yMwNtxyaEMosTrrh5M6f12XSJFg==} + '@sentry/core@10.51.0': + resolution: {integrity: sha512-Y45V/YXvVLEXmOdkbD1oG1gkRWFi9guCEGg3PlIlIpRjAbZUrvLGgjRJIc1E7XpSzmOnWbs5BbUxMv4PDaPj2w==} engines: {node: '>=18'} - '@sentry/svelte@10.50.0': - resolution: {integrity: sha512-pkd9HNpZN+8x9i8n24fpV+Q3/sKDkBKyJ29iNzbhGnZ3CeRPwKxwQOoiBBPQkllYWzr/a7cYFtBKNLdpmTFCOg==} + '@sentry/svelte@10.51.0': + resolution: {integrity: sha512-2/OwIs+WXk+H/CAnWeiQMvXx5EG8LxCtqu4m+HdHtJTUQtERC388zNShZTJU9YYR71KoDOVAU0Q6B2sKNcssFA==} engines: {node: '>=18'} peerDependencies: svelte: 3.x || 4.x || 5.x @@ -758,8 +758,8 @@ packages: resolution: {integrity: sha512-uXP1HouxpOKXfwE6qpy0gCcrMPIgjDT53aVGkfork4QejRSunbKWSKKawW2nIm7RnyFhSjPILMXcnT5xUiXOew==} engines: {node: '>=18'} - '@warkypublic/svelix@0.1.39': - resolution: {integrity: sha512-CeKOyabAXTt5MXzRkQyG0G7+1wwgYD/e4+fX9gRsQWxlVVrHv8qdbK1HxHHKMmu4ZW9csf0dXWcEIt/TSM9qAg==} + '@warkypublic/svelix@0.1.40': + resolution: {integrity: sha512-Pn4T+VVI1Pfrtkbr61oqVyhaUTySU0r6gti9SeSqL+ZJeRfXAj+ZTuwlHzk0w9BxrwlWDnVinGyrpbSjnwb+iQ==} peerDependencies: svelte: ^5.0.0 @@ -2062,38 +2062,38 @@ snapshots: '@rolldown/pluginutils@1.0.0-rc.17': {} - '@sentry-internal/browser-utils@10.50.0': + '@sentry-internal/browser-utils@10.51.0': dependencies: - '@sentry/core': 10.50.0 + '@sentry/core': 10.51.0 - '@sentry-internal/feedback@10.50.0': + '@sentry-internal/feedback@10.51.0': dependencies: - '@sentry/core': 10.50.0 + '@sentry/core': 10.51.0 - '@sentry-internal/replay-canvas@10.50.0': + '@sentry-internal/replay-canvas@10.51.0': dependencies: - '@sentry-internal/replay': 10.50.0 - '@sentry/core': 10.50.0 + '@sentry-internal/replay': 10.51.0 + '@sentry/core': 10.51.0 - '@sentry-internal/replay@10.50.0': + '@sentry-internal/replay@10.51.0': dependencies: - '@sentry-internal/browser-utils': 10.50.0 - '@sentry/core': 10.50.0 + '@sentry-internal/browser-utils': 10.51.0 + '@sentry/core': 10.51.0 - '@sentry/browser@10.50.0': + '@sentry/browser@10.51.0': dependencies: - '@sentry-internal/browser-utils': 10.50.0 - '@sentry-internal/feedback': 10.50.0 - '@sentry-internal/replay': 10.50.0 - '@sentry-internal/replay-canvas': 10.50.0 - '@sentry/core': 10.50.0 + '@sentry-internal/browser-utils': 10.51.0 + '@sentry-internal/feedback': 10.51.0 + '@sentry-internal/replay': 10.51.0 + '@sentry-internal/replay-canvas': 10.51.0 + '@sentry/core': 10.51.0 - '@sentry/core@10.50.0': {} + '@sentry/core@10.51.0': {} - '@sentry/svelte@10.50.0(svelte@5.55.5)': + '@sentry/svelte@10.51.0(svelte@5.55.5)': dependencies: - '@sentry/browser': 10.50.0 - '@sentry/core': 10.50.0 + '@sentry/browser': 10.51.0 + '@sentry/core': 10.51.0 magic-string: 0.30.21 svelte: 5.55.5 @@ -2556,7 +2556,7 @@ snapshots: dependencies: uuid: 13.0.0 - '@warkypublic/svelix@0.1.39(highlight.js@11.8.0)(svelte@5.55.5)(unified@11.0.5)': + '@warkypublic/svelix@0.1.40(highlight.js@11.8.0)(svelte@5.55.5)(unified@11.0.5)': dependencies: '@cartamd/plugin-anchor': 2.2.0(carta-md@4.11.2(svelte@5.55.5)) '@cartamd/plugin-attachment': 4.2.0(carta-md@4.11.2(svelte@5.55.5)) diff --git a/ui/src/App.svelte b/ui/src/App.svelte index f48251a..06a82b5 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -199,7 +199,7 @@{files.length} file{files.length !== 1 ? 's' : ''}
++ {#if gridTotal === null} + Server-backed grid + {:else} + {gridTotal} file{gridTotal !== 1 ? 's' : ''} + {/if} +
| Name | -Type | -Kind | -Size | -Uploaded | -Download | -
|---|---|---|---|---|---|
| {f.name} | -{f.media_type} | -- {f.kind || '—'} - | -{formatBytes(f.size_bytes)} | -{formatDate(f.created_at)} | -- ↓ - | -
{guardrails.length} guardrail{guardrails.length !== 1 ? 's' : ''}
++ {#if gridTotal === null} + Server-backed grid + {:else} + {gridTotal} guardrail{gridTotal !== 1 ? 's' : ''} + {/if} +
+{g.name}
- - {g.severity} - -{g.description}
- {/if} - {#if g.tags?.length} -{projects.length} project{projects.length !== 1 ? 's' : ''}
++ {#if gridTotal === null} + Server-backed grid + {:else} + {gridTotal} project{gridTotal !== 1 ? 's' : ''} + {/if} +
{createError}
{/if} -{selectedProject.name} · {selectedProject.thought_count} thoughts
{selectedProject.description || 'No description.'}
{saveError}
+ {/if} + + + +{skills.length} skill{skills.length !== 1 ? 's' : ''}
++ {#if gridTotal === null} + Server-backed grid + {:else} + {gridTotal} skill{gridTotal !== 1 ? 's' : ''} + {/if} +
+{skill.name}
- {#if skill.description} -{skill.description}
- {/if} - {#if skill.tags?.length} -{skill.content}
-