postgres

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TABLE_PERMISSIONS            = "permissions"
	TABLE_GROUPS                 = "groups"
	TABLE_NAMESPACES             = "namespaces"
	TABLE_ORGANIZATIONS          = "organizations"
	TABLE_POLICIES               = "policies"
	TABLE_PROJECTS               = "projects"
	TABLE_RELATIONS              = "relations"
	TABLE_RESOURCES              = "resources"
	TABLE_ROLES                  = "roles"
	TABLE_USERS                  = "users"
	TABLE_METASCHEMA             = "metaschema"
	TABLE_FLOWS                  = "flows"
	TABLE_SESSIONS               = "sessions"
	TABLE_INVITATIONS            = "invitations"
	TABLE_SERVICEUSER            = "serviceusers"
	TABLE_SERVICEUSERCREDENTIALS = "serviceuser_credentials"
	TABLE_AUDITLOGS              = "auditlogs"
	TABLE_DOMAINS                = "domains"
	TABLE_PREFERENCES            = "preferences"
	TABLE_BILLING_CUSTOMERS      = "billing_customers"
	TABLE_BILLING_PLANS          = "billing_plans"
	TABLE_BILLING_PRODUCTS       = "billing_products"
	TABLE_BILLING_PRICES         = "billing_prices"
	TABLE_BILLING_FEATURES       = "billing_features"
	TABLE_BILLING_SUBSCRIPTIONS  = "billing_subscriptions"
	TABLE_BILLING_CHECKOUTS      = "billing_checkouts"
	TABLE_BILLING_TRANSACTIONS   = "billing_transactions"
	TABLE_BILLING_INVOICES       = "billing_invoices"
)

Variables

View Source
var (
	ErrDuplicateKey              = errors.New("duplicate key")
	ErrCheckViolation            = errors.New("check constraint violation")
	ErrForeignKeyViolation       = errors.New("foreign key violation")
	ErrInvalidTextRepresentation = errors.New("invalid input syntax type")
	ErrInvalidID                 = errors.New("invalid id")
)
View Source
var (
	ErrInvalidSlug = fmt.Errorf("invalid slug")
)

Functions

This section is empty.

Types

type Audit

type Audit struct {
	ID     string `db:"id"`
	OrgID  string `db:"org_id"`
	Source string `db:"source"`
	Action string `db:"action"`

	Actor    types.NullJSONText `db:"actor"`
	Target   types.NullJSONText `db:"target"`
	Metadata types.NullJSONText `db:"metadata"`

	CreatedAt time.Time `db:"created_at"`
}

type AuditRepository

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

func NewAuditRepository

func NewAuditRepository(dbc *db.Client) *AuditRepository

func (AuditRepository) Create

func (a AuditRepository) Create(ctx context.Context, l *audit.Log) error

func (AuditRepository) GetByID

func (a AuditRepository) GetByID(ctx context.Context, id string) (audit.Log, error)

func (AuditRepository) List

func (a AuditRepository) List(ctx context.Context, flt audit.Filter) ([]audit.Log, error)

type BehaviorConfig added in v0.8.18

type BehaviorConfig struct {
	CreditAmount int64 `json:"credit_amount"`
	SeatLimit    int64 `json:"seat_limit"`
	MinQuantity  int64 `json:"min_quantity"`
	MaxQuantity  int64 `json:"max_quantity"`
}

func (*BehaviorConfig) Scan added in v0.8.18

func (b *BehaviorConfig) Scan(src interface{}) error

func (BehaviorConfig) Value added in v0.8.18

func (b BehaviorConfig) Value() (driver.Value, error)

type BillingCheckoutRepository added in v0.8.0

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

func NewBillingCheckoutRepository added in v0.8.0

func NewBillingCheckoutRepository(dbc *db.Client) *BillingCheckoutRepository

func (BillingCheckoutRepository) Create added in v0.8.0

func (BillingCheckoutRepository) GetByID added in v0.8.0

func (BillingCheckoutRepository) GetByName added in v0.8.0

func (BillingCheckoutRepository) List added in v0.8.0

func (BillingCheckoutRepository) UpdateByID added in v0.8.0

type BillingCustomerRepository added in v0.8.0

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

func NewBillingCustomerRepository added in v0.8.0

func NewBillingCustomerRepository(dbc *db.Client) *BillingCustomerRepository

func (BillingCustomerRepository) Create added in v0.8.0

func (BillingCustomerRepository) Delete added in v0.8.0

func (BillingCustomerRepository) GetByID added in v0.8.0

func (BillingCustomerRepository) List added in v0.8.0

func (BillingCustomerRepository) UpdateByID added in v0.8.0

type BillingFeatureRepository added in v0.8.0

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

