-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathupdate-field.mjs
66 lines (62 loc) · 1.61 KB
/
update-field.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import common from "../common/common.mjs";
import { ConfigurationError } from "@pipedream/platform";
export default {
key: "airtable_oauth-update-field",
name: "Update Field",
description: "Update an existing field in a table. [See the documentation](https://airtable.com/developers/web/api/update-field)",
version: "0.0.11",
type: "action",
props: {
...common.props,
fieldId: {
propDefinition: [
common.props.airtable,
"sortFieldId",
({
baseId, tableId,
}) => ({
baseId: baseId.value,
tableId: tableId.value,
}),
],
label: "Field ID",
description: "The field to update",
optional: false,
},
name: {
type: "string",
label: "Name",
description: "The new name of the field",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "The new description of the field",
optional: true,
},
},
async run({ $ }) {
if (!this.name && !this.description) {
throw new ConfigurationError("At least one of `Name` or `Description` must be provided.");
}
const data = {};
if (this.name) {
data.name = this.name;
}
if (this.description) {
data.description = this.description;
}
const response = await this.airtable.updateField({
baseId: this.baseId.value,
tableId: this.tableId.value,
fieldId: this.fieldId,
data,
$,
});
if (response) {
$.export("$summary", `Successfully updated field with ID ${response.id}.`);
}
return response;
},
};