Skip to content

Commit

Permalink
update isocn to svg
Browse files Browse the repository at this point in the history
  • Loading branch information
minhlucvan committed Oct 2, 2024
1 parent e236971 commit 52d2e9a
Show file tree
Hide file tree
Showing 41 changed files with 17,418 additions and 16,446 deletions.
11 changes: 10 additions & 1 deletion nodes.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ module.exports = {
targetDir: path.resolve(__dirname, 'nodes/Browserless/v2'),
version: 2,
tags: ['Browser REST APIs'],
// operations: ['/pdf'],
operations: [
'/scrape',
'/pdf',
'/screenshot',
'/content',
'/function',
'/unblock',
'/performance',
'/download'
],
credentials: [{
displayName: 'Browserless API',
name: 'browserlessApi',
Expand Down
2 changes: 1 addition & 1 deletion nodes/Browserless/Browserless.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Browserless extends VersionedNodeType {
const baseDescription: INodeTypeBaseDescription = {
displayName: 'Browserless',
name: 'browserless',
icon: 'file:browserless.png',
icon: 'file:browserless.svg',
group: ['transform'],
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Interact with Browserless API',
Expand Down
Binary file removed nodes/Browserless/browserless.png
Binary file not shown.
5 changes: 5 additions & 0 deletions nodes/Browserless/browserless.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion nodes/Browserless/v1/Browserless.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Browserless implements INodeType {
...baseDescription,
displayName: 'Browserless',
name: 'browserless',
icon: 'file:browserless.png',
icon: 'file:browserless.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
Expand Down
4 changes: 2 additions & 2 deletions nodes/Browserless/v2/Browserless.methods.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { methods } from './resources';
import { methods } from './resources'

export { methods };
export { methods }
21 changes: 12 additions & 9 deletions nodes/Browserless/v2/Browserless.node.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"node": "n8n-nodes-<name>",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Development", "Developer Tools"],
"resources": {
"credentialDocumentation": [],
"primaryDocumentation": []
}
}
"node": "n8n-nodes-<name>",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": [
"Development",
"Developer Tools"
],
"resources": {
"credentialDocumentation": [],
"primaryDocumentation": []
}
}
76 changes: 40 additions & 36 deletions nodes/Browserless/v2/Browserless.node.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
import { INodeType, INodeTypeBaseDescription, INodeTypeDescription } from 'n8n-workflow';
import {
INodeType,
INodeTypeBaseDescription,
INodeTypeDescription,
} from 'n8n-workflow'

import { properties } from './Browserless.properties';
import { methods } from './Browserless.methods';
import { properties } from './Browserless.properties'
import { methods } from './Browserless.methods'

export class Browserless implements INodeType {
description: INodeTypeDescription;
description: INodeTypeDescription

methods = methods;
methods = methods

constructor(baseDescription: INodeTypeBaseDescription) {
this.description = {
...baseDescription,
displayName: 'Browserless',
name: 'browserless',
icon: 'file:browserless.png',
group: ['transform'],
version: 2,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Browserless API',
defaults: {
name: 'Browserless',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
displayName: 'Browserless API',
name: 'browserlessApi',
required: true,
},
],
requestDefaults: {
headers: {
'Content-Type': 'application/json',
},
baseURL: '={{$credentials.url}}',
},
constructor (baseDescription: INodeTypeBaseDescription) {
this.description = {
...baseDescription,
displayName: 'Browserless',
name: 'browserless',
icon: 'file:browserless.svg',
group: ['transform'],
version: 2,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Browserless API',
defaults: {
name: 'Browserless',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
displayName: 'Browserless API',
name: 'browserlessApi',
required: true,
},
],
requestDefaults: {
headers: {
'Content-Type': 'application/json',
},
baseURL: '={{$credentials.url}}',
},

properties,
};
}
properties: properties,
}
}
}
6 changes: 3 additions & 3 deletions nodes/Browserless/v2/Browserless.properties.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { INodeProperties } from 'n8n-workflow';
import { properties as resources } from './resources';
import { INodeProperties } from 'n8n-workflow'
import { properties as resources } from './resources'

export const properties: INodeProperties[] = [...resources];
export const properties: INodeProperties[] = [...resources]
175 changes: 92 additions & 83 deletions nodes/Browserless/v2/helpers/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,107 @@
import {
BinaryFileType,
IBinaryData,
IDataObject,
IExecuteSingleFunctions,
IHttpRequestOptions,
IN8nHttpFullResponse,
INodeExecutionData,
IPostReceiveBinaryData,
IPostReceiveFilter,
IPostReceiveLimit,
IPostReceiveRootProperty,
IPostReceiveSet,
IPostReceiveSetKeyValue,
IPostReceiveSort,
} from 'n8n-workflow';

export async function preSendActionCustonBody(
this: IExecuteSingleFunctions,
requestOptions: IHttpRequestOptions,
BinaryFileType,
IBinaryData,
IDataObject,
IExecuteSingleFunctions,
IHttpRequestOptions,
IN8nHttpFullResponse,
INodeExecutionData,
IPostReceiveBinaryData,
IPostReceiveFilter,
IPostReceiveLimit,
IPostReceiveRootProperty,
IPostReceiveSet,
IPostReceiveSetKeyValue,
IPostReceiveSort,
} from 'n8n-workflow'

export async function preSendActionCustonBody (
this: IExecuteSingleFunctions,
requestOptions: IHttpRequestOptions
): Promise<IHttpRequestOptions> {
const { customBody } = requestOptions.body as IDataObject;

if (typeof requestOptions.body === 'object' && typeof customBody === 'object') {
// @ts-ignore
requestOptions.body = {
...requestOptions.body,
...customBody,
};
// @ts-ignore
delete requestOptions.body.customBody;
}

return Promise.resolve(requestOptions);
const { customBody } = requestOptions.body as IDataObject

if (
typeof requestOptions.body === 'object' &&
typeof customBody === 'object'
) {
// @ts-ignore
requestOptions.body = {
...requestOptions.body,
...customBody,
}
// @ts-ignore
delete requestOptions.body.customBody
}

return Promise.resolve(requestOptions)
}

/* eslint-disable indent */
/* tslint:disable:indent */
export type PostReceiveAction =
| ((
this: IExecuteSingleFunctions,
items: INodeExecutionData[],
response: IN8nHttpFullResponse,
) => Promise<INodeExecutionData[]>)
| IPostReceiveBinaryData
| IPostReceiveFilter
| IPostReceiveLimit
| IPostReceiveRootProperty
| IPostReceiveSet
| IPostReceiveSetKeyValue
| IPostReceiveSort;
/* eslint-enable indent */
/* tslint:enable:indent */

function getresponseContentType(response: IN8nHttpFullResponse): string {
return response.headers['content-type'] as string;
| ((
this: IExecuteSingleFunctions,
items: INodeExecutionData[],
response: IN8nHttpFullResponse
) => Promise<INodeExecutionData[]>)
| IPostReceiveBinaryData
| IPostReceiveFilter
| IPostReceiveLimit
| IPostReceiveRootProperty
| IPostReceiveSet
| IPostReceiveSetKeyValue
| IPostReceiveSort

function getresponseContentType (response: IN8nHttpFullResponse): string {
return response.headers['content-type'] as string
}

function getFileTypeFromContentType(contentType: string): string {
const type = contentType.split(';')[0].trim();
function getFileTypeFromContentType (contentType: string): string {
const type = contentType.split(';')[0].trim()
return type
}

if (type.includes('/')) {
return type.split('/')[0];
}
function getFileExtensionFromContentType (contentType: string): string {
const type = contentType.split(';')[0].trim()

return type;
}
if (/^image\//.test(type)) {
return type.split('/')[1]
}

function getFileExtensionFromContentType(contentType: string): string {
const type = contentType.split(';')[0].trim();
if (/^audio\//.test(type)) {
return type.split('/')[1]
}

// any/thing -> thing
if (typeof type === 'string' && type.includes('/')) {
return type.split('/')[1];
}
if (/^video\//.test(type)) {
return type.split('/')[1]
}

return type;
if (/^text\//.test(type)) {
return type.split('/')[1]
}

if (/^application\//.test(type)) {
return type.split('/')[1]
}

return type
}

export const postReceiveActionBinaryData: PostReceiveAction =
async function postReceiveActionBinaryData(
this: IExecuteSingleFunctions,
items: INodeExecutionData[],
response: IN8nHttpFullResponse,
): Promise<INodeExecutionData[]> {
const contentType = getresponseContentType(response);

const { binary } = items[0];

if (binary && binary.data && binary.data.mimeType === 'text/plain') {
const data = binary.data as IBinaryData;
data.mimeType = contentType;
data.fileType = getFileTypeFromContentType(contentType) as BinaryFileType;
data.fileExtension = getFileExtensionFromContentType(contentType);
}

return items;
};
async function postReceiveActionBinaryData (
this: IExecuteSingleFunctions,
items: INodeExecutionData[],
response: IN8nHttpFullResponse
): Promise<INodeExecutionData[]> {
const contentType = getresponseContentType(response)

const { binary } = items[0]

if (binary && binary.data) {
const data = binary.data as IBinaryData
data.mimeType = contentType
data.fileType = getFileTypeFromContentType(contentType) as BinaryFileType
data.fileExtension = getFileExtensionFromContentType(contentType)
}

return items
}
4 changes: 2 additions & 2 deletions nodes/Browserless/v2/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * as hooks from './hooks';
export * as methods from './methods';
export * as hooks from './hooks'
export * as methods from './methods'
20 changes: 11 additions & 9 deletions nodes/Browserless/v2/helpers/methods.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { INodeType } from 'n8n-workflow';
import { INodeType } from 'n8n-workflow'

type IMethodModule = INodeType['methods'];
type IMethodModule = INodeType['methods']

/**
* Merge all methods from all modules into one object
* @param modules: IMethodModule[]
* @returns methods: INodeType['methods']
*/
export function aggregateNodeMethods(modules: IMethodModule[]): INodeType['methods'] {
return modules.reduce((methods, module) => {
return {
...methods,
...module,
};
}, {});
export function aggregateNodeMethods (
modules: IMethodModule[]
): INodeType['methods'] {
return modules.reduce((methods, module) => {
return {
...methods,
...module,
}
}, {})
}
Loading

0 comments on commit 52d2e9a

Please sign in to comment.