products

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 52 Imported by: 0

Documentation

Overview

Package products implements digital products (design expansion phase 7, M29): a file and a price, sold through Stripe Checkout on the publisher's own Stripe account; orders with their refunds and disputes, which happen in Stripe and arrive through its webhooks; delivery through the Purchases category's "Product delivery" transactional template, with a personal download link that expires after a number of days and of downloads; and the lead magnets signup forms offer after confirmation.

Everything is free: ReputeCast takes no fee and gates nothing. No card details are ever stored, and the download link isn't either: it is signed from its id when it's needed.

Index

Constants

View Source
const (
	DownloadOK       = "ok"
	DownloadExpired  = "expired"
	DownloadUsedUp   = "used_up"
	DownloadRefunded = "refunded"
	DownloadRevoked  = "revoked"
	// DownloadReplaced is a link replaced by a newer one.
	DownloadReplaced = "replaced"
)

Download states.

View Source
const (
	MaxFileBytes    int64 = 500 << 20
	MaxProductBytes int64 = 2 << 30
	// ChunkBytes is the size of an upload's chunks (the last one may be
	// smaller).
	ChunkBytes int64 = 4 << 20
)

Limits (brief §3.5).

View Source
const (
	// TokenDownload is a buyer's download link: MessageID is the link's
	// id, ContactID the order's.
	TokenDownload linktoken.Kind = 190
	// TokenLeadMagnet is a lead magnet's download after confirmation:
	// MessageID is the lead_magnet_links row.
	TokenLeadMagnet linktoken.Kind = 191
	// TokenThanks opens an order's thank-you page from the checkout's
	// return: MessageID is the order.
	TokenThanks linktoken.Kind = 192
)

Link token kinds (design expansion X19: 190–199).

View Source
const (
	StatusDraft     = "draft"
	StatusPublished = "published"
	StatusArchived  = "archived"

	PriceOneTime = "one_time"
	PricePWYW    = "pwyw"

	OrderPaid              = "paid"
	OrderRefunded          = "refunded"
	OrderPartiallyRefunded = "partially_refunded"
	OrderDisputed          = "disputed"

	SourcePage        = "page"
	SourceShop        = "shop"
	SourceProductPage = "product_page"

	// MinimumCents is the least a price, or a pay-what-you-want minimum,
	// may be: Stripe can't charge less than about $1 in most currencies.
	MinimumCents int64 = 100
)

Statuses.

View Source
const (
	OwnerProduct = "product"
	OwnerForm    = "form"
)

Owner kinds of download files.

View Source
const CategoryName = "Purchases"

CategoryName is the Essential transactional category of buyers' emails, in English; a workspace that writes in another language gets it in that language (the workspace's content from then on).

View Source
const FailedTemplateKey = "product-payment-failed"

FailedTemplateKey is the buyer's notice that a delayed payment (a bank debit) didn't clear (review 2026-11 EN-7). It is made, as a draft, with the delivery template, and sent once it's published.

View Source
const KindProgram = "program"

KindProgram is a program (Windows, Linux or macOS): never sold.

View Source
const TemplateKey = "product-delivery"

TemplateKey is the delivery template every new product starts with.

Variables

View Source
var ErrLinkExpired = errors.New("products: the download link expired")

ErrLinkExpired is a lead magnet link past its days.

View Source
var ErrNoDownload = errors.New("products: no such download link")

ErrNoDownload is a token that isn't a download link of the workspace.

View Source
var ErrNotForSale = errors.New("products: not for sale")

ErrNotForSale is a product that can't be bought (a draft, archived, or Stripe isn't connected).

View Source
var ErrTooManyLinks = errors.New("products: too many new links")

ErrTooManyLinks is a buyer asking for new links too often.

Functions

func Erasure

func Erasure() erasure.Source

Erasure is the contact's product orders and checkouts: the buyer's name and address go, amounts stay for revenue; download links stop working (review 2026-11 DP-1).

func FileText

func FileText(f ProductFilesSummary) string

FileText is how pages name a product's files ("PDF, 86 pages", "ZIP, 38 MB").

func FileTextLong

func FileTextLong(f ProductFilesSummary) string

FileTextLong adds the size ("PDF, 86 pages, 4.2 MB").

func HumanSize

func HumanSize(n int64) string

HumanSize writes a file size ("4.2 MB", "380 KB").

func HumanSizeIn

func HumanSizeIn(l i18n.Lang, n int64) string

HumanSizeIn writes a file size in a language's region format ("4,2 MB").

func KindLabel

func KindLabel(kind, name string) string

KindLabel names a file's kind ("PDF", "ZIP").

func MaskEmail

func MaskEmail(email string) string

MaskEmail shows an address without giving it away ("a•••@example.com").

func Mismatch

func Mismatch(name string, d Detected) (claimed string, bad bool)

Mismatch says whether a file's name and its content disagree: a name that claims one recognised kind over content of another (a ".pdf" that is a ZIP archive). Content that couldn't be told, or an extension that names no recognised kind, can't be checked.

func MoneyShort

func MoneyShort(cents int64, currency string) string

func MoneyText

func MoneyText(cents int64, currency string) string

MoneyShort is an amount without cents when they're zero ("$29", "$15.50"). MoneyText is an amount with its currency ("$29.00").

func Register

func Register(h huma.API, s *Service)

Register adds the products and orders operations.

func RegisterJobs

func RegisterJobs(reg *jobs.Registry, s *Service)

RegisterJobs adds the delivery, confirmation and sweep workers.

func SafeName

func SafeName(name string) string

SafeName keeps a readable file name buyers download.

func ShortName

func ShortName(name string) string

ShortName is how tables name a product: "Field Guide" for "The Deliverability Field Guide", "Launch Kit" for "Newsletter Launch Kit". The full name stays in the panel and in tooltips.

func Slugify

func Slugify(name string) string

Slugify makes an address from a name.

Types

type CampaignPath

type CampaignPath struct {
	api.WorkspaceInput
	Campaign string `path:"campaign" format:"uuid"`
}

CampaignPath is a campaign of the workspace.

type CampaignProductSale

type CampaignProductSale struct {
	ProductID string `json:"productId"`
	Name      string `json:"name"`
	Orders    int64  `json:"orders"`
	// RevenueCents is after refunds.
	RevenueCents int64 `json:"revenueCents"`
}

CampaignProductSale is one product's sales credited to a campaign.

type CampaignProductSales

