UNPKG

n8n-nodes-binalyze-air

Version:

Binalyze AIR nodes for automating DFIR with n8n workflows

195 lines 10.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.api = void 0; const helpers_1 = require("../../utils/helpers"); exports.api = { async getCases(context, credentials, organizationIds = '0', additionalParams) { try { const orgIds = Array.isArray(organizationIds) ? organizationIds.join(',') : organizationIds; const queryParams = { 'filter[organizationIds]': orgIds }; if (additionalParams) { if (additionalParams.pageNumber) { queryParams.pageNumber = additionalParams.pageNumber; } if (additionalParams.pageSize) { queryParams.pageSize = additionalParams.pageSize; } if (additionalParams.status) { queryParams['filter[status]'] = additionalParams.status; } if (additionalParams.ownerUserId) { queryParams['filter[ownerUserId]'] = additionalParams.ownerUserId; } if (additionalParams.sortBy) { queryParams.sortBy = additionalParams.sortBy; } if (additionalParams.sortType) { queryParams.sortType = additionalParams.sortType; } if (additionalParams.searchTerm) { queryParams['filter[searchTerm]'] = additionalParams.searchTerm; } } const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', '/api/public/cases', queryParams); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, 'fetch cases'); } catch (error) { throw new Error(`Failed to fetch cases: ${error instanceof Error ? error.message : String(error)}`); } }, async createCase(context, credentials, caseData) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', '/api/public/cases'); requestOptions.body = caseData; return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, 'create case'); } catch (error) { throw new Error(`Failed to create case: ${error instanceof Error ? error.message : String(error)}`); } }, async updateCase(context, credentials, id, updateData) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'PATCH', `/api/public/cases/${id}`); requestOptions.body = updateData; return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `update case with ID ${id}`); } catch (error) { throw new Error(`Failed to update case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async getCase(context, credentials, id) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', `/api/public/cases/${id}`); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `fetch case with ID ${id}`); } catch (error) { throw new Error(`Failed to fetch case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async closeCase(context, credentials, id) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', `/api/public/cases/${id}/close`); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `close case with ID ${id}`); } catch (error) { throw new Error(`Failed to close case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async openCase(context, credentials, id) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'PATCH', `/api/public/cases/${id}/open`); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `open case with ID ${id}`); } catch (error) { throw new Error(`Failed to open case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async archiveCase(context, credentials, id) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'PATCH', `/api/public/cases/${id}/archive`); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `archive case with ID ${id}`); } catch (error) { throw new Error(`Failed to archive case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async changeOwner(context, credentials, id, newOwnerId) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', `/api/public/cases/${id}/change-owner`); requestOptions.body = { newOwnerId: newOwnerId }; return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `change owner for case with ID ${id}`); } catch (error) { throw new Error(`Failed to change owner for case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async checkCaseName(context, credentials, name) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', '/api/public/cases/check', { name }); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, 'check case name'); } catch (error) { throw new Error(`Failed to check case name: ${error instanceof Error ? error.message : String(error)}`); } }, async getCaseActivities(context, credentials, id) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', `/api/public/cases/${id}/activities`); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `fetch activities for case with ID ${id}`); } catch (error) { throw new Error(`Failed to fetch activities for case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async getCaseEndpoints(context, credentials, id, organizationIds = 0) { try { const orgIds = String(organizationIds); const queryParams = { 'filter[organizationIds]': orgIds }; const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', `/api/public/cases/${id}/endpoints`, queryParams); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `fetch endpoints for case with ID ${id}`); } catch (error) { throw new Error(`Failed to fetch endpoints for case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async getCaseTasksById(context, credentials, id, organizationIds = 0) { try { const orgIds = String(organizationIds); const queryParams = { 'filter[organizationIds]': orgIds }; const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', `/api/public/cases/${id}/tasks`, queryParams); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `fetch tasks for case with ID ${id}`); } catch (error) { throw new Error(`Failed to fetch tasks for case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async getCaseUsers(context, credentials, caseId, organizationIds = '0') { try { const queryParams = { 'filter[organizationIds]': organizationIds }; const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'GET', `/api/public/cases/${caseId}/users`, queryParams); return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `fetch users for case with ID ${caseId}`); } catch (error) { throw new Error(`Failed to fetch users for case with ID ${caseId}: ${error instanceof Error ? error.message : String(error)}`); } }, async removeEndpointsFromCase(context, credentials, id, filter) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', `/api/public/cases/${id}/remove-endpoints`); requestOptions.body = { filter }; return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `remove endpoints from case with ID ${id}`); } catch (error) { throw new Error(`Failed to remove endpoints from case with ID ${id}: ${error instanceof Error ? error.message : String(error)}`); } }, async removeTaskAssignmentFromCase(context, credentials, caseId, taskAssignmentId) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', `/api/public/cases/${caseId}/remove-task-assignment`); requestOptions.body = { taskAssignmentId }; return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `remove task assignment from case with ID ${caseId}`); } catch (error) { throw new Error(`Failed to remove task assignment from case with ID ${caseId}: ${error instanceof Error ? error.message : String(error)}`); } }, async importTaskAssignmentsToCase(context, credentials, caseId, taskAssignmentIds) { try { const requestOptions = (0, helpers_1.buildRequestOptionsWithErrorHandling)(credentials, 'POST', `/api/public/cases/${caseId}/import-task-assignments`); requestOptions.body = { taskAssignmentIds }; return await (0, helpers_1.makeApiRequestWithErrorHandling)(context, requestOptions, `import task assignments to case with ID ${caseId}`); } catch (error) { throw new Error(`Failed to import task assignments to case with ID ${caseId}: ${error instanceof Error ? error.message : String(error)}`); } } }; //# sourceMappingURL=cases.js.map