api

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TpixServer = "https://tpix.typstify.com"
)

Variables

View Source
var (
	TpixClientUserAgent = fmt.Sprintf("tpix-client/%s", version.Version)
)

Functions

func CreateZoteroExport added in v0.6.0

func CreateZoteroExport(target ZoteroExportTarget) (string, error)

CreateZoteroExport creates an export target on TPIX server. Requires a registered Zotero API key in the namespace or current user.

func DeleteZoteroExport added in v0.6.0

func DeleteZoteroExport(exportID string) error

func DownloadPackage

func DownloadPackage(namespace, name, version string, cacheDir string) error

DownloadPackage downloads a package, extracts it to the cache directory, and saves the archive to output path.

func FetchLatestZoteroCollections added in v0.6.0

func FetchLatestZoteroCollections(exportID string, writer io.Writer) error

FetchLatestZoteroCollections fetches the latest version of Zotero items from TPIX server.

func GetPackageIndex added in v0.9.0

func GetPackageIndex() (string, error)

func Init added in v0.6.0

func Init(provider CredentialsProvider)

Types

type CredentialsProvider added in v0.6.0

type CredentialsProvider interface {
	Load() (config.Credentials, error)
	Save(cred config.Credentials) error
}

type DependenciesResponse added in v0.5.0

type DependenciesResponse struct {
	Package      string           `json:"package"`
	Version      string           `json:"version"`
	Dependencies []DependencyInfo `json:"dependencies"`
}

DependenciesResponse represents the dependencies endpoint response

type DependencyInfo added in v0.5.0

type DependencyInfo struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
	Version   string `json:"version"`
}

DependencyInfo represents a single package dependency

func FetchDependencies added in v0.5.0

func FetchDependencies(namespace, name, version string) ([]DependencyInfo, error)

FetchDependencies fetches the dependencies for a specific package version.

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri"`
	ExpiresIn       int    `json:"expires_in"`
}

func StartDeviceLogin added in v0.6.1

func StartDeviceLogin() (*DeviceCodeResponse, error)

type HttpClient added in v0.6.0

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

func NewHttpClient added in v0.6.0

func NewHttpClient(provider CredentialsProvider) *HttpClient

func (*HttpClient) MakeRequest added in v0.6.0

func (c *HttpClient) MakeRequest(method, url string, body io.Reader, contentType string) (*http.Response, error)

MakeRequest creates an HTTP request with Bearer token. On 401 responses, it transparently attempts to refresh the access token and retries the request once.

type PackageResponse

type PackageResponse struct {
	ID              string               `json:"id"`
	Name            string               `json:"name"`
	Namespace       string               `json:"namespace"`
	SourceType      string               `json:"source_type"`
	ExternalURL     string               `json:"external_url"`
	Description     string               `json:"description"`
	HomepageURL     string               `json:"homepage_url"`
	RepositoryURL   string               `json:"repository_url"`
	License         string               `json:"license"`
	IsTemplate      bool                 `json:"is_template"`
	LastPublishedAt time.Time            `json:"last_published_at"` // latest published time
	CreatedAt       time.Time            `json:"created_at"`
	UpdatedAt       time.Time            `json:"updated_at"`
	Versions        []PackageVersionInfo `json:"versions"`
}

PackageResponse represents a package details response

func FetchPackage

func FetchPackage(namespace, name string) (*PackageResponse, error)

FetchPackage fetches package details from the TPIX server.

type PackageVersionInfo

type PackageVersionInfo struct {
	Version     string           `json:"version"`
	SHA256      string           `json:"sha256"`
	PublishedAt time.Time        `json:"published_at"`
	Meta        bundler.Manifest `json:"meta"`
}

PackageVersionInfo represents package version information

type RequestError added in v0.9.1

type RequestError struct {
	Code        int    `json:"-"`
	Message     string `json:"error"`
	Description string `json:"description"`
}

func (*RequestError) Error added in v0.9.1

func (e *RequestError) Error() string

