postgres

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrgRoleOwner  = tenancy.OrgRoleOwner
	OrgRoleAdmin  = tenancy.OrgRoleAdmin
	OrgRoleMember = tenancy.OrgRoleMember

	TeamRoleOwner  = tenancy.TeamRoleOwner
	TeamRoleAdmin  = tenancy.TeamRoleAdmin
	TeamRoleMember = tenancy.TeamRoleMember

	InviteStatusPending = tenancy.InviteStatusPending
)

Variables

This section is empty.

Functions

func DecodeCapabilities

func DecodeCapabilities(typ string, raw []byte) snapshot.ProviderCapabilities

func DecodeFallbacks

func DecodeFallbacks(raw []byte) []gatewayconfig.RouteFallback

func DecodeObjectStore

func DecodeObjectStore(raw []byte) *gatewayconfig.ObjectStoreConfig

func DecodeRetry

func DecodeRetry(raw []byte) *gatewayconfig.RetryConfig

func Migrate

func Migrate(ctx context.Context, pool *pgxpool.Pool) error

Migrate applies the schema. Legacy UUID installs are wiped once. Schema version bumps never drop application data.

func ResetDatabase

func ResetDatabase(ctx context.Context, pool *pgxpool.Pool) error

ResetDatabase drops all AFI tables. Intended for local `afi db reset` only.

Types

type A2AAgent

type A2AAgent = gatewayconfig.A2AAgent

A2AAgent is the platform write-model A2A upstream agent.

type A2AAgents

type A2AAgents struct {
	Pool *pgxpool.Pool
}

A2AAgents implements gatewayconfig.A2AAgentRepository.

func NewA2AAgents

func NewA2AAgents(pool *pgxpool.Pool) *A2AAgents

func (*A2AAgents) Delete

func (p *A2AAgents) Delete(ctx context.Context, id string) error

func (*A2AAgents) Get

func (*A2AAgents) Insert

func (p *A2AAgents) Insert(ctx context.Context, item gatewayconfig.A2AAgent) error

func (*A2AAgents) ListByOrg

func (p *A2AAgents) ListByOrg(ctx context.Context, orgID string) ([]gatewayconfig.A2AAgent, error)

func (*A2AAgents) OrgID

func (p *A2AAgents) OrgID(ctx context.Context, id string) (string, error)

func (*A2AAgents) Update

type APIKey

type APIKey = access.APIKey

APIKey is the platform write-model key (canonical in access).

type APIKeys

type APIKeys struct {
	Pool *pgxpool.Pool
}

APIKeys implements access.APIKeyRepository.

func NewAPIKeys

func NewAPIKeys(pool *pgxpool.Pool) *APIKeys

func (*APIKeys) Delete

func (a *APIKeys) Delete(ctx context.Context, keyID string) error

func (*APIKeys) Get

func (a *APIKeys) Get(ctx context.Context, keyID string) (*access.APIKey, error)

func (*APIKeys) Insert

func (a *APIKeys) Insert(ctx context.Context, key access.APIKey, keyHash string) error

func (*APIKeys) ListByOrg

func (a *APIKeys) ListByOrg(ctx context.Context, orgID string) ([]access.APIKey, error)

func (*APIKeys) ListByProject

func (a *APIKeys) ListByProject(ctx context.Context, projectID string) ([]access.APIKey, error)

func (*APIKeys) OrgID

func (a *APIKeys) OrgID(ctx context.Context, keyID string) (string, error)

type AuditEvents

type AuditEvents struct {
	Pool *pgxpool.Pool
}

AuditEvents implements audit.Store with Postgres.

func (*AuditEvents) Insert

func (a *AuditEvents) Insert(ctx context.Context, e audit.Entry) error

Insert writes one audit entry. Empty organization_id is skipped (system-wide events).

func (*AuditEvents) List

func (a *AuditEvents) List(ctx context.Context, orgID string, f audit.Filter) ([]audit.Record, error)

List returns recent audit events for an organization.

type Counters

type Counters struct {
	Pool *pgxpool.Pool
}

Counters implements dataplane.CounterStore for lifetime (total) quota windows.

func (*Counters) Get

func (c *Counters) Get(ctx context.Context, scopeType, scopeID, metric, window string) (int64, error)

func (*Counters) Incr

func (c *Counters) Incr(ctx context.Context, scopeType, scopeID, metric, window string, delta int64) (int64, error)

type Credential

type Credential = credentials.Credential

Credential / Assignment are org-owned upstream secrets (canonical in credentials).

type CredentialAssignment

type CredentialAssignment = credentials.Assignment

type Credentials

type Credentials struct {
	Pool *pgxpool.Pool
}

Credentials implements credentials.Repository.

func NewCredentials

func NewCredentials(pool *pgxpool.Pool) *Credentials

func (*Credentials) AssignmentOrgID

func (r *Credentials) AssignmentOrgID(ctx context.Context, id string) (string, error)

func (*Credentials) Delete

func (r *Credentials) Delete(ctx context.Context, id string) error

func (*Credentials) DeleteAssignment

func (r *Credentials) DeleteAssignment(ctx context.Context, id string) error

func (*Credentials) Get

func (*Credentials) HasAssignments

func (r *Credentials) HasAssignments(ctx context.Context, credentialID string) (bool, error)

func (*Credentials) Insert

func (*Credentials) InsertAssignment

func (r *Credentials) InsertAssignment(ctx context.Context, a credentials.Assignment) error

func (*Credentials) ListAssignmentsByOrg

func (r *Credentials) ListAssignmentsByOrg(ctx context.Context, orgID string) ([]credentials.Assignment, error)

func (*Credentials) ListByOrg

func (r *Credentials) ListByOrg(ctx context.Context, orgID string) ([]credentials.Credential, error)

func (*Credentials) OrgID

func (r *Credentials) OrgID(ctx context.Context, id string) (string, error)

func (*Credentials) UpdateMeta

func (r *Credentials) UpdateMeta(ctx context.Context, id, name, status string) (*credentials.Credential, error)

func (*Credentials) UpdateSecret

func (r *Credentials) UpdateSecret(ctx context.Context, id string, secretRef string, payload []byte, keyVersion int) (*credentials.Credential, error)

func (*Credentials) UpsertAssignment

func (r *Credentials) UpsertAssignment(ctx context.Context, a credentials.Assignment) (*credentials.Assignment, error)

type Environments

type Environments struct {
	Pool *pgxpool.Pool
}

Environments implements tenancy.EnvironmentRepository.

func NewEnvironments

func NewEnvironments(pool *pgxpool.Pool) *Environments

func (*Environments) Delete

func (e *Environments) Delete(ctx context.Context, environmentID string) error

func (*Environments) Get

func (e *Environments) Get(ctx context.Context, environmentID string) (*tenancy.Environment, error)

func (*Environments) Insert

func (e *Environments) Insert(ctx context.Context, item tenancy.Environment) error

func (*Environments) ListByProject

func (e *Environments) ListByProject(ctx context.Context, projectID string) ([]tenancy.Environment, error)

func (*Environments) OrgID

func (e *Environments) OrgID(ctx context.Context, environmentID string) (string, error)

type ExternalIdentities

type ExternalIdentities struct {
	Pool *pgxpool.Pool
}

ExternalIdentities implements identity.ExternalIdentityRepository.

func NewExternalIdentities

func NewExternalIdentities(pool *pgxpool.Pool) *ExternalIdentities

func (*ExternalIdentities) Create

func (*ExternalIdentities) GetByProviderSubject

func (r *ExternalIdentities) GetByProviderSubject(ctx context.Context, provider, subject string) (*identity.ExternalIdentity, error)

type FederationStore added in v0.3.0

type FederationStore struct {
	Pool *pgxpool.Pool
}

FederationStore implements federation.Repository.

func NewFederationStore added in v0.3.0

func NewFederationStore(pool *pgxpool.Pool) *FederationStore

func (*FederationStore) BumpRevision added in v0.3.0

func (s *FederationStore) BumpRevision(ctx context.Context) (int64, error)

func (*FederationStore) CreatePeer added in v0.3.0

func (*FederationStore) GetPeer added in v0.3.0

