platform

package
v0.0.0-...-3ab48d0 Latest Latest
Warning

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

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

Documentation

Overview

Package platform contains the hosted WhoDB client used by CLI commands.

Index

Constants

View Source
const (
	// DefaultHost is the hosted WhoDB platform URL used when no host is provided.
	DefaultHost = "https://app.whodb.com"
)

Variables

This section is empty.

Functions

func IsInvalidGrant

func IsInvalidGrant(err error) bool

IsInvalidGrant reports whether an auth failure means the refresh token is no longer usable.

func Logout

func Logout(ctx context.Context, host, accessToken string) error

Logout revokes all active sessions for the authenticated platform user.

func NormalizeHost

func NormalizeHost(raw string) (string, error)

NormalizeHost canonicalizes hosted WhoDB URLs for config and requests.

func ResolveAuthHost

func ResolveAuthHost(ctx context.Context, host string) (string, error)

ResolveAuthHost returns the Mothergate base URL advertised by the WhoDB host.

Types

type AuthConfig

type AuthConfig struct {
	MothergateURL string `json:"mothergateUrl"`
}

AuthConfig is the public auth configuration advertised by a WhoDB platform host.

type AuthHTTPError

type AuthHTTPError struct {
	StatusCode int
	Status     string
	Code       string
	Message    string
}

AuthHTTPError describes a failed Mothergate auth endpoint response.

func (*AuthHTTPError) Error

func (e *AuthHTTPError) Error() string

type Client

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

Client sends authenticated requests to a hosted WhoDB platform endpoint.

func NewClient

func NewClient(host, accessToken string) (*Client, error)

NewClient creates a hosted WhoDB platform client.

func (*Client) CreateSource

func (c *Client) CreateSource(ctx context.Context, input CreateSourceInput) (*Source, error)

CreateSource creates a hosted source in one project.

func (*Client) DeleteSource

func (c *Client) DeleteSource(ctx context.Context, projectID, sourceID string) error

DeleteSource deletes a hosted source from one project.

func (*Client) Host

func (c *Client) Host() string

Host returns the canonical hosted WhoDB platform URL.

func (*Client) Me

func (c *Client) Me(ctx context.Context) (*User, error)

Me returns the authenticated platform user.

func (*Client) Organizations

func (c *Client) Organizations(ctx context.Context) ([]Organization, error)

Organizations returns organizations visible to the authenticated user.

func (*Client) ProjectSources

func (c *Client) ProjectSources(ctx context.Context, projectID string) ([]Source, error)

ProjectSources returns sources visible to the user in one project.

func (*Client) Projects

func (c *Client) Projects(ctx context.Context, orgID string) ([]Project, error)

Projects returns projects visible in one organization.

func (*Client) SourceColumns

func (c *Client) SourceColumns(ctx context.Context, projectID, sourceID string, ref SourceObjectRefInput) ([]Column, error)

SourceColumns returns columns for one hosted source object.

func (*Client) SourceObjects

func (c *Client) SourceObjects(ctx context.Context, projectID, sourceID string, parent *SourceObjectRefInput, kinds []SourceObjectKind, pageSize, pageOffset int) ([]SourceObject, error)

SourceObjects returns browseable objects for one hosted source.

func (*Client) SourceRows

func (c *Client) SourceRows(ctx context.Context, projectID, sourceID string, ref SourceObjectRefInput, pageSize, pageOffset int) (*RowsResult, error)

SourceRows returns rows for one hosted source object.

func (*Client) SourceTypes

func (c *Client) SourceTypes(ctx context.Context) ([]SourceType, error)

SourceTypes returns source types available on the hosted platform.

func (*Client) SwitchOrganization

func (c *Client) SwitchOrganization(ctx context.Context, orgID string) (*Organization, error)

SwitchOrganization updates the user's active organization on the hosted platform.

type Column

type Column struct {
	Type             string `json:"type"`
	Name             string `json:"name"`
	MetadataFidelity string `json:"metadataFidelity"`
	IsPrimary        bool   `json:"isPrimary"`
	IsForeignKey     bool   `json:"isForeignKey"`
	ReferencedTable  string `json:"referencedTable,omitempty"`
	ReferencedColumn string `json:"referencedColumn,omitempty"`
	Length           *int   `json:"length,omitempty"`
	Precision        *int   `json:"precision,omitempty"`
	Scale            *int   `json:"scale,omitempty"`
}