type SearchResponse

type SearchResponse struct {
	Query   string         `json:"query"`
	Total   int            `json:"total"`
	Count   int            `json:"count"`
	Results []SearchResult `json:"results"`
}

func SearchPackages

func SearchPackages(query, namespace string, kind string, category string, sort string, limit int) (*SearchResponse, error)

SearchPackages fetches packages matching a query from the TPIX server. kind: "pkg", "template", or "all" sort: "name", "updated", or "popularity" (default)

type SearchResult

type SearchResult struct {
	Name          string    `json:"name"`
	Namespace     string    `json:"namespace"`
	Description   string    `json:"description"`
	LatestVersion string    `json:"latest_version"`
	PublishedAt   time.Time `json:"published_at"` // latest published time
	License       string    `json:"license"`
	IsTemplate    bool      `json:"is_template"`
	Authors       []string  `json:"authors"`
	Categories    []string  `json:"categories"`
	Disciplines   []string  `json:"disciplines"`
	CreatedAt     time.Time `json:"created_at"`
}

SearchResult represents a single search result

type TokenResponse

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

func PollForToken added in v0.6.1

func PollForToken(deviceCode string, hostname string) (*TokenResponse, bool, error)

PollForToken polls the server for the authorized token.

type UploadResponse

type UploadResponse struct {
	SHA256         string   `json:"sha256"`
	Namespace      string   `json:"namespace"`
	Package        string   `json:"package"`
	Version        string   `json:"version"`
	Size           int64    `json:"size"`
	ValidateReport []string `json:"report"`
}

UploadResponse represents an upload response. When the package validation does not pass, only ValidateReport is returned.

func UploadPackage

func UploadPackage(packagePath, namespace string) (*UploadResponse, error)

UploadPackage uploads a package to the TPIX server.

type UserNamespace added in v0.8.1

type UserNamespace struct {
	Name       string `json:"name"`
	Permission string `json:"permission"`
}

type UserProfile added in v0.8.1

type UserProfile struct {
	Email      string          `json:"email"`
	Username   string          `json:"username"`
	CreatedAt  time.Time       `json:"created_at"`
	Namespaces []UserNamespace `json:"namespaces"`
	Subscribed bool            `json:"subscribed"`
}

func GetUserProfile added in v0.8.1

func GetUserProfile() (*UserProfile, error)

type ZoteroCollection added in v0.6.0

type ZoteroCollection struct {
	Key              string `json:"key"`
	Version          int    `json:"version"`
	Name             string `json:"name"`
	ParentCollection string `json:"parentCollection"`
}

ZoteroCollection represents a Zotero collection

type ZoteroExportTarget added in v0.6.0

type ZoteroExportTarget struct {
	NamespaceID   string `json:"namespace_id"`
	Name          string `json:"name" binding:"required"`
	LibraryType   string `json:"library_type" binding:"required"`
	LibraryID     int64  `json:"library_id" binding:"required"`
	CollectionKey string `json:"collection_key"`
	Format        string `json:"format"`
}

type ZoteroGroup added in v0.6.0

type ZoteroGroup struct {
	ID          int    `json:"id"`
	Version     int    `json:"version"`
	Name        string `json:"name"`
	Owner       int    `json:"owner"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Url         string `json:"url"`
}

ZoteroGroup represents a Zotero group

type ZoteroLibrary added in v0.6.0

type ZoteroLibrary struct {
	Namespace   string             `json:"namespace"`
	NamespaceID string             `json:"namespace_id"`
	Scope       string             `json:"scope"` // "users"||"groups"
	Library     ZoteroGroup        `json:"library"`
	Collections []ZoteroCollection `json:"collections"`
}

func QueryZoteroLibraries added in v0.6.0

func QueryZoteroLibraries() ([]ZoteroLibrary, error)

QueryZoteroLibraries fetches zotero libraries the current user has access permission. This includes libraries granted in personal account, and libraries granted by the namespace owners.

Jump to

Keyboard shortcuts

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