func (*FederationStore) GetPeerByJoinTokenHash added in v0.3.0

func (s *FederationStore) GetPeerByJoinTokenHash(ctx context.Context, hash string) (*federation.ControlPlanePeer, error)

func (*FederationStore) GetRevision added in v0.3.0

func (s *FederationStore) GetRevision(ctx context.Context) (int64, error)

func (*FederationStore) GetSyncState added in v0.3.0

func (s *FederationStore) GetSyncState(ctx context.Context, regionSlug string) (*federation.SyncState, error)

func (*FederationStore) ListPeers added in v0.3.0

func (*FederationStore) RecordPeerSync added in v0.3.0

func (s *FederationStore) RecordPeerSync(ctx context.Context, peerID string, cursor int64, at time.Time, syncErr string) error

func (*FederationStore) UpdatePeer added in v0.3.0

func (s *FederationStore) UpdatePeer(ctx context.Context, peerID, name, baseURL, status string) (*federation.ControlPlanePeer, error)

func (*FederationStore) UpdatePeerJoinTokenEnc added in v0.3.0

func (s *FederationStore) UpdatePeerJoinTokenEnc(ctx context.Context, peerID string, enc []byte) error

func (*FederationStore) UpdatePeerJoinTokenHash added in v0.3.0

func (s *FederationStore) UpdatePeerJoinTokenHash(ctx context.Context, peerID, hash string) error

func (*FederationStore) UpsertSyncState added in v0.3.0

func (s *FederationStore) UpsertSyncState(ctx context.Context, st federation.SyncState) error

type InviteOutcome

type InviteOutcome = tenancy.InviteOutcome

type InvitePreview

type InvitePreview = tenancy.InvitePreview

type Invites

type Invites struct {
	Pool *pgxpool.Pool
}

Invites implements tenancy.InviteRepository.

func NewInvites

func NewInvites(pool *pgxpool.Pool) *Invites

func (*Invites) Get

func (i *Invites) Get(ctx context.Context, inviteID string) (*tenancy.OrgInvite, error)

func (*Invites) GetByTokenHash

func (i *Invites) GetByTokenHash(ctx context.Context, tokenHash string) (*tenancy.OrgInvite, string, error)

func (*Invites) GetPendingByOrgEmail

func (i *Invites) GetPendingByOrgEmail(ctx context.Context, orgID, email string) (*tenancy.OrgInvite, error)

func (*Invites) Insert

func (i *Invites) Insert(ctx context.Context, inv tenancy.OrgInvite, tokenHash string) error

func (*Invites) ListByOrg

func (i *Invites) ListByOrg(ctx context.Context, orgID string) ([]tenancy.OrgInvite, error)

func (*Invites) MarkAccepted

func (i *Invites) MarkAccepted(ctx context.Context, inviteID string, at time.Time) error

func (*Invites) MarkRevoked

func (i *Invites) MarkRevoked(ctx context.Context, inviteID string) error

func (*Invites) UpdateToken

func (i *Invites) UpdateToken(ctx context.Context, inviteID, tokenHash string, expiresAt time.Time) error

type LocalDevSeed

type LocalDevSeed struct {
	OrgID           string
	TeamID          string
	ProjectID       string
	ProviderID      string
	UserID          string
	RouteID         string
	KeyID           string
	AdminEmail      string
	AdminName       string
	PasswordHash    string
	OpenAIBaseURL   string
	OpenAIAPIKeyEnv string
	DefaultModel    string
	APIKeyHash      string
	APIKeyPrefix    string
	Now             time.Time
}

LocalDevSeed holds values for the standard local-dev dataset.

type MCPBackend

type MCPBackend = gatewayconfig.MCPBackend

MCPBackend is the platform write-model MCP Streamable HTTP upstream.

type MCPBackends

type MCPBackends struct {
	Pool *pgxpool.Pool
}

MCPBackends implements gatewayconfig.MCPBackendRepository.

func NewMCPBackends

func NewMCPBackends(pool *pgxpool.Pool) *MCPBackends

func (*MCPBackends) Delete

func (p *MCPBackends) Delete(ctx context.Context, id string) error

func (*MCPBackends) Get

func (*MCPBackends) Insert

func (*MCPBackends) ListByOrg

func (p *MCPBackends) ListByOrg(ctx context.Context, orgID string) ([]gatewayconfig.MCPBackend, error)

func (*MCPBackends) OrgID

func (p *MCPBackends) OrgID(ctx context.Context, id string) (string, error)

func (*MCPBackends) Update

type ModelPrice

type ModelPrice = usage.ModelPrice

type OrgInvite

type OrgInvite = tenancy.OrgInvite

type OrgMember

type OrgMember = tenancy.OrgMember

type Organization

type Organization = tenancy.Organization

type Organizations

type Organizations struct {
	Pool *pgxpool.Pool
}

Organizations implements tenancy.OrganizationRepository.

func NewOrganizations

func NewOrganizations(pool *pgxpool.Pool) *Organizations

func (*Organizations) AddMember

func (o *Organizations) AddMember(ctx context.Context, orgID, userID, role string) error

func (*Organizations) ApplyRoleChange

func (o *Organizations) ApplyRoleChange(ctx context.Context, orgID, actorUserID, targetUserID, newRole string, demoteActor bool) error

func (*Organizations) Count

func (o *Organizations) Count(ctx context.Context) (int64, error)

func (*Organizations) CountOwners

func (o *Organizations) CountOwners(ctx context.Context, orgID string) (int, error)

func (*Organizations) CreateWithOwner

func (o *Organizations) CreateWithOwner(ctx context.Context, org tenancy.Organization, ownerUserID string) error

func (*Organizations) Get

func (o *Organizations) Get(ctx context.Context, orgID string) (*tenancy.Organization, error)

func (*Organizations) GetDefaultRetry

func (o *Organizations) GetDefaultRetry(ctx context.Context, orgID string) (*gatewayconfig.RetryConfig, error)

func (*Organizations) GetMember

func (o *Organizations) GetMember(ctx context.Context, orgID, userID string) (*tenancy.OrgMember, error)

func (*Organizations) GetMemberRole

func (o *Organizations) GetMemberRole(ctx context.Context, userID, orgID string) (string, error)

func (*Organizations) GetObjectStore

func (o *Organizations) GetObjectStore(ctx context.Context, orgID string) (*gatewayconfig.ObjectStoreConfig, error)

func (*Organizations) ListForUser

func (o *Organizations) ListForUser(ctx context.Context, userID string) ([]tenancy.Organization, error)

func (*Organizations) ListIDs added in v0.3.0

func (o *Organizations) ListIDs(ctx context.Context) ([]string, error)

func (*Organizations) ListMembers

func (o *Organizations) ListMembers(ctx context.Context, orgID string) ([]tenancy.OrgMember, error)

func (*Organizations) SetDefaultRetry

func (o *Organizations) SetDefaultRetry(ctx context.Context, orgID string, retry *gatewayconfig.RetryConfig) error

func (*Organizations) SetMailProvider

func (o *Organizations) SetMailProvider(ctx context.Context, orgID, provider string) error

func (*Organizations) SetObjectStore

func (o *Organizations) SetObjectStore(ctx context.Context, orgID string, cfg *gatewayconfig.ObjectStoreConfig) error

type PasswordResets

type PasswordResets struct {
	Pool *pgxpool.Pool
}

PasswordResets implements identity.PasswordResetRepository.

func NewPasswordResets

func NewPasswordResets(pool *pgxpool.Pool) *PasswordResets

func (*PasswordResets) Consume

func (r *PasswordResets) Consume(ctx context.Context, id string, usedAt time.Time) error

func (*PasswordResets) Create

func (*PasswordResets) DeleteUnusedForUser

func (r *PasswordResets) DeleteUnusedForUser(ctx context.Context, userID string) error

func (*PasswordResets) GetByTokenHash

func (r *PasswordResets) GetByTokenHash(ctx context.Context, hash string) (*identity.PasswordResetToken, error)

type PlatformEventOutbox

type PlatformEventOutbox struct {
	Pool *pgxpool.Pool
}

PlatformEventOutbox writes and drains the platform_event_outbox table.

func NewPlatformEventOutbox

