command

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UseCase

type UseCase struct {
	// OrganizationRepo provides an abstraction on top of the organization data source.
	OrganizationRepo organization.Repository

	// LedgerRepo provides an abstraction on top of the ledger data source.
	LedgerRepo ledger.Repository

	// SegmentRepo provides an abstraction on top of the segment data source.
	SegmentRepo segment.Repository

	// PortfolioRepo provides an abstraction on top of the portfolio data source.
	PortfolioRepo portfolio.Repository

	// AccountRepo provides an abstraction on top of the account data source.
	AccountRepo account.Repository

	// AssetRepo provides an abstraction on top of the asset data source.
	AssetRepo asset.Repository

	// AccountTypeRepo provides an abstraction on top of the account type data source.
	AccountTypeRepo accounttype.Repository

	// MetadataRepo provides an abstraction on top of the metadata data source.
	MetadataRepo mongodb.Repository

	// RedisRepo provides an abstraction on top of the redis consumer.
	RedisRepo redis.RedisRepository

	// BalancePort provides an abstraction for balance operations.
	// This is a transport-agnostic "port" that can be implemented by either:
	//   - transaction.UseCase: Direct in-process calls (unified ledger mode)
	//   - GRPCBalanceAdapter: Network calls via gRPC (separate services mode)
	BalancePort mbootstrap.BalancePort
}

UseCase is a struct that aggregates various repositories for simplified access in use case implementation.

func (*UseCase) CreateAccount

func (uc *UseCase) CreateAccount(ctx context.Context, organizationID, ledgerID uuid.UUID, cai *mmodel.CreateAccountInput, token string) (*mmodel.Account, error)

CreateAccount creates an account and metadata, then synchronously creates the default balance. The balance is created via the BalancePort interface, which can be either local (in-process) or remote (gRPC) depending on the deployment mode.

func (*UseCase) CreateAccountType

func (uc *UseCase) CreateAccountType(ctx context.Context, organizationID, ledgerID uuid.UUID, payload *mmodel.CreateAccountTypeInput) (*mmodel.AccountType, error)

CreateAccountType creates a new account type. It returns the created account type and an error if the operation fails.

func (*UseCase) CreateAsset

func (uc *UseCase) CreateAsset(ctx context.Context, organizationID, ledgerID uuid.UUID, cii *mmodel.CreateAssetInput, token string) (*mmodel.Asset, error)

CreateAsset creates an asset and metadata synchronously and ensures an external account exists for the asset. If a new external account is created, it also creates the default balance for that account. The balance is created via the BalancePort interface, which can be either local (in-process) or remote (gRPC) depending on the deployment mode.

func (*UseCase) CreateLedger

func (uc *UseCase) CreateLedger(ctx context.Context, organizationID uuid.UUID, cli *mmodel.CreateLedgerInput) (*mmodel.Ledger, error)

CreateLedger creates a new ledger persists data in the repository.

func (*UseCase) CreateMetadata

func (uc *UseCase) CreateMetadata(ctx context.Context, entityName, entityID string, metadata map[string]any) (map[string]any, error)

func (*UseCase) CreateOrganization

func (uc *UseCase) CreateOrganization(ctx context.Context, coi *mmodel.CreateOrganizationInput) (*mmodel.Organization, error)

CreateOrganization creates a new organization persists data in the repository.

func (*UseCase) CreatePortfolio

func (uc *UseCase) CreatePortfolio(ctx context.Context, organizationID, ledgerID uuid.UUID, cpi *mmodel.CreatePortfolioInput) (*mmodel.Portfolio, error)

CreatePortfolio creates a new portfolio persists data in the repository.

func (*UseCase) CreateSegment

func (uc *UseCase) CreateSegment(ctx context.Context, organizationID, ledgerID uuid.UUID, cpi *mmodel.CreateSegmentInput) (*mmodel.Segment, error)

CreateSegment creates a new segment persists data in the repository.

func (*UseCase) DeleteAccountByID

