diff --git a/CHANGELOG.md b/CHANGELOG.md index 2770dfc8ae..e62448a13c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +# [0.212.0](https://github.com/n8n-io/n8n/compare/n8n@0.211.2...n8n@0.212.0) (2023-01-19) + + +### Bug Fixes + +* **core:** Revert rule @typescript-eslint/prefer-nullish-coalescing ([e667df7](https://github.com/n8n-io/n8n/commit/e667df783c8c396fc40ff14de704b1e0def4a699)) +* **editor:** Allow special chars in node selector completion ([#5196](https://github.com/n8n-io/n8n/issues/5196)) ([b718464](https://github.com/n8n-io/n8n/commit/b718464b1f28e52ffb0b12e4b927d8fe3678d02a)) +* **GitLab Node:** Update credential test endpoint ([#5166](https://github.com/n8n-io/n8n/issues/5166)) ([e275306](https://github.com/n8n-io/n8n/commit/e275306c64a410c154e586532e35d25a583f75b4)) +* **Gmail Trigger Node:** Filter by labels not working ([#5173](https://github.com/n8n-io/n8n/issues/5173)) ([026f3a5](https://github.com/n8n-io/n8n/commit/026f3a532d30dcf79b76c9f9cff709e6af0eb9ee)) +* **HTTP Request Node:** Bug - node requires string instead of json ([8f49f49](https://github.com/n8n-io/n8n/commit/8f49f494ae66ce933f0fce3c3b43ce99baa1b728)) +* **HTTP Request Node:** Response format to text is ignored for JSON responses ([8dbe615](https://github.com/n8n-io/n8n/commit/8dbe6159d04c963e7858d31d64721ddc0911ea36)) + + +### Features + +* **core:** Add Prometheus metrics for n8n events and api invocations (experimental) ([#5177](https://github.com/n8n-io/n8n/issues/5177)) ([9b032d6](https://github.com/n8n-io/n8n/commit/9b032d68bc8a7a45aae73e9442315e872902d50a)), closes [#5187](https://github.com/n8n-io/n8n/issues/5187) +* **Item Lists Node:** Table tranformation ([5426690](https://github.com/n8n-io/n8n/commit/5426690791ead70085681ef31f229fbe15c7d656)) + + + ## [0.211.2](https://github.com/n8n-io/n8n/compare/n8n@0.211.1...n8n@0.211.2) (2023-01-17) diff --git a/package.json b/package.json index 049b2c513c..af2e77f20a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "n8n", - "version": "0.211.2", + "version": "0.212.0", "private": true, "homepage": "https://n8n.io", "engines": { diff --git a/packages/cli/package.json b/packages/cli/package.json index 03229331c5..e86b19cb0d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "n8n", - "version": "0.211.2", + "version": "0.212.0", "description": "n8n Workflow Automation Tool", "license": "SEE LICENSE IN LICENSE.md", "homepage": "https://n8n.io", @@ -136,6 +136,7 @@ "dotenv": "^8.0.0", "express": "^4.16.4", "express-openapi-validator": "^4.13.6", + "express-prom-bundle": "^6.6.0", "fast-glob": "^3.2.5", "flatted": "^3.2.4", "google-timezones-json": "^1.0.2", @@ -163,8 +164,8 @@ "luxon": "^3.1.0", "mysql2": "~2.3.3", "n8n-core": "~0.151.1", - "n8n-editor-ui": "~0.177.1", - "n8n-nodes-base": "~0.209.2", + "n8n-editor-ui": "~0.178.0", + "n8n-nodes-base": "~0.210.0", "n8n-workflow": "~0.133.1", "nodemailer": "^6.7.1", "oauth-1.0a": "^2.2.6", diff --git a/packages/cli/src/InternalHooks.ts b/packages/cli/src/InternalHooks.ts index 6530f562fd..32fe4e8dbf 100644 --- a/packages/cli/src/InternalHooks.ts +++ b/packages/cli/src/InternalHooks.ts @@ -182,6 +182,7 @@ export class InternalHooksClass implements IInternalHooksClass { workflow: IWorkflowBase, nodeName: string, ): Promise { + const nodeInWorkflow = workflow.nodes.find((node) => node.name === nodeName); void eventBus.sendNodeEvent({ eventName: 'n8n.node.started', payload: { @@ -189,6 +190,7 @@ export class InternalHooksClass implements IInternalHooksClass { nodeName, workflowId: workflow.id?.toString(), workflowName: workflow.name, + nodeType: nodeInWorkflow?.type, }, }); } @@ -198,6 +200,7 @@ export class InternalHooksClass implements IInternalHooksClass { workflow: IWorkflowBase, nodeName: string, ): Promise { + const nodeInWorkflow = workflow.nodes.find((node) => node.name === nodeName); void eventBus.sendNodeEvent({ eventName: 'n8n.node.finished', payload: { @@ -205,6 +208,7 @@ export class InternalHooksClass implements IInternalHooksClass { nodeName, workflowId: workflow.id?.toString(), workflowName: workflow.name, + nodeType: nodeInWorkflow?.type, }, }); } diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 02278f08a7..5d47fbeefd 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -73,7 +73,6 @@ import jwt from 'jsonwebtoken'; import jwks from 'jwks-rsa'; // @ts-ignore import timezones from 'google-timezones-json'; -import promClient, { Registry } from 'prom-client'; import history from 'connect-history-api-fallback'; import config from '@/config'; @@ -154,6 +153,7 @@ import { licenseController } from './license/license.controller'; import { corsMiddleware } from './middlewares/cors'; import { initEvents } from './events'; import { AbstractServer } from './AbstractServer'; +import { configureMetrics } from './metrics'; const exec = promisify(callbackExec); @@ -321,15 +321,7 @@ class Server extends AbstractServer { } async configure(): Promise { - const enableMetrics = config.getEnv('endpoints.metrics.enable'); - let register: Registry; - - if (enableMetrics) { - const prefix = config.getEnv('endpoints.metrics.prefix'); - register = new promClient.Registry(); - register.setDefaultLabels({ prefix }); - promClient.collectDefaultMetrics({ register }); - } + configureMetrics(this.app); this.frontendSettings.isNpmAvailable = await exec('npm --version') .then(() => true) @@ -590,17 +582,6 @@ class Server extends AbstractServer { this.app.use(`/${this.restEndpoint}/nodes`, nodesController); } - // ---------------------------------------- - // Metrics - // ---------------------------------------- - if (enableMetrics) { - this.app.get('/metrics', async (req: express.Request, res: express.Response) => { - const response = await register.metrics(); - res.setHeader('Content-Type', register.contentType); - ResponseHelper.sendSuccessResponse(res, response, true, 200); - }); - } - // ---------------------------------------- // Workflow // ---------------------------------------- diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index 20bc0331d6..a8b0a9ef3e 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -88,7 +88,9 @@ export function executeErrorWorkflow( let pastExecutionUrl: string | undefined; if (executionId !== undefined) { - pastExecutionUrl = `${WebhookHelpers.getWebhookBaseUrl()}execution/${executionId}`; + pastExecutionUrl = `${WebhookHelpers.getWebhookBaseUrl()}workflow/${ + workflowData.id + }/executions/${executionId}`; } if (fullRunData.data.resultData.error !== undefined) { diff --git a/packages/cli/src/config/schema.ts b/packages/cli/src/config/schema.ts index ef55c7d64a..4ea7765fd5 100644 --- a/packages/cli/src/config/schema.ts +++ b/packages/cli/src/config/schema.ts @@ -573,7 +573,7 @@ export const schema = { format: 'Boolean', default: false, env: 'N8N_METRICS', - doc: 'Enable metrics endpoint', + doc: 'Enable /metrics endpoint. Default: false', }, prefix: { format: String, @@ -581,6 +581,54 @@ export const schema = { env: 'N8N_METRICS_PREFIX', doc: 'An optional prefix for metric names. Default: n8n_', }, + includeDefaultMetrics: { + format: Boolean, + default: true, + env: 'N8N_METRICS_INCLUDE_DEFAULT_METRICS', + doc: 'Whether to expose default system and node.js metrics. Default: true', + }, + includeWorkflowIdLabel: { + format: Boolean, + default: false, + env: 'N8N_METRICS_INCLUDE_WORKFLOW_ID_LABEL', + doc: 'Whether to include a label for the workflow ID on workflow metrics. Default: false', + }, + includeNodeTypeLabel: { + format: Boolean, + default: false, + env: 'N8N_METRICS_INCLUDE_NODE_TYPE_LABEL', + doc: 'Whether to include a label for the node type on node metrics. Default: false', + }, + includeCredentialTypeLabel: { + format: Boolean, + default: false, + env: 'N8N_METRICS_INCLUDE_CREDENTIAL_TYPE_LABEL', + doc: 'Whether to include a label for the credential type on credential metrics. Default: false', + }, + includeApiEndpoints: { + format: Boolean, + default: false, + env: 'N8N_METRICS_INCLUDE_API_ENDPOINTS', + doc: 'Whether to expose metrics for API endpoints. Default: false', + }, + includeApiPathLabel: { + format: Boolean, + default: false, + env: 'N8N_METRICS_INCLUDE_API_PATH_LABEL', + doc: 'Whether to include a label for the path of API invocations. Default: false', + }, + includeApiMethodLabel: { + format: Boolean, + default: false, + env: 'N8N_METRICS_INCLUDE_API_METHOD_LABEL', + doc: 'Whether to include a label for the HTTP method (GET, POST, ...) of API invocations. Default: false', + }, + includeApiStatusCodeLabel: { + format: Boolean, + default: false, + env: 'N8N_METRICS_INCLUDE_API_STATUS_CODE_LABEL', + doc: 'Whether to include a label for the HTTP status code (200, 404, ...) of API invocations. Default: false', + }, }, rest: { format: String, diff --git a/packages/cli/src/eventbus/EventMessageClasses/EventMessageAudit.ts b/packages/cli/src/eventbus/EventMessageClasses/EventMessageAudit.ts index 5c59095f8c..baf8089964 100644 --- a/packages/cli/src/eventbus/EventMessageClasses/EventMessageAudit.ts +++ b/packages/cli/src/eventbus/EventMessageClasses/EventMessageAudit.ts @@ -35,6 +35,11 @@ export interface EventPayloadAudit extends AbstractEventPayload { userEmail?: string; firstName?: string; lastName?: string; + credentialName?: string; + credentialType?: string; + credentialId?: string; + workflowId?: string; + workflowName?: string; } export interface EventMessageAuditOptions extends AbstractEventMessageOptions { diff --git a/packages/cli/src/eventbus/EventMessageClasses/EventMessageNode.ts b/packages/cli/src/eventbus/EventMessageClasses/EventMessageNode.ts index a7c50f1211..cbf726d941 100644 --- a/packages/cli/src/eventbus/EventMessageClasses/EventMessageNode.ts +++ b/packages/cli/src/eventbus/EventMessageClasses/EventMessageNode.ts @@ -11,6 +11,11 @@ export type EventNamesNodeType = typeof eventNamesNode[number]; // -------------------------------------- export interface EventPayloadNode extends AbstractEventPayload { msg?: string; + executionId: string; + nodeName: string; + workflowId?: string; + workflowName: string; + nodeType?: string; } export interface EventMessageNodeOptions extends AbstractEventMessageOptions { diff --git a/packages/cli/src/eventbus/MessageEventBus/MessageEventBus.ts b/packages/cli/src/eventbus/MessageEventBus/MessageEventBus.ts index ea773a3b34..2751dc0f91 100644 --- a/packages/cli/src/eventbus/MessageEventBus/MessageEventBus.ts +++ b/packages/cli/src/eventbus/MessageEventBus/MessageEventBus.ts @@ -6,7 +6,10 @@ import { MessageEventBusLogWriter } from '../MessageEventBusWriter/MessageEventB import EventEmitter from 'events'; import config from '@/config'; import * as Db from '@/Db'; -import { messageEventBusDestinationFromDb } from '../MessageEventBusDestination/Helpers.ee'; +import { + messageEventBusDestinationFromDb, + incrementPrometheusMetric, +} from '../MessageEventBusDestination/Helpers.ee'; import uniqby from 'lodash.uniqby'; import { EventMessageConfirmSource } from '../EventMessageClasses/EventMessageConfirm'; import { @@ -205,6 +208,10 @@ class MessageEventBus extends EventEmitter { } private async emitMessage(msg: EventMessageTypes) { + if (config.getEnv('endpoints.metrics.enable')) { + await incrementPrometheusMetric(msg); + } + // generic emit for external modules to capture events // this is for internal use ONLY and not for use with custom destinations! this.emit('message', msg); diff --git a/packages/cli/src/eventbus/MessageEventBusDestination/Helpers.ee.ts b/packages/cli/src/eventbus/MessageEventBusDestination/Helpers.ee.ts index abc08a87e1..712b1170dc 100644 --- a/packages/cli/src/eventbus/MessageEventBusDestination/Helpers.ee.ts +++ b/packages/cli/src/eventbus/MessageEventBusDestination/Helpers.ee.ts @@ -1,6 +1,13 @@ /* eslint-disable import/no-cycle */ -import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import type { EventDestinations } from '@/databases/entities/MessageEventBusDestinationEntity'; +import { promClient } from '@/metrics'; +import { + EventMessageTypeNames, + LoggerProxy, + MessageEventBusDestinationTypeNames, +} from 'n8n-workflow'; +import config from '../../config'; +import type { EventMessageTypes } from '../EventMessageClasses'; import type { MessageEventBusDestination } from './MessageEventBusDestination.ee'; import { MessageEventBusDestinationSentry } from './MessageEventBusDestinationSentry.ee'; import { MessageEventBusDestinationSyslog } from './MessageEventBusDestinationSyslog.ee'; @@ -24,3 +31,85 @@ export function messageEventBusDestinationFromDb( } return null; } + +const prometheusCounters: Record | null> = {}; + +function getMetricNameForEvent(event: EventMessageTypes): string { + const prefix = config.getEnv('endpoints.metrics.prefix'); + return prefix + event.eventName.replace('n8n.', '').replace(/\./g, '_') + '_total'; +} + +function getLabelValueForNode(nodeType: string): string { + return nodeType.replace('n8n-nodes-', '').replace(/\./g, '_'); +} + +function getLabelValueForCredential(credentialType: string): string { + return credentialType.replace(/\./g, '_'); +} + +function getLabelsForEvent(event: EventMessageTypes): Record { + switch (event.__type) { + case EventMessageTypeNames.audit: + if (event.eventName.startsWith('n8n.audit.user.credentials')) { + return config.getEnv('endpoints.metrics.includeCredentialTypeLabel') + ? { + credential_type: getLabelValueForCredential( + event.payload.credentialType ?? 'unknown', + ), + } + : {}; + } + + if (event.eventName.startsWith('n8n.audit.workflow')) { + return config.getEnv('endpoints.metrics.includeWorkflowIdLabel') + ? { workflow_id: event.payload.workflowId?.toString() ?? 'unknown' } + : {}; + } + break; + + case EventMessageTypeNames.node: + return config.getEnv('endpoints.metrics.includeNodeTypeLabel') + ? { node_type: getLabelValueForNode(event.payload.nodeType ?? 'unknown') } + : {}; + + case EventMessageTypeNames.workflow: + return config.getEnv('endpoints.metrics.includeWorkflowIdLabel') + ? { workflow_id: event.payload.workflowId?.toString() ?? 'unknown' } + : {}; + } + + return {}; +} + +function getCounterSingletonForEvent(event: EventMessageTypes) { + if (!prometheusCounters[event.eventName]) { + const metricName = getMetricNameForEvent(event); + + if (!promClient.validateMetricName(metricName)) { + LoggerProxy.debug(`Invalid metric name: ${metricName}. Ignoring it!`); + prometheusCounters[event.eventName] = null; + return null; + } + + const counter = new promClient.Counter({ + name: metricName, + help: `Total number of ${event.eventName} events.`, + labelNames: Object.keys(getLabelsForEvent(event)), + }); + + promClient.register.registerMetric(counter); + prometheusCounters[event.eventName] = counter; + } + + return prometheusCounters[event.eventName]; +} + +export async function incrementPrometheusMetric(event: EventMessageTypes): Promise { + const counter = getCounterSingletonForEvent(event); + + if (!counter) { + return; + } + + counter.inc(getLabelsForEvent(event)); +} diff --git a/packages/cli/src/eventbus/eventBusRoutes.ts b/packages/cli/src/eventbus/eventBusRoutes.ts index d5a30fc9fb..ea1108d840 100644 --- a/packages/cli/src/eventbus/eventBusRoutes.ts +++ b/packages/cli/src/eventbus/eventBusRoutes.ts @@ -32,6 +32,7 @@ import { } from 'n8n-workflow'; import { User } from '../databases/entities/User'; import * as ResponseHelper from '@/ResponseHelper'; +import { EventMessageNode, EventMessageNodeOptions } from './EventMessageClasses/EventMessageNode'; export const eventBusRouter = express.Router(); @@ -116,6 +117,9 @@ eventBusRouter.post( case EventMessageTypeNames.audit: msg = new EventMessageAudit(req.body as EventMessageAuditOptions); break; + case EventMessageTypeNames.node: + msg = new EventMessageNode(req.body as EventMessageNodeOptions); + break; case EventMessageTypeNames.generic: default: msg = new EventMessageGeneric(req.body); diff --git a/packages/cli/src/metrics/index.ts b/packages/cli/src/metrics/index.ts new file mode 100644 index 0000000000..80b211494d --- /dev/null +++ b/packages/cli/src/metrics/index.ts @@ -0,0 +1,71 @@ +/* eslint-disable @typescript-eslint/no-use-before-define */ +import config from '@/config'; +import { N8N_VERSION } from '@/constants'; +import * as ResponseHelper from '@/ResponseHelper'; +import express from 'express'; +import promBundle from 'express-prom-bundle'; +import promClient from 'prom-client'; +import semverParse from 'semver/functions/parse'; + +export { promClient }; + +export function configureMetrics(app: express.Application) { + if (!config.getEnv('endpoints.metrics.enable')) { + return; + } + + setupDefaultMetrics(); + setupN8nVersionMetric(); + setupApiMetrics(app); + mountMetricsEndpoint(app); +} + +function setupN8nVersionMetric() { + const n8nVersion = semverParse(N8N_VERSION || '0.0.0'); + + if (n8nVersion) { + const versionGauge = new promClient.Gauge({ + name: config.getEnv('endpoints.metrics.prefix') + 'version_info', + help: 'n8n version info.', + labelNames: ['version', 'major', 'minor', 'patch'], + }); + + versionGauge.set( + { + version: 'v' + n8nVersion.version, + major: n8nVersion.major, + minor: n8nVersion.minor, + patch: n8nVersion.patch, + }, + 1, + ); + } +} + +function setupDefaultMetrics() { + if (config.getEnv('endpoints.metrics.includeDefaultMetrics')) { + promClient.collectDefaultMetrics(); + } +} + +function setupApiMetrics(app: express.Application) { + if (config.getEnv('endpoints.metrics.includeApiEndpoints')) { + const metricsMiddleware = promBundle({ + autoregister: false, + includeUp: false, + includePath: config.getEnv('endpoints.metrics.includeApiPathLabel'), + includeMethod: config.getEnv('endpoints.metrics.includeApiMethodLabel'), + includeStatusCode: config.getEnv('endpoints.metrics.includeApiStatusCodeLabel'), + }); + + app.use(['/rest/', '/webhook/', 'webhook-test/', '/api/'], metricsMiddleware); + } +} + +function mountMetricsEndpoint(app: express.Application) { + app.get('/metrics', async (req: express.Request, res: express.Response) => { + const response = await promClient.register.metrics(); + res.setHeader('Content-Type', promClient.register.contentType); + ResponseHelper.sendSuccessResponse(res, response, true, 200); + }); +} diff --git a/packages/cli/test/integration/eventbus.test.ts b/packages/cli/test/integration/eventbus.test.ts index b1349a5758..62c57ac091 100644 --- a/packages/cli/test/integration/eventbus.test.ts +++ b/packages/cli/test/integration/eventbus.test.ts @@ -178,7 +178,7 @@ test('GET /eventbus/destination all returned destinations should exist in eventb } }); -test('should send message to syslog ', async () => { +test.skip('should send message to syslog', async () => { const testMessage = new EventMessageGeneric({ eventName: 'n8n.test.message', id: uuid() }); config.set('enterprise.features.logStreaming', true); // await cleanLogs(); @@ -217,7 +217,7 @@ test('should send message to syslog ', async () => { }); }); -test('should confirm send message if there are no subscribers', async () => { +test.skip('should confirm send message if there are no subscribers', async () => { const testMessageUnsubscribed = new EventMessageGeneric({ eventName: 'n8n.test.unsub', id: uuid(), diff --git a/packages/editor-ui/package.json b/packages/editor-ui/package.json index 2362f258d0..e63664d9df 100644 --- a/packages/editor-ui/package.json +++ b/packages/editor-ui/package.json @@ -1,6 +1,6 @@ { "name": "n8n-editor-ui", - "version": "0.177.1", + "version": "0.178.0", "description": "Workflow Editor UI for n8n", "license": "SEE LICENSE IN LICENSE.md", "homepage": "https://n8n.io", diff --git a/packages/editor-ui/src/api/eventbus.ee.ts b/packages/editor-ui/src/api/eventbus.ee.ts new file mode 100644 index 0000000000..1b00f84630 --- /dev/null +++ b/packages/editor-ui/src/api/eventbus.ee.ts @@ -0,0 +1,54 @@ +import { IRestApiContext } from '@/Interface'; +import { makeRestApiRequest } from '@/utils'; +import { IDataObject, MessageEventBusDestinationOptions } from 'n8n-workflow'; + +export async function saveDestinationToDb( + context: IRestApiContext, + destination: MessageEventBusDestinationOptions, + subscribedEvents: string[] = [], +) { + if (destination.id) { + const data: IDataObject = { + ...destination, + subscribedEvents, + }; + return makeRestApiRequest(context, 'POST', '/eventbus/destination', data); + } +} + +export async function deleteDestinationFromDb(context: IRestApiContext, destinationId: string) { + return makeRestApiRequest(context, 'DELETE', `/eventbus/destination?id=${destinationId}`); +} + +export async function sendTestMessageToDestination( + context: IRestApiContext, + destination: MessageEventBusDestinationOptions, +) { + if (destination.id) { + const data: IDataObject = { + ...destination, + }; + return makeRestApiRequest(context, 'GET', '/eventbus/testmessage', data); + } +} + +export async function getEventNamesFromBackend(context: IRestApiContext): Promise { + return makeRestApiRequest(context, 'GET', '/eventbus/eventnames'); +} + +export async function getDestinationsFromBackend( + context: IRestApiContext, +): Promise { + return makeRestApiRequest(context, 'GET', '/eventbus/destination'); +} + +export async function getExecutionEvents(context: IRestApiContext, executionId: string) { + return makeRestApiRequest(context, 'GET', `/eventbus/execution/${executionId}`); +} + +export async function recoverExecutionDataFromEvents( + context: IRestApiContext, + executionId: string, +) { + return makeRestApiRequest(context, 'GET', `/eventbus/execution-recover/${executionId}`); +} diff --git a/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationCard.ee.vue b/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationCard.ee.vue index 94c8c00a40..b6823fa63a 100644 --- a/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationCard.ee.vue +++ b/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationCard.ee.vue @@ -51,7 +51,6 @@ import mixins from 'vue-typed-mixins'; import { EnterpriseEditionFeature } from '@/constants'; import { showMessage } from '@/mixins/showMessage'; import { useLogStreamingStore } from '../../stores/logStreamingStore'; -import { restApi } from '@/mixins/restApi'; import Vue from 'vue'; import { mapStores } from 'pinia'; import { @@ -59,7 +58,6 @@ import { defaultMessageEventBusDestinationOptions, MessageEventBusDestinationOptions, } from 'n8n-workflow'; -import { saveDestinationToDb } from './Helpers.ee'; import { BaseTextKey } from '../../plugins/i18n'; export const DESTINATION_LIST_ITEM_ACTIONS = { @@ -67,7 +65,7 @@ export const DESTINATION_LIST_ITEM_ACTIONS = { DELETE: 'delete', }; -export default mixins(showMessage, restApi).extend({ +export default mixins(showMessage).extend({ data() { return { EnterpriseEditionFeature, @@ -142,7 +140,7 @@ export default mixins(showMessage, restApi).extend({ this.saveDestination(); }, async saveDestination() { - await saveDestinationToDb(this.restApi(), this.nodeParameters); + await this.logStreamingStore.saveDestination(this.nodeParameters); }, async onAction(action: string) { if (action === DESTINATION_LIST_ITEM_ACTIONS.OPEN) { diff --git a/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationSettingsModal.ee.vue b/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationSettingsModal.ee.vue index 3e66cb512f..0b793d1d81 100644 --- a/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationSettingsModal.ee.vue +++ b/packages/editor-ui/src/components/SettingsLogStreaming/EventDestinationSettingsModal.ee.vue @@ -178,7 +178,6 @@ import mixins from 'vue-typed-mixins'; import { useLogStreamingStore } from '../../stores/logStreamingStore'; import { useNDVStore } from '../../stores/ndv'; import { useWorkflowsStore } from '../../stores/workflows'; -import { restApi } from '../../mixins/restApi'; import ParameterInputList from '@/components/ParameterInputList.vue'; import NodeCredentials from '@/components/NodeCredentials.vue'; import { IMenuItem, INodeUi, ITab, IUpdateInformation } from '../../Interface'; @@ -200,7 +199,7 @@ import Modal from '@/components/Modal.vue'; import { showMessage } from '@/mixins/showMessage'; import { useUIStore } from '../../stores/ui'; import { useUsersStore } from '../../stores/users'; -import { destinationToFakeINodeUi, saveDestinationToDb, sendTestMessage } from './Helpers.ee'; +import { destinationToFakeINodeUi } from './Helpers.ee'; import { webhookModalDescription, sentryModalDescription, @@ -212,7 +211,7 @@ import SaveButton from '../SaveButton.vue'; import EventSelection from '@/components/SettingsLogStreaming/EventSelection.ee.vue'; import { Checkbox } from 'element-ui'; -export default mixins(showMessage, restApi).extend({ +export default mixins(showMessage).extend({ name: 'event-destination-settings-modal', props: { modalName: String, @@ -427,12 +426,14 @@ export default mixins(showMessage, restApi).extend({ this.nodeParameters = deepCopy(nodeParameters); this.workflowsStore.updateNodeProperties({ name: this.node.name, - properties: { parameters: this.nodeParameters as unknown as IDataObject }, + properties: { parameters: this.nodeParameters as unknown as IDataObject, position: [0, 0] }, }); - this.logStreamingStore.updateDestination(this.nodeParameters); + if (this.hasOnceBeenSaved) { + this.logStreamingStore.updateDestination(this.nodeParameters); + } }, async sendTestEvent() { - this.testMessageResult = await sendTestMessage(this.restApi(), this.nodeParameters); + this.testMessageResult = await this.logStreamingStore.sendTestMessage(this.nodeParameters); this.testMessageSent = true; }, async removeThis() { @@ -467,12 +468,14 @@ export default mixins(showMessage, restApi).extend({ if (this.unchanged || !this.destination.id) { return; } - await saveDestinationToDb(this.restApi(), this.nodeParameters); - this.hasOnceBeenSaved = true; - this.testMessageSent = false; - this.unchanged = true; - this.$props.eventBus.$emit('destinationWasSaved', this.destination.id); - this.uiStore.stateIsDirty = false; + const saveResult = await this.logStreamingStore.saveDestination(this.nodeParameters); + if (saveResult === true) { + this.hasOnceBeenSaved = true; + this.testMessageSent = false; + this.unchanged = true; + this.$props.eventBus.$emit('destinationWasSaved', this.destination.id); + this.uiStore.stateIsDirty = false; + } }, }, }); diff --git a/packages/editor-ui/src/components/SettingsLogStreaming/Helpers.ee.ts b/packages/editor-ui/src/components/SettingsLogStreaming/Helpers.ee.ts index 26b8bd5bce..1f367ed9c1 100644 --- a/packages/editor-ui/src/components/SettingsLogStreaming/Helpers.ee.ts +++ b/packages/editor-ui/src/components/SettingsLogStreaming/Helpers.ee.ts @@ -1,6 +1,5 @@ import { INodeCredentials, INodeParameters, MessageEventBusDestinationOptions } from 'n8n-workflow'; -import { INodeUi, IRestApi } from '../../Interface'; -import { useLogStreamingStore } from '../../stores/logStreamingStore'; +import { INodeUi } from '../../Interface'; export function destinationToFakeINodeUi( destination: MessageEventBusDestinationOptions, @@ -20,39 +19,3 @@ export function destinationToFakeINodeUi( }, } as INodeUi; } - -export async function saveDestinationToDb( - restApi: IRestApi, - destination: MessageEventBusDestinationOptions, -) { - const logStreamingStore = useLogStreamingStore(); - if (destination.id) { - const data: MessageEventBusDestinationOptions = { - ...destination, - subscribedEvents: logStreamingStore.getSelectedEvents(destination.id), - }; - try { - await restApi.makeRestApiRequest('POST', '/eventbus/destination', data); - } catch (error) { - console.log(error); - } - logStreamingStore.updateDestination(destination); - } -} - -export async function sendTestMessage( - restApi: IRestApi, - destination: MessageEventBusDestinationOptions, -) { - if (destination.id) { - try { - const sendResult = await restApi.makeRestApiRequest('GET', '/eventbus/testmessage', { - id: destination.id, - }); - return sendResult; - } catch (error) { - console.log(error); - } - return false; - } -} diff --git a/packages/editor-ui/src/stores/logStreamingStore.ts b/packages/editor-ui/src/stores/logStreamingStore.ts index 6e157716d2..3c1794cbe5 100644 --- a/packages/editor-ui/src/stores/logStreamingStore.ts +++ b/packages/editor-ui/src/stores/logStreamingStore.ts @@ -1,5 +1,13 @@ import { deepCopy, MessageEventBusDestinationOptions } from 'n8n-workflow'; import { defineStore } from 'pinia'; +import { + deleteDestinationFromDb, + getDestinationsFromBackend, + getEventNamesFromBackend, + saveDestinationToDb, + sendTestMessageToDestination, +} from '../api/eventbus.ee'; +import { useRootStore } from './n8nRootStore'; export interface EventSelectionItem { selected: boolean; @@ -8,18 +16,19 @@ export interface EventSelectionItem { label: string; } -export interface EventSelectionGroup extends EventSelectionItem { +interface EventSelectionGroup extends EventSelectionItem { children: EventSelectionItem[]; } -export interface TreeAndSelectionStoreItem { +interface DestinationStoreItem { destination: MessageEventBusDestinationOptions; selectedEvents: Set; eventGroups: EventSelectionGroup[]; + isNew: boolean; } export interface DestinationSettingsStore { - [key: string]: TreeAndSelectionStoreItem; + [key: string]: DestinationStoreItem; } export const useLogStreamingStore = defineStore('logStreaming', { @@ -51,13 +60,15 @@ export const useLogStreamingStore = defineStore('logStreaming', { return destinations; }, updateDestination(destination: MessageEventBusDestinationOptions) { - this.$patch((state) => { - if (destination.id && destination.id in this.items) { - state.items[destination.id].destination = destination; - } - // to trigger refresh - state.items = deepCopy(state.items); - }); + if (destination.id && destination.id in this.items) { + this.$patch((state) => { + if (destination.id && destination.id in this.items) { + state.items[destination.id].destination = destination; + } + // to trigger refresh + state.items = deepCopy(state.items); + }); + } }, removeDestination(destinationId: string) { if (!destinationId) return; @@ -159,7 +170,8 @@ export const useLogStreamingStore = defineStore('logStreaming', { destination, selectedEvents: new Set(), eventGroups: [], - } as TreeAndSelectionStoreItem; + isNew: false, + } as DestinationStoreItem; } this.items[destination.id]?.selectedEvents?.clear(); if (destination.subscribedEvents) { @@ -173,6 +185,44 @@ export const useLogStreamingStore = defineStore('logStreaming', { ); } }, + async saveDestination(destination: MessageEventBusDestinationOptions): Promise { + if (destination.id) { + const rootStore = useRootStore(); + const selectedEvents = this.getSelectedEvents(destination.id); + try { + await saveDestinationToDb(rootStore.getRestApiContext, destination, selectedEvents); + this.updateDestination(destination); + return true; + } catch (e) { + return false; + } + } + return false; + }, + async sendTestMessage(destination: MessageEventBusDestinationOptions) { + if (destination.id) { + const rootStore = useRootStore(); + const testResult = await sendTestMessageToDestination( + rootStore.getRestApiContext, + destination, + ); + return testResult; + } + return false; + }, + async fetchEventNames(): Promise { + const rootStore = useRootStore(); + return getEventNamesFromBackend(rootStore.getRestApiContext); + }, + async fetchDestinations(): Promise { + const rootStore = useRootStore(); + return getDestinationsFromBackend(rootStore.getRestApiContext); + }, + async deleteDestination(destinationId: string) { + const rootStore = useRootStore(); + await deleteDestinationFromDb(rootStore.getRestApiContext, destinationId); + this.removeDestination(destinationId); + }, }, }); diff --git a/packages/editor-ui/src/views/SettingsLogStreamingView.vue b/packages/editor-ui/src/views/SettingsLogStreamingView.vue index eb8f6adaa2..eb70ebc10d 100644 --- a/packages/editor-ui/src/views/SettingsLogStreamingView.vue +++ b/packages/editor-ui/src/views/SettingsLogStreamingView.vue @@ -90,7 +90,6 @@ import { useSettingsStore } from '../stores/settings'; import { useUIStore } from '../stores/ui'; import { LOG_STREAM_MODAL_KEY, EnterpriseEditionFeature } from '../constants'; import Vue from 'vue'; -import { restApi } from '../mixins/restApi'; import { deepCopy, defaultMessageEventBusDestinationOptions, @@ -99,7 +98,7 @@ import { import PageViewLayout from '@/components/layouts/PageViewLayout.vue'; import EventDestinationCard from '@/components/SettingsLogStreaming/EventDestinationCard.ee.vue'; -export default mixins(restApi).extend({ +export default mixins().extend({ name: 'SettingsLogStreamingView', props: {}, components: { @@ -125,7 +124,7 @@ export default mixins(restApi).extend({ this.uiStore.nodeViewInitialized = false; // fetch Destination data from the backend - await this.getDestinationDataFromREST(); + await this.getDestinationDataFromBackend(); // since we are not really integrated into the hooks, we listen to the store and refresh the destinations this.logStreamingStore.$onAction(({ name, after }) => { @@ -174,18 +173,18 @@ export default mixins(restApi).extend({ }, }, methods: { - async getDestinationDataFromREST(): Promise { + async getDestinationDataFromBackend(): Promise { this.logStreamingStore.clearEventNames(); this.logStreamingStore.clearDestinationItemTrees(); this.allDestinations = []; - const eventNamesData = await this.restApi().makeRestApiRequest('get', '/eventbus/eventnames'); + const eventNamesData = await this.logStreamingStore.fetchEventNames(); if (eventNamesData) { for (const eventName of eventNamesData) { this.logStreamingStore.addEventName(eventName); } } const destinationData: MessageEventBusDestinationOptions[] = - await this.restApi().makeRestApiRequest('get', '/eventbus/destination'); + await this.logStreamingStore.fetchDestinations(); if (destinationData) { for (const destination of destinationData) { this.logStreamingStore.addDestination(destination); @@ -218,11 +217,7 @@ export default mixins(restApi).extend({ }, async onRemove(destinationId?: string) { if (!destinationId) return; - await this.restApi().makeRestApiRequest( - 'DELETE', - `/eventbus/destination?id=${destinationId}`, - ); - this.logStreamingStore.removeDestination(destinationId); + await this.logStreamingStore.deleteDestination(destinationId); const foundNode = this.workflowsStore.getNodeByName(destinationId); if (foundNode) { this.workflowsStore.removeNode(foundNode); diff --git a/packages/nodes-base/.eslintrc.js b/packages/nodes-base/.eslintrc.js index 7934e2fc38..2edf1d7439 100644 --- a/packages/nodes-base/.eslintrc.js +++ b/packages/nodes-base/.eslintrc.js @@ -29,6 +29,7 @@ module.exports = { '@typescript-eslint/restrict-template-expressions': 'off', //1152 errors, better to fix in separate PR '@typescript-eslint/unbound-method': 'off', '@typescript-eslint/ban-ts-comment': ['warn', { 'ts-ignore': true }], + '@typescript-eslint/prefer-nullish-coalescing': 'off', }, overrides: [ diff --git a/packages/nodes-base/credentials/LinearApi.credentials.ts b/packages/nodes-base/credentials/LinearApi.credentials.ts index 3b96080274..203e67543b 100644 --- a/packages/nodes-base/credentials/LinearApi.credentials.ts +++ b/packages/nodes-base/credentials/LinearApi.credentials.ts @@ -1,4 +1,4 @@ -import { ICredentialType, INodeProperties } from 'n8n-workflow'; +import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow'; export class LinearApi implements ICredentialType { name = 'linearApi'; @@ -16,4 +16,13 @@ export class LinearApi implements ICredentialType { default: '', }, ]; + + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + headers: { + Authorization: '={{$credentials.apiKey}}', + }, + }, + }; } diff --git a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts b/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts index 10229a2205..51e3981ed7 100644 --- a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts @@ -32,7 +32,7 @@ export async function acuitySchedulingApiRequest( method, qs, body, - uri: uri ?? `https://acuityscheduling.com/api/v1${resource}`, + uri: uri || `https://acuityscheduling.com/api/v1${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts index 60af6bfcbd..8ebeac607b 100644 --- a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts @@ -27,7 +27,7 @@ export async function affinityApiRequest( method, body, qs: query, - uri: uri ?? `${endpoint}${resource}`, + uri: uri || `${endpoint}${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts index 978ee238e9..576e5b6960 100644 --- a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts @@ -33,7 +33,7 @@ export async function agileCrmApiRequest( password: credentials.apiKey as string, }, qs: query, - uri: uri ?? `https://${credentials.subdomain}.agilecrm.com/dev/${endpoint}`, + uri: uri || `https://${credentials.subdomain}.agilecrm.com/dev/${endpoint}`, json: true, }; @@ -113,7 +113,7 @@ export async function agileCrmApiRequestUpdate( username: credentials.email as string, password: credentials.apiKey as string, }, - uri: uri ?? baseUri, + uri: uri || baseUri, json: true, }; diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index b71021970c..3f24a79162 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -34,7 +34,7 @@ export async function apiRequest( uri?: string, option: IDataObject = {}, ): Promise { - query = query ?? {}; + query = query || {}; // For some reason for some endpoints the bearer auth does not work // and it returns 404 like for the /meta request. So we always send @@ -46,7 +46,7 @@ export async function apiRequest( method, body, qs: query, - uri: uri ?? `https://api.airtable.com/v0/${endpoint}`, + uri: uri || `https://api.airtable.com/v0/${endpoint}`, useQuerystring: false, json: true, }; diff --git a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts index c49917b183..bbc583d339 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts @@ -441,7 +441,7 @@ export class ApiTemplateIo implements INodeType { const fileName = responseData.download_url.split('/').pop(); const binaryData = await this.helpers.prepareBinaryData( data, - options.fileName ?? fileName, + options.fileName || fileName, ); responseData = { json: responseData, @@ -525,7 +525,7 @@ export class ApiTemplateIo implements INodeType { const fileName = responseData.download_url.split('/').pop(); const binaryData = await this.helpers.prepareBinaryData( imageData, - options.fileName ?? fileName, + options.fileName || fileName, ); responseData = { json: responseData, diff --git a/packages/nodes-base/nodes/Asana/GenericFunctions.ts b/packages/nodes-base/nodes/Asana/GenericFunctions.ts index cdb32e7faa..c120e64bfb 100644 --- a/packages/nodes-base/nodes/Asana/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Asana/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function asanaApiRequest( method, body: { data: body }, qs: query, - url: uri ?? `https://app.asana.com/api/1.0${endpoint}`, + url: uri || `https://app.asana.com/api/1.0${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts index 03a83feb27..a7b322c784 100644 --- a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function autopilotApiRequest( method, body, qs: query, - uri: uri ?? `${endpoint}${resource}`, + uri: uri || `${endpoint}${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts index 782119747e..f383c9de14 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts @@ -44,7 +44,7 @@ export async function awsApiRequest( const endpoint = new URL(getEndpointForService(service, credentials) + path); // Sign AWS API request with the user credentials - const signOpts = { headers: headers ?? {}, host: endpoint.host, method, path, body } as Request; + const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request; const securityHeaders = { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim(), diff --git a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts index a6e40f6750..a9f3916305 100644 --- a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function bannerbearApiRequest( method, body, qs: query, - uri: uri ?? `https://api.bannerbear.com/v2${resource}`, + uri: uri || `https://api.bannerbear.com/v2${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts index 23f06c90fd..f55259febe 100644 --- a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function bitbucketApiRequest( }, qs, body, - uri: uri ?? `https://api.bitbucket.org/2.0${resource}`, + uri: uri || `https://api.bitbucket.org/2.0${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts index 75d3a2b14a..f29517a88c 100644 --- a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function bitlyApiRequest( method, qs, body, - uri: uri ?? `https://api-ssl.bitly.com/v4${resource}`, + uri: uri || `https://api-ssl.bitly.com/v4${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index 4c8c3e0343..fbb72d1dd3 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -138,7 +138,7 @@ export async function loadResource(this: ILoadOptionsFunctions, resource: string data.forEach(({ id, name, externalId }: { id: string; name: string; externalId?: string }) => { returnData.push({ - name: externalId ?? name ?? id, + name: externalId || name || id, value: id, }); }); diff --git a/packages/nodes-base/nodes/Box/GenericFunctions.ts b/packages/nodes-base/nodes/Box/GenericFunctions.ts index bf777aae48..bab2d59e76 100644 --- a/packages/nodes-base/nodes/Box/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Box/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function boxApiRequest( method, body, qs, - uri: uri ?? `https://api.box.com/2.0${resource}`, + uri: uri || `https://api.box.com/2.0${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts b/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts index dbcd28c255..dafeb2e9cc 100644 --- a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function brandfetchApiRequest( method, qs, body, - uri: uri ?? `https://api.brandfetch.io/v1${resource}`, + uri: uri || `https://api.brandfetch.io/v1${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts index 60afd61d10..98b29df8a4 100644 --- a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts @@ -46,7 +46,7 @@ export async function calendlyApiRequest( method, body, qs: query, - uri: uri ?? `${endpoint}${resource}`, + uri: uri || `${endpoint}${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts index 718800ea72..94743117ce 100644 --- a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function circleciApiRequest( method, qs, body, - uri: uri ?? `https://circleci.com/api/v2${resource}`, + uri: uri || `https://circleci.com/api/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts index 82290bc557..666fd57b52 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function webexApiRequest( method, body, qs, - uri: uri ?? `https://webexapis.com/v1${resource}`, + uri: uri || `https://webexapis.com/v1${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts b/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts index ee91d8aecd..0e5c6c1e16 100644 --- a/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Citrix/ADC/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function citrixADCApiRequest( method, body, qs, - uri: uri ?? `${url.replace(new RegExp('/$'), '')}/nitro/v1${resource}`, + uri: uri || `${url.replace(new RegExp('/$'), '')}/nitro/v1${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts index 116e4d46da..8994b94966 100644 --- a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function clearbitApiRequest( method, qs, body, - uri: uri ?? `https://${api}.clearbit.com${resource}`, + uri: uri || `https://${api}.clearbit.com${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts index 983685a20c..75248a2b72 100644 --- a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts @@ -32,7 +32,7 @@ export async function clickupApiRequest( method, qs, body, - uri: uri ?? `https://api.clickup.com/api/v2${resource}`, + uri: uri || `https://api.clickup.com/api/v2${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts index 2f8c70425a..3704d2cd6c 100644 --- a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function cockpitApiRequest( token: credentials.accessToken, }, body, - uri: uri ?? `${credentials.url}/api${resource}`, + uri: uri || `${credentials.url}/api${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Coda/GenericFunctions.ts b/packages/nodes-base/nodes/Coda/GenericFunctions.ts index 7230cf4838..06355708cf 100644 --- a/packages/nodes-base/nodes/Coda/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Coda/GenericFunctions.ts @@ -19,7 +19,7 @@ export async function codaApiRequest( method, qs, body, - uri: uri ?? `https://coda.io/apis/v1${resource}`, + uri: uri || `https://coda.io/apis/v1${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts b/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts index fe34ecd126..45ed9ee335 100644 --- a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function coinGeckoApiRequest( method, body, qs, - uri: uri ?? `https://api.coingecko.com/api/v3${endpoint}`, + uri: uri || `https://api.coingecko.com/api/v3${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts b/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts index 7c3f44b169..5def47282f 100644 --- a/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CompareDatasets/GenericFunctions.ts @@ -47,14 +47,14 @@ function compareItems( differentKeys.forEach((key) => { switch (resolve) { case 'preferInput1': - different[key] = item1.json[key] ?? null; + different[key] = item1.json[key] || null; break; case 'preferInput2': - different[key] = item2.json[key] ?? null; + different[key] = item2.json[key] || null; break; default: - const input1 = item1.json[key] ?? null; - const input2 = item2.json[key] ?? null; + const input1 = item1.json[key] || null; + const input2 = item2.json[key] || null; if (skipFields.includes(key)) { skipped[key] = { input1, input2 }; } else { @@ -89,7 +89,7 @@ function combineItems( if (disableDotNotation) { entry.json[field] = match.json[field]; } else { - const value = get(match.json, field) ?? null; + const value = get(match.json, field) || null; set(entry, `json.${field}`, value); } }); diff --git a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts index de2d843b5b..01bd993bf2 100644 --- a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function contentfulApiRequest( method, qs, body, - uri: uri ?? `https://${isPreview ? 'preview' : 'cdn'}.contentful.com${resource}`, + uri: uri || `https://${isPreview ? 'preview' : 'cdn'}.contentful.com${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts index 6690da0702..830798b79d 100644 --- a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts @@ -23,7 +23,7 @@ export async function convertKitApiRequest( method, qs, body, - uri: uri ?? `https://api.convertkit.com/v3${endpoint}`, + uri: uri || `https://api.convertkit.com/v3${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts index f99e316752..68829e8bd6 100644 --- a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts @@ -27,7 +27,7 @@ export async function cortexApiRequest( headers: {}, method, qs: query, - uri: uri ?? `${credentials.host}/api${resource}`, + uri: uri || `${credentials.host}/api${resource}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/DateTime/DateTime.node.ts b/packages/nodes-base/nodes/DateTime/DateTime.node.ts index e143dc0130..6e8fc1b8bd 100644 --- a/packages/nodes-base/nodes/DateTime/DateTime.node.ts +++ b/packages/nodes-base/nodes/DateTime/DateTime.node.ts @@ -430,7 +430,7 @@ export class DateTime implements INodeType { newDate = moment.unix(currentDate as unknown as number); } else { if (options.fromTimezone || options.toTimezone) { - const fromTimezone = options.fromTimezone ?? workflowTimezone; + const fromTimezone = options.fromTimezone || workflowTimezone; if (options.fromFormat) { newDate = moment.tz( currentDate, diff --git a/packages/nodes-base/nodes/DeepL/GenericFunctions.ts b/packages/nodes-base/nodes/DeepL/GenericFunctions.ts index a23fae97f3..87cc1642ca 100644 --- a/packages/nodes-base/nodes/DeepL/GenericFunctions.ts +++ b/packages/nodes-base/nodes/DeepL/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function deepLApiRequest( method, form: body, qs, - uri: uri ?? `${credentials.apiPlan === 'pro' ? proApiEndpoint : freeApiEndpoint}${resource}`, + uri: uri || `${credentials.apiPlan === 'pro' ? proApiEndpoint : freeApiEndpoint}${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Demio/GenericFunctions.ts b/packages/nodes-base/nodes/Demio/GenericFunctions.ts index 7494afc7cc..b4227f8dab 100644 --- a/packages/nodes-base/nodes/Demio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Demio/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function demioApiRequest( method, qs, body, - uri: uri ?? `https://my.demio.com/api/v1${resource}`, + uri: uri || `https://my.demio.com/api/v1${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts index 11e74f2b03..c76e268d28 100644 --- a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts @@ -33,7 +33,7 @@ export async function dhlApiRequest( method, qs, body, - uri: uri ?? `https://api-eu.dhl.com${path}`, + uri: uri || `https://api-eu.dhl.com${path}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Drift/GenericFunctions.ts b/packages/nodes-base/nodes/Drift/GenericFunctions.ts index 66fc96bc49..30e9ea8d84 100644 --- a/packages/nodes-base/nodes/Drift/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Drift/GenericFunctions.ts @@ -19,7 +19,7 @@ export async function driftApiRequest( method, body, qs: query, - uri: uri ?? `https://driftapi.com${resource}`, + uri: uri || `https://driftapi.com${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts index 80359a68c9..83d9c53f3d 100644 --- a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function erpNextApiRequest( method, body, qs: query, - uri: uri ?? `${baseUrl}${resource}`, + uri: uri || `${baseUrl}${resource}`, json: true, rejectUnauthorized: !credentials.allowUnauthorizedCerts, }; diff --git a/packages/nodes-base/nodes/EditImage/EditImage.node.ts b/packages/nodes-base/nodes/EditImage/EditImage.node.ts index ab6d5b0b1f..01cc6d96b0 100644 --- a/packages/nodes-base/nodes/EditImage/EditImage.node.ts +++ b/packages/nodes-base/nodes/EditImage/EditImage.node.ts @@ -1239,7 +1239,7 @@ export class EditImage implements INodeType { // Combine the lines to a single string const renderText = lines.join('\n'); - const font = options.font ?? operationData.font; + const font = options.font || operationData.font; if (font && font !== 'default') { gmInstance = gmInstance!.font(font as string); diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts index f044b78537..d78c9e2fb0 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts @@ -447,7 +447,7 @@ export class ElasticSecurity implements INodeType { const body = { comment: this.getNodeParameter('comment', i), type: 'user', - owner: additionalFields.owner ?? 'securitySolution', + owner: additionalFields.owner || 'securitySolution', } as IDataObject; const caseId = this.getNodeParameter('caseId', i); diff --git a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts index a6fdcc8d54..f6bbaf5eca 100644 --- a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts +++ b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts @@ -193,7 +193,7 @@ export class EmailSend implements INodeType { continue; } attachments.push({ - filename: item.binary[propertyName].fileName ?? 'unknown', + filename: item.binary[propertyName].fileName || 'unknown', content: await this.helpers.getBinaryDataBuffer(itemIndex, propertyName), }); } diff --git a/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.node.ts b/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.node.ts index ab2db4010a..963d23d9fa 100644 --- a/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.node.ts +++ b/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.node.ts @@ -54,7 +54,7 @@ export class ErrorTrigger implements INodeType { items[0].json = { execution: { id, - url: `${urlParts.join('/')}/${id}`, + url: `${urlParts.join('/')}/workflow/1/${id}`, retryOf: '34', error: { message: 'Example Error Message', diff --git a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts index 827f0eef67..ddaec221b0 100644 --- a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function eventbriteApiRequest( method, qs, body, - uri: uri ?? `https://www.eventbriteapi.com/v3${resource}`, + uri: uri || `https://www.eventbriteapi.com/v3${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts b/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts index 95c1dd9ed5..eef2d8b94c 100644 --- a/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts +++ b/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts @@ -38,7 +38,7 @@ async function execPromise(command: string): Promise { resolve(returnData); }).on('exit', (code) => { - returnData.exitCode = code ?? 0; + returnData.exitCode = code || 0; }); }); } diff --git a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts index c09cee0145..f6b47a4e3a 100644 --- a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts @@ -45,7 +45,7 @@ export async function facebookApiRequest( qs, body, gzip: true, - uri: uri ?? `https://graph.facebook.com/v8.0${resource}`, + uri: uri || `https://graph.facebook.com/v8.0${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Figma/GenericFunctions.ts b/packages/nodes-base/nodes/Figma/GenericFunctions.ts index b6556a464d..7aa17fd22f 100644 --- a/packages/nodes-base/nodes/Figma/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Figma/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function figmaApiRequest( headers: { 'X-FIGMA-TOKEN': credentials.accessToken }, method, body, - uri: uri ?? `https://api.figma.com${resource}`, + uri: uri || `https://api.figma.com${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Flow/GenericFunctions.ts b/packages/nodes-base/nodes/Flow/GenericFunctions.ts index 34f18a87a4..a784cb926b 100644 --- a/packages/nodes-base/nodes/Flow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Flow/GenericFunctions.ts @@ -24,7 +24,7 @@ export async function flowApiRequest( method, qs, body, - uri: uri ?? `https://api.getflow.com/v2${resource}`, + uri: uri || `https://api.getflow.com/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts index 14ff66d04a..cf4aefac96 100644 --- a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts @@ -16,7 +16,7 @@ async function getToken( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, credentials: IFormIoCredentials, ) { - const base = credentials.domain ?? 'https://formio.form.io'; + const base = credentials.domain || 'https://formio.form.io'; const options = { headers: { 'Content-Type': 'application/json', @@ -57,7 +57,7 @@ export async function formIoApiRequest( const token = await getToken.call(this, credentials); - const base = credentials.domain ?? 'https://api.form.io'; + const base = credentials.domain || 'https://api.form.io'; const options = { headers: { diff --git a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts index 69b3975485..02c2c79e0c 100644 --- a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function freshdeskApiRequest( method, body, qs: query, - uri: uri ?? `https://${credentials.domain}.${endpoint}${resource}`, + uri: uri || `https://${credentials.domain}.${endpoint}${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts index 960277615d..4f7e309485 100644 --- a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function getresponseApiRequest( method, body, qs, - uri: uri ?? `https://api.getresponse.com/v3${resource}`, + uri: uri || `https://api.getresponse.com/v3${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts index d2ebbbca8f..763e09fc7c 100644 --- a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts +++ b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts @@ -244,7 +244,7 @@ export class GetResponse implements INodeType { } if (qs.sortBy) { - qs[`sort[${qs.sortBy}]`] = qs.sortOrder ?? 'ASC'; + qs[`sort[${qs.sortBy}]`] = qs.sortOrder || 'ASC'; } if (qs.exactMatch === true) { diff --git a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts index f943d1458c..e46442ac1a 100644 --- a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts @@ -37,7 +37,7 @@ export async function ghostApiRequest( const options: OptionsWithUri = { method, qs: query, - uri: uri ?? `${credentials.url}/ghost/api/${version}${endpoint}`, + uri: uri || `${credentials.url}/ghost/api/${version}${endpoint}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/Ghost/Ghost.node.ts b/packages/nodes-base/nodes/Ghost/Ghost.node.ts index 0ba954b83a..b4c22b5fbf 100644 --- a/packages/nodes-base/nodes/Ghost/Ghost.node.ts +++ b/packages/nodes-base/nodes/Ghost/Ghost.node.ts @@ -291,7 +291,7 @@ export class Ghost implements INodeType { const post: IDataObject = {}; if (contentFormat === 'html') { - post.html = updateFields.content ?? ''; + post.html = updateFields.content || ''; qs.source = 'html'; delete updateFields.content; } else { diff --git a/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts index 42107df6d7..04a73fe63e 100644 --- a/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://analyticsreporting.googleapis.com${endpoint}`, + uri: uri || `https://analyticsreporting.googleapis.com${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts index 0f7f557cf8..7763a8a912 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts @@ -23,7 +23,7 @@ async function getAccessToken( const signature = jwt.sign( { iss: credentials.email as string, - sub: credentials.delegatedEmail ?? (credentials.email as string), + sub: credentials.delegatedEmail || (credentials.email as string), scope: scopes.join(' '), aud: 'https://oauth2.googleapis.com/token', iat: now, @@ -79,7 +79,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://bigquery.googleapis.com/bigquery${resource}`, + uri: uri || `https://bigquery.googleapis.com/bigquery${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts index 3236564fb7..928c3522e1 100644 --- a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts @@ -31,7 +31,7 @@ async function getAccessToken( const signature = jwt.sign( { iss: credentials.email, - sub: credentials.delegatedEmail ?? credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: 'https://oauth2.googleapis.com/token', iat: now, @@ -86,7 +86,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://www.googleapis.com/books/${resource}`, + uri: uri || `https://www.googleapis.com/books/${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts index 69cd2f91f1..001c2653e1 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://www.googleapis.com${resource}`, + uri: uri || `https://www.googleapis.com${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts index f94b2d7768..824918654c 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts @@ -144,7 +144,7 @@ export class GoogleCalendar implements INodeType { const timeMin = this.getNodeParameter('timeMin', i) as string; const timeMax = this.getNodeParameter('timeMax', i) as string; const options = this.getNodeParameter('options', i); - const outputFormat = options.outputFormat ?? 'availability'; + const outputFormat = options.outputFormat || 'availability'; const tz = this.getNodeParameter('options.timezone', i, '', { extractValue: true, }) as string; diff --git a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts index 5631e1e855..edd79df375 100644 --- a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts @@ -41,7 +41,7 @@ export async function getAccessToken( const signature = jwt.sign( { iss: credentials.email, - sub: credentials.delegatedEmail ?? credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: 'https://oauth2.googleapis.com/token', iat: now, @@ -92,7 +92,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://chat.googleapis.com${resource}`, + uri: uri || `https://chat.googleapis.com${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts index 6c9896acee..8b67ddf83c 100644 --- a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://language.googleapis.com${endpoint}`, + uri: uri || `https://language.googleapis.com${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts index 118b57350c..e0b3e41c52 100644 --- a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts +++ b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts @@ -262,8 +262,8 @@ export class GoogleCloudNaturalLanguage implements INodeType { if (operation === 'analyzeSentiment') { const source = this.getNodeParameter('source', i) as string; const options = this.getNodeParameter('options', i); - const encodingType = (options.encodingType as string | undefined) ?? 'UTF16'; - const documentType = (options.documentType as string | undefined) ?? 'PLAIN_TEXT'; + const encodingType = (options.encodingType as string | undefined) || 'UTF16'; + const documentType = (options.documentType as string | undefined) || 'PLAIN_TEXT'; const body: IData = { document: { diff --git a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts index 96a8e0ad61..a269b0282d 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://people.googleapis.com/v1${resource}`, + uri: uri || `https://people.googleapis.com/v1${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts index a4023cb3a2..9041049f82 100644 --- a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts @@ -35,7 +35,7 @@ async function getAccessToken( const signature = jwt.sign( { iss: credentials.email, - sub: credentials.delegatedEmail ?? credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: 'https://oauth2.googleapis.com/token', iat: now, @@ -89,7 +89,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://docs.googleapis.com/v1${endpoint}`, + uri: uri || `https://docs.googleapis.com/v1${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts index 02f0948a72..db8091a8a1 100644 --- a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts @@ -35,7 +35,7 @@ async function getAccessToken( const signature = jwt.sign( { iss: credentials.email, - sub: credentials.delegatedEmail ?? credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: 'https://oauth2.googleapis.com/token', iat: now, @@ -91,7 +91,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://www.googleapis.com${resource}`, + uri: uri || `https://www.googleapis.com${resource}`, json: true, }; @@ -136,8 +136,8 @@ export async function googleApiRequestAllItems( const returnData: IDataObject[] = []; let responseData; - query.maxResults = query.maxResults ?? 100; - query.pageSize = query.pageSize ?? 100; + query.maxResults = query.maxResults || 100; + query.pageSize = query.pageSize || 100; do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index c99f30b569..3cfb6b0e41 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -2652,7 +2652,7 @@ export class GoogleDrive implements INodeType { const body = { name, mimeType: 'application/vnd.google-apps.folder', - parents: options.parents ?? [], + parents: options.parents || [], }; const qs = { diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts index 509becba32..7559819fdb 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function googleApiRequest( qsStringifyOptions: { arrayFormat: 'repeat', }, - uri: uri ?? `https://firestore.googleapis.com/v1/projects${resource}`, + uri: uri || `https://firestore.googleapis.com/v1/projects${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts index f1ed51a2d2..80b4957843 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function googleApiRequest( method, body, qs, - url: uri ?? `https://${projectId}.${region}/${resource}.json`, + url: uri || `https://${projectId}.${region}/${resource}.json`, json: true, }; diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts index e59a3c991a..d3ab4f0475 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://www.googleapis.com/admin${resource}`, + uri: uri || `https://www.googleapis.com/admin${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts index 0b8a93121d..e60884a411 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts @@ -116,7 +116,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://www.googleapis.com${endpoint}`, + uri: uri || `https://www.googleapis.com${endpoint}`, qsStringifyOptions: { arrayFormat: 'repeat', }, @@ -528,7 +528,7 @@ export async function prepareEmailAttachments( } attachmentsList.push({ - name: binaryData.fileName ?? 'unknown', + name: binaryData.fileName || 'unknown', content: binaryDataBuffer, type: binaryData.mimeType, }); diff --git a/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts b/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts index 356ca646fe..8ef63b1e24 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts @@ -324,7 +324,7 @@ export class GmailV1 implements INodeType { binaryProperty, ); attachmentsBinary.push({ - name: binaryData.fileName ?? 'unknown', + name: binaryData.fileName || 'unknown', content: binaryDataBuffer, type: binaryData.mimeType, }); @@ -414,7 +414,7 @@ export class GmailV1 implements INodeType { binaryProperty, ); attachmentsBinary.push({ - name: binaryData.fileName ?? 'unknown', + name: binaryData.fileName || 'unknown', content: binaryDataBuffer, type: binaryData.mimeType, }); @@ -489,7 +489,7 @@ export class GmailV1 implements INodeType { const id = this.getNodeParameter('messageId', i); const additionalFields = this.getNodeParameter('additionalFields', i); - const format = additionalFields.format ?? 'resolved'; + const format = additionalFields.format || 'resolved'; if (format === 'resolved') { qs.format = 'raw'; @@ -557,7 +557,7 @@ export class GmailV1 implements INodeType { responseData = []; } - const format = additionalFields.format ?? 'resolved'; + const format = additionalFields.format || 'resolved'; if (format !== 'ids') { if (format === 'resolved') { @@ -658,7 +658,7 @@ export class GmailV1 implements INodeType { binaryProperty, ); attachmentsBinary.push({ - name: binaryData.fileName ?? 'unknown', + name: binaryData.fileName || 'unknown', content: binaryDataBuffer, type: binaryData.mimeType, }); @@ -707,7 +707,7 @@ export class GmailV1 implements INodeType { const id = this.getNodeParameter('messageId', i); const additionalFields = this.getNodeParameter('additionalFields', i); - const format = additionalFields.format ?? 'resolved'; + const format = additionalFields.format || 'resolved'; if (format === 'resolved') { qs.format = 'raw'; @@ -785,7 +785,7 @@ export class GmailV1 implements INodeType { responseData = []; } - const format = additionalFields.format ?? 'resolved'; + const format = additionalFields.format || 'resolved'; if (format !== 'ids') { if (format === 'resolved') { diff --git a/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts b/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts index 846f2b34e3..dbf135e1d4 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts @@ -678,7 +678,7 @@ export class GmailV2 implements INodeType { const endpoint = `/gmail/v1/users/me/threads/${id}`; const options = this.getNodeParameter('options', i); - const onlyMessages = options.returnOnlyMessages ?? false; + const onlyMessages = options.returnOnlyMessages || false; const qs: IDataObject = {}; const simple = this.getNodeParameter('simple', i) as boolean; diff --git a/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts b/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts index aa72450d86..516a43ec74 100644 --- a/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts @@ -490,8 +490,8 @@ export class GoogleSheetsTrigger implements INodeType { } const [rangeFrom, rangeTo] = range.split(':'); - const cellDataFrom = rangeFrom.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) ?? []; - const cellDataTo = rangeTo.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) ?? []; + const cellDataFrom = rangeFrom.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) || []; + const cellDataTo = rangeTo.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) || []; if (rangeDefinition === 'specifyRangeA1' && cellDataFrom[2] !== undefined) { keyRange = `${cellDataFrom[1]}${+cellDataFrom[2]}:${cellDataTo[1]}${+cellDataFrom[2]}`; @@ -544,7 +544,7 @@ export class GoogleSheetsTrigger implements INodeType { return null; } - const addedRows = sheetData?.slice(workflowStaticData.lastIndexChecked as number) ?? []; + const addedRows = sheetData?.slice(workflowStaticData.lastIndexChecked as number) || []; const returnData = arrayOfArraysToJson(addedRows, columns); workflowStaticData.lastIndexChecked = sheetData.length; diff --git a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts index ffd56ed5cf..c5426b5cab 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts @@ -39,7 +39,7 @@ export async function getAccessToken( const signature = jwt.sign( { iss: credentials.email, - sub: credentials.delegatedEmail ?? credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: 'https://oauth2.googleapis.com/token', iat: now, @@ -94,7 +94,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://sheets.googleapis.com${resource}`, + uri: uri || `https://sheets.googleapis.com${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts b/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts index 1a3e9aec09..811982afee 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts @@ -117,8 +117,8 @@ export class GoogleSheetsV1 implements INodeType { const options = this.getNodeParameter('options', 0, {}); - const valueInputMode = (options.valueInputMode ?? 'RAW') as ValueInputOption; - const valueRenderMode = (options.valueRenderMode ?? 'UNFORMATTED_VALUE') as ValueRenderOption; + const valueInputMode = (options.valueInputMode || 'RAW') as ValueInputOption; + const valueRenderMode = (options.valueRenderMode || 'UNFORMATTED_VALUE') as ValueRenderOption; if (operation === 'append') { // ---------------------------------- @@ -134,7 +134,7 @@ export class GoogleSheetsV1 implements INodeType { setData.push(item.json); }); - const usePathForKeyRow = (options.usePathForKeyRow ?? false) as boolean; + const usePathForKeyRow = (options.usePathForKeyRow || false) as boolean; // Convert data into array format const _data = await sheet.appendSheetData( diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts index 6ad153d6c1..04620109d6 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts @@ -172,7 +172,7 @@ export async function execute( const options = this.getNodeParameter('options', 0, {}); - const valueRenderMode = (options.valueRenderMode ?? 'UNFORMATTED_VALUE') as ValueRenderOption; + const valueRenderMode = (options.valueRenderMode || 'UNFORMATTED_VALUE') as ValueRenderOption; const locationDefineOption = (options.locationDefine as IDataObject)?.values as IDataObject; diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts index 5e4b5fe73c..14731532b5 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/read.operation.ts @@ -124,9 +124,9 @@ export async function execute( const range = getRangeString(sheetName, dataLocationOnSheetOptions); - const valueRenderMode = (outputFormattingOption.general ?? + const valueRenderMode = (outputFormattingOption.general || 'UNFORMATTED_VALUE') as ValueRenderOption; - const dateTimeRenderOption = (outputFormattingOption.date ?? 'FORMATTED_STRING') as string; + const dateTimeRenderOption = (outputFormattingOption.date || 'FORMATTED_STRING') as string; const sheetData = (await sheet.getData( range, diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts index 2a498023bc..17a1cbe225 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts @@ -171,7 +171,7 @@ export async function execute( const options = this.getNodeParameter('options', 0, {}); - const valueRenderMode = (options.valueRenderMode ?? 'UNFORMATTED_VALUE') as ValueRenderOption; + const valueRenderMode = (options.valueRenderMode || 'UNFORMATTED_VALUE') as ValueRenderOption; const locationDefineOptions = (options.locationDefine as IDataObject)?.values as IDataObject; diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheet.ts b/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheet.ts index 4fc8851006..dff6f56824 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheet.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheet.ts @@ -255,7 +255,7 @@ export class GoogleSheet { // ); const lastRowWithData = - lastRow ?? + lastRow || (((await this.getData(range, 'UNFORMATTED_VALUE')) as string[][]) || []).length + 1; const response = await this.updateRows( @@ -403,10 +403,10 @@ export class GoogleSheet { columnValuesList = sheetData.slice(dataStartRowIndex - 1).map((row) => row[keyIndex]); } else { const decodedRange = this.getDecodedSheetRange(range); - const startRowIndex = decodedRange.start?.row ?? dataStartRowIndex; - const endRowIndex = decodedRange.end?.row ?? ''; + const startRowIndex = decodedRange.start?.row || dataStartRowIndex; + const endRowIndex = decodedRange.end?.row || ''; - const keyColumn = this.getColumnWithOffset(decodedRange.start?.column ?? 'A', keyIndex); + const keyColumn = this.getColumnWithOffset(decodedRange.start?.column || 'A', keyIndex); const keyColumnRange = `${decodedRange.name}!${keyColumn}${startRowIndex}:${keyColumn}${endRowIndex}`; columnValuesList = await this.getData(keyColumnRange, valueRenderMode); } @@ -446,9 +446,9 @@ export class GoogleSheet { ) { const decodedRange = this.getDecodedSheetRange(range); // prettier-ignore - const keyRowRange = `${decodedRange.name}!${decodedRange.start?.column ?? ''}${keyRowIndex + 1}:${decodedRange.end?.column ?? ''}${keyRowIndex + 1}`; + const keyRowRange = `${decodedRange.name}!${decodedRange.start?.column || ''}${keyRowIndex + 1}:${decodedRange.end?.column || ''}${keyRowIndex + 1}`; - const sheetDatakeyRow = columnNamesList ?? (await this.getData(keyRowRange, valueRenderMode)); + const sheetDatakeyRow = columnNamesList || (await this.getData(keyRowRange, valueRenderMode)); if (sheetDatakeyRow === undefined) { throw new NodeOperationError( @@ -469,7 +469,7 @@ export class GoogleSheet { } const columnValues: Array = - columnValuesList ?? + columnValuesList || (await this.getColumnValues(range, keyIndex, dataStartRowIndex, valueRenderMode)); const updateData: ISheetUpdateData[] = []; @@ -527,7 +527,7 @@ export class GoogleSheet { // Property exists so add it to the data to update // Get the column name in which the property data can be found const columnToUpdate = this.getColumnWithOffset( - decodedRange.start?.column ?? 'A', + decodedRange.start?.column || 'A', columnNames.indexOf(name), ); @@ -640,7 +640,7 @@ export class GoogleSheet { const decodedRange = this.getDecodedSheetRange(range); const columnNamesRow = - columnNamesList ?? + columnNamesList || (await this.getData( `${decodedRange.name}!${keyRowIndex}:${keyRowIndex}`, 'UNFORMATTED_VALUE', @@ -704,7 +704,7 @@ export class GoogleSheet { } private splitCellRange(cell: string, range: string): SheetCellDecoded { - const cellData = cell.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) ?? []; + const cellData = cell.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) || []; if (cellData === null || cellData.length !== 3) { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts b/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts index 0f84a9a616..45defe3ff3 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/transport/index.ts @@ -36,7 +36,7 @@ export async function getAccessToken( const signature = jwt.sign( { iss: credentials.email, - sub: credentials.delegatedEmail ?? credentials.email, + sub: credentials.delegatedEmail || credentials.email, scope: scopes.join(' '), aud: 'https://oauth2.googleapis.com/token', iat: now, @@ -91,7 +91,7 @@ export async function apiRequest( method, body, qs, - uri: uri ?? `https://sheets.googleapis.com${resource}`, + uri: uri || `https://sheets.googleapis.com${resource}`, json: true, ...option, }; diff --git a/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts b/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts index 2fd12a9804..455c5b8451 100644 --- a/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts +++ b/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts @@ -542,7 +542,7 @@ export class GoogleSlides implements INodeType { return { replaceAllText: { replaceText: text.replaceText, - pageObjectIds: text.pageObjectIds ?? [], + pageObjectIds: text.pageObjectIds || [], containsText: { text: text.text, matchCase: text.matchCase, diff --git a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts index c4c10e0450..a08658f9fa 100644 --- a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts @@ -20,7 +20,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://www.googleapis.com${resource}`, + uri: uri || `https://www.googleapis.com${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts index 8667976d7b..3b7ee46ce3 100644 --- a/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts @@ -89,7 +89,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://translation.googleapis.com${resource}`, + uri: uri || `https://translation.googleapis.com${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts index 0d7526f205..a7e1a31e37 100644 --- a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function googleApiRequest( method, body, qs, - uri: uri ?? `https://www.googleapis.com${resource}`, + uri: uri || `https://www.googleapis.com${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Gotify/GenericFunctions.ts b/packages/nodes-base/nodes/Gotify/GenericFunctions.ts index 6169dd161b..6e3c521144 100644 --- a/packages/nodes-base/nodes/Gotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gotify/GenericFunctions.ts @@ -24,7 +24,7 @@ export async function gotifyApiRequest( }, body, qs, - uri: uri ?? `${credentials.url}${path}`, + uri: uri || `${credentials.url}${path}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts index 9f8cee069a..28a7325056 100644 --- a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts +++ b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts @@ -335,7 +335,7 @@ export class GraphQL implements INodeType { const responseFormat = this.getNodeParameter('responseFormat', 0) as string; const { parameter }: { parameter?: Array<{ name: string; value: string }> } = this.getNodeParameter('headerParametersUi', itemIndex, {}) as IDataObject; - const headerParameters = (parameter ?? []).reduce( + const headerParameters = (parameter || []).reduce( (result, item) => ({ ...result, [item.name]: item.value, diff --git a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts index 77838c844c..a22c9877e7 100644 --- a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function gumroadApiRequest( method, qs, body, - uri: uri ?? `https://api.gumroad.com/v2${resource}`, + uri: uri || `https://api.gumroad.com/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts index f7b66b72dc..f9c149c9cd 100644 --- a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function harvestApiRequest( }, method, body, - uri: uri ?? `https://api.harvestapp.com/v2/${path}`, + uri: uri || `https://api.harvestapp.com/v2/${path}`, qs, json: true, }; diff --git a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts index 9713582036..1e777057ec 100644 --- a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function helpscoutApiRequest( method, body, qs, - uri: uri ?? `https://api.helpscout.net${resource}`, + uri: uri || `https://api.helpscout.net${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts index 4b8017c57b..881f9b8898 100644 --- a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts +++ b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts @@ -504,7 +504,7 @@ export class HelpScout implements INodeType { ]; if (binaryProperty) { return { - fileName: binaryProperty.fileName ?? 'unknown', + fileName: binaryProperty.fileName || 'unknown', data: binaryProperty.data, mimeType: binaryProperty.mimeType, }; diff --git a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts index b784ae2425..ba0bce429f 100644 --- a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts @@ -64,7 +64,7 @@ export async function dueDatePreSendAction( ); } const dueDate = dateToIsoSupressMillis(dueDateParam); - requestOptions.body = (requestOptions.body ?? {}) as object; + requestOptions.body = (requestOptions.body || {}) as object; Object.assign(requestOptions.body, { dueDate }); return requestOptions; } @@ -73,7 +73,7 @@ export async function contactIdentifierPreSendAction( this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions, ): Promise { - requestOptions.body = (requestOptions.body ?? {}) as object; + requestOptions.body = (requestOptions.body || {}) as object; let identifier = this.getNodeParameter('contactIdentifier', null) as string; if (!identifier) { const fields = this.getNodeParameter('updateFields') as { contactIdentifier: string }; @@ -93,7 +93,7 @@ export async function validEmailAndPhonePreSendAction( this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions, ): Promise { - const body = (requestOptions.body ?? {}) as { email?: string; phone?: string }; + const body = (requestOptions.body || {}) as { email?: string; phone?: string }; if (body.email && !isEmailValid(body.email)) { const message = `email "${body.email}" has invalid format`; @@ -112,7 +112,7 @@ export async function dateTimeToEpochPreSendAction( this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions, ): Promise { - const qs = (requestOptions.qs ?? {}) as { + const qs = (requestOptions.qs || {}) as { startDate?: string | number; endDate?: string | number; }; @@ -141,7 +141,7 @@ export async function highLevelApiRequest( method, body, qs, - uri: uri ?? `https://rest.gohighlevel.com/v1${resource}`, + uri: uri || `https://rest.gohighlevel.com/v1${resource}`, json: true, }; if (!Object.keys(body).length) { @@ -158,14 +158,14 @@ export async function opportunityUpdatePreSendAction( this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions, ): Promise { - const body = (requestOptions.body ?? {}) as { title?: string; status?: string }; + const body = (requestOptions.body || {}) as { title?: string; status?: string }; if (!body.status || !body.title) { const pipelineId = this.getNodeParameter('pipelineId'); const opportunityId = this.getNodeParameter('opportunityId'); const resource = `/pipelines/${pipelineId}/opportunities/${opportunityId}`; const responseData = await highLevelApiRequest.call(this, 'GET', resource); - body.status = body.status ?? responseData.status; - body.title = body.title ?? responseData.name; + body.status = body.status || responseData.status; + body.title = body.title || responseData.name; requestOptions.body = body; } return requestOptions; @@ -175,15 +175,15 @@ export async function taskUpdatePreSendAction( this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions, ): Promise { - const body = (requestOptions.body ?? {}) as { title?: string; dueDate?: string }; + const body = (requestOptions.body || {}) as { title?: string; dueDate?: string }; if (!body.title || !body.dueDate) { const contactId = this.getNodeParameter('contactId'); const taskId = this.getNodeParameter('taskId'); const resource = `/contacts/${contactId}/tasks/${taskId}`; const responseData = await highLevelApiRequest.call(this, 'GET', resource); - body.title = body.title ?? responseData.title; + body.title = body.title || responseData.title; // the api response dueDate has to be formatted or it will error on update - body.dueDate = body.dueDate ?? dateToIsoSupressMillis(responseData.dueDate); + body.dueDate = body.dueDate || dateToIsoSupressMillis(responseData.dueDate); requestOptions.body = body; } return requestOptions; @@ -193,7 +193,7 @@ export async function splitTagsPreSendAction( this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions, ): Promise { - const body = (requestOptions.body ?? {}) as IDataObject; + const body = (requestOptions.body || {}) as IDataObject; if (body.tags) { if (Array.isArray(body.tags)) return requestOptions; body.tags = (body.tags as string).split(',').map((tag) => tag.trim()); @@ -215,7 +215,7 @@ export async function highLevelApiPagination( }; const rootProperty = resourceMapping[resource]; - requestData.options.qs = requestData.options.qs ?? {}; + requestData.options.qs = requestData.options.qs || {}; if (returnAll) requestData.options.qs.limit = 100; let responseTotal = 0; diff --git a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts index f8b904ad48..e24a852446 100644 --- a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts @@ -79,7 +79,7 @@ export async function getHomeAssistantServices( for (const domainService of domainServices) { for (const [serviceID, value] of Object.entries(domainService.services)) { const serviceProperties = value as IDataObject; - const serviceName = serviceProperties.description ?? serviceID; + const serviceName = serviceProperties.description || serviceID; returnData.push({ name: serviceName as string, value: serviceID, diff --git a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts index b1f42e8a29..cf731ad498 100644 --- a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts +++ b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts @@ -24,7 +24,7 @@ const extractFunctions: { } = { attribute: ($: Cheerio, valueData: IValueData): string | undefined => $.attr(valueData.attribute!), - html: ($: Cheerio, _valueData: IValueData): string | undefined => $.html() ?? undefined, + html: ($: Cheerio, _valueData: IValueData): string | undefined => $.html() || undefined, text: ($: Cheerio, _valueData: IValueData): string | undefined => $.text(), value: ($: Cheerio, _valueData: IValueData): string | undefined => $.val(), }; diff --git a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts index 1726d01816..9f89dcb10c 100644 --- a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts @@ -36,7 +36,7 @@ export async function hubspotApiRequest( method, qs: query, headers: {}, - uri: uri ?? `https://api.hubapi.com${endpoint}`, + uri: uri || `https://api.hubapi.com${endpoint}`, body, json: true, useQuerystring: true, @@ -85,7 +85,7 @@ export async function hubspotApiRequestAllItems( let responseData; - query.limit = query.limit ?? 250; + query.limit = query.limit || 250; query.count = 100; body.limit = body.limit || 100; diff --git a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts index c13df80e35..f2cfa45128 100644 --- a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts +++ b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts @@ -1412,8 +1412,8 @@ export class Hubspot implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const returnAll = this.getNodeParameter('returnAll', 0); const filtersGroupsUi = this.getNodeParameter('filterGroupsUi', i) as IDataObject; - const sortBy = additionalFields.sortBy ?? 'createdate'; - const direction = additionalFields.direction ?? 'DESCENDING'; + const sortBy = additionalFields.sortBy || 'createdate'; + const direction = additionalFields.direction || 'DESCENDING'; const body: IDataObject = { sorts: [ @@ -2232,8 +2232,8 @@ export class Hubspot implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); const returnAll = this.getNodeParameter('returnAll', 0); const filtersGroupsUi = this.getNodeParameter('filterGroupsUi', i) as IDataObject; - const sortBy = additionalFields.sortBy ?? 'createdate'; - const direction = additionalFields.direction ?? 'DESCENDING'; + const sortBy = additionalFields.sortBy || 'createdate'; + const direction = additionalFields.direction || 'DESCENDING'; const body: IDataObject = { sorts: [ diff --git a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts index f2620854a4..11009302d1 100644 --- a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts +++ b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts @@ -320,7 +320,7 @@ export class HubspotTrigger implements INodeType { let endpoint = `/webhooks/v3/${appId}/settings`; let body: IDataObject = { targetUrl: webhookUrl, - maxConcurrentRequests: additionalFields.maxConcurrentRequests ?? 5, + maxConcurrentRequests: additionalFields.maxConcurrentRequests || 5, }; await hubspotApiRequest.call(this, 'PUT', endpoint, body); diff --git a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts index d418d623d4..224ee6ecb3 100644 --- a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts @@ -23,7 +23,7 @@ export async function hunterApiRequest( method, qs, body, - uri: uri ?? `https://api.hunter.io/v2${resource}`, + uri: uri || `https://api.hunter.io/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/If/If.node.ts b/packages/nodes-base/nodes/If/If.node.ts index ef62ad4ec8..03c0ee0c7a 100644 --- a/packages/nodes-base/nodes/If/If.node.ts +++ b/packages/nodes-base/nodes/If/If.node.ts @@ -324,13 +324,13 @@ export class If implements INodeType { [key: string]: (value1: NodeParameterValue, value2: NodeParameterValue) => boolean; } = { after: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) > (value2 ?? 0), + (value1 || 0) > (value2 || 0), before: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) < (value2 ?? 0), + (value1 || 0) < (value2 || 0), contains: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? '').toString().includes((value2 ?? '').toString()), + (value1 || '').toString().includes((value2 || '').toString()), notContains: (value1: NodeParameterValue, value2: NodeParameterValue) => - !(value1 ?? '').toString().includes((value2 ?? '').toString()), + !(value1 || '').toString().includes((value2 || '').toString()), endsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).endsWith(value2 as string), notEndsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => @@ -338,13 +338,13 @@ export class If implements INodeType { equal: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 === value2, notEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 !== value2, larger: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) > (value2 ?? 0), + (value1 || 0) > (value2 || 0), largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) >= (value2 ?? 0), + (value1 || 0) >= (value2 || 0), smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) < (value2 ?? 0), + (value1 || 0) < (value2 || 0), smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) <= (value2 ?? 0), + (value1 || 0) <= (value2 || 0), startsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).startsWith(value2 as string), notStartsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => @@ -364,32 +364,32 @@ export class If implements INodeType { (isDateObject(value1) && isDateInvalid(value1)) ), regex: (value1: NodeParameterValue, value2: NodeParameterValue) => { - const regexMatch = (value2 ?? '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); + const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); let regex: RegExp; if (!regexMatch) { - regex = new RegExp((value2 ?? '').toString()); + regex = new RegExp((value2 || '').toString()); } else if (regexMatch.length === 1) { regex = new RegExp(regexMatch[1]); } else { regex = new RegExp(regexMatch[1], regexMatch[2]); } - return !!(value1 ?? '').toString().match(regex); + return !!(value1 || '').toString().match(regex); }, notRegex: (value1: NodeParameterValue, value2: NodeParameterValue) => { - const regexMatch = (value2 ?? '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); + const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); let regex: RegExp; if (!regexMatch) { - regex = new RegExp((value2 ?? '').toString()); + regex = new RegExp((value2 || '').toString()); } else if (regexMatch.length === 1) { regex = new RegExp(regexMatch[1]); } else { regex = new RegExp(regexMatch[1], regexMatch[2]); } - return !(value1 ?? '').toString().match(regex); + return !(value1 || '').toString().match(regex); }, }; diff --git a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts index d848c58bee..bfeaf71f46 100644 --- a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function intercomApiRequest( headers: headerWithAuthentication, method, qs: query, - uri: uri ?? `https://api.intercom.io${endpoint}`, + uri: uri || `https://api.intercom.io${endpoint}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts index 277cbb6181..3f8efa2e13 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts @@ -41,7 +41,7 @@ export async function invoiceNinjaApiRequest( const options: OptionsWithUri = { method, qs: query, - uri: uri ?? `${baseUrl}/api/v1${endpoint}`, + uri: uri || `${baseUrl}/api/v1${endpoint}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts index 5d3c83305a..7ecea8bace 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts @@ -198,7 +198,7 @@ export class InvoiceNinja implements INodeType { '/invoices', ); for (const invoice of invoices) { - const invoiceName = (invoice.invoice_number ?? invoice.number) as string; + const invoiceName = (invoice.invoice_number || invoice.number) as string; const invoiceId = invoice.id as string; returnData.push({ name: invoiceName, diff --git a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts index 2130d25691..ba327f37c6 100644 --- a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts @@ -24,7 +24,7 @@ export async function iterableApiRequest( method, body, qs, - uri: uri ?? `https://api.iterable.com/api${resource}`, + uri: uri || `https://api.iterable.com/api${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Jira/GenericFunctions.ts b/packages/nodes-base/nodes/Jira/GenericFunctions.ts index d90bf6ae96..c869e61f6d 100644 --- a/packages/nodes-base/nodes/Jira/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jira/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function jiraSoftwareCloudApiRequest( }, method, qs: query, - uri: uri ?? `${domain}/rest${endpoint}`, + uri: uri || `${domain}/rest${endpoint}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/Jira/Jira.node.ts b/packages/nodes-base/nodes/Jira/Jira.node.ts index 85f09f4576..ace29863c9 100644 --- a/packages/nodes-base/nodes/Jira/Jira.node.ts +++ b/packages/nodes-base/nodes/Jira/Jira.node.ts @@ -286,7 +286,7 @@ export class Jira implements INodeType { if (user.active) { activeUsers.push({ name: user.displayName as string, - value: (user.accountId ?? user.name) as string, + value: (user.accountId || user.name) as string, }); } return activeUsers; @@ -684,7 +684,7 @@ export class Jira implements INodeType { qs.expand = additionalFields.expand as string; } if (simplifyOutput) { - qs.expand = `${qs.expand ?? ''},names`; + qs.expand = `${qs.expand || ''},names`; } if (additionalFields.properties) { qs.properties = additionalFields.properties as string; @@ -702,7 +702,7 @@ export class Jira implements INodeType { if (simplifyOutput) { // Use rendered fields if requested and available - qs.expand = qs.expand ?? ''; + qs.expand = qs.expand || ''; if ( (qs.expand as string).toLowerCase().indexOf('renderedfields') !== -1 && responseData.renderedFields && diff --git a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts index 823df81d5b..04cfe5a9f8 100644 --- a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts @@ -32,7 +32,7 @@ export async function jotformApiRequest( method, qs, form: body, - uri: uri ?? `https://${credentials.apiDomain || 'api.jotform.com'}${resource}`, + uri: uri || `https://${credentials.apiDomain || 'api.jotform.com'}${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts index 9a0fd50e7c..e35ba9b95f 100644 --- a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts +++ b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts @@ -248,7 +248,7 @@ export class KafkaTrigger implements INodeType { const headers: { [key: string]: string } = {}; for (const key of Object.keys(message.headers)) { const header = message.headers[key]; - headers[key] = header?.toString('utf8') ?? ''; + headers[key] = header?.toString('utf8') || ''; } data.headers = headers; diff --git a/packages/nodes-base/nodes/Keap/GenericFunctions.ts b/packages/nodes-base/nodes/Keap/GenericFunctions.ts index 7687941359..d1142f3e78 100644 --- a/packages/nodes-base/nodes/Keap/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Keap/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function keapApiRequest( method, body, qs, - uri: uri ?? `https://api.infusionsoft.com/crm/rest/v1${resource}`, + uri: uri || `https://api.infusionsoft.com/crm/rest/v1${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts index 35fcb6b0fc..2c611d3920 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts @@ -158,7 +158,7 @@ export function formatSubmission( .split('/') .map((k) => _.trim(k, ' _')) .join('.'); - const leafKey = sanitizedKey.split('.').pop() ?? ''; + const leafKey = sanitizedKey.split('.').pop() || ''; let format = 'string'; if (_.some(numberMasks, (mask) => matchWildcard(leafKey, mask))) { format = 'number'; @@ -204,7 +204,7 @@ export async function downloadAttachments( const credentials = await this.getCredentials('koBoToolboxApi'); // Look for attachment links - there can be more than one - const attachmentList = (submission._attachments ?? submission.attachments) as any[]; + const attachmentList = (submission._attachments || submission.attachments) as any[]; if (attachmentList?.length) { for (const [index, attachment] of attachmentList.entries()) { @@ -266,7 +266,7 @@ export async function downloadAttachments( if ('question' === options.binaryNamingScheme && relatedQuestion) { binaryName = relatedQuestion; } else { - binaryName = `${options.dataPropertyAttachmentsPrefixName ?? 'attachment_'}${index}`; + binaryName = `${options.dataPropertyAttachmentsPrefixName || 'attachment_'}${index}`; } binaryItem.binary![binaryName] = await this.helpers.prepareBinaryData( diff --git a/packages/nodes-base/nodes/Line/GenericFunctions.ts b/packages/nodes-base/nodes/Line/GenericFunctions.ts index 6c648e07de..b555cf1a54 100644 --- a/packages/nodes-base/nodes/Line/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Line/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function lineApiRequest( method, body, qs, - uri: uri ?? '', + uri: uri || '', json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Linear/GenericFunctions.ts b/packages/nodes-base/nodes/Linear/GenericFunctions.ts index 30e7428f40..fef5450a04 100644 --- a/packages/nodes-base/nodes/Linear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Linear/GenericFunctions.ts @@ -22,14 +22,11 @@ export async function linearApiRequest( body: any = {}, option: IDataObject = {}, ): Promise { - const credentials = await this.getCredentials('linearApi'); - const endpoint = 'https://api.linear.app/graphql'; let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', - Authorization: credentials.apiKey, }, method: 'POST', body, @@ -38,7 +35,7 @@ export async function linearApiRequest( }; options = Object.assign({}, options, option); try { - return await this.helpers.request(options); + return await this.helpers.requestWithAuthentication.call(this, 'linearApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } diff --git a/packages/nodes-base/nodes/Linear/Linear.node.ts b/packages/nodes-base/nodes/Linear/Linear.node.ts index be81032de4..2b66c34aa2 100644 --- a/packages/nodes-base/nodes/Linear/Linear.node.ts +++ b/packages/nodes-base/nodes/Linear/Linear.node.ts @@ -202,7 +202,7 @@ export class Linear implements INodeType { }; responseData = await linearApiRequest.call(this, body); - responseData = responseData.data?.issues?.nodes[0]; + responseData = responseData.data.issue; } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i); diff --git a/packages/nodes-base/nodes/Linear/Queries.ts b/packages/nodes-base/nodes/Linear/Queries.ts index 993deed39e..861b404d3f 100644 --- a/packages/nodes-base/nodes/Linear/Queries.ts +++ b/packages/nodes-base/nodes/Linear/Queries.ts @@ -93,34 +93,30 @@ export const query = { }`; }, getIssue() { - return `query Issue ($issueId: ID){ - issues(filter: { - id: { eq: $issueId } - }) { - nodes { + return `query Issue($issueId: String!) { + issue(id: $issueId) { + id, + title, + priority, + archivedAt, + assignee { id, - title, - priority - archivedAt - assignee { - id - displayName - } - state { - id - name - } - createdAt - creator { - id - displayName - } - description - dueDate - cycle { - id - name - } + displayName + } + state { + id + name + } + createdAt + creator { + id + displayName + } + description + dueDate + cycle { + id + name } } }`; @@ -129,7 +125,7 @@ export const query = { return `query Issue ($first: Int){ issues (first: $first){ nodes { - id, + id, title, priority archivedAt diff --git a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts index 5e622d41bc..43ccba7b8a 100644 --- a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function lingvaNexApiRequest( method, qs, body, - uri: uri ?? `https://api-b2b.backenster.com/b1/api/v3${resource}`, + uri: uri || `https://api-b2b.backenster.com/b1/api/v3${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Magento/GenericFunctions.ts b/packages/nodes-base/nodes/Magento/GenericFunctions.ts index 38626f4435..e1aa52fd3c 100644 --- a/packages/nodes-base/nodes/Magento/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Magento/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function magentoApiRequest( method, body, qs, - uri: uri ?? `${credentials.host}${resource}`, + uri: uri || `${credentials.host}${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts index b7779cbc73..cd795dc1e1 100644 --- a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function mailCheckApiRequest( method, body, qs, - uri: uri ?? `https://api.mailcheck.co/v1${resource}`, + uri: uri || `https://api.mailcheck.co/v1${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts index 973b0d33a8..cfc3cced20 100644 --- a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts +++ b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts @@ -156,7 +156,7 @@ export class Mailgun implements INodeType { attachments.push({ value: binaryDataBuffer, options: { - filename: item.binary[propertyName].fileName ?? 'unknown', + filename: item.binary[propertyName].fileName || 'unknown', }, }); } diff --git a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts index 217164a5c3..2c0982eeaf 100644 --- a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts @@ -39,7 +39,7 @@ export async function mailjetApiRequest( method, qs, body, - uri: uri ?? `https://api.mailjet.com${path}`, + uri: uri || `https://api.mailjet.com${path}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts b/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts index 21c7bb5354..117e09916d 100644 --- a/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts +++ b/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts @@ -855,7 +855,7 @@ export class Mandrill implements INodeType { attachmentsBinary = _.map(attachmentsUi.attachmentsBinary, (o: IDataObject) => { if (items[i].binary!.hasOwnProperty(o.property as string)) { const aux: IDataObject = {}; - aux.name = items[i].binary![o.property as string].fileName ?? 'unknown'; + aux.name = items[i].binary![o.property as string].fileName || 'unknown'; aux.content = items[i].binary![o.property as string].data; aux.type = items[i].binary![o.property as string].mimeType; return aux; diff --git a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts index 2d1dc762af..261b539ec7 100644 --- a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts @@ -18,7 +18,7 @@ export async function matrixApiRequest( ) { let options: OptionsWithUri = { method, - headers: headers ?? { + headers: headers || { 'Content-Type': 'application/json; charset=utf-8', }, body, @@ -38,7 +38,7 @@ export async function matrixApiRequest( options.uri = `${credentials.homeserverUrl}/_matrix/${ //@ts-ignore - option.overridePrefix ?? 'client' + option.overridePrefix || 'client' }/r0${resource}`; options.headers!.Authorization = `Bearer ${credentials.accessToken}`; const response = await this.helpers.request(options); diff --git a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts index b620c59bed..62baf83dc0 100644 --- a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts @@ -23,7 +23,7 @@ export async function mauticApiRequest( headers: {}, method, qs: query, - uri: uri ?? `/api${endpoint}`, + uri: uri || `/api${endpoint}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/Medium/GenericFunctions.ts b/packages/nodes-base/nodes/Medium/GenericFunctions.ts index ea10e1050c..9c3a1d9616 100644 --- a/packages/nodes-base/nodes/Medium/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Medium/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function mediumApiRequest( 'Accept-Charset': 'utf-8', }, qs: query, - uri: uri ?? `https://api.medium.com/v1${endpoint}`, + uri: uri || `https://api.medium.com/v1${endpoint}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts index 1e1d248f1a..badd717691 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function microsoftApiRequest( method, body, qs, - uri: uri ?? `https://${credentials.subdomain}.${credentials.region}/api/data/v9.2${resource}`, + uri: uri || `https://${credentials.subdomain}.${credentials.region}/api/data/v9.2${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts index 26aff346aa..aacb40c23d 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts @@ -19,7 +19,7 @@ export async function microsoftApiRequest( method, body, qs, - uri: uri ?? `https://graph.microsoft.com/v1.0/me${resource}`, + uri: uri || `https://graph.microsoft.com/v1.0/me${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts index eb85f887be..d4d6509469 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function microsoftApiRequest( method, body, qs, - uri: uri ?? `https://graph.microsoft.com/v1.0/me${resource}`, + uri: uri || `https://graph.microsoft.com/v1.0/me${resource}`, }; try { Object.assign(options, option); diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts index 7381a21641..71285ed852 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts @@ -35,7 +35,7 @@ export async function microsoftApiRequest( method, body, qs, - uri: uri ?? apiUrl, + uri: uri || apiUrl, }; try { Object.assign(options, option); diff --git a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts index b734b52087..7c53d59bcb 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function microsoftApiRequest( method, body, qs, - uri: uri ?? `https://graph.microsoft.com${resource}`, + uri: uri || `https://graph.microsoft.com${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts index 6bb66ad2ae..a8e1dbdf00 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function microsoftApiRequest( method, body, qs, - uri: uri ?? `https://graph.microsoft.com/v1.0/me${resource}`, + uri: uri || `https://graph.microsoft.com/v1.0/me${resource}`, }; try { Object.assign(options, option); diff --git a/packages/nodes-base/nodes/MySql/GenericFunctions.ts b/packages/nodes-base/nodes/MySql/GenericFunctions.ts index 376d0cfb22..bf9b4aa634 100644 --- a/packages/nodes-base/nodes/MySql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MySql/GenericFunctions.ts @@ -62,7 +62,7 @@ export async function searchTables( const sql = ` SELECT table_name FROM information_schema.tables WHERE table_schema = '${credentials.database}' - and table_name like '%${query ?? ''}%' + and table_name like '%${query || ''}%' ORDER BY table_name `; const [rows] = await connection.query(sql); diff --git a/packages/nodes-base/nodes/N8n/GenericFunctions.ts b/packages/nodes-base/nodes/N8n/GenericFunctions.ts index 1712d0e693..b069ef0e15 100644 --- a/packages/nodes-base/nodes/N8n/GenericFunctions.ts +++ b/packages/nodes-base/nodes/N8n/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function apiRequest( body: object, query?: IDataObject, ): Promise { - query = query ?? {}; + query = query || {}; type N8nApiCredentials = { apiKey: string; @@ -60,7 +60,7 @@ export async function apiRequestAllItems( body: object, query?: IDataObject, ): Promise { - query = query ?? {}; + query = query || {}; const returnData: IDataObject[] = []; let nextCursor: string | undefined = undefined; @@ -190,11 +190,11 @@ export const prepareWorkflowCreateBody: PreSendAction = async function ( const body = requestOptions.body as IDataObject; const newBody: IDataObject = {}; - newBody.name = body.name ?? 'My workflow'; - newBody.nodes = body.nodes ?? []; - newBody.settings = body.settings ?? {}; - newBody.connections = body.connections ?? {}; - newBody.staticData = body.staticData ?? null; + newBody.name = body.name || 'My workflow'; + newBody.nodes = body.nodes || []; + newBody.settings = body.settings || {}; + newBody.connections = body.connections || {}; + newBody.staticData = body.staticData || null; requestOptions.body = newBody; diff --git a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts index 2b168b133c..eee6487f71 100644 --- a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts @@ -19,7 +19,7 @@ export async function nasaApiRequest( const options: OptionsWithUri = { method, qs, - uri: uri ?? `https://api.nasa.gov${endpoint}`, + uri: uri || `https://api.nasa.gov${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts index 2bbc82035c..e1d9a3081a 100644 --- a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function netlifyApiRequest( }, qs: query, body, - uri: uri ?? `https://api.netlify.com/api/v1${endpoint}`, + uri: uri || `https://api.netlify.com/api/v1${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index b164d62043..30656a7f86 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function apiRequest( const baseUrl = credentials.host as string; - query = query ?? {}; + query = query || {}; const options: OptionsWithUri = { method, diff --git a/packages/nodes-base/nodes/Notion/DatabaseDescription.ts b/packages/nodes-base/nodes/Notion/DatabaseDescription.ts index 0aa013699b..1025c9d982 100644 --- a/packages/nodes-base/nodes/Notion/DatabaseDescription.ts +++ b/packages/nodes-base/nodes/Notion/DatabaseDescription.ts @@ -141,19 +141,6 @@ export const databaseFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* database:getAll */ /* -------------------------------------------------------------------------- */ - { - displayName: - 'In Notion, make sure you share your database with your integration . Otherwise it won\'t be accessible, or listed here.', - name: 'notionNotice', - type: 'notice', - default: '', - displayOptions: { - show: { - resource: ['database'], - operation: ['getAll'], - }, - }, - }, { displayName: 'Return All', name: 'returnAll', diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index 53c00cf725..f338c33cfd 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -15,6 +15,7 @@ import { INodeProperties, IPollFunctions, NodeApiError, + NodeOperationError, } from 'n8n-workflow'; import { camelCase, capitalCase, snakeCase } from 'change-case'; @@ -25,6 +26,22 @@ import moment from 'moment-timezone'; import { validate as uuidValidate } from 'uuid'; +function uuidValidateWithoutDashes(this: IExecuteFunctions, value: string) { + if (!value || typeof value !== 'string') return false; + if (uuidValidate(value)) return true; + if (value.length == 32) { + //prettier-ignore + const strWithDashes = `${value.slice(0, 8)}-${value.slice(8, 12)}-${value.slice(12, 16)}-${value.slice(16, 20)}-${value.slice(20)}`; + if (uuidValidate(strWithDashes)) return true; + } + throw new NodeOperationError( + this.getNode(), + `The relation id "${value}" is not a valid uuid with optional dashes.`, + ); +} + +export type SortData = { key: string; type: string; direction: string; timestamp: boolean }; + const apiVersion: { [key: number]: string } = { 1: '2021-05-13', 2: '2021-08-16', @@ -53,7 +70,7 @@ export async function notionApiRequest( method, qs, body, - uri: uri ?? `https://api.notion.com/v1${resource}`, + uri: uri || `https://api.notion.com/v1${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -261,7 +278,13 @@ function getDateFormat(includeTime: boolean) { return ''; } -function getPropertyKeyValue(value: any, type: string, timezone: string, version = 1) { +function getPropertyKeyValue( + this: IExecuteFunctions, + value: any, + type: string, + timezone: string, + version = 1, +) { const ignoreIfEmpty = (v: T, cb: (v: T) => any) => !v && value.ignoreIfEmpty ? undefined : cb(v); let result: IDataObject = {}; @@ -289,10 +312,13 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version case 'relation': result = { type: 'relation', - - relation: value.relationValue.reduce((acc: [], cur: any) => { - return acc.concat(cur.split(',').map((relation: string) => ({ id: relation.trim() }))); - }, []), + relation: value.relationValue + .filter((rv: string) => { + return uuidValidateWithoutDashes.call(this, rv); + }) + .reduce((acc: [], cur: any) => { + return acc.concat(cur.split(',').map((relation: string) => ({ id: relation.trim() }))); + }, []), }; break; case 'multi_select': @@ -392,7 +418,12 @@ function getNameAndType(key: string) { }; } -export function mapProperties(properties: IDataObject[], timezone: string, version = 1) { +export function mapProperties( + this: IExecuteFunctions, + properties: IDataObject[], + timezone: string, + version = 1, +) { return properties .filter( (property): property is Record => @@ -402,7 +433,7 @@ export function mapProperties(properties: IDataObject[], timezone: string, versi (property) => [ `${property.key.split('|')[0]}`, - getPropertyKeyValue(property, property.key.split('|')[1], timezone, version), + getPropertyKeyValue.call(this, property, property.key.split('|')[1], timezone, version), ] as const, ) .filter(([, value]) => value) @@ -415,9 +446,7 @@ export function mapProperties(properties: IDataObject[], timezone: string, versi ); } -export function mapSorting( - data: [{ key: string; type: string; direction: string; timestamp: boolean }], -) { +export function mapSorting(data: SortData[]) { return data.map((sort) => { return { direction: sort.direction, @@ -505,13 +534,13 @@ function simplifyProperty(property: any) { } } else if (['multi_select'].includes(property.type)) { if (Array.isArray(property[type])) { - result = property[type].map((e: IDataObject) => e.name ?? {}); + result = property[type].map((e: IDataObject) => e.name || {}); } else { - result = property[type].options.map((e: IDataObject) => e.name ?? {}); + result = property[type].options.map((e: IDataObject) => e.name || {}); } } else if (['relation'].includes(property.type)) { if (Array.isArray(property[type])) { - result = property[type].map((e: IDataObject) => e.id ?? {}); + result = property[type].map((e: IDataObject) => e.id || {}); } else { result = property[type].database_id; } diff --git a/packages/nodes-base/nodes/Notion/Notion.node.ts b/packages/nodes-base/nodes/Notion/Notion.node.ts index 279d5f2e45..5f190f631e 100644 --- a/packages/nodes-base/nodes/Notion/Notion.node.ts +++ b/packages/nodes-base/nodes/Notion/Notion.node.ts @@ -6,12 +6,12 @@ import { NotionV2 } from './v2/NotionV2.node'; export class Notion extends VersionedNodeType { constructor() { const baseDescription: INodeTypeBaseDescription = { - displayName: 'Notion (Beta)', + displayName: 'Notion', name: 'notion', icon: 'file:notion.svg', group: ['output'], subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Consume Notion API (Beta)', + description: 'Consume Notion API', defaultVersion: 2, }; diff --git a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts index 4de1d97b98..f9f4753244 100644 --- a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts +++ b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts @@ -10,7 +10,7 @@ import { getDatabases } from './SearchFunctions'; export class NotionTrigger implements INodeType { description: INodeTypeDescription = { // eslint-disable-next-line n8n-nodes-base/node-class-description-display-name-unsuffixed-trigger-node - displayName: 'Notion Trigger (Beta)', + displayName: 'Notion Trigger', name: 'notionTrigger', icon: 'file:notion.svg', group: ['trigger'], @@ -49,7 +49,7 @@ export class NotionTrigger implements INodeType { }, { displayName: - 'In Notion, make sure you share your database with your integration . Otherwise it won\'t be accessible, or listed here.', + 'In Notion, make sure to add your connection to the pages you want to access.', name: 'notionNotice', type: 'notice', default: '', diff --git a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts index 35678ecdbd..a7de180182 100644 --- a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts +++ b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts @@ -359,7 +359,7 @@ export class NotionV1 implements INodeType { [], ) as IDataObject[]; if (properties.length !== 0) { - body.properties = mapProperties(properties, timezone) as IDataObject; + body.properties = mapProperties.call(this, properties, timezone) as IDataObject; } const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]; extractDatabaseMentionRLC(blockValues); @@ -460,7 +460,7 @@ export class NotionV1 implements INodeType { properties: {}, }; if (properties.length !== 0) { - body.properties = mapProperties(properties, timezone) as IDataObject; + body.properties = mapProperties.call(this, properties, timezone) as IDataObject; } responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, body); if (simple) { diff --git a/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts b/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts index fd15aea9c6..2022a71d84 100644 --- a/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts +++ b/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts @@ -12,13 +12,13 @@ import { databasePageFields, databasePageOperations } from '../DatabasePageDescr import { INodeTypeDescription } from 'n8n-workflow'; export const versionDescription: INodeTypeDescription = { - displayName: 'Notion (Beta)', + displayName: 'Notion', name: 'notion', icon: 'file:notion.svg', group: ['output'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Consume Notion API (Beta)', + description: 'Consume Notion API', defaults: { name: 'Notion (Beta)', }, @@ -67,7 +67,8 @@ export const versionDescription: INodeTypeDescription = { // description: 'The resource to operate on.', // }, { - displayName: "To access content, make sure it's shared with your integration in Notion", + displayName: + 'In Notion, make sure to add your connection to the pages you want to access.', name: 'notionNotice', type: 'notice', default: '', diff --git a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts index 0fc5916d83..1d1173e613 100644 --- a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts +++ b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts @@ -26,6 +26,7 @@ import { notionApiRequest, notionApiRequestAllItems, simplifyObjects, + SortData, validateJSON, } from '../GenericFunctions'; @@ -457,7 +458,7 @@ export class NotionV2 implements INodeType { if (propertiesValues.length !== 0) { body.properties = Object.assign( body.properties, - mapProperties(propertiesValues, timezone, 2) as IDataObject, + mapProperties.call(this, propertiesValues, timezone, 2) as IDataObject, ); } const blockValues = this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]; @@ -536,8 +537,7 @@ export class NotionV2 implements INodeType { delete body.filter; } if (sort) { - //@ts-expect-error - body.sorts = mapSorting(sort); + body.sorts = mapSorting(sort as SortData[]); } if (returnAll) { responseData = await notionApiRequestAllItems.call( @@ -590,7 +590,7 @@ export class NotionV2 implements INodeType { properties: {}, }; if (properties.length !== 0) { - body.properties = mapProperties(properties, timezone, 2) as IDataObject; + body.properties = mapProperties.call(this, properties, timezone, 2) as IDataObject; } responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, body); if (simple) { diff --git a/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts b/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts index 442ac63319..bc1f7a123d 100644 --- a/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts +++ b/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts @@ -12,13 +12,13 @@ import { databasePageFields, databasePageOperations } from '../DatabasePageDescr import { INodeTypeDescription } from 'n8n-workflow'; export const versionDescription: INodeTypeDescription = { - displayName: 'Notion (Beta)', + displayName: 'Notion', name: 'notion', icon: 'file:notion.svg', group: ['output'], version: 2, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Consume Notion API (Beta)', + description: 'Consume Notion API', defaults: { name: 'Notion (Beta)', }, @@ -67,7 +67,8 @@ export const versionDescription: INodeTypeDescription = { // description: 'The resource to operate on.', // }, { - displayName: "To access content, make sure it's shared with your integration in Notion", + displayName: + 'In Notion, make sure to add your connection to the pages you want to access.', name: 'notionNotice', type: 'notice', default: '', diff --git a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts index 4153502a42..0d649d29dc 100644 --- a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts @@ -236,7 +236,7 @@ export async function odooGet( mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], [+itemsID] || [], - fieldsToReturn ?? [], + fieldsToReturn || [], ], }, id: Math.floor(Math.random() * 100), @@ -275,7 +275,7 @@ export async function odooGetAll( mapOdooResources[resource] || resource, mapOperationToJSONRPC[operation], (filters && processFilters(filters)) || [], - fieldsToReturn ?? [], + fieldsToReturn || [], 0, // offset limit, ], diff --git a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts index 479b1a58d2..42bf45f14e 100644 --- a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function oneSimpleApiRequest( body, qs, uri: - uri ?? + uri || `https://onesimpleapi.com/api${resource}?token=${credentials.apiToken}&output=${outputFormat}`, json: true, }; diff --git a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts index 4b018e842b..f276b5b5e0 100644 --- a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts @@ -37,7 +37,7 @@ export async function onfleetApiRequest( method, body, qs, - uri: uri ?? `https://onfleet.com/api/v2/${resource}`, + uri: uri || `https://onfleet.com/api/v2/${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts index 87fac2c57c..7b4c69c193 100644 --- a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts @@ -27,7 +27,7 @@ export async function openThesaurusApiRequest( method, qs, body, - uri: uri ?? `https://www.openthesaurus.de${resource}`, + uri: uri || `https://www.openthesaurus.de${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts index fc102df60f..83cbb27eb4 100644 --- a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function orbitApiRequest( method, qs, body, - uri: uri ?? `https://app.orbit.love/api/v1${resource}`, + uri: uri || `https://app.orbit.love/api/v1${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Oura/GenericFunctions.ts b/packages/nodes-base/nodes/Oura/GenericFunctions.ts index 3c8bf14e48..4f3655c5e8 100644 --- a/packages/nodes-base/nodes/Oura/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Oura/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function ouraApiRequest( method, qs, body, - uri: uri ?? `https://api.ouraring.com/v1${resource}`, + uri: uri || `https://api.ouraring.com/v1${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts index 5fc2299498..3a2cb7ee73 100644 --- a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function pagerDutyApiRequest( method, body, qs: query, - uri: uri ?? `https://api.pagerduty.com${resource}`, + uri: uri || `https://api.pagerduty.com${resource}`, json: true, qsStringifyOptions: { arrayFormat: 'brackets', diff --git a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts index 1d7c2fc3d7..76e806b4c3 100644 --- a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts @@ -75,8 +75,8 @@ export async function payPalApiRequest( const options = { headers: headerWithAuthentication, method, - qs: query ?? {}, - uri: uri ?? `${env}/v1${endpoint}`, + qs: query || {}, + uri: uri || `${env}/v1${endpoint}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts b/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts index 86f19db6ca..5a5a4ce3ee 100644 --- a/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function peekalinkApiRequest( method, qs, body, - uri: uri ?? `https://api.peekalink.io${resource}`, + uri: uri || `https://api.peekalink.io${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts index 88bdd0fa64..f1f5cbe891 100644 --- a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function philipsHueApiRequest( method, body, qs, - uri: uri ?? `https://api.meethue.com/route${resource}`, + uri: uri || `https://api.meethue.com/route${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts index 73ce29f581..64d338ea9f 100644 --- a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function profitWellApiRequest( method, qs, body, - uri: uri ?? `https://api.profitwell.com/v2${resource}`, + uri: uri || `https://api.profitwell.com/v2${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts index 120243966c..5dc7a7dcc4 100644 --- a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts @@ -18,7 +18,7 @@ export async function pushbulletApiRequest( method, body, qs, - uri: uri ?? `https://api.pushbullet.com/v2${path}`, + uri: uri || `https://api.pushbullet.com/v2${path}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts index 0612d38cc2..b29003d7e7 100644 --- a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts @@ -23,7 +23,7 @@ export async function pushcutApiRequest( method, body, qs, - uri: uri ?? `https://api.pushcut.io/v1${path}`, + uri: uri || `https://api.pushcut.io/v1${path}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts b/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts index 6a61260839..b041a2b166 100644 --- a/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts +++ b/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts @@ -219,7 +219,7 @@ export class QuestDb implements INodeType { // ---------------------------------- const additionalFields = this.getNodeParameter('additionalFields', 0); - const mode = (additionalFields.mode ?? 'independently') as string; + const mode = (additionalFields.mode || 'independently') as string; const queryResult = await pgQuery( this.getNodeParameter, diff --git a/packages/nodes-base/nodes/Redis/Redis.node.ts b/packages/nodes-base/nodes/Redis/Redis.node.ts index 2038926ba5..51efea49b4 100644 --- a/packages/nodes-base/nodes/Redis/Redis.node.ts +++ b/packages/nodes-base/nodes/Redis/Redis.node.ts @@ -702,7 +702,7 @@ export class Redis implements INodeType { const keyGet = this.getNodeParameter('key', itemIndex) as string; const keyType = this.getNodeParameter('keyType', itemIndex) as string; - const value = (await getValue(client, keyGet, keyType)) ?? null; + const value = (await getValue(client, keyGet, keyType)) || null; const options = this.getNodeParameter('options', itemIndex, {}); diff --git a/packages/nodes-base/nodes/S3/GenericFunctions.ts b/packages/nodes-base/nodes/S3/GenericFunctions.ts index dfca7eb62b..554a9c2ae9 100644 --- a/packages/nodes-base/nodes/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/S3/GenericFunctions.ts @@ -57,8 +57,8 @@ export async function s3ApiRequest( // Sign AWS API request with the user credentials const signOpts = { - headers: headers ?? {}, - region: region ?? credentials.region, + headers: headers || {}, + region: region || credentials.region, host: endpoint.host, method, path: `${path}?${queryToString(query).replace(/\+/g, '%2B')}`, diff --git a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts index 3ed5870f1a..839e805841 100644 --- a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts @@ -104,7 +104,7 @@ export async function salesforceApiRequest( const options = getOptions.call( this, method, - uri ?? endpoint, + uri || endpoint, body, qs, instance_url as string, @@ -125,7 +125,7 @@ export async function salesforceApiRequest( const options = getOptions.call( this, method, - uri ?? endpoint, + uri || endpoint, body, qs, credentials.oauthTokenData.instance_url, diff --git a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts index 3c5e081da8..5a12674573 100644 --- a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts +++ b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts @@ -1854,7 +1854,7 @@ export class Salesforce implements INodeType { const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); body.entity_content.PathOnClient = `${title}.${ - additionalFields.fileExtension ?? binaryData.fileExtension + additionalFields.fileExtension || binaryData.fileExtension }`; data = { entity_content: { diff --git a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts index f955040bc0..fcfad002d9 100644 --- a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts @@ -34,7 +34,7 @@ export async function salesmateApiRequest( method, qs, body, - uri: uri ?? `https://apis.salesmate.io${resource}`, + uri: uri || `https://apis.salesmate.io${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts index 1723af341a..9c5c0a8639 100644 --- a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts @@ -65,7 +65,7 @@ function endpointCtxExpr(ctx: ICtx, endpoint: string): string { return endpoint.replace( /({{ *(access_token|dtable_uuid|server) *}})/g, (match: string, expr: string, name: TEndpointVariableName) => { - return endpointVariables[name] ?? match; + return endpointVariables[name] || match; }, ); } @@ -94,7 +94,7 @@ export async function seaTableApiRequest( method, qs, body, - uri: url ?? `${resolveBaseUri(ctx)}${endpointCtxExpr(ctx, endpoint)}`, + uri: url || `${resolveBaseUri(ctx)}${endpointCtxExpr(ctx, endpoint)}`, json: true, }; diff --git a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts index 057aae770c..20d5909f59 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function scorecardApiRequest( headers: headerWithAuthentication, method, qs: query, - uri: uri ?? `https://api.securityscorecard.io/${resource}`, + uri: uri || `https://api.securityscorecard.io/${resource}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts index dc1e5ff7a6..ab2a5c8fa3 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts @@ -267,7 +267,7 @@ export class SecurityScorecard implements INodeType { body.date = this.getNodeParameter('date', i); } if (['issues', 'portfolio'].indexOf(reportType) > -1) { - body.format = this.getNodeParameter('options.format', i) ?? 'pdf'; + body.format = this.getNodeParameter('options.format', i) || 'pdf'; } if (['detailed', 'summary'].indexOf(reportType) > -1) { body.branding = this.getNodeParameter('branding', i); diff --git a/packages/nodes-base/nodes/Segment/GenericFunctions.ts b/packages/nodes-base/nodes/Segment/GenericFunctions.ts index a854e2093b..1ef2b7600c 100644 --- a/packages/nodes-base/nodes/Segment/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Segment/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function segmentApiRequest( method, qs, body, - uri: uri ?? `https://api.segment.io/v1${resource}`, + uri: uri || `https://api.segment.io/v1${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts index f2f50cc46b..3b15f105a2 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts @@ -601,7 +601,7 @@ export class SendGrid implements INodeType { attachmentsToSend.push({ content: dataBuffer.toString('base64'), - filename: binaryProperty.fileName ?? 'unknown', + filename: binaryProperty.fileName || 'unknown', type: binaryProperty.mimeType, }); } diff --git a/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts b/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts index 187832b663..b3c8d67ad1 100644 --- a/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts @@ -112,7 +112,7 @@ export namespace SendInBlueNode { itemIndex, mimeType, fileExtension!, - fileName ?? item.binary!.data.fileName!, + fileName || item.binary!.data.fileName!, ); attachment.push({ content, name }); diff --git a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts index 7eb309282f..e900a2ce1d 100644 --- a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts @@ -34,7 +34,7 @@ export async function sentryIoApiRequest( method, qs, body, - uri: uri ?? `https://sentry.io${resource}`, + uri: uri || `https://sentry.io${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts index dea8501bec..12329a7878 100644 --- a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function serviceNowApiRequest( method, qs, body, - uri: uri ?? `https://${credentials.subdomain}.service-now.com/api${resource}`, + uri: uri || `https://${credentials.subdomain}.service-now.com/api${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts index ea7f25bb3c..3d035fef97 100644 --- a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts @@ -39,7 +39,7 @@ export async function shopifyApiRequest( const options: OptionsWithUri = { method, qs: query, - uri: uri ?? `https://${credentials.shopSubdomain}.myshopify.com/admin/api/2019-10${resource}`, + uri: uri || `https://${credentials.shopSubdomain}.myshopify.com/admin/api/2019-10${resource}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/Slack/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/GenericFunctions.ts index 9311368847..b6d4a136c1 100644 --- a/packages/nodes-base/nodes/Slack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/GenericFunctions.ts @@ -24,7 +24,7 @@ export async function slackApiRequest( const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; let options: OptionsWithUri = { method, - headers: headers ?? { + headers: headers || { 'Content-Type': 'application/json; charset=utf-8', }, body, diff --git a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts index 34af2ce7fc..97e8496696 100644 --- a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function spotifyApiRequest( Accept: ' application/json', }, qs: query, - uri: uri ?? `https://api.spotify.com/v1${endpoint}`, + uri: uri || `https://api.spotify.com/v1${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Stackby/GenericFunction.ts b/packages/nodes-base/nodes/Stackby/GenericFunction.ts index fcdf29fd32..ebfa42636e 100644 --- a/packages/nodes-base/nodes/Stackby/GenericFunction.ts +++ b/packages/nodes-base/nodes/Stackby/GenericFunction.ts @@ -27,7 +27,7 @@ export async function apiRequest( method, body, qs: query, - uri: uri ?? `https://stackby.com/api/betav1${endpoint}`, + uri: uri || `https://stackby.com/api/betav1${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Strava/GenericFunctions.ts b/packages/nodes-base/nodes/Strava/GenericFunctions.ts index 4c213202e7..f43ceb272e 100644 --- a/packages/nodes-base/nodes/Strava/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strava/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function stravaApiRequest( method, form: body, qs, - uri: uri ?? `https://www.strava.com/api/v3${resource}`, + uri: uri || `https://www.strava.com/api/v3${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts index 64f4c2f99c..c7744d2843 100644 --- a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts @@ -43,7 +43,7 @@ export async function supabaseApiRequest( method, qs, body, - uri: uri ?? `${credentials.host}/rest/v1${resource}`, + uri: uri || `${credentials.host}/rest/v1${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts index 095d75b90f..6c9cea0cc0 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function surveyMonkeyApiRequest( method, body, qs: query, - uri: uri ?? `${endpoint}${resource}`, + uri: uri || `${endpoint}${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts index d8843377d2..5d3ca8cd7a 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts @@ -691,7 +691,7 @@ export class SurveyMonkeyTrigger implements INodeType { } const addressInfo: IDataObject = {}; for (const answer of question.answers.rows as IDataObject[]) { - addressInfo[answer.type as string] = rows[answer.id as string] ?? ''; + addressInfo[answer.type as string] = rows[answer.id as string] || ''; } responseQuestions.set(heading, addressInfo); } diff --git a/packages/nodes-base/nodes/Switch/Switch.node.ts b/packages/nodes-base/nodes/Switch/Switch.node.ts index 65e55ae16f..9d29647adc 100644 --- a/packages/nodes-base/nodes/Switch/Switch.node.ts +++ b/packages/nodes-base/nodes/Switch/Switch.node.ts @@ -532,13 +532,13 @@ export class Switch implements INodeType { [key: string]: (value1: NodeParameterValue, value2: NodeParameterValue) => boolean; } = { after: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) > (value2 ?? 0), + (value1 || 0) > (value2 || 0), before: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) < (value2 ?? 0), + (value1 || 0) < (value2 || 0), contains: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? '').toString().includes((value2 ?? '').toString()), + (value1 || '').toString().includes((value2 || '').toString()), notContains: (value1: NodeParameterValue, value2: NodeParameterValue) => - !(value1 ?? '').toString().includes((value2 ?? '').toString()), + !(value1 || '').toString().includes((value2 || '').toString()), endsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).endsWith(value2 as string), notEndsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => @@ -546,44 +546,44 @@ export class Switch implements INodeType { equal: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 === value2, notEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 !== value2, larger: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) > (value2 ?? 0), + (value1 || 0) > (value2 || 0), largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) >= (value2 ?? 0), + (value1 || 0) >= (value2 || 0), smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) < (value2 ?? 0), + (value1 || 0) < (value2 || 0), smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => - (value1 ?? 0) <= (value2 ?? 0), + (value1 || 0) <= (value2 || 0), startsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).startsWith(value2 as string), notStartsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => !(value1 as string).startsWith(value2 as string), regex: (value1: NodeParameterValue, value2: NodeParameterValue) => { - const regexMatch = (value2 ?? '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); + const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); let regex: RegExp; if (!regexMatch) { - regex = new RegExp((value2 ?? '').toString()); + regex = new RegExp((value2 || '').toString()); } else if (regexMatch.length === 1) { regex = new RegExp(regexMatch[1]); } else { regex = new RegExp(regexMatch[1], regexMatch[2]); } - return !!(value1 ?? '').toString().match(regex); + return !!(value1 || '').toString().match(regex); }, notRegex: (value1: NodeParameterValue, value2: NodeParameterValue) => { - const regexMatch = (value2 ?? '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); + const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); let regex: RegExp; if (!regexMatch) { - regex = new RegExp((value2 ?? '').toString()); + regex = new RegExp((value2 || '').toString()); } else if (regexMatch.length === 1) { regex = new RegExp(regexMatch[1]); } else { regex = new RegExp(regexMatch[1], regexMatch[2]); } - return !(value1 ?? '').toString().match(regex); + return !(value1 || '').toString().match(regex); }, }; diff --git a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts index 446286d34b..c22ca307af 100644 --- a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function tapfiliateApiRequest( method, qs, body, - uri: uri ?? `https://api.tapfiliate.com/1.6${endpoint}`, + uri: uri || `https://api.tapfiliate.com/1.6${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts index fb77d3f500..10f81f2fee 100644 --- a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts @@ -149,7 +149,7 @@ export async function apiRequest( ): Promise { const credentials = await this.getCredentials('telegramApi'); - query = query ?? {}; + query = query || {}; const options: OptionsWithUri = { headers: {}, diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index cc3ed94e28..fb920749dd 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -1977,7 +1977,7 @@ export class Telegram implements INodeType { ); } - body.disable_notification = body.disable_notification?.toString() ?? 'false'; + body.disable_notification = body.disable_notification?.toString() || 'false'; const formData = { ...body, diff --git a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts index a5039d7bc2..ea7e78ab7d 100644 --- a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function theHiveApiRequest( let options: OptionsWithUri = { method, qs: query, - uri: uri ?? `${credentials.url}/api${resource}`, + uri: uri || `${credentials.url}/api${resource}`, body, rejectUnauthorized: !credentials.allowUnauthorizedCerts, json: true, diff --git a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts index f31f49d67a..20dd6800ab 100644 --- a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts @@ -40,7 +40,7 @@ export async function togglApiRequest( headers: headerWithAuthentication, method, qs: query, - uri: uri ?? `https://api.track.toggl.com/api/v8${resource}`, + uri: uri || `https://api.track.toggl.com/api/v8${resource}`, body, json: true, }; diff --git a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts index 9df57aec04..64559d1293 100644 --- a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts @@ -32,7 +32,7 @@ export async function travisciApiRequest( method, qs, body, - uri: uri ?? `https://api.travis-ci.com${resource}`, + uri: uri || `https://api.travis-ci.com${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Trello/GenericFunctions.ts b/packages/nodes-base/nodes/Trello/GenericFunctions.ts index 5dfda99a9f..01604c3457 100644 --- a/packages/nodes-base/nodes/Trello/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Trello/GenericFunctions.ts @@ -15,7 +15,7 @@ export async function apiRequest( body: object, query?: IDataObject, ): Promise { - query = query ?? {}; + query = query || {}; const options: OptionsWithUri = { method, diff --git a/packages/nodes-base/nodes/Twake/GenericFunctions.ts b/packages/nodes-base/nodes/Twake/GenericFunctions.ts index a98aaf46ff..966abe5234 100644 --- a/packages/nodes-base/nodes/Twake/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twake/GenericFunctions.ts @@ -19,7 +19,7 @@ export async function twakeApiRequest( method, body, qs: query, - uri: uri ?? `https://plugins.twake.app/plugins/n8n${resource}`, + uri: uri || `https://plugins.twake.app/plugins/n8n${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts index 9aabeebee6..6efa943dd8 100644 --- a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function twitterApiRequest( method, body, qs, - url: uri ?? `https://api.twitter.com/1.1${resource}`, + url: uri || `https://api.twitter.com/1.1${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Twitter/Twitter.node.ts b/packages/nodes-base/nodes/Twitter/Twitter.node.ts index 50f4e998f9..c2b7298b0e 100644 --- a/packages/nodes-base/nodes/Twitter/Twitter.node.ts +++ b/packages/nodes-base/nodes/Twitter/Twitter.node.ts @@ -247,7 +247,7 @@ export class Twitter implements INodeType { } } - qs.tweet_mode = additionalFields.tweetMode ?? 'compat'; + qs.tweet_mode = additionalFields.tweetMode || 'compat'; if (returnAll) { responseData = await twitterApiRequestAllItems.call( diff --git a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts index c18cc5145f..eed52bcb68 100644 --- a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts @@ -49,7 +49,7 @@ export async function apiRequest( json: true, }; - query = query ?? {}; + query = query || {}; try { if (authenticationMethod === 'accessToken') { diff --git a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts index 115015094b..073bdaec2e 100644 --- a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts @@ -23,7 +23,7 @@ export async function upleadApiRequest( method, qs, body, - uri: uri ?? `https://api.uplead.com/v2${resource}`, + uri: uri || `https://api.uplead.com/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts index 0979c0fcef..dfc97e096a 100644 --- a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function uptimeRobotApiRequest( api_key: credentials.apiKey, ...body, }, - uri: uri ?? `https://api.uptimerobot.com/v2${resource}`, + uri: uri || `https://api.uptimerobot.com/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts index 04d7838f3a..fbc6e18439 100644 --- a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts @@ -30,7 +30,7 @@ export async function venafiApiRequest( body, qs, rejectUnauthorized: !credentials.allowUnauthorizedCerts, - uri: uri ?? `${credentials.domain}${resource}`, + uri: uri || `${credentials.domain}${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenterTrigger.node.ts b/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenterTrigger.node.ts index 24320a6914..0f66636db7 100644 --- a/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenterTrigger.node.ts +++ b/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenterTrigger.node.ts @@ -51,7 +51,7 @@ export class VenafiTlsProtectDatacenterTrigger implements INodeType { const now = moment().format(); - qs.ValidToGreater = webhookData.lastTimeChecked ?? now; + qs.ValidToGreater = webhookData.lastTimeChecked || now; qs.ValidToLess = now; diff --git a/packages/nodes-base/nodes/Vero/GenericFunctions.ts b/packages/nodes-base/nodes/Vero/GenericFunctions.ts index 83617d6b09..2bf80d7b93 100644 --- a/packages/nodes-base/nodes/Vero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Vero/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function veroApiRequest( auth_token: credentials.authToken, ...body, }, - uri: uri ?? `https://api.getvero.com/api/v2${resource}`, + uri: uri || `https://api.getvero.com/api/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Wait/Wait.node.ts b/packages/nodes-base/nodes/Wait/Wait.node.ts index 4efa81643a..b164ff9b0e 100644 --- a/packages/nodes-base/nodes/Wait/Wait.node.ts +++ b/packages/nodes-base/nodes/Wait/Wait.node.ts @@ -717,7 +717,7 @@ export class Wait implements INodeType { const fileJson = file.toJSON(); returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( file.path, - fileJson.name ?? fileJson.filename, + fileJson.name || fileJson.filename, fileJson.type as string, ); @@ -747,7 +747,7 @@ export class Wait implements INodeType { }, }; - const binaryPropertyName = (options.binaryPropertyName ?? 'data') as string; + const binaryPropertyName = (options.binaryPropertyName || 'data') as string; returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( binaryFile.path, mimeType, diff --git a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts index 72c5e15ae1..e0699f4a6e 100644 --- a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts @@ -36,7 +36,7 @@ export async function webflowApiRequest( method, qs, body, - uri: uri ?? `https://api.webflow.com${resource}`, + uri: uri || `https://api.webflow.com${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Webhook/Webhook.node.ts b/packages/nodes-base/nodes/Webhook/Webhook.node.ts index 1975a7c4c4..2e9d4d2134 100644 --- a/packages/nodes-base/nodes/Webhook/Webhook.node.ts +++ b/packages/nodes-base/nodes/Webhook/Webhook.node.ts @@ -529,7 +529,7 @@ export class Webhook implements INodeType { const fileJson = file.toJSON(); returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( file.path, - fileJson.name ?? fileJson.filename, + fileJson.name || fileJson.filename, fileJson.type as string, ); @@ -559,7 +559,7 @@ export class Webhook implements INodeType { }, }; - const binaryPropertyName = (options.binaryPropertyName ?? 'data') as string; + const binaryPropertyName = (options.binaryPropertyName || 'data') as string; returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( binaryFile.path, mimeType, diff --git a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts index cea58a3930..a96bc99153 100644 --- a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts @@ -13,7 +13,7 @@ export async function apiRequest( ): Promise { const credentials = await this.getCredentials('wekanApi'); - query = query ?? {}; + query = query || {}; const options: OptionsWithUri = { headers: { diff --git a/packages/nodes-base/nodes/WhatsApp/MediaFunctions.ts b/packages/nodes-base/nodes/WhatsApp/MediaFunctions.ts index 6742da52e8..1e3d8a32ac 100644 --- a/packages/nodes-base/nodes/WhatsApp/MediaFunctions.ts +++ b/packages/nodes-base/nodes/WhatsApp/MediaFunctions.ts @@ -35,7 +35,7 @@ export async function setupUpload( const data = new FormData(); data.append('file', buffer, { contentType: mimeType, - filename: mediaFileName ?? binaryFileName, + filename: mediaFileName || binaryFileName, }); data.append('messaging_product', 'whatsapp'); diff --git a/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts b/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts index fa2cdb4b6d..98508b8772 100644 --- a/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts +++ b/packages/nodes-base/nodes/WhatsApp/MessageFunctions.ts @@ -83,7 +83,7 @@ export async function mediaUploadFromItem( const data = new FormData(); data.append('file', await BinaryDataManager.getInstance().retrieveBinaryData(binaryFile), { contentType: mimeType, - filename: mediaFileName ?? binaryFileName, + filename: mediaFileName || binaryFileName, }); data.append('messaging_product', 'whatsapp'); @@ -105,7 +105,7 @@ export async function mediaUploadFromItem( set( requestOptions.body as IDataObject, `${operation}.filename`, - mediaFileName ?? binaryFileName, + mediaFileName || binaryFileName, ); } diff --git a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts index bd274dfad3..fa4b499bde 100644 --- a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts @@ -39,7 +39,7 @@ export async function woocommerceApiRequest( method, qs, body, - uri: uri ?? `${credentials.url}/wp-json/wc/v3${resource}`, + uri: uri || `${credentials.url}/wp-json/wc/v3${resource}`, json: true, }; diff --git a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts index 801421ff47..bfcf68b0da 100644 --- a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function wordpressApiRequest( method, qs, body, - uri: uri ?? `${credentials.url}/wp-json/wp/v2${resource}`, + uri: uri || `${credentials.url}/wp-json/wp/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Workable/GenericFunctions.ts b/packages/nodes-base/nodes/Workable/GenericFunctions.ts index 289b7e2b85..baa63e27eb 100644 --- a/packages/nodes-base/nodes/Workable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Workable/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function workableApiRequest( method, qs, body, - uri: uri ?? `https://${credentials.subdomain}.workable.com/spi/v3${resource}`, + uri: uri || `https://${credentials.subdomain}.workable.com/spi/v3${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Xero/GenericFunctions.ts b/packages/nodes-base/nodes/Xero/GenericFunctions.ts index dfe634aab5..cb99717f43 100644 --- a/packages/nodes-base/nodes/Xero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Xero/GenericFunctions.ts @@ -21,7 +21,7 @@ export async function xeroApiRequest( method, body, qs, - uri: uri ?? `https://api.xero.com/api.xro/2.0${resource}`, + uri: uri || `https://api.xero.com/api.xro/2.0${resource}`, json: true, }; try { diff --git a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts index 44bdc423b4..a8a383b6d0 100644 --- a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts @@ -41,7 +41,7 @@ export async function zendeskApiRequest( method, qs, body, - uri: uri ?? getUri(resource, credentials.subdomain), + uri: uri || getUri(resource, credentials.subdomain), json: true, qsStringifyOptions: { arrayFormat: 'brackets', diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index 98d187b70c..9506f99069 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -49,7 +49,7 @@ export async function zohoApiRequest( }, method, qs, - uri: uri ?? `${oauthTokenData.api_domain}/crm/v2${endpoint}`, + uri: uri || `${oauthTokenData.api_domain}/crm/v2${endpoint}`, json: true, }; diff --git a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts index f253cb2b9b..d1524c176c 100644 --- a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts @@ -17,7 +17,7 @@ export async function zoomApiRequest( let options: OptionsWithUri = { method, - headers: headers ?? { + headers: headers || { 'Content-Type': 'application/json', }, body, diff --git a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts index 355df5b889..7c7735d716 100644 --- a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts @@ -29,7 +29,7 @@ export async function zulipApiRequest( method, form: body, qs: query, - uri: uri ?? `${endpoint}${resource}`, + uri: uri || `${endpoint}${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index cc0a283a17..e33d283fd8 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -1,6 +1,6 @@ { "name": "n8n-nodes-base", - "version": "0.209.2", + "version": "0.210.0", "description": "Base nodes of n8n", "license": "SEE LICENSE IN LICENSE.md", "homepage": "https://n8n.io", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 46bc6cf4de..009624be56 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -160,6 +160,7 @@ importers: dotenv: ^8.0.0 express: ^4.16.4 express-openapi-validator: ^4.13.6 + express-prom-bundle: ^6.6.0 fast-glob: ^3.2.5 flatted: ^3.2.4 google-timezones-json: ^1.0.2 @@ -187,8 +188,8 @@ importers: luxon: ^3.1.0 mysql2: ~2.3.3 n8n-core: ~0.151.1 - n8n-editor-ui: ~0.177.1 - n8n-nodes-base: ~0.209.2 + n8n-editor-ui: ~0.178.0 + n8n-nodes-base: ~0.210.0 n8n-workflow: ~0.133.1 nodemailer: ^6.7.1 nodemon: ^2.0.2 @@ -252,6 +253,7 @@ importers: dotenv: 8.6.0 express: 4.18.2 express-openapi-validator: 4.13.8 + express-prom-bundle: 6.6.0_prom-client@13.2.0 fast-glob: 3.2.12 flatted: 3.2.7 google-timezones-json: 1.0.2 @@ -11563,6 +11565,17 @@ packages: path-to-regexp: 6.2.1 dev: false + /express-prom-bundle/6.6.0_prom-client@13.2.0: + resolution: {integrity: sha512-tZh2P2p5a8/yxQ5VbRav011Poa4R0mHqdFwn9Swe/obXDe5F0jY9wtRAfNYnqk4LXY7akyvR/nrvAHxQPWUjsQ==} + engines: {node: '>=10'} + peerDependencies: + prom-client: '>=12.0.0' + dependencies: + on-finished: 2.4.1 + prom-client: 13.2.0 + url-value-parser: 2.2.0 + dev: false + /express/4.18.2: resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==} engines: {node: '>= 0.10.0'} @@ -21275,6 +21288,11 @@ packages: querystringify: 2.2.0 requires-port: 1.0.0 + /url-value-parser/2.2.0: + resolution: {integrity: sha512-yIQdxJpgkPamPPAPuGdS7Q548rLhny42tg8d4vyTNzFqvOnwqrgHXvgehT09U7fwrzxi3RxCiXjoNUNnNOlQ8A==} + engines: {node: '>=6.0.0'} + dev: false + /url/0.10.3: resolution: {integrity: sha512-hzSUW2q06EqL1gKM/a+obYHLIO6ct2hwPuviqTTOcfFVc61UbfJ2Q32+uGL/HCPxKqrdGB5QUwIe7UqlDgwsOQ==} dependencies: