Documentation
¶
Overview ¶
Package api4datatug is the DataTug module's HTTP API layer. It translates HTTP into domain commands and back; the business logic lives in facade4datatug and the storage access in dal-go.
Copyright 2026 Sneat.co
Index ¶
- func RegisterHttpRoutes(handle extension.HTTPHandleFunc, ids facade4datatug.IDGenerator)
- func RegisterHttpRoutesWithOptions(handle extension.HTTPHandleFunc, ids facade4datatug.IDGenerator, ...)
- func RegisterHttpRoutesWithPlan(handle extension.HTTPHandleFunc, ids facade4datatug.IDGenerator, ...)
- type CompleteGitHubAuthorizationRequest
- type CompleteGitHubAuthorizationResponse
- type CreateGitHubProjectRequest
- type CreateProjectRequest
- type CreateProjectResponse
- type CreateSharedProjectRequest
- type GitHubAuthorizationRouteOptions
- type GitHubAuthorizationService
- type GitHubBranchCapabilities
- type GitHubProjectBranch
- type GitHubProjectBranchesResponse
- type GitHubProjectRouteOptions
- type GitHubRepositoryOption
- type ListGitHubRepositoriesResponse
- type PlanRouteOptions
- type QueryActivityRouteOptions
- type QueryActivityRouteService
- type RegisterGithubProjectRequest
- type RegisterGithubProjectResponse
- type RouteOptions
- type SaveGitHubQueryRequest
- type SharedProjectRouteOptions
- type StartGitHubAuthorizationResponse
- type VerifiedPlanCaller
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHttpRoutes ¶
func RegisterHttpRoutes(handle extension.HTTPHandleFunc, ids facade4datatug.IDGenerator)
RegisterHttpRoutes registers the DataTug module's HTTP routes.
ids is the host's adapter for the domain's IDGenerator port; the host supplies it at composition time (sneat-go/pkg/modules/datatug).
Route paths are literal: the host mounts them verbatim, with no module-id or /v0/ prefix added. These are the paths the datatug-apps client already calls.
func RegisterHttpRoutesWithOptions ¶ added in v0.10.0
func RegisterHttpRoutesWithOptions(handle extension.HTTPHandleFunc, ids facade4datatug.IDGenerator, options RouteOptions)
RegisterHttpRoutesWithOptions mounts the shared command as well as legacy routes. An unbound shared service returns 503 without authentication/storage effects. Binding this route requires independently reviewed host composition.
func RegisterHttpRoutesWithPlan ¶ added in v0.4.0
func RegisterHttpRoutesWithPlan(handle extension.HTTPHandleFunc, ids facade4datatug.IDGenerator, plan PlanRouteOptions)
RegisterHttpRoutesWithPlan adds the personal plan route with host-injected verification and reads. An unbound route fails closed with 503.
Types ¶
type CompleteGitHubAuthorizationRequest ¶ added in v0.13.0
type CompleteGitHubAuthorizationRequest struct {
Code string `json:"code"`
State string `json:"state"`
}
func (CompleteGitHubAuthorizationRequest) Validate ¶ added in v0.13.0
func (r CompleteGitHubAuthorizationRequest) Validate() error
type CompleteGitHubAuthorizationResponse ¶ added in v0.13.0
type CompleteGitHubAuthorizationResponse struct {
Connected bool `json:"connected"`
}
type CreateGitHubProjectRequest ¶ added in v0.14.0
type CreateGitHubProjectRequest struct {
Title string `json:"title"`
SpaceID string `json:"spaceID"`
OperationID string `json:"operationId"`
GitHub struct {
RepositoryID int64 `json:"repositoryID"`
Owner string `json:"owner"`
Name string `json:"name"`
Folder string `json:"folder"`
Branch string `json:"branch"`
ExpectedBranchHead string `json:"expectedBranchHead"`
} `json:"github"`
Template struct {
ID string `json:"id"`
Commit string `json:"commit"`
} `json:"template"`
}
func (*CreateGitHubProjectRequest) UnmarshalJSON ¶ added in v0.14.0
func (v *CreateGitHubProjectRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON refuses unknown fields recursively. The common mutation API must never silently discard richer client metadata before computing a request digest or writing to GitHub.
func (CreateGitHubProjectRequest) Validate ¶ added in v0.14.0
func (v CreateGitHubProjectRequest) Validate() error
type CreateProjectRequest ¶
CreateProjectRequest is the body of a create-project request. The store is taken from the `?store=` query parameter (the same shape the datatug CLI agent's create_project endpoint uses), so it is not part of the JSON body.
func (CreateProjectRequest) Validate ¶
func (v CreateProjectRequest) Validate() error
Validate validates the request.
type CreateProjectResponse ¶
type CreateProjectResponse struct {
ID string `json:"id"`
}
CreateProjectResponse is the response of a successful create-project call.
type CreateSharedProjectRequest ¶ added in v0.10.0
type CreateSharedProjectRequest struct {
}
func (CreateSharedProjectRequest) Validate ¶ added in v0.10.0
func (r CreateSharedProjectRequest) Validate() error
type GitHubAuthorizationRouteOptions ¶ added in v0.13.0
type GitHubAuthorizationRouteOptions struct {
Provider GitHubAuthorizationService
}
GitHubAuthorizationRouteOptions opts the host into actor-bound GitHub App OAuth routes. A nil provider keeps the routes fail-closed with 503.
type GitHubAuthorizationService ¶ added in v0.13.0
type GitHubAuthorizationService interface {
BeginAuthorization(context.Context, string) (string, error)
CompleteAuthorization(context.Context, string, string, string) error
ListRepositories(context.Context, string) ([]githubauth4datatug.GitHubRepository, error)
}
GitHubAuthorizationService is the API layer's narrow host-composition port.
type GitHubBranchCapabilities ¶ added in v0.14.0
type GitHubProjectBranch ¶ added in v0.14.0
type GitHubProjectBranchesResponse ¶ added in v0.14.0
type GitHubProjectBranchesResponse struct {
Branches []GitHubProjectBranch `json:"branches"`
DefaultBranch string `json:"defaultBranch"`
CurrentBranch string `json:"currentBranch,omitempty"`
Capabilities GitHubBranchCapabilities `json:"capabilities"`
}
type GitHubProjectRouteOptions ¶ added in v0.14.0
type GitHubProjectRouteOptions struct {
Service *facade4datatug.SharedProjectService
Provider *githubauth4datatug.Provider
AuthorizeRepository func(context.Context, string, int64, string, string) (facade4datatug.GitHubCreateRepository, error)
// contains filtered or unexported fields
}
GitHubProjectRouteOptions are injected by the host after configuring the dedicated DataTug GitHub App and paid Space service. A missing port is 503. AuthorizeRepository must freshly bind the Firebase UID to the current GitHub user, selected installation, immutable repository and write grant.
type GitHubRepositoryOption ¶ added in v0.13.0
type ListGitHubRepositoriesResponse ¶ added in v0.13.0
type ListGitHubRepositoriesResponse struct {
Repositories []GitHubRepositoryOption `json:"repositories"`
}
type PlanRouteOptions ¶ added in v0.4.0
type PlanRouteOptions struct {
Verifier VerifiedPlanCaller
Service facade4datatug.PersonalPlanService
}
type QueryActivityRouteOptions ¶ added in v0.20.0
type QueryActivityRouteOptions struct {
Service QueryActivityRouteService
}
type QueryActivityRouteService ¶ added in v0.20.0
type QueryActivityRouteService interface {
IssueContext(context.Context, string, string, string) (facade4datatug.QueryActivityContextResponse, error)
Report(context.Context, string, string, facade4datatug.QueryActivityReport) (facade4datatug.QueryActivityReportResult, error)
}
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 is the body of a register-github-project request: a project whose files the client has already committed to a GitHub repository, which the cloud only needs to record in the user's index.
func (RegisterGithubProjectRequest) Validate ¶ added in v0.2.0
func (v RegisterGithubProjectRequest) Validate() error
Validate validates the request.
type RegisterGithubProjectResponse ¶ added in v0.2.0
type RegisterGithubProjectResponse struct {
ID string `json:"id"`
}
RegisterGithubProjectResponse is the response of a successful call.
type RouteOptions ¶ added in v0.10.0
type RouteOptions struct {
Plan PlanRouteOptions
QueryActivity QueryActivityRouteOptions
GitHubAuthorization GitHubAuthorizationRouteOptions
GitHubProjects GitHubProjectRouteOptions
}
RouteOptions preserve the existing plan binding and explicitly opt a host into the new shared route. Old registration APIs retain their exact routes.
type SaveGitHubQueryRequest ¶ added in v0.14.0
type SaveGitHubQueryRequest struct{ dto.SaveQueryRequest }
func (*SaveGitHubQueryRequest) UnmarshalJSON ¶ added in v0.14.0
func (v *SaveGitHubQueryRequest) UnmarshalJSON(data []byte) error
func (SaveGitHubQueryRequest) Validate ¶ added in v0.14.0
func (v SaveGitHubQueryRequest) Validate() error
type SharedProjectRouteOptions ¶ added in v0.10.0
type SharedProjectRouteOptions struct {
}
SharedProjectRouteOptions are supplied only by RegisterHttpRoutesWithOptions; the legacy route registration leaves shared-project routes unmounted. A configured service proves current linked membership and sponsor status for AI eligibility, while project writes still require mutation-time paid checks. Host activation also requires reviewed Firebase rules: today's broad Space member grants do not make the separate create-receipt subtree private.
type StartGitHubAuthorizationResponse ¶ added in v0.13.0
type StartGitHubAuthorizationResponse struct {
AuthorizationURL string `json:"authorizationURL"`
}
type VerifiedPlanCaller ¶ added in v0.4.0
type VerifiedPlanCaller interface {
VerifyPlanCaller(context.Context, *http.Request) (string, error)
}
VerifiedPlanCaller is implemented by the host's credential verifier. It must check token signature, audience, scope and active grant as applicable; this route never regards the Authorization header itself as proof.
Source Files
¶
- http_github_authorization.go
- http_github_project_branches.go
- http_github_project_capabilities.go
- http_github_project_create.go
- http_github_project_reads.go
- http_github_project_register.go
- http_github_query_save.go
- http_plan.go
- http_project_create.go
- http_query_activity.go
- http_shared_project_ai_eligibility.go
- http_shared_project_create.go
- import_pointers.go
- routes.go