crud

package
v0.49.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 10 Imported by: 0

README

crud

Client implementation in go for the Freym service crud.

Docs

Please have a look at our documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthData

type AuthData struct {
	TenantId string
	UserId   string
	Scopes   []string
	Data     map[string]any
}

type CloneResponse

type CloneResponse struct {
	ValidationErrors      []string
	FieldValidationErrors map[string]string
	Entry                 Entry
}

type CreateResponse

type CreateResponse struct {
	ValidationErrors      []string
	FieldValidationErrors map[string]string
	Entry                 Entry
}

type DeliveryClient

type DeliveryClient interface {
	GetEntry(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		filter *Filter,
		wait *Wait,
		options *GetSingleEntryOptions,
	) (*Entry, error)
	GetEntryList(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		pagination *Pagination,
		filter *Filter,
		order []Order,
		wait *ListWait,
		options *GetEntryOptions,
	) (*EntryList, error)
	GetViewEntry(
		ctx context.Context,
		view string,
		authData *AuthData,
		filter *Filter,
		wait *Wait,
		options *GetEntryOptions,
	) (*Entry, error)
	GetViewEntryList(
		ctx context.Context,
		view string,
		authData *AuthData,
		pagination *Pagination,
		filter *Filter,
		order []Order,
		wait *ListWait,
		options *GetEntryOptions,
	) (*EntryList, error)
	CreateEntry(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		data Entry,
		eventMetadata *EventMetadata,
	) (*CreateResponse, error)
	UpsertEntry(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		data Entry,
		eventMetadata *EventMetadata,
	) (*UpsertResponse, error)
	UpdateEntry(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		data Entry,
		eventMetadata *EventMetadata,
	) (*UpdateResponse, error)
	UpdateEntryByFilter(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		filter *Filter,
		data Entry,
		eventMetadata *EventMetadata,
	) (*UpdateByFilterResponse, error)
	CloneEntry(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		newId string,
		eventMetadata *EventMetadata,
	) (*CloneResponse, error)
	DeleteEntryById(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		eventMetadata *EventMetadata,
	) (int64, error)
	DeleteEntryByFilter(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		filter *Filter,
		eventMetadata *EventMetadata,
	) (int64, error)
	Close() error
}

func NewDeliveryClient

func NewDeliveryClient(conf *config.Config) (DeliveryClient, error)

type DeploymentOptions

type DeploymentOptions struct {
	Target managementpb.DeploymentTarget
	Force  bool
}

type Entry

type Entry map[string]any

type EntryList

type EntryList struct {
	Limit   int64
	Page    int64
	Total   int64
	Entries []Entry
}

type EnumType

type EnumType struct {
	Name   string
	Values []string
}

type EventMetadata

type EventMetadata struct {
	CorrelationId string
	CausationId   string
	Target        deliverypb.DeploymentTarget
}

type FieldFilter

type FieldFilter struct {
	Operation string
	Type      string
	Value     any
}

type Filter

type Filter struct {
	// all these field filters have to match
	Fields map[string]FieldFilter
	// these filters will be calculated using the and operator
	And []Filter
	// these filters will be calculated using the or operator
	Or []Filter
}

type GetEntryOptions added in v0.45.0

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

func (*GetEntryOptions) Target added in v0.45.0

func (*GetEntryOptions) UseStrongConsistency added in v0.45.0

func (o *GetEntryOptions) UseStrongConsistency() bool

func (*GetEntryOptions) UseStrongConsistencyById added in v0.45.0

func (o *GetEntryOptions) UseStrongConsistencyById() string

type GetEntryOptionsBuilder added in v0.45.0

type GetEntryOptionsBuilder struct {
	Target                   deliverypb.DeploymentTarget
	UseStrongConsistency     bool
	UseStrongConsistencyById string
}

func (*GetEntryOptionsBuilder) Build added in v0.45.0

type GetSingleEntryOptions added in v0.45.0

type GetSingleEntryOptions struct {
	GetEntryOptions
	// contains filtered or unexported fields
}

func (*GetSingleEntryOptions) ReturnEmptyDataIfNotFound added in v0.45.0

func (o *GetSingleEntryOptions) ReturnEmptyDataIfNotFound() bool

type GetSingleEntryOptionsBuilder added in v0.45.0

type GetSingleEntryOptionsBuilder struct {
	GetEntryOptionsBuilder
	ReturnEmptyDataIfNotFound bool
}

func (*GetSingleEntryOptionsBuilder) Build added in v0.45.0

type ListWait added in v0.44.0

type ListWait struct {
	Condition        []ListWaitCondition
	ConditionTimeout time.Duration
}

type ListWaitCondition added in v0.44.0

type ListWaitCondition struct {
	Operation string
	Value     int64
}

type ManagementClient

type ManagementClient interface {
	DeploySchema(
		ctx context.Context,
		deploymentId int64,
		namespace string,
		projectionTypes []ObjectType,
		crudTypes []ObjectType,
		nestedTypes []ObjectType,
		enums []EnumType,
		views []View,
		baseViews []View,
		options *DeploymentOptions,
	) error
	ActivateSchema(ctx context.Context, deploymentId int64) error
	ConfirmSchema(ctx context.Context, deploymentId int64) error
	RollbackSchema(ctx context.Context, namespace string, target managementpb.DeploymentTarget) error
	RollbackSchemaByDeployment(ctx context.Context, deploymentId int64) error
	GetSchemaDeployment(ctx context.Context, deploymentId int64) (uint32, error)
	Close() error
}

func NewManagementClient

func NewManagementClient(conf *config.Config) (ManagementClient, error)

type MockDeliveryClient

type MockDeliveryClient struct {
	mock.Mock
}

