Documentation
¶
Index ¶
- func GeneratePKCEPair() (verifier, challenge string, err error)
- func ParseUID(raw string) (int64, error)
- func RandomURLToken(size int) (string, error)
- func ResolveRefreshToken(store auth.AuthStore, requestedUserID int64, requestedToken string, ...) (string, error)
- type AccountAddRequest
- type AccountCheckRequest
- type AccountListResult
- type AccountResult
- type AccountService
- func (s AccountService) Add(ctx context.Context, req AccountAddRequest) (AccountResult, error)
- func (s AccountService) Check(ctx context.Context, userID int64) (AccountResult, error)
- func (s AccountService) CheckWithRequest(ctx context.Context, req AccountCheckRequest) (AccountResult, error)
- func (s AccountService) List() (AccountListResult, error)
- func (s AccountService) Remove(userID int64) (AccountResult, int64, error)
- func (s AccountService) Use(userID int64) (int64, error)
- type ArtworkClient
- type ArtworkService
- func (s ArtworkService) Detail(ctx context.Context, clientReq ClientRequest, id int64) (*pixiv.IllustDetail, bool, error)
- func (s ArtworkService) Ranking(ctx context.Context, req RankingRequest) (*pixiv.IllustList, bool, error)
- func (s ArtworkService) Recommended(ctx context.Context, req RecommendedRequest) (*pixiv.IllustList, bool, error)
- func (s ArtworkService) Search(ctx context.Context, req SearchRequest) (*pixiv.IllustList, bool, error)
- type AuthRepository
- type AuthenticatedPixivClient
- type AuthenticatedPixivFactory
- type ClientBundle
- type ClientRequest
- type ClientResolver
- type ClientSession
- type ConfigMutationResult
- type ConfigService
- type ConfigStore
- type DownloadClient
- type DownloadFactory
- type DownloadService
- type Downloader
- type LoginCompleteRequest
- type LoginService
- type LoginStart
- type OAuthClientFactory
- type OAuthExchanger
- type OAuthToken
- type PixivClientFactory
- type RankingRequest
- type RecommendedRequest
- type SDKClient
- type SDKClientFactory
- type SDKClientRequest
- type SDKService
- func (s SDKService) Client(req SDKClientRequest) (SDKClient, error)
- func (s SDKService) CurrentUserID(ctx context.Context, req SDKClientRequest) (SDKClient, int64, error)
- func (s SDKService) JSONOut(override *bool) (bool, error)
- func (s SDKService) OpenOperation(ctx context.Context, req SDKClientRequest) (SDKClient, error)
- type SearchRequest
- type Services
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratePKCEPair ¶
func RandomURLToken ¶
Types ¶
type AccountAddRequest ¶
type AccountCheckRequest ¶
type AccountListResult ¶
type AccountListResult struct {
DefaultUserID int64
Accounts []AccountResult
}
type AccountResult ¶
type AccountService ¶
type AccountService struct {
Auth AuthRepository
LoadRuntime func() (config.RuntimeConfig, error)
RefreshTokenEnv func() string
NewClient AuthenticatedPixivFactory
}
func (AccountService) Add ¶
func (s AccountService) Add(ctx context.Context, req AccountAddRequest) (AccountResult, error)
func (AccountService) Check ¶
func (s AccountService) Check(ctx context.Context, userID int64) (AccountResult, error)
func (AccountService) CheckWithRequest ¶
func (s AccountService) CheckWithRequest(ctx context.Context, req AccountCheckRequest) (AccountResult, error)
func (AccountService) List ¶
func (s AccountService) List() (AccountListResult, error)
func (AccountService) Remove ¶
func (s AccountService) Remove(userID int64) (AccountResult, int64, error)
type ArtworkClient ¶
type ArtworkClient interface {
SearchIllust(context.Context, string, string, string, string, int) (*pixiv.IllustList, error)
IllustDetail(context.Context, int64) (*pixiv.IllustDetail, error)
IllustRanking(context.Context, string, string, int) (*pixiv.IllustList, error)
IllustRecommended(context.Context, int) (*pixiv.IllustList, error)
}
type ArtworkService ¶
type ArtworkService struct {
Resolver ClientResolver
}
func (ArtworkService) Detail ¶
func (s ArtworkService) Detail(ctx context.Context, clientReq ClientRequest, id int64) (*pixiv.IllustDetail, bool, error)
func (ArtworkService) Ranking ¶
func (s ArtworkService) Ranking(ctx context.Context, req RankingRequest) (*pixiv.IllustList, bool, error)
func (ArtworkService) Recommended ¶
func (s ArtworkService) Recommended(ctx context.Context, req RecommendedRequest) (*pixiv.IllustList, bool, error)
func (ArtworkService) Search ¶
func (s ArtworkService) Search(ctx context.Context, req SearchRequest) (*pixiv.IllustList, bool, error)
type AuthRepository ¶
type AuthenticatedPixivFactory ¶
type AuthenticatedPixivFactory func(config.RuntimeConfig) (AuthenticatedPixivClient, error)
type ClientBundle ¶
type ClientBundle struct {
Auth AuthenticatedPixivClient
Artwork ArtworkClient
Download DownloadClient
}
type ClientRequest ¶
type ClientResolver ¶
type ClientResolver struct {
Auth AuthRepository
LoadRuntime func() (config.RuntimeConfig, error)
RefreshTokenEnv func() string
NewClient PixivClientFactory
}
func (ClientResolver) Resolve ¶
func (r ClientResolver) Resolve(ctx context.Context, req ClientRequest) (ClientSession, error)
type ClientSession ¶
type ClientSession struct {
Client ClientBundle
Config config.RuntimeConfig
JSONOut bool
}
type ConfigMutationResult ¶
type ConfigService ¶
type ConfigService struct {
Store ConfigStore
}
func (ConfigService) Get ¶
func (s ConfigService) Get(alias string) (config.SettingValue, error)
func (ConfigService) Path ¶
func (s ConfigService) Path() (string, error)
func (ConfigService) Set ¶
func (s ConfigService) Set(alias, raw string) (ConfigMutationResult, error)
func (ConfigService) Unset ¶
func (s ConfigService) Unset(alias string) (ConfigMutationResult, error)
type ConfigStore ¶
type ConfigStore interface {
Path() (string, error)
Get(string) (config.SettingValue, error)
Set(string, string) (ConfigMutationResult, error)
Unset(string) (ConfigMutationResult, error)
}
type DownloadClient ¶
type DownloadClient interface {
download.PixivClient
}
type DownloadFactory ¶
type DownloadFactory func(DownloadClient, config.RuntimeConfig) Downloader
type DownloadService ¶
type DownloadService struct {
Resolver ClientResolver
NewDownloader DownloadFactory
}
func (DownloadService) Download ¶
func (s DownloadService) Download(ctx context.Context, clientReq ClientRequest, ids []int64) ([]download.DownloadedArtwork, bool, error)
type Downloader ¶
type LoginCompleteRequest ¶
type LoginService ¶
type LoginService struct {
Auth AuthRepository
LoadRuntime func() (config.RuntimeConfig, error)
NewOAuth OAuthClientFactory
}
func (LoginService) Complete ¶
func (s LoginService) Complete(ctx context.Context, req LoginCompleteRequest) (AccountResult, error)
func (LoginService) Start ¶
func (s LoginService) Start() (LoginStart, error)
type LoginStart ¶
type OAuthClientFactory ¶
type OAuthClientFactory func(config.RuntimeConfig, string) (OAuthExchanger, error)
type OAuthExchanger ¶
type OAuthToken ¶
type PixivClientFactory ¶
type PixivClientFactory func(config.RuntimeConfig) (ClientBundle, error)
type RankingRequest ¶
type RankingRequest struct {
Client ClientRequest
Mode string
Date string
Offset int
}
type RecommendedRequest ¶
type RecommendedRequest struct {
Client ClientRequest
Offset int
}
type SDKClient ¶ added in v0.2.0
type SDKClient interface {
CurrentUserID(context.Context) (int64, error)
SearchIllust(context.Context, sdk.SearchIllustRequest) (*sdk.IllustListResult, error)
IllustDetail(context.Context, int64) (*sdk.IllustDetail, error)
IllustRanking(context.Context, sdk.IllustRankingRequest) (*sdk.IllustListResult, error)
IllustRecommended(context.Context, sdk.IllustRecommendedRequest) (*sdk.IllustListResult, error)
UserArtworks(context.Context, sdk.UserArtworksRequest) (*sdk.IllustListResult, error)
UserBookmarks(context.Context, sdk.UserBookmarksRequest) (*sdk.IllustListResult, error)
UserFollowing(context.Context, sdk.UserFollowingRequest) (*sdk.UserListResult, error)
AddBookmark(context.Context, sdk.AddBookmarkRequest) error
RemoveBookmark(context.Context, sdk.RemoveBookmarkRequest) error
FollowUser(context.Context, sdk.FollowUserRequest) error
UnfollowUser(context.Context, sdk.UnfollowUserRequest) error
}
SDKClient 是 CLI 数据命令所需的窄 facade。它刻意不复用或导出旧 Source 的大接口, 让 CLI 通过公共 SDK 获得 cursor、错误和路由语义。
type SDKClientFactory ¶ added in v0.2.0
type SDKClientFactory func(SDKClientRequest) (SDKClient, error)
type SDKClientRequest ¶ added in v0.2.0
type SDKClientRequest struct {
UserID int64
RefreshToken string
HTTPSProxyOverride *string
// AuthFilePath 允许 MCP 等长驻调用方把 OAuth rotation 固定到同一个受保护 store。
// 为空时继续使用 OpenDefault 的标准路径。
AuthFilePath string
}
SDKClientRequest 只携带 CLI 显式覆写;其余 config/auth 优先级由 OpenDefault 在每次 SDK 操作快照中处理。
type SDKService ¶ added in v0.2.0
type SDKService struct {
NewClient SDKClientFactory
LoadRuntime func() (config.RuntimeConfig, error)
}
func (SDKService) Client ¶ added in v0.2.0
func (s SDKService) Client(req SDKClientRequest) (SDKClient, error)
func (SDKService) CurrentUserID ¶ added in v0.2.0
func (s SDKService) CurrentUserID(ctx context.Context, req SDKClientRequest) (SDKClient, int64, error)
CurrentUserID 通过 SDK OAuth 快照获取真实身份。这样 --refresh-token 和环境 token 都不会被本地默认账号误替代。
func (SDKService) JSONOut ¶ added in v0.2.0
func (s SDKService) JSONOut(override *bool) (bool, error)
JSONOut 与既有 CLI config 语义一致:命令显式 --json 覆盖 runtime 配置。
func (SDKService) OpenOperation ¶ added in v0.2.0
func (s SDKService) OpenOperation(ctx context.Context, req SDKClientRequest) (SDKClient, error)
OpenOperation 让一个 CLI 命令的 self 身份解析和所有 cursor 页面共享同一个 OpenDefault 快照,避免 OAuth rotation 在命令进行中使旧 refresh token 失效。
type SearchRequest ¶
type Services ¶
type Services struct {
Account AccountService
Config ConfigService
Artwork ArtworkService
Download DownloadService
Login LoginService
SDK SDKService
}
Click to show internal directories.
Click to hide internal directories.