Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions integrations/trello/definitions/actions/board-actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionDefinition, z } from '@botpress/sdk'
import { boardSchema } from 'definitions/schemas'
import { hasBoardId, noInput, outputsBoard, outputsBoards } from './common'
import { hasBoardId, noInput } from './common'

export const getBoardById = {
title: 'Get board by ID',
Expand All @@ -9,7 +9,9 @@ export const getBoardById = {
schema: hasBoardId.describe('Input schema for getting a board from its ID'),
},
output: {
schema: outputsBoard.describe('Output schema for getting a board from its ID'),
schema: z.object({
board: boardSchema.title('Trello Board').describe('The details of the Trello board associated with the given ID'),
}),
},
} as const satisfies ActionDefinition

Expand All @@ -24,7 +26,12 @@ export const getBoardsByDisplayName = {
.describe('Input schema for getting a board ID from its name'),
},
output: {
schema: outputsBoards.describe('Output schema for getting a board from its name'),
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

Expand All @@ -35,6 +42,8 @@ export const getAllBoards = {
schema: noInput.describe('Input schema for getting all boards'),
},
output: {
schema: outputsBoards.describe('Output schema for getting all boards'),
schema: z.object({
boards: z.array(boardSchema).title('Trello Boards').describe('A list of Trello boards'),
}),
},
} as const satisfies ActionDefinition
40 changes: 27 additions & 13 deletions integrations/trello/definitions/actions/card-actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionDefinition, z } from '@botpress/sdk'
import { cardSchema, listSchema, trelloIdSchema } from 'definitions/schemas'
import { hasCardId, hasListId, hasMessage, outputsCard, outputsCards } from './common'
import { hasCardId, hasListId, hasMessage } from './common'

export const getCardById = {
title: 'Get card by ID',
Expand All @@ -9,13 +9,15 @@ export const getCardById = {
schema: hasCardId.describe('Input schema for getting a card from its ID'),
},
output: {
schema: outputsCard.describe('Output schema for getting a card from its ID'),
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 name',
description: 'Find all lists whose display name match this name',
title: 'Find cards by name',
description: 'Find all cards whose display name match this name',
input: {
schema: hasListId
.extend({
Expand All @@ -24,7 +26,9 @@ export const getCardsByDisplayName = {
.describe('Input schema for getting a card ID from its name'),
},
output: {
schema: outputsCards.describe('Output schema for getting a card ID from its name'),
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

Expand All @@ -35,7 +39,12 @@ export const getCardsInList = {
schema: hasListId.describe('Input schema for getting all cards in a list'),
},
output: {
schema: outputsCards.describe('Output schema for getting all cards in a list'),
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

Expand Down Expand Up @@ -73,8 +82,11 @@ export const createCard = {
.describe('Input schema for creating a new card'),
},
output: {
schema: hasMessage
.extend({
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'),
Expand Down Expand Up @@ -201,11 +213,13 @@ export const addCardComment = {
.describe('Input schema for adding a comment to a card'),
},
output: {
schema: hasMessage
.extend({
newCommentId: trelloIdSchema.describe('Unique identifier of the newly created comment'),
})
.describe('Output schema for adding a comment to a card'),
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

Expand Down
36 changes: 2 additions & 34 deletions integrations/trello/definitions/actions/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from '@botpress/sdk'
import { boardSchema, listSchema, cardSchema, memberSchema } from 'definitions/schemas'
import { boardSchema, listSchema, cardSchema } from 'definitions/schemas'

// ==== Common Input Schemas ====
export const noInput = z.object({})
Expand All @@ -18,37 +18,5 @@ export const hasCardId = z.object({

// ==== Common Output Schemas ====
export const hasMessage = z.object({
message: z.string().describe('Output message'),
})

export const outputsMember = z.object({
member: memberSchema.describe('The member object'),
})

export const outputsMembers = z.object({
members: z.array(memberSchema).describe('Array of member objects'),
})

export const outputsCard = z.object({
card: cardSchema.describe('The card object'),
})

export const outputsCards = z.object({
cards: z.array(cardSchema).describe('Array of card objects'),
})

export const outputsList = z.object({
list: listSchema.describe('The list object'),
})

export const outputsLists = z.object({
lists: z.array(listSchema).describe('Array of list objects'),
})

export const outputsBoard = z.object({
board: boardSchema.describe('The board object'),
})

export const outputsBoards = z.object({
boards: z.array(boardSchema).describe('Array of board objects'),
message: z.string().title('Output message').describe('Output message'),
})
22 changes: 17 additions & 5 deletions integrations/trello/definitions/actions/list-actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionDefinition } from '@botpress/sdk'
import { ActionDefinition, z } from '@botpress/sdk'
import { listSchema } from 'definitions/schemas'
import { hasBoardId, hasListId, outputsList, outputsLists } from './common'
import { hasBoardId, hasListId } from './common'

export const getListById = {
title: 'Get list by ID',
Expand All @@ -9,7 +9,9 @@ export const getListById = {
schema: hasListId.describe('Input schema for getting a list from its ID'),
},
output: {
schema: outputsList.describe('Output schema for getting a list from its ID'),
schema: z.object({
list: listSchema.title('Trello List').describe("The Trello list that's associated with the given list ID"),
}),
},
} as const satisfies ActionDefinition

Expand All @@ -24,7 +26,12 @@ export const getListsByDisplayName = {
.describe('Input schema for getting a list ID from its name'),
},
output: {
schema: outputsLists.describe('Output schema for getting a list ID from its name'),
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

Expand All @@ -35,6 +42,11 @@ export const getListsInBoard = {
schema: hasBoardId.describe('Input schema for getting all lists in a board'),
},
output: {
schema: outputsLists.describe('Output schema for getting all lists in a board'),
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
31 changes: 21 additions & 10 deletions integrations/trello/definitions/actions/member-actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionDefinition, z } from '@botpress/sdk'
import { boardSchema, memberSchema } from 'definitions/schemas'
import { hasBoardId, hasCardId, outputsMember, outputsMembers } from './common'
import { hasBoardId, hasCardId } from './common'

export const getMemberByIdOrUsername = {
title: 'Get member by ID or username',
Expand All @@ -16,7 +16,11 @@ export const getMemberByIdOrUsername = {
.describe('Input schema for getting a member from its ID or username'),
},
output: {
schema: outputsMember.describe('Output schema for getting a member by its ID or username'),
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

Expand All @@ -27,7 +31,12 @@ export const getAllCardMembers = {
schema: hasCardId.describe('Input schema for getting all members of a card'),
},
output: {
schema: outputsMembers.describe('Output schema for getting all members of a card'),
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

Expand All @@ -38,21 +47,23 @@ export const getAllBoardMembers = {
schema: hasBoardId.describe('Input schema for getting all members of a board'),
},
output: {
schema: outputsMembers.describe('Output schema for getting all members of a board'),
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'),
})
.describe('Input schema for getting a member from its name'),
schema: hasBoardId.extend({
displayName: boardSchema.shape.name.title('Display Name').describe('Display name of the member'),
}),
},
output: {
schema: outputsMembers.describe('Output schema for getting a member from its name'),
schema: z.object({
members: z.array(memberSchema).title('Board Members').describe('A list of members that match the specified name'),
}),
},
} as const satisfies ActionDefinition
2 changes: 1 addition & 1 deletion integrations/trello/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { trelloIdSchema } from 'definitions/schemas'
import { events, actions, channels, user, configuration, entities } from './definitions'

export const INTEGRATION_NAME = 'trello'
export const INTEGRATION_VERSION = '2.1.1'
export const INTEGRATION_VERSION = '2.1.2'

export default new sdk.IntegrationDefinition({
name: INTEGRATION_NAME,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/cli",
"version": "5.5.7",
"version": "5.6.1",
"description": "Botpress CLI",
"scripts": {
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
Expand Down
20 changes: 17 additions & 3 deletions packages/cli/src/command-implementations/profile-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type ProfileEntry = ProfileCredentials & {
name: string
}

type ProfileEntryWithoutToken = Omit<ProfileEntry, 'token'>

export type ActiveProfileCommandDefinition = typeof commandDefinitions.profiles.subcommands.active
export class ActiveProfileCommand extends GlobalCommand<ActiveProfileCommandDefinition> {
public async run(): Promise<void> {
Expand All @@ -21,7 +23,8 @@ export class ActiveProfileCommand extends GlobalCommand<ActiveProfileCommandDefi
}

const profile = await this.readProfileFromFS(activeProfileName)
const profileEntry: ProfileEntry = { name: activeProfileName, ...profile }
let profileEntry: ProfileEntry | ProfileEntryWithoutToken = { name: activeProfileName, ...profile }
if (_shouldOmitToken(this.argv)) profileEntry = _stripProfileToken(profileEntry)

this.logger.log('Active profile:')
this.logger.json(profileEntry)
Expand All @@ -38,8 +41,11 @@ export class ListProfilesCommand extends GlobalCommand<ListProfilesCommandDefini
return
}
const activeProfileName = await this.globalCache.get('activeProfile')
this.logger.log(`Active profile: '${chalk.bold(activeProfileName)}'`)
this.logger.json(profileEntries)
const activeProfileMsg = `Active profile: '${chalk.bold(chalk.cyanBright(activeProfileName))}'`

this.logger.log(activeProfileMsg)
this.logger.json(!_shouldOmitToken(this.argv) ? profileEntries : profileEntries.map(_stripProfileToken))
this.logger.log(activeProfileMsg)
}
}

Expand Down Expand Up @@ -86,3 +92,11 @@ const _updateGlobalCache = async (props: {
await props.globalCache.set('token', props.profile.token)
await props.globalCache.set('workspaceId', props.profile.workspaceId)
}

const _stripProfileToken = (profile: ProfileEntry | ProfileEntryWithoutToken): ProfileEntryWithoutToken => ({
name: profile.name,
apiUrl: profile.apiUrl,
workspaceId: profile.workspaceId,
})

const _shouldOmitToken = (argv: { displayToken: boolean }) => !argv.displayToken
9 changes: 8 additions & 1 deletion packages/cli/src/command-implementations/read-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ export class ReadCommand extends ProjectCommand<ReadCommandDefinition> {
}

private _parseIntegration = async (integrationDef: sdk.IntegrationDefinition) => {
const parsed = await apiUtils.prepareCreateIntegrationBody(integrationDef)
const {
// Ignored fields ("code", "icon", "readme") so the terminal output doesn't get polluted
code: _code,
icon: _icon,
readme: _readme,
...parsed
} = await this.prepareCreateIntegrationBody(integrationDef)

parsed.interfaces = utils.records.mapValues(integrationDef.interfaces ?? {}, (iface) => ({
...iface,
id: iface.id ?? '',
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,12 @@ const chatSchema = {

const listProfilesSchema = {
...globalSchema,
displayToken: { type: 'boolean', description: 'Display the token in each of the bp profiles', default: false },
} satisfies CommandSchema

const activeProfileSchema = {
...globalSchema,
displayToken: { type: 'boolean', description: 'Display the token in the bp profile', default: false },
} satisfies CommandSchema

const useProfileSchema = {
Expand Down
2 changes: 1 addition & 1 deletion scripts/upload-sandbox-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const _fallbackProfileArgs = () => ({
token: undefined,
})
function getProfileArgs(): any {
const activeProfileCmdResult = spawnSync('pnpm', ['exec', 'bp', 'profiles', 'active', '--json'])
const activeProfileCmdResult = spawnSync('pnpm', ['exec', 'bp', 'profiles', 'active', '--json', '--displayToken'])
if (activeProfileCmdResult.status !== 0) {
console.debug(
`Failed to get active profile: ${activeProfileCmdResult.error?.message || activeProfileCmdResult.stderr.toString() || 'Unknown error'}`
Expand Down
Loading