fixes
This commit is contained in:
1 parent
6586722652
commit
1e7c7bbfbb
65 files changed
+1345
-640
No files matched your search
@@ -67,7 +67,7 @@ func main() {
|
|||||||
flag = "created/updated"
|
flag = "created/updated"
|
||||||
}
|
}
|
||||||
fmt.Printf(" %-8s $%-5d credits=%-6d price=%s product=%s (%s)\n",
|
fmt.Printf(" %-8s $%-5d credits=%-6d price=%s product=%s (%s)\n",
|
||||||
r.PackID, r.PriceUSD, r.Credits, r.PriceID, r.ProductID, flag)
|
r.PackID, r.PriceEUR, r.Credits, r.PriceID, r.ProductID, flag)
|
||||||
if *writeSettings {
|
if *writeSettings {
|
||||||
if plat == nil {
|
if plat == nil {
|
||||||
fmt.Fprintln(os.Stderr, "-write-settings requires DATABASE_URL")
|
fmt.Fprintln(os.Stderr, "-write-settings requires DATABASE_URL")
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ type ModelPrice struct {
|
|||||||
// GPT-5.6 rates here means a fresh database still costs correctly before the
|
// GPT-5.6 rates here means a fresh database still costs correctly before the
|
||||||
// migration seed is edited. Rates: OpenAI list price, 2026-07-30.
|
// migration seed is edited. Rates: OpenAI list price, 2026-07-30.
|
||||||
var defaultModelPrices = map[string]ModelPrice{
|
var defaultModelPrices = map[string]ModelPrice{
|
||||||
|
// OpenAI public standard-rate text models, verified 2026-10-16.
|
||||||
|
"gpt-5.4-mini": {InputPerMTok: 750_000, CachedInputPerMTok: 75_000, OutputPerMTok: 4_500_000},
|
||||||
|
"gpt-5-mini": {InputPerMTok: 250_000, CachedInputPerMTok: 25_000, OutputPerMTok: 2_000_000},
|
||||||
|
"gpt-6-luna": {InputPerMTok: 100_000, CachedInputPerMTok: 10_000, OutputPerMTok: 500_000},
|
||||||
"gpt-5.6-luna": {InputPerMTok: 200_000, CachedInputPerMTok: 20_000, OutputPerMTok: 1_200_000},
|
"gpt-5.6-luna": {InputPerMTok: 200_000, CachedInputPerMTok: 20_000, OutputPerMTok: 1_200_000},
|
||||||
"gpt-5.6-terra": {InputPerMTok: 2_000_000, CachedInputPerMTok: 200_000, OutputPerMTok: 12_000_000},
|
"gpt-5.6-terra": {InputPerMTok: 2_000_000, CachedInputPerMTok: 200_000, OutputPerMTok: 12_000_000},
|
||||||
"gpt-5.6-sol": {InputPerMTok: 5_000_000, CachedInputPerMTok: 500_000, OutputPerMTok: 30_000_000},
|
"gpt-5.6-sol": {InputPerMTok: 5_000_000, CachedInputPerMTok: 500_000, OutputPerMTok: 30_000_000},
|
||||||
|
|||||||
@@ -113,24 +113,24 @@ type CreditPack struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Credits int `json:"credits"`
|
Credits int `json:"credits"`
|
||||||
PriceUSD int `json:"price_usd"` // whole dollars for marketing UI
|
PriceEUR int `json:"price_eur"` // whole euros for marketing UI
|
||||||
// Approx product×language passes at CreditsPerAIProduct.
|
// Approx product×language passes at CreditsPerAIProduct.
|
||||||
AIProducts int `json:"ai_products"`
|
AIProducts int `json:"ai_products"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func packFromCredits(id, name, desc string, credits, priceUSD int) CreditPack {
|
func packFromCredits(id, name, desc string, credits, priceEUR int) CreditPack {
|
||||||
return CreditPack{
|
return CreditPack{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
Description: desc,
|
Description: desc,
|
||||||
Credits: credits,
|
Credits: credits,
|
||||||
PriceUSD: priceUSD,
|
PriceEUR: priceEUR,
|
||||||
AIProducts: credits / CreditsPerAIProduct,
|
AIProducts: credits / CreditsPerAIProduct,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultCreditPacks is the public top-up ladder (credits-first sizing).
|
// DefaultCreditPacks is the public top-up ladder (credits-first sizing).
|
||||||
// Prices are balanced so small packs are not punitive $/credit vs larger ones,
|
// Prices are balanced so small packs are not punitive €/credit vs larger ones,
|
||||||
// while staying expensive enough that packs cannot undercut plan upgrades or A1 (~€300).
|
// while staying expensive enough that packs cannot undercut plan upgrades or A1 (~€300).
|
||||||
func DefaultCreditPacks() []CreditPack {
|
func DefaultCreditPacks() []CreditPack {
|
||||||
return []CreditPack{
|
return []CreditPack{
|
||||||
|
|||||||
@@ -334,10 +334,10 @@ func (s *Service) consumeCredits(ctx context.Context, tx pgx.Tx, companyID uuid.
|
|||||||
}
|
}
|
||||||
_ = s.EnsureDefaultCosts(ctx)
|
_ = s.EnsureDefaultCosts(ctx)
|
||||||
|
|
||||||
featureCost := s.lookupCost(ctx, featureName, 1)
|
featureCost := s.lookupCostForCompany(ctx, companyID, featureName, 1)
|
||||||
tokenKCost := 1
|
tokenKCost := 1
|
||||||
if tokenCount > 0 {
|
if tokenCount > 0 {
|
||||||
tokenKCost = s.lookupCost(ctx, "openai_token_k", 1)
|
tokenKCost = s.lookupCostForCompany(ctx, companyID, "openai_token_k", 1)
|
||||||
}
|
}
|
||||||
var debit int
|
var debit int
|
||||||
if productCount == 1 {
|
if productCount == 1 {
|
||||||
@@ -477,6 +477,43 @@ func (s *Service) lookupCost(ctx context.Context, feature string, fallback int)
|
|||||||
return cost
|
return cost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lookupCostForCompany resolves credit pricing without caching tenant-specific rules.
|
||||||
|
// Overrides must be positive; the existing credit engine enforces a minimum of 1.
|
||||||
|
// An unconfigured/missing migration retains the global default behavior.
|
||||||
|
func (s *Service) lookupCostForCompany(ctx context.Context, companyID uuid.UUID, feature string, fallback int) int {
|
||||||
|
var cost int
|
||||||
|
err := s.Pool.QueryRow(ctx, `
|
||||||
|
SELECT COALESCE(
|
||||||
|
(SELECT cc.cost_per_unit FROM company_processing_costs cc
|
||||||
|
WHERE cc.company_id = $1 AND cc.feature_name = $2),
|
||||||
|
(SELECT pc.cost_per_unit FROM plan_processing_costs pc
|
||||||
|
JOIN company_plans cp ON cp.plan_id = pc.plan_id
|
||||||
|
WHERE cp.company_id = $1 AND cp.is_active = true AND pc.feature_name = $2
|
||||||
|
ORDER BY cp.created_at DESC LIMIT 1),
|
||||||
|
(SELECT gc.cost_per_unit FROM processing_costs gc
|
||||||
|
WHERE gc.feature_name = $2 AND gc.is_active = true),
|
||||||
|
$3
|
||||||
|
)::integer`, companyID, feature, fallback).Scan(&cost)
|
||||||
|
if err == nil && cost >= 0 {
|
||||||
|
return cost
|
||||||
|
}
|
||||||
|
return s.lookupCost(ctx, feature, fallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EstimateDebitForCompany uses the same company/plan pricing rules as the actual debit.
|
||||||
|
func (s *Service) EstimateDebitForCompany(ctx context.Context, companyID uuid.UUID, feature string, tokenCount int) int {
|
||||||
|
if feature == "" {
|
||||||
|
feature = "product_processing"
|
||||||
|
}
|
||||||
|
_ = s.EnsureDefaultCosts(ctx)
|
||||||
|
base := s.lookupCostForCompany(ctx, companyID, feature, 1)
|
||||||
|
perK := 1
|
||||||
|
if tokenCount > 0 {
|
||||||
|
perK = s.lookupCostForCompany(ctx, companyID, "openai_token_k", 1)
|
||||||
|
}
|
||||||
|
return DebitAmount(base, perK, tokenCount)
|
||||||
|
}
|
||||||
|
|
||||||
// EnsureDefaultCosts seeds plan-aligned processing cost rows (idempotent).
|
// EnsureDefaultCosts seeds plan-aligned processing cost rows (idempotent).
|
||||||
// After a successful seed in this process, subsequent calls no-op (worker seeds at boot).
|
// After a successful seed in this process, subsequent calls no-op (worker seeds at boot).
|
||||||
func (s *Service) EnsureDefaultCosts(ctx context.Context) error {
|
func (s *Service) EnsureDefaultCosts(ctx context.Context) error {
|
||||||
@@ -900,6 +937,10 @@ type UsageSummary struct {
|
|||||||
ProductsProcessed int `json:"products_processed"`
|
ProductsProcessed int `json:"products_processed"`
|
||||||
ProductsTotal int `json:"products_total"`
|
ProductsTotal int `json:"products_total"`
|
||||||
Tokens int64 `json:"tokens"`
|
Tokens int64 `json:"tokens"`
|
||||||
|
InputTokens int64 `json:"input_tokens"`
|
||||||
|
CachedInputTokens int64 `json:"cached_input_tokens"`
|
||||||
|
OutputTokens int64 `json:"output_tokens"`
|
||||||
|
AICalls int64 `json:"ai_calls"`
|
||||||
FeedsInput int `json:"feeds_input"`
|
FeedsInput int `json:"feeds_input"`
|
||||||
FeedsExport int `json:"feeds_export"`
|
FeedsExport int `json:"feeds_export"`
|
||||||
JobsTotal int `json:"jobs_total"`
|
JobsTotal int `json:"jobs_total"`
|
||||||
@@ -1010,6 +1051,21 @@ func (s *Service) UsageSummary(ctx context.Context, companyID uuid.UUID, rangeRa
|
|||||||
out.ProductsProcessed = out.ProductsTotal
|
out.ProductsProcessed = out.ProductsTotal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detailed token usage comes from the durable per-call ledger, not processed
|
||||||
|
// product rows (a single product can make several model calls).
|
||||||
|
// A missing old ledger should not prevent viewing the rest of billing.
|
||||||
|
if err := s.Pool.QueryRow(ctx, `
|
||||||
|
SELECT COALESCE(SUM(prompt_tokens),0)::bigint,
|
||||||
|
COALESCE(SUM(cached_prompt_tokens),0)::bigint,
|
||||||
|
COALESCE(SUM(completion_tokens),0)::bigint,
|
||||||
|
COALESCE(SUM(calls),0)::bigint
|
||||||
|
FROM ai_usage_daily
|
||||||
|
WHERE company_id = $1 AND ($2::timestamptz IS NULL OR day >= $2::date)
|
||||||
|
AND ($3::timestamptz IS NULL OR day < $3::date)`,
|
||||||
|
companyID, since, until).Scan(&out.InputTokens, &out.CachedInputTokens, &out.OutputTokens, &out.AICalls); err != nil {
|
||||||
|
out.Notes = append(out.Notes, "Detailed token usage unavailable; check the AI usage ledger migration.")
|
||||||
|
}
|
||||||
|
|
||||||
if rangeKey == "7d" || rangeKey == "30d" || (rangeKey == "cycle" && since != nil) {
|
if rangeKey == "7d" || rangeKey == "30d" || (rangeKey == "cycle" && since != nil) {
|
||||||
seriesSince := now.Truncate(24*time.Hour).AddDate(0, 0, -29)
|
seriesSince := now.Truncate(24*time.Hour).AddDate(0, 0, -29)
|
||||||
days := 30
|
days := 30
|
||||||
|
|||||||
@@ -328,6 +328,10 @@ func (s *StripeService) CreateCheckoutSession(ctx context.Context, companyID uui
|
|||||||
return CheckoutResult{}, fmt.Errorf("%w: %s %s", ErrStripePriceMissing, plan, term)
|
return CheckoutResult{}, fmt.Errorf("%w: %s %s", ErrStripePriceMissing, plan, term)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := s.requireEuroStripePrice(ctx, priceID); err != nil {
|
||||||
|
return CheckoutResult{}, err
|
||||||
|
}
|
||||||
|
|
||||||
customerID, err := s.ensureCustomer(ctx, companyID, email, companyName)
|
customerID, err := s.ensureCustomer(ctx, companyID, email, companyName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return CheckoutResult{}, err
|
return CheckoutResult{}, err
|
||||||
@@ -406,6 +410,10 @@ func (s *StripeService) CreateCreditPackCheckout(ctx context.Context, companyID
|
|||||||
return CheckoutResult{}, fmt.Errorf("%w: credit pack %s", ErrStripePriceMissing, pack.ID)
|
return CheckoutResult{}, fmt.Errorf("%w: credit pack %s", ErrStripePriceMissing, pack.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := s.requireEuroStripePrice(ctx, priceID); err != nil {
|
||||||
|
return CheckoutResult{}, err
|
||||||
|
}
|
||||||
|
|
||||||
customerID, err := s.ensureCustomer(ctx, companyID, email, companyName)
|
customerID, err := s.ensureCustomer(ctx, companyID, email, companyName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return CheckoutResult{}, err
|
return CheckoutResult{}, err
|
||||||
@@ -1034,6 +1042,22 @@ func verifyStripeSignature(payload []byte, header, secret string, tolerance time
|
|||||||
return ErrStripeBadSignature
|
return ErrStripeBadSignature
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// requireEuroStripePrice blocks checkout against old USD Stripe Price IDs.
|
||||||
|
// Publishing euro list prices cannot alter an existing Stripe Price currency.
|
||||||
|
func (s *StripeService) requireEuroStripePrice(ctx context.Context, priceID string) error {
|
||||||
|
var price struct {
|
||||||
|
Currency string `json:"currency"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
}
|
||||||
|
if err := s.stripeGET(ctx, "https://api.stripe.com/v1/prices/"+url.PathEscape(priceID), &price); err != nil {
|
||||||
|
return fmt.Errorf("verify Stripe EUR price: %w", err)
|
||||||
|
}
|
||||||
|
if !price.Active || !strings.EqualFold(strings.TrimSpace(price.Currency), "eur") {
|
||||||
|
return errors.New("Stripe Price must be active and denominated in EUR; configure a EUR Price ID before checkout")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// LoadStripePriceIDs reads STRIPE_PRICE_* env into the price map.
|
// LoadStripePriceIDs reads STRIPE_PRICE_* env into the price map.
|
||||||
func LoadStripePriceIDs(getenv func(string) string) map[string]string {
|
func LoadStripePriceIDs(getenv func(string) string) map[string]string {
|
||||||
out := map[string]string{}
|
out := map[string]string{}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package billing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StripeInvoice contains only identifiers and URLs supplied by Stripe, never a
|
||||||
|
// locally invented financial document. Amounts are in the invoice currency's
|
||||||
|
// smallest unit, as returned by Stripe.
|
||||||
|
type StripeInvoice struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Number string `json:"number"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Currency string `json:"currency"`
|
||||||
|
Created int64 `json:"created"`
|
||||||
|
AmountDue int64 `json:"amount_due"`
|
||||||
|
AmountPaid int64 `json:"amount_paid"`
|
||||||
|
AmountRemaining int64 `json:"amount_remaining"`
|
||||||
|
HostedInvoiceURL string `json:"hosted_invoice_url,omitempty"`
|
||||||
|
InvoicePDF string `json:"invoice_pdf,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StripeService) ListCompanyInvoices(ctx context.Context, companyID uuid.UUID) ([]StripeInvoice, error) {
|
||||||
|
ctx, cfg, err := s.bindCfg(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if cfg.MockMode() {
|
||||||
|
return []StripeInvoice{}, nil
|
||||||
|
}
|
||||||
|
var customerID *string
|
||||||
|
err = s.Pool.QueryRow(ctx, `SELECT stripe_customer_id FROM companies WHERE id=$1`, companyID).Scan(&customerID)
|
||||||
|
if errors.Is(err, pgx.ErrNoRows) || customerID == nil || strings.TrimSpace(*customerID) == "" {
|
||||||
|
return []StripeInvoice{}, nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var result struct {
|
||||||
|
Data []StripeInvoice `json:"data"`
|
||||||
|
}
|
||||||
|
endpoint := "https://api.stripe.com/v1/invoices?limit=100&customer=" + url.QueryEscape(*customerID)
|
||||||
|
if err := s.stripeGET(ctx, endpoint, &result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if result.Data == nil {
|
||||||
|
result.Data = []StripeInvoice{}
|
||||||
|
}
|
||||||
|
return result.Data, nil
|
||||||
|
}
|
||||||
@@ -64,7 +64,10 @@ func (s *StripeService) CreateSalesQuoteCheckout(ctx context.Context, in SalesQu
|
|||||||
}
|
}
|
||||||
currency := strings.ToLower(strings.TrimSpace(in.Currency))
|
currency := strings.ToLower(strings.TrimSpace(in.Currency))
|
||||||
if currency == "" {
|
if currency == "" {
|
||||||
currency = "usd"
|
currency = "eur"
|
||||||
|
}
|
||||||
|
if currency != "eur" {
|
||||||
|
return SalesQuoteCheckoutResult{}, fmt.Errorf("%w: only EUR sales quotes are supported", ErrStripePlanUnsupported)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cfg, err := s.bindCfg(ctx)
|
ctx, cfg, err := s.bindCfg(ctx)
|
||||||
@@ -206,7 +209,7 @@ func (s *StripeService) createSalesQuotePrice(ctx context.Context, productID str
|
|||||||
form.Set("product", productID)
|
form.Set("product", productID)
|
||||||
form.Set("currency", strings.ToLower(strings.TrimSpace(in.Currency)))
|
form.Set("currency", strings.ToLower(strings.TrimSpace(in.Currency)))
|
||||||
if form.Get("currency") == "" {
|
if form.Get("currency") == "" {
|
||||||
form.Set("currency", "usd")
|
form.Set("currency", "eur")
|
||||||
}
|
}
|
||||||
form.Set("unit_amount", strconv.Itoa(in.InstallmentAmountCents))
|
form.Set("unit_amount", strconv.Itoa(in.InstallmentAmountCents))
|
||||||
form.Set("metadata[descrybe_sales_quote]", in.QuoteID.String())
|
form.Set("metadata[descrybe_sales_quote]", in.QuoteID.String())
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type SyncCreditPackResult struct {
|
|||||||
PriceID string `json:"price_id"`
|
PriceID string `json:"price_id"`
|
||||||
Created bool `json:"created"`
|
Created bool `json:"created"`
|
||||||
Credits int `json:"credits"`
|
Credits int `json:"credits"`
|
||||||
PriceUSD int `json:"price_usd"`
|
PriceEUR int `json:"price_eur"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncCreditPackProducts creates/updates Stripe Products + one-time Prices for
|
// SyncCreditPackProducts creates/updates Stripe Products + one-time Prices for
|
||||||
@@ -47,7 +47,7 @@ func (s *StripeService) SyncCreditPackProducts(ctx context.Context) ([]SyncCredi
|
|||||||
PriceID: priceID,
|
PriceID: priceID,
|
||||||
Created: createdProduct || createdPrice,
|
Created: createdProduct || createdPrice,
|
||||||
Credits: pack.Credits,
|
Credits: pack.Credits,
|
||||||
PriceUSD: pack.PriceUSD,
|
PriceEUR: pack.PriceEUR,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
@@ -73,7 +73,7 @@ func (s *StripeService) ensureCreditPackProduct(ctx context.Context, pack Credit
|
|||||||
form.Set("metadata[descrybe_pack]", pack.ID)
|
form.Set("metadata[descrybe_pack]", pack.ID)
|
||||||
form.Set("metadata[credits]", strconv.Itoa(pack.Credits))
|
form.Set("metadata[credits]", strconv.Itoa(pack.Credits))
|
||||||
form.Set("metadata[ai_products]", strconv.Itoa(pack.AIProducts))
|
form.Set("metadata[ai_products]", strconv.Itoa(pack.AIProducts))
|
||||||
form.Set("metadata[price_usd]", strconv.Itoa(pack.PriceUSD))
|
form.Set("metadata[price_eur]", strconv.Itoa(pack.PriceEUR))
|
||||||
var product struct {
|
var product struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ func (s *StripeService) ensureCreditPackProduct(ctx context.Context, pack Credit
|
|||||||
|
|
||||||
func (s *StripeService) ensureCreditPackPrice(ctx context.Context, productID string, pack CreditPack) (priceID string, created bool, err error) {
|
func (s *StripeService) ensureCreditPackPrice(ctx context.Context, productID string, pack CreditPack) (priceID string, created bool, err error) {
|
||||||
// Reuse an active one-time price on this product that matches unit amount.
|
// Reuse an active one-time price on this product that matches unit amount.
|
||||||
wantCents := pack.PriceUSD * 100
|
wantCents := pack.PriceEUR * 100
|
||||||
var list struct {
|
var list struct {
|
||||||
Data []struct {
|
Data []struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
@@ -103,14 +103,14 @@ func (s *StripeService) ensureCreditPackPrice(ctx context.Context, productID str
|
|||||||
return "", false, err
|
return "", false, err
|
||||||
}
|
}
|
||||||
for _, p := range list.Data {
|
for _, p := range list.Data {
|
||||||
if p.Active && p.Type == "one_time" && strings.EqualFold(p.Currency, "usd") && int(p.UnitAmount) == wantCents {
|
if p.Active && p.Type == "one_time" && strings.EqualFold(p.Currency, "eur") && int(p.UnitAmount) == wantCents {
|
||||||
return p.ID, false, nil
|
return p.ID, false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
form := url.Values{}
|
form := url.Values{}
|
||||||
form.Set("product", productID)
|
form.Set("product", productID)
|
||||||
form.Set("currency", "usd")
|
form.Set("currency", "eur")
|
||||||
form.Set("unit_amount", strconv.Itoa(wantCents))
|
form.Set("unit_amount", strconv.Itoa(wantCents))
|
||||||
form.Set("metadata[descrybe_pack]", pack.ID)
|
form.Set("metadata[descrybe_pack]", pack.ID)
|
||||||
form.Set("metadata[credits]", strconv.Itoa(pack.Credits))
|
form.Set("metadata[credits]", strconv.Itoa(pack.Credits))
|
||||||
|
|||||||
@@ -205,19 +205,19 @@ func TestCreditPackCatalog(t *testing.T) {
|
|||||||
t.Fatalf("want at least 7 packs, got %d", len(packs))
|
t.Fatalf("want at least 7 packs, got %d", len(packs))
|
||||||
}
|
}
|
||||||
tiny, ok := CreditPackByID("tiny")
|
tiny, ok := CreditPackByID("tiny")
|
||||||
if !ok || tiny.Credits != 25 || tiny.PriceUSD != 29 {
|
if !ok || tiny.Credits != 25 || tiny.PriceEUR != 29 {
|
||||||
t.Fatalf("tiny pack: %#v ok=%v", tiny, ok)
|
t.Fatalf("tiny pack: %#v ok=%v", tiny, ok)
|
||||||
}
|
}
|
||||||
small, ok := CreditPackByID("small")
|
small, ok := CreditPackByID("small")
|
||||||
if !ok || small.Credits != 65 || small.PriceUSD != 59 {
|
if !ok || small.Credits != 65 || small.PriceEUR != 59 {
|
||||||
t.Fatalf("small pack: %#v ok=%v", small, ok)
|
t.Fatalf("small pack: %#v ok=%v", small, ok)
|
||||||
}
|
}
|
||||||
med, ok := CreditPackByID("medium")
|
med, ok := CreditPackByID("medium")
|
||||||
if !ok || med.Credits != 200 || med.PriceUSD != 149 {
|
if !ok || med.Credits != 200 || med.PriceEUR != 149 {
|
||||||
t.Fatalf("medium pack: %#v ok=%v", med, ok)
|
t.Fatalf("medium pack: %#v ok=%v", med, ok)
|
||||||
}
|
}
|
||||||
mega, ok := CreditPackByID("mega")
|
mega, ok := CreditPackByID("mega")
|
||||||
if !ok || mega.Credits != 8000 || mega.PriceUSD != 2999 {
|
if !ok || mega.Credits != 8000 || mega.PriceEUR != 2999 {
|
||||||
t.Fatalf("mega pack: %#v ok=%v", mega, ok)
|
t.Fatalf("mega pack: %#v ok=%v", mega, ok)
|
||||||
}
|
}
|
||||||
if CreditPackSettingsKey("small") != "stripe.price.pack.small" {
|
if CreditPackSettingsKey("small") != "stripe.price.pack.small" {
|
||||||
|
|||||||
@@ -1159,7 +1159,7 @@ func (s *Service) ListProcessedProducts(ctx context.Context, companyID uuid.UUID
|
|||||||
p.category,
|
p.category,
|
||||||
cat.name AS category_name,
|
cat.name AS category_name,
|
||||||
COALESCE(cat.unique_id, NULLIF(BTRIM(p.category), '')) AS category_unique_id,
|
COALESCE(cat.unique_id, NULLIF(BTRIM(p.category), '')) AS category_unique_id,
|
||||||
p.status, p.raw_product_id, COALESCE(p.feed_id, r.feed_id) AS feed_id, r.gtin,
|
p.status, p.processing_origin, p.raw_product_id, COALESCE(p.feed_id, r.feed_id) AS feed_id, r.gtin,
|
||||||
f.name AS feed_name,
|
f.name AS feed_name,
|
||||||
f.last_synced_at AS feed_last_synced_at,
|
f.last_synced_at AS feed_last_synced_at,
|
||||||
r.updated_at AS raw_updated_at,
|
r.updated_at AS raw_updated_at,
|
||||||
@@ -1184,7 +1184,7 @@ func (s *Service) ListProcessedProducts(ctx context.Context, companyID uuid.UUID
|
|||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
items, err := scanMaps(rows, []string{
|
items, err := scanMaps(rows, []string{
|
||||||
"id", "product_id", "name", "original_name", "processed_name", "category", "category_name", "category_unique_id",
|
"id", "product_id", "name", "original_name", "processed_name", "category", "category_name", "category_unique_id",
|
||||||
"status", "raw_product_id", "feed_id", "gtin",
|
"status", "processing_origin", "raw_product_id", "feed_id", "gtin",
|
||||||
"feed_name", "feed_last_synced_at", "raw_updated_at",
|
"feed_name", "feed_last_synced_at", "raw_updated_at",
|
||||||
"has_name", "has_processed_name", "has_description", "has_processed_description", "has_category", "has_attributes", "has_processed_attributes",
|
"has_name", "has_processed_name", "has_description", "has_processed_description", "has_category", "has_attributes", "has_processed_attributes",
|
||||||
"has_eprel",
|
"has_eprel",
|
||||||
@@ -1250,7 +1250,7 @@ func (s *Service) ListProcessedProductsDetailed(ctx context.Context, companyID u
|
|||||||
cat.name AS category_name,
|
cat.name AS category_name,
|
||||||
COALESCE(cat.unique_id, NULLIF(BTRIM(p.category), '')) AS category_unique_id,
|
COALESCE(cat.unique_id, NULLIF(BTRIM(p.category), '')) AS category_unique_id,
|
||||||
`+processedFeedCategorySQL+` AS feed_category,
|
`+processedFeedCategorySQL+` AS feed_category,
|
||||||
p.status, p.raw_product_id, p.feed_id, r.gtin,
|
p.status, p.processing_origin, p.raw_product_id, p.feed_id, r.gtin,
|
||||||
`+processedPreferredDescriptionSQL+` AS description,
|
`+processedPreferredDescriptionSQL+` AS description,
|
||||||
`+processedOriginalDescriptionSQL+` AS original_description,
|
`+processedOriginalDescriptionSQL+` AS original_description,
|
||||||
p.processed_name, p.processed_description,
|
p.processed_name, p.processed_description,
|
||||||
@@ -1268,7 +1268,7 @@ func (s *Service) ListProcessedProductsDetailed(ctx context.Context, companyID u
|
|||||||
items, err := scanMaps(rows, []string{
|
items, err := scanMaps(rows, []string{
|
||||||
"id", "product_id", "name", "original_name", "category", "category_name", "category_unique_id",
|
"id", "product_id", "name", "original_name", "category", "category_name", "category_unique_id",
|
||||||
"feed_category",
|
"feed_category",
|
||||||
"status", "raw_product_id", "feed_id", "gtin",
|
"status", "processing_origin", "raw_product_id", "feed_id", "gtin",
|
||||||
"description", "original_description", "processed_name", "processed_description",
|
"description", "original_description", "processed_name", "processed_description",
|
||||||
"meta_title", "meta_description",
|
"meta_title", "meta_description",
|
||||||
"attributes", "processed_attributes", "mapped_data",
|
"attributes", "processed_attributes", "mapped_data",
|
||||||
@@ -1299,7 +1299,7 @@ func (s *Service) GetProcessedProduct(ctx context.Context, companyID, id uuid.UU
|
|||||||
p.processed_name, p.processed_description,
|
p.processed_name, p.processed_description,
|
||||||
COALESCE(p.meta_title, '') AS meta_title,
|
COALESCE(p.meta_title, '') AS meta_title,
|
||||||
COALESCE(p.meta_description, '') AS meta_description,
|
COALESCE(p.meta_description, '') AS meta_description,
|
||||||
p.status, p.attributes, p.processed_attributes, r.gtin, r.mapped_data,
|
p.status, p.processing_origin, p.attributes, p.processed_attributes, r.gtin, r.mapped_data,
|
||||||
COALESCE(p.feed_id, r.feed_id) AS feed_id,
|
COALESCE(p.feed_id, r.feed_id) AS feed_id,
|
||||||
f.name AS feed_name,
|
f.name AS feed_name,
|
||||||
f.last_synced_at AS feed_last_synced_at,
|
f.last_synced_at AS feed_last_synced_at,
|
||||||
@@ -1320,7 +1320,7 @@ func (s *Service) GetProcessedProduct(ctx context.Context, companyID, id uuid.UU
|
|||||||
"feed_category",
|
"feed_category",
|
||||||
"description", "original_description", "processed_name", "processed_description",
|
"description", "original_description", "processed_name", "processed_description",
|
||||||
"meta_title", "meta_description",
|
"meta_title", "meta_description",
|
||||||
"status", "attributes", "processed_attributes", "gtin", "mapped_data",
|
"status", "processing_origin", "attributes", "processed_attributes", "gtin", "mapped_data",
|
||||||
"feed_id", "feed_name", "feed_last_synced_at", "raw_updated_at",
|
"feed_id", "feed_name", "feed_last_synced_at", "raw_updated_at",
|
||||||
"has_processed_name", "has_processed_description", "has_attributes", "has_processed_attributes",
|
"has_processed_name", "has_processed_description", "has_attributes", "has_processed_attributes",
|
||||||
"has_eprel",
|
"has_eprel",
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package httpapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/csv"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Exports audited AI usage by company. This is an operational cost report, NOT
|
||||||
|
// a customer invoice or the amount charged by Stripe.
|
||||||
|
func (s *Server) handleAdminExportAICosts(w http.ResponseWriter, r *http.Request) {
|
||||||
|
q := r.URL.Query()
|
||||||
|
from, to, err := adminCostRange(q.Get("from"), q.Get("to"), q.Get("days"))
|
||||||
|
if err != nil {
|
||||||
|
Error(w, http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
args := []any{from, to}
|
||||||
|
where := "day >= $1 AND day <= $2"
|
||||||
|
if raw := strings.TrimSpace(q.Get("company_id")); raw != "" {
|
||||||
|
cid, err := uuid.Parse(raw)
|
||||||
|
if err != nil {
|
||||||
|
Error(w, http.StatusBadRequest, "invalid company_id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
args = append(args, cid)
|
||||||
|
where += " AND company_id = $3"
|
||||||
|
}
|
||||||
|
result, err := s.scanCostGroup(r.Context(), costGroupCompany, where, args)
|
||||||
|
if err != nil {
|
||||||
|
LogAndError(w, http.StatusInternalServerError, "could not export AI costs", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
|
||||||
|
w.Header().Set("Content-Disposition", `attachment; filename="descrybe-ai-usage-costs.csv"`)
|
||||||
|
w.Header().Set("Cache-Control", "private, no-store")
|
||||||
|
out := csv.NewWriter(w)
|
||||||
|
_ = out.Write([]string{"from", "to", "company_id", "company", "calls", "failed_calls", "input_tokens", "cached_input_tokens", "output_tokens", "total_tokens", "provider_cost_usd", "notice"})
|
||||||
|
v := func(row map[string]any, key string) string { return strconv.FormatInt(int64(row[key].(int64)), 10) }
|
||||||
|
for _, row := range result {
|
||||||
|
cost := float64(row["cost_micros"].(int64)) / 1000000.0
|
||||||
|
_ = out.Write([]string{from.Format("2006-01-02"), to.Format("2006-01-02"), row["id"].(string), row["label"].(string),
|
||||||
|
v(row, "calls"), v(row, "failed_calls"), v(row, "prompt_tokens"), v(row, "cached_prompt_tokens"),
|
||||||
|
v(row, "completion_tokens"), v(row, "total_tokens"), strconv.FormatFloat(cost, 'f', 6, 64),
|
||||||
|
"Provider operating cost in USD; NOT client revenue, Stripe invoice, or payable total"})
|
||||||
|
}
|
||||||
|
out.Flush()
|
||||||
|
}
|
||||||
@@ -172,7 +172,7 @@ func (s *Server) scanCostGroup(ctx context.Context, group costGroup, whereSQL st
|
|||||||
COALESCE(sum(u.cost_micros),0)
|
COALESCE(sum(u.cost_micros),0)
|
||||||
FROM ai_usage_daily u
|
FROM ai_usage_daily u
|
||||||
LEFT JOIN companies c ON c.id = u.company_id
|
LEFT JOIN companies c ON c.id = u.company_id
|
||||||
WHERE ` + whereSQL + `
|
WHERE ` + strings.ReplaceAll(whereSQL, "company_id =", "u.company_id =") + `
|
||||||
GROUP BY u.company_id, c.name
|
GROUP BY u.company_id, c.name
|
||||||
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
|
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
|
||||||
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
|
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
|
||||||
@@ -186,7 +186,7 @@ func (s *Server) scanCostGroup(ctx context.Context, group costGroup, whereSQL st
|
|||||||
FROM ai_usage_daily u
|
FROM ai_usage_daily u
|
||||||
LEFT JOIN users usr ON usr.id = u.user_id
|
LEFT JOIN users usr ON usr.id = u.user_id
|
||||||
LEFT JOIN companies c ON c.id = u.company_id
|
LEFT JOIN companies c ON c.id = u.company_id
|
||||||
WHERE ` + whereSQL + `
|
WHERE ` + strings.ReplaceAll(whereSQL, "company_id =", "u.company_id =") + `
|
||||||
GROUP BY u.user_id, usr.email, u.company_id, c.name
|
GROUP BY u.user_id, usr.email, u.company_id, c.name
|
||||||
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
|
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
|
||||||
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
|
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
|
||||||
@@ -198,7 +198,7 @@ func (s *Server) scanCostGroup(ctx context.Context, group costGroup, whereSQL st
|
|||||||
COALESCE(sum(u.completion_tokens),0), COALESCE(sum(u.total_tokens),0),
|
COALESCE(sum(u.completion_tokens),0), COALESCE(sum(u.total_tokens),0),
|
||||||
COALESCE(sum(u.cost_micros),0)
|
COALESCE(sum(u.cost_micros),0)
|
||||||
FROM ai_usage_daily u
|
FROM ai_usage_daily u
|
||||||
WHERE ` + whereSQL + `
|
WHERE ` + strings.ReplaceAll(whereSQL, "company_id =", "u.company_id =") + `
|
||||||
GROUP BY u.model
|
GROUP BY u.model
|
||||||
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
|
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
|
||||||
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
|
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
|
||||||
|
|||||||
@@ -151,13 +151,16 @@ func (s *Server) handleAdminAnalytics(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
tokenByDay := map[string]adminDayPoint{}
|
tokenByDay := map[string]adminDayPoint{}
|
||||||
tokRows, err := s.Pool.Query(ctx, `
|
tokRows, err := s.Pool.Query(ctx, `
|
||||||
SELECT (created_at AT TIME ZONE 'UTC')::date AS d,
|
WITH tokens AS (
|
||||||
COALESCE(SUM(COALESCE(total_tokens, 0)), 0)::bigint,
|
SELECT day AS d, COALESCE(SUM(total_tokens),0)::bigint AS tok
|
||||||
COUNT(*)::bigint
|
FROM ai_usage_daily WHERE day >= $1::date GROUP BY 1
|
||||||
FROM processed_products
|
), products AS (
|
||||||
WHERE created_at >= $1
|
SELECT (created_at AT TIME ZONE 'UTC')::date AS d, COUNT(*)::bigint AS cnt
|
||||||
GROUP BY 1
|
FROM processed_products WHERE created_at >= $1 GROUP BY 1
|
||||||
ORDER BY 1`, since)
|
)
|
||||||
|
SELECT COALESCE(t.d,p.d) AS d, COALESCE(t.tok,0)::bigint, COALESCE(p.cnt,0)::bigint
|
||||||
|
FROM tokens t FULL OUTER JOIN products p ON t.d=p.d
|
||||||
|
ORDER BY 1`, since)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error(w, http.StatusInternalServerError, "analytics token series failed")
|
Error(w, http.StatusInternalServerError, "analytics token series failed")
|
||||||
return
|
return
|
||||||
@@ -326,7 +329,7 @@ func (s *Server) handleAdminAnalytics(w http.ResponseWriter, r *http.Request) {
|
|||||||
"providers": providers,
|
"providers": providers,
|
||||||
"tokens_by_provider_detail": providerDetail,
|
"tokens_by_provider_detail": providerDetail,
|
||||||
"notes": []string{
|
"notes": []string{
|
||||||
"Tokens come from processed_products.total_tokens (LLM usage recorded per product).",
|
"Tokens come from the durable ai_usage_daily call ledger (input + output), including multiple calls per product.",
|
||||||
"Provider classes use processed_products.ai_provider_mode: internal | popular:<name> | custom (blank/unknown rolled into the internal card).",
|
"Provider classes use processed_products.ai_provider_mode: internal | popular:<name> | custom (blank/unknown rolled into the internal card).",
|
||||||
"Job tokens use processing_jobs.estimated_tokens (running tally during jobs).",
|
"Job tokens use processing_jobs.estimated_tokens (running tally during jobs).",
|
||||||
"Jobs stuck = status running with updated_at older than 2 hours (same threshold as diagnostics).",
|
"Jobs stuck = status running with updated_at older than 2 hours (same threshold as diagnostics).",
|
||||||
@@ -353,12 +356,12 @@ func (s *Server) loadAdminAnalyticsSummary(ctx context.Context, since time.Time)
|
|||||||
(SELECT COUNT(*)::bigint FROM companies WHERE created_at >= $1),
|
(SELECT COUNT(*)::bigint FROM companies WHERE created_at >= $1),
|
||||||
(SELECT COALESCE(SUM(total_credits), 0)::bigint FROM credit_balances),
|
(SELECT COALESCE(SUM(total_credits), 0)::bigint FROM credit_balances),
|
||||||
(SELECT COALESCE(SUM(used_credits), 0)::bigint FROM credit_balances),
|
(SELECT COALESCE(SUM(used_credits), 0)::bigint FROM credit_balances),
|
||||||
(SELECT COALESCE(SUM(COALESCE(total_tokens, 0)), 0)::bigint FROM processed_products),
|
(SELECT COALESCE(SUM(total_tokens), 0)::bigint FROM ai_usage_daily),
|
||||||
(SELECT COUNT(*)::bigint FROM processed_products),
|
(SELECT COUNT(*)::bigint FROM processed_products),
|
||||||
(SELECT COUNT(*)::bigint FROM raw_products),
|
(SELECT COUNT(*)::bigint FROM raw_products),
|
||||||
(SELECT COUNT(*)::bigint FROM input_feeds),
|
(SELECT COUNT(*)::bigint FROM input_feeds),
|
||||||
(SELECT COUNT(*)::bigint FROM export_feeds),
|
(SELECT COUNT(*)::bigint FROM export_feeds),
|
||||||
(SELECT COALESCE(SUM(COALESCE(total_tokens, 0)), 0)::bigint FROM processed_products WHERE created_at >= $1),
|
(SELECT COALESCE(SUM(total_tokens), 0)::bigint FROM ai_usage_daily WHERE day >= $1::date),
|
||||||
(SELECT COUNT(*)::bigint FROM processing_jobs WHERE created_at >= $1 AND status = 'failed'),
|
(SELECT COUNT(*)::bigint FROM processing_jobs WHERE created_at >= $1 AND status = 'failed'),
|
||||||
(SELECT COUNT(*)::bigint FROM processing_jobs WHERE created_at >= $1 AND status = 'completed'),
|
(SELECT COUNT(*)::bigint FROM processing_jobs WHERE created_at >= $1 AND status = 'completed'),
|
||||||
(SELECT COUNT(*)::bigint FROM processing_jobs
|
(SELECT COUNT(*)::bigint FROM processing_jobs
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package httpapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/csv"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Platform-admin export of actual Stripe invoice amounts (not estimated usage).
|
||||||
|
// Scope must be a single company; customer IDs are resolved server-side.
|
||||||
|
func (s *Server) handleAdminExportCompanyInvoices(w http.ResponseWriter, r *http.Request) {
|
||||||
|
id, err := uuid.Parse(strings.TrimSpace(r.URL.Query().Get("company_id")))
|
||||||
|
if err != nil {
|
||||||
|
Error(w, http.StatusBadRequest, "company_id is required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rows, err := s.stripeSvc().ListCompanyInvoices(r.Context(), id)
|
||||||
|
if err != nil {
|
||||||
|
LogAndError(w, http.StatusBadGateway, "could not export Stripe invoices", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
|
||||||
|
w.Header().Set("Content-Disposition", `attachment; filename="descrybe-stripe-invoices.csv"`)
|
||||||
|
w.Header().Set("Cache-Control", "private, no-store")
|
||||||
|
out := csv.NewWriter(w)
|
||||||
|
_ = out.Write([]string{"company_id", "invoice_id", "number", "status", "currency", "created_unix", "amount_due_minor", "amount_paid_minor", "amount_remaining_minor", "hosted_invoice_url", "invoice_pdf"})
|
||||||
|
for _, row := range rows {
|
||||||
|
_ = out.Write([]string{id.String(), row.ID, row.Number, row.Status, row.Currency,
|
||||||
|
strconv.FormatInt(row.Created, 10), strconv.FormatInt(row.AmountDue, 10),
|
||||||
|
strconv.FormatInt(row.AmountPaid, 10), strconv.FormatInt(row.AmountRemaining, 10),
|
||||||
|
row.HostedInvoiceURL, row.InvoicePDF})
|
||||||
|
}
|
||||||
|
out.Flush()
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package httpapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
var editableCostFeatures = map[string]bool{
|
||||||
|
"product_processing": true,
|
||||||
|
"openai_token_k": true,
|
||||||
|
"seo_meta_ai": true,
|
||||||
|
"campaign_copy": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) handleAdminGetProcessingCosts(w http.ResponseWriter, r *http.Request) {
|
||||||
|
rows, err := s.Pool.Query(r.Context(), `
|
||||||
|
SELECT 'default', '', feature_name, cost_per_unit FROM processing_costs WHERE is_active = true
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'plan', plan_id::text, feature_name, cost_per_unit FROM plan_processing_costs
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'company', company_id::text, feature_name, cost_per_unit FROM company_processing_costs
|
||||||
|
ORDER BY 1, 2, 3`)
|
||||||
|
if err != nil {
|
||||||
|
LogAndError(w, http.StatusInternalServerError, "could not load processing costs", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
out := make([]map[string]any, 0, 16)
|
||||||
|
for rows.Next() {
|
||||||
|
var scope, id, feature string
|
||||||
|
var cost int
|
||||||
|
if err := rows.Scan(&scope, &id, &feature, &cost); err != nil {
|
||||||
|
LogAndError(w, http.StatusInternalServerError, "could not scan processing costs", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
out = append(out, map[string]any{"scope": scope, "id": id, "feature": feature, "cost_per_unit": cost})
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
LogAndError(w, http.StatusInternalServerError, "could not read processing costs", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Cache-Control", "private, no-store")
|
||||||
|
JSON(w, http.StatusOK, map[string]any{"rules": out, "notes": "Company overrides take priority over plan rules. Changes affect future debits only."})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) handleAdminPutProcessingCost(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var body struct {
|
||||||
|
Scope string `json:"scope"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Feature string `json:"feature"`
|
||||||
|
Cost *int `json:"cost_per_unit"` // null removes an override; cannot remove global rule
|
||||||
|
}
|
||||||
|
if err := DecodeJSON(r, &body); err != nil {
|
||||||
|
Error(w, http.StatusBadRequest, "invalid json")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
body.Scope = strings.TrimSpace(strings.ToLower(body.Scope))
|
||||||
|
body.Feature = strings.TrimSpace(body.Feature)
|
||||||
|
if !editableCostFeatures[body.Feature] || (body.Cost != nil && (*body.Cost < 1 || *body.Cost > 1000000)) {
|
||||||
|
Error(w, http.StatusBadRequest, "invalid feature or credit cost")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx := r.Context()
|
||||||
|
var err error
|
||||||
|
switch body.Scope {
|
||||||
|
case "company":
|
||||||
|
id, parseErr := uuid.Parse(body.ID)
|
||||||
|
if parseErr != nil {
|
||||||
|
Error(w, http.StatusBadRequest, "invalid company id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if body.Cost == nil {
|
||||||
|
_, err = s.Pool.Exec(ctx, `DELETE FROM company_processing_costs WHERE company_id = $1 AND feature_name = $2`, id, body.Feature)
|
||||||
|
} else {
|
||||||
|
_, err = s.Pool.Exec(ctx, `INSERT INTO company_processing_costs (company_id,feature_name,cost_per_unit) VALUES ($1,$2,$3)
|
||||||
|
ON CONFLICT(company_id,feature_name) DO UPDATE SET cost_per_unit=EXCLUDED.cost_per_unit,updated_at=now()`, id, body.Feature, *body.Cost)
|
||||||
|
}
|
||||||
|
case "plan":
|
||||||
|
id, parseErr := strconv.ParseInt(body.ID, 10, 64)
|
||||||
|
if parseErr != nil || id <= 0 {
|
||||||
|
Error(w, http.StatusBadRequest, "invalid plan id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if body.Cost == nil {
|
||||||
|
_, err = s.Pool.Exec(ctx, `DELETE FROM plan_processing_costs WHERE plan_id = $1 AND feature_name = $2`, id, body.Feature)
|
||||||
|
} else {
|
||||||
|
_, err = s.Pool.Exec(ctx, `INSERT INTO plan_processing_costs (plan_id,feature_name,cost_per_unit) VALUES ($1,$2,$3)
|
||||||
|
ON CONFLICT(plan_id,feature_name) DO UPDATE SET cost_per_unit=EXCLUDED.cost_per_unit,updated_at=now()`, id, body.Feature, *body.Cost)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
Error(w, http.StatusBadRequest, "scope must be company or plan")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
LogAndError(w, http.StatusBadRequest, "could not save processing cost", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Cache-Control", "private, no-store")
|
||||||
|
JSON(w, http.StatusOK, map[string]any{"status": "ok"})
|
||||||
|
}
|
||||||
@@ -57,12 +57,12 @@ func (s *Server) handleAdminSyncStripeCreditPacks(w http.ResponseWriter, r *http
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
written = append(written, map[string]any{
|
written = append(written, map[string]any{
|
||||||
"pack_id": row.PackID,
|
"pack_id": row.PackID,
|
||||||
"product_id": row.ProductID,
|
"product_id": row.ProductID,
|
||||||
"price_id": row.PriceID,
|
"price_id": row.PriceID,
|
||||||
"credits": row.Credits,
|
"credits": row.Credits,
|
||||||
"price_usd": row.PriceUSD,
|
"price_eur": row.PriceEUR,
|
||||||
"created": row.Created,
|
"created": row.Created,
|
||||||
"settings_key": key,
|
"settings_key": key,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,3 +155,19 @@ func (s *Server) handleRunBillingCycles(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
JSON(w, http.StatusOK, out)
|
JSON(w, http.StatusOK, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleListBillingInvoices lists genuine Stripe invoices for the active company.
|
||||||
|
// Private Stripe payment and PDF links are only accessible to company owners.
|
||||||
|
func (s *Server) handleListBillingInvoices(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if !s.allowCompanyOwnerOrPlatform(w, r) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cid, _ := CompanyIDFromContext(r.Context())
|
||||||
|
invoices, err := s.stripeSvc().ListCompanyInvoices(r.Context(), cid)
|
||||||
|
if err != nil {
|
||||||
|
LogAndError(w, http.StatusBadGateway, "could not load invoices", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Cache-Control", "private, no-store")
|
||||||
|
JSON(w, http.StatusOK, map[string]any{"invoices": invoices, "source": "stripe"})
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package httpapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/csv"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Usage statements are informational exports, not tax invoices or payment records.
|
||||||
|
func (s *Server) handleBillingUsageExport(w http.ResponseWriter, r *http.Request) {
|
||||||
|
cid, _ := CompanyIDFromContext(r.Context())
|
||||||
|
if cid == uuid.Nil {
|
||||||
|
Error(w, http.StatusUnauthorized, "company required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
usage, err := s.Billing.UsageSummary(r.Context(), cid, r.URL.Query().Get("range"))
|
||||||
|
if err != nil {
|
||||||
|
LogAndError(w, http.StatusInternalServerError, "could not export usage", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
|
||||||
|
w.Header().Set("Content-Disposition", `attachment; filename="descrybe-usage.csv"`)
|
||||||
|
w.Header().Set("Cache-Control", "private, no-store")
|
||||||
|
out := csv.NewWriter(w)
|
||||||
|
_ = out.Write([]string{"company_id", "range", "metric", "value", "notes"})
|
||||||
|
rows := []struct {
|
||||||
|
label string
|
||||||
|
value int64
|
||||||
|
notes string
|
||||||
|
}{
|
||||||
|
{"ai_calls", usage.AICalls, "Recorded provider calls in period"},
|
||||||
|
{"input_tokens", usage.InputTokens, "Includes cached input"},
|
||||||
|
{"cached_input_tokens", usage.CachedInputTokens, "Subset of input"},
|
||||||
|
{"output_tokens", usage.OutputTokens, ""},
|
||||||
|
{"products_processed", int64(usage.ProductsProcessed), "Period"},
|
||||||
|
{"credits_used_wallet", int64(usage.CreditsUsed), "All-time wallet balance, not period credits"},
|
||||||
|
{"credits_remaining", int64(usage.CreditsRemaining), "Current wallet"},
|
||||||
|
}
|
||||||
|
for _, v := range rows {
|
||||||
|
_ = out.Write([]string{cid.String(), usage.Range, v.label, strconv.FormatInt(v.value, 10), v.notes})
|
||||||
|
}
|
||||||
|
out.Flush()
|
||||||
|
}
|
||||||
@@ -403,7 +403,14 @@ func (s *Server) handleSyncAndProcessSample(w http.ResponseWriter, r *http.Reque
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
procJobs, err := s.Processing.StartJob(r.Context(), cid, uid, rawIDs, processingType)
|
// Public API feed sample processing is API-origin too. The session-based
|
||||||
|
// feed preview keeps the review workflow used by the dashboard.
|
||||||
|
var procJobs []processing.Job
|
||||||
|
if strings.HasPrefix(r.URL.Path, "/api/v1/") {
|
||||||
|
procJobs, err = s.Processing.StartAPIJob(r.Context(), cid, uid, rawIDs, processingType)
|
||||||
|
} else {
|
||||||
|
procJobs, err = s.Processing.StartJob(r.Context(), cid, uid, rawIDs, processingType)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ClientOrLog(w, http.StatusBadRequest, "could not start processing", err, processing.ClientError)
|
ClientOrLog(w, http.StatusBadRequest, "could not start processing", err, processing.ClientError)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ var apiFeatureRoutes = map[string]string{
|
|||||||
"/api/billing/checkout": "billing.checkout",
|
"/api/billing/checkout": "billing.checkout",
|
||||||
"/api/billing/portal": "billing.customer_portal",
|
"/api/billing/portal": "billing.customer_portal",
|
||||||
"/api/billing/usage": "billing.overview",
|
"/api/billing/usage": "billing.overview",
|
||||||
|
"/api/billing/invoices": "billing.overview",
|
||||||
"/api/billing/plans": "billing.plans_compare",
|
"/api/billing/plans": "billing.plans_compare",
|
||||||
"/api/billing/credit-packs": "billing.overview",
|
"/api/billing/credit-packs": "billing.overview",
|
||||||
"/api/billing/stripe": "billing.overview",
|
"/api/billing/stripe": "billing.overview",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package httpapi
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
|
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
|
||||||
"github.com/descrybe/descrybe-v2/apps/api/internal/processing"
|
"github.com/descrybe/descrybe-v2/apps/api/internal/processing"
|
||||||
@@ -40,7 +41,15 @@ func (s *Server) handleStartProcessingJob(w http.ResponseWriter, r *http.Request
|
|||||||
}
|
}
|
||||||
ids = append(ids, id)
|
ids = append(ids, id)
|
||||||
}
|
}
|
||||||
jobs, err := s.Processing.StartJob(r.Context(), cid, uid, ids, body.ProcessingType)
|
// The shared handler serves session dashboard jobs and /api/v1/process.
|
||||||
|
// Public API results should be directly visible in the Processed catalog tab.
|
||||||
|
var jobs []processing.Job
|
||||||
|
var err error
|
||||||
|
if strings.HasPrefix(r.URL.Path, "/api/v1/") {
|
||||||
|
jobs, err = s.Processing.StartAPIJob(r.Context(), cid, uid, ids, body.ProcessingType)
|
||||||
|
} else {
|
||||||
|
jobs, err = s.Processing.StartJob(r.Context(), cid, uid, ids, body.ProcessingType)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if writePlanGate(w, err) {
|
if writePlanGate(w, err) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -407,6 +407,10 @@ func (s *Server) Router() http.Handler {
|
|||||||
r.Get("/diagnostics", s.handleAdminDiagnostics)
|
r.Get("/diagnostics", s.handleAdminDiagnostics)
|
||||||
r.Get("/ai-calls", s.handleAdminListAICalls)
|
r.Get("/ai-calls", s.handleAdminListAICalls)
|
||||||
r.Get("/ai-costs", s.handleAdminAICosts)
|
r.Get("/ai-costs", s.handleAdminAICosts)
|
||||||
|
r.Get("/ai-costs/export", s.handleAdminExportAICosts)
|
||||||
|
r.Get("/billing/invoices/export", s.handleAdminExportCompanyInvoices)
|
||||||
|
r.Get("/processing-costs", s.handleAdminGetProcessingCosts)
|
||||||
|
r.Put("/processing-costs", s.handleAdminPutProcessingCost)
|
||||||
r.Get("/ai-calls/{id}", s.handleAdminGetAICall)
|
r.Get("/ai-calls/{id}", s.handleAdminGetAICall)
|
||||||
r.Get("/analytics", s.handleAdminAnalytics)
|
r.Get("/analytics", s.handleAdminAnalytics)
|
||||||
r.Get("/jobs", s.handleAdminListJobs)
|
r.Get("/jobs", s.handleAdminListJobs)
|
||||||
@@ -476,6 +480,8 @@ func (s *Server) Router() http.Handler {
|
|||||||
r.Get("/billing/credits", s.handleCreditsOverview)
|
r.Get("/billing/credits", s.handleCreditsOverview)
|
||||||
r.Get("/billing/capabilities", s.handleGetCapabilities)
|
r.Get("/billing/capabilities", s.handleGetCapabilities)
|
||||||
r.Get("/billing/usage", s.handleBillingUsage)
|
r.Get("/billing/usage", s.handleBillingUsage)
|
||||||
|
r.Get("/billing/usage/export", s.handleBillingUsageExport)
|
||||||
|
r.Get("/billing/invoices", s.handleListBillingInvoices)
|
||||||
r.Get("/billing/plans", s.handleListPublicPlans)
|
r.Get("/billing/plans", s.handleListPublicPlans)
|
||||||
r.Get("/billing/credit-packs", s.handleListCreditPacks)
|
r.Get("/billing/credit-packs", s.handleListCreditPacks)
|
||||||
r.Get("/billing/stripe", s.handleStripeStatus)
|
r.Get("/billing/stripe", s.handleStripeStatus)
|
||||||
|
|||||||
@@ -18,12 +18,9 @@ info:
|
|||||||
## Authentication
|
## Authentication
|
||||||
|
|
||||||
Public /api/v1 operations require a company API key (Bearer or X-API-Key)
|
Public /api/v1 operations require a company API key (Bearer or X-API-Key)
|
||||||
except GET /health and GET /openapi.yaml. Dashboard-only Team/Admin
|
except GET /health and GET /openapi.yaml.
|
||||||
operations described separately use a signed-in session and CSRF header;
|
|
||||||
they are not executable with a company API key.
|
|
||||||
|
|
||||||
Document-level security is BearerAuth OR ApiKeyAuth (same key value).
|
Document-level security is BearerAuth OR ApiKeyAuth (same key value).
|
||||||
Do not send dashboard session cookies or CSRF tokens to /api/v1.
|
|
||||||
|
|
||||||
### Security schemes (components.securitySchemes)
|
### Security schemes (components.securitySchemes)
|
||||||
|
|
||||||
@@ -38,10 +35,8 @@ info:
|
|||||||
|
|
||||||
1. Sign in at https://api.descrybe.io
|
1. Sign in at https://api.descrybe.io
|
||||||
2. Open Settings -> API keys (/settings?tab=api-keys)
|
2. Open Settings -> API keys (/settings?tab=api-keys)
|
||||||
3. Company admins or teammates granted API Keys management permission create
|
3. Authorized users can create keys in Settings -> API keys. The secret is
|
||||||
a key via dashboard POST /api/api-keys
|
shown once and starts with dk_.
|
||||||
(session cookie + CSRF; not this public OpenAPI surface). The secret is
|
|
||||||
shown once and starts with dk_.
|
|
||||||
4. Store it securely. Later list/revoke shows only key_prefix (first 10
|
4. Store it securely. Later list/revoke shows only key_prefix (first 10
|
||||||
characters). Revoked keys fail auth immediately.
|
characters). Revoked keys fail auth immediately.
|
||||||
|
|
||||||
@@ -64,22 +59,19 @@ info:
|
|||||||
|
|
||||||
### 403 Forbidden
|
### 403 Forbidden
|
||||||
|
|
||||||
Bad API keys on /api/v1 never return 403 (always 401). Tenant scope comes
|
Invalid API keys return 401. Access to unrelated company resources
|
||||||
from the key; cross-company resources typically 404. HTTP 403 appears on
|
is denied by tenant-scoped authorization.
|
||||||
dashboard /api/* session routes (admin required, CSRF mismatch) under
|
|
||||||
Team/Admin tags (SessionCookie + CSRFHeader) - not this public key surface.
|
|
||||||
|
|
||||||
### Rate limits
|
### Rate limits
|
||||||
|
|
||||||
Heavy mutations are limited to 30 requests per minute per company
|
Processing and feed mutations are rate limited. Counts are per HTTP
|
||||||
(in-process per API replica; not shared across replicas). Counts HTTP
|
request, not per product in a batch. Limited POST paths:
|
||||||
requests, not products inside a bulk body. Limited POST paths:
|
|
||||||
|
|
||||||
- /products/process, /process, /process/{id}/retry
|
- /products/process, /process, /process/{id}/retry
|
||||||
- /feeds/{id}/sync, /feeds/{id}/extract-schema, /feeds/{id}/sync-process-sample
|
- /feeds/{id}/sync, /feeds/{id}/extract-schema, /feeds/{id}/sync-process-sample
|
||||||
- /export-feeds/{id}/generate, /export-feeds/{id}/export-products, /export-feeds/{id}/rotate-token (admin)
|
- /export-feeds/{id}/generate, /export-feeds/{id}/export-products, /export-feeds/{id}/rotate-token
|
||||||
|
|
||||||
Over limit: HTTP 429, header Retry-After: 60, body
|
Over limit: HTTP 429 with Retry-After and body
|
||||||
{ "error": "rate limit exceeded" } (see TooManyRequests). Ordinary GETs and
|
{ "error": "rate limit exceeded" } (see TooManyRequests). Ordinary GETs and
|
||||||
other mutations are outside this HTTP budget (process starts may still return
|
other mutations are outside this HTTP budget (process starts may still return
|
||||||
402 for plan/credits).
|
402 for plan/credits).
|
||||||
@@ -104,8 +96,8 @@ info:
|
|||||||
- Plan gates (credits / product limit / AI / EPREL / feature flags) run before
|
- Plan gates (credits / product limit / AI / EPREL / feature flags) run before
|
||||||
EnsureRaw catalog writes on the items[].ean path; blocked starts return HTTP 402
|
EnsureRaw catalog writes on the items[].ean path; blocked starts return HTTP 402
|
||||||
|
|
||||||
2. **Internal / dashboard-style jobs**
|
2. **Product processing jobs**
|
||||||
- POST /process with raw_product_ids (same body as POST /api/processing/jobs)
|
- POST /process with existing raw_product_ids
|
||||||
- GET /process, GET /process/{id}, cancel/terminate/retry
|
- GET /process, GET /process/{id}, cancel/terminate/retry
|
||||||
- Flat JSON (no data wrapper); 202 Accepted on start/retry
|
- Flat JSON (no data wrapper); 202 Accepted on start/retry
|
||||||
- Plan gates return HTTP 402 with PlanGateError (error + code + upgrade_url)
|
- Plan gates return HTTP 402 with PlanGateError (error + code + upgrade_url)
|
||||||
@@ -142,8 +134,7 @@ info:
|
|||||||
product titles or descriptions. Company feature policies may still suppress
|
product titles or descriptions. Company feature policies may still suppress
|
||||||
metadata output.
|
metadata output.
|
||||||
|
|
||||||
Note: Dashboard JSON under /api/* uses session cookies + CSRF and is separate
|
Other path aliases
|
||||||
from this public API-key surface. Other path aliases
|
|
||||||
(/categories/create, /attributes/create, /campaigns) appear next to canonical paths.
|
(/categories/create, /attributes/create, /campaigns) appear next to canonical paths.
|
||||||
servers:
|
servers:
|
||||||
- url: https://api.descrybe.io/api/v1
|
- url: https://api.descrybe.io/api/v1
|
||||||
@@ -161,10 +152,6 @@ tags:
|
|||||||
- name: Campaigns
|
- name: Campaigns
|
||||||
description: Seasonal content calendar (/campaigns aliases)
|
description: Seasonal content calendar (/campaigns aliases)
|
||||||
- name: Processing
|
- name: Processing
|
||||||
- name: Team
|
|
||||||
description: Dashboard session routes under /api (not API-key)
|
|
||||||
- name: Admin
|
|
||||||
description: Platform-admin dashboard routes under /api (not API-key)
|
|
||||||
paths:
|
paths:
|
||||||
/health:
|
/health:
|
||||||
get:
|
get:
|
||||||
@@ -498,7 +485,7 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Selected products returned to unprocessed. Returned when ResetProductsToUnprocessed
|
description: Selected products returned to unprocessed. Returned when ResetProductsToUnprocessed
|
||||||
commits. Requires company-admin capability (API keys use role api and pass).
|
commits. Requires a valid company API key.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
@@ -528,14 +515,14 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: product_ids is required
|
error: product_ids is required
|
||||||
'403':
|
'403':
|
||||||
description: Caller role is neither admin nor api (requireCompanyAdmin). Valid company API keys
|
description: Access denied. Valid company API keys
|
||||||
use role api and do not hit this.
|
use role api and do not hit this.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'500':
|
'500':
|
||||||
description: Unexpected reset failure after validation.
|
description: Unexpected reset failure after validation.
|
||||||
content:
|
content:
|
||||||
@@ -642,15 +629,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -762,15 +747,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'404':
|
'404':
|
||||||
description: Resource id not found for this API-key company (or wrong tenant).
|
description: Resource id not found for this API-key company (or wrong tenant).
|
||||||
content:
|
content:
|
||||||
@@ -1034,15 +1017,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -1350,15 +1331,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -1467,15 +1446,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -1550,15 +1527,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -1931,15 +1906,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2013,15 +1986,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2321,15 +2292,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2447,15 +2416,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2482,7 +2449,7 @@ paths:
|
|||||||
- Feeds
|
- Feeds
|
||||||
summary: Delete feed
|
summary: Delete feed
|
||||||
description: >-
|
description: >-
|
||||||
Company-admin only. Atomically removes the input feed and its exclusively
|
Removes the input feed and its exclusively
|
||||||
owned, unprocessed or failed raw products. Previously processed products
|
owned, unprocessed or failed raw products. Previously processed products
|
||||||
are retained; active processing rows are not deleted, and products shared
|
are retained; active processing rows are not deleted, and products shared
|
||||||
with another existing feed are reassigned to that feed. Flat response
|
with another existing feed are reassigned to that feed. Flat response
|
||||||
@@ -2508,13 +2475,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: invalid id
|
error: invalid id
|
||||||
'403':
|
'403':
|
||||||
description: requireCompanyAdmin rejected the caller (session non-admin). API keys pass.
|
description: Access denied.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'404':
|
'404':
|
||||||
description: Feed not found.
|
description: Feed not found.
|
||||||
content:
|
content:
|
||||||
@@ -2608,15 +2575,13 @@ paths:
|
|||||||
code: not_found
|
code: not_found
|
||||||
message: Feed not found
|
message: Feed not found
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2726,15 +2691,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2834,15 +2797,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2934,15 +2895,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -2971,7 +2930,7 @@ paths:
|
|||||||
- Feeds
|
- Feeds
|
||||||
summary: Sync feed then process a sample of raw products
|
summary: Sync feed then process a sample of raw products
|
||||||
description: |
|
description: |
|
||||||
Optionally syncs the feed, then starts dashboard-style processing for up to N raw products
|
Optionally syncs the feed, then starts processing for up to N raw products
|
||||||
(default 10, max 100). Flat JSON; HTTP 202 when a job is queued, 200 when sync finishes with no products.
|
(default 10, max 100). Flat JSON; HTTP 202 when a job is queued, 200 when sync finishes with no products.
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/ID"
|
- $ref: "#/components/parameters/ID"
|
||||||
@@ -3061,15 +3020,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -3342,15 +3299,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -3450,15 +3405,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -3484,10 +3437,10 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- Export feeds
|
- Export feeds
|
||||||
summary: Delete export feed
|
summary: Delete export feed
|
||||||
description: "Company-admin only. Flat { status: ok } (not SuccessMessage)."
|
description: "Delete an export feed. Returns a deletion confirmation."
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Export feed deleted (admin capability; API keys pass). Flat deleted marker.
|
description: Export feed deleted.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
@@ -3504,13 +3457,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: invalid id
|
error: invalid id
|
||||||
'403':
|
'403':
|
||||||
description: requireCompanyAdmin rejected session non-admin.
|
description: Access denied.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'404':
|
'404':
|
||||||
description: Export feed not found.
|
description: Export feed not found.
|
||||||
content:
|
content:
|
||||||
@@ -3640,15 +3593,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -3677,7 +3628,7 @@ paths:
|
|||||||
summary: Rotate public export URL token
|
summary: Rotate public export URL token
|
||||||
description: |
|
description: |
|
||||||
Replaces public_token so the previous /api/public/export-feeds/{token}.{xml|csv|json}
|
Replaces public_token so the previous /api/public/export-feeds/{token}.{xml|csv|json}
|
||||||
URL stops working immediately. Requires company admin (or platform staff).
|
URL stops working immediately.
|
||||||
Response is a flat ExportFeedDetail including the new public_token.
|
Response is a flat ExportFeedDetail including the new public_token.
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: "#/components/parameters/ID"
|
- $ref: "#/components/parameters/ID"
|
||||||
@@ -3703,13 +3654,13 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/CodedAPIError"
|
$ref: "#/components/schemas/CodedAPIError"
|
||||||
'403':
|
'403':
|
||||||
description: Admin required.
|
description: Access denied.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
"400": { $ref: "#/components/responses/BadRequest" }
|
"400": { $ref: "#/components/responses/BadRequest" }
|
||||||
"422": { $ref: "#/components/responses/ValidationError" }
|
"422": { $ref: "#/components/responses/ValidationError" }
|
||||||
"500": { $ref: "#/components/responses/InternalServerError" }
|
"500": { $ref: "#/components/responses/InternalServerError" }
|
||||||
@@ -3792,15 +3743,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -3901,15 +3850,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -4294,7 +4241,7 @@ paths:
|
|||||||
- $ref: "#/components/parameters/Limit"
|
- $ref: "#/components/parameters/Limit"
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: "Recent dashboard-style jobs. Flat object with jobs[] and limit (handleV1ListProcessJobs\
|
description: "Recent processing jobs. Flat object with jobs[] and limit (\
|
||||||
\ — not a data envelope)."
|
\ — not a data envelope)."
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
@@ -4343,7 +4290,7 @@ paths:
|
|||||||
summary: Start processing job by raw_product_ids
|
summary: Start processing job by raw_product_ids
|
||||||
description: |
|
description: |
|
||||||
Enqueues AI processing for existing raw product UUIDs.
|
Enqueues AI processing for existing raw product UUIDs.
|
||||||
Same pipeline as dashboard POST /api/processing/jobs.
|
Uses the standard product processing pipeline.
|
||||||
Flat JSON body/response (no data wrapper); HTTP 202.
|
Flat JSON body/response (no data wrapper); HTTP 202.
|
||||||
Pass raw_products.id only (GET /products data[].raw_product_id), never PresentProduct.id.
|
Pass raw_products.id only (GET /products data[].raw_product_id), never PresentProduct.id.
|
||||||
|
|
||||||
@@ -4505,15 +4452,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'422':
|
'422':
|
||||||
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
|
||||||
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
or coded). 422 is documented for clients that expect an explicit validation status; body matches
|
||||||
@@ -4582,15 +4527,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'404':
|
'404':
|
||||||
description: Resource id not found for this API-key company (or wrong tenant).
|
description: Resource id not found for this API-key company (or wrong tenant).
|
||||||
content:
|
content:
|
||||||
@@ -4668,15 +4611,13 @@ paths:
|
|||||||
example:
|
example:
|
||||||
error: internal error
|
error: internal error
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'404':
|
'404':
|
||||||
description: Resource id not found for this API-key company (or wrong tenant).
|
description: Resource id not found for this API-key company (or wrong tenant).
|
||||||
content:
|
content:
|
||||||
@@ -4754,15 +4695,13 @@ paths:
|
|||||||
code: unauthorized
|
code: unauthorized
|
||||||
message: Unauthorized
|
message: Unauthorized
|
||||||
'403':
|
'403':
|
||||||
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
|
description: Access denied or resource unavailable to this company.
|
||||||
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
|
|
||||||
callers (API keys use role api and pass).
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
$ref: "#/components/schemas/FlatAPIError"
|
||||||
example:
|
example:
|
||||||
error: admin required
|
error: forbidden
|
||||||
'404':
|
'404':
|
||||||
description: Resource id not found for this API-key company (or wrong tenant).
|
description: Resource id not found for this API-key company (or wrong tenant).
|
||||||
content:
|
content:
|
||||||
@@ -4792,265 +4731,6 @@ paths:
|
|||||||
error:
|
error:
|
||||||
code: validation_error
|
code: validation_error
|
||||||
message: invalid json
|
message: invalid json
|
||||||
/team/{userID}:
|
|
||||||
parameters:
|
|
||||||
- name: userID
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
description: Membership user id within the selected company
|
|
||||||
patch:
|
|
||||||
tags:
|
|
||||||
- Team
|
|
||||||
summary: Update team member role
|
|
||||||
description: |
|
|
||||||
Company admin or platform admin. Demoting the last active admin returns 409.
|
|
||||||
Requires session cookie + CSRF double-submit (X-CSRF-Token).
|
|
||||||
Dashboard surface under /api (not the public /api/v1 API-key base).
|
|
||||||
security:
|
|
||||||
- SessionCookie: []
|
|
||||||
CSRFHeader: []
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- role
|
|
||||||
properties:
|
|
||||||
role:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- admin
|
|
||||||
- member
|
|
||||||
description: Normalized to admin|member (case-insensitive input accepted)
|
|
||||||
example:
|
|
||||||
role: member
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Role updated (or unchanged)
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- status
|
|
||||||
- role
|
|
||||||
- user_id
|
|
||||||
properties:
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
example: ok
|
|
||||||
role:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- admin
|
|
||||||
- member
|
|
||||||
user_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
example:
|
|
||||||
status: ok
|
|
||||||
role: member
|
|
||||||
user_id: 4f3c2b1a-0e9d-4c8b-7a6f-5e4d3c2b1a09
|
|
||||||
'400':
|
|
||||||
description: Invalid request for this route (HTTP 400).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: invalid json
|
|
||||||
'403':
|
|
||||||
description: Forbidden (not company/platform admin)
|
|
||||||
'404':
|
|
||||||
description: Resource not found (HTTP 404).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: not found
|
|
||||||
'409':
|
|
||||||
description: Cannot demote the last admin
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
error:
|
|
||||||
type: string
|
|
||||||
example: cannot demote the last admin
|
|
||||||
'401':
|
|
||||||
description: Missing or invalid API key. RequireAPIKey returns this when Authorization Bearer
|
|
||||||
and X-API-Key are both absent/empty or AuthenticateAPIKey returns ErrInvalidAPIKey. Coded
|
|
||||||
envelope (not a flat string).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/CodedAPIError"
|
|
||||||
example:
|
|
||||||
error:
|
|
||||||
code: unauthorized
|
|
||||||
message: Unauthorized
|
|
||||||
'422':
|
|
||||||
description: Validation failed. Dashboard routes may use this status; prefer reading the message.
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: validation failed
|
|
||||||
'500':
|
|
||||||
description: Unexpected server error (HTTP 500).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: list failed
|
|
||||||
/admin/emails/set-password:
|
|
||||||
post:
|
|
||||||
tags:
|
|
||||||
- Admin
|
|
||||||
summary: Re-issue set-password invites
|
|
||||||
description: |
|
|
||||||
Platform admin only. Prefers durable invite reissue (ReissueSetPasswordInvite);
|
|
||||||
falls back to HMAC set-password tokens when the user has no active membership.
|
|
||||||
Skips synthetic placeholder emails. Rate-limited per admin.
|
|
||||||
When SMTP is disabled and a single user_id is provided, the response may include
|
|
||||||
a one-time token for local/staging link copy (never logs email/token).
|
|
||||||
Dashboard surface under /api (not the public /api/v1 API-key base).
|
|
||||||
security:
|
|
||||||
- SessionCookie: []
|
|
||||||
CSRFHeader: []
|
|
||||||
requestBody:
|
|
||||||
required: false
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
user_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
description: |
|
|
||||||
Target user UUID. When omitted, bulk-targets users needing a password (capped).
|
|
||||||
example:
|
|
||||||
user_id: 4f3c2b1a-0e9d-4c8b-7a6f-5e4d3c2b1a09
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Issue/send summary
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- sent
|
|
||||||
- issued
|
|
||||||
- skipped
|
|
||||||
- smtp_enabled
|
|
||||||
- mode
|
|
||||||
properties:
|
|
||||||
sent:
|
|
||||||
type: integer
|
|
||||||
issued:
|
|
||||||
type: integer
|
|
||||||
skipped:
|
|
||||||
type: integer
|
|
||||||
skipped_synthetic:
|
|
||||||
type: integer
|
|
||||||
skipped_ineligible:
|
|
||||||
type: integer
|
|
||||||
skipped_rate_limited:
|
|
||||||
type: integer
|
|
||||||
skipped_send:
|
|
||||||
type: integer
|
|
||||||
smtp_enabled:
|
|
||||||
type: boolean
|
|
||||||
mode:
|
|
||||||
type: string
|
|
||||||
example: invite
|
|
||||||
token:
|
|
||||||
type: string
|
|
||||||
description: Present only for single-user reissue when SMTP is off
|
|
||||||
example:
|
|
||||||
sent: 1
|
|
||||||
issued: 1
|
|
||||||
skipped: 0
|
|
||||||
skipped_synthetic: 0
|
|
||||||
skipped_ineligible: 0
|
|
||||||
skipped_rate_limited: 0
|
|
||||||
skipped_send: 0
|
|
||||||
smtp_enabled: true
|
|
||||||
mode: invite
|
|
||||||
'401':
|
|
||||||
description: Unauthorized — missing session or privilege for this dashboard route.
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: unauthorized
|
|
||||||
'429':
|
|
||||||
description: Rate limit exceeded for this admin action. May include Retry-After.
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: Too many requests
|
|
||||||
'503':
|
|
||||||
description: Dependency unavailable (for example mailer down).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: mailer unavailable
|
|
||||||
'400':
|
|
||||||
description: Invalid request for this route (HTTP 400).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: invalid json
|
|
||||||
'403':
|
|
||||||
description: Forbidden for this route (HTTP 403).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: admin required
|
|
||||||
'409':
|
|
||||||
description: Conflict with current resource state.
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: conflict
|
|
||||||
'422':
|
|
||||||
description: Validation failed. Dashboard routes may use this status; prefer reading the message.
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: validation failed
|
|
||||||
'500':
|
|
||||||
description: Unexpected server error (HTTP 500).
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/FlatAPIError"
|
|
||||||
example:
|
|
||||||
error: list failed
|
|
||||||
components:
|
components:
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
BearerAuth:
|
BearerAuth:
|
||||||
@@ -5074,18 +4754,6 @@ components:
|
|||||||
Alternate scheme for /api/v1. Same company API key as BearerAuth, sent
|
Alternate scheme for /api/v1. Same company API key as BearerAuth, sent
|
||||||
as header X-API-Key: dk_your_key. When both Authorization Bearer and
|
as header X-API-Key: dk_your_key. When both Authorization Bearer and
|
||||||
X-API-Key are present, Bearer wins.
|
X-API-Key are present, Bearer wins.
|
||||||
SessionCookie:
|
|
||||||
type: apiKey
|
|
||||||
in: cookie
|
|
||||||
name: descrybe_session
|
|
||||||
description: Dashboard session cookie only (SESSION_COOKIE_NAME; default descrybe_session). Not
|
|
||||||
valid for /api/v1 public routes.
|
|
||||||
CSRFHeader:
|
|
||||||
type: apiKey
|
|
||||||
in: header
|
|
||||||
name: X-CSRF-Token
|
|
||||||
description: Dashboard CSRF double-submit header (must match descrybe_csrf cookie). Not used by
|
|
||||||
/api/v1 API-key routes.
|
|
||||||
parameters:
|
parameters:
|
||||||
ID:
|
ID:
|
||||||
in: path
|
in: path
|
||||||
|
|||||||
@@ -11,6 +11,27 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestV1OpenAPIYAMLDoesNotPublishAdminRoutes(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
root := mustParseOpenAPIRoot(t, v1OpenAPIYAML)
|
||||||
|
paths, ok := root["paths"].(map[string]any)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("missing paths map")
|
||||||
|
}
|
||||||
|
for path := range paths {
|
||||||
|
if strings.HasPrefix(path, "/admin/") || strings.HasPrefix(path, "/team/") {
|
||||||
|
t.Fatalf("non-public dashboard path leaked: %s", path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
schemes := root["components"].(map[string]any)["securitySchemes"].(map[string]any)
|
||||||
|
if _, ok := schemes["SessionCookie"]; ok {
|
||||||
|
t.Fatal("session-cookie authentication leaked into public docs")
|
||||||
|
}
|
||||||
|
if _, ok := schemes["CSRFHeader"]; ok {
|
||||||
|
t.Fatal("CSRF authentication leaked into public docs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestV1OpenAPIYAMLParses(t *testing.T) {
|
func TestV1OpenAPIYAMLParses(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ func (s *Server) startV1Jobs(ctx context.Context, companyID, userID uuid.UUID, r
|
|||||||
if s != nil && s.testStartJobs != nil {
|
if s != nil && s.testStartJobs != nil {
|
||||||
return s.testStartJobs(ctx, companyID, userID, rawIDs, processingType)
|
return s.testStartJobs(ctx, companyID, userID, rawIDs, processingType)
|
||||||
}
|
}
|
||||||
return s.Processing.StartJob(ctx, companyID, userID, rawIDs, processingType)
|
return s.Processing.StartAPIJob(ctx, companyID, userID, rawIDs, processingType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) enqueueV1Job(ctx context.Context, jobID uuid.UUID) error {
|
func (s *Server) enqueueV1Job(ctx context.Context, jobID uuid.UUID) error {
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package processing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/descrybe/descrybe-v2/apps/api/internal/catalog"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
|
)
|
||||||
|
|
||||||
|
// API jobs and dashboard jobs share one catalog. API completion is immediately
|
||||||
|
// visible in Processed; dashboard jobs retain explicit Needs review approval.
|
||||||
|
func TestAPIProcessedProductVisibleInCatalog(t *testing.T) {
|
||||||
|
dsn := os.Getenv("DATABASE_URL")
|
||||||
|
if dsn == "" {
|
||||||
|
t.Skip("DATABASE_URL is not set")
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
pg, err := pgxpool.New(ctx, dsn)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer pg.Close()
|
||||||
|
|
||||||
|
var userID uuid.UUID
|
||||||
|
if err := pg.QueryRow(ctx, `SELECT id FROM users LIMIT 1`).Scan(&userID); err != nil {
|
||||||
|
t.Skipf("test user unavailable: %v", err)
|
||||||
|
}
|
||||||
|
companyID := uuid.New()
|
||||||
|
if _, err := pg.Exec(ctx, `INSERT INTO companies (id,name) VALUES ($1,'API catalog visibility test')`, companyID); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
cleanupCtx, cleanupCancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||||
|
defer cleanupCancel()
|
||||||
|
_, _ = pg.Exec(cleanupCtx, `DELETE FROM processing_job_products WHERE job_id IN (SELECT id FROM processing_jobs WHERE company_id=$1)`, companyID)
|
||||||
|
_, _ = pg.Exec(cleanupCtx, `DELETE FROM processing_jobs WHERE company_id=$1`, companyID)
|
||||||
|
_, _ = pg.Exec(cleanupCtx, `DELETE FROM processed_products WHERE company_id=$1`, companyID)
|
||||||
|
_, _ = pg.Exec(cleanupCtx, `DELETE FROM raw_products WHERE company_id=$1`, companyID)
|
||||||
|
_, _ = pg.Exec(cleanupCtx, `DELETE FROM companies WHERE id=$1`, companyID)
|
||||||
|
}()
|
||||||
|
|
||||||
|
raws := []uuid.UUID{uuid.New(), uuid.New()}
|
||||||
|
for i, id := range raws {
|
||||||
|
if _, err := pg.Exec(ctx, `INSERT INTO raw_products (id,company_id,gtin,raw_data,mapped_data,is_processed,processing_status)
|
||||||
|
VALUES ($1,$2,$3,'{}'::jsonb,'{}'::jsonb,false,'unprocessed')`, id, companyID, []string{"1234567890123", "1234567890124"}[i]); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p := NewPipeline(pg)
|
||||||
|
p.Billing = nil
|
||||||
|
p.Limiter = nil
|
||||||
|
apiJobs, err := p.StartAPIJob(ctx, companyID, userID, raws[:1], "full")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
uiJobs, err := p.StartJob(ctx, companyID, userID, raws[1:], "full")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(apiJobs) != 1 || len(uiJobs) != 1 {
|
||||||
|
t.Fatal("expected one job each")
|
||||||
|
}
|
||||||
|
for _, check := range []struct {
|
||||||
|
id uuid.UUID
|
||||||
|
origin string
|
||||||
|
}{{apiJobs[0].ID, "api"}, {uiJobs[0].ID, "dashboard"}} {
|
||||||
|
var actual string
|
||||||
|
if err := pg.QueryRow(ctx, `SELECT origin FROM processing_jobs WHERE id=$1`, check.id).Scan(&actual); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if actual != check.origin {
|
||||||
|
t.Fatalf("job origin=%q want %q", actual, check.origin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, origin := range []string{"api", "dashboard"} {
|
||||||
|
original := "Supplier title"
|
||||||
|
title := "AI title"
|
||||||
|
if i == 1 {
|
||||||
|
title = "Dashboard title"
|
||||||
|
}
|
||||||
|
result := StepResult{
|
||||||
|
Name: original, Description: "Supplier description", ProcessedName: title,
|
||||||
|
ProcessedDescription: "Updated AI description", MetaTitle: "SEO title", MetaDescription: "SEO description",
|
||||||
|
Attributes: map[string]any{}, ProcessedAttributes: map[string]any{"power": "5W"},
|
||||||
|
GPTResponse: map[string]any{}, FieldSources: map[string]any{},
|
||||||
|
}
|
||||||
|
_, err := p.upsertProcessedProduct(ctx, nil, companyID, raws[i], []string{"1234567890123", "1234567890124"}[i], result, []byte(`{}`), []byte(`{"power":"5W"}`), []byte(`{}`), []byte(`{}`), "internal", "sl", origin)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
svc := &catalog.Service{Pool: pg}
|
||||||
|
approved, total, err := svc.ListProcessedProducts(ctx, companyID, catalog.ProductFilter{Status: "completed", Limit: 20})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if total != 1 || len(approved) != 1 {
|
||||||
|
t.Fatalf("completed total=%d items=%d", total, len(approved))
|
||||||
|
}
|
||||||
|
if approved[0]["processing_origin"] != "api" || approved[0]["name"] != "AI title" {
|
||||||
|
t.Fatalf("API result missing: %+v", approved[0])
|
||||||
|
}
|
||||||
|
reviewed, reviewTotal, err := svc.ListProcessedProducts(ctx, companyID, catalog.ProductFilter{Status: "needs_review", Limit: 20})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if reviewTotal != 1 || len(reviewed) != 1 {
|
||||||
|
t.Fatalf("review total=%d", reviewTotal)
|
||||||
|
}
|
||||||
|
if reviewed[0]["processing_origin"] != "dashboard" {
|
||||||
|
t.Fatalf("dashboard status changed: %+v", reviewed[0])
|
||||||
|
}
|
||||||
|
productID, err := uuid.Parse(fmt.Sprint(approved[0]["id"]))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// A later API SEO-only run must update SEO fields without erasing an earlier
|
||||||
|
// AI title, description, category, attributes or localized content.
|
||||||
|
seo := StepResult{MetaTitle: "Revised SEO title", MetaDescription: "Revised SEO description", Attributes: map[string]any{}, ProcessedAttributes: map[string]any{}, GPTResponse: map[string]any{}, FieldSources: map[string]any{}}
|
||||||
|
_, err = p.upsertProcessedProduct(ctx, nil, companyID, raws[0], "1234567890123", seo, []byte(`{}`), []byte(`{}`), []byte(`{}`), []byte(`{}`), "internal", "sl", "api")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// The list must still show the same product once (upsert, not duplicate).
|
||||||
|
_, afterTotal, err := svc.ListProcessedProducts(ctx, companyID, catalog.ProductFilter{Status: "completed", Limit: 20})
|
||||||
|
if err != nil || afterTotal != 1 {
|
||||||
|
t.Fatalf("API reprocess duplicated/missing product total=%d: %v", afterTotal, err)
|
||||||
|
}
|
||||||
|
detail, err := svc.GetProcessedProduct(ctx, companyID, productID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if detail["processed_description"] != "Updated AI description" {
|
||||||
|
t.Fatalf("SEO-only pass erased description: %+v", detail)
|
||||||
|
}
|
||||||
|
if detail["processed_name"] != "AI title" || detail["meta_title"] != "Revised SEO title" || detail["meta_description"] != "Revised SEO description" {
|
||||||
|
t.Fatalf("missing processed detail: %+v", detail)
|
||||||
|
}
|
||||||
|
otherCompany := uuid.New()
|
||||||
|
_, otherTotal, err := svc.ListProcessedProducts(ctx, otherCompany, catalog.ProductFilter{Status: "completed", Limit: 20})
|
||||||
|
if err != nil || otherTotal != 0 {
|
||||||
|
t.Fatalf("company data leaked: %d %v", otherTotal, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -135,6 +135,16 @@ type Job struct {
|
|||||||
// of ≤maxJobProducts so ClaimNext SKIP LOCKED workers stay parallelizable.
|
// of ≤maxJobProducts so ClaimNext SKIP LOCKED workers stay parallelizable.
|
||||||
// Absolute request cap is MaxStartProducts (100k–1M scale).
|
// Absolute request cap is MaxStartProducts (100k–1M scale).
|
||||||
func (p *Pipeline) StartJob(ctx context.Context, companyID, userID uuid.UUID, rawIDs []uuid.UUID, processingType string) ([]Job, error) {
|
func (p *Pipeline) StartJob(ctx context.Context, companyID, userID uuid.UUID, rawIDs []uuid.UUID, processingType string) ([]Job, error) {
|
||||||
|
return p.startJobWithOrigin(ctx, companyID, userID, rawIDs, processingType, "dashboard")
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartAPIJob uses the same processing pipeline and company-scoped catalog as the
|
||||||
|
// dashboard, but completed API results do not require a dashboard approval action.
|
||||||
|
func (p *Pipeline) StartAPIJob(ctx context.Context, companyID, userID uuid.UUID, rawIDs []uuid.UUID, processingType string) ([]Job, error) {
|
||||||
|
return p.startJobWithOrigin(ctx, companyID, userID, rawIDs, processingType, "api")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pipeline) startJobWithOrigin(ctx context.Context, companyID, userID uuid.UUID, rawIDs []uuid.UUID, processingType, origin string) ([]Job, error) {
|
||||||
if processingType == "" {
|
if processingType == "" {
|
||||||
processingType = "full"
|
processingType = "full"
|
||||||
}
|
}
|
||||||
@@ -191,9 +201,9 @@ func (p *Pipeline) StartJob(ctx context.Context, companyID, userID uuid.UUID, ra
|
|||||||
var jobID uuid.UUID
|
var jobID uuid.UUID
|
||||||
err = tx.QueryRow(ctx, `
|
err = tx.QueryRow(ctx, `
|
||||||
INSERT INTO processing_jobs (
|
INSERT INTO processing_jobs (
|
||||||
company_id, user_id, status, total_products, processing_type, current_step, step_progress
|
company_id, user_id, status, total_products, processing_type, current_step, step_progress, origin
|
||||||
) VALUES ($1, $2, 'pending', $3, $4, $5, $6::jsonb) RETURNING id`,
|
) VALUES ($1, $2, 'pending', $3, $4, $5, $6::jsonb, $7) RETURNING id`,
|
||||||
companyID, userID, len(chunk), processingType, firstStep, progressJSON).Scan(&jobID)
|
companyID, userID, len(chunk), processingType, firstStep, progressJSON, origin).Scan(&jobID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -590,12 +600,12 @@ func (p *Pipeline) RetryJob(ctx context.Context, companyID, id uuid.UUID) (Job,
|
|||||||
func (p *Pipeline) ProcessJob(ctx context.Context, jobID uuid.UUID) error {
|
func (p *Pipeline) ProcessJob(ctx context.Context, jobID uuid.UUID) error {
|
||||||
var companyID uuid.UUID
|
var companyID uuid.UUID
|
||||||
var jobUserID *uuid.UUID
|
var jobUserID *uuid.UUID
|
||||||
var status, processingType string
|
var status, processingType, origin string
|
||||||
var alreadyProcessed int
|
var alreadyProcessed int
|
||||||
err := p.Pool.QueryRow(ctx, `
|
err := p.Pool.QueryRow(ctx, `
|
||||||
SELECT company_id, user_id, status, processing_type, processed_products
|
SELECT company_id, user_id, status, processing_type, processed_products, origin
|
||||||
FROM processing_jobs WHERE id = $1`, jobID).
|
FROM processing_jobs WHERE id = $1`, jobID).
|
||||||
Scan(&companyID, &jobUserID, &status, &processingType, &alreadyProcessed)
|
Scan(&companyID, &jobUserID, &status, &processingType, &alreadyProcessed, &origin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -755,7 +765,7 @@ func (p *Pipeline) ProcessJob(ctx context.Context, jobID uuid.UUID) error {
|
|||||||
return fmt.Errorf("processing: check cancel job=%s: %w", jobID, err)
|
return fmt.Errorf("processing: check cancel job=%s: %w", jobID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok, tokens, result, itemErr := p.processOne(ctx, companyID, jobID, &items[i], processingType, jobEngine, modeLabel, usingBYOK, &jobCache)
|
ok, tokens, result, itemErr := p.processOne(ctx, companyID, jobID, &items[i], processingType, origin, jobEngine, modeLabel, usingBYOK, &jobCache)
|
||||||
if itemErr != nil {
|
if itemErr != nil {
|
||||||
failed++
|
failed++
|
||||||
if _, err := p.Pool.Exec(ctx, `
|
if _, err := p.Pool.Exec(ctx, `
|
||||||
@@ -1444,7 +1454,7 @@ func (p *Pipeline) reclaimOrphanedProcessingItems(ctx context.Context, jobID uui
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pipeline) processOne(ctx context.Context, companyID, jobID uuid.UUID, it *jobItem, processingType string, engine *Engine, modeLabel string, usingBYOK bool, cache *jobScopedCache) (bool, int, StepResult, error) {
|
func (p *Pipeline) processOne(ctx context.Context, companyID, jobID uuid.UUID, it *jobItem, processingType, origin string, engine *Engine, modeLabel string, usingBYOK bool, cache *jobScopedCache) (bool, int, StepResult, error) {
|
||||||
if it == nil {
|
if it == nil {
|
||||||
return false, 0, StepResult{}, fmt.Errorf("processing: nil job item")
|
return false, 0, StepResult{}, fmt.Errorf("processing: nil job item")
|
||||||
}
|
}
|
||||||
@@ -1700,10 +1710,10 @@ func (p *Pipeline) processOne(ctx context.Context, companyID, jobID uuid.UUID, i
|
|||||||
if err := p.Billing.ConsumeCreditsTx(ctx, tx, companyID, result.TotalTokens, "product_processing"); err != nil {
|
if err := p.Billing.ConsumeCreditsTx(ctx, tx, companyID, result.TotalTokens, "product_processing"); err != nil {
|
||||||
return false, 0, result, err
|
return false, 0, result, err
|
||||||
}
|
}
|
||||||
cache.noteCreditDebit(p.Billing.EstimateDebit(ctx, "product_processing", result.TotalTokens))
|
cache.noteCreditDebit(p.Billing.EstimateDebitForCompany(ctx, companyID, "product_processing", result.TotalTokens))
|
||||||
}
|
}
|
||||||
|
|
||||||
processedID, err := p.upsertProcessedProduct(ctx, tx, companyID, it.RawID, gtin, result, attrsJSON, procAttrsJSON, gptJSON, sourcesJSON, providerMode, language)
|
processedID, err := p.upsertProcessedProduct(ctx, tx, companyID, it.RawID, gtin, result, attrsJSON, procAttrsJSON, gptJSON, sourcesJSON, providerMode, language, origin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, 0, result, err
|
return false, 0, result, err
|
||||||
}
|
}
|
||||||
@@ -1765,27 +1775,51 @@ const upsertProcessedProductSQL = `
|
|||||||
company_id, raw_product_id, product_id, name, category, description,
|
company_id, raw_product_id, product_id, name, category, description,
|
||||||
processed_name, processed_description, status, attributes, processed_attributes,
|
processed_name, processed_description, status, attributes, processed_attributes,
|
||||||
gpt_response, total_tokens, field_sources, ai_provider_mode, localized_content,
|
gpt_response, total_tokens, field_sources, ai_provider_mode, localized_content,
|
||||||
meta_title, meta_description
|
meta_title, meta_description, processing_origin
|
||||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,'needs_review',$9,$10,$11,$12,$13,$14,$15::jsonb,$16,$17)
|
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,
|
||||||
|
CASE WHEN $18 = 'api' THEN 'completed' ELSE 'needs_review' END,
|
||||||
|
$9,$10,$11,$12,$13,$14,$15::jsonb,$16,$17,$18)
|
||||||
ON CONFLICT (company_id, raw_product_id) DO UPDATE SET
|
ON CONFLICT (company_id, raw_product_id) DO UPDATE SET
|
||||||
product_id = EXCLUDED.product_id,
|
product_id = EXCLUDED.product_id,
|
||||||
name = EXCLUDED.name,
|
name = CASE
|
||||||
category = CASE
|
WHEN EXCLUDED.processing_origin = 'api' THEN COALESCE(NULLIF(BTRIM(EXCLUDED.name), ''), processed_products.name)
|
||||||
|
ELSE EXCLUDED.name
|
||||||
|
END,
|
||||||
|
category = CASE
|
||||||
WHEN COALESCE(EXCLUDED.field_sources->>'category', '') = 'cleared_invalid' THEN ''
|
WHEN COALESCE(EXCLUDED.field_sources->>'category', '') = 'cleared_invalid' THEN ''
|
||||||
ELSE COALESCE(NULLIF(BTRIM(EXCLUDED.category), ''), processed_products.category)
|
ELSE COALESCE(NULLIF(BTRIM(EXCLUDED.category), ''), processed_products.category)
|
||||||
END,
|
END,
|
||||||
description = EXCLUDED.description,
|
description = CASE
|
||||||
processed_name = EXCLUDED.processed_name,
|
WHEN EXCLUDED.processing_origin = 'api' THEN COALESCE(NULLIF(BTRIM(EXCLUDED.description), ''), processed_products.description)
|
||||||
processed_description = EXCLUDED.processed_description,
|
ELSE EXCLUDED.description
|
||||||
status = 'needs_review',
|
END,
|
||||||
attributes = EXCLUDED.attributes,
|
processed_name = CASE
|
||||||
processed_attributes = EXCLUDED.processed_attributes,
|
WHEN EXCLUDED.processing_origin = 'api' THEN COALESCE(NULLIF(BTRIM(EXCLUDED.processed_name), ''), processed_products.processed_name)
|
||||||
|
ELSE EXCLUDED.processed_name
|
||||||
|
END,
|
||||||
|
processed_description = CASE
|
||||||
|
WHEN EXCLUDED.processing_origin = 'api' THEN COALESCE(NULLIF(BTRIM(EXCLUDED.processed_description), ''), processed_products.processed_description)
|
||||||
|
ELSE EXCLUDED.processed_description
|
||||||
|
END,
|
||||||
|
status = EXCLUDED.status,
|
||||||
|
processing_origin = EXCLUDED.processing_origin,
|
||||||
|
attributes = CASE
|
||||||
|
WHEN EXCLUDED.processing_origin = 'api' AND EXCLUDED.attributes = '{}'::jsonb
|
||||||
|
THEN processed_products.attributes ELSE EXCLUDED.attributes END,
|
||||||
|
processed_attributes = CASE
|
||||||
|
WHEN EXCLUDED.processing_origin = 'api' AND EXCLUDED.processed_attributes = '{}'::jsonb
|
||||||
|
THEN processed_products.processed_attributes ELSE EXCLUDED.processed_attributes END,
|
||||||
gpt_response = EXCLUDED.gpt_response,
|
gpt_response = EXCLUDED.gpt_response,
|
||||||
total_tokens = COALESCE(processed_products.total_tokens, 0) + EXCLUDED.total_tokens,
|
total_tokens = COALESCE(processed_products.total_tokens, 0) + EXCLUDED.total_tokens,
|
||||||
field_sources = EXCLUDED.field_sources,
|
field_sources = EXCLUDED.field_sources,
|
||||||
ai_provider_mode = EXCLUDED.ai_provider_mode,
|
ai_provider_mode = EXCLUDED.ai_provider_mode,
|
||||||
localized_content = EXCLUDED.localized_content,
|
localized_content = CASE
|
||||||
meta_title = CASE
|
WHEN EXCLUDED.processing_origin = 'api'
|
||||||
|
THEN COALESCE(processed_products.localized_content, '{}'::jsonb) || EXCLUDED.localized_content
|
||||||
|
ELSE EXCLUDED.localized_content END,
|
||||||
|
meta_title = CASE
|
||||||
|
WHEN EXCLUDED.processing_origin = 'api' AND NULLIF(BTRIM(EXCLUDED.meta_title), '') IS NOT NULL
|
||||||
|
THEN NULLIF(BTRIM(EXCLUDED.meta_title), '')
|
||||||
WHEN NULLIF(BTRIM(processed_products.meta_title), '') IS NULL
|
WHEN NULLIF(BTRIM(processed_products.meta_title), '') IS NULL
|
||||||
THEN NULLIF(BTRIM(EXCLUDED.meta_title), '')
|
THEN NULLIF(BTRIM(EXCLUDED.meta_title), '')
|
||||||
WHEN BTRIM(processed_products.meta_title) ~ '\|\s+[0-9]+$'
|
WHEN BTRIM(processed_products.meta_title) ~ '\|\s+[0-9]+$'
|
||||||
@@ -1800,8 +1834,10 @@ const upsertProcessedProductSQL = `
|
|||||||
THEN NULLIF(BTRIM(EXCLUDED.meta_title), '')
|
THEN NULLIF(BTRIM(EXCLUDED.meta_title), '')
|
||||||
ELSE processed_products.meta_title
|
ELSE processed_products.meta_title
|
||||||
END,
|
END,
|
||||||
meta_description = CASE
|
meta_description = CASE
|
||||||
WHEN NULLIF(BTRIM(processed_products.meta_description), '') IS NULL
|
WHEN EXCLUDED.processing_origin = 'api' AND NULLIF(BTRIM(EXCLUDED.meta_description), '') IS NOT NULL
|
||||||
|
THEN NULLIF(BTRIM(EXCLUDED.meta_description), '')
|
||||||
|
WHEN NULLIF(BTRIM(processed_products.meta_description), '') IS NULL
|
||||||
THEN NULLIF(BTRIM(EXCLUDED.meta_description), '')
|
THEN NULLIF(BTRIM(EXCLUDED.meta_description), '')
|
||||||
WHEN LOWER(processed_products.meta_description) LIKE '%prefer 1-3%'
|
WHEN LOWER(processed_products.meta_description) LIKE '%prefer 1-3%'
|
||||||
OR LOWER(processed_products.meta_description) LIKE '%short retail title%'
|
OR LOWER(processed_products.meta_description) LIKE '%short retail title%'
|
||||||
@@ -1848,6 +1884,7 @@ func (p *Pipeline) upsertProcessedProduct(
|
|||||||
attrsJSON, procAttrsJSON, gptJSON, sourcesJSON []byte,
|
attrsJSON, procAttrsJSON, gptJSON, sourcesJSON []byte,
|
||||||
providerMode string,
|
providerMode string,
|
||||||
primaryLang string,
|
primaryLang string,
|
||||||
|
origin string,
|
||||||
) (uuid.UUID, error) {
|
) (uuid.UUID, error) {
|
||||||
localized := result.LocalizedContent
|
localized := result.LocalizedContent
|
||||||
if localized == nil {
|
if localized == nil {
|
||||||
@@ -1875,7 +1912,7 @@ func (p *Pipeline) upsertProcessedProduct(
|
|||||||
err = queryRow(ctx, upsertProcessedProductSQL,
|
err = queryRow(ctx, upsertProcessedProductSQL,
|
||||||
companyID, rawID, gtin, result.Name, result.Category, result.Description,
|
companyID, rawID, gtin, result.Name, result.Category, result.Description,
|
||||||
result.ProcessedName, result.ProcessedDescription, attrsJSON, procAttrsJSON, gptJSON, result.TotalTokens, sourcesJSON, providerMode, string(locJSON),
|
result.ProcessedName, result.ProcessedDescription, attrsJSON, procAttrsJSON, gptJSON, result.TotalTokens, sourcesJSON, providerMode, string(locJSON),
|
||||||
result.MetaTitle, result.MetaDescription,
|
result.MetaTitle, result.MetaDescription, origin,
|
||||||
).Scan(&processedID)
|
).Scan(&processedID)
|
||||||
return processedID, err
|
return processedID, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- Effective credit rules: company > assigned plan > global defaults.
|
||||||
|
-- These affect future debits only. Existing credit history is never repriced.
|
||||||
|
CREATE TABLE IF NOT EXISTS plan_processing_costs (
|
||||||
|
plan_id BIGINT NOT NULL REFERENCES plans(id) ON DELETE CASCADE,
|
||||||
|
feature_name TEXT NOT NULL,
|
||||||
|
cost_per_unit INTEGER NOT NULL CHECK (cost_per_unit >= 1 AND cost_per_unit <= 1000000),
|
||||||
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||||
|
PRIMARY KEY (plan_id, feature_name)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS company_processing_costs (
|
||||||
|
company_id UUID NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
||||||
|
feature_name TEXT NOT NULL,
|
||||||
|
cost_per_unit INTEGER NOT NULL CHECK (cost_per_unit >= 1 AND cost_per_unit <= 1000000),
|
||||||
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||||
|
PRIMARY KEY (company_id, feature_name)
|
||||||
|
);
|
||||||
|
CREATE INDEX IF NOT EXISTS plan_processing_costs_feature_idx ON plan_processing_costs(feature_name);
|
||||||
|
CREATE INDEX IF NOT EXISTS company_processing_costs_feature_idx ON company_processing_costs(feature_name);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP TABLE IF EXISTS company_processing_costs;
|
||||||
|
DROP TABLE IF EXISTS plan_processing_costs;
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- USD per 1M standard text tokens, OpenAI published rates, 2026-10-16.
|
||||||
|
-- The platform's cost ledger records USD at call time; never reprice history.
|
||||||
|
-- Existing/admin-custom pricing remains authoritative.
|
||||||
|
INSERT INTO ai_model_prices (model,input_micros_per_mtok,cached_input_micros_per_mtok,output_micros_per_mtok,source)
|
||||||
|
VALUES
|
||||||
|
('gpt-5.4-mini',750000,75000,4500000,'https://developers.openai.com/api/docs/models/gpt-5.4-mini'),
|
||||||
|
('gpt-5-mini',250000,25000,2000000,'https://developers.openai.com/api/docs/models/gpt-5-mini'),
|
||||||
|
('gpt-6-luna',100000,10000,500000,'https://developers.openai.com/api/docs/pricing')
|
||||||
|
ON CONFLICT(model) DO NOTHING;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
-- Price rows may be in active use and cost history cannot be re-priced.
|
||||||
|
SELECT 1;
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- Make API-origin processing visible in the existing catalog, without changing the
|
||||||
|
-- review/approval lifecycle of dashboard and feed-initiated jobs.
|
||||||
|
ALTER TABLE processing_jobs
|
||||||
|
ADD COLUMN IF NOT EXISTS origin TEXT NOT NULL DEFAULT 'dashboard';
|
||||||
|
ALTER TABLE processed_products
|
||||||
|
ADD COLUMN IF NOT EXISTS processing_origin TEXT NOT NULL DEFAULT 'dashboard';
|
||||||
|
|
||||||
|
-- Old jobs have no trustworthy origin tag; leave their review state intact.
|
||||||
|
-- The unique (company_id,raw_product_id) index remains the product identity.
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
ALTER TABLE processed_products DROP COLUMN IF EXISTS processing_origin;
|
||||||
|
ALTER TABLE processing_jobs DROP COLUMN IF EXISTS origin;
|
||||||
@@ -99,7 +99,7 @@ describe("buildSubscriptionEcommerce", () => {
|
|||||||
const { ecommerce, extra } = buildSubscriptionEcommerce("starter", "monthly");
|
const { ecommerce, extra } = buildSubscriptionEcommerce("starter", "monthly");
|
||||||
assert.equal(extra.plan, "starter");
|
assert.equal(extra.plan, "starter");
|
||||||
assert.equal(extra.billing_term, "monthly");
|
assert.equal(extra.billing_term, "monthly");
|
||||||
assert.equal(ecommerce.currency, "USD");
|
assert.equal(ecommerce.currency, "EUR");
|
||||||
assert.equal(ecommerce.value, 49);
|
assert.equal(ecommerce.value, 49);
|
||||||
assert.deepEqual(ecommerce.items[0], {
|
assert.deepEqual(ecommerce.items[0], {
|
||||||
item_id: "starter",
|
item_id: "starter",
|
||||||
@@ -124,7 +124,7 @@ describe("buildCreditPackEcommerce", () => {
|
|||||||
it("includes value/currency/items from CREDIT_PACKS list prices", () => {
|
it("includes value/currency/items from CREDIT_PACKS list prices", () => {
|
||||||
const { ecommerce, extra } = buildCreditPackEcommerce("tiny");
|
const { ecommerce, extra } = buildCreditPackEcommerce("tiny");
|
||||||
assert.equal(extra.pack_id, "tiny");
|
assert.equal(extra.pack_id, "tiny");
|
||||||
assert.equal(ecommerce.currency, "USD");
|
assert.equal(ecommerce.currency, "EUR");
|
||||||
assert.equal(ecommerce.value, 29);
|
assert.equal(ecommerce.value, 29);
|
||||||
assert.deepEqual(ecommerce.items[0], {
|
assert.deepEqual(ecommerce.items[0], {
|
||||||
item_id: "tiny",
|
item_id: "tiny",
|
||||||
@@ -143,7 +143,7 @@ describe("toEcommerceObject + purchase resolve", () => {
|
|||||||
});
|
});
|
||||||
assert.deepEqual(toEcommerceObject(ecommerce), {
|
assert.deepEqual(toEcommerceObject(ecommerce), {
|
||||||
items: ecommerce.items,
|
items: ecommerce.items,
|
||||||
currency: "USD",
|
currency: "EUR",
|
||||||
value: 49,
|
value: 49,
|
||||||
transaction_id: "cs_test_abc"
|
transaction_id: "cs_test_abc"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export function normalizeBillingTerm(raw: string | null | undefined): BillingTer
|
|||||||
return t === "yearly" || t === "annual" || t === "year" ? "yearly" : "monthly";
|
return t === "yearly" || t === "annual" || t === "year" ? "yearly" : "monthly";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Marketing list price for a subscription term (USD). */
|
/** Marketing list price for a subscription term (EUR). */
|
||||||
export function subscriptionListValue(
|
export function subscriptionListValue(
|
||||||
monthlyPrice: number,
|
monthlyPrice: number,
|
||||||
term: BillingTerm
|
term: BillingTerm
|
||||||
@@ -81,7 +81,7 @@ export function buildSubscriptionEcommerce(
|
|||||||
};
|
};
|
||||||
const ecommerce: Ga4EcommerceFields = {
|
const ecommerce: Ga4EcommerceFields = {
|
||||||
items: [item],
|
items: [item],
|
||||||
...(price !== undefined ? { currency: "USD", value: price } : {}),
|
...(price !== undefined ? { currency: "EUR", value: price } : {}),
|
||||||
...(opts?.transactionId ? { transaction_id: opts.transactionId } : {})
|
...(opts?.transactionId ? { transaction_id: opts.transactionId } : {})
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
@@ -92,15 +92,15 @@ export function buildSubscriptionEcommerce(
|
|||||||
|
|
||||||
export function buildCreditPackEcommerce(
|
export function buildCreditPackEcommerce(
|
||||||
packId: string,
|
packId: string,
|
||||||
opts?: { transactionId?: string; priceUsd?: number; itemName?: string }
|
opts?: { transactionId?: string; priceEur?: number; itemName?: string }
|
||||||
): { ecommerce: Ga4EcommerceFields; extra: Record<string, unknown> } {
|
): { ecommerce: Ga4EcommerceFields; extra: Record<string, unknown> } {
|
||||||
const key = packId.trim().toLowerCase();
|
const key = packId.trim().toLowerCase();
|
||||||
const marketing = CREDIT_PACKS.find((p) => p.id === key);
|
const marketing = CREDIT_PACKS.find((p) => p.id === key);
|
||||||
const price =
|
const price =
|
||||||
typeof opts?.priceUsd === "number" && opts.priceUsd > 0
|
typeof opts?.priceEur === "number" && opts.priceEur > 0
|
||||||
? opts.priceUsd
|
? opts.priceEur
|
||||||
: typeof marketing?.priceUSD === "number" && marketing.priceUSD > 0
|
: typeof marketing?.priceEUR === "number" && marketing.priceEUR > 0
|
||||||
? marketing.priceUSD
|
? marketing.priceEUR
|
||||||
: undefined;
|
: undefined;
|
||||||
const itemName = (opts?.itemName ?? marketing?.name ?? key).trim() || key;
|
const itemName = (opts?.itemName ?? marketing?.name ?? key).trim() || key;
|
||||||
const item: Ga4EcommerceItem = {
|
const item: Ga4EcommerceItem = {
|
||||||
@@ -112,7 +112,7 @@ export function buildCreditPackEcommerce(
|
|||||||
};
|
};
|
||||||
const ecommerce: Ga4EcommerceFields = {
|
const ecommerce: Ga4EcommerceFields = {
|
||||||
items: [item],
|
items: [item],
|
||||||
...(price !== undefined ? { currency: "USD", value: price } : {}),
|
...(price !== undefined ? { currency: "EUR", value: price } : {}),
|
||||||
...(opts?.transactionId ? { transaction_id: opts.transactionId } : {})
|
...(opts?.transactionId ? { transaction_id: opts.transactionId } : {})
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
function formatMoney(n: number): string {
|
function formatMoney(n: number): string {
|
||||||
return `$${n.toLocaleString()}`;
|
return `€${n.toLocaleString()}`;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -127,9 +127,9 @@
|
|||||||
{#if rec.plan.customPrice}
|
{#if rec.plan.customPrice}
|
||||||
{i18n.t("pricing.card.custom")}
|
{i18n.t("pricing.card.custom")}
|
||||||
{:else if rec.plan.pricePerMonth === 0}
|
{:else if rec.plan.pricePerMonth === 0}
|
||||||
$0 / {i18n.t("pricing.card.perMonth")}
|
€0 / {i18n.t("pricing.card.perMonth")}
|
||||||
{:else}
|
{:else}
|
||||||
{formatMoney(rec.monthlyListUSD)} / {i18n.t("pricing.card.perMonth")}
|
{formatMoney(rec.monthlyListEUR)} / {i18n.t("pricing.card.perMonth")}
|
||||||
{/if}
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
<ul class="mt-3 mb-4 space-y-1 text-sm text-text-muted">
|
<ul class="mt-3 mb-4 space-y-1 text-sm text-text-muted">
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
{i18n.t("pricing.calc.aiNeedsPacks", {
|
{i18n.t("pricing.calc.aiNeedsPacks", {
|
||||||
pack: rec.packs.pack.name,
|
pack: rec.packs.pack.name,
|
||||||
count: rec.packs.count,
|
count: rec.packs.count,
|
||||||
usd: formatMoney(rec.packs.totalUSD)
|
usd: formatMoney(rec.packs.totalEUR)
|
||||||
})}
|
})}
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -165,11 +165,11 @@
|
|||||||
</p>
|
</p>
|
||||||
<p class="mt-1 text-2xl font-bold text-text">{budget.plan.name}</p>
|
<p class="mt-1 text-2xl font-bold text-text">{budget.plan.name}</p>
|
||||||
<p class="mt-2 text-sm text-text-muted">
|
<p class="mt-2 text-sm text-text-muted">
|
||||||
{formatMoney(budget.monthlyListUSD)} / {i18n.t("pricing.card.perMonth")}
|
{formatMoney(budget.monthlyListEUR)} / {i18n.t("pricing.card.perMonth")}
|
||||||
{#if budget.yearlyMonthlyUSD > 0 && budget.yearlyMonthlyUSD < budget.monthlyListUSD}
|
{#if budget.yearlyMonthlyEUR > 0 && budget.yearlyMonthlyEUR < budget.monthlyListEUR}
|
||||||
<span class="ml-1">
|
<span class="ml-1">
|
||||||
({i18n.t("pricing.calc.orYearly", {
|
({i18n.t("pricing.calc.orYearly", {
|
||||||
amount: formatMoney(budget.yearlyMonthlyUSD)
|
amount: formatMoney(budget.yearlyMonthlyEUR)
|
||||||
})})
|
})})
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
{i18n.t("pricing.calc.aiNeedsPacks", {
|
{i18n.t("pricing.calc.aiNeedsPacks", {
|
||||||
pack: budget.packs.pack.name,
|
pack: budget.packs.pack.name,
|
||||||
count: budget.packs.count,
|
count: budget.packs.count,
|
||||||
usd: formatMoney(budget.packs.totalUSD)
|
usd: formatMoney(budget.packs.totalEUR)
|
||||||
})}
|
})}
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -133,10 +133,10 @@
|
|||||||
{#if plan.customPrice}
|
{#if plan.customPrice}
|
||||||
<span class="text-4xl font-bold tracking-tight">{i18n.t("pricing.card.custom")}</span>
|
<span class="text-4xl font-bold tracking-tight">{i18n.t("pricing.card.custom")}</span>
|
||||||
{:else if isFree}
|
{:else if isFree}
|
||||||
<span class="text-4xl font-bold tracking-tight">$0</span>
|
<span class="text-4xl font-bold tracking-tight">€0</span>
|
||||||
<span class="ml-2 text-lg text-text-muted">{i18n.t("pricing.card.forever")}</span>
|
<span class="ml-2 text-lg text-text-muted">{i18n.t("pricing.card.forever")}</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="text-4xl font-bold tracking-tight">${displayPrice}</span>
|
<span class="text-4xl font-bold tracking-tight">€{displayPrice}</span>
|
||||||
<span class="ml-2 text-lg text-text-muted">/{displayPeriod}</span>
|
<span class="ml-2 text-lg text-text-muted">/{displayPeriod}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export type MarketingCreditPack = {
|
|||||||
description: string;
|
description: string;
|
||||||
descriptionKey: string;
|
descriptionKey: string;
|
||||||
credits: number;
|
credits: number;
|
||||||
priceUSD: number;
|
priceEUR: number;
|
||||||
aiProducts: number;
|
aiProducts: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ export const CREDIT_PACKS: MarketingCreditPack[] = [
|
|||||||
description: "Smoke tests / tiny fixes (25 credits ≈ 12 AI products)",
|
description: "Smoke tests / tiny fixes (25 credits ≈ 12 AI products)",
|
||||||
descriptionKey: "pricing.pack.tiny.desc",
|
descriptionKey: "pricing.pack.tiny.desc",
|
||||||
credits: 25,
|
credits: 25,
|
||||||
priceUSD: 29,
|
priceEUR: 29,
|
||||||
aiProducts: 12
|
aiProducts: 12
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -32,7 +32,7 @@ export const CREDIT_PACKS: MarketingCreditPack[] = [
|
|||||||
description: "Small top-up (65 credits ≈ 32 AI products)",
|
description: "Small top-up (65 credits ≈ 32 AI products)",
|
||||||
descriptionKey: "pricing.pack.small.desc",
|
descriptionKey: "pricing.pack.small.desc",
|
||||||
credits: 65,
|
credits: 65,
|
||||||
priceUSD: 59,
|
priceEUR: 59,
|
||||||
aiProducts: 32
|
aiProducts: 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -42,7 +42,7 @@ export const CREDIT_PACKS: MarketingCreditPack[] = [
|
|||||||
description: "Burst top-up (200 credits ≈ 100 AI products)",
|
description: "Burst top-up (200 credits ≈ 100 AI products)",
|
||||||
descriptionKey: "pricing.pack.medium.desc",
|
descriptionKey: "pricing.pack.medium.desc",
|
||||||
credits: 200,
|
credits: 200,
|
||||||
priceUSD: 149,
|
priceEUR: 149,
|
||||||
aiProducts: 100
|
aiProducts: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,7 @@ export const CREDIT_PACKS: MarketingCreditPack[] = [
|
|||||||
description: "Mid buffer (500 credits ≈ 250 AI products)",
|
description: "Mid buffer (500 credits ≈ 250 AI products)",
|
||||||
descriptionKey: "pricing.pack.large.desc",
|
descriptionKey: "pricing.pack.large.desc",
|
||||||
credits: 500,
|
credits: 500,
|
||||||
priceUSD: 299,
|
priceEUR: 299,
|
||||||
aiProducts: 250
|
aiProducts: 250
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -62,7 +62,7 @@ export const CREDIT_PACKS: MarketingCreditPack[] = [
|
|||||||
description: "Catalog / re-run buffer (1,200 credits ≈ 600 AI products)",
|
description: "Catalog / re-run buffer (1,200 credits ≈ 600 AI products)",
|
||||||
descriptionKey: "pricing.pack.xl.desc",
|
descriptionKey: "pricing.pack.xl.desc",
|
||||||
credits: 1200,
|
credits: 1200,
|
||||||
priceUSD: 599,
|
priceEUR: 599,
|
||||||
aiProducts: 600
|
aiProducts: 600
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -72,7 +72,7 @@ export const CREDIT_PACKS: MarketingCreditPack[] = [
|
|||||||
description: "Large multi-language buffer (3,000 credits ≈ 1,500 AI products)",
|
description: "Large multi-language buffer (3,000 credits ≈ 1,500 AI products)",
|
||||||
descriptionKey: "pricing.pack.xxl.desc",
|
descriptionKey: "pricing.pack.xxl.desc",
|
||||||
credits: 3000,
|
credits: 3000,
|
||||||
priceUSD: 1299,
|
priceEUR: 1299,
|
||||||
aiProducts: 1500
|
aiProducts: 1500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@ export const CREDIT_PACKS: MarketingCreditPack[] = [
|
|||||||
description: "Distributor / agency burst (8,000 credits ≈ 4,000 AI products)",
|
description: "Distributor / agency burst (8,000 credits ≈ 4,000 AI products)",
|
||||||
descriptionKey: "pricing.pack.mega.desc",
|
descriptionKey: "pricing.pack.mega.desc",
|
||||||
credits: 8000,
|
credits: 8000,
|
||||||
priceUSD: 2999,
|
priceEUR: 2999,
|
||||||
aiProducts: 4000
|
aiProducts: 4000
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export type PackEstimate = {
|
|||||||
pack: MarketingCreditPack;
|
pack: MarketingCreditPack;
|
||||||
count: number;
|
count: number;
|
||||||
totalCredits: number;
|
totalCredits: number;
|
||||||
totalUSD: number;
|
totalEUR: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PlanRecommendation = {
|
export type PlanRecommendation = {
|
||||||
@@ -29,8 +29,8 @@ export type PlanRecommendation = {
|
|||||||
creditsNeeded: number;
|
creditsNeeded: number;
|
||||||
creditsShortfall: number;
|
creditsShortfall: number;
|
||||||
packs: PackEstimate | null;
|
packs: PackEstimate | null;
|
||||||
monthlyListUSD: number;
|
monthlyListEUR: number;
|
||||||
yearlyMonthlyUSD: number;
|
yearlyMonthlyEUR: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PlanCalculatorResult = {
|
export type PlanCalculatorResult = {
|
||||||
@@ -61,13 +61,13 @@ export function estimatePacksForShortfall(shortfall: number): PackEstimate | nul
|
|||||||
const count = Math.ceil(shortfall / pack.credits);
|
const count = Math.ceil(shortfall / pack.credits);
|
||||||
if (count <= 0) continue;
|
if (count <= 0) continue;
|
||||||
const totalCredits = count * pack.credits;
|
const totalCredits = count * pack.credits;
|
||||||
const totalUSD = count * pack.priceUSD;
|
const totalEUR = count * pack.priceEUR;
|
||||||
if (
|
if (
|
||||||
!best ||
|
!best ||
|
||||||
totalUSD < best.totalUSD ||
|
totalEUR < best.totalEUR ||
|
||||||
(totalUSD === best.totalUSD && count < best.count)
|
(totalEUR === best.totalEUR && count < best.count)
|
||||||
) {
|
) {
|
||||||
best = { pack, count, totalCredits, totalUSD };
|
best = { pack, count, totalCredits, totalEUR };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return best;
|
return best;
|
||||||
@@ -86,8 +86,8 @@ function recommendationFor(
|
|||||||
creditsNeeded,
|
creditsNeeded,
|
||||||
creditsShortfall: shortfall,
|
creditsShortfall: shortfall,
|
||||||
packs,
|
packs,
|
||||||
monthlyListUSD: plan.pricePerMonth,
|
monthlyListEUR: plan.pricePerMonth,
|
||||||
yearlyMonthlyUSD: plan.pricePerMonth > 0 ? Math.round(yearly / 12) : 0
|
yearlyMonthlyEUR: plan.pricePerMonth > 0 ? Math.round(yearly / 12) : 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ export function recommendPlans(
|
|||||||
// Only offer budget when packs can close AI gap without exceeding ~2 months of
|
// Only offer budget when packs can close AI gap without exceeding ~2 months of
|
||||||
// the price delta vs upgrading (keeps Starter+packs from undercutting A1 badly).
|
// the price delta vs upgrading (keeps Starter+packs from undercutting A1 badly).
|
||||||
const lowerRec = recommendationFor(lower, creditsNeeded);
|
const lowerRec = recommendationFor(lower, creditsNeeded);
|
||||||
const packCost = lowerRec.packs?.totalUSD ?? 0;
|
const packCost = lowerRec.packs?.totalEUR ?? 0;
|
||||||
const upgradeDelta = fullPlan.pricePerMonth - lower.pricePerMonth;
|
const upgradeDelta = fullPlan.pricePerMonth - lower.pricePerMonth;
|
||||||
const packOk = packCost === 0 || packCost <= Math.max(upgradeDelta * 2, 149);
|
const packOk = packCost === 0 || packCost <= Math.max(upgradeDelta * 2, 149);
|
||||||
if (packOk || lowerRec.aiComfortable) {
|
if (packOk || lowerRec.aiComfortable) {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export interface PricingFaqItem {
|
|||||||
* Never include client deals (A1, Merkur trial, …) — those stay admin-only.
|
* Never include client deals (A1, Merkur trial, …) — those stay admin-only.
|
||||||
*
|
*
|
||||||
* Limits are product/SKU- and credit-based (no storage meters on public plans).
|
* Limits are product/SKU- and credit-based (no storage meters on public plans).
|
||||||
* List prices are marketing placeholders; self-serve Checkout uses Stripe Price IDs from env/admin.
|
* List prices are in EUR; Stripe Checkout requires matching EUR Price IDs from settings/env.
|
||||||
*/
|
*/
|
||||||
export const PRICING_PLANS: PricingPlan[] = [
|
export const PRICING_PLANS: PricingPlan[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -689,7 +689,10 @@ import { Check, Edit, MoreHorizontal, X } from "@lucide/svelte";
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden w-[130px] shrink-0 items-center px-3 py-2 xl:flex">
|
<div class="hidden w-[130px] shrink-0 items-center px-3 py-2 xl:flex">
|
||||||
{#if product.feed_name}
|
{#if product.processing_origin === "api" && kind === "processed"}
|
||||||
|
<span class="mr-1 inline-flex rounded bg-primary/10 px-1.5 py-0.5 text-[11px] font-medium text-primary" title="Processed through the API">API</span>
|
||||||
|
{/if}
|
||||||
|
{#if product.feed_name}
|
||||||
<div
|
<div
|
||||||
class="truncate text-sm"
|
class="truncate text-sm"
|
||||||
title={productFeedSyncLabel(product)}
|
title={productFeedSyncLabel(product)}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ export type ProductRow = {
|
|||||||
/** Category the feed supplied, before categorize assigned one. */
|
/** Category the feed supplied, before categorize assigned one. */
|
||||||
feed_category?: string | null;
|
feed_category?: string | null;
|
||||||
status?: string | null;
|
status?: string | null;
|
||||||
|
processing_origin?: "api" | "dashboard" | string | null;
|
||||||
processing_status?: string | null;
|
processing_status?: string | null;
|
||||||
raw_product_id?: string | null;
|
raw_product_id?: string | null;
|
||||||
feed_id?: string | number | null;
|
feed_id?: string | number | null;
|
||||||
|
|||||||
@@ -90,10 +90,10 @@
|
|||||||
{#if plan.customPrice}
|
{#if plan.customPrice}
|
||||||
<span class="text-4xl font-bold">{i18n.t("pricing.card.custom")}</span>
|
<span class="text-4xl font-bold">{i18n.t("pricing.card.custom")}</span>
|
||||||
{:else if isFree}
|
{:else if isFree}
|
||||||
<span class="text-4xl font-bold">$0</span>
|
<span class="text-4xl font-bold">€0</span>
|
||||||
<span class="ml-2 text-lg text-text-muted">{i18n.t("pricing.card.forever")}</span>
|
<span class="ml-2 text-lg text-text-muted">{i18n.t("pricing.card.forever")}</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="text-4xl font-bold">${displayPrice}</span>
|
<span class="text-4xl font-bold">€{displayPrice}</span>
|
||||||
<span class="ml-2 text-lg text-text-muted">/{displayPeriod}</span>
|
<span class="ml-2 text-lg text-text-muted">/{displayPeriod}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const de: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5266,7 +5266,7 @@ export const de: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "Was sind KI-Credits?",
|
"pricing.faq.credits.q": "Was sind KI-Credits?",
|
||||||
"pricing.faq.credits.a": "KI-Credits zahlen Schritte wie Titel- und Beschreibungsgenerierung. Free enthält 0 KI-Credits  Feeds mappen und Daten bereinigen geht trotzdem. Bezahlte Monatspakete: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise enthält ein großes verwaltetes Paket (und eigenen Schlüssel). Ab Growth optional eigener Schlüssel statt verwalteter Credits.",
|
"pricing.faq.credits.a": "KI-Credits zahlen Schritte wie Titel- und Beschreibungsgenerierung. Free enthält 0 KI-Credits  Feeds mappen und Daten bereinigen geht trotzdem. Bezahlte Monatspakete: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise enthält ein großes verwaltetes Paket (und eigenen Schlüssel). Ab Growth optional eigener Schlüssel statt verwalteter Credits.",
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "Was passiert bei Produkt- oder Credit-Limit?",
|
"pricing.faq.limits.q": "Was passiert bei Produkt- oder Credit-Limit?",
|
||||||
"pricing.faq.limits.a": "Wir warnen rechtzeitig. Am Produktlimit oder ohne KI-Credits pausieren Jobs, die Kapazität brauchen, bis Platz frei wird, der nächste Zyklus kommt oder Sie upgraden.",
|
"pricing.faq.limits.a": "Wir warnen rechtzeitig. Am Produktlimit oder ohne KI-Credits pausieren Jobs, die Kapazität brauchen, bis Platz frei wird, der nächste Zyklus kommt oder Sie upgraden.",
|
||||||
"pricing.faq.change.q": "Kann ich up- oder downgraden?",
|
"pricing.faq.change.q": "Kann ich up- oder downgraden?",
|
||||||
@@ -5303,7 +5303,7 @@ export const de: MessageDict = {
|
|||||||
"pricing.card.forever": "für immer",
|
"pricing.card.forever": "für immer",
|
||||||
"pricing.card.perMonth": "Monat",
|
"pricing.card.perMonth": "Monat",
|
||||||
"pricing.card.perYear": "Jahr",
|
"pricing.card.perYear": "Jahr",
|
||||||
"pricing.card.savePerMonth": "${amount}/Monat sparen",
|
"pricing.card.savePerMonth": "€{amount}/Monat sparen",
|
||||||
"pricing.card.discountBadge": "-20 %",
|
"pricing.card.discountBadge": "-20 %",
|
||||||
"pricing.card.unlimitedSkus": "Unbegrenzte SKUs",
|
"pricing.card.unlimitedSkus": "Unbegrenzte SKUs",
|
||||||
"pricing.card.oneMSkus": "1M+ SKUs",
|
"pricing.card.oneMSkus": "1M+ SKUs",
|
||||||
|
|||||||
@@ -812,7 +812,7 @@ export const en: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -1130,11 +1130,11 @@ export const en: MessageDict = {
|
|||||||
"Stripe mode for this sync: {mode}. Switch the secret key (sk_test_ vs sk_live_) to sync the other environment.",
|
"Stripe mode for this sync: {mode}. Switch the secret key (sk_test_ vs sk_live_) to sync the other environment.",
|
||||||
"admin.settings.syncCreditPacksFailed":
|
"admin.settings.syncCreditPacksFailed":
|
||||||
"Could not sync credit packs to Stripe.",
|
"Could not sync credit packs to Stripe.",
|
||||||
"admin.settings.pricePackSmall": "Starter pack (65 credits / $59) price ID",
|
"admin.settings.pricePackSmall": "Starter pack (65 credits / €59) price ID",
|
||||||
"admin.settings.pricePackMedium": "Plus pack (200 credits / $149) price ID",
|
"admin.settings.pricePackMedium": "Plus pack (200 credits / €149) price ID",
|
||||||
"admin.settings.pricePackLarge":
|
"admin.settings.pricePackLarge":
|
||||||
"Catalog pack (1,200 credits / $599) price ID",
|
"Catalog pack (1,200 credits / €599) price ID",
|
||||||
"admin.settings.pricePackXL": "Scale pack (8,000 credits / $2,999) price ID",
|
"admin.settings.pricePackXL": "Scale pack (8,000 credits / €2,999) price ID",
|
||||||
"admin.settings.feedAllowlist": "Feed private URL allowlist",
|
"admin.settings.feedAllowlist": "Feed private URL allowlist",
|
||||||
"admin.settings.allowlist": "Allowlist",
|
"admin.settings.allowlist": "Allowlist",
|
||||||
"admin.settings.platformAdmins": "Platform administrators",
|
"admin.settings.platformAdmins": "Platform administrators",
|
||||||
@@ -5739,7 +5739,7 @@ export const en: MessageDict = {
|
|||||||
"Connect CSV or XML supplier feeds, map them to your categories and attributes, generate titles and descriptions that match your rules, then export or sync to WooCommerce.",
|
"Connect CSV or XML supplier feeds, map them to your categories and attributes, generate titles and descriptions that match your rules, then export or sync to WooCommerce.",
|
||||||
"seo.pricing.title": "Pricing from Free to Enterprise | Descrybe",
|
"seo.pricing.title": "Pricing from Free to Enterprise | Descrybe",
|
||||||
"seo.pricing.description":
|
"seo.pricing.description":
|
||||||
"Start free with 50 products and feed mapping. Paid plans start at $49 per month and include AI content, larger SKU limits, export feeds, and store sync.",
|
"Start free with 50 products and feed mapping. Paid plans start at €49 per month and include AI content, larger SKU limits, export feeds, and store sync.",
|
||||||
"seo.privacy.title": "Privacy Policy | Descrybe",
|
"seo.privacy.title": "Privacy Policy | Descrybe",
|
||||||
"seo.privacy.description":
|
"seo.privacy.description":
|
||||||
"How Descrybe collects, uses, and protects account data, product catalogs, and supplier feeds when you use our product data platform.",
|
"How Descrybe collects, uses, and protects account data, product catalogs, and supplier feeds when you use our product data platform.",
|
||||||
@@ -6492,7 +6492,7 @@ export const en: MessageDict = {
|
|||||||
"pricing.card.forever": "forever",
|
"pricing.card.forever": "forever",
|
||||||
"pricing.card.perMonth": "month",
|
"pricing.card.perMonth": "month",
|
||||||
"pricing.card.perYear": "year",
|
"pricing.card.perYear": "year",
|
||||||
"pricing.card.savePerMonth": "Save ${amount}/month",
|
"pricing.card.savePerMonth": "Save €{amount}/month",
|
||||||
"pricing.card.discountBadge": "-20%",
|
"pricing.card.discountBadge": "-20%",
|
||||||
"pricing.card.unlimitedSkus": "Unlimited SKUs",
|
"pricing.card.unlimitedSkus": "Unlimited SKUs",
|
||||||
"pricing.card.oneMSkus": "1M+ SKUs",
|
"pricing.card.oneMSkus": "1M+ SKUs",
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const es: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5275,7 +5275,7 @@ export const es: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "¿Qué son los créditos de IA?",
|
"pricing.faq.credits.q": "¿Qué son los créditos de IA?",
|
||||||
"pricing.faq.credits.a": "Los créditos de IA pagan pasos como generar tÃÂÂtulos y descripciones. Free incluye 0 créditos de IA  aún puedes mapear feeds y limpiar datos. Paquetes mensuales de pago: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise incluye un paquete gestionado grande (y tu propia clave). Desde Growth puedes usar opcionalmente tu propia clave en lugar de créditos gestionados.",
|
"pricing.faq.credits.a": "Los créditos de IA pagan pasos como generar tÃÂÂtulos y descripciones. Free incluye 0 créditos de IA  aún puedes mapear feeds y limpiar datos. Paquetes mensuales de pago: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise incluye un paquete gestionado grande (y tu propia clave). Desde Growth puedes usar opcionalmente tu propia clave en lugar de créditos gestionados.",
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "¿Qué pasa si alcanzo el lÃÂÂmite de productos o créditos?",
|
"pricing.faq.limits.q": "¿Qué pasa si alcanzo el lÃÂÂmite de productos o créditos?",
|
||||||
"pricing.faq.limits.a": "Te avisamos al acercarte. Cuando llegues al tope de productos o te quedes sin créditos de IA, los trabajos que necesiten esa capacidad se pausan hasta liberar espacio, esperar el siguiente ciclo o mejorar de plan.",
|
"pricing.faq.limits.a": "Te avisamos al acercarte. Cuando llegues al tope de productos o te quedes sin créditos de IA, los trabajos que necesiten esa capacidad se pausan hasta liberar espacio, esperar el siguiente ciclo o mejorar de plan.",
|
||||||
"pricing.faq.change.q": "¿Puedo subir o bajar de plan?",
|
"pricing.faq.change.q": "¿Puedo subir o bajar de plan?",
|
||||||
@@ -5312,7 +5312,7 @@ export const es: MessageDict = {
|
|||||||
"pricing.card.forever": "para siempre",
|
"pricing.card.forever": "para siempre",
|
||||||
"pricing.card.perMonth": "mes",
|
"pricing.card.perMonth": "mes",
|
||||||
"pricing.card.perYear": "año",
|
"pricing.card.perYear": "año",
|
||||||
"pricing.card.savePerMonth": "Ahorra ${amount}/mes",
|
"pricing.card.savePerMonth": "Ahorra €{amount}/mes",
|
||||||
"pricing.card.discountBadge": "-20%",
|
"pricing.card.discountBadge": "-20%",
|
||||||
"pricing.card.unlimitedSkus": "SKU ilimitados",
|
"pricing.card.unlimitedSkus": "SKU ilimitados",
|
||||||
"pricing.card.oneMSkus": "Más de 1M de SKU",
|
"pricing.card.oneMSkus": "Más de 1M de SKU",
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const fr: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5275,7 +5275,7 @@ export const fr: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "Que sont les crédits IA ?",
|
"pricing.faq.credits.q": "Que sont les crédits IA ?",
|
||||||
"pricing.faq.credits.a": "Les crédits IA paient des étapes comme la génération de titres et descriptions. Free inclut 0 crédit IA  vous pouvez quand même mapper des flux et nettoyer les données. Packs mensuels payants : Starter 150, Plus 500, Growth 1 200, Business 4 000, Scale 8 000. Enterprise inclut un large pack géré (et votre propre clé). À partir de Growth, vous pouvez optionnellement utiliser votre propre clé.",
|
"pricing.faq.credits.a": "Les crédits IA paient des étapes comme la génération de titres et descriptions. Free inclut 0 crédit IA  vous pouvez quand même mapper des flux et nettoyer les données. Packs mensuels payants : Starter 150, Plus 500, Growth 1 200, Business 4 000, Scale 8 000. Enterprise inclut un large pack géré (et votre propre clé). À partir de Growth, vous pouvez optionnellement utiliser votre propre clé.",
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "Que se passe-t-il si j’atteins la limite produits ou crédits ?",
|
"pricing.faq.limits.q": "Que se passe-t-il si j’atteins la limite produits ou crédits ?",
|
||||||
"pricing.faq.limits.a": "Nous vous prévenons àl’approche. Au plafond produits ou sans crédits IA, les jobs qui en ont besoin se mettent en pause jusqu’àlibérer de la capacité, attendre le prochain cycle ou changer d’offre.",
|
"pricing.faq.limits.a": "Nous vous prévenons àl’approche. Au plafond produits ou sans crédits IA, les jobs qui en ont besoin se mettent en pause jusqu’àlibérer de la capacité, attendre le prochain cycle ou changer d’offre.",
|
||||||
"pricing.faq.change.q": "Puis-je monter ou descendre d’offre ?",
|
"pricing.faq.change.q": "Puis-je monter ou descendre d’offre ?",
|
||||||
@@ -5312,7 +5312,7 @@ export const fr: MessageDict = {
|
|||||||
"pricing.card.forever": "pour toujours",
|
"pricing.card.forever": "pour toujours",
|
||||||
"pricing.card.perMonth": "mois",
|
"pricing.card.perMonth": "mois",
|
||||||
"pricing.card.perYear": "an",
|
"pricing.card.perYear": "an",
|
||||||
"pricing.card.savePerMonth": "Économisez ${amount}/mois",
|
"pricing.card.savePerMonth": "Économisez €{amount}/mois",
|
||||||
"pricing.card.discountBadge": "-20 %",
|
"pricing.card.discountBadge": "-20 %",
|
||||||
"pricing.card.unlimitedSkus": "SKU illimités",
|
"pricing.card.unlimitedSkus": "SKU illimités",
|
||||||
"pricing.card.oneMSkus": "1 M+ SKU",
|
"pricing.card.oneMSkus": "1 M+ SKU",
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const it: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5275,7 +5275,7 @@ export const it: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "Cosa sono i crediti AI?",
|
"pricing.faq.credits.q": "Cosa sono i crediti AI?",
|
||||||
"pricing.faq.credits.a": "I crediti AI pagano passaggi come la generazione di titoli e descrizioni. Free include 0 crediti AI  puoi comunque mappare i feed e pulire i dati. Pacchetti mensili a pagamento: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise include un grande pacchetto gestito (e la tua chiave AI). Da Growth in su puoi opzionalmente usare la tua chiave al posto dei crediti gestiti.",
|
"pricing.faq.credits.a": "I crediti AI pagano passaggi come la generazione di titoli e descrizioni. Free include 0 crediti AI  puoi comunque mappare i feed e pulire i dati. Pacchetti mensili a pagamento: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise include un grande pacchetto gestito (e la tua chiave AI). Da Growth in su puoi opzionalmente usare la tua chiave al posto dei crediti gestiti.",
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "Cosa succede se raggiungo il limite di prodotti o crediti?",
|
"pricing.faq.limits.q": "Cosa succede se raggiungo il limite di prodotti o crediti?",
|
||||||
"pricing.faq.limits.a": "Ti avvisiamo quando ti avvicini. Quando raggiungi il tetto prodotti o finisci i crediti AI, i job che richiedono quella capacitàsi mettono in pausa finché non liberi spazio, aspetti il ciclo successivo o fai upgrade.",
|
"pricing.faq.limits.a": "Ti avvisiamo quando ti avvicini. Quando raggiungi il tetto prodotti o finisci i crediti AI, i job che richiedono quella capacitàsi mettono in pausa finché non liberi spazio, aspetti il ciclo successivo o fai upgrade.",
|
||||||
"pricing.faq.change.q": "Posso fare upgrade o downgrade?",
|
"pricing.faq.change.q": "Posso fare upgrade o downgrade?",
|
||||||
@@ -5312,7 +5312,7 @@ export const it: MessageDict = {
|
|||||||
"pricing.card.forever": "per sempre",
|
"pricing.card.forever": "per sempre",
|
||||||
"pricing.card.perMonth": "mese",
|
"pricing.card.perMonth": "mese",
|
||||||
"pricing.card.perYear": "anno",
|
"pricing.card.perYear": "anno",
|
||||||
"pricing.card.savePerMonth": "Risparmia ${amount}/mese",
|
"pricing.card.savePerMonth": "Risparmia €{amount}/mese",
|
||||||
"pricing.card.discountBadge": "-20%",
|
"pricing.card.discountBadge": "-20%",
|
||||||
"pricing.card.unlimitedSkus": "SKU illimitati",
|
"pricing.card.unlimitedSkus": "SKU illimitati",
|
||||||
"pricing.card.oneMSkus": "Oltre 1M di SKU",
|
"pricing.card.oneMSkus": "Oltre 1M di SKU",
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const ja: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5275,7 +5275,7 @@ export const ja: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "AIクレジットã¨ã¯何ã§ã™ã‹?",
|
"pricing.faq.credits.q": "AIクレジットã¨ã¯何ã§ã™ã‹?",
|
||||||
"pricing.faq.credits.a": "AIクレジットã¯ã€ÂÂタイトルや説明文ã®çâ€ÂŸæˆÂÂãªã©ã®ステッãƒâ€â€ÃƒÂ£Ã‚«使ã‚ÂÂれã¾ã™。Freeã«ã¯AIクレジットãÂÂÅ’0å«ã¾れã¾ãÂÂâ„¢  フィードã®マッãƒâ€Âングã¨商å“ÂÂデータã®クリーンアッãƒâ€â€ÃƒÂ£Ã‚¯å¯能ã§ã™。有料ã®月次パック:Starter 150ã€ÂÂPlus 500ã€ÂÂGrowth 1,200ã€ÂÂBusiness 4,000ã€ÂÂScale 8,000。Enterpriseã«ã¯大è¦ÂÂ模ãªマãƒÂÂージドパック(ãŠよã³独自ã®AIã‚ÂÂー)ãÂÂŒå«ã¾れã¾ã™。Growth以上ã§ã¯ã€ÂÂマãƒÂÂージドクレジットã®代ã‚ÂÂりã«独自ã‚ÂÂーã§AIを実行ã™るã“ã¨もã§ãÂÂÂÂã¾ãÂÂâ„¢ÃLine truncated
|
"pricing.faq.credits.a": "AIクレジットã¯ã€ÂÂタイトルや説明文ã®çâ€ÂŸæˆÂÂãªã©ã®ステッãƒâ€â€ÃƒÂ£Ã‚«使ã‚ÂÂれã¾ã™。Freeã«ã¯AIクレジットãÂÂÅ’0å«ã¾れã¾ãÂÂâ„¢  フィードã®マッãƒâ€Âングã¨商å“ÂÂデータã®クリーンアッãƒâ€â€ÃƒÂ£Ã‚¯å¯能ã§ã™。有料ã®月次パック:Starter 150ã€ÂÂPlus 500ã€ÂÂGrowth 1,200ã€ÂÂBusiness 4,000ã€ÂÂScale 8,000。Enterpriseã«ã¯大è¦ÂÂ模ãªマãƒÂÂージドパック(ãŠよã³独自ã®AIã‚ÂÂー)ãÂÂŒå«ã¾れã¾ã™。Growth以上ã§ã¯ã€ÂÂマãƒÂÂージドクレジットã®代ã‚ÂÂりã«独自ã‚ÂÂーã§AIを実行ã™るã“ã¨もã§ãÂÂÂÂã¾ãÂÂâ„¢ÃLine truncated
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "商å“ÂÂã¾ãŸã¯クレジット上é™ÂÂã«éÂÂâ€Âã™るã¨ã©ã†ãªりã¾ã™ã‹?",
|
"pricing.faq.limits.q": "商å“ÂÂã¾ãŸã¯クレジット上é™ÂÂã«éÂÂâ€Âã™るã¨ã©ã†ãªりã¾ã™ã‹?",
|
||||||
"pricing.faq.limits.a": "è¿‘ãÂÂ¥ãÂÂÂÂã¨è¦告ãÂÂâ€â€ÃƒÂ£Ã‚¾ã™。商å“ÂÂ上é™ÂÂã«éÂÂâ€Âã™るã€ÂÂã¾ãŸã¯AIクレジットãÂŒ尽ãÂÂÂÂã‚‹ã¨ã€ÂÂãÂÂÂÂã®容é‡ÂÂãÂŒ必è¦ÂÂãªジョブã¯ã€ÂÂ空ãÂÂÂÂを確ä¿ÂÂã™るã€ÂÂ次ã®請求サイクルを待ã¤ã€ÂÂã¾ãŸã¯アッãƒâ€â€ÃƒÂ£Ã¢â‚¬Å¡Ã‚°Ã£Æ’¬ãƒ¼ãƒ‰ã™るã¾ã§一時åÂÂϾ¢ãÂÂâ€â€ÃƒÂ£Ã‚¾ã™。",
|
"pricing.faq.limits.a": "è¿‘ãÂÂ¥ãÂÂÂÂã¨è¦告ãÂÂâ€â€ÃƒÂ£Ã‚¾ã™。商å“ÂÂ上é™ÂÂã«éÂÂâ€Âã™るã€ÂÂã¾ãŸã¯AIクレジットãÂŒ尽ãÂÂÂÂã‚‹ã¨ã€ÂÂãÂÂÂÂã®容é‡ÂÂãÂŒ必è¦ÂÂãªジョブã¯ã€ÂÂ空ãÂÂÂÂを確ä¿ÂÂã™るã€ÂÂ次ã®請求サイクルを待ã¤ã€ÂÂã¾ãŸã¯アッãƒâ€â€ÃƒÂ£Ã¢â‚¬Å¡Ã‚°Ã£Æ’¬ãƒ¼ãƒ‰ã™るã¾ã§一時åÂÂϾ¢ãÂÂâ€â€ÃƒÂ£Ã‚¾ã™。",
|
||||||
"pricing.faq.change.q": "アッãƒâ€â€ÃƒÂ£Ã¢â‚¬Å¡Ã‚°Ã£Æ’¬ãƒ¼ãƒ‰ã‚„ダウングレードã¯ã§ãÂÂÂÂã¾ã™ã‹?",
|
"pricing.faq.change.q": "アッãƒâ€â€ÃƒÂ£Ã¢â‚¬Å¡Ã‚°Ã£Æ’¬ãƒ¼ãƒ‰ã‚„ダウングレードã¯ã§ãÂÂÂÂã¾ã™ã‹?",
|
||||||
@@ -5312,7 +5312,7 @@ export const ja: MessageDict = {
|
|||||||
"pricing.card.forever": "ãšã£ã¨",
|
"pricing.card.forever": "ãšã£ã¨",
|
||||||
"pricing.card.perMonth": "月",
|
"pricing.card.perMonth": "月",
|
||||||
"pricing.card.perYear": "å¹´",
|
"pricing.card.perYear": "å¹´",
|
||||||
"pricing.card.savePerMonth": "${amount}/月ãŠå¾â€â€",
|
"pricing.card.savePerMonth": "€{amount}/月ãŠå¾â€â€",
|
||||||
"pricing.card.discountBadge": "-20%",
|
"pricing.card.discountBadge": "-20%",
|
||||||
"pricing.card.unlimitedSkus": "SKU無制é™ÂÂ",
|
"pricing.card.unlimitedSkus": "SKU無制é™ÂÂ",
|
||||||
"pricing.card.oneMSkus": "100万以上ã®SKU",
|
"pricing.card.oneMSkus": "100万以上ã®SKU",
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const nl: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5275,7 +5275,7 @@ export const nl: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "Wat zijn AI-credits?",
|
"pricing.faq.credits.q": "Wat zijn AI-credits?",
|
||||||
"pricing.faq.credits.a": "AI-credits betalen stappen zoals het genereren van titels en beschrijvingen. Free bevat 0 AI-credits  je kunt nog steeds feeds mappen en productdata opschonen. Betaalde maandpakketten: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise bevat een groot beheerd pakket (en je eigen AI-sleutel). Vanaf Growth kun je optioneel AI op je eigen sleutel draaien in plaats van beheerde credits.",
|
"pricing.faq.credits.a": "AI-credits betalen stappen zoals het genereren van titels en beschrijvingen. Free bevat 0 AI-credits  je kunt nog steeds feeds mappen en productdata opschonen. Betaalde maandpakketten: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. Enterprise bevat een groot beheerd pakket (en je eigen AI-sleutel). Vanaf Growth kun je optioneel AI op je eigen sleutel draaien in plaats van beheerde credits.",
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "Wat gebeurt er als ik mijn product- of creditlimiet bereik?",
|
"pricing.faq.limits.q": "Wat gebeurt er als ik mijn product- of creditlimiet bereik?",
|
||||||
"pricing.faq.limits.a": "We waarschuwen je wanneer je dichtbij komt. Als je je productplafond bereikt of AI-credits opraken, pauzeren jobs die die capaciteit nodig hebben tot je ruimte vrijmaakt, wacht op de volgende factureringscyclus of upgrade.",
|
"pricing.faq.limits.a": "We waarschuwen je wanneer je dichtbij komt. Als je je productplafond bereikt of AI-credits opraken, pauzeren jobs die die capaciteit nodig hebben tot je ruimte vrijmaakt, wacht op de volgende factureringscyclus of upgrade.",
|
||||||
"pricing.faq.change.q": "Kan ik upgraden of downgraden?",
|
"pricing.faq.change.q": "Kan ik upgraden of downgraden?",
|
||||||
@@ -5312,7 +5312,7 @@ export const nl: MessageDict = {
|
|||||||
"pricing.card.forever": "voor altijd",
|
"pricing.card.forever": "voor altijd",
|
||||||
"pricing.card.perMonth": "maand",
|
"pricing.card.perMonth": "maand",
|
||||||
"pricing.card.perYear": "jaar",
|
"pricing.card.perYear": "jaar",
|
||||||
"pricing.card.savePerMonth": "Bespaar ${amount}/maand",
|
"pricing.card.savePerMonth": "Bespaar €{amount}/maand",
|
||||||
"pricing.card.discountBadge": "-20%",
|
"pricing.card.discountBadge": "-20%",
|
||||||
"pricing.card.unlimitedSkus": "Onbeperkte SKU's",
|
"pricing.card.unlimitedSkus": "Onbeperkte SKU's",
|
||||||
"pricing.card.oneMSkus": "1M+ SKU's",
|
"pricing.card.oneMSkus": "1M+ SKU's",
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const pl: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5275,7 +5275,7 @@ export const pl: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "Czym sÄ… kredyty AI?",
|
"pricing.faq.credits.q": "Czym sÄ… kredyty AI?",
|
||||||
"pricing.faq.credits.a": "Kredyty AI opłacają kroki takie jak generowanie tytułów i opisów. Free obejmuje 0 kredytów AI  nadal możesz mapować feedy i czyścić dane produktów. Płatne pakiety miesięczne: Starter 150, Plus 500, Growth 1 200, Business 4 000, Scale 8 000. Enterprise obejmuje duży zarządzany pakiet (oraz własny klucz AI). Od Growth w górę możesz opcjonalnie uruchamiać AI na własnym kluczu zamiast zarządzanych kredytów.",
|
"pricing.faq.credits.a": "Kredyty AI opłacają kroki takie jak generowanie tytułów i opisów. Free obejmuje 0 kredytów AI  nadal możesz mapować feedy i czyścić dane produktów. Płatne pakiety miesięczne: Starter 150, Plus 500, Growth 1 200, Business 4 000, Scale 8 000. Enterprise obejmuje duży zarządzany pakiet (oraz własny klucz AI). Od Growth w górę możesz opcjonalnie uruchamiać AI na własnym kluczu zamiast zarządzanych kredytów.",
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "Co się stanie, gdy osiągnę limit produktów lub kredytów?",
|
"pricing.faq.limits.q": "Co się stanie, gdy osiągnę limit produktów lub kredytów?",
|
||||||
"pricing.faq.limits.a": "Ostrzegamy, gdy się zbliżasz. Po osiągnięciu limitu produktów lub wyczerpaniu kredytów AI zadania wymagające tej pojemności wstrzymują się, aż zwolnisz miejsce, poczekasz na kolejny cykl rozliczeniowy lub przejdziesz wyżej.",
|
"pricing.faq.limits.a": "Ostrzegamy, gdy się zbliżasz. Po osiągnięciu limitu produktów lub wyczerpaniu kredytów AI zadania wymagające tej pojemności wstrzymują się, aż zwolnisz miejsce, poczekasz na kolejny cykl rozliczeniowy lub przejdziesz wyżej.",
|
||||||
"pricing.faq.change.q": "Czy mogę przejść wyżej lub niżej?",
|
"pricing.faq.change.q": "Czy mogę przejść wyżej lub niżej?",
|
||||||
@@ -5312,7 +5312,7 @@ export const pl: MessageDict = {
|
|||||||
"pricing.card.forever": "na zawsze",
|
"pricing.card.forever": "na zawsze",
|
||||||
"pricing.card.perMonth": "miesiÄ…c",
|
"pricing.card.perMonth": "miesiÄ…c",
|
||||||
"pricing.card.perYear": "rok",
|
"pricing.card.perYear": "rok",
|
||||||
"pricing.card.savePerMonth": "Oszczędź ${amount}/mies.",
|
"pricing.card.savePerMonth": "OszczÄ™dź €{amount}/mies.",
|
||||||
"pricing.card.discountBadge": "-20%",
|
"pricing.card.discountBadge": "-20%",
|
||||||
"pricing.card.unlimitedSkus": "Bez limitu SKU",
|
"pricing.card.unlimitedSkus": "Bez limitu SKU",
|
||||||
"pricing.card.oneMSkus": "1 mln+ SKU",
|
"pricing.card.oneMSkus": "1 mln+ SKU",
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ export const pt: MessageDict = {
|
|||||||
"admin.sales.monthlyCredits": "Monthly AI credits",
|
"admin.sales.monthlyCredits": "Monthly AI credits",
|
||||||
"admin.sales.maxProducts": "Max SKUs",
|
"admin.sales.maxProducts": "Max SKUs",
|
||||||
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
"admin.sales.unlimitedHint": "Leave blank for unlimited",
|
||||||
"admin.sales.totalUsd": "Total price (USD)",
|
"admin.sales.totalUsd": "Total price (EUR)",
|
||||||
"admin.sales.termMonths": "Term (months)",
|
"admin.sales.termMonths": "Term (months)",
|
||||||
"admin.sales.installmentCount": "Installments",
|
"admin.sales.installmentCount": "Installments",
|
||||||
"admin.sales.installmentInterval": "Interval",
|
"admin.sales.installmentInterval": "Interval",
|
||||||
@@ -5275,7 +5275,7 @@ export const pt: MessageDict = {
|
|||||||
"pricing.faq.credits.q": "O que são créditos de IA?",
|
"pricing.faq.credits.q": "O que são créditos de IA?",
|
||||||
"pricing.faq.credits.a": "Os créditos de IA pagam passos como gerar tÃÂÂtulos e descrições. O Free inclui 0 créditos de IA  ainda pode mapear feeds e limpar dados. Pacotes mensais pagos: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. O Enterprise inclui um grande pacote gerido (e a sua própria chave). A partir do Growth, pode opcionalmente usar a sua chave em vez dos créditos geridos.",
|
"pricing.faq.credits.a": "Os créditos de IA pagam passos como gerar tÃÂÂtulos e descrições. O Free inclui 0 créditos de IA  ainda pode mapear feeds e limpar dados. Pacotes mensais pagos: Starter 150, Plus 500, Growth 1.200, Business 4.000, Scale 8.000. O Enterprise inclui um grande pacote gerido (e a sua própria chave). A partir do Growth, pode opcionalmente usar a sua chave em vez dos créditos geridos.",
|
||||||
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
"pricing.faq.packs.q": "Can I buy extra AI credits?",
|
||||||
"pricing.faq.packs.a": "Yes. One-time packs: Starter $19 / 500 credits, Growth $59 / 2,000, Catalog $199 / 10,000, Scale $599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
"pricing.faq.packs.a": "Yes. One-time packs: Starter €19 / 500 credits, Growth €59 / 2,000, Catalog €199 / 10,000, Scale €599 / 40,000. Buy from Billing after you have a paid plan (or Free with leftover trial credits). Packs do not change your SKU or feed limits.",
|
||||||
"pricing.faq.limits.q": "O que acontece se atingir o limite de produtos ou créditos?",
|
"pricing.faq.limits.q": "O que acontece se atingir o limite de produtos ou créditos?",
|
||||||
"pricing.faq.limits.a": "Avisamos quando se aproximar. Quando atingir o teto de produtos ou ficar sem créditos de IA, os trabalhos que precisam dessa capacidade pausam até libertar espaço, esperar o ciclo seguinte ou fazer upgrade.",
|
"pricing.faq.limits.a": "Avisamos quando se aproximar. Quando atingir o teto de produtos ou ficar sem créditos de IA, os trabalhos que precisam dessa capacidade pausam até libertar espaço, esperar o ciclo seguinte ou fazer upgrade.",
|
||||||
"pricing.faq.change.q": "Posso fazer upgrade ou downgrade?",
|
"pricing.faq.change.q": "Posso fazer upgrade ou downgrade?",
|
||||||
@@ -5312,7 +5312,7 @@ export const pt: MessageDict = {
|
|||||||
"pricing.card.forever": "para sempre",
|
"pricing.card.forever": "para sempre",
|
||||||
"pricing.card.perMonth": "mês",
|
"pricing.card.perMonth": "mês",
|
||||||
"pricing.card.perYear": "ano",
|
"pricing.card.perYear": "ano",
|
||||||
"pricing.card.savePerMonth": "Poupe ${amount}/mês",
|
"pricing.card.savePerMonth": "Poupe €{amount}/mês",
|
||||||
"pricing.card.discountBadge": "-20%",
|
"pricing.card.discountBadge": "-20%",
|
||||||
"pricing.card.unlimitedSkus": "SKUs ilimitados",
|
"pricing.card.unlimitedSkus": "SKUs ilimitados",
|
||||||
"pricing.card.oneMSkus": "Mais de 1M de SKUs",
|
"pricing.card.oneMSkus": "Mais de 1M de SKUs",
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { describe, it } from 'node:test';
|
||||||
|
import { PRICING_PLANS } from './components/pricing/pricing-data.ts';
|
||||||
|
import { CREDIT_PACKS } from './components/pricing/credit-packs.ts';
|
||||||
|
import { buildCreditPackEcommerce, buildSubscriptionEcommerce } from './analytics/ecommerce.ts';
|
||||||
|
|
||||||
|
describe('EUR pricing', () => {
|
||||||
|
it('uses the approved numeric ladder as EUR list prices', () => {
|
||||||
|
assert.deepEqual(PRICING_PLANS.filter(p => !p.customPrice).map(p => [p.name, p.pricePerMonth]), [
|
||||||
|
['Free', 0], ['Starter', 49], ['Plus', 199], ['Growth', 299], ['Business', 499], ['Scale', 999]
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
it('tracks subscriptions and top-ups in EUR', () => {
|
||||||
|
assert.equal(buildSubscriptionEcommerce('business').ecommerce.currency, 'EUR');
|
||||||
|
assert.equal(buildCreditPackEcommerce('tiny').ecommerce.currency, 'EUR');
|
||||||
|
assert.equal(CREDIT_PACKS[0]?.priceEUR, 29);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -28,7 +28,7 @@ export const HOME_SEO: PageSeo = {
|
|||||||
export const PRICING_SEO: PageSeo = {
|
export const PRICING_SEO: PageSeo = {
|
||||||
title: "Pricing: Free, Starter, Growth, Business | Descrybe",
|
title: "Pricing: Free, Starter, Growth, Business | Descrybe",
|
||||||
description:
|
description:
|
||||||
"Start free with 100 products and feed mapping. Paid plans add AI titles and descriptions, more SKUs, export feeds, and WooCommerce sync from $49/month. Enterprise supports unlimited catalogs.",
|
"Start free with 100 products and feed mapping. Paid plans add AI titles and descriptions, more SKUs, export feeds, and WooCommerce sync from €49/month. Enterprise supports unlimited catalogs.",
|
||||||
path: "/pricing",
|
path: "/pricing",
|
||||||
image: DEFAULT_OG_IMAGE,
|
image: DEFAULT_OG_IMAGE,
|
||||||
imageAlt: DEFAULT_OG_IMAGE_ALT
|
imageAlt: DEFAULT_OG_IMAGE_ALT
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export type CreditPack = {
|
|||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
credits: number;
|
credits: number;
|
||||||
price_usd: number;
|
price_eur: number;
|
||||||
ai_products: number;
|
ai_products: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ export async function startCreditPackCheckout(packId: string): Promise<CheckoutR
|
|||||||
}
|
}
|
||||||
const marketing = CREDIT_PACKS.find((p) => p.id === pack);
|
const marketing = CREDIT_PACKS.find((p) => p.id === pack);
|
||||||
const { ecommerce, extra } = buildCreditPackEcommerce(pack, {
|
const { ecommerce, extra } = buildCreditPackEcommerce(pack, {
|
||||||
priceUsd: marketing?.priceUSD,
|
priceEur: marketing?.priceEUR,
|
||||||
itemName: marketing?.name
|
itemName: marketing?.name
|
||||||
});
|
});
|
||||||
trackEcommerceEvent("begin_checkout", ecommerce, extra);
|
trackEcommerceEvent("begin_checkout", ecommerce, extra);
|
||||||
|
|||||||
@@ -145,6 +145,69 @@
|
|||||||
let accessDenied = $state(false);
|
let accessDenied = $state(false);
|
||||||
let error = $state("");
|
let error = $state("");
|
||||||
let days = $state(30);
|
let days = $state(30);
|
||||||
|
type AICostRow = {
|
||||||
|
id?: string;
|
||||||
|
label?: string;
|
||||||
|
calls?: number;
|
||||||
|
prompt_tokens?: number;
|
||||||
|
cached_prompt_tokens?: number;
|
||||||
|
completion_tokens?: number;
|
||||||
|
total_tokens?: number;
|
||||||
|
cost_micros?: number;
|
||||||
|
};
|
||||||
|
type AICostReport = {
|
||||||
|
totals?: AICostRow;
|
||||||
|
by_company?: AICostRow[];
|
||||||
|
};
|
||||||
|
type CreditCostRule = {
|
||||||
|
scope: string;
|
||||||
|
id: string;
|
||||||
|
feature: string;
|
||||||
|
cost_per_unit: number;
|
||||||
|
};
|
||||||
|
let aiCost = $state<AICostReport | null>(null);
|
||||||
|
let fxRate = $state("");
|
||||||
|
let costRules = $state<CreditCostRule[]>([]);
|
||||||
|
let priceScope = $state("company");
|
||||||
|
let priceOwner = $state("");
|
||||||
|
let priceFeature = $state("product_processing");
|
||||||
|
let priceCredits = $state("2");
|
||||||
|
let pricingMessage = $state("");
|
||||||
|
let pricingSaving = $state(false);
|
||||||
|
|
||||||
|
function usd(micros?: number): string {
|
||||||
|
return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(Number(micros ?? 0) / 1000000);
|
||||||
|
}
|
||||||
|
function euroEstimate(micros?: number): string {
|
||||||
|
const rate = Number(fxRate);
|
||||||
|
if (!fxRate || !Number.isFinite(rate) || rate <= 0 || rate > 2) return "Set a USD→EUR rate";
|
||||||
|
return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(Number(micros ?? 0) / 1000000 * rate);
|
||||||
|
}
|
||||||
|
async function refreshCostRules() {
|
||||||
|
try {
|
||||||
|
const result = await api<{ rules: CreditCostRule[] }>("/api/admin/processing-costs");
|
||||||
|
costRules = result.rules ?? [];
|
||||||
|
} catch { costRules = []; }
|
||||||
|
}
|
||||||
|
async function saveProcessingCost() {
|
||||||
|
pricingMessage = "";
|
||||||
|
const creditCost = Number(priceCredits);
|
||||||
|
if (!priceOwner.trim() || !Number.isInteger(creditCost) || creditCost < 1 || creditCost > 1000000) {
|
||||||
|
pricingMessage = "Select a plan/company and enter a positive integer credit amount.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pricingSaving = true;
|
||||||
|
try {
|
||||||
|
await api("/api/admin/processing-costs", {
|
||||||
|
method: "PUT",
|
||||||
|
body: { scope: priceScope, id: priceOwner, feature: priceFeature, cost_per_unit: creditCost }
|
||||||
|
});
|
||||||
|
pricingMessage = "Saved. This rate applies to future processing, not past credits.";
|
||||||
|
await refreshCostRules();
|
||||||
|
} catch (err) { pricingMessage = failureMessage(err, "Could not save credit rate"); }
|
||||||
|
finally { pricingSaving = false; }
|
||||||
|
}
|
||||||
|
|
||||||
let data = $state<AnalyticsResponse | null>(null);
|
let data = $state<AnalyticsResponse | null>(null);
|
||||||
|
|
||||||
const tokenPoints = $derived(
|
const tokenPoints = $derived(
|
||||||
@@ -224,7 +287,7 @@
|
|||||||
loading = false;
|
loading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await load(days);
|
await Promise.all([load(days), refreshCostRules()]);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function load(nextDays: number) {
|
async function load(nextDays: number) {
|
||||||
@@ -232,7 +295,12 @@
|
|||||||
error = "";
|
error = "";
|
||||||
days = nextDays;
|
days = nextDays;
|
||||||
try {
|
try {
|
||||||
data = await api<AnalyticsResponse>(`/api/admin/analytics?days=${nextDays}`);
|
const [analytics, costs] = await Promise.all([
|
||||||
|
api<AnalyticsResponse>(`/api/admin/analytics?days=${nextDays}`),
|
||||||
|
api<AICostReport>(`/api/admin/ai-costs?days=${nextDays}`).catch(() => null)
|
||||||
|
]);
|
||||||
|
data = analytics;
|
||||||
|
aiCost = costs;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error = failureMessage(err, i18n.t("flash.admin.analyticsLoadFailed"));
|
error = failureMessage(err, i18n.t("flash.admin.analyticsLoadFailed"));
|
||||||
data = null;
|
data = null;
|
||||||
@@ -286,7 +354,65 @@
|
|||||||
{:else if error && !data}
|
{:else if error && !data}
|
||||||
<Alert message={error} />
|
<Alert message={error} />
|
||||||
{:else if data}
|
{:else if data}
|
||||||
<div class="space-y-8">
|
<div class="space-y-8">
|
||||||
|
<section class="space-y-3 rounded-lg border border-border bg-card p-4">
|
||||||
|
<div class="flex flex-wrap justify-between items-center gap-3">
|
||||||
|
<div>
|
||||||
|
<h2 class="font-semibold">AI provider costs and credit usage</h2>
|
||||||
|
<p class="text-xs text-muted-foreground">Actual logged model calls; this is operating cost, not the customer's invoice amount.</p>
|
||||||
|
</div>
|
||||||
|
<a href={`/api/admin/ai-costs/export?days=${days}`} class="rounded-md border px-3 py-2 text-sm">Export AI costs CSV</a>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 gap-4 md:grid-cols-4 text-sm">
|
||||||
|
<div><p class="text-muted-foreground">Input tokens</p><strong>{formatCredits(aiCost?.totals?.prompt_tokens ?? 0)}</strong></div>
|
||||||
|
<div><p class="text-muted-foreground">Output tokens</p><strong>{formatCredits(aiCost?.totals?.completion_tokens ?? 0)}</strong></div>
|
||||||
|
<div><p class="text-muted-foreground">Model calls</p><strong>{formatCredits(aiCost?.totals?.calls ?? 0)}</strong></div>
|
||||||
|
<div><p class="text-muted-foreground">Provider operating cost</p><strong>{usd(aiCost?.totals?.cost_micros)}</strong></div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-wrap items-center gap-3 text-sm">
|
||||||
|
<label for="analytics-fx">USD → EUR exchange rate (for estimates)</label>
|
||||||
|
<input id="analytics-fx" type="text" inputmode="decimal" placeholder="Enter verified rate" bind:value={fxRate} class="w-44 rounded border bg-background p-2" />
|
||||||
|
<strong>{euroEstimate(aiCost?.totals?.cost_micros)}</strong>
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-muted-foreground">Credits used (all-time wallet): {formatCredits(data.summary.credits_used)}. Subscription charges are separate and are sourced from Stripe invoices. USD costs are historical ledger snapshots; EUR is an estimate using the rate entered above.</p>
|
||||||
|
{#if aiCost?.by_company?.length}
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="w-full text-left text-sm">
|
||||||
|
<thead><tr class="border-b"><th class="p-2">Company</th><th class="p-2 text-right">Input</th><th class="p-2 text-right">Output</th><th class="p-2 text-right">USD cost</th><th class="p-2 text-right">EUR estimate</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
{#each aiCost?.by_company ?? [] as company (company.id)}
|
||||||
|
<tr class="border-b"><td class="p-2">{company.label || company.id}</td><td class="p-2 text-right">{formatCredits(company.prompt_tokens ?? 0)}</td><td class="p-2 text-right">{formatCredits(company.completion_tokens ?? 0)}</td><td class="p-2 text-right">{usd(company.cost_micros)}</td><td class="p-2 text-right">{euroEstimate(company.cost_micros)}</td></tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</section>
|
||||||
|
<section class="space-y-3 rounded-lg border border-border bg-card p-4">
|
||||||
|
<h2 class="font-semibold">Processing credit rules</h2>
|
||||||
|
<p class="text-xs text-muted-foreground">Company overrides take priority over plan overrides and platform defaults. Values are credits, not euros. For A1, select company and its UUID.</p>
|
||||||
|
<div class="flex flex-wrap gap-2 items-center">
|
||||||
|
<select aria-label="Pricing scope" bind:value={priceScope} class="rounded-md border bg-background p-2 text-sm"><option value="company">Company</option><option value="plan">Plan</option></select>
|
||||||
|
{#if priceScope === "company"}
|
||||||
|
<input aria-label="Company UUID" list="billing-company-ids" placeholder="Company UUID" bind:value={priceOwner} class="w-72 rounded-md border bg-background p-2 text-sm" />
|
||||||
|
<datalist id="billing-company-ids">{#each data.companies as c (c.id)}<option value={c.id}>{c.name}</option>{/each}</datalist>
|
||||||
|
{:else}
|
||||||
|
<input aria-label="Plan numeric ID" type="text" inputmode="numeric" placeholder="Plan ID" bind:value={priceOwner} class="w-28 rounded border bg-background p-2 text-sm" />
|
||||||
|
{/if}
|
||||||
|
<select aria-label="Feature" bind:value={priceFeature} class="rounded border bg-background p-2 text-sm"><option value="product_processing">Product base</option><option value="openai_token_k">Per 1K model tokens</option><option value="seo_meta_ai">SEO meta</option><option value="campaign_copy">Campaign</option></select>
|
||||||
|
<input aria-label="Credit cost" type="text" inputmode="numeric" bind:value={priceCredits} class="w-24 rounded border bg-background p-2 text-sm" />
|
||||||
|
<Button onclick={() => saveProcessingCost()} disabled={pricingSaving}>Save rate</Button>
|
||||||
|
{#if priceScope === "company" && priceOwner.trim()}
|
||||||
|
<a href={`/api/admin/billing/invoices/export?company_id=${encodeURIComponent(priceOwner)}`} class="rounded border px-3 py-2 text-sm">Export Stripe invoices</a>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{#if pricingMessage}<p class="text-xs">{pricingMessage}</p>{/if}
|
||||||
|
<div class="flex flex-wrap gap-2 text-xs text-muted-foreground">
|
||||||
|
{#each costRules as rule (`${rule.scope}:${rule.id}:${rule.feature}`)}
|
||||||
|
<span class="rounded border p-1">{rule.scope} {rule.id || 'default'} · {rule.feature}: {rule.cost_per_unit} credits</span>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
{#if error}
|
{#if error}
|
||||||
<Alert message={error} />
|
<Alert message={error} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
plan_name: planName.trim() || "Custom Deal",
|
plan_name: planName.trim() || "Custom Deal",
|
||||||
monthly_credits: credits,
|
monthly_credits: credits,
|
||||||
max_products: maxP != null && Number.isFinite(maxP) ? maxP : null,
|
max_products: maxP != null && Number.isFinite(maxP) ? maxP : null,
|
||||||
currency: "usd",
|
currency: "eur",
|
||||||
total_amount_cents: totalCents,
|
total_amount_cents: totalCents,
|
||||||
installment_count: count,
|
installment_count: count,
|
||||||
installment_interval: installmentInterval,
|
installment_interval: installmentInterval,
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
function money(cents: number, currency: string): string {
|
function money(cents: number, currency: string): string {
|
||||||
return new Intl.NumberFormat(undefined, {
|
return new Intl.NumberFormat(undefined, {
|
||||||
style: "currency",
|
style: "currency",
|
||||||
currency: (currency || "usd").toUpperCase()
|
currency: (currency || "eur").toUpperCase()
|
||||||
}).format(cents / 100);
|
}).format(cents / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1287,7 +1287,7 @@
|
|||||||
{#each CREDIT_PACKS as pack (pack.id)}
|
{#each CREDIT_PACKS as pack (pack.id)}
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Label for={"price_pack_" + pack.id}>
|
<Label for={"price_pack_" + pack.id}>
|
||||||
{pack.name} ({pack.credits} credits ≈ {pack.aiProducts} AI / ${pack.priceUSD})
|
{pack.name} ({pack.credits} credits ≈ {pack.aiProducts} AI / €{pack.priceEUR})
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id={"price_pack_" + pack.id}
|
id={"price_pack_" + pack.id}
|
||||||
|
|||||||
@@ -79,6 +79,10 @@
|
|||||||
products_processed?: number;
|
products_processed?: number;
|
||||||
products_total?: number;
|
products_total?: number;
|
||||||
tokens?: number;
|
tokens?: number;
|
||||||
|
input_tokens?: number;
|
||||||
|
cached_input_tokens?: number;
|
||||||
|
output_tokens?: number;
|
||||||
|
ai_calls?: number;
|
||||||
feeds_input?: number;
|
feeds_input?: number;
|
||||||
feeds_export?: number;
|
feeds_export?: number;
|
||||||
jobs_total?: number;
|
jobs_total?: number;
|
||||||
@@ -88,6 +92,19 @@
|
|||||||
notes?: string[];
|
notes?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type StripeInvoice = {
|
||||||
|
id: string;
|
||||||
|
number: string;
|
||||||
|
status: string;
|
||||||
|
currency: string;
|
||||||
|
created: number;
|
||||||
|
amount_due: number;
|
||||||
|
amount_paid: number;
|
||||||
|
hosted_invoice_url?: string;
|
||||||
|
invoice_pdf?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
let invoices = $state<StripeInvoice[]>([]);
|
||||||
let credits = $state<CreditBalance | null>(null);
|
let credits = $state<CreditBalance | null>(null);
|
||||||
let usage = $state<UsageSummary | null>(null);
|
let usage = $state<UsageSummary | null>(null);
|
||||||
let stripe = $state<StripeStatus | null>(null);
|
let stripe = $state<StripeStatus | null>(null);
|
||||||
@@ -122,6 +139,10 @@
|
|||||||
credits = creditsRes;
|
credits = creditsRes;
|
||||||
usage = usageRes;
|
usage = usageRes;
|
||||||
stripe = stripeRes;
|
stripe = stripeRes;
|
||||||
|
if (canManageBilling) {
|
||||||
|
const result = await api<{ invoices: StripeInvoice[] }>("/api/billing/invoices").catch(() => ({ invoices: [] }));
|
||||||
|
invoices = result.invoices ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
const checkout = page.url.searchParams.get("checkout");
|
const checkout = page.url.searchParams.get("checkout");
|
||||||
const portal = page.url.searchParams.get("portal");
|
const portal = page.url.searchParams.get("portal");
|
||||||
@@ -304,6 +325,12 @@
|
|||||||
Boolean(stripe && (stripe.has_customer || stripe.has_subscription || stripe.mock))
|
Boolean(stripe && (stripe.has_customer || stripe.has_subscription || stripe.mock))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function invoiceAmount(amount: number, currency: string): string {
|
||||||
|
const code = String(currency || "eur").toUpperCase();
|
||||||
|
const major = ["JPY", "KRW"].includes(code) ? amount : amount / 100;
|
||||||
|
return new Intl.NumberFormat(undefined, { style: "currency", currency: code }).format(major);
|
||||||
|
}
|
||||||
|
|
||||||
function formatContractDate(value: string | Date | null | undefined): string {
|
function formatContractDate(value: string | Date | null | undefined): string {
|
||||||
if (!value) return i18n.t("billing.na");
|
if (!value) return i18n.t("billing.na");
|
||||||
const d = value instanceof Date ? value : new Date(value);
|
const d = value instanceof Date ? value : new Date(value);
|
||||||
@@ -638,7 +665,7 @@
|
|||||||
<p class="text-sm font-medium text-foreground">{i18n.t(pack.nameKey)}</p>
|
<p class="text-sm font-medium text-foreground">{i18n.t(pack.nameKey)}</p>
|
||||||
<p class="text-xs text-muted-foreground">{i18n.t(pack.descriptionKey)}</p>
|
<p class="text-xs text-muted-foreground">{i18n.t(pack.descriptionKey)}</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="shrink-0 text-sm font-semibold tabular-nums">${pack.priceUSD}</p>
|
<p class="shrink-0 text-sm font-semibold tabular-nums">€{pack.priceEUR}</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-xs text-muted-foreground">
|
<p class="text-xs text-muted-foreground">
|
||||||
{i18n.t("billing.packCredits", { credits: pack.credits.toLocaleString() })}
|
{i18n.t("billing.packCredits", { credits: pack.credits.toLocaleString() })}
|
||||||
@@ -660,6 +687,45 @@
|
|||||||
</section>
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<section class="rounded-lg border border-border bg-card p-4 space-y-3">
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
|
<div>
|
||||||
|
<h2 class="font-semibold">AI usage and billing documents</h2>
|
||||||
|
<p class="text-xs text-muted-foreground">Actual recorded provider usage; wallet credits are all-time, not limited by this date range.</p>
|
||||||
|
</div>
|
||||||
|
<a href={`/api/billing/usage/export?range=${dateRangeOption}`} class={buttonClasses("outline", "sm", "")}>Export usage CSV</a>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 gap-3 text-sm md:grid-cols-4">
|
||||||
|
<div><p class="text-muted-foreground">Model calls</p><b>{formatCredits(usage?.ai_calls ?? 0)}</b></div>
|
||||||
|
<div><p class="text-muted-foreground">Input tokens</p><b>{formatCredits(usage?.input_tokens ?? 0)}</b></div>
|
||||||
|
<div><p class="text-muted-foreground">Output tokens</p><b>{formatCredits(usage?.output_tokens ?? 0)}</b></div>
|
||||||
|
<div><p class="text-muted-foreground">Cached input</p><b>{formatCredits(usage?.cached_input_tokens ?? 0)}</b></div>
|
||||||
|
</div>
|
||||||
|
{#if canManageBilling}
|
||||||
|
<div class="border-t pt-3 space-y-2">
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||||
|
<b class="text-sm">Invoices from Stripe</b>
|
||||||
|
{#if showPortal}
|
||||||
|
<Button variant="outline" loading={portalBusy} onclick={() => void manageSubscription()}>Open billing portal</Button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{#if invoices.length > 0}
|
||||||
|
{#each invoices as invoice (invoice.id)}
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm">
|
||||||
|
<div><b>{invoice.number || invoice.id}</b> · {invoice.status} · Due: {invoiceAmount(invoice.amount_due, invoice.currency)} · Paid: {invoiceAmount(invoice.amount_paid, invoice.currency)}</div>
|
||||||
|
<div class="flex gap-3">
|
||||||
|
{#if invoice.hosted_invoice_url}<a class="underline" target="_blank" rel="noopener noreferrer" href={invoice.hosted_invoice_url}>View invoice</a>{/if}
|
||||||
|
{#if invoice.invoice_pdf}<a class="underline" target="_blank" rel="noopener noreferrer" href={invoice.invoice_pdf}>PDF</a>{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
{:else}
|
||||||
|
<p class="text-xs text-muted-foreground">No Stripe invoices found. Manual contracts and mock checkouts do not create a Stripe invoice.</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</section>
|
||||||
|
|
||||||
<section class="space-y-3">
|
<section class="space-y-3">
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -317,10 +317,10 @@
|
|||||||
{#if row.customPrice}
|
{#if row.customPrice}
|
||||||
<span class="text-4xl font-bold">{i18n.t("plans.price.custom")}</span>
|
<span class="text-4xl font-bold">{i18n.t("plans.price.custom")}</span>
|
||||||
{:else if row.price === 0}
|
{:else if row.price === 0}
|
||||||
<span class="text-4xl font-bold">$0</span>
|
<span class="text-4xl font-bold">€0</span>
|
||||||
<span class="ml-2 text-muted-foreground">{i18n.t("plans.price.forever")}</span>
|
<span class="ml-2 text-muted-foreground">{i18n.t("plans.price.forever")}</span>
|
||||||
{:else if row.price != null}
|
{:else if row.price != null}
|
||||||
<span class="text-4xl font-bold">${row.price}</span>
|
<span class="text-4xl font-bold">€{row.price}</span>
|
||||||
<span class="ml-2 text-muted-foreground">{i18n.t("plans.price.perMonth")}</span>
|
<span class="ml-2 text-muted-foreground">{i18n.t("plans.price.perMonth")}</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="text-2xl font-bold text-muted-foreground"
|
<span class="text-2xl font-bold text-muted-foreground"
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
import UpgradeBanner from "$lib/components/UpgradeBanner.svelte";
|
import UpgradeBanner from "$lib/components/UpgradeBanner.svelte";
|
||||||
import { Button, Card, CardHeader } from "$lib/components/ui";
|
import { Button, Card, CardHeader } from "$lib/components/ui";
|
||||||
import ProductTabs from "$lib/components/products/ProductTabs.svelte";
|
import ProductTabs from "$lib/components/products/ProductTabs.svelte";
|
||||||
import RemoteCatalogImport from "$lib/components/feeds/RemoteCatalogImport.svelte";
|
|
||||||
import ProductSearchFilters from "$lib/components/products/ProductSearchFilters.svelte";
|
import ProductSearchFilters from "$lib/components/products/ProductSearchFilters.svelte";
|
||||||
import ProductTable from "$lib/components/products/ProductTable.svelte";
|
import ProductTable from "$lib/components/products/ProductTable.svelte";
|
||||||
import ProductEmptyState from "$lib/components/products/ProductEmptyState.svelte";
|
import ProductEmptyState from "$lib/components/products/ProductEmptyState.svelte";
|
||||||
@@ -1299,14 +1298,7 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if canAdmin}
|
|
||||||
<details class="mb-4 rounded-md border border-border bg-card p-3">
|
|
||||||
<summary class="cursor-pointer text-sm font-medium">Import products from a JSON URL</summary>
|
|
||||||
<div class="mt-3">
|
|
||||||
<RemoteCatalogImport kind="products" onComplete={async () => { await loadProducts(); }} />
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{/if}
|
|
||||||
<Card
|
<Card
|
||||||
class={`min-w-0 overflow-x-auto border-border shadow-sm transition-all duration-300 ${fetching ? "bg-background/20 backdrop-blur-sm" : ""}`}
|
class={`min-w-0 overflow-x-auto border-border shadow-sm transition-all duration-300 ${fetching ? "bg-background/20 backdrop-blur-sm" : ""}`}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Descrybe v13 – Go API/worker import-cycle hotfix
|
||||||
|
|
||||||
|
## Cause
|
||||||
|
|
||||||
|
`feeds/headers.go` imported `platformsettings` to encrypt authenticated feed HTTP headers. `platformsettings` already imports `processing`, which imports `catalog`, which imports `feeds`. This created a Go dependency cycle and prevented both API and worker builds.
|
||||||
|
|
||||||
|
## Correction
|
||||||
|
|
||||||
|
- Extracted the unchanged AES-256-GCM secret storage implementation into `internal/secretcrypto`, importing only `internal/config`.
|
||||||
|
- Updated `feeds/headers.go` to call `secretcrypto` directly.
|
||||||
|
- Retained `platformsettings.DeriveKey`, `.EncryptSecret`, and `.DecryptSecret` as compatible wrappers for existing callers and stored secrets.
|
||||||
|
- Preserved `enc:v1:` ciphertext format, key derivation, production fail-closed behavior, and plaintext rejection in production.
|
||||||
|
- Previous v12 Svelte JSON placeholders remain corrected in the complete ZIP.
|
||||||
|
|
||||||
|
No database migration is required, and no existing feed API keys need rotating as long as the encryption environment key stays unchanged.
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
Merge/copy this hotfix into the project, commit and push, then run `rb` on the server.
|
||||||
|
|
||||||
|
For a focused verification before deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /var/www/descrybe/app/apps/api
|
||||||
|
/usr/local/go/bin/go test ./internal/secretcrypto
|
||||||
|
/usr/local/go/bin/go build -o /tmp/descrybe-api-verify ./cmd/api
|
||||||
|
/usr/local/go/bin/go build -o /tmp/descrybe-worker-verify ./cmd/worker
|
||||||
|
```
|
||||||
|
|
||||||
|
`rb` already builds the app and restarts it if preceding stages succeed.
|
||||||
|
|
||||||
|
## Tests and limitations
|
||||||
|
|
||||||
|
- Isolated Go 1.23 tests passed for encrypted feed header ↔ platform settings compatibility and production key handling.
|
||||||
|
- Static import graph of 29 internal Go packages: 0 dependency cycles.
|
||||||
|
- All 667 API Go source files parsed successfully.
|
||||||
|
- Full Go 1.25 API/worker build and full Svelte production build could not be executed in this environment; run the commands above in the deployment environment before production restart.
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# v14 — EUR pricing, Jager onboarding, and public API docs
|
||||||
|
|
||||||
|
## Public pricing
|
||||||
|
|
||||||
|
Marketing subscriptions retain their numeric tiers but are **new EUR-denominated prices**: Free 0 €, Starter 49 €, Plus 199 €, Growth 299 €, Business 499 €, Scale 999 € per month (Enterprise by quote). Marketing credit packs also display and sync to Stripe in EUR. GA4 purchase tracking uses EUR for subscriptions and top-ups; the separate internal AI provider cost ledger remains denominated in USD where it records actual provider expenses.
|
||||||
|
|
||||||
|
**Stripe cannot change an existing USD Price into EUR.** Before accepting new payments, create EUR Prices for all five paid plans, **both monthly and yearly**, and replace the configured Stripe Price IDs in platform settings or `STRIPE_PRICE_*` environment variables. Run the existing Stripe credit-pack sync action **after deploying** to create/reuse EUR prices for packs, then verify the returned `price_eur` values. Checkout now rejects inactive or non-EUR Stripe Prices rather than collecting USD while advertising EUR. Existing subscriptions linked to USD Price IDs are not converted automatically and must be reviewed/migrated in Stripe separately; do not cancel or replace them blindly.
|
||||||
|
|
||||||
|
The currency change is a **commercial pricing decision**, not FX conversion. Validate VAT handling, invoices, and any legacy/custom quotes separately. No database migration is needed for these source changes.
|
||||||
|
|
||||||
|
## Jager
|
||||||
|
|
||||||
|
`README_JAGER_SESTANEK_SL.md` contains the 30-minute meeting, 5–10 EAN demo, supplier feasibility, support distinctions, package onboarding prices, setup windows and a suggested commercial proposal. No PDF parsing, scraping, custom connectors, or unsupported document translations are offered. Free demo uses explicitly allocated trial AI credits; do not assume a Free plan has AI credits.
|
||||||
|
|
||||||
|
At roughly 2 credits per product-language pass, 1,000 monthly AI products in one language call for around 2,000 credits (actual debit can vary). Business includes 4,000 credits, 4,000 SKU capacity and 8 sources, therefore it is a reasonable candidate **subject to confirming the real SKU count and selected source count**.
|
||||||
|
|
||||||
|
## Public API documentation
|
||||||
|
|
||||||
|
Public `/api/v1/openapi.yaml` contains only API-key endpoints (35 routes), not dashboard-only `/team/*` or `/admin/*` operations. `SessionCookie` and `CSRFHeader` schemes were removed. The public reference no longer directs API clients to internal administration endpoints. The runtime dashboard routes are untouched.
|
||||||
|
|
||||||
|
## Checks and deployment
|
||||||
|
|
||||||
|
Run the production frontend and API/worker builds before deploying, including Go 1.25. Focused Node pricing/GA4 tests and OpenAPI YAML structural checks run without external services. Stripe Checkout with real EUR Price IDs, existing USD subscribers, and VAT must be verified in your actual Stripe test environment before enabling EUR purchase flows in production. No automatic conversion of stored USD subscriptions has been performed.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Popravek Svelte builda in gradivo za sestanek
|
||||||
|
|
||||||
|
## Popravek
|
||||||
|
|
||||||
|
Popravljeni so trije JSON primeri z zavitimi oklepaji v `placeholder` atributih, ki so povzročali Svelte `Expected token }`:
|
||||||
|
|
||||||
|
- `apps/web/src/routes/feeds/+page.svelte` (ustvarjanje vira)
|
||||||
|
- `apps/web/src/routes/feeds/+page.svelte` (urejanje vira)
|
||||||
|
- `apps/web/src/lib/components/feeds/RemoteCatalogImport.svelte`
|
||||||
|
|
||||||
|
## Gradivo za sestanek (slovenščina)
|
||||||
|
|
||||||
|
- `README_SESTANEK_SL.md` (v korenu projekta)
|
||||||
|
- `docs/client/sestanek-dobavitelji-onboarding-sl.md` (podrobna kopija v dokumentaciji)
|
||||||
|
|
||||||
|
## Namestitev
|
||||||
|
|
||||||
|
Prenesite posodobljeno kodo, nato na strežniku izvedite vaš običajen `rb` deployment, ki med drugim zgradi spletno aplikacijo.
|
||||||
|
|
||||||
|
Preverjeno je, da ni več neescapiranih JSON `placeholder` atributov v Svelte datotekah. Celoten produkcijski build ni bil izveden v tem okolju, zato po posodobitvi spremljajte izpis `npm run build --workspace=web`.
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Descrybe v15 — usage and billing changes
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
- Product Management no longer contains the independent JSON URL importer. Configure JSON URLs and mappings under **Feeds**.
|
||||||
|
- `/admin/analytics` reads durable `ai_usage_daily` token totals, plus separately displays operational provider spend and credit use.
|
||||||
|
- `GET /api/admin/ai-costs/export?days=30&company_id=<uuid>` downloads a **provider operating-cost** CSV in historical USD; it is not a customer invoice.
|
||||||
|
- `GET /api/admin/billing/invoices/export?company_id=<uuid>` downloads genuine Stripe invoice references and values in their actual invoice currencies (minor units). Only recent invoices returned by Stripe are listed, up to 100.
|
||||||
|
- `GET /api/billing/usage/export?range=cycle` downloads the signed-in company's usage CSV, not a tax invoice.
|
||||||
|
- `GET /api/billing/invoices` returns genuine Stripe invoices to company owners. Manual invoices and plans without a Stripe customer have no documents here. Links to actual invoice/PDF are supplied by Stripe.
|
||||||
|
- `/admin/processing-costs` GET and PUT support credit prices for a plan or individual company; precedence: company > plan > global. Migration 049 is required.
|
||||||
|
- `ai_model_prices` includes published **GPT-5.4 Mini**, GPT-5 Mini, and GPT-6 Luna standard text token rates seeded only when missing. Migration 050 is required. Prices are in micro-USD; historical costs are never retroactively recalculated.
|
||||||
|
|
||||||
|
## Money and usage accounting
|
||||||
|
|
||||||
|
Three values MUST NOT be added together as "total bill":
|
||||||
|
1. **AI provider cost**: internal OpenAI/provider operating expense, recorded in **USD** at call time (input tokens, cached subset, output tokens, model-specific rate).
|
||||||
|
2. **Platform credits**: in-product consumption units, not euros. Credit wallet is cumulative; the system does not yet retain a daily debit ledger, so 7-day credits are unavailable. Billing cycles separately record aggregate credits per cycle.
|
||||||
|
3. **Invoice amount**: actual amount billed or due, available only from **Stripe** invoices or a separately issued manual invoice. An AI-cost estimate is not a charge to the customer.
|
||||||
|
|
||||||
|
To show EUR for an operational USD cost, an admin supplies a verified USD→EUR exchange rate in analytics. This is an estimate, not an invoice FX rate; per-day historical FX conversion is not implemented. The currency of a Stripe invoice is authoritative. Credit overrides do not edit Stripe subscription prices and only affect future debit amounts.
|
||||||
|
|
||||||
|
### Rate configuration
|
||||||
|
|
||||||
|
Administrator opens `/admin/analytics` > **Processing credit rules**, selects scope (`plan` numeric ID or `company` UUID), feature, and credits. All overrides are ≥1 and ≤1,000,000. A1 company override can differ from the general plan defaults. This does not change the A1 contracted EUR subscription amount, which still needs to be set in Stripe/contract.
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
|
||||||
|
Run migration 049/050 with your normal `npm run migrate`, then deploy API, worker and web. Do not install or invoke local Go commands from customer-facing documentation. Test real Stripe invoices with a non-mock customer account; do not treat mock portal data as a paid invoice.
|
||||||
|
|
||||||
|
### Validation limits
|
||||||
|
|
||||||
|
Changes have been gofmt-checked. Full Go 1.25 build, Svelte production build, database-backed concurrency and Stripe integration tests are not available in this environment. Validate these before production deployment.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# v16 — Public API processing in Product Management
|
||||||
|
|
||||||
|
## What changes
|
||||||
|
|
||||||
|
- `POST /api/v1/products/process` (with `items[]` or `raw_product_ids[]`), `POST /api/v1/process`, and API-key feed sample processing (`POST /api/v1/feeds/{id}/sync-process-sample`) now create jobs with `origin = 'api'`.
|
||||||
|
- Both API routes use the same company-scoped raw/processed product tables as the web dashboard. They do **not** create separate/invisible API-only results.
|
||||||
|
- Once each API item succeeds, the worker persists its generated title, description, attributes, SEO metadata and localized content in `processed_products`. Its status is `completed` so it appears under **Product Management → Processed** without another manual approval step.
|
||||||
|
- A small `API` label distinguishes the processing origin. If the product belongs to an input feed, the original feed remains displayed.
|
||||||
|
- Web dashboard and feed-triggered processing keep their existing **Needs review** workflow.
|
||||||
|
- Processing the same EAN again updates its single existing product record. API-only partial processing (for example SEO metadata) preserves unrelated previously generated content instead of blanking it.
|
||||||
|
- The product detail drawer reads the full saved product and localized content, so API-enriched results can be inspected and edited normally.
|
||||||
|
- The dashboard API is company-scoped: clients cannot view other companies' products.
|
||||||
|
|
||||||
|
## Deploy
|
||||||
|
|
||||||
|
1. Apply database migration `051_api_processed_catalog_visibility.sql` (`npm run migrate`).
|
||||||
|
2. Deploy the updated API, worker and web frontend together (the usual `rb` command also runs migrations).
|
||||||
|
3. Start a public API process job, poll until `COMPLETED`, then open **Product Management → Processed** and refresh; the latest product appears with its generated fields. Use the same EAN to test reprocessing.
|
||||||
|
|
||||||
|
No new API request fields are needed. Existing results already marked `needs_review` are **not** mass-approved retroactively: older processing jobs did not record a reliable origin. They remain available under Needs review, and subsequent API processing makes them appear under Processed. This avoids accidentally accepting content that a company expected to review.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
`go test ./internal/processing -run TestAPIProcessedProductVisibleInCatalog -count=1`
|
||||||
|
|
||||||
|
Run from `apps/api` on a Go 1.25 host with a migrated test PostgreSQL database in `DATABASE_URL`. The integration test exercises company isolation, API/dashboard job origins, completed/review list filters, detail fields, and an SEO-only reprocess.
|
||||||
@@ -1,87 +1,98 @@
|
|||||||
# Descrybe – sestanek z naročnikom: dobavitelji in pilot
|
# JAGER × Descrybe — priprava na predstavitev in ponudbo
|
||||||
|
|
||||||
**Trajanje:** 30 minut · **Cilj:** na dejanskih EAN-ih preveriti uvoz, kakovost podatkov, slovenski AI opis ter izvozne podatke; dogovoriti se za odgovornosti in stroške.
|
**Namen:** v približno 30 minutah pokazati, ali lahko JAGER z obstoječimi funkcijami Descrybe pridobi, uredi in pripravi podatke za približno **1.000 AI-obdelanih izdelkov na mesec**. Predstavitev ni ponudba za razvoj po meri.
|
||||||
|
|
||||||
## 1. Kratek uvod (3 min)
|
## 1. Predlagan potek sestanka (30 minut)
|
||||||
|
|
||||||
»Descrybe je platforma za zbiranje, urejanje in dopolnjevanje podatkov o izdelkih. Iz dobaviteljskih virov uvozimo izdelke, preslikamo polja, kategorije in tehnične lastnosti, po potrebi pripravimo AI naslove, opise in SEO meta podatke ter izvozimo podatke za vašo trgovino. Cilj je, da po prvi nastavitvi lahko večino rednega dela upravljate sami.«
|
| Čas | Tema | Kaj dejansko pokažemo |
|
||||||
|
|---|---|---|
|
||||||
|
| 0–5 min | Njihove potrebe | Seznam EAN, jeziki, število **unikatnih izdelkov** in mesečnih obdelav, želeni izvoz |
|
||||||
|
| 5–15 min | Praktični demo | GROHE: že pripravljeni CSV (izdelki, kategorije, atributi). EMOS: standardni XML, ugnezdene lastnosti. Na 5–10 izbranih EAN pokažemo surove podatke, polja in uvoz |
|
||||||
|
| 15–20 min | AI obdelava | Preverjen primer naslova, HTML opisa in SEO meta v slovenščini; razlika med uvozom in generiranjem |
|
||||||
|
| 20–25 min | Izvoz in omejitve | CSV, XML ali JSON z razpoložljivimi polji in nastavljenimi preslikavami; kaj izvirni vir vsebuje oziroma česa ne |
|
||||||
|
| 25–30 min | Ponudba | Demo krediti, naročnina, enkratni strošek uvajanja, naslednji koraki |
|
||||||
|
|
||||||
### Kaj je že pripravljeno
|
**Uvodni stavek:** »Naš cilj ni, da morate ročno preurejati dobaviteljske datoteke. Pokažimo na vaših EAN-ih, kaj Descrybe prevzame iz strukturiranih virov, kaj uredi in kaj dobite nazaj za svojo trgovino.«
|
||||||
|
|
||||||
- **GROHE:** iz prejetega CSV so bili pripravljeni ločeni uvozi kategorij, atributov in izdelkov. Potreben je še pregled pravilnosti ter preizkus generiranja slovenskih vsebin.
|
## 2. Kaj Descrybe ponuja
|
||||||
- **EMOS:** XML format in ugnezdene lastnosti so bile preizkušene. Na produkcijskem viru je treba potrditi dostopnost, EAN preslikavo in periodično sinhronizacijo.
|
|
||||||
- **Sanotechnik:** dobavitelj nudi JSON; preslikavo njegovih polj in EAN omejitev je treba potrditi na dejanskem dostopnem viru.
|
|
||||||
- **KOOPMAN in TRBOVC:** obseg je treba najprej preveriti, ker podatki niso nujno v enotnem strukturiranem viru.
|
|
||||||
- **Groupe SEB:** ločena ocena po prejemu specifikacije.
|
|
||||||
|
|
||||||
## 2. Praktični pilot (10 min)
|
- Samostojen ali podprt uvoz **strukturiranih CSV, XML in JSON** datotek ali dostopnih URL-jev, preslikava polj in sinhronizacija.
|
||||||
|
- Uvoz kategorij in atributov, ko so podatki na voljo; povezovanje z izdelki v okviru funkcij aplikacije.
|
||||||
|
- AI priprava nazivov, opisov in SEO meta polj v izbranem jeziku **ob ustreznih kreditih** in kontrola rezultata.
|
||||||
|
- Upravljanje dobaviteljskih podatkov, pregled neuspelih uvozov, prilagodljiv izvoz v **CSV/XML/JSON**, kjer izvozna konfiguracija in razpoložljiva polja to omogočajo.
|
||||||
|
- Uporaba podatkov za EU energijske oznake/EPREL, **kjer so ustrezni podatki modela preverljivo na voljo**.
|
||||||
|
|
||||||
1. Naročnik predloži TXT z EAN-i. Za sestanek izberemo **5–10 izdelkov**, med njimi vsaj enega iz GROHE in enega iz EMOS. Pred uvozom preverimo, ali lahko izbor EAN izvajamo z obstoječim filtrom; po potrebi ga vključimo v izvedbeni obseg.
|
**Česa ne obljubimo in ne vključujemo v standardno nastavitev:** branja ali pretvarjanja PDF-katalogov; zbiranja podatkov s spletnih strani (scraping); ročnega prepisovanja artiklov; razvoja novih konektorjev; povezave z nepodprtimi ERP sistemi; pridobivanja manjkajočih fotografij, prevodov varnostnih listin, energijskih razredov ali tehničnih listov; zagotavljanja zakonodajne skladnosti; neomejenih AI obdelav. Pri manjkajočih podatkih polja ostanejo prazna ali jih naročnik dopolni sam.
|
||||||
2. Prikažemo razliko med **surovim uvozom** in **AI obdelavo**: EAN, naziv, znamka, opis, kategorija, tehnične lastnosti, slike, dokumenti.
|
|
||||||
3. Za 1–2 izdelka izberemo slovenski jezik, pregledamo AI naziv, HTML opis in SEO meta podatke. Ustreznost preveri naročnik; prevod se ne ustvari že s samim uvozom dobaviteljeve datoteke.
|
|
||||||
4. Pokažemo **izvoz v CSV, XML ali JSON** glede na preslikavo in dejansko razpoložljive podatke. Pred končno obljubo preverimo konkreten izvozni profil trgovine.
|
|
||||||
5. Zabeležimo manjkajoče podatke in odločitve (npr. energetske nalepke, PDF dokumenti, barve, kategorije).
|
|
||||||
|
|
||||||
**Opomba o preizkusu:** paket Free in prikazani Demo z 0 AI krediti ne omogočata dokazovanja AI generiranja. Za tak preizkus mora imeti testni račun dodeljene AI kredite oziroma ustrezno plačljivo naročnino.
|
## 3. Stanje njihovih dobaviteljev
|
||||||
|
|
||||||
## 3. Kaj vključuje Descrybe in kaj ni zajeto
|
| Dobavitelj | Stanje in naslednji korak |
|
||||||
|
|
||||||
| Zajeto v osnovnem izdelku, v okviru paketa | Izven standardnega priklopa / dodatno po ponudbi |
|
|
||||||
|---|---|
|
|---|---|
|
||||||
| Uvoz dobaviteljskih CSV, XML in JSON virov ter preslikava polj | Razvoj posebnih konektorjev, avtomatizacija neprilagojenih PDF-jev, kompleksno zajemanje spletnih strani |
|
| **GROHE** | Pripravljene CSV datoteke za izdelke, kategorije in atribute. Na sestanku preverimo delujoč uvoz, EAN in slovenski AI rezultat. |
|
||||||
| Uvoz in urejanje kategorij ter atributov, če so podatki na voljo | Ročno dopolnjevanje podatkov, ki jih dobavitelj ne zagotavlja |
|
| **EMOS** | XML in ugnezdene lastnosti so bili preizkušeni. Potrdimo dostop do produkcijskega URL-ja in preslikavo. |
|
||||||
| AI naslovi, opisi, meta podatki in izbrani jeziki ob ustreznem dobroimetju | Neomejeni AI prevodi ali zagotovilo, da AI vsebina nikoli ne potrebuje pregleda |
|
| **Sanotechnik** | Standardni JSON. Preslikamo naziv, EAN/SKU, kategorije, slike in tehnične podatke; potrdimo na njihovem viru. |
|
||||||
| Izvoz glede na podprta polja in nastavljen profil | Integracija z ERP/spletno trgovino, za katero je treba razviti nov namenski modul |
|
| **KOOPMAN** | Samo če dobavitelj omogoča uporaben strukturiran vir; slike, energijski razredi in dokumenti morajo biti dobavljeni oziroma preverljivi. Brez obljube samodejne pridobitve slovenskih listov. |
|
||||||
| Prikaz uvoženih podatkov in razpoložljivih podatkov za energijske oznake | Jamstvo zakonodajne skladnosti, pridobitev manjkajočih izjav in specifikacij od proizvajalcev |
|
| **TRBOVC** | PDF in spletna stran nista del standardne ponudbe. Vključitev samo, če dobavitelj zagotovi ustrezen CSV, XML ali JSON. |
|
||||||
|
| **Groupe SEB** | Ko prejmejo ustrezen strukturiran vir, pregledamo možnost nastavitve v obstoječem uvozniku. |
|
||||||
|
|
||||||
**KOOPMAN lučke:** za izdelke, za katere veljajo pravila energijskega označevanja, so potrebni pravilni energijski razred, elektronska nalepka in podatkovni list, ki morajo biti ustrezno predstavljeni kupcem. Pred priklopom določimo, katere izdelke pravila zajemajo, ali so modeli v EPREL in ali so dokumenti/slovenske informacije razpoložljivi. Ne smemo obljubiti ustvarjanja energijskih nalepk ali razredov iz nič. Končno pravilnost objave potrdi trgovec. Vir: https://energy-efficient-products.ec.europa.eu/product-list/light-sources_en in https://energy-efficient-products.ec.europa.eu/dealers_en
|
**EAN filter:** od naročnika pridobimo seznam točnih EAN-ov. V predstavitvi pokažemo izbrane izdelke in AI obdelavo samo za dogovorjene izdelke. Pred prodajo preverimo, kako obstoječi uvoz oziroma izbor prepreči nepotrebno obdelavo izdelkov zunaj seznama; ne obljubljamo razvoja dodatnega EAN filtrirnega sistema.
|
||||||
|
|
||||||
## 4. Pet načinov vključitve (enkratno, brez DDV)
|
## 4. Naročnine Descrybe — predlagani cenik v EUR
|
||||||
|
|
||||||
| Scenarij | Cena | Vključeno | Tipičen rok |
|
| Paket | EUR/mesec | Največ SKU | Št. virov | AI kreditov/mesec | Podpora na ceniku |
|
||||||
|---|---:|---|---|
|
|---|---:|---:|---:|---:|---|
|
||||||
| **Samostojni začetek** | **0 €** | Registracija, navodila, samostojna preslikava enega vira, samostojen preizkus | Samostojno |
|
| Free | 0 € | 50 | 1 | 0 | Samostojna uporaba |
|
||||||
| **Pomoč pri začetku** | **199 €** | 1 običajen strukturiran vir, osnovna preslikava, preverjanje manjšega vzorca, 1 kratek prikaz | 1–2 delovna dneva |
|
| Starter | 49 € | 100 | 2 | 100 | E-pošta |
|
||||||
| **Katalog iz več virov** | **649 €** | Do 3 običajni strukturirani viri, kategorije, atributi, osnovna pravila, kontrolni vzorec in predaja | 3–5 delovnih dni |
|
| Plus | 199 € | 400 | 3 | 400 | E-pošta |
|
||||||
| **Poslovni zagon** | **1.490 €** | Do 3 standardni viri, razpored sinhronizacije, do 2 jezika, izvoz/API povezava na obstoječe zmožnosti in usposabljanje | 1–2 tedna |
|
| Growth | 299 € | 1.200 | 5 | 1.200 | E-pošta (na ceniku označena »24h«, **ne jamčimo SLA brez pogodbe**) |
|
||||||
| **Integracija po meri** | **od 3.500 €** | ERP/PIM, zahtevni PDF viri, posebne integracije, večje migracije in QA po dogovoru | Po oceni |
|
| **Business** | **499 €** | **4.000** | **8** | **4.000** | Prednostna e-poštna podpora |
|
||||||
|
| Scale | 999 € | 12.000 | 12 | 12.000 | Prednostna podpora in Slack |
|
||||||
|
| Enterprise | Po ponudbi | Po pogodbi | Po pogodbi | Po pogodbi | Pogodbeni SLA |
|
||||||
|
|
||||||
Cene veljajo za dogovorjen obseg dela. Velikost kataloga ni sama po sebi obljuba ročne priprave vseh artiklov. Za dodatne posege predhodno potrdimo ceno (orientacijsko 65–85 €/h). **Naročnina in AI krediti niso vključeni.**
|
**Cene so predlog zneskov v EUR, ne menjalniška pretvorba USD; brez DDV, do potrditve novih EUR Stripe cen.** Letni obračun je ločena možnost (javno prikazan 20 % popust), vendar zneske ponudimo šele po preverjanju obračuna v EUR.
|
||||||
|
|
||||||
## 5. Okvirna cena za posameznega dobavitelja
|
**Zakaj za JAGER Business?** Približno 1.000 AI-obdelanih produktov na mesec × okvirno **2 kredita za en jezik** = približno 2.000 kreditov. Growth vsebuje 1.200 (okvirno 600 obdelav enega jezika), Business 4.000 (okvirno 2.000 obdelav). Dejanska poraba je lahko drugačna pri daljših opisih, ponavljanju, dodatnih jezikih in drugih operacijah. **Število aktivnih SKU in število mesečno obdelanih izdelkov nista isto** — oboje moramo potrditi na sestanku.
|
||||||
|
|
||||||
| Dobavitelj | Ocena priklopa | Pogoj |
|
**Podporne ure v naročninah:** noben javni paket nima določenega fonda svetovalnih ali nastavitvenih ur. Redna tehnična podpora aplikaciji ni isto kot ročno urejanje virov ali usposabljanje. Napis »24h« ne pomeni 24 vključenih ur dela. Enterprise SLA velja samo, če je izrecno pogodbeno dogovorjen.
|
||||||
|---|---:|---|
|
|
||||||
| **GROHE** | **0–99 €** | Če se uporabi že pripravljena CSV preslikava, le končna validacija in kratek prikaz. |
|
|
||||||
| **EMOS** | **149–249 €** | Dostopen XML, EAN, slike, lastnosti, brez razvoja posebnega konektorja. |
|
|
||||||
| **Sanotechnik** | **199–299 €** | Delujoč JSON endpoint in ustrezna preslikava kategorij/slik/polja SKU/EAN. |
|
|
||||||
| **KOOPMAN** | **350–650 €** | Če je dostop do ustreznih produktnih podatkov, slik, modelov ter energetskih dokumentov; dodatno delo lahko ceno spremeni. |
|
|
||||||
| **TRBOVC** | **450–950 €** | Splet + PDF: po pregledu strukture, dovoljene uporabe in možnosti samodejne ekstrakcije; drugače po uri ali novi ponudbi. |
|
|
||||||
| **Groupe SEB** | **Po ogledu vira** | Najprej brezplačna kratka tehnična ocena, nato fiksna ponudba za dogovorjen obseg. |
|
|
||||||
|
|
||||||
**Predlog za to stranko:** najprej **brezplačni 30-minutni prikaz** in omejeni pilot. Nato **649 € za do tri standardne vire** (npr. že pripravljeni GROHE + EMOS + Sanotechnik, če so dostopni in preslikava zadostuje). KOOPMAN ter TRBOVC se ocenita posebej, če vključujeta neurejene dokumente, dodatno preverjanje ali spletno zajemanje. To ni avtomatska zaveza za kompletno obdelavo vseh dobaviteljev.
|
## 5. Enkratna nastavitev in uvajanje (predlog, brez DDV)
|
||||||
|
|
||||||
## 6. Redna naročnina – pomembna omejitev
|
| Paket uvajanja | Cena | Obseg z obstoječimi funkcijami | Vključena skupna pomoč | Predvidena izvedba |
|
||||||
|
|---|---:|---|---|---|
|
||||||
|
| Samostojno | **0 €** | Registracija, vodič, samostojna nastavitev | 0 h | Po lastnem tempu |
|
||||||
|
| Pomoč pri prvem viru | **199 €** | 1 standardni vir, osnovna preslikava, testni izdelki | do 30 min usposabljanja | 1–2 delovna dneva |
|
||||||
|
| Več virov | **649 €** | do 3 strukturirani viri, kategorije/atributi, test in izvoz | do 1 h usposabljanja | 3–5 delovnih dni |
|
||||||
|
| Poslovni zagon | **1.490 €** | do 5 strukturiranih virov, sinhronizacija in izvozni profil, do 2 jezika | do 2 h usposabljanja | 5–10 delovnih dni |
|
||||||
|
| Večji standardni katalog | **2.490 €** | do 8 podprtih strukturiranih virov, več preslikav, QA in predaja | do 3 h usposabljanja | 2–3 tedne |
|
||||||
|
|
||||||
**Po naročnikovem ceniku** so naročnine v USD, enkratna nastavitev pa je tu predlagana v EUR brez DDV.
|
**Vse ure v tabeli so enkratno usposabljanje ob uvajanju, ne mesečna podpora.** Predvideni roki tečejo od prejetja popolnih podatkov in dostopov. Brez PDF uvoza, scrapinga, razvoja po meri ali ročnega popravljanja izdelkov. Naročnina in krediti se zaračunajo ločeno. Dodatno delo se ne začne brez novega dogovora.
|
||||||
|
|
||||||
- **Free:** $0/mesec; 50 SKU; 1 vir; **0 AI kreditov**.
|
**Predlog posebej za JAGER:** BREZPLAČEN kratek demo na 5–10 EAN-ih s testno dodeljenimi AI krediti (npr. 20 kreditov za približno 10 enostavnih obdelav enega jezika). Po potrditvi rezultata paket **649 € enkratno za GROHE, EMOS in Sanotechnik** (če so viri dostopni in delujejo s standardnimi preslikavami), nato **Business 499 €/mesec** za pričakovanih okoli 1.000 mesečnih obdelav. KOOPMAN in TRBOVC nista vključena, dokler ni ustreznega strukturiranega vira. Če naročnik želi pet primernih virov, uporabimo paket Poslovni zagon po 1.490 €; cene ne obljubljamo brez pregleda podatkov.
|
||||||
- **Starter:** $49/mesec; 100 SKU; 2 vira; 100 kreditov.
|
|
||||||
- **Plus:** $199/mesec; 400 SKU; 3 viri; 400 kreditov.
|
|
||||||
- **Growth:** $299/mesec; 1.200 SKU; 5 virov; 1.200 kreditov.
|
|
||||||
- **Business:** $499/mesec; 4.000 SKU; 8 virov; 4.000 kreditov.
|
|
||||||
- **Scale:** $999/mesec; 12.000 SKU; 12 virov; 12.000 kreditov.
|
|
||||||
- **Enterprise:** ponudba po meri; veljajo pogodbeno dogovorjeni pogoji.
|
|
||||||
|
|
||||||
Če ostane vseh **pet virov** (GROHE, EMOS, Sanotechnik, KOOPMAN, TRBOVC), je Growth najnižji od prikazanih paketov z dovolj velikim številom virov **pod pogojem, da je izbranih največ 1.200 SKU**. Z Groupe SEB bi bilo virov šest, zato bi bil med prikazanimi standardnimi paketi potreben najmanj Business (in največ 4.000 SKU). Končni paket določimo šele po prejemu seznama EAN. Letni način obračuna je ločen od mesečnega; pred ponudbo potrdimo aktualen cenik.
|
## 6. Vprašanja naročnika in kratki odgovori
|
||||||
|
|
||||||
## 7. Vprašanja in dogovor ob koncu (5 min)
|
**»Ali lahko sami povežemo dobavitelja?«** Da, če imajo ustrezen CSV, XML ali JSON in uporabljajo obstoječe preslikave; pri prvem viru vam lahko pomagamo s plačljivim uvajanjem.
|
||||||
|
|
||||||
- Koliko **unikatnih EAN-ov** je na seznamu in koliko izdelkov je dejansko v prodaji?
|
**»Zakaj ne dobimo prevoda pri GROHE?«** Uvoz podatkov še ni AI obdelava. Preverimo izbran jezik, kategorijski prompt, AI kredite in rezultate za testni EAN; obdelane izdelke je po potrebi treba ponovno zagnati.
|
||||||
- Kateri dobavitelji morajo v prvi fazi delovati in kako pogosto je potrebna sinhronizacija?
|
|
||||||
- Kateri jeziki so obvezni in ali želi naročnik AI besedila ali samo prenos obstoječih podatkov?
|
|
||||||
- Katera polja mora trgovina prejeti v izvozu (EAN, naziv, opis HTML, specifikacije, slike, meta naslov/opis, oznake)?
|
|
||||||
- Ali so na voljo potrebna dovoljenja za pridobivanje podatkov, dostopi in energetske listine?
|
|
||||||
- Dogovor: priprava pilota na 5–10 EAN-ih, potrditev izvoznega vzorca, nato pisna ponudba in rok za izbrane dobavitelje.
|
|
||||||
|
|
||||||
**Zaključni stavek:** »Predlagamo, da najprej skupaj preizkusimo nekaj vaših izdelkov od uvoza do končnega izvoza. Tako boste videli rezultat in ceno dejanske nastavitve še pred odločitvijo za večji projekt.«
|
**»Ali Demo kaj stane?«** Brezplačen prikaz na manjšem vzorcu lahko izvedemo s posebej dodeljenimi testnimi krediti. To ni plačljiv mesečni paket in ne pomeni 1.000 brezplačnih obdelav.
|
||||||
|
|
||||||
|
**»Ali morate uvoziti vse izdelke dobavitelja?«** Za AI bomo izbrali samo vaše izdelke s seznama EAN. Obseg same sinhronizacije in shranjevanja je treba preveriti glede na razpoložljive filtre in omejitev SKU.
|
||||||
|
|
||||||
|
**»Kaj pa TRBOVC iz PDF-ja?«** Naša standardna rešitev ne pretvarja PDF-jev v produktne podatke. Potrebujemo strukturiran katalog CSV/XML/JSON dobavitelja.
|
||||||
|
|
||||||
|
**»Ali izdelate slovenske energijske listine za KOOPMAN?«** Ne. Če so model in dokumenti na voljo pri dobavitelju/EPREL, jih lahko uporabimo v okviru podprtih polj. Ne ustvarjamo ali potrjujemo neobstoječih listin.
|
||||||
|
|
||||||
|
**»Ali dobimo CSV/XML/JSON za našo trgovino?«** Da, izvozne preslikave omogočajo razpoložljiva polja. Za konkreten format pred dokončno ponudbo potrdimo vzorčni izvoz.
|
||||||
|
|
||||||
|
**»Kaj če imamo več kot 1.000 artiklov v katalogu, a jih obdelamo 1.000 mesečno?«** Paket določata **obe** omejitvi: kapaciteta aktivnih SKU in količina AI kreditov; izberemo paket, ki pokrije oboje.
|
||||||
|
|
||||||
|
**»Kaj če zmanjka kreditov?«** AI obdelave zahtevajo kreditno stanje; možen je nakup dodatnih kreditov ali višji paket v skladu s cenikom. Uvoz in upravljanje podatkov sta ločena od AI obdelav.
|
||||||
|
|
||||||
|
**»Koliko ur podpore imamo mesečno?«** V standardnih paketih ni obljubljenih svetovalnih ur. Obstaja podpora za delovanje aplikacije po razredu paketa, uvodno svetovanje pa je vključeno le v enkratni paket uvajanja.
|
||||||
|
|
||||||
|
## 7. Prodajni zaključek
|
||||||
|
|
||||||
|
> »Najprej bomo na vaših dejanskih EAN-ih pokazali celoten postopek: uvoz podatkov, slovenski naziv in opis, SEO meta ter izvoz. Ko rezultat potrdite, izberemo paket glede na vaše dejansko število artiklov in okoli 1.000 mesečnih obdelav. Začetna nastavitev ima vnaprej določen obseg in ceno. Ni skritih stroškov razvoja po meri.«
|
||||||
|
|
||||||
|
**Dogovoriti se je treba:** (1) število aktivnih EAN, (2) mesečni volumen AI in jezikov, (3) dobavitelje prve faze, (4) obvezen format izvoza, (5) termin za demo s testnimi krediti, (6) potrditev cene uvajanja in naročnine v EUR. Naročnika ne obremenjujemo z internimi tehničnimi postopki.
|
||||||
@@ -68,5 +68,5 @@ All paths below are relative to `/api/v1`, and are checked against the API route
|
|||||||
|
|
||||||
Public catalog and feed list/create routes generally use `data` (and `meta` for paginated lists). Processing jobs under `/process` use a flat job response instead. Do not interchange processed product `id` and `raw_product_id` for job starts. Handle 401 for invalid/revoked keys, 402 for plan/credit gates, 429 with `Retry-After` for throttled operations, and validation errors as documented per operation.
|
Public catalog and feed list/create routes generally use `data` (and `meta` for paginated lists). Processing jobs under `/process` use a flat job response instead. Do not interchange processed product `id` and `raw_product_id` for job starts. Handle 401 for invalid/revoked keys, 402 for plan/credit gates, 429 with `Retry-After` for throttled operations, and validation errors as documented per operation.
|
||||||
|
|
||||||
The dashboard has additional `/api/*` endpoints requiring a signed-in session and CSRF token. Two dashboard-only Team/Admin operations are included in the OpenAPI document for operator reference; **API keys cannot call them**.
|
This reference documents only public `/api/v1` endpoints authorized with company API keys. Internal dashboard and platform administration interfaces are intentionally not published.
|
||||||
|
|
||||||
Reference in new issue
Block a user