@bubblelab/bubble-core 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bubble-bundle.d.ts +803 -351
- package/dist/bubble-factory.d.ts.map +1 -1
- package/dist/bubble-factory.js +130 -35
- package/dist/bubble-factory.js.map +1 -1
- package/dist/bubble-flow/bubble-flow-class.d.ts +5 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -1
- package/dist/bubble-flow/bubble-flow-class.js +20 -0
- package/dist/bubble-flow/bubble-flow-class.js.map +1 -1
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -1
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js +6 -3
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js.map +1 -1
- package/dist/bubbles/service-bubble/agi-inc.d.ts +1121 -0
- package/dist/bubbles/service-bubble/agi-inc.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/agi-inc.js +730 -0
- package/dist/bubbles/service-bubble/agi-inc.js.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts +273 -61
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/ai-agent.js +536 -405
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -1
- package/dist/bubbles/service-bubble/airtable.d.ts +1753 -0
- package/dist/bubbles/service-bubble/airtable.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/airtable.js +1173 -0
- package/dist/bubbles/service-bubble/airtable.js.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.d.ts +240 -0
- package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.js +119 -0
- package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.js.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/instagram-hashtag-scraper.d.ts +4 -4
- package/dist/bubbles/service-bubble/apify/actors/instagram-scraper.d.ts +14 -14
- package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.d.ts +137 -0
- package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.js +81 -0
- package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.js.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/linkedin-posts-search.d.ts +6 -6
- package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-posts.d.ts +32 -32
- package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.d.ts +488 -0
- package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.js +463 -0
- package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.js.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.d.ts +262 -0
- package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.js +291 -0
- package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.js.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.d.ts +12 -12
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts +1301 -170
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.js +32 -0
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.js.map +1 -1
- package/dist/bubbles/service-bubble/apify/apify.d.ts +158 -13
- package/dist/bubbles/service-bubble/apify/apify.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/apify/apify.js +222 -37
- package/dist/bubbles/service-bubble/apify/apify.js.map +1 -1
- package/dist/bubbles/service-bubble/browserbase/browserbase.d.ts +542 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.integration.flow.d.ts +37 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.integration.flow.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.integration.flow.js +203 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.integration.flow.js.map +1 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.js +593 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.js.map +1 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.schema.d.ts +518 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.schema.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.schema.js +311 -0
- package/dist/bubbles/service-bubble/browserbase/browserbase.schema.js.map +1 -0
- package/dist/bubbles/service-bubble/browserbase/index.d.ts +3 -0
- package/dist/bubbles/service-bubble/browserbase/index.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/browserbase/index.js +3 -0
- package/dist/bubbles/service-bubble/browserbase/index.js.map +1 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.d.ts +1358 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.js +219 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.js.map +1 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.schema.d.ts +1604 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.schema.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.schema.js +194 -0
- package/dist/bubbles/service-bubble/crustdata/crustdata.schema.js.map +1 -0
- package/dist/bubbles/service-bubble/crustdata/index.d.ts +3 -0
- package/dist/bubbles/service-bubble/crustdata/index.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/crustdata/index.js +3 -0
- package/dist/bubbles/service-bubble/crustdata/index.js.map +1 -0
- package/dist/bubbles/service-bubble/eleven-labs.d.ts +421 -0
- package/dist/bubbles/service-bubble/eleven-labs.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/eleven-labs.js +479 -0
- package/dist/bubbles/service-bubble/eleven-labs.js.map +1 -0
- package/dist/bubbles/service-bubble/firecrawl.d.ts +37748 -0
- package/dist/bubbles/service-bubble/firecrawl.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/firecrawl.js +1489 -0
- package/dist/bubbles/service-bubble/firecrawl.js.map +1 -0
- package/dist/bubbles/service-bubble/followupboss.d.ts +6822 -0
- package/dist/bubbles/service-bubble/followupboss.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/followupboss.js +1394 -0
- package/dist/bubbles/service-bubble/followupboss.js.map +1 -0
- package/dist/bubbles/service-bubble/github.d.ts +2393 -0
- package/dist/bubbles/service-bubble/github.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/github.js +1046 -0
- package/dist/bubbles/service-bubble/github.js.map +1 -0
- package/dist/bubbles/service-bubble/gmail.d.ts +180 -180
- package/dist/bubbles/service-bubble/google-calendar.d.ts +60 -60
- package/dist/bubbles/service-bubble/google-drive.d.ts +69 -68
- package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/google-drive.js +35 -3
- package/dist/bubbles/service-bubble/google-drive.js.map +1 -1
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.d.ts +943 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.d.ts +31 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.js +184 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.js +401 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.d.ts +1024 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/{google-sheets.js → google-sheets/google-sheets.schema.js} +45 -409
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.d.ts +38 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.js +183 -0
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/index.d.ts +4 -0
- package/dist/bubbles/service-bubble/google-sheets/index.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets/index.js +4 -0
- package/dist/bubbles/service-bubble/google-sheets/index.js.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts +4 -4
- package/dist/bubbles/service-bubble/http.d.ts +17 -5
- package/dist/bubbles/service-bubble/http.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/http.integration.flow.d.ts +49 -0
- package/dist/bubbles/service-bubble/http.integration.flow.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/http.integration.flow.js +425 -0
- package/dist/bubbles/service-bubble/http.integration.flow.js.map +1 -0
- package/dist/bubbles/service-bubble/http.js +47 -5
- package/dist/bubbles/service-bubble/http.js.map +1 -1
- package/dist/bubbles/service-bubble/insforge-db.d.ts +140 -0
- package/dist/bubbles/service-bubble/insforge-db.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/insforge-db.js +260 -0
- package/dist/bubbles/service-bubble/insforge-db.js.map +1 -0
- package/dist/bubbles/service-bubble/notion/index.d.ts +3 -0
- package/dist/bubbles/service-bubble/notion/index.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/notion/index.js +3 -0
- package/dist/bubbles/service-bubble/notion/index.js.map +1 -0
- package/dist/bubbles/service-bubble/notion/notion.d.ts +35405 -0
- package/dist/bubbles/service-bubble/notion/notion.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/notion/notion.js +1492 -0
- package/dist/bubbles/service-bubble/notion/notion.js.map +1 -0
- package/dist/bubbles/service-bubble/notion/property-schemas.d.ts +1148 -0
- package/dist/bubbles/service-bubble/notion/property-schemas.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/notion/property-schemas.js +341 -0
- package/dist/bubbles/service-bubble/notion/property-schemas.js.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts +12 -12
- package/dist/bubbles/service-bubble/resend.d.ts +30 -9
- package/dist/bubbles/service-bubble/resend.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/resend.js +133 -2
- package/dist/bubbles/service-bubble/resend.js.map +1 -1
- package/dist/bubbles/service-bubble/slack.d.ts +1741 -798
- package/dist/bubbles/service-bubble/slack.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/slack.js +322 -28
- package/dist/bubbles/service-bubble/slack.js.map +1 -1
- package/dist/bubbles/service-bubble/storage.d.ts +26 -22
- package/dist/bubbles/service-bubble/storage.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/storage.js +45 -4
- package/dist/bubbles/service-bubble/storage.js.map +1 -1
- package/dist/bubbles/service-bubble/telegram.d.ts +7742 -0
- package/dist/bubbles/service-bubble/telegram.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/telegram.js +1132 -0
- package/dist/bubbles/service-bubble/telegram.js.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.d.ts +494 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.integration.flow.d.ts +31 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.integration.flow.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.integration.flow.js +100 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.integration.flow.js.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.js +1301 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.schema.d.ts +473 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.schema.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.schema.js +230 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.schema.js.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/index.d.ts +3 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/index.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/index.js +3 -0
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/index.js.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +76 -20
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js +12 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +14 -14
- package/dist/bubbles/tool-bubble/code-edit-tool.d.ts +188 -0
- package/dist/bubbles/tool-bubble/code-edit-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/code-edit-tool.js +321 -0
- package/dist/bubbles/tool-bubble/code-edit-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/company-enrichment-tool.d.ts +740 -0
- package/dist/bubbles/tool-bubble/company-enrichment-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/company-enrichment-tool.js +350 -0
- package/dist/bubbles/tool-bubble/company-enrichment-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +8 -4
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +115 -10
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/google-maps-tool.d.ts +455 -0
- package/dist/bubbles/tool-bubble/google-maps-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/google-maps-tool.js +206 -0
- package/dist/bubbles/tool-bubble/google-maps-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/instagram-tool.d.ts +36 -36
- package/dist/bubbles/tool-bubble/instagram-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/instagram-tool.js +4 -2
- package/dist/bubbles/tool-bubble/instagram-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/linkedin-tool.d.ts +830 -453
- package/dist/bubbles/tool-bubble/linkedin-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/linkedin-tool.js +236 -14
- package/dist/bubbles/tool-bubble/linkedin-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +66 -66
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +17 -16
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/research-agent-tool.js +32 -17
- package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/tiktok-tool.d.ts +485 -0
- package/dist/bubbles/tool-bubble/tiktok-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/tiktok-tool.js +226 -0
- package/dist/bubbles/tool-bubble/tiktok-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts +8 -8
- package/dist/bubbles/tool-bubble/twitter-tool.d.ts +947 -0
- package/dist/bubbles/tool-bubble/twitter-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/twitter-tool.js +497 -0
- package/dist/bubbles/tool-bubble/twitter-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +22 -16
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/web-crawl-tool.js +58 -59
- package/dist/bubbles/tool-bubble/web-crawl-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/web-extract-tool.js +17 -17
- package/dist/bubbles/tool-bubble/web-extract-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +21 -113
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/web-scrape-tool.js +55 -73
- package/dist/bubbles/tool-bubble/web-scrape-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +20 -9
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/web-search-tool.js +45 -35
- package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/youtube-tool.d.ts +25 -25
- package/dist/bubbles/tool-bubble/youtube-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/youtube-tool.js +8 -5
- package/dist/bubbles/tool-bubble/youtube-tool.js.map +1 -1
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +4 -4
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +30 -30
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js +1 -1
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +22 -22
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js +1 -1
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +70 -70
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -1
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js +4 -4
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -1
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +36 -36
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +1 -1
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +14 -14
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts.map +1 -1
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js +6 -6
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js.map +1 -1
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +18 -18
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts.map +1 -1
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js +24 -4
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js.map +1 -1
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +19 -19
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts.map +1 -1
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js +8 -8
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js.map +1 -1
- package/dist/bubbles.json +260 -77
- package/dist/index.d.ts +25 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/logging/BubbleLogger.d.ts +55 -16
- package/dist/logging/BubbleLogger.d.ts.map +1 -1
- package/dist/logging/BubbleLogger.js +192 -77
- package/dist/logging/BubbleLogger.js.map +1 -1
- package/dist/logging/StreamingBubbleLogger.d.ts +21 -1
- package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -1
- package/dist/logging/StreamingBubbleLogger.js +80 -8
- package/dist/logging/StreamingBubbleLogger.js.map +1 -1
- package/dist/logging/WebhookStreamLogger.d.ts +66 -0
- package/dist/logging/WebhookStreamLogger.d.ts.map +1 -0
- package/dist/logging/WebhookStreamLogger.js +291 -0
- package/dist/logging/WebhookStreamLogger.js.map +1 -0
- package/dist/types/available-tools.d.ts +1 -1
- package/dist/types/available-tools.d.ts.map +1 -1
- package/dist/types/available-tools.js +7 -0
- package/dist/types/available-tools.js.map +1 -1
- package/dist/types/base-bubble-class.d.ts +6 -4
- package/dist/types/base-bubble-class.d.ts.map +1 -1
- package/dist/types/base-bubble-class.js +30 -23
- package/dist/types/base-bubble-class.js.map +1 -1
- package/dist/types/bubble.d.ts +2 -0
- package/dist/types/bubble.d.ts.map +1 -1
- package/dist/types/service-bubble-class.d.ts +1 -1
- package/dist/types/service-bubble-class.d.ts.map +1 -1
- package/dist/types/service-bubble-class.js +2 -2
- package/dist/types/service-bubble-class.js.map +1 -1
- package/dist/types/tool-bubble-class.d.ts +1 -1
- package/dist/types/tool-bubble-class.d.ts.map +1 -1
- package/dist/types/tool-bubble-class.js +60 -10
- package/dist/types/tool-bubble-class.js.map +1 -1
- package/dist/types/workflow-bubble-class.d.ts +1 -1
- package/dist/types/workflow-bubble-class.d.ts.map +1 -1
- package/dist/types/workflow-bubble-class.js +2 -2
- package/dist/types/workflow-bubble-class.js.map +1 -1
- package/dist/utils/agent-formatter.d.ts +14 -2
- package/dist/utils/agent-formatter.d.ts.map +1 -1
- package/dist/utils/agent-formatter.js +174 -26
- package/dist/utils/agent-formatter.js.map +1 -1
- package/dist/utils/bubbleflow-validation.d.ts +7 -0
- package/dist/utils/bubbleflow-validation.d.ts.map +1 -1
- package/dist/utils/bubbleflow-validation.js +171 -6
- package/dist/utils/bubbleflow-validation.js.map +1 -1
- package/dist/utils/json-parsing.d.ts.map +1 -1
- package/dist/utils/json-parsing.js +146 -0
- package/dist/utils/json-parsing.js.map +1 -1
- package/dist/utils/safe-gemini-chat.d.ts +31 -0
- package/dist/utils/safe-gemini-chat.d.ts.map +1 -0
- package/dist/utils/safe-gemini-chat.js +93 -0
- package/dist/utils/safe-gemini-chat.js.map +1 -0
- package/dist/utils/schema-comparison.d.ts +92 -0
- package/dist/utils/schema-comparison.d.ts.map +1 -0
- package/dist/utils/schema-comparison.js +716 -0
- package/dist/utils/schema-comparison.js.map +1 -0
- package/dist/utils/zod-schema.d.ts +24 -0
- package/dist/utils/zod-schema.d.ts.map +1 -0
- package/dist/utils/zod-schema.js +56 -0
- package/dist/utils/zod-schema.js.map +1 -0
- package/package.json +6 -4
- package/dist/bubbles/service-bubble/google-sheets.d.ts +0 -1811
- package/dist/bubbles/service-bubble/google-sheets.d.ts.map +0 -1
- package/dist/bubbles/service-bubble/google-sheets.js.map +0 -1
- package/dist/bubbles/service-bubble/x-twitter.d.ts +0 -814
- package/dist/bubbles/service-bubble/x-twitter.d.ts.map +0 -1
- package/dist/bubbles/service-bubble/x-twitter.js +0 -445
- package/dist/bubbles/service-bubble/x-twitter.js.map +0 -1
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +0 -125
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +0 -1
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +0 -808
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +0 -1
- package/dist/test-gm.d.ts +0 -10
- package/dist/test-gm.d.ts.map +0 -1
- package/dist/test-gm.js +0 -95
- package/dist/test-gm.js.map +0 -1
- package/dist/utils/param-helper.d.ts +0 -2
- package/dist/utils/param-helper.d.ts.map +0 -1
- package/dist/utils/param-helper.js +0 -5
- package/dist/utils/param-helper.js.map +0 -1
|
@@ -0,0 +1,1492 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ServiceBubble } from '../../../types/service-bubble-class.js';
|
|
3
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
4
|
+
// Notion API base URL
|
|
5
|
+
const NOTION_API_BASE = 'https://api.notion.com/v1';
|
|
6
|
+
const NOTION_API_VERSION = '2025-09-03';
|
|
7
|
+
// Rich text schema
|
|
8
|
+
const RichTextSchema = z.object({
|
|
9
|
+
type: z.enum(['text', 'mention', 'equation']).describe('Type of rich text'),
|
|
10
|
+
text: z
|
|
11
|
+
.object({
|
|
12
|
+
content: z.string().describe('The actual text content'),
|
|
13
|
+
link: z
|
|
14
|
+
.object({
|
|
15
|
+
url: z.string().url().describe('URL for the link'),
|
|
16
|
+
})
|
|
17
|
+
.nullable()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Optional link object'),
|
|
20
|
+
})
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Text object (when type is "text")'),
|
|
23
|
+
annotations: z
|
|
24
|
+
.object({
|
|
25
|
+
bold: z.boolean().default(false).describe('Whether text is bolded'),
|
|
26
|
+
italic: z.boolean().default(false).describe('Whether text is italicized'),
|
|
27
|
+
strikethrough: z
|
|
28
|
+
.boolean()
|
|
29
|
+
.default(false)
|
|
30
|
+
.describe('Whether text is struck through'),
|
|
31
|
+
underline: z
|
|
32
|
+
.boolean()
|
|
33
|
+
.default(false)
|
|
34
|
+
.describe('Whether text is underlined'),
|
|
35
|
+
code: z.boolean().default(false).describe('Whether text is code style'),
|
|
36
|
+
color: z
|
|
37
|
+
.enum([
|
|
38
|
+
'default',
|
|
39
|
+
'gray',
|
|
40
|
+
'brown',
|
|
41
|
+
'orange',
|
|
42
|
+
'yellow',
|
|
43
|
+
'green',
|
|
44
|
+
'blue',
|
|
45
|
+
'purple',
|
|
46
|
+
'pink',
|
|
47
|
+
'red',
|
|
48
|
+
])
|
|
49
|
+
.default('default')
|
|
50
|
+
.describe('Color of the text'),
|
|
51
|
+
})
|
|
52
|
+
.optional()
|
|
53
|
+
.describe('Styling information for the rich text'),
|
|
54
|
+
plain_text: z.string().optional().describe('Plain text without annotations'),
|
|
55
|
+
href: z.string().nullable().optional().describe('URL of any link'),
|
|
56
|
+
});
|
|
57
|
+
// File object schema
|
|
58
|
+
const FileObjectSchema = z.discriminatedUnion('type', [
|
|
59
|
+
z.object({
|
|
60
|
+
type: z.literal('file').describe('Notion-hosted file type'),
|
|
61
|
+
file: z
|
|
62
|
+
.object({
|
|
63
|
+
url: z
|
|
64
|
+
.string()
|
|
65
|
+
.url()
|
|
66
|
+
.describe('Authenticated HTTP GET URL to the file'),
|
|
67
|
+
expiry_time: z
|
|
68
|
+
.string()
|
|
69
|
+
.describe('ISO 8601 date time when the link expires'),
|
|
70
|
+
})
|
|
71
|
+
.describe('File object for Notion-hosted files'),
|
|
72
|
+
}),
|
|
73
|
+
z.object({
|
|
74
|
+
type: z.literal('file_upload').describe('File uploaded via API type'),
|
|
75
|
+
file_upload: z
|
|
76
|
+
.object({
|
|
77
|
+
id: z.string().describe('ID of a File Upload object'),
|
|
78
|
+
})
|
|
79
|
+
.describe('File upload object'),
|
|
80
|
+
}),
|
|
81
|
+
z.object({
|
|
82
|
+
type: z.literal('external').describe('External file type'),
|
|
83
|
+
external: z
|
|
84
|
+
.object({
|
|
85
|
+
url: z.string().url().describe('Link to externally hosted content'),
|
|
86
|
+
})
|
|
87
|
+
.describe('External file object'),
|
|
88
|
+
}),
|
|
89
|
+
]);
|
|
90
|
+
// Icon schema (emoji or file)
|
|
91
|
+
const IconSchema = z.discriminatedUnion('type', [
|
|
92
|
+
z.object({
|
|
93
|
+
type: z.literal('emoji').describe('Emoji icon'),
|
|
94
|
+
emoji: z.string().describe('Emoji character'),
|
|
95
|
+
}),
|
|
96
|
+
z.object({
|
|
97
|
+
type: z.literal('external').describe('External icon'),
|
|
98
|
+
external: z.object({
|
|
99
|
+
url: z.string().url().describe('URL of the external icon'),
|
|
100
|
+
}),
|
|
101
|
+
}),
|
|
102
|
+
z.object({
|
|
103
|
+
type: z.literal('file').describe('File icon'),
|
|
104
|
+
file: z.object({
|
|
105
|
+
url: z.string().url().describe('URL of the file icon'),
|
|
106
|
+
expiry_time: z.string().describe('Expiry time of the URL'),
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
]);
|
|
110
|
+
// User object schema
|
|
111
|
+
const UserSchema = z.object({
|
|
112
|
+
object: z.literal('user').describe('Object type'),
|
|
113
|
+
id: z.string().describe('User ID'),
|
|
114
|
+
type: z.enum(['person', 'bot']).optional().describe('User type'),
|
|
115
|
+
name: z.string().optional().describe('User name'),
|
|
116
|
+
avatar_url: z.string().nullable().optional().describe('Avatar URL'),
|
|
117
|
+
person: z
|
|
118
|
+
.object({
|
|
119
|
+
email: z.string().email().optional().describe('Email address'),
|
|
120
|
+
})
|
|
121
|
+
.optional()
|
|
122
|
+
.describe('Person details'),
|
|
123
|
+
bot: z
|
|
124
|
+
.object({
|
|
125
|
+
owner: z
|
|
126
|
+
.object({
|
|
127
|
+
type: z.enum(['workspace', 'user']).describe('Owner type'),
|
|
128
|
+
workspace: z.boolean().optional(),
|
|
129
|
+
})
|
|
130
|
+
.optional(),
|
|
131
|
+
workspace_name: z.string().optional().describe('Workspace name'),
|
|
132
|
+
})
|
|
133
|
+
.optional()
|
|
134
|
+
.describe('Bot details'),
|
|
135
|
+
});
|
|
136
|
+
// Parent object schema
|
|
137
|
+
const ParentSchema = z.discriminatedUnion('type', [
|
|
138
|
+
z.object({
|
|
139
|
+
type: z.literal('page_id').describe('Parent is a page'),
|
|
140
|
+
page_id: z.string().describe('ID of the parent page'),
|
|
141
|
+
}),
|
|
142
|
+
z.object({
|
|
143
|
+
type: z.literal('database_id').describe('Parent is a database'),
|
|
144
|
+
database_id: z.string().describe('ID of the parent database'),
|
|
145
|
+
}),
|
|
146
|
+
z.object({
|
|
147
|
+
type: z.literal('data_source_id').describe('Parent is a data source'),
|
|
148
|
+
data_source_id: z.string().describe('ID of the parent data source'),
|
|
149
|
+
database_id: z.string().optional().describe('ID of the database'),
|
|
150
|
+
}),
|
|
151
|
+
z.object({
|
|
152
|
+
type: z.literal('block_id').describe('Parent is a block'),
|
|
153
|
+
block_id: z.string().describe('ID of the parent block'),
|
|
154
|
+
}),
|
|
155
|
+
z.object({
|
|
156
|
+
type: z.literal('workspace').describe('Parent is the workspace'),
|
|
157
|
+
workspace: z.literal(true).describe('Workspace parent'),
|
|
158
|
+
}),
|
|
159
|
+
]);
|
|
160
|
+
// Page property value base schema (simplified - full schema would be very complex)
|
|
161
|
+
const PagePropertyValueSchema = z
|
|
162
|
+
.record(z.string(), z.unknown())
|
|
163
|
+
.describe('Page properties object containing various property types');
|
|
164
|
+
// Page object response schema
|
|
165
|
+
const PageObjectSchema = z.object({
|
|
166
|
+
object: z.literal('page').describe('Object type'),
|
|
167
|
+
id: z.string().describe('Page ID'),
|
|
168
|
+
created_time: z.string().describe('ISO 8601 datetime'),
|
|
169
|
+
last_edited_time: z.string().describe('ISO 8601 datetime'),
|
|
170
|
+
created_by: UserSchema.describe('User who created the page'),
|
|
171
|
+
last_edited_by: UserSchema.describe('User who last edited the page'),
|
|
172
|
+
cover: FileObjectSchema.nullable().optional().describe('Page cover image'),
|
|
173
|
+
icon: IconSchema.nullable().optional().describe('Page icon'),
|
|
174
|
+
parent: ParentSchema.describe('Parent of the page'),
|
|
175
|
+
archived: z.boolean().describe('Whether the page is archived'),
|
|
176
|
+
in_trash: z.boolean().optional().describe('Whether the page is in trash'),
|
|
177
|
+
properties: PagePropertyValueSchema.describe('Page properties'),
|
|
178
|
+
url: z.string().url().describe('Public URL of the page'),
|
|
179
|
+
public_url: z
|
|
180
|
+
.string()
|
|
181
|
+
.url()
|
|
182
|
+
.nullable()
|
|
183
|
+
.optional()
|
|
184
|
+
.describe('Public shareable URL'),
|
|
185
|
+
});
|
|
186
|
+
// Block object response schema (simplified)
|
|
187
|
+
const BlockObjectSchema = z
|
|
188
|
+
.object({
|
|
189
|
+
object: z.literal('block').describe('Object type'),
|
|
190
|
+
id: z.string().describe('Block ID'),
|
|
191
|
+
parent: ParentSchema.optional().describe('Parent of the block'),
|
|
192
|
+
created_time: z.string().describe('ISO 8601 datetime'),
|
|
193
|
+
last_edited_time: z.string().describe('ISO 8601 datetime'),
|
|
194
|
+
created_by: UserSchema.describe('User who created the block'),
|
|
195
|
+
last_edited_by: UserSchema.describe('User who last edited the block'),
|
|
196
|
+
has_children: z.boolean().describe('Whether the block has children'),
|
|
197
|
+
archived: z.boolean().describe('Whether the block is archived'),
|
|
198
|
+
in_trash: z.boolean().optional().describe('Whether block is in trash'),
|
|
199
|
+
type: z
|
|
200
|
+
.string()
|
|
201
|
+
.describe('Type of block (e.g., paragraph, heading_2, etc.)'),
|
|
202
|
+
// Block type-specific properties would be dynamic based on 'type'
|
|
203
|
+
})
|
|
204
|
+
.passthrough()
|
|
205
|
+
.describe('Block object with type-specific properties');
|
|
206
|
+
// Data source object response schema
|
|
207
|
+
const DataSourceObjectSchema = z
|
|
208
|
+
.object({
|
|
209
|
+
object: z.literal('data_source').describe('Object type'),
|
|
210
|
+
id: z.string().describe('Data source ID'),
|
|
211
|
+
created_time: z.string().describe('ISO 8601 datetime'),
|
|
212
|
+
last_edited_time: z.string().describe('ISO 8601 datetime'),
|
|
213
|
+
created_by: UserSchema.describe('User who created the data source'),
|
|
214
|
+
last_edited_by: UserSchema.describe('User who last edited the data source'),
|
|
215
|
+
properties: z
|
|
216
|
+
.record(z.string(), z.unknown())
|
|
217
|
+
.describe('Data source properties'),
|
|
218
|
+
parent: z
|
|
219
|
+
.object({
|
|
220
|
+
type: z.literal('database_id'),
|
|
221
|
+
database_id: z.string(),
|
|
222
|
+
})
|
|
223
|
+
.passthrough()
|
|
224
|
+
.describe('Parent database'),
|
|
225
|
+
database_parent: z
|
|
226
|
+
.record(z.unknown())
|
|
227
|
+
.optional()
|
|
228
|
+
.describe('Database parent information'),
|
|
229
|
+
archived: z.boolean().describe('Whether the data source is archived'),
|
|
230
|
+
in_trash: z
|
|
231
|
+
.boolean()
|
|
232
|
+
.optional()
|
|
233
|
+
.describe('Whether data source is in trash'),
|
|
234
|
+
is_inline: z.boolean().optional().describe('Whether displayed inline'),
|
|
235
|
+
icon: IconSchema.nullable().optional().describe('Data source icon'),
|
|
236
|
+
cover: FileObjectSchema.nullable().optional().describe('Data source cover'),
|
|
237
|
+
title: z
|
|
238
|
+
.array(RichTextSchema)
|
|
239
|
+
.default([])
|
|
240
|
+
.describe('Data source title (can be empty array)'),
|
|
241
|
+
description: z
|
|
242
|
+
.array(RichTextSchema)
|
|
243
|
+
.optional()
|
|
244
|
+
.describe('Data source description'),
|
|
245
|
+
url: z.string().url().optional().describe('URL of the data source'),
|
|
246
|
+
public_url: z
|
|
247
|
+
.string()
|
|
248
|
+
.url()
|
|
249
|
+
.nullable()
|
|
250
|
+
.optional()
|
|
251
|
+
.describe('Public shareable URL of the data source'),
|
|
252
|
+
})
|
|
253
|
+
.passthrough();
|
|
254
|
+
// Database object response schema
|
|
255
|
+
const DatabaseObjectSchema = z.object({
|
|
256
|
+
object: z.literal('database').describe('Object type'),
|
|
257
|
+
id: z
|
|
258
|
+
.string()
|
|
259
|
+
.describe('Database ID, To find a database ID, navigate to the database URL in your Notion workspace. The ID is the string of characters in the URL that is between the slash following the workspace name (if applicable) and the question mark. The ID is a 32 characters alphanumeric string.'),
|
|
260
|
+
created_time: z.string().describe('ISO 8601 datetime'),
|
|
261
|
+
last_edited_time: z.string().describe('ISO 8601 datetime'),
|
|
262
|
+
title: z.array(RichTextSchema).describe('Database title'),
|
|
263
|
+
description: z
|
|
264
|
+
.array(RichTextSchema)
|
|
265
|
+
.optional()
|
|
266
|
+
.describe('Database description'),
|
|
267
|
+
icon: IconSchema.nullable().optional().describe('Database icon'),
|
|
268
|
+
cover: FileObjectSchema.nullable().optional().describe('Database cover'),
|
|
269
|
+
parent: ParentSchema.describe('Parent of the database'),
|
|
270
|
+
is_inline: z.boolean().optional().describe('Whether displayed inline'),
|
|
271
|
+
in_trash: z.boolean().optional().describe('Whether in trash'),
|
|
272
|
+
is_locked: z.boolean().optional().describe('Whether locked from editing'),
|
|
273
|
+
data_sources: z
|
|
274
|
+
.array(z.object({
|
|
275
|
+
id: z.string().describe('Data source ID'),
|
|
276
|
+
name: z.string().describe('Data source name'),
|
|
277
|
+
icon: IconSchema.nullable().optional(),
|
|
278
|
+
cover: FileObjectSchema.nullable().optional(),
|
|
279
|
+
}))
|
|
280
|
+
.describe('Array of data sources in this database'),
|
|
281
|
+
url: z.string().url().optional().describe('URL of the database'),
|
|
282
|
+
public_url: z.string().url().nullable().optional(),
|
|
283
|
+
});
|
|
284
|
+
// Comment object response schema
|
|
285
|
+
const CommentObjectSchema = z.object({
|
|
286
|
+
object: z.literal('comment').describe('Object type'),
|
|
287
|
+
id: z.string().describe('Comment ID'),
|
|
288
|
+
parent: z
|
|
289
|
+
.object({
|
|
290
|
+
type: z.enum(['page_id', 'block_id']),
|
|
291
|
+
page_id: z.string().optional(),
|
|
292
|
+
block_id: z.string().optional(),
|
|
293
|
+
})
|
|
294
|
+
.passthrough()
|
|
295
|
+
.describe('Parent page or block'),
|
|
296
|
+
discussion_id: z.string().describe('Discussion thread ID'),
|
|
297
|
+
created_time: z.string().describe('ISO 8601 datetime'),
|
|
298
|
+
last_edited_time: z.string().describe('ISO 8601 datetime'),
|
|
299
|
+
created_by: UserSchema.describe('User who created the comment'),
|
|
300
|
+
rich_text: z.array(RichTextSchema).describe('Comment content'),
|
|
301
|
+
});
|
|
302
|
+
// Define the parameters schema for different Notion operations
|
|
303
|
+
const NotionParamsSchema = z.discriminatedUnion('operation', [
|
|
304
|
+
// Create page operation
|
|
305
|
+
z.object({
|
|
306
|
+
operation: z.literal('create_page').describe('Create a new page in Notion'),
|
|
307
|
+
parent: ParentSchema.describe('Parent page, database, or workspace'),
|
|
308
|
+
properties: z
|
|
309
|
+
.record(z.unknown())
|
|
310
|
+
.optional()
|
|
311
|
+
.describe('Page properties (required if parent is a data source)'),
|
|
312
|
+
children: z
|
|
313
|
+
.array(z.unknown())
|
|
314
|
+
.optional()
|
|
315
|
+
.describe('Array of block objects for page content'),
|
|
316
|
+
icon: FileObjectSchema.or(z.object({
|
|
317
|
+
type: z.literal('emoji'),
|
|
318
|
+
emoji: z.string().describe('Emoji character'),
|
|
319
|
+
}))
|
|
320
|
+
.optional()
|
|
321
|
+
.describe('Page icon (emoji or file)'),
|
|
322
|
+
cover: FileObjectSchema.optional().describe('Page cover image'),
|
|
323
|
+
credentials: z
|
|
324
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
325
|
+
.optional()
|
|
326
|
+
.describe('Object mapping credential types to values'),
|
|
327
|
+
}),
|
|
328
|
+
// Retrieve page operation
|
|
329
|
+
z.object({
|
|
330
|
+
operation: z.literal('retrieve_page').describe('Retrieve a page by its ID'),
|
|
331
|
+
page_id: z.string().describe('UUID of the Notion page'),
|
|
332
|
+
filter_properties: z
|
|
333
|
+
.array(z.string())
|
|
334
|
+
.optional()
|
|
335
|
+
.describe('Limit response to specific property IDs'),
|
|
336
|
+
credentials: z
|
|
337
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
338
|
+
.optional()
|
|
339
|
+
.describe('Object mapping credential types to values'),
|
|
340
|
+
}),
|
|
341
|
+
// Update page operation
|
|
342
|
+
z.object({
|
|
343
|
+
operation: z.literal('update_page').describe('Update an existing page'),
|
|
344
|
+
page_id: z.string().describe('UUID of the Notion page'),
|
|
345
|
+
properties: z
|
|
346
|
+
.record(z.unknown())
|
|
347
|
+
.optional()
|
|
348
|
+
.describe('Page properties to update'),
|
|
349
|
+
icon: FileObjectSchema.or(z.object({
|
|
350
|
+
type: z.literal('emoji'),
|
|
351
|
+
emoji: z.string(),
|
|
352
|
+
}))
|
|
353
|
+
.nullable()
|
|
354
|
+
.optional()
|
|
355
|
+
.describe('Page icon (emoji or file, null to remove)'),
|
|
356
|
+
cover: FileObjectSchema.nullable()
|
|
357
|
+
.optional()
|
|
358
|
+
.describe('Page cover image (null to remove)'),
|
|
359
|
+
archived: z
|
|
360
|
+
.boolean()
|
|
361
|
+
.optional()
|
|
362
|
+
.describe('Set to true to archive the page'),
|
|
363
|
+
in_trash: z
|
|
364
|
+
.boolean()
|
|
365
|
+
.optional()
|
|
366
|
+
.describe('Set to true to move page to trash'),
|
|
367
|
+
is_locked: z
|
|
368
|
+
.boolean()
|
|
369
|
+
.optional()
|
|
370
|
+
.describe('Control if page can be edited in Notion UI'),
|
|
371
|
+
credentials: z
|
|
372
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
373
|
+
.optional()
|
|
374
|
+
.describe('Object mapping credential types to values'),
|
|
375
|
+
}),
|
|
376
|
+
// Retrieve database operation
|
|
377
|
+
z.object({
|
|
378
|
+
operation: z
|
|
379
|
+
.literal('retrieve_database')
|
|
380
|
+
.describe('Retrieve a database by its ID'),
|
|
381
|
+
database_id: z.string().describe('UUID of the Notion database'),
|
|
382
|
+
credentials: z
|
|
383
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
384
|
+
.optional()
|
|
385
|
+
.describe('Object mapping credential types to values'),
|
|
386
|
+
}),
|
|
387
|
+
// Query data source operation
|
|
388
|
+
z.object({
|
|
389
|
+
operation: z
|
|
390
|
+
.literal('query_data_source')
|
|
391
|
+
.describe('Query a data source to retrieve pages'),
|
|
392
|
+
data_source_id: z.string().describe('UUID of the Notion data source'),
|
|
393
|
+
filter: z
|
|
394
|
+
.record(z.unknown())
|
|
395
|
+
.optional()
|
|
396
|
+
.describe('Filter object for querying'),
|
|
397
|
+
sorts: z.array(z.unknown()).optional().describe('Array of sort objects'),
|
|
398
|
+
start_cursor: z.string().optional().describe('Cursor for pagination'),
|
|
399
|
+
page_size: z
|
|
400
|
+
.number()
|
|
401
|
+
.min(1)
|
|
402
|
+
.max(100)
|
|
403
|
+
.optional()
|
|
404
|
+
.default(100)
|
|
405
|
+
.describe('Number of results per page (1-100)'),
|
|
406
|
+
filter_properties: z
|
|
407
|
+
.array(z.string())
|
|
408
|
+
.optional()
|
|
409
|
+
.describe('Limit response to specific property IDs'),
|
|
410
|
+
result_type: z
|
|
411
|
+
.enum(['page', 'data_source'])
|
|
412
|
+
.optional()
|
|
413
|
+
.describe('Filter results to page or data_source'),
|
|
414
|
+
credentials: z
|
|
415
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
416
|
+
.optional()
|
|
417
|
+
.describe('Object mapping credential types to values'),
|
|
418
|
+
}),
|
|
419
|
+
// Create data source operation
|
|
420
|
+
z.object({
|
|
421
|
+
operation: z
|
|
422
|
+
.literal('create_data_source')
|
|
423
|
+
.describe('Create a new data source in an existing database'),
|
|
424
|
+
parent: z
|
|
425
|
+
.object({
|
|
426
|
+
type: z.literal('database_id').describe('Parent type'),
|
|
427
|
+
database_id: z.string().describe('ID of the parent database'),
|
|
428
|
+
})
|
|
429
|
+
.describe('Parent database for the new data source'),
|
|
430
|
+
properties: z
|
|
431
|
+
.record(z.unknown())
|
|
432
|
+
.describe('Property schema for the data source (hash map where keys are property names)'),
|
|
433
|
+
title: z
|
|
434
|
+
.array(RichTextSchema)
|
|
435
|
+
.optional()
|
|
436
|
+
.describe('Title of the data source'),
|
|
437
|
+
icon: FileObjectSchema.or(z.object({
|
|
438
|
+
type: z.literal('emoji'),
|
|
439
|
+
emoji: z.string().describe('Emoji character'),
|
|
440
|
+
}))
|
|
441
|
+
.optional()
|
|
442
|
+
.describe('Data source icon'),
|
|
443
|
+
credentials: z
|
|
444
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
445
|
+
.optional()
|
|
446
|
+
.describe('Object mapping credential types to values'),
|
|
447
|
+
}),
|
|
448
|
+
// Update data source operation
|
|
449
|
+
z.object({
|
|
450
|
+
operation: z.literal('update_data_source').describe('Update a data source'),
|
|
451
|
+
data_source_id: z.string().describe('UUID of the Notion data source'),
|
|
452
|
+
properties: z
|
|
453
|
+
.record(z.unknown())
|
|
454
|
+
.optional()
|
|
455
|
+
.describe('Property schema updates'),
|
|
456
|
+
title: z.array(RichTextSchema).optional().describe('Updated title'),
|
|
457
|
+
description: z
|
|
458
|
+
.array(RichTextSchema)
|
|
459
|
+
.optional()
|
|
460
|
+
.describe('Updated description'),
|
|
461
|
+
icon: FileObjectSchema.or(z.object({
|
|
462
|
+
type: z.literal('emoji'),
|
|
463
|
+
emoji: z.string().describe('Emoji character'),
|
|
464
|
+
}))
|
|
465
|
+
.nullable()
|
|
466
|
+
.optional()
|
|
467
|
+
.describe('Updated icon (null to remove)'),
|
|
468
|
+
in_trash: z.boolean().optional().describe('Set to true to move to trash'),
|
|
469
|
+
parent: z
|
|
470
|
+
.object({
|
|
471
|
+
type: z.literal('database_id'),
|
|
472
|
+
database_id: z.string().describe('ID of the destination database'),
|
|
473
|
+
})
|
|
474
|
+
.optional()
|
|
475
|
+
.describe('New parent database to move data source'),
|
|
476
|
+
credentials: z
|
|
477
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
478
|
+
.optional()
|
|
479
|
+
.describe('Object mapping credential types to values'),
|
|
480
|
+
}),
|
|
481
|
+
// Create database operation
|
|
482
|
+
z.object({
|
|
483
|
+
operation: z.literal('create_database').describe('Create a new database'),
|
|
484
|
+
parent: z
|
|
485
|
+
.object({
|
|
486
|
+
type: z.enum(['page_id', 'workspace']).describe('Type of parent'),
|
|
487
|
+
page_id: z
|
|
488
|
+
.string()
|
|
489
|
+
.optional()
|
|
490
|
+
.describe('ID of parent page (required if type is page_id)'),
|
|
491
|
+
workspace: z
|
|
492
|
+
.literal(true)
|
|
493
|
+
.optional()
|
|
494
|
+
.describe('Workspace parent (required if type is workspace)'),
|
|
495
|
+
})
|
|
496
|
+
.refine((data) => {
|
|
497
|
+
if (data.type === 'page_id') {
|
|
498
|
+
return !!data.page_id;
|
|
499
|
+
}
|
|
500
|
+
if (data.type === 'workspace') {
|
|
501
|
+
return data.workspace === true;
|
|
502
|
+
}
|
|
503
|
+
return false;
|
|
504
|
+
}, {
|
|
505
|
+
message: 'page_id is required when type is page_id, or workspace must be true when type is workspace',
|
|
506
|
+
})
|
|
507
|
+
.transform((data) => {
|
|
508
|
+
if (data.type === 'workspace') {
|
|
509
|
+
return { type: 'workspace', workspace: true };
|
|
510
|
+
}
|
|
511
|
+
return { type: 'page_id', page_id: data.page_id };
|
|
512
|
+
})
|
|
513
|
+
.describe('Parent page or workspace'),
|
|
514
|
+
initial_data_source: z
|
|
515
|
+
.object({
|
|
516
|
+
properties: z
|
|
517
|
+
.record(z.unknown())
|
|
518
|
+
.describe('Property schema for the data source (hash map where keys are property names)'),
|
|
519
|
+
})
|
|
520
|
+
.describe('Initial data source configuration'),
|
|
521
|
+
title: z.array(RichTextSchema).optional().describe('Title of the database'),
|
|
522
|
+
description: z
|
|
523
|
+
.array(RichTextSchema)
|
|
524
|
+
.optional()
|
|
525
|
+
.describe('Description of the database'),
|
|
526
|
+
icon: FileObjectSchema.or(z.object({
|
|
527
|
+
type: z.literal('emoji'),
|
|
528
|
+
emoji: z.string(),
|
|
529
|
+
}))
|
|
530
|
+
.optional()
|
|
531
|
+
.describe('Database icon'),
|
|
532
|
+
cover: FileObjectSchema.optional().describe('Database cover image'),
|
|
533
|
+
credentials: z
|
|
534
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
535
|
+
.optional()
|
|
536
|
+
.describe('Object mapping credential types to values'),
|
|
537
|
+
}),
|
|
538
|
+
// Update database operation
|
|
539
|
+
z.object({
|
|
540
|
+
operation: z.literal('update_database').describe('Update a database'),
|
|
541
|
+
database_id: z.string().describe('UUID of the Notion database'),
|
|
542
|
+
title: z.array(RichTextSchema).optional().describe('Updated title'),
|
|
543
|
+
description: z
|
|
544
|
+
.array(RichTextSchema)
|
|
545
|
+
.optional()
|
|
546
|
+
.describe('Updated description'),
|
|
547
|
+
icon: FileObjectSchema.or(z.object({
|
|
548
|
+
type: z.literal('emoji'),
|
|
549
|
+
emoji: z.string(),
|
|
550
|
+
}))
|
|
551
|
+
.nullable()
|
|
552
|
+
.optional()
|
|
553
|
+
.describe('Updated icon (null to remove)'),
|
|
554
|
+
cover: FileObjectSchema.nullable()
|
|
555
|
+
.optional()
|
|
556
|
+
.describe('Updated cover (null to remove)'),
|
|
557
|
+
parent: ParentSchema.optional().describe('New parent to move database'),
|
|
558
|
+
is_inline: z
|
|
559
|
+
.boolean()
|
|
560
|
+
.optional()
|
|
561
|
+
.describe('Whether database should be displayed inline'),
|
|
562
|
+
in_trash: z.boolean().optional().describe('Set to true to move to trash'),
|
|
563
|
+
is_locked: z
|
|
564
|
+
.boolean()
|
|
565
|
+
.optional()
|
|
566
|
+
.describe('Set to true to lock from editing'),
|
|
567
|
+
credentials: z
|
|
568
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
569
|
+
.optional()
|
|
570
|
+
.describe('Object mapping credential types to values'),
|
|
571
|
+
}),
|
|
572
|
+
// Append block children operation
|
|
573
|
+
z.object({
|
|
574
|
+
operation: z
|
|
575
|
+
.literal('append_block_children')
|
|
576
|
+
.describe('Append children blocks to a parent block or page'),
|
|
577
|
+
block_id: z.string().describe('UUID of the parent block or page'),
|
|
578
|
+
children: z
|
|
579
|
+
.array(z.unknown())
|
|
580
|
+
.min(1)
|
|
581
|
+
.max(100)
|
|
582
|
+
.describe('Array of block objects to append (max 100)'),
|
|
583
|
+
after: z.string().optional().describe('ID of block to append after'),
|
|
584
|
+
credentials: z
|
|
585
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
586
|
+
.optional()
|
|
587
|
+
.describe('Object mapping credential types to values'),
|
|
588
|
+
}),
|
|
589
|
+
// Retrieve block children operation
|
|
590
|
+
z.object({
|
|
591
|
+
operation: z
|
|
592
|
+
.literal('retrieve_block_children')
|
|
593
|
+
.describe('Retrieve children blocks of a parent block'),
|
|
594
|
+
block_id: z.string().describe('UUID of the parent block'),
|
|
595
|
+
start_cursor: z.string().optional().describe('Cursor for pagination'),
|
|
596
|
+
page_size: z
|
|
597
|
+
.number()
|
|
598
|
+
.min(1)
|
|
599
|
+
.max(100)
|
|
600
|
+
.optional()
|
|
601
|
+
.default(100)
|
|
602
|
+
.describe('Number of items per response (max 100)'),
|
|
603
|
+
credentials: z
|
|
604
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
605
|
+
.optional()
|
|
606
|
+
.describe('Object mapping credential types to values'),
|
|
607
|
+
}),
|
|
608
|
+
// Retrieve block operation
|
|
609
|
+
z.object({
|
|
610
|
+
operation: z
|
|
611
|
+
.literal('retrieve_block')
|
|
612
|
+
.describe('Retrieve a block by its ID'),
|
|
613
|
+
block_id: z.string().describe('UUID of the Notion block'),
|
|
614
|
+
credentials: z
|
|
615
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
616
|
+
.optional()
|
|
617
|
+
.describe('Object mapping credential types to values'),
|
|
618
|
+
}),
|
|
619
|
+
// Update block operation
|
|
620
|
+
z.object({
|
|
621
|
+
operation: z.literal('update_block').describe('Update a block'),
|
|
622
|
+
block_id: z.string().describe('UUID of the Notion block'),
|
|
623
|
+
archived: z
|
|
624
|
+
.boolean()
|
|
625
|
+
.optional()
|
|
626
|
+
.describe('Set to true to archive the block'),
|
|
627
|
+
// Block type-specific fields would go here (e.g., heading_2, paragraph, etc.)
|
|
628
|
+
// For simplicity, we'll use passthrough for block-specific updates
|
|
629
|
+
credentials: z
|
|
630
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
631
|
+
.optional()
|
|
632
|
+
.describe('Object mapping credential types to values'),
|
|
633
|
+
}),
|
|
634
|
+
// Create comment operation
|
|
635
|
+
z.object({
|
|
636
|
+
operation: z
|
|
637
|
+
.literal('create_comment')
|
|
638
|
+
.describe('Create a comment on a page or block'),
|
|
639
|
+
parent: z
|
|
640
|
+
.object({
|
|
641
|
+
page_id: z.string().optional().describe('ID of parent page'),
|
|
642
|
+
block_id: z.string().optional().describe('ID of parent block'),
|
|
643
|
+
})
|
|
644
|
+
.describe('Parent page or block ID (one of page_id or block_id is required)'),
|
|
645
|
+
rich_text: z
|
|
646
|
+
.array(RichTextSchema)
|
|
647
|
+
.min(1)
|
|
648
|
+
.describe('Array of rich text objects for comment content'),
|
|
649
|
+
attachments: z
|
|
650
|
+
.array(z.object({
|
|
651
|
+
file_upload_id: z.string().describe('File Upload ID'),
|
|
652
|
+
type: z.literal('file_upload').optional(),
|
|
653
|
+
}))
|
|
654
|
+
.max(3)
|
|
655
|
+
.optional()
|
|
656
|
+
.describe('Array of file attachments (max 3)'),
|
|
657
|
+
display_name: z
|
|
658
|
+
.object({
|
|
659
|
+
type: z
|
|
660
|
+
.enum(['integration', 'user', 'custom'])
|
|
661
|
+
.describe('Type of display name'),
|
|
662
|
+
custom: z
|
|
663
|
+
.object({
|
|
664
|
+
name: z.string().describe('Custom name for the comment'),
|
|
665
|
+
})
|
|
666
|
+
.optional()
|
|
667
|
+
.describe('Custom name object (required if type is custom)'),
|
|
668
|
+
})
|
|
669
|
+
.optional()
|
|
670
|
+
.describe('Custom display name for the comment'),
|
|
671
|
+
credentials: z
|
|
672
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
673
|
+
.optional()
|
|
674
|
+
.describe('Object mapping credential types to values'),
|
|
675
|
+
}),
|
|
676
|
+
// Retrieve comment operation
|
|
677
|
+
z.object({
|
|
678
|
+
operation: z
|
|
679
|
+
.literal('retrieve_comment')
|
|
680
|
+
.describe('Retrieve a comment by its ID'),
|
|
681
|
+
comment_id: z.string().describe('UUID of the Notion comment'),
|
|
682
|
+
credentials: z
|
|
683
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
684
|
+
.optional()
|
|
685
|
+
.describe('Object mapping credential types to values'),
|
|
686
|
+
}),
|
|
687
|
+
// List users operation
|
|
688
|
+
z.object({
|
|
689
|
+
operation: z
|
|
690
|
+
.literal('list_users')
|
|
691
|
+
.describe('List all users in the workspace'),
|
|
692
|
+
start_cursor: z.string().optional().describe('Cursor for pagination'),
|
|
693
|
+
page_size: z
|
|
694
|
+
.number()
|
|
695
|
+
.min(1)
|
|
696
|
+
.max(100)
|
|
697
|
+
.optional()
|
|
698
|
+
.default(100)
|
|
699
|
+
.describe('Number of items per page (max 100)'),
|
|
700
|
+
credentials: z
|
|
701
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
702
|
+
.optional()
|
|
703
|
+
.describe('Object mapping credential types to values'),
|
|
704
|
+
}),
|
|
705
|
+
// Search operation
|
|
706
|
+
z.object({
|
|
707
|
+
operation: z
|
|
708
|
+
.literal('search')
|
|
709
|
+
.describe('Search all pages and data sources shared with the integration'),
|
|
710
|
+
query: z
|
|
711
|
+
.string()
|
|
712
|
+
.optional()
|
|
713
|
+
.describe('Text to compare against page and data source titles. If not provided, returns all pages and data sources shared with the integration'),
|
|
714
|
+
sort: z
|
|
715
|
+
.object({
|
|
716
|
+
direction: z
|
|
717
|
+
.enum(['ascending', 'descending'])
|
|
718
|
+
.describe('Sort direction'),
|
|
719
|
+
timestamp: z
|
|
720
|
+
.literal('last_edited_time')
|
|
721
|
+
.describe('Timestamp field to sort by (only "last_edited_time" is supported)'),
|
|
722
|
+
})
|
|
723
|
+
.optional()
|
|
724
|
+
.describe('Sort criteria. If not provided, most recently edited results are returned first'),
|
|
725
|
+
filter: z
|
|
726
|
+
.object({
|
|
727
|
+
value: z
|
|
728
|
+
.enum(['page', 'data_source'])
|
|
729
|
+
.describe('Filter results to only pages or only data sources'),
|
|
730
|
+
property: z
|
|
731
|
+
.literal('object')
|
|
732
|
+
.describe('Property to filter on (only "object" is supported)'),
|
|
733
|
+
})
|
|
734
|
+
.optional()
|
|
735
|
+
.describe('Filter to limit results to either pages or data sources'),
|
|
736
|
+
start_cursor: z
|
|
737
|
+
.string()
|
|
738
|
+
.optional()
|
|
739
|
+
.describe('Cursor for pagination (from previous response)'),
|
|
740
|
+
page_size: z
|
|
741
|
+
.number()
|
|
742
|
+
.min(1)
|
|
743
|
+
.max(100)
|
|
744
|
+
.optional()
|
|
745
|
+
.default(100)
|
|
746
|
+
.describe('Number of items per page (max 100)'),
|
|
747
|
+
credentials: z
|
|
748
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
749
|
+
.optional()
|
|
750
|
+
.describe('Object mapping credential types to values'),
|
|
751
|
+
}),
|
|
752
|
+
]);
|
|
753
|
+
// Define result schemas with proper response types and specific property names
|
|
754
|
+
const NotionResultSchema = z.discriminatedUnion('operation', [
|
|
755
|
+
z.object({
|
|
756
|
+
operation: z
|
|
757
|
+
.literal('create_page')
|
|
758
|
+
.describe('Create page operation result'),
|
|
759
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
760
|
+
error: z.string().describe('Error message if operation failed'),
|
|
761
|
+
page: PageObjectSchema.optional().describe('Created page object'),
|
|
762
|
+
}),
|
|
763
|
+
z.object({
|
|
764
|
+
operation: z
|
|
765
|
+
.literal('retrieve_page')
|
|
766
|
+
.describe('Retrieve page operation result'),
|
|
767
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
768
|
+
error: z.string().describe('Error message if operation failed'),
|
|
769
|
+
page: PageObjectSchema.optional().describe('Retrieved page object'),
|
|
770
|
+
}),
|
|
771
|
+
z.object({
|
|
772
|
+
operation: z
|
|
773
|
+
.literal('update_page')
|
|
774
|
+
.describe('Update page operation result'),
|
|
775
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
776
|
+
error: z.string().describe('Error message if operation failed'),
|
|
777
|
+
page: PageObjectSchema.optional().describe('Updated page object'),
|
|
778
|
+
}),
|
|
779
|
+
z.object({
|
|
780
|
+
operation: z
|
|
781
|
+
.literal('retrieve_database')
|
|
782
|
+
.describe('Retrieve database operation result'),
|
|
783
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
784
|
+
error: z.string().describe('Error message if operation failed'),
|
|
785
|
+
database: DatabaseObjectSchema.optional().describe('Retrieved database object'),
|
|
786
|
+
}),
|
|
787
|
+
z.object({
|
|
788
|
+
operation: z
|
|
789
|
+
.literal('query_data_source')
|
|
790
|
+
.describe('Query data source operation result'),
|
|
791
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
792
|
+
error: z.string().describe('Error message if operation failed'),
|
|
793
|
+
results: z
|
|
794
|
+
.array(z
|
|
795
|
+
.object({
|
|
796
|
+
object: z
|
|
797
|
+
.enum(['page', 'data_source'])
|
|
798
|
+
.describe('Object type (page or data_source)'),
|
|
799
|
+
id: z.string().describe('Object ID'),
|
|
800
|
+
created_time: z.string().describe('ISO 8601 datetime'),
|
|
801
|
+
last_edited_time: z.string().describe('ISO 8601 datetime'),
|
|
802
|
+
url: z.string().url().optional().describe('URL of the object'),
|
|
803
|
+
properties: z
|
|
804
|
+
.record(z.string(), z.unknown())
|
|
805
|
+
.optional()
|
|
806
|
+
.describe('Object properties'),
|
|
807
|
+
title: z
|
|
808
|
+
.array(z.object({ plain_text: z.string().optional() }).passthrough())
|
|
809
|
+
.optional()
|
|
810
|
+
.describe('Title (for data sources)'),
|
|
811
|
+
parent: z
|
|
812
|
+
.record(z.unknown())
|
|
813
|
+
.optional()
|
|
814
|
+
.describe('Parent of the object'),
|
|
815
|
+
archived: z
|
|
816
|
+
.boolean()
|
|
817
|
+
.optional()
|
|
818
|
+
.describe('Whether the object is archived'),
|
|
819
|
+
in_trash: z
|
|
820
|
+
.boolean()
|
|
821
|
+
.optional()
|
|
822
|
+
.describe('Whether the object is in trash'),
|
|
823
|
+
})
|
|
824
|
+
.passthrough())
|
|
825
|
+
.optional()
|
|
826
|
+
.describe('Array of pages or data sources from query'),
|
|
827
|
+
next_cursor: z
|
|
828
|
+
.string()
|
|
829
|
+
.nullable()
|
|
830
|
+
.optional()
|
|
831
|
+
.describe('Cursor for pagination'),
|
|
832
|
+
has_more: z.boolean().optional().describe('Whether more results exist'),
|
|
833
|
+
}),
|
|
834
|
+
z.object({
|
|
835
|
+
operation: z
|
|
836
|
+
.literal('create_data_source')
|
|
837
|
+
.describe('Create data source operation result'),
|
|
838
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
839
|
+
error: z.string().describe('Error message if operation failed'),
|
|
840
|
+
dataSource: DataSourceObjectSchema.optional().describe('Created data source object'),
|
|
841
|
+
}),
|
|
842
|
+
z.object({
|
|
843
|
+
operation: z
|
|
844
|
+
.literal('update_data_source')
|
|
845
|
+
.describe('Update data source operation result'),
|
|
846
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
847
|
+
error: z.string().describe('Error message if operation failed'),
|
|
848
|
+
dataSource: DataSourceObjectSchema.optional().describe('Updated data source object'),
|
|
849
|
+
}),
|
|
850
|
+
z.object({
|
|
851
|
+
operation: z
|
|
852
|
+
.literal('create_database')
|
|
853
|
+
.describe('Create database operation result'),
|
|
854
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
855
|
+
error: z.string().describe('Error message if operation failed'),
|
|
856
|
+
database: DatabaseObjectSchema.optional().describe('Created database object'),
|
|
857
|
+
}),
|
|
858
|
+
z.object({
|
|
859
|
+
operation: z
|
|
860
|
+
.literal('update_database')
|
|
861
|
+
.describe('Update database operation result'),
|
|
862
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
863
|
+
error: z.string().describe('Error message if operation failed'),
|
|
864
|
+
database: DatabaseObjectSchema.optional().describe('Updated database object'),
|
|
865
|
+
}),
|
|
866
|
+
z.object({
|
|
867
|
+
operation: z
|
|
868
|
+
.literal('append_block_children')
|
|
869
|
+
.describe('Append block children operation result'),
|
|
870
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
871
|
+
error: z.string().describe('Error message if operation failed'),
|
|
872
|
+
blocks: z
|
|
873
|
+
.array(BlockObjectSchema)
|
|
874
|
+
.optional()
|
|
875
|
+
.describe('Array of appended block objects'),
|
|
876
|
+
next_cursor: z
|
|
877
|
+
.string()
|
|
878
|
+
.nullable()
|
|
879
|
+
.optional()
|
|
880
|
+
.describe('Cursor for pagination'),
|
|
881
|
+
has_more: z.boolean().optional().describe('Whether more results exist'),
|
|
882
|
+
}),
|
|
883
|
+
z.object({
|
|
884
|
+
operation: z
|
|
885
|
+
.literal('retrieve_block_children')
|
|
886
|
+
.describe('Retrieve block children operation result'),
|
|
887
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
888
|
+
error: z.string().describe('Error message if operation failed'),
|
|
889
|
+
blocks: z
|
|
890
|
+
.array(BlockObjectSchema)
|
|
891
|
+
.optional()
|
|
892
|
+
.describe('Array of block children'),
|
|
893
|
+
next_cursor: z
|
|
894
|
+
.string()
|
|
895
|
+
.nullable()
|
|
896
|
+
.optional()
|
|
897
|
+
.describe('Cursor for pagination'),
|
|
898
|
+
has_more: z.boolean().optional().describe('Whether more results exist'),
|
|
899
|
+
}),
|
|
900
|
+
z.object({
|
|
901
|
+
operation: z
|
|
902
|
+
.literal('retrieve_block')
|
|
903
|
+
.describe('Retrieve block operation result'),
|
|
904
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
905
|
+
error: z.string().describe('Error message if operation failed'),
|
|
906
|
+
block: BlockObjectSchema.optional().describe('Retrieved block object'),
|
|
907
|
+
}),
|
|
908
|
+
z.object({
|
|
909
|
+
operation: z
|
|
910
|
+
.literal('update_block')
|
|
911
|
+
.describe('Update block operation result'),
|
|
912
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
913
|
+
error: z.string().describe('Error message if operation failed'),
|
|
914
|
+
block: BlockObjectSchema.optional().describe('Updated block object'),
|
|
915
|
+
}),
|
|
916
|
+
z.object({
|
|
917
|
+
operation: z
|
|
918
|
+
.literal('create_comment')
|
|
919
|
+
.describe('Create comment operation result'),
|
|
920
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
921
|
+
error: z.string().describe('Error message if operation failed'),
|
|
922
|
+
comment: CommentObjectSchema.optional().describe('Created comment object'),
|
|
923
|
+
}),
|
|
924
|
+
z.object({
|
|
925
|
+
operation: z
|
|
926
|
+
.literal('retrieve_comment')
|
|
927
|
+
.describe('Retrieve comment operation result'),
|
|
928
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
929
|
+
error: z.string().describe('Error message if operation failed'),
|
|
930
|
+
comment: CommentObjectSchema.optional().describe('Retrieved comment object'),
|
|
931
|
+
}),
|
|
932
|
+
z.object({
|
|
933
|
+
operation: z.literal('list_users').describe('List users operation result'),
|
|
934
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
935
|
+
error: z.string().describe('Error message if operation failed'),
|
|
936
|
+
users: z
|
|
937
|
+
.array(UserSchema)
|
|
938
|
+
.optional()
|
|
939
|
+
.describe('Array of users in the workspace'),
|
|
940
|
+
next_cursor: z
|
|
941
|
+
.string()
|
|
942
|
+
.nullable()
|
|
943
|
+
.optional()
|
|
944
|
+
.describe('Cursor for pagination'),
|
|
945
|
+
has_more: z.boolean().optional().describe('Whether more results exist'),
|
|
946
|
+
}),
|
|
947
|
+
z.object({
|
|
948
|
+
operation: z.literal('search').describe('Search operation result'),
|
|
949
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
950
|
+
error: z.string().describe('Error message if operation failed'),
|
|
951
|
+
results: z
|
|
952
|
+
.array(z
|
|
953
|
+
.object({
|
|
954
|
+
object: z
|
|
955
|
+
.enum(['page', 'data_source'])
|
|
956
|
+
.describe('Object type (page or data_source)'),
|
|
957
|
+
id: z.string().describe('Object ID'),
|
|
958
|
+
created_time: z.string().describe('ISO 8601 datetime'),
|
|
959
|
+
last_edited_time: z.string().describe('ISO 8601 datetime'),
|
|
960
|
+
url: z.string().url().optional().describe('URL of the object'),
|
|
961
|
+
properties: z
|
|
962
|
+
.record(z.string(), z.unknown())
|
|
963
|
+
.optional()
|
|
964
|
+
.describe('Object properties'),
|
|
965
|
+
title: z
|
|
966
|
+
.array(z.object({ plain_text: z.string().optional() }).passthrough())
|
|
967
|
+
.optional()
|
|
968
|
+
.describe('Title (for data sources)'),
|
|
969
|
+
parent: z
|
|
970
|
+
.record(z.unknown())
|
|
971
|
+
.optional()
|
|
972
|
+
.describe('Parent of the object'),
|
|
973
|
+
archived: z
|
|
974
|
+
.boolean()
|
|
975
|
+
.optional()
|
|
976
|
+
.describe('Whether the object is archived'),
|
|
977
|
+
in_trash: z
|
|
978
|
+
.boolean()
|
|
979
|
+
.optional()
|
|
980
|
+
.describe('Whether the object is in trash'),
|
|
981
|
+
})
|
|
982
|
+
.passthrough())
|
|
983
|
+
.optional()
|
|
984
|
+
.describe('Array of pages and/or data sources matching the search query'),
|
|
985
|
+
next_cursor: z
|
|
986
|
+
.string()
|
|
987
|
+
.nullable()
|
|
988
|
+
.optional()
|
|
989
|
+
.describe('Cursor for pagination'),
|
|
990
|
+
has_more: z.boolean().optional().describe('Whether more results exist'),
|
|
991
|
+
}),
|
|
992
|
+
]);
|
|
993
|
+
export class NotionBubble extends ServiceBubble {
|
|
994
|
+
static type = 'service';
|
|
995
|
+
static service = 'notion';
|
|
996
|
+
static authType = 'oauth';
|
|
997
|
+
static bubbleName = 'notion';
|
|
998
|
+
static schema = NotionParamsSchema;
|
|
999
|
+
static resultSchema = NotionResultSchema;
|
|
1000
|
+
static shortDescription = 'Notion API integration for pages, databases, and blocks';
|
|
1001
|
+
static longDescription = `
|
|
1002
|
+
Comprehensive Notion API integration for managing pages, databases, blocks, and comments.
|
|
1003
|
+
|
|
1004
|
+
Features:
|
|
1005
|
+
- Create, retrieve, and update pages
|
|
1006
|
+
- Manage databases and data sources
|
|
1007
|
+
- Query data sources with filters and sorting
|
|
1008
|
+
- Search pages and data sources by title
|
|
1009
|
+
- Append and retrieve block children
|
|
1010
|
+
- Create and retrieve comments
|
|
1011
|
+
- List workspace users
|
|
1012
|
+
|
|
1013
|
+
Use cases:
|
|
1014
|
+
- Content management and automation
|
|
1015
|
+
- Database operations and queries
|
|
1016
|
+
- Page creation and updates
|
|
1017
|
+
- Search and discovery of pages and data sources
|
|
1018
|
+
- Block manipulation
|
|
1019
|
+
- Comment management
|
|
1020
|
+
- Workspace user management
|
|
1021
|
+
|
|
1022
|
+
Security Features:
|
|
1023
|
+
- OAuth token authentication
|
|
1024
|
+
- Parameter validation
|
|
1025
|
+
- Comprehensive error handling
|
|
1026
|
+
- Respects Notion API versioning (${NOTION_API_VERSION})
|
|
1027
|
+
`;
|
|
1028
|
+
static alias = 'notion';
|
|
1029
|
+
constructor(params = {
|
|
1030
|
+
operation: 'list_users',
|
|
1031
|
+
}, context, instanceId) {
|
|
1032
|
+
super(params, context, instanceId);
|
|
1033
|
+
}
|
|
1034
|
+
async testCredential() {
|
|
1035
|
+
try {
|
|
1036
|
+
const token = this.chooseCredential();
|
|
1037
|
+
if (!token) {
|
|
1038
|
+
return false;
|
|
1039
|
+
}
|
|
1040
|
+
// Test by listing users
|
|
1041
|
+
await this.makeNotionApiCall('users', {}, 'GET');
|
|
1042
|
+
return true;
|
|
1043
|
+
}
|
|
1044
|
+
catch (error) {
|
|
1045
|
+
console.error('Notion credential test failed:', error);
|
|
1046
|
+
return false;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
chooseCredential() {
|
|
1050
|
+
const credentials = this.params.credentials;
|
|
1051
|
+
if (!credentials || typeof credentials !== 'object') {
|
|
1052
|
+
return undefined;
|
|
1053
|
+
}
|
|
1054
|
+
return credentials[CredentialType.NOTION_OAUTH_TOKEN];
|
|
1055
|
+
}
|
|
1056
|
+
async performAction(context) {
|
|
1057
|
+
void context;
|
|
1058
|
+
const { operation } = this.params;
|
|
1059
|
+
try {
|
|
1060
|
+
const result = await (async () => {
|
|
1061
|
+
switch (operation) {
|
|
1062
|
+
case 'create_page':
|
|
1063
|
+
return await this.createPage(this.params);
|
|
1064
|
+
case 'retrieve_page':
|
|
1065
|
+
return await this.retrievePage(this.params);
|
|
1066
|
+
case 'update_page':
|
|
1067
|
+
return await this.updatePage(this.params);
|
|
1068
|
+
case 'retrieve_database':
|
|
1069
|
+
return await this.retrieveDatabase(this.params);
|
|
1070
|
+
case 'query_data_source':
|
|
1071
|
+
return await this.queryDataSource(this.params);
|
|
1072
|
+
case 'create_data_source':
|
|
1073
|
+
return await this.createDataSource(this.params);
|
|
1074
|
+
case 'update_data_source':
|
|
1075
|
+
return await this.updateDataSource(this.params);
|
|
1076
|
+
case 'create_database':
|
|
1077
|
+
return await this.createDatabase(this.params);
|
|
1078
|
+
case 'update_database':
|
|
1079
|
+
return await this.updateDatabase(this.params);
|
|
1080
|
+
case 'append_block_children':
|
|
1081
|
+
return await this.appendBlockChildren(this.params);
|
|
1082
|
+
case 'retrieve_block_children':
|
|
1083
|
+
return await this.retrieveBlockChildren(this.params);
|
|
1084
|
+
case 'retrieve_block':
|
|
1085
|
+
return await this.retrieveBlock(this.params);
|
|
1086
|
+
case 'update_block':
|
|
1087
|
+
return await this.updateBlock(this.params);
|
|
1088
|
+
case 'create_comment':
|
|
1089
|
+
return await this.createComment(this.params);
|
|
1090
|
+
case 'retrieve_comment':
|
|
1091
|
+
return await this.retrieveComment(this.params);
|
|
1092
|
+
case 'list_users':
|
|
1093
|
+
return await this.listUsers(this.params);
|
|
1094
|
+
case 'search':
|
|
1095
|
+
return await this.search(this.params);
|
|
1096
|
+
default:
|
|
1097
|
+
throw new Error(`Unsupported operation: ${operation}`);
|
|
1098
|
+
}
|
|
1099
|
+
})();
|
|
1100
|
+
return result;
|
|
1101
|
+
}
|
|
1102
|
+
catch (error) {
|
|
1103
|
+
const failedOperation = this.params.operation;
|
|
1104
|
+
const errorMessage = error instanceof Error
|
|
1105
|
+
? error.message
|
|
1106
|
+
: 'Unknown error occurred in NotionBubble';
|
|
1107
|
+
// Return error result with proper structure for each operation type
|
|
1108
|
+
return {
|
|
1109
|
+
operation: failedOperation,
|
|
1110
|
+
success: false,
|
|
1111
|
+
error: errorMessage,
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
async createPage(params) {
|
|
1116
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1117
|
+
const { parent, properties, children, icon, cover } = parsed;
|
|
1118
|
+
const body = {
|
|
1119
|
+
parent,
|
|
1120
|
+
};
|
|
1121
|
+
if (properties)
|
|
1122
|
+
body.properties = properties;
|
|
1123
|
+
if (children)
|
|
1124
|
+
body.children = children;
|
|
1125
|
+
if (icon)
|
|
1126
|
+
body.icon = icon;
|
|
1127
|
+
if (cover)
|
|
1128
|
+
body.cover = cover;
|
|
1129
|
+
const page = await this.makeNotionApiCall('pages', body, 'POST');
|
|
1130
|
+
return {
|
|
1131
|
+
operation: 'create_page',
|
|
1132
|
+
success: true,
|
|
1133
|
+
error: '',
|
|
1134
|
+
page,
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
async retrievePage(params) {
|
|
1138
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1139
|
+
const { page_id, filter_properties } = parsed;
|
|
1140
|
+
let url = `pages/${page_id}`;
|
|
1141
|
+
if (filter_properties && filter_properties.length > 0) {
|
|
1142
|
+
const params = new URLSearchParams();
|
|
1143
|
+
filter_properties.forEach((prop) => {
|
|
1144
|
+
params.append('filter_properties', prop);
|
|
1145
|
+
});
|
|
1146
|
+
url += `?${params.toString()}`;
|
|
1147
|
+
}
|
|
1148
|
+
const page = await this.makeNotionApiCall(url, {}, 'GET');
|
|
1149
|
+
return {
|
|
1150
|
+
operation: 'retrieve_page',
|
|
1151
|
+
success: true,
|
|
1152
|
+
error: '',
|
|
1153
|
+
page,
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
async updatePage(params) {
|
|
1157
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1158
|
+
const { page_id, properties, icon, cover, archived, in_trash, is_locked } = parsed;
|
|
1159
|
+
const body = {};
|
|
1160
|
+
if (properties)
|
|
1161
|
+
body.properties = properties;
|
|
1162
|
+
if (icon !== undefined)
|
|
1163
|
+
body.icon = icon;
|
|
1164
|
+
if (cover !== undefined)
|
|
1165
|
+
body.cover = cover;
|
|
1166
|
+
if (archived !== undefined)
|
|
1167
|
+
body.archived = archived;
|
|
1168
|
+
if (in_trash !== undefined)
|
|
1169
|
+
body.in_trash = in_trash;
|
|
1170
|
+
if (is_locked !== undefined)
|
|
1171
|
+
body.is_locked = is_locked;
|
|
1172
|
+
const page = await this.makeNotionApiCall(`pages/${page_id}`, body, 'PATCH');
|
|
1173
|
+
return {
|
|
1174
|
+
operation: 'update_page',
|
|
1175
|
+
success: true,
|
|
1176
|
+
error: '',
|
|
1177
|
+
page,
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
async retrieveDatabase(params) {
|
|
1181
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1182
|
+
const { database_id } = parsed;
|
|
1183
|
+
const database = await this.makeNotionApiCall(`databases/${database_id}`, {}, 'GET');
|
|
1184
|
+
return {
|
|
1185
|
+
operation: 'retrieve_database',
|
|
1186
|
+
success: true,
|
|
1187
|
+
error: '',
|
|
1188
|
+
database,
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
async queryDataSource(params) {
|
|
1192
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1193
|
+
const { data_source_id, filter, sorts, start_cursor, page_size, filter_properties, result_type, } = parsed;
|
|
1194
|
+
const body = {};
|
|
1195
|
+
if (filter)
|
|
1196
|
+
body.filter = filter;
|
|
1197
|
+
if (sorts)
|
|
1198
|
+
body.sorts = sorts;
|
|
1199
|
+
if (start_cursor)
|
|
1200
|
+
body.start_cursor = start_cursor;
|
|
1201
|
+
if (page_size !== undefined)
|
|
1202
|
+
body.page_size = page_size;
|
|
1203
|
+
if (result_type)
|
|
1204
|
+
body.result_type = result_type;
|
|
1205
|
+
let url = `data_sources/${data_source_id}/query`;
|
|
1206
|
+
if (filter_properties && filter_properties.length > 0) {
|
|
1207
|
+
const params = new URLSearchParams();
|
|
1208
|
+
filter_properties.forEach((prop) => {
|
|
1209
|
+
params.append('filter_properties', prop);
|
|
1210
|
+
});
|
|
1211
|
+
url += `?${params.toString()}`;
|
|
1212
|
+
}
|
|
1213
|
+
const response = await this.makeNotionApiCall(url, body, 'POST');
|
|
1214
|
+
return {
|
|
1215
|
+
operation: 'query_data_source',
|
|
1216
|
+
success: true,
|
|
1217
|
+
error: '',
|
|
1218
|
+
results: response.results,
|
|
1219
|
+
next_cursor: response.next_cursor,
|
|
1220
|
+
has_more: response.has_more,
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
async updateDataSource(params) {
|
|
1224
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1225
|
+
const { data_source_id, properties, title, description, icon, in_trash, parent, } = parsed;
|
|
1226
|
+
const body = {};
|
|
1227
|
+
if (properties)
|
|
1228
|
+
body.properties = properties;
|
|
1229
|
+
if (title)
|
|
1230
|
+
body.title = title;
|
|
1231
|
+
if (description)
|
|
1232
|
+
body.description = description;
|
|
1233
|
+
if (icon !== undefined)
|
|
1234
|
+
body.icon = icon;
|
|
1235
|
+
if (in_trash !== undefined)
|
|
1236
|
+
body.in_trash = in_trash;
|
|
1237
|
+
if (parent)
|
|
1238
|
+
body.parent = parent;
|
|
1239
|
+
const dataSource = await this.makeNotionApiCall(`data_sources/${data_source_id}`, body, 'PATCH');
|
|
1240
|
+
return {
|
|
1241
|
+
operation: 'update_data_source',
|
|
1242
|
+
success: true,
|
|
1243
|
+
error: '',
|
|
1244
|
+
dataSource,
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
async createDataSource(params) {
|
|
1248
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1249
|
+
const { parent, properties, title, icon } = parsed;
|
|
1250
|
+
const body = {
|
|
1251
|
+
parent,
|
|
1252
|
+
properties,
|
|
1253
|
+
};
|
|
1254
|
+
if (title)
|
|
1255
|
+
body.title = title;
|
|
1256
|
+
if (icon)
|
|
1257
|
+
body.icon = icon;
|
|
1258
|
+
const dataSource = await this.makeNotionApiCall('data_sources', body, 'POST');
|
|
1259
|
+
return {
|
|
1260
|
+
operation: 'create_data_source',
|
|
1261
|
+
success: true,
|
|
1262
|
+
error: '',
|
|
1263
|
+
dataSource,
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
async createDatabase(params) {
|
|
1267
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1268
|
+
const { parent, initial_data_source, title, description, icon, cover } = parsed;
|
|
1269
|
+
// Ensure workspace parent has workspace: true
|
|
1270
|
+
const normalizedParent = parent.type === 'workspace'
|
|
1271
|
+
? { type: 'workspace', workspace: true }
|
|
1272
|
+
: parent;
|
|
1273
|
+
const body = {
|
|
1274
|
+
parent: normalizedParent,
|
|
1275
|
+
initial_data_source,
|
|
1276
|
+
};
|
|
1277
|
+
if (title)
|
|
1278
|
+
body.title = title;
|
|
1279
|
+
if (description)
|
|
1280
|
+
body.description = description;
|
|
1281
|
+
if (icon)
|
|
1282
|
+
body.icon = icon;
|
|
1283
|
+
if (cover)
|
|
1284
|
+
body.cover = cover;
|
|
1285
|
+
const database = await this.makeNotionApiCall('databases', body, 'POST');
|
|
1286
|
+
return {
|
|
1287
|
+
operation: 'create_database',
|
|
1288
|
+
success: true,
|
|
1289
|
+
error: '',
|
|
1290
|
+
database,
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
async updateDatabase(params) {
|
|
1294
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1295
|
+
const { database_id, title, description, icon, cover, parent, is_inline, in_trash, is_locked, } = parsed;
|
|
1296
|
+
const body = {};
|
|
1297
|
+
if (title)
|
|
1298
|
+
body.title = title;
|
|
1299
|
+
if (description)
|
|
1300
|
+
body.description = description;
|
|
1301
|
+
if (icon !== undefined)
|
|
1302
|
+
body.icon = icon;
|
|
1303
|
+
if (cover !== undefined)
|
|
1304
|
+
body.cover = cover;
|
|
1305
|
+
if (parent)
|
|
1306
|
+
body.parent = parent;
|
|
1307
|
+
if (is_inline !== undefined)
|
|
1308
|
+
body.is_inline = is_inline;
|
|
1309
|
+
if (in_trash !== undefined)
|
|
1310
|
+
body.in_trash = in_trash;
|
|
1311
|
+
if (is_locked !== undefined)
|
|
1312
|
+
body.is_locked = is_locked;
|
|
1313
|
+
const database = await this.makeNotionApiCall(`databases/${database_id}`, body, 'PATCH');
|
|
1314
|
+
return {
|
|
1315
|
+
operation: 'update_database',
|
|
1316
|
+
success: true,
|
|
1317
|
+
error: '',
|
|
1318
|
+
database,
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
async appendBlockChildren(params) {
|
|
1322
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1323
|
+
const { block_id, children, after } = parsed;
|
|
1324
|
+
const body = {
|
|
1325
|
+
children,
|
|
1326
|
+
};
|
|
1327
|
+
if (after)
|
|
1328
|
+
body.after = after;
|
|
1329
|
+
const response = await this.makeNotionApiCall(`blocks/${block_id}/children`, body, 'PATCH');
|
|
1330
|
+
return {
|
|
1331
|
+
operation: 'append_block_children',
|
|
1332
|
+
success: true,
|
|
1333
|
+
error: '',
|
|
1334
|
+
blocks: response.results,
|
|
1335
|
+
next_cursor: response.next_cursor,
|
|
1336
|
+
has_more: response.has_more,
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
async retrieveBlockChildren(params) {
|
|
1340
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1341
|
+
const { block_id, start_cursor, page_size } = parsed;
|
|
1342
|
+
let url = `blocks/${block_id}/children`;
|
|
1343
|
+
const params_obj = new URLSearchParams();
|
|
1344
|
+
if (start_cursor)
|
|
1345
|
+
params_obj.append('start_cursor', start_cursor);
|
|
1346
|
+
if (page_size !== undefined)
|
|
1347
|
+
params_obj.append('page_size', page_size.toString());
|
|
1348
|
+
if (params_obj.toString())
|
|
1349
|
+
url += `?${params_obj.toString()}`;
|
|
1350
|
+
const response = await this.makeNotionApiCall(url, {}, 'GET');
|
|
1351
|
+
return {
|
|
1352
|
+
operation: 'retrieve_block_children',
|
|
1353
|
+
success: true,
|
|
1354
|
+
error: '',
|
|
1355
|
+
blocks: response.results,
|
|
1356
|
+
next_cursor: response.next_cursor,
|
|
1357
|
+
has_more: response.has_more,
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
async retrieveBlock(params) {
|
|
1361
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1362
|
+
const { block_id } = parsed;
|
|
1363
|
+
const block = await this.makeNotionApiCall(`blocks/${block_id}`, {}, 'GET');
|
|
1364
|
+
return {
|
|
1365
|
+
operation: 'retrieve_block',
|
|
1366
|
+
success: true,
|
|
1367
|
+
error: '',
|
|
1368
|
+
block,
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
async updateBlock(params) {
|
|
1372
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1373
|
+
const { block_id, archived } = parsed;
|
|
1374
|
+
const body = {};
|
|
1375
|
+
if (archived !== undefined)
|
|
1376
|
+
body.archived = archived;
|
|
1377
|
+
// Note: Block-specific updates (like heading_2, paragraph, etc.) would need
|
|
1378
|
+
// to be passed through params and added to body here
|
|
1379
|
+
// For now, we support archiving
|
|
1380
|
+
const block = await this.makeNotionApiCall(`blocks/${block_id}`, body, 'PATCH');
|
|
1381
|
+
return {
|
|
1382
|
+
operation: 'update_block',
|
|
1383
|
+
success: true,
|
|
1384
|
+
error: '',
|
|
1385
|
+
block,
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
async createComment(params) {
|
|
1389
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1390
|
+
const { parent, rich_text, attachments, display_name } = parsed;
|
|
1391
|
+
const body = {
|
|
1392
|
+
parent,
|
|
1393
|
+
rich_text,
|
|
1394
|
+
};
|
|
1395
|
+
if (attachments)
|
|
1396
|
+
body.attachments = attachments;
|
|
1397
|
+
if (display_name)
|
|
1398
|
+
body.display_name = display_name;
|
|
1399
|
+
const comment = await this.makeNotionApiCall('comments', body, 'POST');
|
|
1400
|
+
return {
|
|
1401
|
+
operation: 'create_comment',
|
|
1402
|
+
success: true,
|
|
1403
|
+
error: '',
|
|
1404
|
+
comment,
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
async retrieveComment(params) {
|
|
1408
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1409
|
+
const { comment_id } = parsed;
|
|
1410
|
+
const comment = await this.makeNotionApiCall(`comments/${comment_id}`, {}, 'GET');
|
|
1411
|
+
return {
|
|
1412
|
+
operation: 'retrieve_comment',
|
|
1413
|
+
success: true,
|
|
1414
|
+
error: '',
|
|
1415
|
+
comment,
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
async listUsers(params) {
|
|
1419
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1420
|
+
const { start_cursor, page_size } = parsed;
|
|
1421
|
+
let url = 'users';
|
|
1422
|
+
const params_obj = new URLSearchParams();
|
|
1423
|
+
if (start_cursor)
|
|
1424
|
+
params_obj.append('start_cursor', start_cursor);
|
|
1425
|
+
if (page_size !== undefined)
|
|
1426
|
+
params_obj.append('page_size', page_size.toString());
|
|
1427
|
+
if (params_obj.toString())
|
|
1428
|
+
url += `?${params_obj.toString()}`;
|
|
1429
|
+
const response = await this.makeNotionApiCall(url, {}, 'GET');
|
|
1430
|
+
return {
|
|
1431
|
+
operation: 'list_users',
|
|
1432
|
+
success: true,
|
|
1433
|
+
error: '',
|
|
1434
|
+
users: response.results,
|
|
1435
|
+
next_cursor: response.next_cursor,
|
|
1436
|
+
has_more: response.has_more,
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
async search(params) {
|
|
1440
|
+
const parsed = NotionParamsSchema.parse(params);
|
|
1441
|
+
const { query, sort, filter, start_cursor, page_size } = parsed;
|
|
1442
|
+
const body = {};
|
|
1443
|
+
if (query)
|
|
1444
|
+
body.query = query;
|
|
1445
|
+
if (sort)
|
|
1446
|
+
body.sort = sort;
|
|
1447
|
+
if (filter)
|
|
1448
|
+
body.filter = filter;
|
|
1449
|
+
if (start_cursor)
|
|
1450
|
+
body.start_cursor = start_cursor;
|
|
1451
|
+
if (page_size !== undefined)
|
|
1452
|
+
body.page_size = page_size;
|
|
1453
|
+
const response = await this.makeNotionApiCall('search', body, 'POST');
|
|
1454
|
+
return {
|
|
1455
|
+
operation: 'search',
|
|
1456
|
+
success: true,
|
|
1457
|
+
error: '',
|
|
1458
|
+
results: response.results,
|
|
1459
|
+
next_cursor: response.next_cursor,
|
|
1460
|
+
has_more: response.has_more,
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
async makeNotionApiCall(endpoint, body, method = 'GET') {
|
|
1464
|
+
const url = `${NOTION_API_BASE}/${endpoint}`;
|
|
1465
|
+
const token = this.chooseCredential();
|
|
1466
|
+
if (!token) {
|
|
1467
|
+
throw new Error('Notion OAuth token is required but was not provided');
|
|
1468
|
+
}
|
|
1469
|
+
const headers = {
|
|
1470
|
+
Authorization: `Bearer ${token}`,
|
|
1471
|
+
'Notion-Version': NOTION_API_VERSION,
|
|
1472
|
+
'Content-Type': 'application/json',
|
|
1473
|
+
};
|
|
1474
|
+
const requestOptions = {
|
|
1475
|
+
method,
|
|
1476
|
+
headers,
|
|
1477
|
+
};
|
|
1478
|
+
if (method !== 'GET' && Object.keys(body).length > 0) {
|
|
1479
|
+
requestOptions.body = JSON.stringify(body);
|
|
1480
|
+
}
|
|
1481
|
+
const response = await fetch(url, requestOptions);
|
|
1482
|
+
const data = (await response.json());
|
|
1483
|
+
if (!response.ok) {
|
|
1484
|
+
// Throw error with Notion error response
|
|
1485
|
+
throw new Error(typeof data === 'object' && data !== null && 'message' in data
|
|
1486
|
+
? String(data.message)
|
|
1487
|
+
: `Notion API error: ${response.status} ${response.statusText}`);
|
|
1488
|
+
}
|
|
1489
|
+
return data;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
//# sourceMappingURL=notion.js.map
|