hooks

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 175 Imported by: 0

Documentation

Overview

Package hooks is middleware to alter the graphql mutation

this file calls the generated edge and history cleanup functions, which are excluded from compilation during code generation because they reference history packages that may not be generated yet, so this file must be excluded during codegen

Index

Constants

View Source
const (
	// AdminsGroup is the group name for all organization admins, super admins, and owners.
	// These users have full read and write access in the organization.
	AdminsGroup = "Admins"
	// ViewersGroup is the group name for all organization members that only have view access in the organization
	ViewersGroup = "Viewers"
	// AllMembersGroup is the group name for all members of the organization, no matter their role
	AllMembersGroup = "All Members"
)
View Source
const MaxFileBackupAttempts = 5

MaxFileBackupAttempts caps replication retries before a file is marked exhausted

Variables

View Source
var (
	// ErrCustomEnumCreationFailed is returned when a custom enum value does not exist but is attempted to be set
	ErrCustomEnumCreationFailed = errors.New("enum value does not exist")
	// ErrCustomEnumInUse is returned when a custom enum is in use and cannot be deleted
	ErrCustomEnumInUse = errors.New("enum is in use")
	// ErrInvalidGlobalEnumField is returned when creating a global enum with an invalid field
	ErrInvalidGlobalEnumField = errors.New("invalid global enum field")
)
View Source
var (
	// ErrInternalServerError is returned when an internal error occurs.
	ErrInternalServerError = errors.New("internal server error")
	// ErrInvalidInput is returned when the input is invalid.
	ErrInvalidInput = errors.New("invalid input")
	// ErrPersonalOrgsNoChildren is returned when personal org attempts to add a child org
	ErrPersonalOrgsNoChildren = errors.New("personal organizations are not allowed to have child organizations")
	// ErrPersonalOrgsNoMembers is returned when personal org attempts to add members
	ErrPersonalOrgsNoMembers = errors.New("personal organizations are not allowed to have members other than the owner")
	// ErrOrgOwnerCannotBeDeleted is returned when an org owner is attempted to be deleted
	ErrOrgOwnerCannotBeDeleted = errors.New("organization owner cannot be deleted, it must be transferred to a new owner first")
	// ErrOrgOwnerCannotBeUpdated is returned when an org owner role is attempted to be changed directly via mutations
	ErrOrgOwnerCannotBeUpdated = errors.New("organization owner role cannot be changed directly, it must be transferred")
	// ErrPersonalOrgsNoUser is returned when personal org has no user associated, so no permissions can be added
	ErrPersonalOrgsNoUser = errors.New("personal organizations missing user association")
	// ErrUserNotInOrg is returned when a user is not a member of an organization when trying to add them to a group
	ErrUserNotInOrg = errors.New("user not in organization")
	// ErrUnsupportedFGARole is returned when a role is assigned that is not supported in our fine grained authorization system
	ErrUnsupportedFGARole = errors.New("unsupported role")
	// ErrMissingRole is returned when an update request is made that contains no role
	ErrMissingRole = errors.New("missing role in update")
	// ErrUserAlreadyOrgMember is returned when an user attempts to be invited to an org they are already a member of
	ErrUserAlreadyOrgMember = errors.New("user already member of organization")
	// ErrUserAlreadySubscriber is returned when an user attempts to subscribe to an organization but is already a subscriber
	ErrUserAlreadySubscriber = errors.New("subscriber already exists")
	// ErrEmailRequired is returned when an email is required but not provided
	ErrEmailRequired = errors.New("email is required but not provided")
	// ErrMaxAttempts is returned when a user has reached the max attempts to resend an invitation to an org
	ErrMaxAttempts = errors.New("too many attempts to resend org invitation")
	// ErrMaxAttemptsAssessments is returned when a user has reached the max attempts to resend an assessment
	ErrMaxAttemptsAssessments = errors.New("too many attempts to resend assessment invitation")
	// ErrMaxSubscriptionAttempts is returned when a user has reached the max attempts to subscribe to an org
	ErrMaxSubscriptionAttempts = errors.New("too many attempts to resend org subscription email")
	// ErrSubscribersNotAllowed is returned when a trust center is not accepting new subscribers
	ErrSubscribersNotAllowed = errors.New("trust center is not accepting new subscribers")
	// ErrAssessmentInCompleted is returned when attempting to resend an email for an assessment that is already completed
	ErrAssessmentInCompleted = errors.New("assessment is already completed")
	// ErrMissingRecipientEmail is returned when an email is required but not provided
	ErrMissingRecipientEmail = errors.New("recipient email is required but not provided")
	// ErrMissingRequiredName is returned when a name is required but not provided
	ErrMissingRequiredName = errors.New("name or display name is required but not provided")
	// ErrTooManyAvatarFiles is returned when a user attempts to upload more than one avatar file
	ErrTooManyAvatarFiles = errors.New("too many avatar files uploaded, only one is allowed")
	// ErrNoControls is returned when a subcontrol has no controls assigned
	ErrNoControls = errors.New("subcontrol must have at least one control assigned")
	// ErrUnableToCast is returned when a type assertion fails
	ErrUnableToCast = errors.New("unable to cast")
	// ErrNoSubscriptions is returned when an organization has no subscriptions
	ErrNoSubscriptions = errors.New("organization has no subscriptions")
	// ErrTooManySubscriptions is returned when an organization has too many subscriptions
	ErrTooManySubscriptions = errors.New("organization has too many subscriptions")
	// ErrTooManyPrices is returned when an organization has too many subscriptions
	ErrTooManyPrices = errors.New("organization has too many prices on a subscription")
	// ErrNoPrices is returned when a subscription has no price
	ErrNoPrices = errors.New("subscription has no price")
	// ErrManagedGroup is returned when a user attempts to modify a managed group
	ErrManagedGroup = errors.New("managed groups cannot be modified")
	// ErrMaxAttemptsOrganization is returned when the max attempts have been reached to create an organization via onboarding
	ErrMaxAttemptsOrganization = errors.New("too many attempts to create organization")
	// ErrUserNotFound is returned when a user is not found in the system
	ErrUserNotFound = errors.New("user not found")
	// ErrCronRequired is returned when a user does not provide a cron expression
	ErrCronRequired = errors.New("cron expression must be specified")
	// ErrZeroTimeNotAllowed is returned when you try to set a non usable time value
	ErrZeroTimeNotAllowed = errors.New("time cannot be empty. Provide a valid time/date")
	// ErrFutureTimeNotAllowed is returned when you try to set a time into the future.
	// future being any second/minute past the current time of validation
	ErrFutureTimeNotAllowed = errors.New("time cannot be in the future")
	// ErrPastTimeNotAllowed is returned when you try to set a time into the past.
	ErrPastTimeNotAllowed = errors.New("time cannot be in the past")
	// ErrFieldRequired is returned when a field is required but not provided
	ErrFieldRequired = errors.New("field is required but not provided")
	// ErrOwnerIDNotExists is returned when an owner_id cannot be found
	ErrOwnerIDNotExists = errors.New("owner_id is required")
	// ErrArchivedProgramUpdateNotAllowed is returned when an archived program is updated. It only
	// allows updates if the status is changed
	ErrArchivedProgramUpdateNotAllowed = errors.New("you cannot update an archived program")
	// ErrNotSingularUpload is returned when a user is importing content to create a schema
	// and they upload more than one file
	ErrNotSingularUpload = errors.New("multiple uploads not supported")
	// ErrSSONotEnforceable makes sure the connection has been tested before it can be enforced for an org
	ErrSSONotEnforceable = errors.New("you cannot enforce sso without testing the connection works correctly")
	// ErrUnableToDetermineEventID is returned when we cannot determine the event ID for an event
	ErrUnableToDetermineEventID = errors.New("unable to determine event ID")
	// ErrNotSingularTrustCenter is returned when an org is trying to create multiple trust centers
	ErrNotSingularTrustCenter = errors.New("you can only create/manage one trust center at a time")
	// ErrStatusApprovedNotAllowed is returned when a user attempts to set status to APPROVED without being in the approver or delegate group
	ErrStatusApprovedNotAllowed = errors.New("you must be in the approver group to mark as approved")
	// ErrInvalidChannel is returned when an invalid notification channel is provided
	ErrInvalidChannel = errors.New("invalid channel")
	// ErrTemplateIDRequired is returned when an assessment is created without a template
	ErrTemplateIDRequired = errors.New("template id required when creating an assessment")
	// ErrTemplateNotFound is returned when an assessment is created with a non existing template
	ErrTemplateNotFound = errors.New("template does not exist")
	// ErrTemplateNotQuestionnaire is returned when an assessment tries to use a wrong template type
	ErrTemplateNotQuestionnaire = errors.New("template must be a questionnaire")
	// ErrTrustCenterIDRequired is returned when the trustcenter id is not provided
	// when creating a customer for the trust center
	ErrTrustCenterIDRequired = errors.New("trustcenter entity must include a trustcenter id")
	// ErrUnableToCreateContact is returned when a contact could not be created
	ErrUnableToCreateContact = errors.New("unable to create a contact")
	// ErrUnableToCreateAssessmentResponse is returned when an assessment response could not be created
	ErrUnableToCreateAssessmentResponse = errors.New("unable to create assessment response")
	// ErrTooManyLogoFiles is returned when a user attempts to upload more than one logo file
	ErrTooManyLogoFiles = errors.New("too many logo files uploaded, only one is allowed")
	// ErrTooManyFaviconFiles is returned when a user attempts to upload more than one favicon file
	ErrTooManyFaviconFiles = errors.New("too many favicon files uploaded, only one is allowed")
	// ErrTooManyHeroImageFiles is returned when a user attempts to upload more than one hero image file
	ErrTooManyHeroImageFiles = errors.New("too many hero image files uploaded, only one is allowed")
	// ErrMissingTrustCenterID is returned when a trust center id is required but not provided
	ErrMissingTrustCenterID = errors.New("trust center id is required")
	// ErrMissingFileID is returned when a file id is required but not provided
	ErrMissingFileID = errors.New("missing file id")
	// ErrCannotSetFileOnCreate is returned when trying to set a file id on create mutations
	ErrCannotSetFileOnCreate = errors.New("cannot set file id on create")
	// ErrCacheRefreshFailed is returned when the cache refresh request fails
	ErrCacheRefreshFailed = errors.New("cache refresh request failed")
	// ErrNoOrganizationID is returned when no organization ID is found in context
	ErrNoOrganizationID = errors.New("no valid organization ID found")
	// ErrNDATemplateRequired is returned when nda requests mutation runs but there is no file for the
	// user to sign
	ErrNDATemplateRequired = errors.New("you need a nda template before a request can be made")
	// ErrMutationMissingID is returned when a mutation does not have an ID
	ErrMutationMissingID = errors.New("mutation missing ID")
	// ErrProposedChangesNotSupported is returned when proposed changes are not supported for a schema type
	ErrProposedChangesNotSupported = errors.New("proposed changes not supported for this schema type")
	// ErrFailedToGetUserFromContext is returned when the user cannot be resolved from the context
	ErrFailedToGetUserFromContext = errors.New("failed to get user from context")
	// ErrFailedToGetObjectOwnerID is returned when the owner id cannot be resolved for a workflow object
	ErrFailedToGetObjectOwnerID = errors.New("failed to get object owner id")
	// ErrFailedToQueryObjectRefs is returned when workflow object refs cannot be queried
	ErrFailedToQueryObjectRefs = errors.New("failed to query object refs")
	// ErrFailedToComputeProposalHash is returned when a workflow proposal hash cannot be computed
	ErrFailedToComputeProposalHash = errors.New("failed to compute proposal hash")
	// ErrFailedToQueryExistingProposal is returned when an existing proposal cannot be queried
	ErrFailedToQueryExistingProposal = errors.New("failed to query existing proposal")
	// ErrFailedToUpdateProposal is returned when a workflow proposal cannot be updated
	ErrFailedToUpdateProposal = errors.New("failed to update proposal")
	// ErrFailedToBeginTransaction is returned when a workflow transaction cannot be started
	ErrFailedToBeginTransaction = errors.New("failed to begin transaction")
	// ErrFailedToCreateWorkflowInstance is returned when a workflow instance cannot be created
	ErrFailedToCreateWorkflowInstance = errors.New("failed to create workflow instance")
	// ErrFailedToCreateWorkflowObjectRef is returned when a workflow object ref cannot be created
	ErrFailedToCreateWorkflowObjectRef = errors.New("failed to create workflow object ref")
	// ErrFailedToCreateWorkflowProposal is returned when a workflow proposal cannot be created
	ErrFailedToCreateWorkflowProposal = errors.New("failed to create workflow proposal inside of ent hooks")
	// ErrFailedToCreateWorkflowProposal is returned when a workflow proposal cannot be created
	ErrFailedToUpdateWorkflowProposal = errors.New("failed to update workflow proposal inside of ent hooks")
	// ErrFailedToLinkProposalToInstance is returned when a proposal cannot be linked to an instance
	ErrFailedToLinkProposalToInstance = errors.New("failed to link proposal to instance")
	// ErrFailedToCommitProposalTransaction is returned when proposal staging transaction cannot be committed
	ErrFailedToCommitProposalTransaction = errors.New("failed to commit proposal transaction")
	// ErrFailedToQueryAssignments is returned when workflow assignments cannot be queried
	ErrFailedToQueryAssignments = errors.New("failed to query assignments")
	// ErrFailedToInvalidateAssignment is returned when an assignment cannot be invalidated
	ErrFailedToInvalidateAssignment = errors.New("failed to invalidate assignment")
	// ErrWorkflowProposalMissingObjectRef is returned when a proposal is missing its object ref edge
	ErrWorkflowProposalMissingObjectRef = errors.New("workflow proposal missing object ref")
	// ErrFailedToDeriveObjectFromRef is returned when a workflow object cannot be derived from a ref
	ErrFailedToDeriveObjectFromRef = errors.New("failed to derive object from ref")
	// ErrFailedToLoadWorkflowObject is returned when a workflow object cannot be loaded
	ErrFailedToLoadWorkflowObject = errors.New("failed to load workflow object")
	// ErrFailedToFindMatchingDefinitions is returned when workflow definitions cannot be matched
	ErrFailedToFindMatchingDefinitions = errors.New("failed to find matching definitions")
	// ErrFailedToRecordAssignmentInvalidationEvent is returned when assignment invalidation events cannot be recorded
	ErrFailedToRecordAssignmentInvalidationEvent = errors.New("failed to record assignment invalidation event")
	// ErrFailedToResolveInvalidationNotificationOwner is returned when the owner for invalidation notifications cannot be resolved
	ErrFailedToResolveInvalidationNotificationOwner = errors.New("failed to resolve invalidation notification owner")
	// ErrFailedToSendInvalidationNotification is returned when invalidation notifications cannot be sent
	ErrFailedToSendInvalidationNotification = errors.New("failed to send invalidation notification")
	// ErrFailedToQueryWorkflowProposal is returned when a workflow proposal cannot be queried
	ErrFailedToQueryWorkflowProposal = errors.New("failed to query workflow proposal")
	// ErrFailedToQueryWorkflowInstances is returned when workflow instances cannot be queried
	ErrFailedToQueryWorkflowInstances = errors.New("failed to query workflow instances")
	// ErrFailedToLoadWorkflowProposalForTrigger is returned when a submitted proposal cannot be loaded for triggering
	ErrFailedToLoadWorkflowProposalForTrigger = errors.New("failed to load workflow proposal for trigger")
	// ErrFailedToResumeWorkflowInstance is returned when a workflow instance cannot be resumed
	ErrFailedToResumeWorkflowInstance = errors.New("failed to resume workflow instance")
	// ErrFailedToTriggerWorkflow is returned when a workflow cannot be triggered
	ErrFailedToTriggerWorkflow = errors.New("failed to trigger workflow")
	// ErrMissingIDForTrustCenterNDARequest is returned when a mutation for trust center nda request is missing the ID field, which is required to determine the trust center and send the appropriate email
	ErrMissingIDForTrustCenterNDARequest = errors.New("missing ID for trust center NDA request mutation")
	// ErrVendorScoringQuestionNotFound is returned when a question key cannot be resolved in the scoring config
	ErrVendorScoringQuestionNotFound = errors.New("vendor scoring question not found in config")
	// ErrStartDateLaterThanEndDate is returned when a program mutation has a start date that is later than the end date
	ErrStartDateLaterThanEndDate = errors.New("mutation's start date cannot be later than end date")
	// ErrFailedToGetOldEndDate is returned when a program mutation's old end date cannot be retrieved, which is necessary to validate that the start date is not later than the old end date
	ErrFailedToGetOldEndDate = errors.New("could not get old end date for mutation")
	// ErrFailedToGetStartDate is returned when a program mutation's start date cannot be retrieved, which is necessary to validate that the old start date is not later than the end date
	ErrFailedToGetOldStartDate = errors.New("could not get old start date for mutation")
	// ErrFailedToGetProgramByID is returned when a program cannot be retrieved by ID when updating
	ErrFailedToGetProgramByID = errors.New("could not get program by id when updating")
	// ErrFailedToGetIdsForProgramUpdate is returned when a program mutation's ids cannot be retrieved, which is necessary to validate bulk updates
	ErrFailedToGetIDsForProgramUpdate = errors.New("could not get ids for mutation program update")
	// ErrInvalidTemplateDefaults is returned when template defaults do not satisfy the template's jsonconfig schema
	ErrInvalidTemplateDefaults = errors.New("template defaults do not satisfy the template schema")
	// ErrMissingNDATemplateFile is returned when the NDA template has no attached file for attestation
	ErrMissingNDATemplateFile = errors.New("NDA template must have at least one attached file")

	// ErrFailedToUploadAttestedPDF is returned when the attested NDA PDF upload fails
	ErrFailedToUploadAttestedPDF = errors.New("failed to upload attested PDF")
	// ErrNoUploadedFiles is returned when the upload pipeline returns zero files
	ErrNoUploadedFiles = errors.New("no files returned from upload")
	// ErrFailedToAssociateFile is returned when linking an uploaded file to its document data record fails
	ErrFailedToAssociateFile = errors.New("failed to associate file with document data")
	// ErrFailedToFetchNDATemplate is returned when the NDA template cannot be queried
	ErrFailedToFetchNDATemplate = errors.New("failed to fetch NDA template")
	// ErrFailedToFetchNDATemplateFiles is returned when the template's file edges cannot be loaded
	ErrFailedToFetchNDATemplateFiles = errors.New("failed to fetch NDA template files")
	// ErrFailedToMarshalDocumentData is returned when document data cannot be serialized to JSON
	ErrFailedToMarshalDocumentData = errors.New("failed to marshal document data")
	// ErrFailedToUnmarshalNDAMetadata is returned when document data JSON cannot be deserialized into the NDA struct
	ErrFailedToUnmarshalNDAMetadata = errors.New("failed to unmarshal NDA metadata")
	// ErrFailedToDownloadNDAPDF is returned when the original NDA PDF cannot be downloaded from storage
	ErrFailedToDownloadNDAPDF = errors.New("failed to download original NDA PDF")
	// ErrFailedToCreateAttestedPDF is returned when appending the attestation page to the PDF fails
	ErrFailedToCreateAttestedPDF = errors.New("failed to create attested PDF")
	// ErrFailedToFetchTrustCenter is returned when the trust center record cannot be queried
	ErrFailedToFetchTrustCenter = errors.New("failed to fetch trust center")
	// ErrFailedToCreateAttestationCert is returned when generating the attestation certificate PDF page fails
	ErrFailedToCreateAttestationCert = errors.New("failed to create attestation certificate")
	// ErrFailedToMergeAttestationPage is returned when merging the attestation page into the original PDF fails
	ErrFailedToMergeAttestationPage = errors.New("failed to merge attestation page")
	// ErrFailedToGenerateAttestationPDF is returned when the attestation PDF output fails
	ErrFailedToGenerateAttestationPDF = errors.New("failed to generate attestation PDF")
	// ErrInvalidScope is returned when a scope is not assignable to service subjects
	ErrInvalidScope = errors.New("scope is not assignable to service subjects")
	// ErrMissingTaskTemplate indicates a rule fired but no taskrules.Template is registered for it
	ErrMissingTaskTemplate = errors.New("entityops: missing task template")
	// ErrExpressionNotList indicates an EachElement expression evaluated to a non-list value
	ErrExpressionNotList = errors.New("entityops: expression did not evaluate to a list")
	// ErrQuestionnaireTransformInvalid is returned when a questionnaire transform configuration or submission cannot map to its target
	ErrQuestionnaireTransformInvalid = errors.New("questionnaire transform invalid")
	// ErrClientResolveFailed indicates the ent client could not be resolved from the context
	ErrClientResolveFailed = errors.New("client resolve failed")
)
View Source
var (
	// ErrPublicStandardCannotBeDeleted defines an error that denotes a public standard cannot be
	// deleted once made public
	ErrPublicStandardCannotBeDeleted = errors.New("public standard not allowed to be deleted")
	// ErrStandardInUseByControls defines an error that denotes a standard cannot be deleted
	// because it is in use by active controls in the system
	ErrStandardInUseByControls = errors.New("standard cannot be deleted because it is in use by one or more controls")
	// ErrStandardInUseByTrustCenter defines an error that denotes a standard cannot be deleted
	// because it is in use by an active trust center
	ErrStandardInUseByTrustCenter = errors.New("standard cannot be deleted because it is in use by a trust center")
	// ErrSystemOwnedStandardCannotBeDeleted defines an error that denotes a system-owned standard
	// can only be deleted by a system admin
	ErrSystemOwnedStandardCannotBeDeleted = errors.New("system-owned standard can only be deleted by a system admin")
)
View Source
var (
	// ErrTagDefinitionInUse is returned when a tag definition is in use and cannot be deleted
	ErrTagDefinitionInUse = errors.New("tag definition is in use")
	// ErrTagDefinitionInUse is returned when there is a db level error fetching all org owned tags
	ErrTagsNotFetched = errors.New("an error occurred while fetching all tags")
)
View Source
var ErrFileBackupExhausted = errors.New("file backup exhausted max attempts")