type CampaignProductSales struct {
	Orders       int64                 `json:"orders"`
	RevenueCents int64                 `json:"revenueCents"`
	Currency     string                `json:"currency"`
	Products     []CampaignProductSale `json:"products"`
	// Window is the attribution window in days: an order counts for the
	// email its buyer last clicked within it.
	Window int `json:"window"`
}

CampaignProductSales are the Revenue section's product sales rows.

type CheckoutHandoff

type CheckoutHandoff struct {
	URL         string
	ProductName string
	Price       Live
	Currency    string
	Account     string
	Tax         bool
	Test        bool
}

CheckoutHandoff is what "Taking you to Stripe…" shows before it goes.

type CheckoutStart

type CheckoutStart struct {
	ProductID uuid.UUID
	// Ticked is the list offer's checkbox.
	Ticked bool
	// Source is where the Buy button was: a page (PageID), the shop or the
	// default product page.
	Source string
	PageID *uuid.UUID
	// PageURL is the page's address (the cancel return); PageLabel how
	// consent names it ("news.acme.io/field-guide").
	PageURL   string
	PageLabel string
	IP        string
	// Email and ContactID are a signed-in member's: the email is filled in.
	Email     string
	ContactID *uuid.UUID
	// ThanksURL is the thank-you page, with {CHECKOUT_SESSION_ID} where the
	// session's id goes.
	ThanksURL string
}

CheckoutStart is a Buy button pressed.

type ConfirmArgs

type ConfirmArgs struct {
	WorkspaceID uuid.UUID `json:"workspace_id"`
	ContactID   uuid.UUID `json:"contact_id"`
}

ConfirmArgs sends the double opt-in email of a buyer who ticked the list offer.

func (ConfirmArgs) InsertOpts

func (ConfirmArgs) InsertOpts() river.InsertOpts

InsertOpts implements river.JobArgsWithInsertOpts.

func (ConfirmArgs) Kind

func (ConfirmArgs) Kind() string

Kind implements river.JobArgs.

type ContactPath

type ContactPath struct {
	api.WorkspaceInput
	Contact string `path:"contact" format:"uuid"`
}

ContactPath is a contact of the workspace (exported: Huma reads embedded path structs only when their type is exported).

type ContactPurchase

type ContactPurchase struct {
	ProductOrderItem
	CoverURL string `json:"coverUrl"`
	CoverAlt string `json:"coverAlt"`
}

ContactPurchase is one order of the contact.

type ContactPurchases

type ContactPurchases struct {
	Items []ContactPurchase `json:"items"`
	// SpentCents is what the live orders came to after refunds, in
	// Currency (the workspace's).
	SpentCents int64  `json:"spentCents"`
	Currency   string `json:"currency"`
	// CanManage is orders:manage (Send a new link, revoke and restore).
	CanManage bool `json:"canManage"`
}

ContactPurchases is the Purchases card.

type DeliverArgs

type DeliverArgs struct {
	LinkID uuid.UUID `json:"link_id"`
}

DeliverArgs sends a link's delivery email.

func (DeliverArgs) InsertOpts

func (DeliverArgs) InsertOpts() river.InsertOpts

InsertOpts sends delivery emails from the events queue, retried.

func (DeliverArgs) Kind

func (DeliverArgs) Kind() string

Kind implements river.JobArgs.

type Detected

type Detected struct {
	// Kind is the content's ("pdf", "zip", "xlsx"…); "" when it couldn't
	// be told.
	Kind        string
	ContentType string
	// Pages is a PDF's page count (0 when it couldn't be read).
	Pages int
}

Detected is what a file's content is.

func Detect

func Detect(path string) (Detected, error)

Detect reads what a file contains from its bytes, never its name.

type DownloadFileView

type DownloadFileView struct {
	ID        uuid.UUID
	Name      string
	KindLabel string
	Pages     int
	Size      int64
}

DownloadFileView is one file on the download page.

type DownloadView

type DownloadView struct {
	State       string
	OrderID     uuid.UUID
	LinkID      uuid.UUID
	Token       string
	ProductName string
	Files       []DownloadFileView
	ExpiresAt   time.Time
	Used        int32
	Allowed     int32
	LinkDays    int32
	OrderNumber int64
	BoughtAt    time.Time
	EmailMasked string
	RefundedAt  *time.Time
	RevokedAt   *time.Time
	Test        bool
}

DownloadView is the download page.

func (DownloadView) Left

func (v DownloadView) Left() int32

Left is the downloads the link has left.

type Flows

type Flows interface {
	Refunded(ctx context.Context, tx pgx.Tx, wsID, contactID, productID uuid.UUID, at time.Time) error
}

Flows makes contacts leave "Bought a product" automations when their payment is refunded (internal/automations).

type FormDownload

type FormDownload struct {
	File *ProductFile `json:"file,omitempty"`
	Days int32        `json:"days"`
	// Signups, Links and Downloaded are the confirmation page's numbers.
	Links      int64 `json:"links"`
	Downloaded int64 `json:"downloaded"`
}

FormDownload is a form's download, for the form builder.

type FormDownloadInput

type FormDownloadInput struct {
	Days int32 `json:"days" minimum:"1" maximum:"30" doc:"How many days a link works"`
}

FormDownloadInput sets how long the confirmation page's links work.

type FormUploadPath

type FormUploadPath struct {
	forms.FormPath
	Upload string `path:"upload" format:"uuid"`
}

FormUploadPath is an upload of a form's download (exported: Huma reads embedded path structs only when their type is exported).

type LeadMagnetOffer

type LeadMagnetOffer struct {
	Name      string
	Kind      string
	Pages     int
	Size      int64
	URL       string
	Days      int32
	ExpiresAt time.Time
}

LeadMagnetOffer is the confirmation page's download.

type Live

type Live struct {
	Name             string `json:"name"`
	Slug             string `json:"slug"`
	ShortDesc        string `json:"shortDesc"`
	LongDesc         string `json:"longDesc"`
	CoverURL         string `json:"coverUrl"`
	CoverAlt         string `json:"coverAlt"`
	PriceKind        string `json:"priceKind"`
	PriceCents       int64  `json:"priceCents"`
	MinCents         int64  `json:"minCents"`
	SuggestedCents   int64  `json:"suggestedCents"`
	SalesPageID      string `json:"salesPageId,omitempty"`
	ShowInShop       bool   `json:"showInShop"`
	OfferOn          bool   `json:"offerOn"`
	OfferListID      string `json:"offerListId,omitempty"`
	OfferText        string `json:"offerText"`
	LinkDays         int32  `json:"linkDays"`
	LinkDownloads    int32  `json:"linkDownloads"`
	DeliveryTemplate string `json:"deliveryTemplate,omitempty"`
	RevokeOnRefund   bool   `json:"revokeOnRefund"`
}

