11import {
2- INodeType ,
3- INodeTypeDescription ,
2+ INodeType ,
3+ INodeTypeDescription ,
44 ILoadOptionsFunctions ,
55 INodeListSearchResult ,
66 IExecuteFunctions ,
@@ -15,22 +15,22 @@ import { apiRequest } from './GenericFunctions';
1515import isbot from 'isbot' ;
1616
1717interface LowcoderAppType {
18- applicationId : string ;
19- name : string ;
18+ applicationId : string ;
19+ name : string ;
2020 applicationType : number
2121}
2222
2323const WAIT_TIME_UNLIMITED = '3000-01-01T00:00:00.000Z' ;
2424
2525export class Lowcoder implements INodeType {
26- description : INodeTypeDescription = {
26+ description : INodeTypeDescription = {
2727 displayName : 'Lowcoder' ,
2828 name : 'lowcoder' ,
2929 // eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
3030 icon : 'file:lowcoder.png' ,
3131 group : [ 'transform' ] ,
3232 version : 1 ,
33- subtitle : '=app:{{ $parameter["appId"]' ,
33+ subtitle : '=app:{{ $parameter["appId"]' ,
3434 description : 'Consume Lowcoder API' ,
3535 defaults : {
3636 name : 'Lowcoder' ,
@@ -54,23 +54,23 @@ export class Lowcoder implements INodeType {
5454 responsePropertyName : '={{$parameter["options"]["responsePropertyName"]}}' ,
5555 responseHeaders : '={{$parameter["options"]["responseHeaders"]}}' ,
5656 path : '={{$parameter["appId"] || ""}}' ,
57- restartWebhook : true ,
57+ restartWebhook : true ,
5858 } ,
59- ] ,
59+ ] ,
6060 properties : [
6161 ...appFields ,
6262 {
63- displayName : 'Resume the workflow by calling this Webhook: http(s)://{n8n-url}/webhook-waiting/{Workflow-Execution-ID}/{Lowcoder-App-ID}' ,
64- name : 'webhookNotice' ,
65- type : 'notice' ,
66- default : '' ,
67- } ,
68- {
69- displayName : 'The Workflow-Execution-ID is available via the n8n Rest API' ,
70- name : 'webhookNotice' ,
71- type : 'notice' ,
72- default : '' ,
73- } ,
63+ displayName : 'Resume the workflow by calling this Webhook: http(s)://{n8n-url}/webhook-waiting/{Workflow-Execution-ID}/{Lowcoder-App-ID}' ,
64+ name : 'webhookNotice' ,
65+ type : 'notice' ,
66+ default : '' ,
67+ } ,
68+ {
69+ displayName : 'The Workflow-Execution-ID is available via the n8n Rest API' ,
70+ name : 'webhookNotice' ,
71+ type : 'notice' ,
72+ default : '' ,
73+ } ,
7474 httpMethodsProperty ,
7575 optionsProperty ,
7676 {
@@ -81,55 +81,56 @@ export class Lowcoder implements INodeType {
8181 description : 'The HTTP response code to return' ,
8282 } ,
8383 ] ,
84- } ;
84+ } ;
8585
8686 methods = {
87- listSearch : {
88- async searchApps (
89- this : ILoadOptionsFunctions ,
90- query ?: string ,
91- ) : Promise < INodeListSearchResult > {
92- const searchResults = await apiRequest . call (
93- this ,
94- 'GET' ,
95- 'applications/list' ,
96- { } ,
97- {
98- query,
87+ listSearch : {
88+ async searchApps (
89+ this : ILoadOptionsFunctions ,
90+ query ?: string ,
91+ ) : Promise < INodeListSearchResult > {
92+
93+ const searchResults = await apiRequest . call (
94+ this ,
95+ 'GET' ,
96+ 'applications/list' ,
97+ { } ,
98+ {
99+ query,
99100 withContainerSize : false
100- } ,
101- ) ;
102- console . log ( searchResults ) ;
103- return {
104- results : searchResults . data . map ( ( b : LowcoderAppType ) => ( {
105- name : `${ b . name } (${ b . applicationType == 2 ? "Module" : "App" } )` ,
106- value : b . applicationId ,
107- } ) ) ,
108- } ;
109- } ,
110- } ,
111- } ;
101+ } ,
102+ ) ;
103+ console . log ( searchResults ) ;
104+ return {
105+ results : searchResults . data . map ( ( b : LowcoderAppType ) => ( {
106+ name : `${ b . name } (${ b . applicationType == 2 ? "Module" : "App" } )` ,
107+ value : b . applicationId ,
108+ } ) ) ,
109+ } ;
110+ } ,
111+ } ,
112+ } ;
112113
113114 async webhook ( this : IWebhookFunctions ) : Promise < IWebhookResponseData > {
114- const options = this . getNodeParameter ( 'options' , { } ) as {
115- binaryData : boolean ;
116- ignoreBots : boolean ;
117- rawBody : Buffer ;
118- responseData ?: string ;
115+ const options = this . getNodeParameter ( 'options' , { } ) as {
116+ binaryData : boolean ;
117+ ignoreBots : boolean ;
118+ rawBody : Buffer ;
119+ responseData ?: string ;
119120 responseCode ?: number ;
120- } ;
121- const req = this . getRequestObject ( ) ;
122- const resp = this . getResponseObject ( ) ;
121+ } ;
122+ const req = this . getRequestObject ( ) ;
123+ const resp = this . getResponseObject ( ) ;
123124
124- try {
125- if ( options . ignoreBots && isbot ( req . headers [ 'user-agent' ] ) ) {
126- throw new NodeApiError ( this . getNode ( ) , { } , { message : 'Authorization data is wrong!' } ) ;
125+ try {
126+ if ( options . ignoreBots && isbot ( req . headers [ 'user-agent' ] ) ) {
127+ throw new NodeApiError ( this . getNode ( ) , { } , { message : 'Authorization data is wrong!' } ) ;
127128 }
128- } catch ( error ) {
129+ } catch ( error ) {
129130 resp . writeHead ( error . responseCode || 401 , { 'WWW-Authenticate' : 'Basic realm="Webhook"' } ) ;
130131 resp . end ( error . message ) ;
131132 return { noWebhookResponse : true } ;
132- }
133+ }
133134
134135 const type = req . query . type ;
135136 if ( type === 'resume' ) {
@@ -155,14 +156,15 @@ export class Lowcoder implements INodeType {
155156 resp . setHeader ( 'Content-Type' , 'application/json' ) ;
156157 resp . end ( JSON . stringify ( { message : 'Static response: workflow not resumed' , type, previousData } ) ) ;
157158 return { noWebhookResponse : true } ;
158- }
159- }
159+ }
160+ }
161+
162+ async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
160163
161- async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
162164 let waitTill = new Date ( WAIT_TIME_UNLIMITED ) ;
163165 const staticData = this . getWorkflowStaticData ( 'node' ) ;
164166 staticData . previousNodeData = this . getInputData ( ) . map ( item => item . json ) ;
165167 await this . putExecutionToWait ( waitTill ) ;
166- return [ this . getInputData ( ) ] ;
167- }
168+ return [ this . getInputData ( ) ] ;
169+ }
168170}
0 commit comments