UNPKG

n8n-nodes-smartsuite

Version:
62 lines 2.03 kB
"use strict"; // src/nodes/SmartSuite/helpers/utils.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.RESERVED_FIELDS = void 0; exports.asIdString = asIdString; exports.debugLog = debugLog; exports.requireParam = requireParam; exports.isReservedField = isReservedField; const n8n_workflow_1 = require("n8n-workflow"); /** * Flattens an n8n “resourceLocator” value into its raw ID string. */ function asIdString(input) { if (typeof input === 'object' && input !== null && 'value' in input) { return input.value; } return String(input ?? ''); } /** * Debug logger (gated by SMARTSUITE_DEBUG / SMARTSUITE_DEBUG_LEVEL). */ function debugLog(msg, data, level = 1) { const envDebug = process.env.SMARTSUITE_DEBUG?.toLowerCase() === 'true'; const envLevel = parseInt(process.env.SMARTSUITE_DEBUG_LEVEL || '1', 10); if (!envDebug || envLevel < level) return; console.log('[SmartSuite DEBUG]', msg, ...(data !== undefined ? [data] : [])); } /** * Validate a resourceLocator (list/id): throw NodeOperationError if missing or invalid. */ function requireParam(paramName, label, itemIndex = 0, pattern, patternMessage) { const raw = this.getNodeParameter(paramName, itemIndex); const id = asIdString(raw); if (!id) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${label} must be selected.`, { itemIndex }); } if (pattern && !pattern.test(id)) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), patternMessage ?? `${label} must be valid.`, { itemIndex }); } return id; } /** * Fields that SmartSuite manages internally (cannot be set via API). */ exports.RESERVED_FIELDS = [ 'autonumber', 'count', 'first_created', 'formula', 'last_updated', 'record_id', 'rollup', 'vote', ]; /** * Test whether a field-slug is one of those reserved. */ function isReservedField(slug) { return exports.RESERVED_FIELDS.includes(slug); } //# sourceMappingURL=utils.js.map