Documentation
¶
Index ¶
- Constants
- Variables
- type ApiClient
- func (c *ApiClient) CreateZoteroExport(target ZoteroExportTarget) (string, error)
- func (c *ApiClient) DeleteZoteroExport(exportID string) error
- func (c *ApiClient) DownloadPackage(namespace, name, version string) error
- func (c *ApiClient) FetchDependencies(namespace, name, version string) ([]DependencyInfo, error)
- func (c *ApiClient) FetchLatestZoteroCollections(exportID string, writer io.Writer) error
- func (c *ApiClient) FetchPackage(namespace, name string) (*PackageResponse, error)
- func (c *ApiClient) GetNamespacePackages(namespace string) ([]PackageResponse, error)
- func (c *ApiClient) GetPackageIndex() (string, error)
- func (c *ApiClient) GetUserProfile() (*UserProfile, error)
- func (c *ApiClient) QueryZoteroLibraries() ([]ZoteroLibrary, error)
- func (c *ApiClient) SearchPackages(query, namespace string, kind string, category string, sort string, limit int) (*SearchResponse, error)
- func (c *ApiClient) UploadPackage(packagePath, namespace string) (*UploadResponse, error)
- type ApiKeyProvider
- type DependenciesResponse
- type DependencyInfo
- type HttpClient
- type PackageResponse
- type PackageVersionInfo
- type RequestError
- type SearchResponse
- type SearchResult
- type UploadResponse
- type UserNamespace
- type UserProfile
- type ZoteroCollection
- type ZoteroExportTarget
- type ZoteroGroup
- type ZoteroLibrary
Constants ¶
const (
TpixServer = "https://tpix.typstify.com"
)
Variables ¶
var (
TpixClientUserAgent = fmt.Sprintf("tpix-client/%s", version.Version)
)
Functions ¶
This section is empty.
Types ¶
type ApiClient ¶ added in v0.10.0
type ApiClient struct {
// contains filtered or unexported fields
}
ApiClient is the API wrapper to access TPIX rest APIs.
func NewApiClient ¶ added in v0.10.0
func NewApiClient(client *HttpClient, store storage.PackageStore) *ApiClient
func (*ApiClient) CreateZoteroExport ¶ added in v0.10.0
func (c *ApiClient) 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 (*ApiClient) DeleteZoteroExport ¶ added in v0.10.0
func (*ApiClient) DownloadPackage ¶ added in v0.10.0
DownloadPackage downloads a package, and save to the package store.
func (*ApiClient) FetchDependencies ¶ added in v0.10.0
func (c *ApiClient) FetchDependencies(namespace, name, version string) ([]DependencyInfo, error)
FetchDependencies fetches the dependencies for a specific package version.
func (*ApiClient) FetchLatestZoteroCollections ¶ added in v0.10.0
FetchLatestZoteroCollections fetches the latest version of Zotero items from TPIX server.
func (*ApiClient) FetchPackage ¶ added in v0.10.0
func (c *ApiClient) FetchPackage(namespace, name string) (*PackageResponse, error)
FetchPackage fetches package details from the TPIX server.
func (*ApiClient) GetNamespacePackages ¶ added in v0.13.0
func (c *ApiClient) GetNamespacePackages(namespace string) ([]PackageResponse, error)
func (*ApiClient) GetPackageIndex ¶ added in v0.10.0
func (*ApiClient) GetUserProfile ¶ added in v0.10.0
func (c *ApiClient) GetUserProfile() (*UserProfile, error)
func (*ApiClient) QueryZoteroLibraries ¶ added in v0.10.0
func (c *ApiClient) 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.
func (*ApiClient) SearchPackages ¶ added in v0.10.0
func (c *ApiClient) 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)
func (*ApiClient) UploadPackage ¶ added in v0.10.0
func (c *ApiClient) UploadPackage(packagePath, namespace string) (*UploadResponse, error)
UploadPackage uploads a package to the TPIX server.
type ApiKeyProvider ¶ added in v0.11.0
type ApiKeyProvider interface {
Get() string
}
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
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 ApiKeyProvider) *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. The request is retried when
func (*HttpClient) SetBaseURL ¶ added in v0.12.0
func (c *HttpClient) SetBaseURL(baseURL string)
SetBaseURL overrides the server base URL. This is primarily useful in tests to point the client at an httptest.Server.
func (*HttpClient) SetHttpClient ¶ added in v0.12.0
func (c *HttpClient) SetHttpClient(client *http.Client)
SetHttpClient overrides the underlying HTTP client used to send requests.
func (*HttpClient) SetMaxRetry ¶ added in v0.10.0
func (c *HttpClient) SetMaxRetry(maxRetry int)
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"`
Authors []string `json:"authors"`
Keywords []string `json:"keywords"`
Categories []string `json:"categories"`
Disciplines []string `json:"disciplines"`
License string `json:"license"`
IsTemplate bool `json:"is_template"`
Thumbnail string `json:"thumbnail"`
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
type PackageVersionInfo ¶
type PackageVersionInfo struct {
Version string `json:"version"`
MinCompilerVer string `json:"minCompilerVer"`
SHA256 string `json:"sha256"`
PublishedAt time.Time `json:"published_at"`
}
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"`
}
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"`
Thumbnail string `json:"thumbnail"`
CreatedAt time.Time `json:"created_at"`
}
SearchResult represents a single search result
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.
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"`
}
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"`
}