ErrFileBackupExhausted marks a replication that hit the attempt cap and will not be retried

View Source
var ErrTextContainsComments = errors.New("text contains comments, unable to set description due to potential loss of data in conversion")

ErrTextContainsComments is returned when attempting to set a text field with a corresponding JSON field that contains comments, this will cause the comment links to be lost in conversion and is not allowed

View Source
var FileBackupTopic = gala.NamespacedTopic(gala.System, "file.backup.requested",
	gala.WithUniqueKey(func(req FileBackupRequest) string {
		return "file-backup-" + req.FileID
	}),
)

FileBackupTopic carries explicit replication requests to enable backfill of backups

Functions

func AddOrDeletePublicStandardTuple

func AddOrDeletePublicStandardTuple(ctx context.Context, m *generated.StandardMutation) (bool, bool, error)

AddOrDeletePublicStandardTuple determines whether to add or delete a standard tuple based on the mutation operation and field values.

Parameters: - ctx: The context for the operation. - m: The StandardMutation containing the mutation details.

Returns: - add: A boolean indicating whether to add the tuple. - delete: A boolean indicating whether to delete the tuple. - err: An error if any occurred during the operation.

The function handles the following mutation operations: - OpCreate: Adds the tuple if both systemOwned and isPublic are true. - OpDelete, OpDeleteOne: Deletes the tuple. - OpUpdateOne: Deletes the tuple if it's a soft delete or if isPublic fields has changed. Adds the tuple if both fields are true. - OpUpdate: Deletes the tuple if isPublic field has been cleared. Adds the tuple if both fields are true.

