export

package
v0.76.8 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package export is the notes export SPI of Meeting Mode: one Document that describes a finished meeting, a structural Outline built from it, Markdown and XHTML renderers of that outline, and the Target interface every sync destination implements (a Markdown file, OneNote, Notion or a host's own).

The package knows nothing about any destination. A target receives the Document and the binary Parts it references, and answers with a Receipt that names what it wrote and the content fingerprint it wrote, so a host can skip a re-push of unchanged content without asking the destination.

Everything in a Document is untrusted text: a model wrote the review after listening to the meeting, and a title can come from a window or a calendar subject. The renderers escape it; neither output can load anything.

Stability: Beta — API-checked; may change with a changelog callout.

Example
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/kombifyio/SpeechKit/pkg/speechkit/meeting/export"
)

// stdoutTarget is a host's own target: it prints the Markdown rendering.
type stdoutTarget struct{}

func (stdoutTarget) ID() string { return "stdout" }

func (stdoutTarget) Push(_ context.Context, doc export.Document, opts export.Options) (export.Receipt, error) {
	fingerprint := doc.Fingerprint()
	if opts.Previous.Fingerprint == fingerprint {
		return export.Receipt{TargetID: "stdout", ExternalID: opts.Previous.ExternalID, Fingerprint: fingerprint, Unchanged: true}, nil
	}
	fmt.Print(doc.Outline().Markdown())
	return export.Receipt{TargetID: "stdout", ExternalID: "1", Fingerprint: fingerprint}, nil
}

func main() {
	registry := export.NewRegistry()
	if err := registry.Register(stdoutTarget{}); err != nil {
		panic(err)
	}
	doc := export.Document{
		Title:     "Weekly sync",
		StartedAt: time.Date(2026, 10, 12, 9, 30, 0, 0, time.UTC),
		Locale:    "en",
		Sections: []export.Section{{
			Title: "Decisions",
			Items: []export.Item{{Text: "Release on Friday", CitationIDs: []int64{7}}},
		}},
		Notes:     []export.Note{{Text: "check the installer", Offset: 90 * time.Second, Stamped: true}},
		Citations: []export.Citation{{SegmentID: 7, Offset: 3 * time.Minute, Speaker: "Ana", Text: "Friday works."}},
	}
	receipt, _ := registry.Push(context.Background(), "stdout", doc, export.Options{})
	again, _ := registry.Push(context.Background(), "stdout", doc, export.Options{Previous: receipt})
	fmt.Println("second push unchanged:", again.Unchanged)
}
Output:
# Weekly sync

_2026-10-12 09:30 · en_

## Decisions

- Release on Friday [1]

## My notes

- [01:30] check the installer

## Transcript citations

1. 03:00 Ana: Friday works.
second push unchanged: true

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrTargetUnavailable: the target is not registered, not connected, or
	// not allowed in this deployment.
	ErrTargetUnavailable = errors.New("export: target unavailable")
	// ErrDestinationGone: the destination (a section, a page, a folder) no
	// longer exists. The host decides whether to pick a new one.
	ErrDestinationGone = errors.New("export: destination gone")
	// ErrDestinationFull: the destination refuses more content.
	ErrDestinationFull = errors.New("export: destination full")
	// ErrTooLarge: the document or one of its parts exceeds what the
	// destination accepts, even after fitting.
	ErrTooLarge = errors.New("export: too large")
	// ErrDestinationNotAllowed: the destination lies outside what this
	// deployment lets the target write to (a policy-pinned notebook scope).
	// A target answers it before it sends anything.
	ErrDestinationNotAllowed = errors.New("export: destination not allowed")
)

Sentinel errors a Target wraps so a host can react without knowing the destination. Test with errors.Is.

Functions

func FormatOffset

func FormatOffset(offset time.Duration) string

FormatOffset renders an offset from the meeting start as m:ss, or h:mm:ss from the first hour on.

func ImagePartName

func ImagePartName(id string) string

ImagePartName is the multipart part name the XHTML renderer references an image by ("name:<part>"). It is derived from the id, so a target that attaches the bytes finds the name without a lookup table, and it contains only letters and digits whatever the id holds.

Types

type Block

