api

package
v0.2.40 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Authentication & Authorization Errors (2000-2099)
	ErrorCodeUnauthorized         = 2000
	ErrorCodeInvalidToken         = 2001 // Used for expired tokens
	ErrorCodeInvalidUserCode      = 2002
	ErrorCodeTokenNotFound        = 2003
	ErrorCodeInvalidDeviceCode    = 2004
	ErrorCodeAuthorizationPending = 2005

	// Organization Errors (3000-3099)
	ErrorCodeOrganizationNotFound = 3000
	ErrorCodeNotOrgMember         = 3001
	ErrorCodeNoCreatePermission   = 3002

	// Application Errors (4000-4099)
	ErrorCodeApplicationNotFound = 4000
	ErrorCodeNoApplicationAccess = 4001
	ErrorCodeDuplicateAppName    = 4002

	// GitHub Integration Errors (5000-5099)
	ErrorCodeGitHubRepoNotFound          = 5000
	ErrorCodeGitHubRepoAccessDenied      = 5001
	ErrorCodeGitHubCollaboratorAddFailed = 5002
)

Error code constants from @repo/errors

Variables

This section is empty.

Functions

func ToCLIError added in v0.2.10

func ToCLIError(errResp *ErrorResponse) error

ToCLIError converts an APIError to a CLIError If a specific error code mapping exists, it returns that CLIError Otherwise, it creates a generic CLIError with the API error details

Types

type AddGithubCollaboratorsRequest added in v0.1.9

type AddGithubCollaboratorsRequest struct {
	ApplicationID  string `json:"applicationId"`
	GithubUsername string `json:"githubUsername"`
}

AddGithubCollaboratorsRequest represents the request body for POST /applications/add-gh-collaborators

type AddGithubCollaboratorsResponse added in v0.1.9

type AddGithubCollaboratorsResponse struct {
	Error   *AppErrorDetail `json:"error,omitempty"`
	Success bool            `json:"success,omitempty"`
	Message string          `json:"message,omitempty"`
}

AddGithubCollaboratorsResponse represents the response from POST /applications/add-gh-collaborators

type AppErrorDetail added in v0.1.11

type AppErrorDetail struct {
	InternalCode int    `json:"internal_code"`
	ErrorString  string `json:"error_string"`
	StatusCode   int    `json:"status_code"`
}

AppErrorDetail represents the error detail from the API (new format)

type ApplicationItem added in v0.1.6

type ApplicationItem struct {
	ID                   string `json:"id"`
	Name                 string `json:"name"`
	GithubRepositoryName string `json:"githubRepositoryName"`
	CloneURLSSH          string `json:"cloneUrlSsh"`
	CloneURLHTTPS        string `json:"cloneUrlHttps"`
}

ApplicationItem represents a single application in the list

type CheckVersionResponse added in v0.1.11

type CheckVersionResponse struct {
	Error         *AppErrorDetail `json:"error,omitempty"`
	ForceUpgrade  bool            `json:"forceUpgrade,omitempty"`
	CanUpgrade    bool            `json:"canUpgrade,omitempty"`
	LatestVersion *string         `json:"latestVersion,omitempty"`
}

CheckVersionResponse represents the response from GET /version/check

type Client

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

Client represents an API client for making authenticated requests

func NewClient

func NewClient(baseURL string) *Client

NewClient creates a new API client with the provided base URL and optional token

func (*Client) AddGithubCollaborators added in v0.1.9

func (c *Client) AddGithubCollaborators(applicationID, githubUsername string) (*AddGithubCollaboratorsResponse, error)

AddGithubCollaborators adds the user as a collaborator to the GitHub repository

func (*Client) CheckVersion added in v0.1.11

func (c *Client) CheckVersion(currentVersion string) (*CheckVersionResponse, error)

CheckVersion checks if the CLI version is up to date

func (*Client) CreateApplication

func (c *Client) CreateApplication(name, description, organizationID string, themeID *string) (*CreateApplicationResponse, error)

CreateApplication creates a new application with a GitHub repository

func (*Client) CreateApplicationVersion added in v0.1.2

func (c *Client) CreateApplicationVersion(applicationID string, appURL string) (*CreateApplicationVersionResponse, error)

CreateApplicationVersion creates a new version of an application

func (*Client) CreateDemoApplication added in v0.2.27

func (c *Client) CreateDemoApplication(organizationID string) (*CreateDemoApplicationResponse, error)

CreateDemoApplication creates a new demo application with a GitHub repository

func (*Client) GetApplicationByRepo

func (c *Client) GetApplicationByRepo(owner, repo string) (*GetApplicationByRepoResponse, error)

GetApplicationByRepo retrieves an application by its repository owner and name

func (*Client) GetApplicationEnv

func (c *Client) GetApplicationEnv(organizationID, applicationID string) (map[string]string, error)

GetApplicationEnv retrieves environment variables for an application

func (*Client) GetApplicationEnvironment added in v0.2.28

func (c *Client) GetApplicationEnvironment(applicationID string) (*GetApplicationEnvironmentResponse, error)

GetApplicationEnvironment retrieves the user's current environment choice for an application

func (c *Client) GetApplicationForLink(applicationID string) (*GetApplicationForLinkResponse, error)

GetApplicationForLink retrieves application info needed for the link command

func (*Client) GetApplicationInfo added in v0.2.40

func (c *Client) GetApplicationInfo(applicationID string) (*GetApplicationInfoResponse, error)

GetApplicationInfo retrieves application info including deploy status and URL

func (*Client) GetApplicationResources added in v0.1.1

func (c *Client) GetApplicationResources(applicationID string) (*GetApplicationResourcesResponse, error)

GetApplicationResources retrieves resources for an application

func (*Client) GetDemoResource added in v0.2.27

func (c *Client) GetDemoResource(orgID string) (*GetDemoResourceResponse, error)

GetDemoResource retrieves the singular demo resource

func (*Client) GetOrganizationApplications added in v0.1.6

func (c *Client) GetOrganizationApplications(organizationID string) (*GetOrganizationApplicationsResponse, error)

GetOrganizationApplications retrieves all applications for an organization

func (*Client) GetOrganizations

func (c *Client) GetOrganizations() (*OrganizationsResponse, error)

GetOrganizations retrieves the list of organizations for the authenticated user

func (*Client) GetResources added in v0.1.18

func (c *Client) GetResources(organizationID string) (*GetResourcesResponse, error)

GetResources retrieves all resources for an organization

func (*Client) GetThemeFiles added in v0.2.40

func (c *Client) GetThemeFiles(applicationID string) (*GetThemeFilesResponse, error)

GetThemeFiles retrieves the generated theme files for an application

func (*Client) GetThemeVersion added in v0.2.40

func (c *Client) GetThemeVersion(applicationID string) (*GetThemeVersionResponse, error)

GetThemeVersion retrieves the theme version for an application

func (*Client) GetVersionStatus added in v0.1.13

func (c *Client) GetVersionStatus(applicationID, organizationID, versionID string) (*GetVersionStatusResponse, error)

GetVersionStatus retrieves the deployment status of an application version

func (*Client) ListApplicationEnvironments added in v0.2.28

func (c *Client) ListApplicationEnvironments(applicationID string) (*ListEnvironmentsResponse, error)

ListApplicationEnvironments retrieves all available environments for an application

func (*Client) ListThemes added in v0.2.40

func (c *Client) ListThemes(orgID string) (*ListThemesResponse, error)

ListThemes retrieves all themes for an organization

func (*Client) Logout

func (c *Client) Logout() error

Logout revokes the current token

func (*Client) PollLogin

func (c *Client) PollLogin(deviceCode string) (*LoginPollResponse, error)

PollLogin polls the login endpoint to check if the user has authorized the device

func (*Client) SaveApplicationResources added in v0.1.18

func (c *Client) SaveApplicationResources(organizationID, applicationID string, resourceIDs []string) (*SaveApplicationResourcesResponse, error)

SaveApplicationResources saves the selected resources for an application

func (*Client) SetApplicationEnvironment added in v0.2.28

func (c *Client) SetApplicationEnvironment(applicationID, environmentID string) (*SetEnvironmentChoiceResponse, error)

SetApplicationEnvironment sets the user's environment choice for an application

func (*Client) StartLogin

func (c *Client) StartLogin() (*LoginStartResponse, error)

StartLogin initiates the device flow login process

func (*Client) UpgradeTheme added in v0.2.40

func (c *Client) UpgradeTheme(applicationID string) error

UpgradeTheme bumps the app's theme version to the latest

func (*Client) VerifyToken

func (c *Client) VerifyToken() (*VerifyTokenResponse, error)

VerifyToken verifies the current token and returns user information

type CreateApplicationRequest

