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

resources

package
v0.3.4 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutomationSteps

func AutomationSteps(steps []externalapi.AutomationStep) []automations.Step

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

func RuleActions

func RuleActions(actions []externalapi.RuleAction) []rules.Action

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

Types

type Converter

type Converter interface {
	ContactToResource(source *ent.Contact) externalapi.ContactResource
	// The contract names the discarded state "archived" (ADR 0049).
	// goverter:map DiscardedAt ArchivedAt
	BroadcastToResource(source *ent.Broadcast) externalapi.BroadcastResource

	// The figures are the report's Stats; the rates are Stats methods.
	// goverter:map Stats.Recipients RecipientsTotal
	// goverter:map Stats.Sent SentCount
	// goverter:map Stats.Skipped SkippedCount
	// goverter:map Stats.Failed FailedCount
	// goverter:map Stats.Opened OpenedCount
	// goverter:map Stats.Clicked ClickedCount
	// goverter:map Stats.Unsubscribed UnsubscribedCount
	// goverter:map Stats.Delivered DeliveredCount
	// goverter:map Stats.Bounced BouncedCount
	// goverter:map Stats.Complained ComplainedCount
	// goverter:map Stats.Captured CapturedCount
	// goverter:map Stats OpenRate | openRate
	// goverter:map Stats ClickRate | clickRate
	BroadcastReportToResource(source broadcasts.Report) externalapi.BroadcastReport
	ApiTokenToInfo(source *ent.ApiToken) externalapi.ApiTokenInfo
	// The contract names the discarded state \"archived\" (ADR 0049).
	// goverter:map DiscardedAt ArchivedAt
	SegmentToResource(source *ent.Segment) externalapi.SegmentResource
	EmailTemplateToResource(source *ent.EmailTemplate) externalapi.TemplateResource
	CustomFieldToResource(source *ent.CustomField) externalapi.CustomFieldResource
	TagToResource(source *ent.Tag) externalapi.TagResource
	// The contract names the discarded state "archived" (ADR 0049).
	// goverter:map DiscardedAt ArchivedAt
	// goverter:map . Steps | automationSteps
	AutomationToResource(source *ent.Automation) externalapi.AutomationResource

	// 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) externalapi.IntegrationResource

	// A Captured message names its From as the contract does, and the nullable parts as null.
	// goverter:map FromEmail From
	// goverter:map IntegrationID IntegrationId
	// goverter:map OutboundMessageID OutboundMessageId | nilEntityID
	// goverter:map FromName FromName | nilString
	// goverter:map SendingSource SendingSource | nilString
	CapturedMessageToResource(source *ent.CapturedMessage) externalapi.CapturedMessageResource
	// The list leaves the content out.
	// goverter:map FromEmail From
	// goverter:map IntegrationID IntegrationId
	// goverter:map OutboundMessageID OutboundMessageId | nilEntityID
	// goverter:map FromName FromName | nilString
	// goverter:map SendingSource SendingSource | nilString
	CapturedMessageToSummary(source *ent.CapturedMessage) externalapi.CapturedMessageSummary
	// 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) externalapi.SmtpConfig
	// goverter:map . Kind | sesConfigKind
	SesConfigToResource(source integrations.RedactedSES) externalapi.SesConfig
	// goverter:map Sent24h SentLast24h
	SendLimitToStatus(source sendlimit.Status) externalapi.SendLimitStatus

	// 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) externalapi.RuleResource

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

	RuleDryRunToResource(source rules.DryRun) externalapi.RuleDryRunResource

	// goverter:map . Failure | enrollmentFailure
	EnrollmentToResource(source *ent.AutomationRun) externalapi.EnrollmentResource

	// The signing secret is deliberately never part of an /api response; the failure state
	// is derived from the failure columns and a nil event filter renders as an empty list.
	// goverter:map EventTypes EventTypes | eventTypes
	// goverter:map . Failure | webhookFailure
	// goverter:map . Enabled | webhookEnabled
	WebhookToResource(source *ent.WebhookEndpoint) externalapi.WebhookResource

	// 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) externalapi.SendingDomainResource
	// goverter:map . Type | dnsRecordType
	DnsRecordToResource(source sendingdomains.Record) externalapi.DnsRecord
	// goverter:map . Type | trackingRecordType
	// goverter:map CheckedAt LastCheckedAt
	TrackingRecordToResource(source sendingdomains.TrackingRecord) externalapi.TrackingRecord

	// 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) externalapi.BrandKitResource

	// goverter:map . Actor | auditActor
	// goverter:map . Target | auditTarget
	AuditEntryToResource(source auditapi.View) externalapi.AuditEntryResource

	SuppressionToResource(source *ent.Suppression) externalapi.SuppressionResource
	UnsubscribeToResource(source *ent.Unsubscribe) externalapi.UnsubscribeResource

	// 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) externalapi.ContactExportContact
	TagToExport(source *ent.Tag) externalapi.ContactExportTag
	VisitorToExport(source *ent.Visitor) externalapi.ContactExportVisitor
	EventToExport(source *ent.Event) externalapi.ContactExportEvent
	UnsubscribeToExport(source *ent.Unsubscribe) externalapi.ContactExportUnsubscribe
	SuppressionToExport(source *ent.Suppression) externalapi.ContactExportSuppression
	ConfirmationToExport(source *ent.Confirmation) externalapi.ContactExportConfirmation
	OutboundMessageToExport(source *ent.OutboundMessage) externalapi.ContactExportOutboundMessage
	BroadcastRecipientToExport(source *ent.BroadcastRecipient) externalapi.ContactExportBroadcastRecipient
}

