Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10360194
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/nodes/Phabricator/Phabricator.node.ts b/nodes/Phabricator/Phabricator.node.ts
index 38856d6..d20a564 100644
--- a/nodes/Phabricator/Phabricator.node.ts
+++ b/nodes/Phabricator/Phabricator.node.ts
@@ -1,106 +1,111 @@
import {
IExecuteFunctions,
INodeExecutionData,
INodeType,
INodeTypeDescription,
NodeExecutionWithMetadata,
} from 'n8n-workflow';
import { methods, apps, short_descriptions, fields } from './methods';
export class Phabricator implements INodeType {
description: INodeTypeDescription = {
displayName: 'Phabricator',
name: 'phabricator',
icon: 'file:phabricator.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"]}}',
description: 'Interact with Phabricator',
defaults: {
name: 'Phabricator',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'phabricatorApi',
required: true,
},
],
requestDefaults: {
method: 'POST',
baseURL: 'https://hub.sealcode.org',
},
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: apps.map((method) => ({
name: method,
value: method,
action: method,
description: `Call ${method} Conduit method`,
})),
default: 'user.whoami',
},
...apps.map((app) => ({
displayName: 'Operation',
name: 'operation',
type: <const>'options',
noDataExpression: true,
description: 'Choose an operation',
required: true,
displayOptions: {
show: {
resource: [app],
},
},
options: Object.entries(methods)
.filter(([method_name]) => {
return method_name.startsWith(app + '.');
})
.map(([method_name, method]) => ({
name: method_name,
value: method_name,
description: method.description,
action:
method_name.split('.').slice(1).join('.') + ': ' + short_descriptions[method_name],
routing: {
request: {
method: <const>'POST',
url: '/api/' + method_name,
},
},
})),
default: Object.keys(methods).filter((method_name) => method_name.startsWith(app + '.'))[0],
})),
...fields,
],
};
async execute(
this: IExecuteFunctions,
): Promise<INodeExecutionData[][] | NodeExecutionWithMetadata[][] | null> {
this.sendMessageToUI('I AM EXECUTED');
const { token, domain } = (await this.getCredentials('phabricatorApi')) as {
token: string;
domain: string;
};
this.sendMessageToUI('parameters↓');
- this.sendMessageToUI(this.getNode().parameters);
+ const parameters = { ...this.getNode().parameters };
+ for (const key in parameters) {
+ if (parameters[key] == '') {
+ delete parameters[key];
+ }
+ }
const request = {
- url: domain + '/api' + this.getNodeParameter('operation', 0),
+ url: domain + '/api/' + this.getNodeParameter('operation', 0),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
- body: new URLSearchParams({ token }),
+ body: new URLSearchParams({ token, ...parameters }),
method: <const>'POST',
};
this.sendMessageToUI(request);
- await this.helpers.httpRequest(request);
- return [];
+ const response = await this.helpers.httpRequest(request);
+ return [response];
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 8, 05:15 (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1034049
Default Alt Text
(3 KB)
Attached To
Mode
rNPN n8n-phabricator-node
Attached
Detach File
Event Timeline
Log In to Comment