func (*MockDeliveryClient) CloneEntry

func (c *MockDeliveryClient) CloneEntry(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	id string,
	newId string,
	eventMetadata *EventMetadata,
) (*CloneResponse, error)

func (*MockDeliveryClient) Close

func (c *MockDeliveryClient) Close() error

func (*MockDeliveryClient) CreateEntry

func (c *MockDeliveryClient) CreateEntry(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	id string,
	data Entry,
	eventMetadata *EventMetadata,
) (*CreateResponse, error)

func (*MockDeliveryClient) DeleteEntryByFilter

func (c *MockDeliveryClient) DeleteEntryByFilter(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	filter *Filter,
	eventMetadata *EventMetadata,
) (int64, error)

func (*MockDeliveryClient) DeleteEntryById

func (c *MockDeliveryClient) DeleteEntryById(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	id string,
	eventMetadata *EventMetadata,
) (int64, error)

func (*MockDeliveryClient) GetEntry

func (c *MockDeliveryClient) GetEntry(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	id string,
	filter *Filter,
	wait *Wait,
	options *GetSingleEntryOptions,
) (*Entry, error)

func (*MockDeliveryClient) GetEntryList

func (c *MockDeliveryClient) GetEntryList(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	pagination *Pagination,
	filter *Filter,
	order []Order,
	wait *ListWait,
	options *GetEntryOptions,
) (*EntryList, error)

func (*MockDeliveryClient) GetViewEntry added in v0.44.0

func (c *MockDeliveryClient) GetViewEntry(
	ctx context.Context,
	view string,
	authData *AuthData,
	filter *Filter,
	wait *Wait,
	options *GetEntryOptions,
) (*Entry, error)

func (*MockDeliveryClient) GetViewEntryList added in v0.44.0

func (c *MockDeliveryClient) GetViewEntryList(
	ctx context.Context,
	view string,
	authData *AuthData,
	pagination *Pagination,
	filter *Filter,
	order []Order,
	wait *ListWait,
	options *GetEntryOptions,
) (*EntryList, error)

func (*MockDeliveryClient) UpdateEntry

func (c *MockDeliveryClient) UpdateEntry(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	id string,
	data Entry,
	eventMetadata *EventMetadata,
) (*UpdateResponse, error)

func (*MockDeliveryClient) UpdateEntryByFilter added in v0.35.0

func (c *MockDeliveryClient) UpdateEntryByFilter(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	filter *Filter,
	data Entry,
	eventMetadata *EventMetadata,
) (*UpdateByFilterResponse, error)

func (*MockDeliveryClient) UpsertEntry added in v0.44.0

func (c *MockDeliveryClient) UpsertEntry(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	id string,
	data Entry,
	eventMetadata *EventMetadata,
) (*UpsertResponse, error)

type MockManagementClient

type MockManagementClient struct {
	mock.Mock
}

func (*MockManagementClient) ActivateSchema added in v0.31.7

func (c *MockManagementClient) ActivateSchema(ctx context.Context, deploymentId int64) error

func (*MockManagementClient) Close

func (c *MockManagementClient) Close() error

func (*MockManagementClient) ConfirmSchema

func (c *MockManagementClient) ConfirmSchema(ctx context.Context, deploymentId int64) error

func (*MockManagementClient) DeploySchema

func (c *MockManagementClient) DeploySchema(
	ctx context.Context,
	deploymentId int64,
	namespace string,
	projectionTypes []ObjectType,
	crudTypes []ObjectType,
	nestedTypes []ObjectType,
	enums []EnumType,
	views []View,
	baseViews []View,
	options *DeploymentOptions,
) error

func (*MockManagementClient) GetSchemaDeployment

func (c *MockManagementClient) GetSchemaDeployment(ctx context.Context, deploymentId int64) (uint32, error)

func (*MockManagementClient) RollbackSchema

func (c *MockManagementClient) RollbackSchema(
	ctx context.Context,
	namespace string,
	target managementpb.DeploymentTarget,
) error

func (*MockManagementClient) RollbackSchemaByDeployment added in v0.31.8

func (c *MockManagementClient) RollbackSchemaByDeployment(ctx context.Context, deploymentId int64) error

type ObjectType

type ObjectType struct {
	Name       string
	Directives []TypeDirective
	Fields     []TypeField
}

type Order

type Order struct {
	Field      string
	Descending bool
}

type Pagination

type Pagination struct {
	Limit int64
	Page  int64
}

type TypeArgument

type TypeArgument struct {
	Name  string
	Value any
}

type TypeDirective

type TypeDirective struct {
	Name      string
	Arguments []TypeArgument
}

type TypeField

type TypeField struct {
	Name       string
	Type       []string
	Directives []TypeDirective
}

type UpdateByFilterDataValidationErrorResponse added in v0.35.0

type UpdateByFilterDataValidationErrorResponse struct {
	ValidationErrors      []string
	FieldValidationErrors map[string]string
}

type UpdateByFilterResponse added in v0.35.0

type UpdateByFilterResponse struct {
	NumberOfUpdatedEntries int64
	ValidationErrors       map[string]UpdateByFilterDataValidationErrorResponse
}

type UpdateResponse

type UpdateResponse struct {
	ValidationErrors      []string
	FieldValidationErrors map[string]string
	Entry                 Entry
}

type UpsertResponse added in v0.44.0

type UpsertResponse struct {
	ValidationErrors      []string
	FieldValidationErrors map[string]string
	Entry                 Entry
}

type View added in v0.38.0

type View struct {
	Name       string
	Sql        string
	Directives []TypeDirective
	Fields     []TypeField
}

type Wait

type Wait struct {
	ConditionFilter  *Filter
	ConditionTimeout time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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