chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:34:48 +08:00
commit 77bb5bf71f
3762 changed files with 353249 additions and 0 deletions
@@ -0,0 +1,26 @@
import { createActionWrapper } from '@botpress/common'
import { TodoistClient, wrapAsyncFnWithTryCatch } from '../todoist-api'
import * as bp from '.botpress'
export const wrapAction: typeof _wrapAction = (meta, actionImpl) =>
_wrapAction(meta, (props) =>
// NOTE: the TodoistClient class already has error handling with error
// redaction, so this try-catch wrapper will only ever be called
// if there's an error in the action implementation itself
wrapAsyncFnWithTryCatch(() => {
props.logger
.forBot()
.debug(`Running action "${meta.actionName}" [bot id: ${props.ctx.botId}]`, { input: props.input })
return actionImpl(props as Parameters<typeof actionImpl>[0], props.input)
}, `Action Error: ${meta.errorMessageWhenFailed}`)()
)
const _wrapAction = createActionWrapper<bp.IntegrationProps>()({
toolFactories: {
todoistClient: TodoistClient.create,
},
extraMetadata: {} as {
errorMessageWhenFailed: string
},
})
@@ -0,0 +1,6 @@
import { wrapAction } from '../action-wrapper'
export const changeTaskPriority = wrapAction(
{ actionName: 'changeTaskPriority', errorMessageWhenFailed: 'Failed to change task priority' },
async ({ todoistClient }, { taskId, priority }) => await todoistClient.updateTask({ task: { id: taskId, priority } })
)
@@ -0,0 +1,10 @@
import { wrapAction } from '../action-wrapper'
export const createNewTask = wrapAction(
{ actionName: 'createNewTask', errorMessageWhenFailed: 'Failed to create task' },
async ({ todoistClient }, task) => {
const newTask = await todoistClient.createNewTask({ task })
return { taskId: newTask.id }
}
)
@@ -0,0 +1,6 @@
import { wrapAction } from '../action-wrapper'
export const getAllProjects = wrapAction(
{ actionName: 'getAllProjects', errorMessageWhenFailed: 'Failed to retrieve projects' },
async ({ todoistClient }) => ({ projects: await todoistClient.getAllProjects() })
)
@@ -0,0 +1,6 @@
import { wrapAction } from '../action-wrapper'
export const getAllSections = wrapAction(
{ actionName: 'getAllSections', errorMessageWhenFailed: 'Failed to retrieve sections' },
async ({ todoistClient }, { projectId }) => ({ sections: await todoistClient.getAllSections({ projectId }) })
)
@@ -0,0 +1,8 @@
import { wrapAction } from '../action-wrapper'
export const getAllTasks = wrapAction(
{ actionName: 'getAllTasks', errorMessageWhenFailed: 'Failed to retrieve tasks' },
async ({ todoistClient }, { projectId, labelName, sectionId }) => ({
tasks: await todoistClient.getAllTasks({ projectId, labelName, sectionId }),
})
)
@@ -0,0 +1,10 @@
import { wrapAction } from '../action-wrapper'
export const getProjectId = wrapAction(
{ actionName: 'getProjectId', errorMessageWhenFailed: 'Failed to retrieve project id' },
async ({ todoistClient }, { name }) => {
const project = await todoistClient.getProjectByName({ name })
return { projectId: project?.id ?? null }
}
)
@@ -0,0 +1,10 @@
import { wrapAction } from '../action-wrapper'
export const getTaskId = wrapAction(
{ actionName: 'getTaskId', errorMessageWhenFailed: 'Failed to retrieve task id' },
async ({ todoistClient }, { name }) => {
const task = await todoistClient.getTaskByName({ name })
return { taskId: task?.id ?? null }
}
)
+19
View File
@@ -0,0 +1,19 @@
import { changeTaskPriority } from './implementations/change-task-priority'
import { createNewTask } from './implementations/create-new-task'
import { getAllProjects } from './implementations/get-all-projects'
import { getAllSections } from './implementations/get-all-sections'
import { getAllTasks } from './implementations/get-all-tasks'
import { getProjectId } from './implementations/get-project-id'
import { getTaskId } from './implementations/get-task-id'
import * as bp from '.botpress'
export const actions = {
changeTaskPriority,
getProjectId,
getTaskId,
createNewTask,
getAllProjects,
getAllSections,
getAllTasks,
} as const satisfies bp.IntegrationProps['actions']