actions

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFields

func BuildFields(buildFieldsFn func() FieldMap) func(*EntMutationBuilder)

func ExistingEnt

func ExistingEnt(existingEnt ent.Entity) func(*EntMutationBuilder)

func GetChangeset

func GetChangeset(action Action) (ent.Changeset, error)

func MultiChangesets

func MultiChangesets(changesetFn ...func() (ent.Changeset, error)) (ent.Changeset, error)

func Save

func Save(action Action) error

Types

type Action

type Action interface {
	GetViewer() viewer.ViewerContext

	// this exists and is just called by clients e.g. in triggers
	// and the generated code calls actions.GetChangeset() which calls GetBuilder
	GetChangeset() (ent.Changeset, error)
	// where new ent should be stored.
	// (TODO:ola) not really needed since builder has all this
	Entity() ent.Entity

	GetBuilder() ent.MutationBuilder
}

type ActionPermissionsError

type ActionPermissionsError struct{}

func (*ActionPermissionsError) Error

func (err *ActionPermissionsError) Error() string

type ActionWithObservers

type ActionWithObservers interface {
	Action
	GetObservers() []Observer
	SetBuilderOnObservers([]Observer)
}

type ActionWithPermissions

type ActionWithPermissions interface {
	Action
	GetPrivacyPolicy() ent.PrivacyPolicy
}

type ActionWithTriggers

type ActionWithTriggers interface {
	Action
	// TODO: dependencies between triggers needed. we'll do dependencies by creating something similar to MultiChangesets that takes 2 or more triggers that depend on each other
	GetTriggers() []Trigger
	SetBuilderOnTriggers([]Trigger)
}

type ActionWithValidator

type ActionWithValidator interface {
	Action
	Validate() error // TODO move this into Action. If we're going to have a Validate() method
}

type ActionWithValidators

type ActionWithValidators interface {
	Action
	GetValidators() []Validator
	SetBuilderOnValidators([]Validator)
}

type ChangesetWithObservers

type ChangesetWithObservers interface {
	ent.Changeset
	Observers() []Observer
}

type ChangesetWithValidators

type ChangesetWithValidators interface {
	ent.Changeset
	Validators() []Validator
}

type EdgeGroupMutationBuilder

type EdgeGroupMutationBuilder struct {
	*EntMutationBuilder
	// contains filtered or unexported fields
}

func NewEdgeGroupMutationBuilder

func NewEdgeGroupMutationBuilder(
	b *EntMutationBuilder,
	statusMap ent.AssocStatusMap,

) *EdgeGroupMutationBuilder

func (*EdgeGroupMutationBuilder) GetChangeset

func (b *EdgeGroupMutationBuilder) GetChangeset() (ent.Changeset, error)

func (*EdgeGroupMutationBuilder) SetEnumValue

func (b *EdgeGroupMutationBuilder) SetEnumValue(enumValue string)

func (*EdgeGroupMutationBuilder) SetIDValue

func (b *EdgeGroupMutationBuilder) SetIDValue(idValue string, nodeType ent.NodeType)

type EntMutationBuilder

type EntMutationBuilder struct {
	Viewer         viewer.ViewerContext
	ExistingEntity ent.Entity

	Operation ent.WriteOperation
	EntConfig ent.Config
	// contains filtered or unexported fields
}

fields in generated builder not in actions bug in in having it in actions now because if we set something in actions that's not there, there'll be an issue TODO rename to [Base|Abstract]MutationBuilder or something like that

func NewMutationBuilder

func NewMutationBuilder(
	v viewer.ViewerContext,
	operation ent.WriteOperation,
	entity ent.Entity,
	entConfig ent.Config,
	opts ...func(*EntMutationBuilder),
) *EntMutationBuilder

TODO have this just take a loader...

func (*EntMutationBuilder) AddInboundEdge

func (b *EntMutationBuilder) AddInboundEdge(
	edgeType ent.EdgeType, id1 interface{}, nodeType ent.NodeType, options ...func(*ent.EdgeOperation)) error

func (*EntMutationBuilder) AddOutboundEdge

func (b *EntMutationBuilder) AddOutboundEdge(edgeType ent.EdgeType, id2 interface{}, nodeType ent.NodeType, options ...func(*ent.EdgeOperation)) error

