UNPKG

@apify/n8n-nodes-apify

Version:
42 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getItems = getItems; const n8n_workflow_1 = require("n8n-workflow"); const genericFunctions_1 = require("../../../resources/genericFunctions"); const helpers_1 = require("../../../helpers"); function normalizeCommaSeparatedList(value) { return value .split(',') .map((field) => field.trim()) .filter((field) => field.length > 0) .join(','); } async function getItems(i) { const datasetId = this.getNodeParameter('datasetId', i); const offset = this.getNodeParameter('offset', i, 0); const limit = this.getNodeParameter('limit', i, 50); const options = (this.getNodeParameter('options', i, {}) || {}); if (!datasetId) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Dataset ID is required'); } const qs = { offset, limit }; if (options.fields) { qs.fields = normalizeCommaSeparatedList(options.fields); } if (options.omit) { qs.omit = normalizeCommaSeparatedList(options.omit); } try { const itemsArray = await genericFunctions_1.apiRequest.call(this, { method: 'GET', uri: `/v2/datasets/${datasetId}/items`, qs, timeout: helpers_1.consts.DATASET_REQUEST_TIMEOUT_MS, }); return this.helpers.returnJsonArray(itemsArray); } catch (error) { throw new n8n_workflow_1.NodeApiError(this.getNode(), error); } } //# sourceMappingURL=execute.js.map