UNPKG

n8n

Version:

n8n Workflow Automation Tool

81 lines 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.integrationError = integrationError; exports.connectionUnavailable = connectionUnavailable; exports.unsupportedQuery = unsupportedQuery; exports.unsupportedAction = unsupportedAction; exports.normalizePlatformId = normalizePlatformId; exports.stringValue = stringValue; exports.stringProperty = stringProperty; exports.numberProperty = numberProperty; exports.booleanProperty = booleanProperty; exports.isoDateProperty = isoDateProperty; exports.removeUndefinedValues = removeUndefinedValues; exports.isDefined = isDefined; exports.hasUpdateIssueField = hasUpdateIssueField; const is_record_1 = require("@n8n/utils/is-record"); const integration_error_codes_1 = require("./integration-error-codes"); function integrationError(code, message) { return { ok: false, error: { code, message } }; } function connectionUnavailable() { return integrationError(integration_error_codes_1.INTEGRATION_ERROR_CODES.CONNECTION_NOT_AVAILABLE, 'The integration connection is not currently available.'); } function unsupportedQuery(platform, query) { return integrationError(integration_error_codes_1.INTEGRATION_ERROR_CODES.UNSUPPORTED_QUERY, `The active ${platform} connection does not support ${query}.`); } function unsupportedAction(platform, action) { return integrationError(integration_error_codes_1.INTEGRATION_ERROR_CODES.UNSUPPORTED_ACTION, `The active ${platform} connection does not support ${action}.`); } function normalizePlatformId(platform, id) { return id.includes(':') ? id : `${platform}:${id}`; } function stringValue(value) { return typeof value === 'string' && value.length > 0 ? value : undefined; } function stringProperty(value, key) { if (!(0, is_record_1.isRecord)(value)) return undefined; return stringValue(value[key]); } function numberProperty(value, key) { if (!(0, is_record_1.isRecord)(value)) return undefined; const property = value[key]; return typeof property === 'number' ? property : undefined; } function booleanProperty(value, key) { if (!(0, is_record_1.isRecord)(value)) return undefined; const property = value[key]; return typeof property === 'boolean' ? property : undefined; } function isoDateProperty(value, key) { if (!(0, is_record_1.isRecord)(value)) return undefined; const property = value[key]; if (property instanceof Date) return property.toISOString(); if (typeof property !== 'string' || property.length === 0) return undefined; const date = new Date(property); return Number.isNaN(date.getTime()) ? undefined : date.toISOString(); } function removeUndefinedValues(value) { return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined)); } function isDefined(value) { return value !== undefined; } function hasUpdateIssueField(input) { return (input.teamId !== undefined || input.title !== undefined || input.description !== undefined || input.assigneeId !== undefined || input.projectId !== undefined || input.labelIds !== undefined || input.priority !== undefined || input.stateId !== undefined || input.parentId !== undefined); } //# sourceMappingURL=integration-helpers.js.map