Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c7e887dbfa | ||
![]() |
8c0a5a3bd3 | ||
![]() |
9b00cff2d9 |
@@ -0,0 +1,98 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create column',
|
||||
key: 'createColumn',
|
||||
description: 'Creates a new column in a board.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Board',
|
||||
key: 'boardId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listBoards',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Column Title',
|
||||
key: 'columnTitle',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Column Type',
|
||||
key: 'columnType',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Button', value: 'button' },
|
||||
{ label: 'Checkbox', value: 'checkbox' },
|
||||
{ label: 'Color Picker', value: 'color_picker' },
|
||||
{ label: 'Connect Boards', value: 'board_relation' },
|
||||
{ label: 'Country', value: 'country' },
|
||||
{ label: 'Creation Log', value: 'creation_log' },
|
||||
{ label: 'Date', value: 'date' },
|
||||
{ label: 'Dependency', value: 'dependency' },
|
||||
{ label: 'Dropdown', value: 'dropdown' },
|
||||
{ label: 'Email', value: 'email' },
|
||||
{ label: 'Files', value: 'file' },
|
||||
{ label: 'Formula', value: 'formula' },
|
||||
{ label: 'Hour', value: 'hour' },
|
||||
{ label: 'Item ID', value: 'item_id' },
|
||||
{ label: 'Last Updated', value: 'last_updated' },
|
||||
{ label: 'Link', value: 'link' },
|
||||
{ label: 'Location', value: 'location' },
|
||||
{ label: 'Long Text', value: 'long_text' },
|
||||
{ label: 'Mirror', value: 'mirror' },
|
||||
{ label: 'monday Doc', value: 'doc' },
|
||||
{ label: 'Name', value: 'name' },
|
||||
{ label: 'Numbers', value: 'numbers' },
|
||||
{ label: 'People', value: 'people' },
|
||||
{ label: 'Phone', value: 'phone' },
|
||||
{ label: 'Rating', value: 'rating' },
|
||||
{ label: 'Status', value: 'status' },
|
||||
{ label: 'Tags', value: 'tags' },
|
||||
{ label: 'Text', value: 'text' },
|
||||
{ label: 'Timeline', value: 'timeline' },
|
||||
{ label: 'Time Tracking', value: 'time_tracking' },
|
||||
{ label: 'Vote', value: 'vote' },
|
||||
{ label: 'Week', value: 'week' },
|
||||
{ label: 'World Clock', value: 'world_clock' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const { boardId, columnTitle, columnType } = $.step.parameters;
|
||||
|
||||
const body = {
|
||||
query: `
|
||||
mutation{
|
||||
create_column (board_id: ${boardId}, title: "${columnTitle}", column_type: ${columnType}) {
|
||||
id
|
||||
title
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
const { data } = await $.http.post('/', body);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
112
packages/backend/src/apps/monday/actions/create-item/index.js
Normal file
112
packages/backend/src/apps/monday/actions/create-item/index.js
Normal file
@@ -0,0 +1,112 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create item',
|
||||
key: 'createItem',
|
||||
description: 'Creates a new item in a board.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Board',
|
||||
key: 'boardId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listBoards',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Group',
|
||||
key: 'groupId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
dependsOn: ['parameters.boardId'],
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listGroups',
|
||||
},
|
||||
{
|
||||
name: 'parameters.boardId',
|
||||
value: '{parameters.boardId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Item Name',
|
||||
key: 'itemName',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Subitem Names',
|
||||
key: 'subitemNames',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Subitem Name',
|
||||
key: 'subitemName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const { boardId, groupId, itemName, subitemNames } = $.step.parameters;
|
||||
const allSubitems = subitemNames.map((entry) => entry.subitemName);
|
||||
|
||||
const body = {
|
||||
query: `
|
||||
mutation {
|
||||
create_item (board_id: ${boardId}${
|
||||
groupId ? `, group_id: "${groupId}"` : ''
|
||||
}, item_name: "${itemName}") {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
const { data } = await $.http.post('/', body);
|
||||
|
||||
const itemId = data.data.create_item.id;
|
||||
|
||||
for (let subitemName of allSubitems) {
|
||||
let body = {
|
||||
query: `
|
||||
mutation {
|
||||
create_subitem (parent_item_id:${itemId}, item_name:"${subitemName}") {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
};
|
||||
|
||||
await $.http.post('/', body);
|
||||
}
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,3 +1,5 @@
|
||||
import createBoard from './create-board/index.js';
|
||||
import createColumn from './create-column/index.js';
|
||||
import createItem from './create-item/index.js';
|
||||
|
||||
export default [createBoard];
|
||||
export default [createBoard, createColumn, createItem];
|
||||
|
4
packages/backend/src/apps/monday/dynamic-data/index.js
Normal file
4
packages/backend/src/apps/monday/dynamic-data/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import listBoards from './list-boards/index.js';
|
||||
import listGroups from './list-groups/index.js';
|
||||
|
||||
export default [listBoards, listGroups];
|
@@ -0,0 +1,34 @@
|
||||
export default {
|
||||
name: 'List boards',
|
||||
key: 'listBoards',
|
||||
|
||||
async run($) {
|
||||
const boards = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const body = {
|
||||
query: `
|
||||
query {
|
||||
boards {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
};
|
||||
|
||||
const { data } = await $.http.post('/', body);
|
||||
|
||||
if (data.data.boards?.length) {
|
||||
for (const board of data.data.boards) {
|
||||
boards.data.push({
|
||||
value: board.id,
|
||||
name: board.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return boards;
|
||||
},
|
||||
};
|
@@ -0,0 +1,40 @@
|
||||
export default {
|
||||
name: 'List groups',
|
||||
key: 'listGroups',
|
||||
|
||||
async run($) {
|
||||
const groups = {
|
||||
data: [],
|
||||
};
|
||||
const boardId = $.step.parameters.parameters.boardId;
|
||||
|
||||
if (!boardId) {
|
||||
return groups;
|
||||
}
|
||||
|
||||
const body = {
|
||||
query: `query {
|
||||
boards (ids: ${boardId}) {
|
||||
groups {
|
||||
title
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
};
|
||||
|
||||
const { data } = await $.http.post('/', body);
|
||||
|
||||
if (data.data.boards[0].groups.length) {
|
||||
for (const group of data.data.boards[0].groups) {
|
||||
groups.data.push({
|
||||
value: group.id,
|
||||
name: group.title,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return groups;
|
||||
},
|
||||
};
|
@@ -3,6 +3,7 @@ import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import actions from './actions/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Monday',
|
||||
@@ -17,4 +18,5 @@ export default defineApp({
|
||||
auth,
|
||||
triggers,
|
||||
actions,
|
||||
dynamicData,
|
||||
});
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import newBoards from './new-boards/index.js';
|
||||
import newUsers from './new-users/index.js';
|
||||
|
||||
export default [newBoards];
|
||||
export default [newBoards, newUsers];
|
||||
|
29
packages/backend/src/apps/monday/triggers/new-users/index.js
Normal file
29
packages/backend/src/apps/monday/triggers/new-users/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New users',
|
||||
key: 'newUsers',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new user joins your account.',
|
||||
|
||||
async run($) {
|
||||
const body = {
|
||||
query: 'query { users { id name } }',
|
||||
};
|
||||
|
||||
const { data } = await $.http.post('/', body);
|
||||
|
||||
if (!data.data?.users?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const user of data.data.users.reverse()) {
|
||||
$.pushTriggerItem({
|
||||
raw: user,
|
||||
meta: {
|
||||
internalId: user.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
@@ -3,6 +3,10 @@ favicon: /favicons/monday.svg
|
||||
items:
|
||||
- name: Create board
|
||||
desc: Creates a new board.
|
||||
- name: Create column
|
||||
desc: Creates a new column in a board.
|
||||
- name: Create item
|
||||
desc: Creates a new item in a board.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
|
@@ -3,6 +3,8 @@ favicon: /favicons/monday.svg
|
||||
items:
|
||||
- name: New board
|
||||
desc: Triggers when a new board is created.
|
||||
- name: New users
|
||||
desc: Triggers when a new user joins your account.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
|
Reference in New Issue
Block a user