func AllListeners added in v2.4.1

func AllListeners() []gala.Registration

AllListeners builds the registrations for every listener family in this package; the constructors run on each call so they observe the current schema registry

func AuthEnforcementAttribution

func AuthEnforcementAttribution() ent.Hook

AuthEnforcementAttribution stamps the grantor and timestamp when a membership's SSO exemption or TFA enforcement is set, and clears the attribution and reason when the policy is removed. The grantor defaults to the acting caller when it is not explicitly provided by the mutation, which lets API driven grants record who performed the change while server driven flows can attribute it to a specific user

func CampaignRecurringListeners

func CampaignRecurringListeners() []gala.Registration

CampaignRecurringListeners keeps recurring campaign scheduling in sync when activation or recurrence fields change

func ControlVisibilityTupleAction

func ControlVisibilityTupleAction(newVisibility, oldVisibility enums.TrustCenterControlVisibility, visibilityChanged bool) (shouldWrite, shouldDelete bool)

ControlVisibilityTupleAction determines whether wildcard viewer tuples should be written or deleted based on the trust center visibility state of a control. The caller is responsible for ensuring this is only called for trust center controls.

func DocumentAssociationListeners

func DocumentAssociationListeners() []gala.Registration

DocumentAssociationListeners links controls referenced in a new document's details

