Help us shape the future of Go! Take the 2026 Go Developer Survey

resources

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package resources holds goverter-generated mappers from ent entities to site API resources (the ogen *Resource DTOs), plus the custom conversions goverter cannot infer on its own. The generated implementation (ConverterImpl) lives in converter_gen.go; consumers instantiate it (see internal/api/site).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutomationSteps

func AutomationSteps(steps []siteapi.SiteAutomationStep) []automations.Step

AutomationSteps converts the typed steps DTO to the automations module's steps.

func BroadcastStats

func BroadcastStats(st broadcasts.Stats) siteapi.SiteBroadcastStats

BroadcastStats nests a Broadcast's delivery figures in the Stats DTO and computes the derived engagement rates. Rates are ratios in [0,1]; a zero denominator yields 0.

func RuleActions

func RuleActions(actions []siteapi.SiteRuleAction) []rules.Action

RuleActions converts the typed Actions DTO to the Rule module's Actions.

Types

type Converter

type Converter interface {
	// The contact is read with its tags loaded (`WithTags`).
	// goverter:map Edges.Tags Tags
	ContactToResource(source *ent.Contact) siteapi.SiteContactResource
	// The contract names the discarded state \"archived\" (ADR 0049).
	// goverter:map DiscardedAt ArchivedAt
	SegmentToResource(source *ent.Segment) siteapi.SiteSegmentResource
	TokenToResource(source *ent.ApiToken) siteapi.SiteApiTokenResource

	// Verification is derived: a non-nil email_verified_at means verified.
	// The Sign-up survey is due only while the Instance still asks it, which the mapper cannot
	// see: the handler sets it from the marker and the Instance switch.
	// goverter:map EmailVerifiedAt EmailVerified | emailVerified
	// goverter:ignore SignupSurveyDue
	UserToResource(source *ent.User) *siteapi.SiteUserResource
	// The grace end and the role belong to the authenticated User's Membership,
	// which the mapper cannot see: the handler attaches them.
	// goverter:ignore SecondFactorGraceEndsAt
	// goverter:ignore Role
	// goverter:ignore AccountLinkAvailable
	// The active holds are read through the Workspace's scope, which the mapper cannot
	// see: the handler attaches them.
	// goverter:ignore Holds
	// The support contact is instance configuration, attached by the handler.
	// goverter:ignore SupportEmail
	// The MCP origin is instance configuration, attached by the handler.
	// goverter:ignore McpUrl
	// The numeric key stays internal: the contract's id is the Workspace id.
	// goverter:map PublicID ID
	WorkspaceToResource(source *ent.Workspace) siteapi.SiteWorkspaceResource
	EventToResource(source *ent.Event) siteapi.SiteEventResource
	LinkClicksToResource(source []linkclicks.Clicks) []siteapi.SiteLinkClicks

	// The delivery figures are derived from the Broadcast's recipients and their Outbound
	// messages, which the mapper cannot see: the handler attaches them (BroadcastStats).
	// goverter:ignore Stats
	// Progress is derived from the recipients, which the mapper cannot see: the
	// handler attaches it.
	// goverter:ignore Progress
	// Warnings are the lint of the content just saved (ADR 0040): the handler attaches them
	// to the response of a save.
	// goverter:ignore Warnings
	// The contract names the discarded state "archived" (ADR 0049).
	// goverter:map DiscardedAt ArchivedAt
	BroadcastToResource(source *ent.Broadcast) siteapi.SiteBroadcastResource

	// goverter:map Processed ProcessedCount
	// goverter:map Remaining RemainingCount
	// goverter:map EstimatedCompletion EstimatedCompletionAt
	BroadcastProgressToResource(source broadcasts.Progress) siteapi.SiteBroadcastProgress

	// goverter:ignore Warnings
	EmailTemplateToResource(source *ent.EmailTemplate) siteapi.SiteEmailTemplateResource

	// The contract names the discarded state "archived" (ADR 0049).
	// goverter:map DiscardedAt ArchivedAt
	// The stored definition string (the executor's JSON format) is decoded into
	// the typed steps DTO at this boundary.
	// goverter:map . Steps | automationSteps
	AutomationToResource(source *ent.Automation) siteapi.SiteAutomationResource

	// The config is a oneOf the generator cannot express, and the params, hook URL and
	// retiring secrets come from the integrations module (decryption, instance URL), and
	// the Send rate limit from sendlimit.Statuses: the handler attaches them.
	// goverter:ignore Config
	// goverter:ignore Params
	// goverter:ignore SecretsRetiring
	// goverter:ignore HookUrl
	// goverter:ignore SendLimit
	// goverter:map DiscardedAt ArchivedAt
	IntegrationToResource(source *ent.Integration) siteapi.SiteIntegrationResource
	// The redacted provider configs: the handler only wraps the one that is set in the
	// contract's oneOf, which goverter cannot express. Empty optional fields are omitted.
	// goverter:map . Kind | smtpConfigKind
	SmtpConfigToResource(source integrations.RedactedSMTP) siteapi.SiteSmtpConfig
	// goverter:map . Kind | sesConfigKind
	SesConfigToResource(source integrations.RedactedSES) siteapi.SiteSesConfig
	// goverter:map Sent24h SentLast24h
	SendLimitToStatus(source sendlimit.Status) siteapi.SiteSendLimitStatus
	PasskeyToResource(source *ent.Passkey) siteapi.SitePasskey
	SuppressionToResource(source *ent.Suppression) siteapi.SiteSuppressionResource
	CustomFieldToResource(source *ent.CustomField) siteapi.SiteCustomFieldResource
	TagToResource(source *ent.Tag) siteapi.SiteTagResource

	// The transactional send history is the Outbound messages of kind transactional
	// (ADR 0015). A message skipped by Send-eligibility is shown as "suppressed" (the
	// only reason a transactional send is skipped); the reason column is the error
	// text only for a failed send.
	// goverter:map . Status | transactionalStatus
	// goverter:map . Error | transactionalError
	// goverter:map TemplateID TemplateId
	TransactionalMessageToResource(source *ent.OutboundMessage) siteapi.SiteTransactionalEmailResource

	// The member's identity comes from the loaded User edge.
	// goverter:map Edges.User.Email Email
	// goverter:map Edges.User.Name Name
	MembershipToResource(source *ent.Membership) siteapi.SiteMembershipResource

	// goverter:map . InvitedByEmail | inviterEmail
	InvitationToResource(source *ent.Invitation) siteapi.SiteInvitationResource

	// The contract names the discarded state "archived" (ADR 0049). The Trigger events are
	// the rows of the Rule's `triggers` edge, loaded with the Rule; the stored actions JSON
	// is decoded into the typed Actions at this boundary.
	// goverter:map DiscardedAt ArchivedAt
	// goverter:map . TriggerEvents | ruleTriggerEvents
	RuleToResource(source *ent.Rule) siteapi.SiteRuleResource

	// The store names the Event's source id; the contract says whose it is.
	// goverter:map SourceID EventSourceId
	RuleFiringToResource(source *ent.RuleFiring) siteapi.SiteRuleFiringResource

	RuleDryRunToResource(source rules.DryRun) siteapi.SiteRuleDryRunResource

	// goverter:map . Failure | enrollmentFailure
	EnrollmentToResource(source *ent.AutomationRun) siteapi.SiteEnrollmentResource

	// The deletion window: the date the Workspace's data will be erased.
	// goverter:map PublicID ID
	// goverter:map DiscardedAt EraseAt | eraseAt
	// Whether the caller is its only Owner comes from the Memberships, which the mapper
	// cannot see: the handler attaches it.
	// goverter:ignore OnlyOwner
	DeletedWorkspaceToResource(source *ent.Workspace) siteapi.SiteDeletedWorkspaceResource

	// goverter:map CreatedAt Since
	HoldToResource(source *ent.Hold) siteapi.SiteWorkspaceHold

	// goverter:map . Record | joinDomainRecord
	// goverter:map . Verified | joinDomainVerified
	JoinDomainToResource(source *ent.JoinDomain) siteapi.SiteJoinDomainResource

	// The DNS records are derived by the sendingdomains module, which the mapper cannot
	// see: the handler attaches them. The private key is never exposed.
	// goverter:ignore DkimRecord
	// goverter:ignore SpfRecord
	// goverter:ignore DmarcRecord
	// goverter:ignore TrackingRecord
	// The contract names the discarded state "archived" (ADR 0049).
	// goverter:map DiscardedAt ArchivedAt
	// goverter:map . Verified | sendingDomainVerified
	SendingDomainToResource(source *ent.SendingDomain) siteapi.SiteSendingDomainResource
	// goverter:map . Type | dnsRecordType
	DnsRecordToResource(source sendingdomains.Record) siteapi.SiteDnsRecord
	// goverter:map . Type | trackingRecordType
	// goverter:map CheckedAt LastCheckedAt
	TrackingRecordToResource(source sendingdomains.TrackingRecord) siteapi.SiteTrackingRecord

	// A Workspace that has not saved a Brand kit has no row to convert, so the mapper
	// takes the module's Kit.
	// goverter:map . UpdatedAt | brandKitUpdatedAt
	BrandKitToResource(source brandkit.Kit) siteapi.SiteBrandKitResource

	// goverter:map . Actor | auditActor
	// goverter:map . Target | auditTarget
	// goverter:map Diff Diff | auditDiff
	AuditEntryToResource(source auditapi.View) siteapi.SiteAuditEntryResource

	// The signing secret is decrypted by the webhooks module, which the mapper cannot see:
	// the handler attaches it. The failure state is derived from the failure columns.
	// goverter:ignore Secret
	// goverter:map EventTypes EventTypes | eventTypes
	// goverter:map . Failure | webhookFailure
	// goverter:map . Enabled | webhookEnabled
	WebhookEndpointToResource(source *ent.WebhookEndpoint) siteapi.SiteWebhookEndpointResource

	// The Data export members (ADR 0021): the contract's typed projection of the
	// stored rows, so the ent JSON tags are never the public format.
	ContactToExport(source *ent.Contact) siteapi.ContactExportContact
	TagToExport(source *ent.Tag) siteapi.ContactExportTag
	VisitorToExport(source *ent.Visitor) siteapi.ContactExportVisitor
	EventToExport(source *ent.Event) siteapi.ContactExportEvent
	UnsubscribeToExport(source *ent.Unsubscribe) siteapi.ContactExportUnsubscribe
	SuppressionToExport(source *ent.Suppression) siteapi.ContactExportSuppression
	ConfirmationToExport(source *ent.Confirmation) siteapi.ContactExportConfirmation
	OutboundMessageToExport(source *ent.OutboundMessage) siteapi.ContactExportOutboundMessage
	BroadcastRecipientToExport(source *ent.BroadcastRecipient) siteapi.ContactExportBroadcastRecipient
}

Converter maps ent entities to site API resources. goverter generates the implementation; named string/time casts are inferred, the extends below cover the conversions it can't (ids, optionals, the event property bag).

goverter:converter goverter:output:file ./converter_gen.go goverter:matchIgnoreCase goverter:enum no goverter:useZeroValueOnPointerInconsistency goverter:extend timestamp goverter:extend optNilString goverter:extend optNilContactSource goverter:extend omitEmpty goverter:extend optNilEmailAddress goverter:extend optNilEntityID goverter:extend optNilTimeZone goverter:extend workspaceTimezone goverter:extend optNilTimestamp goverter:extend contactCustomFields goverter:extend optNilInt32 goverter:extend exportJSON goverter:extend eventProperties goverter:extend templateDoc goverter:extend broadcastDoc goverter:extend automationSteps goverter:extend segmentCondition goverter:extend ruleActions goverter:extend ruleResults goverter:extend emailVerified goverter:extend transactionalChannel goverter:extend transactionalStatus goverter:extend transactionalError goverter:extend nilInt32 goverter:extend nilString goverter:extend count goverter:extend sendLimitWarning goverter:extend sendLimitSource goverter:extend optTimestamp goverter:extend optInt32 goverter:extend optString goverter:extend optMembershipSource goverter:extend optTrackingReason goverter:extend timestampOf goverter:extend tagNames goverter:extend auditDiff goverter:extend optWebhookDisabledReason

type ConverterImpl

type ConverterImpl struct{}

func (*ConverterImpl) AuditEntryToResource

func (c *ConverterImpl) AuditEntryToResource(source auditapi.View) site.SiteAuditEntryResource

func (*ConverterImpl) AutomationToResource

func (c *ConverterImpl) AutomationToResource(source *ent.Automation) site.SiteAutomationResource

func (*ConverterImpl) BrandKitToResource

func (c *ConverterImpl) BrandKitToResource(source brandkit.Kit) site.SiteBrandKitResource

func (*ConverterImpl) BroadcastProgressToResource

func (c *ConverterImpl) BroadcastProgressToResource(source broadcasts.Progress) site.SiteBroadcastProgress

func (*ConverterImpl) BroadcastRecipientToExport

func (c *ConverterImpl) BroadcastRecipientToExport(source *ent.BroadcastRecipient) site.ContactExportBroadcastRecipient

func (*ConverterImpl) BroadcastToResource

func (c *ConverterImpl) BroadcastToResource(source *ent.Broadcast) site.SiteBroadcastResource

func (*ConverterImpl) ConfirmationToExport

func (c *ConverterImpl) ConfirmationToExport(source *ent.Confirmation) site.ContactExportConfirmation

func (*ConverterImpl) ContactToExport

func (c *ConverterImpl) ContactToExport(source *ent.Contact) site.ContactExportContact

func (*ConverterImpl) ContactToResource

func (c *ConverterImpl) ContactToResource(source *ent.Contact) site.SiteContactResource

func (*ConverterImpl) CustomFieldToResource

func (c *ConverterImpl) CustomFieldToResource(source *ent.CustomField) site.SiteCustomFieldResource

func (*ConverterImpl) DeletedWorkspaceToResource

func (c *ConverterImpl) DeletedWorkspaceToResource(source *ent.Workspace) site.SiteDeletedWorkspaceResource

func (*ConverterImpl) DnsRecordToResource

func (c *ConverterImpl) DnsRecordToResource(source sendingdomains.Record) site.SiteDnsRecord

func (*ConverterImpl) EmailTemplateToResource

func (c *ConverterImpl) EmailTemplateToResource(source *ent.EmailTemplate) site.SiteEmailTemplateResource

func (*ConverterImpl) EnrollmentToResource

func (c *ConverterImpl) EnrollmentToResource(source *ent.AutomationRun) site.SiteEnrollmentResource

func (*ConverterImpl) EventToExport

func (c *ConverterImpl) EventToExport(source *ent.Event) site.ContactExportEvent

func (*ConverterImpl) EventToResource

func (c *ConverterImpl) EventToResource(source *ent.Event) site.SiteEventResource

func (*ConverterImpl) HoldToResource

func (c *ConverterImpl) HoldToResource(source *ent.Hold) site.SiteWorkspaceHold

func (*ConverterImpl) IntegrationToResource

func (c *ConverterImpl) IntegrationToResource(source *ent.Integration) site.SiteIntegrationResource

func (*ConverterImpl) InvitationToResource

func (c *ConverterImpl) InvitationToResource(source *ent.Invitation) site.SiteInvitationResource

func (*ConverterImpl) JoinDomainToResource

func (c *ConverterImpl) JoinDomainToResource(source *ent.JoinDomain) site.SiteJoinDomainResource

func (*ConverterImpl) LinkClicksToResource

func (c *ConverterImpl) LinkClicksToResource(source []linkclicks.Clicks) []site.SiteLinkClicks

func (*ConverterImpl) MembershipToResource

func (c *ConverterImpl) MembershipToResource(source *ent.Membership) site.SiteMembershipResource

func (*ConverterImpl) OutboundMessageToExport

func (c *ConverterImpl) OutboundMessageToExport(source *ent.OutboundMessage) site.ContactExportOutboundMessage

func (*ConverterImpl) PasskeyToResource

func (c *ConverterImpl) PasskeyToResource(source *ent.Passkey) site.SitePasskey

func (*ConverterImpl) RuleDryRunToResource

func (c *ConverterImpl) RuleDryRunToResource(source rules.DryRun) site.SiteRuleDryRunResource

func (*ConverterImpl) RuleFiringToResource

func (c *ConverterImpl) RuleFiringToResource(source *ent.RuleFiring) site.SiteRuleFiringResource

func (*ConverterImpl) RuleToResource