type Block struct {
	Kind     BlockKind `json:"kind"`
	Level    int       `json:"level,omitempty"`
	Text     string    `json:"text,omitempty"`
	Emphasis bool      `json:"emphasis,omitempty"`
	Ordered  bool      `json:"ordered,omitempty"`
	Items    []string  `json:"items,omitempty"`
	ImageID  string    `json:"imageId,omitempty"`
	Alt      string    `json:"alt,omitempty"`
}

Block is one element of an Outline. Which fields matter depends on Kind: a heading has Level (1 to 6) and Text, a paragraph Text and Emphasis, a list Ordered and Items, an image ImageID and Alt.

type BlockKind

type BlockKind string

BlockKind names one structural element of an Outline.

const (
	BlockHeading   BlockKind = "heading"
	BlockParagraph BlockKind = "paragraph"
	BlockList      BlockKind = "list"
	BlockImage     BlockKind = "image"
)

The block kinds an Outline is built from.

type Citation

type Citation struct {
	SegmentID int64         `json:"segmentId"`
	Offset    time.Duration `json:"offset"`
	Speaker   string        `json:"speaker,omitempty"`
	Text      string        `json:"text"`
}

Citation is one transcript line, with its offset from the meeting start.

type Destination

type Destination struct {
	ID        string `json:"id"`
	ParentID  string `json:"parentId,omitempty"`
	Name      string `json:"name,omitempty"`
	Container string `json:"container,omitempty"`
}

Destination is where a target writes: a section, a database, a folder. ParentID is its container (a notebook) where the target needs one to create a sibling. Container names the space both ids live in where a target serves several (a OneNote site); empty is the target's default space.

type Document

type Document struct {
	Title     string    `json:"title"`
	StartedAt time.Time `json:"startedAt"`
	// Locale is the BCP-47 tag of the review's language.
	Locale string `json:"locale,omitempty"`
	// Brief is the executive brief: a handful of sentences.
	Brief []string `json:"brief,omitempty"`
	// Sections are the review's headings in order.
	Sections []Section `json:"sections,omitempty"`
	// Notes are what the user typed, reproduced verbatim.
	Notes []Note `json:"notes,omitempty"`
	// Citations are the transcript lines the review cites.
	Citations []Citation `json:"citations,omitempty"`
	// Screenshots reference binary parts by id; the bytes travel in
	// Options.Parts.
	Screenshots []Screenshot `json:"screenshots,omitempty"`
	// Labels are the headings the renderers add. Zero fields fall back to
	// English, so a host passes the catalog strings for Locale.
	Labels Labels `json:"labels,omitzero"`
}

Document is one finished meeting as an export sees it.

func (Document) Fingerprint

func (d Document) Fingerprint() string

Fingerprint identifies the content of a Document. Two documents with the same fingerprint render identically; a target compares it with the fingerprint of its last Receipt to skip an unchanged re-push. Part bytes are not hashed: a screenshot id names immutable content.

func (Document) Outline

func (d Document) Outline() Outline

Outline builds the structure of the document: date and language, the brief, the review sections with citation markers, the user's notes verbatim, the cited transcript lines and the screenshots.

type Item

type Item struct {
	Text string `json:"text"`
	// Owner and Due are set for action items where the meeting named them.
	Owner string `json:"owner,omitempty"`
	Due   string `json:"due,omitempty"`
	// CitationIDs are the SegmentIDs of the Document's Citations this bullet
	// came from.
	CitationIDs []int64 `json:"citationIds,omitempty"`
}

Item is one bullet of a review section.

type Labels

type Labels struct {
	Brief       string `json:"brief,omitempty"`
	Notes       string `json:"notes,omitempty"`
	Citations   string `json:"citations,omitempty"`
	Screenshots string `json:"screenshots,omitempty"`
	Screenshot  string `json:"screenshot,omitempty"`
}

Labels are the renderer's own headings.

type Note

type Note struct {
	Text    string        `json:"text"`
	Offset  time.Duration `json:"offset,omitempty"`
	Stamped bool          `json:"stamped,omitempty"`
}

Note is one note the user wrote. Stamped is false for a note taken before stamps existed; it keeps no invented time.

type Options

type Options struct {
	Destination Destination
	// Parts holds the screenshot bytes; nil exports text only.
	Parts Parts
	// Previous is the receipt of the last successful push of this document
	// to this target, or zero. Its fingerprint and external id make a
	// re-push idempotent.
	Previous Receipt
	// AllowRollover lets a target create a sibling destination when the
	// configured one is full, instead of answering ErrDestinationFull.
	AllowRollover bool
}