func DomainScanListeners

func DomainScanListeners() []gala.Registration

DomainScanListeners submits pending domain scans and requests scans for changed organization domains

func EmitGalaEventHook

func EmitGalaEventHook(runtimes ...*gala.Gala) ent.Hook

EmitGalaEventHook returns a hook that emits Gala mutation envelopes after mutations. Runtimes are deduplicated once at installation; a mutation fans out to every concern topic each runtime has an interested listener for, one envelope per mutated row

func EntitlementListeners

func EntitlementListeners() []gala.Registration

EntitlementListeners keeps Stripe customers and subscriptions in sync with organization lifecycle and billing changes

func FileBackupListeners added in v2.4.1

func FileBackupListeners() []gala.Registration

FileBackupListeners replicates a file to its configured backup provider once the file's storage location has been written

func GetObjectIDFromEntValue

func GetObjectIDFromEntValue(m ent.Value) (string, error)

GetObjectIDFromEntValue extracts the object id from a generic ent value return type this function should be called after the mutation has been successful

func GetObjectIDsFromMutation

func GetObjectIDsFromMutation(ctx context.Context, m utils.GenericMutation, v ent.Value) ([]string, error)

GetObjectIDsFromMutation gets the object ids from the mutation, if it is a create it will use the ent.Value to get the id, requiring the mutation be executed first For updates, it will use the `IDs()` function to get the IDs by querying the database and returning the entity ids that match the mutation's predicate.

func GetObjectTypeFromEntMutation

func GetObjectTypeFromEntMutation(m ent.Mutation) string

GetObjectTypeFromEntMutation gets the object type from the ent mutation

func GetTuplesToAdd

func GetTuplesToAdd(ctx context.Context, m ent.Mutation, tr fgax.TupleRequest, edgeField string) ([]fgax.TupleKey, error)

GetTuplesToAdd is the generic function to get the tuples that need to be added to the authz service based on the edges that were added it is recommend to use the helper functions that call this instead of calling this directly for example, to add a parent relationship, use createParentTuples, or for an org owner relationship, use createOrgOwnerParentTuple this takes in the tuple request and sets the subject and subject id based on the edge field and tuple set relation

func HookAssetCreate

func HookAssetCreate() ent.Hook

HookAssetCreate sets the display name for assets everytime one is created

func HookBillingEmailChange

func HookBillingEmailChange() ent.Hook

HookBillingEmailChange is triggered when the billing_email field is updated on an organization setting.

func HookBlockOwnerRoleChange

func HookBlockOwnerRoleChange() ent.Hook

HookBlockOwnerRoleChange blocks direct owner role changes and enforces it goes through the transfer route

func HookCampaignTargetLinkUser

func HookCampaignTargetLinkUser() ent.Hook

HookCampaignTargetLinkUser links campaign targets to existing users by email.

func HookContact

func HookContact() ent.Hook

HookContact runs on contact create mutations

func HookControlImplementation

func HookControlImplementation() ent.Hook

HookControlImplementation sets default values for the control implementation

func HookControlReferenceFramework

func HookControlReferenceFramework() ent.Hook

HookControlReferenceFramework runs on control mutations to set the reference framework based on the standard's short name

func HookControlTrustCenterVisibility

func HookControlTrustCenterVisibility() ent.Hook

HookControlTrustCenterVisibility manages FGA wildcard viewer tuples when the trust_center_visibility field changes on a control, enabling or revoking anonymous public access based on the visibility state

func HookCreateAPIToken

func HookCreateAPIToken() ent.Hook

HookCreateAPIToken runs on api token mutations and sets the owner id

func HookCreateAssessmentResponse

func HookCreateAssessmentResponse() ent.Hook

HookCreateAssessmentResponse sends the email to the user to fill in and input their data. It also makes sure to bump up the send attempts if needed. The hook is idempotent: multiple create calls for the same assessment/email/campaign combination will update the existing record rather than creating duplicates.

func HookCreateCustomDomain

func HookCreateCustomDomain() ent.Hook

HookCustomDomain runs on create mutations

func HookCreatePersonalAccessToken

func HookCreatePersonalAccessToken() ent.Hook

HookCreatePersonalAccessToken runs on access token mutations and sets the owner id

func HookCreateTrustCenterDoc

func HookCreateTrustCenterDoc() ent.Hook

HookCreateTrustCenterDoc is an ent hook that processes file uploads and sets appropriate fields and permissions on create

func HookCustomEnums

func HookCustomEnums(in CustomEnumFilter) ent.Hook

HookCustomEnums ensures that a custom enum value exists for the given object type and field It looks up the enum by name and sets the corresponding edge field on the mutation

func HookCustomTypeEnumCreate

func HookCustomTypeEnumCreate() ent.Hook

HookCustomTypeEnumCreate validates that the object_type and field combination is valid

func HookCustomTypeEnumDelete

func HookCustomTypeEnumDelete() ent.Hook

HookCustomTypeEnumDelete checks if the enum(s) being deleted is in use by any other object. If in use, the deletion cannot proceed

func HookDNSVerificationDelete

func HookDNSVerificationDelete() ent.Hook

HookDNSVerificationDelete cleans up preview domain DNS records when a verification record is deleted

func HookDeleteCustomDomain

func HookDeleteCustomDomain() ent.Hook

HookDeleteCustomDomain runs on single and bulk deletions.

func HookDeleteDiscussion

func HookDeleteDiscussion() ent.Hook

HookDeleteDiscussionDelete deletes the discussion when the last comment is deleted

