diff --git a/bots/bugbuster/src/linear-lint-issue.ts b/bots/bugbuster/src/linear-lint-issue.ts index 32d3798746b..e65269fa61c 100644 --- a/bots/bugbuster/src/linear-lint-issue.ts +++ b/bots/bugbuster/src/linear-lint-issue.ts @@ -1,11 +1,12 @@ import { isIssueTitleFormatValid } from './issue-title-format-validator' import { Issue } from './utils/graphql-queries' +import { StateKey } from './utils/linear-utils' export type IssueLint = { message: string } -export const lintIssue = async (issue: Issue, status: string): Promise => { +export const lintIssue = async (issue: Issue, status: StateKey): Promise => { const lints: string[] = [] if (!_hasLabelOfCategory(issue, 'type')) { diff --git a/bots/bugbuster/src/utils/linear-utils.ts b/bots/bugbuster/src/utils/linear-utils.ts index 9ef1b34be56..0af9660ae4e 100644 --- a/bots/bugbuster/src/utils/linear-utils.ts +++ b/bots/bugbuster/src/utils/linear-utils.ts @@ -18,6 +18,7 @@ const STATE_KEYS = [ 'STALE', ] as const export type StateKey = (typeof STATE_KEYS)[number] +type State = { state: lin.WorkflowState; key: StateKey } const RESULTS_PER_PAGE = 200 @@ -26,7 +27,7 @@ export class LinearApi { private _client: lin.LinearClient, private _viewer: lin.User, private _teams: lin.Team[], - private _states: lin.WorkflowState[] + private _states: State[] ) {} public static async create(): Promise { @@ -39,7 +40,7 @@ export class LinearApi { const states = await this._listAllStates(client) const teams = await this._listAllTeams(client) - return new LinearApi(client, me, teams, states) + return new LinearApi(client, me, teams, this._toStateObjects(states)) } public get client(): lin.LinearClient { @@ -84,11 +85,19 @@ export class LinearApi { return { issues: [] } } + const stateNamesToOmit = statusesToOmit?.map((key) => { + const matchingStates = this._states.filter((state) => state.key === key) + if (matchingStates[0]) { + return matchingStates[0].state.name + } + return '' + }) + const queryInput: GRAPHQL_QUERIES['listIssues'][QUERY_INPUT] = { filter: { team: { key: { in: teamKeys } }, ...(issueNumber && { number: { eq: issueNumber } }), - ...(statusesToOmit && { state: { name: { nin: statusesToOmit } } }), + ...(stateNamesToOmit && { state: { name: { nin: stateNamesToOmit } } }), }, ...(nextPage && { after: nextPage }), first: RESULTS_PER_PAGE, @@ -113,11 +122,11 @@ export class LinearApi { } public issueStatus(issue: Issue): StateKey { - const state = this._states.find((s) => s.id === issue.state.id) + const state = this._states.find((s) => s.state.id === issue.state.id) if (!state) { throw new Error(`State with ID "${issue.state.id}" not found.`) } - return utils.string.toScreamingSnakeCase(state.name) as StateKey + return state.key } public async resolveComments(issue: Issue): Promise { @@ -154,9 +163,7 @@ export class LinearApi { return new Proxy({} as Record, { get: (_, stateKey: StateKey) => { - const state = this._states.find( - (s) => utils.string.toScreamingSnakeCase(s.name) === stateKey && s.teamId === teamId - ) + const state = this._states.find((s) => s.key === stateKey && s.state.teamId === teamId) if (!state) { throw new Error(`State with key "${stateKey}" not found.`) @@ -190,6 +197,15 @@ export class LinearApi { return states } + private static _toStateObjects(states: lin.WorkflowState[]): State[] { + const stateObjects: State[] = [] + for (const state of states) { + const key = utils.string.toScreamingSnakeCase(state.name) as StateKey + stateObjects.push({ key, state }) + } + return stateObjects + } + private async _executeGraphqlQuery( queryName: K, variables: GRAPHQL_QUERIES[K][QUERY_INPUT] diff --git a/integrations/googlecalendar/integration.definition.ts b/integrations/googlecalendar/integration.definition.ts index 1a131c449e4..09c17d5c020 100644 --- a/integrations/googlecalendar/integration.definition.ts +++ b/integrations/googlecalendar/integration.definition.ts @@ -3,7 +3,7 @@ import { actions, entities, configuration, configurations, identifier, events, s export default new sdk.IntegrationDefinition({ name: 'googlecalendar', - version: '2.0.0', + version: '2.0.1', description: 'Sync with your calendar to manage events, appointments, and schedules directly within the chatbot.', title: 'Google Calendar', readme: 'hub.md', diff --git a/integrations/googlecalendar/src/google-api/google-client.ts b/integrations/googlecalendar/src/google-api/google-client.ts index d2964c1c8d0..e6a09d5e05d 100644 --- a/integrations/googlecalendar/src/google-api/google-client.ts +++ b/integrations/googlecalendar/src/google-api/google-client.ts @@ -115,6 +115,7 @@ export class GoogleClient { requestBody: { timeMin, timeMax, + items: [{ id: this._calendarId }], }, })