Column describes a column returned by a hosted source.

type CreateSourceInput

type CreateSourceInput struct {
	ProjectID    string
	Name         string
	DatabaseType string
	Hostname     string
	Port         string
	Username     string
	Password     string
	Database     string
	Advanced     map[string]string
}

CreateSourceInput describes a hosted WhoDB source to create in one project.

type LoginOptions

type LoginOptions struct {
	Host        string
	OpenBrowser bool
	PrintURL    func(string)
	Timeout     time.Duration
}

LoginOptions configures the browser PKCE login flow.

type Organization

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

Organization is a WhoDB platform organization visible to the user.

type Project

type Project struct {
	ID          string `json:"id"`
	OrgID       string `json:"orgId"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
}

Project is a WhoDB platform project visible to the user.

type Record

type Record struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Record is a key-value metadata entry returned by WhoDB.

type RowsResult

type RowsResult struct {
	Columns       []Column   `json:"columns"`
	Rows          [][]string `json:"rows"`
	DisableUpdate bool       `json:"disableUpdate"`
	TotalCount    int        `json:"totalCount"`
}

RowsResult contains tabular rows returned by a hosted source.

type Source

type Source struct {
	ID           string `json:"id"`
	ProjectID    string `json:"projectId"`
	Name         string `json:"name"`
	DatabaseType string `json:"databaseType"`
	CreatedBy    string `json:"createdBy"`
	CreatedAt    string `json:"createdAt"`
}

Source is a hosted WhoDB project source visible to the authenticated user.

type SourceConnectionField

type SourceConnectionField struct {
	Key             string  `json:"key"`
	Kind            string  `json:"kind"`
	Section         string  `json:"section"`
	Required        bool    `json:"required"`
	LabelKey        string  `json:"labelKey"`
	PlaceholderKey  *string `json:"placeholderKey,omitempty"`
	DefaultValue    *string `json:"defaultValue,omitempty"`
	SupportsOptions bool    `json:"supportsOptions"`
}

SourceConnectionField describes one source credential/configuration field.

type SourceObject

type SourceObject struct {
	Ref         SourceObjectRef  `json:"ref"`
	Kind        SourceObjectKind `json:"kind"`
	Name        string           `json:"name"`
	Path        []string         `json:"path"`
	HasChildren bool             `json:"hasChildren"`
	Actions     []string         `json:"actions"`
	Metadata    []Record         `json:"metadata"`
}

SourceObject is a browsable object returned by a hosted source.

type SourceObjectKind

type SourceObjectKind string

SourceObjectKind identifies a source hierarchy object kind.

type SourceObjectRef

type SourceObjectRef struct {
	Kind    SourceObjectKind `json:"kind"`
	Locator string           `json:"locator"`
	Path    []string         `json:"path"`
}

SourceObjectRef identifies one object inside a source hierarchy.

type SourceObjectRefInput

type SourceObjectRefInput struct {
	Kind    SourceObjectKind
	Locator string
	Path    []string
}

SourceObjectRefInput identifies one source object in GraphQL variables.

type SourceType

type SourceType struct {
	ID               string                  `json:"id"`
	Label            string                  `json:"label"`
	Connector        string                  `json:"connector"`
	Category         string                  `json:"category"`
	ConnectionFields []SourceConnectionField `json:"connectionFields"`
}

SourceType describes one hosted WhoDB source type available for creation.

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token,omitempty"`
	IDToken      string `json:"id_token,omitempty"`
	ExpiresIn    int    `json:"expires_in,omitempty"`
}

TokenResponse is returned by Mothergate auth exchange and refresh endpoints.

func ExchangeCode

func ExchangeCode(ctx context.Context, authHost, code, redirectURI, verifier string) (*TokenResponse, error)

ExchangeCode exchanges a PKCE authorization code for platform tokens.

func Login

func Login(ctx context.Context, opts LoginOptions) (*TokenResponse, error)

Login runs the browser-based PKCE flow and returns platform tokens.

func RefreshToken

func RefreshToken(ctx context.Context, host, refreshToken string) (*TokenResponse, error)

RefreshToken exchanges a refresh token for new platform tokens.

type User

type User struct {
	ID          string `json:"id"`
	Email       string `json:"email"`
	DisplayName string `json:"displayName"`
	OrgID       string `json:"orgId"`
}

User is the platform identity returned by WhoDB.

Jump to

Keyboard shortcuts

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