schema

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package schema registers Hanzo Notify's domain collections with the underlying hanzoai/base app.

Nine collections cover the v1 surface:

tenants                          — IAM-org-slug namespace (one row per org)
providers                        — per-tenant provider config (KMS path + status)
templates                        — re-usable message bodies with approval lifecycle
events                           — event catalog (routing + rate-limit policy)
messages                         — persisted send records (audit + lookup)
meter                            — per-send ledger for billing rollup
notification_preferences         — per-(user, org) channel + marketing prefs (Phase 1)
notification_consent_log         — append-only audit trail of preference changes
notification_unsubscribe_tokens  — HMAC-signed one-click unsubscribe links

Each user-data collection scopes by `tenant` (relation to `tenants`, whose id is the IAM org slug). Access rules deny anonymous read; the route layer narrows further via X-Org-Id from the platform plugin.

Index

Constants

View Source
const (
	Tenants   = "tenants"
	Providers = "providers"
	Templates = "templates"
	Events    = "events"
	Messages  = "messages"
	Meter     = "meter"

	// Phase 1 collections from the notification-preferences paper.
	Preferences       = "notification_preferences"
	ConsentLog        = "notification_consent_log"
	UnsubscribeTokens = "notification_unsubscribe_tokens"
)

Collection names. Hard-coded; this is the contract between the schema, the routes, and the worker.

View Source
const (
	ConsentEventOptIn         = "opt_in"
	ConsentEventOptOut        = "opt_out"
	ConsentEventChannelUpdate = "channel_update"
	ConsentEventPrefUpdate    = "pref_update"
)

ConsentLog event values stored in notification_consent_log.event.

View Source
const (
	MessageStatusQueued    = "queued"
	MessageStatusSending   = "sending"
	MessageStatusSent      = "sent"
	MessageStatusDelivered = "delivered"
	MessageStatusFailed    = "failed"
)

Message status values stored in messages.status.

View Source
const (
	ProviderStatusPendingTest = "pending_test"
	ProviderStatusActive      = "active"
	ProviderStatusDisabled    = "disabled"
)

Provider lifecycle values stored in providers.status.

View Source
const (
	TemplateStatusDraft           = "draft"
	TemplateStatusPendingApproval = "pending_approval"
	TemplateStatusApproved        = "approved"
	TemplateStatusPublished       = "published"
	TemplateStatusArchived        = "archived"
)

Template lifecycle values stored in templates.status.

Variables

This section is empty.

Functions

func MustRegister

func MustRegister(_ *base.Base)

MustRegister wires the notify schema migration into the app. Idempotent: subsequent boots find the collections already present and skip creation. Panics on registration errors so boot fails loudly.

Types

This section is empty.

Jump to

Keyboard shortcuts

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