Documentation
¶
Index ¶
- type Command
- type Entity
- type Event
- type Field
- func (f Field) FieldsAlphabetized() []Field
- func (f Field) FieldsToGoStructFields() string
- func (f Field) GoType() string
- func (f Field) MapFnFromDomainToPg() *string
- func (f Field) MapFnFromPgToDomain() *string
- func (f Field) OpenApiType() string
- func (f Field) PgSqlType() string
- func (f Field) RequiredFields() []Field
- type GoStruct
- type Module
- type ModuleConfig
- type OpenApiComponent
- type Query
- type StringOfVaryingCases
- func (s StringOfVaryingCases) Camel() string
- func (s StringOfVaryingCases) FirstLetterLower() string
- func (s StringOfVaryingCases) Flat() string
- func (s StringOfVaryingCases) Kebab() string
- func (s StringOfVaryingCases) Pascal() string
- func (s StringOfVaryingCases) PascalCapitalizeID() string
- func (s StringOfVaryingCases) PluralCamel() string
- func (s StringOfVaryingCases) PluralFlat() string
- func (s StringOfVaryingCases) PluralKebab() string
- func (s StringOfVaryingCases) PluralPascal() string
- func (s StringOfVaryingCases) PluralSnake() string
- func (s StringOfVaryingCases) PluralTitleWithSpaces() string
- func (s StringOfVaryingCases) Snake() string
- func (s StringOfVaryingCases) Title() string
- func (s StringOfVaryingCases) TitleWithSpaces() string
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"`
Icon string `yaml:"icon"`
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.
func (Entity) NestedObjects ¶ added in v0.1.69
func (Entity) RequiredFields ¶ added in v0.1.69
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"`
Description string `yaml:"description"`
List bool `yaml:"list"`
Optional bool `yaml:"optional"`
Fields []Field `yaml:"fields,omitempty"` // for nested fields (e.g. in a struct or a list of structs)
}
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) FieldsAlphabetized ¶ added in v0.1.73
func (Field) FieldsToGoStructFields ¶ added in v0.1.68
func (Field) GoType ¶
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) MapFnFromDomainToPg ¶ added in v0.1.69
func (Field) MapFnFromPgToDomain ¶ added in v0.1.69
func (Field) OpenApiType ¶
OpenApiType returns the OpenAPI type for the field based on its type and whether it is optional.
func (Field) PgSqlType ¶
PgSqlType returns the PostgreSQL type for the field based on its type and whether it is optional.
func (Field) RequiredFields ¶ added in v0.1.69
type GoStruct ¶ added in v0.1.73
type GoStruct struct {
Name StringOfVaryingCases
Fields []Field
}
type Module ¶
type Module struct {
Name StringOfVaryingCases `yaml:"name"`
Metadata map[string]any `yaml:"metadata"`
Icon string `yaml:"icon"`
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) CommandTypes ¶ added in v0.1.73
func (Module) ConsumedEvents ¶
ConsumedEvents returns a slice of all the events in the module that are marked as consumed (i.e. Kind is "consumed").
func (Module) EmittedEvents ¶
EmittedEvents returns a slice of all the events in the module that are marked as emitted (i.e. Kind is "emitted").
func (Module) NestedObjects ¶ added in v0.1.68
func (Module) OpenApiComponents ¶ added in v0.1.73
func (m Module) OpenApiComponents() []OpenApiComponent
OpenApiComponents returns all relevant openapi components for the module commands, nestedobjects, and aggregates
type ModuleConfig ¶
type ModuleConfig struct {
Modules []Module `yaml:"modules"`
}
type OpenApiComponent ¶ added in v0.1.73
type OpenApiComponent struct {
Name StringOfVaryingCases `yaml:"name"`
Description string `yaml:"description"`
Fields []Field `yaml:"fields"`
}
func (OpenApiComponent) RequiredFields ¶ added in v0.1.73
func (oc OpenApiComponent) RequiredFields() []Field
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) PascalCapitalizeID ¶ added in v0.1.69
func (s StringOfVaryingCases) PascalCapitalizeID() string
PascalCapitalizeID returns the string in PascalCase with "ID" capitalized (e.g. "UserID")
func (StringOfVaryingCases) PluralCamel ¶ added in v0.1.68
func (s StringOfVaryingCases) PluralCamel() string
PluralCamel returns the plural form of the string in camelCase (e.g. "userAccounts")
func (StringOfVaryingCases) PluralFlat ¶ added in v0.1.68
func (s StringOfVaryingCases) PluralFlat() string
PluralFlat returns the plural form of the string in flat case (e.g. "useraccounts")
func (StringOfVaryingCases) PluralKebab ¶ added in v0.1.68
func (s StringOfVaryingCases) PluralKebab() string
PluralKebab returns the plural form of the string in kebab-case (e.g. "user-accounts")
func (StringOfVaryingCases) PluralPascal ¶ added in v0.1.68
func (s StringOfVaryingCases) PluralPascal() string
PluralPascal returns the plural form of the string in PascalCase (e.g. "UserAccounts")
func (StringOfVaryingCases) PluralSnake ¶ added in v0.1.68
func (s StringOfVaryingCases) PluralSnake() string
PluralSnake returns the plural form of the string in snake_case (e.g. "user_accounts")
func (StringOfVaryingCases) PluralTitleWithSpaces ¶ added in v0.1.69
func (s StringOfVaryingCases) PluralTitleWithSpaces() string
returns the plural form of string in title case with spaces (e.g. "User Accounts")
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")
func (StringOfVaryingCases) TitleWithSpaces ¶ added in v0.1.69
func (s StringOfVaryingCases) TitleWithSpaces() string
returns the string in title case with spaces (e.g. "User Account")