@reduck-ai/n8n-nodes-reduck 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/dist/credentials/ReduckApi.credentials.d.ts +2 -2
- package/dist/credentials/ReduckApi.credentials.js +25 -6
- package/dist/credentials/ReduckApi.credentials.js.map +1 -1
- package/dist/credentials/ReduckOAuth2Api.credentials.d.ts +9 -0
- package/dist/credentials/ReduckOAuth2Api.credentials.js +31 -0
- package/dist/credentials/ReduckOAuth2Api.credentials.js.map +1 -0
- package/dist/nodes/Reduck/Reduck.node.js +36 -93
- package/dist/nodes/Reduck/Reduck.node.js.map +1 -1
- package/dist/nodes/Reduck/methods.d.ts +1 -0
- package/dist/nodes/Reduck/methods.js +19 -14
- package/dist/nodes/Reduck/methods.js.map +1 -1
- package/dist/nodes/Reduck/transport.d.ts +4 -2
- package/dist/nodes/Reduck/transport.js +14 -4
- package/dist/nodes/Reduck/transport.js.map +1 -1
- package/dist/package.json +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -13,21 +13,26 @@ On a self-hosted n8n, go to **Settings > Community nodes** and install
|
|
|
13
13
|
|
|
14
14
|
## Credentials
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
2. In n8n, create a **Reduck API** credential and paste the key.
|
|
16
|
+
Choose one in the node's **Authentication** field:
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
- **API Key** (the default): in the Reduck dashboard, open [API keys](https://reduck.ai/api-keys)
|
|
19
|
+
and create a key. Then create a **Reduck API** credential in n8n and paste the key. Keep the
|
|
20
|
+
default **Reduck URL**.
|
|
21
|
+
- **OAuth2**: create a **Reduck OAuth2 API** credential and select **Connect**. Sign in to Reduck
|
|
22
|
+
and approve n8n. There is no client ID or secret to enter.
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
## Run a script
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
The node runs a script, waits until the run finishes, and returns the run.
|
|
24
27
|
|
|
25
28
|
- **Script**: pick one from the list (your scripts, your projects' scripts and the official
|
|
26
29
|
catalogue), or give its address, such as `reduck/news.ycombinator.com/top_stories`.
|
|
27
30
|
- **Arguments**: one field for each argument the script takes, read from the script itself.
|
|
31
|
+
- **Files**: a script that takes a file shows one field for each file input, such as
|
|
32
|
+
`attachment (binary property)`. Write the name of the binary property of the input item that
|
|
33
|
+
holds the file, for example `data`. The page gets the file with the name of the input. A file can
|
|
34
|
+
be approximately 3 MB.
|
|
28
35
|
- **Browser**: a Reduck managed browser (the default), or one of your paired browsers.
|
|
29
|
-
- **Wait for Result**: on by default. The node waits until the run finishes, up to **Timeout**.
|
|
30
|
-
Turn it off to get the run right away, and read it later with **Run > Get**.
|
|
31
36
|
|
|
32
37
|
The output is the run. `result` holds what the script returned:
|
|
33
38
|
|
|
@@ -44,10 +49,6 @@ The output is the run. `result` holds what the script returned:
|
|
|
44
49
|
If the script fails, the node fails with the script's message. Turn on **Continue On Fail** to get
|
|
45
50
|
`{ "error": "…" }` instead.
|
|
46
51
|
|
|
47
|
-
### Run > Get
|
|
48
|
-
|
|
49
|
-
Reads a run by its ID. Use it after a **Script > Run** with **Wait for Result** turned off.
|
|
50
|
-
|
|
51
52
|
## Use it as an AI agent tool
|
|
52
53
|
|
|
53
54
|
Connect the **Reduck Tool** to an **AI Agent** node. Pick the script, and let the agent fill the
|
|
@@ -55,7 +56,6 @@ arguments: select the sparkle icon next to a field, or use `{{ $fromAI('query')
|
|
|
55
56
|
|
|
56
57
|
## Not supported yet
|
|
57
58
|
|
|
58
|
-
- Scripts that take a file as input.
|
|
59
59
|
- Running several scripts in one call.
|
|
60
60
|
|
|
61
61
|
## Compatibility
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IAuthenticate, Icon, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
export declare class ReduckApi implements ICredentialType {
|
|
3
3
|
name: string;
|
|
4
4
|
displayName: string;
|
|
5
5
|
icon: Icon;
|
|
6
6
|
documentationUrl: string;
|
|
7
7
|
properties: INodeProperties[];
|
|
8
|
-
authenticate:
|
|
8
|
+
authenticate: IAuthenticate;
|
|
9
9
|
test: ICredentialTestRequest;
|
|
10
10
|
}
|
|
@@ -17,16 +17,35 @@ class ReduckApi {
|
|
|
17
17
|
default: '',
|
|
18
18
|
description: 'Create one in the Reduck dashboard, under <a href="https://reduck.ai/api-keys" target="_blank">API keys</a>',
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
displayName: 'Reduck URL',
|
|
22
|
+
name: 'url',
|
|
23
|
+
type: 'string',
|
|
24
|
+
default: 'https://reduck.ai',
|
|
25
|
+
description: 'Change it only to test against another Reduck environment',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Deployment Protection Bypass',
|
|
29
|
+
name: 'bypassToken',
|
|
30
|
+
type: 'string',
|
|
31
|
+
typeOptions: { password: true },
|
|
32
|
+
default: '',
|
|
33
|
+
description: 'Only for a Reduck test environment behind deployment protection. Leave it empty.',
|
|
34
|
+
},
|
|
20
35
|
];
|
|
21
|
-
this.authenticate = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
headers
|
|
36
|
+
this.authenticate = async (credentials, requestOptions) => ({
|
|
37
|
+
...requestOptions,
|
|
38
|
+
headers: {
|
|
39
|
+
...requestOptions.headers,
|
|
40
|
+
'X-API-Key': credentials.apiKey,
|
|
41
|
+
...(credentials.bypassToken
|
|
42
|
+
? { 'x-vercel-protection-bypass': credentials.bypassToken }
|
|
43
|
+
: {}),
|
|
25
44
|
},
|
|
26
|
-
};
|
|
45
|
+
});
|
|
27
46
|
this.test = {
|
|
28
47
|
request: {
|
|
29
|
-
baseURL: '
|
|
48
|
+
baseURL: '={{$credentials.url.replace(/\\/+$/, "")}}',
|
|
30
49
|
url: '/api/me',
|
|
31
50
|
},
|
|
32
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReduckApi.credentials.js","sourceRoot":"","sources":["../../credentials/ReduckApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,SAAS;IAAtB;QACC,SAAI,GAAG,WAAW,CAAC;QAEnB,gBAAW,GAAG,YAAY,CAAC;QAE3B,SAAI,GAAS,EAAE,KAAK,EAAE,iCAAiC,EAAE,IAAI,EAAE,sCAAsC,EAAE,CAAC;QAExG,qBAAgB,GAAG,2DAA2D,CAAC;QAE/E,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EACV,6GAA6G;aAC9G;
|
|
1
|
+
{"version":3,"file":"ReduckApi.credentials.js","sourceRoot":"","sources":["../../credentials/ReduckApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,SAAS;IAAtB;QACC,SAAI,GAAG,WAAW,CAAC;QAEnB,gBAAW,GAAG,YAAY,CAAC;QAE3B,SAAI,GAAS,EAAE,KAAK,EAAE,iCAAiC,EAAE,IAAI,EAAE,sCAAsC,EAAE,CAAC;QAExG,qBAAgB,GAAG,2DAA2D,CAAC;QAE/E,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EACV,6GAA6G;aAC9G;YACD;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;gBAC5B,WAAW,EAAE,2DAA2D;aACxE;YACD;gBACC,WAAW,EAAE,8BAA8B;gBAC3C,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,kFAAkF;aAC/F;SACD,CAAC;QAIF,iBAAY,GAAkB,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;YACrE,GAAG,cAAc;YACjB,OAAO,EAAE;gBACR,GAAG,cAAc,CAAC,OAAO;gBACzB,WAAW,EAAE,WAAW,CAAC,MAAgB;gBACzC,GAAG,CAAC,WAAW,CAAC,WAAW;oBAC1B,CAAC,CAAC,EAAE,4BAA4B,EAAE,WAAW,CAAC,WAAqB,EAAE;oBACrE,CAAC,CAAC,EAAE,CAAC;aACN;SACD,CAAC,CAAC;QAEH,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,4CAA4C;gBACrD,GAAG,EAAE,SAAS;aACd;SACD,CAAC;IACH,CAAC;CAAA;AAxDD,8BAwDC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Icon, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class ReduckOAuth2Api implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
extends: string[];
|
|
5
|
+
displayName: string;
|
|
6
|
+
icon: Icon;
|
|
7
|
+
documentationUrl: string;
|
|
8
|
+
properties: INodeProperties[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReduckOAuth2Api = void 0;
|
|
4
|
+
class ReduckOAuth2Api {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'reduckOAuth2Api';
|
|
7
|
+
this.extends = ['oAuth2Api'];
|
|
8
|
+
this.displayName = 'Reduck OAuth2 API';
|
|
9
|
+
this.icon = {
|
|
10
|
+
light: 'file:../nodes/Reduck/reduck.svg',
|
|
11
|
+
dark: 'file:../nodes/Reduck/reduck.dark.svg',
|
|
12
|
+
};
|
|
13
|
+
this.documentationUrl = 'https://github.com/reduck-ai/n8n-nodes-reduck#credentials';
|
|
14
|
+
this.properties = [
|
|
15
|
+
{
|
|
16
|
+
displayName: 'Use Dynamic Client Registration',
|
|
17
|
+
name: 'useDynamicClientRegistration',
|
|
18
|
+
type: 'hidden',
|
|
19
|
+
default: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
displayName: 'Server URL',
|
|
23
|
+
name: 'serverUrl',
|
|
24
|
+
type: 'hidden',
|
|
25
|
+
default: 'https://reduck.ai',
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ReduckOAuth2Api = ReduckOAuth2Api;
|
|
31
|
+
//# sourceMappingURL=ReduckOAuth2Api.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReduckOAuth2Api.credentials.js","sourceRoot":"","sources":["../../credentials/ReduckOAuth2Api.credentials.ts"],"names":[],"mappings":";;;AAKA,MAAa,eAAe;IAA5B;QACC,SAAI,GAAG,iBAAiB,CAAC;QAEzB,YAAO,GAAG,CAAC,WAAW,CAAC,CAAC;QAExB,gBAAW,GAAG,mBAAmB,CAAC;QAElC,SAAI,GAAS;YACZ,KAAK,EAAE,iCAAiC;YACxC,IAAI,EAAE,sCAAsC;SAC5C,CAAC;QAEF,qBAAgB,GAAG,2DAA2D,CAAC;QAE/E,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,iCAAiC;gBAC9C,IAAI,EAAE,8BAA8B;gBACpC,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,IAAI;aACb;YACD;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,mBAAmB;aAC5B;SACD,CAAC;IACH,CAAC;CAAA;AA5BD,0CA4BC"}
|
|
@@ -5,7 +5,6 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
5
5
|
const methods_1 = require("./methods");
|
|
6
6
|
const transport_1 = require("./transport");
|
|
7
7
|
const POLL_MS = 2000;
|
|
8
|
-
const SERVER_WAIT_SECONDS = 45;
|
|
9
8
|
class Reduck {
|
|
10
9
|
constructor() {
|
|
11
10
|
this.description = {
|
|
@@ -14,56 +13,34 @@ class Reduck {
|
|
|
14
13
|
icon: { light: 'file:reduck.svg', dark: 'file:reduck.dark.svg' },
|
|
15
14
|
group: ['transform'],
|
|
16
15
|
version: 1,
|
|
17
|
-
subtitle: '={{$parameter["
|
|
16
|
+
subtitle: '={{$parameter["script"].value}}',
|
|
18
17
|
description: 'Run Reduck browser scripts on any website',
|
|
19
18
|
defaults: { name: 'Reduck' },
|
|
20
19
|
usableAsTool: true,
|
|
21
20
|
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
22
21
|
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
23
|
-
credentials: [
|
|
24
|
-
properties: [
|
|
22
|
+
credentials: [
|
|
25
23
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
noDataExpression: true,
|
|
30
|
-
options: [
|
|
31
|
-
{ name: 'Script', value: 'script' },
|
|
32
|
-
{ name: 'Run', value: 'run' },
|
|
33
|
-
],
|
|
34
|
-
default: 'script',
|
|
24
|
+
name: 'reduckApi',
|
|
25
|
+
required: true,
|
|
26
|
+
displayOptions: { show: { authentication: ['apiKey'] } },
|
|
35
27
|
},
|
|
36
28
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
noDataExpression: true,
|
|
41
|
-
displayOptions: { show: { resource: ['script'] } },
|
|
42
|
-
options: [
|
|
43
|
-
{
|
|
44
|
-
name: 'Run',
|
|
45
|
-
value: 'run',
|
|
46
|
-
description: 'Run a script and get its result',
|
|
47
|
-
action: 'Run a script',
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
default: 'run',
|
|
29
|
+
name: 'reduckOAuth2Api',
|
|
30
|
+
required: true,
|
|
31
|
+
displayOptions: { show: { authentication: ['oAuth2'] } },
|
|
51
32
|
},
|
|
33
|
+
],
|
|
34
|
+
properties: [
|
|
52
35
|
{
|
|
53
|
-
displayName: '
|
|
54
|
-
name: '
|
|
36
|
+
displayName: 'Authentication',
|
|
37
|
+
name: 'authentication',
|
|
55
38
|
type: 'options',
|
|
56
|
-
noDataExpression: true,
|
|
57
|
-
displayOptions: { show: { resource: ['run'] } },
|
|
58
39
|
options: [
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
value: 'get',
|
|
62
|
-
description: 'Get a run and its result',
|
|
63
|
-
action: 'Get a run',
|
|
64
|
-
},
|
|
40
|
+
{ name: 'API Key', value: 'apiKey' },
|
|
41
|
+
{ name: 'OAuth2', value: 'oAuth2' },
|
|
65
42
|
],
|
|
66
|
-
default: '
|
|
43
|
+
default: 'apiKey',
|
|
67
44
|
},
|
|
68
45
|
{
|
|
69
46
|
displayName: 'Script',
|
|
@@ -72,7 +49,6 @@ class Reduck {
|
|
|
72
49
|
default: { mode: 'list', value: '' },
|
|
73
50
|
required: true,
|
|
74
51
|
description: 'The script to run',
|
|
75
|
-
displayOptions: { show: { resource: ['script'], operation: ['run'] } },
|
|
76
52
|
modes: [
|
|
77
53
|
{
|
|
78
54
|
displayName: 'From List',
|
|
@@ -118,10 +94,7 @@ class Reduck {
|
|
|
118
94
|
noFieldsError: 'This script takes no arguments',
|
|
119
95
|
},
|
|
120
96
|
},
|
|
121
|
-
displayOptions: {
|
|
122
|
-
show: { resource: ['script'], operation: ['run'] },
|
|
123
|
-
hide: { script: [''] },
|
|
124
|
-
},
|
|
97
|
+
displayOptions: { hide: { script: [''] } },
|
|
125
98
|
},
|
|
126
99
|
{
|
|
127
100
|
displayName: 'Browser Name or ID',
|
|
@@ -130,7 +103,6 @@ class Reduck {
|
|
|
130
103
|
typeOptions: { loadOptionsMethod: 'getDevices' },
|
|
131
104
|
default: '',
|
|
132
105
|
description: 'Where the script runs: a Reduck managed browser, or one of your paired browsers. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
133
|
-
displayOptions: { show: { resource: ['script'], operation: ['run'] } },
|
|
134
106
|
},
|
|
135
107
|
{
|
|
136
108
|
displayName: 'Region',
|
|
@@ -144,7 +116,7 @@ class Reduck {
|
|
|
144
116
|
],
|
|
145
117
|
default: 'eu-central-1',
|
|
146
118
|
description: 'The datacenter of the managed browser: Europe (Frankfurt) by default. Choose the one nearest to the site.',
|
|
147
|
-
displayOptions: { show: {
|
|
119
|
+
displayOptions: { show: { deviceId: [''] } },
|
|
148
120
|
},
|
|
149
121
|
{
|
|
150
122
|
displayName: 'Country',
|
|
@@ -153,35 +125,7 @@ class Reduck {
|
|
|
153
125
|
default: '',
|
|
154
126
|
placeholder: 'e.g. FR',
|
|
155
127
|
description: 'The ISO 3166 alpha-2 code of the country the managed browser connects to the site from, through a residential proxy. Use it for a site that changes by country. Leave it empty to connect from the datacenter.',
|
|
156
|
-
displayOptions: { show: {
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
displayName: 'Wait for Result',
|
|
160
|
-
name: 'waitForResult',
|
|
161
|
-
type: 'boolean',
|
|
162
|
-
default: true,
|
|
163
|
-
description: 'Whether to wait until the run finishes. Turn it off to get the run right away and read it later with Run > Get.',
|
|
164
|
-
displayOptions: { show: { resource: ['script'], operation: ['run'] } },
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
displayName: 'Timeout (Seconds)',
|
|
168
|
-
name: 'timeout',
|
|
169
|
-
type: 'number',
|
|
170
|
-
typeOptions: { minValue: 1 },
|
|
171
|
-
default: 600,
|
|
172
|
-
description: 'How long to wait for the run before the node fails',
|
|
173
|
-
displayOptions: {
|
|
174
|
-
show: { resource: ['script'], operation: ['run'], waitForResult: [true] },
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
displayName: 'Run ID',
|
|
179
|
-
name: 'runId',
|
|
180
|
-
type: 'string',
|
|
181
|
-
default: '',
|
|
182
|
-
required: true,
|
|
183
|
-
placeholder: 'e.g. 15783c22-bb29-43a6-956f-7ea3d3852c25',
|
|
184
|
-
displayOptions: { show: { resource: ['run'], operation: ['get'] } },
|
|
128
|
+
displayOptions: { show: { deviceId: [''] } },
|
|
185
129
|
},
|
|
186
130
|
],
|
|
187
131
|
};
|
|
@@ -196,14 +140,11 @@ class Reduck {
|
|
|
196
140
|
const out = [];
|
|
197
141
|
for (let i = 0; i < items.length; i++) {
|
|
198
142
|
try {
|
|
199
|
-
const
|
|
200
|
-
const run = resource === 'run'
|
|
201
|
-
? await getRun(this, this.getNodeParameter('runId', i))
|
|
202
|
-
: await runScript(this, i);
|
|
143
|
+
const run = await runScript(this, i);
|
|
203
144
|
if (run.result && 'error' in run.result) {
|
|
204
145
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), run.result.error, {
|
|
205
146
|
itemIndex: i,
|
|
206
|
-
description: `The run's steps and screenshots: ${transport_1.
|
|
147
|
+
description: `The run's steps and screenshots: ${await (0, transport_1.reduckUrl)(this)}/runs/${run.id}`,
|
|
207
148
|
});
|
|
208
149
|
}
|
|
209
150
|
out.push({ json: toItem(run), pairedItem: { item: i } });
|
|
@@ -231,37 +172,39 @@ async function runScript(ctx, i) {
|
|
|
231
172
|
});
|
|
232
173
|
}
|
|
233
174
|
const form = (_a = ctx.getNodeParameter('args', i, {}).value) !== null && _a !== void 0 ? _a : {};
|
|
234
|
-
const args =
|
|
175
|
+
const args = {};
|
|
176
|
+
const files = {};
|
|
177
|
+
for (const [key, value] of Object.entries(form)) {
|
|
178
|
+
if (value === null || value === undefined || value === '')
|
|
179
|
+
continue;
|
|
180
|
+
if (!key.startsWith(methods_1.FILE_FIELD)) {
|
|
181
|
+
args[key] = value;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const property = String(value);
|
|
185
|
+
const { mimeType } = ctx.helpers.assertBinaryData(i, property);
|
|
186
|
+
const bytes = await ctx.helpers.getBinaryDataBuffer(i, property);
|
|
187
|
+
files[key.slice(methods_1.FILE_FIELD.length)] = { b64: bytes.toString('base64'), mime: mimeType };
|
|
188
|
+
}
|
|
235
189
|
const deviceId = ctx.getNodeParameter('deviceId', i, '');
|
|
236
190
|
const region = ctx.getNodeParameter('region', i, '');
|
|
237
191
|
const country = ctx.getNodeParameter('country', i, '').trim();
|
|
238
|
-
const waitForResult = ctx.getNodeParameter('waitForResult', i, true);
|
|
239
192
|
const scriptPath = [script.handle, script.host, script.slug].map(encodeURIComponent).join('/');
|
|
240
193
|
let run = await (0, transport_1.reduckRequest)(ctx, 'POST', `/api/scripts/${scriptPath}/runs`, {
|
|
241
194
|
body: {
|
|
242
195
|
args,
|
|
196
|
+
...(Object.keys(files).length ? { files } : {}),
|
|
243
197
|
...(deviceId
|
|
244
198
|
? { device_id: deviceId }
|
|
245
199
|
: { ...(region ? { region } : {}), ...(country ? { country } : {}) }),
|
|
246
|
-
wait_seconds: waitForResult ? SERVER_WAIT_SECONDS : 0,
|
|
247
200
|
},
|
|
248
201
|
});
|
|
249
|
-
if (!waitForResult)
|
|
250
|
-
return run;
|
|
251
|
-
const deadline = Date.now() + ctx.getNodeParameter('timeout', i, 600) * 1000;
|
|
252
202
|
while (run.finished_at === null) {
|
|
253
|
-
if (Date.now() > deadline) {
|
|
254
|
-
throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `The run did not finish in time. Run ID: ${run.id}`, {
|
|
255
|
-
itemIndex: i,
|
|
256
|
-
description: 'Read it later with Run > Get, or raise the timeout.',
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
203
|
await (0, n8n_workflow_1.sleep)(POLL_MS);
|
|
260
|
-
run = await
|
|
204
|
+
run = await (0, transport_1.reduckRequest)(ctx, 'GET', `/api/runs/${encodeURIComponent(run.id)}`);
|
|
261
205
|
}
|
|
262
206
|
return run;
|
|
263
207
|
}
|
|
264
|
-
const getRun = (ctx, runId) => (0, transport_1.reduckRequest)(ctx, 'GET', `/api/runs/${encodeURIComponent(runId)}`);
|
|
265
208
|
const toItem = (run) => ({
|
|
266
209
|
...run,
|
|
267
210
|
result: run.result && 'result' in run.result ? run.result.result : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reduck.node.js","sourceRoot":"","sources":["../../../nodes/Reduck/Reduck.node.ts"],"names":[],"mappings":";;;AAAA,+CAWsB;AAEtB,
|
|
1
|
+
{"version":3,"file":"Reduck.node.js","sourceRoot":"","sources":["../../../nodes/Reduck/Reduck.node.ts"],"names":[],"mappings":";;;AAAA,+CAWsB;AAEtB,uCAAiF;AACjF,2CAAqF;AAErF,MAAM,OAAO,GAAG,IAAI,CAAC;AAErB,MAAa,MAAM;IAAnB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,QAAQ;YACrB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,sBAAsB,EAAE;YAChE,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,iCAAiC;YAC3C,WAAW,EAAE,2CAA2C;YACxD,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC5B,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,WAAW;oBACjB,QAAQ,EAAE,IAAI;oBACd,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,cAAc,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE;iBACxD;gBACD;oBACC,IAAI,EAAE,iBAAiB;oBACvB,Q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G,MAAM,IAAA,yBAAa,EAAM,GAAG,EAAE,MAAM,EAAE,gBAAgB,UAAU,OAAO,EAAE;QAClF,IAAI,EAAE;YACL,IAAI;YACJ,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAE/C,GAAG,CAAC,QAAQ;gBACX,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;gBACzB,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;SACtE;KACD,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QACjC,MAAM,IAAA,oBAAK,EAAC,OAAO,CAAC,CAAC;QACrB,GAAG,GAAG,MAAM,IAAA,yBAAa,EAAM,GAAG,EAAE,KAAK,EAAE,aAAa,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAGD,MAAM,MAAM,GAAG,CAAC,GAAQ,EAAe,EAAE,CAAC,CAAC;IAC1C,GAAG,GAAG;IACN,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAE,GAAG,CAAC,MAAM,CAAC,MAAsB,CAAC,CAAC,CAAC,IAAI;CACxF,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ILoadOptionsFunctions, type INodeListSearchResult, type INodePropertyOptions, type ResourceMapperFields } from 'n8n-workflow';
|
|
2
|
+
export declare const FILE_FIELD = "file:";
|
|
2
3
|
export declare function searchScripts(this: ILoadOptionsFunctions, filter?: string, paginationToken?: string): Promise<INodeListSearchResult>;
|
|
3
4
|
export declare function getScriptArgs(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
|
|
4
5
|
export declare function getDevices(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FILE_FIELD = void 0;
|
|
3
4
|
exports.searchScripts = searchScripts;
|
|
4
5
|
exports.getScriptArgs = getScriptArgs;
|
|
5
6
|
exports.getDevices = getDevices;
|
|
6
7
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
8
|
const transport_1 = require("./transport");
|
|
9
|
+
exports.FILE_FIELD = 'file:';
|
|
8
10
|
const PAGE_SIZE = 50;
|
|
9
11
|
async function searchScripts(filter, paginationToken) {
|
|
10
12
|
const page = paginationToken ? Number(paginationToken) : 0;
|
|
13
|
+
const origin = await (0, transport_1.reduckUrl)(this);
|
|
11
14
|
const answer = await (0, transport_1.reduckRequest)(this, 'GET', '/api/scripts', {
|
|
12
15
|
qs: { page, page_size: PAGE_SIZE, ...(filter ? { q: filter } : {}) },
|
|
13
16
|
});
|
|
@@ -17,7 +20,7 @@ async function searchScripts(filter, paginationToken) {
|
|
|
17
20
|
return {
|
|
18
21
|
name: `${script.name} (${address})`,
|
|
19
22
|
value: address,
|
|
20
|
-
url: `${
|
|
23
|
+
url: `${origin}/explore/scripts/${address}`,
|
|
21
24
|
};
|
|
22
25
|
}),
|
|
23
26
|
paginationToken: answer.has_next_page ? String(page + 1) : undefined,
|
|
@@ -59,19 +62,21 @@ async function getScriptArgs() {
|
|
|
59
62
|
}
|
|
60
63
|
const schema = (_b = (_a = answer.current_version) === null || _a === void 0 ? void 0 : _a.input_schema) !== null && _b !== void 0 ? _b : {};
|
|
61
64
|
const required = new Set((_c = schema.required) !== null && _c !== void 0 ? _c : []);
|
|
62
|
-
const fields = Object.entries((_d = schema.properties) !== null && _d !== void 0 ? _d : {})
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
const fields = Object.entries((_d = schema.properties) !== null && _d !== void 0 ? _d : {}).map(([name, property]) => {
|
|
66
|
+
const field = { required: required.has(name), defaultMatch: false, display: true };
|
|
67
|
+
if (property.format === 'file') {
|
|
68
|
+
return { ...field, id: `${exports.FILE_FIELD}${name}`, displayName: `${name} (binary property)`, type: 'string' };
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
...field,
|
|
72
|
+
id: name,
|
|
73
|
+
displayName: name,
|
|
74
|
+
type: fieldType(property),
|
|
75
|
+
...(property.enum
|
|
76
|
+
? { options: property.enum.map((value) => ({ name: String(value), value: String(value) })) }
|
|
77
|
+
: {}),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
75
80
|
return { fields };
|
|
76
81
|
}
|
|
77
82
|
async function getDevices() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../nodes/Reduck/methods.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../nodes/Reduck/methods.ts"],"names":[],"mappings":";;;AA0CA,sCAsBC;AAsBD,sCAsCC;AAGD,gCAMC;AArID,+CAQsB;AAEtB,2CAA2E;AAI9D,QAAA,UAAU,GAAG,OAAO,CAAC;AAsBlC,MAAM,SAAS,GAAG,EAAE,CAAC;AAMd,KAAK,UAAU,aAAa,CAElC,MAAe,EACf,eAAwB;IAGxB,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,MAAM,I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I,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7G,OAAO;QACN,EAAE,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,EAAE,EAAE;QAC7C,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,WAAC,OAAA,CAAC,EAAE,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA,EAAA,CAAC;KAClF,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type IDataObject, type IExecuteFunctions, type IHttpRequestMethods, type ILoadOptionsFunctions } from 'n8n-workflow';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
type Ctx = IExecuteFunctions | ILoadOptionsFunctions;
|
|
3
|
+
export declare function reduckUrl(ctx: Ctx): Promise<string>;
|
|
4
|
+
export declare function reduckRequest<T>(ctx: Ctx, method: IHttpRequestMethods, path: string, options?: {
|
|
4
5
|
body?: IDataObject;
|
|
5
6
|
qs?: IDataObject;
|
|
6
7
|
}): Promise<T>;
|
|
@@ -21,3 +22,4 @@ export interface Run {
|
|
|
21
22
|
finished_at: string | null;
|
|
22
23
|
[key: string]: unknown;
|
|
23
24
|
}
|
|
25
|
+
export {};
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.reduckUrl = reduckUrl;
|
|
4
4
|
exports.reduckRequest = reduckRequest;
|
|
5
5
|
exports.parseScriptAddress = parseScriptAddress;
|
|
6
6
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
|
-
|
|
7
|
+
const credentialOf = (ctx) => {
|
|
8
|
+
const authentication = 'getCurrentNodeParameter' in ctx
|
|
9
|
+
? ctx.getCurrentNodeParameter('authentication')
|
|
10
|
+
: ctx.getNodeParameter('authentication', 0);
|
|
11
|
+
return authentication === 'oAuth2' ? 'reduckOAuth2Api' : 'reduckApi';
|
|
12
|
+
};
|
|
13
|
+
async function reduckUrl(ctx) {
|
|
14
|
+
const { url, serverUrl } = await ctx.getCredentials(credentialOf(ctx));
|
|
15
|
+
return (url || serverUrl || 'https://reduck.ai').replace(/\/+$/, '');
|
|
16
|
+
}
|
|
8
17
|
async function reduckRequest(ctx, method, path, options = {}) {
|
|
9
18
|
var _a, _b;
|
|
19
|
+
const url = `${await reduckUrl(ctx)}${path}`;
|
|
10
20
|
try {
|
|
11
|
-
return (await ctx.helpers.httpRequestWithAuthentication.call(ctx,
|
|
21
|
+
return (await ctx.helpers.httpRequestWithAuthentication.call(ctx, credentialOf(ctx), {
|
|
12
22
|
method,
|
|
13
|
-
url
|
|
23
|
+
url,
|
|
14
24
|
json: true,
|
|
15
25
|
...options,
|
|
16
26
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../nodes/Reduck/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../nodes/Reduck/transport.ts"],"names":[],"mappings":";;AAwBA,8BAKC;AAGD,sCA2BC;AAGD,gDAIC;AAlED,+CAOsB;AAMtB,MAAM,YAAY,GAAG,CAAC,GAAQ,EAAU,EAAE;IACzC,MAAM,cAAc,GACnB,yBAAyB,IAAI,GAAG;QAC/B,CAAC,CAAC,GAAG,CAAC,uBAAuB,CAAC,gBAAgB,CAAC;QAC/C,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;IAC9C,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC;AACtE,CAAC,CAAC;AAKK,KAAK,UAAU,SAAS,CAAC,GAAQ;IACvC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG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AAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAC1D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC/B,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reduck-ai/n8n-nodes-reduck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Run your Reduck browser scripts in n8n workflows and AI agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/reduck-ai/n8n-nodes-reduck#readme",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"n8nNodesApiVersion": 1,
|
|
40
40
|
"strict": true,
|
|
41
41
|
"credentials": [
|
|
42
|
-
"dist/credentials/ReduckApi.credentials.js"
|
|
42
|
+
"dist/credentials/ReduckApi.credentials.js",
|
|
43
|
+
"dist/credentials/ReduckOAuth2Api.credentials.js"
|
|
43
44
|
],
|
|
44
45
|
"nodes": [
|
|
45
46
|
"dist/nodes/Reduck/Reduck.node.js"
|