mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 04:47:29 -08:00
⚡ Add the posiblity to set multi-select fields with the names (#1892)
* ⚡ Add the posiblity to set multi-select fields with the names * 🐛 Fix issue with expressions Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
68914a1fcf
commit
233fc72dc2
|
@ -11,7 +11,7 @@ import {
|
|||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import * as uuid from 'uuid/v4';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import {
|
||||
snakeCase,
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
recordOperations,
|
||||
} from './RecordDescription';
|
||||
|
||||
import * as uuid from 'uuid';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export class GoogleBigQuery implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -34,7 +34,7 @@ import {
|
|||
|
||||
import * as moment from 'moment-timezone';
|
||||
|
||||
import * as uuid from 'uuid/v4';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export class GoogleCalendar implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
googleApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import uuid = require('uuid');
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export class GoogleDrive implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from 'n8n-core';
|
||||
|
||||
import * as _ from 'lodash';
|
||||
import * as uuid from 'uuid/v4';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
|
||||
interface MessageResponse {
|
||||
|
|
|
@ -24,6 +24,8 @@ import {
|
|||
|
||||
import * as moment from 'moment-timezone';
|
||||
|
||||
import { validate as uuidValidate } from 'uuid';
|
||||
|
||||
export async function notionApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
try {
|
||||
|
@ -244,9 +246,15 @@ function getPropertyKeyValue(value: any, type: string, timezone: string) {
|
|||
};
|
||||
break;
|
||||
case 'multi_select':
|
||||
const multiSelectValue = value.multiSelectValue;
|
||||
result = {
|
||||
type: 'multi_select',
|
||||
// tslint:disable-next-line: no-any
|
||||
type: 'multi_select', multi_select: value.multiSelectValue.filter((id: any) => id !== null).map((option: string) => ({ id: option })),
|
||||
multi_select: (Array.isArray(multiSelectValue) ? multiSelectValue : multiSelectValue.split(',').map(v => v.trim()))
|
||||
// tslint:disable-next-line: no-any
|
||||
.filter((value: any) => value !== null)
|
||||
.map((option: string) =>
|
||||
((!uuidValidate(option)) ? { name: option } : { id: option })),
|
||||
};
|
||||
break;
|
||||
case 'email':
|
||||
|
|
|
@ -47,6 +47,7 @@ import {
|
|||
databasePageFields,
|
||||
databasePageOperations,
|
||||
} from './DatabasePageDescription';
|
||||
import { getServers } from 'dns';
|
||||
|
||||
export class Notion implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
@ -215,8 +216,16 @@ export class Notion implements INodeType {
|
|||
const resource = this.getCurrentNodeParameter('resource') as string;
|
||||
const operation = this.getCurrentNodeParameter('operation') as string;
|
||||
const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
|
||||
const useNames = (resource === 'databasePage' && operation === 'getAll');
|
||||
return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: (['select', 'multi_select'].includes(type) && useNames) ? option.name : option.id }));
|
||||
if (resource === 'databasePage') {
|
||||
if (['multi_select', 'select'].includes(type) && operation === 'getAll') {
|
||||
return (properties[name][type].options)
|
||||
.map((option: IDataObject) => ({ name: option.name, value: option.name }));
|
||||
} else if (['multi_select'].includes(type) && ['create', 'update'].includes(operation)) {
|
||||
return (properties[name][type].options)
|
||||
.map((option: IDataObject) => ({ name: option.name, value: option.name }));
|
||||
}
|
||||
}
|
||||
return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: option.id }));
|
||||
},
|
||||
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
|
|
@ -37,7 +37,7 @@ import {
|
|||
ITrack,
|
||||
} from './TrackInterface';
|
||||
|
||||
import * as uuid from 'uuid/v4';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export class Segment implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -37,7 +37,7 @@ import {
|
|||
commentFields,
|
||||
commentOperations
|
||||
} from './CommentDescription';
|
||||
import uuid = require('uuid');
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import * as moment from 'moment';
|
||||
|
||||
export class Twist implements INodeType {
|
||||
|
|
|
@ -41,7 +41,7 @@ import {
|
|||
|
||||
import * as moment from 'moment-timezone';
|
||||
|
||||
import * as uuid from 'uuid/v4';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export class Wise implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -599,7 +599,7 @@
|
|||
"@types/request-promise-native": "~1.0.15",
|
||||
"@types/ssh2-sftp-client": "^5.1.0",
|
||||
"@types/tmp": "^0.2.0",
|
||||
"@types/uuid": "^3.4.6",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@types/xml2js": "^0.4.3",
|
||||
"gulp": "^4.0.0",
|
||||
"jest": "^26.4.2",
|
||||
|
@ -656,7 +656,7 @@
|
|||
"snowflake-sdk": "^1.5.3",
|
||||
"ssh2-sftp-client": "^5.2.1",
|
||||
"tmp-promise": "^3.0.2",
|
||||
"uuid": "^3.4.0",
|
||||
"uuid": "^8.3.0",
|
||||
"vm2": "^3.6.10",
|
||||
"xlsx": "^0.17.0",
|
||||
"xml2js": "^0.4.23"
|
||||
|
|
Loading…
Reference in a new issue