generated from n8n-io/n8n-nodes-starter
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e236971
commit 52d2e9a
Showing
41 changed files
with
17,418 additions
and
16,446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
}, {}) | ||
} |
Oops, something went wrong.