func (c *ConverterImpl) RuleToResource(source *ent.Rule) site.SiteRuleResource

func (*ConverterImpl) SegmentToResource

func (c *ConverterImpl) SegmentToResource(source *ent.Segment) site.SiteSegmentResource

func (*ConverterImpl) SendLimitToStatus

func (c *ConverterImpl) SendLimitToStatus(source sendlimit.Status) site.SiteSendLimitStatus

func (*ConverterImpl) SendingDomainToResource

func (c *ConverterImpl) SendingDomainToResource(source *ent.SendingDomain) site.SiteSendingDomainResource

func (*ConverterImpl) SesConfigToResource

func (c *ConverterImpl) SesConfigToResource(source integrations.RedactedSES) site.SiteSesConfig

func (*ConverterImpl) SmtpConfigToResource

func (c *ConverterImpl) SmtpConfigToResource(source integrations.RedactedSMTP) site.SiteSmtpConfig

func (*ConverterImpl) SuppressionToExport

func (c *ConverterImpl) SuppressionToExport(source *ent.Suppression) site.ContactExportSuppression

func (*ConverterImpl) SuppressionToResource

func (c *ConverterImpl) SuppressionToResource(source *ent.Suppression) site.SiteSuppressionResource

func (*ConverterImpl) TagToExport

func (c *ConverterImpl) TagToExport(source *ent.Tag) site.ContactExportTag

func (*ConverterImpl) TagToResource

func (c *ConverterImpl) TagToResource(source *ent.Tag) site.SiteTagResource

func (*ConverterImpl) TokenToResource

func (c *ConverterImpl) TokenToResource(source *ent.ApiToken) site.SiteApiTokenResource

func (*ConverterImpl) TrackingRecordToResource

func (c *ConverterImpl) TrackingRecordToResource(source sendingdomains.TrackingRecord) site.SiteTrackingRecord

func (*ConverterImpl) TransactionalMessageToResource

func (c *ConverterImpl) TransactionalMessageToResource(source *ent.OutboundMessage) site.SiteTransactionalEmailResource

func (*ConverterImpl) UnsubscribeToExport

func (c *ConverterImpl) UnsubscribeToExport(source *ent.Unsubscribe) site.ContactExportUnsubscribe

func (*ConverterImpl) UserToResource

func (c *ConverterImpl) UserToResource(source *ent.User) *site.SiteUserResource

func (*ConverterImpl) VisitorToExport

func (c *ConverterImpl) VisitorToExport(source *ent.Visitor) site.ContactExportVisitor

func (*ConverterImpl) WebhookEndpointToResource

func (c *ConverterImpl) WebhookEndpointToResource(source *ent.WebhookEndpoint) site.SiteWebhookEndpointResource

func (*ConverterImpl) WorkspaceToResource

func (c *ConverterImpl) WorkspaceToResource(source *ent.Workspace) site.SiteWorkspaceResource

type ExportMapper

type ExportMapper struct{ Converter }

ExportMapper adapts the Converter to contactexport.Mapper.

func (ExportMapper) BroadcastRecipient

func (m ExportMapper) BroadcastRecipient(r *ent.BroadcastRecipient) json.Marshaler

func (ExportMapper) Confirmation

func (m ExportMapper) Confirmation(r *ent.Confirmation) json.Marshaler

func (ExportMapper) Contact

func (m ExportMapper) Contact(r *ent.Contact) json.Marshaler

func (ExportMapper) Event

func (m ExportMapper) Event(r *ent.Event) json.Marshaler

func (ExportMapper) OutboundMessage

func (m ExportMapper) OutboundMessage(r *ent.OutboundMessage) json.Marshaler

func (ExportMapper) Suppression

func (m ExportMapper) Suppression(r *ent.Suppression) json.Marshaler

func (ExportMapper) Tag

func (m ExportMapper) Tag(r *ent.Tag) json.Marshaler

func (ExportMapper) Unsubscribe

func (m ExportMapper) Unsubscribe(r *ent.Unsubscribe) json.Marshaler

func (ExportMapper) Visitor

func (m ExportMapper) Visitor(r *ent.Visitor) json.Marshaler

Jump to

Keyboard shortcuts

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