func NewBillingFeatureRepository added in v0.8.0

func NewBillingFeatureRepository(dbc *db.Client) *BillingFeatureRepository

func (BillingFeatureRepository) Create added in v0.8.0

func (BillingFeatureRepository) GetByID added in v0.8.0

func (BillingFeatureRepository) GetByName added in v0.8.0

func (BillingFeatureRepository) List added in v0.8.0

func (BillingFeatureRepository) UpdateByName added in v0.8.0

func (r BillingFeatureRepository) UpdateByName(ctx context.Context, toUpdate product.Feature) (product.Feature, error)

type BillingInvoiceRepository added in v0.8.26

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

func NewBillingInvoiceRepository added in v0.8.26

func NewBillingInvoiceRepository(dbc *db.Client) *BillingInvoiceRepository

func (BillingInvoiceRepository) Create added in v0.8.26

func (BillingInvoiceRepository) Delete added in v0.8.35

func (BillingInvoiceRepository) GetByID added in v0.8.26

func (BillingInvoiceRepository) List added in v0.8.26

func (BillingInvoiceRepository) UpdateByID added in v0.8.26

type BillingPlanRepository added in v0.8.0

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

func NewBillingPlanRepository added in v0.8.0

func NewBillingPlanRepository(dbc *db.Client) *BillingPlanRepository

func (BillingPlanRepository) Create added in v0.8.0

func (r BillingPlanRepository) Create(ctx context.Context, toCreate plan.Plan) (plan.Plan, error)

func (BillingPlanRepository) GetByID added in v0.8.0

func (r BillingPlanRepository) GetByID(ctx context.Context, id string) (plan.Plan, error)

func (BillingPlanRepository) GetByName added in v0.8.0

func (r BillingPlanRepository) GetByName(ctx context.Context, name string) (plan.Plan, error)

func (BillingPlanRepository) List added in v0.8.0

func (r BillingPlanRepository) List(ctx context.Context, filter plan.Filter) ([]plan.Plan, error)

func (BillingPlanRepository) UpdateByName added in v0.8.0

func (r BillingPlanRepository) UpdateByName(ctx context.Context, toUpdate plan.Plan) (plan.Plan, error)

type BillingPriceRepository added in v0.8.0

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

func NewBillingPriceRepository added in v0.8.0

func NewBillingPriceRepository(dbc *db.Client) *BillingPriceRepository

func (BillingPriceRepository) Create added in v0.8.0

func (BillingPriceRepository) GetByID added in v0.8.0

func (BillingPriceRepository) GetByName added in v0.8.0

func (r BillingPriceRepository) GetByName(ctx context.Context, name string) (product.Price, error)

func (BillingPriceRepository) List added in v0.8.0

func (BillingPriceRepository) UpdateByID added in v0.8.0

func (r BillingPriceRepository) UpdateByID(ctx context.Context, toUpdate product.Price) (product.Price, error)

type BillingProductRepository added in v0.8.14

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

func NewBillingProductRepository added in v0.8.14

func NewBillingProductRepository(dbc *db.Client) *BillingProductRepository

func (BillingProductRepository) Create added in v0.8.14

func (BillingProductRepository) GetByID added in v0.8.14

func (BillingProductRepository) GetByName added in v0.8.14

func (BillingProductRepository) List added in v0.8.14

func (BillingProductRepository) UpdateByName added in v0.8.14

func (r BillingProductRepository) UpdateByName(ctx context.Context, toUpdate product.Product) (product.Product, error)

type BillingSubscriptionRepository added in v0.8.0

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

func NewBillingSubscriptionRepository added in v0.8.0

func NewBillingSubscriptionRepository(dbc *db.Client) *BillingSubscriptionRepository

func (BillingSubscriptionRepository) Create added in v0.8.0

func (BillingSubscriptionRepository) Delete added in v0.8.35

func (BillingSubscriptionRepository) GetByID added in v0.8.0

func (BillingSubscriptionRepository) GetByName added in v0.8.0

func (BillingSubscriptionRepository) GetByProviderID added in v0.8.0

func (BillingSubscriptionRepository) List added in v0.8.0

func (BillingSubscriptionRepository) UpdateByID added in v0.8.0

type BillingTransactionRepository added in v0.8.0

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

func NewBillingTransactionRepository added in v0.8.0

func NewBillingTransactionRepository(dbc *db.Client) *BillingTransactionRepository

func (BillingTransactionRepository) CreateEntry added in v0.8.0

func (r BillingTransactionRepository) CreateEntry(ctx context.Context, debitEntry credit.Transaction,
	creditEntry credit.Transaction) ([]credit.Transaction, error)

func (BillingTransactionRepository) GetBalance added in v0.8.0