type CreateApplicationRequest struct {
	Name           string  `json:"name"`
	Description    string  `json:"description"`
	OrganizationID string  `json:"organizationId"`
	ThemeID        *string `json:"themeId,omitempty"`
}

CreateApplicationRequest represents the request body for POST /applications

type CreateApplicationResponse

type CreateApplicationResponse struct {
	Error          *AppErrorDetail `json:"error,omitempty"`
	ApplicationID  string          `json:"applicationId,omitempty"`
	RepositoryName string          `json:"repositoryName,omitempty"`
	CloneURLSSH    string          `json:"cloneUrlSsh,omitempty"`
	CloneURLHTTPS  string          `json:"cloneUrlHttps,omitempty"`
}

CreateApplicationResponse represents the response from POST /applications

type CreateApplicationVersionRequest added in v0.1.2

type CreateApplicationVersionRequest struct {
	ApplicationID string `json:"applicationId"`
	AppURL        string `json:"appURL,omitempty"`
}

CreateApplicationVersionRequest represents the request body for POST /applications/versions

type CreateApplicationVersionResponse added in v0.1.2

type CreateApplicationVersionResponse struct {
	Error     *AppErrorDetail `json:"error,omitempty"`
	VersionID string          `json:"versionId,omitempty"`
}

CreateApplicationVersionResponse represents the response from POST /applications/versions

type CreateDemoApplicationRequest added in v0.2.27

type CreateDemoApplicationRequest struct {
	OrganizationID string `json:"organizationId"`
}

CreateDemoApplicationRequest represents the request body for POST /demo_application

type CreateDemoApplicationResponse added in v0.2.27

type CreateDemoApplicationResponse struct {
	Error          *AppErrorDetail `json:"error,omitempty"`
	ApplicationID  string          `json:"applicationId,omitempty"`
	RepositoryName string          `json:"repositoryName,omitempty"`
	CloneURLSSH    string          `json:"cloneUrlSsh,omitempty"`
	CloneURLHTTPS  string          `json:"cloneUrlHttps,omitempty"`
}

CreateDemoApplicationResponse represents the response from POST /demo_application

type EnvironmentItem added in v0.2.28

type EnvironmentItem struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	IsDefault bool   `json:"isDefault"`
}

EnvironmentItem represents a single environment

type ErrorResponse

type ErrorResponse struct {
	Error *AppErrorDetail `json:"error,omitempty"`
}

ErrorResponse represents an error response from the API (new format only)

type GetApplicationByRepoRequest

type GetApplicationByRepoRequest struct {
	Owner string `json:"owner"`
	Repo  string `json:"repo"`
}

GetApplicationByRepoRequest represents the request body for GET /application/from-repo

type GetApplicationByRepoResponse

type GetApplicationByRepoResponse struct {
	Error          *AppErrorDetail `json:"error,omitempty"`
	ApplicationID  string          `json:"applicationId,omitempty"`
	OrganizationID string          `json:"organizationId,omitempty"`
	TemplateID     *string         `json:"templateId,omitempty"`
	TemplateName   *string         `json:"templateName,omitempty"`
	URLSlug        *string         `json:"urlSlug,omitempty"`
}

GetApplicationByRepoResponse represents the response from GET /application/from-repo

type GetApplicationEnvRequest

type GetApplicationEnvRequest struct {
	OrganizationID string `json:"organizationId"`
	ApplicationID  string `json:"applicationId"`
}

GetApplicationEnvRequest represents the request body for POST /application/env

type GetApplicationEnvResponse

type GetApplicationEnvResponse struct {
	Error   *AppErrorDetail   `json:"error,omitempty"`
	EnvVars map[string]string `json:"envVars,omitempty"`
}

GetApplicationEnvResponse represents the response from POST /application/env

type GetApplicationEnvironmentResponse added in v0.2.28

type GetApplicationEnvironmentResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	EnvironmentID   *string         `json:"environmentId,omitempty"`
	EnvironmentName *string         `json:"environmentName,omitempty"`
}

GetApplicationEnvironmentResponse represents the response from GET /application/:applicationId/environment

type GetApplicationForLinkResponse added in v0.2.29

type GetApplicationForLinkResponse struct {
	Error            *AppErrorDetail `json:"error,omitempty"`
	ApplicationID    string          `json:"applicationId,omitempty"`
	OrganizationID   string          `json:"organizationId,omitempty"`
	OrganizationName string          `json:"organizationName,omitempty"`
	Name             string          `json:"name,omitempty"`
	CloneURLSSH      string          `json:"cloneUrlSsh,omitempty"`
	CloneURLHTTPS    string          `json:"cloneUrlHttps,omitempty"`
}

