common

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CanvasYAMLRepositoryPath  = "canvas.yaml"
	ConsoleYAMLRepositoryPath = "console.yaml"
)

Variables

This section is empty.

Functions

func BuildAppURL added in v0.25.0

func BuildAppURL(ctx core.CommandContext, orgID, canvasID string) string

BuildCanvasURL composes the canonical web URL for an app. Returns "" when the context, base URL, organization id, or app id is missing so callers can omit the URL output without erroring.

orgID and canvasID should come from the API response (canvas metadata) rather than the local CLI context, so the URL stays correct even if the active context drifts.

func CommitRepositoryFiles added in v0.25.1

func CommitRepositoryFiles(
	ctx core.CommandContext,
	canvasID string,
	versionID string,
	expectedHeadSHA string,
	message string,
	operations []openapi_client.CanvasesCanvasRepositoryFileOperation,
	autoLayout *openapi_client.CanvasesCanvasAutoLayout,
	includeAutoLayout bool,
) (*openapi_client.CanvasesCommitCanvasRepositoryFilesResponse, error)

func CommitRepositorySpecFile added in v0.25.1

func CommitRepositorySpecFile(
	ctx core.CommandContext,
	canvasID string,
	versionID string,
	path string,
	content []byte,
	message string,
	autoLayout *openapi_client.CanvasesCanvasAutoLayout,
	includeAutoLayout bool,
) error

func DescribeAppVersionByID

func DescribeAppVersionByID(
	ctx core.CommandContext,
	appID string,
	versionID string,
) (openapi_client.CanvasesCanvasVersion, error)

DescribeAppVersionByID loads a specific app version and errors when the response does not include one.

func EnsureCurrentUserDraftVersionID

func EnsureCurrentUserDraftVersionID(ctx core.CommandContext, appID string) (string, error)

EnsureCurrentUserDraftVersionID returns the version id of a draft branch owned by the current user, creating one if it does not yet exist.

func FetchRepositoryFile added in v0.25.1

func FetchRepositoryFile(ctx core.CommandContext, canvasID, path, versionID string) ([]byte, error)

func FindAppID

func FindAppID(ctx core.CommandContext, client *openapi_client.APIClient, nameOrID string) (string, error)

FindAppID returns the app id for the given name or UUID. If `nameOrID` parses as a UUID, it is returned unchanged. Otherwise the CLI looks up apps by name and requires exactly one match.

func FindCurrentUserDraftVersionID

func FindCurrentUserDraftVersionID(ctx core.CommandContext, appID string) (string, error)

FindCurrentUserDraftVersionID returns the version id of the current user's first draft branch, or an empty string if none exists. It does not create a draft. The API scopes drafts to the authenticated user, so listing already returns only their drafts.

func ListDraftVersions added in v0.26.0

func ListDraftVersions(ctx core.CommandContext, appID string) ([]openapi_client.CanvasesCanvasVersion, error)

ListDraftVersions returns the current user's draft versions for an app. The API scopes drafts to the authenticated user, so no client-side owner filtering is required.

func ResolveAppNameOrIDArg

func ResolveAppNameOrIDArg(ctx core.CommandContext, arg string) (string, error)

ResolveAppNameOrIDArg returns the app id for `arg`, falling back to the active app configured for the user when `arg` is empty. It returns a friendly error when neither is available so callers can surface the same message across commands.

func ResolveDraftVersionID added in v0.26.0

func ResolveDraftVersionID(ctx core.CommandContext, appID, draftID string) (string, error)

ResolveDraftVersionID validates that draftID refers to a draft version owned by the current user and returns it. It errors when the id is empty, points to a non-draft version, or is owned by another user.

Types

This section is empty.

Jump to

Keyboard shortcuts

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