func (r BillingTransactionRepository) GetBalance(ctx context.Context, accountID string) (int64, error)

GetBalance currently sums all transactions for a customer and returns the balance. Ideally to speed this up we should create another table transaction_statement which will in batch compute the monthly summary for each customer, and then we can just query that table to get the balance since last month end date and add it to the entries in transaction table till now.

func (BillingTransactionRepository) GetByID added in v0.8.0

func (BillingTransactionRepository) List added in v0.8.0

func (BillingTransactionRepository) UpdateByID added in v0.8.0

type Checkout added in v0.8.0

type Checkout struct {
	ID         string `db:"id"`
	CustomerID string `db:"customer_id"`
	ProviderID string `db:"provider_id"`

	PlanID             *string            `db:"plan_id"`
	SubscriptionConfig SubscriptionConfig `db:"subscription_config"`
	FeatureID          *string            `db:"feature_id"`

	SuccessUrl    *string            `db:"success_url"`
	CancelUrl     *string            `db:"cancel_url"`
	CheckoutUrl   string             `db:"checkout_url"`
	PaymentStatus *string            `db:"payment_status"`
	State         string             `db:"state"`
	Metadata      types.NullJSONText `db:"metadata"`

	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	ExpireAt  *time.Time `db:"expire_at"`
}

type Customer added in v0.8.0

