Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions components/monday/actions/common/common-create-item.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {
capitalizeWord, getColumnOptions,
} from "../../common/utils.mjs";
import monday from "../../monday.app.mjs";

export default {
Expand All @@ -11,7 +14,7 @@ export default {
}),
],
type: "string[]",
description: "Select columns to fill",
description: "Select which item columns to set values for.",
reloadProps: true,
},
},
Expand All @@ -20,26 +23,32 @@ export default {
if (!this.columns) {
return props;
}
const columnData = await this.monday.listColumns({
boardId: +this.boardId,
});
for (const column of this.columns) {
let description;
if (column === "status") {
description = "Value for status. [Status Index Value Map](https://view.monday.com/1073554546-ad9f20a427a16e67ded630108994c11b?r=use1)";
} else if (column === "person") {
description = "The ID of the person/user to add to item";
let description, options;
options = getColumnOptions(columnData, column);
if (column === "person") {
description = "The ID of a person/user.";
} else if (column === "date4") {
description = "Enter date of item in YYYY-MM-DD format. Eg. `2022-09-02`";
description = "A date string in `YYYY-MM-DD` format, e.g. `2022-09-02`.";
} else if (options) {
description = `Select a value from the list for column "${column}".`;
} else {
description = `Value for column ${column}. See the [Column Type Reference](https://developer.monday.com/api-reference/docs/column-types-reference) to learn more about entering column type values.`;
description = `Value for column "${column}". See the [Column Type Reference](https://developer.monday.com/api-reference/reference/column-types-reference) to learn more about entering column type values.`;
}
props[column] = {
type: "string",
label: column,
label: capitalizeWord(column),
description,
options,
};
}
return props;
},
methods: {
capitalizeWord,
getEmailValue(value) {
let email = value;
if (typeof value === "string") {
Expand Down
4 changes: 2 additions & 2 deletions components/monday/actions/create-board/create-board.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import monday from "../../monday.app.mjs";
export default {
key: "monday-create-board",
name: "Create Board",
description: "Creates a new board. [See the documentation](https://api.developer.monday.com/docs/boards#create-a-board)",
description: "Creates a new board. [See the documentation](https://developer.monday.com/api-reference/reference/boards#create-a-board)",
type: "action",
version: "0.0.7",
version: "0.0.8",
props: {
monday,
boardName: {
Expand Down
10 changes: 5 additions & 5 deletions components/monday/actions/create-column/create-column.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "Create Column",
description: "Creates a column. [See the documentation](https://developer.monday.com/api-reference/reference/columns#create-a-column)",
type: "action",
version: "0.0.8",
version: "0.0.9",
props: {
monday,
boardId: {
Expand All @@ -18,19 +18,19 @@ export default {
title: {
type: "string",
label: "Title",
description: "The new column's title.",
description: "The title of the new column.",
},
columnType: {
type: "string",
label: "Column Type",
description: "The new column's title",
description: "The type of the new column.",
options: constants.COLUMN_TYPE_OPTIONS,
reloadProps: true,
},
description: {
type: "string",
label: "Description",
description: "The column's description.",
description: "The description of the new column.",
optional: true,
},
},
Expand All @@ -39,7 +39,7 @@ export default {
const defaults = {
type: "string",
label: "Defaults",
description: "The new column's defaults. For use with column types `status` or `dropdown`. [See the documentation](https://developer.monday.com/api-reference/reference/columns#create-a-status-or-dropdown-column-with-custom-labels) for additional information.",
description: "The new column's defaults. For use with column types `status` or `dropdown`. [See the documentation](https://developer.monday.com/api-reference/reference/columns#create-a-status-or-dropdown-column-with-custom-labels) for more information.",
optional: true,
};
if (this.columnType === "status") {
Expand Down
4 changes: 2 additions & 2 deletions components/monday/actions/create-group/create-group.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import monday from "../../monday.app.mjs";
export default {
key: "monday-create-group",
name: "Create Group",
description: "Creates a new group in a specific board. [See the documentation](https://api.developer.monday.com/docs/groups-queries#create-a-group)",
description: "Creates a new group in a specific board. [See the documentation](https://developer.monday.com/api-reference/reference/groups#create-a-group)",
type: "action",
version: "0.0.8",
version: "0.0.9",
props: {
monday,
boardId: {
Expand Down
4 changes: 2 additions & 2 deletions components/monday/actions/create-item/create-item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export default {
...commonCreateItem,
key: "monday-create-item",
name: "Create Item",
description: "Creates an item. [See the documentation](https://api.developer.monday.com/docs/items-queries#create-an-item)",
description: "Creates an item. [See the documentation](https://developer.monday.com/api-reference/reference/items#create-an-item)",
type: "action",
version: "0.0.10",
version: "0.1.0",
props: {
monday,
boardId: {
Expand Down
6 changes: 3 additions & 3 deletions components/monday/actions/create-subitem/create-subitem.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "Create Subitem",
description: "Creates a subitem. [See the documentation](https://developer.monday.com/api-reference/reference/subitems#create-a-subitem)",
type: "action",
version: "0.0.3",
version: "0.1.0",
props: {
monday,
boardId: {
Expand All @@ -26,14 +26,14 @@ export default {
}),
],
optional: false,
description: "The parent item's unique identifier",
description: "Select a parent item or provide an item ID.",
},
itemName: {
propDefinition: [
monday,
"itemName",
],
description: "The new subitem's name",
description: "The new subitem's name.",
},
...commonCreateItem.props,
},
Expand Down
4 changes: 2 additions & 2 deletions components/monday/actions/create-update/create-update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "Create an Update",
description: "Creates a new update. [See the documentation](https://developer.monday.com/api-reference/reference/updates#create-an-update)",
type: "action",
version: "0.0.10",
version: "0.0.11",
props: {
monday,
updateBody: {
Expand All @@ -33,7 +33,7 @@ export default {
},
parentId: {
label: "Parent Update ID",
description: "The parent post identifier",
description: "Select a parent update or provide an update ID.",
propDefinition: [
monday,
"updateId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export default {
...common,
key: "monday-get-column-values",
name: "Get Column Values",
description: "Return values of a specific column or columns for a board item. [See the documentation](https://developer.monday.com/api-reference/docs/column-values-v2)",
version: "0.0.5",
description: "Return values of specific column(s) for a board item. [See the documentation](https://developer.monday.com/api-reference/reference/column-values-v2)",
version: "0.0.6",
type: "action",
props: {
...common.props,
Expand All @@ -29,7 +29,7 @@ export default {
],
type: "string[]",
label: "Columns",
description: "Return data from the specified column(s)",
description: "Select the column(s) to return data from.",
optional: true,
},
},
Expand All @@ -49,7 +49,7 @@ export default {
throw new Error(response.errors[0].message);
}

$.export("$summary", `Successfully retrieved column values for item with ID ${this.itemId}.`);
$.export("$summary", `Successfully retrieved column values for item with ID ${this.itemId}`);

return this.formatColumnValues(response.data.items);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { getColumnOptions } from "../../common/utils.mjs";
import common from "../common/column-values.mjs";

export default {
...common,
key: "monday-get-items-by-column-value",
name: "Get Items By Column Value",
description: "Searches a column for items matching a value. [See the documentation](https://developer.monday.com/api-reference/docs/items-page-by-column-values)",
version: "0.0.5",
description: "Searches a column for items matching a value. [See the documentation](https://developer.monday.com/api-reference/reference/items-page-by-column-values)",
version: "0.1.0",
type: "action",
props: {
...common.props,
Expand All @@ -18,12 +19,26 @@ export default {
}),
],
description: "The column to search",
reloadProps: true,
},
value: {
type: "string",
label: "Value",
description: "The value to serach for. [See documentation](https://developer.monday.com/api-reference/docs/items-by-column-values#supported-limited-support-and-unsupported-columns) for additional information about column values.",
},
},
async additionalProps() {
const columnData = await this.monday.listColumns({
boardId: +this.boardId,
});

const options = getColumnOptions(columnData, this.columnId);

return {
value: {
type: "string",
label: "Value",
description: `The value to search for.${options
? ""
: " [See the documentation](https://developer.monday.com/api-reference/reference/items-page-by-column-values#supported-and-unsupported-columns) for additional information about column values."} `,
options,
},
};
},
async run({ $ }) {
const response = await this.monday.getItemsByColumnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
import { axios } from "@pipedream/platform";
import fs from "fs";
import FormData from "form-data";
import { getColumnOptions } from "../../common/utils.mjs";

export default {
...common,
key: "monday-update-column-values",
name: "Update Column Values",
description: "Update multiple column values of an item. [See the documentation](https://developer.monday.com/api-reference/docs/columns#change-multiple-column-values)",
version: "0.0.5",
description: "Update multiple column values of an item. [See the documentation](https://developer.monday.com/api-reference/reference/columns#change-multiple-column-values)",
version: "0.1.0",
type: "action",
props: {
...common.props,
updateInfoBox: {

Check warning on line 16 in components/monday/actions/update-column-values/update-column-values.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop updateInfoBox must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 16 in components/monday/actions/update-column-values/update-column-values.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop updateInfoBox must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "See the [Column types reference](https://developer.monday.com/api-reference/reference/column-types-reference) to find the proper data structures for supported column types.",
},
boardId: {

Check warning on line 21 in components/monday/actions/update-column-values/update-column-values.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop boardId must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 21 in components/monday/actions/update-column-values/update-column-values.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop boardId must have a description. See https://pipedream.com/docs/components/guidelines/#props
...common.props.boardId,
description: "The board's unique identifier. See the [Column types reference](https://developer.monday.com/api-reference/docs/column-types-reference) to find the proper data structures for supported column types.",
reloadProps: true,
},
itemId: {
Expand All @@ -30,14 +35,19 @@
},
async additionalProps() {
const props = {};
if (this.boardId) {
const columns = await this.getColumns(this.boardId);
const { boardId } = this;
if (boardId) {
const columns = await this.monday.listColumns({
boardId: +boardId,
});
for (const column of columns) {
props[column.id] = {
const id = column.id;
props[id] = {
type: "string",
label: column.title,
description: `The value for column ${column.title}`,
description: `The value for the "${column.title}" column (\`${id}\`)`,
optional: true,
options: getColumnOptions(columns, id),
};
if (column.type === "file") {
props[column.id].description += ". The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import monday from "../../monday.app.mjs";
export default {
key: "monday-update-item-name",
name: "Update Item Name",
description: "Update an item's name. [See the documentation](https://api.developer.monday.com/docs/item-name)",
description: "Update an item's name. [See the documentation](https://developer.monday.com/api-reference/reference/columns#change-multiple-column-values)",
type: "action",
version: "0.0.9",
version: "0.0.10",
props: {
monday,
boardId: {
Expand Down
11 changes: 11 additions & 0 deletions components/monday/common/queries.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,23 @@ export default {
boards (ids: [$boardId]) {
columns {
id
settings_str
title
type
}
}
}
`,
listColumnOptions: `
query listColumnOptions ($boardId: ID!) {
boards (ids: [$boardId]) {
columns {
id
title
}
}
}
`,
listUsers: `
query {
users (
Expand Down
33 changes: 30 additions & 3 deletions components/monday/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function emptyStrToUndefined(value) {
const trimmed = typeof(value) === "string" && value.trim();
const trimmed = typeof value === "string" && value.trim();
return trimmed === ""
? undefined
: value;
}

function strinfied(value) {
return typeof(value) === "object"
return typeof value === "object"
? JSON.stringify(value)
: emptyStrToUndefined(value);
}
Expand All @@ -18,11 +18,38 @@ function strNumber(value) {
}

function toNumber(value) {
return typeof(value) === "number"
return typeof value === "number"
? value
: strNumber(value);
}

export function capitalizeWord(str) {
return str.slice(0, 1).toUpperCase() + str.slice(1);
}
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation to capitalizeWord function.

The function should handle edge cases like null, undefined, or empty strings to prevent runtime errors.

 export function capitalizeWord(str) {
+  if (!str) return str;
   return str.slice(0, 1).toUpperCase() + str.slice(1);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function capitalizeWord(str) {
return str.slice(0, 1).toUpperCase() + str.slice(1);
}
export function capitalizeWord(str) {
if (!str) return str;
return str.slice(0, 1).toUpperCase() + str.slice(1);
}


export function getColumnOptions(allColumnData, columnId) {
const columnOptions = allColumnData.find(
({ id }) => id === columnId,
)?.settings_str;
if (columnOptions) {
try {
return Object.entries(JSON.parse(columnOptions).labels).map(
([
value,
label,
]) => ({
label: label !== ""
? label
: value,
value,
}),
);
} catch (err) {
console.log(`Error parsing options for column "${columnId}": ${err}`);
}
}
}

export default {
emptyStrToUndefined,
strinfied,
Expand Down
Loading
Loading