Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,140 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **tests/Unit/Public/Block/Bookmark/New-NotionBookmarkBlock.Tests.ps1**
Introduced unit tests for `New-NotionBookmarkBlock`, covering default and captioned bookmark creation.

- **tests/Unit/Public/Block/Breadcrumb/New-NotionBreadcrumbBlock.Tests.ps1**
Added unit tests validating default behavior of breadcrumb block creation.

- **tests/Unit/Public/Block/BulletedListItem/New-NotionBulletedListItemBlock.Tests.ps1**
Introduced tests to verify text content and color for bulleted list items.

- **tests/Unit/Public/Block/ChildDatabase/New-NotionChildDatabaseBlock.Tests.ps1**
Added validation for empty and titled child database block generation.

- **tests/Unit/Public/Block/ChildDatabase/ChildPage/New-NotionChildPageBlock.Tests.ps1**
Implemented tests for verifying empty and titled child page block creation.

- **tests/Unit/Public/Block/Code/New-NotionCodeBlock.Tests.ps1**
Introduced unit tests for code block creation with various combinations of text, caption, and language.

- **tests/Unit/Public/Block/Column/New-NotionColumnBlock.Tests.ps1**,
**tests/Unit/Public/Block/ColumnList/New-NotionColumnListBlock.Tests.ps1**
Added tests for verifying the default behavior of column and column list block generation.

- **tests/Unit/Public/Block/Divider/New-NotionDividerBlock.Tests.ps1**
Added validation for divider block construction.

- **tests/Unit/Public/Block/Embed/New-NotionEmbedBlock.Tests.ps1**
Added extensive test coverage for URL and caption handling in embed blocks.

- **tests/Unit/Public/Block/Equation/New-NotionEquationBlock.Tests.ps1**
Added unit tests verifying LaTeX expression parsing in equation blocks.

- **tests/Unit/Public/Block/File/New-NotionFileBlock.Tests.ps1**
Introduced tests for external, hosted, and file-object-based file block creation, including expiry handling.

- **tests/Unit/Public/Block/Heading/New-NotionHeadingBlock.Tests.ps1**
Renamed and relocated test under a structured directory.

- **tests/Unit/Public/Block/Image/New-NotionImageBlock.Tests.ps1**
Added support for image block testing from `notion_file` objects.

- **tests/Unit/Public/Block/LinkPreview/New-NotionLinkPreviewBlock.Tests.ps1**
Added test confirming that `link_preview` blocks cannot be manually created.

- **tests/Unit/Public/Block/NumberedListItem/New-NotionNumberedListItemBlock.Tests.ps1**
Added tests to verify rich text rendering in numbered list items.

- **tests/Unit/Public/Block/Paragraph/New-NotionParagraphBlock.Tests.ps1**
Implemented tests for default and colored paragraph content.

- **tests/Unit/Public/Block/Pdf/New-NotionPdfBlock.Tests.ps1**
Renamed and moved PDF block tests into structured folder.

- **tests/Unit/Public/Block/Quote/New-NotionQuoteBlock.Tests.ps1**
Added validation for quote blocks with content and color options.

- **tests/Unit/Public/Block/Synced/New-NotionSyncedBlock.Tests.ps1**
Added coverage for synced block creation.

- **tests/Unit/Public/Block/Table/New-NotionTableBlock.Tests.ps1**
Rewritten and expanded validation for table blocks, including headers, error handling, and hashtable inputs.

- **tests/Unit/Public/Block/TableOfContents/New-NotionTableOfContentsBlock.Tests.ps1**
Introduced default and color-specific table of contents creation tests.

- **tests/Unit/Public/Block/TableRow/New-NotionTableRowBlock.Tests.ps1**
Added tests verifying creation of table rows from flat cell content arrays.

- **tests/Unit/Public/Block/ToDo/New-NotionToDoBlock.Tests.ps1**
Extensive tests covering plain, checked, and color-variant to-do block creation.

- **tests/Unit/Public/Block/Toggle/New-NotionToggleBlock.Tests.ps1**
Implemented tests for toggle blocks including rich text and color validation.

- **tests/Unit/Public/Block/Video/New-NotionVideoBlock.Tests.ps1**
Renamed and organized video block tests into structured location.

- **tests/Unit/Public/Block/New-NotionBlock.Tests.ps1**
Added meta tests covering dynamic creation of multiple block types using `New-NotionBlock`.

- **tests/Unit/Public/Block/\_RichText/New-NotionRichText.Tests.ps1**
Comprehensive unit tests for rich text construction across multiple parameter sets.

- **tests/Unit/Public/Block/\_RichText/New-NotionRichTextAnnotation.Tests.ps1**
Added focused testing for annotation creation via object and flag-based inputs.

### Changed

- **source/Classes/Block/RichText/01_Rich_Text.ps1**
Minor formatting improvement to spacing in `switch` block for content type routing.

- **source/Classes/Block/RichText/02_Rich_Text_Annotation.ps1**
Improved readability, added verbose logging, and corrected default handling in `ConvertFromObject`.

