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,49 @@
import { ActionDefinition, z } from '@botpress/sdk'
import { boardSchema } from 'definitions/schemas'
import { hasBoardId, noInput } from './common'
export const getBoardById = {
title: 'Get board by ID',
description: 'Get a board by its unique identifier',
input: {
schema: hasBoardId.describe('Input schema for getting a board from its ID'),
},
output: {
schema: z.object({
board: boardSchema.title('Trello Board').describe('The details of the Trello board associated with the given ID'),
}),
},
} as const satisfies ActionDefinition
export const getBoardsByDisplayName = {
title: 'Get boards by name',
description: 'Find all boards whose display name match this name',
input: {
schema: z
.object({
boardName: boardSchema.shape.name.title('Board Name').describe('Display name of the board'),
})
.describe('Input schema for getting a board ID from its name'),
},
output: {
schema: z.object({
boards: z
.array(boardSchema)
.title('Trello Boards')
.describe('A list of boards that match the given display name'),
}),
},
} as const satisfies ActionDefinition
export const getAllBoards = {
title: 'Get all boards',
description: 'Get all boards managed by the authenticated user',
input: {
schema: noInput.describe('Input schema for getting all boards'),
},
output: {
schema: z.object({
boards: z.array(boardSchema).title('Trello Boards').describe('A list of Trello boards'),
}),
},
} as const satisfies ActionDefinition
@@ -0,0 +1,282 @@
import { ActionDefinition, z } from '@botpress/sdk'
import { cardSchema, listSchema, trelloIdSchema } from 'definitions/schemas'
import { hasCardId, hasListId, hasMessage } from './common'
export const getCardById = {
title: 'Get card by ID',
description: 'Get a card by its unique identifier',
input: {
schema: hasCardId.describe('Input schema for getting a card from its ID'),
},
output: {
schema: z.object({
card: cardSchema.title('Trello Card').describe("The Trello card that's associated with the given card ID"),
}),
},
} as const satisfies ActionDefinition
export const getCardsByDisplayName = {
title: 'Find cards by name',
description: 'Find all cards whose display name match this name',
input: {
schema: hasListId
.extend({
cardName: cardSchema.shape.name.title('Card Name').describe('Display name of the card'),
})
.describe('Input schema for getting a card ID from its name'),
},
output: {
schema: z.object({
cards: z.array(cardSchema).title('Trello Cards').describe('A list of cards that match the given card name'),
}),
},
} as const satisfies ActionDefinition
export const getCardsInList = {
title: 'Get cards in list',
description: 'Get all cards in a list',
input: {
schema: hasListId.describe('Input schema for getting all cards in a list'),
},
output: {
schema: z.object({
cards: z
.array(cardSchema)
.title('Trello Cards')
.describe('An array of cards that are contained within the given list'),
}),
},
} as const satisfies ActionDefinition
export const createCard = {
title: 'Create new card',
description: 'Create a card and add it to a list',
input: {
schema: z
.object({
listId: listSchema.shape.id.title('List ID').describe('ID of the list in which to insert the new card'),
cardName: cardSchema.shape.name.title('Card Name').describe('Name of the new card'),
cardBody: cardSchema.shape.description.optional().title('Card Body').describe('The body text of the new card'),
memberIds: z
.array(trelloIdSchema)
.optional()
.title('Member IDs')
.describe('Members to add to the card (Optional). This should be a list of member IDs.'),
labelIds: z
.array(trelloIdSchema)
.optional()
.title('Label IDs')
.describe('Labels to add to the card (Optional). This should be a list of label IDs.'),
dueDate: cardSchema.shape.dueDate
.optional()
.title('Due Date')
.describe('The due date of the card in ISO 8601 format (Optional).'),
completionStatus: z
.enum(['Complete', 'Incomplete'])
.default('Incomplete')
.title('Completion Status')
.describe(
'Whether the card should be marked as complete (Optional). Enter "Complete" or "Incomplete" (without quotes).'
),
})
.describe('Input schema for creating a new card'),
},
output: {
schema: z
.object({
message: hasMessage.shape.message
.title('Action message')
.describe('A message that says if the card was successfully created or not'),
newCardId: cardSchema.shape.id.describe('Unique identifier of the new card'),
})
.describe('Output schema for creating a card'),
},
} as const satisfies ActionDefinition
export const updateCard = {
title: 'Update card',
description: 'Update the details of a card',
input: {
schema: hasCardId
.extend({
cardName: cardSchema.shape.name
.optional()
.title('Card Name')
.describe('The name of the card (Optional) (e.g. "My Test Card"). Leave empty to keep the current name.'),
cardBody: cardSchema.shape.description
.optional()
.title('Card Body')
.describe('The new body text of the card (Optional). Leave empty to keep the current body.'),
lifecycleStatus: z
.enum(['Open', 'Archived'])
.optional()
.title('Lifecycle Status')
.describe(
'Whether the card should be archived (Optional). Enter "Open", "Archived" (without quotes), or leave empty to keep the previous status.'
),
completionStatus: z
.enum(['Complete', 'Incomplete'])
.optional()
.title('Completion Status')
.describe(
'Whether the card should be marked as complete (Optional). Enter "Complete", "Incomplete" (without quotes), or leave empty to keep the previous status.'
),
memberIdsToAdd: z
.array(trelloIdSchema)
.optional()
.title('Member IDs to Add')
.describe(
'Members to add to the card (Optional). This should be a list of member IDs. Leave empty to keep the current members.'
),
memberIdsToRemove: z
.array(trelloIdSchema)
.optional()
.title('Member IDs to Remove')
.describe(
'Members to remove from the card (Optional). This should be a list of member IDs. Leave empty to keep the current members.'
),
labelIdsToAdd: z
.array(trelloIdSchema)
.optional()
.title('Label IDs to Add')
.describe(
'Labels to add to the card (Optional). This should be a list of label IDs. Leave empty to keep the current labels.'
),
labelIdsToRemove: z
.array(trelloIdSchema)
.optional()
.title('Label IDs to Remove')
.describe(
'Labels to remove from the card (Optional). This should be a list of label IDs. Leave empty to keep the current labels.'
),
dueDate: cardSchema.shape.dueDate
.nullable()
.optional()
.title('Due Date')
.describe(
'The due date of the card in ISO 8601 format (Optional). Set to null to remove the due date or leave empty to keep the current due date.'
),
listId: listSchema.shape.id
.optional()
.title('List ID')
.describe('Unique identifier of the list in which the card will be moved to'),
/** Note: The validation for "verticalPosition" must be done in the action
* implementation, since studio does not support union types in inputs yet
* and the JSON schema generation does not support zod runtime validation
* like "refine" (at the time of writing, 2026-01-22). */
verticalPosition: z
.string()
.optional()
.title('Vertical Position')
.describe(
'The new position of the card in the list, either "top", "bottom", or a stringified float (Optional). Leave empty to keep the current position.'
),
})
.describe('Input schema for creating a new card'),
},
output: {
schema: hasMessage.describe('Output schema for updating a card'),
},
} as const satisfies ActionDefinition
export const deleteCard = {
title: 'Delete card',
description: 'Deletes a card by its unique identifier',
input: {
schema: z.object({
cardId: cardSchema.shape.id.title('Card ID').describe('ID of the card to delete'),
hardDelete: z
.boolean()
.default(false)
.title('Hard Delete')
.describe(
'Whether to perform a hard delete or a soft delete (archive). Set to true for hard delete, false for soft delete.'
),
}),
},
output: {
schema: z.object({}),
},
} as const satisfies ActionDefinition
export const addCardComment = {
title: 'Add card comment',
description: 'Add a new comment to a card',
input: {
schema: z
.object({
cardId: cardSchema.shape.id
.title('Card ID')
.describe('Unique identifier of the card to which a comment will be added'),
commentBody: z.string().title('Comment Body').describe('The body text of the comment'),
})
.describe('Input schema for adding a comment to a card'),
},
output: {
schema: z.object({
message: z
.string()
.title('Action message')
.describe('A message that says if the comment was successfully created or not'),
newCommentId: trelloIdSchema.title('New Comment ID').describe('Unique identifier of the newly created comment'),
}),
},
} as const satisfies ActionDefinition
const _moveByNSpacesSchema = z.number().min(1).optional().default(1)
export const moveCardUp = {
title: 'Move card up',
description: 'Move a card n spaces up',
input: {
schema: hasCardId.extend({
moveUpByNSpaces: _moveByNSpacesSchema
.title('Move Up By N Spaces')
.describe('Number of spaces by which to move the card up'),
}),
},
output: {
schema: hasMessage.describe('Output schema for moving a card up'),
},
} as const satisfies ActionDefinition
export const moveCardDown = {
title: 'Move card down',
description: 'Move a card n spaces down',
input: {
schema: hasCardId.extend({
moveDownByNSpaces: _moveByNSpacesSchema
.title('Move Down By N Spaces')
.describe('Number of spaces by which to move the card down'),
}),
},
output: {
schema: hasMessage.describe('Output schema for moving a card down'),
},
} as const satisfies ActionDefinition
export const moveCardToList = {
title: 'Move card to another list',
description: 'Move a card to another list within the same board',
input: {
schema: hasCardId.extend({
newListId: listSchema.shape.id
.title('New List ID')
.describe('Unique identifier of the list in which the card will be moved to'),
/** Note: The validation for "newVerticalPosition" must be done in the action
* implementation, since studio does not support union types in inputs yet
* and the JSON schema generation does not support zod runtime validation
* like "refine" (at the time of writing, 2026-01-22). */
newVerticalPosition: z
.string()
.optional()
.title('New Vertical Position')
.describe(
'The new position of the card in the list, either "top", "bottom", or a stringified float (Optional). Leave empty to keep the current position.'
),
}),
},
output: {
schema: hasMessage.describe('Output schema for moving a card to a list'),
},
} as const satisfies ActionDefinition
@@ -0,0 +1,22 @@
import { z } from '@botpress/sdk'
import { boardSchema, listSchema, cardSchema } from 'definitions/schemas'
// ==== Common Input Schemas ====
export const noInput = z.object({})
export const hasBoardId = z.object({
boardId: boardSchema.shape.id.title('Board ID').describe('Unique identifier of the board'),
})
export const hasListId = z.object({
listId: listSchema.shape.id.title('List ID').describe('Unique identifier of the list'),
})
export const hasCardId = z.object({
cardId: cardSchema.shape.id.title('Card ID').describe('Unique identifier of the card'),
})
// ==== Common Output Schemas ====
export const hasMessage = z.object({
message: z.string().title('Output message').describe('Output message'),
})
@@ -0,0 +1,48 @@
import { type IntegrationDefinitionProps } from '@botpress/sdk'
import { getAllBoards, getBoardById, getBoardsByDisplayName } from './board-actions'
import {
addCardComment,
createCard,
deleteCard,
getCardById,
getCardsByDisplayName,
getCardsInList,
moveCardDown,
moveCardToList,
moveCardUp,
updateCard,
} from './card-actions'
import { getListById, getListsByDisplayName, getListsInBoard } from './list-actions'
import {
getAllBoardMembers,
getAllCardMembers,
getBoardMembersByDisplayName,
getMemberByIdOrUsername,
} from './member-actions'
export const actions = {
// === Board Actions ===
getBoardById,
getBoardsByDisplayName,
getAllBoards,
// === List Actions ===
getListById,
getListsByDisplayName,
getListsInBoard,
// === Card Actions ===
getCardById,
getCardsByDisplayName,
getCardsInList,
createCard,
updateCard,
deleteCard,
addCardComment,
moveCardUp,
moveCardDown,
moveCardToList,
// === Member Actions ===
getMemberByIdOrUsername,
getBoardMembersByDisplayName,
getAllBoardMembers,
getAllCardMembers,
} as const satisfies NonNullable<IntegrationDefinitionProps['actions']>
@@ -0,0 +1,52 @@
import { ActionDefinition, z } from '@botpress/sdk'
import { listSchema } from 'definitions/schemas'
import { hasBoardId, hasListId } from './common'
export const getListById = {
title: 'Get list by ID',
description: 'Get a list by its unique identifier',
input: {
schema: hasListId.describe('Input schema for getting a list from its ID'),
},
output: {
schema: z.object({
list: listSchema.title('Trello List').describe("The Trello list that's associated with the given list ID"),
}),
},
} as const satisfies ActionDefinition
export const getListsByDisplayName = {
title: 'Get lists by name',
description: 'Find all lists whose display name match this name',
input: {
schema: hasBoardId
.extend({
listName: listSchema.shape.name.title('List Name').describe('Display name of the list'),
})
.describe('Input schema for getting a list ID from its name'),
},
output: {
schema: z.object({
lists: z
.array(listSchema)
.title('Trello Lists')
.describe('A set of lists that are associated with the given board ID and match the given display name'),
}),
},
} as const satisfies ActionDefinition
export const getListsInBoard = {
title: 'Get lists in board',
description: 'Get all lists in a board',
input: {
schema: hasBoardId.describe('Input schema for getting all lists in a board'),
},
output: {
schema: z.object({
lists: z
.array(listSchema)
.title('Trello Lists')
.describe('A set of all the lists that are associated with the given board ID'),
}),
},
} as const satisfies ActionDefinition
@@ -0,0 +1,69 @@
import { ActionDefinition, z } from '@botpress/sdk'
import { boardSchema, memberSchema } from 'definitions/schemas'
import { hasBoardId, hasCardId } from './common'
export const getMemberByIdOrUsername = {
title: 'Get member by ID or username',
description: 'Get a member by their unique identifier or username',
input: {
schema: z
.object({
memberIdOrUsername: z
.union([memberSchema.shape.id, memberSchema.shape.username])
.title('Member ID or Username')
.describe('ID or username of the member to get'),
})
.describe('Input schema for getting a member from its ID or username'),
},
output: {
schema: z.object({
member: memberSchema
.title('Trello Member')
.describe('The Trello member who is associated with the specified member ID or username'),
}),
},
} as const satisfies ActionDefinition
export const getAllCardMembers = {
title: 'Get all card members',
description: 'Get all members of a card',
input: {
schema: hasCardId.describe('Input schema for getting all members of a card'),
},
output: {
schema: z.object({
members: z
.array(memberSchema)
.title('Card Members')
.describe('A list of members who have been assigned to the card'),
}),
},
} as const satisfies ActionDefinition
export const getAllBoardMembers = {
title: 'Get all board members',
description: 'Get all members of a board',
input: {
schema: hasBoardId.describe('Input schema for getting all members of a board'),
},
output: {
schema: z.object({
members: z.array(memberSchema).title('Board Members').describe('A list of members who have access to the board'),
}),
},
} as const satisfies ActionDefinition
export const getBoardMembersByDisplayName = {
title: 'Get members by name',
description: 'Find all members whose display name match this name',
input: {
schema: hasBoardId.extend({
displayName: boardSchema.shape.name.title('Display Name').describe('Display name of the member'),
}),
},
output: {
schema: z.object({
members: z.array(memberSchema).title('Board Members').describe('A list of members that match the specified name'),
}),
},
} as const satisfies ActionDefinition
@@ -0,0 +1,43 @@
import { IntegrationDefinitionProps, messages } from '@botpress/sdk'
export const channels = {
cardComments: {
title: 'Card Comments',
description: 'Channel for managing comments on Trello cards',
messages: {
text: messages.defaults.text,
},
message: {
tags: {
commentId: {
title: 'Comment ID',
description: 'unique identifier of the comment',
},
},
},
conversation: {
tags: {
cardId: {
title: 'Card ID',
description: 'unique identifier of the card',
},
cardName: {
title: 'Card name',
description: 'display name of the card',
},
listId: {
title: 'List ID',
description: 'unique identifier of the list',
},
listName: {
title: 'Card ID',
description: 'display name of the list',
},
lastCommentId: {
title: 'Last comment ID',
description: 'unique identifier of the last comment sent by the integration in this conversation',
},
},
},
},
} as const satisfies NonNullable<IntegrationDefinitionProps['channels']>
@@ -0,0 +1,33 @@
import { IntegrationDefinitionProps, z } from '@botpress/sdk'
import { trelloIdRegex } from './schemas'
const _optionalTrelloIdRegex = new RegExp(`^$|${trelloIdRegex.source}`)
export const configuration = {
schema: z.object({
trelloApiKey: z
.string()
.title('Trello API Key')
.describe("Can be found in the app's settings within the Trello apps admin page")
.secret(),
trelloApiToken: z
.string()
.title('Trello API Token')
.describe('Can be obtained by granting access to the application on Trello')
.secret(),
trelloBoardId: z
.string()
.regex(_optionalTrelloIdRegex)
.optional()
.title('Trello Board ID')
.describe('Unique identifier of the board to watch for events on Trello'),
trelloApiSecret: z
.string()
.secret()
.optional()
.title('Trello API Secret')
.describe(
"Can be found in the app's settings within the Trello apps admin page. (Only used if the Trello Board ID is provided)"
),
}),
} as const satisfies NonNullable<IntegrationDefinitionProps['configuration']>
@@ -0,0 +1,30 @@
import { type IntegrationDefinitionProps } from '@botpress/sdk'
import { boardSchema, cardSchema, listSchema, memberSchema } from './schemas'
export const entities = {
card: {
title: 'Card',
description: 'A card in a Trello list',
schema: cardSchema,
},
list: {
title: 'List',
description: 'A list in a Trello board',
schema: listSchema,
},
board: {
title: 'Board',
description: 'A Trello board',
schema: boardSchema,
},
boardMember: {
title: 'Board Member',
description: 'A member of a Trello board',
schema: memberSchema,
},
cardMember: {
title: 'Card Member',
description: 'A member assigned to a Trello card',
schema: memberSchema,
},
} as const satisfies IntegrationDefinitionProps['entities']
@@ -0,0 +1,36 @@
import { z } from '@botpress/sdk'
import { boardSchema, cardSchema, listSchema, trelloIdSchema } from '../schemas'
import { botpressEventDataSchema, pickIdAndName } from './common'
export const attachmentAddedToCardEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
list: pickIdAndName(listSchema).title('List').describe('List where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
attachment: z
.object({
id: trelloIdSchema.title('Attachment ID').describe('Unique identifier of the attachment'),
name: z.string().title('Attachment Name').describe('Name of the attachment'),
url: z.string().url().title('Attachment URL').describe('URL of the attachment'),
previewUrl: z.string().url().optional().title('Attachment Preview URL').describe('URL of the attachment preview'),
previewUrl2x: z
.string()
.url()
.optional()
.title('Attachment Preview URL 2x')
.describe('URL of the attachment preview at up to 2x the resolution'),
})
.title('Attachment')
.describe('Attachment that was added to the card'),
})
export const attachmentRemovedFromCardEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
attachment: z
.object({
id: trelloIdSchema.title('Attachment ID').describe('Unique identifier of the attachment'),
name: z.string().title('Attachment Name').describe('Name of the attachment'),
})
.title('Attachment')
.describe('Attachment that was deleted from the card'),
})
@@ -0,0 +1,31 @@
import { z } from '@botpress/sdk'
import { boardSchema, cardSchema, listSchema, trelloIdSchema } from '../schemas'
import { botpressEventDataSchema, pickIdAndName } from './common'
const _cardCommentSchema = z.object({
id: trelloIdSchema.title('Comment ID').describe('Unique identifier of the comment'),
text: z.string().title('Comment Text').describe('Text of the comment'),
})
export const cardCommentCreatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
list: pickIdAndName(listSchema).title('List').describe('List where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
comment: _cardCommentSchema.title('New Comment').describe('Comment that was added to the card'),
})
export const cardCommentUpdatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
comment: _cardCommentSchema.title('Updated Comment').describe('Comment that was updated'),
old: _cardCommentSchema.omit({ id: true }).title('Old Comment').describe('The previous data of the comment'),
})
export const cardCommentDeletedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
comment: _cardCommentSchema
.pick({ id: true })
.title('Deleted Comment')
.describe('Comment that was deleted from the card'),
})
@@ -0,0 +1,56 @@
import { z } from '@botpress/sdk'
import { boardSchema, cardSchema, listSchema, trelloIdSchema } from '../schemas'
import { botpressEventDataSchema, dueReminderSchema, pickIdAndName } from './common'
export const cardCreatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was created'),
list: pickIdAndName(listSchema).title('List').describe('List where the card was created'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was created'),
})
const _baseCardUpdateDataSchema = z
.object({
id: trelloIdSchema.title('Card ID').describe('Unique identifier of the card'),
name: z.string().title('Card Name').describe('Name of the card'),
description: z.string().title('Card Description').describe('Description of the card'),
listId: trelloIdSchema.title('List ID').describe('Unique identifier of the list where the card is located'),
labelIds: z.array(trelloIdSchema).title('Label IDs').describe('Labels attached to the card'),
verticalPosition: z.number().title('Card Position').describe('Position of the card within the list'),
startDate: z.string().datetime().nullable().title('Start Date').describe('Start date of the card'),
dueDate: z.string().datetime().nullable().title('Due Date').describe('Due date of the card'),
dueDateReminder: dueReminderSchema,
isCompleted: z.boolean().title('Is Completed').describe('Whether the card is completed'),
isArchived: z.boolean().title('Is Archived').describe('Whether the card is archived'),
})
.passthrough()
.partial()
export const cardUpdatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: _baseCardUpdateDataSchema.required({ id: true, name: true }).title('Card').describe('Card that was updated'),
old: _baseCardUpdateDataSchema.omit({ id: true }).title('Old').describe('Previous state of the card'),
// Only excluded/optional when the card is moved between lists
list: pickIdAndName(listSchema).optional().title('List').describe('List where the card was updated'),
// Only included if the card was moved between lists
listBefore: pickIdAndName(listSchema)
.optional()
.title('List Before')
.describe('Previous list where the card was located'),
// Only included if the card was moved between lists
listAfter: pickIdAndName(listSchema)
.optional()
.title('List After')
.describe('New list where the card is now located'),
})
export const cardDeletedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was deleted'),
list: pickIdAndName(listSchema).title('List').describe('List where the card was deleted'),
card: cardSchema.pick({ id: true }).title('Card').describe('Card that was deleted'),
})
export const cardVotesUpdatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
voted: z.boolean().title('Has Voted').describe('Whether the user voted on the card'),
})
@@ -0,0 +1,21 @@
import { z } from '@botpress/sdk'
import { boardSchema, cardSchema, trelloIdSchema } from '../schemas'
import { botpressEventDataSchema, pickIdAndName } from './common'
export const labelSchema = z.object({
id: trelloIdSchema.title('Label ID').describe('Unique identifier of the label'),
name: z.string().title('Label Name').describe('Name of the label'),
color: z.string().title('Label Color').describe('Color of the label'),
})
export const labelAddedToCardEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was modified'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was modified'),
label: labelSchema.title('Label').describe('Label that was added to the card'),
})
export const labelRemovedFromCardEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was modified'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was modified'),
label: labelSchema.title('Label').describe('Label that was removed from the card'),
})
@@ -0,0 +1,64 @@
import { z } from '@botpress/sdk'
import { boardSchema, cardSchema, trelloIdSchema } from '../schemas'
import { botpressEventDataSchema, dueReminderSchema, pickIdAndName } from './common'
export const checklistSchema = z.object({
id: trelloIdSchema.title('Checklist ID').describe('Unique identifier of the checklist'),
name: z.string().title('Checklist Name').describe('Name of the checklist'),
})
const _basicChecklistItemSchema = z.object({
id: trelloIdSchema.title('Checklist Item ID').describe('Unique identifier of the checklist item'),
name: z.string().title('Checklist Item Name').describe('Name of the checklist item'),
isCompleted: z.boolean().title('Is Completed').describe('Indicates if the checklist item is marked as completed'),
textData: z
.object({
emoji: z.object({}).title('Checklist Item Emoji').describe('Emoji of the checklist item'),
})
.title('Text data')
.describe('Text data of the checklist item'),
})
export const checklistAddedToCardEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
checklist: checklistSchema.title('Checklist').describe('Checklist that was added to the card'),
})
export const checklistItemCreatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
checklist: checklistSchema.title('Checklist').describe('Checklist where the item was added'),
checklistItem: _basicChecklistItemSchema.title('Checklist Item').describe('The checklist item that was added'),
})
const _baseChecklistItemUpdateDataSchema = _basicChecklistItemSchema.extend({
dueDateReminder: dueReminderSchema.optional(),
dueDate: z.string().datetime().nullable().optional().title('Due Date').describe('Due date of the checklist item'),
})
export const checklistItemUpdatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
checklist: checklistSchema.title('Checklist').describe('Checklist where the item was updated'),
checklistItem: _baseChecklistItemUpdateDataSchema.title('Checklist Item').describe('Checklist item that was updated'),
old: _baseChecklistItemUpdateDataSchema
.omit({ id: true })
.partial()
.title('Old Checklist Item')
.describe('The previous data of the checklist item'),
})
export const checklistItemStatusUpdatedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
checklist: checklistSchema.title('Checklist').describe('Checklist where the item was updated'),
checklistItem: _basicChecklistItemSchema.title('Checklist Item').describe('Checklist item that was updated'),
})
export const checklistItemDeletedEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
checklist: checklistSchema.title('Checklist').describe('Checklist where the item was removed'),
checklistItem: _basicChecklistItemSchema.title('Checklist Item').describe('Checklist item that was removed'),
})
@@ -0,0 +1,69 @@
import { z } from '@botpress/sdk'
import { trelloIdSchema } from '../schemas'
export enum TrelloEventType {
// ---- Card Events ----
CARD_CREATED = 'createCard',
CARD_UPDATED = 'updateCard',
CARD_DELETED = 'deleteCard',
CARD_VOTES_UPDATED = 'voteOnCard',
// ---- Card Comment Events ----
CARD_COMMENT_CREATED = 'commentCard',
CARD_COMMENT_UPDATED = 'updateComment',
CARD_COMMENT_DELETED = 'deleteComment',
// ---- Card Label Events ----
LABEL_ADDED_TO_CARD = 'addLabelToCard',
LABEL_REMOVED_FROM_CARD = 'removeLabelFromCard',
// ---- Card Attachment Events ----
ATTACHMENT_ADDED_TO_CARD = 'addAttachmentToCard',
ATTACHMENT_REMOVED_FROM_CARD = 'deleteAttachmentFromCard',
// ---- Checklist Events ----
CHECKLIST_ADDED_TO_CARD = 'addChecklistToCard',
CHECKLIST_ITEM_CREATED = 'createCheckItem',
CHECKLIST_ITEM_UPDATED = 'updateCheckItem',
CHECKLIST_ITEM_DELETED = 'deleteCheckItem',
CHECKLIST_ITEM_STATUS_UPDATED = 'updateCheckItemStateOnCard',
// ---- Member Events ----
MEMBER_ADDED_TO_CARD = 'addMemberToCard',
MEMBER_REMOVED_FROM_CARD = 'removeMemberFromCard',
}
type IdAndNameSchema = z.ZodObject<{ id: z.ZodString; name: z.ZodString }>
export const pickIdAndName = <T extends IdAndNameSchema>(schema: T) => schema.pick({ id: true, name: true })
/** The number of minutes before the due date when a reminder will be sent.
*
* @remark When the value is "-1", it means no due date reminder is set. */
export const dueReminderSchema = z
.number()
.int('Due date reminder is not an integer')
.min(-1)
.title('Due Date Reminder')
.describe('The number of minutes before the due date when a reminder will be sent')
export const botpressEventDataSchema = z.object({
eventId: trelloIdSchema.title('Event ID').describe('Unique identifier of the event'),
actor: z
.union([
z.object({
id: trelloIdSchema.title('Actor ID').describe('Unique identifier of the actor who triggered the event'),
type: z
.literal('member')
.title('Actor Type')
.describe('The type of the actor (e.g. member or app) who triggered the event'),
name: z.string().title('Actor Name').describe('The name of the actor (e.g. member) who triggered the event'),
}),
z.object({
id: trelloIdSchema.title('Actor ID').describe('Unique identifier of the actor who triggered the event'),
type: z
.literal('app')
.title('Actor Type')
.describe('The type of the actor (e.g. member or app) who triggered the event'),
}),
])
.title('Actor')
.describe('The actor (e.g. member or app) who triggered the event'),
dateCreated: z.string().datetime().title('Date Created').describe('The datetime when the event was triggered'),
})
export type CommonEventData = z.infer<typeof botpressEventDataSchema>
@@ -0,0 +1,136 @@
import { type IntegrationDefinitionProps } from '@botpress/sdk'
import { attachmentAddedToCardEventSchema, attachmentRemovedFromCardEventSchema } from './card-attachment-events'
import {
cardCommentCreatedEventSchema,
cardCommentDeletedEventSchema,
cardCommentUpdatedEventSchema,
} from './card-comment-events'
import {
cardCreatedEventSchema,
cardDeletedEventSchema,
cardUpdatedEventSchema,
cardVotesUpdatedEventSchema,
} from './card-events'
import { labelAddedToCardEventSchema, labelRemovedFromCardEventSchema } from './card-label-events'
import {
checklistAddedToCardEventSchema,
checklistItemCreatedEventSchema,
checklistItemDeletedEventSchema,
checklistItemUpdatedEventSchema,
checklistItemStatusUpdatedEventSchema,
} from './checklist-events'
import { CommonEventData, TrelloEventType } from './common'
import { memberAddedToCardEventSchema, memberRemovedFromCardEventSchema } from './member-events'
export const events = {
// ===============================
// Card Events
// ===============================
[TrelloEventType.CARD_CREATED]: {
title: 'Card Created',
description: 'Triggered when a card is created',
schema: cardCreatedEventSchema,
},
[TrelloEventType.CARD_UPDATED]: {
title: 'Card Updated',
description: 'Triggered when a card is updated',
schema: cardUpdatedEventSchema,
},
[TrelloEventType.CARD_DELETED]: {
title: 'Card Deleted',
description: 'Triggered when a card is deleted',
schema: cardDeletedEventSchema,
},
[TrelloEventType.CARD_VOTES_UPDATED]: {
title: 'Card Votes Updated',
description: 'Triggered when a vote is added to or removed from a card',
schema: cardVotesUpdatedEventSchema,
},
// ===============================
// Card Comment Events
// ===============================
[TrelloEventType.CARD_COMMENT_CREATED]: {
title: 'Comment Created',
description: 'Triggered when a comment is added to a card',
schema: cardCommentCreatedEventSchema,
},
[TrelloEventType.CARD_COMMENT_UPDATED]: {
title: 'Comment Updated',
description: 'Triggered when a comment is updated on a card',
schema: cardCommentUpdatedEventSchema,
},
[TrelloEventType.CARD_COMMENT_DELETED]: {
title: 'Comment Deleted',
description: 'Triggered when a comment is deleted from a card',
schema: cardCommentDeletedEventSchema,
},
// ===============================
// Card Label Events
// ===============================
[TrelloEventType.LABEL_ADDED_TO_CARD]: {
title: 'Card Label Added',
description: 'Triggered when a label is added to a card',
schema: labelAddedToCardEventSchema,
},
[TrelloEventType.LABEL_REMOVED_FROM_CARD]: {
title: 'Card Label Removed',
description: 'Triggered when a label is removed from a card',
schema: labelRemovedFromCardEventSchema,
},
// ================================
// Card Attachment Events
// ================================
[TrelloEventType.ATTACHMENT_ADDED_TO_CARD]: {
title: 'Card Attachment Added',
description: 'Triggered when an attachment is added to a card',
schema: attachmentAddedToCardEventSchema,
},
[TrelloEventType.ATTACHMENT_REMOVED_FROM_CARD]: {
title: 'Card Attachment Removed',
description: 'Triggered when an attachment is removed from a card',
schema: attachmentRemovedFromCardEventSchema,
},
// ================================
// Checklist Events
// ================================
[TrelloEventType.CHECKLIST_ADDED_TO_CARD]: {
title: 'Checklist Added To Card',
description: 'Triggered when a checklist is added to a card',
schema: checklistAddedToCardEventSchema,
},
[TrelloEventType.CHECKLIST_ITEM_CREATED]: {
title: 'Checklist Item Created',
description: 'Triggered when a checklist item is added to a card',
schema: checklistItemCreatedEventSchema,
},
[TrelloEventType.CHECKLIST_ITEM_UPDATED]: {
title: 'Checklist Item Updated',
description: 'Triggered when a checklist item is modified on a card',
schema: checklistItemUpdatedEventSchema,
},
[TrelloEventType.CHECKLIST_ITEM_DELETED]: {
title: 'Checklist Item Deleted',
description: 'Triggered when a checklist item is removed from a card',
schema: checklistItemDeletedEventSchema,
},
[TrelloEventType.CHECKLIST_ITEM_STATUS_UPDATED]: {
title: 'Checklist Item Completion Updated',
description: 'Triggered when the completion status of a checklist item is updated',
schema: checklistItemStatusUpdatedEventSchema,
},
// ===============================
// Member Events
// ===============================
[TrelloEventType.MEMBER_ADDED_TO_CARD]: {
title: 'Member Added To Card',
description: 'Triggered when a member is added to a card',
schema: memberAddedToCardEventSchema,
},
[TrelloEventType.MEMBER_REMOVED_FROM_CARD]: {
title: 'Member Removed From Card',
description: 'Triggered when a member is removed from a card',
schema: memberRemovedFromCardEventSchema,
},
} as const satisfies NonNullable<IntegrationDefinitionProps['events']>
export { TrelloEventType, type CommonEventData }
@@ -0,0 +1,28 @@
import { z } from '@botpress/sdk'
import { boardSchema, cardSchema, trelloIdSchema } from '../schemas'
import { botpressEventDataSchema, pickIdAndName } from './common'
export const eventMemberSchema = z.object({
id: trelloIdSchema.title('Member ID').describe('Unique identifier of the member'),
name: z.string().title('Member Name').describe('Full name of the member'),
})
export const memberAddedToCardEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that the member was added to'),
member: eventMemberSchema.title('Member').describe('Member that was added to the card'),
})
export const memberRemovedFromCardEventSchema = botpressEventDataSchema.extend({
board: pickIdAndName(boardSchema).title('Board').describe('Board where the card was updated'),
card: pickIdAndName(cardSchema).title('Card').describe('Card that was updated'),
member: eventMemberSchema
.extend({
deactivated: z
.boolean()
.title('Deactivated')
.describe('Indicates if the member was deactivated at the time of removal'),
})
.title('Member')
.describe('Member that was removed from the card'),
})
+6
View File
@@ -0,0 +1,6 @@
export { actions } from './actions'
export { channels } from './channels'
export { configuration } from './configuration'
export { events } from './events'
export { user } from './user'
export { entities } from './entities'
@@ -0,0 +1,50 @@
import { z } from '@botpress/sdk'
export const trelloIdRegex = /^[0-9a-fA-F]{24}$/
export const trelloIdSchema = z.string().regex(trelloIdRegex)
export type TrelloID = z.infer<typeof trelloIdSchema>
export const boardSchema = z.object({
id: trelloIdSchema.title('Board ID').describe('Unique identifier of the board'),
name: z.string().title('Board Name').describe('The name of the board'),
})
export type Board = z.infer<typeof boardSchema>
export const cardSchema = z.object({
id: trelloIdSchema.title('Card ID').describe('Unique identifier of the card'),
name: z.string().title('Card Name').describe('The preview name of the card'),
description: z.string().title('Card Description').describe('Detailed description of the card'),
listId: trelloIdSchema.title('List ID').describe('Identifier of the list the card belongs to'),
verticalPosition: z.number().title('Position').describe('Position of the card within the list'),
isClosed: z.boolean().title('Is Closed').describe('Indicates if the card is closed'),
isCompleted: z.boolean().title('Is Completed').describe('Indicates if the card is completed'),
dueDate: z.string().datetime().optional().title('Due Date').describe('The expected completed by date (Optional)'),
labelIds: z.array(trelloIdSchema).title('Label IDs').describe('A list of label IDs attached to the card'),
memberIds: z.array(trelloIdSchema).title('Member IDs').describe('A list of member IDs assigned to the card'),
})
export type Card = z.infer<typeof cardSchema>
export const listSchema = z.object({
id: trelloIdSchema.title('List ID').describe('Unique identifier of the list'),
name: z.string().title('List Name').describe('The name of the list'),
})
export type List = z.infer<typeof listSchema>
export const memberSchema = z.object({
id: trelloIdSchema.title('Member ID').describe('Unique identifier of the member'),
username: z.string().title('Username').describe('A public alias that represents the member'),
fullName: z.string().title('Full Name').describe('Full name of the member'),
})
export type Member = z.infer<typeof memberSchema>
export const webhookSchema = z.object({
id: trelloIdSchema.title('Webhook ID').describe('Unique identifier of the webhook'),
modelId: trelloIdSchema.title('Model ID').describe('ID of the Trello model the webhook watches for events'),
callbackUrl: z
.string()
.url()
.title('Callback URL')
.describe('The URL that Trello will call when a webhook event occurs'),
})
export type Webhook = z.infer<typeof webhookSchema>
+10
View File
@@ -0,0 +1,10 @@
import { IntegrationDefinitionProps } from '@botpress/sdk'
export const user = {
tags: {
userId: {
title: 'User ID',
description: 'Unique identifier of the Trello user',
},
},
} as const satisfies NonNullable<IntegrationDefinitionProps['user']>