Documentation
¶
Index ¶
- Constants
- func CreateZoteroExport(target ZoteroExportTarget) (string, error)
- func DeleteZoteroExport(exportID string) error
- func DownloadPackage(namespace, name, version string, cacheDir string) error
- func FetchLatestZoteroCollections(exportID string, writer io.Writer) error
- func Init(provider CredentialsProvider)
- type CredentialsProvider
- type DependenciesResponse
- type DependencyInfo
- type DeviceCodeResponse
- type ErrorResponse
- type HttpClient
- type PackageResponse
- type PackageVersionInfo
- type SearchResponse
- type SearchResult
- type TokenResponse
- type UploadResponse
- type UserNamespace
- type UserProfile
- type ZoteroCollection
- type ZoteroExportTarget
- type ZoteroGroup
- type ZoteroLibrary
Constants ¶
const ( TpixServer = "https://tpix.typstify.com" TpixClientUserAgent = "tpix-client/v1.0.0" )
Variables ¶
This section is empty.
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 DownloadPackage ¶
DownloadPackage downloads a package, extracts it to the cache directory, and optionally saves the archive to output path.
func FetchLatestZoteroCollections ¶ added in v0.6.0
FetchLatestZoteroCollections fetches the latest version of Zotero items from TPIX server.
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 ErrorResponse ¶
ErrorResponse represents a standard error response
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 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 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.