func NewPlatformEventOutbox(pool *pgxpool.Pool) *PlatformEventOutbox

func (*PlatformEventOutbox) ClaimBatch

func (o *PlatformEventOutbox) ClaimBatch(ctx context.Context, limit int) ([]workers.OutboxRow, error)

func (*PlatformEventOutbox) Enqueue

func (o *PlatformEventOutbox) Enqueue(ctx context.Context, payload []byte) error

func (*PlatformEventOutbox) MarkProcessed

func (o *PlatformEventOutbox) MarkProcessed(ctx context.Context, id int64) error

type Policies

type Policies struct {
	Pool *pgxpool.Pool
}

Policies implements gatewayconfig.PolicyRepository.

func NewPolicies

func NewPolicies(pool *pgxpool.Pool) *Policies

func (*Policies) Delete

func (p *Policies) Delete(ctx context.Context, policyID string) error

func (*Policies) Get

func (p *Policies) Get(ctx context.Context, policyID string) (*gatewayconfig.RequestPolicy, error)

func (*Policies) Insert

func (*Policies) ListByOrg

func (p *Policies) ListByOrg(ctx context.Context, orgID string) ([]gatewayconfig.RequestPolicy, error)

func (*Policies) OrgID

func (p *Policies) OrgID(ctx context.Context, policyID string) (string, error)

func (*Policies) Update

func (*Policies) UpdatePriorities

func (p *Policies) UpdatePriorities(ctx context.Context, orgID string, items []gatewayconfig.PolicyPriorityUpdate) error

type PriceLookup

type PriceLookup struct {
	Pool *pgxpool.Pool
}

PriceLookup reads model_prices for cost computation.

func (*PriceLookup) LookupModelPrice

func (p *PriceLookup) LookupModelPrice(ctx context.Context, providerType, model string) (float64, float64, bool, error)

type Project

type Project = tenancy.Project

type Projects

type Projects struct {
	Pool *pgxpool.Pool
}

Projects implements tenancy.ProjectRepository.

func NewProjects

func NewProjects(pool *pgxpool.Pool) *Projects

func (*Projects) Insert

func (p *Projects) Insert(ctx context.Context, item tenancy.Project) error

func (*Projects) ListByOrg

func (p *Projects) ListByOrg(ctx context.Context, orgID string) ([]tenancy.Project, error)

func (*Projects) ListByOrgForUser

func (p *Projects) ListByOrgForUser(ctx context.Context, orgID, userID string) ([]tenancy.Project, error)

func (*Projects) OrgID

func (p *Projects) OrgID(ctx context.Context, projectID string) (string, error)

type Provider

type Provider = gatewayconfig.Provider

Provider / Route are platform write-model config (canonical in gatewayconfig).

type ProviderHealth

type ProviderHealth = usage.ProviderHealth

type Providers

type Providers struct {
	Pool *pgxpool.Pool
}

Providers implements gatewayconfig.ProviderRepository.

func NewProviders

func NewProviders(pool *pgxpool.Pool) *Providers

func (*Providers) Delete

func (p *Providers) Delete(ctx context.Context, providerID string) error

func (*Providers) Insert

func (p *Providers) Insert(ctx context.Context, item gatewayconfig.Provider) error

func (*Providers) ListByOrg

func (p *Providers) ListByOrg(ctx context.Context, orgID string) ([]gatewayconfig.Provider, error)

func (*Providers) OrgID

func (p *Providers) OrgID(ctx context.Context, providerID string) (string, error)

func (*Providers) Update

func (p *Providers) Update(ctx context.Context, providerID, name, baseURL, apiKeyEnv string, config *json.RawMessage) (*gatewayconfig.Provider, error)

type Quota

type Quota = gatewayconfig.Quota

Quota is the platform write-model quota (canonical type in gatewayconfig).

type Quotas

type Quotas struct {
	Pool *pgxpool.Pool
}

Quotas implements gatewayconfig.QuotaRepository.

func NewQuotas

func NewQuotas(pool *pgxpool.Pool) *Quotas

func (*Quotas) Delete

func (q *Quotas) Delete(ctx context.Context, quotaID string) error

func (*Quotas) Insert

func (q *Quotas) Insert(ctx context.Context, item gatewayconfig.Quota) error

func (*Quotas) ListByOrg

func (q *Quotas) ListByOrg(ctx context.Context, orgID string) ([]gatewayconfig.Quota, error)

func (*Quotas) OrgID

func (q *Quotas) OrgID(ctx context.Context, quotaID string) (string, error)

func (*Quotas) UpdateLimit

func (q *Quotas) UpdateLimit(ctx context.Context, quotaID string, limitValue int64) (*gatewayconfig.Quota, error)

type RegionalApplyTarget added in v0.3.0

type RegionalApplyTarget struct {
	Store     *Store
	SnapStore snapshot.Store
}

RegionalApplyTarget applies federation exports onto local Phase 2 tables + snapshot store.

func (*RegionalApplyTarget) EnsureRegion added in v0.3.0

func (t *RegionalApplyTarget) EnsureRegion(ctx context.Context, id, slug, name string) error

func (*RegionalApplyTarget) PutSnapshot added in v0.3.0

func (t *RegionalApplyTarget) PutSnapshot(ctx context.Context, snap *snapshot.Snapshot) (int64, error)

func (*RegionalApplyTarget) ReplaceMemberships added in v0.3.0

func (t *RegionalApplyTarget) ReplaceMemberships(ctx context.Context, regionID string, mems []regions.OrgRegionMembership) error

func (*RegionalApplyTarget) ReplaceOverlays added in v0.3.0

func (t *RegionalApplyTarget) ReplaceOverlays(ctx context.Context, regionID string, overlays []regions.RegionConfigOverlay) error

type RegionsStore added in v0.3.0

type RegionsStore struct {
	Pool *pgxpool.Pool
}

RegionsStore implements regions.Repository.

func NewRegionsStore added in v0.3.0

func NewRegionsStore(pool *pgxpool.Pool) *RegionsStore

func (*RegionsStore) CountDeployments added in v0.3.0

func (s *RegionsStore) CountDeployments(ctx context.Context, regionID string) (int, error)

func (*RegionsStore) CreateRegion added in v0.3.0

func (s *RegionsStore) CreateRegion(ctx context.Context, r regions.Region) error

func (*RegionsStore) DeleteMembership added in v0.3.0

func (s *RegionsStore) DeleteMembership(ctx context.Context, regionID, orgID string) error

func (*RegionsStore) DeleteOverlay added in v0.3.0

func (s *RegionsStore) DeleteOverlay(ctx context.Context, regionID, orgID string) error

func (*RegionsStore) GetDeployment added in v0.3.0

func (s *RegionsStore) GetDeployment(ctx context.Context, deploymentID string) (*regions.GatewayDeployment, error)

func (*RegionsStore) GetDeploymentByJoinTokenHash added in v0.3.0

func (s *RegionsStore) GetDeploymentByJoinTokenHash(ctx context.Context, tokenHash string) (*regions.GatewayDeployment, error)

func (*RegionsStore) GetMembership added in v0.3.0

func (s *RegionsStore) GetMembership(ctx context.Context, regionID, orgID string) (*regions.OrgRegionMembership, error)

func (*RegionsStore) GetOverlay added in v0.3.0

func (s *RegionsStore) GetOverlay(ctx context.Context, regionID, orgID string) (*regions.RegionConfigOverlay, error)

func (*RegionsStore) GetRegion added in v0.3.0

func (s *RegionsStore) GetRegion(ctx context.Context, regionID string) (*regions.Region, error)

func (*RegionsStore) GetRegionBySlug added in v0.3.0

func (s *RegionsStore) GetRegionBySlug(ctx context.Context, slug string) (*regions.Region, error)

func (*RegionsStore) InsertDeployment added in v0.3.0

func (s *RegionsStore) InsertDeployment(ctx context.Context, d regions.GatewayDeployment) error

func (*RegionsStore) ListDeploymentsByRegion added in v0.3.0

func (s *RegionsStore) ListDeploymentsByRegion(ctx context.Context, regionID string) ([]regions.GatewayDeployment, error)