- **source/Classes/Block/RichText/Type/01_Rich_text_text.ps1**
Introduced verbose output and ensured `plain_text` is assigned from the underlying text structure.

- **source/Classes/Block/RichText/Type/03_Rich_text_equation.ps1**
Implemented full support for `ConvertFromObject` logic and commented out unused `ToJson()` method stub.

- **source/Classes/03_File/03_external_file.ps1**, **source/Classes/Block/23.1_File_block.ps1**
Added `Write-Verbose` diagnostic logging for constructor calls.

### Fixed

- **source/Classes/Block/05_Bookmark.ps1**
Refactored `bookmark_structure` constructor to unify input parsing and ensure consistent caption/url handling.

- **source/Classes/Block/11_Code.ps1**
Fixed incorrect assignment of caption text to rich text; reordered constructor logic for correctness.

- **source/Classes/Block/30_Table_Of_Contents.ps1**
Ensured `color` property is always initialized to a valid default.

- **source/Classes/Block/27.2_TableRow.ps1**
Corrected debug output to reference actual dynamic cell count instead of fixed index.


- **tests/Unit/Classes/Block/05_Bookmark.tests.ps1**
Removed redundant assertion and corrected expected structure for caption verification.

- **tests/Unit/Classes/Block/11_Code.tests.ps1**
Corrected assertion expecting incorrect text in the caption field.

- **tests/Unit/Classes/Block/30_Table_Of_Contents.tests.ps1**
Updated type expectation to match new default structure initialization.

- **tests/Unit/Classes/Database/DatabaseProperties/09_dp_formula.Tests.ps1**
Adjusted tests to validate exception behavior when formula input is missing or malformed.

- **All test files:**
Applied `-DisableNameChecking` to all `Import-Module Pester` statements to suppress Pester warnings and improve compatibility.

## [0.12.0] - 2025-08-23

### Added
Expand Down
1 change: 1 addition & 0 deletions source/Classes/03_File/03_external_file.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class notion_external_file : notion_file

notion_external_file([string]$name, $caption, [string]$url):base("external", $name, $caption)
{
Write-Verbose "[notion_external_file]::new($name, $($caption | ConvertTo-Json -Depth 5 -EnumsAsStrings), $url)"
$this.external = [notion_external_file_structure]::new($url)
}

Expand Down
24 changes: 11 additions & 13 deletions source/Classes/Block/05_Bookmark.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ class bookmark_structure

bookmark_structure($bookmark)
{
if ($bookmark -is [string])
{
$this.url = $bookmark
return
}
elseif ($bookmark -is [PSCustomObject])
{
$this.caption = [rich_text]::ConvertFromObjects($bookmark.caption)
$this.url = $bookmark.url
}
$this.url = $bookmark
}

bookmark_structure([object]$caption, [string]$url)
Expand All @@ -33,7 +24,14 @@ class bookmark_structure
{
return $value
}
return [bookmark_structure]::new($Value)
if ($value -is [string])
{
return [bookmark_structure]::new($value)
}
$bookmark_Obj = [bookmark_structure]::new()
$bookmark_Obj.caption = [rich_text]::ConvertFromObjects($Value.caption)
$bookmark_Obj.url = $Value.url
return $bookmark_Obj
}
}

Expand All @@ -49,7 +47,7 @@ class notion_bookmark_block : notion_block

notion_bookmark_block($url)
{
$this.bookmark = [bookmark_structure]::ConvertFromObject($url)
$this.bookmark = [bookmark_structure]::new($url)
}

notion_bookmark_block($caption, [string]$url)
Expand All @@ -61,7 +59,7 @@ class notion_bookmark_block : notion_block
static [notion_bookmark_block] ConvertFromObject($Value)
{
$bookmark_Obj = [notion_bookmark_block]::new()
$bookmark_Obj.bookmark = [bookmark_structure]::new($Value.bookmark)
$bookmark_Obj.bookmark = [bookmark_structure]::ConvertFromObject($Value.bookmark)
return $bookmark_Obj
}
}
6 changes: 3 additions & 3 deletions source/Classes/Block/11_Code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class code_structure
{
throw "Invalid language: $language"
}
$this.caption = [rich_text]::ConvertFromObjects($text)
$this.rich_text = [rich_text]::ConvertFromObjects($text)
$this.caption = [rich_text]::ConvertFromObjects($caption)
$this.language = $language
}

