UNPKG

n8n-nodes-smartsuite

Version:
42 lines 1.76 kB
"use strict"; // src/nodes/SmartSuite/actions/table/listTable.operation.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.execute = execute; const n8n_workflow_1 = require("n8n-workflow"); const utils_1 = require("../../helpers/utils"); const smartSuiteApi_1 = require("../../transport/smartSuiteApi"); const validation_1 = require("../../helpers/validation"); async function execute() { (0, utils_1.debugLog)('[Table] listTable.execute called', this.getNode().parameters, 2); const items = this.getInputData(); const returnAll = this.getNodeParameter('returnAll', 0); const limit = returnAll ? undefined : this.getNodeParameter('limit', 0); const returnData = []; for (let i = 0; i < items.length; i++) { const solutionId = await validation_1.getSolutionId.call(this, i); const qs = { solution: solutionId }; if (!returnAll) { qs.limit = limit; } let tablesArray; if (returnAll) { tablesArray = await smartSuiteApi_1.paginatedRequest.call(this, 'GET', '/applications/', {}, qs); } else { const resp = await smartSuiteApi_1.apiRequest.call(this, 'GET', '/applications/', {}, qs); tablesArray = Array.isArray(resp.results) ? resp.results : Array.isArray(resp) ? resp : []; } if (!tablesArray.length) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No tables found for Solution: ${solutionId}`, { itemIndex: i }); } returnData.push(...this.helpers.returnJsonArray(tablesArray)); } return returnData; } //# sourceMappingURL=listTable.operation.js.map