func HookDeletePermissions

func HookDeletePermissions() ent.Hook

HookDeletePermissions is an ent hook that deletes all relationship tuples associated with an object on either delete or soft-delete operations

func HookDeleteUser

func HookDeleteUser() ent.Hook

HookDeleteUser runs on user deletions to clean up personal organizations

func HookDetailsVersion

func HookDetailsVersion() ent.Hook

HookDetailsVersion is an ent hook that parses the versions from the details of a document creation

func HookDirectoryAccountDelete

func HookDirectoryAccountDelete() ent.Hook

HookDirectoryAccountDelete syncs identity holder email aliases after a directory account is removed, since the async listener cannot look up the deleted row

func HookDocumentDataFile

func HookDocumentDataFile() ent.Hook

HookDocumentDataFile handles file uploads and attaches them to document data. restricted to system admins updating NDA documents only for now in riverqueue. the old/regular case of adding FileIDs to mutations will still be accepted for non admins.

func HookDocumentDataTrustCenterNDA

func HookDocumentDataTrustCenterNDA() ent.Hook

HookDocumentDataTrustCenterNDA runs on document data create mutations to ensure trust center NDA document submissions are valid

func HookEdgePermissions

func HookEdgePermissions() ent.Hook

HookEdgePermissions runs on edge mutations to ensure the user has access to the object they are trying to add for edges. It uses the accessmap generated to get the object type and checks if the user has access to it.

func HookEmailTemplateSanitize

func HookEmailTemplateSanitize() ent.Hook

HookEmailTemplateSanitize sanitizes customer-supplied fields on email template create and update mutations. String values in the defaults map are scrubbed of HTML tags to prevent stored XSS; Go template expressions like {{ .companyName }} pass through unmodified since they are not HTML

func HookEmailValidation

func HookEmailValidation() ent.Hook

HookEmailValidation runs on user mutations to validate email addresses to ensure they meet the configured criteria which could include checks for disposable, free, or role-based emails. Additionally, it can set a default avatar using Gravatar if no avatar is provided during user creation. This hook only accepts mutations that implement the MutationWithEmail interface or are Invite mutations, which used the recipient field.

func HookEmailVerificationToken

func HookEmailVerificationToken() ent.Hook

HookEmailVerificationToken runs on email verification mutations and sets expires

func HookEnableTFA

func HookEnableTFA() ent.Hook

HookEnableTFA is a hook that generates the tfa secrets if the totp setting is set to allowed

func HookEntityApprovedForUse

func HookEntityApprovedForUse() ent.Hook

HookEntityApprovedForUse sets approved_for_use based on the entity status.

func HookEntityCreate

func HookEntityCreate() ent.Hook

HookEntityCreate runs on entity mutations to set default values that are not provided

func HookEntityFiles

func HookEntityFiles() ent.Hook

HookEntityFiles runs on entity mutations to check for uploaded files

func HookEntityLogoFile

func HookEntityLogoFile() ent.Hook

HookEntityLogoFile runs on entity mutations to check for an uploaded logo file

func HookEvidenceFiles

func HookEvidenceFiles() ent.Hook

HookEvidenceFiles runs on evidence mutations to check for uploaded files

func HookEvidenceReviewDate

func HookEvidenceReviewDate() ent.Hook

HookEvidenceReviewDate runs on evidence mutations and calculate the next review time based on creation date + review frequency

func HookExport

func HookExport() ent.Hook

func HookExtractNotificationTemplateVariables

func HookExtractNotificationTemplateVariables() ent.Hook

HookExtractNotificationTemplateVariables parses template content fields on create and update, extracts Go template variable references, and merges them as properties into jsonconfig. Existing jsonconfig properties are preserved; only newly discovered variables are added. System-reserved field names (CompanyName, Recipient, URLS, etc.) are filtered out so jsonconfig only describes user-supplied inputs. When defaults are also set in the mutation, they are validated against the finalized schema.

func HookFileDelete

func HookFileDelete() ent.Hook

HookFileDelete makes sure to clean up the file from external storage once deleted

func HookFileDownloadToken

func HookFileDownloadToken() ent.Hook

HookPasswordResetToken runs on reset token mutations and sets expires

func HookGroup

func HookGroup() ent.Hook

HookGroup runs on group mutations to set default values that are not provided

func HookGroupAuthz

func HookGroupAuthz() ent.Hook

HookGroupAuthz runs on group mutations to setup or remove relationship tuples

func HookGroupMembers

func HookGroupMembers() ent.Hook

HookGroupMembers checks the users role, ensures they are a member of the org, and prevents direct modifications to managed groups unless the caller has the bypass capability

func HookGroupPermissionsTuples

func HookGroupPermissionsTuples() ent.Hook

HookGroupPermissionsTuples is a hook that adds group permissions tuples for the object being created this is the reverse edge of the object owned tuples, meaning these run on group mutations whereas the other hooks run on the object mutations

func HookGroupSettingVisibility

func HookGroupSettingVisibility() ent.Hook

HookGroupSettingVisibility is a hook that updates the conditional tuples for group settings based on the visibility setting changing the initial tuple is set up on group creation

func HookIdentityHolderFiles

func HookIdentityHolderFiles() ent.Hook

HookIdentityHolderFiles runs on identity holder mutations to check for uploaded files

func HookIdentityHolderSoftDelete

func HookIdentityHolderSoftDelete() ent.Hook

HookIdentityHolderSoftDelete clears identity_holder_id on linked directory accounts when an identity holder is soft-deleted, preventing stale foreign key references

func HookImpersonatorAttribution

func HookImpersonatorAttribution() ent.Hook

HookImpersonatorAttribution stamps the acting impersonator onto a record when the mutation is performed during an impersonation session (for example an Openlane support session). The record's created_by/updated_by still reflect the impersonated identity, while updated_by_impersonator records the real actor behind the session so changes remain traceable to a specific person. When the mutation is not impersonated the field is cleared so it reflects the most recent actor

func HookImportDocument

func HookImportDocument() ent.Hook

HookImportDocument is an ent hook that imports document content from either an uploaded file or a provided URL If a file is uploaded it becomes the source of the details and sets the document name to the original filename

func HookIntegrationCampaignEmail

func HookIntegrationCampaignEmail() ent.Hook

HookIntegrationCampaignEmail enforces the one-campaign-email-per-org invariant. When an integration is flagged as the campaign email provider, all sibling integrations in the same organization have their campaign_email flag cleared

func HookIntegrationPrimaryDirectory

func HookIntegrationPrimaryDirectory() ent.Hook

HookIntegrationPrimaryDirectory enforces the one-primary-directory-per-org invariant When an integration is set as the primary directory, all sibling integrations in the same organization have their primary_directory flag cleared

func HookInvite

func HookInvite() ent.Hook

HookInvite runs on invite create mutations

func HookInviteAccepted

func HookInviteAccepted() ent.Hook

HookInviteAccepted adds the user to the organization when the status is accepted and any groups specified in the invite

func HookInviteGroups

func HookInviteGroups() ent.Hook

HookInviteGroups checks the user has access to the groups specified in the invite mutation before allowing the mutation to proceed users must have edit access to the group to be able to add an invite

func HookManagedGroups

func HookManagedGroups() ent.Hook

HookManagedGroups runs on group mutations to prevent updates to managed groups

func HookMappedControl

func HookMappedControl() ent.Hook

HookMappedControl runs on mapped control create and update mutations to restrict certain fields to system admins only

func HookMembershipSelf

func HookMembershipSelf(table string) ent.Hook

HookMembershipSelf is a hook that runs on membership mutations to prevent users from updating their own membership

func HookNoteFiles

func HookNoteFiles() ent.Hook

