Documentation
¶
Overview ¶
Package catalog implements EdgeFetch's pure-CPU e-commerce sanitization, Shopify and WooCommerce product/feed normalization, polite storefront catalog pagination, deterministic FNV-1a/SHA-256 snapshot hashing and diffing, shrink-guard detection, UCP discovery, record filtering, and bounded multi-tenant catalog state.
All files in this package compile cleanly under both native targets and GOOS=wasip1 GOARCH=wasm without importing net/http, crypto/tls, or crypto/x509.
Index ¶
- Constants
- Variables
- func ApproxHashBundleBytes(hashes *SnapshotHashBundle) int
- func ApproxUTF8Bytes(s string) int
- func CatalogSpecFirstPage(cfg DeclarativeCatalogConfig, originURLStr, collection string) (string, error)
- func CatalogSpecNextPage(cfg DeclarativeCatalogConfig, prevURL, body string, pageIndex int, ...) (string, error)
- func ComputeCatalogProductHash(rec CatalogRecord) string
- func ComputeCatalogVariantHash(v CatalogVariantRecord) string
- func ConvertCommerceHTMLFragmentToMD(frag, baseURL string) string
- func DecompressGzipBounded(raw []byte, maxBytes int) ([]byte, error)
- func EncodeURIComponent(s string) string
- func EvaluateShrinkGuard(prevProductsCount, currProductsCount int) (warning string, previousProducts int, shrunk bool)
- func ExtractEditorJSPlainTextGo(raw string) string
- func ExtractShopifyCurrencyFromHTML(rawHTML string) string
- func FormatGFMTable(headers []string, rows [][]string) string
- func FormatMarkdownLinkCommerce(label, rawURL string) string
- func FormatMedusaPriceAmountGo(amount float64, currency string, isMinorUnits bool) (float64, bool)
- func GenerateCatalogID() string
- func InitCatalogPullPlan(req CatalogInitRequest) (*CatalogPullPlan, *CatalogValidationError)
- func IsAllowedStoreRedirectURL(finalURLStr, requestedOriginStr, selfHost string) bool
- func IsBigCommerceHTMLOrHeaders(rawHTML string, headers map[string]string) bool
- func IsChallengePageResponse(status int, outcome, problem string, headers map[string]string, body string) bool
- func IsMagento2HTMLOrHeaders(rawHTML string, headers map[string]string) bool
- func IsNonStorefrontHTMLFallback(status int, outcome, problem string, headers map[string]string, ...) bool
- func IsRobotsOrSignalBlocked(outcome, problem string) string
- func IsSFCCDemandwareHTMLOrHeaders(rawHTML string, headers map[string]string) bool
- func IsSafeHTTPSStoreURL(urlStr, selfHost string) (*url.URL, bool)
- func IsSafePublicHostname(rawHost, selfHost string) bool
- func IsShopifyHTMLOrHeaders(rawHTML string, headers map[string]string) bool
- func IsShopware6HTMLOrHeaders(rawHTML string, headers map[string]string) bool
- func IsSquarespaceCommerceHTMLOrHeaders(rawHTML string, headers map[string]string) bool
- func IsTemplateNoiseGo(s string) bool
- func IsValidCatalogID(id string) bool
- func IsWooCommerceHTMLOrHeaders(rawHTML string, headers map[string]string) bool
- func NormalizePublicCommerceImageURL(raw any) string
- func ParseRetryAfterMs(retryAfterMs *float64, headers map[string]string, defaultMs int, nowMs int64) int
- func ParseShopifyCurrencyProbe(rawBody string) string
- func ResolveMagento2RenderInfoTwinURL(pageURL, rawHTML string) string
- func ResolveSquarespaceCommerceTwinURL(rawURL string) string
- func SafeDecodeURIComponent(raw string) (string, bool)
- func SanitizeCommerceField(raw any, maxLen int) string
- func SanitizeCommerceTimestamp(raw any, maxLen int) *string
- func SerializeRecordsNDJSON(records []CatalogRecord) string
- func StripTagsInlineCommerce(rawHTML string) string
- type CatalogFilterOutput
- type CatalogInitRequest
- type CatalogOption
- type CatalogPageEvalInput
- type CatalogPageEvalOutput
- type CatalogPullPlan
- type CatalogRecord
- func ApplyShopifyCurrencyBackfill(records []CatalogRecord, currency string) []CatalogRecord
- func CatalogSpecParsePage(cfg DeclarativeCatalogConfig, body, originStr, fields string, ...) ([]CatalogRecord, bool, error)
- func ClampCatalogRecord(rec CatalogRecord) (CatalogRecord, int)
- func NormalizeShopifyProductRecord(rawProd map[string]any, originStr string, opts *ShopifyNormalizeOptions) *CatalogRecord
- func NormalizeWooCommerceProductRecord(rawProd map[string]any, originStr string, opts *WooNormalizeOptions) *CatalogRecord
- func ParseRecordsNDJSON(ndjson string) ([]CatalogRecord, int)
- type CatalogRecordFilter
- type CatalogRunStatus
- type CatalogSnapshotDiff
- type CatalogStatusSummary
- type CatalogStore
- func (s *CatalogStore) AcquireConcurrencySlot(tenant CatalogTenantInfo) (func(), bool)
- func (s *CatalogStore) FindPreviousCompleteBaseline(userID, origin, collection, excludeCatalogID string) (int, *SnapshotHashBundle, bool)
- func (s *CatalogStore) GetCachedOriginCurrency(origin string, now time.Time) (string, bool)
- func (s *CatalogStore) GetRun(catalogID, ownerKey string) (*StoredCatalogRun, bool)
- func (s *CatalogStore) MemoryStats() MemoryUsageStats
- func (s *CatalogStore) ReloadRecordsCoalesced(ctx context.Context, artifactID string, ...) ([]CatalogRecord, error)
- func (s *CatalogStore) RememberRun(entry StoredCatalogRun)
- func (s *CatalogStore) SetCachedOriginCurrency(origin, currency string, ttl time.Duration, now time.Time)
- type CatalogTenantInfo
- type CatalogUCPMetadata
- type CatalogValidationError
- type CatalogVariantDiffCounts
- type CatalogVariantRecord
- type ClampedRecordItem
- type DeclarativeCatalogConfig
- type DetailedCatalogSnapshotDiff
- type FetchFunc
- type FetchRequest
- type FetchResponse
- type LeanCatalogRecord
- type MemoryUsageStats
- type PaginationInfo
- type PostFetchSiteResult
- func ExtractBigCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractMagento2ProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractSFCCProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractShopifyProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractShopware6ProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractShopwareOrMagentoHTML(rawURL, rawHTML, currentMD, extractorID string) *PostFetchSiteResult
- func ExtractSmartEtailingHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractSquarespaceCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractWave2aCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractWave2bCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractWooCommerceCatalogHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- func ExtractWooCommerceProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
- type SFCCSpecTable
- type SFCCTwinURL
- type ShopifyCollectionTwinURL
- type ShopifyEnrichParams
- type ShopifyFeedFormatOptions
- type ShopifyNormalizeOptions
- type ShopifyProductTwinURLs
- type SnapshotHashBundle
- type StoredCatalogRun
- type TwinFormattedDoc
- func EnrichShopifyProductFromJSON(params ShopifyEnrichParams) *TwinFormattedDoc
- func EnrichWooCommerceProductFromStoreAPI(params WooEnrichParams) *TwinFormattedDoc
- func FormatBigCartelJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatBigCommerceXMLSitemap(rawBody, origURL string) *TwinFormattedDoc
- func FormatEcwidV3JSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatHCLWCSProductJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatLightspeedEcomJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatMagento2RenderInfoJSON(rawBody, origURL, fallbackHTML string) *TwinFormattedDoc
- func FormatMedusaProductJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatOracleCommerceProductJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatPrestaShopQuickviewJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatSAPOCCProductJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatSFCCProductVariationJSON(rawBody, origURL, fallbackHTML, _ string) *TwinFormattedDoc
- func FormatSaleorGraphQLJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatShopifyProductsFeedTwin(rawBody, origURL string, opts ...ShopifyFeedFormatOptions) *TwinFormattedDoc
- func FormatSpreeSolidusJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatSquarespaceCommerceJSON(rawBody, origURL string) *TwinFormattedDoc
- func FormatVTEXProductJSON(rawJSON, origURL string) *TwinFormattedDoc
- func FormatWCStoreAPIListTwin(rawBody, origURL string) *TwinFormattedDoc
- func FormatWCStoreAPIListTwinWithOptions(rawBody, origURL, twinURL string) *TwinFormattedDoc
- func FormatWCStoreAPIProductTwin(rawBody, origURL string) *TwinFormattedDoc
- func FormatWave2aCommerceMode(mode, rawJSON, origURL string) *TwinFormattedDoc
- func FormatWave2bCommerceMode(mode, rawJSON, origURL string) *TwinFormattedDoc
- type WooCommerceCatalogTwinURL
- type WooCommerceProductTwinURL
- type WooEnrichParams
- type WooNormalizeOptions
Constants ¶
const ( DefaultMaxImagesPerProduct = 250 DefaultMaxVariantsPerProduct = 250 MaxCatalogInMemoryBytes = 16 * 1024 * 1024 MaxGlobalCatalogBytes = 32 * 1024 * 1024 MaxPerUserCatalogBytes = 8 * 1024 * 1024 MaxCachedCatalogRuns = 16 MaxCachedCatalogRunsPerUser = 4 MaxConcurrentCatalogPerPrincipal = 2 MaxConcurrentCatalogGlobal = 8 MaxConcurrentCatalogNonOwner = 6 MaxConcurrentR2Reloads = 2 MaxCatalogTotalSleepMs = 120_000 MaxCatalogWallMs = 120_000 MaxR2DecompressedBytes = 32 * 1024 * 1024 MaxR2CacheableArtifactBytes = 8 * 1024 * 1024 MaxVariantsPerCatalogRun = 50_000 MaxRecordSerializedBytes = 64 * 1024 MaxCompactHistoryRuns = 256 MaxCompactHistoryRunsPerUser = 32 )
Variables ¶
var ValidCatalogPlatforms = map[string]bool{ "shopify": true, "woocommerce": true, }
ValidCatalogPlatforms is the strict allowlist of declarative catalog platforms.
Functions ¶
func ApproxHashBundleBytes ¶
func ApproxHashBundleBytes(hashes *SnapshotHashBundle) int
ApproxHashBundleBytes estimates the in-memory footprint in bytes of a SnapshotHashBundle.
func ApproxUTF8Bytes ¶
ApproxUTF8Bytes returns the UTF-8 byte length of s.
func CatalogSpecFirstPage ¶
func CatalogSpecFirstPage(cfg DeclarativeCatalogConfig, originURLStr, collection string) (string, error)
CatalogSpecFirstPage builds the first pagination URL for a validated DeclarativeCatalogConfig.
func CatalogSpecNextPage ¶
func CatalogSpecNextPage(cfg DeclarativeCatalogConfig, prevURL, body string, pageIndex int, headers map[string]string) (string, error)
CatalogSpecNextPage resolves the next page URL (or `""` when pagination is finished) for Shopify or WooCommerce.
func ComputeCatalogProductHash ¶
func ComputeCatalogProductHash(rec CatalogRecord) string
ComputeCatalogProductHash computes a deterministic content hash for a CatalogRecord, explicitly ignoring `updatedAt` and `publishedAt` so inventory timestamp bumps do not cause false `changed` diffs.
func ComputeCatalogVariantHash ¶
func ComputeCatalogVariantHash(v CatalogVariantRecord) string
ComputeCatalogVariantHash computes a deterministic content hash for a single variant.
func ConvertCommerceHTMLFragmentToMD ¶
ConvertCommerceHTMLFragmentToMD converts an HTML description fragment into sanitized Markdown using Go's full HTML extractor (`extract.ExtractHTMLDocumentFull`) with images enabled.
func DecompressGzipBounded ¶
DecompressGzipBounded gunzips raw bytes with a hard decompressed ceiling (`maxBytes`), immediately aborting if decompressed output exceeds `maxBytes`.
func EncodeURIComponent ¶
EncodeURIComponent matches JavaScript's `encodeURIComponent` (unreserved: A-Z a-z 0-9 - _ . ! ~ * ' ( )).
func EvaluateShrinkGuard ¶
func EvaluateShrinkGuard(prevProductsCount, currProductsCount int) (warning string, previousProducts int, shrunk bool)
EvaluateShrinkGuard checks whether the current snapshot dropped strictly below 50% (`>50%` drop) of the previous trusted complete snapshot (`currCount < prevCount * 0.5`).
func ExtractEditorJSPlainTextGo ¶ added in v2.8.29
ExtractEditorJSPlainTextGo decodes Saleor-style EditorJS JSON (`{"blocks":[{"type":"paragraph","data":{"text":"..."}}]}`) into clean sanitized plain text / Markdown, falling back cleanly if raw is already HTML or plain text.
func ExtractShopifyCurrencyFromHTML ¶
ExtractShopifyCurrencyFromHTML extracts a 3-letter ISO currency code from Shopify HTML globals, OpenGraph meta, or JSON-LD.
func FormatGFMTable ¶
FormatGFMTable formats headers and string rows into a GitHub-Flavored Markdown table.
func FormatMarkdownLinkCommerce ¶
FormatMarkdownLinkCommerce safely formats `[label](url)` by escaping brackets/angle-brackets and odd trailing backslashes in `label`, and percent-encoding unsafe URL delimiters in `rawURL`.
func FormatMedusaPriceAmountGo ¶ added in v2.8.29
FormatMedusaPriceAmountGo normalizes Medusa v1 minor-unit integer/cent amounts vs v2 major-unit calculated amounts.
func GenerateCatalogID ¶
func GenerateCatalogID() string
GenerateCatalogID produces a `cat_<16hex>` run identifier.
func InitCatalogPullPlan ¶
func InitCatalogPullPlan(req CatalogInitRequest) (*CatalogPullPlan, *CatalogValidationError)
InitCatalogPullPlan validates the requested storefront URL and platform and computes the initial pagination plan.
func IsAllowedStoreRedirectURL ¶
IsAllowedStoreRedirectURL ensures `finalURLStr` stays on a safe public `https://` store host matching the requested store origin (or its `www.` equivalent).
func IsBigCommerceHTMLOrHeaders ¶
IsBigCommerceHTMLOrHeaders detects BigCommerce Stencil storefronts structurally from response headers or HTML markers.
func IsChallengePageResponse ¶
func IsChallengePageResponse(status int, outcome, problem string, headers map[string]string, body string) bool
IsChallengePageResponse detects WAF / anti-bot interstitials while exempting valid JSON product payloads.
func IsMagento2HTMLOrHeaders ¶
IsMagento2HTMLOrHeaders detects Magento 2 storefronts strictly via structural HTTP headers or HTML markers.
func IsNonStorefrontHTMLFallback ¶
func IsNonStorefrontHTMLFallback(status int, outcome, problem string, headers map[string]string, body, platform string) bool
IsNonStorefrontHTMLFallback detects plain non-storefront HTML SPA/site fallbacks (with zero WAF or platform markers) so `platform: "auto"` exits cleanly with `unsupported_storefront` instead of false `challenged`.
func IsRobotsOrSignalBlocked ¶
IsRobotsOrSignalBlocked classifies robots.txt and Content-Signal ethical block outcomes.
func IsSFCCDemandwareHTMLOrHeaders ¶
IsSFCCDemandwareHTMLOrHeaders detects Salesforce Commerce Cloud (Demandware) storefronts strictly via structural HTTP headers and HTML/URL markers (never via hardcoded brand lists).
func IsSafeHTTPSStoreURL ¶
IsSafeHTTPSStoreURL validates that urlStr is a strictly public `https://` storefront URL on port 443 without credentials, trailing-dot hostnames, IP literals, or recursive selfHost matches.
func IsSafePublicHostname ¶
IsSafePublicHostname validates that rawHost is a public internet DNS name and NOT an IP literal, numeric/hex IPv4 obfuscation, loopback/LAN/metadata name, wildcard DNS-rebinding domain, bare public suffix, or recursive self-hub hostname.
func IsShopifyHTMLOrHeaders ¶
IsShopifyHTMLOrHeaders detects Shopify storefronts from HTTP response headers or HTML markers.
func IsShopware6HTMLOrHeaders ¶
IsShopware6HTMLOrHeaders detects Shopware 6 storefronts strictly via structural HTTP headers or HTML markers.
func IsSquarespaceCommerceHTMLOrHeaders ¶
IsSquarespaceCommerceHTMLOrHeaders detects Squarespace Commerce storefronts structurally from HTTP headers or bounded HTML markers (never matching non-commerce Squarespace blogs).
func IsTemplateNoiseGo ¶ added in v2.8.29
IsTemplateNoiseGo rejects raw client-side template expressions (Kendo `# var ... #`, `#=`, Mustache `{{...}}`, `${...}`, `<%...%>`).
func IsValidCatalogID ¶
IsValidCatalogID validates a `catalogId` parameter against path traversal and control-byte injection.
func IsWooCommerceHTMLOrHeaders ¶
IsWooCommerceHTMLOrHeaders detects WooCommerce storefronts from Link headers or HTML markers.
func NormalizePublicCommerceImageURL ¶
NormalizePublicCommerceImageURL validates and normalizes a commerce image/asset URL to a strictly public `https://` URL on port 443 without credentials, IP literals, or private/local hosts.
func ParseRetryAfterMs ¶
func ParseRetryAfterMs(retryAfterMs *float64, headers map[string]string, defaultMs int, nowMs int64) int
ParseRetryAfterMs parses numeric or HTTP-date `Retry-After` headers into bounded cooldown milliseconds `[1000..300000]`.
func ParseShopifyCurrencyProbe ¶
ParseShopifyCurrencyProbe extracts a 3-letter ISO currency code from Shopify `/meta.json` or `/cart.js` JSON.
func ResolveMagento2RenderInfoTwinURL ¶
ResolveMagento2RenderInfoTwinURL builds a bounded same-origin `/rest/V1/products-render-info` URL for Magento 2 product pages (strictly `pageSize=1`, never unfiltered catalog dumps).
func ResolveSquarespaceCommerceTwinURL ¶
ResolveSquarespaceCommerceTwinURL appends `?format=json-pretty` on safe public HTTPS URLs unless `format=json` / `format=json-pretty` is already present.
func SafeDecodeURIComponent ¶
SafeDecodeURIComponent decodes percent-escapes strictly (like JS `decodeURIComponent`, without treating `+` as space) and rejects invalid UTF-8 byte sequences.
func SanitizeCommerceField ¶
SanitizeCommerceField sanitizes untrusted e-commerce text fields (`title`, `vendor`, `productType`, `tags`, `options`, `variants[].title`, `sku`) non-destructively so product characters (`<`, `>`, `&`, `[`, `]`, `*`, `_`, `#`, `~`, “ ` “, `|`) are preserved via escaping while HTML tags, entity smuggling, phishing links, emphasis breakouts, and ATX headings are impossible.
func SanitizeCommerceTimestamp ¶
SanitizeCommerceTimestamp sanitizes commerce timestamps (`publishedAt`, `updatedAt`) by collapsing control/line-break characters and escaping HTML/Markdown-unsafe characters.
func SerializeRecordsNDJSON ¶
func SerializeRecordsNDJSON(records []CatalogRecord) string
SerializeRecordsNDJSON serializes a slice of CatalogRecord values into newline-delimited JSON.
func StripTagsInlineCommerce ¶
StripTagsInlineCommerce strips HTML tags linearly, decodes basic entities, collapses whitespace, and escapes any residual `<` characters.
Types ¶
type CatalogFilterOutput ¶
type CatalogFilterOutput struct {
TotalProducts int `json:"totalProducts"`
MatchedProducts int `json:"matchedProducts"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Returned int `json:"returned"`
HasMore bool `json:"hasMore"`
NeedsShopifyCurrency bool `json:"needsShopifyCurrency,omitempty"`
FullRecords []CatalogRecord `json:"fullRecords,omitempty"`
LeanRecords []LeanCatalogRecord `json:"leanRecords,omitempty"`
}
CatalogFilterOutput holds paginated, filtered, and optionally lean-projected catalog records.
func FilterCatalogRecords ¶
func FilterCatalogRecords(records []CatalogRecord, f CatalogRecordFilter) CatalogFilterOutput
FilterCatalogRecords filters, slices, backfills currency, and projects (`full` or `lean`) normalized catalog records.
type CatalogInitRequest ¶
type CatalogInitRequest struct {
URL string `json:"url"`
Platform string `json:"platform,omitempty"`
Collection string `json:"collection,omitempty"`
ScopeCollection string `json:"scopeCollection,omitempty"`
Fields string `json:"fields,omitempty"`
MaxPages *int `json:"maxPages,omitempty"`
PauseMs *int `json:"pauseMs,omitempty"`
SelfHost string `json:"selfHost,omitempty"`
ShopifyPauseMs int `json:"shopifyPauseMs,omitempty"`
ShopifyPageCap int `json:"shopifyPageCap,omitempty"`
WooPauseMs int `json:"wooPauseMs,omitempty"`
WooPageCap int `json:"wooPageCap,omitempty"`
}
CatalogInitRequest holds input parameters for initializing a catalog pull plan.
type CatalogOption ¶
CatalogOption represents a normalized product option definition (e.g. Size, Color).
type CatalogPageEvalInput ¶
type CatalogPageEvalInput struct {
CurrentURL string `json:"currentUrl"`
OriginWithCollection string `json:"originWithCollection"`
Collection string `json:"collection,omitempty"`
SelfHost string `json:"selfHost,omitempty"`
Platform string `json:"platform"`
Fields string `json:"fields"`
PagesRead int `json:"pagesRead"`
TriedAutoFallbackToWC bool `json:"triedAutoFallbackToWc"`
AutoFallbackFromShopify bool `json:"autoFallbackFromShopify"`
ReqPauseMs *int `json:"reqPauseMs,omitempty"`
CatalogCfg DeclarativeCatalogConfig `json:"catalogCfg"`
WooCatalogCfg DeclarativeCatalogConfig `json:"wooCatalogCfg"`
Status int `json:"status"`
Outcome string `json:"outcome,omitempty"`
Problem string `json:"problem,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
FinalURL string `json:"finalUrl,omitempty"`
RetryAfterMs *float64 `json:"retryAfterMs,omitempty"`
NowMs int64 `json:"nowMs,omitempty"`
}
CatalogPageEvalInput describes a single fetched page to evaluate during a catalog pull.
type CatalogPageEvalOutput ¶
type CatalogPageEvalOutput struct {
Action string `json:"action"` // "parsed" | "cooldown" | "fallback_wc" | "halt"
StopReason string `json:"stopReason,omitempty"`
BlockKind string `json:"blockKind,omitempty"`
Challenged bool `json:"challenged,omitempty"`
UnsupportedStore bool `json:"unsupportedStore,omitempty"`
WaitMs int `json:"waitMs,omitempty"`
NewPauseMs int `json:"newPauseMs,omitempty"`
NextURL string `json:"nextUrl,omitempty"`
Done bool `json:"done,omitempty"`
Items []ClampedRecordItem `json:"items,omitempty"`
}
CatalogPageEvalOutput describes the pure-CPU state transition after inspecting/parsing a fetched catalog page.
func EvaluateCatalogPageResponse ¶
func EvaluateCatalogPageResponse(in CatalogPageEvalInput, rawBody string) CatalogPageEvalOutput
EvaluateCatalogPageResponse evaluates redirect safety, robots/signal blocks, WAF challenges, 429 cooldowns, `auto` Shopify->WooCommerce fallback, strict JSON parsing, record clamping, and next-page URL resolution.
type CatalogPullPlan ¶
type CatalogPullPlan struct {
Origin string `json:"origin"`
OriginWithCollection string `json:"originWithCollection"`
Collection string `json:"collection,omitempty"`
Fields string `json:"fields"`
RawPlatform string `json:"rawPlatform"`
InitialPlatform string `json:"initialPlatform"`
EffectivePauseMs int `json:"effectivePauseMs"`
MaxPages int `json:"maxPages"`
CallerExplicitMaxPages bool `json:"callerExplicitMaxPages"`
FirstPageURL string `json:"firstPageUrl"`
}
CatalogPullPlan contains validated, normalized parameters for executing a storefront catalog run.
type CatalogRecord ¶
type CatalogRecord struct {
Platform string `json:"platform"`
Origin string `json:"origin"`
ProductID string `json:"productId"`
Handle string `json:"handle"`
URL string `json:"url"`
Title string `json:"title"`
Vendor *string `json:"vendor"`
ProductType *string `json:"productType"`
Tags []string `json:"tags"`
DescriptionText *string `json:"descriptionText,omitempty"`
PublishedAt *string `json:"publishedAt"`
UpdatedAt *string `json:"updatedAt"`
Images *[]string `json:"images,omitempty"`
Options []CatalogOption `json:"options"`
Variants []CatalogVariantRecord `json:"variants"`
}
CatalogRecord represents a platform-neutral normalized e-commerce product record. Note: DescriptionText and Images use pointers so `"lean"` mode omits them (`nil`) while `"full"` mode always serializes `""` and `[]` (`non-nil`).
func ApplyShopifyCurrencyBackfill ¶
func ApplyShopifyCurrencyBackfill(records []CatalogRecord, currency string) []CatalogRecord
ApplyShopifyCurrencyBackfill populates missing variant currencies in-place with `currency`.
func CatalogSpecParsePage ¶
func CatalogSpecParsePage(cfg DeclarativeCatalogConfig, body, originStr, fields string, headers map[string]string) ([]CatalogRecord, bool, error)
CatalogSpecParsePage parses a raw JSON catalog page for Shopify or WooCommerce.
func ClampCatalogRecord ¶
func ClampCatalogRecord(rec CatalogRecord) (CatalogRecord, int)
ClampCatalogRecord bounds description length, image/variant/tag/option counts, and serialized JSON size (`<= 64 KiB`).
func NormalizeShopifyProductRecord ¶
func NormalizeShopifyProductRecord(rawProd map[string]any, originStr string, opts *ShopifyNormalizeOptions) *CatalogRecord
NormalizeShopifyProductRecord normalizes a raw Shopify product JSON object into a neutral CatalogRecord.
func NormalizeWooCommerceProductRecord ¶
func NormalizeWooCommerceProductRecord(rawProd map[string]any, originStr string, opts *WooNormalizeOptions) *CatalogRecord
NormalizeWooCommerceProductRecord normalizes a WooCommerce Store API v1 product object into a CatalogRecord.
func ParseRecordsNDJSON ¶
func ParseRecordsNDJSON(ndjson string) ([]CatalogRecord, int)
ParseRecordsNDJSON parses newline-delimited JSON CatalogRecord lines, skipping malformed lines and estimating the in-memory LRU cache footprint.
func (*CatalogRecord) UnmarshalJSON ¶
func (r *CatalogRecord) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both canonical CatalogRecord JSON and partial records (e.g. `id` fallback).
type CatalogRecordFilter ¶
type CatalogRecordFilter struct {
Platform string `json:"platform,omitempty"`
Offset int `json:"offset,omitempty"`
Cursor string `json:"cursor,omitempty"`
Limit int `json:"limit,omitempty"`
Vendors []string `json:"vendors,omitempty"`
ProductTypes []string `json:"productTypes,omitempty"`
Tags []string `json:"tags,omitempty"`
AvailableOnly bool `json:"availableOnly,omitempty"`
InStockOnly bool `json:"inStockOnly,omitempty"`
MinPrice *float64 `json:"minPrice,omitempty"`
MaxPrice *float64 `json:"maxPrice,omitempty"`
Query string `json:"query,omitempty"`
Fields string `json:"fields,omitempty"`
FallbackCurrency string `json:"fallbackCurrency,omitempty"`
}
CatalogRecordFilter specifies query, attribute, price, availability, and pagination filters over CatalogRecord slices.
type CatalogRunStatus ¶
type CatalogRunStatus string
CatalogRunStatus enumerates lifecycle states of a catalog pull.
const ( StatusRunning CatalogRunStatus = "running" StatusCoolingDown CatalogRunStatus = "cooling_down" StatusComplete CatalogRunStatus = "complete" StatusPartial CatalogRunStatus = "partial" StatusChallenged CatalogRunStatus = "challenged" )
type CatalogSnapshotDiff ¶
type CatalogSnapshotDiff struct {
Added int `json:"added"`
Removed int `json:"removed"`
Changed int `json:"changed"`
VariantDiff *CatalogVariantDiffCounts `json:"variantDiff,omitempty"`
}
CatalogSnapshotDiff holds product-level and variant-level snapshot diff counters.
func ComputeCatalogSnapshotDiff ¶
func ComputeCatalogSnapshotDiff(prev, curr SnapshotHashBundle) CatalogSnapshotDiff
ComputeCatalogSnapshotDiff computes added, removed, and changed counts at both product and variant granularity.
type CatalogStatusSummary ¶
type CatalogStatusSummary struct {
OK bool `json:"ok"`
CatalogID string `json:"catalogId"`
Status CatalogRunStatus `json:"status"`
Platform string `json:"platform"`
Origin string `json:"origin"`
Collection string `json:"collection,omitempty"`
Fields string `json:"fields,omitempty"`
Products int `json:"products"`
Variants int `json:"variants"`
Pages int `json:"pages"`
PagesRead int `json:"pagesRead"`
PauseMs int `json:"pauseMs"`
DurationMs int64 `json:"durationMs"`
Truncated bool `json:"truncated,omitempty"`
Reason string `json:"reason,omitempty"`
ResumeAt string `json:"resumeAt,omitempty"`
Warning string `json:"warning,omitempty"`
PreviousProducts *int `json:"previousProducts,omitempty"`
ArtifactID string `json:"artifactId,omitempty"`
Diff *CatalogSnapshotDiff `json:"diff"`
UCP *CatalogUCPMetadata `json:"ucp,omitempty"`
Blocked any `json:"blocked,omitempty"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
CatalogStatusSummary summarizes the status, counts, and diff of a catalog run.
type CatalogStore ¶
type CatalogStore struct {
// contains filtered or unexported fields
}
CatalogStore manages bounded 32 MiB multi-tenant LRU state, per-principal/owner concurrency slots, and singleflight `<= 2` artifact reload admission for Phase 3's native Go `--mode=hub`.
func NewCatalogStore ¶
func NewCatalogStore() *CatalogStore
NewCatalogStore creates an isolated bounded CatalogStore (`32 MiB` global ceiling, `<= 2` reload semaphore).
func (*CatalogStore) AcquireConcurrencySlot ¶
func (s *CatalogStore) AcquireConcurrencySlot(tenant CatalogTenantInfo) (func(), bool)
AcquireConcurrencySlot enforces per-principal (`<= 2`), non-owner (`<= 6`), and global (`<= 8`) run caps, reserving 2 global slots exclusively for `owner`.
func (*CatalogStore) FindPreviousCompleteBaseline ¶
func (s *CatalogStore) FindPreviousCompleteBaseline(userID, origin, collection, excludeCatalogID string) (int, *SnapshotHashBundle, bool)
FindPreviousCompleteBaseline returns the latest non-shrunk `complete` run for `(userID, origin, collection)`.
func (*CatalogStore) GetCachedOriginCurrency ¶
GetCachedOriginCurrency returns a cached 3-letter ISO currency (or negative `""` probe) for a Shopify origin.
func (*CatalogStore) GetRun ¶
func (s *CatalogStore) GetRun(catalogID, ownerKey string) (*StoredCatalogRun, bool)
GetRun looks up a tenant-owned run in memory.
func (*CatalogStore) MemoryStats ¶
func (s *CatalogStore) MemoryStats() MemoryUsageStats
MemoryStats returns live memory and concurrency usage metrics.
func (*CatalogStore) ReloadRecordsCoalesced ¶
func (s *CatalogStore) ReloadRecordsCoalesced(ctx context.Context, artifactID string, loader func(context.Context) ([]byte, error)) ([]CatalogRecord, error)
ReloadRecordsCoalesced coalesces concurrent cold artifact reads onto 1 singleflight call and bounds concurrent decompressions to `<= 2` (`MaxConcurrentR2Reloads`).
func (*CatalogStore) RememberRun ¶
func (s *CatalogStore) RememberRun(entry StoredCatalogRun)
RememberRun inserts or updates a catalog run and enforces per-user fair-share + global 32 MiB LRU caps.
func (*CatalogStore) SetCachedOriginCurrency ¶
func (s *CatalogStore) SetCachedOriginCurrency(origin, currency string, ttl time.Duration, now time.Time)
SetCachedOriginCurrency stores a positive or negative Shopify origin currency lookup in a bounded (`<= 256`) cache.
type CatalogTenantInfo ¶
type CatalogTenantInfo struct {
OwnerKey string `json:"ownerKey"`
ConcurrencyBucketKey string `json:"concurrencyBucketKey"`
IsOwner bool `json:"isOwner"`
}
CatalogTenantInfo holds resolved multi-tenant ownership and concurrency bucket keys.
func ResolveCatalogTenantBucket ¶
func ResolveCatalogTenantBucket(cleanUserID, principal, activeUserID, activeRole string) CatalogTenantInfo
ResolveCatalogTenantBucket normalizes userId/principal into tenant storage and concurrency keys, grouping `oauth:<member>-client-1..N` onto `oauth:<member>` so multi-client rotation cannot multiply concurrency.
type CatalogUCPMetadata ¶
type CatalogUCPMetadata struct {
Advertised bool `json:"advertised"`
Endpoint string `json:"endpoint"`
}
CatalogUCPMetadata describes advertised Universal Commerce Protocol (UCP) endpoints in robots.txt.
func DiscoverUCPEndpointFromRobots ¶
func DiscoverUCPEndpointFromRobots(originStr, robotsText string) *CatalogUCPMetadata
DiscoverUCPEndpointFromRobots inspects `robots.txt` text for advertised Shopify / Universal Commerce Protocol endpoints (`/.well-known/ucp` or `/api/ucp/mcp`), strictly treating `robots.txt` prose as untrusted data.
type CatalogValidationError ¶
type CatalogValidationError struct {
ErrorCode string `json:"error"`
Message string `json:"message"`
}
CatalogValidationError represents a 400 validation failure during pull initialization.
type CatalogVariantDiffCounts ¶
type CatalogVariantDiffCounts struct {
Added int `json:"added"`
Removed int `json:"removed"`
Changed int `json:"changed"`
}
CatalogVariantDiffCounts holds variant-level snapshot diff counters.
type CatalogVariantRecord ¶
type CatalogVariantRecord struct {
VariantID string `json:"variantId"`
SKU *string `json:"sku"`
Barcode *string `json:"barcode,omitempty"`
Title *string `json:"title"`
Options []string `json:"options"`
Price *float64 `json:"price"`
CompareAt *float64 `json:"compareAt"`
Currency *string `json:"currency"`
Available *bool `json:"available"`
InventoryPolicy *string `json:"inventoryPolicy,omitempty"`
InventoryQuantity *int `json:"inventoryQuantity,omitempty"`
Grams *int `json:"grams"`
Image *string `json:"image"`
}
CatalogVariantRecord represents a normalized SKU/variant within a CatalogRecord.
func (*CatalogVariantRecord) UnmarshalJSON ¶
func (v *CatalogVariantRecord) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both canonical CatalogVariantRecord fields and legacy/loose caller fields (`id` -> VariantID, `compareAtPrice` -> CompareAt) so hashing never fails.
type ClampedRecordItem ¶
type ClampedRecordItem struct {
Key string `json:"key"`
Record CatalogRecord `json:"record"`
FootprintBytes int `json:"footprintBytes"`
}
ClampedRecordItem pairs a clamped CatalogRecord with its computed V8/Go memory footprint.
type DeclarativeCatalogConfig ¶
type DeclarativeCatalogConfig struct {
Platform string `json:"platform"`
PauseMs int `json:"pauseMs"`
PageCap int `json:"pageCap"`
FirstPageTemplate string `json:"firstPageTemplate,omitempty"`
CollectionPageTemplate string `json:"collectionPageTemplate,omitempty"`
PerPage int `json:"perPage,omitempty"`
MaxVariantsPerProduct int `json:"maxVariantsPerProduct,omitempty"`
MaxImagesPerProduct int `json:"maxImagesPerProduct,omitempty"`
}
DeclarativeCatalogConfig configures polite full-store catalog pagination for Shopify or WooCommerce.
func ValidateDeclarativeCatalogConfig ¶
func ValidateDeclarativeCatalogConfig(cfg DeclarativeCatalogConfig) (DeclarativeCatalogConfig, error)
ValidateDeclarativeCatalogConfig validates platform allowlist and normalizes pauseMs/pageCap bounds.
type DetailedCatalogSnapshotDiff ¶
type DetailedCatalogSnapshotDiff struct {
Added int `json:"added"`
Removed int `json:"removed"`
Changed int `json:"changed"`
PriceChanged int `json:"priceChanged"`
AvailabilityChanged int `json:"availabilityChanged"`
Unchanged int `json:"unchanged"`
VariantDiff CatalogVariantDiffCounts `json:"variantDiff"`
ShrunkOver50Pct bool `json:"shrunkOver50Pct"`
PreviousProducts int `json:"previousProducts,omitempty"`
}
DetailedCatalogSnapshotDiff extends CatalogSnapshotDiff with price/availability breakdown and shrink guard.
func ComputeDetailedCatalogSnapshotDiff ¶
func ComputeDetailedCatalogSnapshotDiff(prevRecords, currRecords []CatalogRecord) DetailedCatalogSnapshotDiff
ComputeDetailedCatalogSnapshotDiff computes full product/variant diff breakdowns including priceChanged, availabilityChanged, unchanged, and `>50%` shrink guard detection.
type FetchFunc ¶
type FetchFunc func(ctx context.Context, req FetchRequest) (*FetchResponse, error)
FetchFunc executes a polite, robots/SSRF-checked fetch for Phase 3's Go `--mode=hub`.
type FetchRequest ¶
type FetchRequest struct {
URL string
Kind string // "json" | "text"
Accept string
MaxBytes int
TimeoutMs int
}
FetchRequest describes a polite single-URL outbound request for native Go `--mode=hub` catalog runs.
type FetchResponse ¶
type FetchResponse struct {
Status int
Outcome string
Problem string
Headers map[string]string
Body string
FinalURL string
RetryAfterMs *float64
}
FetchResponse holds a transport-agnostic response returned by FetchFunc (no net/http dependency).
type LeanCatalogRecord ¶
type LeanCatalogRecord struct {
Platform string `json:"platform"`
Origin string `json:"origin"`
ProductID string `json:"productId"`
Handle string `json:"handle"`
URL string `json:"url"`
Title string `json:"title"`
Vendor *string `json:"vendor"`
ProductType *string `json:"productType"`
Available bool `json:"available"`
PriceMin *float64 `json:"priceMin"`
PriceMax *float64 `json:"priceMax"`
Currency *string `json:"currency"`
Image *string `json:"image"`
VariantCount int `json:"variantCount"`
PublishedAt *string `json:"publishedAt"`
UpdatedAt *string `json:"updatedAt"`
}
LeanCatalogRecord is the compact product-level summary emitted when `fields: "lean"`.
func ProjectLeanCatalogRecord ¶
func ProjectLeanCatalogRecord(rec CatalogRecord) LeanCatalogRecord
ProjectLeanCatalogRecord projects a full CatalogRecord down to compact product-level summary fields (`fields: "lean"`), omitting `tags`, `options`, `images`, `descriptionText`, and `variants[]`.
type MemoryUsageStats ¶
type MemoryUsageStats struct {
RunsCount int
RecordsBytes int
HashesBytes int
ReloadCacheBytes int
TotalBytes int
MaxBytes int
ActiveReloads int
PeakReloadsSeen int
ActiveGlobalRuns int
ActiveNonOwnerRun int
}
MemoryUsageStats reports live memory and reload concurrency counters for CatalogStore.
type PaginationInfo ¶
type PaginationInfo struct {
Page int `json:"page"`
Returned int `json:"returned"`
Limit int `json:"limit,omitempty"`
HasMore bool `json:"hasMore"`
NextURL string `json:"nextUrl,omitempty"`
}
PaginationInfo describes feed-level page metadata for twin formatters.
type PostFetchSiteResult ¶
type PostFetchSiteResult struct {
ExtractorID string `json:"extractorId"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
PublishedTime string `json:"publishedTime,omitempty"`
Markdown string `json:"markdown"`
Links []string `json:"links,omitempty"`
Records []CatalogRecord `json:"records,omitempty"`
}
PostFetchSiteResult holds structured post-fetch HTML commerce extraction output.
func ExtractBigCommerceHTML ¶
func ExtractBigCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractBigCommerceHTML extracts BigCommerce Stencil product details (`BCData`, JSON-LD, Microdata, `form[data-cart-item-add]` options, `<dl class="productView-info">` specs) or category grid cards.
func ExtractMagento2ProductHTML ¶
func ExtractMagento2ProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractMagento2ProductHTML extracts Magento 2 `text/x-magento-init` swatch/configurable JSON, `#product-attribute-specs-table`, and JSON-LD into normalized `CatalogRecord` + GFM tables.
func ExtractSFCCProductHTML ¶
func ExtractSFCCProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractSFCCProductHTML extracts SFCC product JSON-LD, `data-pid`, variation options, and geometry/specification HTML tables as a zero-network fail-open fallback.
func ExtractShopifyProductHTML ¶
func ExtractShopifyProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractShopifyProductHTML extracts product records and Markdown from a live Shopify product HTML document.
func ExtractShopware6ProductHTML ¶
func ExtractShopware6ProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractShopware6ProductHTML extracts Shopware 6 (`sw-product-detail`, `.product-detail-properties-table`, configurator options, and JSON-LD) into normalized `CatalogRecord` + GFM tables.
func ExtractShopwareOrMagentoHTML ¶
func ExtractShopwareOrMagentoHTML(rawURL, rawHTML, currentMD, extractorID string) *PostFetchSiteResult
ExtractShopwareOrMagentoHTML dispatches post-fetch HTML extraction to Magento 2 or Shopware 6 strictly based on structural markers.
func ExtractSmartEtailingHTML ¶ added in v2.8.29
func ExtractSmartEtailingHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractSmartEtailingHTML extracts SmartEtailing IBD bike shop product, specs, and dealer pickup details.
func ExtractSquarespaceCommerceHTML ¶
func ExtractSquarespaceCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractSquarespaceCommerceHTML provides a zero-network HTML/JSON-LD fallback when `?format=json-pretty` is disallowed by `robots.txt` or returns 403/404.
func ExtractWave2aCommerceHTML ¶ added in v2.8.29
func ExtractWave2aCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractWave2aCommerceHTML handles HTML extraction for Wave 2A commerce adapters (#1-#5) when structural markers and product data match.
func ExtractWave2bCommerceHTML ¶ added in v2.8.29
func ExtractWave2bCommerceHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractWave2bCommerceHTML handles HTML extraction for Wave 2B commerce adapters (#6-#15).
func ExtractWooCommerceCatalogHTML ¶
func ExtractWooCommerceCatalogHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractWooCommerceCatalogHTML extracts a product list from WooCommerce `/product-category/` or `/shop/` HTML as a fail-open fallback when the Store API is unavailable or disallowed by robots.txt.
func ExtractWooCommerceProductHTML ¶
func ExtractWooCommerceProductHTML(rawURL, rawHTML, _ string, extractorID string) *PostFetchSiteResult
ExtractWooCommerceProductHTML extracts product records and Markdown from a live WooCommerce product HTML document.
type SFCCSpecTable ¶
SFCCSpecTable represents an extracted HTML specification or geometry table.
func ExtractSFCCGeometryAndSpecTables ¶
func ExtractSFCCGeometryAndSpecTables(doc *extract.HTMLDoc) []SFCCSpecTable
ExtractSFCCGeometryAndSpecTables extracts product specification and geometry `<table>` and `<dl>` structures.
type SFCCTwinURL ¶
SFCCTwinURL holds the resolved same-origin SFCC `Product-Variation` JSON endpoint.
func ResolveSFCCProductVariationTwinURL ¶
func ResolveSFCCProductVariationTwinURL(pageURL, rawHTML string) *SFCCTwinURL
ResolveSFCCProductVariationTwinURL discovers or constructs a strictly same-origin `https://` SFCC `Product-Variation` JSON twin URL from HTML markers (`Product-Variation` URL or `Sites-*-Site` + `data-pid`).
type ShopifyCollectionTwinURL ¶
type ShopifyCollectionTwinURL struct {
JSONURL string `json:"jsonUrl"`
Handle string `json:"handle"`
}
ShopifyCollectionTwinURL holds the resolved `/collections/<handle>/products.json?limit=50` twin URL.
func ResolveCustomDomainShopifyCollectionTwinURL ¶
func ResolveCustomDomainShopifyCollectionTwinURL(pageURL string) *ShopifyCollectionTwinURL
ResolveCustomDomainShopifyCollectionTwinURL resolves `/collections/<handle>` URLs (with optional leading locale) to `/collections/<handle>/products.json?limit=50`, rejecting product sub-routes (`/collections/<col>/products/<prod>`).
type ShopifyEnrichParams ¶
type ShopifyEnrichParams struct {
RawJSON string `json:"rawJson"`
ProductURL string `json:"productUrl"`
Currency string `json:"currency,omitempty"`
IsAjaxJS *bool `json:"isAjaxJs,omitempty"`
AjaxJSBody string `json:"ajaxJsBody,omitempty"`
}
ShopifyEnrichParams configures EnrichShopifyProductFromJSON.
type ShopifyFeedFormatOptions ¶
type ShopifyFeedFormatOptions struct {
TwinURL string `json:"twinUrl,omitempty"`
Currency string `json:"currency,omitempty"`
}
ShopifyFeedFormatOptions configures FormatShopifyProductsFeedTwin.
type ShopifyNormalizeOptions ¶
type ShopifyNormalizeOptions struct {
Currency string `json:"currency,omitempty"`
Fields string `json:"fields,omitempty"`
IsAjaxJS *bool `json:"isAjaxJs,omitempty"`
AjaxVariantsByID map[string]map[string]any `json:"ajaxVariantsById,omitempty"`
MaxImages int `json:"maxImages,omitempty"`
MaxVariants int `json:"maxVariants,omitempty"`
}
ShopifyNormalizeOptions configures NormalizeShopifyProductRecord.
type ShopifyProductTwinURLs ¶
type ShopifyProductTwinURLs struct {
JSONURL string `json:"jsonUrl"`
JSURL string `json:"jsUrl"`
Handle string `json:"handle"`
}
ShopifyProductTwinURLs holds resolved `.json` and `.js` twin URLs for a custom-domain Shopify product page.
func ResolveCustomDomainShopifyProductTwinURL ¶
func ResolveCustomDomainShopifyProductTwinURL(productURL string) *ShopifyProductTwinURLs
ResolveCustomDomainShopifyProductTwinURL resolves `/products/<handle>` URLs to `.json` and `.js` twin endpoints.
type SnapshotHashBundle ¶
type SnapshotHashBundle struct {
Products map[string]string `json:"products"`
Variants map[string]string `json:"variants"`
}
SnapshotHashBundle maps product IDs and `productId::variantId` keys to deterministic FNV-1a 64-bit hashes.
func BuildSnapshotHashBundle ¶
func BuildSnapshotHashBundle(records []CatalogRecord) SnapshotHashBundle
BuildSnapshotHashBundle constructs product-level and variant-level hash maps for a catalog snapshot.
type StoredCatalogRun ¶
type StoredCatalogRun struct {
UserID string
Summary CatalogStatusSummary
Hashes *SnapshotHashBundle
HashesBytes int
HashesArtifactID string
Records []CatalogRecord // nil when evicted or flushed to object storage
HasRecords bool
RetainedBytes int
}
StoredCatalogRun represents an in-memory catalog run entry managed by CatalogStore.
type TwinFormattedDoc ¶
type TwinFormattedDoc struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
PublishedTime string `json:"publishedTime,omitempty"`
Markdown string `json:"markdown"`
Links []string `json:"links,omitempty"`
Records []CatalogRecord `json:"records,omitempty"`
Pagination *PaginationInfo `json:"pagination,omitempty"`
Total *int `json:"total,omitempty"`
Returned *int `json:"returned,omitempty"`
Truncated *bool `json:"truncated,omitempty"`
NextCursor string `json:"nextCursor,omitempty"`
}
TwinFormattedDoc holds a formatted Markdown twin document and normalized commerce records.
func EnrichShopifyProductFromJSON ¶
func EnrichShopifyProductFromJSON(params ShopifyEnrichParams) *TwinFormattedDoc
EnrichShopifyProductFromJSON formats a single-product Shopify `.json` or `.js` payload into a TwinFormattedDoc.
func EnrichWooCommerceProductFromStoreAPI ¶
func EnrichWooCommerceProductFromStoreAPI(params WooEnrichParams) *TwinFormattedDoc
EnrichWooCommerceProductFromStoreAPI formats a WooCommerce Store API v1 response into a TwinFormattedDoc.
func FormatBigCartelJSON ¶ added in v2.8.29
func FormatBigCartelJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatBigCartelJSON formats Big Cartel `/products.json` arrays and `/product/<slug>.js` objects.
func FormatBigCommerceXMLSitemap ¶
func FormatBigCommerceXMLSitemap(rawBody, origURL string) *TwinFormattedDoc
FormatBigCommerceXMLSitemap parses BigCommerce `/xmlsitemap.php` (`<sitemapindex>` or `<urlset>`) into a GFM table, validated `Links`, and `CatalogRecord[]`. Fails open (`nil`) on non-XML responses.
func FormatEcwidV3JSON ¶ added in v2.8.29
func FormatEcwidV3JSON(rawJSON, origURL string) *TwinFormattedDoc
FormatEcwidV3JSON formats Ecwid REST API v3 `/api/v3/{storeId}/products` and `/products/{id}` JSON.
func FormatHCLWCSProductJSON ¶ added in v2.8.29
func FormatHCLWCSProductJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatHCLWCSProductJSON formats HCL / IBM WebSphere Commerce `/wcs/resources/store/{storeId}/productview/...` JSON.
func FormatLightspeedEcomJSON ¶ added in v2.8.29
func FormatLightspeedEcomJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatLightspeedEcomJSON formats Lightspeed eCom C-Series `?format=json` product or collection payloads.
func FormatMagento2RenderInfoJSON ¶
func FormatMagento2RenderInfoJSON(rawBody, origURL, fallbackHTML string) *TwinFormattedDoc
FormatMagento2RenderInfoJSON parses Magento 2 `/rest/V1/products-render-info` JSON (failing open on 401/403/404 error objects or empty `items[]`) and merges optional HTML spec tables.
func FormatMedusaProductJSON ¶ added in v2.8.29
func FormatMedusaProductJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatMedusaProductJSON formats Medusa v1/v2 `/store/products` and `/store/products/{id}` JSON.
func FormatOracleCommerceProductJSON ¶ added in v2.8.29
func FormatOracleCommerceProductJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatOracleCommerceProductJSON formats Oracle Commerce Cloud `/ccstore/v1/products/{id}` or `/ccstore/v1/search`.
func FormatPrestaShopQuickviewJSON ¶ added in v2.8.29
func FormatPrestaShopQuickviewJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatPrestaShopQuickviewJSON formats PrestaShop `?action=quickview` JSON responses (`{product:{...}}`).
func FormatSAPOCCProductJSON ¶ added in v2.8.29
func FormatSAPOCCProductJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatSAPOCCProductJSON formats SAP Commerce Cloud OCC v2 product or search JSON.
func FormatSFCCProductVariationJSON ¶
func FormatSFCCProductVariationJSON(rawBody, origURL, fallbackHTML, _ string) *TwinFormattedDoc
FormatSFCCProductVariationJSON parses an SFCC `Product-Variation` JSON payload, merges any HTML geometry/spec tables from `fallbackHTML`, and emits normalized `CatalogRecord` + GFM tables.
func FormatSaleorGraphQLJSON ¶ added in v2.8.29
func FormatSaleorGraphQLJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatSaleorGraphQLJSON formats Saleor Storefront GraphQL `data.products.edges` and `data.product` payloads.
func FormatShopifyProductsFeedTwin ¶
func FormatShopifyProductsFeedTwin(rawBody, origURL string, opts ...ShopifyFeedFormatOptions) *TwinFormattedDoc
FormatShopifyProductsFeedTwin formats a `/products.json` or `/collections/<h>/products.json` feed page.
func FormatSpreeSolidusJSON ¶ added in v2.8.29
func FormatSpreeSolidusJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatSpreeSolidusJSON formats Spree/Solidus JSON:API `/api/v2/storefront/products` responses.
func FormatSquarespaceCommerceJSON ¶
func FormatSquarespaceCommerceJSON(rawBody, origURL string) *TwinFormattedDoc
FormatSquarespaceCommerceJSON formats Squarespace `?format=json-pretty` single-product or collection JSON into a GFM table + normalized `CatalogRecord[]`.
func FormatVTEXProductJSON ¶ added in v2.8.29
func FormatVTEXProductJSON(rawJSON, origURL string) *TwinFormattedDoc
FormatVTEXProductJSON formats VTEX `/api/catalog_system/pub/products/search` or `/variations/{id}` JSON.
func FormatWCStoreAPIListTwin ¶
func FormatWCStoreAPIListTwin(rawBody, origURL string) *TwinFormattedDoc
FormatWCStoreAPIListTwin formats a `/wp-json/wc/store/v1/products` list response into a TwinFormattedDoc.
func FormatWCStoreAPIListTwinWithOptions ¶
func FormatWCStoreAPIListTwinWithOptions(rawBody, origURL, twinURL string) *TwinFormattedDoc
FormatWCStoreAPIListTwinWithOptions formats a `/wp-json/wc/store/v1/products` list response into a TwinFormattedDoc, reading `per_page`, `page`, and `NextURL` base from `twinURL` when provided (so custom-domain HTML URLs get accurate pagination).
func FormatWCStoreAPIProductTwin ¶
func FormatWCStoreAPIProductTwin(rawBody, origURL string) *TwinFormattedDoc
FormatWCStoreAPIProductTwin formats a single `/wp-json/wc/store/v1/products/<id>` object into a TwinFormattedDoc.
func FormatWave2aCommerceMode ¶ added in v2.8.29
func FormatWave2aCommerceMode(mode, rawJSON, origURL string) *TwinFormattedDoc
FormatWave2aCommerceMode dispatches Wave 2A commerce twin modes for Go WASM & declarative manifests.
func FormatWave2bCommerceMode ¶ added in v2.8.29
func FormatWave2bCommerceMode(mode, rawJSON, origURL string) *TwinFormattedDoc
FormatWave2bCommerceMode dispatches Wave 2B commerce twin modes (`#6-#13`) for Go WASM & declarative manifests.
type WooCommerceCatalogTwinURL ¶
type WooCommerceCatalogTwinURL struct {
Kind string `json:"kind"`
Slug string `json:"slug,omitempty"`
StoreAPIURL string `json:"storeApiUrl"`
}
WooCommerceCatalogTwinURL holds the resolved Store API v1 list endpoint for a custom-domain `/product-category/<slug>/` or `/shop/` URL.
func ResolveCustomDomainWooCommerceCatalogTwinURL ¶
func ResolveCustomDomainWooCommerceCatalogTwinURL(pageURL string) *WooCommerceCatalogTwinURL
ResolveCustomDomainWooCommerceCatalogTwinURL upgrades `/product-category/.../<slug>/` and `/shop/` URLs to `/wp-json/wc/store/v1/products?category=<slug>&per_page=50` or `?per_page=50`.
type WooCommerceProductTwinURL ¶
type WooCommerceProductTwinURL struct {
Slug string `json:"slug"`
StoreAPIURL string `json:"storeApiUrl"`
}
WooCommerceProductTwinURL holds the resolved WooCommerce Store API v1 twin URL for a product page.
func ResolveCustomDomainWooCommerceProductTwinURL ¶
func ResolveCustomDomainWooCommerceProductTwinURL(productURL string) *WooCommerceProductTwinURL
ResolveCustomDomainWooCommerceProductTwinURL upgrades `/product/<slug>/` URLs to `/wp-json/wc/store/v1/products?slug=<slug>`.
type WooEnrichParams ¶
type WooEnrichParams struct {
RawJSON string `json:"rawJson"`
ProductURL string `json:"productUrl"`
Slug string `json:"slug"`
FallbackBodyMD string `json:"fallbackBodyMd,omitempty"`
}
WooEnrichParams configures EnrichWooCommerceProductFromStoreAPI.
type WooNormalizeOptions ¶
type WooNormalizeOptions struct {
Fields string `json:"fields,omitempty"`
MaxImages int `json:"maxImages,omitempty"`
MaxVariants int `json:"maxVariants,omitempty"`
}
WooNormalizeOptions configures NormalizeWooCommerceProductRecord.