Files
member-console/internal/entitlements/models.go
Christian Galo 751bae7768 Use plan ladder for org defaults
Add default_plan_ladder_id with a forward data migration and update
the runtime to resolve the ladder's rank-0 tier at use-time. Regenerate
sqlc, update auto-provisioning, ReapplyDefaultsForPool, operator UI and
tests; add GetTierByLadderRank and pool/provision query helpers. Add a
CSP-safe confirm-action modal and wire operator actions to it. Close
plan-sole-writer safety gaps and serialize IssueGrant with a FOR UPDATE
pool lock to prevent ladder races.
2026-04-27 01:57:17 -05:00

415 lines
17 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package entitlements
import (
"database/sql"
"encoding/json"
"time"
"github.com/google/uuid"
"github.com/sqlc-dev/pqtype"
)
type Account struct {
BillingAccountID string `json:"billing_account_id"`
OrgID string `json:"org_id"`
Name string `json:"name"`
Status string `json:"status"`
Metadata json.RawMessage `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type BillingInvoice struct {
InvoiceID string `json:"invoice_id"`
BillingAccountID string `json:"billing_account_id"`
SubscriptionID uuid.NullUUID `json:"subscription_id"`
Status string `json:"status"`
AmountDue int32 `json:"amount_due"`
AmountPaid int32 `json:"amount_paid"`
Currency string `json:"currency"`
PeriodStart sql.NullTime `json:"period_start"`
PeriodEnd sql.NullTime `json:"period_end"`
DueDate sql.NullTime `json:"due_date"`
PaidAt sql.NullTime `json:"paid_at"`
VoidedAt sql.NullTime `json:"voided_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type BillingInvoiceLineItem struct {
LineItemID string `json:"line_item_id"`
InvoiceID string `json:"invoice_id"`
SubscriptionItemID uuid.NullUUID `json:"subscription_item_id"`
PriceID string `json:"price_id"`
Amount int32 `json:"amount"`
Currency string `json:"currency"`
Description sql.NullString `json:"description"`
Quantity int32 `json:"quantity"`
PeriodStart sql.NullTime `json:"period_start"`
PeriodEnd sql.NullTime `json:"period_end"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type BillingPayment struct {
PaymentID string `json:"payment_id"`
InvoiceID string `json:"invoice_id"`
BillingAccountID string `json:"billing_account_id"`
PaymentMethodID uuid.NullUUID `json:"payment_method_id"`
Amount int32 `json:"amount"`
Currency string `json:"currency"`
Status string `json:"status"`
FailedAt sql.NullTime `json:"failed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type BillingPaymentMethod struct {
PaymentMethodID string `json:"payment_method_id"`
BillingAccountID string `json:"billing_account_id"`
PmType string `json:"pm_type"`
CardBrand sql.NullString `json:"card_brand"`
CardLast4 sql.NullString `json:"card_last4"`
CardExpMonth sql.NullInt32 `json:"card_exp_month"`
CardExpYear sql.NullInt32 `json:"card_exp_year"`
Funding sql.NullString `json:"funding"`
IsDefault bool `json:"is_default"`
DetachedAt sql.NullTime `json:"detached_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type BillingProductKind struct {
ProductID string `json:"product_id"`
ProductKind string `json:"product_kind"`
}
type EntitlementSet struct {
SetID string `json:"set_id"`
Name string `json:"name"`
Description sql.NullString `json:"description"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type EntitlementSetRule struct {
RuleID string `json:"rule_id"`
SetID string `json:"set_id"`
RuleType string `json:"rule_type"`
ResourceKey sql.NullString `json:"resource_key"`
ResourceValue sql.NullInt64 `json:"resource_value"`
ResourcePerUnit sql.NullBool `json:"resource_per_unit"`
StackingPolicy sql.NullString `json:"stacking_policy"`
ResetPeriod sql.NullString `json:"reset_period"`
CreditAmount sql.NullInt32 `json:"credit_amount"`
CreditCurrency sql.NullString `json:"credit_currency"`
Description sql.NullString `json:"description"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Grant struct {
GrantID string `json:"grant_id"`
ProductID uuid.NullUUID `json:"product_id"`
GrantedToBillingAccountID uuid.NullUUID `json:"granted_to_billing_account_id"`
GrantedToOrgID uuid.NullUUID `json:"granted_to_org_id"`
GrantedToPersonID uuid.NullUUID `json:"granted_to_person_id"`
GrantedByPersonID uuid.NullUUID `json:"granted_by_person_id"`
GrantReason string `json:"grant_reason"`
Description sql.NullString `json:"description"`
Quantity int32 `json:"quantity"`
ValidFrom time.Time `json:"valid_from"`
ValidUntil sql.NullTime `json:"valid_until"`
Status string `json:"status"`
RevokedAt sql.NullTime `json:"revoked_at"`
RevokedByPersonID uuid.NullUUID `json:"revoked_by_person_id"`
RevocationReason sql.NullString `json:"revocation_reason"`
Metadata pqtype.NullRawMessage `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
EntitlementSetID uuid.NullUUID `json:"entitlement_set_id"`
ExtendsGrantID uuid.NullUUID `json:"extends_grant_id"`
}
type NumericEntitlement struct {
EntitlementID string `json:"entitlement_id"`
PoolID string `json:"pool_id"`
ResourceKey string `json:"resource_key"`
EntitlementType string `json:"entitlement_type"`
ResourceLimit int64 `json:"resource_limit"`
ResetPeriod sql.NullString `json:"reset_period"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type NumericEntitlementContribution struct {
ContributionID string `json:"contribution_id"`
EntitlementID string `json:"entitlement_id"`
ProvisionID string `json:"provision_id"`
ContributedValue int64 `json:"contributed_value"`
StackingPolicy string `json:"stacking_policy"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type NumericEntitlementUsage struct {
UsageID string `json:"usage_id"`
EntitlementID string `json:"entitlement_id"`
PoolID string `json:"pool_id"`
ResourceKey string `json:"resource_key"`
CurrentUsage int64 `json:"current_usage"`
CurrentPeriodStart sql.NullTime `json:"current_period_start"`
CurrentPeriodEnd sql.NullTime `json:"current_period_end"`
LastResetAt sql.NullTime `json:"last_reset_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type OrgMember struct {
OrgMemberID string `json:"org_member_id"`
OrgID string `json:"org_id"`
PersonID string `json:"person_id"`
RoleID string `json:"role_id"`
Status string `json:"status"`
JoinedAt time.Time `json:"joined_at"`
RemovedAt sql.NullTime `json:"removed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Organization struct {
OrgID string `json:"org_id"`
Name string `json:"name"`
Slug string `json:"slug"`
OrgType string `json:"org_type"`
OwnerPersonID string `json:"owner_person_id"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type OrganizationOrgType struct {
OrgType string `json:"org_type"`
DisplayName string `json:"display_name"`
Description sql.NullString `json:"description"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DefaultPlanLadderID uuid.NullUUID `json:"default_plan_ladder_id"`
}
type Person struct {
PersonID string `json:"person_id"`
UserID string `json:"user_id"`
DisplayName string `json:"display_name"`
PrimaryEmail string `json:"primary_email"`
PrimaryEmailVerified bool `json:"primary_email_verified"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type PlanLadder struct {
PlanLadderID string `json:"plan_ladder_id"`
LadderKey string `json:"ladder_key"`
Name string `json:"name"`
Description sql.NullString `json:"description"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type PlanLadderTier struct {
PlanLadderID string `json:"plan_ladder_id"`
ProductID string `json:"product_id"`
Rank int32 `json:"rank"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type PoolAssignment struct {
AssignmentID string `json:"assignment_id"`
PoolID string `json:"pool_id"`
WorkspaceID string `json:"workspace_id"`
IsPrimary bool `json:"is_primary"`
Status string `json:"status"`
SuspendedAt sql.NullTime `json:"suspended_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type PoolProvision struct {
ProvisionID string `json:"provision_id"`
PoolID string `json:"pool_id"`
BillingAccountID uuid.NullUUID `json:"billing_account_id"`
SubscriptionID uuid.NullUUID `json:"subscription_id"`
PurchaseID uuid.NullUUID `json:"purchase_id"`
GrantID uuid.NullUUID `json:"grant_id"`
Quantity int32 `json:"quantity"`
Status string `json:"status"`
ActivatedAt time.Time `json:"activated_at"`
SuspendedAt sql.NullTime `json:"suspended_at"`
EndedAt sql.NullTime `json:"ended_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
EntitlementSetID string `json:"entitlement_set_id"`
}
type PoolProvisionLadder struct {
ProvisionID string `json:"provision_id"`
PlanLadderID string `json:"plan_ladder_id"`
PoolID string `json:"pool_id"`
Status string `json:"status"`
ActivatedAt time.Time `json:"activated_at"`
EndedAt sql.NullTime `json:"ended_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ProductID string `json:"product_id"`
}
type PoolProvisionTransition struct {
TransitionID string `json:"transition_id"`
PoolID string `json:"pool_id"`
ProvisionID uuid.NullUUID `json:"provision_id"`
PlanLadderID string `json:"plan_ladder_id"`
FromRank sql.NullInt32 `json:"from_rank"`
ToRank sql.NullInt32 `json:"to_rank"`
TransitionType string `json:"transition_type"`
ActorType string `json:"actor_type"`
ActorID uuid.NullUUID `json:"actor_id"`
Reason sql.NullString `json:"reason"`
EffectiveAt time.Time `json:"effective_at"`
CreatedAt time.Time `json:"created_at"`
}
type Price struct {
PriceID string `json:"price_id"`
ProductID string `json:"product_id"`
Currency string `json:"currency"`
UnitAmount int32 `json:"unit_amount"`
RecurringInterval sql.NullString `json:"recurring_interval"`
TrialPeriodDays sql.NullInt32 `json:"trial_period_days"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Product struct {
ProductID string `json:"product_id"`
Name string `json:"name"`
Description sql.NullString `json:"description"`
ProductType sql.NullString `json:"product_type"`
Metadata pqtype.NullRawMessage `json:"metadata"`
IsActive bool `json:"is_active"`
IsPublic bool `json:"is_public"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
EntitlementSetID uuid.NullUUID `json:"entitlement_set_id"`
LifecycleStatus string `json:"lifecycle_status"`
}
type ResourceKey struct {
ResourceKey string `json:"resource_key"`
DisplayName string `json:"display_name"`
Description sql.NullString `json:"description"`
Unit string `json:"unit"`
CreatedAt time.Time `json:"created_at"`
}
type ResourcePool struct {
PoolID string `json:"pool_id"`
OrgID string `json:"org_id"`
Name string `json:"name"`
Slug string `json:"slug"`
PoolType string `json:"pool_type"`
IsAutoManaged bool `json:"is_auto_managed"`
Description sql.NullString `json:"description"`
Status string `json:"status"`
SuspendedAt sql.NullTime `json:"suspended_at"`
ArchivedAt sql.NullTime `json:"archived_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Role struct {
RoleID string `json:"role_id"`
OrgID uuid.NullUUID `json:"org_id"`
RoleName string `json:"role_name"`
DisplayName string `json:"display_name"`
Description sql.NullString `json:"description"`
IsSystem bool `json:"is_system"`
Permissions []string `json:"permissions"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type RoleAssignment struct {
AssignmentID string `json:"assignment_id"`
RoleID string `json:"role_id"`
PersonID string `json:"person_id"`
OrgID string `json:"org_id"`
ScopeType string `json:"scope_type"`
ScopeID string `json:"scope_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Subscription struct {
SubscriptionID string `json:"subscription_id"`
BillingAccountID string `json:"billing_account_id"`
Status string `json:"status"`
CurrentPeriodStart sql.NullTime `json:"current_period_start"`
CurrentPeriodEnd sql.NullTime `json:"current_period_end"`
CancelAtPeriodEnd bool `json:"cancel_at_period_end"`
CanceledAt sql.NullTime `json:"canceled_at"`
EndedAt sql.NullTime `json:"ended_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type SubscriptionChange struct {
ChangeID string `json:"change_id"`
SubscriptionID string `json:"subscription_id"`
PreviousStatus sql.NullString `json:"previous_status"`
NewStatus string `json:"new_status"`
StripeEventID string `json:"stripe_event_id"`
ChangedAt time.Time `json:"changed_at"`
}
type SubscriptionItem struct {
SubscriptionItemID string `json:"subscription_item_id"`
SubscriptionID string `json:"subscription_id"`
ProductID string `json:"product_id"`
PriceID string `json:"price_id"`
Quantity int32 `json:"quantity"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type User struct {
UserID string `json:"user_id"`
OidcSubject string `json:"oidc_subject"`
Status string `json:"status"`
LastLoginAt sql.NullTime `json:"last_login_at"`
LastLoginIp sql.NullString `json:"last_login_ip"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Workspace struct {
WorkspaceID string `json:"workspace_id"`
OrgID string `json:"org_id"`
Name string `json:"name"`
Slug string `json:"slug"`
Description sql.NullString `json:"description"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}