logic

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS_ACTIVE = "active"
)

Variables

This section is empty.

Functions

func ImportProjectFromYAML

func ImportProjectFromYAML(yamlStr string, projectID uuid.UUID, userID uuid.UUID) error

ImportProjectFromYAML imports the project architecture from YAML

func ValidateProjectImportYAML

func ValidateProjectImportYAML(yamlStr string, projectID uuid.UUID) []string

ValidateProjectImportYAML validates the YAML structure and references

Types

type AppDBSerializerStruct

type AppDBSerializerStruct struct {
	ID                string `json:"id"`
	Name              string `json:"name"`
	Status            string `json:"status"`
	Description       string `json:"description"`
	ProjectID         string `json:"project_id"`
	CreatedByUserID   string `json:"created_by_user_id"`
	CreatedByUserName string `json:"created_by_user_name"`
	CreatedAt         string `json:"created_at"`
	UpdatedAt         string `json:"updated_at"`
}

type AppImport

type AppImport struct {
	Name        string          `yaml:"name"`
	Description string          `yaml:"description"`
	Sends       []SendImport    `yaml:"sends,omitempty"`
	Receives    []ReceiveImport `yaml:"receives,omitempty"`
}

type AppObject

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

func (*AppObject) GetID

func (app *AppObject) GetID() uuid.UUID

func (*AppObject) Serialize

func (app *AppObject) Serialize() *AppDBSerializerStruct

type AppResourceMessageObject

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

AppResourceMessageObject represents a relationship between an app, resource, and message

func (*AppResourceMessageObject) GetAppID

func (arm *AppResourceMessageObject) GetAppID() uuid.UUID

GetAppID returns the app ID

func (*AppResourceMessageObject) GetDirection

func (arm *AppResourceMessageObject) GetDirection() string

GetDirection returns the direction (sends/receives)

func (*AppResourceMessageObject) GetMessageID

func (arm *AppResourceMessageObject) GetMessageID() uuid.UUID

GetMessageID returns the message ID

func (*AppResourceMessageObject) GetResourceID

func (arm *AppResourceMessageObject) GetResourceID() uuid.UUID

GetResourceID returns the resource ID

func (*AppResourceMessageObject) GetStatus

func (arm *AppResourceMessageObject) GetStatus() string

GetStatus returns the status

type AppUsageDBSerializerStruct

type AppUsageDBSerializerStruct struct {
	AppID string                               `json:"app_id"`
	Usage []AppUsageResourceDBSerializerStruct `json:"usage"`
}

AppUsageDBSerializerStruct represents the usage for an app

type AppUsageMatrixReader

type AppUsageMatrixReader struct {
	Resource *ResourceDBSerializerStruct `json:"resource"`
	Server   *ServerDBSerializerStruct   `json:"server"`
	Message  *MessageDBSerializerStruct  `json:"message"`
}

AppUsageMatrixReader represents a single connection in the usage matrix

type AppUsageMatrixResponse

type AppUsageMatrixResponse struct {
	AppID    string                 `json:"app_id"`
	Sends    []AppUsageMatrixReader `json:"sends"`
	Receives []AppUsageMatrixReader `json:"receives"`
}

AppUsageMatrixResponse represents the app usage matrix

type AppUsageResourceDBSerializerStruct

type AppUsageResourceDBSerializerStruct struct {
	Resource  *ResourceDBSerializerStruct `json:"resource"`
	Server    *ServerDBSerializerStruct   `json:"server"`
	Message   *MessageDBSerializerStruct  `json:"message"`
	Direction string                      `json:"direction"` // "receives" or "sends"
}

AppUsageResourceDBSerializerStruct represents a single usage record

type AppsObjectsManager

type AppsObjectsManager struct {
}

func (*AppsObjectsManager) CanNameBeUsed

func (appsManager *AppsObjectsManager) CanNameBeUsed(name string, projectID uuid.UUID) bool

func (*AppsObjectsManager) CreateANewApp

func (appsManager *AppsObjectsManager) CreateANewApp(
	name string,
	description string,
	projectID uuid.UUID,
	createdByUserID uuid.UUID) (*AppObject, error)

