Documentation
¶
Overview ¶
Package facade4datatug holds the DataTug extension's application commands.
It is storage-agnostic by construction: the only persistence API it uses is dal-go, so it never learns whether the host backs it with Firestore, an in-memory database (tests), or anything else. Platform needs arrive through ports declared in ports.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrOrgRequired is returned when a GitHub project is registered without // its repository owner. ErrOrgRequired = errors.New("github org is required") // ErrRepoRequired is returned when a GitHub project is registered without // its repository name. ErrRepoRequired = errors.New("github repo is required") )
var ( // ErrUserIDRequired is returned when a command is called without a user. ErrUserIDRequired = errors.New("user id is required") // ErrTitleRequired is returned when a project is created without a title. ErrTitleRequired = errors.New("project title is required") // ErrUnsupportedStore is returned for a store this API does not serve. A // project in a GitHub repo is created by the client holding the user's // GitHub credential, and a local filesystem project by the datatug CLI // agent — only the DataTug cloud store is created here. ErrUnsupportedStore = errors.New("store is not served by the DataTug cloud API") )
Functions ¶
This section is empty.
Types ¶
type Facade ¶
type Facade struct {
// contains filtered or unexported fields
}
Facade carries the injected database and ports for the DataTug extension's application commands. The host constructs one Facade at composition time (sneat-go/pkg/modules/datatug), wiring a real adapter per port; tests construct it over an in-memory database with fakes.
func NewFacade ¶
func NewFacade(db dal.DB, ids IDGenerator) Facade
NewFacade returns a Facade over the given database and ports.
func (Facade) CreateProject ¶
func (f Facade) CreateProject( ctx context.Context, userID, storeID, title string, ) (projectID string, err error)
CreateProject creates a DataTug project in the cloud store and registers its brief in the user's DataTug index, both in one transaction. It returns the id of the created project.
func (Facade) RegisterGithubProject ¶ added in v0.2.0
func (f Facade) RegisterGithubProject( ctx context.Context, userID string, request RegisterGithubProjectRequest, ) (projectID string, err error)
RegisterGithubProject records a project that lives in a GitHub repository in the user's DataTug index, so it shows up among the user's projects.
The project files themselves are created by the client that holds the user's GitHub credential — this command only keeps the index; the cloud never talks to GitHub. It returns the project id the web client addresses the project by (`repo@org@folder`).
type IDGenerator ¶
type IDGenerator interface {
// NewID returns the id of a new record.
NewID(ctx context.Context) (string, error)
}
IDGenerator is a PORT: the module must not import sneat-go-core, sneat-core-modules or another extension's backend, so anything it needs from outside crosses a small interface defined here and is satisfied by an adapter in the host composition root (sneat-go/pkg/modules/datatug/adapters.go). Domain tests fake the port — see project_create_test.go's fakeIDGenerator.
type RegisterGithubProjectRequest ¶ added in v0.2.0
type RegisterGithubProjectRequest struct {
Org string `json:"org"`
Repo string `json:"repo"`
Folder string `json:"folder"`
Title string `json:"title"`
}
RegisterGithubProjectRequest describes a project that already exists in a GitHub repository.
func (RegisterGithubProjectRequest) Validate ¶ added in v0.2.0
func (v RegisterGithubProjectRequest) Validate() error
Validate validates the request.