From 3d4e6d093961edd0971ed8fdd1e90513e42f22d9 Mon Sep 17 00:00:00 2001 From: Hein Date: Wed, 15 Jul 2026 12:55:15 +0200 Subject: [PATCH] feat(sqltypes): add nullable SQL types with automatic casting * Introduced SqlNull type for nullable values with auto-casting. * Implemented JSON, YAML, and XML marshaling/unmarshaling. * Added specific types for common SQL types (e.g., SqlInt64, SqlString). * Included utility functions for creating nullable types. * Added SqlTimeStamp, SqlDate, and SqlTime types with custom formatting. --- go.mod | 2 +- go.sum | 6 +- internal/app/resolvespec_models_generated.go | 1 + .../sql_public_agent_guardrails.go | 20 +- .../generatedmodels/sql_public_agent_parts.go | 26 +- .../sql_public_agent_persona_guardrails.go | 4 +- .../sql_public_agent_persona_parts.go | 16 +- .../sql_public_agent_persona_skills.go | 14 +- .../sql_public_agent_persona_traits.go | 12 +- .../sql_public_agent_personas.go | 26 +- .../sql_public_agent_skills.go | 34 +- .../sql_public_agent_traits.go | 22 +- .../sql_public_arc_stage_parts.go | 12 +- .../generatedmodels/sql_public_arc_stages.go | 22 +- .../sql_public_character_arcs.go | 18 +- .../sql_public_chat_histories.go | 29 +- .../generatedmodels/sql_public_embeddings.go | 20 +- .../generatedmodels/sql_public_learnings.go | 60 ++-- .../sql_public_oauth_clients.go | 12 +- .../generatedmodels/sql_public_persona_arc.go | 18 +- .../sql_public_plan_dependencies.go | 14 +- .../sql_public_plan_guardrails.go | 14 +- .../sql_public_plan_related_plans.go | 14 +- .../generatedmodels/sql_public_plan_skills.go | 14 +- internal/generatedmodels/sql_public_plans.go | 51 +-- .../sql_public_project_guardrails.go | 14 +- .../sql_public_project_personas.go | 16 +- .../sql_public_project_skills.go | 16 +- .../generatedmodels/sql_public_projects.go | 16 +- .../sql_public_stored_files.go | 33 +- .../sql_public_thought_learning_links.go | 64 ++++ .../sql_public_thought_links.go | 16 +- .../generatedmodels/sql_public_thoughts.go | 34 +- .../sql_public_tool_annotations.go | 12 +- migrations/020_generated_schema.sql | 8 +- vendor/git.warky.dev/wdevs/relspecgo/LICENSE | 73 ++++ .../wdevs/relspecgo/pkg/sqltypes/README.md | 136 +++++++ .../pkg/sqltypes}/sql_array_types.go | 306 +++++++++++++++- .../relspecgo/pkg/sqltypes}/sql_types.go | 339 +++++++++++++++++- vendor/modules.txt | 6 +- 40 files changed, 1240 insertions(+), 330 deletions(-) create mode 100644 internal/generatedmodels/sql_public_thought_learning_links.go create mode 100644 vendor/git.warky.dev/wdevs/relspecgo/LICENSE create mode 100644 vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/README.md rename vendor/{github.com/bitechdev/ResolveSpec/pkg/spectypes => git.warky.dev/wdevs/relspecgo/pkg/sqltypes}/sql_array_types.go (68%) rename vendor/{github.com/bitechdev/ResolveSpec/pkg/spectypes => git.warky.dev/wdevs/relspecgo/pkg/sqltypes}/sql_types.go (63%) diff --git a/go.mod b/go.mod index e2f9abe..075fb60 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module git.warky.dev/wdevs/amcs go 1.26.1 require ( + git.warky.dev/wdevs/relspecgo v1.0.62 github.com/bitechdev/ResolveSpec v1.1.26 github.com/google/jsonschema-go v0.4.3 github.com/google/uuid v1.6.0 @@ -46,7 +47,6 @@ require ( github.com/prometheus/procfs v0.20.1 // indirect github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect github.com/redis/go-redis/v9 v9.19.0 // indirect - github.com/rogpeppe/go-internal v1.14.1 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/segmentio/asm v1.1.3 // indirect github.com/segmentio/encoding v0.5.4 // indirect diff --git a/go.sum b/go.sum index 80649cc..70e432c 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= entgo.io/ent v0.14.3 h1:wokAV/kIlH9TeklJWGGS7AYJdVckr0DloWjIcO9iIIQ= entgo.io/ent v0.14.3/go.mod h1:aDPE/OziPEu8+OWbzy4UlvWmD2/kbRuWfK2A40hcxJM= +git.warky.dev/wdevs/relspecgo v1.0.62 h1:byBe2IlcwQRKsV5qXHfGITtfvGZewHlNstP+O8BGnns= +git.warky.dev/wdevs/relspecgo v1.0.62/go.mod h1:JpZBvui9dYc/QcD5TZ1wKab+4bUvPw5/rOLOA/h2F6A= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= @@ -452,8 +454,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= -golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= +golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8= +golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= diff --git a/internal/app/resolvespec_models_generated.go b/internal/app/resolvespec_models_generated.go index a377ffc..2c9b4ba 100644 --- a/internal/app/resolvespec_models_generated.go +++ b/internal/app/resolvespec_models_generated.go @@ -32,6 +32,7 @@ func resolveSpecModels() []resolveSpecModel { {schema: "public", entity: "project_skills", model: generatedmodels.ModelPublicProjectSkills{}}, {schema: "public", entity: "projects", model: generatedmodels.ModelPublicProjects{}}, {schema: "public", entity: "stored_files", model: generatedmodels.ModelPublicStoredFiles{}}, + {schema: "public", entity: "thought_learning_links", model: generatedmodels.ModelPublicThoughtLearningLinks{}}, {schema: "public", entity: "thought_links", model: generatedmodels.ModelPublicThoughtLinks{}}, {schema: "public", entity: "thoughts", model: generatedmodels.ModelPublicThoughts{}}, {schema: "public", entity: "tool_annotations", model: generatedmodels.ModelPublicToolAnnotations{}}, diff --git a/internal/generatedmodels/sql_public_agent_guardrails.go b/internal/generatedmodels/sql_public_agent_guardrails.go index 0b308aa..3a614c9 100644 --- a/internal/generatedmodels/sql_public_agent_guardrails.go +++ b/internal/generatedmodels/sql_public_agent_guardrails.go @@ -3,21 +3,21 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentGuardrails struct { bun.BaseModel `bun:"table:public.agent_guardrails,alias:agent_guardrails"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," 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"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - 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"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + Content sql_types.SqlString `bun:"content,type:text,notnull," json:"content"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + Severity sql_types.SqlString `bun:"severity,type:text,default:'medium',notnull," json:"severity"` + Tags sql_types.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` RelGuardrailIDPublicAgentPersonaGuardrails []*ModelPublicAgentPersonaGuardrails `bun:"rel:has-many,join:id=guardrail_id" json:"relguardrailidpublicagentpersonaguardrails,omitempty"` // Has many ModelPublicAgentPersonaGuardrails 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 diff --git a/internal/generatedmodels/sql_public_agent_parts.go b/internal/generatedmodels/sql_public_agent_parts.go index 04be757..5c62578 100644 --- a/internal/generatedmodels/sql_public_agent_parts.go +++ b/internal/generatedmodels/sql_public_agent_parts.go @@ -3,24 +3,24 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentParts struct { bun.BaseModel `bun:"table:public.agent_parts,alias:agent_parts"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - Content resolvespec_common.SqlString `bun:"content,type:text,default:'',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"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - PartType resolvespec_common.SqlString `bun:"part_type,type:text,notnull," json:"part_type"` - Summary resolvespec_common.SqlString `bun:"summary,type:text,notnull," json:"summary"` - 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"` - RelPartIDPublicAgentPersonaParts []*ModelPublicAgentPersonaParts `bun:"rel:has-many,join:id=part_id" json:"relpartidpublicagentpersonaparts,omitempty"` // Has many ModelPublicAgentPersonaParts - RelPartIDPublicArcStageParts []*ModelPublicArcStageParts `bun:"rel:has-many,join:id=part_id" json:"relpartidpublicarcstageparts,omitempty"` // Has many ModelPublicArcStageParts + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + Content sql_types.SqlString `bun:"content,type:text,default:'',notnull," json:"content"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + PartType sql_types.SqlString `bun:"part_type,type:text,notnull," json:"part_type"` + Summary sql_types.SqlString `bun:"summary,type:text,notnull," json:"summary"` + Tags sql_types.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelPartIDPublicAgentPersonaParts []*ModelPublicAgentPersonaParts `bun:"rel:has-many,join:id=part_id" json:"relpartidpublicagentpersonaparts,omitempty"` // Has many ModelPublicAgentPersonaParts + RelPartIDPublicArcStageParts []*ModelPublicArcStageParts `bun:"rel:has-many,join:id=part_id" json:"relpartidpublicarcstageparts,omitempty"` // Has many ModelPublicArcStageParts } // TableName returns the table name for ModelPublicAgentParts diff --git a/internal/generatedmodels/sql_public_agent_persona_guardrails.go b/internal/generatedmodels/sql_public_agent_persona_guardrails.go index a5bfc0c..56b3b27 100644 --- a/internal/generatedmodels/sql_public_agent_persona_guardrails.go +++ b/internal/generatedmodels/sql_public_agent_persona_guardrails.go @@ -3,13 +3,13 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentPersonaGuardrails struct { bun.BaseModel `bun:"table:public.agent_persona_guardrails,alias:agent_persona_guardrails"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` GuardrailID int64 `bun:"guardrail_id,type:bigint,notnull," json:"guardrail_id"` PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` RelGuardrailID *ModelPublicAgentGuardrails `bun:"rel:has-one,join:guardrail_id=id" json:"relguardrailid,omitempty"` // Has one ModelPublicAgentGuardrails diff --git a/internal/generatedmodels/sql_public_agent_persona_parts.go b/internal/generatedmodels/sql_public_agent_persona_parts.go index 4e803c1..418f214 100644 --- a/internal/generatedmodels/sql_public_agent_persona_parts.go +++ b/internal/generatedmodels/sql_public_agent_persona_parts.go @@ -3,19 +3,19 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentPersonaParts struct { bun.BaseModel `bun:"table:public.agent_persona_parts,alias:agent_persona_parts"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - PartID int64 `bun:"part_id,type:bigint,notnull," json:"part_id"` - PartOrder int32 `bun:"part_order,type:int,default:0,notnull," json:"part_order"` - PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` - Priority int32 `bun:"priority,type:int,default:0,notnull," json:"priority"` - RelPartID *ModelPublicAgentParts `bun:"rel:has-one,join:part_id=id" json:"relpartid,omitempty"` // Has one ModelPublicAgentParts - RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + PartID int64 `bun:"part_id,type:bigint,notnull," json:"part_id"` + PartOrder int32 `bun:"part_order,type:int,default:0,notnull," json:"part_order"` + PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` + Priority int32 `bun:"priority,type:int,default:0,notnull," json:"priority"` + RelPartID *ModelPublicAgentParts `bun:"rel:has-one,join:part_id=id" json:"relpartid,omitempty"` // Has one ModelPublicAgentParts + RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas } // TableName returns the table name for ModelPublicAgentPersonaParts diff --git a/internal/generatedmodels/sql_public_agent_persona_skills.go b/internal/generatedmodels/sql_public_agent_persona_skills.go index c8a7dfc..bedf2c1 100644 --- a/internal/generatedmodels/sql_public_agent_persona_skills.go +++ b/internal/generatedmodels/sql_public_agent_persona_skills.go @@ -3,18 +3,18 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentPersonaSkills struct { bun.BaseModel `bun:"table:public.agent_persona_skills,alias:agent_persona_skills"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - Override bool `bun:"override,type:boolean,default:false,notnull," json:"override"` - PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` - SkillID int64 `bun:"skill_id,type:bigint,notnull," json:"skill_id"` - RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas - RelSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:skill_id=id" json:"relskillid,omitempty"` // Has one ModelPublicAgentSkills + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + Override bool `bun:"override,type:boolean,default:false,notnull," json:"override"` + PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` + SkillID int64 `bun:"skill_id,type:bigint,notnull," json:"skill_id"` + RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas + RelSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:skill_id=id" json:"relskillid,omitempty"` // Has one ModelPublicAgentSkills } // TableName returns the table name for ModelPublicAgentPersonaSkills diff --git a/internal/generatedmodels/sql_public_agent_persona_traits.go b/internal/generatedmodels/sql_public_agent_persona_traits.go index d6c0ad9..d6563b5 100644 --- a/internal/generatedmodels/sql_public_agent_persona_traits.go +++ b/internal/generatedmodels/sql_public_agent_persona_traits.go @@ -3,17 +3,17 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentPersonaTraits struct { bun.BaseModel `bun:"table:public.agent_persona_traits,alias:agent_persona_traits"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` - TraitID int64 `bun:"trait_id,type:bigint,notnull," json:"trait_id"` - RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas - RelTraitID *ModelPublicAgentTraits `bun:"rel:has-one,join:trait_id=id" json:"reltraitid,omitempty"` // Has one ModelPublicAgentTraits + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` + TraitID int64 `bun:"trait_id,type:bigint,notnull," json:"trait_id"` + RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas + RelTraitID *ModelPublicAgentTraits `bun:"rel:has-one,join:trait_id=id" json:"reltraitid,omitempty"` // Has one ModelPublicAgentTraits } // TableName returns the table name for ModelPublicAgentPersonaTraits diff --git a/internal/generatedmodels/sql_public_agent_personas.go b/internal/generatedmodels/sql_public_agent_personas.go index 2251ab6..2e1bdcf 100644 --- a/internal/generatedmodels/sql_public_agent_personas.go +++ b/internal/generatedmodels/sql_public_agent_personas.go @@ -3,24 +3,24 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentPersonas struct { bun.BaseModel `bun:"table:public.agent_personas,alias:agent_personas"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CompiledAt resolvespec_common.SqlTimeStamp `bun:"compiled_at,type:timestamptz,nullzero," json:"compiled_at"` - CompiledDetail resolvespec_common.SqlString `bun:"compiled_detail,type:text,default:'',notnull," json:"compiled_detail"` - CompiledSummary resolvespec_common.SqlString `bun:"compiled_summary,type:text,default:'',notnull," json:"compiled_summary"` - 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"` - Detail resolvespec_common.SqlString `bun:"detail,type:text,default:'',notnull," json:"detail"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Summary resolvespec_common.SqlString `bun:"summary,type:text,notnull," json:"summary"` - 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"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CompiledAt sql_types.SqlTimeStamp `bun:"compiled_at,type:timestamptz,nullzero," json:"compiled_at"` + CompiledDetail sql_types.SqlString `bun:"compiled_detail,type:text,default:'',notnull," json:"compiled_detail"` + CompiledSummary sql_types.SqlString `bun:"compiled_summary,type:text,default:'',notnull," json:"compiled_summary"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + Detail sql_types.SqlString `bun:"detail,type:text,default:'',notnull," json:"detail"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + Summary sql_types.SqlString `bun:"summary,type:text,notnull," json:"summary"` + Tags sql_types.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` RelPersonaIDPublicAgentPersonaParts []*ModelPublicAgentPersonaParts `bun:"rel:has-many,join:id=persona_id" json:"relpersonaidpublicagentpersonaparts,omitempty"` // Has many ModelPublicAgentPersonaParts RelPersonaIDPublicAgentPersonaSkills []*ModelPublicAgentPersonaSkills `bun:"rel:has-many,join:id=persona_id" json:"relpersonaidpublicagentpersonaskills,omitempty"` // Has many ModelPublicAgentPersonaSkills RelPersonaIDPublicProjectPersonas []*ModelPublicProjectPersonas `bun:"rel:has-many,join:id=persona_id" json:"relpersonaidpublicprojectpersonas,omitempty"` // Has many ModelPublicProjectPersonas diff --git a/internal/generatedmodels/sql_public_agent_skills.go b/internal/generatedmodels/sql_public_agent_skills.go index 4913cf0..6aa174f 100644 --- a/internal/generatedmodels/sql_public_agent_skills.go +++ b/internal/generatedmodels/sql_public_agent_skills.go @@ -3,28 +3,28 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentSkills struct { bun.BaseModel `bun:"table:public.agent_skills,alias:agent_skills"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," 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"` - DomainTags resolvespec_common.SqlStringArray `bun:"domain_tags,type:text[],default:'{}',notnull," json:"domain_tags"` - FrameworkTags resolvespec_common.SqlStringArray `bun:"framework_tags,type:text[],default:'{}',notnull," json:"framework_tags"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - LanguageTags resolvespec_common.SqlStringArray `bun:"language_tags,type:text[],default:'{}',notnull," json:"language_tags"` - LibraryTags resolvespec_common.SqlStringArray `bun:"library_tags,type:text[],default:'{}',notnull," json:"library_tags"` - 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"` - RelSkillIDPublicAgentPersonaSkills []*ModelPublicAgentPersonaSkills `bun:"rel:has-many,join:id=skill_id" json:"relskillidpublicagentpersonaskills,omitempty"` // Has many ModelPublicAgentPersonaSkills - 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 sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + Content sql_types.SqlString `bun:"content,type:text,notnull," json:"content"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + DomainTags sql_types.SqlStringArray `bun:"domain_tags,type:text[],default:'{}',notnull," json:"domain_tags"` + FrameworkTags sql_types.SqlStringArray `bun:"framework_tags,type:text[],default:'{}',notnull," json:"framework_tags"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + LanguageTags sql_types.SqlStringArray `bun:"language_tags,type:text[],default:'{}',notnull," json:"language_tags"` + LibraryTags sql_types.SqlStringArray `bun:"library_tags,type:text[],default:'{}',notnull," json:"library_tags"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + Tags sql_types.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelSkillIDPublicAgentPersonaSkills []*ModelPublicAgentPersonaSkills `bun:"rel:has-many,join:id=skill_id" json:"relskillidpublicagentpersonaskills,omitempty"` // Has many ModelPublicAgentPersonaSkills + 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_agent_traits.go b/internal/generatedmodels/sql_public_agent_traits.go index 867b613..08a7c74 100644 --- a/internal/generatedmodels/sql_public_agent_traits.go +++ b/internal/generatedmodels/sql_public_agent_traits.go @@ -3,22 +3,22 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicAgentTraits struct { bun.BaseModel `bun:"table:public.agent_traits,alias:agent_traits"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - 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"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - Instruction resolvespec_common.SqlString `bun:"instruction,type:text,default:'',notnull," json:"instruction"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - Tags resolvespec_common.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` - TraitType resolvespec_common.SqlString `bun:"trait_type,type:text,notnull," json:"trait_type"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelTraitIDPublicAgentPersonaTraits []*ModelPublicAgentPersonaTraits `bun:"rel:has-many,join:id=trait_id" json:"reltraitidpublicagentpersonatraits,omitempty"` // Has many ModelPublicAgentPersonaTraits + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Instruction sql_types.SqlString `bun:"instruction,type:text,default:'',notnull," json:"instruction"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + Tags sql_types.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` + TraitType sql_types.SqlString `bun:"trait_type,type:text,notnull," json:"trait_type"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelTraitIDPublicAgentPersonaTraits []*ModelPublicAgentPersonaTraits `bun:"rel:has-many,join:id=trait_id" json:"reltraitidpublicagentpersonatraits,omitempty"` // Has many ModelPublicAgentPersonaTraits } // TableName returns the table name for ModelPublicAgentTraits diff --git a/internal/generatedmodels/sql_public_arc_stage_parts.go b/internal/generatedmodels/sql_public_arc_stage_parts.go index dfb5cc7..fd068e2 100644 --- a/internal/generatedmodels/sql_public_arc_stage_parts.go +++ b/internal/generatedmodels/sql_public_arc_stage_parts.go @@ -3,17 +3,17 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicArcStageParts struct { bun.BaseModel `bun:"table:public.arc_stage_parts,alias:arc_stage_parts"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - PartID int64 `bun:"part_id,type:bigint,notnull," json:"part_id"` - StageID int64 `bun:"stage_id,type:bigint,notnull," json:"stage_id"` - RelPartID *ModelPublicAgentParts `bun:"rel:has-one,join:part_id=id" json:"relpartid,omitempty"` // Has one ModelPublicAgentParts - RelStageID *ModelPublicArcStages `bun:"rel:has-one,join:stage_id=id" json:"relstageid,omitempty"` // Has one ModelPublicArcStages + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + PartID int64 `bun:"part_id,type:bigint,notnull," json:"part_id"` + StageID int64 `bun:"stage_id,type:bigint,notnull," json:"stage_id"` + RelPartID *ModelPublicAgentParts `bun:"rel:has-one,join:part_id=id" json:"relpartid,omitempty"` // Has one ModelPublicAgentParts + RelStageID *ModelPublicArcStages `bun:"rel:has-one,join:stage_id=id" json:"relstageid,omitempty"` // Has one ModelPublicArcStages } // TableName returns the table name for ModelPublicArcStageParts diff --git a/internal/generatedmodels/sql_public_arc_stages.go b/internal/generatedmodels/sql_public_arc_stages.go index e421dc6..d1160d7 100644 --- a/internal/generatedmodels/sql_public_arc_stages.go +++ b/internal/generatedmodels/sql_public_arc_stages.go @@ -3,22 +3,22 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicArcStages struct { bun.BaseModel `bun:"table:public.arc_stages,alias:arc_stages"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - ArcID int64 `bun:"arc_id,type:bigint,notnull," json:"arc_id"` - Condition resolvespec_common.SqlString `bun:"condition,type:text,default:'',notnull," json:"condition"` - 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"` - StageOrder int32 `bun:"stage_order,type:int,default:0,notnull," json:"stage_order"` - RelArcID *ModelPublicCharacterArcs `bun:"rel:has-one,join:arc_id=id" json:"relarcid,omitempty"` // Has one ModelPublicCharacterArcs - RelStageIDPublicArcStageParts []*ModelPublicArcStageParts `bun:"rel:has-many,join:id=stage_id" json:"relstageidpublicarcstageparts,omitempty"` // Has many ModelPublicArcStageParts - RelCurrentStageIDPublicPersonaArcs []*ModelPublicPersonaArc `bun:"rel:has-many,join:id=current_stage_id" json:"relcurrentstageidpublicpersonaarcs,omitempty"` // Has many ModelPublicPersonaArc + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + ArcID int64 `bun:"arc_id,type:bigint,notnull," json:"arc_id"` + Condition sql_types.SqlString `bun:"condition,type:text,default:'',notnull," json:"condition"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + StageOrder int32 `bun:"stage_order,type:int,default:0,notnull," json:"stage_order"` + RelArcID *ModelPublicCharacterArcs `bun:"rel:has-one,join:arc_id=id" json:"relarcid,omitempty"` // Has one ModelPublicCharacterArcs + RelStageIDPublicArcStageParts []*ModelPublicArcStageParts `bun:"rel:has-many,join:id=stage_id" json:"relstageidpublicarcstageparts,omitempty"` // Has many ModelPublicArcStageParts + RelCurrentStageIDPublicPersonaArcs []*ModelPublicPersonaArc `bun:"rel:has-many,join:id=current_stage_id" json:"relcurrentstageidpublicpersonaarcs,omitempty"` // Has many ModelPublicPersonaArc } // TableName returns the table name for ModelPublicArcStages diff --git a/internal/generatedmodels/sql_public_character_arcs.go b/internal/generatedmodels/sql_public_character_arcs.go index d2c1cab..a70043e 100644 --- a/internal/generatedmodels/sql_public_character_arcs.go +++ b/internal/generatedmodels/sql_public_character_arcs.go @@ -3,20 +3,20 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicCharacterArcs struct { bun.BaseModel `bun:"table:public.character_arcs,alias:character_arcs"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - 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"` - Summary resolvespec_common.SqlString `bun:"summary,type:text,default:'',notnull," json:"summary"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelArcIDPublicArcStages []*ModelPublicArcStages `bun:"rel:has-many,join:id=arc_id" json:"relarcidpublicarcstages,omitempty"` // Has many ModelPublicArcStages - RelArcIDPublicPersonaArcs []*ModelPublicPersonaArc `bun:"rel:has-many,join:id=arc_id" json:"relarcidpublicpersonaarcs,omitempty"` // Has many ModelPublicPersonaArc + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + Summary sql_types.SqlString `bun:"summary,type:text,default:'',notnull," json:"summary"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelArcIDPublicArcStages []*ModelPublicArcStages `bun:"rel:has-many,join:id=arc_id" json:"relarcidpublicarcstages,omitempty"` // Has many ModelPublicArcStages + RelArcIDPublicPersonaArcs []*ModelPublicPersonaArc `bun:"rel:has-many,join:id=arc_id" json:"relarcidpublicpersonaarcs,omitempty"` // Has many ModelPublicPersonaArc } // TableName returns the table name for ModelPublicCharacterArcs diff --git a/internal/generatedmodels/sql_public_chat_histories.go b/internal/generatedmodels/sql_public_chat_histories.go index a1e1315..a3b3979 100644 --- a/internal/generatedmodels/sql_public_chat_histories.go +++ b/internal/generatedmodels/sql_public_chat_histories.go @@ -3,25 +3,26 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicChatHistories struct { bun.BaseModel `bun:"table:public.chat_histories,alias:chat_histories"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - 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"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - 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.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` - SessionID resolvespec_common.SqlString `bun:"session_id,type:text,notnull," json:"session_id"` - Summary resolvespec_common.SqlString `bun:"summary,type:text,nullzero," json:"summary"` - 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"` - RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + AgentID sql_types.SqlString `bun:"agent_id,type:text,nullzero," json:"agent_id"` + Channel sql_types.SqlString `bun:"channel,type:text,nullzero," json:"channel"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Messages sql_types.SqlJSONB `bun:"messages,type:jsonb,default:'[]',notnull," json:"messages"` + Metadata sql_types.SqlJSONB `bun:"metadata,type:jsonb,default:'{}',notnull," json:"metadata"` + ProjectID sql_types.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` + SessionID sql_types.SqlString `bun:"session_id,type:text,notnull," json:"session_id"` + Summary sql_types.SqlString `bun:"summary,type:text,nullzero," json:"summary"` + TenantKey sql_types.SqlString `bun:"tenant_key,type:text,nullzero," json:"tenant_key"` + Title sql_types.SqlString `bun:"title,type:text,nullzero," json:"title"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects } // TableName returns the table name for ModelPublicChatHistories diff --git a/internal/generatedmodels/sql_public_embeddings.go b/internal/generatedmodels/sql_public_embeddings.go index a410b1a..cbe0e65 100644 --- a/internal/generatedmodels/sql_public_embeddings.go +++ b/internal/generatedmodels/sql_public_embeddings.go @@ -3,21 +3,21 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) 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"` - 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 int64 `bun:"thought_id,type:bigint,notnull,unique:uidx_embeddings_thought_id_model," json:"thought_id"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),nullzero," json:"updated_at"` - RelThoughtID *ModelPublicThoughts `bun:"rel:has-one,join:thought_id=id" json:"relthoughtid,omitempty"` // Has one ModelPublicThoughts + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),nullzero," json:"created_at"` + Dim int32 `bun:"dim,type:int,notnull," json:"dim"` + Embedding sql_types.SqlVector `bun:"embedding,type:vector,notnull," json:"embedding"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Model sql_types.SqlString `bun:"model,type:text,notnull,unique:uidx_embeddings_thought_id_model," json:"model"` + ThoughtID int64 `bun:"thought_id,type:bigint,notnull,unique:uidx_embeddings_thought_id_model," json:"thought_id"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),nullzero," json:"updated_at"` + RelThoughtID *ModelPublicThoughts `bun:"rel:has-one,join:thought_id=id" json:"relthoughtid,omitempty"` // Has one ModelPublicThoughts } // TableName returns the table name for ModelPublicEmbeddings diff --git a/internal/generatedmodels/sql_public_learnings.go b/internal/generatedmodels/sql_public_learnings.go index 4f7dab7..1f839f8 100644 --- a/internal/generatedmodels/sql_public_learnings.go +++ b/internal/generatedmodels/sql_public_learnings.go @@ -3,39 +3,41 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicLearnings struct { - bun.BaseModel `bun:"table:public.learnings,alias:learnings"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," 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.SqlInt64 `bun:"duplicate_of_learning_id,type:bigint,nullzero," json:"duplicate_of_learning_id"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - Priority resolvespec_common.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` - ProjectID resolvespec_common.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` - RelatedSkillID resolvespec_common.SqlInt64 `bun:"related_skill_id,type:bigint,nullzero," json:"related_skill_id"` - RelatedThoughtID resolvespec_common.SqlInt64 `bun:"related_thought_id,type:bigint,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.SqlInt64 `bun:"supersedes_learning_id,type:bigint,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=id" 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=id" json:"relrelatedthoughtid,omitempty"` // Has one ModelPublicThoughts - RelSupersedesLearningID *ModelPublicLearnings `bun:"rel:has-one,join:supersedes_learning_id=id" json:"relsupersedeslearningid,omitempty"` // Has one ModelPublicLearnings + bun.BaseModel `bun:"table:public.learnings,alias:learnings"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + ActionRequired bool `bun:"action_required,type:boolean,default:false,notnull," json:"action_required"` + Area sql_types.SqlString `bun:"area,type:text,default:'other',notnull," json:"area"` + Category sql_types.SqlString `bun:"category,type:text,default:'insight',notnull," json:"category"` + Confidence sql_types.SqlString `bun:"confidence,type:text,default:'hypothesis',notnull," json:"confidence"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Details sql_types.SqlString `bun:"details,type:text,default:'',notnull," json:"details"` + DuplicateOfLearningID sql_types.SqlInt64 `bun:"duplicate_of_learning_id,type:bigint,nullzero," json:"duplicate_of_learning_id"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Priority sql_types.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` + ProjectID sql_types.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` + RelatedSkillID sql_types.SqlInt64 `bun:"related_skill_id,type:bigint,nullzero," json:"related_skill_id"` + RelatedThoughtID sql_types.SqlInt64 `bun:"related_thought_id,type:bigint,nullzero," json:"related_thought_id"` + ReviewedAt sql_types.SqlTimeStamp `bun:"reviewed_at,type:timestamptz,nullzero," json:"reviewed_at"` + ReviewedBy sql_types.SqlString `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"` + SourceRef sql_types.SqlString `bun:"source_ref,type:text,nullzero," json:"source_ref"` + SourceType sql_types.SqlString `bun:"source_type,type:text,nullzero," json:"source_type"` + Status sql_types.SqlString `bun:"status,type:text,default:'pending',notnull," json:"status"` + Summary sql_types.SqlString `bun:"summary,type:text,notnull," json:"summary"` + SupersedesLearningID sql_types.SqlInt64 `bun:"supersedes_learning_id,type:bigint,nullzero," json:"supersedes_learning_id"` + Tags sql_types.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` + TenantKey sql_types.SqlString `bun:"tenant_key,type:text,nullzero," json:"tenant_key"` + UpdatedAt sql_types.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=id" 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=id" json:"relrelatedthoughtid,omitempty"` // Has one ModelPublicThoughts + RelSupersedesLearningID *ModelPublicLearnings `bun:"rel:has-one,join:supersedes_learning_id=id" json:"relsupersedeslearningid,omitempty"` // Has one ModelPublicLearnings + RelLearningIDPublicThoughtLearningLinks []*ModelPublicThoughtLearningLinks `bun:"rel:has-many,join:id=learning_id" json:"rellearningidpublicthoughtlearninglinks,omitempty"` // Has many ModelPublicThoughtLearningLinks } // TableName returns the table name for ModelPublicLearnings diff --git a/internal/generatedmodels/sql_public_oauth_clients.go b/internal/generatedmodels/sql_public_oauth_clients.go index 877e2d7..5856241 100644 --- a/internal/generatedmodels/sql_public_oauth_clients.go +++ b/internal/generatedmodels/sql_public_oauth_clients.go @@ -3,17 +3,17 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicOauthClients struct { bun.BaseModel `bun:"table:public.oauth_clients,alias:oauth_clients"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - ClientID resolvespec_common.SqlString `bun:"client_id,type:text,notnull," json:"client_id"` - ClientName resolvespec_common.SqlString `bun:"client_name,type:text,default:'',notnull," json:"client_name"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - RedirectUris resolvespec_common.SqlStringArray `bun:"redirect_uris,type:text[],default:'{}',notnull," json:"redirect_uris"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + ClientID sql_types.SqlString `bun:"client_id,type:text,notnull," json:"client_id"` + ClientName sql_types.SqlString `bun:"client_name,type:text,default:'',notnull," json:"client_name"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + RedirectUris sql_types.SqlStringArray `bun:"redirect_uris,type:text[],default:'{}',notnull," json:"redirect_uris"` } // TableName returns the table name for ModelPublicOauthClients diff --git a/internal/generatedmodels/sql_public_persona_arc.go b/internal/generatedmodels/sql_public_persona_arc.go index 179ab27..5e07d42 100644 --- a/internal/generatedmodels/sql_public_persona_arc.go +++ b/internal/generatedmodels/sql_public_persona_arc.go @@ -3,20 +3,20 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicPersonaArc struct { bun.BaseModel `bun:"table:public.persona_arc,alias:persona_arc"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - PersonaID int64 `bun:"persona_id,type:bigint,pk," json:"persona_id"` - ArcID int64 `bun:"arc_id,type:bigint,notnull," json:"arc_id"` - CurrentStageID int64 `bun:"current_stage_id,type:bigint,notnull," json:"current_stage_id"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelArcID *ModelPublicCharacterArcs `bun:"rel:has-one,join:arc_id=id" json:"relarcid,omitempty"` // Has one ModelPublicCharacterArcs - RelCurrentStageID *ModelPublicArcStages `bun:"rel:has-one,join:current_stage_id=id" json:"relcurrentstageid,omitempty"` // Has one ModelPublicArcStages - RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + PersonaID int64 `bun:"persona_id,type:bigint,pk," json:"persona_id"` + ArcID int64 `bun:"arc_id,type:bigint,notnull," json:"arc_id"` + CurrentStageID int64 `bun:"current_stage_id,type:bigint,notnull," json:"current_stage_id"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelArcID *ModelPublicCharacterArcs `bun:"rel:has-one,join:arc_id=id" json:"relarcid,omitempty"` // Has one ModelPublicCharacterArcs + RelCurrentStageID *ModelPublicArcStages `bun:"rel:has-one,join:current_stage_id=id" json:"relcurrentstageid,omitempty"` // Has one ModelPublicArcStages + RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas } // TableName returns the table name for ModelPublicPersonaArc diff --git a/internal/generatedmodels/sql_public_plan_dependencies.go b/internal/generatedmodels/sql_public_plan_dependencies.go index 2d82802..0752194 100644 --- a/internal/generatedmodels/sql_public_plan_dependencies.go +++ b/internal/generatedmodels/sql_public_plan_dependencies.go @@ -3,18 +3,18 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicPlanDependencies struct { bun.BaseModel `bun:"table:public.plan_dependencies,alias:plan_dependencies"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - DependsOnPlanID int64 `bun:"depends_on_plan_id,type:bigint,notnull,unique:uidx_plan_dependencies_plan_id_depends_on_plan_id," json:"depends_on_plan_id"` - PlanID int64 `bun:"plan_id,type:bigint,notnull,unique:uidx_plan_dependencies_plan_id_depends_on_plan_id," json:"plan_id"` - RelDependsOnPlanID *ModelPublicPlans `bun:"rel:has-one,join:depends_on_plan_id=id" json:"reldependsonplanid,omitempty"` // Has one ModelPublicPlans - RelPlanID *ModelPublicPlans `bun:"rel:has-one,join:plan_id=id" json:"relplanid,omitempty"` // Has one ModelPublicPlans + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + DependsOnPlanID int64 `bun:"depends_on_plan_id,type:bigint,notnull,unique:uidx_plan_dependencies_plan_id_depends_on_plan_id," json:"depends_on_plan_id"` + PlanID int64 `bun:"plan_id,type:bigint,notnull,unique:uidx_plan_dependencies_plan_id_depends_on_plan_id," json:"plan_id"` + RelDependsOnPlanID *ModelPublicPlans `bun:"rel:has-one,join:depends_on_plan_id=id" json:"reldependsonplanid,omitempty"` // Has one ModelPublicPlans + RelPlanID *ModelPublicPlans `bun:"rel:has-one,join:plan_id=id" json:"relplanid,omitempty"` // Has one ModelPublicPlans } // TableName returns the table name for ModelPublicPlanDependencies diff --git a/internal/generatedmodels/sql_public_plan_guardrails.go b/internal/generatedmodels/sql_public_plan_guardrails.go index 4a1bfc1..68ae3a3 100644 --- a/internal/generatedmodels/sql_public_plan_guardrails.go +++ b/internal/generatedmodels/sql_public_plan_guardrails.go @@ -3,18 +3,18 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicPlanGuardrails struct { bun.BaseModel `bun:"table:public.plan_guardrails,alias:plan_guardrails"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - GuardrailID int64 `bun:"guardrail_id,type:bigint,notnull,unique:uidx_plan_guardrails_plan_id_guardrail_id," json:"guardrail_id"` - PlanID int64 `bun:"plan_id,type:bigint,notnull,unique:uidx_plan_guardrails_plan_id_guardrail_id," json:"plan_id"` - RelGuardrailID *ModelPublicAgentGuardrails `bun:"rel:has-one,join:guardrail_id=id" json:"relguardrailid,omitempty"` // Has one ModelPublicAgentGuardrails - RelPlanID *ModelPublicPlans `bun:"rel:has-one,join:plan_id=id" json:"relplanid,omitempty"` // Has one ModelPublicPlans + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + GuardrailID int64 `bun:"guardrail_id,type:bigint,notnull,unique:uidx_plan_guardrails_plan_id_guardrail_id," json:"guardrail_id"` + PlanID int64 `bun:"plan_id,type:bigint,notnull,unique:uidx_plan_guardrails_plan_id_guardrail_id," json:"plan_id"` + RelGuardrailID *ModelPublicAgentGuardrails `bun:"rel:has-one,join:guardrail_id=id" json:"relguardrailid,omitempty"` // Has one ModelPublicAgentGuardrails + RelPlanID *ModelPublicPlans `bun:"rel:has-one,join:plan_id=id" json:"relplanid,omitempty"` // Has one ModelPublicPlans } // TableName returns the table name for ModelPublicPlanGuardrails diff --git a/internal/generatedmodels/sql_public_plan_related_plans.go b/internal/generatedmodels/sql_public_plan_related_plans.go index ea733fe..911801f 100644 --- a/internal/generatedmodels/sql_public_plan_related_plans.go +++ b/internal/generatedmodels/sql_public_plan_related_plans.go @@ -3,18 +3,18 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicPlanRelatedPlans struct { bun.BaseModel `bun:"table:public.plan_related_plans,alias:plan_related_plans"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - PlanAID int64 `bun:"plan_a_id,type:bigint,notnull,unique:uidx_plan_related_plans_plan_a_id_plan_b_id," json:"plan_a_id"` - PlanBID int64 `bun:"plan_b_id,type:bigint,notnull,unique:uidx_plan_related_plans_plan_a_id_plan_b_id," json:"plan_b_id"` - RelPlanAID *ModelPublicPlans `bun:"rel:has-one,join:plan_a_id=id" json:"relplanaid,omitempty"` // Has one ModelPublicPlans - RelPlanBID *ModelPublicPlans `bun:"rel:has-one,join:plan_b_id=id" json:"relplanbid,omitempty"` // Has one ModelPublicPlans + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + PlanAID int64 `bun:"plan_a_id,type:bigint,notnull,unique:uidx_plan_related_plans_plan_a_id_plan_b_id," json:"plan_a_id"` + PlanBID int64 `bun:"plan_b_id,type:bigint,notnull,unique:uidx_plan_related_plans_plan_a_id_plan_b_id," json:"plan_b_id"` + RelPlanAID *ModelPublicPlans `bun:"rel:has-one,join:plan_a_id=id" json:"relplanaid,omitempty"` // Has one ModelPublicPlans + RelPlanBID *ModelPublicPlans `bun:"rel:has-one,join:plan_b_id=id" json:"relplanbid,omitempty"` // Has one ModelPublicPlans } // TableName returns the table name for ModelPublicPlanRelatedPlans diff --git a/internal/generatedmodels/sql_public_plan_skills.go b/internal/generatedmodels/sql_public_plan_skills.go index b6f1a28..790d84c 100644 --- a/internal/generatedmodels/sql_public_plan_skills.go +++ b/internal/generatedmodels/sql_public_plan_skills.go @@ -3,18 +3,18 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicPlanSkills struct { bun.BaseModel `bun:"table:public.plan_skills,alias:plan_skills"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - PlanID int64 `bun:"plan_id,type:bigint,notnull,unique:uidx_plan_skills_plan_id_skill_id," json:"plan_id"` - SkillID int64 `bun:"skill_id,type:bigint,notnull,unique:uidx_plan_skills_plan_id_skill_id," json:"skill_id"` - RelPlanID *ModelPublicPlans `bun:"rel:has-one,join:plan_id=id" json:"relplanid,omitempty"` // Has one ModelPublicPlans - RelSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:skill_id=id" json:"relskillid,omitempty"` // Has one ModelPublicAgentSkills + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + PlanID int64 `bun:"plan_id,type:bigint,notnull,unique:uidx_plan_skills_plan_id_skill_id," json:"plan_id"` + SkillID int64 `bun:"skill_id,type:bigint,notnull,unique:uidx_plan_skills_plan_id_skill_id," json:"skill_id"` + RelPlanID *ModelPublicPlans `bun:"rel:has-one,join:plan_id=id" json:"relplanid,omitempty"` // Has one ModelPublicPlans + RelSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:skill_id=id" json:"relskillid,omitempty"` // Has one ModelPublicAgentSkills } // TableName returns the table name for ModelPublicPlanSkills diff --git a/internal/generatedmodels/sql_public_plans.go b/internal/generatedmodels/sql_public_plans.go index 2f3c12c..431afed 100644 --- a/internal/generatedmodels/sql_public_plans.go +++ b/internal/generatedmodels/sql_public_plans.go @@ -3,36 +3,37 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicPlans struct { bun.BaseModel `bun:"table:public.plans,alias:plans"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," 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"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - 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.SqlInt64 `bun:"project_id,type:bigint,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.SqlInt64 `bun:"supersedes_plan_id,type:bigint,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=id" 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 sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CompletedAt sql_types.SqlTimeStamp `bun:"completed_at,type:timestamptz,nullzero," json:"completed_at"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,default:'',notnull," json:"description"` + DueDate sql_types.SqlTimeStamp `bun:"due_date,type:timestamptz,nullzero," json:"due_date"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + LastReviewedAt sql_types.SqlTimeStamp `bun:"last_reviewed_at,type:timestamptz,nullzero," json:"last_reviewed_at"` + Owner sql_types.SqlString `bun:"owner,type:text,nullzero," json:"owner"` + Priority sql_types.SqlString `bun:"priority,type:text,default:'medium',notnull," json:"priority"` // low, medium, high, critical + ProjectID sql_types.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` + ReviewedBy sql_types.SqlString `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"` + Status sql_types.SqlString `bun:"status,type:text,default:'draft',notnull," json:"status"` // draft, active, blocked, completed, cancelled, superseded + SupersedesPlanID sql_types.SqlInt64 `bun:"supersedes_plan_id,type:bigint,nullzero," json:"supersedes_plan_id"` + Tags sql_types.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"` + TenantKey sql_types.SqlString `bun:"tenant_key,type:text,nullzero," json:"tenant_key"` + Title sql_types.SqlString `bun:"title,type:text,notnull," json:"title"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" 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_project_guardrails.go b/internal/generatedmodels/sql_public_project_guardrails.go index 9f8493e..ff70a84 100644 --- a/internal/generatedmodels/sql_public_project_guardrails.go +++ b/internal/generatedmodels/sql_public_project_guardrails.go @@ -3,18 +3,18 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicProjectGuardrails struct { bun.BaseModel `bun:"table:public.project_guardrails,alias:project_guardrails"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - GuardrailID int64 `bun:"guardrail_id,type:bigint,notnull," json:"guardrail_id"` - ProjectID int64 `bun:"project_id,type:bigint,notnull," json:"project_id"` - RelGuardrailID *ModelPublicAgentGuardrails `bun:"rel:has-one,join:guardrail_id=id" json:"relguardrailid,omitempty"` // Has one ModelPublicAgentGuardrails - RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + GuardrailID int64 `bun:"guardrail_id,type:bigint,notnull," json:"guardrail_id"` + ProjectID int64 `bun:"project_id,type:bigint,notnull," json:"project_id"` + RelGuardrailID *ModelPublicAgentGuardrails `bun:"rel:has-one,join:guardrail_id=id" json:"relguardrailid,omitempty"` // Has one ModelPublicAgentGuardrails + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects } // TableName returns the table name for ModelPublicProjectGuardrails diff --git a/internal/generatedmodels/sql_public_project_personas.go b/internal/generatedmodels/sql_public_project_personas.go index 2051990..2ce025f 100644 --- a/internal/generatedmodels/sql_public_project_personas.go +++ b/internal/generatedmodels/sql_public_project_personas.go @@ -3,19 +3,19 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicProjectPersonas struct { bun.BaseModel `bun:"table:public.project_personas,alias:project_personas"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - IsDefault bool `bun:"is_default,type:boolean,default:false,notnull," json:"is_default"` - PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` - ProjectID int64 `bun:"project_id,type:bigint,notnull," json:"project_id"` - RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas - RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + IsDefault bool `bun:"is_default,type:boolean,default:false,notnull," json:"is_default"` + PersonaID int64 `bun:"persona_id,type:bigint,notnull," json:"persona_id"` + ProjectID int64 `bun:"project_id,type:bigint,notnull," json:"project_id"` + RelPersonaID *ModelPublicAgentPersonas `bun:"rel:has-one,join:persona_id=id" json:"relpersonaid,omitempty"` // Has one ModelPublicAgentPersonas + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects } // TableName returns the table name for ModelPublicProjectPersonas diff --git a/internal/generatedmodels/sql_public_project_skills.go b/internal/generatedmodels/sql_public_project_skills.go index c0f1592..d099bfc 100644 --- a/internal/generatedmodels/sql_public_project_skills.go +++ b/internal/generatedmodels/sql_public_project_skills.go @@ -3,19 +3,19 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicProjectSkills struct { bun.BaseModel `bun:"table:public.project_skills,alias:project_skills"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Override bool `bun:"override,type:boolean,default:false,notnull," json:"override"` - ProjectID int64 `bun:"project_id,type:bigint,notnull," json:"project_id"` - SkillID int64 `bun:"skill_id,type:bigint,notnull," json:"skill_id"` - RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects - RelSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:skill_id=id" json:"relskillid,omitempty"` // Has one ModelPublicAgentSkills + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Override bool `bun:"override,type:boolean,default:false,notnull," json:"override"` + ProjectID int64 `bun:"project_id,type:bigint,notnull," json:"project_id"` + SkillID int64 `bun:"skill_id,type:bigint,notnull," json:"skill_id"` + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + RelSkillID *ModelPublicAgentSkills `bun:"rel:has-one,join:skill_id=id" json:"relskillid,omitempty"` // Has one ModelPublicAgentSkills } // TableName returns the table name for ModelPublicProjectSkills diff --git a/internal/generatedmodels/sql_public_projects.go b/internal/generatedmodels/sql_public_projects.go index 94a8375..f1f16cb 100644 --- a/internal/generatedmodels/sql_public_projects.go +++ b/internal/generatedmodels/sql_public_projects.go @@ -3,19 +3,19 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicProjects struct { bun.BaseModel `bun:"table:public.projects,alias:projects"` - 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"` - Description resolvespec_common.SqlString `bun:"description,type:text,nullzero," json:"description"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - LastActiveAt resolvespec_common.SqlTimeStamp `bun:"last_active_at,type:timestamptz,default:now(),nullzero," json:"last_active_at"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - ThoughtCount resolvespec_common.SqlInt64 `bun:"thought_count,scanonly" json:"thought_count"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),nullzero," json:"created_at"` + Description sql_types.SqlString `bun:"description,type:text,nullzero," json:"description"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + LastActiveAt sql_types.SqlTimeStamp `bun:"last_active_at,type:timestamptz,default:now(),nullzero," json:"last_active_at"` + Name sql_types.SqlString `bun:"name,type:text,notnull,unique:uidx_projects_tenant_key_name," json:"name"` + TenantKey sql_types.SqlString `bun:"tenant_key,type:text,nullzero,unique:uidx_projects_tenant_key_name," json:"tenant_key"` RelProjectIDPublicProjectPersonas []*ModelPublicProjectPersonas `bun:"rel:has-many,join:id=project_id" json:"relprojectidpublicprojectpersonas,omitempty"` // Has many ModelPublicProjectPersonas RelProjectIDPublicThoughts []*ModelPublicThoughts `bun:"rel:has-many,join:id=project_id" json:"relprojectidpublicthoughts,omitempty"` // Has many ModelPublicThoughts RelProjectIDPublicStoredFiles []*ModelPublicStoredFiles `bun:"rel:has-many,join:id=project_id" json:"relprojectidpublicstoredfiles,omitempty"` // Has many ModelPublicStoredFiles diff --git a/internal/generatedmodels/sql_public_stored_files.go b/internal/generatedmodels/sql_public_stored_files.go index 54d7932..b00c57e 100644 --- a/internal/generatedmodels/sql_public_stored_files.go +++ b/internal/generatedmodels/sql_public_stored_files.go @@ -3,27 +3,28 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicStoredFiles struct { bun.BaseModel `bun:"table:public.stored_files,alias:stored_files"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - Content []byte `bun:"content,type:bytea,notnull," json:"content"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Encoding resolvespec_common.SqlString `bun:"encoding,type:text,default:'base64',notnull," json:"encoding"` - GUID resolvespec_common.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` - Kind resolvespec_common.SqlString `bun:"kind,type:text,default:'file',notnull," json:"kind"` - MediaType resolvespec_common.SqlString `bun:"media_type,type:text,notnull," json:"media_type"` - Name resolvespec_common.SqlString `bun:"name,type:text,notnull," json:"name"` - ProjectID resolvespec_common.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` - Sha256 resolvespec_common.SqlString `bun:"sha256,type:text,notnull," json:"sha256"` - SizeBytes int64 `bun:"size_bytes,type:bigint,notnull," json:"size_bytes"` - ThoughtID resolvespec_common.SqlInt64 `bun:"thought_id,type:bigint,nullzero," json:"thought_id"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` - RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects - RelThoughtID *ModelPublicThoughts `bun:"rel:has-one,join:thought_id=id" json:"relthoughtid,omitempty"` // Has one ModelPublicThoughts + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + Content []byte `bun:"content,type:bytea,notnull," json:"content"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Encoding sql_types.SqlString `bun:"encoding,type:text,default:'base64',notnull," json:"encoding"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Kind sql_types.SqlString `bun:"kind,type:text,default:'file',notnull," json:"kind"` + MediaType sql_types.SqlString `bun:"media_type,type:text,notnull," json:"media_type"` + Name sql_types.SqlString `bun:"name,type:text,notnull," json:"name"` + ProjectID sql_types.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` + Sha256 sql_types.SqlString `bun:"sha256,type:text,notnull," json:"sha256"` + SizeBytes int64 `bun:"size_bytes,type:bigint,notnull," json:"size_bytes"` + TenantKey sql_types.SqlString `bun:"tenant_key,type:text,nullzero," json:"tenant_key"` + ThoughtID sql_types.SqlInt64 `bun:"thought_id,type:bigint,nullzero," json:"thought_id"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + RelThoughtID *ModelPublicThoughts `bun:"rel:has-one,join:thought_id=id" json:"relthoughtid,omitempty"` // Has one ModelPublicThoughts } // TableName returns the table name for ModelPublicStoredFiles diff --git a/internal/generatedmodels/sql_public_thought_learning_links.go b/internal/generatedmodels/sql_public_thought_learning_links.go new file mode 100644 index 0000000..312d3ba --- /dev/null +++ b/internal/generatedmodels/sql_public_thought_learning_links.go @@ -0,0 +1,64 @@ +// Code generated by relspecgo. DO NOT EDIT. +package generatedmodels + +import ( + "fmt" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" + "github.com/uptrace/bun" +) + +type ModelPublicThoughtLearningLinks struct { + bun.BaseModel `bun:"table:public.thought_learning_links,alias:thought_learning_links"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + LearningID int64 `bun:"learning_id,type:bigint,notnull,unique:uidx_thought_learning_links_thought_id_learning_id," json:"learning_id"` + Relation sql_types.SqlString `bun:"relation,type:text,default:'source',notnull," json:"relation"` + ThoughtID int64 `bun:"thought_id,type:bigint,notnull,unique:uidx_thought_learning_links_thought_id_learning_id," json:"thought_id"` + RelLearningID *ModelPublicLearnings `bun:"rel:has-one,join:learning_id=id" json:"rellearningid,omitempty"` // Has one ModelPublicLearnings + RelThoughtID *ModelPublicThoughts `bun:"rel:has-one,join:thought_id=id" json:"relthoughtid,omitempty"` // Has one ModelPublicThoughts +} + +// TableName returns the table name for ModelPublicThoughtLearningLinks +func (m ModelPublicThoughtLearningLinks) TableName() string { + return "public.thought_learning_links" +} + +// TableNameOnly returns the table name without schema for ModelPublicThoughtLearningLinks +func (m ModelPublicThoughtLearningLinks) TableNameOnly() string { + return "thought_learning_links" +} + +// SchemaName returns the schema name for ModelPublicThoughtLearningLinks +func (m ModelPublicThoughtLearningLinks) SchemaName() string { + return "public" +} + +// GetID returns the primary key value +func (m ModelPublicThoughtLearningLinks) GetID() int64 { + return m.ID.Int64() +} + +// GetIDStr returns the primary key as a string +func (m ModelPublicThoughtLearningLinks) GetIDStr() string { + return m.ID.String() +} + +// SetID sets the primary key value +func (m ModelPublicThoughtLearningLinks) SetID(newid int64) { + m.UpdateID(newid) +} + +// UpdateID updates the primary key value +func (m *ModelPublicThoughtLearningLinks) UpdateID(newid int64) { + m.ID.FromString(fmt.Sprintf("%d", newid)) +} + +// GetIDName returns the name of the primary key column +func (m ModelPublicThoughtLearningLinks) GetIDName() string { + return "id" +} + +// GetPrefix returns the table prefix +func (m ModelPublicThoughtLearningLinks) GetPrefix() string { + return "TLL" +} diff --git a/internal/generatedmodels/sql_public_thought_links.go b/internal/generatedmodels/sql_public_thought_links.go index c021da8..0d344cf 100644 --- a/internal/generatedmodels/sql_public_thought_links.go +++ b/internal/generatedmodels/sql_public_thought_links.go @@ -3,19 +3,19 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicThoughtLinks struct { bun.BaseModel `bun:"table:public.thought_links,alias:thought_links"` - 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"` - FromID int64 `bun:"from_id,type:bigint,notnull," json:"from_id"` - Relation resolvespec_common.SqlString `bun:"relation,type:text,notnull," json:"relation"` - ToID int64 `bun:"to_id,type:bigint,notnull," json:"to_id"` - RelFromID *ModelPublicThoughts `bun:"rel:has-one,join:from_id=id" json:"relfromid,omitempty"` // Has one ModelPublicThoughts - RelToID *ModelPublicThoughts `bun:"rel:has-one,join:to_id=id" json:"reltoid,omitempty"` // Has one ModelPublicThoughts + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),nullzero," json:"created_at"` + FromID int64 `bun:"from_id,type:bigint,notnull," json:"from_id"` + Relation sql_types.SqlString `bun:"relation,type:text,notnull," json:"relation"` + ToID int64 `bun:"to_id,type:bigint,notnull," json:"to_id"` + RelFromID *ModelPublicThoughts `bun:"rel:has-one,join:from_id=id" json:"relfromid,omitempty"` // Has one ModelPublicThoughts + RelToID *ModelPublicThoughts `bun:"rel:has-one,join:to_id=id" json:"reltoid,omitempty"` // Has one ModelPublicThoughts } // TableName returns the table name for ModelPublicThoughtLinks diff --git a/internal/generatedmodels/sql_public_thoughts.go b/internal/generatedmodels/sql_public_thoughts.go index f5c2936..b8d5584 100644 --- a/internal/generatedmodels/sql_public_thoughts.go +++ b/internal/generatedmodels/sql_public_thoughts.go @@ -3,26 +3,28 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicThoughts struct { - bun.BaseModel `bun:"table:public.thoughts,alias:thoughts"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - ArchivedAt resolvespec_common.SqlTimeStamp `bun:"archived_at,type:timestamptz,nullzero," json:"archived_at"` - 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"` - ProjectID resolvespec_common.SqlInt64 `bun:"project_id,type:bigint,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=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects - RelFromIDPublicThoughtLinks []*ModelPublicThoughtLinks `bun:"rel:has-many,join:id=from_id" json:"relfromidpublicthoughtlinks,omitempty"` // Has many ModelPublicThoughtLinks - RelToIDPublicThoughtLinks []*ModelPublicThoughtLinks `bun:"rel:has-many,join:id=to_id" json:"reltoidpublicthoughtlinks,omitempty"` // Has many ModelPublicThoughtLinks - RelThoughtIDPublicEmbeddings []*ModelPublicEmbeddings `bun:"rel:has-many,join:id=thought_id" json:"relthoughtidpublicembeddings,omitempty"` // Has many ModelPublicEmbeddings - RelThoughtIDPublicStoredFiles []*ModelPublicStoredFiles `bun:"rel:has-many,join:id=thought_id" json:"relthoughtidpublicstoredfiles,omitempty"` // Has many ModelPublicStoredFiles - RelRelatedThoughtIDPublicLearnings []*ModelPublicLearnings `bun:"rel:has-many,join:id=related_thought_id" json:"relrelatedthoughtidpubliclearnings,omitempty"` // Has many ModelPublicLearnings + bun.BaseModel `bun:"table:public.thoughts,alias:thoughts"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + ArchivedAt sql_types.SqlTimeStamp `bun:"archived_at,type:timestamptz,nullzero," json:"archived_at"` + Content sql_types.SqlString `bun:"content,type:text,notnull," json:"content"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),nullzero," json:"created_at"` + GUID sql_types.SqlUUID `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"` + Metadata sql_types.SqlJSONB `bun:"metadata,type:jsonb,default:{}::jsonb,nullzero," json:"metadata"` + ProjectID sql_types.SqlInt64 `bun:"project_id,type:bigint,nullzero," json:"project_id"` + TenantKey sql_types.SqlString `bun:"tenant_key,type:text,nullzero," json:"tenant_key"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),nullzero," json:"updated_at"` + RelProjectID *ModelPublicProjects `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"` // Has one ModelPublicProjects + RelFromIDPublicThoughtLinks []*ModelPublicThoughtLinks `bun:"rel:has-many,join:id=from_id" json:"relfromidpublicthoughtlinks,omitempty"` // Has many ModelPublicThoughtLinks + RelToIDPublicThoughtLinks []*ModelPublicThoughtLinks `bun:"rel:has-many,join:id=to_id" json:"reltoidpublicthoughtlinks,omitempty"` // Has many ModelPublicThoughtLinks + RelThoughtIDPublicThoughtLearningLinks []*ModelPublicThoughtLearningLinks `bun:"rel:has-many,join:id=thought_id" json:"relthoughtidpublicthoughtlearninglinks,omitempty"` // Has many ModelPublicThoughtLearningLinks + RelThoughtIDPublicEmbeddings []*ModelPublicEmbeddings `bun:"rel:has-many,join:id=thought_id" json:"relthoughtidpublicembeddings,omitempty"` // Has many ModelPublicEmbeddings + RelThoughtIDPublicStoredFiles []*ModelPublicStoredFiles `bun:"rel:has-many,join:id=thought_id" json:"relthoughtidpublicstoredfiles,omitempty"` // Has many ModelPublicStoredFiles + RelRelatedThoughtIDPublicLearnings []*ModelPublicLearnings `bun:"rel:has-many,join:id=related_thought_id" json:"relrelatedthoughtidpubliclearnings,omitempty"` // Has many ModelPublicLearnings } // TableName returns the table name for ModelPublicThoughts diff --git a/internal/generatedmodels/sql_public_tool_annotations.go b/internal/generatedmodels/sql_public_tool_annotations.go index e938381..679ace5 100644 --- a/internal/generatedmodels/sql_public_tool_annotations.go +++ b/internal/generatedmodels/sql_public_tool_annotations.go @@ -3,17 +3,17 @@ package generatedmodels import ( "fmt" - resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes" + sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" "github.com/uptrace/bun" ) type ModelPublicToolAnnotations struct { bun.BaseModel `bun:"table:public.tool_annotations,alias:tool_annotations"` - ID resolvespec_common.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` - CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` - Notes resolvespec_common.SqlString `bun:"notes,type:text,default:'',notnull," json:"notes"` - ToolName resolvespec_common.SqlString `bun:"tool_name,type:text,notnull," json:"tool_name"` - UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` + ID sql_types.SqlInt64 `bun:"id,type:bigserial,pk,autoincrement," json:"id"` + CreatedAt sql_types.SqlTimeStamp `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"` + Notes sql_types.SqlString `bun:"notes,type:text,default:'',notnull," json:"notes"` + ToolName sql_types.SqlString `bun:"tool_name,type:text,notnull," json:"tool_name"` + UpdatedAt sql_types.SqlTimeStamp `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"` } // TableName returns the table name for ModelPublicToolAnnotations diff --git a/migrations/020_generated_schema.sql b/migrations/020_generated_schema.sql index 4ced9d5..ca2084d 100644 --- a/migrations/020_generated_schema.sql +++ b/migrations/020_generated_schema.sql @@ -82,7 +82,7 @@ CREATE SEQUENCE IF NOT EXISTS public.identity_arc_stage_parts_id START 1 CACHE 1; -CREATE SEQUENCE IF NOT EXISTS public.identity_persona_arc_persona_id +CREATE SEQUENCE IF NOT EXISTS public.identity_persona_arc_id INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 @@ -11401,15 +11401,15 @@ BEGIN IF EXISTS ( SELECT 1 FROM pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace - WHERE c.relname = 'identity_persona_arc_persona_id' + WHERE c.relname = 'identity_persona_arc_id' AND n.nspname = 'public' AND c.relkind = 'S' ) THEN - SELECT COALESCE(MAX(persona_id), 0) + 1 + SELECT COALESCE(MAX(id), 0) + 1 FROM public.persona_arc INTO m_cnt; - PERFORM setval('public.identity_persona_arc_persona_id'::regclass, m_cnt); + PERFORM setval('public.identity_persona_arc_id'::regclass, m_cnt); END IF; END; $$; diff --git a/vendor/git.warky.dev/wdevs/relspecgo/LICENSE b/vendor/git.warky.dev/wdevs/relspecgo/LICENSE new file mode 100644 index 0000000..bc58c5d --- /dev/null +++ b/vendor/git.warky.dev/wdevs/relspecgo/LICENSE @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright 2025 wdevs + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/README.md b/vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/README.md new file mode 100644 index 0000000..2818d15 --- /dev/null +++ b/vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/README.md @@ -0,0 +1,136 @@ +# sqltypes + +Nullable SQL types for hand-written or generated Go models. Each type wraps a +value with a `Valid` flag and implements `database/sql.Scanner`, +`driver.Valuer`, `encoding/json`, `gopkg.in/yaml.v3`, and `encoding/xml` +marshalling — so a single struct field can be scanned from a database row, +round-tripped through JSON/YAML/XML, and written back to the database without +any per-format glue code. + +This package is what the `bun` and `gorm` writers emit when generating models +with `--types sqltypes` (see [`pkg/writers/bun`](../writers/bun/README.md) and +[`pkg/writers/gorm`](../writers/gorm/README.md)). It can also be imported +directly in hand-written models. + +## Import + +```go +import sql_types "git.warky.dev/wdevs/relspecgo/pkg/sqltypes" +``` + +## Scalar types + +All scalar types are instantiations of the generic `SqlNull[T]`: + +| Type | Underlying | Typical SQL type | +|---|---|---| +| `SqlInt16` | `int16` | `smallint` | +| `SqlInt32` | `int32` | `integer` | +| `SqlInt64` | `int64` | `bigint` | +| `SqlFloat32` | `float32` | `real`, `float4` | +| `SqlFloat64` | `float64` | `double precision`, `numeric`, `decimal`, `money` | +| `SqlBool` | `bool` | `boolean` | +| `SqlString` | `string` | `text`, `varchar`, `char`, `citext`, `inet`, `cidr`, `macaddr` | +| `SqlByteArray` | `[]byte` | `bytea` (base64-encoded in JSON/YAML/XML) | +| `SqlUUID` | `uuid.UUID` (`github.com/google/uuid`) | `uuid` | + +You can also instantiate `SqlNull[T]` directly for any type not covered +above, e.g. `SqlNull[MyEnum]`. + +### Date/time types + +Plain `time.Time` doesn't distinguish date-only, time-only, and timestamp +semantics, and its zero value marshals to a confusing `0001-01-01T00:00:00Z`. +These wrapper types fix both problems: + +| Type | Format | Notes | +|---|---|---| +| `SqlTimeStamp` | `2006-01-02T15:04:05` | Full timestamp | +| `SqlDate` | `2006-01-02` | Date only | +| `SqlTime` | `15:04:05` | Time only | + +Zero/pre-epoch values (`time.Time{}` or anything before `0002-01-01`) marshal +to `null` and `Value()` returns `nil`, instead of leaking Go's zero-time +sentinel into the database or API responses. + +### JSON types + +| Type | Underlying | Notes | +|---|---|---| +| `SqlJSONB` | `[]byte` | Raw JSON bytes; `MarshalYAML` decodes to native YAML mappings/sequences instead of an embedded JSON string | +| `SqlJSON` | `= SqlJSONB` | Alias — PostgreSQL's `json` and `jsonb` share the same Go representation | + +`SqlJSONB` has `AsMap()` / `AsSlice()` helpers for pulling out +`map[string]any` / `[]any` without a separate `json.Unmarshal` call. + +### Vector type (pgvector) + +`SqlVector` wraps `[]float32` for the `vector` column type ([pgvector](https://github.com/pgvector/pgvector)), +scanning/writing the `[1,2,3]` literal format pgvector uses over the wire. + +## Array types + +PostgreSQL array columns (`text[]`, `integer[]`, …) map to `SqlXxxArray` +types, each wrapping `Val []T` + `Valid bool` and handling PostgreSQL's +`{a,b,c}` array literal format on `Scan`/`Value`: + +`SqlStringArray`, `SqlInt16Array`, `SqlInt32Array`, `SqlInt64Array`, +`SqlFloat32Array`, `SqlFloat64Array`, `SqlBoolArray`, `SqlUUIDArray`. + +## Constructing values + +Every type has a `NewSqlXxx(v)` constructor that sets `Valid: true`: + +```go +name := sql_types.NewSqlString("Ada Lovelace") +age := sql_types.NewSqlInt32(36) +tags := sql_types.NewSqlStringArray([]string{"engineer", "mathematician"}) +``` + +The zero value of any type (`sql_types.SqlString{}`) is null/invalid — use it +directly for a `NULL` field instead of a separate constructor. + +Generic helpers: + +```go +sql_types.Null(v, valid) // SqlNull[T]{Val: v, Valid: valid} +sql_types.NewSql[T](anyValue) // best-effort conversion from any Go value +``` + +## Reading values back + +Each scalar type has typed accessors that return the zero value instead of +panicking when `Valid` is false: + +```go +n.Int64() // SqlInt16/32/64, SqlFloat32/64, SqlBool, SqlString → int64 +n.Float64() // → float64 +n.Bool() // → bool +n.Time() // SqlNull[time.Time]-based types → time.Time +n.UUID() // SqlUUID → uuid.UUID +n.String() // fmt.Stringer — empty string when invalid +``` + +## Example + +```go +type User struct { + ID sql_types.SqlUUID `json:"id"` + Name sql_types.SqlString `json:"name"` + Tags sql_types.SqlStringArray `json:"tags"` + Metadata sql_types.SqlJSONB `json:"metadata"` + CreatedAt sql_types.SqlTimeStamp `json:"created_at"` +} + +u := User{ + ID: sql_types.NewSqlUUID(uuid.New()), + Name: sql_types.NewSqlString("Ada Lovelace"), + Tags: sql_types.NewSqlStringArray([]string{"engineer"}), + CreatedAt: sql_types.SqlTimeStampNow(), +} +// Metadata left as the zero value → serializes as null, scans as NULL. +``` + +Every type implements `sql.Scanner` and `driver.Valuer`, so these fields can +be used directly as struct fields with `database/sql`, `bun`, or `gorm` +without additional tags or hooks. diff --git a/vendor/github.com/bitechdev/ResolveSpec/pkg/spectypes/sql_array_types.go b/vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/sql_array_types.go similarity index 68% rename from vendor/github.com/bitechdev/ResolveSpec/pkg/spectypes/sql_array_types.go rename to vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/sql_array_types.go index 921387b..2b0816f 100644 --- a/vendor/github.com/bitechdev/ResolveSpec/pkg/spectypes/sql_array_types.go +++ b/vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/sql_array_types.go @@ -1,15 +1,85 @@ -package spectypes +package sqltypes import ( "database/sql/driver" "encoding/json" + "encoding/xml" "fmt" "strconv" "strings" "github.com/google/uuid" + "gopkg.in/yaml.v3" ) +// marshalYAMLSlice returns the value used by yaml.Marshaler implementations +// for the nullable array types below: nil when invalid, the slice otherwise. +func marshalYAMLSlice[T any](valid bool, vals []T) (any, error) { + if !valid { + return nil, nil + } + return vals, nil +} + +// unmarshalYAMLSlice returns the value used by yaml.Unmarshaler +// implementations for the nullable array types below. +func unmarshalYAMLSlice[T any](value *yaml.Node) (vals []T, valid bool, err error) { + if value == nil || value.Tag == "!!null" { + return nil, false, nil + } + if err := value.Decode(&vals); err != nil { + return nil, false, err + } + return vals, true, nil +} + +// xmlArrayItemName is the element name used for each item when a nullable +// array type is encoded as XML, since XML has no native list type. +var xmlArrayItemName = xml.Name{Local: "item"} + +// marshalXMLSlice writes a nullable array type as XML: an empty element when +// invalid, otherwise the start tag followed by one child per element. +func marshalXMLSlice[T any](e *xml.Encoder, start xml.StartElement, valid bool, vals []T) error { + if !valid { + return e.EncodeElement("", start) + } + if err := e.EncodeToken(start); err != nil { + return err + } + for _, v := range vals { + if err := e.EncodeElement(v, xml.StartElement{Name: xmlArrayItemName}); err != nil { + return err + } + } + return e.EncodeToken(start.End()) +} + +// unmarshalXMLSlice reads back the XML written by marshalXMLSlice. +// +// XML has no native null representation: an element with no children +// unmarshals to a valid, empty slice rather than an invalid one. +func unmarshalXMLSlice[T any](d *xml.Decoder, start xml.StartElement) ([]T, error) { + var vals []T + for { + tok, err := d.Token() + if err != nil { + return nil, err + } + switch t := tok.(type) { + case xml.StartElement: + var v T + if err := d.DecodeElement(&v, &t); err != nil { + return nil, err + } + vals = append(vals, v) + case xml.EndElement: + if t.Name == start.Name { + return vals, nil + } + } + } +} + // parsePostgresArrayElements parses a PostgreSQL array literal (e.g. `{a,"b,c",d}`) // into a slice of raw string elements. Each element retains its unquoted/unescaped value. func parsePostgresArrayElements(s string) ([]string, error) { @@ -140,6 +210,32 @@ func (a *SqlStringArray) UnmarshalJSON(b []byte) error { return nil } +func (a SqlStringArray) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlStringArray) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[string](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlStringArray) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlStringArray) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[string](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlStringArray(v []string) SqlStringArray { return SqlStringArray{Val: v, Valid: true} } @@ -215,6 +311,32 @@ func (a *SqlInt16Array) UnmarshalJSON(b []byte) error { return nil } +func (a SqlInt16Array) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlInt16Array) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[int16](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlInt16Array) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlInt16Array) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[int16](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlInt16Array(v []int16) SqlInt16Array { return SqlInt16Array{Val: v, Valid: true} } @@ -290,6 +412,32 @@ func (a *SqlInt32Array) UnmarshalJSON(b []byte) error { return nil } +func (a SqlInt32Array) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlInt32Array) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[int32](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlInt32Array) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlInt32Array) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[int32](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlInt32Array(v []int32) SqlInt32Array { return SqlInt32Array{Val: v, Valid: true} } @@ -365,6 +513,32 @@ func (a *SqlInt64Array) UnmarshalJSON(b []byte) error { return nil } +func (a SqlInt64Array) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlInt64Array) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[int64](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlInt64Array) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlInt64Array) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[int64](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlInt64Array(v []int64) SqlInt64Array { return SqlInt64Array{Val: v, Valid: true} } @@ -440,6 +614,32 @@ func (a *SqlFloat32Array) UnmarshalJSON(b []byte) error { return nil } +func (a SqlFloat32Array) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlFloat32Array) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[float32](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlFloat32Array) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlFloat32Array) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[float32](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlFloat32Array(v []float32) SqlFloat32Array { return SqlFloat32Array{Val: v, Valid: true} } @@ -515,6 +715,32 @@ func (a *SqlFloat64Array) UnmarshalJSON(b []byte) error { return nil } +func (a SqlFloat64Array) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlFloat64Array) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[float64](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlFloat64Array) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlFloat64Array) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[float64](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlFloat64Array(v []float64) SqlFloat64Array { return SqlFloat64Array{Val: v, Valid: true} } @@ -591,6 +817,32 @@ func (a *SqlBoolArray) UnmarshalJSON(b []byte) error { return nil } +func (a SqlBoolArray) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlBoolArray) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[bool](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlBoolArray) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlBoolArray) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[bool](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlBoolArray(v []bool) SqlBoolArray { return SqlBoolArray{Val: v, Valid: true} } @@ -666,6 +918,32 @@ func (a *SqlUUIDArray) UnmarshalJSON(b []byte) error { return nil } +func (a SqlUUIDArray) MarshalYAML() (any, error) { + return marshalYAMLSlice(a.Valid, a.Val) +} + +func (a *SqlUUIDArray) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[uuid.UUID](value) + if err != nil { + return err + } + a.Val, a.Valid = vals, valid + return nil +} + +func (a SqlUUIDArray) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, a.Valid, a.Val) +} + +func (a *SqlUUIDArray) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[uuid.UUID](d, start) + if err != nil { + return err + } + a.Val, a.Valid = vals, true + return nil +} + func NewSqlUUIDArray(v []uuid.UUID) SqlUUIDArray { return SqlUUIDArray{Val: v, Valid: true} } @@ -750,6 +1028,32 @@ func (v *SqlVector) UnmarshalJSON(b []byte) error { return nil } +func (v SqlVector) MarshalYAML() (any, error) { + return marshalYAMLSlice(v.Valid, v.Val) +} + +func (v *SqlVector) UnmarshalYAML(value *yaml.Node) error { + vals, valid, err := unmarshalYAMLSlice[float32](value) + if err != nil { + return err + } + v.Val, v.Valid = vals, valid + return nil +} + +func (v SqlVector) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + return marshalXMLSlice(e, start, v.Valid, v.Val) +} + +func (v *SqlVector) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + vals, err := unmarshalXMLSlice[float32](d, start) + if err != nil { + return err + } + v.Val, v.Valid = vals, true + return nil +} + func NewSqlVector(val []float32) SqlVector { return SqlVector{Val: val, Valid: true} } diff --git a/vendor/github.com/bitechdev/ResolveSpec/pkg/spectypes/sql_types.go b/vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/sql_types.go similarity index 63% rename from vendor/github.com/bitechdev/ResolveSpec/pkg/spectypes/sql_types.go rename to vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/sql_types.go index f9a81d6..0b3146c 100644 --- a/vendor/github.com/bitechdev/ResolveSpec/pkg/spectypes/sql_types.go +++ b/vendor/git.warky.dev/wdevs/relspecgo/pkg/sqltypes/sql_types.go @@ -1,11 +1,12 @@ -// Package spectypes provides nullable SQL types with automatic casting and conversion methods. -package spectypes +// Package sqltypes provides nullable SQL types with automatic casting and conversion methods. +package sqltypes import ( "database/sql" "database/sql/driver" "encoding/base64" "encoding/json" + "encoding/xml" "fmt" "reflect" "strconv" @@ -13,6 +14,7 @@ import ( "time" "github.com/google/uuid" + "gopkg.in/yaml.v3" ) // tryParseDT attempts to parse a string into a time.Time using various formats. @@ -120,15 +122,22 @@ func (n *SqlNull[T]) FromString(s string) error { var zero T switch any(zero).(type) { - case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64: + case int, int8, int16, int32, int64: if i, err := strconv.ParseInt(s, 10, 64); err == nil { reflect.ValueOf(&n.Val).Elem().SetInt(i) n.Valid = true - } - if f, err := strconv.ParseFloat(s, 64); err == nil { + } else if f, err := strconv.ParseFloat(s, 64); err == nil { reflect.ValueOf(&n.Val).Elem().SetInt(int64(f)) n.Valid = true } + case uint, uint8, uint16, uint32, uint64: + if u, err := strconv.ParseUint(s, 10, 64); err == nil { + reflect.ValueOf(&n.Val).Elem().SetUint(u) + n.Valid = true + } else if f, err := strconv.ParseFloat(s, 64); err == nil && f >= 0 { + reflect.ValueOf(&n.Val).Elem().SetUint(uint64(f)) + n.Valid = true + } case float32, float64: if f, err := strconv.ParseFloat(s, 64); err == nil { reflect.ValueOf(&n.Val).Elem().SetFloat(f) @@ -232,6 +241,104 @@ func (n *SqlNull[T]) UnmarshalJSON(b []byte) error { return fmt.Errorf("cannot unmarshal %s into SqlNull[%T]", b, n.Val) } +// MarshalYAML implements yaml.Marshaler. +func (n SqlNull[T]) MarshalYAML() (any, error) { + if !n.Valid { + return nil, nil + } + + // Check if T is []byte, and encode to base64 (mirrors MarshalJSON). + if b, ok := any(n.Val).([]byte); ok { + return base64.StdEncoding.EncodeToString(b), nil + } + + return n.Val, nil +} + +// UnmarshalYAML implements yaml.Unmarshaler. +func (n *SqlNull[T]) UnmarshalYAML(value *yaml.Node) error { + if value == nil || value.Tag == "!!null" { + n.Valid = false + n.Val = *new(T) + return nil + } + + // Check if T is []byte, and decode from base64. + var zero T + if _, ok := any(zero).([]byte); ok { + var s string + if err := value.Decode(&s); err == nil { + if decoded, err := base64.StdEncoding.DecodeString(s); err == nil { + n.Val = any(decoded).(T) + n.Valid = true + return nil + } + n.Val = any([]byte(s)).(T) + n.Valid = true + return nil + } + } + + var val T + if err := value.Decode(&val); err == nil { + n.Val = val + n.Valid = true + return nil + } + + // Fallback: decode as string and parse. + var s string + if err := value.Decode(&s); err == nil { + return n.FromString(s) + } + + return fmt.Errorf("cannot unmarshal %q into SqlNull[%T]", value.Value, n.Val) +} + +// MarshalXML implements xml.Marshaler. +func (n SqlNull[T]) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if !n.Valid { + return e.EncodeElement("", start) + } + + // Check if T is []byte, and encode to base64 (mirrors MarshalJSON). + if b, ok := any(n.Val).([]byte); ok { + return e.EncodeElement(base64.StdEncoding.EncodeToString(b), start) + } + + return e.EncodeElement(n.Val, start) +} + +// UnmarshalXML implements xml.Unmarshaler. +// +// XML has no native null representation, so an empty element unmarshals to +// an invalid (null) value rather than a zero-value-but-valid one. +func (n *SqlNull[T]) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var s string + if err := d.DecodeElement(&s, &start); err != nil { + return err + } + if s == "" { + n.Valid = false + n.Val = *new(T) + return nil + } + + var zero T + if _, ok := any(zero).([]byte); ok { + if decoded, err := base64.StdEncoding.DecodeString(s); err == nil { + n.Val = any(decoded).(T) + n.Valid = true + return nil + } + n.Val = any([]byte(s)).(T) + n.Valid = true + return nil + } + + return n.FromString(s) +} + // String implements fmt.Stringer. func (n SqlNull[T]) String() string { if !n.Valid { @@ -329,6 +436,7 @@ type ( SqlInt16 = SqlNull[int16] SqlInt32 = SqlNull[int32] SqlInt64 = SqlNull[int64] + SqlFloat32 = SqlNull[float32] SqlFloat64 = SqlNull[float64] SqlBool = SqlNull[bool] SqlString = SqlNull[string] @@ -343,7 +451,7 @@ func (t SqlTimeStamp) MarshalJSON() ([]byte, error) { if !t.Valid || t.Val.IsZero() || t.Val.Before(time.Date(0002, 1, 1, 0, 0, 0, 0, time.UTC)) { return []byte("null"), nil } - return []byte(fmt.Sprintf(`"%s"`, t.Val.Format("2006-01-02T15:04:05"))), nil + return fmt.Appendf(nil, `"%s"`, t.Val.Format("2006-01-02T15:04:05")), nil } func (t *SqlTimeStamp) UnmarshalJSON(b []byte) error { @@ -363,6 +471,49 @@ func (t SqlTimeStamp) Value() (driver.Value, error) { return t.Val.Format("2006-01-02T15:04:05"), nil } +func (t SqlTimeStamp) MarshalYAML() (any, error) { + if !t.Valid || t.Val.IsZero() || t.Val.Before(time.Date(0002, 1, 1, 0, 0, 0, 0, time.UTC)) { + return nil, nil + } + return t.Val.Format("2006-01-02T15:04:05"), nil +} + +func (t *SqlTimeStamp) UnmarshalYAML(value *yaml.Node) error { + if err := t.SqlNull.UnmarshalYAML(value); err != nil { + return err + } + if t.Valid && (t.Val.IsZero() || t.Val.Format("2006-01-02T15:04:05") == "0001-01-01T00:00:00") { + t.Valid = false + } + return nil +} + +func (t SqlTimeStamp) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if !t.Valid || t.Val.IsZero() || t.Val.Before(time.Date(0002, 1, 1, 0, 0, 0, 0, time.UTC)) { + return e.EncodeElement("", start) + } + return e.EncodeElement(t.Val.Format("2006-01-02T15:04:05"), start) +} + +func (t *SqlTimeStamp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var s string + if err := d.DecodeElement(&s, &start); err != nil { + return err + } + if s == "" { + t.Valid = false + t.Val = time.Time{} + return nil + } + tm, err := tryParseDT(s) + if err != nil { + return err + } + t.Val = tm + t.Valid = !tm.IsZero() && tm.Format("2006-01-02T15:04:05") != "0001-01-01T00:00:00" + return nil +} + func SqlTimeStampNow() SqlTimeStamp { return SqlTimeStamp{SqlNull: SqlNull[time.Time]{Val: time.Now(), Valid: true}} } @@ -378,7 +529,7 @@ func (d SqlDate) MarshalJSON() ([]byte, error) { if strings.HasPrefix(s, "0001-01-01") { return []byte("null"), nil } - return []byte(fmt.Sprintf(`"%s"`, s)), nil + return fmt.Appendf(nil, `"%s"`, s), nil } func (d *SqlDate) UnmarshalJSON(b []byte) error { @@ -413,6 +564,57 @@ func (d SqlDate) String() string { return s } +func (d SqlDate) MarshalYAML() (any, error) { + if !d.Valid || d.Val.IsZero() { + return nil, nil + } + s := d.Val.Format("2006-01-02") + if strings.HasPrefix(s, "0001-01-01") { + return nil, nil + } + return s, nil +} + +func (d *SqlDate) UnmarshalYAML(value *yaml.Node) error { + if err := d.SqlNull.UnmarshalYAML(value); err != nil { + return err + } + if d.Valid && d.Val.Format("2006-01-02") <= "0001-01-01" { + d.Valid = false + } + return nil +} + +func (d SqlDate) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if !d.Valid || d.Val.IsZero() { + return e.EncodeElement("", start) + } + s := d.Val.Format("2006-01-02") + if strings.HasPrefix(s, "0001-01-01") { + return e.EncodeElement("", start) + } + return e.EncodeElement(s, start) +} + +func (d *SqlDate) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { + var s string + if err := dec.DecodeElement(&s, &start); err != nil { + return err + } + if s == "" { + d.Valid = false + d.Val = time.Time{} + return nil + } + tm, err := tryParseDT(s) + if err != nil { + return err + } + d.Val = tm + d.Valid = !tm.IsZero() && tm.Format("2006-01-02") > "0001-01-01" + return nil +} + func SqlDateNow() SqlDate { return SqlDate{SqlNull: SqlNull[time.Time]{Val: time.Now(), Valid: true}} } @@ -428,7 +630,7 @@ func (t SqlTime) MarshalJSON() ([]byte, error) { if s == "00:00:00" { return []byte("null"), nil } - return []byte(fmt.Sprintf(`"%s"`, s)), nil + return fmt.Appendf(nil, `"%s"`, s), nil } func (t *SqlTime) UnmarshalJSON(b []byte) error { @@ -455,6 +657,57 @@ func (t SqlTime) String() string { return t.Val.Format("15:04:05") } +func (t SqlTime) MarshalYAML() (any, error) { + if !t.Valid || t.Val.IsZero() { + return nil, nil + } + s := t.Val.Format("15:04:05") + if s == "00:00:00" { + return nil, nil + } + return s, nil +} + +func (t *SqlTime) UnmarshalYAML(value *yaml.Node) error { + if err := t.SqlNull.UnmarshalYAML(value); err != nil { + return err + } + if t.Valid && t.Val.Format("15:04:05") == "00:00:00" { + t.Valid = false + } + return nil +} + +func (t SqlTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if !t.Valid || t.Val.IsZero() { + return e.EncodeElement("", start) + } + s := t.Val.Format("15:04:05") + if s == "00:00:00" { + return e.EncodeElement("", start) + } + return e.EncodeElement(s, start) +} + +func (t *SqlTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var s string + if err := d.DecodeElement(&s, &start); err != nil { + return err + } + if s == "" { + t.Valid = false + t.Val = time.Time{} + return nil + } + tm, err := tryParseDT(s) + if err != nil { + return err + } + t.Val = tm + t.Valid = !tm.IsZero() && tm.Format("15:04:05") != "00:00:00" + return nil +} + func SqlTimeNow() SqlTime { return SqlTime{SqlNull: SqlNull[time.Time]{Val: time.Now(), Valid: true}} } @@ -462,6 +715,11 @@ func SqlTimeNow() SqlTime { // SqlJSONB - Nullable JSONB as []byte. type SqlJSONB []byte +// SqlJSON - Nullable JSON as []byte. PostgreSQL's json and jsonb types share +// the same textual representation and Go marshalling behavior, differing only +// in server-side storage, so SqlJSON is an alias of SqlJSONB. +type SqlJSON = SqlJSONB + // Scan implements sql.Scanner. func (n *SqlJSONB) Scan(value any) error { if value == nil { @@ -518,6 +776,67 @@ func (n *SqlJSONB) UnmarshalJSON(b []byte) error { return nil } +// MarshalYAML implements yaml.Marshaler. The underlying JSON is decoded into +// a generic value first so it renders as native YAML mappings/sequences +// rather than an embedded JSON string. +func (n SqlJSONB) MarshalYAML() (any, error) { + if len(n) == 0 { + return nil, nil + } + var v any + if err := json.Unmarshal(n, &v); err != nil { + return nil, nil + } + return v, nil +} + +// UnmarshalYAML implements yaml.Unmarshaler. +func (n *SqlJSONB) UnmarshalYAML(value *yaml.Node) error { + if value == nil || value.Tag == "!!null" { + *n = nil + return nil + } + var v any + if err := value.Decode(&v); err != nil { + return err + } + b, err := json.Marshal(v) + if err != nil { + return err + } + *n = b + return nil +} + +// MarshalXML implements xml.Marshaler. JSON has no clean structural mapping +// to XML, so the raw JSON text is emitted as the element's text content. +func (n SqlJSONB) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + if len(n) == 0 { + return e.EncodeElement("", start) + } + var obj any + if err := json.Unmarshal(n, &obj); err != nil { + return e.EncodeElement("", start) + } + return e.EncodeElement(string(n), start) +} + +// UnmarshalXML implements xml.Unmarshaler, reading back the raw JSON text +// written by MarshalXML. +func (n *SqlJSONB) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var s string + if err := d.DecodeElement(&s, &start); err != nil { + return err + } + s = strings.TrimSpace(s) + if s == "" { + *n = nil + return nil + } + *n = []byte(s) + return nil +} + func (n SqlJSONB) AsMap() (map[string]any, error) { if len(n) == 0 { return nil, nil @@ -625,6 +944,10 @@ func NewSqlInt64(v int64) SqlInt64 { return SqlInt64{Val: v, Valid: true} } +func NewSqlFloat32(v float32) SqlFloat32 { + return SqlFloat32{Val: v, Valid: true} +} + func NewSqlFloat64(v float64) SqlFloat64 { return SqlFloat64{Val: v, Valid: true} } diff --git a/vendor/modules.txt b/vendor/modules.txt index 3a131d8..5707aaf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,3 +1,6 @@ +# git.warky.dev/wdevs/relspecgo v1.0.62 +## explicit; go 1.25.7 +git.warky.dev/wdevs/relspecgo/pkg/sqltypes # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile @@ -15,7 +18,6 @@ github.com/bitechdev/ResolveSpec/pkg/modelregistry github.com/bitechdev/ResolveSpec/pkg/reflection github.com/bitechdev/ResolveSpec/pkg/resolvespec github.com/bitechdev/ResolveSpec/pkg/security -github.com/bitechdev/ResolveSpec/pkg/spectypes # github.com/bradfitz/gomemcache v0.0.0-20260422231931-4d751bb6e37c ## explicit; go 1.18 github.com/bradfitz/gomemcache/memcache @@ -184,8 +186,6 @@ github.com/redis/go-redis/v9/internal/routing github.com/redis/go-redis/v9/internal/util github.com/redis/go-redis/v9/maintnotifications github.com/redis/go-redis/v9/push -# github.com/rogpeppe/go-internal v1.14.1 -## explicit; go 1.23 # github.com/sagikazarmark/locafero v0.12.0 ## explicit; go 1.23.0 github.com/sagikazarmark/locafero