store

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module implements the mdk.Module interface for StoreSettings management.

func NewModule

func NewModule() *Module

NewModule creates a new instance of the Store module.

func (*Module) FieldResolvers

func (m *Module) FieldResolvers() map[string]any

FieldResolvers exposes custom field-level resolvers.

func (*Module) GetSettingsStep

func (m *Module) GetSettingsStep(sCtx mdk.StepContext) mdk.StepResult

func (*Module) GetStoreSettings

func (m *Module) GetStoreSettings(ctx context.Context) (*StoreSettings, error)

GetStoreSettings returns the global store settings record.

func (*Module) ID

func (m *Module) ID() string

ID returns the unique identifier for the module.

func (*Module) Init

func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error

Init initializes the store module and seeds default configurations if necessary.

func (*Module) ListResources

func (m *Module) ListResources(ctx context.Context) ([]mdk.MCPResource, error)

func (*Module) Models

func (m *Module) Models() []any

Models registers GORM database structures for GORM auto-migration.

func (*Module) Mutations

func (m *Module) Mutations() map[string]any

Mutations exposes resolver mutation maps.

func (*Module) Queries

func (m *Module) Queries() map[string]any

Queries exposes resolver query maps.

func (*Module) ReadResource

func (m *Module) ReadResource(ctx context.Context, uri string) (string, error)

func (*Module) Repo

func (m *Module) Repo() *Repository

Repo returns the direct repository data-access client.

func (*Module) Routes

func (m *Module) Routes() []mdk.Route

Routes returns HTTP endpoints mapped to this module (none).

func (*Module) Shutdown

func (m *Module) Shutdown(ctx context.Context) error

Shutdown cleans up resources on application stop.

func (*Module) UpdateSettingsStep

func (m *Module) UpdateSettingsStep(sCtx mdk.StepContext) mdk.StepResult

func (*Module) UpdateStoreSettings

func (m *Module) UpdateStoreSettings(ctx context.Context, input UpdateStoreSettingsInput) (*StoreSettings, error)

UpdateStoreSettings updates non-nil input configurations for the store settings.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository handles database interactions for the singleton StoreSettings.

func NewRepository

func NewRepository(db *gorm.DB) *Repository

NewRepository creates a new database repository instance.

func (*Repository) Get

func (r *Repository) Get(ctx context.Context) (*StoreSettings, error)

Get retrieves the singleton StoreSettings (ID = 1).

func (*Repository) Save

func (r *Repository) Save(ctx context.Context, settings *StoreSettings) error

Save saves or updates the StoreSettings entity.

type SEOInput

type SEOInput struct {
	MetaTitle       *string `json:"metaTitle"`
	MetaDescription *string `json:"metaDescription"`
	MetaKeywords    *string `json:"metaKeywords"`
	MetaImage       *string `json:"metaImage"`
}

SEOInput matches the GraphQL input mapping.

type StoreSettings

type StoreSettings struct {
	ID          uint   `gorm:"primaryKey;default:1" json:"id"`
	Name        string `gorm:"not null;default:'My Hyperrr Store'" json:"name"`
	Host        string `gorm:"not null;default:'localhost:8080'" json:"host"`
	Email       string `gorm:"default:'admin@example.com'" json:"email"`
	Phone       string `json:"phone"`
	Description string `json:"description"`
	Currency    string `gorm:"not null;default:'USD'" json:"currency"`
	Locale      string `gorm:"not null;default:'en-US'" json:"locale"`
	Timezone    string `gorm:"not null;default:'UTC'" json:"timezone"`

	// Physical Store Address (used by fulfillment, tax, invoice modules)
	Address string `json:"address"`
	City    string `json:"city"`
	State   string `json:"state"`
	Zip     string `json:"zip"`
	Country string `json:"country"`

	// SEO & Metadata
	SEO        seo.SEO `gorm:"embedded;embeddedPrefix:seo_" json:"seo"`
	RobotsTXT  string  `gorm:"type:text" json:"robotsTxt"`
	SitemapURL string  `json:"sitemapUrl"`
	LogoURL    string  `json:"logoUrl"`
	FaviconURL string  `json:"faviconUrl"`

	// Social Links
	SocialFacebook  string `json:"socialFacebook"`
	SocialInstagram string `json:"socialInstagram"`
	SocialTwitter   string `json:"socialTwitter"`
	SocialLinkedin  string `json:"socialLinkedin"`
	SocialYoutube   string `json:"socialYoutube"`
	SocialPinterest string `json:"socialPinterest"`
	SocialTikTok    string `json:"socialTikTok"`

	// Dynamic Metadata (Dynamic Extensibility options)
	Metadata mdk.Metadata `gorm:"type:text" json:"metadata"`

	// Timestamps
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

StoreSettings represents the global configurations and settings of the e-commerce shop.

type UpdateStoreSettingsInput

type UpdateStoreSettingsInput struct {
	Name            *string      `json:"name"`
	Host            *string      `json:"host"`
	Email           *string      `json:"email"`
	Phone           *string      `json:"phone"`
	Description     *string      `json:"description"`
	Currency        *string      `json:"currency"`
	Locale          *string      `json:"locale"`
	Timezone        *string      `json:"timezone"`
	Address         *string      `json:"address"`
	City            *string      `json:"city"`
	State           *string      `json:"state"`
	Zip             *string      `json:"zip"`
	Country         *string      `json:"country"`
	SEO             *SEOInput    `json:"seo"`
	RobotsTxt       *string      `json:"robotsTxt"`
	SitemapUrl      *string      `json:"sitemapUrl"`
	LogoUrl         *string      `json:"logoUrl"`
	FaviconUrl      *string      `json:"faviconUrl"`
	SocialFacebook  *string      `json:"socialFacebook"`
	SocialInstagram *string      `json:"socialInstagram"`
	SocialTwitter   *string      `json:"socialTwitter"`
	SocialLinkedin  *string      `json:"socialLinkedin"`
	SocialYoutube   *string      `json:"socialYoutube"`
	SocialPinterest *string      `json:"socialPinterest"`
	SocialTikTok    *string      `json:"socialTikTok"`
	Metadata        mdk.Metadata `json:"metadata"`
}

UpdateStoreSettingsInput maps GraphQL inputs to updates on the model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL