node

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 52 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 node implements an OBX brand node: the OBX Protocol (read side), the OBX Ingest API (write side), the Node Admin + Portal API used by the shared admin-ui, imports, renditions, exports, webhooks and statistics.

Index

Constants

View Source
const (
	Software    = "obx-node-go"
	SpecVersion = "0.2.0"
	OBXVersion  = "0.2"
)

Software and Version identify this implementation in discovery.

View Source
const (
	MaxUploadBytes     int64 = 100 << 20
	MaxObjectBytes     int64 = 2 << 30
	PartBytes          int64 = 8 << 20
	MaxBatchOperations       = 1000
	MaxImportBytes     int64 = 2 << 30
)

Limits advertised in IngestInfo (docs/ingest.md §9).

View Source
const (
	KindBrand   = "brand"
	KindProduct = "product"
	KindVariant = "variant"
	KindAsset   = "asset"
)

Kinds of catalog objects.

Variables

View Source
var AllScopes = []string{"catalog:read", "media:read", "media:original", "usage:write"}

AllScopes are the protocol scopes.

View Source
var DerivedRenditions = []string{"web", "square", "thumb"}

DerivedRenditions are the renditions derived from the original.

View Source
var RenditionNames = []string{"original", "web", "square", "thumb"}

RenditionNames in canonical order.

View Source
var SupportedLanguages = []string{"bg", "cs", "da", "de", "el", "en", "es", "et", "fi", "fr", "ga", "hr", "hu", "it", "lt", "lv", "mt", "nl", "nb", "pl", "pt", "ro", "sk", "sl", "sv"}

SupportedLanguages are the UI/e-mail languages.

View Source
var Version = "0.2.0-dev"

Version is set at build time (-ldflags "-X .../node.Version=...").

Functions

func LogHandler

func LogHandler(h slog.Handler) slog.Handler

LogHandler wraps a slog handler so that every record logged with a request context carries request_id.

func RequestID

func RequestID(ctx context.Context) string

RequestID returns the id of the request that ctx belongs to ("" outside a request).

func ValidExternalID

func ValidExternalID(s string) (string, bool)

ValidExternalID checks the ExternalId rules (1-200 chars, no control characters, no '/'); the value is trimmed first.

Types

type App

type App struct {
	Cfg    *config.Config
	DB     *db.DB
	Store  blobstore.Store
	Keys   *secure.Keys
	Log    *slog.Logger
	Mail   Mailer
	Policy safehttp.Policy
	UI     fs.FS // admin-ui build (index.html, assets, locales)

	// Now can be replaced in tests.
	Now func() time.Time
	// contains filtered or unexported fields
}

App holds the node's shared state.

func New

func New(ctx context.Context, cfg *config.Config, ui fs.FS, log *slog.Logger) (*App, error)

New opens the database and blob store, migrates, and prepares the node.

func (*App) Audit

func (a *App) Audit(ctx context.Context, action, targetType, targetID string)

Audit records an action done on the command line.

func (*App) AuditLog

func (a *App) AuditLog(ctx context.Context, limit int) ([]map[string]any, error)

AuditLog returns the latest entries (command line).

func (*App) Backup

func (a *App) Backup(ctx context.Context, dir string) (*BackupManifest, error)

Backup writes a consistent copy of the node to dir (which must be empty or missing): the SQLite database as one file (VACUUM INTO, safe while the node runs), the local files and the secret key. Files in a bucket and a PostgreSQL database are not copied; the manifest says so.

func (*App) Changes

func (a *App) Changes(ctx context.Context, v *Viewer, cursor string, limit int) (*ChangesPage, *problem.Problem, error)

Changes returns one feed page for viewer v.

func (*App) Close

func (a *App) Close() error

Close releases resources (after Stop).

func (*App) CreateIngestToken

func (a *App) CreateIngestToken(ctx context.Context, name string, scopes, brands []string, expiresAt *string) (*ingestToken, string, *problem.Problem)

CreateIngestToken creates a token (admin API and CLI).

func (*App) Handler

func (a *App) Handler() http.Handler

Handler returns the node's HTTP handler.

func (*App) HasBlob

func (a *App) HasBlob(ctx context.Context, sha string) bool

HasBlob reports whether the node has the bytes.

func (*App) ImportErrors

func (a *App) ImportErrors(ctx context.Context, jobID string, max int) []string

ImportErrors returns human-readable problems of an import run.

func (*App) ImportLocal

func (a *App) ImportLocal(ctx context.Context, li LocalImport) (map[string]any, error)

ImportLocal stages local files, runs the import and returns the ImportRun.

func (*App) LastMails

func (a *App) LastMails() []SentMail

LastMails returns captured mails (log driver only).

func (*App) NodeID

func (a *App) NodeID() string

NodeID returns the publisher id.

func (*App) PersonalData

func (a *App) PersonalData(ctx context.Context, email, retailerID string) (map[string]any, error)

PersonalData exports a retailer (id) or an account (e-mail) for the CLI.

func (*App) PortalName

func (a *App) PortalName(ctx context.Context, lang string) string

PortalName returns "<Brand> · <local word>" for lang. The word is the brand's own portal_name (language fallback rule) or the glossary word from the vendored admin-ui locale files.

func (*App) PutBlob

func (a *App) PutBlob(ctx context.Context, r io.Reader, declaredSHA string, limit int64) (*Blob, error)

PutBlob stores an uploaded image. declaredSHA (may be "") is verified. Only accepted image types (by magic bytes) are stored.

func (*App) PutBlobBytes

func (a *App) PutBlobBytes(ctx context.Context, data []byte) (*Blob, error)

PutBlobBytes stores in-memory bytes (renditions, imports).

func (*App) RenderOriginal

func (a *App) RenderOriginal(ctx context.Context, sha string) error

RenderOriginal makes web/square/thumb for an original (idempotent) and updates the assets waiting for them.

func (a *App) ResetLink(ctx context.Context, email string) (string, error)

ResetLink creates a one-time password reset link (CLI).

func (*App) RunJobsNow

func (a *App) RunJobsNow(ctx context.Context)

RunJobsNow runs queued jobs synchronously (CLI and tests).

func (*App) SetDraining

func (a *App) SetDraining()

SetDraining marks the node as shutting down: /readyz answers 503 so load balancers stop sending new requests while running ones finish.

func (*App) SetPassword

func (a *App) SetPassword(ctx context.Context, email, password string) error

SetPassword sets a password directly (CLI) and ends all sessions.

func (*App) Settings

func (a *App) Settings(ctx context.Context) *Settings

Settings returns the current settings (cached; invalidated on save).

func (*App) SetupDone

func (a *App) SetupDone(ctx context.Context) bool

SetupDone reports whether first-run setup completed.

func (*App) Start

func (a *App) Start()

Start launches the background workers. With SQLite the node is the only instance, so jobs that were running when the previous process stopped are queued again right away (every job kind is safe to run again).

func (*App) Stop

func (a *App) Stop()

Stop stops the background workers (running jobs finish their step).

func (*App) WriteOp

func (a *App) WriteOp(ctx context.Context, allowedBrands []string, fn func(w *writer) (*IngestResult, *problem.Problem)) (*IngestResult, *problem.Problem)

WriteOp runs one catalog operation in its own transaction. A failed operation is rolled back completely (no change entries).

type Asset

type Asset struct {
	ID          string                `json:"id"`
	ExternalID  string                `json:"external_id"`
	ProductID   string                `json:"product_id"`
	BrandID     string                `json:"brand_id"`
	MediaType   string                `json:"media_type"`
	ColorCode   *string               `json:"color_code"`
	VariantIDs  []string              `json:"variant_ids"`
	Role        string                `json:"role"`
	View        *string               `json:"view"`
	Position    int                   `json:"position"`
	Filename    string                `json:"filename"`
	AltText     LocalizedText         `json:"alt_text"`
	ContentType string                `json:"content_type"`
	Width       int                   `json:"width"`
	Height      int                   `json:"height"`
	Bytes       int64                 `json:"bytes"`
	SHA256      string                `json:"sha256"`
	Rights      Rights                `json:"rights"`
	Provenance  Provenance            `json:"provenance"`
	Renditions  map[string]*Rendition `json:"renditions"`
	UpdatedAt   string                `json:"updated_at"`
}

Asset is the protocol Asset.

type AssetData

type AssetData struct {
	ProductExternalID  string                     `json:"product_external_id"`
	ColorCode          *string                    `json:"color_code"`
	VariantExternalIDs []string                   `json:"variant_external_ids"`
	MediaType          string                     `json:"media_type"`
	Role               string                     `json:"role"`
	View               *string                    `json:"view"`
	Position           int                        `json:"position"`
	Filename           *string                    `json:"filename"`
	AltText            LocalizedText              `json:"alt_text"`
	Rights             map[string]json.RawMessage `json:"rights"`
	Provenance         map[string]json.RawMessage `json:"provenance"`
	Files              map[string]FileRef         `json:"files"`
}

AssetData is the stored AssetInput (without status). Rights and provenance keep only the fields the brand sent (omitted = node default).

type BackupManifest

type BackupManifest struct {
	Format            int    `json:"format"`
	CreatedAt         string `json:"created_at"`
	NodeGoVersion     string `json:"node_go_version"`
	SchemaVersion     int    `json:"schema_version"`
	NodeID            string `json:"node_id"`
	Database          string `json:"database"` // "obx.db" or a note
	Files             string `json:"files"`    // "blobs" or a note
	FileCount         int    `json:"file_count"`
	SecretKey         string `json:"secret_key"` // "secret.key" or a note
	SecretFingerprint string `json:"secret_fingerprint"`
}

BackupManifest describes a backup directory made by "node-go backup".

func Restore

func Restore(cfg *config.Config, dir string, force bool) (*BackupManifest, error)

Restore puts a backup made by Backup in place for cfg. The node must not be running. Without force it refuses to overwrite an existing database. It does not start the node; the next start opens the restored data.

type Blob

type Blob struct {
	SHA256      string `json:"sha256"`
	Bytes       int64  `json:"bytes"`
	ContentType string `json:"content_type"`
	Width       *int   `json:"width"`
	Height      *int   `json:"height"`
	Created     bool   `json:"created"`
}

Blob is the Blob schema.

type Brand

type Brand struct {
	ID          string        `json:"id"`
	ExternalID  string        `json:"external_id"`
	Name        string        `json:"name"`
	LogoURL     *string       `json:"logo_url"`
	Website     *string       `json:"website"`
	Description LocalizedText `json:"description"`
	UpdatedAt   string        `json:"updated_at"`
}

Brand is the protocol Brand.

type BrandData

type BrandData struct {
	Name        string        `json:"name"`
	LogoURL     *string       `json:"logo_url"`
	Website     *string       `json:"website"`
	Description LocalizedText `json:"description"`
}

BrandData is the stored BrandInput (without status).

type CareItem

type CareItem struct {
	Code string        `json:"code"`
	Text LocalizedText `json:"text"`
}

CareItem is one care instruction.

type Certification added in v0.2.0

type Certification struct {
	Scheme        string  `json:"scheme"`
	LicenceNumber *string `json:"licence_number"`
	Scope         string  `json:"scope"`
}

Certification is one voluntary certification the brand states.

type Change

type Change struct {
	Seq        int64   `json:"seq"`
	Type       string  `json:"type"`
	Op         string  `json:"op"`
	ID         string  `json:"id"`
	ExternalID *string `json:"external_id"`
	BrandID    *string `json:"brand_id"`
	ProductID  *string `json:"product_id"`
	UpdatedAt  string  `json:"updated_at"`
	Data       any     `json:"data,omitempty"`
	Resync     *bool   `json:"resync,omitempty"`
}

Change is one feed entry.

type ChangesPage

type ChangesPage struct {
	Changes    []Change `json:"changes"`
	NextCursor string   `json:"next_cursor"`
	HasMore    bool     `json:"has_more"`
	Phase      string   `json:"phase"`
}

ChangesPage is one page of the feed.

type Color

type Color struct {
	Code          string        `json:"code"`
	Name          LocalizedText `json:"name"`
	SupplierColor *string       `json:"supplier_color"`
	Family        *string       `json:"family"`
}

Color of a variant.

type Features added in v0.2.0

type Features map[string]any

Features are the typed product features (registry keys and other keys, values as decoded from JSON); nil marshals as null.

type Fiber

type Fiber struct {
	Fiber      string  `json:"fiber"`
	Percentage float64 `json:"percentage"`
	Recycled   bool    `json:"recycled,omitempty"`
	Organic    bool    `json:"organic,omitempty"`
}

Fiber is one fibre of a material part.

type FileRef

type FileRef struct {
	SHA256 string `json:"sha256"`
	Width  *int   `json:"width"`
	Height *int   `json:"height"`
}

FileRef references a blob in AssetData.files.

type FootwearMaterials added in v0.2.0

type FootwearMaterials struct {
	Upper         *string `json:"upper"`
	LiningAndSock *string `json:"lining_and_sock"`
	OuterSole     *string `json:"outer_sole"`
}

FootwearMaterials is the material of the three parts of a shoe (Directive 94/11/EC); responses always include all three parts.

type Grant

type Grant struct {
	ID              string     `json:"id"`
	Retailer        GrantParty `json:"retailer"`
	BrandIDs        []string   `json:"brand_ids"`
	Scopes          []string   `json:"scopes"`
	OriginalAllowed bool       `json:"original_allowed"`
	Status          string     `json:"status"`
	UpdatedAt       string     `json:"updated_at"`
}

Grant is the protocol Grant.

type GrantParty

type GrantParty struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

GrantParty names the retailer of a grant.

type ImportRowError

type ImportRowError struct {
	File     string  `json:"file"`
	Row      *int    `json:"row"`
	Column   *string `json:"column"`
	Severity string  `json:"severity"`
	ObxError string  `json:"obx_error"`
	Detail   string  `json:"detail"`
	Value    *string `json:"value"`
}

ImportRowError is one problem found while importing.

type IngestRecord

type IngestRecord struct {
	Kind         string         `json:"kind"`
	ID           string         `json:"id"`
	ExternalID   string         `json:"external_id"`
	Status       string         `json:"status"`
	Visibility   string         `json:"visibility"`
	ETag         string         `json:"etag"`
	CreatedAt    string         `json:"created_at"`
	UpdatedAt    string         `json:"updated_at"`
	Data         map[string]any `json:"data"`
	MissingFiles *[]string      `json:"missing_files,omitempty"` // assets only; [] when complete
}

IngestRecord is the GET representation in the ingest API and admin catalog.

type IngestResult

type IngestResult struct {
	Index      *int     `json:"index,omitempty"`
	Op         string   `json:"op"`
	Kind       string   `json:"kind"`
	ExternalID string   `json:"external_id"`
	Result     string   `json:"result"`
	ID         *string  `json:"id"`
	Visibility *string  `json:"visibility"`
	ETag       *string  `json:"etag"`
	Error      any      `json:"error"`
	Warnings   []string `json:"warnings,omitempty"`
	// WarningDetails are the warnings with a stable code (label
	// completeness); each is also in Warnings as text.
	WarningDetails []WarningDetail `json:"warning_details,omitempty"`
}

IngestResult is the result of one ingest write.

type LiveFile

type LiveFile struct {
	SHA256      string `json:"sha256"`
	ContentType string `json:"content_type"`
	Width       int    `json:"width"`
	Height      int    `json:"height"`
	Bytes       int64  `json:"bytes"`
}

LiveFile is one resolved file of an asset (stored in assets.live_files).

type LocalImport

type LocalImport struct {
	CSV, AssetsCSV, Images, Package string
	Mode                            string
	AllowMassUnpublish, DryRun      bool
}

LocalImport describes an import from local files (CLI).

type LocalizedText

type LocalizedText map[string]string

LocalizedText is text per BCP 47 tag. nil marshals as null.

func (LocalizedText) Pick

func (t LocalizedText) Pick(lang string, order ...string) string

Pick returns the text for lang with the shared fallback rule: the requested language, then English, then the first available language (in the node's content-language order, then alphabetical).

type Mailer

type Mailer interface {
	Send(ctx context.Context, to, subject, body string) error
	Configured() bool
}

Mailer sends e-mail.

type MaterialPart

type MaterialPart struct {
	Part   string  `json:"part"`
	Fibers []Fiber `json:"fibers"`
}

MaterialPart is the composition of one part.

type Measurements added in v0.2.0

type Measurements struct {
	HeightCM        *float64 `json:"height_cm,omitempty"`
	WidthCM         *float64 `json:"width_cm,omitempty"`
	DepthCM         *float64 `json:"depth_cm,omitempty"`
	WeightKG        *float64 `json:"weight_kg,omitempty"`
	VolumeL         *float64 `json:"volume_l,omitempty"`
	VolumeExpandedL *float64 `json:"volume_expanded_l,omitempty"`
	HandleDropCM    *float64 `json:"handle_drop_cm,omitempty"`
	StrapLengthCM   *Range   `json:"strap_length_cm,omitempty"`
	LaptopMaxInch   *float64 `json:"laptop_max_inch,omitempty"`
	HeelHeightCM    *float64 `json:"heel_height_cm,omitempty"`
	ShaftHeightCM   *float64 `json:"shaft_height_cm,omitempty"`
	InseamCM        *float64 `json:"inseam_cm,omitempty"`
}

Measurements of one variant; nil members are not stated and left out.

func (*Measurements) Cell added in v0.2.0

func (m *Measurements) Cell(key string) string

Cell returns one measurement as a products.csv cell ("" when not stated).

type Product

type Product struct {
	ID                   string             `json:"id"`
	ExternalID           string             `json:"external_id"`
	BrandID              string             `json:"brand_id"`
	StyleNumber          string             `json:"style_number"`
	Name                 LocalizedText      `json:"name"`
	Description          LocalizedText      `json:"description"`
	ItemType             *string            `json:"item_type"`
	ItemSubtype          *string            `json:"item_subtype"`
	GPCBrick             *string            `json:"gpc_brick"`
	TargetGroup          *string            `json:"target_group"`
	Season               *string            `json:"season"`
	Collection           *string            `json:"collection"`
	Materials            []MaterialPart     `json:"materials"`
	ContainsAnimalOrigin *bool              `json:"contains_animal_origin"`
	FootwearMaterials    *FootwearMaterials `json:"footwear_materials"`
	Care                 []CareItem         `json:"care"`
	CountryOfOrigin      *string            `json:"country_of_origin"`
	Certifications       []Certification    `json:"certifications"`
	DPPURL               *string            `json:"dpp_url"`
	Features             Features           `json:"features"`
	Attributes           map[string]any     `json:"attributes"`
	CreatedAt            string             `json:"created_at"`
	UpdatedAt            string             `json:"updated_at"`
	Variants             *[]Variant         `json:"variants,omitempty"`
	Assets               *[]Asset           `json:"assets,omitempty"`
}

Product is the protocol Product (Variants/Assets set = ProductDetail).

type ProductData

type ProductData struct {
	BrandExternalID      string             `json:"brand_external_id"`
	StyleNumber          string             `json:"style_number"`
	Name                 LocalizedText      `json:"name"`
	Description          LocalizedText      `json:"description"`
	ItemType             *string            `json:"item_type"`
	ItemSubtype          *string            `json:"item_subtype"`
	GPCBrick             *string            `json:"gpc_brick"`
	TargetGroup          *string            `json:"target_group"`
	Season               *string            `json:"season"`
	Collection           *string            `json:"collection"`
	Materials            []MaterialPart     `json:"materials"`
	ContainsAnimalOrigin *bool              `json:"contains_animal_origin"`
	FootwearMaterials    *FootwearMaterials `json:"footwear_materials"`
	Care                 []CareItem         `json:"care"`
	CountryOfOrigin      *string            `json:"country_of_origin"`
	Certifications       []Certification    `json:"certifications"`
	DPPURL               *string            `json:"dpp_url"`
	Features             Features           `json:"features"`
	Attributes           map[string]any     `json:"attributes"`
}

ProductData is the stored ProductInput (without status).

type Provenance

type Provenance struct {
	AIGenerated     bool    `json:"ai_generated"`
	AIEdited        bool    `json:"ai_edited"`
	Source          string  `json:"source"`
	C2PA            string  `json:"c2pa"`
	C2PAManifestURL *string `json:"c2pa_manifest_url"`
	Generator       *string `json:"generator"`
}

Provenance is the effective provenance object.

type Range added in v0.2.0

type Range struct {
	Min float64 `json:"min"`
	Max float64 `json:"max"`
}

Range is a shortest and longest setting (strap_length_cm).

type Rendition

type Rendition struct {
	Name         string  `json:"name"`
	URL          string  `json:"url"`
	URLExpiresAt *string `json:"url_expires_at"`
	ContentType  string  `json:"content_type"`
	Width        int     `json:"width"`
	Height       int     `json:"height"`
	Bytes        int64   `json:"bytes"`
	SHA256       string  `json:"sha256"`
}

Rendition is one downloadable file of an asset.

type Rights

type Rights struct {
	License      string   `json:"license"`
	LicenseText  *string  `json:"license_text"`
	Channels     []string `json:"channels"`
	Territories  []string `json:"territories"`
	EmbargoUntil *string  `json:"embargo_until"`
	ExpiresAt    *string  `json:"expires_at"`
	Credit       *string  `json:"credit"`
	ModelRelease *bool    `json:"model_release"`
}

Rights is the effective rights object.

func DefaultRights

func DefaultRights() Rights

DefaultRights are the protocol default rights (docs/protocol.md §5.6).

type SentMail

type SentMail struct{ To, Subject, Body string }

SentMail is a mail captured by the log driver (tests).

type Settings

type Settings struct {
	Company struct {
		Name         string  `json:"name"`
		Website      *string `json:"website"`
		ContactEmail *string `json:"contact_email"`
		Country      *string `json:"country"`
	} `json:"company"`
	Branding struct {
		DisplayName string        `json:"display_name"`
		LogoURL     *string       `json:"logo_url"`
		AccentColor *string       `json:"accent_color"`
		WelcomeText LocalizedText `json:"welcome_text"`
		// PortalName overrides the local word in "<Brand> · <local word>",
		// per language (optional; same shape as admin-ui expects).
		PortalName LocalizedText `json:"portal_name"`
	} `json:"branding"`
	Portal struct {
		AccessRequestsEnabled  bool     `json:"access_requests_enabled"`
		AllowOriginalDownload  bool     `json:"allow_original_download"`
		AllowArticleDataExport bool     `json:"allow_article_data_export"`
		RetailerAPISelfService bool     `json:"retailer_api_self_service"`
		Languages              []string `json:"languages"`
		DefaultLanguage        string   `json:"default_language"`
	} `json:"portal"`
	Defaults struct {
		Rights       Rights `json:"rights"`
		IngestStatus string `json:"ingest_status"`
	} `json:"defaults"`
	// Retention of personal and usage data, in days (the same settings as
	// the other OBX portals; docs/operations.md#personal-data-gdpr).
	Retention struct {
		DownloadEventsDays int `json:"download_events_days"`
		AuditLogDays       int `json:"audit_log_days"`
		AccessRequestsDays int `json:"access_requests_days"`
	} `json:"retention"`
	// LogoSHA is the blob hash of the uploaded logo (internal).
	LogoSHA string `json:"logo_sha,omitempty"`
	// LogoType is the logo media type (internal).
	LogoType string `json:"logo_type,omitempty"`
}

Settings is the brand's node configuration (admin Settings, minus the read-only `node` facts which are computed).

func (*Settings) ContentLanguages

func (s *Settings) ContentLanguages() []string

Languages returns the content languages (first = default).

type Variant

type Variant struct {
	ID           string        `json:"id"`
	ExternalID   string        `json:"external_id"`
	ProductID    string        `json:"product_id"`
	BrandID      string        `json:"brand_id"`
	GTIN         *string       `json:"gtin"`
	GTINOriginal *string       `json:"gtin_original"`
	SKU          *string       `json:"sku"`
	Color        Color         `json:"color"`
	Size         *string       `json:"size"`
	SizeLength   *string       `json:"size_length"`
	SizeSystem   *string       `json:"size_system"`
	Measurements *Measurements `json:"measurements"`
	UpdatedAt    string        `json:"updated_at"`
}

Variant is the protocol Variant.

type VariantData

type VariantData struct {
	ProductExternalID string        `json:"product_external_id"`
	GTIN              *string       `json:"gtin"`
	SKU               *string       `json:"sku"`
	Color             Color         `json:"color"`
	Size              *string       `json:"size"`
	SizeLength        *string       `json:"size_length"`
	SizeSystem        *string       `json:"size_system"`
	Measurements      *Measurements `json:"measurements"`
}

VariantData is the stored VariantInput (without status).

type Viewer

type Viewer struct {
	Kind            string // client | user | admin
	RetailerID      string
	RetailerName    string
	BrandIDs        []string // nil = all published brands
	OriginalAllowed bool
	Scopes          map[string]bool
	ClientRowID     string
	ClientName      string
	UserID          string
	UserName        string
	Language        string
}

Viewer is whoever reads the catalog: a retailer's API client, a retailer user in the portal, or a brand admin previewing the portal.

func (*Viewer) Preview

func (v *Viewer) Preview() bool

Preview reports whether this is a brand admin looking at the portal.

func (*Viewer) SeesBrand

func (v *Viewer) SeesBrand(brandID string) bool

SeesBrand reports whether the brand is inside the viewer's grant.

type WarningDetail added in v0.2.0

type WarningDetail struct {
	Code    string  `json:"code"`
	Pointer *string `json:"pointer"`
	Detail  string  `json:"detail"`
	// contains filtered or unexported fields
}

WarningDetail is a warning with a stable code (IngestResult.warning_details).

Jump to

Keyboard shortcuts

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