-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.json
59 lines (59 loc) · 5.35 KB
/
plugin.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
"uuid": "1aeb711d-7fa2-46e6-8dfd-9d6dbce372ea",
"id": "view_notion_db_structure",
"emoji": "🧩",
"title": "Notion Database Structure Viewer",
"overviewMarkdown": "# **Notion Database Structure Viewer**\nThis plugin allows users to get database structure of a Notion database.\n\n### 📝 **User Setting Notes:**\n#### 🔧 **Set Up the Plugin Server:**\n- A plugin server must be set up to use this feature. Follow the detailed guide to set up a plugin server on Render: [How to Deploy the Plugin Server on Render](https://docs.typingmind.com/plugins/plugins-server/how-to-deploy-plugins-server-on-render)\n\n#### 🔑 **Set Up Your Notion API Key:**\n- Go to the [Notion Integration Page](https://www.notion.so/profile/integrations) and create a new integration.\n- Copy the key from the Integration Detail Page.\n- Paste the key into the plugin's user settings:\n **Notion API Key:** `ntn_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`\n\nFor detailed instructions, visit the [Notion Integration API Documentation](https://developers.notion.com/docs/create-a-notion-integration)\n\n#### 🔗 **Share Your Database with the Integration:**\n- Open your database in Notion.\n- Click the **“Share”** button in the top right.\n- Select **“Invite”**, search for your integration name, and click **“Invite”** to grant access.\n\nFor detailed instructions, visit the [Notion API Connections Documentation](https://www.notion.com/help/add-and-manage-connections-with-the-api)\n\n### 📌 **Important Notes:**\n\n#### 👉 **Rate Limits:**\n- There are rate limits for Notion API requests. Learn more at [Notion API Rate Limits](https://developers.notion.com/reference/request-limits#rate-limits).\n\n### 💡 **Example Usage** \n> Could you provide the structure of the Employee Directory database from this Notion Database URL: https://www.notion.so/12345bcxyz?v=11111aaaaaa",
"openaiSpec": {
"name": "view_notion_db_structure",
"description": "Retrieves the structure of a Notion Database by using the Notion API.",
"parameters": {
"type": "object",
"properties": {
"databaseId": {
"type": "string",
"description": "The ID or URL of the Notion database being viewed. For example, in the URL https://www.notion.so/{DATABASE_ID}?v={VIEW_ID}, the database ID is the string before ?v=, which is {DATABASE_ID}."
}
},
"required": [
"databaseId"
]
}
},
"userSettings": [
{
"name": "pluginServer",
"label": "Plugin Server",
"required": true,
"description": "The URL of the plugin server. For more details, refer to the documentation: https://docs.typingmind.com/plugins/plugins-server",
"placeholder": "https://...."
},
{
"name": "notionApiKey",
"label": "Notion API Key",
"description": "Enter your Notion Secret Key. You can create an integration from Notion at https://www.notion.so/profile/integrations",
"required": true
}
],
"code": "// Helper to fetch the database structure\nasync function fetchDatabaseStructure(databaseId, apiKey) {\n // Headers for Notion API requests\n const headers = {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"Notion-Version\": \"2022-06-28\", // or the version you are using\n };\n try {\n const response = await fetch(\n `https://api.notion.com/v1/databases/${databaseId}`,\n {\n method: \"GET\",\n headers: headers,\n }\n );\n\n if (!response.ok) {\n throw new Error(\n `Error fetching database structure: ${response.statusText}`\n );\n }\n\n const data = await response.json();\n console.log(JSON.stringify(data));\n return data;\n } catch (error) {\n throw new Error(`Failed to fetch database structure: ${error.message}`);\n }\n}\n\nasync function get_notion_db_structure(params, userSettings) {\n const { databaseId } = params;\n const { notionSecretKey } = userSettings;\n\n if (!notionSecretKey) {\n throw new Error(\n \"Missing the Notion API Key. Please set it in the plugin settings.\"\n );\n }\n\n if (!databaseId) {\n throw new Error(\n \"Missing the Database Id. Please set it in the plugin settings.\"\n );\n }\n\n try {\n const result = await fetchDatabaseStructure(databaseId,notionSecretKey);\n return result;\n } catch (error) {\n console.error(\"Error:\", error.message); \n }\n}",
"iconURL": "https://registry.npmmirror.com/@lobehub/icons-static-png/latest/files/light/notion.png",
"authenticationType": "AUTH_TYPE_NONE",
"implementationType": "http",
"httpAction": {
"id": "727fa0bc-4633-4e0d-99fc-38d975493d96",
"name": "",
"url": "{pluginServer}/notion-database/view-structure",
"method": "POST",
"hasHeaders": true,
"requestHeaders": "{\n \"Content-Type\": \"application/json\"\n}",
"hasResultTransform": false,
"resultTransform": {
"engine": "jmes",
"expression": ""
},
"hasBody": true,
"requestBody": "{\n \"notionApiKey\": \"{notionApiKey}\",\n \"databaseId\": \"{databaseId}\"\n}"
},
"oauthConfig": null,
"outputType": "respond_to_ai"
}