crud

package
v0.31.8 Latest Latest
Warning

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

Go to latest
Published: Feb 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
	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,
		returnEmptyDataIfNotFound bool,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*Entry, error)
	GetEntryList(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		pagination *Pagination,
		filter *Filter,
		order []Order,
		useStrongConsistency bool,
		target deliverypb.DeploymentTarget,
	) (*EntryList, error)
	CreateEntry(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		data Entry,
		eventMetadata *EventMetadata,
	) (*CreateResponse, error)
	UpdateEntry(
		ctx context.Context,
		typeName string,
		authData *AuthData,
		id string,
		data Entry,
		eventMetadata *EventMetadata,
	) (*UpdateResponse, 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
	UserId        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 ManagementClient

type ManagementClient interface {
	DeploySchema(
		ctx context.Context,
		deploymentId int64,
		namespace string,
		projectionTypes []ObjectType,
		crudTypes []ObjectType,
		nestedTypes []ObjectType,
		enums []EnumType,
		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,
	returnEmptyDataIfNotFound bool,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*Entry, error)

func (*MockDeliveryClient) GetEntryList

func (c *MockDeliveryClient) GetEntryList(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	pagination *Pagination,
	filter *Filter,
	order []Order,
	useStrongConsistency bool,
	target deliverypb.DeploymentTarget,
) (*EntryList, error)

func (*MockDeliveryClient) UpdateEntry

func (c *MockDeliveryClient) UpdateEntry(
	ctx context.Context,
	typeName string,
	authData *AuthData,
	id string,
	data Entry,
	eventMetadata *EventMetadata,
) (*UpdateResponse, 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,
	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 UpdateResponse

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

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