Gate and meter email group: enterprise license (self-host) + credits (cloud) (#22390)

Email group (marketing email) was gated only by the
`IS_EMAIL_GROUP_ENABLED` feature flag with no server-side enforcement.
This adds real gating, split by deployment:

- **Self-hosted** (`IS_BILLING_ENABLED=false`): requires a valid
Enterprise plan.
- **Cloud** (billing enabled): metered by credits, mirroring the
existing AI credit system. Priced on AWS SES cost ($0.10/1,000 outbound)
× 3 margin = $0.30/1,000 (300 micro-credits/email). Pre-flight blocks
sends when out of credits; each email is charged after SES accepts it,
in the async send job — matching how AWS bills us (no refund on bounce).

Enforcement is applied at every email group resolver, and denials
surface as proper client errors through a dedicated GraphQL exception
filter.
This commit is contained in:
neo773
2026-07-02 20:44:49 +05:30
committed by GitHub
parent a28887bba6
commit 6f64be5751
18 changed files with 288 additions and 6 deletions
@@ -9,6 +9,7 @@ export enum UsageOperationType {
CODE_EXECUTION = 'CODE_EXECUTION',
WEB_SEARCH = 'WEB_SEARCH',
CALL_RECORDING = 'CALL_RECORDING',
EMAIL_SEND = 'EMAIL_SEND',
}
registerEnumType(UsageOperationType, {
@@ -7,4 +7,5 @@ export enum UsageResourceType {
STORAGE = 'STORAGE',
API = 'API',
LOGIC_FUNCTION = 'LOGIC_FUNCTION',
EMAIL = 'EMAIL',
}