feat(models): add new models for public API, event log, hook, session, user, and whatsapp account
Some checks failed
CI / Test (1.23) (push) Failing after -22m31s
CI / Test (1.22) (push) Failing after -22m34s
CI / Build (push) Failing after -22m43s
CI / Lint (push) Failing after -22m27s

* Introduced ModelPublicAPIKey, ModelPublicEventLog, ModelPublicHook, ModelPublicSession, ModelPublicUser, and ModelPublicWhatsappAccount
* Removed deprecated ModelPublicUsers
* Updated database schema definitions to reflect new model structure
* Adjusted seed data to use correct types for timestamps
This commit is contained in:
Hein
2026-02-20 16:19:49 +02:00
parent 524bc4179b
commit 3b6d0f81d2
10 changed files with 157 additions and 167 deletions

View File

@@ -0,0 +1,69 @@
// Code generated by relspecgo. DO NOT EDIT.
package models
import (
"fmt"
resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
"github.com/uptrace/bun"
)
type ModelPublicAPIKey struct {
bun.BaseModel `bun:"table:public.api_key,alias:api_key"`
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"`
ExpiresAt resolvespec_common.SqlTimeStamp `bun:"expires_at,type:timestamp,nullzero," json:"expires_at"`
Key resolvespec_common.SqlString `bun:"key,type:varchar(255),notnull," json:"key"` // Hashed API key
KeyPrefix resolvespec_common.SqlString `bun:"key_prefix,type:varchar(20),nullzero," json:"key_prefix"` // First few characters for display
LastUsedAt resolvespec_common.SqlTimeStamp `bun:"last_used_at,type:timestamp,nullzero," json:"last_used_at"`
Name resolvespec_common.SqlString `bun:"name,type:varchar(255),notnull," json:"name"` // Friendly name for the API key
Permissions resolvespec_common.SqlString `bun:"permissions,type:text,nullzero," json:"permissions"` // JSON array of permissions
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
}
// TableName returns the table name for ModelPublicAPIKey
func (m ModelPublicAPIKey) TableName() string {
return "public.api_key"
}
// TableNameOnly returns the table name without schema for ModelPublicAPIKey
func (m ModelPublicAPIKey) TableNameOnly() string {
return "api_key"
}
// SchemaName returns the schema name for ModelPublicAPIKey
func (m ModelPublicAPIKey) SchemaName() string {
return "public"
}
// GetID returns the primary key value
func (m ModelPublicAPIKey) GetID() int64 {
return m.ID.Int64()
}
// GetIDStr returns the primary key as a string
func (m ModelPublicAPIKey) GetIDStr() string {
return fmt.Sprintf("%d", m.ID)
}
// SetID sets the primary key value
func (m ModelPublicAPIKey) SetID(newid int64) {
m.UpdateID(newid)
}
// UpdateID updates the primary key value
func (m *ModelPublicAPIKey) UpdateID(newid int64) {
m.ID.FromString(fmt.Sprintf("%d", newid))
}
// GetIDName returns the name of the primary key column
func (m ModelPublicAPIKey) GetIDName() string {
return "id"
}
// GetPrefix returns the table prefix
func (m ModelPublicAPIKey) GetPrefix() string {
return "AKP"
}