notifications

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const RelativeRoot = "content/notifications"

Variables

View Source
var FallbackLocales = []string{
	"ar", "bg", "ca", "cs", "da", "de", "el", "en", "es", "et", "eu",
	"fa", "fi", "fr", "ga", "gl", "hi", "hr", "hu", "is", "it", "ja",
	"ko", "lb", "lt", "lv", "nl", "no", "pl", "pt", "ro", "ru", "sl",
	"sr", "sv", "th", "tr", "zh",
}

FallbackLocales mirrors the legacy locale allowlist.

Functions

func AllowedLocales

func AllowedLocales(siteLocales []string) map[string]struct{}

AllowedLocales builds the accepted locale set.

func BuildNotifications

func BuildNotifications(root string, only map[string]struct{}, allowedLocales map[string]struct{}) ([]api.Notification, error)

BuildNotifications reads disk templates and converts them to API notifications.

func ResolveProjectRoot

func ResolveProjectRoot() (string, error)

ResolveProjectRoot returns the nearest nimbu.yml directory or cwd.

func RootPath

func RootPath(projectRoot string) string

RootPath returns the notifications directory for a project root.

func ToNotification

func ToNotification(tpl Template) api.Notification

ToNotification converts a local template into api.Notification for output.

func ToNotificationPayload

func ToNotificationPayload(tpl Template) map[string]any

ToNotificationPayload converts one local template into API payload form.

func WriteNotifications

func WriteNotifications(root string, notifications []api.Notification, only map[string]struct{}) ([]string, error)

WriteNotifications writes remote notifications to the local disk contract.

Types

type PullResult

type PullResult struct {
	Root    string   `json:"root"`
	Slugs   []string `json:"slugs"`
	Written []string `json:"written"`
}

PullResult reports files written during pull.

func Pull

func Pull(ctx context.Context, client *api.Client, root string, only map[string]struct{}) (PullResult, error)

Pull fetches remote notifications and writes them to disk.

type PushAction

type PushAction struct {
	Action string `json:"action"`
	Slug   string `json:"slug"`
}

PushAction reports one uploaded notification.

type PushResult

type PushResult struct {
	Root    string       `json:"root"`
	Actions []PushAction `json:"actions"`
}

PushResult reports notifications uploaded during push.

func Push

func Push(ctx context.Context, client *api.Client, root string, allowedLocales map[string]struct{}, only map[string]struct{}) (PushResult, error)

Push uploads local notifications using safe upsert semantics.

type Template

type Template struct {
	Slug         string
	Name         string
	Description  string
	Subject      string
	Text         string
	HTML         string
	HTMLEnabled  bool
	Translations map[string]Translation
}

Template models one notification template on disk.

func ReadTemplates

func ReadTemplates(root string, only map[string]struct{}, allowedLocales map[string]struct{}) ([]Template, error)

ReadTemplates reads local notifications from disk.

func (Template) ToNotification

func (t Template) ToNotification() api.Notification

ToNotification converts a disk template into the API contract.

type Translation

type Translation struct {
	Subject string
	Text    string
	HTML    string
}

Translation models one localized override on disk.

Jump to

Keyboard shortcuts

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