func (uc *UseCase) DeleteAccountByID(ctx context.Context, organizationID, ledgerID uuid.UUID, portfolioID *uuid.UUID, id uuid.UUID, token string) error

DeleteAccountByID deletes an account from the repository by ids. It first deletes all balances associated with the account via the BalancePort interface, which can be either local (in-process) or remote (gRPC) depending on the deployment mode.

func (*UseCase) DeleteAccountTypeByID

func (uc *UseCase) DeleteAccountTypeByID(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error

DeleteAccountTypeByID deletes an account type by its ID. It returns an error if the operation fails or if the account type is not found.

func (*UseCase) DeleteAssetByID

func (uc *UseCase) DeleteAssetByID(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error

DeleteAssetByID delete an asset from the repository by ids.

func (*UseCase) DeleteLedgerByID

func (uc *UseCase) DeleteLedgerByID(ctx context.Context, organizationID, id uuid.UUID) error

DeleteLedgerByID deletes a ledger from the repository

func (*UseCase) DeleteOrganizationByID

func (uc *UseCase) DeleteOrganizationByID(ctx context.Context, id uuid.UUID) error

DeleteOrganizationByID fetch a new organization from the repository

func (*UseCase) DeletePortfolioByID

func (uc *UseCase) DeletePortfolioByID(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error

DeletePortfolioByID deletes a portfolio from the repository by ids.

func (*UseCase) DeleteSegmentByID

func (uc *UseCase) DeleteSegmentByID(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error

DeleteSegmentByID delete a segment from the repository by ids.

func (*UseCase) UpdateAccount

func (uc *UseCase) UpdateAccount(ctx context.Context, organizationID, ledgerID uuid.UUID, portfolioID *uuid.UUID, id uuid.UUID, uai *mmodel.UpdateAccountInput) (*mmodel.Account, error)

UpdateAccount update an account from the repository by given id.

func (*UseCase) UpdateAccountType

func (uc *UseCase) UpdateAccountType(ctx context.Context, organizationID, ledgerID uuid.UUID, id uuid.UUID, input *mmodel.UpdateAccountTypeInput) (*mmodel.AccountType, error)

UpdateAccountType updates an account type by its ID. It returns the updated account type and an error if the operation fails.

func (*UseCase) UpdateAssetByID

func (uc *UseCase) UpdateAssetByID(ctx context.Context, organizationID, ledgerID uuid.UUID, id uuid.UUID, uii *mmodel.UpdateAssetInput) (*mmodel.Asset, error)

UpdateAssetByID update an asset from the repository by given id.

func (*UseCase) UpdateLedgerByID

func (uc *UseCase) UpdateLedgerByID(ctx context.Context, organizationID, id uuid.UUID, uli *mmodel.UpdateLedgerInput) (*mmodel.Ledger, error)

UpdateLedgerByID update a ledger from the repository.

func (*UseCase) UpdateMetadata

func (uc *UseCase) UpdateMetadata(ctx context.Context, entityName, entityID string, metadata map[string]any) (map[string]any, error)

func (*UseCase) UpdateOrganizationByID

func (uc *UseCase) UpdateOrganizationByID(ctx context.Context, id uuid.UUID, uoi *mmodel.UpdateOrganizationInput) (*mmodel.Organization, error)

UpdateOrganizationByID update an organization from the repository.

func (*UseCase) UpdatePortfolioByID

func (uc *UseCase) UpdatePortfolioByID(ctx context.Context, organizationID, ledgerID, id uuid.UUID, upi *mmodel.UpdatePortfolioInput) (*mmodel.Portfolio, error)

UpdatePortfolioByID update a portfolio from the repository by given id.

func (*UseCase) UpdateSegmentByID

func (uc *UseCase) UpdateSegmentByID(ctx context.Context, organizationID, ledgerID, id uuid.UUID, upi *mmodel.UpdateSegmentInput) (*mmodel.Segment, error)

UpdateSegmentByID update a segment from the repository by given id.

Jump to

Keyboard shortcuts

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