searchfilter

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0, BSD-3-Clause, CC-BY-4.0, + 2 more Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package searchfilter 定义 CLI/MCP 共用的搜索筛选 continuation 语义。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BookmarkContext

func BookmarkContext(min, max *int, strategy string) string

BookmarkContext 绑定实际采用的收藏筛选策略;nil 与显式零值语义不同。 调用方保留产品筛选,SDK 只绑定摘要,不把本地条件发送到 upstream。

func FilterContext

func FilterContext(rating, contentType string) (string, error)

FilterContext 生成只包含 canonical 本地语义的 opaque cursor context。 context 只参与 SDK cursor binding,不会被当作 upstream 请求参数。

Types

type ContentType

type ContentType string

ContentType 是 artwork 结果的本地 subtype/selector 语义。

const (
	ContentTypeAll             ContentType = "all"
	ContentTypeIllustAndUgoira ContentType = "illust-and-ugoira"
	ContentTypeIllust          ContentType = "illust"
	ContentTypeManga           ContentType = "manga"
	ContentTypeUgoira          ContentType = "ugoira"
)

ContentType 的 canonical 值。

func NormalizeContentType

func NormalizeContentType(value string) (ContentType, error)

NormalizeContentType 将 artwork subtype/selector 规范化为 canonical 值。 illustration 是既有 public artwork kind 的兼容别名,canonical 值为 illust。

type Filter

type Filter struct {
	Rating      Rating
	ContentType ContentType
}

Filter 保存已规范化的本地筛选条件。零值等价于没有筛选。 Rating 只用于 client-side matching,不能映射为 x_restrict 请求字段。

func NormalizeFilter

func NormalizeFilter(rating, contentType string) (Filter, error)

NormalizeFilter 将命令层输入归一化为共享 canonical 语义。 空值和显式 all 等价;illustration 是既有 public artwork kind 的兼容别名。

func (Filter) CursorContext

func (f Filter) CursorContext() string

CursorContext 返回当前本地筛选语义的稳定摘要,不暴露原始输入。

func (Filter) Matches

func (f Filter) Matches(xRestrict int, kind string) bool

Matches 按 DTO 中的 x_restrict 与 artwork kind 执行本地筛选。 x_restrict 的 0/1/2 分别对应 safe/r18/r18g;未知值只会在显式 rating 筛选时被排除,避免把未知上游值误判为已知安全级别。

type Rating

type Rating string

Rating 是产品层的本地 rating 语义。它不是 Pixiv App API 的请求参数。

const (
	RatingAll    Rating = "all"
	RatingSFW    Rating = "sfw"
	RatingR18    Rating = "r18"
	RatingR18G   Rating = "r18g"
	RatingMature Rating = "mature"
)

Rating 的 canonical 值。

func NormalizeRating

func NormalizeRating(value string) (Rating, error)

NormalizeRating 将 rating 输入规范化为本地 canonical 值。 该值只用于结果匹配和 cursor binding,不对应任何 upstream query 参数。

Jump to

Keyboard shortcuts

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