GetApplicationForLinkResponse represents the response from GET /application/:applicationId/link-info

type GetApplicationInfoResponse added in v0.2.40

type GetApplicationInfoResponse struct {
	Error         *AppErrorDetail `json:"error,omitempty"`
	ApplicationID string          `json:"applicationId,omitempty"`
	Name          string          `json:"name,omitempty"`
	AppURL        *string         `json:"appUrl,omitempty"`
	DeployStatus  string          `json:"deployStatus,omitempty"`
}

GetApplicationInfoResponse represents the response from GET /applications/:applicationId/info

type GetApplicationResourcesResponse added in v0.1.1

type GetApplicationResourcesResponse struct {
	Error     *AppErrorDetail `json:"error,omitempty"`
	Resources []ResourceItem  `json:"resources,omitempty"`
}

GetApplicationResourcesResponse represents the response from GET /applications/:applicationId/resources

type GetDemoResourceResponse added in v0.2.27

type GetDemoResourceResponse struct {
	Error    *AppErrorDetail `json:"error,omitempty"`
	Resource *ResourceItem   `json:"resource,omitempty"`
}

GetDemoResourceResponse represents the response from GET /demo_resource

type GetOrganizationApplicationsRequest added in v0.1.7

type GetOrganizationApplicationsRequest struct {
	OrganizationID string `json:"organizationId"`
}

GetOrganizationApplicationsRequest represents the request body for POST /organizations/applications

type GetOrganizationApplicationsResponse added in v0.1.6

type GetOrganizationApplicationsResponse struct {
	Error        *AppErrorDetail   `json:"error,omitempty"`
	Applications []ApplicationItem `json:"applications,omitempty"`
}

GetOrganizationApplicationsResponse represents the response from POST /organizations/applications

type GetResourcesRequest added in v0.1.18

type GetResourcesRequest struct {
	OrganizationID string `json:"organizationId"`
}

GetResourcesRequest represents the request body for POST /resources

type GetResourcesResponse added in v0.1.18

type GetResourcesResponse struct {
	Error     *AppErrorDetail `json:"error,omitempty"`
	Resources []ResourceItem  `json:"resources,omitempty"`
}

GetResourcesResponse represents the response from POST /resources

type GetThemeFilesResponse added in v0.2.40

type GetThemeFilesResponse struct {
	Error         *AppErrorDetail `json:"error,omitempty"`
	Css           *string         `json:"css,omitempty"`
	ThemeModule   *string         `json:"themeModule,omitempty"`
	LogoComponent *string         `json:"logoComponent,omitempty"`
	Skill         *string         `json:"skill,omitempty"`
	Version       *int            `json:"version,omitempty"`
}

GetThemeFilesResponse represents the response from GET /application/:applicationId/theme-files

type GetThemeVersionResponse added in v0.2.40

type GetThemeVersionResponse struct {
	Error              *AppErrorDetail `json:"error,omitempty"`
	AppThemeVersion    *int            `json:"appThemeVersion,omitempty"`
	LatestThemeVersion *int            `json:"latestThemeVersion,omitempty"`
	UpgradeAvailable   bool            `json:"upgradeAvailable"`
}

GetThemeVersionResponse represents the response from GET /application/:applicationId/theme-version

type GetVersionStatusRequest added in v0.1.13

type GetVersionStatusRequest struct {
	ApplicationID  string `json:"applicationId"`
	OrganizationID string `json:"organizationId"`
	VersionID      string `json:"versionId"`
}

GetVersionStatusRequest represents the request body for POST /applications/versions/status

type GetVersionStatusResponse added in v0.1.13

type GetVersionStatusResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	Status          string          `json:"status,omitempty"`
	DeploymentError string          `json:"deploymentError,omitempty"`
	AppURL          string          `json:"app_url,omitempty"`
}

GetVersionStatusResponse represents the response from POST /applications/versions/status

type ListEnvironmentsResponse added in v0.2.28

type ListEnvironmentsResponse struct {
	Error        *AppErrorDetail   `json:"error,omitempty"`
	Environments []EnvironmentItem `json:"environments,omitempty"`
}

ListEnvironmentsResponse represents the response from GET /application/:applicationId/environments

