Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package platformsettings
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
|
||||
)
|
||||
|
||||
// Well-known Values map keys for integrations (Agent 6).
|
||||
// Stored in company_settings JSON under the system company (see Service).
|
||||
const (
|
||||
KeyStripeSecretKey = "stripe.secret_key"
|
||||
KeyStripeWebhookSecret = "stripe.webhook_secret"
|
||||
KeyStripeMock = "stripe.mock"
|
||||
KeyStripePriceStarterMo = "stripe.price.starter.monthly"
|
||||
KeyStripePriceStarterYr = "stripe.price.starter.yearly"
|
||||
KeyStripePricePlusMo = "stripe.price.plus.monthly"
|
||||
KeyStripePricePlusYr = "stripe.price.plus.yearly"
|
||||
KeyStripePriceGrowthMo = "stripe.price.growth.monthly"
|
||||
KeyStripePriceGrowthYr = "stripe.price.growth.yearly"
|
||||
KeyStripePriceBizMo = "stripe.price.business.monthly"
|
||||
KeyStripePriceBizYr = "stripe.price.business.yearly"
|
||||
KeyStripePriceScaleMo = "stripe.price.scale.monthly"
|
||||
KeyStripePriceScaleYr = "stripe.price.scale.yearly"
|
||||
// Legacy aliases for common packs (also generated via billing.CreditPackSettingsKey).
|
||||
KeyStripePricePackSmall = "stripe.price.pack.small"
|
||||
KeyStripePricePackMedium = "stripe.price.pack.medium"
|
||||
KeyStripePricePackLarge = "stripe.price.pack.large"
|
||||
KeyStripePricePackXL = "stripe.price.pack.xl"
|
||||
|
||||
KeyEPRELEnabled = "eprel.enabled"
|
||||
KeyEPRELBaseURL = "eprel.base_url"
|
||||
KeyEPRELTimeout = "eprel.timeout"
|
||||
KeyEPRELFicheLanguage = "eprel.fiche_language"
|
||||
KeyEPRELAPIKey = "eprel.api_key"
|
||||
|
||||
KeyFeedPrivateAllowlist = "feeds.private_url_allowlist"
|
||||
|
||||
KeyPineconeAPIKey = "pinecone.api_key"
|
||||
KeyPineconeHost = "pinecone.host"
|
||||
KeyPineconeNamespace = "pinecone.namespace"
|
||||
)
|
||||
|
||||
// SecretValueKeys are Values entries stored as enc:v1: ciphertext.
|
||||
func SecretValueKeys() map[string]struct{} {
|
||||
return map[string]struct{}{
|
||||
KeyStripeSecretKey: {},
|
||||
KeyStripeWebhookSecret: {},
|
||||
KeyEPRELAPIKey: {},
|
||||
ValueKeyResendAPIKey: {},
|
||||
KeyPineconeAPIKey: {},
|
||||
}
|
||||
}
|
||||
|
||||
// AllowedValueKeys is the allowlist for Values bag writes (mass-assignment guard).
|
||||
func AllowedValueKeys() map[string]struct{} {
|
||||
out := map[string]struct{}{
|
||||
KeyStripeSecretKey: {},
|
||||
KeyStripeWebhookSecret: {},
|
||||
KeyStripeMock: {},
|
||||
KeyStripePriceStarterMo: {},
|
||||
KeyStripePriceStarterYr: {},
|
||||
KeyStripePricePlusMo: {},
|
||||
KeyStripePricePlusYr: {},
|
||||
KeyStripePriceGrowthMo: {},
|
||||
KeyStripePriceGrowthYr: {},
|
||||
KeyStripePriceBizMo: {},
|
||||
KeyStripePriceBizYr: {},
|
||||
KeyStripePriceScaleMo: {},
|
||||
KeyStripePriceScaleYr: {},
|
||||
KeyEPRELEnabled: {},
|
||||
KeyEPRELBaseURL: {},
|
||||
KeyEPRELTimeout: {},
|
||||
KeyEPRELFicheLanguage: {},
|
||||
KeyEPRELAPIKey: {},
|
||||
KeyFeedPrivateAllowlist: {},
|
||||
KeyPineconeAPIKey: {},
|
||||
KeyPineconeHost: {},
|
||||
KeyPineconeNamespace: {},
|
||||
ValueKeyResendAPIKey: {},
|
||||
ValueKeyEmailDryRun: {},
|
||||
}
|
||||
for _, pack := range billing.DefaultCreditPacks() {
|
||||
out[billing.CreditPackSettingsKey(pack.ID)] = struct{}{}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func isSecretValueKey(key string) bool {
|
||||
_, ok := SecretValueKeys()[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
func isAllowedValueKey(key string) bool {
|
||||
_, ok := AllowedValueKeys()[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
// EPREL fiche language codes accepted by the admin UI / EC API language query param.
|
||||
var eprelFicheLanguages = map[string]struct{}{
|
||||
"EN": {}, "DE": {}, "FR": {}, "NL": {}, "ES": {}, "IT": {},
|
||||
}
|
||||
|
||||
// NormalizeEPRELFicheLanguage uppercases and allowlists fiche language codes.
|
||||
func NormalizeEPRELFicheLanguage(raw string) (string, error) {
|
||||
code := strings.ToUpper(strings.TrimSpace(raw))
|
||||
if code == "" {
|
||||
return "EN", nil
|
||||
}
|
||||
if _, ok := eprelFicheLanguages[code]; !ok {
|
||||
return "", ClientMsg("unsupported eprel fiche language")
|
||||
}
|
||||
return code, nil
|
||||
}
|
||||
Reference in New Issue
Block a user