Live is a published product as the shop, its pages and checkout see it.

type Merchant

type Merchant struct {
	Connected bool
	Account   string
	Test      bool
	Tax       bool
	Currency  string
}

Merchant is who buyers pay.

type NewLinkInput

type NewLinkInput struct {
	// RequestedBy notes who asked ("the buyer, by replying to the delivery email").
	RequestedBy string `json:"requestedBy,omitempty" maxLength:"200"`
}

NewLinkInput sends a new download link.

type OrderPath

type OrderPath struct {
	api.WorkspaceInput
	Order string `path:"order" format:"uuid"`
}

OrderPath is an order of the workspace.

type OrdersQuery

type OrdersQuery struct {
	Q        string
	Product  string
	Status   string
	Period   string
	Page     int
	PageSize int
}

OrdersQuery filters orders.

type PaymentFailedArgs

type PaymentFailedArgs struct {
	CheckoutID uuid.UUID `json:"checkout_id"`
}

PaymentFailedArgs tells a buyer their payment didn't go through. The address is the checkout's, so the job carries no personal data.

func (PaymentFailedArgs) InsertOpts

func (PaymentFailedArgs) InsertOpts() river.InsertOpts

InsertOpts sends from the events queue, retried, once per checkout.

func (PaymentFailedArgs) Kind

func (PaymentFailedArgs) Kind() string

Kind implements river.JobArgs.

type ProductAutomationNumbers

type ProductAutomationNumbers struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Entered  int64  `json:"entered" doc:"Contacts still in the flow or through it"`
	Contacts int64  `json:"contacts"`
	Refunded int64  `json:"refunded" doc:"Contacts who left because their payment was refunded"`
}

ProductAutomationNumbers is the "Bought a product" automation's numbers.

type ProductCheck

type ProductCheck struct {
	Key string `json:"key" enum:"stripe,file,price,template,route,cover_alt,sales_page,failed_notice"`
	OK  bool   `json:"ok"`
	// Advisory: a recommendation that doesn't block publishing (the
	// payment-failed notice, review 2026-11 EN-10).
	Advisory bool `json:"advisory,omitempty"`
	// What the check found: the account and mode, the file, the price,
	// the template and its version, the route, the sales page.
	Account  string     `json:"account,omitempty"`
	Mode     string     `json:"mode,omitempty"`
	File     string     `json:"file,omitempty"`
	Bytes    int64      `json:"bytes,omitempty"`
	Template string     `json:"template,omitempty"`
	Version  int32      `json:"version,omitempty"`
	Draft    bool       `json:"draft,omitempty" doc:"The template has a draft but no published version"`
	Route    string     `json:"route,omitempty" example:"Postmark, then Amazon SES"`
	Path     string     `json:"path,omitempty"`
	At       *time.Time `json:"at,omitempty"`
	Default  bool       `json:"default,omitempty" doc:"No sales page chosen: the default product page"`
	// TemplateID links the fix ("Open product-delivery and publish it").
	TemplateID string `json:"templateId,omitempty"`
}

ProductCheck is one publish check.

type ProductCount

type ProductCount struct {
	ProductID string `json:"productId"`
	Name      string `json:"name"`
	Count     int64  `json:"count"`
}

ProductCount is a product's count ("214 Field Guide").

type ProductCover

type ProductCover struct {
	URL    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

ProductCover is an uploaded cover image.

type ProductCreate

type ProductCreate struct {
	Name string `json:"name,omitempty" maxLength:"120"`
}

ProductCreate starts a product.

type ProductDelivery

type ProductDelivery struct {
	TemplateID     string `json:"templateId" doc:"The transactional template of the delivery email"`
	LinkDays       int32  `json:"linkDays" minimum:"1" maximum:"30"`
	Downloads      int32  `json:"downloads" minimum:"1" maximum:"20"`
	RevokeOnRefund bool   `json:"revokeOnRefund" doc:"Revoke access when a payment is refunded or disputed"`
}

ProductDelivery is how buyers get the file.

type ProductDetail

type ProductDetail struct {
	ID          string         `json:"id"`
	Status      string         `json:"status" enum:"draft,published,archived"`
	Draft       ProductFields  `json:"draft"`
	Live        *ProductFields `json:"live,omitempty"`
	Changes     []string       `json:"changes" doc:"The draft's fields that differ from what's live"`
	PublishedAt *time.Time     `json:"publishedAt,omitempty"`
	PublishedBy string         `json:"publishedBy"`
	ArchivedAt  *time.Time     `json:"archivedAt,omitempty"`
	CreatedBy   string         `json:"createdBy"`
	UpdatedAt   time.Time      `json:"updatedAt"`
	UpdatedBy   string         `json:"updatedBy"`
	Files       []ProductFile  `json:"files"`
	FilesBytes  int64          `json:"filesBytes"`
	MaxBytes    int64          `json:"maxBytes"`
	MaxFile     int64          `json:"maxFile"`
	ChunkBytes  int64          `json:"chunkBytes"`
	Checks      []ProductCheck `json:"checks"`
	// Numbers since the product was first published.
	Numbers   *ProductNumbers         `json:"numbers,omitempty"`
	Pages     []ProductPageOption     `json:"pages"`
	Lists     []ProductListOption     `json:"lists"`
	Templates []ProductTemplateOption `json:"templates"`
	Payments  ProductsPayments        `json:"payments"`
	Route     string                  `json:"route"`
	// Addresses: the site's products path ("news.acme.io/products/"),
	// the shop and the default product page.
	SiteHost  string           `json:"siteHost"`
	ShopURL   string           `json:"shopUrl"`
	PageURL   string           `json:"pageUrl"`
	SalesPage ProductSalesPage `json:"salesPage"`
	// Orders counts every live order (the price change dialog).
	Orders  int64           `json:"orders"`
	Helpers ProductsHelpers `json:"helpers"`
}

ProductDetail is the product editor.

type ProductDownloadState

type ProductDownloadState struct {
	// State: delivered (the email arrived), sent (it left), pending (being
	// sent), failed, expired, used_up, revoked (by a person or a refund),
	// revoked_auto (a dispute, as the product says).
	State       string     `json:"state" enum:"pending,sent,delivered,failed,expired,used_up,revoked,revoked_auto"`
	Provider    string     `json:"provider"`
	SentAt      *time.Time `json:"sentAt,omitempty"`
	DeliveredAt *time.Time `json:"deliveredAt,omitempty"`
	Error       string     `json:"error,omitempty"`
	Used        int32      `json:"used"`
	Allowed     int32      `json:"allowed"`
	ExpiresAt   *time.Time `json:"expiresAt,omitempty"`
	// NewLink: the current link replaced an expired one, sent by a person
	// (or the buyer from the expired link's page).
	NewLink   bool       `json:"newLink"`
	NewLinkAt *time.Time `json:"newLinkAt,omitempty"`
	NewLinkBy string     `json:"newLinkBy"`
	// The revocation: when, by whom ("" for the system) and why.
	RevokedAt    *time.Time `json:"revokedAt,omitempty"`
	RevokedBy    string     `json:"revokedBy"`
	RevokeReason string     `json:"revokeReason" enum:",manual,refund,dispute"`
}

ProductDownloadState is an order's download link as the Download column and the order panel show it.

type ProductFields

type ProductFields struct {
	Name             string          `json:"name" maxLength:"120"`
	Slug             string          `json:"slug" maxLength:"80"`
	ShortDescription string          `json:"shortDescription" maxLength:"120"`
	LongDescription  string          `json:"longDescription" maxLength:"4000"`
	CoverURL         string          `json:"coverUrl" maxLength:"1000"`
	CoverAlt         string          `json:"coverAlt" maxLength:"300"`
	Price            ProductPrice    `json:"price"`
	SalesPageID      string          `json:"salesPageId" doc:"Empty for the default product page"`
	ShowInShop       bool            `json:"showInShop"`
	Offer            ProductOffer    `json:"offer"`
	Delivery         ProductDelivery `json:"delivery"`
}

ProductFields are a product's editable fields: the draft, or what's live.

type ProductFile

type ProductFile struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Kind        string    `json:"kind" doc:"What the content is: pdf, zip, xlsx…, empty when it couldn't be told"`
	KindLabel   string    `json:"kindLabel" doc:"PDF, ZIP, XLSX"`
	ContentType string    `json:"contentType"`
	Pages       int       `json:"pages"`
	SizeBytes   int64     `json:"sizeBytes"`
	UploadedAt  time.Time `json:"uploadedAt"`
	UploadedBy  string    `json:"uploadedBy"`
}

ProductFile is one of a product's files.

type ProductFilesSummary

type ProductFilesSummary struct {
	Count int    `json:"count"`
	Kind  string `json:"kind" doc:"The first file's kind in capitals (PDF, ZIP, XLSX)"`
	Pages int    `json:"pages" doc:"The first file's pages, for a PDF"`
	Bytes int64  `json:"bytes"`
}

ProductFilesSummary is what a product's files add up to ("PDF, 86 pages, 4.2 MB").

type ProductListItem

type ProductListItem struct {
	ID        string              `json:"id"`
	Name      string              `json:"name"`
	ShortName string              `json:"shortName"`
	CoverURL  string              `json:"coverUrl"`
	CoverAlt  string              `json:"coverAlt"`
	Files     ProductFilesSummary `json:"files"`
	Price     ProductPrice        `json:"price"`
	Currency  string              `json:"currency"`
	Status    string              `json:"status" enum:"draft,published,archived"`
	// StatusAt and StatusBy say when and by whom it was published or
	// archived; a draft names who edited it last.
	StatusAt      *time.Time       `json:"statusAt,omitempty"`
	StatusBy      string           `json:"statusBy"`
	Orders        int64            `json:"orders"`
	GrossCents    int64            `json:"grossCents"`
	Refunds       int64            `json:"refunds"`
	RefundedCents int64            `json:"refundedCents"`
	SalesPage     ProductSalesPage `json:"salesPage"`
	UpdatedAt     time.Time        `json:"updatedAt"`
}

ProductListItem is one row of Earn › Products.

type ProductListOption

type ProductListOption struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	DoubleOptIn bool   `json:"doubleOptIn"`
}

ProductListOption is a list the offer can use.

type ProductNumbers

type ProductNumbers struct {
	Since         time.Time `json:"since"`
	Orders        int64     `json:"orders"`
	GrossCents    int64     `json:"grossCents"`
	RefundedCents int64     `json:"refundedCents"`
	Refunds       int64     `json:"refunds"`
	FromPage      int64     `json:"fromPage"`
	FromShop      int64     `json:"fromShop"`
	FromDefault   int64     `json:"fromDefault"`
	Contacts      int64     `json:"contacts"`
	Joined        int64     `json:"joined"`
	None          int64     `json:"none"`
	// OfferList names the list buyers joined at checkout.
	OfferList  string                    `json:"offerList"`
	Automation *ProductAutomationNumbers `json:"automation,omitempty"`
	Test       bool                      `json:"test"`
}

ProductNumbers are a published product's numbers since it was first published.

type ProductOffer

type ProductOffer struct {
	On     bool   `json:"on"`
	ListID string `json:"listId" doc:"The list a buyer who ticks it joins, with its double opt-in"`
	Text   string `json:"text" maxLength:"160" doc:"The exact text, kept as consent"`
}

ProductOffer is the list offer next to the Buy button.

type ProductOrderBuyer

type ProductOrderBuyer struct {
	Email string `json:"email"`
	Name  string `json:"name"`
	// Kind: a contact already, joined at checkout (the list offer), or not
	// a contact (the order keeps the address for delivery and support only).
	Kind         string     `json:"kind" enum:"contact,joined,none"`
	ContactID    string     `json:"contactId,omitempty"`
	ContactSince *time.Time `json:"contactSince,omitempty"`
	// The list offer's list and when its double opt-in was confirmed.
	List        string     `json:"list"`
	ListStatus  string     `json:"listStatus" enum:",pending,subscribed,unsubscribed"`
	ConfirmedAt *time.Time `json:"confirmedAt,omitempty"`
	DoubleOptIn bool       `json:"doubleOptIn"`
}

ProductOrderBuyer is who bought, and how they relate to contacts.

type ProductOrderConsent

type ProductOrderConsent struct {
	Offered bool       `json:"offered"`
	Ticked  bool       `json:"ticked"`
	Text    string     `json:"text"`
	List    string     `json:"list"`
	Page    string     `json:"page"`
	IP      string     `json:"ip"`
	At      *time.Time `json:"at,omitempty"`
}

ProductOrderConsent is the consent given at checkout.

type ProductOrderDelivery

type ProductOrderDelivery struct {
	MessageID   string     `json:"messageId,omitempty"`
	Template    string     `json:"template"`
	Version     int32      `json:"version"`
	Status      string     `json:"status"`
	Provider    string     `json:"provider"`
	SentAt      *time.Time `json:"sentAt,omitempty"`
	DeliveredAt *time.Time `json:"deliveredAt,omitempty"`
	Seconds     float64    `json:"seconds"`
	// NewLink: this email carried a new link, sent by a person.
	NewLink bool `json:"newLink"`
}

ProductOrderDelivery is the delivery email.

type ProductOrderDetail

type ProductOrderDetail struct {
	ProductOrderItem
	ProductCover string                `json:"productCover"`
	ProductAlt   string                `json:"productAlt"`
	Files        ProductFilesSummary   `json:"files"`
	Price        ProductPrice          `json:"price"`
	Buyer        ProductOrderBuyer     `json:"buyer"`
	Consent      ProductOrderConsent   `json:"consent"`
	Payment      ProductOrderPayment   `json:"payment"`
	Delivery     *ProductOrderDelivery `json:"delivery,omitempty"`
	Downloads    ProductOrderDownloads `json:"downloads"`
	// PreviousExpired: the link before the current one had expired.
	Activity []ProductOrderEvent `json:"activity"`
	// What a member may do: send a new link (never while revoked), revoke,
	// restore.
	CanSendLink bool     `json:"canSendLink"`
	CanRevoke   bool     `json:"canRevoke"`
	CanRestore  bool     `json:"canRestore"`
	Route       string   `json:"route"`
	Helpers     []string `json:"helpers"`
}

ProductOrderDetail is the order panel.

type ProductOrderDownloads

type ProductOrderDownloads struct {
	Count     int64      `json:"count"`
	Addresses int64      `json:"addresses" doc:"Distinct IP addresses (kept only as hashes)"`
	First     *time.Time `json:"first,omitempty"`
	Last      *time.Time `json:"last,omitempty"`
}

ProductOrderDownloads sums up the downloads.

type ProductOrderEvent

type ProductOrderEvent struct {
	Kind string    `` /* 207-byte string literal not displayed */
	At   time.Time `json:"at"`
	// By is the person, "" for the system or the buyer.
	By string `json:"by"`
	// What the line says: the page and the list offer, Stripe's event,
	// the template, provider and seconds, the downloads, amounts, reasons.
	Page      string     `json:"page,omitempty"`
	Ticked    bool       `json:"ticked,omitempty"`
	Stripe    string     `json:"stripe,omitempty"`
	Template  string     `json:"template,omitempty"`
	Version   int32      `json:"version,omitempty"`
	Provider  string     `json:"provider,omitempty"`
	Seconds   float64    `json:"seconds,omitempty"`
	Count     int64      `json:"count,omitempty"`
	Used      int32      `json:"used,omitempty"`
	Allowed   int32      `json:"allowed,omitempty"`
	File      string     `json:"file,omitempty"`
	Bytes     int64      `json:"bytes,omitempty"`
	Amount    int64      `json:"amount,omitempty"`
	Currency  string     `json:"currency,omitempty"`
	Reason    string     `json:"reason,omitempty"`
	RespondBy *time.Time `json:"respondBy,omitempty"`
	Outcome   string     `json:"outcome,omitempty"`
	Email     string     `json:"email,omitempty"`
	Note      string     `json:"note,omitempty"`
	ByStripe  bool       `json:"byStripe,omitempty" doc:"Done in Stripe's dashboard"`
	Auto      bool       `json:"auto,omitempty" doc:"Done by the system, as the product's setting says"`
}

ProductOrderEvent is one line of the order's activity.

type ProductOrderItem

type ProductOrderItem struct {
	ID             string               `json:"id"`
	Number         int64                `json:"number"`
	PaidAt         time.Time            `json:"paidAt"`
	BuyerEmail     string               `json:"buyerEmail"`
	ProductID      string               `json:"productId"`
	Product        string               `json:"product" doc:"The product's short name (Field Guide)"`
	ProductName    string               `json:"productName"`
	AmountCents    int64                `json:"amountCents"`
	Currency       string               `json:"currency"`
	PayWhatYouWant bool                 `json:"payWhatYouWant"`
	Status         string               `json:"status" enum:"paid,refunded,partially_refunded,disputed"`
	Test           bool                 `json:"test"`
	RefundedCents  int64                `json:"refundedCents"`
	RefundedAt     *time.Time           `json:"refundedAt,omitempty"`
	DisputeStatus  string               `json:"disputeStatus" enum:",open,won,lost"`
	DisputeReason  string               `json:"disputeReason"`
	DisputedAt     *time.Time           `json:"disputedAt,omitempty"`
	Download       ProductDownloadState `json:"download"`
}

ProductOrderItem is one row of the orders table.

type ProductOrderList

type ProductOrderList struct {
	Items    []ProductOrderItem `json:"items"`
	Total    int64              `json:"total"`
	Page     int                `json:"page"`
	PageSize int                `json:"pageSize"`
	// Products names the products the filter offers.
	Products []ProductCount `json:"products"`
}

ProductOrderList is a page of orders.

type ProductOrderPayment

type ProductOrderPayment struct {
	Provider        string     `json:"provider"`
	Account         string     `json:"account"`
	Mode            string     `json:"mode" enum:"live,test"`
	AmountCents     int64      `json:"amountCents"`
	TaxCents        int64      `json:"taxCents"`
	Currency        string     `json:"currency"`
	RefundedCents   int64      `json:"refundedCents"`
	RefundedAt      *time.Time `json:"refundedAt,omitempty"`
	DisputeStatus   string     `json:"disputeStatus" enum:",open,won,lost"`
	DisputeReason   string     `json:"disputeReason"`
	DisputeFeeCents int64      `json:"disputeFeeCents"`
	DisputeDueBy    *time.Time `json:"disputeDueBy,omitempty"`
	// URL opens the payment in Stripe's dashboard (refunds happen there).
	URL        string `json:"url"`
	DisputeURL string `json:"disputeUrl"`
}

ProductOrderPayment is the payment as Stripe reports it.

type ProductPageOption

