From f6b609489ada6b6bddca0c0c98810be803ed4135 Mon Sep 17 00:00:00 2001 From: Fabian Franz Steiner <75947402+fasteiner@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:16:03 +0000 Subject: [PATCH 1/2] Implement code changes to enhance functionality and improve performance --- diff.txt | 2274 +++++++++++++++++++++++++++++++++++++ source/WikiSource/Home.md | 8 + 2 files changed, 2282 insertions(+) create mode 100644 diff.txt diff --git a/diff.txt b/diff.txt new file mode 100644 index 0000000..95823da --- /dev/null +++ b/diff.txt @@ -0,0 +1,2274 @@ +diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json +deleted file mode 100644 +index 4b549a8..0000000 +--- a/.devcontainer/devcontainer.json ++++ /dev/null +@@ -1,37 +0,0 @@ +-{ +- "name": "Notion PowerShell Dev Container", +- "image": "mcr.microsoft.com/devcontainers/base:debian", +- "features": { +- "ghcr.io/devcontainers/features/common-utils:2": { +- "installZsh": false, +- "installGit": true +- }, +- "ghcr.io/devcontainers/features/powershell:1": { +- "version": "7" +- }, +- "ghcr.io/devcontainers/features/dotnet:1": { +- "version": "8.0" +- } +- }, +- "postCreateCommand": "pwsh -f .devcontainer/setup.ps1", +- "customizations": { +- "vscode": { +- "extensions": [ +- "davidanson.vscode-markdownlint", +- "ms-vscode.powershell", +- "streetsidesoftware.code-spell-checker", +- "redhat.vscode-yaml", +- "bierner.markdown-mermaid", +- "vscode-icons-team.vscode-icons" +- ], +- "settings": { +- "powershell.scriptAnalysis.enable": true, +- "powershell.codeFormatting.preset": "OTBS", +- "files.trimTrailingWhitespace": true, +- "files.insertFinalNewline": true, +- "terminal.integrated.defaultProfile.linux": "pwsh" +- } +- } +- }, +- "remoteUser": "vscode" +-} +diff --git a/.devcontainer/setup.ps1 b/.devcontainer/setup.ps1 +deleted file mode 100644 +index 20b51c6..0000000 +--- a/.devcontainer/setup.ps1 ++++ /dev/null +@@ -1,41 +0,0 @@ +-Write-Host "🔧 Installing PowerShell tooling (Preview versions)..." +- +-# Trust PSGallery to avoid prompts +-Set-PSRepository -Name PSGallery -InstallationPolicy Trusted +- +-# Install preview modules +-Install-Module Pester -Force -AllowPrerelease +-Install-Module Microsoft.PowerShell.PlatyPS -Force +-Install-Module Sampler -Force -AllowPrerelease +- +-# Add NuGet source (safe to re-run) +-dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org +- +-# Install GitVersion as global tool +-dotnet tool install --global GitVersion.Tool --version 5.12.0 +- +-# Ensure the .dotnet/tools path is added to current PATH +-$dotnetToolsPath = [System.IO.Path]::Combine($HOME, ".dotnet", "tools") +-if ($env:PATH -notlike "*$dotnetToolsPath*") { +- Write-Host "➕ Adding $dotnetToolsPath to PATH" +- $env:PATH = "$dotnetToolsPath`:$env:PATH" +-} +- +-# Add to PowerShell profile for persistence +-$profileScript = $PROFILE +-if (-not (Test-Path -Path $profileScript)) { +- New-Item -ItemType File -Path $profileScript -Force | Out-Null +-} +-Add-Content -Path $profileScript -Value @" +-# Added by devcontainer setup +-\$dotnetTools = [System.IO.Path]::Combine(\$HOME, '.dotnet', 'tools') +-if (\$env:PATH -notlike "*\$dotnetTools*") { +- \$env:PATH = "\$dotnetTools`:\$env:PATH" +-} +-"@ +- +-Write-Host "✅ Setup complete. Verifying GitVersion..." +-dotnet-gitversion /showvariable SemVer +- +-# Run a full build of the Notion module +-#./build.ps1 -tasks build -ResolveDependency -UseModuleFast +diff --git a/.vscode/profile.ps1 b/.vscode/profile.ps1 +index f0b7346..b8d7109 100644 +--- a/.vscode/profile.ps1 ++++ b/.vscode/profile.ps1 +@@ -1,6 +1,4 @@ +-if($pwd -notlike "*/Notion") { +- Set-Location "$env:USERPROFILE\Documents\PowerShell\Modules.DEV\TSNotion" +-} ++Set-Location "$env:USERPROFILE\Documents\PowerShell\Modules.DEV\TSNotion" + ./build.ps1 -tasks minibuild + $version = dotnet-gitversion /showvariable MajorMinorPatch /nocache + $ModuleFile = ".\output\module\Notion\$version\Notion.psd1" +diff --git a/.vscode/settings.json b/.vscode/settings.json +index a45442d..08a7fe9 100644 +--- a/.vscode/settings.json ++++ b/.vscode/settings.json +@@ -55,17 +55,6 @@ + "liveshare.allowGuestDebugControl": true, + "workbench.iconTheme": "vscode-icons", + "terminal.integrated.bracketedPasteMode": false, +- "terminal.integrated.profiles.linux": { +- "Notion pwsh": { +- "path": "pwsh", +- "args": [ +- "-NoExit", +- "-Command", +- "& './.vscode/profile.ps1'" +- ] +- } +- }, +- "terminal.integrated.defaultProfile.linux": "Notion pwsh", + "terminal.integrated.profiles.windows": { + "Notion pwsh": { + "source": "PowerShell", +diff --git a/CHANGELOG.md b/CHANGELOG.md +index aef343b..5adc881 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -7,64 +7,78 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 + + ### Added + +-- **VSCode Configuration** +- - `.vscode/settings.json`: Configured `terminal.integrated.bracketedPasteMode`, disabled minimap, custom terminal profile, formatter preferences, and extension settings. +- - `.vscode/profile.ps1`: PowerShell profile to auto-import the module during VSCode sessions. +- - `.vscode/vsicons-custom-icons/`: Support for custom icons, including `file_type_pester.svg` and `copyFileToSystemPath.ps1`. +- +-- **Build and Wiki Scripts** +- - `.build/Copy-WikiContent.ps1`: Script to copy wiki content from source to destination with flattened structure. +- - `.build/New-WikiSidebarFromPs1.ps1`: Generates `_Sidebar.md` from PowerShell and Markdown files. +- - `.build/README.md`: Documentation for adding custom build tasks and workflows. +- - `build.yaml`: Added `minibuild` task with steps for `Clean`, `Build_Module_ModuleBuilder`, and `Build_NestedModules_ModuleBuilder`. +- +-- **Module Source Code** +- - `source/Classes/03_File/01_notion_file.ps1`: Static `Create` method to instantiate child objects based on file type. +- - `source/Classes/Block/RichText/01_Rich_Text.ps1`: `ConvertFromObjects` method to convert arrays or single objects into `rich_text[]`. +- - Various block classes (`Bookmark`, `Callout`, `ChildPage`, `Code`, `Image`, `Video`, etc.): New or refactored constructors, support for flexible input, `ConvertFromObject(s)` methods, support for `caption`, emoji, etc. +- - `source/Classes/Block/04_Block.ps1`: Improved error messages for unsupported and unknown block types with GitHub issue link. +- - `source/Classes/Emoji/01_emoji.ps1`: `ConvertFromObject` method to handle strings and emoji objects. +- - `source/Public/Block/New-NotionBlock.ps1`: Generic factory function to create Notion blocks. +- - `source/Public/Block/Cmds/*`: Many new cmdlets like `New-NotionBookmarkBlock`, `New-NotionCalloutBlock`, etc. +- - `docs/Enums/`: Markdown documentation for all enums used in the module. +- - `source/WikiSource/`: Wiki source files including setup guide, FAQ, and integration images. +- +-- **Tests** +- - `tests/Integration/Block/testpage.tests.ps1`: Improved logic and error message validation. +- - `tests/Integration/PageProperties/testpage.tests.ps1`: Validation for page property types. +- - `tests/Unit/Classes/Block/`: Unit tests for many block classes. +- - Additional tests for new constructors, block types, and unsupported block error messages. ++- `.vscode/settings.json`: added `terminal.integrated.bracketedPasteMode`, disabled minimap, and configured custom terminal profile ++- `.vscode/profile.ps1`: PowerShell profile to auto-import the module during development ++- `.vscode/vsicons-custom-icons/`: added custom icon support for Pester files ++- `.build/Copy-WikiContent.ps1`: script to copy wiki content from source to destination, flattening structure ++- `.build/New-WikiSidebarFromPs1.ps1`: script to generate `_Sidebar.md` from PowerShell and Markdown files ++- `.build/README.md`: documentation for adding custom build tasks and workflows ++- `build.yaml`: added `minibuild` task with steps for `Clean`, `Build_Module_ModuleBuilder`, and `Build_NestedModules_ModuleBuilder` ++- `source/Classes/03_File/01_notion_file.ps1`: ++ - Added static `Create` method to instantiate child objects based on file type ++- `source/Classes/Block/RichText/01_Rich_Text.ps1`: ++ - Added `ConvertFromObjects` method to convert arrays or single objects into `rich_text[]` ++- `source/Classes/Block/04_Block.ps1`: ++ - Improved error messages for unsupported and unknown block types with GitHub issue link and quoted block type ++- `source/Classes/Block/05_Bookmark.ps1`: ++ - Refactored constructors to support flexible input types and added `ConvertFromObject` method ++- `source/Classes/Block/07_Bulleted_List_Item.ps1`: ++ - Refactored constructors to use `ConvertFromObjects` and support flexible input ++- `source/Classes/Block/08_Callout.ps1`: ++ - Refactored constructors and added `ConvertFromObject` for emoji and rich text ++- `source/Classes/Block/09_Child_Database.ps1`: ++ - Used `ConvertFromObject` for `child_database_structure` ++- `source/Classes/Block/10_Child_Page.ps1`: ++ - Used `ConvertFromObject` for `child_page_structure` ++- `source/Classes/Block/11_Code.ps1`: ++ - Refactored constructors to use `ConvertFromObjects` and support caption ++- `source/Classes/Block/15_Embed.ps1`: ++ - Added support for `caption` and `ConvertFromObject` improvements ++- `source/Classes/Block/16_Equation.ps1`: ++ - Renamed constructors to match class name ++- `source/Classes/Block/21_Image.ps1`: ++ - Added support for `caption` and improved `ConvertFromObject` ++- `source/Classes/Block/31_To_do.ps1`: ++ - Refactored constructor to remove base call ++- `source/Classes/Block/33_Video.ps1`: ++ - Refactored constructors to use `Create` method and support caption ++- `source/Classes/Emoji/01_emoji.ps1`: ++ - Added `ConvertFromObject` method to handle strings and emoji objects ++- `tests/Integration/Block/testpage.tests.ps1`: ++ - Improved test logic for unsupported block types with specific error message checks ++- `source/Public/Block/New-NotionBlock.ps1`: generic factory function to create Notion blocks ++- `source/Public/Block/Cmds/*`: added many new `New-Notion*Block.ps1` cmdlets for block creation (e.g., `Bookmark`, `Callout`, `ChildPage`, `Code`, etc.) ++- `docs/Enums/`: added Markdown documentation for all enums used in the module ++- `source/WikiSource/`: added wiki source files including setup guide, FAQ, and integration images ++- `tests/Unit/Classes/Block/`: added unit tests for many block classes (e.g., `Bookmark`, `Breadcrumb`, `Callout`, `Code`, `Image`, `Video`, etc.) + + ### Changed + +-- **General Refactoring** +- - Refactored many constructors across block classes to support more flexible input and consistent use of `ConvertFromObjects`. +- - `source/Classes/Emoji/01_emoji.ps1`: Improved emoji conversion logic. +- - `source/Enum/*`: Added missing enum values and documentation links. +- +-- **Configuration Files** +- - `.vscode/analyzersettings.psd1`: Relaxed some analyzer rules (e.g., allowed `Write-Host`). +- - `.github/ISSUE_TEMPLATE/`: Updated templates to reflect support for cmdlets, classes, and enums. +- - `README.md`: Added badges, logo, and improved getting started section. +- - `RequiredModules.psd1`: Switched to Pester Version 6. +- - `build.ps1`: Added tasks `Generate_Wiki_Sidebar_From_Ps1` and `Copy_Wiki_Content_Custom`. ++- `RequiredModules.psd1`: switched to Pester Version 6 ++- `.vscode/analyzersettings.psd1`: relaxed some analyzer rules (e.g., allow `Write-Host`) ++- `.github/ISSUE_TEMPLATE/`: updated templates to reflect support for commands, classes, and enums ++- `README.md`: added badges, logo, and improved getting started section ++- `build.ps1`: added tasks `Generate_Wiki_Sidebar_From_Ps1` and `Copy_Wiki_Content_Custom` ++- Refactored multiple constructors across block classes to support more flexible input types and use `ConvertFromObjects` for consistency ++- `source/Classes/Emoji/01_emoji.ps1`: improved emoji conversion logic ++- `source/Enum/*`: added missing enum values and documentation links + + ### Fixed + +-- **Class Fixes** +- - `source/Enum/01_notion_color.ps1`: Added `default_background` color. +- - `source/Classes/Block/32_Toggle.ps1`: Fixed class name and constructor. +- - `source/Classes/Block/33_Video.ps1`: Fixed constructors and file instantiation logic. +- - `source/Classes/Block/05_Bookmark.ps1`: Fixed constructors and `bookmark_structure` logic. +- - `source/Classes/Block/07_Bulleted_List_Item.ps1`: Fixed `rich_text` conversion in constructors. +- - `source/Classes/Block/08_Callout.ps1`: Fixed constructors and emoji handling. +- - `source/Classes/Emoji/01_emoji.ps1`: Fixed `ConvertFromObject` to handle strings and emoji objects. +- +-- **Tests and Validation** +- - Improved error handling and validation in integration tests. +- - Enhanced input validation to prevent runtime errors. +- - Fixed `ConvertTo-Json` depth handling for complete serialization. +- - Fixed enum handling and added missing values. ++- `source/Enum/01_notion_color.ps1`: added `default_background` as a color (missing in documentation but available in API) ++- `source/Classes/Block/32_Toggle.ps1`: fixed class name and constructor ++- `source/Classes/Block/33_Video.ps1`: fixed constructors and file instantiation logic ++- `source/Classes/Block/05_Bookmark.ps1`: ++ - Fixed constructors ++ - `bookmark_structure`: fixed constructor with two parameters to fully support `rich_text` ++- `source/Classes/Block/07_Bulleted_List_Item.ps1`: ++ - Fixed `rich_text` conversion in constructors ++- `source/Classes/Block/08_Callout.ps1`: ++ - Fixed constructors and emoji handling ++- `source/Classes/Emoji/01_emoji.ps1`: ++ - Fixed `ConvertFromObject` to handle strings and emoji objects ++- `tests/Integration/Block/testpage.tests.ps1`: improved error handling and validation for unsupported block types ++- `tests/Integration/PageProperties/testpage.tests.ps1`: added validation for page property types + + ## [0.3.0] - 2025-05-18 + +diff --git a/build.ps1 b/build.ps1 +index f258459..e8358f5 100644 +--- a/build.ps1 ++++ b/build.ps1 +@@ -156,16 +156,7 @@ param + #> + process + { +- # when the command git version does not exist, create an alias to dotnet-gitversion. +- if (-not (Get-Command -Name gitversion -ErrorAction SilentlyContinue)) +- { +- Write-Host -Object "[pre-build] Creating alias 'gitversion' for 'dotnet-gitversion'" -ForegroundColor Green +- Set-Alias -Name gitversion -Value dotnet-gitversion -Scope Global +- } +- else +- { +- Write-Host -Object "[pre-build] Command 'gitversion' already exists, skipping alias creation." -ForegroundColor Yellow +- } ++ Set-Alias -Name gitversion -Value dotnet-gitversion -Scope Global + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + # Only run the process block through InvokeBuild (look at the Begin block at the bottom of this script). +diff --git a/docs/Classes/Block/24_PDF.md b/docs/Classes/Block/24_PDF.md +index f355508..dfdc729 100644 +--- a/docs/Classes/Block/24_PDF.md ++++ b/docs/Classes/Block/24_PDF.md +@@ -4,12 +4,20 @@ + + ```mermaid + classDiagram +- class notion_PDF_block { ++ class PDF_structure { ++ [rich_text[]] $caption ++ ConvertFromObject() ++ } ++ ++ ++ ++ class notion_PDF_block { + [notion_blocktype] $type = "pdf" +- [notion_file] $pdf ++ [PDF_structure] $pdf + ConvertFromObject() + } +- `notion_file` <.. `notion_PDF_block`:uses ++ `notion_file` --|> `PDF_structure`:inherits ++ `PDF_structure` <.. `notion_PDF_block`:uses + `notion_block` --|> `notion_PDF_block`:inherits + ``` + +diff --git a/source/Classes/03_File/01_notion_file.ps1 b/source/Classes/03_File/01_notion_file.ps1 +index ee354a3..5ad141b 100644 +--- a/source/Classes/03_File/01_notion_file.ps1 ++++ b/source/Classes/03_File/01_notion_file.ps1 +@@ -45,11 +45,6 @@ class notion_file : notion_icon + { + return [notion_external_file]::new($name, $processedCaption, $url) + } +- "file_upload " +- { +- # not implemented yet +- Write-Error "File upload type is not implemented yet." -Category NotImplemented -TargetObject $type +- } + default + { + Write-Error "Invalid file type: $type. Supported types are 'file' or 'external'." -Category InvalidData -TargetObject $type +@@ -72,22 +67,14 @@ class notion_file : notion_icon + return $Value + } + $fileObject = $null +- switch ($Value.type) ++ if ($Value.type -eq "file") + { +- "file" { +- $fileObject = [notion_hosted_file]::ConvertFromObject($Value) +- } +- "external" { +- $fileObject = [notion_external_file]::ConvertFromObject($Value) +- } +- "file_upload" { +- # not implemented yet +- Write-Error "File upload type is not implemented yet." -Category NotImplemented -TargetObject $Value.type +- } +- default { +- Write-Error "Invalid file type: $($Value.type). Supported types are 'file' or 'external'." -Category InvalidData -TargetObject $Value.type +- } +- } ++ $fileObject = [notion_hosted_file]::ConvertFromObject($Value) ++ } ++ else ++ { ++ $fileObject = [notion_external_file]::ConvertFromObject($Value) ++ } + $fileObject.type = $Value.type + $fileObject.caption = [rich_text]::ConvertFromObjects($Value.caption) + $fileObject.name = $Value.name +diff --git a/source/Classes/03_File/03_external_file.ps1 b/source/Classes/03_File/03_external_file.ps1 +index 3e7750d..6336be8 100644 +--- a/source/Classes/03_File/03_external_file.ps1 ++++ b/source/Classes/03_File/03_external_file.ps1 +@@ -23,12 +23,6 @@ class notion_external_file : notion_file + notion_external_file():base("external") + { + } +- +- notion_external_file([string]$url):base("external") +- { +- $this.external = [notion_external_file_structure]::new($url) +- } +- + notion_external_file([string]$name, $url):base("external", $name) + { + $this.external = [notion_external_file_structure]::new($url) +diff --git a/source/Classes/Block/04_Block.ps1 b/source/Classes/Block/04_Block.ps1 +index d243145..3c01059 100644 +--- a/source/Classes/Block/04_Block.ps1 ++++ b/source/Classes/Block/04_Block.ps1 +@@ -78,11 +78,6 @@ class notion_block + + static [notion_block] ConvertFromObject($Value) + { +- if($value -is [notion_block]) +- { +- # If the value is already a notion_block, return it +- return $value +- } + # Write-Verbose "[notion_block]::ConvertFromObject($($Value | ConvertTo-Json -Depth 10 ))" + $notion_block = $null + switch ($Value.type) +diff --git a/source/Classes/Block/23_Paragraph.ps1 b/source/Classes/Block/23_Paragraph.ps1 +index 9dcc2ca..f33793b 100644 +--- a/source/Classes/Block/23_Paragraph.ps1 ++++ b/source/Classes/Block/23_Paragraph.ps1 +@@ -14,12 +14,6 @@ class paragraph_structure + $this.rich_text = [rich_text]::ConvertFromObjects($rich_text) + } + +- paragraph_structure($rich_text, $color) +- { +- $this.rich_text = [rich_text]::ConvertFromObjects($rich_text) +- $this.color = [Enum]::Parse([notion_color], $color) +- } +- + [void] addRichText($rich_text) + { + $this.rich_text += [rich_text]::ConvertFromObjects($rich_text) +@@ -49,11 +43,6 @@ class notion_paragraph_block : notion_block + $this.paragraph = [Paragraph_structure]::new($richtext) + } + +- notion_paragraph_block($richtext, $color) +- { +- $this.paragraph = [Paragraph_structure]::new($richtext, $color) +- } +- + [void] addRichText($richtext) + { + $this.paragraph = [Paragraph_structure]::addRichText($richtext) +diff --git a/source/Classes/Block/24_PDF.ps1 b/source/Classes/Block/24_PDF.ps1 +index 7841c2f..cd3bc1f 100644 +--- a/source/Classes/Block/24_PDF.ps1 ++++ b/source/Classes/Block/24_PDF.ps1 +@@ -1,28 +1,72 @@ ++class PDF_structure : notion_file ++{ ++ [rich_text[]] $caption ++ ++ PDF_structure([notion_file] $file) ++ { ++ $this.type = $file.type ++ $this."$($file.type)" = $file ++ } ++ ++ PDF_structure([rich_text[]] $caption, [notion_filetype] $file) ++ { ++ $this.caption = @($caption) ++ $this.type = $file.type ++ $this."$($file.type)" = $file ++ } ++ ++ static [PDF_structure] ConvertFromObject($Value) ++ { ++ $pdf_obj = [notion_file]::ConvertFromObject($Value) ++ $pdf_obj.caption = $Value.caption.rich_text.ForEach({ [rich_text]::ConvertFromObject($_) }) ++ return $pdf_obj ++ } ++} ++ ++ + class notion_PDF_block : notion_block + # https://developers.notion.com/reference/block#pdf + { + [notion_blocktype] $type = "pdf" +- [notion_file] $pdf ++ [PDF_structure] $pdf + + notion_PDF_block() +- { +- ++ { ++ $this.pdf = [PDF_structure]::new() ++ + } + +- notion_PDF_block($file) ++ notion_PDF_block([notion_file] $file) + { +- $this.pdf = [notion_file]::ConvertFromObject($file) ++ $this.pdf = [PDF_structure]::new($file) + } + +- notion_PDF_block($caption, $url, $name) ++ notion_PDF_block([rich_text[]] $caption, [notion_file] $file) + { +- $this.pdf = [notion_file]::Create("external", $name, $caption, $url, $null) ++ $this.pdf = [PDF_structure]::new($caption, $file) + } +- ++ # # Notion-hosted files constructor ++ # PDF($url, $expiry_time, [rich_text[]] $caption) : base($url, $expiry_time) ++ # { ++ # $this.caption = $caption ++ # } ++ ++ # # External files constructor ++ # PDF($url) : base($url) ++ # { ++ # $this.caption = @() ++ # } ++ ++ # # Generic constructor ++ # PDF([notion_filetype] $filetype, $url, $expiry_time, [rich_text[]] $caption) : base($filetype, $url, $expiry_time) ++ # { ++ # $this.caption = $caption ++ # } ++ + static [notion_PDF_block] ConvertFromObject($Value) + { + $PDF_obj = [notion_PDF_block]::new() +- $PDF_obj.pdf = [notion_file]::ConvertFromObject($Value.pdf) ++ $PDF_obj.pdf = [PDF_structure]::ConvertFromObject($Value.pdf) + return $PDF_obj + } + } +diff --git a/source/Classes/Block/25_Quote.ps1 b/source/Classes/Block/25_Quote.ps1 +index f87ba83..1a4cc46 100644 +--- a/source/Classes/Block/25_Quote.ps1 ++++ b/source/Classes/Block/25_Quote.ps1 +@@ -5,19 +5,15 @@ class Quote_structure + [notion_block[]] $children = @() + + #TODO: Implement addchildren +- Quote_structure() ++ Quote_structure([rich_text[]] $rich_text, [notion_color] $color = "default") + { +- } +- +- Quote_structure($rich_text, $color = "default") +- { +- $this.rich_text = [rich_text]::ConvertFromObjects($rich_text) +- $this.color = [Enum]::Parse([notion_color], $color) ++ $this.rich_text = @($rich_text) ++ $this.color = $color + } + + static [Quote_structure] ConvertFromObject($Value) + { +- return [Quote_structure]::new( $Value.rich_text, $Value.color ?? "default" ) ++ return [Quote_structure]::new($Value.rich_text.ForEach({[rich_text]::ConvertFromObject($_)}), $Value.color) + } + } + +@@ -28,10 +24,9 @@ class notion_quote_block : notion_block + [Quote_structure] $quote + + notion_quote_block() +- { +- } ++ {} + +- notion_quote_block( $rich_text, $color) ++ notion_quote_block([rich_text[]] $rich_text, [notion_color] $color) + { + $this.quote = [Quote_structure]::new($rich_text, $color) + } +diff --git a/source/Classes/Block/26_Synced_Block.ps1 b/source/Classes/Block/26_Synced_Block.ps1 +index 23734b2..06e0d50 100644 +--- a/source/Classes/Block/26_Synced_Block.ps1 ++++ b/source/Classes/Block/26_Synced_Block.ps1 +@@ -1,25 +1,6 @@ +-class Synced_Block_Duplicate_structure +-{ +- [string]$block_id = $null +- +- Synced_Block_Duplicate_structure() +- { +- } +- +- Synced_Block_Duplicate_structure($block_id) +- { +- $this.block_id = $block_id +- } +- static [Synced_Block_Duplicate_structure] ConvertFromObject($Value) +- { +- return [Synced_Block_Duplicate_structure]::new($Value.block_id) +- } +-} +- +- + class Synced_Block_structure + { +- [Synced_Block_Duplicate_structure] $synced_from = $null ++ [notion_block] $synced_from = $null + [notion_block[]] $children = @() + #TODO: Implement addchildren + +@@ -27,49 +8,13 @@ class Synced_Block_structure + { + } + +- Synced_Block_structure($synced_from) +- { +- $this.synced_from = [Synced_Block_Duplicate_structure]::new($synced_from.block_id) +- } +- +- [void] AddChild( $child) ++ Synced_Block_structure([notion_block] $synced_from) + { +- if ($this.synced_from -eq $null) +- { +- $this.children += [notion_block]::ConvertFromObject($child) +- } +- else +- { +- Write-Error "Cannot add child to synced block, as this is a duplicate synced block." -Category InvalidOperation -TargetObject $this +- return +- } ++ $this.synced_from = $synced_from + } +- +- [void] AddChildren( $children) +- { +- foreach ($child in $children) +- { +- $this.AddChild($child) +- } +- } +- +- + static [Synced_Block_structure] ConvertFromObject($Value) + { +- if ($Value.synced_from) +- { +- if ($Value.synced_from.object -is [Synced_Block_structure]) +- { +- return $Value.synced_from +- } +- $synced_from_Obj = [Synced_Block_structure]::new() +- $synced_from_Obj.synced_from = [Synced_Block_Duplicate_structure]::ConvertFromObject($Value.synced_from) +- return $synced_from_Obj +- } +- else +- { +- return [Synced_Block_structure]::new() +- } ++ return [Synced_Block_structure]::new($Value.synced_from) + } + } + +@@ -79,32 +24,11 @@ class notion_synced_block : notion_block + [notion_blocktype] $type = "synced_block" + [Synced_Block_structure] $synced_block + +- +- #Original synced block constructor + notion_synced_block() + { + $this.synced_block = [Synced_Block_structure]::new() + } + +- #duplicate synced block constructor +- notion_synced_block($synced_block) +- { +- $this.synced_block = [Synced_Block_structure]::new($synced_block) +- } +- +- [void] AddChild( $child) +- { +- $this.synced_block.AddChild($child) +- } +- +- [void] AddChildren( $children) +- { +- foreach ($child in $children) +- { +- $this.AddChild($child) +- } +- } +- + static [notion_synced_block] ConvertFromObject($Value) + { + $synced_block_Obj = [notion_synced_block]::new() +diff --git a/source/Classes/Block/27.2_TableRow.ps1 b/source/Classes/Block/27.2_TableRow.ps1 +index c12e970..77efeef 100644 +--- a/source/Classes/Block/27.2_TableRow.ps1 ++++ b/source/Classes/Block/27.2_TableRow.ps1 +@@ -16,15 +16,14 @@ class TableRow_structure + { + # for each property add a cell + # if not a list +- if ($object -is [TableRow_structure] -and $object.cells) +- { ++ if($object -is [TableRow_structure] -and $object.cells){ + $this.cells = $object.cells + } + if ($object -isnot [System.Array] -and $object.cells) + { +- $object.cells.foreach({ +- $this.AddCell($_) +- }) ++ $object.cells.foreach{ ++ $this.AddCell($_) ++ } + } + else + { +@@ -41,22 +40,19 @@ class TableRow_structure + AddCell([object]$cellcontent) + { + [rich_text[]] $cell = @() +- if ($cellcontent -is [string] -or $cellcontent -is [int] -or $cellcontent -is [double] -or $cellcontent -is [bool] -or $cellcontent -is [datetime]) ++ if($cellcontent -is [string] -or $cellcontent -is [int] -or $cellcontent -is [double] -or $cellcontent -is [bool] -or $cellcontent -is [datetime]) + { + $cell += [rich_text_text]::new($cellcontent.ToString()) + } +- elseif ($cellcontent -is [rich_text]) +- { ++ elseif ($cellcontent -is [rich_text]) { + $cell += $cellcontent + } +- elseif ($cellcontent -is [array]) +- { ++ elseif ($cellcontent -is [array]) { + $cellcontent.foreach({ +- $cell += [rich_text]::ConvertFromObject($_) +- }) ++ $cell += [rich_text]::ConvertFromObject($_) ++ }) + } +- else +- { ++ else{ + $cell += [rich_text]::ConvertFromObject($cellcontent) + } + $this.cells += $cell +@@ -66,8 +62,8 @@ class TableRow_structure + { + $table_row_Obj = [TableRow_structure]::new() + $Value.cells.foreach({ +- $table_row_Obj.AddCell($_) +- }) ++ $table_row_Obj.AddCell($_) ++ }) + return $table_row_Obj + } + } +@@ -84,7 +80,7 @@ class notion_table_row_block : notion_block + + notion_table_row_block([object] $object) + { +- if ($object -is [array]) ++ if($object -is [array]) + { + # if array of cells + $this.table_row = [TableRow_structure]::new($object) +diff --git a/source/Classes/Block/30_Table_Of_Contents.ps1 b/source/Classes/Block/30_Table_Of_Contents.ps1 +index 40c280e..798ba8c 100644 +--- a/source/Classes/Block/30_Table_Of_Contents.ps1 ++++ b/source/Classes/Block/30_Table_Of_Contents.ps1 +@@ -3,17 +3,13 @@ class Table_Of_Contents_structure + #https://developers.notion.com/reference/block#table-of-contents + [notion_color] $color = "default" + +- Table_Of_Contents_structure() ++ Table_Of_Contents_structure([notion_color] $color = "default") + { +- } +- +- Table_Of_Contents_structure($color = "default") +- { +- $this.color = [enum]::Parse([notion_color], $color) ++ $this.color = $color + } + static [Table_Of_Contents_structure] ConvertFromObject($Value) + { +- return [Table_Of_Contents_structure]::new($Value.color ?? "default") ++ return [Table_Of_Contents_structure]::new([Enum]::Parse([notion_color], $Value.color)) + } + } + +@@ -23,11 +19,7 @@ class notion_table_of_contents_block : notion_block + [notion_blocktype] $type = "table_of_contents" + [Table_Of_Contents_structure] $table_of_contents + +- notion_table_of_contents_block() +- { +- } +- +- notion_table_of_contents_block($color = "default") ++ notion_table_of_contents_block([notion_color] $color = "default") + { + $this.table_of_contents = [Table_Of_Contents_structure]::new($color) + } +diff --git a/source/Classes/Block/31_To_do.ps1 b/source/Classes/Block/31_To_do.ps1 +index 08dd270..fd61453 100644 +--- a/source/Classes/Block/31_To_do.ps1 ++++ b/source/Classes/Block/31_To_do.ps1 +@@ -10,18 +10,17 @@ class to_do_structure + { + } + +- +- to_do_structure($rich_text, [bool] $checked = $false, $color = "default") ++ to_do_structure([rich_text[]] $rich_text, [bool] $checked = $false, [notion_color] $color = "default") + { +- $this.rich_text = [rich_text]::ConvertFromObjects($rich_text) ++ $this.rich_text = $rich_text.rich_text.ForEach({ [rich_text]::ConvertFromObject($_) }) + $this.checked = $checked +- $this.color = [Enum]::Parse([notion_color], $color) ++ $this.color = $color + } + + static [to_do_structure] ConvertFromObject ($Value) + { + $notion_to_do_obj = [to_do_structure]::new() +- $notion_to_do_obj.rich_text = [rich_text]::ConvertFromObjects($Value.rich_text) ++ $notion_to_do_obj.rich_text = $Value.rich_text.ForEach({ [rich_text]::ConvertFromObject($_) }) + $notion_to_do_obj.checked = $Value.checked + $notion_to_do_obj.color = [Enum]::Parse([notion_color], $Value.color ?? "default") + return $notion_to_do_obj +@@ -37,12 +36,7 @@ class notion_to_do_block : notion_block + { + } + +- notion_to_do_block($rich_text) +- { +- $this.to_do = [to_do_structure]::new($rich_text, $false, "default") +- } +- +- notion_to_do_block($rich_text, [bool] $checked = $false, $color = "default") ++ notion_to_do_block([rich_text[]] $rich_text, [bool] $checked = $false, [notion_color] $color = "default") + { + $this.to_do = [to_do_structure]::new($rich_text, $checked, $color) + } +diff --git a/source/Classes/Block/32_Toggle.ps1 b/source/Classes/Block/32_Toggle.ps1 +index 995adee..aac8765 100644 +--- a/source/Classes/Block/32_Toggle.ps1 ++++ b/source/Classes/Block/32_Toggle.ps1 +@@ -7,15 +7,15 @@ class Toggle_structure + + Toggle_structure() {} + +- Toggle_structure($rich_text, $color = "default") ++ Toggle_structure([rich_text[]] $rich_text, [notion_color] $color = "default") + { +- $this.rich_text = [rich_text]::ConvertFromObjects($rich_text) +- $this.color = [Enum]::Parse([notion_color], $color) ++ $this.rich_text = @($rich_text) ++ $this.color = $color + } + + static [Toggle_structure] ConvertFromObject($Value) + { +- return [Toggle_structure]::new($Value.rich_text, $Value.color ?? "default") ++ return [Toggle_structure]::new($Value.rich_text.ForEach({ [rich_text]::ConvertFromObject($_) }), $Value.color) + } + } + class notion_toggle_block : notion_block +@@ -29,12 +29,7 @@ class notion_toggle_block : notion_block + + } + +- notion_toggle_block($rich_text) +- { +- $this.toggle = [Toggle_structure]::new($rich_text, "default") +- } +- +- notion_toggle_block($rich_text, $color = "default") ++ notion_toggle_block([rich_text[]] $rich_text, [notion_color] $color = "default") : base("toggle") + { + $this.toggle = [Toggle_structure]::new($rich_text, $color) + } +diff --git a/source/Public/Block/BulletedListItem/New-NotionBulletedListItemBlock.ps1 b/source/Public/Block/BulletedListItem/New-NotionBulletedListItemBlock.ps1 +deleted file mode 100644 +index 229822d..0000000 +--- a/source/Public/Block/BulletedListItem/New-NotionBulletedListItemBlock.ps1 ++++ /dev/null +@@ -1,54 +0,0 @@ +-function New-NotionBulletedListItemBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion bulleted list item block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_bulleted_list_item_block class. +- You can create an empty bulleted list item block, or provide rich text and an optional color. +- +- .PARAMETER RichText +- The rich text content for the bulleted list item. +- +- .PARAMETER Color +- The color for the bulleted list item. Default is "default". +- +- .EXAMPLE +- New-NotionBulletedListItemBlock -RichText "Item 1" -Color "red" +- +- .EXAMPLE +- New-NotionBulletedListItemBlock -RichText "Item 2" +- +- .EXAMPLE +- New-NotionBulletedListItemBlock +- +- .OUTPUTS +- notion_bulleted_list_item_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithText', Mandatory = $true)] +- [object]$RichText, +- +- [Parameter(ParameterSetName = 'WithText')] +- [object]$Color +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithText') +- { +- if ($PSBoundParameters.ContainsKey('Color')) +- { +- $obj = [notion_bulleted_list_item_block]::new($RichText, $Color) +- } +- else +- { +- $obj = [notion_bulleted_list_item_block]::new($RichText) +- } +- } +- else +- { +- $obj = [notion_bulleted_list_item_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/Cmds/BulletedListItem/New-NotionBulletedListItemBlock.ps1 b/source/Public/Block/Cmds/BulletedListItem/New-NotionBulletedListItemBlock.ps1 +new file mode 100644 +index 0000000..cd5269a +--- /dev/null ++++ b/source/Public/Block/Cmds/BulletedListItem/New-NotionBulletedListItemBlock.ps1 +@@ -0,0 +1,12 @@ ++function New-NotionBulletedListItemBlock ++{ ++ [CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Callout/New-NotionCalloutBlock.ps1 b/source/Public/Block/Cmds/Callout/New-NotionCalloutBlock.ps1 +similarity index 100% +rename from source/Public/Block/Callout/New-NotionCalloutBlock.ps1 +rename to source/Public/Block/Cmds/Callout/New-NotionCalloutBlock.ps1 +diff --git a/source/Public/Block/ChildDatabase/New-NotionChildDatabaseBlock.ps1 b/source/Public/Block/Cmds/ChildDatabase/New-NotionChildDatabaseBlock.ps1 +similarity index 100% +rename from source/Public/Block/ChildDatabase/New-NotionChildDatabaseBlock.ps1 +rename to source/Public/Block/Cmds/ChildDatabase/New-NotionChildDatabaseBlock.ps1 +diff --git a/source/Public/Block/ChildDatabase/ChildPage/New-NotionChildPageBlock.ps1 b/source/Public/Block/Cmds/ChildPage/New-NotionChildPageBlock.ps1 +similarity index 100% +rename from source/Public/Block/ChildDatabase/ChildPage/New-NotionChildPageBlock.ps1 +rename to source/Public/Block/Cmds/ChildPage/New-NotionChildPageBlock.ps1 +diff --git a/source/Public/Block/Code/New-NotionCodeBlock.ps1 b/source/Public/Block/Cmds/Code/New-NotionCodeBlock.ps1 +similarity index 100% +rename from source/Public/Block/Code/New-NotionCodeBlock.ps1 +rename to source/Public/Block/Cmds/Code/New-NotionCodeBlock.ps1 +diff --git a/source/Public/Block/Column/New-NotionColumnBlock.ps1 b/source/Public/Block/Cmds/Column/New-NotionColumnBlock.ps1 +similarity index 100% +rename from source/Public/Block/Column/New-NotionColumnBlock.ps1 +rename to source/Public/Block/Cmds/Column/New-NotionColumnBlock.ps1 +diff --git a/source/Public/Block/ColumnList/New-NotionColumnListBlock.ps1 b/source/Public/Block/Cmds/ColumnList/New-NotionColumnListBlock.ps1 +similarity index 100% +rename from source/Public/Block/ColumnList/New-NotionColumnListBlock.ps1 +rename to source/Public/Block/Cmds/ColumnList/New-NotionColumnListBlock.ps1 +diff --git a/source/Public/Block/Cmds/Divider/New-NotionDividerBlock.ps1 b/source/Public/Block/Cmds/Divider/New-NotionDividerBlock.ps1 +new file mode 100644 +index 0000000..8bb460b +--- /dev/null ++++ b/source/Public/Block/Cmds/Divider/New-NotionDividerBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionDividerBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/Embed/New-NotionEmbedBlock.ps1 b/source/Public/Block/Cmds/Embed/New-NotionEmbedBlock.ps1 +new file mode 100644 +index 0000000..fbbed42 +--- /dev/null ++++ b/source/Public/Block/Cmds/Embed/New-NotionEmbedBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionEmbedBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/Equation/New-NotionEquationBlock.ps1 b/source/Public/Block/Cmds/Equation/New-NotionEquationBlock.ps1 +new file mode 100644 +index 0000000..d64b5ad +--- /dev/null ++++ b/source/Public/Block/Cmds/Equation/New-NotionEquationBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionEquationBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/File/New-NotionFileBlock.ps1 b/source/Public/Block/Cmds/File/New-NotionFileBlock.ps1 +new file mode 100644 +index 0000000..9656a93 +--- /dev/null ++++ b/source/Public/Block/Cmds/File/New-NotionFileBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionFileBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/LinkPreview/New-NotionLinkPreviewBlock.ps1 b/source/Public/Block/Cmds/LinkPreview/New-NotionLinkPreviewBlock.ps1 +new file mode 100644 +index 0000000..27fc369 +--- /dev/null ++++ b/source/Public/Block/Cmds/LinkPreview/New-NotionLinkPreviewBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionLinkPreviewBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/NumberedListItem/New-NotionNumberedListItemBlock.ps1 b/source/Public/Block/Cmds/NumberedListItem/New-NotionNumberedListItemBlock.ps1 +new file mode 100644 +index 0000000..6ede933 +--- /dev/null ++++ b/source/Public/Block/Cmds/NumberedListItem/New-NotionNumberedListItemBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionNumberedListItemBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/Paragraph/New-NotionParagraphBlock.ps1 b/source/Public/Block/Cmds/Paragraph/New-NotionParagraphBlock.ps1 +new file mode 100644 +index 0000000..d03fd64 +--- /dev/null ++++ b/source/Public/Block/Cmds/Paragraph/New-NotionParagraphBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionParagraphBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/Quote/New-NotionQuoteBlock.ps1 b/source/Public/Block/Cmds/Quote/New-NotionQuoteBlock.ps1 +new file mode 100644 +index 0000000..ce83ae0 +--- /dev/null ++++ b/source/Public/Block/Cmds/Quote/New-NotionQuoteBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionQuoteBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/Synced/New-NotionSyncedBlock.ps1 b/source/Public/Block/Cmds/Synced/New-NotionSyncedBlock.ps1 +new file mode 100644 +index 0000000..88e95d3 +--- /dev/null ++++ b/source/Public/Block/Cmds/Synced/New-NotionSyncedBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionSyncedBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/Table/New-NotionTableBlock.ps1 b/source/Public/Block/Cmds/Table/New-NotionTableBlock.ps1 +new file mode 100644 +index 0000000..c0f1a85 +--- /dev/null ++++ b/source/Public/Block/Cmds/Table/New-NotionTableBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionTableBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/TableOfContents/New-NotionTableOfContentsBlock.ps1 b/source/Public/Block/Cmds/TableOfContents/New-NotionTableOfContentsBlock.ps1 +new file mode 100644 +index 0000000..58d2fff +--- /dev/null ++++ b/source/Public/Block/Cmds/TableOfContents/New-NotionTableOfContentsBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionTableOfContentsBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/TableRow/New-NotionTableRowBlock.ps1 b/source/Public/Block/Cmds/TableRow/New-NotionTableRowBlock.ps1 +new file mode 100644 +index 0000000..2203155 +--- /dev/null ++++ b/source/Public/Block/Cmds/TableRow/New-NotionTableRowBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionTableRowBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/ToDo/New-NotionToDoBlock.ps1 b/source/Public/Block/Cmds/ToDo/New-NotionToDoBlock.ps1 +new file mode 100644 +index 0000000..5660654 +--- /dev/null ++++ b/source/Public/Block/Cmds/ToDo/New-NotionToDoBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionToDoBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Cmds/Toggle/New-NotionToggleBlock.ps1 b/source/Public/Block/Cmds/Toggle/New-NotionToggleBlock.ps1 +new file mode 100644 +index 0000000..e7fb6c8 +--- /dev/null ++++ b/source/Public/Block/Cmds/Toggle/New-NotionToggleBlock.ps1 +@@ -0,0 +1,11 @@ ++function New-NotionToggleBlock { ++[CmdletBinding()] ++ [OutputType([void])] ++ param( ++ [Parameter(Mandatory = $True)] ++ $parameter1 ++ ) ++ ++throw [System.NotImplementedException]::new("This function is not yet implemented.") ++ ++} +diff --git a/source/Public/Block/Divider/New-NotionDividerBlock.ps1 b/source/Public/Block/Divider/New-NotionDividerBlock.ps1 +deleted file mode 100644 +index b217cdf..0000000 +--- a/source/Public/Block/Divider/New-NotionDividerBlock.ps1 ++++ /dev/null +@@ -1,22 +0,0 @@ +-function New-NotionDividerBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion divider block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_divider_block class. +- The divider block does not require any parameters. +- +- .EXAMPLE +- New-NotionDividerBlock +- +- .OUTPUTS +- notion_divider_block +- #> +- [CmdletBinding()] +- param () +- +- $obj = [notion_divider_block]::new() +- return $obj +-} +diff --git a/source/Public/Block/Embed/New-NotionEmbedBlock.ps1 b/source/Public/Block/Embed/New-NotionEmbedBlock.ps1 +deleted file mode 100644 +index 625bfce..0000000 +--- a/source/Public/Block/Embed/New-NotionEmbedBlock.ps1 ++++ /dev/null +@@ -1,52 +0,0 @@ +-function New-NotionEmbedBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion embed block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_embed_block class. +- You can create an empty embed block, provide a URL, or provide both a URL and a caption. +- +- .PARAMETER Url +- The URL to be embedded in the block. +- +- .PARAMETER Caption +- The caption (rich_text[] or object) to be displayed for the embed block. +- +- .EXAMPLE +- New-NotionEmbedBlock -Url "https://example.com" +- +- .EXAMPLE +- New-NotionEmbedBlock -Url "https://example.com" -Caption "Example caption" +- +- .EXAMPLE +- New-NotionEmbedBlock +- +- .OUTPUTS +- notion_embed_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'BothParams', Mandatory = $true, HelpMessage = 'URL to be embedded in the block.')] +- [string]$Url, +- +- [Parameter(ParameterSetName = 'BothParams', Mandatory = $true, HelpMessage = 'Caption for the embed block.')] +- [object]$Caption +- ) +- +- if ($PSBoundParameters.ContainsKey('Url') -and $PSBoundParameters.ContainsKey('Caption')) +- { +- $caption = [rich_text]::ConvertFromObject($caption) +- $obj = [notion_embed_block]::new($Url, $Caption) +- } +- elseif ($PSBoundParameters.ContainsKey('Url')) +- { +- $obj = [notion_embed_block]::new($Url) +- } +- else +- { +- $obj = [notion_embed_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/Equation/New-NotionEquationBlock.ps1 b/source/Public/Block/Equation/New-NotionEquationBlock.ps1 +deleted file mode 100644 +index 5793517..0000000 +--- a/source/Public/Block/Equation/New-NotionEquationBlock.ps1 ++++ /dev/null +@@ -1,38 +0,0 @@ +-function New-NotionEquationBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion equation block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_equation_block class. +- You can create an empty equation block or provide an expression for the equation. +- +- .PARAMETER Expression +- The LaTeX expression to be displayed in the equation block. +- +- .EXAMPLE +- New-NotionEquationBlock -Expression "\frac{a}{b}" +- +- .EXAMPLE +- New-NotionEquationBlock +- +- .OUTPUTS +- notion_equation_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'Default')] +- param ( +- [Parameter(ParameterSetName = 'Default', HelpMessage = 'A KaTeX compatible string.')] +- [string]$Expression +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'Default') +- { +- $obj = [notion_equation_block]::new($Expression) +- } +- else +- { +- $obj = [notion_equation_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/File/New-NotionFileBlock.ps1 b/source/Public/Block/File/New-NotionFileBlock.ps1 +deleted file mode 100644 +index 760aa8f..0000000 +--- a/source/Public/Block/File/New-NotionFileBlock.ps1 ++++ /dev/null +@@ -1,87 +0,0 @@ +-function New-NotionFileBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion file block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_file_block class. +- You can create an empty file block, provide a hosted file (with name, caption, url, and expiry time), +- provide an external file (with name, caption, and url), or directly assign a file object. +- +- .PARAMETER Name +- The name of the file. +- +- .PARAMETER Caption +- The caption (rich_text[] or object) to be displayed for the file. +- +- .PARAMETER Url +- The URL of the file. +- +- .PARAMETER ExpiryTime +- The expiry time for hosted files. +- +- .PARAMETER File +- A notion_hosted_file or notion_external_file object to assign directly. +- +- .EXAMPLE +- New-NotionFileBlock -Name "example.pdf" -Caption "Example" -Url "https://example.com/file.pdf" -ExpiryTime "2025-12-31T23:59:59Z" +- +- .EXAMPLE +- New-NotionFileBlock -Name "example.pdf" -Caption "Example" -Url "https://example.com/file.pdf" +- +- .EXAMPLE +- New-NotionFileBlock -File $notionFileObject +- +- .EXAMPLE +- New-NotionFileBlock +- +- .OUTPUTS +- notion_file_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'Hosted', Mandatory = $true)] +- [Parameter(ParameterSetName = 'External', Mandatory = $true)] +- [string]$Name, +- +- [Parameter(ParameterSetName = 'Hosted', Mandatory = $true, HelpMessage = 'The caption of the file block.')] +- [Parameter(ParameterSetName = 'External', Mandatory = $true, HelpMessage = 'The caption of the file block.')] +- $Caption, +- +- [Parameter(ParameterSetName = 'Hosted', Mandatory = $true, HelpMessage = 'An authenticated HTTP GET URL to the file.')] +- [Parameter(ParameterSetName = 'External', Mandatory = $true)] +- [string]$Url, +- +- [Parameter(ParameterSetName = 'Hosted', HelpMessage = 'The date and time when the link expires.')] +- [object]$ExpiryTime, +- +- [Parameter(ParameterSetName = 'File', Mandatory = $true)] +- [object]$File +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'Hosted') +- { +- $caption = [rich_text]::ConvertFromObject($caption) +- # if expiry time is provided, convert it to Notion formatted date-time +- if ($ExpiryTime) +- { +- $ExpiryTime = ConvertTo-NotionFormattedDateTime -InputDate $ExpiryTime +- } +- $obj = [notion_file_block]::new($Name, $Caption, $Url, $ExpiryTime) +- } +- elseif ($PSCmdlet.ParameterSetName -eq 'External') +- { +- $caption = [rich_text]::ConvertFromObject($caption) +- $obj = [notion_file_block]::new($Name, $Caption, $Url) +- } +- elseif ($PSCmdlet.ParameterSetName -eq 'File') +- { +- $obj = [notion_file_block]::new($File) +- } +- else +- { +- $obj = [notion_file_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/LinkPreview/New-NotionLinkPreviewBlock.ps1 b/source/Public/Block/LinkPreview/New-NotionLinkPreviewBlock.ps1 +deleted file mode 100644 +index a6dda34..0000000 +--- a/source/Public/Block/LinkPreview/New-NotionLinkPreviewBlock.ps1 ++++ /dev/null +@@ -1,34 +0,0 @@ +-function New-NotionLinkPreviewBlock { +- <# +- .SYNOPSIS +- Creates a new Notion link preview block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_link_preview_block class. +- You can create an empty link preview block or provide a URL for the preview. +- +- .PARAMETER Url +- The URL to be used in the link preview block. +- +- .EXAMPLE +- New-NotionLinkPreviewBlock -Url "https://example.com" +- +- .EXAMPLE +- New-NotionLinkPreviewBlock +- +- .OUTPUTS +- notion_link_preview_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithUrl', Mandatory = $true)] +- [string]$Url +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithUrl') { +- $obj = [notion_link_preview_block]::new($Url) +- } else { +- $obj = [notion_link_preview_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/NumberedListItem/New-NotionNumberedListItemBlock.ps1 b/source/Public/Block/NumberedListItem/New-NotionNumberedListItemBlock.ps1 +deleted file mode 100644 +index b3848be..0000000 +--- a/source/Public/Block/NumberedListItem/New-NotionNumberedListItemBlock.ps1 ++++ /dev/null +@@ -1,38 +0,0 @@ +-function New-NotionNumberedListItemBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion numbered list item block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_numbered_list_item_block class. +- You can create an empty numbered list item block or provide rich text content for the item. +- +- .PARAMETER RichText +- The rich text content for the numbered list item. +- +- .EXAMPLE +- New-NotionNumberedListItemBlock -RichText "Item 1" +- +- .EXAMPLE +- New-NotionNumberedListItemBlock +- +- .OUTPUTS +- notion_numbered_list_item_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithText', Mandatory = $true)] +- [object]$RichText +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithText') +- { +- $obj = [notion_numbered_list_item_block]::new($RichText) +- } +- else +- { +- $obj = [notion_numbered_list_item_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/Paragraph/New-NotionParagraphBlock.ps1 b/source/Public/Block/Paragraph/New-NotionParagraphBlock.ps1 +deleted file mode 100644 +index b8c521d..0000000 +--- a/source/Public/Block/Paragraph/New-NotionParagraphBlock.ps1 ++++ /dev/null +@@ -1,52 +0,0 @@ +-function New-NotionParagraphBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion paragraph block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_paragraph_block class. +- You can create an empty paragraph block, provide rich text content, or provide rich text content and a color. +- +- .PARAMETER RichText +- The rich text content for the paragraph block. +- +- .PARAMETER Color +- The color for the paragraph block. +- +- .EXAMPLE +- New-NotionParagraphBlock +- +- .EXAMPLE +- New-NotionParagraphBlock -RichText "This is a paragraph." +- +- .EXAMPLE +- New-NotionParagraphBlock -RichText "This is a paragraph." -Color "yellow" +- +- .OUTPUTS +- notion_paragraph_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithText', Mandatory = $true)] +- [Parameter(ParameterSetName = 'WithTextAndColor', Mandatory = $true)] +- [object[]]$RichText, +- +- [Parameter(ParameterSetName = 'WithTextAndColor')] +- $Color = "default" +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithTextAndColor') +- { +- $obj = [notion_paragraph_block]::new($RichText, $Color) +- } +- elseif ($PSCmdlet.ParameterSetName -eq 'WithText') +- { +- $obj = [notion_paragraph_block]::new($RichText) +- } +- else +- { +- $obj = [notion_paragraph_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/Quote/New-NotionQuoteBlock.ps1 b/source/Public/Block/Quote/New-NotionQuoteBlock.ps1 +deleted file mode 100644 +index bb2ca7d..0000000 +--- a/source/Public/Block/Quote/New-NotionQuoteBlock.ps1 ++++ /dev/null +@@ -1,44 +0,0 @@ +-function New-NotionQuoteBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion quote block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_quote_block class. +- You can create an empty quote block or provide rich text and a color for the quote. +- +- .PARAMETER RichText +- The rich text content for the quote block. +- +- .PARAMETER Color +- The color for the quote block. Default is "default". +- +- .EXAMPLE +- New-NotionQuoteBlock -RichText "This is a quote." -Color "gray" +- +- .EXAMPLE +- New-NotionQuoteBlock +- +- .OUTPUTS +- notion_quote_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithText', Mandatory = $true)] +- [object[]]$RichText, +- +- [Parameter(ParameterSetName = 'WithText')] +- [object]$Color = "default" +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithText') +- { +- $obj = [notion_quote_block]::new($RichText, $Color) +- } +- else +- { +- $obj = [notion_quote_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/Synced/New-NotionSyncedBlock.ps1 b/source/Public/Block/Synced/New-NotionSyncedBlock.ps1 +deleted file mode 100644 +index 474d055..0000000 +--- a/source/Public/Block/Synced/New-NotionSyncedBlock.ps1 ++++ /dev/null +@@ -1,22 +0,0 @@ +-function New-NotionSyncedBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion synced block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_synced_block class. +- You can create an empty synced block. +- +- .EXAMPLE +- New-NotionSyncedBlock +- +- .OUTPUTS +- notion_synced_block +- #> +- [CmdletBinding()] +- param () +- +- $obj = [notion_synced_block]::new() +- return $obj +-} +diff --git a/source/Public/Block/Table/New-NotionTableBlock.ps1 b/source/Public/Block/Table/New-NotionTable.ps1 +similarity index 97% +rename from source/Public/Block/Table/New-NotionTableBlock.ps1 +rename to source/Public/Block/Table/New-NotionTable.ps1 +index 9f98dca..3219665 100644 +--- a/source/Public/Block/Table/New-NotionTableBlock.ps1 ++++ b/source/Public/Block/Table/New-NotionTable.ps1 +@@ -1,5 +1,4 @@ +-function New-NotionTable +-{ ++function New-NotionTable{ + <# + .SYNOPSIS + Creates a new Notion table. +@@ -27,7 +26,7 @@ function New-NotionTable + #> + [CmdletBinding()] + [OutputType([notion_table_block])] +- param ( ++ param( + [Alias("data")] + [object[][]] $TableData, + [bool] $has_column_header = $false, +diff --git a/source/Public/Block/TableRow/New-NotionTableRowBlock.ps1 b/source/Public/Block/Table/New-NotionTableRow.ps1 +similarity index 95% +rename from source/Public/Block/TableRow/New-NotionTableRowBlock.ps1 +rename to source/Public/Block/Table/New-NotionTableRow.ps1 +index d463868..445741c 100644 +--- a/source/Public/Block/TableRow/New-NotionTableRowBlock.ps1 ++++ b/source/Public/Block/Table/New-NotionTableRow.ps1 +@@ -1,5 +1,4 @@ +-function New-NotionTableRow +-{ ++function New-NotionTableRow { + <# + .SYNOPSIS + Creates a new Notion table row. +diff --git a/source/Public/Block/TableOfContents/New-NotionTableOfContentsBlock.ps1 b/source/Public/Block/TableOfContents/New-NotionTableOfContentsBlock.ps1 +deleted file mode 100644 +index d1d2cb9..0000000 +--- a/source/Public/Block/TableOfContents/New-NotionTableOfContentsBlock.ps1 ++++ /dev/null +@@ -1,38 +0,0 @@ +-function New-NotionTableOfContentsBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion table of contents block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_table_of_contents_block class. +- You can create a table of contents block with a specific color or use the default color. +- +- .PARAMETER Color +- The color for the table of contents block. Default is "default". +- +- .EXAMPLE +- New-NotionTableOfContentsBlock +- +- .EXAMPLE +- New-NotionTableOfContentsBlock -Color "gray" +- +- .OUTPUTS +- notion_table_of_contents_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithColor')] +- $Color = "default" +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithColor') +- { +- $obj = [notion_table_of_contents_block]::new($Color) +- } +- else +- { +- $obj = [notion_table_of_contents_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/ToDo/New-NotionToDoBlock.ps1 b/source/Public/Block/ToDo/New-NotionToDoBlock.ps1 +deleted file mode 100644 +index 4f03ba3..0000000 +--- a/source/Public/Block/ToDo/New-NotionToDoBlock.ps1 ++++ /dev/null +@@ -1,52 +0,0 @@ +-function New-NotionToDoBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion to-do block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_to_do_block class. +- You can create an empty to-do block, provide rich text content, or provide rich text content and a checked state. +- +- .PARAMETER RichText +- The rich text content for the to-do item. +- +- .PARAMETER Checked +- Indicates whether the to-do item is checked. +- +- .EXAMPLE +- New-NotionToDoBlock +- +- .EXAMPLE +- New-NotionToDoBlock -RichText "Buy milk" +- +- .EXAMPLE +- New-NotionToDoBlock -RichText "Buy milk" -Checked $true +- +- .OUTPUTS +- notion_to_do_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithText', Mandatory = $true)] +- [Parameter(ParameterSetName = 'WithTextAndChecked', Mandatory = $true)] +- [object]$RichText, +- +- [Parameter(ParameterSetName = 'WithTextAndChecked', Mandatory = $true)] +- [bool]$Checked +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithTextAndChecked') +- { +- $obj = [notion_to_do_block]::new($RichText, $Checked) +- } +- elseif ($PSCmdlet.ParameterSetName -eq 'WithText') +- { +- $obj = [notion_to_do_block]::new($RichText) +- } +- else +- { +- $obj = [notion_to_do_block]::new() +- } +- return $obj +-} +diff --git a/source/Public/Block/Toggle/New-NotionToggleBlock.ps1 b/source/Public/Block/Toggle/New-NotionToggleBlock.ps1 +deleted file mode 100644 +index 11f3a74..0000000 +--- a/source/Public/Block/Toggle/New-NotionToggleBlock.ps1 ++++ /dev/null +@@ -1,47 +0,0 @@ +-function New-NotionToggleBlock +-{ +- <# +- .SYNOPSIS +- Creates a new Notion toggle block object. +- +- .DESCRIPTION +- This function creates a new instance of the notion_toggle_block class. +- You can create an empty toggle block, or provide rich text and an optional color. +- +- .PARAMETER RichText +- The rich text content for the toggle block. +- +- .PARAMETER Color +- The color for the toggle block. Default is "default". +- +- .EXAMPLE +- New-NotionToggleBlock +- +- .EXAMPLE +- New-NotionToggleBlock -RichText "Details" +- +- .EXAMPLE +- New-NotionToggleBlock -RichText "Details" -Color "gray" +- +- .OUTPUTS +- notion_toggle_block +- #> +- [CmdletBinding(DefaultParameterSetName = 'None')] +- param ( +- [Parameter(ParameterSetName = 'WithText', Mandatory = $true)] +- [object[]]$RichText, +- +- [Parameter(ParameterSetName = 'WithText')] +- $Color = "default" +- ) +- +- if ($PSCmdlet.ParameterSetName -eq 'WithText') +- { +- $obj = [notion_toggle_block]::new($RichText, $Color) +- } +- else +- { +- $obj = [notion_toggle_block]::new() +- } +- return $obj +-} +diff --git a/tests/Unit/Classes/Block/24_PDF.tests.ps1 b/tests/Unit/Classes/Block/24_PDF.tests.ps1 +index 7bf475c..8b13789 100644 +--- a/tests/Unit/Classes/Block/24_PDF.tests.ps1 ++++ b/tests/Unit/Classes/Block/24_PDF.tests.ps1 +@@ -1,64 +1 @@ +-Import-Module Pester + +-BeforeDiscovery { +- $projectPath = "$($PSScriptRoot)/../../../.." | Convert-Path +- +- if (-not $ProjectName) +- { +- $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath +- } +- Write-Debug "ProjectName: $ProjectName" +- $global:moduleName = $ProjectName +- +- Remove-Module -Name $global:moduleName -Force -ErrorAction SilentlyContinue +- $mut = Import-Module -Name "$projectPath/output/module/$ProjectName" -Force -ErrorAction Stop -PassThru +-} +- +-Describe "notion_PDF_block Tests" { +- Context "Constructor Tests" { +- It "Should create an empty notion_PDF_block" { +- $block = [notion_PDF_block]::new() +- $block | Should -BeOfType "notion_PDF_block" +- $block.type | Should -Be "pdf" +- $block.pdf | Should -BeNullOrEmpty +- } +- +- It "Should create a notion_PDF_block with a notion_file" { +- $file = [notion_external_file]::new("doc.pdf", "Caption", "https://example.com/doc.pdf") +- $block = [notion_PDF_block]::new($file) +- $block.pdf.name | Should -Be "doc.pdf" +- $block.pdf.caption[0].plain_text | Should -Be "Caption" +- $block.pdf.external.url | Should -Be "https://example.com/doc.pdf" +- } +- +- It "Should create a notion_PDF_block with caption, url, and name" { +- $block = [notion_PDF_block]::new("My Caption", "https://example.com/file.pdf", "file.pdf") +- $block.pdf.name | Should -Be "file.pdf" +- $block.pdf.caption[0].plain_text | Should -Be "My Caption" +- $block.pdf.external.url | Should -Be "https://example.com/file.pdf" +- } +- } +- +- Context "ConvertFromObject Tests" { +- It "Should convert from object correctly" { +- $mock = [PSCustomObject]@{ +- pdf = [PSCustomObject]@{ +- type = "external" +- name = "converted.pdf" +- caption = @([PSCustomObject]@{ +- type = "text" +- text = @{ content = "Converted caption" } +- plain_text = "Converted caption" +- }) +- external = @{ url = "https://example.com/converted.pdf" } +- } +- } +- $block = [notion_PDF_block]::ConvertFromObject($mock) +- $block | Should -BeOfType "notion_PDF_block" +- ($block.pdf.GetType().Name) | Should -Be "notion_external_file" +- $block.pdf.name | Should -Be "converted.pdf" +- $block.pdf.caption[0].plain_text | Should -Be "Converted caption" +- $block.pdf.external.url | Should -Be "https://example.com/converted.pdf" +- } +- } +-} +diff --git a/tests/Unit/Classes/Block/25_Quote.tests.ps1 b/tests/Unit/Classes/Block/25_Quote.tests.ps1 +index a000742..8b13789 100644 +--- a/tests/Unit/Classes/Block/25_Quote.tests.ps1 ++++ b/tests/Unit/Classes/Block/25_Quote.tests.ps1 +@@ -1,69 +1 @@ +-Import-Module Pester + +-BeforeDiscovery { +- $projectPath = "$($PSScriptRoot)/../../../.." | Convert-Path +- +- if (-not $ProjectName) +- { +- $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath +- } +- Write-Debug "ProjectName: $ProjectName" +- $global:moduleName = $ProjectName +- +- Remove-Module -Name $global:moduleName -Force -ErrorAction SilentlyContinue +- $mut = Import-Module -Name "$projectPath/output/module/$ProjectName" -Force -ErrorAction Stop -PassThru +-} +- +-Describe "notion_quote_block Tests" { +- Context "Constructor Tests" { +- It "Should create an empty notion_quote_block" { +- $block = [notion_quote_block]::new() +- $block | Should -BeOfType "notion_quote_block" +- $block.type | Should -Be "quote" +- $block.quote | Should -BeNullOrEmpty +- } +- +- It "Should create a notion_quote_block with rich_text and color" { +- $rt = [rich_text_text]::new("Quote this") +- $block = [notion_quote_block]::new(@($rt), "green") +- $block.quote | Should -Not -BeNullOrEmpty +- ($block.quote.GetType().Name) | Should -Be "Quote_structure" +- $block.quote.rich_text[0].plain_text | Should -Be "Quote this" +- $block.quote.color.ToString() | Should -Be "green" +- } +- } +- +- Context "ConvertFromObject Tests" { +- It "Should convert from object correctly" { +- $mock = [PSCustomObject]@{ +- quote = [PSCustomObject]@{ +- rich_text = @([PSCustomObject]@{ +- type = "text" +- text = @{ content = "Converted quote" } +- plain_text = "Converted quote" +- }) +- color = "yellow" +- } +- } +- $block = [notion_quote_block]::ConvertFromObject($mock) +- $block | Should -BeOfType "notion_quote_block" +- ($block.quote.GetType().Name) | Should -Be "Quote_structure" +- $block.quote.rich_text[0].plain_text | Should -Be "Converted quote" +- $block.quote.color.ToString() | Should -Be "yellow" +- } +- +- It "Should default to 'default' color if not provided" { +- $mock = [PSCustomObject]@{ +- quote = [PSCustomObject]@{ +- rich_text = @([PSCustomObject]@{ +- type = "text" +- text = @{ content = "No color quote" } +- plain_text = "No color quote" +- }) +- } +- } +- $block = [notion_quote_block]::ConvertFromObject($mock) +- $block.quote.color.ToString() | Should -Be "default" +- } +- } +-} +diff --git a/tests/Unit/Classes/Block/26_Synced_Block.tests.ps1 b/tests/Unit/Classes/Block/26_Synced_Block.tests.ps1 +index 373c3ad..8b13789 100644 +--- a/tests/Unit/Classes/Block/26_Synced_Block.tests.ps1 ++++ b/tests/Unit/Classes/Block/26_Synced_Block.tests.ps1 +@@ -1,73 +1 @@ +-Import-Module Pester + +-BeforeDiscovery { +- $projectPath = "$($PSScriptRoot)/../../../.." | Convert-Path +- +- if (-not $ProjectName) +- { +- $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath +- } +- Write-Debug "ProjectName: $ProjectName" +- $global:moduleName = $ProjectName +- +- Remove-Module -Name $global:moduleName -Force -ErrorAction SilentlyContinue +- $mut = Import-Module -Name "$projectPath/output/module/$ProjectName" -Force -ErrorAction Stop -PassThru +-} +- +-Describe "notion_synced_block Tests" { +- Context "Constructor Tests" { +- It "Should create an original synced block" { +- $block = [notion_synced_block]::new() +- $block | Should -BeOfType "notion_synced_block" +- $block.type | Should -Be "synced_block" +- ($block.synced_block.GetType().Name) | Should -Be "Synced_Block_structure" +- $block.synced_block.synced_from | Should -BeNullOrEmpty +- $block.synced_block.children | Should -BeNullOrEmpty +- } +- +- It "Should create a duplicate synced block with block_id" { +- $block = [notion_synced_block]::new([PSCustomObject]@{ block_id = "abc123" }) +- $block.synced_block.synced_from.block_id | Should -Be "abc123" +- } +- } +- +- Context "AddChild Tests" { +- It "Should add a child to an original synced block" { +- $block = [notion_synced_block]::new() +- $child = [notion_paragraph_block]::new(@([rich_text_text]::new("Child text"))) +- $block.AddChild($child) +- $block.synced_block.children.Count | Should -Be 1 +- ($block.synced_block.children[0].GetType().Name) | Should -Be "notion_paragraph_block" +- } +- +- It "Should not add a child to a duplicate synced block" { +- $block = [notion_synced_block]::new([PSCustomObject]@{ block_id = "abc123" }) +- $child = [notion_paragraph_block]::new(@([rich_text_text]::new("Should not add"))) +- { $ErrorActionPreference = "Stop"; $block.AddChild($child) } | Should -Throw +- } +- } +- +- Context "ConvertFromObject Tests" { +- It "Should convert from object with synced_from" { +- $mock = [PSCustomObject]@{ +- synced_block = [PSCustomObject]@{ +- synced_from = [PSCustomObject]@{ +- block_id = "xyz789" +- } +- } +- } +- $block = [notion_synced_block]::ConvertFromObject($mock) +- $block | Should -BeOfType "notion_synced_block" +- $block.synced_block.synced_from.block_id | Should -Be "xyz789" +- } +- +- It "Should convert from object without synced_from" { +- $mock = [PSCustomObject]@{ +- synced_block = [PSCustomObject]@{} +- } +- $block = [notion_synced_block]::ConvertFromObject($mock) +- $block | Should -BeOfType "notion_synced_block" +- $block.synced_block.synced_from | Should -BeNullOrEmpty +- } +- } +-} +diff --git a/tests/Unit/Classes/Block/30_Table_Of_Contents.tests.ps1 b/tests/Unit/Classes/Block/30_Table_Of_Contents.tests.ps1 +index 5d57262..8b13789 100644 +--- a/tests/Unit/Classes/Block/30_Table_Of_Contents.tests.ps1 ++++ b/tests/Unit/Classes/Block/30_Table_Of_Contents.tests.ps1 +@@ -1,56 +1 @@ + +-Import-Module Pester +- +-BeforeDiscovery { +- $projectPath = "$($PSScriptRoot)/../../../.." | Convert-Path +- +- if (-not $ProjectName) +- { +- $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath +- } +- Write-Debug "ProjectName: $ProjectName" +- $global:moduleName = $ProjectName +- +- Remove-Module -Name $global:moduleName -Force -ErrorAction SilentlyContinue +- $mut = Import-Module -Name "$projectPath/output/module/$ProjectName" -Force -ErrorAction Stop -PassThru +-} +- +-Describe "notion_table_of_contents_block Tests" { +- Context "Constructor Tests" { +- It "Should create an empty notion_table_of_contents_block" { +- $block = [notion_table_of_contents_block]::new() +- $block | Should -BeOfType "notion_table_of_contents_block" +- $block.type | Should -Be "table_of_contents" +- $block.table_of_contents | Should -BeNullOrEmpty +- } +- +- It "Should create a notion_table_of_contents_block with color" { +- $block = [notion_table_of_contents_block]::new("brown") +- $block.table_of_contents | Should -Not -BeNullOrEmpty +- ($block.table_of_contents.GetType().Name) | Should -Be "Table_Of_Contents_structure" +- $block.table_of_contents.color.ToString() | Should -Be "brown" +- } +- } +- +- Context "ConvertFromObject Tests" { +- It "Should convert from object with color" { +- $mock = [PSCustomObject]@{ +- table_of_contents = [PSCustomObject]@{ +- color = "orange_background" +- } +- } +- $block = [notion_table_of_contents_block]::ConvertFromObject($mock) +- $block | Should -BeOfType "notion_table_of_contents_block" +- ($block.table_of_contents.GetType().Name) | Should -Be "Table_Of_Contents_structure" +- $block.table_of_contents.color.ToString() | Should -Be "orange_background" +- } +- +- It "Should default to 'default' color if not provided" { +- $mock = [PSCustomObject]@{ +- table_of_contents = [PSCustomObject]@{} +- } +- $block = [notion_table_of_contents_block]::ConvertFromObject($mock) +- $block.table_of_contents.color.ToString() | Should -Be "default" +- } +- } +-} +diff --git a/tests/Unit/Classes/Block/31_To_do.tests.ps1 b/tests/Unit/Classes/Block/31_To_do.tests.ps1 +index ae41a2c..8b13789 100644 +--- a/tests/Unit/Classes/Block/31_To_do.tests.ps1 ++++ b/tests/Unit/Classes/Block/31_To_do.tests.ps1 +@@ -1,80 +1 @@ +-Import-Module Pester + +-BeforeDiscovery { +- $projectPath = "$($PSScriptRoot)/../../../.." | Convert-Path +- +- if (-not $ProjectName) +- { +- $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath +- } +- Write-Debug "ProjectName: $ProjectName" +- $global:moduleName = $ProjectName +- +- Remove-Module -Name $global:moduleName -Force -ErrorAction SilentlyContinue +- $mut = Import-Module -Name "$projectPath/output/module/$ProjectName" -Force -ErrorAction Stop -PassThru +-} +- +-Describe "notion_to_do_block Tests" { +- Context "Constructor Tests" { +- It "Should create an empty notion_to_do_block" { +- $block = [notion_to_do_block]::new() +- $block | Should -BeOfType "notion_to_do_block" +- $block.type | Should -Be "to_do" +- $block.to_do | Should -BeNullOrEmpty +- } +- +- It "Should create a notion_to_do_block with rich_text only" { +- $rt = [rich_text_text]::new("Task 1") +- $block = [notion_to_do_block]::new(@($rt)) +- $block.to_do | Should -Not -BeNullOrEmpty +- ($block.to_do.GetType().Name) | Should -Be "to_do_structure" +- $block.to_do.rich_text[0].plain_text | Should -Be "Task 1" +- $block.to_do.checked | Should -BeFalse +- $block.to_do.color.ToString() | Should -Be "default" +- } +- +- It "Should create a notion_to_do_block with all parameters" { +- $rt = [rich_text_text]::new("Task 2") +- $block = [notion_to_do_block]::new(@($rt), $true, "green") +- $block.to_do.checked | Should -BeTrue +- $block.to_do.color.ToString() | Should -Be "green" +- } +- } +- +- Context "ConvertFromObject Tests" { +- It "Should convert from object correctly" { +- $mock = [PSCustomObject]@{ +- to_do = [PSCustomObject]@{ +- rich_text = @([PSCustomObject]@{ +- type = "text" +- text = @{ content = "Converted task" } +- plain_text = "Converted task" +- }) +- checked = $true +- color = "blue" +- } +- } +- $block = [notion_to_do_block]::ConvertFromObject($mock) +- $block | Should -BeOfType "notion_to_do_block" +- ($block.to_do.GetType().Name) | Should -Be "to_do_structure" +- $block.to_do.rich_text[0].plain_text | Should -Be "Converted task" +- $block.to_do.checked | Should -BeTrue +- $block.to_do.color.ToString() | Should -Be "blue" +- } +- +- It "Should default to 'default' color if not provided" { +- $mock = [PSCustomObject]@{ +- to_do = [PSCustomObject]@{ +- rich_text = @([PSCustomObject]@{ +- type = "text" +- text = @{ content = "No color task" } +- plain_text = "No color task" +- }) +- checked = $false +- } +- } +- $block = [notion_to_do_block]::ConvertFromObject($mock) +- $block.to_do.color.ToString() | Should -Be "default" +- } +- } +-} +diff --git a/tests/Unit/Classes/Block/32_Toggle.tests.ps1 b/tests/Unit/Classes/Block/32_Toggle.tests.ps1 +index 908d2d7..8b13789 100644 +--- a/tests/Unit/Classes/Block/32_Toggle.tests.ps1 ++++ b/tests/Unit/Classes/Block/32_Toggle.tests.ps1 +@@ -1,76 +1 @@ + +-Import-Module Pester +- +-BeforeDiscovery { +- $projectPath = "$($PSScriptRoot)/../../../.." | Convert-Path +- +- if (-not $ProjectName) +- { +- $ProjectName = Get-SamplerProjectName -BuildRoot $projectPath +- } +- Write-Debug "ProjectName: $ProjectName" +- $global:moduleName = $ProjectName +- +- Remove-Module -Name $global:moduleName -Force -ErrorAction SilentlyContinue +- $mut = Import-Module -Name "$projectPath/output/module/$ProjectName" -Force -ErrorAction Stop -PassThru +-} +- +-Describe "notion_toggle_block Tests" { +- Context "Constructor Tests" { +- It "Should create an empty notion_toggle_block" { +- $block = [notion_toggle_block]::new() +- $block | Should -BeOfType "notion_toggle_block" +- $block.type | Should -Be "toggle" +- $block.toggle | Should -BeNullOrEmpty +- } +- +- It "Should create a notion_toggle_block with rich_text only" { +- $rt = [rich_text_text]::new("Toggle content") +- $block = [notion_toggle_block]::new(@($rt)) +- $block.toggle | Should -Not -BeNullOrEmpty +- ($block.toggle.GetType().Name) | Should -Be "Toggle_structure" +- $block.toggle.rich_text[0].plain_text | Should -Be "Toggle content" +- $block.toggle.color.ToString() | Should -Be "default" +- } +- +- It "Should create a notion_toggle_block with rich_text and color" { +- $rt = [rich_text_text]::new("Colored toggle") +- $block = [notion_toggle_block]::new(@($rt), "pink") +- $block.toggle.color.ToString() | Should -Be "pink" +- } +- } +- +- Context "ConvertFromObject Tests" { +- It "Should convert from object correctly" { +- $mock = [PSCustomObject]@{ +- toggle = [PSCustomObject]@{ +- rich_text = @([PSCustomObject]@{ +- type = "text" +- text = @{ content = "Converted toggle" } +- plain_text = "Converted toggle" +- }) +- color = "gray_background" +- } +- } +- $block = [notion_toggle_block]::ConvertFromObject($mock) +- $block | Should -BeOfType "notion_toggle_block" +- ($block.toggle.GetType().Name) | Should -Be "Toggle_structure" +- $block.toggle.rich_text[0].plain_text | Should -Be "Converted toggle" +- $block.toggle.color.ToString() | Should -Be "gray_background" +- } +- +- It "Should default to 'default' color if not provided" { +- $mock = [PSCustomObject]@{ +- toggle = [PSCustomObject]@{ +- rich_text = @([PSCustomObject]@{ +- type = "text" +- text = @{ content = "No color toggle" } +- plain_text = "No color toggle" +- }) +- } +- } +- $block = [notion_toggle_block]::ConvertFromObject($mock) +- $block.toggle.color.ToString() | Should -Be "default" +- } +- } +-} diff --git a/source/WikiSource/Home.md b/source/WikiSource/Home.md index fd4c8d4..00e5b47 100644 --- a/source/WikiSource/Home.md +++ b/source/WikiSource/Home.md @@ -58,6 +58,14 @@ The charm of Notion classes are this simple use while creating objects. ``` PowerShell [notion_block]::new() # creates an empty block object [notion_page]::new() # creates a new page object +[notion_emoji]::new() # creates a new emoji object +``` + +However, there is also a New-NotionBlock CmdLet available to create a new block object. + +``` PowerShell +New-NotionBookmarkBlock -URL "https://www.example.com" -Caption "Example Bookmark" +New-NotionCalloutBlock -RichText "This is a callout" -Icon "💡" ``` If you receive items from the API, the Notion module will automatically convert it into Notion objects From 2c84a9cdee6a7e6c673fc16b5f061f9b320560c8 Mon Sep 17 00:00:00 2001 From: Fabian Franz Steiner <75947402+fasteiner@users.noreply.github.com> Date: Sat, 14 Jun 2025 23:17:15 +0000 Subject: [PATCH 2/2] Add example for New-NotionBreadcrumbBlock in Home.md --- source/WikiSource/Home.md | 1 + 1 file changed, 1 insertion(+) diff --git a/source/WikiSource/Home.md b/source/WikiSource/Home.md index 00e5b47..50aed5a 100644 --- a/source/WikiSource/Home.md +++ b/source/WikiSource/Home.md @@ -66,6 +66,7 @@ However, there is also a New-NotionBlock CmdLet available to create a ``` PowerShell New-NotionBookmarkBlock -URL "https://www.example.com" -Caption "Example Bookmark" New-NotionCalloutBlock -RichText "This is a callout" -Icon "💡" +New-NotionBreadcrumbBlock #new breadcrumb block ``` If you receive items from the API, the Notion module will automatically convert it into Notion objects