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
4 changes: 4 additions & 0 deletions bots/bugbuster/bot.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,9 @@ export default new sdk.BotDefinition({
clientSecret: genenv.BUGBUSTER_SLACK_CLIENT_SECRET,
signingSecret: genenv.BUGBUSTER_SLACK_SIGNING_SECRET,
typingIndicatorEmoji: false,
replyBehaviour: {
location: 'channel',
onlyOnBotMention: false,
},
},
})
6 changes: 5 additions & 1 deletion bots/bugbuster/src/handlers/lint-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as types from 'src/types'
import * as boot from '../bootstrap'
import * as bp from '.botpress'

const LINEAR_ISSUE_BASE_URL = 'https://linear.app/botpress/issue/'

export const handleLintAll: bp.WorkflowHandlers['lintAll'] = async (props) => {
const { client, workflow, ctx, conversation } = props

Expand Down Expand Up @@ -112,7 +114,9 @@ export const handleLintAllTimeout: bp.WorkflowHandlers['lintAll'] = async (props
}

const _buildResultMessage = (results: types.LintResult[]) => {
const failedIssuesLinks = results.filter((result) => result.result === 'failed').map((result) => result.identifier)
const failedIssuesLinks = results
.filter((result) => result.result === 'failed')
.map((result) => `[${result.identifier}](${LINEAR_ISSUE_BASE_URL + result.identifier})`)

let messageDetail = 'No issue contained lint errors.'
if (failedIssuesLinks.length === 1) {
Expand Down
15 changes: 15 additions & 0 deletions integrations/bamboohr/definitions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
bambooHrCompanyInfo,
bambooHrEmployeeBasicInfoResponse,
bambooHrEmployeeCustomInfoResponse,
bambooHrFields,
} from './bamboohr-schemas'
import { employeeId, employeeIdObject } from './common'

Expand Down Expand Up @@ -68,9 +69,23 @@ const getCompanyInfo: ActionDefinition = {
},
}

const getFields: ActionDefinition = {
title: 'Get Employee Fields',
description: 'Retrieve the list of available employee fields.',
input: {
schema: z.object({}),
},
output: {
schema: z.object({
fields: bambooHrFields,
}),
},
}

export const actions = {
getEmployeeBasicInfo,
getEmployeeCustomInfo,
listEmployees,
getCompanyInfo,
getFields,
} as const
16 changes: 15 additions & 1 deletion integrations/bamboohr/definitions/bamboohr-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const bambooHrEmployeeBasicInfoResponse = bambooHrEmployeeWebhookFields.e
displayName: z.string().title('Display Name').describe("Employee's display name."),
})

export const bambooHrEmployeeCustomInfoResponse = z.object({ id: employeeId }).catchall(z.string())
export const bambooHrEmployeeCustomInfoResponse = z.object({ id: employeeId }).passthrough()

export const bambooHrEmployeeDirectoryResponse = z.object({
fields: z
Expand Down Expand Up @@ -211,3 +211,17 @@ export const bambooHrCompanyInfo = z.object({
.describe('Address of the company.'),
phone: z.string().nullable().optional().title('Phone Number').describe('Phone number of the company.'),
})

export const bambooHrFields = z
.array(
z
.object({
id: z.union([z.string(), z.number()]).title('ID').describe('Unique identifier for the field.'),
name: z.string().title('Name').describe('Name of the field.'),
type: z.string().title('Type').describe('Data type of the field.'),
alias: z.string().optional().title('Alias').describe('Alias used for the field in API requests.'),
})
.passthrough()
)
.title('Fields')
.describe('List of available employee fields.')
2 changes: 1 addition & 1 deletion integrations/bamboohr/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IntegrationDefinition, z } from '@botpress/sdk'
import { actions, events, subdomain } from './definitions'

export const INTEGRATION_NAME = 'bamboohr'
export const INTEGRATION_VERSION = '2.0.4'
export const INTEGRATION_VERSION = '2.1.0'

export default new IntegrationDefinition({
name: INTEGRATION_NAME,
Expand Down
11 changes: 11 additions & 0 deletions integrations/bamboohr/src/actions/employees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ export const listEmployees: bp.IntegrationProps['actions']['listEmployees'] = as
throw new RuntimeError(`Failed to list employees: ${error.message}`)
}
}

export const getFields: bp.IntegrationProps['actions']['getFields'] = async ({ client, ctx, logger }) => {
const bambooHrClient = await BambooHRClient.create({ client, ctx, logger })

try {
return { fields: await bambooHrClient.getFields() }
} catch (thrown) {
const error = thrown instanceof Error ? thrown : new Error(String(thrown))
throw new RuntimeError(`Failed to get fields: ${error.message}`)
}
}
3 changes: 2 additions & 1 deletion integrations/bamboohr/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getCompanyInfo } from './company'
import { getEmployeeBasicInfo, getEmployeeCustomInfo, listEmployees } from './employees'
import { getEmployeeBasicInfo, getEmployeeCustomInfo, listEmployees, getFields } from './employees'
import * as bp from '.botpress'

export const actions = {
getEmployeeBasicInfo,
getEmployeeCustomInfo,
listEmployees,
getCompanyInfo,
getFields,
} satisfies bp.IntegrationProps['actions']
15 changes: 15 additions & 0 deletions integrations/bamboohr/src/api/bamboohr-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
bambooHrEmployeeBasicInfoResponse,
bambooHrEmployeeCustomInfoResponse,
bambooHrEmployeeDirectoryResponse,
bambooHrFields,
bambooHrWebhookCreateResponse,
} from 'definitions'
import * as types from '../types'
Expand Down Expand Up @@ -131,6 +132,20 @@ export class BambooHRClient {
return result.data
}

public async getFields(): Promise<z.infer<typeof bambooHrFields>> {
const url = new URL(`${this._baseUrl}/meta/fields`)

const res = await this._makeRequest({ method: 'GET', url })
const result = await parseResponseWithErrors(res, bambooHrFields)

if (!result.success) {
this._props.logger.forBot().error(result.error, result.details)
throw new Error(result.error)
}

return result.data
}

public async getEmployeeBasicInfo(employeeId: string): Promise<z.infer<typeof bambooHrEmployeeBasicInfoResponse>> {
const url = new URL(`${this._baseUrl}/employees/${employeeId}`)

Expand Down
Loading