actions/create-userstory/create-userstory.mjs
import { parseObject } from "../../common/utils.mjs"; import taiga from "../../taiga.app.mjs"; export default { key: "taiga-create-userstory", name: "Create User Story", description: "Create a new user story in a Taiga project. [See the documentation](https://docs.taiga.io/api.html#user-stories-create)", version: "0.0.2", annotations: { destructiveHint: false, openWorldHint: true, readOnlyHint: false, }, type: "action", props: { taiga, projectId: { propDefinition: [ taiga, "projectId", ], }, subject: { propDefinition: [ taiga, "userStorySubject", ], }, description: { propDefinition: [ taiga, "userStoryDescription", ], optional: true, }, status: { propDefinition: [ taiga, "userStoryStatus", ({ projectId }) => ({ projectId, }), ], optional: true, }, assignedTo: { propDefinition: [ taiga, "userId", ({ projectId }) => ({ projectId, }), ], label: "Assigned To", description: "User to assign the user story to", optional: true, }, tags: { propDefinition: [ taiga, "tags", ], description: "Tags to associate with the user story", optional: true, }, backlogOrder: { propDefinition: [ taiga, "backlogOrder", ], optional: true, }, kanbanOrder: { propDefinition: [ taiga, "kanbanOrder", ], optional: true, }, sprintOrder: { propDefinition: [ taiga, "sprintOrder", ], optional: true, }, clientRequirement: { propDefinition: [ taiga, "clientRequirement", ], optional: true, }, isBlocked: { propDefinition: [ taiga, "isBlocked", ], description: "Whether the user story is blocked", optional: true, }, milestone: { propDefinition: [ taiga, "milestone", ({ projectId }) => ({ projectId, }), ], description: "Milestone to associate the user story with", optional: true, }, points: { propDefinition: [ taiga, "points", ], optional: true, }, teamRequirement: { propDefinition: [ taiga, "teamRequirement", ], optional: true, }, watchers: { propDefinition: [ taiga, "userId", ({ projectId }) => ({ projectId, }), ], type: "string[]", label: "Watchers", description: "Users to watch the user story", optional: true, }, }, async run({ $ }) { const response = await this.taiga.createUserStory({ $, data: { subject: this.subject, description: this.description, project: this.projectId, status: this.status, assigned_to: this.assignedTo, tags: parseObject(this.tags), backlog_order: this.backlogOrder, client_requirement: this.clientRequirement, is_blocked: this.isBlocked, milestone: this.milestone, points: parseObject(this.points), kanban_order: this.kanbanOrder, sprint_order: this.sprintOrder, team_requirement: this.teamRequirement, watchers: parseObject(this.watchers), }, }); $.export("$summary", `Created user story: ${response.subject}`); return response; }, };