Expand Down Expand Up @@ -63,8 +63,8 @@ class code_structure
static [code_structure] ConvertFromObject($Value)
{
$code_structure = [code_structure]::new()
$code_structure.caption = $Value.caption.ForEach({ [rich_text]::ConvertFromObject($_) })
$code_structure.rich_text = $Value.rich_text.ForEach({ [rich_text]::ConvertFromObject($_) })
$code_structure.caption = [rich_text]::ConvertFromObjects($Value.caption)
$code_structure.rich_text = [rich_text]::ConvertFromObjects($Value.rich_text)
if (-not [code_structure]::IsValidLanguage($Value.language))
{
throw "Invalid language: $($Value.language)"
Expand Down
1 change: 1 addition & 0 deletions source/Classes/Block/23.1_File_block.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class notion_file_block : notion_block

notion_file_block($name, $caption, [string]$url)
{
Write-Verbose "notion_file_block::new($name, $($caption | ConvertTo-Json -Depth 5 -EnumsAsStrings), $url)"
$caption = [rich_text]::ConvertFromObjects($caption)
$this.file = [notion_external_file]::new($name, $caption, $url)
}
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/Block/27.2_TableRow.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TableRow_structure
foreach ($item in $object)
{
$this.AddCell($item)
Write-Debug "Added cell $($this.cells[0].count) content: $($item)"
Write-Debug "Added cell $($this.cells.count) content: $($item)"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions source/Classes/Block/30_Table_Of_Contents.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Table_Of_Contents_structure

Table_Of_Contents_structure()
{
$this.color = [notion_color]::default
}

Table_Of_Contents_structure($color = "default")
Expand All @@ -25,6 +26,7 @@ class notion_table_of_contents_block : notion_block

notion_table_of_contents_block()
{
$this.table_of_contents = [Table_Of_Contents_structure]::new()
}

notion_table_of_contents_block($color = "default")
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/Block/RichText/01_Rich_Text.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class rich_text
{
throw [System.ArgumentException]::new("The content must be 2000 characters or less.")
}
switch($type)
switch ($type)
{
"text"
{
Expand Down
19 changes: 10 additions & 9 deletions source/Classes/Block/RichText/02_Rich_Text_Annotation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class notion_annotation
# [notion_annotation]::new(@("bold","code"))
notion_annotation($annotations)
{
if (!$annotations) {
if (!$annotations)
{
return
}
$this.bold = $annotations.bold
Expand All @@ -26,7 +27,7 @@ class notion_annotation
$this.code = $annotations.code
$this.color = [Enum]::Parse([notion_color], $annotations.color)
}
notion_annotation([bool]$bold,[bool]$italic,[bool]$strikethrough,[bool]$underline,[bool]$code,[notion_color]$color)
notion_annotation([bool]$bold, [bool]$italic, [bool]$strikethrough, [bool]$underline, [bool]$code, [notion_color]$color)
{
$this.bold = $bold
$this.italic = $italic
Expand All @@ -39,24 +40,24 @@ class notion_annotation
[string] ToJson([bool]$compress = $false)
{
$json = @{
bold = $this.bold
italic = $this.italic
bold = $this.bold
italic = $this.italic
strikethrough = $this.strikethrough
underline = $this.underline
code = $this.code
color = $this.color.ToString()
underline = $this.underline
code = $this.code
color = $this.color.ToString()
}
return $json | ConvertTo-Json -Compress:$compress -EnumsAsStrings
}

static [notion_annotation] ConvertFromObject($Value)
{
Write-Verbose "[notion_annotation]::ConvertFromObject($($Value | ConvertTo-Json))"
$annotation = [notion_annotation]::new()
if(!$Value)
if (!$Value)
{
return $null
}
$annotation = [notion_annotation]::new()
$annotation.bold = $Value.bold
$annotation.italic = $Value.italic
$annotation.strikethrough = $Value.strikethrough
Expand Down
14 changes: 9 additions & 5 deletions source/Classes/Block/RichText/Type/01_Rich_text_text.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class rich_text_text_structure

static [rich_text_text_structure] ConvertFromObject($Value)
{
if($Value -is [rich_text_text])
Write-Verbose "[rich_text_text_structure]::ConvertFromObject($($Value | ConvertTo-Json -Depth 5))"
if ($Value -is [rich_text_text])
{
return $Value
}
Expand Down Expand Up @@ -65,7 +66,8 @@ class rich_text_text : rich_text
$this.text = [rich_text_text_structure]::new($content)
$this.plain_text = $content
}
elseif ($content -is [datetime] -or $content -is [int] -or $content -is [double] -or $content -is [bool]) {
elseif ($content -is [datetime] -or $content -is [int] -or $content -is [double] -or $content -is [bool])
{
$this.text = [rich_text_text_structure]::new($content.ToString())
$this.plain_text = $content.ToString()
}
Expand Down Expand Up @@ -109,19 +111,21 @@ class rich_text_text : rich_text

static [rich_text_text] ConvertFromObject($Value)
{
$rich_text = [rich_text_text]::new()
if($Value -is [rich_text_text])
Write-Verbose "[rich_text_text]::ConvertFromObject($($Value | ConvertTo-Json -Depth 5))"
if ($Value -is [rich_text_text])
{
return $Value
}

$rich_text = [rich_text_text]::new()
if ($Value -is [string])
{
$rich_text.text = [rich_text_text_structure]::new($Value)
$rich_text.plain_text = $Value
return $rich_text
}
$rich_text.text = [rich_text_text_structure]::ConvertFromObject($Value.text)
$rich_text.plain_text = $Value.plain_text ?? $Value.text.content
$rich_text.plain_text = $rich_text.text.content
return $rich_text
}
}
Loading
Loading