func (*RegionsStore) ListMembershipsByOrg added in v0.3.0

func (s *RegionsStore) ListMembershipsByOrg(ctx context.Context, orgID string) ([]regions.OrgRegionMembership, error)

func (*RegionsStore) ListMembershipsByRegion added in v0.3.0

func (s *RegionsStore) ListMembershipsByRegion(ctx context.Context, regionID string) ([]regions.OrgRegionMembership, error)

func (*RegionsStore) ListOverlaysByRegion added in v0.3.0

func (s *RegionsStore) ListOverlaysByRegion(ctx context.Context, regionID string) ([]regions.RegionConfigOverlay, error)

func (*RegionsStore) ListRegions added in v0.3.0

func (s *RegionsStore) ListRegions(ctx context.Context) ([]regions.Region, error)

func (*RegionsStore) RecordHeartbeat added in v0.3.0

func (s *RegionsStore) RecordHeartbeat(ctx context.Context, deploymentID string, snapVersion int64, build string, at time.Time) error

func (*RegionsStore) UpdateDeploymentStatus added in v0.3.0

func (s *RegionsStore) UpdateDeploymentStatus(ctx context.Context, deploymentID, status string) error

func (*RegionsStore) UpdateJoinTokenHash added in v0.3.0

func (s *RegionsStore) UpdateJoinTokenHash(ctx context.Context, deploymentID, joinTokenHash string) error

func (*RegionsStore) UpdateRegion added in v0.3.0

func (s *RegionsStore) UpdateRegion(ctx context.Context, regionID, name, status string) (*regions.Region, error)

func (*RegionsStore) UpsertMembership added in v0.3.0

func (s *RegionsStore) UpsertMembership(ctx context.Context, m regions.OrgRegionMembership) error

func (*RegionsStore) UpsertOverlay added in v0.3.0

func (s *RegionsStore) UpsertOverlay(ctx context.Context, o regions.RegionConfigOverlay) error

type RequestPolicy

type RequestPolicy = gatewayconfig.RequestPolicy

RequestPolicy is the platform write-model CEL policy (canonical in gatewayconfig).

type RetryConfig

type RetryConfig = gatewayconfig.RetryConfig

type Route

type Route = gatewayconfig.Route

type RouteFallback

type RouteFallback = gatewayconfig.RouteFallback

type Routes

type Routes struct {
	Pool *pgxpool.Pool
}

Routes implements gatewayconfig.RouteRepository.

func NewRoutes

func NewRoutes(pool *pgxpool.Pool) *Routes

func (*Routes) Delete

func (r *Routes) Delete(ctx context.Context, routeID string) error

func (*Routes) Insert

func (r *Routes) Insert(ctx context.Context, item gatewayconfig.Route) error

func (*Routes) ListByOrg

func (r *Routes) ListByOrg(ctx context.Context, orgID string) ([]gatewayconfig.Route, error)

func (*Routes) OrgID

func (r *Routes) OrgID(ctx context.Context, routeID string) (string, error)

func (*Routes) Update

func (r *Routes) Update(ctx context.Context, routeID, model, providerID, targetModel string, fallbacks []gatewayconfig.RouteFallback, retry *gatewayconfig.RetryConfig, strategy string, weight int) (*gatewayconfig.Route, error)

type SeedWriter

type SeedWriter struct {
	Pool *pgxpool.Pool
}

SeedWriter persists local-dev bootstrap data.

func NewSeedWriter

func NewSeedWriter(pool *pgxpool.Pool) *SeedWriter

func (*SeedWriter) EnsureAudioRoutes

func (w *SeedWriter) EnsureAudioRoutes(ctx context.Context, orgID, providerID string, now time.Time) (changed bool, err error)

EnsureAudioRoutes upserts tts-1 / whisper-1 routes. changed is true when a route was newly created.

func (*SeedWriter) EnsureElevenLabs

func (w *SeedWriter) EnsureElevenLabs(ctx context.Context, orgID string, now time.Time) error

EnsureElevenLabs upserts the ElevenLabs provider and curated TTS/STT routes.

func (*SeedWriter) OrgExists

func (w *SeedWriter) OrgExists(ctx context.Context, orgID string) (bool, error)

func (*SeedWriter) ProviderExists

func (w *SeedWriter) ProviderExists(ctx context.Context, providerID string) (bool, error)

func (*SeedWriter) SeedLocalDev

func (w *SeedWriter) SeedLocalDev(ctx context.Context, s LocalDevSeed) error

SeedLocalDev upserts the standard local-dev dataset in a transaction.

func (*SeedWriter) UpsertEchoExtension

func (w *SeedWriter) UpsertEchoExtension(ctx context.Context, orgID string, now time.Time) error

UpsertEchoExtension upserts the echo provider + echo-demo route for an org.

type Seeder

type Seeder struct {
	// contains filtered or unexported fields
}

func NewSeeder

func NewSeeder(pool *pgxpool.Pool, store *Store, snapStore snapshot.Store, cfg *kernel.Config) *Seeder

func (*Seeder) EnsureEchoExtension

func (s *Seeder) EnsureEchoExtension(ctx context.Context) error

EnsureEchoExtension upserts prov_echo + echo-demo route for org_local and republishes.

func (*Seeder) EnsureElevenLabs

func (s *Seeder) EnsureElevenLabs(ctx context.Context) error

EnsureElevenLabs upserts prov_elevenlabs + curated TTS/STT routes for org_local.

func (*Seeder) EnsureLocalAudioRoutes

func (s *Seeder) EnsureLocalAudioRoutes(ctx context.Context) error

EnsureLocalAudioRoutes upserts tts-1 / whisper-1 → prov_openai for org_local and republishes.

func (*Seeder) PublishRegionSnapshots added in v0.3.0

func (s *Seeder) PublishRegionSnapshots(ctx context.Context, regionIDs ...string) error

PublishRegionSnapshots puts the global snapshot and only the listed regions' blobs. When regionIDs is empty, all active/draining regions are published (same as PublishSnapshot).

func (*Seeder) PublishSnapshot

func (s *Seeder) PublishSnapshot(ctx context.Context) error

func (*Seeder) Seed

func (s *Seeder) Seed(ctx context.Context) error

Seed always inserts (or upserts) the standard local-dev dataset and publishes a snapshot.

func (*Seeder) SeedIfEmpty

func (s *Seeder) SeedIfEmpty(ctx context.Context) error

SeedIfEmpty inserts local-dev data when the database has no organizations. When the DB already has orgs, it still ensures local audio + echo extension routes (idempotent).

func (*Seeder) SetRegionMirror added in v0.3.0

func (s *Seeder) SetRegionMirror(mirror *objectstore.SnapshotStore)

SetRegionMirror enables per-region object-store publish under snapshots/{slug}/.

type SigningKeys added in v0.3.0

type SigningKeys struct {
	Pool *pgxpool.Pool
}

func NewSigningKeys added in v0.3.0

func NewSigningKeys(pool *pgxpool.Pool) *SigningKeys

func (*SigningKeys) Delete added in v0.3.0

func (r *SigningKeys) Delete(ctx context.Context, id string) error

func (*SigningKeys) Get added in v0.3.0

func (r *SigningKeys) Get(ctx context.Context, id string) (*access.SigningKey, error)

func (*SigningKeys) Insert added in v0.3.0

func (r *SigningKeys) Insert(ctx context.Context, k access.SigningKey) error

func (*SigningKeys) ListByOrg added in v0.3.0

func (r *SigningKeys) ListByOrg(ctx context.Context, orgID string) ([]access.SigningKey, error)

func (*SigningKeys) OrgID added in v0.3.0

func (r *SigningKeys) OrgID(ctx context.Context, id string) (string, error)

func (*SigningKeys) UpdateMeta added in v0.3.0

func (r *SigningKeys) UpdateMeta(ctx context.Context, id, name, status string) (*access.SigningKey, error)

func (*SigningKeys) UpdatePublicKey added in v0.3.0

func (r *SigningKeys) UpdatePublicKey(ctx context.Context, id, publicKeyPEM string) (*access.SigningKey, error)

type SnapshotSourceLoader

type SnapshotSourceLoader struct {
	Pool *pgxpool.Pool
}