func (*AppsObjectsManager) GetAllAppsForProject

func (appsManager *AppsObjectsManager) GetAllAppsForProject(
	projectID uuid.UUID) ([]AppObject, error)

func (*AppsObjectsManager) GetAppUsage

func (manager *AppsObjectsManager) GetAppUsage(appID uuid.UUID) (*AppUsageDBSerializerStruct, error)

GetAppUsage gets the usage information for an app

func (*AppsObjectsManager) GetAppUsageMatrix

func (manager *AppsObjectsManager) GetAppUsageMatrix(appID uuid.UUID) (*AppUsageMatrixResponse, error)

GetAppUsageMatrix gets the usage matrix for an app

func (*AppsObjectsManager) GetByID

func (appsManager *AppsObjectsManager) GetByID(id uuid.UUID) (*AppObject, error)

type AppsResourcesMessagesObjectsManager

type AppsResourcesMessagesObjectsManager struct {
}

AppsResourcesMessagesObjectsManager manages app-resource-message relationships

func (*AppsResourcesMessagesObjectsManager) ConnectionExists

func (manager *AppsResourcesMessagesObjectsManager) ConnectionExists(
	appID uuid.UUID,
	resourceID uuid.UUID,
	messageID uuid.UUID,
	direction string,
) bool

ConnectionExists checks if a connection already exists

func (*AppsResourcesMessagesObjectsManager) CreateConnection

func (manager *AppsResourcesMessagesObjectsManager) CreateConnection(
	appID uuid.UUID,
	resourceID uuid.UUID,
	messageID uuid.UUID,
	direction string,
	createdByUserID uuid.UUID,
) (*AppResourceMessageObject, error)

CreateConnection creates a new app-resource-message connection

func (*AppsResourcesMessagesObjectsManager) GetAllForApp

func (manager *AppsResourcesMessagesObjectsManager) GetAllForApp(appID uuid.UUID) ([]*AppResourceMessageObject, error)

GetAllForApp retrieves all app resource messages for a specific app

type BindImport

type BindImport struct {
	Source string `yaml:"source"`
	Target string `yaml:"target"`
}

type MessageDBSerializerStruct