func (*EntMutationBuilder) Entity

func (b *EntMutationBuilder) Entity() ent.Entity

func (*EntMutationBuilder) ExistingEnt

func (b *EntMutationBuilder) ExistingEnt() ent.Entity

func (*EntMutationBuilder) GetChangeset

func (b *EntMutationBuilder) GetChangeset() (ent.Changeset, error)

Note that this shouldn't be called directly Need to pass things to it to work correctly all of these should be passed in constructor? TODO refactor this and construction so that calling action.Validate() works shouldn't need the workarounds we did for GetChangeset e.g ent.Save()

func (*EntMutationBuilder) GetOperation

func (b *EntMutationBuilder) GetOperation() ent.WriteOperation

func (*EntMutationBuilder) GetPlaceholderID

func (b *EntMutationBuilder) GetPlaceholderID() string

func (*EntMutationBuilder) GetRawFields

func (b *EntMutationBuilder) GetRawFields() map[string]interface{}

func (*EntMutationBuilder) GetViewer

func (b *EntMutationBuilder) GetViewer() viewer.ViewerContext

func (*EntMutationBuilder) OverrideRawField

func (b *EntMutationBuilder) OverrideRawField(key string, val interface{})

func (*EntMutationBuilder) RemoveInboundEdge

func (b *EntMutationBuilder) RemoveInboundEdge(edgeType ent.EdgeType, id1 string, nodeType ent.NodeType) error

func (*EntMutationBuilder) RemoveOutboundEdge

func (b *EntMutationBuilder) RemoveOutboundEdge(edgeType ent.EdgeType, id2 string, nodeType ent.NodeType) error

func (*EntMutationBuilder) SetObservers

func (b *EntMutationBuilder) SetObservers(observers []Observer)

func (*EntMutationBuilder) SetRawFields

func (b *EntMutationBuilder) SetRawFields(m map[string]interface{})

func (*EntMutationBuilder) SetTriggers

func (b *EntMutationBuilder) SetTriggers(triggers []Trigger)

func (*EntMutationBuilder) SetValidators

func (b *EntMutationBuilder) SetValidators(validators []Validator)

func (*EntMutationBuilder) Validate

func (b *EntMutationBuilder) Validate() error

type EntMutationChangeset

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

func (*EntMutationChangeset) Changesets

func (c *EntMutationChangeset) Changesets() []ent.Changeset

func (*EntMutationChangeset) Dependencies

func (c *EntMutationChangeset) Dependencies() ent.MutationBuilderMap

func (*EntMutationChangeset) EntConfig

func (c *EntMutationChangeset) EntConfig() ent.Config

func (*EntMutationChangeset) Entity

func (c *EntMutationChangeset) Entity() ent.Entity

func (*EntMutationChangeset) ExistingEnt

func (c *EntMutationChangeset) ExistingEnt() ent.Entity

func (*EntMutationChangeset) GetExecutor

func (c *EntMutationChangeset) GetExecutor() ent.Executor

func (*EntMutationChangeset) GetPlaceholderID

func (c *EntMutationChangeset) GetPlaceholderID() string

func (*EntMutationChangeset) GetViewer

func (c *EntMutationChangeset) GetViewer() viewer.ViewerContext

func (*EntMutationChangeset) Observers

func (c *EntMutationChangeset) Observers() []Observer

func (*EntMutationChangeset) Validators

func (c *EntMutationChangeset) Validators() []Validator

type FieldInfo

type FieldInfo struct {
	// The field as defined by the developer
	Field *field.Field
	// The value provided by the end user
	Value interface{}
}

FieldInfo represents the information from the action passed to EntMutationBuilder.

type FieldMap

type FieldMap map[string]*FieldInfo

FieldMap is a named type for a map of field names to FieldInfo. Generated by the ent framework for actions

type Observer

type Observer interface {
	Observe() error
}

Observer is something that's run after an action has been run This is where things like send email, send push notification etc are run They are run IFF the action succeeds. They are not run within the transaction where the action, trigger, validator etc all runs

type Trigger

type Trigger interface {
	GetChangeset() (ent.Changeset, error)
}

type Validator

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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