SnapshotSourceLoader loads compile inputs from platform tables.

func NewSnapshotSourceLoader

func NewSnapshotSourceLoader(pool *pgxpool.Pool) *SnapshotSourceLoader

func (*SnapshotSourceLoader) Load

type SnapshotStore

type SnapshotStore struct {
	Pool *pgxpool.Pool
}

SnapshotStore persists compiled gateway snapshots in Postgres.

func NewSnapshotStore

func NewSnapshotStore(pool *pgxpool.Pool) *SnapshotStore

func (*SnapshotStore) Latest

func (s *SnapshotStore) Latest(ctx context.Context) (*snapshot.Snapshot, error)

func (*SnapshotStore) Put

func (s *SnapshotStore) Put(ctx context.Context, snap *snapshot.Snapshot) (int64, error)

func (*SnapshotStore) Watch

func (s *SnapshotStore) Watch(ctx context.Context, pollInterval time.Duration, onUpdate func(*snapshot.Snapshot)) error

Watch calls onUpdate whenever a newer snapshot appears. Polls at pollInterval and also wakes on Postgres LISTEN/NOTIFY.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

func (*Store) APIKeyBelongsToOrg

func (s *Store) APIKeyBelongsToOrg(ctx context.Context, keyID, orgID string) error

func (*Store) AcceptOrgInvite

func (s *Store) AcceptOrgInvite(ctx context.Context, rawToken, name, passwordHash string) (*OrgMember, *User, error)

func (*Store) AddOrgMemberByEmail

func (s *Store) AddOrgMemberByEmail(ctx context.Context, orgID, email string) (*OrgMember, error)

func (*Store) AddTeamMember

func (s *Store) AddTeamMember(ctx context.Context, teamID, userID string) (*TeamMember, error)

func (*Store) AssignCredential

func (s *Store) AssignCredential(ctx context.Context, credentialID, scopeType, scopeID, createdBy string) (*CredentialAssignment, error)

func (*Store) AuthenticateDeploymentJoinToken added in v0.3.0

func (s *Store) AuthenticateDeploymentJoinToken(ctx context.Context, rawToken string) (*regions.GatewayDeployment, error)

func (*Store) AuthenticateFederationPeerToken added in v0.3.0

func (s *Store) AuthenticateFederationPeerToken(ctx context.Context, rawToken string) (*federation.ControlPlanePeer, error)

func (*Store) BindAllOrgsToRegion added in v0.3.0

func (s *Store) BindAllOrgsToRegion(ctx context.Context, regionID string) (int, error)

func (*Store) BindOrgToRegion added in v0.3.0

func (s *Store) BindOrgToRegion(ctx context.Context, regionID, orgID, status string) (*regions.OrgRegionMembership, error)

func (*Store) BumpFederationRevision added in v0.3.0

func (s *Store) BumpFederationRevision(ctx context.Context) (int64, error)

func (*Store) CanAccessTeam

func (s *Store) CanAccessTeam(ctx context.Context, teamID, userID string) (bool, error)

func (*Store) CanChangeTeamRoles

func (s *Store) CanChangeTeamRoles(ctx context.Context, teamID, userID string) (bool, error)

func (*Store) CanManageTeam

func (s *Store) CanManageTeam(ctx context.Context, teamID, userID string) (bool, error)

func (*Store) CountOrgs

func (s *Store) CountOrgs(ctx context.Context) (int64, error)

func (*Store) CreateA2AAgent

func (s *Store) CreateA2AAgent(ctx context.Context, orgID, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme string, cardCache []byte, enabled bool) (*A2AAgent, error)

func (*Store) CreateAPIKey

func (s *Store) CreateAPIKey(ctx context.Context, orgID, kind, ownerUserID, projectID, environmentID, name, rawKey string) (*APIKey, error)

CreateAPIKey inserts a key. kind must be personal or service_account. Personal: ownerUserID required, projectID must be empty. Service account: ownerUserID empty, projectID optional (empty = org-wide).

func (*Store) CreateCredential

func (s *Store) CreateCredential(ctx context.Context, orgID, name, providerType, storageKind, secretRef, secretValue string) (*Credential, error)

func (*Store) CreateEnvironment

func (s *Store) CreateEnvironment(ctx context.Context, orgID, projectID, name, slug string) (*tenancy.Environment, error)

func (*Store) CreateMCPBackend

func (s *Store) CreateMCPBackend(ctx context.Context, orgID, alias, name, baseURL, apiKeyEnv string, methodAllowlist []byte, enabled bool) (*MCPBackend, error)

func (*Store) CreateOrganization

func (s *Store) CreateOrganization(ctx context.Context, name, creatorUserID string) (*Organization, error)

func (*Store) CreatePolicy

func (s *Store) CreatePolicy(ctx context.Context, orgID, name, expression string, actions []gatewayconfig.PolicyAction, enabled bool, priority int) (*RequestPolicy, error)

func (*Store) CreateProject

func (s *Store) CreateProject(ctx context.Context, orgID, teamID, name string) (*Project, error)

func (*Store) CreateProvider

func (s *Store) CreateProvider(ctx context.Context, orgID, name, typ, baseURL, apiKeyEnv string, caps snapshot.ProviderCapabilities, config json.RawMessage) (*Provider, error)

func (*Store) CreateQuota

func (s *Store) CreateQuota(ctx context.Context, orgID, scopeType, scopeID, metric string, limitValue int64, window string) (*Quota, error)

func (*Store) CreateRegion added in v0.3.0

func (s *Store) CreateRegion(ctx context.Context, slug, name string) (*regions.Region, error)

func (*Store) CreateRoute

func (s *Store) CreateRoute(ctx context.Context, orgID, model, providerID, targetModel string, fallbacks []RouteFallback, retry *RetryConfig, strategy string, weight int) (*Route, error)

func (*Store) CreateSigningKey added in v0.3.0

func (s *Store) CreateSigningKey(ctx context.Context, orgID, keyID, projectID, environmentID, name, algorithm, publicKeyPEM string) (*access.SigningKey, error)

func (*Store) CreateTeam

func (s *Store) CreateTeam(ctx context.Context, orgID, name, creatorUserID string) (*Team, error)

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, id, email, name, passwordHash string) (*User, error)

func (*Store) CreateWasmHook

func (s *Store) CreateWasmHook(ctx context.Context, orgID, name, phase, moduleURI, digest string, enabled bool, priority int, config []byte) (*WasmHook, error)

func (*Store) DeleteA2AAgent

func (s *Store) DeleteA2AAgent(ctx context.Context, id string) error

func (*Store) DeleteAPIKey

func (s *Store) DeleteAPIKey(ctx context.Context, keyID string) error

func (*Store) DeleteCredential

func (s *Store) DeleteCredential(ctx context.Context, credentialID string) error

func (*Store) DeleteCredentialAssignment

func (s *Store) DeleteCredentialAssignment(ctx context.Context, assignmentID string) error

func (*Store) DeleteEnvironment

func (s *Store) DeleteEnvironment(ctx context.Context, environmentID string) error

func (*Store) DeleteMCPBackend

func (s *Store) DeleteMCPBackend(ctx context.Context, id string) error

func (*Store) DeletePolicy

func (s *Store) DeletePolicy(ctx context.Context, policyID string) error

func (*Store) DeleteProvider

func (s *Store) DeleteProvider(ctx context.Context, providerID string) error

func (*Store) DeleteQuota

func (s *Store) DeleteQuota(ctx context.Context, quotaID string) error

func (*Store) DeleteRegionOverlay added in v0.3.0

func (s *Store) DeleteRegionOverlay(ctx context.Context, regionID, orgID string) error

func (*Store) DeleteRoute

func (s *Store) DeleteRoute(ctx context.Context, routeID string) error

func (*Store) DeleteSigningKey added in v0.3.0

func (s *Store) DeleteSigningKey(ctx context.Context, id string) error

func (*Store) DeleteWasmHook

func (s *Store) DeleteWasmHook(ctx context.Context, id string) error

func (*Store) EnqueueUsage

func (s *Store) EnqueueUsage(ctx context.Context, payload []byte) error

func (*Store) EnvironmentBelongsToProject

