first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const companyReportGetDescription: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Report ID',
|
||||
name: 'reportId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['companyReport'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'ID of the report. You can get the report number by hovering over the report name on the reports page and grabbing the ID.',
|
||||
},
|
||||
{
|
||||
displayName: 'Format',
|
||||
name: 'format',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'CSV',
|
||||
value: 'CSV',
|
||||
},
|
||||
{
|
||||
name: 'JSON',
|
||||
value: 'JSON',
|
||||
},
|
||||
{
|
||||
name: 'PDF',
|
||||
value: 'PDF',
|
||||
},
|
||||
{
|
||||
name: 'XLS',
|
||||
value: 'XLS',
|
||||
},
|
||||
{
|
||||
name: 'XML',
|
||||
value: 'XML',
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['companyReport'],
|
||||
},
|
||||
},
|
||||
default: 'JSON',
|
||||
description: 'The output format for the report',
|
||||
},
|
||||
{
|
||||
displayName: 'Put Output In Field',
|
||||
name: 'output',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
required: true,
|
||||
description: 'The name of the output field to put the binary file data in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['companyReport'],
|
||||
},
|
||||
hide: {
|
||||
format: ['JSON'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['companyReport'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Duplicate Field Filtering',
|
||||
name: 'fd',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to apply the standard duplicate field filtering or not',
|
||||
},
|
||||
{
|
||||
displayName: 'Only Current',
|
||||
name: 'onlyCurrent',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to hide future dated values from the history table fields or not',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function get(this: IExecuteFunctions, index: number) {
|
||||
const body: IDataObject = {};
|
||||
const requestMethod = 'GET';
|
||||
const items = this.getInputData();
|
||||
|
||||
//meta data
|
||||
const reportId = this.getNodeParameter('reportId', index) as string;
|
||||
const format = this.getNodeParameter('format', 0) as string;
|
||||
const fd = this.getNodeParameter('options.fd', index, true) as boolean;
|
||||
const onlyCurrent = this.getNodeParameter('options.onlyCurrent', index, true) as boolean;
|
||||
|
||||
//endpoint
|
||||
const endpoint = `reports/${reportId}/?format=${format}&fd=${fd}&onlyCurrent=${onlyCurrent}`;
|
||||
|
||||
if (format === 'JSON') {
|
||||
const responseData = await apiRequest.call(
|
||||
this,
|
||||
requestMethod,
|
||||
endpoint,
|
||||
body,
|
||||
{},
|
||||
{ resolveWithFullResponse: true },
|
||||
);
|
||||
return this.helpers.returnJsonArray(responseData.body as IDataObject);
|
||||
}
|
||||
|
||||
const output: string = this.getNodeParameter('output', index) as string;
|
||||
|
||||
const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, {
|
||||
encoding: null,
|
||||
json: false,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
let mimeType = response.headers['content-type'] as string | undefined;
|
||||
mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined;
|
||||
const contentDisposition = response.headers['content-disposition'];
|
||||
const fileNameRegex = /(?<=filename=").*\b/;
|
||||
const match = fileNameRegex.exec(contentDisposition as string);
|
||||
let fileName = '';
|
||||
|
||||
// file name was found
|
||||
if (match !== null) {
|
||||
fileName = match[0];
|
||||
}
|
||||
|
||||
const newItem: INodeExecutionData = {
|
||||
json: items[index].json,
|
||||
binary: {},
|
||||
};
|
||||
|
||||
if (items[index].binary !== undefined && newItem.binary) {
|
||||
// Create a shallow copy of the binary data so that the old
|
||||
// data references which do not get changed still stay behind
|
||||
// but the incoming data does not get changed.
|
||||
Object.assign(newItem.binary, items[index].binary);
|
||||
}
|
||||
|
||||
newItem.binary = {
|
||||
[output]: await this.helpers.prepareBinaryData(
|
||||
response.body as unknown as Buffer,
|
||||
fileName,
|
||||
mimeType,
|
||||
),
|
||||
};
|
||||
|
||||
return [newItem as unknown as INodeExecutionData[]];
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { companyReportGetDescription as description } from './description';
|
||||
import { get as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as get from './get';
|
||||
|
||||
export { get };
|
||||
|
||||
export const descriptions: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['companyReport'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a company report',
|
||||
action: 'Get a company report',
|
||||
},
|
||||
],
|
||||
default: 'get',
|
||||
},
|
||||
...get.description,
|
||||
];
|
||||
Reference in New Issue
Block a user