type Customer struct {
	ID         string `db:"id"`
	OrgID      string `db:"org_id"`
	ProviderID string `db:"provider_id"`

	Name     string             `db:"name"`
	Email    string             `db:"email"`
	Phone    *string            `db:"phone"`
	Currency string             `db:"currency"`
	Address  types.NullJSONText `db:"address"`
	Metadata types.NullJSONText `db:"metadata"`
	Tax      Tax                `db:"tax"`

	State     string     `db:"state"`
	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

type Domain added in v0.7.2

type Domain struct {
	ID        string    `db:"id"`
	OrgID     string    `db:"org_id"`
	Name      string    `db:"name"`
	Token     string    `db:"token"`
	State     string    `db:"state"`
	UpdatedAt time.Time `db:"updated_at"`
	CreatedAt time.Time `db:"created_at"`
}

type DomainRepository added in v0.7.2

type DomainRepository struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

func NewDomainRepository added in v0.7.2

func NewDomainRepository(logger log.Logger, dbc *db.Client) *DomainRepository

func (*DomainRepository) Create added in v0.7.2

func (s *DomainRepository) Create(ctx context.Context, toCreate domain.Domain) (domain.Domain, error)

func (*DomainRepository) Delete added in v0.7.2

func (s *DomainRepository) Delete(ctx context.Context, id string) error

func (*DomainRepository) DeleteExpiredDomainRequests added in v0.7.2

func (s *DomainRepository) DeleteExpiredDomainRequests(ctx context.Context) error

func (*DomainRepository) Get added in v0.7.2

func (*DomainRepository) List added in v0.7.2

func (*DomainRepository) Update added in v0.7.2

func (s *DomainRepository) Update(ctx context.Context, toUpdate domain.Domain) (domain.Domain, error)

type Feature added in v0.8.0

type Feature struct {
	ID         string         `db:"id"`
	Name       string         `db:"name"`
	Title      *string        `db:"title"`
	ProductIDs pq.StringArray `db:"product_ids"`

	Metadata types.NullJSONText `db:"metadata"`

	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

type Flow

type Flow struct {
	ID        uuid.UUID `db:"id"`
	Method    string    `db:"method"`
	Email     string    `db:"email"`
	Nonce     string    `db:"nonce"`
	Metadata  []byte    `db:"metadata"`
	CreatedAt time.Time `db:"created_at"`
	ExpiresAt time.Time `db:"expires_at"`
}

type FlowRepository

type FlowRepository struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

func NewFlowRepository

func NewFlowRepository(logger log.Logger, dbc *db.Client) *FlowRepository

func (*FlowRepository) Delete

func (s *FlowRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*FlowRepository) DeleteExpiredFlows

func (s *FlowRepository) DeleteExpiredFlows(ctx context.Context) error

func (*FlowRepository) Get

func (*FlowRepository) Set

func (s *FlowRepository) Set(ctx context.Context, flow *authenticate.Flow) error

type Group

type Group struct {
	ID        string         `db:"id"`
	Name      string         `db:"name"`
	Title     sql.NullString `db:"title"`
	OrgID     string         `db:"org_id"`
	Metadata  []byte         `db:"metadata"`
	State     sql.NullString `db:"state"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
	DeletedAt sql.NullTime   `db:"deleted_at"`
}

type GroupRepository

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

func NewGroupRepository

func NewGroupRepository(dbc *db.Client) *GroupRepository

func (GroupRepository) Create

func (r GroupRepository) Create(ctx context.Context, grp group.Group) (group.Group, error)

func (GroupRepository) Delete

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

func (GroupRepository) GetByID

func (r GroupRepository) GetByID(ctx context.Context, id string) (group.Group, error)

func (GroupRepository) GetByIDs

func (r GroupRepository) GetByIDs(ctx context.Context, groupIDs []string, flt group.Filter) ([]group.Group, error)

func (GroupRepository) List

func (r GroupRepository) List(ctx context.Context, flt group.Filter) ([]group.Group, error)

func (GroupRepository) ListGroupRelations

func (r GroupRepository) ListGroupRelations(ctx context.Context, objectId string, subject_type string, role string) ([]relation.Relation, error)

TODO(kushsharma): no longer in use, delete if needed

func (GroupRepository) SetState

func (r GroupRepository) SetState(ctx context.Context, id string, state group.State) error

func (GroupRepository) UpdateByID

func (r GroupRepository) UpdateByID(ctx context.Context, grp group.Group) (group.Group, error)

type Invitation

type Invitation struct {
	ID        uuid.UUID `db:"id"`
	UserID    string    `db:"user_id"`
	OrgID     string    `db:"org_id"`
	Metadata  []byte    `db:"metadata"`
	CreatedAt time.Time `db:"created_at"`
	ExpiresAt time.Time `db:"expires_at"`
}

type InvitationRepository

type InvitationRepository struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

func NewInvitationRepository

func NewInvitationRepository(logger log.Logger, dbc *db.Client) *InvitationRepository

func (*InvitationRepository) Delete

func (s *InvitationRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*InvitationRepository) GarbageCollect

func (s *InvitationRepository) GarbageCollect(ctx context.Context) error

TODO(kushsharma): schedue a cron for it

func (*InvitationRepository) Get

func (*InvitationRepository) List

func (*InvitationRepository) ListByUser

func (*InvitationRepository) Set

type Invoice added in v0.8.26

type Invoice struct {
	ID         string `db:"id"`
	ProviderID string `db:"provider_id"`
	CustomerID string `db:"customer_id"`
	State      string `db:"state"`
	Currency   string `db:"currency"`
	Amount     int64  `db:"amount"`
	HostedURL  string `db:"hosted_url"`

	Metadata types.NullJSONText `db:"metadata"`

	PeriodStartAt *time.Time `db:"period_start_at"`
	PeriodEndAt   *time.Time `db:"period_end_at"`
	DueAt         *time.Time `db:"due_at"`
	EffectiveAt   *time.Time `db:"effective_at"`
	CreatedAt     time.Time  `db:"created_at"`
	UpdatedAt     time.Time  `db:"updated_at"`
	DeletedAt     *time.Time `db:"deleted_at"`
}

type MetaSchema

type MetaSchema struct {
	ID        string    `db:"id"`
	Name      string    `db:"name"`
	Schema    string    `db:"schema"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type MetaSchemaRepository

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

func NewMetaSchemaRepository

func NewMetaSchemaRepository(logger log.Logger, dbc *db.Client) *MetaSchemaRepository

func (MetaSchemaRepository) Create

func (MetaSchemaRepository) Delete

func (m MetaSchemaRepository) Delete(ctx context.Context, id string) (string, error)

func (MetaSchemaRepository) Get

func (MetaSchemaRepository) List

func (MetaSchemaRepository) MigrateDefaults

func (m MetaSchemaRepository) MigrateDefaults(ctx context.Context) error

add default schemas to db once during database migration

func (MetaSchemaRepository) Update

type Namespace

type Namespace struct {
	ID        string       `db:"id"`
	Name      string       `db:"name"`
	Metadata  []byte       `db:"metadata"`
	CreatedAt time.Time    `db:"created_at"`
	UpdatedAt time.Time    `db:"updated_at"`
	DeletedAt sql.NullTime `db:"deleted_at"`
}

type NamespaceRepository

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

func NewNamespaceRepository

func NewNamespaceRepository(dbc *db.Client) *NamespaceRepository

func (NamespaceRepository) Get

func (NamespaceRepository) List

func (NamespaceRepository) Update

func (NamespaceRepository) Upsert

Upsert inserts a new namespace if it doesn't exist. If it does, update the details and return no error

type Organization

type Organization struct {
	ID        string         `db:"id"`
	Name      string         `db:"name"`
	Title     sql.NullString `db:"title"`
	Avatar    sql.NullString `db:"avatar"`
	Metadata  []byte         `db:"metadata"`
	State     sql.NullString `db:"state"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
	DeletedAt sql.NullTime   `db:"deleted_at"`
}

type OrganizationRepository

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

func NewOrganizationRepository

func NewOrganizationRepository(dbc *db.Client) *OrganizationRepository

func (OrganizationRepository) Create

func (OrganizationRepository) Delete

func (OrganizationRepository) GetByID

func (OrganizationRepository) GetByIDs

func (OrganizationRepository) GetByName

func (OrganizationRepository) List

func (OrganizationRepository) SetState

func (OrganizationRepository) UpdateByID

func (OrganizationRepository) UpdateByName

type Permission

type Permission struct {
	ID          string    `db:"id"`
	Name        string    `db:"name"`
	Slug        string    `db:"slug"`
	Namespace   Namespace `db:"namespace"`
	NamespaceID string    `db:"namespace_name"`
	Metadata    []byte    `db:"metadata"`
	CreatedAt   time.Time `db:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"`
}

type PermissionRepository

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

func NewPermissionRepository

func NewPermissionRepository(dbc *db.Client) *PermissionRepository

func (PermissionRepository) Delete

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

func (PermissionRepository) Get

func (PermissionRepository) GetBySlug

func (PermissionRepository) List

func (PermissionRepository) Update

func (PermissionRepository) Upsert

type Phase added in v0.8.19

type Phase struct {
	EffectiveAt time.Time `json:"effective_at"`
	EndsAt      time.Time `json:"ends_at"`
	PlanID      string    `json:"plan_id"`
}

type Plan added in v0.8.0

type Plan struct {
	ID string `db:"id"`

	Name           string  `db:"name"`
	Title          *string `db:"title"`
	Description    *string `db:"description"`
	Interval       *string `db:"interval"`
	OnStartCredits int64   `db:"on_start_credits"`

	State     string             `db:"state"`
	TrialDays *int64             `db:"trial_days"`
	Metadata  types.NullJSONText `db:"metadata"`

	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

type Policy

type Policy struct {
	ID            string `db:"id"`
	Role          Role
	RoleID        string    `db:"role_id"`
	ResourceID    string    `db:"resource_id"`
	ResourceType  string    `db:"resource_type"`
	PrincipalID   string    `db:"principal_id"`
	PrincipalType string    `db:"principal_type"`
	Metadata      []byte    `db:"metadata"`
	CreatedAt     time.Time `db:"created_at"`
	UpdatedAt     time.Time `db:"updated_at"`
}

type PolicyCols

type PolicyCols struct {
	ID            string    `db:"id"`
	RoleID        string    `db:"role_id"`
	ResourceType  string    `db:"resource_type"`
	ResourceID    string    `db:"resource_id"`
	PrincipalID   string    `db:"principal_id"`
	PrincipalType string    `db:"principal_type"`
	Metadata      []byte    `db:"metadata"`
	CreatedAt     time.Time `db:"created_at"`
	UpdatedAt     time.Time `db:"updated_at"`
}

type PolicyRepository

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

func NewPolicyRepository

func NewPolicyRepository(dbc *db.Client) *PolicyRepository

func (PolicyRepository) Count added in v0.8.13

func (r PolicyRepository) Count(ctx context.Context, flt policy.Filter) (int64, error)

func (PolicyRepository) Delete

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

func (PolicyRepository) Get

func (PolicyRepository) GroupMemberCount added in v0.8.8

func (r PolicyRepository) GroupMemberCount(ctx context.Context, groupIDs []string) ([]policy.MemberCount, error)

func (PolicyRepository) List

func (PolicyRepository) OrgMemberCount added in v0.8.13

func (r PolicyRepository) OrgMemberCount(ctx context.Context, id string) (policy.MemberCount, error)

func (PolicyRepository) ProjectMemberCount added in v0.8.8

func (r PolicyRepository) ProjectMemberCount(ctx context.Context, projectIDs []string) ([]policy.MemberCount, error)

func (PolicyRepository) Update

func (r PolicyRepository) Update(ctx context.Context, toUpdate policy.Policy) (string, error)

func (PolicyRepository) Upsert

type Preference added in v0.7.3

type Preference struct {
	ID           uuid.UUID `db:"id"`
	Name         string    `db:"name"`
	Value        string    `db:"value"`
	ResourceType string    `db:"resource_type"`
	ResourceID   string    `db:"resource_id"`
	CreatedAt    time.Time `db:"created_at"`
	UpdatedAt    time.Time `db:"updated_at"`
}

type PreferenceRepository added in v0.7.3

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

func NewPreferenceRepository added in v0.7.3

func NewPreferenceRepository(dbc *db.Client) *PreferenceRepository

func (*PreferenceRepository) Get added in v0.7.3

func (*PreferenceRepository) List added in v0.7.3

func (*PreferenceRepository) Set added in v0.7.3

type Price added in v0.8.0

type Price struct {
	ID            string `db:"id"`
	ProductID     string `db:"product_id"`
	ProviderID    string `db:"provider_id"`
	Name          string `db:"name"`
	BillingScheme string `db:"billing_scheme"`
	Currency      string `db:"currency"`
	Amount        int64  `db:"amount"`

	Interval string `db:"interval"`

	UsageType        string  `db:"usage_type"`
	MeteredAggregate *string `db:"metered_aggregate"`
	TierMode         *string `db:"tier_mode"`

	State    string             `db:"state"`
	Metadata types.NullJSONText `db:"metadata"`

	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

type Product added in v0.8.14

type Product struct {
	ID          string         `db:"id"`
	ProviderID  string         `db:"provider_id"`
	PlanIDs     pq.StringArray `db:"plan_ids"`
	Name        string         `db:"name"`
	Title       *string        `db:"title"`
	Description *string        `db:"description"`

	Behavior string             `db:"behavior"`
	Config   BehaviorConfig     `db:"config"`
	State    string             `db:"state"`
	Metadata types.NullJSONText `db:"metadata"`

	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"`
}

type Project

type Project struct {
	ID        string         `db:"id"`
	Name      string         `db:"name"`
	Title     sql.NullString `db:"title"`
	OrgID     string         `db:"org_id"`
	Metadata  []byte         `db:"metadata"`
	State     sql.NullString `db:"state"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
	DeletedAt sql.NullTime   `db:"deleted_at"`
}

type ProjectRepository

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

func NewProjectRepository

func NewProjectRepository(dbc *db.Client) *ProjectRepository

func (ProjectRepository) Create

func (ProjectRepository) Delete

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

func (ProjectRepository) GetByID

func (ProjectRepository) GetByName

func (r ProjectRepository) GetByName(ctx context.Context, name string) (project.Project, error)

func (ProjectRepository) List

func (ProjectRepository) SetState

func (r ProjectRepository) SetState(ctx context.Context, id string, state project.State) error

func (ProjectRepository) UpdateByID

func (ProjectRepository) UpdateByName

func (r ProjectRepository) UpdateByName(ctx context.Context, prj project.Project) (project.Project, error)

type Relation

type Relation struct {
	ID                   string         `db:"id"`
	SubjectNamespaceID   string         `db:"subject_namespace_name"`
	SubjectNamespace     Namespace      `db:"subject_namespace"`
	SubjectID            string         `db:"subject_id"`
	SubjectSubRelationID sql.NullString `db:"subject_subrelation_name"`
	ObjectNamespaceID    string         `db:"object_namespace_name"`
	ObjectNamespace      Namespace      `db:"object_namespace"`
	ObjectID             string         `db:"object_id"`
	RelationName         string         `db:"relation_name"`
	CreatedAt            time.Time      `db:"created_at"`
	UpdatedAt            time.Time      `db:"updated_at"`
	DeletedAt            sql.NullTime   `db:"deleted_at"`
}

type RelationRepository

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

func NewRelationRepository

func NewRelationRepository(dbc *db.Client) *RelationRepository

func (RelationRepository) DeleteByID

func (r RelationRepository) DeleteByID(ctx context.Context, id string) error

func (RelationRepository) Get

func (RelationRepository) GetByFields

func (RelationRepository) List

func (RelationRepository) ListByFields

func (r RelationRepository) ListByFields(ctx context.Context, rel relation.Relation) ([]relation.Relation, error)

func (RelationRepository) Upsert

func (r RelationRepository) Upsert(ctx context.Context, relationToCreate relation.Relation) (relation.Relation, error)

type Resource

type Resource struct {
	ID            string         `db:"id"`
	URN           string         `db:"urn"`
	Name          string         `db:"name"`
	Title         string         `db:"title"`
	ProjectID     string         `db:"project_id"`
	Project       Project        `db:"project"`
	Metadata      []byte         `db:"metadata"`
	NamespaceID   string         `db:"namespace_name"`
	Namespace     Namespace      `db:"namespace"`
	PrincipalID   sql.NullString `db:"principal_id"`
	PrincipalType sql.NullString `db:"principal_type"`
	CreatedAt     time.Time      `db:"created_at"`
	UpdatedAt     time.Time      `db:"updated_at"`
	DeletedAt     sql.NullTime   `db:"deleted_at"`
}

type ResourceCols

type ResourceCols struct {
	ID            string         `db:"id"`
	URN           string         `db:"urn"`
	Title         string         `db:"title"`
	Name          string         `db:"name"`
	ProjectID     string         `db:"project_id"`
	NamespaceID   string         `db:"namespace_name"`
	PrincipalID   sql.NullString `db:"principal_id"`
	PrincipalType sql.NullString `db:"principal_type"`
	Metadata      []byte         `db:"metadata"`
	CreatedAt     time.Time      `db:"created_at"`
	UpdatedAt     time.Time      `db:"updated_at"`
}

type ResourceRepository

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

func NewResourceRepository

func NewResourceRepository(dbc *db.Client) *ResourceRepository

func (ResourceRepository) Create

func (ResourceRepository) Delete

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

func (ResourceRepository) GetByID

func (ResourceRepository) GetByURN

func (ResourceRepository) List

func (ResourceRepository) Update

type Role

type Role struct {
	ID          string         `db:"id"`
	OrgID       string         `db:"org_id"`
	Name        string         `db:"name"`
	Title       sql.NullString `db:"title"`
	Permissions []byte         `db:"permissions"`
	State       string         `db:"state"`
	Scopes      pq.StringArray `db:"scopes"`
	Metadata    []byte         `db:"metadata"`
	CreatedAt   time.Time      `db:"created_at"`
	UpdatedAt   time.Time      `db:"updated_at"`
	DeletedAt   sql.NullTime   `db:"deleted_at"`
}

type RoleRepository

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

func NewRoleRepository

func NewRoleRepository(dbc *db.Client) *RoleRepository

func (RoleRepository) Delete

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

func (RoleRepository) Get

func (r RoleRepository) Get(ctx context.Context, id string) (role.Role, error)

func (RoleRepository) GetByName

func (r RoleRepository) GetByName(ctx context.Context, orgID, name string) (role.Role, error)

func (RoleRepository) List

func (r RoleRepository) List(ctx context.Context, flt role.Filter) ([]role.Role, error)

func (RoleRepository) Update

func (r RoleRepository) Update(ctx context.Context, rl role.Role) (role.Role, error)

func (RoleRepository) Upsert

func (r RoleRepository) Upsert(ctx context.Context, rl role.Role) (role.Role, error)

type ServiceUser

type ServiceUser struct {
	ID        string         `db:"id"`
	OrgID     string         `db:"org_id"`
	Title     sql.NullString `db:"title"`
	State     sql.NullString `db:"state"`
	Metadata  []byte         `db:"metadata"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
	DeletedAt sql.NullTime   `db:"deleted_at"`
}

type ServiceUserCredential

type ServiceUserCredential struct {
	ID            string         `db:"id"`
	ServiceUserID string         `db:"serviceuser_id"`
	Type          sql.NullString `db:"type"`
	SecretHash    sql.NullString `db:"secret_hash"`
	PublicKey     []byte         `db:"public_key"`
	Title         sql.NullString `db:"title"`
	Metadata      []byte         `db:"metadata"`
	CreatedAt     time.Time      `db:"created_at"`
	UpdatedAt     time.Time      `db:"updated_at"`
	DeletedAt     sql.NullTime   `db:"deleted_at"`
}

type ServiceUserCredentialRepository

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

func NewServiceUserCredentialRepository

func NewServiceUserCredentialRepository(dbc *db.Client) *ServiceUserCredentialRepository

func (ServiceUserCredentialRepository) Create

func (ServiceUserCredentialRepository) Delete

func (ServiceUserCredentialRepository) Get

func (ServiceUserCredentialRepository) List

type ServiceUserRepository

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

func NewServiceUserRepository

func NewServiceUserRepository(dbc *db.Client) *ServiceUserRepository

func (ServiceUserRepository) Create

func (ServiceUserRepository) Delete

func (s ServiceUserRepository) Delete(ctx context.Context, id string) error

func (ServiceUserRepository) GetByID

func (ServiceUserRepository) GetByIDs

GetByIDs returns a list of service users by their IDs.

func (ServiceUserRepository) List

type Session

type Session struct {
	ID              uuid.UUID `db:"id"`
	UserID          uuid.UUID `db:"user_id"`
	AuthenticatedAt time.Time `db:"authenticated_at"`
	ExpiresAt       time.Time `db:"expires_at"`
	Metadata        []byte    `db:"metadata"`
	CreatedAt       time.Time `db:"created_at"`
}

type SessionRepository

type SessionRepository struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

func NewSessionRepository

func NewSessionRepository(logger log.Logger, dbc *db.Client) *SessionRepository

func (*SessionRepository) Delete

func (s *SessionRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*SessionRepository) DeleteExpiredSessions

func (s *SessionRepository) DeleteExpiredSessions(ctx context.Context) error

func (*SessionRepository) Get

func (*SessionRepository) Set

func (*SessionRepository) UpdateValidity

func (s *SessionRepository) UpdateValidity(ctx context.Context, id uuid.UUID, validity time.Duration) error

type Subscription added in v0.8.0

type Subscription struct {
	ID             string `db:"id"`
	ProviderID     string `db:"provider_id"`
	SubscriptionID string `db:"customer_id"`
	PlanID         string `db:"plan_id"`

	State    string              `db:"state"`
	Metadata types.NullJSONText  `db:"metadata"`
	Changes  SubscriptionChanges `db:"changes"`

	CreatedAt            time.Time  `db:"created_at"`
	UpdatedAt            time.Time  `db:"updated_at"`
	CanceledAt           *time.Time `db:"canceled_at"`
	EndedAt              *time.Time `db:"ended_at"`
	DeletedAt            *time.Time `db:"deleted_at"`
	TrialEndsAt          *time.Time `db:"trial_ends_at"`
	CurrentPeriodStartAt *time.Time `db:"current_period_start_at"`
	CurrentPeriodEndAt   *time.Time `db:"current_period_end_at"`
	BillingCycleAnchorAt *time.Time `db:"billing_cycle_anchor_at"`
}

type SubscriptionChanges added in v0.8.19

type SubscriptionChanges struct {
	Phases      []Phase `json:"phases"`
	PlanHistory []Phase `json:"plan_history"`
}

func (*SubscriptionChanges) Scan added in v0.8.19

func (c *SubscriptionChanges) Scan(src interface{}) error

func (SubscriptionChanges) Value added in v0.8.19

func (c SubscriptionChanges) Value() (driver.Value, error)

type SubscriptionConfig added in v0.8.30

type SubscriptionConfig struct {
	SkipTrial        bool `db:"skip_trial" json:"skip_trial"`
	CancelAfterTrial bool `db:"cancel_after_trial" json:"cancel_after_trial"`
}

func (*SubscriptionConfig) Scan added in v0.8.30

func (s *SubscriptionConfig) Scan(src interface{}) error

func (SubscriptionConfig) Value added in v0.8.30

func (s SubscriptionConfig) Value() (driver.Value, error)

type Tax added in v0.9.0

type Tax struct {
	TaxIDs []customer.Tax `json:"taxids"`
}

func (*Tax) Scan added in v0.9.0

func (t *Tax) Scan(src interface{}) error

func (Tax) Value added in v0.9.0

func (t Tax) Value() (driver.Value, error)

type Transaction added in v0.8.0

type Transaction struct {
	ID          string             `db:"id"`
	AccountID   string             `db:"account_id"`
	Amount      int64              `db:"amount"`
	Type        string             `db:"type"`
	Source      string             `db:"source"`
	Description string             `db:"description"`
	UserID      *string            `db:"user_id"`
	Metadata    types.NullJSONText `db:"metadata"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

Transaction represents a transaction entry in the database. A transaction can be of type credit or debit, every change creates two entry in records. At the moment transfer of funds are only between customer account and system account, we don't need a transaction id. If we do to support transfer of amount between more than two accounts we can add a transaction id which will be same for all entries in a single transaction.

type User

type User struct {
	ID        string         `db:"id"`
	Name      string         `db:"name"`
	Email     string         `db:"email"`
	Title     sql.NullString `db:"title"`
	Avatar    sql.NullString `db:"avatar"`
	Metadata  []byte         `db:"metadata"`
	State     sql.NullString `db:"state"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
	DeletedAt sql.NullTime   `db:"deleted_at"`
}

type UserRepository

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

func NewUserRepository

func NewUserRepository(dbc *db.Client) *UserRepository

func (UserRepository) Create

func (r UserRepository) Create(ctx context.Context, usr user.User) (user.User, error)

func (UserRepository) Delete

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

func (UserRepository) GetByEmail

func (r UserRepository) GetByEmail(ctx context.Context, email string) (user.User, error)

func (UserRepository) GetByID

func (r UserRepository) GetByID(ctx context.Context, id string) (user.User, error)

func (UserRepository) GetByIDs

func (r UserRepository) GetByIDs(ctx context.Context, userIDs []string) ([]user.User, error)

func (UserRepository) GetByName

func (r UserRepository) GetByName(ctx context.Context, name string) (user.User, error)

func (UserRepository) List

func (r UserRepository) List(ctx context.Context, flt user.Filter) ([]user.User, error)

func (UserRepository) SetState

func (r UserRepository) SetState(ctx context.Context, id string, state user.State) error

func (UserRepository) UpdateByEmail

func (r UserRepository) UpdateByEmail(ctx context.Context, usr user.User) (user.User, error)

func (UserRepository) UpdateByID

func (r UserRepository) UpdateByID(ctx context.Context, usr user.User) (user.User, error)

func (UserRepository) UpdateByName

func (r UserRepository) UpdateByName(ctx context.Context, usr user.User) (user.User, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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