module

package
v0.1.65 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name          StringOfVaryingCases   `yaml:"name"`
	Description   string                 `yaml:"description"`
	EventsEmitted []StringOfVaryingCases `yaml:"events_emitted"`
	Params        []Field                `yaml:"params"`
}

Command represents a command in the module, which has a name, description, fields, and a list of events that it emits when handled.

type Entity

type Entity struct {
	Name        StringOfVaryingCases `yaml:"name"`
	Description string               `yaml:"description"`
	Fields      []Field              `yaml:"fields"`
}

Entity represents an entity in the module, which has a name, description, fields, and a boolean indicating whether it is the aggregate root entity for the module.

type Event

type Event struct {
	Name        StringOfVaryingCases `yaml:"name"`
	Description string               `yaml:"description"`
	Kind        string               `yaml:"kind"` // emitted or consumed
	Fields      []Field              `yaml:"fields"`
}

Event represents an event in the module, which has a name, description, fields, and a kind (either "emitted" or "consumed") to indicate whether the event is emitted by the module or consumed by the module.

type Field

type Field struct {
	Name     StringOfVaryingCases `yaml:"name"`
	Type     string               `yaml:"type"`
	Optional bool                 `yaml:"optional"`
}

Field represents a field in an entity, command, or event, which has a name, type, and a boolean indicating whether the field is optional. It also includes helper methods to get the Go type, PostgreSQL type, and OpenAPI type for the field based on its type and whether it is optional.

func (Field) GoType

func (f Field) GoType() string

GoType returns the Go type for the field based on its type and whether it is optional. It supports basic types like string, int32, int64, float32, float64, bool, and time, and returns a pointer to the type if the field is optional. For any other types, it returns the type as-is.

func (Field) OpenApiType

func (f Field) OpenApiType() string

OpenApiType returns the OpenAPI type for the field based on its type and whether it is optional.

func (Field) PgSqlType

func (f Field) PgSqlType() string

PgSqlType returns the PostgreSQL type for the field based on its type and whether it is optional.

type Module

type Module struct {
	Name           StringOfVaryingCases `yaml:"name"`
	Metadata       map[string]any       `yaml:"metadata"`
	Description    string               `yaml:"description"`
	DefaultQueries bool                 `yaml:"defaultQueries"`
	Aggregates     []Entity             `yaml:"aggregates"`
	Commands       []Command            `yaml:"commands"`
	Events         []Event              `yaml:"events"`
	Queries        []Query              `yaml:"queries"`
}

Module encompasses all the information about a module, including its name, description, entities, commands, events, and queries. It also includes helper methods to get the aggregate root entity, non-aggregate entities, emitted events, and consumed events for the module.

func (Module) ConsumedEvents

func (m Module) ConsumedEvents() []Event

ConsumedEvents returns a slice of all the events in the module that are marked as consumed (i.e. Kind is "consumed").

func (Module) EmittedEvents

func (m Module) EmittedEvents() []Event

EmittedEvents returns a slice of all the events in the module that are marked as emitted (i.e. Kind is "emitted").

func (Module) Validate added in v0.1.65

func (m Module) Validate() error

type ModuleConfig

type ModuleConfig struct {
	Modules []Module `yaml:"modules"`
}

type Query

type Query struct {
	Name   StringOfVaryingCases `yaml:"name"`
	Params []Field              `yaml:"params"`
}

Query represents a query in the module, which has a name

type StringOfVaryingCases

type StringOfVaryingCases string

must be in snake_case during initialization

func (StringOfVaryingCases) Camel

func (s StringOfVaryingCases) Camel() string

Camel returns the string in camelCase (e.g. "userAccount")

func (StringOfVaryingCases) FirstLetterLower

func (s StringOfVaryingCases) FirstLetterLower() string

FirstLetterLower returns the first letter of the string in lowercase (e.g. "u")

func (StringOfVaryingCases) Flat

func (s StringOfVaryingCases) Flat() string

Flat returns the string in flat case (e.g. "useraccount")

func (StringOfVaryingCases) Kebab

func (s StringOfVaryingCases) Kebab() string

Kebab returns the string in kebab-case (e.g. "user-account")

func (StringOfVaryingCases) Pascal

func (s StringOfVaryingCases) Pascal() string

Pascal returns the string in PascalCase (e.g. "UserAccount")

func (StringOfVaryingCases) Snake

func (s StringOfVaryingCases) Snake() string

Snake returns the string in snake_case (e.g. "user_account") - this is just the original string, but we include this method for consistency and to make it clear that the original string should be in snake_case

func (StringOfVaryingCases) Title added in v0.1.65

func (s StringOfVaryingCases) Title() string

returns the string in title case (e.g. "Useraccount")

Jump to

Keyboard shortcuts

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