type MessageDBSerializerStruct struct {
	ID            string `json:"id"`
	ProjectID     string `json:"project_id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	Status        string `json:"status"`
	SchemaID      string `json:"schema_id"`
	SchemaVersion int    `json:"schema_version"`
	CreatedByID   string `json:"created_by_id"`
	CreatedByName string `json:"created_by_name"`
	CreatedAt     string `json:"created_at"`
}

type MessageImport

type MessageImport struct {
	Name        string          `yaml:"name"`
	Description string          `yaml:"description"`
	Schema      SchemaReference `yaml:"schema"`
}

type MessageObject

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

func (*MessageObject) GetID

func (message *MessageObject) GetID() uuid.UUID

GetID returns the ID of the message

func (*MessageObject) GetProjectID

func (message *MessageObject) GetProjectID() uuid.UUID

GetProjectID returns the project ID of the message

func (*MessageObject) GetSchemaID

func (message *MessageObject) GetSchemaID() uuid.UUID

GetSchemaID returns the schema ID for this message

func (*MessageObject) GetSchemaVersion

func (message *MessageObject) GetSchemaVersion() int

GetSchemaVersion returns the schema version for this message

func (*MessageObject) Serialize

func (message *MessageObject) Serialize() *MessageDBSerializerStruct

Serialize converts a MessageObject to its serialized form

type MessagesObjectsManager

type MessagesObjectsManager struct{}

func (*MessagesObjectsManager) CanNameBeUsed

func (messagesManager *MessagesObjectsManager) CanNameBeUsed(name string, projectID uuid.UUID) bool

CanNameBeUsed checks if a message name can be used in a project

func (*MessagesObjectsManager) CreateANewMessage

func (messagesManager *MessagesObjectsManager) CreateANewMessage(
	description string,
	userID uuid.UUID,
	projectID uuid.UUID,
	name string,
	schemaID uuid.UUID,
	schemaVersion int,
) (*MessageObject, error)

CreateANewMessage creates a new message in the database

func (*MessagesObjectsManager) GetAllMessagesInProject

func (messagesManager *MessagesObjectsManager) GetAllMessagesInProject(projectID uuid.UUID) ([]MessageObject, error)

GetAllMessagesInProject retrieves all messages in a project

func (*MessagesObjectsManager) GetByID

func (messagesManager *MessagesObjectsManager) GetByID(messageID uuid.UUID) (*MessageObject, error)

GetByID retrieves a message by its ID

type ProjectDBSerializerStruct

type ProjectDBSerializerStruct struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Status        string `json:"status"`
	IsPrivate     bool   `json:"is_private"`
	Description   string `json:"description"`
	CreatedByType string `json:"created_by_type"`
	CreatedByID   string `json:"created_by_id"`
	CreatedByName string `json:"created_by_name"`
}

type ProjectImportYAML

type ProjectImportYAML struct {
	Version  int             `yaml:"version"`
	Servers  []ServerImport  `yaml:"servers"`
	Schemas  []SchemaImport  `yaml:"schemas"`
	Messages []MessageImport `yaml:"messages"`
	Apps     []AppImport     `yaml:"apps"`
}

YAML structures for project import

type ProjectObject

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

ProjectObject represents a project in the system which is a container for all apps, schemas, and other resources. Projects are visible to all users, but can be private or public. Private projects are now supported, but not implemented yet.

func (*ProjectObject) GetID

func (project *ProjectObject) GetID() uuid.UUID

func (*ProjectObject) Serialize

func (project *ProjectObject) Serialize() *ProjectDBSerializerStruct

type ProjectsObjectsManager

type ProjectsObjectsManager struct {
}

ProjectsObjectsManager manages project objects in the system. It accumulates functions which perform operations over multiple project objects, such as creating new projects, retrieving projects by ID or email, etc.

func (*ProjectsObjectsManager) CheckIfProjectWithSpecificNameExists

func (projectsManager *ProjectsObjectsManager) CheckIfProjectWithSpecificNameExists(name string) bool

CheckIfProjectWithSpecificNameExists checks if a project with the given name exists Only one project with a specific name can exist for a user at a time.

func (*ProjectsObjectsManager) CreateANewProject

func (projectsManager *ProjectsObjectsManager) CreateANewProject(name string,
	description string, createdById uuid.UUID) (*ProjectObject, error)

CreateANewProject creates a new project in the system.

func (*ProjectsObjectsManager) GetAllProjects

func (projectsManager *ProjectsObjectsManager) GetAllProjects(myID uuid.UUID) ([]ProjectObject, error)

GetAllProjects retrieves all projects that are active in the system. Currently, returns both public and private projects.

func (*ProjectsObjectsManager) GetByID

func (projectsManager *ProjectsObjectsManager) GetByID(id uuid.UUID) (*ProjectObject, error)

type ReceiveImport

type ReceiveImport struct {
	Message  string `yaml:"message"`
	Resource string `yaml:"resource"`
}

type ResourceBindingDBSerializerStruct

type ResourceBindingDBSerializerStruct struct {
	ID               string `json:"id"`
	SourceResourceID string `json:"source_resource_id"`
	TargetResourceID string `json:"target_resource_id"`
	CreatedAt        string `json:"created_at"`
	UpdatedAt        string `json:"updated_at"`
}

type ResourceBindingObject

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

func (*ResourceBindingObject) GetID

func (binding *ResourceBindingObject) GetID() uuid.UUID

func (*ResourceBindingObject) Serialize

type ResourceBindingsObjectsManager

type ResourceBindingsObjectsManager struct {
}

func (*ResourceBindingsObjectsManager) CheckIfBindingExists

func (manager *ResourceBindingsObjectsManager) CheckIfBindingExists(sourceResourceID, targetResourceID uuid.UUID) bool

func (*ResourceBindingsObjectsManager) CreateABinding

func (manager *ResourceBindingsObjectsManager) CreateABinding(
	sourceResourceID uuid.UUID,
	targetResourceID uuid.UUID) (*ResourceBindingObject, error)

func (*ResourceBindingsObjectsManager) GetAllBindingsForResource

func (manager *ResourceBindingsObjectsManager) GetAllBindingsForResource(
	resourceID uuid.UUID) ([]ResourceBindingObject, error)

func (*ResourceBindingsObjectsManager) GetByID

type ResourceDBSerializerStruct

type ResourceDBSerializerStruct struct {
	ID                string `json:"id"`
	ServerID          string `json:"server_id"`
	Name              string `json:"name"`
	Mode              string `json:"mode"`
	ResourceType      string `json:"resource_type"`
	Status            string `json:"status"`
	Description       string `json:"description"`
	ProjectID         string `json:"project_id"`
	CreatedByUserID   string `json:"created_by_user_id"`
	CreatedByUserName string `json:"created_by_user_name"`
	CreatedAt         string `json:"created_at"`
	UpdatedAt         string `json:"updated_at"`
}

type ResourceImport

type ResourceImport struct {
	Name        string `yaml:"name"`
	Mode        string `yaml:"mode"`
	Type        string `yaml:"type"`
	Description string `yaml:"description"`
}

type ResourceObject

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

func (*ResourceObject) GetID

func (resource *ResourceObject) GetID() uuid.UUID

func (*ResourceObject) GetServerID

func (resource *ResourceObject) GetServerID() uuid.UUID

func (*ResourceObject) Serialize

func (resource *ResourceObject) Serialize() *ResourceDBSerializerStruct

type ResourcesObjectsManager

type ResourcesObjectsManager struct {
}

func (*ResourcesObjectsManager) CanNameBeUsed

func (manager *ResourcesObjectsManager) CanNameBeUsed(name string, serverID uuid.UUID) bool

func (*ResourcesObjectsManager) CreateANewResource

func (manager *ResourcesObjectsManager) CreateANewResource(
	serverID uuid.UUID,
	projectID uuid.UUID,
	name string,
	mode string,
	resourceType string,
	description string,
	createdByUserID uuid.UUID) (*ResourceObject, error)

func (*ResourcesObjectsManager) GetAllResourcesForServer

func (manager *ResourcesObjectsManager) GetAllResourcesForServer(
	serverID uuid.UUID) ([]ResourceObject, error)

func (*ResourcesObjectsManager) GetByID

func (manager *ResourcesObjectsManager) GetByID(id uuid.UUID) (*ResourceObject, error)

type SchemaDBSerializerStruct

type SchemaDBSerializerStruct struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Status        string `json:"status"`
	Type          string `json:"type"`
	Description   string `json:"description"`
	CreatedByType string `json:"created_by_type"`
	CreatedByID   string `json:"created_by_id"`
	ProjectID     string `json:"project_id"`
	CreatedByName string `json:"created_by_name"`
	Schema        string `json:"schema"`
	Version       int    `json:"version"`
}

type SchemaEditDBSerializerStruct

type SchemaEditDBSerializerStruct struct {
	CreatedAt     string `json:"created_at"`
	SchemaID      string `json:"schema_id"`
	UserID        string `json:"user_id"`
	Version       int    `json:"version"`
	CreatedByName string `json:"created_by_name"`
	Schema        string `json:"schema"`
}

type SchemaEditShortDBSerializerStruct

type SchemaEditShortDBSerializerStruct struct {
	CreatedAt     string `json:"created_at"`
	SchemaID      string `json:"schema_id"`
	UserID        string `json:"user_id"`
	Version       int    `json:"version"`
	CreatedByName string `json:"created_by_name"`
}

type SchemaImport

type SchemaImport struct {
	Name        string `yaml:"name"`
	Type        string `yaml:"type"`
	Version     int    `yaml:"version"`
	Description string `yaml:"description"`
	Schema      string `yaml:"schema"`
}

type SchemaObject

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

SchemaObject represents a schema in the system. It is heavily coupled with schema versions.

func (*SchemaObject) CreateANewVersion

func (schema *SchemaObject) CreateANewVersion(newSchemaContent string, userID uuid.UUID) (*SchemaObject, error)

CreateANewVersion creates a new version of an existing schema

func (*SchemaObject) GenerateCode

func (schema *SchemaObject) GenerateCode(language string) (generatedCode string, structName string, err error)

GenerateCode generates code from the schema in the specified language Returns the generated code and the name of the generated structure/class Requires JSON_SCHEMA_CONVERTOR_CMD environment variable to be set with the full path to quicktype

func (*SchemaObject) GetAllVersions

func (schemaObject *SchemaObject) GetAllVersions() []*SchemaVersionObject

func (*SchemaObject) GetCurrentVersion

func (schema *SchemaObject) GetCurrentVersion() int

func (*SchemaObject) GetID

func (schema *SchemaObject) GetID() uuid.UUID

func (*SchemaObject) GetLatestVersion

func (schema *SchemaObject) GetLatestVersion() int

func (*SchemaObject) GetName

func (schema *SchemaObject) GetName() string

func (*SchemaObject) GetProjectID

func (schema *SchemaObject) GetProjectID() uuid.UUID

func (*SchemaObject) GetType

func (schema *SchemaObject) GetType() string

func (*SchemaObject) Serialize

func (schema *SchemaObject) Serialize() *SchemaDBSerializerStruct

type SchemaObjectsManager

type SchemaObjectsManager struct {
}

SchemaObjectsManager manages schemas and schema versions together

func (*SchemaObjectsManager) CanNameBeUsed

func (schemaManager *SchemaObjectsManager) CanNameBeUsed(name string, projectID uuid.UUID) bool

CanNameBeUsed checks if a schema name can be used in a project

func (*SchemaObjectsManager) CheckIfThisSchemaNameAlreadyExists

func (schemaManager *SchemaObjectsManager) CheckIfThisSchemaNameAlreadyExists(ProjectID uuid.UUID, name string) bool

CheckIfThisSchemaNameAlreadyExists checks if a schema with the given name already exists in the project. Users can refer to schemas by name, so we need to ensure that the name is unique in order to avoid confusion.

func (*SchemaObjectsManager) CreateANewSchema

func (schemaManager *SchemaObjectsManager) CreateANewSchema(name string,
	description string,
	schema string,
	schemaType string,
	createdByType string,
	createdById uuid.UUID,
	userID uuid.UUID,
	projectID uuid.UUID,
) (*SchemaObject, error)

CreateANewSchema creates a new schema in the database. Creation of schema also creates a new schema version.

func (*SchemaObjectsManager) GetAllSchemasInProject

func (schemaManager *SchemaObjectsManager) GetAllSchemasInProject(ProjectID uuid.UUID) []SchemaObject

func (*SchemaObjectsManager) GetByID

func (schemaManager *SchemaObjectsManager) GetByID(schemaID uuid.UUID) (*SchemaObject, error)

GetByID retrieves a schema by its ID

func (*SchemaObjectsManager) GetSpecificVersionOfSchema

func (schemaManager *SchemaObjectsManager) GetSpecificVersionOfSchema(schemaID uuid.UUID, version int) (*SchemaVersionObject, error)

GetSpecificVersionOfSchema retrieves a specific version of a schema

func (*SchemaObjectsManager) SchemaWithVersionExists

func (schemaManager *SchemaObjectsManager) SchemaWithVersionExists(schemaID uuid.UUID, schemaVersion int) bool

SchemaWithVersionExists checks if a schema with the specific ID and version exists and is active

type SchemaReference

type SchemaReference struct {
	Name string `yaml:"name"`
}

type SchemaVersionObject

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

SchemaVersionObject represents a version of a schema.

func (*SchemaVersionObject) GenerateCode

func (schemaVersion *SchemaVersionObject) GenerateCode(language string, schemaType string, schemaName string) (generatedCode string, structName string, err error)

GenerateCode generates code from this schema version in the specified language Returns the generated code and the name of the generated structure/class Requires JSON_SCHEMA_CONVERTOR_CMD environment variable to be set with the full path to quicktype

func (*SchemaVersionObject) SerializeLong

func (schemaEditObject *SchemaVersionObject) SerializeLong() *SchemaEditDBSerializerStruct

func (*SchemaVersionObject) SerializeShort

func (schemaEditObject *SchemaVersionObject) SerializeShort() *SchemaEditShortDBSerializerStruct

type SendImport

type SendImport struct {
	Message  string `yaml:"message"`
	Resource string `yaml:"resource"`
}

type ServerDBSerializerStruct

type ServerDBSerializerStruct struct {
	ID                string `json:"id"`
	Name              string `json:"name"`
	Protocol          string `json:"protocol"`
	Status            string `json:"status"`
	Description       string `json:"description"`
	ProjectID         string `json:"project_id"`
	CreatedByUserID   string `json:"created_by_user_id"`
	CreatedByUserName string `json:"created_by_user_name"`
	CreatedAt         string `json:"created_at"`
	UpdatedAt         string `json:"updated_at"`
}

type ServerImport

type ServerImport struct {
	Name        string           `yaml:"name"`
	Type        string           `yaml:"type"`
	Description string           `yaml:"description"`
	Resources   []ResourceImport `yaml:"resources"`
	Binds       []BindImport     `yaml:"binds,omitempty"`
}

type ServerObject

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

func (*ServerObject) GetID

func (server *ServerObject) GetID() uuid.UUID

func (*ServerObject) GetProjectID

func (server *ServerObject) GetProjectID() uuid.UUID

func (*ServerObject) Serialize

func (server *ServerObject) Serialize() *ServerDBSerializerStruct

type ServersObjectsManager

type ServersObjectsManager struct {
}

func (*ServersObjectsManager) CanNameBeUsed

func (manager *ServersObjectsManager) CanNameBeUsed(name string, projectID uuid.UUID) bool

func (*ServersObjectsManager) CreateANewServer

func (manager *ServersObjectsManager) CreateANewServer(
	name string,
	description string,
	protocol string,
	projectID uuid.UUID,
	createdByUserID uuid.UUID) (*ServerObject, error)

func (*ServersObjectsManager) GetAllServersForProject

func (manager *ServersObjectsManager) GetAllServersForProject(
	projectID uuid.UUID) ([]ServerObject, error)

func (*ServersObjectsManager) GetByID

func (manager *ServersObjectsManager) GetByID(id uuid.UUID) (*ServerObject, error)

type UserDBSerializerStruct

type UserDBSerializerStruct struct {
	ID     string `json:"id"`
	Handle string `json:"handle"`
	Status string `json:"status"`
}

type UserObject

type UserObject struct {
	Model *db.UsersDBModel
}

UserObject represents a user in the system. It performs operations on a single user object, such as serialization, authentication, and other user-specific actions.

func (*UserObject) GetID

func (user *UserObject) GetID() uuid.UUID

func (*UserObject) Serialize

func (user *UserObject) Serialize() *UserDBSerializerStruct

func (*UserObject) VerifyPassword

func (user *UserObject) VerifyPassword(password string) bool

VerifyPassword checks if the provided password matches the stored password hash.

type UserObjectsManager

type UserObjectsManager struct {
}

UserObjectsManager manages user objects in the system. It accumulates functions which perform operations over multiple user objects, such as creating new users, retrieving users by ID or email, etc.

func (*UserObjectsManager) FindByEmail

func (usersManager *UserObjectsManager) FindByEmail(email string) (*UserObject, error)

FindByEmail retrieves a user from the database by their email.

func (*UserObjectsManager) FindByID

func (usersManager *UserObjectsManager) FindByID(id uuid.UUID) (*UserObject, error)

FindByID retrieves a user from the database by their ID.

func (*UserObjectsManager) RegisterNewUserWithEmailAndPassword

func (usersManager *UserObjectsManager) RegisterNewUserWithEmailAndPassword(email string, password string) (
	*UserObject, error)

RegisterNewUserWithEmailAndPassword creates a new user in the database with the provided email and password.

Jump to

Keyboard shortcuts

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