|
| 1 | +import common from "../common/common.mjs"; |
| 2 | +import fields from "../../common/fields.mjs"; |
| 3 | + |
| 4 | +export default { |
| 5 | + ...common, |
| 6 | + key: "trello-get-board", |
| 7 | + name: "Get Board", |
| 8 | + description: "Request a single board. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-get).", |
| 9 | + version: "0.0.1", |
| 10 | + type: "action", |
| 11 | + props: { |
| 12 | + ...common.props, |
| 13 | + boardId: { |
| 14 | + propDefinition: [ |
| 15 | + common.props.app, |
| 16 | + "board", |
| 17 | + ], |
| 18 | + label: "Board ID", |
| 19 | + description: "The ID of the board to retrieve", |
| 20 | + }, |
| 21 | + actions: { |
| 22 | + propDefinition: [ |
| 23 | + common.props.app, |
| 24 | + "actions", |
| 25 | + ], |
| 26 | + }, |
| 27 | + boardStars: { |
| 28 | + type: "string", |
| 29 | + label: "Board Stars", |
| 30 | + description: "Valid values are one of: `mine` or `none`. Default is `none`.", |
| 31 | + options: [ |
| 32 | + "mine", |
| 33 | + "none", |
| 34 | + ], |
| 35 | + optional: true, |
| 36 | + }, |
| 37 | + cardPluginData: { |
| 38 | + type: "boolean", |
| 39 | + label: "Card Plugin Data", |
| 40 | + description: "Use with the cards param to include card pluginData with the response. Default is `none`.", |
| 41 | + optional: true, |
| 42 | + }, |
| 43 | + customFields: { |
| 44 | + type: "boolean", |
| 45 | + label: "Custom Fields", |
| 46 | + description: "This is a nested resource. Include custom fields in the response.", |
| 47 | + default: false, |
| 48 | + optional: true, |
| 49 | + }, |
| 50 | + fields: { |
| 51 | + type: "string[]", |
| 52 | + label: "Fields", |
| 53 | + description: "The fields of the board to be included in the response. Valid values: all or a comma-separated list of specific fields.", |
| 54 | + options: fields.board, |
| 55 | + optional: true, |
| 56 | + }, |
| 57 | + labels: { |
| 58 | + type: "string", |
| 59 | + label: "Labels", |
| 60 | + description: "This is a nested resource. Specify what labels to include in the response. One of: `all` or `none`", |
| 61 | + optional: true, |
| 62 | + options: [ |
| 63 | + "all", |
| 64 | + "none", |
| 65 | + ], |
| 66 | + }, |
| 67 | + lists: { |
| 68 | + description: "This is a nested resource. Specify what lists to include in the response.", |
| 69 | + propDefinition: [ |
| 70 | + common.props.app, |
| 71 | + "lists", |
| 72 | + ({ boardId }) => ({ |
| 73 | + board: boardId, |
| 74 | + }), |
| 75 | + ], |
| 76 | + }, |
| 77 | + members: { |
| 78 | + propDefinition: [ |
| 79 | + common.props.app, |
| 80 | + "members", |
| 81 | + ({ boardId }) => ({ |
| 82 | + boardId, |
| 83 | + }), |
| 84 | + ], |
| 85 | + }, |
| 86 | + pluginData: { |
| 87 | + type: "boolean", |
| 88 | + label: "Plugin Data", |
| 89 | + description: "Determines whether the pluginData for this board should be returned.", |
| 90 | + optional: true, |
| 91 | + }, |
| 92 | + organization: { |
| 93 | + type: "boolean", |
| 94 | + label: "Organization", |
| 95 | + description: "This is a nested resource. Include organization information in the response.", |
| 96 | + optional: true, |
| 97 | + }, |
| 98 | + organizationPluginData: { |
| 99 | + type: "boolean", |
| 100 | + label: "Organization Plugin Data", |
| 101 | + description: "Use with the organization param to include organization pluginData with the response", |
| 102 | + optional: true, |
| 103 | + }, |
| 104 | + myPrefs: { |
| 105 | + type: "boolean", |
| 106 | + label: "My Preferences", |
| 107 | + description: "Include the user's preferences for this board in the response.", |
| 108 | + optional: true, |
| 109 | + }, |
| 110 | + tags: { |
| 111 | + type: "boolean", |
| 112 | + label: "Tags", |
| 113 | + description: "Also known as collections, tags, refer to the collection(s) that a Board belongs to.", |
| 114 | + optional: true, |
| 115 | + }, |
| 116 | + }, |
| 117 | + methods: { |
| 118 | + getCommaSeparatedString(array) { |
| 119 | + return Array.isArray(array) |
| 120 | + ? array.join(",") |
| 121 | + : array; |
| 122 | + }, |
| 123 | + }, |
| 124 | + async run({ $ }) { |
| 125 | + const { |
| 126 | + app, |
| 127 | + getCommaSeparatedString, |
| 128 | + boardId, |
| 129 | + actions, |
| 130 | + boardStars, |
| 131 | + cardPluginData, |
| 132 | + customFields, |
| 133 | + fields, |
| 134 | + labels, |
| 135 | + lists, |
| 136 | + members, |
| 137 | + pluginData, |
| 138 | + organization, |
| 139 | + organizationPluginData, |
| 140 | + myPrefs, |
| 141 | + tags, |
| 142 | + } = this; |
| 143 | + |
| 144 | + const response = await app.getBoard({ |
| 145 | + $, |
| 146 | + boardId, |
| 147 | + params: { |
| 148 | + actions: getCommaSeparatedString(actions), |
| 149 | + boardStars, |
| 150 | + card_pluginData: cardPluginData, |
| 151 | + customFields, |
| 152 | + fields: getCommaSeparatedString(fields), |
| 153 | + labels: getCommaSeparatedString(labels), |
| 154 | + lists: getCommaSeparatedString(lists), |
| 155 | + members: getCommaSeparatedString(members), |
| 156 | + pluginData, |
| 157 | + organization, |
| 158 | + organizationPluginData, |
| 159 | + myPrefs, |
| 160 | + tags, |
| 161 | + }, |
| 162 | + }); |
| 163 | + |
| 164 | + $.export("$summary", `Successfully retrieved board with ID \`${response.id}\``); |
| 165 | + return response; |
| 166 | + }, |
| 167 | +}; |
0 commit comments