HookNoteFiles runs on note mutations to check for uploaded files

func HookNotification

func HookNotification() ent.Hook

HookNotification runs on notification mutations to validate channels

func HookNotificationPublish

func HookNotificationPublish() ent.Hook

HookNotificationPublish runs after notification creation to publish to subscribers

func HookNotificationTemplateSanitize

func HookNotificationTemplateSanitize() ent.Hook

HookNotificationTemplateSanitize sanitizes template content fields on create and update for non-system-owned notification templates. System-owned templates are loaded via harmonize and are trusted. Body content is sanitized with the email-aware bluemonday policy; title and subject fields are stripped of all HTML tags.

func HookObjectOwnedTuples

func HookObjectOwnedTuples(parents []string, ownerRelation string) ent.Hook

HookObjectOwnedTuples is a hook that adds object owned tuples for the object being created given a set of parent id fields, it will add the user and parent permissions to the object on creation by default, it will always add a user permission to the object ownerRelation should normally be set to fgax.ParentRelation, but in some cases this is set to owner to account for different inherited permissions from parent objects vs. the user/service owner of the object (see notes as an example)

func HookOnboarding

func HookOnboarding() ent.Hook

HookOnboarding runs on onboarding mutations to create the organization and settings

func HookOrgMembers

func HookOrgMembers() ent.Hook

func HookOrgMembersDelete

func HookOrgMembersDelete() ent.Hook

HookOrgMembersDelete is a hook that runs during the delete operation of an org membership

func HookOrgModule

func HookOrgModule() ent.Hook

HookOrgModule adds the feature tuples to fga as needed

func HookOrgModuleUpdate

func HookOrgModuleUpdate() ent.Hook

HookOrgModuleUpdate updates the feature tuple in fga based off the module status in the database

func HookOrganization

func HookOrganization() ent.Hook

HookOrganization runs on org mutations to set default values that are not provided

func HookOrganizationCreatePolicy

func HookOrganizationCreatePolicy() ent.Hook

HookOrganizationCreatePolicy is used on organization and organization setting creation mutations if the allowed email domains are set, it will create a conditional tuple that restricts access to the organization based on the email domain

func HookOrganizationDelete

func HookOrganizationDelete() ent.Hook

HookOrganizationDelete runs on org delete mutations to ensure the org can be deleted

func HookOrganizationUpdatePolicy

func HookOrganizationUpdatePolicy() ent.Hook

HookOrganizationUpdatePolicy is used on organization setting mutations where the allowed email domains are set in the request it will update the conditional tuple that restricts access to the organization based on the email domain

func HookPasswordResetToken

func HookPasswordResetToken() ent.Hook

HookPasswordResetToken runs on reset token mutations and sets expires

func HookPlatformFiles

func HookPlatformFiles() ent.Hook

HookPlatformFiles runs on platform mutations to check for uploaded files

func HookProgramAuthz

func HookProgramAuthz() ent.Hook

HookProgramAuthz runs on program mutations to setup or remove relationship tuples and prevents updates to archived programs - except if the update contains status changes too

func HookProgramMembers

func HookProgramMembers() ent.Hook

HookProgramMembers is a hook that ensures that the user is a member of the organization before allowing them to be added to a program TODO (sfunk): can this be generic across all edges with users that are owned by an organization?

func HookProgramValidation

func HookProgramValidation() ent.Hook

HookProgramValidation validates that the start date is before the end date on program's created and updated

func HookPublicAccess

func HookPublicAccess() ent.Hook

HookCreatePublicAccess adds public access (wildcard tuples) to the created object for system owned objects. Deletion of tuples is handled by the global HookDeletePermissions hook

func HookQuestionnaireAssessment

func HookQuestionnaireAssessment() ent.Hook

HookQuestionnaireAssessment is a hook that checks if the templatate associated with the assessment is a questionnaire

func HookRelationTuples

func HookRelationTuples(objects map[string]string, relation fgax.Relation) ent.Hook

HookRelationTuples is a hook that adds tuples for the object being created the objects input is a map of object id fields to the object type these tuples based are based on the direct relation, e.g. a group#member to another object this is the reverse of the HookGroupPermissionsTuples

func HookRequestor

func HookRequestor() ent.Hook

HookRequestor sets the requestor_id field on create mutations

func HookReviewFiles

func HookReviewFiles() ent.Hook

HookReviewFiles runs on review mutations to check for uploaded files

func HookReviews

func HookReviews() ent.Hook

HookReviews runs on review mutations to process and update the entities tied to the review

func HookRevisionUpdate

func HookRevisionUpdate() ent.Hook

HookRevisionUpdate is a hook that runs on update mutations to handle the revision of an object It checks if the revision is set, and if not, it retrieves the current revision from the database and bumps the patch version if just metadata was updated, bumps minor for details or details_json updates If the revision is cleared, it sets the revision to the default value

func HookRisks

func HookRisks() ent.Hook

HookRisks sets fields on the risk based on changes to fields

func HookSeverityLevel

func HookSeverityLevel() ent.Hook

HookSeverityLevel sets the security_level based on the score field using CVSS v4.0 ranges

func HookSlateJSON

func HookSlateJSON() ent.Hook

HookSlateJSON is an ent hook that will handle clearing JSON fields if description is set, this will prevent stale JSON data from remaining when a user sets description via the API (or bulk csv operations) that does not include the JSON field data

func HookStandardCreate

func HookStandardCreate() ent.Hook

HookStandardCreate sets default values on creation, such as setting the short name to the name if it's not provided

func HookStandardDelete

func HookStandardDelete() ent.Hook

HookStandardDelete blocks deletion of a standard that is in use by trust center compliances. For system-owned standards, it cascades the deletion by clearing standard_id from org-owned controls and deleting system-owned controls. For non-system-owned standards, it blocks deletion if controls exist.

func HookStandardFileUpload

func HookStandardFileUpload() ent.Hook

func HookStandardPublicAccessTuples

func HookStandardPublicAccessTuples() ent.Hook

HookStandardPublicAccessTuples adds tuples for publicly available standards based on the system owned and isPublic fields; and deletes them when the fields are cleared. see AddOrDeleteStandardTuple for details on how the fields are checked and it's called functions for specifics on mutation types

func HookStatusApproval

func HookStatusApproval() ent.Hook

HookStatusApproval is an ent hook that ensures only users in the approver or delegate group can set status to APPROVED

func HookSubcontrolCreate

func HookSubcontrolCreate() ent.Hook

HookSubcontrolCreate sets default values for the subcontrol on creation

func HookSubcontrolUpdate

func HookSubcontrolUpdate() ent.Hook

HookSubcontrolUpdate ensures that there is at least 1 control assigned to the subcontrol

func HookSubprocessor

func HookSubprocessor() ent.Hook

HookSubprocessor runs on subprocessor mutations to check for uploaded logo file

func HookSubscriberCreate

func HookSubscriberCreate() ent.Hook

HookSubscriberCreate runs on subscriber create mutations

func HookSubscriberUpdated

func HookSubscriberUpdated() ent.Hook

HookSubscriberUpdated runs on subscriber update mutations to set the active status to false if the user is unsubscribed

func HookSummarizeDetails

func HookSummarizeDetails() ent.Hook

HookSummarizeDetails is an ent hook that summarizes long details fields into a short human readable summary

func HookSystemOwnedControls

func HookSystemOwnedControls() ent.Hook

HookSystemOwnedControls runs on mutations to check for system owned controls since only view access to a control is required for edges on tasks, evidence, this ensures that system owned controls are not linked to org owned objects

func HookTagDefinition

func HookTagDefinition() ent.Hook

func HookTagDefinitionDelete

func HookTagDefinitionDelete() ent.Hook

