Documentation
¶
Overview ¶
Package contactexport is the subject-access Data export of one Contact (GDPR Art. 15/20, ADR 0021): a streamed JSON document holding the Contact, its Tags, Visitors, all Events, the Unsubscribe/Suppression/Confirmation rows for its Destinations and the OutboundMessage / BroadcastRecipient delivery metadata. Rendered message bodies are never part of it (no entity read here carries one). Each row is projected onto the contract's typed ContactExportDocument members by a Mapper, never encoded as the stored entity. Large collections are read in keyset pages and written straight to the writer, so the document is never buffered whole.
Index ¶
- Variables
- func Filename(c *ent.Contact) string
- func Find(ctx context.Context, s *ent.Scoped, id *int64, email *string) (*ent.Contact, error)
- func Open(ctx context.Context, s *ent.Scoped, m Mapper, c *ent.Contact) io.Reader
- func Ref[T ~string](v T, ok bool) *string
- func Stream(ctx context.Context, s *ent.Scoped, m Mapper, w io.Writer, c *ent.Contact) error
- type Mapper
Constants ¶
This section is empty.
Variables ¶
var ErrIdentifier = errors.New("contactexport: exactly one of id or email is required")
ErrIdentifier means the request named neither or both of id and email.
var ErrNotFound = errors.New("contactexport: contact not found")
ErrNotFound means no Contact in the Workspace matches the identifier.
Functions ¶
func Find ¶
Find resolves the Contact to export by exactly one of its id or email, inside the Workspace of s: another Workspace's Contact is not found. Both surfaces map its two errors (ErrIdentifier: bad request; ErrNotFound) the same way.
func Open ¶
Open starts the export of c in the background and returns the stream to hand to the HTTP response: the document is produced as the response is read. The producer ends with the request's context, so an abandoned download cannot leak it.
Types ¶
type Mapper ¶
type Mapper interface {
Contact(row *ent.Contact) json.Marshaler
Tag(row *ent.Tag) json.Marshaler
Visitor(row *ent.Visitor) json.Marshaler
Event(row *ent.Event) json.Marshaler
Unsubscribe(row *ent.Unsubscribe) json.Marshaler
Suppression(row *ent.Suppression) json.Marshaler
Confirmation(row *ent.Confirmation) json.Marshaler
OutboundMessage(row *ent.OutboundMessage) json.Marshaler
BroadcastRecipient(row *ent.BroadcastRecipient) json.Marshaler
}
Mapper projects stored rows onto the members of the surface's generated ContactExportDocument. Each surface (site, external) generates its own copy of those types from the shared TypeSpec model, so a Mapper hands back each member as a json.Marshaler and the document is assembled here without knowing which surface it serves. Stored rows are never encoded directly: the contract, not the ent JSON tags, decides what a person sees.