utils

package
v1.11.21 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package utils is a helper for working with ent policies

Index

Constants

View Source
const (

	// OrgEmailConditionName is the name of the condition for organization email domain checks
	OrgEmailConditionName = "email_domains_allowed"
	// OrgAccessCheckRelation is the relation for organization access checks
	OrgAccessCheckRelation = "access"
)

Context keys for authorization checks

Variables

This section is empty.

Functions

func AuthzClient added in v0.6.19

func AuthzClient(ctx context.Context, m generated.Mutation) *fgax.Client

AuthzClient returns the authz client from the context if it exists, otherwise it will attempt to get the client from the mutation if it implements the `MutationClient` interface

func AuthzClientFromContext added in v0.4.1

func AuthzClientFromContext(ctx context.Context) *fgax.Client

AuthzClientFromContext returns the authz client from the context if it exists this is useful when you need to get the client from the context directly

func ModulesEnabled added in v0.30.10

func ModulesEnabled(client *generated.Client) bool

ModulesEnabled checks if the modules feature is enabled for the given client

func NewMutationPolicyWithoutNil

func NewMutationPolicyWithoutNil(source privacy.MutationPolicy) privacy.MutationPolicy

NewMutationPolicyWithoutNil is creating a new slice of `privacy.MutationPolicy` by removing any `nil` values from the input `source` slice. It iterates over each item in the source slice and appends it to the new slice only if it is not `nil` - the new slice is then returned

func NewOrganizationConditionContext added in v0.7.0

func NewOrganizationConditionContext(domains []string) *map[string]any

NewOrganizationConditionContext creates a new context key for organization condition checks

func NewOrganizationContextKey added in v0.7.0

func NewOrganizationContextKey(e string) *map[string]any

NewOrganizationContextKey creates a new context key for organization checks if the full email is provided it will take the domain after the `@` symbol

func PaymentMethodCheckRequired added in v0.41.1

func PaymentMethodCheckRequired(client *generated.Client) bool

PaymentMethodCheckRequired checks if the config requires orgs to have a valid payment method in stripe

Types

type GenericMutation added in v0.27.0

type GenericMutation interface {
	ID() (id string, exists bool)
	IDs(ctx context.Context) ([]string, error)
	Type() string
	Op() ent.Op
	Client() *generated.Client
	Field(name string) (ent.Value, bool)
	Fields() []string
	ClearedFields() []string
}

GenericMutation is an interface for getting a mutation ID and type

type MutationClient added in v0.6.19

type MutationClient interface {
	Client() *generated.Client
}

MutationClient is an interface that can be implemented by a mutation to return the ent client

Jump to

Keyboard shortcuts

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