resolver

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 8 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 resolver owns the command-scoped semantic resolution of Pixiv targets. It does not open a client or perform network I/O except through an explicitly supplied bare-ID probe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BareIDPolicy

type BareIDPolicy struct {
	Candidates []string
	Probe      func(context.Context, int64, TypeSpec) ProbeOutcome
}

BareIDPolicy enables a controlled probe only for a contract that explicitly freezes its candidate namespaces. A probe must report whether each candidate was found, absent, forbidden, or unavailable; the resolver never guesses a type from an unclassified error.

type Contract

type Contract struct {
	Operation   string
	DefaultType string
	Types       []TypeSpec
	URLKinds    map[pixiv.ReferenceKind]URLTypeRelation
	BareID      *BareIDPolicy
}

Contract contains the command-specific input and conflict rules. It is a policy value rather than a universal entity union: every command declares only the type values, URL kinds, and optional probe candidates it supports.

type Input

type Input struct {
	Value  string
	Record *recordpkg.Record
	Type   string
}

Input is the value accepted by a command resolver. Exactly one of Value and Record must be supplied. Type is the command's already-parsed type selector; an empty Type uses Contract.DefaultType or URL inference.

type ProbeOutcome

type ProbeOutcome struct {
	Status ProbeStatus
	Err    error
}

ProbeOutcome is returned by BareIDPolicy.Probe. Err should be a classified SDK error for forbidden or network outcomes; the status remains authoritative and prevents the resolver from silently trying another namespace.

type ProbeStatus

type ProbeStatus string

ProbeStatus is the outcome class returned by a controlled bare-ID probe.

const (
	ProbeFound         ProbeStatus = "found"
	ProbeNotFound      ProbeStatus = "not_found"
	ProbeForbidden     ProbeStatus = "forbidden"
	ProbeNetworkError  ProbeStatus = "network_error"
	ProbeIndeterminate ProbeStatus = "indeterminate"
)

type ResultKind

type ResultKind string

ResultKind identifies the content returned or mutated by a command.

const (
	ResultKindArtwork ResultKind = "artwork"
	ResultKindNovel   ResultKind = "novel"
	ResultKindUser    ResultKind = "user"
	ResultKindSeries  ResultKind = "series"
	ResultKindComment ResultKind = "comment"
	ResultKindTag     ResultKind = "tag"
)

type Source

type Source string

Source records which local input path produced a resolved target.

const (
	SourceID          Source = "id"
	SourceURL         Source = "url"
	SourceRecord      Source = "record"
	SourceBareIDProbe Source = "bare_id_probe"
)

type Subtype

type Subtype string

Subtype is an endpoint-specific content subtype. It is deliberately separate from both the input target namespace and the result kind.

const (
	SubtypeIllust Subtype = "illust"
	SubtypeManga  Subtype = "manga"
	SubtypeUgoira Subtype = "ugoira"
)

type Target

type Target struct {
	ID            int64
	TargetKind    TargetKind
	ResultKind    ResultKind
	Subtype       Subtype
	ReferenceKind pixiv.ReferenceKind
	OwnerUserID   int64
	All           bool
	Source        Source
}

Target is the resolved identity consumed by a command owner. TargetKind is the input namespace, ResultKind is the selected operation content, and ReferenceKind preserves URL-specific distinctions such as user bookmarks or artwork series. All is a selector and is never represented as a Subtype.

func Resolve

func Resolve(ctx context.Context, input Input, contract Contract) (Target, error)

Resolve applies one command contract to either a text value or a structured canonical record. It performs no network I/O unless the contract supplies a controlled bare-ID probe for an otherwise untyped numeric value.

type TargetKind

type TargetKind string

TargetKind identifies the input namespace selected by a command contract. URL-specific identities such as user_bookmarks and artwork_series remain in Target.ReferenceKind rather than being collapsed into a new global kind.

const (
	TargetKindArtwork TargetKind = "artwork"
	TargetKindNovel   TargetKind = "novel"
	TargetKindUser    TargetKind = "user"
	TargetKindSeries  TargetKind = "series"
	TargetKindComment TargetKind = "comment"
)

type TypeSpec

type TypeSpec struct {
	Name              string
	ResultKind        ResultKind
	Subtype           Subtype
	BareReferenceKind pixiv.ReferenceKind
	// BareTargetKind represents an input identity that has no supported Pixiv
	// page reference, such as a comment ID. When set, it must agree with the
	// target kind derived from BareReferenceKind, if one is also provided.
	BareTargetKind TargetKind
	All            bool
}

TypeSpec describes one type value that a particular command contract accepts. BareReferenceKind is the namespace used when the same type is supplied with a numeric ID. Bookmark list, for example, maps artwork and novel result selectors to a user bare-ID namespace.

type URLTypeRelation

type URLTypeRelation string

URLTypeRelation controls whether a parsed URL's declared namespace must agree with the command's selected result type.

const (
	// URLTypeMustMatchResult is used by detail, series, and work mutations.
	URLTypeMustMatchResult URLTypeRelation = "must_match_result"
	// URLTypeIndependent allows an owner URL to select a different result kind,
	// such as a user URL with bookmark --type novel.
	URLTypeIndependent URLTypeRelation = "independent"
)

Jump to

Keyboard shortcuts

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