mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): fix for no-uncaught-json-parse warnings
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -149,7 +150,7 @@ export class AgileCrm implements INodeType {
|
||||
} else if (filterType === 'json') {
|
||||
const filterJsonRules = this.getNodeParameter('filterJson', i) as string;
|
||||
if (validateJSON(filterJsonRules) !== undefined) {
|
||||
Object.assign(filterJson, JSON.parse(filterJsonRules) as IFilter);
|
||||
Object.assign(filterJson, jsonParse(filterJsonRules) as IFilter);
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), 'Filter (JSON) must be a valid json', {
|
||||
itemIndex: i,
|
||||
@@ -203,7 +204,7 @@ export class AgileCrm implements INodeType {
|
||||
|
||||
if (additionalFieldsJson !== '') {
|
||||
if (validateJSON(additionalFieldsJson) !== undefined) {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
Object.assign(body, jsonParse(additionalFieldsJson));
|
||||
} else {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
@@ -355,7 +356,7 @@ export class AgileCrm implements INodeType {
|
||||
|
||||
if (additionalFieldsJson !== '') {
|
||||
if (validateJSON(additionalFieldsJson) !== undefined) {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
Object.assign(body, jsonParse(additionalFieldsJson));
|
||||
} else {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
@@ -533,7 +534,7 @@ export class AgileCrm implements INodeType {
|
||||
|
||||
if (additionalFieldsJson !== '') {
|
||||
if (validateJSON(additionalFieldsJson) !== undefined) {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
Object.assign(body, jsonParse(additionalFieldsJson));
|
||||
} else {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
@@ -573,7 +574,7 @@ export class AgileCrm implements INodeType {
|
||||
|
||||
if (additionalFieldsJson !== '') {
|
||||
if (validateJSON(additionalFieldsJson) !== undefined) {
|
||||
Object.assign(body, JSON.parse(additionalFieldsJson));
|
||||
Object.assign(body, jsonParse(additionalFieldsJson));
|
||||
} else {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
ITriggerResponse,
|
||||
jsonParse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -190,7 +191,7 @@ export class AmqpTrigger implements INodeType {
|
||||
}
|
||||
|
||||
if (options.jsonParseBody === true) {
|
||||
data.body = JSON.parse(data.body);
|
||||
data.body = jsonParse(data.body);
|
||||
}
|
||||
if (options.onlyBody === true) {
|
||||
data = data.body;
|
||||
|
||||
@@ -178,7 +178,7 @@ export class AwsSnsTrigger implements INodeType {
|
||||
const topic = this.getNodeParameter('topic') as string;
|
||||
|
||||
// @ts-ignore
|
||||
const body = JSON.parse(req.rawBody.toString());
|
||||
const body = jsonParse(req.rawBody.toString());
|
||||
|
||||
if (body.Type === 'SubscriptionConfirmation' && body.TopicArn === topic) {
|
||||
const { Token } = body;
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import { IDataObject, IHttpRequestOptions, NodeApiError } from 'n8n-workflow';
|
||||
import { IDataObject, IHttpRequestOptions, jsonParse, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function awsApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
@@ -18,7 +18,7 @@ export async function awsApiRequest(
|
||||
query: IDataObject = {},
|
||||
headers?: object,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('aws');
|
||||
|
||||
const requestOptions = {
|
||||
@@ -50,7 +50,7 @@ export async function awsApiRequestREST(
|
||||
query: IDataObject = {},
|
||||
headers?: object,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
): Promise<any> {
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, query, headers);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
@@ -70,23 +70,17 @@ export async function awsApiRequestAllItems(
|
||||
headers: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
|
||||
do {
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
service,
|
||||
method,
|
||||
path,
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
);
|
||||
responseData = await awsApiRequestREST.call(this, service, method, path, body, query, headers);
|
||||
if (responseData.NextToken) {
|
||||
const data = JSON.parse(body as string);
|
||||
// tslint:disable-next-line:no-any
|
||||
const data = jsonParse<any>(body as string, {
|
||||
errorMessage: 'Response body is not valid JSON',
|
||||
});
|
||||
data['NextToken'] = responseData.NextToken;
|
||||
}
|
||||
returnData.push.apply(returnData, get(responseData, propertyName));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, jsonParse } from 'n8n-workflow';
|
||||
import { ICollection } from './CollectionInterface';
|
||||
import { cockpitApiRequest } from './GenericFunctions';
|
||||
|
||||
@@ -46,7 +46,9 @@ export async function getAllCollectionEntries(
|
||||
}
|
||||
|
||||
if (options.filter) {
|
||||
body.filter = JSON.parse(options.filter.toString());
|
||||
body.filter = jsonParse(options.filter.toString(), {
|
||||
errorMessage: "'Filter' option is not valid JSON",
|
||||
});
|
||||
}
|
||||
|
||||
if (options.limit) {
|
||||
@@ -58,7 +60,9 @@ export async function getAllCollectionEntries(
|
||||
}
|
||||
|
||||
if (options.sort) {
|
||||
body.sort = JSON.parse(options.sort.toString());
|
||||
body.sort = jsonParse(options.sort.toString(), {
|
||||
errorMessage: "'Sort' option is not valid JSON",
|
||||
});
|
||||
}
|
||||
|
||||
if (options.populate) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
import { IDataObject, jsonParse, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
export async function cockpitApiRequest(
|
||||
@@ -48,7 +48,7 @@ export function createDataFromParameters(
|
||||
|
||||
if (dataFieldsAreJson) {
|
||||
// Parameters are defined as JSON
|
||||
return JSON.parse(this.getNodeParameter('dataFieldsJson', itemIndex, '{}') as string);
|
||||
return jsonParse(this.getNodeParameter('dataFieldsJson', itemIndex, '{}') as string);
|
||||
}
|
||||
|
||||
// Parameters are defined in UI
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
@@ -171,7 +172,7 @@ export class Discord implements INodeType {
|
||||
|
||||
if (options.allowed_mentions) {
|
||||
//@ts-expect-error
|
||||
body.allowed_mentions = JSON.parse(options.allowed_mentions);
|
||||
body.allowed_mentions = jsonParse(options.allowed_mentions);
|
||||
}
|
||||
|
||||
if (options.avatarUrl) {
|
||||
@@ -188,12 +189,12 @@ export class Discord implements INodeType {
|
||||
|
||||
if (options.payloadJson) {
|
||||
//@ts-expect-error
|
||||
body.payload_json = JSON.parse(options.payloadJson);
|
||||
body.payload_json = jsonParse(options.payloadJson);
|
||||
}
|
||||
|
||||
if (options.attachments) {
|
||||
//@ts-expect-error
|
||||
body.attachments = JSON.parse(options.attachments as DiscordAttachment[]);
|
||||
body.attachments = jsonParse(options.attachments as DiscordAttachment[]);
|
||||
}
|
||||
|
||||
//* Not used props, delete them from the payload as Discord won't need them :^
|
||||
@@ -270,7 +271,7 @@ export class Discord implements INodeType {
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({success: true}),
|
||||
this.helpers.returnJsonArray({ success: true }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { elasticsearchApiRequest, elasticsearchApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
@@ -127,7 +133,12 @@ export class Elasticsearch implements INodeType {
|
||||
|
||||
if (Object.keys(options).length) {
|
||||
const { query, ...rest } = options;
|
||||
if (query) Object.assign(body, JSON.parse(query));
|
||||
if (query) {
|
||||
Object.assign(
|
||||
body,
|
||||
jsonParse(query, { errorMessage: "Invalid JSON in 'Query' option" }),
|
||||
);
|
||||
}
|
||||
Object.assign(qs, rest);
|
||||
qs._source = true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
@@ -338,7 +339,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType {
|
||||
this,
|
||||
'POST',
|
||||
`/${projectId}/databases/${database}/documents:runQuery`,
|
||||
JSON.parse(query),
|
||||
jsonParse(query),
|
||||
);
|
||||
|
||||
responseData = responseData.map(
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeBaseDescription,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
@@ -951,7 +952,11 @@ export class HttpRequestV3 implements INodeType {
|
||||
itemIndex,
|
||||
[],
|
||||
) as [{ name: string; value: string }];
|
||||
const specifyHeaders = this.getNodeParameter('specifyHeaders', itemIndex, 'keypair') as string;
|
||||
const specifyHeaders = this.getNodeParameter(
|
||||
'specifyHeaders',
|
||||
itemIndex,
|
||||
'keypair',
|
||||
) as string;
|
||||
const jsonHeadersParameter = this.getNodeParameter('jsonHeaders', itemIndex, '') as string;
|
||||
|
||||
const {
|
||||
@@ -1097,7 +1102,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
);
|
||||
}
|
||||
|
||||
requestOptions.body = JSON.parse(jsonBodyParameter);
|
||||
requestOptions.body = jsonParse(jsonBodyParameter);
|
||||
} else if (specifyBody === 'string') {
|
||||
//form urlencoded
|
||||
requestOptions.body = Object.fromEntries(new URLSearchParams(body));
|
||||
@@ -1147,7 +1152,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
);
|
||||
}
|
||||
|
||||
requestOptions.qs = JSON.parse(jsonQueryParameter);
|
||||
requestOptions.qs = jsonParse(jsonQueryParameter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1172,7 +1177,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
);
|
||||
}
|
||||
|
||||
requestOptions.headers = JSON.parse(jsonHeadersParameter);
|
||||
requestOptions.headers = jsonParse(jsonHeadersParameter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1323,7 +1328,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
const responseContentType = response.headers['content-type'] ?? '';
|
||||
if (responseContentType.includes('application/json')) {
|
||||
responseFormat = 'json';
|
||||
response.body = JSON.parse(Buffer.from(response.body).toString());
|
||||
response.body = jsonParse(Buffer.from(response.body).toString());
|
||||
} else if (binaryContentTypes.some((e) => responseContentType.includes(e))) {
|
||||
responseFormat = 'file';
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
jsonParse,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { jotformApiRequest } from './GenericFunctions';
|
||||
@@ -167,7 +168,8 @@ export class JotFormTrigger implements INodeType {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
form.parse(req, async (err, data, files) => {
|
||||
const rawRequest = JSON.parse(data.rawRequest as string);
|
||||
// tslint:disable-next-line:no-any
|
||||
const rawRequest = jsonParse<any>(data.rawRequest as string);
|
||||
data.rawRequest = rawRequest;
|
||||
|
||||
let returnData: IDataObject;
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
IN8nHttpFullResponse,
|
||||
INodeExecutionData,
|
||||
INodeProperties,
|
||||
jsonParse,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const questionsOperations: INodeProperties[] = [
|
||||
@@ -74,9 +75,7 @@ export const questionsOperations: INodeProperties[] = [
|
||||
}
|
||||
items[i] = newItem;
|
||||
if (this.getNode().parameters.format === 'json') {
|
||||
items[i].json = JSON.parse(
|
||||
items[i].json as unknown as string,
|
||||
)[0] as unknown as IDataObject;
|
||||
items[i].json = jsonParse<IDataObject[]>(items[i].json as unknown as string)[0];
|
||||
console.log(items[i].json);
|
||||
delete items[i].binary;
|
||||
} else {
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -362,7 +363,7 @@ export class MoveBinaryData implements INodeType {
|
||||
convertedValue = iconv.decode(buffer, encoding, {
|
||||
stripBOM: options.stripBOM as boolean,
|
||||
});
|
||||
newItem.json = JSON.parse(convertedValue);
|
||||
newItem.json = jsonParse(convertedValue);
|
||||
} else {
|
||||
// Does get added to existing data so copy it first
|
||||
newItem.json = deepCopy(item.json);
|
||||
@@ -376,7 +377,7 @@ export class MoveBinaryData implements INodeType {
|
||||
}
|
||||
|
||||
if (options.jsonParse) {
|
||||
convertedValue = JSON.parse(convertedValue);
|
||||
convertedValue = jsonParse(convertedValue);
|
||||
}
|
||||
|
||||
const destinationKey = this.getNodeParameter('destinationKey', itemIndex, '') as string;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
IPollFunctions,
|
||||
jsonParse,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
@@ -115,7 +116,7 @@ export async function downloadRecordAttachments(
|
||||
for (const fieldName of fieldNames) {
|
||||
if (record[fieldName]) {
|
||||
for (const [index, attachment] of (
|
||||
JSON.parse(record[fieldName] as string) as IAttachment[]
|
||||
jsonParse(record[fieldName] as string) as IAttachment[]
|
||||
).entries()) {
|
||||
const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, {
|
||||
json: false,
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeBaseDescription,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -528,7 +529,7 @@ export class NotionV2 implements INodeType {
|
||||
} else if (filterType === 'json') {
|
||||
const filterJson = this.getNodeParameter('filterJson', i) as string;
|
||||
if (validateJSON(filterJson) !== undefined) {
|
||||
body.filter = JSON.parse(filterJson);
|
||||
body.filter = jsonParse(filterJson);
|
||||
} else {
|
||||
throw new NodeApiError(this.getNode(), {
|
||||
message: 'Filters (JSON) must be a valid json',
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { get, set, unset } from 'lodash';
|
||||
import { options } from 'rhea';
|
||||
|
||||
interface IRenameKey {
|
||||
currentKey: string;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -206,7 +207,9 @@ export class RespondToWebhook implements INodeType {
|
||||
if (respondWith === 'json') {
|
||||
const responseBodyParameter = this.getNodeParameter('responseBody', 0) as string;
|
||||
if (responseBodyParameter) {
|
||||
responseBody = JSON.parse(responseBodyParameter);
|
||||
responseBody = jsonParse(responseBodyParameter, {
|
||||
errorMessage: "Invalid JSON in 'Response Body' field",
|
||||
});
|
||||
}
|
||||
} else if (respondWith === 'firstIncomingItem') {
|
||||
responseBody = items[0].json;
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
IHttpRequestOptions,
|
||||
IWebhookFunctions,
|
||||
JsonObject,
|
||||
jsonParse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { OptionsWithUri } from 'request';
|
||||
@@ -337,7 +338,7 @@ export namespace SendInBlueWebhookApi {
|
||||
options,
|
||||
)) as string;
|
||||
|
||||
return JSON.parse(webhooks) as Webhooks;
|
||||
return jsonParse(webhooks) as Webhooks;
|
||||
};
|
||||
|
||||
export const createWebHook = async (
|
||||
@@ -367,7 +368,7 @@ export namespace SendInBlueWebhookApi {
|
||||
options,
|
||||
);
|
||||
|
||||
return JSON.parse(webhookId) as WebhookId;
|
||||
return jsonParse(webhookId) as WebhookId;
|
||||
};
|
||||
|
||||
export const deleteWebhook = async (ref: IHookFunctions, webhookId: string) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import EventSource from 'eventsource';
|
||||
import { ITriggerFunctions } from 'n8n-core';
|
||||
import { INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow';
|
||||
import { INodeType, INodeTypeDescription, ITriggerResponse, jsonParse } from 'n8n-workflow';
|
||||
|
||||
export class SseTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -37,7 +37,8 @@ export class SseTrigger implements INodeType {
|
||||
const eventSource = new EventSource(url);
|
||||
|
||||
eventSource.onmessage = (event) => {
|
||||
const eventData = JSON.parse(event.data);
|
||||
// tslint:disable-next-line:no-any
|
||||
const eventData = jsonParse<any>(event.data, { errorMessage: 'Invalid JSON for event data' });
|
||||
this.emit([this.helpers.returnJsonArray([eventData])]);
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
jsonParse,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -91,7 +92,8 @@ export class StopAndError implements INodeType {
|
||||
toThrow = this.getNodeParameter('errorMessage', 0) as string;
|
||||
} else {
|
||||
const json = this.getNodeParameter('errorObject', 0) as string;
|
||||
const errorObject = JSON.parse(json);
|
||||
// tslint:disable-next-line:no-any
|
||||
const errorObject = jsonParse<any>(json);
|
||||
|
||||
toThrow = {
|
||||
name: 'User-thrown error',
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
jsonParse,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
@@ -514,7 +515,8 @@ export class SurveyMonkeyTrigger implements INodeType {
|
||||
return {};
|
||||
}
|
||||
|
||||
let responseData = JSON.parse(data.join(''));
|
||||
// tslint:disable-next-line:no-any
|
||||
let responseData = jsonParse<any>(data.join(''));
|
||||
let endpoint = '';
|
||||
|
||||
let returnItem: INodeExecutionData[] = [
|
||||
|
||||
@@ -2,7 +2,7 @@ import { OptionsWithUri } from 'request';
|
||||
|
||||
import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
import { IDataObject, jsonParse, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import moment from 'moment';
|
||||
import { Eq } from './QueryFunctions';
|
||||
@@ -79,7 +79,7 @@ export function prepareOptional(optionals: IDataObject): IDataObject {
|
||||
response[key] = Date.parse(optionals[key] as string);
|
||||
} else if (key === 'artifacts') {
|
||||
try {
|
||||
response[key] = JSON.parse(optionals[key] as string);
|
||||
response[key] = jsonParse(optionals[key] as string);
|
||||
} catch (error) {
|
||||
throw new Error('Invalid JSON for artifacts');
|
||||
}
|
||||
@@ -107,7 +107,7 @@ export async function prepareCustomFields(
|
||||
|
||||
if (typeof customFieldsJson === 'string') {
|
||||
try {
|
||||
customFieldsJson = JSON.parse(customFieldsJson);
|
||||
customFieldsJson = jsonParse(customFieldsJson);
|
||||
} catch (error) {
|
||||
throw new Error('Invalid JSON for customFields');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { IDataObject, jsonParse } from 'n8n-workflow';
|
||||
import {
|
||||
Context,
|
||||
FormatDueDatetime,
|
||||
@@ -228,7 +228,7 @@ export class SyncHandler implements OperationHandler {
|
||||
const commandsJson = ctx.getNodeParameter('commands', itemIndex) as string;
|
||||
const projectId = ctx.getNodeParameter('project', itemIndex) as number;
|
||||
const sections = await getSectionIds(ctx, projectId);
|
||||
const commands: Command[] = JSON.parse(commandsJson);
|
||||
const commands: Command[] = jsonParse(commandsJson);
|
||||
const tempIdMapping = new Map<string, string>();
|
||||
|
||||
for (let i = 0; i < commands.length; i++) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
jsonParse,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { wufooApiRequest } from './GenericFunctions';
|
||||
@@ -153,7 +154,10 @@ export class WufooTrigger implements INodeType {
|
||||
return {};
|
||||
}
|
||||
|
||||
const fieldsObject = JSON.parse(req.body.FieldStructure);
|
||||
// tslint:disable-next-line:no-any
|
||||
const fieldsObject = jsonParse<any>(req.body.FieldStructure, {
|
||||
errorMessage: "Invalid JSON in request body field 'FieldStructure'",
|
||||
});
|
||||
|
||||
fieldsObject.Fields.map((field: IField) => {
|
||||
// TODO
|
||||
@@ -206,8 +210,12 @@ export class WufooTrigger implements INodeType {
|
||||
entryId: req.body.EntryId as number,
|
||||
dateCreated: req.body.DateCreated as Date,
|
||||
formId: req.body.FormId as string,
|
||||
formStructure: JSON.parse(req.body.FormStructure),
|
||||
fieldStructure: JSON.parse(req.body.FieldStructure),
|
||||
formStructure: jsonParse(req.body.FormStructure, {
|
||||
errorMessage: "Invalid JSON in request body field 'FormStructure'",
|
||||
}),
|
||||
fieldStructure: jsonParse(req.body.FieldStructure, {
|
||||
errorMessage: "Invalid JSON in request body field 'FieldStructure'",
|
||||
}),
|
||||
entries,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user