Add Activepieces integration for workflow automation
- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import mondaySdk from 'monday-sdk-js';
|
||||
import { MondayClientSdk } from 'monday-sdk-js/types/client-sdk.interface';
|
||||
import { Board, MondayColumn, User } from './models';
|
||||
import { mondayGraphQLMutations } from './mutations';
|
||||
import { mondayGraphQLQueries } from './queries';
|
||||
export class mondayClient {
|
||||
private client: MondayClientSdk;
|
||||
constructor(apiKey: string) {
|
||||
this.client = mondaySdk();
|
||||
this.client.setToken(apiKey);
|
||||
this.client.setApiVersion('2023-10');
|
||||
}
|
||||
async listWorkspcaes() {
|
||||
return await this.client.api<{
|
||||
workspaces: { id: string; name: string }[];
|
||||
}>(mondayGraphQLQueries.listWorkspaces);
|
||||
}
|
||||
async listWorkspaceBoards(variables: object) {
|
||||
return await this.client.api<{
|
||||
boards: { id: string; name: string; type: string }[];
|
||||
}>(mondayGraphQLQueries.listWorkspaceBoards, { variables: variables });
|
||||
}
|
||||
async listBoardGroups(variables: object) {
|
||||
return await this.client.api<{ boards: Board[] }>(
|
||||
mondayGraphQLQueries.listBoardGroups,
|
||||
{ variables: variables }
|
||||
);
|
||||
}
|
||||
async listBoardColumns(variables: object) {
|
||||
return await this.client.api<{ boards: { columns: MondayColumn[] }[] }>(
|
||||
mondayGraphQLQueries.listBoardColumns,
|
||||
{ variables: variables }
|
||||
);
|
||||
}
|
||||
async listBoardItems(variables: object) {
|
||||
return await this.client.api<{ boards: Board[] }>(
|
||||
mondayGraphQLQueries.listBoardItems,
|
||||
{ variables: variables }
|
||||
);
|
||||
}
|
||||
async createItem(variables: object) {
|
||||
return await this.client.api(mondayGraphQLMutations.createItem, {
|
||||
variables: variables,
|
||||
});
|
||||
}
|
||||
async updateItem(variables: object) {
|
||||
return await this.client.api(mondayGraphQLMutations.updateItem, {
|
||||
variables: variables,
|
||||
});
|
||||
}
|
||||
async createWebhook(variables: object) {
|
||||
return await this.client.api<{ id: string; board_id: string }>(
|
||||
mondayGraphQLMutations.createWebhook,
|
||||
{
|
||||
variables: variables,
|
||||
}
|
||||
);
|
||||
}
|
||||
async deleteWebhook(variables: object) {
|
||||
return await this.client.api(mondayGraphQLMutations.deleteWebhook, {
|
||||
variables: variables,
|
||||
});
|
||||
}
|
||||
async listUsers() {
|
||||
return await this.client.api<{ users: User[] }>(
|
||||
mondayGraphQLQueries.listUsers
|
||||
);
|
||||
}
|
||||
async getBoardItemValues(variables: object) {
|
||||
return await this.client.api<{ boards: Board[] }>(
|
||||
mondayGraphQLQueries.getBoardItemValues,
|
||||
{ variables: variables }
|
||||
);
|
||||
}
|
||||
async getItemColumnValues(variables: object) {
|
||||
return await this.client.api<{ boards: Board[] }>(
|
||||
mondayGraphQLQueries.getItemColumnValues,
|
||||
{
|
||||
variables: variables,
|
||||
}
|
||||
);
|
||||
}
|
||||
async createColumn(variables: object) {
|
||||
return await this.client.api<{ id: string }>(
|
||||
mondayGraphQLMutations.createColumn,
|
||||
{ variables: variables }
|
||||
);
|
||||
}
|
||||
async createGroup(variables: object) {
|
||||
return await this.client.api<{ id: string }>(
|
||||
mondayGraphQLMutations.createGroup,
|
||||
{ variables: variables }
|
||||
);
|
||||
}
|
||||
async createUpdate(variables: object) {
|
||||
return await this.client.api<{ id: string }>(
|
||||
mondayGraphQLMutations.createUpdate,
|
||||
{ variables: variables }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
export const enum MondayColumnType {
|
||||
AUTO_NUMBER = 'auto_number',
|
||||
BOARD_RELATION = 'board_relation',
|
||||
BUTTON = 'button',
|
||||
CHECKBOX = 'checkbox',
|
||||
COLOR_PICKER = 'color_picker',
|
||||
COUNTRY = 'country',
|
||||
CREATION_LOG = 'creation_log',
|
||||
DATE = 'date',
|
||||
DEPENDENCY = 'dependency',
|
||||
DOC = 'doc',
|
||||
DROPDOWN = 'dropdown',
|
||||
EMAIL = 'email',
|
||||
FILE = 'file',
|
||||
FORMULA = 'formula',
|
||||
HOUR = 'hour',
|
||||
ITEM_ASSIGNEES = 'item_assignees',
|
||||
ITEM_ID = 'item_id',
|
||||
LAST_UPDATED = 'last_updated',
|
||||
LINK = 'link',
|
||||
LOCATION = 'location',
|
||||
LONG_TEXT = 'long_text',
|
||||
MIRROR = 'mirror',
|
||||
NAME = 'name',
|
||||
NUMBERS = 'numbers',
|
||||
PHONE = 'phone',
|
||||
PEOPLE = 'people',
|
||||
PROGRESS = 'progress',
|
||||
RATING = 'rating',
|
||||
STATUS = 'status',
|
||||
SUBTASKS = 'subtasks',
|
||||
TAGS = 'tags',
|
||||
TEAM = 'team',
|
||||
TEXT = 'text',
|
||||
TIMELINE = 'timeline',
|
||||
TIME_TRACKING = 'time_tracking',
|
||||
VOTE = 'vote',
|
||||
WEEK = 'week',
|
||||
WORLD_CLOCK = 'world_clock',
|
||||
UNSUPPORTED = 'unsupported',
|
||||
}
|
||||
|
||||
export const enum MondayWebhookEventType {
|
||||
CHANGE_COLUMN_VALUE = 'change_column_value',
|
||||
CHANGE_STATUS_COLUMN_VALUE = 'change_status_column_value',
|
||||
CHANGE_SUBITEM_COLUMN_VALUE = 'change_subitem_column_value',
|
||||
CHANGE_SPECIFIC_COLUMN_VALUE = 'change_specific_column_value',
|
||||
CHANGE_NAME = 'change_name',
|
||||
CREATE_ITEM = 'create_item',
|
||||
ITEM_ARCHIVED = 'item_archived',
|
||||
ITEM_DELETED = 'item_deleted',
|
||||
ITEM_MOVED_TO_ANY_GROUP = 'item_moved_to_any_group',
|
||||
ITEM_MOVED_TO_SPECIFIC_GROUP = 'item_moved_to_specific_group',
|
||||
ITEM_RESTORED = 'item_restored',
|
||||
CREATE_SUBITEM = 'create_subitem',
|
||||
CHANGE_SUBITEM_NAME = 'change_subitem_name',
|
||||
MOVE_SUBITEM = 'move_subitem',
|
||||
SUBITEM_ARCHIVED = 'subitem_archived',
|
||||
SUBITEM_DELETED = 'subitem_deleted',
|
||||
CREATE_COLUMN = 'create_column',
|
||||
CREATE_UPDATE = 'create_update',
|
||||
EDIT_UPDATE = 'edit_update',
|
||||
DELETE_UPDATE = 'delete_update',
|
||||
CREATE_SUBITEM_UPDATE = 'create_subitem_update',
|
||||
}
|
||||
export const enum BoardType {
|
||||
BOARD = 'board',
|
||||
SUB_ITEMS_BOARD = 'sub_items_board',
|
||||
}
|
||||
export const MondayNotWritableColumnType = [
|
||||
MondayColumnType.UNSUPPORTED,
|
||||
MondayColumnType.AUTO_NUMBER,
|
||||
MondayColumnType.NAME,
|
||||
MondayColumnType.COLOR_PICKER,
|
||||
MondayColumnType.BUTTON,
|
||||
MondayColumnType.MIRROR,
|
||||
MondayColumnType.SUBTASKS,
|
||||
MondayColumnType.ITEM_ID,
|
||||
MondayColumnType.CREATION_LOG,
|
||||
MondayColumnType.FILE,
|
||||
MondayColumnType.FORMULA,
|
||||
MondayColumnType.DOC,
|
||||
MondayColumnType.LAST_UPDATED,
|
||||
MondayColumnType.PROGRESS,
|
||||
MondayColumnType.TAGS,
|
||||
MondayColumnType.TIME_TRACKING,
|
||||
MondayColumnType.VOTE,
|
||||
];
|
||||
|
||||
export const COLUMN_TYPE_OPTIONS = [
|
||||
{
|
||||
label: 'Auto Number',
|
||||
value: MondayColumnType.AUTO_NUMBER,
|
||||
},
|
||||
{
|
||||
label: 'Color Picker',
|
||||
value: MondayColumnType.COLOR_PICKER,
|
||||
},
|
||||
{
|
||||
label: 'Checkbox',
|
||||
value: MondayColumnType.CHECKBOX,
|
||||
},
|
||||
{
|
||||
label: 'Country',
|
||||
value: MondayColumnType.COUNTRY,
|
||||
},
|
||||
{
|
||||
label: 'Creation Log',
|
||||
value: MondayColumnType.CREATION_LOG,
|
||||
},
|
||||
{
|
||||
label: 'Date',
|
||||
value: MondayColumnType.DATE,
|
||||
},
|
||||
{
|
||||
label: 'Dropdown',
|
||||
value: MondayColumnType.DROPDOWN,
|
||||
},
|
||||
{
|
||||
label: 'Email',
|
||||
value: MondayColumnType.EMAIL,
|
||||
},
|
||||
{
|
||||
label: 'Hour',
|
||||
value: MondayColumnType.HOUR,
|
||||
},
|
||||
{
|
||||
label: 'Item ID',
|
||||
value: MondayColumnType.ITEM_ID,
|
||||
},
|
||||
{
|
||||
label: 'Last Updated',
|
||||
value: MondayColumnType.LAST_UPDATED,
|
||||
},
|
||||
{
|
||||
label: 'Link',
|
||||
value: MondayColumnType.LINK,
|
||||
},
|
||||
{
|
||||
label: 'Location',
|
||||
value: MondayColumnType.LOCATION,
|
||||
},
|
||||
{
|
||||
label: 'Long Text',
|
||||
value: MondayColumnType.LONG_TEXT,
|
||||
},
|
||||
{
|
||||
label: 'Numbers',
|
||||
value: MondayColumnType.NUMBERS,
|
||||
},
|
||||
{
|
||||
label: 'People',
|
||||
value: MondayColumnType.PEOPLE,
|
||||
},
|
||||
{
|
||||
label: 'Phone',
|
||||
value: MondayColumnType.PHONE,
|
||||
},
|
||||
{
|
||||
label: 'Progress Tracking',
|
||||
value: MondayColumnType.PROGRESS,
|
||||
},
|
||||
{
|
||||
label: 'Rating',
|
||||
value: MondayColumnType.RATING,
|
||||
},
|
||||
{
|
||||
label: 'Status',
|
||||
value: MondayColumnType.STATUS,
|
||||
},
|
||||
{
|
||||
label: 'Tags',
|
||||
value: MondayColumnType.TAGS,
|
||||
},
|
||||
{
|
||||
label: 'Text',
|
||||
value: MondayColumnType.TEXT,
|
||||
},
|
||||
{
|
||||
label: 'Timeline',
|
||||
value: MondayColumnType.TIMELINE,
|
||||
},
|
||||
{
|
||||
label: 'Time Tracking',
|
||||
value: MondayColumnType.TIME_TRACKING,
|
||||
},
|
||||
{
|
||||
label: 'Vote',
|
||||
value: MondayColumnType.VOTE,
|
||||
},
|
||||
{
|
||||
label: 'Week',
|
||||
value: MondayColumnType.WEEK,
|
||||
},
|
||||
{
|
||||
label: 'World Clock',
|
||||
value: MondayColumnType.WORLD_CLOCK,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,374 @@
|
||||
import {
|
||||
DynamicPropsValue,
|
||||
Property,
|
||||
} from '@activepieces/pieces-framework';
|
||||
import { isEmpty } from '@activepieces/shared';
|
||||
import dayjs from 'dayjs';
|
||||
import { MondayColumnType } from './constants';
|
||||
import { ColumnValue, MondayColumn } from './models';
|
||||
|
||||
type ColumnIdTypeMap = {
|
||||
[key: string]: string;
|
||||
};
|
||||
export function generateColumnIdTypeMap(
|
||||
columns: MondayColumn[]
|
||||
): ColumnIdTypeMap {
|
||||
const result: ColumnIdTypeMap = {};
|
||||
for (const column of columns) {
|
||||
result[column.id] = column.type;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// creates activepiece prop type for monday column
|
||||
export const convertMondayColumnToActivepiecesProp = (column: MondayColumn) => {
|
||||
switch (column.type) {
|
||||
case MondayColumnType.CHECKBOX:
|
||||
return Property.Checkbox({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
});
|
||||
case MondayColumnType.BOARD_RELATION:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
description:
|
||||
'A list of item IDs to connect with. The items must be on boards that are connected to the column. Example: [125345, 5846475]',
|
||||
required: false,
|
||||
});
|
||||
case MondayColumnType.COUNTRY:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `The ISO 2-letter code and the country's name are separated by a dash. Example: US-United States`,
|
||||
});
|
||||
case MondayColumnType.DATE:
|
||||
return Property.DateTime({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: 'Use YYYY-MM-DD HH:mm:ss format.',
|
||||
});
|
||||
case MondayColumnType.DEPENDENCY:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
description:
|
||||
'A list of item IDs from the same board. Example: [188392, 20339]',
|
||||
required: false,
|
||||
});
|
||||
case MondayColumnType.DROPDOWN: {
|
||||
const labels: { id: string; name: string }[] = JSON.parse(
|
||||
column.settings_str
|
||||
).labels;
|
||||
return Property.StaticMultiSelectDropdown({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
options: {
|
||||
disabled: false,
|
||||
options:
|
||||
labels.length > 0
|
||||
? labels.map((label) => {
|
||||
return {
|
||||
label: label.name,
|
||||
value: label.name,
|
||||
};
|
||||
})
|
||||
: [],
|
||||
},
|
||||
});
|
||||
}
|
||||
case MondayColumnType.EMAIL:
|
||||
case MondayColumnType.LINK:
|
||||
case MondayColumnType.TEXT:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
});
|
||||
case MondayColumnType.HOUR:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `Represent time in 24-hour format, like '16:30' or '2:00', ensuring removal of leading zeroes from data (e.g., send '9' instead of '09').`,
|
||||
});
|
||||
case MondayColumnType.LOCATION:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `Enter location details in the following format: **latitude|longitude|address(optional)**. For example: "37.7749|-122.4194|San Francisco, CA, USA."`,
|
||||
});
|
||||
case MondayColumnType.LONG_TEXT:
|
||||
return Property.LongText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
});
|
||||
case MondayColumnType.NUMBERS:
|
||||
return Property.Number({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
});
|
||||
case MondayColumnType.PHONE:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `Enter your phone number along with the country's ISO 2-letter code, separated by a dash. For ezample, 1234567890-US.`,
|
||||
});
|
||||
case MondayColumnType.RATING:
|
||||
return Property.Number({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `A number between 1 and 5.For example, 3.`,
|
||||
});
|
||||
case MondayColumnType.STATUS: {
|
||||
const labels = JSON.parse(column.settings_str).labels;
|
||||
const options: { label: string; value: string }[] = [];
|
||||
Object.keys(labels).forEach((key) => {
|
||||
if (labels[key] !== '') {
|
||||
options.push({ value: labels[key], label: labels[key] });
|
||||
}
|
||||
});
|
||||
return Property.StaticDropdown({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
options: {
|
||||
disabled: false,
|
||||
options: options,
|
||||
},
|
||||
});
|
||||
}
|
||||
case MondayColumnType.TIMELINE:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `Enter the start and end dates in the YYYY-MM-DD format, separated by a symbol of semicolon(;) symbol. For example: '2022-01-01;2022-12-31`,
|
||||
});
|
||||
case MondayColumnType.WEEK:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `Enter the start and end dates in the YYYY-MM-DD format, separated by a symbol of semicolon(;) symbol. The dates must be 7 days apart (inclusive of the first and last date).\n For example: '2019-06-10;2019-06-16`,
|
||||
|
||||
});
|
||||
case MondayColumnType.WORLD_CLOCK:
|
||||
return Property.ShortText({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
description: `Enter the timezone in the 'Continent/City' format, for example, Europe/London.`,
|
||||
});
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
export const convertPropValueToMondayColumnValue = (
|
||||
columnType: string,
|
||||
propValue: DynamicPropsValue
|
||||
) => {
|
||||
switch (columnType) {
|
||||
case MondayColumnType.CHECKBOX:
|
||||
return {
|
||||
checked: propValue ? 'true' : 'false',
|
||||
};
|
||||
case MondayColumnType.BOARD_RELATION:
|
||||
case MondayColumnType.DEPENDENCY:
|
||||
return {
|
||||
item_ids: JSON.parse(propValue as unknown as string),
|
||||
};
|
||||
case MondayColumnType.COUNTRY:
|
||||
return {
|
||||
countryCode: propValue.split('-')[0],
|
||||
countryName: propValue.split('-')[1],
|
||||
};
|
||||
case MondayColumnType.DATE: {
|
||||
let datevalue = dayjs(propValue as unknown as string);
|
||||
if (!datevalue.isValid()) {
|
||||
datevalue = dayjs();
|
||||
}
|
||||
return {
|
||||
date: datevalue.format('YYYY-MM-DD'),
|
||||
time: datevalue.format('HH:mm:ss'),
|
||||
};
|
||||
}
|
||||
case MondayColumnType.DROPDOWN:
|
||||
return {
|
||||
labels: propValue,
|
||||
};
|
||||
case MondayColumnType.EMAIL:
|
||||
return {
|
||||
email: propValue,
|
||||
text: propValue,
|
||||
};
|
||||
case MondayColumnType.HOUR: {
|
||||
const [hour, minute] = propValue.split(':');
|
||||
return {
|
||||
hour: Number(hour) ?? 0,
|
||||
minute: Number(minute) ?? 0,
|
||||
};
|
||||
}
|
||||
case MondayColumnType.LINK:
|
||||
return {
|
||||
url: propValue,
|
||||
text: propValue,
|
||||
};
|
||||
case MondayColumnType.LOCATION: {
|
||||
const [lat, lng, address] = propValue.split('|');
|
||||
return {
|
||||
lat: lat ?? '',
|
||||
lng: lng ?? '',
|
||||
address: address ?? '',
|
||||
};
|
||||
}
|
||||
case MondayColumnType.LONG_TEXT:
|
||||
return {
|
||||
text: propValue,
|
||||
};
|
||||
case MondayColumnType.NUMBERS:
|
||||
return String(propValue);
|
||||
case MondayColumnType.PEOPLE: {
|
||||
const res: { id: string; kind: string }[] = [];
|
||||
if (Array.isArray(propValue)) {
|
||||
propValue.forEach((person) => {
|
||||
res.push({ id: person, kind: 'person' });
|
||||
});
|
||||
}
|
||||
return {
|
||||
personsAndTeams: res,
|
||||
};
|
||||
}
|
||||
case MondayColumnType.PHONE: {
|
||||
const [phone, countryCode] = propValue.split('-');
|
||||
return {
|
||||
phone: `+${phone}`,
|
||||
countryShortName: countryCode,
|
||||
};
|
||||
}
|
||||
case MondayColumnType.RATING:
|
||||
return {
|
||||
rating: Number(propValue),
|
||||
};
|
||||
case MondayColumnType.STATUS:
|
||||
return {
|
||||
label: propValue,
|
||||
};
|
||||
case MondayColumnType.TEXT:
|
||||
return propValue;
|
||||
case MondayColumnType.TIMELINE:
|
||||
return {
|
||||
from: propValue.split(';')[0],
|
||||
to: propValue.split(';')[1],
|
||||
};
|
||||
case MondayColumnType.WEEK:
|
||||
return {
|
||||
startDate: propValue.split(';')[0],
|
||||
endDate: propValue.split(';')[1],
|
||||
};
|
||||
case MondayColumnType.WORLD_CLOCK:
|
||||
return {
|
||||
timezone: propValue,
|
||||
};
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const parseMondayColumnValue = (columnValue: ColumnValue) => {
|
||||
switch (columnValue.type) {
|
||||
case MondayColumnType.BUTTON:
|
||||
return columnValue.label;
|
||||
case MondayColumnType.CHECKBOX:
|
||||
return JSON.parse(columnValue.value)?.checked ?? false;
|
||||
case MondayColumnType.BOARD_RELATION:
|
||||
return columnValue.linked_item_ids ?? [];
|
||||
case MondayColumnType.DEPENDENCY:
|
||||
return JSON.parse(columnValue.linked_item_ids ?? '[]');
|
||||
case MondayColumnType.SUBTASKS: {
|
||||
const res: number[] = [];
|
||||
if (!isEmpty(JSON.parse(columnValue.value))) {
|
||||
JSON.parse(columnValue.value).linkedPulseIds.map(
|
||||
(item: { linkedPulseId: number }) => {
|
||||
res.push(item.linkedPulseId);
|
||||
}
|
||||
);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
case MondayColumnType.COLOR_PICKER:
|
||||
return JSON.parse(columnValue.value)?.color.hex ?? null;
|
||||
case MondayColumnType.COUNTRY:
|
||||
return JSON.parse(columnValue.value)?.countryName ?? null;
|
||||
case MondayColumnType.CREATION_LOG:
|
||||
return JSON.parse(columnValue.value)?.created_at ?? null;
|
||||
case MondayColumnType.DATE: {
|
||||
if (isEmpty(columnValue.value)) {
|
||||
return null;
|
||||
}
|
||||
const dateTime = JSON.parse(columnValue.value);
|
||||
return `${dateTime.date} ${dateTime.time}`;
|
||||
}
|
||||
case MondayColumnType.DOC:
|
||||
return JSON.parse(columnValue.value)?.files[0].linkToFile ?? null;
|
||||
case MondayColumnType.DROPDOWN:
|
||||
return JSON.parse(columnValue.value)?.ids ?? [];
|
||||
case MondayColumnType.EMAIL:
|
||||
return JSON.parse(columnValue.value)?.email ?? null;
|
||||
case MondayColumnType.FILE:
|
||||
return columnValue.text;
|
||||
case MondayColumnType.HOUR: {
|
||||
if (isEmpty(columnValue.value)) {
|
||||
return null;
|
||||
}
|
||||
const hourTime = JSON.parse(columnValue.value);
|
||||
return `${hourTime.hour}:${hourTime.minute}`;
|
||||
}
|
||||
case MondayColumnType.ITEM_ID:
|
||||
return JSON.parse(columnValue.value)?.item_id ?? null;
|
||||
case MondayColumnType.LAST_UPDATED:
|
||||
return JSON.parse(columnValue.value).updated_at;
|
||||
case MondayColumnType.LINK:
|
||||
return JSON.parse(columnValue.value)?.url ?? null;
|
||||
case MondayColumnType.LOCATION:
|
||||
return JSON.parse(columnValue.value)?.address ?? null;
|
||||
case MondayColumnType.LONG_TEXT:
|
||||
return JSON.parse(columnValue.value)?.text ?? null;
|
||||
case MondayColumnType.MIRROR:
|
||||
return null;
|
||||
case MondayColumnType.NUMBERS:
|
||||
return Number(JSON.parse(columnValue.value));
|
||||
case MondayColumnType.PEOPLE: {
|
||||
const people: number[] = [];
|
||||
if (!isEmpty(columnValue.value)) {
|
||||
JSON.parse(columnValue.value).personsAndTeams.map(
|
||||
(item: { id: number; kind: string }) => {
|
||||
people.push(item.id);
|
||||
}
|
||||
);
|
||||
}
|
||||
return people;
|
||||
}
|
||||
case MondayColumnType.PHONE:
|
||||
return JSON.parse(columnValue.value)?.phone ?? null;
|
||||
case MondayColumnType.RATING:
|
||||
return JSON.parse(columnValue.value)?.rating ?? null;
|
||||
case MondayColumnType.STATUS:
|
||||
return columnValue.label;
|
||||
case MondayColumnType.TAGS:
|
||||
return columnValue.tags.map((item: { name: string }) => item.name);
|
||||
case MondayColumnType.TEXT:
|
||||
return JSON.parse(columnValue.value);
|
||||
case MondayColumnType.TIMELINE: {
|
||||
if (isEmpty(columnValue.value)) {
|
||||
return null;
|
||||
}
|
||||
const timeline = JSON.parse(columnValue.value);
|
||||
return { from: timeline.from, to: timeline.to };
|
||||
}
|
||||
case MondayColumnType.TIME_TRACKING:
|
||||
return JSON.parse(columnValue.value)?.duration ?? null;
|
||||
case MondayColumnType.VOTE:
|
||||
return columnValue?.vote_count ?? 0;
|
||||
case MondayColumnType.WEEK: {
|
||||
return {
|
||||
startDate: columnValue.start_date,
|
||||
endDate: columnValue.end_date,
|
||||
};
|
||||
}
|
||||
case MondayColumnType.WORLD_CLOCK:
|
||||
return JSON.parse(columnValue.value)?.timezone ?? null;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,219 @@
|
||||
import { AppConnectionValueForAuthProperty, DynamicPropsValue, Property } from '@activepieces/pieces-framework';
|
||||
import { mondayClient } from './client';
|
||||
import { MondayColumnType, MondayNotWritableColumnType } from './constants';
|
||||
import { convertMondayColumnToActivepiecesProp } from './helper';
|
||||
import { mondayAuth } from '../..';
|
||||
|
||||
export function makeClient(auth: AppConnectionValueForAuthProperty<typeof mondayAuth>): mondayClient {
|
||||
return new mondayClient(auth.secret_text);
|
||||
}
|
||||
|
||||
export const mondayCommon = {
|
||||
workspace_id: (required = true) =>
|
||||
Property.Dropdown({
|
||||
auth: mondayAuth,
|
||||
|
||||
displayName: 'Workspace ID',
|
||||
required: required,
|
||||
refreshers: [],
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'connect your account first',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
const client = makeClient(auth);
|
||||
const res = await client.listWorkspcaes();
|
||||
return {
|
||||
disabled: false,
|
||||
options: res.data.workspaces.map((workspace) => {
|
||||
return {
|
||||
label: workspace.name,
|
||||
value: workspace.id,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
}),
|
||||
board_id: (required = true) =>
|
||||
Property.Dropdown({
|
||||
auth: mondayAuth,
|
||||
displayName: 'Board ID',
|
||||
required: required,
|
||||
refreshers: ['workspace_id'],
|
||||
options: async ({ auth, workspace_id }) => {
|
||||
if (!auth || !workspace_id) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder:
|
||||
'connect your account first and select your workspace.',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
|
||||
const client = makeClient(auth);
|
||||
const res = await client.listWorkspaceBoards({
|
||||
workspaceId: workspace_id as string,
|
||||
});
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options: res.data.boards
|
||||
.filter((board) => board.type === 'board')
|
||||
.map((board) => {
|
||||
return {
|
||||
label: board.name,
|
||||
value: board.id,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
}),
|
||||
group_id: (required = false) =>
|
||||
Property.Dropdown({
|
||||
auth: mondayAuth,
|
||||
displayName: 'Board Group ID',
|
||||
required: required,
|
||||
refreshers: ['board_id'],
|
||||
options: async ({ auth, board_id }) => {
|
||||
if (!auth || !board_id) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder:
|
||||
'connect your account first and select workspace board.',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
const client = makeClient(auth);
|
||||
const res = await client.listBoardGroups({
|
||||
boardId: board_id as string,
|
||||
});
|
||||
return {
|
||||
disabled: false,
|
||||
options:
|
||||
res.data.boards.length > 0
|
||||
? res.data.boards[0]?.groups.map((group) => ({
|
||||
label: group.title,
|
||||
value: group.id,
|
||||
}))
|
||||
: [],
|
||||
};
|
||||
},
|
||||
}),
|
||||
item_id: (required = true) =>
|
||||
Property.Dropdown({
|
||||
auth: mondayAuth,
|
||||
displayName: 'Item ID',
|
||||
required: required,
|
||||
refreshers: ['board_id'],
|
||||
options: async ({ auth, board_id }) => {
|
||||
if (!auth || !board_id) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder:
|
||||
'connect your account first and select workspace board.',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
const client = makeClient(auth);
|
||||
const res = await client.listBoardItems({
|
||||
boardId: board_id as string,
|
||||
});
|
||||
|
||||
const items = res.data.boards[0]?.items_page.items;
|
||||
return {
|
||||
disabled: false,
|
||||
options: items.map((item) => {
|
||||
return {
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
}),
|
||||
columnIds: (required = true) =>
|
||||
Property.MultiSelectDropdown({
|
||||
auth: mondayAuth,
|
||||
displayName: 'Column IDs',
|
||||
description:
|
||||
'Limit data output by specifying column IDs; leave empty to display all columns.',
|
||||
required,
|
||||
refreshers: ['board_id'],
|
||||
options: async ({ auth, board_id }) => {
|
||||
if (!auth || !board_id) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder:
|
||||
'connect your account first and select workspace board.',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
const client = makeClient(auth);
|
||||
const res = await client.listBoardColumns({
|
||||
boardId: board_id as string,
|
||||
});
|
||||
return {
|
||||
disabled: false,
|
||||
options: res.data.boards[0].columns.map((column) => {
|
||||
return {
|
||||
label: column.title,
|
||||
value: column.id,
|
||||
};
|
||||
}),
|
||||
};
|
||||
},
|
||||
}),
|
||||
columnValues: Property.DynamicProperties({
|
||||
auth: mondayAuth,
|
||||
displayName: 'Columns',
|
||||
required: true,
|
||||
refreshers: ['board_id'],
|
||||
props: async ({ auth, board_id }) => {
|
||||
if (!auth || !board_id) {
|
||||
return {
|
||||
disabled: true,
|
||||
placeholder: 'connect your account first and select workspace board.',
|
||||
options: [],
|
||||
};
|
||||
}
|
||||
const fields: DynamicPropsValue = {};
|
||||
try {
|
||||
const client = makeClient(auth);
|
||||
const res = await client.listBoardColumns({
|
||||
boardId: board_id as unknown as string,
|
||||
});
|
||||
const columns = res.data.boards[0]?.columns;
|
||||
for (const column of columns) {
|
||||
if (!MondayNotWritableColumnType.includes(column.type)) {
|
||||
if (column.type === MondayColumnType.PEOPLE) {
|
||||
const userData = await client.listUsers();
|
||||
fields[column.id] = Property.StaticMultiSelectDropdown({
|
||||
displayName: column.title,
|
||||
required: false,
|
||||
options: {
|
||||
disabled: false,
|
||||
options: userData.data.users.map((user) => {
|
||||
return {
|
||||
label: `${user.name} (${user.email})`,
|
||||
value: user.id,
|
||||
};
|
||||
}),
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const prop = convertMondayColumnToActivepiecesProp(column);
|
||||
if (prop != null) fields[column.id] = prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.debug(e);
|
||||
}
|
||||
return fields;
|
||||
},
|
||||
}),
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
import { BoardType, MondayColumnType } from './constants';
|
||||
|
||||
export interface MondayColumn {
|
||||
id: string;
|
||||
title: string;
|
||||
type: MondayColumnType;
|
||||
description?: string;
|
||||
settings_str: string;
|
||||
}
|
||||
export interface ColumnValue {
|
||||
id: string;
|
||||
value: string;
|
||||
text: string;
|
||||
type: MondayColumnType;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type WorkspaceResponse = {
|
||||
data: { workspaces: Workspace[] };
|
||||
account_id: number;
|
||||
};
|
||||
|
||||
export interface Workspace {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
export interface Group {
|
||||
id: string;
|
||||
title: string;
|
||||
}
|
||||
export interface SubItem {
|
||||
id: string;
|
||||
board: Board;
|
||||
group: Group;
|
||||
subscribers: User[];
|
||||
name: string;
|
||||
email: string;
|
||||
created_at: string;
|
||||
}
|
||||
export interface Item {
|
||||
id: string;
|
||||
board: Board;
|
||||
group: Group;
|
||||
name: string;
|
||||
email: string;
|
||||
created_at: string;
|
||||
column_values: ColumnValue[];
|
||||
subitems: SubItem[];
|
||||
}
|
||||
export interface Board {
|
||||
id: string;
|
||||
name: string;
|
||||
groups: Group[];
|
||||
type: BoardType;
|
||||
items_page: { items: Item[] };
|
||||
}
|
||||
|
||||
export interface Update {
|
||||
body: string;
|
||||
id: string;
|
||||
created_at: string;
|
||||
creator: {
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
email: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export type BoardResponse = { data: { boards: Board[] }; account_id: number };
|
||||
|
||||
export interface WebhookInformation {
|
||||
id: string;
|
||||
board_id: string;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
export const mondayGraphQLMutations = {
|
||||
createItem: `
|
||||
mutation createItem(
|
||||
$itemName: String!
|
||||
$boardId: ID!
|
||||
$groupId: String
|
||||
$columnValues: JSON
|
||||
$createLabels: Boolean
|
||||
) {
|
||||
create_item(
|
||||
item_name: $itemName
|
||||
board_id: $boardId
|
||||
group_id: $groupId
|
||||
column_values: $columnValues
|
||||
create_labels_if_missing: $createLabels
|
||||
) {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
updateItem: `
|
||||
mutation updateItem($itemId: ID!, $boardId: ID!, $columnValues: JSON!) {
|
||||
change_multiple_column_values(
|
||||
item_id: $itemId
|
||||
board_id: $boardId
|
||||
column_values: $columnValues
|
||||
) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}`,
|
||||
createWebhook: `
|
||||
mutation createWebhook(
|
||||
$boardId: ID!
|
||||
$url: String!
|
||||
$event: WebhookEventType!
|
||||
$config: JSON
|
||||
) {
|
||||
create_webhook(
|
||||
board_id: $boardId
|
||||
url: $url
|
||||
event: $event
|
||||
config: $config
|
||||
) {
|
||||
id
|
||||
board_id
|
||||
}
|
||||
}`,
|
||||
deleteWebhook: `
|
||||
mutation deleteWebhook($webhookId: ID!) {
|
||||
delete_webhook(id: $webhookId) {
|
||||
id
|
||||
board_id
|
||||
}
|
||||
}`,
|
||||
createColumn: `
|
||||
mutation createColumn(
|
||||
$boardId: ID!
|
||||
$columnTitle: String!
|
||||
$columnType: ColumnType!
|
||||
) {
|
||||
create_column(
|
||||
board_id: $boardId
|
||||
title: $columnTitle
|
||||
column_type: $columnType
|
||||
) {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
createGroup: `
|
||||
mutation createGroup($boardId: ID!, $groupName: String!) {
|
||||
create_group(board_id: $boardId, group_name: $groupName) {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
createUpdate: `
|
||||
mutation createUpdate($itemId: ID!, $body: String!) {
|
||||
create_update(item_id: $itemId, body: $body) {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
};
|
||||
@@ -0,0 +1,158 @@
|
||||
export const mondayGraphQLQueries = {
|
||||
listWorkspaces: `
|
||||
query listWorkspaces($limit: Int)
|
||||
{
|
||||
workspaces(limit: $limit)
|
||||
{
|
||||
id
|
||||
name
|
||||
}
|
||||
}`,
|
||||
listWorkspaceBoards: `
|
||||
query listWorkspaceBoards($workspaceId: ID)
|
||||
{
|
||||
boards(workspace_ids: [$workspaceId], order_by: created_at)
|
||||
{
|
||||
id
|
||||
name
|
||||
type
|
||||
}
|
||||
}`,
|
||||
listBoardGroups: `
|
||||
query listGroups($boardId: ID!)
|
||||
{
|
||||
boards(ids: [$boardId])
|
||||
{
|
||||
groups{
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}`,
|
||||
listBoardColumns: `
|
||||
query listBoardColumns($boardId: ID!)
|
||||
{
|
||||
boards(ids: [$boardId])
|
||||
{
|
||||
columns{
|
||||
id
|
||||
title
|
||||
type
|
||||
settings_str
|
||||
description
|
||||
}
|
||||
}
|
||||
}`,
|
||||
listBoardItems: `
|
||||
query listBoardItems($boardId: ID!)
|
||||
{
|
||||
boards(ids: [$boardId])
|
||||
{
|
||||
items_page
|
||||
{
|
||||
items{
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
listUsers: `
|
||||
query listUsers
|
||||
{
|
||||
users(newest_first: true)
|
||||
{
|
||||
id
|
||||
name
|
||||
email
|
||||
}
|
||||
}`,
|
||||
getItemColumnValues: `
|
||||
query getItemColumnValues($boardId: ID!,$itemId: ID!,$columnIds: [String!])
|
||||
{
|
||||
boards(ids: [$boardId])
|
||||
{
|
||||
items_page(query_params: {ids: [$itemId]})
|
||||
{
|
||||
items{
|
||||
id
|
||||
name
|
||||
column_values(ids: $columnIds){
|
||||
id
|
||||
type
|
||||
value
|
||||
text
|
||||
... on ButtonValue{
|
||||
label
|
||||
}
|
||||
... on StatusValue{
|
||||
label
|
||||
}
|
||||
... on VoteValue{
|
||||
vote_count
|
||||
}
|
||||
... on TagsValue{
|
||||
tags{
|
||||
name
|
||||
}
|
||||
}
|
||||
... on BoardRelationValue {
|
||||
linked_item_ids
|
||||
}
|
||||
... on DependencyValue {
|
||||
linked_item_ids
|
||||
}
|
||||
... on WeekValue {
|
||||
start_date
|
||||
end_date
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
getBoardItemValues: `
|
||||
query getItemColumnValues($boardId: ID!,$columnIds: [String!])
|
||||
{
|
||||
boards(ids: [$boardId])
|
||||
{
|
||||
items_page(query_params: {order_by: {column_id: "__last_updated__",direction: desc}})
|
||||
{
|
||||
items{
|
||||
id
|
||||
name
|
||||
column_values(ids: $columnIds){
|
||||
id
|
||||
type
|
||||
value
|
||||
text
|
||||
... on ButtonValue{
|
||||
label
|
||||
}
|
||||
... on StatusValue{
|
||||
label
|
||||
}
|
||||
... on VoteValue{
|
||||
vote_count
|
||||
}
|
||||
... on TagsValue{
|
||||
tags{
|
||||
name
|
||||
}
|
||||
}
|
||||
... on BoardRelationValue {
|
||||
linked_item_ids
|
||||
}
|
||||
... on DependencyValue {
|
||||
linked_item_ids
|
||||
}
|
||||
... on WeekValue {
|
||||
start_date
|
||||
end_date
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
};
|
||||
Reference in New Issue
Block a user