UNPKG

n8n-nodes-smartsuite

Version:
54 lines 1.97 kB
"use strict"; // src/nodes/SmartSuite/actions/solution/listSolution.operation.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.description = void 0; exports.execute = execute; const smartSuiteApi_1 = require("../../transport/smartSuiteApi"); exports.description = [ { displayName: 'Return All', name: 'returnAll', type: 'boolean', default: false, description: 'Return all solutions (paginated)', displayOptions: { show: { resource: ['solution'], operation: ['listSolution'] }, }, }, { displayName: 'Limit', name: 'limit', type: 'number', default: 50, typeOptions: { minValue: 1, maxValue: 1000 }, description: 'Max number of results to return when not returning all', displayOptions: { show: { resource: ['solution'], operation: ['listSolution'], returnAll: [false], }, }, }, ]; async function execute() { const returnAll = this.getNodeParameter('returnAll', 0); const limit = this.getNodeParameter('limit', 0, 50); const endpoint = '/solutions/'; if (returnAll) { // Use native paginatedRequest helper for all pages const allResults = await smartSuiteApi_1.paginatedRequest.call(this, 'GET', endpoint, {}, { limit, offset: 0 }); return this.helpers.returnJsonArray(allResults); } else { // Single-page mode via apiRequest const qs = { limit, offset: 0 }; const resp = (await smartSuiteApi_1.apiRequest.call(this, 'GET', endpoint, {}, qs)); const pageItems = Array.isArray(resp) ? resp : resp.response ?? resp.results ?? resp.items ?? resp.solutions ?? []; const limited = pageItems.slice(0, limit); return this.helpers.returnJsonArray(limited); } } //# sourceMappingURL=listSolution.operation.js.map