HookTagDefinitionDelete checks if the tag definition(s) being deleted is in use by any workflow definition. If in use, the deletion cannot proceed

func HookTags

func HookTags() ent.Hook

HookTags will create tag definitions if they do not already exist when tags are added to an entity

func HookTaskCreate

func HookTaskCreate() ent.Hook

HookTaskCreate runs on task create mutations to set default values that are not provided this will set the assigner to the current user if it is not provided

func HookTaskPermissions

func HookTaskPermissions() ent.Hook

HookTaskPermissions runs on task create and update mutations to add and remove the assignee tuple

func HookTemplate

func HookTemplate() ent.Hook

HookTemplate runs on template create and update mutations

func HookTemplateFiles

func HookTemplateFiles() ent.Hook

func HookTrustCenter

func HookTrustCenter() ent.Hook

HookTrustCenter runs on trust center create mutations

func HookTrustCenterComplianceAuthz

func HookTrustCenterComplianceAuthz() ent.Hook

HookTrustCenterComplianceAuthz runs on trust center compliance mutations to setup or remove relationship tuples

func HookTrustCenterDelete

func HookTrustCenterDelete() ent.Hook

HookTrustCenterDelete runs on trust center delete mutations

func HookTrustCenterEntityCreate

func HookTrustCenterEntityCreate() ent.Hook

HookTrustCenterEntityCreate scopes the entity to the customer type by default. If the customer entity does not exist ( maybe old orgs ), it creates it before proceeding to the trustcenter entity creation

func HookTrustCenterEntityFiles

func HookTrustCenterEntityFiles() ent.Hook

HookTrustCenterEntityFiles runs on trustcenter entity mutations and checks for an uploaded logo file

func HookTrustCenterFAQ

func HookTrustCenterFAQ() ent.Hook

HookTrustCenterFAQ sets the trustcenter ID on the note so it is always accessible.

func HookTrustCenterNDARequestCreate

func HookTrustCenterNDARequestCreate() ent.Hook

HookTrustCenterNDARequestCreate handles new NDA request creation

func HookTrustCenterNDARequestUpdate

func HookTrustCenterNDARequestUpdate() ent.Hook

HookTrustCenterNDARequestUpdate handles NDA request status updates - sends email when approved

func HookTrustCenterSetting

func HookTrustCenterSetting() ent.Hook

HookTrustCenterSetting process files for trust center settings

func HookTrustCenterSettingCreatePreview

func HookTrustCenterSettingCreatePreview() ent.Hook

HookTrustCenterSettingCreatePreview is a hook that runs on trust center setting create or update to enqueue a job to create the preview domain

func HookTrustCenterSubprocessor

func HookTrustCenterSubprocessor() ent.Hook

HookTrustCenterSubprocessor adds parent relationship tuples on create of trust center subprocessors for the subprocessor, allowing trust center access

func HookTrustCenterUpdate

func HookTrustCenterUpdate() ent.Hook

HookTrustCenterUpdate runs on trust center update mutations

func HookTrustCenterWatermarkConfig

func HookTrustCenterWatermarkConfig() ent.Hook

HookTrustCenterWatermarkConfig process files for trust center watermark config

func HookUpdateAPIToken

func HookUpdateAPIToken() ent.Hook

HookUpdateAPIToken runs on api token update and redacts the token

func HookUpdateAssessmentResponse

func HookUpdateAssessmentResponse() ent.Hook

HookUpdateAssessmentResponse validates status transitions and checks if the assessment response is past due. Completed is a terminal state. Draft can only be set if already in draft.

func HookUpdateManagedGroups

func HookUpdateManagedGroups() ent.Hook

HookUpdateManagedGroups runs when org members are added to add the users to the system managed groups

func HookUpdatePersonalAccessToken

func HookUpdatePersonalAccessToken() ent.Hook

HookUpdatePersonalAccessToken runs on access token update and redacts the token

func HookUpdateTrustCenterDoc

func HookUpdateTrustCenterDoc() ent.Hook

HookUpdateTrustCenterDoc is an ent hook that processes file uploads and sets appropriate fields and permissions on update

func HookUser

func HookUser() ent.Hook

HookUser runs on user mutations validate and hash the password and set default values that are not provided

func HookUserCanViewTuple

func HookUserCanViewTuple() ent.Hook

HookUserCanViewTuple adds the user#can_view relation for the created object it is agnostic to the object type so it can be used on any schema

func HookUserPermissions

func HookUserPermissions() ent.Hook

HookUserPermissions runs on user creations to add user _self permissions these are used for parent inherited relations on other objects in the system

func HookUserSetting

func HookUserSetting() ent.Hook

HookUserSetting runs on user settings mutations and validates input on update

func HookUserSettingEmailConfirmation

func HookUserSettingEmailConfirmation() ent.Hook

HookUserSettingEmailConfirmation runs on user settings mutations and handles auto-join when email is confirmed and sends welcome email after verification

func HookValidateIdentityProviderConfig

func HookValidateIdentityProviderConfig() ent.Hook

HookValidateIdentityProviderConfig ensures identity provider configuration is present when SSO login is enforced and resets the enforced/tested status whenever any SSO configuration field changes

func HookVendorRiskScoreAggregate

func HookVendorRiskScoreAggregate() ent.Hook

HookVendorRiskScoreAggregate recomputes Entity.risk_score and Entity.risk_rating after a VendorRiskScore is created, updated, or deleted

func HookVendorRiskScoreCompute

func HookVendorRiskScoreCompute() ent.Hook

HookVendorRiskScoreCompute sets the score field based on impact x likelihood, and populates denormalized question fields from the scoring config on create

func HookVendorScoringConfigKeyGen

func HookVendorScoringConfigKeyGen() ent.Hook

HookVendorScoringConfigKeyGen assigns stable keys to custom questions that lack a generated CUST-prefix key before the config is persisted

func HookVerifyTFA

func HookVerifyTFA() ent.Hook

HookVerifyTFA is a hook that will generate recovery codes and enable TFA for a user if the TFA has been verified

func HookWebauthnDelete

func HookWebauthnDelete() ent.Hook

HookWebauthnDelete runs on passkey delete mutations to ensure that we update the user's settings if needed

func HookWorkflowApprovalRouting

func HookWorkflowApprovalRouting() ent.Hook

HookWorkflowApprovalRouting intercepts mutations on workflowable schemas and routes them to WorkflowProposal when a matching workflow definition with approval requirements exists. This enables the "proposed changes" pattern where mutations require approval before being applied.

func HookWorkflowAssignmentDecisionAuth

func HookWorkflowAssignmentDecisionAuth() ent.Hook

HookWorkflowAssignmentDecisionAuth ensures only assignment targets can approve/reject.

func HookWorkflowDefinitionPrefilter

func HookWorkflowDefinitionPrefilter() ent.Hook

HookWorkflowDefinitionPrefilter derives prefilter fields from the definition JSON.

func HookWorkflowInstanceCascadeDelete

func HookWorkflowInstanceCascadeDelete() ent.Hook

HookWorkflowInstanceCascadeDelete removes workflow-related child records when instances are deleted.

func HookWorkflowProposalInvalidateAssignments

func HookWorkflowProposalInvalidateAssignments() ent.Hook

HookWorkflowProposalInvalidateAssignments invalidates approved assignments when a SUBMITTED proposal is edited

func HookWorkflowProposalTriggerOnSubmit

func HookWorkflowProposalTriggerOnSubmit() ent.Hook

HookWorkflowProposalTriggerOnSubmit triggers workflows when a proposal transitions to SUBMITTED state

func IdentityResolutionListeners

func IdentityResolutionListeners() []gala.Registration

IdentityResolutionListeners resolves directory accounts to identity holders after mutations commit

