Add Lua plugin host, built-in amazon plugin and dibs check.
Sandboxed gopher-lua with time, memory and call-stack limits from [sandbox], a goquery-backed doc API, price parsing, and the 'check', 'plugin test' and 'fixtures' commands. Sellers are first_party, fulfilled (shipped by the shop) or third_party, and items accept fulfilled by default; used-only offers are not available. Plugin tests run on real pages that 'dibs fixtures' fetches into an untracked directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f90ef18f90
commit
bb010356a0
28 files changed
+2096
-26
No files matched your search
@@ -16,7 +16,10 @@ import (
|
||||
const MinInterval = 60 * time.Second
|
||||
|
||||
const (
|
||||
// Seller policies for an item: sold by the shop itself; sold or at least
|
||||
// shipped by it (e.g. Fulfilled by Amazon); or anyone.
|
||||
SellerFirstParty = "first_party"
|
||||
SellerFulfilled = "fulfilled"
|
||||
SellerAny = "any"
|
||||
|
||||
CartModeDeeplink = "deeplink"
|
||||
@@ -35,6 +38,10 @@ const (
|
||||
DefaultSessionTimeout = 5 * time.Minute
|
||||
DefaultMemoryMB = 64
|
||||
DefaultCallStack = 200
|
||||
|
||||
// DefaultSeller also accepts marketplace offers the shop ships (such as
|
||||
// Fulfilled by Amazon), which is how many listings are sold.
|
||||
DefaultSeller = SellerFulfilled
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -119,6 +126,32 @@ func (d Duration) MarshalText() ([]byte, error) {
|
||||
// IsSet reports whether the value came from the config file.
|
||||
func (d Duration) IsSet() bool { return d.set }
|
||||
|
||||
// sellerRanks orders the sellers a plugin reports, from most to least
|
||||
// trusted. The values match plugin.Seller*.
|
||||
var sellerRanks = map[string]int{
|
||||
"first_party": 0,
|
||||
"fulfilled": 1,
|
||||
"third_party": 2,
|
||||
"unknown": 3,
|
||||
}
|
||||
|
||||
// policyRanks is the least trusted seller each policy still accepts.
|
||||
var policyRanks = map[string]int{
|
||||
SellerFirstParty: 0,
|
||||
SellerFulfilled: 1,
|
||||
SellerAny: 3,
|
||||
}
|
||||
|
||||
// AcceptsSeller reports whether an offer from seller, as a plugin reports it,
|
||||
// passes the item's seller policy. The policies are ordered: "fulfilled"
|
||||
// accepts everything "first_party" does, and "any" accepts every seller.
|
||||
func (it Item) AcceptsSeller(seller string) bool {
|
||||
rank, ok := sellerRanks[seller]
|
||||
if !ok { return false }
|
||||
|
||||
return rank <= policyRanks[it.Seller]
|
||||
}
|
||||
|
||||
// Options control validation that depends on the environment.
|
||||
type Options struct {
|
||||
// Builtins are the names of the embedded plugins.
|
||||
|
||||
Reference in new issue
Block a user