type ProductPageOption struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Path   string `json:"path"`
	Status string `json:"status" enum:"draft,scheduled,published,unpublished"`
}

ProductPageOption is a page a product can sell on.

type ProductPath

type ProductPath struct {
	api.WorkspaceInput
	Product string `path:"product" format:"uuid"`
}

ProductPath is a product of the workspace (exported: Huma reads embedded path structs only when their type is exported).

type ProductPrice

type ProductPrice struct {
	Kind           string `json:"kind" enum:"one_time,pwyw"`
	AmountCents    int64  `json:"amountCents" minimum:"0" maximum:"100000000"`
	MinimumCents   int64  `json:"minimumCents" minimum:"0" maximum:"100000000"`
	SuggestedCents int64  `json:"suggestedCents" minimum:"0" maximum:"100000000"`
}

ProductPrice is a product's price, in the currency's minor units.

type ProductPublishInput

type ProductPublishInput struct {
	// ConfirmPrice confirms a published product's new price: existing
	// buyers keep their access, new buyers pay the new price.
	ConfirmPrice bool `json:"confirmPrice,omitempty"`
}

ProductPublishInput publishes a product's draft.

type ProductSalesPage

type ProductSalesPage struct {
	PageID      string     `json:"pageId,omitempty" doc:"Empty for the default product page"`
	Name        string     `json:"name"`
	Path        string     `json:"path" example:"/field-guide"`
	Status      string     `json:"status" enum:"draft,scheduled,published,unpublished,default"`
	PublishedAt *time.Time `json:"publishedAt,omitempty"`
}

ProductSalesPage is where a product's Buy buttons lead.

type ProductSourceRow

type ProductSourceRow struct {
	ProductID  string `json:"productId"`
	Product    string `json:"product"`
	Source     string `json:"source" enum:"page,shop,product_page"`
	Orders     int64  `json:"orders"`
	GrossCents int64  `json:"grossCents"`
}

ProductSourceRow is where some sales came from: a product's sales page, the shop or its default page.

type ProductTemplateOption

type ProductTemplateOption struct {
	ID       string `json:"id"`
	Key      string `json:"key"`
	Name     string `json:"name"`
	Version  int32  `json:"version" doc:"The live version; 0 when none is published"`
	Category string `json:"category"`
	Kind     string `json:"kind" doc:"essential or optional"`
}

ProductTemplateOption is a transactional template a product can deliver with.

type ProductsBuyers

type ProductsBuyers struct {
	Product   string         `json:"product"`
	Contacts  int64          `json:"contacts" doc:"Buyers who were contacts already"`
	Joined    int64          `json:"joined" doc:"Buyers who ticked the list offer and became contacts"`
	None      int64          `json:"none" doc:"Buyers who aren't contacts"`
	Ticked    int64          `json:"ticked"`
	TickedBy  []ProductCount `json:"tickedBy"`
	OfferText string         `json:"offerText"`
}

ProductsBuyers are buyers as contacts: the best-selling product's, and the list offers ticked per product.

type ProductsFile

type ProductsFile struct {
	ContentType        string `header:"Content-Type"`
	ContentDisposition string `header:"Content-Disposition"`
	CacheControl       string `header:"Cache-Control"`
	Body               []byte
}

ProductsFile is a CSV download.

type ProductsHelpers

type ProductsHelpers struct {
	Edit    []string `json:"edit"`
	Publish []string `json:"publish"`
	Orders  []string `json:"orders"`
	Export  []string `json:"export"`
}

ProductsHelpers name who can help with what a member can't do.

type ProductsOverview

type ProductsOverview struct {
	Period   string             `json:"period" enum:"30d,90d,12m"`
	From     time.Time          `json:"from"`
	Until    time.Time          `json:"until"`
	Stats    ProductsStats      `json:"stats"`
	Products []ProductListItem  `json:"products"`
	Sources  []ProductSourceRow `json:"sources"`
	Buyers   ProductsBuyers     `json:"buyers"`
	Payments ProductsPayments   `json:"payments"`
	Helpers  ProductsHelpers    `json:"helpers"`
}

ProductsOverview is Earn › Products.

type ProductsPayments

type ProductsPayments struct {
	Connected        bool   `json:"connected"`
	Provider         string `json:"provider"`
	Mode             string `json:"mode" enum:"live,test,"`
	Account          string `json:"account"`
	HasLive          bool   `json:"hasLive"`
	Currency         string `json:"currency"`
	TaxAtCheckout    bool   `json:"taxAtCheckout"`
	PricesIncludeTax bool   `json:"pricesIncludeTax"`
}

ProductsPayments is the payment connection products sell through.

type ProductsStats

type ProductsStats struct {
	Orders         int64          `json:"orders"`
	ByProduct      []ProductCount `json:"byProduct"`
	GrossCents     int64          `json:"grossCents"`
	RefundedCents  int64          `json:"refundedCents"`
	RefundedOrders int64          `json:"refundedOrders"`
	OpenDisputes   int64          `json:"openDisputes"`
	NetCents       int64          `json:"netCents"`
}

ProductsStats are the period's numbers (live payments, or test ones in test mode).

type ProductsSummary

type ProductsSummary struct {
	Orders         int64     `json:"orders"`
	GrossCents     int64     `json:"grossCents"`
	RefundedCents  int64     `json:"refundedCents"`
	RefundedOrders int64     `json:"refundedOrders"`
	Currency       string    `json:"currency"`
	Products       int64     `json:"products"`
	From           time.Time `json:"from"`
	Until          time.Time `json:"until"`
}

ProductsSummary is the Earn overview's "Product sales" card.

type PublicProduct

type PublicProduct struct {
	ID       uuid.UUID
	Status   string
	Live     Live
	Files    ProductFilesSummary
	Currency string
	// SalesPage is the published sales page's address ("" for none: the
	// default product page).
	SalesPage string
	// OfferList and OfferNote are the list offer's list and its line
	// ("One email a week.").
	OfferList string
	OfferNote string
	// Published: readers can buy it.
	Published bool
}

