d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
119 lines
3.0 KiB
TypeScript
119 lines
3.0 KiB
TypeScript
import type { NotionAddDatabaseRowParams } from '@/tools/notion/types'
|
|
import { PAGE_OUTPUT_PROPERTIES } from '@/tools/notion/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
interface NotionAddDatabaseRowResponse {
|
|
success: boolean
|
|
output: {
|
|
id: string
|
|
url: string
|
|
title: string
|
|
created_time: string
|
|
last_edited_time: string
|
|
}
|
|
}
|
|
|
|
export const notionAddDatabaseRowTool: ToolConfig<
|
|
NotionAddDatabaseRowParams,
|
|
NotionAddDatabaseRowResponse
|
|
> = {
|
|
id: 'notion_add_database_row',
|
|
name: 'Add Notion Database Row',
|
|
description: 'Add a new row to a Notion database with specified properties',
|
|
version: '1.0.0',
|
|
|
|
oauth: {
|
|
required: true,
|
|
provider: 'notion',
|
|
},
|
|
|
|
params: {
|
|
accessToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'hidden',
|
|
description: 'Notion OAuth access token',
|
|
},
|
|
databaseId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'ID of the database to add the row to',
|
|
},
|
|
properties: {
|
|
type: 'json',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Row properties as JSON object matching the database schema (e.g., {"Name": {"title": [{"text": {"content": "Task 1"}}]}, "Status": {"select": {"name": "Done"}}})',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: () => 'https://api.notion.com/v1/pages',
|
|
method: 'POST',
|
|
headers: (params: NotionAddDatabaseRowParams) => {
|
|
if (!params.accessToken) {
|
|
throw new Error('Access token is required')
|
|
}
|
|
|
|
return {
|
|
Authorization: `Bearer ${params.accessToken}`,
|
|
'Notion-Version': '2022-06-28',
|
|
'Content-Type': 'application/json',
|
|
}
|
|
},
|
|
body: (params: NotionAddDatabaseRowParams) => {
|
|
return {
|
|
parent: {
|
|
type: 'database_id',
|
|
database_id: params.databaseId.trim(),
|
|
},
|
|
properties: params.properties,
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
// Extract title from properties if available
|
|
let rowTitle = 'Untitled'
|
|
for (const [, value] of Object.entries(data.properties || {})) {
|
|
const prop = value as any
|
|
if (prop.type === 'title' && prop.title?.length > 0) {
|
|
rowTitle = prop.title.map((t: any) => t.plain_text || '').join('')
|
|
break
|
|
}
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
id: data.id,
|
|
url: data.url,
|
|
title: rowTitle,
|
|
created_time: data.created_time,
|
|
last_edited_time: data.last_edited_time,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
id: PAGE_OUTPUT_PROPERTIES.id,
|
|
url: PAGE_OUTPUT_PROPERTIES.url,
|
|
title: { type: 'string', description: 'Row title' },
|
|
created_time: PAGE_OUTPUT_PROPERTIES.created_time,
|
|
last_edited_time: PAGE_OUTPUT_PROPERTIES.last_edited_time,
|
|
},
|
|
}
|
|
|
|
export const notionAddDatabaseRowV2Tool: ToolConfig<
|
|
NotionAddDatabaseRowParams,
|
|
NotionAddDatabaseRowResponse
|
|
> = {
|
|
...notionAddDatabaseRowTool,
|
|
id: 'notion_add_database_row_v2',
|
|
version: '2.0.0',
|
|
}
|