Converter maps ent entities to external API resources. goverter generates the implementation; the extends below cover the conversions it can't infer.

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 optNilEmailAddress goverter:extend optNilTimeZone goverter:extend optNilTimestamp goverter:extend openRate goverter:extend clickRate goverter:extend optNilEntityID goverter:extend contactCustomFields goverter:extend optNilInt32 goverter:extend exportJSON goverter:extend segmentCondition goverter:extend ruleActions goverter:extend ruleResults goverter:extend templateDoc goverter:extend broadcastDoc goverter:extend nilInt32 goverter:extend nilString goverter:extend count goverter:extend omitEmpty goverter:extend sendLimitWarning goverter:extend sendLimitSource goverter:extend optTimestamp goverter:extend optInt32 goverter:extend optString goverter:extend optTrackingReason goverter:extend auditDiff goverter:extend optWebhookDisabledReason

type ConverterImpl

type ConverterImpl struct{}

func (*ConverterImpl) ApiTokenToInfo

func (c *ConverterImpl) ApiTokenToInfo(source *ent.ApiToken) external.ApiTokenInfo

func (*ConverterImpl) AuditEntryToResource

func (c *ConverterImpl) AuditEntryToResource(source auditapi.View) external.AuditEntryResource

func (*ConverterImpl) AutomationToResource

func (c *ConverterImpl) AutomationToResource(source *ent.Automation) external.AutomationResource

func (*ConverterImpl) BrandKitToResource

func (c *ConverterImpl) BrandKitToResource(source brandkit.Kit) external.BrandKitResource

func (*ConverterImpl) BroadcastRecipientToExport

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

func (*ConverterImpl) BroadcastReportToResource

func (c *ConverterImpl) BroadcastReportToResource(source broadcasts.Report) external.BroadcastReport

func (*ConverterImpl) BroadcastToResource

func (c *ConverterImpl) BroadcastToResource(source *ent.Broadcast) external.BroadcastResource

func (*ConverterImpl) CapturedMessageToResource

func (c *ConverterImpl) CapturedMessageToResource(source *ent.CapturedMessage) external.CapturedMessageResource

func (*ConverterImpl) CapturedMessageToSummary

func (c *ConverterImpl) CapturedMessageToSummary(source *ent.CapturedMessage) external.CapturedMessageSummary

func (*ConverterImpl) ConfirmationToExport

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

func (*ConverterImpl) ContactToExport

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

func (*ConverterImpl) ContactToResource

func (c *ConverterImpl) ContactToResource(source *ent.Contact) external.ContactResource

func (*ConverterImpl) CustomFieldToResource

func (c *ConverterImpl) CustomFieldToResource(source *ent.CustomField) external.CustomFieldResource

func (*ConverterImpl) DnsRecordToResource

func (c *ConverterImpl) DnsRecordToResource(source sendingdomains.Record) external.DnsRecord

func (*ConverterImpl) EmailTemplateToResource

func (c *ConverterImpl) EmailTemplateToResource(source *ent.EmailTemplate) external.TemplateResource

func (*ConverterImpl) EnrollmentToResource

func (c *ConverterImpl) EnrollmentToResource(source *ent.AutomationRun) external.EnrollmentResource

func (*ConverterImpl) EventToExport

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

func (*ConverterImpl) IntegrationToResource

func (c *ConverterImpl) IntegrationToResource(source *ent.Integration) external.IntegrationResource

func (*ConverterImpl) OutboundMessageToExport

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

func (*ConverterImpl) RuleDryRunToResource

func (c *ConverterImpl) RuleDryRunToResource(source rules.DryRun) external.RuleDryRunResource

func (*ConverterImpl) RuleFiringToResource

func (c *ConverterImpl) RuleFiringToResource(source *ent.RuleFiring) external.RuleFiringResource

func (*ConverterImpl) RuleToResource

func (c *ConverterImpl) RuleToResource(source *ent.Rule) external.RuleResource

func (*ConverterImpl) SegmentToResource

func (c *ConverterImpl) SegmentToResource(source *ent.Segment) external.SegmentResource

func (*ConverterImpl) SendLimitToStatus

func (c *ConverterImpl) SendLimitToStatus(source sendlimit.Status) external.SendLimitStatus

func (*ConverterImpl) SendingDomainToResource

func (c *ConverterImpl) SendingDomainToResource(source *ent.SendingDomain) external.SendingDomainResource

func (*ConverterImpl) SesConfigToResource

func (c *ConverterImpl) SesConfigToResource(source integrations.RedactedSES) external.SesConfig

func (*ConverterImpl) SmtpConfigToResource

func (c *ConverterImpl) SmtpConfigToResource(source integrations.RedactedSMTP) external.SmtpConfig

func (*ConverterImpl) SuppressionToExport

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

func (*ConverterImpl) SuppressionToResource

func (c *ConverterImpl) SuppressionToResource(source *ent.Suppression) external.SuppressionResource

func (*ConverterImpl) TagToExport

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

func (*ConverterImpl) TagToResource

func (c *ConverterImpl) TagToResource(source *ent.Tag) external.TagResource

func (*ConverterImpl) TrackingRecordToResource

func (c *ConverterImpl) TrackingRecordToResource(source sendingdomains.TrackingRecord) external.TrackingRecord

func (*ConverterImpl) UnsubscribeToExport

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

func (*ConverterImpl) UnsubscribeToResource

func (c *ConverterImpl) UnsubscribeToResource(source *ent.Unsubscribe) external.UnsubscribeResource

func (*ConverterImpl) VisitorToExport

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

func (*ConverterImpl) WebhookToResource

func (c *ConverterImpl) WebhookToResource(source *ent.WebhookEndpoint) external.WebhookResource

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