func IntegrationCleanupListeners

func IntegrationCleanupListeners() []gala.Registration

IntegrationCleanupListeners purges queued integration jobs on removal or disconnect and reseeds them on reconnect

func IsUniqueConstraintError

func IsUniqueConstraintError(err error) bool

IsUniqueConstraintError reports if the error resulted from a DB uniqueness constraint violation. e.g. duplicate value in unique index.

func IsValidEnumField

func IsValidEnumField(objectType, field string) bool

IsValidEnumField returns true if any table has a column matching the object type and field pattern For global enums (empty objectType), checks for {field}_id columns For object-scoped enums, checks for {objectType}_{field}_id columns

func MetricsHook

func MetricsHook() ent.Hook

MetricsHook inits the collectors with count total at beginning, error on mutation error and a duration after the mutation

func NDAAttestationListeners

func NDAAttestationListeners() []gala.Registration

NDAAttestationListeners attests signed trust center NDAs after document data creation

func OrgOwnedTuplesHook

func OrgOwnedTuplesHook() ent.Hook

OrgOwnedTuplesHook is a hook that adds organization owned tuples for the object being created it will only add the parent organization permissions, and no specific user permissions

func OrganizationAvatarListeners

func OrganizationAvatarListeners(opts ...OrganizationAvatarListenerOption) []gala.Registration

OrganizationAvatarListeners discovers an avatar from the organization's domains after creation

func OrganizationCleanupListeners

func OrganizationCleanupListeners() []gala.Registration

OrganizationCleanupListeners cascades an organization soft delete by hard-deleting everything it owns

func QuestionnaireTransformListeners

func QuestionnaireTransformListeners() []gala.Registration

QuestionnaireTransformListeners transforms completed questionnaire document data into entities using the template's transform configuration

func RecomputeEntityRiskAggregate

func RecomputeEntityRiskAggregate(ctx context.Context, client *generated.Client, entityID string) error

RecomputeEntityRiskAggregate recalculates an entity's aggregate risk_score, risk_rating, and risk_score_coverage from all VendorRiskScore records, respecting the scoring mode on the associated VendorScoringConfig

func RegisterGlobalHooks

func RegisterGlobalHooks(client *entgen.Client)

RegisterGlobalHooks registers global hooks shared across runtime modes.

func SetNewRevision

func SetNewRevision(ctx context.Context, mut MutationWithRevision) error

SetNewRevision sets the new revision for a mutation based on the current revision and the revision bump If the revision is set, it does nothing If the revision is not set, it retrieves the current revision from the database and bumps the version based on the revision bump If there is no revision bump set, it bumps the patch version

func SetTrustCenterConfig

func SetTrustCenterConfig(cfg TrustCenterConfig)

SetTrustCenterConfig sets the trust center configuration. It also populates the shared trustcenterurl config so the integration runtime can build trust center links without importing this package

func StripInvalidChars

func StripInvalidChars(s string) string

StripInvalidChars removes invalid characters from a string

func SubscriberLinkListeners

func SubscriberLinkListeners() []gala.Registration

SubscriberLinkListeners links a newly created subscriber to an existing contact and/or user with a matching email

func TaskRuleListeners

func TaskRuleListeners() []gala.Registration

TaskRuleListeners evaluates schema task rules on mutation and creates suggested tasks

func TrustCenterCacheListeners

func TrustCenterCacheListeners() []gala.Registration

TrustCenterCacheListeners refreshes the trust center cache when trust-center-linked records change, including soft deletes

func TrustCenterWatermarkListeners

func TrustCenterWatermarkListeners() []gala.Registration

TrustCenterWatermarkListeners enqueues watermarking jobs when trust center document files change

func ValidateIdentityProviderConfig

func ValidateIdentityProviderConfig(ctx context.Context, m *generated.OrganizationSettingMutation) error

ValidateIdentityProviderConfig checks if the identity provider configuration is valid the intent of the function is to ensure all necessary identity provider configuration fields are present and valid when SSO enforcement is being set to active, while also supporting partial updates by falling back to existing values when appropriate

func VendorScoringListeners

func VendorScoringListeners() []gala.Registration

VendorScoringListeners recomputes entity risk aggregates when vendor scoring configuration changes

func WorkflowListeners

func WorkflowListeners() []gala.Registration

WorkflowListeners wires workflow mutations and command events to the workflow engine

func WorkflowMutationListeners

func WorkflowMutationListeners() []gala.Registration

WorkflowMutationListeners forwards workflow-eligible mutations to the workflow engine

Types

type AvatarMutation

type AvatarMutation interface {
	pkgobjects.Mutation

	SetAvatarLocalFileID(s string)
	SetAvatarUpdatedAt(t time.Time)
}

AvatarMutation is an interface for setting the local file ID for an avatar

type CustomEnumFilter

type CustomEnumFilter struct {
	// ObjectType is the object type the enum applies to, e.g. "risk", "control", "risk_category"
	ObjectType string
	// Field is the field the enum applies to, e.g. "kind", "category"
	Field string
	// EdgeFieldName is the edge field name the enum applies to that is the foreign key, e.g. "risk_kind_id"
	EdgeFieldName string
	// SchemaFieldName is the schema field name the enum applies to, e.g. "control_kind_name
	SchemaFieldName string
	// AllowGlobal indicates the enum lookup should use global enums with an empty object type
	AllowGlobal bool
	// DisableAutoCreate disables auto-creation of the enum if it doesn't exist
	DisableAutoCreate bool
}

CustomEnumFilter is used to filter custom enums based on object type and field

type FileBackupRequest added in v2.4.1

type FileBackupRequest struct {
	FileID string `json:"file_id"`
}

FileBackupRequest asks for a single file to be replicated to its backup provider

type MutationMember

type MutationMember interface {
	utils.GenericMutation

	UserIDs() []string
	UserID() (string, bool)
}

MutationMember is an interface that can be implemented by a member mutation to get IDs

type MutationWithEmail

type MutationWithEmail interface {
	Email() (string, bool)

	utils.GenericMutation
}

MutationWithEmail is an interface that mutations that require email validation must implement

type MutationWithRevision

type MutationWithRevision interface {
	Revision() (string, bool)
	RevisionCleared() bool
	OldRevision(ctx context.Context) (string, error)
	SetRevision(s string)
	OldField(ctx context.Context, name string) (ent.Value, error)

	utils.GenericMutation
}

MutationWithRevision is an interface that defines the methods required for a mutation to be able to handle revisions It includes methods for getting and setting the revision

type OrgMember

type OrgMember struct {
	// UserID is the user ID of the org member
	UserID string
	// NewRole is the role of the org member
	NewRole enums.Role
	// OldRow is the old role of the org member
	OldRole enums.Role
	// OrgID is the organization ID of the org member
	OrgID string
}

OrgMember is a struct to hold the org member details

type OrganizationAvatarListenerOption

type OrganizationAvatarListenerOption func(*organizationAvatarListenerConfig)

OrganizationAvatarListenerOption customizes avatar discovery

func WithOrganizationAvatarRequester

func WithOrganizationAvatarRequester(requester *httpsling.Requester) OrganizationAvatarListenerOption

WithOrganizationAvatarRequester sets the avatar discovery requester

type TaskLabelResolver

type TaskLabelResolver func(ctx context.Context, client *generated.Client, value string) string

TaskLabelResolver resolves a human-readable label for one EachElement value filling the {label} placeholder in a task template

type TrustCenterConfig

type TrustCenterConfig struct {
	CnameTarget              string
	PreviewCnameTarget       string
	DefaultTrustCenterDomain string
	CacheRefreshScheme       string
}

TrustCenterConfig holds the trust center configuration

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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