Options steer one push.

type Outline

type Outline struct {
	Title   string    `json:"title"`
	Created time.Time `json:"created,omitzero"`
	Locale  string    `json:"locale,omitempty"`
	Blocks  []Block   `json:"blocks"`
}

Outline is the structure a Document renders to. It is built, never parsed from Markdown, so every renderer sees the same blocks; a target may also split it (a slice of Blocks is an Outline of its own).

func (Outline) BodyXHTML

func (o Outline) BodyXHTML() string

BodyXHTML renders only the blocks, as the content of a body element. A target appends it to an existing page.

func (Outline) ImageIDs

func (o Outline) ImageIDs() []string

ImageIDs lists the image ids of the outline in order.

func (Outline) Markdown

func (o Outline) Markdown() string

Markdown renders the outline as a Markdown file. Text is neutralised so a viewer that renders HTML or images loads nothing: "<" is escaped and image syntax "![" loses its "!".

func (Outline) XHTML

func (o Outline) XHTML() string

XHTML renders the outline as a complete XHTML page in the subset Microsoft OneNote accepts as page input: html, head, title, meta, body, h1 to h6, p, ul, ol, li, i and img. It is well-formed XML in UTF-8; images reference multipart parts as src="name:<ImagePartName(id)>".

type Part

type Part struct {
	ID          string
	ContentType string
	Data        []byte
}

Part is one binary attachment of a Document.

type Parts

type Parts interface {
	Load(ctx context.Context, id string) (Part, error)
}

Parts gives a target the bytes behind a Screenshot id. Load answers an error wrapping fs.ErrNotExist (or any error) for a part that is gone; the target then skips it and reports it in Receipt.Skipped.

type PartsMap

type PartsMap map[string]Part

PartsMap is an in-memory Parts.

func (PartsMap) Load

func (m PartsMap) Load(_ context.Context, id string) (Part, error)

Load implements Parts.

type Receipt

type Receipt struct {
	TargetID   string `json:"targetId"`
	ExternalID string `json:"externalId"`
	URL        string `json:"url,omitempty"`
	// Fingerprint is the Document fingerprint the destination now holds.
	// It is empty when a push failed half-way: the external object exists
	// but does not hold the whole document.
	Fingerprint string `json:"fingerprint,omitempty"`
	// Destination is where the push landed; it differs from the requested
	// one after a rollover.
	Destination Destination `json:"destination,omitzero"`
	// Skipped lists screenshot ids that were not written (missing parts or
	// a destination limit).
	Skipped []string `json:"skipped,omitempty"`
	// Unchanged is true when the push sent nothing because the destination
	// already held this fingerprint.
	Unchanged bool      `json:"unchanged,omitempty"`
	PushedAt  time.Time `json:"pushedAt,omitzero"`
}

Receipt records what a push wrote.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds the targets a host offers. It is safe for concurrent use.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) IDs

func (r *Registry) IDs() []string

IDs lists the registered target ids in sorted order.

func (*Registry) Push

func (r *Registry) Push(ctx context.Context, targetID string, doc Document, opts Options) (Receipt, error)

Push looks the target up and pushes the document to it.

func (*Registry) Register

func (r *Registry) Register(target Target) error

Register adds a target. A second target with the same id is refused.

func (*Registry) Target

func (r *Registry) Target(id string) (Target, error)

Target returns the registered target, or ErrTargetUnavailable.

type Screenshot

type Screenshot struct {
	ID      string        `json:"id"`
	Offset  time.Duration `json:"offset"`
	Caption string        `json:"caption,omitempty"`
}

Screenshot references one image part by id.

type Section

type Section struct {
	Title string `json:"title"`
	Items []Item `json:"items,omitempty"`
}

Section is one heading of the review.

type Target

type Target interface {
	// ID is the stable identifier the registry and the store use.
	ID() string
	// Push writes the document. When opts.Previous carries the current
	// fingerprint, Push returns it with Unchanged set and sends nothing.
	Push(ctx context.Context, doc Document, opts Options) (Receipt, error)
}

Target is one export destination.

Jump to

Keyboard shortcuts

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