PublicProduct is a product as readers see it: its published version (or its draft, for the builder's previews).

type Service

type Service struct {
	Pool  *pgxpool.Pool
	Q     *store.Queries
	Audit *audit.Logger
	Log   *slog.Logger
	Now   func() time.Time
	URLs  publicurl.Builder
	Links *linktoken.Signer
	Files Store
	// Forms gives the public site's links (the custom domain once it's
	// verified).
	Forms *forms.Service
	// Earn is the payment connection products sell through.
	Earn func() *earn.Service
	// Transactional sends the delivery email.
	Transactional func() *transactional.Service
	// Audience subscribes a buyer who ticked the list offer.
	Audience func() *audience.Service
	// Jobs queues the delivery emails, in the transaction that makes them.
	Jobs func() *jobs.Client
	// Flows makes contacts leave "Bought a product" automations after a
	// refund (nil: none).
	Flows Flows
	// Media keeps cover images in the image library.
	Media *media.Service
	// SiteOn says whether the publication website is on: buyers can sign in
	// to its account page for a new link (nil: off).
	SiteOn func(ctx context.Context, ws *store.Workspace) bool
	// CountsChanged tells the kept audience counts that a workspace's buyers
	// changed, so a "Bought a product" segment counts the new order at once
	// (review 2026-11 OP-12; nil: nothing kept).
	CountsChanged func(ws uuid.UUID)
}

Service holds the products domain.

func (s *Service) AccountNewLink(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, _ string, orderID uuid.UUID) error

AccountNewLink sends a new link for an order of a signed-in member (the account page's "Send me a new link"), to the address on the order.

func (*Service) Archive

func (s *Service) Archive(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, archive bool) (ProductDetail, error)

Archive stops selling a product: it can't be bought, and its buyers keep their downloads.

func (s *Service) BuyerNewLink(ctx context.Context, ws *store.Workspace, token string) (string, error)

BuyerNewLink sends a new link to the order's address, from an expired or used-up link's page. It answers the masked address the link went to.

func (*Service) CampaignSales

func (s *Service) CampaignSales(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (CampaignProductSales, error)

CampaignSales are the product sales credited to a campaign (live orders).

func (*Service) CancelUpload

func (s *Service) CancelUpload(ctx context.Context, ws *store.Workspace, kind string, owner uuid.UUID, id string) error

CancelUpload drops an upload and what arrived of it.

func (*Service) Consume

func (s *Service) Consume(ctx context.Context, tx pgx.Tx, e earn.PaymentEvent) (earn.Consumed, bool, error)

Consume is the payment consumer (registered with earn.RegisterPaymentConsumer).

func (*Service) ContactActivity

func (s *Service) ContactActivity(ctx context.Context, ws *store.Workspace, contactID uuid.UUID, before *time.Time, beforeID string, limit int) ([]audience.ContactActivityItem, int64, error)

ContactActivity implements audience.ActivitySource: the contact bought a product, and a refund. Test orders are left out.

func (*Service) Create

Create starts a draft product.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error

Delete removes a product that was never published; a published one is archived instead, so its buyers keep their downloads.

func (*Service) Deliver

func (s *Service) Deliver(ctx context.Context, linkID uuid.UUID) error

Deliver sends a link's delivery email. A link superseded or revoked meanwhile isn't sent.

func (*Service) Detail

func (s *Service) Detail(ctx context.Context, ws *store.Workspace, id uuid.UUID) (ProductDetail, error)

Detail is one product for its editor.

func (*Service) Download

func (s *Service) Download(ctx context.Context, ws *store.Workspace, token string) (DownloadView, error)

Download reads a download page.

func (*Service) DownloadToken

func (s *Service) DownloadToken(wsID, orderID, linkID uuid.UUID) string

DownloadToken is a link's token: signed from its id, never stored.

func (*Service) DownloadURL

func (s *Service) DownloadURL(ctx context.Context, ws *store.Workspace, orderID, linkID uuid.UUID) string

DownloadURL is a link's download page.

func (*Service) Export

func (s *Service) Export(ctx context.Context, ws *store.Workspace, p *authz.Principal, in OrdersQuery) ([]byte, int, error)

Export writes the orders a filter shows as CSV, and records the export.

func (*Service) FinishFormUpload

func (s *Service) FinishFormUpload(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, upload string) (FormDownload, error)

FinishFormUpload checks the file and makes it the form's download.

func (*Service) FinishUpload

func (s *Service) FinishUpload(ctx context.Context, ws *store.Workspace, p *authz.Principal, kind string, owner uuid.UUID, id string) (ProductFile, error)

FinishUpload checks a complete upload's content and keeps the file: it joins the owner's files (replacing one when asked).

func (*Service) FormDownloadDays

func (s *Service) FormDownloadDays(ctx context.Context, ws *store.Workspace, p *authz.Principal, formID uuid.UUID, days int32) (FormDownload, error)

FormDownloadDays sets how long a form's download links work.

func (*Service) FormDownloadOf

func (s *Service) FormDownloadOf(ctx context.Context, ws *store.Workspace, formID uuid.UUID) (FormDownload, error)

FormDownloadOf reads a form's download.

func (*Service) LeadMagnetFor

func (s *Service) LeadMagnetFor(ctx context.Context, ws *store.Workspace, base string, formID, contactID uuid.UUID) (LeadMagnetOffer, bool, error)

LeadMagnetFor is the download a contact who confirmed through a form gets: a link of their own, made once and reused while it works.

func (*Service) Merchant

func (s *Service) Merchant(ctx context.Context, ws *store.Workspace) (Merchant, error)

Merchant reads the payment connection products sell through.

func (*Service) OpenFile

func (s *Service) OpenFile(ctx context.Context, ws *store.Workspace, token string, fileID uuid.UUID, ip string, count bool) (store.DownloadFile, *os.File, string, error)

OpenFile counts a download and opens the file to send. The caller closes it. A download resumed from the middle (a Range request) doesn't count again: count is false for it.

func (*Service) OpenLeadMagnet

func (s *Service) OpenLeadMagnet(ctx context.Context, ws *store.Workspace, token string, count bool) (store.DownloadFile, *os.File, error)

OpenLeadMagnet counts a lead magnet's download and opens its file.

func (*Service) Order

Order is one order for its panel.

func (*Service) Orders

Orders lists orders, newest first.

func (*Service) Overview

func (s *Service) Overview(ctx context.Context, ws *store.Workspace, period string) (ProductsOverview, error)

Overview is Earn › Products for a period.

func (*Service) ProductBySlug

func (s *Service) ProductBySlug(ctx context.Context, ws *store.Workspace, slug string, drafts bool) (PublicProduct, string, error)

ProductBySlug is the product answering at /products/{slug}; moved is the address it moved to.

func (*Service) PublicProducts

func (s *Service) PublicProducts(ctx context.Context, ws *store.Workspace, ids []uuid.UUID, drafts bool) (map[uuid.UUID]PublicProduct, error)

PublicProducts reads products by id; draft products only when drafts.

func (*Service) Publish

Publish makes the draft live: the price in Stripe, then the shop, its pages and checkout.

func (*Service) Purchases

func (s *Service) Purchases(ctx context.Context, ws *store.Workspace, p *authz.Principal, contactID uuid.UUID) (ContactPurchases, error)

Purchases lists a contact's orders, newest first; test orders are left out.

func (*Service) RemoveFile

func (s *Service) RemoveFile(ctx context.Context, ws *store.Workspace, p *authz.Principal, kind string, owner, fileID uuid.UUID) error

RemoveFile takes a file off its owner. Buyers' download pages show the files the product has now.

func (*Service) RemoveFormDownload

func (s *Service) RemoveFormDownload(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (FormDownload, error)

RemoveFormDownload stops offering a download after confirmation. Links already sent stop working.

func (*Service) Revoke

func (s *Service) Revoke(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, revoke bool) (ProductOrderDetail, error)

Revoke stops an order's downloads; Restore lets them work again (not after a full refund).

func (*Service) Save

Save saves a product's draft. A published product's live version changes only with Publish changes.

SendNewLink sends a new download link, to the address on the order and never another one; the older links stop working.

func (*Service) SendPaymentFailed

func (s *Service) SendPaymentFailed(ctx context.Context, checkoutID uuid.UUID) error

SendPaymentFailed emails the buyer of a failed checkout, with a link back to the product to try again. Without a published template nothing is sent: the Transactional log shows nothing, the order list nothing.

func (*Service) ShopProducts

func (s *Service) ShopProducts(ctx context.Context, ws *store.Workspace) ([]PublicProduct, error)

ShopProducts are the published products shown in the shop.

func (*Service) StartCheckout

func (s *Service) StartCheckout(ctx context.Context, ws *store.Workspace, in CheckoutStart) (CheckoutHandoff, error)

StartCheckout opens a Checkout session for a published product.

func (*Service) StartFormUpload

func (s *Service) StartFormUpload(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in UploadStart) (UploadState, error)

StartFormUpload starts the upload of a form's file; it replaces the one the form offers once it finished.

func (*Service) StartUpload

func (s *Service) StartUpload(ctx context.Context, ws *store.Workspace, p *authz.Principal, kind string, owner uuid.UUID, in UploadStart) (UploadState, error)

StartUpload starts an upload for an owner (a product, a form).

func (*Service) Summary

func (s *Service) Summary(ctx context.Context, ws *store.Workspace) (ProductsSummary, error)

Summary is the Earn overview's "Product sales" card: the last 30 days.

func (*Service) Sweep

func (s *Service) Sweep(ctx context.Context) error

Sweep drops uploads older than a day that never finished, and marks checkouts older than a day expired (Stripe's sessions last 24 hours).

func (*Service) Thanks

func (s *Service) Thanks(ctx context.Context, ws *store.Workspace, productID uuid.UUID, sessionID string) (ThanksView, bool, error)

Thanks reads the order a returning buyer paid for. Back from Stripe before its webhook arrives, the payment is read from Stripe and applied now (the webhook then finds the order made).

func (*Service) ThanksFor

func (s *Service) ThanksFor(ctx context.Context, ws *store.Workspace, sessionID string) (ThanksView, bool, error)

ThanksFor reads the order of a Checkout session, whichever product it bought (a page's thank-you page).

func (*Service) WriteChunk

func (s *Service) WriteChunk(ctx context.Context, ws *store.Workspace, kind string, owner uuid.UUID, id string, offset int64, data []byte) (UploadState, error)

WriteChunk appends a chunk at offset.

type Store

type Store struct {
	Dir string
}

Store keeps files on disk under a folder.

func (Store) Open

func (st Store) Open(key string) (*os.File, error)

Open opens a stored file.

func (Store) PutBytes

func (st Store) PutBytes(wsID uuid.UUID, data []byte) (string, []byte, error)

PutBytes stores a file's bytes under the workspace (the demo's sample files) and returns their key and checksum.

func (Store) Remove

func (st Store) Remove(key string) error

Remove deletes a stored file's bytes.

func (Store) SweepUploads

func (st Store) SweepUploads(before time.Time)

SweepUploads drops uploads older than a day that never finished.

type SweepArgs

type SweepArgs struct{}

SweepArgs drops unfinished uploads and closes checkouts nobody finished.

func (SweepArgs) InsertOpts

func (SweepArgs) InsertOpts() river.InsertOpts

InsertOpts runs one sweep at a time.

func (SweepArgs) Kind

func (SweepArgs) Kind() string

Kind implements river.JobArgs.

type ThanksView

type ThanksView struct {
	Order       store.ProductOrder
	ProductName string
	Files       ProductFilesSummary
	DownloadURL string
	EmailMasked string
	ExpiresAt   time.Time
	Downloads   int32
	// OfferPending: the buyer ticked the list offer and its double opt-in
	// waits for the confirmation click.
	OfferPending bool
	OfferList    string
	Test         bool
}

ThanksView is the thank-you page after Stripe.

type Upload

type Upload struct {
	ID          string    `json:"id"`
	WorkspaceID uuid.UUID `json:"workspaceId"`
	OwnerKind   string    `json:"ownerKind"`
	OwnerID     uuid.UUID `json:"ownerId"`
	Name        string    `json:"name"`
	Size        int64     `json:"size"`
	Replaces    string    `json:"replaces,omitempty"`
	UserID      uuid.UUID `json:"userId"`
	Created     time.Time `json:"created"`
}

Upload is a file arriving in chunks.

type UploadPath

type UploadPath struct {
	ProductPath
	Upload string `path:"upload" format:"uuid"`
}

UploadPath is an upload of a product.

type UploadStart

type UploadStart struct {
	Name string `json:"name" minLength:"1" maxLength:"255"`
	Size int64  `json:"size" minimum:"1"`
	// Replaces is a file the new one replaces once it finished uploading.
	Replaces string `json:"replaces,omitempty" format:"uuid"`
}

UploadStart announces a file.

type UploadState

type UploadState struct {
	ID         string `json:"id"`
	Received   int64  `json:"received"`
	Size       int64  `json:"size"`
	ChunkBytes int64  `json:"chunkBytes"`
}

UploadState is where an upload stands.

Jump to

Keyboard shortcuts

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