-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trello: Improve/Migrate legacy Trello components
- Loading branch information
Showing
57 changed files
with
1,642 additions
and
1,648 deletions.
There are no files selected for viewing
73 changes: 0 additions & 73 deletions
73
components/trello/actions/add-attachment-to-card-via-url/add-attachment-to-card-via-url.mjs
This file was deleted.
Oops, something went wrong.
128 changes: 128 additions & 0 deletions
128
components/trello/actions/add-attachment-to-card/add-attachment-to-card.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
import fs from "fs"; | ||
import FormData from "form-data"; | ||
import common from "../common.mjs"; | ||
|
||
export default { | ||
...common, | ||
key: "trello-add-attachment-to-card", | ||
name: "Add Attachment To Card", | ||
description: "Adds a file attachment on a card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-post)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
...common.props, | ||
board: { | ||
propDefinition: [ | ||
common.props.app, | ||
"board", | ||
], | ||
}, | ||
cardId: { | ||
propDefinition: [ | ||
common.props.app, | ||
"cards", | ||
(c) => ({ | ||
board: c.board, | ||
}), | ||
], | ||
type: "string", | ||
label: "Card", | ||
description: "The ID of the Card to add the Attachment to", | ||
optional: false, | ||
}, | ||
name: { | ||
propDefinition: [ | ||
common.props.app, | ||
"name", | ||
], | ||
}, | ||
url: { | ||
propDefinition: [ | ||
common.props.app, | ||
"url", | ||
], | ||
optional: true, | ||
}, | ||
mimeType: { | ||
propDefinition: [ | ||
common.props.app, | ||
"mimeType", | ||
], | ||
}, | ||
setCover: { | ||
type: "boolean", | ||
label: "Set Cover?", | ||
description: "Determines whether to use the new attachment as a cover for the Card", | ||
default: false, | ||
}, | ||
file: { | ||
type: "string", | ||
label: "File Path", | ||
description: "The path to the file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory). If you provide a file path, the **File Attachment URL** field will be ignored.", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
...common.methods, | ||
addAttachmentToCard({ | ||
cardId, ...args | ||
} = {}) { | ||
return this.app.post({ | ||
path: `/cards/${cardId}/attachments`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
addAttachmentToCard, | ||
cardId, | ||
name, | ||
url, | ||
mimeType, | ||
setCover, | ||
file, | ||
} = this; | ||
let response; | ||
|
||
if (file && !file?.startsWith("/tmp")) { | ||
throw new ConfigurationError("The file path must be in the `/tmp` directory"); | ||
} | ||
|
||
if (file) { | ||
const data = new FormData(); | ||
data.append("file", fs.createReadStream(file)); | ||
|
||
response = await addAttachmentToCard({ | ||
$, | ||
cardId, | ||
params: { | ||
name, | ||
mimeType, | ||
setCover, | ||
}, | ||
headers: { | ||
"Content-Type": `multipart/form-data; boundary=${data.getBoundary()}`, | ||
...data.getHeaders(), | ||
}, | ||
data, | ||
}); | ||
|
||
} else { | ||
response = await addAttachmentToCard({ | ||
$, | ||
cardId, | ||
params: { | ||
url, | ||
name, | ||
mimeType, | ||
setCover, | ||
}, | ||
}); | ||
} | ||
|
||
$.export("$summary", `Successfully added attachement to card ${cardId}`); | ||
return response; | ||
}, | ||
}; |
94 changes: 56 additions & 38 deletions
94
components/trello/actions/add-checklist/add-checklist.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,86 @@ | ||
// legacy_hash_id: a_WYieM3 | ||
import { axios } from "@pipedream/platform"; | ||
import app from "../../trello.app.mjs"; | ||
|
||
export default { | ||
key: "trello-add-checklist", | ||
name: "Create a Checklist", | ||
description: "Adds a new checklist to a card.", | ||
version: "0.1.3", | ||
description: "Adds a new checklist to a card. [See the documentation](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-checklists-post).", | ||
version: "0.2.0", | ||
type: "action", | ||
props: { | ||
trello: { | ||
type: "app", | ||
app: "trello", | ||
app, | ||
boardId: { | ||
propDefinition: [ | ||
app, | ||
"board", | ||
], | ||
}, | ||
id: { | ||
cardId: { | ||
type: "string", | ||
label: "Card ID", | ||
description: "The ID of the card.", | ||
optional: false, | ||
propDefinition: [ | ||
app, | ||
"cards", | ||
({ boardId }) => ({ | ||
board: boardId, | ||
}), | ||
], | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Checklist Name", | ||
description: "The name of the checklist.", | ||
optional: true, | ||
}, | ||
idChecklistSource: { | ||
type: "string", | ||
description: "The ID of a source checklist to copy into the new one.", | ||
optional: true, | ||
propDefinition: [ | ||
app, | ||
"checklist", | ||
({ boardId }) => ({ | ||
board: boardId, | ||
}), | ||
], | ||
}, | ||
pos: { | ||
type: "string", | ||
label: "Position", | ||
description: "The position of the checklist on the card. One of: top, bottom, or a positive number.", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
addChecklist({ | ||
cardId, ...args | ||
} = {}) { | ||
return this.app.post({ | ||
path: `/cards/${cardId}/checklists`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const oauthSignerUri = this.trello.$auth.oauth_signer_uri; | ||
|
||
let id = this.id; | ||
const trelloParams = [ | ||
"name", | ||
"idChecklistSource", | ||
"pos", | ||
]; | ||
let p = this; | ||
|
||
const queryString = trelloParams.filter((param) => p[param]).map((param) => `${param}=${p[param]}`) | ||
.join("&"); | ||
|
||
const config = { | ||
url: `https://api.trello.com/1/cards/${id}/checklists?${queryString}`, | ||
method: "POST", | ||
data: "", | ||
}; | ||
const { | ||
addChecklist, | ||
cardId, | ||
name, | ||
idChecklistSource, | ||
pos, | ||
} = this; | ||
|
||
const token = { | ||
key: this.trello.$auth.oauth_access_token, | ||
secret: this.trello.$auth.oauth_refresh_token, | ||
}; | ||
const response = await addChecklist({ | ||
$, | ||
cardId, | ||
params: { | ||
name, | ||
idChecklistSource, | ||
pos, | ||
}, | ||
}); | ||
|
||
const signConfig = { | ||
token, | ||
oauthSignerUri, | ||
}; | ||
$.export("$summary", "Successfully added checklist."); | ||
|
||
const resp = await axios($, config, signConfig); | ||
return resp; | ||
return response; | ||
}, | ||
}; |
Oops, something went wrong.