notion

package
v1.801.360 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

export.go normalizes a Notion workspace EXPORT (the "Markdown & CSV" or "HTML" zip a user downloads) into vault.Page documents — distinct from notion.go, which shapes records from the live Notion API connector. Both live in this package because both are pure Notion-format knowledge; neither depends on cloud.

A Notion export encodes hierarchy in the directory tree (a page's subpages live in a folder named after the page) and links between pages as relative file links ([text](Child%20<id>.md) or <a href="Child%20<id>.html">). This normalizer rebuilds the parent tree from the folder nesting and rewrites intra-export links to "[Title]" wikilinks, so the kb-page after_save hook extracts them into kb-link edges — the export's link structure survives as real KB links.

Package notion is the pure record-shaping logic for the Notion long-tail connector: how to turn the raw JSON a Notion search returns (via the activepieces piece run through the auto engine) into normalized {title, body, external_id, url, timestamp} documents for KB ingestion. It has NO cloud dependency, so the Notion parsing — where the real per-provider complexity lives — is unit-testable in isolation. clients/kb/sync_piece.go wires this into the framework.Ingest path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body(rec map[string]any) string

Body renders a short body from the record's plain-text property values, so the embedding has prose beyond the title. Full block content is a follow-up getPageOrBlockChildren pull; this keeps the first ingest bounded and honest.

func ParseExport

func ParseExport(files []vault.File) ([]vault.Page, error)

ParseExport maps a Notion export's page files (.md or .html) to pages, resolving the parent tree from folder nesting and rewriting intra-export links to wikilinks. Non-page files (.csv databases, images) are ignored.

func Results

func Results(output any) []map[string]any

Results extracts the item list from a custom_api_call output. The piece returns { status, headers, body }; a Notion search puts items under body.results.

func Time

func Time(iso string) string

Time converts a Notion ISO timestamp to the store's "YYYY-MM-DD HH:MM:SS".

func Title

func Title(rec map[string]any) string

Title extracts a human title from a Notion page/database record. A database stores its title at the top-level `title` array; a page under the title-typed property.

Types

type Doc

type Doc struct {
	Title      string
	Body       string
	ExternalID string
	URL        string
	Timestamp  string // "YYYY-MM-DD HH:MM:SS" or ""
}

Doc is a normalized Notion record ready to file as a kb-source. The KB sync maps it onto the framework document fields (title/body/external_id/url/source_ts).

func Normalize

func Normalize(rec map[string]any) Doc

Normalize maps ONE Notion page/database record to a Doc.

Jump to

Keyboard shortcuts

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