type ListThemesResponse added in v0.2.40

type ListThemesResponse struct {
	Error  *AppErrorDetail `json:"error,omitempty"`
	Themes []ThemeItem     `json:"themes,omitempty"`
}

ListThemesResponse represents the response from GET /themes

type LoginPollRequest

type LoginPollRequest struct {
	DeviceCode string `json:"device_code"`
}

LoginPollRequest represents the request body for POST /login/poll

type LoginPollResponse

type LoginPollResponse struct {
	Error       *AppErrorDetail `json:"error,omitempty"`
	AccessToken string          `json:"access_token,omitempty"`
	TokenType   string          `json:"token_type,omitempty"`
	ExpiresIn   int             `json:"expires_in,omitempty"`
}

LoginPollResponse represents the response from POST /login/poll

type LoginStartResponse

type LoginStartResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	DeviceCode      string          `json:"device_code,omitempty"`
	UserCode        string          `json:"user_code,omitempty"`
	VerificationURI string          `json:"verification_uri,omitempty"`
	ExpiresIn       int             `json:"expires_in,omitempty"`
	Interval        int             `json:"interval,omitempty"`
}

LoginStartResponse represents the response from POST /login/start

type Organization

type Organization struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Organization represents an organization from the API

type OrganizationsResponse

type OrganizationsResponse struct {
	Error         *AppErrorDetail `json:"error,omitempty"`
	Organizations []Organization  `json:"organizations,omitempty"`
}

OrganizationsResponse represents the response from GET /organizations

type ResourceItem added in v0.1.1

type ResourceItem struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

ResourceItem represents a single resource

type SaveApplicationResourcesRequest added in v0.1.18

type SaveApplicationResourcesRequest struct {
	OrganizationID string   `json:"organizationId"`
	ApplicationID  string   `json:"applicationId"`
	ResourceIDs    []string `json:"resourceIds"`
}

SaveApplicationResourcesRequest represents the request body for POST /application-resources

type SaveApplicationResourcesResponse added in v0.1.18

type SaveApplicationResourcesResponse struct {
	Error   *AppErrorDetail `json:"error,omitempty"`
	Success bool            `json:"success,omitempty"`
}

SaveApplicationResourcesResponse represents the response from POST /application-resources

type SetEnvironmentChoiceRequest added in v0.2.28

type SetEnvironmentChoiceRequest struct {
	EnvironmentID string `json:"environmentId"`
}

SetEnvironmentChoiceRequest represents the request body for POST /application/:applicationId/environment

type SetEnvironmentChoiceResponse added in v0.2.28

type SetEnvironmentChoiceResponse struct {
	Error           *AppErrorDetail `json:"error,omitempty"`
	EnvironmentID   string          `json:"environmentId,omitempty"`
	EnvironmentName string          `json:"environmentName,omitempty"`
}

SetEnvironmentChoiceResponse represents the response from POST /application/:applicationId/environment

type ThemeConfig added in v0.2.40

type ThemeConfig struct {
	BaseColor   interface{} `json:"baseColor"`
	AccentTheme interface{} `json:"accentTheme"`
	Font        string      `json:"font"`
	Radius      string      `json:"radius"`
	Elevation   string      `json:"elevation,omitempty"`
}

ThemeConfig represents the theme configuration

type ThemeDisplayColors added in v0.2.40

type ThemeDisplayColors struct {
	BaseColorHex   *string `json:"baseColorHex,omitempty"`
	AccentColorHex *string `json:"accentColorHex,omitempty"`
}

ThemeDisplayColors contains resolved hex colors for terminal rendering.

type ThemeItem added in v0.2.40

type ThemeItem struct {
	ID            string              `json:"id"`
	Name          string              `json:"name"`
	IsDefault     bool                `json:"isDefault"`
	Config        ThemeConfig         `json:"config"`
	DisplayColors *ThemeDisplayColors `json:"displayColors,omitempty"`
}

ThemeItem represents a single theme

type VerifyTokenResponse

type VerifyTokenResponse struct {
	Error  *AppErrorDetail `json:"error,omitempty"`
	Active bool            `json:"active,omitempty"`
	UserID string          `json:"user_id,omitempty"`
	Email  string          `json:"email,omitempty"`
	Exp    int64           `json:"exp,omitempty"`
}

VerifyTokenResponse represents the response from GET /verify

type VersionCheckRequest added in v0.1.11

type VersionCheckRequest struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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