func (s *Store) EnvironmentBelongsToProject(ctx context.Context, environmentID, projectID, orgID string) error

func (*Store) ExportFederationRegion added in v0.3.0

func (s *Store) ExportFederationRegion(ctx context.Context, slug string, since int64, objectPrefix string) (*federation.RegionExport, error)

func (*Store) FederationRepo added in v0.3.0

func (s *Store) FederationRepo() *FederationStore

FederationRepo exposes the federation repository for the regional puller.

func (*Store) FindByEmail

func (s *Store) FindByEmail(ctx context.Context, email string) (userID, name, userEmail string, err error)

func (*Store) GetA2AAgentOrgID

func (s *Store) GetA2AAgentOrgID(ctx context.Context, id string) (string, error)

func (*Store) GetAPIKey

func (s *Store) GetAPIKey(ctx context.Context, keyID string) (*APIKey, error)

func (*Store) GetAPIKeyOrgID

func (s *Store) GetAPIKeyOrgID(ctx context.Context, keyID string) (string, error)

func (*Store) GetCounter

func (s *Store) GetCounter(ctx context.Context, scopeType, scopeID, metric, window string) (int64, error)

GetCounter / IncrCounter / EnqueueUsage remain for transitional callers. Prefer internal/adapters/postgres for new gateway/worker wiring.

func (*Store) GetCredential

func (s *Store) GetCredential(ctx context.Context, credentialID string) (*Credential, error)

func (*Store) GetCredentialAssignmentOrgID

func (s *Store) GetCredentialAssignmentOrgID(ctx context.Context, assignmentID string) (string, error)

func (*Store) GetCredentialOrgID

func (s *Store) GetCredentialOrgID(ctx context.Context, credentialID string) (string, error)

func (*Store) GetDeployment added in v0.3.0

func (s *Store) GetDeployment(ctx context.Context, deploymentID string) (*regions.GatewayDeployment, error)

func (*Store) GetEnvironment

func (s *Store) GetEnvironment(ctx context.Context, environmentID string) (*tenancy.Environment, error)

func (*Store) GetEnvironmentOrgID

func (s *Store) GetEnvironmentOrgID(ctx context.Context, environmentID string) (string, error)

func (*Store) GetFederationPeer added in v0.3.0

func (s *Store) GetFederationPeer(ctx context.Context, peerID string) (*federation.ControlPlanePeer, error)

func (*Store) GetFederationRevision added in v0.3.0

func (s *Store) GetFederationRevision(ctx context.Context) (int64, error)

func (*Store) GetFederationSyncState added in v0.3.0

func (s *Store) GetFederationSyncState(ctx context.Context, regionSlug string) (*federation.SyncState, error)

func (*Store) GetMCPBackendOrgID

func (s *Store) GetMCPBackendOrgID(ctx context.Context, id string) (string, error)

func (*Store) GetOrgDefaultRetry

func (s *Store) GetOrgDefaultRetry(ctx context.Context, orgID string) (*RetryConfig, error)

func (*Store) GetOrgMemberRole

func (s *Store) GetOrgMemberRole(ctx context.Context, userID, orgID string) (string, error)

func (*Store) GetOrgObjectStore

func (s *Store) GetOrgObjectStore(ctx context.Context, orgID string) (*gatewayconfig.ObjectStoreConfig, error)

func (*Store) GetOrganization

func (s *Store) GetOrganization(ctx context.Context, orgID string) (*Organization, error)

func (*Store) GetPolicyOrgID

func (s *Store) GetPolicyOrgID(ctx context.Context, policyID string) (string, error)

func (*Store) GetProjectOrgID

func (s *Store) GetProjectOrgID(ctx context.Context, projectID string) (string, error)

func (*Store) GetProviderOrgID

func (s *Store) GetProviderOrgID(ctx context.Context, providerID string) (string, error)

func (*Store) GetQuotaOrgID

func (s *Store) GetQuotaOrgID(ctx context.Context, quotaID string) (string, error)

func (*Store) GetRegion added in v0.3.0

func (s *Store) GetRegion(ctx context.Context, regionID string) (*regions.Region, error)

func (*Store) GetRegionBySlug added in v0.3.0

func (s *Store) GetRegionBySlug(ctx context.Context, slug string) (*regions.Region, error)

func (*Store) GetRegionOverlay added in v0.3.0

func (s *Store) GetRegionOverlay(ctx context.Context, regionID, orgID string) (*regions.RegionConfigOverlay, error)

func (*Store) GetRouteOrgID

func (s *Store) GetRouteOrgID(ctx context.Context, routeID string) (string, error)

func (*Store) GetSigningKeyOrgID added in v0.3.0

func (s *Store) GetSigningKeyOrgID(ctx context.Context, id string) (string, error)

func (*Store) GetTeam

func (s *Store) GetTeam(ctx context.Context, teamID string) (*Team, error)

func (*Store) GetTeamOrgID

func (s *Store) GetTeamOrgID(ctx context.Context, teamID string) (string, error)

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(ctx context.Context, email string) (*User, error)

func (*Store) GetUserByID

func (s *Store) GetUserByID(ctx context.Context, id string) (*User, error)

func (*Store) GetWasmHookOrgID

func (s *Store) GetWasmHookOrgID(ctx context.Context, id string) (string, error)

func (*Store) IncrCounter

func (s *Store) IncrCounter(ctx context.Context, scopeType, scopeID, metric, window string, delta int64) (int64, error)

func (*Store) InsertUsage

func (s *Store) InsertUsage(ctx context.Context, e UsageEvent) error

func (*Store) InviteOrgMember

func (s *Store) InviteOrgMember(ctx context.Context, orgID, email, invitedByUserID string) (*InviteOutcome, string, error)

func (*Store) IsOrgAdmin

func (s *Store) IsOrgAdmin(ctx context.Context, userID, orgID string) (bool, error)

func (*Store) IsOrgMember

func (s *Store) IsOrgMember(ctx context.Context, userID, orgID string) (bool, error)

func (*Store) IsOrgOwner

func (s *Store) IsOrgOwner(ctx context.Context, userID, orgID string) (bool, error)

func (*Store) JoinFederationPeer added in v0.3.0

func (s *Store) JoinFederationPeer(ctx context.Context, rawToken string) (*federation.ControlPlanePeer, error)

func (*Store) ListA2AAgents

func (s *Store) ListA2AAgents(ctx context.Context, orgID string) ([]A2AAgent, error)

func (*Store) ListAPIKeys

func (s *Store) ListAPIKeys(ctx context.Context, projectID string) ([]APIKey, error)

func (*Store) ListAudit

func (s *Store) ListAudit(ctx context.Context, orgID string, f audit.Filter) ([]audit.Record, error)

func (*Store) ListCredentialAssignments

func (s *Store) ListCredentialAssignments(ctx context.Context, orgID string) ([]CredentialAssignment, error)

func (*Store) ListCredentials

func (s *Store) ListCredentials(ctx context.Context, orgID string) ([]Credential, error)

func (*Store) ListDeployments added in v0.3.0

func (s *Store) ListDeployments(ctx context.Context, regionID string) ([]regions.GatewayDeployment, error)

func (*Store) ListEnvironments

func (s *Store) ListEnvironments(ctx context.Context, projectID string) ([]tenancy.Environment, error)

func (*Store) ListFederationPeers added in v0.3.0

func (s *Store) ListFederationPeers(ctx context.Context) ([]federation.ControlPlanePeer, error)

func (*Store) ListFederationUsageReports added in v0.3.0

func (s *Store) ListFederationUsageReports(ctx context.Context, orgID string, since, until *time.Time, limit int) ([]usage.Record, error)

ListFederationUsageReports returns local usage_events for hub on-demand pull.

func (*Store) ListMCPBackends

func (s *Store) ListMCPBackends(ctx context.Context, orgID string) ([]MCPBackend, error)

func (*Store) ListOrgAPIKeys

func (s *Store) ListOrgAPIKeys(ctx context.Context, orgID string) ([]APIKey, error)

func (*Store) ListOrgInvites

func (s *Store) ListOrgInvites(ctx context.Context, orgID string) ([]OrgInvite, error)

