mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(Monday.com Node): Migrate to api 2023-10 (#8254)
This commit is contained in:
parent
f208a6e087
commit
ccde38a8a8
|
@ -10,12 +10,29 @@ The flag `N8N_CACHE_ENABLED` was removed. The cache is now always enabled.
|
||||||
|
|
||||||
Additionally, expressions in credentials now follow the paired item, so if you have multiple input items, n8n will try to pair the matching row to fill in the credential details.
|
Additionally, expressions in credentials now follow the paired item, so if you have multiple input items, n8n will try to pair the matching row to fill in the credential details.
|
||||||
|
|
||||||
|
In the Monday.com Node, due to API changes, the data structure of entries in `column_values` array has changed
|
||||||
|
|
||||||
### When is action necessary?
|
### When is action necessary?
|
||||||
|
|
||||||
If you are using the flag `N8N_CACHE_ENABLED`, remove it from your settings.
|
If you are using the flag `N8N_CACHE_ENABLED`, remove it from your settings.
|
||||||
|
|
||||||
In regards to credentials, if you use expression in credentials, you might want to revisit them. Previously, n8n would stick to the first item only, but now it will try to match the proper paired item.
|
In regards to credentials, if you use expression in credentials, you might want to revisit them. Previously, n8n would stick to the first item only, but now it will try to match the proper paired item.
|
||||||
|
|
||||||
|
If you are using the Monday.com node and refering to `column_values` property, check in table below if you are using any of the affected properties of its entries.
|
||||||
|
|
||||||
|
| Resource | Operation | Previous | New |
|
||||||
|
| ---------- | ------------------- | --------------- | ------------------- |
|
||||||
|
| Board | Get | owner | owners |
|
||||||
|
| Board | Get All | owner | owners |
|
||||||
|
| Board Item | Get | title | column.title |
|
||||||
|
| Board Item | Get All | title | column.title |
|
||||||
|
| Board Item | Get By Column Value | title | column.title |
|
||||||
|
| Board Item | Get | additional_info | column.settings_str |
|
||||||
|
| Board Item | Get All | additional_info | column.settings_str |
|
||||||
|
| Board Item | Get By Column Value | additional_info | column.settings_str |
|
||||||
|
|
||||||
|
\*column.settings_str is not a complete equivalent additional_info
|
||||||
|
|
||||||
## 1.22.0
|
## 1.22.0
|
||||||
|
|
||||||
### What changed?
|
### What changed?
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
|
import type {
|
||||||
|
IAuthenticateGeneric,
|
||||||
|
ICredentialTestRequest,
|
||||||
|
ICredentialType,
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export class MondayComApi implements ICredentialType {
|
export class MondayComApi implements ICredentialType {
|
||||||
name = 'mondayComApi';
|
name = 'mondayComApi';
|
||||||
|
@ -16,4 +21,27 @@ export class MondayComApi implements ICredentialType {
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
authenticate: IAuthenticateGeneric = {
|
||||||
|
type: 'generic',
|
||||||
|
properties: {
|
||||||
|
headers: {
|
||||||
|
Authorization: '=Bearer {{$credentials.apiToken}}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
headers: {
|
||||||
|
'API-Version': '2023-10',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
baseURL: 'https://api.monday.com/v2',
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
query: 'query { me { name }}',
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,34 +14,31 @@ import get from 'lodash/get';
|
||||||
|
|
||||||
export async function mondayComApiRequest(
|
export async function mondayComApiRequest(
|
||||||
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||||
|
|
||||||
body: any = {},
|
body: any = {},
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
|
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
|
||||||
|
|
||||||
const endpoint = 'https://api.monday.com/v2/';
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
|
'API-Version': '2023-10',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body,
|
body,
|
||||||
uri: endpoint,
|
uri: 'https://api.monday.com/v2/',
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
let credentialType = 'mondayComApi';
|
||||||
const credentials = await this.getCredentials('mondayComApi');
|
|
||||||
|
|
||||||
options.headers = { Authorization: `Bearer ${credentials.apiToken}` };
|
if (authenticationMethod === 'oAuth2') {
|
||||||
|
credentialType = 'mondayComOAuth2Api';
|
||||||
return await this.helpers.request(options);
|
|
||||||
} else {
|
|
||||||
return await this.helpers.requestOAuth2.call(this, 'mondayComOAuth2Api', options);
|
|
||||||
}
|
}
|
||||||
|
return await this.helpers.requestWithAuthentication.call(this, credentialType, options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +47,6 @@ export async function mondayComApiRequest(
|
||||||
export async function mondayComApiRequestAllItems(
|
export async function mondayComApiRequestAllItems(
|
||||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||||
propertyName: string,
|
propertyName: string,
|
||||||
|
|
||||||
body: any = {},
|
body: any = {},
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const returnData: IDataObject[] = [];
|
const returnData: IDataObject[] = [];
|
||||||
|
@ -66,3 +62,41 @@ export async function mondayComApiRequestAllItems(
|
||||||
} while (get(responseData, propertyName).length > 0);
|
} while (get(responseData, propertyName).length > 0);
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function mondayComApiPaginatedRequest(
|
||||||
|
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||||
|
itemsPath: string,
|
||||||
|
fieldsToReturn: string,
|
||||||
|
body: IDataObject = {},
|
||||||
|
) {
|
||||||
|
const returnData: IDataObject[] = [];
|
||||||
|
|
||||||
|
const initialResponse = await mondayComApiRequest.call(this, body);
|
||||||
|
const data = get(initialResponse, itemsPath) as IDataObject;
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
returnData.push.apply(returnData, data.items as IDataObject[]);
|
||||||
|
|
||||||
|
let cursor: null | string = data.cursor as string;
|
||||||
|
|
||||||
|
while (cursor) {
|
||||||
|
const responseData = (
|
||||||
|
(await mondayComApiRequest.call(this, {
|
||||||
|
query: `query ( $cursor: String!) { next_items_page (cursor: $cursor, limit: 100) { cursor items ${fieldsToReturn} } }`,
|
||||||
|
variables: {
|
||||||
|
cursor,
|
||||||
|
},
|
||||||
|
})) as IDataObject
|
||||||
|
).data as { next_items_page: { cursor: string; items: IDataObject[] } };
|
||||||
|
|
||||||
|
if (responseData && responseData.next_items_page) {
|
||||||
|
returnData.push.apply(returnData, responseData.next_items_page.items);
|
||||||
|
cursor = responseData.next_items_page.cursor;
|
||||||
|
} else {
|
||||||
|
cursor = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,11 @@ import type {
|
||||||
import { NodeOperationError } from 'n8n-workflow';
|
import { NodeOperationError } from 'n8n-workflow';
|
||||||
|
|
||||||
import { snakeCase } from 'change-case';
|
import { snakeCase } from 'change-case';
|
||||||
import { mondayComApiRequest, mondayComApiRequestAllItems } from './GenericFunctions';
|
import {
|
||||||
|
mondayComApiPaginatedRequest,
|
||||||
|
mondayComApiRequest,
|
||||||
|
mondayComApiRequestAllItems,
|
||||||
|
} from './GenericFunctions';
|
||||||
|
|
||||||
import { boardFields, boardOperations } from './BoardDescription';
|
import { boardFields, boardOperations } from './BoardDescription';
|
||||||
|
|
||||||
|
@ -155,18 +159,17 @@ export class MondayCom implements INodeType {
|
||||||
// select them easily
|
// select them easily
|
||||||
async getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
const boardId = parseInt(this.getCurrentNodeParameter('boardId') as string, 10);
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `query ($boardId: [Int]) {
|
query: `query ($boardId: [ID!]) {
|
||||||
boards (ids: $boardId){
|
boards (ids: $boardId){
|
||||||
columns() {
|
columns {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
variables: {
|
variables: {
|
||||||
page: 1,
|
|
||||||
boardId,
|
boardId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -190,11 +193,11 @@ export class MondayCom implements INodeType {
|
||||||
// select them easily
|
// select them easily
|
||||||
async getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
const boardId = parseInt(this.getCurrentNodeParameter('boardId') as string, 10);
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
||||||
const body = {
|
const body = {
|
||||||
query: `query ($boardId: Int!) {
|
query: `query ($boardId: ID!) {
|
||||||
boards ( ids: [$boardId]){
|
boards ( ids: [$boardId]){
|
||||||
groups () {
|
groups {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
@ -234,10 +237,10 @@ export class MondayCom implements INodeType {
|
||||||
try {
|
try {
|
||||||
if (resource === 'board') {
|
if (resource === 'board') {
|
||||||
if (operation === 'archive') {
|
if (operation === 'archive') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($id: Int!) {
|
query: `mutation ($id: ID!) {
|
||||||
archive_board (board_id: $id) {
|
archive_board (board_id: $id) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -256,7 +259,7 @@ export class MondayCom implements INodeType {
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($name: String!, $kind: BoardKind!, $templateId: Int) {
|
query: `mutation ($name: String!, $kind: BoardKind!, $templateId: ID) {
|
||||||
create_board (board_name: $name, board_kind: $kind, template_id: $templateId) {
|
create_board (board_name: $name, board_kind: $kind, template_id: $templateId) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -275,10 +278,10 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.create_board;
|
responseData = responseData.data.create_board;
|
||||||
}
|
}
|
||||||
if (operation === 'get') {
|
if (operation === 'get') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `query ($id: [Int]) {
|
query: `query ($id: [ID!]) {
|
||||||
boards (ids: $id){
|
boards (ids: $id){
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@ -286,7 +289,7 @@ export class MondayCom implements INodeType {
|
||||||
state
|
state
|
||||||
board_folder_id
|
board_folder_id
|
||||||
board_kind
|
board_kind
|
||||||
owner() {
|
owners {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,7 +314,7 @@ export class MondayCom implements INodeType {
|
||||||
state
|
state
|
||||||
board_folder_id
|
board_folder_id
|
||||||
board_kind
|
board_kind
|
||||||
owner() {
|
owners {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,13 +335,13 @@ export class MondayCom implements INodeType {
|
||||||
}
|
}
|
||||||
if (resource === 'boardColumn') {
|
if (resource === 'boardColumn') {
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const title = this.getNodeParameter('title', i) as string;
|
const title = this.getNodeParameter('title', i) as string;
|
||||||
const columnType = this.getNodeParameter('columnType', i) as string;
|
const columnType = this.getNodeParameter('columnType', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($boardId: Int!, $title: String!, $columnType: ColumnType, $defaults: JSON ) {
|
query: `mutation ($boardId: ID!, $title: String!, $columnType: ColumnType!, $defaults: JSON ) {
|
||||||
create_column (board_id: $boardId, title: $title, column_type: $columnType, defaults: $defaults) {
|
create_column (board_id: $boardId, title: $title, column_type: $columnType, defaults: $defaults) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -367,12 +370,12 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.create_column;
|
responseData = responseData.data.create_column;
|
||||||
}
|
}
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `query ($boardId: [Int]) {
|
query: `query ($boardId: [ID!]) {
|
||||||
boards (ids: $boardId){
|
boards (ids: $boardId){
|
||||||
columns() {
|
columns {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
type
|
type
|
||||||
|
@ -393,11 +396,11 @@ export class MondayCom implements INodeType {
|
||||||
}
|
}
|
||||||
if (resource === 'boardGroup') {
|
if (resource === 'boardGroup') {
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const name = this.getNodeParameter('name', i) as string;
|
const name = this.getNodeParameter('name', i) as string;
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($boardId: Int!, $groupName: String!) {
|
query: `mutation ($boardId: ID!, $groupName: String!) {
|
||||||
create_group (board_id: $boardId, group_name: $groupName) {
|
create_group (board_id: $boardId, group_name: $groupName) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -412,11 +415,11 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.create_group;
|
responseData = responseData.data.create_group;
|
||||||
}
|
}
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const groupId = this.getNodeParameter('groupId', i) as string;
|
const groupId = this.getNodeParameter('groupId', i) as string;
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($boardId: Int!, $groupId: String!) {
|
query: `mutation ($boardId: ID!, $groupId: String!) {
|
||||||
delete_group (board_id: $boardId, group_id: $groupId) {
|
delete_group (board_id: $boardId, group_id: $groupId) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -431,13 +434,13 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.delete_group;
|
responseData = responseData.data.delete_group;
|
||||||
}
|
}
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `query ($boardId: [Int]) {
|
query: `query ($boardId: [ID!]) {
|
||||||
boards (ids: $boardId, ){
|
boards (ids: $boardId, ){
|
||||||
id
|
id
|
||||||
groups() {
|
groups {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
color
|
color
|
||||||
|
@ -457,11 +460,11 @@ export class MondayCom implements INodeType {
|
||||||
}
|
}
|
||||||
if (resource === 'boardItem') {
|
if (resource === 'boardItem') {
|
||||||
if (operation === 'addUpdate') {
|
if (operation === 'addUpdate') {
|
||||||
const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10);
|
const itemId = this.getNodeParameter('itemId', i);
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($itemId: Int!, $value: String!) {
|
query: `mutation ($itemId: ID!, $value: String!) {
|
||||||
create_update (item_id: $itemId, body: $value) {
|
create_update (item_id: $itemId, body: $value) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -476,13 +479,13 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.create_update;
|
responseData = responseData.data.create_update;
|
||||||
}
|
}
|
||||||
if (operation === 'changeColumnValue') {
|
if (operation === 'changeColumnValue') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10);
|
const itemId = this.getNodeParameter('itemId', i);
|
||||||
const columnId = this.getNodeParameter('columnId', i) as string;
|
const columnId = this.getNodeParameter('columnId', i) as string;
|
||||||
const value = this.getNodeParameter('value', i) as string;
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($boardId: Int!, $itemId: Int!, $columnId: String!, $value: JSON!) {
|
query: `mutation ($boardId: ID!, $itemId: ID!, $columnId: String!, $value: JSON!) {
|
||||||
change_column_value (board_id: $boardId, item_id: $itemId, column_id: $columnId, value: $value) {
|
change_column_value (board_id: $boardId, item_id: $itemId, column_id: $columnId, value: $value) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -507,12 +510,12 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.change_column_value;
|
responseData = responseData.data.change_column_value;
|
||||||
}
|
}
|
||||||
if (operation === 'changeMultipleColumnValues') {
|
if (operation === 'changeMultipleColumnValues') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10);
|
const itemId = this.getNodeParameter('itemId', i);
|
||||||
const columnValues = this.getNodeParameter('columnValues', i) as string;
|
const columnValues = this.getNodeParameter('columnValues', i) as string;
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($boardId: Int!, $itemId: Int!, $columnValues: JSON!) {
|
query: `mutation ($boardId: ID!, $itemId: ID!, $columnValues: JSON!) {
|
||||||
change_multiple_column_values (board_id: $boardId, item_id: $itemId, column_values: $columnValues) {
|
change_multiple_column_values (board_id: $boardId, item_id: $itemId, column_values: $columnValues) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -536,13 +539,13 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.change_multiple_column_values;
|
responseData = responseData.data.change_multiple_column_values;
|
||||||
}
|
}
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const groupId = this.getNodeParameter('groupId', i) as string;
|
const groupId = this.getNodeParameter('groupId', i) as string;
|
||||||
const itemName = this.getNodeParameter('name', i) as string;
|
const itemName = this.getNodeParameter('name', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($boardId: Int!, $groupId: String!, $itemName: String!, $columnValues: JSON) {
|
query: `mutation ($boardId: ID!, $groupId: String!, $itemName: String!, $columnValues: JSON) {
|
||||||
create_item (board_id: $boardId, group_id: $groupId, item_name: $itemName, column_values: $columnValues) {
|
create_item (board_id: $boardId, group_id: $groupId, item_name: $itemName, column_values: $columnValues) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -571,10 +574,10 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.create_item;
|
responseData = responseData.data.create_item;
|
||||||
}
|
}
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10);
|
const itemId = this.getNodeParameter('itemId', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($itemId: Int!) {
|
query: `mutation ($itemId: ID!) {
|
||||||
delete_item (item_id: $itemId) {
|
delete_item (item_id: $itemId) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -587,24 +590,27 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.delete_item;
|
responseData = responseData.data.delete_item;
|
||||||
}
|
}
|
||||||
if (operation === 'get') {
|
if (operation === 'get') {
|
||||||
const itemIds = (this.getNodeParameter('itemId', i) as string)
|
const itemIds = (this.getNodeParameter('itemId', i) as string).split(',');
|
||||||
.split(',')
|
|
||||||
.map((n) => parseInt(n, 10));
|
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `query ($itemId: [Int!]){
|
query: `query ($itemId: [ID!]){
|
||||||
items (ids: $itemId) {
|
items (ids: $itemId) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
created_at
|
created_at
|
||||||
state
|
state
|
||||||
column_values() {
|
column_values {
|
||||||
id
|
id
|
||||||
text
|
text
|
||||||
title
|
|
||||||
type
|
type
|
||||||
value
|
value
|
||||||
additional_info
|
column {
|
||||||
|
|
||||||
|
title
|
||||||
|
archived
|
||||||
|
description
|
||||||
|
settings_str
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
|
@ -616,101 +622,128 @@ export class MondayCom implements INodeType {
|
||||||
responseData = responseData.data.items;
|
responseData = responseData.data.items;
|
||||||
}
|
}
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const groupId = this.getNodeParameter('groupId', i) as string;
|
const groupId = this.getNodeParameter('groupId', i) as string;
|
||||||
const returnAll = this.getNodeParameter('returnAll', i);
|
const returnAll = this.getNodeParameter('returnAll', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const fieldsToReturn = `
|
||||||
query: `query ($boardId: [Int], $groupId: [String], $page: Int, $limit: Int) {
|
{
|
||||||
boards (ids: $boardId) {
|
id
|
||||||
groups (ids: $groupId) {
|
name
|
||||||
id
|
created_at
|
||||||
items(limit: $limit, page: $page) {
|
state
|
||||||
id
|
column_values {
|
||||||
name
|
id
|
||||||
created_at
|
text
|
||||||
state
|
type
|
||||||
column_values() {
|
value
|
||||||
id
|
column {
|
||||||
text
|
title
|
||||||
title
|
archived
|
||||||
type
|
description
|
||||||
value
|
settings_str
|
||||||
additional_info
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
query: `query ($boardId: [ID!], $groupId: [String], $limit: Int) {
|
||||||
|
boards(ids: $boardId) {
|
||||||
|
groups(ids: $groupId) {
|
||||||
|
id
|
||||||
|
items_page(limit: $limit) {
|
||||||
|
cursor
|
||||||
|
items ${fieldsToReturn}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`,
|
}
|
||||||
|
}`,
|
||||||
variables: {
|
variables: {
|
||||||
boardId,
|
boardId,
|
||||||
groupId,
|
groupId,
|
||||||
|
limit: 100,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await mondayComApiRequestAllItems.call(
|
responseData = await mondayComApiPaginatedRequest.call(
|
||||||
this,
|
this,
|
||||||
'data.boards[0].groups[0].items',
|
'data.boards[0].groups[0].items_page',
|
||||||
body,
|
fieldsToReturn,
|
||||||
|
body as IDataObject,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
body.variables.limit = this.getNodeParameter('limit', i);
|
body.variables.limit = this.getNodeParameter('limit', i);
|
||||||
responseData = await mondayComApiRequest.call(this, body);
|
responseData = await mondayComApiRequest.call(this, body);
|
||||||
responseData = responseData.data.boards[0].groups[0].items;
|
responseData = responseData.data.boards[0].groups[0].items_page.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'getByColumnValue') {
|
if (operation === 'getByColumnValue') {
|
||||||
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
|
const boardId = this.getNodeParameter('boardId', i);
|
||||||
const columnId = this.getNodeParameter('columnId', i) as string;
|
const columnId = this.getNodeParameter('columnId', i) as string;
|
||||||
const columnValue = this.getNodeParameter('columnValue', i) as string;
|
const columnValue = this.getNodeParameter('columnValue', i) as string;
|
||||||
const returnAll = this.getNodeParameter('returnAll', i);
|
const returnAll = this.getNodeParameter('returnAll', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const fieldsToReturn = `{
|
||||||
query: `query ($boardId: Int!, $columnId: String!, $columnValue: String!, $page: Int, $limit: Int ){
|
id
|
||||||
items_by_column_values (board_id: $boardId, column_id: $columnId, column_value: $columnValue, page: $page, limit: $limit) {
|
name
|
||||||
id
|
created_at
|
||||||
name
|
state
|
||||||
created_at
|
board {
|
||||||
state
|
id
|
||||||
board {
|
}
|
||||||
id
|
column_values {
|
||||||
}
|
id
|
||||||
column_values() {
|
text
|
||||||
id
|
type
|
||||||
text
|
value
|
||||||
title
|
column {
|
||||||
type
|
title
|
||||||
value
|
archived
|
||||||
additional_info
|
description
|
||||||
}
|
settings_str
|
||||||
}
|
}
|
||||||
}`,
|
}
|
||||||
|
}`;
|
||||||
|
const body = {
|
||||||
|
query: `query ($boardId: ID!, $columnId: String!, $columnValue: String!, $limit: Int) {
|
||||||
|
items_page_by_column_values(
|
||||||
|
limit: $limit
|
||||||
|
board_id: $boardId
|
||||||
|
columns: [{column_id: $columnId, column_values: [$columnValue]}]
|
||||||
|
) {
|
||||||
|
cursor
|
||||||
|
items ${fieldsToReturn}
|
||||||
|
}
|
||||||
|
}`,
|
||||||
variables: {
|
variables: {
|
||||||
boardId,
|
boardId,
|
||||||
columnId,
|
columnId,
|
||||||
columnValue,
|
columnValue,
|
||||||
|
limit: 100,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await mondayComApiRequestAllItems.call(
|
responseData = await mondayComApiPaginatedRequest.call(
|
||||||
this,
|
this,
|
||||||
'data.items_by_column_values',
|
'data.items_page_by_column_values',
|
||||||
body,
|
fieldsToReturn,
|
||||||
|
body as IDataObject,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
body.variables.limit = this.getNodeParameter('limit', i);
|
body.variables.limit = this.getNodeParameter('limit', i);
|
||||||
responseData = await mondayComApiRequest.call(this, body);
|
responseData = await mondayComApiRequest.call(this, body);
|
||||||
responseData = responseData.data.items_by_column_values;
|
responseData = responseData.data.items_page_by_column_values.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'move') {
|
if (operation === 'move') {
|
||||||
const groupId = this.getNodeParameter('groupId', i) as string;
|
const groupId = this.getNodeParameter('groupId', i) as string;
|
||||||
const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10);
|
const itemId = this.getNodeParameter('itemId', i);
|
||||||
|
|
||||||
const body: IGraphqlBody = {
|
const body: IGraphqlBody = {
|
||||||
query: `mutation ($groupId: String!, $itemId: Int!) {
|
query: `mutation ($groupId: String!, $itemId: ID!) {
|
||||||
move_item_to_group (group_id: $groupId, item_id: $itemId) {
|
move_item_to_group (group_id: $groupId, item_id: $itemId) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue