UNPKG

@apify/n8n-nodes-apify

Version:
92 lines 2.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.overrideActorProperties = overrideActorProperties; exports.listActors = listActors; const genericFunctions_1 = require("./genericFunctions"); const resourceLocatorProperty = { displayName: 'Actor ID', name: 'actorId', type: 'resourceLocator', default: { mode: 'list', value: '' }, modes: [ { displayName: 'From List', name: 'list', type: 'list', placeholder: 'Choose...', typeOptions: { searchListMethod: 'listActors', searchFilterRequired: false, searchable: false, }, }, { displayName: 'By URL', name: 'url', type: 'string', placeholder: 'https://console.apify.com/actors/AtBpiepuIUNs2k2ku/input', validation: [ { type: 'regex', properties: { regex: 'https://console.apify.com/actors/([a-zA-Z0-9]+)', errorMessage: 'Not a valid Actor URL', }, }, ], extractValue: { type: 'regex', regex: 'https://console.apify.com/actors/([a-zA-Z0-9]+)', }, }, { displayName: 'ID', name: 'id', type: 'string', validation: [ { type: 'regex', properties: { regex: '[a-zA-Z0-9]+', errorMessage: 'Not a valid Actor ID', }, }, ], placeholder: 'NVCnbrChXaPbhVs8bISltEhngFg', url: '=http:/console.apify.com/actors/{{ $value }}/input', }, ], }; function mapProperty(property) { return { ...property, ...resourceLocatorProperty, }; } function overrideActorProperties(properties) { return properties.map((property) => { if (property.name === 'actorId') { return mapProperty(property); } return property; }); } async function listActors(query) { const searchResults = await genericFunctions_1.apiRequestAllItems.call(this, 'GET', '/v2/acts', {}, { qs: { limit: 100, offset: 0, }, }); const { data } = searchResults; const { items } = data; return { results: items.map((b) => ({ name: b.name, value: b.id, url: `https://console.apify.com/actors/${b.id}/input`, description: b.name, })), }; } //# sourceMappingURL=actorResourceLocator.js.map