func (*Store) ListOrgMembers

func (s *Store) ListOrgMembers(ctx context.Context, orgID string) ([]OrgMember, error)

func (*Store) ListOrganizationIDs added in v0.3.0

func (s *Store) ListOrganizationIDs(ctx context.Context) ([]string, error)

func (*Store) ListOrganizationsForUser

func (s *Store) ListOrganizationsForUser(ctx context.Context, userID string) ([]Organization, error)

func (*Store) ListPolicies

func (s *Store) ListPolicies(ctx context.Context, orgID string) ([]RequestPolicy, error)

func (*Store) ListProjects

func (s *Store) ListProjects(ctx context.Context, orgID, userID string) ([]Project, error)

func (*Store) ListProviderHealth

func (s *Store) ListProviderHealth(ctx context.Context, orgID string, from, to time.Time) ([]ProviderHealth, error)

ListProviderHealth aggregates usage_events for models routed to each org provider.

func (*Store) ListProviders

func (s *Store) ListProviders(ctx context.Context, orgID string) ([]Provider, error)

func (*Store) ListQuotas

func (s *Store) ListQuotas(ctx context.Context, orgID string) ([]Quota, error)

func (*Store) ListRegionMemberships added in v0.3.0

func (s *Store) ListRegionMemberships(ctx context.Context, regionID string) ([]regions.OrgRegionMembership, error)

func (*Store) ListRegions added in v0.3.0

func (s *Store) ListRegions(ctx context.Context) ([]regions.Region, error)

func (*Store) ListRoutes

func (s *Store) ListRoutes(ctx context.Context, orgID string) ([]Route, error)

func (*Store) ListSigningKeys added in v0.3.0

func (s *Store) ListSigningKeys(ctx context.Context, orgID string) ([]access.SigningKey, error)

func (*Store) ListTeamMembers

func (s *Store) ListTeamMembers(ctx context.Context, teamID string) ([]TeamMember, error)

func (*Store) ListTeams

func (s *Store) ListTeams(ctx context.Context, orgID, userID string) ([]Team, error)

func (*Store) ListUsage

func (s *Store) ListUsage(ctx context.Context, orgID string, f UsageFilter) ([]UsageEvent, error)

func (*Store) ListWasmHooks

func (s *Store) ListWasmHooks(ctx context.Context, orgID string) ([]WasmHook, error)

func (*Store) LoadSnapshotSource

func (s *Store) LoadSnapshotSource(ctx context.Context) (snapshot.Source, error)

func (*Store) LookupModelPrice

func (s *Store) LookupModelPrice(ctx context.Context, providerType, model string) (ModelPrice, bool, error)

func (*Store) OpenFederationPeerJoinToken added in v0.3.0

func (s *Store) OpenFederationPeerJoinToken(ctx context.Context, peerID string) (string, error)

OpenFederationPeerJoinToken decrypts the hub-retained join token for regional pulls.

func (*Store) PreviewOrgInvite

func (s *Store) PreviewOrgInvite(ctx context.Context, rawToken string) (*InvitePreview, error)

func (*Store) ProjectBelongsToOrg

func (s *Store) ProjectBelongsToOrg(ctx context.Context, projectID, orgID string) error

func (*Store) PutRegionOverlay added in v0.3.0

func (s *Store) PutRegionOverlay(ctx context.Context, regionID, orgID string, payload regions.OverlayPayload) (*regions.RegionConfigOverlay, error)

func (*Store) RecordDeploymentHeartbeat added in v0.3.0

func (s *Store) RecordDeploymentHeartbeat(ctx context.Context, deploymentID, joinToken string, snapVersion int64, build string) (*regions.GatewayDeployment, error)

func (*Store) RecordFederationPeerSync added in v0.3.0

func (s *Store) RecordFederationPeerSync(ctx context.Context, peerID string, cursor int64, syncErr string) error

func (*Store) RegisterDeployment added in v0.3.0

func (s *Store) RegisterDeployment(ctx context.Context, regionID, name, publicBaseURL string) (*regions.DeploymentWithToken, error)

func (*Store) RegisterFederationPeer added in v0.3.0

func (s *Store) RegisterFederationPeer(ctx context.Context, name, regionID, baseURL string) (*federation.PeerWithToken, error)

func (*Store) RemoveTeamMember

func (s *Store) RemoveTeamMember(ctx context.Context, teamID, userID string) error

func (*Store) ReorderPolicies

func (s *Store) ReorderPolicies(ctx context.Context, orgID string, items []gatewayconfig.PolicyPriorityUpdate) error

func (*Store) ResendOrgInvite

func (s *Store) ResendOrgInvite(ctx context.Context, orgID, inviteID string) (*OrgInvite, string, error)

func (*Store) RevokeOrgInvite

func (s *Store) RevokeOrgInvite(ctx context.Context, orgID, inviteID string) error

func (*Store) RotateCredential

func (s *Store) RotateCredential(ctx context.Context, credentialID, secretRef, secretValue string) (*Credential, error)

func (*Store) RotateDeploymentJoinToken added in v0.3.0

func (s *Store) RotateDeploymentJoinToken(ctx context.Context, deploymentID string) (*regions.DeploymentWithToken, error)

func (*Store) RotateFederationPeerJoinToken added in v0.3.0

func (s *Store) RotateFederationPeerJoinToken(ctx context.Context, peerID string) (*federation.PeerWithToken, error)

func (*Store) RotateSigningKey added in v0.3.0

func (s *Store) RotateSigningKey(ctx context.Context, id, publicKeyPEM string) (*access.SigningKey, error)

func (*Store) SetCredentialsMasterKey

func (s *Store) SetCredentialsMasterKey(raw string) error

SetCredentialsMasterKey configures encryption for encrypted_db credentials. Empty raw leaves encrypted_db creates disabled.

func (*Store) SetFederationRegionMirror added in v0.3.0

func (s *Store) SetFederationRegionMirror(m *objectstore.SnapshotStore)

SetFederationRegionMirror attaches the hub object-store mirror used for federation export.

func (*Store) SetFederationTokenKey added in v0.3.0

func (s *Store) SetFederationTokenKey(raw string) error

SetFederationTokenKey configures sealing for peer join tokens (hub pull of usage reports). Prefer credentials master key; callers may fall back to the JWT secret.

func (*Store) SetOrgDefaultRetry

func (s *Store) SetOrgDefaultRetry(ctx context.Context, orgID string, retry *RetryConfig) error

func (*Store) SetOrgMailProvider

func (s *Store) SetOrgMailProvider(ctx context.Context, orgID, provider string) (*Organization, error)

func (*Store) SetOrgObjectStore

func (s *Store) SetOrgObjectStore(ctx context.Context, orgID string, cfg *gatewayconfig.ObjectStoreConfig) error

func (*Store) SummarizeUsage

func (s *Store) SummarizeUsage(ctx context.Context, orgID string, f UsageFilter) ([]UsageSummaryBucket, error)

func (*Store) TeamBelongsToOrg

func (s *Store) TeamBelongsToOrg(ctx context.Context, teamID, orgID string) error

func (*Store) UnbindOrgFromRegion added in v0.3.0

func (s *Store) UnbindOrgFromRegion(ctx context.Context, regionID, orgID string) error

func (*Store) UpdateA2AAgent

func (s *Store) UpdateA2AAgent(ctx context.Context, id string, alias, name, upstreamURL, cardURL, apiKeyEnv, authScheme *string, cardCache []byte, enabled *bool) (*A2AAgent, error)

func (*Store) UpdateCredential

func (s *Store) UpdateCredential(ctx context.Context, credentialID, name, status string) (*Credential, error)

func (*Store) UpdateFederationPeer added in v0.3.0

func (s *Store) UpdateFederationPeer(ctx context.Context, peerID, name, baseURL, status string) (*federation.ControlPlanePeer, error)

func (*Store) UpdateMCPBackend

func (s *Store) UpdateMCPBackend(ctx context.Context, id string, alias, name, baseURL, apiKeyEnv *string, methodAllowlist []byte, enabled *bool) (*MCPBackend, error)

func (*Store) UpdateOrgMemberRole

func (s *Store) UpdateOrgMemberRole(ctx context.Context, orgID, actorUserID, targetUserID, role string) (*OrgMember, error)

UpdateOrgMemberRole changes a member's role. Only the org owner may call this. Promoting to owner transfers ownership (actor becomes admin). Cannot demote the sole owner.

func (*Store) UpdatePolicy

func (s *Store) UpdatePolicy(ctx context.Context, policyID string, name, expression *string, actions []gatewayconfig.PolicyAction, enabled *bool, priority *int) (*RequestPolicy, error)

func (*Store) UpdateProvider

func (s *Store) UpdateProvider(ctx context.Context, providerID, name, baseURL, apiKeyEnv string, config *json.RawMessage) (*Provider, error)

func (*Store) UpdateQuota

func (s *Store) UpdateQuota(ctx context.Context, quotaID string, limitValue int64) (*Quota, error)

func (*Store) UpdateRegion added in v0.3.0

func (s *Store) UpdateRegion(ctx context.Context, regionID, name, status string) (*regions.Region, error)

func (*Store) UpdateRoute

func (s *Store) UpdateRoute(ctx context.Context, routeID, model, providerID, targetModel string, fallbacks []RouteFallback, retry *RetryConfig, strategy string, weight int) (*Route, error)

func (*Store) UpdateSigningKey added in v0.3.0

func (s *Store) UpdateSigningKey(ctx context.Context, id, name, status string) (*access.SigningKey, error)

func (*Store) UpdateTeamMemberRole

func (s *Store) UpdateTeamMemberRole(ctx context.Context, teamID, actorUserID, targetUserID, role string) (*TeamMember, error)

func (*Store) UpdateWasmHook

func (s *Store) UpdateWasmHook(ctx context.Context, id string, name, phase, moduleURI, digest *string, enabled *bool, priority *int, config []byte) (*WasmHook, error)

func (*Store) UpsertFederationSyncState added in v0.3.0

func (s *Store) UpsertFederationSyncState(ctx context.Context, st federation.SyncState) error

func (*Store) UserIsOrgMember

func (s *Store) UserIsOrgMember(ctx context.Context, userID, orgID string) error

type Team

type Team = tenancy.Team

type TeamMember

type TeamMember = tenancy.TeamMember

type Teams

type Teams struct {
	Pool *pgxpool.Pool
}

Teams implements tenancy.TeamRepository.

func NewTeams

func NewTeams(pool *pgxpool.Pool) *Teams

func (*Teams) AddMember

func (t *Teams) AddMember(ctx context.Context, teamID, userID, role string) error

func (*Teams) CountOwners

func (t *Teams) CountOwners(ctx context.Context, teamID string) (int, error)

func (*Teams) CreateWithOwner

func (t *Teams) CreateWithOwner(ctx context.Context, team tenancy.Team, ownerUserID string) error

func (*Teams) Get

func (t *Teams) Get(ctx context.Context, teamID string) (*tenancy.Team, error)

func (*Teams) GetMember

func (t *Teams) GetMember(ctx context.Context, teamID, userID string) (*tenancy.TeamMember, error)

func (*Teams) GetMemberRole

func (t *Teams) GetMemberRole(ctx context.Context, teamID, userID string) (string, error)

func (*Teams) ListByOrg

func (t *Teams) ListByOrg(ctx context.Context, orgID string) ([]tenancy.Team, error)

func (*Teams) ListByOrgForUser

func (t *Teams) ListByOrgForUser(ctx context.Context, orgID, userID string) ([]tenancy.Team, error)

func (*Teams) ListMembers

func (t *Teams) ListMembers(ctx context.Context, teamID string) ([]tenancy.TeamMember, error)

func (*Teams) OrgID

func (t *Teams) OrgID(ctx context.Context, teamID string) (string, error)

func (*Teams) RemoveMember

func (t *Teams) RemoveMember(ctx context.Context, teamID, userID string) error

func (*Teams) SetMemberRole

func (t *Teams) SetMemberRole(ctx context.Context, teamID, userID, role string) error

type UsageEvent

type UsageEvent = usage.Record

UsageEvent is the control-plane read model (persisted row + joins). Emit/outbox use the canonical usage.Event.

type UsageFilter

type UsageFilter = usage.Filter

type UsageOutbox

type UsageOutbox struct {
	Pool *pgxpool.Pool
}

UsageOutbox writes and drains the usage_outbox table.

func (*UsageOutbox) ClaimBatch

func (o *UsageOutbox) ClaimBatch(ctx context.Context, limit int) ([]workers.OutboxRow, error)

func (*UsageOutbox) Enqueue

func (o *UsageOutbox) Enqueue(ctx context.Context, payload []byte) error

Enqueue implements a write-side port for the gateway request path.

func (*UsageOutbox) MarkProcessed

func (o *UsageOutbox) MarkProcessed(ctx context.Context, id int64) error

type UsageQueries

type UsageQueries struct {
	Pool *pgxpool.Pool
}

UsageQueries reads and writes usage_events for the control plane.

func NewUsageQueries

func NewUsageQueries(pool *pgxpool.Pool) *UsageQueries

func (*UsageQueries) InsertRecord

func (q *UsageQueries) InsertRecord(ctx context.Context, e usage.Record) error

func (*UsageQueries) List

func (q *UsageQueries) List(ctx context.Context, orgID string, f usage.Filter) ([]usage.Record, error)

func (*UsageQueries) ListProviderHealth

func (q *UsageQueries) ListProviderHealth(ctx context.Context, orgID string, from, to time.Time) ([]usage.ProviderHealth, error)

func (*UsageQueries) ListReportsSince added in v0.3.0

func (q *UsageQueries) ListReportsSince(ctx context.Context, orgID string, since, until *time.Time, limit int) ([]usage.Record, error)

ListReportsSince returns usage events for federation report pull (newest first). orgID empty = all orgs. since/until filter created_at when set.

func (*UsageQueries) LookupModelPrice

func (q *UsageQueries) LookupModelPrice(ctx context.Context, providerType, model string) (usage.ModelPrice, bool, error)

func (*UsageQueries) Summarize

func (q *UsageQueries) Summarize(ctx context.Context, orgID string, f usage.Filter) ([]usage.SummaryBucket, error)

type UsageSink

type UsageSink struct {
	Pool *pgxpool.Pool
}

UsageSink writes usage_events from drained outbox payloads.

func (*UsageSink) InsertUsage

func (s *UsageSink) InsertUsage(ctx context.Context, e usage.Event, costUSD *float64) error

type UsageSummaryBucket

type UsageSummaryBucket = usage.SummaryBucket

type User

type User = identity.User

type Users

type Users struct {
	Pool *pgxpool.Pool
}

Users implements identity.UserRepository.

func NewUsers

func NewUsers(pool *pgxpool.Pool) *Users

func (*Users) Create

func (u *Users) Create(ctx context.Context, user identity.User) error

func (*Users) GetByEmail

func (u *Users) GetByEmail(ctx context.Context, email string) (*identity.User, error)

func (*Users) GetByID

func (u *Users) GetByID(ctx context.Context, id string) (*identity.User, error)

func (*Users) UpdatePassword

func (u *Users) UpdatePassword(ctx context.Context, userID, passwordHash string) error

type WasmHook

type WasmHook = gatewayconfig.WasmHook

WasmHook is the platform write-model WASM lifecycle binding.

type WasmHooks

type WasmHooks struct {
	Pool *pgxpool.Pool
}

WasmHooks implements gatewayconfig.WasmHookRepository.

func NewWasmHooks

func NewWasmHooks(pool *pgxpool.Pool) *WasmHooks

func (*WasmHooks) Delete

func (p *WasmHooks) Delete(ctx context.Context, id string) error

func (*WasmHooks) Get

func (*WasmHooks) Insert

func (p *WasmHooks) Insert(ctx context.Context, item gatewayconfig.WasmHook) error

func (*WasmHooks) ListByOrg

func (p *WasmHooks) ListByOrg(ctx context.Context, orgID string) ([]gatewayconfig.WasmHook, error)

func (*WasmHooks) OrgID

func (p *WasmHooks) OrgID(ctx context.Context, id string) (string, error)

func (*WasmHooks) Update

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL