-
Notifications
You must be signed in to change notification settings - Fork 75
Create Form Tool & Get Form Tool #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
584775c
684ac31
68f9a88
c3309e9
65837fd
3bf9bd5
de37496
6b2c384
f42c2dc
5b0c4a9
13c1b1d
962197b
7afe696
e28ceb9
8f1e7da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { z } from 'zod'; | ||
| import { | ||
| BoardKind, | ||
| CreateFormMutation, | ||
| CreateFormMutationVariables, | ||
| } from '../../../../monday-graphql/generated/graphql'; | ||
| import { createForm } from './workforms.graphql'; | ||
| import { ToolInputType, ToolOutputType, ToolType } from '../../../tool'; | ||
| import { BaseMondayApiTool, createMondayApiAnnotations } from '../base-monday-api-tool'; | ||
| import { GraphQLDescriptions } from './workforms.consts'; | ||
|
|
||
| export const createFormToolSchema = { | ||
| destination_workspace_id: z.number().describe(GraphQLDescriptions.form.args.destinationWorkspaceId), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be of type string, if in the gql its number this should change. I know someone from your team plans to change it to type ID (for all the IDS)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is dependent on the use_template mutation so we copy the exact types they use as well. When they switch to IDs we will too |
||
| destination_folder_id: z.number().optional().describe(GraphQLDescriptions.form.args.destinationFolderId), | ||
| destination_folder_name: z.string().optional().describe(GraphQLDescriptions.form.args.destinationFolderName), | ||
| board_kind: z.nativeEnum(BoardKind).optional().describe(GraphQLDescriptions.form.args.boardKind), | ||
| destination_name: z.string().optional().describe(GraphQLDescriptions.form.args.destinationName), | ||
| board_owner_ids: z.array(z.number()).optional().describe(GraphQLDescriptions.form.args.boardOwnerIds), | ||
| board_owner_team_ids: z.array(z.number()).optional().describe(GraphQLDescriptions.form.args.boardOwnerTeamIds), | ||
| board_subscriber_ids: z.array(z.number()).optional().describe(GraphQLDescriptions.form.args.boardSubscriberIds), | ||
| board_subscriber_teams_ids: z | ||
| .array(z.number()) | ||
| .optional() | ||
| .describe(GraphQLDescriptions.form.args.boardSubscriberTeamsIds), | ||
| }; | ||
|
|
||
| export class CreateFormTool extends BaseMondayApiTool<typeof createFormToolSchema, never> { | ||
|
GuyHadas marked this conversation as resolved.
|
||
| name = 'create_form'; | ||
| type = ToolType.WRITE; | ||
| annotations = createMondayApiAnnotations({ | ||
| title: 'Create Form', | ||
| readOnlyHint: false, | ||
| destructiveHint: false, | ||
| idempotentHint: false, | ||
| }); | ||
|
|
||
| getDescription(): string { | ||
|
GuyHadas marked this conversation as resolved.
|
||
| return 'Create a monday.com form. This will create a new form as well as a new board for which the form’s responses will be stored. The returned board_id is the ID of the board that was created while the returned formToken can be used for all future queries and mutations to continue editing the form.'; | ||
| } | ||
|
|
||
| getInputSchema(): typeof createFormToolSchema { | ||
| return createFormToolSchema; | ||
| } | ||
|
|
||
| protected async executeInternal(input: ToolInputType<typeof createFormToolSchema>): Promise<ToolOutputType<never>> { | ||
| const variables: CreateFormMutationVariables = { | ||
| destination_workspace_id: input.destination_workspace_id, | ||
| destination_folder_id: input.destination_folder_id, | ||
| destination_folder_name: input.destination_folder_name, | ||
| board_kind: input.board_kind, | ||
| destination_name: input.destination_name, | ||
| board_owner_ids: input.board_owner_ids, | ||
| board_owner_team_ids: input.board_owner_team_ids, | ||
| board_subscriber_ids: input.board_subscriber_ids, | ||
| board_subscriber_teams_ids: input.board_subscriber_teams_ids, | ||
| }; | ||
|
|
||
| const res = await this.mondayApi.request<CreateFormMutation>(createForm, variables); | ||
|
|
||
| return { | ||
| content: `Form created successfully. Board ID: ${res.create_form?.boardId}, Token: ${res.create_form?.token}`, | ||
| }; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { z } from 'zod'; | ||
| import { GetFormQuery, GetFormQueryVariables } from '../../../../monday-graphql/generated/graphql'; | ||
| import { getForm } from './workforms.graphql'; | ||
| import { ToolInputType, ToolOutputType, ToolType } from '../../../tool'; | ||
| import { BaseMondayApiTool, createMondayApiAnnotations } from '../base-monday-api-tool'; | ||
| import { GraphQLDescriptions } from './workforms.consts'; | ||
|
|
||
| export const getFormToolSchema = { | ||
| formToken: z.string().describe(GraphQLDescriptions.commonArgs.formToken), | ||
| }; | ||
|
|
||
| export class GetFormTool extends BaseMondayApiTool<typeof getFormToolSchema, never> { | ||
| name = 'get_form'; | ||
| type = ToolType.READ; | ||
| annotations = createMondayApiAnnotations({ | ||
| title: 'Get Form', | ||
| readOnlyHint: true, | ||
| destructiveHint: false, | ||
| }); | ||
|
|
||
| getDescription(): string { | ||
| return 'Get a monday.com form by its form token. Form tokens can be extracted from the form’s url. Given a form url, such as https://forms.monday.com/forms/abc123def456ghi789?r=use1, the token is the alphanumeric string that appears right after /forms/ and before the ?. In the example, the token is abc123def456ghi789.'; | ||
|
GuyHadas marked this conversation as resolved.
|
||
| } | ||
|
|
||
| getInputSchema(): typeof getFormToolSchema { | ||
| return getFormToolSchema; | ||
| } | ||
|
|
||
| protected async executeInternal(input: ToolInputType<typeof getFormToolSchema>): Promise<ToolOutputType<never>> { | ||
| const variables: GetFormQueryVariables = { | ||
| formToken: input.formToken, | ||
| }; | ||
|
|
||
| const res = await this.mondayApi.request<GetFormQuery>(getForm, variables); | ||
|
|
||
| if (!res.form) { | ||
| return { | ||
| content: `Form with token ${input.formToken} not found or you don't have access to it.`, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| content: `The form with the token ${input.formToken} is: ${JSON.stringify(res.form, null, 2)}`, | ||
| }; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.