Skip to main content

Crate notion2prompt

Crate notion2prompt 

Source
Expand description

notion2prompt library — converts Notion pages and databases into structured prompts.

§Public API

The library exposes types organized by concern:

  • Error handlingAppError, ValidationError
  • ConfigurationPipelineConfig
  • Domain modelNotionObject, Page, Database, Block, etc.
  • Domain typesNotionId, ApiKey, BlockId, PageId, etc.
  • API clientNotionFetcher, NotionHttpClient, parsers
  • Formattingrender_blocks, RenderContext, TableBuilder

Structs§

Annotations
ApiKey
API key for Notion API authentication
ApiResponse
Result of an HTTP operation with response metadata.
BlockCommon
Common fields for all blocks
BookmarkBlock
Bookmark block
BreadcrumbBlock
Breadcrumb block
BulletedListItemBlock
Bulleted list item block
CachedNotionClient
A NotionRepository implementation that caches raw API JSON responses to disk. Cache hits re-parse through the standard parsers so the domain model is never serialized/deserialized directly.
CalloutBlock
Callout block
ChildDatabaseBlock
Child database block
ChildPageBlock
Child page block
CodeBlock
Code block
ColumnBlock
Column block
ColumnListBlock
Column list block
Database
A Notion database
DatabaseProperty
Database property definition
DatabaseTitle
Database title
DateValue
Date value with optional time and end date
DividerBlock
Divider block
EmbedBlock
Embed block
EquationBlock
Equation block
EquationData
ExternalFile
FileBlock
File block
Heading1Block
Heading 1 block
Heading2Block
Heading 2 block
Heading3Block
Heading 3 block
ImageBlock
Image block
Link
LinkPreviewBlock
Link preview block
LinkToPageBlock
Link to page block
MentionData
Mention data with type information
NotionFetcher
Enhanced queue-based fetcher with parallel work-stealing and error recovery.
NotionFile
NotionHttpClient
A thin wrapper around reqwest Client for Notion API requests.
NotionId
NotionId - A general-purpose Notion ID that can represent any type of object
NumberedListItemBlock
Numbered list item block
ObjectGraph
Immutable graph representing parent-child relationships between Notion objects.
Page
A Notion page
PageTitle
Page title
ParagraphBlock
Paragraph block
PartialUser
Partial user representation (used in mentions)
PdfBlock
PDF block
PipelineConfig
Resolved pipeline configuration — validated and ready to drive all three stages.
PropertyName
The name of a property on a Notion page or database.
PropertyValue
Property value — wraps a typed value with its property ID.
QuoteBlock
Quote block
RenderContext
Context passed through the rendering pipeline.
RenderedPrompt
The final output of the render stage — a complete prompt ready for delivery.
RichTextItem
Rich text item with formatting annotations.
SelectOption
Select option
SyncedBlock
Synced block
SyncedFrom
TableBlock
Table block
TableBuilder
Builder for constructing tables from databases.
TableOfContentsBlock
Table of contents block
TableRowBlock
Table row block
TemplateBlock
Template block
TemplateName
Template name with validation
TextBlockContent
Text content block
TextContent
Legacy text content — kept for API deserialization compatibility.
ToDoBlock
To-do block
ToggleBlock
Toggle block
UnsupportedBlock
Unsupported block
User
User representation
ValidatedUrl
Validated URL type
VideoBlock
Video block
Warning
Warning message with structured information

Enums§

AppError
Main application error type.
Block
Block represents all possible Notion block types
ChildDatabaseContent
The resolution state of a child database’s content.
Color
Type-safe color enum instead of strings
DatabaseFetchFailure
Domain vocabulary for why a database fetch failed.
DatabasePropertyType
Database property types
FetchError
Error that can occur during content retrieval operations.
FileObject
File object types
FormulaResult
Formula result types
Icon
Icon types
MentionType
Different types of mentions in rich text
NotionObject
The root object that can be fetched from Notion
NumberFormat
Number format options
Parent
Parent reference with typed IDs
PropertyTypeValue
The specific value types for properties - compatibility layer
RichTextType
The kind of rich text content — a typed vocabulary replacing stringly-typed dispatch.
RollupResult
Rollup result types - used by legacy PropertyValue system
TrackError
Error that can occur during visit tracking operations.
ValidationError
WarningLevel

Traits§

BlockVisitor
Visitor trait for traversing block structures.
ContentSource
Retrieves Notion content by ID.
DepthLimiter
Depth limiting capability for controlling recursion depth.
NotionContent
Content retrieval capability for Notion API.
NotionContentExt
Extension trait with typed convenience methods for NotionContent.
NotionRepository
The ability to retrieve content from a Notion workspace.
PromptComposer
Transforms a NotionObject into a RenderedPrompt.
PromptDelivery
Delivers a rendered prompt to its destinations.
VisitTracker
Visit tracking capability for preventing cycles during recursive traversal.

Functions§

compose_block_markdown
Composes a single block into markdown with a heading.
compose_database_summary
Composes a database summary as markdown: title, schema, data count, metadata.
compose_notion_markdown
Composes any NotionObject into markdown — dispatches by variant.
compose_page_markdown
Composes a Notion page into markdown: title, properties, content, metadata.
parse_block_response
Parse block response using notion-client
parse_blocks_pagination
Pagination function for blocks (using notion-client) - returns PaginatedResponse
parse_database_response
Parse database response using notion-client
parse_page_response
Parse page response using notion-client
parse_pages_pagination
Pagination function for pages (using notion-client) - returns PaginatedResponse
render_blocks
Renders a slice of blocks into markdown.
render_prompt
Renders a NotionObject into a prompt string using Handlebars templates.

Type Aliases§

BlockId
DatabaseId
PageId
Type aliases for specific ID types
UserId